pdf.js 828 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 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 /******/ (() => { // webpackBootstrap
  33. /******/ var __webpack_modules__ = ([
  34. /* 0 */
  35. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  36. "use strict";
  37. Object.defineProperty(exports, "__esModule", ({
  38. value: true
  39. }));
  40. Object.defineProperty(exports, "addLinkAttributes", ({
  41. enumerable: true,
  42. get: function get() {
  43. return _display_utils.addLinkAttributes;
  44. }
  45. }));
  46. Object.defineProperty(exports, "getFilenameFromUrl", ({
  47. enumerable: true,
  48. get: function get() {
  49. return _display_utils.getFilenameFromUrl;
  50. }
  51. }));
  52. Object.defineProperty(exports, "LinkTarget", ({
  53. enumerable: true,
  54. get: function get() {
  55. return _display_utils.LinkTarget;
  56. }
  57. }));
  58. Object.defineProperty(exports, "loadScript", ({
  59. enumerable: true,
  60. get: function get() {
  61. return _display_utils.loadScript;
  62. }
  63. }));
  64. Object.defineProperty(exports, "PDFDateString", ({
  65. enumerable: true,
  66. get: function get() {
  67. return _display_utils.PDFDateString;
  68. }
  69. }));
  70. Object.defineProperty(exports, "RenderingCancelledException", ({
  71. enumerable: true,
  72. get: function get() {
  73. return _display_utils.RenderingCancelledException;
  74. }
  75. }));
  76. Object.defineProperty(exports, "build", ({
  77. enumerable: true,
  78. get: function get() {
  79. return _api.build;
  80. }
  81. }));
  82. Object.defineProperty(exports, "getDocument", ({
  83. enumerable: true,
  84. get: function get() {
  85. return _api.getDocument;
  86. }
  87. }));
  88. Object.defineProperty(exports, "LoopbackPort", ({
  89. enumerable: true,
  90. get: function get() {
  91. return _api.LoopbackPort;
  92. }
  93. }));
  94. Object.defineProperty(exports, "PDFDataRangeTransport", ({
  95. enumerable: true,
  96. get: function get() {
  97. return _api.PDFDataRangeTransport;
  98. }
  99. }));
  100. Object.defineProperty(exports, "PDFWorker", ({
  101. enumerable: true,
  102. get: function get() {
  103. return _api.PDFWorker;
  104. }
  105. }));
  106. Object.defineProperty(exports, "version", ({
  107. enumerable: true,
  108. get: function get() {
  109. return _api.version;
  110. }
  111. }));
  112. Object.defineProperty(exports, "CMapCompressionType", ({
  113. enumerable: true,
  114. get: function get() {
  115. return _util.CMapCompressionType;
  116. }
  117. }));
  118. Object.defineProperty(exports, "createObjectURL", ({
  119. enumerable: true,
  120. get: function get() {
  121. return _util.createObjectURL;
  122. }
  123. }));
  124. Object.defineProperty(exports, "createPromiseCapability", ({
  125. enumerable: true,
  126. get: function get() {
  127. return _util.createPromiseCapability;
  128. }
  129. }));
  130. Object.defineProperty(exports, "createValidAbsoluteUrl", ({
  131. enumerable: true,
  132. get: function get() {
  133. return _util.createValidAbsoluteUrl;
  134. }
  135. }));
  136. Object.defineProperty(exports, "InvalidPDFException", ({
  137. enumerable: true,
  138. get: function get() {
  139. return _util.InvalidPDFException;
  140. }
  141. }));
  142. Object.defineProperty(exports, "MissingPDFException", ({
  143. enumerable: true,
  144. get: function get() {
  145. return _util.MissingPDFException;
  146. }
  147. }));
  148. Object.defineProperty(exports, "OPS", ({
  149. enumerable: true,
  150. get: function get() {
  151. return _util.OPS;
  152. }
  153. }));
  154. Object.defineProperty(exports, "PasswordResponses", ({
  155. enumerable: true,
  156. get: function get() {
  157. return _util.PasswordResponses;
  158. }
  159. }));
  160. Object.defineProperty(exports, "PermissionFlag", ({
  161. enumerable: true,
  162. get: function get() {
  163. return _util.PermissionFlag;
  164. }
  165. }));
  166. Object.defineProperty(exports, "removeNullCharacters", ({
  167. enumerable: true,
  168. get: function get() {
  169. return _util.removeNullCharacters;
  170. }
  171. }));
  172. Object.defineProperty(exports, "shadow", ({
  173. enumerable: true,
  174. get: function get() {
  175. return _util.shadow;
  176. }
  177. }));
  178. Object.defineProperty(exports, "UnexpectedResponseException", ({
  179. enumerable: true,
  180. get: function get() {
  181. return _util.UnexpectedResponseException;
  182. }
  183. }));
  184. Object.defineProperty(exports, "UNSUPPORTED_FEATURES", ({
  185. enumerable: true,
  186. get: function get() {
  187. return _util.UNSUPPORTED_FEATURES;
  188. }
  189. }));
  190. Object.defineProperty(exports, "Util", ({
  191. enumerable: true,
  192. get: function get() {
  193. return _util.Util;
  194. }
  195. }));
  196. Object.defineProperty(exports, "VerbosityLevel", ({
  197. enumerable: true,
  198. get: function get() {
  199. return _util.VerbosityLevel;
  200. }
  201. }));
  202. Object.defineProperty(exports, "AnnotationLayer", ({
  203. enumerable: true,
  204. get: function get() {
  205. return _annotation_layer.AnnotationLayer;
  206. }
  207. }));
  208. Object.defineProperty(exports, "apiCompatibilityParams", ({
  209. enumerable: true,
  210. get: function get() {
  211. return _api_compatibility.apiCompatibilityParams;
  212. }
  213. }));
  214. Object.defineProperty(exports, "GlobalWorkerOptions", ({
  215. enumerable: true,
  216. get: function get() {
  217. return _worker_options.GlobalWorkerOptions;
  218. }
  219. }));
  220. Object.defineProperty(exports, "renderTextLayer", ({
  221. enumerable: true,
  222. get: function get() {
  223. return _text_layer.renderTextLayer;
  224. }
  225. }));
  226. Object.defineProperty(exports, "SVGGraphics", ({
  227. enumerable: true,
  228. get: function get() {
  229. return _svg.SVGGraphics;
  230. }
  231. }));
  232. var _display_utils = __w_pdfjs_require__(1);
  233. var _api = __w_pdfjs_require__(135);
  234. var _util = __w_pdfjs_require__(4);
  235. var _annotation_layer = __w_pdfjs_require__(149);
  236. var _api_compatibility = __w_pdfjs_require__(139);
  237. var _worker_options = __w_pdfjs_require__(142);
  238. var _text_layer = __w_pdfjs_require__(151);
  239. var _svg = __w_pdfjs_require__(152);
  240. var pdfjsVersion = '2.7.570';
  241. var pdfjsBuild = 'f2c7338b0';
  242. {
  243. var _require = __w_pdfjs_require__(6),
  244. isNodeJS = _require.isNodeJS;
  245. if (isNodeJS) {
  246. var PDFNodeStream = __w_pdfjs_require__(153).PDFNodeStream;
  247. (0, _api.setPDFNetworkStreamFactory)(function (params) {
  248. return new PDFNodeStream(params);
  249. });
  250. } else {
  251. var PDFNetworkStream = __w_pdfjs_require__(156).PDFNetworkStream;
  252. var PDFFetchStream;
  253. if ((0, _display_utils.isFetchSupported)()) {
  254. PDFFetchStream = __w_pdfjs_require__(157).PDFFetchStream;
  255. }
  256. (0, _api.setPDFNetworkStreamFactory)(function (params) {
  257. if (PDFFetchStream && (0, _display_utils.isValidFetchUrl)(params.url)) {
  258. return new PDFFetchStream(params);
  259. }
  260. return new PDFNetworkStream(params);
  261. });
  262. }
  263. }
  264. /***/ }),
  265. /* 1 */
  266. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  267. "use strict";
  268. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  269. Object.defineProperty(exports, "__esModule", ({
  270. value: true
  271. }));
  272. exports.addLinkAttributes = addLinkAttributes;
  273. exports.deprecated = deprecated;
  274. exports.getFilenameFromUrl = getFilenameFromUrl;
  275. exports.isFetchSupported = isFetchSupported;
  276. exports.isValidFetchUrl = isValidFetchUrl;
  277. exports.loadScript = loadScript;
  278. exports.StatTimer = exports.RenderingCancelledException = exports.PDFDateString = exports.PageViewport = exports.LinkTarget = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.BaseCMapReaderFactory = exports.BaseCanvasFactory = void 0;
  279. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  280. var _util = __w_pdfjs_require__(4);
  281. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  282. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  283. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  284. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  285. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  286. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  287. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  288. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  289. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  290. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  291. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  292. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  293. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  294. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  295. 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); } }
  296. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  297. var DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  298. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  299. var SVG_NS = "http://www.w3.org/2000/svg";
  300. var BaseCanvasFactory = /*#__PURE__*/function () {
  301. function BaseCanvasFactory() {
  302. _classCallCheck(this, BaseCanvasFactory);
  303. if (this.constructor === BaseCanvasFactory) {
  304. (0, _util.unreachable)("Cannot initialize BaseCanvasFactory.");
  305. }
  306. }
  307. _createClass(BaseCanvasFactory, [{
  308. key: "create",
  309. value: function create(width, height) {
  310. (0, _util.unreachable)("Abstract method `create` called.");
  311. }
  312. }, {
  313. key: "reset",
  314. value: function reset(canvasAndContext, width, height) {
  315. if (!canvasAndContext.canvas) {
  316. throw new Error("Canvas is not specified");
  317. }
  318. if (width <= 0 || height <= 0) {
  319. throw new Error("Invalid canvas size");
  320. }
  321. canvasAndContext.canvas.width = width;
  322. canvasAndContext.canvas.height = height;
  323. }
  324. }, {
  325. key: "destroy",
  326. value: function destroy(canvasAndContext) {
  327. if (!canvasAndContext.canvas) {
  328. throw new Error("Canvas is not specified");
  329. }
  330. canvasAndContext.canvas.width = 0;
  331. canvasAndContext.canvas.height = 0;
  332. canvasAndContext.canvas = null;
  333. canvasAndContext.context = null;
  334. }
  335. }]);
  336. return BaseCanvasFactory;
  337. }();
  338. exports.BaseCanvasFactory = BaseCanvasFactory;
  339. var DOMCanvasFactory = /*#__PURE__*/function (_BaseCanvasFactory) {
  340. _inherits(DOMCanvasFactory, _BaseCanvasFactory);
  341. var _super = _createSuper(DOMCanvasFactory);
  342. function DOMCanvasFactory() {
  343. var _this;
  344. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  345. _ref$ownerDocument = _ref.ownerDocument,
  346. ownerDocument = _ref$ownerDocument === void 0 ? globalThis.document : _ref$ownerDocument;
  347. _classCallCheck(this, DOMCanvasFactory);
  348. _this = _super.call(this);
  349. _this._document = ownerDocument;
  350. return _this;
  351. }
  352. _createClass(DOMCanvasFactory, [{
  353. key: "create",
  354. value: function create(width, height) {
  355. if (width <= 0 || height <= 0) {
  356. throw new Error("Invalid canvas size");
  357. }
  358. var canvas = this._document.createElement("canvas");
  359. var context = canvas.getContext("2d");
  360. canvas.width = width;
  361. canvas.height = height;
  362. return {
  363. canvas: canvas,
  364. context: context
  365. };
  366. }
  367. }]);
  368. return DOMCanvasFactory;
  369. }(BaseCanvasFactory);
  370. exports.DOMCanvasFactory = DOMCanvasFactory;
  371. var BaseCMapReaderFactory = /*#__PURE__*/function () {
  372. function BaseCMapReaderFactory(_ref2) {
  373. var _ref2$baseUrl = _ref2.baseUrl,
  374. baseUrl = _ref2$baseUrl === void 0 ? null : _ref2$baseUrl,
  375. _ref2$isCompressed = _ref2.isCompressed,
  376. isCompressed = _ref2$isCompressed === void 0 ? false : _ref2$isCompressed;
  377. _classCallCheck(this, BaseCMapReaderFactory);
  378. if (this.constructor === BaseCMapReaderFactory) {
  379. (0, _util.unreachable)("Cannot initialize BaseCMapReaderFactory.");
  380. }
  381. this.baseUrl = baseUrl;
  382. this.isCompressed = isCompressed;
  383. }
  384. _createClass(BaseCMapReaderFactory, [{
  385. key: "fetch",
  386. value: function () {
  387. var _fetch = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref3) {
  388. var _this2 = this;
  389. var name, url, compressionType;
  390. return _regenerator["default"].wrap(function _callee$(_context) {
  391. while (1) {
  392. switch (_context.prev = _context.next) {
  393. case 0:
  394. name = _ref3.name;
  395. if (this.baseUrl) {
  396. _context.next = 3;
  397. break;
  398. }
  399. throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
  400. case 3:
  401. if (name) {
  402. _context.next = 5;
  403. break;
  404. }
  405. throw new Error("CMap name must be specified.");
  406. case 5:
  407. url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
  408. compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
  409. return _context.abrupt("return", this._fetchData(url, compressionType)["catch"](function (reason) {
  410. throw new Error("Unable to load ".concat(_this2.isCompressed ? "binary " : "", "CMap at: ").concat(url));
  411. }));
  412. case 8:
  413. case "end":
  414. return _context.stop();
  415. }
  416. }
  417. }, _callee, this);
  418. }));
  419. function fetch(_x) {
  420. return _fetch.apply(this, arguments);
  421. }
  422. return fetch;
  423. }()
  424. }, {
  425. key: "_fetchData",
  426. value: function _fetchData(url, compressionType) {
  427. (0, _util.unreachable)("Abstract method `_fetchData` called.");
  428. }
  429. }]);
  430. return BaseCMapReaderFactory;
  431. }();
  432. exports.BaseCMapReaderFactory = BaseCMapReaderFactory;
  433. var DOMCMapReaderFactory = /*#__PURE__*/function (_BaseCMapReaderFactor) {
  434. _inherits(DOMCMapReaderFactory, _BaseCMapReaderFactor);
  435. var _super2 = _createSuper(DOMCMapReaderFactory);
  436. function DOMCMapReaderFactory() {
  437. _classCallCheck(this, DOMCMapReaderFactory);
  438. return _super2.apply(this, arguments);
  439. }
  440. _createClass(DOMCMapReaderFactory, [{
  441. key: "_fetchData",
  442. value: function _fetchData(url, compressionType) {
  443. var _this3 = this;
  444. if (isFetchSupported() && isValidFetchUrl(url, document.baseURI)) {
  445. return fetch(url).then( /*#__PURE__*/function () {
  446. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(response) {
  447. var cMapData;
  448. return _regenerator["default"].wrap(function _callee2$(_context2) {
  449. while (1) {
  450. switch (_context2.prev = _context2.next) {
  451. case 0:
  452. if (response.ok) {
  453. _context2.next = 2;
  454. break;
  455. }
  456. throw new Error(response.statusText);
  457. case 2:
  458. if (!_this3.isCompressed) {
  459. _context2.next = 10;
  460. break;
  461. }
  462. _context2.t0 = Uint8Array;
  463. _context2.next = 6;
  464. return response.arrayBuffer();
  465. case 6:
  466. _context2.t1 = _context2.sent;
  467. cMapData = new _context2.t0(_context2.t1);
  468. _context2.next = 15;
  469. break;
  470. case 10:
  471. _context2.t2 = _util.stringToBytes;
  472. _context2.next = 13;
  473. return response.text();
  474. case 13:
  475. _context2.t3 = _context2.sent;
  476. cMapData = (0, _context2.t2)(_context2.t3);
  477. case 15:
  478. return _context2.abrupt("return", {
  479. cMapData: cMapData,
  480. compressionType: compressionType
  481. });
  482. case 16:
  483. case "end":
  484. return _context2.stop();
  485. }
  486. }
  487. }, _callee2);
  488. }));
  489. return function (_x2) {
  490. return _ref4.apply(this, arguments);
  491. };
  492. }());
  493. }
  494. return new Promise(function (resolve, reject) {
  495. var request = new XMLHttpRequest();
  496. request.open("GET", url, true);
  497. if (_this3.isCompressed) {
  498. request.responseType = "arraybuffer";
  499. }
  500. request.onreadystatechange = function () {
  501. if (request.readyState !== XMLHttpRequest.DONE) {
  502. return;
  503. }
  504. if (request.status === 200 || request.status === 0) {
  505. var cMapData;
  506. if (_this3.isCompressed && request.response) {
  507. cMapData = new Uint8Array(request.response);
  508. } else if (!_this3.isCompressed && request.responseText) {
  509. cMapData = (0, _util.stringToBytes)(request.responseText);
  510. }
  511. if (cMapData) {
  512. resolve({
  513. cMapData: cMapData,
  514. compressionType: compressionType
  515. });
  516. return;
  517. }
  518. }
  519. reject(new Error(request.statusText));
  520. };
  521. request.send(null);
  522. });
  523. }
  524. }]);
  525. return DOMCMapReaderFactory;
  526. }(BaseCMapReaderFactory);
  527. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  528. var DOMSVGFactory = /*#__PURE__*/function () {
  529. function DOMSVGFactory() {
  530. _classCallCheck(this, DOMSVGFactory);
  531. }
  532. _createClass(DOMSVGFactory, [{
  533. key: "create",
  534. value: function create(width, height) {
  535. (0, _util.assert)(width > 0 && height > 0, "Invalid SVG dimensions");
  536. var svg = document.createElementNS(SVG_NS, "svg:svg");
  537. svg.setAttribute("version", "1.1");
  538. svg.setAttribute("width", width + "px");
  539. svg.setAttribute("height", height + "px");
  540. svg.setAttribute("preserveAspectRatio", "none");
  541. svg.setAttribute("viewBox", "0 0 " + width + " " + height);
  542. return svg;
  543. }
  544. }, {
  545. key: "createElement",
  546. value: function createElement(type) {
  547. (0, _util.assert)(typeof type === "string", "Invalid SVG element type");
  548. return document.createElementNS(SVG_NS, type);
  549. }
  550. }]);
  551. return DOMSVGFactory;
  552. }();
  553. exports.DOMSVGFactory = DOMSVGFactory;
  554. var PageViewport = /*#__PURE__*/function () {
  555. function PageViewport(_ref5) {
  556. var viewBox = _ref5.viewBox,
  557. scale = _ref5.scale,
  558. rotation = _ref5.rotation,
  559. _ref5$offsetX = _ref5.offsetX,
  560. offsetX = _ref5$offsetX === void 0 ? 0 : _ref5$offsetX,
  561. _ref5$offsetY = _ref5.offsetY,
  562. offsetY = _ref5$offsetY === void 0 ? 0 : _ref5$offsetY,
  563. _ref5$dontFlip = _ref5.dontFlip,
  564. dontFlip = _ref5$dontFlip === void 0 ? false : _ref5$dontFlip;
  565. _classCallCheck(this, PageViewport);
  566. this.viewBox = viewBox;
  567. this.scale = scale;
  568. this.rotation = rotation;
  569. this.offsetX = offsetX;
  570. this.offsetY = offsetY;
  571. var centerX = (viewBox[2] + viewBox[0]) / 2;
  572. var centerY = (viewBox[3] + viewBox[1]) / 2;
  573. var rotateA, rotateB, rotateC, rotateD;
  574. rotation = rotation % 360;
  575. rotation = rotation < 0 ? rotation + 360 : rotation;
  576. switch (rotation) {
  577. case 180:
  578. rotateA = -1;
  579. rotateB = 0;
  580. rotateC = 0;
  581. rotateD = 1;
  582. break;
  583. case 90:
  584. rotateA = 0;
  585. rotateB = 1;
  586. rotateC = 1;
  587. rotateD = 0;
  588. break;
  589. case 270:
  590. rotateA = 0;
  591. rotateB = -1;
  592. rotateC = -1;
  593. rotateD = 0;
  594. break;
  595. case 0:
  596. rotateA = 1;
  597. rotateB = 0;
  598. rotateC = 0;
  599. rotateD = -1;
  600. break;
  601. default:
  602. throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");
  603. }
  604. if (dontFlip) {
  605. rotateC = -rotateC;
  606. rotateD = -rotateD;
  607. }
  608. var offsetCanvasX, offsetCanvasY;
  609. var width, height;
  610. if (rotateA === 0) {
  611. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  612. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  613. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  614. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  615. } else {
  616. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  617. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  618. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  619. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  620. }
  621. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  622. this.width = width;
  623. this.height = height;
  624. }
  625. _createClass(PageViewport, [{
  626. key: "clone",
  627. value: function clone() {
  628. var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  629. _ref6$scale = _ref6.scale,
  630. scale = _ref6$scale === void 0 ? this.scale : _ref6$scale,
  631. _ref6$rotation = _ref6.rotation,
  632. rotation = _ref6$rotation === void 0 ? this.rotation : _ref6$rotation,
  633. _ref6$offsetX = _ref6.offsetX,
  634. offsetX = _ref6$offsetX === void 0 ? this.offsetX : _ref6$offsetX,
  635. _ref6$offsetY = _ref6.offsetY,
  636. offsetY = _ref6$offsetY === void 0 ? this.offsetY : _ref6$offsetY,
  637. _ref6$dontFlip = _ref6.dontFlip,
  638. dontFlip = _ref6$dontFlip === void 0 ? false : _ref6$dontFlip;
  639. return new PageViewport({
  640. viewBox: this.viewBox.slice(),
  641. scale: scale,
  642. rotation: rotation,
  643. offsetX: offsetX,
  644. offsetY: offsetY,
  645. dontFlip: dontFlip
  646. });
  647. }
  648. }, {
  649. key: "convertToViewportPoint",
  650. value: function convertToViewportPoint(x, y) {
  651. return _util.Util.applyTransform([x, y], this.transform);
  652. }
  653. }, {
  654. key: "convertToViewportRectangle",
  655. value: function convertToViewportRectangle(rect) {
  656. var topLeft = _util.Util.applyTransform([rect[0], rect[1]], this.transform);
  657. var bottomRight = _util.Util.applyTransform([rect[2], rect[3]], this.transform);
  658. return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
  659. }
  660. }, {
  661. key: "convertToPdfPoint",
  662. value: function convertToPdfPoint(x, y) {
  663. return _util.Util.applyInverseTransform([x, y], this.transform);
  664. }
  665. }]);
  666. return PageViewport;
  667. }();
  668. exports.PageViewport = PageViewport;
  669. var RenderingCancelledException = /*#__PURE__*/function (_BaseException) {
  670. _inherits(RenderingCancelledException, _BaseException);
  671. var _super3 = _createSuper(RenderingCancelledException);
  672. function RenderingCancelledException(msg, type) {
  673. var _this4;
  674. _classCallCheck(this, RenderingCancelledException);
  675. _this4 = _super3.call(this, msg);
  676. _this4.type = type;
  677. return _this4;
  678. }
  679. return RenderingCancelledException;
  680. }(_util.BaseException);
  681. exports.RenderingCancelledException = RenderingCancelledException;
  682. var LinkTarget = {
  683. NONE: 0,
  684. SELF: 1,
  685. BLANK: 2,
  686. PARENT: 3,
  687. TOP: 4
  688. };
  689. exports.LinkTarget = LinkTarget;
  690. function addLinkAttributes(link) {
  691. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  692. url = _ref7.url,
  693. target = _ref7.target,
  694. rel = _ref7.rel,
  695. _ref7$enabled = _ref7.enabled,
  696. enabled = _ref7$enabled === void 0 ? true : _ref7$enabled;
  697. (0, _util.assert)(url && typeof url === "string", 'addLinkAttributes: A valid "url" parameter must provided.');
  698. var urlNullRemoved = (0, _util.removeNullCharacters)(url);
  699. if (enabled) {
  700. link.href = link.title = urlNullRemoved;
  701. } else {
  702. link.href = "";
  703. link.title = "Disabled: ".concat(urlNullRemoved);
  704. link.onclick = function () {
  705. return false;
  706. };
  707. }
  708. var targetStr = "";
  709. switch (target) {
  710. case LinkTarget.NONE:
  711. break;
  712. case LinkTarget.SELF:
  713. targetStr = "_self";
  714. break;
  715. case LinkTarget.BLANK:
  716. targetStr = "_blank";
  717. break;
  718. case LinkTarget.PARENT:
  719. targetStr = "_parent";
  720. break;
  721. case LinkTarget.TOP:
  722. targetStr = "_top";
  723. break;
  724. }
  725. link.target = targetStr;
  726. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  727. }
  728. function getFilenameFromUrl(url) {
  729. var anchor = url.indexOf("#");
  730. var query = url.indexOf("?");
  731. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  732. return url.substring(url.lastIndexOf("/", end) + 1, end);
  733. }
  734. var StatTimer = /*#__PURE__*/function () {
  735. function StatTimer() {
  736. _classCallCheck(this, StatTimer);
  737. this.started = Object.create(null);
  738. this.times = [];
  739. }
  740. _createClass(StatTimer, [{
  741. key: "time",
  742. value: function time(name) {
  743. if (name in this.started) {
  744. (0, _util.warn)("Timer is already running for ".concat(name));
  745. }
  746. this.started[name] = Date.now();
  747. }
  748. }, {
  749. key: "timeEnd",
  750. value: function timeEnd(name) {
  751. if (!(name in this.started)) {
  752. (0, _util.warn)("Timer has not been started for ".concat(name));
  753. }
  754. this.times.push({
  755. name: name,
  756. start: this.started[name],
  757. end: Date.now()
  758. });
  759. delete this.started[name];
  760. }
  761. }, {
  762. key: "toString",
  763. value: function toString() {
  764. var outBuf = [];
  765. var longest = 0;
  766. var _iterator = _createForOfIteratorHelper(this.times),
  767. _step;
  768. try {
  769. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  770. var time = _step.value;
  771. var name = time.name;
  772. if (name.length > longest) {
  773. longest = name.length;
  774. }
  775. }
  776. } catch (err) {
  777. _iterator.e(err);
  778. } finally {
  779. _iterator.f();
  780. }
  781. var _iterator2 = _createForOfIteratorHelper(this.times),
  782. _step2;
  783. try {
  784. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  785. var _time = _step2.value;
  786. var duration = _time.end - _time.start;
  787. outBuf.push("".concat(_time.name.padEnd(longest), " ").concat(duration, "ms\n"));
  788. }
  789. } catch (err) {
  790. _iterator2.e(err);
  791. } finally {
  792. _iterator2.f();
  793. }
  794. return outBuf.join("");
  795. }
  796. }]);
  797. return StatTimer;
  798. }();
  799. exports.StatTimer = StatTimer;
  800. function isFetchSupported() {
  801. return typeof fetch !== "undefined" && typeof Response !== "undefined" && "body" in Response.prototype && typeof ReadableStream !== "undefined";
  802. }
  803. function isValidFetchUrl(url, baseUrl) {
  804. try {
  805. var _ref8 = baseUrl ? new URL(url, baseUrl) : new URL(url),
  806. protocol = _ref8.protocol;
  807. return protocol === "http:" || protocol === "https:";
  808. } catch (ex) {
  809. return false;
  810. }
  811. }
  812. function loadScript(src) {
  813. var removeScriptElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  814. return new Promise(function (resolve, reject) {
  815. var script = document.createElement("script");
  816. script.src = src;
  817. script.onload = function (evt) {
  818. if (removeScriptElement) {
  819. script.remove();
  820. }
  821. resolve(evt);
  822. };
  823. script.onerror = function () {
  824. reject(new Error("Cannot load script at: ".concat(script.src)));
  825. };
  826. (document.head || document.documentElement).appendChild(script);
  827. });
  828. }
  829. function deprecated(details) {
  830. console.log("Deprecated API usage: " + details);
  831. }
  832. var pdfDateStringRegex;
  833. var PDFDateString = /*#__PURE__*/function () {
  834. function PDFDateString() {
  835. _classCallCheck(this, PDFDateString);
  836. }
  837. _createClass(PDFDateString, null, [{
  838. key: "toDateObject",
  839. value: function toDateObject(input) {
  840. if (!input || !(0, _util.isString)(input)) {
  841. return null;
  842. }
  843. if (!pdfDateStringRegex) {
  844. pdfDateStringRegex = new RegExp("^D:" + "(\\d{4})" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "([Z|+|-])?" + "(\\d{2})?" + "'?" + "(\\d{2})?" + "'?");
  845. }
  846. var matches = pdfDateStringRegex.exec(input);
  847. if (!matches) {
  848. return null;
  849. }
  850. var year = parseInt(matches[1], 10);
  851. var month = parseInt(matches[2], 10);
  852. month = month >= 1 && month <= 12 ? month - 1 : 0;
  853. var day = parseInt(matches[3], 10);
  854. day = day >= 1 && day <= 31 ? day : 1;
  855. var hour = parseInt(matches[4], 10);
  856. hour = hour >= 0 && hour <= 23 ? hour : 0;
  857. var minute = parseInt(matches[5], 10);
  858. minute = minute >= 0 && minute <= 59 ? minute : 0;
  859. var second = parseInt(matches[6], 10);
  860. second = second >= 0 && second <= 59 ? second : 0;
  861. var universalTimeRelation = matches[7] || "Z";
  862. var offsetHour = parseInt(matches[8], 10);
  863. offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
  864. var offsetMinute = parseInt(matches[9], 10) || 0;
  865. offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
  866. if (universalTimeRelation === "-") {
  867. hour += offsetHour;
  868. minute += offsetMinute;
  869. } else if (universalTimeRelation === "+") {
  870. hour -= offsetHour;
  871. minute -= offsetMinute;
  872. }
  873. return new Date(Date.UTC(year, month, day, hour, minute, second));
  874. }
  875. }]);
  876. return PDFDateString;
  877. }();
  878. exports.PDFDateString = PDFDateString;
  879. /***/ }),
  880. /* 2 */
  881. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  882. "use strict";
  883. module.exports = __w_pdfjs_require__(3);
  884. /***/ }),
  885. /* 3 */
  886. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  887. "use strict";
  888. /* module decorator */ module = __w_pdfjs_require__.nmd(module);
  889. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  890. var runtime = function (exports) {
  891. "use strict";
  892. var Op = Object.prototype;
  893. var hasOwn = Op.hasOwnProperty;
  894. var undefined;
  895. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  896. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  897. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  898. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  899. function define(obj, key, value) {
  900. Object.defineProperty(obj, key, {
  901. value: value,
  902. enumerable: true,
  903. configurable: true,
  904. writable: true
  905. });
  906. return obj[key];
  907. }
  908. try {
  909. define({}, "");
  910. } catch (err) {
  911. define = function define(obj, key, value) {
  912. return obj[key] = value;
  913. };
  914. }
  915. function wrap(innerFn, outerFn, self, tryLocsList) {
  916. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  917. var generator = Object.create(protoGenerator.prototype);
  918. var context = new Context(tryLocsList || []);
  919. generator._invoke = makeInvokeMethod(innerFn, self, context);
  920. return generator;
  921. }
  922. exports.wrap = wrap;
  923. function tryCatch(fn, obj, arg) {
  924. try {
  925. return {
  926. type: "normal",
  927. arg: fn.call(obj, arg)
  928. };
  929. } catch (err) {
  930. return {
  931. type: "throw",
  932. arg: err
  933. };
  934. }
  935. }
  936. var GenStateSuspendedStart = "suspendedStart";
  937. var GenStateSuspendedYield = "suspendedYield";
  938. var GenStateExecuting = "executing";
  939. var GenStateCompleted = "completed";
  940. var ContinueSentinel = {};
  941. function Generator() {}
  942. function GeneratorFunction() {}
  943. function GeneratorFunctionPrototype() {}
  944. var IteratorPrototype = {};
  945. IteratorPrototype[iteratorSymbol] = function () {
  946. return this;
  947. };
  948. var getProto = Object.getPrototypeOf;
  949. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  950. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  951. IteratorPrototype = NativeIteratorPrototype;
  952. }
  953. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  954. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  955. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  956. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  957. function defineIteratorMethods(prototype) {
  958. ["next", "throw", "return"].forEach(function (method) {
  959. define(prototype, method, function (arg) {
  960. return this._invoke(method, arg);
  961. });
  962. });
  963. }
  964. exports.isGeneratorFunction = function (genFun) {
  965. var ctor = typeof genFun === "function" && genFun.constructor;
  966. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  967. };
  968. exports.mark = function (genFun) {
  969. if (Object.setPrototypeOf) {
  970. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  971. } else {
  972. genFun.__proto__ = GeneratorFunctionPrototype;
  973. define(genFun, toStringTagSymbol, "GeneratorFunction");
  974. }
  975. genFun.prototype = Object.create(Gp);
  976. return genFun;
  977. };
  978. exports.awrap = function (arg) {
  979. return {
  980. __await: arg
  981. };
  982. };
  983. function AsyncIterator(generator, PromiseImpl) {
  984. function invoke(method, arg, resolve, reject) {
  985. var record = tryCatch(generator[method], generator, arg);
  986. if (record.type === "throw") {
  987. reject(record.arg);
  988. } else {
  989. var result = record.arg;
  990. var value = result.value;
  991. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  992. return PromiseImpl.resolve(value.__await).then(function (value) {
  993. invoke("next", value, resolve, reject);
  994. }, function (err) {
  995. invoke("throw", err, resolve, reject);
  996. });
  997. }
  998. return PromiseImpl.resolve(value).then(function (unwrapped) {
  999. result.value = unwrapped;
  1000. resolve(result);
  1001. }, function (error) {
  1002. return invoke("throw", error, resolve, reject);
  1003. });
  1004. }
  1005. }
  1006. var previousPromise;
  1007. function enqueue(method, arg) {
  1008. function callInvokeWithMethodAndArg() {
  1009. return new PromiseImpl(function (resolve, reject) {
  1010. invoke(method, arg, resolve, reject);
  1011. });
  1012. }
  1013. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  1014. }
  1015. this._invoke = enqueue;
  1016. }
  1017. defineIteratorMethods(AsyncIterator.prototype);
  1018. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  1019. return this;
  1020. };
  1021. exports.AsyncIterator = AsyncIterator;
  1022. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  1023. if (PromiseImpl === void 0) PromiseImpl = Promise;
  1024. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  1025. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  1026. return result.done ? result.value : iter.next();
  1027. });
  1028. };
  1029. function makeInvokeMethod(innerFn, self, context) {
  1030. var state = GenStateSuspendedStart;
  1031. return function invoke(method, arg) {
  1032. if (state === GenStateExecuting) {
  1033. throw new Error("Generator is already running");
  1034. }
  1035. if (state === GenStateCompleted) {
  1036. if (method === "throw") {
  1037. throw arg;
  1038. }
  1039. return doneResult();
  1040. }
  1041. context.method = method;
  1042. context.arg = arg;
  1043. while (true) {
  1044. var delegate = context.delegate;
  1045. if (delegate) {
  1046. var delegateResult = maybeInvokeDelegate(delegate, context);
  1047. if (delegateResult) {
  1048. if (delegateResult === ContinueSentinel) continue;
  1049. return delegateResult;
  1050. }
  1051. }
  1052. if (context.method === "next") {
  1053. context.sent = context._sent = context.arg;
  1054. } else if (context.method === "throw") {
  1055. if (state === GenStateSuspendedStart) {
  1056. state = GenStateCompleted;
  1057. throw context.arg;
  1058. }
  1059. context.dispatchException(context.arg);
  1060. } else if (context.method === "return") {
  1061. context.abrupt("return", context.arg);
  1062. }
  1063. state = GenStateExecuting;
  1064. var record = tryCatch(innerFn, self, context);
  1065. if (record.type === "normal") {
  1066. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  1067. if (record.arg === ContinueSentinel) {
  1068. continue;
  1069. }
  1070. return {
  1071. value: record.arg,
  1072. done: context.done
  1073. };
  1074. } else if (record.type === "throw") {
  1075. state = GenStateCompleted;
  1076. context.method = "throw";
  1077. context.arg = record.arg;
  1078. }
  1079. }
  1080. };
  1081. }
  1082. function maybeInvokeDelegate(delegate, context) {
  1083. var method = delegate.iterator[context.method];
  1084. if (method === undefined) {
  1085. context.delegate = null;
  1086. if (context.method === "throw") {
  1087. if (delegate.iterator["return"]) {
  1088. context.method = "return";
  1089. context.arg = undefined;
  1090. maybeInvokeDelegate(delegate, context);
  1091. if (context.method === "throw") {
  1092. return ContinueSentinel;
  1093. }
  1094. }
  1095. context.method = "throw";
  1096. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  1097. }
  1098. return ContinueSentinel;
  1099. }
  1100. var record = tryCatch(method, delegate.iterator, context.arg);
  1101. if (record.type === "throw") {
  1102. context.method = "throw";
  1103. context.arg = record.arg;
  1104. context.delegate = null;
  1105. return ContinueSentinel;
  1106. }
  1107. var info = record.arg;
  1108. if (!info) {
  1109. context.method = "throw";
  1110. context.arg = new TypeError("iterator result is not an object");
  1111. context.delegate = null;
  1112. return ContinueSentinel;
  1113. }
  1114. if (info.done) {
  1115. context[delegate.resultName] = info.value;
  1116. context.next = delegate.nextLoc;
  1117. if (context.method !== "return") {
  1118. context.method = "next";
  1119. context.arg = undefined;
  1120. }
  1121. } else {
  1122. return info;
  1123. }
  1124. context.delegate = null;
  1125. return ContinueSentinel;
  1126. }
  1127. defineIteratorMethods(Gp);
  1128. define(Gp, toStringTagSymbol, "Generator");
  1129. Gp[iteratorSymbol] = function () {
  1130. return this;
  1131. };
  1132. Gp.toString = function () {
  1133. return "[object Generator]";
  1134. };
  1135. function pushTryEntry(locs) {
  1136. var entry = {
  1137. tryLoc: locs[0]
  1138. };
  1139. if (1 in locs) {
  1140. entry.catchLoc = locs[1];
  1141. }
  1142. if (2 in locs) {
  1143. entry.finallyLoc = locs[2];
  1144. entry.afterLoc = locs[3];
  1145. }
  1146. this.tryEntries.push(entry);
  1147. }
  1148. function resetTryEntry(entry) {
  1149. var record = entry.completion || {};
  1150. record.type = "normal";
  1151. delete record.arg;
  1152. entry.completion = record;
  1153. }
  1154. function Context(tryLocsList) {
  1155. this.tryEntries = [{
  1156. tryLoc: "root"
  1157. }];
  1158. tryLocsList.forEach(pushTryEntry, this);
  1159. this.reset(true);
  1160. }
  1161. exports.keys = function (object) {
  1162. var keys = [];
  1163. for (var key in object) {
  1164. keys.push(key);
  1165. }
  1166. keys.reverse();
  1167. return function next() {
  1168. while (keys.length) {
  1169. var key = keys.pop();
  1170. if (key in object) {
  1171. next.value = key;
  1172. next.done = false;
  1173. return next;
  1174. }
  1175. }
  1176. next.done = true;
  1177. return next;
  1178. };
  1179. };
  1180. function values(iterable) {
  1181. if (iterable) {
  1182. var iteratorMethod = iterable[iteratorSymbol];
  1183. if (iteratorMethod) {
  1184. return iteratorMethod.call(iterable);
  1185. }
  1186. if (typeof iterable.next === "function") {
  1187. return iterable;
  1188. }
  1189. if (!isNaN(iterable.length)) {
  1190. var i = -1,
  1191. next = function next() {
  1192. while (++i < iterable.length) {
  1193. if (hasOwn.call(iterable, i)) {
  1194. next.value = iterable[i];
  1195. next.done = false;
  1196. return next;
  1197. }
  1198. }
  1199. next.value = undefined;
  1200. next.done = true;
  1201. return next;
  1202. };
  1203. return next.next = next;
  1204. }
  1205. }
  1206. return {
  1207. next: doneResult
  1208. };
  1209. }
  1210. exports.values = values;
  1211. function doneResult() {
  1212. return {
  1213. value: undefined,
  1214. done: true
  1215. };
  1216. }
  1217. Context.prototype = {
  1218. constructor: Context,
  1219. reset: function reset(skipTempReset) {
  1220. this.prev = 0;
  1221. this.next = 0;
  1222. this.sent = this._sent = undefined;
  1223. this.done = false;
  1224. this.delegate = null;
  1225. this.method = "next";
  1226. this.arg = undefined;
  1227. this.tryEntries.forEach(resetTryEntry);
  1228. if (!skipTempReset) {
  1229. for (var name in this) {
  1230. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  1231. this[name] = undefined;
  1232. }
  1233. }
  1234. }
  1235. },
  1236. stop: function stop() {
  1237. this.done = true;
  1238. var rootEntry = this.tryEntries[0];
  1239. var rootRecord = rootEntry.completion;
  1240. if (rootRecord.type === "throw") {
  1241. throw rootRecord.arg;
  1242. }
  1243. return this.rval;
  1244. },
  1245. dispatchException: function dispatchException(exception) {
  1246. if (this.done) {
  1247. throw exception;
  1248. }
  1249. var context = this;
  1250. function handle(loc, caught) {
  1251. record.type = "throw";
  1252. record.arg = exception;
  1253. context.next = loc;
  1254. if (caught) {
  1255. context.method = "next";
  1256. context.arg = undefined;
  1257. }
  1258. return !!caught;
  1259. }
  1260. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1261. var entry = this.tryEntries[i];
  1262. var record = entry.completion;
  1263. if (entry.tryLoc === "root") {
  1264. return handle("end");
  1265. }
  1266. if (entry.tryLoc <= this.prev) {
  1267. var hasCatch = hasOwn.call(entry, "catchLoc");
  1268. var hasFinally = hasOwn.call(entry, "finallyLoc");
  1269. if (hasCatch && hasFinally) {
  1270. if (this.prev < entry.catchLoc) {
  1271. return handle(entry.catchLoc, true);
  1272. } else if (this.prev < entry.finallyLoc) {
  1273. return handle(entry.finallyLoc);
  1274. }
  1275. } else if (hasCatch) {
  1276. if (this.prev < entry.catchLoc) {
  1277. return handle(entry.catchLoc, true);
  1278. }
  1279. } else if (hasFinally) {
  1280. if (this.prev < entry.finallyLoc) {
  1281. return handle(entry.finallyLoc);
  1282. }
  1283. } else {
  1284. throw new Error("try statement without catch or finally");
  1285. }
  1286. }
  1287. }
  1288. },
  1289. abrupt: function abrupt(type, arg) {
  1290. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1291. var entry = this.tryEntries[i];
  1292. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  1293. var finallyEntry = entry;
  1294. break;
  1295. }
  1296. }
  1297. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  1298. finallyEntry = null;
  1299. }
  1300. var record = finallyEntry ? finallyEntry.completion : {};
  1301. record.type = type;
  1302. record.arg = arg;
  1303. if (finallyEntry) {
  1304. this.method = "next";
  1305. this.next = finallyEntry.finallyLoc;
  1306. return ContinueSentinel;
  1307. }
  1308. return this.complete(record);
  1309. },
  1310. complete: function complete(record, afterLoc) {
  1311. if (record.type === "throw") {
  1312. throw record.arg;
  1313. }
  1314. if (record.type === "break" || record.type === "continue") {
  1315. this.next = record.arg;
  1316. } else if (record.type === "return") {
  1317. this.rval = this.arg = record.arg;
  1318. this.method = "return";
  1319. this.next = "end";
  1320. } else if (record.type === "normal" && afterLoc) {
  1321. this.next = afterLoc;
  1322. }
  1323. return ContinueSentinel;
  1324. },
  1325. finish: function finish(finallyLoc) {
  1326. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1327. var entry = this.tryEntries[i];
  1328. if (entry.finallyLoc === finallyLoc) {
  1329. this.complete(entry.completion, entry.afterLoc);
  1330. resetTryEntry(entry);
  1331. return ContinueSentinel;
  1332. }
  1333. }
  1334. },
  1335. "catch": function _catch(tryLoc) {
  1336. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1337. var entry = this.tryEntries[i];
  1338. if (entry.tryLoc === tryLoc) {
  1339. var record = entry.completion;
  1340. if (record.type === "throw") {
  1341. var thrown = record.arg;
  1342. resetTryEntry(entry);
  1343. }
  1344. return thrown;
  1345. }
  1346. }
  1347. throw new Error("illegal catch attempt");
  1348. },
  1349. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  1350. this.delegate = {
  1351. iterator: values(iterable),
  1352. resultName: resultName,
  1353. nextLoc: nextLoc
  1354. };
  1355. if (this.method === "next") {
  1356. this.arg = undefined;
  1357. }
  1358. return ContinueSentinel;
  1359. }
  1360. };
  1361. return exports;
  1362. }(( false ? 0 : _typeof(module)) === "object" ? module.exports : {});
  1363. try {
  1364. regeneratorRuntime = runtime;
  1365. } catch (accidentalStrictMode) {
  1366. Function("r", "regeneratorRuntime = r")(runtime);
  1367. }
  1368. /***/ }),
  1369. /* 4 */
  1370. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1371. "use strict";
  1372. Object.defineProperty(exports, "__esModule", ({
  1373. value: true
  1374. }));
  1375. exports.arrayByteLength = arrayByteLength;
  1376. exports.arraysToBytes = arraysToBytes;
  1377. exports.assert = assert;
  1378. exports.bytesToString = bytesToString;
  1379. exports.createPromiseCapability = createPromiseCapability;
  1380. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1381. exports.encodeToXmlString = encodeToXmlString;
  1382. exports.escapeString = escapeString;
  1383. exports.getModificationDate = getModificationDate;
  1384. exports.getVerbosityLevel = getVerbosityLevel;
  1385. exports.info = info;
  1386. exports.isArrayBuffer = isArrayBuffer;
  1387. exports.isArrayEqual = isArrayEqual;
  1388. exports.isAscii = isAscii;
  1389. exports.isBool = isBool;
  1390. exports.isNum = isNum;
  1391. exports.isSameOrigin = isSameOrigin;
  1392. exports.isString = isString;
  1393. exports.objectFromEntries = objectFromEntries;
  1394. exports.objectSize = objectSize;
  1395. exports.removeNullCharacters = removeNullCharacters;
  1396. exports.setVerbosityLevel = setVerbosityLevel;
  1397. exports.shadow = shadow;
  1398. exports.string32 = string32;
  1399. exports.stringToBytes = stringToBytes;
  1400. exports.stringToPDFString = stringToPDFString;
  1401. exports.stringToUTF16BEString = stringToUTF16BEString;
  1402. exports.stringToUTF8String = stringToUTF8String;
  1403. exports.unreachable = unreachable;
  1404. exports.utf8StringToString = utf8StringToString;
  1405. exports.warn = warn;
  1406. exports.VerbosityLevel = exports.Util = exports.UNSUPPORTED_FEATURES = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.PageActionEventType = exports.OPS = exports.MissingPDFException = exports.IsLittleEndianCached = exports.IsEvalSupportedCached = exports.InvalidPDFException = exports.ImageKind = exports.IDENTITY_MATRIX = exports.FormatError = exports.FontType = exports.FONT_IDENTITY_MATRIX = exports.DocumentActionEventType = exports.createObjectURL = exports.CMapCompressionType = exports.BaseException = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.AnnotationActionEventType = exports.AbortException = void 0;
  1407. __w_pdfjs_require__(5);
  1408. 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); } }
  1409. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1410. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  1411. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  1412. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  1413. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  1414. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  1415. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  1416. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1417. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1418. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  1419. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  1420. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1421. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  1422. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  1423. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  1424. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  1425. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  1426. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1427. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  1428. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1429. var PermissionFlag = {
  1430. PRINT: 0x04,
  1431. MODIFY_CONTENTS: 0x08,
  1432. COPY: 0x10,
  1433. MODIFY_ANNOTATIONS: 0x20,
  1434. FILL_INTERACTIVE_FORMS: 0x100,
  1435. COPY_FOR_ACCESSIBILITY: 0x200,
  1436. ASSEMBLE: 0x400,
  1437. PRINT_HIGH_QUALITY: 0x800
  1438. };
  1439. exports.PermissionFlag = PermissionFlag;
  1440. var TextRenderingMode = {
  1441. FILL: 0,
  1442. STROKE: 1,
  1443. FILL_STROKE: 2,
  1444. INVISIBLE: 3,
  1445. FILL_ADD_TO_PATH: 4,
  1446. STROKE_ADD_TO_PATH: 5,
  1447. FILL_STROKE_ADD_TO_PATH: 6,
  1448. ADD_TO_PATH: 7,
  1449. FILL_STROKE_MASK: 3,
  1450. ADD_TO_PATH_FLAG: 4
  1451. };
  1452. exports.TextRenderingMode = TextRenderingMode;
  1453. var ImageKind = {
  1454. GRAYSCALE_1BPP: 1,
  1455. RGB_24BPP: 2,
  1456. RGBA_32BPP: 3
  1457. };
  1458. exports.ImageKind = ImageKind;
  1459. var AnnotationType = {
  1460. TEXT: 1,
  1461. LINK: 2,
  1462. FREETEXT: 3,
  1463. LINE: 4,
  1464. SQUARE: 5,
  1465. CIRCLE: 6,
  1466. POLYGON: 7,
  1467. POLYLINE: 8,
  1468. HIGHLIGHT: 9,
  1469. UNDERLINE: 10,
  1470. SQUIGGLY: 11,
  1471. STRIKEOUT: 12,
  1472. STAMP: 13,
  1473. CARET: 14,
  1474. INK: 15,
  1475. POPUP: 16,
  1476. FILEATTACHMENT: 17,
  1477. SOUND: 18,
  1478. MOVIE: 19,
  1479. WIDGET: 20,
  1480. SCREEN: 21,
  1481. PRINTERMARK: 22,
  1482. TRAPNET: 23,
  1483. WATERMARK: 24,
  1484. THREED: 25,
  1485. REDACT: 26
  1486. };
  1487. exports.AnnotationType = AnnotationType;
  1488. var AnnotationStateModelType = {
  1489. MARKED: "Marked",
  1490. REVIEW: "Review"
  1491. };
  1492. exports.AnnotationStateModelType = AnnotationStateModelType;
  1493. var AnnotationMarkedState = {
  1494. MARKED: "Marked",
  1495. UNMARKED: "Unmarked"
  1496. };
  1497. exports.AnnotationMarkedState = AnnotationMarkedState;
  1498. var AnnotationReviewState = {
  1499. ACCEPTED: "Accepted",
  1500. REJECTED: "Rejected",
  1501. CANCELLED: "Cancelled",
  1502. COMPLETED: "Completed",
  1503. NONE: "None"
  1504. };
  1505. exports.AnnotationReviewState = AnnotationReviewState;
  1506. var AnnotationReplyType = {
  1507. GROUP: "Group",
  1508. REPLY: "R"
  1509. };
  1510. exports.AnnotationReplyType = AnnotationReplyType;
  1511. var AnnotationFlag = {
  1512. INVISIBLE: 0x01,
  1513. HIDDEN: 0x02,
  1514. PRINT: 0x04,
  1515. NOZOOM: 0x08,
  1516. NOROTATE: 0x10,
  1517. NOVIEW: 0x20,
  1518. READONLY: 0x40,
  1519. LOCKED: 0x80,
  1520. TOGGLENOVIEW: 0x100,
  1521. LOCKEDCONTENTS: 0x200
  1522. };
  1523. exports.AnnotationFlag = AnnotationFlag;
  1524. var AnnotationFieldFlag = {
  1525. READONLY: 0x0000001,
  1526. REQUIRED: 0x0000002,
  1527. NOEXPORT: 0x0000004,
  1528. MULTILINE: 0x0001000,
  1529. PASSWORD: 0x0002000,
  1530. NOTOGGLETOOFF: 0x0004000,
  1531. RADIO: 0x0008000,
  1532. PUSHBUTTON: 0x0010000,
  1533. COMBO: 0x0020000,
  1534. EDIT: 0x0040000,
  1535. SORT: 0x0080000,
  1536. FILESELECT: 0x0100000,
  1537. MULTISELECT: 0x0200000,
  1538. DONOTSPELLCHECK: 0x0400000,
  1539. DONOTSCROLL: 0x0800000,
  1540. COMB: 0x1000000,
  1541. RICHTEXT: 0x2000000,
  1542. RADIOSINUNISON: 0x2000000,
  1543. COMMITONSELCHANGE: 0x4000000
  1544. };
  1545. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1546. var AnnotationBorderStyleType = {
  1547. SOLID: 1,
  1548. DASHED: 2,
  1549. BEVELED: 3,
  1550. INSET: 4,
  1551. UNDERLINE: 5
  1552. };
  1553. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1554. var AnnotationActionEventType = {
  1555. E: "Mouse Enter",
  1556. X: "Mouse Exit",
  1557. D: "Mouse Down",
  1558. U: "Mouse Up",
  1559. Fo: "Focus",
  1560. Bl: "Blur",
  1561. PO: "PageOpen",
  1562. PC: "PageClose",
  1563. PV: "PageVisible",
  1564. PI: "PageInvisible",
  1565. K: "Keystroke",
  1566. F: "Format",
  1567. V: "Validate",
  1568. C: "Calculate"
  1569. };
  1570. exports.AnnotationActionEventType = AnnotationActionEventType;
  1571. var DocumentActionEventType = {
  1572. WC: "WillClose",
  1573. WS: "WillSave",
  1574. DS: "DidSave",
  1575. WP: "WillPrint",
  1576. DP: "DidPrint"
  1577. };
  1578. exports.DocumentActionEventType = DocumentActionEventType;
  1579. var PageActionEventType = {
  1580. O: "PageOpen",
  1581. C: "PageClose"
  1582. };
  1583. exports.PageActionEventType = PageActionEventType;
  1584. var StreamType = {
  1585. UNKNOWN: "UNKNOWN",
  1586. FLATE: "FLATE",
  1587. LZW: "LZW",
  1588. DCT: "DCT",
  1589. JPX: "JPX",
  1590. JBIG: "JBIG",
  1591. A85: "A85",
  1592. AHX: "AHX",
  1593. CCF: "CCF",
  1594. RLX: "RLX"
  1595. };
  1596. exports.StreamType = StreamType;
  1597. var FontType = {
  1598. UNKNOWN: "UNKNOWN",
  1599. TYPE1: "TYPE1",
  1600. TYPE1C: "TYPE1C",
  1601. CIDFONTTYPE0: "CIDFONTTYPE0",
  1602. CIDFONTTYPE0C: "CIDFONTTYPE0C",
  1603. TRUETYPE: "TRUETYPE",
  1604. CIDFONTTYPE2: "CIDFONTTYPE2",
  1605. TYPE3: "TYPE3",
  1606. OPENTYPE: "OPENTYPE",
  1607. TYPE0: "TYPE0",
  1608. MMTYPE1: "MMTYPE1"
  1609. };
  1610. exports.FontType = FontType;
  1611. var VerbosityLevel = {
  1612. ERRORS: 0,
  1613. WARNINGS: 1,
  1614. INFOS: 5
  1615. };
  1616. exports.VerbosityLevel = VerbosityLevel;
  1617. var CMapCompressionType = {
  1618. NONE: 0,
  1619. BINARY: 1,
  1620. STREAM: 2
  1621. };
  1622. exports.CMapCompressionType = CMapCompressionType;
  1623. var OPS = {
  1624. dependency: 1,
  1625. setLineWidth: 2,
  1626. setLineCap: 3,
  1627. setLineJoin: 4,
  1628. setMiterLimit: 5,
  1629. setDash: 6,
  1630. setRenderingIntent: 7,
  1631. setFlatness: 8,
  1632. setGState: 9,
  1633. save: 10,
  1634. restore: 11,
  1635. transform: 12,
  1636. moveTo: 13,
  1637. lineTo: 14,
  1638. curveTo: 15,
  1639. curveTo2: 16,
  1640. curveTo3: 17,
  1641. closePath: 18,
  1642. rectangle: 19,
  1643. stroke: 20,
  1644. closeStroke: 21,
  1645. fill: 22,
  1646. eoFill: 23,
  1647. fillStroke: 24,
  1648. eoFillStroke: 25,
  1649. closeFillStroke: 26,
  1650. closeEOFillStroke: 27,
  1651. endPath: 28,
  1652. clip: 29,
  1653. eoClip: 30,
  1654. beginText: 31,
  1655. endText: 32,
  1656. setCharSpacing: 33,
  1657. setWordSpacing: 34,
  1658. setHScale: 35,
  1659. setLeading: 36,
  1660. setFont: 37,
  1661. setTextRenderingMode: 38,
  1662. setTextRise: 39,
  1663. moveText: 40,
  1664. setLeadingMoveText: 41,
  1665. setTextMatrix: 42,
  1666. nextLine: 43,
  1667. showText: 44,
  1668. showSpacedText: 45,
  1669. nextLineShowText: 46,
  1670. nextLineSetSpacingShowText: 47,
  1671. setCharWidth: 48,
  1672. setCharWidthAndBounds: 49,
  1673. setStrokeColorSpace: 50,
  1674. setFillColorSpace: 51,
  1675. setStrokeColor: 52,
  1676. setStrokeColorN: 53,
  1677. setFillColor: 54,
  1678. setFillColorN: 55,
  1679. setStrokeGray: 56,
  1680. setFillGray: 57,
  1681. setStrokeRGBColor: 58,
  1682. setFillRGBColor: 59,
  1683. setStrokeCMYKColor: 60,
  1684. setFillCMYKColor: 61,
  1685. shadingFill: 62,
  1686. beginInlineImage: 63,
  1687. beginImageData: 64,
  1688. endInlineImage: 65,
  1689. paintXObject: 66,
  1690. markPoint: 67,
  1691. markPointProps: 68,
  1692. beginMarkedContent: 69,
  1693. beginMarkedContentProps: 70,
  1694. endMarkedContent: 71,
  1695. beginCompat: 72,
  1696. endCompat: 73,
  1697. paintFormXObjectBegin: 74,
  1698. paintFormXObjectEnd: 75,
  1699. beginGroup: 76,
  1700. endGroup: 77,
  1701. beginAnnotations: 78,
  1702. endAnnotations: 79,
  1703. beginAnnotation: 80,
  1704. endAnnotation: 81,
  1705. paintJpegXObject: 82,
  1706. paintImageMaskXObject: 83,
  1707. paintImageMaskXObjectGroup: 84,
  1708. paintImageXObject: 85,
  1709. paintInlineImageXObject: 86,
  1710. paintInlineImageXObjectGroup: 87,
  1711. paintImageXObjectRepeat: 88,
  1712. paintImageMaskXObjectRepeat: 89,
  1713. paintSolidColorImageMask: 90,
  1714. constructPath: 91
  1715. };
  1716. exports.OPS = OPS;
  1717. var UNSUPPORTED_FEATURES = {
  1718. unknown: "unknown",
  1719. forms: "forms",
  1720. javaScript: "javaScript",
  1721. smask: "smask",
  1722. shadingPattern: "shadingPattern",
  1723. font: "font",
  1724. errorTilingPattern: "errorTilingPattern",
  1725. errorExtGState: "errorExtGState",
  1726. errorXObject: "errorXObject",
  1727. errorFontLoadType3: "errorFontLoadType3",
  1728. errorFontState: "errorFontState",
  1729. errorFontMissing: "errorFontMissing",
  1730. errorFontTranslate: "errorFontTranslate",
  1731. errorColorSpace: "errorColorSpace",
  1732. errorOperatorList: "errorOperatorList",
  1733. errorFontToUnicode: "errorFontToUnicode",
  1734. errorFontLoadNative: "errorFontLoadNative",
  1735. errorFontGetPath: "errorFontGetPath",
  1736. errorMarkedContent: "errorMarkedContent"
  1737. };
  1738. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1739. var PasswordResponses = {
  1740. NEED_PASSWORD: 1,
  1741. INCORRECT_PASSWORD: 2
  1742. };
  1743. exports.PasswordResponses = PasswordResponses;
  1744. var verbosity = VerbosityLevel.WARNINGS;
  1745. function setVerbosityLevel(level) {
  1746. if (Number.isInteger(level)) {
  1747. verbosity = level;
  1748. }
  1749. }
  1750. function getVerbosityLevel() {
  1751. return verbosity;
  1752. }
  1753. function info(msg) {
  1754. if (verbosity >= VerbosityLevel.INFOS) {
  1755. console.log("Info: ".concat(msg));
  1756. }
  1757. }
  1758. function warn(msg) {
  1759. if (verbosity >= VerbosityLevel.WARNINGS) {
  1760. console.log("Warning: ".concat(msg));
  1761. }
  1762. }
  1763. function unreachable(msg) {
  1764. throw new Error(msg);
  1765. }
  1766. function assert(cond, msg) {
  1767. if (!cond) {
  1768. unreachable(msg);
  1769. }
  1770. }
  1771. function isSameOrigin(baseUrl, otherUrl) {
  1772. var base;
  1773. try {
  1774. base = new URL(baseUrl);
  1775. if (!base.origin || base.origin === "null") {
  1776. return false;
  1777. }
  1778. } catch (e) {
  1779. return false;
  1780. }
  1781. var other = new URL(otherUrl, base);
  1782. return base.origin === other.origin;
  1783. }
  1784. function _isValidProtocol(url) {
  1785. if (!url) {
  1786. return false;
  1787. }
  1788. switch (url.protocol) {
  1789. case "http:":
  1790. case "https:":
  1791. case "ftp:":
  1792. case "mailto:":
  1793. case "tel:":
  1794. return true;
  1795. default:
  1796. return false;
  1797. }
  1798. }
  1799. function createValidAbsoluteUrl(url, baseUrl) {
  1800. if (!url) {
  1801. return null;
  1802. }
  1803. try {
  1804. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  1805. if (_isValidProtocol(absoluteUrl)) {
  1806. return absoluteUrl;
  1807. }
  1808. } catch (ex) {}
  1809. return null;
  1810. }
  1811. function shadow(obj, prop, value) {
  1812. Object.defineProperty(obj, prop, {
  1813. value: value,
  1814. enumerable: true,
  1815. configurable: true,
  1816. writable: false
  1817. });
  1818. return value;
  1819. }
  1820. var BaseException = function BaseExceptionClosure() {
  1821. function BaseException(message) {
  1822. if (this.constructor === BaseException) {
  1823. unreachable("Cannot initialize BaseException.");
  1824. }
  1825. this.message = message;
  1826. this.name = this.constructor.name;
  1827. }
  1828. BaseException.prototype = new Error();
  1829. BaseException.constructor = BaseException;
  1830. return BaseException;
  1831. }();
  1832. exports.BaseException = BaseException;
  1833. var PasswordException = /*#__PURE__*/function (_BaseException) {
  1834. _inherits(PasswordException, _BaseException);
  1835. var _super = _createSuper(PasswordException);
  1836. function PasswordException(msg, code) {
  1837. var _this;
  1838. _classCallCheck(this, PasswordException);
  1839. _this = _super.call(this, msg);
  1840. _this.code = code;
  1841. return _this;
  1842. }
  1843. return PasswordException;
  1844. }(BaseException);
  1845. exports.PasswordException = PasswordException;
  1846. var UnknownErrorException = /*#__PURE__*/function (_BaseException2) {
  1847. _inherits(UnknownErrorException, _BaseException2);
  1848. var _super2 = _createSuper(UnknownErrorException);
  1849. function UnknownErrorException(msg, details) {
  1850. var _this2;
  1851. _classCallCheck(this, UnknownErrorException);
  1852. _this2 = _super2.call(this, msg);
  1853. _this2.details = details;
  1854. return _this2;
  1855. }
  1856. return UnknownErrorException;
  1857. }(BaseException);
  1858. exports.UnknownErrorException = UnknownErrorException;
  1859. var InvalidPDFException = /*#__PURE__*/function (_BaseException3) {
  1860. _inherits(InvalidPDFException, _BaseException3);
  1861. var _super3 = _createSuper(InvalidPDFException);
  1862. function InvalidPDFException() {
  1863. _classCallCheck(this, InvalidPDFException);
  1864. return _super3.apply(this, arguments);
  1865. }
  1866. return InvalidPDFException;
  1867. }(BaseException);
  1868. exports.InvalidPDFException = InvalidPDFException;
  1869. var MissingPDFException = /*#__PURE__*/function (_BaseException4) {
  1870. _inherits(MissingPDFException, _BaseException4);
  1871. var _super4 = _createSuper(MissingPDFException);
  1872. function MissingPDFException() {
  1873. _classCallCheck(this, MissingPDFException);
  1874. return _super4.apply(this, arguments);
  1875. }
  1876. return MissingPDFException;
  1877. }(BaseException);
  1878. exports.MissingPDFException = MissingPDFException;
  1879. var UnexpectedResponseException = /*#__PURE__*/function (_BaseException5) {
  1880. _inherits(UnexpectedResponseException, _BaseException5);
  1881. var _super5 = _createSuper(UnexpectedResponseException);
  1882. function UnexpectedResponseException(msg, status) {
  1883. var _this3;
  1884. _classCallCheck(this, UnexpectedResponseException);
  1885. _this3 = _super5.call(this, msg);
  1886. _this3.status = status;
  1887. return _this3;
  1888. }
  1889. return UnexpectedResponseException;
  1890. }(BaseException);
  1891. exports.UnexpectedResponseException = UnexpectedResponseException;
  1892. var FormatError = /*#__PURE__*/function (_BaseException6) {
  1893. _inherits(FormatError, _BaseException6);
  1894. var _super6 = _createSuper(FormatError);
  1895. function FormatError() {
  1896. _classCallCheck(this, FormatError);
  1897. return _super6.apply(this, arguments);
  1898. }
  1899. return FormatError;
  1900. }(BaseException);
  1901. exports.FormatError = FormatError;
  1902. var AbortException = /*#__PURE__*/function (_BaseException7) {
  1903. _inherits(AbortException, _BaseException7);
  1904. var _super7 = _createSuper(AbortException);
  1905. function AbortException() {
  1906. _classCallCheck(this, AbortException);
  1907. return _super7.apply(this, arguments);
  1908. }
  1909. return AbortException;
  1910. }(BaseException);
  1911. exports.AbortException = AbortException;
  1912. var NullCharactersRegExp = /\x00/g;
  1913. function removeNullCharacters(str) {
  1914. if (typeof str !== "string") {
  1915. warn("The argument for removeNullCharacters must be a string.");
  1916. return str;
  1917. }
  1918. return str.replace(NullCharactersRegExp, "");
  1919. }
  1920. function bytesToString(bytes) {
  1921. assert(bytes !== null && _typeof(bytes) === "object" && bytes.length !== undefined, "Invalid argument for bytesToString");
  1922. var length = bytes.length;
  1923. var MAX_ARGUMENT_COUNT = 8192;
  1924. if (length < MAX_ARGUMENT_COUNT) {
  1925. return String.fromCharCode.apply(null, bytes);
  1926. }
  1927. var strBuf = [];
  1928. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  1929. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  1930. var chunk = bytes.subarray(i, chunkEnd);
  1931. strBuf.push(String.fromCharCode.apply(null, chunk));
  1932. }
  1933. return strBuf.join("");
  1934. }
  1935. function stringToBytes(str) {
  1936. assert(typeof str === "string", "Invalid argument for stringToBytes");
  1937. var length = str.length;
  1938. var bytes = new Uint8Array(length);
  1939. for (var i = 0; i < length; ++i) {
  1940. bytes[i] = str.charCodeAt(i) & 0xff;
  1941. }
  1942. return bytes;
  1943. }
  1944. function arrayByteLength(arr) {
  1945. if (arr.length !== undefined) {
  1946. return arr.length;
  1947. }
  1948. assert(arr.byteLength !== undefined, "arrayByteLength - invalid argument.");
  1949. return arr.byteLength;
  1950. }
  1951. function arraysToBytes(arr) {
  1952. var length = arr.length;
  1953. if (length === 1 && arr[0] instanceof Uint8Array) {
  1954. return arr[0];
  1955. }
  1956. var resultLength = 0;
  1957. for (var i = 0; i < length; i++) {
  1958. resultLength += arrayByteLength(arr[i]);
  1959. }
  1960. var pos = 0;
  1961. var data = new Uint8Array(resultLength);
  1962. for (var _i = 0; _i < length; _i++) {
  1963. var item = arr[_i];
  1964. if (!(item instanceof Uint8Array)) {
  1965. if (typeof item === "string") {
  1966. item = stringToBytes(item);
  1967. } else {
  1968. item = new Uint8Array(item);
  1969. }
  1970. }
  1971. var itemLength = item.byteLength;
  1972. data.set(item, pos);
  1973. pos += itemLength;
  1974. }
  1975. return data;
  1976. }
  1977. function string32(value) {
  1978. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  1979. }
  1980. function objectSize(obj) {
  1981. return Object.keys(obj).length;
  1982. }
  1983. function objectFromEntries(iterable) {
  1984. return Object.assign(Object.create(null), Object.fromEntries(iterable));
  1985. }
  1986. function isLittleEndian() {
  1987. var buffer8 = new Uint8Array(4);
  1988. buffer8[0] = 1;
  1989. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  1990. return view32[0] === 1;
  1991. }
  1992. var IsLittleEndianCached = {
  1993. get value() {
  1994. return shadow(this, "value", isLittleEndian());
  1995. }
  1996. };
  1997. exports.IsLittleEndianCached = IsLittleEndianCached;
  1998. function isEvalSupported() {
  1999. try {
  2000. new Function("");
  2001. return true;
  2002. } catch (e) {
  2003. return false;
  2004. }
  2005. }
  2006. var IsEvalSupportedCached = {
  2007. get value() {
  2008. return shadow(this, "value", isEvalSupported());
  2009. }
  2010. };
  2011. exports.IsEvalSupportedCached = IsEvalSupportedCached;
  2012. var hexNumbers = _toConsumableArray(Array(256).keys()).map(function (n) {
  2013. return n.toString(16).padStart(2, "0");
  2014. });
  2015. var Util = /*#__PURE__*/function () {
  2016. function Util() {
  2017. _classCallCheck(this, Util);
  2018. }
  2019. _createClass(Util, null, [{
  2020. key: "makeHexColor",
  2021. value: function makeHexColor(r, g, b) {
  2022. return "#".concat(hexNumbers[r]).concat(hexNumbers[g]).concat(hexNumbers[b]);
  2023. }
  2024. }, {
  2025. key: "transform",
  2026. value: function transform(m1, m2) {
  2027. 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]];
  2028. }
  2029. }, {
  2030. key: "applyTransform",
  2031. value: function applyTransform(p, m) {
  2032. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  2033. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  2034. return [xt, yt];
  2035. }
  2036. }, {
  2037. key: "applyInverseTransform",
  2038. value: function applyInverseTransform(p, m) {
  2039. var d = m[0] * m[3] - m[1] * m[2];
  2040. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  2041. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  2042. return [xt, yt];
  2043. }
  2044. }, {
  2045. key: "getAxialAlignedBoundingBox",
  2046. value: function getAxialAlignedBoundingBox(r, m) {
  2047. var p1 = Util.applyTransform(r, m);
  2048. var p2 = Util.applyTransform(r.slice(2, 4), m);
  2049. var p3 = Util.applyTransform([r[0], r[3]], m);
  2050. var p4 = Util.applyTransform([r[2], r[1]], m);
  2051. 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])];
  2052. }
  2053. }, {
  2054. key: "inverseTransform",
  2055. value: function inverseTransform(m) {
  2056. var d = m[0] * m[3] - m[1] * m[2];
  2057. 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];
  2058. }
  2059. }, {
  2060. key: "apply3dTransform",
  2061. value: function apply3dTransform(m, v) {
  2062. 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]];
  2063. }
  2064. }, {
  2065. key: "singularValueDecompose2dScale",
  2066. value: function singularValueDecompose2dScale(m) {
  2067. var transpose = [m[0], m[2], m[1], m[3]];
  2068. var a = m[0] * transpose[0] + m[1] * transpose[2];
  2069. var b = m[0] * transpose[1] + m[1] * transpose[3];
  2070. var c = m[2] * transpose[0] + m[3] * transpose[2];
  2071. var d = m[2] * transpose[1] + m[3] * transpose[3];
  2072. var first = (a + d) / 2;
  2073. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  2074. var sx = first + second || 1;
  2075. var sy = first - second || 1;
  2076. return [Math.sqrt(sx), Math.sqrt(sy)];
  2077. }
  2078. }, {
  2079. key: "normalizeRect",
  2080. value: function normalizeRect(rect) {
  2081. var r = rect.slice(0);
  2082. if (rect[0] > rect[2]) {
  2083. r[0] = rect[2];
  2084. r[2] = rect[0];
  2085. }
  2086. if (rect[1] > rect[3]) {
  2087. r[1] = rect[3];
  2088. r[3] = rect[1];
  2089. }
  2090. return r;
  2091. }
  2092. }, {
  2093. key: "intersect",
  2094. value: function intersect(rect1, rect2) {
  2095. function compare(a, b) {
  2096. return a - b;
  2097. }
  2098. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare);
  2099. var orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare);
  2100. var result = [];
  2101. rect1 = Util.normalizeRect(rect1);
  2102. rect2 = Util.normalizeRect(rect2);
  2103. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  2104. result[0] = orderedX[1];
  2105. result[2] = orderedX[2];
  2106. } else {
  2107. return null;
  2108. }
  2109. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  2110. result[1] = orderedY[1];
  2111. result[3] = orderedY[2];
  2112. } else {
  2113. return null;
  2114. }
  2115. return result;
  2116. }
  2117. }]);
  2118. return Util;
  2119. }();
  2120. exports.Util = Util;
  2121. 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];
  2122. function stringToPDFString(str) {
  2123. var length = str.length,
  2124. strBuf = [];
  2125. if (str[0] === "\xFE" && str[1] === "\xFF") {
  2126. for (var i = 2; i < length; i += 2) {
  2127. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  2128. }
  2129. } else if (str[0] === "\xFF" && str[1] === "\xFE") {
  2130. for (var _i2 = 2; _i2 < length; _i2 += 2) {
  2131. strBuf.push(String.fromCharCode(str.charCodeAt(_i2 + 1) << 8 | str.charCodeAt(_i2)));
  2132. }
  2133. } else {
  2134. for (var _i3 = 0; _i3 < length; ++_i3) {
  2135. var code = PDFStringTranslateTable[str.charCodeAt(_i3)];
  2136. strBuf.push(code ? String.fromCharCode(code) : str.charAt(_i3));
  2137. }
  2138. }
  2139. return strBuf.join("");
  2140. }
  2141. function escapeString(str) {
  2142. return str.replace(/([()\\\n\r])/g, function (match) {
  2143. if (match === "\n") {
  2144. return "\\n";
  2145. } else if (match === "\r") {
  2146. return "\\r";
  2147. }
  2148. return "\\".concat(match);
  2149. });
  2150. }
  2151. function isAscii(str) {
  2152. return /^[\x00-\x7F]*$/.test(str);
  2153. }
  2154. function stringToUTF16BEString(str) {
  2155. var buf = ["\xFE\xFF"];
  2156. for (var i = 0, ii = str.length; i < ii; i++) {
  2157. var _char = str.charCodeAt(i);
  2158. buf.push(String.fromCharCode(_char >> 8 & 0xff));
  2159. buf.push(String.fromCharCode(_char & 0xff));
  2160. }
  2161. return buf.join("");
  2162. }
  2163. function stringToUTF8String(str) {
  2164. return decodeURIComponent(escape(str));
  2165. }
  2166. function utf8StringToString(str) {
  2167. return unescape(encodeURIComponent(str));
  2168. }
  2169. function isBool(v) {
  2170. return typeof v === "boolean";
  2171. }
  2172. function isNum(v) {
  2173. return typeof v === "number";
  2174. }
  2175. function isString(v) {
  2176. return typeof v === "string";
  2177. }
  2178. function isArrayBuffer(v) {
  2179. return _typeof(v) === "object" && v !== null && v.byteLength !== undefined;
  2180. }
  2181. function isArrayEqual(arr1, arr2) {
  2182. if (arr1.length !== arr2.length) {
  2183. return false;
  2184. }
  2185. return arr1.every(function (element, index) {
  2186. return element === arr2[index];
  2187. });
  2188. }
  2189. function getModificationDate() {
  2190. var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
  2191. var buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
  2192. return buffer.join("");
  2193. }
  2194. function createPromiseCapability() {
  2195. var capability = Object.create(null);
  2196. var isSettled = false;
  2197. Object.defineProperty(capability, "settled", {
  2198. get: function get() {
  2199. return isSettled;
  2200. }
  2201. });
  2202. capability.promise = new Promise(function (resolve, reject) {
  2203. capability.resolve = function (data) {
  2204. isSettled = true;
  2205. resolve(data);
  2206. };
  2207. capability.reject = function (reason) {
  2208. isSettled = true;
  2209. reject(reason);
  2210. };
  2211. });
  2212. return capability;
  2213. }
  2214. var createObjectURL = function createObjectURLClosure() {
  2215. var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  2216. return function createObjectURL(data, contentType) {
  2217. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2218. if (!forceDataSchema && URL.createObjectURL) {
  2219. var blob = new Blob([data], {
  2220. type: contentType
  2221. });
  2222. return URL.createObjectURL(blob);
  2223. }
  2224. var buffer = "data:".concat(contentType, ";base64,");
  2225. for (var i = 0, ii = data.length; i < ii; i += 3) {
  2226. var b1 = data[i] & 0xff;
  2227. var b2 = data[i + 1] & 0xff;
  2228. var b3 = data[i + 2] & 0xff;
  2229. var d1 = b1 >> 2,
  2230. d2 = (b1 & 3) << 4 | b2 >> 4;
  2231. var d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
  2232. var d4 = i + 2 < ii ? b3 & 0x3f : 64;
  2233. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  2234. }
  2235. return buffer;
  2236. };
  2237. }();
  2238. exports.createObjectURL = createObjectURL;
  2239. var XMLEntities = {
  2240. 0x3c: "&lt;",
  2241. 0x3e: "&gt;",
  2242. 0x26: "&amp;",
  2243. 0x22: "&quot;",
  2244. 0x27: "&apos;"
  2245. };
  2246. function encodeToXmlString(str) {
  2247. var buffer = [];
  2248. var start = 0;
  2249. for (var i = 0, ii = str.length; i < ii; i++) {
  2250. var _char2 = str.codePointAt(i);
  2251. if (0x20 <= _char2 && _char2 <= 0x7e) {
  2252. var entity = XMLEntities[_char2];
  2253. if (entity) {
  2254. if (start < i) {
  2255. buffer.push(str.substring(start, i));
  2256. }
  2257. buffer.push(entity);
  2258. start = i + 1;
  2259. }
  2260. } else {
  2261. if (start < i) {
  2262. buffer.push(str.substring(start, i));
  2263. }
  2264. buffer.push("&#x".concat(_char2.toString(16).toUpperCase(), ";"));
  2265. if (_char2 > 0xd7ff && (_char2 < 0xe000 || _char2 > 0xfffd)) {
  2266. i++;
  2267. }
  2268. start = i + 1;
  2269. }
  2270. }
  2271. if (buffer.length === 0) {
  2272. return str;
  2273. }
  2274. if (start < str.length) {
  2275. buffer.push(str.substring(start, str.length));
  2276. }
  2277. return buffer.join("");
  2278. }
  2279. /***/ }),
  2280. /* 5 */
  2281. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2282. "use strict";
  2283. var _is_node = __w_pdfjs_require__(6);
  2284. if (typeof globalThis === "undefined" || !globalThis._pdfjsCompatibilityChecked) {
  2285. if (typeof globalThis === "undefined" || globalThis.Math !== Math) {
  2286. globalThis = __w_pdfjs_require__(7);
  2287. }
  2288. globalThis._pdfjsCompatibilityChecked = true;
  2289. (function checkNodeBtoa() {
  2290. if (globalThis.btoa || !_is_node.isNodeJS) {
  2291. return;
  2292. }
  2293. globalThis.btoa = function (chars) {
  2294. return Buffer.from(chars, "binary").toString("base64");
  2295. };
  2296. })();
  2297. (function checkNodeAtob() {
  2298. if (globalThis.atob || !_is_node.isNodeJS) {
  2299. return;
  2300. }
  2301. globalThis.atob = function (input) {
  2302. return Buffer.from(input, "base64").toString("binary");
  2303. };
  2304. })();
  2305. (function checkObjectFromEntries() {
  2306. if (Object.fromEntries) {
  2307. return;
  2308. }
  2309. __w_pdfjs_require__(52);
  2310. })();
  2311. (function checkPromise() {
  2312. if (globalThis.Promise.allSettled) {
  2313. return;
  2314. }
  2315. globalThis.Promise = __w_pdfjs_require__(82);
  2316. })();
  2317. (function checkURL() {
  2318. globalThis.URL = __w_pdfjs_require__(111);
  2319. })();
  2320. (function checkReadableStream() {
  2321. var isReadableStreamSupported = false;
  2322. if (typeof ReadableStream !== "undefined") {
  2323. try {
  2324. new ReadableStream({
  2325. start: function start(controller) {
  2326. controller.close();
  2327. }
  2328. });
  2329. isReadableStreamSupported = true;
  2330. } catch (e) {}
  2331. }
  2332. if (isReadableStreamSupported) {
  2333. return;
  2334. }
  2335. globalThis.ReadableStream = __w_pdfjs_require__(121).ReadableStream;
  2336. })();
  2337. (function checkStringPadStart() {
  2338. if (String.prototype.padStart) {
  2339. return;
  2340. }
  2341. __w_pdfjs_require__(122);
  2342. })();
  2343. (function checkStringPadEnd() {
  2344. if (String.prototype.padEnd) {
  2345. return;
  2346. }
  2347. __w_pdfjs_require__(128);
  2348. })();
  2349. (function checkObjectValues() {
  2350. if (Object.values) {
  2351. return;
  2352. }
  2353. Object.values = __w_pdfjs_require__(130);
  2354. })();
  2355. (function checkObjectEntries() {
  2356. if (Object.entries) {
  2357. return;
  2358. }
  2359. Object.entries = __w_pdfjs_require__(133);
  2360. })();
  2361. }
  2362. /***/ }),
  2363. /* 6 */
  2364. /***/ ((__unused_webpack_module, exports) => {
  2365. "use strict";
  2366. Object.defineProperty(exports, "__esModule", ({
  2367. value: true
  2368. }));
  2369. exports.isNodeJS = void 0;
  2370. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2371. var isNodeJS = (typeof process === "undefined" ? "undefined" : _typeof(process)) === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
  2372. exports.isNodeJS = isNodeJS;
  2373. /***/ }),
  2374. /* 7 */
  2375. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2376. __w_pdfjs_require__(8);
  2377. module.exports = __w_pdfjs_require__(10);
  2378. /***/ }),
  2379. /* 8 */
  2380. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2381. var $ = __w_pdfjs_require__(9);
  2382. var global = __w_pdfjs_require__(10);
  2383. $({ global: true }, { globalThis: global });
  2384. /***/ }),
  2385. /* 9 */
  2386. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2387. var global = __w_pdfjs_require__(10);
  2388. var getOwnPropertyDescriptor = __w_pdfjs_require__(11).f;
  2389. var createNonEnumerableProperty = __w_pdfjs_require__(25);
  2390. var redefine = __w_pdfjs_require__(28);
  2391. var setGlobal = __w_pdfjs_require__(29);
  2392. var copyConstructorProperties = __w_pdfjs_require__(39);
  2393. var isForced = __w_pdfjs_require__(51);
  2394. module.exports = function (options, source) {
  2395. var TARGET = options.target;
  2396. var GLOBAL = options.global;
  2397. var STATIC = options.stat;
  2398. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  2399. if (GLOBAL) {
  2400. target = global;
  2401. } else if (STATIC) {
  2402. target = global[TARGET] || setGlobal(TARGET, {});
  2403. } else {
  2404. target = (global[TARGET] || {}).prototype;
  2405. }
  2406. if (target)
  2407. for (key in source) {
  2408. sourceProperty = source[key];
  2409. if (options.noTargetGet) {
  2410. descriptor = getOwnPropertyDescriptor(target, key);
  2411. targetProperty = descriptor && descriptor.value;
  2412. } else
  2413. targetProperty = target[key];
  2414. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  2415. if (!FORCED && targetProperty !== undefined) {
  2416. if (typeof sourceProperty === typeof targetProperty)
  2417. continue;
  2418. copyConstructorProperties(sourceProperty, targetProperty);
  2419. }
  2420. if (options.sham || targetProperty && targetProperty.sham) {
  2421. createNonEnumerableProperty(sourceProperty, 'sham', true);
  2422. }
  2423. redefine(target, key, sourceProperty, options);
  2424. }
  2425. };
  2426. /***/ }),
  2427. /* 10 */
  2428. /***/ ((module) => {
  2429. var check = function (it) {
  2430. return it && it.Math == Math && it;
  2431. };
  2432. module.exports = check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || function () {
  2433. return this;
  2434. }() || Function('return this')();
  2435. /***/ }),
  2436. /* 11 */
  2437. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2438. var DESCRIPTORS = __w_pdfjs_require__(12);
  2439. var propertyIsEnumerableModule = __w_pdfjs_require__(14);
  2440. var createPropertyDescriptor = __w_pdfjs_require__(15);
  2441. var toIndexedObject = __w_pdfjs_require__(16);
  2442. var toPrimitive = __w_pdfjs_require__(20);
  2443. var has = __w_pdfjs_require__(22);
  2444. var IE8_DOM_DEFINE = __w_pdfjs_require__(23);
  2445. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  2446. exports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  2447. O = toIndexedObject(O);
  2448. P = toPrimitive(P, true);
  2449. if (IE8_DOM_DEFINE)
  2450. try {
  2451. return nativeGetOwnPropertyDescriptor(O, P);
  2452. } catch (error) {
  2453. }
  2454. if (has(O, P))
  2455. return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);
  2456. };
  2457. /***/ }),
  2458. /* 12 */
  2459. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2460. var fails = __w_pdfjs_require__(13);
  2461. module.exports = !fails(function () {
  2462. return Object.defineProperty({}, 1, {
  2463. get: function () {
  2464. return 7;
  2465. }
  2466. })[1] != 7;
  2467. });
  2468. /***/ }),
  2469. /* 13 */
  2470. /***/ ((module) => {
  2471. module.exports = function (exec) {
  2472. try {
  2473. return !!exec();
  2474. } catch (error) {
  2475. return true;
  2476. }
  2477. };
  2478. /***/ }),
  2479. /* 14 */
  2480. /***/ ((__unused_webpack_module, exports) => {
  2481. "use strict";
  2482. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  2483. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  2484. var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  2485. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  2486. var descriptor = getOwnPropertyDescriptor(this, V);
  2487. return !!descriptor && descriptor.enumerable;
  2488. } : nativePropertyIsEnumerable;
  2489. /***/ }),
  2490. /* 15 */
  2491. /***/ ((module) => {
  2492. module.exports = function (bitmap, value) {
  2493. return {
  2494. enumerable: !(bitmap & 1),
  2495. configurable: !(bitmap & 2),
  2496. writable: !(bitmap & 4),
  2497. value: value
  2498. };
  2499. };
  2500. /***/ }),
  2501. /* 16 */
  2502. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2503. var IndexedObject = __w_pdfjs_require__(17);
  2504. var requireObjectCoercible = __w_pdfjs_require__(19);
  2505. module.exports = function (it) {
  2506. return IndexedObject(requireObjectCoercible(it));
  2507. };
  2508. /***/ }),
  2509. /* 17 */
  2510. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2511. var fails = __w_pdfjs_require__(13);
  2512. var classof = __w_pdfjs_require__(18);
  2513. var split = ''.split;
  2514. module.exports = fails(function () {
  2515. return !Object('z').propertyIsEnumerable(0);
  2516. }) ? function (it) {
  2517. return classof(it) == 'String' ? split.call(it, '') : Object(it);
  2518. } : Object;
  2519. /***/ }),
  2520. /* 18 */
  2521. /***/ ((module) => {
  2522. var toString = {}.toString;
  2523. module.exports = function (it) {
  2524. return toString.call(it).slice(8, -1);
  2525. };
  2526. /***/ }),
  2527. /* 19 */
  2528. /***/ ((module) => {
  2529. module.exports = function (it) {
  2530. if (it == undefined)
  2531. throw TypeError("Can't call method on " + it);
  2532. return it;
  2533. };
  2534. /***/ }),
  2535. /* 20 */
  2536. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2537. var isObject = __w_pdfjs_require__(21);
  2538. module.exports = function (input, PREFERRED_STRING) {
  2539. if (!isObject(input))
  2540. return input;
  2541. var fn, val;
  2542. if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input)))
  2543. return val;
  2544. if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input)))
  2545. return val;
  2546. if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input)))
  2547. return val;
  2548. throw TypeError("Can't convert object to primitive value");
  2549. };
  2550. /***/ }),
  2551. /* 21 */
  2552. /***/ ((module) => {
  2553. module.exports = function (it) {
  2554. return typeof it === 'object' ? it !== null : typeof it === 'function';
  2555. };
  2556. /***/ }),
  2557. /* 22 */
  2558. /***/ ((module) => {
  2559. var hasOwnProperty = {}.hasOwnProperty;
  2560. module.exports = function (it, key) {
  2561. return hasOwnProperty.call(it, key);
  2562. };
  2563. /***/ }),
  2564. /* 23 */
  2565. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2566. var DESCRIPTORS = __w_pdfjs_require__(12);
  2567. var fails = __w_pdfjs_require__(13);
  2568. var createElement = __w_pdfjs_require__(24);
  2569. module.exports = !DESCRIPTORS && !fails(function () {
  2570. return Object.defineProperty(createElement('div'), 'a', {
  2571. get: function () {
  2572. return 7;
  2573. }
  2574. }).a != 7;
  2575. });
  2576. /***/ }),
  2577. /* 24 */
  2578. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2579. var global = __w_pdfjs_require__(10);
  2580. var isObject = __w_pdfjs_require__(21);
  2581. var document = global.document;
  2582. var EXISTS = isObject(document) && isObject(document.createElement);
  2583. module.exports = function (it) {
  2584. return EXISTS ? document.createElement(it) : {};
  2585. };
  2586. /***/ }),
  2587. /* 25 */
  2588. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2589. var DESCRIPTORS = __w_pdfjs_require__(12);
  2590. var definePropertyModule = __w_pdfjs_require__(26);
  2591. var createPropertyDescriptor = __w_pdfjs_require__(15);
  2592. module.exports = DESCRIPTORS ? function (object, key, value) {
  2593. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  2594. } : function (object, key, value) {
  2595. object[key] = value;
  2596. return object;
  2597. };
  2598. /***/ }),
  2599. /* 26 */
  2600. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2601. var DESCRIPTORS = __w_pdfjs_require__(12);
  2602. var IE8_DOM_DEFINE = __w_pdfjs_require__(23);
  2603. var anObject = __w_pdfjs_require__(27);
  2604. var toPrimitive = __w_pdfjs_require__(20);
  2605. var nativeDefineProperty = Object.defineProperty;
  2606. exports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  2607. anObject(O);
  2608. P = toPrimitive(P, true);
  2609. anObject(Attributes);
  2610. if (IE8_DOM_DEFINE)
  2611. try {
  2612. return nativeDefineProperty(O, P, Attributes);
  2613. } catch (error) {
  2614. }
  2615. if ('get' in Attributes || 'set' in Attributes)
  2616. throw TypeError('Accessors not supported');
  2617. if ('value' in Attributes)
  2618. O[P] = Attributes.value;
  2619. return O;
  2620. };
  2621. /***/ }),
  2622. /* 27 */
  2623. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2624. var isObject = __w_pdfjs_require__(21);
  2625. module.exports = function (it) {
  2626. if (!isObject(it)) {
  2627. throw TypeError(String(it) + ' is not an object');
  2628. }
  2629. return it;
  2630. };
  2631. /***/ }),
  2632. /* 28 */
  2633. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2634. var global = __w_pdfjs_require__(10);
  2635. var createNonEnumerableProperty = __w_pdfjs_require__(25);
  2636. var has = __w_pdfjs_require__(22);
  2637. var setGlobal = __w_pdfjs_require__(29);
  2638. var inspectSource = __w_pdfjs_require__(30);
  2639. var InternalStateModule = __w_pdfjs_require__(32);
  2640. var getInternalState = InternalStateModule.get;
  2641. var enforceInternalState = InternalStateModule.enforce;
  2642. var TEMPLATE = String(String).split('String');
  2643. (module.exports = function (O, key, value, options) {
  2644. var unsafe = options ? !!options.unsafe : false;
  2645. var simple = options ? !!options.enumerable : false;
  2646. var noTargetGet = options ? !!options.noTargetGet : false;
  2647. var state;
  2648. if (typeof value == 'function') {
  2649. if (typeof key == 'string' && !has(value, 'name')) {
  2650. createNonEnumerableProperty(value, 'name', key);
  2651. }
  2652. state = enforceInternalState(value);
  2653. if (!state.source) {
  2654. state.source = TEMPLATE.join(typeof key == 'string' ? key : '');
  2655. }
  2656. }
  2657. if (O === global) {
  2658. if (simple)
  2659. O[key] = value;
  2660. else
  2661. setGlobal(key, value);
  2662. return;
  2663. } else if (!unsafe) {
  2664. delete O[key];
  2665. } else if (!noTargetGet && O[key]) {
  2666. simple = true;
  2667. }
  2668. if (simple)
  2669. O[key] = value;
  2670. else
  2671. createNonEnumerableProperty(O, key, value);
  2672. })(Function.prototype, 'toString', function toString() {
  2673. return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
  2674. });
  2675. /***/ }),
  2676. /* 29 */
  2677. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2678. var global = __w_pdfjs_require__(10);
  2679. var createNonEnumerableProperty = __w_pdfjs_require__(25);
  2680. module.exports = function (key, value) {
  2681. try {
  2682. createNonEnumerableProperty(global, key, value);
  2683. } catch (error) {
  2684. global[key] = value;
  2685. }
  2686. return value;
  2687. };
  2688. /***/ }),
  2689. /* 30 */
  2690. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2691. var store = __w_pdfjs_require__(31);
  2692. var functionToString = Function.toString;
  2693. if (typeof store.inspectSource != 'function') {
  2694. store.inspectSource = function (it) {
  2695. return functionToString.call(it);
  2696. };
  2697. }
  2698. module.exports = store.inspectSource;
  2699. /***/ }),
  2700. /* 31 */
  2701. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2702. var global = __w_pdfjs_require__(10);
  2703. var setGlobal = __w_pdfjs_require__(29);
  2704. var SHARED = '__core-js_shared__';
  2705. var store = global[SHARED] || setGlobal(SHARED, {});
  2706. module.exports = store;
  2707. /***/ }),
  2708. /* 32 */
  2709. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2710. var NATIVE_WEAK_MAP = __w_pdfjs_require__(33);
  2711. var global = __w_pdfjs_require__(10);
  2712. var isObject = __w_pdfjs_require__(21);
  2713. var createNonEnumerableProperty = __w_pdfjs_require__(25);
  2714. var objectHas = __w_pdfjs_require__(22);
  2715. var shared = __w_pdfjs_require__(31);
  2716. var sharedKey = __w_pdfjs_require__(34);
  2717. var hiddenKeys = __w_pdfjs_require__(38);
  2718. var WeakMap = global.WeakMap;
  2719. var set, get, has;
  2720. var enforce = function (it) {
  2721. return has(it) ? get(it) : set(it, {});
  2722. };
  2723. var getterFor = function (TYPE) {
  2724. return function (it) {
  2725. var state;
  2726. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  2727. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  2728. }
  2729. return state;
  2730. };
  2731. };
  2732. if (NATIVE_WEAK_MAP) {
  2733. var store = shared.state || (shared.state = new WeakMap());
  2734. var wmget = store.get;
  2735. var wmhas = store.has;
  2736. var wmset = store.set;
  2737. set = function (it, metadata) {
  2738. metadata.facade = it;
  2739. wmset.call(store, it, metadata);
  2740. return metadata;
  2741. };
  2742. get = function (it) {
  2743. return wmget.call(store, it) || {};
  2744. };
  2745. has = function (it) {
  2746. return wmhas.call(store, it);
  2747. };
  2748. } else {
  2749. var STATE = sharedKey('state');
  2750. hiddenKeys[STATE] = true;
  2751. set = function (it, metadata) {
  2752. metadata.facade = it;
  2753. createNonEnumerableProperty(it, STATE, metadata);
  2754. return metadata;
  2755. };
  2756. get = function (it) {
  2757. return objectHas(it, STATE) ? it[STATE] : {};
  2758. };
  2759. has = function (it) {
  2760. return objectHas(it, STATE);
  2761. };
  2762. }
  2763. module.exports = {
  2764. set: set,
  2765. get: get,
  2766. has: has,
  2767. enforce: enforce,
  2768. getterFor: getterFor
  2769. };
  2770. /***/ }),
  2771. /* 33 */
  2772. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2773. var global = __w_pdfjs_require__(10);
  2774. var inspectSource = __w_pdfjs_require__(30);
  2775. var WeakMap = global.WeakMap;
  2776. module.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));
  2777. /***/ }),
  2778. /* 34 */
  2779. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2780. var shared = __w_pdfjs_require__(35);
  2781. var uid = __w_pdfjs_require__(37);
  2782. var keys = shared('keys');
  2783. module.exports = function (key) {
  2784. return keys[key] || (keys[key] = uid(key));
  2785. };
  2786. /***/ }),
  2787. /* 35 */
  2788. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2789. var IS_PURE = __w_pdfjs_require__(36);
  2790. var store = __w_pdfjs_require__(31);
  2791. (module.exports = function (key, value) {
  2792. return store[key] || (store[key] = value !== undefined ? value : {});
  2793. })('versions', []).push({
  2794. version: '3.8.3',
  2795. mode: IS_PURE ? 'pure' : 'global',
  2796. copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
  2797. });
  2798. /***/ }),
  2799. /* 36 */
  2800. /***/ ((module) => {
  2801. module.exports = false;
  2802. /***/ }),
  2803. /* 37 */
  2804. /***/ ((module) => {
  2805. var id = 0;
  2806. var postfix = Math.random();
  2807. module.exports = function (key) {
  2808. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  2809. };
  2810. /***/ }),
  2811. /* 38 */
  2812. /***/ ((module) => {
  2813. module.exports = {};
  2814. /***/ }),
  2815. /* 39 */
  2816. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2817. var has = __w_pdfjs_require__(22);
  2818. var ownKeys = __w_pdfjs_require__(40);
  2819. var getOwnPropertyDescriptorModule = __w_pdfjs_require__(11);
  2820. var definePropertyModule = __w_pdfjs_require__(26);
  2821. module.exports = function (target, source) {
  2822. var keys = ownKeys(source);
  2823. var defineProperty = definePropertyModule.f;
  2824. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  2825. for (var i = 0; i < keys.length; i++) {
  2826. var key = keys[i];
  2827. if (!has(target, key))
  2828. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  2829. }
  2830. };
  2831. /***/ }),
  2832. /* 40 */
  2833. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2834. var getBuiltIn = __w_pdfjs_require__(41);
  2835. var getOwnPropertyNamesModule = __w_pdfjs_require__(43);
  2836. var getOwnPropertySymbolsModule = __w_pdfjs_require__(50);
  2837. var anObject = __w_pdfjs_require__(27);
  2838. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  2839. var keys = getOwnPropertyNamesModule.f(anObject(it));
  2840. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  2841. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  2842. };
  2843. /***/ }),
  2844. /* 41 */
  2845. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2846. var path = __w_pdfjs_require__(42);
  2847. var global = __w_pdfjs_require__(10);
  2848. var aFunction = function (variable) {
  2849. return typeof variable == 'function' ? variable : undefined;
  2850. };
  2851. module.exports = function (namespace, method) {
  2852. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace]) : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  2853. };
  2854. /***/ }),
  2855. /* 42 */
  2856. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2857. var global = __w_pdfjs_require__(10);
  2858. module.exports = global;
  2859. /***/ }),
  2860. /* 43 */
  2861. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2862. var internalObjectKeys = __w_pdfjs_require__(44);
  2863. var enumBugKeys = __w_pdfjs_require__(49);
  2864. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  2865. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  2866. return internalObjectKeys(O, hiddenKeys);
  2867. };
  2868. /***/ }),
  2869. /* 44 */
  2870. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2871. var has = __w_pdfjs_require__(22);
  2872. var toIndexedObject = __w_pdfjs_require__(16);
  2873. var indexOf = __w_pdfjs_require__(45).indexOf;
  2874. var hiddenKeys = __w_pdfjs_require__(38);
  2875. module.exports = function (object, names) {
  2876. var O = toIndexedObject(object);
  2877. var i = 0;
  2878. var result = [];
  2879. var key;
  2880. for (key in O)
  2881. !has(hiddenKeys, key) && has(O, key) && result.push(key);
  2882. while (names.length > i)
  2883. if (has(O, key = names[i++])) {
  2884. ~indexOf(result, key) || result.push(key);
  2885. }
  2886. return result;
  2887. };
  2888. /***/ }),
  2889. /* 45 */
  2890. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2891. var toIndexedObject = __w_pdfjs_require__(16);
  2892. var toLength = __w_pdfjs_require__(46);
  2893. var toAbsoluteIndex = __w_pdfjs_require__(48);
  2894. var createMethod = function (IS_INCLUDES) {
  2895. return function ($this, el, fromIndex) {
  2896. var O = toIndexedObject($this);
  2897. var length = toLength(O.length);
  2898. var index = toAbsoluteIndex(fromIndex, length);
  2899. var value;
  2900. if (IS_INCLUDES && el != el)
  2901. while (length > index) {
  2902. value = O[index++];
  2903. if (value != value)
  2904. return true;
  2905. }
  2906. else
  2907. for (; length > index; index++) {
  2908. if ((IS_INCLUDES || index in O) && O[index] === el)
  2909. return IS_INCLUDES || index || 0;
  2910. }
  2911. return !IS_INCLUDES && -1;
  2912. };
  2913. };
  2914. module.exports = {
  2915. includes: createMethod(true),
  2916. indexOf: createMethod(false)
  2917. };
  2918. /***/ }),
  2919. /* 46 */
  2920. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2921. var toInteger = __w_pdfjs_require__(47);
  2922. var min = Math.min;
  2923. module.exports = function (argument) {
  2924. return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0;
  2925. };
  2926. /***/ }),
  2927. /* 47 */
  2928. /***/ ((module) => {
  2929. var ceil = Math.ceil;
  2930. var floor = Math.floor;
  2931. module.exports = function (argument) {
  2932. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  2933. };
  2934. /***/ }),
  2935. /* 48 */
  2936. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2937. var toInteger = __w_pdfjs_require__(47);
  2938. var max = Math.max;
  2939. var min = Math.min;
  2940. module.exports = function (index, length) {
  2941. var integer = toInteger(index);
  2942. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  2943. };
  2944. /***/ }),
  2945. /* 49 */
  2946. /***/ ((module) => {
  2947. module.exports = [
  2948. 'constructor',
  2949. 'hasOwnProperty',
  2950. 'isPrototypeOf',
  2951. 'propertyIsEnumerable',
  2952. 'toLocaleString',
  2953. 'toString',
  2954. 'valueOf'
  2955. ];
  2956. /***/ }),
  2957. /* 50 */
  2958. /***/ ((__unused_webpack_module, exports) => {
  2959. exports.f = Object.getOwnPropertySymbols;
  2960. /***/ }),
  2961. /* 51 */
  2962. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2963. var fails = __w_pdfjs_require__(13);
  2964. var replacement = /#|\.prototype\./;
  2965. var isForced = function (feature, detection) {
  2966. var value = data[normalize(feature)];
  2967. return value == POLYFILL ? true : value == NATIVE ? false : typeof detection == 'function' ? fails(detection) : !!detection;
  2968. };
  2969. var normalize = isForced.normalize = function (string) {
  2970. return String(string).replace(replacement, '.').toLowerCase();
  2971. };
  2972. var data = isForced.data = {};
  2973. var NATIVE = isForced.NATIVE = 'N';
  2974. var POLYFILL = isForced.POLYFILL = 'P';
  2975. module.exports = isForced;
  2976. /***/ }),
  2977. /* 52 */
  2978. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2979. __w_pdfjs_require__(53);
  2980. __w_pdfjs_require__(72);
  2981. var path = __w_pdfjs_require__(42);
  2982. module.exports = path.Object.fromEntries;
  2983. /***/ }),
  2984. /* 53 */
  2985. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2986. "use strict";
  2987. var toIndexedObject = __w_pdfjs_require__(16);
  2988. var addToUnscopables = __w_pdfjs_require__(54);
  2989. var Iterators = __w_pdfjs_require__(62);
  2990. var InternalStateModule = __w_pdfjs_require__(32);
  2991. var defineIterator = __w_pdfjs_require__(63);
  2992. var ARRAY_ITERATOR = 'Array Iterator';
  2993. var setInternalState = InternalStateModule.set;
  2994. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  2995. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  2996. setInternalState(this, {
  2997. type: ARRAY_ITERATOR,
  2998. target: toIndexedObject(iterated),
  2999. index: 0,
  3000. kind: kind
  3001. });
  3002. }, function () {
  3003. var state = getInternalState(this);
  3004. var target = state.target;
  3005. var kind = state.kind;
  3006. var index = state.index++;
  3007. if (!target || index >= target.length) {
  3008. state.target = undefined;
  3009. return {
  3010. value: undefined,
  3011. done: true
  3012. };
  3013. }
  3014. if (kind == 'keys')
  3015. return {
  3016. value: index,
  3017. done: false
  3018. };
  3019. if (kind == 'values')
  3020. return {
  3021. value: target[index],
  3022. done: false
  3023. };
  3024. return {
  3025. value: [
  3026. index,
  3027. target[index]
  3028. ],
  3029. done: false
  3030. };
  3031. }, 'values');
  3032. Iterators.Arguments = Iterators.Array;
  3033. addToUnscopables('keys');
  3034. addToUnscopables('values');
  3035. addToUnscopables('entries');
  3036. /***/ }),
  3037. /* 54 */
  3038. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3039. var wellKnownSymbol = __w_pdfjs_require__(55);
  3040. var create = __w_pdfjs_require__(58);
  3041. var definePropertyModule = __w_pdfjs_require__(26);
  3042. var UNSCOPABLES = wellKnownSymbol('unscopables');
  3043. var ArrayPrototype = Array.prototype;
  3044. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  3045. definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
  3046. configurable: true,
  3047. value: create(null)
  3048. });
  3049. }
  3050. module.exports = function (key) {
  3051. ArrayPrototype[UNSCOPABLES][key] = true;
  3052. };
  3053. /***/ }),
  3054. /* 55 */
  3055. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3056. var global = __w_pdfjs_require__(10);
  3057. var shared = __w_pdfjs_require__(35);
  3058. var has = __w_pdfjs_require__(22);
  3059. var uid = __w_pdfjs_require__(37);
  3060. var NATIVE_SYMBOL = __w_pdfjs_require__(56);
  3061. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(57);
  3062. var WellKnownSymbolsStore = shared('wks');
  3063. var Symbol = global.Symbol;
  3064. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
  3065. module.exports = function (name) {
  3066. if (!has(WellKnownSymbolsStore, name)) {
  3067. if (NATIVE_SYMBOL && has(Symbol, name))
  3068. WellKnownSymbolsStore[name] = Symbol[name];
  3069. else
  3070. WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  3071. }
  3072. return WellKnownSymbolsStore[name];
  3073. };
  3074. /***/ }),
  3075. /* 56 */
  3076. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3077. var fails = __w_pdfjs_require__(13);
  3078. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  3079. return !String(Symbol());
  3080. });
  3081. /***/ }),
  3082. /* 57 */
  3083. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3084. var NATIVE_SYMBOL = __w_pdfjs_require__(56);
  3085. module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol';
  3086. /***/ }),
  3087. /* 58 */
  3088. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3089. var anObject = __w_pdfjs_require__(27);
  3090. var defineProperties = __w_pdfjs_require__(59);
  3091. var enumBugKeys = __w_pdfjs_require__(49);
  3092. var hiddenKeys = __w_pdfjs_require__(38);
  3093. var html = __w_pdfjs_require__(61);
  3094. var documentCreateElement = __w_pdfjs_require__(24);
  3095. var sharedKey = __w_pdfjs_require__(34);
  3096. var GT = '>';
  3097. var LT = '<';
  3098. var PROTOTYPE = 'prototype';
  3099. var SCRIPT = 'script';
  3100. var IE_PROTO = sharedKey('IE_PROTO');
  3101. var EmptyConstructor = function () {
  3102. };
  3103. var scriptTag = function (content) {
  3104. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  3105. };
  3106. var NullProtoObjectViaActiveX = function (activeXDocument) {
  3107. activeXDocument.write(scriptTag(''));
  3108. activeXDocument.close();
  3109. var temp = activeXDocument.parentWindow.Object;
  3110. activeXDocument = null;
  3111. return temp;
  3112. };
  3113. var NullProtoObjectViaIFrame = function () {
  3114. var iframe = documentCreateElement('iframe');
  3115. var JS = 'java' + SCRIPT + ':';
  3116. var iframeDocument;
  3117. iframe.style.display = 'none';
  3118. html.appendChild(iframe);
  3119. iframe.src = String(JS);
  3120. iframeDocument = iframe.contentWindow.document;
  3121. iframeDocument.open();
  3122. iframeDocument.write(scriptTag('document.F=Object'));
  3123. iframeDocument.close();
  3124. return iframeDocument.F;
  3125. };
  3126. var activeXDocument;
  3127. var NullProtoObject = function () {
  3128. try {
  3129. activeXDocument = document.domain && new ActiveXObject('htmlfile');
  3130. } catch (error) {
  3131. }
  3132. NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
  3133. var length = enumBugKeys.length;
  3134. while (length--)
  3135. delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  3136. return NullProtoObject();
  3137. };
  3138. hiddenKeys[IE_PROTO] = true;
  3139. module.exports = Object.create || function create(O, Properties) {
  3140. var result;
  3141. if (O !== null) {
  3142. EmptyConstructor[PROTOTYPE] = anObject(O);
  3143. result = new EmptyConstructor();
  3144. EmptyConstructor[PROTOTYPE] = null;
  3145. result[IE_PROTO] = O;
  3146. } else
  3147. result = NullProtoObject();
  3148. return Properties === undefined ? result : defineProperties(result, Properties);
  3149. };
  3150. /***/ }),
  3151. /* 59 */
  3152. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3153. var DESCRIPTORS = __w_pdfjs_require__(12);
  3154. var definePropertyModule = __w_pdfjs_require__(26);
  3155. var anObject = __w_pdfjs_require__(27);
  3156. var objectKeys = __w_pdfjs_require__(60);
  3157. module.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  3158. anObject(O);
  3159. var keys = objectKeys(Properties);
  3160. var length = keys.length;
  3161. var index = 0;
  3162. var key;
  3163. while (length > index)
  3164. definePropertyModule.f(O, key = keys[index++], Properties[key]);
  3165. return O;
  3166. };
  3167. /***/ }),
  3168. /* 60 */
  3169. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3170. var internalObjectKeys = __w_pdfjs_require__(44);
  3171. var enumBugKeys = __w_pdfjs_require__(49);
  3172. module.exports = Object.keys || function keys(O) {
  3173. return internalObjectKeys(O, enumBugKeys);
  3174. };
  3175. /***/ }),
  3176. /* 61 */
  3177. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3178. var getBuiltIn = __w_pdfjs_require__(41);
  3179. module.exports = getBuiltIn('document', 'documentElement');
  3180. /***/ }),
  3181. /* 62 */
  3182. /***/ ((module) => {
  3183. module.exports = {};
  3184. /***/ }),
  3185. /* 63 */
  3186. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3187. "use strict";
  3188. var $ = __w_pdfjs_require__(9);
  3189. var createIteratorConstructor = __w_pdfjs_require__(64);
  3190. var getPrototypeOf = __w_pdfjs_require__(66);
  3191. var setPrototypeOf = __w_pdfjs_require__(70);
  3192. var setToStringTag = __w_pdfjs_require__(69);
  3193. var createNonEnumerableProperty = __w_pdfjs_require__(25);
  3194. var redefine = __w_pdfjs_require__(28);
  3195. var wellKnownSymbol = __w_pdfjs_require__(55);
  3196. var IS_PURE = __w_pdfjs_require__(36);
  3197. var Iterators = __w_pdfjs_require__(62);
  3198. var IteratorsCore = __w_pdfjs_require__(65);
  3199. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  3200. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  3201. var ITERATOR = wellKnownSymbol('iterator');
  3202. var KEYS = 'keys';
  3203. var VALUES = 'values';
  3204. var ENTRIES = 'entries';
  3205. var returnThis = function () {
  3206. return this;
  3207. };
  3208. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  3209. createIteratorConstructor(IteratorConstructor, NAME, next);
  3210. var getIterationMethod = function (KIND) {
  3211. if (KIND === DEFAULT && defaultIterator)
  3212. return defaultIterator;
  3213. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype)
  3214. return IterablePrototype[KIND];
  3215. switch (KIND) {
  3216. case KEYS:
  3217. return function keys() {
  3218. return new IteratorConstructor(this, KIND);
  3219. };
  3220. case VALUES:
  3221. return function values() {
  3222. return new IteratorConstructor(this, KIND);
  3223. };
  3224. case ENTRIES:
  3225. return function entries() {
  3226. return new IteratorConstructor(this, KIND);
  3227. };
  3228. }
  3229. return function () {
  3230. return new IteratorConstructor(this);
  3231. };
  3232. };
  3233. var TO_STRING_TAG = NAME + ' Iterator';
  3234. var INCORRECT_VALUES_NAME = false;
  3235. var IterablePrototype = Iterable.prototype;
  3236. var nativeIterator = IterablePrototype[ITERATOR] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT];
  3237. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  3238. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  3239. var CurrentIteratorPrototype, methods, KEY;
  3240. if (anyNativeIterator) {
  3241. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  3242. if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  3243. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  3244. if (setPrototypeOf) {
  3245. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  3246. } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') {
  3247. createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR, returnThis);
  3248. }
  3249. }
  3250. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  3251. if (IS_PURE)
  3252. Iterators[TO_STRING_TAG] = returnThis;
  3253. }
  3254. }
  3255. if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  3256. INCORRECT_VALUES_NAME = true;
  3257. defaultIterator = function values() {
  3258. return nativeIterator.call(this);
  3259. };
  3260. }
  3261. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  3262. createNonEnumerableProperty(IterablePrototype, ITERATOR, defaultIterator);
  3263. }
  3264. Iterators[NAME] = defaultIterator;
  3265. if (DEFAULT) {
  3266. methods = {
  3267. values: getIterationMethod(VALUES),
  3268. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  3269. entries: getIterationMethod(ENTRIES)
  3270. };
  3271. if (FORCED)
  3272. for (KEY in methods) {
  3273. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  3274. redefine(IterablePrototype, KEY, methods[KEY]);
  3275. }
  3276. }
  3277. else
  3278. $({
  3279. target: NAME,
  3280. proto: true,
  3281. forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME
  3282. }, methods);
  3283. }
  3284. return methods;
  3285. };
  3286. /***/ }),
  3287. /* 64 */
  3288. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3289. "use strict";
  3290. var IteratorPrototype = __w_pdfjs_require__(65).IteratorPrototype;
  3291. var create = __w_pdfjs_require__(58);
  3292. var createPropertyDescriptor = __w_pdfjs_require__(15);
  3293. var setToStringTag = __w_pdfjs_require__(69);
  3294. var Iterators = __w_pdfjs_require__(62);
  3295. var returnThis = function () {
  3296. return this;
  3297. };
  3298. module.exports = function (IteratorConstructor, NAME, next) {
  3299. var TO_STRING_TAG = NAME + ' Iterator';
  3300. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(1, next) });
  3301. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  3302. Iterators[TO_STRING_TAG] = returnThis;
  3303. return IteratorConstructor;
  3304. };
  3305. /***/ }),
  3306. /* 65 */
  3307. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3308. "use strict";
  3309. var fails = __w_pdfjs_require__(13);
  3310. var getPrototypeOf = __w_pdfjs_require__(66);
  3311. var createNonEnumerableProperty = __w_pdfjs_require__(25);
  3312. var has = __w_pdfjs_require__(22);
  3313. var wellKnownSymbol = __w_pdfjs_require__(55);
  3314. var IS_PURE = __w_pdfjs_require__(36);
  3315. var ITERATOR = wellKnownSymbol('iterator');
  3316. var BUGGY_SAFARI_ITERATORS = false;
  3317. var returnThis = function () {
  3318. return this;
  3319. };
  3320. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  3321. if ([].keys) {
  3322. arrayIterator = [].keys();
  3323. if (!('next' in arrayIterator))
  3324. BUGGY_SAFARI_ITERATORS = true;
  3325. else {
  3326. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  3327. if (PrototypeOfArrayIteratorPrototype !== Object.prototype)
  3328. IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  3329. }
  3330. }
  3331. var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () {
  3332. var test = {};
  3333. return IteratorPrototype[ITERATOR].call(test) !== test;
  3334. });
  3335. if (NEW_ITERATOR_PROTOTYPE)
  3336. IteratorPrototype = {};
  3337. if ((!IS_PURE || NEW_ITERATOR_PROTOTYPE) && !has(IteratorPrototype, ITERATOR)) {
  3338. createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);
  3339. }
  3340. module.exports = {
  3341. IteratorPrototype: IteratorPrototype,
  3342. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  3343. };
  3344. /***/ }),
  3345. /* 66 */
  3346. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3347. var has = __w_pdfjs_require__(22);
  3348. var toObject = __w_pdfjs_require__(67);
  3349. var sharedKey = __w_pdfjs_require__(34);
  3350. var CORRECT_PROTOTYPE_GETTER = __w_pdfjs_require__(68);
  3351. var IE_PROTO = sharedKey('IE_PROTO');
  3352. var ObjectPrototype = Object.prototype;
  3353. module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
  3354. O = toObject(O);
  3355. if (has(O, IE_PROTO))
  3356. return O[IE_PROTO];
  3357. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  3358. return O.constructor.prototype;
  3359. }
  3360. return O instanceof Object ? ObjectPrototype : null;
  3361. };
  3362. /***/ }),
  3363. /* 67 */
  3364. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3365. var requireObjectCoercible = __w_pdfjs_require__(19);
  3366. module.exports = function (argument) {
  3367. return Object(requireObjectCoercible(argument));
  3368. };
  3369. /***/ }),
  3370. /* 68 */
  3371. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3372. var fails = __w_pdfjs_require__(13);
  3373. module.exports = !fails(function () {
  3374. function F() {
  3375. }
  3376. F.prototype.constructor = null;
  3377. return Object.getPrototypeOf(new F()) !== F.prototype;
  3378. });
  3379. /***/ }),
  3380. /* 69 */
  3381. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3382. var defineProperty = __w_pdfjs_require__(26).f;
  3383. var has = __w_pdfjs_require__(22);
  3384. var wellKnownSymbol = __w_pdfjs_require__(55);
  3385. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  3386. module.exports = function (it, TAG, STATIC) {
  3387. if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
  3388. defineProperty(it, TO_STRING_TAG, {
  3389. configurable: true,
  3390. value: TAG
  3391. });
  3392. }
  3393. };
  3394. /***/ }),
  3395. /* 70 */
  3396. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3397. var anObject = __w_pdfjs_require__(27);
  3398. var aPossiblePrototype = __w_pdfjs_require__(71);
  3399. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  3400. var CORRECT_SETTER = false;
  3401. var test = {};
  3402. var setter;
  3403. try {
  3404. setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
  3405. setter.call(test, []);
  3406. CORRECT_SETTER = test instanceof Array;
  3407. } catch (error) {
  3408. }
  3409. return function setPrototypeOf(O, proto) {
  3410. anObject(O);
  3411. aPossiblePrototype(proto);
  3412. if (CORRECT_SETTER)
  3413. setter.call(O, proto);
  3414. else
  3415. O.__proto__ = proto;
  3416. return O;
  3417. };
  3418. }() : undefined);
  3419. /***/ }),
  3420. /* 71 */
  3421. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3422. var isObject = __w_pdfjs_require__(21);
  3423. module.exports = function (it) {
  3424. if (!isObject(it) && it !== null) {
  3425. throw TypeError("Can't set " + String(it) + ' as a prototype');
  3426. }
  3427. return it;
  3428. };
  3429. /***/ }),
  3430. /* 72 */
  3431. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3432. var $ = __w_pdfjs_require__(9);
  3433. var iterate = __w_pdfjs_require__(73);
  3434. var createProperty = __w_pdfjs_require__(81);
  3435. $({
  3436. target: 'Object',
  3437. stat: true
  3438. }, {
  3439. fromEntries: function fromEntries(iterable) {
  3440. var obj = {};
  3441. iterate(iterable, function (k, v) {
  3442. createProperty(obj, k, v);
  3443. }, { AS_ENTRIES: true });
  3444. return obj;
  3445. }
  3446. });
  3447. /***/ }),
  3448. /* 73 */
  3449. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3450. var anObject = __w_pdfjs_require__(27);
  3451. var isArrayIteratorMethod = __w_pdfjs_require__(74);
  3452. var toLength = __w_pdfjs_require__(46);
  3453. var bind = __w_pdfjs_require__(75);
  3454. var getIteratorMethod = __w_pdfjs_require__(77);
  3455. var iteratorClose = __w_pdfjs_require__(80);
  3456. var Result = function (stopped, result) {
  3457. this.stopped = stopped;
  3458. this.result = result;
  3459. };
  3460. module.exports = function (iterable, unboundFunction, options) {
  3461. var that = options && options.that;
  3462. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  3463. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  3464. var INTERRUPTED = !!(options && options.INTERRUPTED);
  3465. var fn = bind(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED);
  3466. var iterator, iterFn, index, length, result, next, step;
  3467. var stop = function (condition) {
  3468. if (iterator)
  3469. iteratorClose(iterator);
  3470. return new Result(true, condition);
  3471. };
  3472. var callFn = function (value) {
  3473. if (AS_ENTRIES) {
  3474. anObject(value);
  3475. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  3476. }
  3477. return INTERRUPTED ? fn(value, stop) : fn(value);
  3478. };
  3479. if (IS_ITERATOR) {
  3480. iterator = iterable;
  3481. } else {
  3482. iterFn = getIteratorMethod(iterable);
  3483. if (typeof iterFn != 'function')
  3484. throw TypeError('Target is not iterable');
  3485. if (isArrayIteratorMethod(iterFn)) {
  3486. for (index = 0, length = toLength(iterable.length); length > index; index++) {
  3487. result = callFn(iterable[index]);
  3488. if (result && result instanceof Result)
  3489. return result;
  3490. }
  3491. return new Result(false);
  3492. }
  3493. iterator = iterFn.call(iterable);
  3494. }
  3495. next = iterator.next;
  3496. while (!(step = next.call(iterator)).done) {
  3497. try {
  3498. result = callFn(step.value);
  3499. } catch (error) {
  3500. iteratorClose(iterator);
  3501. throw error;
  3502. }
  3503. if (typeof result == 'object' && result && result instanceof Result)
  3504. return result;
  3505. }
  3506. return new Result(false);
  3507. };
  3508. /***/ }),
  3509. /* 74 */
  3510. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3511. var wellKnownSymbol = __w_pdfjs_require__(55);
  3512. var Iterators = __w_pdfjs_require__(62);
  3513. var ITERATOR = wellKnownSymbol('iterator');
  3514. var ArrayPrototype = Array.prototype;
  3515. module.exports = function (it) {
  3516. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  3517. };
  3518. /***/ }),
  3519. /* 75 */
  3520. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3521. var aFunction = __w_pdfjs_require__(76);
  3522. module.exports = function (fn, that, length) {
  3523. aFunction(fn);
  3524. if (that === undefined)
  3525. return fn;
  3526. switch (length) {
  3527. case 0:
  3528. return function () {
  3529. return fn.call(that);
  3530. };
  3531. case 1:
  3532. return function (a) {
  3533. return fn.call(that, a);
  3534. };
  3535. case 2:
  3536. return function (a, b) {
  3537. return fn.call(that, a, b);
  3538. };
  3539. case 3:
  3540. return function (a, b, c) {
  3541. return fn.call(that, a, b, c);
  3542. };
  3543. }
  3544. return function () {
  3545. return fn.apply(that, arguments);
  3546. };
  3547. };
  3548. /***/ }),
  3549. /* 76 */
  3550. /***/ ((module) => {
  3551. module.exports = function (it) {
  3552. if (typeof it != 'function') {
  3553. throw TypeError(String(it) + ' is not a function');
  3554. }
  3555. return it;
  3556. };
  3557. /***/ }),
  3558. /* 77 */
  3559. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3560. var classof = __w_pdfjs_require__(78);
  3561. var Iterators = __w_pdfjs_require__(62);
  3562. var wellKnownSymbol = __w_pdfjs_require__(55);
  3563. var ITERATOR = wellKnownSymbol('iterator');
  3564. module.exports = function (it) {
  3565. if (it != undefined)
  3566. return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
  3567. };
  3568. /***/ }),
  3569. /* 78 */
  3570. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3571. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(79);
  3572. var classofRaw = __w_pdfjs_require__(18);
  3573. var wellKnownSymbol = __w_pdfjs_require__(55);
  3574. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  3575. var CORRECT_ARGUMENTS = classofRaw(function () {
  3576. return arguments;
  3577. }()) == 'Arguments';
  3578. var tryGet = function (it, key) {
  3579. try {
  3580. return it[key];
  3581. } catch (error) {
  3582. }
  3583. };
  3584. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  3585. var O, tag, result;
  3586. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag : CORRECT_ARGUMENTS ? classofRaw(O) : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  3587. };
  3588. /***/ }),
  3589. /* 79 */
  3590. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3591. var wellKnownSymbol = __w_pdfjs_require__(55);
  3592. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  3593. var test = {};
  3594. test[TO_STRING_TAG] = 'z';
  3595. module.exports = String(test) === '[object z]';
  3596. /***/ }),
  3597. /* 80 */
  3598. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3599. var anObject = __w_pdfjs_require__(27);
  3600. module.exports = function (iterator) {
  3601. var returnMethod = iterator['return'];
  3602. if (returnMethod !== undefined) {
  3603. return anObject(returnMethod.call(iterator)).value;
  3604. }
  3605. };
  3606. /***/ }),
  3607. /* 81 */
  3608. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3609. "use strict";
  3610. var toPrimitive = __w_pdfjs_require__(20);
  3611. var definePropertyModule = __w_pdfjs_require__(26);
  3612. var createPropertyDescriptor = __w_pdfjs_require__(15);
  3613. module.exports = function (object, key, value) {
  3614. var propertyKey = toPrimitive(key);
  3615. if (propertyKey in object)
  3616. definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  3617. else
  3618. object[propertyKey] = value;
  3619. };
  3620. /***/ }),
  3621. /* 82 */
  3622. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3623. __w_pdfjs_require__(83);
  3624. __w_pdfjs_require__(84);
  3625. __w_pdfjs_require__(86);
  3626. __w_pdfjs_require__(104);
  3627. __w_pdfjs_require__(105);
  3628. __w_pdfjs_require__(106);
  3629. __w_pdfjs_require__(107);
  3630. __w_pdfjs_require__(109);
  3631. var path = __w_pdfjs_require__(42);
  3632. module.exports = path.Promise;
  3633. /***/ }),
  3634. /* 83 */
  3635. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3636. "use strict";
  3637. var $ = __w_pdfjs_require__(9);
  3638. var getPrototypeOf = __w_pdfjs_require__(66);
  3639. var setPrototypeOf = __w_pdfjs_require__(70);
  3640. var create = __w_pdfjs_require__(58);
  3641. var createNonEnumerableProperty = __w_pdfjs_require__(25);
  3642. var createPropertyDescriptor = __w_pdfjs_require__(15);
  3643. var iterate = __w_pdfjs_require__(73);
  3644. var $AggregateError = function AggregateError(errors, message) {
  3645. var that = this;
  3646. if (!(that instanceof $AggregateError))
  3647. return new $AggregateError(errors, message);
  3648. if (setPrototypeOf) {
  3649. that = setPrototypeOf(new Error(undefined), getPrototypeOf(that));
  3650. }
  3651. if (message !== undefined)
  3652. createNonEnumerableProperty(that, 'message', String(message));
  3653. var errorsArray = [];
  3654. iterate(errors, errorsArray.push, { that: errorsArray });
  3655. createNonEnumerableProperty(that, 'errors', errorsArray);
  3656. return that;
  3657. };
  3658. $AggregateError.prototype = create(Error.prototype, {
  3659. constructor: createPropertyDescriptor(5, $AggregateError),
  3660. message: createPropertyDescriptor(5, ''),
  3661. name: createPropertyDescriptor(5, 'AggregateError')
  3662. });
  3663. $({ global: true }, { AggregateError: $AggregateError });
  3664. /***/ }),
  3665. /* 84 */
  3666. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3667. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(79);
  3668. var redefine = __w_pdfjs_require__(28);
  3669. var toString = __w_pdfjs_require__(85);
  3670. if (!TO_STRING_TAG_SUPPORT) {
  3671. redefine(Object.prototype, 'toString', toString, { unsafe: true });
  3672. }
  3673. /***/ }),
  3674. /* 85 */
  3675. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3676. "use strict";
  3677. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(79);
  3678. var classof = __w_pdfjs_require__(78);
  3679. module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
  3680. return '[object ' + classof(this) + ']';
  3681. };
  3682. /***/ }),
  3683. /* 86 */
  3684. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3685. "use strict";
  3686. var $ = __w_pdfjs_require__(9);
  3687. var IS_PURE = __w_pdfjs_require__(36);
  3688. var global = __w_pdfjs_require__(10);
  3689. var getBuiltIn = __w_pdfjs_require__(41);
  3690. var NativePromise = __w_pdfjs_require__(87);
  3691. var redefine = __w_pdfjs_require__(28);
  3692. var redefineAll = __w_pdfjs_require__(88);
  3693. var setToStringTag = __w_pdfjs_require__(69);
  3694. var setSpecies = __w_pdfjs_require__(89);
  3695. var isObject = __w_pdfjs_require__(21);
  3696. var aFunction = __w_pdfjs_require__(76);
  3697. var anInstance = __w_pdfjs_require__(90);
  3698. var inspectSource = __w_pdfjs_require__(30);
  3699. var iterate = __w_pdfjs_require__(73);
  3700. var checkCorrectnessOfIteration = __w_pdfjs_require__(91);
  3701. var speciesConstructor = __w_pdfjs_require__(92);
  3702. var task = __w_pdfjs_require__(93).set;
  3703. var microtask = __w_pdfjs_require__(97);
  3704. var promiseResolve = __w_pdfjs_require__(99);
  3705. var hostReportErrors = __w_pdfjs_require__(101);
  3706. var newPromiseCapabilityModule = __w_pdfjs_require__(100);
  3707. var perform = __w_pdfjs_require__(102);
  3708. var InternalStateModule = __w_pdfjs_require__(32);
  3709. var isForced = __w_pdfjs_require__(51);
  3710. var wellKnownSymbol = __w_pdfjs_require__(55);
  3711. var IS_NODE = __w_pdfjs_require__(96);
  3712. var V8_VERSION = __w_pdfjs_require__(103);
  3713. var SPECIES = wellKnownSymbol('species');
  3714. var PROMISE = 'Promise';
  3715. var getInternalState = InternalStateModule.get;
  3716. var setInternalState = InternalStateModule.set;
  3717. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  3718. var PromiseConstructor = NativePromise;
  3719. var TypeError = global.TypeError;
  3720. var document = global.document;
  3721. var process = global.process;
  3722. var $fetch = getBuiltIn('fetch');
  3723. var newPromiseCapability = newPromiseCapabilityModule.f;
  3724. var newGenericPromiseCapability = newPromiseCapability;
  3725. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  3726. var NATIVE_REJECTION_EVENT = typeof PromiseRejectionEvent == 'function';
  3727. var UNHANDLED_REJECTION = 'unhandledrejection';
  3728. var REJECTION_HANDLED = 'rejectionhandled';
  3729. var PENDING = 0;
  3730. var FULFILLED = 1;
  3731. var REJECTED = 2;
  3732. var HANDLED = 1;
  3733. var UNHANDLED = 2;
  3734. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  3735. var FORCED = isForced(PROMISE, function () {
  3736. var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
  3737. if (!GLOBAL_CORE_JS_PROMISE) {
  3738. if (V8_VERSION === 66)
  3739. return true;
  3740. if (!IS_NODE && !NATIVE_REJECTION_EVENT)
  3741. return true;
  3742. }
  3743. if (IS_PURE && !PromiseConstructor.prototype['finally'])
  3744. return true;
  3745. if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor))
  3746. return false;
  3747. var promise = PromiseConstructor.resolve(1);
  3748. var FakePromise = function (exec) {
  3749. exec(function () {
  3750. }, function () {
  3751. });
  3752. };
  3753. var constructor = promise.constructor = {};
  3754. constructor[SPECIES] = FakePromise;
  3755. return !(promise.then(function () {
  3756. }) instanceof FakePromise);
  3757. });
  3758. var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
  3759. PromiseConstructor.all(iterable)['catch'](function () {
  3760. });
  3761. });
  3762. var isThenable = function (it) {
  3763. var then;
  3764. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  3765. };
  3766. var notify = function (state, isReject) {
  3767. if (state.notified)
  3768. return;
  3769. state.notified = true;
  3770. var chain = state.reactions;
  3771. microtask(function () {
  3772. var value = state.value;
  3773. var ok = state.state == FULFILLED;
  3774. var index = 0;
  3775. while (chain.length > index) {
  3776. var reaction = chain[index++];
  3777. var handler = ok ? reaction.ok : reaction.fail;
  3778. var resolve = reaction.resolve;
  3779. var reject = reaction.reject;
  3780. var domain = reaction.domain;
  3781. var result, then, exited;
  3782. try {
  3783. if (handler) {
  3784. if (!ok) {
  3785. if (state.rejection === UNHANDLED)
  3786. onHandleUnhandled(state);
  3787. state.rejection = HANDLED;
  3788. }
  3789. if (handler === true)
  3790. result = value;
  3791. else {
  3792. if (domain)
  3793. domain.enter();
  3794. result = handler(value);
  3795. if (domain) {
  3796. domain.exit();
  3797. exited = true;
  3798. }
  3799. }
  3800. if (result === reaction.promise) {
  3801. reject(TypeError('Promise-chain cycle'));
  3802. } else if (then = isThenable(result)) {
  3803. then.call(result, resolve, reject);
  3804. } else
  3805. resolve(result);
  3806. } else
  3807. reject(value);
  3808. } catch (error) {
  3809. if (domain && !exited)
  3810. domain.exit();
  3811. reject(error);
  3812. }
  3813. }
  3814. state.reactions = [];
  3815. state.notified = false;
  3816. if (isReject && !state.rejection)
  3817. onUnhandled(state);
  3818. });
  3819. };
  3820. var dispatchEvent = function (name, promise, reason) {
  3821. var event, handler;
  3822. if (DISPATCH_EVENT) {
  3823. event = document.createEvent('Event');
  3824. event.promise = promise;
  3825. event.reason = reason;
  3826. event.initEvent(name, false, true);
  3827. global.dispatchEvent(event);
  3828. } else
  3829. event = {
  3830. promise: promise,
  3831. reason: reason
  3832. };
  3833. if (!NATIVE_REJECTION_EVENT && (handler = global['on' + name]))
  3834. handler(event);
  3835. else if (name === UNHANDLED_REJECTION)
  3836. hostReportErrors('Unhandled promise rejection', reason);
  3837. };
  3838. var onUnhandled = function (state) {
  3839. task.call(global, function () {
  3840. var promise = state.facade;
  3841. var value = state.value;
  3842. var IS_UNHANDLED = isUnhandled(state);
  3843. var result;
  3844. if (IS_UNHANDLED) {
  3845. result = perform(function () {
  3846. if (IS_NODE) {
  3847. process.emit('unhandledRejection', value, promise);
  3848. } else
  3849. dispatchEvent(UNHANDLED_REJECTION, promise, value);
  3850. });
  3851. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  3852. if (result.error)
  3853. throw result.value;
  3854. }
  3855. });
  3856. };
  3857. var isUnhandled = function (state) {
  3858. return state.rejection !== HANDLED && !state.parent;
  3859. };
  3860. var onHandleUnhandled = function (state) {
  3861. task.call(global, function () {
  3862. var promise = state.facade;
  3863. if (IS_NODE) {
  3864. process.emit('rejectionHandled', promise);
  3865. } else
  3866. dispatchEvent(REJECTION_HANDLED, promise, state.value);
  3867. });
  3868. };
  3869. var bind = function (fn, state, unwrap) {
  3870. return function (value) {
  3871. fn(state, value, unwrap);
  3872. };
  3873. };
  3874. var internalReject = function (state, value, unwrap) {
  3875. if (state.done)
  3876. return;
  3877. state.done = true;
  3878. if (unwrap)
  3879. state = unwrap;
  3880. state.value = value;
  3881. state.state = REJECTED;
  3882. notify(state, true);
  3883. };
  3884. var internalResolve = function (state, value, unwrap) {
  3885. if (state.done)
  3886. return;
  3887. state.done = true;
  3888. if (unwrap)
  3889. state = unwrap;
  3890. try {
  3891. if (state.facade === value)
  3892. throw TypeError("Promise can't be resolved itself");
  3893. var then = isThenable(value);
  3894. if (then) {
  3895. microtask(function () {
  3896. var wrapper = { done: false };
  3897. try {
  3898. then.call(value, bind(internalResolve, wrapper, state), bind(internalReject, wrapper, state));
  3899. } catch (error) {
  3900. internalReject(wrapper, error, state);
  3901. }
  3902. });
  3903. } else {
  3904. state.value = value;
  3905. state.state = FULFILLED;
  3906. notify(state, false);
  3907. }
  3908. } catch (error) {
  3909. internalReject({ done: false }, error, state);
  3910. }
  3911. };
  3912. if (FORCED) {
  3913. PromiseConstructor = function Promise(executor) {
  3914. anInstance(this, PromiseConstructor, PROMISE);
  3915. aFunction(executor);
  3916. Internal.call(this);
  3917. var state = getInternalState(this);
  3918. try {
  3919. executor(bind(internalResolve, state), bind(internalReject, state));
  3920. } catch (error) {
  3921. internalReject(state, error);
  3922. }
  3923. };
  3924. Internal = function Promise(executor) {
  3925. setInternalState(this, {
  3926. type: PROMISE,
  3927. done: false,
  3928. notified: false,
  3929. parent: false,
  3930. reactions: [],
  3931. rejection: false,
  3932. state: PENDING,
  3933. value: undefined
  3934. });
  3935. };
  3936. Internal.prototype = redefineAll(PromiseConstructor.prototype, {
  3937. then: function then(onFulfilled, onRejected) {
  3938. var state = getInternalPromiseState(this);
  3939. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  3940. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  3941. reaction.fail = typeof onRejected == 'function' && onRejected;
  3942. reaction.domain = IS_NODE ? process.domain : undefined;
  3943. state.parent = true;
  3944. state.reactions.push(reaction);
  3945. if (state.state != PENDING)
  3946. notify(state, false);
  3947. return reaction.promise;
  3948. },
  3949. 'catch': function (onRejected) {
  3950. return this.then(undefined, onRejected);
  3951. }
  3952. });
  3953. OwnPromiseCapability = function () {
  3954. var promise = new Internal();
  3955. var state = getInternalState(promise);
  3956. this.promise = promise;
  3957. this.resolve = bind(internalResolve, state);
  3958. this.reject = bind(internalReject, state);
  3959. };
  3960. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  3961. return C === PromiseConstructor || C === PromiseWrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
  3962. };
  3963. if (!IS_PURE && typeof NativePromise == 'function') {
  3964. nativeThen = NativePromise.prototype.then;
  3965. redefine(NativePromise.prototype, 'then', function then(onFulfilled, onRejected) {
  3966. var that = this;
  3967. return new PromiseConstructor(function (resolve, reject) {
  3968. nativeThen.call(that, resolve, reject);
  3969. }).then(onFulfilled, onRejected);
  3970. }, { unsafe: true });
  3971. if (typeof $fetch == 'function')
  3972. $({
  3973. global: true,
  3974. enumerable: true,
  3975. forced: true
  3976. }, {
  3977. fetch: function fetch(input) {
  3978. return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));
  3979. }
  3980. });
  3981. }
  3982. }
  3983. $({
  3984. global: true,
  3985. wrap: true,
  3986. forced: FORCED
  3987. }, { Promise: PromiseConstructor });
  3988. setToStringTag(PromiseConstructor, PROMISE, false, true);
  3989. setSpecies(PROMISE);
  3990. PromiseWrapper = getBuiltIn(PROMISE);
  3991. $({
  3992. target: PROMISE,
  3993. stat: true,
  3994. forced: FORCED
  3995. }, {
  3996. reject: function reject(r) {
  3997. var capability = newPromiseCapability(this);
  3998. capability.reject.call(undefined, r);
  3999. return capability.promise;
  4000. }
  4001. });
  4002. $({
  4003. target: PROMISE,
  4004. stat: true,
  4005. forced: IS_PURE || FORCED
  4006. }, {
  4007. resolve: function resolve(x) {
  4008. return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);
  4009. }
  4010. });
  4011. $({
  4012. target: PROMISE,
  4013. stat: true,
  4014. forced: INCORRECT_ITERATION
  4015. }, {
  4016. all: function all(iterable) {
  4017. var C = this;
  4018. var capability = newPromiseCapability(C);
  4019. var resolve = capability.resolve;
  4020. var reject = capability.reject;
  4021. var result = perform(function () {
  4022. var $promiseResolve = aFunction(C.resolve);
  4023. var values = [];
  4024. var counter = 0;
  4025. var remaining = 1;
  4026. iterate(iterable, function (promise) {
  4027. var index = counter++;
  4028. var alreadyCalled = false;
  4029. values.push(undefined);
  4030. remaining++;
  4031. $promiseResolve.call(C, promise).then(function (value) {
  4032. if (alreadyCalled)
  4033. return;
  4034. alreadyCalled = true;
  4035. values[index] = value;
  4036. --remaining || resolve(values);
  4037. }, reject);
  4038. });
  4039. --remaining || resolve(values);
  4040. });
  4041. if (result.error)
  4042. reject(result.value);
  4043. return capability.promise;
  4044. },
  4045. race: function race(iterable) {
  4046. var C = this;
  4047. var capability = newPromiseCapability(C);
  4048. var reject = capability.reject;
  4049. var result = perform(function () {
  4050. var $promiseResolve = aFunction(C.resolve);
  4051. iterate(iterable, function (promise) {
  4052. $promiseResolve.call(C, promise).then(capability.resolve, reject);
  4053. });
  4054. });
  4055. if (result.error)
  4056. reject(result.value);
  4057. return capability.promise;
  4058. }
  4059. });
  4060. /***/ }),
  4061. /* 87 */
  4062. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4063. var global = __w_pdfjs_require__(10);
  4064. module.exports = global.Promise;
  4065. /***/ }),
  4066. /* 88 */
  4067. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4068. var redefine = __w_pdfjs_require__(28);
  4069. module.exports = function (target, src, options) {
  4070. for (var key in src)
  4071. redefine(target, key, src[key], options);
  4072. return target;
  4073. };
  4074. /***/ }),
  4075. /* 89 */
  4076. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4077. "use strict";
  4078. var getBuiltIn = __w_pdfjs_require__(41);
  4079. var definePropertyModule = __w_pdfjs_require__(26);
  4080. var wellKnownSymbol = __w_pdfjs_require__(55);
  4081. var DESCRIPTORS = __w_pdfjs_require__(12);
  4082. var SPECIES = wellKnownSymbol('species');
  4083. module.exports = function (CONSTRUCTOR_NAME) {
  4084. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  4085. var defineProperty = definePropertyModule.f;
  4086. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  4087. defineProperty(Constructor, SPECIES, {
  4088. configurable: true,
  4089. get: function () {
  4090. return this;
  4091. }
  4092. });
  4093. }
  4094. };
  4095. /***/ }),
  4096. /* 90 */
  4097. /***/ ((module) => {
  4098. module.exports = function (it, Constructor, name) {
  4099. if (!(it instanceof Constructor)) {
  4100. throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
  4101. }
  4102. return it;
  4103. };
  4104. /***/ }),
  4105. /* 91 */
  4106. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4107. var wellKnownSymbol = __w_pdfjs_require__(55);
  4108. var ITERATOR = wellKnownSymbol('iterator');
  4109. var SAFE_CLOSING = false;
  4110. try {
  4111. var called = 0;
  4112. var iteratorWithReturn = {
  4113. next: function () {
  4114. return { done: !!called++ };
  4115. },
  4116. 'return': function () {
  4117. SAFE_CLOSING = true;
  4118. }
  4119. };
  4120. iteratorWithReturn[ITERATOR] = function () {
  4121. return this;
  4122. };
  4123. Array.from(iteratorWithReturn, function () {
  4124. throw 2;
  4125. });
  4126. } catch (error) {
  4127. }
  4128. module.exports = function (exec, SKIP_CLOSING) {
  4129. if (!SKIP_CLOSING && !SAFE_CLOSING)
  4130. return false;
  4131. var ITERATION_SUPPORT = false;
  4132. try {
  4133. var object = {};
  4134. object[ITERATOR] = function () {
  4135. return {
  4136. next: function () {
  4137. return { done: ITERATION_SUPPORT = true };
  4138. }
  4139. };
  4140. };
  4141. exec(object);
  4142. } catch (error) {
  4143. }
  4144. return ITERATION_SUPPORT;
  4145. };
  4146. /***/ }),
  4147. /* 92 */
  4148. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4149. var anObject = __w_pdfjs_require__(27);
  4150. var aFunction = __w_pdfjs_require__(76);
  4151. var wellKnownSymbol = __w_pdfjs_require__(55);
  4152. var SPECIES = wellKnownSymbol('species');
  4153. module.exports = function (O, defaultConstructor) {
  4154. var C = anObject(O).constructor;
  4155. var S;
  4156. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);
  4157. };
  4158. /***/ }),
  4159. /* 93 */
  4160. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4161. var global = __w_pdfjs_require__(10);
  4162. var fails = __w_pdfjs_require__(13);
  4163. var bind = __w_pdfjs_require__(75);
  4164. var html = __w_pdfjs_require__(61);
  4165. var createElement = __w_pdfjs_require__(24);
  4166. var IS_IOS = __w_pdfjs_require__(94);
  4167. var IS_NODE = __w_pdfjs_require__(96);
  4168. var location = global.location;
  4169. var set = global.setImmediate;
  4170. var clear = global.clearImmediate;
  4171. var process = global.process;
  4172. var MessageChannel = global.MessageChannel;
  4173. var Dispatch = global.Dispatch;
  4174. var counter = 0;
  4175. var queue = {};
  4176. var ONREADYSTATECHANGE = 'onreadystatechange';
  4177. var defer, channel, port;
  4178. var run = function (id) {
  4179. if (queue.hasOwnProperty(id)) {
  4180. var fn = queue[id];
  4181. delete queue[id];
  4182. fn();
  4183. }
  4184. };
  4185. var runner = function (id) {
  4186. return function () {
  4187. run(id);
  4188. };
  4189. };
  4190. var listener = function (event) {
  4191. run(event.data);
  4192. };
  4193. var post = function (id) {
  4194. global.postMessage(id + '', location.protocol + '//' + location.host);
  4195. };
  4196. if (!set || !clear) {
  4197. set = function setImmediate(fn) {
  4198. var args = [];
  4199. var i = 1;
  4200. while (arguments.length > i)
  4201. args.push(arguments[i++]);
  4202. queue[++counter] = function () {
  4203. (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
  4204. };
  4205. defer(counter);
  4206. return counter;
  4207. };
  4208. clear = function clearImmediate(id) {
  4209. delete queue[id];
  4210. };
  4211. if (IS_NODE) {
  4212. defer = function (id) {
  4213. process.nextTick(runner(id));
  4214. };
  4215. } else if (Dispatch && Dispatch.now) {
  4216. defer = function (id) {
  4217. Dispatch.now(runner(id));
  4218. };
  4219. } else if (MessageChannel && !IS_IOS) {
  4220. channel = new MessageChannel();
  4221. port = channel.port2;
  4222. channel.port1.onmessage = listener;
  4223. defer = bind(port.postMessage, port, 1);
  4224. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts && location && location.protocol !== 'file:' && !fails(post)) {
  4225. defer = post;
  4226. global.addEventListener('message', listener, false);
  4227. } else if (ONREADYSTATECHANGE in createElement('script')) {
  4228. defer = function (id) {
  4229. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  4230. html.removeChild(this);
  4231. run(id);
  4232. };
  4233. };
  4234. } else {
  4235. defer = function (id) {
  4236. setTimeout(runner(id), 0);
  4237. };
  4238. }
  4239. }
  4240. module.exports = {
  4241. set: set,
  4242. clear: clear
  4243. };
  4244. /***/ }),
  4245. /* 94 */
  4246. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4247. var userAgent = __w_pdfjs_require__(95);
  4248. module.exports = /(iphone|ipod|ipad).*applewebkit/i.test(userAgent);
  4249. /***/ }),
  4250. /* 95 */
  4251. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4252. var getBuiltIn = __w_pdfjs_require__(41);
  4253. module.exports = getBuiltIn('navigator', 'userAgent') || '';
  4254. /***/ }),
  4255. /* 96 */
  4256. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4257. var classof = __w_pdfjs_require__(18);
  4258. var global = __w_pdfjs_require__(10);
  4259. module.exports = classof(global.process) == 'process';
  4260. /***/ }),
  4261. /* 97 */
  4262. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4263. var global = __w_pdfjs_require__(10);
  4264. var getOwnPropertyDescriptor = __w_pdfjs_require__(11).f;
  4265. var macrotask = __w_pdfjs_require__(93).set;
  4266. var IS_IOS = __w_pdfjs_require__(94);
  4267. var IS_WEBOS_WEBKIT = __w_pdfjs_require__(98);
  4268. var IS_NODE = __w_pdfjs_require__(96);
  4269. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  4270. var document = global.document;
  4271. var process = global.process;
  4272. var Promise = global.Promise;
  4273. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  4274. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  4275. var flush, head, last, notify, toggle, node, promise, then;
  4276. if (!queueMicrotask) {
  4277. flush = function () {
  4278. var parent, fn;
  4279. if (IS_NODE && (parent = process.domain))
  4280. parent.exit();
  4281. while (head) {
  4282. fn = head.fn;
  4283. head = head.next;
  4284. try {
  4285. fn();
  4286. } catch (error) {
  4287. if (head)
  4288. notify();
  4289. else
  4290. last = undefined;
  4291. throw error;
  4292. }
  4293. }
  4294. last = undefined;
  4295. if (parent)
  4296. parent.enter();
  4297. };
  4298. if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
  4299. toggle = true;
  4300. node = document.createTextNode('');
  4301. new MutationObserver(flush).observe(node, { characterData: true });
  4302. notify = function () {
  4303. node.data = toggle = !toggle;
  4304. };
  4305. } else if (Promise && Promise.resolve) {
  4306. promise = Promise.resolve(undefined);
  4307. then = promise.then;
  4308. notify = function () {
  4309. then.call(promise, flush);
  4310. };
  4311. } else if (IS_NODE) {
  4312. notify = function () {
  4313. process.nextTick(flush);
  4314. };
  4315. } else {
  4316. notify = function () {
  4317. macrotask.call(global, flush);
  4318. };
  4319. }
  4320. }
  4321. module.exports = queueMicrotask || function (fn) {
  4322. var task = {
  4323. fn: fn,
  4324. next: undefined
  4325. };
  4326. if (last)
  4327. last.next = task;
  4328. if (!head) {
  4329. head = task;
  4330. notify();
  4331. }
  4332. last = task;
  4333. };
  4334. /***/ }),
  4335. /* 98 */
  4336. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4337. var userAgent = __w_pdfjs_require__(95);
  4338. module.exports = /web0s(?!.*chrome)/i.test(userAgent);
  4339. /***/ }),
  4340. /* 99 */
  4341. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4342. var anObject = __w_pdfjs_require__(27);
  4343. var isObject = __w_pdfjs_require__(21);
  4344. var newPromiseCapability = __w_pdfjs_require__(100);
  4345. module.exports = function (C, x) {
  4346. anObject(C);
  4347. if (isObject(x) && x.constructor === C)
  4348. return x;
  4349. var promiseCapability = newPromiseCapability.f(C);
  4350. var resolve = promiseCapability.resolve;
  4351. resolve(x);
  4352. return promiseCapability.promise;
  4353. };
  4354. /***/ }),
  4355. /* 100 */
  4356. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4357. "use strict";
  4358. var aFunction = __w_pdfjs_require__(76);
  4359. var PromiseCapability = function (C) {
  4360. var resolve, reject;
  4361. this.promise = new C(function ($$resolve, $$reject) {
  4362. if (resolve !== undefined || reject !== undefined)
  4363. throw TypeError('Bad Promise constructor');
  4364. resolve = $$resolve;
  4365. reject = $$reject;
  4366. });
  4367. this.resolve = aFunction(resolve);
  4368. this.reject = aFunction(reject);
  4369. };
  4370. module.exports.f = function (C) {
  4371. return new PromiseCapability(C);
  4372. };
  4373. /***/ }),
  4374. /* 101 */
  4375. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4376. var global = __w_pdfjs_require__(10);
  4377. module.exports = function (a, b) {
  4378. var console = global.console;
  4379. if (console && console.error) {
  4380. arguments.length === 1 ? console.error(a) : console.error(a, b);
  4381. }
  4382. };
  4383. /***/ }),
  4384. /* 102 */
  4385. /***/ ((module) => {
  4386. module.exports = function (exec) {
  4387. try {
  4388. return {
  4389. error: false,
  4390. value: exec()
  4391. };
  4392. } catch (error) {
  4393. return {
  4394. error: true,
  4395. value: error
  4396. };
  4397. }
  4398. };
  4399. /***/ }),
  4400. /* 103 */
  4401. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4402. var global = __w_pdfjs_require__(10);
  4403. var userAgent = __w_pdfjs_require__(95);
  4404. var process = global.process;
  4405. var versions = process && process.versions;
  4406. var v8 = versions && versions.v8;
  4407. var match, version;
  4408. if (v8) {
  4409. match = v8.split('.');
  4410. version = match[0] + match[1];
  4411. } else if (userAgent) {
  4412. match = userAgent.match(/Edge\/(\d+)/);
  4413. if (!match || match[1] >= 74) {
  4414. match = userAgent.match(/Chrome\/(\d+)/);
  4415. if (match)
  4416. version = match[1];
  4417. }
  4418. }
  4419. module.exports = version && +version;
  4420. /***/ }),
  4421. /* 104 */
  4422. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4423. "use strict";
  4424. var $ = __w_pdfjs_require__(9);
  4425. var aFunction = __w_pdfjs_require__(76);
  4426. var newPromiseCapabilityModule = __w_pdfjs_require__(100);
  4427. var perform = __w_pdfjs_require__(102);
  4428. var iterate = __w_pdfjs_require__(73);
  4429. $({
  4430. target: 'Promise',
  4431. stat: true
  4432. }, {
  4433. allSettled: function allSettled(iterable) {
  4434. var C = this;
  4435. var capability = newPromiseCapabilityModule.f(C);
  4436. var resolve = capability.resolve;
  4437. var reject = capability.reject;
  4438. var result = perform(function () {
  4439. var promiseResolve = aFunction(C.resolve);
  4440. var values = [];
  4441. var counter = 0;
  4442. var remaining = 1;
  4443. iterate(iterable, function (promise) {
  4444. var index = counter++;
  4445. var alreadyCalled = false;
  4446. values.push(undefined);
  4447. remaining++;
  4448. promiseResolve.call(C, promise).then(function (value) {
  4449. if (alreadyCalled)
  4450. return;
  4451. alreadyCalled = true;
  4452. values[index] = {
  4453. status: 'fulfilled',
  4454. value: value
  4455. };
  4456. --remaining || resolve(values);
  4457. }, function (error) {
  4458. if (alreadyCalled)
  4459. return;
  4460. alreadyCalled = true;
  4461. values[index] = {
  4462. status: 'rejected',
  4463. reason: error
  4464. };
  4465. --remaining || resolve(values);
  4466. });
  4467. });
  4468. --remaining || resolve(values);
  4469. });
  4470. if (result.error)
  4471. reject(result.value);
  4472. return capability.promise;
  4473. }
  4474. });
  4475. /***/ }),
  4476. /* 105 */
  4477. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4478. "use strict";
  4479. var $ = __w_pdfjs_require__(9);
  4480. var aFunction = __w_pdfjs_require__(76);
  4481. var getBuiltIn = __w_pdfjs_require__(41);
  4482. var newPromiseCapabilityModule = __w_pdfjs_require__(100);
  4483. var perform = __w_pdfjs_require__(102);
  4484. var iterate = __w_pdfjs_require__(73);
  4485. var PROMISE_ANY_ERROR = 'No one promise resolved';
  4486. $({
  4487. target: 'Promise',
  4488. stat: true
  4489. }, {
  4490. any: function any(iterable) {
  4491. var C = this;
  4492. var capability = newPromiseCapabilityModule.f(C);
  4493. var resolve = capability.resolve;
  4494. var reject = capability.reject;
  4495. var result = perform(function () {
  4496. var promiseResolve = aFunction(C.resolve);
  4497. var errors = [];
  4498. var counter = 0;
  4499. var remaining = 1;
  4500. var alreadyResolved = false;
  4501. iterate(iterable, function (promise) {
  4502. var index = counter++;
  4503. var alreadyRejected = false;
  4504. errors.push(undefined);
  4505. remaining++;
  4506. promiseResolve.call(C, promise).then(function (value) {
  4507. if (alreadyRejected || alreadyResolved)
  4508. return;
  4509. alreadyResolved = true;
  4510. resolve(value);
  4511. }, function (error) {
  4512. if (alreadyRejected || alreadyResolved)
  4513. return;
  4514. alreadyRejected = true;
  4515. errors[index] = error;
  4516. --remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));
  4517. });
  4518. });
  4519. --remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));
  4520. });
  4521. if (result.error)
  4522. reject(result.value);
  4523. return capability.promise;
  4524. }
  4525. });
  4526. /***/ }),
  4527. /* 106 */
  4528. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4529. "use strict";
  4530. var $ = __w_pdfjs_require__(9);
  4531. var IS_PURE = __w_pdfjs_require__(36);
  4532. var NativePromise = __w_pdfjs_require__(87);
  4533. var fails = __w_pdfjs_require__(13);
  4534. var getBuiltIn = __w_pdfjs_require__(41);
  4535. var speciesConstructor = __w_pdfjs_require__(92);
  4536. var promiseResolve = __w_pdfjs_require__(99);
  4537. var redefine = __w_pdfjs_require__(28);
  4538. var NON_GENERIC = !!NativePromise && fails(function () {
  4539. NativePromise.prototype['finally'].call({
  4540. then: function () {
  4541. }
  4542. }, function () {
  4543. });
  4544. });
  4545. $({
  4546. target: 'Promise',
  4547. proto: true,
  4548. real: true,
  4549. forced: NON_GENERIC
  4550. }, {
  4551. 'finally': function (onFinally) {
  4552. var C = speciesConstructor(this, getBuiltIn('Promise'));
  4553. var isFunction = typeof onFinally == 'function';
  4554. return this.then(isFunction ? function (x) {
  4555. return promiseResolve(C, onFinally()).then(function () {
  4556. return x;
  4557. });
  4558. } : onFinally, isFunction ? function (e) {
  4559. return promiseResolve(C, onFinally()).then(function () {
  4560. throw e;
  4561. });
  4562. } : onFinally);
  4563. }
  4564. });
  4565. if (!IS_PURE && typeof NativePromise == 'function' && !NativePromise.prototype['finally']) {
  4566. redefine(NativePromise.prototype, 'finally', getBuiltIn('Promise').prototype['finally']);
  4567. }
  4568. /***/ }),
  4569. /* 107 */
  4570. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4571. "use strict";
  4572. var charAt = __w_pdfjs_require__(108).charAt;
  4573. var InternalStateModule = __w_pdfjs_require__(32);
  4574. var defineIterator = __w_pdfjs_require__(63);
  4575. var STRING_ITERATOR = 'String Iterator';
  4576. var setInternalState = InternalStateModule.set;
  4577. var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
  4578. defineIterator(String, 'String', function (iterated) {
  4579. setInternalState(this, {
  4580. type: STRING_ITERATOR,
  4581. string: String(iterated),
  4582. index: 0
  4583. });
  4584. }, function next() {
  4585. var state = getInternalState(this);
  4586. var string = state.string;
  4587. var index = state.index;
  4588. var point;
  4589. if (index >= string.length)
  4590. return {
  4591. value: undefined,
  4592. done: true
  4593. };
  4594. point = charAt(string, index);
  4595. state.index += point.length;
  4596. return {
  4597. value: point,
  4598. done: false
  4599. };
  4600. });
  4601. /***/ }),
  4602. /* 108 */
  4603. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4604. var toInteger = __w_pdfjs_require__(47);
  4605. var requireObjectCoercible = __w_pdfjs_require__(19);
  4606. var createMethod = function (CONVERT_TO_STRING) {
  4607. return function ($this, pos) {
  4608. var S = String(requireObjectCoercible($this));
  4609. var position = toInteger(pos);
  4610. var size = S.length;
  4611. var first, second;
  4612. if (position < 0 || position >= size)
  4613. return CONVERT_TO_STRING ? '' : undefined;
  4614. first = S.charCodeAt(position);
  4615. return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? S.charAt(position) : first : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  4616. };
  4617. };
  4618. module.exports = {
  4619. codeAt: createMethod(false),
  4620. charAt: createMethod(true)
  4621. };
  4622. /***/ }),
  4623. /* 109 */
  4624. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4625. var global = __w_pdfjs_require__(10);
  4626. var DOMIterables = __w_pdfjs_require__(110);
  4627. var ArrayIteratorMethods = __w_pdfjs_require__(53);
  4628. var createNonEnumerableProperty = __w_pdfjs_require__(25);
  4629. var wellKnownSymbol = __w_pdfjs_require__(55);
  4630. var ITERATOR = wellKnownSymbol('iterator');
  4631. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  4632. var ArrayValues = ArrayIteratorMethods.values;
  4633. for (var COLLECTION_NAME in DOMIterables) {
  4634. var Collection = global[COLLECTION_NAME];
  4635. var CollectionPrototype = Collection && Collection.prototype;
  4636. if (CollectionPrototype) {
  4637. if (CollectionPrototype[ITERATOR] !== ArrayValues)
  4638. try {
  4639. createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);
  4640. } catch (error) {
  4641. CollectionPrototype[ITERATOR] = ArrayValues;
  4642. }
  4643. if (!CollectionPrototype[TO_STRING_TAG]) {
  4644. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  4645. }
  4646. if (DOMIterables[COLLECTION_NAME])
  4647. for (var METHOD_NAME in ArrayIteratorMethods) {
  4648. if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME])
  4649. try {
  4650. createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);
  4651. } catch (error) {
  4652. CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];
  4653. }
  4654. }
  4655. }
  4656. }
  4657. /***/ }),
  4658. /* 110 */
  4659. /***/ ((module) => {
  4660. module.exports = {
  4661. CSSRuleList: 0,
  4662. CSSStyleDeclaration: 0,
  4663. CSSValueList: 0,
  4664. ClientRectList: 0,
  4665. DOMRectList: 0,
  4666. DOMStringList: 0,
  4667. DOMTokenList: 1,
  4668. DataTransferItemList: 0,
  4669. FileList: 0,
  4670. HTMLAllCollection: 0,
  4671. HTMLCollection: 0,
  4672. HTMLFormElement: 0,
  4673. HTMLSelectElement: 0,
  4674. MediaList: 0,
  4675. MimeTypeArray: 0,
  4676. NamedNodeMap: 0,
  4677. NodeList: 1,
  4678. PaintRequestList: 0,
  4679. Plugin: 0,
  4680. PluginArray: 0,
  4681. SVGLengthList: 0,
  4682. SVGNumberList: 0,
  4683. SVGPathSegList: 0,
  4684. SVGPointList: 0,
  4685. SVGStringList: 0,
  4686. SVGTransformList: 0,
  4687. SourceBufferList: 0,
  4688. StyleSheetList: 0,
  4689. TextTrackCueList: 0,
  4690. TextTrackList: 0,
  4691. TouchList: 0
  4692. };
  4693. /***/ }),
  4694. /* 111 */
  4695. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4696. __w_pdfjs_require__(112);
  4697. __w_pdfjs_require__(120);
  4698. __w_pdfjs_require__(118);
  4699. var path = __w_pdfjs_require__(42);
  4700. module.exports = path.URL;
  4701. /***/ }),
  4702. /* 112 */
  4703. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4704. "use strict";
  4705. __w_pdfjs_require__(107);
  4706. var $ = __w_pdfjs_require__(9);
  4707. var DESCRIPTORS = __w_pdfjs_require__(12);
  4708. var USE_NATIVE_URL = __w_pdfjs_require__(113);
  4709. var global = __w_pdfjs_require__(10);
  4710. var defineProperties = __w_pdfjs_require__(59);
  4711. var redefine = __w_pdfjs_require__(28);
  4712. var anInstance = __w_pdfjs_require__(90);
  4713. var has = __w_pdfjs_require__(22);
  4714. var assign = __w_pdfjs_require__(114);
  4715. var arrayFrom = __w_pdfjs_require__(115);
  4716. var codeAt = __w_pdfjs_require__(108).codeAt;
  4717. var toASCII = __w_pdfjs_require__(117);
  4718. var setToStringTag = __w_pdfjs_require__(69);
  4719. var URLSearchParamsModule = __w_pdfjs_require__(118);
  4720. var InternalStateModule = __w_pdfjs_require__(32);
  4721. var NativeURL = global.URL;
  4722. var URLSearchParams = URLSearchParamsModule.URLSearchParams;
  4723. var getInternalSearchParamsState = URLSearchParamsModule.getState;
  4724. var setInternalState = InternalStateModule.set;
  4725. var getInternalURLState = InternalStateModule.getterFor('URL');
  4726. var floor = Math.floor;
  4727. var pow = Math.pow;
  4728. var INVALID_AUTHORITY = 'Invalid authority';
  4729. var INVALID_SCHEME = 'Invalid scheme';
  4730. var INVALID_HOST = 'Invalid host';
  4731. var INVALID_PORT = 'Invalid port';
  4732. var ALPHA = /[A-Za-z]/;
  4733. var ALPHANUMERIC = /[\d+-.A-Za-z]/;
  4734. var DIGIT = /\d/;
  4735. var HEX_START = /^(0x|0X)/;
  4736. var OCT = /^[0-7]+$/;
  4737. var DEC = /^\d+$/;
  4738. var HEX = /^[\dA-Fa-f]+$/;
  4739. var FORBIDDEN_HOST_CODE_POINT = /[\u0000\u0009\u000A\u000D #%/:?@[\\]]/;
  4740. var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\u0000\u0009\u000A\u000D #/:?@[\\]]/;
  4741. var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g;
  4742. var TAB_AND_NEW_LINE = /[\u0009\u000A\u000D]/g;
  4743. var EOF;
  4744. var parseHost = function (url, input) {
  4745. var result, codePoints, index;
  4746. if (input.charAt(0) == '[') {
  4747. if (input.charAt(input.length - 1) != ']')
  4748. return INVALID_HOST;
  4749. result = parseIPv6(input.slice(1, -1));
  4750. if (!result)
  4751. return INVALID_HOST;
  4752. url.host = result;
  4753. } else if (!isSpecial(url)) {
  4754. if (FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT.test(input))
  4755. return INVALID_HOST;
  4756. result = '';
  4757. codePoints = arrayFrom(input);
  4758. for (index = 0; index < codePoints.length; index++) {
  4759. result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
  4760. }
  4761. url.host = result;
  4762. } else {
  4763. input = toASCII(input);
  4764. if (FORBIDDEN_HOST_CODE_POINT.test(input))
  4765. return INVALID_HOST;
  4766. result = parseIPv4(input);
  4767. if (result === null)
  4768. return INVALID_HOST;
  4769. url.host = result;
  4770. }
  4771. };
  4772. var parseIPv4 = function (input) {
  4773. var parts = input.split('.');
  4774. var partsLength, numbers, index, part, radix, number, ipv4;
  4775. if (parts.length && parts[parts.length - 1] == '') {
  4776. parts.pop();
  4777. }
  4778. partsLength = parts.length;
  4779. if (partsLength > 4)
  4780. return input;
  4781. numbers = [];
  4782. for (index = 0; index < partsLength; index++) {
  4783. part = parts[index];
  4784. if (part == '')
  4785. return input;
  4786. radix = 10;
  4787. if (part.length > 1 && part.charAt(0) == '0') {
  4788. radix = HEX_START.test(part) ? 16 : 8;
  4789. part = part.slice(radix == 8 ? 1 : 2);
  4790. }
  4791. if (part === '') {
  4792. number = 0;
  4793. } else {
  4794. if (!(radix == 10 ? DEC : radix == 8 ? OCT : HEX).test(part))
  4795. return input;
  4796. number = parseInt(part, radix);
  4797. }
  4798. numbers.push(number);
  4799. }
  4800. for (index = 0; index < partsLength; index++) {
  4801. number = numbers[index];
  4802. if (index == partsLength - 1) {
  4803. if (number >= pow(256, 5 - partsLength))
  4804. return null;
  4805. } else if (number > 255)
  4806. return null;
  4807. }
  4808. ipv4 = numbers.pop();
  4809. for (index = 0; index < numbers.length; index++) {
  4810. ipv4 += numbers[index] * pow(256, 3 - index);
  4811. }
  4812. return ipv4;
  4813. };
  4814. var parseIPv6 = function (input) {
  4815. var address = [
  4816. 0,
  4817. 0,
  4818. 0,
  4819. 0,
  4820. 0,
  4821. 0,
  4822. 0,
  4823. 0
  4824. ];
  4825. var pieceIndex = 0;
  4826. var compress = null;
  4827. var pointer = 0;
  4828. var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
  4829. var char = function () {
  4830. return input.charAt(pointer);
  4831. };
  4832. if (char() == ':') {
  4833. if (input.charAt(1) != ':')
  4834. return;
  4835. pointer += 2;
  4836. pieceIndex++;
  4837. compress = pieceIndex;
  4838. }
  4839. while (char()) {
  4840. if (pieceIndex == 8)
  4841. return;
  4842. if (char() == ':') {
  4843. if (compress !== null)
  4844. return;
  4845. pointer++;
  4846. pieceIndex++;
  4847. compress = pieceIndex;
  4848. continue;
  4849. }
  4850. value = length = 0;
  4851. while (length < 4 && HEX.test(char())) {
  4852. value = value * 16 + parseInt(char(), 16);
  4853. pointer++;
  4854. length++;
  4855. }
  4856. if (char() == '.') {
  4857. if (length == 0)
  4858. return;
  4859. pointer -= length;
  4860. if (pieceIndex > 6)
  4861. return;
  4862. numbersSeen = 0;
  4863. while (char()) {
  4864. ipv4Piece = null;
  4865. if (numbersSeen > 0) {
  4866. if (char() == '.' && numbersSeen < 4)
  4867. pointer++;
  4868. else
  4869. return;
  4870. }
  4871. if (!DIGIT.test(char()))
  4872. return;
  4873. while (DIGIT.test(char())) {
  4874. number = parseInt(char(), 10);
  4875. if (ipv4Piece === null)
  4876. ipv4Piece = number;
  4877. else if (ipv4Piece == 0)
  4878. return;
  4879. else
  4880. ipv4Piece = ipv4Piece * 10 + number;
  4881. if (ipv4Piece > 255)
  4882. return;
  4883. pointer++;
  4884. }
  4885. address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
  4886. numbersSeen++;
  4887. if (numbersSeen == 2 || numbersSeen == 4)
  4888. pieceIndex++;
  4889. }
  4890. if (numbersSeen != 4)
  4891. return;
  4892. break;
  4893. } else if (char() == ':') {
  4894. pointer++;
  4895. if (!char())
  4896. return;
  4897. } else if (char())
  4898. return;
  4899. address[pieceIndex++] = value;
  4900. }
  4901. if (compress !== null) {
  4902. swaps = pieceIndex - compress;
  4903. pieceIndex = 7;
  4904. while (pieceIndex != 0 && swaps > 0) {
  4905. swap = address[pieceIndex];
  4906. address[pieceIndex--] = address[compress + swaps - 1];
  4907. address[compress + --swaps] = swap;
  4908. }
  4909. } else if (pieceIndex != 8)
  4910. return;
  4911. return address;
  4912. };
  4913. var findLongestZeroSequence = function (ipv6) {
  4914. var maxIndex = null;
  4915. var maxLength = 1;
  4916. var currStart = null;
  4917. var currLength = 0;
  4918. var index = 0;
  4919. for (; index < 8; index++) {
  4920. if (ipv6[index] !== 0) {
  4921. if (currLength > maxLength) {
  4922. maxIndex = currStart;
  4923. maxLength = currLength;
  4924. }
  4925. currStart = null;
  4926. currLength = 0;
  4927. } else {
  4928. if (currStart === null)
  4929. currStart = index;
  4930. ++currLength;
  4931. }
  4932. }
  4933. if (currLength > maxLength) {
  4934. maxIndex = currStart;
  4935. maxLength = currLength;
  4936. }
  4937. return maxIndex;
  4938. };
  4939. var serializeHost = function (host) {
  4940. var result, index, compress, ignore0;
  4941. if (typeof host == 'number') {
  4942. result = [];
  4943. for (index = 0; index < 4; index++) {
  4944. result.unshift(host % 256);
  4945. host = floor(host / 256);
  4946. }
  4947. return result.join('.');
  4948. } else if (typeof host == 'object') {
  4949. result = '';
  4950. compress = findLongestZeroSequence(host);
  4951. for (index = 0; index < 8; index++) {
  4952. if (ignore0 && host[index] === 0)
  4953. continue;
  4954. if (ignore0)
  4955. ignore0 = false;
  4956. if (compress === index) {
  4957. result += index ? ':' : '::';
  4958. ignore0 = true;
  4959. } else {
  4960. result += host[index].toString(16);
  4961. if (index < 7)
  4962. result += ':';
  4963. }
  4964. }
  4965. return '[' + result + ']';
  4966. }
  4967. return host;
  4968. };
  4969. var C0ControlPercentEncodeSet = {};
  4970. var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {
  4971. ' ': 1,
  4972. '"': 1,
  4973. '<': 1,
  4974. '>': 1,
  4975. '`': 1
  4976. });
  4977. var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {
  4978. '#': 1,
  4979. '?': 1,
  4980. '{': 1,
  4981. '}': 1
  4982. });
  4983. var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {
  4984. '/': 1,
  4985. ':': 1,
  4986. ';': 1,
  4987. '=': 1,
  4988. '@': 1,
  4989. '[': 1,
  4990. '\\': 1,
  4991. ']': 1,
  4992. '^': 1,
  4993. '|': 1
  4994. });
  4995. var percentEncode = function (char, set) {
  4996. var code = codeAt(char, 0);
  4997. return code > 0x20 && code < 0x7F && !has(set, char) ? char : encodeURIComponent(char);
  4998. };
  4999. var specialSchemes = {
  5000. ftp: 21,
  5001. file: null,
  5002. http: 80,
  5003. https: 443,
  5004. ws: 80,
  5005. wss: 443
  5006. };
  5007. var isSpecial = function (url) {
  5008. return has(specialSchemes, url.scheme);
  5009. };
  5010. var includesCredentials = function (url) {
  5011. return url.username != '' || url.password != '';
  5012. };
  5013. var cannotHaveUsernamePasswordPort = function (url) {
  5014. return !url.host || url.cannotBeABaseURL || url.scheme == 'file';
  5015. };
  5016. var isWindowsDriveLetter = function (string, normalized) {
  5017. var second;
  5018. return string.length == 2 && ALPHA.test(string.charAt(0)) && ((second = string.charAt(1)) == ':' || !normalized && second == '|');
  5019. };
  5020. var startsWithWindowsDriveLetter = function (string) {
  5021. var third;
  5022. return string.length > 1 && isWindowsDriveLetter(string.slice(0, 2)) && (string.length == 2 || ((third = string.charAt(2)) === '/' || third === '\\' || third === '?' || third === '#'));
  5023. };
  5024. var shortenURLsPath = function (url) {
  5025. var path = url.path;
  5026. var pathSize = path.length;
  5027. if (pathSize && (url.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {
  5028. path.pop();
  5029. }
  5030. };
  5031. var isSingleDot = function (segment) {
  5032. return segment === '.' || segment.toLowerCase() === '%2e';
  5033. };
  5034. var isDoubleDot = function (segment) {
  5035. segment = segment.toLowerCase();
  5036. return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
  5037. };
  5038. var SCHEME_START = {};
  5039. var SCHEME = {};
  5040. var NO_SCHEME = {};
  5041. var SPECIAL_RELATIVE_OR_AUTHORITY = {};
  5042. var PATH_OR_AUTHORITY = {};
  5043. var RELATIVE = {};
  5044. var RELATIVE_SLASH = {};
  5045. var SPECIAL_AUTHORITY_SLASHES = {};
  5046. var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
  5047. var AUTHORITY = {};
  5048. var HOST = {};
  5049. var HOSTNAME = {};
  5050. var PORT = {};
  5051. var FILE = {};
  5052. var FILE_SLASH = {};
  5053. var FILE_HOST = {};
  5054. var PATH_START = {};
  5055. var PATH = {};
  5056. var CANNOT_BE_A_BASE_URL_PATH = {};
  5057. var QUERY = {};
  5058. var FRAGMENT = {};
  5059. var parseURL = function (url, input, stateOverride, base) {
  5060. var state = stateOverride || SCHEME_START;
  5061. var pointer = 0;
  5062. var buffer = '';
  5063. var seenAt = false;
  5064. var seenBracket = false;
  5065. var seenPasswordToken = false;
  5066. var codePoints, char, bufferCodePoints, failure;
  5067. if (!stateOverride) {
  5068. url.scheme = '';
  5069. url.username = '';
  5070. url.password = '';
  5071. url.host = null;
  5072. url.port = null;
  5073. url.path = [];
  5074. url.query = null;
  5075. url.fragment = null;
  5076. url.cannotBeABaseURL = false;
  5077. input = input.replace(LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');
  5078. }
  5079. input = input.replace(TAB_AND_NEW_LINE, '');
  5080. codePoints = arrayFrom(input);
  5081. while (pointer <= codePoints.length) {
  5082. char = codePoints[pointer];
  5083. switch (state) {
  5084. case SCHEME_START:
  5085. if (char && ALPHA.test(char)) {
  5086. buffer += char.toLowerCase();
  5087. state = SCHEME;
  5088. } else if (!stateOverride) {
  5089. state = NO_SCHEME;
  5090. continue;
  5091. } else
  5092. return INVALID_SCHEME;
  5093. break;
  5094. case SCHEME:
  5095. if (char && (ALPHANUMERIC.test(char) || char == '+' || char == '-' || char == '.')) {
  5096. buffer += char.toLowerCase();
  5097. } else if (char == ':') {
  5098. if (stateOverride && (isSpecial(url) != has(specialSchemes, buffer) || buffer == 'file' && (includesCredentials(url) || url.port !== null) || url.scheme == 'file' && !url.host))
  5099. return;
  5100. url.scheme = buffer;
  5101. if (stateOverride) {
  5102. if (isSpecial(url) && specialSchemes[url.scheme] == url.port)
  5103. url.port = null;
  5104. return;
  5105. }
  5106. buffer = '';
  5107. if (url.scheme == 'file') {
  5108. state = FILE;
  5109. } else if (isSpecial(url) && base && base.scheme == url.scheme) {
  5110. state = SPECIAL_RELATIVE_OR_AUTHORITY;
  5111. } else if (isSpecial(url)) {
  5112. state = SPECIAL_AUTHORITY_SLASHES;
  5113. } else if (codePoints[pointer + 1] == '/') {
  5114. state = PATH_OR_AUTHORITY;
  5115. pointer++;
  5116. } else {
  5117. url.cannotBeABaseURL = true;
  5118. url.path.push('');
  5119. state = CANNOT_BE_A_BASE_URL_PATH;
  5120. }
  5121. } else if (!stateOverride) {
  5122. buffer = '';
  5123. state = NO_SCHEME;
  5124. pointer = 0;
  5125. continue;
  5126. } else
  5127. return INVALID_SCHEME;
  5128. break;
  5129. case NO_SCHEME:
  5130. if (!base || base.cannotBeABaseURL && char != '#')
  5131. return INVALID_SCHEME;
  5132. if (base.cannotBeABaseURL && char == '#') {
  5133. url.scheme = base.scheme;
  5134. url.path = base.path.slice();
  5135. url.query = base.query;
  5136. url.fragment = '';
  5137. url.cannotBeABaseURL = true;
  5138. state = FRAGMENT;
  5139. break;
  5140. }
  5141. state = base.scheme == 'file' ? FILE : RELATIVE;
  5142. continue;
  5143. case SPECIAL_RELATIVE_OR_AUTHORITY:
  5144. if (char == '/' && codePoints[pointer + 1] == '/') {
  5145. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  5146. pointer++;
  5147. } else {
  5148. state = RELATIVE;
  5149. continue;
  5150. }
  5151. break;
  5152. case PATH_OR_AUTHORITY:
  5153. if (char == '/') {
  5154. state = AUTHORITY;
  5155. break;
  5156. } else {
  5157. state = PATH;
  5158. continue;
  5159. }
  5160. case RELATIVE:
  5161. url.scheme = base.scheme;
  5162. if (char == EOF) {
  5163. url.username = base.username;
  5164. url.password = base.password;
  5165. url.host = base.host;
  5166. url.port = base.port;
  5167. url.path = base.path.slice();
  5168. url.query = base.query;
  5169. } else if (char == '/' || char == '\\' && isSpecial(url)) {
  5170. state = RELATIVE_SLASH;
  5171. } else if (char == '?') {
  5172. url.username = base.username;
  5173. url.password = base.password;
  5174. url.host = base.host;
  5175. url.port = base.port;
  5176. url.path = base.path.slice();
  5177. url.query = '';
  5178. state = QUERY;
  5179. } else if (char == '#') {
  5180. url.username = base.username;
  5181. url.password = base.password;
  5182. url.host = base.host;
  5183. url.port = base.port;
  5184. url.path = base.path.slice();
  5185. url.query = base.query;
  5186. url.fragment = '';
  5187. state = FRAGMENT;
  5188. } else {
  5189. url.username = base.username;
  5190. url.password = base.password;
  5191. url.host = base.host;
  5192. url.port = base.port;
  5193. url.path = base.path.slice();
  5194. url.path.pop();
  5195. state = PATH;
  5196. continue;
  5197. }
  5198. break;
  5199. case RELATIVE_SLASH:
  5200. if (isSpecial(url) && (char == '/' || char == '\\')) {
  5201. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  5202. } else if (char == '/') {
  5203. state = AUTHORITY;
  5204. } else {
  5205. url.username = base.username;
  5206. url.password = base.password;
  5207. url.host = base.host;
  5208. url.port = base.port;
  5209. state = PATH;
  5210. continue;
  5211. }
  5212. break;
  5213. case SPECIAL_AUTHORITY_SLASHES:
  5214. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  5215. if (char != '/' || buffer.charAt(pointer + 1) != '/')
  5216. continue;
  5217. pointer++;
  5218. break;
  5219. case SPECIAL_AUTHORITY_IGNORE_SLASHES:
  5220. if (char != '/' && char != '\\') {
  5221. state = AUTHORITY;
  5222. continue;
  5223. }
  5224. break;
  5225. case AUTHORITY:
  5226. if (char == '@') {
  5227. if (seenAt)
  5228. buffer = '%40' + buffer;
  5229. seenAt = true;
  5230. bufferCodePoints = arrayFrom(buffer);
  5231. for (var i = 0; i < bufferCodePoints.length; i++) {
  5232. var codePoint = bufferCodePoints[i];
  5233. if (codePoint == ':' && !seenPasswordToken) {
  5234. seenPasswordToken = true;
  5235. continue;
  5236. }
  5237. var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
  5238. if (seenPasswordToken)
  5239. url.password += encodedCodePoints;
  5240. else
  5241. url.username += encodedCodePoints;
  5242. }
  5243. buffer = '';
  5244. } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url)) {
  5245. if (seenAt && buffer == '')
  5246. return INVALID_AUTHORITY;
  5247. pointer -= arrayFrom(buffer).length + 1;
  5248. buffer = '';
  5249. state = HOST;
  5250. } else
  5251. buffer += char;
  5252. break;
  5253. case HOST:
  5254. case HOSTNAME:
  5255. if (stateOverride && url.scheme == 'file') {
  5256. state = FILE_HOST;
  5257. continue;
  5258. } else if (char == ':' && !seenBracket) {
  5259. if (buffer == '')
  5260. return INVALID_HOST;
  5261. failure = parseHost(url, buffer);
  5262. if (failure)
  5263. return failure;
  5264. buffer = '';
  5265. state = PORT;
  5266. if (stateOverride == HOSTNAME)
  5267. return;
  5268. } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url)) {
  5269. if (isSpecial(url) && buffer == '')
  5270. return INVALID_HOST;
  5271. if (stateOverride && buffer == '' && (includesCredentials(url) || url.port !== null))
  5272. return;
  5273. failure = parseHost(url, buffer);
  5274. if (failure)
  5275. return failure;
  5276. buffer = '';
  5277. state = PATH_START;
  5278. if (stateOverride)
  5279. return;
  5280. continue;
  5281. } else {
  5282. if (char == '[')
  5283. seenBracket = true;
  5284. else if (char == ']')
  5285. seenBracket = false;
  5286. buffer += char;
  5287. }
  5288. break;
  5289. case PORT:
  5290. if (DIGIT.test(char)) {
  5291. buffer += char;
  5292. } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url) || stateOverride) {
  5293. if (buffer != '') {
  5294. var port = parseInt(buffer, 10);
  5295. if (port > 0xFFFF)
  5296. return INVALID_PORT;
  5297. url.port = isSpecial(url) && port === specialSchemes[url.scheme] ? null : port;
  5298. buffer = '';
  5299. }
  5300. if (stateOverride)
  5301. return;
  5302. state = PATH_START;
  5303. continue;
  5304. } else
  5305. return INVALID_PORT;
  5306. break;
  5307. case FILE:
  5308. url.scheme = 'file';
  5309. if (char == '/' || char == '\\')
  5310. state = FILE_SLASH;
  5311. else if (base && base.scheme == 'file') {
  5312. if (char == EOF) {
  5313. url.host = base.host;
  5314. url.path = base.path.slice();
  5315. url.query = base.query;
  5316. } else if (char == '?') {
  5317. url.host = base.host;
  5318. url.path = base.path.slice();
  5319. url.query = '';
  5320. state = QUERY;
  5321. } else if (char == '#') {
  5322. url.host = base.host;
  5323. url.path = base.path.slice();
  5324. url.query = base.query;
  5325. url.fragment = '';
  5326. state = FRAGMENT;
  5327. } else {
  5328. if (!startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
  5329. url.host = base.host;
  5330. url.path = base.path.slice();
  5331. shortenURLsPath(url);
  5332. }
  5333. state = PATH;
  5334. continue;
  5335. }
  5336. } else {
  5337. state = PATH;
  5338. continue;
  5339. }
  5340. break;
  5341. case FILE_SLASH:
  5342. if (char == '/' || char == '\\') {
  5343. state = FILE_HOST;
  5344. break;
  5345. }
  5346. if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
  5347. if (isWindowsDriveLetter(base.path[0], true))
  5348. url.path.push(base.path[0]);
  5349. else
  5350. url.host = base.host;
  5351. }
  5352. state = PATH;
  5353. continue;
  5354. case FILE_HOST:
  5355. if (char == EOF || char == '/' || char == '\\' || char == '?' || char == '#') {
  5356. if (!stateOverride && isWindowsDriveLetter(buffer)) {
  5357. state = PATH;
  5358. } else if (buffer == '') {
  5359. url.host = '';
  5360. if (stateOverride)
  5361. return;
  5362. state = PATH_START;
  5363. } else {
  5364. failure = parseHost(url, buffer);
  5365. if (failure)
  5366. return failure;
  5367. if (url.host == 'localhost')
  5368. url.host = '';
  5369. if (stateOverride)
  5370. return;
  5371. buffer = '';
  5372. state = PATH_START;
  5373. }
  5374. continue;
  5375. } else
  5376. buffer += char;
  5377. break;
  5378. case PATH_START:
  5379. if (isSpecial(url)) {
  5380. state = PATH;
  5381. if (char != '/' && char != '\\')
  5382. continue;
  5383. } else if (!stateOverride && char == '?') {
  5384. url.query = '';
  5385. state = QUERY;
  5386. } else if (!stateOverride && char == '#') {
  5387. url.fragment = '';
  5388. state = FRAGMENT;
  5389. } else if (char != EOF) {
  5390. state = PATH;
  5391. if (char != '/')
  5392. continue;
  5393. }
  5394. break;
  5395. case PATH:
  5396. if (char == EOF || char == '/' || char == '\\' && isSpecial(url) || !stateOverride && (char == '?' || char == '#')) {
  5397. if (isDoubleDot(buffer)) {
  5398. shortenURLsPath(url);
  5399. if (char != '/' && !(char == '\\' && isSpecial(url))) {
  5400. url.path.push('');
  5401. }
  5402. } else if (isSingleDot(buffer)) {
  5403. if (char != '/' && !(char == '\\' && isSpecial(url))) {
  5404. url.path.push('');
  5405. }
  5406. } else {
  5407. if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
  5408. if (url.host)
  5409. url.host = '';
  5410. buffer = buffer.charAt(0) + ':';
  5411. }
  5412. url.path.push(buffer);
  5413. }
  5414. buffer = '';
  5415. if (url.scheme == 'file' && (char == EOF || char == '?' || char == '#')) {
  5416. while (url.path.length > 1 && url.path[0] === '') {
  5417. url.path.shift();
  5418. }
  5419. }
  5420. if (char == '?') {
  5421. url.query = '';
  5422. state = QUERY;
  5423. } else if (char == '#') {
  5424. url.fragment = '';
  5425. state = FRAGMENT;
  5426. }
  5427. } else {
  5428. buffer += percentEncode(char, pathPercentEncodeSet);
  5429. }
  5430. break;
  5431. case CANNOT_BE_A_BASE_URL_PATH:
  5432. if (char == '?') {
  5433. url.query = '';
  5434. state = QUERY;
  5435. } else if (char == '#') {
  5436. url.fragment = '';
  5437. state = FRAGMENT;
  5438. } else if (char != EOF) {
  5439. url.path[0] += percentEncode(char, C0ControlPercentEncodeSet);
  5440. }
  5441. break;
  5442. case QUERY:
  5443. if (!stateOverride && char == '#') {
  5444. url.fragment = '';
  5445. state = FRAGMENT;
  5446. } else if (char != EOF) {
  5447. if (char == "'" && isSpecial(url))
  5448. url.query += '%27';
  5449. else if (char == '#')
  5450. url.query += '%23';
  5451. else
  5452. url.query += percentEncode(char, C0ControlPercentEncodeSet);
  5453. }
  5454. break;
  5455. case FRAGMENT:
  5456. if (char != EOF)
  5457. url.fragment += percentEncode(char, fragmentPercentEncodeSet);
  5458. break;
  5459. }
  5460. pointer++;
  5461. }
  5462. };
  5463. var URLConstructor = function URL(url) {
  5464. var that = anInstance(this, URLConstructor, 'URL');
  5465. var base = arguments.length > 1 ? arguments[1] : undefined;
  5466. var urlString = String(url);
  5467. var state = setInternalState(that, { type: 'URL' });
  5468. var baseState, failure;
  5469. if (base !== undefined) {
  5470. if (base instanceof URLConstructor)
  5471. baseState = getInternalURLState(base);
  5472. else {
  5473. failure = parseURL(baseState = {}, String(base));
  5474. if (failure)
  5475. throw TypeError(failure);
  5476. }
  5477. }
  5478. failure = parseURL(state, urlString, null, baseState);
  5479. if (failure)
  5480. throw TypeError(failure);
  5481. var searchParams = state.searchParams = new URLSearchParams();
  5482. var searchParamsState = getInternalSearchParamsState(searchParams);
  5483. searchParamsState.updateSearchParams(state.query);
  5484. searchParamsState.updateURL = function () {
  5485. state.query = String(searchParams) || null;
  5486. };
  5487. if (!DESCRIPTORS) {
  5488. that.href = serializeURL.call(that);
  5489. that.origin = getOrigin.call(that);
  5490. that.protocol = getProtocol.call(that);
  5491. that.username = getUsername.call(that);
  5492. that.password = getPassword.call(that);
  5493. that.host = getHost.call(that);
  5494. that.hostname = getHostname.call(that);
  5495. that.port = getPort.call(that);
  5496. that.pathname = getPathname.call(that);
  5497. that.search = getSearch.call(that);
  5498. that.searchParams = getSearchParams.call(that);
  5499. that.hash = getHash.call(that);
  5500. }
  5501. };
  5502. var URLPrototype = URLConstructor.prototype;
  5503. var serializeURL = function () {
  5504. var url = getInternalURLState(this);
  5505. var scheme = url.scheme;
  5506. var username = url.username;
  5507. var password = url.password;
  5508. var host = url.host;
  5509. var port = url.port;
  5510. var path = url.path;
  5511. var query = url.query;
  5512. var fragment = url.fragment;
  5513. var output = scheme + ':';
  5514. if (host !== null) {
  5515. output += '//';
  5516. if (includesCredentials(url)) {
  5517. output += username + (password ? ':' + password : '') + '@';
  5518. }
  5519. output += serializeHost(host);
  5520. if (port !== null)
  5521. output += ':' + port;
  5522. } else if (scheme == 'file')
  5523. output += '//';
  5524. output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
  5525. if (query !== null)
  5526. output += '?' + query;
  5527. if (fragment !== null)
  5528. output += '#' + fragment;
  5529. return output;
  5530. };
  5531. var getOrigin = function () {
  5532. var url = getInternalURLState(this);
  5533. var scheme = url.scheme;
  5534. var port = url.port;
  5535. if (scheme == 'blob')
  5536. try {
  5537. return new URL(scheme.path[0]).origin;
  5538. } catch (error) {
  5539. return 'null';
  5540. }
  5541. if (scheme == 'file' || !isSpecial(url))
  5542. return 'null';
  5543. return scheme + '://' + serializeHost(url.host) + (port !== null ? ':' + port : '');
  5544. };
  5545. var getProtocol = function () {
  5546. return getInternalURLState(this).scheme + ':';
  5547. };
  5548. var getUsername = function () {
  5549. return getInternalURLState(this).username;
  5550. };
  5551. var getPassword = function () {
  5552. return getInternalURLState(this).password;
  5553. };
  5554. var getHost = function () {
  5555. var url = getInternalURLState(this);
  5556. var host = url.host;
  5557. var port = url.port;
  5558. return host === null ? '' : port === null ? serializeHost(host) : serializeHost(host) + ':' + port;
  5559. };
  5560. var getHostname = function () {
  5561. var host = getInternalURLState(this).host;
  5562. return host === null ? '' : serializeHost(host);
  5563. };
  5564. var getPort = function () {
  5565. var port = getInternalURLState(this).port;
  5566. return port === null ? '' : String(port);
  5567. };
  5568. var getPathname = function () {
  5569. var url = getInternalURLState(this);
  5570. var path = url.path;
  5571. return url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
  5572. };
  5573. var getSearch = function () {
  5574. var query = getInternalURLState(this).query;
  5575. return query ? '?' + query : '';
  5576. };
  5577. var getSearchParams = function () {
  5578. return getInternalURLState(this).searchParams;
  5579. };
  5580. var getHash = function () {
  5581. var fragment = getInternalURLState(this).fragment;
  5582. return fragment ? '#' + fragment : '';
  5583. };
  5584. var accessorDescriptor = function (getter, setter) {
  5585. return {
  5586. get: getter,
  5587. set: setter,
  5588. configurable: true,
  5589. enumerable: true
  5590. };
  5591. };
  5592. if (DESCRIPTORS) {
  5593. defineProperties(URLPrototype, {
  5594. href: accessorDescriptor(serializeURL, function (href) {
  5595. var url = getInternalURLState(this);
  5596. var urlString = String(href);
  5597. var failure = parseURL(url, urlString);
  5598. if (failure)
  5599. throw TypeError(failure);
  5600. getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
  5601. }),
  5602. origin: accessorDescriptor(getOrigin),
  5603. protocol: accessorDescriptor(getProtocol, function (protocol) {
  5604. var url = getInternalURLState(this);
  5605. parseURL(url, String(protocol) + ':', SCHEME_START);
  5606. }),
  5607. username: accessorDescriptor(getUsername, function (username) {
  5608. var url = getInternalURLState(this);
  5609. var codePoints = arrayFrom(String(username));
  5610. if (cannotHaveUsernamePasswordPort(url))
  5611. return;
  5612. url.username = '';
  5613. for (var i = 0; i < codePoints.length; i++) {
  5614. url.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  5615. }
  5616. }),
  5617. password: accessorDescriptor(getPassword, function (password) {
  5618. var url = getInternalURLState(this);
  5619. var codePoints = arrayFrom(String(password));
  5620. if (cannotHaveUsernamePasswordPort(url))
  5621. return;
  5622. url.password = '';
  5623. for (var i = 0; i < codePoints.length; i++) {
  5624. url.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  5625. }
  5626. }),
  5627. host: accessorDescriptor(getHost, function (host) {
  5628. var url = getInternalURLState(this);
  5629. if (url.cannotBeABaseURL)
  5630. return;
  5631. parseURL(url, String(host), HOST);
  5632. }),
  5633. hostname: accessorDescriptor(getHostname, function (hostname) {
  5634. var url = getInternalURLState(this);
  5635. if (url.cannotBeABaseURL)
  5636. return;
  5637. parseURL(url, String(hostname), HOSTNAME);
  5638. }),
  5639. port: accessorDescriptor(getPort, function (port) {
  5640. var url = getInternalURLState(this);
  5641. if (cannotHaveUsernamePasswordPort(url))
  5642. return;
  5643. port = String(port);
  5644. if (port == '')
  5645. url.port = null;
  5646. else
  5647. parseURL(url, port, PORT);
  5648. }),
  5649. pathname: accessorDescriptor(getPathname, function (pathname) {
  5650. var url = getInternalURLState(this);
  5651. if (url.cannotBeABaseURL)
  5652. return;
  5653. url.path = [];
  5654. parseURL(url, pathname + '', PATH_START);
  5655. }),
  5656. search: accessorDescriptor(getSearch, function (search) {
  5657. var url = getInternalURLState(this);
  5658. search = String(search);
  5659. if (search == '') {
  5660. url.query = null;
  5661. } else {
  5662. if ('?' == search.charAt(0))
  5663. search = search.slice(1);
  5664. url.query = '';
  5665. parseURL(url, search, QUERY);
  5666. }
  5667. getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
  5668. }),
  5669. searchParams: accessorDescriptor(getSearchParams),
  5670. hash: accessorDescriptor(getHash, function (hash) {
  5671. var url = getInternalURLState(this);
  5672. hash = String(hash);
  5673. if (hash == '') {
  5674. url.fragment = null;
  5675. return;
  5676. }
  5677. if ('#' == hash.charAt(0))
  5678. hash = hash.slice(1);
  5679. url.fragment = '';
  5680. parseURL(url, hash, FRAGMENT);
  5681. })
  5682. });
  5683. }
  5684. redefine(URLPrototype, 'toJSON', function toJSON() {
  5685. return serializeURL.call(this);
  5686. }, { enumerable: true });
  5687. redefine(URLPrototype, 'toString', function toString() {
  5688. return serializeURL.call(this);
  5689. }, { enumerable: true });
  5690. if (NativeURL) {
  5691. var nativeCreateObjectURL = NativeURL.createObjectURL;
  5692. var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
  5693. if (nativeCreateObjectURL)
  5694. redefine(URLConstructor, 'createObjectURL', function createObjectURL(blob) {
  5695. return nativeCreateObjectURL.apply(NativeURL, arguments);
  5696. });
  5697. if (nativeRevokeObjectURL)
  5698. redefine(URLConstructor, 'revokeObjectURL', function revokeObjectURL(url) {
  5699. return nativeRevokeObjectURL.apply(NativeURL, arguments);
  5700. });
  5701. }
  5702. setToStringTag(URLConstructor, 'URL');
  5703. $({
  5704. global: true,
  5705. forced: !USE_NATIVE_URL,
  5706. sham: !DESCRIPTORS
  5707. }, { URL: URLConstructor });
  5708. /***/ }),
  5709. /* 113 */
  5710. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5711. var fails = __w_pdfjs_require__(13);
  5712. var wellKnownSymbol = __w_pdfjs_require__(55);
  5713. var IS_PURE = __w_pdfjs_require__(36);
  5714. var ITERATOR = wellKnownSymbol('iterator');
  5715. module.exports = !fails(function () {
  5716. var url = new URL('b?a=1&b=2&c=3', 'http://a');
  5717. var searchParams = url.searchParams;
  5718. var result = '';
  5719. url.pathname = 'c%20d';
  5720. searchParams.forEach(function (value, key) {
  5721. searchParams['delete']('b');
  5722. result += key + value;
  5723. });
  5724. return IS_PURE && !url.toJSON || !searchParams.sort || url.href !== 'http://a/c%20d?a=1&c=3' || searchParams.get('c') !== '3' || String(new URLSearchParams('?a=1')) !== 'a=1' || !searchParams[ITERATOR] || new URL('https://a@b').username !== 'a' || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b' || new URL('http://тест').host !== 'xn--e1aybc' || new URL('http://a#б').hash !== '#%D0%B1' || result !== 'a1c3' || new URL('http://x', undefined).host !== 'x';
  5725. });
  5726. /***/ }),
  5727. /* 114 */
  5728. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5729. "use strict";
  5730. var DESCRIPTORS = __w_pdfjs_require__(12);
  5731. var fails = __w_pdfjs_require__(13);
  5732. var objectKeys = __w_pdfjs_require__(60);
  5733. var getOwnPropertySymbolsModule = __w_pdfjs_require__(50);
  5734. var propertyIsEnumerableModule = __w_pdfjs_require__(14);
  5735. var toObject = __w_pdfjs_require__(67);
  5736. var IndexedObject = __w_pdfjs_require__(17);
  5737. var nativeAssign = Object.assign;
  5738. var defineProperty = Object.defineProperty;
  5739. module.exports = !nativeAssign || fails(function () {
  5740. if (DESCRIPTORS && nativeAssign({ b: 1 }, nativeAssign(defineProperty({}, 'a', {
  5741. enumerable: true,
  5742. get: function () {
  5743. defineProperty(this, 'b', {
  5744. value: 3,
  5745. enumerable: false
  5746. });
  5747. }
  5748. }), { b: 2 })).b !== 1)
  5749. return true;
  5750. var A = {};
  5751. var B = {};
  5752. var symbol = Symbol();
  5753. var alphabet = 'abcdefghijklmnopqrst';
  5754. A[symbol] = 7;
  5755. alphabet.split('').forEach(function (chr) {
  5756. B[chr] = chr;
  5757. });
  5758. return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
  5759. }) ? function assign(target, source) {
  5760. var T = toObject(target);
  5761. var argumentsLength = arguments.length;
  5762. var index = 1;
  5763. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  5764. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  5765. while (argumentsLength > index) {
  5766. var S = IndexedObject(arguments[index++]);
  5767. var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
  5768. var length = keys.length;
  5769. var j = 0;
  5770. var key;
  5771. while (length > j) {
  5772. key = keys[j++];
  5773. if (!DESCRIPTORS || propertyIsEnumerable.call(S, key))
  5774. T[key] = S[key];
  5775. }
  5776. }
  5777. return T;
  5778. } : nativeAssign;
  5779. /***/ }),
  5780. /* 115 */
  5781. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5782. "use strict";
  5783. var bind = __w_pdfjs_require__(75);
  5784. var toObject = __w_pdfjs_require__(67);
  5785. var callWithSafeIterationClosing = __w_pdfjs_require__(116);
  5786. var isArrayIteratorMethod = __w_pdfjs_require__(74);
  5787. var toLength = __w_pdfjs_require__(46);
  5788. var createProperty = __w_pdfjs_require__(81);
  5789. var getIteratorMethod = __w_pdfjs_require__(77);
  5790. module.exports = function from(arrayLike) {
  5791. var O = toObject(arrayLike);
  5792. var C = typeof this == 'function' ? this : Array;
  5793. var argumentsLength = arguments.length;
  5794. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  5795. var mapping = mapfn !== undefined;
  5796. var iteratorMethod = getIteratorMethod(O);
  5797. var index = 0;
  5798. var length, result, step, iterator, next, value;
  5799. if (mapping)
  5800. mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2);
  5801. if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {
  5802. iterator = iteratorMethod.call(O);
  5803. next = iterator.next;
  5804. result = new C();
  5805. for (; !(step = next.call(iterator)).done; index++) {
  5806. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [
  5807. step.value,
  5808. index
  5809. ], true) : step.value;
  5810. createProperty(result, index, value);
  5811. }
  5812. } else {
  5813. length = toLength(O.length);
  5814. result = new C(length);
  5815. for (; length > index; index++) {
  5816. value = mapping ? mapfn(O[index], index) : O[index];
  5817. createProperty(result, index, value);
  5818. }
  5819. }
  5820. result.length = index;
  5821. return result;
  5822. };
  5823. /***/ }),
  5824. /* 116 */
  5825. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5826. var anObject = __w_pdfjs_require__(27);
  5827. var iteratorClose = __w_pdfjs_require__(80);
  5828. module.exports = function (iterator, fn, value, ENTRIES) {
  5829. try {
  5830. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  5831. } catch (error) {
  5832. iteratorClose(iterator);
  5833. throw error;
  5834. }
  5835. };
  5836. /***/ }),
  5837. /* 117 */
  5838. /***/ ((module) => {
  5839. "use strict";
  5840. var maxInt = 2147483647;
  5841. var base = 36;
  5842. var tMin = 1;
  5843. var tMax = 26;
  5844. var skew = 38;
  5845. var damp = 700;
  5846. var initialBias = 72;
  5847. var initialN = 128;
  5848. var delimiter = '-';
  5849. var regexNonASCII = /[^\0-\u007E]/;
  5850. var regexSeparators = /[.\u3002\uFF0E\uFF61]/g;
  5851. var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
  5852. var baseMinusTMin = base - tMin;
  5853. var floor = Math.floor;
  5854. var stringFromCharCode = String.fromCharCode;
  5855. var ucs2decode = function (string) {
  5856. var output = [];
  5857. var counter = 0;
  5858. var length = string.length;
  5859. while (counter < length) {
  5860. var value = string.charCodeAt(counter++);
  5861. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  5862. var extra = string.charCodeAt(counter++);
  5863. if ((extra & 0xFC00) == 0xDC00) {
  5864. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  5865. } else {
  5866. output.push(value);
  5867. counter--;
  5868. }
  5869. } else {
  5870. output.push(value);
  5871. }
  5872. }
  5873. return output;
  5874. };
  5875. var digitToBasic = function (digit) {
  5876. return digit + 22 + 75 * (digit < 26);
  5877. };
  5878. var adapt = function (delta, numPoints, firstTime) {
  5879. var k = 0;
  5880. delta = firstTime ? floor(delta / damp) : delta >> 1;
  5881. delta += floor(delta / numPoints);
  5882. for (; delta > baseMinusTMin * tMax >> 1; k += base) {
  5883. delta = floor(delta / baseMinusTMin);
  5884. }
  5885. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  5886. };
  5887. var encode = function (input) {
  5888. var output = [];
  5889. input = ucs2decode(input);
  5890. var inputLength = input.length;
  5891. var n = initialN;
  5892. var delta = 0;
  5893. var bias = initialBias;
  5894. var i, currentValue;
  5895. for (i = 0; i < input.length; i++) {
  5896. currentValue = input[i];
  5897. if (currentValue < 0x80) {
  5898. output.push(stringFromCharCode(currentValue));
  5899. }
  5900. }
  5901. var basicLength = output.length;
  5902. var handledCPCount = basicLength;
  5903. if (basicLength) {
  5904. output.push(delimiter);
  5905. }
  5906. while (handledCPCount < inputLength) {
  5907. var m = maxInt;
  5908. for (i = 0; i < input.length; i++) {
  5909. currentValue = input[i];
  5910. if (currentValue >= n && currentValue < m) {
  5911. m = currentValue;
  5912. }
  5913. }
  5914. var handledCPCountPlusOne = handledCPCount + 1;
  5915. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  5916. throw RangeError(OVERFLOW_ERROR);
  5917. }
  5918. delta += (m - n) * handledCPCountPlusOne;
  5919. n = m;
  5920. for (i = 0; i < input.length; i++) {
  5921. currentValue = input[i];
  5922. if (currentValue < n && ++delta > maxInt) {
  5923. throw RangeError(OVERFLOW_ERROR);
  5924. }
  5925. if (currentValue == n) {
  5926. var q = delta;
  5927. for (var k = base;; k += base) {
  5928. var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  5929. if (q < t)
  5930. break;
  5931. var qMinusT = q - t;
  5932. var baseMinusT = base - t;
  5933. output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
  5934. q = floor(qMinusT / baseMinusT);
  5935. }
  5936. output.push(stringFromCharCode(digitToBasic(q)));
  5937. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  5938. delta = 0;
  5939. ++handledCPCount;
  5940. }
  5941. }
  5942. ++delta;
  5943. ++n;
  5944. }
  5945. return output.join('');
  5946. };
  5947. module.exports = function (input) {
  5948. var encoded = [];
  5949. var labels = input.toLowerCase().replace(regexSeparators, '\u002E').split('.');
  5950. var i, label;
  5951. for (i = 0; i < labels.length; i++) {
  5952. label = labels[i];
  5953. encoded.push(regexNonASCII.test(label) ? 'xn--' + encode(label) : label);
  5954. }
  5955. return encoded.join('.');
  5956. };
  5957. /***/ }),
  5958. /* 118 */
  5959. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5960. "use strict";
  5961. __w_pdfjs_require__(53);
  5962. var $ = __w_pdfjs_require__(9);
  5963. var getBuiltIn = __w_pdfjs_require__(41);
  5964. var USE_NATIVE_URL = __w_pdfjs_require__(113);
  5965. var redefine = __w_pdfjs_require__(28);
  5966. var redefineAll = __w_pdfjs_require__(88);
  5967. var setToStringTag = __w_pdfjs_require__(69);
  5968. var createIteratorConstructor = __w_pdfjs_require__(64);
  5969. var InternalStateModule = __w_pdfjs_require__(32);
  5970. var anInstance = __w_pdfjs_require__(90);
  5971. var hasOwn = __w_pdfjs_require__(22);
  5972. var bind = __w_pdfjs_require__(75);
  5973. var classof = __w_pdfjs_require__(78);
  5974. var anObject = __w_pdfjs_require__(27);
  5975. var isObject = __w_pdfjs_require__(21);
  5976. var create = __w_pdfjs_require__(58);
  5977. var createPropertyDescriptor = __w_pdfjs_require__(15);
  5978. var getIterator = __w_pdfjs_require__(119);
  5979. var getIteratorMethod = __w_pdfjs_require__(77);
  5980. var wellKnownSymbol = __w_pdfjs_require__(55);
  5981. var $fetch = getBuiltIn('fetch');
  5982. var Headers = getBuiltIn('Headers');
  5983. var ITERATOR = wellKnownSymbol('iterator');
  5984. var URL_SEARCH_PARAMS = 'URLSearchParams';
  5985. var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
  5986. var setInternalState = InternalStateModule.set;
  5987. var getInternalParamsState = InternalStateModule.getterFor(URL_SEARCH_PARAMS);
  5988. var getInternalIteratorState = InternalStateModule.getterFor(URL_SEARCH_PARAMS_ITERATOR);
  5989. var plus = /\+/g;
  5990. var sequences = Array(4);
  5991. var percentSequence = function (bytes) {
  5992. return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
  5993. };
  5994. var percentDecode = function (sequence) {
  5995. try {
  5996. return decodeURIComponent(sequence);
  5997. } catch (error) {
  5998. return sequence;
  5999. }
  6000. };
  6001. var deserialize = function (it) {
  6002. var result = it.replace(plus, ' ');
  6003. var bytes = 4;
  6004. try {
  6005. return decodeURIComponent(result);
  6006. } catch (error) {
  6007. while (bytes) {
  6008. result = result.replace(percentSequence(bytes--), percentDecode);
  6009. }
  6010. return result;
  6011. }
  6012. };
  6013. var find = /[!'()~]|%20/g;
  6014. var replace = {
  6015. '!': '%21',
  6016. "'": '%27',
  6017. '(': '%28',
  6018. ')': '%29',
  6019. '~': '%7E',
  6020. '%20': '+'
  6021. };
  6022. var replacer = function (match) {
  6023. return replace[match];
  6024. };
  6025. var serialize = function (it) {
  6026. return encodeURIComponent(it).replace(find, replacer);
  6027. };
  6028. var parseSearchParams = function (result, query) {
  6029. if (query) {
  6030. var attributes = query.split('&');
  6031. var index = 0;
  6032. var attribute, entry;
  6033. while (index < attributes.length) {
  6034. attribute = attributes[index++];
  6035. if (attribute.length) {
  6036. entry = attribute.split('=');
  6037. result.push({
  6038. key: deserialize(entry.shift()),
  6039. value: deserialize(entry.join('='))
  6040. });
  6041. }
  6042. }
  6043. }
  6044. };
  6045. var updateSearchParams = function (query) {
  6046. this.entries.length = 0;
  6047. parseSearchParams(this.entries, query);
  6048. };
  6049. var validateArgumentsLength = function (passed, required) {
  6050. if (passed < required)
  6051. throw TypeError('Not enough arguments');
  6052. };
  6053. var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
  6054. setInternalState(this, {
  6055. type: URL_SEARCH_PARAMS_ITERATOR,
  6056. iterator: getIterator(getInternalParamsState(params).entries),
  6057. kind: kind
  6058. });
  6059. }, 'Iterator', function next() {
  6060. var state = getInternalIteratorState(this);
  6061. var kind = state.kind;
  6062. var step = state.iterator.next();
  6063. var entry = step.value;
  6064. if (!step.done) {
  6065. step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [
  6066. entry.key,
  6067. entry.value
  6068. ];
  6069. }
  6070. return step;
  6071. });
  6072. var URLSearchParamsConstructor = function URLSearchParams() {
  6073. anInstance(this, URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  6074. var init = arguments.length > 0 ? arguments[0] : undefined;
  6075. var that = this;
  6076. var entries = [];
  6077. var iteratorMethod, iterator, next, step, entryIterator, entryNext, first, second, key;
  6078. setInternalState(that, {
  6079. type: URL_SEARCH_PARAMS,
  6080. entries: entries,
  6081. updateURL: function () {
  6082. },
  6083. updateSearchParams: updateSearchParams
  6084. });
  6085. if (init !== undefined) {
  6086. if (isObject(init)) {
  6087. iteratorMethod = getIteratorMethod(init);
  6088. if (typeof iteratorMethod === 'function') {
  6089. iterator = iteratorMethod.call(init);
  6090. next = iterator.next;
  6091. while (!(step = next.call(iterator)).done) {
  6092. entryIterator = getIterator(anObject(step.value));
  6093. entryNext = entryIterator.next;
  6094. if ((first = entryNext.call(entryIterator)).done || (second = entryNext.call(entryIterator)).done || !entryNext.call(entryIterator).done)
  6095. throw TypeError('Expected sequence with length 2');
  6096. entries.push({
  6097. key: first.value + '',
  6098. value: second.value + ''
  6099. });
  6100. }
  6101. } else
  6102. for (key in init)
  6103. if (hasOwn(init, key))
  6104. entries.push({
  6105. key: key,
  6106. value: init[key] + ''
  6107. });
  6108. } else {
  6109. parseSearchParams(entries, typeof init === 'string' ? init.charAt(0) === '?' ? init.slice(1) : init : init + '');
  6110. }
  6111. }
  6112. };
  6113. var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
  6114. redefineAll(URLSearchParamsPrototype, {
  6115. append: function append(name, value) {
  6116. validateArgumentsLength(arguments.length, 2);
  6117. var state = getInternalParamsState(this);
  6118. state.entries.push({
  6119. key: name + '',
  6120. value: value + ''
  6121. });
  6122. state.updateURL();
  6123. },
  6124. 'delete': function (name) {
  6125. validateArgumentsLength(arguments.length, 1);
  6126. var state = getInternalParamsState(this);
  6127. var entries = state.entries;
  6128. var key = name + '';
  6129. var index = 0;
  6130. while (index < entries.length) {
  6131. if (entries[index].key === key)
  6132. entries.splice(index, 1);
  6133. else
  6134. index++;
  6135. }
  6136. state.updateURL();
  6137. },
  6138. get: function get(name) {
  6139. validateArgumentsLength(arguments.length, 1);
  6140. var entries = getInternalParamsState(this).entries;
  6141. var key = name + '';
  6142. var index = 0;
  6143. for (; index < entries.length; index++) {
  6144. if (entries[index].key === key)
  6145. return entries[index].value;
  6146. }
  6147. return null;
  6148. },
  6149. getAll: function getAll(name) {
  6150. validateArgumentsLength(arguments.length, 1);
  6151. var entries = getInternalParamsState(this).entries;
  6152. var key = name + '';
  6153. var result = [];
  6154. var index = 0;
  6155. for (; index < entries.length; index++) {
  6156. if (entries[index].key === key)
  6157. result.push(entries[index].value);
  6158. }
  6159. return result;
  6160. },
  6161. has: function has(name) {
  6162. validateArgumentsLength(arguments.length, 1);
  6163. var entries = getInternalParamsState(this).entries;
  6164. var key = name + '';
  6165. var index = 0;
  6166. while (index < entries.length) {
  6167. if (entries[index++].key === key)
  6168. return true;
  6169. }
  6170. return false;
  6171. },
  6172. set: function set(name, value) {
  6173. validateArgumentsLength(arguments.length, 1);
  6174. var state = getInternalParamsState(this);
  6175. var entries = state.entries;
  6176. var found = false;
  6177. var key = name + '';
  6178. var val = value + '';
  6179. var index = 0;
  6180. var entry;
  6181. for (; index < entries.length; index++) {
  6182. entry = entries[index];
  6183. if (entry.key === key) {
  6184. if (found)
  6185. entries.splice(index--, 1);
  6186. else {
  6187. found = true;
  6188. entry.value = val;
  6189. }
  6190. }
  6191. }
  6192. if (!found)
  6193. entries.push({
  6194. key: key,
  6195. value: val
  6196. });
  6197. state.updateURL();
  6198. },
  6199. sort: function sort() {
  6200. var state = getInternalParamsState(this);
  6201. var entries = state.entries;
  6202. var slice = entries.slice();
  6203. var entry, entriesIndex, sliceIndex;
  6204. entries.length = 0;
  6205. for (sliceIndex = 0; sliceIndex < slice.length; sliceIndex++) {
  6206. entry = slice[sliceIndex];
  6207. for (entriesIndex = 0; entriesIndex < sliceIndex; entriesIndex++) {
  6208. if (entries[entriesIndex].key > entry.key) {
  6209. entries.splice(entriesIndex, 0, entry);
  6210. break;
  6211. }
  6212. }
  6213. if (entriesIndex === sliceIndex)
  6214. entries.push(entry);
  6215. }
  6216. state.updateURL();
  6217. },
  6218. forEach: function forEach(callback) {
  6219. var entries = getInternalParamsState(this).entries;
  6220. var boundFunction = bind(callback, arguments.length > 1 ? arguments[1] : undefined, 3);
  6221. var index = 0;
  6222. var entry;
  6223. while (index < entries.length) {
  6224. entry = entries[index++];
  6225. boundFunction(entry.value, entry.key, this);
  6226. }
  6227. },
  6228. keys: function keys() {
  6229. return new URLSearchParamsIterator(this, 'keys');
  6230. },
  6231. values: function values() {
  6232. return new URLSearchParamsIterator(this, 'values');
  6233. },
  6234. entries: function entries() {
  6235. return new URLSearchParamsIterator(this, 'entries');
  6236. }
  6237. }, { enumerable: true });
  6238. redefine(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries);
  6239. redefine(URLSearchParamsPrototype, 'toString', function toString() {
  6240. var entries = getInternalParamsState(this).entries;
  6241. var result = [];
  6242. var index = 0;
  6243. var entry;
  6244. while (index < entries.length) {
  6245. entry = entries[index++];
  6246. result.push(serialize(entry.key) + '=' + serialize(entry.value));
  6247. }
  6248. return result.join('&');
  6249. }, { enumerable: true });
  6250. setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  6251. $({
  6252. global: true,
  6253. forced: !USE_NATIVE_URL
  6254. }, { URLSearchParams: URLSearchParamsConstructor });
  6255. if (!USE_NATIVE_URL && typeof $fetch == 'function' && typeof Headers == 'function') {
  6256. $({
  6257. global: true,
  6258. enumerable: true,
  6259. forced: true
  6260. }, {
  6261. fetch: function fetch(input) {
  6262. var args = [input];
  6263. var init, body, headers;
  6264. if (arguments.length > 1) {
  6265. init = arguments[1];
  6266. if (isObject(init)) {
  6267. body = init.body;
  6268. if (classof(body) === URL_SEARCH_PARAMS) {
  6269. headers = init.headers ? new Headers(init.headers) : new Headers();
  6270. if (!headers.has('content-type')) {
  6271. headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
  6272. }
  6273. init = create(init, {
  6274. body: createPropertyDescriptor(0, String(body)),
  6275. headers: createPropertyDescriptor(0, headers)
  6276. });
  6277. }
  6278. }
  6279. args.push(init);
  6280. }
  6281. return $fetch.apply(this, args);
  6282. }
  6283. });
  6284. }
  6285. module.exports = {
  6286. URLSearchParams: URLSearchParamsConstructor,
  6287. getState: getInternalParamsState
  6288. };
  6289. /***/ }),
  6290. /* 119 */
  6291. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6292. var anObject = __w_pdfjs_require__(27);
  6293. var getIteratorMethod = __w_pdfjs_require__(77);
  6294. module.exports = function (it) {
  6295. var iteratorMethod = getIteratorMethod(it);
  6296. if (typeof iteratorMethod != 'function') {
  6297. throw TypeError(String(it) + ' is not iterable');
  6298. }
  6299. return anObject(iteratorMethod.call(it));
  6300. };
  6301. /***/ }),
  6302. /* 120 */
  6303. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6304. "use strict";
  6305. var $ = __w_pdfjs_require__(9);
  6306. $({
  6307. target: 'URL',
  6308. proto: true,
  6309. enumerable: true
  6310. }, {
  6311. toJSON: function toJSON() {
  6312. return URL.prototype.toString.call(this);
  6313. }
  6314. });
  6315. /***/ }),
  6316. /* 121 */
  6317. /***/ (function(__unused_webpack_module, exports) {
  6318. (function (global, factory) {
  6319. true ? factory(exports) : 0;
  6320. }(this, function (exports) {
  6321. 'use strict';
  6322. var SymbolPolyfill = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol : function (description) {
  6323. return "Symbol(" + description + ")";
  6324. };
  6325. function noop() {
  6326. }
  6327. function getGlobals() {
  6328. if (typeof self !== 'undefined') {
  6329. return self;
  6330. } else if (typeof window !== 'undefined') {
  6331. return window;
  6332. } else if (typeof global !== 'undefined') {
  6333. return global;
  6334. }
  6335. return undefined;
  6336. }
  6337. var globals = getGlobals();
  6338. function typeIsObject(x) {
  6339. return typeof x === 'object' && x !== null || typeof x === 'function';
  6340. }
  6341. var rethrowAssertionErrorRejection = noop;
  6342. var originalPromise = Promise;
  6343. var originalPromiseThen = Promise.prototype.then;
  6344. var originalPromiseResolve = Promise.resolve.bind(originalPromise);
  6345. var originalPromiseReject = Promise.reject.bind(originalPromise);
  6346. function newPromise(executor) {
  6347. return new originalPromise(executor);
  6348. }
  6349. function promiseResolvedWith(value) {
  6350. return originalPromiseResolve(value);
  6351. }
  6352. function promiseRejectedWith(reason) {
  6353. return originalPromiseReject(reason);
  6354. }
  6355. function PerformPromiseThen(promise, onFulfilled, onRejected) {
  6356. return originalPromiseThen.call(promise, onFulfilled, onRejected);
  6357. }
  6358. function uponPromise(promise, onFulfilled, onRejected) {
  6359. PerformPromiseThen(PerformPromiseThen(promise, onFulfilled, onRejected), undefined, rethrowAssertionErrorRejection);
  6360. }
  6361. function uponFulfillment(promise, onFulfilled) {
  6362. uponPromise(promise, onFulfilled);
  6363. }
  6364. function uponRejection(promise, onRejected) {
  6365. uponPromise(promise, undefined, onRejected);
  6366. }
  6367. function transformPromiseWith(promise, fulfillmentHandler, rejectionHandler) {
  6368. return PerformPromiseThen(promise, fulfillmentHandler, rejectionHandler);
  6369. }
  6370. function setPromiseIsHandledToTrue(promise) {
  6371. PerformPromiseThen(promise, undefined, rethrowAssertionErrorRejection);
  6372. }
  6373. var queueMicrotask = function () {
  6374. var globalQueueMicrotask = globals && globals.queueMicrotask;
  6375. if (typeof globalQueueMicrotask === 'function') {
  6376. return globalQueueMicrotask;
  6377. }
  6378. var resolvedPromise = promiseResolvedWith(undefined);
  6379. return function (fn) {
  6380. return PerformPromiseThen(resolvedPromise, fn);
  6381. };
  6382. }();
  6383. function reflectCall(F, V, args) {
  6384. if (typeof F !== 'function') {
  6385. throw new TypeError('Argument is not a function');
  6386. }
  6387. return Function.prototype.apply.call(F, V, args);
  6388. }
  6389. function promiseCall(F, V, args) {
  6390. try {
  6391. return promiseResolvedWith(reflectCall(F, V, args));
  6392. } catch (value) {
  6393. return promiseRejectedWith(value);
  6394. }
  6395. }
  6396. var QUEUE_MAX_ARRAY_SIZE = 16384;
  6397. var SimpleQueue = function () {
  6398. function SimpleQueue() {
  6399. this._cursor = 0;
  6400. this._size = 0;
  6401. this._front = {
  6402. _elements: [],
  6403. _next: undefined
  6404. };
  6405. this._back = this._front;
  6406. this._cursor = 0;
  6407. this._size = 0;
  6408. }
  6409. Object.defineProperty(SimpleQueue.prototype, "length", {
  6410. get: function () {
  6411. return this._size;
  6412. },
  6413. enumerable: false,
  6414. configurable: true
  6415. });
  6416. SimpleQueue.prototype.push = function (element) {
  6417. var oldBack = this._back;
  6418. var newBack = oldBack;
  6419. if (oldBack._elements.length === QUEUE_MAX_ARRAY_SIZE - 1) {
  6420. newBack = {
  6421. _elements: [],
  6422. _next: undefined
  6423. };
  6424. }
  6425. oldBack._elements.push(element);
  6426. if (newBack !== oldBack) {
  6427. this._back = newBack;
  6428. oldBack._next = newBack;
  6429. }
  6430. ++this._size;
  6431. };
  6432. SimpleQueue.prototype.shift = function () {
  6433. var oldFront = this._front;
  6434. var newFront = oldFront;
  6435. var oldCursor = this._cursor;
  6436. var newCursor = oldCursor + 1;
  6437. var elements = oldFront._elements;
  6438. var element = elements[oldCursor];
  6439. if (newCursor === QUEUE_MAX_ARRAY_SIZE) {
  6440. newFront = oldFront._next;
  6441. newCursor = 0;
  6442. }
  6443. --this._size;
  6444. this._cursor = newCursor;
  6445. if (oldFront !== newFront) {
  6446. this._front = newFront;
  6447. }
  6448. elements[oldCursor] = undefined;
  6449. return element;
  6450. };
  6451. SimpleQueue.prototype.forEach = function (callback) {
  6452. var i = this._cursor;
  6453. var node = this._front;
  6454. var elements = node._elements;
  6455. while (i !== elements.length || node._next !== undefined) {
  6456. if (i === elements.length) {
  6457. node = node._next;
  6458. elements = node._elements;
  6459. i = 0;
  6460. if (elements.length === 0) {
  6461. break;
  6462. }
  6463. }
  6464. callback(elements[i]);
  6465. ++i;
  6466. }
  6467. };
  6468. SimpleQueue.prototype.peek = function () {
  6469. var front = this._front;
  6470. var cursor = this._cursor;
  6471. return front._elements[cursor];
  6472. };
  6473. return SimpleQueue;
  6474. }();
  6475. function ReadableStreamReaderGenericInitialize(reader, stream) {
  6476. reader._ownerReadableStream = stream;
  6477. stream._reader = reader;
  6478. if (stream._state === 'readable') {
  6479. defaultReaderClosedPromiseInitialize(reader);
  6480. } else if (stream._state === 'closed') {
  6481. defaultReaderClosedPromiseInitializeAsResolved(reader);
  6482. } else {
  6483. defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);
  6484. }
  6485. }
  6486. function ReadableStreamReaderGenericCancel(reader, reason) {
  6487. var stream = reader._ownerReadableStream;
  6488. return ReadableStreamCancel(stream, reason);
  6489. }
  6490. function ReadableStreamReaderGenericRelease(reader) {
  6491. if (reader._ownerReadableStream._state === 'readable') {
  6492. defaultReaderClosedPromiseReject(reader, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"));
  6493. } else {
  6494. defaultReaderClosedPromiseResetToRejected(reader, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"));
  6495. }
  6496. reader._ownerReadableStream._reader = undefined;
  6497. reader._ownerReadableStream = undefined;
  6498. }
  6499. function readerLockException(name) {
  6500. return new TypeError('Cannot ' + name + ' a stream using a released reader');
  6501. }
  6502. function defaultReaderClosedPromiseInitialize(reader) {
  6503. reader._closedPromise = newPromise(function (resolve, reject) {
  6504. reader._closedPromise_resolve = resolve;
  6505. reader._closedPromise_reject = reject;
  6506. });
  6507. }
  6508. function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {
  6509. defaultReaderClosedPromiseInitialize(reader);
  6510. defaultReaderClosedPromiseReject(reader, reason);
  6511. }
  6512. function defaultReaderClosedPromiseInitializeAsResolved(reader) {
  6513. defaultReaderClosedPromiseInitialize(reader);
  6514. defaultReaderClosedPromiseResolve(reader);
  6515. }
  6516. function defaultReaderClosedPromiseReject(reader, reason) {
  6517. if (reader._closedPromise_reject === undefined) {
  6518. return;
  6519. }
  6520. setPromiseIsHandledToTrue(reader._closedPromise);
  6521. reader._closedPromise_reject(reason);
  6522. reader._closedPromise_resolve = undefined;
  6523. reader._closedPromise_reject = undefined;
  6524. }
  6525. function defaultReaderClosedPromiseResetToRejected(reader, reason) {
  6526. defaultReaderClosedPromiseInitializeAsRejected(reader, reason);
  6527. }
  6528. function defaultReaderClosedPromiseResolve(reader) {
  6529. if (reader._closedPromise_resolve === undefined) {
  6530. return;
  6531. }
  6532. reader._closedPromise_resolve(undefined);
  6533. reader._closedPromise_resolve = undefined;
  6534. reader._closedPromise_reject = undefined;
  6535. }
  6536. var AbortSteps = SymbolPolyfill('[[AbortSteps]]');
  6537. var ErrorSteps = SymbolPolyfill('[[ErrorSteps]]');
  6538. var CancelSteps = SymbolPolyfill('[[CancelSteps]]');
  6539. var PullSteps = SymbolPolyfill('[[PullSteps]]');
  6540. var NumberIsFinite = Number.isFinite || function (x) {
  6541. return typeof x === 'number' && isFinite(x);
  6542. };
  6543. var MathTrunc = Math.trunc || function (v) {
  6544. return v < 0 ? Math.ceil(v) : Math.floor(v);
  6545. };
  6546. function isDictionary(x) {
  6547. return typeof x === 'object' || typeof x === 'function';
  6548. }
  6549. function assertDictionary(obj, context) {
  6550. if (obj !== undefined && !isDictionary(obj)) {
  6551. throw new TypeError(context + " is not an object.");
  6552. }
  6553. }
  6554. function assertFunction(x, context) {
  6555. if (typeof x !== 'function') {
  6556. throw new TypeError(context + " is not a function.");
  6557. }
  6558. }
  6559. function isObject(x) {
  6560. return typeof x === 'object' && x !== null || typeof x === 'function';
  6561. }
  6562. function assertObject(x, context) {
  6563. if (!isObject(x)) {
  6564. throw new TypeError(context + " is not an object.");
  6565. }
  6566. }
  6567. function assertRequiredArgument(x, position, context) {
  6568. if (x === undefined) {
  6569. throw new TypeError("Parameter " + position + " is required in '" + context + "'.");
  6570. }
  6571. }
  6572. function assertRequiredField(x, field, context) {
  6573. if (x === undefined) {
  6574. throw new TypeError(field + " is required in '" + context + "'.");
  6575. }
  6576. }
  6577. function convertUnrestrictedDouble(value) {
  6578. return Number(value);
  6579. }
  6580. function censorNegativeZero(x) {
  6581. return x === 0 ? 0 : x;
  6582. }
  6583. function integerPart(x) {
  6584. return censorNegativeZero(MathTrunc(x));
  6585. }
  6586. function convertUnsignedLongLongWithEnforceRange(value, context) {
  6587. var lowerBound = 0;
  6588. var upperBound = Number.MAX_SAFE_INTEGER;
  6589. var x = Number(value);
  6590. x = censorNegativeZero(x);
  6591. if (!NumberIsFinite(x)) {
  6592. throw new TypeError(context + " is not a finite number");
  6593. }
  6594. x = integerPart(x);
  6595. if (x < lowerBound || x > upperBound) {
  6596. throw new TypeError(context + " is outside the accepted range of " + lowerBound + " to " + upperBound + ", inclusive");
  6597. }
  6598. if (!NumberIsFinite(x) || x === 0) {
  6599. return 0;
  6600. }
  6601. return x;
  6602. }
  6603. function assertReadableStream(x, context) {
  6604. if (!IsReadableStream(x)) {
  6605. throw new TypeError(context + " is not a ReadableStream.");
  6606. }
  6607. }
  6608. function AcquireReadableStreamDefaultReader(stream) {
  6609. return new ReadableStreamDefaultReader(stream);
  6610. }
  6611. function ReadableStreamAddReadRequest(stream, readRequest) {
  6612. stream._reader._readRequests.push(readRequest);
  6613. }
  6614. function ReadableStreamFulfillReadRequest(stream, chunk, done) {
  6615. var reader = stream._reader;
  6616. var readRequest = reader._readRequests.shift();
  6617. if (done) {
  6618. readRequest._closeSteps();
  6619. } else {
  6620. readRequest._chunkSteps(chunk);
  6621. }
  6622. }
  6623. function ReadableStreamGetNumReadRequests(stream) {
  6624. return stream._reader._readRequests.length;
  6625. }
  6626. function ReadableStreamHasDefaultReader(stream) {
  6627. var reader = stream._reader;
  6628. if (reader === undefined) {
  6629. return false;
  6630. }
  6631. if (!IsReadableStreamDefaultReader(reader)) {
  6632. return false;
  6633. }
  6634. return true;
  6635. }
  6636. var ReadableStreamDefaultReader = function () {
  6637. function ReadableStreamDefaultReader(stream) {
  6638. assertRequiredArgument(stream, 1, 'ReadableStreamDefaultReader');
  6639. assertReadableStream(stream, 'First parameter');
  6640. if (IsReadableStreamLocked(stream)) {
  6641. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  6642. }
  6643. ReadableStreamReaderGenericInitialize(this, stream);
  6644. this._readRequests = new SimpleQueue();
  6645. }
  6646. Object.defineProperty(ReadableStreamDefaultReader.prototype, "closed", {
  6647. get: function () {
  6648. if (!IsReadableStreamDefaultReader(this)) {
  6649. return promiseRejectedWith(defaultReaderBrandCheckException('closed'));
  6650. }
  6651. return this._closedPromise;
  6652. },
  6653. enumerable: false,
  6654. configurable: true
  6655. });
  6656. ReadableStreamDefaultReader.prototype.cancel = function (reason) {
  6657. if (reason === void 0) {
  6658. reason = undefined;
  6659. }
  6660. if (!IsReadableStreamDefaultReader(this)) {
  6661. return promiseRejectedWith(defaultReaderBrandCheckException('cancel'));
  6662. }
  6663. if (this._ownerReadableStream === undefined) {
  6664. return promiseRejectedWith(readerLockException('cancel'));
  6665. }
  6666. return ReadableStreamReaderGenericCancel(this, reason);
  6667. };
  6668. ReadableStreamDefaultReader.prototype.read = function () {
  6669. if (!IsReadableStreamDefaultReader(this)) {
  6670. return promiseRejectedWith(defaultReaderBrandCheckException('read'));
  6671. }
  6672. if (this._ownerReadableStream === undefined) {
  6673. return promiseRejectedWith(readerLockException('read from'));
  6674. }
  6675. var resolvePromise;
  6676. var rejectPromise;
  6677. var promise = newPromise(function (resolve, reject) {
  6678. resolvePromise = resolve;
  6679. rejectPromise = reject;
  6680. });
  6681. var readRequest = {
  6682. _chunkSteps: function (chunk) {
  6683. return resolvePromise({
  6684. value: chunk,
  6685. done: false
  6686. });
  6687. },
  6688. _closeSteps: function () {
  6689. return resolvePromise({
  6690. value: undefined,
  6691. done: true
  6692. });
  6693. },
  6694. _errorSteps: function (e) {
  6695. return rejectPromise(e);
  6696. }
  6697. };
  6698. ReadableStreamDefaultReaderRead(this, readRequest);
  6699. return promise;
  6700. };
  6701. ReadableStreamDefaultReader.prototype.releaseLock = function () {
  6702. if (!IsReadableStreamDefaultReader(this)) {
  6703. throw defaultReaderBrandCheckException('releaseLock');
  6704. }
  6705. if (this._ownerReadableStream === undefined) {
  6706. return;
  6707. }
  6708. if (this._readRequests.length > 0) {
  6709. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  6710. }
  6711. ReadableStreamReaderGenericRelease(this);
  6712. };
  6713. return ReadableStreamDefaultReader;
  6714. }();
  6715. Object.defineProperties(ReadableStreamDefaultReader.prototype, {
  6716. cancel: { enumerable: true },
  6717. read: { enumerable: true },
  6718. releaseLock: { enumerable: true },
  6719. closed: { enumerable: true }
  6720. });
  6721. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  6722. Object.defineProperty(ReadableStreamDefaultReader.prototype, SymbolPolyfill.toStringTag, {
  6723. value: 'ReadableStreamDefaultReader',
  6724. configurable: true
  6725. });
  6726. }
  6727. function IsReadableStreamDefaultReader(x) {
  6728. if (!typeIsObject(x)) {
  6729. return false;
  6730. }
  6731. if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
  6732. return false;
  6733. }
  6734. return true;
  6735. }
  6736. function ReadableStreamDefaultReaderRead(reader, readRequest) {
  6737. var stream = reader._ownerReadableStream;
  6738. stream._disturbed = true;
  6739. if (stream._state === 'closed') {
  6740. readRequest._closeSteps();
  6741. } else if (stream._state === 'errored') {
  6742. readRequest._errorSteps(stream._storedError);
  6743. } else {
  6744. stream._readableStreamController[PullSteps](readRequest);
  6745. }
  6746. }
  6747. function defaultReaderBrandCheckException(name) {
  6748. return new TypeError("ReadableStreamDefaultReader.prototype." + name + " can only be used on a ReadableStreamDefaultReader");
  6749. }
  6750. var _a;
  6751. var AsyncIteratorPrototype;
  6752. if (typeof SymbolPolyfill.asyncIterator === 'symbol') {
  6753. AsyncIteratorPrototype = (_a = {}, _a[SymbolPolyfill.asyncIterator] = function () {
  6754. return this;
  6755. }, _a);
  6756. Object.defineProperty(AsyncIteratorPrototype, SymbolPolyfill.asyncIterator, { enumerable: false });
  6757. }
  6758. var ReadableStreamAsyncIteratorImpl = function () {
  6759. function ReadableStreamAsyncIteratorImpl(reader, preventCancel) {
  6760. this._ongoingPromise = undefined;
  6761. this._isFinished = false;
  6762. this._reader = reader;
  6763. this._preventCancel = preventCancel;
  6764. }
  6765. ReadableStreamAsyncIteratorImpl.prototype.next = function () {
  6766. var _this = this;
  6767. var nextSteps = function () {
  6768. return _this._nextSteps();
  6769. };
  6770. this._ongoingPromise = this._ongoingPromise ? transformPromiseWith(this._ongoingPromise, nextSteps, nextSteps) : nextSteps();
  6771. return this._ongoingPromise;
  6772. };
  6773. ReadableStreamAsyncIteratorImpl.prototype.return = function (value) {
  6774. var _this = this;
  6775. var returnSteps = function () {
  6776. return _this._returnSteps(value);
  6777. };
  6778. return this._ongoingPromise ? transformPromiseWith(this._ongoingPromise, returnSteps, returnSteps) : returnSteps();
  6779. };
  6780. ReadableStreamAsyncIteratorImpl.prototype._nextSteps = function () {
  6781. var _this = this;
  6782. if (this._isFinished) {
  6783. return Promise.resolve({
  6784. value: undefined,
  6785. done: true
  6786. });
  6787. }
  6788. var reader = this._reader;
  6789. if (reader._ownerReadableStream === undefined) {
  6790. return promiseRejectedWith(readerLockException('iterate'));
  6791. }
  6792. var resolvePromise;
  6793. var rejectPromise;
  6794. var promise = newPromise(function (resolve, reject) {
  6795. resolvePromise = resolve;
  6796. rejectPromise = reject;
  6797. });
  6798. var readRequest = {
  6799. _chunkSteps: function (chunk) {
  6800. _this._ongoingPromise = undefined;
  6801. queueMicrotask(function () {
  6802. return resolvePromise({
  6803. value: chunk,
  6804. done: false
  6805. });
  6806. });
  6807. },
  6808. _closeSteps: function () {
  6809. _this._ongoingPromise = undefined;
  6810. _this._isFinished = true;
  6811. ReadableStreamReaderGenericRelease(reader);
  6812. resolvePromise({
  6813. value: undefined,
  6814. done: true
  6815. });
  6816. },
  6817. _errorSteps: function (reason) {
  6818. _this._ongoingPromise = undefined;
  6819. _this._isFinished = true;
  6820. ReadableStreamReaderGenericRelease(reader);
  6821. rejectPromise(reason);
  6822. }
  6823. };
  6824. ReadableStreamDefaultReaderRead(reader, readRequest);
  6825. return promise;
  6826. };
  6827. ReadableStreamAsyncIteratorImpl.prototype._returnSteps = function (value) {
  6828. if (this._isFinished) {
  6829. return Promise.resolve({
  6830. value: value,
  6831. done: true
  6832. });
  6833. }
  6834. this._isFinished = true;
  6835. var reader = this._reader;
  6836. if (reader._ownerReadableStream === undefined) {
  6837. return promiseRejectedWith(readerLockException('finish iterating'));
  6838. }
  6839. if (!this._preventCancel) {
  6840. var result = ReadableStreamReaderGenericCancel(reader, value);
  6841. ReadableStreamReaderGenericRelease(reader);
  6842. return transformPromiseWith(result, function () {
  6843. return {
  6844. value: value,
  6845. done: true
  6846. };
  6847. });
  6848. }
  6849. ReadableStreamReaderGenericRelease(reader);
  6850. return promiseResolvedWith({
  6851. value: value,
  6852. done: true
  6853. });
  6854. };
  6855. return ReadableStreamAsyncIteratorImpl;
  6856. }();
  6857. var ReadableStreamAsyncIteratorPrototype = {
  6858. next: function () {
  6859. if (!IsReadableStreamAsyncIterator(this)) {
  6860. return promiseRejectedWith(streamAsyncIteratorBrandCheckException('next'));
  6861. }
  6862. return this._asyncIteratorImpl.next();
  6863. },
  6864. return: function (value) {
  6865. if (!IsReadableStreamAsyncIterator(this)) {
  6866. return promiseRejectedWith(streamAsyncIteratorBrandCheckException('return'));
  6867. }
  6868. return this._asyncIteratorImpl.return(value);
  6869. }
  6870. };
  6871. if (AsyncIteratorPrototype !== undefined) {
  6872. Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
  6873. }
  6874. function AcquireReadableStreamAsyncIterator(stream, preventCancel) {
  6875. var reader = AcquireReadableStreamDefaultReader(stream);
  6876. var impl = new ReadableStreamAsyncIteratorImpl(reader, preventCancel);
  6877. var iterator = Object.create(ReadableStreamAsyncIteratorPrototype);
  6878. iterator._asyncIteratorImpl = impl;
  6879. return iterator;
  6880. }
  6881. function IsReadableStreamAsyncIterator(x) {
  6882. if (!typeIsObject(x)) {
  6883. return false;
  6884. }
  6885. if (!Object.prototype.hasOwnProperty.call(x, '_asyncIteratorImpl')) {
  6886. return false;
  6887. }
  6888. return true;
  6889. }
  6890. function streamAsyncIteratorBrandCheckException(name) {
  6891. return new TypeError("ReadableStreamAsyncIterator." + name + " can only be used on a ReadableSteamAsyncIterator");
  6892. }
  6893. var NumberIsNaN = Number.isNaN || function (x) {
  6894. return x !== x;
  6895. };
  6896. function IsFiniteNonNegativeNumber(v) {
  6897. if (!IsNonNegativeNumber(v)) {
  6898. return false;
  6899. }
  6900. if (v === Infinity) {
  6901. return false;
  6902. }
  6903. return true;
  6904. }
  6905. function IsNonNegativeNumber(v) {
  6906. if (typeof v !== 'number') {
  6907. return false;
  6908. }
  6909. if (NumberIsNaN(v)) {
  6910. return false;
  6911. }
  6912. if (v < 0) {
  6913. return false;
  6914. }
  6915. return true;
  6916. }
  6917. function DequeueValue(container) {
  6918. var pair = container._queue.shift();
  6919. container._queueTotalSize -= pair.size;
  6920. if (container._queueTotalSize < 0) {
  6921. container._queueTotalSize = 0;
  6922. }
  6923. return pair.value;
  6924. }
  6925. function EnqueueValueWithSize(container, value, size) {
  6926. size = Number(size);
  6927. if (!IsFiniteNonNegativeNumber(size)) {
  6928. throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
  6929. }
  6930. container._queue.push({
  6931. value: value,
  6932. size: size
  6933. });
  6934. container._queueTotalSize += size;
  6935. }
  6936. function PeekQueueValue(container) {
  6937. var pair = container._queue.peek();
  6938. return pair.value;
  6939. }
  6940. function ResetQueue(container) {
  6941. container._queue = new SimpleQueue();
  6942. container._queueTotalSize = 0;
  6943. }
  6944. function CreateArrayFromList(elements) {
  6945. return elements.slice();
  6946. }
  6947. function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
  6948. new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
  6949. }
  6950. function TransferArrayBuffer(O) {
  6951. return O;
  6952. }
  6953. function IsDetachedBuffer(O) {
  6954. return false;
  6955. }
  6956. var ReadableStreamBYOBRequest = function () {
  6957. function ReadableStreamBYOBRequest() {
  6958. throw new TypeError('Illegal constructor');
  6959. }
  6960. Object.defineProperty(ReadableStreamBYOBRequest.prototype, "view", {
  6961. get: function () {
  6962. if (!IsReadableStreamBYOBRequest(this)) {
  6963. throw byobRequestBrandCheckException('view');
  6964. }
  6965. return this._view;
  6966. },
  6967. enumerable: false,
  6968. configurable: true
  6969. });
  6970. ReadableStreamBYOBRequest.prototype.respond = function (bytesWritten) {
  6971. if (!IsReadableStreamBYOBRequest(this)) {
  6972. throw byobRequestBrandCheckException('respond');
  6973. }
  6974. assertRequiredArgument(bytesWritten, 1, 'respond');
  6975. bytesWritten = convertUnsignedLongLongWithEnforceRange(bytesWritten, 'First parameter');
  6976. if (this._associatedReadableByteStreamController === undefined) {
  6977. throw new TypeError('This BYOB request has been invalidated');
  6978. }
  6979. if (IsDetachedBuffer(this._view.buffer));
  6980. ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
  6981. };
  6982. ReadableStreamBYOBRequest.prototype.respondWithNewView = function (view) {
  6983. if (!IsReadableStreamBYOBRequest(this)) {
  6984. throw byobRequestBrandCheckException('respondWithNewView');
  6985. }
  6986. assertRequiredArgument(view, 1, 'respondWithNewView');
  6987. if (!ArrayBuffer.isView(view)) {
  6988. throw new TypeError('You can only respond with array buffer views');
  6989. }
  6990. if (view.byteLength === 0) {
  6991. throw new TypeError('chunk must have non-zero byteLength');
  6992. }
  6993. if (view.buffer.byteLength === 0) {
  6994. throw new TypeError("chunk's buffer must have non-zero byteLength");
  6995. }
  6996. if (this._associatedReadableByteStreamController === undefined) {
  6997. throw new TypeError('This BYOB request has been invalidated');
  6998. }
  6999. ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
  7000. };
  7001. return ReadableStreamBYOBRequest;
  7002. }();
  7003. Object.defineProperties(ReadableStreamBYOBRequest.prototype, {
  7004. respond: { enumerable: true },
  7005. respondWithNewView: { enumerable: true },
  7006. view: { enumerable: true }
  7007. });
  7008. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  7009. Object.defineProperty(ReadableStreamBYOBRequest.prototype, SymbolPolyfill.toStringTag, {
  7010. value: 'ReadableStreamBYOBRequest',
  7011. configurable: true
  7012. });
  7013. }
  7014. var ReadableByteStreamController = function () {
  7015. function ReadableByteStreamController() {
  7016. throw new TypeError('Illegal constructor');
  7017. }
  7018. Object.defineProperty(ReadableByteStreamController.prototype, "byobRequest", {
  7019. get: function () {
  7020. if (!IsReadableByteStreamController(this)) {
  7021. throw byteStreamControllerBrandCheckException('byobRequest');
  7022. }
  7023. if (this._byobRequest === null && this._pendingPullIntos.length > 0) {
  7024. var firstDescriptor = this._pendingPullIntos.peek();
  7025. var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
  7026. var byobRequest = Object.create(ReadableStreamBYOBRequest.prototype);
  7027. SetUpReadableStreamBYOBRequest(byobRequest, this, view);
  7028. this._byobRequest = byobRequest;
  7029. }
  7030. return this._byobRequest;
  7031. },
  7032. enumerable: false,
  7033. configurable: true
  7034. });
  7035. Object.defineProperty(ReadableByteStreamController.prototype, "desiredSize", {
  7036. get: function () {
  7037. if (!IsReadableByteStreamController(this)) {
  7038. throw byteStreamControllerBrandCheckException('desiredSize');
  7039. }
  7040. return ReadableByteStreamControllerGetDesiredSize(this);
  7041. },
  7042. enumerable: false,
  7043. configurable: true
  7044. });
  7045. ReadableByteStreamController.prototype.close = function () {
  7046. if (!IsReadableByteStreamController(this)) {
  7047. throw byteStreamControllerBrandCheckException('close');
  7048. }
  7049. if (this._closeRequested) {
  7050. throw new TypeError('The stream has already been closed; do not close it again!');
  7051. }
  7052. var state = this._controlledReadableByteStream._state;
  7053. if (state !== 'readable') {
  7054. throw new TypeError("The stream (in " + state + " state) is not in the readable state and cannot be closed");
  7055. }
  7056. ReadableByteStreamControllerClose(this);
  7057. };
  7058. ReadableByteStreamController.prototype.enqueue = function (chunk) {
  7059. if (!IsReadableByteStreamController(this)) {
  7060. throw byteStreamControllerBrandCheckException('enqueue');
  7061. }
  7062. assertRequiredArgument(chunk, 1, 'enqueue');
  7063. if (!ArrayBuffer.isView(chunk)) {
  7064. throw new TypeError('chunk must be an array buffer view');
  7065. }
  7066. if (chunk.byteLength === 0) {
  7067. throw new TypeError('chunk must have non-zero byteLength');
  7068. }
  7069. if (chunk.buffer.byteLength === 0) {
  7070. throw new TypeError("chunk's buffer must have non-zero byteLength");
  7071. }
  7072. if (this._closeRequested) {
  7073. throw new TypeError('stream is closed or draining');
  7074. }
  7075. var state = this._controlledReadableByteStream._state;
  7076. if (state !== 'readable') {
  7077. throw new TypeError("The stream (in " + state + " state) is not in the readable state and cannot be enqueued to");
  7078. }
  7079. ReadableByteStreamControllerEnqueue(this, chunk);
  7080. };
  7081. ReadableByteStreamController.prototype.error = function (e) {
  7082. if (e === void 0) {
  7083. e = undefined;
  7084. }
  7085. if (!IsReadableByteStreamController(this)) {
  7086. throw byteStreamControllerBrandCheckException('error');
  7087. }
  7088. ReadableByteStreamControllerError(this, e);
  7089. };
  7090. ReadableByteStreamController.prototype[CancelSteps] = function (reason) {
  7091. if (this._pendingPullIntos.length > 0) {
  7092. var firstDescriptor = this._pendingPullIntos.peek();
  7093. firstDescriptor.bytesFilled = 0;
  7094. }
  7095. ResetQueue(this);
  7096. var result = this._cancelAlgorithm(reason);
  7097. ReadableByteStreamControllerClearAlgorithms(this);
  7098. return result;
  7099. };
  7100. ReadableByteStreamController.prototype[PullSteps] = function (readRequest) {
  7101. var stream = this._controlledReadableByteStream;
  7102. if (this._queueTotalSize > 0) {
  7103. var entry = this._queue.shift();
  7104. this._queueTotalSize -= entry.byteLength;
  7105. ReadableByteStreamControllerHandleQueueDrain(this);
  7106. var view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
  7107. readRequest._chunkSteps(view);
  7108. return;
  7109. }
  7110. var autoAllocateChunkSize = this._autoAllocateChunkSize;
  7111. if (autoAllocateChunkSize !== undefined) {
  7112. var buffer = void 0;
  7113. try {
  7114. buffer = new ArrayBuffer(autoAllocateChunkSize);
  7115. } catch (bufferE) {
  7116. readRequest._errorSteps(bufferE);
  7117. return;
  7118. }
  7119. var pullIntoDescriptor = {
  7120. buffer: buffer,
  7121. byteOffset: 0,
  7122. byteLength: autoAllocateChunkSize,
  7123. bytesFilled: 0,
  7124. elementSize: 1,
  7125. viewConstructor: Uint8Array,
  7126. readerType: 'default'
  7127. };
  7128. this._pendingPullIntos.push(pullIntoDescriptor);
  7129. }
  7130. ReadableStreamAddReadRequest(stream, readRequest);
  7131. ReadableByteStreamControllerCallPullIfNeeded(this);
  7132. };
  7133. return ReadableByteStreamController;
  7134. }();
  7135. Object.defineProperties(ReadableByteStreamController.prototype, {
  7136. close: { enumerable: true },
  7137. enqueue: { enumerable: true },
  7138. error: { enumerable: true },
  7139. byobRequest: { enumerable: true },
  7140. desiredSize: { enumerable: true }
  7141. });
  7142. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  7143. Object.defineProperty(ReadableByteStreamController.prototype, SymbolPolyfill.toStringTag, {
  7144. value: 'ReadableByteStreamController',
  7145. configurable: true
  7146. });
  7147. }
  7148. function IsReadableByteStreamController(x) {
  7149. if (!typeIsObject(x)) {
  7150. return false;
  7151. }
  7152. if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableByteStream')) {
  7153. return false;
  7154. }
  7155. return true;
  7156. }
  7157. function IsReadableStreamBYOBRequest(x) {
  7158. if (!typeIsObject(x)) {
  7159. return false;
  7160. }
  7161. if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
  7162. return false;
  7163. }
  7164. return true;
  7165. }
  7166. function ReadableByteStreamControllerCallPullIfNeeded(controller) {
  7167. var shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
  7168. if (!shouldPull) {
  7169. return;
  7170. }
  7171. if (controller._pulling) {
  7172. controller._pullAgain = true;
  7173. return;
  7174. }
  7175. controller._pulling = true;
  7176. var pullPromise = controller._pullAlgorithm();
  7177. uponPromise(pullPromise, function () {
  7178. controller._pulling = false;
  7179. if (controller._pullAgain) {
  7180. controller._pullAgain = false;
  7181. ReadableByteStreamControllerCallPullIfNeeded(controller);
  7182. }
  7183. }, function (e) {
  7184. ReadableByteStreamControllerError(controller, e);
  7185. });
  7186. }
  7187. function ReadableByteStreamControllerClearPendingPullIntos(controller) {
  7188. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  7189. controller._pendingPullIntos = new SimpleQueue();
  7190. }
  7191. function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {
  7192. var done = false;
  7193. if (stream._state === 'closed') {
  7194. done = true;
  7195. }
  7196. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  7197. if (pullIntoDescriptor.readerType === 'default') {
  7198. ReadableStreamFulfillReadRequest(stream, filledView, done);
  7199. } else {
  7200. ReadableStreamFulfillReadIntoRequest(stream, filledView, done);
  7201. }
  7202. }
  7203. function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {
  7204. var bytesFilled = pullIntoDescriptor.bytesFilled;
  7205. var elementSize = pullIntoDescriptor.elementSize;
  7206. return new pullIntoDescriptor.viewConstructor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);
  7207. }
  7208. function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {
  7209. controller._queue.push({
  7210. buffer: buffer,
  7211. byteOffset: byteOffset,
  7212. byteLength: byteLength
  7213. });
  7214. controller._queueTotalSize += byteLength;
  7215. }
  7216. function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
  7217. var elementSize = pullIntoDescriptor.elementSize;
  7218. var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
  7219. var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
  7220. var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
  7221. var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
  7222. var totalBytesToCopyRemaining = maxBytesToCopy;
  7223. var ready = false;
  7224. if (maxAlignedBytes > currentAlignedBytes) {
  7225. totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
  7226. ready = true;
  7227. }
  7228. var queue = controller._queue;
  7229. while (totalBytesToCopyRemaining > 0) {
  7230. var headOfQueue = queue.peek();
  7231. var bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength);
  7232. var destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  7233. CopyDataBlockBytes(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);
  7234. if (headOfQueue.byteLength === bytesToCopy) {
  7235. queue.shift();
  7236. } else {
  7237. headOfQueue.byteOffset += bytesToCopy;
  7238. headOfQueue.byteLength -= bytesToCopy;
  7239. }
  7240. controller._queueTotalSize -= bytesToCopy;
  7241. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor);
  7242. totalBytesToCopyRemaining -= bytesToCopy;
  7243. }
  7244. return ready;
  7245. }
  7246. function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
  7247. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  7248. pullIntoDescriptor.bytesFilled += size;
  7249. }
  7250. function ReadableByteStreamControllerHandleQueueDrain(controller) {
  7251. if (controller._queueTotalSize === 0 && controller._closeRequested) {
  7252. ReadableByteStreamControllerClearAlgorithms(controller);
  7253. ReadableStreamClose(controller._controlledReadableByteStream);
  7254. } else {
  7255. ReadableByteStreamControllerCallPullIfNeeded(controller);
  7256. }
  7257. }
  7258. function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {
  7259. if (controller._byobRequest === null) {
  7260. return;
  7261. }
  7262. controller._byobRequest._associatedReadableByteStreamController = undefined;
  7263. controller._byobRequest._view = null;
  7264. controller._byobRequest = null;
  7265. }
  7266. function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {
  7267. while (controller._pendingPullIntos.length > 0) {
  7268. if (controller._queueTotalSize === 0) {
  7269. return;
  7270. }
  7271. var pullIntoDescriptor = controller._pendingPullIntos.peek();
  7272. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor)) {
  7273. ReadableByteStreamControllerShiftPendingPullInto(controller);
  7274. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
  7275. }
  7276. }
  7277. }
  7278. function ReadableByteStreamControllerPullInto(controller, view, readIntoRequest) {
  7279. var stream = controller._controlledReadableByteStream;
  7280. var elementSize = 1;
  7281. if (view.constructor !== DataView) {
  7282. elementSize = view.constructor.BYTES_PER_ELEMENT;
  7283. }
  7284. var ctor = view.constructor;
  7285. var buffer = TransferArrayBuffer(view.buffer);
  7286. var pullIntoDescriptor = {
  7287. buffer: buffer,
  7288. byteOffset: view.byteOffset,
  7289. byteLength: view.byteLength,
  7290. bytesFilled: 0,
  7291. elementSize: elementSize,
  7292. viewConstructor: ctor,
  7293. readerType: 'byob'
  7294. };
  7295. if (controller._pendingPullIntos.length > 0) {
  7296. controller._pendingPullIntos.push(pullIntoDescriptor);
  7297. ReadableStreamAddReadIntoRequest(stream, readIntoRequest);
  7298. return;
  7299. }
  7300. if (stream._state === 'closed') {
  7301. var emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
  7302. readIntoRequest._closeSteps(emptyView);
  7303. return;
  7304. }
  7305. if (controller._queueTotalSize > 0) {
  7306. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor)) {
  7307. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  7308. ReadableByteStreamControllerHandleQueueDrain(controller);
  7309. readIntoRequest._chunkSteps(filledView);
  7310. return;
  7311. }
  7312. if (controller._closeRequested) {
  7313. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  7314. ReadableByteStreamControllerError(controller, e);
  7315. readIntoRequest._errorSteps(e);
  7316. return;
  7317. }
  7318. }
  7319. controller._pendingPullIntos.push(pullIntoDescriptor);
  7320. ReadableStreamAddReadIntoRequest(stream, readIntoRequest);
  7321. ReadableByteStreamControllerCallPullIfNeeded(controller);
  7322. }
  7323. function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
  7324. firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
  7325. var stream = controller._controlledReadableByteStream;
  7326. if (ReadableStreamHasBYOBReader(stream)) {
  7327. while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  7328. var pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
  7329. ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);
  7330. }
  7331. }
  7332. }
  7333. function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
  7334. if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
  7335. throw new RangeError('bytesWritten out of range');
  7336. }
  7337. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
  7338. if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
  7339. return;
  7340. }
  7341. ReadableByteStreamControllerShiftPendingPullInto(controller);
  7342. var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
  7343. if (remainderSize > 0) {
  7344. var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  7345. var remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end);
  7346. ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
  7347. }
  7348. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  7349. pullIntoDescriptor.bytesFilled -= remainderSize;
  7350. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
  7351. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  7352. }
  7353. function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
  7354. var firstDescriptor = controller._pendingPullIntos.peek();
  7355. var state = controller._controlledReadableByteStream._state;
  7356. if (state === 'closed') {
  7357. if (bytesWritten !== 0) {
  7358. throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
  7359. }
  7360. ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
  7361. } else {
  7362. ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
  7363. }
  7364. ReadableByteStreamControllerCallPullIfNeeded(controller);
  7365. }
  7366. function ReadableByteStreamControllerShiftPendingPullInto(controller) {
  7367. var descriptor = controller._pendingPullIntos.shift();
  7368. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  7369. return descriptor;
  7370. }
  7371. function ReadableByteStreamControllerShouldCallPull(controller) {
  7372. var stream = controller._controlledReadableByteStream;
  7373. if (stream._state !== 'readable') {
  7374. return false;
  7375. }
  7376. if (controller._closeRequested) {
  7377. return false;
  7378. }
  7379. if (!controller._started) {
  7380. return false;
  7381. }
  7382. if (ReadableStreamHasDefaultReader(stream) && ReadableStreamGetNumReadRequests(stream) > 0) {
  7383. return true;
  7384. }
  7385. if (ReadableStreamHasBYOBReader(stream) && ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  7386. return true;
  7387. }
  7388. var desiredSize = ReadableByteStreamControllerGetDesiredSize(controller);
  7389. if (desiredSize > 0) {
  7390. return true;
  7391. }
  7392. return false;
  7393. }
  7394. function ReadableByteStreamControllerClearAlgorithms(controller) {
  7395. controller._pullAlgorithm = undefined;
  7396. controller._cancelAlgorithm = undefined;
  7397. }
  7398. function ReadableByteStreamControllerClose(controller) {
  7399. var stream = controller._controlledReadableByteStream;
  7400. if (controller._closeRequested || stream._state !== 'readable') {
  7401. return;
  7402. }
  7403. if (controller._queueTotalSize > 0) {
  7404. controller._closeRequested = true;
  7405. return;
  7406. }
  7407. if (controller._pendingPullIntos.length > 0) {
  7408. var firstPendingPullInto = controller._pendingPullIntos.peek();
  7409. if (firstPendingPullInto.bytesFilled > 0) {
  7410. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  7411. ReadableByteStreamControllerError(controller, e);
  7412. throw e;
  7413. }
  7414. }
  7415. ReadableByteStreamControllerClearAlgorithms(controller);
  7416. ReadableStreamClose(stream);
  7417. }
  7418. function ReadableByteStreamControllerEnqueue(controller, chunk) {
  7419. var stream = controller._controlledReadableByteStream;
  7420. if (controller._closeRequested || stream._state !== 'readable') {
  7421. return;
  7422. }
  7423. var buffer = chunk.buffer;
  7424. var byteOffset = chunk.byteOffset;
  7425. var byteLength = chunk.byteLength;
  7426. var transferredBuffer = TransferArrayBuffer(buffer);
  7427. if (ReadableStreamHasDefaultReader(stream)) {
  7428. if (ReadableStreamGetNumReadRequests(stream) === 0) {
  7429. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  7430. } else {
  7431. var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
  7432. ReadableStreamFulfillReadRequest(stream, transferredView, false);
  7433. }
  7434. } else if (ReadableStreamHasBYOBReader(stream)) {
  7435. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  7436. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  7437. } else {
  7438. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  7439. }
  7440. ReadableByteStreamControllerCallPullIfNeeded(controller);
  7441. }
  7442. function ReadableByteStreamControllerError(controller, e) {
  7443. var stream = controller._controlledReadableByteStream;
  7444. if (stream._state !== 'readable') {
  7445. return;
  7446. }
  7447. ReadableByteStreamControllerClearPendingPullIntos(controller);
  7448. ResetQueue(controller);
  7449. ReadableByteStreamControllerClearAlgorithms(controller);
  7450. ReadableStreamError(stream, e);
  7451. }
  7452. function ReadableByteStreamControllerGetDesiredSize(controller) {
  7453. var state = controller._controlledReadableByteStream._state;
  7454. if (state === 'errored') {
  7455. return null;
  7456. }
  7457. if (state === 'closed') {
  7458. return 0;
  7459. }
  7460. return controller._strategyHWM - controller._queueTotalSize;
  7461. }
  7462. function ReadableByteStreamControllerRespond(controller, bytesWritten) {
  7463. bytesWritten = Number(bytesWritten);
  7464. if (!IsFiniteNonNegativeNumber(bytesWritten)) {
  7465. throw new RangeError('bytesWritten must be a finite');
  7466. }
  7467. ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
  7468. }
  7469. function ReadableByteStreamControllerRespondWithNewView(controller, view) {
  7470. var firstDescriptor = controller._pendingPullIntos.peek();
  7471. if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
  7472. throw new RangeError('The region specified by view does not match byobRequest');
  7473. }
  7474. if (firstDescriptor.byteLength !== view.byteLength) {
  7475. throw new RangeError('The buffer of view has different capacity than byobRequest');
  7476. }
  7477. firstDescriptor.buffer = view.buffer;
  7478. ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
  7479. }
  7480. function SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize) {
  7481. controller._controlledReadableByteStream = stream;
  7482. controller._pullAgain = false;
  7483. controller._pulling = false;
  7484. controller._byobRequest = null;
  7485. controller._queue = controller._queueTotalSize = undefined;
  7486. ResetQueue(controller);
  7487. controller._closeRequested = false;
  7488. controller._started = false;
  7489. controller._strategyHWM = highWaterMark;
  7490. controller._pullAlgorithm = pullAlgorithm;
  7491. controller._cancelAlgorithm = cancelAlgorithm;
  7492. controller._autoAllocateChunkSize = autoAllocateChunkSize;
  7493. controller._pendingPullIntos = new SimpleQueue();
  7494. stream._readableStreamController = controller;
  7495. var startResult = startAlgorithm();
  7496. uponPromise(promiseResolvedWith(startResult), function () {
  7497. controller._started = true;
  7498. ReadableByteStreamControllerCallPullIfNeeded(controller);
  7499. }, function (r) {
  7500. ReadableByteStreamControllerError(controller, r);
  7501. });
  7502. }
  7503. function SetUpReadableByteStreamControllerFromUnderlyingSource(stream, underlyingByteSource, highWaterMark) {
  7504. var controller = Object.create(ReadableByteStreamController.prototype);
  7505. var startAlgorithm = function () {
  7506. return undefined;
  7507. };
  7508. var pullAlgorithm = function () {
  7509. return promiseResolvedWith(undefined);
  7510. };
  7511. var cancelAlgorithm = function () {
  7512. return promiseResolvedWith(undefined);
  7513. };
  7514. if (underlyingByteSource.start !== undefined) {
  7515. startAlgorithm = function () {
  7516. return underlyingByteSource.start(controller);
  7517. };
  7518. }
  7519. if (underlyingByteSource.pull !== undefined) {
  7520. pullAlgorithm = function () {
  7521. return underlyingByteSource.pull(controller);
  7522. };
  7523. }
  7524. if (underlyingByteSource.cancel !== undefined) {
  7525. cancelAlgorithm = function (reason) {
  7526. return underlyingByteSource.cancel(reason);
  7527. };
  7528. }
  7529. var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
  7530. SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize);
  7531. }
  7532. function SetUpReadableStreamBYOBRequest(request, controller, view) {
  7533. request._associatedReadableByteStreamController = controller;
  7534. request._view = view;
  7535. }
  7536. function byobRequestBrandCheckException(name) {
  7537. return new TypeError("ReadableStreamBYOBRequest.prototype." + name + " can only be used on a ReadableStreamBYOBRequest");
  7538. }
  7539. function byteStreamControllerBrandCheckException(name) {
  7540. return new TypeError("ReadableByteStreamController.prototype." + name + " can only be used on a ReadableByteStreamController");
  7541. }
  7542. function AcquireReadableStreamBYOBReader(stream) {
  7543. return new ReadableStreamBYOBReader(stream);
  7544. }
  7545. function ReadableStreamAddReadIntoRequest(stream, readIntoRequest) {
  7546. stream._reader._readIntoRequests.push(readIntoRequest);
  7547. }
  7548. function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) {
  7549. var reader = stream._reader;
  7550. var readIntoRequest = reader._readIntoRequests.shift();
  7551. if (done) {
  7552. readIntoRequest._closeSteps(chunk);
  7553. } else {
  7554. readIntoRequest._chunkSteps(chunk);
  7555. }
  7556. }
  7557. function ReadableStreamGetNumReadIntoRequests(stream) {
  7558. return stream._reader._readIntoRequests.length;
  7559. }
  7560. function ReadableStreamHasBYOBReader(stream) {
  7561. var reader = stream._reader;
  7562. if (reader === undefined) {
  7563. return false;
  7564. }
  7565. if (!IsReadableStreamBYOBReader(reader)) {
  7566. return false;
  7567. }
  7568. return true;
  7569. }
  7570. var ReadableStreamBYOBReader = function () {
  7571. function ReadableStreamBYOBReader(stream) {
  7572. assertRequiredArgument(stream, 1, 'ReadableStreamBYOBReader');
  7573. assertReadableStream(stream, 'First parameter');
  7574. if (IsReadableStreamLocked(stream)) {
  7575. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  7576. }
  7577. if (!IsReadableByteStreamController(stream._readableStreamController)) {
  7578. throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source');
  7579. }
  7580. ReadableStreamReaderGenericInitialize(this, stream);
  7581. this._readIntoRequests = new SimpleQueue();
  7582. }
  7583. Object.defineProperty(ReadableStreamBYOBReader.prototype, "closed", {
  7584. get: function () {
  7585. if (!IsReadableStreamBYOBReader(this)) {
  7586. return promiseRejectedWith(byobReaderBrandCheckException('closed'));
  7587. }
  7588. return this._closedPromise;
  7589. },
  7590. enumerable: false,
  7591. configurable: true
  7592. });
  7593. ReadableStreamBYOBReader.prototype.cancel = function (reason) {
  7594. if (reason === void 0) {
  7595. reason = undefined;
  7596. }
  7597. if (!IsReadableStreamBYOBReader(this)) {
  7598. return promiseRejectedWith(byobReaderBrandCheckException('cancel'));
  7599. }
  7600. if (this._ownerReadableStream === undefined) {
  7601. return promiseRejectedWith(readerLockException('cancel'));
  7602. }
  7603. return ReadableStreamReaderGenericCancel(this, reason);
  7604. };
  7605. ReadableStreamBYOBReader.prototype.read = function (view) {
  7606. if (!IsReadableStreamBYOBReader(this)) {
  7607. return promiseRejectedWith(byobReaderBrandCheckException('read'));
  7608. }
  7609. if (!ArrayBuffer.isView(view)) {
  7610. return promiseRejectedWith(new TypeError('view must be an array buffer view'));
  7611. }
  7612. if (view.byteLength === 0) {
  7613. return promiseRejectedWith(new TypeError('view must have non-zero byteLength'));
  7614. }
  7615. if (view.buffer.byteLength === 0) {
  7616. return promiseRejectedWith(new TypeError("view's buffer must have non-zero byteLength"));
  7617. }
  7618. if (this._ownerReadableStream === undefined) {
  7619. return promiseRejectedWith(readerLockException('read from'));
  7620. }
  7621. var resolvePromise;
  7622. var rejectPromise;
  7623. var promise = newPromise(function (resolve, reject) {
  7624. resolvePromise = resolve;
  7625. rejectPromise = reject;
  7626. });
  7627. var readIntoRequest = {
  7628. _chunkSteps: function (chunk) {
  7629. return resolvePromise({
  7630. value: chunk,
  7631. done: false
  7632. });
  7633. },
  7634. _closeSteps: function (chunk) {
  7635. return resolvePromise({
  7636. value: chunk,
  7637. done: true
  7638. });
  7639. },
  7640. _errorSteps: function (e) {
  7641. return rejectPromise(e);
  7642. }
  7643. };
  7644. ReadableStreamBYOBReaderRead(this, view, readIntoRequest);
  7645. return promise;
  7646. };
  7647. ReadableStreamBYOBReader.prototype.releaseLock = function () {
  7648. if (!IsReadableStreamBYOBReader(this)) {
  7649. throw byobReaderBrandCheckException('releaseLock');
  7650. }
  7651. if (this._ownerReadableStream === undefined) {
  7652. return;
  7653. }
  7654. if (this._readIntoRequests.length > 0) {
  7655. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  7656. }
  7657. ReadableStreamReaderGenericRelease(this);
  7658. };
  7659. return ReadableStreamBYOBReader;
  7660. }();
  7661. Object.defineProperties(ReadableStreamBYOBReader.prototype, {
  7662. cancel: { enumerable: true },
  7663. read: { enumerable: true },
  7664. releaseLock: { enumerable: true },
  7665. closed: { enumerable: true }
  7666. });
  7667. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  7668. Object.defineProperty(ReadableStreamBYOBReader.prototype, SymbolPolyfill.toStringTag, {
  7669. value: 'ReadableStreamBYOBReader',
  7670. configurable: true
  7671. });
  7672. }
  7673. function IsReadableStreamBYOBReader(x) {
  7674. if (!typeIsObject(x)) {
  7675. return false;
  7676. }
  7677. if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
  7678. return false;
  7679. }
  7680. return true;
  7681. }
  7682. function ReadableStreamBYOBReaderRead(reader, view, readIntoRequest) {
  7683. var stream = reader._ownerReadableStream;
  7684. stream._disturbed = true;
  7685. if (stream._state === 'errored') {
  7686. readIntoRequest._errorSteps(stream._storedError);
  7687. } else {
  7688. ReadableByteStreamControllerPullInto(stream._readableStreamController, view, readIntoRequest);
  7689. }
  7690. }
  7691. function byobReaderBrandCheckException(name) {
  7692. return new TypeError("ReadableStreamBYOBReader.prototype." + name + " can only be used on a ReadableStreamBYOBReader");
  7693. }
  7694. function ExtractHighWaterMark(strategy, defaultHWM) {
  7695. var highWaterMark = strategy.highWaterMark;
  7696. if (highWaterMark === undefined) {
  7697. return defaultHWM;
  7698. }
  7699. if (NumberIsNaN(highWaterMark) || highWaterMark < 0) {
  7700. throw new RangeError('Invalid highWaterMark');
  7701. }
  7702. return highWaterMark;
  7703. }
  7704. function ExtractSizeAlgorithm(strategy) {
  7705. var size = strategy.size;
  7706. if (!size) {
  7707. return function () {
  7708. return 1;
  7709. };
  7710. }
  7711. return size;
  7712. }
  7713. function convertQueuingStrategy(init, context) {
  7714. assertDictionary(init, context);
  7715. var highWaterMark = init === null || init === void 0 ? void 0 : init.highWaterMark;
  7716. var size = init === null || init === void 0 ? void 0 : init.size;
  7717. return {
  7718. highWaterMark: highWaterMark === undefined ? undefined : convertUnrestrictedDouble(highWaterMark),
  7719. size: size === undefined ? undefined : convertQueuingStrategySize(size, context + " has member 'size' that")
  7720. };
  7721. }
  7722. function convertQueuingStrategySize(fn, context) {
  7723. assertFunction(fn, context);
  7724. return function (chunk) {
  7725. return convertUnrestrictedDouble(fn(chunk));
  7726. };
  7727. }
  7728. function convertUnderlyingSink(original, context) {
  7729. assertDictionary(original, context);
  7730. var abort = original === null || original === void 0 ? void 0 : original.abort;
  7731. var close = original === null || original === void 0 ? void 0 : original.close;
  7732. var start = original === null || original === void 0 ? void 0 : original.start;
  7733. var type = original === null || original === void 0 ? void 0 : original.type;
  7734. var write = original === null || original === void 0 ? void 0 : original.write;
  7735. return {
  7736. abort: abort === undefined ? undefined : convertUnderlyingSinkAbortCallback(abort, original, context + " has member 'abort' that"),
  7737. close: close === undefined ? undefined : convertUnderlyingSinkCloseCallback(close, original, context + " has member 'close' that"),
  7738. start: start === undefined ? undefined : convertUnderlyingSinkStartCallback(start, original, context + " has member 'start' that"),
  7739. write: write === undefined ? undefined : convertUnderlyingSinkWriteCallback(write, original, context + " has member 'write' that"),
  7740. type: type
  7741. };
  7742. }
  7743. function convertUnderlyingSinkAbortCallback(fn, original, context) {
  7744. assertFunction(fn, context);
  7745. return function (reason) {
  7746. return promiseCall(fn, original, [reason]);
  7747. };
  7748. }
  7749. function convertUnderlyingSinkCloseCallback(fn, original, context) {
  7750. assertFunction(fn, context);
  7751. return function () {
  7752. return promiseCall(fn, original, []);
  7753. };
  7754. }
  7755. function convertUnderlyingSinkStartCallback(fn, original, context) {
  7756. assertFunction(fn, context);
  7757. return function (controller) {
  7758. return reflectCall(fn, original, [controller]);
  7759. };
  7760. }
  7761. function convertUnderlyingSinkWriteCallback(fn, original, context) {
  7762. assertFunction(fn, context);
  7763. return function (chunk, controller) {
  7764. return promiseCall(fn, original, [
  7765. chunk,
  7766. controller
  7767. ]);
  7768. };
  7769. }
  7770. function assertWritableStream(x, context) {
  7771. if (!IsWritableStream(x)) {
  7772. throw new TypeError(context + " is not a WritableStream.");
  7773. }
  7774. }
  7775. var WritableStream = function () {
  7776. function WritableStream(rawUnderlyingSink, rawStrategy) {
  7777. if (rawUnderlyingSink === void 0) {
  7778. rawUnderlyingSink = {};
  7779. }
  7780. if (rawStrategy === void 0) {
  7781. rawStrategy = {};
  7782. }
  7783. if (rawUnderlyingSink === undefined) {
  7784. rawUnderlyingSink = null;
  7785. } else {
  7786. assertObject(rawUnderlyingSink, 'First parameter');
  7787. }
  7788. var strategy = convertQueuingStrategy(rawStrategy, 'Second parameter');
  7789. var underlyingSink = convertUnderlyingSink(rawUnderlyingSink, 'First parameter');
  7790. InitializeWritableStream(this);
  7791. var type = underlyingSink.type;
  7792. if (type !== undefined) {
  7793. throw new RangeError('Invalid type is specified');
  7794. }
  7795. var sizeAlgorithm = ExtractSizeAlgorithm(strategy);
  7796. var highWaterMark = ExtractHighWaterMark(strategy, 1);
  7797. SetUpWritableStreamDefaultControllerFromUnderlyingSink(this, underlyingSink, highWaterMark, sizeAlgorithm);
  7798. }
  7799. Object.defineProperty(WritableStream.prototype, "locked", {
  7800. get: function () {
  7801. if (!IsWritableStream(this)) {
  7802. throw streamBrandCheckException('locked');
  7803. }
  7804. return IsWritableStreamLocked(this);
  7805. },
  7806. enumerable: false,
  7807. configurable: true
  7808. });
  7809. WritableStream.prototype.abort = function (reason) {
  7810. if (reason === void 0) {
  7811. reason = undefined;
  7812. }
  7813. if (!IsWritableStream(this)) {
  7814. return promiseRejectedWith(streamBrandCheckException('abort'));
  7815. }
  7816. if (IsWritableStreamLocked(this)) {
  7817. return promiseRejectedWith(new TypeError('Cannot abort a stream that already has a writer'));
  7818. }
  7819. return WritableStreamAbort(this, reason);
  7820. };
  7821. WritableStream.prototype.close = function () {
  7822. if (!IsWritableStream(this)) {
  7823. return promiseRejectedWith(streamBrandCheckException('close'));
  7824. }
  7825. if (IsWritableStreamLocked(this)) {
  7826. return promiseRejectedWith(new TypeError('Cannot close a stream that already has a writer'));
  7827. }
  7828. if (WritableStreamCloseQueuedOrInFlight(this)) {
  7829. return promiseRejectedWith(new TypeError('Cannot close an already-closing stream'));
  7830. }
  7831. return WritableStreamClose(this);
  7832. };
  7833. WritableStream.prototype.getWriter = function () {
  7834. if (!IsWritableStream(this)) {
  7835. throw streamBrandCheckException('getWriter');
  7836. }
  7837. return AcquireWritableStreamDefaultWriter(this);
  7838. };
  7839. return WritableStream;
  7840. }();
  7841. Object.defineProperties(WritableStream.prototype, {
  7842. abort: { enumerable: true },
  7843. close: { enumerable: true },
  7844. getWriter: { enumerable: true },
  7845. locked: { enumerable: true }
  7846. });
  7847. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  7848. Object.defineProperty(WritableStream.prototype, SymbolPolyfill.toStringTag, {
  7849. value: 'WritableStream',
  7850. configurable: true
  7851. });
  7852. }
  7853. function AcquireWritableStreamDefaultWriter(stream) {
  7854. return new WritableStreamDefaultWriter(stream);
  7855. }
  7856. function CreateWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm) {
  7857. if (highWaterMark === void 0) {
  7858. highWaterMark = 1;
  7859. }
  7860. if (sizeAlgorithm === void 0) {
  7861. sizeAlgorithm = function () {
  7862. return 1;
  7863. };
  7864. }
  7865. var stream = Object.create(WritableStream.prototype);
  7866. InitializeWritableStream(stream);
  7867. var controller = Object.create(WritableStreamDefaultController.prototype);
  7868. SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
  7869. return stream;
  7870. }
  7871. function InitializeWritableStream(stream) {
  7872. stream._state = 'writable';
  7873. stream._storedError = undefined;
  7874. stream._writer = undefined;
  7875. stream._writableStreamController = undefined;
  7876. stream._writeRequests = new SimpleQueue();
  7877. stream._inFlightWriteRequest = undefined;
  7878. stream._closeRequest = undefined;
  7879. stream._inFlightCloseRequest = undefined;
  7880. stream._pendingAbortRequest = undefined;
  7881. stream._backpressure = false;
  7882. }
  7883. function IsWritableStream(x) {
  7884. if (!typeIsObject(x)) {
  7885. return false;
  7886. }
  7887. if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
  7888. return false;
  7889. }
  7890. return true;
  7891. }
  7892. function IsWritableStreamLocked(stream) {
  7893. if (stream._writer === undefined) {
  7894. return false;
  7895. }
  7896. return true;
  7897. }
  7898. function WritableStreamAbort(stream, reason) {
  7899. var state = stream._state;
  7900. if (state === 'closed' || state === 'errored') {
  7901. return promiseResolvedWith(undefined);
  7902. }
  7903. if (stream._pendingAbortRequest !== undefined) {
  7904. return stream._pendingAbortRequest._promise;
  7905. }
  7906. var wasAlreadyErroring = false;
  7907. if (state === 'erroring') {
  7908. wasAlreadyErroring = true;
  7909. reason = undefined;
  7910. }
  7911. var promise = newPromise(function (resolve, reject) {
  7912. stream._pendingAbortRequest = {
  7913. _promise: undefined,
  7914. _resolve: resolve,
  7915. _reject: reject,
  7916. _reason: reason,
  7917. _wasAlreadyErroring: wasAlreadyErroring
  7918. };
  7919. });
  7920. stream._pendingAbortRequest._promise = promise;
  7921. if (!wasAlreadyErroring) {
  7922. WritableStreamStartErroring(stream, reason);
  7923. }
  7924. return promise;
  7925. }
  7926. function WritableStreamClose(stream) {
  7927. var state = stream._state;
  7928. if (state === 'closed' || state === 'errored') {
  7929. return promiseRejectedWith(new TypeError("The stream (in " + state + " state) is not in the writable state and cannot be closed"));
  7930. }
  7931. var promise = newPromise(function (resolve, reject) {
  7932. var closeRequest = {
  7933. _resolve: resolve,
  7934. _reject: reject
  7935. };
  7936. stream._closeRequest = closeRequest;
  7937. });
  7938. var writer = stream._writer;
  7939. if (writer !== undefined && stream._backpressure && state === 'writable') {
  7940. defaultWriterReadyPromiseResolve(writer);
  7941. }
  7942. WritableStreamDefaultControllerClose(stream._writableStreamController);
  7943. return promise;
  7944. }
  7945. function WritableStreamAddWriteRequest(stream) {
  7946. var promise = newPromise(function (resolve, reject) {
  7947. var writeRequest = {
  7948. _resolve: resolve,
  7949. _reject: reject
  7950. };
  7951. stream._writeRequests.push(writeRequest);
  7952. });
  7953. return promise;
  7954. }
  7955. function WritableStreamDealWithRejection(stream, error) {
  7956. var state = stream._state;
  7957. if (state === 'writable') {
  7958. WritableStreamStartErroring(stream, error);
  7959. return;
  7960. }
  7961. WritableStreamFinishErroring(stream);
  7962. }
  7963. function WritableStreamStartErroring(stream, reason) {
  7964. var controller = stream._writableStreamController;
  7965. stream._state = 'erroring';
  7966. stream._storedError = reason;
  7967. var writer = stream._writer;
  7968. if (writer !== undefined) {
  7969. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);
  7970. }
  7971. if (!WritableStreamHasOperationMarkedInFlight(stream) && controller._started) {
  7972. WritableStreamFinishErroring(stream);
  7973. }
  7974. }
  7975. function WritableStreamFinishErroring(stream) {
  7976. stream._state = 'errored';
  7977. stream._writableStreamController[ErrorSteps]();
  7978. var storedError = stream._storedError;
  7979. stream._writeRequests.forEach(function (writeRequest) {
  7980. writeRequest._reject(storedError);
  7981. });
  7982. stream._writeRequests = new SimpleQueue();
  7983. if (stream._pendingAbortRequest === undefined) {
  7984. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7985. return;
  7986. }
  7987. var abortRequest = stream._pendingAbortRequest;
  7988. stream._pendingAbortRequest = undefined;
  7989. if (abortRequest._wasAlreadyErroring) {
  7990. abortRequest._reject(storedError);
  7991. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7992. return;
  7993. }
  7994. var promise = stream._writableStreamController[AbortSteps](abortRequest._reason);
  7995. uponPromise(promise, function () {
  7996. abortRequest._resolve();
  7997. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7998. }, function (reason) {
  7999. abortRequest._reject(reason);
  8000. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  8001. });
  8002. }
  8003. function WritableStreamFinishInFlightWrite(stream) {
  8004. stream._inFlightWriteRequest._resolve(undefined);
  8005. stream._inFlightWriteRequest = undefined;
  8006. }
  8007. function WritableStreamFinishInFlightWriteWithError(stream, error) {
  8008. stream._inFlightWriteRequest._reject(error);
  8009. stream._inFlightWriteRequest = undefined;
  8010. WritableStreamDealWithRejection(stream, error);
  8011. }
  8012. function WritableStreamFinishInFlightClose(stream) {
  8013. stream._inFlightCloseRequest._resolve(undefined);
  8014. stream._inFlightCloseRequest = undefined;
  8015. var state = stream._state;
  8016. if (state === 'erroring') {
  8017. stream._storedError = undefined;
  8018. if (stream._pendingAbortRequest !== undefined) {
  8019. stream._pendingAbortRequest._resolve();
  8020. stream._pendingAbortRequest = undefined;
  8021. }
  8022. }
  8023. stream._state = 'closed';
  8024. var writer = stream._writer;
  8025. if (writer !== undefined) {
  8026. defaultWriterClosedPromiseResolve(writer);
  8027. }
  8028. }
  8029. function WritableStreamFinishInFlightCloseWithError(stream, error) {
  8030. stream._inFlightCloseRequest._reject(error);
  8031. stream._inFlightCloseRequest = undefined;
  8032. if (stream._pendingAbortRequest !== undefined) {
  8033. stream._pendingAbortRequest._reject(error);
  8034. stream._pendingAbortRequest = undefined;
  8035. }
  8036. WritableStreamDealWithRejection(stream, error);
  8037. }
  8038. function WritableStreamCloseQueuedOrInFlight(stream) {
  8039. if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) {
  8040. return false;
  8041. }
  8042. return true;
  8043. }
  8044. function WritableStreamHasOperationMarkedInFlight(stream) {
  8045. if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) {
  8046. return false;
  8047. }
  8048. return true;
  8049. }
  8050. function WritableStreamMarkCloseRequestInFlight(stream) {
  8051. stream._inFlightCloseRequest = stream._closeRequest;
  8052. stream._closeRequest = undefined;
  8053. }
  8054. function WritableStreamMarkFirstWriteRequestInFlight(stream) {
  8055. stream._inFlightWriteRequest = stream._writeRequests.shift();
  8056. }
  8057. function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) {
  8058. if (stream._closeRequest !== undefined) {
  8059. stream._closeRequest._reject(stream._storedError);
  8060. stream._closeRequest = undefined;
  8061. }
  8062. var writer = stream._writer;
  8063. if (writer !== undefined) {
  8064. defaultWriterClosedPromiseReject(writer, stream._storedError);
  8065. }
  8066. }
  8067. function WritableStreamUpdateBackpressure(stream, backpressure) {
  8068. var writer = stream._writer;
  8069. if (writer !== undefined && backpressure !== stream._backpressure) {
  8070. if (backpressure) {
  8071. defaultWriterReadyPromiseReset(writer);
  8072. } else {
  8073. defaultWriterReadyPromiseResolve(writer);
  8074. }
  8075. }
  8076. stream._backpressure = backpressure;
  8077. }
  8078. var WritableStreamDefaultWriter = function () {
  8079. function WritableStreamDefaultWriter(stream) {
  8080. assertRequiredArgument(stream, 1, 'WritableStreamDefaultWriter');
  8081. assertWritableStream(stream, 'First parameter');
  8082. if (IsWritableStreamLocked(stream)) {
  8083. throw new TypeError('This stream has already been locked for exclusive writing by another writer');
  8084. }
  8085. this._ownerWritableStream = stream;
  8086. stream._writer = this;
  8087. var state = stream._state;
  8088. if (state === 'writable') {
  8089. if (!WritableStreamCloseQueuedOrInFlight(stream) && stream._backpressure) {
  8090. defaultWriterReadyPromiseInitialize(this);
  8091. } else {
  8092. defaultWriterReadyPromiseInitializeAsResolved(this);
  8093. }
  8094. defaultWriterClosedPromiseInitialize(this);
  8095. } else if (state === 'erroring') {
  8096. defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError);
  8097. defaultWriterClosedPromiseInitialize(this);
  8098. } else if (state === 'closed') {
  8099. defaultWriterReadyPromiseInitializeAsResolved(this);
  8100. defaultWriterClosedPromiseInitializeAsResolved(this);
  8101. } else {
  8102. var storedError = stream._storedError;
  8103. defaultWriterReadyPromiseInitializeAsRejected(this, storedError);
  8104. defaultWriterClosedPromiseInitializeAsRejected(this, storedError);
  8105. }
  8106. }
  8107. Object.defineProperty(WritableStreamDefaultWriter.prototype, "closed", {
  8108. get: function () {
  8109. if (!IsWritableStreamDefaultWriter(this)) {
  8110. return promiseRejectedWith(defaultWriterBrandCheckException('closed'));
  8111. }
  8112. return this._closedPromise;
  8113. },
  8114. enumerable: false,
  8115. configurable: true
  8116. });
  8117. Object.defineProperty(WritableStreamDefaultWriter.prototype, "desiredSize", {
  8118. get: function () {
  8119. if (!IsWritableStreamDefaultWriter(this)) {
  8120. throw defaultWriterBrandCheckException('desiredSize');
  8121. }
  8122. if (this._ownerWritableStream === undefined) {
  8123. throw defaultWriterLockException('desiredSize');
  8124. }
  8125. return WritableStreamDefaultWriterGetDesiredSize(this);
  8126. },
  8127. enumerable: false,
  8128. configurable: true
  8129. });
  8130. Object.defineProperty(WritableStreamDefaultWriter.prototype, "ready", {
  8131. get: function () {
  8132. if (!IsWritableStreamDefaultWriter(this)) {
  8133. return promiseRejectedWith(defaultWriterBrandCheckException('ready'));
  8134. }
  8135. return this._readyPromise;
  8136. },
  8137. enumerable: false,
  8138. configurable: true
  8139. });
  8140. WritableStreamDefaultWriter.prototype.abort = function (reason) {
  8141. if (reason === void 0) {
  8142. reason = undefined;
  8143. }
  8144. if (!IsWritableStreamDefaultWriter(this)) {
  8145. return promiseRejectedWith(defaultWriterBrandCheckException('abort'));
  8146. }
  8147. if (this._ownerWritableStream === undefined) {
  8148. return promiseRejectedWith(defaultWriterLockException('abort'));
  8149. }
  8150. return WritableStreamDefaultWriterAbort(this, reason);
  8151. };
  8152. WritableStreamDefaultWriter.prototype.close = function () {
  8153. if (!IsWritableStreamDefaultWriter(this)) {
  8154. return promiseRejectedWith(defaultWriterBrandCheckException('close'));
  8155. }
  8156. var stream = this._ownerWritableStream;
  8157. if (stream === undefined) {
  8158. return promiseRejectedWith(defaultWriterLockException('close'));
  8159. }
  8160. if (WritableStreamCloseQueuedOrInFlight(stream)) {
  8161. return promiseRejectedWith(new TypeError('Cannot close an already-closing stream'));
  8162. }
  8163. return WritableStreamDefaultWriterClose(this);
  8164. };
  8165. WritableStreamDefaultWriter.prototype.releaseLock = function () {
  8166. if (!IsWritableStreamDefaultWriter(this)) {
  8167. throw defaultWriterBrandCheckException('releaseLock');
  8168. }
  8169. var stream = this._ownerWritableStream;
  8170. if (stream === undefined) {
  8171. return;
  8172. }
  8173. WritableStreamDefaultWriterRelease(this);
  8174. };
  8175. WritableStreamDefaultWriter.prototype.write = function (chunk) {
  8176. if (chunk === void 0) {
  8177. chunk = undefined;
  8178. }
  8179. if (!IsWritableStreamDefaultWriter(this)) {
  8180. return promiseRejectedWith(defaultWriterBrandCheckException('write'));
  8181. }
  8182. if (this._ownerWritableStream === undefined) {
  8183. return promiseRejectedWith(defaultWriterLockException('write to'));
  8184. }
  8185. return WritableStreamDefaultWriterWrite(this, chunk);
  8186. };
  8187. return WritableStreamDefaultWriter;
  8188. }();
  8189. Object.defineProperties(WritableStreamDefaultWriter.prototype, {
  8190. abort: { enumerable: true },
  8191. close: { enumerable: true },
  8192. releaseLock: { enumerable: true },
  8193. write: { enumerable: true },
  8194. closed: { enumerable: true },
  8195. desiredSize: { enumerable: true },
  8196. ready: { enumerable: true }
  8197. });
  8198. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  8199. Object.defineProperty(WritableStreamDefaultWriter.prototype, SymbolPolyfill.toStringTag, {
  8200. value: 'WritableStreamDefaultWriter',
  8201. configurable: true
  8202. });
  8203. }
  8204. function IsWritableStreamDefaultWriter(x) {
  8205. if (!typeIsObject(x)) {
  8206. return false;
  8207. }
  8208. if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
  8209. return false;
  8210. }
  8211. return true;
  8212. }
  8213. function WritableStreamDefaultWriterAbort(writer, reason) {
  8214. var stream = writer._ownerWritableStream;
  8215. return WritableStreamAbort(stream, reason);
  8216. }
  8217. function WritableStreamDefaultWriterClose(writer) {
  8218. var stream = writer._ownerWritableStream;
  8219. return WritableStreamClose(stream);
  8220. }
  8221. function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
  8222. var stream = writer._ownerWritableStream;
  8223. var state = stream._state;
  8224. if (WritableStreamCloseQueuedOrInFlight(stream) || state === 'closed') {
  8225. return promiseResolvedWith(undefined);
  8226. }
  8227. if (state === 'errored') {
  8228. return promiseRejectedWith(stream._storedError);
  8229. }
  8230. return WritableStreamDefaultWriterClose(writer);
  8231. }
  8232. function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
  8233. if (writer._closedPromiseState === 'pending') {
  8234. defaultWriterClosedPromiseReject(writer, error);
  8235. } else {
  8236. defaultWriterClosedPromiseResetToRejected(writer, error);
  8237. }
  8238. }
  8239. function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
  8240. if (writer._readyPromiseState === 'pending') {
  8241. defaultWriterReadyPromiseReject(writer, error);
  8242. } else {
  8243. defaultWriterReadyPromiseResetToRejected(writer, error);
  8244. }
  8245. }
  8246. function WritableStreamDefaultWriterGetDesiredSize(writer) {
  8247. var stream = writer._ownerWritableStream;
  8248. var state = stream._state;
  8249. if (state === 'errored' || state === 'erroring') {
  8250. return null;
  8251. }
  8252. if (state === 'closed') {
  8253. return 0;
  8254. }
  8255. return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController);
  8256. }
  8257. function WritableStreamDefaultWriterRelease(writer) {
  8258. var stream = writer._ownerWritableStream;
  8259. var releasedError = new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");
  8260. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
  8261. WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
  8262. stream._writer = undefined;
  8263. writer._ownerWritableStream = undefined;
  8264. }
  8265. function WritableStreamDefaultWriterWrite(writer, chunk) {
  8266. var stream = writer._ownerWritableStream;
  8267. var controller = stream._writableStreamController;
  8268. var chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
  8269. if (stream !== writer._ownerWritableStream) {
  8270. return promiseRejectedWith(defaultWriterLockException('write to'));
  8271. }
  8272. var state = stream._state;
  8273. if (state === 'errored') {
  8274. return promiseRejectedWith(stream._storedError);
  8275. }
  8276. if (WritableStreamCloseQueuedOrInFlight(stream) || state === 'closed') {
  8277. return promiseRejectedWith(new TypeError('The stream is closing or closed and cannot be written to'));
  8278. }
  8279. if (state === 'erroring') {
  8280. return promiseRejectedWith(stream._storedError);
  8281. }
  8282. var promise = WritableStreamAddWriteRequest(stream);
  8283. WritableStreamDefaultControllerWrite(controller, chunk, chunkSize);
  8284. return promise;
  8285. }
  8286. var closeSentinel = {};
  8287. var WritableStreamDefaultController = function () {
  8288. function WritableStreamDefaultController() {
  8289. throw new TypeError('Illegal constructor');
  8290. }
  8291. WritableStreamDefaultController.prototype.error = function (e) {
  8292. if (e === void 0) {
  8293. e = undefined;
  8294. }
  8295. if (!IsWritableStreamDefaultController(this)) {
  8296. throw new TypeError('WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController');
  8297. }
  8298. var state = this._controlledWritableStream._state;
  8299. if (state !== 'writable') {
  8300. return;
  8301. }
  8302. WritableStreamDefaultControllerError(this, e);
  8303. };
  8304. WritableStreamDefaultController.prototype[AbortSteps] = function (reason) {
  8305. var result = this._abortAlgorithm(reason);
  8306. WritableStreamDefaultControllerClearAlgorithms(this);
  8307. return result;
  8308. };
  8309. WritableStreamDefaultController.prototype[ErrorSteps] = function () {
  8310. ResetQueue(this);
  8311. };
  8312. return WritableStreamDefaultController;
  8313. }();
  8314. Object.defineProperties(WritableStreamDefaultController.prototype, { error: { enumerable: true } });
  8315. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  8316. Object.defineProperty(WritableStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
  8317. value: 'WritableStreamDefaultController',
  8318. configurable: true
  8319. });
  8320. }
  8321. function IsWritableStreamDefaultController(x) {
  8322. if (!typeIsObject(x)) {
  8323. return false;
  8324. }
  8325. if (!Object.prototype.hasOwnProperty.call(x, '_controlledWritableStream')) {
  8326. return false;
  8327. }
  8328. return true;
  8329. }
  8330. function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm) {
  8331. controller._controlledWritableStream = stream;
  8332. stream._writableStreamController = controller;
  8333. controller._queue = undefined;
  8334. controller._queueTotalSize = undefined;
  8335. ResetQueue(controller);
  8336. controller._started = false;
  8337. controller._strategySizeAlgorithm = sizeAlgorithm;
  8338. controller._strategyHWM = highWaterMark;
  8339. controller._writeAlgorithm = writeAlgorithm;
  8340. controller._closeAlgorithm = closeAlgorithm;
  8341. controller._abortAlgorithm = abortAlgorithm;
  8342. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  8343. WritableStreamUpdateBackpressure(stream, backpressure);
  8344. var startResult = startAlgorithm();
  8345. var startPromise = promiseResolvedWith(startResult);
  8346. uponPromise(startPromise, function () {
  8347. controller._started = true;
  8348. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  8349. }, function (r) {
  8350. controller._started = true;
  8351. WritableStreamDealWithRejection(stream, r);
  8352. });
  8353. }
  8354. function SetUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, highWaterMark, sizeAlgorithm) {
  8355. var controller = Object.create(WritableStreamDefaultController.prototype);
  8356. var startAlgorithm = function () {
  8357. return undefined;
  8358. };
  8359. var writeAlgorithm = function () {
  8360. return promiseResolvedWith(undefined);
  8361. };
  8362. var closeAlgorithm = function () {
  8363. return promiseResolvedWith(undefined);
  8364. };
  8365. var abortAlgorithm = function () {
  8366. return promiseResolvedWith(undefined);
  8367. };
  8368. if (underlyingSink.start !== undefined) {
  8369. startAlgorithm = function () {
  8370. return underlyingSink.start(controller);
  8371. };
  8372. }
  8373. if (underlyingSink.write !== undefined) {
  8374. writeAlgorithm = function (chunk) {
  8375. return underlyingSink.write(chunk, controller);
  8376. };
  8377. }
  8378. if (underlyingSink.close !== undefined) {
  8379. closeAlgorithm = function () {
  8380. return underlyingSink.close();
  8381. };
  8382. }
  8383. if (underlyingSink.abort !== undefined) {
  8384. abortAlgorithm = function (reason) {
  8385. return underlyingSink.abort(reason);
  8386. };
  8387. }
  8388. SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
  8389. }
  8390. function WritableStreamDefaultControllerClearAlgorithms(controller) {
  8391. controller._writeAlgorithm = undefined;
  8392. controller._closeAlgorithm = undefined;
  8393. controller._abortAlgorithm = undefined;
  8394. controller._strategySizeAlgorithm = undefined;
  8395. }
  8396. function WritableStreamDefaultControllerClose(controller) {
  8397. EnqueueValueWithSize(controller, closeSentinel, 0);
  8398. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  8399. }
  8400. function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
  8401. try {
  8402. return controller._strategySizeAlgorithm(chunk);
  8403. } catch (chunkSizeE) {
  8404. WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  8405. return 1;
  8406. }
  8407. }
  8408. function WritableStreamDefaultControllerGetDesiredSize(controller) {
  8409. return controller._strategyHWM - controller._queueTotalSize;
  8410. }
  8411. function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
  8412. try {
  8413. EnqueueValueWithSize(controller, chunk, chunkSize);
  8414. } catch (enqueueE) {
  8415. WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  8416. return;
  8417. }
  8418. var stream = controller._controlledWritableStream;
  8419. if (!WritableStreamCloseQueuedOrInFlight(stream) && stream._state === 'writable') {
  8420. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  8421. WritableStreamUpdateBackpressure(stream, backpressure);
  8422. }
  8423. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  8424. }
  8425. function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) {
  8426. var stream = controller._controlledWritableStream;
  8427. if (!controller._started) {
  8428. return;
  8429. }
  8430. if (stream._inFlightWriteRequest !== undefined) {
  8431. return;
  8432. }
  8433. var state = stream._state;
  8434. if (state === 'erroring') {
  8435. WritableStreamFinishErroring(stream);
  8436. return;
  8437. }
  8438. if (controller._queue.length === 0) {
  8439. return;
  8440. }
  8441. var value = PeekQueueValue(controller);
  8442. if (value === closeSentinel) {
  8443. WritableStreamDefaultControllerProcessClose(controller);
  8444. } else {
  8445. WritableStreamDefaultControllerProcessWrite(controller, value);
  8446. }
  8447. }
  8448. function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
  8449. if (controller._controlledWritableStream._state === 'writable') {
  8450. WritableStreamDefaultControllerError(controller, error);
  8451. }
  8452. }
  8453. function WritableStreamDefaultControllerProcessClose(controller) {
  8454. var stream = controller._controlledWritableStream;
  8455. WritableStreamMarkCloseRequestInFlight(stream);
  8456. DequeueValue(controller);
  8457. var sinkClosePromise = controller._closeAlgorithm();
  8458. WritableStreamDefaultControllerClearAlgorithms(controller);
  8459. uponPromise(sinkClosePromise, function () {
  8460. WritableStreamFinishInFlightClose(stream);
  8461. }, function (reason) {
  8462. WritableStreamFinishInFlightCloseWithError(stream, reason);
  8463. });
  8464. }
  8465. function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
  8466. var stream = controller._controlledWritableStream;
  8467. WritableStreamMarkFirstWriteRequestInFlight(stream);
  8468. var sinkWritePromise = controller._writeAlgorithm(chunk);
  8469. uponPromise(sinkWritePromise, function () {
  8470. WritableStreamFinishInFlightWrite(stream);
  8471. var state = stream._state;
  8472. DequeueValue(controller);
  8473. if (!WritableStreamCloseQueuedOrInFlight(stream) && state === 'writable') {
  8474. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  8475. WritableStreamUpdateBackpressure(stream, backpressure);
  8476. }
  8477. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  8478. }, function (reason) {
  8479. if (stream._state === 'writable') {
  8480. WritableStreamDefaultControllerClearAlgorithms(controller);
  8481. }
  8482. WritableStreamFinishInFlightWriteWithError(stream, reason);
  8483. });
  8484. }
  8485. function WritableStreamDefaultControllerGetBackpressure(controller) {
  8486. var desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
  8487. return desiredSize <= 0;
  8488. }
  8489. function WritableStreamDefaultControllerError(controller, error) {
  8490. var stream = controller._controlledWritableStream;
  8491. WritableStreamDefaultControllerClearAlgorithms(controller);
  8492. WritableStreamStartErroring(stream, error);
  8493. }
  8494. function streamBrandCheckException(name) {
  8495. return new TypeError("WritableStream.prototype." + name + " can only be used on a WritableStream");
  8496. }
  8497. function defaultWriterBrandCheckException(name) {
  8498. return new TypeError("WritableStreamDefaultWriter.prototype." + name + " can only be used on a WritableStreamDefaultWriter");
  8499. }
  8500. function defaultWriterLockException(name) {
  8501. return new TypeError('Cannot ' + name + ' a stream using a released writer');
  8502. }
  8503. function defaultWriterClosedPromiseInitialize(writer) {
  8504. writer._closedPromise = newPromise(function (resolve, reject) {
  8505. writer._closedPromise_resolve = resolve;
  8506. writer._closedPromise_reject = reject;
  8507. writer._closedPromiseState = 'pending';
  8508. });
  8509. }
  8510. function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) {
  8511. defaultWriterClosedPromiseInitialize(writer);
  8512. defaultWriterClosedPromiseReject(writer, reason);
  8513. }
  8514. function defaultWriterClosedPromiseInitializeAsResolved(writer) {
  8515. defaultWriterClosedPromiseInitialize(writer);
  8516. defaultWriterClosedPromiseResolve(writer);
  8517. }
  8518. function defaultWriterClosedPromiseReject(writer, reason) {
  8519. if (writer._closedPromise_reject === undefined) {
  8520. return;
  8521. }
  8522. setPromiseIsHandledToTrue(writer._closedPromise);
  8523. writer._closedPromise_reject(reason);
  8524. writer._closedPromise_resolve = undefined;
  8525. writer._closedPromise_reject = undefined;
  8526. writer._closedPromiseState = 'rejected';
  8527. }
  8528. function defaultWriterClosedPromiseResetToRejected(writer, reason) {
  8529. defaultWriterClosedPromiseInitializeAsRejected(writer, reason);
  8530. }
  8531. function defaultWriterClosedPromiseResolve(writer) {
  8532. if (writer._closedPromise_resolve === undefined) {
  8533. return;
  8534. }
  8535. writer._closedPromise_resolve(undefined);
  8536. writer._closedPromise_resolve = undefined;
  8537. writer._closedPromise_reject = undefined;
  8538. writer._closedPromiseState = 'resolved';
  8539. }
  8540. function defaultWriterReadyPromiseInitialize(writer) {
  8541. writer._readyPromise = newPromise(function (resolve, reject) {
  8542. writer._readyPromise_resolve = resolve;
  8543. writer._readyPromise_reject = reject;
  8544. });
  8545. writer._readyPromiseState = 'pending';
  8546. }
  8547. function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) {
  8548. defaultWriterReadyPromiseInitialize(writer);
  8549. defaultWriterReadyPromiseReject(writer, reason);
  8550. }
  8551. function defaultWriterReadyPromiseInitializeAsResolved(writer) {
  8552. defaultWriterReadyPromiseInitialize(writer);
  8553. defaultWriterReadyPromiseResolve(writer);
  8554. }
  8555. function defaultWriterReadyPromiseReject(writer, reason) {
  8556. if (writer._readyPromise_reject === undefined) {
  8557. return;
  8558. }
  8559. setPromiseIsHandledToTrue(writer._readyPromise);
  8560. writer._readyPromise_reject(reason);
  8561. writer._readyPromise_resolve = undefined;
  8562. writer._readyPromise_reject = undefined;
  8563. writer._readyPromiseState = 'rejected';
  8564. }
  8565. function defaultWriterReadyPromiseReset(writer) {
  8566. defaultWriterReadyPromiseInitialize(writer);
  8567. }
  8568. function defaultWriterReadyPromiseResetToRejected(writer, reason) {
  8569. defaultWriterReadyPromiseInitializeAsRejected(writer, reason);
  8570. }
  8571. function defaultWriterReadyPromiseResolve(writer) {
  8572. if (writer._readyPromise_resolve === undefined) {
  8573. return;
  8574. }
  8575. writer._readyPromise_resolve(undefined);
  8576. writer._readyPromise_resolve = undefined;
  8577. writer._readyPromise_reject = undefined;
  8578. writer._readyPromiseState = 'fulfilled';
  8579. }
  8580. function isAbortSignal(value) {
  8581. if (typeof value !== 'object' || value === null) {
  8582. return false;
  8583. }
  8584. try {
  8585. return typeof value.aborted === 'boolean';
  8586. } catch (_a) {
  8587. return false;
  8588. }
  8589. }
  8590. var NativeDOMException = typeof DOMException !== 'undefined' ? DOMException : undefined;
  8591. function isDOMExceptionConstructor(ctor) {
  8592. if (!(typeof ctor === 'function' || typeof ctor === 'object')) {
  8593. return false;
  8594. }
  8595. try {
  8596. new ctor();
  8597. return true;
  8598. } catch (_a) {
  8599. return false;
  8600. }
  8601. }
  8602. function createDOMExceptionPolyfill() {
  8603. var ctor = function DOMException(message, name) {
  8604. this.message = message || '';
  8605. this.name = name || 'Error';
  8606. if (Error.captureStackTrace) {
  8607. Error.captureStackTrace(this, this.constructor);
  8608. }
  8609. };
  8610. ctor.prototype = Object.create(Error.prototype);
  8611. Object.defineProperty(ctor.prototype, 'constructor', {
  8612. value: ctor,
  8613. writable: true,
  8614. configurable: true
  8615. });
  8616. return ctor;
  8617. }
  8618. var DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
  8619. function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
  8620. var reader = AcquireReadableStreamDefaultReader(source);
  8621. var writer = AcquireWritableStreamDefaultWriter(dest);
  8622. source._disturbed = true;
  8623. var shuttingDown = false;
  8624. var currentWrite = promiseResolvedWith(undefined);
  8625. return newPromise(function (resolve, reject) {
  8626. var abortAlgorithm;
  8627. if (signal !== undefined) {
  8628. abortAlgorithm = function () {
  8629. var error = new DOMException$1('Aborted', 'AbortError');
  8630. var actions = [];
  8631. if (!preventAbort) {
  8632. actions.push(function () {
  8633. if (dest._state === 'writable') {
  8634. return WritableStreamAbort(dest, error);
  8635. }
  8636. return promiseResolvedWith(undefined);
  8637. });
  8638. }
  8639. if (!preventCancel) {
  8640. actions.push(function () {
  8641. if (source._state === 'readable') {
  8642. return ReadableStreamCancel(source, error);
  8643. }
  8644. return promiseResolvedWith(undefined);
  8645. });
  8646. }
  8647. shutdownWithAction(function () {
  8648. return Promise.all(actions.map(function (action) {
  8649. return action();
  8650. }));
  8651. }, true, error);
  8652. };
  8653. if (signal.aborted) {
  8654. abortAlgorithm();
  8655. return;
  8656. }
  8657. signal.addEventListener('abort', abortAlgorithm);
  8658. }
  8659. function pipeLoop() {
  8660. return newPromise(function (resolveLoop, rejectLoop) {
  8661. function next(done) {
  8662. if (done) {
  8663. resolveLoop();
  8664. } else {
  8665. PerformPromiseThen(pipeStep(), next, rejectLoop);
  8666. }
  8667. }
  8668. next(false);
  8669. });
  8670. }
  8671. function pipeStep() {
  8672. if (shuttingDown) {
  8673. return promiseResolvedWith(true);
  8674. }
  8675. return PerformPromiseThen(writer._readyPromise, function () {
  8676. return newPromise(function (resolveRead, rejectRead) {
  8677. ReadableStreamDefaultReaderRead(reader, {
  8678. _chunkSteps: function (chunk) {
  8679. currentWrite = PerformPromiseThen(WritableStreamDefaultWriterWrite(writer, chunk), undefined, noop);
  8680. resolveRead(false);
  8681. },
  8682. _closeSteps: function () {
  8683. return resolveRead(true);
  8684. },
  8685. _errorSteps: rejectRead
  8686. });
  8687. });
  8688. });
  8689. }
  8690. isOrBecomesErrored(source, reader._closedPromise, function (storedError) {
  8691. if (!preventAbort) {
  8692. shutdownWithAction(function () {
  8693. return WritableStreamAbort(dest, storedError);
  8694. }, true, storedError);
  8695. } else {
  8696. shutdown(true, storedError);
  8697. }
  8698. });
  8699. isOrBecomesErrored(dest, writer._closedPromise, function (storedError) {
  8700. if (!preventCancel) {
  8701. shutdownWithAction(function () {
  8702. return ReadableStreamCancel(source, storedError);
  8703. }, true, storedError);
  8704. } else {
  8705. shutdown(true, storedError);
  8706. }
  8707. });
  8708. isOrBecomesClosed(source, reader._closedPromise, function () {
  8709. if (!preventClose) {
  8710. shutdownWithAction(function () {
  8711. return WritableStreamDefaultWriterCloseWithErrorPropagation(writer);
  8712. });
  8713. } else {
  8714. shutdown();
  8715. }
  8716. });
  8717. if (WritableStreamCloseQueuedOrInFlight(dest) || dest._state === 'closed') {
  8718. var destClosed_1 = new TypeError('the destination writable stream closed before all data could be piped to it');
  8719. if (!preventCancel) {
  8720. shutdownWithAction(function () {
  8721. return ReadableStreamCancel(source, destClosed_1);
  8722. }, true, destClosed_1);
  8723. } else {
  8724. shutdown(true, destClosed_1);
  8725. }
  8726. }
  8727. setPromiseIsHandledToTrue(pipeLoop());
  8728. function waitForWritesToFinish() {
  8729. var oldCurrentWrite = currentWrite;
  8730. return PerformPromiseThen(currentWrite, function () {
  8731. return oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined;
  8732. });
  8733. }
  8734. function isOrBecomesErrored(stream, promise, action) {
  8735. if (stream._state === 'errored') {
  8736. action(stream._storedError);
  8737. } else {
  8738. uponRejection(promise, action);
  8739. }
  8740. }
  8741. function isOrBecomesClosed(stream, promise, action) {
  8742. if (stream._state === 'closed') {
  8743. action();
  8744. } else {
  8745. uponFulfillment(promise, action);
  8746. }
  8747. }
  8748. function shutdownWithAction(action, originalIsError, originalError) {
  8749. if (shuttingDown) {
  8750. return;
  8751. }
  8752. shuttingDown = true;
  8753. if (dest._state === 'writable' && !WritableStreamCloseQueuedOrInFlight(dest)) {
  8754. uponFulfillment(waitForWritesToFinish(), doTheRest);
  8755. } else {
  8756. doTheRest();
  8757. }
  8758. function doTheRest() {
  8759. uponPromise(action(), function () {
  8760. return finalize(originalIsError, originalError);
  8761. }, function (newError) {
  8762. return finalize(true, newError);
  8763. });
  8764. }
  8765. }
  8766. function shutdown(isError, error) {
  8767. if (shuttingDown) {
  8768. return;
  8769. }
  8770. shuttingDown = true;
  8771. if (dest._state === 'writable' && !WritableStreamCloseQueuedOrInFlight(dest)) {
  8772. uponFulfillment(waitForWritesToFinish(), function () {
  8773. return finalize(isError, error);
  8774. });
  8775. } else {
  8776. finalize(isError, error);
  8777. }
  8778. }
  8779. function finalize(isError, error) {
  8780. WritableStreamDefaultWriterRelease(writer);
  8781. ReadableStreamReaderGenericRelease(reader);
  8782. if (signal !== undefined) {
  8783. signal.removeEventListener('abort', abortAlgorithm);
  8784. }
  8785. if (isError) {
  8786. reject(error);
  8787. } else {
  8788. resolve(undefined);
  8789. }
  8790. }
  8791. });
  8792. }
  8793. var ReadableStreamDefaultController = function () {
  8794. function ReadableStreamDefaultController() {
  8795. throw new TypeError('Illegal constructor');
  8796. }
  8797. Object.defineProperty(ReadableStreamDefaultController.prototype, "desiredSize", {
  8798. get: function () {
  8799. if (!IsReadableStreamDefaultController(this)) {
  8800. throw defaultControllerBrandCheckException('desiredSize');
  8801. }
  8802. return ReadableStreamDefaultControllerGetDesiredSize(this);
  8803. },
  8804. enumerable: false,
  8805. configurable: true
  8806. });
  8807. ReadableStreamDefaultController.prototype.close = function () {
  8808. if (!IsReadableStreamDefaultController(this)) {
  8809. throw defaultControllerBrandCheckException('close');
  8810. }
  8811. if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
  8812. throw new TypeError('The stream is not in a state that permits close');
  8813. }
  8814. ReadableStreamDefaultControllerClose(this);
  8815. };
  8816. ReadableStreamDefaultController.prototype.enqueue = function (chunk) {
  8817. if (chunk === void 0) {
  8818. chunk = undefined;
  8819. }
  8820. if (!IsReadableStreamDefaultController(this)) {
  8821. throw defaultControllerBrandCheckException('enqueue');
  8822. }
  8823. if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
  8824. throw new TypeError('The stream is not in a state that permits enqueue');
  8825. }
  8826. return ReadableStreamDefaultControllerEnqueue(this, chunk);
  8827. };
  8828. ReadableStreamDefaultController.prototype.error = function (e) {
  8829. if (e === void 0) {
  8830. e = undefined;
  8831. }
  8832. if (!IsReadableStreamDefaultController(this)) {
  8833. throw defaultControllerBrandCheckException('error');
  8834. }
  8835. ReadableStreamDefaultControllerError(this, e);
  8836. };
  8837. ReadableStreamDefaultController.prototype[CancelSteps] = function (reason) {
  8838. ResetQueue(this);
  8839. var result = this._cancelAlgorithm(reason);
  8840. ReadableStreamDefaultControllerClearAlgorithms(this);
  8841. return result;
  8842. };
  8843. ReadableStreamDefaultController.prototype[PullSteps] = function (readRequest) {
  8844. var stream = this._controlledReadableStream;
  8845. if (this._queue.length > 0) {
  8846. var chunk = DequeueValue(this);
  8847. if (this._closeRequested && this._queue.length === 0) {
  8848. ReadableStreamDefaultControllerClearAlgorithms(this);
  8849. ReadableStreamClose(stream);
  8850. } else {
  8851. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  8852. }
  8853. readRequest._chunkSteps(chunk);
  8854. } else {
  8855. ReadableStreamAddReadRequest(stream, readRequest);
  8856. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  8857. }
  8858. };
  8859. return ReadableStreamDefaultController;
  8860. }();
  8861. Object.defineProperties(ReadableStreamDefaultController.prototype, {
  8862. close: { enumerable: true },
  8863. enqueue: { enumerable: true },
  8864. error: { enumerable: true },
  8865. desiredSize: { enumerable: true }
  8866. });
  8867. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  8868. Object.defineProperty(ReadableStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
  8869. value: 'ReadableStreamDefaultController',
  8870. configurable: true
  8871. });
  8872. }
  8873. function IsReadableStreamDefaultController(x) {
  8874. if (!typeIsObject(x)) {
  8875. return false;
  8876. }
  8877. if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableStream')) {
  8878. return false;
  8879. }
  8880. return true;
  8881. }
  8882. function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
  8883. var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
  8884. if (!shouldPull) {
  8885. return;
  8886. }
  8887. if (controller._pulling) {
  8888. controller._pullAgain = true;
  8889. return;
  8890. }
  8891. controller._pulling = true;
  8892. var pullPromise = controller._pullAlgorithm();
  8893. uponPromise(pullPromise, function () {
  8894. controller._pulling = false;
  8895. if (controller._pullAgain) {
  8896. controller._pullAgain = false;
  8897. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  8898. }
  8899. }, function (e) {
  8900. ReadableStreamDefaultControllerError(controller, e);
  8901. });
  8902. }
  8903. function ReadableStreamDefaultControllerShouldCallPull(controller) {
  8904. var stream = controller._controlledReadableStream;
  8905. if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(controller)) {
  8906. return false;
  8907. }
  8908. if (!controller._started) {
  8909. return false;
  8910. }
  8911. if (IsReadableStreamLocked(stream) && ReadableStreamGetNumReadRequests(stream) > 0) {
  8912. return true;
  8913. }
  8914. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  8915. if (desiredSize > 0) {
  8916. return true;
  8917. }
  8918. return false;
  8919. }
  8920. function ReadableStreamDefaultControllerClearAlgorithms(controller) {
  8921. controller._pullAlgorithm = undefined;
  8922. controller._cancelAlgorithm = undefined;
  8923. controller._strategySizeAlgorithm = undefined;
  8924. }
  8925. function ReadableStreamDefaultControllerClose(controller) {
  8926. if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(controller)) {
  8927. return;
  8928. }
  8929. var stream = controller._controlledReadableStream;
  8930. controller._closeRequested = true;
  8931. if (controller._queue.length === 0) {
  8932. ReadableStreamDefaultControllerClearAlgorithms(controller);
  8933. ReadableStreamClose(stream);
  8934. }
  8935. }
  8936. function ReadableStreamDefaultControllerEnqueue(controller, chunk) {
  8937. if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(controller)) {
  8938. return;
  8939. }
  8940. var stream = controller._controlledReadableStream;
  8941. if (IsReadableStreamLocked(stream) && ReadableStreamGetNumReadRequests(stream) > 0) {
  8942. ReadableStreamFulfillReadRequest(stream, chunk, false);
  8943. } else {
  8944. var chunkSize = void 0;
  8945. try {
  8946. chunkSize = controller._strategySizeAlgorithm(chunk);
  8947. } catch (chunkSizeE) {
  8948. ReadableStreamDefaultControllerError(controller, chunkSizeE);
  8949. throw chunkSizeE;
  8950. }
  8951. try {
  8952. EnqueueValueWithSize(controller, chunk, chunkSize);
  8953. } catch (enqueueE) {
  8954. ReadableStreamDefaultControllerError(controller, enqueueE);
  8955. throw enqueueE;
  8956. }
  8957. }
  8958. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  8959. }
  8960. function ReadableStreamDefaultControllerError(controller, e) {
  8961. var stream = controller._controlledReadableStream;
  8962. if (stream._state !== 'readable') {
  8963. return;
  8964. }
  8965. ResetQueue(controller);
  8966. ReadableStreamDefaultControllerClearAlgorithms(controller);
  8967. ReadableStreamError(stream, e);
  8968. }
  8969. function ReadableStreamDefaultControllerGetDesiredSize(controller) {
  8970. var state = controller._controlledReadableStream._state;
  8971. if (state === 'errored') {
  8972. return null;
  8973. }
  8974. if (state === 'closed') {
  8975. return 0;
  8976. }
  8977. return controller._strategyHWM - controller._queueTotalSize;
  8978. }
  8979. function ReadableStreamDefaultControllerHasBackpressure(controller) {
  8980. if (ReadableStreamDefaultControllerShouldCallPull(controller)) {
  8981. return false;
  8982. }
  8983. return true;
  8984. }
  8985. function ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) {
  8986. var state = controller._controlledReadableStream._state;
  8987. if (!controller._closeRequested && state === 'readable') {
  8988. return true;
  8989. }
  8990. return false;
  8991. }
  8992. function SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm) {
  8993. controller._controlledReadableStream = stream;
  8994. controller._queue = undefined;
  8995. controller._queueTotalSize = undefined;
  8996. ResetQueue(controller);
  8997. controller._started = false;
  8998. controller._closeRequested = false;
  8999. controller._pullAgain = false;
  9000. controller._pulling = false;
  9001. controller._strategySizeAlgorithm = sizeAlgorithm;
  9002. controller._strategyHWM = highWaterMark;
  9003. controller._pullAlgorithm = pullAlgorithm;
  9004. controller._cancelAlgorithm = cancelAlgorithm;
  9005. stream._readableStreamController = controller;
  9006. var startResult = startAlgorithm();
  9007. uponPromise(promiseResolvedWith(startResult), function () {
  9008. controller._started = true;
  9009. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  9010. }, function (r) {
  9011. ReadableStreamDefaultControllerError(controller, r);
  9012. });
  9013. }
  9014. function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underlyingSource, highWaterMark, sizeAlgorithm) {
  9015. var controller = Object.create(ReadableStreamDefaultController.prototype);
  9016. var startAlgorithm = function () {
  9017. return undefined;
  9018. };
  9019. var pullAlgorithm = function () {
  9020. return promiseResolvedWith(undefined);
  9021. };
  9022. var cancelAlgorithm = function () {
  9023. return promiseResolvedWith(undefined);
  9024. };
  9025. if (underlyingSource.start !== undefined) {
  9026. startAlgorithm = function () {
  9027. return underlyingSource.start(controller);
  9028. };
  9029. }
  9030. if (underlyingSource.pull !== undefined) {
  9031. pullAlgorithm = function () {
  9032. return underlyingSource.pull(controller);
  9033. };
  9034. }
  9035. if (underlyingSource.cancel !== undefined) {
  9036. cancelAlgorithm = function (reason) {
  9037. return underlyingSource.cancel(reason);
  9038. };
  9039. }
  9040. SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
  9041. }
  9042. function defaultControllerBrandCheckException(name) {
  9043. return new TypeError("ReadableStreamDefaultController.prototype." + name + " can only be used on a ReadableStreamDefaultController");
  9044. }
  9045. function ReadableStreamTee(stream, cloneForBranch2) {
  9046. var reader = AcquireReadableStreamDefaultReader(stream);
  9047. var reading = false;
  9048. var canceled1 = false;
  9049. var canceled2 = false;
  9050. var reason1;
  9051. var reason2;
  9052. var branch1;
  9053. var branch2;
  9054. var resolveCancelPromise;
  9055. var cancelPromise = newPromise(function (resolve) {
  9056. resolveCancelPromise = resolve;
  9057. });
  9058. function pullAlgorithm() {
  9059. if (reading) {
  9060. return promiseResolvedWith(undefined);
  9061. }
  9062. reading = true;
  9063. var readRequest = {
  9064. _chunkSteps: function (value) {
  9065. queueMicrotask(function () {
  9066. reading = false;
  9067. var value1 = value;
  9068. var value2 = value;
  9069. if (!canceled1) {
  9070. ReadableStreamDefaultControllerEnqueue(branch1._readableStreamController, value1);
  9071. }
  9072. if (!canceled2) {
  9073. ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, value2);
  9074. }
  9075. resolveCancelPromise(undefined);
  9076. });
  9077. },
  9078. _closeSteps: function () {
  9079. reading = false;
  9080. if (!canceled1) {
  9081. ReadableStreamDefaultControllerClose(branch1._readableStreamController);
  9082. }
  9083. if (!canceled2) {
  9084. ReadableStreamDefaultControllerClose(branch2._readableStreamController);
  9085. }
  9086. },
  9087. _errorSteps: function () {
  9088. reading = false;
  9089. }
  9090. };
  9091. ReadableStreamDefaultReaderRead(reader, readRequest);
  9092. return promiseResolvedWith(undefined);
  9093. }
  9094. function cancel1Algorithm(reason) {
  9095. canceled1 = true;
  9096. reason1 = reason;
  9097. if (canceled2) {
  9098. var compositeReason = CreateArrayFromList([
  9099. reason1,
  9100. reason2
  9101. ]);
  9102. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  9103. resolveCancelPromise(cancelResult);
  9104. }
  9105. return cancelPromise;
  9106. }
  9107. function cancel2Algorithm(reason) {
  9108. canceled2 = true;
  9109. reason2 = reason;
  9110. if (canceled1) {
  9111. var compositeReason = CreateArrayFromList([
  9112. reason1,
  9113. reason2
  9114. ]);
  9115. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  9116. resolveCancelPromise(cancelResult);
  9117. }
  9118. return cancelPromise;
  9119. }
  9120. function startAlgorithm() {
  9121. }
  9122. branch1 = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel1Algorithm);
  9123. branch2 = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel2Algorithm);
  9124. uponRejection(reader._closedPromise, function (r) {
  9125. ReadableStreamDefaultControllerError(branch1._readableStreamController, r);
  9126. ReadableStreamDefaultControllerError(branch2._readableStreamController, r);
  9127. resolveCancelPromise(undefined);
  9128. });
  9129. return [
  9130. branch1,
  9131. branch2
  9132. ];
  9133. }
  9134. function convertUnderlyingDefaultOrByteSource(source, context) {
  9135. assertDictionary(source, context);
  9136. var original = source;
  9137. var autoAllocateChunkSize = original === null || original === void 0 ? void 0 : original.autoAllocateChunkSize;
  9138. var cancel = original === null || original === void 0 ? void 0 : original.cancel;
  9139. var pull = original === null || original === void 0 ? void 0 : original.pull;
  9140. var start = original === null || original === void 0 ? void 0 : original.start;
  9141. var type = original === null || original === void 0 ? void 0 : original.type;
  9142. return {
  9143. autoAllocateChunkSize: autoAllocateChunkSize === undefined ? undefined : convertUnsignedLongLongWithEnforceRange(autoAllocateChunkSize, context + " has member 'autoAllocateChunkSize' that"),
  9144. cancel: cancel === undefined ? undefined : convertUnderlyingSourceCancelCallback(cancel, original, context + " has member 'cancel' that"),
  9145. pull: pull === undefined ? undefined : convertUnderlyingSourcePullCallback(pull, original, context + " has member 'pull' that"),
  9146. start: start === undefined ? undefined : convertUnderlyingSourceStartCallback(start, original, context + " has member 'start' that"),
  9147. type: type === undefined ? undefined : convertReadableStreamType(type, context + " has member 'type' that")
  9148. };
  9149. }
  9150. function convertUnderlyingSourceCancelCallback(fn, original, context) {
  9151. assertFunction(fn, context);
  9152. return function (reason) {
  9153. return promiseCall(fn, original, [reason]);
  9154. };
  9155. }
  9156. function convertUnderlyingSourcePullCallback(fn, original, context) {
  9157. assertFunction(fn, context);
  9158. return function (controller) {
  9159. return promiseCall(fn, original, [controller]);
  9160. };
  9161. }
  9162. function convertUnderlyingSourceStartCallback(fn, original, context) {
  9163. assertFunction(fn, context);
  9164. return function (controller) {
  9165. return reflectCall(fn, original, [controller]);
  9166. };
  9167. }
  9168. function convertReadableStreamType(type, context) {
  9169. type = "" + type;
  9170. if (type !== 'bytes') {
  9171. throw new TypeError(context + " '" + type + "' is not a valid enumeration value for ReadableStreamType");
  9172. }
  9173. return type;
  9174. }
  9175. function convertReaderOptions(options, context) {
  9176. assertDictionary(options, context);
  9177. var mode = options === null || options === void 0 ? void 0 : options.mode;
  9178. return { mode: mode === undefined ? undefined : convertReadableStreamReaderMode(mode, context + " has member 'mode' that") };
  9179. }
  9180. function convertReadableStreamReaderMode(mode, context) {
  9181. mode = "" + mode;
  9182. if (mode !== 'byob') {
  9183. throw new TypeError(context + " '" + mode + "' is not a valid enumeration value for ReadableStreamReaderMode");
  9184. }
  9185. return mode;
  9186. }
  9187. function convertIteratorOptions(options, context) {
  9188. assertDictionary(options, context);
  9189. var preventCancel = options === null || options === void 0 ? void 0 : options.preventCancel;
  9190. return { preventCancel: Boolean(preventCancel) };
  9191. }
  9192. function convertPipeOptions(options, context) {
  9193. assertDictionary(options, context);
  9194. var preventAbort = options === null || options === void 0 ? void 0 : options.preventAbort;
  9195. var preventCancel = options === null || options === void 0 ? void 0 : options.preventCancel;
  9196. var preventClose = options === null || options === void 0 ? void 0 : options.preventClose;
  9197. var signal = options === null || options === void 0 ? void 0 : options.signal;
  9198. if (signal !== undefined) {
  9199. assertAbortSignal(signal, context + " has member 'signal' that");
  9200. }
  9201. return {
  9202. preventAbort: Boolean(preventAbort),
  9203. preventCancel: Boolean(preventCancel),
  9204. preventClose: Boolean(preventClose),
  9205. signal: signal
  9206. };
  9207. }
  9208. function assertAbortSignal(signal, context) {
  9209. if (!isAbortSignal(signal)) {
  9210. throw new TypeError(context + " is not an AbortSignal.");
  9211. }
  9212. }
  9213. function convertReadableWritablePair(pair, context) {
  9214. assertDictionary(pair, context);
  9215. var readable = pair === null || pair === void 0 ? void 0 : pair.readable;
  9216. assertRequiredField(readable, 'readable', 'ReadableWritablePair');
  9217. assertReadableStream(readable, context + " has member 'readable' that");
  9218. var writable = pair === null || pair === void 0 ? void 0 : pair.writable;
  9219. assertRequiredField(writable, 'writable', 'ReadableWritablePair');
  9220. assertWritableStream(writable, context + " has member 'writable' that");
  9221. return {
  9222. readable: readable,
  9223. writable: writable
  9224. };
  9225. }
  9226. var ReadableStream = function () {
  9227. function ReadableStream(rawUnderlyingSource, rawStrategy) {
  9228. if (rawUnderlyingSource === void 0) {
  9229. rawUnderlyingSource = {};
  9230. }
  9231. if (rawStrategy === void 0) {
  9232. rawStrategy = {};
  9233. }
  9234. if (rawUnderlyingSource === undefined) {
  9235. rawUnderlyingSource = null;
  9236. } else {
  9237. assertObject(rawUnderlyingSource, 'First parameter');
  9238. }
  9239. var strategy = convertQueuingStrategy(rawStrategy, 'Second parameter');
  9240. var underlyingSource = convertUnderlyingDefaultOrByteSource(rawUnderlyingSource, 'First parameter');
  9241. InitializeReadableStream(this);
  9242. if (underlyingSource.type === 'bytes') {
  9243. if (strategy.size !== undefined) {
  9244. throw new RangeError('The strategy for a byte stream cannot have a size function');
  9245. }
  9246. var highWaterMark = ExtractHighWaterMark(strategy, 0);
  9247. SetUpReadableByteStreamControllerFromUnderlyingSource(this, underlyingSource, highWaterMark);
  9248. } else {
  9249. var sizeAlgorithm = ExtractSizeAlgorithm(strategy);
  9250. var highWaterMark = ExtractHighWaterMark(strategy, 1);
  9251. SetUpReadableStreamDefaultControllerFromUnderlyingSource(this, underlyingSource, highWaterMark, sizeAlgorithm);
  9252. }
  9253. }
  9254. Object.defineProperty(ReadableStream.prototype, "locked", {
  9255. get: function () {
  9256. if (!IsReadableStream(this)) {
  9257. throw streamBrandCheckException$1('locked');
  9258. }
  9259. return IsReadableStreamLocked(this);
  9260. },
  9261. enumerable: false,
  9262. configurable: true
  9263. });
  9264. ReadableStream.prototype.cancel = function (reason) {
  9265. if (reason === void 0) {
  9266. reason = undefined;
  9267. }
  9268. if (!IsReadableStream(this)) {
  9269. return promiseRejectedWith(streamBrandCheckException$1('cancel'));
  9270. }
  9271. if (IsReadableStreamLocked(this)) {
  9272. return promiseRejectedWith(new TypeError('Cannot cancel a stream that already has a reader'));
  9273. }
  9274. return ReadableStreamCancel(this, reason);
  9275. };
  9276. ReadableStream.prototype.getReader = function (rawOptions) {
  9277. if (rawOptions === void 0) {
  9278. rawOptions = undefined;
  9279. }
  9280. if (!IsReadableStream(this)) {
  9281. throw streamBrandCheckException$1('getReader');
  9282. }
  9283. var options = convertReaderOptions(rawOptions, 'First parameter');
  9284. if (options.mode === undefined) {
  9285. return AcquireReadableStreamDefaultReader(this);
  9286. }
  9287. return AcquireReadableStreamBYOBReader(this);
  9288. };
  9289. ReadableStream.prototype.pipeThrough = function (rawTransform, rawOptions) {
  9290. if (rawOptions === void 0) {
  9291. rawOptions = {};
  9292. }
  9293. if (!IsReadableStream(this)) {
  9294. throw streamBrandCheckException$1('pipeThrough');
  9295. }
  9296. assertRequiredArgument(rawTransform, 1, 'pipeThrough');
  9297. var transform = convertReadableWritablePair(rawTransform, 'First parameter');
  9298. var options = convertPipeOptions(rawOptions, 'Second parameter');
  9299. if (IsReadableStreamLocked(this)) {
  9300. throw new TypeError('ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream');
  9301. }
  9302. if (IsWritableStreamLocked(transform.writable)) {
  9303. throw new TypeError('ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream');
  9304. }
  9305. var promise = ReadableStreamPipeTo(this, transform.writable, options.preventClose, options.preventAbort, options.preventCancel, options.signal);
  9306. setPromiseIsHandledToTrue(promise);
  9307. return transform.readable;
  9308. };
  9309. ReadableStream.prototype.pipeTo = function (destination, rawOptions) {
  9310. if (rawOptions === void 0) {
  9311. rawOptions = {};
  9312. }
  9313. if (!IsReadableStream(this)) {
  9314. return promiseRejectedWith(streamBrandCheckException$1('pipeTo'));
  9315. }
  9316. if (destination === undefined) {
  9317. return promiseRejectedWith("Parameter 1 is required in 'pipeTo'.");
  9318. }
  9319. if (!IsWritableStream(destination)) {
  9320. return promiseRejectedWith(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));
  9321. }
  9322. var options;
  9323. try {
  9324. options = convertPipeOptions(rawOptions, 'Second parameter');
  9325. } catch (e) {
  9326. return promiseRejectedWith(e);
  9327. }
  9328. if (IsReadableStreamLocked(this)) {
  9329. return promiseRejectedWith(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream'));
  9330. }
  9331. if (IsWritableStreamLocked(destination)) {
  9332. return promiseRejectedWith(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream'));
  9333. }
  9334. return ReadableStreamPipeTo(this, destination, options.preventClose, options.preventAbort, options.preventCancel, options.signal);
  9335. };
  9336. ReadableStream.prototype.tee = function () {
  9337. if (!IsReadableStream(this)) {
  9338. throw streamBrandCheckException$1('tee');
  9339. }
  9340. var branches = ReadableStreamTee(this);
  9341. return CreateArrayFromList(branches);
  9342. };
  9343. ReadableStream.prototype.values = function (rawOptions) {
  9344. if (rawOptions === void 0) {
  9345. rawOptions = undefined;
  9346. }
  9347. if (!IsReadableStream(this)) {
  9348. throw streamBrandCheckException$1('values');
  9349. }
  9350. var options = convertIteratorOptions(rawOptions, 'First parameter');
  9351. return AcquireReadableStreamAsyncIterator(this, options.preventCancel);
  9352. };
  9353. return ReadableStream;
  9354. }();
  9355. Object.defineProperties(ReadableStream.prototype, {
  9356. cancel: { enumerable: true },
  9357. getReader: { enumerable: true },
  9358. pipeThrough: { enumerable: true },
  9359. pipeTo: { enumerable: true },
  9360. tee: { enumerable: true },
  9361. values: { enumerable: true },
  9362. locked: { enumerable: true }
  9363. });
  9364. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  9365. Object.defineProperty(ReadableStream.prototype, SymbolPolyfill.toStringTag, {
  9366. value: 'ReadableStream',
  9367. configurable: true
  9368. });
  9369. }
  9370. if (typeof SymbolPolyfill.asyncIterator === 'symbol') {
  9371. Object.defineProperty(ReadableStream.prototype, SymbolPolyfill.asyncIterator, {
  9372. value: ReadableStream.prototype.values,
  9373. writable: true,
  9374. configurable: true
  9375. });
  9376. }
  9377. function CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm) {
  9378. if (highWaterMark === void 0) {
  9379. highWaterMark = 1;
  9380. }
  9381. if (sizeAlgorithm === void 0) {
  9382. sizeAlgorithm = function () {
  9383. return 1;
  9384. };
  9385. }
  9386. var stream = Object.create(ReadableStream.prototype);
  9387. InitializeReadableStream(stream);
  9388. var controller = Object.create(ReadableStreamDefaultController.prototype);
  9389. SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
  9390. return stream;
  9391. }
  9392. function InitializeReadableStream(stream) {
  9393. stream._state = 'readable';
  9394. stream._reader = undefined;
  9395. stream._storedError = undefined;
  9396. stream._disturbed = false;
  9397. }
  9398. function IsReadableStream(x) {
  9399. if (!typeIsObject(x)) {
  9400. return false;
  9401. }
  9402. if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
  9403. return false;
  9404. }
  9405. return true;
  9406. }
  9407. function IsReadableStreamLocked(stream) {
  9408. if (stream._reader === undefined) {
  9409. return false;
  9410. }
  9411. return true;
  9412. }
  9413. function ReadableStreamCancel(stream, reason) {
  9414. stream._disturbed = true;
  9415. if (stream._state === 'closed') {
  9416. return promiseResolvedWith(undefined);
  9417. }
  9418. if (stream._state === 'errored') {
  9419. return promiseRejectedWith(stream._storedError);
  9420. }
  9421. ReadableStreamClose(stream);
  9422. var sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
  9423. return transformPromiseWith(sourceCancelPromise, noop);
  9424. }
  9425. function ReadableStreamClose(stream) {
  9426. stream._state = 'closed';
  9427. var reader = stream._reader;
  9428. if (reader === undefined) {
  9429. return;
  9430. }
  9431. if (IsReadableStreamDefaultReader(reader)) {
  9432. reader._readRequests.forEach(function (readRequest) {
  9433. readRequest._closeSteps();
  9434. });
  9435. reader._readRequests = new SimpleQueue();
  9436. }
  9437. defaultReaderClosedPromiseResolve(reader);
  9438. }
  9439. function ReadableStreamError(stream, e) {
  9440. stream._state = 'errored';
  9441. stream._storedError = e;
  9442. var reader = stream._reader;
  9443. if (reader === undefined) {
  9444. return;
  9445. }
  9446. if (IsReadableStreamDefaultReader(reader)) {
  9447. reader._readRequests.forEach(function (readRequest) {
  9448. readRequest._errorSteps(e);
  9449. });
  9450. reader._readRequests = new SimpleQueue();
  9451. } else {
  9452. reader._readIntoRequests.forEach(function (readIntoRequest) {
  9453. readIntoRequest._errorSteps(e);
  9454. });
  9455. reader._readIntoRequests = new SimpleQueue();
  9456. }
  9457. defaultReaderClosedPromiseReject(reader, e);
  9458. }
  9459. function streamBrandCheckException$1(name) {
  9460. return new TypeError("ReadableStream.prototype." + name + " can only be used on a ReadableStream");
  9461. }
  9462. function convertQueuingStrategyInit(init, context) {
  9463. assertDictionary(init, context);
  9464. var highWaterMark = init === null || init === void 0 ? void 0 : init.highWaterMark;
  9465. assertRequiredField(highWaterMark, 'highWaterMark', 'QueuingStrategyInit');
  9466. return { highWaterMark: convertUnrestrictedDouble(highWaterMark) };
  9467. }
  9468. var byteLengthSizeFunction = function size(chunk) {
  9469. return chunk.byteLength;
  9470. };
  9471. var ByteLengthQueuingStrategy = function () {
  9472. function ByteLengthQueuingStrategy(options) {
  9473. assertRequiredArgument(options, 1, 'ByteLengthQueuingStrategy');
  9474. options = convertQueuingStrategyInit(options, 'First parameter');
  9475. this._byteLengthQueuingStrategyHighWaterMark = options.highWaterMark;
  9476. }
  9477. Object.defineProperty(ByteLengthQueuingStrategy.prototype, "highWaterMark", {
  9478. get: function () {
  9479. if (!IsByteLengthQueuingStrategy(this)) {
  9480. throw byteLengthBrandCheckException('highWaterMark');
  9481. }
  9482. return this._byteLengthQueuingStrategyHighWaterMark;
  9483. },
  9484. enumerable: false,
  9485. configurable: true
  9486. });
  9487. Object.defineProperty(ByteLengthQueuingStrategy.prototype, "size", {
  9488. get: function () {
  9489. if (!IsByteLengthQueuingStrategy(this)) {
  9490. throw byteLengthBrandCheckException('size');
  9491. }
  9492. return byteLengthSizeFunction;
  9493. },
  9494. enumerable: false,
  9495. configurable: true
  9496. });
  9497. return ByteLengthQueuingStrategy;
  9498. }();
  9499. Object.defineProperties(ByteLengthQueuingStrategy.prototype, {
  9500. highWaterMark: { enumerable: true },
  9501. size: { enumerable: true }
  9502. });
  9503. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  9504. Object.defineProperty(ByteLengthQueuingStrategy.prototype, SymbolPolyfill.toStringTag, {
  9505. value: 'ByteLengthQueuingStrategy',
  9506. configurable: true
  9507. });
  9508. }
  9509. function byteLengthBrandCheckException(name) {
  9510. return new TypeError("ByteLengthQueuingStrategy.prototype." + name + " can only be used on a ByteLengthQueuingStrategy");
  9511. }
  9512. function IsByteLengthQueuingStrategy(x) {
  9513. if (!typeIsObject(x)) {
  9514. return false;
  9515. }
  9516. if (!Object.prototype.hasOwnProperty.call(x, '_byteLengthQueuingStrategyHighWaterMark')) {
  9517. return false;
  9518. }
  9519. return true;
  9520. }
  9521. var countSizeFunction = function size() {
  9522. return 1;
  9523. };
  9524. var CountQueuingStrategy = function () {
  9525. function CountQueuingStrategy(options) {
  9526. assertRequiredArgument(options, 1, 'CountQueuingStrategy');
  9527. options = convertQueuingStrategyInit(options, 'First parameter');
  9528. this._countQueuingStrategyHighWaterMark = options.highWaterMark;
  9529. }
  9530. Object.defineProperty(CountQueuingStrategy.prototype, "highWaterMark", {
  9531. get: function () {
  9532. if (!IsCountQueuingStrategy(this)) {
  9533. throw countBrandCheckException('highWaterMark');
  9534. }
  9535. return this._countQueuingStrategyHighWaterMark;
  9536. },
  9537. enumerable: false,
  9538. configurable: true
  9539. });
  9540. Object.defineProperty(CountQueuingStrategy.prototype, "size", {
  9541. get: function () {
  9542. if (!IsCountQueuingStrategy(this)) {
  9543. throw countBrandCheckException('size');
  9544. }
  9545. return countSizeFunction;
  9546. },
  9547. enumerable: false,
  9548. configurable: true
  9549. });
  9550. return CountQueuingStrategy;
  9551. }();
  9552. Object.defineProperties(CountQueuingStrategy.prototype, {
  9553. highWaterMark: { enumerable: true },
  9554. size: { enumerable: true }
  9555. });
  9556. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  9557. Object.defineProperty(CountQueuingStrategy.prototype, SymbolPolyfill.toStringTag, {
  9558. value: 'CountQueuingStrategy',
  9559. configurable: true
  9560. });
  9561. }
  9562. function countBrandCheckException(name) {
  9563. return new TypeError("CountQueuingStrategy.prototype." + name + " can only be used on a CountQueuingStrategy");
  9564. }
  9565. function IsCountQueuingStrategy(x) {
  9566. if (!typeIsObject(x)) {
  9567. return false;
  9568. }
  9569. if (!Object.prototype.hasOwnProperty.call(x, '_countQueuingStrategyHighWaterMark')) {
  9570. return false;
  9571. }
  9572. return true;
  9573. }
  9574. function convertTransformer(original, context) {
  9575. assertDictionary(original, context);
  9576. var flush = original === null || original === void 0 ? void 0 : original.flush;
  9577. var readableType = original === null || original === void 0 ? void 0 : original.readableType;
  9578. var start = original === null || original === void 0 ? void 0 : original.start;
  9579. var transform = original === null || original === void 0 ? void 0 : original.transform;
  9580. var writableType = original === null || original === void 0 ? void 0 : original.writableType;
  9581. return {
  9582. flush: flush === undefined ? undefined : convertTransformerFlushCallback(flush, original, context + " has member 'flush' that"),
  9583. readableType: readableType,
  9584. start: start === undefined ? undefined : convertTransformerStartCallback(start, original, context + " has member 'start' that"),
  9585. transform: transform === undefined ? undefined : convertTransformerTransformCallback(transform, original, context + " has member 'transform' that"),
  9586. writableType: writableType
  9587. };
  9588. }
  9589. function convertTransformerFlushCallback(fn, original, context) {
  9590. assertFunction(fn, context);
  9591. return function (controller) {
  9592. return promiseCall(fn, original, [controller]);
  9593. };
  9594. }
  9595. function convertTransformerStartCallback(fn, original, context) {
  9596. assertFunction(fn, context);
  9597. return function (controller) {
  9598. return reflectCall(fn, original, [controller]);
  9599. };
  9600. }
  9601. function convertTransformerTransformCallback(fn, original, context) {
  9602. assertFunction(fn, context);
  9603. return function (chunk, controller) {
  9604. return promiseCall(fn, original, [
  9605. chunk,
  9606. controller
  9607. ]);
  9608. };
  9609. }
  9610. var TransformStream = function () {
  9611. function TransformStream(rawTransformer, rawWritableStrategy, rawReadableStrategy) {
  9612. if (rawTransformer === void 0) {
  9613. rawTransformer = {};
  9614. }
  9615. if (rawWritableStrategy === void 0) {
  9616. rawWritableStrategy = {};
  9617. }
  9618. if (rawReadableStrategy === void 0) {
  9619. rawReadableStrategy = {};
  9620. }
  9621. if (rawTransformer === undefined) {
  9622. rawTransformer = null;
  9623. }
  9624. var writableStrategy = convertQueuingStrategy(rawWritableStrategy, 'Second parameter');
  9625. var readableStrategy = convertQueuingStrategy(rawReadableStrategy, 'Third parameter');
  9626. var transformer = convertTransformer(rawTransformer, 'First parameter');
  9627. if (transformer.readableType !== undefined) {
  9628. throw new RangeError('Invalid readableType specified');
  9629. }
  9630. if (transformer.writableType !== undefined) {
  9631. throw new RangeError('Invalid writableType specified');
  9632. }
  9633. var readableHighWaterMark = ExtractHighWaterMark(readableStrategy, 0);
  9634. var readableSizeAlgorithm = ExtractSizeAlgorithm(readableStrategy);
  9635. var writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
  9636. var writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
  9637. var startPromise_resolve;
  9638. var startPromise = newPromise(function (resolve) {
  9639. startPromise_resolve = resolve;
  9640. });
  9641. InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
  9642. SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
  9643. if (transformer.start !== undefined) {
  9644. startPromise_resolve(transformer.start(this._transformStreamController));
  9645. } else {
  9646. startPromise_resolve(undefined);
  9647. }
  9648. }
  9649. Object.defineProperty(TransformStream.prototype, "readable", {
  9650. get: function () {
  9651. if (!IsTransformStream(this)) {
  9652. throw streamBrandCheckException$2('readable');
  9653. }
  9654. return this._readable;
  9655. },
  9656. enumerable: false,
  9657. configurable: true
  9658. });
  9659. Object.defineProperty(TransformStream.prototype, "writable", {
  9660. get: function () {
  9661. if (!IsTransformStream(this)) {
  9662. throw streamBrandCheckException$2('writable');
  9663. }
  9664. return this._writable;
  9665. },
  9666. enumerable: false,
  9667. configurable: true
  9668. });
  9669. return TransformStream;
  9670. }();
  9671. Object.defineProperties(TransformStream.prototype, {
  9672. readable: { enumerable: true },
  9673. writable: { enumerable: true }
  9674. });
  9675. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  9676. Object.defineProperty(TransformStream.prototype, SymbolPolyfill.toStringTag, {
  9677. value: 'TransformStream',
  9678. configurable: true
  9679. });
  9680. }
  9681. function InitializeTransformStream(stream, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm) {
  9682. function startAlgorithm() {
  9683. return startPromise;
  9684. }
  9685. function writeAlgorithm(chunk) {
  9686. return TransformStreamDefaultSinkWriteAlgorithm(stream, chunk);
  9687. }
  9688. function abortAlgorithm(reason) {
  9689. return TransformStreamDefaultSinkAbortAlgorithm(stream, reason);
  9690. }
  9691. function closeAlgorithm() {
  9692. return TransformStreamDefaultSinkCloseAlgorithm(stream);
  9693. }
  9694. stream._writable = CreateWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, writableHighWaterMark, writableSizeAlgorithm);
  9695. function pullAlgorithm() {
  9696. return TransformStreamDefaultSourcePullAlgorithm(stream);
  9697. }
  9698. function cancelAlgorithm(reason) {
  9699. TransformStreamErrorWritableAndUnblockWrite(stream, reason);
  9700. return promiseResolvedWith(undefined);
  9701. }
  9702. stream._readable = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
  9703. stream._backpressure = undefined;
  9704. stream._backpressureChangePromise = undefined;
  9705. stream._backpressureChangePromise_resolve = undefined;
  9706. TransformStreamSetBackpressure(stream, true);
  9707. stream._transformStreamController = undefined;
  9708. }
  9709. function IsTransformStream(x) {
  9710. if (!typeIsObject(x)) {
  9711. return false;
  9712. }
  9713. if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
  9714. return false;
  9715. }
  9716. return true;
  9717. }
  9718. function TransformStreamError(stream, e) {
  9719. ReadableStreamDefaultControllerError(stream._readable._readableStreamController, e);
  9720. TransformStreamErrorWritableAndUnblockWrite(stream, e);
  9721. }
  9722. function TransformStreamErrorWritableAndUnblockWrite(stream, e) {
  9723. TransformStreamDefaultControllerClearAlgorithms(stream._transformStreamController);
  9724. WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, e);
  9725. if (stream._backpressure) {
  9726. TransformStreamSetBackpressure(stream, false);
  9727. }
  9728. }
  9729. function TransformStreamSetBackpressure(stream, backpressure) {
  9730. if (stream._backpressureChangePromise !== undefined) {
  9731. stream._backpressureChangePromise_resolve();
  9732. }
  9733. stream._backpressureChangePromise = newPromise(function (resolve) {
  9734. stream._backpressureChangePromise_resolve = resolve;
  9735. });
  9736. stream._backpressure = backpressure;
  9737. }
  9738. var TransformStreamDefaultController = function () {
  9739. function TransformStreamDefaultController() {
  9740. throw new TypeError('Illegal constructor');
  9741. }
  9742. Object.defineProperty(TransformStreamDefaultController.prototype, "desiredSize", {
  9743. get: function () {
  9744. if (!IsTransformStreamDefaultController(this)) {
  9745. throw defaultControllerBrandCheckException$1('desiredSize');
  9746. }
  9747. var readableController = this._controlledTransformStream._readable._readableStreamController;
  9748. return ReadableStreamDefaultControllerGetDesiredSize(readableController);
  9749. },
  9750. enumerable: false,
  9751. configurable: true
  9752. });
  9753. TransformStreamDefaultController.prototype.enqueue = function (chunk) {
  9754. if (chunk === void 0) {
  9755. chunk = undefined;
  9756. }
  9757. if (!IsTransformStreamDefaultController(this)) {
  9758. throw defaultControllerBrandCheckException$1('enqueue');
  9759. }
  9760. TransformStreamDefaultControllerEnqueue(this, chunk);
  9761. };
  9762. TransformStreamDefaultController.prototype.error = function (reason) {
  9763. if (reason === void 0) {
  9764. reason = undefined;
  9765. }
  9766. if (!IsTransformStreamDefaultController(this)) {
  9767. throw defaultControllerBrandCheckException$1('error');
  9768. }
  9769. TransformStreamDefaultControllerError(this, reason);
  9770. };
  9771. TransformStreamDefaultController.prototype.terminate = function () {
  9772. if (!IsTransformStreamDefaultController(this)) {
  9773. throw defaultControllerBrandCheckException$1('terminate');
  9774. }
  9775. TransformStreamDefaultControllerTerminate(this);
  9776. };
  9777. return TransformStreamDefaultController;
  9778. }();
  9779. Object.defineProperties(TransformStreamDefaultController.prototype, {
  9780. enqueue: { enumerable: true },
  9781. error: { enumerable: true },
  9782. terminate: { enumerable: true },
  9783. desiredSize: { enumerable: true }
  9784. });
  9785. if (typeof SymbolPolyfill.toStringTag === 'symbol') {
  9786. Object.defineProperty(TransformStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
  9787. value: 'TransformStreamDefaultController',
  9788. configurable: true
  9789. });
  9790. }
  9791. function IsTransformStreamDefaultController(x) {
  9792. if (!typeIsObject(x)) {
  9793. return false;
  9794. }
  9795. if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
  9796. return false;
  9797. }
  9798. return true;
  9799. }
  9800. function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm) {
  9801. controller._controlledTransformStream = stream;
  9802. stream._transformStreamController = controller;
  9803. controller._transformAlgorithm = transformAlgorithm;
  9804. controller._flushAlgorithm = flushAlgorithm;
  9805. }
  9806. function SetUpTransformStreamDefaultControllerFromTransformer(stream, transformer) {
  9807. var controller = Object.create(TransformStreamDefaultController.prototype);
  9808. var transformAlgorithm = function (chunk) {
  9809. try {
  9810. TransformStreamDefaultControllerEnqueue(controller, chunk);
  9811. return promiseResolvedWith(undefined);
  9812. } catch (transformResultE) {
  9813. return promiseRejectedWith(transformResultE);
  9814. }
  9815. };
  9816. var flushAlgorithm = function () {
  9817. return promiseResolvedWith(undefined);
  9818. };
  9819. if (transformer.transform !== undefined) {
  9820. transformAlgorithm = function (chunk) {
  9821. return transformer.transform(chunk, controller);
  9822. };
  9823. }
  9824. if (transformer.flush !== undefined) {
  9825. flushAlgorithm = function () {
  9826. return transformer.flush(controller);
  9827. };
  9828. }
  9829. SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);
  9830. }
  9831. function TransformStreamDefaultControllerClearAlgorithms(controller) {
  9832. controller._transformAlgorithm = undefined;
  9833. controller._flushAlgorithm = undefined;
  9834. }
  9835. function TransformStreamDefaultControllerEnqueue(controller, chunk) {
  9836. var stream = controller._controlledTransformStream;
  9837. var readableController = stream._readable._readableStreamController;
  9838. if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController)) {
  9839. throw new TypeError('Readable side is not in a state that permits enqueue');
  9840. }
  9841. try {
  9842. ReadableStreamDefaultControllerEnqueue(readableController, chunk);
  9843. } catch (e) {
  9844. TransformStreamErrorWritableAndUnblockWrite(stream, e);
  9845. throw stream._readable._storedError;
  9846. }
  9847. var backpressure = ReadableStreamDefaultControllerHasBackpressure(readableController);
  9848. if (backpressure !== stream._backpressure) {
  9849. TransformStreamSetBackpressure(stream, true);
  9850. }
  9851. }
  9852. function TransformStreamDefaultControllerError(controller, e) {
  9853. TransformStreamError(controller._controlledTransformStream, e);
  9854. }
  9855. function TransformStreamDefaultControllerPerformTransform(controller, chunk) {
  9856. var transformPromise = controller._transformAlgorithm(chunk);
  9857. return transformPromiseWith(transformPromise, undefined, function (r) {
  9858. TransformStreamError(controller._controlledTransformStream, r);
  9859. throw r;
  9860. });
  9861. }
  9862. function TransformStreamDefaultControllerTerminate(controller) {
  9863. var stream = controller._controlledTransformStream;
  9864. var readableController = stream._readable._readableStreamController;
  9865. ReadableStreamDefaultControllerClose(readableController);
  9866. var error = new TypeError('TransformStream terminated');
  9867. TransformStreamErrorWritableAndUnblockWrite(stream, error);
  9868. }
  9869. function TransformStreamDefaultSinkWriteAlgorithm(stream, chunk) {
  9870. var controller = stream._transformStreamController;
  9871. if (stream._backpressure) {
  9872. var backpressureChangePromise = stream._backpressureChangePromise;
  9873. return transformPromiseWith(backpressureChangePromise, function () {
  9874. var writable = stream._writable;
  9875. var state = writable._state;
  9876. if (state === 'erroring') {
  9877. throw writable._storedError;
  9878. }
  9879. return TransformStreamDefaultControllerPerformTransform(controller, chunk);
  9880. });
  9881. }
  9882. return TransformStreamDefaultControllerPerformTransform(controller, chunk);
  9883. }
  9884. function TransformStreamDefaultSinkAbortAlgorithm(stream, reason) {
  9885. TransformStreamError(stream, reason);
  9886. return promiseResolvedWith(undefined);
  9887. }
  9888. function TransformStreamDefaultSinkCloseAlgorithm(stream) {
  9889. var readable = stream._readable;
  9890. var controller = stream._transformStreamController;
  9891. var flushPromise = controller._flushAlgorithm();
  9892. TransformStreamDefaultControllerClearAlgorithms(controller);
  9893. return transformPromiseWith(flushPromise, function () {
  9894. if (readable._state === 'errored') {
  9895. throw readable._storedError;
  9896. }
  9897. ReadableStreamDefaultControllerClose(readable._readableStreamController);
  9898. }, function (r) {
  9899. TransformStreamError(stream, r);
  9900. throw readable._storedError;
  9901. });
  9902. }
  9903. function TransformStreamDefaultSourcePullAlgorithm(stream) {
  9904. TransformStreamSetBackpressure(stream, false);
  9905. return stream._backpressureChangePromise;
  9906. }
  9907. function defaultControllerBrandCheckException$1(name) {
  9908. return new TypeError("TransformStreamDefaultController.prototype." + name + " can only be used on a TransformStreamDefaultController");
  9909. }
  9910. function streamBrandCheckException$2(name) {
  9911. return new TypeError("TransformStream.prototype." + name + " can only be used on a TransformStream");
  9912. }
  9913. exports.ByteLengthQueuingStrategy = ByteLengthQueuingStrategy;
  9914. exports.CountQueuingStrategy = CountQueuingStrategy;
  9915. exports.ReadableByteStreamController = ReadableByteStreamController;
  9916. exports.ReadableStream = ReadableStream;
  9917. exports.ReadableStreamBYOBReader = ReadableStreamBYOBReader;
  9918. exports.ReadableStreamBYOBRequest = ReadableStreamBYOBRequest;
  9919. exports.ReadableStreamDefaultController = ReadableStreamDefaultController;
  9920. exports.ReadableStreamDefaultReader = ReadableStreamDefaultReader;
  9921. exports.TransformStream = TransformStream;
  9922. exports.TransformStreamDefaultController = TransformStreamDefaultController;
  9923. exports.WritableStream = WritableStream;
  9924. exports.WritableStreamDefaultController = WritableStreamDefaultController;
  9925. exports.WritableStreamDefaultWriter = WritableStreamDefaultWriter;
  9926. Object.defineProperty(exports, '__esModule', { value: true });
  9927. }));
  9928. /***/ }),
  9929. /* 122 */
  9930. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  9931. __w_pdfjs_require__(123);
  9932. var entryUnbind = __w_pdfjs_require__(127);
  9933. module.exports = entryUnbind('String', 'padStart');
  9934. /***/ }),
  9935. /* 123 */
  9936. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  9937. "use strict";
  9938. var $ = __w_pdfjs_require__(9);
  9939. var $padStart = __w_pdfjs_require__(124).start;
  9940. var WEBKIT_BUG = __w_pdfjs_require__(126);
  9941. $({
  9942. target: 'String',
  9943. proto: true,
  9944. forced: WEBKIT_BUG
  9945. }, {
  9946. padStart: function padStart(maxLength) {
  9947. return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
  9948. }
  9949. });
  9950. /***/ }),
  9951. /* 124 */
  9952. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  9953. var toLength = __w_pdfjs_require__(46);
  9954. var repeat = __w_pdfjs_require__(125);
  9955. var requireObjectCoercible = __w_pdfjs_require__(19);
  9956. var ceil = Math.ceil;
  9957. var createMethod = function (IS_END) {
  9958. return function ($this, maxLength, fillString) {
  9959. var S = String(requireObjectCoercible($this));
  9960. var stringLength = S.length;
  9961. var fillStr = fillString === undefined ? ' ' : String(fillString);
  9962. var intMaxLength = toLength(maxLength);
  9963. var fillLen, stringFiller;
  9964. if (intMaxLength <= stringLength || fillStr == '')
  9965. return S;
  9966. fillLen = intMaxLength - stringLength;
  9967. stringFiller = repeat.call(fillStr, ceil(fillLen / fillStr.length));
  9968. if (stringFiller.length > fillLen)
  9969. stringFiller = stringFiller.slice(0, fillLen);
  9970. return IS_END ? S + stringFiller : stringFiller + S;
  9971. };
  9972. };
  9973. module.exports = {
  9974. start: createMethod(false),
  9975. end: createMethod(true)
  9976. };
  9977. /***/ }),
  9978. /* 125 */
  9979. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  9980. "use strict";
  9981. var toInteger = __w_pdfjs_require__(47);
  9982. var requireObjectCoercible = __w_pdfjs_require__(19);
  9983. module.exports = ''.repeat || function repeat(count) {
  9984. var str = String(requireObjectCoercible(this));
  9985. var result = '';
  9986. var n = toInteger(count);
  9987. if (n < 0 || n == Infinity)
  9988. throw RangeError('Wrong number of repetitions');
  9989. for (; n > 0; (n >>>= 1) && (str += str))
  9990. if (n & 1)
  9991. result += str;
  9992. return result;
  9993. };
  9994. /***/ }),
  9995. /* 126 */
  9996. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  9997. var userAgent = __w_pdfjs_require__(95);
  9998. module.exports = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent);
  9999. /***/ }),
  10000. /* 127 */
  10001. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10002. var global = __w_pdfjs_require__(10);
  10003. var bind = __w_pdfjs_require__(75);
  10004. var call = Function.call;
  10005. module.exports = function (CONSTRUCTOR, METHOD, length) {
  10006. return bind(call, global[CONSTRUCTOR].prototype[METHOD], length);
  10007. };
  10008. /***/ }),
  10009. /* 128 */
  10010. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10011. __w_pdfjs_require__(129);
  10012. var entryUnbind = __w_pdfjs_require__(127);
  10013. module.exports = entryUnbind('String', 'padEnd');
  10014. /***/ }),
  10015. /* 129 */
  10016. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10017. "use strict";
  10018. var $ = __w_pdfjs_require__(9);
  10019. var $padEnd = __w_pdfjs_require__(124).end;
  10020. var WEBKIT_BUG = __w_pdfjs_require__(126);
  10021. $({
  10022. target: 'String',
  10023. proto: true,
  10024. forced: WEBKIT_BUG
  10025. }, {
  10026. padEnd: function padEnd(maxLength) {
  10027. return $padEnd(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
  10028. }
  10029. });
  10030. /***/ }),
  10031. /* 130 */
  10032. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10033. __w_pdfjs_require__(131);
  10034. var path = __w_pdfjs_require__(42);
  10035. module.exports = path.Object.values;
  10036. /***/ }),
  10037. /* 131 */
  10038. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10039. var $ = __w_pdfjs_require__(9);
  10040. var $values = __w_pdfjs_require__(132).values;
  10041. $({
  10042. target: 'Object',
  10043. stat: true
  10044. }, {
  10045. values: function values(O) {
  10046. return $values(O);
  10047. }
  10048. });
  10049. /***/ }),
  10050. /* 132 */
  10051. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10052. var DESCRIPTORS = __w_pdfjs_require__(12);
  10053. var objectKeys = __w_pdfjs_require__(60);
  10054. var toIndexedObject = __w_pdfjs_require__(16);
  10055. var propertyIsEnumerable = __w_pdfjs_require__(14).f;
  10056. var createMethod = function (TO_ENTRIES) {
  10057. return function (it) {
  10058. var O = toIndexedObject(it);
  10059. var keys = objectKeys(O);
  10060. var length = keys.length;
  10061. var i = 0;
  10062. var result = [];
  10063. var key;
  10064. while (length > i) {
  10065. key = keys[i++];
  10066. if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) {
  10067. result.push(TO_ENTRIES ? [
  10068. key,
  10069. O[key]
  10070. ] : O[key]);
  10071. }
  10072. }
  10073. return result;
  10074. };
  10075. };
  10076. module.exports = {
  10077. entries: createMethod(true),
  10078. values: createMethod(false)
  10079. };
  10080. /***/ }),
  10081. /* 133 */
  10082. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10083. __w_pdfjs_require__(134);
  10084. var path = __w_pdfjs_require__(42);
  10085. module.exports = path.Object.entries;
  10086. /***/ }),
  10087. /* 134 */
  10088. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10089. var $ = __w_pdfjs_require__(9);
  10090. var $entries = __w_pdfjs_require__(132).entries;
  10091. $({
  10092. target: 'Object',
  10093. stat: true
  10094. }, {
  10095. entries: function entries(O) {
  10096. return $entries(O);
  10097. }
  10098. });
  10099. /***/ }),
  10100. /* 135 */
  10101. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  10102. "use strict";
  10103. Object.defineProperty(exports, "__esModule", ({
  10104. value: true
  10105. }));
  10106. exports.getDocument = getDocument;
  10107. exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory;
  10108. exports.version = exports.PDFWorker = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFDataRangeTransport = exports.LoopbackPort = exports.DefaultCMapReaderFactory = exports.DefaultCanvasFactory = exports.build = void 0;
  10109. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  10110. var _util = __w_pdfjs_require__(4);
  10111. var _display_utils = __w_pdfjs_require__(1);
  10112. var _font_loader = __w_pdfjs_require__(136);
  10113. var _node_utils = __w_pdfjs_require__(137);
  10114. var _annotation_storage = __w_pdfjs_require__(138);
  10115. var _api_compatibility = __w_pdfjs_require__(139);
  10116. var _canvas = __w_pdfjs_require__(140);
  10117. var _worker_options = __w_pdfjs_require__(142);
  10118. var _is_node = __w_pdfjs_require__(6);
  10119. var _message_handler = __w_pdfjs_require__(143);
  10120. var _metadata = __w_pdfjs_require__(144);
  10121. var _optional_content_config = __w_pdfjs_require__(146);
  10122. var _transport_stream = __w_pdfjs_require__(147);
  10123. var _webgl = __w_pdfjs_require__(148);
  10124. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  10125. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  10126. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  10127. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  10128. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  10129. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  10130. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  10131. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  10132. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10133. 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); } }
  10134. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10135. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  10136. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  10137. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  10138. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  10139. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  10140. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  10141. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10142. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  10143. var RENDERING_CANCELLED_TIMEOUT = 100;
  10144. var DefaultCanvasFactory = _is_node.isNodeJS ? _node_utils.NodeCanvasFactory : _display_utils.DOMCanvasFactory;
  10145. exports.DefaultCanvasFactory = DefaultCanvasFactory;
  10146. var DefaultCMapReaderFactory = _is_node.isNodeJS ? _node_utils.NodeCMapReaderFactory : _display_utils.DOMCMapReaderFactory;
  10147. exports.DefaultCMapReaderFactory = DefaultCMapReaderFactory;
  10148. var createPDFNetworkStream;
  10149. function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
  10150. createPDFNetworkStream = pdfNetworkStreamFactory;
  10151. }
  10152. function getDocument(src) {
  10153. var task = new PDFDocumentLoadingTask();
  10154. var source;
  10155. if (typeof src === "string") {
  10156. source = {
  10157. url: src
  10158. };
  10159. } else if ((0, _util.isArrayBuffer)(src)) {
  10160. source = {
  10161. data: src
  10162. };
  10163. } else if (src instanceof PDFDataRangeTransport) {
  10164. source = {
  10165. range: src
  10166. };
  10167. } else {
  10168. if (_typeof(src) !== "object") {
  10169. throw new Error("Invalid parameter in getDocument, " + "need either Uint8Array, string or a parameter object");
  10170. }
  10171. if (!src.url && !src.data && !src.range) {
  10172. throw new Error("Invalid parameter object: need either .data, .range or .url");
  10173. }
  10174. source = src;
  10175. }
  10176. var params = Object.create(null);
  10177. var rangeTransport = null,
  10178. worker = null;
  10179. for (var key in source) {
  10180. if (key === "url" && typeof window !== "undefined") {
  10181. params[key] = new URL(source[key], window.location).href;
  10182. continue;
  10183. } else if (key === "range") {
  10184. rangeTransport = source[key];
  10185. continue;
  10186. } else if (key === "worker") {
  10187. worker = source[key];
  10188. continue;
  10189. } else if (key === "data" && !(source[key] instanceof Uint8Array)) {
  10190. var pdfBytes = source[key];
  10191. if (typeof pdfBytes === "string") {
  10192. params[key] = (0, _util.stringToBytes)(pdfBytes);
  10193. } else if (_typeof(pdfBytes) === "object" && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  10194. params[key] = new Uint8Array(pdfBytes);
  10195. } else if ((0, _util.isArrayBuffer)(pdfBytes)) {
  10196. params[key] = new Uint8Array(pdfBytes);
  10197. } else {
  10198. throw new Error("Invalid PDF binary data: either typed array, " + "string or array-like object is expected in the " + "data property.");
  10199. }
  10200. continue;
  10201. }
  10202. params[key] = source[key];
  10203. }
  10204. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  10205. params.CMapReaderFactory = params.CMapReaderFactory || DefaultCMapReaderFactory;
  10206. params.ignoreErrors = params.stopAtErrors !== true;
  10207. params.fontExtraProperties = params.fontExtraProperties === true;
  10208. params.pdfBug = params.pdfBug === true;
  10209. if (!Number.isInteger(params.maxImageSize)) {
  10210. params.maxImageSize = -1;
  10211. }
  10212. if (typeof params.isEvalSupported !== "boolean") {
  10213. params.isEvalSupported = true;
  10214. }
  10215. if (typeof params.disableFontFace !== "boolean") {
  10216. params.disableFontFace = _api_compatibility.apiCompatibilityParams.disableFontFace || false;
  10217. }
  10218. if (typeof params.ownerDocument === "undefined") {
  10219. params.ownerDocument = globalThis.document;
  10220. }
  10221. if (typeof params.disableRange !== "boolean") {
  10222. params.disableRange = false;
  10223. }
  10224. if (typeof params.disableStream !== "boolean") {
  10225. params.disableStream = false;
  10226. }
  10227. if (typeof params.disableAutoFetch !== "boolean") {
  10228. params.disableAutoFetch = false;
  10229. }
  10230. (0, _util.setVerbosityLevel)(params.verbosity);
  10231. if (!worker) {
  10232. var workerParams = {
  10233. verbosity: params.verbosity,
  10234. port: _worker_options.GlobalWorkerOptions.workerPort
  10235. };
  10236. worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
  10237. task._worker = worker;
  10238. }
  10239. var docId = task.docId;
  10240. worker.promise.then(function () {
  10241. if (task.destroyed) {
  10242. throw new Error("Loading aborted");
  10243. }
  10244. var workerIdPromise = _fetchDocument(worker, params, rangeTransport, docId);
  10245. var networkStreamPromise = new Promise(function (resolve) {
  10246. var networkStream;
  10247. if (rangeTransport) {
  10248. networkStream = new _transport_stream.PDFDataTransportStream({
  10249. length: params.length,
  10250. initialData: params.initialData,
  10251. progressiveDone: params.progressiveDone,
  10252. disableRange: params.disableRange,
  10253. disableStream: params.disableStream
  10254. }, rangeTransport);
  10255. } else if (!params.data) {
  10256. networkStream = createPDFNetworkStream({
  10257. url: params.url,
  10258. length: params.length,
  10259. httpHeaders: params.httpHeaders,
  10260. withCredentials: params.withCredentials,
  10261. rangeChunkSize: params.rangeChunkSize,
  10262. disableRange: params.disableRange,
  10263. disableStream: params.disableStream
  10264. });
  10265. }
  10266. resolve(networkStream);
  10267. });
  10268. return Promise.all([workerIdPromise, networkStreamPromise]).then(function (_ref) {
  10269. var _ref2 = _slicedToArray(_ref, 2),
  10270. workerId = _ref2[0],
  10271. networkStream = _ref2[1];
  10272. if (task.destroyed) {
  10273. throw new Error("Loading aborted");
  10274. }
  10275. var messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port);
  10276. messageHandler.postMessageTransfers = worker.postMessageTransfers;
  10277. var transport = new WorkerTransport(messageHandler, task, networkStream, params);
  10278. task._transport = transport;
  10279. messageHandler.send("Ready", null);
  10280. });
  10281. })["catch"](task._capability.reject);
  10282. return task;
  10283. }
  10284. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  10285. if (worker.destroyed) {
  10286. return Promise.reject(new Error("Worker was destroyed"));
  10287. }
  10288. if (pdfDataRangeTransport) {
  10289. source.length = pdfDataRangeTransport.length;
  10290. source.initialData = pdfDataRangeTransport.initialData;
  10291. source.progressiveDone = pdfDataRangeTransport.progressiveDone;
  10292. }
  10293. return worker.messageHandler.sendWithPromise("GetDocRequest", {
  10294. docId: docId,
  10295. apiVersion: '2.7.570',
  10296. source: {
  10297. data: source.data,
  10298. url: source.url,
  10299. password: source.password,
  10300. disableAutoFetch: source.disableAutoFetch,
  10301. rangeChunkSize: source.rangeChunkSize,
  10302. length: source.length
  10303. },
  10304. maxImageSize: source.maxImageSize,
  10305. disableFontFace: source.disableFontFace,
  10306. postMessageTransfers: worker.postMessageTransfers,
  10307. docBaseUrl: source.docBaseUrl,
  10308. ignoreErrors: source.ignoreErrors,
  10309. isEvalSupported: source.isEvalSupported,
  10310. fontExtraProperties: source.fontExtraProperties
  10311. }).then(function (workerId) {
  10312. if (worker.destroyed) {
  10313. throw new Error("Worker was destroyed");
  10314. }
  10315. return workerId;
  10316. });
  10317. }
  10318. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  10319. var nextDocumentId = 0;
  10320. var PDFDocumentLoadingTask = /*#__PURE__*/function () {
  10321. function PDFDocumentLoadingTask() {
  10322. _classCallCheck(this, PDFDocumentLoadingTask);
  10323. this._capability = (0, _util.createPromiseCapability)();
  10324. this._transport = null;
  10325. this._worker = null;
  10326. this.docId = "d" + nextDocumentId++;
  10327. this.destroyed = false;
  10328. this.onPassword = null;
  10329. this.onProgress = null;
  10330. this.onUnsupportedFeature = null;
  10331. }
  10332. _createClass(PDFDocumentLoadingTask, [{
  10333. key: "destroy",
  10334. value: function destroy() {
  10335. var _this = this;
  10336. this.destroyed = true;
  10337. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  10338. return transportDestroyed.then(function () {
  10339. _this._transport = null;
  10340. if (_this._worker) {
  10341. _this._worker.destroy();
  10342. _this._worker = null;
  10343. }
  10344. });
  10345. }
  10346. }, {
  10347. key: "promise",
  10348. get: function get() {
  10349. return this._capability.promise;
  10350. }
  10351. }]);
  10352. return PDFDocumentLoadingTask;
  10353. }();
  10354. return PDFDocumentLoadingTask;
  10355. }();
  10356. var PDFDataRangeTransport = /*#__PURE__*/function () {
  10357. function PDFDataRangeTransport(length, initialData) {
  10358. var progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10359. _classCallCheck(this, PDFDataRangeTransport);
  10360. this.length = length;
  10361. this.initialData = initialData;
  10362. this.progressiveDone = progressiveDone;
  10363. this._rangeListeners = [];
  10364. this._progressListeners = [];
  10365. this._progressiveReadListeners = [];
  10366. this._progressiveDoneListeners = [];
  10367. this._readyCapability = (0, _util.createPromiseCapability)();
  10368. }
  10369. _createClass(PDFDataRangeTransport, [{
  10370. key: "addRangeListener",
  10371. value: function addRangeListener(listener) {
  10372. this._rangeListeners.push(listener);
  10373. }
  10374. }, {
  10375. key: "addProgressListener",
  10376. value: function addProgressListener(listener) {
  10377. this._progressListeners.push(listener);
  10378. }
  10379. }, {
  10380. key: "addProgressiveReadListener",
  10381. value: function addProgressiveReadListener(listener) {
  10382. this._progressiveReadListeners.push(listener);
  10383. }
  10384. }, {
  10385. key: "addProgressiveDoneListener",
  10386. value: function addProgressiveDoneListener(listener) {
  10387. this._progressiveDoneListeners.push(listener);
  10388. }
  10389. }, {
  10390. key: "onDataRange",
  10391. value: function onDataRange(begin, chunk) {
  10392. var _iterator = _createForOfIteratorHelper(this._rangeListeners),
  10393. _step;
  10394. try {
  10395. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10396. var listener = _step.value;
  10397. listener(begin, chunk);
  10398. }
  10399. } catch (err) {
  10400. _iterator.e(err);
  10401. } finally {
  10402. _iterator.f();
  10403. }
  10404. }
  10405. }, {
  10406. key: "onDataProgress",
  10407. value: function onDataProgress(loaded, total) {
  10408. var _this2 = this;
  10409. this._readyCapability.promise.then(function () {
  10410. var _iterator2 = _createForOfIteratorHelper(_this2._progressListeners),
  10411. _step2;
  10412. try {
  10413. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  10414. var listener = _step2.value;
  10415. listener(loaded, total);
  10416. }
  10417. } catch (err) {
  10418. _iterator2.e(err);
  10419. } finally {
  10420. _iterator2.f();
  10421. }
  10422. });
  10423. }
  10424. }, {
  10425. key: "onDataProgressiveRead",
  10426. value: function onDataProgressiveRead(chunk) {
  10427. var _this3 = this;
  10428. this._readyCapability.promise.then(function () {
  10429. var _iterator3 = _createForOfIteratorHelper(_this3._progressiveReadListeners),
  10430. _step3;
  10431. try {
  10432. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  10433. var listener = _step3.value;
  10434. listener(chunk);
  10435. }
  10436. } catch (err) {
  10437. _iterator3.e(err);
  10438. } finally {
  10439. _iterator3.f();
  10440. }
  10441. });
  10442. }
  10443. }, {
  10444. key: "onDataProgressiveDone",
  10445. value: function onDataProgressiveDone() {
  10446. var _this4 = this;
  10447. this._readyCapability.promise.then(function () {
  10448. var _iterator4 = _createForOfIteratorHelper(_this4._progressiveDoneListeners),
  10449. _step4;
  10450. try {
  10451. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  10452. var listener = _step4.value;
  10453. listener();
  10454. }
  10455. } catch (err) {
  10456. _iterator4.e(err);
  10457. } finally {
  10458. _iterator4.f();
  10459. }
  10460. });
  10461. }
  10462. }, {
  10463. key: "transportReady",
  10464. value: function transportReady() {
  10465. this._readyCapability.resolve();
  10466. }
  10467. }, {
  10468. key: "requestDataRange",
  10469. value: function requestDataRange(begin, end) {
  10470. (0, _util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange");
  10471. }
  10472. }, {
  10473. key: "abort",
  10474. value: function abort() {}
  10475. }]);
  10476. return PDFDataRangeTransport;
  10477. }();
  10478. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  10479. var PDFDocumentProxy = /*#__PURE__*/function () {
  10480. function PDFDocumentProxy(pdfInfo, transport) {
  10481. _classCallCheck(this, PDFDocumentProxy);
  10482. this._pdfInfo = pdfInfo;
  10483. this._transport = transport;
  10484. }
  10485. _createClass(PDFDocumentProxy, [{
  10486. key: "getPage",
  10487. value: function getPage(pageNumber) {
  10488. return this._transport.getPage(pageNumber);
  10489. }
  10490. }, {
  10491. key: "getPageIndex",
  10492. value: function getPageIndex(ref) {
  10493. return this._transport.getPageIndex(ref);
  10494. }
  10495. }, {
  10496. key: "getDestinations",
  10497. value: function getDestinations() {
  10498. return this._transport.getDestinations();
  10499. }
  10500. }, {
  10501. key: "getDestination",
  10502. value: function getDestination(id) {
  10503. return this._transport.getDestination(id);
  10504. }
  10505. }, {
  10506. key: "getPageLabels",
  10507. value: function getPageLabels() {
  10508. return this._transport.getPageLabels();
  10509. }
  10510. }, {
  10511. key: "getPageLayout",
  10512. value: function getPageLayout() {
  10513. return this._transport.getPageLayout();
  10514. }
  10515. }, {
  10516. key: "getPageMode",
  10517. value: function getPageMode() {
  10518. return this._transport.getPageMode();
  10519. }
  10520. }, {
  10521. key: "getViewerPreferences",
  10522. value: function getViewerPreferences() {
  10523. return this._transport.getViewerPreferences();
  10524. }
  10525. }, {
  10526. key: "getOpenAction",
  10527. value: function getOpenAction() {
  10528. return this._transport.getOpenAction();
  10529. }
  10530. }, {
  10531. key: "getAttachments",
  10532. value: function getAttachments() {
  10533. return this._transport.getAttachments();
  10534. }
  10535. }, {
  10536. key: "getJavaScript",
  10537. value: function getJavaScript() {
  10538. return this._transport.getJavaScript();
  10539. }
  10540. }, {
  10541. key: "getJSActions",
  10542. value: function getJSActions() {
  10543. return this._transport.getDocJSActions();
  10544. }
  10545. }, {
  10546. key: "getOutline",
  10547. value: function getOutline() {
  10548. return this._transport.getOutline();
  10549. }
  10550. }, {
  10551. key: "getOptionalContentConfig",
  10552. value: function getOptionalContentConfig() {
  10553. return this._transport.getOptionalContentConfig();
  10554. }
  10555. }, {
  10556. key: "getPermissions",
  10557. value: function getPermissions() {
  10558. return this._transport.getPermissions();
  10559. }
  10560. }, {
  10561. key: "getMetadata",
  10562. value: function getMetadata() {
  10563. return this._transport.getMetadata();
  10564. }
  10565. }, {
  10566. key: "getMarkInfo",
  10567. value: function getMarkInfo() {
  10568. return this._transport.getMarkInfo();
  10569. }
  10570. }, {
  10571. key: "getData",
  10572. value: function getData() {
  10573. return this._transport.getData();
  10574. }
  10575. }, {
  10576. key: "getDownloadInfo",
  10577. value: function getDownloadInfo() {
  10578. return this._transport.downloadInfoCapability.promise;
  10579. }
  10580. }, {
  10581. key: "getStats",
  10582. value: function getStats() {
  10583. return this._transport.getStats();
  10584. }
  10585. }, {
  10586. key: "cleanup",
  10587. value: function cleanup() {
  10588. return this._transport.startCleanup();
  10589. }
  10590. }, {
  10591. key: "destroy",
  10592. value: function destroy() {
  10593. return this.loadingTask.destroy();
  10594. }
  10595. }, {
  10596. key: "saveDocument",
  10597. value: function saveDocument(annotationStorage) {
  10598. return this._transport.saveDocument(annotationStorage);
  10599. }
  10600. }, {
  10601. key: "getFieldObjects",
  10602. value: function getFieldObjects() {
  10603. return this._transport.getFieldObjects();
  10604. }
  10605. }, {
  10606. key: "hasJSActions",
  10607. value: function hasJSActions() {
  10608. return this._transport.hasJSActions();
  10609. }
  10610. }, {
  10611. key: "getCalculationOrderIds",
  10612. value: function getCalculationOrderIds() {
  10613. return this._transport.getCalculationOrderIds();
  10614. }
  10615. }, {
  10616. key: "annotationStorage",
  10617. get: function get() {
  10618. return (0, _util.shadow)(this, "annotationStorage", new _annotation_storage.AnnotationStorage());
  10619. }
  10620. }, {
  10621. key: "numPages",
  10622. get: function get() {
  10623. return this._pdfInfo.numPages;
  10624. }
  10625. }, {
  10626. key: "fingerprint",
  10627. get: function get() {
  10628. return this._pdfInfo.fingerprint;
  10629. }
  10630. }, {
  10631. key: "loadingParams",
  10632. get: function get() {
  10633. return this._transport.loadingParams;
  10634. }
  10635. }, {
  10636. key: "loadingTask",
  10637. get: function get() {
  10638. return this._transport.loadingTask;
  10639. }
  10640. }]);
  10641. return PDFDocumentProxy;
  10642. }();
  10643. exports.PDFDocumentProxy = PDFDocumentProxy;
  10644. var PDFPageProxy = /*#__PURE__*/function () {
  10645. function PDFPageProxy(pageIndex, pageInfo, transport, ownerDocument) {
  10646. var pdfBug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  10647. _classCallCheck(this, PDFPageProxy);
  10648. this._pageIndex = pageIndex;
  10649. this._pageInfo = pageInfo;
  10650. this._ownerDocument = ownerDocument;
  10651. this._transport = transport;
  10652. this._stats = pdfBug ? new _display_utils.StatTimer() : null;
  10653. this._pdfBug = pdfBug;
  10654. this.commonObjs = transport.commonObjs;
  10655. this.objs = new PDFObjects();
  10656. this.cleanupAfterRender = false;
  10657. this.pendingCleanup = false;
  10658. this._intentStates = new Map();
  10659. this.destroyed = false;
  10660. }
  10661. _createClass(PDFPageProxy, [{
  10662. key: "getViewport",
  10663. value: function getViewport() {
  10664. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  10665. scale = _ref3.scale,
  10666. _ref3$rotation = _ref3.rotation,
  10667. rotation = _ref3$rotation === void 0 ? this.rotate : _ref3$rotation,
  10668. _ref3$offsetX = _ref3.offsetX,
  10669. offsetX = _ref3$offsetX === void 0 ? 0 : _ref3$offsetX,
  10670. _ref3$offsetY = _ref3.offsetY,
  10671. offsetY = _ref3$offsetY === void 0 ? 0 : _ref3$offsetY,
  10672. _ref3$dontFlip = _ref3.dontFlip,
  10673. dontFlip = _ref3$dontFlip === void 0 ? false : _ref3$dontFlip;
  10674. return new _display_utils.PageViewport({
  10675. viewBox: this.view,
  10676. scale: scale,
  10677. rotation: rotation,
  10678. offsetX: offsetX,
  10679. offsetY: offsetY,
  10680. dontFlip: dontFlip
  10681. });
  10682. }
  10683. }, {
  10684. key: "getAnnotations",
  10685. value: function getAnnotations() {
  10686. var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  10687. _ref4$intent = _ref4.intent,
  10688. intent = _ref4$intent === void 0 ? null : _ref4$intent;
  10689. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  10690. this.annotationsPromise = this._transport.getAnnotations(this._pageIndex, intent);
  10691. this.annotationsIntent = intent;
  10692. }
  10693. return this.annotationsPromise;
  10694. }
  10695. }, {
  10696. key: "getJSActions",
  10697. value: function getJSActions() {
  10698. return this._jsActionsPromise || (this._jsActionsPromise = this._transport.getPageJSActions(this._pageIndex));
  10699. }
  10700. }, {
  10701. key: "render",
  10702. value: function render(_ref5) {
  10703. var _this5 = this;
  10704. var canvasContext = _ref5.canvasContext,
  10705. viewport = _ref5.viewport,
  10706. _ref5$intent = _ref5.intent,
  10707. intent = _ref5$intent === void 0 ? "display" : _ref5$intent,
  10708. _ref5$enableWebGL = _ref5.enableWebGL,
  10709. enableWebGL = _ref5$enableWebGL === void 0 ? false : _ref5$enableWebGL,
  10710. _ref5$renderInteracti = _ref5.renderInteractiveForms,
  10711. renderInteractiveForms = _ref5$renderInteracti === void 0 ? false : _ref5$renderInteracti,
  10712. _ref5$transform = _ref5.transform,
  10713. transform = _ref5$transform === void 0 ? null : _ref5$transform,
  10714. _ref5$imageLayer = _ref5.imageLayer,
  10715. imageLayer = _ref5$imageLayer === void 0 ? null : _ref5$imageLayer,
  10716. _ref5$canvasFactory = _ref5.canvasFactory,
  10717. canvasFactory = _ref5$canvasFactory === void 0 ? null : _ref5$canvasFactory,
  10718. _ref5$background = _ref5.background,
  10719. background = _ref5$background === void 0 ? null : _ref5$background,
  10720. _ref5$annotationStora = _ref5.annotationStorage,
  10721. annotationStorage = _ref5$annotationStora === void 0 ? null : _ref5$annotationStora,
  10722. _ref5$optionalContent = _ref5.optionalContentConfigPromise,
  10723. optionalContentConfigPromise = _ref5$optionalContent === void 0 ? null : _ref5$optionalContent;
  10724. if (this._stats) {
  10725. this._stats.time("Overall");
  10726. }
  10727. var renderingIntent = intent === "print" ? "print" : "display";
  10728. this.pendingCleanup = false;
  10729. if (!optionalContentConfigPromise) {
  10730. optionalContentConfigPromise = this._transport.getOptionalContentConfig();
  10731. }
  10732. var intentState = this._intentStates.get(renderingIntent);
  10733. if (!intentState) {
  10734. intentState = Object.create(null);
  10735. this._intentStates.set(renderingIntent, intentState);
  10736. }
  10737. if (intentState.streamReaderCancelTimeout) {
  10738. clearTimeout(intentState.streamReaderCancelTimeout);
  10739. intentState.streamReaderCancelTimeout = null;
  10740. }
  10741. var canvasFactoryInstance = canvasFactory || new DefaultCanvasFactory({
  10742. ownerDocument: this._ownerDocument
  10743. });
  10744. var webGLContext = new _webgl.WebGLContext({
  10745. enable: enableWebGL
  10746. });
  10747. if (!intentState.displayReadyCapability) {
  10748. intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
  10749. intentState.operatorList = {
  10750. fnArray: [],
  10751. argsArray: [],
  10752. lastChunk: false
  10753. };
  10754. if (this._stats) {
  10755. this._stats.time("Page Request");
  10756. }
  10757. this._pumpOperatorList({
  10758. pageIndex: this._pageIndex,
  10759. intent: renderingIntent,
  10760. renderInteractiveForms: renderInteractiveForms === true,
  10761. annotationStorage: (annotationStorage === null || annotationStorage === void 0 ? void 0 : annotationStorage.getAll()) || null
  10762. });
  10763. }
  10764. var complete = function complete(error) {
  10765. var i = intentState.renderTasks.indexOf(internalRenderTask);
  10766. if (i >= 0) {
  10767. intentState.renderTasks.splice(i, 1);
  10768. }
  10769. if (_this5.cleanupAfterRender || renderingIntent === "print") {
  10770. _this5.pendingCleanup = true;
  10771. }
  10772. _this5._tryCleanup();
  10773. if (error) {
  10774. internalRenderTask.capability.reject(error);
  10775. _this5._abortOperatorList({
  10776. intentState: intentState,
  10777. reason: error
  10778. });
  10779. } else {
  10780. internalRenderTask.capability.resolve();
  10781. }
  10782. if (_this5._stats) {
  10783. _this5._stats.timeEnd("Rendering");
  10784. _this5._stats.timeEnd("Overall");
  10785. }
  10786. };
  10787. var internalRenderTask = new InternalRenderTask({
  10788. callback: complete,
  10789. params: {
  10790. canvasContext: canvasContext,
  10791. viewport: viewport,
  10792. transform: transform,
  10793. imageLayer: imageLayer,
  10794. background: background
  10795. },
  10796. objs: this.objs,
  10797. commonObjs: this.commonObjs,
  10798. operatorList: intentState.operatorList,
  10799. pageIndex: this._pageIndex,
  10800. canvasFactory: canvasFactoryInstance,
  10801. webGLContext: webGLContext,
  10802. useRequestAnimationFrame: renderingIntent !== "print",
  10803. pdfBug: this._pdfBug
  10804. });
  10805. if (!intentState.renderTasks) {
  10806. intentState.renderTasks = [];
  10807. }
  10808. intentState.renderTasks.push(internalRenderTask);
  10809. var renderTask = internalRenderTask.task;
  10810. Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(function (_ref6) {
  10811. var _ref7 = _slicedToArray(_ref6, 2),
  10812. transparency = _ref7[0],
  10813. optionalContentConfig = _ref7[1];
  10814. if (_this5.pendingCleanup) {
  10815. complete();
  10816. return;
  10817. }
  10818. if (_this5._stats) {
  10819. _this5._stats.time("Rendering");
  10820. }
  10821. internalRenderTask.initializeGraphics({
  10822. transparency: transparency,
  10823. optionalContentConfig: optionalContentConfig
  10824. });
  10825. internalRenderTask.operatorListChanged();
  10826. })["catch"](complete);
  10827. return renderTask;
  10828. }
  10829. }, {
  10830. key: "getOperatorList",
  10831. value: function getOperatorList() {
  10832. function operatorListChanged() {
  10833. if (intentState.operatorList.lastChunk) {
  10834. intentState.opListReadCapability.resolve(intentState.operatorList);
  10835. var i = intentState.renderTasks.indexOf(opListTask);
  10836. if (i >= 0) {
  10837. intentState.renderTasks.splice(i, 1);
  10838. }
  10839. }
  10840. }
  10841. var renderingIntent = "oplist";
  10842. var intentState = this._intentStates.get(renderingIntent);
  10843. if (!intentState) {
  10844. intentState = Object.create(null);
  10845. this._intentStates.set(renderingIntent, intentState);
  10846. }
  10847. var opListTask;
  10848. if (!intentState.opListReadCapability) {
  10849. opListTask = Object.create(null);
  10850. opListTask.operatorListChanged = operatorListChanged;
  10851. intentState.opListReadCapability = (0, _util.createPromiseCapability)();
  10852. intentState.renderTasks = [];
  10853. intentState.renderTasks.push(opListTask);
  10854. intentState.operatorList = {
  10855. fnArray: [],
  10856. argsArray: [],
  10857. lastChunk: false
  10858. };
  10859. if (this._stats) {
  10860. this._stats.time("Page Request");
  10861. }
  10862. this._pumpOperatorList({
  10863. pageIndex: this._pageIndex,
  10864. intent: renderingIntent
  10865. });
  10866. }
  10867. return intentState.opListReadCapability.promise;
  10868. }
  10869. }, {
  10870. key: "streamTextContent",
  10871. value: function streamTextContent() {
  10872. var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  10873. _ref8$normalizeWhites = _ref8.normalizeWhitespace,
  10874. normalizeWhitespace = _ref8$normalizeWhites === void 0 ? false : _ref8$normalizeWhites,
  10875. _ref8$disableCombineT = _ref8.disableCombineTextItems,
  10876. disableCombineTextItems = _ref8$disableCombineT === void 0 ? false : _ref8$disableCombineT;
  10877. var TEXT_CONTENT_CHUNK_SIZE = 100;
  10878. return this._transport.messageHandler.sendWithStream("GetTextContent", {
  10879. pageIndex: this._pageIndex,
  10880. normalizeWhitespace: normalizeWhitespace === true,
  10881. combineTextItems: disableCombineTextItems !== true
  10882. }, {
  10883. highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
  10884. size: function size(textContent) {
  10885. return textContent.items.length;
  10886. }
  10887. });
  10888. }
  10889. }, {
  10890. key: "getTextContent",
  10891. value: function getTextContent() {
  10892. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10893. var readableStream = this.streamTextContent(params);
  10894. return new Promise(function (resolve, reject) {
  10895. function pump() {
  10896. reader.read().then(function (_ref9) {
  10897. var _textContent$items;
  10898. var value = _ref9.value,
  10899. done = _ref9.done;
  10900. if (done) {
  10901. resolve(textContent);
  10902. return;
  10903. }
  10904. Object.assign(textContent.styles, value.styles);
  10905. (_textContent$items = textContent.items).push.apply(_textContent$items, _toConsumableArray(value.items));
  10906. pump();
  10907. }, reject);
  10908. }
  10909. var reader = readableStream.getReader();
  10910. var textContent = {
  10911. items: [],
  10912. styles: Object.create(null)
  10913. };
  10914. pump();
  10915. });
  10916. }
  10917. }, {
  10918. key: "_destroy",
  10919. value: function _destroy() {
  10920. this.destroyed = true;
  10921. this._transport.pageCache[this._pageIndex] = null;
  10922. var waitOn = [];
  10923. var _iterator5 = _createForOfIteratorHelper(this._intentStates),
  10924. _step5;
  10925. try {
  10926. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  10927. var _step5$value = _slicedToArray(_step5.value, 2),
  10928. intent = _step5$value[0],
  10929. intentState = _step5$value[1];
  10930. this._abortOperatorList({
  10931. intentState: intentState,
  10932. reason: new Error("Page was destroyed."),
  10933. force: true
  10934. });
  10935. if (intent === "oplist") {
  10936. continue;
  10937. }
  10938. var _iterator6 = _createForOfIteratorHelper(intentState.renderTasks),
  10939. _step6;
  10940. try {
  10941. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  10942. var internalRenderTask = _step6.value;
  10943. waitOn.push(internalRenderTask.completed);
  10944. internalRenderTask.cancel();
  10945. }
  10946. } catch (err) {
  10947. _iterator6.e(err);
  10948. } finally {
  10949. _iterator6.f();
  10950. }
  10951. }
  10952. } catch (err) {
  10953. _iterator5.e(err);
  10954. } finally {
  10955. _iterator5.f();
  10956. }
  10957. this.objs.clear();
  10958. this.annotationsPromise = null;
  10959. this._jsActionsPromise = null;
  10960. this.pendingCleanup = false;
  10961. return Promise.all(waitOn);
  10962. }
  10963. }, {
  10964. key: "cleanup",
  10965. value: function cleanup() {
  10966. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10967. this.pendingCleanup = true;
  10968. return this._tryCleanup(resetStats);
  10969. }
  10970. }, {
  10971. key: "_tryCleanup",
  10972. value: function _tryCleanup() {
  10973. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10974. if (!this.pendingCleanup) {
  10975. return false;
  10976. }
  10977. var _iterator7 = _createForOfIteratorHelper(this._intentStates.values()),
  10978. _step7;
  10979. try {
  10980. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  10981. var _step7$value = _step7.value,
  10982. renderTasks = _step7$value.renderTasks,
  10983. operatorList = _step7$value.operatorList;
  10984. if (renderTasks.length !== 0 || !operatorList.lastChunk) {
  10985. return false;
  10986. }
  10987. }
  10988. } catch (err) {
  10989. _iterator7.e(err);
  10990. } finally {
  10991. _iterator7.f();
  10992. }
  10993. this._intentStates.clear();
  10994. this.objs.clear();
  10995. this.annotationsPromise = null;
  10996. this._jsActionsPromise = null;
  10997. if (resetStats && this._stats) {
  10998. this._stats = new _display_utils.StatTimer();
  10999. }
  11000. this.pendingCleanup = false;
  11001. return true;
  11002. }
  11003. }, {
  11004. key: "_startRenderPage",
  11005. value: function _startRenderPage(transparency, intent) {
  11006. var intentState = this._intentStates.get(intent);
  11007. if (!intentState) {
  11008. return;
  11009. }
  11010. if (this._stats) {
  11011. this._stats.timeEnd("Page Request");
  11012. }
  11013. if (intentState.displayReadyCapability) {
  11014. intentState.displayReadyCapability.resolve(transparency);
  11015. }
  11016. }
  11017. }, {
  11018. key: "_renderPageChunk",
  11019. value: function _renderPageChunk(operatorListChunk, intentState) {
  11020. for (var i = 0, ii = operatorListChunk.length; i < ii; i++) {
  11021. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  11022. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  11023. }
  11024. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  11025. for (var _i2 = 0; _i2 < intentState.renderTasks.length; _i2++) {
  11026. intentState.renderTasks[_i2].operatorListChanged();
  11027. }
  11028. if (operatorListChunk.lastChunk) {
  11029. this._tryCleanup();
  11030. }
  11031. }
  11032. }, {
  11033. key: "_pumpOperatorList",
  11034. value: function _pumpOperatorList(args) {
  11035. var _this6 = this;
  11036. (0, _util.assert)(args.intent, 'PDFPageProxy._pumpOperatorList: Expected "intent" argument.');
  11037. var readableStream = this._transport.messageHandler.sendWithStream("GetOperatorList", args);
  11038. var reader = readableStream.getReader();
  11039. var intentState = this._intentStates.get(args.intent);
  11040. intentState.streamReader = reader;
  11041. var pump = function pump() {
  11042. reader.read().then(function (_ref10) {
  11043. var value = _ref10.value,
  11044. done = _ref10.done;
  11045. if (done) {
  11046. intentState.streamReader = null;
  11047. return;
  11048. }
  11049. if (_this6._transport.destroyed) {
  11050. return;
  11051. }
  11052. _this6._renderPageChunk(value, intentState);
  11053. pump();
  11054. }, function (reason) {
  11055. intentState.streamReader = null;
  11056. if (_this6._transport.destroyed) {
  11057. return;
  11058. }
  11059. if (intentState.operatorList) {
  11060. intentState.operatorList.lastChunk = true;
  11061. for (var i = 0; i < intentState.renderTasks.length; i++) {
  11062. intentState.renderTasks[i].operatorListChanged();
  11063. }
  11064. _this6._tryCleanup();
  11065. }
  11066. if (intentState.displayReadyCapability) {
  11067. intentState.displayReadyCapability.reject(reason);
  11068. } else if (intentState.opListReadCapability) {
  11069. intentState.opListReadCapability.reject(reason);
  11070. } else {
  11071. throw reason;
  11072. }
  11073. });
  11074. };
  11075. pump();
  11076. }
  11077. }, {
  11078. key: "_abortOperatorList",
  11079. value: function _abortOperatorList(_ref11) {
  11080. var _this7 = this;
  11081. var intentState = _ref11.intentState,
  11082. reason = _ref11.reason,
  11083. _ref11$force = _ref11.force,
  11084. force = _ref11$force === void 0 ? false : _ref11$force;
  11085. (0, _util.assert)(reason instanceof Error || _typeof(reason) === "object" && reason !== null, 'PDFPageProxy._abortOperatorList: Expected "reason" argument.');
  11086. if (!intentState.streamReader) {
  11087. return;
  11088. }
  11089. if (!force) {
  11090. if (intentState.renderTasks.length !== 0) {
  11091. return;
  11092. }
  11093. if (reason instanceof _display_utils.RenderingCancelledException) {
  11094. intentState.streamReaderCancelTimeout = setTimeout(function () {
  11095. _this7._abortOperatorList({
  11096. intentState: intentState,
  11097. reason: reason,
  11098. force: true
  11099. });
  11100. intentState.streamReaderCancelTimeout = null;
  11101. }, RENDERING_CANCELLED_TIMEOUT);
  11102. return;
  11103. }
  11104. }
  11105. intentState.streamReader.cancel(new _util.AbortException(reason === null || reason === void 0 ? void 0 : reason.message));
  11106. intentState.streamReader = null;
  11107. if (this._transport.destroyed) {
  11108. return;
  11109. }
  11110. var _iterator8 = _createForOfIteratorHelper(this._intentStates),
  11111. _step8;
  11112. try {
  11113. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  11114. var _step8$value = _slicedToArray(_step8.value, 2),
  11115. intent = _step8$value[0],
  11116. curIntentState = _step8$value[1];
  11117. if (curIntentState === intentState) {
  11118. this._intentStates["delete"](intent);
  11119. break;
  11120. }
  11121. }
  11122. } catch (err) {
  11123. _iterator8.e(err);
  11124. } finally {
  11125. _iterator8.f();
  11126. }
  11127. this.cleanup();
  11128. }
  11129. }, {
  11130. key: "pageNumber",
  11131. get: function get() {
  11132. return this._pageIndex + 1;
  11133. }
  11134. }, {
  11135. key: "rotate",
  11136. get: function get() {
  11137. return this._pageInfo.rotate;
  11138. }
  11139. }, {
  11140. key: "ref",
  11141. get: function get() {
  11142. return this._pageInfo.ref;
  11143. }
  11144. }, {
  11145. key: "userUnit",
  11146. get: function get() {
  11147. return this._pageInfo.userUnit;
  11148. }
  11149. }, {
  11150. key: "view",
  11151. get: function get() {
  11152. return this._pageInfo.view;
  11153. }
  11154. }, {
  11155. key: "stats",
  11156. get: function get() {
  11157. return this._stats;
  11158. }
  11159. }]);
  11160. return PDFPageProxy;
  11161. }();
  11162. exports.PDFPageProxy = PDFPageProxy;
  11163. var LoopbackPort = /*#__PURE__*/function () {
  11164. function LoopbackPort() {
  11165. var defer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  11166. _classCallCheck(this, LoopbackPort);
  11167. this._listeners = [];
  11168. this._defer = defer;
  11169. this._deferred = Promise.resolve(undefined);
  11170. }
  11171. _createClass(LoopbackPort, [{
  11172. key: "postMessage",
  11173. value: function postMessage(obj, transfers) {
  11174. var _this8 = this;
  11175. function cloneValue(value) {
  11176. if (_typeof(value) !== "object" || value === null) {
  11177. return value;
  11178. }
  11179. if (cloned.has(value)) {
  11180. return cloned.get(value);
  11181. }
  11182. var buffer, result;
  11183. if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
  11184. if (transfers !== null && transfers !== void 0 && transfers.includes(buffer)) {
  11185. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  11186. } else {
  11187. result = new value.constructor(value);
  11188. }
  11189. cloned.set(value, result);
  11190. return result;
  11191. }
  11192. result = Array.isArray(value) ? [] : {};
  11193. cloned.set(value, result);
  11194. for (var i in value) {
  11195. var desc = void 0,
  11196. p = value;
  11197. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  11198. p = Object.getPrototypeOf(p);
  11199. }
  11200. if (typeof desc.value === "undefined") {
  11201. continue;
  11202. }
  11203. if (typeof desc.value === "function") {
  11204. if (value.hasOwnProperty && value.hasOwnProperty(i)) {
  11205. throw new Error("LoopbackPort.postMessage - cannot clone: ".concat(value[i]));
  11206. }
  11207. continue;
  11208. }
  11209. result[i] = cloneValue(desc.value);
  11210. }
  11211. return result;
  11212. }
  11213. if (!this._defer) {
  11214. this._listeners.forEach(function (listener) {
  11215. listener.call(_this8, {
  11216. data: obj
  11217. });
  11218. });
  11219. return;
  11220. }
  11221. var cloned = new WeakMap();
  11222. var e = {
  11223. data: cloneValue(obj)
  11224. };
  11225. this._deferred.then(function () {
  11226. _this8._listeners.forEach(function (listener) {
  11227. listener.call(_this8, e);
  11228. });
  11229. });
  11230. }
  11231. }, {
  11232. key: "addEventListener",
  11233. value: function addEventListener(name, listener) {
  11234. this._listeners.push(listener);
  11235. }
  11236. }, {
  11237. key: "removeEventListener",
  11238. value: function removeEventListener(name, listener) {
  11239. var i = this._listeners.indexOf(listener);
  11240. this._listeners.splice(i, 1);
  11241. }
  11242. }, {
  11243. key: "terminate",
  11244. value: function terminate() {
  11245. this._listeners.length = 0;
  11246. }
  11247. }]);
  11248. return LoopbackPort;
  11249. }();
  11250. exports.LoopbackPort = LoopbackPort;
  11251. var PDFWorker = function PDFWorkerClosure() {
  11252. var pdfWorkerPorts = new WeakMap();
  11253. var isWorkerDisabled = false;
  11254. var fallbackWorkerSrc;
  11255. var nextFakeWorkerId = 0;
  11256. var fakeWorkerCapability;
  11257. if (_is_node.isNodeJS && typeof require === "function") {
  11258. isWorkerDisabled = true;
  11259. fallbackWorkerSrc = "./pdf.worker.js";
  11260. } else if ((typeof document === "undefined" ? "undefined" : _typeof(document)) === "object" && "currentScript" in document) {
  11261. var _document$currentScri;
  11262. var pdfjsFilePath = (_document$currentScri = document.currentScript) === null || _document$currentScri === void 0 ? void 0 : _document$currentScri.src;
  11263. if (pdfjsFilePath) {
  11264. fallbackWorkerSrc = pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, ".worker$1$2");
  11265. }
  11266. }
  11267. function _getWorkerSrc() {
  11268. if (_worker_options.GlobalWorkerOptions.workerSrc) {
  11269. return _worker_options.GlobalWorkerOptions.workerSrc;
  11270. }
  11271. if (typeof fallbackWorkerSrc !== "undefined") {
  11272. if (!_is_node.isNodeJS) {
  11273. (0, _display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.');
  11274. }
  11275. return fallbackWorkerSrc;
  11276. }
  11277. throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
  11278. }
  11279. function getMainThreadWorkerMessageHandler() {
  11280. var mainWorkerMessageHandler;
  11281. try {
  11282. var _globalThis$pdfjsWork;
  11283. mainWorkerMessageHandler = (_globalThis$pdfjsWork = globalThis.pdfjsWorker) === null || _globalThis$pdfjsWork === void 0 ? void 0 : _globalThis$pdfjsWork.WorkerMessageHandler;
  11284. } catch (ex) {}
  11285. return mainWorkerMessageHandler || null;
  11286. }
  11287. function setupFakeWorkerGlobal() {
  11288. if (fakeWorkerCapability) {
  11289. return fakeWorkerCapability.promise;
  11290. }
  11291. fakeWorkerCapability = (0, _util.createPromiseCapability)();
  11292. var loader = /*#__PURE__*/function () {
  11293. var _ref12 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  11294. var mainWorkerMessageHandler, worker;
  11295. return _regenerator["default"].wrap(function _callee$(_context) {
  11296. while (1) {
  11297. switch (_context.prev = _context.next) {
  11298. case 0:
  11299. mainWorkerMessageHandler = getMainThreadWorkerMessageHandler();
  11300. if (!mainWorkerMessageHandler) {
  11301. _context.next = 3;
  11302. break;
  11303. }
  11304. return _context.abrupt("return", mainWorkerMessageHandler);
  11305. case 3:
  11306. if (!(_is_node.isNodeJS && typeof require === "function")) {
  11307. _context.next = 6;
  11308. break;
  11309. }
  11310. worker = eval("require")(_getWorkerSrc());
  11311. return _context.abrupt("return", worker.WorkerMessageHandler);
  11312. case 6:
  11313. _context.next = 8;
  11314. return (0, _display_utils.loadScript)(_getWorkerSrc());
  11315. case 8:
  11316. return _context.abrupt("return", window.pdfjsWorker.WorkerMessageHandler);
  11317. case 9:
  11318. case "end":
  11319. return _context.stop();
  11320. }
  11321. }
  11322. }, _callee);
  11323. }));
  11324. return function loader() {
  11325. return _ref12.apply(this, arguments);
  11326. };
  11327. }();
  11328. loader().then(fakeWorkerCapability.resolve, fakeWorkerCapability.reject);
  11329. return fakeWorkerCapability.promise;
  11330. }
  11331. function createCDNWrapper(url) {
  11332. var wrapper = "importScripts('" + url + "');";
  11333. return URL.createObjectURL(new Blob([wrapper]));
  11334. }
  11335. var PDFWorker = /*#__PURE__*/function () {
  11336. function PDFWorker() {
  11337. var _ref13 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  11338. _ref13$name = _ref13.name,
  11339. name = _ref13$name === void 0 ? null : _ref13$name,
  11340. _ref13$port = _ref13.port,
  11341. port = _ref13$port === void 0 ? null : _ref13$port,
  11342. _ref13$verbosity = _ref13.verbosity,
  11343. verbosity = _ref13$verbosity === void 0 ? (0, _util.getVerbosityLevel)() : _ref13$verbosity;
  11344. _classCallCheck(this, PDFWorker);
  11345. if (port && pdfWorkerPorts.has(port)) {
  11346. throw new Error("Cannot use more than one PDFWorker per port");
  11347. }
  11348. this.name = name;
  11349. this.destroyed = false;
  11350. this.postMessageTransfers = true;
  11351. this.verbosity = verbosity;
  11352. this._readyCapability = (0, _util.createPromiseCapability)();
  11353. this._port = null;
  11354. this._webWorker = null;
  11355. this._messageHandler = null;
  11356. if (port) {
  11357. pdfWorkerPorts.set(port, this);
  11358. this._initializeFromPort(port);
  11359. return;
  11360. }
  11361. this._initialize();
  11362. }
  11363. _createClass(PDFWorker, [{
  11364. key: "_initializeFromPort",
  11365. value: function _initializeFromPort(port) {
  11366. this._port = port;
  11367. this._messageHandler = new _message_handler.MessageHandler("main", "worker", port);
  11368. this._messageHandler.on("ready", function () {});
  11369. this._readyCapability.resolve();
  11370. }
  11371. }, {
  11372. key: "_initialize",
  11373. value: function _initialize() {
  11374. var _this9 = this;
  11375. if (typeof Worker !== "undefined" && !isWorkerDisabled && !getMainThreadWorkerMessageHandler()) {
  11376. var workerSrc = _getWorkerSrc();
  11377. try {
  11378. if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) {
  11379. workerSrc = createCDNWrapper(new URL(workerSrc, window.location).href);
  11380. }
  11381. var worker = new Worker(workerSrc);
  11382. var messageHandler = new _message_handler.MessageHandler("main", "worker", worker);
  11383. var terminateEarly = function terminateEarly() {
  11384. worker.removeEventListener("error", onWorkerError);
  11385. messageHandler.destroy();
  11386. worker.terminate();
  11387. if (_this9.destroyed) {
  11388. _this9._readyCapability.reject(new Error("Worker was destroyed"));
  11389. } else {
  11390. _this9._setupFakeWorker();
  11391. }
  11392. };
  11393. var onWorkerError = function onWorkerError() {
  11394. if (!_this9._webWorker) {
  11395. terminateEarly();
  11396. }
  11397. };
  11398. worker.addEventListener("error", onWorkerError);
  11399. messageHandler.on("test", function (data) {
  11400. worker.removeEventListener("error", onWorkerError);
  11401. if (_this9.destroyed) {
  11402. terminateEarly();
  11403. return;
  11404. }
  11405. if (data) {
  11406. _this9._messageHandler = messageHandler;
  11407. _this9._port = worker;
  11408. _this9._webWorker = worker;
  11409. if (!data.supportTransfers) {
  11410. _this9.postMessageTransfers = false;
  11411. }
  11412. _this9._readyCapability.resolve();
  11413. messageHandler.send("configure", {
  11414. verbosity: _this9.verbosity
  11415. });
  11416. } else {
  11417. _this9._setupFakeWorker();
  11418. messageHandler.destroy();
  11419. worker.terminate();
  11420. }
  11421. });
  11422. messageHandler.on("ready", function (data) {
  11423. worker.removeEventListener("error", onWorkerError);
  11424. if (_this9.destroyed) {
  11425. terminateEarly();
  11426. return;
  11427. }
  11428. try {
  11429. sendTest();
  11430. } catch (e) {
  11431. _this9._setupFakeWorker();
  11432. }
  11433. });
  11434. var sendTest = function sendTest() {
  11435. var testObj = new Uint8Array([_this9.postMessageTransfers ? 255 : 0]);
  11436. try {
  11437. messageHandler.send("test", testObj, [testObj.buffer]);
  11438. } catch (ex) {
  11439. (0, _util.warn)("Cannot use postMessage transfers.");
  11440. testObj[0] = 0;
  11441. messageHandler.send("test", testObj);
  11442. }
  11443. };
  11444. sendTest();
  11445. return;
  11446. } catch (e) {
  11447. (0, _util.info)("The worker has been disabled.");
  11448. }
  11449. }
  11450. this._setupFakeWorker();
  11451. }
  11452. }, {
  11453. key: "_setupFakeWorker",
  11454. value: function _setupFakeWorker() {
  11455. var _this10 = this;
  11456. if (!isWorkerDisabled) {
  11457. (0, _util.warn)("Setting up fake worker.");
  11458. isWorkerDisabled = true;
  11459. }
  11460. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  11461. if (_this10.destroyed) {
  11462. _this10._readyCapability.reject(new Error("Worker was destroyed"));
  11463. return;
  11464. }
  11465. var port = new LoopbackPort();
  11466. _this10._port = port;
  11467. var id = "fake" + nextFakeWorkerId++;
  11468. var workerHandler = new _message_handler.MessageHandler(id + "_worker", id, port);
  11469. WorkerMessageHandler.setup(workerHandler, port);
  11470. var messageHandler = new _message_handler.MessageHandler(id, id + "_worker", port);
  11471. _this10._messageHandler = messageHandler;
  11472. _this10._readyCapability.resolve();
  11473. messageHandler.send("configure", {
  11474. verbosity: _this10.verbosity
  11475. });
  11476. })["catch"](function (reason) {
  11477. _this10._readyCapability.reject(new Error("Setting up fake worker failed: \"".concat(reason.message, "\".")));
  11478. });
  11479. }
  11480. }, {
  11481. key: "destroy",
  11482. value: function destroy() {
  11483. this.destroyed = true;
  11484. if (this._webWorker) {
  11485. this._webWorker.terminate();
  11486. this._webWorker = null;
  11487. }
  11488. pdfWorkerPorts["delete"](this._port);
  11489. this._port = null;
  11490. if (this._messageHandler) {
  11491. this._messageHandler.destroy();
  11492. this._messageHandler = null;
  11493. }
  11494. }
  11495. }, {
  11496. key: "promise",
  11497. get: function get() {
  11498. return this._readyCapability.promise;
  11499. }
  11500. }, {
  11501. key: "port",
  11502. get: function get() {
  11503. return this._port;
  11504. }
  11505. }, {
  11506. key: "messageHandler",
  11507. get: function get() {
  11508. return this._messageHandler;
  11509. }
  11510. }], [{
  11511. key: "fromPort",
  11512. value: function fromPort(params) {
  11513. if (!params || !params.port) {
  11514. throw new Error("PDFWorker.fromPort - invalid method signature.");
  11515. }
  11516. if (pdfWorkerPorts.has(params.port)) {
  11517. return pdfWorkerPorts.get(params.port);
  11518. }
  11519. return new PDFWorker(params);
  11520. }
  11521. }, {
  11522. key: "getWorkerSrc",
  11523. value: function getWorkerSrc() {
  11524. return _getWorkerSrc();
  11525. }
  11526. }]);
  11527. return PDFWorker;
  11528. }();
  11529. return PDFWorker;
  11530. }();
  11531. exports.PDFWorker = PDFWorker;
  11532. var WorkerTransport = /*#__PURE__*/function () {
  11533. function WorkerTransport(messageHandler, loadingTask, networkStream, params) {
  11534. _classCallCheck(this, WorkerTransport);
  11535. this.messageHandler = messageHandler;
  11536. this.loadingTask = loadingTask;
  11537. this.commonObjs = new PDFObjects();
  11538. this.fontLoader = new _font_loader.FontLoader({
  11539. docId: loadingTask.docId,
  11540. onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
  11541. ownerDocument: params.ownerDocument
  11542. });
  11543. this._params = params;
  11544. this.CMapReaderFactory = new params.CMapReaderFactory({
  11545. baseUrl: params.cMapUrl,
  11546. isCompressed: params.cMapPacked
  11547. });
  11548. this.destroyed = false;
  11549. this.destroyCapability = null;
  11550. this._passwordCapability = null;
  11551. this._networkStream = networkStream;
  11552. this._fullReader = null;
  11553. this._lastProgress = null;
  11554. this.pageCache = [];
  11555. this.pagePromises = [];
  11556. this.downloadInfoCapability = (0, _util.createPromiseCapability)();
  11557. this.setupMessageHandler();
  11558. }
  11559. _createClass(WorkerTransport, [{
  11560. key: "destroy",
  11561. value: function destroy() {
  11562. var _this11 = this;
  11563. if (this.destroyCapability) {
  11564. return this.destroyCapability.promise;
  11565. }
  11566. this.destroyed = true;
  11567. this.destroyCapability = (0, _util.createPromiseCapability)();
  11568. if (this._passwordCapability) {
  11569. this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));
  11570. }
  11571. var waitOn = [];
  11572. this.pageCache.forEach(function (page) {
  11573. if (page) {
  11574. waitOn.push(page._destroy());
  11575. }
  11576. });
  11577. this.pageCache.length = 0;
  11578. this.pagePromises.length = 0;
  11579. var terminated = this.messageHandler.sendWithPromise("Terminate", null);
  11580. waitOn.push(terminated);
  11581. if (this.loadingTaskSettled) {
  11582. var annotationStorageResetModified = this.loadingTask.promise.then(function (pdfDocument) {
  11583. if (pdfDocument.hasOwnProperty("annotationStorage")) {
  11584. pdfDocument.annotationStorage.resetModified();
  11585. }
  11586. })["catch"](function () {});
  11587. waitOn.push(annotationStorageResetModified);
  11588. }
  11589. Promise.all(waitOn).then(function () {
  11590. _this11.commonObjs.clear();
  11591. _this11.fontLoader.clear();
  11592. _this11._hasJSActionsPromise = null;
  11593. if (_this11._networkStream) {
  11594. _this11._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated."));
  11595. }
  11596. if (_this11.messageHandler) {
  11597. _this11.messageHandler.destroy();
  11598. _this11.messageHandler = null;
  11599. }
  11600. _this11.destroyCapability.resolve();
  11601. }, this.destroyCapability.reject);
  11602. return this.destroyCapability.promise;
  11603. }
  11604. }, {
  11605. key: "setupMessageHandler",
  11606. value: function setupMessageHandler() {
  11607. var _this12 = this;
  11608. var messageHandler = this.messageHandler,
  11609. loadingTask = this.loadingTask;
  11610. messageHandler.on("GetReader", function (data, sink) {
  11611. (0, _util.assert)(_this12._networkStream, "GetReader - no `IPDFStream` instance available.");
  11612. _this12._fullReader = _this12._networkStream.getFullReader();
  11613. _this12._fullReader.onProgress = function (evt) {
  11614. _this12._lastProgress = {
  11615. loaded: evt.loaded,
  11616. total: evt.total
  11617. };
  11618. };
  11619. sink.onPull = function () {
  11620. _this12._fullReader.read().then(function (_ref14) {
  11621. var value = _ref14.value,
  11622. done = _ref14.done;
  11623. if (done) {
  11624. sink.close();
  11625. return;
  11626. }
  11627. (0, _util.assert)((0, _util.isArrayBuffer)(value), "GetReader - expected an ArrayBuffer.");
  11628. sink.enqueue(new Uint8Array(value), 1, [value]);
  11629. })["catch"](function (reason) {
  11630. sink.error(reason);
  11631. });
  11632. };
  11633. sink.onCancel = function (reason) {
  11634. _this12._fullReader.cancel(reason);
  11635. sink.ready["catch"](function (readyReason) {
  11636. if (_this12.destroyed) {
  11637. return;
  11638. }
  11639. throw readyReason;
  11640. });
  11641. };
  11642. });
  11643. messageHandler.on("ReaderHeadersReady", function (data) {
  11644. var headersCapability = (0, _util.createPromiseCapability)();
  11645. var fullReader = _this12._fullReader;
  11646. fullReader.headersReady.then(function () {
  11647. if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
  11648. if (_this12._lastProgress && loadingTask.onProgress) {
  11649. loadingTask.onProgress(_this12._lastProgress);
  11650. }
  11651. fullReader.onProgress = function (evt) {
  11652. if (loadingTask.onProgress) {
  11653. loadingTask.onProgress({
  11654. loaded: evt.loaded,
  11655. total: evt.total
  11656. });
  11657. }
  11658. };
  11659. }
  11660. headersCapability.resolve({
  11661. isStreamingSupported: fullReader.isStreamingSupported,
  11662. isRangeSupported: fullReader.isRangeSupported,
  11663. contentLength: fullReader.contentLength
  11664. });
  11665. }, headersCapability.reject);
  11666. return headersCapability.promise;
  11667. });
  11668. messageHandler.on("GetRangeReader", function (data, sink) {
  11669. (0, _util.assert)(_this12._networkStream, "GetRangeReader - no `IPDFStream` instance available.");
  11670. var rangeReader = _this12._networkStream.getRangeReader(data.begin, data.end);
  11671. if (!rangeReader) {
  11672. sink.close();
  11673. return;
  11674. }
  11675. sink.onPull = function () {
  11676. rangeReader.read().then(function (_ref15) {
  11677. var value = _ref15.value,
  11678. done = _ref15.done;
  11679. if (done) {
  11680. sink.close();
  11681. return;
  11682. }
  11683. (0, _util.assert)((0, _util.isArrayBuffer)(value), "GetRangeReader - expected an ArrayBuffer.");
  11684. sink.enqueue(new Uint8Array(value), 1, [value]);
  11685. })["catch"](function (reason) {
  11686. sink.error(reason);
  11687. });
  11688. };
  11689. sink.onCancel = function (reason) {
  11690. rangeReader.cancel(reason);
  11691. sink.ready["catch"](function (readyReason) {
  11692. if (_this12.destroyed) {
  11693. return;
  11694. }
  11695. throw readyReason;
  11696. });
  11697. };
  11698. });
  11699. messageHandler.on("GetDoc", function (_ref16) {
  11700. var pdfInfo = _ref16.pdfInfo;
  11701. _this12._numPages = pdfInfo.numPages;
  11702. loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, _this12));
  11703. });
  11704. messageHandler.on("DocException", function (ex) {
  11705. var reason;
  11706. switch (ex.name) {
  11707. case "PasswordException":
  11708. reason = new _util.PasswordException(ex.message, ex.code);
  11709. break;
  11710. case "InvalidPDFException":
  11711. reason = new _util.InvalidPDFException(ex.message);
  11712. break;
  11713. case "MissingPDFException":
  11714. reason = new _util.MissingPDFException(ex.message);
  11715. break;
  11716. case "UnexpectedResponseException":
  11717. reason = new _util.UnexpectedResponseException(ex.message, ex.status);
  11718. break;
  11719. case "UnknownErrorException":
  11720. reason = new _util.UnknownErrorException(ex.message, ex.details);
  11721. break;
  11722. }
  11723. if (!(reason instanceof Error)) {
  11724. var msg = "DocException - expected a valid Error.";
  11725. (0, _util.warn)(msg);
  11726. }
  11727. loadingTask._capability.reject(reason);
  11728. });
  11729. messageHandler.on("PasswordRequest", function (exception) {
  11730. _this12._passwordCapability = (0, _util.createPromiseCapability)();
  11731. if (loadingTask.onPassword) {
  11732. var updatePassword = function updatePassword(password) {
  11733. _this12._passwordCapability.resolve({
  11734. password: password
  11735. });
  11736. };
  11737. try {
  11738. loadingTask.onPassword(updatePassword, exception.code);
  11739. } catch (ex) {
  11740. _this12._passwordCapability.reject(ex);
  11741. }
  11742. } else {
  11743. _this12._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
  11744. }
  11745. return _this12._passwordCapability.promise;
  11746. });
  11747. messageHandler.on("DataLoaded", function (data) {
  11748. if (loadingTask.onProgress) {
  11749. loadingTask.onProgress({
  11750. loaded: data.length,
  11751. total: data.length
  11752. });
  11753. }
  11754. _this12.downloadInfoCapability.resolve(data);
  11755. });
  11756. messageHandler.on("StartRenderPage", function (data) {
  11757. if (_this12.destroyed) {
  11758. return;
  11759. }
  11760. var page = _this12.pageCache[data.pageIndex];
  11761. page._startRenderPage(data.transparency, data.intent);
  11762. });
  11763. messageHandler.on("commonobj", function (data) {
  11764. var _globalThis$FontInspe;
  11765. if (_this12.destroyed) {
  11766. return;
  11767. }
  11768. var _data = _slicedToArray(data, 3),
  11769. id = _data[0],
  11770. type = _data[1],
  11771. exportedData = _data[2];
  11772. if (_this12.commonObjs.has(id)) {
  11773. return;
  11774. }
  11775. switch (type) {
  11776. case "Font":
  11777. var params = _this12._params;
  11778. if ("error" in exportedData) {
  11779. var exportedError = exportedData.error;
  11780. (0, _util.warn)("Error during font loading: ".concat(exportedError));
  11781. _this12.commonObjs.resolve(id, exportedError);
  11782. break;
  11783. }
  11784. var fontRegistry = null;
  11785. if (params.pdfBug && (_globalThis$FontInspe = globalThis.FontInspector) !== null && _globalThis$FontInspe !== void 0 && _globalThis$FontInspe.enabled) {
  11786. fontRegistry = {
  11787. registerFont: function registerFont(font, url) {
  11788. globalThis.FontInspector.fontAdded(font, url);
  11789. }
  11790. };
  11791. }
  11792. var font = new _font_loader.FontFaceObject(exportedData, {
  11793. isEvalSupported: params.isEvalSupported,
  11794. disableFontFace: params.disableFontFace,
  11795. ignoreErrors: params.ignoreErrors,
  11796. onUnsupportedFeature: _this12._onUnsupportedFeature.bind(_this12),
  11797. fontRegistry: fontRegistry
  11798. });
  11799. _this12.fontLoader.bind(font)["catch"](function (reason) {
  11800. return messageHandler.sendWithPromise("FontFallback", {
  11801. id: id
  11802. });
  11803. })["finally"](function () {
  11804. if (!params.fontExtraProperties && font.data) {
  11805. font.data = null;
  11806. }
  11807. _this12.commonObjs.resolve(id, font);
  11808. });
  11809. break;
  11810. case "FontPath":
  11811. case "Image":
  11812. _this12.commonObjs.resolve(id, exportedData);
  11813. break;
  11814. default:
  11815. throw new Error("Got unknown common object type ".concat(type));
  11816. }
  11817. });
  11818. messageHandler.on("obj", function (data) {
  11819. var _imageData$data;
  11820. if (_this12.destroyed) {
  11821. return undefined;
  11822. }
  11823. var _data2 = _slicedToArray(data, 4),
  11824. id = _data2[0],
  11825. pageIndex = _data2[1],
  11826. type = _data2[2],
  11827. imageData = _data2[3];
  11828. var pageProxy = _this12.pageCache[pageIndex];
  11829. if (pageProxy.objs.has(id)) {
  11830. return undefined;
  11831. }
  11832. switch (type) {
  11833. case "Image":
  11834. pageProxy.objs.resolve(id, imageData);
  11835. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  11836. if ((imageData === null || imageData === void 0 ? void 0 : (_imageData$data = imageData.data) === null || _imageData$data === void 0 ? void 0 : _imageData$data.length) > MAX_IMAGE_SIZE_TO_STORE) {
  11837. pageProxy.cleanupAfterRender = true;
  11838. }
  11839. break;
  11840. default:
  11841. throw new Error("Got unknown object type ".concat(type));
  11842. }
  11843. return undefined;
  11844. });
  11845. messageHandler.on("DocProgress", function (data) {
  11846. if (_this12.destroyed) {
  11847. return;
  11848. }
  11849. if (loadingTask.onProgress) {
  11850. loadingTask.onProgress({
  11851. loaded: data.loaded,
  11852. total: data.total
  11853. });
  11854. }
  11855. });
  11856. messageHandler.on("UnsupportedFeature", this._onUnsupportedFeature.bind(this));
  11857. messageHandler.on("FetchBuiltInCMap", function (data, sink) {
  11858. if (_this12.destroyed) {
  11859. sink.error(new Error("Worker was destroyed"));
  11860. return;
  11861. }
  11862. var fetched = false;
  11863. sink.onPull = function () {
  11864. if (fetched) {
  11865. sink.close();
  11866. return;
  11867. }
  11868. fetched = true;
  11869. _this12.CMapReaderFactory.fetch(data).then(function (builtInCMap) {
  11870. sink.enqueue(builtInCMap, 1, [builtInCMap.cMapData.buffer]);
  11871. })["catch"](function (reason) {
  11872. sink.error(reason);
  11873. });
  11874. };
  11875. });
  11876. }
  11877. }, {
  11878. key: "_onUnsupportedFeature",
  11879. value: function _onUnsupportedFeature(_ref17) {
  11880. var featureId = _ref17.featureId;
  11881. if (this.destroyed) {
  11882. return;
  11883. }
  11884. if (this.loadingTask.onUnsupportedFeature) {
  11885. this.loadingTask.onUnsupportedFeature(featureId);
  11886. }
  11887. }
  11888. }, {
  11889. key: "getData",
  11890. value: function getData() {
  11891. return this.messageHandler.sendWithPromise("GetData", null);
  11892. }
  11893. }, {
  11894. key: "getPage",
  11895. value: function getPage(pageNumber) {
  11896. var _this13 = this;
  11897. if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this._numPages) {
  11898. return Promise.reject(new Error("Invalid page request"));
  11899. }
  11900. var pageIndex = pageNumber - 1;
  11901. if (pageIndex in this.pagePromises) {
  11902. return this.pagePromises[pageIndex];
  11903. }
  11904. var promise = this.messageHandler.sendWithPromise("GetPage", {
  11905. pageIndex: pageIndex
  11906. }).then(function (pageInfo) {
  11907. if (_this13.destroyed) {
  11908. throw new Error("Transport destroyed");
  11909. }
  11910. var page = new PDFPageProxy(pageIndex, pageInfo, _this13, _this13._params.ownerDocument, _this13._params.pdfBug);
  11911. _this13.pageCache[pageIndex] = page;
  11912. return page;
  11913. });
  11914. this.pagePromises[pageIndex] = promise;
  11915. return promise;
  11916. }
  11917. }, {
  11918. key: "getPageIndex",
  11919. value: function getPageIndex(ref) {
  11920. return this.messageHandler.sendWithPromise("GetPageIndex", {
  11921. ref: ref
  11922. })["catch"](function (reason) {
  11923. return Promise.reject(new Error(reason));
  11924. });
  11925. }
  11926. }, {
  11927. key: "getAnnotations",
  11928. value: function getAnnotations(pageIndex, intent) {
  11929. return this.messageHandler.sendWithPromise("GetAnnotations", {
  11930. pageIndex: pageIndex,
  11931. intent: intent
  11932. });
  11933. }
  11934. }, {
  11935. key: "saveDocument",
  11936. value: function saveDocument(annotationStorage) {
  11937. var _this$_fullReader$fil, _this$_fullReader;
  11938. return this.messageHandler.sendWithPromise("SaveDocument", {
  11939. numPages: this._numPages,
  11940. annotationStorage: (annotationStorage === null || annotationStorage === void 0 ? void 0 : annotationStorage.getAll()) || null,
  11941. filename: (_this$_fullReader$fil = (_this$_fullReader = this._fullReader) === null || _this$_fullReader === void 0 ? void 0 : _this$_fullReader.filename) !== null && _this$_fullReader$fil !== void 0 ? _this$_fullReader$fil : null
  11942. })["finally"](function () {
  11943. if (annotationStorage) {
  11944. annotationStorage.resetModified();
  11945. }
  11946. });
  11947. }
  11948. }, {
  11949. key: "getFieldObjects",
  11950. value: function getFieldObjects() {
  11951. return this.messageHandler.sendWithPromise("GetFieldObjects", null);
  11952. }
  11953. }, {
  11954. key: "hasJSActions",
  11955. value: function hasJSActions() {
  11956. return this._hasJSActionsPromise || (this._hasJSActionsPromise = this.messageHandler.sendWithPromise("HasJSActions", null));
  11957. }
  11958. }, {
  11959. key: "getCalculationOrderIds",
  11960. value: function getCalculationOrderIds() {
  11961. return this.messageHandler.sendWithPromise("GetCalculationOrderIds", null);
  11962. }
  11963. }, {
  11964. key: "getDestinations",
  11965. value: function getDestinations() {
  11966. return this.messageHandler.sendWithPromise("GetDestinations", null);
  11967. }
  11968. }, {
  11969. key: "getDestination",
  11970. value: function getDestination(id) {
  11971. if (typeof id !== "string") {
  11972. return Promise.reject(new Error("Invalid destination request."));
  11973. }
  11974. return this.messageHandler.sendWithPromise("GetDestination", {
  11975. id: id
  11976. });
  11977. }
  11978. }, {
  11979. key: "getPageLabels",
  11980. value: function getPageLabels() {
  11981. return this.messageHandler.sendWithPromise("GetPageLabels", null);
  11982. }
  11983. }, {
  11984. key: "getPageLayout",
  11985. value: function getPageLayout() {
  11986. return this.messageHandler.sendWithPromise("GetPageLayout", null);
  11987. }
  11988. }, {
  11989. key: "getPageMode",
  11990. value: function getPageMode() {
  11991. return this.messageHandler.sendWithPromise("GetPageMode", null);
  11992. }
  11993. }, {
  11994. key: "getViewerPreferences",
  11995. value: function getViewerPreferences() {
  11996. return this.messageHandler.sendWithPromise("GetViewerPreferences", null);
  11997. }
  11998. }, {
  11999. key: "getOpenAction",
  12000. value: function getOpenAction() {
  12001. return this.messageHandler.sendWithPromise("GetOpenAction", null);
  12002. }
  12003. }, {
  12004. key: "getAttachments",
  12005. value: function getAttachments() {
  12006. return this.messageHandler.sendWithPromise("GetAttachments", null);
  12007. }
  12008. }, {
  12009. key: "getJavaScript",
  12010. value: function getJavaScript() {
  12011. return this.messageHandler.sendWithPromise("GetJavaScript", null);
  12012. }
  12013. }, {
  12014. key: "getDocJSActions",
  12015. value: function getDocJSActions() {
  12016. return this.messageHandler.sendWithPromise("GetDocJSActions", null);
  12017. }
  12018. }, {
  12019. key: "getPageJSActions",
  12020. value: function getPageJSActions(pageIndex) {
  12021. return this.messageHandler.sendWithPromise("GetPageJSActions", {
  12022. pageIndex: pageIndex
  12023. });
  12024. }
  12025. }, {
  12026. key: "getOutline",
  12027. value: function getOutline() {
  12028. return this.messageHandler.sendWithPromise("GetOutline", null);
  12029. }
  12030. }, {
  12031. key: "getOptionalContentConfig",
  12032. value: function getOptionalContentConfig() {
  12033. return this.messageHandler.sendWithPromise("GetOptionalContentConfig", null).then(function (results) {
  12034. return new _optional_content_config.OptionalContentConfig(results);
  12035. });
  12036. }
  12037. }, {
  12038. key: "getPermissions",
  12039. value: function getPermissions() {
  12040. return this.messageHandler.sendWithPromise("GetPermissions", null);
  12041. }
  12042. }, {
  12043. key: "getMetadata",
  12044. value: function getMetadata() {
  12045. var _this14 = this;
  12046. return this.messageHandler.sendWithPromise("GetMetadata", null).then(function (results) {
  12047. var _this14$_fullReader$f, _this14$_fullReader, _this14$_fullReader$c, _this14$_fullReader2;
  12048. return {
  12049. info: results[0],
  12050. metadata: results[1] ? new _metadata.Metadata(results[1]) : null,
  12051. contentDispositionFilename: (_this14$_fullReader$f = (_this14$_fullReader = _this14._fullReader) === null || _this14$_fullReader === void 0 ? void 0 : _this14$_fullReader.filename) !== null && _this14$_fullReader$f !== void 0 ? _this14$_fullReader$f : null,
  12052. contentLength: (_this14$_fullReader$c = (_this14$_fullReader2 = _this14._fullReader) === null || _this14$_fullReader2 === void 0 ? void 0 : _this14$_fullReader2.contentLength) !== null && _this14$_fullReader$c !== void 0 ? _this14$_fullReader$c : null
  12053. };
  12054. });
  12055. }
  12056. }, {
  12057. key: "getMarkInfo",
  12058. value: function getMarkInfo() {
  12059. return this.messageHandler.sendWithPromise("GetMarkInfo", null);
  12060. }
  12061. }, {
  12062. key: "getStats",
  12063. value: function getStats() {
  12064. return this.messageHandler.sendWithPromise("GetStats", null);
  12065. }
  12066. }, {
  12067. key: "startCleanup",
  12068. value: function startCleanup() {
  12069. var _this15 = this;
  12070. return this.messageHandler.sendWithPromise("Cleanup", null).then(function () {
  12071. for (var i = 0, ii = _this15.pageCache.length; i < ii; i++) {
  12072. var page = _this15.pageCache[i];
  12073. if (page) {
  12074. var cleanupSuccessful = page.cleanup();
  12075. if (!cleanupSuccessful) {
  12076. throw new Error("startCleanup: Page ".concat(i + 1, " is currently rendering."));
  12077. }
  12078. }
  12079. }
  12080. _this15.commonObjs.clear();
  12081. _this15.fontLoader.clear();
  12082. _this15._hasJSActionsPromise = null;
  12083. });
  12084. }
  12085. }, {
  12086. key: "loadingTaskSettled",
  12087. get: function get() {
  12088. return this.loadingTask._capability.settled;
  12089. }
  12090. }, {
  12091. key: "loadingParams",
  12092. get: function get() {
  12093. var params = this._params;
  12094. return (0, _util.shadow)(this, "loadingParams", {
  12095. disableAutoFetch: params.disableAutoFetch,
  12096. disableFontFace: params.disableFontFace
  12097. });
  12098. }
  12099. }]);
  12100. return WorkerTransport;
  12101. }();
  12102. var PDFObjects = /*#__PURE__*/function () {
  12103. function PDFObjects() {
  12104. _classCallCheck(this, PDFObjects);
  12105. this._objs = Object.create(null);
  12106. }
  12107. _createClass(PDFObjects, [{
  12108. key: "_ensureObj",
  12109. value: function _ensureObj(objId) {
  12110. if (this._objs[objId]) {
  12111. return this._objs[objId];
  12112. }
  12113. return this._objs[objId] = {
  12114. capability: (0, _util.createPromiseCapability)(),
  12115. data: null,
  12116. resolved: false
  12117. };
  12118. }
  12119. }, {
  12120. key: "get",
  12121. value: function get(objId) {
  12122. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  12123. if (callback) {
  12124. this._ensureObj(objId).capability.promise.then(callback);
  12125. return null;
  12126. }
  12127. var obj = this._objs[objId];
  12128. if (!obj || !obj.resolved) {
  12129. throw new Error("Requesting object that isn't resolved yet ".concat(objId, "."));
  12130. }
  12131. return obj.data;
  12132. }
  12133. }, {
  12134. key: "has",
  12135. value: function has(objId) {
  12136. var obj = this._objs[objId];
  12137. return (obj === null || obj === void 0 ? void 0 : obj.resolved) || false;
  12138. }
  12139. }, {
  12140. key: "resolve",
  12141. value: function resolve(objId, data) {
  12142. var obj = this._ensureObj(objId);
  12143. obj.resolved = true;
  12144. obj.data = data;
  12145. obj.capability.resolve(data);
  12146. }
  12147. }, {
  12148. key: "clear",
  12149. value: function clear() {
  12150. this._objs = Object.create(null);
  12151. }
  12152. }]);
  12153. return PDFObjects;
  12154. }();
  12155. var RenderTask = /*#__PURE__*/function () {
  12156. function RenderTask(internalRenderTask) {
  12157. _classCallCheck(this, RenderTask);
  12158. this._internalRenderTask = internalRenderTask;
  12159. this.onContinue = null;
  12160. }
  12161. _createClass(RenderTask, [{
  12162. key: "cancel",
  12163. value: function cancel() {
  12164. this._internalRenderTask.cancel();
  12165. }
  12166. }, {
  12167. key: "promise",
  12168. get: function get() {
  12169. return this._internalRenderTask.capability.promise;
  12170. }
  12171. }]);
  12172. return RenderTask;
  12173. }();
  12174. var InternalRenderTask = function InternalRenderTaskClosure() {
  12175. var canvasInRendering = new WeakSet();
  12176. var InternalRenderTask = /*#__PURE__*/function () {
  12177. function InternalRenderTask(_ref18) {
  12178. var callback = _ref18.callback,
  12179. params = _ref18.params,
  12180. objs = _ref18.objs,
  12181. commonObjs = _ref18.commonObjs,
  12182. operatorList = _ref18.operatorList,
  12183. pageIndex = _ref18.pageIndex,
  12184. canvasFactory = _ref18.canvasFactory,
  12185. webGLContext = _ref18.webGLContext,
  12186. _ref18$useRequestAnim = _ref18.useRequestAnimationFrame,
  12187. useRequestAnimationFrame = _ref18$useRequestAnim === void 0 ? false : _ref18$useRequestAnim,
  12188. _ref18$pdfBug = _ref18.pdfBug,
  12189. pdfBug = _ref18$pdfBug === void 0 ? false : _ref18$pdfBug;
  12190. _classCallCheck(this, InternalRenderTask);
  12191. this.callback = callback;
  12192. this.params = params;
  12193. this.objs = objs;
  12194. this.commonObjs = commonObjs;
  12195. this.operatorListIdx = null;
  12196. this.operatorList = operatorList;
  12197. this._pageIndex = pageIndex;
  12198. this.canvasFactory = canvasFactory;
  12199. this.webGLContext = webGLContext;
  12200. this._pdfBug = pdfBug;
  12201. this.running = false;
  12202. this.graphicsReadyCallback = null;
  12203. this.graphicsReady = false;
  12204. this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== "undefined";
  12205. this.cancelled = false;
  12206. this.capability = (0, _util.createPromiseCapability)();
  12207. this.task = new RenderTask(this);
  12208. this._continueBound = this._continue.bind(this);
  12209. this._scheduleNextBound = this._scheduleNext.bind(this);
  12210. this._nextBound = this._next.bind(this);
  12211. this._canvas = params.canvasContext.canvas;
  12212. }
  12213. _createClass(InternalRenderTask, [{
  12214. key: "initializeGraphics",
  12215. value: function initializeGraphics(_ref19) {
  12216. var _globalThis$StepperMa;
  12217. var _ref19$transparency = _ref19.transparency,
  12218. transparency = _ref19$transparency === void 0 ? false : _ref19$transparency,
  12219. optionalContentConfig = _ref19.optionalContentConfig;
  12220. if (this.cancelled) {
  12221. return;
  12222. }
  12223. if (this._canvas) {
  12224. if (canvasInRendering.has(this._canvas)) {
  12225. throw new Error("Cannot use the same canvas during multiple render() operations. " + "Use different canvas or ensure previous operations were " + "cancelled or completed.");
  12226. }
  12227. canvasInRendering.add(this._canvas);
  12228. }
  12229. if (this._pdfBug && (_globalThis$StepperMa = globalThis.StepperManager) !== null && _globalThis$StepperMa !== void 0 && _globalThis$StepperMa.enabled) {
  12230. this.stepper = globalThis.StepperManager.create(this._pageIndex);
  12231. this.stepper.init(this.operatorList);
  12232. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  12233. }
  12234. var _this$params = this.params,
  12235. canvasContext = _this$params.canvasContext,
  12236. viewport = _this$params.viewport,
  12237. transform = _this$params.transform,
  12238. imageLayer = _this$params.imageLayer,
  12239. background = _this$params.background;
  12240. this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, imageLayer, optionalContentConfig);
  12241. this.gfx.beginDrawing({
  12242. transform: transform,
  12243. viewport: viewport,
  12244. transparency: transparency,
  12245. background: background
  12246. });
  12247. this.operatorListIdx = 0;
  12248. this.graphicsReady = true;
  12249. if (this.graphicsReadyCallback) {
  12250. this.graphicsReadyCallback();
  12251. }
  12252. }
  12253. }, {
  12254. key: "cancel",
  12255. value: function cancel() {
  12256. var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  12257. this.running = false;
  12258. this.cancelled = true;
  12259. if (this.gfx) {
  12260. this.gfx.endDrawing();
  12261. }
  12262. if (this._canvas) {
  12263. canvasInRendering["delete"](this._canvas);
  12264. }
  12265. this.callback(error || new _display_utils.RenderingCancelledException("Rendering cancelled, page ".concat(this._pageIndex + 1), "canvas"));
  12266. }
  12267. }, {
  12268. key: "operatorListChanged",
  12269. value: function operatorListChanged() {
  12270. if (!this.graphicsReady) {
  12271. if (!this.graphicsReadyCallback) {
  12272. this.graphicsReadyCallback = this._continueBound;
  12273. }
  12274. return;
  12275. }
  12276. if (this.stepper) {
  12277. this.stepper.updateOperatorList(this.operatorList);
  12278. }
  12279. if (this.running) {
  12280. return;
  12281. }
  12282. this._continue();
  12283. }
  12284. }, {
  12285. key: "_continue",
  12286. value: function _continue() {
  12287. this.running = true;
  12288. if (this.cancelled) {
  12289. return;
  12290. }
  12291. if (this.task.onContinue) {
  12292. this.task.onContinue(this._scheduleNextBound);
  12293. } else {
  12294. this._scheduleNext();
  12295. }
  12296. }
  12297. }, {
  12298. key: "_scheduleNext",
  12299. value: function _scheduleNext() {
  12300. var _this16 = this;
  12301. if (this._useRequestAnimationFrame) {
  12302. window.requestAnimationFrame(function () {
  12303. _this16._nextBound()["catch"](_this16.cancel.bind(_this16));
  12304. });
  12305. } else {
  12306. Promise.resolve().then(this._nextBound)["catch"](this.cancel.bind(this));
  12307. }
  12308. }
  12309. }, {
  12310. key: "_next",
  12311. value: function () {
  12312. var _next2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12313. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12314. while (1) {
  12315. switch (_context2.prev = _context2.next) {
  12316. case 0:
  12317. if (!this.cancelled) {
  12318. _context2.next = 2;
  12319. break;
  12320. }
  12321. return _context2.abrupt("return");
  12322. case 2:
  12323. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  12324. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  12325. this.running = false;
  12326. if (this.operatorList.lastChunk) {
  12327. this.gfx.endDrawing();
  12328. if (this._canvas) {
  12329. canvasInRendering["delete"](this._canvas);
  12330. }
  12331. this.callback();
  12332. }
  12333. }
  12334. case 4:
  12335. case "end":
  12336. return _context2.stop();
  12337. }
  12338. }
  12339. }, _callee2, this);
  12340. }));
  12341. function _next() {
  12342. return _next2.apply(this, arguments);
  12343. }
  12344. return _next;
  12345. }()
  12346. }, {
  12347. key: "completed",
  12348. get: function get() {
  12349. return this.capability.promise["catch"](function () {});
  12350. }
  12351. }]);
  12352. return InternalRenderTask;
  12353. }();
  12354. return InternalRenderTask;
  12355. }();
  12356. var version = '2.7.570';
  12357. exports.version = version;
  12358. var build = 'f2c7338b0';
  12359. exports.build = build;
  12360. /***/ }),
  12361. /* 136 */
  12362. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12363. "use strict";
  12364. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12365. Object.defineProperty(exports, "__esModule", ({
  12366. value: true
  12367. }));
  12368. exports.FontLoader = exports.FontFaceObject = void 0;
  12369. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  12370. var _util = __w_pdfjs_require__(4);
  12371. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12372. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12373. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12374. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12375. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12376. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12377. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  12378. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12379. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  12380. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  12381. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12382. 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); } }
  12383. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12384. var BaseFontLoader = /*#__PURE__*/function () {
  12385. function BaseFontLoader(_ref) {
  12386. var docId = _ref.docId,
  12387. onUnsupportedFeature = _ref.onUnsupportedFeature,
  12388. _ref$ownerDocument = _ref.ownerDocument,
  12389. ownerDocument = _ref$ownerDocument === void 0 ? globalThis.document : _ref$ownerDocument;
  12390. _classCallCheck(this, BaseFontLoader);
  12391. if (this.constructor === BaseFontLoader) {
  12392. (0, _util.unreachable)("Cannot initialize BaseFontLoader.");
  12393. }
  12394. this.docId = docId;
  12395. this._onUnsupportedFeature = onUnsupportedFeature;
  12396. this._document = ownerDocument;
  12397. this.nativeFontFaces = [];
  12398. this.styleElement = null;
  12399. }
  12400. _createClass(BaseFontLoader, [{
  12401. key: "addNativeFontFace",
  12402. value: function addNativeFontFace(nativeFontFace) {
  12403. this.nativeFontFaces.push(nativeFontFace);
  12404. this._document.fonts.add(nativeFontFace);
  12405. }
  12406. }, {
  12407. key: "insertRule",
  12408. value: function insertRule(rule) {
  12409. var styleElement = this.styleElement;
  12410. if (!styleElement) {
  12411. styleElement = this.styleElement = this._document.createElement("style");
  12412. styleElement.id = "PDFJS_FONT_STYLE_TAG_".concat(this.docId);
  12413. this._document.documentElement.getElementsByTagName("head")[0].appendChild(styleElement);
  12414. }
  12415. var styleSheet = styleElement.sheet;
  12416. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  12417. }
  12418. }, {
  12419. key: "clear",
  12420. value: function clear() {
  12421. var _this = this;
  12422. this.nativeFontFaces.forEach(function (nativeFontFace) {
  12423. _this._document.fonts["delete"](nativeFontFace);
  12424. });
  12425. this.nativeFontFaces.length = 0;
  12426. if (this.styleElement) {
  12427. this.styleElement.remove();
  12428. this.styleElement = null;
  12429. }
  12430. }
  12431. }, {
  12432. key: "bind",
  12433. value: function () {
  12434. var _bind = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(font) {
  12435. var _this2 = this;
  12436. var nativeFontFace, rule;
  12437. return _regenerator["default"].wrap(function _callee$(_context) {
  12438. while (1) {
  12439. switch (_context.prev = _context.next) {
  12440. case 0:
  12441. if (!(font.attached || font.missingFile)) {
  12442. _context.next = 2;
  12443. break;
  12444. }
  12445. return _context.abrupt("return");
  12446. case 2:
  12447. font.attached = true;
  12448. if (!this.isFontLoadingAPISupported) {
  12449. _context.next = 19;
  12450. break;
  12451. }
  12452. nativeFontFace = font.createNativeFontFace();
  12453. if (!nativeFontFace) {
  12454. _context.next = 18;
  12455. break;
  12456. }
  12457. this.addNativeFontFace(nativeFontFace);
  12458. _context.prev = 7;
  12459. _context.next = 10;
  12460. return nativeFontFace.loaded;
  12461. case 10:
  12462. _context.next = 18;
  12463. break;
  12464. case 12:
  12465. _context.prev = 12;
  12466. _context.t0 = _context["catch"](7);
  12467. this._onUnsupportedFeature({
  12468. featureId: _util.UNSUPPORTED_FEATURES.errorFontLoadNative
  12469. });
  12470. (0, _util.warn)("Failed to load font '".concat(nativeFontFace.family, "': '").concat(_context.t0, "'."));
  12471. font.disableFontFace = true;
  12472. throw _context.t0;
  12473. case 18:
  12474. return _context.abrupt("return");
  12475. case 19:
  12476. rule = font.createFontFaceRule();
  12477. if (!rule) {
  12478. _context.next = 26;
  12479. break;
  12480. }
  12481. this.insertRule(rule);
  12482. if (!this.isSyncFontLoadingSupported) {
  12483. _context.next = 24;
  12484. break;
  12485. }
  12486. return _context.abrupt("return");
  12487. case 24:
  12488. _context.next = 26;
  12489. return new Promise(function (resolve) {
  12490. var request = _this2._queueLoadingCallback(resolve);
  12491. _this2._prepareFontLoadEvent([rule], [font], request);
  12492. });
  12493. case 26:
  12494. case "end":
  12495. return _context.stop();
  12496. }
  12497. }
  12498. }, _callee, this, [[7, 12]]);
  12499. }));
  12500. function bind(_x) {
  12501. return _bind.apply(this, arguments);
  12502. }
  12503. return bind;
  12504. }()
  12505. }, {
  12506. key: "_queueLoadingCallback",
  12507. value: function _queueLoadingCallback(callback) {
  12508. (0, _util.unreachable)("Abstract method `_queueLoadingCallback`.");
  12509. }
  12510. }, {
  12511. key: "_prepareFontLoadEvent",
  12512. value: function _prepareFontLoadEvent(rules, fontsToLoad, request) {
  12513. (0, _util.unreachable)("Abstract method `_prepareFontLoadEvent`.");
  12514. }
  12515. }, {
  12516. key: "isFontLoadingAPISupported",
  12517. get: function get() {
  12518. var _this$_document;
  12519. return (0, _util.shadow)(this, "isFontLoadingAPISupported", !!((_this$_document = this._document) !== null && _this$_document !== void 0 && _this$_document.fonts));
  12520. }
  12521. }, {
  12522. key: "isSyncFontLoadingSupported",
  12523. get: function get() {
  12524. (0, _util.unreachable)("Abstract method `isSyncFontLoadingSupported`.");
  12525. }
  12526. }, {
  12527. key: "_loadTestFont",
  12528. get: function get() {
  12529. (0, _util.unreachable)("Abstract method `_loadTestFont`.");
  12530. }
  12531. }]);
  12532. return BaseFontLoader;
  12533. }();
  12534. var FontLoader;
  12535. exports.FontLoader = FontLoader;
  12536. {
  12537. exports.FontLoader = FontLoader = /*#__PURE__*/function (_BaseFontLoader) {
  12538. _inherits(GenericFontLoader, _BaseFontLoader);
  12539. var _super = _createSuper(GenericFontLoader);
  12540. function GenericFontLoader(params) {
  12541. var _this3;
  12542. _classCallCheck(this, GenericFontLoader);
  12543. _this3 = _super.call(this, params);
  12544. _this3.loadingContext = {
  12545. requests: [],
  12546. nextRequestId: 0
  12547. };
  12548. _this3.loadTestFontId = 0;
  12549. return _this3;
  12550. }
  12551. _createClass(GenericFontLoader, [{
  12552. key: "_queueLoadingCallback",
  12553. value: function _queueLoadingCallback(callback) {
  12554. function completeRequest() {
  12555. (0, _util.assert)(!request.done, "completeRequest() cannot be called twice.");
  12556. request.done = true;
  12557. while (context.requests.length > 0 && context.requests[0].done) {
  12558. var otherRequest = context.requests.shift();
  12559. setTimeout(otherRequest.callback, 0);
  12560. }
  12561. }
  12562. var context = this.loadingContext;
  12563. var request = {
  12564. id: "pdfjs-font-loading-".concat(context.nextRequestId++),
  12565. done: false,
  12566. complete: completeRequest,
  12567. callback: callback
  12568. };
  12569. context.requests.push(request);
  12570. return request;
  12571. }
  12572. }, {
  12573. key: "_prepareFontLoadEvent",
  12574. value: function _prepareFontLoadEvent(rules, fonts, request) {
  12575. var _this4 = this;
  12576. function int32(data, offset) {
  12577. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  12578. }
  12579. function spliceString(s, offset, remove, insert) {
  12580. var chunk1 = s.substring(0, offset);
  12581. var chunk2 = s.substring(offset + remove);
  12582. return chunk1 + insert + chunk2;
  12583. }
  12584. var i, ii;
  12585. var canvas = this._document.createElement("canvas");
  12586. canvas.width = 1;
  12587. canvas.height = 1;
  12588. var ctx = canvas.getContext("2d");
  12589. var called = 0;
  12590. function isFontReady(name, callback) {
  12591. called++;
  12592. if (called > 30) {
  12593. (0, _util.warn)("Load test font never loaded.");
  12594. callback();
  12595. return;
  12596. }
  12597. ctx.font = "30px " + name;
  12598. ctx.fillText(".", 0, 20);
  12599. var imageData = ctx.getImageData(0, 0, 1, 1);
  12600. if (imageData.data[3] > 0) {
  12601. callback();
  12602. return;
  12603. }
  12604. setTimeout(isFontReady.bind(null, name, callback));
  12605. }
  12606. var loadTestFontId = "lt".concat(Date.now()).concat(this.loadTestFontId++);
  12607. var data = this._loadTestFont;
  12608. var COMMENT_OFFSET = 976;
  12609. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  12610. var CFF_CHECKSUM_OFFSET = 16;
  12611. var XXXX_VALUE = 0x58585858;
  12612. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  12613. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  12614. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  12615. }
  12616. if (i < loadTestFontId.length) {
  12617. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + "XXX", i) | 0;
  12618. }
  12619. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
  12620. var url = "url(data:font/opentype;base64,".concat(btoa(data), ");");
  12621. var rule = "@font-face {font-family:\"".concat(loadTestFontId, "\";src:").concat(url, "}");
  12622. this.insertRule(rule);
  12623. var names = [];
  12624. for (i = 0, ii = fonts.length; i < ii; i++) {
  12625. names.push(fonts[i].loadedName);
  12626. }
  12627. names.push(loadTestFontId);
  12628. var div = this._document.createElement("div");
  12629. div.style.visibility = "hidden";
  12630. div.style.width = div.style.height = "10px";
  12631. div.style.position = "absolute";
  12632. div.style.top = div.style.left = "0px";
  12633. for (i = 0, ii = names.length; i < ii; ++i) {
  12634. var span = this._document.createElement("span");
  12635. span.textContent = "Hi";
  12636. span.style.fontFamily = names[i];
  12637. div.appendChild(span);
  12638. }
  12639. this._document.body.appendChild(div);
  12640. isFontReady(loadTestFontId, function () {
  12641. _this4._document.body.removeChild(div);
  12642. request.complete();
  12643. });
  12644. }
  12645. }, {
  12646. key: "isSyncFontLoadingSupported",
  12647. get: function get() {
  12648. var supported = false;
  12649. if (typeof navigator === "undefined") {
  12650. supported = true;
  12651. } else {
  12652. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  12653. if ((m === null || m === void 0 ? void 0 : m[1]) >= 14) {
  12654. supported = true;
  12655. }
  12656. }
  12657. return (0, _util.shadow)(this, "isSyncFontLoadingSupported", supported);
  12658. }
  12659. }, {
  12660. key: "_loadTestFont",
  12661. get: function get() {
  12662. var getLoadTestFont = function getLoadTestFont() {
  12663. 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==");
  12664. };
  12665. return (0, _util.shadow)(this, "_loadTestFont", getLoadTestFont());
  12666. }
  12667. }]);
  12668. return GenericFontLoader;
  12669. }(BaseFontLoader);
  12670. }
  12671. var FontFaceObject = /*#__PURE__*/function () {
  12672. function FontFaceObject(translatedData, _ref2) {
  12673. var _ref2$isEvalSupported = _ref2.isEvalSupported,
  12674. isEvalSupported = _ref2$isEvalSupported === void 0 ? true : _ref2$isEvalSupported,
  12675. _ref2$disableFontFace = _ref2.disableFontFace,
  12676. disableFontFace = _ref2$disableFontFace === void 0 ? false : _ref2$disableFontFace,
  12677. _ref2$ignoreErrors = _ref2.ignoreErrors,
  12678. ignoreErrors = _ref2$ignoreErrors === void 0 ? false : _ref2$ignoreErrors,
  12679. _ref2$onUnsupportedFe = _ref2.onUnsupportedFeature,
  12680. onUnsupportedFeature = _ref2$onUnsupportedFe === void 0 ? null : _ref2$onUnsupportedFe,
  12681. _ref2$fontRegistry = _ref2.fontRegistry,
  12682. fontRegistry = _ref2$fontRegistry === void 0 ? null : _ref2$fontRegistry;
  12683. _classCallCheck(this, FontFaceObject);
  12684. this.compiledGlyphs = Object.create(null);
  12685. for (var i in translatedData) {
  12686. this[i] = translatedData[i];
  12687. }
  12688. this.isEvalSupported = isEvalSupported !== false;
  12689. this.disableFontFace = disableFontFace === true;
  12690. this.ignoreErrors = ignoreErrors === true;
  12691. this._onUnsupportedFeature = onUnsupportedFeature;
  12692. this.fontRegistry = fontRegistry;
  12693. }
  12694. _createClass(FontFaceObject, [{
  12695. key: "createNativeFontFace",
  12696. value: function createNativeFontFace() {
  12697. if (!this.data || this.disableFontFace) {
  12698. return null;
  12699. }
  12700. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  12701. if (this.fontRegistry) {
  12702. this.fontRegistry.registerFont(this);
  12703. }
  12704. return nativeFontFace;
  12705. }
  12706. }, {
  12707. key: "createFontFaceRule",
  12708. value: function createFontFaceRule() {
  12709. if (!this.data || this.disableFontFace) {
  12710. return null;
  12711. }
  12712. var data = (0, _util.bytesToString)(new Uint8Array(this.data));
  12713. var url = "url(data:".concat(this.mimetype, ";base64,").concat(btoa(data), ");");
  12714. var rule = "@font-face {font-family:\"".concat(this.loadedName, "\";src:").concat(url, "}");
  12715. if (this.fontRegistry) {
  12716. this.fontRegistry.registerFont(this, url);
  12717. }
  12718. return rule;
  12719. }
  12720. }, {
  12721. key: "getPathGenerator",
  12722. value: function getPathGenerator(objs, character) {
  12723. if (this.compiledGlyphs[character] !== undefined) {
  12724. return this.compiledGlyphs[character];
  12725. }
  12726. var cmds, current;
  12727. try {
  12728. cmds = objs.get(this.loadedName + "_path_" + character);
  12729. } catch (ex) {
  12730. if (!this.ignoreErrors) {
  12731. throw ex;
  12732. }
  12733. if (this._onUnsupportedFeature) {
  12734. this._onUnsupportedFeature({
  12735. featureId: _util.UNSUPPORTED_FEATURES.errorFontGetPath
  12736. });
  12737. }
  12738. (0, _util.warn)("getPathGenerator - ignoring character: \"".concat(ex, "\"."));
  12739. return this.compiledGlyphs[character] = function (c, size) {};
  12740. }
  12741. if (this.isEvalSupported && _util.IsEvalSupportedCached.value) {
  12742. var args,
  12743. js = "";
  12744. for (var i = 0, ii = cmds.length; i < ii; i++) {
  12745. current = cmds[i];
  12746. if (current.args !== undefined) {
  12747. args = current.args.join(",");
  12748. } else {
  12749. args = "";
  12750. }
  12751. js += "c." + current.cmd + "(" + args + ");\n";
  12752. }
  12753. return this.compiledGlyphs[character] = new Function("c", "size", js);
  12754. }
  12755. return this.compiledGlyphs[character] = function (c, size) {
  12756. for (var _i = 0, _ii = cmds.length; _i < _ii; _i++) {
  12757. current = cmds[_i];
  12758. if (current.cmd === "scale") {
  12759. current.args = [size, -size];
  12760. }
  12761. c[current.cmd].apply(c, current.args);
  12762. }
  12763. };
  12764. }
  12765. }]);
  12766. return FontFaceObject;
  12767. }();
  12768. exports.FontFaceObject = FontFaceObject;
  12769. /***/ }),
  12770. /* 137 */
  12771. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12772. "use strict";
  12773. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12774. Object.defineProperty(exports, "__esModule", ({
  12775. value: true
  12776. }));
  12777. exports.NodeCMapReaderFactory = exports.NodeCanvasFactory = void 0;
  12778. var _display_utils = __w_pdfjs_require__(1);
  12779. var _is_node = __w_pdfjs_require__(6);
  12780. var _util = __w_pdfjs_require__(4);
  12781. 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); } }
  12782. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12783. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12784. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12785. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12786. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12787. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12788. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  12789. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12790. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12791. var NodeCanvasFactory = function NodeCanvasFactory() {
  12792. _classCallCheck(this, NodeCanvasFactory);
  12793. (0, _util.unreachable)("Not implemented: NodeCanvasFactory");
  12794. };
  12795. exports.NodeCanvasFactory = NodeCanvasFactory;
  12796. var NodeCMapReaderFactory = function NodeCMapReaderFactory() {
  12797. _classCallCheck(this, NodeCMapReaderFactory);
  12798. (0, _util.unreachable)("Not implemented: NodeCMapReaderFactory");
  12799. };
  12800. exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
  12801. if (_is_node.isNodeJS) {
  12802. exports.NodeCanvasFactory = NodeCanvasFactory = /*#__PURE__*/function (_BaseCanvasFactory) {
  12803. _inherits(NodeCanvasFactory, _BaseCanvasFactory);
  12804. var _super = _createSuper(NodeCanvasFactory);
  12805. function NodeCanvasFactory() {
  12806. _classCallCheck(this, NodeCanvasFactory);
  12807. return _super.apply(this, arguments);
  12808. }
  12809. _createClass(NodeCanvasFactory, [{
  12810. key: "create",
  12811. value: function create(width, height) {
  12812. if (width <= 0 || height <= 0) {
  12813. throw new Error("Invalid canvas size");
  12814. }
  12815. var Canvas = require("canvas");
  12816. var canvas = Canvas.createCanvas(width, height);
  12817. return {
  12818. canvas: canvas,
  12819. context: canvas.getContext("2d")
  12820. };
  12821. }
  12822. }]);
  12823. return NodeCanvasFactory;
  12824. }(_display_utils.BaseCanvasFactory);
  12825. exports.NodeCMapReaderFactory = NodeCMapReaderFactory = /*#__PURE__*/function (_BaseCMapReaderFactor) {
  12826. _inherits(NodeCMapReaderFactory, _BaseCMapReaderFactor);
  12827. var _super2 = _createSuper(NodeCMapReaderFactory);
  12828. function NodeCMapReaderFactory() {
  12829. _classCallCheck(this, NodeCMapReaderFactory);
  12830. return _super2.apply(this, arguments);
  12831. }
  12832. _createClass(NodeCMapReaderFactory, [{
  12833. key: "_fetchData",
  12834. value: function _fetchData(url, compressionType) {
  12835. return new Promise(function (resolve, reject) {
  12836. var fs = require("fs");
  12837. fs.readFile(url, function (error, data) {
  12838. if (error || !data) {
  12839. reject(new Error(error));
  12840. return;
  12841. }
  12842. resolve({
  12843. cMapData: new Uint8Array(data),
  12844. compressionType: compressionType
  12845. });
  12846. });
  12847. });
  12848. }
  12849. }]);
  12850. return NodeCMapReaderFactory;
  12851. }(_display_utils.BaseCMapReaderFactory);
  12852. }
  12853. /***/ }),
  12854. /* 138 */
  12855. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12856. "use strict";
  12857. Object.defineProperty(exports, "__esModule", ({
  12858. value: true
  12859. }));
  12860. exports.AnnotationStorage = void 0;
  12861. var _util = __w_pdfjs_require__(4);
  12862. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  12863. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  12864. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  12865. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  12866. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  12867. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  12868. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12869. 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); } }
  12870. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12871. var AnnotationStorage = /*#__PURE__*/function () {
  12872. function AnnotationStorage() {
  12873. _classCallCheck(this, AnnotationStorage);
  12874. this._storage = new Map();
  12875. this._modified = false;
  12876. this.onSetModified = null;
  12877. this.onResetModified = null;
  12878. }
  12879. _createClass(AnnotationStorage, [{
  12880. key: "getOrCreateValue",
  12881. value: function getOrCreateValue(key, defaultValue) {
  12882. if (this._storage.has(key)) {
  12883. return this._storage.get(key);
  12884. }
  12885. this._storage.set(key, defaultValue);
  12886. return defaultValue;
  12887. }
  12888. }, {
  12889. key: "setValue",
  12890. value: function setValue(key, value) {
  12891. var obj = this._storage.get(key);
  12892. var modified = false;
  12893. if (obj !== undefined) {
  12894. for (var _i = 0, _Object$entries = Object.entries(value); _i < _Object$entries.length; _i++) {
  12895. var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
  12896. entry = _Object$entries$_i[0],
  12897. val = _Object$entries$_i[1];
  12898. if (obj[entry] !== val) {
  12899. modified = true;
  12900. obj[entry] = val;
  12901. }
  12902. }
  12903. } else {
  12904. this._storage.set(key, value);
  12905. modified = true;
  12906. }
  12907. if (modified) {
  12908. this._setModified();
  12909. }
  12910. }
  12911. }, {
  12912. key: "getAll",
  12913. value: function getAll() {
  12914. if (this._storage.size === 0) {
  12915. return null;
  12916. }
  12917. return (0, _util.objectFromEntries)(this._storage);
  12918. }
  12919. }, {
  12920. key: "_setModified",
  12921. value: function _setModified() {
  12922. if (!this._modified) {
  12923. this._modified = true;
  12924. if (typeof this.onSetModified === "function") {
  12925. this.onSetModified();
  12926. }
  12927. }
  12928. }
  12929. }, {
  12930. key: "resetModified",
  12931. value: function resetModified() {
  12932. if (this._modified) {
  12933. this._modified = false;
  12934. if (typeof this.onResetModified === "function") {
  12935. this.onResetModified();
  12936. }
  12937. }
  12938. }
  12939. }, {
  12940. key: "size",
  12941. get: function get() {
  12942. return this._storage.size;
  12943. }
  12944. }]);
  12945. return AnnotationStorage;
  12946. }();
  12947. exports.AnnotationStorage = AnnotationStorage;
  12948. /***/ }),
  12949. /* 139 */
  12950. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12951. "use strict";
  12952. Object.defineProperty(exports, "__esModule", ({
  12953. value: true
  12954. }));
  12955. exports.apiCompatibilityParams = void 0;
  12956. var _is_node = __w_pdfjs_require__(6);
  12957. var compatibilityParams = Object.create(null);
  12958. {
  12959. (function checkFontFace() {
  12960. if (_is_node.isNodeJS) {
  12961. compatibilityParams.disableFontFace = true;
  12962. }
  12963. })();
  12964. }
  12965. var apiCompatibilityParams = Object.freeze(compatibilityParams);
  12966. exports.apiCompatibilityParams = apiCompatibilityParams;
  12967. /***/ }),
  12968. /* 140 */
  12969. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12970. "use strict";
  12971. Object.defineProperty(exports, "__esModule", ({
  12972. value: true
  12973. }));
  12974. exports.CanvasGraphics = void 0;
  12975. var _util = __w_pdfjs_require__(4);
  12976. var _pattern_helper = __w_pdfjs_require__(141);
  12977. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12978. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  12979. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  12980. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  12981. var MIN_FONT_SIZE = 16;
  12982. var MAX_FONT_SIZE = 100;
  12983. var MAX_GROUP_SIZE = 4096;
  12984. var COMPILE_TYPE3_GLYPHS = true;
  12985. var MAX_SIZE_TO_COMPILE = 1000;
  12986. var FULL_CHUNK_HEIGHT = 16;
  12987. function addContextCurrentTransform(ctx) {
  12988. if (!ctx.mozCurrentTransform) {
  12989. ctx._originalSave = ctx.save;
  12990. ctx._originalRestore = ctx.restore;
  12991. ctx._originalRotate = ctx.rotate;
  12992. ctx._originalScale = ctx.scale;
  12993. ctx._originalTranslate = ctx.translate;
  12994. ctx._originalTransform = ctx.transform;
  12995. ctx._originalSetTransform = ctx.setTransform;
  12996. ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
  12997. ctx._transformStack = [];
  12998. Object.defineProperty(ctx, "mozCurrentTransform", {
  12999. get: function getCurrentTransform() {
  13000. return this._transformMatrix;
  13001. }
  13002. });
  13003. Object.defineProperty(ctx, "mozCurrentTransformInverse", {
  13004. get: function getCurrentTransformInverse() {
  13005. var m = this._transformMatrix;
  13006. var a = m[0],
  13007. b = m[1],
  13008. c = m[2],
  13009. d = m[3],
  13010. e = m[4],
  13011. f = m[5];
  13012. var ad_bc = a * d - b * c;
  13013. var bc_ad = b * c - a * d;
  13014. 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];
  13015. }
  13016. });
  13017. ctx.save = function ctxSave() {
  13018. var old = this._transformMatrix;
  13019. this._transformStack.push(old);
  13020. this._transformMatrix = old.slice(0, 6);
  13021. this._originalSave();
  13022. };
  13023. ctx.restore = function ctxRestore() {
  13024. var prev = this._transformStack.pop();
  13025. if (prev) {
  13026. this._transformMatrix = prev;
  13027. this._originalRestore();
  13028. }
  13029. };
  13030. ctx.translate = function ctxTranslate(x, y) {
  13031. var m = this._transformMatrix;
  13032. m[4] = m[0] * x + m[2] * y + m[4];
  13033. m[5] = m[1] * x + m[3] * y + m[5];
  13034. this._originalTranslate(x, y);
  13035. };
  13036. ctx.scale = function ctxScale(x, y) {
  13037. var m = this._transformMatrix;
  13038. m[0] = m[0] * x;
  13039. m[1] = m[1] * x;
  13040. m[2] = m[2] * y;
  13041. m[3] = m[3] * y;
  13042. this._originalScale(x, y);
  13043. };
  13044. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  13045. var m = this._transformMatrix;
  13046. 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]];
  13047. ctx._originalTransform(a, b, c, d, e, f);
  13048. };
  13049. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  13050. this._transformMatrix = [a, b, c, d, e, f];
  13051. ctx._originalSetTransform(a, b, c, d, e, f);
  13052. };
  13053. ctx.rotate = function ctxRotate(angle) {
  13054. var cosValue = Math.cos(angle);
  13055. var sinValue = Math.sin(angle);
  13056. var m = this._transformMatrix;
  13057. 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]];
  13058. this._originalRotate(angle);
  13059. };
  13060. }
  13061. }
  13062. var CachedCanvases = function CachedCanvasesClosure() {
  13063. function CachedCanvases(canvasFactory) {
  13064. this.canvasFactory = canvasFactory;
  13065. this.cache = Object.create(null);
  13066. }
  13067. CachedCanvases.prototype = {
  13068. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  13069. var canvasEntry;
  13070. if (this.cache[id] !== undefined) {
  13071. canvasEntry = this.cache[id];
  13072. this.canvasFactory.reset(canvasEntry, width, height);
  13073. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  13074. } else {
  13075. canvasEntry = this.canvasFactory.create(width, height);
  13076. this.cache[id] = canvasEntry;
  13077. }
  13078. if (trackTransform) {
  13079. addContextCurrentTransform(canvasEntry.context);
  13080. }
  13081. return canvasEntry;
  13082. },
  13083. clear: function clear() {
  13084. for (var id in this.cache) {
  13085. var canvasEntry = this.cache[id];
  13086. this.canvasFactory.destroy(canvasEntry);
  13087. delete this.cache[id];
  13088. }
  13089. }
  13090. };
  13091. return CachedCanvases;
  13092. }();
  13093. function compileType3Glyph(imgData) {
  13094. var POINT_TO_PROCESS_LIMIT = 1000;
  13095. var width = imgData.width,
  13096. height = imgData.height,
  13097. width1 = width + 1;
  13098. var i, ii, j, j0;
  13099. var points = new Uint8Array(width1 * (height + 1));
  13100. var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
  13101. var lineSize = width + 7 & ~7,
  13102. data0 = imgData.data;
  13103. var data = new Uint8Array(lineSize * height);
  13104. var pos = 0;
  13105. for (i = 0, ii = data0.length; i < ii; i++) {
  13106. var elem = data0[i];
  13107. var mask = 128;
  13108. while (mask > 0) {
  13109. data[pos++] = elem & mask ? 0 : 255;
  13110. mask >>= 1;
  13111. }
  13112. }
  13113. var count = 0;
  13114. pos = 0;
  13115. if (data[pos] !== 0) {
  13116. points[0] = 1;
  13117. ++count;
  13118. }
  13119. for (j = 1; j < width; j++) {
  13120. if (data[pos] !== data[pos + 1]) {
  13121. points[j] = data[pos] ? 2 : 1;
  13122. ++count;
  13123. }
  13124. pos++;
  13125. }
  13126. if (data[pos] !== 0) {
  13127. points[j] = 2;
  13128. ++count;
  13129. }
  13130. for (i = 1; i < height; i++) {
  13131. pos = i * lineSize;
  13132. j0 = i * width1;
  13133. if (data[pos - lineSize] !== data[pos]) {
  13134. points[j0] = data[pos] ? 1 : 8;
  13135. ++count;
  13136. }
  13137. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  13138. for (j = 1; j < width; j++) {
  13139. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  13140. if (POINT_TYPES[sum]) {
  13141. points[j0 + j] = POINT_TYPES[sum];
  13142. ++count;
  13143. }
  13144. pos++;
  13145. }
  13146. if (data[pos - lineSize] !== data[pos]) {
  13147. points[j0 + j] = data[pos] ? 2 : 4;
  13148. ++count;
  13149. }
  13150. if (count > POINT_TO_PROCESS_LIMIT) {
  13151. return null;
  13152. }
  13153. }
  13154. pos = lineSize * (height - 1);
  13155. j0 = i * width1;
  13156. if (data[pos] !== 0) {
  13157. points[j0] = 8;
  13158. ++count;
  13159. }
  13160. for (j = 1; j < width; j++) {
  13161. if (data[pos] !== data[pos + 1]) {
  13162. points[j0 + j] = data[pos] ? 4 : 8;
  13163. ++count;
  13164. }
  13165. pos++;
  13166. }
  13167. if (data[pos] !== 0) {
  13168. points[j0 + j] = 4;
  13169. ++count;
  13170. }
  13171. if (count > POINT_TO_PROCESS_LIMIT) {
  13172. return null;
  13173. }
  13174. var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
  13175. var outlines = [];
  13176. for (i = 0; count && i <= height; i++) {
  13177. var p = i * width1;
  13178. var end = p + width;
  13179. while (p < end && !points[p]) {
  13180. p++;
  13181. }
  13182. if (p === end) {
  13183. continue;
  13184. }
  13185. var coords = [p % width1, i];
  13186. var p0 = p;
  13187. var type = points[p];
  13188. do {
  13189. var step = steps[type];
  13190. do {
  13191. p += step;
  13192. } while (!points[p]);
  13193. var pp = points[p];
  13194. if (pp !== 5 && pp !== 10) {
  13195. type = pp;
  13196. points[p] = 0;
  13197. } else {
  13198. type = pp & 0x33 * type >> 4;
  13199. points[p] &= type >> 2 | type << 2;
  13200. }
  13201. coords.push(p % width1);
  13202. coords.push(p / width1 | 0);
  13203. if (!points[p]) {
  13204. --count;
  13205. }
  13206. } while (p0 !== p);
  13207. outlines.push(coords);
  13208. --i;
  13209. }
  13210. var drawOutline = function drawOutline(c) {
  13211. c.save();
  13212. c.scale(1 / width, -1 / height);
  13213. c.translate(0, -height);
  13214. c.beginPath();
  13215. for (var k = 0, kk = outlines.length; k < kk; k++) {
  13216. var o = outlines[k];
  13217. c.moveTo(o[0], o[1]);
  13218. for (var l = 2, ll = o.length; l < ll; l += 2) {
  13219. c.lineTo(o[l], o[l + 1]);
  13220. }
  13221. }
  13222. c.fill();
  13223. c.beginPath();
  13224. c.restore();
  13225. };
  13226. return drawOutline;
  13227. }
  13228. var CanvasExtraState = function CanvasExtraStateClosure() {
  13229. function CanvasExtraState() {
  13230. this.alphaIsShape = false;
  13231. this.fontSize = 0;
  13232. this.fontSizeScale = 1;
  13233. this.textMatrix = _util.IDENTITY_MATRIX;
  13234. this.textMatrixScale = 1;
  13235. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  13236. this.leading = 0;
  13237. this.x = 0;
  13238. this.y = 0;
  13239. this.lineX = 0;
  13240. this.lineY = 0;
  13241. this.charSpacing = 0;
  13242. this.wordSpacing = 0;
  13243. this.textHScale = 1;
  13244. this.textRenderingMode = _util.TextRenderingMode.FILL;
  13245. this.textRise = 0;
  13246. this.fillColor = "#000000";
  13247. this.strokeColor = "#000000";
  13248. this.patternFill = false;
  13249. this.fillAlpha = 1;
  13250. this.strokeAlpha = 1;
  13251. this.lineWidth = 1;
  13252. this.activeSMask = null;
  13253. this.resumeSMaskCtx = null;
  13254. this.transferMaps = null;
  13255. }
  13256. CanvasExtraState.prototype = {
  13257. clone: function CanvasExtraState_clone() {
  13258. return Object.create(this);
  13259. },
  13260. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  13261. this.x = x;
  13262. this.y = y;
  13263. }
  13264. };
  13265. return CanvasExtraState;
  13266. }();
  13267. var CanvasGraphics = function CanvasGraphicsClosure() {
  13268. var EXECUTION_TIME = 15;
  13269. var EXECUTION_STEPS = 10;
  13270. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer, optionalContentConfig) {
  13271. this.ctx = canvasCtx;
  13272. this.current = new CanvasExtraState();
  13273. this.stateStack = [];
  13274. this.pendingClip = null;
  13275. this.pendingEOFill = false;
  13276. this.res = null;
  13277. this.xobjs = null;
  13278. this.commonObjs = commonObjs;
  13279. this.objs = objs;
  13280. this.canvasFactory = canvasFactory;
  13281. this.webGLContext = webGLContext;
  13282. this.imageLayer = imageLayer;
  13283. this.groupStack = [];
  13284. this.processingType3 = null;
  13285. this.baseTransform = null;
  13286. this.baseTransformStack = [];
  13287. this.groupLevel = 0;
  13288. this.smaskStack = [];
  13289. this.smaskCounter = 0;
  13290. this.tempSMask = null;
  13291. this.contentVisible = true;
  13292. this.markedContentStack = [];
  13293. this.optionalContentConfig = optionalContentConfig;
  13294. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  13295. if (canvasCtx) {
  13296. addContextCurrentTransform(canvasCtx);
  13297. }
  13298. this._cachedGetSinglePixelWidth = null;
  13299. }
  13300. function putBinaryImageData(ctx, imgData) {
  13301. var transferMaps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  13302. if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
  13303. ctx.putImageData(imgData, 0, 0);
  13304. return;
  13305. }
  13306. var height = imgData.height,
  13307. width = imgData.width;
  13308. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  13309. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  13310. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  13311. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  13312. var srcPos = 0,
  13313. destPos;
  13314. var src = imgData.data;
  13315. var dest = chunkImgData.data;
  13316. var i, j, thisChunkHeight, elemsInThisChunk;
  13317. var transferMapRed, transferMapGreen, transferMapBlue, transferMapGray;
  13318. if (transferMaps) {
  13319. switch (transferMaps.length) {
  13320. case 1:
  13321. transferMapRed = transferMaps[0];
  13322. transferMapGreen = transferMaps[0];
  13323. transferMapBlue = transferMaps[0];
  13324. transferMapGray = transferMaps[0];
  13325. break;
  13326. case 4:
  13327. transferMapRed = transferMaps[0];
  13328. transferMapGreen = transferMaps[1];
  13329. transferMapBlue = transferMaps[2];
  13330. transferMapGray = transferMaps[3];
  13331. break;
  13332. }
  13333. }
  13334. if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
  13335. var srcLength = src.byteLength;
  13336. var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
  13337. var dest32DataLength = dest32.length;
  13338. var fullSrcDiff = width + 7 >> 3;
  13339. var white = 0xffffffff;
  13340. var black = _util.IsLittleEndianCached.value ? 0xff000000 : 0x000000ff;
  13341. if (transferMapGray) {
  13342. if (transferMapGray[0] === 0xff && transferMapGray[0xff] === 0) {
  13343. var _ref = [black, white];
  13344. white = _ref[0];
  13345. black = _ref[1];
  13346. }
  13347. }
  13348. for (i = 0; i < totalChunks; i++) {
  13349. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  13350. destPos = 0;
  13351. for (j = 0; j < thisChunkHeight; j++) {
  13352. var srcDiff = srcLength - srcPos;
  13353. var k = 0;
  13354. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  13355. var kEndUnrolled = kEnd & ~7;
  13356. var mask = 0;
  13357. var srcByte = 0;
  13358. for (; k < kEndUnrolled; k += 8) {
  13359. srcByte = src[srcPos++];
  13360. dest32[destPos++] = srcByte & 128 ? white : black;
  13361. dest32[destPos++] = srcByte & 64 ? white : black;
  13362. dest32[destPos++] = srcByte & 32 ? white : black;
  13363. dest32[destPos++] = srcByte & 16 ? white : black;
  13364. dest32[destPos++] = srcByte & 8 ? white : black;
  13365. dest32[destPos++] = srcByte & 4 ? white : black;
  13366. dest32[destPos++] = srcByte & 2 ? white : black;
  13367. dest32[destPos++] = srcByte & 1 ? white : black;
  13368. }
  13369. for (; k < kEnd; k++) {
  13370. if (mask === 0) {
  13371. srcByte = src[srcPos++];
  13372. mask = 128;
  13373. }
  13374. dest32[destPos++] = srcByte & mask ? white : black;
  13375. mask >>= 1;
  13376. }
  13377. }
  13378. while (destPos < dest32DataLength) {
  13379. dest32[destPos++] = 0;
  13380. }
  13381. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  13382. }
  13383. } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
  13384. var hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
  13385. j = 0;
  13386. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  13387. for (i = 0; i < fullChunks; i++) {
  13388. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  13389. srcPos += elemsInThisChunk;
  13390. if (hasTransferMaps) {
  13391. for (var _k = 0; _k < elemsInThisChunk; _k += 4) {
  13392. if (transferMapRed) {
  13393. dest[_k + 0] = transferMapRed[dest[_k + 0]];
  13394. }
  13395. if (transferMapGreen) {
  13396. dest[_k + 1] = transferMapGreen[dest[_k + 1]];
  13397. }
  13398. if (transferMapBlue) {
  13399. dest[_k + 2] = transferMapBlue[dest[_k + 2]];
  13400. }
  13401. }
  13402. }
  13403. ctx.putImageData(chunkImgData, 0, j);
  13404. j += FULL_CHUNK_HEIGHT;
  13405. }
  13406. if (i < totalChunks) {
  13407. elemsInThisChunk = width * partialChunkHeight * 4;
  13408. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  13409. if (hasTransferMaps) {
  13410. for (var _k2 = 0; _k2 < elemsInThisChunk; _k2 += 4) {
  13411. if (transferMapRed) {
  13412. dest[_k2 + 0] = transferMapRed[dest[_k2 + 0]];
  13413. }
  13414. if (transferMapGreen) {
  13415. dest[_k2 + 1] = transferMapGreen[dest[_k2 + 1]];
  13416. }
  13417. if (transferMapBlue) {
  13418. dest[_k2 + 2] = transferMapBlue[dest[_k2 + 2]];
  13419. }
  13420. }
  13421. }
  13422. ctx.putImageData(chunkImgData, 0, j);
  13423. }
  13424. } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
  13425. var _hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
  13426. thisChunkHeight = FULL_CHUNK_HEIGHT;
  13427. elemsInThisChunk = width * thisChunkHeight;
  13428. for (i = 0; i < totalChunks; i++) {
  13429. if (i >= fullChunks) {
  13430. thisChunkHeight = partialChunkHeight;
  13431. elemsInThisChunk = width * thisChunkHeight;
  13432. }
  13433. destPos = 0;
  13434. for (j = elemsInThisChunk; j--;) {
  13435. dest[destPos++] = src[srcPos++];
  13436. dest[destPos++] = src[srcPos++];
  13437. dest[destPos++] = src[srcPos++];
  13438. dest[destPos++] = 255;
  13439. }
  13440. if (_hasTransferMaps) {
  13441. for (var _k3 = 0; _k3 < destPos; _k3 += 4) {
  13442. if (transferMapRed) {
  13443. dest[_k3 + 0] = transferMapRed[dest[_k3 + 0]];
  13444. }
  13445. if (transferMapGreen) {
  13446. dest[_k3 + 1] = transferMapGreen[dest[_k3 + 1]];
  13447. }
  13448. if (transferMapBlue) {
  13449. dest[_k3 + 2] = transferMapBlue[dest[_k3 + 2]];
  13450. }
  13451. }
  13452. }
  13453. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  13454. }
  13455. } else {
  13456. throw new Error("bad image kind: ".concat(imgData.kind));
  13457. }
  13458. }
  13459. function putBinaryImageMask(ctx, imgData) {
  13460. var height = imgData.height,
  13461. width = imgData.width;
  13462. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  13463. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  13464. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  13465. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  13466. var srcPos = 0;
  13467. var src = imgData.data;
  13468. var dest = chunkImgData.data;
  13469. for (var i = 0; i < totalChunks; i++) {
  13470. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  13471. var destPos = 3;
  13472. for (var j = 0; j < thisChunkHeight; j++) {
  13473. var elem = void 0,
  13474. mask = 0;
  13475. for (var k = 0; k < width; k++) {
  13476. if (!mask) {
  13477. elem = src[srcPos++];
  13478. mask = 128;
  13479. }
  13480. dest[destPos] = elem & mask ? 0 : 255;
  13481. destPos += 4;
  13482. mask >>= 1;
  13483. }
  13484. }
  13485. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  13486. }
  13487. }
  13488. function copyCtxState(sourceCtx, destCtx) {
  13489. var properties = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font"];
  13490. for (var i = 0, ii = properties.length; i < ii; i++) {
  13491. var property = properties[i];
  13492. if (sourceCtx[property] !== undefined) {
  13493. destCtx[property] = sourceCtx[property];
  13494. }
  13495. }
  13496. if (sourceCtx.setLineDash !== undefined) {
  13497. destCtx.setLineDash(sourceCtx.getLineDash());
  13498. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  13499. }
  13500. }
  13501. function resetCtxToDefault(ctx) {
  13502. ctx.strokeStyle = "#000000";
  13503. ctx.fillStyle = "#000000";
  13504. ctx.fillRule = "nonzero";
  13505. ctx.globalAlpha = 1;
  13506. ctx.lineWidth = 1;
  13507. ctx.lineCap = "butt";
  13508. ctx.lineJoin = "miter";
  13509. ctx.miterLimit = 10;
  13510. ctx.globalCompositeOperation = "source-over";
  13511. ctx.font = "10px sans-serif";
  13512. if (ctx.setLineDash !== undefined) {
  13513. ctx.setLineDash([]);
  13514. ctx.lineDashOffset = 0;
  13515. }
  13516. }
  13517. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  13518. var length = bytes.length;
  13519. for (var i = 3; i < length; i += 4) {
  13520. var alpha = bytes[i];
  13521. if (alpha === 0) {
  13522. bytes[i - 3] = r0;
  13523. bytes[i - 2] = g0;
  13524. bytes[i - 1] = b0;
  13525. } else if (alpha < 255) {
  13526. var alpha_ = 255 - alpha;
  13527. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  13528. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  13529. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  13530. }
  13531. }
  13532. }
  13533. function composeSMaskAlpha(maskData, layerData, transferMap) {
  13534. var length = maskData.length;
  13535. var scale = 1 / 255;
  13536. for (var i = 3; i < length; i += 4) {
  13537. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  13538. layerData[i] = layerData[i] * alpha * scale | 0;
  13539. }
  13540. }
  13541. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  13542. var length = maskData.length;
  13543. for (var i = 3; i < length; i += 4) {
  13544. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  13545. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  13546. }
  13547. }
  13548. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  13549. var hasBackdrop = !!backdrop;
  13550. var r0 = hasBackdrop ? backdrop[0] : 0;
  13551. var g0 = hasBackdrop ? backdrop[1] : 0;
  13552. var b0 = hasBackdrop ? backdrop[2] : 0;
  13553. var composeFn;
  13554. if (subtype === "Luminosity") {
  13555. composeFn = composeSMaskLuminosity;
  13556. } else {
  13557. composeFn = composeSMaskAlpha;
  13558. }
  13559. var PIXELS_TO_PROCESS = 1048576;
  13560. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  13561. for (var row = 0; row < height; row += chunkSize) {
  13562. var chunkHeight = Math.min(chunkSize, height - row);
  13563. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  13564. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  13565. if (hasBackdrop) {
  13566. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  13567. }
  13568. composeFn(maskData.data, layerData.data, transferMap);
  13569. maskCtx.putImageData(layerData, 0, row);
  13570. }
  13571. }
  13572. function composeSMask(ctx, smask, layerCtx, webGLContext) {
  13573. var mask = smask.canvas;
  13574. var maskCtx = smask.context;
  13575. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  13576. var backdrop = smask.backdrop || null;
  13577. if (!smask.transferMap && webGLContext.isEnabled) {
  13578. var composed = webGLContext.composeSMask({
  13579. layer: layerCtx.canvas,
  13580. mask: mask,
  13581. properties: {
  13582. subtype: smask.subtype,
  13583. backdrop: backdrop
  13584. }
  13585. });
  13586. ctx.setTransform(1, 0, 0, 1, 0, 0);
  13587. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  13588. return;
  13589. }
  13590. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  13591. ctx.drawImage(mask, 0, 0);
  13592. }
  13593. var LINE_CAP_STYLES = ["butt", "round", "square"];
  13594. var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
  13595. var NORMAL_CLIP = {};
  13596. var EO_CLIP = {};
  13597. CanvasGraphics.prototype = {
  13598. beginDrawing: function beginDrawing(_ref2) {
  13599. var transform = _ref2.transform,
  13600. viewport = _ref2.viewport,
  13601. _ref2$transparency = _ref2.transparency,
  13602. transparency = _ref2$transparency === void 0 ? false : _ref2$transparency,
  13603. _ref2$background = _ref2.background,
  13604. background = _ref2$background === void 0 ? null : _ref2$background;
  13605. var width = this.ctx.canvas.width;
  13606. var height = this.ctx.canvas.height;
  13607. this.ctx.save();
  13608. this.ctx.fillStyle = background || "rgb(255, 255, 255)";
  13609. this.ctx.fillRect(0, 0, width, height);
  13610. this.ctx.restore();
  13611. if (transparency) {
  13612. var transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height, true);
  13613. this.compositeCtx = this.ctx;
  13614. this.transparentCanvas = transparentCanvas.canvas;
  13615. this.ctx = transparentCanvas.context;
  13616. this.ctx.save();
  13617. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  13618. }
  13619. this.ctx.save();
  13620. resetCtxToDefault(this.ctx);
  13621. if (transform) {
  13622. this.ctx.transform.apply(this.ctx, transform);
  13623. }
  13624. this.ctx.transform.apply(this.ctx, viewport.transform);
  13625. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  13626. this._combinedScaleFactor = Math.hypot(this.baseTransform[0], this.baseTransform[2]);
  13627. if (this.imageLayer) {
  13628. this.imageLayer.beginLayout();
  13629. }
  13630. },
  13631. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  13632. var argsArray = operatorList.argsArray;
  13633. var fnArray = operatorList.fnArray;
  13634. var i = executionStartIdx || 0;
  13635. var argsArrayLen = argsArray.length;
  13636. if (argsArrayLen === i) {
  13637. return i;
  13638. }
  13639. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === "function";
  13640. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  13641. var steps = 0;
  13642. var commonObjs = this.commonObjs;
  13643. var objs = this.objs;
  13644. var fnId;
  13645. while (true) {
  13646. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  13647. stepper.breakIt(i, continueCallback);
  13648. return i;
  13649. }
  13650. fnId = fnArray[i];
  13651. if (fnId !== _util.OPS.dependency) {
  13652. this[fnId].apply(this, argsArray[i]);
  13653. } else {
  13654. var _iterator = _createForOfIteratorHelper(argsArray[i]),
  13655. _step;
  13656. try {
  13657. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13658. var depObjId = _step.value;
  13659. var objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
  13660. if (!objsPool.has(depObjId)) {
  13661. objsPool.get(depObjId, continueCallback);
  13662. return i;
  13663. }
  13664. }
  13665. } catch (err) {
  13666. _iterator.e(err);
  13667. } finally {
  13668. _iterator.f();
  13669. }
  13670. }
  13671. i++;
  13672. if (i === argsArrayLen) {
  13673. return i;
  13674. }
  13675. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  13676. if (Date.now() > endTime) {
  13677. continueCallback();
  13678. return i;
  13679. }
  13680. steps = 0;
  13681. }
  13682. }
  13683. },
  13684. endDrawing: function CanvasGraphics_endDrawing() {
  13685. while (this.stateStack.length || this.current.activeSMask !== null) {
  13686. this.restore();
  13687. }
  13688. this.ctx.restore();
  13689. if (this.transparentCanvas) {
  13690. this.ctx = this.compositeCtx;
  13691. this.ctx.save();
  13692. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  13693. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  13694. this.ctx.restore();
  13695. this.transparentCanvas = null;
  13696. }
  13697. this.cachedCanvases.clear();
  13698. this.webGLContext.clear();
  13699. if (this.imageLayer) {
  13700. this.imageLayer.endLayout();
  13701. }
  13702. },
  13703. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  13704. this.current.lineWidth = width;
  13705. this.ctx.lineWidth = width;
  13706. },
  13707. setLineCap: function CanvasGraphics_setLineCap(style) {
  13708. this.ctx.lineCap = LINE_CAP_STYLES[style];
  13709. },
  13710. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  13711. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  13712. },
  13713. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  13714. this.ctx.miterLimit = limit;
  13715. },
  13716. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  13717. var ctx = this.ctx;
  13718. if (ctx.setLineDash !== undefined) {
  13719. ctx.setLineDash(dashArray);
  13720. ctx.lineDashOffset = dashPhase;
  13721. }
  13722. },
  13723. setRenderingIntent: function setRenderingIntent(intent) {},
  13724. setFlatness: function setFlatness(flatness) {},
  13725. setGState: function CanvasGraphics_setGState(states) {
  13726. for (var i = 0, ii = states.length; i < ii; i++) {
  13727. var state = states[i];
  13728. var key = state[0];
  13729. var value = state[1];
  13730. switch (key) {
  13731. case "LW":
  13732. this.setLineWidth(value);
  13733. break;
  13734. case "LC":
  13735. this.setLineCap(value);
  13736. break;
  13737. case "LJ":
  13738. this.setLineJoin(value);
  13739. break;
  13740. case "ML":
  13741. this.setMiterLimit(value);
  13742. break;
  13743. case "D":
  13744. this.setDash(value[0], value[1]);
  13745. break;
  13746. case "RI":
  13747. this.setRenderingIntent(value);
  13748. break;
  13749. case "FL":
  13750. this.setFlatness(value);
  13751. break;
  13752. case "Font":
  13753. this.setFont(value[0], value[1]);
  13754. break;
  13755. case "CA":
  13756. this.current.strokeAlpha = state[1];
  13757. break;
  13758. case "ca":
  13759. this.current.fillAlpha = state[1];
  13760. this.ctx.globalAlpha = state[1];
  13761. break;
  13762. case "BM":
  13763. this.ctx.globalCompositeOperation = value;
  13764. break;
  13765. case "SMask":
  13766. if (this.current.activeSMask) {
  13767. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  13768. this.suspendSMaskGroup();
  13769. } else {
  13770. this.endSMaskGroup();
  13771. }
  13772. }
  13773. this.current.activeSMask = value ? this.tempSMask : null;
  13774. if (this.current.activeSMask) {
  13775. this.beginSMaskGroup();
  13776. }
  13777. this.tempSMask = null;
  13778. break;
  13779. case "TR":
  13780. this.current.transferMaps = value;
  13781. }
  13782. }
  13783. },
  13784. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  13785. var activeSMask = this.current.activeSMask;
  13786. var drawnWidth = activeSMask.canvas.width;
  13787. var drawnHeight = activeSMask.canvas.height;
  13788. var cacheId = "smaskGroupAt" + this.groupLevel;
  13789. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  13790. var currentCtx = this.ctx;
  13791. var currentTransform = currentCtx.mozCurrentTransform;
  13792. this.ctx.save();
  13793. var groupCtx = scratchCanvas.context;
  13794. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  13795. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  13796. groupCtx.transform.apply(groupCtx, currentTransform);
  13797. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  13798. copyCtxState(currentCtx, groupCtx);
  13799. this.ctx = groupCtx;
  13800. this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
  13801. this.groupStack.push(currentCtx);
  13802. this.groupLevel++;
  13803. },
  13804. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  13805. var groupCtx = this.ctx;
  13806. this.groupLevel--;
  13807. this.ctx = this.groupStack.pop();
  13808. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  13809. this.ctx.restore();
  13810. this.ctx.save();
  13811. copyCtxState(groupCtx, this.ctx);
  13812. this.current.resumeSMaskCtx = groupCtx;
  13813. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  13814. this.ctx.transform.apply(this.ctx, deltaTransform);
  13815. groupCtx.save();
  13816. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  13817. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  13818. groupCtx.restore();
  13819. },
  13820. resumeSMaskGroup: function CanvasGraphics_resumeSMaskGroup() {
  13821. var groupCtx = this.current.resumeSMaskCtx;
  13822. var currentCtx = this.ctx;
  13823. this.ctx = groupCtx;
  13824. this.groupStack.push(currentCtx);
  13825. this.groupLevel++;
  13826. },
  13827. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  13828. var groupCtx = this.ctx;
  13829. this.groupLevel--;
  13830. this.ctx = this.groupStack.pop();
  13831. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  13832. this.ctx.restore();
  13833. copyCtxState(groupCtx, this.ctx);
  13834. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  13835. this.ctx.transform.apply(this.ctx, deltaTransform);
  13836. },
  13837. save: function CanvasGraphics_save() {
  13838. this.ctx.save();
  13839. var old = this.current;
  13840. this.stateStack.push(old);
  13841. this.current = old.clone();
  13842. this.current.resumeSMaskCtx = null;
  13843. },
  13844. restore: function CanvasGraphics_restore() {
  13845. if (this.current.resumeSMaskCtx) {
  13846. this.resumeSMaskGroup();
  13847. }
  13848. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  13849. this.endSMaskGroup();
  13850. }
  13851. if (this.stateStack.length !== 0) {
  13852. this.current = this.stateStack.pop();
  13853. this.ctx.restore();
  13854. this.pendingClip = null;
  13855. this._cachedGetSinglePixelWidth = null;
  13856. } else {
  13857. this.current.activeSMask = null;
  13858. }
  13859. },
  13860. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  13861. this.ctx.transform(a, b, c, d, e, f);
  13862. this._cachedGetSinglePixelWidth = null;
  13863. },
  13864. constructPath: function CanvasGraphics_constructPath(ops, args) {
  13865. var ctx = this.ctx;
  13866. var current = this.current;
  13867. var x = current.x,
  13868. y = current.y;
  13869. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  13870. switch (ops[i] | 0) {
  13871. case _util.OPS.rectangle:
  13872. x = args[j++];
  13873. y = args[j++];
  13874. var width = args[j++];
  13875. var height = args[j++];
  13876. var xw = x + width;
  13877. var yh = y + height;
  13878. ctx.moveTo(x, y);
  13879. if (width === 0 || height === 0) {
  13880. ctx.lineTo(xw, yh);
  13881. } else {
  13882. ctx.lineTo(xw, y);
  13883. ctx.lineTo(xw, yh);
  13884. ctx.lineTo(x, yh);
  13885. }
  13886. ctx.closePath();
  13887. break;
  13888. case _util.OPS.moveTo:
  13889. x = args[j++];
  13890. y = args[j++];
  13891. ctx.moveTo(x, y);
  13892. break;
  13893. case _util.OPS.lineTo:
  13894. x = args[j++];
  13895. y = args[j++];
  13896. ctx.lineTo(x, y);
  13897. break;
  13898. case _util.OPS.curveTo:
  13899. x = args[j + 4];
  13900. y = args[j + 5];
  13901. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  13902. j += 6;
  13903. break;
  13904. case _util.OPS.curveTo2:
  13905. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  13906. x = args[j + 2];
  13907. y = args[j + 3];
  13908. j += 4;
  13909. break;
  13910. case _util.OPS.curveTo3:
  13911. x = args[j + 2];
  13912. y = args[j + 3];
  13913. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  13914. j += 4;
  13915. break;
  13916. case _util.OPS.closePath:
  13917. ctx.closePath();
  13918. break;
  13919. }
  13920. }
  13921. current.setCurrentPoint(x, y);
  13922. },
  13923. closePath: function CanvasGraphics_closePath() {
  13924. this.ctx.closePath();
  13925. },
  13926. stroke: function CanvasGraphics_stroke(consumePath) {
  13927. consumePath = typeof consumePath !== "undefined" ? consumePath : true;
  13928. var ctx = this.ctx;
  13929. var strokeColor = this.current.strokeColor;
  13930. ctx.globalAlpha = this.current.strokeAlpha;
  13931. if (this.contentVisible) {
  13932. if (_typeof(strokeColor) === "object" && strokeColor !== null && strokeColor !== void 0 && strokeColor.getPattern) {
  13933. ctx.save();
  13934. var transform = ctx.mozCurrentTransform;
  13935. var scale = _util.Util.singularValueDecompose2dScale(transform)[0];
  13936. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  13937. var lineWidth = this.getSinglePixelWidth();
  13938. var scaledLineWidth = this.current.lineWidth * scale;
  13939. if (lineWidth < 0 && -lineWidth >= scaledLineWidth) {
  13940. ctx.resetTransform();
  13941. ctx.lineWidth = Math.round(this._combinedScaleFactor);
  13942. } else {
  13943. ctx.lineWidth = Math.max(lineWidth, scaledLineWidth);
  13944. }
  13945. ctx.stroke();
  13946. ctx.restore();
  13947. } else {
  13948. var _lineWidth = this.getSinglePixelWidth();
  13949. if (_lineWidth < 0 && -_lineWidth >= this.current.lineWidth) {
  13950. ctx.save();
  13951. ctx.resetTransform();
  13952. ctx.lineWidth = Math.round(this._combinedScaleFactor);
  13953. ctx.stroke();
  13954. ctx.restore();
  13955. } else {
  13956. ctx.lineWidth = Math.max(_lineWidth, this.current.lineWidth);
  13957. ctx.stroke();
  13958. }
  13959. }
  13960. }
  13961. if (consumePath) {
  13962. this.consumePath();
  13963. }
  13964. ctx.globalAlpha = this.current.fillAlpha;
  13965. },
  13966. closeStroke: function CanvasGraphics_closeStroke() {
  13967. this.closePath();
  13968. this.stroke();
  13969. },
  13970. fill: function CanvasGraphics_fill(consumePath) {
  13971. consumePath = typeof consumePath !== "undefined" ? consumePath : true;
  13972. var ctx = this.ctx;
  13973. var fillColor = this.current.fillColor;
  13974. var isPatternFill = this.current.patternFill;
  13975. var needRestore = false;
  13976. if (isPatternFill) {
  13977. ctx.save();
  13978. if (this.baseTransform) {
  13979. ctx.setTransform.apply(ctx, this.baseTransform);
  13980. }
  13981. ctx.fillStyle = fillColor.getPattern(ctx, this);
  13982. needRestore = true;
  13983. }
  13984. if (this.contentVisible) {
  13985. if (this.pendingEOFill) {
  13986. ctx.fill("evenodd");
  13987. this.pendingEOFill = false;
  13988. } else {
  13989. ctx.fill();
  13990. }
  13991. }
  13992. if (needRestore) {
  13993. ctx.restore();
  13994. }
  13995. if (consumePath) {
  13996. this.consumePath();
  13997. }
  13998. },
  13999. eoFill: function CanvasGraphics_eoFill() {
  14000. this.pendingEOFill = true;
  14001. this.fill();
  14002. },
  14003. fillStroke: function CanvasGraphics_fillStroke() {
  14004. this.fill(false);
  14005. this.stroke(false);
  14006. this.consumePath();
  14007. },
  14008. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  14009. this.pendingEOFill = true;
  14010. this.fillStroke();
  14011. },
  14012. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  14013. this.closePath();
  14014. this.fillStroke();
  14015. },
  14016. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  14017. this.pendingEOFill = true;
  14018. this.closePath();
  14019. this.fillStroke();
  14020. },
  14021. endPath: function CanvasGraphics_endPath() {
  14022. this.consumePath();
  14023. },
  14024. clip: function CanvasGraphics_clip() {
  14025. this.pendingClip = NORMAL_CLIP;
  14026. },
  14027. eoClip: function CanvasGraphics_eoClip() {
  14028. this.pendingClip = EO_CLIP;
  14029. },
  14030. beginText: function CanvasGraphics_beginText() {
  14031. this.current.textMatrix = _util.IDENTITY_MATRIX;
  14032. this.current.textMatrixScale = 1;
  14033. this.current.x = this.current.lineX = 0;
  14034. this.current.y = this.current.lineY = 0;
  14035. },
  14036. endText: function CanvasGraphics_endText() {
  14037. var paths = this.pendingTextPaths;
  14038. var ctx = this.ctx;
  14039. if (paths === undefined) {
  14040. ctx.beginPath();
  14041. return;
  14042. }
  14043. ctx.save();
  14044. ctx.beginPath();
  14045. for (var i = 0; i < paths.length; i++) {
  14046. var path = paths[i];
  14047. ctx.setTransform.apply(ctx, path.transform);
  14048. ctx.translate(path.x, path.y);
  14049. path.addToPath(ctx, path.fontSize);
  14050. }
  14051. ctx.restore();
  14052. ctx.clip();
  14053. ctx.beginPath();
  14054. delete this.pendingTextPaths;
  14055. },
  14056. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  14057. this.current.charSpacing = spacing;
  14058. },
  14059. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  14060. this.current.wordSpacing = spacing;
  14061. },
  14062. setHScale: function CanvasGraphics_setHScale(scale) {
  14063. this.current.textHScale = scale / 100;
  14064. },
  14065. setLeading: function CanvasGraphics_setLeading(leading) {
  14066. this.current.leading = -leading;
  14067. },
  14068. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  14069. var fontObj = this.commonObjs.get(fontRefName);
  14070. var current = this.current;
  14071. if (!fontObj) {
  14072. throw new Error("Can't find font for ".concat(fontRefName));
  14073. }
  14074. current.fontMatrix = fontObj.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  14075. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  14076. (0, _util.warn)("Invalid font matrix for font " + fontRefName);
  14077. }
  14078. if (size < 0) {
  14079. size = -size;
  14080. current.fontDirection = -1;
  14081. } else {
  14082. current.fontDirection = 1;
  14083. }
  14084. this.current.font = fontObj;
  14085. this.current.fontSize = size;
  14086. if (fontObj.isType3Font) {
  14087. return;
  14088. }
  14089. var name = fontObj.loadedName || "sans-serif";
  14090. var bold = "normal";
  14091. if (fontObj.black) {
  14092. bold = "900";
  14093. } else if (fontObj.bold) {
  14094. bold = "bold";
  14095. }
  14096. var italic = fontObj.italic ? "italic" : "normal";
  14097. var typeface = "\"".concat(name, "\", ").concat(fontObj.fallbackName);
  14098. var browserFontSize = size;
  14099. if (size < MIN_FONT_SIZE) {
  14100. browserFontSize = MIN_FONT_SIZE;
  14101. } else if (size > MAX_FONT_SIZE) {
  14102. browserFontSize = MAX_FONT_SIZE;
  14103. }
  14104. this.current.fontSizeScale = size / browserFontSize;
  14105. this.ctx.font = "".concat(italic, " ").concat(bold, " ").concat(browserFontSize, "px ").concat(typeface);
  14106. },
  14107. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  14108. this.current.textRenderingMode = mode;
  14109. },
  14110. setTextRise: function CanvasGraphics_setTextRise(rise) {
  14111. this.current.textRise = rise;
  14112. },
  14113. moveText: function CanvasGraphics_moveText(x, y) {
  14114. this.current.x = this.current.lineX += x;
  14115. this.current.y = this.current.lineY += y;
  14116. },
  14117. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  14118. this.setLeading(-y);
  14119. this.moveText(x, y);
  14120. },
  14121. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  14122. this.current.textMatrix = [a, b, c, d, e, f];
  14123. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  14124. this.current.x = this.current.lineX = 0;
  14125. this.current.y = this.current.lineY = 0;
  14126. },
  14127. nextLine: function CanvasGraphics_nextLine() {
  14128. this.moveText(0, this.current.leading);
  14129. },
  14130. paintChar: function paintChar(character, x, y, patternTransform, resetLineWidthToOne) {
  14131. var ctx = this.ctx;
  14132. var current = this.current;
  14133. var font = current.font;
  14134. var textRenderingMode = current.textRenderingMode;
  14135. var fontSize = current.fontSize / current.fontSizeScale;
  14136. var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  14137. var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  14138. var patternFill = current.patternFill && !font.missingFile;
  14139. var addToPath;
  14140. if (font.disableFontFace || isAddToPathSet || patternFill) {
  14141. addToPath = font.getPathGenerator(this.commonObjs, character);
  14142. }
  14143. if (font.disableFontFace || patternFill) {
  14144. ctx.save();
  14145. ctx.translate(x, y);
  14146. ctx.beginPath();
  14147. addToPath(ctx, fontSize);
  14148. if (patternTransform) {
  14149. ctx.setTransform.apply(ctx, patternTransform);
  14150. }
  14151. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  14152. ctx.fill();
  14153. }
  14154. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  14155. if (resetLineWidthToOne) {
  14156. ctx.resetTransform();
  14157. ctx.lineWidth = Math.round(this._combinedScaleFactor);
  14158. }
  14159. ctx.stroke();
  14160. }
  14161. ctx.restore();
  14162. } else {
  14163. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  14164. ctx.fillText(character, x, y);
  14165. }
  14166. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  14167. if (resetLineWidthToOne) {
  14168. ctx.save();
  14169. ctx.moveTo(x, y);
  14170. ctx.resetTransform();
  14171. ctx.lineWidth = Math.round(this._combinedScaleFactor);
  14172. ctx.strokeText(character, 0, 0);
  14173. ctx.restore();
  14174. } else {
  14175. ctx.strokeText(character, x, y);
  14176. }
  14177. }
  14178. }
  14179. if (isAddToPathSet) {
  14180. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  14181. paths.push({
  14182. transform: ctx.mozCurrentTransform,
  14183. x: x,
  14184. y: y,
  14185. fontSize: fontSize,
  14186. addToPath: addToPath
  14187. });
  14188. }
  14189. },
  14190. get isFontSubpixelAAEnabled() {
  14191. var _this$cachedCanvases$ = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10),
  14192. ctx = _this$cachedCanvases$.context;
  14193. ctx.scale(1.5, 1);
  14194. ctx.fillText("I", 0, 10);
  14195. var data = ctx.getImageData(0, 0, 10, 10).data;
  14196. var enabled = false;
  14197. for (var i = 3; i < data.length; i += 4) {
  14198. if (data[i] > 0 && data[i] < 255) {
  14199. enabled = true;
  14200. break;
  14201. }
  14202. }
  14203. return (0, _util.shadow)(this, "isFontSubpixelAAEnabled", enabled);
  14204. },
  14205. showText: function CanvasGraphics_showText(glyphs) {
  14206. var current = this.current;
  14207. var font = current.font;
  14208. if (font.isType3Font) {
  14209. return this.showType3Text(glyphs);
  14210. }
  14211. var fontSize = current.fontSize;
  14212. if (fontSize === 0) {
  14213. return undefined;
  14214. }
  14215. var ctx = this.ctx;
  14216. var fontSizeScale = current.fontSizeScale;
  14217. var charSpacing = current.charSpacing;
  14218. var wordSpacing = current.wordSpacing;
  14219. var fontDirection = current.fontDirection;
  14220. var textHScale = current.textHScale * fontDirection;
  14221. var glyphsLength = glyphs.length;
  14222. var vertical = font.vertical;
  14223. var spacingDir = vertical ? 1 : -1;
  14224. var defaultVMetrics = font.defaultVMetrics;
  14225. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  14226. var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
  14227. ctx.save();
  14228. var patternTransform;
  14229. if (current.patternFill) {
  14230. ctx.save();
  14231. var pattern = current.fillColor.getPattern(ctx, this);
  14232. patternTransform = ctx.mozCurrentTransform;
  14233. ctx.restore();
  14234. ctx.fillStyle = pattern;
  14235. }
  14236. ctx.transform.apply(ctx, current.textMatrix);
  14237. ctx.translate(current.x, current.y + current.textRise);
  14238. if (fontDirection > 0) {
  14239. ctx.scale(textHScale, -1);
  14240. } else {
  14241. ctx.scale(textHScale, 1);
  14242. }
  14243. var lineWidth = current.lineWidth;
  14244. var resetLineWidthToOne = false;
  14245. var scale = current.textMatrixScale;
  14246. if (scale === 0 || lineWidth === 0) {
  14247. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  14248. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  14249. this._cachedGetSinglePixelWidth = null;
  14250. lineWidth = this.getSinglePixelWidth();
  14251. resetLineWidthToOne = lineWidth < 0;
  14252. }
  14253. } else {
  14254. lineWidth /= scale;
  14255. }
  14256. if (fontSizeScale !== 1.0) {
  14257. ctx.scale(fontSizeScale, fontSizeScale);
  14258. lineWidth /= fontSizeScale;
  14259. }
  14260. ctx.lineWidth = lineWidth;
  14261. var x = 0,
  14262. i;
  14263. for (i = 0; i < glyphsLength; ++i) {
  14264. var glyph = glyphs[i];
  14265. if ((0, _util.isNum)(glyph)) {
  14266. x += spacingDir * glyph * fontSize / 1000;
  14267. continue;
  14268. }
  14269. var restoreNeeded = false;
  14270. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  14271. var character = glyph.fontChar;
  14272. var accent = glyph.accent;
  14273. var scaledX = void 0,
  14274. scaledY = void 0;
  14275. var width = glyph.width;
  14276. if (vertical) {
  14277. var vmetric = glyph.vmetric || defaultVMetrics;
  14278. var vx = -(glyph.vmetric ? vmetric[1] : width * 0.5) * widthAdvanceScale;
  14279. var vy = vmetric[2] * widthAdvanceScale;
  14280. width = vmetric ? -vmetric[0] : width;
  14281. scaledX = vx / fontSizeScale;
  14282. scaledY = (x + vy) / fontSizeScale;
  14283. } else {
  14284. scaledX = x / fontSizeScale;
  14285. scaledY = 0;
  14286. }
  14287. if (font.remeasure && width > 0) {
  14288. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  14289. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  14290. var characterScaleX = width / measuredWidth;
  14291. restoreNeeded = true;
  14292. ctx.save();
  14293. ctx.scale(characterScaleX, 1);
  14294. scaledX /= characterScaleX;
  14295. } else if (width !== measuredWidth) {
  14296. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  14297. }
  14298. }
  14299. if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
  14300. if (simpleFillText && !accent) {
  14301. ctx.fillText(character, scaledX, scaledY);
  14302. } else {
  14303. this.paintChar(character, scaledX, scaledY, patternTransform, resetLineWidthToOne);
  14304. if (accent) {
  14305. var scaledAccentX = scaledX + fontSize * accent.offset.x / fontSizeScale;
  14306. var scaledAccentY = scaledY - fontSize * accent.offset.y / fontSizeScale;
  14307. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform, resetLineWidthToOne);
  14308. }
  14309. }
  14310. }
  14311. var charWidth = void 0;
  14312. if (vertical) {
  14313. charWidth = width * widthAdvanceScale - spacing * fontDirection;
  14314. } else {
  14315. charWidth = width * widthAdvanceScale + spacing * fontDirection;
  14316. }
  14317. x += charWidth;
  14318. if (restoreNeeded) {
  14319. ctx.restore();
  14320. }
  14321. }
  14322. if (vertical) {
  14323. current.y -= x;
  14324. } else {
  14325. current.x += x * textHScale;
  14326. }
  14327. ctx.restore();
  14328. },
  14329. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  14330. var ctx = this.ctx;
  14331. var current = this.current;
  14332. var font = current.font;
  14333. var fontSize = current.fontSize;
  14334. var fontDirection = current.fontDirection;
  14335. var spacingDir = font.vertical ? 1 : -1;
  14336. var charSpacing = current.charSpacing;
  14337. var wordSpacing = current.wordSpacing;
  14338. var textHScale = current.textHScale * fontDirection;
  14339. var fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  14340. var glyphsLength = glyphs.length;
  14341. var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
  14342. var i, glyph, width, spacingLength;
  14343. if (isTextInvisible || fontSize === 0) {
  14344. return;
  14345. }
  14346. this._cachedGetSinglePixelWidth = null;
  14347. ctx.save();
  14348. ctx.transform.apply(ctx, current.textMatrix);
  14349. ctx.translate(current.x, current.y);
  14350. ctx.scale(textHScale, fontDirection);
  14351. for (i = 0; i < glyphsLength; ++i) {
  14352. glyph = glyphs[i];
  14353. if ((0, _util.isNum)(glyph)) {
  14354. spacingLength = spacingDir * glyph * fontSize / 1000;
  14355. this.ctx.translate(spacingLength, 0);
  14356. current.x += spacingLength * textHScale;
  14357. continue;
  14358. }
  14359. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  14360. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  14361. if (!operatorList) {
  14362. (0, _util.warn)("Type3 character \"".concat(glyph.operatorListId, "\" is not available."));
  14363. continue;
  14364. }
  14365. if (this.contentVisible) {
  14366. this.processingType3 = glyph;
  14367. this.save();
  14368. ctx.scale(fontSize, fontSize);
  14369. ctx.transform.apply(ctx, fontMatrix);
  14370. this.executeOperatorList(operatorList);
  14371. this.restore();
  14372. }
  14373. var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
  14374. width = transformed[0] * fontSize + spacing;
  14375. ctx.translate(width, 0);
  14376. current.x += width * textHScale;
  14377. }
  14378. ctx.restore();
  14379. this.processingType3 = null;
  14380. },
  14381. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {},
  14382. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  14383. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  14384. this.clip();
  14385. this.endPath();
  14386. },
  14387. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  14388. var _this = this;
  14389. var pattern;
  14390. if (IR[0] === "TilingPattern") {
  14391. var color = IR[1];
  14392. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  14393. var canvasGraphicsFactory = {
  14394. createCanvasGraphics: function createCanvasGraphics(ctx) {
  14395. return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory, _this.webGLContext);
  14396. }
  14397. };
  14398. pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  14399. } else {
  14400. pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR);
  14401. }
  14402. return pattern;
  14403. },
  14404. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  14405. this.current.strokeColor = this.getColorN_Pattern(arguments);
  14406. },
  14407. setFillColorN: function CanvasGraphics_setFillColorN() {
  14408. this.current.fillColor = this.getColorN_Pattern(arguments);
  14409. this.current.patternFill = true;
  14410. },
  14411. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  14412. var color = _util.Util.makeHexColor(r, g, b);
  14413. this.ctx.strokeStyle = color;
  14414. this.current.strokeColor = color;
  14415. },
  14416. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  14417. var color = _util.Util.makeHexColor(r, g, b);
  14418. this.ctx.fillStyle = color;
  14419. this.current.fillColor = color;
  14420. this.current.patternFill = false;
  14421. },
  14422. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  14423. if (!this.contentVisible) {
  14424. return;
  14425. }
  14426. var ctx = this.ctx;
  14427. this.save();
  14428. var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
  14429. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  14430. var inv = ctx.mozCurrentTransformInverse;
  14431. if (inv) {
  14432. var canvas = ctx.canvas;
  14433. var width = canvas.width;
  14434. var height = canvas.height;
  14435. var bl = _util.Util.applyTransform([0, 0], inv);
  14436. var br = _util.Util.applyTransform([0, height], inv);
  14437. var ul = _util.Util.applyTransform([width, 0], inv);
  14438. var ur = _util.Util.applyTransform([width, height], inv);
  14439. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  14440. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  14441. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  14442. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  14443. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  14444. } else {
  14445. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  14446. }
  14447. this.restore();
  14448. },
  14449. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  14450. (0, _util.unreachable)("Should not call beginInlineImage");
  14451. },
  14452. beginImageData: function CanvasGraphics_beginImageData() {
  14453. (0, _util.unreachable)("Should not call beginImageData");
  14454. },
  14455. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  14456. if (!this.contentVisible) {
  14457. return;
  14458. }
  14459. this.save();
  14460. this.baseTransformStack.push(this.baseTransform);
  14461. if (Array.isArray(matrix) && matrix.length === 6) {
  14462. this.transform.apply(this, matrix);
  14463. }
  14464. this.baseTransform = this.ctx.mozCurrentTransform;
  14465. if (bbox) {
  14466. var width = bbox[2] - bbox[0];
  14467. var height = bbox[3] - bbox[1];
  14468. this.ctx.rect(bbox[0], bbox[1], width, height);
  14469. this.clip();
  14470. this.endPath();
  14471. }
  14472. },
  14473. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  14474. if (!this.contentVisible) {
  14475. return;
  14476. }
  14477. this.restore();
  14478. this.baseTransform = this.baseTransformStack.pop();
  14479. },
  14480. beginGroup: function CanvasGraphics_beginGroup(group) {
  14481. if (!this.contentVisible) {
  14482. return;
  14483. }
  14484. this.save();
  14485. var currentCtx = this.ctx;
  14486. if (!group.isolated) {
  14487. (0, _util.info)("TODO: Support non-isolated groups.");
  14488. }
  14489. if (group.knockout) {
  14490. (0, _util.warn)("Knockout groups not supported.");
  14491. }
  14492. var currentTransform = currentCtx.mozCurrentTransform;
  14493. if (group.matrix) {
  14494. currentCtx.transform.apply(currentCtx, group.matrix);
  14495. }
  14496. if (!group.bbox) {
  14497. throw new Error("Bounding box is required.");
  14498. }
  14499. var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  14500. var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
  14501. bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
  14502. var offsetX = Math.floor(bounds[0]);
  14503. var offsetY = Math.floor(bounds[1]);
  14504. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  14505. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  14506. var scaleX = 1,
  14507. scaleY = 1;
  14508. if (drawnWidth > MAX_GROUP_SIZE) {
  14509. scaleX = drawnWidth / MAX_GROUP_SIZE;
  14510. drawnWidth = MAX_GROUP_SIZE;
  14511. }
  14512. if (drawnHeight > MAX_GROUP_SIZE) {
  14513. scaleY = drawnHeight / MAX_GROUP_SIZE;
  14514. drawnHeight = MAX_GROUP_SIZE;
  14515. }
  14516. var cacheId = "groupAt" + this.groupLevel;
  14517. if (group.smask) {
  14518. cacheId += "_smask_" + this.smaskCounter++ % 2;
  14519. }
  14520. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  14521. var groupCtx = scratchCanvas.context;
  14522. groupCtx.scale(1 / scaleX, 1 / scaleY);
  14523. groupCtx.translate(-offsetX, -offsetY);
  14524. groupCtx.transform.apply(groupCtx, currentTransform);
  14525. if (group.smask) {
  14526. this.smaskStack.push({
  14527. canvas: scratchCanvas.canvas,
  14528. context: groupCtx,
  14529. offsetX: offsetX,
  14530. offsetY: offsetY,
  14531. scaleX: scaleX,
  14532. scaleY: scaleY,
  14533. subtype: group.smask.subtype,
  14534. backdrop: group.smask.backdrop,
  14535. transferMap: group.smask.transferMap || null,
  14536. startTransformInverse: null
  14537. });
  14538. } else {
  14539. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  14540. currentCtx.translate(offsetX, offsetY);
  14541. currentCtx.scale(scaleX, scaleY);
  14542. }
  14543. copyCtxState(currentCtx, groupCtx);
  14544. this.ctx = groupCtx;
  14545. this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
  14546. this.groupStack.push(currentCtx);
  14547. this.groupLevel++;
  14548. this.current.activeSMask = null;
  14549. },
  14550. endGroup: function CanvasGraphics_endGroup(group) {
  14551. if (!this.contentVisible) {
  14552. return;
  14553. }
  14554. this.groupLevel--;
  14555. var groupCtx = this.ctx;
  14556. this.ctx = this.groupStack.pop();
  14557. if (this.ctx.imageSmoothingEnabled !== undefined) {
  14558. this.ctx.imageSmoothingEnabled = false;
  14559. } else {
  14560. this.ctx.mozImageSmoothingEnabled = false;
  14561. }
  14562. if (group.smask) {
  14563. this.tempSMask = this.smaskStack.pop();
  14564. } else {
  14565. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  14566. }
  14567. this.restore();
  14568. },
  14569. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  14570. this.save();
  14571. if (this.baseTransform) {
  14572. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  14573. }
  14574. },
  14575. endAnnotations: function CanvasGraphics_endAnnotations() {
  14576. this.restore();
  14577. },
  14578. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  14579. this.save();
  14580. resetCtxToDefault(this.ctx);
  14581. this.current = new CanvasExtraState();
  14582. if (Array.isArray(rect) && rect.length === 4) {
  14583. var width = rect[2] - rect[0];
  14584. var height = rect[3] - rect[1];
  14585. this.ctx.rect(rect[0], rect[1], width, height);
  14586. this.clip();
  14587. this.endPath();
  14588. }
  14589. this.transform.apply(this, transform);
  14590. this.transform.apply(this, matrix);
  14591. },
  14592. endAnnotation: function CanvasGraphics_endAnnotation() {
  14593. this.restore();
  14594. },
  14595. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  14596. if (!this.contentVisible) {
  14597. return;
  14598. }
  14599. var ctx = this.ctx;
  14600. var width = img.width,
  14601. height = img.height;
  14602. var fillColor = this.current.fillColor;
  14603. var isPatternFill = this.current.patternFill;
  14604. var glyph = this.processingType3;
  14605. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  14606. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  14607. glyph.compiled = compileType3Glyph({
  14608. data: img.data,
  14609. width: width,
  14610. height: height
  14611. });
  14612. } else {
  14613. glyph.compiled = null;
  14614. }
  14615. }
  14616. if (glyph !== null && glyph !== void 0 && glyph.compiled) {
  14617. glyph.compiled(ctx);
  14618. return;
  14619. }
  14620. var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
  14621. var maskCtx = maskCanvas.context;
  14622. maskCtx.save();
  14623. putBinaryImageMask(maskCtx, img);
  14624. maskCtx.globalCompositeOperation = "source-in";
  14625. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  14626. maskCtx.fillRect(0, 0, width, height);
  14627. maskCtx.restore();
  14628. this.paintInlineImageXObject(maskCanvas.canvas);
  14629. },
  14630. paintImageMaskXObjectRepeat: function paintImageMaskXObjectRepeat(imgData, scaleX) {
  14631. var skewX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  14632. var skewY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  14633. var scaleY = arguments.length > 4 ? arguments[4] : undefined;
  14634. var positions = arguments.length > 5 ? arguments[5] : undefined;
  14635. if (!this.contentVisible) {
  14636. return;
  14637. }
  14638. var width = imgData.width;
  14639. var height = imgData.height;
  14640. var fillColor = this.current.fillColor;
  14641. var isPatternFill = this.current.patternFill;
  14642. var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
  14643. var maskCtx = maskCanvas.context;
  14644. maskCtx.save();
  14645. putBinaryImageMask(maskCtx, imgData);
  14646. maskCtx.globalCompositeOperation = "source-in";
  14647. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  14648. maskCtx.fillRect(0, 0, width, height);
  14649. maskCtx.restore();
  14650. var ctx = this.ctx;
  14651. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  14652. ctx.save();
  14653. ctx.transform(scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]);
  14654. ctx.scale(1, -1);
  14655. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  14656. ctx.restore();
  14657. }
  14658. },
  14659. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  14660. if (!this.contentVisible) {
  14661. return;
  14662. }
  14663. var ctx = this.ctx;
  14664. var fillColor = this.current.fillColor;
  14665. var isPatternFill = this.current.patternFill;
  14666. for (var i = 0, ii = images.length; i < ii; i++) {
  14667. var image = images[i];
  14668. var width = image.width,
  14669. height = image.height;
  14670. var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
  14671. var maskCtx = maskCanvas.context;
  14672. maskCtx.save();
  14673. putBinaryImageMask(maskCtx, image);
  14674. maskCtx.globalCompositeOperation = "source-in";
  14675. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  14676. maskCtx.fillRect(0, 0, width, height);
  14677. maskCtx.restore();
  14678. ctx.save();
  14679. ctx.transform.apply(ctx, image.transform);
  14680. ctx.scale(1, -1);
  14681. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  14682. ctx.restore();
  14683. }
  14684. },
  14685. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  14686. if (!this.contentVisible) {
  14687. return;
  14688. }
  14689. var imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
  14690. if (!imgData) {
  14691. (0, _util.warn)("Dependent image isn't ready yet");
  14692. return;
  14693. }
  14694. this.paintInlineImageXObject(imgData);
  14695. },
  14696. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  14697. if (!this.contentVisible) {
  14698. return;
  14699. }
  14700. var imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
  14701. if (!imgData) {
  14702. (0, _util.warn)("Dependent image isn't ready yet");
  14703. return;
  14704. }
  14705. var width = imgData.width;
  14706. var height = imgData.height;
  14707. var map = [];
  14708. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  14709. map.push({
  14710. transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
  14711. x: 0,
  14712. y: 0,
  14713. w: width,
  14714. h: height
  14715. });
  14716. }
  14717. this.paintInlineImageXObjectGroup(imgData, map);
  14718. },
  14719. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  14720. if (!this.contentVisible) {
  14721. return;
  14722. }
  14723. var width = imgData.width;
  14724. var height = imgData.height;
  14725. var ctx = this.ctx;
  14726. this.save();
  14727. ctx.scale(1 / width, -1 / height);
  14728. var currentTransform = ctx.mozCurrentTransformInverse;
  14729. var a = currentTransform[0],
  14730. b = currentTransform[1];
  14731. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  14732. var c = currentTransform[2],
  14733. d = currentTransform[3];
  14734. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  14735. var imgToPaint, tmpCanvas, tmpCtx;
  14736. if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
  14737. imgToPaint = imgData;
  14738. } else {
  14739. tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
  14740. tmpCtx = tmpCanvas.context;
  14741. putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
  14742. imgToPaint = tmpCanvas.canvas;
  14743. }
  14744. var paintWidth = width,
  14745. paintHeight = height;
  14746. var tmpCanvasId = "prescale1";
  14747. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  14748. var newWidth = paintWidth,
  14749. newHeight = paintHeight;
  14750. if (widthScale > 2 && paintWidth > 1) {
  14751. newWidth = Math.ceil(paintWidth / 2);
  14752. widthScale /= paintWidth / newWidth;
  14753. }
  14754. if (heightScale > 2 && paintHeight > 1) {
  14755. newHeight = Math.ceil(paintHeight / 2);
  14756. heightScale /= paintHeight / newHeight;
  14757. }
  14758. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  14759. tmpCtx = tmpCanvas.context;
  14760. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  14761. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  14762. imgToPaint = tmpCanvas.canvas;
  14763. paintWidth = newWidth;
  14764. paintHeight = newHeight;
  14765. tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
  14766. }
  14767. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  14768. if (this.imageLayer) {
  14769. var position = this.getCanvasPosition(0, -height);
  14770. this.imageLayer.appendImage({
  14771. imgData: imgData,
  14772. left: position[0],
  14773. top: position[1],
  14774. width: width / currentTransform[0],
  14775. height: height / currentTransform[3]
  14776. });
  14777. }
  14778. this.restore();
  14779. },
  14780. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  14781. if (!this.contentVisible) {
  14782. return;
  14783. }
  14784. var ctx = this.ctx;
  14785. var w = imgData.width;
  14786. var h = imgData.height;
  14787. var tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
  14788. var tmpCtx = tmpCanvas.context;
  14789. putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
  14790. for (var i = 0, ii = map.length; i < ii; i++) {
  14791. var entry = map[i];
  14792. ctx.save();
  14793. ctx.transform.apply(ctx, entry.transform);
  14794. ctx.scale(1, -1);
  14795. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  14796. if (this.imageLayer) {
  14797. var position = this.getCanvasPosition(entry.x, entry.y);
  14798. this.imageLayer.appendImage({
  14799. imgData: imgData,
  14800. left: position[0],
  14801. top: position[1],
  14802. width: w,
  14803. height: h
  14804. });
  14805. }
  14806. ctx.restore();
  14807. }
  14808. },
  14809. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  14810. if (!this.contentVisible) {
  14811. return;
  14812. }
  14813. this.ctx.fillRect(0, 0, 1, 1);
  14814. },
  14815. markPoint: function CanvasGraphics_markPoint(tag) {},
  14816. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
  14817. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  14818. this.markedContentStack.push({
  14819. visible: true
  14820. });
  14821. },
  14822. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  14823. if (tag === "OC") {
  14824. this.markedContentStack.push({
  14825. visible: this.optionalContentConfig.isVisible(properties)
  14826. });
  14827. } else {
  14828. this.markedContentStack.push({
  14829. visible: true
  14830. });
  14831. }
  14832. this.contentVisible = this.isContentVisible();
  14833. },
  14834. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  14835. this.markedContentStack.pop();
  14836. this.contentVisible = this.isContentVisible();
  14837. },
  14838. beginCompat: function CanvasGraphics_beginCompat() {},
  14839. endCompat: function CanvasGraphics_endCompat() {},
  14840. consumePath: function CanvasGraphics_consumePath() {
  14841. var ctx = this.ctx;
  14842. if (this.pendingClip) {
  14843. if (this.pendingClip === EO_CLIP) {
  14844. ctx.clip("evenodd");
  14845. } else {
  14846. ctx.clip();
  14847. }
  14848. this.pendingClip = null;
  14849. }
  14850. ctx.beginPath();
  14851. },
  14852. getSinglePixelWidth: function getSinglePixelWidth() {
  14853. if (this._cachedGetSinglePixelWidth === null) {
  14854. var m = this.ctx.mozCurrentTransform;
  14855. var absDet = Math.abs(m[0] * m[3] - m[2] * m[1]);
  14856. var sqNorm1 = Math.pow(m[0], 2) + Math.pow(m[2], 2);
  14857. var sqNorm2 = Math.pow(m[1], 2) + Math.pow(m[3], 2);
  14858. var pixelHeight = Math.sqrt(Math.max(sqNorm1, sqNorm2)) / absDet;
  14859. if (sqNorm1 !== sqNorm2 && this._combinedScaleFactor * pixelHeight > 1) {
  14860. this._cachedGetSinglePixelWidth = -(this._combinedScaleFactor * pixelHeight);
  14861. } else if (absDet > Number.EPSILON) {
  14862. this._cachedGetSinglePixelWidth = pixelHeight * 1.0000001;
  14863. } else {
  14864. this._cachedGetSinglePixelWidth = 1;
  14865. }
  14866. }
  14867. return this._cachedGetSinglePixelWidth;
  14868. },
  14869. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  14870. var transform = this.ctx.mozCurrentTransform;
  14871. return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
  14872. },
  14873. isContentVisible: function CanvasGraphics_isContentVisible() {
  14874. for (var i = this.markedContentStack.length - 1; i >= 0; i--) {
  14875. if (!this.markedContentStack[i].visible) {
  14876. return false;
  14877. }
  14878. }
  14879. return true;
  14880. }
  14881. };
  14882. for (var op in _util.OPS) {
  14883. CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
  14884. }
  14885. return CanvasGraphics;
  14886. }();
  14887. exports.CanvasGraphics = CanvasGraphics;
  14888. /***/ }),
  14889. /* 141 */
  14890. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14891. "use strict";
  14892. Object.defineProperty(exports, "__esModule", ({
  14893. value: true
  14894. }));
  14895. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  14896. exports.TilingPattern = void 0;
  14897. var _util = __w_pdfjs_require__(4);
  14898. var ShadingIRs = {};
  14899. function applyBoundingBox(ctx, bbox) {
  14900. if (!bbox || typeof Path2D === "undefined") {
  14901. return;
  14902. }
  14903. var width = bbox[2] - bbox[0];
  14904. var height = bbox[3] - bbox[1];
  14905. var region = new Path2D();
  14906. region.rect(bbox[0], bbox[1], width, height);
  14907. ctx.clip(region);
  14908. }
  14909. ShadingIRs.RadialAxial = {
  14910. fromIR: function RadialAxial_fromIR(raw) {
  14911. var type = raw[1];
  14912. var bbox = raw[2];
  14913. var colorStops = raw[3];
  14914. var p0 = raw[4];
  14915. var p1 = raw[5];
  14916. var r0 = raw[6];
  14917. var r1 = raw[7];
  14918. return {
  14919. getPattern: function RadialAxial_getPattern(ctx) {
  14920. applyBoundingBox(ctx, bbox);
  14921. var grad;
  14922. if (type === "axial") {
  14923. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  14924. } else if (type === "radial") {
  14925. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  14926. }
  14927. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  14928. var c = colorStops[i];
  14929. grad.addColorStop(c[0], c[1]);
  14930. }
  14931. return grad;
  14932. }
  14933. };
  14934. }
  14935. };
  14936. var createMeshCanvas = function createMeshCanvasClosure() {
  14937. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  14938. var coords = context.coords,
  14939. colors = context.colors;
  14940. var bytes = data.data,
  14941. rowSize = data.width * 4;
  14942. var tmp;
  14943. if (coords[p1 + 1] > coords[p2 + 1]) {
  14944. tmp = p1;
  14945. p1 = p2;
  14946. p2 = tmp;
  14947. tmp = c1;
  14948. c1 = c2;
  14949. c2 = tmp;
  14950. }
  14951. if (coords[p2 + 1] > coords[p3 + 1]) {
  14952. tmp = p2;
  14953. p2 = p3;
  14954. p3 = tmp;
  14955. tmp = c2;
  14956. c2 = c3;
  14957. c3 = tmp;
  14958. }
  14959. if (coords[p1 + 1] > coords[p2 + 1]) {
  14960. tmp = p1;
  14961. p1 = p2;
  14962. p2 = tmp;
  14963. tmp = c1;
  14964. c1 = c2;
  14965. c2 = tmp;
  14966. }
  14967. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  14968. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  14969. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  14970. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  14971. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  14972. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  14973. if (y1 >= y3) {
  14974. return;
  14975. }
  14976. var c1r = colors[c1],
  14977. c1g = colors[c1 + 1],
  14978. c1b = colors[c1 + 2];
  14979. var c2r = colors[c2],
  14980. c2g = colors[c2 + 1],
  14981. c2b = colors[c2 + 2];
  14982. var c3r = colors[c3],
  14983. c3g = colors[c3 + 1],
  14984. c3b = colors[c3 + 2];
  14985. var minY = Math.round(y1),
  14986. maxY = Math.round(y3);
  14987. var xa, car, cag, cab;
  14988. var xb, cbr, cbg, cbb;
  14989. for (var y = minY; y <= maxY; y++) {
  14990. if (y < y2) {
  14991. var _k = void 0;
  14992. if (y < y1) {
  14993. _k = 0;
  14994. } else if (y1 === y2) {
  14995. _k = 1;
  14996. } else {
  14997. _k = (y1 - y) / (y1 - y2);
  14998. }
  14999. xa = x1 - (x1 - x2) * _k;
  15000. car = c1r - (c1r - c2r) * _k;
  15001. cag = c1g - (c1g - c2g) * _k;
  15002. cab = c1b - (c1b - c2b) * _k;
  15003. } else {
  15004. var _k2 = void 0;
  15005. if (y > y3) {
  15006. _k2 = 1;
  15007. } else if (y2 === y3) {
  15008. _k2 = 0;
  15009. } else {
  15010. _k2 = (y2 - y) / (y2 - y3);
  15011. }
  15012. xa = x2 - (x2 - x3) * _k2;
  15013. car = c2r - (c2r - c3r) * _k2;
  15014. cag = c2g - (c2g - c3g) * _k2;
  15015. cab = c2b - (c2b - c3b) * _k2;
  15016. }
  15017. var k = void 0;
  15018. if (y < y1) {
  15019. k = 0;
  15020. } else if (y > y3) {
  15021. k = 1;
  15022. } else {
  15023. k = (y1 - y) / (y1 - y3);
  15024. }
  15025. xb = x1 - (x1 - x3) * k;
  15026. cbr = c1r - (c1r - c3r) * k;
  15027. cbg = c1g - (c1g - c3g) * k;
  15028. cbb = c1b - (c1b - c3b) * k;
  15029. var x1_ = Math.round(Math.min(xa, xb));
  15030. var x2_ = Math.round(Math.max(xa, xb));
  15031. var j = rowSize * y + x1_ * 4;
  15032. for (var x = x1_; x <= x2_; x++) {
  15033. k = (xa - x) / (xa - xb);
  15034. if (k < 0) {
  15035. k = 0;
  15036. } else if (k > 1) {
  15037. k = 1;
  15038. }
  15039. bytes[j++] = car - (car - cbr) * k | 0;
  15040. bytes[j++] = cag - (cag - cbg) * k | 0;
  15041. bytes[j++] = cab - (cab - cbb) * k | 0;
  15042. bytes[j++] = 255;
  15043. }
  15044. }
  15045. }
  15046. function drawFigure(data, figure, context) {
  15047. var ps = figure.coords;
  15048. var cs = figure.colors;
  15049. var i, ii;
  15050. switch (figure.type) {
  15051. case "lattice":
  15052. var verticesPerRow = figure.verticesPerRow;
  15053. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  15054. var cols = verticesPerRow - 1;
  15055. for (i = 0; i < rows; i++) {
  15056. var q = i * verticesPerRow;
  15057. for (var j = 0; j < cols; j++, q++) {
  15058. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  15059. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  15060. }
  15061. }
  15062. break;
  15063. case "triangles":
  15064. for (i = 0, ii = ps.length; i < ii; i += 3) {
  15065. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  15066. }
  15067. break;
  15068. default:
  15069. throw new Error("illegal figure");
  15070. }
  15071. }
  15072. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases, webGLContext) {
  15073. var EXPECTED_SCALE = 1.1;
  15074. var MAX_PATTERN_SIZE = 3000;
  15075. var BORDER_SIZE = 2;
  15076. var offsetX = Math.floor(bounds[0]);
  15077. var offsetY = Math.floor(bounds[1]);
  15078. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  15079. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  15080. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  15081. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  15082. var scaleX = boundsWidth / width;
  15083. var scaleY = boundsHeight / height;
  15084. var context = {
  15085. coords: coords,
  15086. colors: colors,
  15087. offsetX: -offsetX,
  15088. offsetY: -offsetY,
  15089. scaleX: 1 / scaleX,
  15090. scaleY: 1 / scaleY
  15091. };
  15092. var paddedWidth = width + BORDER_SIZE * 2;
  15093. var paddedHeight = height + BORDER_SIZE * 2;
  15094. var canvas, tmpCanvas, i, ii;
  15095. if (webGLContext.isEnabled) {
  15096. canvas = webGLContext.drawFigures({
  15097. width: width,
  15098. height: height,
  15099. backgroundColor: backgroundColor,
  15100. figures: figures,
  15101. context: context
  15102. });
  15103. tmpCanvas = cachedCanvases.getCanvas("mesh", paddedWidth, paddedHeight, false);
  15104. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  15105. canvas = tmpCanvas.canvas;
  15106. } else {
  15107. tmpCanvas = cachedCanvases.getCanvas("mesh", paddedWidth, paddedHeight, false);
  15108. var tmpCtx = tmpCanvas.context;
  15109. var data = tmpCtx.createImageData(width, height);
  15110. if (backgroundColor) {
  15111. var bytes = data.data;
  15112. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  15113. bytes[i] = backgroundColor[0];
  15114. bytes[i + 1] = backgroundColor[1];
  15115. bytes[i + 2] = backgroundColor[2];
  15116. bytes[i + 3] = 255;
  15117. }
  15118. }
  15119. for (i = 0; i < figures.length; i++) {
  15120. drawFigure(data, figures[i], context);
  15121. }
  15122. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  15123. canvas = tmpCanvas.canvas;
  15124. }
  15125. return {
  15126. canvas: canvas,
  15127. offsetX: offsetX - BORDER_SIZE * scaleX,
  15128. offsetY: offsetY - BORDER_SIZE * scaleY,
  15129. scaleX: scaleX,
  15130. scaleY: scaleY
  15131. };
  15132. }
  15133. return createMeshCanvas;
  15134. }();
  15135. ShadingIRs.Mesh = {
  15136. fromIR: function Mesh_fromIR(raw) {
  15137. var coords = raw[2];
  15138. var colors = raw[3];
  15139. var figures = raw[4];
  15140. var bounds = raw[5];
  15141. var matrix = raw[6];
  15142. var bbox = raw[7];
  15143. var background = raw[8];
  15144. return {
  15145. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  15146. applyBoundingBox(ctx, bbox);
  15147. var scale;
  15148. if (shadingFill) {
  15149. scale = _util.Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  15150. } else {
  15151. scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
  15152. if (matrix) {
  15153. var matrixScale = _util.Util.singularValueDecompose2dScale(matrix);
  15154. scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
  15155. }
  15156. }
  15157. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases, owner.webGLContext);
  15158. if (!shadingFill) {
  15159. ctx.setTransform.apply(ctx, owner.baseTransform);
  15160. if (matrix) {
  15161. ctx.transform.apply(ctx, matrix);
  15162. }
  15163. }
  15164. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  15165. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  15166. return ctx.createPattern(temporaryPatternCanvas.canvas, "no-repeat");
  15167. }
  15168. };
  15169. }
  15170. };
  15171. ShadingIRs.Dummy = {
  15172. fromIR: function Dummy_fromIR() {
  15173. return {
  15174. getPattern: function Dummy_fromIR_getPattern() {
  15175. return "hotpink";
  15176. }
  15177. };
  15178. }
  15179. };
  15180. function getShadingPatternFromIR(raw) {
  15181. var shadingIR = ShadingIRs[raw[0]];
  15182. if (!shadingIR) {
  15183. throw new Error("Unknown IR type: ".concat(raw[0]));
  15184. }
  15185. return shadingIR.fromIR(raw);
  15186. }
  15187. var TilingPattern = function TilingPatternClosure() {
  15188. var PaintType = {
  15189. COLORED: 1,
  15190. UNCOLORED: 2
  15191. };
  15192. var MAX_PATTERN_SIZE = 3000;
  15193. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  15194. this.operatorList = IR[2];
  15195. this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
  15196. this.bbox = IR[4];
  15197. this.xstep = IR[5];
  15198. this.ystep = IR[6];
  15199. this.paintType = IR[7];
  15200. this.tilingType = IR[8];
  15201. this.color = color;
  15202. this.canvasGraphicsFactory = canvasGraphicsFactory;
  15203. this.baseTransform = baseTransform;
  15204. this.ctx = ctx;
  15205. }
  15206. TilingPattern.prototype = {
  15207. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  15208. var operatorList = this.operatorList;
  15209. var bbox = this.bbox;
  15210. var xstep = this.xstep;
  15211. var ystep = this.ystep;
  15212. var paintType = this.paintType;
  15213. var tilingType = this.tilingType;
  15214. var color = this.color;
  15215. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  15216. (0, _util.info)("TilingType: " + tilingType);
  15217. var x0 = bbox[0],
  15218. y0 = bbox[1],
  15219. x1 = bbox[2],
  15220. y1 = bbox[3];
  15221. var matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  15222. var curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
  15223. var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
  15224. var dimx = this.getSizeAndScale(xstep, this.ctx.canvas.width, combinedScale[0]);
  15225. var dimy = this.getSizeAndScale(ystep, this.ctx.canvas.height, combinedScale[1]);
  15226. var tmpCanvas = owner.cachedCanvases.getCanvas("pattern", dimx.size, dimy.size, true);
  15227. var tmpCtx = tmpCanvas.context;
  15228. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  15229. graphics.groupLevel = owner.groupLevel;
  15230. this.setFillAndStrokeStyleToContext(graphics, paintType, color);
  15231. graphics.transform(dimx.scale, 0, 0, dimy.scale, 0, 0);
  15232. graphics.transform(1, 0, 0, 1, -x0, -y0);
  15233. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  15234. graphics.executeOperatorList(operatorList);
  15235. this.ctx.transform(1, 0, 0, 1, x0, y0);
  15236. this.ctx.scale(1 / dimx.scale, 1 / dimy.scale);
  15237. return tmpCanvas.canvas;
  15238. },
  15239. getSizeAndScale: function TilingPattern_getSizeAndScale(step, realOutputSize, scale) {
  15240. step = Math.abs(step);
  15241. var maxSize = Math.max(MAX_PATTERN_SIZE, realOutputSize);
  15242. var size = Math.ceil(step * scale);
  15243. if (size >= maxSize) {
  15244. size = maxSize;
  15245. } else {
  15246. scale = size / step;
  15247. }
  15248. return {
  15249. scale: scale,
  15250. size: size
  15251. };
  15252. },
  15253. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  15254. if (Array.isArray(bbox) && bbox.length === 4) {
  15255. var bboxWidth = x1 - x0;
  15256. var bboxHeight = y1 - y0;
  15257. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  15258. graphics.clip();
  15259. graphics.endPath();
  15260. }
  15261. },
  15262. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(graphics, paintType, color) {
  15263. var context = graphics.ctx,
  15264. current = graphics.current;
  15265. switch (paintType) {
  15266. case PaintType.COLORED:
  15267. var ctx = this.ctx;
  15268. context.fillStyle = ctx.fillStyle;
  15269. context.strokeStyle = ctx.strokeStyle;
  15270. current.fillColor = ctx.fillStyle;
  15271. current.strokeColor = ctx.strokeStyle;
  15272. break;
  15273. case PaintType.UNCOLORED:
  15274. var cssColor = _util.Util.makeHexColor(color[0], color[1], color[2]);
  15275. context.fillStyle = cssColor;
  15276. context.strokeStyle = cssColor;
  15277. current.fillColor = cssColor;
  15278. current.strokeColor = cssColor;
  15279. break;
  15280. default:
  15281. throw new _util.FormatError("Unsupported paint type: ".concat(paintType));
  15282. }
  15283. },
  15284. getPattern: function TilingPattern_getPattern(ctx, owner) {
  15285. ctx = this.ctx;
  15286. ctx.setTransform.apply(ctx, this.baseTransform);
  15287. ctx.transform.apply(ctx, this.matrix);
  15288. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  15289. return ctx.createPattern(temporaryPatternCanvas, "repeat");
  15290. }
  15291. };
  15292. return TilingPattern;
  15293. }();
  15294. exports.TilingPattern = TilingPattern;
  15295. /***/ }),
  15296. /* 142 */
  15297. /***/ ((__unused_webpack_module, exports) => {
  15298. "use strict";
  15299. Object.defineProperty(exports, "__esModule", ({
  15300. value: true
  15301. }));
  15302. exports.GlobalWorkerOptions = void 0;
  15303. var GlobalWorkerOptions = Object.create(null);
  15304. exports.GlobalWorkerOptions = GlobalWorkerOptions;
  15305. GlobalWorkerOptions.workerPort = GlobalWorkerOptions.workerPort === undefined ? null : GlobalWorkerOptions.workerPort;
  15306. GlobalWorkerOptions.workerSrc = GlobalWorkerOptions.workerSrc === undefined ? "" : GlobalWorkerOptions.workerSrc;
  15307. /***/ }),
  15308. /* 143 */
  15309. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15310. "use strict";
  15311. Object.defineProperty(exports, "__esModule", ({
  15312. value: true
  15313. }));
  15314. exports.MessageHandler = void 0;
  15315. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  15316. var _util = __w_pdfjs_require__(4);
  15317. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15318. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  15319. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  15320. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15321. 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); } }
  15322. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15323. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15324. var CallbackKind = {
  15325. UNKNOWN: 0,
  15326. DATA: 1,
  15327. ERROR: 2
  15328. };
  15329. var StreamKind = {
  15330. UNKNOWN: 0,
  15331. CANCEL: 1,
  15332. CANCEL_COMPLETE: 2,
  15333. CLOSE: 3,
  15334. ENQUEUE: 4,
  15335. ERROR: 5,
  15336. PULL: 6,
  15337. PULL_COMPLETE: 7,
  15338. START_COMPLETE: 8
  15339. };
  15340. function wrapReason(reason) {
  15341. if (_typeof(reason) !== "object" || reason === null) {
  15342. return reason;
  15343. }
  15344. switch (reason.name) {
  15345. case "AbortException":
  15346. return new _util.AbortException(reason.message);
  15347. case "MissingPDFException":
  15348. return new _util.MissingPDFException(reason.message);
  15349. case "UnexpectedResponseException":
  15350. return new _util.UnexpectedResponseException(reason.message, reason.status);
  15351. case "UnknownErrorException":
  15352. return new _util.UnknownErrorException(reason.message, reason.details);
  15353. default:
  15354. return new _util.UnknownErrorException(reason.message, reason.toString());
  15355. }
  15356. }
  15357. var MessageHandler = /*#__PURE__*/function () {
  15358. function MessageHandler(sourceName, targetName, comObj) {
  15359. var _this = this;
  15360. _classCallCheck(this, MessageHandler);
  15361. this.sourceName = sourceName;
  15362. this.targetName = targetName;
  15363. this.comObj = comObj;
  15364. this.callbackId = 1;
  15365. this.streamId = 1;
  15366. this.postMessageTransfers = true;
  15367. this.streamSinks = Object.create(null);
  15368. this.streamControllers = Object.create(null);
  15369. this.callbackCapabilities = Object.create(null);
  15370. this.actionHandler = Object.create(null);
  15371. this._onComObjOnMessage = function (event) {
  15372. var data = event.data;
  15373. if (data.targetName !== _this.sourceName) {
  15374. return;
  15375. }
  15376. if (data.stream) {
  15377. _this._processStreamMessage(data);
  15378. return;
  15379. }
  15380. if (data.callback) {
  15381. var callbackId = data.callbackId;
  15382. var capability = _this.callbackCapabilities[callbackId];
  15383. if (!capability) {
  15384. throw new Error("Cannot resolve callback ".concat(callbackId));
  15385. }
  15386. delete _this.callbackCapabilities[callbackId];
  15387. if (data.callback === CallbackKind.DATA) {
  15388. capability.resolve(data.data);
  15389. } else if (data.callback === CallbackKind.ERROR) {
  15390. capability.reject(wrapReason(data.reason));
  15391. } else {
  15392. throw new Error("Unexpected callback case");
  15393. }
  15394. return;
  15395. }
  15396. var action = _this.actionHandler[data.action];
  15397. if (!action) {
  15398. throw new Error("Unknown action from worker: ".concat(data.action));
  15399. }
  15400. if (data.callbackId) {
  15401. var cbSourceName = _this.sourceName;
  15402. var cbTargetName = data.sourceName;
  15403. new Promise(function (resolve) {
  15404. resolve(action(data.data));
  15405. }).then(function (result) {
  15406. comObj.postMessage({
  15407. sourceName: cbSourceName,
  15408. targetName: cbTargetName,
  15409. callback: CallbackKind.DATA,
  15410. callbackId: data.callbackId,
  15411. data: result
  15412. });
  15413. }, function (reason) {
  15414. comObj.postMessage({
  15415. sourceName: cbSourceName,
  15416. targetName: cbTargetName,
  15417. callback: CallbackKind.ERROR,
  15418. callbackId: data.callbackId,
  15419. reason: wrapReason(reason)
  15420. });
  15421. });
  15422. return;
  15423. }
  15424. if (data.streamId) {
  15425. _this._createStreamSink(data);
  15426. return;
  15427. }
  15428. action(data.data);
  15429. };
  15430. comObj.addEventListener("message", this._onComObjOnMessage);
  15431. }
  15432. _createClass(MessageHandler, [{
  15433. key: "on",
  15434. value: function on(actionName, handler) {
  15435. var ah = this.actionHandler;
  15436. if (ah[actionName]) {
  15437. throw new Error("There is already an actionName called \"".concat(actionName, "\""));
  15438. }
  15439. ah[actionName] = handler;
  15440. }
  15441. }, {
  15442. key: "send",
  15443. value: function send(actionName, data, transfers) {
  15444. this._postMessage({
  15445. sourceName: this.sourceName,
  15446. targetName: this.targetName,
  15447. action: actionName,
  15448. data: data
  15449. }, transfers);
  15450. }
  15451. }, {
  15452. key: "sendWithPromise",
  15453. value: function sendWithPromise(actionName, data, transfers) {
  15454. var callbackId = this.callbackId++;
  15455. var capability = (0, _util.createPromiseCapability)();
  15456. this.callbackCapabilities[callbackId] = capability;
  15457. try {
  15458. this._postMessage({
  15459. sourceName: this.sourceName,
  15460. targetName: this.targetName,
  15461. action: actionName,
  15462. callbackId: callbackId,
  15463. data: data
  15464. }, transfers);
  15465. } catch (ex) {
  15466. capability.reject(ex);
  15467. }
  15468. return capability.promise;
  15469. }
  15470. }, {
  15471. key: "sendWithStream",
  15472. value: function sendWithStream(actionName, data, queueingStrategy, transfers) {
  15473. var _this2 = this;
  15474. var streamId = this.streamId++;
  15475. var sourceName = this.sourceName;
  15476. var targetName = this.targetName;
  15477. var comObj = this.comObj;
  15478. return new ReadableStream({
  15479. start: function start(controller) {
  15480. var startCapability = (0, _util.createPromiseCapability)();
  15481. _this2.streamControllers[streamId] = {
  15482. controller: controller,
  15483. startCall: startCapability,
  15484. pullCall: null,
  15485. cancelCall: null,
  15486. isClosed: false
  15487. };
  15488. _this2._postMessage({
  15489. sourceName: sourceName,
  15490. targetName: targetName,
  15491. action: actionName,
  15492. streamId: streamId,
  15493. data: data,
  15494. desiredSize: controller.desiredSize
  15495. }, transfers);
  15496. return startCapability.promise;
  15497. },
  15498. pull: function pull(controller) {
  15499. var pullCapability = (0, _util.createPromiseCapability)();
  15500. _this2.streamControllers[streamId].pullCall = pullCapability;
  15501. comObj.postMessage({
  15502. sourceName: sourceName,
  15503. targetName: targetName,
  15504. stream: StreamKind.PULL,
  15505. streamId: streamId,
  15506. desiredSize: controller.desiredSize
  15507. });
  15508. return pullCapability.promise;
  15509. },
  15510. cancel: function cancel(reason) {
  15511. (0, _util.assert)(reason instanceof Error, "cancel must have a valid reason");
  15512. var cancelCapability = (0, _util.createPromiseCapability)();
  15513. _this2.streamControllers[streamId].cancelCall = cancelCapability;
  15514. _this2.streamControllers[streamId].isClosed = true;
  15515. comObj.postMessage({
  15516. sourceName: sourceName,
  15517. targetName: targetName,
  15518. stream: StreamKind.CANCEL,
  15519. streamId: streamId,
  15520. reason: wrapReason(reason)
  15521. });
  15522. return cancelCapability.promise;
  15523. }
  15524. }, queueingStrategy);
  15525. }
  15526. }, {
  15527. key: "_createStreamSink",
  15528. value: function _createStreamSink(data) {
  15529. var self = this;
  15530. var action = this.actionHandler[data.action];
  15531. var streamId = data.streamId;
  15532. var sourceName = this.sourceName;
  15533. var targetName = data.sourceName;
  15534. var comObj = this.comObj;
  15535. var streamSink = {
  15536. enqueue: function enqueue(chunk) {
  15537. var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  15538. var transfers = arguments.length > 2 ? arguments[2] : undefined;
  15539. if (this.isCancelled) {
  15540. return;
  15541. }
  15542. var lastDesiredSize = this.desiredSize;
  15543. this.desiredSize -= size;
  15544. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  15545. this.sinkCapability = (0, _util.createPromiseCapability)();
  15546. this.ready = this.sinkCapability.promise;
  15547. }
  15548. self._postMessage({
  15549. sourceName: sourceName,
  15550. targetName: targetName,
  15551. stream: StreamKind.ENQUEUE,
  15552. streamId: streamId,
  15553. chunk: chunk
  15554. }, transfers);
  15555. },
  15556. close: function close() {
  15557. if (this.isCancelled) {
  15558. return;
  15559. }
  15560. this.isCancelled = true;
  15561. comObj.postMessage({
  15562. sourceName: sourceName,
  15563. targetName: targetName,
  15564. stream: StreamKind.CLOSE,
  15565. streamId: streamId
  15566. });
  15567. delete self.streamSinks[streamId];
  15568. },
  15569. error: function error(reason) {
  15570. (0, _util.assert)(reason instanceof Error, "error must have a valid reason");
  15571. if (this.isCancelled) {
  15572. return;
  15573. }
  15574. this.isCancelled = true;
  15575. comObj.postMessage({
  15576. sourceName: sourceName,
  15577. targetName: targetName,
  15578. stream: StreamKind.ERROR,
  15579. streamId: streamId,
  15580. reason: wrapReason(reason)
  15581. });
  15582. },
  15583. sinkCapability: (0, _util.createPromiseCapability)(),
  15584. onPull: null,
  15585. onCancel: null,
  15586. isCancelled: false,
  15587. desiredSize: data.desiredSize,
  15588. ready: null
  15589. };
  15590. streamSink.sinkCapability.resolve();
  15591. streamSink.ready = streamSink.sinkCapability.promise;
  15592. this.streamSinks[streamId] = streamSink;
  15593. new Promise(function (resolve) {
  15594. resolve(action(data.data, streamSink));
  15595. }).then(function () {
  15596. comObj.postMessage({
  15597. sourceName: sourceName,
  15598. targetName: targetName,
  15599. stream: StreamKind.START_COMPLETE,
  15600. streamId: streamId,
  15601. success: true
  15602. });
  15603. }, function (reason) {
  15604. comObj.postMessage({
  15605. sourceName: sourceName,
  15606. targetName: targetName,
  15607. stream: StreamKind.START_COMPLETE,
  15608. streamId: streamId,
  15609. reason: wrapReason(reason)
  15610. });
  15611. });
  15612. }
  15613. }, {
  15614. key: "_processStreamMessage",
  15615. value: function _processStreamMessage(data) {
  15616. var streamId = data.streamId;
  15617. var sourceName = this.sourceName;
  15618. var targetName = data.sourceName;
  15619. var comObj = this.comObj;
  15620. switch (data.stream) {
  15621. case StreamKind.START_COMPLETE:
  15622. if (data.success) {
  15623. this.streamControllers[streamId].startCall.resolve();
  15624. } else {
  15625. this.streamControllers[streamId].startCall.reject(wrapReason(data.reason));
  15626. }
  15627. break;
  15628. case StreamKind.PULL_COMPLETE:
  15629. if (data.success) {
  15630. this.streamControllers[streamId].pullCall.resolve();
  15631. } else {
  15632. this.streamControllers[streamId].pullCall.reject(wrapReason(data.reason));
  15633. }
  15634. break;
  15635. case StreamKind.PULL:
  15636. if (!this.streamSinks[streamId]) {
  15637. comObj.postMessage({
  15638. sourceName: sourceName,
  15639. targetName: targetName,
  15640. stream: StreamKind.PULL_COMPLETE,
  15641. streamId: streamId,
  15642. success: true
  15643. });
  15644. break;
  15645. }
  15646. if (this.streamSinks[streamId].desiredSize <= 0 && data.desiredSize > 0) {
  15647. this.streamSinks[streamId].sinkCapability.resolve();
  15648. }
  15649. this.streamSinks[streamId].desiredSize = data.desiredSize;
  15650. var onPull = this.streamSinks[data.streamId].onPull;
  15651. new Promise(function (resolve) {
  15652. resolve(onPull && onPull());
  15653. }).then(function () {
  15654. comObj.postMessage({
  15655. sourceName: sourceName,
  15656. targetName: targetName,
  15657. stream: StreamKind.PULL_COMPLETE,
  15658. streamId: streamId,
  15659. success: true
  15660. });
  15661. }, function (reason) {
  15662. comObj.postMessage({
  15663. sourceName: sourceName,
  15664. targetName: targetName,
  15665. stream: StreamKind.PULL_COMPLETE,
  15666. streamId: streamId,
  15667. reason: wrapReason(reason)
  15668. });
  15669. });
  15670. break;
  15671. case StreamKind.ENQUEUE:
  15672. (0, _util.assert)(this.streamControllers[streamId], "enqueue should have stream controller");
  15673. if (this.streamControllers[streamId].isClosed) {
  15674. break;
  15675. }
  15676. this.streamControllers[streamId].controller.enqueue(data.chunk);
  15677. break;
  15678. case StreamKind.CLOSE:
  15679. (0, _util.assert)(this.streamControllers[streamId], "close should have stream controller");
  15680. if (this.streamControllers[streamId].isClosed) {
  15681. break;
  15682. }
  15683. this.streamControllers[streamId].isClosed = true;
  15684. this.streamControllers[streamId].controller.close();
  15685. this._deleteStreamController(streamId);
  15686. break;
  15687. case StreamKind.ERROR:
  15688. (0, _util.assert)(this.streamControllers[streamId], "error should have stream controller");
  15689. this.streamControllers[streamId].controller.error(wrapReason(data.reason));
  15690. this._deleteStreamController(streamId);
  15691. break;
  15692. case StreamKind.CANCEL_COMPLETE:
  15693. if (data.success) {
  15694. this.streamControllers[streamId].cancelCall.resolve();
  15695. } else {
  15696. this.streamControllers[streamId].cancelCall.reject(wrapReason(data.reason));
  15697. }
  15698. this._deleteStreamController(streamId);
  15699. break;
  15700. case StreamKind.CANCEL:
  15701. if (!this.streamSinks[streamId]) {
  15702. break;
  15703. }
  15704. var onCancel = this.streamSinks[data.streamId].onCancel;
  15705. new Promise(function (resolve) {
  15706. resolve(onCancel && onCancel(wrapReason(data.reason)));
  15707. }).then(function () {
  15708. comObj.postMessage({
  15709. sourceName: sourceName,
  15710. targetName: targetName,
  15711. stream: StreamKind.CANCEL_COMPLETE,
  15712. streamId: streamId,
  15713. success: true
  15714. });
  15715. }, function (reason) {
  15716. comObj.postMessage({
  15717. sourceName: sourceName,
  15718. targetName: targetName,
  15719. stream: StreamKind.CANCEL_COMPLETE,
  15720. streamId: streamId,
  15721. reason: wrapReason(reason)
  15722. });
  15723. });
  15724. this.streamSinks[streamId].sinkCapability.reject(wrapReason(data.reason));
  15725. this.streamSinks[streamId].isCancelled = true;
  15726. delete this.streamSinks[streamId];
  15727. break;
  15728. default:
  15729. throw new Error("Unexpected stream case");
  15730. }
  15731. }
  15732. }, {
  15733. key: "_deleteStreamController",
  15734. value: function () {
  15735. var _deleteStreamController2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(streamId) {
  15736. return _regenerator["default"].wrap(function _callee$(_context) {
  15737. while (1) {
  15738. switch (_context.prev = _context.next) {
  15739. case 0:
  15740. _context.next = 2;
  15741. return Promise.allSettled([this.streamControllers[streamId].startCall, this.streamControllers[streamId].pullCall, this.streamControllers[streamId].cancelCall].map(function (capability) {
  15742. return capability && capability.promise;
  15743. }));
  15744. case 2:
  15745. delete this.streamControllers[streamId];
  15746. case 3:
  15747. case "end":
  15748. return _context.stop();
  15749. }
  15750. }
  15751. }, _callee, this);
  15752. }));
  15753. function _deleteStreamController(_x) {
  15754. return _deleteStreamController2.apply(this, arguments);
  15755. }
  15756. return _deleteStreamController;
  15757. }()
  15758. }, {
  15759. key: "_postMessage",
  15760. value: function _postMessage(message, transfers) {
  15761. if (transfers && this.postMessageTransfers) {
  15762. this.comObj.postMessage(message, transfers);
  15763. } else {
  15764. this.comObj.postMessage(message);
  15765. }
  15766. }
  15767. }, {
  15768. key: "destroy",
  15769. value: function destroy() {
  15770. this.comObj.removeEventListener("message", this._onComObjOnMessage);
  15771. }
  15772. }]);
  15773. return MessageHandler;
  15774. }();
  15775. exports.MessageHandler = MessageHandler;
  15776. /***/ }),
  15777. /* 144 */
  15778. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15779. "use strict";
  15780. Object.defineProperty(exports, "__esModule", ({
  15781. value: true
  15782. }));
  15783. exports.Metadata = void 0;
  15784. var _util = __w_pdfjs_require__(4);
  15785. var _xml_parser = __w_pdfjs_require__(145);
  15786. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  15787. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  15788. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  15789. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15790. 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); } }
  15791. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15792. var Metadata = /*#__PURE__*/function () {
  15793. function Metadata(data) {
  15794. _classCallCheck(this, Metadata);
  15795. (0, _util.assert)(typeof data === "string", "Metadata: input is not a string");
  15796. data = this._repair(data);
  15797. var parser = new _xml_parser.SimpleXMLParser({
  15798. lowerCaseName: true
  15799. });
  15800. var xmlDocument = parser.parseFromString(data);
  15801. this._metadataMap = new Map();
  15802. if (xmlDocument) {
  15803. this._parse(xmlDocument);
  15804. }
  15805. this._data = data;
  15806. }
  15807. _createClass(Metadata, [{
  15808. key: "_repair",
  15809. value: function _repair(data) {
  15810. return data.replace(/^[^<]+/, "").replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  15811. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  15812. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  15813. }).replace(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
  15814. switch (name) {
  15815. case "amp":
  15816. return "&";
  15817. case "apos":
  15818. return "'";
  15819. case "gt":
  15820. return ">";
  15821. case "lt":
  15822. return "<";
  15823. case "quot":
  15824. return '"';
  15825. }
  15826. throw new Error("_repair: ".concat(name, " isn't defined."));
  15827. });
  15828. var chars = "";
  15829. for (var i = 0, ii = bytes.length; i < ii; i += 2) {
  15830. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  15831. if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
  15832. chars += String.fromCharCode(code);
  15833. } else {
  15834. chars += "&#x" + (0x10000 + code).toString(16).substring(1) + ";";
  15835. }
  15836. }
  15837. return ">" + chars;
  15838. });
  15839. }
  15840. }, {
  15841. key: "_getSequence",
  15842. value: function _getSequence(entry) {
  15843. var name = entry.nodeName;
  15844. if (name !== "rdf:bag" && name !== "rdf:seq" && name !== "rdf:alt") {
  15845. return null;
  15846. }
  15847. return entry.childNodes.filter(function (node) {
  15848. return node.nodeName === "rdf:li";
  15849. });
  15850. }
  15851. }, {
  15852. key: "_getCreators",
  15853. value: function _getCreators(entry) {
  15854. if (entry.nodeName !== "dc:creator") {
  15855. return false;
  15856. }
  15857. if (!entry.hasChildNodes()) {
  15858. return true;
  15859. }
  15860. var seqNode = entry.childNodes[0];
  15861. var authors = this._getSequence(seqNode) || [];
  15862. this._metadataMap.set(entry.nodeName, authors.map(function (node) {
  15863. return node.textContent.trim();
  15864. }));
  15865. return true;
  15866. }
  15867. }, {
  15868. key: "_parse",
  15869. value: function _parse(xmlDocument) {
  15870. var rdf = xmlDocument.documentElement;
  15871. if (rdf.nodeName !== "rdf:rdf") {
  15872. rdf = rdf.firstChild;
  15873. while (rdf && rdf.nodeName !== "rdf:rdf") {
  15874. rdf = rdf.nextSibling;
  15875. }
  15876. }
  15877. if (!rdf || rdf.nodeName !== "rdf:rdf" || !rdf.hasChildNodes()) {
  15878. return;
  15879. }
  15880. var _iterator = _createForOfIteratorHelper(rdf.childNodes),
  15881. _step;
  15882. try {
  15883. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  15884. var desc = _step.value;
  15885. if (desc.nodeName !== "rdf:description") {
  15886. continue;
  15887. }
  15888. var _iterator2 = _createForOfIteratorHelper(desc.childNodes),
  15889. _step2;
  15890. try {
  15891. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  15892. var entry = _step2.value;
  15893. var name = entry.nodeName;
  15894. if (name === "#text") {
  15895. continue;
  15896. }
  15897. if (this._getCreators(entry)) {
  15898. continue;
  15899. }
  15900. this._metadataMap.set(name, entry.textContent.trim());
  15901. }
  15902. } catch (err) {
  15903. _iterator2.e(err);
  15904. } finally {
  15905. _iterator2.f();
  15906. }
  15907. }
  15908. } catch (err) {
  15909. _iterator.e(err);
  15910. } finally {
  15911. _iterator.f();
  15912. }
  15913. }
  15914. }, {
  15915. key: "getRaw",
  15916. value: function getRaw() {
  15917. return this._data;
  15918. }
  15919. }, {
  15920. key: "get",
  15921. value: function get(name) {
  15922. var _this$_metadataMap$ge;
  15923. return (_this$_metadataMap$ge = this._metadataMap.get(name)) !== null && _this$_metadataMap$ge !== void 0 ? _this$_metadataMap$ge : null;
  15924. }
  15925. }, {
  15926. key: "getAll",
  15927. value: function getAll() {
  15928. return (0, _util.objectFromEntries)(this._metadataMap);
  15929. }
  15930. }, {
  15931. key: "has",
  15932. value: function has(name) {
  15933. return this._metadataMap.has(name);
  15934. }
  15935. }]);
  15936. return Metadata;
  15937. }();
  15938. exports.Metadata = Metadata;
  15939. /***/ }),
  15940. /* 145 */
  15941. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15942. "use strict";
  15943. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15944. Object.defineProperty(exports, "__esModule", ({
  15945. value: true
  15946. }));
  15947. exports.SimpleXMLParser = exports.SimpleDOMNode = void 0;
  15948. var _util = __w_pdfjs_require__(4);
  15949. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  15950. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  15951. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15952. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15953. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  15954. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15955. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15956. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  15957. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15958. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  15959. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  15960. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  15961. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  15962. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  15963. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  15964. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  15965. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15966. 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); } }
  15967. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15968. var XMLParserErrorCode = {
  15969. NoError: 0,
  15970. EndOfDocument: -1,
  15971. UnterminatedCdat: -2,
  15972. UnterminatedXmlDeclaration: -3,
  15973. UnterminatedDoctypeDeclaration: -4,
  15974. UnterminatedComment: -5,
  15975. MalformedElement: -6,
  15976. OutOfMemory: -7,
  15977. UnterminatedAttributeValue: -8,
  15978. UnterminatedElement: -9,
  15979. ElementNeverBegun: -10
  15980. };
  15981. function isWhitespace(s, index) {
  15982. var ch = s[index];
  15983. return ch === " " || ch === "\n" || ch === "\r" || ch === "\t";
  15984. }
  15985. function isWhitespaceString(s) {
  15986. for (var i = 0, ii = s.length; i < ii; i++) {
  15987. if (!isWhitespace(s, i)) {
  15988. return false;
  15989. }
  15990. }
  15991. return true;
  15992. }
  15993. var XMLParserBase = /*#__PURE__*/function () {
  15994. function XMLParserBase() {
  15995. _classCallCheck(this, XMLParserBase);
  15996. }
  15997. _createClass(XMLParserBase, [{
  15998. key: "_resolveEntities",
  15999. value: function _resolveEntities(s) {
  16000. var _this = this;
  16001. return s.replace(/&([^;]+);/g, function (all, entity) {
  16002. if (entity.substring(0, 2) === "#x") {
  16003. return String.fromCodePoint(parseInt(entity.substring(2), 16));
  16004. } else if (entity.substring(0, 1) === "#") {
  16005. return String.fromCodePoint(parseInt(entity.substring(1), 10));
  16006. }
  16007. switch (entity) {
  16008. case "lt":
  16009. return "<";
  16010. case "gt":
  16011. return ">";
  16012. case "amp":
  16013. return "&";
  16014. case "quot":
  16015. return '"';
  16016. }
  16017. return _this.onResolveEntity(entity);
  16018. });
  16019. }
  16020. }, {
  16021. key: "_parseContent",
  16022. value: function _parseContent(s, start) {
  16023. var attributes = [];
  16024. var pos = start;
  16025. function skipWs() {
  16026. while (pos < s.length && isWhitespace(s, pos)) {
  16027. ++pos;
  16028. }
  16029. }
  16030. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "/") {
  16031. ++pos;
  16032. }
  16033. var name = s.substring(start, pos);
  16034. skipWs();
  16035. while (pos < s.length && s[pos] !== ">" && s[pos] !== "/" && s[pos] !== "?") {
  16036. skipWs();
  16037. var attrName = "",
  16038. attrValue = "";
  16039. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== "=") {
  16040. attrName += s[pos];
  16041. ++pos;
  16042. }
  16043. skipWs();
  16044. if (s[pos] !== "=") {
  16045. return null;
  16046. }
  16047. ++pos;
  16048. skipWs();
  16049. var attrEndChar = s[pos];
  16050. if (attrEndChar !== '"' && attrEndChar !== "'") {
  16051. return null;
  16052. }
  16053. var attrEndIndex = s.indexOf(attrEndChar, ++pos);
  16054. if (attrEndIndex < 0) {
  16055. return null;
  16056. }
  16057. attrValue = s.substring(pos, attrEndIndex);
  16058. attributes.push({
  16059. name: attrName,
  16060. value: this._resolveEntities(attrValue)
  16061. });
  16062. pos = attrEndIndex + 1;
  16063. skipWs();
  16064. }
  16065. return {
  16066. name: name,
  16067. attributes: attributes,
  16068. parsed: pos - start
  16069. };
  16070. }
  16071. }, {
  16072. key: "_parseProcessingInstruction",
  16073. value: function _parseProcessingInstruction(s, start) {
  16074. var pos = start;
  16075. function skipWs() {
  16076. while (pos < s.length && isWhitespace(s, pos)) {
  16077. ++pos;
  16078. }
  16079. }
  16080. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "/") {
  16081. ++pos;
  16082. }
  16083. var name = s.substring(start, pos);
  16084. skipWs();
  16085. var attrStart = pos;
  16086. while (pos < s.length && (s[pos] !== "?" || s[pos + 1] !== ">")) {
  16087. ++pos;
  16088. }
  16089. var value = s.substring(attrStart, pos);
  16090. return {
  16091. name: name,
  16092. value: value,
  16093. parsed: pos - start
  16094. };
  16095. }
  16096. }, {
  16097. key: "parseXml",
  16098. value: function parseXml(s) {
  16099. var i = 0;
  16100. while (i < s.length) {
  16101. var ch = s[i];
  16102. var j = i;
  16103. if (ch === "<") {
  16104. ++j;
  16105. var ch2 = s[j];
  16106. var q = void 0;
  16107. switch (ch2) {
  16108. case "/":
  16109. ++j;
  16110. q = s.indexOf(">", j);
  16111. if (q < 0) {
  16112. this.onError(XMLParserErrorCode.UnterminatedElement);
  16113. return;
  16114. }
  16115. this.onEndElement(s.substring(j, q));
  16116. j = q + 1;
  16117. break;
  16118. case "?":
  16119. ++j;
  16120. var pi = this._parseProcessingInstruction(s, j);
  16121. if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== "?>") {
  16122. this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration);
  16123. return;
  16124. }
  16125. this.onPi(pi.name, pi.value);
  16126. j += pi.parsed + 2;
  16127. break;
  16128. case "!":
  16129. if (s.substring(j + 1, j + 3) === "--") {
  16130. q = s.indexOf("-->", j + 3);
  16131. if (q < 0) {
  16132. this.onError(XMLParserErrorCode.UnterminatedComment);
  16133. return;
  16134. }
  16135. this.onComment(s.substring(j + 3, q));
  16136. j = q + 3;
  16137. } else if (s.substring(j + 1, j + 8) === "[CDATA[") {
  16138. q = s.indexOf("]]>", j + 8);
  16139. if (q < 0) {
  16140. this.onError(XMLParserErrorCode.UnterminatedCdat);
  16141. return;
  16142. }
  16143. this.onCdata(s.substring(j + 8, q));
  16144. j = q + 3;
  16145. } else if (s.substring(j + 1, j + 8) === "DOCTYPE") {
  16146. var q2 = s.indexOf("[", j + 8);
  16147. var complexDoctype = false;
  16148. q = s.indexOf(">", j + 8);
  16149. if (q < 0) {
  16150. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  16151. return;
  16152. }
  16153. if (q2 > 0 && q > q2) {
  16154. q = s.indexOf("]>", j + 8);
  16155. if (q < 0) {
  16156. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  16157. return;
  16158. }
  16159. complexDoctype = true;
  16160. }
  16161. var doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0));
  16162. this.onDoctype(doctypeContent);
  16163. j = q + (complexDoctype ? 2 : 1);
  16164. } else {
  16165. this.onError(XMLParserErrorCode.MalformedElement);
  16166. return;
  16167. }
  16168. break;
  16169. default:
  16170. var content = this._parseContent(s, j);
  16171. if (content === null) {
  16172. this.onError(XMLParserErrorCode.MalformedElement);
  16173. return;
  16174. }
  16175. var isClosed = false;
  16176. if (s.substring(j + content.parsed, j + content.parsed + 2) === "/>") {
  16177. isClosed = true;
  16178. } else if (s.substring(j + content.parsed, j + content.parsed + 1) !== ">") {
  16179. this.onError(XMLParserErrorCode.UnterminatedElement);
  16180. return;
  16181. }
  16182. this.onBeginElement(content.name, content.attributes, isClosed);
  16183. j += content.parsed + (isClosed ? 2 : 1);
  16184. break;
  16185. }
  16186. } else {
  16187. while (j < s.length && s[j] !== "<") {
  16188. j++;
  16189. }
  16190. var text = s.substring(i, j);
  16191. this.onText(this._resolveEntities(text));
  16192. }
  16193. i = j;
  16194. }
  16195. }
  16196. }, {
  16197. key: "onResolveEntity",
  16198. value: function onResolveEntity(name) {
  16199. return "&".concat(name, ";");
  16200. }
  16201. }, {
  16202. key: "onPi",
  16203. value: function onPi(name, value) {}
  16204. }, {
  16205. key: "onComment",
  16206. value: function onComment(text) {}
  16207. }, {
  16208. key: "onCdata",
  16209. value: function onCdata(text) {}
  16210. }, {
  16211. key: "onDoctype",
  16212. value: function onDoctype(doctypeContent) {}
  16213. }, {
  16214. key: "onText",
  16215. value: function onText(text) {}
  16216. }, {
  16217. key: "onBeginElement",
  16218. value: function onBeginElement(name, attributes, isEmpty) {}
  16219. }, {
  16220. key: "onEndElement",
  16221. value: function onEndElement(name) {}
  16222. }, {
  16223. key: "onError",
  16224. value: function onError(code) {}
  16225. }]);
  16226. return XMLParserBase;
  16227. }();
  16228. var SimpleDOMNode = /*#__PURE__*/function () {
  16229. function SimpleDOMNode(nodeName, nodeValue) {
  16230. _classCallCheck(this, SimpleDOMNode);
  16231. this.nodeName = nodeName;
  16232. this.nodeValue = nodeValue;
  16233. Object.defineProperty(this, "parentNode", {
  16234. value: null,
  16235. writable: true
  16236. });
  16237. }
  16238. _createClass(SimpleDOMNode, [{
  16239. key: "hasChildNodes",
  16240. value: function hasChildNodes() {
  16241. return this.childNodes && this.childNodes.length > 0;
  16242. }
  16243. }, {
  16244. key: "searchNode",
  16245. value: function searchNode(paths, pos) {
  16246. if (pos >= paths.length) {
  16247. return this;
  16248. }
  16249. var component = paths[pos];
  16250. var stack = [];
  16251. var node = this;
  16252. while (true) {
  16253. if (component.name === node.nodeName) {
  16254. if (component.pos === 0) {
  16255. var res = node.searchNode(paths, pos + 1);
  16256. if (res !== null) {
  16257. return res;
  16258. }
  16259. } else if (stack.length === 0) {
  16260. return null;
  16261. } else {
  16262. var _stack$pop = stack.pop(),
  16263. _stack$pop2 = _slicedToArray(_stack$pop, 1),
  16264. parent = _stack$pop2[0];
  16265. var siblingPos = 0;
  16266. var _iterator = _createForOfIteratorHelper(parent.childNodes),
  16267. _step;
  16268. try {
  16269. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  16270. var child = _step.value;
  16271. if (component.name === child.nodeName) {
  16272. if (siblingPos === component.pos) {
  16273. return child.searchNode(paths, pos + 1);
  16274. }
  16275. siblingPos++;
  16276. }
  16277. }
  16278. } catch (err) {
  16279. _iterator.e(err);
  16280. } finally {
  16281. _iterator.f();
  16282. }
  16283. return node.searchNode(paths, pos + 1);
  16284. }
  16285. }
  16286. if (node.childNodes && node.childNodes.length !== 0) {
  16287. stack.push([node, 0]);
  16288. node = node.childNodes[0];
  16289. } else if (stack.length === 0) {
  16290. return null;
  16291. } else {
  16292. while (stack.length !== 0) {
  16293. var _stack$pop3 = stack.pop(),
  16294. _stack$pop4 = _slicedToArray(_stack$pop3, 2),
  16295. _parent = _stack$pop4[0],
  16296. currentPos = _stack$pop4[1];
  16297. var newPos = currentPos + 1;
  16298. if (newPos < _parent.childNodes.length) {
  16299. stack.push([_parent, newPos]);
  16300. node = _parent.childNodes[newPos];
  16301. break;
  16302. }
  16303. }
  16304. if (stack.length === 0) {
  16305. return null;
  16306. }
  16307. }
  16308. }
  16309. }
  16310. }, {
  16311. key: "dump",
  16312. value: function dump(buffer) {
  16313. if (this.nodeName === "#text") {
  16314. buffer.push((0, _util.encodeToXmlString)(this.nodeValue));
  16315. return;
  16316. }
  16317. buffer.push("<".concat(this.nodeName));
  16318. if (this.attributes) {
  16319. var _iterator2 = _createForOfIteratorHelper(this.attributes),
  16320. _step2;
  16321. try {
  16322. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  16323. var attribute = _step2.value;
  16324. buffer.push(" ".concat(attribute.name, "=\"").concat((0, _util.encodeToXmlString)(attribute.value), "\""));
  16325. }
  16326. } catch (err) {
  16327. _iterator2.e(err);
  16328. } finally {
  16329. _iterator2.f();
  16330. }
  16331. }
  16332. if (this.hasChildNodes()) {
  16333. buffer.push(">");
  16334. var _iterator3 = _createForOfIteratorHelper(this.childNodes),
  16335. _step3;
  16336. try {
  16337. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  16338. var child = _step3.value;
  16339. child.dump(buffer);
  16340. }
  16341. } catch (err) {
  16342. _iterator3.e(err);
  16343. } finally {
  16344. _iterator3.f();
  16345. }
  16346. buffer.push("</".concat(this.nodeName, ">"));
  16347. } else if (this.nodeValue) {
  16348. buffer.push(">".concat((0, _util.encodeToXmlString)(this.nodeValue), "</").concat(this.nodeName, ">"));
  16349. } else {
  16350. buffer.push("/>");
  16351. }
  16352. }
  16353. }, {
  16354. key: "firstChild",
  16355. get: function get() {
  16356. return this.childNodes && this.childNodes[0];
  16357. }
  16358. }, {
  16359. key: "nextSibling",
  16360. get: function get() {
  16361. var childNodes = this.parentNode.childNodes;
  16362. if (!childNodes) {
  16363. return undefined;
  16364. }
  16365. var index = childNodes.indexOf(this);
  16366. if (index === -1) {
  16367. return undefined;
  16368. }
  16369. return childNodes[index + 1];
  16370. }
  16371. }, {
  16372. key: "textContent",
  16373. get: function get() {
  16374. if (!this.childNodes) {
  16375. return this.nodeValue || "";
  16376. }
  16377. return this.childNodes.map(function (child) {
  16378. return child.textContent;
  16379. }).join("");
  16380. }
  16381. }]);
  16382. return SimpleDOMNode;
  16383. }();
  16384. exports.SimpleDOMNode = SimpleDOMNode;
  16385. var SimpleXMLParser = /*#__PURE__*/function (_XMLParserBase) {
  16386. _inherits(SimpleXMLParser, _XMLParserBase);
  16387. var _super = _createSuper(SimpleXMLParser);
  16388. function SimpleXMLParser(_ref) {
  16389. var _this2;
  16390. var _ref$hasAttributes = _ref.hasAttributes,
  16391. hasAttributes = _ref$hasAttributes === void 0 ? false : _ref$hasAttributes,
  16392. _ref$lowerCaseName = _ref.lowerCaseName,
  16393. lowerCaseName = _ref$lowerCaseName === void 0 ? false : _ref$lowerCaseName;
  16394. _classCallCheck(this, SimpleXMLParser);
  16395. _this2 = _super.call(this);
  16396. _this2._currentFragment = null;
  16397. _this2._stack = null;
  16398. _this2._errorCode = XMLParserErrorCode.NoError;
  16399. _this2._hasAttributes = hasAttributes;
  16400. _this2._lowerCaseName = lowerCaseName;
  16401. return _this2;
  16402. }
  16403. _createClass(SimpleXMLParser, [{
  16404. key: "parseFromString",
  16405. value: function parseFromString(data) {
  16406. this._currentFragment = [];
  16407. this._stack = [];
  16408. this._errorCode = XMLParserErrorCode.NoError;
  16409. this.parseXml(data);
  16410. if (this._errorCode !== XMLParserErrorCode.NoError) {
  16411. return undefined;
  16412. }
  16413. var _this$_currentFragmen = _slicedToArray(this._currentFragment, 1),
  16414. documentElement = _this$_currentFragmen[0];
  16415. if (!documentElement) {
  16416. return undefined;
  16417. }
  16418. return {
  16419. documentElement: documentElement
  16420. };
  16421. }
  16422. }, {
  16423. key: "onResolveEntity",
  16424. value: function onResolveEntity(name) {
  16425. switch (name) {
  16426. case "apos":
  16427. return "'";
  16428. }
  16429. return _get(_getPrototypeOf(SimpleXMLParser.prototype), "onResolveEntity", this).call(this, name);
  16430. }
  16431. }, {
  16432. key: "onText",
  16433. value: function onText(text) {
  16434. if (isWhitespaceString(text)) {
  16435. return;
  16436. }
  16437. var node = new SimpleDOMNode("#text", text);
  16438. this._currentFragment.push(node);
  16439. }
  16440. }, {
  16441. key: "onCdata",
  16442. value: function onCdata(text) {
  16443. var node = new SimpleDOMNode("#text", text);
  16444. this._currentFragment.push(node);
  16445. }
  16446. }, {
  16447. key: "onBeginElement",
  16448. value: function onBeginElement(name, attributes, isEmpty) {
  16449. if (this._lowerCaseName) {
  16450. name = name.toLowerCase();
  16451. }
  16452. var node = new SimpleDOMNode(name);
  16453. node.childNodes = [];
  16454. if (this._hasAttributes) {
  16455. node.attributes = attributes;
  16456. }
  16457. this._currentFragment.push(node);
  16458. if (isEmpty) {
  16459. return;
  16460. }
  16461. this._stack.push(this._currentFragment);
  16462. this._currentFragment = node.childNodes;
  16463. }
  16464. }, {
  16465. key: "onEndElement",
  16466. value: function onEndElement(name) {
  16467. this._currentFragment = this._stack.pop() || [];
  16468. var lastElement = this._currentFragment[this._currentFragment.length - 1];
  16469. if (!lastElement) {
  16470. return;
  16471. }
  16472. for (var i = 0, ii = lastElement.childNodes.length; i < ii; i++) {
  16473. lastElement.childNodes[i].parentNode = lastElement;
  16474. }
  16475. }
  16476. }, {
  16477. key: "onError",
  16478. value: function onError(code) {
  16479. this._errorCode = code;
  16480. }
  16481. }]);
  16482. return SimpleXMLParser;
  16483. }(XMLParserBase);
  16484. exports.SimpleXMLParser = SimpleXMLParser;
  16485. /***/ }),
  16486. /* 146 */
  16487. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  16488. "use strict";
  16489. Object.defineProperty(exports, "__esModule", ({
  16490. value: true
  16491. }));
  16492. exports.OptionalContentConfig = void 0;
  16493. var _util = __w_pdfjs_require__(4);
  16494. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  16495. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  16496. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  16497. 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); } }
  16498. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16499. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16500. var OptionalContentGroup = function OptionalContentGroup(name, intent) {
  16501. _classCallCheck(this, OptionalContentGroup);
  16502. this.visible = true;
  16503. this.name = name;
  16504. this.intent = intent;
  16505. };
  16506. var OptionalContentConfig = /*#__PURE__*/function () {
  16507. function OptionalContentConfig(data) {
  16508. _classCallCheck(this, OptionalContentConfig);
  16509. this.name = null;
  16510. this.creator = null;
  16511. this._order = null;
  16512. this._groups = new Map();
  16513. if (data === null) {
  16514. return;
  16515. }
  16516. this.name = data.name;
  16517. this.creator = data.creator;
  16518. this._order = data.order;
  16519. var _iterator = _createForOfIteratorHelper(data.groups),
  16520. _step;
  16521. try {
  16522. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  16523. var _group = _step.value;
  16524. this._groups.set(_group.id, new OptionalContentGroup(_group.name, _group.intent));
  16525. }
  16526. } catch (err) {
  16527. _iterator.e(err);
  16528. } finally {
  16529. _iterator.f();
  16530. }
  16531. if (data.baseState === "OFF") {
  16532. var _iterator2 = _createForOfIteratorHelper(this._groups),
  16533. _step2;
  16534. try {
  16535. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  16536. var group = _step2.value;
  16537. group.visible = false;
  16538. }
  16539. } catch (err) {
  16540. _iterator2.e(err);
  16541. } finally {
  16542. _iterator2.f();
  16543. }
  16544. }
  16545. var _iterator3 = _createForOfIteratorHelper(data.on),
  16546. _step3;
  16547. try {
  16548. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  16549. var on = _step3.value;
  16550. this._groups.get(on).visible = true;
  16551. }
  16552. } catch (err) {
  16553. _iterator3.e(err);
  16554. } finally {
  16555. _iterator3.f();
  16556. }
  16557. var _iterator4 = _createForOfIteratorHelper(data.off),
  16558. _step4;
  16559. try {
  16560. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  16561. var off = _step4.value;
  16562. this._groups.get(off).visible = false;
  16563. }
  16564. } catch (err) {
  16565. _iterator4.e(err);
  16566. } finally {
  16567. _iterator4.f();
  16568. }
  16569. }
  16570. _createClass(OptionalContentConfig, [{
  16571. key: "isVisible",
  16572. value: function isVisible(group) {
  16573. if (group.type === "OCG") {
  16574. if (!this._groups.has(group.id)) {
  16575. (0, _util.warn)("Optional content group not found: ".concat(group.id));
  16576. return true;
  16577. }
  16578. return this._groups.get(group.id).visible;
  16579. } else if (group.type === "OCMD") {
  16580. if (group.expression) {
  16581. (0, _util.warn)("Visibility expression not supported yet.");
  16582. }
  16583. if (!group.policy || group.policy === "AnyOn") {
  16584. var _iterator5 = _createForOfIteratorHelper(group.ids),
  16585. _step5;
  16586. try {
  16587. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  16588. var id = _step5.value;
  16589. if (!this._groups.has(id)) {
  16590. (0, _util.warn)("Optional content group not found: ".concat(id));
  16591. return true;
  16592. }
  16593. if (this._groups.get(id).visible) {
  16594. return true;
  16595. }
  16596. }
  16597. } catch (err) {
  16598. _iterator5.e(err);
  16599. } finally {
  16600. _iterator5.f();
  16601. }
  16602. return false;
  16603. } else if (group.policy === "AllOn") {
  16604. var _iterator6 = _createForOfIteratorHelper(group.ids),
  16605. _step6;
  16606. try {
  16607. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  16608. var _id = _step6.value;
  16609. if (!this._groups.has(_id)) {
  16610. (0, _util.warn)("Optional content group not found: ".concat(_id));
  16611. return true;
  16612. }
  16613. if (!this._groups.get(_id).visible) {
  16614. return false;
  16615. }
  16616. }
  16617. } catch (err) {
  16618. _iterator6.e(err);
  16619. } finally {
  16620. _iterator6.f();
  16621. }
  16622. return true;
  16623. } else if (group.policy === "AnyOff") {
  16624. var _iterator7 = _createForOfIteratorHelper(group.ids),
  16625. _step7;
  16626. try {
  16627. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  16628. var _id2 = _step7.value;
  16629. if (!this._groups.has(_id2)) {
  16630. (0, _util.warn)("Optional content group not found: ".concat(_id2));
  16631. return true;
  16632. }
  16633. if (!this._groups.get(_id2).visible) {
  16634. return true;
  16635. }
  16636. }
  16637. } catch (err) {
  16638. _iterator7.e(err);
  16639. } finally {
  16640. _iterator7.f();
  16641. }
  16642. return false;
  16643. } else if (group.policy === "AllOff") {
  16644. var _iterator8 = _createForOfIteratorHelper(group.ids),
  16645. _step8;
  16646. try {
  16647. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  16648. var _id3 = _step8.value;
  16649. if (!this._groups.has(_id3)) {
  16650. (0, _util.warn)("Optional content group not found: ".concat(_id3));
  16651. return true;
  16652. }
  16653. if (this._groups.get(_id3).visible) {
  16654. return false;
  16655. }
  16656. }
  16657. } catch (err) {
  16658. _iterator8.e(err);
  16659. } finally {
  16660. _iterator8.f();
  16661. }
  16662. return true;
  16663. }
  16664. (0, _util.warn)("Unknown optional content policy ".concat(group.policy, "."));
  16665. return true;
  16666. }
  16667. (0, _util.warn)("Unknown group type ".concat(group.type, "."));
  16668. return true;
  16669. }
  16670. }, {
  16671. key: "setVisibility",
  16672. value: function setVisibility(id) {
  16673. var visible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  16674. if (!this._groups.has(id)) {
  16675. (0, _util.warn)("Optional content group not found: ".concat(id));
  16676. return;
  16677. }
  16678. this._groups.get(id).visible = !!visible;
  16679. }
  16680. }, {
  16681. key: "getOrder",
  16682. value: function getOrder() {
  16683. if (!this._groups.size) {
  16684. return null;
  16685. }
  16686. if (this._order) {
  16687. return this._order.slice();
  16688. }
  16689. return Array.from(this._groups.keys());
  16690. }
  16691. }, {
  16692. key: "getGroups",
  16693. value: function getGroups() {
  16694. if (!this._groups.size) {
  16695. return null;
  16696. }
  16697. return (0, _util.objectFromEntries)(this._groups);
  16698. }
  16699. }, {
  16700. key: "getGroup",
  16701. value: function getGroup(id) {
  16702. return this._groups.get(id) || null;
  16703. }
  16704. }]);
  16705. return OptionalContentConfig;
  16706. }();
  16707. exports.OptionalContentConfig = OptionalContentConfig;
  16708. /***/ }),
  16709. /* 147 */
  16710. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  16711. "use strict";
  16712. Object.defineProperty(exports, "__esModule", ({
  16713. value: true
  16714. }));
  16715. exports.PDFDataTransportStream = void 0;
  16716. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  16717. var _util = __w_pdfjs_require__(4);
  16718. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  16719. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  16720. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  16721. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  16722. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  16723. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  16724. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16725. 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); } }
  16726. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16727. var PDFDataTransportStream = /*#__PURE__*/function () {
  16728. function PDFDataTransportStream(params, pdfDataRangeTransport) {
  16729. var _this = this;
  16730. _classCallCheck(this, PDFDataTransportStream);
  16731. (0, _util.assert)(pdfDataRangeTransport, 'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');
  16732. this._queuedChunks = [];
  16733. this._progressiveDone = params.progressiveDone || false;
  16734. var initialData = params.initialData;
  16735. if ((initialData === null || initialData === void 0 ? void 0 : initialData.length) > 0) {
  16736. var buffer = new Uint8Array(initialData).buffer;
  16737. this._queuedChunks.push(buffer);
  16738. }
  16739. this._pdfDataRangeTransport = pdfDataRangeTransport;
  16740. this._isStreamingSupported = !params.disableStream;
  16741. this._isRangeSupported = !params.disableRange;
  16742. this._contentLength = params.length;
  16743. this._fullRequestReader = null;
  16744. this._rangeReaders = [];
  16745. this._pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  16746. _this._onReceiveData({
  16747. begin: begin,
  16748. chunk: chunk
  16749. });
  16750. });
  16751. this._pdfDataRangeTransport.addProgressListener(function (loaded, total) {
  16752. _this._onProgress({
  16753. loaded: loaded,
  16754. total: total
  16755. });
  16756. });
  16757. this._pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  16758. _this._onReceiveData({
  16759. chunk: chunk
  16760. });
  16761. });
  16762. this._pdfDataRangeTransport.addProgressiveDoneListener(function () {
  16763. _this._onProgressiveDone();
  16764. });
  16765. this._pdfDataRangeTransport.transportReady();
  16766. }
  16767. _createClass(PDFDataTransportStream, [{
  16768. key: "_onReceiveData",
  16769. value: function _onReceiveData(args) {
  16770. var buffer = new Uint8Array(args.chunk).buffer;
  16771. if (args.begin === undefined) {
  16772. if (this._fullRequestReader) {
  16773. this._fullRequestReader._enqueue(buffer);
  16774. } else {
  16775. this._queuedChunks.push(buffer);
  16776. }
  16777. } else {
  16778. var found = this._rangeReaders.some(function (rangeReader) {
  16779. if (rangeReader._begin !== args.begin) {
  16780. return false;
  16781. }
  16782. rangeReader._enqueue(buffer);
  16783. return true;
  16784. });
  16785. (0, _util.assert)(found, "_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");
  16786. }
  16787. }
  16788. }, {
  16789. key: "_onProgress",
  16790. value: function _onProgress(evt) {
  16791. if (evt.total === undefined) {
  16792. var firstReader = this._rangeReaders[0];
  16793. if (firstReader !== null && firstReader !== void 0 && firstReader.onProgress) {
  16794. firstReader.onProgress({
  16795. loaded: evt.loaded
  16796. });
  16797. }
  16798. } else {
  16799. var fullReader = this._fullRequestReader;
  16800. if (fullReader !== null && fullReader !== void 0 && fullReader.onProgress) {
  16801. fullReader.onProgress({
  16802. loaded: evt.loaded,
  16803. total: evt.total
  16804. });
  16805. }
  16806. }
  16807. }
  16808. }, {
  16809. key: "_onProgressiveDone",
  16810. value: function _onProgressiveDone() {
  16811. if (this._fullRequestReader) {
  16812. this._fullRequestReader.progressiveDone();
  16813. }
  16814. this._progressiveDone = true;
  16815. }
  16816. }, {
  16817. key: "_removeRangeReader",
  16818. value: function _removeRangeReader(reader) {
  16819. var i = this._rangeReaders.indexOf(reader);
  16820. if (i >= 0) {
  16821. this._rangeReaders.splice(i, 1);
  16822. }
  16823. }
  16824. }, {
  16825. key: "getFullReader",
  16826. value: function getFullReader() {
  16827. (0, _util.assert)(!this._fullRequestReader, "PDFDataTransportStream.getFullReader can only be called once.");
  16828. var queuedChunks = this._queuedChunks;
  16829. this._queuedChunks = null;
  16830. return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone);
  16831. }
  16832. }, {
  16833. key: "getRangeReader",
  16834. value: function getRangeReader(begin, end) {
  16835. if (end <= this._progressiveDataLength) {
  16836. return null;
  16837. }
  16838. var reader = new PDFDataTransportStreamRangeReader(this, begin, end);
  16839. this._pdfDataRangeTransport.requestDataRange(begin, end);
  16840. this._rangeReaders.push(reader);
  16841. return reader;
  16842. }
  16843. }, {
  16844. key: "cancelAllRequests",
  16845. value: function cancelAllRequests(reason) {
  16846. if (this._fullRequestReader) {
  16847. this._fullRequestReader.cancel(reason);
  16848. }
  16849. var readers = this._rangeReaders.slice(0);
  16850. readers.forEach(function (rangeReader) {
  16851. rangeReader.cancel(reason);
  16852. });
  16853. this._pdfDataRangeTransport.abort();
  16854. }
  16855. }, {
  16856. key: "_progressiveDataLength",
  16857. get: function get() {
  16858. var _this$_fullRequestRea, _this$_fullRequestRea2;
  16859. return (_this$_fullRequestRea = (_this$_fullRequestRea2 = this._fullRequestReader) === null || _this$_fullRequestRea2 === void 0 ? void 0 : _this$_fullRequestRea2._loaded) !== null && _this$_fullRequestRea !== void 0 ? _this$_fullRequestRea : 0;
  16860. }
  16861. }]);
  16862. return PDFDataTransportStream;
  16863. }();
  16864. exports.PDFDataTransportStream = PDFDataTransportStream;
  16865. var PDFDataTransportStreamReader = /*#__PURE__*/function () {
  16866. function PDFDataTransportStreamReader(stream, queuedChunks) {
  16867. var progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  16868. _classCallCheck(this, PDFDataTransportStreamReader);
  16869. this._stream = stream;
  16870. this._done = progressiveDone || false;
  16871. this._filename = null;
  16872. this._queuedChunks = queuedChunks || [];
  16873. this._loaded = 0;
  16874. var _iterator = _createForOfIteratorHelper(this._queuedChunks),
  16875. _step;
  16876. try {
  16877. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  16878. var chunk = _step.value;
  16879. this._loaded += chunk.byteLength;
  16880. }
  16881. } catch (err) {
  16882. _iterator.e(err);
  16883. } finally {
  16884. _iterator.f();
  16885. }
  16886. this._requests = [];
  16887. this._headersReady = Promise.resolve();
  16888. stream._fullRequestReader = this;
  16889. this.onProgress = null;
  16890. }
  16891. _createClass(PDFDataTransportStreamReader, [{
  16892. key: "_enqueue",
  16893. value: function _enqueue(chunk) {
  16894. if (this._done) {
  16895. return;
  16896. }
  16897. if (this._requests.length > 0) {
  16898. var requestCapability = this._requests.shift();
  16899. requestCapability.resolve({
  16900. value: chunk,
  16901. done: false
  16902. });
  16903. } else {
  16904. this._queuedChunks.push(chunk);
  16905. }
  16906. this._loaded += chunk.byteLength;
  16907. }
  16908. }, {
  16909. key: "read",
  16910. value: function () {
  16911. var _read = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  16912. var chunk, requestCapability;
  16913. return _regenerator["default"].wrap(function _callee$(_context) {
  16914. while (1) {
  16915. switch (_context.prev = _context.next) {
  16916. case 0:
  16917. if (!(this._queuedChunks.length > 0)) {
  16918. _context.next = 3;
  16919. break;
  16920. }
  16921. chunk = this._queuedChunks.shift();
  16922. return _context.abrupt("return", {
  16923. value: chunk,
  16924. done: false
  16925. });
  16926. case 3:
  16927. if (!this._done) {
  16928. _context.next = 5;
  16929. break;
  16930. }
  16931. return _context.abrupt("return", {
  16932. value: undefined,
  16933. done: true
  16934. });
  16935. case 5:
  16936. requestCapability = (0, _util.createPromiseCapability)();
  16937. this._requests.push(requestCapability);
  16938. return _context.abrupt("return", requestCapability.promise);
  16939. case 8:
  16940. case "end":
  16941. return _context.stop();
  16942. }
  16943. }
  16944. }, _callee, this);
  16945. }));
  16946. function read() {
  16947. return _read.apply(this, arguments);
  16948. }
  16949. return read;
  16950. }()
  16951. }, {
  16952. key: "cancel",
  16953. value: function cancel(reason) {
  16954. this._done = true;
  16955. this._requests.forEach(function (requestCapability) {
  16956. requestCapability.resolve({
  16957. value: undefined,
  16958. done: true
  16959. });
  16960. });
  16961. this._requests = [];
  16962. }
  16963. }, {
  16964. key: "progressiveDone",
  16965. value: function progressiveDone() {
  16966. if (this._done) {
  16967. return;
  16968. }
  16969. this._done = true;
  16970. }
  16971. }, {
  16972. key: "headersReady",
  16973. get: function get() {
  16974. return this._headersReady;
  16975. }
  16976. }, {
  16977. key: "filename",
  16978. get: function get() {
  16979. return this._filename;
  16980. }
  16981. }, {
  16982. key: "isRangeSupported",
  16983. get: function get() {
  16984. return this._stream._isRangeSupported;
  16985. }
  16986. }, {
  16987. key: "isStreamingSupported",
  16988. get: function get() {
  16989. return this._stream._isStreamingSupported;
  16990. }
  16991. }, {
  16992. key: "contentLength",
  16993. get: function get() {
  16994. return this._stream._contentLength;
  16995. }
  16996. }]);
  16997. return PDFDataTransportStreamReader;
  16998. }();
  16999. var PDFDataTransportStreamRangeReader = /*#__PURE__*/function () {
  17000. function PDFDataTransportStreamRangeReader(stream, begin, end) {
  17001. _classCallCheck(this, PDFDataTransportStreamRangeReader);
  17002. this._stream = stream;
  17003. this._begin = begin;
  17004. this._end = end;
  17005. this._queuedChunk = null;
  17006. this._requests = [];
  17007. this._done = false;
  17008. this.onProgress = null;
  17009. }
  17010. _createClass(PDFDataTransportStreamRangeReader, [{
  17011. key: "_enqueue",
  17012. value: function _enqueue(chunk) {
  17013. if (this._done) {
  17014. return;
  17015. }
  17016. if (this._requests.length === 0) {
  17017. this._queuedChunk = chunk;
  17018. } else {
  17019. var requestsCapability = this._requests.shift();
  17020. requestsCapability.resolve({
  17021. value: chunk,
  17022. done: false
  17023. });
  17024. this._requests.forEach(function (requestCapability) {
  17025. requestCapability.resolve({
  17026. value: undefined,
  17027. done: true
  17028. });
  17029. });
  17030. this._requests = [];
  17031. }
  17032. this._done = true;
  17033. this._stream._removeRangeReader(this);
  17034. }
  17035. }, {
  17036. key: "read",
  17037. value: function () {
  17038. var _read2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  17039. var chunk, requestCapability;
  17040. return _regenerator["default"].wrap(function _callee2$(_context2) {
  17041. while (1) {
  17042. switch (_context2.prev = _context2.next) {
  17043. case 0:
  17044. if (!this._queuedChunk) {
  17045. _context2.next = 4;
  17046. break;
  17047. }
  17048. chunk = this._queuedChunk;
  17049. this._queuedChunk = null;
  17050. return _context2.abrupt("return", {
  17051. value: chunk,
  17052. done: false
  17053. });
  17054. case 4:
  17055. if (!this._done) {
  17056. _context2.next = 6;
  17057. break;
  17058. }
  17059. return _context2.abrupt("return", {
  17060. value: undefined,
  17061. done: true
  17062. });
  17063. case 6:
  17064. requestCapability = (0, _util.createPromiseCapability)();
  17065. this._requests.push(requestCapability);
  17066. return _context2.abrupt("return", requestCapability.promise);
  17067. case 9:
  17068. case "end":
  17069. return _context2.stop();
  17070. }
  17071. }
  17072. }, _callee2, this);
  17073. }));
  17074. function read() {
  17075. return _read2.apply(this, arguments);
  17076. }
  17077. return read;
  17078. }()
  17079. }, {
  17080. key: "cancel",
  17081. value: function cancel(reason) {
  17082. this._done = true;
  17083. this._requests.forEach(function (requestCapability) {
  17084. requestCapability.resolve({
  17085. value: undefined,
  17086. done: true
  17087. });
  17088. });
  17089. this._requests = [];
  17090. this._stream._removeRangeReader(this);
  17091. }
  17092. }, {
  17093. key: "isStreamingSupported",
  17094. get: function get() {
  17095. return false;
  17096. }
  17097. }]);
  17098. return PDFDataTransportStreamRangeReader;
  17099. }();
  17100. /***/ }),
  17101. /* 148 */
  17102. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17103. "use strict";
  17104. Object.defineProperty(exports, "__esModule", ({
  17105. value: true
  17106. }));
  17107. exports.WebGLContext = void 0;
  17108. var _util = __w_pdfjs_require__(4);
  17109. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17110. 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); } }
  17111. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17112. var WebGLContext = /*#__PURE__*/function () {
  17113. function WebGLContext(_ref) {
  17114. var _ref$enable = _ref.enable,
  17115. enable = _ref$enable === void 0 ? false : _ref$enable;
  17116. _classCallCheck(this, WebGLContext);
  17117. this._enabled = enable === true;
  17118. }
  17119. _createClass(WebGLContext, [{
  17120. key: "composeSMask",
  17121. value: function composeSMask(_ref2) {
  17122. var layer = _ref2.layer,
  17123. mask = _ref2.mask,
  17124. properties = _ref2.properties;
  17125. return WebGLUtils.composeSMask(layer, mask, properties);
  17126. }
  17127. }, {
  17128. key: "drawFigures",
  17129. value: function drawFigures(_ref3) {
  17130. var width = _ref3.width,
  17131. height = _ref3.height,
  17132. backgroundColor = _ref3.backgroundColor,
  17133. figures = _ref3.figures,
  17134. context = _ref3.context;
  17135. return WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  17136. }
  17137. }, {
  17138. key: "clear",
  17139. value: function clear() {
  17140. WebGLUtils.cleanup();
  17141. }
  17142. }, {
  17143. key: "isEnabled",
  17144. get: function get() {
  17145. var enabled = this._enabled;
  17146. if (enabled) {
  17147. enabled = WebGLUtils.tryInitGL();
  17148. }
  17149. return (0, _util.shadow)(this, "isEnabled", enabled);
  17150. }
  17151. }]);
  17152. return WebGLContext;
  17153. }();
  17154. exports.WebGLContext = WebGLContext;
  17155. var WebGLUtils = function WebGLUtilsClosure() {
  17156. function loadShader(gl, code, shaderType) {
  17157. var shader = gl.createShader(shaderType);
  17158. gl.shaderSource(shader, code);
  17159. gl.compileShader(shader);
  17160. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  17161. if (!compiled) {
  17162. var errorMsg = gl.getShaderInfoLog(shader);
  17163. throw new Error("Error during shader compilation: " + errorMsg);
  17164. }
  17165. return shader;
  17166. }
  17167. function createVertexShader(gl, code) {
  17168. return loadShader(gl, code, gl.VERTEX_SHADER);
  17169. }
  17170. function createFragmentShader(gl, code) {
  17171. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  17172. }
  17173. function createProgram(gl, shaders) {
  17174. var program = gl.createProgram();
  17175. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  17176. gl.attachShader(program, shaders[i]);
  17177. }
  17178. gl.linkProgram(program);
  17179. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  17180. if (!linked) {
  17181. var errorMsg = gl.getProgramInfoLog(program);
  17182. throw new Error("Error during program linking: " + errorMsg);
  17183. }
  17184. return program;
  17185. }
  17186. function createTexture(gl, image, textureId) {
  17187. gl.activeTexture(textureId);
  17188. var texture = gl.createTexture();
  17189. gl.bindTexture(gl.TEXTURE_2D, texture);
  17190. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  17191. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  17192. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  17193. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  17194. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  17195. return texture;
  17196. }
  17197. var currentGL, currentCanvas;
  17198. function generateGL() {
  17199. if (currentGL) {
  17200. return;
  17201. }
  17202. currentCanvas = document.createElement("canvas");
  17203. currentGL = currentCanvas.getContext("webgl", {
  17204. premultipliedalpha: false
  17205. });
  17206. }
  17207. var smaskVertexShaderCode = "\
  17208. attribute vec2 a_position; \
  17209. attribute vec2 a_texCoord; \
  17210. \
  17211. uniform vec2 u_resolution; \
  17212. \
  17213. varying vec2 v_texCoord; \
  17214. \
  17215. void main() { \
  17216. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  17217. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  17218. \
  17219. v_texCoord = a_texCoord; \
  17220. } ";
  17221. var smaskFragmentShaderCode = "\
  17222. precision mediump float; \
  17223. \
  17224. uniform vec4 u_backdrop; \
  17225. uniform int u_subtype; \
  17226. uniform sampler2D u_image; \
  17227. uniform sampler2D u_mask; \
  17228. \
  17229. varying vec2 v_texCoord; \
  17230. \
  17231. void main() { \
  17232. vec4 imageColor = texture2D(u_image, v_texCoord); \
  17233. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  17234. if (u_backdrop.a > 0.0) { \
  17235. maskColor.rgb = maskColor.rgb * maskColor.a + \
  17236. u_backdrop.rgb * (1.0 - maskColor.a); \
  17237. } \
  17238. float lum; \
  17239. if (u_subtype == 0) { \
  17240. lum = maskColor.a; \
  17241. } else { \
  17242. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  17243. maskColor.b * 0.11; \
  17244. } \
  17245. imageColor.a *= lum; \
  17246. imageColor.rgb *= imageColor.a; \
  17247. gl_FragColor = imageColor; \
  17248. } ";
  17249. var smaskCache = null;
  17250. function initSmaskGL() {
  17251. generateGL();
  17252. var canvas = currentCanvas;
  17253. currentCanvas = null;
  17254. var gl = currentGL;
  17255. currentGL = null;
  17256. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  17257. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  17258. var program = createProgram(gl, [vertexShader, fragmentShader]);
  17259. gl.useProgram(program);
  17260. var cache = {};
  17261. cache.gl = gl;
  17262. cache.canvas = canvas;
  17263. cache.resolutionLocation = gl.getUniformLocation(program, "u_resolution");
  17264. cache.positionLocation = gl.getAttribLocation(program, "a_position");
  17265. cache.backdropLocation = gl.getUniformLocation(program, "u_backdrop");
  17266. cache.subtypeLocation = gl.getUniformLocation(program, "u_subtype");
  17267. var texCoordLocation = gl.getAttribLocation(program, "a_texCoord");
  17268. var texLayerLocation = gl.getUniformLocation(program, "u_image");
  17269. var texMaskLocation = gl.getUniformLocation(program, "u_mask");
  17270. var texCoordBuffer = gl.createBuffer();
  17271. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  17272. 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);
  17273. gl.enableVertexAttribArray(texCoordLocation);
  17274. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  17275. gl.uniform1i(texLayerLocation, 0);
  17276. gl.uniform1i(texMaskLocation, 1);
  17277. smaskCache = cache;
  17278. }
  17279. function composeSMask(layer, mask, properties) {
  17280. var width = layer.width,
  17281. height = layer.height;
  17282. if (!smaskCache) {
  17283. initSmaskGL();
  17284. }
  17285. var cache = smaskCache,
  17286. canvas = cache.canvas,
  17287. gl = cache.gl;
  17288. canvas.width = width;
  17289. canvas.height = height;
  17290. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  17291. gl.uniform2f(cache.resolutionLocation, width, height);
  17292. if (properties.backdrop) {
  17293. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  17294. } else {
  17295. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  17296. }
  17297. gl.uniform1i(cache.subtypeLocation, properties.subtype === "Luminosity" ? 1 : 0);
  17298. var texture = createTexture(gl, layer, gl.TEXTURE0);
  17299. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  17300. var buffer = gl.createBuffer();
  17301. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  17302. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW);
  17303. gl.enableVertexAttribArray(cache.positionLocation);
  17304. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  17305. gl.clearColor(0, 0, 0, 0);
  17306. gl.enable(gl.BLEND);
  17307. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  17308. gl.clear(gl.COLOR_BUFFER_BIT);
  17309. gl.drawArrays(gl.TRIANGLES, 0, 6);
  17310. gl.flush();
  17311. gl.deleteTexture(texture);
  17312. gl.deleteTexture(maskTexture);
  17313. gl.deleteBuffer(buffer);
  17314. return canvas;
  17315. }
  17316. var figuresVertexShaderCode = "\
  17317. attribute vec2 a_position; \
  17318. attribute vec3 a_color; \
  17319. \
  17320. uniform vec2 u_resolution; \
  17321. uniform vec2 u_scale; \
  17322. uniform vec2 u_offset; \
  17323. \
  17324. varying vec4 v_color; \
  17325. \
  17326. void main() { \
  17327. vec2 position = (a_position + u_offset) * u_scale; \
  17328. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  17329. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  17330. \
  17331. v_color = vec4(a_color / 255.0, 1.0); \
  17332. } ";
  17333. var figuresFragmentShaderCode = "\
  17334. precision mediump float; \
  17335. \
  17336. varying vec4 v_color; \
  17337. \
  17338. void main() { \
  17339. gl_FragColor = v_color; \
  17340. } ";
  17341. var figuresCache = null;
  17342. function initFiguresGL() {
  17343. generateGL();
  17344. var canvas = currentCanvas;
  17345. currentCanvas = null;
  17346. var gl = currentGL;
  17347. currentGL = null;
  17348. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  17349. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  17350. var program = createProgram(gl, [vertexShader, fragmentShader]);
  17351. gl.useProgram(program);
  17352. var cache = {};
  17353. cache.gl = gl;
  17354. cache.canvas = canvas;
  17355. cache.resolutionLocation = gl.getUniformLocation(program, "u_resolution");
  17356. cache.scaleLocation = gl.getUniformLocation(program, "u_scale");
  17357. cache.offsetLocation = gl.getUniformLocation(program, "u_offset");
  17358. cache.positionLocation = gl.getAttribLocation(program, "a_position");
  17359. cache.colorLocation = gl.getAttribLocation(program, "a_color");
  17360. figuresCache = cache;
  17361. }
  17362. function drawFigures(width, height, backgroundColor, figures, context) {
  17363. if (!figuresCache) {
  17364. initFiguresGL();
  17365. }
  17366. var cache = figuresCache,
  17367. canvas = cache.canvas,
  17368. gl = cache.gl;
  17369. canvas.width = width;
  17370. canvas.height = height;
  17371. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  17372. gl.uniform2f(cache.resolutionLocation, width, height);
  17373. var count = 0;
  17374. for (var i = 0, ii = figures.length; i < ii; i++) {
  17375. switch (figures[i].type) {
  17376. case "lattice":
  17377. var rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  17378. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  17379. break;
  17380. case "triangles":
  17381. count += figures[i].coords.length;
  17382. break;
  17383. }
  17384. }
  17385. var coords = new Float32Array(count * 2);
  17386. var colors = new Uint8Array(count * 3);
  17387. var coordsMap = context.coords,
  17388. colorsMap = context.colors;
  17389. var pIndex = 0,
  17390. cIndex = 0;
  17391. for (var _i = 0, _ii = figures.length; _i < _ii; _i++) {
  17392. var figure = figures[_i],
  17393. ps = figure.coords,
  17394. cs = figure.colors;
  17395. switch (figure.type) {
  17396. case "lattice":
  17397. var cols = figure.verticesPerRow;
  17398. var _rows = ps.length / cols | 0;
  17399. for (var row = 1; row < _rows; row++) {
  17400. var offset = row * cols + 1;
  17401. for (var col = 1; col < cols; col++, offset++) {
  17402. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  17403. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  17404. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  17405. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  17406. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  17407. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  17408. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  17409. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  17410. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  17411. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  17412. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  17413. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  17414. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  17415. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  17416. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  17417. coords[pIndex + 6] = coords[pIndex + 2];
  17418. coords[pIndex + 7] = coords[pIndex + 3];
  17419. coords[pIndex + 8] = coords[pIndex + 4];
  17420. coords[pIndex + 9] = coords[pIndex + 5];
  17421. coords[pIndex + 10] = coordsMap[ps[offset]];
  17422. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  17423. colors[cIndex + 9] = colors[cIndex + 3];
  17424. colors[cIndex + 10] = colors[cIndex + 4];
  17425. colors[cIndex + 11] = colors[cIndex + 5];
  17426. colors[cIndex + 12] = colors[cIndex + 6];
  17427. colors[cIndex + 13] = colors[cIndex + 7];
  17428. colors[cIndex + 14] = colors[cIndex + 8];
  17429. colors[cIndex + 15] = colorsMap[cs[offset]];
  17430. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  17431. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  17432. pIndex += 12;
  17433. cIndex += 18;
  17434. }
  17435. }
  17436. break;
  17437. case "triangles":
  17438. for (var j = 0, jj = ps.length; j < jj; j++) {
  17439. coords[pIndex] = coordsMap[ps[j]];
  17440. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  17441. colors[cIndex] = colorsMap[cs[j]];
  17442. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  17443. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  17444. pIndex += 2;
  17445. cIndex += 3;
  17446. }
  17447. break;
  17448. }
  17449. }
  17450. if (backgroundColor) {
  17451. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  17452. } else {
  17453. gl.clearColor(0, 0, 0, 0);
  17454. }
  17455. gl.clear(gl.COLOR_BUFFER_BIT);
  17456. var coordsBuffer = gl.createBuffer();
  17457. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  17458. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  17459. gl.enableVertexAttribArray(cache.positionLocation);
  17460. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  17461. var colorsBuffer = gl.createBuffer();
  17462. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  17463. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  17464. gl.enableVertexAttribArray(cache.colorLocation);
  17465. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  17466. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  17467. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  17468. gl.drawArrays(gl.TRIANGLES, 0, count);
  17469. gl.flush();
  17470. gl.deleteBuffer(coordsBuffer);
  17471. gl.deleteBuffer(colorsBuffer);
  17472. return canvas;
  17473. }
  17474. return {
  17475. tryInitGL: function tryInitGL() {
  17476. try {
  17477. generateGL();
  17478. return !!currentGL;
  17479. } catch (ex) {}
  17480. return false;
  17481. },
  17482. composeSMask: composeSMask,
  17483. drawFigures: drawFigures,
  17484. cleanup: function cleanup() {
  17485. var _smaskCache, _figuresCache;
  17486. if ((_smaskCache = smaskCache) !== null && _smaskCache !== void 0 && _smaskCache.canvas) {
  17487. smaskCache.canvas.width = 0;
  17488. smaskCache.canvas.height = 0;
  17489. }
  17490. if ((_figuresCache = figuresCache) !== null && _figuresCache !== void 0 && _figuresCache.canvas) {
  17491. figuresCache.canvas.width = 0;
  17492. figuresCache.canvas.height = 0;
  17493. }
  17494. smaskCache = null;
  17495. figuresCache = null;
  17496. }
  17497. };
  17498. }();
  17499. /***/ }),
  17500. /* 149 */
  17501. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17502. "use strict";
  17503. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  17504. Object.defineProperty(exports, "__esModule", ({
  17505. value: true
  17506. }));
  17507. exports.AnnotationLayer = void 0;
  17508. var _display_utils = __w_pdfjs_require__(1);
  17509. var _util = __w_pdfjs_require__(4);
  17510. var _annotation_storage = __w_pdfjs_require__(138);
  17511. var _scripting_utils = __w_pdfjs_require__(150);
  17512. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  17513. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  17514. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  17515. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  17516. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  17517. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  17518. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  17519. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  17520. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  17521. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17522. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17523. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  17524. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17525. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  17526. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  17527. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  17528. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17529. 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); } }
  17530. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17531. var AnnotationElementFactory = /*#__PURE__*/function () {
  17532. function AnnotationElementFactory() {
  17533. _classCallCheck(this, AnnotationElementFactory);
  17534. }
  17535. _createClass(AnnotationElementFactory, null, [{
  17536. key: "create",
  17537. value: function create(parameters) {
  17538. var subtype = parameters.data.annotationType;
  17539. switch (subtype) {
  17540. case _util.AnnotationType.LINK:
  17541. return new LinkAnnotationElement(parameters);
  17542. case _util.AnnotationType.TEXT:
  17543. return new TextAnnotationElement(parameters);
  17544. case _util.AnnotationType.WIDGET:
  17545. var fieldType = parameters.data.fieldType;
  17546. switch (fieldType) {
  17547. case "Tx":
  17548. return new TextWidgetAnnotationElement(parameters);
  17549. case "Btn":
  17550. if (parameters.data.radioButton) {
  17551. return new RadioButtonWidgetAnnotationElement(parameters);
  17552. } else if (parameters.data.checkBox) {
  17553. return new CheckboxWidgetAnnotationElement(parameters);
  17554. }
  17555. return new PushButtonWidgetAnnotationElement(parameters);
  17556. case "Ch":
  17557. return new ChoiceWidgetAnnotationElement(parameters);
  17558. }
  17559. return new WidgetAnnotationElement(parameters);
  17560. case _util.AnnotationType.POPUP:
  17561. return new PopupAnnotationElement(parameters);
  17562. case _util.AnnotationType.FREETEXT:
  17563. return new FreeTextAnnotationElement(parameters);
  17564. case _util.AnnotationType.LINE:
  17565. return new LineAnnotationElement(parameters);
  17566. case _util.AnnotationType.SQUARE:
  17567. return new SquareAnnotationElement(parameters);
  17568. case _util.AnnotationType.CIRCLE:
  17569. return new CircleAnnotationElement(parameters);
  17570. case _util.AnnotationType.POLYLINE:
  17571. return new PolylineAnnotationElement(parameters);
  17572. case _util.AnnotationType.CARET:
  17573. return new CaretAnnotationElement(parameters);
  17574. case _util.AnnotationType.INK:
  17575. return new InkAnnotationElement(parameters);
  17576. case _util.AnnotationType.POLYGON:
  17577. return new PolygonAnnotationElement(parameters);
  17578. case _util.AnnotationType.HIGHLIGHT:
  17579. return new HighlightAnnotationElement(parameters);
  17580. case _util.AnnotationType.UNDERLINE:
  17581. return new UnderlineAnnotationElement(parameters);
  17582. case _util.AnnotationType.SQUIGGLY:
  17583. return new SquigglyAnnotationElement(parameters);
  17584. case _util.AnnotationType.STRIKEOUT:
  17585. return new StrikeOutAnnotationElement(parameters);
  17586. case _util.AnnotationType.STAMP:
  17587. return new StampAnnotationElement(parameters);
  17588. case _util.AnnotationType.FILEATTACHMENT:
  17589. return new FileAttachmentAnnotationElement(parameters);
  17590. default:
  17591. return new AnnotationElement(parameters);
  17592. }
  17593. }
  17594. }]);
  17595. return AnnotationElementFactory;
  17596. }();
  17597. var AnnotationElement = /*#__PURE__*/function () {
  17598. function AnnotationElement(parameters) {
  17599. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  17600. _ref$isRenderable = _ref.isRenderable,
  17601. isRenderable = _ref$isRenderable === void 0 ? false : _ref$isRenderable,
  17602. _ref$ignoreBorder = _ref.ignoreBorder,
  17603. ignoreBorder = _ref$ignoreBorder === void 0 ? false : _ref$ignoreBorder,
  17604. _ref$createQuadrilate = _ref.createQuadrilaterals,
  17605. createQuadrilaterals = _ref$createQuadrilate === void 0 ? false : _ref$createQuadrilate;
  17606. _classCallCheck(this, AnnotationElement);
  17607. this.isRenderable = isRenderable;
  17608. this.data = parameters.data;
  17609. this.layer = parameters.layer;
  17610. this.page = parameters.page;
  17611. this.viewport = parameters.viewport;
  17612. this.linkService = parameters.linkService;
  17613. this.downloadManager = parameters.downloadManager;
  17614. this.imageResourcesPath = parameters.imageResourcesPath;
  17615. this.renderInteractiveForms = parameters.renderInteractiveForms;
  17616. this.svgFactory = parameters.svgFactory;
  17617. this.annotationStorage = parameters.annotationStorage;
  17618. this.enableScripting = parameters.enableScripting;
  17619. this.hasJSActions = parameters.hasJSActions;
  17620. this._mouseState = parameters.mouseState;
  17621. if (isRenderable) {
  17622. this.container = this._createContainer(ignoreBorder);
  17623. }
  17624. if (createQuadrilaterals) {
  17625. this.quadrilaterals = this._createQuadrilaterals(ignoreBorder);
  17626. }
  17627. }
  17628. _createClass(AnnotationElement, [{
  17629. key: "_createContainer",
  17630. value: function _createContainer() {
  17631. var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17632. var data = this.data,
  17633. page = this.page,
  17634. viewport = this.viewport;
  17635. var container = document.createElement("section");
  17636. var width = data.rect[2] - data.rect[0];
  17637. var height = data.rect[3] - data.rect[1];
  17638. container.setAttribute("data-annotation-id", data.id);
  17639. 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]]);
  17640. container.style.transform = "matrix(".concat(viewport.transform.join(","), ")");
  17641. container.style.transformOrigin = "".concat(-rect[0], "px ").concat(-rect[1], "px");
  17642. if (!ignoreBorder && data.borderStyle.width > 0) {
  17643. container.style.borderWidth = "".concat(data.borderStyle.width, "px");
  17644. if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
  17645. width = width - 2 * data.borderStyle.width;
  17646. height = height - 2 * data.borderStyle.width;
  17647. }
  17648. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  17649. var verticalRadius = data.borderStyle.verticalCornerRadius;
  17650. if (horizontalRadius > 0 || verticalRadius > 0) {
  17651. var radius = "".concat(horizontalRadius, "px / ").concat(verticalRadius, "px");
  17652. container.style.borderRadius = radius;
  17653. }
  17654. switch (data.borderStyle.style) {
  17655. case _util.AnnotationBorderStyleType.SOLID:
  17656. container.style.borderStyle = "solid";
  17657. break;
  17658. case _util.AnnotationBorderStyleType.DASHED:
  17659. container.style.borderStyle = "dashed";
  17660. break;
  17661. case _util.AnnotationBorderStyleType.BEVELED:
  17662. (0, _util.warn)("Unimplemented border style: beveled");
  17663. break;
  17664. case _util.AnnotationBorderStyleType.INSET:
  17665. (0, _util.warn)("Unimplemented border style: inset");
  17666. break;
  17667. case _util.AnnotationBorderStyleType.UNDERLINE:
  17668. container.style.borderBottomStyle = "solid";
  17669. break;
  17670. default:
  17671. break;
  17672. }
  17673. if (data.color) {
  17674. container.style.borderColor = _util.Util.makeHexColor(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  17675. } else {
  17676. container.style.borderWidth = 0;
  17677. }
  17678. }
  17679. container.style.left = "".concat(rect[0], "px");
  17680. container.style.top = "".concat(rect[1], "px");
  17681. container.style.width = "".concat(width, "px");
  17682. container.style.height = "".concat(height, "px");
  17683. return container;
  17684. }
  17685. }, {
  17686. key: "_createQuadrilaterals",
  17687. value: function _createQuadrilaterals() {
  17688. var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17689. if (!this.data.quadPoints) {
  17690. return null;
  17691. }
  17692. var quadrilaterals = [];
  17693. var savedRect = this.data.rect;
  17694. var _iterator = _createForOfIteratorHelper(this.data.quadPoints),
  17695. _step;
  17696. try {
  17697. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  17698. var quadPoint = _step.value;
  17699. this.data.rect = [quadPoint[2].x, quadPoint[2].y, quadPoint[1].x, quadPoint[1].y];
  17700. quadrilaterals.push(this._createContainer(ignoreBorder));
  17701. }
  17702. } catch (err) {
  17703. _iterator.e(err);
  17704. } finally {
  17705. _iterator.f();
  17706. }
  17707. this.data.rect = savedRect;
  17708. return quadrilaterals;
  17709. }
  17710. }, {
  17711. key: "_createPopup",
  17712. value: function _createPopup(trigger, data) {
  17713. var container = this.container;
  17714. if (this.quadrilaterals) {
  17715. trigger = trigger || this.quadrilaterals;
  17716. container = this.quadrilaterals[0];
  17717. }
  17718. if (!trigger) {
  17719. trigger = document.createElement("div");
  17720. trigger.style.height = container.style.height;
  17721. trigger.style.width = container.style.width;
  17722. container.appendChild(trigger);
  17723. }
  17724. var popupElement = new PopupElement({
  17725. container: container,
  17726. trigger: trigger,
  17727. color: data.color,
  17728. title: data.title,
  17729. modificationDate: data.modificationDate,
  17730. contents: data.contents,
  17731. hideWrapper: true
  17732. });
  17733. var popup = popupElement.render();
  17734. popup.style.left = container.style.width;
  17735. container.appendChild(popup);
  17736. }
  17737. }, {
  17738. key: "_renderQuadrilaterals",
  17739. value: function _renderQuadrilaterals(className) {
  17740. this.quadrilaterals.forEach(function (quadrilateral) {
  17741. quadrilateral.className = className;
  17742. });
  17743. return this.quadrilaterals;
  17744. }
  17745. }, {
  17746. key: "render",
  17747. value: function render() {
  17748. (0, _util.unreachable)("Abstract method `AnnotationElement.render` called");
  17749. }
  17750. }]);
  17751. return AnnotationElement;
  17752. }();
  17753. var LinkAnnotationElement = /*#__PURE__*/function (_AnnotationElement) {
  17754. _inherits(LinkAnnotationElement, _AnnotationElement);
  17755. var _super = _createSuper(LinkAnnotationElement);
  17756. function LinkAnnotationElement(parameters) {
  17757. _classCallCheck(this, LinkAnnotationElement);
  17758. var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action || parameters.data.isTooltipOnly || parameters.data.actions && (parameters.data.actions.Action || parameters.data.actions["Mouse Up"] || parameters.data.actions["Mouse Down"]));
  17759. return _super.call(this, parameters, {
  17760. isRenderable: isRenderable,
  17761. createQuadrilaterals: true
  17762. });
  17763. }
  17764. _createClass(LinkAnnotationElement, [{
  17765. key: "render",
  17766. value: function render() {
  17767. var data = this.data,
  17768. linkService = this.linkService;
  17769. var link = document.createElement("a");
  17770. if (data.url) {
  17771. (0, _display_utils.addLinkAttributes)(link, {
  17772. url: data.url,
  17773. target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
  17774. rel: linkService.externalLinkRel,
  17775. enabled: linkService.externalLinkEnabled
  17776. });
  17777. } else if (data.action) {
  17778. this._bindNamedAction(link, data.action);
  17779. } else if (data.dest) {
  17780. this._bindLink(link, data.dest);
  17781. } else if (data.actions && (data.actions.Action || data.actions["Mouse Up"] || data.actions["Mouse Down"]) && this.enableScripting && this.hasJSActions) {
  17782. this._bindJSAction(link, data);
  17783. } else {
  17784. this._bindLink(link, "");
  17785. }
  17786. if (this.quadrilaterals) {
  17787. return this._renderQuadrilaterals("linkAnnotation").map(function (quadrilateral, index) {
  17788. var linkElement = index === 0 ? link : link.cloneNode();
  17789. quadrilateral.appendChild(linkElement);
  17790. return quadrilateral;
  17791. });
  17792. }
  17793. this.container.className = "linkAnnotation";
  17794. this.container.appendChild(link);
  17795. return this.container;
  17796. }
  17797. }, {
  17798. key: "_bindLink",
  17799. value: function _bindLink(link, destination) {
  17800. var _this = this;
  17801. link.href = this.linkService.getDestinationHash(destination);
  17802. link.onclick = function () {
  17803. if (destination) {
  17804. _this.linkService.goToDestination(destination);
  17805. }
  17806. return false;
  17807. };
  17808. if (destination || destination === "") {
  17809. link.className = "internalLink";
  17810. }
  17811. }
  17812. }, {
  17813. key: "_bindNamedAction",
  17814. value: function _bindNamedAction(link, action) {
  17815. var _this2 = this;
  17816. link.href = this.linkService.getAnchorUrl("");
  17817. link.onclick = function () {
  17818. _this2.linkService.executeNamedAction(action);
  17819. return false;
  17820. };
  17821. link.className = "internalLink";
  17822. }
  17823. }, {
  17824. key: "_bindJSAction",
  17825. value: function _bindJSAction(link, data) {
  17826. var _this3 = this;
  17827. link.href = this.linkService.getAnchorUrl("");
  17828. var map = new Map([["Action", "onclick"], ["Mouse Up", "onmouseup"], ["Mouse Down", "onmousedown"]]);
  17829. var _loop = function _loop() {
  17830. var name = _Object$keys[_i];
  17831. var jsName = map.get(name);
  17832. if (!jsName) {
  17833. return "continue";
  17834. }
  17835. link[jsName] = function () {
  17836. var _this3$linkService$ev;
  17837. (_this3$linkService$ev = _this3.linkService.eventBus) === null || _this3$linkService$ev === void 0 ? void 0 : _this3$linkService$ev.dispatch("dispatcheventinsandbox", {
  17838. source: _this3,
  17839. detail: {
  17840. id: data.id,
  17841. name: name
  17842. }
  17843. });
  17844. return false;
  17845. };
  17846. };
  17847. for (var _i = 0, _Object$keys = Object.keys(data.actions); _i < _Object$keys.length; _i++) {
  17848. var _ret = _loop();
  17849. if (_ret === "continue") continue;
  17850. }
  17851. link.className = "internalLink";
  17852. }
  17853. }]);
  17854. return LinkAnnotationElement;
  17855. }(AnnotationElement);
  17856. var TextAnnotationElement = /*#__PURE__*/function (_AnnotationElement2) {
  17857. _inherits(TextAnnotationElement, _AnnotationElement2);
  17858. var _super2 = _createSuper(TextAnnotationElement);
  17859. function TextAnnotationElement(parameters) {
  17860. _classCallCheck(this, TextAnnotationElement);
  17861. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  17862. return _super2.call(this, parameters, {
  17863. isRenderable: isRenderable
  17864. });
  17865. }
  17866. _createClass(TextAnnotationElement, [{
  17867. key: "render",
  17868. value: function render() {
  17869. this.container.className = "textAnnotation";
  17870. var image = document.createElement("img");
  17871. image.style.height = this.container.style.height;
  17872. image.style.width = this.container.style.width;
  17873. image.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg";
  17874. image.alt = "[{{type}} Annotation]";
  17875. image.dataset.l10nId = "text_annotation_type";
  17876. image.dataset.l10nArgs = JSON.stringify({
  17877. type: this.data.name
  17878. });
  17879. if (!this.data.hasPopup) {
  17880. this._createPopup(image, this.data);
  17881. }
  17882. this.container.appendChild(image);
  17883. return this.container;
  17884. }
  17885. }]);
  17886. return TextAnnotationElement;
  17887. }(AnnotationElement);
  17888. var WidgetAnnotationElement = /*#__PURE__*/function (_AnnotationElement3) {
  17889. _inherits(WidgetAnnotationElement, _AnnotationElement3);
  17890. var _super3 = _createSuper(WidgetAnnotationElement);
  17891. function WidgetAnnotationElement() {
  17892. _classCallCheck(this, WidgetAnnotationElement);
  17893. return _super3.apply(this, arguments);
  17894. }
  17895. _createClass(WidgetAnnotationElement, [{
  17896. key: "render",
  17897. value: function render() {
  17898. if (this.data.alternativeText) {
  17899. this.container.title = this.data.alternativeText;
  17900. }
  17901. return this.container;
  17902. }
  17903. }, {
  17904. key: "_getKeyModifier",
  17905. value: function _getKeyModifier(event) {
  17906. return navigator.platform.includes("Win") && event.ctrlKey || navigator.platform.includes("Mac") && event.metaKey;
  17907. }
  17908. }, {
  17909. key: "_setEventListener",
  17910. value: function _setEventListener(element, baseName, eventName, valueGetter) {
  17911. var _this4 = this;
  17912. if (baseName.includes("mouse")) {
  17913. element.addEventListener(baseName, function (event) {
  17914. var _this4$linkService$ev;
  17915. (_this4$linkService$ev = _this4.linkService.eventBus) === null || _this4$linkService$ev === void 0 ? void 0 : _this4$linkService$ev.dispatch("dispatcheventinsandbox", {
  17916. source: _this4,
  17917. detail: {
  17918. id: _this4.data.id,
  17919. name: eventName,
  17920. value: valueGetter(event),
  17921. shift: event.shiftKey,
  17922. modifier: _this4._getKeyModifier(event)
  17923. }
  17924. });
  17925. });
  17926. } else {
  17927. element.addEventListener(baseName, function (event) {
  17928. var _this4$linkService$ev2;
  17929. (_this4$linkService$ev2 = _this4.linkService.eventBus) === null || _this4$linkService$ev2 === void 0 ? void 0 : _this4$linkService$ev2.dispatch("dispatcheventinsandbox", {
  17930. source: _this4,
  17931. detail: {
  17932. id: _this4.data.id,
  17933. name: eventName,
  17934. value: event.target.checked
  17935. }
  17936. });
  17937. });
  17938. }
  17939. }
  17940. }, {
  17941. key: "_setEventListeners",
  17942. value: function _setEventListeners(element, names, getter) {
  17943. var _iterator2 = _createForOfIteratorHelper(names),
  17944. _step2;
  17945. try {
  17946. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  17947. var _this$data$actions;
  17948. var _step2$value = _slicedToArray(_step2.value, 2),
  17949. baseName = _step2$value[0],
  17950. eventName = _step2$value[1];
  17951. if (eventName === "Action" || (_this$data$actions = this.data.actions) !== null && _this$data$actions !== void 0 && _this$data$actions[eventName]) {
  17952. this._setEventListener(element, baseName, eventName, getter);
  17953. }
  17954. }
  17955. } catch (err) {
  17956. _iterator2.e(err);
  17957. } finally {
  17958. _iterator2.f();
  17959. }
  17960. }
  17961. }]);
  17962. return WidgetAnnotationElement;
  17963. }(AnnotationElement);
  17964. var TextWidgetAnnotationElement = /*#__PURE__*/function (_WidgetAnnotationElem) {
  17965. _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
  17966. var _super4 = _createSuper(TextWidgetAnnotationElement);
  17967. function TextWidgetAnnotationElement(parameters) {
  17968. _classCallCheck(this, TextWidgetAnnotationElement);
  17969. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  17970. return _super4.call(this, parameters, {
  17971. isRenderable: isRenderable
  17972. });
  17973. }
  17974. _createClass(TextWidgetAnnotationElement, [{
  17975. key: "render",
  17976. value: function render() {
  17977. var _this5 = this;
  17978. var storage = this.annotationStorage;
  17979. var id = this.data.id;
  17980. this.container.className = "textWidgetAnnotation";
  17981. var element = null;
  17982. if (this.renderInteractiveForms) {
  17983. var textContent = storage.getOrCreateValue(id, {
  17984. value: this.data.fieldValue
  17985. }).value;
  17986. var elementData = {
  17987. userValue: null,
  17988. formattedValue: null,
  17989. beforeInputSelectionRange: null,
  17990. beforeInputValue: null
  17991. };
  17992. if (this.data.multiLine) {
  17993. element = document.createElement("textarea");
  17994. element.textContent = textContent;
  17995. } else {
  17996. element = document.createElement("input");
  17997. element.type = "text";
  17998. element.setAttribute("value", textContent);
  17999. }
  18000. elementData.userValue = textContent;
  18001. element.setAttribute("id", id);
  18002. element.addEventListener("input", function (event) {
  18003. storage.setValue(id, {
  18004. value: event.target.value
  18005. });
  18006. });
  18007. var blurListener = function blurListener(event) {
  18008. if (elementData.formattedValue) {
  18009. event.target.value = elementData.formattedValue;
  18010. }
  18011. event.target.setSelectionRange(0, 0);
  18012. elementData.beforeInputSelectionRange = null;
  18013. };
  18014. if (this.enableScripting && this.hasJSActions) {
  18015. element.addEventListener("focus", function (event) {
  18016. if (elementData.userValue) {
  18017. event.target.value = elementData.userValue;
  18018. }
  18019. });
  18020. element.addEventListener("updatefromsandbox", function (event) {
  18021. var detail = event.detail;
  18022. var actions = {
  18023. value: function value() {
  18024. elementData.userValue = detail.value || "";
  18025. storage.setValue(id, {
  18026. value: elementData.userValue.toString()
  18027. });
  18028. if (!elementData.formattedValue) {
  18029. event.target.value = elementData.userValue;
  18030. }
  18031. },
  18032. valueAsString: function valueAsString() {
  18033. elementData.formattedValue = detail.valueAsString || "";
  18034. if (event.target !== document.activeElement) {
  18035. event.target.value = elementData.formattedValue;
  18036. }
  18037. storage.setValue(id, {
  18038. formattedValue: elementData.formattedValue
  18039. });
  18040. },
  18041. focus: function focus() {
  18042. setTimeout(function () {
  18043. return event.target.focus({
  18044. preventScroll: false
  18045. });
  18046. }, 0);
  18047. },
  18048. userName: function userName() {
  18049. event.target.title = detail.userName;
  18050. },
  18051. hidden: function hidden() {
  18052. event.target.style.visibility = detail.hidden ? "hidden" : "visible";
  18053. storage.setValue(id, {
  18054. hidden: detail.hidden
  18055. });
  18056. },
  18057. editable: function editable() {
  18058. event.target.disabled = !detail.editable;
  18059. },
  18060. selRange: function selRange() {
  18061. var _detail$selRange = _slicedToArray(detail.selRange, 2),
  18062. selStart = _detail$selRange[0],
  18063. selEnd = _detail$selRange[1];
  18064. if (selStart >= 0 && selEnd < event.target.value.length) {
  18065. event.target.setSelectionRange(selStart, selEnd);
  18066. }
  18067. },
  18068. strokeColor: function strokeColor() {
  18069. var color = detail.strokeColor;
  18070. event.target.style.color = _scripting_utils.ColorConverters["".concat(color[0], "_HTML")](color.slice(1));
  18071. }
  18072. };
  18073. Object.keys(detail).filter(function (name) {
  18074. return name in actions;
  18075. }).forEach(function (name) {
  18076. return actions[name]();
  18077. });
  18078. });
  18079. if (this.data.actions) {
  18080. element.addEventListener("keydown", function (event) {
  18081. var _this5$linkService$ev;
  18082. elementData.beforeInputValue = event.target.value;
  18083. var commitKey = -1;
  18084. if (event.key === "Escape") {
  18085. commitKey = 0;
  18086. } else if (event.key === "Enter") {
  18087. commitKey = 2;
  18088. } else if (event.key === "Tab") {
  18089. commitKey = 3;
  18090. }
  18091. if (commitKey === -1) {
  18092. return;
  18093. }
  18094. elementData.userValue = event.target.value;
  18095. (_this5$linkService$ev = _this5.linkService.eventBus) === null || _this5$linkService$ev === void 0 ? void 0 : _this5$linkService$ev.dispatch("dispatcheventinsandbox", {
  18096. source: _this5,
  18097. detail: {
  18098. id: id,
  18099. name: "Keystroke",
  18100. value: event.target.value,
  18101. willCommit: true,
  18102. commitKey: commitKey,
  18103. selStart: event.target.selectionStart,
  18104. selEnd: event.target.selectionEnd
  18105. }
  18106. });
  18107. });
  18108. var _blurListener = blurListener;
  18109. blurListener = null;
  18110. element.addEventListener("blur", function (event) {
  18111. if (_this5._mouseState.isDown) {
  18112. var _this5$linkService$ev2;
  18113. elementData.userValue = event.target.value;
  18114. (_this5$linkService$ev2 = _this5.linkService.eventBus) === null || _this5$linkService$ev2 === void 0 ? void 0 : _this5$linkService$ev2.dispatch("dispatcheventinsandbox", {
  18115. source: _this5,
  18116. detail: {
  18117. id: id,
  18118. name: "Keystroke",
  18119. value: event.target.value,
  18120. willCommit: true,
  18121. commitKey: 1,
  18122. selStart: event.target.selectionStart,
  18123. selEnd: event.target.selectionEnd
  18124. }
  18125. });
  18126. }
  18127. _blurListener(event);
  18128. });
  18129. element.addEventListener("mousedown", function (event) {
  18130. elementData.beforeInputValue = event.target.value;
  18131. elementData.beforeInputSelectionRange = null;
  18132. });
  18133. element.addEventListener("keyup", function (event) {
  18134. if (event.target.selectionStart === event.target.selectionEnd) {
  18135. elementData.beforeInputSelectionRange = null;
  18136. }
  18137. });
  18138. element.addEventListener("select", function (event) {
  18139. elementData.beforeInputSelectionRange = [event.target.selectionStart, event.target.selectionEnd];
  18140. });
  18141. if ("Keystroke" in this.data.actions) {
  18142. element.addEventListener("input", function (event) {
  18143. var _this5$linkService$ev3;
  18144. var selStart = -1;
  18145. var selEnd = -1;
  18146. if (elementData.beforeInputSelectionRange) {
  18147. var _elementData$beforeIn = _slicedToArray(elementData.beforeInputSelectionRange, 2);
  18148. selStart = _elementData$beforeIn[0];
  18149. selEnd = _elementData$beforeIn[1];
  18150. }
  18151. (_this5$linkService$ev3 = _this5.linkService.eventBus) === null || _this5$linkService$ev3 === void 0 ? void 0 : _this5$linkService$ev3.dispatch("dispatcheventinsandbox", {
  18152. source: _this5,
  18153. detail: {
  18154. id: id,
  18155. name: "Keystroke",
  18156. value: elementData.beforeInputValue,
  18157. change: event.data,
  18158. willCommit: false,
  18159. selStart: selStart,
  18160. selEnd: selEnd
  18161. }
  18162. });
  18163. });
  18164. }
  18165. this._setEventListeners(element, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], function (event) {
  18166. return event.target.value;
  18167. });
  18168. }
  18169. }
  18170. if (blurListener) {
  18171. element.addEventListener("blur", blurListener);
  18172. }
  18173. element.disabled = this.data.readOnly;
  18174. element.name = this.data.fieldName;
  18175. if (this.data.maxLen !== null) {
  18176. element.maxLength = this.data.maxLen;
  18177. }
  18178. if (this.data.comb) {
  18179. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  18180. var combWidth = fieldWidth / this.data.maxLen;
  18181. element.classList.add("comb");
  18182. element.style.letterSpacing = "calc(".concat(combWidth, "px - 1ch)");
  18183. }
  18184. } else {
  18185. element = document.createElement("div");
  18186. element.textContent = this.data.fieldValue;
  18187. element.style.verticalAlign = "middle";
  18188. element.style.display = "table-cell";
  18189. }
  18190. this._setTextStyle(element);
  18191. this.container.appendChild(element);
  18192. return this.container;
  18193. }
  18194. }, {
  18195. key: "_setTextStyle",
  18196. value: function _setTextStyle(element) {
  18197. var TEXT_ALIGNMENT = ["left", "center", "right"];
  18198. var _this$data$defaultApp = this.data.defaultAppearanceData,
  18199. fontSize = _this$data$defaultApp.fontSize,
  18200. fontColor = _this$data$defaultApp.fontColor;
  18201. var style = element.style;
  18202. if (fontSize) {
  18203. style.fontSize = "".concat(fontSize, "px");
  18204. }
  18205. style.color = _util.Util.makeHexColor(fontColor[0], fontColor[1], fontColor[2]);
  18206. if (this.data.textAlignment !== null) {
  18207. style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  18208. }
  18209. }
  18210. }]);
  18211. return TextWidgetAnnotationElement;
  18212. }(WidgetAnnotationElement);
  18213. var CheckboxWidgetAnnotationElement = /*#__PURE__*/function (_WidgetAnnotationElem2) {
  18214. _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
  18215. var _super5 = _createSuper(CheckboxWidgetAnnotationElement);
  18216. function CheckboxWidgetAnnotationElement(parameters) {
  18217. _classCallCheck(this, CheckboxWidgetAnnotationElement);
  18218. return _super5.call(this, parameters, {
  18219. isRenderable: parameters.renderInteractiveForms
  18220. });
  18221. }
  18222. _createClass(CheckboxWidgetAnnotationElement, [{
  18223. key: "render",
  18224. value: function render() {
  18225. var storage = this.annotationStorage;
  18226. var data = this.data;
  18227. var id = data.id;
  18228. var value = storage.getOrCreateValue(id, {
  18229. value: data.fieldValue && data.fieldValue !== "Off"
  18230. }).value;
  18231. this.container.className = "buttonWidgetAnnotation checkBox";
  18232. var element = document.createElement("input");
  18233. element.disabled = data.readOnly;
  18234. element.type = "checkbox";
  18235. element.name = this.data.fieldName;
  18236. if (value) {
  18237. element.setAttribute("checked", true);
  18238. }
  18239. element.setAttribute("id", id);
  18240. element.addEventListener("change", function (event) {
  18241. var name = event.target.name;
  18242. var _iterator3 = _createForOfIteratorHelper(document.getElementsByName(name)),
  18243. _step3;
  18244. try {
  18245. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  18246. var checkbox = _step3.value;
  18247. if (checkbox !== event.target) {
  18248. checkbox.checked = false;
  18249. storage.setValue(checkbox.parentNode.getAttribute("data-annotation-id"), {
  18250. value: false
  18251. });
  18252. }
  18253. }
  18254. } catch (err) {
  18255. _iterator3.e(err);
  18256. } finally {
  18257. _iterator3.f();
  18258. }
  18259. storage.setValue(id, {
  18260. value: event.target.checked
  18261. });
  18262. });
  18263. if (this.enableScripting && this.hasJSActions) {
  18264. element.addEventListener("updatefromsandbox", function (event) {
  18265. var detail = event.detail;
  18266. var actions = {
  18267. value: function value() {
  18268. event.target.checked = detail.value !== "Off";
  18269. storage.setValue(id, {
  18270. value: event.target.checked
  18271. });
  18272. },
  18273. focus: function focus() {
  18274. setTimeout(function () {
  18275. return event.target.focus({
  18276. preventScroll: false
  18277. });
  18278. }, 0);
  18279. },
  18280. hidden: function hidden() {
  18281. event.target.style.visibility = detail.hidden ? "hidden" : "visible";
  18282. storage.setValue(id, {
  18283. hidden: detail.hidden
  18284. });
  18285. },
  18286. editable: function editable() {
  18287. event.target.disabled = !detail.editable;
  18288. }
  18289. };
  18290. Object.keys(detail).filter(function (name) {
  18291. return name in actions;
  18292. }).forEach(function (name) {
  18293. return actions[name]();
  18294. });
  18295. });
  18296. this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], function (event) {
  18297. return event.target.checked;
  18298. });
  18299. }
  18300. this.container.appendChild(element);
  18301. return this.container;
  18302. }
  18303. }]);
  18304. return CheckboxWidgetAnnotationElement;
  18305. }(WidgetAnnotationElement);
  18306. var RadioButtonWidgetAnnotationElement = /*#__PURE__*/function (_WidgetAnnotationElem3) {
  18307. _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
  18308. var _super6 = _createSuper(RadioButtonWidgetAnnotationElement);
  18309. function RadioButtonWidgetAnnotationElement(parameters) {
  18310. _classCallCheck(this, RadioButtonWidgetAnnotationElement);
  18311. return _super6.call(this, parameters, {
  18312. isRenderable: parameters.renderInteractiveForms
  18313. });
  18314. }
  18315. _createClass(RadioButtonWidgetAnnotationElement, [{
  18316. key: "render",
  18317. value: function render() {
  18318. this.container.className = "buttonWidgetAnnotation radioButton";
  18319. var storage = this.annotationStorage;
  18320. var data = this.data;
  18321. var id = data.id;
  18322. var value = storage.getOrCreateValue(id, {
  18323. value: data.fieldValue === data.buttonValue
  18324. }).value;
  18325. var element = document.createElement("input");
  18326. element.disabled = data.readOnly;
  18327. element.type = "radio";
  18328. element.name = data.fieldName;
  18329. if (value) {
  18330. element.setAttribute("checked", true);
  18331. }
  18332. element.setAttribute("pdfButtonValue", data.buttonValue);
  18333. element.setAttribute("id", id);
  18334. element.addEventListener("change", function (event) {
  18335. var target = event.target;
  18336. var _iterator4 = _createForOfIteratorHelper(document.getElementsByName(target.name)),
  18337. _step4;
  18338. try {
  18339. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  18340. var radio = _step4.value;
  18341. if (radio !== target) {
  18342. storage.setValue(radio.getAttribute("id"), {
  18343. value: false
  18344. });
  18345. }
  18346. }
  18347. } catch (err) {
  18348. _iterator4.e(err);
  18349. } finally {
  18350. _iterator4.f();
  18351. }
  18352. storage.setValue(id, {
  18353. value: target.checked
  18354. });
  18355. });
  18356. if (this.enableScripting && this.hasJSActions) {
  18357. element.addEventListener("updatefromsandbox", function (event) {
  18358. var detail = event.detail;
  18359. var actions = {
  18360. value: function value() {
  18361. var fieldValue = detail.value;
  18362. var _iterator5 = _createForOfIteratorHelper(document.getElementsByName(event.target.name)),
  18363. _step5;
  18364. try {
  18365. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  18366. var radio = _step5.value;
  18367. var radioId = radio.getAttribute("id");
  18368. if (fieldValue === radio.getAttribute("pdfButtonValue")) {
  18369. radio.setAttribute("checked", true);
  18370. storage.setValue(radioId, {
  18371. value: true
  18372. });
  18373. } else {
  18374. storage.setValue(radioId, {
  18375. value: false
  18376. });
  18377. }
  18378. }
  18379. } catch (err) {
  18380. _iterator5.e(err);
  18381. } finally {
  18382. _iterator5.f();
  18383. }
  18384. },
  18385. focus: function focus() {
  18386. setTimeout(function () {
  18387. return event.target.focus({
  18388. preventScroll: false
  18389. });
  18390. }, 0);
  18391. },
  18392. hidden: function hidden() {
  18393. event.target.style.visibility = detail.hidden ? "hidden" : "visible";
  18394. storage.setValue(id, {
  18395. hidden: detail.hidden
  18396. });
  18397. },
  18398. editable: function editable() {
  18399. event.target.disabled = !detail.editable;
  18400. }
  18401. };
  18402. Object.keys(detail).filter(function (name) {
  18403. return name in actions;
  18404. }).forEach(function (name) {
  18405. return actions[name]();
  18406. });
  18407. });
  18408. this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], function (event) {
  18409. return event.target.checked;
  18410. });
  18411. }
  18412. this.container.appendChild(element);
  18413. return this.container;
  18414. }
  18415. }]);
  18416. return RadioButtonWidgetAnnotationElement;
  18417. }(WidgetAnnotationElement);
  18418. var PushButtonWidgetAnnotationElement = /*#__PURE__*/function (_LinkAnnotationElemen) {
  18419. _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
  18420. var _super7 = _createSuper(PushButtonWidgetAnnotationElement);
  18421. function PushButtonWidgetAnnotationElement() {
  18422. _classCallCheck(this, PushButtonWidgetAnnotationElement);
  18423. return _super7.apply(this, arguments);
  18424. }
  18425. _createClass(PushButtonWidgetAnnotationElement, [{
  18426. key: "render",
  18427. value: function render() {
  18428. var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);
  18429. container.className = "buttonWidgetAnnotation pushButton";
  18430. if (this.data.alternativeText) {
  18431. container.title = this.data.alternativeText;
  18432. }
  18433. return container;
  18434. }
  18435. }]);
  18436. return PushButtonWidgetAnnotationElement;
  18437. }(LinkAnnotationElement);
  18438. var ChoiceWidgetAnnotationElement = /*#__PURE__*/function (_WidgetAnnotationElem4) {
  18439. _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
  18440. var _super8 = _createSuper(ChoiceWidgetAnnotationElement);
  18441. function ChoiceWidgetAnnotationElement(parameters) {
  18442. _classCallCheck(this, ChoiceWidgetAnnotationElement);
  18443. return _super8.call(this, parameters, {
  18444. isRenderable: parameters.renderInteractiveForms
  18445. });
  18446. }
  18447. _createClass(ChoiceWidgetAnnotationElement, [{
  18448. key: "render",
  18449. value: function render() {
  18450. var _this6 = this;
  18451. this.container.className = "choiceWidgetAnnotation";
  18452. var storage = this.annotationStorage;
  18453. var id = this.data.id;
  18454. storage.getOrCreateValue(id, {
  18455. value: this.data.fieldValue.length > 0 ? this.data.fieldValue[0] : undefined
  18456. });
  18457. var selectElement = document.createElement("select");
  18458. selectElement.disabled = this.data.readOnly;
  18459. selectElement.name = this.data.fieldName;
  18460. selectElement.setAttribute("id", id);
  18461. if (!this.data.combo) {
  18462. selectElement.size = this.data.options.length;
  18463. if (this.data.multiSelect) {
  18464. selectElement.multiple = true;
  18465. }
  18466. }
  18467. var _iterator6 = _createForOfIteratorHelper(this.data.options),
  18468. _step6;
  18469. try {
  18470. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  18471. var option = _step6.value;
  18472. var optionElement = document.createElement("option");
  18473. optionElement.textContent = option.displayValue;
  18474. optionElement.value = option.exportValue;
  18475. if (this.data.fieldValue.includes(option.exportValue)) {
  18476. optionElement.setAttribute("selected", true);
  18477. }
  18478. selectElement.appendChild(optionElement);
  18479. }
  18480. } catch (err) {
  18481. _iterator6.e(err);
  18482. } finally {
  18483. _iterator6.f();
  18484. }
  18485. function getValue(event) {
  18486. var options = event.target.options;
  18487. return options[options.selectedIndex].value;
  18488. }
  18489. if (this.enableScripting && this.hasJSActions) {
  18490. selectElement.addEventListener("updatefromsandbox", function (event) {
  18491. var detail = event.detail;
  18492. var actions = {
  18493. value: function value() {
  18494. var options = event.target.options;
  18495. var value = detail.value;
  18496. var i = options.indexOf(value);
  18497. if (i !== -1) {
  18498. options.selectedIndex = i;
  18499. storage.setValue(id, {
  18500. value: value
  18501. });
  18502. }
  18503. },
  18504. focus: function focus() {
  18505. setTimeout(function () {
  18506. return event.target.focus({
  18507. preventScroll: false
  18508. });
  18509. }, 0);
  18510. },
  18511. hidden: function hidden() {
  18512. event.target.style.visibility = detail.hidden ? "hidden" : "visible";
  18513. storage.setValue(id, {
  18514. hidden: detail.hidden
  18515. });
  18516. },
  18517. editable: function editable() {
  18518. event.target.disabled = !detail.editable;
  18519. }
  18520. };
  18521. Object.keys(detail).filter(function (name) {
  18522. return name in actions;
  18523. }).forEach(function (name) {
  18524. return actions[name]();
  18525. });
  18526. });
  18527. selectElement.addEventListener("input", function (event) {
  18528. var _this6$linkService$ev;
  18529. var value = getValue(event);
  18530. storage.setValue(id, {
  18531. value: value
  18532. });
  18533. (_this6$linkService$ev = _this6.linkService.eventBus) === null || _this6$linkService$ev === void 0 ? void 0 : _this6$linkService$ev.dispatch("dispatcheventinsandbox", {
  18534. source: _this6,
  18535. detail: {
  18536. id: id,
  18537. name: "Keystroke",
  18538. changeEx: value,
  18539. willCommit: true,
  18540. commitKey: 1,
  18541. keyDown: false
  18542. }
  18543. });
  18544. });
  18545. this._setEventListeners(selectElement, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], function (event) {
  18546. return event.target.checked;
  18547. });
  18548. } else {
  18549. selectElement.addEventListener("input", function (event) {
  18550. storage.setValue(id, {
  18551. value: getValue(event)
  18552. });
  18553. });
  18554. }
  18555. this.container.appendChild(selectElement);
  18556. return this.container;
  18557. }
  18558. }]);
  18559. return ChoiceWidgetAnnotationElement;
  18560. }(WidgetAnnotationElement);
  18561. var PopupAnnotationElement = /*#__PURE__*/function (_AnnotationElement4) {
  18562. _inherits(PopupAnnotationElement, _AnnotationElement4);
  18563. var _super9 = _createSuper(PopupAnnotationElement);
  18564. function PopupAnnotationElement(parameters) {
  18565. _classCallCheck(this, PopupAnnotationElement);
  18566. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  18567. return _super9.call(this, parameters, {
  18568. isRenderable: isRenderable
  18569. });
  18570. }
  18571. _createClass(PopupAnnotationElement, [{
  18572. key: "render",
  18573. value: function render() {
  18574. var IGNORE_TYPES = ["Line", "Square", "Circle", "PolyLine", "Polygon", "Ink"];
  18575. this.container.className = "popupAnnotation";
  18576. if (IGNORE_TYPES.includes(this.data.parentType)) {
  18577. return this.container;
  18578. }
  18579. var selector = "[data-annotation-id=\"".concat(this.data.parentId, "\"]");
  18580. var parentElements = this.layer.querySelectorAll(selector);
  18581. if (parentElements.length === 0) {
  18582. return this.container;
  18583. }
  18584. var popup = new PopupElement({
  18585. container: this.container,
  18586. trigger: Array.from(parentElements),
  18587. color: this.data.color,
  18588. title: this.data.title,
  18589. modificationDate: this.data.modificationDate,
  18590. contents: this.data.contents
  18591. });
  18592. var page = this.page;
  18593. var rect = _util.Util.normalizeRect([this.data.parentRect[0], page.view[3] - this.data.parentRect[1] + page.view[1], this.data.parentRect[2], page.view[3] - this.data.parentRect[3] + page.view[1]]);
  18594. var popupLeft = rect[0] + this.data.parentRect[2] - this.data.parentRect[0];
  18595. var popupTop = rect[1];
  18596. this.container.style.transformOrigin = "".concat(-popupLeft, "px ").concat(-popupTop, "px");
  18597. this.container.style.left = "".concat(popupLeft, "px");
  18598. this.container.style.top = "".concat(popupTop, "px");
  18599. this.container.appendChild(popup.render());
  18600. return this.container;
  18601. }
  18602. }]);
  18603. return PopupAnnotationElement;
  18604. }(AnnotationElement);
  18605. var PopupElement = /*#__PURE__*/function () {
  18606. function PopupElement(parameters) {
  18607. _classCallCheck(this, PopupElement);
  18608. this.container = parameters.container;
  18609. this.trigger = parameters.trigger;
  18610. this.color = parameters.color;
  18611. this.title = parameters.title;
  18612. this.modificationDate = parameters.modificationDate;
  18613. this.contents = parameters.contents;
  18614. this.hideWrapper = parameters.hideWrapper || false;
  18615. this.pinned = false;
  18616. }
  18617. _createClass(PopupElement, [{
  18618. key: "render",
  18619. value: function render() {
  18620. var _this7 = this;
  18621. var BACKGROUND_ENLIGHT = 0.7;
  18622. var wrapper = document.createElement("div");
  18623. wrapper.className = "popupWrapper";
  18624. this.hideElement = this.hideWrapper ? wrapper : this.container;
  18625. this.hideElement.setAttribute("hidden", true);
  18626. var popup = document.createElement("div");
  18627. popup.className = "popup";
  18628. var color = this.color;
  18629. if (color) {
  18630. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  18631. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  18632. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  18633. popup.style.backgroundColor = _util.Util.makeHexColor(r | 0, g | 0, b | 0);
  18634. }
  18635. var title = document.createElement("h1");
  18636. title.textContent = this.title;
  18637. popup.appendChild(title);
  18638. var dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
  18639. if (dateObject) {
  18640. var modificationDate = document.createElement("span");
  18641. modificationDate.textContent = "{{date}}, {{time}}";
  18642. modificationDate.dataset.l10nId = "annotation_date_string";
  18643. modificationDate.dataset.l10nArgs = JSON.stringify({
  18644. date: dateObject.toLocaleDateString(),
  18645. time: dateObject.toLocaleTimeString()
  18646. });
  18647. popup.appendChild(modificationDate);
  18648. }
  18649. var contents = this._formatContents(this.contents);
  18650. popup.appendChild(contents);
  18651. if (!Array.isArray(this.trigger)) {
  18652. this.trigger = [this.trigger];
  18653. }
  18654. this.trigger.forEach(function (element) {
  18655. element.addEventListener("click", _this7._toggle.bind(_this7));
  18656. element.addEventListener("mouseover", _this7._show.bind(_this7, false));
  18657. element.addEventListener("mouseout", _this7._hide.bind(_this7, false));
  18658. });
  18659. popup.addEventListener("click", this._hide.bind(this, true));
  18660. wrapper.appendChild(popup);
  18661. return wrapper;
  18662. }
  18663. }, {
  18664. key: "_formatContents",
  18665. value: function _formatContents(contents) {
  18666. var p = document.createElement("p");
  18667. var lines = contents.split(/(?:\r\n?|\n)/);
  18668. for (var i = 0, ii = lines.length; i < ii; ++i) {
  18669. var line = lines[i];
  18670. p.appendChild(document.createTextNode(line));
  18671. if (i < ii - 1) {
  18672. p.appendChild(document.createElement("br"));
  18673. }
  18674. }
  18675. return p;
  18676. }
  18677. }, {
  18678. key: "_toggle",
  18679. value: function _toggle() {
  18680. if (this.pinned) {
  18681. this._hide(true);
  18682. } else {
  18683. this._show(true);
  18684. }
  18685. }
  18686. }, {
  18687. key: "_show",
  18688. value: function _show() {
  18689. var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  18690. if (pin) {
  18691. this.pinned = true;
  18692. }
  18693. if (this.hideElement.hasAttribute("hidden")) {
  18694. this.hideElement.removeAttribute("hidden");
  18695. this.container.style.zIndex += 1;
  18696. }
  18697. }
  18698. }, {
  18699. key: "_hide",
  18700. value: function _hide() {
  18701. var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  18702. if (unpin) {
  18703. this.pinned = false;
  18704. }
  18705. if (!this.hideElement.hasAttribute("hidden") && !this.pinned) {
  18706. this.hideElement.setAttribute("hidden", true);
  18707. this.container.style.zIndex -= 1;
  18708. }
  18709. }
  18710. }]);
  18711. return PopupElement;
  18712. }();
  18713. var FreeTextAnnotationElement = /*#__PURE__*/function (_AnnotationElement5) {
  18714. _inherits(FreeTextAnnotationElement, _AnnotationElement5);
  18715. var _super10 = _createSuper(FreeTextAnnotationElement);
  18716. function FreeTextAnnotationElement(parameters) {
  18717. _classCallCheck(this, FreeTextAnnotationElement);
  18718. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18719. return _super10.call(this, parameters, {
  18720. isRenderable: isRenderable,
  18721. ignoreBorder: true
  18722. });
  18723. }
  18724. _createClass(FreeTextAnnotationElement, [{
  18725. key: "render",
  18726. value: function render() {
  18727. this.container.className = "freeTextAnnotation";
  18728. if (!this.data.hasPopup) {
  18729. this._createPopup(null, this.data);
  18730. }
  18731. return this.container;
  18732. }
  18733. }]);
  18734. return FreeTextAnnotationElement;
  18735. }(AnnotationElement);
  18736. var LineAnnotationElement = /*#__PURE__*/function (_AnnotationElement6) {
  18737. _inherits(LineAnnotationElement, _AnnotationElement6);
  18738. var _super11 = _createSuper(LineAnnotationElement);
  18739. function LineAnnotationElement(parameters) {
  18740. _classCallCheck(this, LineAnnotationElement);
  18741. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18742. return _super11.call(this, parameters, {
  18743. isRenderable: isRenderable,
  18744. ignoreBorder: true
  18745. });
  18746. }
  18747. _createClass(LineAnnotationElement, [{
  18748. key: "render",
  18749. value: function render() {
  18750. this.container.className = "lineAnnotation";
  18751. var data = this.data;
  18752. var width = data.rect[2] - data.rect[0];
  18753. var height = data.rect[3] - data.rect[1];
  18754. var svg = this.svgFactory.create(width, height);
  18755. var line = this.svgFactory.createElement("svg:line");
  18756. line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
  18757. line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
  18758. line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
  18759. line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
  18760. line.setAttribute("stroke-width", data.borderStyle.width || 1);
  18761. line.setAttribute("stroke", "transparent");
  18762. svg.appendChild(line);
  18763. this.container.append(svg);
  18764. this._createPopup(line, data);
  18765. return this.container;
  18766. }
  18767. }]);
  18768. return LineAnnotationElement;
  18769. }(AnnotationElement);
  18770. var SquareAnnotationElement = /*#__PURE__*/function (_AnnotationElement7) {
  18771. _inherits(SquareAnnotationElement, _AnnotationElement7);
  18772. var _super12 = _createSuper(SquareAnnotationElement);
  18773. function SquareAnnotationElement(parameters) {
  18774. _classCallCheck(this, SquareAnnotationElement);
  18775. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18776. return _super12.call(this, parameters, {
  18777. isRenderable: isRenderable,
  18778. ignoreBorder: true
  18779. });
  18780. }
  18781. _createClass(SquareAnnotationElement, [{
  18782. key: "render",
  18783. value: function render() {
  18784. this.container.className = "squareAnnotation";
  18785. var data = this.data;
  18786. var width = data.rect[2] - data.rect[0];
  18787. var height = data.rect[3] - data.rect[1];
  18788. var svg = this.svgFactory.create(width, height);
  18789. var borderWidth = data.borderStyle.width;
  18790. var square = this.svgFactory.createElement("svg:rect");
  18791. square.setAttribute("x", borderWidth / 2);
  18792. square.setAttribute("y", borderWidth / 2);
  18793. square.setAttribute("width", width - borderWidth);
  18794. square.setAttribute("height", height - borderWidth);
  18795. square.setAttribute("stroke-width", borderWidth || 1);
  18796. square.setAttribute("stroke", "transparent");
  18797. square.setAttribute("fill", "none");
  18798. svg.appendChild(square);
  18799. this.container.append(svg);
  18800. this._createPopup(square, data);
  18801. return this.container;
  18802. }
  18803. }]);
  18804. return SquareAnnotationElement;
  18805. }(AnnotationElement);
  18806. var CircleAnnotationElement = /*#__PURE__*/function (_AnnotationElement8) {
  18807. _inherits(CircleAnnotationElement, _AnnotationElement8);
  18808. var _super13 = _createSuper(CircleAnnotationElement);
  18809. function CircleAnnotationElement(parameters) {
  18810. _classCallCheck(this, CircleAnnotationElement);
  18811. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18812. return _super13.call(this, parameters, {
  18813. isRenderable: isRenderable,
  18814. ignoreBorder: true
  18815. });
  18816. }
  18817. _createClass(CircleAnnotationElement, [{
  18818. key: "render",
  18819. value: function render() {
  18820. this.container.className = "circleAnnotation";
  18821. var data = this.data;
  18822. var width = data.rect[2] - data.rect[0];
  18823. var height = data.rect[3] - data.rect[1];
  18824. var svg = this.svgFactory.create(width, height);
  18825. var borderWidth = data.borderStyle.width;
  18826. var circle = this.svgFactory.createElement("svg:ellipse");
  18827. circle.setAttribute("cx", width / 2);
  18828. circle.setAttribute("cy", height / 2);
  18829. circle.setAttribute("rx", width / 2 - borderWidth / 2);
  18830. circle.setAttribute("ry", height / 2 - borderWidth / 2);
  18831. circle.setAttribute("stroke-width", borderWidth || 1);
  18832. circle.setAttribute("stroke", "transparent");
  18833. circle.setAttribute("fill", "none");
  18834. svg.appendChild(circle);
  18835. this.container.append(svg);
  18836. this._createPopup(circle, data);
  18837. return this.container;
  18838. }
  18839. }]);
  18840. return CircleAnnotationElement;
  18841. }(AnnotationElement);
  18842. var PolylineAnnotationElement = /*#__PURE__*/function (_AnnotationElement9) {
  18843. _inherits(PolylineAnnotationElement, _AnnotationElement9);
  18844. var _super14 = _createSuper(PolylineAnnotationElement);
  18845. function PolylineAnnotationElement(parameters) {
  18846. var _this8;
  18847. _classCallCheck(this, PolylineAnnotationElement);
  18848. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18849. _this8 = _super14.call(this, parameters, {
  18850. isRenderable: isRenderable,
  18851. ignoreBorder: true
  18852. });
  18853. _this8.containerClassName = "polylineAnnotation";
  18854. _this8.svgElementName = "svg:polyline";
  18855. return _this8;
  18856. }
  18857. _createClass(PolylineAnnotationElement, [{
  18858. key: "render",
  18859. value: function render() {
  18860. this.container.className = this.containerClassName;
  18861. var data = this.data;
  18862. var width = data.rect[2] - data.rect[0];
  18863. var height = data.rect[3] - data.rect[1];
  18864. var svg = this.svgFactory.create(width, height);
  18865. var points = [];
  18866. var _iterator7 = _createForOfIteratorHelper(data.vertices),
  18867. _step7;
  18868. try {
  18869. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  18870. var coordinate = _step7.value;
  18871. var x = coordinate.x - data.rect[0];
  18872. var y = data.rect[3] - coordinate.y;
  18873. points.push(x + "," + y);
  18874. }
  18875. } catch (err) {
  18876. _iterator7.e(err);
  18877. } finally {
  18878. _iterator7.f();
  18879. }
  18880. points = points.join(" ");
  18881. var polyline = this.svgFactory.createElement(this.svgElementName);
  18882. polyline.setAttribute("points", points);
  18883. polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
  18884. polyline.setAttribute("stroke", "transparent");
  18885. polyline.setAttribute("fill", "none");
  18886. svg.appendChild(polyline);
  18887. this.container.append(svg);
  18888. this._createPopup(polyline, data);
  18889. return this.container;
  18890. }
  18891. }]);
  18892. return PolylineAnnotationElement;
  18893. }(AnnotationElement);
  18894. var PolygonAnnotationElement = /*#__PURE__*/function (_PolylineAnnotationEl) {
  18895. _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
  18896. var _super15 = _createSuper(PolygonAnnotationElement);
  18897. function PolygonAnnotationElement(parameters) {
  18898. var _this9;
  18899. _classCallCheck(this, PolygonAnnotationElement);
  18900. _this9 = _super15.call(this, parameters);
  18901. _this9.containerClassName = "polygonAnnotation";
  18902. _this9.svgElementName = "svg:polygon";
  18903. return _this9;
  18904. }
  18905. return PolygonAnnotationElement;
  18906. }(PolylineAnnotationElement);
  18907. var CaretAnnotationElement = /*#__PURE__*/function (_AnnotationElement10) {
  18908. _inherits(CaretAnnotationElement, _AnnotationElement10);
  18909. var _super16 = _createSuper(CaretAnnotationElement);
  18910. function CaretAnnotationElement(parameters) {
  18911. _classCallCheck(this, CaretAnnotationElement);
  18912. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18913. return _super16.call(this, parameters, {
  18914. isRenderable: isRenderable,
  18915. ignoreBorder: true
  18916. });
  18917. }
  18918. _createClass(CaretAnnotationElement, [{
  18919. key: "render",
  18920. value: function render() {
  18921. this.container.className = "caretAnnotation";
  18922. if (!this.data.hasPopup) {
  18923. this._createPopup(null, this.data);
  18924. }
  18925. return this.container;
  18926. }
  18927. }]);
  18928. return CaretAnnotationElement;
  18929. }(AnnotationElement);
  18930. var InkAnnotationElement = /*#__PURE__*/function (_AnnotationElement11) {
  18931. _inherits(InkAnnotationElement, _AnnotationElement11);
  18932. var _super17 = _createSuper(InkAnnotationElement);
  18933. function InkAnnotationElement(parameters) {
  18934. var _this10;
  18935. _classCallCheck(this, InkAnnotationElement);
  18936. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18937. _this10 = _super17.call(this, parameters, {
  18938. isRenderable: isRenderable,
  18939. ignoreBorder: true
  18940. });
  18941. _this10.containerClassName = "inkAnnotation";
  18942. _this10.svgElementName = "svg:polyline";
  18943. return _this10;
  18944. }
  18945. _createClass(InkAnnotationElement, [{
  18946. key: "render",
  18947. value: function render() {
  18948. this.container.className = this.containerClassName;
  18949. var data = this.data;
  18950. var width = data.rect[2] - data.rect[0];
  18951. var height = data.rect[3] - data.rect[1];
  18952. var svg = this.svgFactory.create(width, height);
  18953. var _iterator8 = _createForOfIteratorHelper(data.inkLists),
  18954. _step8;
  18955. try {
  18956. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  18957. var inkList = _step8.value;
  18958. var points = [];
  18959. var _iterator9 = _createForOfIteratorHelper(inkList),
  18960. _step9;
  18961. try {
  18962. for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
  18963. var coordinate = _step9.value;
  18964. var x = coordinate.x - data.rect[0];
  18965. var y = data.rect[3] - coordinate.y;
  18966. points.push("".concat(x, ",").concat(y));
  18967. }
  18968. } catch (err) {
  18969. _iterator9.e(err);
  18970. } finally {
  18971. _iterator9.f();
  18972. }
  18973. points = points.join(" ");
  18974. var polyline = this.svgFactory.createElement(this.svgElementName);
  18975. polyline.setAttribute("points", points);
  18976. polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
  18977. polyline.setAttribute("stroke", "transparent");
  18978. polyline.setAttribute("fill", "none");
  18979. this._createPopup(polyline, data);
  18980. svg.appendChild(polyline);
  18981. }
  18982. } catch (err) {
  18983. _iterator8.e(err);
  18984. } finally {
  18985. _iterator8.f();
  18986. }
  18987. this.container.append(svg);
  18988. return this.container;
  18989. }
  18990. }]);
  18991. return InkAnnotationElement;
  18992. }(AnnotationElement);
  18993. var HighlightAnnotationElement = /*#__PURE__*/function (_AnnotationElement12) {
  18994. _inherits(HighlightAnnotationElement, _AnnotationElement12);
  18995. var _super18 = _createSuper(HighlightAnnotationElement);
  18996. function HighlightAnnotationElement(parameters) {
  18997. _classCallCheck(this, HighlightAnnotationElement);
  18998. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18999. return _super18.call(this, parameters, {
  19000. isRenderable: isRenderable,
  19001. ignoreBorder: true,
  19002. createQuadrilaterals: true
  19003. });
  19004. }
  19005. _createClass(HighlightAnnotationElement, [{
  19006. key: "render",
  19007. value: function render() {
  19008. if (!this.data.hasPopup) {
  19009. this._createPopup(null, this.data);
  19010. }
  19011. if (this.quadrilaterals) {
  19012. return this._renderQuadrilaterals("highlightAnnotation");
  19013. }
  19014. this.container.className = "highlightAnnotation";
  19015. return this.container;
  19016. }
  19017. }]);
  19018. return HighlightAnnotationElement;
  19019. }(AnnotationElement);
  19020. var UnderlineAnnotationElement = /*#__PURE__*/function (_AnnotationElement13) {
  19021. _inherits(UnderlineAnnotationElement, _AnnotationElement13);
  19022. var _super19 = _createSuper(UnderlineAnnotationElement);
  19023. function UnderlineAnnotationElement(parameters) {
  19024. _classCallCheck(this, UnderlineAnnotationElement);
  19025. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19026. return _super19.call(this, parameters, {
  19027. isRenderable: isRenderable,
  19028. ignoreBorder: true,
  19029. createQuadrilaterals: true
  19030. });
  19031. }
  19032. _createClass(UnderlineAnnotationElement, [{
  19033. key: "render",
  19034. value: function render() {
  19035. if (!this.data.hasPopup) {
  19036. this._createPopup(null, this.data);
  19037. }
  19038. if (this.quadrilaterals) {
  19039. return this._renderQuadrilaterals("underlineAnnotation");
  19040. }
  19041. this.container.className = "underlineAnnotation";
  19042. return this.container;
  19043. }
  19044. }]);
  19045. return UnderlineAnnotationElement;
  19046. }(AnnotationElement);
  19047. var SquigglyAnnotationElement = /*#__PURE__*/function (_AnnotationElement14) {
  19048. _inherits(SquigglyAnnotationElement, _AnnotationElement14);
  19049. var _super20 = _createSuper(SquigglyAnnotationElement);
  19050. function SquigglyAnnotationElement(parameters) {
  19051. _classCallCheck(this, SquigglyAnnotationElement);
  19052. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19053. return _super20.call(this, parameters, {
  19054. isRenderable: isRenderable,
  19055. ignoreBorder: true,
  19056. createQuadrilaterals: true
  19057. });
  19058. }
  19059. _createClass(SquigglyAnnotationElement, [{
  19060. key: "render",
  19061. value: function render() {
  19062. if (!this.data.hasPopup) {
  19063. this._createPopup(null, this.data);
  19064. }
  19065. if (this.quadrilaterals) {
  19066. return this._renderQuadrilaterals("squigglyAnnotation");
  19067. }
  19068. this.container.className = "squigglyAnnotation";
  19069. return this.container;
  19070. }
  19071. }]);
  19072. return SquigglyAnnotationElement;
  19073. }(AnnotationElement);
  19074. var StrikeOutAnnotationElement = /*#__PURE__*/function (_AnnotationElement15) {
  19075. _inherits(StrikeOutAnnotationElement, _AnnotationElement15);
  19076. var _super21 = _createSuper(StrikeOutAnnotationElement);
  19077. function StrikeOutAnnotationElement(parameters) {
  19078. _classCallCheck(this, StrikeOutAnnotationElement);
  19079. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19080. return _super21.call(this, parameters, {
  19081. isRenderable: isRenderable,
  19082. ignoreBorder: true,
  19083. createQuadrilaterals: true
  19084. });
  19085. }
  19086. _createClass(StrikeOutAnnotationElement, [{
  19087. key: "render",
  19088. value: function render() {
  19089. if (!this.data.hasPopup) {
  19090. this._createPopup(null, this.data);
  19091. }
  19092. if (this.quadrilaterals) {
  19093. return this._renderQuadrilaterals("strikeoutAnnotation");
  19094. }
  19095. this.container.className = "strikeoutAnnotation";
  19096. return this.container;
  19097. }
  19098. }]);
  19099. return StrikeOutAnnotationElement;
  19100. }(AnnotationElement);
  19101. var StampAnnotationElement = /*#__PURE__*/function (_AnnotationElement16) {
  19102. _inherits(StampAnnotationElement, _AnnotationElement16);
  19103. var _super22 = _createSuper(StampAnnotationElement);
  19104. function StampAnnotationElement(parameters) {
  19105. _classCallCheck(this, StampAnnotationElement);
  19106. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19107. return _super22.call(this, parameters, {
  19108. isRenderable: isRenderable,
  19109. ignoreBorder: true
  19110. });
  19111. }
  19112. _createClass(StampAnnotationElement, [{
  19113. key: "render",
  19114. value: function render() {
  19115. this.container.className = "stampAnnotation";
  19116. if (!this.data.hasPopup) {
  19117. this._createPopup(null, this.data);
  19118. }
  19119. return this.container;
  19120. }
  19121. }]);
  19122. return StampAnnotationElement;
  19123. }(AnnotationElement);
  19124. var FileAttachmentAnnotationElement = /*#__PURE__*/function (_AnnotationElement17) {
  19125. _inherits(FileAttachmentAnnotationElement, _AnnotationElement17);
  19126. var _super23 = _createSuper(FileAttachmentAnnotationElement);
  19127. function FileAttachmentAnnotationElement(parameters) {
  19128. var _this11$linkService$e;
  19129. var _this11;
  19130. _classCallCheck(this, FileAttachmentAnnotationElement);
  19131. _this11 = _super23.call(this, parameters, {
  19132. isRenderable: true
  19133. });
  19134. var _this11$data$file = _this11.data.file,
  19135. filename = _this11$data$file.filename,
  19136. content = _this11$data$file.content;
  19137. _this11.filename = (0, _display_utils.getFilenameFromUrl)(filename);
  19138. _this11.content = content;
  19139. (_this11$linkService$e = _this11.linkService.eventBus) === null || _this11$linkService$e === void 0 ? void 0 : _this11$linkService$e.dispatch("fileattachmentannotation", {
  19140. source: _assertThisInitialized(_this11),
  19141. id: (0, _util.stringToPDFString)(filename),
  19142. filename: filename,
  19143. content: content
  19144. });
  19145. return _this11;
  19146. }
  19147. _createClass(FileAttachmentAnnotationElement, [{
  19148. key: "render",
  19149. value: function render() {
  19150. this.container.className = "fileAttachmentAnnotation";
  19151. var trigger = document.createElement("div");
  19152. trigger.style.height = this.container.style.height;
  19153. trigger.style.width = this.container.style.width;
  19154. trigger.addEventListener("dblclick", this._download.bind(this));
  19155. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  19156. this._createPopup(trigger, this.data);
  19157. }
  19158. this.container.appendChild(trigger);
  19159. return this.container;
  19160. }
  19161. }, {
  19162. key: "_download",
  19163. value: function _download() {
  19164. if (!this.downloadManager) {
  19165. (0, _util.warn)("Download cannot be started due to unavailable download manager");
  19166. return;
  19167. }
  19168. this.downloadManager.downloadData(this.content, this.filename, "");
  19169. }
  19170. }]);
  19171. return FileAttachmentAnnotationElement;
  19172. }(AnnotationElement);
  19173. var AnnotationLayer = /*#__PURE__*/function () {
  19174. function AnnotationLayer() {
  19175. _classCallCheck(this, AnnotationLayer);
  19176. }
  19177. _createClass(AnnotationLayer, null, [{
  19178. key: "render",
  19179. value: function render(parameters) {
  19180. var sortedAnnotations = [],
  19181. popupAnnotations = [];
  19182. var _iterator10 = _createForOfIteratorHelper(parameters.annotations),
  19183. _step10;
  19184. try {
  19185. for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
  19186. var _data = _step10.value;
  19187. if (!_data) {
  19188. continue;
  19189. }
  19190. if (_data.annotationType === _util.AnnotationType.POPUP) {
  19191. popupAnnotations.push(_data);
  19192. continue;
  19193. }
  19194. sortedAnnotations.push(_data);
  19195. }
  19196. } catch (err) {
  19197. _iterator10.e(err);
  19198. } finally {
  19199. _iterator10.f();
  19200. }
  19201. if (popupAnnotations.length) {
  19202. sortedAnnotations.push.apply(sortedAnnotations, popupAnnotations);
  19203. }
  19204. for (var _i2 = 0, _sortedAnnotations = sortedAnnotations; _i2 < _sortedAnnotations.length; _i2++) {
  19205. var data = _sortedAnnotations[_i2];
  19206. var element = AnnotationElementFactory.create({
  19207. data: data,
  19208. layer: parameters.div,
  19209. page: parameters.page,
  19210. viewport: parameters.viewport,
  19211. linkService: parameters.linkService,
  19212. downloadManager: parameters.downloadManager,
  19213. imageResourcesPath: parameters.imageResourcesPath || "",
  19214. renderInteractiveForms: typeof parameters.renderInteractiveForms === "boolean" ? parameters.renderInteractiveForms : true,
  19215. svgFactory: new _display_utils.DOMSVGFactory(),
  19216. annotationStorage: parameters.annotationStorage || new _annotation_storage.AnnotationStorage(),
  19217. enableScripting: parameters.enableScripting,
  19218. hasJSActions: parameters.hasJSActions,
  19219. mouseState: parameters.mouseState || {
  19220. isDown: false
  19221. }
  19222. });
  19223. if (element.isRenderable) {
  19224. var rendered = element.render();
  19225. if (data.hidden) {
  19226. rendered.style.visibility = "hidden";
  19227. }
  19228. if (Array.isArray(rendered)) {
  19229. var _iterator11 = _createForOfIteratorHelper(rendered),
  19230. _step11;
  19231. try {
  19232. for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
  19233. var renderedElement = _step11.value;
  19234. parameters.div.appendChild(renderedElement);
  19235. }
  19236. } catch (err) {
  19237. _iterator11.e(err);
  19238. } finally {
  19239. _iterator11.f();
  19240. }
  19241. } else {
  19242. if (element instanceof PopupAnnotationElement) {
  19243. parameters.div.prepend(rendered);
  19244. } else {
  19245. parameters.div.appendChild(rendered);
  19246. }
  19247. }
  19248. }
  19249. }
  19250. }
  19251. }, {
  19252. key: "update",
  19253. value: function update(parameters) {
  19254. var transform = "matrix(".concat(parameters.viewport.transform.join(","), ")");
  19255. var _iterator12 = _createForOfIteratorHelper(parameters.annotations),
  19256. _step12;
  19257. try {
  19258. for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
  19259. var data = _step12.value;
  19260. var elements = parameters.div.querySelectorAll("[data-annotation-id=\"".concat(data.id, "\"]"));
  19261. if (elements) {
  19262. elements.forEach(function (element) {
  19263. element.style.transform = transform;
  19264. });
  19265. }
  19266. }
  19267. } catch (err) {
  19268. _iterator12.e(err);
  19269. } finally {
  19270. _iterator12.f();
  19271. }
  19272. parameters.div.removeAttribute("hidden");
  19273. }
  19274. }]);
  19275. return AnnotationLayer;
  19276. }();
  19277. exports.AnnotationLayer = AnnotationLayer;
  19278. /***/ }),
  19279. /* 150 */
  19280. /***/ ((__unused_webpack_module, exports) => {
  19281. "use strict";
  19282. Object.defineProperty(exports, "__esModule", ({
  19283. value: true
  19284. }));
  19285. exports.ColorConverters = void 0;
  19286. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  19287. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  19288. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  19289. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  19290. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  19291. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  19292. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19293. 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); } }
  19294. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  19295. function makeColorComp(n) {
  19296. return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
  19297. }
  19298. var ColorConverters = /*#__PURE__*/function () {
  19299. function ColorConverters() {
  19300. _classCallCheck(this, ColorConverters);
  19301. }
  19302. _createClass(ColorConverters, null, [{
  19303. key: "CMYK_G",
  19304. value: function CMYK_G(_ref) {
  19305. var _ref2 = _slicedToArray(_ref, 4),
  19306. c = _ref2[0],
  19307. y = _ref2[1],
  19308. m = _ref2[2],
  19309. k = _ref2[3];
  19310. return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
  19311. }
  19312. }, {
  19313. key: "G_CMYK",
  19314. value: function G_CMYK(_ref3) {
  19315. var _ref4 = _slicedToArray(_ref3, 1),
  19316. g = _ref4[0];
  19317. return ["CMYK", 0, 0, 0, 1 - g];
  19318. }
  19319. }, {
  19320. key: "G_RGB",
  19321. value: function G_RGB(_ref5) {
  19322. var _ref6 = _slicedToArray(_ref5, 1),
  19323. g = _ref6[0];
  19324. return ["RGB", g, g, g];
  19325. }
  19326. }, {
  19327. key: "G_HTML",
  19328. value: function G_HTML(_ref7) {
  19329. var _ref8 = _slicedToArray(_ref7, 1),
  19330. g = _ref8[0];
  19331. var G = makeColorComp(g);
  19332. return "#".concat(G).concat(G).concat(G);
  19333. }
  19334. }, {
  19335. key: "RGB_G",
  19336. value: function RGB_G(_ref9) {
  19337. var _ref10 = _slicedToArray(_ref9, 3),
  19338. r = _ref10[0],
  19339. g = _ref10[1],
  19340. b = _ref10[2];
  19341. return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
  19342. }
  19343. }, {
  19344. key: "RGB_HTML",
  19345. value: function RGB_HTML(_ref11) {
  19346. var _ref12 = _slicedToArray(_ref11, 3),
  19347. r = _ref12[0],
  19348. g = _ref12[1],
  19349. b = _ref12[2];
  19350. var R = makeColorComp(r);
  19351. var G = makeColorComp(g);
  19352. var B = makeColorComp(b);
  19353. return "#".concat(R).concat(G).concat(B);
  19354. }
  19355. }, {
  19356. key: "T_HTML",
  19357. value: function T_HTML() {
  19358. return "#00000000";
  19359. }
  19360. }, {
  19361. key: "CMYK_RGB",
  19362. value: function CMYK_RGB(_ref13) {
  19363. var _ref14 = _slicedToArray(_ref13, 4),
  19364. c = _ref14[0],
  19365. y = _ref14[1],
  19366. m = _ref14[2],
  19367. k = _ref14[3];
  19368. return ["RGB", 1 - Math.min(1, c + k), 1 - Math.min(1, m + k), 1 - Math.min(1, y + k)];
  19369. }
  19370. }, {
  19371. key: "CMYK_HTML",
  19372. value: function CMYK_HTML(components) {
  19373. return this.RGB_HTML(this.CMYK_RGB(components));
  19374. }
  19375. }, {
  19376. key: "RGB_CMYK",
  19377. value: function RGB_CMYK(_ref15) {
  19378. var _ref16 = _slicedToArray(_ref15, 3),
  19379. r = _ref16[0],
  19380. g = _ref16[1],
  19381. b = _ref16[2];
  19382. var c = 1 - r;
  19383. var m = 1 - g;
  19384. var y = 1 - b;
  19385. var k = Math.min(c, m, y);
  19386. return ["CMYK", c, m, y, k];
  19387. }
  19388. }]);
  19389. return ColorConverters;
  19390. }();
  19391. exports.ColorConverters = ColorConverters;
  19392. /***/ }),
  19393. /* 151 */
  19394. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  19395. "use strict";
  19396. Object.defineProperty(exports, "__esModule", ({
  19397. value: true
  19398. }));
  19399. exports.renderTextLayer = void 0;
  19400. var _util = __w_pdfjs_require__(4);
  19401. var renderTextLayer = function renderTextLayerClosure() {
  19402. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  19403. var NonWhitespaceRegexp = /\S/;
  19404. function isAllWhitespace(str) {
  19405. return !NonWhitespaceRegexp.test(str);
  19406. }
  19407. function appendText(task, geom, styles) {
  19408. var textDiv = document.createElement("span");
  19409. var textDivProperties = {
  19410. angle: 0,
  19411. canvasWidth: 0,
  19412. isWhitespace: false,
  19413. originalTransform: null,
  19414. paddingBottom: 0,
  19415. paddingLeft: 0,
  19416. paddingRight: 0,
  19417. paddingTop: 0,
  19418. scale: 1
  19419. };
  19420. task._textDivs.push(textDiv);
  19421. if (isAllWhitespace(geom.str)) {
  19422. textDivProperties.isWhitespace = true;
  19423. task._textDivProperties.set(textDiv, textDivProperties);
  19424. return;
  19425. }
  19426. var tx = _util.Util.transform(task._viewport.transform, geom.transform);
  19427. var angle = Math.atan2(tx[1], tx[0]);
  19428. var style = styles[geom.fontName];
  19429. if (style.vertical) {
  19430. angle += Math.PI / 2;
  19431. }
  19432. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  19433. var fontAscent = fontHeight;
  19434. if (style.ascent) {
  19435. fontAscent = style.ascent * fontAscent;
  19436. } else if (style.descent) {
  19437. fontAscent = (1 + style.descent) * fontAscent;
  19438. }
  19439. var left, top;
  19440. if (angle === 0) {
  19441. left = tx[4];
  19442. top = tx[5] - fontAscent;
  19443. } else {
  19444. left = tx[4] + fontAscent * Math.sin(angle);
  19445. top = tx[5] - fontAscent * Math.cos(angle);
  19446. }
  19447. textDiv.style.left = "".concat(left, "px");
  19448. textDiv.style.top = "".concat(top, "px");
  19449. textDiv.style.fontSize = "".concat(fontHeight, "px");
  19450. textDiv.style.fontFamily = style.fontFamily;
  19451. textDiv.textContent = geom.str;
  19452. if (task._fontInspectorEnabled) {
  19453. textDiv.dataset.fontName = geom.fontName;
  19454. }
  19455. if (angle !== 0) {
  19456. textDivProperties.angle = angle * (180 / Math.PI);
  19457. }
  19458. var shouldScaleText = false;
  19459. if (geom.str.length > 1) {
  19460. shouldScaleText = true;
  19461. } else if (geom.transform[0] !== geom.transform[3]) {
  19462. var absScaleX = Math.abs(geom.transform[0]),
  19463. absScaleY = Math.abs(geom.transform[3]);
  19464. if (absScaleX !== absScaleY && Math.max(absScaleX, absScaleY) / Math.min(absScaleX, absScaleY) > 1.5) {
  19465. shouldScaleText = true;
  19466. }
  19467. }
  19468. if (shouldScaleText) {
  19469. if (style.vertical) {
  19470. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  19471. } else {
  19472. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  19473. }
  19474. }
  19475. task._textDivProperties.set(textDiv, textDivProperties);
  19476. if (task._textContentStream) {
  19477. task._layoutText(textDiv);
  19478. }
  19479. if (task._enhanceTextSelection) {
  19480. var angleCos = 1,
  19481. angleSin = 0;
  19482. if (angle !== 0) {
  19483. angleCos = Math.cos(angle);
  19484. angleSin = Math.sin(angle);
  19485. }
  19486. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  19487. var divHeight = fontHeight;
  19488. var m, b;
  19489. if (angle !== 0) {
  19490. m = [angleCos, angleSin, -angleSin, angleCos, left, top];
  19491. b = _util.Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
  19492. } else {
  19493. b = [left, top, left + divWidth, top + divHeight];
  19494. }
  19495. task._bounds.push({
  19496. left: b[0],
  19497. top: b[1],
  19498. right: b[2],
  19499. bottom: b[3],
  19500. div: textDiv,
  19501. size: [divWidth, divHeight],
  19502. m: m
  19503. });
  19504. }
  19505. }
  19506. function render(task) {
  19507. if (task._canceled) {
  19508. return;
  19509. }
  19510. var textDivs = task._textDivs;
  19511. var capability = task._capability;
  19512. var textDivsLength = textDivs.length;
  19513. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  19514. task._renderingDone = true;
  19515. capability.resolve();
  19516. return;
  19517. }
  19518. if (!task._textContentStream) {
  19519. for (var i = 0; i < textDivsLength; i++) {
  19520. task._layoutText(textDivs[i]);
  19521. }
  19522. }
  19523. task._renderingDone = true;
  19524. capability.resolve();
  19525. }
  19526. function findPositiveMin(ts, offset, count) {
  19527. var result = 0;
  19528. for (var i = 0; i < count; i++) {
  19529. var t = ts[offset++];
  19530. if (t > 0) {
  19531. result = result ? Math.min(t, result) : t;
  19532. }
  19533. }
  19534. return result;
  19535. }
  19536. function expand(task) {
  19537. var bounds = task._bounds;
  19538. var viewport = task._viewport;
  19539. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  19540. var _loop = function _loop(i) {
  19541. var div = bounds[i].div;
  19542. var divProperties = task._textDivProperties.get(div);
  19543. if (divProperties.angle === 0) {
  19544. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  19545. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  19546. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  19547. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  19548. task._textDivProperties.set(div, divProperties);
  19549. return "continue";
  19550. }
  19551. var e = expanded[i],
  19552. b = bounds[i];
  19553. var m = b.m,
  19554. c = m[0],
  19555. s = m[1];
  19556. var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
  19557. var ts = new Float64Array(64);
  19558. points.forEach(function (p, j) {
  19559. var t = _util.Util.applyTransform(p, m);
  19560. ts[j + 0] = c && (e.left - t[0]) / c;
  19561. ts[j + 4] = s && (e.top - t[1]) / s;
  19562. ts[j + 8] = c && (e.right - t[0]) / c;
  19563. ts[j + 12] = s && (e.bottom - t[1]) / s;
  19564. ts[j + 16] = s && (e.left - t[0]) / -s;
  19565. ts[j + 20] = c && (e.top - t[1]) / c;
  19566. ts[j + 24] = s && (e.right - t[0]) / -s;
  19567. ts[j + 28] = c && (e.bottom - t[1]) / c;
  19568. ts[j + 32] = c && (e.left - t[0]) / -c;
  19569. ts[j + 36] = s && (e.top - t[1]) / -s;
  19570. ts[j + 40] = c && (e.right - t[0]) / -c;
  19571. ts[j + 44] = s && (e.bottom - t[1]) / -s;
  19572. ts[j + 48] = s && (e.left - t[0]) / s;
  19573. ts[j + 52] = c && (e.top - t[1]) / -c;
  19574. ts[j + 56] = s && (e.right - t[0]) / s;
  19575. ts[j + 60] = c && (e.bottom - t[1]) / -c;
  19576. });
  19577. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  19578. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  19579. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  19580. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  19581. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  19582. task._textDivProperties.set(div, divProperties);
  19583. };
  19584. for (var i = 0; i < expanded.length; i++) {
  19585. var _ret = _loop(i);
  19586. if (_ret === "continue") continue;
  19587. }
  19588. }
  19589. function expandBounds(width, height, boxes) {
  19590. var bounds = boxes.map(function (box, i) {
  19591. return {
  19592. x1: box.left,
  19593. y1: box.top,
  19594. x2: box.right,
  19595. y2: box.bottom,
  19596. index: i,
  19597. x1New: undefined,
  19598. x2New: undefined
  19599. };
  19600. });
  19601. expandBoundsLTR(width, bounds);
  19602. var expanded = new Array(boxes.length);
  19603. bounds.forEach(function (b) {
  19604. var i = b.index;
  19605. expanded[i] = {
  19606. left: b.x1New,
  19607. top: 0,
  19608. right: b.x2New,
  19609. bottom: 0
  19610. };
  19611. });
  19612. boxes.map(function (box, i) {
  19613. var e = expanded[i],
  19614. b = bounds[i];
  19615. b.x1 = box.top;
  19616. b.y1 = width - e.right;
  19617. b.x2 = box.bottom;
  19618. b.y2 = width - e.left;
  19619. b.index = i;
  19620. b.x1New = undefined;
  19621. b.x2New = undefined;
  19622. });
  19623. expandBoundsLTR(height, bounds);
  19624. bounds.forEach(function (b) {
  19625. var i = b.index;
  19626. expanded[i].top = b.x1New;
  19627. expanded[i].bottom = b.x2New;
  19628. });
  19629. return expanded;
  19630. }
  19631. function expandBoundsLTR(width, bounds) {
  19632. bounds.sort(function (a, b) {
  19633. return a.x1 - b.x1 || a.index - b.index;
  19634. });
  19635. var fakeBoundary = {
  19636. x1: -Infinity,
  19637. y1: -Infinity,
  19638. x2: 0,
  19639. y2: Infinity,
  19640. index: -1,
  19641. x1New: 0,
  19642. x2New: 0
  19643. };
  19644. var horizon = [{
  19645. start: -Infinity,
  19646. end: Infinity,
  19647. boundary: fakeBoundary
  19648. }];
  19649. bounds.forEach(function (boundary) {
  19650. var i = 0;
  19651. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  19652. i++;
  19653. }
  19654. var j = horizon.length - 1;
  19655. while (j >= 0 && horizon[j].start >= boundary.y2) {
  19656. j--;
  19657. }
  19658. var horizonPart, affectedBoundary;
  19659. var q,
  19660. k,
  19661. maxXNew = -Infinity;
  19662. for (q = i; q <= j; q++) {
  19663. horizonPart = horizon[q];
  19664. affectedBoundary = horizonPart.boundary;
  19665. var xNew = void 0;
  19666. if (affectedBoundary.x2 > boundary.x1) {
  19667. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  19668. } else if (affectedBoundary.x2New === undefined) {
  19669. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  19670. } else {
  19671. xNew = affectedBoundary.x2New;
  19672. }
  19673. if (xNew > maxXNew) {
  19674. maxXNew = xNew;
  19675. }
  19676. }
  19677. boundary.x1New = maxXNew;
  19678. for (q = i; q <= j; q++) {
  19679. horizonPart = horizon[q];
  19680. affectedBoundary = horizonPart.boundary;
  19681. if (affectedBoundary.x2New === undefined) {
  19682. if (affectedBoundary.x2 > boundary.x1) {
  19683. if (affectedBoundary.index > boundary.index) {
  19684. affectedBoundary.x2New = affectedBoundary.x2;
  19685. }
  19686. } else {
  19687. affectedBoundary.x2New = maxXNew;
  19688. }
  19689. } else if (affectedBoundary.x2New > maxXNew) {
  19690. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  19691. }
  19692. }
  19693. var changedHorizon = [];
  19694. var lastBoundary = null;
  19695. for (q = i; q <= j; q++) {
  19696. horizonPart = horizon[q];
  19697. affectedBoundary = horizonPart.boundary;
  19698. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  19699. if (lastBoundary === useBoundary) {
  19700. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  19701. } else {
  19702. changedHorizon.push({
  19703. start: horizonPart.start,
  19704. end: horizonPart.end,
  19705. boundary: useBoundary
  19706. });
  19707. lastBoundary = useBoundary;
  19708. }
  19709. }
  19710. if (horizon[i].start < boundary.y1) {
  19711. changedHorizon[0].start = boundary.y1;
  19712. changedHorizon.unshift({
  19713. start: horizon[i].start,
  19714. end: boundary.y1,
  19715. boundary: horizon[i].boundary
  19716. });
  19717. }
  19718. if (boundary.y2 < horizon[j].end) {
  19719. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  19720. changedHorizon.push({
  19721. start: boundary.y2,
  19722. end: horizon[j].end,
  19723. boundary: horizon[j].boundary
  19724. });
  19725. }
  19726. for (q = i; q <= j; q++) {
  19727. horizonPart = horizon[q];
  19728. affectedBoundary = horizonPart.boundary;
  19729. if (affectedBoundary.x2New !== undefined) {
  19730. continue;
  19731. }
  19732. var used = false;
  19733. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  19734. used = horizon[k].boundary === affectedBoundary;
  19735. }
  19736. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  19737. used = horizon[k].boundary === affectedBoundary;
  19738. }
  19739. for (k = 0; !used && k < changedHorizon.length; k++) {
  19740. used = changedHorizon[k].boundary === affectedBoundary;
  19741. }
  19742. if (!used) {
  19743. affectedBoundary.x2New = maxXNew;
  19744. }
  19745. }
  19746. Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon));
  19747. });
  19748. horizon.forEach(function (horizonPart) {
  19749. var affectedBoundary = horizonPart.boundary;
  19750. if (affectedBoundary.x2New === undefined) {
  19751. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  19752. }
  19753. });
  19754. }
  19755. function TextLayerRenderTask(_ref) {
  19756. var _globalThis$FontInspe,
  19757. _this = this;
  19758. var textContent = _ref.textContent,
  19759. textContentStream = _ref.textContentStream,
  19760. container = _ref.container,
  19761. viewport = _ref.viewport,
  19762. textDivs = _ref.textDivs,
  19763. textContentItemsStr = _ref.textContentItemsStr,
  19764. enhanceTextSelection = _ref.enhanceTextSelection;
  19765. this._textContent = textContent;
  19766. this._textContentStream = textContentStream;
  19767. this._container = container;
  19768. this._document = container.ownerDocument;
  19769. this._viewport = viewport;
  19770. this._textDivs = textDivs || [];
  19771. this._textContentItemsStr = textContentItemsStr || [];
  19772. this._enhanceTextSelection = !!enhanceTextSelection;
  19773. this._fontInspectorEnabled = !!((_globalThis$FontInspe = globalThis.FontInspector) !== null && _globalThis$FontInspe !== void 0 && _globalThis$FontInspe.enabled);
  19774. this._reader = null;
  19775. this._layoutTextLastFontSize = null;
  19776. this._layoutTextLastFontFamily = null;
  19777. this._layoutTextCtx = null;
  19778. this._textDivProperties = new WeakMap();
  19779. this._renderingDone = false;
  19780. this._canceled = false;
  19781. this._capability = (0, _util.createPromiseCapability)();
  19782. this._renderTimer = null;
  19783. this._bounds = [];
  19784. this._capability.promise["finally"](function () {
  19785. if (_this._layoutTextCtx) {
  19786. _this._layoutTextCtx.canvas.width = 0;
  19787. _this._layoutTextCtx.canvas.height = 0;
  19788. _this._layoutTextCtx = null;
  19789. }
  19790. })["catch"](function () {});
  19791. }
  19792. TextLayerRenderTask.prototype = {
  19793. get promise() {
  19794. return this._capability.promise;
  19795. },
  19796. cancel: function TextLayer_cancel() {
  19797. this._canceled = true;
  19798. if (this._reader) {
  19799. this._reader.cancel(new _util.AbortException("TextLayer task cancelled."));
  19800. this._reader = null;
  19801. }
  19802. if (this._renderTimer !== null) {
  19803. clearTimeout(this._renderTimer);
  19804. this._renderTimer = null;
  19805. }
  19806. this._capability.reject(new Error("TextLayer task cancelled."));
  19807. },
  19808. _processItems: function _processItems(items, styleCache) {
  19809. for (var i = 0, len = items.length; i < len; i++) {
  19810. this._textContentItemsStr.push(items[i].str);
  19811. appendText(this, items[i], styleCache);
  19812. }
  19813. },
  19814. _layoutText: function _layoutText(textDiv) {
  19815. var textDivProperties = this._textDivProperties.get(textDiv);
  19816. if (textDivProperties.isWhitespace) {
  19817. return;
  19818. }
  19819. var transform = "";
  19820. if (textDivProperties.canvasWidth !== 0) {
  19821. var _textDiv$style = textDiv.style,
  19822. fontSize = _textDiv$style.fontSize,
  19823. fontFamily = _textDiv$style.fontFamily;
  19824. if (fontSize !== this._layoutTextLastFontSize || fontFamily !== this._layoutTextLastFontFamily) {
  19825. this._layoutTextCtx.font = "".concat(fontSize, " ").concat(fontFamily);
  19826. this._layoutTextLastFontSize = fontSize;
  19827. this._layoutTextLastFontFamily = fontFamily;
  19828. }
  19829. var _this$_layoutTextCtx$ = this._layoutTextCtx.measureText(textDiv.textContent),
  19830. width = _this$_layoutTextCtx$.width;
  19831. if (width > 0) {
  19832. textDivProperties.scale = textDivProperties.canvasWidth / width;
  19833. transform = "scaleX(".concat(textDivProperties.scale, ")");
  19834. }
  19835. }
  19836. if (textDivProperties.angle !== 0) {
  19837. transform = "rotate(".concat(textDivProperties.angle, "deg) ").concat(transform);
  19838. }
  19839. if (transform.length > 0) {
  19840. if (this._enhanceTextSelection) {
  19841. textDivProperties.originalTransform = transform;
  19842. }
  19843. textDiv.style.transform = transform;
  19844. }
  19845. this._textDivProperties.set(textDiv, textDivProperties);
  19846. this._container.appendChild(textDiv);
  19847. },
  19848. _render: function TextLayer_render(timeout) {
  19849. var _this2 = this;
  19850. var capability = (0, _util.createPromiseCapability)();
  19851. var styleCache = Object.create(null);
  19852. var canvas = this._document.createElement("canvas");
  19853. canvas.mozOpaque = true;
  19854. this._layoutTextCtx = canvas.getContext("2d", {
  19855. alpha: false
  19856. });
  19857. if (this._textContent) {
  19858. var textItems = this._textContent.items;
  19859. var textStyles = this._textContent.styles;
  19860. this._processItems(textItems, textStyles);
  19861. capability.resolve();
  19862. } else if (this._textContentStream) {
  19863. var pump = function pump() {
  19864. _this2._reader.read().then(function (_ref2) {
  19865. var value = _ref2.value,
  19866. done = _ref2.done;
  19867. if (done) {
  19868. capability.resolve();
  19869. return;
  19870. }
  19871. Object.assign(styleCache, value.styles);
  19872. _this2._processItems(value.items, styleCache);
  19873. pump();
  19874. }, capability.reject);
  19875. };
  19876. this._reader = this._textContentStream.getReader();
  19877. pump();
  19878. } else {
  19879. throw new Error('Neither "textContent" nor "textContentStream"' + " parameters specified.");
  19880. }
  19881. capability.promise.then(function () {
  19882. styleCache = null;
  19883. if (!timeout) {
  19884. render(_this2);
  19885. } else {
  19886. _this2._renderTimer = setTimeout(function () {
  19887. render(_this2);
  19888. _this2._renderTimer = null;
  19889. }, timeout);
  19890. }
  19891. }, this._capability.reject);
  19892. },
  19893. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  19894. if (!this._enhanceTextSelection || !this._renderingDone) {
  19895. return;
  19896. }
  19897. if (this._bounds !== null) {
  19898. expand(this);
  19899. this._bounds = null;
  19900. }
  19901. var transformBuf = [],
  19902. paddingBuf = [];
  19903. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  19904. var div = this._textDivs[i];
  19905. var divProps = this._textDivProperties.get(div);
  19906. if (divProps.isWhitespace) {
  19907. continue;
  19908. }
  19909. if (expandDivs) {
  19910. transformBuf.length = 0;
  19911. paddingBuf.length = 0;
  19912. if (divProps.originalTransform) {
  19913. transformBuf.push(divProps.originalTransform);
  19914. }
  19915. if (divProps.paddingTop > 0) {
  19916. paddingBuf.push("".concat(divProps.paddingTop, "px"));
  19917. transformBuf.push("translateY(".concat(-divProps.paddingTop, "px)"));
  19918. } else {
  19919. paddingBuf.push(0);
  19920. }
  19921. if (divProps.paddingRight > 0) {
  19922. paddingBuf.push("".concat(divProps.paddingRight / divProps.scale, "px"));
  19923. } else {
  19924. paddingBuf.push(0);
  19925. }
  19926. if (divProps.paddingBottom > 0) {
  19927. paddingBuf.push("".concat(divProps.paddingBottom, "px"));
  19928. } else {
  19929. paddingBuf.push(0);
  19930. }
  19931. if (divProps.paddingLeft > 0) {
  19932. paddingBuf.push("".concat(divProps.paddingLeft / divProps.scale, "px"));
  19933. transformBuf.push("translateX(".concat(-divProps.paddingLeft / divProps.scale, "px)"));
  19934. } else {
  19935. paddingBuf.push(0);
  19936. }
  19937. div.style.padding = paddingBuf.join(" ");
  19938. if (transformBuf.length) {
  19939. div.style.transform = transformBuf.join(" ");
  19940. }
  19941. } else {
  19942. div.style.padding = null;
  19943. div.style.transform = divProps.originalTransform;
  19944. }
  19945. }
  19946. }
  19947. };
  19948. function renderTextLayer(renderParameters) {
  19949. var task = new TextLayerRenderTask({
  19950. textContent: renderParameters.textContent,
  19951. textContentStream: renderParameters.textContentStream,
  19952. container: renderParameters.container,
  19953. viewport: renderParameters.viewport,
  19954. textDivs: renderParameters.textDivs,
  19955. textContentItemsStr: renderParameters.textContentItemsStr,
  19956. enhanceTextSelection: renderParameters.enhanceTextSelection
  19957. });
  19958. task._render(renderParameters.timeout);
  19959. return task;
  19960. }
  19961. return renderTextLayer;
  19962. }();
  19963. exports.renderTextLayer = renderTextLayer;
  19964. /***/ }),
  19965. /* 152 */
  19966. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  19967. "use strict";
  19968. Object.defineProperty(exports, "__esModule", ({
  19969. value: true
  19970. }));
  19971. exports.SVGGraphics = void 0;
  19972. var _util = __w_pdfjs_require__(4);
  19973. var _display_utils = __w_pdfjs_require__(1);
  19974. var _is_node = __w_pdfjs_require__(6);
  19975. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  19976. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  19977. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  19978. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  19979. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  19980. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  19981. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  19982. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  19983. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  19984. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  19985. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  19986. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19987. 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); } }
  19988. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  19989. var SVGGraphics = function SVGGraphics() {
  19990. throw new Error("Not implemented: SVGGraphics");
  19991. };
  19992. exports.SVGGraphics = SVGGraphics;
  19993. {
  19994. var opListToTree = function opListToTree(opList) {
  19995. var opTree = [];
  19996. var tmp = [];
  19997. var _iterator = _createForOfIteratorHelper(opList),
  19998. _step;
  19999. try {
  20000. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  20001. var opListElement = _step.value;
  20002. if (opListElement.fn === "save") {
  20003. opTree.push({
  20004. fnId: 92,
  20005. fn: "group",
  20006. items: []
  20007. });
  20008. tmp.push(opTree);
  20009. opTree = opTree[opTree.length - 1].items;
  20010. continue;
  20011. }
  20012. if (opListElement.fn === "restore") {
  20013. opTree = tmp.pop();
  20014. } else {
  20015. opTree.push(opListElement);
  20016. }
  20017. }
  20018. } catch (err) {
  20019. _iterator.e(err);
  20020. } finally {
  20021. _iterator.f();
  20022. }
  20023. return opTree;
  20024. };
  20025. var pf = function pf(value) {
  20026. if (Number.isInteger(value)) {
  20027. return value.toString();
  20028. }
  20029. var s = value.toFixed(10);
  20030. var i = s.length - 1;
  20031. if (s[i] !== "0") {
  20032. return s;
  20033. }
  20034. do {
  20035. i--;
  20036. } while (s[i] === "0");
  20037. return s.substring(0, s[i] === "." ? i : i + 1);
  20038. };
  20039. var pm = function pm(m) {
  20040. if (m[4] === 0 && m[5] === 0) {
  20041. if (m[1] === 0 && m[2] === 0) {
  20042. if (m[0] === 1 && m[3] === 1) {
  20043. return "";
  20044. }
  20045. return "scale(".concat(pf(m[0]), " ").concat(pf(m[3]), ")");
  20046. }
  20047. if (m[0] === m[3] && m[1] === -m[2]) {
  20048. var a = Math.acos(m[0]) * 180 / Math.PI;
  20049. return "rotate(".concat(pf(a), ")");
  20050. }
  20051. } else {
  20052. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  20053. return "translate(".concat(pf(m[4]), " ").concat(pf(m[5]), ")");
  20054. }
  20055. }
  20056. return "matrix(".concat(pf(m[0]), " ").concat(pf(m[1]), " ").concat(pf(m[2]), " ").concat(pf(m[3]), " ").concat(pf(m[4]), " ") + "".concat(pf(m[5]), ")");
  20057. };
  20058. var SVG_DEFAULTS = {
  20059. fontStyle: "normal",
  20060. fontWeight: "normal",
  20061. fillColor: "#000000"
  20062. };
  20063. var XML_NS = "http://www.w3.org/XML/1998/namespace";
  20064. var XLINK_NS = "http://www.w3.org/1999/xlink";
  20065. var LINE_CAP_STYLES = ["butt", "round", "square"];
  20066. var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
  20067. var convertImgDataToPng = function () {
  20068. var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
  20069. var CHUNK_WRAPPER_SIZE = 12;
  20070. var crcTable = new Int32Array(256);
  20071. for (var i = 0; i < 256; i++) {
  20072. var c = i;
  20073. for (var h = 0; h < 8; h++) {
  20074. if (c & 1) {
  20075. c = 0xedb88320 ^ c >> 1 & 0x7fffffff;
  20076. } else {
  20077. c = c >> 1 & 0x7fffffff;
  20078. }
  20079. }
  20080. crcTable[i] = c;
  20081. }
  20082. function crc32(data, start, end) {
  20083. var crc = -1;
  20084. for (var _i = start; _i < end; _i++) {
  20085. var a = (crc ^ data[_i]) & 0xff;
  20086. var b = crcTable[a];
  20087. crc = crc >>> 8 ^ b;
  20088. }
  20089. return crc ^ -1;
  20090. }
  20091. function writePngChunk(type, body, data, offset) {
  20092. var p = offset;
  20093. var len = body.length;
  20094. data[p] = len >> 24 & 0xff;
  20095. data[p + 1] = len >> 16 & 0xff;
  20096. data[p + 2] = len >> 8 & 0xff;
  20097. data[p + 3] = len & 0xff;
  20098. p += 4;
  20099. data[p] = type.charCodeAt(0) & 0xff;
  20100. data[p + 1] = type.charCodeAt(1) & 0xff;
  20101. data[p + 2] = type.charCodeAt(2) & 0xff;
  20102. data[p + 3] = type.charCodeAt(3) & 0xff;
  20103. p += 4;
  20104. data.set(body, p);
  20105. p += body.length;
  20106. var crc = crc32(data, offset + 4, p);
  20107. data[p] = crc >> 24 & 0xff;
  20108. data[p + 1] = crc >> 16 & 0xff;
  20109. data[p + 2] = crc >> 8 & 0xff;
  20110. data[p + 3] = crc & 0xff;
  20111. }
  20112. function adler32(data, start, end) {
  20113. var a = 1;
  20114. var b = 0;
  20115. for (var _i2 = start; _i2 < end; ++_i2) {
  20116. a = (a + (data[_i2] & 0xff)) % 65521;
  20117. b = (b + a) % 65521;
  20118. }
  20119. return b << 16 | a;
  20120. }
  20121. function deflateSync(literals) {
  20122. if (!_is_node.isNodeJS) {
  20123. return deflateSyncUncompressed(literals);
  20124. }
  20125. try {
  20126. var input;
  20127. if (parseInt(process.versions.node) >= 8) {
  20128. input = literals;
  20129. } else {
  20130. input = Buffer.from(literals);
  20131. }
  20132. var output = require("zlib").deflateSync(input, {
  20133. level: 9
  20134. });
  20135. return output instanceof Uint8Array ? output : new Uint8Array(output);
  20136. } catch (e) {
  20137. (0, _util.warn)("Not compressing PNG because zlib.deflateSync is unavailable: " + e);
  20138. }
  20139. return deflateSyncUncompressed(literals);
  20140. }
  20141. function deflateSyncUncompressed(literals) {
  20142. var len = literals.length;
  20143. var maxBlockLength = 0xffff;
  20144. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20145. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20146. var pi = 0;
  20147. idat[pi++] = 0x78;
  20148. idat[pi++] = 0x9c;
  20149. var pos = 0;
  20150. while (len > maxBlockLength) {
  20151. idat[pi++] = 0x00;
  20152. idat[pi++] = 0xff;
  20153. idat[pi++] = 0xff;
  20154. idat[pi++] = 0x00;
  20155. idat[pi++] = 0x00;
  20156. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20157. pi += maxBlockLength;
  20158. pos += maxBlockLength;
  20159. len -= maxBlockLength;
  20160. }
  20161. idat[pi++] = 0x01;
  20162. idat[pi++] = len & 0xff;
  20163. idat[pi++] = len >> 8 & 0xff;
  20164. idat[pi++] = ~len & 0xffff & 0xff;
  20165. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20166. idat.set(literals.subarray(pos), pi);
  20167. pi += literals.length - pos;
  20168. var adler = adler32(literals, 0, literals.length);
  20169. idat[pi++] = adler >> 24 & 0xff;
  20170. idat[pi++] = adler >> 16 & 0xff;
  20171. idat[pi++] = adler >> 8 & 0xff;
  20172. idat[pi++] = adler & 0xff;
  20173. return idat;
  20174. }
  20175. function encode(imgData, kind, forceDataSchema, isMask) {
  20176. var width = imgData.width;
  20177. var height = imgData.height;
  20178. var bitDepth, colorType, lineSize;
  20179. var bytes = imgData.data;
  20180. switch (kind) {
  20181. case _util.ImageKind.GRAYSCALE_1BPP:
  20182. colorType = 0;
  20183. bitDepth = 1;
  20184. lineSize = width + 7 >> 3;
  20185. break;
  20186. case _util.ImageKind.RGB_24BPP:
  20187. colorType = 2;
  20188. bitDepth = 8;
  20189. lineSize = width * 3;
  20190. break;
  20191. case _util.ImageKind.RGBA_32BPP:
  20192. colorType = 6;
  20193. bitDepth = 8;
  20194. lineSize = width * 4;
  20195. break;
  20196. default:
  20197. throw new Error("invalid format");
  20198. }
  20199. var literals = new Uint8Array((1 + lineSize) * height);
  20200. var offsetLiterals = 0,
  20201. offsetBytes = 0;
  20202. for (var y = 0; y < height; ++y) {
  20203. literals[offsetLiterals++] = 0;
  20204. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20205. offsetBytes += lineSize;
  20206. offsetLiterals += lineSize;
  20207. }
  20208. if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
  20209. offsetLiterals = 0;
  20210. for (var _y = 0; _y < height; _y++) {
  20211. offsetLiterals++;
  20212. for (var _i3 = 0; _i3 < lineSize; _i3++) {
  20213. literals[offsetLiterals++] ^= 0xff;
  20214. }
  20215. }
  20216. }
  20217. 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]);
  20218. var idat = deflateSync(literals);
  20219. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20220. var data = new Uint8Array(pngLength);
  20221. var offset = 0;
  20222. data.set(PNG_HEADER, offset);
  20223. offset += PNG_HEADER.length;
  20224. writePngChunk("IHDR", ihdr, data, offset);
  20225. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20226. writePngChunk("IDATA", idat, data, offset);
  20227. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20228. writePngChunk("IEND", new Uint8Array(0), data, offset);
  20229. return (0, _util.createObjectURL)(data, "image/png", forceDataSchema);
  20230. }
  20231. return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
  20232. var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20233. return encode(imgData, kind, forceDataSchema, isMask);
  20234. };
  20235. }();
  20236. var SVGExtraState = /*#__PURE__*/function () {
  20237. function SVGExtraState() {
  20238. _classCallCheck(this, SVGExtraState);
  20239. this.fontSizeScale = 1;
  20240. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20241. this.fontSize = 0;
  20242. this.textMatrix = _util.IDENTITY_MATRIX;
  20243. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  20244. this.leading = 0;
  20245. this.textRenderingMode = _util.TextRenderingMode.FILL;
  20246. this.textMatrixScale = 1;
  20247. this.x = 0;
  20248. this.y = 0;
  20249. this.lineX = 0;
  20250. this.lineY = 0;
  20251. this.charSpacing = 0;
  20252. this.wordSpacing = 0;
  20253. this.textHScale = 1;
  20254. this.textRise = 0;
  20255. this.fillColor = SVG_DEFAULTS.fillColor;
  20256. this.strokeColor = "#000000";
  20257. this.fillAlpha = 1;
  20258. this.strokeAlpha = 1;
  20259. this.lineWidth = 1;
  20260. this.lineJoin = "";
  20261. this.lineCap = "";
  20262. this.miterLimit = 0;
  20263. this.dashArray = [];
  20264. this.dashPhase = 0;
  20265. this.dependencies = [];
  20266. this.activeClipUrl = null;
  20267. this.clipGroup = null;
  20268. this.maskId = "";
  20269. }
  20270. _createClass(SVGExtraState, [{
  20271. key: "clone",
  20272. value: function clone() {
  20273. return Object.create(this);
  20274. }
  20275. }, {
  20276. key: "setCurrentPoint",
  20277. value: function setCurrentPoint(x, y) {
  20278. this.x = x;
  20279. this.y = y;
  20280. }
  20281. }]);
  20282. return SVGExtraState;
  20283. }();
  20284. var clipCount = 0;
  20285. var maskCount = 0;
  20286. var shadingCount = 0;
  20287. exports.SVGGraphics = SVGGraphics = /*#__PURE__*/function () {
  20288. function SVGGraphics(commonObjs, objs) {
  20289. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  20290. _classCallCheck(this, SVGGraphics);
  20291. this.svgFactory = new _display_utils.DOMSVGFactory();
  20292. this.current = new SVGExtraState();
  20293. this.transformMatrix = _util.IDENTITY_MATRIX;
  20294. this.transformStack = [];
  20295. this.extraStack = [];
  20296. this.commonObjs = commonObjs;
  20297. this.objs = objs;
  20298. this.pendingClip = null;
  20299. this.pendingEOFill = false;
  20300. this.embedFonts = false;
  20301. this.embeddedFonts = Object.create(null);
  20302. this.cssStyle = null;
  20303. this.forceDataSchema = !!forceDataSchema;
  20304. this._operatorIdMapping = [];
  20305. for (var op in _util.OPS) {
  20306. this._operatorIdMapping[_util.OPS[op]] = op;
  20307. }
  20308. }
  20309. _createClass(SVGGraphics, [{
  20310. key: "save",
  20311. value: function save() {
  20312. this.transformStack.push(this.transformMatrix);
  20313. var old = this.current;
  20314. this.extraStack.push(old);
  20315. this.current = old.clone();
  20316. }
  20317. }, {
  20318. key: "restore",
  20319. value: function restore() {
  20320. this.transformMatrix = this.transformStack.pop();
  20321. this.current = this.extraStack.pop();
  20322. this.pendingClip = null;
  20323. this.tgrp = null;
  20324. }
  20325. }, {
  20326. key: "group",
  20327. value: function group(items) {
  20328. this.save();
  20329. this.executeOpTree(items);
  20330. this.restore();
  20331. }
  20332. }, {
  20333. key: "loadDependencies",
  20334. value: function loadDependencies(operatorList) {
  20335. var _this = this;
  20336. var fnArray = operatorList.fnArray;
  20337. var argsArray = operatorList.argsArray;
  20338. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  20339. if (fnArray[i] !== _util.OPS.dependency) {
  20340. continue;
  20341. }
  20342. var _iterator2 = _createForOfIteratorHelper(argsArray[i]),
  20343. _step2;
  20344. try {
  20345. var _loop = function _loop() {
  20346. var obj = _step2.value;
  20347. var objsPool = obj.startsWith("g_") ? _this.commonObjs : _this.objs;
  20348. var promise = new Promise(function (resolve) {
  20349. objsPool.get(obj, resolve);
  20350. });
  20351. _this.current.dependencies.push(promise);
  20352. };
  20353. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  20354. _loop();
  20355. }
  20356. } catch (err) {
  20357. _iterator2.e(err);
  20358. } finally {
  20359. _iterator2.f();
  20360. }
  20361. }
  20362. return Promise.all(this.current.dependencies);
  20363. }
  20364. }, {
  20365. key: "transform",
  20366. value: function transform(a, b, c, d, e, f) {
  20367. var transformMatrix = [a, b, c, d, e, f];
  20368. this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
  20369. this.tgrp = null;
  20370. }
  20371. }, {
  20372. key: "getSVG",
  20373. value: function getSVG(operatorList, viewport) {
  20374. var _this2 = this;
  20375. this.viewport = viewport;
  20376. var svgElement = this._initialize(viewport);
  20377. return this.loadDependencies(operatorList).then(function () {
  20378. _this2.transformMatrix = _util.IDENTITY_MATRIX;
  20379. _this2.executeOpTree(_this2.convertOpList(operatorList));
  20380. return svgElement;
  20381. });
  20382. }
  20383. }, {
  20384. key: "convertOpList",
  20385. value: function convertOpList(operatorList) {
  20386. var operatorIdMapping = this._operatorIdMapping;
  20387. var argsArray = operatorList.argsArray;
  20388. var fnArray = operatorList.fnArray;
  20389. var opList = [];
  20390. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  20391. var fnId = fnArray[i];
  20392. opList.push({
  20393. fnId: fnId,
  20394. fn: operatorIdMapping[fnId],
  20395. args: argsArray[i]
  20396. });
  20397. }
  20398. return opListToTree(opList);
  20399. }
  20400. }, {
  20401. key: "executeOpTree",
  20402. value: function executeOpTree(opTree) {
  20403. var _iterator3 = _createForOfIteratorHelper(opTree),
  20404. _step3;
  20405. try {
  20406. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  20407. var opTreeElement = _step3.value;
  20408. var fn = opTreeElement.fn;
  20409. var fnId = opTreeElement.fnId;
  20410. var args = opTreeElement.args;
  20411. switch (fnId | 0) {
  20412. case _util.OPS.beginText:
  20413. this.beginText();
  20414. break;
  20415. case _util.OPS.dependency:
  20416. break;
  20417. case _util.OPS.setLeading:
  20418. this.setLeading(args);
  20419. break;
  20420. case _util.OPS.setLeadingMoveText:
  20421. this.setLeadingMoveText(args[0], args[1]);
  20422. break;
  20423. case _util.OPS.setFont:
  20424. this.setFont(args);
  20425. break;
  20426. case _util.OPS.showText:
  20427. this.showText(args[0]);
  20428. break;
  20429. case _util.OPS.showSpacedText:
  20430. this.showText(args[0]);
  20431. break;
  20432. case _util.OPS.endText:
  20433. this.endText();
  20434. break;
  20435. case _util.OPS.moveText:
  20436. this.moveText(args[0], args[1]);
  20437. break;
  20438. case _util.OPS.setCharSpacing:
  20439. this.setCharSpacing(args[0]);
  20440. break;
  20441. case _util.OPS.setWordSpacing:
  20442. this.setWordSpacing(args[0]);
  20443. break;
  20444. case _util.OPS.setHScale:
  20445. this.setHScale(args[0]);
  20446. break;
  20447. case _util.OPS.setTextMatrix:
  20448. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  20449. break;
  20450. case _util.OPS.setTextRise:
  20451. this.setTextRise(args[0]);
  20452. break;
  20453. case _util.OPS.setTextRenderingMode:
  20454. this.setTextRenderingMode(args[0]);
  20455. break;
  20456. case _util.OPS.setLineWidth:
  20457. this.setLineWidth(args[0]);
  20458. break;
  20459. case _util.OPS.setLineJoin:
  20460. this.setLineJoin(args[0]);
  20461. break;
  20462. case _util.OPS.setLineCap:
  20463. this.setLineCap(args[0]);
  20464. break;
  20465. case _util.OPS.setMiterLimit:
  20466. this.setMiterLimit(args[0]);
  20467. break;
  20468. case _util.OPS.setFillRGBColor:
  20469. this.setFillRGBColor(args[0], args[1], args[2]);
  20470. break;
  20471. case _util.OPS.setStrokeRGBColor:
  20472. this.setStrokeRGBColor(args[0], args[1], args[2]);
  20473. break;
  20474. case _util.OPS.setStrokeColorN:
  20475. this.setStrokeColorN(args);
  20476. break;
  20477. case _util.OPS.setFillColorN:
  20478. this.setFillColorN(args);
  20479. break;
  20480. case _util.OPS.shadingFill:
  20481. this.shadingFill(args[0]);
  20482. break;
  20483. case _util.OPS.setDash:
  20484. this.setDash(args[0], args[1]);
  20485. break;
  20486. case _util.OPS.setRenderingIntent:
  20487. this.setRenderingIntent(args[0]);
  20488. break;
  20489. case _util.OPS.setFlatness:
  20490. this.setFlatness(args[0]);
  20491. break;
  20492. case _util.OPS.setGState:
  20493. this.setGState(args[0]);
  20494. break;
  20495. case _util.OPS.fill:
  20496. this.fill();
  20497. break;
  20498. case _util.OPS.eoFill:
  20499. this.eoFill();
  20500. break;
  20501. case _util.OPS.stroke:
  20502. this.stroke();
  20503. break;
  20504. case _util.OPS.fillStroke:
  20505. this.fillStroke();
  20506. break;
  20507. case _util.OPS.eoFillStroke:
  20508. this.eoFillStroke();
  20509. break;
  20510. case _util.OPS.clip:
  20511. this.clip("nonzero");
  20512. break;
  20513. case _util.OPS.eoClip:
  20514. this.clip("evenodd");
  20515. break;
  20516. case _util.OPS.paintSolidColorImageMask:
  20517. this.paintSolidColorImageMask();
  20518. break;
  20519. case _util.OPS.paintImageXObject:
  20520. this.paintImageXObject(args[0]);
  20521. break;
  20522. case _util.OPS.paintInlineImageXObject:
  20523. this.paintInlineImageXObject(args[0]);
  20524. break;
  20525. case _util.OPS.paintImageMaskXObject:
  20526. this.paintImageMaskXObject(args[0]);
  20527. break;
  20528. case _util.OPS.paintFormXObjectBegin:
  20529. this.paintFormXObjectBegin(args[0], args[1]);
  20530. break;
  20531. case _util.OPS.paintFormXObjectEnd:
  20532. this.paintFormXObjectEnd();
  20533. break;
  20534. case _util.OPS.closePath:
  20535. this.closePath();
  20536. break;
  20537. case _util.OPS.closeStroke:
  20538. this.closeStroke();
  20539. break;
  20540. case _util.OPS.closeFillStroke:
  20541. this.closeFillStroke();
  20542. break;
  20543. case _util.OPS.closeEOFillStroke:
  20544. this.closeEOFillStroke();
  20545. break;
  20546. case _util.OPS.nextLine:
  20547. this.nextLine();
  20548. break;
  20549. case _util.OPS.transform:
  20550. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  20551. break;
  20552. case _util.OPS.constructPath:
  20553. this.constructPath(args[0], args[1]);
  20554. break;
  20555. case _util.OPS.endPath:
  20556. this.endPath();
  20557. break;
  20558. case 92:
  20559. this.group(opTreeElement.items);
  20560. break;
  20561. default:
  20562. (0, _util.warn)("Unimplemented operator ".concat(fn));
  20563. break;
  20564. }
  20565. }
  20566. } catch (err) {
  20567. _iterator3.e(err);
  20568. } finally {
  20569. _iterator3.f();
  20570. }
  20571. }
  20572. }, {
  20573. key: "setWordSpacing",
  20574. value: function setWordSpacing(wordSpacing) {
  20575. this.current.wordSpacing = wordSpacing;
  20576. }
  20577. }, {
  20578. key: "setCharSpacing",
  20579. value: function setCharSpacing(charSpacing) {
  20580. this.current.charSpacing = charSpacing;
  20581. }
  20582. }, {
  20583. key: "nextLine",
  20584. value: function nextLine() {
  20585. this.moveText(0, this.current.leading);
  20586. }
  20587. }, {
  20588. key: "setTextMatrix",
  20589. value: function setTextMatrix(a, b, c, d, e, f) {
  20590. var current = this.current;
  20591. current.textMatrix = current.lineMatrix = [a, b, c, d, e, f];
  20592. current.textMatrixScale = Math.sqrt(a * a + b * b);
  20593. current.x = current.lineX = 0;
  20594. current.y = current.lineY = 0;
  20595. current.xcoords = [];
  20596. current.ycoords = [];
  20597. current.tspan = this.svgFactory.createElement("svg:tspan");
  20598. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  20599. current.tspan.setAttributeNS(null, "font-size", "".concat(pf(current.fontSize), "px"));
  20600. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  20601. current.txtElement = this.svgFactory.createElement("svg:text");
  20602. current.txtElement.appendChild(current.tspan);
  20603. }
  20604. }, {
  20605. key: "beginText",
  20606. value: function beginText() {
  20607. var current = this.current;
  20608. current.x = current.lineX = 0;
  20609. current.y = current.lineY = 0;
  20610. current.textMatrix = _util.IDENTITY_MATRIX;
  20611. current.lineMatrix = _util.IDENTITY_MATRIX;
  20612. current.textMatrixScale = 1;
  20613. current.tspan = this.svgFactory.createElement("svg:tspan");
  20614. current.txtElement = this.svgFactory.createElement("svg:text");
  20615. current.txtgrp = this.svgFactory.createElement("svg:g");
  20616. current.xcoords = [];
  20617. current.ycoords = [];
  20618. }
  20619. }, {
  20620. key: "moveText",
  20621. value: function moveText(x, y) {
  20622. var current = this.current;
  20623. current.x = current.lineX += x;
  20624. current.y = current.lineY += y;
  20625. current.xcoords = [];
  20626. current.ycoords = [];
  20627. current.tspan = this.svgFactory.createElement("svg:tspan");
  20628. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  20629. current.tspan.setAttributeNS(null, "font-size", "".concat(pf(current.fontSize), "px"));
  20630. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  20631. }
  20632. }, {
  20633. key: "showText",
  20634. value: function showText(glyphs) {
  20635. var current = this.current;
  20636. var font = current.font;
  20637. var fontSize = current.fontSize;
  20638. if (fontSize === 0) {
  20639. return;
  20640. }
  20641. var fontSizeScale = current.fontSizeScale;
  20642. var charSpacing = current.charSpacing;
  20643. var wordSpacing = current.wordSpacing;
  20644. var fontDirection = current.fontDirection;
  20645. var textHScale = current.textHScale * fontDirection;
  20646. var vertical = font.vertical;
  20647. var spacingDir = vertical ? 1 : -1;
  20648. var defaultVMetrics = font.defaultVMetrics;
  20649. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  20650. var x = 0;
  20651. var _iterator4 = _createForOfIteratorHelper(glyphs),
  20652. _step4;
  20653. try {
  20654. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  20655. var glyph = _step4.value;
  20656. if (glyph === null) {
  20657. x += fontDirection * wordSpacing;
  20658. continue;
  20659. } else if ((0, _util.isNum)(glyph)) {
  20660. x += spacingDir * glyph * fontSize / 1000;
  20661. continue;
  20662. }
  20663. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  20664. var character = glyph.fontChar;
  20665. var scaledX = void 0,
  20666. scaledY = void 0;
  20667. var width = glyph.width;
  20668. if (vertical) {
  20669. var vx = void 0;
  20670. var vmetric = glyph.vmetric || defaultVMetrics;
  20671. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  20672. vx = -vx * widthAdvanceScale;
  20673. var vy = vmetric[2] * widthAdvanceScale;
  20674. width = vmetric ? -vmetric[0] : width;
  20675. scaledX = vx / fontSizeScale;
  20676. scaledY = (x + vy) / fontSizeScale;
  20677. } else {
  20678. scaledX = x / fontSizeScale;
  20679. scaledY = 0;
  20680. }
  20681. if (glyph.isInFont || font.missingFile) {
  20682. current.xcoords.push(current.x + scaledX);
  20683. if (vertical) {
  20684. current.ycoords.push(-current.y + scaledY);
  20685. }
  20686. current.tspan.textContent += character;
  20687. } else {}
  20688. var charWidth = void 0;
  20689. if (vertical) {
  20690. charWidth = width * widthAdvanceScale - spacing * fontDirection;
  20691. } else {
  20692. charWidth = width * widthAdvanceScale + spacing * fontDirection;
  20693. }
  20694. x += charWidth;
  20695. }
  20696. } catch (err) {
  20697. _iterator4.e(err);
  20698. } finally {
  20699. _iterator4.f();
  20700. }
  20701. current.tspan.setAttributeNS(null, "x", current.xcoords.map(pf).join(" "));
  20702. if (vertical) {
  20703. current.tspan.setAttributeNS(null, "y", current.ycoords.map(pf).join(" "));
  20704. } else {
  20705. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  20706. }
  20707. if (vertical) {
  20708. current.y -= x;
  20709. } else {
  20710. current.x += x * textHScale;
  20711. }
  20712. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  20713. current.tspan.setAttributeNS(null, "font-size", "".concat(pf(current.fontSize), "px"));
  20714. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  20715. current.tspan.setAttributeNS(null, "font-style", current.fontStyle);
  20716. }
  20717. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  20718. current.tspan.setAttributeNS(null, "font-weight", current.fontWeight);
  20719. }
  20720. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  20721. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  20722. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  20723. current.tspan.setAttributeNS(null, "fill", current.fillColor);
  20724. }
  20725. if (current.fillAlpha < 1) {
  20726. current.tspan.setAttributeNS(null, "fill-opacity", current.fillAlpha);
  20727. }
  20728. } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
  20729. current.tspan.setAttributeNS(null, "fill", "transparent");
  20730. } else {
  20731. current.tspan.setAttributeNS(null, "fill", "none");
  20732. }
  20733. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  20734. var lineWidthScale = 1 / (current.textMatrixScale || 1);
  20735. this._setStrokeAttributes(current.tspan, lineWidthScale);
  20736. }
  20737. var textMatrix = current.textMatrix;
  20738. if (current.textRise !== 0) {
  20739. textMatrix = textMatrix.slice();
  20740. textMatrix[5] += current.textRise;
  20741. }
  20742. current.txtElement.setAttributeNS(null, "transform", "".concat(pm(textMatrix), " scale(").concat(pf(textHScale), ", -1)"));
  20743. current.txtElement.setAttributeNS(XML_NS, "xml:space", "preserve");
  20744. current.txtElement.appendChild(current.tspan);
  20745. current.txtgrp.appendChild(current.txtElement);
  20746. this._ensureTransformGroup().appendChild(current.txtElement);
  20747. }
  20748. }, {
  20749. key: "setLeadingMoveText",
  20750. value: function setLeadingMoveText(x, y) {
  20751. this.setLeading(-y);
  20752. this.moveText(x, y);
  20753. }
  20754. }, {
  20755. key: "addFontStyle",
  20756. value: function addFontStyle(fontObj) {
  20757. if (!fontObj.data) {
  20758. throw new Error("addFontStyle: No font data available, " + 'ensure that the "fontExtraProperties" API parameter is set.');
  20759. }
  20760. if (!this.cssStyle) {
  20761. this.cssStyle = this.svgFactory.createElement("svg:style");
  20762. this.cssStyle.setAttributeNS(null, "type", "text/css");
  20763. this.defs.appendChild(this.cssStyle);
  20764. }
  20765. var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  20766. this.cssStyle.textContent += "@font-face { font-family: \"".concat(fontObj.loadedName, "\";") + " src: url(".concat(url, "); }\n");
  20767. }
  20768. }, {
  20769. key: "setFont",
  20770. value: function setFont(details) {
  20771. var current = this.current;
  20772. var fontObj = this.commonObjs.get(details[0]);
  20773. var size = details[1];
  20774. current.font = fontObj;
  20775. if (this.embedFonts && !fontObj.missingFile && !this.embeddedFonts[fontObj.loadedName]) {
  20776. this.addFontStyle(fontObj);
  20777. this.embeddedFonts[fontObj.loadedName] = fontObj;
  20778. }
  20779. current.fontMatrix = fontObj.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  20780. var bold = "normal";
  20781. if (fontObj.black) {
  20782. bold = "900";
  20783. } else if (fontObj.bold) {
  20784. bold = "bold";
  20785. }
  20786. var italic = fontObj.italic ? "italic" : "normal";
  20787. if (size < 0) {
  20788. size = -size;
  20789. current.fontDirection = -1;
  20790. } else {
  20791. current.fontDirection = 1;
  20792. }
  20793. current.fontSize = size;
  20794. current.fontFamily = fontObj.loadedName;
  20795. current.fontWeight = bold;
  20796. current.fontStyle = italic;
  20797. current.tspan = this.svgFactory.createElement("svg:tspan");
  20798. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  20799. current.xcoords = [];
  20800. current.ycoords = [];
  20801. }
  20802. }, {
  20803. key: "endText",
  20804. value: function endText() {
  20805. var _current$txtElement;
  20806. var current = this.current;
  20807. if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && (_current$txtElement = current.txtElement) !== null && _current$txtElement !== void 0 && _current$txtElement.hasChildNodes()) {
  20808. current.element = current.txtElement;
  20809. this.clip("nonzero");
  20810. this.endPath();
  20811. }
  20812. }
  20813. }, {
  20814. key: "setLineWidth",
  20815. value: function setLineWidth(width) {
  20816. if (width > 0) {
  20817. this.current.lineWidth = width;
  20818. }
  20819. }
  20820. }, {
  20821. key: "setLineCap",
  20822. value: function setLineCap(style) {
  20823. this.current.lineCap = LINE_CAP_STYLES[style];
  20824. }
  20825. }, {
  20826. key: "setLineJoin",
  20827. value: function setLineJoin(style) {
  20828. this.current.lineJoin = LINE_JOIN_STYLES[style];
  20829. }
  20830. }, {
  20831. key: "setMiterLimit",
  20832. value: function setMiterLimit(limit) {
  20833. this.current.miterLimit = limit;
  20834. }
  20835. }, {
  20836. key: "setStrokeAlpha",
  20837. value: function setStrokeAlpha(strokeAlpha) {
  20838. this.current.strokeAlpha = strokeAlpha;
  20839. }
  20840. }, {
  20841. key: "setStrokeRGBColor",
  20842. value: function setStrokeRGBColor(r, g, b) {
  20843. this.current.strokeColor = _util.Util.makeHexColor(r, g, b);
  20844. }
  20845. }, {
  20846. key: "setFillAlpha",
  20847. value: function setFillAlpha(fillAlpha) {
  20848. this.current.fillAlpha = fillAlpha;
  20849. }
  20850. }, {
  20851. key: "setFillRGBColor",
  20852. value: function setFillRGBColor(r, g, b) {
  20853. this.current.fillColor = _util.Util.makeHexColor(r, g, b);
  20854. this.current.tspan = this.svgFactory.createElement("svg:tspan");
  20855. this.current.xcoords = [];
  20856. this.current.ycoords = [];
  20857. }
  20858. }, {
  20859. key: "setStrokeColorN",
  20860. value: function setStrokeColorN(args) {
  20861. this.current.strokeColor = this._makeColorN_Pattern(args);
  20862. }
  20863. }, {
  20864. key: "setFillColorN",
  20865. value: function setFillColorN(args) {
  20866. this.current.fillColor = this._makeColorN_Pattern(args);
  20867. }
  20868. }, {
  20869. key: "shadingFill",
  20870. value: function shadingFill(args) {
  20871. var width = this.viewport.width;
  20872. var height = this.viewport.height;
  20873. var inv = _util.Util.inverseTransform(this.transformMatrix);
  20874. var bl = _util.Util.applyTransform([0, 0], inv);
  20875. var br = _util.Util.applyTransform([0, height], inv);
  20876. var ul = _util.Util.applyTransform([width, 0], inv);
  20877. var ur = _util.Util.applyTransform([width, height], inv);
  20878. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  20879. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  20880. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  20881. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  20882. var rect = this.svgFactory.createElement("svg:rect");
  20883. rect.setAttributeNS(null, "x", x0);
  20884. rect.setAttributeNS(null, "y", y0);
  20885. rect.setAttributeNS(null, "width", x1 - x0);
  20886. rect.setAttributeNS(null, "height", y1 - y0);
  20887. rect.setAttributeNS(null, "fill", this._makeShadingPattern(args));
  20888. if (this.current.fillAlpha < 1) {
  20889. rect.setAttributeNS(null, "fill-opacity", this.current.fillAlpha);
  20890. }
  20891. this._ensureTransformGroup().appendChild(rect);
  20892. }
  20893. }, {
  20894. key: "_makeColorN_Pattern",
  20895. value: function _makeColorN_Pattern(args) {
  20896. if (args[0] === "TilingPattern") {
  20897. return this._makeTilingPattern(args);
  20898. }
  20899. return this._makeShadingPattern(args);
  20900. }
  20901. }, {
  20902. key: "_makeTilingPattern",
  20903. value: function _makeTilingPattern(args) {
  20904. var color = args[1];
  20905. var operatorList = args[2];
  20906. var matrix = args[3] || _util.IDENTITY_MATRIX;
  20907. var _args$ = _slicedToArray(args[4], 4),
  20908. x0 = _args$[0],
  20909. y0 = _args$[1],
  20910. x1 = _args$[2],
  20911. y1 = _args$[3];
  20912. var xstep = args[5];
  20913. var ystep = args[6];
  20914. var paintType = args[7];
  20915. var tilingId = "shading".concat(shadingCount++);
  20916. var _Util$applyTransform = _util.Util.applyTransform([x0, y0], matrix),
  20917. _Util$applyTransform2 = _slicedToArray(_Util$applyTransform, 2),
  20918. tx0 = _Util$applyTransform2[0],
  20919. ty0 = _Util$applyTransform2[1];
  20920. var _Util$applyTransform3 = _util.Util.applyTransform([x1, y1], matrix),
  20921. _Util$applyTransform4 = _slicedToArray(_Util$applyTransform3, 2),
  20922. tx1 = _Util$applyTransform4[0],
  20923. ty1 = _Util$applyTransform4[1];
  20924. var _Util$singularValueDe = _util.Util.singularValueDecompose2dScale(matrix),
  20925. _Util$singularValueDe2 = _slicedToArray(_Util$singularValueDe, 2),
  20926. xscale = _Util$singularValueDe2[0],
  20927. yscale = _Util$singularValueDe2[1];
  20928. var txstep = xstep * xscale;
  20929. var tystep = ystep * yscale;
  20930. var tiling = this.svgFactory.createElement("svg:pattern");
  20931. tiling.setAttributeNS(null, "id", tilingId);
  20932. tiling.setAttributeNS(null, "patternUnits", "userSpaceOnUse");
  20933. tiling.setAttributeNS(null, "width", txstep);
  20934. tiling.setAttributeNS(null, "height", tystep);
  20935. tiling.setAttributeNS(null, "x", "".concat(tx0));
  20936. tiling.setAttributeNS(null, "y", "".concat(ty0));
  20937. var svg = this.svg;
  20938. var transformMatrix = this.transformMatrix;
  20939. var fillColor = this.current.fillColor;
  20940. var strokeColor = this.current.strokeColor;
  20941. var bbox = this.svgFactory.create(tx1 - tx0, ty1 - ty0);
  20942. this.svg = bbox;
  20943. this.transformMatrix = matrix;
  20944. if (paintType === 2) {
  20945. var cssColor = _util.Util.makeHexColor.apply(_util.Util, _toConsumableArray(color));
  20946. this.current.fillColor = cssColor;
  20947. this.current.strokeColor = cssColor;
  20948. }
  20949. this.executeOpTree(this.convertOpList(operatorList));
  20950. this.svg = svg;
  20951. this.transformMatrix = transformMatrix;
  20952. this.current.fillColor = fillColor;
  20953. this.current.strokeColor = strokeColor;
  20954. tiling.appendChild(bbox.childNodes[0]);
  20955. this.defs.appendChild(tiling);
  20956. return "url(#".concat(tilingId, ")");
  20957. }
  20958. }, {
  20959. key: "_makeShadingPattern",
  20960. value: function _makeShadingPattern(args) {
  20961. switch (args[0]) {
  20962. case "RadialAxial":
  20963. var shadingId = "shading".concat(shadingCount++);
  20964. var colorStops = args[3];
  20965. var gradient;
  20966. switch (args[1]) {
  20967. case "axial":
  20968. var point0 = args[4];
  20969. var point1 = args[5];
  20970. gradient = this.svgFactory.createElement("svg:linearGradient");
  20971. gradient.setAttributeNS(null, "id", shadingId);
  20972. gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
  20973. gradient.setAttributeNS(null, "x1", point0[0]);
  20974. gradient.setAttributeNS(null, "y1", point0[1]);
  20975. gradient.setAttributeNS(null, "x2", point1[0]);
  20976. gradient.setAttributeNS(null, "y2", point1[1]);
  20977. break;
  20978. case "radial":
  20979. var focalPoint = args[4];
  20980. var circlePoint = args[5];
  20981. var focalRadius = args[6];
  20982. var circleRadius = args[7];
  20983. gradient = this.svgFactory.createElement("svg:radialGradient");
  20984. gradient.setAttributeNS(null, "id", shadingId);
  20985. gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
  20986. gradient.setAttributeNS(null, "cx", circlePoint[0]);
  20987. gradient.setAttributeNS(null, "cy", circlePoint[1]);
  20988. gradient.setAttributeNS(null, "r", circleRadius);
  20989. gradient.setAttributeNS(null, "fx", focalPoint[0]);
  20990. gradient.setAttributeNS(null, "fy", focalPoint[1]);
  20991. gradient.setAttributeNS(null, "fr", focalRadius);
  20992. break;
  20993. default:
  20994. throw new Error("Unknown RadialAxial type: ".concat(args[1]));
  20995. }
  20996. var _iterator5 = _createForOfIteratorHelper(colorStops),
  20997. _step5;
  20998. try {
  20999. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  21000. var colorStop = _step5.value;
  21001. var stop = this.svgFactory.createElement("svg:stop");
  21002. stop.setAttributeNS(null, "offset", colorStop[0]);
  21003. stop.setAttributeNS(null, "stop-color", colorStop[1]);
  21004. gradient.appendChild(stop);
  21005. }
  21006. } catch (err) {
  21007. _iterator5.e(err);
  21008. } finally {
  21009. _iterator5.f();
  21010. }
  21011. this.defs.appendChild(gradient);
  21012. return "url(#".concat(shadingId, ")");
  21013. case "Mesh":
  21014. (0, _util.warn)("Unimplemented pattern Mesh");
  21015. return null;
  21016. case "Dummy":
  21017. return "hotpink";
  21018. default:
  21019. throw new Error("Unknown IR type: ".concat(args[0]));
  21020. }
  21021. }
  21022. }, {
  21023. key: "setDash",
  21024. value: function setDash(dashArray, dashPhase) {
  21025. this.current.dashArray = dashArray;
  21026. this.current.dashPhase = dashPhase;
  21027. }
  21028. }, {
  21029. key: "constructPath",
  21030. value: function constructPath(ops, args) {
  21031. var current = this.current;
  21032. var x = current.x,
  21033. y = current.y;
  21034. var d = [];
  21035. var j = 0;
  21036. var _iterator6 = _createForOfIteratorHelper(ops),
  21037. _step6;
  21038. try {
  21039. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  21040. var op = _step6.value;
  21041. switch (op | 0) {
  21042. case _util.OPS.rectangle:
  21043. x = args[j++];
  21044. y = args[j++];
  21045. var width = args[j++];
  21046. var height = args[j++];
  21047. var xw = x + width;
  21048. var yh = y + height;
  21049. d.push("M", pf(x), pf(y), "L", pf(xw), pf(y), "L", pf(xw), pf(yh), "L", pf(x), pf(yh), "Z");
  21050. break;
  21051. case _util.OPS.moveTo:
  21052. x = args[j++];
  21053. y = args[j++];
  21054. d.push("M", pf(x), pf(y));
  21055. break;
  21056. case _util.OPS.lineTo:
  21057. x = args[j++];
  21058. y = args[j++];
  21059. d.push("L", pf(x), pf(y));
  21060. break;
  21061. case _util.OPS.curveTo:
  21062. x = args[j + 4];
  21063. y = args[j + 5];
  21064. d.push("C", pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  21065. j += 6;
  21066. break;
  21067. case _util.OPS.curveTo2:
  21068. d.push("C", pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  21069. x = args[j + 2];
  21070. y = args[j + 3];
  21071. j += 4;
  21072. break;
  21073. case _util.OPS.curveTo3:
  21074. x = args[j + 2];
  21075. y = args[j + 3];
  21076. d.push("C", pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  21077. j += 4;
  21078. break;
  21079. case _util.OPS.closePath:
  21080. d.push("Z");
  21081. break;
  21082. }
  21083. }
  21084. } catch (err) {
  21085. _iterator6.e(err);
  21086. } finally {
  21087. _iterator6.f();
  21088. }
  21089. d = d.join(" ");
  21090. if (current.path && ops.length > 0 && ops[0] !== _util.OPS.rectangle && ops[0] !== _util.OPS.moveTo) {
  21091. d = current.path.getAttributeNS(null, "d") + d;
  21092. } else {
  21093. current.path = this.svgFactory.createElement("svg:path");
  21094. this._ensureTransformGroup().appendChild(current.path);
  21095. }
  21096. current.path.setAttributeNS(null, "d", d);
  21097. current.path.setAttributeNS(null, "fill", "none");
  21098. current.element = current.path;
  21099. current.setCurrentPoint(x, y);
  21100. }
  21101. }, {
  21102. key: "endPath",
  21103. value: function endPath() {
  21104. var current = this.current;
  21105. current.path = null;
  21106. if (!this.pendingClip) {
  21107. return;
  21108. }
  21109. if (!current.element) {
  21110. this.pendingClip = null;
  21111. return;
  21112. }
  21113. var clipId = "clippath".concat(clipCount++);
  21114. var clipPath = this.svgFactory.createElement("svg:clipPath");
  21115. clipPath.setAttributeNS(null, "id", clipId);
  21116. clipPath.setAttributeNS(null, "transform", pm(this.transformMatrix));
  21117. var clipElement = current.element.cloneNode(true);
  21118. if (this.pendingClip === "evenodd") {
  21119. clipElement.setAttributeNS(null, "clip-rule", "evenodd");
  21120. } else {
  21121. clipElement.setAttributeNS(null, "clip-rule", "nonzero");
  21122. }
  21123. this.pendingClip = null;
  21124. clipPath.appendChild(clipElement);
  21125. this.defs.appendChild(clipPath);
  21126. if (current.activeClipUrl) {
  21127. current.clipGroup = null;
  21128. this.extraStack.forEach(function (prev) {
  21129. prev.clipGroup = null;
  21130. });
  21131. clipPath.setAttributeNS(null, "clip-path", current.activeClipUrl);
  21132. }
  21133. current.activeClipUrl = "url(#".concat(clipId, ")");
  21134. this.tgrp = null;
  21135. }
  21136. }, {
  21137. key: "clip",
  21138. value: function clip(type) {
  21139. this.pendingClip = type;
  21140. }
  21141. }, {
  21142. key: "closePath",
  21143. value: function closePath() {
  21144. var current = this.current;
  21145. if (current.path) {
  21146. var d = "".concat(current.path.getAttributeNS(null, "d"), "Z");
  21147. current.path.setAttributeNS(null, "d", d);
  21148. }
  21149. }
  21150. }, {
  21151. key: "setLeading",
  21152. value: function setLeading(leading) {
  21153. this.current.leading = -leading;
  21154. }
  21155. }, {
  21156. key: "setTextRise",
  21157. value: function setTextRise(textRise) {
  21158. this.current.textRise = textRise;
  21159. }
  21160. }, {
  21161. key: "setTextRenderingMode",
  21162. value: function setTextRenderingMode(textRenderingMode) {
  21163. this.current.textRenderingMode = textRenderingMode;
  21164. }
  21165. }, {
  21166. key: "setHScale",
  21167. value: function setHScale(scale) {
  21168. this.current.textHScale = scale / 100;
  21169. }
  21170. }, {
  21171. key: "setRenderingIntent",
  21172. value: function setRenderingIntent(intent) {}
  21173. }, {
  21174. key: "setFlatness",
  21175. value: function setFlatness(flatness) {}
  21176. }, {
  21177. key: "setGState",
  21178. value: function setGState(states) {
  21179. var _iterator7 = _createForOfIteratorHelper(states),
  21180. _step7;
  21181. try {
  21182. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  21183. var _step7$value = _slicedToArray(_step7.value, 2),
  21184. key = _step7$value[0],
  21185. value = _step7$value[1];
  21186. switch (key) {
  21187. case "LW":
  21188. this.setLineWidth(value);
  21189. break;
  21190. case "LC":
  21191. this.setLineCap(value);
  21192. break;
  21193. case "LJ":
  21194. this.setLineJoin(value);
  21195. break;
  21196. case "ML":
  21197. this.setMiterLimit(value);
  21198. break;
  21199. case "D":
  21200. this.setDash(value[0], value[1]);
  21201. break;
  21202. case "RI":
  21203. this.setRenderingIntent(value);
  21204. break;
  21205. case "FL":
  21206. this.setFlatness(value);
  21207. break;
  21208. case "Font":
  21209. this.setFont(value);
  21210. break;
  21211. case "CA":
  21212. this.setStrokeAlpha(value);
  21213. break;
  21214. case "ca":
  21215. this.setFillAlpha(value);
  21216. break;
  21217. default:
  21218. (0, _util.warn)("Unimplemented graphic state operator ".concat(key));
  21219. break;
  21220. }
  21221. }
  21222. } catch (err) {
  21223. _iterator7.e(err);
  21224. } finally {
  21225. _iterator7.f();
  21226. }
  21227. }
  21228. }, {
  21229. key: "fill",
  21230. value: function fill() {
  21231. var current = this.current;
  21232. if (current.element) {
  21233. current.element.setAttributeNS(null, "fill", current.fillColor);
  21234. current.element.setAttributeNS(null, "fill-opacity", current.fillAlpha);
  21235. this.endPath();
  21236. }
  21237. }
  21238. }, {
  21239. key: "stroke",
  21240. value: function stroke() {
  21241. var current = this.current;
  21242. if (current.element) {
  21243. this._setStrokeAttributes(current.element);
  21244. current.element.setAttributeNS(null, "fill", "none");
  21245. this.endPath();
  21246. }
  21247. }
  21248. }, {
  21249. key: "_setStrokeAttributes",
  21250. value: function _setStrokeAttributes(element) {
  21251. var lineWidthScale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  21252. var current = this.current;
  21253. var dashArray = current.dashArray;
  21254. if (lineWidthScale !== 1 && dashArray.length > 0) {
  21255. dashArray = dashArray.map(function (value) {
  21256. return lineWidthScale * value;
  21257. });
  21258. }
  21259. element.setAttributeNS(null, "stroke", current.strokeColor);
  21260. element.setAttributeNS(null, "stroke-opacity", current.strokeAlpha);
  21261. element.setAttributeNS(null, "stroke-miterlimit", pf(current.miterLimit));
  21262. element.setAttributeNS(null, "stroke-linecap", current.lineCap);
  21263. element.setAttributeNS(null, "stroke-linejoin", current.lineJoin);
  21264. element.setAttributeNS(null, "stroke-width", pf(lineWidthScale * current.lineWidth) + "px");
  21265. element.setAttributeNS(null, "stroke-dasharray", dashArray.map(pf).join(" "));
  21266. element.setAttributeNS(null, "stroke-dashoffset", pf(lineWidthScale * current.dashPhase) + "px");
  21267. }
  21268. }, {
  21269. key: "eoFill",
  21270. value: function eoFill() {
  21271. if (this.current.element) {
  21272. this.current.element.setAttributeNS(null, "fill-rule", "evenodd");
  21273. }
  21274. this.fill();
  21275. }
  21276. }, {
  21277. key: "fillStroke",
  21278. value: function fillStroke() {
  21279. this.stroke();
  21280. this.fill();
  21281. }
  21282. }, {
  21283. key: "eoFillStroke",
  21284. value: function eoFillStroke() {
  21285. if (this.current.element) {
  21286. this.current.element.setAttributeNS(null, "fill-rule", "evenodd");
  21287. }
  21288. this.fillStroke();
  21289. }
  21290. }, {
  21291. key: "closeStroke",
  21292. value: function closeStroke() {
  21293. this.closePath();
  21294. this.stroke();
  21295. }
  21296. }, {
  21297. key: "closeFillStroke",
  21298. value: function closeFillStroke() {
  21299. this.closePath();
  21300. this.fillStroke();
  21301. }
  21302. }, {
  21303. key: "closeEOFillStroke",
  21304. value: function closeEOFillStroke() {
  21305. this.closePath();
  21306. this.eoFillStroke();
  21307. }
  21308. }, {
  21309. key: "paintSolidColorImageMask",
  21310. value: function paintSolidColorImageMask() {
  21311. var rect = this.svgFactory.createElement("svg:rect");
  21312. rect.setAttributeNS(null, "x", "0");
  21313. rect.setAttributeNS(null, "y", "0");
  21314. rect.setAttributeNS(null, "width", "1px");
  21315. rect.setAttributeNS(null, "height", "1px");
  21316. rect.setAttributeNS(null, "fill", this.current.fillColor);
  21317. this._ensureTransformGroup().appendChild(rect);
  21318. }
  21319. }, {
  21320. key: "paintImageXObject",
  21321. value: function paintImageXObject(objId) {
  21322. var imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
  21323. if (!imgData) {
  21324. (0, _util.warn)("Dependent image with object ID ".concat(objId, " is not ready yet"));
  21325. return;
  21326. }
  21327. this.paintInlineImageXObject(imgData);
  21328. }
  21329. }, {
  21330. key: "paintInlineImageXObject",
  21331. value: function paintInlineImageXObject(imgData, mask) {
  21332. var width = imgData.width;
  21333. var height = imgData.height;
  21334. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
  21335. var cliprect = this.svgFactory.createElement("svg:rect");
  21336. cliprect.setAttributeNS(null, "x", "0");
  21337. cliprect.setAttributeNS(null, "y", "0");
  21338. cliprect.setAttributeNS(null, "width", pf(width));
  21339. cliprect.setAttributeNS(null, "height", pf(height));
  21340. this.current.element = cliprect;
  21341. this.clip("nonzero");
  21342. var imgEl = this.svgFactory.createElement("svg:image");
  21343. imgEl.setAttributeNS(XLINK_NS, "xlink:href", imgSrc);
  21344. imgEl.setAttributeNS(null, "x", "0");
  21345. imgEl.setAttributeNS(null, "y", pf(-height));
  21346. imgEl.setAttributeNS(null, "width", pf(width) + "px");
  21347. imgEl.setAttributeNS(null, "height", pf(height) + "px");
  21348. imgEl.setAttributeNS(null, "transform", "scale(".concat(pf(1 / width), " ").concat(pf(-1 / height), ")"));
  21349. if (mask) {
  21350. mask.appendChild(imgEl);
  21351. } else {
  21352. this._ensureTransformGroup().appendChild(imgEl);
  21353. }
  21354. }
  21355. }, {
  21356. key: "paintImageMaskXObject",
  21357. value: function paintImageMaskXObject(imgData) {
  21358. var current = this.current;
  21359. var width = imgData.width;
  21360. var height = imgData.height;
  21361. var fillColor = current.fillColor;
  21362. current.maskId = "mask".concat(maskCount++);
  21363. var mask = this.svgFactory.createElement("svg:mask");
  21364. mask.setAttributeNS(null, "id", current.maskId);
  21365. var rect = this.svgFactory.createElement("svg:rect");
  21366. rect.setAttributeNS(null, "x", "0");
  21367. rect.setAttributeNS(null, "y", "0");
  21368. rect.setAttributeNS(null, "width", pf(width));
  21369. rect.setAttributeNS(null, "height", pf(height));
  21370. rect.setAttributeNS(null, "fill", fillColor);
  21371. rect.setAttributeNS(null, "mask", "url(#".concat(current.maskId, ")"));
  21372. this.defs.appendChild(mask);
  21373. this._ensureTransformGroup().appendChild(rect);
  21374. this.paintInlineImageXObject(imgData, mask);
  21375. }
  21376. }, {
  21377. key: "paintFormXObjectBegin",
  21378. value: function paintFormXObjectBegin(matrix, bbox) {
  21379. if (Array.isArray(matrix) && matrix.length === 6) {
  21380. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  21381. }
  21382. if (bbox) {
  21383. var width = bbox[2] - bbox[0];
  21384. var height = bbox[3] - bbox[1];
  21385. var cliprect = this.svgFactory.createElement("svg:rect");
  21386. cliprect.setAttributeNS(null, "x", bbox[0]);
  21387. cliprect.setAttributeNS(null, "y", bbox[1]);
  21388. cliprect.setAttributeNS(null, "width", pf(width));
  21389. cliprect.setAttributeNS(null, "height", pf(height));
  21390. this.current.element = cliprect;
  21391. this.clip("nonzero");
  21392. this.endPath();
  21393. }
  21394. }
  21395. }, {
  21396. key: "paintFormXObjectEnd",
  21397. value: function paintFormXObjectEnd() {}
  21398. }, {
  21399. key: "_initialize",
  21400. value: function _initialize(viewport) {
  21401. var svg = this.svgFactory.create(viewport.width, viewport.height);
  21402. var definitions = this.svgFactory.createElement("svg:defs");
  21403. svg.appendChild(definitions);
  21404. this.defs = definitions;
  21405. var rootGroup = this.svgFactory.createElement("svg:g");
  21406. rootGroup.setAttributeNS(null, "transform", pm(viewport.transform));
  21407. svg.appendChild(rootGroup);
  21408. this.svg = rootGroup;
  21409. return svg;
  21410. }
  21411. }, {
  21412. key: "_ensureClipGroup",
  21413. value: function _ensureClipGroup() {
  21414. if (!this.current.clipGroup) {
  21415. var clipGroup = this.svgFactory.createElement("svg:g");
  21416. clipGroup.setAttributeNS(null, "clip-path", this.current.activeClipUrl);
  21417. this.svg.appendChild(clipGroup);
  21418. this.current.clipGroup = clipGroup;
  21419. }
  21420. return this.current.clipGroup;
  21421. }
  21422. }, {
  21423. key: "_ensureTransformGroup",
  21424. value: function _ensureTransformGroup() {
  21425. if (!this.tgrp) {
  21426. this.tgrp = this.svgFactory.createElement("svg:g");
  21427. this.tgrp.setAttributeNS(null, "transform", pm(this.transformMatrix));
  21428. if (this.current.activeClipUrl) {
  21429. this._ensureClipGroup().appendChild(this.tgrp);
  21430. } else {
  21431. this.svg.appendChild(this.tgrp);
  21432. }
  21433. }
  21434. return this.tgrp;
  21435. }
  21436. }]);
  21437. return SVGGraphics;
  21438. }();
  21439. }
  21440. /***/ }),
  21441. /* 153 */
  21442. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  21443. "use strict";
  21444. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  21445. Object.defineProperty(exports, "__esModule", ({
  21446. value: true
  21447. }));
  21448. exports.PDFNodeStream = void 0;
  21449. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  21450. var _util = __w_pdfjs_require__(4);
  21451. var _network_utils = __w_pdfjs_require__(154);
  21452. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  21453. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  21454. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  21455. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  21456. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  21457. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  21458. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  21459. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  21460. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  21461. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  21462. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21463. 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); } }
  21464. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21465. ;
  21466. var fs = require("fs");
  21467. var http = require("http");
  21468. var https = require("https");
  21469. var url = require("url");
  21470. var fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
  21471. function parseUrl(sourceUrl) {
  21472. var parsedUrl = url.parse(sourceUrl);
  21473. if (parsedUrl.protocol === "file:" || parsedUrl.host) {
  21474. return parsedUrl;
  21475. }
  21476. if (/^[a-z]:[/\\]/i.test(sourceUrl)) {
  21477. return url.parse("file:///".concat(sourceUrl));
  21478. }
  21479. if (!parsedUrl.host) {
  21480. parsedUrl.protocol = "file:";
  21481. }
  21482. return parsedUrl;
  21483. }
  21484. var PDFNodeStream = /*#__PURE__*/function () {
  21485. function PDFNodeStream(source) {
  21486. _classCallCheck(this, PDFNodeStream);
  21487. this.source = source;
  21488. this.url = parseUrl(source.url);
  21489. this.isHttp = this.url.protocol === "http:" || this.url.protocol === "https:";
  21490. this.isFsUrl = this.url.protocol === "file:";
  21491. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  21492. this._fullRequestReader = null;
  21493. this._rangeRequestReaders = [];
  21494. }
  21495. _createClass(PDFNodeStream, [{
  21496. key: "getFullReader",
  21497. value: function getFullReader() {
  21498. (0, _util.assert)(!this._fullRequestReader, "PDFNodeStream.getFullReader can only be called once.");
  21499. this._fullRequestReader = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
  21500. return this._fullRequestReader;
  21501. }
  21502. }, {
  21503. key: "getRangeReader",
  21504. value: function getRangeReader(start, end) {
  21505. if (end <= this._progressiveDataLength) {
  21506. return null;
  21507. }
  21508. var rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
  21509. this._rangeRequestReaders.push(rangeReader);
  21510. return rangeReader;
  21511. }
  21512. }, {
  21513. key: "cancelAllRequests",
  21514. value: function cancelAllRequests(reason) {
  21515. if (this._fullRequestReader) {
  21516. this._fullRequestReader.cancel(reason);
  21517. }
  21518. var readers = this._rangeRequestReaders.slice(0);
  21519. readers.forEach(function (reader) {
  21520. reader.cancel(reason);
  21521. });
  21522. }
  21523. }, {
  21524. key: "_progressiveDataLength",
  21525. get: function get() {
  21526. var _this$_fullRequestRea, _this$_fullRequestRea2;
  21527. return (_this$_fullRequestRea = (_this$_fullRequestRea2 = this._fullRequestReader) === null || _this$_fullRequestRea2 === void 0 ? void 0 : _this$_fullRequestRea2._loaded) !== null && _this$_fullRequestRea !== void 0 ? _this$_fullRequestRea : 0;
  21528. }
  21529. }]);
  21530. return PDFNodeStream;
  21531. }();
  21532. exports.PDFNodeStream = PDFNodeStream;
  21533. var BaseFullReader = /*#__PURE__*/function () {
  21534. function BaseFullReader(stream) {
  21535. _classCallCheck(this, BaseFullReader);
  21536. this._url = stream.url;
  21537. this._done = false;
  21538. this._storedError = null;
  21539. this.onProgress = null;
  21540. var source = stream.source;
  21541. this._contentLength = source.length;
  21542. this._loaded = 0;
  21543. this._filename = null;
  21544. this._disableRange = source.disableRange || false;
  21545. this._rangeChunkSize = source.rangeChunkSize;
  21546. if (!this._rangeChunkSize && !this._disableRange) {
  21547. this._disableRange = true;
  21548. }
  21549. this._isStreamingSupported = !source.disableStream;
  21550. this._isRangeSupported = !source.disableRange;
  21551. this._readableStream = null;
  21552. this._readCapability = (0, _util.createPromiseCapability)();
  21553. this._headersCapability = (0, _util.createPromiseCapability)();
  21554. }
  21555. _createClass(BaseFullReader, [{
  21556. key: "read",
  21557. value: function () {
  21558. var _read = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  21559. var chunk, buffer;
  21560. return _regenerator["default"].wrap(function _callee$(_context) {
  21561. while (1) {
  21562. switch (_context.prev = _context.next) {
  21563. case 0:
  21564. _context.next = 2;
  21565. return this._readCapability.promise;
  21566. case 2:
  21567. if (!this._done) {
  21568. _context.next = 4;
  21569. break;
  21570. }
  21571. return _context.abrupt("return", {
  21572. value: undefined,
  21573. done: true
  21574. });
  21575. case 4:
  21576. if (!this._storedError) {
  21577. _context.next = 6;
  21578. break;
  21579. }
  21580. throw this._storedError;
  21581. case 6:
  21582. chunk = this._readableStream.read();
  21583. if (!(chunk === null)) {
  21584. _context.next = 10;
  21585. break;
  21586. }
  21587. this._readCapability = (0, _util.createPromiseCapability)();
  21588. return _context.abrupt("return", this.read());
  21589. case 10:
  21590. this._loaded += chunk.length;
  21591. if (this.onProgress) {
  21592. this.onProgress({
  21593. loaded: this._loaded,
  21594. total: this._contentLength
  21595. });
  21596. }
  21597. buffer = new Uint8Array(chunk).buffer;
  21598. return _context.abrupt("return", {
  21599. value: buffer,
  21600. done: false
  21601. });
  21602. case 14:
  21603. case "end":
  21604. return _context.stop();
  21605. }
  21606. }
  21607. }, _callee, this);
  21608. }));
  21609. function read() {
  21610. return _read.apply(this, arguments);
  21611. }
  21612. return read;
  21613. }()
  21614. }, {
  21615. key: "cancel",
  21616. value: function cancel(reason) {
  21617. if (!this._readableStream) {
  21618. this._error(reason);
  21619. return;
  21620. }
  21621. this._readableStream.destroy(reason);
  21622. }
  21623. }, {
  21624. key: "_error",
  21625. value: function _error(reason) {
  21626. this._storedError = reason;
  21627. this._readCapability.resolve();
  21628. }
  21629. }, {
  21630. key: "_setReadableStream",
  21631. value: function _setReadableStream(readableStream) {
  21632. var _this = this;
  21633. this._readableStream = readableStream;
  21634. readableStream.on("readable", function () {
  21635. _this._readCapability.resolve();
  21636. });
  21637. readableStream.on("end", function () {
  21638. readableStream.destroy();
  21639. _this._done = true;
  21640. _this._readCapability.resolve();
  21641. });
  21642. readableStream.on("error", function (reason) {
  21643. _this._error(reason);
  21644. });
  21645. if (!this._isStreamingSupported && this._isRangeSupported) {
  21646. this._error(new _util.AbortException("streaming is disabled"));
  21647. }
  21648. if (this._storedError) {
  21649. this._readableStream.destroy(this._storedError);
  21650. }
  21651. }
  21652. }, {
  21653. key: "headersReady",
  21654. get: function get() {
  21655. return this._headersCapability.promise;
  21656. }
  21657. }, {
  21658. key: "filename",
  21659. get: function get() {
  21660. return this._filename;
  21661. }
  21662. }, {
  21663. key: "contentLength",
  21664. get: function get() {
  21665. return this._contentLength;
  21666. }
  21667. }, {
  21668. key: "isRangeSupported",
  21669. get: function get() {
  21670. return this._isRangeSupported;
  21671. }
  21672. }, {
  21673. key: "isStreamingSupported",
  21674. get: function get() {
  21675. return this._isStreamingSupported;
  21676. }
  21677. }]);
  21678. return BaseFullReader;
  21679. }();
  21680. var BaseRangeReader = /*#__PURE__*/function () {
  21681. function BaseRangeReader(stream) {
  21682. _classCallCheck(this, BaseRangeReader);
  21683. this._url = stream.url;
  21684. this._done = false;
  21685. this._storedError = null;
  21686. this.onProgress = null;
  21687. this._loaded = 0;
  21688. this._readableStream = null;
  21689. this._readCapability = (0, _util.createPromiseCapability)();
  21690. var source = stream.source;
  21691. this._isStreamingSupported = !source.disableStream;
  21692. }
  21693. _createClass(BaseRangeReader, [{
  21694. key: "read",
  21695. value: function () {
  21696. var _read2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  21697. var chunk, buffer;
  21698. return _regenerator["default"].wrap(function _callee2$(_context2) {
  21699. while (1) {
  21700. switch (_context2.prev = _context2.next) {
  21701. case 0:
  21702. _context2.next = 2;
  21703. return this._readCapability.promise;
  21704. case 2:
  21705. if (!this._done) {
  21706. _context2.next = 4;
  21707. break;
  21708. }
  21709. return _context2.abrupt("return", {
  21710. value: undefined,
  21711. done: true
  21712. });
  21713. case 4:
  21714. if (!this._storedError) {
  21715. _context2.next = 6;
  21716. break;
  21717. }
  21718. throw this._storedError;
  21719. case 6:
  21720. chunk = this._readableStream.read();
  21721. if (!(chunk === null)) {
  21722. _context2.next = 10;
  21723. break;
  21724. }
  21725. this._readCapability = (0, _util.createPromiseCapability)();
  21726. return _context2.abrupt("return", this.read());
  21727. case 10:
  21728. this._loaded += chunk.length;
  21729. if (this.onProgress) {
  21730. this.onProgress({
  21731. loaded: this._loaded
  21732. });
  21733. }
  21734. buffer = new Uint8Array(chunk).buffer;
  21735. return _context2.abrupt("return", {
  21736. value: buffer,
  21737. done: false
  21738. });
  21739. case 14:
  21740. case "end":
  21741. return _context2.stop();
  21742. }
  21743. }
  21744. }, _callee2, this);
  21745. }));
  21746. function read() {
  21747. return _read2.apply(this, arguments);
  21748. }
  21749. return read;
  21750. }()
  21751. }, {
  21752. key: "cancel",
  21753. value: function cancel(reason) {
  21754. if (!this._readableStream) {
  21755. this._error(reason);
  21756. return;
  21757. }
  21758. this._readableStream.destroy(reason);
  21759. }
  21760. }, {
  21761. key: "_error",
  21762. value: function _error(reason) {
  21763. this._storedError = reason;
  21764. this._readCapability.resolve();
  21765. }
  21766. }, {
  21767. key: "_setReadableStream",
  21768. value: function _setReadableStream(readableStream) {
  21769. var _this2 = this;
  21770. this._readableStream = readableStream;
  21771. readableStream.on("readable", function () {
  21772. _this2._readCapability.resolve();
  21773. });
  21774. readableStream.on("end", function () {
  21775. readableStream.destroy();
  21776. _this2._done = true;
  21777. _this2._readCapability.resolve();
  21778. });
  21779. readableStream.on("error", function (reason) {
  21780. _this2._error(reason);
  21781. });
  21782. if (this._storedError) {
  21783. this._readableStream.destroy(this._storedError);
  21784. }
  21785. }
  21786. }, {
  21787. key: "isStreamingSupported",
  21788. get: function get() {
  21789. return this._isStreamingSupported;
  21790. }
  21791. }]);
  21792. return BaseRangeReader;
  21793. }();
  21794. function createRequestOptions(parsedUrl, headers) {
  21795. return {
  21796. protocol: parsedUrl.protocol,
  21797. auth: parsedUrl.auth,
  21798. host: parsedUrl.hostname,
  21799. port: parsedUrl.port,
  21800. path: parsedUrl.path,
  21801. method: "GET",
  21802. headers: headers
  21803. };
  21804. }
  21805. var PDFNodeStreamFullReader = /*#__PURE__*/function (_BaseFullReader) {
  21806. _inherits(PDFNodeStreamFullReader, _BaseFullReader);
  21807. var _super = _createSuper(PDFNodeStreamFullReader);
  21808. function PDFNodeStreamFullReader(stream) {
  21809. var _this3;
  21810. _classCallCheck(this, PDFNodeStreamFullReader);
  21811. _this3 = _super.call(this, stream);
  21812. var handleResponse = function handleResponse(response) {
  21813. if (response.statusCode === 404) {
  21814. var error = new _util.MissingPDFException("Missing PDF \"".concat(_this3._url, "\"."));
  21815. _this3._storedError = error;
  21816. _this3._headersCapability.reject(error);
  21817. return;
  21818. }
  21819. _this3._headersCapability.resolve();
  21820. _this3._setReadableStream(response);
  21821. var getResponseHeader = function getResponseHeader(name) {
  21822. return _this3._readableStream.headers[name.toLowerCase()];
  21823. };
  21824. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  21825. getResponseHeader: getResponseHeader,
  21826. isHttp: stream.isHttp,
  21827. rangeChunkSize: _this3._rangeChunkSize,
  21828. disableRange: _this3._disableRange
  21829. }),
  21830. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  21831. suggestedLength = _validateRangeRequest.suggestedLength;
  21832. _this3._isRangeSupported = allowRangeRequests;
  21833. _this3._contentLength = suggestedLength || _this3._contentLength;
  21834. _this3._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  21835. };
  21836. _this3._request = null;
  21837. if (_this3._url.protocol === "http:") {
  21838. _this3._request = http.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  21839. } else {
  21840. _this3._request = https.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  21841. }
  21842. _this3._request.on("error", function (reason) {
  21843. _this3._storedError = reason;
  21844. _this3._headersCapability.reject(reason);
  21845. });
  21846. _this3._request.end();
  21847. return _this3;
  21848. }
  21849. return PDFNodeStreamFullReader;
  21850. }(BaseFullReader);
  21851. var PDFNodeStreamRangeReader = /*#__PURE__*/function (_BaseRangeReader) {
  21852. _inherits(PDFNodeStreamRangeReader, _BaseRangeReader);
  21853. var _super2 = _createSuper(PDFNodeStreamRangeReader);
  21854. function PDFNodeStreamRangeReader(stream, start, end) {
  21855. var _this4;
  21856. _classCallCheck(this, PDFNodeStreamRangeReader);
  21857. _this4 = _super2.call(this, stream);
  21858. _this4._httpHeaders = {};
  21859. for (var property in stream.httpHeaders) {
  21860. var value = stream.httpHeaders[property];
  21861. if (typeof value === "undefined") {
  21862. continue;
  21863. }
  21864. _this4._httpHeaders[property] = value;
  21865. }
  21866. _this4._httpHeaders.Range = "bytes=".concat(start, "-").concat(end - 1);
  21867. var handleResponse = function handleResponse(response) {
  21868. if (response.statusCode === 404) {
  21869. var error = new _util.MissingPDFException("Missing PDF \"".concat(_this4._url, "\"."));
  21870. _this4._storedError = error;
  21871. return;
  21872. }
  21873. _this4._setReadableStream(response);
  21874. };
  21875. _this4._request = null;
  21876. if (_this4._url.protocol === "http:") {
  21877. _this4._request = http.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  21878. } else {
  21879. _this4._request = https.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  21880. }
  21881. _this4._request.on("error", function (reason) {
  21882. _this4._storedError = reason;
  21883. });
  21884. _this4._request.end();
  21885. return _this4;
  21886. }
  21887. return PDFNodeStreamRangeReader;
  21888. }(BaseRangeReader);
  21889. var PDFNodeStreamFsFullReader = /*#__PURE__*/function (_BaseFullReader2) {
  21890. _inherits(PDFNodeStreamFsFullReader, _BaseFullReader2);
  21891. var _super3 = _createSuper(PDFNodeStreamFsFullReader);
  21892. function PDFNodeStreamFsFullReader(stream) {
  21893. var _this5;
  21894. _classCallCheck(this, PDFNodeStreamFsFullReader);
  21895. _this5 = _super3.call(this, stream);
  21896. var path = decodeURIComponent(_this5._url.path);
  21897. if (fileUriRegex.test(_this5._url.href)) {
  21898. path = path.replace(/^\//, "");
  21899. }
  21900. fs.lstat(path, function (error, stat) {
  21901. if (error) {
  21902. if (error.code === "ENOENT") {
  21903. error = new _util.MissingPDFException("Missing PDF \"".concat(path, "\"."));
  21904. }
  21905. _this5._storedError = error;
  21906. _this5._headersCapability.reject(error);
  21907. return;
  21908. }
  21909. _this5._contentLength = stat.size;
  21910. _this5._setReadableStream(fs.createReadStream(path));
  21911. _this5._headersCapability.resolve();
  21912. });
  21913. return _this5;
  21914. }
  21915. return PDFNodeStreamFsFullReader;
  21916. }(BaseFullReader);
  21917. var PDFNodeStreamFsRangeReader = /*#__PURE__*/function (_BaseRangeReader2) {
  21918. _inherits(PDFNodeStreamFsRangeReader, _BaseRangeReader2);
  21919. var _super4 = _createSuper(PDFNodeStreamFsRangeReader);
  21920. function PDFNodeStreamFsRangeReader(stream, start, end) {
  21921. var _this6;
  21922. _classCallCheck(this, PDFNodeStreamFsRangeReader);
  21923. _this6 = _super4.call(this, stream);
  21924. var path = decodeURIComponent(_this6._url.path);
  21925. if (fileUriRegex.test(_this6._url.href)) {
  21926. path = path.replace(/^\//, "");
  21927. }
  21928. _this6._setReadableStream(fs.createReadStream(path, {
  21929. start: start,
  21930. end: end - 1
  21931. }));
  21932. return _this6;
  21933. }
  21934. return PDFNodeStreamFsRangeReader;
  21935. }(BaseRangeReader);
  21936. /***/ }),
  21937. /* 154 */
  21938. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  21939. "use strict";
  21940. Object.defineProperty(exports, "__esModule", ({
  21941. value: true
  21942. }));
  21943. exports.createResponseStatusError = createResponseStatusError;
  21944. exports.extractFilenameFromHeader = extractFilenameFromHeader;
  21945. exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
  21946. exports.validateResponseStatus = validateResponseStatus;
  21947. var _util = __w_pdfjs_require__(4);
  21948. var _content_disposition = __w_pdfjs_require__(155);
  21949. function validateRangeRequestCapabilities(_ref) {
  21950. var getResponseHeader = _ref.getResponseHeader,
  21951. isHttp = _ref.isHttp,
  21952. rangeChunkSize = _ref.rangeChunkSize,
  21953. disableRange = _ref.disableRange;
  21954. (0, _util.assert)(rangeChunkSize > 0, "Range chunk size must be larger than zero");
  21955. var returnValues = {
  21956. allowRangeRequests: false,
  21957. suggestedLength: undefined
  21958. };
  21959. var length = parseInt(getResponseHeader("Content-Length"), 10);
  21960. if (!Number.isInteger(length)) {
  21961. return returnValues;
  21962. }
  21963. returnValues.suggestedLength = length;
  21964. if (length <= 2 * rangeChunkSize) {
  21965. return returnValues;
  21966. }
  21967. if (disableRange || !isHttp) {
  21968. return returnValues;
  21969. }
  21970. if (getResponseHeader("Accept-Ranges") !== "bytes") {
  21971. return returnValues;
  21972. }
  21973. var contentEncoding = getResponseHeader("Content-Encoding") || "identity";
  21974. if (contentEncoding !== "identity") {
  21975. return returnValues;
  21976. }
  21977. returnValues.allowRangeRequests = true;
  21978. return returnValues;
  21979. }
  21980. function extractFilenameFromHeader(getResponseHeader) {
  21981. var contentDisposition = getResponseHeader("Content-Disposition");
  21982. if (contentDisposition) {
  21983. var filename = (0, _content_disposition.getFilenameFromContentDispositionHeader)(contentDisposition);
  21984. if (filename.includes("%")) {
  21985. try {
  21986. filename = decodeURIComponent(filename);
  21987. } catch (ex) {}
  21988. }
  21989. if (/\.pdf$/i.test(filename)) {
  21990. return filename;
  21991. }
  21992. }
  21993. return null;
  21994. }
  21995. function createResponseStatusError(status, url) {
  21996. if (status === 404 || status === 0 && url.startsWith("file:")) {
  21997. return new _util.MissingPDFException('Missing PDF "' + url + '".');
  21998. }
  21999. return new _util.UnexpectedResponseException("Unexpected server response (" + status + ') while retrieving PDF "' + url + '".', status);
  22000. }
  22001. function validateResponseStatus(status) {
  22002. return status === 200 || status === 206;
  22003. }
  22004. /***/ }),
  22005. /* 155 */
  22006. /***/ ((__unused_webpack_module, exports) => {
  22007. "use strict";
  22008. Object.defineProperty(exports, "__esModule", ({
  22009. value: true
  22010. }));
  22011. exports.getFilenameFromContentDispositionHeader = getFilenameFromContentDispositionHeader;
  22012. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  22013. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  22014. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  22015. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  22016. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  22017. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  22018. function getFilenameFromContentDispositionHeader(contentDisposition) {
  22019. var needsEncodingFixup = true;
  22020. var tmp = toParamRegExp("filename\\*", "i").exec(contentDisposition);
  22021. if (tmp) {
  22022. tmp = tmp[1];
  22023. var filename = rfc2616unquote(tmp);
  22024. filename = unescape(filename);
  22025. filename = rfc5987decode(filename);
  22026. filename = rfc2047decode(filename);
  22027. return fixupEncoding(filename);
  22028. }
  22029. tmp = rfc2231getparam(contentDisposition);
  22030. if (tmp) {
  22031. var _filename = rfc2047decode(tmp);
  22032. return fixupEncoding(_filename);
  22033. }
  22034. tmp = toParamRegExp("filename", "i").exec(contentDisposition);
  22035. if (tmp) {
  22036. tmp = tmp[1];
  22037. var _filename2 = rfc2616unquote(tmp);
  22038. _filename2 = rfc2047decode(_filename2);
  22039. return fixupEncoding(_filename2);
  22040. }
  22041. function toParamRegExp(attributePattern, flags) {
  22042. return new RegExp("(?:^|;)\\s*" + attributePattern + "\\s*=\\s*" + "(" + '[^";\\s][^;\\s]*' + "|" + '"(?:[^"\\\\]|\\\\"?)+"?' + ")", flags);
  22043. }
  22044. function textdecode(encoding, value) {
  22045. if (encoding) {
  22046. if (!/^[\x00-\xFF]+$/.test(value)) {
  22047. return value;
  22048. }
  22049. try {
  22050. var decoder = new TextDecoder(encoding, {
  22051. fatal: true
  22052. });
  22053. var bytes = Array.from(value, function (ch) {
  22054. return ch.charCodeAt(0) & 0xff;
  22055. });
  22056. value = decoder.decode(new Uint8Array(bytes));
  22057. needsEncodingFixup = false;
  22058. } catch (e) {
  22059. if (/^utf-?8$/i.test(encoding)) {
  22060. try {
  22061. value = decodeURIComponent(escape(value));
  22062. needsEncodingFixup = false;
  22063. } catch (err) {}
  22064. }
  22065. }
  22066. }
  22067. return value;
  22068. }
  22069. function fixupEncoding(value) {
  22070. if (needsEncodingFixup && /[\x80-\xff]/.test(value)) {
  22071. value = textdecode("utf-8", value);
  22072. if (needsEncodingFixup) {
  22073. value = textdecode("iso-8859-1", value);
  22074. }
  22075. }
  22076. return value;
  22077. }
  22078. function rfc2231getparam(contentDispositionStr) {
  22079. var matches = [];
  22080. var match;
  22081. var iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
  22082. while ((match = iter.exec(contentDispositionStr)) !== null) {
  22083. var _match = match,
  22084. _match2 = _slicedToArray(_match, 4),
  22085. n = _match2[1],
  22086. quot = _match2[2],
  22087. part = _match2[3];
  22088. n = parseInt(n, 10);
  22089. if (n in matches) {
  22090. if (n === 0) {
  22091. break;
  22092. }
  22093. continue;
  22094. }
  22095. matches[n] = [quot, part];
  22096. }
  22097. var parts = [];
  22098. for (var _n2 = 0; _n2 < matches.length; ++_n2) {
  22099. if (!(_n2 in matches)) {
  22100. break;
  22101. }
  22102. var _matches$_n = _slicedToArray(matches[_n2], 2),
  22103. _quot = _matches$_n[0],
  22104. _part = _matches$_n[1];
  22105. _part = rfc2616unquote(_part);
  22106. if (_quot) {
  22107. _part = unescape(_part);
  22108. if (_n2 === 0) {
  22109. _part = rfc5987decode(_part);
  22110. }
  22111. }
  22112. parts.push(_part);
  22113. }
  22114. return parts.join("");
  22115. }
  22116. function rfc2616unquote(value) {
  22117. if (value.startsWith('"')) {
  22118. var parts = value.slice(1).split('\\"');
  22119. for (var i = 0; i < parts.length; ++i) {
  22120. var quotindex = parts[i].indexOf('"');
  22121. if (quotindex !== -1) {
  22122. parts[i] = parts[i].slice(0, quotindex);
  22123. parts.length = i + 1;
  22124. }
  22125. parts[i] = parts[i].replace(/\\(.)/g, "$1");
  22126. }
  22127. value = parts.join('"');
  22128. }
  22129. return value;
  22130. }
  22131. function rfc5987decode(extvalue) {
  22132. var encodingend = extvalue.indexOf("'");
  22133. if (encodingend === -1) {
  22134. return extvalue;
  22135. }
  22136. var encoding = extvalue.slice(0, encodingend);
  22137. var langvalue = extvalue.slice(encodingend + 1);
  22138. var value = langvalue.replace(/^[^']*'/, "");
  22139. return textdecode(encoding, value);
  22140. }
  22141. function rfc2047decode(value) {
  22142. if (!value.startsWith("=?") || /[\x00-\x19\x80-\xff]/.test(value)) {
  22143. return value;
  22144. }
  22145. return value.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (matches, charset, encoding, text) {
  22146. if (encoding === "q" || encoding === "Q") {
  22147. text = text.replace(/_/g, " ");
  22148. text = text.replace(/=([0-9a-fA-F]{2})/g, function (match, hex) {
  22149. return String.fromCharCode(parseInt(hex, 16));
  22150. });
  22151. return textdecode(charset, text);
  22152. }
  22153. try {
  22154. text = atob(text);
  22155. } catch (e) {}
  22156. return textdecode(charset, text);
  22157. });
  22158. }
  22159. return "";
  22160. }
  22161. /***/ }),
  22162. /* 156 */
  22163. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  22164. "use strict";
  22165. Object.defineProperty(exports, "__esModule", ({
  22166. value: true
  22167. }));
  22168. exports.PDFNetworkStream = void 0;
  22169. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  22170. var _util = __w_pdfjs_require__(4);
  22171. var _network_utils = __w_pdfjs_require__(154);
  22172. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  22173. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  22174. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  22175. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22176. 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); } }
  22177. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  22178. ;
  22179. var OK_RESPONSE = 200;
  22180. var PARTIAL_CONTENT_RESPONSE = 206;
  22181. function getArrayBuffer(xhr) {
  22182. var data = xhr.response;
  22183. if (typeof data !== "string") {
  22184. return data;
  22185. }
  22186. var array = (0, _util.stringToBytes)(data);
  22187. return array.buffer;
  22188. }
  22189. var NetworkManager = /*#__PURE__*/function () {
  22190. function NetworkManager(url, args) {
  22191. _classCallCheck(this, NetworkManager);
  22192. this.url = url;
  22193. args = args || {};
  22194. this.isHttp = /^https?:/i.test(url);
  22195. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  22196. this.withCredentials = args.withCredentials || false;
  22197. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  22198. return new XMLHttpRequest();
  22199. };
  22200. this.currXhrId = 0;
  22201. this.pendingRequests = Object.create(null);
  22202. }
  22203. _createClass(NetworkManager, [{
  22204. key: "requestRange",
  22205. value: function requestRange(begin, end, listeners) {
  22206. var args = {
  22207. begin: begin,
  22208. end: end
  22209. };
  22210. for (var prop in listeners) {
  22211. args[prop] = listeners[prop];
  22212. }
  22213. return this.request(args);
  22214. }
  22215. }, {
  22216. key: "requestFull",
  22217. value: function requestFull(listeners) {
  22218. return this.request(listeners);
  22219. }
  22220. }, {
  22221. key: "request",
  22222. value: function request(args) {
  22223. var xhr = this.getXhr();
  22224. var xhrId = this.currXhrId++;
  22225. var pendingRequest = this.pendingRequests[xhrId] = {
  22226. xhr: xhr
  22227. };
  22228. xhr.open("GET", this.url);
  22229. xhr.withCredentials = this.withCredentials;
  22230. for (var property in this.httpHeaders) {
  22231. var value = this.httpHeaders[property];
  22232. if (typeof value === "undefined") {
  22233. continue;
  22234. }
  22235. xhr.setRequestHeader(property, value);
  22236. }
  22237. if (this.isHttp && "begin" in args && "end" in args) {
  22238. xhr.setRequestHeader("Range", "bytes=".concat(args.begin, "-").concat(args.end - 1));
  22239. pendingRequest.expectedStatus = PARTIAL_CONTENT_RESPONSE;
  22240. } else {
  22241. pendingRequest.expectedStatus = OK_RESPONSE;
  22242. }
  22243. xhr.responseType = "arraybuffer";
  22244. if (args.onError) {
  22245. xhr.onerror = function (evt) {
  22246. args.onError(xhr.status);
  22247. };
  22248. }
  22249. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  22250. xhr.onprogress = this.onProgress.bind(this, xhrId);
  22251. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  22252. pendingRequest.onDone = args.onDone;
  22253. pendingRequest.onError = args.onError;
  22254. pendingRequest.onProgress = args.onProgress;
  22255. xhr.send(null);
  22256. return xhrId;
  22257. }
  22258. }, {
  22259. key: "onProgress",
  22260. value: function onProgress(xhrId, evt) {
  22261. var pendingRequest = this.pendingRequests[xhrId];
  22262. if (!pendingRequest) {
  22263. return;
  22264. }
  22265. if (pendingRequest.onProgress) {
  22266. pendingRequest.onProgress(evt);
  22267. }
  22268. }
  22269. }, {
  22270. key: "onStateChange",
  22271. value: function onStateChange(xhrId, evt) {
  22272. var pendingRequest = this.pendingRequests[xhrId];
  22273. if (!pendingRequest) {
  22274. return;
  22275. }
  22276. var xhr = pendingRequest.xhr;
  22277. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  22278. pendingRequest.onHeadersReceived();
  22279. delete pendingRequest.onHeadersReceived;
  22280. }
  22281. if (xhr.readyState !== 4) {
  22282. return;
  22283. }
  22284. if (!(xhrId in this.pendingRequests)) {
  22285. return;
  22286. }
  22287. delete this.pendingRequests[xhrId];
  22288. if (xhr.status === 0 && this.isHttp) {
  22289. if (pendingRequest.onError) {
  22290. pendingRequest.onError(xhr.status);
  22291. }
  22292. return;
  22293. }
  22294. var xhrStatus = xhr.status || OK_RESPONSE;
  22295. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  22296. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  22297. if (pendingRequest.onError) {
  22298. pendingRequest.onError(xhr.status);
  22299. }
  22300. return;
  22301. }
  22302. var chunk = getArrayBuffer(xhr);
  22303. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  22304. var rangeHeader = xhr.getResponseHeader("Content-Range");
  22305. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  22306. pendingRequest.onDone({
  22307. begin: parseInt(matches[1], 10),
  22308. chunk: chunk
  22309. });
  22310. } else if (chunk) {
  22311. pendingRequest.onDone({
  22312. begin: 0,
  22313. chunk: chunk
  22314. });
  22315. } else if (pendingRequest.onError) {
  22316. pendingRequest.onError(xhr.status);
  22317. }
  22318. }
  22319. }, {
  22320. key: "getRequestXhr",
  22321. value: function getRequestXhr(xhrId) {
  22322. return this.pendingRequests[xhrId].xhr;
  22323. }
  22324. }, {
  22325. key: "isPendingRequest",
  22326. value: function isPendingRequest(xhrId) {
  22327. return xhrId in this.pendingRequests;
  22328. }
  22329. }, {
  22330. key: "abortRequest",
  22331. value: function abortRequest(xhrId) {
  22332. var xhr = this.pendingRequests[xhrId].xhr;
  22333. delete this.pendingRequests[xhrId];
  22334. xhr.abort();
  22335. }
  22336. }]);
  22337. return NetworkManager;
  22338. }();
  22339. var PDFNetworkStream = /*#__PURE__*/function () {
  22340. function PDFNetworkStream(source) {
  22341. _classCallCheck(this, PDFNetworkStream);
  22342. this._source = source;
  22343. this._manager = new NetworkManager(source.url, {
  22344. httpHeaders: source.httpHeaders,
  22345. withCredentials: source.withCredentials
  22346. });
  22347. this._rangeChunkSize = source.rangeChunkSize;
  22348. this._fullRequestReader = null;
  22349. this._rangeRequestReaders = [];
  22350. }
  22351. _createClass(PDFNetworkStream, [{
  22352. key: "_onRangeRequestReaderClosed",
  22353. value: function _onRangeRequestReaderClosed(reader) {
  22354. var i = this._rangeRequestReaders.indexOf(reader);
  22355. if (i >= 0) {
  22356. this._rangeRequestReaders.splice(i, 1);
  22357. }
  22358. }
  22359. }, {
  22360. key: "getFullReader",
  22361. value: function getFullReader() {
  22362. (0, _util.assert)(!this._fullRequestReader, "PDFNetworkStream.getFullReader can only be called once.");
  22363. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
  22364. return this._fullRequestReader;
  22365. }
  22366. }, {
  22367. key: "getRangeReader",
  22368. value: function getRangeReader(begin, end) {
  22369. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  22370. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  22371. this._rangeRequestReaders.push(reader);
  22372. return reader;
  22373. }
  22374. }, {
  22375. key: "cancelAllRequests",
  22376. value: function cancelAllRequests(reason) {
  22377. if (this._fullRequestReader) {
  22378. this._fullRequestReader.cancel(reason);
  22379. }
  22380. var readers = this._rangeRequestReaders.slice(0);
  22381. readers.forEach(function (reader) {
  22382. reader.cancel(reason);
  22383. });
  22384. }
  22385. }]);
  22386. return PDFNetworkStream;
  22387. }();
  22388. exports.PDFNetworkStream = PDFNetworkStream;
  22389. var PDFNetworkStreamFullRequestReader = /*#__PURE__*/function () {
  22390. function PDFNetworkStreamFullRequestReader(manager, source) {
  22391. _classCallCheck(this, PDFNetworkStreamFullRequestReader);
  22392. this._manager = manager;
  22393. var args = {
  22394. onHeadersReceived: this._onHeadersReceived.bind(this),
  22395. onDone: this._onDone.bind(this),
  22396. onError: this._onError.bind(this),
  22397. onProgress: this._onProgress.bind(this)
  22398. };
  22399. this._url = source.url;
  22400. this._fullRequestId = manager.requestFull(args);
  22401. this._headersReceivedCapability = (0, _util.createPromiseCapability)();
  22402. this._disableRange = source.disableRange || false;
  22403. this._contentLength = source.length;
  22404. this._rangeChunkSize = source.rangeChunkSize;
  22405. if (!this._rangeChunkSize && !this._disableRange) {
  22406. this._disableRange = true;
  22407. }
  22408. this._isStreamingSupported = false;
  22409. this._isRangeSupported = false;
  22410. this._cachedChunks = [];
  22411. this._requests = [];
  22412. this._done = false;
  22413. this._storedError = undefined;
  22414. this._filename = null;
  22415. this.onProgress = null;
  22416. }
  22417. _createClass(PDFNetworkStreamFullRequestReader, [{
  22418. key: "_onHeadersReceived",
  22419. value: function _onHeadersReceived() {
  22420. var fullRequestXhrId = this._fullRequestId;
  22421. var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
  22422. var getResponseHeader = function getResponseHeader(name) {
  22423. return fullRequestXhr.getResponseHeader(name);
  22424. };
  22425. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  22426. getResponseHeader: getResponseHeader,
  22427. isHttp: this._manager.isHttp,
  22428. rangeChunkSize: this._rangeChunkSize,
  22429. disableRange: this._disableRange
  22430. }),
  22431. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  22432. suggestedLength = _validateRangeRequest.suggestedLength;
  22433. if (allowRangeRequests) {
  22434. this._isRangeSupported = true;
  22435. }
  22436. this._contentLength = suggestedLength || this._contentLength;
  22437. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  22438. if (this._isRangeSupported) {
  22439. this._manager.abortRequest(fullRequestXhrId);
  22440. }
  22441. this._headersReceivedCapability.resolve();
  22442. }
  22443. }, {
  22444. key: "_onDone",
  22445. value: function _onDone(args) {
  22446. if (args) {
  22447. if (this._requests.length > 0) {
  22448. var requestCapability = this._requests.shift();
  22449. requestCapability.resolve({
  22450. value: args.chunk,
  22451. done: false
  22452. });
  22453. } else {
  22454. this._cachedChunks.push(args.chunk);
  22455. }
  22456. }
  22457. this._done = true;
  22458. if (this._cachedChunks.length > 0) {
  22459. return;
  22460. }
  22461. this._requests.forEach(function (requestCapability) {
  22462. requestCapability.resolve({
  22463. value: undefined,
  22464. done: true
  22465. });
  22466. });
  22467. this._requests = [];
  22468. }
  22469. }, {
  22470. key: "_onError",
  22471. value: function _onError(status) {
  22472. var url = this._url;
  22473. var exception = (0, _network_utils.createResponseStatusError)(status, url);
  22474. this._storedError = exception;
  22475. this._headersReceivedCapability.reject(exception);
  22476. this._requests.forEach(function (requestCapability) {
  22477. requestCapability.reject(exception);
  22478. });
  22479. this._requests = [];
  22480. this._cachedChunks = [];
  22481. }
  22482. }, {
  22483. key: "_onProgress",
  22484. value: function _onProgress(data) {
  22485. if (this.onProgress) {
  22486. this.onProgress({
  22487. loaded: data.loaded,
  22488. total: data.lengthComputable ? data.total : this._contentLength
  22489. });
  22490. }
  22491. }
  22492. }, {
  22493. key: "read",
  22494. value: function () {
  22495. var _read = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  22496. var chunk, requestCapability;
  22497. return _regenerator["default"].wrap(function _callee$(_context) {
  22498. while (1) {
  22499. switch (_context.prev = _context.next) {
  22500. case 0:
  22501. if (!this._storedError) {
  22502. _context.next = 2;
  22503. break;
  22504. }
  22505. throw this._storedError;
  22506. case 2:
  22507. if (!(this._cachedChunks.length > 0)) {
  22508. _context.next = 5;
  22509. break;
  22510. }
  22511. chunk = this._cachedChunks.shift();
  22512. return _context.abrupt("return", {
  22513. value: chunk,
  22514. done: false
  22515. });
  22516. case 5:
  22517. if (!this._done) {
  22518. _context.next = 7;
  22519. break;
  22520. }
  22521. return _context.abrupt("return", {
  22522. value: undefined,
  22523. done: true
  22524. });
  22525. case 7:
  22526. requestCapability = (0, _util.createPromiseCapability)();
  22527. this._requests.push(requestCapability);
  22528. return _context.abrupt("return", requestCapability.promise);
  22529. case 10:
  22530. case "end":
  22531. return _context.stop();
  22532. }
  22533. }
  22534. }, _callee, this);
  22535. }));
  22536. function read() {
  22537. return _read.apply(this, arguments);
  22538. }
  22539. return read;
  22540. }()
  22541. }, {
  22542. key: "cancel",
  22543. value: function cancel(reason) {
  22544. this._done = true;
  22545. this._headersReceivedCapability.reject(reason);
  22546. this._requests.forEach(function (requestCapability) {
  22547. requestCapability.resolve({
  22548. value: undefined,
  22549. done: true
  22550. });
  22551. });
  22552. this._requests = [];
  22553. if (this._manager.isPendingRequest(this._fullRequestId)) {
  22554. this._manager.abortRequest(this._fullRequestId);
  22555. }
  22556. this._fullRequestReader = null;
  22557. }
  22558. }, {
  22559. key: "filename",
  22560. get: function get() {
  22561. return this._filename;
  22562. }
  22563. }, {
  22564. key: "isRangeSupported",
  22565. get: function get() {
  22566. return this._isRangeSupported;
  22567. }
  22568. }, {
  22569. key: "isStreamingSupported",
  22570. get: function get() {
  22571. return this._isStreamingSupported;
  22572. }
  22573. }, {
  22574. key: "contentLength",
  22575. get: function get() {
  22576. return this._contentLength;
  22577. }
  22578. }, {
  22579. key: "headersReady",
  22580. get: function get() {
  22581. return this._headersReceivedCapability.promise;
  22582. }
  22583. }]);
  22584. return PDFNetworkStreamFullRequestReader;
  22585. }();
  22586. var PDFNetworkStreamRangeRequestReader = /*#__PURE__*/function () {
  22587. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  22588. _classCallCheck(this, PDFNetworkStreamRangeRequestReader);
  22589. this._manager = manager;
  22590. var args = {
  22591. onDone: this._onDone.bind(this),
  22592. onProgress: this._onProgress.bind(this)
  22593. };
  22594. this._requestId = manager.requestRange(begin, end, args);
  22595. this._requests = [];
  22596. this._queuedChunk = null;
  22597. this._done = false;
  22598. this.onProgress = null;
  22599. this.onClosed = null;
  22600. }
  22601. _createClass(PDFNetworkStreamRangeRequestReader, [{
  22602. key: "_close",
  22603. value: function _close() {
  22604. if (this.onClosed) {
  22605. this.onClosed(this);
  22606. }
  22607. }
  22608. }, {
  22609. key: "_onDone",
  22610. value: function _onDone(data) {
  22611. var chunk = data.chunk;
  22612. if (this._requests.length > 0) {
  22613. var requestCapability = this._requests.shift();
  22614. requestCapability.resolve({
  22615. value: chunk,
  22616. done: false
  22617. });
  22618. } else {
  22619. this._queuedChunk = chunk;
  22620. }
  22621. this._done = true;
  22622. this._requests.forEach(function (requestCapability) {
  22623. requestCapability.resolve({
  22624. value: undefined,
  22625. done: true
  22626. });
  22627. });
  22628. this._requests = [];
  22629. this._close();
  22630. }
  22631. }, {
  22632. key: "_onProgress",
  22633. value: function _onProgress(evt) {
  22634. if (!this.isStreamingSupported && this.onProgress) {
  22635. this.onProgress({
  22636. loaded: evt.loaded
  22637. });
  22638. }
  22639. }
  22640. }, {
  22641. key: "read",
  22642. value: function () {
  22643. var _read2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  22644. var chunk, requestCapability;
  22645. return _regenerator["default"].wrap(function _callee2$(_context2) {
  22646. while (1) {
  22647. switch (_context2.prev = _context2.next) {
  22648. case 0:
  22649. if (!(this._queuedChunk !== null)) {
  22650. _context2.next = 4;
  22651. break;
  22652. }
  22653. chunk = this._queuedChunk;
  22654. this._queuedChunk = null;
  22655. return _context2.abrupt("return", {
  22656. value: chunk,
  22657. done: false
  22658. });
  22659. case 4:
  22660. if (!this._done) {
  22661. _context2.next = 6;
  22662. break;
  22663. }
  22664. return _context2.abrupt("return", {
  22665. value: undefined,
  22666. done: true
  22667. });
  22668. case 6:
  22669. requestCapability = (0, _util.createPromiseCapability)();
  22670. this._requests.push(requestCapability);
  22671. return _context2.abrupt("return", requestCapability.promise);
  22672. case 9:
  22673. case "end":
  22674. return _context2.stop();
  22675. }
  22676. }
  22677. }, _callee2, this);
  22678. }));
  22679. function read() {
  22680. return _read2.apply(this, arguments);
  22681. }
  22682. return read;
  22683. }()
  22684. }, {
  22685. key: "cancel",
  22686. value: function cancel(reason) {
  22687. this._done = true;
  22688. this._requests.forEach(function (requestCapability) {
  22689. requestCapability.resolve({
  22690. value: undefined,
  22691. done: true
  22692. });
  22693. });
  22694. this._requests = [];
  22695. if (this._manager.isPendingRequest(this._requestId)) {
  22696. this._manager.abortRequest(this._requestId);
  22697. }
  22698. this._close();
  22699. }
  22700. }, {
  22701. key: "isStreamingSupported",
  22702. get: function get() {
  22703. return false;
  22704. }
  22705. }]);
  22706. return PDFNetworkStreamRangeRequestReader;
  22707. }();
  22708. /***/ }),
  22709. /* 157 */
  22710. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  22711. "use strict";
  22712. Object.defineProperty(exports, "__esModule", ({
  22713. value: true
  22714. }));
  22715. exports.PDFFetchStream = void 0;
  22716. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(2));
  22717. var _util = __w_pdfjs_require__(4);
  22718. var _network_utils = __w_pdfjs_require__(154);
  22719. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  22720. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  22721. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  22722. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22723. 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); } }
  22724. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  22725. ;
  22726. function createFetchOptions(headers, withCredentials, abortController) {
  22727. return {
  22728. method: "GET",
  22729. headers: headers,
  22730. signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
  22731. mode: "cors",
  22732. credentials: withCredentials ? "include" : "same-origin",
  22733. redirect: "follow"
  22734. };
  22735. }
  22736. function createHeaders(httpHeaders) {
  22737. var headers = new Headers();
  22738. for (var property in httpHeaders) {
  22739. var value = httpHeaders[property];
  22740. if (typeof value === "undefined") {
  22741. continue;
  22742. }
  22743. headers.append(property, value);
  22744. }
  22745. return headers;
  22746. }
  22747. var PDFFetchStream = /*#__PURE__*/function () {
  22748. function PDFFetchStream(source) {
  22749. _classCallCheck(this, PDFFetchStream);
  22750. this.source = source;
  22751. this.isHttp = /^https?:/i.test(source.url);
  22752. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  22753. this._fullRequestReader = null;
  22754. this._rangeRequestReaders = [];
  22755. }
  22756. _createClass(PDFFetchStream, [{
  22757. key: "getFullReader",
  22758. value: function getFullReader() {
  22759. (0, _util.assert)(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once.");
  22760. this._fullRequestReader = new PDFFetchStreamReader(this);
  22761. return this._fullRequestReader;
  22762. }
  22763. }, {
  22764. key: "getRangeReader",
  22765. value: function getRangeReader(begin, end) {
  22766. if (end <= this._progressiveDataLength) {
  22767. return null;
  22768. }
  22769. var reader = new PDFFetchStreamRangeReader(this, begin, end);
  22770. this._rangeRequestReaders.push(reader);
  22771. return reader;
  22772. }
  22773. }, {
  22774. key: "cancelAllRequests",
  22775. value: function cancelAllRequests(reason) {
  22776. if (this._fullRequestReader) {
  22777. this._fullRequestReader.cancel(reason);
  22778. }
  22779. var readers = this._rangeRequestReaders.slice(0);
  22780. readers.forEach(function (reader) {
  22781. reader.cancel(reason);
  22782. });
  22783. }
  22784. }, {
  22785. key: "_progressiveDataLength",
  22786. get: function get() {
  22787. var _this$_fullRequestRea, _this$_fullRequestRea2;
  22788. return (_this$_fullRequestRea = (_this$_fullRequestRea2 = this._fullRequestReader) === null || _this$_fullRequestRea2 === void 0 ? void 0 : _this$_fullRequestRea2._loaded) !== null && _this$_fullRequestRea !== void 0 ? _this$_fullRequestRea : 0;
  22789. }
  22790. }]);
  22791. return PDFFetchStream;
  22792. }();
  22793. exports.PDFFetchStream = PDFFetchStream;
  22794. var PDFFetchStreamReader = /*#__PURE__*/function () {
  22795. function PDFFetchStreamReader(stream) {
  22796. var _this = this;
  22797. _classCallCheck(this, PDFFetchStreamReader);
  22798. this._stream = stream;
  22799. this._reader = null;
  22800. this._loaded = 0;
  22801. this._filename = null;
  22802. var source = stream.source;
  22803. this._withCredentials = source.withCredentials || false;
  22804. this._contentLength = source.length;
  22805. this._headersCapability = (0, _util.createPromiseCapability)();
  22806. this._disableRange = source.disableRange || false;
  22807. this._rangeChunkSize = source.rangeChunkSize;
  22808. if (!this._rangeChunkSize && !this._disableRange) {
  22809. this._disableRange = true;
  22810. }
  22811. if (typeof AbortController !== "undefined") {
  22812. this._abortController = new AbortController();
  22813. }
  22814. this._isStreamingSupported = !source.disableStream;
  22815. this._isRangeSupported = !source.disableRange;
  22816. this._headers = createHeaders(this._stream.httpHeaders);
  22817. var url = source.url;
  22818. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  22819. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  22820. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  22821. }
  22822. _this._reader = response.body.getReader();
  22823. _this._headersCapability.resolve();
  22824. var getResponseHeader = function getResponseHeader(name) {
  22825. return response.headers.get(name);
  22826. };
  22827. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  22828. getResponseHeader: getResponseHeader,
  22829. isHttp: _this._stream.isHttp,
  22830. rangeChunkSize: _this._rangeChunkSize,
  22831. disableRange: _this._disableRange
  22832. }),
  22833. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  22834. suggestedLength = _validateRangeRequest.suggestedLength;
  22835. _this._isRangeSupported = allowRangeRequests;
  22836. _this._contentLength = suggestedLength || _this._contentLength;
  22837. _this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  22838. if (!_this._isStreamingSupported && _this._isRangeSupported) {
  22839. _this.cancel(new _util.AbortException("Streaming is disabled."));
  22840. }
  22841. })["catch"](this._headersCapability.reject);
  22842. this.onProgress = null;
  22843. }
  22844. _createClass(PDFFetchStreamReader, [{
  22845. key: "read",
  22846. value: function () {
  22847. var _read = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  22848. var _yield$this$_reader$r, value, done, buffer;
  22849. return _regenerator["default"].wrap(function _callee$(_context) {
  22850. while (1) {
  22851. switch (_context.prev = _context.next) {
  22852. case 0:
  22853. _context.next = 2;
  22854. return this._headersCapability.promise;
  22855. case 2:
  22856. _context.next = 4;
  22857. return this._reader.read();
  22858. case 4:
  22859. _yield$this$_reader$r = _context.sent;
  22860. value = _yield$this$_reader$r.value;
  22861. done = _yield$this$_reader$r.done;
  22862. if (!done) {
  22863. _context.next = 9;
  22864. break;
  22865. }
  22866. return _context.abrupt("return", {
  22867. value: value,
  22868. done: done
  22869. });
  22870. case 9:
  22871. this._loaded += value.byteLength;
  22872. if (this.onProgress) {
  22873. this.onProgress({
  22874. loaded: this._loaded,
  22875. total: this._contentLength
  22876. });
  22877. }
  22878. buffer = new Uint8Array(value).buffer;
  22879. return _context.abrupt("return", {
  22880. value: buffer,
  22881. done: false
  22882. });
  22883. case 13:
  22884. case "end":
  22885. return _context.stop();
  22886. }
  22887. }
  22888. }, _callee, this);
  22889. }));
  22890. function read() {
  22891. return _read.apply(this, arguments);
  22892. }
  22893. return read;
  22894. }()
  22895. }, {
  22896. key: "cancel",
  22897. value: function cancel(reason) {
  22898. if (this._reader) {
  22899. this._reader.cancel(reason);
  22900. }
  22901. if (this._abortController) {
  22902. this._abortController.abort();
  22903. }
  22904. }
  22905. }, {
  22906. key: "headersReady",
  22907. get: function get() {
  22908. return this._headersCapability.promise;
  22909. }
  22910. }, {
  22911. key: "filename",
  22912. get: function get() {
  22913. return this._filename;
  22914. }
  22915. }, {
  22916. key: "contentLength",
  22917. get: function get() {
  22918. return this._contentLength;
  22919. }
  22920. }, {
  22921. key: "isRangeSupported",
  22922. get: function get() {
  22923. return this._isRangeSupported;
  22924. }
  22925. }, {
  22926. key: "isStreamingSupported",
  22927. get: function get() {
  22928. return this._isStreamingSupported;
  22929. }
  22930. }]);
  22931. return PDFFetchStreamReader;
  22932. }();
  22933. var PDFFetchStreamRangeReader = /*#__PURE__*/function () {
  22934. function PDFFetchStreamRangeReader(stream, begin, end) {
  22935. var _this2 = this;
  22936. _classCallCheck(this, PDFFetchStreamRangeReader);
  22937. this._stream = stream;
  22938. this._reader = null;
  22939. this._loaded = 0;
  22940. var source = stream.source;
  22941. this._withCredentials = source.withCredentials || false;
  22942. this._readCapability = (0, _util.createPromiseCapability)();
  22943. this._isStreamingSupported = !source.disableStream;
  22944. if (typeof AbortController !== "undefined") {
  22945. this._abortController = new AbortController();
  22946. }
  22947. this._headers = createHeaders(this._stream.httpHeaders);
  22948. this._headers.append("Range", "bytes=".concat(begin, "-").concat(end - 1));
  22949. var url = source.url;
  22950. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  22951. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  22952. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  22953. }
  22954. _this2._readCapability.resolve();
  22955. _this2._reader = response.body.getReader();
  22956. })["catch"](function (reason) {
  22957. if ((reason === null || reason === void 0 ? void 0 : reason.name) === "AbortError") {
  22958. return;
  22959. }
  22960. throw reason;
  22961. });
  22962. this.onProgress = null;
  22963. }
  22964. _createClass(PDFFetchStreamRangeReader, [{
  22965. key: "read",
  22966. value: function () {
  22967. var _read2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  22968. var _yield$this$_reader$r2, value, done, buffer;
  22969. return _regenerator["default"].wrap(function _callee2$(_context2) {
  22970. while (1) {
  22971. switch (_context2.prev = _context2.next) {
  22972. case 0:
  22973. _context2.next = 2;
  22974. return this._readCapability.promise;
  22975. case 2:
  22976. _context2.next = 4;
  22977. return this._reader.read();
  22978. case 4:
  22979. _yield$this$_reader$r2 = _context2.sent;
  22980. value = _yield$this$_reader$r2.value;
  22981. done = _yield$this$_reader$r2.done;
  22982. if (!done) {
  22983. _context2.next = 9;
  22984. break;
  22985. }
  22986. return _context2.abrupt("return", {
  22987. value: value,
  22988. done: done
  22989. });
  22990. case 9:
  22991. this._loaded += value.byteLength;
  22992. if (this.onProgress) {
  22993. this.onProgress({
  22994. loaded: this._loaded
  22995. });
  22996. }
  22997. buffer = new Uint8Array(value).buffer;
  22998. return _context2.abrupt("return", {
  22999. value: buffer,
  23000. done: false
  23001. });
  23002. case 13:
  23003. case "end":
  23004. return _context2.stop();
  23005. }
  23006. }
  23007. }, _callee2, this);
  23008. }));
  23009. function read() {
  23010. return _read2.apply(this, arguments);
  23011. }
  23012. return read;
  23013. }()
  23014. }, {
  23015. key: "cancel",
  23016. value: function cancel(reason) {
  23017. if (this._reader) {
  23018. this._reader.cancel(reason);
  23019. }
  23020. if (this._abortController) {
  23021. this._abortController.abort();
  23022. }
  23023. }
  23024. }, {
  23025. key: "isStreamingSupported",
  23026. get: function get() {
  23027. return this._isStreamingSupported;
  23028. }
  23029. }]);
  23030. return PDFFetchStreamRangeReader;
  23031. }();
  23032. /***/ })
  23033. /******/ ]);
  23034. /************************************************************************/
  23035. /******/ // The module cache
  23036. /******/ var __webpack_module_cache__ = {};
  23037. /******/
  23038. /******/ // The require function
  23039. /******/ function __w_pdfjs_require__(moduleId) {
  23040. /******/ // Check if module is in cache
  23041. /******/ if(__webpack_module_cache__[moduleId]) {
  23042. /******/ return __webpack_module_cache__[moduleId].exports;
  23043. /******/ }
  23044. /******/ // Create a new module (and put it into the cache)
  23045. /******/ var module = __webpack_module_cache__[moduleId] = {
  23046. /******/ id: moduleId,
  23047. /******/ loaded: false,
  23048. /******/ exports: {}
  23049. /******/ };
  23050. /******/
  23051. /******/ // Execute the module function
  23052. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  23053. /******/
  23054. /******/ // Flag the module as loaded
  23055. /******/ module.loaded = true;
  23056. /******/
  23057. /******/ // Return the exports of the module
  23058. /******/ return module.exports;
  23059. /******/ }
  23060. /******/
  23061. /************************************************************************/
  23062. /******/ /* webpack/runtime/node module decorator */
  23063. /******/ (() => {
  23064. /******/ __w_pdfjs_require__.nmd = (module) => {
  23065. /******/ module.paths = [];
  23066. /******/ if (!module.children) module.children = [];
  23067. /******/ return module;
  23068. /******/ };
  23069. /******/ })();
  23070. /******/
  23071. /************************************************************************/
  23072. /******/ // module exports must be returned from runtime so entry inlining is disabled
  23073. /******/ // startup
  23074. /******/ // Load entry module and return exports
  23075. /******/ return __w_pdfjs_require__(0);
  23076. /******/ })()
  23077. ;
  23078. });
  23079. //# sourceMappingURL=pdf.js.map