| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593 |
- var __create = Object.create;
- var __defProp = Object.defineProperty;
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
- var __getOwnPropNames = Object.getOwnPropertyNames;
- var __getProtoOf = Object.getPrototypeOf;
- var __hasOwnProp = Object.prototype.hasOwnProperty;
- var __glob = (map) => (path) => {
- var fn = map[path];
- if (fn) return fn();
- throw new Error("Module not found in bundle: " + path);
- };
- var __esm = (fn, res) => function __init() {
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
- };
- var __commonJS = (cb, mod) => function __require() {
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
- };
- var __export = (target, all) => {
- for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
- };
- var __copyProps = (to, from, except, desc) => {
- if (from && typeof from === "object" || typeof from === "function") {
- for (let key of __getOwnPropNames(from))
- if (!__hasOwnProp.call(to, key) && key !== except)
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
- }
- return to;
- };
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
- // If the importer is in node compatibility mode or this is not an ESM
- // file that has been converted to a CommonJS file using a Babel-
- // compatible transform (i.e. "__esModule" has not been set), then set
- // "default" to the CommonJS "module.exports" for node compatibility.
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
- mod
- ));
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
- // node_modules/mongodb/lib/error.js
- var require_error = __commonJS({
- "node_modules/mongodb/lib/error.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.isResumableError = exports2.isNetworkTimeoutError = exports2.isSDAMUnrecoverableError = exports2.isNodeShuttingDownError = exports2.isRetryableReadError = exports2.isRetryableWriteError = exports2.needsRetryableWriteLabel = exports2.MongoWriteConcernError = exports2.MongoServerSelectionError = exports2.MongoSystemError = exports2.MongoMissingDependencyError = exports2.MongoMissingCredentialsError = exports2.MongoCompatibilityError = exports2.MongoInvalidArgumentError = exports2.MongoParseError = exports2.MongoNetworkTimeoutError = exports2.MongoNetworkError = exports2.isNetworkErrorBeforeHandshake = exports2.MongoTopologyClosedError = exports2.MongoCursorExhaustedError = exports2.MongoServerClosedError = exports2.MongoCursorInUseError = exports2.MongoUnexpectedServerResponseError = exports2.MongoGridFSChunkError = exports2.MongoGridFSStreamError = exports2.MongoTailableCursorError = exports2.MongoChangeStreamError = exports2.MongoAzureError = exports2.MongoAWSError = exports2.MongoKerberosError = exports2.MongoExpiredSessionError = exports2.MongoTransactionError = exports2.MongoNotConnectedError = exports2.MongoDecompressionError = exports2.MongoBatchReExecutionError = exports2.MongoRuntimeError = exports2.MongoAPIError = exports2.MongoDriverError = exports2.MongoServerError = exports2.MongoError = exports2.MongoErrorLabel = exports2.GET_MORE_RESUMABLE_CODES = exports2.MONGODB_ERROR_CODES = exports2.NODE_IS_RECOVERING_ERROR_MESSAGE = exports2.LEGACY_NOT_PRIMARY_OR_SECONDARY_ERROR_MESSAGE = exports2.LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE = void 0;
- var kErrorLabels = Symbol("errorLabels");
- exports2.LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE = new RegExp("not master", "i");
- exports2.LEGACY_NOT_PRIMARY_OR_SECONDARY_ERROR_MESSAGE = new RegExp("not master or secondary", "i");
- exports2.NODE_IS_RECOVERING_ERROR_MESSAGE = new RegExp("node is recovering", "i");
- exports2.MONGODB_ERROR_CODES = Object.freeze({
- HostUnreachable: 6,
- HostNotFound: 7,
- NetworkTimeout: 89,
- ShutdownInProgress: 91,
- PrimarySteppedDown: 189,
- ExceededTimeLimit: 262,
- SocketException: 9001,
- NotWritablePrimary: 10107,
- InterruptedAtShutdown: 11600,
- InterruptedDueToReplStateChange: 11602,
- NotPrimaryNoSecondaryOk: 13435,
- NotPrimaryOrSecondary: 13436,
- StaleShardVersion: 63,
- StaleEpoch: 150,
- StaleConfig: 13388,
- RetryChangeStream: 234,
- FailedToSatisfyReadPreference: 133,
- CursorNotFound: 43,
- LegacyNotPrimary: 10058,
- WriteConcernFailed: 64,
- NamespaceNotFound: 26,
- IllegalOperation: 20,
- MaxTimeMSExpired: 50,
- UnknownReplWriteConcern: 79,
- UnsatisfiableWriteConcern: 100,
- Reauthenticate: 391
- });
- exports2.GET_MORE_RESUMABLE_CODES = /* @__PURE__ */ new Set([
- exports2.MONGODB_ERROR_CODES.HostUnreachable,
- exports2.MONGODB_ERROR_CODES.HostNotFound,
- exports2.MONGODB_ERROR_CODES.NetworkTimeout,
- exports2.MONGODB_ERROR_CODES.ShutdownInProgress,
- exports2.MONGODB_ERROR_CODES.PrimarySteppedDown,
- exports2.MONGODB_ERROR_CODES.ExceededTimeLimit,
- exports2.MONGODB_ERROR_CODES.SocketException,
- exports2.MONGODB_ERROR_CODES.NotWritablePrimary,
- exports2.MONGODB_ERROR_CODES.InterruptedAtShutdown,
- exports2.MONGODB_ERROR_CODES.InterruptedDueToReplStateChange,
- exports2.MONGODB_ERROR_CODES.NotPrimaryNoSecondaryOk,
- exports2.MONGODB_ERROR_CODES.NotPrimaryOrSecondary,
- exports2.MONGODB_ERROR_CODES.StaleShardVersion,
- exports2.MONGODB_ERROR_CODES.StaleEpoch,
- exports2.MONGODB_ERROR_CODES.StaleConfig,
- exports2.MONGODB_ERROR_CODES.RetryChangeStream,
- exports2.MONGODB_ERROR_CODES.FailedToSatisfyReadPreference,
- exports2.MONGODB_ERROR_CODES.CursorNotFound
- ]);
- exports2.MongoErrorLabel = Object.freeze({
- RetryableWriteError: "RetryableWriteError",
- TransientTransactionError: "TransientTransactionError",
- UnknownTransactionCommitResult: "UnknownTransactionCommitResult",
- ResumableChangeStreamError: "ResumableChangeStreamError",
- HandshakeError: "HandshakeError",
- ResetPool: "ResetPool",
- InterruptInUseConnections: "InterruptInUseConnections",
- NoWritesPerformed: "NoWritesPerformed"
- });
- function isAggregateError(e) {
- return "errors" in e && Array.isArray(e.errors);
- }
- var MongoError = class _MongoError extends Error {
- constructor(message) {
- super(_MongoError.buildErrorMessage(message));
- if (message instanceof Error) {
- this.cause = message;
- }
- this[kErrorLabels] = /* @__PURE__ */ new Set();
- }
- /** @internal */
- static buildErrorMessage(e) {
- if (typeof e === "string") {
- return e;
- }
- if (isAggregateError(e) && e.message.length === 0) {
- return e.errors.length === 0 ? "AggregateError has an empty errors array. Please check the `cause` property for more information." : e.errors.map(({ message }) => message).join(", ");
- }
- return e.message;
- }
- get name() {
- return "MongoError";
- }
- /** Legacy name for server error responses */
- get errmsg() {
- return this.message;
- }
- /**
- * Checks the error to see if it has an error label
- *
- * @param label - The error label to check for
- * @returns returns true if the error has the provided error label
- */
- hasErrorLabel(label) {
- return this[kErrorLabels].has(label);
- }
- addErrorLabel(label) {
- this[kErrorLabels].add(label);
- }
- get errorLabels() {
- return Array.from(this[kErrorLabels]);
- }
- };
- exports2.MongoError = MongoError;
- var MongoServerError = class extends MongoError {
- constructor(message) {
- super(message.message || message.errmsg || message.$err || "n/a");
- if (message.errorLabels) {
- this[kErrorLabels] = new Set(message.errorLabels);
- }
- for (const name in message) {
- if (name !== "errorLabels" && name !== "errmsg" && name !== "message")
- this[name] = message[name];
- }
- }
- get name() {
- return "MongoServerError";
- }
- };
- exports2.MongoServerError = MongoServerError;
- var MongoDriverError = class extends MongoError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoDriverError";
- }
- };
- exports2.MongoDriverError = MongoDriverError;
- var MongoAPIError = class extends MongoDriverError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoAPIError";
- }
- };
- exports2.MongoAPIError = MongoAPIError;
- var MongoRuntimeError = class extends MongoDriverError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoRuntimeError";
- }
- };
- exports2.MongoRuntimeError = MongoRuntimeError;
- var MongoBatchReExecutionError = class extends MongoAPIError {
- constructor(message = "This batch has already been executed, create new batch to execute") {
- super(message);
- }
- get name() {
- return "MongoBatchReExecutionError";
- }
- };
- exports2.MongoBatchReExecutionError = MongoBatchReExecutionError;
- var MongoDecompressionError = class extends MongoRuntimeError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoDecompressionError";
- }
- };
- exports2.MongoDecompressionError = MongoDecompressionError;
- var MongoNotConnectedError = class extends MongoAPIError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoNotConnectedError";
- }
- };
- exports2.MongoNotConnectedError = MongoNotConnectedError;
- var MongoTransactionError = class extends MongoAPIError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoTransactionError";
- }
- };
- exports2.MongoTransactionError = MongoTransactionError;
- var MongoExpiredSessionError = class extends MongoAPIError {
- constructor(message = "Cannot use a session that has ended") {
- super(message);
- }
- get name() {
- return "MongoExpiredSessionError";
- }
- };
- exports2.MongoExpiredSessionError = MongoExpiredSessionError;
- var MongoKerberosError = class extends MongoRuntimeError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoKerberosError";
- }
- };
- exports2.MongoKerberosError = MongoKerberosError;
- var MongoAWSError = class extends MongoRuntimeError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoAWSError";
- }
- };
- exports2.MongoAWSError = MongoAWSError;
- var MongoAzureError = class extends MongoRuntimeError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoAzureError";
- }
- };
- exports2.MongoAzureError = MongoAzureError;
- var MongoChangeStreamError = class extends MongoRuntimeError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoChangeStreamError";
- }
- };
- exports2.MongoChangeStreamError = MongoChangeStreamError;
- var MongoTailableCursorError = class extends MongoAPIError {
- constructor(message = "Tailable cursor does not support this operation") {
- super(message);
- }
- get name() {
- return "MongoTailableCursorError";
- }
- };
- exports2.MongoTailableCursorError = MongoTailableCursorError;
- var MongoGridFSStreamError = class extends MongoRuntimeError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoGridFSStreamError";
- }
- };
- exports2.MongoGridFSStreamError = MongoGridFSStreamError;
- var MongoGridFSChunkError = class extends MongoRuntimeError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoGridFSChunkError";
- }
- };
- exports2.MongoGridFSChunkError = MongoGridFSChunkError;
- var MongoUnexpectedServerResponseError = class extends MongoRuntimeError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoUnexpectedServerResponseError";
- }
- };
- exports2.MongoUnexpectedServerResponseError = MongoUnexpectedServerResponseError;
- var MongoCursorInUseError = class extends MongoAPIError {
- constructor(message = "Cursor is already initialized") {
- super(message);
- }
- get name() {
- return "MongoCursorInUseError";
- }
- };
- exports2.MongoCursorInUseError = MongoCursorInUseError;
- var MongoServerClosedError = class extends MongoAPIError {
- constructor(message = "Server is closed") {
- super(message);
- }
- get name() {
- return "MongoServerClosedError";
- }
- };
- exports2.MongoServerClosedError = MongoServerClosedError;
- var MongoCursorExhaustedError = class extends MongoAPIError {
- constructor(message) {
- super(message || "Cursor is exhausted");
- }
- get name() {
- return "MongoCursorExhaustedError";
- }
- };
- exports2.MongoCursorExhaustedError = MongoCursorExhaustedError;
- var MongoTopologyClosedError = class extends MongoAPIError {
- constructor(message = "Topology is closed") {
- super(message);
- }
- get name() {
- return "MongoTopologyClosedError";
- }
- };
- exports2.MongoTopologyClosedError = MongoTopologyClosedError;
- var kBeforeHandshake = Symbol("beforeHandshake");
- function isNetworkErrorBeforeHandshake(err) {
- return err[kBeforeHandshake] === true;
- }
- exports2.isNetworkErrorBeforeHandshake = isNetworkErrorBeforeHandshake;
- var MongoNetworkError = class extends MongoError {
- constructor(message, options) {
- super(message);
- if (options && typeof options.beforeHandshake === "boolean") {
- this[kBeforeHandshake] = options.beforeHandshake;
- }
- }
- get name() {
- return "MongoNetworkError";
- }
- };
- exports2.MongoNetworkError = MongoNetworkError;
- var MongoNetworkTimeoutError = class extends MongoNetworkError {
- constructor(message, options) {
- super(message, options);
- }
- get name() {
- return "MongoNetworkTimeoutError";
- }
- };
- exports2.MongoNetworkTimeoutError = MongoNetworkTimeoutError;
- var MongoParseError = class extends MongoDriverError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoParseError";
- }
- };
- exports2.MongoParseError = MongoParseError;
- var MongoInvalidArgumentError = class extends MongoAPIError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoInvalidArgumentError";
- }
- };
- exports2.MongoInvalidArgumentError = MongoInvalidArgumentError;
- var MongoCompatibilityError = class extends MongoAPIError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoCompatibilityError";
- }
- };
- exports2.MongoCompatibilityError = MongoCompatibilityError;
- var MongoMissingCredentialsError = class extends MongoAPIError {
- constructor(message) {
- super(message);
- }
- get name() {
- return "MongoMissingCredentialsError";
- }
- };
- exports2.MongoMissingCredentialsError = MongoMissingCredentialsError;
- var MongoMissingDependencyError = class extends MongoAPIError {
- constructor(message, { cause } = {}) {
- super(message);
- if (cause)
- this.cause = cause;
- }
- get name() {
- return "MongoMissingDependencyError";
- }
- };
- exports2.MongoMissingDependencyError = MongoMissingDependencyError;
- var MongoSystemError = class extends MongoError {
- constructor(message, reason) {
- var _a;
- if (reason && reason.error) {
- super(reason.error.message || reason.error);
- } else {
- super(message);
- }
- if (reason) {
- this.reason = reason;
- }
- this.code = (_a = reason.error) == null ? void 0 : _a.code;
- }
- get name() {
- return "MongoSystemError";
- }
- };
- exports2.MongoSystemError = MongoSystemError;
- var MongoServerSelectionError = class extends MongoSystemError {
- constructor(message, reason) {
- super(message, reason);
- }
- get name() {
- return "MongoServerSelectionError";
- }
- };
- exports2.MongoServerSelectionError = MongoServerSelectionError;
- function makeWriteConcernResultObject(input) {
- const output = Object.assign({}, input);
- if (output.ok === 0) {
- output.ok = 1;
- delete output.errmsg;
- delete output.code;
- delete output.codeName;
- }
- return output;
- }
- var MongoWriteConcernError = class extends MongoServerError {
- constructor(message, result) {
- if (result && Array.isArray(result.errorLabels)) {
- message.errorLabels = result.errorLabels;
- }
- super(message);
- this.errInfo = message.errInfo;
- if (result != null) {
- this.result = makeWriteConcernResultObject(result);
- }
- }
- get name() {
- return "MongoWriteConcernError";
- }
- };
- exports2.MongoWriteConcernError = MongoWriteConcernError;
- var RETRYABLE_READ_ERROR_CODES = /* @__PURE__ */ new Set([
- exports2.MONGODB_ERROR_CODES.HostUnreachable,
- exports2.MONGODB_ERROR_CODES.HostNotFound,
- exports2.MONGODB_ERROR_CODES.NetworkTimeout,
- exports2.MONGODB_ERROR_CODES.ShutdownInProgress,
- exports2.MONGODB_ERROR_CODES.PrimarySteppedDown,
- exports2.MONGODB_ERROR_CODES.SocketException,
- exports2.MONGODB_ERROR_CODES.NotWritablePrimary,
- exports2.MONGODB_ERROR_CODES.InterruptedAtShutdown,
- exports2.MONGODB_ERROR_CODES.InterruptedDueToReplStateChange,
- exports2.MONGODB_ERROR_CODES.NotPrimaryNoSecondaryOk,
- exports2.MONGODB_ERROR_CODES.NotPrimaryOrSecondary
- ]);
- var RETRYABLE_WRITE_ERROR_CODES = /* @__PURE__ */ new Set([
- ...RETRYABLE_READ_ERROR_CODES,
- exports2.MONGODB_ERROR_CODES.ExceededTimeLimit
- ]);
- function needsRetryableWriteLabel(error, maxWireVersion) {
- var _a;
- if (error instanceof MongoNetworkError) {
- return true;
- }
- if (error instanceof MongoError) {
- if ((maxWireVersion >= 9 || error.hasErrorLabel(exports2.MongoErrorLabel.RetryableWriteError)) && !error.hasErrorLabel(exports2.MongoErrorLabel.HandshakeError)) {
- return false;
- }
- }
- if (error instanceof MongoWriteConcernError) {
- return RETRYABLE_WRITE_ERROR_CODES.has(((_a = error.result) == null ? void 0 : _a.code) ?? error.code ?? 0);
- }
- if (error instanceof MongoError && typeof error.code === "number") {
- return RETRYABLE_WRITE_ERROR_CODES.has(error.code);
- }
- const isNotWritablePrimaryError2 = exports2.LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE.test(error.message);
- if (isNotWritablePrimaryError2) {
- return true;
- }
- const isNodeIsRecoveringError = exports2.NODE_IS_RECOVERING_ERROR_MESSAGE.test(error.message);
- if (isNodeIsRecoveringError) {
- return true;
- }
- return false;
- }
- exports2.needsRetryableWriteLabel = needsRetryableWriteLabel;
- function isRetryableWriteError(error) {
- return error.hasErrorLabel(exports2.MongoErrorLabel.RetryableWriteError);
- }
- exports2.isRetryableWriteError = isRetryableWriteError;
- function isRetryableReadError(error) {
- const hasRetryableErrorCode = typeof error.code === "number" ? RETRYABLE_READ_ERROR_CODES.has(error.code) : false;
- if (hasRetryableErrorCode) {
- return true;
- }
- if (error instanceof MongoNetworkError) {
- return true;
- }
- const isNotWritablePrimaryError2 = exports2.LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE.test(error.message);
- if (isNotWritablePrimaryError2) {
- return true;
- }
- const isNodeIsRecoveringError = exports2.NODE_IS_RECOVERING_ERROR_MESSAGE.test(error.message);
- if (isNodeIsRecoveringError) {
- return true;
- }
- return false;
- }
- exports2.isRetryableReadError = isRetryableReadError;
- var SDAM_RECOVERING_CODES = /* @__PURE__ */ new Set([
- exports2.MONGODB_ERROR_CODES.ShutdownInProgress,
- exports2.MONGODB_ERROR_CODES.PrimarySteppedDown,
- exports2.MONGODB_ERROR_CODES.InterruptedAtShutdown,
- exports2.MONGODB_ERROR_CODES.InterruptedDueToReplStateChange,
- exports2.MONGODB_ERROR_CODES.NotPrimaryOrSecondary
- ]);
- var SDAM_NOT_PRIMARY_CODES = /* @__PURE__ */ new Set([
- exports2.MONGODB_ERROR_CODES.NotWritablePrimary,
- exports2.MONGODB_ERROR_CODES.NotPrimaryNoSecondaryOk,
- exports2.MONGODB_ERROR_CODES.LegacyNotPrimary
- ]);
- var SDAM_NODE_SHUTTING_DOWN_ERROR_CODES = /* @__PURE__ */ new Set([
- exports2.MONGODB_ERROR_CODES.InterruptedAtShutdown,
- exports2.MONGODB_ERROR_CODES.ShutdownInProgress
- ]);
- function isRecoveringError(err) {
- if (typeof err.code === "number") {
- return SDAM_RECOVERING_CODES.has(err.code);
- }
- return exports2.LEGACY_NOT_PRIMARY_OR_SECONDARY_ERROR_MESSAGE.test(err.message) || exports2.NODE_IS_RECOVERING_ERROR_MESSAGE.test(err.message);
- }
- function isNotWritablePrimaryError(err) {
- if (typeof err.code === "number") {
- return SDAM_NOT_PRIMARY_CODES.has(err.code);
- }
- if (isRecoveringError(err)) {
- return false;
- }
- return exports2.LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE.test(err.message);
- }
- function isNodeShuttingDownError(err) {
- return !!(typeof err.code === "number" && SDAM_NODE_SHUTTING_DOWN_ERROR_CODES.has(err.code));
- }
- exports2.isNodeShuttingDownError = isNodeShuttingDownError;
- function isSDAMUnrecoverableError(error) {
- if (error instanceof MongoParseError || error == null) {
- return true;
- }
- return isRecoveringError(error) || isNotWritablePrimaryError(error);
- }
- exports2.isSDAMUnrecoverableError = isSDAMUnrecoverableError;
- function isNetworkTimeoutError(err) {
- return !!(err instanceof MongoNetworkError && err.message.match(/timed out/));
- }
- exports2.isNetworkTimeoutError = isNetworkTimeoutError;
- function isResumableError(error, wireVersion) {
- if (error == null || !(error instanceof MongoError)) {
- return false;
- }
- if (error instanceof MongoNetworkError) {
- return true;
- }
- if (wireVersion != null && wireVersion >= 9) {
- if (error.code === exports2.MONGODB_ERROR_CODES.CursorNotFound) {
- return true;
- }
- return error.hasErrorLabel(exports2.MongoErrorLabel.ResumableChangeStreamError);
- }
- if (typeof error.code === "number") {
- return exports2.GET_MORE_RESUMABLE_CODES.has(error.code);
- }
- return false;
- }
- exports2.isResumableError = isResumableError;
- }
- });
- // node_modules/bson/lib/bson.cjs
- var require_bson = __commonJS({
- "node_modules/bson/lib/bson.cjs"(exports2) {
- "use strict";
- function isAnyArrayBuffer(value) {
- return ["[object ArrayBuffer]", "[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(value));
- }
- function isUint8Array(value) {
- return Object.prototype.toString.call(value) === "[object Uint8Array]";
- }
- function isRegExp(d) {
- return Object.prototype.toString.call(d) === "[object RegExp]";
- }
- function isMap(d) {
- return Object.prototype.toString.call(d) === "[object Map]";
- }
- function isDate(d) {
- return Object.prototype.toString.call(d) === "[object Date]";
- }
- var BSON_MAJOR_VERSION = 5;
- var BSON_INT32_MAX = 2147483647;
- var BSON_INT32_MIN = -2147483648;
- var BSON_INT64_MAX = Math.pow(2, 63) - 1;
- var BSON_INT64_MIN = -Math.pow(2, 63);
- var JS_INT_MAX = Math.pow(2, 53);
- var JS_INT_MIN = -Math.pow(2, 53);
- var BSON_DATA_NUMBER = 1;
- var BSON_DATA_STRING = 2;
- var BSON_DATA_OBJECT = 3;
- var BSON_DATA_ARRAY = 4;
- var BSON_DATA_BINARY = 5;
- var BSON_DATA_UNDEFINED = 6;
- var BSON_DATA_OID = 7;
- var BSON_DATA_BOOLEAN = 8;
- var BSON_DATA_DATE = 9;
- var BSON_DATA_NULL = 10;
- var BSON_DATA_REGEXP = 11;
- var BSON_DATA_DBPOINTER = 12;
- var BSON_DATA_CODE = 13;
- var BSON_DATA_SYMBOL = 14;
- var BSON_DATA_CODE_W_SCOPE = 15;
- var BSON_DATA_INT = 16;
- var BSON_DATA_TIMESTAMP = 17;
- var BSON_DATA_LONG = 18;
- var BSON_DATA_DECIMAL128 = 19;
- var BSON_DATA_MIN_KEY = 255;
- var BSON_DATA_MAX_KEY = 127;
- var BSON_BINARY_SUBTYPE_DEFAULT = 0;
- var BSON_BINARY_SUBTYPE_UUID_NEW = 4;
- var BSONType = Object.freeze({
- double: 1,
- string: 2,
- object: 3,
- array: 4,
- binData: 5,
- undefined: 6,
- objectId: 7,
- bool: 8,
- date: 9,
- null: 10,
- regex: 11,
- dbPointer: 12,
- javascript: 13,
- symbol: 14,
- javascriptWithScope: 15,
- int: 16,
- timestamp: 17,
- long: 18,
- decimal: 19,
- minKey: -1,
- maxKey: 127
- });
- var BSONError = class extends Error {
- get bsonError() {
- return true;
- }
- get name() {
- return "BSONError";
- }
- constructor(message) {
- super(message);
- }
- static isBSONError(value) {
- return value != null && typeof value === "object" && "bsonError" in value && value.bsonError === true && "name" in value && "message" in value && "stack" in value;
- }
- };
- var BSONVersionError = class extends BSONError {
- get name() {
- return "BSONVersionError";
- }
- constructor() {
- super(`Unsupported BSON version, bson types must be from bson ${BSON_MAJOR_VERSION}.x.x`);
- }
- };
- var BSONRuntimeError = class extends BSONError {
- get name() {
- return "BSONRuntimeError";
- }
- constructor(message) {
- super(message);
- }
- };
- function nodejsMathRandomBytes(byteLength) {
- return nodeJsByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256)));
- }
- var nodejsRandomBytes = (() => {
- try {
- return require("crypto").randomBytes;
- } catch {
- return nodejsMathRandomBytes;
- }
- })();
- var nodeJsByteUtils = {
- toLocalBufferType(potentialBuffer) {
- if (Buffer.isBuffer(potentialBuffer)) {
- return potentialBuffer;
- }
- if (ArrayBuffer.isView(potentialBuffer)) {
- return Buffer.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength);
- }
- const stringTag = (potentialBuffer == null ? void 0 : potentialBuffer[Symbol.toStringTag]) ?? Object.prototype.toString.call(potentialBuffer);
- if (stringTag === "ArrayBuffer" || stringTag === "SharedArrayBuffer" || stringTag === "[object ArrayBuffer]" || stringTag === "[object SharedArrayBuffer]") {
- return Buffer.from(potentialBuffer);
- }
- throw new BSONError(`Cannot create Buffer from ${String(potentialBuffer)}`);
- },
- allocate(size) {
- return Buffer.alloc(size);
- },
- equals(a, b) {
- return nodeJsByteUtils.toLocalBufferType(a).equals(b);
- },
- fromNumberArray(array) {
- return Buffer.from(array);
- },
- fromBase64(base64) {
- return Buffer.from(base64, "base64");
- },
- toBase64(buffer2) {
- return nodeJsByteUtils.toLocalBufferType(buffer2).toString("base64");
- },
- fromISO88591(codePoints) {
- return Buffer.from(codePoints, "binary");
- },
- toISO88591(buffer2) {
- return nodeJsByteUtils.toLocalBufferType(buffer2).toString("binary");
- },
- fromHex(hex) {
- return Buffer.from(hex, "hex");
- },
- toHex(buffer2) {
- return nodeJsByteUtils.toLocalBufferType(buffer2).toString("hex");
- },
- fromUTF8(text) {
- return Buffer.from(text, "utf8");
- },
- toUTF8(buffer2, start, end) {
- return nodeJsByteUtils.toLocalBufferType(buffer2).toString("utf8", start, end);
- },
- utf8ByteLength(input) {
- return Buffer.byteLength(input, "utf8");
- },
- encodeUTF8Into(buffer2, source, byteOffset) {
- return nodeJsByteUtils.toLocalBufferType(buffer2).write(source, byteOffset, void 0, "utf8");
- },
- randomBytes: nodejsRandomBytes
- };
- function isReactNative() {
- const { navigator: navigator2 } = globalThis;
- return typeof navigator2 === "object" && navigator2.product === "ReactNative";
- }
- function webMathRandomBytes(byteLength) {
- if (byteLength < 0) {
- throw new RangeError(`The argument 'byteLength' is invalid. Received ${byteLength}`);
- }
- return webByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256)));
- }
- var webRandomBytes = (() => {
- var _a2;
- const { crypto } = globalThis;
- if (crypto != null && typeof crypto.getRandomValues === "function") {
- return (byteLength) => {
- return crypto.getRandomValues(webByteUtils.allocate(byteLength));
- };
- } else {
- if (isReactNative()) {
- const { console } = globalThis;
- (_a2 = console == null ? void 0 : console.warn) == null ? void 0 : _a2.call(console, "BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.");
- }
- return webMathRandomBytes;
- }
- })();
- var HEX_DIGIT = /(\d|[a-f])/i;
- var webByteUtils = {
- toLocalBufferType(potentialUint8array) {
- const stringTag = (potentialUint8array == null ? void 0 : potentialUint8array[Symbol.toStringTag]) ?? Object.prototype.toString.call(potentialUint8array);
- if (stringTag === "Uint8Array") {
- return potentialUint8array;
- }
- if (ArrayBuffer.isView(potentialUint8array)) {
- return new Uint8Array(potentialUint8array.buffer.slice(potentialUint8array.byteOffset, potentialUint8array.byteOffset + potentialUint8array.byteLength));
- }
- if (stringTag === "ArrayBuffer" || stringTag === "SharedArrayBuffer" || stringTag === "[object ArrayBuffer]" || stringTag === "[object SharedArrayBuffer]") {
- return new Uint8Array(potentialUint8array);
- }
- throw new BSONError(`Cannot make a Uint8Array from ${String(potentialUint8array)}`);
- },
- allocate(size) {
- if (typeof size !== "number") {
- throw new TypeError(`The "size" argument must be of type number. Received ${String(size)}`);
- }
- return new Uint8Array(size);
- },
- equals(a, b) {
- if (a.byteLength !== b.byteLength) {
- return false;
- }
- for (let i = 0; i < a.byteLength; i++) {
- if (a[i] !== b[i]) {
- return false;
- }
- }
- return true;
- },
- fromNumberArray(array) {
- return Uint8Array.from(array);
- },
- fromBase64(base64) {
- return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
- },
- toBase64(uint8array) {
- return btoa(webByteUtils.toISO88591(uint8array));
- },
- fromISO88591(codePoints) {
- return Uint8Array.from(codePoints, (c) => c.charCodeAt(0) & 255);
- },
- toISO88591(uint8array) {
- return Array.from(Uint16Array.from(uint8array), (b) => String.fromCharCode(b)).join("");
- },
- fromHex(hex) {
- const evenLengthHex = hex.length % 2 === 0 ? hex : hex.slice(0, hex.length - 1);
- const buffer2 = [];
- for (let i = 0; i < evenLengthHex.length; i += 2) {
- const firstDigit = evenLengthHex[i];
- const secondDigit = evenLengthHex[i + 1];
- if (!HEX_DIGIT.test(firstDigit)) {
- break;
- }
- if (!HEX_DIGIT.test(secondDigit)) {
- break;
- }
- const hexDigit = Number.parseInt(`${firstDigit}${secondDigit}`, 16);
- buffer2.push(hexDigit);
- }
- return Uint8Array.from(buffer2);
- },
- toHex(uint8array) {
- return Array.from(uint8array, (byte) => byte.toString(16).padStart(2, "0")).join("");
- },
- fromUTF8(text) {
- return new TextEncoder().encode(text);
- },
- toUTF8(uint8array, start, end) {
- return new TextDecoder("utf8", { fatal: false }).decode(uint8array.slice(start, end));
- },
- utf8ByteLength(input) {
- return webByteUtils.fromUTF8(input).byteLength;
- },
- encodeUTF8Into(buffer2, source, byteOffset) {
- const bytes = webByteUtils.fromUTF8(source);
- buffer2.set(bytes, byteOffset);
- return bytes.byteLength;
- },
- randomBytes: webRandomBytes
- };
- var _a;
- var hasGlobalBuffer = typeof Buffer === "function" && ((_a = Buffer.prototype) == null ? void 0 : _a._isBuffer) !== true;
- var ByteUtils = hasGlobalBuffer ? nodeJsByteUtils : webByteUtils;
- var BSONDataView = class extends DataView {
- static fromUint8Array(input) {
- return new DataView(input.buffer, input.byteOffset, input.byteLength);
- }
- };
- var BSONValue = class {
- get [Symbol.for("@@mdb.bson.version")]() {
- return BSON_MAJOR_VERSION;
- }
- };
- var Binary = class _Binary extends BSONValue {
- get _bsontype() {
- return "Binary";
- }
- constructor(buffer2, subType) {
- super();
- if (!(buffer2 == null) && !(typeof buffer2 === "string") && !ArrayBuffer.isView(buffer2) && !(buffer2 instanceof ArrayBuffer) && !Array.isArray(buffer2)) {
- throw new BSONError("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");
- }
- this.sub_type = subType ?? _Binary.BSON_BINARY_SUBTYPE_DEFAULT;
- if (buffer2 == null) {
- this.buffer = ByteUtils.allocate(_Binary.BUFFER_SIZE);
- this.position = 0;
- } else {
- if (typeof buffer2 === "string") {
- this.buffer = ByteUtils.fromISO88591(buffer2);
- } else if (Array.isArray(buffer2)) {
- this.buffer = ByteUtils.fromNumberArray(buffer2);
- } else {
- this.buffer = ByteUtils.toLocalBufferType(buffer2);
- }
- this.position = this.buffer.byteLength;
- }
- }
- put(byteValue) {
- if (typeof byteValue === "string" && byteValue.length !== 1) {
- throw new BSONError("only accepts single character String");
- } else if (typeof byteValue !== "number" && byteValue.length !== 1)
- throw new BSONError("only accepts single character Uint8Array or Array");
- let decodedByte;
- if (typeof byteValue === "string") {
- decodedByte = byteValue.charCodeAt(0);
- } else if (typeof byteValue === "number") {
- decodedByte = byteValue;
- } else {
- decodedByte = byteValue[0];
- }
- if (decodedByte < 0 || decodedByte > 255) {
- throw new BSONError("only accepts number in a valid unsigned byte range 0-255");
- }
- if (this.buffer.byteLength > this.position) {
- this.buffer[this.position++] = decodedByte;
- } else {
- const newSpace = ByteUtils.allocate(_Binary.BUFFER_SIZE + this.buffer.length);
- newSpace.set(this.buffer, 0);
- this.buffer = newSpace;
- this.buffer[this.position++] = decodedByte;
- }
- }
- write(sequence, offset) {
- offset = typeof offset === "number" ? offset : this.position;
- if (this.buffer.byteLength < offset + sequence.length) {
- const newSpace = ByteUtils.allocate(this.buffer.byteLength + sequence.length);
- newSpace.set(this.buffer, 0);
- this.buffer = newSpace;
- }
- if (ArrayBuffer.isView(sequence)) {
- this.buffer.set(ByteUtils.toLocalBufferType(sequence), offset);
- this.position = offset + sequence.byteLength > this.position ? offset + sequence.length : this.position;
- } else if (typeof sequence === "string") {
- const bytes = ByteUtils.fromISO88591(sequence);
- this.buffer.set(bytes, offset);
- this.position = offset + sequence.length > this.position ? offset + sequence.length : this.position;
- }
- }
- read(position, length) {
- length = length && length > 0 ? length : this.position;
- return this.buffer.slice(position, position + length);
- }
- value(asRaw) {
- asRaw = !!asRaw;
- if (asRaw && this.buffer.length === this.position) {
- return this.buffer;
- }
- if (asRaw) {
- return this.buffer.slice(0, this.position);
- }
- return ByteUtils.toISO88591(this.buffer.subarray(0, this.position));
- }
- length() {
- return this.position;
- }
- toJSON() {
- return ByteUtils.toBase64(this.buffer);
- }
- toString(encoding) {
- if (encoding === "hex")
- return ByteUtils.toHex(this.buffer);
- if (encoding === "base64")
- return ByteUtils.toBase64(this.buffer);
- if (encoding === "utf8" || encoding === "utf-8")
- return ByteUtils.toUTF8(this.buffer, 0, this.buffer.byteLength);
- return ByteUtils.toUTF8(this.buffer, 0, this.buffer.byteLength);
- }
- toExtendedJSON(options) {
- options = options || {};
- const base64String = ByteUtils.toBase64(this.buffer);
- const subType = Number(this.sub_type).toString(16);
- if (options.legacy) {
- return {
- $binary: base64String,
- $type: subType.length === 1 ? "0" + subType : subType
- };
- }
- return {
- $binary: {
- base64: base64String,
- subType: subType.length === 1 ? "0" + subType : subType
- }
- };
- }
- toUUID() {
- if (this.sub_type === _Binary.SUBTYPE_UUID) {
- return new UUID(this.buffer.slice(0, this.position));
- }
- throw new BSONError(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${_Binary.SUBTYPE_UUID}" is currently supported.`);
- }
- static createFromHexString(hex, subType) {
- return new _Binary(ByteUtils.fromHex(hex), subType);
- }
- static createFromBase64(base64, subType) {
- return new _Binary(ByteUtils.fromBase64(base64), subType);
- }
- static fromExtendedJSON(doc, options) {
- options = options || {};
- let data;
- let type;
- if ("$binary" in doc) {
- if (options.legacy && typeof doc.$binary === "string" && "$type" in doc) {
- type = doc.$type ? parseInt(doc.$type, 16) : 0;
- data = ByteUtils.fromBase64(doc.$binary);
- } else {
- if (typeof doc.$binary !== "string") {
- type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0;
- data = ByteUtils.fromBase64(doc.$binary.base64);
- }
- }
- } else if ("$uuid" in doc) {
- type = 4;
- data = UUID.bytesFromString(doc.$uuid);
- }
- if (!data) {
- throw new BSONError(`Unexpected Binary Extended JSON format ${JSON.stringify(doc)}`);
- }
- return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new _Binary(data, type);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- const base64 = ByteUtils.toBase64(this.buffer.subarray(0, this.position));
- return `Binary.createFromBase64("${base64}", ${this.sub_type})`;
- }
- };
- Binary.BSON_BINARY_SUBTYPE_DEFAULT = 0;
- Binary.BUFFER_SIZE = 256;
- Binary.SUBTYPE_DEFAULT = 0;
- Binary.SUBTYPE_FUNCTION = 1;
- Binary.SUBTYPE_BYTE_ARRAY = 2;
- Binary.SUBTYPE_UUID_OLD = 3;
- Binary.SUBTYPE_UUID = 4;
- Binary.SUBTYPE_MD5 = 5;
- Binary.SUBTYPE_ENCRYPTED = 6;
- Binary.SUBTYPE_COLUMN = 7;
- Binary.SUBTYPE_USER_DEFINED = 128;
- var UUID_BYTE_LENGTH = 16;
- var UUID_WITHOUT_DASHES = /^[0-9A-F]{32}$/i;
- var UUID_WITH_DASHES = /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;
- var UUID = class _UUID extends Binary {
- constructor(input) {
- let bytes;
- if (input == null) {
- bytes = _UUID.generate();
- } else if (input instanceof _UUID) {
- bytes = ByteUtils.toLocalBufferType(new Uint8Array(input.buffer));
- } else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) {
- bytes = ByteUtils.toLocalBufferType(input);
- } else if (typeof input === "string") {
- bytes = _UUID.bytesFromString(input);
- } else {
- throw new BSONError("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");
- }
- super(bytes, BSON_BINARY_SUBTYPE_UUID_NEW);
- }
- get id() {
- return this.buffer;
- }
- set id(value) {
- this.buffer = value;
- }
- toHexString(includeDashes = true) {
- if (includeDashes) {
- return [
- ByteUtils.toHex(this.buffer.subarray(0, 4)),
- ByteUtils.toHex(this.buffer.subarray(4, 6)),
- ByteUtils.toHex(this.buffer.subarray(6, 8)),
- ByteUtils.toHex(this.buffer.subarray(8, 10)),
- ByteUtils.toHex(this.buffer.subarray(10, 16))
- ].join("-");
- }
- return ByteUtils.toHex(this.buffer);
- }
- toString(encoding) {
- if (encoding === "hex")
- return ByteUtils.toHex(this.id);
- if (encoding === "base64")
- return ByteUtils.toBase64(this.id);
- return this.toHexString();
- }
- toJSON() {
- return this.toHexString();
- }
- equals(otherId) {
- if (!otherId) {
- return false;
- }
- if (otherId instanceof _UUID) {
- return ByteUtils.equals(otherId.id, this.id);
- }
- try {
- return ByteUtils.equals(new _UUID(otherId).id, this.id);
- } catch {
- return false;
- }
- }
- toBinary() {
- return new Binary(this.id, Binary.SUBTYPE_UUID);
- }
- static generate() {
- const bytes = ByteUtils.randomBytes(UUID_BYTE_LENGTH);
- bytes[6] = bytes[6] & 15 | 64;
- bytes[8] = bytes[8] & 63 | 128;
- return bytes;
- }
- static isValid(input) {
- if (!input) {
- return false;
- }
- if (typeof input === "string") {
- return _UUID.isValidUUIDString(input);
- }
- if (isUint8Array(input)) {
- return input.byteLength === UUID_BYTE_LENGTH;
- }
- return input._bsontype === "Binary" && input.sub_type === this.SUBTYPE_UUID && input.buffer.byteLength === 16;
- }
- static createFromHexString(hexString) {
- const buffer2 = _UUID.bytesFromString(hexString);
- return new _UUID(buffer2);
- }
- static createFromBase64(base64) {
- return new _UUID(ByteUtils.fromBase64(base64));
- }
- static bytesFromString(representation) {
- if (!_UUID.isValidUUIDString(representation)) {
- throw new BSONError("UUID string representation must be 32 hex digits or canonical hyphenated representation");
- }
- return ByteUtils.fromHex(representation.replace(/-/g, ""));
- }
- static isValidUUIDString(representation) {
- return UUID_WITHOUT_DASHES.test(representation) || UUID_WITH_DASHES.test(representation);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- return `new UUID("${this.toHexString()}")`;
- }
- };
- UUID.cacheHexString = false;
- var Code = class _Code extends BSONValue {
- get _bsontype() {
- return "Code";
- }
- constructor(code, scope) {
- super();
- this.code = code.toString();
- this.scope = scope ?? null;
- }
- toJSON() {
- if (this.scope != null) {
- return { code: this.code, scope: this.scope };
- }
- return { code: this.code };
- }
- toExtendedJSON() {
- if (this.scope) {
- return { $code: this.code, $scope: this.scope };
- }
- return { $code: this.code };
- }
- static fromExtendedJSON(doc) {
- return new _Code(doc.$code, doc.$scope);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- const codeJson = this.toJSON();
- return `new Code("${String(codeJson.code)}"${codeJson.scope != null ? `, ${JSON.stringify(codeJson.scope)}` : ""})`;
- }
- };
- function isDBRefLike(value) {
- return value != null && typeof value === "object" && "$id" in value && value.$id != null && "$ref" in value && typeof value.$ref === "string" && (!("$db" in value) || "$db" in value && typeof value.$db === "string");
- }
- var DBRef = class _DBRef extends BSONValue {
- get _bsontype() {
- return "DBRef";
- }
- constructor(collection, oid, db, fields) {
- super();
- const parts = collection.split(".");
- if (parts.length === 2) {
- db = parts.shift();
- collection = parts.shift();
- }
- this.collection = collection;
- this.oid = oid;
- this.db = db;
- this.fields = fields || {};
- }
- get namespace() {
- return this.collection;
- }
- set namespace(value) {
- this.collection = value;
- }
- toJSON() {
- const o = Object.assign({
- $ref: this.collection,
- $id: this.oid
- }, this.fields);
- if (this.db != null)
- o.$db = this.db;
- return o;
- }
- toExtendedJSON(options) {
- options = options || {};
- let o = {
- $ref: this.collection,
- $id: this.oid
- };
- if (options.legacy) {
- return o;
- }
- if (this.db)
- o.$db = this.db;
- o = Object.assign(o, this.fields);
- return o;
- }
- static fromExtendedJSON(doc) {
- const copy = Object.assign({}, doc);
- delete copy.$ref;
- delete copy.$id;
- delete copy.$db;
- return new _DBRef(doc.$ref, doc.$id, doc.$db, copy);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- const oid = this.oid === void 0 || this.oid.toString === void 0 ? this.oid : this.oid.toString();
- return `new DBRef("${this.namespace}", new ObjectId("${String(oid)}")${this.db ? `, "${this.db}"` : ""})`;
- }
- };
- var wasm = void 0;
- try {
- wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports;
- } catch {
- }
- var TWO_PWR_16_DBL = 1 << 16;
- var TWO_PWR_24_DBL = 1 << 24;
- var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
- var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
- var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
- var INT_CACHE = {};
- var UINT_CACHE = {};
- var MAX_INT64_STRING_LENGTH = 20;
- var DECIMAL_REG_EX = /^(\+?0|(\+|-)?[1-9][0-9]*)$/;
- var Long = class _Long extends BSONValue {
- get _bsontype() {
- return "Long";
- }
- get __isLong__() {
- return true;
- }
- constructor(low = 0, high, unsigned) {
- super();
- if (typeof low === "bigint") {
- Object.assign(this, _Long.fromBigInt(low, !!high));
- } else if (typeof low === "string") {
- Object.assign(this, _Long.fromString(low, !!high));
- } else {
- this.low = low | 0;
- this.high = high | 0;
- this.unsigned = !!unsigned;
- }
- }
- static fromBits(lowBits, highBits, unsigned) {
- return new _Long(lowBits, highBits, unsigned);
- }
- static fromInt(value, unsigned) {
- let obj, cachedObj, cache;
- if (unsigned) {
- value >>>= 0;
- if (cache = 0 <= value && value < 256) {
- cachedObj = UINT_CACHE[value];
- if (cachedObj)
- return cachedObj;
- }
- obj = _Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true);
- if (cache)
- UINT_CACHE[value] = obj;
- return obj;
- } else {
- value |= 0;
- if (cache = -128 <= value && value < 128) {
- cachedObj = INT_CACHE[value];
- if (cachedObj)
- return cachedObj;
- }
- obj = _Long.fromBits(value, value < 0 ? -1 : 0, false);
- if (cache)
- INT_CACHE[value] = obj;
- return obj;
- }
- }
- static fromNumber(value, unsigned) {
- if (isNaN(value))
- return unsigned ? _Long.UZERO : _Long.ZERO;
- if (unsigned) {
- if (value < 0)
- return _Long.UZERO;
- if (value >= TWO_PWR_64_DBL)
- return _Long.MAX_UNSIGNED_VALUE;
- } else {
- if (value <= -TWO_PWR_63_DBL)
- return _Long.MIN_VALUE;
- if (value + 1 >= TWO_PWR_63_DBL)
- return _Long.MAX_VALUE;
- }
- if (value < 0)
- return _Long.fromNumber(-value, unsigned).neg();
- return _Long.fromBits(value % TWO_PWR_32_DBL | 0, value / TWO_PWR_32_DBL | 0, unsigned);
- }
- static fromBigInt(value, unsigned) {
- return _Long.fromString(value.toString(), unsigned);
- }
- static fromString(str, unsigned, radix) {
- if (str.length === 0)
- throw new BSONError("empty string");
- if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
- return _Long.ZERO;
- if (typeof unsigned === "number") {
- radix = unsigned, unsigned = false;
- } else {
- unsigned = !!unsigned;
- }
- radix = radix || 10;
- if (radix < 2 || 36 < radix)
- throw new BSONError("radix");
- let p;
- if ((p = str.indexOf("-")) > 0)
- throw new BSONError("interior hyphen");
- else if (p === 0) {
- return _Long.fromString(str.substring(1), unsigned, radix).neg();
- }
- const radixToPower = _Long.fromNumber(Math.pow(radix, 8));
- let result = _Long.ZERO;
- for (let i = 0; i < str.length; i += 8) {
- const size = Math.min(8, str.length - i), value = parseInt(str.substring(i, i + size), radix);
- if (size < 8) {
- const power = _Long.fromNumber(Math.pow(radix, size));
- result = result.mul(power).add(_Long.fromNumber(value));
- } else {
- result = result.mul(radixToPower);
- result = result.add(_Long.fromNumber(value));
- }
- }
- result.unsigned = unsigned;
- return result;
- }
- static fromBytes(bytes, unsigned, le) {
- return le ? _Long.fromBytesLE(bytes, unsigned) : _Long.fromBytesBE(bytes, unsigned);
- }
- static fromBytesLE(bytes, unsigned) {
- return new _Long(bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24, bytes[4] | bytes[5] << 8 | bytes[6] << 16 | bytes[7] << 24, unsigned);
- }
- static fromBytesBE(bytes, unsigned) {
- return new _Long(bytes[4] << 24 | bytes[5] << 16 | bytes[6] << 8 | bytes[7], bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], unsigned);
- }
- static isLong(value) {
- return value != null && typeof value === "object" && "__isLong__" in value && value.__isLong__ === true;
- }
- static fromValue(val, unsigned) {
- if (typeof val === "number")
- return _Long.fromNumber(val, unsigned);
- if (typeof val === "string")
- return _Long.fromString(val, unsigned);
- return _Long.fromBits(val.low, val.high, typeof unsigned === "boolean" ? unsigned : val.unsigned);
- }
- add(addend) {
- if (!_Long.isLong(addend))
- addend = _Long.fromValue(addend);
- const a48 = this.high >>> 16;
- const a32 = this.high & 65535;
- const a16 = this.low >>> 16;
- const a00 = this.low & 65535;
- const b48 = addend.high >>> 16;
- const b32 = addend.high & 65535;
- const b16 = addend.low >>> 16;
- const b00 = addend.low & 65535;
- let c48 = 0, c32 = 0, c16 = 0, c00 = 0;
- c00 += a00 + b00;
- c16 += c00 >>> 16;
- c00 &= 65535;
- c16 += a16 + b16;
- c32 += c16 >>> 16;
- c16 &= 65535;
- c32 += a32 + b32;
- c48 += c32 >>> 16;
- c32 &= 65535;
- c48 += a48 + b48;
- c48 &= 65535;
- return _Long.fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
- }
- and(other) {
- if (!_Long.isLong(other))
- other = _Long.fromValue(other);
- return _Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned);
- }
- compare(other) {
- if (!_Long.isLong(other))
- other = _Long.fromValue(other);
- if (this.eq(other))
- return 0;
- const thisNeg = this.isNegative(), otherNeg = other.isNegative();
- if (thisNeg && !otherNeg)
- return -1;
- if (!thisNeg && otherNeg)
- return 1;
- if (!this.unsigned)
- return this.sub(other).isNegative() ? -1 : 1;
- return other.high >>> 0 > this.high >>> 0 || other.high === this.high && other.low >>> 0 > this.low >>> 0 ? -1 : 1;
- }
- comp(other) {
- return this.compare(other);
- }
- divide(divisor) {
- if (!_Long.isLong(divisor))
- divisor = _Long.fromValue(divisor);
- if (divisor.isZero())
- throw new BSONError("division by zero");
- if (wasm) {
- if (!this.unsigned && this.high === -2147483648 && divisor.low === -1 && divisor.high === -1) {
- return this;
- }
- const low = (this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, divisor.low, divisor.high);
- return _Long.fromBits(low, wasm.get_high(), this.unsigned);
- }
- if (this.isZero())
- return this.unsigned ? _Long.UZERO : _Long.ZERO;
- let approx, rem, res;
- if (!this.unsigned) {
- if (this.eq(_Long.MIN_VALUE)) {
- if (divisor.eq(_Long.ONE) || divisor.eq(_Long.NEG_ONE))
- return _Long.MIN_VALUE;
- else if (divisor.eq(_Long.MIN_VALUE))
- return _Long.ONE;
- else {
- const halfThis = this.shr(1);
- approx = halfThis.div(divisor).shl(1);
- if (approx.eq(_Long.ZERO)) {
- return divisor.isNegative() ? _Long.ONE : _Long.NEG_ONE;
- } else {
- rem = this.sub(divisor.mul(approx));
- res = approx.add(rem.div(divisor));
- return res;
- }
- }
- } else if (divisor.eq(_Long.MIN_VALUE))
- return this.unsigned ? _Long.UZERO : _Long.ZERO;
- if (this.isNegative()) {
- if (divisor.isNegative())
- return this.neg().div(divisor.neg());
- return this.neg().div(divisor).neg();
- } else if (divisor.isNegative())
- return this.div(divisor.neg()).neg();
- res = _Long.ZERO;
- } else {
- if (!divisor.unsigned)
- divisor = divisor.toUnsigned();
- if (divisor.gt(this))
- return _Long.UZERO;
- if (divisor.gt(this.shru(1)))
- return _Long.UONE;
- res = _Long.UZERO;
- }
- rem = this;
- while (rem.gte(divisor)) {
- approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
- const log2 = Math.ceil(Math.log(approx) / Math.LN2);
- const delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48);
- let approxRes = _Long.fromNumber(approx);
- let approxRem = approxRes.mul(divisor);
- while (approxRem.isNegative() || approxRem.gt(rem)) {
- approx -= delta;
- approxRes = _Long.fromNumber(approx, this.unsigned);
- approxRem = approxRes.mul(divisor);
- }
- if (approxRes.isZero())
- approxRes = _Long.ONE;
- res = res.add(approxRes);
- rem = rem.sub(approxRem);
- }
- return res;
- }
- div(divisor) {
- return this.divide(divisor);
- }
- equals(other) {
- if (!_Long.isLong(other))
- other = _Long.fromValue(other);
- if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1)
- return false;
- return this.high === other.high && this.low === other.low;
- }
- eq(other) {
- return this.equals(other);
- }
- getHighBits() {
- return this.high;
- }
- getHighBitsUnsigned() {
- return this.high >>> 0;
- }
- getLowBits() {
- return this.low;
- }
- getLowBitsUnsigned() {
- return this.low >>> 0;
- }
- getNumBitsAbs() {
- if (this.isNegative()) {
- return this.eq(_Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();
- }
- const val = this.high !== 0 ? this.high : this.low;
- let bit;
- for (bit = 31; bit > 0; bit--)
- if ((val & 1 << bit) !== 0)
- break;
- return this.high !== 0 ? bit + 33 : bit + 1;
- }
- greaterThan(other) {
- return this.comp(other) > 0;
- }
- gt(other) {
- return this.greaterThan(other);
- }
- greaterThanOrEqual(other) {
- return this.comp(other) >= 0;
- }
- gte(other) {
- return this.greaterThanOrEqual(other);
- }
- ge(other) {
- return this.greaterThanOrEqual(other);
- }
- isEven() {
- return (this.low & 1) === 0;
- }
- isNegative() {
- return !this.unsigned && this.high < 0;
- }
- isOdd() {
- return (this.low & 1) === 1;
- }
- isPositive() {
- return this.unsigned || this.high >= 0;
- }
- isZero() {
- return this.high === 0 && this.low === 0;
- }
- lessThan(other) {
- return this.comp(other) < 0;
- }
- lt(other) {
- return this.lessThan(other);
- }
- lessThanOrEqual(other) {
- return this.comp(other) <= 0;
- }
- lte(other) {
- return this.lessThanOrEqual(other);
- }
- modulo(divisor) {
- if (!_Long.isLong(divisor))
- divisor = _Long.fromValue(divisor);
- if (wasm) {
- const low = (this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, divisor.low, divisor.high);
- return _Long.fromBits(low, wasm.get_high(), this.unsigned);
- }
- return this.sub(this.div(divisor).mul(divisor));
- }
- mod(divisor) {
- return this.modulo(divisor);
- }
- rem(divisor) {
- return this.modulo(divisor);
- }
- multiply(multiplier) {
- if (this.isZero())
- return _Long.ZERO;
- if (!_Long.isLong(multiplier))
- multiplier = _Long.fromValue(multiplier);
- if (wasm) {
- const low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high);
- return _Long.fromBits(low, wasm.get_high(), this.unsigned);
- }
- if (multiplier.isZero())
- return _Long.ZERO;
- if (this.eq(_Long.MIN_VALUE))
- return multiplier.isOdd() ? _Long.MIN_VALUE : _Long.ZERO;
- if (multiplier.eq(_Long.MIN_VALUE))
- return this.isOdd() ? _Long.MIN_VALUE : _Long.ZERO;
- if (this.isNegative()) {
- if (multiplier.isNegative())
- return this.neg().mul(multiplier.neg());
- else
- return this.neg().mul(multiplier).neg();
- } else if (multiplier.isNegative())
- return this.mul(multiplier.neg()).neg();
- if (this.lt(_Long.TWO_PWR_24) && multiplier.lt(_Long.TWO_PWR_24))
- return _Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);
- const a48 = this.high >>> 16;
- const a32 = this.high & 65535;
- const a16 = this.low >>> 16;
- const a00 = this.low & 65535;
- const b48 = multiplier.high >>> 16;
- const b32 = multiplier.high & 65535;
- const b16 = multiplier.low >>> 16;
- const b00 = multiplier.low & 65535;
- let c48 = 0, c32 = 0, c16 = 0, c00 = 0;
- c00 += a00 * b00;
- c16 += c00 >>> 16;
- c00 &= 65535;
- c16 += a16 * b00;
- c32 += c16 >>> 16;
- c16 &= 65535;
- c16 += a00 * b16;
- c32 += c16 >>> 16;
- c16 &= 65535;
- c32 += a32 * b00;
- c48 += c32 >>> 16;
- c32 &= 65535;
- c32 += a16 * b16;
- c48 += c32 >>> 16;
- c32 &= 65535;
- c32 += a00 * b32;
- c48 += c32 >>> 16;
- c32 &= 65535;
- c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
- c48 &= 65535;
- return _Long.fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
- }
- mul(multiplier) {
- return this.multiply(multiplier);
- }
- negate() {
- if (!this.unsigned && this.eq(_Long.MIN_VALUE))
- return _Long.MIN_VALUE;
- return this.not().add(_Long.ONE);
- }
- neg() {
- return this.negate();
- }
- not() {
- return _Long.fromBits(~this.low, ~this.high, this.unsigned);
- }
- notEquals(other) {
- return !this.equals(other);
- }
- neq(other) {
- return this.notEquals(other);
- }
- ne(other) {
- return this.notEquals(other);
- }
- or(other) {
- if (!_Long.isLong(other))
- other = _Long.fromValue(other);
- return _Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned);
- }
- shiftLeft(numBits) {
- if (_Long.isLong(numBits))
- numBits = numBits.toInt();
- if ((numBits &= 63) === 0)
- return this;
- else if (numBits < 32)
- return _Long.fromBits(this.low << numBits, this.high << numBits | this.low >>> 32 - numBits, this.unsigned);
- else
- return _Long.fromBits(0, this.low << numBits - 32, this.unsigned);
- }
- shl(numBits) {
- return this.shiftLeft(numBits);
- }
- shiftRight(numBits) {
- if (_Long.isLong(numBits))
- numBits = numBits.toInt();
- if ((numBits &= 63) === 0)
- return this;
- else if (numBits < 32)
- return _Long.fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >> numBits, this.unsigned);
- else
- return _Long.fromBits(this.high >> numBits - 32, this.high >= 0 ? 0 : -1, this.unsigned);
- }
- shr(numBits) {
- return this.shiftRight(numBits);
- }
- shiftRightUnsigned(numBits) {
- if (_Long.isLong(numBits))
- numBits = numBits.toInt();
- numBits &= 63;
- if (numBits === 0)
- return this;
- else {
- const high = this.high;
- if (numBits < 32) {
- const low = this.low;
- return _Long.fromBits(low >>> numBits | high << 32 - numBits, high >>> numBits, this.unsigned);
- } else if (numBits === 32)
- return _Long.fromBits(high, 0, this.unsigned);
- else
- return _Long.fromBits(high >>> numBits - 32, 0, this.unsigned);
- }
- }
- shr_u(numBits) {
- return this.shiftRightUnsigned(numBits);
- }
- shru(numBits) {
- return this.shiftRightUnsigned(numBits);
- }
- subtract(subtrahend) {
- if (!_Long.isLong(subtrahend))
- subtrahend = _Long.fromValue(subtrahend);
- return this.add(subtrahend.neg());
- }
- sub(subtrahend) {
- return this.subtract(subtrahend);
- }
- toInt() {
- return this.unsigned ? this.low >>> 0 : this.low;
- }
- toNumber() {
- if (this.unsigned)
- return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
- return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
- }
- toBigInt() {
- return BigInt(this.toString());
- }
- toBytes(le) {
- return le ? this.toBytesLE() : this.toBytesBE();
- }
- toBytesLE() {
- const hi = this.high, lo = this.low;
- return [
- lo & 255,
- lo >>> 8 & 255,
- lo >>> 16 & 255,
- lo >>> 24,
- hi & 255,
- hi >>> 8 & 255,
- hi >>> 16 & 255,
- hi >>> 24
- ];
- }
- toBytesBE() {
- const hi = this.high, lo = this.low;
- return [
- hi >>> 24,
- hi >>> 16 & 255,
- hi >>> 8 & 255,
- hi & 255,
- lo >>> 24,
- lo >>> 16 & 255,
- lo >>> 8 & 255,
- lo & 255
- ];
- }
- toSigned() {
- if (!this.unsigned)
- return this;
- return _Long.fromBits(this.low, this.high, false);
- }
- toString(radix) {
- radix = radix || 10;
- if (radix < 2 || 36 < radix)
- throw new BSONError("radix");
- if (this.isZero())
- return "0";
- if (this.isNegative()) {
- if (this.eq(_Long.MIN_VALUE)) {
- const radixLong = _Long.fromNumber(radix), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this);
- return div.toString(radix) + rem1.toInt().toString(radix);
- } else
- return "-" + this.neg().toString(radix);
- }
- const radixToPower = _Long.fromNumber(Math.pow(radix, 6), this.unsigned);
- let rem = this;
- let result = "";
- while (true) {
- const remDiv = rem.div(radixToPower);
- const intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0;
- let digits = intval.toString(radix);
- rem = remDiv;
- if (rem.isZero()) {
- return digits + result;
- } else {
- while (digits.length < 6)
- digits = "0" + digits;
- result = "" + digits + result;
- }
- }
- }
- toUnsigned() {
- if (this.unsigned)
- return this;
- return _Long.fromBits(this.low, this.high, true);
- }
- xor(other) {
- if (!_Long.isLong(other))
- other = _Long.fromValue(other);
- return _Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
- }
- eqz() {
- return this.isZero();
- }
- le(other) {
- return this.lessThanOrEqual(other);
- }
- toExtendedJSON(options) {
- if (options && options.relaxed)
- return this.toNumber();
- return { $numberLong: this.toString() };
- }
- static fromExtendedJSON(doc, options) {
- const { useBigInt64 = false, relaxed = true } = { ...options };
- if (doc.$numberLong.length > MAX_INT64_STRING_LENGTH) {
- throw new BSONError("$numberLong string is too long");
- }
- if (!DECIMAL_REG_EX.test(doc.$numberLong)) {
- throw new BSONError(`$numberLong string "${doc.$numberLong}" is in an invalid format`);
- }
- if (useBigInt64) {
- const bigIntResult = BigInt(doc.$numberLong);
- return BigInt.asIntN(64, bigIntResult);
- }
- const longResult = _Long.fromString(doc.$numberLong);
- if (relaxed) {
- return longResult.toNumber();
- }
- return longResult;
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- return `new Long("${this.toString()}"${this.unsigned ? ", true" : ""})`;
- }
- };
- Long.TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL);
- Long.MAX_UNSIGNED_VALUE = Long.fromBits(4294967295 | 0, 4294967295 | 0, true);
- Long.ZERO = Long.fromInt(0);
- Long.UZERO = Long.fromInt(0, true);
- Long.ONE = Long.fromInt(1);
- Long.UONE = Long.fromInt(1, true);
- Long.NEG_ONE = Long.fromInt(-1);
- Long.MAX_VALUE = Long.fromBits(4294967295 | 0, 2147483647 | 0, false);
- Long.MIN_VALUE = Long.fromBits(0, 2147483648 | 0, false);
- var PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/;
- var PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i;
- var PARSE_NAN_REGEXP = /^(\+|-)?NaN$/i;
- var EXPONENT_MAX = 6111;
- var EXPONENT_MIN = -6176;
- var EXPONENT_BIAS = 6176;
- var MAX_DIGITS = 34;
- var NAN_BUFFER = ByteUtils.fromNumberArray([
- 124,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- ].reverse());
- var INF_NEGATIVE_BUFFER = ByteUtils.fromNumberArray([
- 248,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- ].reverse());
- var INF_POSITIVE_BUFFER = ByteUtils.fromNumberArray([
- 120,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- ].reverse());
- var EXPONENT_REGEX = /^([-+])?(\d+)?$/;
- var COMBINATION_MASK = 31;
- var EXPONENT_MASK = 16383;
- var COMBINATION_INFINITY = 30;
- var COMBINATION_NAN = 31;
- function isDigit(value) {
- return !isNaN(parseInt(value, 10));
- }
- function divideu128(value) {
- const DIVISOR = Long.fromNumber(1e3 * 1e3 * 1e3);
- let _rem = Long.fromNumber(0);
- if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) {
- return { quotient: value, rem: _rem };
- }
- for (let i = 0; i <= 3; i++) {
- _rem = _rem.shiftLeft(32);
- _rem = _rem.add(new Long(value.parts[i], 0));
- value.parts[i] = _rem.div(DIVISOR).low;
- _rem = _rem.modulo(DIVISOR);
- }
- return { quotient: value, rem: _rem };
- }
- function multiply64x2(left, right) {
- if (!left && !right) {
- return { high: Long.fromNumber(0), low: Long.fromNumber(0) };
- }
- const leftHigh = left.shiftRightUnsigned(32);
- const leftLow = new Long(left.getLowBits(), 0);
- const rightHigh = right.shiftRightUnsigned(32);
- const rightLow = new Long(right.getLowBits(), 0);
- let productHigh = leftHigh.multiply(rightHigh);
- let productMid = leftHigh.multiply(rightLow);
- const productMid2 = leftLow.multiply(rightHigh);
- let productLow = leftLow.multiply(rightLow);
- productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
- productMid = new Long(productMid.getLowBits(), 0).add(productMid2).add(productLow.shiftRightUnsigned(32));
- productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
- productLow = productMid.shiftLeft(32).add(new Long(productLow.getLowBits(), 0));
- return { high: productHigh, low: productLow };
- }
- function lessThan(left, right) {
- const uhleft = left.high >>> 0;
- const uhright = right.high >>> 0;
- if (uhleft < uhright) {
- return true;
- } else if (uhleft === uhright) {
- const ulleft = left.low >>> 0;
- const ulright = right.low >>> 0;
- if (ulleft < ulright)
- return true;
- }
- return false;
- }
- function invalidErr(string, message) {
- throw new BSONError(`"${string}" is not a valid Decimal128 string - ${message}`);
- }
- var Decimal128 = class _Decimal128 extends BSONValue {
- get _bsontype() {
- return "Decimal128";
- }
- constructor(bytes) {
- super();
- if (typeof bytes === "string") {
- this.bytes = _Decimal128.fromString(bytes).bytes;
- } else if (isUint8Array(bytes)) {
- if (bytes.byteLength !== 16) {
- throw new BSONError("Decimal128 must take a Buffer of 16 bytes");
- }
- this.bytes = bytes;
- } else {
- throw new BSONError("Decimal128 must take a Buffer or string");
- }
- }
- static fromString(representation) {
- return _Decimal128._fromString(representation, { allowRounding: false });
- }
- static fromStringWithRounding(representation) {
- return _Decimal128._fromString(representation, { allowRounding: true });
- }
- static _fromString(representation, options) {
- let isNegative = false;
- let sawSign = false;
- let sawRadix = false;
- let foundNonZero = false;
- let significantDigits = 0;
- let nDigitsRead = 0;
- let nDigits = 0;
- let radixPosition = 0;
- let firstNonZero = 0;
- const digits = [0];
- let nDigitsStored = 0;
- let digitsInsert = 0;
- let lastDigit = 0;
- let exponent = 0;
- let significandHigh = new Long(0, 0);
- let significandLow = new Long(0, 0);
- let biasedExponent = 0;
- let index = 0;
- if (representation.length >= 7e3) {
- throw new BSONError("" + representation + " not a valid Decimal128 string");
- }
- const stringMatch = representation.match(PARSE_STRING_REGEXP);
- const infMatch = representation.match(PARSE_INF_REGEXP);
- const nanMatch = representation.match(PARSE_NAN_REGEXP);
- if (!stringMatch && !infMatch && !nanMatch || representation.length === 0) {
- throw new BSONError("" + representation + " not a valid Decimal128 string");
- }
- if (stringMatch) {
- const unsignedNumber = stringMatch[2];
- const e = stringMatch[4];
- const expSign = stringMatch[5];
- const expNumber = stringMatch[6];
- if (e && expNumber === void 0)
- invalidErr(representation, "missing exponent power");
- if (e && unsignedNumber === void 0)
- invalidErr(representation, "missing exponent base");
- if (e === void 0 && (expSign || expNumber)) {
- invalidErr(representation, "missing e before exponent");
- }
- }
- if (representation[index] === "+" || representation[index] === "-") {
- sawSign = true;
- isNegative = representation[index++] === "-";
- }
- if (!isDigit(representation[index]) && representation[index] !== ".") {
- if (representation[index] === "i" || representation[index] === "I") {
- return new _Decimal128(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER);
- } else if (representation[index] === "N") {
- return new _Decimal128(NAN_BUFFER);
- }
- }
- while (isDigit(representation[index]) || representation[index] === ".") {
- if (representation[index] === ".") {
- if (sawRadix)
- invalidErr(representation, "contains multiple periods");
- sawRadix = true;
- index = index + 1;
- continue;
- }
- if (nDigitsStored < MAX_DIGITS) {
- if (representation[index] !== "0" || foundNonZero) {
- if (!foundNonZero) {
- firstNonZero = nDigitsRead;
- }
- foundNonZero = true;
- digits[digitsInsert++] = parseInt(representation[index], 10);
- nDigitsStored = nDigitsStored + 1;
- }
- }
- if (foundNonZero)
- nDigits = nDigits + 1;
- if (sawRadix)
- radixPosition = radixPosition + 1;
- nDigitsRead = nDigitsRead + 1;
- index = index + 1;
- }
- if (sawRadix && !nDigitsRead)
- throw new BSONError("" + representation + " not a valid Decimal128 string");
- if (representation[index] === "e" || representation[index] === "E") {
- const match = representation.substr(++index).match(EXPONENT_REGEX);
- if (!match || !match[2])
- return new _Decimal128(NAN_BUFFER);
- exponent = parseInt(match[0], 10);
- index = index + match[0].length;
- }
- if (representation[index])
- return new _Decimal128(NAN_BUFFER);
- if (!nDigitsStored) {
- digits[0] = 0;
- nDigits = 1;
- nDigitsStored = 1;
- significantDigits = 0;
- } else {
- lastDigit = nDigitsStored - 1;
- significantDigits = nDigits;
- if (significantDigits !== 1) {
- while (representation[firstNonZero + significantDigits - 1 + Number(sawSign) + Number(sawRadix)] === "0") {
- significantDigits = significantDigits - 1;
- }
- }
- }
- if (exponent <= radixPosition && radixPosition > exponent + (1 << 14)) {
- exponent = EXPONENT_MIN;
- } else {
- exponent = exponent - radixPosition;
- }
- while (exponent > EXPONENT_MAX) {
- lastDigit = lastDigit + 1;
- if (lastDigit >= MAX_DIGITS) {
- if (significantDigits === 0) {
- exponent = EXPONENT_MAX;
- break;
- }
- invalidErr(representation, "overflow");
- }
- exponent = exponent - 1;
- }
- if (options.allowRounding) {
- while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) {
- if (lastDigit === 0 && significantDigits < nDigitsStored) {
- exponent = EXPONENT_MIN;
- significantDigits = 0;
- break;
- }
- if (nDigitsStored < nDigits) {
- nDigits = nDigits - 1;
- } else {
- lastDigit = lastDigit - 1;
- }
- if (exponent < EXPONENT_MAX) {
- exponent = exponent + 1;
- } else {
- const digitsString = digits.join("");
- if (digitsString.match(/^0+$/)) {
- exponent = EXPONENT_MAX;
- break;
- }
- invalidErr(representation, "overflow");
- }
- }
- if (lastDigit + 1 < significantDigits) {
- let endOfString = nDigitsRead;
- if (sawRadix) {
- firstNonZero = firstNonZero + 1;
- endOfString = endOfString + 1;
- }
- if (sawSign) {
- firstNonZero = firstNonZero + 1;
- endOfString = endOfString + 1;
- }
- const roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10);
- let roundBit = 0;
- if (roundDigit >= 5) {
- roundBit = 1;
- if (roundDigit === 5) {
- roundBit = digits[lastDigit] % 2 === 1 ? 1 : 0;
- for (let i = firstNonZero + lastDigit + 2; i < endOfString; i++) {
- if (parseInt(representation[i], 10)) {
- roundBit = 1;
- break;
- }
- }
- }
- }
- if (roundBit) {
- let dIdx = lastDigit;
- for (; dIdx >= 0; dIdx--) {
- if (++digits[dIdx] > 9) {
- digits[dIdx] = 0;
- if (dIdx === 0) {
- if (exponent < EXPONENT_MAX) {
- exponent = exponent + 1;
- digits[dIdx] = 1;
- } else {
- return new _Decimal128(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER);
- }
- }
- } else {
- break;
- }
- }
- }
- }
- } else {
- while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) {
- if (lastDigit === 0) {
- if (significantDigits === 0) {
- exponent = EXPONENT_MIN;
- break;
- }
- invalidErr(representation, "exponent underflow");
- }
- if (nDigitsStored < nDigits) {
- if (representation[nDigits - 1 + Number(sawSign) + Number(sawRadix)] !== "0" && significantDigits !== 0) {
- invalidErr(representation, "inexact rounding");
- }
- nDigits = nDigits - 1;
- } else {
- if (digits[lastDigit] !== 0) {
- invalidErr(representation, "inexact rounding");
- }
- lastDigit = lastDigit - 1;
- }
- if (exponent < EXPONENT_MAX) {
- exponent = exponent + 1;
- } else {
- invalidErr(representation, "overflow");
- }
- }
- if (lastDigit + 1 < significantDigits) {
- if (sawRadix) {
- firstNonZero = firstNonZero + 1;
- }
- if (sawSign) {
- firstNonZero = firstNonZero + 1;
- }
- const roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10);
- if (roundDigit !== 0) {
- invalidErr(representation, "inexact rounding");
- }
- }
- }
- significandHigh = Long.fromNumber(0);
- significandLow = Long.fromNumber(0);
- if (significantDigits === 0) {
- significandHigh = Long.fromNumber(0);
- significandLow = Long.fromNumber(0);
- } else if (lastDigit < 17) {
- let dIdx = 0;
- significandLow = Long.fromNumber(digits[dIdx++]);
- significandHigh = new Long(0, 0);
- for (; dIdx <= lastDigit; dIdx++) {
- significandLow = significandLow.multiply(Long.fromNumber(10));
- significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
- }
- } else {
- let dIdx = 0;
- significandHigh = Long.fromNumber(digits[dIdx++]);
- for (; dIdx <= lastDigit - 17; dIdx++) {
- significandHigh = significandHigh.multiply(Long.fromNumber(10));
- significandHigh = significandHigh.add(Long.fromNumber(digits[dIdx]));
- }
- significandLow = Long.fromNumber(digits[dIdx++]);
- for (; dIdx <= lastDigit; dIdx++) {
- significandLow = significandLow.multiply(Long.fromNumber(10));
- significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
- }
- }
- const significand = multiply64x2(significandHigh, Long.fromString("100000000000000000"));
- significand.low = significand.low.add(significandLow);
- if (lessThan(significand.low, significandLow)) {
- significand.high = significand.high.add(Long.fromNumber(1));
- }
- biasedExponent = exponent + EXPONENT_BIAS;
- const dec = { low: Long.fromNumber(0), high: Long.fromNumber(0) };
- if (significand.high.shiftRightUnsigned(49).and(Long.fromNumber(1)).equals(Long.fromNumber(1))) {
- dec.high = dec.high.or(Long.fromNumber(3).shiftLeft(61));
- dec.high = dec.high.or(Long.fromNumber(biasedExponent).and(Long.fromNumber(16383).shiftLeft(47)));
- dec.high = dec.high.or(significand.high.and(Long.fromNumber(140737488355327)));
- } else {
- dec.high = dec.high.or(Long.fromNumber(biasedExponent & 16383).shiftLeft(49));
- dec.high = dec.high.or(significand.high.and(Long.fromNumber(562949953421311)));
- }
- dec.low = significand.low;
- if (isNegative) {
- dec.high = dec.high.or(Long.fromString("9223372036854775808"));
- }
- const buffer2 = ByteUtils.allocate(16);
- index = 0;
- buffer2[index++] = dec.low.low & 255;
- buffer2[index++] = dec.low.low >> 8 & 255;
- buffer2[index++] = dec.low.low >> 16 & 255;
- buffer2[index++] = dec.low.low >> 24 & 255;
- buffer2[index++] = dec.low.high & 255;
- buffer2[index++] = dec.low.high >> 8 & 255;
- buffer2[index++] = dec.low.high >> 16 & 255;
- buffer2[index++] = dec.low.high >> 24 & 255;
- buffer2[index++] = dec.high.low & 255;
- buffer2[index++] = dec.high.low >> 8 & 255;
- buffer2[index++] = dec.high.low >> 16 & 255;
- buffer2[index++] = dec.high.low >> 24 & 255;
- buffer2[index++] = dec.high.high & 255;
- buffer2[index++] = dec.high.high >> 8 & 255;
- buffer2[index++] = dec.high.high >> 16 & 255;
- buffer2[index++] = dec.high.high >> 24 & 255;
- return new _Decimal128(buffer2);
- }
- toString() {
- let biased_exponent;
- let significand_digits = 0;
- const significand = new Array(36);
- for (let i = 0; i < significand.length; i++)
- significand[i] = 0;
- let index = 0;
- let is_zero = false;
- let significand_msb;
- let significand128 = { parts: [0, 0, 0, 0] };
- let j, k;
- const string = [];
- index = 0;
- const buffer2 = this.bytes;
- const low = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- const midl = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- const midh = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- const high = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- index = 0;
- const dec = {
- low: new Long(low, midl),
- high: new Long(midh, high)
- };
- if (dec.high.lessThan(Long.ZERO)) {
- string.push("-");
- }
- const combination = high >> 26 & COMBINATION_MASK;
- if (combination >> 3 === 3) {
- if (combination === COMBINATION_INFINITY) {
- return string.join("") + "Infinity";
- } else if (combination === COMBINATION_NAN) {
- return "NaN";
- } else {
- biased_exponent = high >> 15 & EXPONENT_MASK;
- significand_msb = 8 + (high >> 14 & 1);
- }
- } else {
- significand_msb = high >> 14 & 7;
- biased_exponent = high >> 17 & EXPONENT_MASK;
- }
- const exponent = biased_exponent - EXPONENT_BIAS;
- significand128.parts[0] = (high & 16383) + ((significand_msb & 15) << 14);
- significand128.parts[1] = midh;
- significand128.parts[2] = midl;
- significand128.parts[3] = low;
- if (significand128.parts[0] === 0 && significand128.parts[1] === 0 && significand128.parts[2] === 0 && significand128.parts[3] === 0) {
- is_zero = true;
- } else {
- for (k = 3; k >= 0; k--) {
- let least_digits = 0;
- const result = divideu128(significand128);
- significand128 = result.quotient;
- least_digits = result.rem.low;
- if (!least_digits)
- continue;
- for (j = 8; j >= 0; j--) {
- significand[k * 9 + j] = least_digits % 10;
- least_digits = Math.floor(least_digits / 10);
- }
- }
- }
- if (is_zero) {
- significand_digits = 1;
- significand[index] = 0;
- } else {
- significand_digits = 36;
- while (!significand[index]) {
- significand_digits = significand_digits - 1;
- index = index + 1;
- }
- }
- const scientific_exponent = significand_digits - 1 + exponent;
- if (scientific_exponent >= 34 || scientific_exponent <= -7 || exponent > 0) {
- if (significand_digits > 34) {
- string.push(`${0}`);
- if (exponent > 0)
- string.push(`E+${exponent}`);
- else if (exponent < 0)
- string.push(`E${exponent}`);
- return string.join("");
- }
- string.push(`${significand[index++]}`);
- significand_digits = significand_digits - 1;
- if (significand_digits) {
- string.push(".");
- }
- for (let i = 0; i < significand_digits; i++) {
- string.push(`${significand[index++]}`);
- }
- string.push("E");
- if (scientific_exponent > 0) {
- string.push(`+${scientific_exponent}`);
- } else {
- string.push(`${scientific_exponent}`);
- }
- } else {
- if (exponent >= 0) {
- for (let i = 0; i < significand_digits; i++) {
- string.push(`${significand[index++]}`);
- }
- } else {
- let radix_position = significand_digits + exponent;
- if (radix_position > 0) {
- for (let i = 0; i < radix_position; i++) {
- string.push(`${significand[index++]}`);
- }
- } else {
- string.push("0");
- }
- string.push(".");
- while (radix_position++ < 0) {
- string.push("0");
- }
- for (let i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) {
- string.push(`${significand[index++]}`);
- }
- }
- }
- return string.join("");
- }
- toJSON() {
- return { $numberDecimal: this.toString() };
- }
- toExtendedJSON() {
- return { $numberDecimal: this.toString() };
- }
- static fromExtendedJSON(doc) {
- return _Decimal128.fromString(doc.$numberDecimal);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- return `new Decimal128("${this.toString()}")`;
- }
- };
- var Double = class _Double extends BSONValue {
- get _bsontype() {
- return "Double";
- }
- constructor(value) {
- super();
- if (value instanceof Number) {
- value = value.valueOf();
- }
- this.value = +value;
- }
- valueOf() {
- return this.value;
- }
- toJSON() {
- return this.value;
- }
- toString(radix) {
- return this.value.toString(radix);
- }
- toExtendedJSON(options) {
- if (options && (options.legacy || options.relaxed && isFinite(this.value))) {
- return this.value;
- }
- if (Object.is(Math.sign(this.value), -0)) {
- return { $numberDouble: "-0.0" };
- }
- return {
- $numberDouble: Number.isInteger(this.value) ? this.value.toFixed(1) : this.value.toString()
- };
- }
- static fromExtendedJSON(doc, options) {
- const doubleValue = parseFloat(doc.$numberDouble);
- return options && options.relaxed ? doubleValue : new _Double(doubleValue);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- const eJSON = this.toExtendedJSON();
- return `new Double(${eJSON.$numberDouble})`;
- }
- };
- var Int32 = class _Int32 extends BSONValue {
- get _bsontype() {
- return "Int32";
- }
- constructor(value) {
- super();
- if (value instanceof Number) {
- value = value.valueOf();
- }
- this.value = +value | 0;
- }
- valueOf() {
- return this.value;
- }
- toString(radix) {
- return this.value.toString(radix);
- }
- toJSON() {
- return this.value;
- }
- toExtendedJSON(options) {
- if (options && (options.relaxed || options.legacy))
- return this.value;
- return { $numberInt: this.value.toString() };
- }
- static fromExtendedJSON(doc, options) {
- return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new _Int32(doc.$numberInt);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- return `new Int32(${this.valueOf()})`;
- }
- };
- var MaxKey = class _MaxKey extends BSONValue {
- get _bsontype() {
- return "MaxKey";
- }
- toExtendedJSON() {
- return { $maxKey: 1 };
- }
- static fromExtendedJSON() {
- return new _MaxKey();
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- return "new MaxKey()";
- }
- };
- var MinKey = class _MinKey extends BSONValue {
- get _bsontype() {
- return "MinKey";
- }
- toExtendedJSON() {
- return { $minKey: 1 };
- }
- static fromExtendedJSON() {
- return new _MinKey();
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- return "new MinKey()";
- }
- };
- var checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$");
- var PROCESS_UNIQUE = null;
- var kId = Symbol("id");
- var ObjectId3 = class _ObjectId extends BSONValue {
- get _bsontype() {
- return "ObjectId";
- }
- constructor(inputId) {
- super();
- let workingId;
- if (typeof inputId === "object" && inputId && "id" in inputId) {
- if (typeof inputId.id !== "string" && !ArrayBuffer.isView(inputId.id)) {
- throw new BSONError("Argument passed in must have an id that is of type string or Buffer");
- }
- if ("toHexString" in inputId && typeof inputId.toHexString === "function") {
- workingId = ByteUtils.fromHex(inputId.toHexString());
- } else {
- workingId = inputId.id;
- }
- } else {
- workingId = inputId;
- }
- if (workingId == null || typeof workingId === "number") {
- this[kId] = _ObjectId.generate(typeof workingId === "number" ? workingId : void 0);
- } else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) {
- this[kId] = ByteUtils.toLocalBufferType(workingId);
- } else if (typeof workingId === "string") {
- if (workingId.length === 12) {
- const bytes = ByteUtils.fromUTF8(workingId);
- if (bytes.byteLength === 12) {
- this[kId] = bytes;
- } else {
- throw new BSONError("Argument passed in must be a string of 12 bytes");
- }
- } else if (workingId.length === 24 && checkForHexRegExp.test(workingId)) {
- this[kId] = ByteUtils.fromHex(workingId);
- } else {
- throw new BSONError("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");
- }
- } else {
- throw new BSONError("Argument passed in does not match the accepted types");
- }
- if (_ObjectId.cacheHexString) {
- this.__id = ByteUtils.toHex(this.id);
- }
- }
- get id() {
- return this[kId];
- }
- set id(value) {
- this[kId] = value;
- if (_ObjectId.cacheHexString) {
- this.__id = ByteUtils.toHex(value);
- }
- }
- toHexString() {
- if (_ObjectId.cacheHexString && this.__id) {
- return this.__id;
- }
- const hexString = ByteUtils.toHex(this.id);
- if (_ObjectId.cacheHexString && !this.__id) {
- this.__id = hexString;
- }
- return hexString;
- }
- static getInc() {
- return _ObjectId.index = (_ObjectId.index + 1) % 16777215;
- }
- static generate(time) {
- if ("number" !== typeof time) {
- time = Math.floor(Date.now() / 1e3);
- }
- const inc = _ObjectId.getInc();
- const buffer2 = ByteUtils.allocate(12);
- BSONDataView.fromUint8Array(buffer2).setUint32(0, time, false);
- if (PROCESS_UNIQUE === null) {
- PROCESS_UNIQUE = ByteUtils.randomBytes(5);
- }
- buffer2[4] = PROCESS_UNIQUE[0];
- buffer2[5] = PROCESS_UNIQUE[1];
- buffer2[6] = PROCESS_UNIQUE[2];
- buffer2[7] = PROCESS_UNIQUE[3];
- buffer2[8] = PROCESS_UNIQUE[4];
- buffer2[11] = inc & 255;
- buffer2[10] = inc >> 8 & 255;
- buffer2[9] = inc >> 16 & 255;
- return buffer2;
- }
- toString(encoding) {
- if (encoding === "base64")
- return ByteUtils.toBase64(this.id);
- if (encoding === "hex")
- return this.toHexString();
- return this.toHexString();
- }
- toJSON() {
- return this.toHexString();
- }
- equals(otherId) {
- if (otherId === void 0 || otherId === null) {
- return false;
- }
- if (otherId instanceof _ObjectId) {
- return this[kId][11] === otherId[kId][11] && ByteUtils.equals(this[kId], otherId[kId]);
- }
- if (typeof otherId === "string" && _ObjectId.isValid(otherId) && otherId.length === 12 && isUint8Array(this.id)) {
- return ByteUtils.equals(this.id, ByteUtils.fromISO88591(otherId));
- }
- if (typeof otherId === "string" && _ObjectId.isValid(otherId) && otherId.length === 24) {
- return otherId.toLowerCase() === this.toHexString();
- }
- if (typeof otherId === "string" && _ObjectId.isValid(otherId) && otherId.length === 12) {
- return ByteUtils.equals(ByteUtils.fromUTF8(otherId), this.id);
- }
- if (typeof otherId === "object" && "toHexString" in otherId && typeof otherId.toHexString === "function") {
- const otherIdString = otherId.toHexString();
- const thisIdString = this.toHexString().toLowerCase();
- return typeof otherIdString === "string" && otherIdString.toLowerCase() === thisIdString;
- }
- return false;
- }
- getTimestamp() {
- const timestamp = /* @__PURE__ */ new Date();
- const time = BSONDataView.fromUint8Array(this.id).getUint32(0, false);
- timestamp.setTime(Math.floor(time) * 1e3);
- return timestamp;
- }
- static createPk() {
- return new _ObjectId();
- }
- static createFromTime(time) {
- const buffer2 = ByteUtils.fromNumberArray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
- BSONDataView.fromUint8Array(buffer2).setUint32(0, time, false);
- return new _ObjectId(buffer2);
- }
- static createFromHexString(hexString) {
- if ((hexString == null ? void 0 : hexString.length) !== 24) {
- throw new BSONError("hex string must be 24 characters");
- }
- return new _ObjectId(ByteUtils.fromHex(hexString));
- }
- static createFromBase64(base64) {
- if ((base64 == null ? void 0 : base64.length) !== 16) {
- throw new BSONError("base64 string must be 16 characters");
- }
- return new _ObjectId(ByteUtils.fromBase64(base64));
- }
- static isValid(id) {
- if (id == null)
- return false;
- try {
- new _ObjectId(id);
- return true;
- } catch {
- return false;
- }
- }
- toExtendedJSON() {
- if (this.toHexString)
- return { $oid: this.toHexString() };
- return { $oid: this.toString("hex") };
- }
- static fromExtendedJSON(doc) {
- return new _ObjectId(doc.$oid);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- return `new ObjectId("${this.toHexString()}")`;
- }
- };
- ObjectId3.index = Math.floor(Math.random() * 16777215);
- function internalCalculateObjectSize(object, serializeFunctions, ignoreUndefined) {
- let totalLength = 4 + 1;
- if (Array.isArray(object)) {
- for (let i = 0; i < object.length; i++) {
- totalLength += calculateElement(i.toString(), object[i], serializeFunctions, true, ignoreUndefined);
- }
- } else {
- if (typeof (object == null ? void 0 : object.toBSON) === "function") {
- object = object.toBSON();
- }
- for (const key of Object.keys(object)) {
- totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined);
- }
- }
- return totalLength;
- }
- function calculateElement(name, value, serializeFunctions = false, isArray = false, ignoreUndefined = false) {
- if (typeof (value == null ? void 0 : value.toBSON) === "function") {
- value = value.toBSON();
- }
- switch (typeof value) {
- case "string":
- return 1 + ByteUtils.utf8ByteLength(name) + 1 + 4 + ByteUtils.utf8ByteLength(value) + 1;
- case "number":
- if (Math.floor(value) === value && value >= JS_INT_MIN && value <= JS_INT_MAX) {
- if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (4 + 1);
- } else {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
- }
- } else {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
- }
- case "undefined":
- if (isArray || !ignoreUndefined)
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1;
- return 0;
- case "boolean":
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (1 + 1);
- case "object":
- if (value != null && typeof value._bsontype === "string" && value[Symbol.for("@@mdb.bson.version")] !== BSON_MAJOR_VERSION) {
- throw new BSONVersionError();
- } else if (value == null || value._bsontype === "MinKey" || value._bsontype === "MaxKey") {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1;
- } else if (value._bsontype === "ObjectId") {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (12 + 1);
- } else if (value instanceof Date || isDate(value)) {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
- } else if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer || isAnyArrayBuffer(value)) {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (1 + 4 + 1) + value.byteLength;
- } else if (value._bsontype === "Long" || value._bsontype === "Double" || value._bsontype === "Timestamp") {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
- } else if (value._bsontype === "Decimal128") {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (16 + 1);
- } else if (value._bsontype === "Code") {
- if (value.scope != null && Object.keys(value.scope).length > 0) {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + 4 + 4 + ByteUtils.utf8ByteLength(value.code.toString()) + 1 + internalCalculateObjectSize(value.scope, serializeFunctions, ignoreUndefined);
- } else {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + 4 + ByteUtils.utf8ByteLength(value.code.toString()) + 1;
- }
- } else if (value._bsontype === "Binary") {
- const binary = value;
- if (binary.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (binary.position + 1 + 4 + 1 + 4);
- } else {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (binary.position + 1 + 4 + 1);
- }
- } else if (value._bsontype === "Symbol") {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + ByteUtils.utf8ByteLength(value.value) + 4 + 1 + 1;
- } else if (value._bsontype === "DBRef") {
- const ordered_values = Object.assign({
- $ref: value.collection,
- $id: value.oid
- }, value.fields);
- if (value.db != null) {
- ordered_values["$db"] = value.db;
- }
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + internalCalculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined);
- } else if (value instanceof RegExp || isRegExp(value)) {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + ByteUtils.utf8ByteLength(value.source) + 1 + (value.global ? 1 : 0) + (value.ignoreCase ? 1 : 0) + (value.multiline ? 1 : 0) + 1;
- } else if (value._bsontype === "BSONRegExp") {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + ByteUtils.utf8ByteLength(value.pattern) + 1 + ByteUtils.utf8ByteLength(value.options) + 1;
- } else {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + internalCalculateObjectSize(value, serializeFunctions, ignoreUndefined) + 1;
- }
- case "function":
- if (serializeFunctions) {
- return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + 4 + ByteUtils.utf8ByteLength(value.toString()) + 1;
- }
- }
- return 0;
- }
- function alphabetize(str) {
- return str.split("").sort().join("");
- }
- var BSONRegExp = class _BSONRegExp extends BSONValue {
- get _bsontype() {
- return "BSONRegExp";
- }
- constructor(pattern, options) {
- super();
- this.pattern = pattern;
- this.options = alphabetize(options ?? "");
- if (this.pattern.indexOf("\0") !== -1) {
- throw new BSONError(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);
- }
- if (this.options.indexOf("\0") !== -1) {
- throw new BSONError(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);
- }
- for (let i = 0; i < this.options.length; i++) {
- if (!(this.options[i] === "i" || this.options[i] === "m" || this.options[i] === "x" || this.options[i] === "l" || this.options[i] === "s" || this.options[i] === "u")) {
- throw new BSONError(`The regular expression option [${this.options[i]}] is not supported`);
- }
- }
- }
- static parseOptions(options) {
- return options ? options.split("").sort().join("") : "";
- }
- toExtendedJSON(options) {
- options = options || {};
- if (options.legacy) {
- return { $regex: this.pattern, $options: this.options };
- }
- return { $regularExpression: { pattern: this.pattern, options: this.options } };
- }
- static fromExtendedJSON(doc) {
- if ("$regex" in doc) {
- if (typeof doc.$regex !== "string") {
- if (doc.$regex._bsontype === "BSONRegExp") {
- return doc;
- }
- } else {
- return new _BSONRegExp(doc.$regex, _BSONRegExp.parseOptions(doc.$options));
- }
- }
- if ("$regularExpression" in doc) {
- return new _BSONRegExp(doc.$regularExpression.pattern, _BSONRegExp.parseOptions(doc.$regularExpression.options));
- }
- throw new BSONError(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(doc)}`);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- return `new BSONRegExp(${JSON.stringify(this.pattern)}, ${JSON.stringify(this.options)})`;
- }
- };
- var BSONSymbol = class _BSONSymbol extends BSONValue {
- get _bsontype() {
- return "BSONSymbol";
- }
- constructor(value) {
- super();
- this.value = value;
- }
- valueOf() {
- return this.value;
- }
- toString() {
- return this.value;
- }
- inspect() {
- return `new BSONSymbol("${this.value}")`;
- }
- toJSON() {
- return this.value;
- }
- toExtendedJSON() {
- return { $symbol: this.value };
- }
- static fromExtendedJSON(doc) {
- return new _BSONSymbol(doc.$symbol);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- };
- var LongWithoutOverridesClass = Long;
- var Timestamp = class _Timestamp extends LongWithoutOverridesClass {
- get _bsontype() {
- return "Timestamp";
- }
- constructor(low) {
- if (low == null) {
- super(0, 0, true);
- } else if (typeof low === "bigint") {
- super(low, true);
- } else if (Long.isLong(low)) {
- super(low.low, low.high, true);
- } else if (typeof low === "object" && "t" in low && "i" in low) {
- if (typeof low.t !== "number" && (typeof low.t !== "object" || low.t._bsontype !== "Int32")) {
- throw new BSONError("Timestamp constructed from { t, i } must provide t as a number");
- }
- if (typeof low.i !== "number" && (typeof low.i !== "object" || low.i._bsontype !== "Int32")) {
- throw new BSONError("Timestamp constructed from { t, i } must provide i as a number");
- }
- const t = Number(low.t);
- const i = Number(low.i);
- if (t < 0 || Number.isNaN(t)) {
- throw new BSONError("Timestamp constructed from { t, i } must provide a positive t");
- }
- if (i < 0 || Number.isNaN(i)) {
- throw new BSONError("Timestamp constructed from { t, i } must provide a positive i");
- }
- if (t > 4294967295) {
- throw new BSONError("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");
- }
- if (i > 4294967295) {
- throw new BSONError("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");
- }
- super(i, t, true);
- } else {
- throw new BSONError("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }");
- }
- }
- toJSON() {
- return {
- $timestamp: this.toString()
- };
- }
- static fromInt(value) {
- return new _Timestamp(Long.fromInt(value, true));
- }
- static fromNumber(value) {
- return new _Timestamp(Long.fromNumber(value, true));
- }
- static fromBits(lowBits, highBits) {
- return new _Timestamp({ i: lowBits, t: highBits });
- }
- static fromString(str, optRadix) {
- return new _Timestamp(Long.fromString(str, true, optRadix));
- }
- toExtendedJSON() {
- return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } };
- }
- static fromExtendedJSON(doc) {
- const i = Long.isLong(doc.$timestamp.i) ? doc.$timestamp.i.getLowBitsUnsigned() : doc.$timestamp.i;
- const t = Long.isLong(doc.$timestamp.t) ? doc.$timestamp.t.getLowBitsUnsigned() : doc.$timestamp.t;
- return new _Timestamp({ t, i });
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- return `new Timestamp({ t: ${this.getHighBits()}, i: ${this.getLowBits()} })`;
- }
- };
- Timestamp.MAX_VALUE = Long.MAX_UNSIGNED_VALUE;
- var FIRST_BIT = 128;
- var FIRST_TWO_BITS = 192;
- var FIRST_THREE_BITS = 224;
- var FIRST_FOUR_BITS = 240;
- var FIRST_FIVE_BITS = 248;
- var TWO_BIT_CHAR = 192;
- var THREE_BIT_CHAR = 224;
- var FOUR_BIT_CHAR = 240;
- var CONTINUING_CHAR = 128;
- function validateUtf8(bytes, start, end) {
- let continuation = 0;
- for (let i = start; i < end; i += 1) {
- const byte = bytes[i];
- if (continuation) {
- if ((byte & FIRST_TWO_BITS) !== CONTINUING_CHAR) {
- return false;
- }
- continuation -= 1;
- } else if (byte & FIRST_BIT) {
- if ((byte & FIRST_THREE_BITS) === TWO_BIT_CHAR) {
- continuation = 1;
- } else if ((byte & FIRST_FOUR_BITS) === THREE_BIT_CHAR) {
- continuation = 2;
- } else if ((byte & FIRST_FIVE_BITS) === FOUR_BIT_CHAR) {
- continuation = 3;
- } else {
- return false;
- }
- }
- }
- return !continuation;
- }
- var JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX);
- var JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN);
- function internalDeserialize(buffer2, options, isArray) {
- options = options == null ? {} : options;
- const index = options && options.index ? options.index : 0;
- const size = buffer2[index] | buffer2[index + 1] << 8 | buffer2[index + 2] << 16 | buffer2[index + 3] << 24;
- if (size < 5) {
- throw new BSONError(`bson size must be >= 5, is ${size}`);
- }
- if (options.allowObjectSmallerThanBufferSize && buffer2.length < size) {
- throw new BSONError(`buffer length ${buffer2.length} must be >= bson size ${size}`);
- }
- if (!options.allowObjectSmallerThanBufferSize && buffer2.length !== size) {
- throw new BSONError(`buffer length ${buffer2.length} must === bson size ${size}`);
- }
- if (size + index > buffer2.byteLength) {
- throw new BSONError(`(bson size ${size} + options.index ${index} must be <= buffer length ${buffer2.byteLength})`);
- }
- if (buffer2[index + size - 1] !== 0) {
- throw new BSONError("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");
- }
- return deserializeObject(buffer2, index, options, isArray);
- }
- var allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/;
- function deserializeObject(buffer2, index, options, isArray = false) {
- const fieldsAsRaw = options["fieldsAsRaw"] == null ? null : options["fieldsAsRaw"];
- const raw = options["raw"] == null ? false : options["raw"];
- const bsonRegExp = typeof options["bsonRegExp"] === "boolean" ? options["bsonRegExp"] : false;
- const promoteBuffers = options.promoteBuffers ?? false;
- const promoteLongs = options.promoteLongs ?? true;
- const promoteValues = options.promoteValues ?? true;
- const useBigInt64 = options.useBigInt64 ?? false;
- if (useBigInt64 && !promoteValues) {
- throw new BSONError("Must either request bigint or Long for int64 deserialization");
- }
- if (useBigInt64 && !promoteLongs) {
- throw new BSONError("Must either request bigint or Long for int64 deserialization");
- }
- const validation = options.validation == null ? { utf8: true } : options.validation;
- let globalUTFValidation = true;
- let validationSetting;
- const utf8KeysSet = /* @__PURE__ */ new Set();
- const utf8ValidatedKeys = validation.utf8;
- if (typeof utf8ValidatedKeys === "boolean") {
- validationSetting = utf8ValidatedKeys;
- } else {
- globalUTFValidation = false;
- const utf8ValidationValues = Object.keys(utf8ValidatedKeys).map(function(key) {
- return utf8ValidatedKeys[key];
- });
- if (utf8ValidationValues.length === 0) {
- throw new BSONError("UTF-8 validation setting cannot be empty");
- }
- if (typeof utf8ValidationValues[0] !== "boolean") {
- throw new BSONError("Invalid UTF-8 validation option, must specify boolean values");
- }
- validationSetting = utf8ValidationValues[0];
- if (!utf8ValidationValues.every((item) => item === validationSetting)) {
- throw new BSONError("Invalid UTF-8 validation option - keys must be all true or all false");
- }
- }
- if (!globalUTFValidation) {
- for (const key of Object.keys(utf8ValidatedKeys)) {
- utf8KeysSet.add(key);
- }
- }
- const startIndex = index;
- if (buffer2.length < 5)
- throw new BSONError("corrupt bson message < 5 bytes long");
- const size = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- if (size < 5 || size > buffer2.length)
- throw new BSONError("corrupt bson message");
- const object = isArray ? [] : {};
- let arrayIndex = 0;
- const done = false;
- let isPossibleDBRef = isArray ? false : null;
- const dataview = new DataView(buffer2.buffer, buffer2.byteOffset, buffer2.byteLength);
- while (!done) {
- const elementType = buffer2[index++];
- if (elementType === 0)
- break;
- let i = index;
- while (buffer2[i] !== 0 && i < buffer2.length) {
- i++;
- }
- if (i >= buffer2.byteLength)
- throw new BSONError("Bad BSON Document: illegal CString");
- const name = isArray ? arrayIndex++ : ByteUtils.toUTF8(buffer2, index, i);
- let shouldValidateKey = true;
- if (globalUTFValidation || utf8KeysSet.has(name)) {
- shouldValidateKey = validationSetting;
- } else {
- shouldValidateKey = !validationSetting;
- }
- if (isPossibleDBRef !== false && name[0] === "$") {
- isPossibleDBRef = allowedDBRefKeys.test(name);
- }
- let value;
- index = i + 1;
- if (elementType === BSON_DATA_STRING) {
- const stringSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- if (stringSize <= 0 || stringSize > buffer2.length - index || buffer2[index + stringSize - 1] !== 0) {
- throw new BSONError("bad string length in bson");
- }
- value = getValidatedString(buffer2, index, index + stringSize - 1, shouldValidateKey);
- index = index + stringSize;
- } else if (elementType === BSON_DATA_OID) {
- const oid = ByteUtils.allocate(12);
- oid.set(buffer2.subarray(index, index + 12));
- value = new ObjectId3(oid);
- index = index + 12;
- } else if (elementType === BSON_DATA_INT && promoteValues === false) {
- value = new Int32(buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24);
- } else if (elementType === BSON_DATA_INT) {
- value = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- } else if (elementType === BSON_DATA_NUMBER && promoteValues === false) {
- value = new Double(dataview.getFloat64(index, true));
- index = index + 8;
- } else if (elementType === BSON_DATA_NUMBER) {
- value = dataview.getFloat64(index, true);
- index = index + 8;
- } else if (elementType === BSON_DATA_DATE) {
- const lowBits = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- const highBits = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- value = new Date(new Long(lowBits, highBits).toNumber());
- } else if (elementType === BSON_DATA_BOOLEAN) {
- if (buffer2[index] !== 0 && buffer2[index] !== 1)
- throw new BSONError("illegal boolean type value");
- value = buffer2[index++] === 1;
- } else if (elementType === BSON_DATA_OBJECT) {
- const _index = index;
- const objectSize = buffer2[index] | buffer2[index + 1] << 8 | buffer2[index + 2] << 16 | buffer2[index + 3] << 24;
- if (objectSize <= 0 || objectSize > buffer2.length - index)
- throw new BSONError("bad embedded document length in bson");
- if (raw) {
- value = buffer2.slice(index, index + objectSize);
- } else {
- let objectOptions = options;
- if (!globalUTFValidation) {
- objectOptions = { ...options, validation: { utf8: shouldValidateKey } };
- }
- value = deserializeObject(buffer2, _index, objectOptions, false);
- }
- index = index + objectSize;
- } else if (elementType === BSON_DATA_ARRAY) {
- const _index = index;
- const objectSize = buffer2[index] | buffer2[index + 1] << 8 | buffer2[index + 2] << 16 | buffer2[index + 3] << 24;
- let arrayOptions = options;
- const stopIndex = index + objectSize;
- if (fieldsAsRaw && fieldsAsRaw[name]) {
- arrayOptions = { ...options, raw: true };
- }
- if (!globalUTFValidation) {
- arrayOptions = { ...arrayOptions, validation: { utf8: shouldValidateKey } };
- }
- value = deserializeObject(buffer2, _index, arrayOptions, true);
- index = index + objectSize;
- if (buffer2[index - 1] !== 0)
- throw new BSONError("invalid array terminator byte");
- if (index !== stopIndex)
- throw new BSONError("corrupted array bson");
- } else if (elementType === BSON_DATA_UNDEFINED) {
- value = void 0;
- } else if (elementType === BSON_DATA_NULL) {
- value = null;
- } else if (elementType === BSON_DATA_LONG) {
- const dataview2 = BSONDataView.fromUint8Array(buffer2.subarray(index, index + 8));
- const lowBits = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- const highBits = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- const long = new Long(lowBits, highBits);
- if (useBigInt64) {
- value = dataview2.getBigInt64(0, true);
- } else if (promoteLongs && promoteValues === true) {
- value = long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) ? long.toNumber() : long;
- } else {
- value = long;
- }
- } else if (elementType === BSON_DATA_DECIMAL128) {
- const bytes = ByteUtils.allocate(16);
- bytes.set(buffer2.subarray(index, index + 16), 0);
- index = index + 16;
- value = new Decimal128(bytes);
- } else if (elementType === BSON_DATA_BINARY) {
- let binarySize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- const totalBinarySize = binarySize;
- const subType = buffer2[index++];
- if (binarySize < 0)
- throw new BSONError("Negative binary type element size found");
- if (binarySize > buffer2.byteLength)
- throw new BSONError("Binary type size larger than document size");
- if (buffer2["slice"] != null) {
- if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
- binarySize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- if (binarySize < 0)
- throw new BSONError("Negative binary type element size found for subtype 0x02");
- if (binarySize > totalBinarySize - 4)
- throw new BSONError("Binary type with subtype 0x02 contains too long binary size");
- if (binarySize < totalBinarySize - 4)
- throw new BSONError("Binary type with subtype 0x02 contains too short binary size");
- }
- if (promoteBuffers && promoteValues) {
- value = ByteUtils.toLocalBufferType(buffer2.slice(index, index + binarySize));
- } else {
- value = new Binary(buffer2.slice(index, index + binarySize), subType);
- if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) {
- value = value.toUUID();
- }
- }
- } else {
- const _buffer = ByteUtils.allocate(binarySize);
- if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
- binarySize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- if (binarySize < 0)
- throw new BSONError("Negative binary type element size found for subtype 0x02");
- if (binarySize > totalBinarySize - 4)
- throw new BSONError("Binary type with subtype 0x02 contains too long binary size");
- if (binarySize < totalBinarySize - 4)
- throw new BSONError("Binary type with subtype 0x02 contains too short binary size");
- }
- for (i = 0; i < binarySize; i++) {
- _buffer[i] = buffer2[index + i];
- }
- if (promoteBuffers && promoteValues) {
- value = _buffer;
- } else {
- value = new Binary(buffer2.slice(index, index + binarySize), subType);
- if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) {
- value = value.toUUID();
- }
- }
- }
- index = index + binarySize;
- } else if (elementType === BSON_DATA_REGEXP && bsonRegExp === false) {
- i = index;
- while (buffer2[i] !== 0 && i < buffer2.length) {
- i++;
- }
- if (i >= buffer2.length)
- throw new BSONError("Bad BSON Document: illegal CString");
- const source = ByteUtils.toUTF8(buffer2, index, i);
- index = i + 1;
- i = index;
- while (buffer2[i] !== 0 && i < buffer2.length) {
- i++;
- }
- if (i >= buffer2.length)
- throw new BSONError("Bad BSON Document: illegal CString");
- const regExpOptions = ByteUtils.toUTF8(buffer2, index, i);
- index = i + 1;
- const optionsArray = new Array(regExpOptions.length);
- for (i = 0; i < regExpOptions.length; i++) {
- switch (regExpOptions[i]) {
- case "m":
- optionsArray[i] = "m";
- break;
- case "s":
- optionsArray[i] = "g";
- break;
- case "i":
- optionsArray[i] = "i";
- break;
- }
- }
- value = new RegExp(source, optionsArray.join(""));
- } else if (elementType === BSON_DATA_REGEXP && bsonRegExp === true) {
- i = index;
- while (buffer2[i] !== 0 && i < buffer2.length) {
- i++;
- }
- if (i >= buffer2.length)
- throw new BSONError("Bad BSON Document: illegal CString");
- const source = ByteUtils.toUTF8(buffer2, index, i);
- index = i + 1;
- i = index;
- while (buffer2[i] !== 0 && i < buffer2.length) {
- i++;
- }
- if (i >= buffer2.length)
- throw new BSONError("Bad BSON Document: illegal CString");
- const regExpOptions = ByteUtils.toUTF8(buffer2, index, i);
- index = i + 1;
- value = new BSONRegExp(source, regExpOptions);
- } else if (elementType === BSON_DATA_SYMBOL) {
- const stringSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- if (stringSize <= 0 || stringSize > buffer2.length - index || buffer2[index + stringSize - 1] !== 0) {
- throw new BSONError("bad string length in bson");
- }
- const symbol = getValidatedString(buffer2, index, index + stringSize - 1, shouldValidateKey);
- value = promoteValues ? symbol : new BSONSymbol(symbol);
- index = index + stringSize;
- } else if (elementType === BSON_DATA_TIMESTAMP) {
- const i2 = buffer2[index++] + buffer2[index++] * (1 << 8) + buffer2[index++] * (1 << 16) + buffer2[index++] * (1 << 24);
- const t = buffer2[index++] + buffer2[index++] * (1 << 8) + buffer2[index++] * (1 << 16) + buffer2[index++] * (1 << 24);
- value = new Timestamp({ i: i2, t });
- } else if (elementType === BSON_DATA_MIN_KEY) {
- value = new MinKey();
- } else if (elementType === BSON_DATA_MAX_KEY) {
- value = new MaxKey();
- } else if (elementType === BSON_DATA_CODE) {
- const stringSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- if (stringSize <= 0 || stringSize > buffer2.length - index || buffer2[index + stringSize - 1] !== 0) {
- throw new BSONError("bad string length in bson");
- }
- const functionString = getValidatedString(buffer2, index, index + stringSize - 1, shouldValidateKey);
- value = new Code(functionString);
- index = index + stringSize;
- } else if (elementType === BSON_DATA_CODE_W_SCOPE) {
- const totalSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- if (totalSize < 4 + 4 + 4 + 1) {
- throw new BSONError("code_w_scope total size shorter minimum expected length");
- }
- const stringSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- if (stringSize <= 0 || stringSize > buffer2.length - index || buffer2[index + stringSize - 1] !== 0) {
- throw new BSONError("bad string length in bson");
- }
- const functionString = getValidatedString(buffer2, index, index + stringSize - 1, shouldValidateKey);
- index = index + stringSize;
- const _index = index;
- const objectSize = buffer2[index] | buffer2[index + 1] << 8 | buffer2[index + 2] << 16 | buffer2[index + 3] << 24;
- const scopeObject = deserializeObject(buffer2, _index, options, false);
- index = index + objectSize;
- if (totalSize < 4 + 4 + objectSize + stringSize) {
- throw new BSONError("code_w_scope total size is too short, truncating scope");
- }
- if (totalSize > 4 + 4 + objectSize + stringSize) {
- throw new BSONError("code_w_scope total size is too long, clips outer document");
- }
- value = new Code(functionString, scopeObject);
- } else if (elementType === BSON_DATA_DBPOINTER) {
- const stringSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24;
- if (stringSize <= 0 || stringSize > buffer2.length - index || buffer2[index + stringSize - 1] !== 0)
- throw new BSONError("bad string length in bson");
- if (validation != null && validation.utf8) {
- if (!validateUtf8(buffer2, index, index + stringSize - 1)) {
- throw new BSONError("Invalid UTF-8 string in BSON document");
- }
- }
- const namespace = ByteUtils.toUTF8(buffer2, index, index + stringSize - 1);
- index = index + stringSize;
- const oidBuffer = ByteUtils.allocate(12);
- oidBuffer.set(buffer2.subarray(index, index + 12), 0);
- const oid = new ObjectId3(oidBuffer);
- index = index + 12;
- value = new DBRef(namespace, oid);
- } else {
- throw new BSONError(`Detected unknown BSON type ${elementType.toString(16)} for fieldname "${name}"`);
- }
- if (name === "__proto__") {
- Object.defineProperty(object, name, {
- value,
- writable: true,
- enumerable: true,
- configurable: true
- });
- } else {
- object[name] = value;
- }
- }
- if (size !== index - startIndex) {
- if (isArray)
- throw new BSONError("corrupt array bson");
- throw new BSONError("corrupt object bson");
- }
- if (!isPossibleDBRef)
- return object;
- if (isDBRefLike(object)) {
- const copy = Object.assign({}, object);
- delete copy.$ref;
- delete copy.$id;
- delete copy.$db;
- return new DBRef(object.$ref, object.$id, object.$db, copy);
- }
- return object;
- }
- function getValidatedString(buffer2, start, end, shouldValidateUtf8) {
- const value = ByteUtils.toUTF8(buffer2, start, end);
- if (shouldValidateUtf8) {
- for (let i = 0; i < value.length; i++) {
- if (value.charCodeAt(i) === 65533) {
- if (!validateUtf8(buffer2, start, end)) {
- throw new BSONError("Invalid UTF-8 string in BSON document");
- }
- break;
- }
- }
- }
- return value;
- }
- var regexp = /\x00/;
- var ignoreKeys = /* @__PURE__ */ new Set(["$db", "$ref", "$id", "$clusterTime"]);
- function serializeString(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_STRING;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes + 1;
- buffer2[index - 1] = 0;
- const size = ByteUtils.encodeUTF8Into(buffer2, value, index + 4);
- buffer2[index + 3] = size + 1 >> 24 & 255;
- buffer2[index + 2] = size + 1 >> 16 & 255;
- buffer2[index + 1] = size + 1 >> 8 & 255;
- buffer2[index] = size + 1 & 255;
- index = index + 4 + size;
- buffer2[index++] = 0;
- return index;
- }
- var NUMBER_SPACE = new DataView(new ArrayBuffer(8), 0, 8);
- var FOUR_BYTE_VIEW_ON_NUMBER = new Uint8Array(NUMBER_SPACE.buffer, 0, 4);
- var EIGHT_BYTE_VIEW_ON_NUMBER = new Uint8Array(NUMBER_SPACE.buffer, 0, 8);
- function serializeNumber(buffer2, key, value, index) {
- const isNegativeZero = Object.is(value, -0);
- const type = !isNegativeZero && Number.isSafeInteger(value) && value <= BSON_INT32_MAX && value >= BSON_INT32_MIN ? BSON_DATA_INT : BSON_DATA_NUMBER;
- if (type === BSON_DATA_INT) {
- NUMBER_SPACE.setInt32(0, value, true);
- } else {
- NUMBER_SPACE.setFloat64(0, value, true);
- }
- const bytes = type === BSON_DATA_INT ? FOUR_BYTE_VIEW_ON_NUMBER : EIGHT_BYTE_VIEW_ON_NUMBER;
- buffer2[index++] = type;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- buffer2.set(bytes, index);
- index += bytes.byteLength;
- return index;
- }
- function serializeBigInt(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_LONG;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index += numberOfWrittenBytes;
- buffer2[index++] = 0;
- NUMBER_SPACE.setBigInt64(0, value, true);
- buffer2.set(EIGHT_BYTE_VIEW_ON_NUMBER, index);
- index += EIGHT_BYTE_VIEW_ON_NUMBER.byteLength;
- return index;
- }
- function serializeNull(buffer2, key, _, index) {
- buffer2[index++] = BSON_DATA_NULL;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- return index;
- }
- function serializeBoolean(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_BOOLEAN;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- buffer2[index++] = value ? 1 : 0;
- return index;
- }
- function serializeDate(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_DATE;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- const dateInMilis = Long.fromNumber(value.getTime());
- const lowBits = dateInMilis.getLowBits();
- const highBits = dateInMilis.getHighBits();
- buffer2[index++] = lowBits & 255;
- buffer2[index++] = lowBits >> 8 & 255;
- buffer2[index++] = lowBits >> 16 & 255;
- buffer2[index++] = lowBits >> 24 & 255;
- buffer2[index++] = highBits & 255;
- buffer2[index++] = highBits >> 8 & 255;
- buffer2[index++] = highBits >> 16 & 255;
- buffer2[index++] = highBits >> 24 & 255;
- return index;
- }
- function serializeRegExp(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_REGEXP;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- if (value.source && value.source.match(regexp) != null) {
- throw new BSONError("value " + value.source + " must not contain null bytes");
- }
- index = index + ByteUtils.encodeUTF8Into(buffer2, value.source, index);
- buffer2[index++] = 0;
- if (value.ignoreCase)
- buffer2[index++] = 105;
- if (value.global)
- buffer2[index++] = 115;
- if (value.multiline)
- buffer2[index++] = 109;
- buffer2[index++] = 0;
- return index;
- }
- function serializeBSONRegExp(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_REGEXP;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- if (value.pattern.match(regexp) != null) {
- throw new BSONError("pattern " + value.pattern + " must not contain null bytes");
- }
- index = index + ByteUtils.encodeUTF8Into(buffer2, value.pattern, index);
- buffer2[index++] = 0;
- const sortedOptions = value.options.split("").sort().join("");
- index = index + ByteUtils.encodeUTF8Into(buffer2, sortedOptions, index);
- buffer2[index++] = 0;
- return index;
- }
- function serializeMinMax(buffer2, key, value, index) {
- if (value === null) {
- buffer2[index++] = BSON_DATA_NULL;
- } else if (value._bsontype === "MinKey") {
- buffer2[index++] = BSON_DATA_MIN_KEY;
- } else {
- buffer2[index++] = BSON_DATA_MAX_KEY;
- }
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- return index;
- }
- function serializeObjectId(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_OID;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- if (isUint8Array(value.id)) {
- buffer2.set(value.id.subarray(0, 12), index);
- } else {
- throw new BSONError("object [" + JSON.stringify(value) + "] is not a valid ObjectId");
- }
- return index + 12;
- }
- function serializeBuffer(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_BINARY;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- const size = value.length;
- buffer2[index++] = size & 255;
- buffer2[index++] = size >> 8 & 255;
- buffer2[index++] = size >> 16 & 255;
- buffer2[index++] = size >> 24 & 255;
- buffer2[index++] = BSON_BINARY_SUBTYPE_DEFAULT;
- buffer2.set(value, index);
- index = index + size;
- return index;
- }
- function serializeObject(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path) {
- if (path.has(value)) {
- throw new BSONError("Cannot convert circular structure to BSON");
- }
- path.add(value);
- buffer2[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- const endIndex = serializeInto(buffer2, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path);
- path.delete(value);
- return endIndex;
- }
- function serializeDecimal128(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_DECIMAL128;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- buffer2.set(value.bytes.subarray(0, 16), index);
- return index + 16;
- }
- function serializeLong(buffer2, key, value, index) {
- buffer2[index++] = value._bsontype === "Long" ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- const lowBits = value.getLowBits();
- const highBits = value.getHighBits();
- buffer2[index++] = lowBits & 255;
- buffer2[index++] = lowBits >> 8 & 255;
- buffer2[index++] = lowBits >> 16 & 255;
- buffer2[index++] = lowBits >> 24 & 255;
- buffer2[index++] = highBits & 255;
- buffer2[index++] = highBits >> 8 & 255;
- buffer2[index++] = highBits >> 16 & 255;
- buffer2[index++] = highBits >> 24 & 255;
- return index;
- }
- function serializeInt32(buffer2, key, value, index) {
- value = value.valueOf();
- buffer2[index++] = BSON_DATA_INT;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- buffer2[index++] = value & 255;
- buffer2[index++] = value >> 8 & 255;
- buffer2[index++] = value >> 16 & 255;
- buffer2[index++] = value >> 24 & 255;
- return index;
- }
- function serializeDouble(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_NUMBER;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- NUMBER_SPACE.setFloat64(0, value.value, true);
- buffer2.set(EIGHT_BYTE_VIEW_ON_NUMBER, index);
- index = index + 8;
- return index;
- }
- function serializeFunction(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_CODE;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- const functionString = value.toString();
- const size = ByteUtils.encodeUTF8Into(buffer2, functionString, index + 4) + 1;
- buffer2[index] = size & 255;
- buffer2[index + 1] = size >> 8 & 255;
- buffer2[index + 2] = size >> 16 & 255;
- buffer2[index + 3] = size >> 24 & 255;
- index = index + 4 + size - 1;
- buffer2[index++] = 0;
- return index;
- }
- function serializeCode(buffer2, key, value, index, checkKeys = false, depth = 0, serializeFunctions = false, ignoreUndefined = true, path) {
- if (value.scope && typeof value.scope === "object") {
- buffer2[index++] = BSON_DATA_CODE_W_SCOPE;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- let startIndex = index;
- const functionString = value.code;
- index = index + 4;
- const codeSize = ByteUtils.encodeUTF8Into(buffer2, functionString, index + 4) + 1;
- buffer2[index] = codeSize & 255;
- buffer2[index + 1] = codeSize >> 8 & 255;
- buffer2[index + 2] = codeSize >> 16 & 255;
- buffer2[index + 3] = codeSize >> 24 & 255;
- buffer2[index + 4 + codeSize - 1] = 0;
- index = index + codeSize + 4;
- const endIndex = serializeInto(buffer2, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path);
- index = endIndex - 1;
- const totalSize = endIndex - startIndex;
- buffer2[startIndex++] = totalSize & 255;
- buffer2[startIndex++] = totalSize >> 8 & 255;
- buffer2[startIndex++] = totalSize >> 16 & 255;
- buffer2[startIndex++] = totalSize >> 24 & 255;
- buffer2[index++] = 0;
- } else {
- buffer2[index++] = BSON_DATA_CODE;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- const functionString = value.code.toString();
- const size = ByteUtils.encodeUTF8Into(buffer2, functionString, index + 4) + 1;
- buffer2[index] = size & 255;
- buffer2[index + 1] = size >> 8 & 255;
- buffer2[index + 2] = size >> 16 & 255;
- buffer2[index + 3] = size >> 24 & 255;
- index = index + 4 + size - 1;
- buffer2[index++] = 0;
- }
- return index;
- }
- function serializeBinary(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_BINARY;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- const data = value.buffer;
- let size = value.position;
- if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY)
- size = size + 4;
- buffer2[index++] = size & 255;
- buffer2[index++] = size >> 8 & 255;
- buffer2[index++] = size >> 16 & 255;
- buffer2[index++] = size >> 24 & 255;
- buffer2[index++] = value.sub_type;
- if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
- size = size - 4;
- buffer2[index++] = size & 255;
- buffer2[index++] = size >> 8 & 255;
- buffer2[index++] = size >> 16 & 255;
- buffer2[index++] = size >> 24 & 255;
- }
- buffer2.set(data, index);
- index = index + value.position;
- return index;
- }
- function serializeSymbol(buffer2, key, value, index) {
- buffer2[index++] = BSON_DATA_SYMBOL;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- const size = ByteUtils.encodeUTF8Into(buffer2, value.value, index + 4) + 1;
- buffer2[index] = size & 255;
- buffer2[index + 1] = size >> 8 & 255;
- buffer2[index + 2] = size >> 16 & 255;
- buffer2[index + 3] = size >> 24 & 255;
- index = index + 4 + size - 1;
- buffer2[index++] = 0;
- return index;
- }
- function serializeDBRef(buffer2, key, value, index, depth, serializeFunctions, path) {
- buffer2[index++] = BSON_DATA_OBJECT;
- const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index);
- index = index + numberOfWrittenBytes;
- buffer2[index++] = 0;
- let startIndex = index;
- let output = {
- $ref: value.collection || value.namespace,
- $id: value.oid
- };
- if (value.db != null) {
- output.$db = value.db;
- }
- output = Object.assign(output, value.fields);
- const endIndex = serializeInto(buffer2, output, false, index, depth + 1, serializeFunctions, true, path);
- const size = endIndex - startIndex;
- buffer2[startIndex++] = size & 255;
- buffer2[startIndex++] = size >> 8 & 255;
- buffer2[startIndex++] = size >> 16 & 255;
- buffer2[startIndex++] = size >> 24 & 255;
- return endIndex;
- }
- function serializeInto(buffer2, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) {
- if (path == null) {
- if (object == null) {
- buffer2[0] = 5;
- buffer2[1] = 0;
- buffer2[2] = 0;
- buffer2[3] = 0;
- buffer2[4] = 0;
- return 5;
- }
- if (Array.isArray(object)) {
- throw new BSONError("serialize does not support an array as the root input");
- }
- if (typeof object !== "object") {
- throw new BSONError("serialize does not support non-object as the root input");
- } else if ("_bsontype" in object && typeof object._bsontype === "string") {
- throw new BSONError(`BSON types cannot be serialized as a document`);
- } else if (isDate(object) || isRegExp(object) || isUint8Array(object) || isAnyArrayBuffer(object)) {
- throw new BSONError(`date, regexp, typedarray, and arraybuffer cannot be BSON documents`);
- }
- path = /* @__PURE__ */ new Set();
- }
- path.add(object);
- let index = startingIndex + 4;
- if (Array.isArray(object)) {
- for (let i = 0; i < object.length; i++) {
- const key = `${i}`;
- let value = object[i];
- if (typeof (value == null ? void 0 : value.toBSON) === "function") {
- value = value.toBSON();
- }
- if (typeof value === "string") {
- index = serializeString(buffer2, key, value, index);
- } else if (typeof value === "number") {
- index = serializeNumber(buffer2, key, value, index);
- } else if (typeof value === "bigint") {
- index = serializeBigInt(buffer2, key, value, index);
- } else if (typeof value === "boolean") {
- index = serializeBoolean(buffer2, key, value, index);
- } else if (value instanceof Date || isDate(value)) {
- index = serializeDate(buffer2, key, value, index);
- } else if (value === void 0) {
- index = serializeNull(buffer2, key, value, index);
- } else if (value === null) {
- index = serializeNull(buffer2, key, value, index);
- } else if (isUint8Array(value)) {
- index = serializeBuffer(buffer2, key, value, index);
- } else if (value instanceof RegExp || isRegExp(value)) {
- index = serializeRegExp(buffer2, key, value, index);
- } else if (typeof value === "object" && value._bsontype == null) {
- index = serializeObject(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
- } else if (typeof value === "object" && value[Symbol.for("@@mdb.bson.version")] !== BSON_MAJOR_VERSION) {
- throw new BSONVersionError();
- } else if (value._bsontype === "ObjectId") {
- index = serializeObjectId(buffer2, key, value, index);
- } else if (value._bsontype === "Decimal128") {
- index = serializeDecimal128(buffer2, key, value, index);
- } else if (value._bsontype === "Long" || value._bsontype === "Timestamp") {
- index = serializeLong(buffer2, key, value, index);
- } else if (value._bsontype === "Double") {
- index = serializeDouble(buffer2, key, value, index);
- } else if (typeof value === "function" && serializeFunctions) {
- index = serializeFunction(buffer2, key, value, index);
- } else if (value._bsontype === "Code") {
- index = serializeCode(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
- } else if (value._bsontype === "Binary") {
- index = serializeBinary(buffer2, key, value, index);
- } else if (value._bsontype === "BSONSymbol") {
- index = serializeSymbol(buffer2, key, value, index);
- } else if (value._bsontype === "DBRef") {
- index = serializeDBRef(buffer2, key, value, index, depth, serializeFunctions, path);
- } else if (value._bsontype === "BSONRegExp") {
- index = serializeBSONRegExp(buffer2, key, value, index);
- } else if (value._bsontype === "Int32") {
- index = serializeInt32(buffer2, key, value, index);
- } else if (value._bsontype === "MinKey" || value._bsontype === "MaxKey") {
- index = serializeMinMax(buffer2, key, value, index);
- } else if (typeof value._bsontype !== "undefined") {
- throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
- }
- }
- } else if (object instanceof Map || isMap(object)) {
- const iterator = object.entries();
- let done = false;
- while (!done) {
- const entry = iterator.next();
- done = !!entry.done;
- if (done)
- continue;
- const key = entry.value[0];
- let value = entry.value[1];
- if (typeof (value == null ? void 0 : value.toBSON) === "function") {
- value = value.toBSON();
- }
- const type = typeof value;
- if (typeof key === "string" && !ignoreKeys.has(key)) {
- if (key.match(regexp) != null) {
- throw new BSONError("key " + key + " must not contain null bytes");
- }
- if (checkKeys) {
- if ("$" === key[0]) {
- throw new BSONError("key " + key + " must not start with '$'");
- } else if (~key.indexOf(".")) {
- throw new BSONError("key " + key + " must not contain '.'");
- }
- }
- }
- if (type === "string") {
- index = serializeString(buffer2, key, value, index);
- } else if (type === "number") {
- index = serializeNumber(buffer2, key, value, index);
- } else if (type === "bigint") {
- index = serializeBigInt(buffer2, key, value, index);
- } else if (type === "boolean") {
- index = serializeBoolean(buffer2, key, value, index);
- } else if (value instanceof Date || isDate(value)) {
- index = serializeDate(buffer2, key, value, index);
- } else if (value === null || value === void 0 && ignoreUndefined === false) {
- index = serializeNull(buffer2, key, value, index);
- } else if (isUint8Array(value)) {
- index = serializeBuffer(buffer2, key, value, index);
- } else if (value instanceof RegExp || isRegExp(value)) {
- index = serializeRegExp(buffer2, key, value, index);
- } else if (type === "object" && value._bsontype == null) {
- index = serializeObject(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
- } else if (typeof value === "object" && value[Symbol.for("@@mdb.bson.version")] !== BSON_MAJOR_VERSION) {
- throw new BSONVersionError();
- } else if (value._bsontype === "ObjectId") {
- index = serializeObjectId(buffer2, key, value, index);
- } else if (type === "object" && value._bsontype === "Decimal128") {
- index = serializeDecimal128(buffer2, key, value, index);
- } else if (value._bsontype === "Long" || value._bsontype === "Timestamp") {
- index = serializeLong(buffer2, key, value, index);
- } else if (value._bsontype === "Double") {
- index = serializeDouble(buffer2, key, value, index);
- } else if (value._bsontype === "Code") {
- index = serializeCode(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
- } else if (typeof value === "function" && serializeFunctions) {
- index = serializeFunction(buffer2, key, value, index);
- } else if (value._bsontype === "Binary") {
- index = serializeBinary(buffer2, key, value, index);
- } else if (value._bsontype === "BSONSymbol") {
- index = serializeSymbol(buffer2, key, value, index);
- } else if (value._bsontype === "DBRef") {
- index = serializeDBRef(buffer2, key, value, index, depth, serializeFunctions, path);
- } else if (value._bsontype === "BSONRegExp") {
- index = serializeBSONRegExp(buffer2, key, value, index);
- } else if (value._bsontype === "Int32") {
- index = serializeInt32(buffer2, key, value, index);
- } else if (value._bsontype === "MinKey" || value._bsontype === "MaxKey") {
- index = serializeMinMax(buffer2, key, value, index);
- } else if (typeof value._bsontype !== "undefined") {
- throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
- }
- }
- } else {
- if (typeof (object == null ? void 0 : object.toBSON) === "function") {
- object = object.toBSON();
- if (object != null && typeof object !== "object") {
- throw new BSONError("toBSON function did not return an object");
- }
- }
- for (const key of Object.keys(object)) {
- let value = object[key];
- if (typeof (value == null ? void 0 : value.toBSON) === "function") {
- value = value.toBSON();
- }
- const type = typeof value;
- if (typeof key === "string" && !ignoreKeys.has(key)) {
- if (key.match(regexp) != null) {
- throw new BSONError("key " + key + " must not contain null bytes");
- }
- if (checkKeys) {
- if ("$" === key[0]) {
- throw new BSONError("key " + key + " must not start with '$'");
- } else if (~key.indexOf(".")) {
- throw new BSONError("key " + key + " must not contain '.'");
- }
- }
- }
- if (type === "string") {
- index = serializeString(buffer2, key, value, index);
- } else if (type === "number") {
- index = serializeNumber(buffer2, key, value, index);
- } else if (type === "bigint") {
- index = serializeBigInt(buffer2, key, value, index);
- } else if (type === "boolean") {
- index = serializeBoolean(buffer2, key, value, index);
- } else if (value instanceof Date || isDate(value)) {
- index = serializeDate(buffer2, key, value, index);
- } else if (value === void 0) {
- if (ignoreUndefined === false)
- index = serializeNull(buffer2, key, value, index);
- } else if (value === null) {
- index = serializeNull(buffer2, key, value, index);
- } else if (isUint8Array(value)) {
- index = serializeBuffer(buffer2, key, value, index);
- } else if (value instanceof RegExp || isRegExp(value)) {
- index = serializeRegExp(buffer2, key, value, index);
- } else if (type === "object" && value._bsontype == null) {
- index = serializeObject(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
- } else if (typeof value === "object" && value[Symbol.for("@@mdb.bson.version")] !== BSON_MAJOR_VERSION) {
- throw new BSONVersionError();
- } else if (value._bsontype === "ObjectId") {
- index = serializeObjectId(buffer2, key, value, index);
- } else if (type === "object" && value._bsontype === "Decimal128") {
- index = serializeDecimal128(buffer2, key, value, index);
- } else if (value._bsontype === "Long" || value._bsontype === "Timestamp") {
- index = serializeLong(buffer2, key, value, index);
- } else if (value._bsontype === "Double") {
- index = serializeDouble(buffer2, key, value, index);
- } else if (value._bsontype === "Code") {
- index = serializeCode(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
- } else if (typeof value === "function" && serializeFunctions) {
- index = serializeFunction(buffer2, key, value, index);
- } else if (value._bsontype === "Binary") {
- index = serializeBinary(buffer2, key, value, index);
- } else if (value._bsontype === "BSONSymbol") {
- index = serializeSymbol(buffer2, key, value, index);
- } else if (value._bsontype === "DBRef") {
- index = serializeDBRef(buffer2, key, value, index, depth, serializeFunctions, path);
- } else if (value._bsontype === "BSONRegExp") {
- index = serializeBSONRegExp(buffer2, key, value, index);
- } else if (value._bsontype === "Int32") {
- index = serializeInt32(buffer2, key, value, index);
- } else if (value._bsontype === "MinKey" || value._bsontype === "MaxKey") {
- index = serializeMinMax(buffer2, key, value, index);
- } else if (typeof value._bsontype !== "undefined") {
- throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
- }
- }
- }
- path.delete(object);
- buffer2[index++] = 0;
- const size = index - startingIndex;
- buffer2[startingIndex++] = size & 255;
- buffer2[startingIndex++] = size >> 8 & 255;
- buffer2[startingIndex++] = size >> 16 & 255;
- buffer2[startingIndex++] = size >> 24 & 255;
- return index;
- }
- function isBSONType(value) {
- return value != null && typeof value === "object" && "_bsontype" in value && typeof value._bsontype === "string";
- }
- var keysToCodecs = {
- $oid: ObjectId3,
- $binary: Binary,
- $uuid: Binary,
- $symbol: BSONSymbol,
- $numberInt: Int32,
- $numberDecimal: Decimal128,
- $numberDouble: Double,
- $numberLong: Long,
- $minKey: MinKey,
- $maxKey: MaxKey,
- $regex: BSONRegExp,
- $regularExpression: BSONRegExp,
- $timestamp: Timestamp
- };
- function deserializeValue(value, options = {}) {
- if (typeof value === "number") {
- const in32BitRange = value <= BSON_INT32_MAX && value >= BSON_INT32_MIN;
- const in64BitRange = value <= BSON_INT64_MAX && value >= BSON_INT64_MIN;
- if (options.relaxed || options.legacy) {
- return value;
- }
- if (Number.isInteger(value) && !Object.is(value, -0)) {
- if (in32BitRange) {
- return new Int32(value);
- }
- if (in64BitRange) {
- if (options.useBigInt64) {
- return BigInt(value);
- }
- return Long.fromNumber(value);
- }
- }
- return new Double(value);
- }
- if (value == null || typeof value !== "object")
- return value;
- if (value.$undefined)
- return null;
- const keys = Object.keys(value).filter((k) => k.startsWith("$") && value[k] != null);
- for (let i = 0; i < keys.length; i++) {
- const c = keysToCodecs[keys[i]];
- if (c)
- return c.fromExtendedJSON(value, options);
- }
- if (value.$date != null) {
- const d = value.$date;
- const date = /* @__PURE__ */ new Date();
- if (options.legacy) {
- if (typeof d === "number")
- date.setTime(d);
- else if (typeof d === "string")
- date.setTime(Date.parse(d));
- else if (typeof d === "bigint")
- date.setTime(Number(d));
- else
- throw new BSONRuntimeError(`Unrecognized type for EJSON date: ${typeof d}`);
- } else {
- if (typeof d === "string")
- date.setTime(Date.parse(d));
- else if (Long.isLong(d))
- date.setTime(d.toNumber());
- else if (typeof d === "number" && options.relaxed)
- date.setTime(d);
- else if (typeof d === "bigint")
- date.setTime(Number(d));
- else
- throw new BSONRuntimeError(`Unrecognized type for EJSON date: ${typeof d}`);
- }
- return date;
- }
- if (value.$code != null) {
- const copy = Object.assign({}, value);
- if (value.$scope) {
- copy.$scope = deserializeValue(value.$scope);
- }
- return Code.fromExtendedJSON(value);
- }
- if (isDBRefLike(value) || value.$dbPointer) {
- const v = value.$ref ? value : value.$dbPointer;
- if (v instanceof DBRef)
- return v;
- const dollarKeys = Object.keys(v).filter((k) => k.startsWith("$"));
- let valid = true;
- dollarKeys.forEach((k) => {
- if (["$ref", "$id", "$db"].indexOf(k) === -1)
- valid = false;
- });
- if (valid)
- return DBRef.fromExtendedJSON(v);
- }
- return value;
- }
- function serializeArray(array, options) {
- return array.map((v, index) => {
- options.seenObjects.push({ propertyName: `index ${index}`, obj: null });
- try {
- return serializeValue(v, options);
- } finally {
- options.seenObjects.pop();
- }
- });
- }
- function getISOString(date) {
- const isoStr = date.toISOString();
- return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + "Z";
- }
- function serializeValue(value, options) {
- if (value instanceof Map || isMap(value)) {
- const obj = /* @__PURE__ */ Object.create(null);
- for (const [k, v] of value) {
- if (typeof k !== "string") {
- throw new BSONError("Can only serialize maps with string keys");
- }
- obj[k] = v;
- }
- return serializeValue(obj, options);
- }
- if ((typeof value === "object" || typeof value === "function") && value !== null) {
- const index = options.seenObjects.findIndex((entry) => entry.obj === value);
- if (index !== -1) {
- const props = options.seenObjects.map((entry) => entry.propertyName);
- const leadingPart = props.slice(0, index).map((prop) => `${prop} -> `).join("");
- const alreadySeen = props[index];
- const circularPart = " -> " + props.slice(index + 1, props.length - 1).map((prop) => `${prop} -> `).join("");
- const current = props[props.length - 1];
- const leadingSpace = " ".repeat(leadingPart.length + alreadySeen.length / 2);
- const dashes = "-".repeat(circularPart.length + (alreadySeen.length + current.length) / 2 - 1);
- throw new BSONError(`Converting circular structure to EJSON:
- ${leadingPart}${alreadySeen}${circularPart}${current}
- ${leadingSpace}\\${dashes}/`);
- }
- options.seenObjects[options.seenObjects.length - 1].obj = value;
- }
- if (Array.isArray(value))
- return serializeArray(value, options);
- if (value === void 0)
- return null;
- if (value instanceof Date || isDate(value)) {
- const dateNum = value.getTime(), inRange = dateNum > -1 && dateNum < 2534023188e5;
- if (options.legacy) {
- return options.relaxed && inRange ? { $date: value.getTime() } : { $date: getISOString(value) };
- }
- return options.relaxed && inRange ? { $date: getISOString(value) } : { $date: { $numberLong: value.getTime().toString() } };
- }
- if (typeof value === "number" && (!options.relaxed || !isFinite(value))) {
- if (Number.isInteger(value) && !Object.is(value, -0)) {
- if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) {
- return { $numberInt: value.toString() };
- }
- if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX) {
- return { $numberLong: value.toString() };
- }
- }
- return { $numberDouble: Object.is(value, -0) ? "-0.0" : value.toString() };
- }
- if (typeof value === "bigint") {
- if (!options.relaxed) {
- return { $numberLong: BigInt.asIntN(64, value).toString() };
- }
- return Number(BigInt.asIntN(64, value));
- }
- if (value instanceof RegExp || isRegExp(value)) {
- let flags = value.flags;
- if (flags === void 0) {
- const match = value.toString().match(/[gimuy]*$/);
- if (match) {
- flags = match[0];
- }
- }
- const rx = new BSONRegExp(value.source, flags);
- return rx.toExtendedJSON(options);
- }
- if (value != null && typeof value === "object")
- return serializeDocument(value, options);
- return value;
- }
- var BSON_TYPE_MAPPINGS = {
- Binary: (o) => new Binary(o.value(), o.sub_type),
- Code: (o) => new Code(o.code, o.scope),
- DBRef: (o) => new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields),
- Decimal128: (o) => new Decimal128(o.bytes),
- Double: (o) => new Double(o.value),
- Int32: (o) => new Int32(o.value),
- Long: (o) => Long.fromBits(o.low != null ? o.low : o.low_, o.low != null ? o.high : o.high_, o.low != null ? o.unsigned : o.unsigned_),
- MaxKey: () => new MaxKey(),
- MinKey: () => new MinKey(),
- ObjectId: (o) => new ObjectId3(o),
- BSONRegExp: (o) => new BSONRegExp(o.pattern, o.options),
- BSONSymbol: (o) => new BSONSymbol(o.value),
- Timestamp: (o) => Timestamp.fromBits(o.low, o.high)
- };
- function serializeDocument(doc, options) {
- if (doc == null || typeof doc !== "object")
- throw new BSONError("not an object instance");
- const bsontype = doc._bsontype;
- if (typeof bsontype === "undefined") {
- const _doc = {};
- for (const name of Object.keys(doc)) {
- options.seenObjects.push({ propertyName: name, obj: null });
- try {
- const value = serializeValue(doc[name], options);
- if (name === "__proto__") {
- Object.defineProperty(_doc, name, {
- value,
- writable: true,
- enumerable: true,
- configurable: true
- });
- } else {
- _doc[name] = value;
- }
- } finally {
- options.seenObjects.pop();
- }
- }
- return _doc;
- } else if (doc != null && typeof doc === "object" && typeof doc._bsontype === "string" && doc[Symbol.for("@@mdb.bson.version")] !== BSON_MAJOR_VERSION) {
- throw new BSONVersionError();
- } else if (isBSONType(doc)) {
- let outDoc = doc;
- if (typeof outDoc.toExtendedJSON !== "function") {
- const mapper = BSON_TYPE_MAPPINGS[doc._bsontype];
- if (!mapper) {
- throw new BSONError("Unrecognized or invalid _bsontype: " + doc._bsontype);
- }
- outDoc = mapper(outDoc);
- }
- if (bsontype === "Code" && outDoc.scope) {
- outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options));
- } else if (bsontype === "DBRef" && outDoc.oid) {
- outDoc = new DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options));
- }
- return outDoc.toExtendedJSON(options);
- } else {
- throw new BSONError("_bsontype must be a string, but was: " + typeof bsontype);
- }
- }
- function parse(text, options) {
- const ejsonOptions = {
- useBigInt64: (options == null ? void 0 : options.useBigInt64) ?? false,
- relaxed: (options == null ? void 0 : options.relaxed) ?? true,
- legacy: (options == null ? void 0 : options.legacy) ?? false
- };
- return JSON.parse(text, (key, value) => {
- if (key.indexOf("\0") !== -1) {
- throw new BSONError(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(key)}`);
- }
- return deserializeValue(value, ejsonOptions);
- });
- }
- function stringify(value, replacer, space, options) {
- if (space != null && typeof space === "object") {
- options = space;
- space = 0;
- }
- if (replacer != null && typeof replacer === "object" && !Array.isArray(replacer)) {
- options = replacer;
- replacer = void 0;
- space = 0;
- }
- const serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, {
- seenObjects: [{ propertyName: "(root)", obj: null }]
- });
- const doc = serializeValue(value, serializeOptions);
- return JSON.stringify(doc, replacer, space);
- }
- function EJSONserialize(value, options) {
- options = options || {};
- return JSON.parse(stringify(value, options));
- }
- function EJSONdeserialize(ejson, options) {
- options = options || {};
- return parse(JSON.stringify(ejson), options);
- }
- var EJSON = /* @__PURE__ */ Object.create(null);
- EJSON.parse = parse;
- EJSON.stringify = stringify;
- EJSON.serialize = EJSONserialize;
- EJSON.deserialize = EJSONdeserialize;
- Object.freeze(EJSON);
- var MAXSIZE = 1024 * 1024 * 17;
- var buffer = ByteUtils.allocate(MAXSIZE);
- function setInternalBufferSize(size) {
- if (buffer.length < size) {
- buffer = ByteUtils.allocate(size);
- }
- }
- function serialize(object, options = {}) {
- const checkKeys = typeof options.checkKeys === "boolean" ? options.checkKeys : false;
- const serializeFunctions = typeof options.serializeFunctions === "boolean" ? options.serializeFunctions : false;
- const ignoreUndefined = typeof options.ignoreUndefined === "boolean" ? options.ignoreUndefined : true;
- const minInternalBufferSize = typeof options.minInternalBufferSize === "number" ? options.minInternalBufferSize : MAXSIZE;
- if (buffer.length < minInternalBufferSize) {
- buffer = ByteUtils.allocate(minInternalBufferSize);
- }
- const serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, null);
- const finishedBuffer = ByteUtils.allocate(serializationIndex);
- finishedBuffer.set(buffer.subarray(0, serializationIndex), 0);
- return finishedBuffer;
- }
- function serializeWithBufferAndIndex(object, finalBuffer, options = {}) {
- const checkKeys = typeof options.checkKeys === "boolean" ? options.checkKeys : false;
- const serializeFunctions = typeof options.serializeFunctions === "boolean" ? options.serializeFunctions : false;
- const ignoreUndefined = typeof options.ignoreUndefined === "boolean" ? options.ignoreUndefined : true;
- const startIndex = typeof options.index === "number" ? options.index : 0;
- const serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, null);
- finalBuffer.set(buffer.subarray(0, serializationIndex), startIndex);
- return startIndex + serializationIndex - 1;
- }
- function deserialize(buffer2, options = {}) {
- return internalDeserialize(ByteUtils.toLocalBufferType(buffer2), options);
- }
- function calculateObjectSize(object, options = {}) {
- options = options || {};
- const serializeFunctions = typeof options.serializeFunctions === "boolean" ? options.serializeFunctions : false;
- const ignoreUndefined = typeof options.ignoreUndefined === "boolean" ? options.ignoreUndefined : true;
- return internalCalculateObjectSize(object, serializeFunctions, ignoreUndefined);
- }
- function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) {
- const internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options);
- const bufferData = ByteUtils.toLocalBufferType(data);
- let index = startIndex;
- for (let i = 0; i < numberOfDocuments; i++) {
- const size = bufferData[index] | bufferData[index + 1] << 8 | bufferData[index + 2] << 16 | bufferData[index + 3] << 24;
- internalOptions.index = index;
- documents[docStartIndex + i] = internalDeserialize(bufferData, internalOptions);
- index = index + size;
- }
- return index;
- }
- var bson = /* @__PURE__ */ Object.freeze({
- __proto__: null,
- BSONError,
- BSONRegExp,
- BSONRuntimeError,
- BSONSymbol,
- BSONType,
- BSONValue,
- BSONVersionError,
- Binary,
- Code,
- DBRef,
- Decimal128,
- Double,
- EJSON,
- Int32,
- Long,
- MaxKey,
- MinKey,
- ObjectId: ObjectId3,
- Timestamp,
- UUID,
- calculateObjectSize,
- deserialize,
- deserializeStream,
- serialize,
- serializeWithBufferAndIndex,
- setInternalBufferSize
- });
- exports2.BSON = bson;
- exports2.BSONError = BSONError;
- exports2.BSONRegExp = BSONRegExp;
- exports2.BSONRuntimeError = BSONRuntimeError;
- exports2.BSONSymbol = BSONSymbol;
- exports2.BSONType = BSONType;
- exports2.BSONValue = BSONValue;
- exports2.BSONVersionError = BSONVersionError;
- exports2.Binary = Binary;
- exports2.Code = Code;
- exports2.DBRef = DBRef;
- exports2.Decimal128 = Decimal128;
- exports2.Double = Double;
- exports2.EJSON = EJSON;
- exports2.Int32 = Int32;
- exports2.Long = Long;
- exports2.MaxKey = MaxKey;
- exports2.MinKey = MinKey;
- exports2.ObjectId = ObjectId3;
- exports2.Timestamp = Timestamp;
- exports2.UUID = UUID;
- exports2.calculateObjectSize = calculateObjectSize;
- exports2.deserialize = deserialize;
- exports2.deserializeStream = deserializeStream;
- exports2.serialize = serialize;
- exports2.serializeWithBufferAndIndex = serializeWithBufferAndIndex;
- exports2.setInternalBufferSize = setInternalBufferSize;
- }
- });
- // node_modules/mongodb/lib/bson.js
- var require_bson2 = __commonJS({
- "node_modules/mongodb/lib/bson.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.resolveBSONOptions = exports2.pluckBSONSerializeOptions = exports2.Timestamp = exports2.serialize = exports2.ObjectId = exports2.MinKey = exports2.MaxKey = exports2.Long = exports2.Int32 = exports2.Double = exports2.deserialize = exports2.Decimal128 = exports2.DBRef = exports2.Code = exports2.calculateObjectSize = exports2.BSONType = exports2.BSONSymbol = exports2.BSONRegExp = exports2.BSON = exports2.Binary = void 0;
- var bson_1 = require_bson();
- Object.defineProperty(exports2, "Binary", { enumerable: true, get: function() {
- return bson_1.Binary;
- } });
- Object.defineProperty(exports2, "BSON", { enumerable: true, get: function() {
- return bson_1.BSON;
- } });
- Object.defineProperty(exports2, "BSONRegExp", { enumerable: true, get: function() {
- return bson_1.BSONRegExp;
- } });
- Object.defineProperty(exports2, "BSONSymbol", { enumerable: true, get: function() {
- return bson_1.BSONSymbol;
- } });
- Object.defineProperty(exports2, "BSONType", { enumerable: true, get: function() {
- return bson_1.BSONType;
- } });
- Object.defineProperty(exports2, "calculateObjectSize", { enumerable: true, get: function() {
- return bson_1.calculateObjectSize;
- } });
- Object.defineProperty(exports2, "Code", { enumerable: true, get: function() {
- return bson_1.Code;
- } });
- Object.defineProperty(exports2, "DBRef", { enumerable: true, get: function() {
- return bson_1.DBRef;
- } });
- Object.defineProperty(exports2, "Decimal128", { enumerable: true, get: function() {
- return bson_1.Decimal128;
- } });
- Object.defineProperty(exports2, "deserialize", { enumerable: true, get: function() {
- return bson_1.deserialize;
- } });
- Object.defineProperty(exports2, "Double", { enumerable: true, get: function() {
- return bson_1.Double;
- } });
- Object.defineProperty(exports2, "Int32", { enumerable: true, get: function() {
- return bson_1.Int32;
- } });
- Object.defineProperty(exports2, "Long", { enumerable: true, get: function() {
- return bson_1.Long;
- } });
- Object.defineProperty(exports2, "MaxKey", { enumerable: true, get: function() {
- return bson_1.MaxKey;
- } });
- Object.defineProperty(exports2, "MinKey", { enumerable: true, get: function() {
- return bson_1.MinKey;
- } });
- Object.defineProperty(exports2, "ObjectId", { enumerable: true, get: function() {
- return bson_1.ObjectId;
- } });
- Object.defineProperty(exports2, "serialize", { enumerable: true, get: function() {
- return bson_1.serialize;
- } });
- Object.defineProperty(exports2, "Timestamp", { enumerable: true, get: function() {
- return bson_1.Timestamp;
- } });
- function pluckBSONSerializeOptions(options) {
- const { fieldsAsRaw, useBigInt64, promoteValues, promoteBuffers, promoteLongs, serializeFunctions, ignoreUndefined, bsonRegExp, raw, enableUtf8Validation } = options;
- return {
- fieldsAsRaw,
- useBigInt64,
- promoteValues,
- promoteBuffers,
- promoteLongs,
- serializeFunctions,
- ignoreUndefined,
- bsonRegExp,
- raw,
- enableUtf8Validation
- };
- }
- exports2.pluckBSONSerializeOptions = pluckBSONSerializeOptions;
- function resolveBSONOptions(options, parent) {
- const parentOptions = parent == null ? void 0 : parent.bsonOptions;
- return {
- raw: (options == null ? void 0 : options.raw) ?? (parentOptions == null ? void 0 : parentOptions.raw) ?? false,
- useBigInt64: (options == null ? void 0 : options.useBigInt64) ?? (parentOptions == null ? void 0 : parentOptions.useBigInt64) ?? false,
- promoteLongs: (options == null ? void 0 : options.promoteLongs) ?? (parentOptions == null ? void 0 : parentOptions.promoteLongs) ?? true,
- promoteValues: (options == null ? void 0 : options.promoteValues) ?? (parentOptions == null ? void 0 : parentOptions.promoteValues) ?? true,
- promoteBuffers: (options == null ? void 0 : options.promoteBuffers) ?? (parentOptions == null ? void 0 : parentOptions.promoteBuffers) ?? false,
- ignoreUndefined: (options == null ? void 0 : options.ignoreUndefined) ?? (parentOptions == null ? void 0 : parentOptions.ignoreUndefined) ?? false,
- bsonRegExp: (options == null ? void 0 : options.bsonRegExp) ?? (parentOptions == null ? void 0 : parentOptions.bsonRegExp) ?? false,
- serializeFunctions: (options == null ? void 0 : options.serializeFunctions) ?? (parentOptions == null ? void 0 : parentOptions.serializeFunctions) ?? false,
- fieldsAsRaw: (options == null ? void 0 : options.fieldsAsRaw) ?? (parentOptions == null ? void 0 : parentOptions.fieldsAsRaw) ?? {},
- enableUtf8Validation: (options == null ? void 0 : options.enableUtf8Validation) ?? (parentOptions == null ? void 0 : parentOptions.enableUtf8Validation) ?? true
- };
- }
- exports2.resolveBSONOptions = resolveBSONOptions;
- }
- });
- // node_modules/mongodb/lib/cmap/wire_protocol/constants.js
- var require_constants = __commonJS({
- "node_modules/mongodb/lib/cmap/wire_protocol/constants.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.OP_MSG = exports2.OP_COMPRESSED = exports2.OP_DELETE = exports2.OP_QUERY = exports2.OP_INSERT = exports2.OP_UPDATE = exports2.OP_REPLY = exports2.MIN_SUPPORTED_QE_SERVER_VERSION = exports2.MIN_SUPPORTED_QE_WIRE_VERSION = exports2.MAX_SUPPORTED_WIRE_VERSION = exports2.MIN_SUPPORTED_WIRE_VERSION = exports2.MAX_SUPPORTED_SERVER_VERSION = exports2.MIN_SUPPORTED_SERVER_VERSION = void 0;
- exports2.MIN_SUPPORTED_SERVER_VERSION = "3.6";
- exports2.MAX_SUPPORTED_SERVER_VERSION = "7.0";
- exports2.MIN_SUPPORTED_WIRE_VERSION = 6;
- exports2.MAX_SUPPORTED_WIRE_VERSION = 21;
- exports2.MIN_SUPPORTED_QE_WIRE_VERSION = 21;
- exports2.MIN_SUPPORTED_QE_SERVER_VERSION = "7.0";
- exports2.OP_REPLY = 1;
- exports2.OP_UPDATE = 2001;
- exports2.OP_INSERT = 2002;
- exports2.OP_QUERY = 2004;
- exports2.OP_DELETE = 2006;
- exports2.OP_COMPRESSED = 2012;
- exports2.OP_MSG = 2013;
- }
- });
- // node_modules/mongodb/lib/constants.js
- var require_constants2 = __commonJS({
- "node_modules/mongodb/lib/constants.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.TOPOLOGY_EVENTS = exports2.CMAP_EVENTS = exports2.HEARTBEAT_EVENTS = exports2.RESUME_TOKEN_CHANGED = exports2.END = exports2.CHANGE = exports2.INIT = exports2.MORE = exports2.RESPONSE = exports2.SERVER_HEARTBEAT_FAILED = exports2.SERVER_HEARTBEAT_SUCCEEDED = exports2.SERVER_HEARTBEAT_STARTED = exports2.COMMAND_FAILED = exports2.COMMAND_SUCCEEDED = exports2.COMMAND_STARTED = exports2.CLUSTER_TIME_RECEIVED = exports2.CONNECTION_CHECKED_IN = exports2.CONNECTION_CHECKED_OUT = exports2.CONNECTION_CHECK_OUT_FAILED = exports2.CONNECTION_CHECK_OUT_STARTED = exports2.CONNECTION_CLOSED = exports2.CONNECTION_READY = exports2.CONNECTION_CREATED = exports2.CONNECTION_POOL_READY = exports2.CONNECTION_POOL_CLEARED = exports2.CONNECTION_POOL_CLOSED = exports2.CONNECTION_POOL_CREATED = exports2.TOPOLOGY_DESCRIPTION_CHANGED = exports2.TOPOLOGY_CLOSED = exports2.TOPOLOGY_OPENING = exports2.SERVER_DESCRIPTION_CHANGED = exports2.SERVER_CLOSED = exports2.SERVER_OPENING = exports2.DESCRIPTION_RECEIVED = exports2.UNPINNED = exports2.PINNED = exports2.MESSAGE = exports2.ENDED = exports2.CLOSED = exports2.CONNECT = exports2.OPEN = exports2.CLOSE = exports2.TIMEOUT = exports2.ERROR = exports2.SYSTEM_JS_COLLECTION = exports2.SYSTEM_COMMAND_COLLECTION = exports2.SYSTEM_USER_COLLECTION = exports2.SYSTEM_PROFILE_COLLECTION = exports2.SYSTEM_INDEX_COLLECTION = exports2.SYSTEM_NAMESPACE_COLLECTION = void 0;
- exports2.LEGACY_HELLO_COMMAND_CAMEL_CASE = exports2.LEGACY_HELLO_COMMAND = exports2.MONGO_CLIENT_EVENTS = exports2.LOCAL_SERVER_EVENTS = exports2.SERVER_RELAY_EVENTS = exports2.APM_EVENTS = void 0;
- exports2.SYSTEM_NAMESPACE_COLLECTION = "system.namespaces";
- exports2.SYSTEM_INDEX_COLLECTION = "system.indexes";
- exports2.SYSTEM_PROFILE_COLLECTION = "system.profile";
- exports2.SYSTEM_USER_COLLECTION = "system.users";
- exports2.SYSTEM_COMMAND_COLLECTION = "$cmd";
- exports2.SYSTEM_JS_COLLECTION = "system.js";
- exports2.ERROR = "error";
- exports2.TIMEOUT = "timeout";
- exports2.CLOSE = "close";
- exports2.OPEN = "open";
- exports2.CONNECT = "connect";
- exports2.CLOSED = "closed";
- exports2.ENDED = "ended";
- exports2.MESSAGE = "message";
- exports2.PINNED = "pinned";
- exports2.UNPINNED = "unpinned";
- exports2.DESCRIPTION_RECEIVED = "descriptionReceived";
- exports2.SERVER_OPENING = "serverOpening";
- exports2.SERVER_CLOSED = "serverClosed";
- exports2.SERVER_DESCRIPTION_CHANGED = "serverDescriptionChanged";
- exports2.TOPOLOGY_OPENING = "topologyOpening";
- exports2.TOPOLOGY_CLOSED = "topologyClosed";
- exports2.TOPOLOGY_DESCRIPTION_CHANGED = "topologyDescriptionChanged";
- exports2.CONNECTION_POOL_CREATED = "connectionPoolCreated";
- exports2.CONNECTION_POOL_CLOSED = "connectionPoolClosed";
- exports2.CONNECTION_POOL_CLEARED = "connectionPoolCleared";
- exports2.CONNECTION_POOL_READY = "connectionPoolReady";
- exports2.CONNECTION_CREATED = "connectionCreated";
- exports2.CONNECTION_READY = "connectionReady";
- exports2.CONNECTION_CLOSED = "connectionClosed";
- exports2.CONNECTION_CHECK_OUT_STARTED = "connectionCheckOutStarted";
- exports2.CONNECTION_CHECK_OUT_FAILED = "connectionCheckOutFailed";
- exports2.CONNECTION_CHECKED_OUT = "connectionCheckedOut";
- exports2.CONNECTION_CHECKED_IN = "connectionCheckedIn";
- exports2.CLUSTER_TIME_RECEIVED = "clusterTimeReceived";
- exports2.COMMAND_STARTED = "commandStarted";
- exports2.COMMAND_SUCCEEDED = "commandSucceeded";
- exports2.COMMAND_FAILED = "commandFailed";
- exports2.SERVER_HEARTBEAT_STARTED = "serverHeartbeatStarted";
- exports2.SERVER_HEARTBEAT_SUCCEEDED = "serverHeartbeatSucceeded";
- exports2.SERVER_HEARTBEAT_FAILED = "serverHeartbeatFailed";
- exports2.RESPONSE = "response";
- exports2.MORE = "more";
- exports2.INIT = "init";
- exports2.CHANGE = "change";
- exports2.END = "end";
- exports2.RESUME_TOKEN_CHANGED = "resumeTokenChanged";
- exports2.HEARTBEAT_EVENTS = Object.freeze([
- exports2.SERVER_HEARTBEAT_STARTED,
- exports2.SERVER_HEARTBEAT_SUCCEEDED,
- exports2.SERVER_HEARTBEAT_FAILED
- ]);
- exports2.CMAP_EVENTS = Object.freeze([
- exports2.CONNECTION_POOL_CREATED,
- exports2.CONNECTION_POOL_READY,
- exports2.CONNECTION_POOL_CLEARED,
- exports2.CONNECTION_POOL_CLOSED,
- exports2.CONNECTION_CREATED,
- exports2.CONNECTION_READY,
- exports2.CONNECTION_CLOSED,
- exports2.CONNECTION_CHECK_OUT_STARTED,
- exports2.CONNECTION_CHECK_OUT_FAILED,
- exports2.CONNECTION_CHECKED_OUT,
- exports2.CONNECTION_CHECKED_IN
- ]);
- exports2.TOPOLOGY_EVENTS = Object.freeze([
- exports2.SERVER_OPENING,
- exports2.SERVER_CLOSED,
- exports2.SERVER_DESCRIPTION_CHANGED,
- exports2.TOPOLOGY_OPENING,
- exports2.TOPOLOGY_CLOSED,
- exports2.TOPOLOGY_DESCRIPTION_CHANGED,
- exports2.ERROR,
- exports2.TIMEOUT,
- exports2.CLOSE
- ]);
- exports2.APM_EVENTS = Object.freeze([
- exports2.COMMAND_STARTED,
- exports2.COMMAND_SUCCEEDED,
- exports2.COMMAND_FAILED
- ]);
- exports2.SERVER_RELAY_EVENTS = Object.freeze([
- exports2.SERVER_HEARTBEAT_STARTED,
- exports2.SERVER_HEARTBEAT_SUCCEEDED,
- exports2.SERVER_HEARTBEAT_FAILED,
- exports2.COMMAND_STARTED,
- exports2.COMMAND_SUCCEEDED,
- exports2.COMMAND_FAILED,
- ...exports2.CMAP_EVENTS
- ]);
- exports2.LOCAL_SERVER_EVENTS = Object.freeze([
- exports2.CONNECT,
- exports2.DESCRIPTION_RECEIVED,
- exports2.CLOSED,
- exports2.ENDED
- ]);
- exports2.MONGO_CLIENT_EVENTS = Object.freeze([
- ...exports2.CMAP_EVENTS,
- ...exports2.APM_EVENTS,
- ...exports2.TOPOLOGY_EVENTS,
- ...exports2.HEARTBEAT_EVENTS
- ]);
- exports2.LEGACY_HELLO_COMMAND = "ismaster";
- exports2.LEGACY_HELLO_COMMAND_CAMEL_CASE = "isMaster";
- }
- });
- // node_modules/mongodb/lib/read_concern.js
- var require_read_concern = __commonJS({
- "node_modules/mongodb/lib/read_concern.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ReadConcern = exports2.ReadConcernLevel = void 0;
- exports2.ReadConcernLevel = Object.freeze({
- local: "local",
- majority: "majority",
- linearizable: "linearizable",
- available: "available",
- snapshot: "snapshot"
- });
- var ReadConcern = class _ReadConcern {
- /** Constructs a ReadConcern from the read concern level.*/
- constructor(level) {
- this.level = exports2.ReadConcernLevel[level] ?? level;
- }
- /**
- * Construct a ReadConcern given an options object.
- *
- * @param options - The options object from which to extract the write concern.
- */
- static fromOptions(options) {
- if (options == null) {
- return;
- }
- if (options.readConcern) {
- const { readConcern } = options;
- if (readConcern instanceof _ReadConcern) {
- return readConcern;
- } else if (typeof readConcern === "string") {
- return new _ReadConcern(readConcern);
- } else if ("level" in readConcern && readConcern.level) {
- return new _ReadConcern(readConcern.level);
- }
- }
- if (options.level) {
- return new _ReadConcern(options.level);
- }
- return;
- }
- static get MAJORITY() {
- return exports2.ReadConcernLevel.majority;
- }
- static get AVAILABLE() {
- return exports2.ReadConcernLevel.available;
- }
- static get LINEARIZABLE() {
- return exports2.ReadConcernLevel.linearizable;
- }
- static get SNAPSHOT() {
- return exports2.ReadConcernLevel.snapshot;
- }
- toJSON() {
- return { level: this.level };
- }
- };
- exports2.ReadConcern = ReadConcern;
- }
- });
- // node_modules/mongodb/lib/read_preference.js
- var require_read_preference = __commonJS({
- "node_modules/mongodb/lib/read_preference.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ReadPreference = exports2.ReadPreferenceMode = void 0;
- var error_1 = require_error();
- exports2.ReadPreferenceMode = Object.freeze({
- primary: "primary",
- primaryPreferred: "primaryPreferred",
- secondary: "secondary",
- secondaryPreferred: "secondaryPreferred",
- nearest: "nearest"
- });
- var ReadPreference = class _ReadPreference {
- /**
- * @param mode - A string describing the read preference mode (primary|primaryPreferred|secondary|secondaryPreferred|nearest)
- * @param tags - A tag set used to target reads to members with the specified tag(s). tagSet is not available if using read preference mode primary.
- * @param options - Additional read preference options
- */
- constructor(mode, tags, options) {
- if (!_ReadPreference.isValid(mode)) {
- throw new error_1.MongoInvalidArgumentError(`Invalid read preference mode ${JSON.stringify(mode)}`);
- }
- if (options == null && typeof tags === "object" && !Array.isArray(tags)) {
- options = tags;
- tags = void 0;
- } else if (tags && !Array.isArray(tags)) {
- throw new error_1.MongoInvalidArgumentError("ReadPreference tags must be an array");
- }
- this.mode = mode;
- this.tags = tags;
- this.hedge = options == null ? void 0 : options.hedge;
- this.maxStalenessSeconds = void 0;
- this.minWireVersion = void 0;
- options = options ?? {};
- if (options.maxStalenessSeconds != null) {
- if (options.maxStalenessSeconds <= 0) {
- throw new error_1.MongoInvalidArgumentError("maxStalenessSeconds must be a positive integer");
- }
- this.maxStalenessSeconds = options.maxStalenessSeconds;
- this.minWireVersion = 5;
- }
- if (this.mode === _ReadPreference.PRIMARY) {
- if (this.tags && Array.isArray(this.tags) && this.tags.length > 0) {
- throw new error_1.MongoInvalidArgumentError("Primary read preference cannot be combined with tags");
- }
- if (this.maxStalenessSeconds) {
- throw new error_1.MongoInvalidArgumentError("Primary read preference cannot be combined with maxStalenessSeconds");
- }
- if (this.hedge) {
- throw new error_1.MongoInvalidArgumentError("Primary read preference cannot be combined with hedge");
- }
- }
- }
- // Support the deprecated `preference` property introduced in the porcelain layer
- get preference() {
- return this.mode;
- }
- static fromString(mode) {
- return new _ReadPreference(mode);
- }
- /**
- * Construct a ReadPreference given an options object.
- *
- * @param options - The options object from which to extract the read preference.
- */
- static fromOptions(options) {
- var _a;
- if (!options)
- return;
- const readPreference = options.readPreference ?? ((_a = options.session) == null ? void 0 : _a.transaction.options.readPreference);
- const readPreferenceTags = options.readPreferenceTags;
- if (readPreference == null) {
- return;
- }
- if (typeof readPreference === "string") {
- return new _ReadPreference(readPreference, readPreferenceTags, {
- maxStalenessSeconds: options.maxStalenessSeconds,
- hedge: options.hedge
- });
- } else if (!(readPreference instanceof _ReadPreference) && typeof readPreference === "object") {
- const mode = readPreference.mode || readPreference.preference;
- if (mode && typeof mode === "string") {
- return new _ReadPreference(mode, readPreference.tags ?? readPreferenceTags, {
- maxStalenessSeconds: readPreference.maxStalenessSeconds,
- hedge: options.hedge
- });
- }
- }
- if (readPreferenceTags) {
- readPreference.tags = readPreferenceTags;
- }
- return readPreference;
- }
- /**
- * Replaces options.readPreference with a ReadPreference instance
- */
- static translate(options) {
- if (options.readPreference == null)
- return options;
- const r = options.readPreference;
- if (typeof r === "string") {
- options.readPreference = new _ReadPreference(r);
- } else if (r && !(r instanceof _ReadPreference) && typeof r === "object") {
- const mode = r.mode || r.preference;
- if (mode && typeof mode === "string") {
- options.readPreference = new _ReadPreference(mode, r.tags, {
- maxStalenessSeconds: r.maxStalenessSeconds
- });
- }
- } else if (!(r instanceof _ReadPreference)) {
- throw new error_1.MongoInvalidArgumentError(`Invalid read preference: ${r}`);
- }
- return options;
- }
- /**
- * Validate if a mode is legal
- *
- * @param mode - The string representing the read preference mode.
- */
- static isValid(mode) {
- const VALID_MODES = /* @__PURE__ */ new Set([
- _ReadPreference.PRIMARY,
- _ReadPreference.PRIMARY_PREFERRED,
- _ReadPreference.SECONDARY,
- _ReadPreference.SECONDARY_PREFERRED,
- _ReadPreference.NEAREST,
- null
- ]);
- return VALID_MODES.has(mode);
- }
- /**
- * Validate if a mode is legal
- *
- * @param mode - The string representing the read preference mode.
- */
- isValid(mode) {
- return _ReadPreference.isValid(typeof mode === "string" ? mode : this.mode);
- }
- /**
- * Indicates that this readPreference needs the "SecondaryOk" bit when sent over the wire
- * @see https://www.mongodb.com/docs/manual/reference/mongodb-wire-protocol/#op-query
- */
- secondaryOk() {
- const NEEDS_SECONDARYOK = /* @__PURE__ */ new Set([
- _ReadPreference.PRIMARY_PREFERRED,
- _ReadPreference.SECONDARY,
- _ReadPreference.SECONDARY_PREFERRED,
- _ReadPreference.NEAREST
- ]);
- return NEEDS_SECONDARYOK.has(this.mode);
- }
- /**
- * Check if the two ReadPreferences are equivalent
- *
- * @param readPreference - The read preference with which to check equality
- */
- equals(readPreference) {
- return readPreference.mode === this.mode;
- }
- /** Return JSON representation */
- toJSON() {
- const readPreference = { mode: this.mode };
- if (Array.isArray(this.tags))
- readPreference.tags = this.tags;
- if (this.maxStalenessSeconds)
- readPreference.maxStalenessSeconds = this.maxStalenessSeconds;
- if (this.hedge)
- readPreference.hedge = this.hedge;
- return readPreference;
- }
- };
- ReadPreference.PRIMARY = exports2.ReadPreferenceMode.primary;
- ReadPreference.PRIMARY_PREFERRED = exports2.ReadPreferenceMode.primaryPreferred;
- ReadPreference.SECONDARY = exports2.ReadPreferenceMode.secondary;
- ReadPreference.SECONDARY_PREFERRED = exports2.ReadPreferenceMode.secondaryPreferred;
- ReadPreference.NEAREST = exports2.ReadPreferenceMode.nearest;
- ReadPreference.primary = new ReadPreference(exports2.ReadPreferenceMode.primary);
- ReadPreference.primaryPreferred = new ReadPreference(exports2.ReadPreferenceMode.primaryPreferred);
- ReadPreference.secondary = new ReadPreference(exports2.ReadPreferenceMode.secondary);
- ReadPreference.secondaryPreferred = new ReadPreference(exports2.ReadPreferenceMode.secondaryPreferred);
- ReadPreference.nearest = new ReadPreference(exports2.ReadPreferenceMode.nearest);
- exports2.ReadPreference = ReadPreference;
- }
- });
- // node_modules/mongodb/lib/sdam/common.js
- var require_common = __commonJS({
- "node_modules/mongodb/lib/sdam/common.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2._advanceClusterTime = exports2.drainTimerQueue = exports2.ServerType = exports2.TopologyType = exports2.STATE_CONNECTED = exports2.STATE_CONNECTING = exports2.STATE_CLOSED = exports2.STATE_CLOSING = void 0;
- var timers_1 = require("timers");
- exports2.STATE_CLOSING = "closing";
- exports2.STATE_CLOSED = "closed";
- exports2.STATE_CONNECTING = "connecting";
- exports2.STATE_CONNECTED = "connected";
- exports2.TopologyType = Object.freeze({
- Single: "Single",
- ReplicaSetNoPrimary: "ReplicaSetNoPrimary",
- ReplicaSetWithPrimary: "ReplicaSetWithPrimary",
- Sharded: "Sharded",
- Unknown: "Unknown",
- LoadBalanced: "LoadBalanced"
- });
- exports2.ServerType = Object.freeze({
- Standalone: "Standalone",
- Mongos: "Mongos",
- PossiblePrimary: "PossiblePrimary",
- RSPrimary: "RSPrimary",
- RSSecondary: "RSSecondary",
- RSArbiter: "RSArbiter",
- RSOther: "RSOther",
- RSGhost: "RSGhost",
- Unknown: "Unknown",
- LoadBalancer: "LoadBalancer"
- });
- function drainTimerQueue(queue) {
- queue.forEach(timers_1.clearTimeout);
- queue.clear();
- }
- exports2.drainTimerQueue = drainTimerQueue;
- function _advanceClusterTime(entity, $clusterTime) {
- if (entity.clusterTime == null) {
- entity.clusterTime = $clusterTime;
- } else {
- if ($clusterTime.clusterTime.greaterThan(entity.clusterTime.clusterTime)) {
- entity.clusterTime = $clusterTime;
- }
- }
- }
- exports2._advanceClusterTime = _advanceClusterTime;
- }
- });
- // node_modules/mongodb/lib/write_concern.js
- var require_write_concern = __commonJS({
- "node_modules/mongodb/lib/write_concern.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.WriteConcern = exports2.WRITE_CONCERN_KEYS = void 0;
- exports2.WRITE_CONCERN_KEYS = ["w", "wtimeout", "j", "journal", "fsync"];
- var WriteConcern = class _WriteConcern {
- /**
- * Constructs a WriteConcern from the write concern properties.
- * @param w - request acknowledgment that the write operation has propagated to a specified number of mongod instances or to mongod instances with specified tags.
- * @param wtimeoutMS - specify a time limit to prevent write operations from blocking indefinitely
- * @param journal - request acknowledgment that the write operation has been written to the on-disk journal
- * @param fsync - equivalent to the j option. Is deprecated and will be removed in the next major version.
- */
- constructor(w, wtimeoutMS, journal, fsync) {
- if (w != null) {
- if (!Number.isNaN(Number(w))) {
- this.w = Number(w);
- } else {
- this.w = w;
- }
- }
- if (wtimeoutMS != null) {
- this.wtimeoutMS = this.wtimeout = wtimeoutMS;
- }
- if (journal != null) {
- this.journal = this.j = journal;
- }
- if (fsync != null) {
- this.journal = this.j = fsync ? true : false;
- }
- }
- /**
- * Apply a write concern to a command document. Will modify and return the command.
- */
- static apply(command, writeConcern) {
- const wc = {};
- if (writeConcern.w != null)
- wc.w = writeConcern.w;
- if (writeConcern.wtimeoutMS != null)
- wc.wtimeout = writeConcern.wtimeoutMS;
- if (writeConcern.journal != null)
- wc.j = writeConcern.j;
- command.writeConcern = wc;
- return command;
- }
- /** Construct a WriteConcern given an options object. */
- static fromOptions(options, inherit) {
- if (options == null)
- return void 0;
- inherit = inherit ?? {};
- let opts;
- if (typeof options === "string" || typeof options === "number") {
- opts = { w: options };
- } else if (options instanceof _WriteConcern) {
- opts = options;
- } else {
- opts = options.writeConcern;
- }
- const parentOpts = inherit instanceof _WriteConcern ? inherit : inherit.writeConcern;
- const { w = void 0, wtimeout = void 0, j = void 0, fsync = void 0, journal = void 0, wtimeoutMS = void 0 } = {
- ...parentOpts,
- ...opts
- };
- if (w != null || wtimeout != null || wtimeoutMS != null || j != null || journal != null || fsync != null) {
- return new _WriteConcern(w, wtimeout ?? wtimeoutMS, j ?? journal, fsync);
- }
- return void 0;
- }
- };
- exports2.WriteConcern = WriteConcern;
- }
- });
- // node_modules/mongodb/lib/utils.js
- var require_utils = __commonJS({
- "node_modules/mongodb/lib/utils.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.matchesParentDomain = exports2.parseUnsignedInteger = exports2.parseInteger = exports2.compareObjectId = exports2.getMongoDBClientEncryption = exports2.commandSupportsReadConcern = exports2.shuffle = exports2.supportsRetryableWrites = exports2.enumToString = exports2.emitWarningOnce = exports2.emitWarning = exports2.MONGODB_WARNING_CODE = exports2.DEFAULT_PK_FACTORY = exports2.HostAddress = exports2.BufferPool = exports2.List = exports2.deepCopy = exports2.isRecord = exports2.setDifference = exports2.isHello = exports2.isSuperset = exports2.resolveOptions = exports2.hasAtomicOperators = exports2.calculateDurationInMs = exports2.now = exports2.makeStateMachine = exports2.errorStrictEqual = exports2.arrayStrictEqual = exports2.eachAsync = exports2.maxWireVersion = exports2.uuidV4 = exports2.databaseNamespace = exports2.maybeCallback = exports2.makeCounter = exports2.MongoDBCollectionNamespace = exports2.MongoDBNamespace = exports2.ns = exports2.getTopology = exports2.decorateWithExplain = exports2.decorateWithReadConcern = exports2.decorateWithCollation = exports2.isPromiseLike = exports2.applyRetryableWrites = exports2.filterOptions = exports2.mergeOptions = exports2.isObject = exports2.normalizeHintField = exports2.checkCollectionName = exports2.hostMatchesWildcards = exports2.ByteUtils = void 0;
- exports2.request = void 0;
- var crypto = require("crypto");
- var http = require("http");
- var url = require("url");
- var url_1 = require("url");
- var bson_1 = require_bson2();
- var constants_1 = require_constants();
- var constants_2 = require_constants2();
- var error_1 = require_error();
- var read_concern_1 = require_read_concern();
- var read_preference_1 = require_read_preference();
- var common_1 = require_common();
- var write_concern_1 = require_write_concern();
- exports2.ByteUtils = {
- toLocalBufferType(buffer) {
- return Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
- },
- equals(seqA, seqB) {
- return exports2.ByteUtils.toLocalBufferType(seqA).equals(seqB);
- },
- compare(seqA, seqB) {
- return exports2.ByteUtils.toLocalBufferType(seqA).compare(seqB);
- },
- toBase64(uint8array) {
- return exports2.ByteUtils.toLocalBufferType(uint8array).toString("base64");
- }
- };
- function hostMatchesWildcards(host, wildcards) {
- for (const wildcard of wildcards) {
- if (host === wildcard || wildcard.startsWith("*.") && (host == null ? void 0 : host.endsWith(wildcard.substring(2, wildcard.length))) || wildcard.startsWith("*/") && (host == null ? void 0 : host.endsWith(wildcard.substring(2, wildcard.length)))) {
- return true;
- }
- }
- return false;
- }
- exports2.hostMatchesWildcards = hostMatchesWildcards;
- function checkCollectionName(collectionName) {
- if ("string" !== typeof collectionName) {
- throw new error_1.MongoInvalidArgumentError("Collection name must be a String");
- }
- if (!collectionName || collectionName.indexOf("..") !== -1) {
- throw new error_1.MongoInvalidArgumentError("Collection names cannot be empty");
- }
- if (collectionName.indexOf("$") !== -1 && collectionName.match(/((^\$cmd)|(oplog\.\$main))/) == null) {
- throw new error_1.MongoInvalidArgumentError("Collection names must not contain '$'");
- }
- if (collectionName.match(/^\.|\.$/) != null) {
- throw new error_1.MongoInvalidArgumentError("Collection names must not start or end with '.'");
- }
- if (collectionName.indexOf("\0") !== -1) {
- throw new error_1.MongoInvalidArgumentError("Collection names cannot contain a null character");
- }
- }
- exports2.checkCollectionName = checkCollectionName;
- function normalizeHintField(hint) {
- let finalHint = void 0;
- if (typeof hint === "string") {
- finalHint = hint;
- } else if (Array.isArray(hint)) {
- finalHint = {};
- hint.forEach((param) => {
- finalHint[param] = 1;
- });
- } else if (hint != null && typeof hint === "object") {
- finalHint = {};
- for (const name in hint) {
- finalHint[name] = hint[name];
- }
- }
- return finalHint;
- }
- exports2.normalizeHintField = normalizeHintField;
- var TO_STRING = (object) => Object.prototype.toString.call(object);
- function isObject(arg) {
- return "[object Object]" === TO_STRING(arg);
- }
- exports2.isObject = isObject;
- function mergeOptions(target, source) {
- return { ...target, ...source };
- }
- exports2.mergeOptions = mergeOptions;
- function filterOptions(options, names) {
- const filterOptions2 = {};
- for (const name in options) {
- if (names.includes(name)) {
- filterOptions2[name] = options[name];
- }
- }
- return filterOptions2;
- }
- exports2.filterOptions = filterOptions;
- function applyRetryableWrites(target, db) {
- var _a;
- if (db && ((_a = db.s.options) == null ? void 0 : _a.retryWrites)) {
- target.retryWrites = true;
- }
- return target;
- }
- exports2.applyRetryableWrites = applyRetryableWrites;
- function isPromiseLike(value) {
- return !!value && typeof value.then === "function";
- }
- exports2.isPromiseLike = isPromiseLike;
- function decorateWithCollation(command, target, options) {
- const capabilities = getTopology(target).capabilities;
- if (options.collation && typeof options.collation === "object") {
- if (capabilities && capabilities.commandsTakeCollation) {
- command.collation = options.collation;
- } else {
- throw new error_1.MongoCompatibilityError(`Current topology does not support collation`);
- }
- }
- }
- exports2.decorateWithCollation = decorateWithCollation;
- function decorateWithReadConcern(command, coll, options) {
- if (options && options.session && options.session.inTransaction()) {
- return;
- }
- const readConcern = Object.assign({}, command.readConcern || {});
- if (coll.s.readConcern) {
- Object.assign(readConcern, coll.s.readConcern);
- }
- if (Object.keys(readConcern).length > 0) {
- Object.assign(command, { readConcern });
- }
- }
- exports2.decorateWithReadConcern = decorateWithReadConcern;
- function decorateWithExplain(command, explain) {
- if (command.explain) {
- return command;
- }
- return { explain: command, verbosity: explain.verbosity };
- }
- exports2.decorateWithExplain = decorateWithExplain;
- function getTopology(provider) {
- if ("topology" in provider && provider.topology) {
- return provider.topology;
- } else if ("client" in provider && provider.client.topology) {
- return provider.client.topology;
- }
- throw new error_1.MongoNotConnectedError("MongoClient must be connected to perform this operation");
- }
- exports2.getTopology = getTopology;
- function ns(ns2) {
- return MongoDBNamespace.fromString(ns2);
- }
- exports2.ns = ns;
- var MongoDBNamespace = class _MongoDBNamespace {
- /**
- * Create a namespace object
- *
- * @param db - database name
- * @param collection - collection name
- */
- constructor(db, collection) {
- this.db = db;
- this.collection = collection;
- this.collection = collection === "" ? void 0 : collection;
- }
- toString() {
- return this.collection ? `${this.db}.${this.collection}` : this.db;
- }
- withCollection(collection) {
- return new MongoDBCollectionNamespace(this.db, collection);
- }
- static fromString(namespace) {
- if (typeof namespace !== "string" || namespace === "") {
- throw new error_1.MongoRuntimeError(`Cannot parse namespace from "${namespace}"`);
- }
- const [db, ...collectionParts] = namespace.split(".");
- const collection = collectionParts.join(".");
- return new _MongoDBNamespace(db, collection === "" ? void 0 : collection);
- }
- };
- exports2.MongoDBNamespace = MongoDBNamespace;
- var MongoDBCollectionNamespace = class extends MongoDBNamespace {
- constructor(db, collection) {
- super(db, collection);
- this.collection = collection;
- }
- };
- exports2.MongoDBCollectionNamespace = MongoDBCollectionNamespace;
- function* makeCounter(seed = 0) {
- let count = seed;
- while (true) {
- const newCount = count;
- count += 1;
- yield newCount;
- }
- }
- exports2.makeCounter = makeCounter;
- function maybeCallback(promiseFn, callback) {
- const promise = promiseFn();
- if (callback == null) {
- return promise;
- }
- promise.then((result) => callback(void 0, result), (error) => callback(error));
- return;
- }
- exports2.maybeCallback = maybeCallback;
- function databaseNamespace(ns2) {
- return ns2.split(".")[0];
- }
- exports2.databaseNamespace = databaseNamespace;
- function uuidV4() {
- const result = crypto.randomBytes(16);
- result[6] = result[6] & 15 | 64;
- result[8] = result[8] & 63 | 128;
- return result;
- }
- exports2.uuidV4 = uuidV4;
- function maxWireVersion(topologyOrServer) {
- if (topologyOrServer) {
- if (topologyOrServer.loadBalanced) {
- return constants_1.MAX_SUPPORTED_WIRE_VERSION;
- }
- if (topologyOrServer.hello) {
- return topologyOrServer.hello.maxWireVersion;
- }
- if ("lastHello" in topologyOrServer && typeof topologyOrServer.lastHello === "function") {
- const lastHello = topologyOrServer.lastHello();
- if (lastHello) {
- return lastHello.maxWireVersion;
- }
- }
- if (topologyOrServer.description && "maxWireVersion" in topologyOrServer.description && topologyOrServer.description.maxWireVersion != null) {
- return topologyOrServer.description.maxWireVersion;
- }
- }
- return 0;
- }
- exports2.maxWireVersion = maxWireVersion;
- function eachAsync(arr, eachFn, callback) {
- arr = arr || [];
- let idx = 0;
- let awaiting = 0;
- for (idx = 0; idx < arr.length; ++idx) {
- awaiting++;
- eachFn(arr[idx], eachCallback);
- }
- if (awaiting === 0) {
- callback();
- return;
- }
- function eachCallback(err) {
- awaiting--;
- if (err) {
- callback(err);
- return;
- }
- if (idx === arr.length && awaiting <= 0) {
- callback();
- }
- }
- }
- exports2.eachAsync = eachAsync;
- function arrayStrictEqual(arr, arr2) {
- if (!Array.isArray(arr) || !Array.isArray(arr2)) {
- return false;
- }
- return arr.length === arr2.length && arr.every((elt, idx) => elt === arr2[idx]);
- }
- exports2.arrayStrictEqual = arrayStrictEqual;
- function errorStrictEqual(lhs, rhs) {
- if (lhs === rhs) {
- return true;
- }
- if (!lhs || !rhs) {
- return lhs === rhs;
- }
- if (lhs == null && rhs != null || lhs != null && rhs == null) {
- return false;
- }
- if (lhs.constructor.name !== rhs.constructor.name) {
- return false;
- }
- if (lhs.message !== rhs.message) {
- return false;
- }
- return true;
- }
- exports2.errorStrictEqual = errorStrictEqual;
- function makeStateMachine(stateTable) {
- return function stateTransition(target, newState) {
- const legalStates = stateTable[target.s.state];
- if (legalStates && legalStates.indexOf(newState) < 0) {
- throw new error_1.MongoRuntimeError(`illegal state transition from [${target.s.state}] => [${newState}], allowed: [${legalStates}]`);
- }
- target.emit("stateChanged", target.s.state, newState);
- target.s.state = newState;
- };
- }
- exports2.makeStateMachine = makeStateMachine;
- function now() {
- const hrtime = process.hrtime();
- return Math.floor(hrtime[0] * 1e3 + hrtime[1] / 1e6);
- }
- exports2.now = now;
- function calculateDurationInMs(started) {
- if (typeof started !== "number") {
- throw new error_1.MongoInvalidArgumentError("Numeric value required to calculate duration");
- }
- const elapsed = now() - started;
- return elapsed < 0 ? 0 : elapsed;
- }
- exports2.calculateDurationInMs = calculateDurationInMs;
- function hasAtomicOperators(doc) {
- if (Array.isArray(doc)) {
- for (const document of doc) {
- if (hasAtomicOperators(document)) {
- return true;
- }
- }
- return false;
- }
- const keys = Object.keys(doc);
- return keys.length > 0 && keys[0][0] === "$";
- }
- exports2.hasAtomicOperators = hasAtomicOperators;
- function resolveOptions(parent, options) {
- const result = Object.assign({}, options, (0, bson_1.resolveBSONOptions)(options, parent));
- const session = options == null ? void 0 : options.session;
- if (!(session == null ? void 0 : session.inTransaction())) {
- const readConcern = read_concern_1.ReadConcern.fromOptions(options) ?? (parent == null ? void 0 : parent.readConcern);
- if (readConcern) {
- result.readConcern = readConcern;
- }
- const writeConcern = write_concern_1.WriteConcern.fromOptions(options) ?? (parent == null ? void 0 : parent.writeConcern);
- if (writeConcern) {
- result.writeConcern = writeConcern;
- }
- }
- const readPreference = read_preference_1.ReadPreference.fromOptions(options) ?? (parent == null ? void 0 : parent.readPreference);
- if (readPreference) {
- result.readPreference = readPreference;
- }
- return result;
- }
- exports2.resolveOptions = resolveOptions;
- function isSuperset(set, subset) {
- set = Array.isArray(set) ? new Set(set) : set;
- subset = Array.isArray(subset) ? new Set(subset) : subset;
- for (const elem of subset) {
- if (!set.has(elem)) {
- return false;
- }
- }
- return true;
- }
- exports2.isSuperset = isSuperset;
- function isHello(doc) {
- return doc[constants_2.LEGACY_HELLO_COMMAND] || doc.hello ? true : false;
- }
- exports2.isHello = isHello;
- function setDifference(setA, setB) {
- const difference = new Set(setA);
- for (const elem of setB) {
- difference.delete(elem);
- }
- return difference;
- }
- exports2.setDifference = setDifference;
- var HAS_OWN = (object, prop) => Object.prototype.hasOwnProperty.call(object, prop);
- function isRecord(value, requiredKeys = void 0) {
- if (!isObject(value)) {
- return false;
- }
- const ctor = value.constructor;
- if (ctor && ctor.prototype) {
- if (!isObject(ctor.prototype)) {
- return false;
- }
- if (!HAS_OWN(ctor.prototype, "isPrototypeOf")) {
- return false;
- }
- }
- if (requiredKeys) {
- const keys = Object.keys(value);
- return isSuperset(keys, requiredKeys);
- }
- return true;
- }
- exports2.isRecord = isRecord;
- function deepCopy(value) {
- if (value == null) {
- return value;
- } else if (Array.isArray(value)) {
- return value.map((item) => deepCopy(item));
- } else if (isRecord(value)) {
- const res = {};
- for (const key in value) {
- res[key] = deepCopy(value[key]);
- }
- return res;
- }
- const ctor = value.constructor;
- if (ctor) {
- switch (ctor.name.toLowerCase()) {
- case "date":
- return new ctor(Number(value));
- case "map":
- return new Map(value);
- case "set":
- return new Set(value);
- case "buffer":
- return Buffer.from(value);
- }
- }
- return value;
- }
- exports2.deepCopy = deepCopy;
- var List = class {
- get length() {
- return this.count;
- }
- get [Symbol.toStringTag]() {
- return "List";
- }
- constructor() {
- this.count = 0;
- this.head = {
- next: null,
- prev: null,
- value: null
- };
- this.head.next = this.head;
- this.head.prev = this.head;
- }
- toArray() {
- return Array.from(this);
- }
- toString() {
- return `head <=> ${this.toArray().join(" <=> ")} <=> head`;
- }
- *[Symbol.iterator]() {
- for (const node of this.nodes()) {
- yield node.value;
- }
- }
- *nodes() {
- let ptr = this.head.next;
- while (ptr !== this.head) {
- const { next } = ptr;
- yield ptr;
- ptr = next;
- }
- }
- /** Insert at end of list */
- push(value) {
- this.count += 1;
- const newNode = {
- next: this.head,
- prev: this.head.prev,
- value
- };
- this.head.prev.next = newNode;
- this.head.prev = newNode;
- }
- /** Inserts every item inside an iterable instead of the iterable itself */
- pushMany(iterable) {
- for (const value of iterable) {
- this.push(value);
- }
- }
- /** Insert at front of list */
- unshift(value) {
- this.count += 1;
- const newNode = {
- next: this.head.next,
- prev: this.head,
- value
- };
- this.head.next.prev = newNode;
- this.head.next = newNode;
- }
- remove(node) {
- if (node === this.head || this.length === 0) {
- return null;
- }
- this.count -= 1;
- const prevNode = node.prev;
- const nextNode = node.next;
- prevNode.next = nextNode;
- nextNode.prev = prevNode;
- return node.value;
- }
- /** Removes the first node at the front of the list */
- shift() {
- return this.remove(this.head.next);
- }
- /** Removes the last node at the end of the list */
- pop() {
- return this.remove(this.head.prev);
- }
- /** Iterates through the list and removes nodes where filter returns true */
- prune(filter) {
- for (const node of this.nodes()) {
- if (filter(node.value)) {
- this.remove(node);
- }
- }
- }
- clear() {
- this.count = 0;
- this.head.next = this.head;
- this.head.prev = this.head;
- }
- /** Returns the first item in the list, does not remove */
- first() {
- return this.head.next.value;
- }
- /** Returns the last item in the list, does not remove */
- last() {
- return this.head.prev.value;
- }
- };
- exports2.List = List;
- var BufferPool = class {
- constructor() {
- this.buffers = new List();
- this.totalByteLength = 0;
- }
- get length() {
- return this.totalByteLength;
- }
- /** Adds a buffer to the internal buffer pool list */
- append(buffer) {
- this.buffers.push(buffer);
- this.totalByteLength += buffer.length;
- }
- /**
- * If BufferPool contains 4 bytes or more construct an int32 from the leading bytes,
- * otherwise return null. Size can be negative, caller should error check.
- */
- getInt32() {
- if (this.totalByteLength < 4) {
- return null;
- }
- const firstBuffer = this.buffers.first();
- if (firstBuffer != null && firstBuffer.byteLength >= 4) {
- return firstBuffer.readInt32LE(0);
- }
- const top4Bytes = this.read(4);
- const value = top4Bytes.readInt32LE(0);
- this.totalByteLength += 4;
- this.buffers.unshift(top4Bytes);
- return value;
- }
- /** Reads the requested number of bytes, optionally consuming them */
- read(size) {
- if (typeof size !== "number" || size < 0) {
- throw new error_1.MongoInvalidArgumentError('Argument "size" must be a non-negative number');
- }
- if (size > this.totalByteLength) {
- return Buffer.alloc(0);
- }
- const result = Buffer.allocUnsafe(size);
- for (let bytesRead = 0; bytesRead < size; ) {
- const buffer = this.buffers.shift();
- if (buffer == null) {
- break;
- }
- const bytesRemaining = size - bytesRead;
- const bytesReadable = Math.min(bytesRemaining, buffer.byteLength);
- const bytes = buffer.subarray(0, bytesReadable);
- result.set(bytes, bytesRead);
- bytesRead += bytesReadable;
- this.totalByteLength -= bytesReadable;
- if (bytesReadable < buffer.byteLength) {
- this.buffers.unshift(buffer.subarray(bytesReadable));
- }
- }
- return result;
- }
- };
- exports2.BufferPool = BufferPool;
- var HostAddress = class _HostAddress {
- constructor(hostString) {
- this.host = void 0;
- this.port = void 0;
- this.socketPath = void 0;
- this.isIPv6 = false;
- const escapedHost = hostString.split(" ").join("%20");
- if (escapedHost.endsWith(".sock")) {
- this.socketPath = decodeURIComponent(escapedHost);
- return;
- }
- const urlString = `iLoveJS://${escapedHost}`;
- let url2;
- try {
- url2 = new url_1.URL(urlString);
- } catch (urlError) {
- const runtimeError = new error_1.MongoRuntimeError(`Unable to parse ${escapedHost} with URL`);
- runtimeError.cause = urlError;
- throw runtimeError;
- }
- const hostname = url2.hostname;
- const port = url2.port;
- let normalized = decodeURIComponent(hostname).toLowerCase();
- if (normalized.startsWith("[") && normalized.endsWith("]")) {
- this.isIPv6 = true;
- normalized = normalized.substring(1, hostname.length - 1);
- }
- this.host = normalized.toLowerCase();
- if (typeof port === "number") {
- this.port = port;
- } else if (typeof port === "string" && port !== "") {
- this.port = Number.parseInt(port, 10);
- } else {
- this.port = 27017;
- }
- if (this.port === 0) {
- throw new error_1.MongoParseError("Invalid port (zero) with hostname");
- }
- Object.freeze(this);
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- return this.inspect();
- }
- inspect() {
- return `new HostAddress('${this.toString()}')`;
- }
- toString() {
- if (typeof this.host === "string") {
- if (this.isIPv6) {
- return `[${this.host}]:${this.port}`;
- }
- return `${this.host}:${this.port}`;
- }
- return `${this.socketPath}`;
- }
- static fromString(s) {
- return new _HostAddress(s);
- }
- static fromHostPort(host, port) {
- if (host.includes(":")) {
- host = `[${host}]`;
- }
- return _HostAddress.fromString(`${host}:${port}`);
- }
- static fromSrvRecord({ name, port }) {
- return _HostAddress.fromHostPort(name, port);
- }
- toHostPort() {
- if (this.socketPath) {
- return { host: this.socketPath, port: 0 };
- }
- const host = this.host ?? "";
- const port = this.port ?? 0;
- return { host, port };
- }
- };
- exports2.HostAddress = HostAddress;
- exports2.DEFAULT_PK_FACTORY = {
- // We prefer not to rely on ObjectId having a createPk method
- createPk() {
- return new bson_1.ObjectId();
- }
- };
- exports2.MONGODB_WARNING_CODE = "MONGODB DRIVER";
- function emitWarning(message) {
- return process.emitWarning(message, { code: exports2.MONGODB_WARNING_CODE });
- }
- exports2.emitWarning = emitWarning;
- var emittedWarnings = /* @__PURE__ */ new Set();
- function emitWarningOnce(message) {
- if (!emittedWarnings.has(message)) {
- emittedWarnings.add(message);
- return emitWarning(message);
- }
- }
- exports2.emitWarningOnce = emitWarningOnce;
- function enumToString(en) {
- return Object.values(en).join(", ");
- }
- exports2.enumToString = enumToString;
- function supportsRetryableWrites(server) {
- if (!server) {
- return false;
- }
- if (server.loadBalanced) {
- return true;
- }
- if (server.description.logicalSessionTimeoutMinutes != null) {
- if (server.description.type !== common_1.ServerType.Standalone) {
- return true;
- }
- }
- return false;
- }
- exports2.supportsRetryableWrites = supportsRetryableWrites;
- function shuffle(sequence, limit = 0) {
- const items = Array.from(sequence);
- if (limit > items.length) {
- throw new error_1.MongoRuntimeError("Limit must be less than the number of items");
- }
- let remainingItemsToShuffle = items.length;
- const lowerBound = limit % items.length === 0 ? 1 : items.length - limit;
- while (remainingItemsToShuffle > lowerBound) {
- const randomIndex = Math.floor(Math.random() * remainingItemsToShuffle);
- remainingItemsToShuffle -= 1;
- const swapHold = items[remainingItemsToShuffle];
- items[remainingItemsToShuffle] = items[randomIndex];
- items[randomIndex] = swapHold;
- }
- return limit % items.length === 0 ? items : items.slice(lowerBound);
- }
- exports2.shuffle = shuffle;
- function commandSupportsReadConcern(command, options) {
- if (command.aggregate || command.count || command.distinct || command.find || command.geoNear) {
- return true;
- }
- if (command.mapReduce && options && options.out && (options.out.inline === 1 || options.out === "inline")) {
- return true;
- }
- return false;
- }
- exports2.commandSupportsReadConcern = commandSupportsReadConcern;
- function getMongoDBClientEncryption() {
- let mongodbClientEncryption = null;
- if (typeof process.env.MONGODB_CLIENT_ENCRYPTION_OVERRIDE === "string" && process.env.MONGODB_CLIENT_ENCRYPTION_OVERRIDE.length > 0) {
- try {
- mongodbClientEncryption = require(process.env.MONGODB_CLIENT_ENCRYPTION_OVERRIDE);
- } catch {
- }
- } else {
- try {
- mongodbClientEncryption = require("mongodb-client-encryption");
- } catch {
- }
- }
- return mongodbClientEncryption;
- }
- exports2.getMongoDBClientEncryption = getMongoDBClientEncryption;
- function compareObjectId(oid1, oid2) {
- if (oid1 == null && oid2 == null) {
- return 0;
- }
- if (oid1 == null) {
- return -1;
- }
- if (oid2 == null) {
- return 1;
- }
- return exports2.ByteUtils.compare(oid1.id, oid2.id);
- }
- exports2.compareObjectId = compareObjectId;
- function parseInteger(value) {
- if (typeof value === "number")
- return Math.trunc(value);
- const parsedValue = Number.parseInt(String(value), 10);
- return Number.isNaN(parsedValue) ? null : parsedValue;
- }
- exports2.parseInteger = parseInteger;
- function parseUnsignedInteger(value) {
- const parsedInt = parseInteger(value);
- return parsedInt != null && parsedInt >= 0 ? parsedInt : null;
- }
- exports2.parseUnsignedInteger = parseUnsignedInteger;
- function matchesParentDomain(address, srvHost) {
- const normalizedAddress = address.endsWith(".") ? address.slice(0, address.length - 1) : address;
- const normalizedSrvHost = srvHost.endsWith(".") ? srvHost.slice(0, srvHost.length - 1) : srvHost;
- const allCharacterBeforeFirstDot = /^.*?\./;
- const addressDomain = `.${normalizedAddress.replace(allCharacterBeforeFirstDot, "")}`;
- const srvHostDomain = `.${normalizedSrvHost.replace(allCharacterBeforeFirstDot, "")}`;
- return addressDomain.endsWith(srvHostDomain);
- }
- exports2.matchesParentDomain = matchesParentDomain;
- async function request(uri, options = {}) {
- return new Promise((resolve, reject) => {
- const requestOptions = {
- method: "GET",
- timeout: 1e4,
- json: true,
- ...url.parse(uri),
- ...options
- };
- const req = http.request(requestOptions, (res) => {
- res.setEncoding("utf8");
- let data = "";
- res.on("data", (d) => {
- data += d;
- });
- res.once("end", () => {
- if (options.json === false) {
- resolve(data);
- return;
- }
- try {
- const parsed = JSON.parse(data);
- resolve(parsed);
- } catch {
- reject(new error_1.MongoRuntimeError(`Invalid JSON response: "${data}"`));
- }
- });
- });
- req.once("timeout", () => req.destroy(new error_1.MongoNetworkTimeoutError(`Network request to ${uri} timed out after ${options.timeout} ms`)));
- req.once("error", (error) => reject(error));
- req.end();
- });
- }
- exports2.request = request;
- }
- });
- // node_modules/mongodb/lib/explain.js
- var require_explain = __commonJS({
- "node_modules/mongodb/lib/explain.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.Explain = exports2.ExplainVerbosity = void 0;
- var error_1 = require_error();
- exports2.ExplainVerbosity = Object.freeze({
- queryPlanner: "queryPlanner",
- queryPlannerExtended: "queryPlannerExtended",
- executionStats: "executionStats",
- allPlansExecution: "allPlansExecution"
- });
- var Explain = class _Explain {
- constructor(verbosity) {
- if (typeof verbosity === "boolean") {
- this.verbosity = verbosity ? exports2.ExplainVerbosity.allPlansExecution : exports2.ExplainVerbosity.queryPlanner;
- } else {
- this.verbosity = verbosity;
- }
- }
- static fromOptions(options) {
- if ((options == null ? void 0 : options.explain) == null)
- return;
- const explain = options.explain;
- if (typeof explain === "boolean" || typeof explain === "string") {
- return new _Explain(explain);
- }
- throw new error_1.MongoInvalidArgumentError('Field "explain" must be a string or a boolean');
- }
- };
- exports2.Explain = Explain;
- }
- });
- // node_modules/mongodb/lib/sdam/server_selection.js
- var require_server_selection = __commonJS({
- "node_modules/mongodb/lib/sdam/server_selection.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.readPreferenceServerSelector = exports2.secondaryWritableServerSelector = exports2.sameServerSelector = exports2.writableServerSelector = exports2.MIN_SECONDARY_WRITE_WIRE_VERSION = void 0;
- var error_1 = require_error();
- var read_preference_1 = require_read_preference();
- var common_1 = require_common();
- var IDLE_WRITE_PERIOD = 1e4;
- var SMALLEST_MAX_STALENESS_SECONDS = 90;
- exports2.MIN_SECONDARY_WRITE_WIRE_VERSION = 13;
- function writableServerSelector() {
- return (topologyDescription, servers) => latencyWindowReducer(topologyDescription, servers.filter((s) => s.isWritable));
- }
- exports2.writableServerSelector = writableServerSelector;
- function sameServerSelector(description) {
- return (topologyDescription, servers) => {
- if (!description)
- return [];
- return servers.filter((sd) => {
- return sd.address === description.address && sd.type !== common_1.ServerType.Unknown;
- });
- };
- }
- exports2.sameServerSelector = sameServerSelector;
- function secondaryWritableServerSelector(wireVersion, readPreference) {
- if (!readPreference || !wireVersion || wireVersion && wireVersion < exports2.MIN_SECONDARY_WRITE_WIRE_VERSION) {
- return readPreferenceServerSelector(read_preference_1.ReadPreference.primary);
- }
- return readPreferenceServerSelector(readPreference);
- }
- exports2.secondaryWritableServerSelector = secondaryWritableServerSelector;
- function maxStalenessReducer(readPreference, topologyDescription, servers) {
- if (readPreference.maxStalenessSeconds == null || readPreference.maxStalenessSeconds < 0) {
- return servers;
- }
- const maxStaleness = readPreference.maxStalenessSeconds;
- const maxStalenessVariance = (topologyDescription.heartbeatFrequencyMS + IDLE_WRITE_PERIOD) / 1e3;
- if (maxStaleness < maxStalenessVariance) {
- throw new error_1.MongoInvalidArgumentError(`Option "maxStalenessSeconds" must be at least ${maxStalenessVariance} seconds`);
- }
- if (maxStaleness < SMALLEST_MAX_STALENESS_SECONDS) {
- throw new error_1.MongoInvalidArgumentError(`Option "maxStalenessSeconds" must be at least ${SMALLEST_MAX_STALENESS_SECONDS} seconds`);
- }
- if (topologyDescription.type === common_1.TopologyType.ReplicaSetWithPrimary) {
- const primary = Array.from(topologyDescription.servers.values()).filter(primaryFilter)[0];
- return servers.reduce((result, server) => {
- const stalenessMS = server.lastUpdateTime - server.lastWriteDate - (primary.lastUpdateTime - primary.lastWriteDate) + topologyDescription.heartbeatFrequencyMS;
- const staleness = stalenessMS / 1e3;
- const maxStalenessSeconds = readPreference.maxStalenessSeconds ?? 0;
- if (staleness <= maxStalenessSeconds) {
- result.push(server);
- }
- return result;
- }, []);
- }
- if (topologyDescription.type === common_1.TopologyType.ReplicaSetNoPrimary) {
- if (servers.length === 0) {
- return servers;
- }
- const sMax = servers.reduce((max, s) => s.lastWriteDate > max.lastWriteDate ? s : max);
- return servers.reduce((result, server) => {
- const stalenessMS = sMax.lastWriteDate - server.lastWriteDate + topologyDescription.heartbeatFrequencyMS;
- const staleness = stalenessMS / 1e3;
- const maxStalenessSeconds = readPreference.maxStalenessSeconds ?? 0;
- if (staleness <= maxStalenessSeconds) {
- result.push(server);
- }
- return result;
- }, []);
- }
- return servers;
- }
- function tagSetMatch(tagSet, serverTags) {
- const keys = Object.keys(tagSet);
- const serverTagKeys = Object.keys(serverTags);
- for (let i = 0; i < keys.length; ++i) {
- const key = keys[i];
- if (serverTagKeys.indexOf(key) === -1 || serverTags[key] !== tagSet[key]) {
- return false;
- }
- }
- return true;
- }
- function tagSetReducer(readPreference, servers) {
- if (readPreference.tags == null || Array.isArray(readPreference.tags) && readPreference.tags.length === 0) {
- return servers;
- }
- for (let i = 0; i < readPreference.tags.length; ++i) {
- const tagSet = readPreference.tags[i];
- const serversMatchingTagset = servers.reduce((matched, server) => {
- if (tagSetMatch(tagSet, server.tags))
- matched.push(server);
- return matched;
- }, []);
- if (serversMatchingTagset.length) {
- return serversMatchingTagset;
- }
- }
- return [];
- }
- function latencyWindowReducer(topologyDescription, servers) {
- const low = servers.reduce((min, server) => min === -1 ? server.roundTripTime : Math.min(server.roundTripTime, min), -1);
- const high = low + topologyDescription.localThresholdMS;
- return servers.reduce((result, server) => {
- if (server.roundTripTime <= high && server.roundTripTime >= low)
- result.push(server);
- return result;
- }, []);
- }
- function primaryFilter(server) {
- return server.type === common_1.ServerType.RSPrimary;
- }
- function secondaryFilter(server) {
- return server.type === common_1.ServerType.RSSecondary;
- }
- function nearestFilter(server) {
- return server.type === common_1.ServerType.RSSecondary || server.type === common_1.ServerType.RSPrimary;
- }
- function knownFilter(server) {
- return server.type !== common_1.ServerType.Unknown;
- }
- function loadBalancerFilter(server) {
- return server.type === common_1.ServerType.LoadBalancer;
- }
- function readPreferenceServerSelector(readPreference) {
- if (!readPreference.isValid()) {
- throw new error_1.MongoInvalidArgumentError("Invalid read preference specified");
- }
- return (topologyDescription, servers) => {
- const commonWireVersion = topologyDescription.commonWireVersion;
- if (commonWireVersion && readPreference.minWireVersion && readPreference.minWireVersion > commonWireVersion) {
- throw new error_1.MongoCompatibilityError(`Minimum wire version '${readPreference.minWireVersion}' required, but found '${commonWireVersion}'`);
- }
- if (topologyDescription.type === common_1.TopologyType.LoadBalanced) {
- return servers.filter(loadBalancerFilter);
- }
- if (topologyDescription.type === common_1.TopologyType.Unknown) {
- return [];
- }
- if (topologyDescription.type === common_1.TopologyType.Single || topologyDescription.type === common_1.TopologyType.Sharded) {
- return latencyWindowReducer(topologyDescription, servers.filter(knownFilter));
- }
- const mode = readPreference.mode;
- if (mode === read_preference_1.ReadPreference.PRIMARY) {
- return servers.filter(primaryFilter);
- }
- if (mode === read_preference_1.ReadPreference.PRIMARY_PREFERRED) {
- const result = servers.filter(primaryFilter);
- if (result.length) {
- return result;
- }
- }
- const filter = mode === read_preference_1.ReadPreference.NEAREST ? nearestFilter : secondaryFilter;
- const selectedServers = latencyWindowReducer(topologyDescription, tagSetReducer(readPreference, maxStalenessReducer(readPreference, topologyDescription, servers.filter(filter))));
- if (mode === read_preference_1.ReadPreference.SECONDARY_PREFERRED && selectedServers.length === 0) {
- return servers.filter(primaryFilter);
- }
- return selectedServers;
- };
- }
- exports2.readPreferenceServerSelector = readPreferenceServerSelector;
- }
- });
- // node_modules/mongodb/lib/operations/operation.js
- var require_operation = __commonJS({
- "node_modules/mongodb/lib/operations/operation.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.defineAspects = exports2.AbstractCallbackOperation = exports2.AbstractOperation = exports2.Aspect = void 0;
- var util_1 = require("util");
- var bson_1 = require_bson2();
- var read_preference_1 = require_read_preference();
- exports2.Aspect = {
- READ_OPERATION: Symbol("READ_OPERATION"),
- WRITE_OPERATION: Symbol("WRITE_OPERATION"),
- RETRYABLE: Symbol("RETRYABLE"),
- EXPLAINABLE: Symbol("EXPLAINABLE"),
- SKIP_COLLATION: Symbol("SKIP_COLLATION"),
- CURSOR_CREATING: Symbol("CURSOR_CREATING"),
- MUST_SELECT_SAME_SERVER: Symbol("MUST_SELECT_SAME_SERVER")
- };
- var kSession = Symbol("session");
- var AbstractOperation = class {
- constructor(options = {}) {
- this.readPreference = this.hasAspect(exports2.Aspect.WRITE_OPERATION) ? read_preference_1.ReadPreference.primary : read_preference_1.ReadPreference.fromOptions(options) ?? read_preference_1.ReadPreference.primary;
- this.bsonOptions = (0, bson_1.resolveBSONOptions)(options);
- this[kSession] = options.session != null ? options.session : void 0;
- this.options = options;
- this.bypassPinningCheck = !!options.bypassPinningCheck;
- this.trySecondaryWrite = false;
- }
- hasAspect(aspect) {
- const ctor = this.constructor;
- if (ctor.aspects == null) {
- return false;
- }
- return ctor.aspects.has(aspect);
- }
- get session() {
- return this[kSession];
- }
- clearSession() {
- this[kSession] = void 0;
- }
- get canRetryRead() {
- return true;
- }
- get canRetryWrite() {
- return true;
- }
- };
- exports2.AbstractOperation = AbstractOperation;
- var AbstractCallbackOperation = class extends AbstractOperation {
- constructor(options = {}) {
- super(options);
- }
- execute(server, session) {
- return (0, util_1.promisify)((callback) => {
- this.executeCallback(server, session, callback);
- })();
- }
- };
- exports2.AbstractCallbackOperation = AbstractCallbackOperation;
- function defineAspects(operation, aspects) {
- if (!Array.isArray(aspects) && !(aspects instanceof Set)) {
- aspects = [aspects];
- }
- aspects = new Set(aspects);
- Object.defineProperty(operation, "aspects", {
- value: aspects,
- writable: false
- });
- return aspects;
- }
- exports2.defineAspects = defineAspects;
- }
- });
- // node_modules/mongodb/lib/operations/command.js
- var require_command = __commonJS({
- "node_modules/mongodb/lib/operations/command.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.CommandCallbackOperation = exports2.CommandOperation = void 0;
- var error_1 = require_error();
- var explain_1 = require_explain();
- var read_concern_1 = require_read_concern();
- var server_selection_1 = require_server_selection();
- var utils_1 = require_utils();
- var write_concern_1 = require_write_concern();
- var operation_1 = require_operation();
- var CommandOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(parent, options) {
- super(options);
- this.options = options ?? {};
- const dbNameOverride = (options == null ? void 0 : options.dbName) || (options == null ? void 0 : options.authdb);
- if (dbNameOverride) {
- this.ns = new utils_1.MongoDBNamespace(dbNameOverride, "$cmd");
- } else {
- this.ns = parent ? parent.s.namespace.withCollection("$cmd") : new utils_1.MongoDBNamespace("admin", "$cmd");
- }
- this.readConcern = read_concern_1.ReadConcern.fromOptions(options);
- this.writeConcern = write_concern_1.WriteConcern.fromOptions(options);
- if (this.hasAspect(operation_1.Aspect.EXPLAINABLE)) {
- this.explain = explain_1.Explain.fromOptions(options);
- } else if ((options == null ? void 0 : options.explain) != null) {
- throw new error_1.MongoInvalidArgumentError(`Option "explain" is not supported on this command`);
- }
- }
- get canRetryWrite() {
- if (this.hasAspect(operation_1.Aspect.EXPLAINABLE)) {
- return this.explain == null;
- }
- return true;
- }
- async executeCommand(server, session, cmd) {
- this.server = server;
- const options = {
- ...this.options,
- ...this.bsonOptions,
- readPreference: this.readPreference,
- session
- };
- const serverWireVersion = (0, utils_1.maxWireVersion)(server);
- const inTransaction = this.session && this.session.inTransaction();
- if (this.readConcern && (0, utils_1.commandSupportsReadConcern)(cmd) && !inTransaction) {
- Object.assign(cmd, { readConcern: this.readConcern });
- }
- if (this.trySecondaryWrite && serverWireVersion < server_selection_1.MIN_SECONDARY_WRITE_WIRE_VERSION) {
- options.omitReadPreference = true;
- }
- if (this.writeConcern && this.hasAspect(operation_1.Aspect.WRITE_OPERATION) && !inTransaction) {
- write_concern_1.WriteConcern.apply(cmd, this.writeConcern);
- }
- if (options.collation && typeof options.collation === "object" && !this.hasAspect(operation_1.Aspect.SKIP_COLLATION)) {
- Object.assign(cmd, { collation: options.collation });
- }
- if (typeof options.maxTimeMS === "number") {
- cmd.maxTimeMS = options.maxTimeMS;
- }
- if (this.hasAspect(operation_1.Aspect.EXPLAINABLE) && this.explain) {
- cmd = (0, utils_1.decorateWithExplain)(cmd, this.explain);
- }
- return server.commandAsync(this.ns, cmd, options);
- }
- };
- exports2.CommandOperation = CommandOperation;
- var CommandCallbackOperation = class extends CommandOperation {
- constructor(parent, options) {
- super(parent, options);
- }
- executeCommandCallback(server, session, cmd, callback) {
- super.executeCommand(server, session, cmd).then((res) => callback(void 0, res), (err) => callback(err, void 0));
- }
- };
- exports2.CommandCallbackOperation = CommandCallbackOperation;
- }
- });
- // node_modules/mongodb/lib/operations/add_user.js
- var require_add_user = __commonJS({
- "node_modules/mongodb/lib/operations/add_user.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AddUserOperation = void 0;
- var crypto = require("crypto");
- var error_1 = require_error();
- var utils_1 = require_utils();
- var command_1 = require_command();
- var operation_1 = require_operation();
- var AddUserOperation = class extends command_1.CommandCallbackOperation {
- constructor(db, username, password, options) {
- super(db, options);
- this.db = db;
- this.username = username;
- this.password = password;
- this.options = options ?? {};
- }
- executeCallback(server, session, callback) {
- const db = this.db;
- const username = this.username;
- const password = this.password;
- const options = this.options;
- if ("digestPassword" in options && options.digestPassword != null) {
- return callback(new error_1.MongoInvalidArgumentError('Option "digestPassword" not supported via addUser, use db.command(...) instead'));
- }
- let roles;
- if (!options.roles || Array.isArray(options.roles) && options.roles.length === 0) {
- (0, utils_1.emitWarningOnce)('Creating a user without roles is deprecated. Defaults to "root" if db is "admin" or "dbOwner" otherwise');
- if (db.databaseName.toLowerCase() === "admin") {
- roles = ["root"];
- } else {
- roles = ["dbOwner"];
- }
- } else {
- roles = Array.isArray(options.roles) ? options.roles : [options.roles];
- }
- let topology;
- try {
- topology = (0, utils_1.getTopology)(db);
- } catch (error) {
- return callback(error);
- }
- const digestPassword = topology.lastHello().maxWireVersion >= 7;
- let userPassword = password;
- if (!digestPassword) {
- const md5 = crypto.createHash("md5");
- md5.update(`${username}:mongo:${password}`);
- userPassword = md5.digest("hex");
- }
- const command = {
- createUser: username,
- customData: options.customData || {},
- roles,
- digestPassword
- };
- if (typeof password === "string") {
- command.pwd = userPassword;
- }
- super.executeCommandCallback(server, session, command, callback);
- }
- };
- exports2.AddUserOperation = AddUserOperation;
- (0, operation_1.defineAspects)(AddUserOperation, [operation_1.Aspect.WRITE_OPERATION]);
- }
- });
- // node_modules/mongodb/lib/operations/execute_operation.js
- var require_execute_operation = __commonJS({
- "node_modules/mongodb/lib/operations/execute_operation.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.executeOperation = void 0;
- var error_1 = require_error();
- var read_preference_1 = require_read_preference();
- var server_selection_1 = require_server_selection();
- var utils_1 = require_utils();
- var operation_1 = require_operation();
- var MMAPv1_RETRY_WRITES_ERROR_CODE = error_1.MONGODB_ERROR_CODES.IllegalOperation;
- var MMAPv1_RETRY_WRITES_ERROR_MESSAGE = "This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.";
- function executeOperation(client, operation, callback) {
- return (0, utils_1.maybeCallback)(() => executeOperationAsync(client, operation), callback);
- }
- exports2.executeOperation = executeOperation;
- async function executeOperationAsync(client, operation) {
- var _a;
- if (!(operation instanceof operation_1.AbstractCallbackOperation)) {
- throw new error_1.MongoRuntimeError("This method requires a valid operation instance");
- }
- if (client.topology == null) {
- if (client.s.hasBeenClosed) {
- throw new error_1.MongoNotConnectedError("Client must be connected before running operations");
- }
- client.s.options[Symbol.for("@@mdb.skipPingOnConnect")] = true;
- try {
- await client.connect();
- } finally {
- delete client.s.options[Symbol.for("@@mdb.skipPingOnConnect")];
- }
- }
- const { topology } = client;
- if (topology == null) {
- throw new error_1.MongoRuntimeError("client.connect did not create a topology but also did not throw");
- }
- let session = operation.session;
- let owner;
- if (session == null) {
- owner = Symbol();
- session = client.startSession({ owner, explicit: false });
- } else if (session.hasEnded) {
- throw new error_1.MongoExpiredSessionError("Use of expired sessions is not permitted");
- } else if (session.snapshotEnabled && !topology.capabilities.supportsSnapshotReads) {
- throw new error_1.MongoCompatibilityError("Snapshot reads require MongoDB 5.0 or later");
- }
- const readPreference = operation.readPreference ?? read_preference_1.ReadPreference.primary;
- const inTransaction = !!(session == null ? void 0 : session.inTransaction());
- if (inTransaction && !readPreference.equals(read_preference_1.ReadPreference.primary)) {
- throw new error_1.MongoTransactionError(`Read preference in a transaction must be primary, not: ${readPreference.mode}`);
- }
- if ((session == null ? void 0 : session.isPinned) && session.transaction.isCommitted && !operation.bypassPinningCheck) {
- session.unpin();
- }
- let selector;
- if (operation.hasAspect(operation_1.Aspect.MUST_SELECT_SAME_SERVER)) {
- selector = (0, server_selection_1.sameServerSelector)((_a = operation.server) == null ? void 0 : _a.description);
- } else if (operation.trySecondaryWrite) {
- selector = (0, server_selection_1.secondaryWritableServerSelector)(topology.commonWireVersion, readPreference);
- } else {
- selector = readPreference;
- }
- const server = await topology.selectServerAsync(selector, { session });
- if (session == null) {
- return operation.execute(server, void 0);
- }
- if (!operation.hasAspect(operation_1.Aspect.RETRYABLE)) {
- try {
- return await operation.execute(server, session);
- } finally {
- if ((session == null ? void 0 : session.owner) != null && session.owner === owner) {
- await session.endSession().catch(() => null);
- }
- }
- }
- const willRetryRead = topology.s.options.retryReads && !inTransaction && operation.canRetryRead;
- const willRetryWrite = topology.s.options.retryWrites && !inTransaction && (0, utils_1.supportsRetryableWrites)(server) && operation.canRetryWrite;
- const hasReadAspect = operation.hasAspect(operation_1.Aspect.READ_OPERATION);
- const hasWriteAspect = operation.hasAspect(operation_1.Aspect.WRITE_OPERATION);
- const willRetry = hasReadAspect && willRetryRead || hasWriteAspect && willRetryWrite;
- if (hasWriteAspect && willRetryWrite) {
- operation.options.willRetryWrite = true;
- session.incrementTransactionNumber();
- }
- try {
- return await operation.execute(server, session);
- } catch (operationError) {
- if (willRetry && operationError instanceof error_1.MongoError) {
- return await retryOperation(operation, operationError, {
- session,
- topology,
- selector
- });
- }
- throw operationError;
- } finally {
- if ((session == null ? void 0 : session.owner) != null && session.owner === owner) {
- await session.endSession().catch(() => null);
- }
- }
- }
- async function retryOperation(operation, originalError, { session, topology, selector }) {
- const isWriteOperation = operation.hasAspect(operation_1.Aspect.WRITE_OPERATION);
- const isReadOperation = operation.hasAspect(operation_1.Aspect.READ_OPERATION);
- if (isWriteOperation && originalError.code === MMAPv1_RETRY_WRITES_ERROR_CODE) {
- throw new error_1.MongoServerError({
- message: MMAPv1_RETRY_WRITES_ERROR_MESSAGE,
- errmsg: MMAPv1_RETRY_WRITES_ERROR_MESSAGE,
- originalError
- });
- }
- if (isWriteOperation && !(0, error_1.isRetryableWriteError)(originalError)) {
- throw originalError;
- }
- if (isReadOperation && !(0, error_1.isRetryableReadError)(originalError)) {
- throw originalError;
- }
- if (originalError instanceof error_1.MongoNetworkError && session.isPinned && !session.inTransaction() && operation.hasAspect(operation_1.Aspect.CURSOR_CREATING)) {
- session.unpin({ force: true, forceClear: true });
- }
- const server = await topology.selectServerAsync(selector, { session });
- if (isWriteOperation && !(0, utils_1.supportsRetryableWrites)(server)) {
- throw new error_1.MongoUnexpectedServerResponseError("Selected server does not support retryable writes");
- }
- try {
- return await operation.execute(server, session);
- } catch (retryError) {
- if (retryError instanceof error_1.MongoError && retryError.hasErrorLabel(error_1.MongoErrorLabel.NoWritesPerformed)) {
- throw originalError;
- }
- throw retryError;
- }
- }
- }
- });
- // node_modules/mongodb/lib/operations/list_databases.js
- var require_list_databases = __commonJS({
- "node_modules/mongodb/lib/operations/list_databases.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ListDatabasesOperation = void 0;
- var utils_1 = require_utils();
- var command_1 = require_command();
- var operation_1 = require_operation();
- var ListDatabasesOperation = class extends command_1.CommandCallbackOperation {
- constructor(db, options) {
- super(db, options);
- this.options = options ?? {};
- this.ns = new utils_1.MongoDBNamespace("admin", "$cmd");
- }
- executeCallback(server, session, callback) {
- const cmd = { listDatabases: 1 };
- if (typeof this.options.nameOnly === "boolean") {
- cmd.nameOnly = this.options.nameOnly;
- }
- if (this.options.filter) {
- cmd.filter = this.options.filter;
- }
- if (typeof this.options.authorizedDatabases === "boolean") {
- cmd.authorizedDatabases = this.options.authorizedDatabases;
- }
- if ((0, utils_1.maxWireVersion)(server) >= 9 && this.options.comment !== void 0) {
- cmd.comment = this.options.comment;
- }
- super.executeCommandCallback(server, session, cmd, callback);
- }
- };
- exports2.ListDatabasesOperation = ListDatabasesOperation;
- (0, operation_1.defineAspects)(ListDatabasesOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE]);
- }
- });
- // node_modules/mongodb/lib/operations/remove_user.js
- var require_remove_user = __commonJS({
- "node_modules/mongodb/lib/operations/remove_user.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.RemoveUserOperation = void 0;
- var command_1 = require_command();
- var operation_1 = require_operation();
- var RemoveUserOperation = class extends command_1.CommandCallbackOperation {
- constructor(db, username, options) {
- super(db, options);
- this.options = options;
- this.username = username;
- }
- executeCallback(server, session, callback) {
- super.executeCommandCallback(server, session, { dropUser: this.username }, (err) => {
- callback(err, err ? false : true);
- });
- }
- };
- exports2.RemoveUserOperation = RemoveUserOperation;
- (0, operation_1.defineAspects)(RemoveUserOperation, [operation_1.Aspect.WRITE_OPERATION]);
- }
- });
- // node_modules/mongodb/lib/operations/run_command.js
- var require_run_command = __commonJS({
- "node_modules/mongodb/lib/operations/run_command.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.RunAdminCommandOperation = exports2.RunCommandOperation = void 0;
- var utils_1 = require_utils();
- var command_1 = require_command();
- var RunCommandOperation = class extends command_1.CommandCallbackOperation {
- constructor(parent, command, options) {
- super(parent, options);
- this.options = options ?? {};
- this.command = command;
- }
- executeCallback(server, session, callback) {
- const command = this.command;
- this.executeCommandCallback(server, session, command, callback);
- }
- };
- exports2.RunCommandOperation = RunCommandOperation;
- var RunAdminCommandOperation = class extends RunCommandOperation {
- constructor(parent, command, options) {
- super(parent, command, options);
- this.ns = new utils_1.MongoDBNamespace("admin");
- }
- };
- exports2.RunAdminCommandOperation = RunAdminCommandOperation;
- }
- });
- // node_modules/mongodb/lib/operations/validate_collection.js
- var require_validate_collection = __commonJS({
- "node_modules/mongodb/lib/operations/validate_collection.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ValidateCollectionOperation = void 0;
- var error_1 = require_error();
- var command_1 = require_command();
- var ValidateCollectionOperation = class extends command_1.CommandCallbackOperation {
- constructor(admin, collectionName, options) {
- const command = { validate: collectionName };
- const keys = Object.keys(options);
- for (let i = 0; i < keys.length; i++) {
- if (Object.prototype.hasOwnProperty.call(options, keys[i]) && keys[i] !== "session") {
- command[keys[i]] = options[keys[i]];
- }
- }
- super(admin.s.db, options);
- this.options = options;
- this.command = command;
- this.collectionName = collectionName;
- }
- executeCallback(server, session, callback) {
- const collectionName = this.collectionName;
- super.executeCommandCallback(server, session, this.command, (err, doc) => {
- if (err != null)
- return callback(err);
- if (doc.ok === 0)
- return callback(new error_1.MongoRuntimeError("Error with validate command"));
- if (doc.result != null && typeof doc.result !== "string")
- return callback(new error_1.MongoRuntimeError("Error with validation data"));
- if (doc.result != null && doc.result.match(/exception|corrupt/) != null)
- return callback(new error_1.MongoRuntimeError(`Invalid collection ${collectionName}`));
- if (doc.valid != null && !doc.valid)
- return callback(new error_1.MongoRuntimeError(`Invalid collection ${collectionName}`));
- return callback(void 0, doc);
- });
- }
- };
- exports2.ValidateCollectionOperation = ValidateCollectionOperation;
- }
- });
- // node_modules/mongodb/lib/admin.js
- var require_admin = __commonJS({
- "node_modules/mongodb/lib/admin.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.Admin = void 0;
- var add_user_1 = require_add_user();
- var execute_operation_1 = require_execute_operation();
- var list_databases_1 = require_list_databases();
- var remove_user_1 = require_remove_user();
- var run_command_1 = require_run_command();
- var validate_collection_1 = require_validate_collection();
- var Admin = class {
- /**
- * Create a new Admin instance
- * @internal
- */
- constructor(db) {
- this.s = { db };
- }
- /**
- * Execute a command
- *
- * The driver will ensure the following fields are attached to the command sent to the server:
- * - `lsid` - sourced from an implicit session or options.session
- * - `$readPreference` - defaults to primary or can be configured by options.readPreference
- * - `$db` - sourced from the name of this database
- *
- * If the client has a serverApi setting:
- * - `apiVersion`
- * - `apiStrict`
- * - `apiDeprecationErrors`
- *
- * When in a transaction:
- * - `readConcern` - sourced from readConcern set on the TransactionOptions
- * - `writeConcern` - sourced from writeConcern set on the TransactionOptions
- *
- * Attaching any of the above fields to the command will have no effect as the driver will overwrite the value.
- *
- * @param command - The command to execute
- * @param options - Optional settings for the command
- */
- async command(command, options) {
- return (0, execute_operation_1.executeOperation)(this.s.db.client, new run_command_1.RunCommandOperation(this.s.db, command, { dbName: "admin", ...options }));
- }
- /**
- * Retrieve the server build information
- *
- * @param options - Optional settings for the command
- */
- async buildInfo(options) {
- return this.command({ buildinfo: 1 }, options);
- }
- /**
- * Retrieve the server build information
- *
- * @param options - Optional settings for the command
- */
- async serverInfo(options) {
- return this.command({ buildinfo: 1 }, options);
- }
- /**
- * Retrieve this db's server status.
- *
- * @param options - Optional settings for the command
- */
- async serverStatus(options) {
- return this.command({ serverStatus: 1 }, options);
- }
- /**
- * Ping the MongoDB server and retrieve results
- *
- * @param options - Optional settings for the command
- */
- async ping(options) {
- return this.command({ ping: 1 }, options);
- }
- /**
- * Add a user to the database
- *
- * @param username - The username for the new user
- * @param passwordOrOptions - An optional password for the new user, or the options for the command
- * @param options - Optional settings for the command
- * @deprecated Use the createUser command in `db.command()` instead.
- * @see https://www.mongodb.com/docs/manual/reference/command/createUser/
- */
- async addUser(username, passwordOrOptions, options) {
- options = options != null && typeof options === "object" ? options : passwordOrOptions != null && typeof passwordOrOptions === "object" ? passwordOrOptions : void 0;
- const password = typeof passwordOrOptions === "string" ? passwordOrOptions : void 0;
- return (0, execute_operation_1.executeOperation)(this.s.db.client, new add_user_1.AddUserOperation(this.s.db, username, password, { dbName: "admin", ...options }));
- }
- /**
- * Remove a user from a database
- *
- * @param username - The username to remove
- * @param options - Optional settings for the command
- */
- async removeUser(username, options) {
- return (0, execute_operation_1.executeOperation)(this.s.db.client, new remove_user_1.RemoveUserOperation(this.s.db, username, { dbName: "admin", ...options }));
- }
- /**
- * Validate an existing collection
- *
- * @param collectionName - The name of the collection to validate.
- * @param options - Optional settings for the command
- */
- async validateCollection(collectionName, options = {}) {
- return (0, execute_operation_1.executeOperation)(this.s.db.client, new validate_collection_1.ValidateCollectionOperation(this, collectionName, options));
- }
- /**
- * List the available databases
- *
- * @param options - Optional settings for the command
- */
- async listDatabases(options) {
- return (0, execute_operation_1.executeOperation)(this.s.db.client, new list_databases_1.ListDatabasesOperation(this.s.db, options));
- }
- /**
- * Get ReplicaSet status
- *
- * @param options - Optional settings for the command
- */
- async replSetGetStatus(options) {
- return this.command({ replSetGetStatus: 1 }, options);
- }
- };
- exports2.Admin = Admin;
- }
- });
- // node_modules/mongodb/lib/operations/delete.js
- var require_delete = __commonJS({
- "node_modules/mongodb/lib/operations/delete.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.makeDeleteStatement = exports2.DeleteManyOperation = exports2.DeleteOneOperation = exports2.DeleteOperation = void 0;
- var error_1 = require_error();
- var command_1 = require_command();
- var operation_1 = require_operation();
- var DeleteOperation = class extends command_1.CommandCallbackOperation {
- constructor(ns, statements, options) {
- super(void 0, options);
- this.options = options;
- this.ns = ns;
- this.statements = statements;
- }
- get canRetryWrite() {
- if (super.canRetryWrite === false) {
- return false;
- }
- return this.statements.every((op) => op.limit != null ? op.limit > 0 : true);
- }
- executeCallback(server, session, callback) {
- const options = this.options ?? {};
- const ordered = typeof options.ordered === "boolean" ? options.ordered : true;
- const command = {
- delete: this.ns.collection,
- deletes: this.statements,
- ordered
- };
- if (options.let) {
- command.let = options.let;
- }
- if (options.comment !== void 0) {
- command.comment = options.comment;
- }
- const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;
- if (unacknowledgedWrite) {
- if (this.statements.find((o) => o.hint)) {
- callback(new error_1.MongoCompatibilityError(`hint is not supported with unacknowledged writes`));
- return;
- }
- }
- super.executeCommandCallback(server, session, command, callback);
- }
- };
- exports2.DeleteOperation = DeleteOperation;
- var DeleteOneOperation = class extends DeleteOperation {
- constructor(collection, filter, options) {
- super(collection.s.namespace, [makeDeleteStatement(filter, { ...options, limit: 1 })], options);
- }
- executeCallback(server, session, callback) {
- super.executeCallback(server, session, (err, res) => {
- var _a;
- if (err || res == null)
- return callback(err);
- if (res.code)
- return callback(new error_1.MongoServerError(res));
- if (res.writeErrors)
- return callback(new error_1.MongoServerError(res.writeErrors[0]));
- if (this.explain)
- return callback(void 0, res);
- callback(void 0, {
- acknowledged: ((_a = this.writeConcern) == null ? void 0 : _a.w) !== 0,
- deletedCount: res.n
- });
- });
- }
- };
- exports2.DeleteOneOperation = DeleteOneOperation;
- var DeleteManyOperation = class extends DeleteOperation {
- constructor(collection, filter, options) {
- super(collection.s.namespace, [makeDeleteStatement(filter, options)], options);
- }
- executeCallback(server, session, callback) {
- super.executeCallback(server, session, (err, res) => {
- var _a;
- if (err || res == null)
- return callback(err);
- if (res.code)
- return callback(new error_1.MongoServerError(res));
- if (res.writeErrors)
- return callback(new error_1.MongoServerError(res.writeErrors[0]));
- if (this.explain)
- return callback(void 0, res);
- callback(void 0, {
- acknowledged: ((_a = this.writeConcern) == null ? void 0 : _a.w) !== 0,
- deletedCount: res.n
- });
- });
- }
- };
- exports2.DeleteManyOperation = DeleteManyOperation;
- function makeDeleteStatement(filter, options) {
- const op = {
- q: filter,
- limit: typeof options.limit === "number" ? options.limit : 0
- };
- if (options.collation) {
- op.collation = options.collation;
- }
- if (options.hint) {
- op.hint = options.hint;
- }
- return op;
- }
- exports2.makeDeleteStatement = makeDeleteStatement;
- (0, operation_1.defineAspects)(DeleteOperation, [operation_1.Aspect.RETRYABLE, operation_1.Aspect.WRITE_OPERATION]);
- (0, operation_1.defineAspects)(DeleteOneOperation, [
- operation_1.Aspect.RETRYABLE,
- operation_1.Aspect.WRITE_OPERATION,
- operation_1.Aspect.EXPLAINABLE,
- operation_1.Aspect.SKIP_COLLATION
- ]);
- (0, operation_1.defineAspects)(DeleteManyOperation, [
- operation_1.Aspect.WRITE_OPERATION,
- operation_1.Aspect.EXPLAINABLE,
- operation_1.Aspect.SKIP_COLLATION
- ]);
- }
- });
- // node_modules/mongodb/lib/operations/bulk_write.js
- var require_bulk_write = __commonJS({
- "node_modules/mongodb/lib/operations/bulk_write.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.BulkWriteOperation = void 0;
- var operation_1 = require_operation();
- var BulkWriteOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(collection, operations, options) {
- super(options);
- this.options = options;
- this.collection = collection;
- this.operations = operations;
- }
- executeCallback(server, session, callback) {
- const coll = this.collection;
- const operations = this.operations;
- const options = { ...this.options, ...this.bsonOptions, readPreference: this.readPreference };
- const bulk = options.ordered === false ? coll.initializeUnorderedBulkOp(options) : coll.initializeOrderedBulkOp(options);
- try {
- for (let i = 0; i < operations.length; i++) {
- bulk.raw(operations[i]);
- }
- } catch (err) {
- return callback(err);
- }
- bulk.execute({ ...options, session }).then((result) => callback(void 0, result), (error) => callback(error));
- }
- };
- exports2.BulkWriteOperation = BulkWriteOperation;
- (0, operation_1.defineAspects)(BulkWriteOperation, [operation_1.Aspect.WRITE_OPERATION]);
- }
- });
- // node_modules/mongodb/lib/operations/common_functions.js
- var require_common_functions = __commonJS({
- "node_modules/mongodb/lib/operations/common_functions.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.prepareDocs = exports2.indexInformation = void 0;
- var error_1 = require_error();
- var utils_1 = require_utils();
- function indexInformation(db, name, _optionsOrCallback, _callback) {
- let options = _optionsOrCallback;
- let callback = _callback;
- if ("function" === typeof _optionsOrCallback) {
- callback = _optionsOrCallback;
- options = {};
- }
- const full = options.full == null ? false : options.full;
- let topology;
- try {
- topology = (0, utils_1.getTopology)(db);
- } catch (error) {
- return callback(error);
- }
- if (topology.isDestroyed())
- return callback(new error_1.MongoTopologyClosedError());
- function processResults(indexes) {
- const info = {};
- for (let i = 0; i < indexes.length; i++) {
- const index = indexes[i];
- info[index.name] = [];
- for (const name2 in index.key) {
- info[index.name].push([name2, index.key[name2]]);
- }
- }
- return info;
- }
- db.collection(name).listIndexes(options).toArray().then((indexes) => {
- if (!Array.isArray(indexes))
- return callback(void 0, []);
- if (full)
- return callback(void 0, indexes);
- callback(void 0, processResults(indexes));
- }, (error) => callback(error));
- }
- exports2.indexInformation = indexInformation;
- function prepareDocs(coll, docs, options) {
- var _a;
- const forceServerObjectId = typeof options.forceServerObjectId === "boolean" ? options.forceServerObjectId : (_a = coll.s.db.options) == null ? void 0 : _a.forceServerObjectId;
- if (forceServerObjectId === true) {
- return docs;
- }
- return docs.map((doc) => {
- if (doc._id == null) {
- doc._id = coll.s.pkFactory.createPk();
- }
- return doc;
- });
- }
- exports2.prepareDocs = prepareDocs;
- }
- });
- // node_modules/mongodb/lib/operations/insert.js
- var require_insert = __commonJS({
- "node_modules/mongodb/lib/operations/insert.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.InsertManyOperation = exports2.InsertOneOperation = exports2.InsertOperation = void 0;
- var error_1 = require_error();
- var write_concern_1 = require_write_concern();
- var bulk_write_1 = require_bulk_write();
- var command_1 = require_command();
- var common_functions_1 = require_common_functions();
- var operation_1 = require_operation();
- var InsertOperation = class extends command_1.CommandCallbackOperation {
- constructor(ns, documents, options) {
- super(void 0, options);
- this.options = { ...options, checkKeys: options.checkKeys ?? false };
- this.ns = ns;
- this.documents = documents;
- }
- executeCallback(server, session, callback) {
- const options = this.options ?? {};
- const ordered = typeof options.ordered === "boolean" ? options.ordered : true;
- const command = {
- insert: this.ns.collection,
- documents: this.documents,
- ordered
- };
- if (typeof options.bypassDocumentValidation === "boolean") {
- command.bypassDocumentValidation = options.bypassDocumentValidation;
- }
- if (options.comment !== void 0) {
- command.comment = options.comment;
- }
- super.executeCommandCallback(server, session, command, callback);
- }
- };
- exports2.InsertOperation = InsertOperation;
- var InsertOneOperation = class extends InsertOperation {
- constructor(collection, doc, options) {
- super(collection.s.namespace, (0, common_functions_1.prepareDocs)(collection, [doc], options), options);
- }
- executeCallback(server, session, callback) {
- super.executeCallback(server, session, (err, res) => {
- var _a;
- if (err || res == null)
- return callback(err);
- if (res.code)
- return callback(new error_1.MongoServerError(res));
- if (res.writeErrors) {
- return callback(new error_1.MongoServerError(res.writeErrors[0]));
- }
- callback(void 0, {
- acknowledged: ((_a = this.writeConcern) == null ? void 0 : _a.w) !== 0,
- insertedId: this.documents[0]._id
- });
- });
- }
- };
- exports2.InsertOneOperation = InsertOneOperation;
- var InsertManyOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(collection, docs, options) {
- super(options);
- if (!Array.isArray(docs)) {
- throw new error_1.MongoInvalidArgumentError('Argument "docs" must be an array of documents');
- }
- this.options = options;
- this.collection = collection;
- this.docs = docs;
- }
- executeCallback(server, session, callback) {
- const coll = this.collection;
- const options = { ...this.options, ...this.bsonOptions, readPreference: this.readPreference };
- const writeConcern = write_concern_1.WriteConcern.fromOptions(options);
- const bulkWriteOperation = new bulk_write_1.BulkWriteOperation(coll, (0, common_functions_1.prepareDocs)(coll, this.docs, options).map((document) => ({ insertOne: { document } })), options);
- bulkWriteOperation.executeCallback(server, session, (err, res) => {
- if (err || res == null) {
- if (err && err.message === "Operation must be an object with an operation key") {
- err = new error_1.MongoInvalidArgumentError("Collection.insertMany() cannot be called with an array that has null/undefined values");
- }
- return callback(err);
- }
- callback(void 0, {
- acknowledged: (writeConcern == null ? void 0 : writeConcern.w) !== 0,
- insertedCount: res.insertedCount,
- insertedIds: res.insertedIds
- });
- });
- }
- };
- exports2.InsertManyOperation = InsertManyOperation;
- (0, operation_1.defineAspects)(InsertOperation, [operation_1.Aspect.RETRYABLE, operation_1.Aspect.WRITE_OPERATION]);
- (0, operation_1.defineAspects)(InsertOneOperation, [operation_1.Aspect.RETRYABLE, operation_1.Aspect.WRITE_OPERATION]);
- (0, operation_1.defineAspects)(InsertManyOperation, [operation_1.Aspect.WRITE_OPERATION]);
- }
- });
- // node_modules/mongodb/lib/operations/update.js
- var require_update = __commonJS({
- "node_modules/mongodb/lib/operations/update.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.makeUpdateStatement = exports2.ReplaceOneOperation = exports2.UpdateManyOperation = exports2.UpdateOneOperation = exports2.UpdateOperation = void 0;
- var error_1 = require_error();
- var utils_1 = require_utils();
- var command_1 = require_command();
- var operation_1 = require_operation();
- var UpdateOperation = class extends command_1.CommandCallbackOperation {
- constructor(ns, statements, options) {
- super(void 0, options);
- this.options = options;
- this.ns = ns;
- this.statements = statements;
- }
- get canRetryWrite() {
- if (super.canRetryWrite === false) {
- return false;
- }
- return this.statements.every((op) => op.multi == null || op.multi === false);
- }
- executeCallback(server, session, callback) {
- const options = this.options ?? {};
- const ordered = typeof options.ordered === "boolean" ? options.ordered : true;
- const command = {
- update: this.ns.collection,
- updates: this.statements,
- ordered
- };
- if (typeof options.bypassDocumentValidation === "boolean") {
- command.bypassDocumentValidation = options.bypassDocumentValidation;
- }
- if (options.let) {
- command.let = options.let;
- }
- if (options.comment !== void 0) {
- command.comment = options.comment;
- }
- const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;
- if (unacknowledgedWrite) {
- if (this.statements.find((o) => o.hint)) {
- callback(new error_1.MongoCompatibilityError(`hint is not supported with unacknowledged writes`));
- return;
- }
- }
- super.executeCommandCallback(server, session, command, callback);
- }
- };
- exports2.UpdateOperation = UpdateOperation;
- var UpdateOneOperation = class extends UpdateOperation {
- constructor(collection, filter, update, options) {
- super(collection.s.namespace, [makeUpdateStatement(filter, update, { ...options, multi: false })], options);
- if (!(0, utils_1.hasAtomicOperators)(update)) {
- throw new error_1.MongoInvalidArgumentError("Update document requires atomic operators");
- }
- }
- executeCallback(server, session, callback) {
- super.executeCallback(server, session, (err, res) => {
- var _a;
- if (err || !res)
- return callback(err);
- if (this.explain != null)
- return callback(void 0, res);
- if (res.code)
- return callback(new error_1.MongoServerError(res));
- if (res.writeErrors)
- return callback(new error_1.MongoServerError(res.writeErrors[0]));
- callback(void 0, {
- acknowledged: ((_a = this.writeConcern) == null ? void 0 : _a.w) !== 0,
- modifiedCount: res.nModified != null ? res.nModified : res.n,
- upsertedId: Array.isArray(res.upserted) && res.upserted.length > 0 ? res.upserted[0]._id : null,
- upsertedCount: Array.isArray(res.upserted) && res.upserted.length ? res.upserted.length : 0,
- matchedCount: Array.isArray(res.upserted) && res.upserted.length > 0 ? 0 : res.n
- });
- });
- }
- };
- exports2.UpdateOneOperation = UpdateOneOperation;
- var UpdateManyOperation = class extends UpdateOperation {
- constructor(collection, filter, update, options) {
- super(collection.s.namespace, [makeUpdateStatement(filter, update, { ...options, multi: true })], options);
- if (!(0, utils_1.hasAtomicOperators)(update)) {
- throw new error_1.MongoInvalidArgumentError("Update document requires atomic operators");
- }
- }
- executeCallback(server, session, callback) {
- super.executeCallback(server, session, (err, res) => {
- var _a;
- if (err || !res)
- return callback(err);
- if (this.explain != null)
- return callback(void 0, res);
- if (res.code)
- return callback(new error_1.MongoServerError(res));
- if (res.writeErrors)
- return callback(new error_1.MongoServerError(res.writeErrors[0]));
- callback(void 0, {
- acknowledged: ((_a = this.writeConcern) == null ? void 0 : _a.w) !== 0,
- modifiedCount: res.nModified != null ? res.nModified : res.n,
- upsertedId: Array.isArray(res.upserted) && res.upserted.length > 0 ? res.upserted[0]._id : null,
- upsertedCount: Array.isArray(res.upserted) && res.upserted.length ? res.upserted.length : 0,
- matchedCount: Array.isArray(res.upserted) && res.upserted.length > 0 ? 0 : res.n
- });
- });
- }
- };
- exports2.UpdateManyOperation = UpdateManyOperation;
- var ReplaceOneOperation = class extends UpdateOperation {
- constructor(collection, filter, replacement, options) {
- super(collection.s.namespace, [makeUpdateStatement(filter, replacement, { ...options, multi: false })], options);
- if ((0, utils_1.hasAtomicOperators)(replacement)) {
- throw new error_1.MongoInvalidArgumentError("Replacement document must not contain atomic operators");
- }
- }
- executeCallback(server, session, callback) {
- super.executeCallback(server, session, (err, res) => {
- var _a;
- if (err || !res)
- return callback(err);
- if (this.explain != null)
- return callback(void 0, res);
- if (res.code)
- return callback(new error_1.MongoServerError(res));
- if (res.writeErrors)
- return callback(new error_1.MongoServerError(res.writeErrors[0]));
- callback(void 0, {
- acknowledged: ((_a = this.writeConcern) == null ? void 0 : _a.w) !== 0,
- modifiedCount: res.nModified != null ? res.nModified : res.n,
- upsertedId: Array.isArray(res.upserted) && res.upserted.length > 0 ? res.upserted[0]._id : null,
- upsertedCount: Array.isArray(res.upserted) && res.upserted.length ? res.upserted.length : 0,
- matchedCount: Array.isArray(res.upserted) && res.upserted.length > 0 ? 0 : res.n
- });
- });
- }
- };
- exports2.ReplaceOneOperation = ReplaceOneOperation;
- function makeUpdateStatement(filter, update, options) {
- if (filter == null || typeof filter !== "object") {
- throw new error_1.MongoInvalidArgumentError("Selector must be a valid JavaScript object");
- }
- if (update == null || typeof update !== "object") {
- throw new error_1.MongoInvalidArgumentError("Document must be a valid JavaScript object");
- }
- const op = { q: filter, u: update };
- if (typeof options.upsert === "boolean") {
- op.upsert = options.upsert;
- }
- if (options.multi) {
- op.multi = options.multi;
- }
- if (options.hint) {
- op.hint = options.hint;
- }
- if (options.arrayFilters) {
- op.arrayFilters = options.arrayFilters;
- }
- if (options.collation) {
- op.collation = options.collation;
- }
- return op;
- }
- exports2.makeUpdateStatement = makeUpdateStatement;
- (0, operation_1.defineAspects)(UpdateOperation, [operation_1.Aspect.RETRYABLE, operation_1.Aspect.WRITE_OPERATION, operation_1.Aspect.SKIP_COLLATION]);
- (0, operation_1.defineAspects)(UpdateOneOperation, [
- operation_1.Aspect.RETRYABLE,
- operation_1.Aspect.WRITE_OPERATION,
- operation_1.Aspect.EXPLAINABLE,
- operation_1.Aspect.SKIP_COLLATION
- ]);
- (0, operation_1.defineAspects)(UpdateManyOperation, [
- operation_1.Aspect.WRITE_OPERATION,
- operation_1.Aspect.EXPLAINABLE,
- operation_1.Aspect.SKIP_COLLATION
- ]);
- (0, operation_1.defineAspects)(ReplaceOneOperation, [
- operation_1.Aspect.RETRYABLE,
- operation_1.Aspect.WRITE_OPERATION,
- operation_1.Aspect.SKIP_COLLATION
- ]);
- }
- });
- // node_modules/mongodb/lib/bulk/common.js
- var require_common2 = __commonJS({
- "node_modules/mongodb/lib/bulk/common.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.BulkOperationBase = exports2.FindOperators = exports2.MongoBulkWriteError = exports2.mergeBatchResults = exports2.WriteError = exports2.WriteConcernError = exports2.BulkWriteResult = exports2.Batch = exports2.BatchType = void 0;
- var bson_1 = require_bson2();
- var error_1 = require_error();
- var delete_1 = require_delete();
- var execute_operation_1 = require_execute_operation();
- var insert_1 = require_insert();
- var operation_1 = require_operation();
- var update_1 = require_update();
- var utils_1 = require_utils();
- var write_concern_1 = require_write_concern();
- var kServerError = Symbol("serverError");
- exports2.BatchType = Object.freeze({
- INSERT: 1,
- UPDATE: 2,
- DELETE: 3
- });
- var Batch = class {
- constructor(batchType, originalZeroIndex) {
- this.originalZeroIndex = originalZeroIndex;
- this.currentIndex = 0;
- this.originalIndexes = [];
- this.batchType = batchType;
- this.operations = [];
- this.size = 0;
- this.sizeBytes = 0;
- }
- };
- exports2.Batch = Batch;
- var BulkWriteResult = class _BulkWriteResult {
- static generateIdMap(ids) {
- const idMap = {};
- for (const doc of ids) {
- idMap[doc.index] = doc._id;
- }
- return idMap;
- }
- /**
- * Create a new BulkWriteResult instance
- * @internal
- */
- constructor(bulkResult, isOrdered) {
- this.result = bulkResult;
- this.insertedCount = this.result.nInserted ?? 0;
- this.matchedCount = this.result.nMatched ?? 0;
- this.modifiedCount = this.result.nModified ?? 0;
- this.deletedCount = this.result.nRemoved ?? 0;
- this.upsertedCount = this.result.upserted.length ?? 0;
- this.upsertedIds = _BulkWriteResult.generateIdMap(this.result.upserted);
- this.insertedIds = _BulkWriteResult.generateIdMap(this.getSuccessfullyInsertedIds(bulkResult, isOrdered));
- Object.defineProperty(this, "result", { value: this.result, enumerable: false });
- }
- /**
- * Returns document_ids that were actually inserted
- * @internal
- */
- getSuccessfullyInsertedIds(bulkResult, isOrdered) {
- if (bulkResult.writeErrors.length === 0)
- return bulkResult.insertedIds;
- if (isOrdered) {
- return bulkResult.insertedIds.slice(0, bulkResult.writeErrors[0].index);
- }
- return bulkResult.insertedIds.filter(({ index }) => !bulkResult.writeErrors.some((writeError) => index === writeError.index));
- }
- /** Evaluates to true if the bulk operation correctly executes */
- get ok() {
- return this.result.ok;
- }
- /**
- * The number of inserted documents
- * @deprecated Use insertedCount instead.
- */
- get nInserted() {
- return this.result.nInserted;
- }
- /**
- * Number of upserted documents
- * @deprecated User upsertedCount instead.
- */
- get nUpserted() {
- return this.result.nUpserted;
- }
- /**
- * Number of matched documents
- * @deprecated Use matchedCount instead.
- */
- get nMatched() {
- return this.result.nMatched;
- }
- /**
- * Number of documents updated physically on disk
- * @deprecated Use modifiedCount instead.
- */
- get nModified() {
- return this.result.nModified;
- }
- /**
- * Number of removed documents
- * @deprecated Use deletedCount instead.
- */
- get nRemoved() {
- return this.result.nRemoved;
- }
- /**
- * Returns an array of all inserted ids
- * @deprecated Use insertedIds instead.
- */
- getInsertedIds() {
- return this.result.insertedIds;
- }
- /**
- * Returns an array of all upserted ids
- * @deprecated Use upsertedIds instead.
- */
- getUpsertedIds() {
- return this.result.upserted;
- }
- /** Returns the upserted id at the given index */
- getUpsertedIdAt(index) {
- return this.result.upserted[index];
- }
- /** Returns raw internal result */
- getRawResponse() {
- return this.result;
- }
- /** Returns true if the bulk operation contains a write error */
- hasWriteErrors() {
- return this.result.writeErrors.length > 0;
- }
- /** Returns the number of write errors off the bulk operation */
- getWriteErrorCount() {
- return this.result.writeErrors.length;
- }
- /** Returns a specific write error object */
- getWriteErrorAt(index) {
- return index < this.result.writeErrors.length ? this.result.writeErrors[index] : void 0;
- }
- /** Retrieve all write errors */
- getWriteErrors() {
- return this.result.writeErrors;
- }
- /** Retrieve the write concern error if one exists */
- getWriteConcernError() {
- if (this.result.writeConcernErrors.length === 0) {
- return;
- } else if (this.result.writeConcernErrors.length === 1) {
- return this.result.writeConcernErrors[0];
- } else {
- let errmsg = "";
- for (let i = 0; i < this.result.writeConcernErrors.length; i++) {
- const err = this.result.writeConcernErrors[i];
- errmsg = errmsg + err.errmsg;
- if (i === 0)
- errmsg = errmsg + " and ";
- }
- return new WriteConcernError({ errmsg, code: error_1.MONGODB_ERROR_CODES.WriteConcernFailed });
- }
- }
- toString() {
- return `BulkWriteResult(${this.result})`;
- }
- isOk() {
- return this.result.ok === 1;
- }
- };
- exports2.BulkWriteResult = BulkWriteResult;
- var WriteConcernError = class {
- constructor(error) {
- this[kServerError] = error;
- }
- /** Write concern error code. */
- get code() {
- return this[kServerError].code;
- }
- /** Write concern error message. */
- get errmsg() {
- return this[kServerError].errmsg;
- }
- /** Write concern error info. */
- get errInfo() {
- return this[kServerError].errInfo;
- }
- toJSON() {
- return this[kServerError];
- }
- toString() {
- return `WriteConcernError(${this.errmsg})`;
- }
- };
- exports2.WriteConcernError = WriteConcernError;
- var WriteError = class {
- constructor(err) {
- this.err = err;
- }
- /** WriteError code. */
- get code() {
- return this.err.code;
- }
- /** WriteError original bulk operation index. */
- get index() {
- return this.err.index;
- }
- /** WriteError message. */
- get errmsg() {
- return this.err.errmsg;
- }
- /** WriteError details. */
- get errInfo() {
- return this.err.errInfo;
- }
- /** Returns the underlying operation that caused the error */
- getOperation() {
- return this.err.op;
- }
- toJSON() {
- return { code: this.err.code, index: this.err.index, errmsg: this.err.errmsg, op: this.err.op };
- }
- toString() {
- return `WriteError(${JSON.stringify(this.toJSON())})`;
- }
- };
- exports2.WriteError = WriteError;
- function mergeBatchResults(batch, bulkResult, err, result) {
- if (err) {
- result = err;
- } else if (result && result.result) {
- result = result.result;
- }
- if (result == null) {
- return;
- }
- if (result.ok === 0 && bulkResult.ok === 1) {
- bulkResult.ok = 0;
- const writeError = {
- index: 0,
- code: result.code || 0,
- errmsg: result.message,
- errInfo: result.errInfo,
- op: batch.operations[0]
- };
- bulkResult.writeErrors.push(new WriteError(writeError));
- return;
- } else if (result.ok === 0 && bulkResult.ok === 0) {
- return;
- }
- if (isInsertBatch(batch) && result.n) {
- bulkResult.nInserted = bulkResult.nInserted + result.n;
- }
- if (isDeleteBatch(batch) && result.n) {
- bulkResult.nRemoved = bulkResult.nRemoved + result.n;
- }
- let nUpserted = 0;
- if (Array.isArray(result.upserted)) {
- nUpserted = result.upserted.length;
- for (let i = 0; i < result.upserted.length; i++) {
- bulkResult.upserted.push({
- index: result.upserted[i].index + batch.originalZeroIndex,
- _id: result.upserted[i]._id
- });
- }
- } else if (result.upserted) {
- nUpserted = 1;
- bulkResult.upserted.push({
- index: batch.originalZeroIndex,
- _id: result.upserted
- });
- }
- if (isUpdateBatch(batch) && result.n) {
- const nModified = result.nModified;
- bulkResult.nUpserted = bulkResult.nUpserted + nUpserted;
- bulkResult.nMatched = bulkResult.nMatched + (result.n - nUpserted);
- if (typeof nModified === "number") {
- bulkResult.nModified = bulkResult.nModified + nModified;
- } else {
- bulkResult.nModified = 0;
- }
- }
- if (Array.isArray(result.writeErrors)) {
- for (let i = 0; i < result.writeErrors.length; i++) {
- const writeError = {
- index: batch.originalIndexes[result.writeErrors[i].index],
- code: result.writeErrors[i].code,
- errmsg: result.writeErrors[i].errmsg,
- errInfo: result.writeErrors[i].errInfo,
- op: batch.operations[result.writeErrors[i].index]
- };
- bulkResult.writeErrors.push(new WriteError(writeError));
- }
- }
- if (result.writeConcernError) {
- bulkResult.writeConcernErrors.push(new WriteConcernError(result.writeConcernError));
- }
- }
- exports2.mergeBatchResults = mergeBatchResults;
- function executeCommands(bulkOperation, options, callback) {
- if (bulkOperation.s.batches.length === 0) {
- return callback(void 0, new BulkWriteResult(bulkOperation.s.bulkResult, bulkOperation.isOrdered));
- }
- const batch = bulkOperation.s.batches.shift();
- function resultHandler(err, result) {
- if (err && "message" in err && !(err instanceof error_1.MongoWriteConcernError)) {
- return callback(new MongoBulkWriteError(err, new BulkWriteResult(bulkOperation.s.bulkResult, bulkOperation.isOrdered)));
- }
- if (err instanceof error_1.MongoWriteConcernError) {
- return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, bulkOperation.isOrdered, err, callback);
- }
- mergeBatchResults(batch, bulkOperation.s.bulkResult, err, result);
- const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult, bulkOperation.isOrdered);
- if (bulkOperation.handleWriteError(callback, writeResult))
- return;
- executeCommands(bulkOperation, options, callback);
- }
- const finalOptions = (0, utils_1.resolveOptions)(bulkOperation, {
- ...options,
- ordered: bulkOperation.isOrdered
- });
- if (finalOptions.bypassDocumentValidation !== true) {
- delete finalOptions.bypassDocumentValidation;
- }
- if (bulkOperation.operationId) {
- resultHandler.operationId = bulkOperation.operationId;
- }
- if (bulkOperation.s.bypassDocumentValidation === true) {
- finalOptions.bypassDocumentValidation = true;
- }
- if (bulkOperation.s.checkKeys === false) {
- finalOptions.checkKeys = false;
- }
- if (finalOptions.retryWrites) {
- if (isUpdateBatch(batch)) {
- finalOptions.retryWrites = finalOptions.retryWrites && !batch.operations.some((op) => op.multi);
- }
- if (isDeleteBatch(batch)) {
- finalOptions.retryWrites = finalOptions.retryWrites && !batch.operations.some((op) => op.limit === 0);
- }
- }
- try {
- if (isInsertBatch(batch)) {
- (0, execute_operation_1.executeOperation)(bulkOperation.s.collection.client, new insert_1.InsertOperation(bulkOperation.s.namespace, batch.operations, finalOptions), resultHandler);
- } else if (isUpdateBatch(batch)) {
- (0, execute_operation_1.executeOperation)(bulkOperation.s.collection.client, new update_1.UpdateOperation(bulkOperation.s.namespace, batch.operations, finalOptions), resultHandler);
- } else if (isDeleteBatch(batch)) {
- (0, execute_operation_1.executeOperation)(bulkOperation.s.collection.client, new delete_1.DeleteOperation(bulkOperation.s.namespace, batch.operations, finalOptions), resultHandler);
- }
- } catch (err) {
- err.ok = 0;
- mergeBatchResults(batch, bulkOperation.s.bulkResult, err, void 0);
- callback();
- }
- }
- function handleMongoWriteConcernError(batch, bulkResult, isOrdered, err, callback) {
- var _a, _b;
- mergeBatchResults(batch, bulkResult, void 0, err.result);
- callback(new MongoBulkWriteError({
- message: (_a = err.result) == null ? void 0 : _a.writeConcernError.errmsg,
- code: (_b = err.result) == null ? void 0 : _b.writeConcernError.result
- }, new BulkWriteResult(bulkResult, isOrdered)));
- }
- var MongoBulkWriteError = class extends error_1.MongoServerError {
- /** Creates a new MongoBulkWriteError */
- constructor(error, result) {
- super(error);
- this.writeErrors = [];
- if (error instanceof WriteConcernError)
- this.err = error;
- else if (!(error instanceof Error)) {
- this.message = error.message;
- this.code = error.code;
- this.writeErrors = error.writeErrors ?? [];
- }
- this.result = result;
- Object.assign(this, error);
- }
- get name() {
- return "MongoBulkWriteError";
- }
- /** Number of documents inserted. */
- get insertedCount() {
- return this.result.insertedCount;
- }
- /** Number of documents matched for update. */
- get matchedCount() {
- return this.result.matchedCount;
- }
- /** Number of documents modified. */
- get modifiedCount() {
- return this.result.modifiedCount;
- }
- /** Number of documents deleted. */
- get deletedCount() {
- return this.result.deletedCount;
- }
- /** Number of documents upserted. */
- get upsertedCount() {
- return this.result.upsertedCount;
- }
- /** Inserted document generated Id's, hash key is the index of the originating operation */
- get insertedIds() {
- return this.result.insertedIds;
- }
- /** Upserted document generated Id's, hash key is the index of the originating operation */
- get upsertedIds() {
- return this.result.upsertedIds;
- }
- };
- exports2.MongoBulkWriteError = MongoBulkWriteError;
- var FindOperators = class {
- /**
- * Creates a new FindOperators object.
- * @internal
- */
- constructor(bulkOperation) {
- this.bulkOperation = bulkOperation;
- }
- /** Add a multiple update operation to the bulk operation */
- update(updateDocument) {
- const currentOp = buildCurrentOp(this.bulkOperation);
- return this.bulkOperation.addToOperationsList(exports2.BatchType.UPDATE, (0, update_1.makeUpdateStatement)(currentOp.selector, updateDocument, {
- ...currentOp,
- multi: true
- }));
- }
- /** Add a single update operation to the bulk operation */
- updateOne(updateDocument) {
- if (!(0, utils_1.hasAtomicOperators)(updateDocument)) {
- throw new error_1.MongoInvalidArgumentError("Update document requires atomic operators");
- }
- const currentOp = buildCurrentOp(this.bulkOperation);
- return this.bulkOperation.addToOperationsList(exports2.BatchType.UPDATE, (0, update_1.makeUpdateStatement)(currentOp.selector, updateDocument, { ...currentOp, multi: false }));
- }
- /** Add a replace one operation to the bulk operation */
- replaceOne(replacement) {
- if ((0, utils_1.hasAtomicOperators)(replacement)) {
- throw new error_1.MongoInvalidArgumentError("Replacement document must not use atomic operators");
- }
- const currentOp = buildCurrentOp(this.bulkOperation);
- return this.bulkOperation.addToOperationsList(exports2.BatchType.UPDATE, (0, update_1.makeUpdateStatement)(currentOp.selector, replacement, { ...currentOp, multi: false }));
- }
- /** Add a delete one operation to the bulk operation */
- deleteOne() {
- const currentOp = buildCurrentOp(this.bulkOperation);
- return this.bulkOperation.addToOperationsList(exports2.BatchType.DELETE, (0, delete_1.makeDeleteStatement)(currentOp.selector, { ...currentOp, limit: 1 }));
- }
- /** Add a delete many operation to the bulk operation */
- delete() {
- const currentOp = buildCurrentOp(this.bulkOperation);
- return this.bulkOperation.addToOperationsList(exports2.BatchType.DELETE, (0, delete_1.makeDeleteStatement)(currentOp.selector, { ...currentOp, limit: 0 }));
- }
- /** Upsert modifier for update bulk operation, noting that this operation is an upsert. */
- upsert() {
- if (!this.bulkOperation.s.currentOp) {
- this.bulkOperation.s.currentOp = {};
- }
- this.bulkOperation.s.currentOp.upsert = true;
- return this;
- }
- /** Specifies the collation for the query condition. */
- collation(collation) {
- if (!this.bulkOperation.s.currentOp) {
- this.bulkOperation.s.currentOp = {};
- }
- this.bulkOperation.s.currentOp.collation = collation;
- return this;
- }
- /** Specifies arrayFilters for UpdateOne or UpdateMany bulk operations. */
- arrayFilters(arrayFilters) {
- if (!this.bulkOperation.s.currentOp) {
- this.bulkOperation.s.currentOp = {};
- }
- this.bulkOperation.s.currentOp.arrayFilters = arrayFilters;
- return this;
- }
- /** Specifies hint for the bulk operation. */
- hint(hint) {
- if (!this.bulkOperation.s.currentOp) {
- this.bulkOperation.s.currentOp = {};
- }
- this.bulkOperation.s.currentOp.hint = hint;
- return this;
- }
- };
- exports2.FindOperators = FindOperators;
- var BulkWriteShimOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(bulkOperation, options) {
- super(options);
- this.bulkOperation = bulkOperation;
- }
- executeCallback(server, session, callback) {
- if (this.options.session == null) {
- this.options.session = session;
- }
- return executeCommands(this.bulkOperation, this.options, callback);
- }
- };
- var BulkOperationBase = class {
- /**
- * Create a new OrderedBulkOperation or UnorderedBulkOperation instance
- * @internal
- */
- constructor(collection, options, isOrdered) {
- this.isOrdered = isOrdered;
- const topology = (0, utils_1.getTopology)(collection);
- options = options == null ? {} : options;
- const namespace = collection.s.namespace;
- const executed = false;
- const currentOp = void 0;
- const hello = topology.lastHello();
- const usingAutoEncryption = !!(topology.s.options && topology.s.options.autoEncrypter);
- const maxBsonObjectSize = hello && hello.maxBsonObjectSize ? hello.maxBsonObjectSize : 1024 * 1024 * 16;
- const maxBatchSizeBytes = usingAutoEncryption ? 1024 * 1024 * 2 : maxBsonObjectSize;
- const maxWriteBatchSize = hello && hello.maxWriteBatchSize ? hello.maxWriteBatchSize : 1e3;
- const maxKeySize = (maxWriteBatchSize - 1).toString(10).length + 2;
- let finalOptions = Object.assign({}, options);
- finalOptions = (0, utils_1.applyRetryableWrites)(finalOptions, collection.s.db);
- const bulkResult = {
- ok: 1,
- writeErrors: [],
- writeConcernErrors: [],
- insertedIds: [],
- nInserted: 0,
- nUpserted: 0,
- nMatched: 0,
- nModified: 0,
- nRemoved: 0,
- upserted: []
- };
- this.s = {
- // Final result
- bulkResult,
- // Current batch state
- currentBatch: void 0,
- currentIndex: 0,
- // ordered specific
- currentBatchSize: 0,
- currentBatchSizeBytes: 0,
- // unordered specific
- currentInsertBatch: void 0,
- currentUpdateBatch: void 0,
- currentRemoveBatch: void 0,
- batches: [],
- // Write concern
- writeConcern: write_concern_1.WriteConcern.fromOptions(options),
- // Max batch size options
- maxBsonObjectSize,
- maxBatchSizeBytes,
- maxWriteBatchSize,
- maxKeySize,
- // Namespace
- namespace,
- // Topology
- topology,
- // Options
- options: finalOptions,
- // BSON options
- bsonOptions: (0, bson_1.resolveBSONOptions)(options),
- // Current operation
- currentOp,
- // Executed
- executed,
- // Collection
- collection,
- // Fundamental error
- err: void 0,
- // check keys
- checkKeys: typeof options.checkKeys === "boolean" ? options.checkKeys : false
- };
- if (options.bypassDocumentValidation === true) {
- this.s.bypassDocumentValidation = true;
- }
- }
- /**
- * Add a single insert document to the bulk operation
- *
- * @example
- * ```ts
- * const bulkOp = collection.initializeOrderedBulkOp();
- *
- * // Adds three inserts to the bulkOp.
- * bulkOp
- * .insert({ a: 1 })
- * .insert({ b: 2 })
- * .insert({ c: 3 });
- * await bulkOp.execute();
- * ```
- */
- insert(document) {
- if (document._id == null && !shouldForceServerObjectId(this)) {
- document._id = new bson_1.ObjectId();
- }
- return this.addToOperationsList(exports2.BatchType.INSERT, document);
- }
- /**
- * Builds a find operation for an update/updateOne/delete/deleteOne/replaceOne.
- * Returns a builder object used to complete the definition of the operation.
- *
- * @example
- * ```ts
- * const bulkOp = collection.initializeOrderedBulkOp();
- *
- * // Add an updateOne to the bulkOp
- * bulkOp.find({ a: 1 }).updateOne({ $set: { b: 2 } });
- *
- * // Add an updateMany to the bulkOp
- * bulkOp.find({ c: 3 }).update({ $set: { d: 4 } });
- *
- * // Add an upsert
- * bulkOp.find({ e: 5 }).upsert().updateOne({ $set: { f: 6 } });
- *
- * // Add a deletion
- * bulkOp.find({ g: 7 }).deleteOne();
- *
- * // Add a multi deletion
- * bulkOp.find({ h: 8 }).delete();
- *
- * // Add a replaceOne
- * bulkOp.find({ i: 9 }).replaceOne({writeConcern: { j: 10 }});
- *
- * // Update using a pipeline (requires Mongodb 4.2 or higher)
- * bulk.find({ k: 11, y: { $exists: true }, z: { $exists: true } }).updateOne([
- * { $set: { total: { $sum: [ '$y', '$z' ] } } }
- * ]);
- *
- * // All of the ops will now be executed
- * await bulkOp.execute();
- * ```
- */
- find(selector) {
- if (!selector) {
- throw new error_1.MongoInvalidArgumentError("Bulk find operation must specify a selector");
- }
- this.s.currentOp = {
- selector
- };
- return new FindOperators(this);
- }
- /** Specifies a raw operation to perform in the bulk write. */
- raw(op) {
- if (op == null || typeof op !== "object") {
- throw new error_1.MongoInvalidArgumentError("Operation must be an object with an operation key");
- }
- if ("insertOne" in op) {
- const forceServerObjectId = shouldForceServerObjectId(this);
- if (op.insertOne && op.insertOne.document == null) {
- if (forceServerObjectId !== true && op.insertOne._id == null) {
- op.insertOne._id = new bson_1.ObjectId();
- }
- return this.addToOperationsList(exports2.BatchType.INSERT, op.insertOne);
- }
- if (forceServerObjectId !== true && op.insertOne.document._id == null) {
- op.insertOne.document._id = new bson_1.ObjectId();
- }
- return this.addToOperationsList(exports2.BatchType.INSERT, op.insertOne.document);
- }
- if ("replaceOne" in op || "updateOne" in op || "updateMany" in op) {
- if ("replaceOne" in op) {
- if ("q" in op.replaceOne) {
- throw new error_1.MongoInvalidArgumentError("Raw operations are not allowed");
- }
- const updateStatement = (0, update_1.makeUpdateStatement)(op.replaceOne.filter, op.replaceOne.replacement, { ...op.replaceOne, multi: false });
- if ((0, utils_1.hasAtomicOperators)(updateStatement.u)) {
- throw new error_1.MongoInvalidArgumentError("Replacement document must not use atomic operators");
- }
- return this.addToOperationsList(exports2.BatchType.UPDATE, updateStatement);
- }
- if ("updateOne" in op) {
- if ("q" in op.updateOne) {
- throw new error_1.MongoInvalidArgumentError("Raw operations are not allowed");
- }
- const updateStatement = (0, update_1.makeUpdateStatement)(op.updateOne.filter, op.updateOne.update, {
- ...op.updateOne,
- multi: false
- });
- if (!(0, utils_1.hasAtomicOperators)(updateStatement.u)) {
- throw new error_1.MongoInvalidArgumentError("Update document requires atomic operators");
- }
- return this.addToOperationsList(exports2.BatchType.UPDATE, updateStatement);
- }
- if ("updateMany" in op) {
- if ("q" in op.updateMany) {
- throw new error_1.MongoInvalidArgumentError("Raw operations are not allowed");
- }
- const updateStatement = (0, update_1.makeUpdateStatement)(op.updateMany.filter, op.updateMany.update, {
- ...op.updateMany,
- multi: true
- });
- if (!(0, utils_1.hasAtomicOperators)(updateStatement.u)) {
- throw new error_1.MongoInvalidArgumentError("Update document requires atomic operators");
- }
- return this.addToOperationsList(exports2.BatchType.UPDATE, updateStatement);
- }
- }
- if ("deleteOne" in op) {
- if ("q" in op.deleteOne) {
- throw new error_1.MongoInvalidArgumentError("Raw operations are not allowed");
- }
- return this.addToOperationsList(exports2.BatchType.DELETE, (0, delete_1.makeDeleteStatement)(op.deleteOne.filter, { ...op.deleteOne, limit: 1 }));
- }
- if ("deleteMany" in op) {
- if ("q" in op.deleteMany) {
- throw new error_1.MongoInvalidArgumentError("Raw operations are not allowed");
- }
- return this.addToOperationsList(exports2.BatchType.DELETE, (0, delete_1.makeDeleteStatement)(op.deleteMany.filter, { ...op.deleteMany, limit: 0 }));
- }
- throw new error_1.MongoInvalidArgumentError("bulkWrite only supports insertOne, updateOne, updateMany, deleteOne, deleteMany");
- }
- get bsonOptions() {
- return this.s.bsonOptions;
- }
- get writeConcern() {
- return this.s.writeConcern;
- }
- get batches() {
- const batches = [...this.s.batches];
- if (this.isOrdered) {
- if (this.s.currentBatch)
- batches.push(this.s.currentBatch);
- } else {
- if (this.s.currentInsertBatch)
- batches.push(this.s.currentInsertBatch);
- if (this.s.currentUpdateBatch)
- batches.push(this.s.currentUpdateBatch);
- if (this.s.currentRemoveBatch)
- batches.push(this.s.currentRemoveBatch);
- }
- return batches;
- }
- async execute(options = {}) {
- if (this.s.executed) {
- throw new error_1.MongoBatchReExecutionError();
- }
- const writeConcern = write_concern_1.WriteConcern.fromOptions(options);
- if (writeConcern) {
- this.s.writeConcern = writeConcern;
- }
- if (this.isOrdered) {
- if (this.s.currentBatch)
- this.s.batches.push(this.s.currentBatch);
- } else {
- if (this.s.currentInsertBatch)
- this.s.batches.push(this.s.currentInsertBatch);
- if (this.s.currentUpdateBatch)
- this.s.batches.push(this.s.currentUpdateBatch);
- if (this.s.currentRemoveBatch)
- this.s.batches.push(this.s.currentRemoveBatch);
- }
- if (this.s.batches.length === 0) {
- throw new error_1.MongoInvalidArgumentError("Invalid BulkOperation, Batch cannot be empty");
- }
- this.s.executed = true;
- const finalOptions = { ...this.s.options, ...options };
- const operation = new BulkWriteShimOperation(this, finalOptions);
- return (0, execute_operation_1.executeOperation)(this.s.collection.client, operation);
- }
- /**
- * Handles the write error before executing commands
- * @internal
- */
- handleWriteError(callback, writeResult) {
- if (this.s.bulkResult.writeErrors.length > 0) {
- const msg = this.s.bulkResult.writeErrors[0].errmsg ? this.s.bulkResult.writeErrors[0].errmsg : "write operation failed";
- callback(new MongoBulkWriteError({
- message: msg,
- code: this.s.bulkResult.writeErrors[0].code,
- writeErrors: this.s.bulkResult.writeErrors
- }, writeResult));
- return true;
- }
- const writeConcernError = writeResult.getWriteConcernError();
- if (writeConcernError) {
- callback(new MongoBulkWriteError(writeConcernError, writeResult));
- return true;
- }
- return false;
- }
- };
- exports2.BulkOperationBase = BulkOperationBase;
- Object.defineProperty(BulkOperationBase.prototype, "length", {
- enumerable: true,
- get() {
- return this.s.currentIndex;
- }
- });
- function shouldForceServerObjectId(bulkOperation) {
- var _a, _b;
- if (typeof bulkOperation.s.options.forceServerObjectId === "boolean") {
- return bulkOperation.s.options.forceServerObjectId;
- }
- if (typeof ((_a = bulkOperation.s.collection.s.db.options) == null ? void 0 : _a.forceServerObjectId) === "boolean") {
- return (_b = bulkOperation.s.collection.s.db.options) == null ? void 0 : _b.forceServerObjectId;
- }
- return false;
- }
- function isInsertBatch(batch) {
- return batch.batchType === exports2.BatchType.INSERT;
- }
- function isUpdateBatch(batch) {
- return batch.batchType === exports2.BatchType.UPDATE;
- }
- function isDeleteBatch(batch) {
- return batch.batchType === exports2.BatchType.DELETE;
- }
- function buildCurrentOp(bulkOp) {
- let { currentOp } = bulkOp.s;
- bulkOp.s.currentOp = void 0;
- if (!currentOp)
- currentOp = {};
- return currentOp;
- }
- }
- });
- // node_modules/mongodb/lib/bulk/ordered.js
- var require_ordered = __commonJS({
- "node_modules/mongodb/lib/bulk/ordered.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.OrderedBulkOperation = void 0;
- var BSON = require_bson2();
- var error_1 = require_error();
- var common_1 = require_common2();
- var OrderedBulkOperation = class extends common_1.BulkOperationBase {
- /** @internal */
- constructor(collection, options) {
- super(collection, options, true);
- }
- addToOperationsList(batchType, document) {
- const bsonSize = BSON.calculateObjectSize(document, {
- checkKeys: false,
- // Since we don't know what the user selected for BSON options here,
- // err on the safe side, and check the size with ignoreUndefined: false.
- ignoreUndefined: false
- });
- if (bsonSize >= this.s.maxBsonObjectSize)
- throw new error_1.MongoInvalidArgumentError(`Document is larger than the maximum size ${this.s.maxBsonObjectSize}`);
- if (this.s.currentBatch == null) {
- this.s.currentBatch = new common_1.Batch(batchType, this.s.currentIndex);
- }
- const maxKeySize = this.s.maxKeySize;
- if (
- // New batch if we exceed the max batch op size
- this.s.currentBatchSize + 1 >= this.s.maxWriteBatchSize || // New batch if we exceed the maxBatchSizeBytes. Only matters if batch already has a doc,
- // since we can't sent an empty batch
- this.s.currentBatchSize > 0 && this.s.currentBatchSizeBytes + maxKeySize + bsonSize >= this.s.maxBatchSizeBytes || // New batch if the new op does not have the same op type as the current batch
- this.s.currentBatch.batchType !== batchType
- ) {
- this.s.batches.push(this.s.currentBatch);
- this.s.currentBatch = new common_1.Batch(batchType, this.s.currentIndex);
- this.s.currentBatchSize = 0;
- this.s.currentBatchSizeBytes = 0;
- }
- if (batchType === common_1.BatchType.INSERT) {
- this.s.bulkResult.insertedIds.push({
- index: this.s.currentIndex,
- _id: document._id
- });
- }
- if (Array.isArray(document)) {
- throw new error_1.MongoInvalidArgumentError("Operation passed in cannot be an Array");
- }
- this.s.currentBatch.originalIndexes.push(this.s.currentIndex);
- this.s.currentBatch.operations.push(document);
- this.s.currentBatchSize += 1;
- this.s.currentBatchSizeBytes += maxKeySize + bsonSize;
- this.s.currentIndex += 1;
- return this;
- }
- };
- exports2.OrderedBulkOperation = OrderedBulkOperation;
- }
- });
- // node_modules/mongodb/lib/bulk/unordered.js
- var require_unordered = __commonJS({
- "node_modules/mongodb/lib/bulk/unordered.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.UnorderedBulkOperation = void 0;
- var BSON = require_bson2();
- var error_1 = require_error();
- var common_1 = require_common2();
- var UnorderedBulkOperation = class extends common_1.BulkOperationBase {
- /** @internal */
- constructor(collection, options) {
- super(collection, options, false);
- }
- handleWriteError(callback, writeResult) {
- if (this.s.batches.length) {
- return false;
- }
- return super.handleWriteError(callback, writeResult);
- }
- addToOperationsList(batchType, document) {
- const bsonSize = BSON.calculateObjectSize(document, {
- checkKeys: false,
- // Since we don't know what the user selected for BSON options here,
- // err on the safe side, and check the size with ignoreUndefined: false.
- ignoreUndefined: false
- });
- if (bsonSize >= this.s.maxBsonObjectSize) {
- throw new error_1.MongoInvalidArgumentError(`Document is larger than the maximum size ${this.s.maxBsonObjectSize}`);
- }
- this.s.currentBatch = void 0;
- if (batchType === common_1.BatchType.INSERT) {
- this.s.currentBatch = this.s.currentInsertBatch;
- } else if (batchType === common_1.BatchType.UPDATE) {
- this.s.currentBatch = this.s.currentUpdateBatch;
- } else if (batchType === common_1.BatchType.DELETE) {
- this.s.currentBatch = this.s.currentRemoveBatch;
- }
- const maxKeySize = this.s.maxKeySize;
- if (this.s.currentBatch == null) {
- this.s.currentBatch = new common_1.Batch(batchType, this.s.currentIndex);
- }
- if (
- // New batch if we exceed the max batch op size
- this.s.currentBatch.size + 1 >= this.s.maxWriteBatchSize || // New batch if we exceed the maxBatchSizeBytes. Only matters if batch already has a doc,
- // since we can't sent an empty batch
- this.s.currentBatch.size > 0 && this.s.currentBatch.sizeBytes + maxKeySize + bsonSize >= this.s.maxBatchSizeBytes || // New batch if the new op does not have the same op type as the current batch
- this.s.currentBatch.batchType !== batchType
- ) {
- this.s.batches.push(this.s.currentBatch);
- this.s.currentBatch = new common_1.Batch(batchType, this.s.currentIndex);
- }
- if (Array.isArray(document)) {
- throw new error_1.MongoInvalidArgumentError("Operation passed in cannot be an Array");
- }
- this.s.currentBatch.operations.push(document);
- this.s.currentBatch.originalIndexes.push(this.s.currentIndex);
- this.s.currentIndex = this.s.currentIndex + 1;
- if (batchType === common_1.BatchType.INSERT) {
- this.s.currentInsertBatch = this.s.currentBatch;
- this.s.bulkResult.insertedIds.push({
- index: this.s.bulkResult.insertedIds.length,
- _id: document._id
- });
- } else if (batchType === common_1.BatchType.UPDATE) {
- this.s.currentUpdateBatch = this.s.currentBatch;
- } else if (batchType === common_1.BatchType.DELETE) {
- this.s.currentRemoveBatch = this.s.currentBatch;
- }
- this.s.currentBatch.size += 1;
- this.s.currentBatch.sizeBytes += maxKeySize + bsonSize;
- return this;
- }
- };
- exports2.UnorderedBulkOperation = UnorderedBulkOperation;
- }
- });
- // node_modules/mongodb/lib/operations/aggregate.js
- var require_aggregate = __commonJS({
- "node_modules/mongodb/lib/operations/aggregate.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AggregateOperation = exports2.DB_AGGREGATE_COLLECTION = void 0;
- var error_1 = require_error();
- var utils_1 = require_utils();
- var write_concern_1 = require_write_concern();
- var command_1 = require_command();
- var operation_1 = require_operation();
- exports2.DB_AGGREGATE_COLLECTION = 1;
- var MIN_WIRE_VERSION_$OUT_READ_CONCERN_SUPPORT = 8;
- var AggregateOperation = class extends command_1.CommandCallbackOperation {
- constructor(ns, pipeline, options) {
- super(void 0, { ...options, dbName: ns.db });
- this.options = { ...options };
- this.target = ns.collection || exports2.DB_AGGREGATE_COLLECTION;
- this.pipeline = pipeline;
- this.hasWriteStage = false;
- if (typeof (options == null ? void 0 : options.out) === "string") {
- this.pipeline = this.pipeline.concat({ $out: options.out });
- this.hasWriteStage = true;
- } else if (pipeline.length > 0) {
- const finalStage = pipeline[pipeline.length - 1];
- if (finalStage.$out || finalStage.$merge) {
- this.hasWriteStage = true;
- }
- }
- if (this.hasWriteStage) {
- this.trySecondaryWrite = true;
- } else {
- delete this.options.writeConcern;
- }
- if (this.explain && this.writeConcern) {
- throw new error_1.MongoInvalidArgumentError('Option "explain" cannot be used on an aggregate call with writeConcern');
- }
- if ((options == null ? void 0 : options.cursor) != null && typeof options.cursor !== "object") {
- throw new error_1.MongoInvalidArgumentError("Cursor options must be an object");
- }
- }
- get canRetryRead() {
- return !this.hasWriteStage;
- }
- addToPipeline(stage) {
- this.pipeline.push(stage);
- }
- executeCallback(server, session, callback) {
- const options = this.options;
- const serverWireVersion = (0, utils_1.maxWireVersion)(server);
- const command = { aggregate: this.target, pipeline: this.pipeline };
- if (this.hasWriteStage && serverWireVersion < MIN_WIRE_VERSION_$OUT_READ_CONCERN_SUPPORT) {
- this.readConcern = void 0;
- }
- if (this.hasWriteStage && this.writeConcern) {
- write_concern_1.WriteConcern.apply(command, this.writeConcern);
- }
- if (options.bypassDocumentValidation === true) {
- command.bypassDocumentValidation = options.bypassDocumentValidation;
- }
- if (typeof options.allowDiskUse === "boolean") {
- command.allowDiskUse = options.allowDiskUse;
- }
- if (options.hint) {
- command.hint = options.hint;
- }
- if (options.let) {
- command.let = options.let;
- }
- if (options.comment !== void 0) {
- command.comment = options.comment;
- }
- command.cursor = options.cursor || {};
- if (options.batchSize && !this.hasWriteStage) {
- command.cursor.batchSize = options.batchSize;
- }
- super.executeCommandCallback(server, session, command, callback);
- }
- };
- exports2.AggregateOperation = AggregateOperation;
- (0, operation_1.defineAspects)(AggregateOperation, [
- operation_1.Aspect.READ_OPERATION,
- operation_1.Aspect.RETRYABLE,
- operation_1.Aspect.EXPLAINABLE,
- operation_1.Aspect.CURSOR_CREATING
- ]);
- }
- });
- // node_modules/mongodb/lib/mongo_types.js
- var require_mongo_types = __commonJS({
- "node_modules/mongodb/lib/mongo_types.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.CancellationToken = exports2.TypedEventEmitter = void 0;
- var events_1 = require("events");
- var TypedEventEmitter = class extends events_1.EventEmitter {
- /** @internal */
- emitAndLog(event, ...args) {
- var _a;
- this.emit(event, ...args);
- if (this.component)
- (_a = this.mongoLogger) == null ? void 0 : _a.debug(this.component, args[0]);
- }
- };
- exports2.TypedEventEmitter = TypedEventEmitter;
- var CancellationToken = class extends TypedEventEmitter {
- };
- exports2.CancellationToken = CancellationToken;
- }
- });
- // node_modules/mongodb/lib/operations/get_more.js
- var require_get_more = __commonJS({
- "node_modules/mongodb/lib/operations/get_more.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.GetMoreOperation = void 0;
- var error_1 = require_error();
- var utils_1 = require_utils();
- var operation_1 = require_operation();
- var GetMoreOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(ns, cursorId, server, options) {
- super(options);
- this.options = options;
- this.ns = ns;
- this.cursorId = cursorId;
- this.server = server;
- }
- /**
- * Although there is a server already associated with the get more operation, the signature
- * for execute passes a server so we will just use that one.
- */
- executeCallback(server, session, callback) {
- if (server !== this.server) {
- return callback(new error_1.MongoRuntimeError("Getmore must run on the same server operation began on"));
- }
- if (this.cursorId == null || this.cursorId.isZero()) {
- return callback(new error_1.MongoRuntimeError("Unable to iterate cursor with no id"));
- }
- const collection = this.ns.collection;
- if (collection == null) {
- return callback(new error_1.MongoRuntimeError("A collection name must be determined before getMore"));
- }
- const getMoreCmd = {
- getMore: this.cursorId,
- collection
- };
- if (typeof this.options.batchSize === "number") {
- getMoreCmd.batchSize = Math.abs(this.options.batchSize);
- }
- if (typeof this.options.maxAwaitTimeMS === "number") {
- getMoreCmd.maxTimeMS = this.options.maxAwaitTimeMS;
- }
- if (this.options.comment !== void 0 && (0, utils_1.maxWireVersion)(server) >= 9) {
- getMoreCmd.comment = this.options.comment;
- }
- const commandOptions = {
- returnFieldSelector: null,
- documentsReturnedIn: "nextBatch",
- ...this.options
- };
- server.command(this.ns, getMoreCmd, commandOptions, callback);
- }
- };
- exports2.GetMoreOperation = GetMoreOperation;
- (0, operation_1.defineAspects)(GetMoreOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.MUST_SELECT_SAME_SERVER]);
- }
- });
- // node_modules/mongodb/lib/operations/kill_cursors.js
- var require_kill_cursors = __commonJS({
- "node_modules/mongodb/lib/operations/kill_cursors.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.KillCursorsOperation = void 0;
- var error_1 = require_error();
- var operation_1 = require_operation();
- var KillCursorsOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(cursorId, ns, server, options) {
- super(options);
- this.ns = ns;
- this.cursorId = cursorId;
- this.server = server;
- }
- executeCallback(server, session, callback) {
- if (server !== this.server) {
- return callback(new error_1.MongoRuntimeError("Killcursor must run on the same server operation began on"));
- }
- const killCursors = this.ns.collection;
- if (killCursors == null) {
- return callback(new error_1.MongoRuntimeError("A collection name must be determined before killCursors"));
- }
- const killCursorsCommand = {
- killCursors,
- cursors: [this.cursorId]
- };
- server.command(this.ns, killCursorsCommand, { session }, () => callback());
- }
- };
- exports2.KillCursorsOperation = KillCursorsOperation;
- (0, operation_1.defineAspects)(KillCursorsOperation, [operation_1.Aspect.MUST_SELECT_SAME_SERVER]);
- }
- });
- // node_modules/mongodb/lib/cmap/metrics.js
- var require_metrics = __commonJS({
- "node_modules/mongodb/lib/cmap/metrics.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ConnectionPoolMetrics = void 0;
- var ConnectionPoolMetrics = class _ConnectionPoolMetrics {
- constructor() {
- this.txnConnections = 0;
- this.cursorConnections = 0;
- this.otherConnections = 0;
- }
- /**
- * Mark a connection as pinned for a specific operation.
- */
- markPinned(pinType) {
- if (pinType === _ConnectionPoolMetrics.TXN) {
- this.txnConnections += 1;
- } else if (pinType === _ConnectionPoolMetrics.CURSOR) {
- this.cursorConnections += 1;
- } else {
- this.otherConnections += 1;
- }
- }
- /**
- * Unmark a connection as pinned for an operation.
- */
- markUnpinned(pinType) {
- if (pinType === _ConnectionPoolMetrics.TXN) {
- this.txnConnections -= 1;
- } else if (pinType === _ConnectionPoolMetrics.CURSOR) {
- this.cursorConnections -= 1;
- } else {
- this.otherConnections -= 1;
- }
- }
- /**
- * Return information about the cmap metrics as a string.
- */
- info(maxPoolSize) {
- return `Timed out while checking out a connection from connection pool: maxPoolSize: ${maxPoolSize}, connections in use by cursors: ${this.cursorConnections}, connections in use by transactions: ${this.txnConnections}, connections in use by other operations: ${this.otherConnections}`;
- }
- /**
- * Reset the metrics to the initial values.
- */
- reset() {
- this.txnConnections = 0;
- this.cursorConnections = 0;
- this.otherConnections = 0;
- }
- };
- ConnectionPoolMetrics.TXN = "txn";
- ConnectionPoolMetrics.CURSOR = "cursor";
- ConnectionPoolMetrics.OTHER = "other";
- exports2.ConnectionPoolMetrics = ConnectionPoolMetrics;
- }
- });
- // node_modules/mongodb/lib/sdam/server_description.js
- var require_server_description = __commonJS({
- "node_modules/mongodb/lib/sdam/server_description.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.compareTopologyVersion = exports2.parseServerType = exports2.ServerDescription = void 0;
- var bson_1 = require_bson2();
- var error_1 = require_error();
- var utils_1 = require_utils();
- var common_1 = require_common();
- var WRITABLE_SERVER_TYPES = /* @__PURE__ */ new Set([
- common_1.ServerType.RSPrimary,
- common_1.ServerType.Standalone,
- common_1.ServerType.Mongos,
- common_1.ServerType.LoadBalancer
- ]);
- var DATA_BEARING_SERVER_TYPES = /* @__PURE__ */ new Set([
- common_1.ServerType.RSPrimary,
- common_1.ServerType.RSSecondary,
- common_1.ServerType.Mongos,
- common_1.ServerType.Standalone,
- common_1.ServerType.LoadBalancer
- ]);
- var ServerDescription = class {
- /**
- * Create a ServerDescription
- * @internal
- *
- * @param address - The address of the server
- * @param hello - An optional hello response for this server
- */
- constructor(address, hello, options = {}) {
- var _a, _b, _c, _d, _e, _f;
- if (address == null || address === "") {
- throw new error_1.MongoRuntimeError("ServerDescription must be provided with a non-empty address");
- }
- this.address = typeof address === "string" ? utils_1.HostAddress.fromString(address).toString() : address.toString();
- this.type = parseServerType(hello, options);
- this.hosts = ((_a = hello == null ? void 0 : hello.hosts) == null ? void 0 : _a.map((host) => host.toLowerCase())) ?? [];
- this.passives = ((_b = hello == null ? void 0 : hello.passives) == null ? void 0 : _b.map((host) => host.toLowerCase())) ?? [];
- this.arbiters = ((_c = hello == null ? void 0 : hello.arbiters) == null ? void 0 : _c.map((host) => host.toLowerCase())) ?? [];
- this.tags = (hello == null ? void 0 : hello.tags) ?? {};
- this.minWireVersion = (hello == null ? void 0 : hello.minWireVersion) ?? 0;
- this.maxWireVersion = (hello == null ? void 0 : hello.maxWireVersion) ?? 0;
- this.roundTripTime = (options == null ? void 0 : options.roundTripTime) ?? -1;
- this.lastUpdateTime = (0, utils_1.now)();
- this.lastWriteDate = ((_d = hello == null ? void 0 : hello.lastWrite) == null ? void 0 : _d.lastWriteDate) ?? 0;
- this.error = options.error ?? null;
- this.topologyVersion = ((_e = this.error) == null ? void 0 : _e.topologyVersion) ?? (hello == null ? void 0 : hello.topologyVersion) ?? null;
- this.setName = (hello == null ? void 0 : hello.setName) ?? null;
- this.setVersion = (hello == null ? void 0 : hello.setVersion) ?? null;
- this.electionId = (hello == null ? void 0 : hello.electionId) ?? null;
- this.logicalSessionTimeoutMinutes = (hello == null ? void 0 : hello.logicalSessionTimeoutMinutes) ?? null;
- this.primary = (hello == null ? void 0 : hello.primary) ?? null;
- this.me = ((_f = hello == null ? void 0 : hello.me) == null ? void 0 : _f.toLowerCase()) ?? null;
- this.$clusterTime = (hello == null ? void 0 : hello.$clusterTime) ?? null;
- }
- get hostAddress() {
- return utils_1.HostAddress.fromString(this.address);
- }
- get allHosts() {
- return this.hosts.concat(this.arbiters).concat(this.passives);
- }
- /** Is this server available for reads*/
- get isReadable() {
- return this.type === common_1.ServerType.RSSecondary || this.isWritable;
- }
- /** Is this server data bearing */
- get isDataBearing() {
- return DATA_BEARING_SERVER_TYPES.has(this.type);
- }
- /** Is this server available for writes */
- get isWritable() {
- return WRITABLE_SERVER_TYPES.has(this.type);
- }
- get host() {
- const chopLength = `:${this.port}`.length;
- return this.address.slice(0, -chopLength);
- }
- get port() {
- const port = this.address.split(":").pop();
- return port ? Number.parseInt(port, 10) : 27017;
- }
- /**
- * Determines if another `ServerDescription` is equal to this one per the rules defined
- * in the {@link https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#serverdescription|SDAM spec}
- */
- equals(other) {
- const topologyVersionsEqual = this.topologyVersion === (other == null ? void 0 : other.topologyVersion) || compareTopologyVersion(this.topologyVersion, other == null ? void 0 : other.topologyVersion) === 0;
- const electionIdsEqual = this.electionId != null && (other == null ? void 0 : other.electionId) != null ? (0, utils_1.compareObjectId)(this.electionId, other.electionId) === 0 : this.electionId === (other == null ? void 0 : other.electionId);
- return other != null && (0, utils_1.errorStrictEqual)(this.error, other.error) && this.type === other.type && this.minWireVersion === other.minWireVersion && (0, utils_1.arrayStrictEqual)(this.hosts, other.hosts) && tagsStrictEqual(this.tags, other.tags) && this.setName === other.setName && this.setVersion === other.setVersion && electionIdsEqual && this.primary === other.primary && this.logicalSessionTimeoutMinutes === other.logicalSessionTimeoutMinutes && topologyVersionsEqual;
- }
- };
- exports2.ServerDescription = ServerDescription;
- function parseServerType(hello, options) {
- if (options == null ? void 0 : options.loadBalanced) {
- return common_1.ServerType.LoadBalancer;
- }
- if (!hello || !hello.ok) {
- return common_1.ServerType.Unknown;
- }
- if (hello.isreplicaset) {
- return common_1.ServerType.RSGhost;
- }
- if (hello.msg && hello.msg === "isdbgrid") {
- return common_1.ServerType.Mongos;
- }
- if (hello.setName) {
- if (hello.hidden) {
- return common_1.ServerType.RSOther;
- } else if (hello.isWritablePrimary) {
- return common_1.ServerType.RSPrimary;
- } else if (hello.secondary) {
- return common_1.ServerType.RSSecondary;
- } else if (hello.arbiterOnly) {
- return common_1.ServerType.RSArbiter;
- } else {
- return common_1.ServerType.RSOther;
- }
- }
- return common_1.ServerType.Standalone;
- }
- exports2.parseServerType = parseServerType;
- function tagsStrictEqual(tags, tags2) {
- const tagsKeys = Object.keys(tags);
- const tags2Keys = Object.keys(tags2);
- return tagsKeys.length === tags2Keys.length && tagsKeys.every((key) => tags2[key] === tags[key]);
- }
- function compareTopologyVersion(currentTv, newTv) {
- if (currentTv == null || newTv == null) {
- return -1;
- }
- if (!currentTv.processId.equals(newTv.processId)) {
- return -1;
- }
- const currentCounter = bson_1.Long.isLong(currentTv.counter) ? currentTv.counter : bson_1.Long.fromNumber(currentTv.counter);
- const newCounter = bson_1.Long.isLong(newTv.counter) ? newTv.counter : bson_1.Long.fromNumber(newTv.counter);
- return currentCounter.compare(newCounter);
- }
- exports2.compareTopologyVersion = compareTopologyVersion;
- }
- });
- // node_modules/mongodb/lib/sdam/topology_description.js
- var require_topology_description = __commonJS({
- "node_modules/mongodb/lib/sdam/topology_description.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.TopologyDescription = void 0;
- var WIRE_CONSTANTS = require_constants();
- var error_1 = require_error();
- var utils_1 = require_utils();
- var common_1 = require_common();
- var server_description_1 = require_server_description();
- var MIN_SUPPORTED_SERVER_VERSION = WIRE_CONSTANTS.MIN_SUPPORTED_SERVER_VERSION;
- var MAX_SUPPORTED_SERVER_VERSION = WIRE_CONSTANTS.MAX_SUPPORTED_SERVER_VERSION;
- var MIN_SUPPORTED_WIRE_VERSION = WIRE_CONSTANTS.MIN_SUPPORTED_WIRE_VERSION;
- var MAX_SUPPORTED_WIRE_VERSION = WIRE_CONSTANTS.MAX_SUPPORTED_WIRE_VERSION;
- var MONGOS_OR_UNKNOWN = /* @__PURE__ */ new Set([common_1.ServerType.Mongos, common_1.ServerType.Unknown]);
- var MONGOS_OR_STANDALONE = /* @__PURE__ */ new Set([common_1.ServerType.Mongos, common_1.ServerType.Standalone]);
- var NON_PRIMARY_RS_MEMBERS = /* @__PURE__ */ new Set([
- common_1.ServerType.RSSecondary,
- common_1.ServerType.RSArbiter,
- common_1.ServerType.RSOther
- ]);
- var TopologyDescription = class _TopologyDescription {
- /**
- * Create a TopologyDescription
- */
- constructor(topologyType, serverDescriptions = null, setName = null, maxSetVersion = null, maxElectionId = null, commonWireVersion = null, options = null) {
- options = options ?? {};
- this.type = topologyType ?? common_1.TopologyType.Unknown;
- this.servers = serverDescriptions ?? /* @__PURE__ */ new Map();
- this.stale = false;
- this.compatible = true;
- this.heartbeatFrequencyMS = options.heartbeatFrequencyMS ?? 0;
- this.localThresholdMS = options.localThresholdMS ?? 15;
- this.setName = setName ?? null;
- this.maxElectionId = maxElectionId ?? null;
- this.maxSetVersion = maxSetVersion ?? null;
- this.commonWireVersion = commonWireVersion ?? 0;
- for (const serverDescription of this.servers.values()) {
- if (serverDescription.type === common_1.ServerType.Unknown || serverDescription.type === common_1.ServerType.LoadBalancer) {
- continue;
- }
- if (serverDescription.minWireVersion > MAX_SUPPORTED_WIRE_VERSION) {
- this.compatible = false;
- this.compatibilityError = `Server at ${serverDescription.address} requires wire version ${serverDescription.minWireVersion}, but this version of the driver only supports up to ${MAX_SUPPORTED_WIRE_VERSION} (MongoDB ${MAX_SUPPORTED_SERVER_VERSION})`;
- }
- if (serverDescription.maxWireVersion < MIN_SUPPORTED_WIRE_VERSION) {
- this.compatible = false;
- this.compatibilityError = `Server at ${serverDescription.address} reports wire version ${serverDescription.maxWireVersion}, but this version of the driver requires at least ${MIN_SUPPORTED_WIRE_VERSION} (MongoDB ${MIN_SUPPORTED_SERVER_VERSION}).`;
- break;
- }
- }
- this.logicalSessionTimeoutMinutes = null;
- for (const [, server] of this.servers) {
- if (server.isReadable) {
- if (server.logicalSessionTimeoutMinutes == null) {
- this.logicalSessionTimeoutMinutes = null;
- break;
- }
- if (this.logicalSessionTimeoutMinutes == null) {
- this.logicalSessionTimeoutMinutes = server.logicalSessionTimeoutMinutes;
- continue;
- }
- this.logicalSessionTimeoutMinutes = Math.min(this.logicalSessionTimeoutMinutes, server.logicalSessionTimeoutMinutes);
- }
- }
- }
- /**
- * Returns a new TopologyDescription based on the SrvPollingEvent
- * @internal
- */
- updateFromSrvPollingEvent(ev, srvMaxHosts = 0) {
- const incomingHostnames = ev.hostnames();
- const currentHostnames = new Set(this.servers.keys());
- const hostnamesToAdd = new Set(incomingHostnames);
- const hostnamesToRemove = /* @__PURE__ */ new Set();
- for (const hostname of currentHostnames) {
- hostnamesToAdd.delete(hostname);
- if (!incomingHostnames.has(hostname)) {
- hostnamesToRemove.add(hostname);
- }
- }
- if (hostnamesToAdd.size === 0 && hostnamesToRemove.size === 0) {
- return this;
- }
- const serverDescriptions = new Map(this.servers);
- for (const removedHost of hostnamesToRemove) {
- serverDescriptions.delete(removedHost);
- }
- if (hostnamesToAdd.size > 0) {
- if (srvMaxHosts === 0) {
- for (const hostToAdd of hostnamesToAdd) {
- serverDescriptions.set(hostToAdd, new server_description_1.ServerDescription(hostToAdd));
- }
- } else if (serverDescriptions.size < srvMaxHosts) {
- const selectedHosts = (0, utils_1.shuffle)(hostnamesToAdd, srvMaxHosts - serverDescriptions.size);
- for (const selectedHostToAdd of selectedHosts) {
- serverDescriptions.set(selectedHostToAdd, new server_description_1.ServerDescription(selectedHostToAdd));
- }
- }
- }
- return new _TopologyDescription(this.type, serverDescriptions, this.setName, this.maxSetVersion, this.maxElectionId, this.commonWireVersion, { heartbeatFrequencyMS: this.heartbeatFrequencyMS, localThresholdMS: this.localThresholdMS });
- }
- /**
- * Returns a copy of this description updated with a given ServerDescription
- * @internal
- */
- update(serverDescription) {
- const address = serverDescription.address;
- let { type: topologyType, setName, maxSetVersion, maxElectionId, commonWireVersion } = this;
- const serverType = serverDescription.type;
- const serverDescriptions = new Map(this.servers);
- if (serverDescription.maxWireVersion !== 0) {
- if (commonWireVersion == null) {
- commonWireVersion = serverDescription.maxWireVersion;
- } else {
- commonWireVersion = Math.min(commonWireVersion, serverDescription.maxWireVersion);
- }
- }
- if (typeof serverDescription.setName === "string" && typeof setName === "string" && serverDescription.setName !== setName) {
- if (topologyType === common_1.TopologyType.Single) {
- serverDescription = new server_description_1.ServerDescription(address);
- } else {
- serverDescriptions.delete(address);
- }
- }
- serverDescriptions.set(address, serverDescription);
- if (topologyType === common_1.TopologyType.Single) {
- return new _TopologyDescription(common_1.TopologyType.Single, serverDescriptions, setName, maxSetVersion, maxElectionId, commonWireVersion, { heartbeatFrequencyMS: this.heartbeatFrequencyMS, localThresholdMS: this.localThresholdMS });
- }
- if (topologyType === common_1.TopologyType.Unknown) {
- if (serverType === common_1.ServerType.Standalone && this.servers.size !== 1) {
- serverDescriptions.delete(address);
- } else {
- topologyType = topologyTypeForServerType(serverType);
- }
- }
- if (topologyType === common_1.TopologyType.Sharded) {
- if (!MONGOS_OR_UNKNOWN.has(serverType)) {
- serverDescriptions.delete(address);
- }
- }
- if (topologyType === common_1.TopologyType.ReplicaSetNoPrimary) {
- if (MONGOS_OR_STANDALONE.has(serverType)) {
- serverDescriptions.delete(address);
- }
- if (serverType === common_1.ServerType.RSPrimary) {
- const result = updateRsFromPrimary(serverDescriptions, serverDescription, setName, maxSetVersion, maxElectionId);
- topologyType = result[0];
- setName = result[1];
- maxSetVersion = result[2];
- maxElectionId = result[3];
- } else if (NON_PRIMARY_RS_MEMBERS.has(serverType)) {
- const result = updateRsNoPrimaryFromMember(serverDescriptions, serverDescription, setName);
- topologyType = result[0];
- setName = result[1];
- }
- }
- if (topologyType === common_1.TopologyType.ReplicaSetWithPrimary) {
- if (MONGOS_OR_STANDALONE.has(serverType)) {
- serverDescriptions.delete(address);
- topologyType = checkHasPrimary(serverDescriptions);
- } else if (serverType === common_1.ServerType.RSPrimary) {
- const result = updateRsFromPrimary(serverDescriptions, serverDescription, setName, maxSetVersion, maxElectionId);
- topologyType = result[0];
- setName = result[1];
- maxSetVersion = result[2];
- maxElectionId = result[3];
- } else if (NON_PRIMARY_RS_MEMBERS.has(serverType)) {
- topologyType = updateRsWithPrimaryFromMember(serverDescriptions, serverDescription, setName);
- } else {
- topologyType = checkHasPrimary(serverDescriptions);
- }
- }
- return new _TopologyDescription(topologyType, serverDescriptions, setName, maxSetVersion, maxElectionId, commonWireVersion, { heartbeatFrequencyMS: this.heartbeatFrequencyMS, localThresholdMS: this.localThresholdMS });
- }
- get error() {
- const descriptionsWithError = Array.from(this.servers.values()).filter((sd) => sd.error);
- if (descriptionsWithError.length > 0) {
- return descriptionsWithError[0].error;
- }
- return null;
- }
- /**
- * Determines if the topology description has any known servers
- */
- get hasKnownServers() {
- return Array.from(this.servers.values()).some((sd) => sd.type !== common_1.ServerType.Unknown);
- }
- /**
- * Determines if this topology description has a data-bearing server available.
- */
- get hasDataBearingServers() {
- return Array.from(this.servers.values()).some((sd) => sd.isDataBearing);
- }
- /**
- * Determines if the topology has a definition for the provided address
- * @internal
- */
- hasServer(address) {
- return this.servers.has(address);
- }
- };
- exports2.TopologyDescription = TopologyDescription;
- function topologyTypeForServerType(serverType) {
- switch (serverType) {
- case common_1.ServerType.Standalone:
- return common_1.TopologyType.Single;
- case common_1.ServerType.Mongos:
- return common_1.TopologyType.Sharded;
- case common_1.ServerType.RSPrimary:
- return common_1.TopologyType.ReplicaSetWithPrimary;
- case common_1.ServerType.RSOther:
- case common_1.ServerType.RSSecondary:
- return common_1.TopologyType.ReplicaSetNoPrimary;
- default:
- return common_1.TopologyType.Unknown;
- }
- }
- function updateRsFromPrimary(serverDescriptions, serverDescription, setName = null, maxSetVersion = null, maxElectionId = null) {
- setName = setName || serverDescription.setName;
- if (setName !== serverDescription.setName) {
- serverDescriptions.delete(serverDescription.address);
- return [checkHasPrimary(serverDescriptions), setName, maxSetVersion, maxElectionId];
- }
- if (serverDescription.maxWireVersion >= 17) {
- const electionIdComparison = (0, utils_1.compareObjectId)(maxElectionId, serverDescription.electionId);
- const maxElectionIdIsEqual = electionIdComparison === 0;
- const maxElectionIdIsLess = electionIdComparison === -1;
- const maxSetVersionIsLessOrEqual = (maxSetVersion ?? -1) <= (serverDescription.setVersion ?? -1);
- if (maxElectionIdIsLess || maxElectionIdIsEqual && maxSetVersionIsLessOrEqual) {
- maxElectionId = serverDescription.electionId;
- maxSetVersion = serverDescription.setVersion;
- } else {
- serverDescriptions.set(serverDescription.address, new server_description_1.ServerDescription(serverDescription.address));
- return [checkHasPrimary(serverDescriptions), setName, maxSetVersion, maxElectionId];
- }
- } else {
- const electionId = serverDescription.electionId ? serverDescription.electionId : null;
- if (serverDescription.setVersion && electionId) {
- if (maxSetVersion && maxElectionId) {
- if (maxSetVersion > serverDescription.setVersion || (0, utils_1.compareObjectId)(maxElectionId, electionId) > 0) {
- serverDescriptions.set(serverDescription.address, new server_description_1.ServerDescription(serverDescription.address));
- return [checkHasPrimary(serverDescriptions), setName, maxSetVersion, maxElectionId];
- }
- }
- maxElectionId = serverDescription.electionId;
- }
- if (serverDescription.setVersion != null && (maxSetVersion == null || serverDescription.setVersion > maxSetVersion)) {
- maxSetVersion = serverDescription.setVersion;
- }
- }
- for (const [address, server] of serverDescriptions) {
- if (server.type === common_1.ServerType.RSPrimary && server.address !== serverDescription.address) {
- serverDescriptions.set(address, new server_description_1.ServerDescription(server.address));
- break;
- }
- }
- serverDescription.allHosts.forEach((address) => {
- if (!serverDescriptions.has(address)) {
- serverDescriptions.set(address, new server_description_1.ServerDescription(address));
- }
- });
- const currentAddresses = Array.from(serverDescriptions.keys());
- const responseAddresses = serverDescription.allHosts;
- currentAddresses.filter((addr) => responseAddresses.indexOf(addr) === -1).forEach((address) => {
- serverDescriptions.delete(address);
- });
- return [checkHasPrimary(serverDescriptions), setName, maxSetVersion, maxElectionId];
- }
- function updateRsWithPrimaryFromMember(serverDescriptions, serverDescription, setName = null) {
- if (setName == null) {
- throw new error_1.MongoRuntimeError('Argument "setName" is required if connected to a replica set');
- }
- if (setName !== serverDescription.setName || serverDescription.me && serverDescription.address !== serverDescription.me) {
- serverDescriptions.delete(serverDescription.address);
- }
- return checkHasPrimary(serverDescriptions);
- }
- function updateRsNoPrimaryFromMember(serverDescriptions, serverDescription, setName = null) {
- const topologyType = common_1.TopologyType.ReplicaSetNoPrimary;
- setName = setName ?? serverDescription.setName;
- if (setName !== serverDescription.setName) {
- serverDescriptions.delete(serverDescription.address);
- return [topologyType, setName];
- }
- serverDescription.allHosts.forEach((address) => {
- if (!serverDescriptions.has(address)) {
- serverDescriptions.set(address, new server_description_1.ServerDescription(address));
- }
- });
- if (serverDescription.me && serverDescription.address !== serverDescription.me) {
- serverDescriptions.delete(serverDescription.address);
- }
- return [topologyType, setName];
- }
- function checkHasPrimary(serverDescriptions) {
- for (const serverDescription of serverDescriptions.values()) {
- if (serverDescription.type === common_1.ServerType.RSPrimary) {
- return common_1.TopologyType.ReplicaSetWithPrimary;
- }
- }
- return common_1.TopologyType.ReplicaSetNoPrimary;
- }
- }
- });
- // node_modules/mongodb/lib/cmap/wire_protocol/shared.js
- var require_shared = __commonJS({
- "node_modules/mongodb/lib/cmap/wire_protocol/shared.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.isSharded = exports2.getReadPreference = void 0;
- var error_1 = require_error();
- var read_preference_1 = require_read_preference();
- var common_1 = require_common();
- var topology_description_1 = require_topology_description();
- function getReadPreference(options) {
- let readPreference = (options == null ? void 0 : options.readPreference) ?? read_preference_1.ReadPreference.primary;
- if (options == null ? void 0 : options.readPreference) {
- readPreference = options.readPreference;
- }
- if (typeof readPreference === "string") {
- readPreference = read_preference_1.ReadPreference.fromString(readPreference);
- }
- if (!(readPreference instanceof read_preference_1.ReadPreference)) {
- throw new error_1.MongoInvalidArgumentError('Option "readPreference" must be a ReadPreference instance');
- }
- return readPreference;
- }
- exports2.getReadPreference = getReadPreference;
- function isSharded(topologyOrServer) {
- if (topologyOrServer == null) {
- return false;
- }
- if (topologyOrServer.description && topologyOrServer.description.type === common_1.ServerType.Mongos) {
- return true;
- }
- if (topologyOrServer.description && topologyOrServer.description instanceof topology_description_1.TopologyDescription) {
- const servers = Array.from(topologyOrServer.description.servers.values());
- return servers.some((server) => server.type === common_1.ServerType.Mongos);
- }
- return false;
- }
- exports2.isSharded = isSharded;
- }
- });
- // node_modules/mongodb/lib/transactions.js
- var require_transactions = __commonJS({
- "node_modules/mongodb/lib/transactions.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.isTransactionCommand = exports2.Transaction = exports2.TxnState = void 0;
- var error_1 = require_error();
- var read_concern_1 = require_read_concern();
- var read_preference_1 = require_read_preference();
- var write_concern_1 = require_write_concern();
- exports2.TxnState = Object.freeze({
- NO_TRANSACTION: "NO_TRANSACTION",
- STARTING_TRANSACTION: "STARTING_TRANSACTION",
- TRANSACTION_IN_PROGRESS: "TRANSACTION_IN_PROGRESS",
- TRANSACTION_COMMITTED: "TRANSACTION_COMMITTED",
- TRANSACTION_COMMITTED_EMPTY: "TRANSACTION_COMMITTED_EMPTY",
- TRANSACTION_ABORTED: "TRANSACTION_ABORTED"
- });
- var stateMachine = {
- [exports2.TxnState.NO_TRANSACTION]: [exports2.TxnState.NO_TRANSACTION, exports2.TxnState.STARTING_TRANSACTION],
- [exports2.TxnState.STARTING_TRANSACTION]: [
- exports2.TxnState.TRANSACTION_IN_PROGRESS,
- exports2.TxnState.TRANSACTION_COMMITTED,
- exports2.TxnState.TRANSACTION_COMMITTED_EMPTY,
- exports2.TxnState.TRANSACTION_ABORTED
- ],
- [exports2.TxnState.TRANSACTION_IN_PROGRESS]: [
- exports2.TxnState.TRANSACTION_IN_PROGRESS,
- exports2.TxnState.TRANSACTION_COMMITTED,
- exports2.TxnState.TRANSACTION_ABORTED
- ],
- [exports2.TxnState.TRANSACTION_COMMITTED]: [
- exports2.TxnState.TRANSACTION_COMMITTED,
- exports2.TxnState.TRANSACTION_COMMITTED_EMPTY,
- exports2.TxnState.STARTING_TRANSACTION,
- exports2.TxnState.NO_TRANSACTION
- ],
- [exports2.TxnState.TRANSACTION_ABORTED]: [exports2.TxnState.STARTING_TRANSACTION, exports2.TxnState.NO_TRANSACTION],
- [exports2.TxnState.TRANSACTION_COMMITTED_EMPTY]: [
- exports2.TxnState.TRANSACTION_COMMITTED_EMPTY,
- exports2.TxnState.NO_TRANSACTION
- ]
- };
- var ACTIVE_STATES = /* @__PURE__ */ new Set([
- exports2.TxnState.STARTING_TRANSACTION,
- exports2.TxnState.TRANSACTION_IN_PROGRESS
- ]);
- var COMMITTED_STATES = /* @__PURE__ */ new Set([
- exports2.TxnState.TRANSACTION_COMMITTED,
- exports2.TxnState.TRANSACTION_COMMITTED_EMPTY,
- exports2.TxnState.TRANSACTION_ABORTED
- ]);
- var Transaction = class {
- /** Create a transaction @internal */
- constructor(options) {
- options = options ?? {};
- this.state = exports2.TxnState.NO_TRANSACTION;
- this.options = {};
- const writeConcern = write_concern_1.WriteConcern.fromOptions(options);
- if (writeConcern) {
- if (writeConcern.w === 0) {
- throw new error_1.MongoTransactionError("Transactions do not support unacknowledged write concern");
- }
- this.options.writeConcern = writeConcern;
- }
- if (options.readConcern) {
- this.options.readConcern = read_concern_1.ReadConcern.fromOptions(options);
- }
- if (options.readPreference) {
- this.options.readPreference = read_preference_1.ReadPreference.fromOptions(options);
- }
- if (options.maxCommitTimeMS) {
- this.options.maxTimeMS = options.maxCommitTimeMS;
- }
- this._pinnedServer = void 0;
- this._recoveryToken = void 0;
- }
- /** @internal */
- get server() {
- return this._pinnedServer;
- }
- get recoveryToken() {
- return this._recoveryToken;
- }
- get isPinned() {
- return !!this.server;
- }
- /** @returns Whether the transaction has started */
- get isStarting() {
- return this.state === exports2.TxnState.STARTING_TRANSACTION;
- }
- /**
- * @returns Whether this session is presently in a transaction
- */
- get isActive() {
- return ACTIVE_STATES.has(this.state);
- }
- get isCommitted() {
- return COMMITTED_STATES.has(this.state);
- }
- /**
- * Transition the transaction in the state machine
- * @internal
- * @param nextState - The new state to transition to
- */
- transition(nextState) {
- const nextStates = stateMachine[this.state];
- if (nextStates && nextStates.includes(nextState)) {
- this.state = nextState;
- if (this.state === exports2.TxnState.NO_TRANSACTION || this.state === exports2.TxnState.STARTING_TRANSACTION || this.state === exports2.TxnState.TRANSACTION_ABORTED) {
- this.unpinServer();
- }
- return;
- }
- throw new error_1.MongoRuntimeError(`Attempted illegal state transition from [${this.state}] to [${nextState}]`);
- }
- /** @internal */
- pinServer(server) {
- if (this.isActive) {
- this._pinnedServer = server;
- }
- }
- /** @internal */
- unpinServer() {
- this._pinnedServer = void 0;
- }
- };
- exports2.Transaction = Transaction;
- function isTransactionCommand(command) {
- return !!(command.commitTransaction || command.abortTransaction);
- }
- exports2.isTransactionCommand = isTransactionCommand;
- }
- });
- // node_modules/mongodb/lib/sessions.js
- var require_sessions = __commonJS({
- "node_modules/mongodb/lib/sessions.js"(exports2) {
- "use strict";
- var _a;
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.updateSessionFromResponse = exports2.applySession = exports2.ServerSessionPool = exports2.ServerSession = exports2.maybeClearPinnedConnection = exports2.ClientSession = void 0;
- var util_1 = require("util");
- var bson_1 = require_bson2();
- var metrics_1 = require_metrics();
- var shared_1 = require_shared();
- var constants_1 = require_constants2();
- var error_1 = require_error();
- var mongo_types_1 = require_mongo_types();
- var execute_operation_1 = require_execute_operation();
- var run_command_1 = require_run_command();
- var read_concern_1 = require_read_concern();
- var read_preference_1 = require_read_preference();
- var common_1 = require_common();
- var transactions_1 = require_transactions();
- var utils_1 = require_utils();
- var write_concern_1 = require_write_concern();
- var minWireVersionForShardedTransactions = 8;
- var kServerSession = Symbol("serverSession");
- var kSnapshotTime = Symbol("snapshotTime");
- var kSnapshotEnabled = Symbol("snapshotEnabled");
- var kPinnedConnection = Symbol("pinnedConnection");
- var kTxnNumberIncrement = Symbol("txnNumberIncrement");
- var ClientSession = class _ClientSession extends mongo_types_1.TypedEventEmitter {
- /**
- * Create a client session.
- * @internal
- * @param client - The current client
- * @param sessionPool - The server session pool (Internal Class)
- * @param options - Optional settings
- * @param clientOptions - Optional settings provided when creating a MongoClient
- */
- constructor(client, sessionPool, options, clientOptions) {
- super();
- this[_a] = false;
- if (client == null) {
- throw new error_1.MongoRuntimeError("ClientSession requires a MongoClient");
- }
- if (sessionPool == null || !(sessionPool instanceof ServerSessionPool)) {
- throw new error_1.MongoRuntimeError("ClientSession requires a ServerSessionPool");
- }
- options = options ?? {};
- if (options.snapshot === true) {
- this[kSnapshotEnabled] = true;
- if (options.causalConsistency === true) {
- throw new error_1.MongoInvalidArgumentError('Properties "causalConsistency" and "snapshot" are mutually exclusive');
- }
- }
- this.client = client;
- this.sessionPool = sessionPool;
- this.hasEnded = false;
- this.clientOptions = clientOptions;
- this.explicit = !!options.explicit;
- this[kServerSession] = this.explicit ? this.sessionPool.acquire() : null;
- this[kTxnNumberIncrement] = 0;
- const defaultCausalConsistencyValue = this.explicit && options.snapshot !== true;
- this.supports = {
- // if we can enable causal consistency, do so by default
- causalConsistency: options.causalConsistency ?? defaultCausalConsistencyValue
- };
- this.clusterTime = options.initialClusterTime;
- this.operationTime = void 0;
- this.owner = options.owner;
- this.defaultTransactionOptions = Object.assign({}, options.defaultTransactionOptions);
- this.transaction = new transactions_1.Transaction();
- }
- /** The server id associated with this session */
- get id() {
- var _a2;
- return (_a2 = this[kServerSession]) == null ? void 0 : _a2.id;
- }
- get serverSession() {
- let serverSession = this[kServerSession];
- if (serverSession == null) {
- if (this.explicit) {
- throw new error_1.MongoRuntimeError("Unexpected null serverSession for an explicit session");
- }
- if (this.hasEnded) {
- throw new error_1.MongoRuntimeError("Unexpected null serverSession for an ended implicit session");
- }
- serverSession = this.sessionPool.acquire();
- this[kServerSession] = serverSession;
- }
- return serverSession;
- }
- /** Whether or not this session is configured for snapshot reads */
- get snapshotEnabled() {
- return this[kSnapshotEnabled];
- }
- get loadBalanced() {
- var _a2;
- return ((_a2 = this.client.topology) == null ? void 0 : _a2.description.type) === common_1.TopologyType.LoadBalanced;
- }
- /** @internal */
- get pinnedConnection() {
- return this[kPinnedConnection];
- }
- /** @internal */
- pin(conn) {
- if (this[kPinnedConnection]) {
- throw TypeError("Cannot pin multiple connections to the same session");
- }
- this[kPinnedConnection] = conn;
- conn.emit(constants_1.PINNED, this.inTransaction() ? metrics_1.ConnectionPoolMetrics.TXN : metrics_1.ConnectionPoolMetrics.CURSOR);
- }
- /** @internal */
- unpin(options) {
- if (this.loadBalanced) {
- return maybeClearPinnedConnection(this, options);
- }
- this.transaction.unpinServer();
- }
- get isPinned() {
- return this.loadBalanced ? !!this[kPinnedConnection] : this.transaction.isPinned;
- }
- /**
- * Ends this session on the server
- *
- * @param options - Optional settings. Currently reserved for future use
- */
- async endSession(options) {
- try {
- if (this.inTransaction()) {
- await this.abortTransaction();
- }
- if (!this.hasEnded) {
- const serverSession = this[kServerSession];
- if (serverSession != null) {
- this.sessionPool.release(serverSession);
- Object.defineProperty(this, kServerSession, {
- value: ServerSession.clone(serverSession),
- writable: false
- });
- }
- this.hasEnded = true;
- this.emit("ended", this);
- }
- } catch {
- } finally {
- maybeClearPinnedConnection(this, { force: true, ...options });
- }
- }
- /**
- * Advances the operationTime for a ClientSession.
- *
- * @param operationTime - the `BSON.Timestamp` of the operation type it is desired to advance to
- */
- advanceOperationTime(operationTime) {
- if (this.operationTime == null) {
- this.operationTime = operationTime;
- return;
- }
- if (operationTime.greaterThan(this.operationTime)) {
- this.operationTime = operationTime;
- }
- }
- /**
- * Advances the clusterTime for a ClientSession to the provided clusterTime of another ClientSession
- *
- * @param clusterTime - the $clusterTime returned by the server from another session in the form of a document containing the `BSON.Timestamp` clusterTime and signature
- */
- advanceClusterTime(clusterTime) {
- var _a2, _b;
- if (!clusterTime || typeof clusterTime !== "object") {
- throw new error_1.MongoInvalidArgumentError("input cluster time must be an object");
- }
- if (!clusterTime.clusterTime || clusterTime.clusterTime._bsontype !== "Timestamp") {
- throw new error_1.MongoInvalidArgumentError('input cluster time "clusterTime" property must be a valid BSON Timestamp');
- }
- if (!clusterTime.signature || ((_a2 = clusterTime.signature.hash) == null ? void 0 : _a2._bsontype) !== "Binary" || typeof clusterTime.signature.keyId !== "bigint" && typeof clusterTime.signature.keyId !== "number" && ((_b = clusterTime.signature.keyId) == null ? void 0 : _b._bsontype) !== "Long") {
- throw new error_1.MongoInvalidArgumentError('input cluster time must have a valid "signature" property with BSON Binary hash and BSON Long keyId');
- }
- (0, common_1._advanceClusterTime)(this, clusterTime);
- }
- /**
- * Used to determine if this session equals another
- *
- * @param session - The session to compare to
- */
- equals(session) {
- if (!(session instanceof _ClientSession)) {
- return false;
- }
- if (this.id == null || session.id == null) {
- return false;
- }
- return utils_1.ByteUtils.equals(this.id.id.buffer, session.id.id.buffer);
- }
- /**
- * Increment the transaction number on the internal ServerSession
- *
- * @privateRemarks
- * This helper increments a value stored on the client session that will be
- * added to the serverSession's txnNumber upon applying it to a command.
- * This is because the serverSession is lazily acquired after a connection is obtained
- */
- incrementTransactionNumber() {
- this[kTxnNumberIncrement] += 1;
- }
- /** @returns whether this session is currently in a transaction or not */
- inTransaction() {
- return this.transaction.isActive;
- }
- /**
- * Starts a new transaction with the given options.
- *
- * @param options - Options for the transaction
- */
- startTransaction(options) {
- var _a2, _b, _c;
- if (this[kSnapshotEnabled]) {
- throw new error_1.MongoCompatibilityError("Transactions are not supported in snapshot sessions");
- }
- if (this.inTransaction()) {
- throw new error_1.MongoTransactionError("Transaction already in progress");
- }
- if (this.isPinned && this.transaction.isCommitted) {
- this.unpin();
- }
- const topologyMaxWireVersion = (0, utils_1.maxWireVersion)(this.client.topology);
- if ((0, shared_1.isSharded)(this.client.topology) && topologyMaxWireVersion != null && topologyMaxWireVersion < minWireVersionForShardedTransactions) {
- throw new error_1.MongoCompatibilityError("Transactions are not supported on sharded clusters in MongoDB < 4.2.");
- }
- this.incrementTransactionNumber();
- this.transaction = new transactions_1.Transaction({
- readConcern: (options == null ? void 0 : options.readConcern) ?? this.defaultTransactionOptions.readConcern ?? ((_a2 = this.clientOptions) == null ? void 0 : _a2.readConcern),
- writeConcern: (options == null ? void 0 : options.writeConcern) ?? this.defaultTransactionOptions.writeConcern ?? ((_b = this.clientOptions) == null ? void 0 : _b.writeConcern),
- readPreference: (options == null ? void 0 : options.readPreference) ?? this.defaultTransactionOptions.readPreference ?? ((_c = this.clientOptions) == null ? void 0 : _c.readPreference),
- maxCommitTimeMS: (options == null ? void 0 : options.maxCommitTimeMS) ?? this.defaultTransactionOptions.maxCommitTimeMS
- });
- this.transaction.transition(transactions_1.TxnState.STARTING_TRANSACTION);
- }
- /**
- * Commits the currently active transaction in this session.
- */
- async commitTransaction() {
- return endTransactionAsync(this, "commitTransaction");
- }
- /**
- * Aborts the currently active transaction in this session.
- */
- async abortTransaction() {
- return endTransactionAsync(this, "abortTransaction");
- }
- /**
- * This is here to ensure that ClientSession is never serialized to BSON.
- */
- toBSON() {
- throw new error_1.MongoRuntimeError("ClientSession cannot be serialized to BSON.");
- }
- /**
- * Runs a provided callback within a transaction, retrying either the commitTransaction operation
- * or entire transaction as needed (and when the error permits) to better ensure that
- * the transaction can complete successfully.
- *
- * **IMPORTANT:** This method requires the user to return a Promise, and `await` all operations.
- * Any callbacks that do not return a Promise will result in undefined behavior.
- *
- * @remarks
- * This function:
- * - Will return the command response from the final commitTransaction if every operation is successful (can be used as a truthy object)
- * - Will return `undefined` if the transaction is explicitly aborted with `await session.abortTransaction()`
- * - Will throw if one of the operations throws or `throw` statement is used inside the `withTransaction` callback
- *
- * Checkout a descriptive example here:
- * @see https://www.mongodb.com/developer/quickstart/node-transactions/
- *
- * @param fn - callback to run within a transaction
- * @param options - optional settings for the transaction
- * @returns A raw command response or undefined
- */
- async withTransaction(fn, options) {
- const startTime = (0, utils_1.now)();
- return attemptTransaction(this, startTime, fn, options);
- }
- };
- exports2.ClientSession = ClientSession;
- _a = kSnapshotEnabled;
- var MAX_WITH_TRANSACTION_TIMEOUT = 12e4;
- var NON_DETERMINISTIC_WRITE_CONCERN_ERRORS = /* @__PURE__ */ new Set([
- "CannotSatisfyWriteConcern",
- "UnknownReplWriteConcern",
- "UnsatisfiableWriteConcern"
- ]);
- function hasNotTimedOut(startTime, max) {
- return (0, utils_1.calculateDurationInMs)(startTime) < max;
- }
- function isUnknownTransactionCommitResult(err) {
- const isNonDeterministicWriteConcernError = err instanceof error_1.MongoServerError && err.codeName && NON_DETERMINISTIC_WRITE_CONCERN_ERRORS.has(err.codeName);
- return isMaxTimeMSExpiredError(err) || !isNonDeterministicWriteConcernError && err.code !== error_1.MONGODB_ERROR_CODES.UnsatisfiableWriteConcern && err.code !== error_1.MONGODB_ERROR_CODES.UnknownReplWriteConcern;
- }
- function maybeClearPinnedConnection(session, options) {
- const conn = session[kPinnedConnection];
- const error = options == null ? void 0 : options.error;
- if (session.inTransaction() && error && error instanceof error_1.MongoError && error.hasErrorLabel(error_1.MongoErrorLabel.TransientTransactionError)) {
- return;
- }
- const topology = session.client.topology;
- if (conn && topology != null) {
- const servers = Array.from(topology.s.servers.values());
- const loadBalancer = servers[0];
- if ((options == null ? void 0 : options.error) == null || (options == null ? void 0 : options.force)) {
- loadBalancer.pool.checkIn(conn);
- conn.emit(constants_1.UNPINNED, session.transaction.state !== transactions_1.TxnState.NO_TRANSACTION ? metrics_1.ConnectionPoolMetrics.TXN : metrics_1.ConnectionPoolMetrics.CURSOR);
- if (options == null ? void 0 : options.forceClear) {
- loadBalancer.pool.clear({ serviceId: conn.serviceId });
- }
- }
- session[kPinnedConnection] = void 0;
- }
- }
- exports2.maybeClearPinnedConnection = maybeClearPinnedConnection;
- function isMaxTimeMSExpiredError(err) {
- if (err == null || !(err instanceof error_1.MongoServerError)) {
- return false;
- }
- return err.code === error_1.MONGODB_ERROR_CODES.MaxTimeMSExpired || err.writeConcernError && err.writeConcernError.code === error_1.MONGODB_ERROR_CODES.MaxTimeMSExpired;
- }
- function attemptTransactionCommit(session, startTime, fn, options) {
- return session.commitTransaction().catch((err) => {
- if (err instanceof error_1.MongoError && hasNotTimedOut(startTime, MAX_WITH_TRANSACTION_TIMEOUT) && !isMaxTimeMSExpiredError(err)) {
- if (err.hasErrorLabel(error_1.MongoErrorLabel.UnknownTransactionCommitResult)) {
- return attemptTransactionCommit(session, startTime, fn, options);
- }
- if (err.hasErrorLabel(error_1.MongoErrorLabel.TransientTransactionError)) {
- return attemptTransaction(session, startTime, fn, options);
- }
- }
- throw err;
- });
- }
- var USER_EXPLICIT_TXN_END_STATES = /* @__PURE__ */ new Set([
- transactions_1.TxnState.NO_TRANSACTION,
- transactions_1.TxnState.TRANSACTION_COMMITTED,
- transactions_1.TxnState.TRANSACTION_ABORTED
- ]);
- function userExplicitlyEndedTransaction(session) {
- return USER_EXPLICIT_TXN_END_STATES.has(session.transaction.state);
- }
- function attemptTransaction(session, startTime, fn, options) {
- session.startTransaction(options);
- let promise;
- try {
- promise = fn(session);
- } catch (err) {
- promise = Promise.reject(err);
- }
- if (!(0, utils_1.isPromiseLike)(promise)) {
- session.abortTransaction().catch(() => null);
- throw new error_1.MongoInvalidArgumentError("Function provided to `withTransaction` must return a Promise");
- }
- return promise.then(() => {
- if (userExplicitlyEndedTransaction(session)) {
- return;
- }
- return attemptTransactionCommit(session, startTime, fn, options);
- }, (err) => {
- function maybeRetryOrThrow(err2) {
- if (err2 instanceof error_1.MongoError && err2.hasErrorLabel(error_1.MongoErrorLabel.TransientTransactionError) && hasNotTimedOut(startTime, MAX_WITH_TRANSACTION_TIMEOUT)) {
- return attemptTransaction(session, startTime, fn, options);
- }
- if (isMaxTimeMSExpiredError(err2)) {
- err2.addErrorLabel(error_1.MongoErrorLabel.UnknownTransactionCommitResult);
- }
- throw err2;
- }
- if (session.inTransaction()) {
- return session.abortTransaction().then(() => maybeRetryOrThrow(err));
- }
- return maybeRetryOrThrow(err);
- });
- }
- var endTransactionAsync = (0, util_1.promisify)(endTransaction);
- function endTransaction(session, commandName, callback) {
- const txnState = session.transaction.state;
- if (txnState === transactions_1.TxnState.NO_TRANSACTION) {
- callback(new error_1.MongoTransactionError("No transaction started"));
- return;
- }
- if (commandName === "commitTransaction") {
- if (txnState === transactions_1.TxnState.STARTING_TRANSACTION || txnState === transactions_1.TxnState.TRANSACTION_COMMITTED_EMPTY) {
- session.transaction.transition(transactions_1.TxnState.TRANSACTION_COMMITTED_EMPTY);
- callback();
- return;
- }
- if (txnState === transactions_1.TxnState.TRANSACTION_ABORTED) {
- callback(new error_1.MongoTransactionError("Cannot call commitTransaction after calling abortTransaction"));
- return;
- }
- } else {
- if (txnState === transactions_1.TxnState.STARTING_TRANSACTION) {
- session.transaction.transition(transactions_1.TxnState.TRANSACTION_ABORTED);
- callback();
- return;
- }
- if (txnState === transactions_1.TxnState.TRANSACTION_ABORTED) {
- callback(new error_1.MongoTransactionError("Cannot call abortTransaction twice"));
- return;
- }
- if (txnState === transactions_1.TxnState.TRANSACTION_COMMITTED || txnState === transactions_1.TxnState.TRANSACTION_COMMITTED_EMPTY) {
- callback(new error_1.MongoTransactionError("Cannot call abortTransaction after calling commitTransaction"));
- return;
- }
- }
- const command = { [commandName]: 1 };
- let writeConcern;
- if (session.transaction.options.writeConcern) {
- writeConcern = Object.assign({}, session.transaction.options.writeConcern);
- } else if (session.clientOptions && session.clientOptions.writeConcern) {
- writeConcern = { w: session.clientOptions.writeConcern.w };
- }
- if (txnState === transactions_1.TxnState.TRANSACTION_COMMITTED) {
- writeConcern = Object.assign({ wtimeoutMS: 1e4 }, writeConcern, { w: "majority" });
- }
- if (writeConcern) {
- write_concern_1.WriteConcern.apply(command, writeConcern);
- }
- if (commandName === "commitTransaction" && session.transaction.options.maxTimeMS) {
- Object.assign(command, { maxTimeMS: session.transaction.options.maxTimeMS });
- }
- function commandHandler(error, result) {
- if (commandName !== "commitTransaction") {
- session.transaction.transition(transactions_1.TxnState.TRANSACTION_ABORTED);
- if (session.loadBalanced) {
- maybeClearPinnedConnection(session, { force: false });
- }
- return callback();
- }
- session.transaction.transition(transactions_1.TxnState.TRANSACTION_COMMITTED);
- if (error instanceof error_1.MongoError) {
- if (error.hasErrorLabel(error_1.MongoErrorLabel.RetryableWriteError) || error instanceof error_1.MongoWriteConcernError || isMaxTimeMSExpiredError(error)) {
- if (isUnknownTransactionCommitResult(error)) {
- error.addErrorLabel(error_1.MongoErrorLabel.UnknownTransactionCommitResult);
- session.unpin({ error });
- }
- } else if (error.hasErrorLabel(error_1.MongoErrorLabel.TransientTransactionError)) {
- session.unpin({ error });
- }
- }
- callback(error, result);
- }
- if (session.transaction.recoveryToken) {
- command.recoveryToken = session.transaction.recoveryToken;
- }
- (0, execute_operation_1.executeOperation)(session.client, new run_command_1.RunAdminCommandOperation(void 0, command, {
- session,
- readPreference: read_preference_1.ReadPreference.primary,
- bypassPinningCheck: true
- }), (error, result) => {
- if (command.abortTransaction) {
- session.unpin();
- }
- if (error instanceof error_1.MongoError && error.hasErrorLabel(error_1.MongoErrorLabel.RetryableWriteError)) {
- if (command.commitTransaction) {
- session.unpin({ force: true });
- command.writeConcern = Object.assign({ wtimeout: 1e4 }, command.writeConcern, {
- w: "majority"
- });
- }
- return (0, execute_operation_1.executeOperation)(session.client, new run_command_1.RunAdminCommandOperation(void 0, command, {
- session,
- readPreference: read_preference_1.ReadPreference.primary,
- bypassPinningCheck: true
- }), commandHandler);
- }
- commandHandler(error, result);
- });
- }
- var ServerSession = class _ServerSession {
- /** @internal */
- constructor() {
- this.id = { id: new bson_1.Binary((0, utils_1.uuidV4)(), bson_1.Binary.SUBTYPE_UUID) };
- this.lastUse = (0, utils_1.now)();
- this.txnNumber = 0;
- this.isDirty = false;
- }
- /**
- * Determines if the server session has timed out.
- *
- * @param sessionTimeoutMinutes - The server's "logicalSessionTimeoutMinutes"
- */
- hasTimedOut(sessionTimeoutMinutes) {
- const idleTimeMinutes = Math.round((0, utils_1.calculateDurationInMs)(this.lastUse) % 864e5 % 36e5 / 6e4);
- return idleTimeMinutes > sessionTimeoutMinutes - 1;
- }
- /**
- * @internal
- * Cloning meant to keep a readable reference to the server session data
- * after ClientSession has ended
- */
- static clone(serverSession) {
- const arrayBuffer = new ArrayBuffer(16);
- const idBytes = Buffer.from(arrayBuffer);
- idBytes.set(serverSession.id.id.buffer);
- const id = new bson_1.Binary(idBytes, serverSession.id.id.sub_type);
- return Object.setPrototypeOf({
- id: { id },
- lastUse: serverSession.lastUse,
- txnNumber: serverSession.txnNumber,
- isDirty: serverSession.isDirty
- }, _ServerSession.prototype);
- }
- };
- exports2.ServerSession = ServerSession;
- var ServerSessionPool = class {
- constructor(client) {
- if (client == null) {
- throw new error_1.MongoRuntimeError("ServerSessionPool requires a MongoClient");
- }
- this.client = client;
- this.sessions = new utils_1.List();
- }
- /**
- * Acquire a Server Session from the pool.
- * Iterates through each session in the pool, removing any stale sessions
- * along the way. The first non-stale session found is removed from the
- * pool and returned. If no non-stale session is found, a new ServerSession is created.
- */
- acquire() {
- var _a2, _b;
- const sessionTimeoutMinutes = ((_a2 = this.client.topology) == null ? void 0 : _a2.logicalSessionTimeoutMinutes) ?? 10;
- let session = null;
- while (this.sessions.length > 0) {
- const potentialSession = this.sessions.shift();
- if (potentialSession != null && (!!((_b = this.client.topology) == null ? void 0 : _b.loadBalanced) || !potentialSession.hasTimedOut(sessionTimeoutMinutes))) {
- session = potentialSession;
- break;
- }
- }
- if (session == null) {
- session = new ServerSession();
- }
- return session;
- }
- /**
- * Release a session to the session pool
- * Adds the session back to the session pool if the session has not timed out yet.
- * This method also removes any stale sessions from the pool.
- *
- * @param session - The session to release to the pool
- */
- release(session) {
- var _a2, _b;
- const sessionTimeoutMinutes = ((_a2 = this.client.topology) == null ? void 0 : _a2.logicalSessionTimeoutMinutes) ?? 10;
- if (((_b = this.client.topology) == null ? void 0 : _b.loadBalanced) && !sessionTimeoutMinutes) {
- this.sessions.unshift(session);
- }
- if (!sessionTimeoutMinutes) {
- return;
- }
- this.sessions.prune((session2) => session2.hasTimedOut(sessionTimeoutMinutes));
- if (!session.hasTimedOut(sessionTimeoutMinutes)) {
- if (session.isDirty) {
- return;
- }
- this.sessions.unshift(session);
- }
- }
- };
- exports2.ServerSessionPool = ServerSessionPool;
- function applySession(session, command, options) {
- var _a2, _b;
- if (session.hasEnded) {
- return new error_1.MongoExpiredSessionError();
- }
- const serverSession = session.serverSession;
- if (serverSession == null) {
- return new error_1.MongoRuntimeError("Unable to acquire server session");
- }
- if (((_a2 = options.writeConcern) == null ? void 0 : _a2.w) === 0) {
- if (session && session.explicit) {
- return new error_1.MongoAPIError("Cannot have explicit session with unacknowledged writes");
- }
- return;
- }
- serverSession.lastUse = (0, utils_1.now)();
- command.lsid = serverSession.id;
- const inTxnOrTxnCommand = session.inTransaction() || (0, transactions_1.isTransactionCommand)(command);
- const isRetryableWrite = !!options.willRetryWrite;
- if (isRetryableWrite || inTxnOrTxnCommand) {
- serverSession.txnNumber += session[kTxnNumberIncrement];
- session[kTxnNumberIncrement] = 0;
- command.txnNumber = bson_1.Long.fromNumber(serverSession.txnNumber);
- }
- if (!inTxnOrTxnCommand) {
- if (session.transaction.state !== transactions_1.TxnState.NO_TRANSACTION) {
- session.transaction.transition(transactions_1.TxnState.NO_TRANSACTION);
- }
- if (session.supports.causalConsistency && session.operationTime && (0, utils_1.commandSupportsReadConcern)(command, options)) {
- command.readConcern = command.readConcern || {};
- Object.assign(command.readConcern, { afterClusterTime: session.operationTime });
- } else if (session[kSnapshotEnabled]) {
- command.readConcern = command.readConcern || { level: read_concern_1.ReadConcernLevel.snapshot };
- if (session[kSnapshotTime] != null) {
- Object.assign(command.readConcern, { atClusterTime: session[kSnapshotTime] });
- }
- }
- return;
- }
- command.autocommit = false;
- if (session.transaction.state === transactions_1.TxnState.STARTING_TRANSACTION) {
- session.transaction.transition(transactions_1.TxnState.TRANSACTION_IN_PROGRESS);
- command.startTransaction = true;
- const readConcern = session.transaction.options.readConcern || ((_b = session == null ? void 0 : session.clientOptions) == null ? void 0 : _b.readConcern);
- if (readConcern) {
- command.readConcern = readConcern;
- }
- if (session.supports.causalConsistency && session.operationTime) {
- command.readConcern = command.readConcern || {};
- Object.assign(command.readConcern, { afterClusterTime: session.operationTime });
- }
- }
- return;
- }
- exports2.applySession = applySession;
- function updateSessionFromResponse(session, document) {
- var _a2;
- if (document.$clusterTime) {
- (0, common_1._advanceClusterTime)(session, document.$clusterTime);
- }
- if (document.operationTime && session && session.supports.causalConsistency) {
- session.advanceOperationTime(document.operationTime);
- }
- if (document.recoveryToken && session && session.inTransaction()) {
- session.transaction._recoveryToken = document.recoveryToken;
- }
- if ((session == null ? void 0 : session[kSnapshotEnabled]) && session[kSnapshotTime] == null) {
- const atClusterTime = ((_a2 = document.cursor) == null ? void 0 : _a2.atClusterTime) || document.atClusterTime;
- if (atClusterTime) {
- session[kSnapshotTime] = atClusterTime;
- }
- }
- }
- exports2.updateSessionFromResponse = updateSessionFromResponse;
- }
- });
- // node_modules/mongodb/lib/cursor/abstract_cursor.js
- var require_abstract_cursor = __commonJS({
- "node_modules/mongodb/lib/cursor/abstract_cursor.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.assertUninitialized = exports2.AbstractCursor = exports2.CURSOR_FLAGS = void 0;
- var stream_1 = require("stream");
- var util_1 = require("util");
- var bson_1 = require_bson2();
- var error_1 = require_error();
- var mongo_types_1 = require_mongo_types();
- var execute_operation_1 = require_execute_operation();
- var get_more_1 = require_get_more();
- var kill_cursors_1 = require_kill_cursors();
- var read_concern_1 = require_read_concern();
- var read_preference_1 = require_read_preference();
- var sessions_1 = require_sessions();
- var utils_1 = require_utils();
- var kId = Symbol("id");
- var kDocuments = Symbol("documents");
- var kServer = Symbol("server");
- var kNamespace = Symbol("namespace");
- var kClient = Symbol("client");
- var kSession = Symbol("session");
- var kOptions = Symbol("options");
- var kTransform = Symbol("transform");
- var kInitialized = Symbol("initialized");
- var kClosed = Symbol("closed");
- var kKilled = Symbol("killed");
- var kInit = Symbol("kInit");
- exports2.CURSOR_FLAGS = [
- "tailable",
- "oplogReplay",
- "noCursorTimeout",
- "awaitData",
- "exhaust",
- "partial"
- ];
- var AbstractCursor = class extends mongo_types_1.TypedEventEmitter {
- /** @internal */
- constructor(client, namespace, options = {}) {
- super();
- if (!client.s.isMongoClient) {
- throw new error_1.MongoRuntimeError("Cursor must be constructed with MongoClient");
- }
- this[kClient] = client;
- this[kNamespace] = namespace;
- this[kId] = null;
- this[kDocuments] = new utils_1.List();
- this[kInitialized] = false;
- this[kClosed] = false;
- this[kKilled] = false;
- this[kOptions] = {
- readPreference: options.readPreference && options.readPreference instanceof read_preference_1.ReadPreference ? options.readPreference : read_preference_1.ReadPreference.primary,
- ...(0, bson_1.pluckBSONSerializeOptions)(options)
- };
- const readConcern = read_concern_1.ReadConcern.fromOptions(options);
- if (readConcern) {
- this[kOptions].readConcern = readConcern;
- }
- if (typeof options.batchSize === "number") {
- this[kOptions].batchSize = options.batchSize;
- }
- if (options.comment !== void 0) {
- this[kOptions].comment = options.comment;
- }
- if (typeof options.maxTimeMS === "number") {
- this[kOptions].maxTimeMS = options.maxTimeMS;
- }
- if (typeof options.maxAwaitTimeMS === "number") {
- this[kOptions].maxAwaitTimeMS = options.maxAwaitTimeMS;
- }
- if (options.session instanceof sessions_1.ClientSession) {
- this[kSession] = options.session;
- } else {
- this[kSession] = this[kClient].startSession({ owner: this, explicit: false });
- }
- }
- get id() {
- return this[kId] ?? void 0;
- }
- /** @internal */
- get isDead() {
- var _a;
- return (((_a = this[kId]) == null ? void 0 : _a.isZero()) ?? false) || this[kClosed] || this[kKilled];
- }
- /** @internal */
- get client() {
- return this[kClient];
- }
- /** @internal */
- get server() {
- return this[kServer];
- }
- get namespace() {
- return this[kNamespace];
- }
- get readPreference() {
- return this[kOptions].readPreference;
- }
- get readConcern() {
- return this[kOptions].readConcern;
- }
- /** @internal */
- get session() {
- return this[kSession];
- }
- set session(clientSession) {
- this[kSession] = clientSession;
- }
- /** @internal */
- get cursorOptions() {
- return this[kOptions];
- }
- get closed() {
- return this[kClosed];
- }
- get killed() {
- return this[kKilled];
- }
- get loadBalanced() {
- var _a;
- return !!((_a = this[kClient].topology) == null ? void 0 : _a.loadBalanced);
- }
- /** Returns current buffered documents length */
- bufferedCount() {
- return this[kDocuments].length;
- }
- /** Returns current buffered documents */
- readBufferedDocuments(number) {
- const bufferedDocs = [];
- const documentsToRead = Math.min(number ?? this[kDocuments].length, this[kDocuments].length);
- for (let count = 0; count < documentsToRead; count++) {
- const document = this[kDocuments].shift();
- if (document != null) {
- bufferedDocs.push(document);
- }
- }
- return bufferedDocs;
- }
- async *[Symbol.asyncIterator]() {
- if (this.closed) {
- return;
- }
- try {
- while (true) {
- const document = await this.next();
- if (document === null) {
- if (!this.closed) {
- const message = "Cursor returned a `null` document, but the cursor is not exhausted. Mapping documents to `null` is not supported in the cursor transform.";
- await cleanupCursorAsync(this, { needsToEmitClosed: true }).catch(() => null);
- throw new error_1.MongoAPIError(message);
- }
- break;
- }
- yield document;
- if (this[kId] === bson_1.Long.ZERO) {
- break;
- }
- }
- } finally {
- if (!this.closed) {
- await this.close().catch(() => null);
- }
- }
- }
- stream(options) {
- if (options == null ? void 0 : options.transform) {
- const transform = options.transform;
- const readable = new ReadableCursorStream(this);
- return readable.pipe(new stream_1.Transform({
- objectMode: true,
- highWaterMark: 1,
- transform(chunk, _, callback) {
- try {
- const transformed = transform(chunk);
- callback(void 0, transformed);
- } catch (err) {
- callback(err);
- }
- }
- }));
- }
- return new ReadableCursorStream(this);
- }
- async hasNext() {
- if (this[kId] === bson_1.Long.ZERO) {
- return false;
- }
- if (this[kDocuments].length !== 0) {
- return true;
- }
- const doc = await next(this, { blocking: true, transform: false });
- if (doc) {
- this[kDocuments].unshift(doc);
- return true;
- }
- return false;
- }
- /** Get the next available document from the cursor, returns null if no more documents are available. */
- async next() {
- if (this[kId] === bson_1.Long.ZERO) {
- throw new error_1.MongoCursorExhaustedError();
- }
- return next(this, { blocking: true, transform: true });
- }
- /**
- * Try to get the next available document from the cursor or `null` if an empty batch is returned
- */
- async tryNext() {
- if (this[kId] === bson_1.Long.ZERO) {
- throw new error_1.MongoCursorExhaustedError();
- }
- return next(this, { blocking: false, transform: true });
- }
- /**
- * Iterates over all the documents for this cursor using the iterator, callback pattern.
- *
- * If the iterator returns `false`, iteration will stop.
- *
- * @param iterator - The iteration callback.
- * @deprecated - Will be removed in a future release. Use for await...of instead.
- */
- async forEach(iterator) {
- if (typeof iterator !== "function") {
- throw new error_1.MongoInvalidArgumentError('Argument "iterator" must be a function');
- }
- for await (const document of this) {
- const result = iterator(document);
- if (result === false) {
- break;
- }
- }
- }
- async close() {
- const needsToEmitClosed = !this[kClosed];
- this[kClosed] = true;
- await cleanupCursorAsync(this, { needsToEmitClosed });
- }
- /**
- * Returns an array of documents. The caller is responsible for making sure that there
- * is enough memory to store the results. Note that the array only contains partial
- * results when this cursor had been previously accessed. In that case,
- * cursor.rewind() can be used to reset the cursor.
- */
- async toArray() {
- const array = [];
- for await (const document of this) {
- array.push(document);
- }
- return array;
- }
- /**
- * Add a cursor flag to the cursor
- *
- * @param flag - The flag to set, must be one of following ['tailable', 'oplogReplay', 'noCursorTimeout', 'awaitData', 'partial' -.
- * @param value - The flag boolean value.
- */
- addCursorFlag(flag, value) {
- assertUninitialized(this);
- if (!exports2.CURSOR_FLAGS.includes(flag)) {
- throw new error_1.MongoInvalidArgumentError(`Flag ${flag} is not one of ${exports2.CURSOR_FLAGS}`);
- }
- if (typeof value !== "boolean") {
- throw new error_1.MongoInvalidArgumentError(`Flag ${flag} must be a boolean value`);
- }
- this[kOptions][flag] = value;
- return this;
- }
- /**
- * Map all documents using the provided function
- * If there is a transform set on the cursor, that will be called first and the result passed to
- * this function's transform.
- *
- * @remarks
- *
- * **Note** Cursors use `null` internally to indicate that there are no more documents in the cursor. Providing a mapping
- * function that maps values to `null` will result in the cursor closing itself before it has finished iterating
- * all documents. This will **not** result in a memory leak, just surprising behavior. For example:
- *
- * ```typescript
- * const cursor = collection.find({});
- * cursor.map(() => null);
- *
- * const documents = await cursor.toArray();
- * // documents is always [], regardless of how many documents are in the collection.
- * ```
- *
- * Other falsey values are allowed:
- *
- * ```typescript
- * const cursor = collection.find({});
- * cursor.map(() => '');
- *
- * const documents = await cursor.toArray();
- * // documents is now an array of empty strings
- * ```
- *
- * **Note for Typescript Users:** adding a transform changes the return type of the iteration of this cursor,
- * it **does not** return a new instance of a cursor. This means when calling map,
- * you should always assign the result to a new variable in order to get a correctly typed cursor variable.
- * Take note of the following example:
- *
- * @example
- * ```typescript
- * const cursor: FindCursor<Document> = coll.find();
- * const mappedCursor: FindCursor<number> = cursor.map(doc => Object.keys(doc).length);
- * const keyCounts: number[] = await mappedCursor.toArray(); // cursor.toArray() still returns Document[]
- * ```
- * @param transform - The mapping transformation method.
- */
- map(transform) {
- assertUninitialized(this);
- const oldTransform = this[kTransform];
- if (oldTransform) {
- this[kTransform] = (doc) => {
- return transform(oldTransform(doc));
- };
- } else {
- this[kTransform] = transform;
- }
- return this;
- }
- /**
- * Set the ReadPreference for the cursor.
- *
- * @param readPreference - The new read preference for the cursor.
- */
- withReadPreference(readPreference) {
- assertUninitialized(this);
- if (readPreference instanceof read_preference_1.ReadPreference) {
- this[kOptions].readPreference = readPreference;
- } else if (typeof readPreference === "string") {
- this[kOptions].readPreference = read_preference_1.ReadPreference.fromString(readPreference);
- } else {
- throw new error_1.MongoInvalidArgumentError(`Invalid read preference: ${readPreference}`);
- }
- return this;
- }
- /**
- * Set the ReadPreference for the cursor.
- *
- * @param readPreference - The new read preference for the cursor.
- */
- withReadConcern(readConcern) {
- assertUninitialized(this);
- const resolvedReadConcern = read_concern_1.ReadConcern.fromOptions({ readConcern });
- if (resolvedReadConcern) {
- this[kOptions].readConcern = resolvedReadConcern;
- }
- return this;
- }
- /**
- * Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher)
- *
- * @param value - Number of milliseconds to wait before aborting the query.
- */
- maxTimeMS(value) {
- assertUninitialized(this);
- if (typeof value !== "number") {
- throw new error_1.MongoInvalidArgumentError("Argument for maxTimeMS must be a number");
- }
- this[kOptions].maxTimeMS = value;
- return this;
- }
- /**
- * Set the batch size for the cursor.
- *
- * @param value - The number of documents to return per batch. See {@link https://www.mongodb.com/docs/manual/reference/command/find/|find command documentation}.
- */
- batchSize(value) {
- assertUninitialized(this);
- if (this[kOptions].tailable) {
- throw new error_1.MongoTailableCursorError("Tailable cursor does not support batchSize");
- }
- if (typeof value !== "number") {
- throw new error_1.MongoInvalidArgumentError('Operation "batchSize" requires an integer');
- }
- this[kOptions].batchSize = value;
- return this;
- }
- /**
- * Rewind this cursor to its uninitialized state. Any options that are present on the cursor will
- * remain in effect. Iterating this cursor will cause new queries to be sent to the server, even
- * if the resultant data has already been retrieved by this cursor.
- */
- rewind() {
- if (!this[kInitialized]) {
- return;
- }
- this[kId] = null;
- this[kDocuments].clear();
- this[kClosed] = false;
- this[kKilled] = false;
- this[kInitialized] = false;
- const session = this[kSession];
- if (session) {
- if (session.explicit === false) {
- if (!session.hasEnded) {
- session.endSession().catch(() => null);
- }
- this[kSession] = this.client.startSession({ owner: this, explicit: false });
- }
- }
- }
- /** @internal */
- _getMore(batchSize, callback) {
- const getMoreOperation = new get_more_1.GetMoreOperation(this[kNamespace], this[kId], this[kServer], {
- ...this[kOptions],
- session: this[kSession],
- batchSize
- });
- (0, execute_operation_1.executeOperation)(this[kClient], getMoreOperation, callback);
- }
- /**
- * @internal
- *
- * This function is exposed for the unified test runner's createChangeStream
- * operation. We cannot refactor to use the abstract _initialize method without
- * a significant refactor.
- */
- [kInit](callback) {
- this._initialize(this[kSession], (error, state) => {
- if (state) {
- const response = state.response;
- this[kServer] = state.server;
- if (response.cursor) {
- this[kId] = typeof response.cursor.id === "number" ? bson_1.Long.fromNumber(response.cursor.id) : typeof response.cursor.id === "bigint" ? bson_1.Long.fromBigInt(response.cursor.id) : response.cursor.id;
- if (response.cursor.ns) {
- this[kNamespace] = (0, utils_1.ns)(response.cursor.ns);
- }
- this[kDocuments].pushMany(response.cursor.firstBatch);
- }
- if (this[kId] == null) {
- this[kId] = bson_1.Long.ZERO;
- this[kDocuments].push(state.response);
- }
- }
- this[kInitialized] = true;
- if (error) {
- return cleanupCursor(this, { error }, () => callback(error, void 0));
- }
- if (this.isDead) {
- return cleanupCursor(this, void 0, () => callback());
- }
- callback();
- });
- }
- };
- AbstractCursor.CLOSE = "close";
- exports2.AbstractCursor = AbstractCursor;
- async function next(cursor, { blocking, transform }) {
- if (cursor.closed) {
- return null;
- }
- do {
- if (cursor[kId] == null) {
- await (0, util_1.promisify)(cursor[kInit].bind(cursor))();
- }
- if (cursor[kDocuments].length !== 0) {
- const doc = cursor[kDocuments].shift();
- if (doc != null && transform && cursor[kTransform]) {
- try {
- return cursor[kTransform](doc);
- } catch (error) {
- await cleanupCursorAsync(cursor, { error, needsToEmitClosed: true }).catch(() => null);
- throw error;
- }
- }
- return doc;
- }
- if (cursor.isDead) {
- await cleanupCursorAsync(cursor, {});
- return null;
- }
- const batchSize = cursor[kOptions].batchSize || 1e3;
- try {
- const response = await (0, util_1.promisify)(cursor._getMore.bind(cursor))(batchSize);
- if (response) {
- const cursorId = typeof response.cursor.id === "number" ? bson_1.Long.fromNumber(response.cursor.id) : typeof response.cursor.id === "bigint" ? bson_1.Long.fromBigInt(response.cursor.id) : response.cursor.id;
- cursor[kDocuments].pushMany(response.cursor.nextBatch);
- cursor[kId] = cursorId;
- }
- } catch (error) {
- await cleanupCursorAsync(cursor, { error }).catch(() => null);
- throw error;
- }
- if (cursor.isDead) {
- await cleanupCursorAsync(cursor, {});
- }
- if (cursor[kDocuments].length === 0 && blocking === false) {
- return null;
- }
- } while (!cursor.isDead || cursor[kDocuments].length !== 0);
- return null;
- }
- var cleanupCursorAsync = (0, util_1.promisify)(cleanupCursor);
- function cleanupCursor(cursor, options, callback) {
- const cursorId = cursor[kId];
- const cursorNs = cursor[kNamespace];
- const server = cursor[kServer];
- const session = cursor[kSession];
- const error = options == null ? void 0 : options.error;
- const needsToEmitClosed = (options == null ? void 0 : options.needsToEmitClosed) ?? cursor[kDocuments].length === 0;
- if (error) {
- if (cursor.loadBalanced && error instanceof error_1.MongoNetworkError) {
- return completeCleanup();
- }
- }
- if (cursorId == null || server == null || cursorId.isZero() || cursorNs == null) {
- if (needsToEmitClosed) {
- cursor[kClosed] = true;
- cursor[kId] = bson_1.Long.ZERO;
- cursor.emit(AbstractCursor.CLOSE);
- }
- if (session) {
- if (session.owner === cursor) {
- session.endSession({ error }).finally(() => {
- callback();
- });
- return;
- }
- if (!session.inTransaction()) {
- (0, sessions_1.maybeClearPinnedConnection)(session, { error });
- }
- }
- return callback();
- }
- function completeCleanup() {
- if (session) {
- if (session.owner === cursor) {
- session.endSession({ error }).finally(() => {
- cursor.emit(AbstractCursor.CLOSE);
- callback();
- });
- return;
- }
- if (!session.inTransaction()) {
- (0, sessions_1.maybeClearPinnedConnection)(session, { error });
- }
- }
- cursor.emit(AbstractCursor.CLOSE);
- return callback();
- }
- cursor[kKilled] = true;
- if (session.hasEnded) {
- return completeCleanup();
- }
- (0, execute_operation_1.executeOperation)(cursor[kClient], new kill_cursors_1.KillCursorsOperation(cursorId, cursorNs, server, { session })).catch(() => null).finally(completeCleanup);
- }
- function assertUninitialized(cursor) {
- if (cursor[kInitialized]) {
- throw new error_1.MongoCursorInUseError();
- }
- }
- exports2.assertUninitialized = assertUninitialized;
- var ReadableCursorStream = class extends stream_1.Readable {
- constructor(cursor) {
- super({
- objectMode: true,
- autoDestroy: false,
- highWaterMark: 1
- });
- this._readInProgress = false;
- this._cursor = cursor;
- }
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- _read(size) {
- if (!this._readInProgress) {
- this._readInProgress = true;
- this._readNext();
- }
- }
- _destroy(error, callback) {
- this._cursor.close().then(() => callback(error), (closeError) => callback(closeError));
- }
- _readNext() {
- next(this._cursor, { blocking: true, transform: true }).then((result) => {
- if (result == null) {
- this.push(null);
- } else if (this.destroyed) {
- this._cursor.close().catch(() => null);
- } else {
- if (this.push(result)) {
- return this._readNext();
- }
- this._readInProgress = false;
- }
- }, (err) => {
- if (err.message.match(/server is closed/)) {
- this._cursor.close().catch(() => null);
- return this.push(null);
- }
- if (err.message.match(/operation was interrupted/)) {
- return this.push(null);
- }
- return this.destroy(err);
- });
- }
- };
- }
- });
- // node_modules/mongodb/lib/cursor/aggregation_cursor.js
- var require_aggregation_cursor = __commonJS({
- "node_modules/mongodb/lib/cursor/aggregation_cursor.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AggregationCursor = void 0;
- var aggregate_1 = require_aggregate();
- var execute_operation_1 = require_execute_operation();
- var utils_1 = require_utils();
- var abstract_cursor_1 = require_abstract_cursor();
- var kPipeline = Symbol("pipeline");
- var kOptions = Symbol("options");
- var AggregationCursor = class _AggregationCursor extends abstract_cursor_1.AbstractCursor {
- /** @internal */
- constructor(client, namespace, pipeline = [], options = {}) {
- super(client, namespace, options);
- this[kPipeline] = pipeline;
- this[kOptions] = options;
- }
- get pipeline() {
- return this[kPipeline];
- }
- clone() {
- const clonedOptions = (0, utils_1.mergeOptions)({}, this[kOptions]);
- delete clonedOptions.session;
- return new _AggregationCursor(this.client, this.namespace, this[kPipeline], {
- ...clonedOptions
- });
- }
- map(transform) {
- return super.map(transform);
- }
- /** @internal */
- _initialize(session, callback) {
- const aggregateOperation = new aggregate_1.AggregateOperation(this.namespace, this[kPipeline], {
- ...this[kOptions],
- ...this.cursorOptions,
- session
- });
- (0, execute_operation_1.executeOperation)(this.client, aggregateOperation, (err, response) => {
- if (err || response == null)
- return callback(err);
- callback(void 0, { server: aggregateOperation.server, session, response });
- });
- }
- /** Execute the explain for the cursor */
- async explain(verbosity) {
- return (0, execute_operation_1.executeOperation)(this.client, new aggregate_1.AggregateOperation(this.namespace, this[kPipeline], {
- ...this[kOptions],
- ...this.cursorOptions,
- explain: verbosity ?? true
- }));
- }
- group($group) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $group });
- return this;
- }
- /** Add a limit stage to the aggregation pipeline */
- limit($limit) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $limit });
- return this;
- }
- /** Add a match stage to the aggregation pipeline */
- match($match) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $match });
- return this;
- }
- /** Add an out stage to the aggregation pipeline */
- out($out) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $out });
- return this;
- }
- /**
- * Add a project stage to the aggregation pipeline
- *
- * @remarks
- * In order to strictly type this function you must provide an interface
- * that represents the effect of your projection on the result documents.
- *
- * By default chaining a projection to your cursor changes the returned type to the generic {@link Document} type.
- * You should specify a parameterized type to have assertions on your final results.
- *
- * @example
- * ```typescript
- * // Best way
- * const docs: AggregationCursor<{ a: number }> = cursor.project<{ a: number }>({ _id: 0, a: true });
- * // Flexible way
- * const docs: AggregationCursor<Document> = cursor.project({ _id: 0, a: true });
- * ```
- *
- * @remarks
- * In order to strictly type this function you must provide an interface
- * that represents the effect of your projection on the result documents.
- *
- * **Note for Typescript Users:** adding a transform changes the return type of the iteration of this cursor,
- * it **does not** return a new instance of a cursor. This means when calling project,
- * you should always assign the result to a new variable in order to get a correctly typed cursor variable.
- * Take note of the following example:
- *
- * @example
- * ```typescript
- * const cursor: AggregationCursor<{ a: number; b: string }> = coll.aggregate([]);
- * const projectCursor = cursor.project<{ a: number }>({ _id: 0, a: true });
- * const aPropOnlyArray: {a: number}[] = await projectCursor.toArray();
- *
- * // or always use chaining and save the final cursor
- *
- * const cursor = coll.aggregate().project<{ a: string }>({
- * _id: 0,
- * a: { $convert: { input: '$a', to: 'string' }
- * }});
- * ```
- */
- project($project) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $project });
- return this;
- }
- /** Add a lookup stage to the aggregation pipeline */
- lookup($lookup) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $lookup });
- return this;
- }
- /** Add a redact stage to the aggregation pipeline */
- redact($redact) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $redact });
- return this;
- }
- /** Add a skip stage to the aggregation pipeline */
- skip($skip) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $skip });
- return this;
- }
- /** Add a sort stage to the aggregation pipeline */
- sort($sort) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $sort });
- return this;
- }
- /** Add a unwind stage to the aggregation pipeline */
- unwind($unwind) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $unwind });
- return this;
- }
- /** Add a geoNear stage to the aggregation pipeline */
- geoNear($geoNear) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kPipeline].push({ $geoNear });
- return this;
- }
- };
- exports2.AggregationCursor = AggregationCursor;
- }
- });
- // node_modules/mongodb/lib/operations/count.js
- var require_count = __commonJS({
- "node_modules/mongodb/lib/operations/count.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.CountOperation = void 0;
- var command_1 = require_command();
- var operation_1 = require_operation();
- var CountOperation = class extends command_1.CommandCallbackOperation {
- constructor(namespace, filter, options) {
- super({ s: { namespace } }, options);
- this.options = options;
- this.collectionName = namespace.collection;
- this.query = filter;
- }
- executeCallback(server, session, callback) {
- const options = this.options;
- const cmd = {
- count: this.collectionName,
- query: this.query
- };
- if (typeof options.limit === "number") {
- cmd.limit = options.limit;
- }
- if (typeof options.skip === "number") {
- cmd.skip = options.skip;
- }
- if (options.hint != null) {
- cmd.hint = options.hint;
- }
- if (typeof options.maxTimeMS === "number") {
- cmd.maxTimeMS = options.maxTimeMS;
- }
- super.executeCommandCallback(server, session, cmd, (err, result) => {
- callback(err, result ? result.n : 0);
- });
- }
- };
- exports2.CountOperation = CountOperation;
- (0, operation_1.defineAspects)(CountOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE]);
- }
- });
- // node_modules/mongodb/lib/sort.js
- var require_sort = __commonJS({
- "node_modules/mongodb/lib/sort.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.formatSort = void 0;
- var error_1 = require_error();
- function prepareDirection(direction = 1) {
- const value = `${direction}`.toLowerCase();
- if (isMeta(direction))
- return direction;
- switch (value) {
- case "ascending":
- case "asc":
- case "1":
- return 1;
- case "descending":
- case "desc":
- case "-1":
- return -1;
- default:
- throw new error_1.MongoInvalidArgumentError(`Invalid sort direction: ${JSON.stringify(direction)}`);
- }
- }
- function isMeta(t) {
- return typeof t === "object" && t != null && "$meta" in t && typeof t.$meta === "string";
- }
- function isPair(t) {
- if (Array.isArray(t) && t.length === 2) {
- try {
- prepareDirection(t[1]);
- return true;
- } catch (e) {
- return false;
- }
- }
- return false;
- }
- function isDeep(t) {
- return Array.isArray(t) && Array.isArray(t[0]);
- }
- function isMap(t) {
- return t instanceof Map && t.size > 0;
- }
- function pairToMap(v) {
- return /* @__PURE__ */ new Map([[`${v[0]}`, prepareDirection([v[1]])]]);
- }
- function deepToMap(t) {
- const sortEntries = t.map(([k, v]) => [`${k}`, prepareDirection(v)]);
- return new Map(sortEntries);
- }
- function stringsToMap(t) {
- const sortEntries = t.map((key) => [`${key}`, 1]);
- return new Map(sortEntries);
- }
- function objectToMap(t) {
- const sortEntries = Object.entries(t).map(([k, v]) => [
- `${k}`,
- prepareDirection(v)
- ]);
- return new Map(sortEntries);
- }
- function mapToMap(t) {
- const sortEntries = Array.from(t).map(([k, v]) => [
- `${k}`,
- prepareDirection(v)
- ]);
- return new Map(sortEntries);
- }
- function formatSort(sort, direction) {
- if (sort == null)
- return void 0;
- if (typeof sort === "string")
- return /* @__PURE__ */ new Map([[sort, prepareDirection(direction)]]);
- if (typeof sort !== "object") {
- throw new error_1.MongoInvalidArgumentError(`Invalid sort format: ${JSON.stringify(sort)} Sort must be a valid object`);
- }
- if (!Array.isArray(sort)) {
- return isMap(sort) ? mapToMap(sort) : Object.keys(sort).length ? objectToMap(sort) : void 0;
- }
- if (!sort.length)
- return void 0;
- if (isDeep(sort))
- return deepToMap(sort);
- if (isPair(sort))
- return pairToMap(sort);
- return stringsToMap(sort);
- }
- exports2.formatSort = formatSort;
- }
- });
- // node_modules/mongodb/lib/operations/find.js
- var require_find = __commonJS({
- "node_modules/mongodb/lib/operations/find.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.FindOperation = void 0;
- var error_1 = require_error();
- var read_concern_1 = require_read_concern();
- var sort_1 = require_sort();
- var utils_1 = require_utils();
- var command_1 = require_command();
- var operation_1 = require_operation();
- var FindOperation = class extends command_1.CommandCallbackOperation {
- constructor(collection, ns, filter = {}, options = {}) {
- super(collection, options);
- this.options = { ...options };
- delete this.options.writeConcern;
- this.ns = ns;
- if (typeof filter !== "object" || Array.isArray(filter)) {
- throw new error_1.MongoInvalidArgumentError("Query filter must be a plain object or ObjectId");
- }
- this.filter = filter != null && filter._bsontype === "ObjectId" ? { _id: filter } : filter;
- }
- executeCallback(server, session, callback) {
- this.server = server;
- const options = this.options;
- let findCommand = makeFindCommand(this.ns, this.filter, options);
- if (this.explain) {
- findCommand = (0, utils_1.decorateWithExplain)(findCommand, this.explain);
- }
- server.command(this.ns, findCommand, {
- ...this.options,
- ...this.bsonOptions,
- documentsReturnedIn: "firstBatch",
- session
- }, callback);
- }
- };
- exports2.FindOperation = FindOperation;
- function makeFindCommand(ns, filter, options) {
- const findCommand = {
- find: ns.collection,
- filter
- };
- if (options.sort) {
- findCommand.sort = (0, sort_1.formatSort)(options.sort);
- }
- if (options.projection) {
- let projection = options.projection;
- if (projection && Array.isArray(projection)) {
- projection = projection.length ? projection.reduce((result, field) => {
- result[field] = 1;
- return result;
- }, {}) : { _id: 1 };
- }
- findCommand.projection = projection;
- }
- if (options.hint) {
- findCommand.hint = (0, utils_1.normalizeHintField)(options.hint);
- }
- if (typeof options.skip === "number") {
- findCommand.skip = options.skip;
- }
- if (typeof options.limit === "number") {
- if (options.limit < 0) {
- findCommand.limit = -options.limit;
- findCommand.singleBatch = true;
- } else {
- findCommand.limit = options.limit;
- }
- }
- if (typeof options.batchSize === "number") {
- if (options.batchSize < 0) {
- if (options.limit && options.limit !== 0 && Math.abs(options.batchSize) < Math.abs(options.limit)) {
- findCommand.limit = -options.batchSize;
- }
- findCommand.singleBatch = true;
- } else {
- findCommand.batchSize = options.batchSize;
- }
- }
- if (typeof options.singleBatch === "boolean") {
- findCommand.singleBatch = options.singleBatch;
- }
- if (options.comment !== void 0) {
- findCommand.comment = options.comment;
- }
- if (typeof options.maxTimeMS === "number") {
- findCommand.maxTimeMS = options.maxTimeMS;
- }
- const readConcern = read_concern_1.ReadConcern.fromOptions(options);
- if (readConcern) {
- findCommand.readConcern = readConcern.toJSON();
- }
- if (options.max) {
- findCommand.max = options.max;
- }
- if (options.min) {
- findCommand.min = options.min;
- }
- if (typeof options.returnKey === "boolean") {
- findCommand.returnKey = options.returnKey;
- }
- if (typeof options.showRecordId === "boolean") {
- findCommand.showRecordId = options.showRecordId;
- }
- if (typeof options.tailable === "boolean") {
- findCommand.tailable = options.tailable;
- }
- if (typeof options.oplogReplay === "boolean") {
- findCommand.oplogReplay = options.oplogReplay;
- }
- if (typeof options.timeout === "boolean") {
- findCommand.noCursorTimeout = !options.timeout;
- } else if (typeof options.noCursorTimeout === "boolean") {
- findCommand.noCursorTimeout = options.noCursorTimeout;
- }
- if (typeof options.awaitData === "boolean") {
- findCommand.awaitData = options.awaitData;
- }
- if (typeof options.allowPartialResults === "boolean") {
- findCommand.allowPartialResults = options.allowPartialResults;
- }
- if (options.collation) {
- findCommand.collation = options.collation;
- }
- if (typeof options.allowDiskUse === "boolean") {
- findCommand.allowDiskUse = options.allowDiskUse;
- }
- if (options.let) {
- findCommand.let = options.let;
- }
- return findCommand;
- }
- (0, operation_1.defineAspects)(FindOperation, [
- operation_1.Aspect.READ_OPERATION,
- operation_1.Aspect.RETRYABLE,
- operation_1.Aspect.EXPLAINABLE,
- operation_1.Aspect.CURSOR_CREATING
- ]);
- }
- });
- // node_modules/mongodb/lib/cursor/find_cursor.js
- var require_find_cursor = __commonJS({
- "node_modules/mongodb/lib/cursor/find_cursor.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.FindCursor = exports2.FLAGS = void 0;
- var bson_1 = require_bson2();
- var error_1 = require_error();
- var count_1 = require_count();
- var execute_operation_1 = require_execute_operation();
- var find_1 = require_find();
- var sort_1 = require_sort();
- var utils_1 = require_utils();
- var abstract_cursor_1 = require_abstract_cursor();
- var kFilter = Symbol("filter");
- var kNumReturned = Symbol("numReturned");
- var kBuiltOptions = Symbol("builtOptions");
- exports2.FLAGS = [
- "tailable",
- "oplogReplay",
- "noCursorTimeout",
- "awaitData",
- "exhaust",
- "partial"
- ];
- var FindCursor = class _FindCursor extends abstract_cursor_1.AbstractCursor {
- /** @internal */
- constructor(client, namespace, filter = {}, options = {}) {
- super(client, namespace, options);
- this[kFilter] = filter;
- this[kBuiltOptions] = options;
- if (options.sort != null) {
- this[kBuiltOptions].sort = (0, sort_1.formatSort)(options.sort);
- }
- }
- clone() {
- const clonedOptions = (0, utils_1.mergeOptions)({}, this[kBuiltOptions]);
- delete clonedOptions.session;
- return new _FindCursor(this.client, this.namespace, this[kFilter], {
- ...clonedOptions
- });
- }
- map(transform) {
- return super.map(transform);
- }
- /** @internal */
- _initialize(session, callback) {
- const findOperation = new find_1.FindOperation(void 0, this.namespace, this[kFilter], {
- ...this[kBuiltOptions],
- ...this.cursorOptions,
- session
- });
- (0, execute_operation_1.executeOperation)(this.client, findOperation, (err, response) => {
- if (err || response == null)
- return callback(err);
- if (response.cursor) {
- this[kNumReturned] = response.cursor.firstBatch.length;
- } else {
- this[kNumReturned] = response.documents ? response.documents.length : 0;
- }
- callback(void 0, { server: findOperation.server, session, response });
- });
- }
- /** @internal */
- _getMore(batchSize, callback) {
- const numReturned = this[kNumReturned];
- if (numReturned) {
- const limit = this[kBuiltOptions].limit;
- batchSize = limit && limit > 0 && numReturned + batchSize > limit ? limit - numReturned : batchSize;
- if (batchSize <= 0) {
- this.close().finally(() => callback(void 0, { cursor: { id: bson_1.Long.ZERO, nextBatch: [] } }));
- return;
- }
- }
- super._getMore(batchSize, (err, response) => {
- if (err)
- return callback(err);
- if (response) {
- this[kNumReturned] = this[kNumReturned] + response.cursor.nextBatch.length;
- }
- callback(void 0, response);
- });
- }
- /**
- * Get the count of documents for this cursor
- * @deprecated Use `collection.estimatedDocumentCount` or `collection.countDocuments` instead
- */
- async count(options) {
- (0, utils_1.emitWarningOnce)("cursor.count is deprecated and will be removed in the next major version, please use `collection.estimatedDocumentCount` or `collection.countDocuments` instead ");
- if (typeof options === "boolean") {
- throw new error_1.MongoInvalidArgumentError("Invalid first parameter to count");
- }
- return (0, execute_operation_1.executeOperation)(this.client, new count_1.CountOperation(this.namespace, this[kFilter], {
- ...this[kBuiltOptions],
- ...this.cursorOptions,
- ...options
- }));
- }
- /** Execute the explain for the cursor */
- async explain(verbosity) {
- return (0, execute_operation_1.executeOperation)(this.client, new find_1.FindOperation(void 0, this.namespace, this[kFilter], {
- ...this[kBuiltOptions],
- ...this.cursorOptions,
- explain: verbosity ?? true
- }));
- }
- /** Set the cursor query */
- filter(filter) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kFilter] = filter;
- return this;
- }
- /**
- * Set the cursor hint
- *
- * @param hint - If specified, then the query system will only consider plans using the hinted index.
- */
- hint(hint) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kBuiltOptions].hint = hint;
- return this;
- }
- /**
- * Set the cursor min
- *
- * @param min - Specify a $min value to specify the inclusive lower bound for a specific index in order to constrain the results of find(). The $min specifies the lower bound for all keys of a specific index in order.
- */
- min(min) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kBuiltOptions].min = min;
- return this;
- }
- /**
- * Set the cursor max
- *
- * @param max - Specify a $max value to specify the exclusive upper bound for a specific index in order to constrain the results of find(). The $max specifies the upper bound for all keys of a specific index in order.
- */
- max(max) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kBuiltOptions].max = max;
- return this;
- }
- /**
- * Set the cursor returnKey.
- * If set to true, modifies the cursor to only return the index field or fields for the results of the query, rather than documents.
- * If set to true and the query does not use an index to perform the read operation, the returned documents will not contain any fields.
- *
- * @param value - the returnKey value.
- */
- returnKey(value) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kBuiltOptions].returnKey = value;
- return this;
- }
- /**
- * Modifies the output of a query by adding a field $recordId to matching documents. $recordId is the internal key which uniquely identifies a document in a collection.
- *
- * @param value - The $showDiskLoc option has now been deprecated and replaced with the showRecordId field. $showDiskLoc will still be accepted for OP_QUERY stye find.
- */
- showRecordId(value) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kBuiltOptions].showRecordId = value;
- return this;
- }
- /**
- * Add a query modifier to the cursor query
- *
- * @param name - The query modifier (must start with $, such as $orderby etc)
- * @param value - The modifier value.
- */
- addQueryModifier(name, value) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- if (name[0] !== "$") {
- throw new error_1.MongoInvalidArgumentError(`${name} is not a valid query modifier`);
- }
- const field = name.substr(1);
- switch (field) {
- case "comment":
- this[kBuiltOptions].comment = value;
- break;
- case "explain":
- this[kBuiltOptions].explain = value;
- break;
- case "hint":
- this[kBuiltOptions].hint = value;
- break;
- case "max":
- this[kBuiltOptions].max = value;
- break;
- case "maxTimeMS":
- this[kBuiltOptions].maxTimeMS = value;
- break;
- case "min":
- this[kBuiltOptions].min = value;
- break;
- case "orderby":
- this[kBuiltOptions].sort = (0, sort_1.formatSort)(value);
- break;
- case "query":
- this[kFilter] = value;
- break;
- case "returnKey":
- this[kBuiltOptions].returnKey = value;
- break;
- case "showDiskLoc":
- this[kBuiltOptions].showRecordId = value;
- break;
- default:
- throw new error_1.MongoInvalidArgumentError(`Invalid query modifier: ${name}`);
- }
- return this;
- }
- /**
- * Add a comment to the cursor query allowing for tracking the comment in the log.
- *
- * @param value - The comment attached to this query.
- */
- comment(value) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kBuiltOptions].comment = value;
- return this;
- }
- /**
- * Set a maxAwaitTimeMS on a tailing cursor query to allow to customize the timeout value for the option awaitData (Only supported on MongoDB 3.2 or higher, ignored otherwise)
- *
- * @param value - Number of milliseconds to wait before aborting the tailed query.
- */
- maxAwaitTimeMS(value) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- if (typeof value !== "number") {
- throw new error_1.MongoInvalidArgumentError("Argument for maxAwaitTimeMS must be a number");
- }
- this[kBuiltOptions].maxAwaitTimeMS = value;
- return this;
- }
- /**
- * Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher)
- *
- * @param value - Number of milliseconds to wait before aborting the query.
- */
- maxTimeMS(value) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- if (typeof value !== "number") {
- throw new error_1.MongoInvalidArgumentError("Argument for maxTimeMS must be a number");
- }
- this[kBuiltOptions].maxTimeMS = value;
- return this;
- }
- /**
- * Add a project stage to the aggregation pipeline
- *
- * @remarks
- * In order to strictly type this function you must provide an interface
- * that represents the effect of your projection on the result documents.
- *
- * By default chaining a projection to your cursor changes the returned type to the generic
- * {@link Document} type.
- * You should specify a parameterized type to have assertions on your final results.
- *
- * @example
- * ```typescript
- * // Best way
- * const docs: FindCursor<{ a: number }> = cursor.project<{ a: number }>({ _id: 0, a: true });
- * // Flexible way
- * const docs: FindCursor<Document> = cursor.project({ _id: 0, a: true });
- * ```
- *
- * @remarks
- *
- * **Note for Typescript Users:** adding a transform changes the return type of the iteration of this cursor,
- * it **does not** return a new instance of a cursor. This means when calling project,
- * you should always assign the result to a new variable in order to get a correctly typed cursor variable.
- * Take note of the following example:
- *
- * @example
- * ```typescript
- * const cursor: FindCursor<{ a: number; b: string }> = coll.find();
- * const projectCursor = cursor.project<{ a: number }>({ _id: 0, a: true });
- * const aPropOnlyArray: {a: number}[] = await projectCursor.toArray();
- *
- * // or always use chaining and save the final cursor
- *
- * const cursor = coll.find().project<{ a: string }>({
- * _id: 0,
- * a: { $convert: { input: '$a', to: 'string' }
- * }});
- * ```
- */
- project(value) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kBuiltOptions].projection = value;
- return this;
- }
- /**
- * Sets the sort order of the cursor query.
- *
- * @param sort - The key or keys set for the sort.
- * @param direction - The direction of the sorting (1 or -1).
- */
- sort(sort, direction) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- if (this[kBuiltOptions].tailable) {
- throw new error_1.MongoTailableCursorError("Tailable cursor does not support sorting");
- }
- this[kBuiltOptions].sort = (0, sort_1.formatSort)(sort, direction);
- return this;
- }
- /**
- * Allows disk use for blocking sort operations exceeding 100MB memory. (MongoDB 3.2 or higher)
- *
- * @remarks
- * {@link https://www.mongodb.com/docs/manual/reference/command/find/#find-cmd-allowdiskuse | find command allowDiskUse documentation}
- */
- allowDiskUse(allow = true) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- if (!this[kBuiltOptions].sort) {
- throw new error_1.MongoInvalidArgumentError('Option "allowDiskUse" requires a sort specification');
- }
- if (!allow) {
- this[kBuiltOptions].allowDiskUse = false;
- return this;
- }
- this[kBuiltOptions].allowDiskUse = true;
- return this;
- }
- /**
- * Set the collation options for the cursor.
- *
- * @param value - The cursor collation options (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
- */
- collation(value) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- this[kBuiltOptions].collation = value;
- return this;
- }
- /**
- * Set the limit for the cursor.
- *
- * @param value - The limit for the cursor query.
- */
- limit(value) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- if (this[kBuiltOptions].tailable) {
- throw new error_1.MongoTailableCursorError("Tailable cursor does not support limit");
- }
- if (typeof value !== "number") {
- throw new error_1.MongoInvalidArgumentError('Operation "limit" requires an integer');
- }
- this[kBuiltOptions].limit = value;
- return this;
- }
- /**
- * Set the skip for the cursor.
- *
- * @param value - The skip for the cursor query.
- */
- skip(value) {
- (0, abstract_cursor_1.assertUninitialized)(this);
- if (this[kBuiltOptions].tailable) {
- throw new error_1.MongoTailableCursorError("Tailable cursor does not support skip");
- }
- if (typeof value !== "number") {
- throw new error_1.MongoInvalidArgumentError('Operation "skip" requires an integer');
- }
- this[kBuiltOptions].skip = value;
- return this;
- }
- };
- exports2.FindCursor = FindCursor;
- }
- });
- // node_modules/mongodb/lib/operations/indexes.js
- var require_indexes = __commonJS({
- "node_modules/mongodb/lib/operations/indexes.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.IndexInformationOperation = exports2.IndexExistsOperation = exports2.ListIndexesOperation = exports2.DropIndexesOperation = exports2.DropIndexOperation = exports2.EnsureIndexOperation = exports2.CreateIndexOperation = exports2.CreateIndexesOperation = exports2.IndexesOperation = void 0;
- var error_1 = require_error();
- var read_preference_1 = require_read_preference();
- var utils_1 = require_utils();
- var command_1 = require_command();
- var common_functions_1 = require_common_functions();
- var operation_1 = require_operation();
- var VALID_INDEX_OPTIONS = /* @__PURE__ */ new Set([
- "background",
- "unique",
- "name",
- "partialFilterExpression",
- "sparse",
- "hidden",
- "expireAfterSeconds",
- "storageEngine",
- "collation",
- "version",
- // text indexes
- "weights",
- "default_language",
- "language_override",
- "textIndexVersion",
- // 2d-sphere indexes
- "2dsphereIndexVersion",
- // 2d indexes
- "bits",
- "min",
- "max",
- // geoHaystack Indexes
- "bucketSize",
- // wildcard indexes
- "wildcardProjection"
- ]);
- function isIndexDirection(x) {
- return typeof x === "number" || x === "2d" || x === "2dsphere" || x === "text" || x === "geoHaystack";
- }
- function isSingleIndexTuple(t) {
- return Array.isArray(t) && t.length === 2 && isIndexDirection(t[1]);
- }
- function makeIndexSpec(indexSpec, options) {
- const key = /* @__PURE__ */ new Map();
- const indexSpecs = !Array.isArray(indexSpec) || isSingleIndexTuple(indexSpec) ? [indexSpec] : indexSpec;
- for (const spec of indexSpecs) {
- if (typeof spec === "string") {
- key.set(spec, 1);
- } else if (Array.isArray(spec)) {
- key.set(spec[0], spec[1] ?? 1);
- } else if (spec instanceof Map) {
- for (const [property, value] of spec) {
- key.set(property, value);
- }
- } else if ((0, utils_1.isObject)(spec)) {
- for (const [property, value] of Object.entries(spec)) {
- key.set(property, value);
- }
- }
- }
- return { ...options, key };
- }
- var IndexesOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(collection, options) {
- super(options);
- this.options = options;
- this.collection = collection;
- }
- executeCallback(server, session, callback) {
- const coll = this.collection;
- const options = this.options;
- (0, common_functions_1.indexInformation)(coll.s.db, coll.collectionName, { full: true, ...options, readPreference: this.readPreference, session }, callback);
- }
- };
- exports2.IndexesOperation = IndexesOperation;
- var CreateIndexesOperation = class extends command_1.CommandCallbackOperation {
- constructor(parent, collectionName, indexes, options) {
- super(parent, options);
- this.options = options ?? {};
- this.collectionName = collectionName;
- this.indexes = indexes.map((userIndex) => {
- const key = userIndex.key instanceof Map ? userIndex.key : new Map(Object.entries(userIndex.key));
- const name = userIndex.name != null ? userIndex.name : Array.from(key).flat().join("_");
- const validIndexOptions = Object.fromEntries(Object.entries({ ...userIndex }).filter(([optionName]) => VALID_INDEX_OPTIONS.has(optionName)));
- return {
- ...validIndexOptions,
- name,
- key
- };
- });
- }
- executeCallback(server, session, callback) {
- const options = this.options;
- const indexes = this.indexes;
- const serverWireVersion = (0, utils_1.maxWireVersion)(server);
- const cmd = { createIndexes: this.collectionName, indexes };
- if (options.commitQuorum != null) {
- if (serverWireVersion < 9) {
- callback(new error_1.MongoCompatibilityError("Option `commitQuorum` for `createIndexes` not supported on servers < 4.4"));
- return;
- }
- cmd.commitQuorum = options.commitQuorum;
- }
- this.options.collation = void 0;
- super.executeCommandCallback(server, session, cmd, (err) => {
- if (err) {
- callback(err);
- return;
- }
- const indexNames = indexes.map((index) => index.name || "");
- callback(void 0, indexNames);
- });
- }
- };
- exports2.CreateIndexesOperation = CreateIndexesOperation;
- var CreateIndexOperation = class extends CreateIndexesOperation {
- constructor(parent, collectionName, indexSpec, options) {
- super(parent, collectionName, [makeIndexSpec(indexSpec, options)], options);
- }
- executeCallback(server, session, callback) {
- super.executeCallback(server, session, (err, indexNames) => {
- if (err || !indexNames)
- return callback(err);
- return callback(void 0, indexNames[0]);
- });
- }
- };
- exports2.CreateIndexOperation = CreateIndexOperation;
- var EnsureIndexOperation = class extends CreateIndexOperation {
- constructor(db, collectionName, indexSpec, options) {
- super(db, collectionName, indexSpec, options);
- this.readPreference = read_preference_1.ReadPreference.primary;
- this.db = db;
- this.collectionName = collectionName;
- }
- executeCallback(server, session, callback) {
- const indexName = this.indexes[0].name;
- const cursor = this.db.collection(this.collectionName).listIndexes({ session });
- cursor.toArray().then((indexes) => {
- indexes = Array.isArray(indexes) ? indexes : [indexes];
- if (indexes.some((index) => index.name === indexName)) {
- callback(void 0, indexName);
- return;
- }
- super.executeCallback(server, session, callback);
- }, (error) => {
- if (error instanceof error_1.MongoError && error.code === error_1.MONGODB_ERROR_CODES.NamespaceNotFound) {
- return super.executeCallback(server, session, callback);
- }
- return callback(error);
- });
- }
- };
- exports2.EnsureIndexOperation = EnsureIndexOperation;
- var DropIndexOperation = class extends command_1.CommandCallbackOperation {
- constructor(collection, indexName, options) {
- super(collection, options);
- this.options = options ?? {};
- this.collection = collection;
- this.indexName = indexName;
- }
- executeCallback(server, session, callback) {
- const cmd = { dropIndexes: this.collection.collectionName, index: this.indexName };
- super.executeCommandCallback(server, session, cmd, callback);
- }
- };
- exports2.DropIndexOperation = DropIndexOperation;
- var DropIndexesOperation = class extends DropIndexOperation {
- constructor(collection, options) {
- super(collection, "*", options);
- }
- executeCallback(server, session, callback) {
- super.executeCallback(server, session, (err) => {
- if (err)
- return callback(err, false);
- callback(void 0, true);
- });
- }
- };
- exports2.DropIndexesOperation = DropIndexesOperation;
- var ListIndexesOperation = class extends command_1.CommandCallbackOperation {
- constructor(collection, options) {
- super(collection, options);
- this.options = { ...options };
- delete this.options.writeConcern;
- this.collectionNamespace = collection.s.namespace;
- }
- executeCallback(server, session, callback) {
- const serverWireVersion = (0, utils_1.maxWireVersion)(server);
- const cursor = this.options.batchSize ? { batchSize: this.options.batchSize } : {};
- const command = { listIndexes: this.collectionNamespace.collection, cursor };
- if (serverWireVersion >= 9 && this.options.comment !== void 0) {
- command.comment = this.options.comment;
- }
- super.executeCommandCallback(server, session, command, callback);
- }
- };
- exports2.ListIndexesOperation = ListIndexesOperation;
- var IndexExistsOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(collection, indexes, options) {
- super(options);
- this.options = options;
- this.collection = collection;
- this.indexes = indexes;
- }
- executeCallback(server, session, callback) {
- const coll = this.collection;
- const indexes = this.indexes;
- (0, common_functions_1.indexInformation)(coll.s.db, coll.collectionName, { ...this.options, readPreference: this.readPreference, session }, (err, indexInformation) => {
- if (err != null)
- return callback(err);
- if (!Array.isArray(indexes))
- return callback(void 0, indexInformation[indexes] != null);
- for (let i = 0; i < indexes.length; i++) {
- if (indexInformation[indexes[i]] == null) {
- return callback(void 0, false);
- }
- }
- return callback(void 0, true);
- });
- }
- };
- exports2.IndexExistsOperation = IndexExistsOperation;
- var IndexInformationOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(db, name, options) {
- super(options);
- this.options = options ?? {};
- this.db = db;
- this.name = name;
- }
- executeCallback(server, session, callback) {
- const db = this.db;
- const name = this.name;
- (0, common_functions_1.indexInformation)(db, name, { ...this.options, readPreference: this.readPreference, session }, callback);
- }
- };
- exports2.IndexInformationOperation = IndexInformationOperation;
- (0, operation_1.defineAspects)(ListIndexesOperation, [
- operation_1.Aspect.READ_OPERATION,
- operation_1.Aspect.RETRYABLE,
- operation_1.Aspect.CURSOR_CREATING
- ]);
- (0, operation_1.defineAspects)(CreateIndexesOperation, [operation_1.Aspect.WRITE_OPERATION]);
- (0, operation_1.defineAspects)(CreateIndexOperation, [operation_1.Aspect.WRITE_OPERATION]);
- (0, operation_1.defineAspects)(EnsureIndexOperation, [operation_1.Aspect.WRITE_OPERATION]);
- (0, operation_1.defineAspects)(DropIndexOperation, [operation_1.Aspect.WRITE_OPERATION]);
- (0, operation_1.defineAspects)(DropIndexesOperation, [operation_1.Aspect.WRITE_OPERATION]);
- }
- });
- // node_modules/mongodb/lib/cursor/list_indexes_cursor.js
- var require_list_indexes_cursor = __commonJS({
- "node_modules/mongodb/lib/cursor/list_indexes_cursor.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ListIndexesCursor = void 0;
- var execute_operation_1 = require_execute_operation();
- var indexes_1 = require_indexes();
- var abstract_cursor_1 = require_abstract_cursor();
- var ListIndexesCursor = class _ListIndexesCursor extends abstract_cursor_1.AbstractCursor {
- constructor(collection, options) {
- super(collection.client, collection.s.namespace, options);
- this.parent = collection;
- this.options = options;
- }
- clone() {
- return new _ListIndexesCursor(this.parent, {
- ...this.options,
- ...this.cursorOptions
- });
- }
- /** @internal */
- _initialize(session, callback) {
- const operation = new indexes_1.ListIndexesOperation(this.parent, {
- ...this.cursorOptions,
- ...this.options,
- session
- });
- (0, execute_operation_1.executeOperation)(this.parent.client, operation, (err, response) => {
- if (err || response == null)
- return callback(err);
- callback(void 0, { server: operation.server, session, response });
- });
- }
- };
- exports2.ListIndexesCursor = ListIndexesCursor;
- }
- });
- // node_modules/mongodb/lib/cursor/list_search_indexes_cursor.js
- var require_list_search_indexes_cursor = __commonJS({
- "node_modules/mongodb/lib/cursor/list_search_indexes_cursor.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ListSearchIndexesCursor = void 0;
- var aggregation_cursor_1 = require_aggregation_cursor();
- var ListSearchIndexesCursor = class extends aggregation_cursor_1.AggregationCursor {
- /** @internal */
- constructor({ fullNamespace: ns, client }, name, options = {}) {
- const pipeline = name == null ? [{ $listSearchIndexes: {} }] : [{ $listSearchIndexes: { name } }];
- super(client, ns, pipeline, options);
- }
- };
- exports2.ListSearchIndexesCursor = ListSearchIndexesCursor;
- }
- });
- // node_modules/mongodb/lib/operations/count_documents.js
- var require_count_documents = __commonJS({
- "node_modules/mongodb/lib/operations/count_documents.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.CountDocumentsOperation = void 0;
- var aggregate_1 = require_aggregate();
- var CountDocumentsOperation = class extends aggregate_1.AggregateOperation {
- constructor(collection, query, options) {
- const pipeline = [];
- pipeline.push({ $match: query });
- if (typeof options.skip === "number") {
- pipeline.push({ $skip: options.skip });
- }
- if (typeof options.limit === "number") {
- pipeline.push({ $limit: options.limit });
- }
- pipeline.push({ $group: { _id: 1, n: { $sum: 1 } } });
- super(collection.s.namespace, pipeline, options);
- }
- executeCallback(server, session, callback) {
- super.executeCallback(server, session, (err, result) => {
- if (err || !result) {
- callback(err);
- return;
- }
- const response = result;
- if (response.cursor == null || response.cursor.firstBatch == null) {
- callback(void 0, 0);
- return;
- }
- const docs = response.cursor.firstBatch;
- callback(void 0, docs.length ? docs[0].n : 0);
- });
- }
- };
- exports2.CountDocumentsOperation = CountDocumentsOperation;
- }
- });
- // node_modules/mongodb/lib/operations/distinct.js
- var require_distinct = __commonJS({
- "node_modules/mongodb/lib/operations/distinct.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.DistinctOperation = void 0;
- var utils_1 = require_utils();
- var command_1 = require_command();
- var operation_1 = require_operation();
- var DistinctOperation = class extends command_1.CommandCallbackOperation {
- /**
- * Construct a Distinct operation.
- *
- * @param collection - Collection instance.
- * @param key - Field of the document to find distinct values for.
- * @param query - The query for filtering the set of documents to which we apply the distinct filter.
- * @param options - Optional settings. See Collection.prototype.distinct for a list of options.
- */
- constructor(collection, key, query, options) {
- super(collection, options);
- this.options = options ?? {};
- this.collection = collection;
- this.key = key;
- this.query = query;
- }
- executeCallback(server, session, callback) {
- const coll = this.collection;
- const key = this.key;
- const query = this.query;
- const options = this.options;
- const cmd = {
- distinct: coll.collectionName,
- key,
- query
- };
- if (typeof options.maxTimeMS === "number") {
- cmd.maxTimeMS = options.maxTimeMS;
- }
- if (typeof options.comment !== "undefined") {
- cmd.comment = options.comment;
- }
- (0, utils_1.decorateWithReadConcern)(cmd, coll, options);
- try {
- (0, utils_1.decorateWithCollation)(cmd, coll, options);
- } catch (err) {
- return callback(err);
- }
- super.executeCommandCallback(server, session, cmd, (err, result) => {
- if (err) {
- callback(err);
- return;
- }
- callback(void 0, this.explain ? result : result.values);
- });
- }
- };
- exports2.DistinctOperation = DistinctOperation;
- (0, operation_1.defineAspects)(DistinctOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE, operation_1.Aspect.EXPLAINABLE]);
- }
- });
- // node_modules/mongodb/lib/operations/drop.js
- var require_drop = __commonJS({
- "node_modules/mongodb/lib/operations/drop.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.DropDatabaseOperation = exports2.DropCollectionOperation = void 0;
- var error_1 = require_error();
- var command_1 = require_command();
- var operation_1 = require_operation();
- var DropCollectionOperation = class _DropCollectionOperation extends command_1.CommandCallbackOperation {
- constructor(db, name, options = {}) {
- super(db, options);
- this.db = db;
- this.options = options;
- this.name = name;
- }
- executeCallback(server, session, callback) {
- (async () => {
- var _a, _b, _c;
- const db = this.db;
- const options = this.options;
- const name = this.name;
- const encryptedFieldsMap = (_a = db.client.options.autoEncryption) == null ? void 0 : _a.encryptedFieldsMap;
- let encryptedFields = options.encryptedFields ?? (encryptedFieldsMap == null ? void 0 : encryptedFieldsMap[`${db.databaseName}.${name}`]);
- if (!encryptedFields && encryptedFieldsMap) {
- const listCollectionsResult = await db.listCollections({ name }, { nameOnly: false }).toArray();
- encryptedFields = (_c = (_b = listCollectionsResult == null ? void 0 : listCollectionsResult[0]) == null ? void 0 : _b.options) == null ? void 0 : _c.encryptedFields;
- }
- if (encryptedFields) {
- const escCollection = encryptedFields.escCollection || `enxcol_.${name}.esc`;
- const ecocCollection = encryptedFields.ecocCollection || `enxcol_.${name}.ecoc`;
- for (const collectionName of [escCollection, ecocCollection]) {
- const dropOp = new _DropCollectionOperation(db, collectionName);
- try {
- await dropOp.executeWithoutEncryptedFieldsCheck(server, session);
- } catch (err) {
- if (!(err instanceof error_1.MongoServerError) || err.code !== error_1.MONGODB_ERROR_CODES.NamespaceNotFound) {
- throw err;
- }
- }
- }
- }
- return this.executeWithoutEncryptedFieldsCheck(server, session);
- })().then((result) => callback(void 0, result), (err) => callback(err));
- }
- executeWithoutEncryptedFieldsCheck(server, session) {
- return new Promise((resolve, reject) => {
- super.executeCommandCallback(server, session, { drop: this.name }, (err, result) => {
- if (err)
- return reject(err);
- resolve(!!result.ok);
- });
- });
- }
- };
- exports2.DropCollectionOperation = DropCollectionOperation;
- var DropDatabaseOperation = class extends command_1.CommandCallbackOperation {
- constructor(db, options) {
- super(db, options);
- this.options = options;
- }
- executeCallback(server, session, callback) {
- super.executeCommandCallback(server, session, { dropDatabase: 1 }, (err, result) => {
- if (err)
- return callback(err);
- if (result.ok)
- return callback(void 0, true);
- callback(void 0, false);
- });
- }
- };
- exports2.DropDatabaseOperation = DropDatabaseOperation;
- (0, operation_1.defineAspects)(DropCollectionOperation, [operation_1.Aspect.WRITE_OPERATION]);
- (0, operation_1.defineAspects)(DropDatabaseOperation, [operation_1.Aspect.WRITE_OPERATION]);
- }
- });
- // node_modules/mongodb/lib/operations/estimated_document_count.js
- var require_estimated_document_count = __commonJS({
- "node_modules/mongodb/lib/operations/estimated_document_count.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.EstimatedDocumentCountOperation = void 0;
- var command_1 = require_command();
- var operation_1 = require_operation();
- var EstimatedDocumentCountOperation = class extends command_1.CommandCallbackOperation {
- constructor(collection, options = {}) {
- super(collection, options);
- this.options = options;
- this.collectionName = collection.collectionName;
- }
- executeCallback(server, session, callback) {
- const cmd = { count: this.collectionName };
- if (typeof this.options.maxTimeMS === "number") {
- cmd.maxTimeMS = this.options.maxTimeMS;
- }
- if (this.options.comment !== void 0) {
- cmd.comment = this.options.comment;
- }
- super.executeCommandCallback(server, session, cmd, (err, response) => {
- if (err) {
- callback(err);
- return;
- }
- callback(void 0, (response == null ? void 0 : response.n) || 0);
- });
- }
- };
- exports2.EstimatedDocumentCountOperation = EstimatedDocumentCountOperation;
- (0, operation_1.defineAspects)(EstimatedDocumentCountOperation, [
- operation_1.Aspect.READ_OPERATION,
- operation_1.Aspect.RETRYABLE,
- operation_1.Aspect.CURSOR_CREATING
- ]);
- }
- });
- // node_modules/mongodb/lib/operations/find_and_modify.js
- var require_find_and_modify = __commonJS({
- "node_modules/mongodb/lib/operations/find_and_modify.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.FindOneAndUpdateOperation = exports2.FindOneAndReplaceOperation = exports2.FindOneAndDeleteOperation = exports2.ReturnDocument = void 0;
- var error_1 = require_error();
- var read_preference_1 = require_read_preference();
- var sort_1 = require_sort();
- var utils_1 = require_utils();
- var command_1 = require_command();
- var operation_1 = require_operation();
- exports2.ReturnDocument = Object.freeze({
- BEFORE: "before",
- AFTER: "after"
- });
- function configureFindAndModifyCmdBaseUpdateOpts(cmdBase, options) {
- cmdBase.new = options.returnDocument === exports2.ReturnDocument.AFTER;
- cmdBase.upsert = options.upsert === true;
- if (options.bypassDocumentValidation === true) {
- cmdBase.bypassDocumentValidation = options.bypassDocumentValidation;
- }
- return cmdBase;
- }
- var FindAndModifyOperation = class extends command_1.CommandCallbackOperation {
- constructor(collection, query, options) {
- super(collection, options);
- this.options = options ?? {};
- this.cmdBase = {
- remove: false,
- new: false,
- upsert: false
- };
- options.includeResultMetadata ?? (options.includeResultMetadata = true);
- const sort = (0, sort_1.formatSort)(options.sort);
- if (sort) {
- this.cmdBase.sort = sort;
- }
- if (options.projection) {
- this.cmdBase.fields = options.projection;
- }
- if (options.maxTimeMS) {
- this.cmdBase.maxTimeMS = options.maxTimeMS;
- }
- if (options.writeConcern) {
- this.cmdBase.writeConcern = options.writeConcern;
- }
- if (options.let) {
- this.cmdBase.let = options.let;
- }
- if (options.comment !== void 0) {
- this.cmdBase.comment = options.comment;
- }
- this.readPreference = read_preference_1.ReadPreference.primary;
- this.collection = collection;
- this.query = query;
- }
- executeCallback(server, session, callback) {
- var _a;
- const coll = this.collection;
- const query = this.query;
- const options = { ...this.options, ...this.bsonOptions };
- const cmd = {
- findAndModify: coll.collectionName,
- query,
- ...this.cmdBase
- };
- try {
- (0, utils_1.decorateWithCollation)(cmd, coll, options);
- } catch (err) {
- return callback(err);
- }
- if (options.hint) {
- const unacknowledgedWrite = ((_a = this.writeConcern) == null ? void 0 : _a.w) === 0;
- if (unacknowledgedWrite || (0, utils_1.maxWireVersion)(server) < 8) {
- callback(new error_1.MongoCompatibilityError("The current topology does not support a hint on findAndModify commands"));
- return;
- }
- cmd.hint = options.hint;
- }
- super.executeCommandCallback(server, session, cmd, (err, result) => {
- if (err)
- return callback(err);
- return callback(void 0, options.includeResultMetadata ? result : result.value ?? null);
- });
- }
- };
- var FindOneAndDeleteOperation = class extends FindAndModifyOperation {
- constructor(collection, filter, options) {
- if (filter == null || typeof filter !== "object") {
- throw new error_1.MongoInvalidArgumentError('Argument "filter" must be an object');
- }
- super(collection, filter, options);
- this.cmdBase.remove = true;
- }
- };
- exports2.FindOneAndDeleteOperation = FindOneAndDeleteOperation;
- var FindOneAndReplaceOperation = class extends FindAndModifyOperation {
- constructor(collection, filter, replacement, options) {
- if (filter == null || typeof filter !== "object") {
- throw new error_1.MongoInvalidArgumentError('Argument "filter" must be an object');
- }
- if (replacement == null || typeof replacement !== "object") {
- throw new error_1.MongoInvalidArgumentError('Argument "replacement" must be an object');
- }
- if ((0, utils_1.hasAtomicOperators)(replacement)) {
- throw new error_1.MongoInvalidArgumentError("Replacement document must not contain atomic operators");
- }
- super(collection, filter, options);
- this.cmdBase.update = replacement;
- configureFindAndModifyCmdBaseUpdateOpts(this.cmdBase, options);
- }
- };
- exports2.FindOneAndReplaceOperation = FindOneAndReplaceOperation;
- var FindOneAndUpdateOperation = class extends FindAndModifyOperation {
- constructor(collection, filter, update, options) {
- if (filter == null || typeof filter !== "object") {
- throw new error_1.MongoInvalidArgumentError('Argument "filter" must be an object');
- }
- if (update == null || typeof update !== "object") {
- throw new error_1.MongoInvalidArgumentError('Argument "update" must be an object');
- }
- if (!(0, utils_1.hasAtomicOperators)(update)) {
- throw new error_1.MongoInvalidArgumentError("Update document requires atomic operators");
- }
- super(collection, filter, options);
- this.cmdBase.update = update;
- configureFindAndModifyCmdBaseUpdateOpts(this.cmdBase, options);
- if (options.arrayFilters) {
- this.cmdBase.arrayFilters = options.arrayFilters;
- }
- }
- };
- exports2.FindOneAndUpdateOperation = FindOneAndUpdateOperation;
- (0, operation_1.defineAspects)(FindAndModifyOperation, [
- operation_1.Aspect.WRITE_OPERATION,
- operation_1.Aspect.RETRYABLE,
- operation_1.Aspect.EXPLAINABLE
- ]);
- }
- });
- // node_modules/mongodb/lib/operations/is_capped.js
- var require_is_capped = __commonJS({
- "node_modules/mongodb/lib/operations/is_capped.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.IsCappedOperation = void 0;
- var error_1 = require_error();
- var operation_1 = require_operation();
- var IsCappedOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(collection, options) {
- super(options);
- this.options = options;
- this.collection = collection;
- }
- executeCallback(server, session, callback) {
- const coll = this.collection;
- coll.s.db.listCollections({ name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session }).toArray().then((collections) => {
- var _a;
- if (collections.length === 0) {
- return callback(new error_1.MongoAPIError(`collection ${coll.namespace} not found`));
- }
- callback(void 0, !!((_a = collections[0].options) == null ? void 0 : _a.capped));
- }, (error) => callback(error));
- }
- };
- exports2.IsCappedOperation = IsCappedOperation;
- }
- });
- // node_modules/mongodb/lib/operations/options_operation.js
- var require_options_operation = __commonJS({
- "node_modules/mongodb/lib/operations/options_operation.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.OptionsOperation = void 0;
- var error_1 = require_error();
- var operation_1 = require_operation();
- var OptionsOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(collection, options) {
- super(options);
- this.options = options;
- this.collection = collection;
- }
- executeCallback(server, session, callback) {
- const coll = this.collection;
- coll.s.db.listCollections({ name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session }).toArray().then((collections) => {
- if (collections.length === 0) {
- return callback(new error_1.MongoAPIError(`collection ${coll.namespace} not found`));
- }
- callback(void 0, collections[0].options);
- }, (error) => callback(error));
- }
- };
- exports2.OptionsOperation = OptionsOperation;
- }
- });
- // node_modules/mongodb/lib/operations/rename.js
- var require_rename = __commonJS({
- "node_modules/mongodb/lib/operations/rename.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.RenameOperation = void 0;
- var collection_1 = require_collection();
- var error_1 = require_error();
- var utils_1 = require_utils();
- var operation_1 = require_operation();
- var run_command_1 = require_run_command();
- var RenameOperation = class extends run_command_1.RunAdminCommandOperation {
- constructor(collection, newName, options) {
- (0, utils_1.checkCollectionName)(newName);
- const renameCollection = collection.namespace;
- const toCollection = collection.s.namespace.withCollection(newName).toString();
- const dropTarget = typeof options.dropTarget === "boolean" ? options.dropTarget : false;
- const cmd = { renameCollection, to: toCollection, dropTarget };
- super(collection, cmd, options);
- this.options = options;
- this.collection = collection;
- this.newName = newName;
- }
- executeCallback(server, session, callback) {
- const coll = this.collection;
- super.executeCallback(server, session, (err, doc) => {
- if (err)
- return callback(err);
- if (doc == null ? void 0 : doc.errmsg) {
- return callback(new error_1.MongoServerError(doc));
- }
- let newColl;
- try {
- newColl = new collection_1.Collection(coll.s.db, this.newName, coll.s.options);
- } catch (err2) {
- return callback(err2);
- }
- return callback(void 0, newColl);
- });
- }
- };
- exports2.RenameOperation = RenameOperation;
- (0, operation_1.defineAspects)(RenameOperation, [operation_1.Aspect.WRITE_OPERATION]);
- }
- });
- // node_modules/mongodb/lib/operations/search_indexes/create.js
- var require_create = __commonJS({
- "node_modules/mongodb/lib/operations/search_indexes/create.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.CreateSearchIndexesOperation = void 0;
- var operation_1 = require_operation();
- var CreateSearchIndexesOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(collection, descriptions) {
- super();
- this.collection = collection;
- this.descriptions = descriptions;
- }
- executeCallback(server, session, callback) {
- const namespace = this.collection.fullNamespace;
- const command = {
- createSearchIndexes: namespace.collection,
- indexes: this.descriptions
- };
- server.command(namespace, command, { session }, (err, res) => {
- if (err || !res) {
- callback(err);
- return;
- }
- const indexesCreated = (res == null ? void 0 : res.indexesCreated) ?? [];
- callback(void 0, indexesCreated.map(({ name }) => name));
- });
- }
- };
- exports2.CreateSearchIndexesOperation = CreateSearchIndexesOperation;
- }
- });
- // node_modules/mongodb/lib/operations/search_indexes/drop.js
- var require_drop2 = __commonJS({
- "node_modules/mongodb/lib/operations/search_indexes/drop.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.DropSearchIndexOperation = void 0;
- var operation_1 = require_operation();
- var DropSearchIndexOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(collection, name) {
- super();
- this.collection = collection;
- this.name = name;
- }
- executeCallback(server, session, callback) {
- const namespace = this.collection.fullNamespace;
- const command = {
- dropSearchIndex: namespace.collection
- };
- if (typeof this.name === "string") {
- command.name = this.name;
- }
- server.command(namespace, command, { session }, (err) => {
- if (err) {
- callback(err);
- return;
- }
- callback();
- });
- }
- };
- exports2.DropSearchIndexOperation = DropSearchIndexOperation;
- }
- });
- // node_modules/mongodb/lib/operations/search_indexes/update.js
- var require_update2 = __commonJS({
- "node_modules/mongodb/lib/operations/search_indexes/update.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.UpdateSearchIndexOperation = void 0;
- var operation_1 = require_operation();
- var UpdateSearchIndexOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(collection, name, definition) {
- super();
- this.collection = collection;
- this.name = name;
- this.definition = definition;
- }
- executeCallback(server, session, callback) {
- const namespace = this.collection.fullNamespace;
- const command = {
- updateSearchIndex: namespace.collection,
- name: this.name,
- definition: this.definition
- };
- server.command(namespace, command, { session }, (err) => {
- if (err) {
- callback(err);
- return;
- }
- callback();
- });
- }
- };
- exports2.UpdateSearchIndexOperation = UpdateSearchIndexOperation;
- }
- });
- // node_modules/mongodb/lib/operations/stats.js
- var require_stats = __commonJS({
- "node_modules/mongodb/lib/operations/stats.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.DbStatsOperation = exports2.CollStatsOperation = void 0;
- var command_1 = require_command();
- var operation_1 = require_operation();
- var CollStatsOperation = class extends command_1.CommandCallbackOperation {
- /**
- * Construct a Stats operation.
- *
- * @param collection - Collection instance
- * @param options - Optional settings. See Collection.prototype.stats for a list of options.
- */
- constructor(collection, options) {
- super(collection, options);
- this.options = options ?? {};
- this.collectionName = collection.collectionName;
- }
- executeCallback(server, session, callback) {
- const command = { collStats: this.collectionName };
- if (this.options.scale != null) {
- command.scale = this.options.scale;
- }
- super.executeCommandCallback(server, session, command, callback);
- }
- };
- exports2.CollStatsOperation = CollStatsOperation;
- var DbStatsOperation = class extends command_1.CommandCallbackOperation {
- constructor(db, options) {
- super(db, options);
- this.options = options;
- }
- executeCallback(server, session, callback) {
- const command = { dbStats: true };
- if (this.options.scale != null) {
- command.scale = this.options.scale;
- }
- super.executeCommandCallback(server, session, command, callback);
- }
- };
- exports2.DbStatsOperation = DbStatsOperation;
- (0, operation_1.defineAspects)(CollStatsOperation, [operation_1.Aspect.READ_OPERATION]);
- (0, operation_1.defineAspects)(DbStatsOperation, [operation_1.Aspect.READ_OPERATION]);
- }
- });
- // node_modules/mongodb/lib/collection.js
- var require_collection = __commonJS({
- "node_modules/mongodb/lib/collection.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.Collection = void 0;
- var bson_1 = require_bson2();
- var ordered_1 = require_ordered();
- var unordered_1 = require_unordered();
- var change_stream_1 = require_change_stream();
- var aggregation_cursor_1 = require_aggregation_cursor();
- var find_cursor_1 = require_find_cursor();
- var list_indexes_cursor_1 = require_list_indexes_cursor();
- var list_search_indexes_cursor_1 = require_list_search_indexes_cursor();
- var error_1 = require_error();
- var bulk_write_1 = require_bulk_write();
- var count_1 = require_count();
- var count_documents_1 = require_count_documents();
- var delete_1 = require_delete();
- var distinct_1 = require_distinct();
- var drop_1 = require_drop();
- var estimated_document_count_1 = require_estimated_document_count();
- var execute_operation_1 = require_execute_operation();
- var find_and_modify_1 = require_find_and_modify();
- var indexes_1 = require_indexes();
- var insert_1 = require_insert();
- var is_capped_1 = require_is_capped();
- var options_operation_1 = require_options_operation();
- var rename_1 = require_rename();
- var create_1 = require_create();
- var drop_2 = require_drop2();
- var update_1 = require_update2();
- var stats_1 = require_stats();
- var update_2 = require_update();
- var read_concern_1 = require_read_concern();
- var read_preference_1 = require_read_preference();
- var utils_1 = require_utils();
- var write_concern_1 = require_write_concern();
- var Collection = class {
- /**
- * Create a new Collection instance
- * @internal
- */
- constructor(db, name, options) {
- var _a;
- (0, utils_1.checkCollectionName)(name);
- this.s = {
- db,
- options,
- namespace: new utils_1.MongoDBCollectionNamespace(db.databaseName, name),
- pkFactory: ((_a = db.options) == null ? void 0 : _a.pkFactory) ?? utils_1.DEFAULT_PK_FACTORY,
- readPreference: read_preference_1.ReadPreference.fromOptions(options),
- bsonOptions: (0, bson_1.resolveBSONOptions)(options, db),
- readConcern: read_concern_1.ReadConcern.fromOptions(options),
- writeConcern: write_concern_1.WriteConcern.fromOptions(options)
- };
- this.client = db.client;
- }
- /**
- * The name of the database this collection belongs to
- */
- get dbName() {
- return this.s.namespace.db;
- }
- /**
- * The name of this collection
- */
- get collectionName() {
- return this.s.namespace.collection;
- }
- /**
- * The namespace of this collection, in the format `${this.dbName}.${this.collectionName}`
- */
- get namespace() {
- return this.fullNamespace.toString();
- }
- /**
- * @internal
- *
- * The `MongoDBNamespace` for the collection.
- */
- get fullNamespace() {
- return this.s.namespace;
- }
- /**
- * The current readConcern of the collection. If not explicitly defined for
- * this collection, will be inherited from the parent DB
- */
- get readConcern() {
- if (this.s.readConcern == null) {
- return this.s.db.readConcern;
- }
- return this.s.readConcern;
- }
- /**
- * The current readPreference of the collection. If not explicitly defined for
- * this collection, will be inherited from the parent DB
- */
- get readPreference() {
- if (this.s.readPreference == null) {
- return this.s.db.readPreference;
- }
- return this.s.readPreference;
- }
- get bsonOptions() {
- return this.s.bsonOptions;
- }
- /**
- * The current writeConcern of the collection. If not explicitly defined for
- * this collection, will be inherited from the parent DB
- */
- get writeConcern() {
- if (this.s.writeConcern == null) {
- return this.s.db.writeConcern;
- }
- return this.s.writeConcern;
- }
- /** The current index hint for the collection */
- get hint() {
- return this.s.collectionHint;
- }
- set hint(v) {
- this.s.collectionHint = (0, utils_1.normalizeHintField)(v);
- }
- /**
- * Inserts a single document into MongoDB. If documents passed in do not contain the **_id** field,
- * one will be added to each of the documents missing it by the driver, mutating the document. This behavior
- * can be overridden by setting the **forceServerObjectId** flag.
- *
- * @param doc - The document to insert
- * @param options - Optional settings for the command
- */
- async insertOne(doc, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new insert_1.InsertOneOperation(this, doc, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Inserts an array of documents into MongoDB. If documents passed in do not contain the **_id** field,
- * one will be added to each of the documents missing it by the driver, mutating the document. This behavior
- * can be overridden by setting the **forceServerObjectId** flag.
- *
- * @param docs - The documents to insert
- * @param options - Optional settings for the command
- */
- async insertMany(docs, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new insert_1.InsertManyOperation(this, docs, (0, utils_1.resolveOptions)(this, options ?? { ordered: true })));
- }
- /**
- * Perform a bulkWrite operation without a fluent API
- *
- * Legal operation types are
- * - `insertOne`
- * - `replaceOne`
- * - `updateOne`
- * - `updateMany`
- * - `deleteOne`
- * - `deleteMany`
- *
- * If documents passed in do not contain the **_id** field,
- * one will be added to each of the documents missing it by the driver, mutating the document. This behavior
- * can be overridden by setting the **forceServerObjectId** flag.
- *
- * @param operations - Bulk operations to perform
- * @param options - Optional settings for the command
- * @throws MongoDriverError if operations is not an array
- */
- async bulkWrite(operations, options) {
- if (!Array.isArray(operations)) {
- throw new error_1.MongoInvalidArgumentError('Argument "operations" must be an array of documents');
- }
- return (0, execute_operation_1.executeOperation)(this.client, new bulk_write_1.BulkWriteOperation(this, operations, (0, utils_1.resolveOptions)(this, options ?? { ordered: true })));
- }
- /**
- * Update a single document in a collection
- *
- * @param filter - The filter used to select the document to update
- * @param update - The update operations to be applied to the document
- * @param options - Optional settings for the command
- */
- async updateOne(filter, update, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new update_2.UpdateOneOperation(this, filter, update, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Replace a document in a collection with another document
- *
- * @param filter - The filter used to select the document to replace
- * @param replacement - The Document that replaces the matching document
- * @param options - Optional settings for the command
- */
- async replaceOne(filter, replacement, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new update_2.ReplaceOneOperation(this, filter, replacement, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Update multiple documents in a collection
- *
- * @param filter - The filter used to select the documents to update
- * @param update - The update operations to be applied to the documents
- * @param options - Optional settings for the command
- */
- async updateMany(filter, update, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new update_2.UpdateManyOperation(this, filter, update, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Delete a document from a collection
- *
- * @param filter - The filter used to select the document to remove
- * @param options - Optional settings for the command
- */
- async deleteOne(filter = {}, options = {}) {
- return (0, execute_operation_1.executeOperation)(this.client, new delete_1.DeleteOneOperation(this, filter, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Delete multiple documents from a collection
- *
- * @param filter - The filter used to select the documents to remove
- * @param options - Optional settings for the command
- */
- async deleteMany(filter = {}, options = {}) {
- return (0, execute_operation_1.executeOperation)(this.client, new delete_1.DeleteManyOperation(this, filter, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Rename the collection.
- *
- * @remarks
- * This operation does not inherit options from the Db or MongoClient.
- *
- * @param newName - New name of of the collection.
- * @param options - Optional settings for the command
- */
- async rename(newName, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new rename_1.RenameOperation(this, newName, {
- ...options,
- readPreference: read_preference_1.ReadPreference.PRIMARY
- }));
- }
- /**
- * Drop the collection from the database, removing it permanently. New accesses will create a new collection.
- *
- * @param options - Optional settings for the command
- */
- async drop(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new drop_1.DropCollectionOperation(this.s.db, this.collectionName, options));
- }
- async findOne(filter = {}, options = {}) {
- const cursor = this.find(filter, options).limit(-1).batchSize(1);
- const res = await cursor.next();
- await cursor.close();
- return res;
- }
- find(filter = {}, options = {}) {
- return new find_cursor_1.FindCursor(this.client, this.s.namespace, filter, (0, utils_1.resolveOptions)(this, options));
- }
- /**
- * Returns the options of the collection.
- *
- * @param options - Optional settings for the command
- */
- async options(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new options_operation_1.OptionsOperation(this, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Returns if the collection is a capped collection
- *
- * @param options - Optional settings for the command
- */
- async isCapped(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new is_capped_1.IsCappedOperation(this, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Creates an index on the db and collection collection.
- *
- * @param indexSpec - The field name or index specification to create an index for
- * @param options - Optional settings for the command
- *
- * @example
- * ```ts
- * const collection = client.db('foo').collection('bar');
- *
- * await collection.createIndex({ a: 1, b: -1 });
- *
- * // Alternate syntax for { c: 1, d: -1 } that ensures order of indexes
- * await collection.createIndex([ [c, 1], [d, -1] ]);
- *
- * // Equivalent to { e: 1 }
- * await collection.createIndex('e');
- *
- * // Equivalent to { f: 1, g: 1 }
- * await collection.createIndex(['f', 'g'])
- *
- * // Equivalent to { h: 1, i: -1 }
- * await collection.createIndex([ { h: 1 }, { i: -1 } ]);
- *
- * // Equivalent to { j: 1, k: -1, l: 2d }
- * await collection.createIndex(['j', ['k', -1], { l: '2d' }])
- * ```
- */
- async createIndex(indexSpec, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new indexes_1.CreateIndexOperation(this, this.collectionName, indexSpec, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Creates multiple indexes in the collection, this method is only supported for
- * MongoDB 2.6 or higher. Earlier version of MongoDB will throw a command not supported
- * error.
- *
- * **Note**: Unlike {@link Collection#createIndex| createIndex}, this function takes in raw index specifications.
- * Index specifications are defined {@link https://www.mongodb.com/docs/manual/reference/command/createIndexes/| here}.
- *
- * @param indexSpecs - An array of index specifications to be created
- * @param options - Optional settings for the command
- *
- * @example
- * ```ts
- * const collection = client.db('foo').collection('bar');
- * await collection.createIndexes([
- * // Simple index on field fizz
- * {
- * key: { fizz: 1 },
- * }
- * // wildcard index
- * {
- * key: { '$**': 1 }
- * },
- * // named index on darmok and jalad
- * {
- * key: { darmok: 1, jalad: -1 }
- * name: 'tanagra'
- * }
- * ]);
- * ```
- */
- async createIndexes(indexSpecs, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new indexes_1.CreateIndexesOperation(this, this.collectionName, indexSpecs, (0, utils_1.resolveOptions)(this, { ...options, maxTimeMS: void 0 })));
- }
- /**
- * Drops an index from this collection.
- *
- * @param indexName - Name of the index to drop.
- * @param options - Optional settings for the command
- */
- async dropIndex(indexName, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new indexes_1.DropIndexOperation(this, indexName, {
- ...(0, utils_1.resolveOptions)(this, options),
- readPreference: read_preference_1.ReadPreference.primary
- }));
- }
- /**
- * Drops all indexes from this collection.
- *
- * @param options - Optional settings for the command
- */
- async dropIndexes(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new indexes_1.DropIndexesOperation(this, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Get the list of all indexes information for the collection.
- *
- * @param options - Optional settings for the command
- */
- listIndexes(options) {
- return new list_indexes_cursor_1.ListIndexesCursor(this, (0, utils_1.resolveOptions)(this, options));
- }
- /**
- * Checks if one or more indexes exist on the collection, fails on first non-existing index
- *
- * @param indexes - One or more index names to check.
- * @param options - Optional settings for the command
- */
- async indexExists(indexes, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new indexes_1.IndexExistsOperation(this, indexes, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Retrieves this collections index info.
- *
- * @param options - Optional settings for the command
- */
- async indexInformation(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new indexes_1.IndexInformationOperation(this.s.db, this.collectionName, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Gets an estimate of the count of documents in a collection using collection metadata.
- * This will always run a count command on all server versions.
- *
- * due to an oversight in versions 5.0.0-5.0.8 of MongoDB, the count command,
- * which estimatedDocumentCount uses in its implementation, was not included in v1 of
- * the Stable API, and so users of the Stable API with estimatedDocumentCount are
- * recommended to upgrade their server version to 5.0.9+ or set apiStrict: false to avoid
- * encountering errors.
- *
- * @see {@link https://www.mongodb.com/docs/manual/reference/command/count/#behavior|Count: Behavior}
- * @param options - Optional settings for the command
- */
- async estimatedDocumentCount(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new estimated_document_count_1.EstimatedDocumentCountOperation(this, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Gets the number of documents matching the filter.
- * For a fast count of the total documents in a collection see {@link Collection#estimatedDocumentCount| estimatedDocumentCount}.
- * **Note**: When migrating from {@link Collection#count| count} to {@link Collection#countDocuments| countDocuments}
- * the following query operators must be replaced:
- *
- * | Operator | Replacement |
- * | -------- | ----------- |
- * | `$where` | [`$expr`][1] |
- * | `$near` | [`$geoWithin`][2] with [`$center`][3] |
- * | `$nearSphere` | [`$geoWithin`][2] with [`$centerSphere`][4] |
- *
- * [1]: https://www.mongodb.com/docs/manual/reference/operator/query/expr/
- * [2]: https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/
- * [3]: https://www.mongodb.com/docs/manual/reference/operator/query/center/#op._S_center
- * [4]: https://www.mongodb.com/docs/manual/reference/operator/query/centerSphere/#op._S_centerSphere
- *
- * @param filter - The filter for the count
- * @param options - Optional settings for the command
- *
- * @see https://www.mongodb.com/docs/manual/reference/operator/query/expr/
- * @see https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/
- * @see https://www.mongodb.com/docs/manual/reference/operator/query/center/#op._S_center
- * @see https://www.mongodb.com/docs/manual/reference/operator/query/centerSphere/#op._S_centerSphere
- */
- async countDocuments(filter = {}, options = {}) {
- return (0, execute_operation_1.executeOperation)(this.client, new count_documents_1.CountDocumentsOperation(this, filter, (0, utils_1.resolveOptions)(this, options)));
- }
- async distinct(key, filter = {}, options = {}) {
- return (0, execute_operation_1.executeOperation)(this.client, new distinct_1.DistinctOperation(this, key, filter, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Retrieve all the indexes on the collection.
- *
- * @param options - Optional settings for the command
- */
- async indexes(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new indexes_1.IndexesOperation(this, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Get all the collection statistics.
- *
- * @deprecated the `collStats` operation will be removed in the next major release. Please
- * use an aggregation pipeline with the [`$collStats`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/) stage instead
- *
- * @param options - Optional settings for the command
- */
- async stats(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new stats_1.CollStatsOperation(this, options));
- }
- async findOneAndDelete(filter, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new find_and_modify_1.FindOneAndDeleteOperation(this, filter, (0, utils_1.resolveOptions)(this, options)));
- }
- async findOneAndReplace(filter, replacement, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new find_and_modify_1.FindOneAndReplaceOperation(this, filter, replacement, (0, utils_1.resolveOptions)(this, options)));
- }
- async findOneAndUpdate(filter, update, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new find_and_modify_1.FindOneAndUpdateOperation(this, filter, update, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Execute an aggregation framework pipeline against the collection, needs MongoDB \>= 2.2
- *
- * @param pipeline - An array of aggregation pipelines to execute
- * @param options - Optional settings for the command
- */
- aggregate(pipeline = [], options) {
- if (!Array.isArray(pipeline)) {
- throw new error_1.MongoInvalidArgumentError('Argument "pipeline" must be an array of aggregation stages');
- }
- return new aggregation_cursor_1.AggregationCursor(this.client, this.s.namespace, pipeline, (0, utils_1.resolveOptions)(this, options));
- }
- /**
- * Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this collection.
- *
- * @remarks
- * watch() accepts two generic arguments for distinct use cases:
- * - The first is to override the schema that may be defined for this specific collection
- * - The second is to override the shape of the change stream document entirely, if it is not provided the type will default to ChangeStreamDocument of the first argument
- * @example
- * By just providing the first argument I can type the change to be `ChangeStreamDocument<{ _id: number }>`
- * ```ts
- * collection.watch<{ _id: number }>()
- * .on('change', change => console.log(change._id.toFixed(4)));
- * ```
- *
- * @example
- * Passing a second argument provides a way to reflect the type changes caused by an advanced pipeline.
- * Here, we are using a pipeline to have MongoDB filter for insert changes only and add a comment.
- * No need start from scratch on the ChangeStreamInsertDocument type!
- * By using an intersection we can save time and ensure defaults remain the same type!
- * ```ts
- * collection
- * .watch<Schema, ChangeStreamInsertDocument<Schema> & { comment: string }>([
- * { $addFields: { comment: 'big changes' } },
- * { $match: { operationType: 'insert' } }
- * ])
- * .on('change', change => {
- * change.comment.startsWith('big');
- * change.operationType === 'insert';
- * // No need to narrow in code because the generics did that for us!
- * expectType<Schema>(change.fullDocument);
- * });
- * ```
- *
- * @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
- * @param options - Optional settings for the command
- * @typeParam TLocal - Type of the data being detected by the change stream
- * @typeParam TChange - Type of the whole change stream document emitted
- */
- watch(pipeline = [], options = {}) {
- if (!Array.isArray(pipeline)) {
- options = pipeline;
- pipeline = [];
- }
- return new change_stream_1.ChangeStream(this, pipeline, (0, utils_1.resolveOptions)(this, options));
- }
- /**
- * Initiate an Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.
- *
- * @throws MongoNotConnectedError
- * @remarks
- * **NOTE:** MongoClient must be connected prior to calling this method due to a known limitation in this legacy implementation.
- * However, `collection.bulkWrite()` provides an equivalent API that does not require prior connecting.
- */
- initializeUnorderedBulkOp(options) {
- return new unordered_1.UnorderedBulkOperation(this, (0, utils_1.resolveOptions)(this, options));
- }
- /**
- * Initiate an In order bulk write operation. Operations will be serially executed in the order they are added, creating a new operation for each switch in types.
- *
- * @throws MongoNotConnectedError
- * @remarks
- * **NOTE:** MongoClient must be connected prior to calling this method due to a known limitation in this legacy implementation.
- * However, `collection.bulkWrite()` provides an equivalent API that does not require prior connecting.
- */
- initializeOrderedBulkOp(options) {
- return new ordered_1.OrderedBulkOperation(this, (0, utils_1.resolveOptions)(this, options));
- }
- /**
- * An estimated count of matching documents in the db to a filter.
- *
- * **NOTE:** This method has been deprecated, since it does not provide an accurate count of the documents
- * in a collection. To obtain an accurate count of documents in the collection, use {@link Collection#countDocuments| countDocuments}.
- * To obtain an estimated count of all documents in the collection, use {@link Collection#estimatedDocumentCount| estimatedDocumentCount}.
- *
- * @deprecated use {@link Collection#countDocuments| countDocuments} or {@link Collection#estimatedDocumentCount| estimatedDocumentCount} instead
- *
- * @param filter - The filter for the count.
- * @param options - Optional settings for the command
- */
- async count(filter = {}, options = {}) {
- return (0, execute_operation_1.executeOperation)(this.client, new count_1.CountOperation(this.fullNamespace, filter, (0, utils_1.resolveOptions)(this, options)));
- }
- listSearchIndexes(indexNameOrOptions, options) {
- options = typeof indexNameOrOptions === "object" ? indexNameOrOptions : options == null ? {} : options;
- const indexName = indexNameOrOptions == null ? null : typeof indexNameOrOptions === "object" ? null : indexNameOrOptions;
- return new list_search_indexes_cursor_1.ListSearchIndexesCursor(this, indexName, options);
- }
- /**
- * Creates a single search index for the collection.
- *
- * @param description - The index description for the new search index.
- * @returns A promise that resolves to the name of the new search index.
- *
- * @remarks Only available when used against a 7.0+ Atlas cluster.
- */
- async createSearchIndex(description) {
- const [index] = await this.createSearchIndexes([description]);
- return index;
- }
- /**
- * Creates multiple search indexes for the current collection.
- *
- * @param descriptions - An array of `SearchIndexDescription`s for the new search indexes.
- * @returns A promise that resolves to an array of the newly created search index names.
- *
- * @remarks Only available when used against a 7.0+ Atlas cluster.
- * @returns
- */
- async createSearchIndexes(descriptions) {
- return (0, execute_operation_1.executeOperation)(this.client, new create_1.CreateSearchIndexesOperation(this, descriptions));
- }
- /**
- * Deletes a search index by index name.
- *
- * @param name - The name of the search index to be deleted.
- *
- * @remarks Only available when used against a 7.0+ Atlas cluster.
- */
- async dropSearchIndex(name) {
- return (0, execute_operation_1.executeOperation)(this.client, new drop_2.DropSearchIndexOperation(this, name));
- }
- /**
- * Updates a search index by replacing the existing index definition with the provided definition.
- *
- * @param name - The name of the search index to update.
- * @param definition - The new search index definition.
- *
- * @remarks Only available when used against a 7.0+ Atlas cluster.
- */
- async updateSearchIndex(name, definition) {
- return (0, execute_operation_1.executeOperation)(this.client, new update_1.UpdateSearchIndexOperation(this, name, definition));
- }
- };
- exports2.Collection = Collection;
- }
- });
- // node_modules/mongodb/lib/cursor/change_stream_cursor.js
- var require_change_stream_cursor = __commonJS({
- "node_modules/mongodb/lib/cursor/change_stream_cursor.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ChangeStreamCursor = void 0;
- var change_stream_1 = require_change_stream();
- var constants_1 = require_constants2();
- var aggregate_1 = require_aggregate();
- var execute_operation_1 = require_execute_operation();
- var utils_1 = require_utils();
- var abstract_cursor_1 = require_abstract_cursor();
- var ChangeStreamCursor = class _ChangeStreamCursor extends abstract_cursor_1.AbstractCursor {
- constructor(client, namespace, pipeline = [], options = {}) {
- super(client, namespace, options);
- this.pipeline = pipeline;
- this.options = options;
- this._resumeToken = null;
- this.startAtOperationTime = options.startAtOperationTime;
- if (options.startAfter) {
- this.resumeToken = options.startAfter;
- } else if (options.resumeAfter) {
- this.resumeToken = options.resumeAfter;
- }
- }
- set resumeToken(token) {
- this._resumeToken = token;
- this.emit(change_stream_1.ChangeStream.RESUME_TOKEN_CHANGED, token);
- }
- get resumeToken() {
- return this._resumeToken;
- }
- get resumeOptions() {
- const options = {
- ...this.options
- };
- for (const key of ["resumeAfter", "startAfter", "startAtOperationTime"]) {
- delete options[key];
- }
- if (this.resumeToken != null) {
- if (this.options.startAfter && !this.hasReceived) {
- options.startAfter = this.resumeToken;
- } else {
- options.resumeAfter = this.resumeToken;
- }
- } else if (this.startAtOperationTime != null && (0, utils_1.maxWireVersion)(this.server) >= 7) {
- options.startAtOperationTime = this.startAtOperationTime;
- }
- return options;
- }
- cacheResumeToken(resumeToken) {
- if (this.bufferedCount() === 0 && this.postBatchResumeToken) {
- this.resumeToken = this.postBatchResumeToken;
- } else {
- this.resumeToken = resumeToken;
- }
- this.hasReceived = true;
- }
- _processBatch(response) {
- const cursor = response.cursor;
- if (cursor.postBatchResumeToken) {
- this.postBatchResumeToken = response.cursor.postBatchResumeToken;
- const batch = "firstBatch" in response.cursor ? response.cursor.firstBatch : response.cursor.nextBatch;
- if (batch.length === 0) {
- this.resumeToken = cursor.postBatchResumeToken;
- }
- }
- }
- clone() {
- return new _ChangeStreamCursor(this.client, this.namespace, this.pipeline, {
- ...this.cursorOptions
- });
- }
- _initialize(session, callback) {
- const aggregateOperation = new aggregate_1.AggregateOperation(this.namespace, this.pipeline, {
- ...this.cursorOptions,
- ...this.options,
- session
- });
- (0, execute_operation_1.executeOperation)(session.client, aggregateOperation, (err, response) => {
- if (err || response == null) {
- return callback(err);
- }
- const server = aggregateOperation.server;
- this.maxWireVersion = (0, utils_1.maxWireVersion)(server);
- if (this.startAtOperationTime == null && this.resumeAfter == null && this.startAfter == null && this.maxWireVersion >= 7) {
- this.startAtOperationTime = response.operationTime;
- }
- this._processBatch(response);
- this.emit(constants_1.INIT, response);
- this.emit(constants_1.RESPONSE);
- callback(void 0, { server, session, response });
- });
- }
- _getMore(batchSize, callback) {
- super._getMore(batchSize, (err, response) => {
- if (err) {
- return callback(err);
- }
- this.maxWireVersion = (0, utils_1.maxWireVersion)(this.server);
- this._processBatch(response);
- this.emit(change_stream_1.ChangeStream.MORE, response);
- this.emit(change_stream_1.ChangeStream.RESPONSE);
- callback(err, response);
- });
- }
- };
- exports2.ChangeStreamCursor = ChangeStreamCursor;
- }
- });
- // node_modules/mongodb/lib/operations/list_collections.js
- var require_list_collections = __commonJS({
- "node_modules/mongodb/lib/operations/list_collections.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ListCollectionsOperation = void 0;
- var utils_1 = require_utils();
- var command_1 = require_command();
- var operation_1 = require_operation();
- var ListCollectionsOperation = class extends command_1.CommandCallbackOperation {
- constructor(db, filter, options) {
- super(db, options);
- this.options = { ...options };
- delete this.options.writeConcern;
- this.db = db;
- this.filter = filter;
- this.nameOnly = !!this.options.nameOnly;
- this.authorizedCollections = !!this.options.authorizedCollections;
- if (typeof this.options.batchSize === "number") {
- this.batchSize = this.options.batchSize;
- }
- }
- executeCallback(server, session, callback) {
- return super.executeCommandCallback(server, session, this.generateCommand((0, utils_1.maxWireVersion)(server)), callback);
- }
- /* This is here for the purpose of unit testing the final command that gets sent. */
- generateCommand(wireVersion) {
- const command = {
- listCollections: 1,
- filter: this.filter,
- cursor: this.batchSize ? { batchSize: this.batchSize } : {},
- nameOnly: this.nameOnly,
- authorizedCollections: this.authorizedCollections
- };
- if (wireVersion >= 9 && this.options.comment !== void 0) {
- command.comment = this.options.comment;
- }
- return command;
- }
- };
- exports2.ListCollectionsOperation = ListCollectionsOperation;
- (0, operation_1.defineAspects)(ListCollectionsOperation, [
- operation_1.Aspect.READ_OPERATION,
- operation_1.Aspect.RETRYABLE,
- operation_1.Aspect.CURSOR_CREATING
- ]);
- }
- });
- // node_modules/mongodb/lib/cursor/list_collections_cursor.js
- var require_list_collections_cursor = __commonJS({
- "node_modules/mongodb/lib/cursor/list_collections_cursor.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ListCollectionsCursor = void 0;
- var execute_operation_1 = require_execute_operation();
- var list_collections_1 = require_list_collections();
- var abstract_cursor_1 = require_abstract_cursor();
- var ListCollectionsCursor = class _ListCollectionsCursor extends abstract_cursor_1.AbstractCursor {
- constructor(db, filter, options) {
- super(db.client, db.s.namespace, options);
- this.parent = db;
- this.filter = filter;
- this.options = options;
- }
- clone() {
- return new _ListCollectionsCursor(this.parent, this.filter, {
- ...this.options,
- ...this.cursorOptions
- });
- }
- /** @internal */
- _initialize(session, callback) {
- const operation = new list_collections_1.ListCollectionsOperation(this.parent, this.filter, {
- ...this.cursorOptions,
- ...this.options,
- session
- });
- (0, execute_operation_1.executeOperation)(this.parent.client, operation, (err, response) => {
- if (err || response == null)
- return callback(err);
- callback(void 0, { server: operation.server, session, response });
- });
- }
- };
- exports2.ListCollectionsCursor = ListCollectionsCursor;
- }
- });
- // node_modules/mongodb/lib/cursor/run_command_cursor.js
- var require_run_command_cursor = __commonJS({
- "node_modules/mongodb/lib/cursor/run_command_cursor.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.RunCommandCursor = void 0;
- var error_1 = require_error();
- var execute_operation_1 = require_execute_operation();
- var get_more_1 = require_get_more();
- var run_command_1 = require_run_command();
- var utils_1 = require_utils();
- var abstract_cursor_1 = require_abstract_cursor();
- var RunCommandCursor = class extends abstract_cursor_1.AbstractCursor {
- /**
- * Controls the `getMore.comment` field
- * @param comment - any BSON value
- */
- setComment(comment) {
- this.getMoreOptions.comment = comment;
- return this;
- }
- /**
- * Controls the `getMore.maxTimeMS` field. Only valid when cursor is tailable await
- * @param maxTimeMS - the number of milliseconds to wait for new data
- */
- setMaxTimeMS(maxTimeMS) {
- this.getMoreOptions.maxAwaitTimeMS = maxTimeMS;
- return this;
- }
- /**
- * Controls the `getMore.batchSize` field
- * @param maxTimeMS - the number documents to return in the `nextBatch`
- */
- setBatchSize(batchSize) {
- this.getMoreOptions.batchSize = batchSize;
- return this;
- }
- /** Unsupported for RunCommandCursor */
- clone() {
- throw new error_1.MongoAPIError("Clone not supported, create a new cursor with db.runCursorCommand");
- }
- /** Unsupported for RunCommandCursor: readConcern must be configured directly on command document */
- withReadConcern(_) {
- throw new error_1.MongoAPIError("RunCommandCursor does not support readConcern it must be attached to the command being run");
- }
- /** Unsupported for RunCommandCursor: various cursor flags must be configured directly on command document */
- addCursorFlag(_, __) {
- throw new error_1.MongoAPIError("RunCommandCursor does not support cursor flags, they must be attached to the command being run");
- }
- /** Unsupported for RunCommandCursor: maxTimeMS must be configured directly on command document */
- maxTimeMS(_) {
- throw new error_1.MongoAPIError("maxTimeMS must be configured on the command document directly, to configure getMore.maxTimeMS use cursor.setMaxTimeMS()");
- }
- /** Unsupported for RunCommandCursor: batchSize must be configured directly on command document */
- batchSize(_) {
- throw new error_1.MongoAPIError("batchSize must be configured on the command document directly, to configure getMore.batchSize use cursor.setBatchSize()");
- }
- /** @internal */
- constructor(db, command, options = {}) {
- super(db.client, (0, utils_1.ns)(db.namespace), options);
- this.getMoreOptions = {};
- this.db = db;
- this.command = Object.freeze({ ...command });
- }
- /** @internal */
- _initialize(session, callback) {
- const operation = new run_command_1.RunCommandOperation(this.db, this.command, {
- ...this.cursorOptions,
- session,
- readPreference: this.cursorOptions.readPreference
- });
- (0, execute_operation_1.executeOperation)(this.client, operation).then((response) => {
- if (response.cursor == null) {
- callback(new error_1.MongoUnexpectedServerResponseError("Expected server to respond with cursor"));
- return;
- }
- callback(void 0, {
- server: operation.server,
- session,
- response
- });
- }, (err) => callback(err));
- }
- /** @internal */
- _getMore(_batchSize, callback) {
- const getMoreOperation = new get_more_1.GetMoreOperation(this.namespace, this.id, this.server, {
- ...this.cursorOptions,
- session: this.session,
- ...this.getMoreOptions
- });
- (0, execute_operation_1.executeOperation)(this.client, getMoreOperation, callback);
- }
- };
- exports2.RunCommandCursor = RunCommandCursor;
- }
- });
- // node_modules/mongodb/lib/operations/collections.js
- var require_collections = __commonJS({
- "node_modules/mongodb/lib/operations/collections.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.CollectionsOperation = void 0;
- var collection_1 = require_collection();
- var operation_1 = require_operation();
- var CollectionsOperation = class extends operation_1.AbstractCallbackOperation {
- constructor(db, options) {
- super(options);
- this.options = options;
- this.db = db;
- }
- executeCallback(server, session, callback) {
- this.db.listCollections({}, { ...this.options, nameOnly: true, readPreference: this.readPreference, session }).toArray().then((documents) => {
- const collections = [];
- for (const { name } of documents) {
- if (!name.includes("$")) {
- collections.push(new collection_1.Collection(this.db, name, this.db.s.options));
- }
- }
- callback(void 0, collections);
- }, (error) => callback(error));
- }
- };
- exports2.CollectionsOperation = CollectionsOperation;
- }
- });
- // node_modules/mongodb/lib/operations/create_collection.js
- var require_create_collection = __commonJS({
- "node_modules/mongodb/lib/operations/create_collection.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.CreateCollectionOperation = void 0;
- var constants_1 = require_constants();
- var collection_1 = require_collection();
- var error_1 = require_error();
- var command_1 = require_command();
- var indexes_1 = require_indexes();
- var operation_1 = require_operation();
- var ILLEGAL_COMMAND_FIELDS = /* @__PURE__ */ new Set([
- "w",
- "wtimeout",
- "j",
- "fsync",
- "autoIndexId",
- "pkFactory",
- "raw",
- "readPreference",
- "session",
- "readConcern",
- "writeConcern",
- "raw",
- "fieldsAsRaw",
- "useBigInt64",
- "promoteLongs",
- "promoteValues",
- "promoteBuffers",
- "bsonRegExp",
- "serializeFunctions",
- "ignoreUndefined",
- "enableUtf8Validation"
- ]);
- var INVALID_QE_VERSION = "Driver support of Queryable Encryption is incompatible with server. Upgrade server to use Queryable Encryption.";
- var CreateCollectionOperation = class _CreateCollectionOperation extends command_1.CommandCallbackOperation {
- constructor(db, name, options = {}) {
- super(db, options);
- this.options = options;
- this.db = db;
- this.name = name;
- }
- executeCallback(server, session, callback) {
- (async () => {
- var _a, _b;
- const db = this.db;
- const name = this.name;
- const options = this.options;
- const encryptedFields = options.encryptedFields ?? ((_b = (_a = db.client.options.autoEncryption) == null ? void 0 : _a.encryptedFieldsMap) == null ? void 0 : _b[`${db.databaseName}.${name}`]);
- if (encryptedFields) {
- if (!server.loadBalanced && server.description.maxWireVersion < constants_1.MIN_SUPPORTED_QE_WIRE_VERSION) {
- throw new error_1.MongoCompatibilityError(`${INVALID_QE_VERSION} The minimum server version required is ${constants_1.MIN_SUPPORTED_QE_SERVER_VERSION}`);
- }
- const escCollection = encryptedFields.escCollection ?? `enxcol_.${name}.esc`;
- const ecocCollection = encryptedFields.ecocCollection ?? `enxcol_.${name}.ecoc`;
- for (const collectionName of [escCollection, ecocCollection]) {
- const createOp = new _CreateCollectionOperation(db, collectionName, {
- clusteredIndex: {
- key: { _id: 1 },
- unique: true
- }
- });
- await createOp.executeWithoutEncryptedFieldsCheck(server, session);
- }
- if (!options.encryptedFields) {
- this.options = { ...this.options, encryptedFields };
- }
- }
- const coll = await this.executeWithoutEncryptedFieldsCheck(server, session);
- if (encryptedFields) {
- const createIndexOp = new indexes_1.CreateIndexOperation(db, name, { __safeContent__: 1 }, {});
- await createIndexOp.execute(server, session);
- }
- return coll;
- })().then((coll) => callback(void 0, coll), (err) => callback(err));
- }
- executeWithoutEncryptedFieldsCheck(server, session) {
- return new Promise((resolve, reject) => {
- const db = this.db;
- const name = this.name;
- const options = this.options;
- const done = (err) => {
- if (err) {
- return reject(err);
- }
- resolve(new collection_1.Collection(db, name, options));
- };
- const cmd = { create: name };
- for (const n in options) {
- if (options[n] != null && typeof options[n] !== "function" && !ILLEGAL_COMMAND_FIELDS.has(n)) {
- cmd[n] = options[n];
- }
- }
- super.executeCommandCallback(server, session, cmd, done);
- });
- }
- };
- exports2.CreateCollectionOperation = CreateCollectionOperation;
- (0, operation_1.defineAspects)(CreateCollectionOperation, [operation_1.Aspect.WRITE_OPERATION]);
- }
- });
- // node_modules/mongodb/lib/operations/profiling_level.js
- var require_profiling_level = __commonJS({
- "node_modules/mongodb/lib/operations/profiling_level.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ProfilingLevelOperation = void 0;
- var error_1 = require_error();
- var command_1 = require_command();
- var ProfilingLevelOperation = class extends command_1.CommandCallbackOperation {
- constructor(db, options) {
- super(db, options);
- this.options = options;
- }
- executeCallback(server, session, callback) {
- super.executeCommandCallback(server, session, { profile: -1 }, (err, doc) => {
- if (err == null && doc.ok === 1) {
- const was = doc.was;
- if (was === 0)
- return callback(void 0, "off");
- if (was === 1)
- return callback(void 0, "slow_only");
- if (was === 2)
- return callback(void 0, "all");
- return callback(new error_1.MongoRuntimeError(`Illegal profiling level value ${was}`));
- } else {
- err != null ? callback(err) : callback(new error_1.MongoRuntimeError("Error with profile command"));
- }
- });
- }
- };
- exports2.ProfilingLevelOperation = ProfilingLevelOperation;
- }
- });
- // node_modules/mongodb/lib/operations/set_profiling_level.js
- var require_set_profiling_level = __commonJS({
- "node_modules/mongodb/lib/operations/set_profiling_level.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.SetProfilingLevelOperation = exports2.ProfilingLevel = void 0;
- var error_1 = require_error();
- var utils_1 = require_utils();
- var command_1 = require_command();
- var levelValues = /* @__PURE__ */ new Set(["off", "slow_only", "all"]);
- exports2.ProfilingLevel = Object.freeze({
- off: "off",
- slowOnly: "slow_only",
- all: "all"
- });
- var SetProfilingLevelOperation = class extends command_1.CommandCallbackOperation {
- constructor(db, level, options) {
- super(db, options);
- this.options = options;
- switch (level) {
- case exports2.ProfilingLevel.off:
- this.profile = 0;
- break;
- case exports2.ProfilingLevel.slowOnly:
- this.profile = 1;
- break;
- case exports2.ProfilingLevel.all:
- this.profile = 2;
- break;
- default:
- this.profile = 0;
- break;
- }
- this.level = level;
- }
- executeCallback(server, session, callback) {
- const level = this.level;
- if (!levelValues.has(level)) {
- return callback(new error_1.MongoInvalidArgumentError(`Profiling level must be one of "${(0, utils_1.enumToString)(exports2.ProfilingLevel)}"`));
- }
- super.executeCommandCallback(server, session, { profile: this.profile }, (err, doc) => {
- if (err == null && doc.ok === 1)
- return callback(void 0, level);
- return err != null ? callback(err) : callback(new error_1.MongoRuntimeError("Error with profile command"));
- });
- }
- };
- exports2.SetProfilingLevelOperation = SetProfilingLevelOperation;
- }
- });
- // node_modules/mongodb/lib/db.js
- var require_db = __commonJS({
- "node_modules/mongodb/lib/db.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.Db = void 0;
- var admin_1 = require_admin();
- var bson_1 = require_bson2();
- var change_stream_1 = require_change_stream();
- var collection_1 = require_collection();
- var CONSTANTS = require_constants2();
- var aggregation_cursor_1 = require_aggregation_cursor();
- var list_collections_cursor_1 = require_list_collections_cursor();
- var run_command_cursor_1 = require_run_command_cursor();
- var error_1 = require_error();
- var add_user_1 = require_add_user();
- var collections_1 = require_collections();
- var create_collection_1 = require_create_collection();
- var drop_1 = require_drop();
- var execute_operation_1 = require_execute_operation();
- var indexes_1 = require_indexes();
- var profiling_level_1 = require_profiling_level();
- var remove_user_1 = require_remove_user();
- var rename_1 = require_rename();
- var run_command_1 = require_run_command();
- var set_profiling_level_1 = require_set_profiling_level();
- var stats_1 = require_stats();
- var read_concern_1 = require_read_concern();
- var read_preference_1 = require_read_preference();
- var utils_1 = require_utils();
- var write_concern_1 = require_write_concern();
- var DB_OPTIONS_ALLOW_LIST = [
- "writeConcern",
- "readPreference",
- "readPreferenceTags",
- "native_parser",
- "forceServerObjectId",
- "pkFactory",
- "serializeFunctions",
- "raw",
- "authSource",
- "ignoreUndefined",
- "readConcern",
- "retryMiliSeconds",
- "numberOfRetries",
- "useBigInt64",
- "promoteBuffers",
- "promoteLongs",
- "bsonRegExp",
- "enableUtf8Validation",
- "promoteValues",
- "compression",
- "retryWrites"
- ];
- var Db = class {
- /**
- * Creates a new Db instance
- *
- * @param client - The MongoClient for the database.
- * @param databaseName - The name of the database this instance represents.
- * @param options - Optional settings for Db construction
- */
- constructor(client, databaseName, options) {
- options = options ?? {};
- options = (0, utils_1.filterOptions)(options, DB_OPTIONS_ALLOW_LIST);
- validateDatabaseName(databaseName);
- this.s = {
- // Options
- options,
- // Unpack read preference
- readPreference: read_preference_1.ReadPreference.fromOptions(options),
- // Merge bson options
- bsonOptions: (0, bson_1.resolveBSONOptions)(options, client),
- // Set up the primary key factory or fallback to ObjectId
- pkFactory: (options == null ? void 0 : options.pkFactory) ?? utils_1.DEFAULT_PK_FACTORY,
- // ReadConcern
- readConcern: read_concern_1.ReadConcern.fromOptions(options),
- writeConcern: write_concern_1.WriteConcern.fromOptions(options),
- // Namespace
- namespace: new utils_1.MongoDBNamespace(databaseName)
- };
- this.client = client;
- }
- get databaseName() {
- return this.s.namespace.db;
- }
- // Options
- get options() {
- return this.s.options;
- }
- /**
- * Check if a secondary can be used (because the read preference is *not* set to primary)
- */
- get secondaryOk() {
- var _a;
- return ((_a = this.s.readPreference) == null ? void 0 : _a.preference) !== "primary" || false;
- }
- get readConcern() {
- return this.s.readConcern;
- }
- /**
- * The current readPreference of the Db. If not explicitly defined for
- * this Db, will be inherited from the parent MongoClient
- */
- get readPreference() {
- if (this.s.readPreference == null) {
- return this.client.readPreference;
- }
- return this.s.readPreference;
- }
- get bsonOptions() {
- return this.s.bsonOptions;
- }
- // get the write Concern
- get writeConcern() {
- return this.s.writeConcern;
- }
- get namespace() {
- return this.s.namespace.toString();
- }
- /**
- * Create a new collection on a server with the specified options. Use this to create capped collections.
- * More information about command options available at https://www.mongodb.com/docs/manual/reference/command/create/
- *
- * @param name - The name of the collection to create
- * @param options - Optional settings for the command
- */
- async createCollection(name, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new create_collection_1.CreateCollectionOperation(this, name, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Execute a command
- *
- * @remarks
- * This command does not inherit options from the MongoClient.
- *
- * The driver will ensure the following fields are attached to the command sent to the server:
- * - `lsid` - sourced from an implicit session or options.session
- * - `$readPreference` - defaults to primary or can be configured by options.readPreference
- * - `$db` - sourced from the name of this database
- *
- * If the client has a serverApi setting:
- * - `apiVersion`
- * - `apiStrict`
- * - `apiDeprecationErrors`
- *
- * When in a transaction:
- * - `readConcern` - sourced from readConcern set on the TransactionOptions
- * - `writeConcern` - sourced from writeConcern set on the TransactionOptions
- *
- * Attaching any of the above fields to the command will have no effect as the driver will overwrite the value.
- *
- * @param command - The command to run
- * @param options - Optional settings for the command
- */
- async command(command, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new run_command_1.RunCommandOperation(this, command, options));
- }
- /**
- * Execute an aggregation framework pipeline against the database, needs MongoDB \>= 3.6
- *
- * @param pipeline - An array of aggregation stages to be executed
- * @param options - Optional settings for the command
- */
- aggregate(pipeline = [], options) {
- return new aggregation_cursor_1.AggregationCursor(this.client, this.s.namespace, pipeline, (0, utils_1.resolveOptions)(this, options));
- }
- /** Return the Admin db instance */
- admin() {
- return new admin_1.Admin(this);
- }
- /**
- * Returns a reference to a MongoDB Collection. If it does not exist it will be created implicitly.
- *
- * @param name - the collection name we wish to access.
- * @returns return the new Collection instance
- */
- collection(name, options = {}) {
- if (typeof options === "function") {
- throw new error_1.MongoInvalidArgumentError("The callback form of this helper has been removed.");
- }
- return new collection_1.Collection(this, name, (0, utils_1.resolveOptions)(this, options));
- }
- /**
- * Get all the db statistics.
- *
- * @param options - Optional settings for the command
- */
- async stats(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new stats_1.DbStatsOperation(this, (0, utils_1.resolveOptions)(this, options)));
- }
- listCollections(filter = {}, options = {}) {
- return new list_collections_cursor_1.ListCollectionsCursor(this, filter, (0, utils_1.resolveOptions)(this, options));
- }
- /**
- * Rename a collection.
- *
- * @remarks
- * This operation does not inherit options from the MongoClient.
- *
- * @param fromCollection - Name of current collection to rename
- * @param toCollection - New name of of the collection
- * @param options - Optional settings for the command
- */
- async renameCollection(fromCollection, toCollection, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new rename_1.RenameOperation(this.collection(fromCollection), toCollection, { ...options, new_collection: true, readPreference: read_preference_1.ReadPreference.primary }));
- }
- /**
- * Drop a collection from the database, removing it permanently. New accesses will create a new collection.
- *
- * @param name - Name of collection to drop
- * @param options - Optional settings for the command
- */
- async dropCollection(name, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new drop_1.DropCollectionOperation(this, name, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Drop a database, removing it permanently from the server.
- *
- * @param options - Optional settings for the command
- */
- async dropDatabase(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new drop_1.DropDatabaseOperation(this, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Fetch all collections for the current db.
- *
- * @param options - Optional settings for the command
- */
- async collections(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new collections_1.CollectionsOperation(this, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Creates an index on the db and collection.
- *
- * @param name - Name of the collection to create the index on.
- * @param indexSpec - Specify the field to index, or an index specification
- * @param options - Optional settings for the command
- */
- async createIndex(name, indexSpec, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new indexes_1.CreateIndexOperation(this, name, indexSpec, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Add a user to the database
- *
- * @param username - The username for the new user
- * @param passwordOrOptions - An optional password for the new user, or the options for the command
- * @param options - Optional settings for the command
- * @deprecated Use the createUser command in `db.command()` instead.
- * @see https://www.mongodb.com/docs/manual/reference/command/createUser/
- */
- async addUser(username, passwordOrOptions, options) {
- options = options != null && typeof options === "object" ? options : passwordOrOptions != null && typeof passwordOrOptions === "object" ? passwordOrOptions : void 0;
- const password = typeof passwordOrOptions === "string" ? passwordOrOptions : void 0;
- return (0, execute_operation_1.executeOperation)(this.client, new add_user_1.AddUserOperation(this, username, password, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Remove a user from a database
- *
- * @param username - The username to remove
- * @param options - Optional settings for the command
- */
- async removeUser(username, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new remove_user_1.RemoveUserOperation(this, username, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Set the current profiling level of MongoDB
- *
- * @param level - The new profiling level (off, slow_only, all).
- * @param options - Optional settings for the command
- */
- async setProfilingLevel(level, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new set_profiling_level_1.SetProfilingLevelOperation(this, level, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Retrieve the current profiling Level for MongoDB
- *
- * @param options - Optional settings for the command
- */
- async profilingLevel(options) {
- return (0, execute_operation_1.executeOperation)(this.client, new profiling_level_1.ProfilingLevelOperation(this, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Retrieves this collections index info.
- *
- * @param name - The name of the collection.
- * @param options - Optional settings for the command
- */
- async indexInformation(name, options) {
- return (0, execute_operation_1.executeOperation)(this.client, new indexes_1.IndexInformationOperation(this, name, (0, utils_1.resolveOptions)(this, options)));
- }
- /**
- * Create a new Change Stream, watching for new changes (insertions, updates,
- * replacements, deletions, and invalidations) in this database. Will ignore all
- * changes to system collections.
- *
- * @remarks
- * watch() accepts two generic arguments for distinct use cases:
- * - The first is to provide the schema that may be defined for all the collections within this database
- * - The second is to override the shape of the change stream document entirely, if it is not provided the type will default to ChangeStreamDocument of the first argument
- *
- * @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
- * @param options - Optional settings for the command
- * @typeParam TSchema - Type of the data being detected by the change stream
- * @typeParam TChange - Type of the whole change stream document emitted
- */
- watch(pipeline = [], options = {}) {
- if (!Array.isArray(pipeline)) {
- options = pipeline;
- pipeline = [];
- }
- return new change_stream_1.ChangeStream(this, pipeline, (0, utils_1.resolveOptions)(this, options));
- }
- /**
- * A low level cursor API providing basic driver functionality:
- * - ClientSession management
- * - ReadPreference for server selection
- * - Running getMores automatically when a local batch is exhausted
- *
- * @param command - The command that will start a cursor on the server.
- * @param options - Configurations for running the command, bson options will apply to getMores
- */
- runCursorCommand(command, options) {
- return new run_command_cursor_1.RunCommandCursor(this, command, options);
- }
- };
- Db.SYSTEM_NAMESPACE_COLLECTION = CONSTANTS.SYSTEM_NAMESPACE_COLLECTION;
- Db.SYSTEM_INDEX_COLLECTION = CONSTANTS.SYSTEM_INDEX_COLLECTION;
- Db.SYSTEM_PROFILE_COLLECTION = CONSTANTS.SYSTEM_PROFILE_COLLECTION;
- Db.SYSTEM_USER_COLLECTION = CONSTANTS.SYSTEM_USER_COLLECTION;
- Db.SYSTEM_COMMAND_COLLECTION = CONSTANTS.SYSTEM_COMMAND_COLLECTION;
- Db.SYSTEM_JS_COLLECTION = CONSTANTS.SYSTEM_JS_COLLECTION;
- exports2.Db = Db;
- function validateDatabaseName(databaseName) {
- if (typeof databaseName !== "string")
- throw new error_1.MongoInvalidArgumentError("Database name must be a string");
- if (databaseName.length === 0)
- throw new error_1.MongoInvalidArgumentError("Database name cannot be the empty string");
- if (databaseName === "$external")
- return;
- const invalidChars = [" ", ".", "$", "/", "\\"];
- for (let i = 0; i < invalidChars.length; i++) {
- if (databaseName.indexOf(invalidChars[i]) !== -1)
- throw new error_1.MongoAPIError(`database names cannot contain the character '${invalidChars[i]}'`);
- }
- }
- }
- });
- // node_modules/@mongodb-js/saslprep/dist/index.js
- var require_dist = __commonJS({
- "node_modules/@mongodb-js/saslprep/dist/index.js"(exports2, module2) {
- "use strict";
- var getCodePoint = (character) => character.codePointAt(0);
- var first = (x) => x[0];
- var last = (x) => x[x.length - 1];
- function toCodePoints(input) {
- const codepoints = [];
- const size = input.length;
- for (let i = 0; i < size; i += 1) {
- const before = input.charCodeAt(i);
- if (before >= 55296 && before <= 56319 && size > i + 1) {
- const next = input.charCodeAt(i + 1);
- if (next >= 56320 && next <= 57343) {
- codepoints.push((before - 55296) * 1024 + next - 56320 + 65536);
- i += 1;
- continue;
- }
- }
- codepoints.push(before);
- }
- return codepoints;
- }
- function saslprep({ unassigned_code_points, commonly_mapped_to_nothing, non_ASCII_space_characters, prohibited_characters, bidirectional_r_al, bidirectional_l }, input, opts = {}) {
- const mapping2space = non_ASCII_space_characters;
- const mapping2nothing = commonly_mapped_to_nothing;
- if (typeof input !== "string") {
- throw new TypeError("Expected string.");
- }
- if (input.length === 0) {
- return "";
- }
- const mapped_input = toCodePoints(input).map((character) => mapping2space.get(character) ? 32 : character).filter((character) => !mapping2nothing.get(character));
- const normalized_input = String.fromCodePoint.apply(null, mapped_input).normalize("NFKC");
- const normalized_map = toCodePoints(normalized_input);
- const hasProhibited = normalized_map.some((character) => prohibited_characters.get(character));
- if (hasProhibited) {
- throw new Error("Prohibited character, see https://tools.ietf.org/html/rfc4013#section-2.3");
- }
- if (opts.allowUnassigned !== true) {
- const hasUnassigned = normalized_map.some((character) => unassigned_code_points.get(character));
- if (hasUnassigned) {
- throw new Error("Unassigned code point, see https://tools.ietf.org/html/rfc4013#section-2.5");
- }
- }
- const hasBidiRAL = normalized_map.some((character) => bidirectional_r_al.get(character));
- const hasBidiL = normalized_map.some((character) => bidirectional_l.get(character));
- if (hasBidiRAL && hasBidiL) {
- throw new Error("String must not contain RandALCat and LCat at the same time, see https://tools.ietf.org/html/rfc3454#section-6");
- }
- const isFirstBidiRAL = bidirectional_r_al.get(getCodePoint(first(normalized_input)));
- const isLastBidiRAL = bidirectional_r_al.get(getCodePoint(last(normalized_input)));
- if (hasBidiRAL && !(isFirstBidiRAL && isLastBidiRAL)) {
- throw new Error("Bidirectional RandALCat character must be the first and the last character of the string, see https://tools.ietf.org/html/rfc3454#section-6");
- }
- return normalized_input;
- }
- saslprep.saslprep = saslprep;
- saslprep.default = saslprep;
- module2.exports = saslprep;
- }
- });
- // node_modules/memory-pager/index.js
- var require_memory_pager = __commonJS({
- "node_modules/memory-pager/index.js"(exports2, module2) {
- module2.exports = Pager;
- function Pager(pageSize, opts) {
- if (!(this instanceof Pager)) return new Pager(pageSize, opts);
- this.length = 0;
- this.updates = [];
- this.path = new Uint16Array(4);
- this.pages = new Array(32768);
- this.maxPages = this.pages.length;
- this.level = 0;
- this.pageSize = pageSize || 1024;
- this.deduplicate = opts ? opts.deduplicate : null;
- this.zeros = this.deduplicate ? alloc(this.deduplicate.length) : null;
- }
- Pager.prototype.updated = function(page) {
- while (this.deduplicate && page.buffer[page.deduplicate] === this.deduplicate[page.deduplicate]) {
- page.deduplicate++;
- if (page.deduplicate === this.deduplicate.length) {
- page.deduplicate = 0;
- if (page.buffer.equals && page.buffer.equals(this.deduplicate)) page.buffer = this.deduplicate;
- break;
- }
- }
- if (page.updated || !this.updates) return;
- page.updated = true;
- this.updates.push(page);
- };
- Pager.prototype.lastUpdate = function() {
- if (!this.updates || !this.updates.length) return null;
- var page = this.updates.pop();
- page.updated = false;
- return page;
- };
- Pager.prototype._array = function(i, noAllocate) {
- if (i >= this.maxPages) {
- if (noAllocate) return;
- grow(this, i);
- }
- factor(i, this.path);
- var arr = this.pages;
- for (var j = this.level; j > 0; j--) {
- var p = this.path[j];
- var next = arr[p];
- if (!next) {
- if (noAllocate) return;
- next = arr[p] = new Array(32768);
- }
- arr = next;
- }
- return arr;
- };
- Pager.prototype.get = function(i, noAllocate) {
- var arr = this._array(i, noAllocate);
- var first = this.path[0];
- var page = arr && arr[first];
- if (!page && !noAllocate) {
- page = arr[first] = new Page(i, alloc(this.pageSize));
- if (i >= this.length) this.length = i + 1;
- }
- if (page && page.buffer === this.deduplicate && this.deduplicate && !noAllocate) {
- page.buffer = copy(page.buffer);
- page.deduplicate = 0;
- }
- return page;
- };
- Pager.prototype.set = function(i, buf) {
- var arr = this._array(i, false);
- var first = this.path[0];
- if (i >= this.length) this.length = i + 1;
- if (!buf || this.zeros && buf.equals && buf.equals(this.zeros)) {
- arr[first] = void 0;
- return;
- }
- if (this.deduplicate && buf.equals && buf.equals(this.deduplicate)) {
- buf = this.deduplicate;
- }
- var page = arr[first];
- var b = truncate(buf, this.pageSize);
- if (page) page.buffer = b;
- else arr[first] = new Page(i, b);
- };
- Pager.prototype.toBuffer = function() {
- var list = new Array(this.length);
- var empty = alloc(this.pageSize);
- var ptr = 0;
- while (ptr < list.length) {
- var arr = this._array(ptr, true);
- for (var i = 0; i < 32768 && ptr < list.length; i++) {
- list[ptr++] = arr && arr[i] ? arr[i].buffer : empty;
- }
- }
- return Buffer.concat(list);
- };
- function grow(pager, index) {
- while (pager.maxPages < index) {
- var old = pager.pages;
- pager.pages = new Array(32768);
- pager.pages[0] = old;
- pager.level++;
- pager.maxPages *= 32768;
- }
- }
- function truncate(buf, len) {
- if (buf.length === len) return buf;
- if (buf.length > len) return buf.slice(0, len);
- var cpy = alloc(len);
- buf.copy(cpy);
- return cpy;
- }
- function alloc(size) {
- if (Buffer.alloc) return Buffer.alloc(size);
- var buf = new Buffer(size);
- buf.fill(0);
- return buf;
- }
- function copy(buf) {
- var cpy = Buffer.allocUnsafe ? Buffer.allocUnsafe(buf.length) : new Buffer(buf.length);
- buf.copy(cpy);
- return cpy;
- }
- function Page(i, buf) {
- this.offset = i * buf.length;
- this.buffer = buf;
- this.updated = false;
- this.deduplicate = 0;
- }
- function factor(n, out) {
- n = (n - (out[0] = n & 32767)) / 32768;
- n = (n - (out[1] = n & 32767)) / 32768;
- out[3] = (n - (out[2] = n & 32767)) / 32768 & 32767;
- }
- }
- });
- // node_modules/sparse-bitfield/index.js
- var require_sparse_bitfield = __commonJS({
- "node_modules/sparse-bitfield/index.js"(exports2, module2) {
- var pager = require_memory_pager();
- module2.exports = Bitfield;
- function Bitfield(opts) {
- if (!(this instanceof Bitfield)) return new Bitfield(opts);
- if (!opts) opts = {};
- if (Buffer.isBuffer(opts)) opts = { buffer: opts };
- this.pageOffset = opts.pageOffset || 0;
- this.pageSize = opts.pageSize || 1024;
- this.pages = opts.pages || pager(this.pageSize);
- this.byteLength = this.pages.length * this.pageSize;
- this.length = 8 * this.byteLength;
- if (!powerOfTwo(this.pageSize)) throw new Error("The page size should be a power of two");
- this._trackUpdates = !!opts.trackUpdates;
- this._pageMask = this.pageSize - 1;
- if (opts.buffer) {
- for (var i = 0; i < opts.buffer.length; i += this.pageSize) {
- this.pages.set(i / this.pageSize, opts.buffer.slice(i, i + this.pageSize));
- }
- this.byteLength = opts.buffer.length;
- this.length = 8 * this.byteLength;
- }
- }
- Bitfield.prototype.get = function(i) {
- var o = i & 7;
- var j = (i - o) / 8;
- return !!(this.getByte(j) & 128 >> o);
- };
- Bitfield.prototype.getByte = function(i) {
- var o = i & this._pageMask;
- var j = (i - o) / this.pageSize;
- var page = this.pages.get(j, true);
- return page ? page.buffer[o + this.pageOffset] : 0;
- };
- Bitfield.prototype.set = function(i, v) {
- var o = i & 7;
- var j = (i - o) / 8;
- var b = this.getByte(j);
- return this.setByte(j, v ? b | 128 >> o : b & (255 ^ 128 >> o));
- };
- Bitfield.prototype.toBuffer = function() {
- var all = alloc(this.pages.length * this.pageSize);
- for (var i = 0; i < this.pages.length; i++) {
- var next = this.pages.get(i, true);
- var allOffset = i * this.pageSize;
- if (next) next.buffer.copy(all, allOffset, this.pageOffset, this.pageOffset + this.pageSize);
- }
- return all;
- };
- Bitfield.prototype.setByte = function(i, b) {
- var o = i & this._pageMask;
- var j = (i - o) / this.pageSize;
- var page = this.pages.get(j, false);
- o += this.pageOffset;
- if (page.buffer[o] === b) return false;
- page.buffer[o] = b;
- if (i >= this.byteLength) {
- this.byteLength = i + 1;
- this.length = this.byteLength * 8;
- }
- if (this._trackUpdates) this.pages.updated(page);
- return true;
- };
- function alloc(n) {
- if (Buffer.alloc) return Buffer.alloc(n);
- var b = new Buffer(n);
- b.fill(0);
- return b;
- }
- function powerOfTwo(x) {
- return !(x & x - 1);
- }
- }
- });
- // node_modules/@mongodb-js/saslprep/dist/memory-code-points.js
- var require_memory_code_points = __commonJS({
- "node_modules/@mongodb-js/saslprep/dist/memory-code-points.js"(exports2) {
- "use strict";
- var __importDefault = exports2 && exports2.__importDefault || function(mod) {
- return mod && mod.__esModule ? mod : { "default": mod };
- };
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.createMemoryCodePoints = void 0;
- var sparse_bitfield_1 = __importDefault(require_sparse_bitfield());
- function createMemoryCodePoints(data) {
- let offset = 0;
- function read() {
- const size = data.readUInt32BE(offset);
- offset += 4;
- const codepoints = data.slice(offset, offset + size);
- offset += size;
- return (0, sparse_bitfield_1.default)({ buffer: codepoints });
- }
- const unassigned_code_points = read();
- const commonly_mapped_to_nothing = read();
- const non_ASCII_space_characters = read();
- const prohibited_characters = read();
- const bidirectional_r_al = read();
- const bidirectional_l = read();
- return {
- unassigned_code_points,
- commonly_mapped_to_nothing,
- non_ASCII_space_characters,
- prohibited_characters,
- bidirectional_r_al,
- bidirectional_l
- };
- }
- exports2.createMemoryCodePoints = createMemoryCodePoints;
- }
- });
- // node_modules/@mongodb-js/saslprep/dist/code-points-data.js
- var require_code_points_data = __commonJS({
- "node_modules/@mongodb-js/saslprep/dist/code-points-data.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- var zlib_1 = require("zlib");
- exports2.default = (0, zlib_1.gunzipSync)(Buffer.from("H4sIAAAAAAACA+3dTYgcaRkA4LemO9Mhxm0FITnE9Cwr4jHgwgZ22B6YywqCJ0HQg5CL4sGTuOjCtGSF4CkHEW856MlTQHD3EJnWkU0Owh5VxE3LHlYQdNxd2U6mU59UV/d09fw4M2EySSXPAzNdP1/9fX/99bzVNZEN4jisRDulVFnQmLxm1aXF9Id/2/xMxNJ4XZlg576yuYlGt9gupV6xoFf8jhu9YvulVrFlp5XSx+lfvYhORGPXvqIRWSxERKtIm8bKFd10WNfKDS5Fo9jJWrq2+M2IlW+8uHgl/+BsROfPF4v5L7148Ur68Sha6dqZpYiVVy8tvLCWXo80Sf/lS89dGX2wHGvpzoXVn75/YWH5wmqe8uika82ViJXTy83Ve2k5Urozm38wm4/ls6t5uT6yfsTSJ7J3T0VKt8c5ExEXI8aFkH729c3eT+7EC6ca8cVULZUiYacX0R5PNWNxlh9L1y90q5kyzrpyy+9WcvOV6URntqw7La9sNVstXyczWVaWYbaaTYqzOHpr7pyiNT3/YzKuT63Z/FqKZlFTiuXtFM2vVOtIq7jiyKJbWZaOWD0euz0yoV2Z7kY0xq2x0YhfzVpmM5px9nTEH7JZ0ot5u39p0ma75Z472/s/H+2yr2inYyuq7fMvJivH2rM72N/Z3lyL31F2b1ya1P0zn816k2KP6JU9UzseucdQH5YqVeH/lFajSN2udg+TLJ9rksNxlvV2lki19rXKI43TPLejFu4ov7k3nMbhyhfY3Xb37f8BAGCf0eMTOH5szf154KmnNgKcnLb+Fzi2AfXktbN7fJelwTAiO/W5uQ2KINXRYu+znqo/WTAdLadURHmy3qciazd3bra4T3w16/f7t7Ms9U5gfJu10955sx1r3vmhBAAAAAAAgId20J1iZbDowNvIjuH427Gr5l/eiC+8OplZON8sVjx/qr9y+Pj+YRItT+NqAM+kkZs3AAAAAID6yfx1FwCAI97/dCh1/ub6SA0AAAAAAAAAgNoT/wcAAAAAAACA+hP/BwAAAAAAAID6E/8HAAAAAAAAgPoT/wcAAAAAAACA+hP/BwAAAAAAAID6E/8HAAAAAAAAgPoT/wcAAAAAAACA+hP/BwAAAAAAAID6E/8HAAAAAAAAgPoT/wcAAAAAAACA+hutp5SiQpYAAAAAAAAAQO2MIpZiT804flnAE2fhwjOeAZXr76kOAAAAAAAA8FjNf4N/l0NE3U/vuVQskLpSd4/Yh2xu9xTu0tFeeNYsLI2f/VMdNxTzj6Je9E/+6pp6Nn3awW3A54goe4Bss6v+PGsjQGMAAAAAAOBp5XEgwH6e7J7rwEQHRb/XvAMAAAAAAAA8yzoDeQDwVGjIAgAAAAAAAACoPfF/AAAAAAAAAKg/8X8AAAAAAAAAqD/xfwAAAAAAAACoP/F/AAAAAAAAAKg/8X8AAAAAAAAAqD/xfwAAAAAAAACoP/F/AAAAAAAAAKg/8X8AAAAAAAAAqD/xfwAAAAAAAACoP/F/AAAAAAAAAKg/8X8AAAAAAAAAqL/GSkSkClkCAAAAAAAAALXTSAAAAAAAAABA3Y1kAQAAAAAAAADUX8RSXZ9dsHC9+M8Fg2Ex/em1lAZpEBGttcrVjZqLEa+k0XpKw9mG4zWx4ukPUMhkAQAAAAAAABzBqbSe3//rXOS9HxGdo4TqR2XkutCdBu+LaPZw/lBbO7cbHnh2C7N7AIo4evEznllqLqWUp/LnYOtpM2bnOH66wI1+9GO4sOuISwv/TOlumu56FDv3NZhc4mR9v7zYIrafr40j/Cccvj9Xns3t3mu99E7qxUv3bqS0/ouNH/08++RGemfQ+nsx/5uNXsQPGulynPvv3ZTW37zd+1ovrqaYpP/122X6Xpx779Z3zr/3YOPKW1lkaRDf31pPaf3j/msRsVGkL+d/f+/m4sJsPm1cfSsr16e8m9Ldj/KsnyIuR3nXw83Is3EhxLd/2V773ks3m/cj/THKUummdP9qKhIOImuOU0Xjwb3y+oqt735rpTetVbF9n8R4x9crRfO77TKqVOZpDclv5bfK18lMnk+q0K18UpxF/RrGXE0Zxtqx3tWSj+vxbL4XaasfKb0dRbtLW73JsfPGg177H+OmGKlfvS1msllt7JEJm9XOJqXR+Fkfo1H66uy5H1v3Xx5+uJmGLw9jro2u7Loj4PnuR6+f+e3d261+eazNhzrL7X83MohoHpS4PddV8ki1it61//pw1g7z6p1U/26Nm2llST57B5rUvuG0XqSU/rPd7jYrqWcbd+beJQ77BgPMDwn37/8BAGCf0eMTOH4cPlufv9VGgJOzqf8Fjm1APXkd7B7f5dF57GPMaWy/MTvjvNvtXj6h8W2+GXvnzXaseeeHEgAAAAAAAB7aQXeKlcGiadBoEOeLb2dtpGOL2MyOtf391a3P/zD96c3JzIP3t4oV797vrh8+vn+YRL5bBuj/AQAAAABqJvfHXQAAHkX82zfXAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACeAgkAAAAAAAAAqLuRLAAAAAAAAACA2hv9D1iu/VAYaAYA", "base64"));
- }
- });
- // node_modules/@mongodb-js/saslprep/dist/node.js
- var require_node = __commonJS({
- "node_modules/@mongodb-js/saslprep/dist/node.js"(exports2, module2) {
- "use strict";
- var __importDefault = exports2 && exports2.__importDefault || function(mod) {
- return mod && mod.__esModule ? mod : { "default": mod };
- };
- var index_1 = __importDefault(require_dist());
- var memory_code_points_1 = require_memory_code_points();
- var code_points_data_1 = __importDefault(require_code_points_data());
- var codePoints = (0, memory_code_points_1.createMemoryCodePoints)(code_points_data_1.default);
- function saslprep(input, opts) {
- return (0, index_1.default)(codePoints, input, opts);
- }
- saslprep.saslprep = saslprep;
- saslprep.default = saslprep;
- module2.exports = saslprep;
- }
- });
- // node_modules/mongodb/lib/deps.js
- var require_deps = __commonJS({
- "node_modules/mongodb/lib/deps.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AutoEncryptionLoggerLevel = exports2.aws4 = exports2.saslprep = exports2.getSnappy = exports2.getAwsCredentialProvider = exports2.getZstdLibrary = exports2.ZStandard = exports2.getKerberos = exports2.Kerberos = void 0;
- var error_1 = require_error();
- function makeErrorModule(error) {
- const props = error ? { kModuleError: error } : {};
- return new Proxy(props, {
- get: (_, key) => {
- if (key === "kModuleError") {
- return error;
- }
- throw error;
- },
- set: () => {
- throw error;
- }
- });
- }
- exports2.Kerberos = makeErrorModule(new error_1.MongoMissingDependencyError("Optional module `kerberos` not found. Please install it to enable kerberos authentication"));
- function getKerberos() {
- try {
- exports2.Kerberos = require("kerberos");
- return exports2.Kerberos;
- } catch {
- return exports2.Kerberos;
- }
- }
- exports2.getKerberos = getKerberos;
- exports2.ZStandard = makeErrorModule(new error_1.MongoMissingDependencyError("Optional module `@mongodb-js/zstd` not found. Please install it to enable zstd compression"));
- function getZstdLibrary() {
- try {
- exports2.ZStandard = require("@mongodb-js/zstd");
- return exports2.ZStandard;
- } catch {
- return exports2.ZStandard;
- }
- }
- exports2.getZstdLibrary = getZstdLibrary;
- function getAwsCredentialProvider() {
- try {
- const credentialProvider = require("@aws-sdk/credential-providers");
- return credentialProvider;
- } catch {
- return makeErrorModule(new error_1.MongoMissingDependencyError("Optional module `@aws-sdk/credential-providers` not found. Please install it to enable getting aws credentials via the official sdk."));
- }
- }
- exports2.getAwsCredentialProvider = getAwsCredentialProvider;
- function getSnappy() {
- try {
- const value = require("snappy");
- return value;
- } catch (cause) {
- const kModuleError = new error_1.MongoMissingDependencyError("Optional module `snappy` not found. Please install it to enable snappy compression", { cause });
- return { kModuleError };
- }
- }
- exports2.getSnappy = getSnappy;
- exports2.saslprep = makeErrorModule(new error_1.MongoMissingDependencyError("Optional module `saslprep` not found. Please install it to enable Stringprep Profile for User Names and Passwords"));
- try {
- exports2.saslprep = require_node();
- } catch {
- }
- exports2.aws4 = makeErrorModule(new error_1.MongoMissingDependencyError("Optional module `aws4` not found. Please install it to enable AWS authentication"));
- try {
- exports2.aws4 = require("aws4");
- } catch {
- }
- exports2.AutoEncryptionLoggerLevel = Object.freeze({
- FatalError: 0,
- Error: 1,
- Warning: 2,
- Info: 3,
- Trace: 4
- });
- }
- });
- // node_modules/mongodb/lib/cmap/auth/auth_provider.js
- var require_auth_provider = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/auth_provider.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AuthProvider = exports2.AuthContext = void 0;
- var error_1 = require_error();
- var AuthContext = class {
- constructor(connection, credentials, options) {
- this.reauthenticating = false;
- this.connection = connection;
- this.credentials = credentials;
- this.options = options;
- }
- };
- exports2.AuthContext = AuthContext;
- var AuthProvider = class {
- /**
- * Prepare the handshake document before the initial handshake.
- *
- * @param handshakeDoc - The document used for the initial handshake on a connection
- * @param authContext - Context for authentication flow
- */
- async prepare(handshakeDoc, _authContext) {
- return handshakeDoc;
- }
- /**
- * Reauthenticate.
- * @param context - The shared auth context.
- */
- async reauth(context) {
- if (context.reauthenticating) {
- throw new error_1.MongoRuntimeError("Reauthentication already in progress.");
- }
- try {
- context.reauthenticating = true;
- await this.auth(context);
- } finally {
- context.reauthenticating = false;
- }
- }
- };
- exports2.AuthProvider = AuthProvider;
- }
- });
- // node_modules/mongodb/lib/cmap/auth/gssapi.js
- var require_gssapi = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/gssapi.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.resolveCname = exports2.performGSSAPICanonicalizeHostName = exports2.GSSAPI = exports2.GSSAPICanonicalizationValue = void 0;
- var dns = require("dns");
- var deps_1 = require_deps();
- var error_1 = require_error();
- var utils_1 = require_utils();
- var auth_provider_1 = require_auth_provider();
- exports2.GSSAPICanonicalizationValue = Object.freeze({
- on: true,
- off: false,
- none: "none",
- forward: "forward",
- forwardAndReverse: "forwardAndReverse"
- });
- async function externalCommand(connection, command) {
- return connection.commandAsync((0, utils_1.ns)("$external.$cmd"), command, void 0);
- }
- var krb;
- var GSSAPI = class extends auth_provider_1.AuthProvider {
- async auth(authContext) {
- const { connection, credentials } = authContext;
- if (credentials == null) {
- throw new error_1.MongoMissingCredentialsError("Credentials required for GSSAPI authentication");
- }
- const { username } = credentials;
- const client = await makeKerberosClient(authContext);
- const payload = await client.step("");
- const saslStartResponse = await externalCommand(connection, saslStart(payload));
- const negotiatedPayload = await negotiate(client, 10, saslStartResponse.payload);
- const saslContinueResponse = await externalCommand(connection, saslContinue(negotiatedPayload, saslStartResponse.conversationId));
- const finalizePayload = await finalize(client, username, saslContinueResponse.payload);
- await externalCommand(connection, {
- saslContinue: 1,
- conversationId: saslContinueResponse.conversationId,
- payload: finalizePayload
- });
- }
- };
- exports2.GSSAPI = GSSAPI;
- async function makeKerberosClient(authContext) {
- const { hostAddress } = authContext.options;
- const { credentials } = authContext;
- if (!hostAddress || typeof hostAddress.host !== "string" || !credentials) {
- throw new error_1.MongoInvalidArgumentError("Connection must have host and port and credentials defined.");
- }
- loadKrb();
- if ("kModuleError" in krb) {
- throw krb["kModuleError"];
- }
- const { initializeClient } = krb;
- const { username, password } = credentials;
- const mechanismProperties = credentials.mechanismProperties;
- const serviceName = mechanismProperties.SERVICE_NAME ?? "mongodb";
- const host = await performGSSAPICanonicalizeHostName(hostAddress.host, mechanismProperties);
- const initOptions = {};
- if (password != null) {
- Object.assign(initOptions, { user: username, password });
- }
- const spnHost = mechanismProperties.SERVICE_HOST ?? host;
- let spn = `${serviceName}${process.platform === "win32" ? "/" : "@"}${spnHost}`;
- if ("SERVICE_REALM" in mechanismProperties) {
- spn = `${spn}@${mechanismProperties.SERVICE_REALM}`;
- }
- return initializeClient(spn, initOptions);
- }
- function saslStart(payload) {
- return {
- saslStart: 1,
- mechanism: "GSSAPI",
- payload,
- autoAuthorize: 1
- };
- }
- function saslContinue(payload, conversationId) {
- return {
- saslContinue: 1,
- conversationId,
- payload
- };
- }
- async function negotiate(client, retries, payload) {
- try {
- const response = await client.step(payload);
- return response || "";
- } catch (error) {
- if (retries === 0) {
- throw error;
- }
- return negotiate(client, retries - 1, payload);
- }
- }
- async function finalize(client, user, payload) {
- const response = await client.unwrap(payload);
- return client.wrap(response || "", { user });
- }
- async function performGSSAPICanonicalizeHostName(host, mechanismProperties) {
- const mode = mechanismProperties.CANONICALIZE_HOST_NAME;
- if (!mode || mode === exports2.GSSAPICanonicalizationValue.none) {
- return host;
- }
- if (mode === exports2.GSSAPICanonicalizationValue.on || mode === exports2.GSSAPICanonicalizationValue.forwardAndReverse) {
- const { address } = await dns.promises.lookup(host);
- try {
- const results = await dns.promises.resolvePtr(address);
- return results.length > 0 ? results[0] : host;
- } catch (error) {
- return resolveCname(host);
- }
- } else {
- return resolveCname(host);
- }
- }
- exports2.performGSSAPICanonicalizeHostName = performGSSAPICanonicalizeHostName;
- async function resolveCname(host) {
- try {
- const results = await dns.promises.resolveCname(host);
- return results.length > 0 ? results[0] : host;
- } catch {
- return host;
- }
- }
- exports2.resolveCname = resolveCname;
- function loadKrb() {
- if (!krb) {
- krb = (0, deps_1.getKerberos)();
- }
- }
- }
- });
- // node_modules/mongodb/lib/cmap/auth/providers.js
- var require_providers = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/providers.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AUTH_MECHS_AUTH_SRC_EXTERNAL = exports2.AuthMechanism = void 0;
- exports2.AuthMechanism = Object.freeze({
- MONGODB_AWS: "MONGODB-AWS",
- MONGODB_CR: "MONGODB-CR",
- MONGODB_DEFAULT: "DEFAULT",
- MONGODB_GSSAPI: "GSSAPI",
- MONGODB_PLAIN: "PLAIN",
- MONGODB_SCRAM_SHA1: "SCRAM-SHA-1",
- MONGODB_SCRAM_SHA256: "SCRAM-SHA-256",
- MONGODB_X509: "MONGODB-X509",
- /** @experimental */
- MONGODB_OIDC: "MONGODB-OIDC"
- });
- exports2.AUTH_MECHS_AUTH_SRC_EXTERNAL = /* @__PURE__ */ new Set([
- exports2.AuthMechanism.MONGODB_GSSAPI,
- exports2.AuthMechanism.MONGODB_AWS,
- exports2.AuthMechanism.MONGODB_OIDC,
- exports2.AuthMechanism.MONGODB_X509
- ]);
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongo_credentials.js
- var require_mongo_credentials = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongo_credentials.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.MongoCredentials = exports2.DEFAULT_ALLOWED_HOSTS = void 0;
- var error_1 = require_error();
- var gssapi_1 = require_gssapi();
- var providers_1 = require_providers();
- function getDefaultAuthMechanism(hello) {
- if (hello) {
- if (Array.isArray(hello.saslSupportedMechs)) {
- return hello.saslSupportedMechs.includes(providers_1.AuthMechanism.MONGODB_SCRAM_SHA256) ? providers_1.AuthMechanism.MONGODB_SCRAM_SHA256 : providers_1.AuthMechanism.MONGODB_SCRAM_SHA1;
- }
- if (hello.maxWireVersion >= 3) {
- return providers_1.AuthMechanism.MONGODB_SCRAM_SHA1;
- }
- }
- return providers_1.AuthMechanism.MONGODB_CR;
- }
- var ALLOWED_PROVIDER_NAMES = ["aws", "azure"];
- var ALLOWED_HOSTS_ERROR = "Auth mechanism property ALLOWED_HOSTS must be an array of strings.";
- exports2.DEFAULT_ALLOWED_HOSTS = [
- "*.mongodb.net",
- "*.mongodb-dev.net",
- "*.mongodbgov.net",
- "localhost",
- "127.0.0.1",
- "::1"
- ];
- var TOKEN_AUDIENCE_MISSING_ERROR = "TOKEN_AUDIENCE must be set in the auth mechanism properties when PROVIDER_NAME is azure.";
- var MongoCredentials = class _MongoCredentials {
- constructor(options) {
- this.username = options.username ?? "";
- this.password = options.password;
- this.source = options.source;
- if (!this.source && options.db) {
- this.source = options.db;
- }
- this.mechanism = options.mechanism || providers_1.AuthMechanism.MONGODB_DEFAULT;
- this.mechanismProperties = options.mechanismProperties || {};
- if (this.mechanism.match(/MONGODB-AWS/i)) {
- if (!this.username && process.env.AWS_ACCESS_KEY_ID) {
- this.username = process.env.AWS_ACCESS_KEY_ID;
- }
- if (!this.password && process.env.AWS_SECRET_ACCESS_KEY) {
- this.password = process.env.AWS_SECRET_ACCESS_KEY;
- }
- if (this.mechanismProperties.AWS_SESSION_TOKEN == null && process.env.AWS_SESSION_TOKEN != null) {
- this.mechanismProperties = {
- ...this.mechanismProperties,
- AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN
- };
- }
- }
- if (this.mechanism === providers_1.AuthMechanism.MONGODB_OIDC && !this.mechanismProperties.ALLOWED_HOSTS) {
- this.mechanismProperties = {
- ...this.mechanismProperties,
- ALLOWED_HOSTS: exports2.DEFAULT_ALLOWED_HOSTS
- };
- }
- Object.freeze(this.mechanismProperties);
- Object.freeze(this);
- }
- /** Determines if two MongoCredentials objects are equivalent */
- equals(other) {
- return this.mechanism === other.mechanism && this.username === other.username && this.password === other.password && this.source === other.source;
- }
- /**
- * If the authentication mechanism is set to "default", resolves the authMechanism
- * based on the server version and server supported sasl mechanisms.
- *
- * @param hello - A hello response from the server
- */
- resolveAuthMechanism(hello) {
- if (this.mechanism.match(/DEFAULT/i)) {
- return new _MongoCredentials({
- username: this.username,
- password: this.password,
- source: this.source,
- mechanism: getDefaultAuthMechanism(hello),
- mechanismProperties: this.mechanismProperties
- });
- }
- return this;
- }
- validate() {
- if ((this.mechanism === providers_1.AuthMechanism.MONGODB_GSSAPI || this.mechanism === providers_1.AuthMechanism.MONGODB_CR || this.mechanism === providers_1.AuthMechanism.MONGODB_PLAIN || this.mechanism === providers_1.AuthMechanism.MONGODB_SCRAM_SHA1 || this.mechanism === providers_1.AuthMechanism.MONGODB_SCRAM_SHA256) && !this.username) {
- throw new error_1.MongoMissingCredentialsError(`Username required for mechanism '${this.mechanism}'`);
- }
- if (this.mechanism === providers_1.AuthMechanism.MONGODB_OIDC) {
- if (this.username && this.mechanismProperties.PROVIDER_NAME) {
- throw new error_1.MongoInvalidArgumentError(`username and PROVIDER_NAME may not be used together for mechanism '${this.mechanism}'.`);
- }
- if (this.mechanismProperties.PROVIDER_NAME === "azure" && !this.mechanismProperties.TOKEN_AUDIENCE) {
- throw new error_1.MongoAzureError(TOKEN_AUDIENCE_MISSING_ERROR);
- }
- if (this.mechanismProperties.PROVIDER_NAME && !ALLOWED_PROVIDER_NAMES.includes(this.mechanismProperties.PROVIDER_NAME)) {
- throw new error_1.MongoInvalidArgumentError(`Currently only a PROVIDER_NAME in ${ALLOWED_PROVIDER_NAMES.join(",")} is supported for mechanism '${this.mechanism}'.`);
- }
- if (this.mechanismProperties.REFRESH_TOKEN_CALLBACK && !this.mechanismProperties.REQUEST_TOKEN_CALLBACK) {
- throw new error_1.MongoInvalidArgumentError(`A REQUEST_TOKEN_CALLBACK must be provided when using a REFRESH_TOKEN_CALLBACK for mechanism '${this.mechanism}'`);
- }
- if (!this.mechanismProperties.PROVIDER_NAME && !this.mechanismProperties.REQUEST_TOKEN_CALLBACK) {
- throw new error_1.MongoInvalidArgumentError(`Either a PROVIDER_NAME or a REQUEST_TOKEN_CALLBACK must be specified for mechanism '${this.mechanism}'.`);
- }
- if (this.mechanismProperties.ALLOWED_HOSTS) {
- const hosts = this.mechanismProperties.ALLOWED_HOSTS;
- if (!Array.isArray(hosts)) {
- throw new error_1.MongoInvalidArgumentError(ALLOWED_HOSTS_ERROR);
- }
- for (const host of hosts) {
- if (typeof host !== "string") {
- throw new error_1.MongoInvalidArgumentError(ALLOWED_HOSTS_ERROR);
- }
- }
- }
- }
- if (providers_1.AUTH_MECHS_AUTH_SRC_EXTERNAL.has(this.mechanism)) {
- if (this.source != null && this.source !== "$external") {
- throw new error_1.MongoAPIError(`Invalid source '${this.source}' for mechanism '${this.mechanism}' specified.`);
- }
- }
- if (this.mechanism === providers_1.AuthMechanism.MONGODB_PLAIN && this.source == null) {
- throw new error_1.MongoAPIError("PLAIN Authentication Mechanism needs an auth source");
- }
- if (this.mechanism === providers_1.AuthMechanism.MONGODB_X509 && this.password != null) {
- if (this.password === "") {
- Reflect.set(this, "password", void 0);
- return;
- }
- throw new error_1.MongoAPIError(`Password not allowed for mechanism MONGODB-X509`);
- }
- const canonicalization = this.mechanismProperties.CANONICALIZE_HOST_NAME ?? false;
- if (!Object.values(gssapi_1.GSSAPICanonicalizationValue).includes(canonicalization)) {
- throw new error_1.MongoAPIError(`Invalid CANONICALIZE_HOST_NAME value: ${canonicalization}`);
- }
- }
- static merge(creds, options) {
- return new _MongoCredentials({
- username: options.username ?? (creds == null ? void 0 : creds.username) ?? "",
- password: options.password ?? (creds == null ? void 0 : creds.password) ?? "",
- mechanism: options.mechanism ?? (creds == null ? void 0 : creds.mechanism) ?? providers_1.AuthMechanism.MONGODB_DEFAULT,
- mechanismProperties: options.mechanismProperties ?? (creds == null ? void 0 : creds.mechanismProperties) ?? {},
- source: options.source ?? options.db ?? (creds == null ? void 0 : creds.source) ?? "admin"
- });
- }
- };
- exports2.MongoCredentials = MongoCredentials;
- }
- });
- // node_modules/webidl-conversions/lib/index.js
- var require_lib = __commonJS({
- "node_modules/webidl-conversions/lib/index.js"(exports2) {
- "use strict";
- function makeException(ErrorType, message, options) {
- if (options.globals) {
- ErrorType = options.globals[ErrorType.name];
- }
- return new ErrorType(`${options.context ? options.context : "Value"} ${message}.`);
- }
- function toNumber(value, options) {
- if (typeof value === "bigint") {
- throw makeException(TypeError, "is a BigInt which cannot be converted to a number", options);
- }
- if (!options.globals) {
- return Number(value);
- }
- return options.globals.Number(value);
- }
- function evenRound(x) {
- if (x > 0 && x % 1 === 0.5 && (x & 1) === 0 || x < 0 && x % 1 === -0.5 && (x & 1) === 1) {
- return censorNegativeZero(Math.floor(x));
- }
- return censorNegativeZero(Math.round(x));
- }
- function integerPart(n) {
- return censorNegativeZero(Math.trunc(n));
- }
- function sign(x) {
- return x < 0 ? -1 : 1;
- }
- function modulo(x, y) {
- const signMightNotMatch = x % y;
- if (sign(y) !== sign(signMightNotMatch)) {
- return signMightNotMatch + y;
- }
- return signMightNotMatch;
- }
- function censorNegativeZero(x) {
- return x === 0 ? 0 : x;
- }
- function createIntegerConversion(bitLength, { unsigned }) {
- let lowerBound, upperBound;
- if (unsigned) {
- lowerBound = 0;
- upperBound = 2 ** bitLength - 1;
- } else {
- lowerBound = -(2 ** (bitLength - 1));
- upperBound = 2 ** (bitLength - 1) - 1;
- }
- const twoToTheBitLength = 2 ** bitLength;
- const twoToOneLessThanTheBitLength = 2 ** (bitLength - 1);
- return (value, options = {}) => {
- let x = toNumber(value, options);
- x = censorNegativeZero(x);
- if (options.enforceRange) {
- if (!Number.isFinite(x)) {
- throw makeException(TypeError, "is not a finite number", options);
- }
- x = integerPart(x);
- if (x < lowerBound || x > upperBound) {
- throw makeException(
- TypeError,
- `is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`,
- options
- );
- }
- return x;
- }
- if (!Number.isNaN(x) && options.clamp) {
- x = Math.min(Math.max(x, lowerBound), upperBound);
- x = evenRound(x);
- return x;
- }
- if (!Number.isFinite(x) || x === 0) {
- return 0;
- }
- x = integerPart(x);
- if (x >= lowerBound && x <= upperBound) {
- return x;
- }
- x = modulo(x, twoToTheBitLength);
- if (!unsigned && x >= twoToOneLessThanTheBitLength) {
- return x - twoToTheBitLength;
- }
- return x;
- };
- }
- function createLongLongConversion(bitLength, { unsigned }) {
- const upperBound = Number.MAX_SAFE_INTEGER;
- const lowerBound = unsigned ? 0 : Number.MIN_SAFE_INTEGER;
- const asBigIntN = unsigned ? BigInt.asUintN : BigInt.asIntN;
- return (value, options = {}) => {
- let x = toNumber(value, options);
- x = censorNegativeZero(x);
- if (options.enforceRange) {
- if (!Number.isFinite(x)) {
- throw makeException(TypeError, "is not a finite number", options);
- }
- x = integerPart(x);
- if (x < lowerBound || x > upperBound) {
- throw makeException(
- TypeError,
- `is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`,
- options
- );
- }
- return x;
- }
- if (!Number.isNaN(x) && options.clamp) {
- x = Math.min(Math.max(x, lowerBound), upperBound);
- x = evenRound(x);
- return x;
- }
- if (!Number.isFinite(x) || x === 0) {
- return 0;
- }
- let xBigInt = BigInt(integerPart(x));
- xBigInt = asBigIntN(bitLength, xBigInt);
- return Number(xBigInt);
- };
- }
- exports2.any = (value) => {
- return value;
- };
- exports2.undefined = () => {
- return void 0;
- };
- exports2.boolean = (value) => {
- return Boolean(value);
- };
- exports2.byte = createIntegerConversion(8, { unsigned: false });
- exports2.octet = createIntegerConversion(8, { unsigned: true });
- exports2.short = createIntegerConversion(16, { unsigned: false });
- exports2["unsigned short"] = createIntegerConversion(16, { unsigned: true });
- exports2.long = createIntegerConversion(32, { unsigned: false });
- exports2["unsigned long"] = createIntegerConversion(32, { unsigned: true });
- exports2["long long"] = createLongLongConversion(64, { unsigned: false });
- exports2["unsigned long long"] = createLongLongConversion(64, { unsigned: true });
- exports2.double = (value, options = {}) => {
- const x = toNumber(value, options);
- if (!Number.isFinite(x)) {
- throw makeException(TypeError, "is not a finite floating-point value", options);
- }
- return x;
- };
- exports2["unrestricted double"] = (value, options = {}) => {
- const x = toNumber(value, options);
- return x;
- };
- exports2.float = (value, options = {}) => {
- const x = toNumber(value, options);
- if (!Number.isFinite(x)) {
- throw makeException(TypeError, "is not a finite floating-point value", options);
- }
- if (Object.is(x, -0)) {
- return x;
- }
- const y = Math.fround(x);
- if (!Number.isFinite(y)) {
- throw makeException(TypeError, "is outside the range of a single-precision floating-point value", options);
- }
- return y;
- };
- exports2["unrestricted float"] = (value, options = {}) => {
- const x = toNumber(value, options);
- if (isNaN(x)) {
- return x;
- }
- if (Object.is(x, -0)) {
- return x;
- }
- return Math.fround(x);
- };
- exports2.DOMString = (value, options = {}) => {
- if (options.treatNullAsEmptyString && value === null) {
- return "";
- }
- if (typeof value === "symbol") {
- throw makeException(TypeError, "is a symbol, which cannot be converted to a string", options);
- }
- const StringCtor = options.globals ? options.globals.String : String;
- return StringCtor(value);
- };
- exports2.ByteString = (value, options = {}) => {
- const x = exports2.DOMString(value, options);
- let c;
- for (let i = 0; (c = x.codePointAt(i)) !== void 0; ++i) {
- if (c > 255) {
- throw makeException(TypeError, "is not a valid ByteString", options);
- }
- }
- return x;
- };
- exports2.USVString = (value, options = {}) => {
- const S = exports2.DOMString(value, options);
- const n = S.length;
- const U = [];
- for (let i = 0; i < n; ++i) {
- const c = S.charCodeAt(i);
- if (c < 55296 || c > 57343) {
- U.push(String.fromCodePoint(c));
- } else if (56320 <= c && c <= 57343) {
- U.push(String.fromCodePoint(65533));
- } else if (i === n - 1) {
- U.push(String.fromCodePoint(65533));
- } else {
- const d = S.charCodeAt(i + 1);
- if (56320 <= d && d <= 57343) {
- const a = c & 1023;
- const b = d & 1023;
- U.push(String.fromCodePoint((2 << 15) + (2 << 9) * a + b));
- ++i;
- } else {
- U.push(String.fromCodePoint(65533));
- }
- }
- }
- return U.join("");
- };
- exports2.object = (value, options = {}) => {
- if (value === null || typeof value !== "object" && typeof value !== "function") {
- throw makeException(TypeError, "is not an object", options);
- }
- return value;
- };
- var abByteLengthGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
- var sabByteLengthGetter = typeof SharedArrayBuffer === "function" ? Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get : null;
- function isNonSharedArrayBuffer(value) {
- try {
- abByteLengthGetter.call(value);
- return true;
- } catch {
- return false;
- }
- }
- function isSharedArrayBuffer(value) {
- try {
- sabByteLengthGetter.call(value);
- return true;
- } catch {
- return false;
- }
- }
- function isArrayBufferDetached(value) {
- try {
- new Uint8Array(value);
- return false;
- } catch {
- return true;
- }
- }
- exports2.ArrayBuffer = (value, options = {}) => {
- if (!isNonSharedArrayBuffer(value)) {
- if (options.allowShared && !isSharedArrayBuffer(value)) {
- throw makeException(TypeError, "is not an ArrayBuffer or SharedArrayBuffer", options);
- }
- throw makeException(TypeError, "is not an ArrayBuffer", options);
- }
- if (isArrayBufferDetached(value)) {
- throw makeException(TypeError, "is a detached ArrayBuffer", options);
- }
- return value;
- };
- var dvByteLengthGetter = Object.getOwnPropertyDescriptor(DataView.prototype, "byteLength").get;
- exports2.DataView = (value, options = {}) => {
- try {
- dvByteLengthGetter.call(value);
- } catch (e) {
- throw makeException(TypeError, "is not a DataView", options);
- }
- if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
- throw makeException(TypeError, "is backed by a SharedArrayBuffer, which is not allowed", options);
- }
- if (isArrayBufferDetached(value.buffer)) {
- throw makeException(TypeError, "is backed by a detached ArrayBuffer", options);
- }
- return value;
- };
- var typedArrayNameGetter = Object.getOwnPropertyDescriptor(
- Object.getPrototypeOf(Uint8Array).prototype,
- Symbol.toStringTag
- ).get;
- [
- Int8Array,
- Int16Array,
- Int32Array,
- Uint8Array,
- Uint16Array,
- Uint32Array,
- Uint8ClampedArray,
- Float32Array,
- Float64Array
- ].forEach((func) => {
- const { name } = func;
- const article = /^[AEIOU]/u.test(name) ? "an" : "a";
- exports2[name] = (value, options = {}) => {
- if (!ArrayBuffer.isView(value) || typedArrayNameGetter.call(value) !== name) {
- throw makeException(TypeError, `is not ${article} ${name} object`, options);
- }
- if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
- throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", options);
- }
- if (isArrayBufferDetached(value.buffer)) {
- throw makeException(TypeError, "is a view on a detached ArrayBuffer", options);
- }
- return value;
- };
- });
- exports2.ArrayBufferView = (value, options = {}) => {
- if (!ArrayBuffer.isView(value)) {
- throw makeException(TypeError, "is not a view on an ArrayBuffer or SharedArrayBuffer", options);
- }
- if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
- throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", options);
- }
- if (isArrayBufferDetached(value.buffer)) {
- throw makeException(TypeError, "is a view on a detached ArrayBuffer", options);
- }
- return value;
- };
- exports2.BufferSource = (value, options = {}) => {
- if (ArrayBuffer.isView(value)) {
- if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
- throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", options);
- }
- if (isArrayBufferDetached(value.buffer)) {
- throw makeException(TypeError, "is a view on a detached ArrayBuffer", options);
- }
- return value;
- }
- if (!options.allowShared && !isNonSharedArrayBuffer(value)) {
- throw makeException(TypeError, "is not an ArrayBuffer or a view on one", options);
- }
- if (options.allowShared && !isSharedArrayBuffer(value) && !isNonSharedArrayBuffer(value)) {
- throw makeException(TypeError, "is not an ArrayBuffer, SharedArrayBuffer, or a view on one", options);
- }
- if (isArrayBufferDetached(value)) {
- throw makeException(TypeError, "is a detached ArrayBuffer", options);
- }
- return value;
- };
- exports2.DOMTimeStamp = exports2["unsigned long long"];
- }
- });
- // node_modules/whatwg-url/lib/utils.js
- var require_utils2 = __commonJS({
- "node_modules/whatwg-url/lib/utils.js"(exports2, module2) {
- "use strict";
- function isObject(value) {
- return typeof value === "object" && value !== null || typeof value === "function";
- }
- var hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
- function define2(target, source) {
- for (const key of Reflect.ownKeys(source)) {
- const descriptor = Reflect.getOwnPropertyDescriptor(source, key);
- if (descriptor && !Reflect.defineProperty(target, key, descriptor)) {
- throw new TypeError(`Cannot redefine property: ${String(key)}`);
- }
- }
- }
- function newObjectInRealm(globalObject, object) {
- const ctorRegistry = initCtorRegistry(globalObject);
- return Object.defineProperties(
- Object.create(ctorRegistry["%Object.prototype%"]),
- Object.getOwnPropertyDescriptors(object)
- );
- }
- var wrapperSymbol = Symbol("wrapper");
- var implSymbol = Symbol("impl");
- var sameObjectCaches = Symbol("SameObject caches");
- var ctorRegistrySymbol = Symbol.for("[webidl2js] constructor registry");
- var AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {
- }).prototype);
- function initCtorRegistry(globalObject) {
- if (hasOwn(globalObject, ctorRegistrySymbol)) {
- return globalObject[ctorRegistrySymbol];
- }
- const ctorRegistry = /* @__PURE__ */ Object.create(null);
- ctorRegistry["%Object.prototype%"] = globalObject.Object.prototype;
- ctorRegistry["%IteratorPrototype%"] = Object.getPrototypeOf(
- Object.getPrototypeOf(new globalObject.Array()[Symbol.iterator]())
- );
- try {
- ctorRegistry["%AsyncIteratorPrototype%"] = Object.getPrototypeOf(
- Object.getPrototypeOf(
- globalObject.eval("(async function* () {})").prototype
- )
- );
- } catch {
- ctorRegistry["%AsyncIteratorPrototype%"] = AsyncIteratorPrototype;
- }
- globalObject[ctorRegistrySymbol] = ctorRegistry;
- return ctorRegistry;
- }
- function getSameObject(wrapper, prop, creator) {
- if (!wrapper[sameObjectCaches]) {
- wrapper[sameObjectCaches] = /* @__PURE__ */ Object.create(null);
- }
- if (prop in wrapper[sameObjectCaches]) {
- return wrapper[sameObjectCaches][prop];
- }
- wrapper[sameObjectCaches][prop] = creator();
- return wrapper[sameObjectCaches][prop];
- }
- function wrapperForImpl(impl) {
- return impl ? impl[wrapperSymbol] : null;
- }
- function implForWrapper(wrapper) {
- return wrapper ? wrapper[implSymbol] : null;
- }
- function tryWrapperForImpl(impl) {
- const wrapper = wrapperForImpl(impl);
- return wrapper ? wrapper : impl;
- }
- function tryImplForWrapper(wrapper) {
- const impl = implForWrapper(wrapper);
- return impl ? impl : wrapper;
- }
- var iterInternalSymbol = Symbol("internal");
- function isArrayIndexPropName(P) {
- if (typeof P !== "string") {
- return false;
- }
- const i = P >>> 0;
- if (i === 2 ** 32 - 1) {
- return false;
- }
- const s = `${i}`;
- if (P !== s) {
- return false;
- }
- return true;
- }
- var byteLengthGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
- function isArrayBuffer(value) {
- try {
- byteLengthGetter.call(value);
- return true;
- } catch (e) {
- return false;
- }
- }
- function iteratorResult([key, value], kind) {
- let result;
- switch (kind) {
- case "key":
- result = key;
- break;
- case "value":
- result = value;
- break;
- case "key+value":
- result = [key, value];
- break;
- }
- return { value: result, done: false };
- }
- var supportsPropertyIndex = Symbol("supports property index");
- var supportedPropertyIndices = Symbol("supported property indices");
- var supportsPropertyName = Symbol("supports property name");
- var supportedPropertyNames = Symbol("supported property names");
- var indexedGet = Symbol("indexed property get");
- var indexedSetNew = Symbol("indexed property set new");
- var indexedSetExisting = Symbol("indexed property set existing");
- var namedGet = Symbol("named property get");
- var namedSetNew = Symbol("named property set new");
- var namedSetExisting = Symbol("named property set existing");
- var namedDelete = Symbol("named property delete");
- var asyncIteratorNext = Symbol("async iterator get the next iteration result");
- var asyncIteratorReturn = Symbol("async iterator return steps");
- var asyncIteratorInit = Symbol("async iterator initialization steps");
- var asyncIteratorEOI = Symbol("async iterator end of iteration");
- module2.exports = exports2 = {
- isObject,
- hasOwn,
- define: define2,
- newObjectInRealm,
- wrapperSymbol,
- implSymbol,
- getSameObject,
- ctorRegistrySymbol,
- initCtorRegistry,
- wrapperForImpl,
- implForWrapper,
- tryWrapperForImpl,
- tryImplForWrapper,
- iterInternalSymbol,
- isArrayBuffer,
- isArrayIndexPropName,
- supportsPropertyIndex,
- supportedPropertyIndices,
- supportsPropertyName,
- supportedPropertyNames,
- indexedGet,
- indexedSetNew,
- indexedSetExisting,
- namedGet,
- namedSetNew,
- namedSetExisting,
- namedDelete,
- asyncIteratorNext,
- asyncIteratorReturn,
- asyncIteratorInit,
- asyncIteratorEOI,
- iteratorResult
- };
- }
- });
- // node_modules/tr46/lib/regexes.js
- var require_regexes = __commonJS({
- "node_modules/tr46/lib/regexes.js"(exports2, module2) {
- "use strict";
- var combiningMarks = /[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\u{101FD}\u{102E0}\u{10376}-\u{1037A}\u{10A01}-\u{10A03}\u{10A05}\u{10A06}\u{10A0C}-\u{10A0F}\u{10A38}-\u{10A3A}\u{10A3F}\u{10AE5}\u{10AE6}\u{10D24}-\u{10D27}\u{10EAB}\u{10EAC}\u{10F46}-\u{10F50}\u{10F82}-\u{10F85}\u{11000}-\u{11002}\u{11038}-\u{11046}\u{11070}\u{11073}\u{11074}\u{1107F}-\u{11082}\u{110B0}-\u{110BA}\u{110C2}\u{11100}-\u{11102}\u{11127}-\u{11134}\u{11145}\u{11146}\u{11173}\u{11180}-\u{11182}\u{111B3}-\u{111C0}\u{111C9}-\u{111CC}\u{111CE}\u{111CF}\u{1122C}-\u{11237}\u{1123E}\u{112DF}-\u{112EA}\u{11300}-\u{11303}\u{1133B}\u{1133C}\u{1133E}-\u{11344}\u{11347}\u{11348}\u{1134B}-\u{1134D}\u{11357}\u{11362}\u{11363}\u{11366}-\u{1136C}\u{11370}-\u{11374}\u{11435}-\u{11446}\u{1145E}\u{114B0}-\u{114C3}\u{115AF}-\u{115B5}\u{115B8}-\u{115C0}\u{115DC}\u{115DD}\u{11630}-\u{11640}\u{116AB}-\u{116B7}\u{1171D}-\u{1172B}\u{1182C}-\u{1183A}\u{11930}-\u{11935}\u{11937}\u{11938}\u{1193B}-\u{1193E}\u{11940}\u{11942}\u{11943}\u{119D1}-\u{119D7}\u{119DA}-\u{119E0}\u{119E4}\u{11A01}-\u{11A0A}\u{11A33}-\u{11A39}\u{11A3B}-\u{11A3E}\u{11A47}\u{11A51}-\u{11A5B}\u{11A8A}-\u{11A99}\u{11C2F}-\u{11C36}\u{11C38}-\u{11C3F}\u{11C92}-\u{11CA7}\u{11CA9}-\u{11CB6}\u{11D31}-\u{11D36}\u{11D3A}\u{11D3C}\u{11D3D}\u{11D3F}-\u{11D45}\u{11D47}\u{11D8A}-\u{11D8E}\u{11D90}\u{11D91}\u{11D93}-\u{11D97}\u{11EF3}-\u{11EF6}\u{16AF0}-\u{16AF4}\u{16B30}-\u{16B36}\u{16F4F}\u{16F51}-\u{16F87}\u{16F8F}-\u{16F92}\u{16FE4}\u{16FF0}\u{16FF1}\u{1BC9D}\u{1BC9E}\u{1CF00}-\u{1CF2D}\u{1CF30}-\u{1CF46}\u{1D165}-\u{1D169}\u{1D16D}-\u{1D172}\u{1D17B}-\u{1D182}\u{1D185}-\u{1D18B}\u{1D1AA}-\u{1D1AD}\u{1D242}-\u{1D244}\u{1DA00}-\u{1DA36}\u{1DA3B}-\u{1DA6C}\u{1DA75}\u{1DA84}\u{1DA9B}-\u{1DA9F}\u{1DAA1}-\u{1DAAF}\u{1E000}-\u{1E006}\u{1E008}-\u{1E018}\u{1E01B}-\u{1E021}\u{1E023}\u{1E024}\u{1E026}-\u{1E02A}\u{1E130}-\u{1E136}\u{1E2AE}\u{1E2EC}-\u{1E2EF}\u{1E8D0}-\u{1E8D6}\u{1E944}-\u{1E94A}\u{E0100}-\u{E01EF}]/u;
- var combiningClassVirama = /[\u094D\u09CD\u0A4D\u0ACD\u0B4D\u0BCD\u0C4D\u0CCD\u0D3B\u0D3C\u0D4D\u0DCA\u0E3A\u0EBA\u0F84\u1039\u103A\u1714\u1734\u17D2\u1A60\u1B44\u1BAA\u1BAB\u1BF2\u1BF3\u2D7F\uA806\uA8C4\uA953\uA9C0\uAAF6\uABED\u{10A3F}\u{11046}\u{1107F}\u{110B9}\u{11133}\u{11134}\u{111C0}\u{11235}\u{112EA}\u{1134D}\u{11442}\u{114C2}\u{115BF}\u{1163F}\u{116B6}\u{1172B}\u{11839}\u{119E0}\u{11A34}\u{11A47}\u{11A99}\u{11C3F}\u{11D44}\u{11D45}\u{11D97}]/u;
- var validZWNJ = /[\u0620\u0626\u0628\u062A-\u062E\u0633-\u063F\u0641-\u0647\u0649\u064A\u066E\u066F\u0678-\u0687\u069A-\u06BF\u06C1\u06C2\u06CC\u06CE\u06D0\u06D1\u06FA-\u06FC\u06FF\u0712-\u0714\u071A-\u071D\u071F-\u0727\u0729\u072B\u072D\u072E\u074E-\u0758\u075C-\u076A\u076D-\u0770\u0772\u0775-\u0777\u077A-\u077F\u07CA-\u07EA\u0841-\u0845\u0848\u084A-\u0853\u0855\u0860\u0862-\u0865\u0868\u08A0-\u08A9\u08AF\u08B0\u08B3\u08B4\u08B6-\u08B8\u08BA-\u08BD\u1807\u1820-\u1878\u1887-\u18A8\u18AA\uA840-\uA872\u{10AC0}-\u{10AC4}\u{10ACD}\u{10AD3}-\u{10ADC}\u{10ADE}-\u{10AE0}\u{10AEB}-\u{10AEE}\u{10B80}\u{10B82}\u{10B86}-\u{10B88}\u{10B8A}\u{10B8B}\u{10B8D}\u{10B90}\u{10BAD}\u{10BAE}\u{10D00}-\u{10D21}\u{10D23}\u{10F30}-\u{10F32}\u{10F34}-\u{10F44}\u{10F51}-\u{10F53}\u{1E900}-\u{1E943}][\xAD\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u061C\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u070F\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09C1-\u09C4\u09CD\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3F\u0B41-\u0B44\u0B4D\u0B56\u0B62\u0B63\u0B82\u0BC0\u0BCD\u0C00\u0C04\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC6\u0CCC\u0CCD\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D41-\u0D44\u0D4D\u0D62\u0D63\u0DCA\u0DD2-\u0DD4\u0DD6\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B03\u1B34\u1B36-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u200B\u200E\u200F\u202A-\u202E\u2060-\u2064\u206A-\u206F\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302D\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFEFF\uFFF9-\uFFFB\u{101FD}\u{102E0}\u{10376}-\u{1037A}\u{10A01}-\u{10A03}\u{10A05}\u{10A06}\u{10A0C}-\u{10A0F}\u{10A38}-\u{10A3A}\u{10A3F}\u{10AE5}\u{10AE6}\u{10D24}-\u{10D27}\u{10F46}-\u{10F50}\u{11001}\u{11038}-\u{11046}\u{1107F}-\u{11081}\u{110B3}-\u{110B6}\u{110B9}\u{110BA}\u{11100}-\u{11102}\u{11127}-\u{1112B}\u{1112D}-\u{11134}\u{11173}\u{11180}\u{11181}\u{111B6}-\u{111BE}\u{111C9}-\u{111CC}\u{1122F}-\u{11231}\u{11234}\u{11236}\u{11237}\u{1123E}\u{112DF}\u{112E3}-\u{112EA}\u{11300}\u{11301}\u{1133B}\u{1133C}\u{11340}\u{11366}-\u{1136C}\u{11370}-\u{11374}\u{11438}-\u{1143F}\u{11442}-\u{11444}\u{11446}\u{1145E}\u{114B3}-\u{114B8}\u{114BA}\u{114BF}\u{114C0}\u{114C2}\u{114C3}\u{115B2}-\u{115B5}\u{115BC}\u{115BD}\u{115BF}\u{115C0}\u{115DC}\u{115DD}\u{11633}-\u{1163A}\u{1163D}\u{1163F}\u{11640}\u{116AB}\u{116AD}\u{116B0}-\u{116B5}\u{116B7}\u{1171D}-\u{1171F}\u{11722}-\u{11725}\u{11727}-\u{1172B}\u{1182F}-\u{11837}\u{11839}\u{1183A}\u{119D4}-\u{119D7}\u{119DA}\u{119DB}\u{119E0}\u{11A01}-\u{11A0A}\u{11A33}-\u{11A38}\u{11A3B}-\u{11A3E}\u{11A47}\u{11A51}-\u{11A56}\u{11A59}-\u{11A5B}\u{11A8A}-\u{11A96}\u{11A98}\u{11A99}\u{11C30}-\u{11C36}\u{11C38}-\u{11C3D}\u{11C3F}\u{11C92}-\u{11CA7}\u{11CAA}-\u{11CB0}\u{11CB2}\u{11CB3}\u{11CB5}\u{11CB6}\u{11D31}-\u{11D36}\u{11D3A}\u{11D3C}\u{11D3D}\u{11D3F}-\u{11D45}\u{11D47}\u{11D90}\u{11D91}\u{11D95}\u{11D97}\u{11EF3}\u{11EF4}\u{13430}-\u{13438}\u{16AF0}-\u{16AF4}\u{16B30}-\u{16B36}\u{16F4F}\u{16F8F}-\u{16F92}\u{1BC9D}\u{1BC9E}\u{1BCA0}-\u{1BCA3}\u{1D167}-\u{1D169}\u{1D173}-\u{1D182}\u{1D185}-\u{1D18B}\u{1D1AA}-\u{1D1AD}\u{1D242}-\u{1D244}\u{1DA00}-\u{1DA36}\u{1DA3B}-\u{1DA6C}\u{1DA75}\u{1DA84}\u{1DA9B}-\u{1DA9F}\u{1DAA1}-\u{1DAAF}\u{1E000}-\u{1E006}\u{1E008}-\u{1E018}\u{1E01B}-\u{1E021}\u{1E023}\u{1E024}\u{1E026}-\u{1E02A}\u{1E130}-\u{1E136}\u{1E2EC}-\u{1E2EF}\u{1E8D0}-\u{1E8D6}\u{1E944}-\u{1E94B}\u{E0001}\u{E0020}-\u{E007F}\u{E0100}-\u{E01EF}]*\u200C[\xAD\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u061C\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u070F\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09C1-\u09C4\u09CD\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3F\u0B41-\u0B44\u0B4D\u0B56\u0B62\u0B63\u0B82\u0BC0\u0BCD\u0C00\u0C04\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC6\u0CCC\u0CCD\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D41-\u0D44\u0D4D\u0D62\u0D63\u0DCA\u0DD2-\u0DD4\u0DD6\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B03\u1B34\u1B36-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u200B\u200E\u200F\u202A-\u202E\u2060-\u2064\u206A-\u206F\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302D\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFEFF\uFFF9-\uFFFB\u{101FD}\u{102E0}\u{10376}-\u{1037A}\u{10A01}-\u{10A03}\u{10A05}\u{10A06}\u{10A0C}-\u{10A0F}\u{10A38}-\u{10A3A}\u{10A3F}\u{10AE5}\u{10AE6}\u{10D24}-\u{10D27}\u{10F46}-\u{10F50}\u{11001}\u{11038}-\u{11046}\u{1107F}-\u{11081}\u{110B3}-\u{110B6}\u{110B9}\u{110BA}\u{11100}-\u{11102}\u{11127}-\u{1112B}\u{1112D}-\u{11134}\u{11173}\u{11180}\u{11181}\u{111B6}-\u{111BE}\u{111C9}-\u{111CC}\u{1122F}-\u{11231}\u{11234}\u{11236}\u{11237}\u{1123E}\u{112DF}\u{112E3}-\u{112EA}\u{11300}\u{11301}\u{1133B}\u{1133C}\u{11340}\u{11366}-\u{1136C}\u{11370}-\u{11374}\u{11438}-\u{1143F}\u{11442}-\u{11444}\u{11446}\u{1145E}\u{114B3}-\u{114B8}\u{114BA}\u{114BF}\u{114C0}\u{114C2}\u{114C3}\u{115B2}-\u{115B5}\u{115BC}\u{115BD}\u{115BF}\u{115C0}\u{115DC}\u{115DD}\u{11633}-\u{1163A}\u{1163D}\u{1163F}\u{11640}\u{116AB}\u{116AD}\u{116B0}-\u{116B5}\u{116B7}\u{1171D}-\u{1171F}\u{11722}-\u{11725}\u{11727}-\u{1172B}\u{1182F}-\u{11837}\u{11839}\u{1183A}\u{119D4}-\u{119D7}\u{119DA}\u{119DB}\u{119E0}\u{11A01}-\u{11A0A}\u{11A33}-\u{11A38}\u{11A3B}-\u{11A3E}\u{11A47}\u{11A51}-\u{11A56}\u{11A59}-\u{11A5B}\u{11A8A}-\u{11A96}\u{11A98}\u{11A99}\u{11C30}-\u{11C36}\u{11C38}-\u{11C3D}\u{11C3F}\u{11C92}-\u{11CA7}\u{11CAA}-\u{11CB0}\u{11CB2}\u{11CB3}\u{11CB5}\u{11CB6}\u{11D31}-\u{11D36}\u{11D3A}\u{11D3C}\u{11D3D}\u{11D3F}-\u{11D45}\u{11D47}\u{11D90}\u{11D91}\u{11D95}\u{11D97}\u{11EF3}\u{11EF4}\u{13430}-\u{13438}\u{16AF0}-\u{16AF4}\u{16B30}-\u{16B36}\u{16F4F}\u{16F8F}-\u{16F92}\u{1BC9D}\u{1BC9E}\u{1BCA0}-\u{1BCA3}\u{1D167}-\u{1D169}\u{1D173}-\u{1D182}\u{1D185}-\u{1D18B}\u{1D1AA}-\u{1D1AD}\u{1D242}-\u{1D244}\u{1DA00}-\u{1DA36}\u{1DA3B}-\u{1DA6C}\u{1DA75}\u{1DA84}\u{1DA9B}-\u{1DA9F}\u{1DAA1}-\u{1DAAF}\u{1E000}-\u{1E006}\u{1E008}-\u{1E018}\u{1E01B}-\u{1E021}\u{1E023}\u{1E024}\u{1E026}-\u{1E02A}\u{1E130}-\u{1E136}\u{1E2EC}-\u{1E2EF}\u{1E8D0}-\u{1E8D6}\u{1E944}-\u{1E94B}\u{E0001}\u{E0020}-\u{E007F}\u{E0100}-\u{E01EF}]*[\u0620\u0622-\u063F\u0641-\u064A\u066E\u066F\u0671-\u0673\u0675-\u06D3\u06D5\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u077F\u07CA-\u07EA\u0840-\u0855\u0860\u0862-\u0865\u0867-\u086A\u08A0-\u08AC\u08AE-\u08B4\u08B6-\u08BD\u1807\u1820-\u1878\u1887-\u18A8\u18AA\uA840-\uA871\u{10AC0}-\u{10AC5}\u{10AC7}\u{10AC9}\u{10ACA}\u{10ACE}-\u{10AD6}\u{10AD8}-\u{10AE1}\u{10AE4}\u{10AEB}-\u{10AEF}\u{10B80}-\u{10B91}\u{10BA9}-\u{10BAE}\u{10D01}-\u{10D23}\u{10F30}-\u{10F44}\u{10F51}-\u{10F54}\u{1E900}-\u{1E943}]/u;
- var bidiDomain = /[\u05BE\u05C0\u05C3\u05C6\u05D0-\u05EA\u05EF-\u05F4\u0600-\u0605\u0608\u060B\u060D\u061B-\u064A\u0660-\u0669\u066B-\u066F\u0671-\u06D5\u06DD\u06E5\u06E6\u06EE\u06EF\u06FA-\u070D\u070F\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u07FE-\u0815\u081A\u0824\u0828\u0830-\u083E\u0840-\u0858\u085E\u0860-\u086A\u0870-\u088E\u0890\u0891\u08A0-\u08C9\u08E2\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBC2\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFC\uFE70-\uFE74\uFE76-\uFEFC\u{10800}-\u{10805}\u{10808}\u{1080A}-\u{10835}\u{10837}\u{10838}\u{1083C}\u{1083F}-\u{10855}\u{10857}-\u{1089E}\u{108A7}-\u{108AF}\u{108E0}-\u{108F2}\u{108F4}\u{108F5}\u{108FB}-\u{1091B}\u{10920}-\u{10939}\u{1093F}\u{10980}-\u{109B7}\u{109BC}-\u{109CF}\u{109D2}-\u{10A00}\u{10A10}-\u{10A13}\u{10A15}-\u{10A17}\u{10A19}-\u{10A35}\u{10A40}-\u{10A48}\u{10A50}-\u{10A58}\u{10A60}-\u{10A9F}\u{10AC0}-\u{10AE4}\u{10AEB}-\u{10AF6}\u{10B00}-\u{10B35}\u{10B40}-\u{10B55}\u{10B58}-\u{10B72}\u{10B78}-\u{10B91}\u{10B99}-\u{10B9C}\u{10BA9}-\u{10BAF}\u{10C00}-\u{10C48}\u{10C80}-\u{10CB2}\u{10CC0}-\u{10CF2}\u{10CFA}-\u{10D23}\u{10D30}-\u{10D39}\u{10E60}-\u{10E7E}\u{10E80}-\u{10EA9}\u{10EAD}\u{10EB0}\u{10EB1}\u{10F00}-\u{10F27}\u{10F30}-\u{10F45}\u{10F51}-\u{10F59}\u{10F70}-\u{10F81}\u{10F86}-\u{10F89}\u{10FB0}-\u{10FCB}\u{10FE0}-\u{10FF6}\u{1E800}-\u{1E8C4}\u{1E8C7}-\u{1E8CF}\u{1E900}-\u{1E943}\u{1E94B}\u{1E950}-\u{1E959}\u{1E95E}\u{1E95F}\u{1EC71}-\u{1ECB4}\u{1ED01}-\u{1ED3D}\u{1EE00}-\u{1EE03}\u{1EE05}-\u{1EE1F}\u{1EE21}\u{1EE22}\u{1EE24}\u{1EE27}\u{1EE29}-\u{1EE32}\u{1EE34}-\u{1EE37}\u{1EE39}\u{1EE3B}\u{1EE42}\u{1EE47}\u{1EE49}\u{1EE4B}\u{1EE4D}-\u{1EE4F}\u{1EE51}\u{1EE52}\u{1EE54}\u{1EE57}\u{1EE59}\u{1EE5B}\u{1EE5D}\u{1EE5F}\u{1EE61}\u{1EE62}\u{1EE64}\u{1EE67}-\u{1EE6A}\u{1EE6C}-\u{1EE72}\u{1EE74}-\u{1EE77}\u{1EE79}-\u{1EE7C}\u{1EE7E}\u{1EE80}-\u{1EE89}\u{1EE8B}-\u{1EE9B}\u{1EEA1}-\u{1EEA3}\u{1EEA5}-\u{1EEA9}\u{1EEAB}-\u{1EEBB}]/u;
- var bidiS1LTR = /[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02BB-\u02C1\u02D0\u02D1\u02E0-\u02E4\u02EE\u0370-\u0373\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0482\u048A-\u052F\u0531-\u0556\u0559-\u0589\u0903-\u0939\u093B\u093D-\u0940\u0949-\u094C\u094E-\u0950\u0958-\u0961\u0964-\u0980\u0982\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD-\u09C0\u09C7\u09C8\u09CB\u09CC\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09FA\u09FC\u09FD\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3E-\u0A40\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A76\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD-\u0AC0\u0AC9\u0ACB\u0ACC\u0AD0\u0AE0\u0AE1\u0AE6-\u0AF0\u0AF9\u0B02\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B3E\u0B40\u0B47\u0B48\u0B4B\u0B4C\u0B57\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE\u0BBF\u0BC1\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD0\u0BD7\u0BE6-\u0BF2\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C41-\u0C44\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C66-\u0C6F\u0C77\u0C7F\u0C80\u0C82-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD-\u0CC4\u0CC6-\u0CC8\u0CCA\u0CCB\u0CD5\u0CD6\u0CDD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D4E\u0D4F\u0D54-\u0D61\u0D66-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCF-\u0DD1\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2-\u0DF4\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E4F-\u0E5B\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00-\u0F17\u0F1A-\u0F34\u0F36\u0F38\u0F3E-\u0F47\u0F49-\u0F6C\u0F7F\u0F85\u0F88-\u0F8C\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FDA\u1000-\u102C\u1031\u1038\u103B\u103C\u103F-\u1057\u105A-\u105D\u1061-\u1070\u1075-\u1081\u1083\u1084\u1087-\u108C\u108E-\u109C\u109E-\u10C5\u10C7\u10CD\u10D0-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1360-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u167F\u1681-\u169A\u16A0-\u16F8\u1700-\u1711\u1715\u171F-\u1731\u1734-\u1736\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17B6\u17BE-\u17C5\u17C7\u17C8\u17D4-\u17DA\u17DC\u17E0-\u17E9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1923-\u1926\u1929-\u192B\u1930\u1931\u1933-\u1938\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A19\u1A1A\u1A1E-\u1A55\u1A57\u1A61\u1A63\u1A64\u1A6D-\u1A72\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AAD\u1B04-\u1B33\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B4C\u1B50-\u1B6A\u1B74-\u1B7E\u1B82-\u1BA1\u1BA6\u1BA7\u1BAA\u1BAE-\u1BE5\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2\u1BF3\u1BFC-\u1C2B\u1C34\u1C35\u1C3B-\u1C49\u1C4D-\u1C88\u1C90-\u1CBA\u1CBD-\u1CC7\u1CD3\u1CE1\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5-\u1CF7\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200E\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u214F\u2160-\u2188\u2336-\u237A\u2395\u249C-\u24E9\u26AC\u2800-\u28FF\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D70\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u302E\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\u31BF\u31F0-\u321C\u3220-\u324F\u3260-\u327B\u327F-\u32B0\u32C0-\u32CB\u32D0-\u3376\u337B-\u33DD\u33E0-\u33FE\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA60C\uA610-\uA62B\uA640-\uA66E\uA680-\uA69D\uA6A0-\uA6EF\uA6F2-\uA6F7\uA722-\uA787\uA789-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA824\uA827\uA830-\uA837\uA840-\uA873\uA880-\uA8C3\uA8CE-\uA8D9\uA8F2-\uA8FE\uA900-\uA925\uA92E-\uA946\uA952\uA953\uA95F-\uA97C\uA983-\uA9B2\uA9B4\uA9B5\uA9BA\uA9BB\uA9BE-\uA9CD\uA9CF-\uA9D9\uA9DE-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA2F\uAA30\uAA33\uAA34\uAA40-\uAA42\uAA44-\uAA4B\uAA4D\uAA50-\uAA59\uAA5C-\uAA7B\uAA7D-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAAEB\uAAEE-\uAAF5\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB69\uAB70-\uABE4\uABE6\uABE7\uABE9-\uABEC\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uD800-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\u{10000}-\u{1000B}\u{1000D}-\u{10026}\u{10028}-\u{1003A}\u{1003C}\u{1003D}\u{1003F}-\u{1004D}\u{10050}-\u{1005D}\u{10080}-\u{100FA}\u{10100}\u{10102}\u{10107}-\u{10133}\u{10137}-\u{1013F}\u{1018D}\u{1018E}\u{101D0}-\u{101FC}\u{10280}-\u{1029C}\u{102A0}-\u{102D0}\u{10300}-\u{10323}\u{1032D}-\u{1034A}\u{10350}-\u{10375}\u{10380}-\u{1039D}\u{1039F}-\u{103C3}\u{103C8}-\u{103D5}\u{10400}-\u{1049D}\u{104A0}-\u{104A9}\u{104B0}-\u{104D3}\u{104D8}-\u{104FB}\u{10500}-\u{10527}\u{10530}-\u{10563}\u{1056F}-\u{1057A}\u{1057C}-\u{1058A}\u{1058C}-\u{10592}\u{10594}\u{10595}\u{10597}-\u{105A1}\u{105A3}-\u{105B1}\u{105B3}-\u{105B9}\u{105BB}\u{105BC}\u{10600}-\u{10736}\u{10740}-\u{10755}\u{10760}-\u{10767}\u{10780}-\u{10785}\u{10787}-\u{107B0}\u{107B2}-\u{107BA}\u{11000}\u{11002}-\u{11037}\u{11047}-\u{1104D}\u{11066}-\u{1106F}\u{11071}\u{11072}\u{11075}\u{11082}-\u{110B2}\u{110B7}\u{110B8}\u{110BB}-\u{110C1}\u{110CD}\u{110D0}-\u{110E8}\u{110F0}-\u{110F9}\u{11103}-\u{11126}\u{1112C}\u{11136}-\u{11147}\u{11150}-\u{11172}\u{11174}-\u{11176}\u{11182}-\u{111B5}\u{111BF}-\u{111C8}\u{111CD}\u{111CE}\u{111D0}-\u{111DF}\u{111E1}-\u{111F4}\u{11200}-\u{11211}\u{11213}-\u{1122E}\u{11232}\u{11233}\u{11235}\u{11238}-\u{1123D}\u{11280}-\u{11286}\u{11288}\u{1128A}-\u{1128D}\u{1128F}-\u{1129D}\u{1129F}-\u{112A9}\u{112B0}-\u{112DE}\u{112E0}-\u{112E2}\u{112F0}-\u{112F9}\u{11302}\u{11303}\u{11305}-\u{1130C}\u{1130F}\u{11310}\u{11313}-\u{11328}\u{1132A}-\u{11330}\u{11332}\u{11333}\u{11335}-\u{11339}\u{1133D}-\u{1133F}\u{11341}-\u{11344}\u{11347}\u{11348}\u{1134B}-\u{1134D}\u{11350}\u{11357}\u{1135D}-\u{11363}\u{11400}-\u{11437}\u{11440}\u{11441}\u{11445}\u{11447}-\u{1145B}\u{1145D}\u{1145F}-\u{11461}\u{11480}-\u{114B2}\u{114B9}\u{114BB}-\u{114BE}\u{114C1}\u{114C4}-\u{114C7}\u{114D0}-\u{114D9}\u{11580}-\u{115B1}\u{115B8}-\u{115BB}\u{115BE}\u{115C1}-\u{115DB}\u{11600}-\u{11632}\u{1163B}\u{1163C}\u{1163E}\u{11641}-\u{11644}\u{11650}-\u{11659}\u{11680}-\u{116AA}\u{116AC}\u{116AE}\u{116AF}\u{116B6}\u{116B8}\u{116B9}\u{116C0}-\u{116C9}\u{11700}-\u{1171A}\u{11720}\u{11721}\u{11726}\u{11730}-\u{11746}\u{11800}-\u{1182E}\u{11838}\u{1183B}\u{118A0}-\u{118F2}\u{118FF}-\u{11906}\u{11909}\u{1190C}-\u{11913}\u{11915}\u{11916}\u{11918}-\u{11935}\u{11937}\u{11938}\u{1193D}\u{1193F}-\u{11942}\u{11944}-\u{11946}\u{11950}-\u{11959}\u{119A0}-\u{119A7}\u{119AA}-\u{119D3}\u{119DC}-\u{119DF}\u{119E1}-\u{119E4}\u{11A00}\u{11A07}\u{11A08}\u{11A0B}-\u{11A32}\u{11A39}\u{11A3A}\u{11A3F}-\u{11A46}\u{11A50}\u{11A57}\u{11A58}\u{11A5C}-\u{11A89}\u{11A97}\u{11A9A}-\u{11AA2}\u{11AB0}-\u{11AF8}\u{11C00}-\u{11C08}\u{11C0A}-\u{11C2F}\u{11C3E}-\u{11C45}\u{11C50}-\u{11C6C}\u{11C70}-\u{11C8F}\u{11CA9}\u{11CB1}\u{11CB4}\u{11D00}-\u{11D06}\u{11D08}\u{11D09}\u{11D0B}-\u{11D30}\u{11D46}\u{11D50}-\u{11D59}\u{11D60}-\u{11D65}\u{11D67}\u{11D68}\u{11D6A}-\u{11D8E}\u{11D93}\u{11D94}\u{11D96}\u{11D98}\u{11DA0}-\u{11DA9}\u{11EE0}-\u{11EF2}\u{11EF5}-\u{11EF8}\u{11FB0}\u{11FC0}-\u{11FD4}\u{11FFF}-\u{12399}\u{12400}-\u{1246E}\u{12470}-\u{12474}\u{12480}-\u{12543}\u{12F90}-\u{12FF2}\u{13000}-\u{1342E}\u{13430}-\u{13438}\u{14400}-\u{14646}\u{16800}-\u{16A38}\u{16A40}-\u{16A5E}\u{16A60}-\u{16A69}\u{16A6E}-\u{16ABE}\u{16AC0}-\u{16AC9}\u{16AD0}-\u{16AED}\u{16AF5}\u{16B00}-\u{16B2F}\u{16B37}-\u{16B45}\u{16B50}-\u{16B59}\u{16B5B}-\u{16B61}\u{16B63}-\u{16B77}\u{16B7D}-\u{16B8F}\u{16E40}-\u{16E9A}\u{16F00}-\u{16F4A}\u{16F50}-\u{16F87}\u{16F93}-\u{16F9F}\u{16FE0}\u{16FE1}\u{16FE3}\u{16FF0}\u{16FF1}\u{17000}-\u{187F7}\u{18800}-\u{18CD5}\u{18D00}-\u{18D08}\u{1AFF0}-\u{1AFF3}\u{1AFF5}-\u{1AFFB}\u{1AFFD}\u{1AFFE}\u{1B000}-\u{1B122}\u{1B150}-\u{1B152}\u{1B164}-\u{1B167}\u{1B170}-\u{1B2FB}\u{1BC00}-\u{1BC6A}\u{1BC70}-\u{1BC7C}\u{1BC80}-\u{1BC88}\u{1BC90}-\u{1BC99}\u{1BC9C}\u{1BC9F}\u{1CF50}-\u{1CFC3}\u{1D000}-\u{1D0F5}\u{1D100}-\u{1D126}\u{1D129}-\u{1D166}\u{1D16A}-\u{1D172}\u{1D183}\u{1D184}\u{1D18C}-\u{1D1A9}\u{1D1AE}-\u{1D1E8}\u{1D2E0}-\u{1D2F3}\u{1D360}-\u{1D378}\u{1D400}-\u{1D454}\u{1D456}-\u{1D49C}\u{1D49E}\u{1D49F}\u{1D4A2}\u{1D4A5}\u{1D4A6}\u{1D4A9}-\u{1D4AC}\u{1D4AE}-\u{1D4B9}\u{1D4BB}\u{1D4BD}-\u{1D4C3}\u{1D4C5}-\u{1D505}\u{1D507}-\u{1D50A}\u{1D50D}-\u{1D514}\u{1D516}-\u{1D51C}\u{1D51E}-\u{1D539}\u{1D53B}-\u{1D53E}\u{1D540}-\u{1D544}\u{1D546}\u{1D54A}-\u{1D550}\u{1D552}-\u{1D6A5}\u{1D6A8}-\u{1D6DA}\u{1D6DC}-\u{1D714}\u{1D716}-\u{1D74E}\u{1D750}-\u{1D788}\u{1D78A}-\u{1D7C2}\u{1D7C4}-\u{1D7CB}\u{1D800}-\u{1D9FF}\u{1DA37}-\u{1DA3A}\u{1DA6D}-\u{1DA74}\u{1DA76}-\u{1DA83}\u{1DA85}-\u{1DA8B}\u{1DF00}-\u{1DF1E}\u{1E100}-\u{1E12C}\u{1E137}-\u{1E13D}\u{1E140}-\u{1E149}\u{1E14E}\u{1E14F}\u{1E290}-\u{1E2AD}\u{1E2C0}-\u{1E2EB}\u{1E2F0}-\u{1E2F9}\u{1E7E0}-\u{1E7E6}\u{1E7E8}-\u{1E7EB}\u{1E7ED}\u{1E7EE}\u{1E7F0}-\u{1E7FE}\u{1F110}-\u{1F12E}\u{1F130}-\u{1F169}\u{1F170}-\u{1F1AC}\u{1F1E6}-\u{1F202}\u{1F210}-\u{1F23B}\u{1F240}-\u{1F248}\u{1F250}\u{1F251}\u{20000}-\u{2A6DF}\u{2A700}-\u{2B738}\u{2B740}-\u{2B81D}\u{2B820}-\u{2CEA1}\u{2CEB0}-\u{2EBE0}\u{2F800}-\u{2FA1D}\u{30000}-\u{3134A}\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}]/u;
- var bidiS1RTL = /[\u05BE\u05C0\u05C3\u05C6\u05D0-\u05EA\u05EF-\u05F4\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u070D\u070F\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u07FE-\u0815\u081A\u0824\u0828\u0830-\u083E\u0840-\u0858\u085E\u0860-\u086A\u0870-\u088E\u08A0-\u08C9\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBC2\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFC\uFE70-\uFE74\uFE76-\uFEFC\u{10800}-\u{10805}\u{10808}\u{1080A}-\u{10835}\u{10837}\u{10838}\u{1083C}\u{1083F}-\u{10855}\u{10857}-\u{1089E}\u{108A7}-\u{108AF}\u{108E0}-\u{108F2}\u{108F4}\u{108F5}\u{108FB}-\u{1091B}\u{10920}-\u{10939}\u{1093F}\u{10980}-\u{109B7}\u{109BC}-\u{109CF}\u{109D2}-\u{10A00}\u{10A10}-\u{10A13}\u{10A15}-\u{10A17}\u{10A19}-\u{10A35}\u{10A40}-\u{10A48}\u{10A50}-\u{10A58}\u{10A60}-\u{10A9F}\u{10AC0}-\u{10AE4}\u{10AEB}-\u{10AF6}\u{10B00}-\u{10B35}\u{10B40}-\u{10B55}\u{10B58}-\u{10B72}\u{10B78}-\u{10B91}\u{10B99}-\u{10B9C}\u{10BA9}-\u{10BAF}\u{10C00}-\u{10C48}\u{10C80}-\u{10CB2}\u{10CC0}-\u{10CF2}\u{10CFA}-\u{10D23}\u{10E80}-\u{10EA9}\u{10EAD}\u{10EB0}\u{10EB1}\u{10F00}-\u{10F27}\u{10F30}-\u{10F45}\u{10F51}-\u{10F59}\u{10F70}-\u{10F81}\u{10F86}-\u{10F89}\u{10FB0}-\u{10FCB}\u{10FE0}-\u{10FF6}\u{1E800}-\u{1E8C4}\u{1E8C7}-\u{1E8CF}\u{1E900}-\u{1E943}\u{1E94B}\u{1E950}-\u{1E959}\u{1E95E}\u{1E95F}\u{1EC71}-\u{1ECB4}\u{1ED01}-\u{1ED3D}\u{1EE00}-\u{1EE03}\u{1EE05}-\u{1EE1F}\u{1EE21}\u{1EE22}\u{1EE24}\u{1EE27}\u{1EE29}-\u{1EE32}\u{1EE34}-\u{1EE37}\u{1EE39}\u{1EE3B}\u{1EE42}\u{1EE47}\u{1EE49}\u{1EE4B}\u{1EE4D}-\u{1EE4F}\u{1EE51}\u{1EE52}\u{1EE54}\u{1EE57}\u{1EE59}\u{1EE5B}\u{1EE5D}\u{1EE5F}\u{1EE61}\u{1EE62}\u{1EE64}\u{1EE67}-\u{1EE6A}\u{1EE6C}-\u{1EE72}\u{1EE74}-\u{1EE77}\u{1EE79}-\u{1EE7C}\u{1EE7E}\u{1EE80}-\u{1EE89}\u{1EE8B}-\u{1EE9B}\u{1EEA1}-\u{1EEA3}\u{1EEA5}-\u{1EEA9}\u{1EEAB}-\u{1EEBB}]/u;
- var bidiS2 = /^[\0-\x08\x0E-\x1B!-@\[-`\{-\x84\x86-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02B9\u02BA\u02C2-\u02CF\u02D2-\u02DF\u02E5-\u02ED\u02EF-\u036F\u0374\u0375\u037E\u0384\u0385\u0387\u03F6\u0483-\u0489\u058A\u058D-\u058F\u0591-\u05C7\u05D0-\u05EA\u05EF-\u05F4\u0600-\u070D\u070F-\u074A\u074D-\u07B1\u07C0-\u07FA\u07FD-\u082D\u0830-\u083E\u0840-\u085B\u085E\u0860-\u086A\u0870-\u088E\u0890\u0891\u0898-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09C1-\u09C4\u09CD\u09E2\u09E3\u09F2\u09F3\u09FB\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AF1\u0AFA-\u0AFF\u0B01\u0B3C\u0B3F\u0B41-\u0B44\u0B4D\u0B55\u0B56\u0B62\u0B63\u0B82\u0BC0\u0BCD\u0BF3-\u0BFA\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C78-\u0C7E\u0C81\u0CBC\u0CCC\u0CCD\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D41-\u0D44\u0D4D\u0D62\u0D63\u0D81\u0DCA\u0DD2-\u0DD4\u0DD6\u0E31\u0E34-\u0E3A\u0E3F\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39-\u0F3D\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1390-\u1399\u1400\u169B\u169C\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DB\u17DD\u17F0-\u17F9\u1800-\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1940\u1944\u1945\u19DE-\u19FF\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34\u1B36-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u200B-\u200D\u200F-\u2027\u202F-\u205E\u2060-\u2064\u206A-\u2070\u2074-\u207E\u2080-\u208E\u20A0-\u20C0\u20D0-\u20F0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u2150-\u215F\u2189-\u218B\u2190-\u2335\u237B-\u2394\u2396-\u2426\u2440-\u244A\u2460-\u249B\u24EA-\u26AB\u26AD-\u27FF\u2900-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2CEF-\u2CF1\u2CF9-\u2CFF\u2D7F\u2DE0-\u2E5D\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u3004\u3008-\u3020\u302A-\u302D\u3030\u3036\u3037\u303D-\u303F\u3099-\u309C\u30A0\u30FB\u31C0-\u31E3\u321D\u321E\u3250-\u325F\u327C-\u327E\u32B1-\u32BF\u32CC-\u32CF\u3377-\u337A\u33DE\u33DF\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA60D-\uA60F\uA66F-\uA67F\uA69E\uA69F\uA6F0\uA6F1\uA700-\uA721\uA788\uA802\uA806\uA80B\uA825\uA826\uA828-\uA82C\uA838\uA839\uA874-\uA877\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uAB6A\uAB6B\uABE5\uABE8\uABED\uFB1D-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBC2\uFBD3-\uFD8F\uFD92-\uFDC7\uFDCF\uFDF0-\uFE19\uFE20-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFE70-\uFE74\uFE76-\uFEFC\uFEFF\uFF01-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFF9-\uFFFD\u{10101}\u{10140}-\u{1018C}\u{10190}-\u{1019C}\u{101A0}\u{101FD}\u{102E0}-\u{102FB}\u{10376}-\u{1037A}\u{10800}-\u{10805}\u{10808}\u{1080A}-\u{10835}\u{10837}\u{10838}\u{1083C}\u{1083F}-\u{10855}\u{10857}-\u{1089E}\u{108A7}-\u{108AF}\u{108E0}-\u{108F2}\u{108F4}\u{108F5}\u{108FB}-\u{1091B}\u{1091F}-\u{10939}\u{1093F}\u{10980}-\u{109B7}\u{109BC}-\u{109CF}\u{109D2}-\u{10A03}\u{10A05}\u{10A06}\u{10A0C}-\u{10A13}\u{10A15}-\u{10A17}\u{10A19}-\u{10A35}\u{10A38}-\u{10A3A}\u{10A3F}-\u{10A48}\u{10A50}-\u{10A58}\u{10A60}-\u{10A9F}\u{10AC0}-\u{10AE6}\u{10AEB}-\u{10AF6}\u{10B00}-\u{10B35}\u{10B39}-\u{10B55}\u{10B58}-\u{10B72}\u{10B78}-\u{10B91}\u{10B99}-\u{10B9C}\u{10BA9}-\u{10BAF}\u{10C00}-\u{10C48}\u{10C80}-\u{10CB2}\u{10CC0}-\u{10CF2}\u{10CFA}-\u{10D27}\u{10D30}-\u{10D39}\u{10E60}-\u{10E7E}\u{10E80}-\u{10EA9}\u{10EAB}-\u{10EAD}\u{10EB0}\u{10EB1}\u{10F00}-\u{10F27}\u{10F30}-\u{10F59}\u{10F70}-\u{10F89}\u{10FB0}-\u{10FCB}\u{10FE0}-\u{10FF6}\u{11001}\u{11038}-\u{11046}\u{11052}-\u{11065}\u{11070}\u{11073}\u{11074}\u{1107F}-\u{11081}\u{110B3}-\u{110B6}\u{110B9}\u{110BA}\u{110C2}\u{11100}-\u{11102}\u{11127}-\u{1112B}\u{1112D}-\u{11134}\u{11173}\u{11180}\u{11181}\u{111B6}-\u{111BE}\u{111C9}-\u{111CC}\u{111CF}\u{1122F}-\u{11231}\u{11234}\u{11236}\u{11237}\u{1123E}\u{112DF}\u{112E3}-\u{112EA}\u{11300}\u{11301}\u{1133B}\u{1133C}\u{11340}\u{11366}-\u{1136C}\u{11370}-\u{11374}\u{11438}-\u{1143F}\u{11442}-\u{11444}\u{11446}\u{1145E}\u{114B3}-\u{114B8}\u{114BA}\u{114BF}\u{114C0}\u{114C2}\u{114C3}\u{115B2}-\u{115B5}\u{115BC}\u{115BD}\u{115BF}\u{115C0}\u{115DC}\u{115DD}\u{11633}-\u{1163A}\u{1163D}\u{1163F}\u{11640}\u{11660}-\u{1166C}\u{116AB}\u{116AD}\u{116B0}-\u{116B5}\u{116B7}\u{1171D}-\u{1171F}\u{11722}-\u{11725}\u{11727}-\u{1172B}\u{1182F}-\u{11837}\u{11839}\u{1183A}\u{1193B}\u{1193C}\u{1193E}\u{11943}\u{119D4}-\u{119D7}\u{119DA}\u{119DB}\u{119E0}\u{11A01}-\u{11A06}\u{11A09}\u{11A0A}\u{11A33}-\u{11A38}\u{11A3B}-\u{11A3E}\u{11A47}\u{11A51}-\u{11A56}\u{11A59}-\u{11A5B}\u{11A8A}-\u{11A96}\u{11A98}\u{11A99}\u{11C30}-\u{11C36}\u{11C38}-\u{11C3D}\u{11C92}-\u{11CA7}\u{11CAA}-\u{11CB0}\u{11CB2}\u{11CB3}\u{11CB5}\u{11CB6}\u{11D31}-\u{11D36}\u{11D3A}\u{11D3C}\u{11D3D}\u{11D3F}-\u{11D45}\u{11D47}\u{11D90}\u{11D91}\u{11D95}\u{11D97}\u{11EF3}\u{11EF4}\u{11FD5}-\u{11FF1}\u{16AF0}-\u{16AF4}\u{16B30}-\u{16B36}\u{16F4F}\u{16F8F}-\u{16F92}\u{16FE2}\u{16FE4}\u{1BC9D}\u{1BC9E}\u{1BCA0}-\u{1BCA3}\u{1CF00}-\u{1CF2D}\u{1CF30}-\u{1CF46}\u{1D167}-\u{1D169}\u{1D173}-\u{1D182}\u{1D185}-\u{1D18B}\u{1D1AA}-\u{1D1AD}\u{1D1E9}\u{1D1EA}\u{1D200}-\u{1D245}\u{1D300}-\u{1D356}\u{1D6DB}\u{1D715}\u{1D74F}\u{1D789}\u{1D7C3}\u{1D7CE}-\u{1D7FF}\u{1DA00}-\u{1DA36}\u{1DA3B}-\u{1DA6C}\u{1DA75}\u{1DA84}\u{1DA9B}-\u{1DA9F}\u{1DAA1}-\u{1DAAF}\u{1E000}-\u{1E006}\u{1E008}-\u{1E018}\u{1E01B}-\u{1E021}\u{1E023}\u{1E024}\u{1E026}-\u{1E02A}\u{1E130}-\u{1E136}\u{1E2AE}\u{1E2EC}-\u{1E2EF}\u{1E2FF}\u{1E800}-\u{1E8C4}\u{1E8C7}-\u{1E8D6}\u{1E900}-\u{1E94B}\u{1E950}-\u{1E959}\u{1E95E}\u{1E95F}\u{1EC71}-\u{1ECB4}\u{1ED01}-\u{1ED3D}\u{1EE00}-\u{1EE03}\u{1EE05}-\u{1EE1F}\u{1EE21}\u{1EE22}\u{1EE24}\u{1EE27}\u{1EE29}-\u{1EE32}\u{1EE34}-\u{1EE37}\u{1EE39}\u{1EE3B}\u{1EE42}\u{1EE47}\u{1EE49}\u{1EE4B}\u{1EE4D}-\u{1EE4F}\u{1EE51}\u{1EE52}\u{1EE54}\u{1EE57}\u{1EE59}\u{1EE5B}\u{1EE5D}\u{1EE5F}\u{1EE61}\u{1EE62}\u{1EE64}\u{1EE67}-\u{1EE6A}\u{1EE6C}-\u{1EE72}\u{1EE74}-\u{1EE77}\u{1EE79}-\u{1EE7C}\u{1EE7E}\u{1EE80}-\u{1EE89}\u{1EE8B}-\u{1EE9B}\u{1EEA1}-\u{1EEA3}\u{1EEA5}-\u{1EEA9}\u{1EEAB}-\u{1EEBB}\u{1EEF0}\u{1EEF1}\u{1F000}-\u{1F02B}\u{1F030}-\u{1F093}\u{1F0A0}-\u{1F0AE}\u{1F0B1}-\u{1F0BF}\u{1F0C1}-\u{1F0CF}\u{1F0D1}-\u{1F0F5}\u{1F100}-\u{1F10F}\u{1F12F}\u{1F16A}-\u{1F16F}\u{1F1AD}\u{1F260}-\u{1F265}\u{1F300}-\u{1F6D7}\u{1F6DD}-\u{1F6EC}\u{1F6F0}-\u{1F6FC}\u{1F700}-\u{1F773}\u{1F780}-\u{1F7D8}\u{1F7E0}-\u{1F7EB}\u{1F7F0}\u{1F800}-\u{1F80B}\u{1F810}-\u{1F847}\u{1F850}-\u{1F859}\u{1F860}-\u{1F887}\u{1F890}-\u{1F8AD}\u{1F8B0}\u{1F8B1}\u{1F900}-\u{1FA53}\u{1FA60}-\u{1FA6D}\u{1FA70}-\u{1FA74}\u{1FA78}-\u{1FA7C}\u{1FA80}-\u{1FA86}\u{1FA90}-\u{1FAAC}\u{1FAB0}-\u{1FABA}\u{1FAC0}-\u{1FAC5}\u{1FAD0}-\u{1FAD9}\u{1FAE0}-\u{1FAE7}\u{1FAF0}-\u{1FAF6}\u{1FB00}-\u{1FB92}\u{1FB94}-\u{1FBCA}\u{1FBF0}-\u{1FBF9}\u{E0001}\u{E0020}-\u{E007F}\u{E0100}-\u{E01EF}]*$/u;
- var bidiS3 = /[0-9\xB2\xB3\xB9\u05BE\u05C0\u05C3\u05C6\u05D0-\u05EA\u05EF-\u05F4\u0600-\u0605\u0608\u060B\u060D\u061B-\u064A\u0660-\u0669\u066B-\u066F\u0671-\u06D5\u06DD\u06E5\u06E6\u06EE-\u070D\u070F\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u07FE-\u0815\u081A\u0824\u0828\u0830-\u083E\u0840-\u0858\u085E\u0860-\u086A\u0870-\u088E\u0890\u0891\u08A0-\u08C9\u08E2\u200F\u2070\u2074-\u2079\u2080-\u2089\u2488-\u249B\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBC2\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFC\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\u{102E1}-\u{102FB}\u{10800}-\u{10805}\u{10808}\u{1080A}-\u{10835}\u{10837}\u{10838}\u{1083C}\u{1083F}-\u{10855}\u{10857}-\u{1089E}\u{108A7}-\u{108AF}\u{108E0}-\u{108F2}\u{108F4}\u{108F5}\u{108FB}-\u{1091B}\u{10920}-\u{10939}\u{1093F}\u{10980}-\u{109B7}\u{109BC}-\u{109CF}\u{109D2}-\u{10A00}\u{10A10}-\u{10A13}\u{10A15}-\u{10A17}\u{10A19}-\u{10A35}\u{10A40}-\u{10A48}\u{10A50}-\u{10A58}\u{10A60}-\u{10A9F}\u{10AC0}-\u{10AE4}\u{10AEB}-\u{10AF6}\u{10B00}-\u{10B35}\u{10B40}-\u{10B55}\u{10B58}-\u{10B72}\u{10B78}-\u{10B91}\u{10B99}-\u{10B9C}\u{10BA9}-\u{10BAF}\u{10C00}-\u{10C48}\u{10C80}-\u{10CB2}\u{10CC0}-\u{10CF2}\u{10CFA}-\u{10D23}\u{10D30}-\u{10D39}\u{10E60}-\u{10E7E}\u{10E80}-\u{10EA9}\u{10EAD}\u{10EB0}\u{10EB1}\u{10F00}-\u{10F27}\u{10F30}-\u{10F45}\u{10F51}-\u{10F59}\u{10F70}-\u{10F81}\u{10F86}-\u{10F89}\u{10FB0}-\u{10FCB}\u{10FE0}-\u{10FF6}\u{1D7CE}-\u{1D7FF}\u{1E800}-\u{1E8C4}\u{1E8C7}-\u{1E8CF}\u{1E900}-\u{1E943}\u{1E94B}\u{1E950}-\u{1E959}\u{1E95E}\u{1E95F}\u{1EC71}-\u{1ECB4}\u{1ED01}-\u{1ED3D}\u{1EE00}-\u{1EE03}\u{1EE05}-\u{1EE1F}\u{1EE21}\u{1EE22}\u{1EE24}\u{1EE27}\u{1EE29}-\u{1EE32}\u{1EE34}-\u{1EE37}\u{1EE39}\u{1EE3B}\u{1EE42}\u{1EE47}\u{1EE49}\u{1EE4B}\u{1EE4D}-\u{1EE4F}\u{1EE51}\u{1EE52}\u{1EE54}\u{1EE57}\u{1EE59}\u{1EE5B}\u{1EE5D}\u{1EE5F}\u{1EE61}\u{1EE62}\u{1EE64}\u{1EE67}-\u{1EE6A}\u{1EE6C}-\u{1EE72}\u{1EE74}-\u{1EE77}\u{1EE79}-\u{1EE7C}\u{1EE7E}\u{1EE80}-\u{1EE89}\u{1EE8B}-\u{1EE9B}\u{1EEA1}-\u{1EEA3}\u{1EEA5}-\u{1EEA9}\u{1EEAB}-\u{1EEBB}\u{1F100}-\u{1F10A}\u{1FBF0}-\u{1FBF9}][\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09C1-\u09C4\u09CD\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3F\u0B41-\u0B44\u0B4D\u0B55\u0B56\u0B62\u0B63\u0B82\u0BC0\u0BCD\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CCC\u0CCD\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D41-\u0D44\u0D4D\u0D62\u0D63\u0D81\u0DCA\u0DD2-\u0DD4\u0DD6\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34\u1B36-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302D\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\u{101FD}\u{102E0}\u{10376}-\u{1037A}\u{10A01}-\u{10A03}\u{10A05}\u{10A06}\u{10A0C}-\u{10A0F}\u{10A38}-\u{10A3A}\u{10A3F}\u{10AE5}\u{10AE6}\u{10D24}-\u{10D27}\u{10EAB}\u{10EAC}\u{10F46}-\u{10F50}\u{10F82}-\u{10F85}\u{11001}\u{11038}-\u{11046}\u{11070}\u{11073}\u{11074}\u{1107F}-\u{11081}\u{110B3}-\u{110B6}\u{110B9}\u{110BA}\u{110C2}\u{11100}-\u{11102}\u{11127}-\u{1112B}\u{1112D}-\u{11134}\u{11173}\u{11180}\u{11181}\u{111B6}-\u{111BE}\u{111C9}-\u{111CC}\u{111CF}\u{1122F}-\u{11231}\u{11234}\u{11236}\u{11237}\u{1123E}\u{112DF}\u{112E3}-\u{112EA}\u{11300}\u{11301}\u{1133B}\u{1133C}\u{11340}\u{11366}-\u{1136C}\u{11370}-\u{11374}\u{11438}-\u{1143F}\u{11442}-\u{11444}\u{11446}\u{1145E}\u{114B3}-\u{114B8}\u{114BA}\u{114BF}\u{114C0}\u{114C2}\u{114C3}\u{115B2}-\u{115B5}\u{115BC}\u{115BD}\u{115BF}\u{115C0}\u{115DC}\u{115DD}\u{11633}-\u{1163A}\u{1163D}\u{1163F}\u{11640}\u{116AB}\u{116AD}\u{116B0}-\u{116B5}\u{116B7}\u{1171D}-\u{1171F}\u{11722}-\u{11725}\u{11727}-\u{1172B}\u{1182F}-\u{11837}\u{11839}\u{1183A}\u{1193B}\u{1193C}\u{1193E}\u{11943}\u{119D4}-\u{119D7}\u{119DA}\u{119DB}\u{119E0}\u{11A01}-\u{11A06}\u{11A09}\u{11A0A}\u{11A33}-\u{11A38}\u{11A3B}-\u{11A3E}\u{11A47}\u{11A51}-\u{11A56}\u{11A59}-\u{11A5B}\u{11A8A}-\u{11A96}\u{11A98}\u{11A99}\u{11C30}-\u{11C36}\u{11C38}-\u{11C3D}\u{11C92}-\u{11CA7}\u{11CAA}-\u{11CB0}\u{11CB2}\u{11CB3}\u{11CB5}\u{11CB6}\u{11D31}-\u{11D36}\u{11D3A}\u{11D3C}\u{11D3D}\u{11D3F}-\u{11D45}\u{11D47}\u{11D90}\u{11D91}\u{11D95}\u{11D97}\u{11EF3}\u{11EF4}\u{16AF0}-\u{16AF4}\u{16B30}-\u{16B36}\u{16F4F}\u{16F8F}-\u{16F92}\u{16FE4}\u{1BC9D}\u{1BC9E}\u{1CF00}-\u{1CF2D}\u{1CF30}-\u{1CF46}\u{1D167}-\u{1D169}\u{1D17B}-\u{1D182}\u{1D185}-\u{1D18B}\u{1D1AA}-\u{1D1AD}\u{1D242}-\u{1D244}\u{1DA00}-\u{1DA36}\u{1DA3B}-\u{1DA6C}\u{1DA75}\u{1DA84}\u{1DA9B}-\u{1DA9F}\u{1DAA1}-\u{1DAAF}\u{1E000}-\u{1E006}\u{1E008}-\u{1E018}\u{1E01B}-\u{1E021}\u{1E023}\u{1E024}\u{1E026}-\u{1E02A}\u{1E130}-\u{1E136}\u{1E2AE}\u{1E2EC}-\u{1E2EF}\u{1E8D0}-\u{1E8D6}\u{1E944}-\u{1E94A}\u{E0100}-\u{E01EF}]*$/u;
- var bidiS4EN = /[0-9\xB2\xB3\xB9\u06F0-\u06F9\u2070\u2074-\u2079\u2080-\u2089\u2488-\u249B\uFF10-\uFF19\u{102E1}-\u{102FB}\u{1D7CE}-\u{1D7FF}\u{1F100}-\u{1F10A}\u{1FBF0}-\u{1FBF9}]/u;
- var bidiS4AN = /[\u0600-\u0605\u0660-\u0669\u066B\u066C\u06DD\u0890\u0891\u08E2\u{10D30}-\u{10D39}\u{10E60}-\u{10E7E}]/u;
- var bidiS5 = /^[\0-\x08\x0E-\x1B!-\x84\x86-\u0377\u037A-\u037F\u0384-\u038A\u038C\u038E-\u03A1\u03A3-\u052F\u0531-\u0556\u0559-\u058A\u058D-\u058F\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0606\u0607\u0609\u060A\u060C\u060E-\u061A\u064B-\u065F\u066A\u0670\u06D6-\u06DC\u06DE-\u06E4\u06E7-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07F6-\u07F9\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A76\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AF1\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B77\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BFA\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3C-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C5D\u0C60-\u0C63\u0C66-\u0C6F\u0C77-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDD\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4F\u0D54-\u0D63\u0D66-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2-\u0DF4\u0E01-\u0E3A\u0E3F-\u0E5B\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00-\u0F47\u0F49-\u0F6C\u0F71-\u0F97\u0F99-\u0FBC\u0FBE-\u0FCC\u0FCE-\u0FDA\u1000-\u10C5\u10C7\u10CD\u10D0-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u137C\u1380-\u1399\u13A0-\u13F5\u13F8-\u13FD\u1400-\u167F\u1681-\u169C\u16A0-\u16F8\u1700-\u1715\u171F-\u1736\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17DD\u17E0-\u17E9\u17F0-\u17F9\u1800-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1940\u1944-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u19DE-\u1A1B\u1A1E-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA0-\u1AAD\u1AB0-\u1ACE\u1B00-\u1B4C\u1B50-\u1B7E\u1B80-\u1BF3\u1BFC-\u1C37\u1C3B-\u1C49\u1C4D-\u1C88\u1C90-\u1CBA\u1CBD-\u1CC7\u1CD0-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FC4\u1FC6-\u1FD3\u1FD6-\u1FDB\u1FDD-\u1FEF\u1FF2-\u1FF4\u1FF6-\u1FFE\u200B-\u200E\u2010-\u2027\u202F-\u205E\u2060-\u2064\u206A-\u2071\u2074-\u208E\u2090-\u209C\u20A0-\u20C0\u20D0-\u20F0\u2100-\u218B\u2190-\u2426\u2440-\u244A\u2460-\u2B73\u2B76-\u2B95\u2B97-\u2CF3\u2CF9-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D70\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2E5D\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303F\u3041-\u3096\u3099-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\u31E3\u31F0-\u321E\u3220-\uA48C\uA490-\uA4C6\uA4D0-\uA62B\uA640-\uA6F7\uA700-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA82C\uA830-\uA839\uA840-\uA877\uA880-\uA8C5\uA8CE-\uA8D9\uA8E0-\uA953\uA95F-\uA97C\uA980-\uA9CD\uA9CF-\uA9D9\uA9DE-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA5C-\uAAC2\uAADB-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB6B\uAB70-\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uD800-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1E\uFB29\uFD3E-\uFD4F\uFDCF\uFDFD-\uFE19\uFE20-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFEFF\uFF01-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFF9-\uFFFD\u{10000}-\u{1000B}\u{1000D}-\u{10026}\u{10028}-\u{1003A}\u{1003C}\u{1003D}\u{1003F}-\u{1004D}\u{10050}-\u{1005D}\u{10080}-\u{100FA}\u{10100}-\u{10102}\u{10107}-\u{10133}\u{10137}-\u{1018E}\u{10190}-\u{1019C}\u{101A0}\u{101D0}-\u{101FD}\u{10280}-\u{1029C}\u{102A0}-\u{102D0}\u{102E0}-\u{102FB}\u{10300}-\u{10323}\u{1032D}-\u{1034A}\u{10350}-\u{1037A}\u{10380}-\u{1039D}\u{1039F}-\u{103C3}\u{103C8}-\u{103D5}\u{10400}-\u{1049D}\u{104A0}-\u{104A9}\u{104B0}-\u{104D3}\u{104D8}-\u{104FB}\u{10500}-\u{10527}\u{10530}-\u{10563}\u{1056F}-\u{1057A}\u{1057C}-\u{1058A}\u{1058C}-\u{10592}\u{10594}\u{10595}\u{10597}-\u{105A1}\u{105A3}-\u{105B1}\u{105B3}-\u{105B9}\u{105BB}\u{105BC}\u{10600}-\u{10736}\u{10740}-\u{10755}\u{10760}-\u{10767}\u{10780}-\u{10785}\u{10787}-\u{107B0}\u{107B2}-\u{107BA}\u{1091F}\u{10A01}-\u{10A03}\u{10A05}\u{10A06}\u{10A0C}-\u{10A0F}\u{10A38}-\u{10A3A}\u{10A3F}\u{10AE5}\u{10AE6}\u{10B39}-\u{10B3F}\u{10D24}-\u{10D27}\u{10EAB}\u{10EAC}\u{10F46}-\u{10F50}\u{10F82}-\u{10F85}\u{11000}-\u{1104D}\u{11052}-\u{11075}\u{1107F}-\u{110C2}\u{110CD}\u{110D0}-\u{110E8}\u{110F0}-\u{110F9}\u{11100}-\u{11134}\u{11136}-\u{11147}\u{11150}-\u{11176}\u{11180}-\u{111DF}\u{111E1}-\u{111F4}\u{11200}-\u{11211}\u{11213}-\u{1123E}\u{11280}-\u{11286}\u{11288}\u{1128A}-\u{1128D}\u{1128F}-\u{1129D}\u{1129F}-\u{112A9}\u{112B0}-\u{112EA}\u{112F0}-\u{112F9}\u{11300}-\u{11303}\u{11305}-\u{1130C}\u{1130F}\u{11310}\u{11313}-\u{11328}\u{1132A}-\u{11330}\u{11332}\u{11333}\u{11335}-\u{11339}\u{1133B}-\u{11344}\u{11347}\u{11348}\u{1134B}-\u{1134D}\u{11350}\u{11357}\u{1135D}-\u{11363}\u{11366}-\u{1136C}\u{11370}-\u{11374}\u{11400}-\u{1145B}\u{1145D}-\u{11461}\u{11480}-\u{114C7}\u{114D0}-\u{114D9}\u{11580}-\u{115B5}\u{115B8}-\u{115DD}\u{11600}-\u{11644}\u{11650}-\u{11659}\u{11660}-\u{1166C}\u{11680}-\u{116B9}\u{116C0}-\u{116C9}\u{11700}-\u{1171A}\u{1171D}-\u{1172B}\u{11730}-\u{11746}\u{11800}-\u{1183B}\u{118A0}-\u{118F2}\u{118FF}-\u{11906}\u{11909}\u{1190C}-\u{11913}\u{11915}\u{11916}\u{11918}-\u{11935}\u{11937}\u{11938}\u{1193B}-\u{11946}\u{11950}-\u{11959}\u{119A0}-\u{119A7}\u{119AA}-\u{119D7}\u{119DA}-\u{119E4}\u{11A00}-\u{11A47}\u{11A50}-\u{11AA2}\u{11AB0}-\u{11AF8}\u{11C00}-\u{11C08}\u{11C0A}-\u{11C36}\u{11C38}-\u{11C45}\u{11C50}-\u{11C6C}\u{11C70}-\u{11C8F}\u{11C92}-\u{11CA7}\u{11CA9}-\u{11CB6}\u{11D00}-\u{11D06}\u{11D08}\u{11D09}\u{11D0B}-\u{11D36}\u{11D3A}\u{11D3C}\u{11D3D}\u{11D3F}-\u{11D47}\u{11D50}-\u{11D59}\u{11D60}-\u{11D65}\u{11D67}\u{11D68}\u{11D6A}-\u{11D8E}\u{11D90}\u{11D91}\u{11D93}-\u{11D98}\u{11DA0}-\u{11DA9}\u{11EE0}-\u{11EF8}\u{11FB0}\u{11FC0}-\u{11FF1}\u{11FFF}-\u{12399}\u{12400}-\u{1246E}\u{12470}-\u{12474}\u{12480}-\u{12543}\u{12F90}-\u{12FF2}\u{13000}-\u{1342E}\u{13430}-\u{13438}\u{14400}-\u{14646}\u{16800}-\u{16A38}\u{16A40}-\u{16A5E}\u{16A60}-\u{16A69}\u{16A6E}-\u{16ABE}\u{16AC0}-\u{16AC9}\u{16AD0}-\u{16AED}\u{16AF0}-\u{16AF5}\u{16B00}-\u{16B45}\u{16B50}-\u{16B59}\u{16B5B}-\u{16B61}\u{16B63}-\u{16B77}\u{16B7D}-\u{16B8F}\u{16E40}-\u{16E9A}\u{16F00}-\u{16F4A}\u{16F4F}-\u{16F87}\u{16F8F}-\u{16F9F}\u{16FE0}-\u{16FE4}\u{16FF0}\u{16FF1}\u{17000}-\u{187F7}\u{18800}-\u{18CD5}\u{18D00}-\u{18D08}\u{1AFF0}-\u{1AFF3}\u{1AFF5}-\u{1AFFB}\u{1AFFD}\u{1AFFE}\u{1B000}-\u{1B122}\u{1B150}-\u{1B152}\u{1B164}-\u{1B167}\u{1B170}-\u{1B2FB}\u{1BC00}-\u{1BC6A}\u{1BC70}-\u{1BC7C}\u{1BC80}-\u{1BC88}\u{1BC90}-\u{1BC99}\u{1BC9C}-\u{1BCA3}\u{1CF00}-\u{1CF2D}\u{1CF30}-\u{1CF46}\u{1CF50}-\u{1CFC3}\u{1D000}-\u{1D0F5}\u{1D100}-\u{1D126}\u{1D129}-\u{1D1EA}\u{1D200}-\u{1D245}\u{1D2E0}-\u{1D2F3}\u{1D300}-\u{1D356}\u{1D360}-\u{1D378}\u{1D400}-\u{1D454}\u{1D456}-\u{1D49C}\u{1D49E}\u{1D49F}\u{1D4A2}\u{1D4A5}\u{1D4A6}\u{1D4A9}-\u{1D4AC}\u{1D4AE}-\u{1D4B9}\u{1D4BB}\u{1D4BD}-\u{1D4C3}\u{1D4C5}-\u{1D505}\u{1D507}-\u{1D50A}\u{1D50D}-\u{1D514}\u{1D516}-\u{1D51C}\u{1D51E}-\u{1D539}\u{1D53B}-\u{1D53E}\u{1D540}-\u{1D544}\u{1D546}\u{1D54A}-\u{1D550}\u{1D552}-\u{1D6A5}\u{1D6A8}-\u{1D7CB}\u{1D7CE}-\u{1DA8B}\u{1DA9B}-\u{1DA9F}\u{1DAA1}-\u{1DAAF}\u{1DF00}-\u{1DF1E}\u{1E000}-\u{1E006}\u{1E008}-\u{1E018}\u{1E01B}-\u{1E021}\u{1E023}\u{1E024}\u{1E026}-\u{1E02A}\u{1E100}-\u{1E12C}\u{1E130}-\u{1E13D}\u{1E140}-\u{1E149}\u{1E14E}\u{1E14F}\u{1E290}-\u{1E2AE}\u{1E2C0}-\u{1E2F9}\u{1E2FF}\u{1E7E0}-\u{1E7E6}\u{1E7E8}-\u{1E7EB}\u{1E7ED}\u{1E7EE}\u{1E7F0}-\u{1E7FE}\u{1E8D0}-\u{1E8D6}\u{1E944}-\u{1E94A}\u{1EEF0}\u{1EEF1}\u{1F000}-\u{1F02B}\u{1F030}-\u{1F093}\u{1F0A0}-\u{1F0AE}\u{1F0B1}-\u{1F0BF}\u{1F0C1}-\u{1F0CF}\u{1F0D1}-\u{1F0F5}\u{1F100}-\u{1F1AD}\u{1F1E6}-\u{1F202}\u{1F210}-\u{1F23B}\u{1F240}-\u{1F248}\u{1F250}\u{1F251}\u{1F260}-\u{1F265}\u{1F300}-\u{1F6D7}\u{1F6DD}-\u{1F6EC}\u{1F6F0}-\u{1F6FC}\u{1F700}-\u{1F773}\u{1F780}-\u{1F7D8}\u{1F7E0}-\u{1F7EB}\u{1F7F0}\u{1F800}-\u{1F80B}\u{1F810}-\u{1F847}\u{1F850}-\u{1F859}\u{1F860}-\u{1F887}\u{1F890}-\u{1F8AD}\u{1F8B0}\u{1F8B1}\u{1F900}-\u{1FA53}\u{1FA60}-\u{1FA6D}\u{1FA70}-\u{1FA74}\u{1FA78}-\u{1FA7C}\u{1FA80}-\u{1FA86}\u{1FA90}-\u{1FAAC}\u{1FAB0}-\u{1FABA}\u{1FAC0}-\u{1FAC5}\u{1FAD0}-\u{1FAD9}\u{1FAE0}-\u{1FAE7}\u{1FAF0}-\u{1FAF6}\u{1FB00}-\u{1FB92}\u{1FB94}-\u{1FBCA}\u{1FBF0}-\u{1FBF9}\u{20000}-\u{2A6DF}\u{2A700}-\u{2B738}\u{2B740}-\u{2B81D}\u{2B820}-\u{2CEA1}\u{2CEB0}-\u{2EBE0}\u{2F800}-\u{2FA1D}\u{30000}-\u{3134A}\u{E0001}\u{E0020}-\u{E007F}\u{E0100}-\u{E01EF}\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}]*$/u;
- var bidiS6 = /[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02BB-\u02C1\u02D0\u02D1\u02E0-\u02E4\u02EE\u0370-\u0373\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0482\u048A-\u052F\u0531-\u0556\u0559-\u0589\u06F0-\u06F9\u0903-\u0939\u093B\u093D-\u0940\u0949-\u094C\u094E-\u0950\u0958-\u0961\u0964-\u0980\u0982\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD-\u09C0\u09C7\u09C8\u09CB\u09CC\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09FA\u09FC\u09FD\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3E-\u0A40\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A76\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD-\u0AC0\u0AC9\u0ACB\u0ACC\u0AD0\u0AE0\u0AE1\u0AE6-\u0AF0\u0AF9\u0B02\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B3E\u0B40\u0B47\u0B48\u0B4B\u0B4C\u0B57\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE\u0BBF\u0BC1\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD0\u0BD7\u0BE6-\u0BF2\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C41-\u0C44\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C66-\u0C6F\u0C77\u0C7F\u0C80\u0C82-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD-\u0CC4\u0CC6-\u0CC8\u0CCA\u0CCB\u0CD5\u0CD6\u0CDD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D4E\u0D4F\u0D54-\u0D61\u0D66-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCF-\u0DD1\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2-\u0DF4\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E4F-\u0E5B\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00-\u0F17\u0F1A-\u0F34\u0F36\u0F38\u0F3E-\u0F47\u0F49-\u0F6C\u0F7F\u0F85\u0F88-\u0F8C\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FDA\u1000-\u102C\u1031\u1038\u103B\u103C\u103F-\u1057\u105A-\u105D\u1061-\u1070\u1075-\u1081\u1083\u1084\u1087-\u108C\u108E-\u109C\u109E-\u10C5\u10C7\u10CD\u10D0-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1360-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u167F\u1681-\u169A\u16A0-\u16F8\u1700-\u1711\u1715\u171F-\u1731\u1734-\u1736\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17B6\u17BE-\u17C5\u17C7\u17C8\u17D4-\u17DA\u17DC\u17E0-\u17E9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1923-\u1926\u1929-\u192B\u1930\u1931\u1933-\u1938\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A19\u1A1A\u1A1E-\u1A55\u1A57\u1A61\u1A63\u1A64\u1A6D-\u1A72\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AAD\u1B04-\u1B33\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B4C\u1B50-\u1B6A\u1B74-\u1B7E\u1B82-\u1BA1\u1BA6\u1BA7\u1BAA\u1BAE-\u1BE5\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2\u1BF3\u1BFC-\u1C2B\u1C34\u1C35\u1C3B-\u1C49\u1C4D-\u1C88\u1C90-\u1CBA\u1CBD-\u1CC7\u1CD3\u1CE1\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5-\u1CF7\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200E\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u214F\u2160-\u2188\u2336-\u237A\u2395\u2488-\u24E9\u26AC\u2800-\u28FF\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D70\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u302E\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\u31BF\u31F0-\u321C\u3220-\u324F\u3260-\u327B\u327F-\u32B0\u32C0-\u32CB\u32D0-\u3376\u337B-\u33DD\u33E0-\u33FE\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA60C\uA610-\uA62B\uA640-\uA66E\uA680-\uA69D\uA6A0-\uA6EF\uA6F2-\uA6F7\uA722-\uA787\uA789-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA824\uA827\uA830-\uA837\uA840-\uA873\uA880-\uA8C3\uA8CE-\uA8D9\uA8F2-\uA8FE\uA900-\uA925\uA92E-\uA946\uA952\uA953\uA95F-\uA97C\uA983-\uA9B2\uA9B4\uA9B5\uA9BA\uA9BB\uA9BE-\uA9CD\uA9CF-\uA9D9\uA9DE-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA2F\uAA30\uAA33\uAA34\uAA40-\uAA42\uAA44-\uAA4B\uAA4D\uAA50-\uAA59\uAA5C-\uAA7B\uAA7D-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAAEB\uAAEE-\uAAF5\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB69\uAB70-\uABE4\uABE6\uABE7\uABE9-\uABEC\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uD800-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\u{10000}-\u{1000B}\u{1000D}-\u{10026}\u{10028}-\u{1003A}\u{1003C}\u{1003D}\u{1003F}-\u{1004D}\u{10050}-\u{1005D}\u{10080}-\u{100FA}\u{10100}\u{10102}\u{10107}-\u{10133}\u{10137}-\u{1013F}\u{1018D}\u{1018E}\u{101D0}-\u{101FC}\u{10280}-\u{1029C}\u{102A0}-\u{102D0}\u{102E1}-\u{102FB}\u{10300}-\u{10323}\u{1032D}-\u{1034A}\u{10350}-\u{10375}\u{10380}-\u{1039D}\u{1039F}-\u{103C3}\u{103C8}-\u{103D5}\u{10400}-\u{1049D}\u{104A0}-\u{104A9}\u{104B0}-\u{104D3}\u{104D8}-\u{104FB}\u{10500}-\u{10527}\u{10530}-\u{10563}\u{1056F}-\u{1057A}\u{1057C}-\u{1058A}\u{1058C}-\u{10592}\u{10594}\u{10595}\u{10597}-\u{105A1}\u{105A3}-\u{105B1}\u{105B3}-\u{105B9}\u{105BB}\u{105BC}\u{10600}-\u{10736}\u{10740}-\u{10755}\u{10760}-\u{10767}\u{10780}-\u{10785}\u{10787}-\u{107B0}\u{107B2}-\u{107BA}\u{11000}\u{11002}-\u{11037}\u{11047}-\u{1104D}\u{11066}-\u{1106F}\u{11071}\u{11072}\u{11075}\u{11082}-\u{110B2}\u{110B7}\u{110B8}\u{110BB}-\u{110C1}\u{110CD}\u{110D0}-\u{110E8}\u{110F0}-\u{110F9}\u{11103}-\u{11126}\u{1112C}\u{11136}-\u{11147}\u{11150}-\u{11172}\u{11174}-\u{11176}\u{11182}-\u{111B5}\u{111BF}-\u{111C8}\u{111CD}\u{111CE}\u{111D0}-\u{111DF}\u{111E1}-\u{111F4}\u{11200}-\u{11211}\u{11213}-\u{1122E}\u{11232}\u{11233}\u{11235}\u{11238}-\u{1123D}\u{11280}-\u{11286}\u{11288}\u{1128A}-\u{1128D}\u{1128F}-\u{1129D}\u{1129F}-\u{112A9}\u{112B0}-\u{112DE}\u{112E0}-\u{112E2}\u{112F0}-\u{112F9}\u{11302}\u{11303}\u{11305}-\u{1130C}\u{1130F}\u{11310}\u{11313}-\u{11328}\u{1132A}-\u{11330}\u{11332}\u{11333}\u{11335}-\u{11339}\u{1133D}-\u{1133F}\u{11341}-\u{11344}\u{11347}\u{11348}\u{1134B}-\u{1134D}\u{11350}\u{11357}\u{1135D}-\u{11363}\u{11400}-\u{11437}\u{11440}\u{11441}\u{11445}\u{11447}-\u{1145B}\u{1145D}\u{1145F}-\u{11461}\u{11480}-\u{114B2}\u{114B9}\u{114BB}-\u{114BE}\u{114C1}\u{114C4}-\u{114C7}\u{114D0}-\u{114D9}\u{11580}-\u{115B1}\u{115B8}-\u{115BB}\u{115BE}\u{115C1}-\u{115DB}\u{11600}-\u{11632}\u{1163B}\u{1163C}\u{1163E}\u{11641}-\u{11644}\u{11650}-\u{11659}\u{11680}-\u{116AA}\u{116AC}\u{116AE}\u{116AF}\u{116B6}\u{116B8}\u{116B9}\u{116C0}-\u{116C9}\u{11700}-\u{1171A}\u{11720}\u{11721}\u{11726}\u{11730}-\u{11746}\u{11800}-\u{1182E}\u{11838}\u{1183B}\u{118A0}-\u{118F2}\u{118FF}-\u{11906}\u{11909}\u{1190C}-\u{11913}\u{11915}\u{11916}\u{11918}-\u{11935}\u{11937}\u{11938}\u{1193D}\u{1193F}-\u{11942}\u{11944}-\u{11946}\u{11950}-\u{11959}\u{119A0}-\u{119A7}\u{119AA}-\u{119D3}\u{119DC}-\u{119DF}\u{119E1}-\u{119E4}\u{11A00}\u{11A07}\u{11A08}\u{11A0B}-\u{11A32}\u{11A39}\u{11A3A}\u{11A3F}-\u{11A46}\u{11A50}\u{11A57}\u{11A58}\u{11A5C}-\u{11A89}\u{11A97}\u{11A9A}-\u{11AA2}\u{11AB0}-\u{11AF8}\u{11C00}-\u{11C08}\u{11C0A}-\u{11C2F}\u{11C3E}-\u{11C45}\u{11C50}-\u{11C6C}\u{11C70}-\u{11C8F}\u{11CA9}\u{11CB1}\u{11CB4}\u{11D00}-\u{11D06}\u{11D08}\u{11D09}\u{11D0B}-\u{11D30}\u{11D46}\u{11D50}-\u{11D59}\u{11D60}-\u{11D65}\u{11D67}\u{11D68}\u{11D6A}-\u{11D8E}\u{11D93}\u{11D94}\u{11D96}\u{11D98}\u{11DA0}-\u{11DA9}\u{11EE0}-\u{11EF2}\u{11EF5}-\u{11EF8}\u{11FB0}\u{11FC0}-\u{11FD4}\u{11FFF}-\u{12399}\u{12400}-\u{1246E}\u{12470}-\u{12474}\u{12480}-\u{12543}\u{12F90}-\u{12FF2}\u{13000}-\u{1342E}\u{13430}-\u{13438}\u{14400}-\u{14646}\u{16800}-\u{16A38}\u{16A40}-\u{16A5E}\u{16A60}-\u{16A69}\u{16A6E}-\u{16ABE}\u{16AC0}-\u{16AC9}\u{16AD0}-\u{16AED}\u{16AF5}\u{16B00}-\u{16B2F}\u{16B37}-\u{16B45}\u{16B50}-\u{16B59}\u{16B5B}-\u{16B61}\u{16B63}-\u{16B77}\u{16B7D}-\u{16B8F}\u{16E40}-\u{16E9A}\u{16F00}-\u{16F4A}\u{16F50}-\u{16F87}\u{16F93}-\u{16F9F}\u{16FE0}\u{16FE1}\u{16FE3}\u{16FF0}\u{16FF1}\u{17000}-\u{187F7}\u{18800}-\u{18CD5}\u{18D00}-\u{18D08}\u{1AFF0}-\u{1AFF3}\u{1AFF5}-\u{1AFFB}\u{1AFFD}\u{1AFFE}\u{1B000}-\u{1B122}\u{1B150}-\u{1B152}\u{1B164}-\u{1B167}\u{1B170}-\u{1B2FB}\u{1BC00}-\u{1BC6A}\u{1BC70}-\u{1BC7C}\u{1BC80}-\u{1BC88}\u{1BC90}-\u{1BC99}\u{1BC9C}\u{1BC9F}\u{1CF50}-\u{1CFC3}\u{1D000}-\u{1D0F5}\u{1D100}-\u{1D126}\u{1D129}-\u{1D166}\u{1D16A}-\u{1D172}\u{1D183}\u{1D184}\u{1D18C}-\u{1D1A9}\u{1D1AE}-\u{1D1E8}\u{1D2E0}-\u{1D2F3}\u{1D360}-\u{1D378}\u{1D400}-\u{1D454}\u{1D456}-\u{1D49C}\u{1D49E}\u{1D49F}\u{1D4A2}\u{1D4A5}\u{1D4A6}\u{1D4A9}-\u{1D4AC}\u{1D4AE}-\u{1D4B9}\u{1D4BB}\u{1D4BD}-\u{1D4C3}\u{1D4C5}-\u{1D505}\u{1D507}-\u{1D50A}\u{1D50D}-\u{1D514}\u{1D516}-\u{1D51C}\u{1D51E}-\u{1D539}\u{1D53B}-\u{1D53E}\u{1D540}-\u{1D544}\u{1D546}\u{1D54A}-\u{1D550}\u{1D552}-\u{1D6A5}\u{1D6A8}-\u{1D6DA}\u{1D6DC}-\u{1D714}\u{1D716}-\u{1D74E}\u{1D750}-\u{1D788}\u{1D78A}-\u{1D7C2}\u{1D7C4}-\u{1D7CB}\u{1D7CE}-\u{1D9FF}\u{1DA37}-\u{1DA3A}\u{1DA6D}-\u{1DA74}\u{1DA76}-\u{1DA83}\u{1DA85}-\u{1DA8B}\u{1DF00}-\u{1DF1E}\u{1E100}-\u{1E12C}\u{1E137}-\u{1E13D}\u{1E140}-\u{1E149}\u{1E14E}\u{1E14F}\u{1E290}-\u{1E2AD}\u{1E2C0}-\u{1E2EB}\u{1E2F0}-\u{1E2F9}\u{1E7E0}-\u{1E7E6}\u{1E7E8}-\u{1E7EB}\u{1E7ED}\u{1E7EE}\u{1E7F0}-\u{1E7FE}\u{1F100}-\u{1F10A}\u{1F110}-\u{1F12E}\u{1F130}-\u{1F169}\u{1F170}-\u{1F1AC}\u{1F1E6}-\u{1F202}\u{1F210}-\u{1F23B}\u{1F240}-\u{1F248}\u{1F250}\u{1F251}\u{1FBF0}-\u{1FBF9}\u{20000}-\u{2A6DF}\u{2A700}-\u{2B738}\u{2B740}-\u{2B81D}\u{2B820}-\u{2CEA1}\u{2CEB0}-\u{2EBE0}\u{2F800}-\u{2FA1D}\u{30000}-\u{3134A}\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}][\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09C1-\u09C4\u09CD\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3F\u0B41-\u0B44\u0B4D\u0B55\u0B56\u0B62\u0B63\u0B82\u0BC0\u0BCD\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CCC\u0CCD\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D41-\u0D44\u0D4D\u0D62\u0D63\u0D81\u0DCA\u0DD2-\u0DD4\u0DD6\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34\u1B36-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302D\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\u{101FD}\u{102E0}\u{10376}-\u{1037A}\u{10A01}-\u{10A03}\u{10A05}\u{10A06}\u{10A0C}-\u{10A0F}\u{10A38}-\u{10A3A}\u{10A3F}\u{10AE5}\u{10AE6}\u{10D24}-\u{10D27}\u{10EAB}\u{10EAC}\u{10F46}-\u{10F50}\u{10F82}-\u{10F85}\u{11001}\u{11038}-\u{11046}\u{11070}\u{11073}\u{11074}\u{1107F}-\u{11081}\u{110B3}-\u{110B6}\u{110B9}\u{110BA}\u{110C2}\u{11100}-\u{11102}\u{11127}-\u{1112B}\u{1112D}-\u{11134}\u{11173}\u{11180}\u{11181}\u{111B6}-\u{111BE}\u{111C9}-\u{111CC}\u{111CF}\u{1122F}-\u{11231}\u{11234}\u{11236}\u{11237}\u{1123E}\u{112DF}\u{112E3}-\u{112EA}\u{11300}\u{11301}\u{1133B}\u{1133C}\u{11340}\u{11366}-\u{1136C}\u{11370}-\u{11374}\u{11438}-\u{1143F}\u{11442}-\u{11444}\u{11446}\u{1145E}\u{114B3}-\u{114B8}\u{114BA}\u{114BF}\u{114C0}\u{114C2}\u{114C3}\u{115B2}-\u{115B5}\u{115BC}\u{115BD}\u{115BF}\u{115C0}\u{115DC}\u{115DD}\u{11633}-\u{1163A}\u{1163D}\u{1163F}\u{11640}\u{116AB}\u{116AD}\u{116B0}-\u{116B5}\u{116B7}\u{1171D}-\u{1171F}\u{11722}-\u{11725}\u{11727}-\u{1172B}\u{1182F}-\u{11837}\u{11839}\u{1183A}\u{1193B}\u{1193C}\u{1193E}\u{11943}\u{119D4}-\u{119D7}\u{119DA}\u{119DB}\u{119E0}\u{11A01}-\u{11A06}\u{11A09}\u{11A0A}\u{11A33}-\u{11A38}\u{11A3B}-\u{11A3E}\u{11A47}\u{11A51}-\u{11A56}\u{11A59}-\u{11A5B}\u{11A8A}-\u{11A96}\u{11A98}\u{11A99}\u{11C30}-\u{11C36}\u{11C38}-\u{11C3D}\u{11C92}-\u{11CA7}\u{11CAA}-\u{11CB0}\u{11CB2}\u{11CB3}\u{11CB5}\u{11CB6}\u{11D31}-\u{11D36}\u{11D3A}\u{11D3C}\u{11D3D}\u{11D3F}-\u{11D45}\u{11D47}\u{11D90}\u{11D91}\u{11D95}\u{11D97}\u{11EF3}\u{11EF4}\u{16AF0}-\u{16AF4}\u{16B30}-\u{16B36}\u{16F4F}\u{16F8F}-\u{16F92}\u{16FE4}\u{1BC9D}\u{1BC9E}\u{1CF00}-\u{1CF2D}\u{1CF30}-\u{1CF46}\u{1D167}-\u{1D169}\u{1D17B}-\u{1D182}\u{1D185}-\u{1D18B}\u{1D1AA}-\u{1D1AD}\u{1D242}-\u{1D244}\u{1DA00}-\u{1DA36}\u{1DA3B}-\u{1DA6C}\u{1DA75}\u{1DA84}\u{1DA9B}-\u{1DA9F}\u{1DAA1}-\u{1DAAF}\u{1E000}-\u{1E006}\u{1E008}-\u{1E018}\u{1E01B}-\u{1E021}\u{1E023}\u{1E024}\u{1E026}-\u{1E02A}\u{1E130}-\u{1E136}\u{1E2AE}\u{1E2EC}-\u{1E2EF}\u{1E8D0}-\u{1E8D6}\u{1E944}-\u{1E94A}\u{E0100}-\u{E01EF}]*$/u;
- module2.exports = {
- combiningMarks,
- combiningClassVirama,
- validZWNJ,
- bidiDomain,
- bidiS1LTR,
- bidiS1RTL,
- bidiS2,
- bidiS3,
- bidiS4EN,
- bidiS4AN,
- bidiS5,
- bidiS6
- };
- }
- });
- // node_modules/tr46/lib/mappingTable.json
- var require_mappingTable = __commonJS({
- "node_modules/tr46/lib/mappingTable.json"(exports2, module2) {
- module2.exports = [[[0, 44], 4], [[45, 46], 2], [47, 4], [[48, 57], 2], [[58, 64], 4], [65, 1, "a"], [66, 1, "b"], [67, 1, "c"], [68, 1, "d"], [69, 1, "e"], [70, 1, "f"], [71, 1, "g"], [72, 1, "h"], [73, 1, "i"], [74, 1, "j"], [75, 1, "k"], [76, 1, "l"], [77, 1, "m"], [78, 1, "n"], [79, 1, "o"], [80, 1, "p"], [81, 1, "q"], [82, 1, "r"], [83, 1, "s"], [84, 1, "t"], [85, 1, "u"], [86, 1, "v"], [87, 1, "w"], [88, 1, "x"], [89, 1, "y"], [90, 1, "z"], [[91, 96], 4], [[97, 122], 2], [[123, 127], 4], [[128, 159], 3], [160, 5, " "], [[161, 167], 2], [168, 5, " \u0308"], [169, 2], [170, 1, "a"], [[171, 172], 2], [173, 7], [174, 2], [175, 5, " \u0304"], [[176, 177], 2], [178, 1, "2"], [179, 1, "3"], [180, 5, " \u0301"], [181, 1, "\u03BC"], [182, 2], [183, 2], [184, 5, " \u0327"], [185, 1, "1"], [186, 1, "o"], [187, 2], [188, 1, "1\u20444"], [189, 1, "1\u20442"], [190, 1, "3\u20444"], [191, 2], [192, 1, "\xE0"], [193, 1, "\xE1"], [194, 1, "\xE2"], [195, 1, "\xE3"], [196, 1, "\xE4"], [197, 1, "\xE5"], [198, 1, "\xE6"], [199, 1, "\xE7"], [200, 1, "\xE8"], [201, 1, "\xE9"], [202, 1, "\xEA"], [203, 1, "\xEB"], [204, 1, "\xEC"], [205, 1, "\xED"], [206, 1, "\xEE"], [207, 1, "\xEF"], [208, 1, "\xF0"], [209, 1, "\xF1"], [210, 1, "\xF2"], [211, 1, "\xF3"], [212, 1, "\xF4"], [213, 1, "\xF5"], [214, 1, "\xF6"], [215, 2], [216, 1, "\xF8"], [217, 1, "\xF9"], [218, 1, "\xFA"], [219, 1, "\xFB"], [220, 1, "\xFC"], [221, 1, "\xFD"], [222, 1, "\xFE"], [223, 6, "ss"], [[224, 246], 2], [247, 2], [[248, 255], 2], [256, 1, "\u0101"], [257, 2], [258, 1, "\u0103"], [259, 2], [260, 1, "\u0105"], [261, 2], [262, 1, "\u0107"], [263, 2], [264, 1, "\u0109"], [265, 2], [266, 1, "\u010B"], [267, 2], [268, 1, "\u010D"], [269, 2], [270, 1, "\u010F"], [271, 2], [272, 1, "\u0111"], [273, 2], [274, 1, "\u0113"], [275, 2], [276, 1, "\u0115"], [277, 2], [278, 1, "\u0117"], [279, 2], [280, 1, "\u0119"], [281, 2], [282, 1, "\u011B"], [283, 2], [284, 1, "\u011D"], [285, 2], [286, 1, "\u011F"], [287, 2], [288, 1, "\u0121"], [289, 2], [290, 1, "\u0123"], [291, 2], [292, 1, "\u0125"], [293, 2], [294, 1, "\u0127"], [295, 2], [296, 1, "\u0129"], [297, 2], [298, 1, "\u012B"], [299, 2], [300, 1, "\u012D"], [301, 2], [302, 1, "\u012F"], [303, 2], [304, 1, "i\u0307"], [305, 2], [[306, 307], 1, "ij"], [308, 1, "\u0135"], [309, 2], [310, 1, "\u0137"], [[311, 312], 2], [313, 1, "\u013A"], [314, 2], [315, 1, "\u013C"], [316, 2], [317, 1, "\u013E"], [318, 2], [[319, 320], 1, "l\xB7"], [321, 1, "\u0142"], [322, 2], [323, 1, "\u0144"], [324, 2], [325, 1, "\u0146"], [326, 2], [327, 1, "\u0148"], [328, 2], [329, 1, "\u02BCn"], [330, 1, "\u014B"], [331, 2], [332, 1, "\u014D"], [333, 2], [334, 1, "\u014F"], [335, 2], [336, 1, "\u0151"], [337, 2], [338, 1, "\u0153"], [339, 2], [340, 1, "\u0155"], [341, 2], [342, 1, "\u0157"], [343, 2], [344, 1, "\u0159"], [345, 2], [346, 1, "\u015B"], [347, 2], [348, 1, "\u015D"], [349, 2], [350, 1, "\u015F"], [351, 2], [352, 1, "\u0161"], [353, 2], [354, 1, "\u0163"], [355, 2], [356, 1, "\u0165"], [357, 2], [358, 1, "\u0167"], [359, 2], [360, 1, "\u0169"], [361, 2], [362, 1, "\u016B"], [363, 2], [364, 1, "\u016D"], [365, 2], [366, 1, "\u016F"], [367, 2], [368, 1, "\u0171"], [369, 2], [370, 1, "\u0173"], [371, 2], [372, 1, "\u0175"], [373, 2], [374, 1, "\u0177"], [375, 2], [376, 1, "\xFF"], [377, 1, "\u017A"], [378, 2], [379, 1, "\u017C"], [380, 2], [381, 1, "\u017E"], [382, 2], [383, 1, "s"], [384, 2], [385, 1, "\u0253"], [386, 1, "\u0183"], [387, 2], [388, 1, "\u0185"], [389, 2], [390, 1, "\u0254"], [391, 1, "\u0188"], [392, 2], [393, 1, "\u0256"], [394, 1, "\u0257"], [395, 1, "\u018C"], [[396, 397], 2], [398, 1, "\u01DD"], [399, 1, "\u0259"], [400, 1, "\u025B"], [401, 1, "\u0192"], [402, 2], [403, 1, "\u0260"], [404, 1, "\u0263"], [405, 2], [406, 1, "\u0269"], [407, 1, "\u0268"], [408, 1, "\u0199"], [[409, 411], 2], [412, 1, "\u026F"], [413, 1, "\u0272"], [414, 2], [415, 1, "\u0275"], [416, 1, "\u01A1"], [417, 2], [418, 1, "\u01A3"], [419, 2], [420, 1, "\u01A5"], [421, 2], [422, 1, "\u0280"], [423, 1, "\u01A8"], [424, 2], [425, 1, "\u0283"], [[426, 427], 2], [428, 1, "\u01AD"], [429, 2], [430, 1, "\u0288"], [431, 1, "\u01B0"], [432, 2], [433, 1, "\u028A"], [434, 1, "\u028B"], [435, 1, "\u01B4"], [436, 2], [437, 1, "\u01B6"], [438, 2], [439, 1, "\u0292"], [440, 1, "\u01B9"], [[441, 443], 2], [444, 1, "\u01BD"], [[445, 451], 2], [[452, 454], 1, "d\u017E"], [[455, 457], 1, "lj"], [[458, 460], 1, "nj"], [461, 1, "\u01CE"], [462, 2], [463, 1, "\u01D0"], [464, 2], [465, 1, "\u01D2"], [466, 2], [467, 1, "\u01D4"], [468, 2], [469, 1, "\u01D6"], [470, 2], [471, 1, "\u01D8"], [472, 2], [473, 1, "\u01DA"], [474, 2], [475, 1, "\u01DC"], [[476, 477], 2], [478, 1, "\u01DF"], [479, 2], [480, 1, "\u01E1"], [481, 2], [482, 1, "\u01E3"], [483, 2], [484, 1, "\u01E5"], [485, 2], [486, 1, "\u01E7"], [487, 2], [488, 1, "\u01E9"], [489, 2], [490, 1, "\u01EB"], [491, 2], [492, 1, "\u01ED"], [493, 2], [494, 1, "\u01EF"], [[495, 496], 2], [[497, 499], 1, "dz"], [500, 1, "\u01F5"], [501, 2], [502, 1, "\u0195"], [503, 1, "\u01BF"], [504, 1, "\u01F9"], [505, 2], [506, 1, "\u01FB"], [507, 2], [508, 1, "\u01FD"], [509, 2], [510, 1, "\u01FF"], [511, 2], [512, 1, "\u0201"], [513, 2], [514, 1, "\u0203"], [515, 2], [516, 1, "\u0205"], [517, 2], [518, 1, "\u0207"], [519, 2], [520, 1, "\u0209"], [521, 2], [522, 1, "\u020B"], [523, 2], [524, 1, "\u020D"], [525, 2], [526, 1, "\u020F"], [527, 2], [528, 1, "\u0211"], [529, 2], [530, 1, "\u0213"], [531, 2], [532, 1, "\u0215"], [533, 2], [534, 1, "\u0217"], [535, 2], [536, 1, "\u0219"], [537, 2], [538, 1, "\u021B"], [539, 2], [540, 1, "\u021D"], [541, 2], [542, 1, "\u021F"], [543, 2], [544, 1, "\u019E"], [545, 2], [546, 1, "\u0223"], [547, 2], [548, 1, "\u0225"], [549, 2], [550, 1, "\u0227"], [551, 2], [552, 1, "\u0229"], [553, 2], [554, 1, "\u022B"], [555, 2], [556, 1, "\u022D"], [557, 2], [558, 1, "\u022F"], [559, 2], [560, 1, "\u0231"], [561, 2], [562, 1, "\u0233"], [563, 2], [[564, 566], 2], [[567, 569], 2], [570, 1, "\u2C65"], [571, 1, "\u023C"], [572, 2], [573, 1, "\u019A"], [574, 1, "\u2C66"], [[575, 576], 2], [577, 1, "\u0242"], [578, 2], [579, 1, "\u0180"], [580, 1, "\u0289"], [581, 1, "\u028C"], [582, 1, "\u0247"], [583, 2], [584, 1, "\u0249"], [585, 2], [586, 1, "\u024B"], [587, 2], [588, 1, "\u024D"], [589, 2], [590, 1, "\u024F"], [591, 2], [[592, 680], 2], [[681, 685], 2], [[686, 687], 2], [688, 1, "h"], [689, 1, "\u0266"], [690, 1, "j"], [691, 1, "r"], [692, 1, "\u0279"], [693, 1, "\u027B"], [694, 1, "\u0281"], [695, 1, "w"], [696, 1, "y"], [[697, 705], 2], [[706, 709], 2], [[710, 721], 2], [[722, 727], 2], [728, 5, " \u0306"], [729, 5, " \u0307"], [730, 5, " \u030A"], [731, 5, " \u0328"], [732, 5, " \u0303"], [733, 5, " \u030B"], [734, 2], [735, 2], [736, 1, "\u0263"], [737, 1, "l"], [738, 1, "s"], [739, 1, "x"], [740, 1, "\u0295"], [[741, 745], 2], [[746, 747], 2], [748, 2], [749, 2], [750, 2], [[751, 767], 2], [[768, 831], 2], [832, 1, "\u0300"], [833, 1, "\u0301"], [834, 2], [835, 1, "\u0313"], [836, 1, "\u0308\u0301"], [837, 1, "\u03B9"], [[838, 846], 2], [847, 7], [[848, 855], 2], [[856, 860], 2], [[861, 863], 2], [[864, 865], 2], [866, 2], [[867, 879], 2], [880, 1, "\u0371"], [881, 2], [882, 1, "\u0373"], [883, 2], [884, 1, "\u02B9"], [885, 2], [886, 1, "\u0377"], [887, 2], [[888, 889], 3], [890, 5, " \u03B9"], [[891, 893], 2], [894, 5, ";"], [895, 1, "\u03F3"], [[896, 899], 3], [900, 5, " \u0301"], [901, 5, " \u0308\u0301"], [902, 1, "\u03AC"], [903, 1, "\xB7"], [904, 1, "\u03AD"], [905, 1, "\u03AE"], [906, 1, "\u03AF"], [907, 3], [908, 1, "\u03CC"], [909, 3], [910, 1, "\u03CD"], [911, 1, "\u03CE"], [912, 2], [913, 1, "\u03B1"], [914, 1, "\u03B2"], [915, 1, "\u03B3"], [916, 1, "\u03B4"], [917, 1, "\u03B5"], [918, 1, "\u03B6"], [919, 1, "\u03B7"], [920, 1, "\u03B8"], [921, 1, "\u03B9"], [922, 1, "\u03BA"], [923, 1, "\u03BB"], [924, 1, "\u03BC"], [925, 1, "\u03BD"], [926, 1, "\u03BE"], [927, 1, "\u03BF"], [928, 1, "\u03C0"], [929, 1, "\u03C1"], [930, 3], [931, 1, "\u03C3"], [932, 1, "\u03C4"], [933, 1, "\u03C5"], [934, 1, "\u03C6"], [935, 1, "\u03C7"], [936, 1, "\u03C8"], [937, 1, "\u03C9"], [938, 1, "\u03CA"], [939, 1, "\u03CB"], [[940, 961], 2], [962, 6, "\u03C3"], [[963, 974], 2], [975, 1, "\u03D7"], [976, 1, "\u03B2"], [977, 1, "\u03B8"], [978, 1, "\u03C5"], [979, 1, "\u03CD"], [980, 1, "\u03CB"], [981, 1, "\u03C6"], [982, 1, "\u03C0"], [983, 2], [984, 1, "\u03D9"], [985, 2], [986, 1, "\u03DB"], [987, 2], [988, 1, "\u03DD"], [989, 2], [990, 1, "\u03DF"], [991, 2], [992, 1, "\u03E1"], [993, 2], [994, 1, "\u03E3"], [995, 2], [996, 1, "\u03E5"], [997, 2], [998, 1, "\u03E7"], [999, 2], [1e3, 1, "\u03E9"], [1001, 2], [1002, 1, "\u03EB"], [1003, 2], [1004, 1, "\u03ED"], [1005, 2], [1006, 1, "\u03EF"], [1007, 2], [1008, 1, "\u03BA"], [1009, 1, "\u03C1"], [1010, 1, "\u03C3"], [1011, 2], [1012, 1, "\u03B8"], [1013, 1, "\u03B5"], [1014, 2], [1015, 1, "\u03F8"], [1016, 2], [1017, 1, "\u03C3"], [1018, 1, "\u03FB"], [1019, 2], [1020, 2], [1021, 1, "\u037B"], [1022, 1, "\u037C"], [1023, 1, "\u037D"], [1024, 1, "\u0450"], [1025, 1, "\u0451"], [1026, 1, "\u0452"], [1027, 1, "\u0453"], [1028, 1, "\u0454"], [1029, 1, "\u0455"], [1030, 1, "\u0456"], [1031, 1, "\u0457"], [1032, 1, "\u0458"], [1033, 1, "\u0459"], [1034, 1, "\u045A"], [1035, 1, "\u045B"], [1036, 1, "\u045C"], [1037, 1, "\u045D"], [1038, 1, "\u045E"], [1039, 1, "\u045F"], [1040, 1, "\u0430"], [1041, 1, "\u0431"], [1042, 1, "\u0432"], [1043, 1, "\u0433"], [1044, 1, "\u0434"], [1045, 1, "\u0435"], [1046, 1, "\u0436"], [1047, 1, "\u0437"], [1048, 1, "\u0438"], [1049, 1, "\u0439"], [1050, 1, "\u043A"], [1051, 1, "\u043B"], [1052, 1, "\u043C"], [1053, 1, "\u043D"], [1054, 1, "\u043E"], [1055, 1, "\u043F"], [1056, 1, "\u0440"], [1057, 1, "\u0441"], [1058, 1, "\u0442"], [1059, 1, "\u0443"], [1060, 1, "\u0444"], [1061, 1, "\u0445"], [1062, 1, "\u0446"], [1063, 1, "\u0447"], [1064, 1, "\u0448"], [1065, 1, "\u0449"], [1066, 1, "\u044A"], [1067, 1, "\u044B"], [1068, 1, "\u044C"], [1069, 1, "\u044D"], [1070, 1, "\u044E"], [1071, 1, "\u044F"], [[1072, 1103], 2], [1104, 2], [[1105, 1116], 2], [1117, 2], [[1118, 1119], 2], [1120, 1, "\u0461"], [1121, 2], [1122, 1, "\u0463"], [1123, 2], [1124, 1, "\u0465"], [1125, 2], [1126, 1, "\u0467"], [1127, 2], [1128, 1, "\u0469"], [1129, 2], [1130, 1, "\u046B"], [1131, 2], [1132, 1, "\u046D"], [1133, 2], [1134, 1, "\u046F"], [1135, 2], [1136, 1, "\u0471"], [1137, 2], [1138, 1, "\u0473"], [1139, 2], [1140, 1, "\u0475"], [1141, 2], [1142, 1, "\u0477"], [1143, 2], [1144, 1, "\u0479"], [1145, 2], [1146, 1, "\u047B"], [1147, 2], [1148, 1, "\u047D"], [1149, 2], [1150, 1, "\u047F"], [1151, 2], [1152, 1, "\u0481"], [1153, 2], [1154, 2], [[1155, 1158], 2], [1159, 2], [[1160, 1161], 2], [1162, 1, "\u048B"], [1163, 2], [1164, 1, "\u048D"], [1165, 2], [1166, 1, "\u048F"], [1167, 2], [1168, 1, "\u0491"], [1169, 2], [1170, 1, "\u0493"], [1171, 2], [1172, 1, "\u0495"], [1173, 2], [1174, 1, "\u0497"], [1175, 2], [1176, 1, "\u0499"], [1177, 2], [1178, 1, "\u049B"], [1179, 2], [1180, 1, "\u049D"], [1181, 2], [1182, 1, "\u049F"], [1183, 2], [1184, 1, "\u04A1"], [1185, 2], [1186, 1, "\u04A3"], [1187, 2], [1188, 1, "\u04A5"], [1189, 2], [1190, 1, "\u04A7"], [1191, 2], [1192, 1, "\u04A9"], [1193, 2], [1194, 1, "\u04AB"], [1195, 2], [1196, 1, "\u04AD"], [1197, 2], [1198, 1, "\u04AF"], [1199, 2], [1200, 1, "\u04B1"], [1201, 2], [1202, 1, "\u04B3"], [1203, 2], [1204, 1, "\u04B5"], [1205, 2], [1206, 1, "\u04B7"], [1207, 2], [1208, 1, "\u04B9"], [1209, 2], [1210, 1, "\u04BB"], [1211, 2], [1212, 1, "\u04BD"], [1213, 2], [1214, 1, "\u04BF"], [1215, 2], [1216, 3], [1217, 1, "\u04C2"], [1218, 2], [1219, 1, "\u04C4"], [1220, 2], [1221, 1, "\u04C6"], [1222, 2], [1223, 1, "\u04C8"], [1224, 2], [1225, 1, "\u04CA"], [1226, 2], [1227, 1, "\u04CC"], [1228, 2], [1229, 1, "\u04CE"], [1230, 2], [1231, 2], [1232, 1, "\u04D1"], [1233, 2], [1234, 1, "\u04D3"], [1235, 2], [1236, 1, "\u04D5"], [1237, 2], [1238, 1, "\u04D7"], [1239, 2], [1240, 1, "\u04D9"], [1241, 2], [1242, 1, "\u04DB"], [1243, 2], [1244, 1, "\u04DD"], [1245, 2], [1246, 1, "\u04DF"], [1247, 2], [1248, 1, "\u04E1"], [1249, 2], [1250, 1, "\u04E3"], [1251, 2], [1252, 1, "\u04E5"], [1253, 2], [1254, 1, "\u04E7"], [1255, 2], [1256, 1, "\u04E9"], [1257, 2], [1258, 1, "\u04EB"], [1259, 2], [1260, 1, "\u04ED"], [1261, 2], [1262, 1, "\u04EF"], [1263, 2], [1264, 1, "\u04F1"], [1265, 2], [1266, 1, "\u04F3"], [1267, 2], [1268, 1, "\u04F5"], [1269, 2], [1270, 1, "\u04F7"], [1271, 2], [1272, 1, "\u04F9"], [1273, 2], [1274, 1, "\u04FB"], [1275, 2], [1276, 1, "\u04FD"], [1277, 2], [1278, 1, "\u04FF"], [1279, 2], [1280, 1, "\u0501"], [1281, 2], [1282, 1, "\u0503"], [1283, 2], [1284, 1, "\u0505"], [1285, 2], [1286, 1, "\u0507"], [1287, 2], [1288, 1, "\u0509"], [1289, 2], [1290, 1, "\u050B"], [1291, 2], [1292, 1, "\u050D"], [1293, 2], [1294, 1, "\u050F"], [1295, 2], [1296, 1, "\u0511"], [1297, 2], [1298, 1, "\u0513"], [1299, 2], [1300, 1, "\u0515"], [1301, 2], [1302, 1, "\u0517"], [1303, 2], [1304, 1, "\u0519"], [1305, 2], [1306, 1, "\u051B"], [1307, 2], [1308, 1, "\u051D"], [1309, 2], [1310, 1, "\u051F"], [1311, 2], [1312, 1, "\u0521"], [1313, 2], [1314, 1, "\u0523"], [1315, 2], [1316, 1, "\u0525"], [1317, 2], [1318, 1, "\u0527"], [1319, 2], [1320, 1, "\u0529"], [1321, 2], [1322, 1, "\u052B"], [1323, 2], [1324, 1, "\u052D"], [1325, 2], [1326, 1, "\u052F"], [1327, 2], [1328, 3], [1329, 1, "\u0561"], [1330, 1, "\u0562"], [1331, 1, "\u0563"], [1332, 1, "\u0564"], [1333, 1, "\u0565"], [1334, 1, "\u0566"], [1335, 1, "\u0567"], [1336, 1, "\u0568"], [1337, 1, "\u0569"], [1338, 1, "\u056A"], [1339, 1, "\u056B"], [1340, 1, "\u056C"], [1341, 1, "\u056D"], [1342, 1, "\u056E"], [1343, 1, "\u056F"], [1344, 1, "\u0570"], [1345, 1, "\u0571"], [1346, 1, "\u0572"], [1347, 1, "\u0573"], [1348, 1, "\u0574"], [1349, 1, "\u0575"], [1350, 1, "\u0576"], [1351, 1, "\u0577"], [1352, 1, "\u0578"], [1353, 1, "\u0579"], [1354, 1, "\u057A"], [1355, 1, "\u057B"], [1356, 1, "\u057C"], [1357, 1, "\u057D"], [1358, 1, "\u057E"], [1359, 1, "\u057F"], [1360, 1, "\u0580"], [1361, 1, "\u0581"], [1362, 1, "\u0582"], [1363, 1, "\u0583"], [1364, 1, "\u0584"], [1365, 1, "\u0585"], [1366, 1, "\u0586"], [[1367, 1368], 3], [1369, 2], [[1370, 1375], 2], [1376, 2], [[1377, 1414], 2], [1415, 1, "\u0565\u0582"], [1416, 2], [1417, 2], [1418, 2], [[1419, 1420], 3], [[1421, 1422], 2], [1423, 2], [1424, 3], [[1425, 1441], 2], [1442, 2], [[1443, 1455], 2], [[1456, 1465], 2], [1466, 2], [[1467, 1469], 2], [1470, 2], [1471, 2], [1472, 2], [[1473, 1474], 2], [1475, 2], [1476, 2], [1477, 2], [1478, 2], [1479, 2], [[1480, 1487], 3], [[1488, 1514], 2], [[1515, 1518], 3], [1519, 2], [[1520, 1524], 2], [[1525, 1535], 3], [[1536, 1539], 3], [1540, 3], [1541, 3], [[1542, 1546], 2], [1547, 2], [1548, 2], [[1549, 1551], 2], [[1552, 1557], 2], [[1558, 1562], 2], [1563, 2], [1564, 3], [1565, 2], [1566, 2], [1567, 2], [1568, 2], [[1569, 1594], 2], [[1595, 1599], 2], [1600, 2], [[1601, 1618], 2], [[1619, 1621], 2], [[1622, 1624], 2], [[1625, 1630], 2], [1631, 2], [[1632, 1641], 2], [[1642, 1645], 2], [[1646, 1647], 2], [[1648, 1652], 2], [1653, 1, "\u0627\u0674"], [1654, 1, "\u0648\u0674"], [1655, 1, "\u06C7\u0674"], [1656, 1, "\u064A\u0674"], [[1657, 1719], 2], [[1720, 1721], 2], [[1722, 1726], 2], [1727, 2], [[1728, 1742], 2], [1743, 2], [[1744, 1747], 2], [1748, 2], [[1749, 1756], 2], [1757, 3], [1758, 2], [[1759, 1768], 2], [1769, 2], [[1770, 1773], 2], [[1774, 1775], 2], [[1776, 1785], 2], [[1786, 1790], 2], [1791, 2], [[1792, 1805], 2], [1806, 3], [1807, 3], [[1808, 1836], 2], [[1837, 1839], 2], [[1840, 1866], 2], [[1867, 1868], 3], [[1869, 1871], 2], [[1872, 1901], 2], [[1902, 1919], 2], [[1920, 1968], 2], [1969, 2], [[1970, 1983], 3], [[1984, 2037], 2], [[2038, 2042], 2], [[2043, 2044], 3], [2045, 2], [[2046, 2047], 2], [[2048, 2093], 2], [[2094, 2095], 3], [[2096, 2110], 2], [2111, 3], [[2112, 2139], 2], [[2140, 2141], 3], [2142, 2], [2143, 3], [[2144, 2154], 2], [[2155, 2159], 3], [[2160, 2183], 2], [2184, 2], [[2185, 2190], 2], [2191, 3], [[2192, 2193], 3], [[2194, 2199], 3], [[2200, 2207], 2], [2208, 2], [2209, 2], [[2210, 2220], 2], [[2221, 2226], 2], [[2227, 2228], 2], [2229, 2], [[2230, 2237], 2], [[2238, 2247], 2], [[2248, 2258], 2], [2259, 2], [[2260, 2273], 2], [2274, 3], [2275, 2], [[2276, 2302], 2], [2303, 2], [2304, 2], [[2305, 2307], 2], [2308, 2], [[2309, 2361], 2], [[2362, 2363], 2], [[2364, 2381], 2], [2382, 2], [2383, 2], [[2384, 2388], 2], [2389, 2], [[2390, 2391], 2], [2392, 1, "\u0915\u093C"], [2393, 1, "\u0916\u093C"], [2394, 1, "\u0917\u093C"], [2395, 1, "\u091C\u093C"], [2396, 1, "\u0921\u093C"], [2397, 1, "\u0922\u093C"], [2398, 1, "\u092B\u093C"], [2399, 1, "\u092F\u093C"], [[2400, 2403], 2], [[2404, 2405], 2], [[2406, 2415], 2], [2416, 2], [[2417, 2418], 2], [[2419, 2423], 2], [2424, 2], [[2425, 2426], 2], [[2427, 2428], 2], [2429, 2], [[2430, 2431], 2], [2432, 2], [[2433, 2435], 2], [2436, 3], [[2437, 2444], 2], [[2445, 2446], 3], [[2447, 2448], 2], [[2449, 2450], 3], [[2451, 2472], 2], [2473, 3], [[2474, 2480], 2], [2481, 3], [2482, 2], [[2483, 2485], 3], [[2486, 2489], 2], [[2490, 2491], 3], [2492, 2], [2493, 2], [[2494, 2500], 2], [[2501, 2502], 3], [[2503, 2504], 2], [[2505, 2506], 3], [[2507, 2509], 2], [2510, 2], [[2511, 2518], 3], [2519, 2], [[2520, 2523], 3], [2524, 1, "\u09A1\u09BC"], [2525, 1, "\u09A2\u09BC"], [2526, 3], [2527, 1, "\u09AF\u09BC"], [[2528, 2531], 2], [[2532, 2533], 3], [[2534, 2545], 2], [[2546, 2554], 2], [2555, 2], [2556, 2], [2557, 2], [2558, 2], [[2559, 2560], 3], [2561, 2], [2562, 2], [2563, 2], [2564, 3], [[2565, 2570], 2], [[2571, 2574], 3], [[2575, 2576], 2], [[2577, 2578], 3], [[2579, 2600], 2], [2601, 3], [[2602, 2608], 2], [2609, 3], [2610, 2], [2611, 1, "\u0A32\u0A3C"], [2612, 3], [2613, 2], [2614, 1, "\u0A38\u0A3C"], [2615, 3], [[2616, 2617], 2], [[2618, 2619], 3], [2620, 2], [2621, 3], [[2622, 2626], 2], [[2627, 2630], 3], [[2631, 2632], 2], [[2633, 2634], 3], [[2635, 2637], 2], [[2638, 2640], 3], [2641, 2], [[2642, 2648], 3], [2649, 1, "\u0A16\u0A3C"], [2650, 1, "\u0A17\u0A3C"], [2651, 1, "\u0A1C\u0A3C"], [2652, 2], [2653, 3], [2654, 1, "\u0A2B\u0A3C"], [[2655, 2661], 3], [[2662, 2676], 2], [2677, 2], [2678, 2], [[2679, 2688], 3], [[2689, 2691], 2], [2692, 3], [[2693, 2699], 2], [2700, 2], [2701, 2], [2702, 3], [[2703, 2705], 2], [2706, 3], [[2707, 2728], 2], [2729, 3], [[2730, 2736], 2], [2737, 3], [[2738, 2739], 2], [2740, 3], [[2741, 2745], 2], [[2746, 2747], 3], [[2748, 2757], 2], [2758, 3], [[2759, 2761], 2], [2762, 3], [[2763, 2765], 2], [[2766, 2767], 3], [2768, 2], [[2769, 2783], 3], [2784, 2], [[2785, 2787], 2], [[2788, 2789], 3], [[2790, 2799], 2], [2800, 2], [2801, 2], [[2802, 2808], 3], [2809, 2], [[2810, 2815], 2], [2816, 3], [[2817, 2819], 2], [2820, 3], [[2821, 2828], 2], [[2829, 2830], 3], [[2831, 2832], 2], [[2833, 2834], 3], [[2835, 2856], 2], [2857, 3], [[2858, 2864], 2], [2865, 3], [[2866, 2867], 2], [2868, 3], [2869, 2], [[2870, 2873], 2], [[2874, 2875], 3], [[2876, 2883], 2], [2884, 2], [[2885, 2886], 3], [[2887, 2888], 2], [[2889, 2890], 3], [[2891, 2893], 2], [[2894, 2900], 3], [2901, 2], [[2902, 2903], 2], [[2904, 2907], 3], [2908, 1, "\u0B21\u0B3C"], [2909, 1, "\u0B22\u0B3C"], [2910, 3], [[2911, 2913], 2], [[2914, 2915], 2], [[2916, 2917], 3], [[2918, 2927], 2], [2928, 2], [2929, 2], [[2930, 2935], 2], [[2936, 2945], 3], [[2946, 2947], 2], [2948, 3], [[2949, 2954], 2], [[2955, 2957], 3], [[2958, 2960], 2], [2961, 3], [[2962, 2965], 2], [[2966, 2968], 3], [[2969, 2970], 2], [2971, 3], [2972, 2], [2973, 3], [[2974, 2975], 2], [[2976, 2978], 3], [[2979, 2980], 2], [[2981, 2983], 3], [[2984, 2986], 2], [[2987, 2989], 3], [[2990, 2997], 2], [2998, 2], [[2999, 3001], 2], [[3002, 3005], 3], [[3006, 3010], 2], [[3011, 3013], 3], [[3014, 3016], 2], [3017, 3], [[3018, 3021], 2], [[3022, 3023], 3], [3024, 2], [[3025, 3030], 3], [3031, 2], [[3032, 3045], 3], [3046, 2], [[3047, 3055], 2], [[3056, 3058], 2], [[3059, 3066], 2], [[3067, 3071], 3], [3072, 2], [[3073, 3075], 2], [3076, 2], [[3077, 3084], 2], [3085, 3], [[3086, 3088], 2], [3089, 3], [[3090, 3112], 2], [3113, 3], [[3114, 3123], 2], [3124, 2], [[3125, 3129], 2], [[3130, 3131], 3], [3132, 2], [3133, 2], [[3134, 3140], 2], [3141, 3], [[3142, 3144], 2], [3145, 3], [[3146, 3149], 2], [[3150, 3156], 3], [[3157, 3158], 2], [3159, 3], [[3160, 3161], 2], [3162, 2], [[3163, 3164], 3], [3165, 2], [[3166, 3167], 3], [[3168, 3169], 2], [[3170, 3171], 2], [[3172, 3173], 3], [[3174, 3183], 2], [[3184, 3190], 3], [3191, 2], [[3192, 3199], 2], [3200, 2], [3201, 2], [[3202, 3203], 2], [3204, 2], [[3205, 3212], 2], [3213, 3], [[3214, 3216], 2], [3217, 3], [[3218, 3240], 2], [3241, 3], [[3242, 3251], 2], [3252, 3], [[3253, 3257], 2], [[3258, 3259], 3], [[3260, 3261], 2], [[3262, 3268], 2], [3269, 3], [[3270, 3272], 2], [3273, 3], [[3274, 3277], 2], [[3278, 3284], 3], [[3285, 3286], 2], [[3287, 3292], 3], [3293, 2], [3294, 2], [3295, 3], [[3296, 3297], 2], [[3298, 3299], 2], [[3300, 3301], 3], [[3302, 3311], 2], [3312, 3], [[3313, 3314], 2], [[3315, 3327], 3], [3328, 2], [3329, 2], [[3330, 3331], 2], [3332, 2], [[3333, 3340], 2], [3341, 3], [[3342, 3344], 2], [3345, 3], [[3346, 3368], 2], [3369, 2], [[3370, 3385], 2], [3386, 2], [[3387, 3388], 2], [3389, 2], [[3390, 3395], 2], [3396, 2], [3397, 3], [[3398, 3400], 2], [3401, 3], [[3402, 3405], 2], [3406, 2], [3407, 2], [[3408, 3411], 3], [[3412, 3414], 2], [3415, 2], [[3416, 3422], 2], [3423, 2], [[3424, 3425], 2], [[3426, 3427], 2], [[3428, 3429], 3], [[3430, 3439], 2], [[3440, 3445], 2], [[3446, 3448], 2], [3449, 2], [[3450, 3455], 2], [3456, 3], [3457, 2], [[3458, 3459], 2], [3460, 3], [[3461, 3478], 2], [[3479, 3481], 3], [[3482, 3505], 2], [3506, 3], [[3507, 3515], 2], [3516, 3], [3517, 2], [[3518, 3519], 3], [[3520, 3526], 2], [[3527, 3529], 3], [3530, 2], [[3531, 3534], 3], [[3535, 3540], 2], [3541, 3], [3542, 2], [3543, 3], [[3544, 3551], 2], [[3552, 3557], 3], [[3558, 3567], 2], [[3568, 3569], 3], [[3570, 3571], 2], [3572, 2], [[3573, 3584], 3], [[3585, 3634], 2], [3635, 1, "\u0E4D\u0E32"], [[3636, 3642], 2], [[3643, 3646], 3], [3647, 2], [[3648, 3662], 2], [3663, 2], [[3664, 3673], 2], [[3674, 3675], 2], [[3676, 3712], 3], [[3713, 3714], 2], [3715, 3], [3716, 2], [3717, 3], [3718, 2], [[3719, 3720], 2], [3721, 2], [3722, 2], [3723, 3], [3724, 2], [3725, 2], [[3726, 3731], 2], [[3732, 3735], 2], [3736, 2], [[3737, 3743], 2], [3744, 2], [[3745, 3747], 2], [3748, 3], [3749, 2], [3750, 3], [3751, 2], [[3752, 3753], 2], [[3754, 3755], 2], [3756, 2], [[3757, 3762], 2], [3763, 1, "\u0ECD\u0EB2"], [[3764, 3769], 2], [3770, 2], [[3771, 3773], 2], [[3774, 3775], 3], [[3776, 3780], 2], [3781, 3], [3782, 2], [3783, 3], [[3784, 3789], 2], [[3790, 3791], 3], [[3792, 3801], 2], [[3802, 3803], 3], [3804, 1, "\u0EAB\u0E99"], [3805, 1, "\u0EAB\u0EA1"], [[3806, 3807], 2], [[3808, 3839], 3], [3840, 2], [[3841, 3850], 2], [3851, 2], [3852, 1, "\u0F0B"], [[3853, 3863], 2], [[3864, 3865], 2], [[3866, 3871], 2], [[3872, 3881], 2], [[3882, 3892], 2], [3893, 2], [3894, 2], [3895, 2], [3896, 2], [3897, 2], [[3898, 3901], 2], [[3902, 3906], 2], [3907, 1, "\u0F42\u0FB7"], [[3908, 3911], 2], [3912, 3], [[3913, 3916], 2], [3917, 1, "\u0F4C\u0FB7"], [[3918, 3921], 2], [3922, 1, "\u0F51\u0FB7"], [[3923, 3926], 2], [3927, 1, "\u0F56\u0FB7"], [[3928, 3931], 2], [3932, 1, "\u0F5B\u0FB7"], [[3933, 3944], 2], [3945, 1, "\u0F40\u0FB5"], [3946, 2], [[3947, 3948], 2], [[3949, 3952], 3], [[3953, 3954], 2], [3955, 1, "\u0F71\u0F72"], [3956, 2], [3957, 1, "\u0F71\u0F74"], [3958, 1, "\u0FB2\u0F80"], [3959, 1, "\u0FB2\u0F71\u0F80"], [3960, 1, "\u0FB3\u0F80"], [3961, 1, "\u0FB3\u0F71\u0F80"], [[3962, 3968], 2], [3969, 1, "\u0F71\u0F80"], [[3970, 3972], 2], [3973, 2], [[3974, 3979], 2], [[3980, 3983], 2], [[3984, 3986], 2], [3987, 1, "\u0F92\u0FB7"], [[3988, 3989], 2], [3990, 2], [3991, 2], [3992, 3], [[3993, 3996], 2], [3997, 1, "\u0F9C\u0FB7"], [[3998, 4001], 2], [4002, 1, "\u0FA1\u0FB7"], [[4003, 4006], 2], [4007, 1, "\u0FA6\u0FB7"], [[4008, 4011], 2], [4012, 1, "\u0FAB\u0FB7"], [4013, 2], [[4014, 4016], 2], [[4017, 4023], 2], [4024, 2], [4025, 1, "\u0F90\u0FB5"], [[4026, 4028], 2], [4029, 3], [[4030, 4037], 2], [4038, 2], [[4039, 4044], 2], [4045, 3], [4046, 2], [4047, 2], [[4048, 4049], 2], [[4050, 4052], 2], [[4053, 4056], 2], [[4057, 4058], 2], [[4059, 4095], 3], [[4096, 4129], 2], [4130, 2], [[4131, 4135], 2], [4136, 2], [[4137, 4138], 2], [4139, 2], [[4140, 4146], 2], [[4147, 4149], 2], [[4150, 4153], 2], [[4154, 4159], 2], [[4160, 4169], 2], [[4170, 4175], 2], [[4176, 4185], 2], [[4186, 4249], 2], [[4250, 4253], 2], [[4254, 4255], 2], [[4256, 4293], 3], [4294, 3], [4295, 1, "\u2D27"], [[4296, 4300], 3], [4301, 1, "\u2D2D"], [[4302, 4303], 3], [[4304, 4342], 2], [[4343, 4344], 2], [[4345, 4346], 2], [4347, 2], [4348, 1, "\u10DC"], [[4349, 4351], 2], [[4352, 4441], 2], [[4442, 4446], 2], [[4447, 4448], 3], [[4449, 4514], 2], [[4515, 4519], 2], [[4520, 4601], 2], [[4602, 4607], 2], [[4608, 4614], 2], [4615, 2], [[4616, 4678], 2], [4679, 2], [4680, 2], [4681, 3], [[4682, 4685], 2], [[4686, 4687], 3], [[4688, 4694], 2], [4695, 3], [4696, 2], [4697, 3], [[4698, 4701], 2], [[4702, 4703], 3], [[4704, 4742], 2], [4743, 2], [4744, 2], [4745, 3], [[4746, 4749], 2], [[4750, 4751], 3], [[4752, 4782], 2], [4783, 2], [4784, 2], [4785, 3], [[4786, 4789], 2], [[4790, 4791], 3], [[4792, 4798], 2], [4799, 3], [4800, 2], [4801, 3], [[4802, 4805], 2], [[4806, 4807], 3], [[4808, 4814], 2], [4815, 2], [[4816, 4822], 2], [4823, 3], [[4824, 4846], 2], [4847, 2], [[4848, 4878], 2], [4879, 2], [4880, 2], [4881, 3], [[4882, 4885], 2], [[4886, 4887], 3], [[4888, 4894], 2], [4895, 2], [[4896, 4934], 2], [4935, 2], [[4936, 4954], 2], [[4955, 4956], 3], [[4957, 4958], 2], [4959, 2], [4960, 2], [[4961, 4988], 2], [[4989, 4991], 3], [[4992, 5007], 2], [[5008, 5017], 2], [[5018, 5023], 3], [[5024, 5108], 2], [5109, 2], [[5110, 5111], 3], [5112, 1, "\u13F0"], [5113, 1, "\u13F1"], [5114, 1, "\u13F2"], [5115, 1, "\u13F3"], [5116, 1, "\u13F4"], [5117, 1, "\u13F5"], [[5118, 5119], 3], [5120, 2], [[5121, 5740], 2], [[5741, 5742], 2], [[5743, 5750], 2], [[5751, 5759], 2], [5760, 3], [[5761, 5786], 2], [[5787, 5788], 2], [[5789, 5791], 3], [[5792, 5866], 2], [[5867, 5872], 2], [[5873, 5880], 2], [[5881, 5887], 3], [[5888, 5900], 2], [5901, 2], [[5902, 5908], 2], [5909, 2], [[5910, 5918], 3], [5919, 2], [[5920, 5940], 2], [[5941, 5942], 2], [[5943, 5951], 3], [[5952, 5971], 2], [[5972, 5983], 3], [[5984, 5996], 2], [5997, 3], [[5998, 6e3], 2], [6001, 3], [[6002, 6003], 2], [[6004, 6015], 3], [[6016, 6067], 2], [[6068, 6069], 3], [[6070, 6099], 2], [[6100, 6102], 2], [6103, 2], [[6104, 6107], 2], [6108, 2], [6109, 2], [[6110, 6111], 3], [[6112, 6121], 2], [[6122, 6127], 3], [[6128, 6137], 2], [[6138, 6143], 3], [[6144, 6149], 2], [6150, 3], [[6151, 6154], 2], [[6155, 6157], 7], [6158, 3], [6159, 7], [[6160, 6169], 2], [[6170, 6175], 3], [[6176, 6263], 2], [6264, 2], [[6265, 6271], 3], [[6272, 6313], 2], [6314, 2], [[6315, 6319], 3], [[6320, 6389], 2], [[6390, 6399], 3], [[6400, 6428], 2], [[6429, 6430], 2], [6431, 3], [[6432, 6443], 2], [[6444, 6447], 3], [[6448, 6459], 2], [[6460, 6463], 3], [6464, 2], [[6465, 6467], 3], [[6468, 6469], 2], [[6470, 6509], 2], [[6510, 6511], 3], [[6512, 6516], 2], [[6517, 6527], 3], [[6528, 6569], 2], [[6570, 6571], 2], [[6572, 6575], 3], [[6576, 6601], 2], [[6602, 6607], 3], [[6608, 6617], 2], [6618, 2], [[6619, 6621], 3], [[6622, 6623], 2], [[6624, 6655], 2], [[6656, 6683], 2], [[6684, 6685], 3], [[6686, 6687], 2], [[6688, 6750], 2], [6751, 3], [[6752, 6780], 2], [[6781, 6782], 3], [[6783, 6793], 2], [[6794, 6799], 3], [[6800, 6809], 2], [[6810, 6815], 3], [[6816, 6822], 2], [6823, 2], [[6824, 6829], 2], [[6830, 6831], 3], [[6832, 6845], 2], [6846, 2], [[6847, 6848], 2], [[6849, 6862], 2], [[6863, 6911], 3], [[6912, 6987], 2], [6988, 2], [[6989, 6991], 3], [[6992, 7001], 2], [[7002, 7018], 2], [[7019, 7027], 2], [[7028, 7036], 2], [[7037, 7038], 2], [7039, 3], [[7040, 7082], 2], [[7083, 7085], 2], [[7086, 7097], 2], [[7098, 7103], 2], [[7104, 7155], 2], [[7156, 7163], 3], [[7164, 7167], 2], [[7168, 7223], 2], [[7224, 7226], 3], [[7227, 7231], 2], [[7232, 7241], 2], [[7242, 7244], 3], [[7245, 7293], 2], [[7294, 7295], 2], [7296, 1, "\u0432"], [7297, 1, "\u0434"], [7298, 1, "\u043E"], [7299, 1, "\u0441"], [[7300, 7301], 1, "\u0442"], [7302, 1, "\u044A"], [7303, 1, "\u0463"], [7304, 1, "\uA64B"], [[7305, 7311], 3], [7312, 1, "\u10D0"], [7313, 1, "\u10D1"], [7314, 1, "\u10D2"], [7315, 1, "\u10D3"], [7316, 1, "\u10D4"], [7317, 1, "\u10D5"], [7318, 1, "\u10D6"], [7319, 1, "\u10D7"], [7320, 1, "\u10D8"], [7321, 1, "\u10D9"], [7322, 1, "\u10DA"], [7323, 1, "\u10DB"], [7324, 1, "\u10DC"], [7325, 1, "\u10DD"], [7326, 1, "\u10DE"], [7327, 1, "\u10DF"], [7328, 1, "\u10E0"], [7329, 1, "\u10E1"], [7330, 1, "\u10E2"], [7331, 1, "\u10E3"], [7332, 1, "\u10E4"], [7333, 1, "\u10E5"], [7334, 1, "\u10E6"], [7335, 1, "\u10E7"], [7336, 1, "\u10E8"], [7337, 1, "\u10E9"], [7338, 1, "\u10EA"], [7339, 1, "\u10EB"], [7340, 1, "\u10EC"], [7341, 1, "\u10ED"], [7342, 1, "\u10EE"], [7343, 1, "\u10EF"], [7344, 1, "\u10F0"], [7345, 1, "\u10F1"], [7346, 1, "\u10F2"], [7347, 1, "\u10F3"], [7348, 1, "\u10F4"], [7349, 1, "\u10F5"], [7350, 1, "\u10F6"], [7351, 1, "\u10F7"], [7352, 1, "\u10F8"], [7353, 1, "\u10F9"], [7354, 1, "\u10FA"], [[7355, 7356], 3], [7357, 1, "\u10FD"], [7358, 1, "\u10FE"], [7359, 1, "\u10FF"], [[7360, 7367], 2], [[7368, 7375], 3], [[7376, 7378], 2], [7379, 2], [[7380, 7410], 2], [[7411, 7414], 2], [7415, 2], [[7416, 7417], 2], [7418, 2], [[7419, 7423], 3], [[7424, 7467], 2], [7468, 1, "a"], [7469, 1, "\xE6"], [7470, 1, "b"], [7471, 2], [7472, 1, "d"], [7473, 1, "e"], [7474, 1, "\u01DD"], [7475, 1, "g"], [7476, 1, "h"], [7477, 1, "i"], [7478, 1, "j"], [7479, 1, "k"], [7480, 1, "l"], [7481, 1, "m"], [7482, 1, "n"], [7483, 2], [7484, 1, "o"], [7485, 1, "\u0223"], [7486, 1, "p"], [7487, 1, "r"], [7488, 1, "t"], [7489, 1, "u"], [7490, 1, "w"], [7491, 1, "a"], [7492, 1, "\u0250"], [7493, 1, "\u0251"], [7494, 1, "\u1D02"], [7495, 1, "b"], [7496, 1, "d"], [7497, 1, "e"], [7498, 1, "\u0259"], [7499, 1, "\u025B"], [7500, 1, "\u025C"], [7501, 1, "g"], [7502, 2], [7503, 1, "k"], [7504, 1, "m"], [7505, 1, "\u014B"], [7506, 1, "o"], [7507, 1, "\u0254"], [7508, 1, "\u1D16"], [7509, 1, "\u1D17"], [7510, 1, "p"], [7511, 1, "t"], [7512, 1, "u"], [7513, 1, "\u1D1D"], [7514, 1, "\u026F"], [7515, 1, "v"], [7516, 1, "\u1D25"], [7517, 1, "\u03B2"], [7518, 1, "\u03B3"], [7519, 1, "\u03B4"], [7520, 1, "\u03C6"], [7521, 1, "\u03C7"], [7522, 1, "i"], [7523, 1, "r"], [7524, 1, "u"], [7525, 1, "v"], [7526, 1, "\u03B2"], [7527, 1, "\u03B3"], [7528, 1, "\u03C1"], [7529, 1, "\u03C6"], [7530, 1, "\u03C7"], [7531, 2], [[7532, 7543], 2], [7544, 1, "\u043D"], [[7545, 7578], 2], [7579, 1, "\u0252"], [7580, 1, "c"], [7581, 1, "\u0255"], [7582, 1, "\xF0"], [7583, 1, "\u025C"], [7584, 1, "f"], [7585, 1, "\u025F"], [7586, 1, "\u0261"], [7587, 1, "\u0265"], [7588, 1, "\u0268"], [7589, 1, "\u0269"], [7590, 1, "\u026A"], [7591, 1, "\u1D7B"], [7592, 1, "\u029D"], [7593, 1, "\u026D"], [7594, 1, "\u1D85"], [7595, 1, "\u029F"], [7596, 1, "\u0271"], [7597, 1, "\u0270"], [7598, 1, "\u0272"], [7599, 1, "\u0273"], [7600, 1, "\u0274"], [7601, 1, "\u0275"], [7602, 1, "\u0278"], [7603, 1, "\u0282"], [7604, 1, "\u0283"], [7605, 1, "\u01AB"], [7606, 1, "\u0289"], [7607, 1, "\u028A"], [7608, 1, "\u1D1C"], [7609, 1, "\u028B"], [7610, 1, "\u028C"], [7611, 1, "z"], [7612, 1, "\u0290"], [7613, 1, "\u0291"], [7614, 1, "\u0292"], [7615, 1, "\u03B8"], [[7616, 7619], 2], [[7620, 7626], 2], [[7627, 7654], 2], [[7655, 7669], 2], [[7670, 7673], 2], [7674, 2], [7675, 2], [7676, 2], [7677, 2], [[7678, 7679], 2], [7680, 1, "\u1E01"], [7681, 2], [7682, 1, "\u1E03"], [7683, 2], [7684, 1, "\u1E05"], [7685, 2], [7686, 1, "\u1E07"], [7687, 2], [7688, 1, "\u1E09"], [7689, 2], [7690, 1, "\u1E0B"], [7691, 2], [7692, 1, "\u1E0D"], [7693, 2], [7694, 1, "\u1E0F"], [7695, 2], [7696, 1, "\u1E11"], [7697, 2], [7698, 1, "\u1E13"], [7699, 2], [7700, 1, "\u1E15"], [7701, 2], [7702, 1, "\u1E17"], [7703, 2], [7704, 1, "\u1E19"], [7705, 2], [7706, 1, "\u1E1B"], [7707, 2], [7708, 1, "\u1E1D"], [7709, 2], [7710, 1, "\u1E1F"], [7711, 2], [7712, 1, "\u1E21"], [7713, 2], [7714, 1, "\u1E23"], [7715, 2], [7716, 1, "\u1E25"], [7717, 2], [7718, 1, "\u1E27"], [7719, 2], [7720, 1, "\u1E29"], [7721, 2], [7722, 1, "\u1E2B"], [7723, 2], [7724, 1, "\u1E2D"], [7725, 2], [7726, 1, "\u1E2F"], [7727, 2], [7728, 1, "\u1E31"], [7729, 2], [7730, 1, "\u1E33"], [7731, 2], [7732, 1, "\u1E35"], [7733, 2], [7734, 1, "\u1E37"], [7735, 2], [7736, 1, "\u1E39"], [7737, 2], [7738, 1, "\u1E3B"], [7739, 2], [7740, 1, "\u1E3D"], [7741, 2], [7742, 1, "\u1E3F"], [7743, 2], [7744, 1, "\u1E41"], [7745, 2], [7746, 1, "\u1E43"], [7747, 2], [7748, 1, "\u1E45"], [7749, 2], [7750, 1, "\u1E47"], [7751, 2], [7752, 1, "\u1E49"], [7753, 2], [7754, 1, "\u1E4B"], [7755, 2], [7756, 1, "\u1E4D"], [7757, 2], [7758, 1, "\u1E4F"], [7759, 2], [7760, 1, "\u1E51"], [7761, 2], [7762, 1, "\u1E53"], [7763, 2], [7764, 1, "\u1E55"], [7765, 2], [7766, 1, "\u1E57"], [7767, 2], [7768, 1, "\u1E59"], [7769, 2], [7770, 1, "\u1E5B"], [7771, 2], [7772, 1, "\u1E5D"], [7773, 2], [7774, 1, "\u1E5F"], [7775, 2], [7776, 1, "\u1E61"], [7777, 2], [7778, 1, "\u1E63"], [7779, 2], [7780, 1, "\u1E65"], [7781, 2], [7782, 1, "\u1E67"], [7783, 2], [7784, 1, "\u1E69"], [7785, 2], [7786, 1, "\u1E6B"], [7787, 2], [7788, 1, "\u1E6D"], [7789, 2], [7790, 1, "\u1E6F"], [7791, 2], [7792, 1, "\u1E71"], [7793, 2], [7794, 1, "\u1E73"], [7795, 2], [7796, 1, "\u1E75"], [7797, 2], [7798, 1, "\u1E77"], [7799, 2], [7800, 1, "\u1E79"], [7801, 2], [7802, 1, "\u1E7B"], [7803, 2], [7804, 1, "\u1E7D"], [7805, 2], [7806, 1, "\u1E7F"], [7807, 2], [7808, 1, "\u1E81"], [7809, 2], [7810, 1, "\u1E83"], [7811, 2], [7812, 1, "\u1E85"], [7813, 2], [7814, 1, "\u1E87"], [7815, 2], [7816, 1, "\u1E89"], [7817, 2], [7818, 1, "\u1E8B"], [7819, 2], [7820, 1, "\u1E8D"], [7821, 2], [7822, 1, "\u1E8F"], [7823, 2], [7824, 1, "\u1E91"], [7825, 2], [7826, 1, "\u1E93"], [7827, 2], [7828, 1, "\u1E95"], [[7829, 7833], 2], [7834, 1, "a\u02BE"], [7835, 1, "\u1E61"], [[7836, 7837], 2], [7838, 1, "ss"], [7839, 2], [7840, 1, "\u1EA1"], [7841, 2], [7842, 1, "\u1EA3"], [7843, 2], [7844, 1, "\u1EA5"], [7845, 2], [7846, 1, "\u1EA7"], [7847, 2], [7848, 1, "\u1EA9"], [7849, 2], [7850, 1, "\u1EAB"], [7851, 2], [7852, 1, "\u1EAD"], [7853, 2], [7854, 1, "\u1EAF"], [7855, 2], [7856, 1, "\u1EB1"], [7857, 2], [7858, 1, "\u1EB3"], [7859, 2], [7860, 1, "\u1EB5"], [7861, 2], [7862, 1, "\u1EB7"], [7863, 2], [7864, 1, "\u1EB9"], [7865, 2], [7866, 1, "\u1EBB"], [7867, 2], [7868, 1, "\u1EBD"], [7869, 2], [7870, 1, "\u1EBF"], [7871, 2], [7872, 1, "\u1EC1"], [7873, 2], [7874, 1, "\u1EC3"], [7875, 2], [7876, 1, "\u1EC5"], [7877, 2], [7878, 1, "\u1EC7"], [7879, 2], [7880, 1, "\u1EC9"], [7881, 2], [7882, 1, "\u1ECB"], [7883, 2], [7884, 1, "\u1ECD"], [7885, 2], [7886, 1, "\u1ECF"], [7887, 2], [7888, 1, "\u1ED1"], [7889, 2], [7890, 1, "\u1ED3"], [7891, 2], [7892, 1, "\u1ED5"], [7893, 2], [7894, 1, "\u1ED7"], [7895, 2], [7896, 1, "\u1ED9"], [7897, 2], [7898, 1, "\u1EDB"], [7899, 2], [7900, 1, "\u1EDD"], [7901, 2], [7902, 1, "\u1EDF"], [7903, 2], [7904, 1, "\u1EE1"], [7905, 2], [7906, 1, "\u1EE3"], [7907, 2], [7908, 1, "\u1EE5"], [7909, 2], [7910, 1, "\u1EE7"], [7911, 2], [7912, 1, "\u1EE9"], [7913, 2], [7914, 1, "\u1EEB"], [7915, 2], [7916, 1, "\u1EED"], [7917, 2], [7918, 1, "\u1EEF"], [7919, 2], [7920, 1, "\u1EF1"], [7921, 2], [7922, 1, "\u1EF3"], [7923, 2], [7924, 1, "\u1EF5"], [7925, 2], [7926, 1, "\u1EF7"], [7927, 2], [7928, 1, "\u1EF9"], [7929, 2], [7930, 1, "\u1EFB"], [7931, 2], [7932, 1, "\u1EFD"], [7933, 2], [7934, 1, "\u1EFF"], [7935, 2], [[7936, 7943], 2], [7944, 1, "\u1F00"], [7945, 1, "\u1F01"], [7946, 1, "\u1F02"], [7947, 1, "\u1F03"], [7948, 1, "\u1F04"], [7949, 1, "\u1F05"], [7950, 1, "\u1F06"], [7951, 1, "\u1F07"], [[7952, 7957], 2], [[7958, 7959], 3], [7960, 1, "\u1F10"], [7961, 1, "\u1F11"], [7962, 1, "\u1F12"], [7963, 1, "\u1F13"], [7964, 1, "\u1F14"], [7965, 1, "\u1F15"], [[7966, 7967], 3], [[7968, 7975], 2], [7976, 1, "\u1F20"], [7977, 1, "\u1F21"], [7978, 1, "\u1F22"], [7979, 1, "\u1F23"], [7980, 1, "\u1F24"], [7981, 1, "\u1F25"], [7982, 1, "\u1F26"], [7983, 1, "\u1F27"], [[7984, 7991], 2], [7992, 1, "\u1F30"], [7993, 1, "\u1F31"], [7994, 1, "\u1F32"], [7995, 1, "\u1F33"], [7996, 1, "\u1F34"], [7997, 1, "\u1F35"], [7998, 1, "\u1F36"], [7999, 1, "\u1F37"], [[8e3, 8005], 2], [[8006, 8007], 3], [8008, 1, "\u1F40"], [8009, 1, "\u1F41"], [8010, 1, "\u1F42"], [8011, 1, "\u1F43"], [8012, 1, "\u1F44"], [8013, 1, "\u1F45"], [[8014, 8015], 3], [[8016, 8023], 2], [8024, 3], [8025, 1, "\u1F51"], [8026, 3], [8027, 1, "\u1F53"], [8028, 3], [8029, 1, "\u1F55"], [8030, 3], [8031, 1, "\u1F57"], [[8032, 8039], 2], [8040, 1, "\u1F60"], [8041, 1, "\u1F61"], [8042, 1, "\u1F62"], [8043, 1, "\u1F63"], [8044, 1, "\u1F64"], [8045, 1, "\u1F65"], [8046, 1, "\u1F66"], [8047, 1, "\u1F67"], [8048, 2], [8049, 1, "\u03AC"], [8050, 2], [8051, 1, "\u03AD"], [8052, 2], [8053, 1, "\u03AE"], [8054, 2], [8055, 1, "\u03AF"], [8056, 2], [8057, 1, "\u03CC"], [8058, 2], [8059, 1, "\u03CD"], [8060, 2], [8061, 1, "\u03CE"], [[8062, 8063], 3], [8064, 1, "\u1F00\u03B9"], [8065, 1, "\u1F01\u03B9"], [8066, 1, "\u1F02\u03B9"], [8067, 1, "\u1F03\u03B9"], [8068, 1, "\u1F04\u03B9"], [8069, 1, "\u1F05\u03B9"], [8070, 1, "\u1F06\u03B9"], [8071, 1, "\u1F07\u03B9"], [8072, 1, "\u1F00\u03B9"], [8073, 1, "\u1F01\u03B9"], [8074, 1, "\u1F02\u03B9"], [8075, 1, "\u1F03\u03B9"], [8076, 1, "\u1F04\u03B9"], [8077, 1, "\u1F05\u03B9"], [8078, 1, "\u1F06\u03B9"], [8079, 1, "\u1F07\u03B9"], [8080, 1, "\u1F20\u03B9"], [8081, 1, "\u1F21\u03B9"], [8082, 1, "\u1F22\u03B9"], [8083, 1, "\u1F23\u03B9"], [8084, 1, "\u1F24\u03B9"], [8085, 1, "\u1F25\u03B9"], [8086, 1, "\u1F26\u03B9"], [8087, 1, "\u1F27\u03B9"], [8088, 1, "\u1F20\u03B9"], [8089, 1, "\u1F21\u03B9"], [8090, 1, "\u1F22\u03B9"], [8091, 1, "\u1F23\u03B9"], [8092, 1, "\u1F24\u03B9"], [8093, 1, "\u1F25\u03B9"], [8094, 1, "\u1F26\u03B9"], [8095, 1, "\u1F27\u03B9"], [8096, 1, "\u1F60\u03B9"], [8097, 1, "\u1F61\u03B9"], [8098, 1, "\u1F62\u03B9"], [8099, 1, "\u1F63\u03B9"], [8100, 1, "\u1F64\u03B9"], [8101, 1, "\u1F65\u03B9"], [8102, 1, "\u1F66\u03B9"], [8103, 1, "\u1F67\u03B9"], [8104, 1, "\u1F60\u03B9"], [8105, 1, "\u1F61\u03B9"], [8106, 1, "\u1F62\u03B9"], [8107, 1, "\u1F63\u03B9"], [8108, 1, "\u1F64\u03B9"], [8109, 1, "\u1F65\u03B9"], [8110, 1, "\u1F66\u03B9"], [8111, 1, "\u1F67\u03B9"], [[8112, 8113], 2], [8114, 1, "\u1F70\u03B9"], [8115, 1, "\u03B1\u03B9"], [8116, 1, "\u03AC\u03B9"], [8117, 3], [8118, 2], [8119, 1, "\u1FB6\u03B9"], [8120, 1, "\u1FB0"], [8121, 1, "\u1FB1"], [8122, 1, "\u1F70"], [8123, 1, "\u03AC"], [8124, 1, "\u03B1\u03B9"], [8125, 5, " \u0313"], [8126, 1, "\u03B9"], [8127, 5, " \u0313"], [8128, 5, " \u0342"], [8129, 5, " \u0308\u0342"], [8130, 1, "\u1F74\u03B9"], [8131, 1, "\u03B7\u03B9"], [8132, 1, "\u03AE\u03B9"], [8133, 3], [8134, 2], [8135, 1, "\u1FC6\u03B9"], [8136, 1, "\u1F72"], [8137, 1, "\u03AD"], [8138, 1, "\u1F74"], [8139, 1, "\u03AE"], [8140, 1, "\u03B7\u03B9"], [8141, 5, " \u0313\u0300"], [8142, 5, " \u0313\u0301"], [8143, 5, " \u0313\u0342"], [[8144, 8146], 2], [8147, 1, "\u0390"], [[8148, 8149], 3], [[8150, 8151], 2], [8152, 1, "\u1FD0"], [8153, 1, "\u1FD1"], [8154, 1, "\u1F76"], [8155, 1, "\u03AF"], [8156, 3], [8157, 5, " \u0314\u0300"], [8158, 5, " \u0314\u0301"], [8159, 5, " \u0314\u0342"], [[8160, 8162], 2], [8163, 1, "\u03B0"], [[8164, 8167], 2], [8168, 1, "\u1FE0"], [8169, 1, "\u1FE1"], [8170, 1, "\u1F7A"], [8171, 1, "\u03CD"], [8172, 1, "\u1FE5"], [8173, 5, " \u0308\u0300"], [8174, 5, " \u0308\u0301"], [8175, 5, "`"], [[8176, 8177], 3], [8178, 1, "\u1F7C\u03B9"], [8179, 1, "\u03C9\u03B9"], [8180, 1, "\u03CE\u03B9"], [8181, 3], [8182, 2], [8183, 1, "\u1FF6\u03B9"], [8184, 1, "\u1F78"], [8185, 1, "\u03CC"], [8186, 1, "\u1F7C"], [8187, 1, "\u03CE"], [8188, 1, "\u03C9\u03B9"], [8189, 5, " \u0301"], [8190, 5, " \u0314"], [8191, 3], [[8192, 8202], 5, " "], [8203, 7], [[8204, 8205], 6, ""], [[8206, 8207], 3], [8208, 2], [8209, 1, "\u2010"], [[8210, 8214], 2], [8215, 5, " \u0333"], [[8216, 8227], 2], [[8228, 8230], 3], [8231, 2], [[8232, 8238], 3], [8239, 5, " "], [[8240, 8242], 2], [8243, 1, "\u2032\u2032"], [8244, 1, "\u2032\u2032\u2032"], [8245, 2], [8246, 1, "\u2035\u2035"], [8247, 1, "\u2035\u2035\u2035"], [[8248, 8251], 2], [8252, 5, "!!"], [8253, 2], [8254, 5, " \u0305"], [[8255, 8262], 2], [8263, 5, "??"], [8264, 5, "?!"], [8265, 5, "!?"], [[8266, 8269], 2], [[8270, 8274], 2], [[8275, 8276], 2], [[8277, 8278], 2], [8279, 1, "\u2032\u2032\u2032\u2032"], [[8280, 8286], 2], [8287, 5, " "], [8288, 7], [[8289, 8291], 3], [8292, 7], [8293, 3], [[8294, 8297], 3], [[8298, 8303], 3], [8304, 1, "0"], [8305, 1, "i"], [[8306, 8307], 3], [8308, 1, "4"], [8309, 1, "5"], [8310, 1, "6"], [8311, 1, "7"], [8312, 1, "8"], [8313, 1, "9"], [8314, 5, "+"], [8315, 1, "\u2212"], [8316, 5, "="], [8317, 5, "("], [8318, 5, ")"], [8319, 1, "n"], [8320, 1, "0"], [8321, 1, "1"], [8322, 1, "2"], [8323, 1, "3"], [8324, 1, "4"], [8325, 1, "5"], [8326, 1, "6"], [8327, 1, "7"], [8328, 1, "8"], [8329, 1, "9"], [8330, 5, "+"], [8331, 1, "\u2212"], [8332, 5, "="], [8333, 5, "("], [8334, 5, ")"], [8335, 3], [8336, 1, "a"], [8337, 1, "e"], [8338, 1, "o"], [8339, 1, "x"], [8340, 1, "\u0259"], [8341, 1, "h"], [8342, 1, "k"], [8343, 1, "l"], [8344, 1, "m"], [8345, 1, "n"], [8346, 1, "p"], [8347, 1, "s"], [8348, 1, "t"], [[8349, 8351], 3], [[8352, 8359], 2], [8360, 1, "rs"], [[8361, 8362], 2], [8363, 2], [8364, 2], [[8365, 8367], 2], [[8368, 8369], 2], [[8370, 8373], 2], [[8374, 8376], 2], [8377, 2], [8378, 2], [[8379, 8381], 2], [8382, 2], [8383, 2], [8384, 2], [[8385, 8399], 3], [[8400, 8417], 2], [[8418, 8419], 2], [[8420, 8426], 2], [8427, 2], [[8428, 8431], 2], [8432, 2], [[8433, 8447], 3], [8448, 5, "a/c"], [8449, 5, "a/s"], [8450, 1, "c"], [8451, 1, "\xB0c"], [8452, 2], [8453, 5, "c/o"], [8454, 5, "c/u"], [8455, 1, "\u025B"], [8456, 2], [8457, 1, "\xB0f"], [8458, 1, "g"], [[8459, 8462], 1, "h"], [8463, 1, "\u0127"], [[8464, 8465], 1, "i"], [[8466, 8467], 1, "l"], [8468, 2], [8469, 1, "n"], [8470, 1, "no"], [[8471, 8472], 2], [8473, 1, "p"], [8474, 1, "q"], [[8475, 8477], 1, "r"], [[8478, 8479], 2], [8480, 1, "sm"], [8481, 1, "tel"], [8482, 1, "tm"], [8483, 2], [8484, 1, "z"], [8485, 2], [8486, 1, "\u03C9"], [8487, 2], [8488, 1, "z"], [8489, 2], [8490, 1, "k"], [8491, 1, "\xE5"], [8492, 1, "b"], [8493, 1, "c"], [8494, 2], [[8495, 8496], 1, "e"], [8497, 1, "f"], [8498, 3], [8499, 1, "m"], [8500, 1, "o"], [8501, 1, "\u05D0"], [8502, 1, "\u05D1"], [8503, 1, "\u05D2"], [8504, 1, "\u05D3"], [8505, 1, "i"], [8506, 2], [8507, 1, "fax"], [8508, 1, "\u03C0"], [[8509, 8510], 1, "\u03B3"], [8511, 1, "\u03C0"], [8512, 1, "\u2211"], [[8513, 8516], 2], [[8517, 8518], 1, "d"], [8519, 1, "e"], [8520, 1, "i"], [8521, 1, "j"], [[8522, 8523], 2], [8524, 2], [8525, 2], [8526, 2], [8527, 2], [8528, 1, "1\u20447"], [8529, 1, "1\u20449"], [8530, 1, "1\u204410"], [8531, 1, "1\u20443"], [8532, 1, "2\u20443"], [8533, 1, "1\u20445"], [8534, 1, "2\u20445"], [8535, 1, "3\u20445"], [8536, 1, "4\u20445"], [8537, 1, "1\u20446"], [8538, 1, "5\u20446"], [8539, 1, "1\u20448"], [8540, 1, "3\u20448"], [8541, 1, "5\u20448"], [8542, 1, "7\u20448"], [8543, 1, "1\u2044"], [8544, 1, "i"], [8545, 1, "ii"], [8546, 1, "iii"], [8547, 1, "iv"], [8548, 1, "v"], [8549, 1, "vi"], [8550, 1, "vii"], [8551, 1, "viii"], [8552, 1, "ix"], [8553, 1, "x"], [8554, 1, "xi"], [8555, 1, "xii"], [8556, 1, "l"], [8557, 1, "c"], [8558, 1, "d"], [8559, 1, "m"], [8560, 1, "i"], [8561, 1, "ii"], [8562, 1, "iii"], [8563, 1, "iv"], [8564, 1, "v"], [8565, 1, "vi"], [8566, 1, "vii"], [8567, 1, "viii"], [8568, 1, "ix"], [8569, 1, "x"], [8570, 1, "xi"], [8571, 1, "xii"], [8572, 1, "l"], [8573, 1, "c"], [8574, 1, "d"], [8575, 1, "m"], [[8576, 8578], 2], [8579, 3], [8580, 2], [[8581, 8584], 2], [8585, 1, "0\u20443"], [[8586, 8587], 2], [[8588, 8591], 3], [[8592, 8682], 2], [[8683, 8691], 2], [[8692, 8703], 2], [[8704, 8747], 2], [8748, 1, "\u222B\u222B"], [8749, 1, "\u222B\u222B\u222B"], [8750, 2], [8751, 1, "\u222E\u222E"], [8752, 1, "\u222E\u222E\u222E"], [[8753, 8799], 2], [8800, 4], [[8801, 8813], 2], [[8814, 8815], 4], [[8816, 8945], 2], [[8946, 8959], 2], [8960, 2], [8961, 2], [[8962, 9e3], 2], [9001, 1, "\u3008"], [9002, 1, "\u3009"], [[9003, 9082], 2], [9083, 2], [9084, 2], [[9085, 9114], 2], [[9115, 9166], 2], [[9167, 9168], 2], [[9169, 9179], 2], [[9180, 9191], 2], [9192, 2], [[9193, 9203], 2], [[9204, 9210], 2], [[9211, 9214], 2], [9215, 2], [[9216, 9252], 2], [[9253, 9254], 2], [[9255, 9279], 3], [[9280, 9290], 2], [[9291, 9311], 3], [9312, 1, "1"], [9313, 1, "2"], [9314, 1, "3"], [9315, 1, "4"], [9316, 1, "5"], [9317, 1, "6"], [9318, 1, "7"], [9319, 1, "8"], [9320, 1, "9"], [9321, 1, "10"], [9322, 1, "11"], [9323, 1, "12"], [9324, 1, "13"], [9325, 1, "14"], [9326, 1, "15"], [9327, 1, "16"], [9328, 1, "17"], [9329, 1, "18"], [9330, 1, "19"], [9331, 1, "20"], [9332, 5, "(1)"], [9333, 5, "(2)"], [9334, 5, "(3)"], [9335, 5, "(4)"], [9336, 5, "(5)"], [9337, 5, "(6)"], [9338, 5, "(7)"], [9339, 5, "(8)"], [9340, 5, "(9)"], [9341, 5, "(10)"], [9342, 5, "(11)"], [9343, 5, "(12)"], [9344, 5, "(13)"], [9345, 5, "(14)"], [9346, 5, "(15)"], [9347, 5, "(16)"], [9348, 5, "(17)"], [9349, 5, "(18)"], [9350, 5, "(19)"], [9351, 5, "(20)"], [[9352, 9371], 3], [9372, 5, "(a)"], [9373, 5, "(b)"], [9374, 5, "(c)"], [9375, 5, "(d)"], [9376, 5, "(e)"], [9377, 5, "(f)"], [9378, 5, "(g)"], [9379, 5, "(h)"], [9380, 5, "(i)"], [9381, 5, "(j)"], [9382, 5, "(k)"], [9383, 5, "(l)"], [9384, 5, "(m)"], [9385, 5, "(n)"], [9386, 5, "(o)"], [9387, 5, "(p)"], [9388, 5, "(q)"], [9389, 5, "(r)"], [9390, 5, "(s)"], [9391, 5, "(t)"], [9392, 5, "(u)"], [9393, 5, "(v)"], [9394, 5, "(w)"], [9395, 5, "(x)"], [9396, 5, "(y)"], [9397, 5, "(z)"], [9398, 1, "a"], [9399, 1, "b"], [9400, 1, "c"], [9401, 1, "d"], [9402, 1, "e"], [9403, 1, "f"], [9404, 1, "g"], [9405, 1, "h"], [9406, 1, "i"], [9407, 1, "j"], [9408, 1, "k"], [9409, 1, "l"], [9410, 1, "m"], [9411, 1, "n"], [9412, 1, "o"], [9413, 1, "p"], [9414, 1, "q"], [9415, 1, "r"], [9416, 1, "s"], [9417, 1, "t"], [9418, 1, "u"], [9419, 1, "v"], [9420, 1, "w"], [9421, 1, "x"], [9422, 1, "y"], [9423, 1, "z"], [9424, 1, "a"], [9425, 1, "b"], [9426, 1, "c"], [9427, 1, "d"], [9428, 1, "e"], [9429, 1, "f"], [9430, 1, "g"], [9431, 1, "h"], [9432, 1, "i"], [9433, 1, "j"], [9434, 1, "k"], [9435, 1, "l"], [9436, 1, "m"], [9437, 1, "n"], [9438, 1, "o"], [9439, 1, "p"], [9440, 1, "q"], [9441, 1, "r"], [9442, 1, "s"], [9443, 1, "t"], [9444, 1, "u"], [9445, 1, "v"], [9446, 1, "w"], [9447, 1, "x"], [9448, 1, "y"], [9449, 1, "z"], [9450, 1, "0"], [[9451, 9470], 2], [9471, 2], [[9472, 9621], 2], [[9622, 9631], 2], [[9632, 9711], 2], [[9712, 9719], 2], [[9720, 9727], 2], [[9728, 9747], 2], [[9748, 9749], 2], [[9750, 9751], 2], [9752, 2], [9753, 2], [[9754, 9839], 2], [[9840, 9841], 2], [[9842, 9853], 2], [[9854, 9855], 2], [[9856, 9865], 2], [[9866, 9873], 2], [[9874, 9884], 2], [9885, 2], [[9886, 9887], 2], [[9888, 9889], 2], [[9890, 9905], 2], [9906, 2], [[9907, 9916], 2], [[9917, 9919], 2], [[9920, 9923], 2], [[9924, 9933], 2], [9934, 2], [[9935, 9953], 2], [9954, 2], [9955, 2], [[9956, 9959], 2], [[9960, 9983], 2], [9984, 2], [[9985, 9988], 2], [9989, 2], [[9990, 9993], 2], [[9994, 9995], 2], [[9996, 10023], 2], [10024, 2], [[10025, 10059], 2], [10060, 2], [10061, 2], [10062, 2], [[10063, 10066], 2], [[10067, 10069], 2], [10070, 2], [10071, 2], [[10072, 10078], 2], [[10079, 10080], 2], [[10081, 10087], 2], [[10088, 10101], 2], [[10102, 10132], 2], [[10133, 10135], 2], [[10136, 10159], 2], [10160, 2], [[10161, 10174], 2], [10175, 2], [[10176, 10182], 2], [[10183, 10186], 2], [10187, 2], [10188, 2], [10189, 2], [[10190, 10191], 2], [[10192, 10219], 2], [[10220, 10223], 2], [[10224, 10239], 2], [[10240, 10495], 2], [[10496, 10763], 2], [10764, 1, "\u222B\u222B\u222B\u222B"], [[10765, 10867], 2], [10868, 5, "::="], [10869, 5, "=="], [10870, 5, "==="], [[10871, 10971], 2], [10972, 1, "\u2ADD\u0338"], [[10973, 11007], 2], [[11008, 11021], 2], [[11022, 11027], 2], [[11028, 11034], 2], [[11035, 11039], 2], [[11040, 11043], 2], [[11044, 11084], 2], [[11085, 11087], 2], [[11088, 11092], 2], [[11093, 11097], 2], [[11098, 11123], 2], [[11124, 11125], 3], [[11126, 11157], 2], [11158, 3], [11159, 2], [[11160, 11193], 2], [[11194, 11196], 2], [[11197, 11208], 2], [11209, 2], [[11210, 11217], 2], [11218, 2], [[11219, 11243], 2], [[11244, 11247], 2], [[11248, 11262], 2], [11263, 2], [11264, 1, "\u2C30"], [11265, 1, "\u2C31"], [11266, 1, "\u2C32"], [11267, 1, "\u2C33"], [11268, 1, "\u2C34"], [11269, 1, "\u2C35"], [11270, 1, "\u2C36"], [11271, 1, "\u2C37"], [11272, 1, "\u2C38"], [11273, 1, "\u2C39"], [11274, 1, "\u2C3A"], [11275, 1, "\u2C3B"], [11276, 1, "\u2C3C"], [11277, 1, "\u2C3D"], [11278, 1, "\u2C3E"], [11279, 1, "\u2C3F"], [11280, 1, "\u2C40"], [11281, 1, "\u2C41"], [11282, 1, "\u2C42"], [11283, 1, "\u2C43"], [11284, 1, "\u2C44"], [11285, 1, "\u2C45"], [11286, 1, "\u2C46"], [11287, 1, "\u2C47"], [11288, 1, "\u2C48"], [11289, 1, "\u2C49"], [11290, 1, "\u2C4A"], [11291, 1, "\u2C4B"], [11292, 1, "\u2C4C"], [11293, 1, "\u2C4D"], [11294, 1, "\u2C4E"], [11295, 1, "\u2C4F"], [11296, 1, "\u2C50"], [11297, 1, "\u2C51"], [11298, 1, "\u2C52"], [11299, 1, "\u2C53"], [11300, 1, "\u2C54"], [11301, 1, "\u2C55"], [11302, 1, "\u2C56"], [11303, 1, "\u2C57"], [11304, 1, "\u2C58"], [11305, 1, "\u2C59"], [11306, 1, "\u2C5A"], [11307, 1, "\u2C5B"], [11308, 1, "\u2C5C"], [11309, 1, "\u2C5D"], [11310, 1, "\u2C5E"], [11311, 1, "\u2C5F"], [[11312, 11358], 2], [11359, 2], [11360, 1, "\u2C61"], [11361, 2], [11362, 1, "\u026B"], [11363, 1, "\u1D7D"], [11364, 1, "\u027D"], [[11365, 11366], 2], [11367, 1, "\u2C68"], [11368, 2], [11369, 1, "\u2C6A"], [11370, 2], [11371, 1, "\u2C6C"], [11372, 2], [11373, 1, "\u0251"], [11374, 1, "\u0271"], [11375, 1, "\u0250"], [11376, 1, "\u0252"], [11377, 2], [11378, 1, "\u2C73"], [11379, 2], [11380, 2], [11381, 1, "\u2C76"], [[11382, 11383], 2], [[11384, 11387], 2], [11388, 1, "j"], [11389, 1, "v"], [11390, 1, "\u023F"], [11391, 1, "\u0240"], [11392, 1, "\u2C81"], [11393, 2], [11394, 1, "\u2C83"], [11395, 2], [11396, 1, "\u2C85"], [11397, 2], [11398, 1, "\u2C87"], [11399, 2], [11400, 1, "\u2C89"], [11401, 2], [11402, 1, "\u2C8B"], [11403, 2], [11404, 1, "\u2C8D"], [11405, 2], [11406, 1, "\u2C8F"], [11407, 2], [11408, 1, "\u2C91"], [11409, 2], [11410, 1, "\u2C93"], [11411, 2], [11412, 1, "\u2C95"], [11413, 2], [11414, 1, "\u2C97"], [11415, 2], [11416, 1, "\u2C99"], [11417, 2], [11418, 1, "\u2C9B"], [11419, 2], [11420, 1, "\u2C9D"], [11421, 2], [11422, 1, "\u2C9F"], [11423, 2], [11424, 1, "\u2CA1"], [11425, 2], [11426, 1, "\u2CA3"], [11427, 2], [11428, 1, "\u2CA5"], [11429, 2], [11430, 1, "\u2CA7"], [11431, 2], [11432, 1, "\u2CA9"], [11433, 2], [11434, 1, "\u2CAB"], [11435, 2], [11436, 1, "\u2CAD"], [11437, 2], [11438, 1, "\u2CAF"], [11439, 2], [11440, 1, "\u2CB1"], [11441, 2], [11442, 1, "\u2CB3"], [11443, 2], [11444, 1, "\u2CB5"], [11445, 2], [11446, 1, "\u2CB7"], [11447, 2], [11448, 1, "\u2CB9"], [11449, 2], [11450, 1, "\u2CBB"], [11451, 2], [11452, 1, "\u2CBD"], [11453, 2], [11454, 1, "\u2CBF"], [11455, 2], [11456, 1, "\u2CC1"], [11457, 2], [11458, 1, "\u2CC3"], [11459, 2], [11460, 1, "\u2CC5"], [11461, 2], [11462, 1, "\u2CC7"], [11463, 2], [11464, 1, "\u2CC9"], [11465, 2], [11466, 1, "\u2CCB"], [11467, 2], [11468, 1, "\u2CCD"], [11469, 2], [11470, 1, "\u2CCF"], [11471, 2], [11472, 1, "\u2CD1"], [11473, 2], [11474, 1, "\u2CD3"], [11475, 2], [11476, 1, "\u2CD5"], [11477, 2], [11478, 1, "\u2CD7"], [11479, 2], [11480, 1, "\u2CD9"], [11481, 2], [11482, 1, "\u2CDB"], [11483, 2], [11484, 1, "\u2CDD"], [11485, 2], [11486, 1, "\u2CDF"], [11487, 2], [11488, 1, "\u2CE1"], [11489, 2], [11490, 1, "\u2CE3"], [[11491, 11492], 2], [[11493, 11498], 2], [11499, 1, "\u2CEC"], [11500, 2], [11501, 1, "\u2CEE"], [[11502, 11505], 2], [11506, 1, "\u2CF3"], [11507, 2], [[11508, 11512], 3], [[11513, 11519], 2], [[11520, 11557], 2], [11558, 3], [11559, 2], [[11560, 11564], 3], [11565, 2], [[11566, 11567], 3], [[11568, 11621], 2], [[11622, 11623], 2], [[11624, 11630], 3], [11631, 1, "\u2D61"], [11632, 2], [[11633, 11646], 3], [11647, 2], [[11648, 11670], 2], [[11671, 11679], 3], [[11680, 11686], 2], [11687, 3], [[11688, 11694], 2], [11695, 3], [[11696, 11702], 2], [11703, 3], [[11704, 11710], 2], [11711, 3], [[11712, 11718], 2], [11719, 3], [[11720, 11726], 2], [11727, 3], [[11728, 11734], 2], [11735, 3], [[11736, 11742], 2], [11743, 3], [[11744, 11775], 2], [[11776, 11799], 2], [[11800, 11803], 2], [[11804, 11805], 2], [[11806, 11822], 2], [11823, 2], [11824, 2], [11825, 2], [[11826, 11835], 2], [[11836, 11842], 2], [[11843, 11844], 2], [[11845, 11849], 2], [[11850, 11854], 2], [11855, 2], [[11856, 11858], 2], [[11859, 11869], 2], [[11870, 11903], 3], [[11904, 11929], 2], [11930, 3], [[11931, 11934], 2], [11935, 1, "\u6BCD"], [[11936, 12018], 2], [12019, 1, "\u9F9F"], [[12020, 12031], 3], [12032, 1, "\u4E00"], [12033, 1, "\u4E28"], [12034, 1, "\u4E36"], [12035, 1, "\u4E3F"], [12036, 1, "\u4E59"], [12037, 1, "\u4E85"], [12038, 1, "\u4E8C"], [12039, 1, "\u4EA0"], [12040, 1, "\u4EBA"], [12041, 1, "\u513F"], [12042, 1, "\u5165"], [12043, 1, "\u516B"], [12044, 1, "\u5182"], [12045, 1, "\u5196"], [12046, 1, "\u51AB"], [12047, 1, "\u51E0"], [12048, 1, "\u51F5"], [12049, 1, "\u5200"], [12050, 1, "\u529B"], [12051, 1, "\u52F9"], [12052, 1, "\u5315"], [12053, 1, "\u531A"], [12054, 1, "\u5338"], [12055, 1, "\u5341"], [12056, 1, "\u535C"], [12057, 1, "\u5369"], [12058, 1, "\u5382"], [12059, 1, "\u53B6"], [12060, 1, "\u53C8"], [12061, 1, "\u53E3"], [12062, 1, "\u56D7"], [12063, 1, "\u571F"], [12064, 1, "\u58EB"], [12065, 1, "\u5902"], [12066, 1, "\u590A"], [12067, 1, "\u5915"], [12068, 1, "\u5927"], [12069, 1, "\u5973"], [12070, 1, "\u5B50"], [12071, 1, "\u5B80"], [12072, 1, "\u5BF8"], [12073, 1, "\u5C0F"], [12074, 1, "\u5C22"], [12075, 1, "\u5C38"], [12076, 1, "\u5C6E"], [12077, 1, "\u5C71"], [12078, 1, "\u5DDB"], [12079, 1, "\u5DE5"], [12080, 1, "\u5DF1"], [12081, 1, "\u5DFE"], [12082, 1, "\u5E72"], [12083, 1, "\u5E7A"], [12084, 1, "\u5E7F"], [12085, 1, "\u5EF4"], [12086, 1, "\u5EFE"], [12087, 1, "\u5F0B"], [12088, 1, "\u5F13"], [12089, 1, "\u5F50"], [12090, 1, "\u5F61"], [12091, 1, "\u5F73"], [12092, 1, "\u5FC3"], [12093, 1, "\u6208"], [12094, 1, "\u6236"], [12095, 1, "\u624B"], [12096, 1, "\u652F"], [12097, 1, "\u6534"], [12098, 1, "\u6587"], [12099, 1, "\u6597"], [12100, 1, "\u65A4"], [12101, 1, "\u65B9"], [12102, 1, "\u65E0"], [12103, 1, "\u65E5"], [12104, 1, "\u66F0"], [12105, 1, "\u6708"], [12106, 1, "\u6728"], [12107, 1, "\u6B20"], [12108, 1, "\u6B62"], [12109, 1, "\u6B79"], [12110, 1, "\u6BB3"], [12111, 1, "\u6BCB"], [12112, 1, "\u6BD4"], [12113, 1, "\u6BDB"], [12114, 1, "\u6C0F"], [12115, 1, "\u6C14"], [12116, 1, "\u6C34"], [12117, 1, "\u706B"], [12118, 1, "\u722A"], [12119, 1, "\u7236"], [12120, 1, "\u723B"], [12121, 1, "\u723F"], [12122, 1, "\u7247"], [12123, 1, "\u7259"], [12124, 1, "\u725B"], [12125, 1, "\u72AC"], [12126, 1, "\u7384"], [12127, 1, "\u7389"], [12128, 1, "\u74DC"], [12129, 1, "\u74E6"], [12130, 1, "\u7518"], [12131, 1, "\u751F"], [12132, 1, "\u7528"], [12133, 1, "\u7530"], [12134, 1, "\u758B"], [12135, 1, "\u7592"], [12136, 1, "\u7676"], [12137, 1, "\u767D"], [12138, 1, "\u76AE"], [12139, 1, "\u76BF"], [12140, 1, "\u76EE"], [12141, 1, "\u77DB"], [12142, 1, "\u77E2"], [12143, 1, "\u77F3"], [12144, 1, "\u793A"], [12145, 1, "\u79B8"], [12146, 1, "\u79BE"], [12147, 1, "\u7A74"], [12148, 1, "\u7ACB"], [12149, 1, "\u7AF9"], [12150, 1, "\u7C73"], [12151, 1, "\u7CF8"], [12152, 1, "\u7F36"], [12153, 1, "\u7F51"], [12154, 1, "\u7F8A"], [12155, 1, "\u7FBD"], [12156, 1, "\u8001"], [12157, 1, "\u800C"], [12158, 1, "\u8012"], [12159, 1, "\u8033"], [12160, 1, "\u807F"], [12161, 1, "\u8089"], [12162, 1, "\u81E3"], [12163, 1, "\u81EA"], [12164, 1, "\u81F3"], [12165, 1, "\u81FC"], [12166, 1, "\u820C"], [12167, 1, "\u821B"], [12168, 1, "\u821F"], [12169, 1, "\u826E"], [12170, 1, "\u8272"], [12171, 1, "\u8278"], [12172, 1, "\u864D"], [12173, 1, "\u866B"], [12174, 1, "\u8840"], [12175, 1, "\u884C"], [12176, 1, "\u8863"], [12177, 1, "\u897E"], [12178, 1, "\u898B"], [12179, 1, "\u89D2"], [12180, 1, "\u8A00"], [12181, 1, "\u8C37"], [12182, 1, "\u8C46"], [12183, 1, "\u8C55"], [12184, 1, "\u8C78"], [12185, 1, "\u8C9D"], [12186, 1, "\u8D64"], [12187, 1, "\u8D70"], [12188, 1, "\u8DB3"], [12189, 1, "\u8EAB"], [12190, 1, "\u8ECA"], [12191, 1, "\u8F9B"], [12192, 1, "\u8FB0"], [12193, 1, "\u8FB5"], [12194, 1, "\u9091"], [12195, 1, "\u9149"], [12196, 1, "\u91C6"], [12197, 1, "\u91CC"], [12198, 1, "\u91D1"], [12199, 1, "\u9577"], [12200, 1, "\u9580"], [12201, 1, "\u961C"], [12202, 1, "\u96B6"], [12203, 1, "\u96B9"], [12204, 1, "\u96E8"], [12205, 1, "\u9751"], [12206, 1, "\u975E"], [12207, 1, "\u9762"], [12208, 1, "\u9769"], [12209, 1, "\u97CB"], [12210, 1, "\u97ED"], [12211, 1, "\u97F3"], [12212, 1, "\u9801"], [12213, 1, "\u98A8"], [12214, 1, "\u98DB"], [12215, 1, "\u98DF"], [12216, 1, "\u9996"], [12217, 1, "\u9999"], [12218, 1, "\u99AC"], [12219, 1, "\u9AA8"], [12220, 1, "\u9AD8"], [12221, 1, "\u9ADF"], [12222, 1, "\u9B25"], [12223, 1, "\u9B2F"], [12224, 1, "\u9B32"], [12225, 1, "\u9B3C"], [12226, 1, "\u9B5A"], [12227, 1, "\u9CE5"], [12228, 1, "\u9E75"], [12229, 1, "\u9E7F"], [12230, 1, "\u9EA5"], [12231, 1, "\u9EBB"], [12232, 1, "\u9EC3"], [12233, 1, "\u9ECD"], [12234, 1, "\u9ED1"], [12235, 1, "\u9EF9"], [12236, 1, "\u9EFD"], [12237, 1, "\u9F0E"], [12238, 1, "\u9F13"], [12239, 1, "\u9F20"], [12240, 1, "\u9F3B"], [12241, 1, "\u9F4A"], [12242, 1, "\u9F52"], [12243, 1, "\u9F8D"], [12244, 1, "\u9F9C"], [12245, 1, "\u9FA0"], [[12246, 12271], 3], [[12272, 12283], 3], [[12284, 12287], 3], [12288, 5, " "], [12289, 2], [12290, 1, "."], [[12291, 12292], 2], [[12293, 12295], 2], [[12296, 12329], 2], [[12330, 12333], 2], [[12334, 12341], 2], [12342, 1, "\u3012"], [12343, 2], [12344, 1, "\u5341"], [12345, 1, "\u5344"], [12346, 1, "\u5345"], [12347, 2], [12348, 2], [12349, 2], [12350, 2], [12351, 2], [12352, 3], [[12353, 12436], 2], [[12437, 12438], 2], [[12439, 12440], 3], [[12441, 12442], 2], [12443, 5, " \u3099"], [12444, 5, " \u309A"], [[12445, 12446], 2], [12447, 1, "\u3088\u308A"], [12448, 2], [[12449, 12542], 2], [12543, 1, "\u30B3\u30C8"], [[12544, 12548], 3], [[12549, 12588], 2], [12589, 2], [12590, 2], [12591, 2], [12592, 3], [12593, 1, "\u1100"], [12594, 1, "\u1101"], [12595, 1, "\u11AA"], [12596, 1, "\u1102"], [12597, 1, "\u11AC"], [12598, 1, "\u11AD"], [12599, 1, "\u1103"], [12600, 1, "\u1104"], [12601, 1, "\u1105"], [12602, 1, "\u11B0"], [12603, 1, "\u11B1"], [12604, 1, "\u11B2"], [12605, 1, "\u11B3"], [12606, 1, "\u11B4"], [12607, 1, "\u11B5"], [12608, 1, "\u111A"], [12609, 1, "\u1106"], [12610, 1, "\u1107"], [12611, 1, "\u1108"], [12612, 1, "\u1121"], [12613, 1, "\u1109"], [12614, 1, "\u110A"], [12615, 1, "\u110B"], [12616, 1, "\u110C"], [12617, 1, "\u110D"], [12618, 1, "\u110E"], [12619, 1, "\u110F"], [12620, 1, "\u1110"], [12621, 1, "\u1111"], [12622, 1, "\u1112"], [12623, 1, "\u1161"], [12624, 1, "\u1162"], [12625, 1, "\u1163"], [12626, 1, "\u1164"], [12627, 1, "\u1165"], [12628, 1, "\u1166"], [12629, 1, "\u1167"], [12630, 1, "\u1168"], [12631, 1, "\u1169"], [12632, 1, "\u116A"], [12633, 1, "\u116B"], [12634, 1, "\u116C"], [12635, 1, "\u116D"], [12636, 1, "\u116E"], [12637, 1, "\u116F"], [12638, 1, "\u1170"], [12639, 1, "\u1171"], [12640, 1, "\u1172"], [12641, 1, "\u1173"], [12642, 1, "\u1174"], [12643, 1, "\u1175"], [12644, 3], [12645, 1, "\u1114"], [12646, 1, "\u1115"], [12647, 1, "\u11C7"], [12648, 1, "\u11C8"], [12649, 1, "\u11CC"], [12650, 1, "\u11CE"], [12651, 1, "\u11D3"], [12652, 1, "\u11D7"], [12653, 1, "\u11D9"], [12654, 1, "\u111C"], [12655, 1, "\u11DD"], [12656, 1, "\u11DF"], [12657, 1, "\u111D"], [12658, 1, "\u111E"], [12659, 1, "\u1120"], [12660, 1, "\u1122"], [12661, 1, "\u1123"], [12662, 1, "\u1127"], [12663, 1, "\u1129"], [12664, 1, "\u112B"], [12665, 1, "\u112C"], [12666, 1, "\u112D"], [12667, 1, "\u112E"], [12668, 1, "\u112F"], [12669, 1, "\u1132"], [12670, 1, "\u1136"], [12671, 1, "\u1140"], [12672, 1, "\u1147"], [12673, 1, "\u114C"], [12674, 1, "\u11F1"], [12675, 1, "\u11F2"], [12676, 1, "\u1157"], [12677, 1, "\u1158"], [12678, 1, "\u1159"], [12679, 1, "\u1184"], [12680, 1, "\u1185"], [12681, 1, "\u1188"], [12682, 1, "\u1191"], [12683, 1, "\u1192"], [12684, 1, "\u1194"], [12685, 1, "\u119E"], [12686, 1, "\u11A1"], [12687, 3], [[12688, 12689], 2], [12690, 1, "\u4E00"], [12691, 1, "\u4E8C"], [12692, 1, "\u4E09"], [12693, 1, "\u56DB"], [12694, 1, "\u4E0A"], [12695, 1, "\u4E2D"], [12696, 1, "\u4E0B"], [12697, 1, "\u7532"], [12698, 1, "\u4E59"], [12699, 1, "\u4E19"], [12700, 1, "\u4E01"], [12701, 1, "\u5929"], [12702, 1, "\u5730"], [12703, 1, "\u4EBA"], [[12704, 12727], 2], [[12728, 12730], 2], [[12731, 12735], 2], [[12736, 12751], 2], [[12752, 12771], 2], [[12772, 12783], 3], [[12784, 12799], 2], [12800, 5, "(\u1100)"], [12801, 5, "(\u1102)"], [12802, 5, "(\u1103)"], [12803, 5, "(\u1105)"], [12804, 5, "(\u1106)"], [12805, 5, "(\u1107)"], [12806, 5, "(\u1109)"], [12807, 5, "(\u110B)"], [12808, 5, "(\u110C)"], [12809, 5, "(\u110E)"], [12810, 5, "(\u110F)"], [12811, 5, "(\u1110)"], [12812, 5, "(\u1111)"], [12813, 5, "(\u1112)"], [12814, 5, "(\uAC00)"], [12815, 5, "(\uB098)"], [12816, 5, "(\uB2E4)"], [12817, 5, "(\uB77C)"], [12818, 5, "(\uB9C8)"], [12819, 5, "(\uBC14)"], [12820, 5, "(\uC0AC)"], [12821, 5, "(\uC544)"], [12822, 5, "(\uC790)"], [12823, 5, "(\uCC28)"], [12824, 5, "(\uCE74)"], [12825, 5, "(\uD0C0)"], [12826, 5, "(\uD30C)"], [12827, 5, "(\uD558)"], [12828, 5, "(\uC8FC)"], [12829, 5, "(\uC624\uC804)"], [12830, 5, "(\uC624\uD6C4)"], [12831, 3], [12832, 5, "(\u4E00)"], [12833, 5, "(\u4E8C)"], [12834, 5, "(\u4E09)"], [12835, 5, "(\u56DB)"], [12836, 5, "(\u4E94)"], [12837, 5, "(\u516D)"], [12838, 5, "(\u4E03)"], [12839, 5, "(\u516B)"], [12840, 5, "(\u4E5D)"], [12841, 5, "(\u5341)"], [12842, 5, "(\u6708)"], [12843, 5, "(\u706B)"], [12844, 5, "(\u6C34)"], [12845, 5, "(\u6728)"], [12846, 5, "(\u91D1)"], [12847, 5, "(\u571F)"], [12848, 5, "(\u65E5)"], [12849, 5, "(\u682A)"], [12850, 5, "(\u6709)"], [12851, 5, "(\u793E)"], [12852, 5, "(\u540D)"], [12853, 5, "(\u7279)"], [12854, 5, "(\u8CA1)"], [12855, 5, "(\u795D)"], [12856, 5, "(\u52B4)"], [12857, 5, "(\u4EE3)"], [12858, 5, "(\u547C)"], [12859, 5, "(\u5B66)"], [12860, 5, "(\u76E3)"], [12861, 5, "(\u4F01)"], [12862, 5, "(\u8CC7)"], [12863, 5, "(\u5354)"], [12864, 5, "(\u796D)"], [12865, 5, "(\u4F11)"], [12866, 5, "(\u81EA)"], [12867, 5, "(\u81F3)"], [12868, 1, "\u554F"], [12869, 1, "\u5E7C"], [12870, 1, "\u6587"], [12871, 1, "\u7B8F"], [[12872, 12879], 2], [12880, 1, "pte"], [12881, 1, "21"], [12882, 1, "22"], [12883, 1, "23"], [12884, 1, "24"], [12885, 1, "25"], [12886, 1, "26"], [12887, 1, "27"], [12888, 1, "28"], [12889, 1, "29"], [12890, 1, "30"], [12891, 1, "31"], [12892, 1, "32"], [12893, 1, "33"], [12894, 1, "34"], [12895, 1, "35"], [12896, 1, "\u1100"], [12897, 1, "\u1102"], [12898, 1, "\u1103"], [12899, 1, "\u1105"], [12900, 1, "\u1106"], [12901, 1, "\u1107"], [12902, 1, "\u1109"], [12903, 1, "\u110B"], [12904, 1, "\u110C"], [12905, 1, "\u110E"], [12906, 1, "\u110F"], [12907, 1, "\u1110"], [12908, 1, "\u1111"], [12909, 1, "\u1112"], [12910, 1, "\uAC00"], [12911, 1, "\uB098"], [12912, 1, "\uB2E4"], [12913, 1, "\uB77C"], [12914, 1, "\uB9C8"], [12915, 1, "\uBC14"], [12916, 1, "\uC0AC"], [12917, 1, "\uC544"], [12918, 1, "\uC790"], [12919, 1, "\uCC28"], [12920, 1, "\uCE74"], [12921, 1, "\uD0C0"], [12922, 1, "\uD30C"], [12923, 1, "\uD558"], [12924, 1, "\uCC38\uACE0"], [12925, 1, "\uC8FC\uC758"], [12926, 1, "\uC6B0"], [12927, 2], [12928, 1, "\u4E00"], [12929, 1, "\u4E8C"], [12930, 1, "\u4E09"], [12931, 1, "\u56DB"], [12932, 1, "\u4E94"], [12933, 1, "\u516D"], [12934, 1, "\u4E03"], [12935, 1, "\u516B"], [12936, 1, "\u4E5D"], [12937, 1, "\u5341"], [12938, 1, "\u6708"], [12939, 1, "\u706B"], [12940, 1, "\u6C34"], [12941, 1, "\u6728"], [12942, 1, "\u91D1"], [12943, 1, "\u571F"], [12944, 1, "\u65E5"], [12945, 1, "\u682A"], [12946, 1, "\u6709"], [12947, 1, "\u793E"], [12948, 1, "\u540D"], [12949, 1, "\u7279"], [12950, 1, "\u8CA1"], [12951, 1, "\u795D"], [12952, 1, "\u52B4"], [12953, 1, "\u79D8"], [12954, 1, "\u7537"], [12955, 1, "\u5973"], [12956, 1, "\u9069"], [12957, 1, "\u512A"], [12958, 1, "\u5370"], [12959, 1, "\u6CE8"], [12960, 1, "\u9805"], [12961, 1, "\u4F11"], [12962, 1, "\u5199"], [12963, 1, "\u6B63"], [12964, 1, "\u4E0A"], [12965, 1, "\u4E2D"], [12966, 1, "\u4E0B"], [12967, 1, "\u5DE6"], [12968, 1, "\u53F3"], [12969, 1, "\u533B"], [12970, 1, "\u5B97"], [12971, 1, "\u5B66"], [12972, 1, "\u76E3"], [12973, 1, "\u4F01"], [12974, 1, "\u8CC7"], [12975, 1, "\u5354"], [12976, 1, "\u591C"], [12977, 1, "36"], [12978, 1, "37"], [12979, 1, "38"], [12980, 1, "39"], [12981, 1, "40"], [12982, 1, "41"], [12983, 1, "42"], [12984, 1, "43"], [12985, 1, "44"], [12986, 1, "45"], [12987, 1, "46"], [12988, 1, "47"], [12989, 1, "48"], [12990, 1, "49"], [12991, 1, "50"], [12992, 1, "1\u6708"], [12993, 1, "2\u6708"], [12994, 1, "3\u6708"], [12995, 1, "4\u6708"], [12996, 1, "5\u6708"], [12997, 1, "6\u6708"], [12998, 1, "7\u6708"], [12999, 1, "8\u6708"], [13e3, 1, "9\u6708"], [13001, 1, "10\u6708"], [13002, 1, "11\u6708"], [13003, 1, "12\u6708"], [13004, 1, "hg"], [13005, 1, "erg"], [13006, 1, "ev"], [13007, 1, "ltd"], [13008, 1, "\u30A2"], [13009, 1, "\u30A4"], [13010, 1, "\u30A6"], [13011, 1, "\u30A8"], [13012, 1, "\u30AA"], [13013, 1, "\u30AB"], [13014, 1, "\u30AD"], [13015, 1, "\u30AF"], [13016, 1, "\u30B1"], [13017, 1, "\u30B3"], [13018, 1, "\u30B5"], [13019, 1, "\u30B7"], [13020, 1, "\u30B9"], [13021, 1, "\u30BB"], [13022, 1, "\u30BD"], [13023, 1, "\u30BF"], [13024, 1, "\u30C1"], [13025, 1, "\u30C4"], [13026, 1, "\u30C6"], [13027, 1, "\u30C8"], [13028, 1, "\u30CA"], [13029, 1, "\u30CB"], [13030, 1, "\u30CC"], [13031, 1, "\u30CD"], [13032, 1, "\u30CE"], [13033, 1, "\u30CF"], [13034, 1, "\u30D2"], [13035, 1, "\u30D5"], [13036, 1, "\u30D8"], [13037, 1, "\u30DB"], [13038, 1, "\u30DE"], [13039, 1, "\u30DF"], [13040, 1, "\u30E0"], [13041, 1, "\u30E1"], [13042, 1, "\u30E2"], [13043, 1, "\u30E4"], [13044, 1, "\u30E6"], [13045, 1, "\u30E8"], [13046, 1, "\u30E9"], [13047, 1, "\u30EA"], [13048, 1, "\u30EB"], [13049, 1, "\u30EC"], [13050, 1, "\u30ED"], [13051, 1, "\u30EF"], [13052, 1, "\u30F0"], [13053, 1, "\u30F1"], [13054, 1, "\u30F2"], [13055, 1, "\u4EE4\u548C"], [13056, 1, "\u30A2\u30D1\u30FC\u30C8"], [13057, 1, "\u30A2\u30EB\u30D5\u30A1"], [13058, 1, "\u30A2\u30F3\u30DA\u30A2"], [13059, 1, "\u30A2\u30FC\u30EB"], [13060, 1, "\u30A4\u30CB\u30F3\u30B0"], [13061, 1, "\u30A4\u30F3\u30C1"], [13062, 1, "\u30A6\u30A9\u30F3"], [13063, 1, "\u30A8\u30B9\u30AF\u30FC\u30C9"], [13064, 1, "\u30A8\u30FC\u30AB\u30FC"], [13065, 1, "\u30AA\u30F3\u30B9"], [13066, 1, "\u30AA\u30FC\u30E0"], [13067, 1, "\u30AB\u30A4\u30EA"], [13068, 1, "\u30AB\u30E9\u30C3\u30C8"], [13069, 1, "\u30AB\u30ED\u30EA\u30FC"], [13070, 1, "\u30AC\u30ED\u30F3"], [13071, 1, "\u30AC\u30F3\u30DE"], [13072, 1, "\u30AE\u30AC"], [13073, 1, "\u30AE\u30CB\u30FC"], [13074, 1, "\u30AD\u30E5\u30EA\u30FC"], [13075, 1, "\u30AE\u30EB\u30C0\u30FC"], [13076, 1, "\u30AD\u30ED"], [13077, 1, "\u30AD\u30ED\u30B0\u30E9\u30E0"], [13078, 1, "\u30AD\u30ED\u30E1\u30FC\u30C8\u30EB"], [13079, 1, "\u30AD\u30ED\u30EF\u30C3\u30C8"], [13080, 1, "\u30B0\u30E9\u30E0"], [13081, 1, "\u30B0\u30E9\u30E0\u30C8\u30F3"], [13082, 1, "\u30AF\u30EB\u30BC\u30A4\u30ED"], [13083, 1, "\u30AF\u30ED\u30FC\u30CD"], [13084, 1, "\u30B1\u30FC\u30B9"], [13085, 1, "\u30B3\u30EB\u30CA"], [13086, 1, "\u30B3\u30FC\u30DD"], [13087, 1, "\u30B5\u30A4\u30AF\u30EB"], [13088, 1, "\u30B5\u30F3\u30C1\u30FC\u30E0"], [13089, 1, "\u30B7\u30EA\u30F3\u30B0"], [13090, 1, "\u30BB\u30F3\u30C1"], [13091, 1, "\u30BB\u30F3\u30C8"], [13092, 1, "\u30C0\u30FC\u30B9"], [13093, 1, "\u30C7\u30B7"], [13094, 1, "\u30C9\u30EB"], [13095, 1, "\u30C8\u30F3"], [13096, 1, "\u30CA\u30CE"], [13097, 1, "\u30CE\u30C3\u30C8"], [13098, 1, "\u30CF\u30A4\u30C4"], [13099, 1, "\u30D1\u30FC\u30BB\u30F3\u30C8"], [13100, 1, "\u30D1\u30FC\u30C4"], [13101, 1, "\u30D0\u30FC\u30EC\u30EB"], [13102, 1, "\u30D4\u30A2\u30B9\u30C8\u30EB"], [13103, 1, "\u30D4\u30AF\u30EB"], [13104, 1, "\u30D4\u30B3"], [13105, 1, "\u30D3\u30EB"], [13106, 1, "\u30D5\u30A1\u30E9\u30C3\u30C9"], [13107, 1, "\u30D5\u30A3\u30FC\u30C8"], [13108, 1, "\u30D6\u30C3\u30B7\u30A7\u30EB"], [13109, 1, "\u30D5\u30E9\u30F3"], [13110, 1, "\u30D8\u30AF\u30BF\u30FC\u30EB"], [13111, 1, "\u30DA\u30BD"], [13112, 1, "\u30DA\u30CB\u30D2"], [13113, 1, "\u30D8\u30EB\u30C4"], [13114, 1, "\u30DA\u30F3\u30B9"], [13115, 1, "\u30DA\u30FC\u30B8"], [13116, 1, "\u30D9\u30FC\u30BF"], [13117, 1, "\u30DD\u30A4\u30F3\u30C8"], [13118, 1, "\u30DC\u30EB\u30C8"], [13119, 1, "\u30DB\u30F3"], [13120, 1, "\u30DD\u30F3\u30C9"], [13121, 1, "\u30DB\u30FC\u30EB"], [13122, 1, "\u30DB\u30FC\u30F3"], [13123, 1, "\u30DE\u30A4\u30AF\u30ED"], [13124, 1, "\u30DE\u30A4\u30EB"], [13125, 1, "\u30DE\u30C3\u30CF"], [13126, 1, "\u30DE\u30EB\u30AF"], [13127, 1, "\u30DE\u30F3\u30B7\u30E7\u30F3"], [13128, 1, "\u30DF\u30AF\u30ED\u30F3"], [13129, 1, "\u30DF\u30EA"], [13130, 1, "\u30DF\u30EA\u30D0\u30FC\u30EB"], [13131, 1, "\u30E1\u30AC"], [13132, 1, "\u30E1\u30AC\u30C8\u30F3"], [13133, 1, "\u30E1\u30FC\u30C8\u30EB"], [13134, 1, "\u30E4\u30FC\u30C9"], [13135, 1, "\u30E4\u30FC\u30EB"], [13136, 1, "\u30E6\u30A2\u30F3"], [13137, 1, "\u30EA\u30C3\u30C8\u30EB"], [13138, 1, "\u30EA\u30E9"], [13139, 1, "\u30EB\u30D4\u30FC"], [13140, 1, "\u30EB\u30FC\u30D6\u30EB"], [13141, 1, "\u30EC\u30E0"], [13142, 1, "\u30EC\u30F3\u30C8\u30B2\u30F3"], [13143, 1, "\u30EF\u30C3\u30C8"], [13144, 1, "0\u70B9"], [13145, 1, "1\u70B9"], [13146, 1, "2\u70B9"], [13147, 1, "3\u70B9"], [13148, 1, "4\u70B9"], [13149, 1, "5\u70B9"], [13150, 1, "6\u70B9"], [13151, 1, "7\u70B9"], [13152, 1, "8\u70B9"], [13153, 1, "9\u70B9"], [13154, 1, "10\u70B9"], [13155, 1, "11\u70B9"], [13156, 1, "12\u70B9"], [13157, 1, "13\u70B9"], [13158, 1, "14\u70B9"], [13159, 1, "15\u70B9"], [13160, 1, "16\u70B9"], [13161, 1, "17\u70B9"], [13162, 1, "18\u70B9"], [13163, 1, "19\u70B9"], [13164, 1, "20\u70B9"], [13165, 1, "21\u70B9"], [13166, 1, "22\u70B9"], [13167, 1, "23\u70B9"], [13168, 1, "24\u70B9"], [13169, 1, "hpa"], [13170, 1, "da"], [13171, 1, "au"], [13172, 1, "bar"], [13173, 1, "ov"], [13174, 1, "pc"], [13175, 1, "dm"], [13176, 1, "dm2"], [13177, 1, "dm3"], [13178, 1, "iu"], [13179, 1, "\u5E73\u6210"], [13180, 1, "\u662D\u548C"], [13181, 1, "\u5927\u6B63"], [13182, 1, "\u660E\u6CBB"], [13183, 1, "\u682A\u5F0F\u4F1A\u793E"], [13184, 1, "pa"], [13185, 1, "na"], [13186, 1, "\u03BCa"], [13187, 1, "ma"], [13188, 1, "ka"], [13189, 1, "kb"], [13190, 1, "mb"], [13191, 1, "gb"], [13192, 1, "cal"], [13193, 1, "kcal"], [13194, 1, "pf"], [13195, 1, "nf"], [13196, 1, "\u03BCf"], [13197, 1, "\u03BCg"], [13198, 1, "mg"], [13199, 1, "kg"], [13200, 1, "hz"], [13201, 1, "khz"], [13202, 1, "mhz"], [13203, 1, "ghz"], [13204, 1, "thz"], [13205, 1, "\u03BCl"], [13206, 1, "ml"], [13207, 1, "dl"], [13208, 1, "kl"], [13209, 1, "fm"], [13210, 1, "nm"], [13211, 1, "\u03BCm"], [13212, 1, "mm"], [13213, 1, "cm"], [13214, 1, "km"], [13215, 1, "mm2"], [13216, 1, "cm2"], [13217, 1, "m2"], [13218, 1, "km2"], [13219, 1, "mm3"], [13220, 1, "cm3"], [13221, 1, "m3"], [13222, 1, "km3"], [13223, 1, "m\u2215s"], [13224, 1, "m\u2215s2"], [13225, 1, "pa"], [13226, 1, "kpa"], [13227, 1, "mpa"], [13228, 1, "gpa"], [13229, 1, "rad"], [13230, 1, "rad\u2215s"], [13231, 1, "rad\u2215s2"], [13232, 1, "ps"], [13233, 1, "ns"], [13234, 1, "\u03BCs"], [13235, 1, "ms"], [13236, 1, "pv"], [13237, 1, "nv"], [13238, 1, "\u03BCv"], [13239, 1, "mv"], [13240, 1, "kv"], [13241, 1, "mv"], [13242, 1, "pw"], [13243, 1, "nw"], [13244, 1, "\u03BCw"], [13245, 1, "mw"], [13246, 1, "kw"], [13247, 1, "mw"], [13248, 1, "k\u03C9"], [13249, 1, "m\u03C9"], [13250, 3], [13251, 1, "bq"], [13252, 1, "cc"], [13253, 1, "cd"], [13254, 1, "c\u2215kg"], [13255, 3], [13256, 1, "db"], [13257, 1, "gy"], [13258, 1, "ha"], [13259, 1, "hp"], [13260, 1, "in"], [13261, 1, "kk"], [13262, 1, "km"], [13263, 1, "kt"], [13264, 1, "lm"], [13265, 1, "ln"], [13266, 1, "log"], [13267, 1, "lx"], [13268, 1, "mb"], [13269, 1, "mil"], [13270, 1, "mol"], [13271, 1, "ph"], [13272, 3], [13273, 1, "ppm"], [13274, 1, "pr"], [13275, 1, "sr"], [13276, 1, "sv"], [13277, 1, "wb"], [13278, 1, "v\u2215m"], [13279, 1, "a\u2215m"], [13280, 1, "1\u65E5"], [13281, 1, "2\u65E5"], [13282, 1, "3\u65E5"], [13283, 1, "4\u65E5"], [13284, 1, "5\u65E5"], [13285, 1, "6\u65E5"], [13286, 1, "7\u65E5"], [13287, 1, "8\u65E5"], [13288, 1, "9\u65E5"], [13289, 1, "10\u65E5"], [13290, 1, "11\u65E5"], [13291, 1, "12\u65E5"], [13292, 1, "13\u65E5"], [13293, 1, "14\u65E5"], [13294, 1, "15\u65E5"], [13295, 1, "16\u65E5"], [13296, 1, "17\u65E5"], [13297, 1, "18\u65E5"], [13298, 1, "19\u65E5"], [13299, 1, "20\u65E5"], [13300, 1, "21\u65E5"], [13301, 1, "22\u65E5"], [13302, 1, "23\u65E5"], [13303, 1, "24\u65E5"], [13304, 1, "25\u65E5"], [13305, 1, "26\u65E5"], [13306, 1, "27\u65E5"], [13307, 1, "28\u65E5"], [13308, 1, "29\u65E5"], [13309, 1, "30\u65E5"], [13310, 1, "31\u65E5"], [13311, 1, "gal"], [[13312, 19893], 2], [[19894, 19903], 2], [[19904, 19967], 2], [[19968, 40869], 2], [[40870, 40891], 2], [[40892, 40899], 2], [[40900, 40907], 2], [40908, 2], [[40909, 40917], 2], [[40918, 40938], 2], [[40939, 40943], 2], [[40944, 40956], 2], [[40957, 40959], 2], [[40960, 42124], 2], [[42125, 42127], 3], [[42128, 42145], 2], [[42146, 42147], 2], [[42148, 42163], 2], [42164, 2], [[42165, 42176], 2], [42177, 2], [[42178, 42180], 2], [42181, 2], [42182, 2], [[42183, 42191], 3], [[42192, 42237], 2], [[42238, 42239], 2], [[42240, 42508], 2], [[42509, 42511], 2], [[42512, 42539], 2], [[42540, 42559], 3], [42560, 1, "\uA641"], [42561, 2], [42562, 1, "\uA643"], [42563, 2], [42564, 1, "\uA645"], [42565, 2], [42566, 1, "\uA647"], [42567, 2], [42568, 1, "\uA649"], [42569, 2], [42570, 1, "\uA64B"], [42571, 2], [42572, 1, "\uA64D"], [42573, 2], [42574, 1, "\uA64F"], [42575, 2], [42576, 1, "\uA651"], [42577, 2], [42578, 1, "\uA653"], [42579, 2], [42580, 1, "\uA655"], [42581, 2], [42582, 1, "\uA657"], [42583, 2], [42584, 1, "\uA659"], [42585, 2], [42586, 1, "\uA65B"], [42587, 2], [42588, 1, "\uA65D"], [42589, 2], [42590, 1, "\uA65F"], [42591, 2], [42592, 1, "\uA661"], [42593, 2], [42594, 1, "\uA663"], [42595, 2], [42596, 1, "\uA665"], [42597, 2], [42598, 1, "\uA667"], [42599, 2], [42600, 1, "\uA669"], [42601, 2], [42602, 1, "\uA66B"], [42603, 2], [42604, 1, "\uA66D"], [[42605, 42607], 2], [[42608, 42611], 2], [[42612, 42619], 2], [[42620, 42621], 2], [42622, 2], [42623, 2], [42624, 1, "\uA681"], [42625, 2], [42626, 1, "\uA683"], [42627, 2], [42628, 1, "\uA685"], [42629, 2], [42630, 1, "\uA687"], [42631, 2], [42632, 1, "\uA689"], [42633, 2], [42634, 1, "\uA68B"], [42635, 2], [42636, 1, "\uA68D"], [42637, 2], [42638, 1, "\uA68F"], [42639, 2], [42640, 1, "\uA691"], [42641, 2], [42642, 1, "\uA693"], [42643, 2], [42644, 1, "\uA695"], [42645, 2], [42646, 1, "\uA697"], [42647, 2], [42648, 1, "\uA699"], [42649, 2], [42650, 1, "\uA69B"], [42651, 2], [42652, 1, "\u044A"], [42653, 1, "\u044C"], [42654, 2], [42655, 2], [[42656, 42725], 2], [[42726, 42735], 2], [[42736, 42737], 2], [[42738, 42743], 2], [[42744, 42751], 3], [[42752, 42774], 2], [[42775, 42778], 2], [[42779, 42783], 2], [[42784, 42785], 2], [42786, 1, "\uA723"], [42787, 2], [42788, 1, "\uA725"], [42789, 2], [42790, 1, "\uA727"], [42791, 2], [42792, 1, "\uA729"], [42793, 2], [42794, 1, "\uA72B"], [42795, 2], [42796, 1, "\uA72D"], [42797, 2], [42798, 1, "\uA72F"], [[42799, 42801], 2], [42802, 1, "\uA733"], [42803, 2], [42804, 1, "\uA735"], [42805, 2], [42806, 1, "\uA737"], [42807, 2], [42808, 1, "\uA739"], [42809, 2], [42810, 1, "\uA73B"], [42811, 2], [42812, 1, "\uA73D"], [42813, 2], [42814, 1, "\uA73F"], [42815, 2], [42816, 1, "\uA741"], [42817, 2], [42818, 1, "\uA743"], [42819, 2], [42820, 1, "\uA745"], [42821, 2], [42822, 1, "\uA747"], [42823, 2], [42824, 1, "\uA749"], [42825, 2], [42826, 1, "\uA74B"], [42827, 2], [42828, 1, "\uA74D"], [42829, 2], [42830, 1, "\uA74F"], [42831, 2], [42832, 1, "\uA751"], [42833, 2], [42834, 1, "\uA753"], [42835, 2], [42836, 1, "\uA755"], [42837, 2], [42838, 1, "\uA757"], [42839, 2], [42840, 1, "\uA759"], [42841, 2], [42842, 1, "\uA75B"], [42843, 2], [42844, 1, "\uA75D"], [42845, 2], [42846, 1, "\uA75F"], [42847, 2], [42848, 1, "\uA761"], [42849, 2], [42850, 1, "\uA763"], [42851, 2], [42852, 1, "\uA765"], [42853, 2], [42854, 1, "\uA767"], [42855, 2], [42856, 1, "\uA769"], [42857, 2], [42858, 1, "\uA76B"], [42859, 2], [42860, 1, "\uA76D"], [42861, 2], [42862, 1, "\uA76F"], [42863, 2], [42864, 1, "\uA76F"], [[42865, 42872], 2], [42873, 1, "\uA77A"], [42874, 2], [42875, 1, "\uA77C"], [42876, 2], [42877, 1, "\u1D79"], [42878, 1, "\uA77F"], [42879, 2], [42880, 1, "\uA781"], [42881, 2], [42882, 1, "\uA783"], [42883, 2], [42884, 1, "\uA785"], [42885, 2], [42886, 1, "\uA787"], [[42887, 42888], 2], [[42889, 42890], 2], [42891, 1, "\uA78C"], [42892, 2], [42893, 1, "\u0265"], [42894, 2], [42895, 2], [42896, 1, "\uA791"], [42897, 2], [42898, 1, "\uA793"], [42899, 2], [[42900, 42901], 2], [42902, 1, "\uA797"], [42903, 2], [42904, 1, "\uA799"], [42905, 2], [42906, 1, "\uA79B"], [42907, 2], [42908, 1, "\uA79D"], [42909, 2], [42910, 1, "\uA79F"], [42911, 2], [42912, 1, "\uA7A1"], [42913, 2], [42914, 1, "\uA7A3"], [42915, 2], [42916, 1, "\uA7A5"], [42917, 2], [42918, 1, "\uA7A7"], [42919, 2], [42920, 1, "\uA7A9"], [42921, 2], [42922, 1, "\u0266"], [42923, 1, "\u025C"], [42924, 1, "\u0261"], [42925, 1, "\u026C"], [42926, 1, "\u026A"], [42927, 2], [42928, 1, "\u029E"], [42929, 1, "\u0287"], [42930, 1, "\u029D"], [42931, 1, "\uAB53"], [42932, 1, "\uA7B5"], [42933, 2], [42934, 1, "\uA7B7"], [42935, 2], [42936, 1, "\uA7B9"], [42937, 2], [42938, 1, "\uA7BB"], [42939, 2], [42940, 1, "\uA7BD"], [42941, 2], [42942, 1, "\uA7BF"], [42943, 2], [42944, 1, "\uA7C1"], [42945, 2], [42946, 1, "\uA7C3"], [42947, 2], [42948, 1, "\uA794"], [42949, 1, "\u0282"], [42950, 1, "\u1D8E"], [42951, 1, "\uA7C8"], [42952, 2], [42953, 1, "\uA7CA"], [42954, 2], [[42955, 42959], 3], [42960, 1, "\uA7D1"], [42961, 2], [42962, 3], [42963, 2], [42964, 3], [42965, 2], [42966, 1, "\uA7D7"], [42967, 2], [42968, 1, "\uA7D9"], [42969, 2], [[42970, 42993], 3], [42994, 1, "c"], [42995, 1, "f"], [42996, 1, "q"], [42997, 1, "\uA7F6"], [42998, 2], [42999, 2], [43e3, 1, "\u0127"], [43001, 1, "\u0153"], [43002, 2], [[43003, 43007], 2], [[43008, 43047], 2], [[43048, 43051], 2], [43052, 2], [[43053, 43055], 3], [[43056, 43065], 2], [[43066, 43071], 3], [[43072, 43123], 2], [[43124, 43127], 2], [[43128, 43135], 3], [[43136, 43204], 2], [43205, 2], [[43206, 43213], 3], [[43214, 43215], 2], [[43216, 43225], 2], [[43226, 43231], 3], [[43232, 43255], 2], [[43256, 43258], 2], [43259, 2], [43260, 2], [43261, 2], [[43262, 43263], 2], [[43264, 43309], 2], [[43310, 43311], 2], [[43312, 43347], 2], [[43348, 43358], 3], [43359, 2], [[43360, 43388], 2], [[43389, 43391], 3], [[43392, 43456], 2], [[43457, 43469], 2], [43470, 3], [[43471, 43481], 2], [[43482, 43485], 3], [[43486, 43487], 2], [[43488, 43518], 2], [43519, 3], [[43520, 43574], 2], [[43575, 43583], 3], [[43584, 43597], 2], [[43598, 43599], 3], [[43600, 43609], 2], [[43610, 43611], 3], [[43612, 43615], 2], [[43616, 43638], 2], [[43639, 43641], 2], [[43642, 43643], 2], [[43644, 43647], 2], [[43648, 43714], 2], [[43715, 43738], 3], [[43739, 43741], 2], [[43742, 43743], 2], [[43744, 43759], 2], [[43760, 43761], 2], [[43762, 43766], 2], [[43767, 43776], 3], [[43777, 43782], 2], [[43783, 43784], 3], [[43785, 43790], 2], [[43791, 43792], 3], [[43793, 43798], 2], [[43799, 43807], 3], [[43808, 43814], 2], [43815, 3], [[43816, 43822], 2], [43823, 3], [[43824, 43866], 2], [43867, 2], [43868, 1, "\uA727"], [43869, 1, "\uAB37"], [43870, 1, "\u026B"], [43871, 1, "\uAB52"], [[43872, 43875], 2], [[43876, 43877], 2], [[43878, 43879], 2], [43880, 2], [43881, 1, "\u028D"], [[43882, 43883], 2], [[43884, 43887], 3], [43888, 1, "\u13A0"], [43889, 1, "\u13A1"], [43890, 1, "\u13A2"], [43891, 1, "\u13A3"], [43892, 1, "\u13A4"], [43893, 1, "\u13A5"], [43894, 1, "\u13A6"], [43895, 1, "\u13A7"], [43896, 1, "\u13A8"], [43897, 1, "\u13A9"], [43898, 1, "\u13AA"], [43899, 1, "\u13AB"], [43900, 1, "\u13AC"], [43901, 1, "\u13AD"], [43902, 1, "\u13AE"], [43903, 1, "\u13AF"], [43904, 1, "\u13B0"], [43905, 1, "\u13B1"], [43906, 1, "\u13B2"], [43907, 1, "\u13B3"], [43908, 1, "\u13B4"], [43909, 1, "\u13B5"], [43910, 1, "\u13B6"], [43911, 1, "\u13B7"], [43912, 1, "\u13B8"], [43913, 1, "\u13B9"], [43914, 1, "\u13BA"], [43915, 1, "\u13BB"], [43916, 1, "\u13BC"], [43917, 1, "\u13BD"], [43918, 1, "\u13BE"], [43919, 1, "\u13BF"], [43920, 1, "\u13C0"], [43921, 1, "\u13C1"], [43922, 1, "\u13C2"], [43923, 1, "\u13C3"], [43924, 1, "\u13C4"], [43925, 1, "\u13C5"], [43926, 1, "\u13C6"], [43927, 1, "\u13C7"], [43928, 1, "\u13C8"], [43929, 1, "\u13C9"], [43930, 1, "\u13CA"], [43931, 1, "\u13CB"], [43932, 1, "\u13CC"], [43933, 1, "\u13CD"], [43934, 1, "\u13CE"], [43935, 1, "\u13CF"], [43936, 1, "\u13D0"], [43937, 1, "\u13D1"], [43938, 1, "\u13D2"], [43939, 1, "\u13D3"], [43940, 1, "\u13D4"], [43941, 1, "\u13D5"], [43942, 1, "\u13D6"], [43943, 1, "\u13D7"], [43944, 1, "\u13D8"], [43945, 1, "\u13D9"], [43946, 1, "\u13DA"], [43947, 1, "\u13DB"], [43948, 1, "\u13DC"], [43949, 1, "\u13DD"], [43950, 1, "\u13DE"], [43951, 1, "\u13DF"], [43952, 1, "\u13E0"], [43953, 1, "\u13E1"], [43954, 1, "\u13E2"], [43955, 1, "\u13E3"], [43956, 1, "\u13E4"], [43957, 1, "\u13E5"], [43958, 1, "\u13E6"], [43959, 1, "\u13E7"], [43960, 1, "\u13E8"], [43961, 1, "\u13E9"], [43962, 1, "\u13EA"], [43963, 1, "\u13EB"], [43964, 1, "\u13EC"], [43965, 1, "\u13ED"], [43966, 1, "\u13EE"], [43967, 1, "\u13EF"], [[43968, 44010], 2], [44011, 2], [[44012, 44013], 2], [[44014, 44015], 3], [[44016, 44025], 2], [[44026, 44031], 3], [[44032, 55203], 2], [[55204, 55215], 3], [[55216, 55238], 2], [[55239, 55242], 3], [[55243, 55291], 2], [[55292, 55295], 3], [[55296, 57343], 3], [[57344, 63743], 3], [63744, 1, "\u8C48"], [63745, 1, "\u66F4"], [63746, 1, "\u8ECA"], [63747, 1, "\u8CC8"], [63748, 1, "\u6ED1"], [63749, 1, "\u4E32"], [63750, 1, "\u53E5"], [[63751, 63752], 1, "\u9F9C"], [63753, 1, "\u5951"], [63754, 1, "\u91D1"], [63755, 1, "\u5587"], [63756, 1, "\u5948"], [63757, 1, "\u61F6"], [63758, 1, "\u7669"], [63759, 1, "\u7F85"], [63760, 1, "\u863F"], [63761, 1, "\u87BA"], [63762, 1, "\u88F8"], [63763, 1, "\u908F"], [63764, 1, "\u6A02"], [63765, 1, "\u6D1B"], [63766, 1, "\u70D9"], [63767, 1, "\u73DE"], [63768, 1, "\u843D"], [63769, 1, "\u916A"], [63770, 1, "\u99F1"], [63771, 1, "\u4E82"], [63772, 1, "\u5375"], [63773, 1, "\u6B04"], [63774, 1, "\u721B"], [63775, 1, "\u862D"], [63776, 1, "\u9E1E"], [63777, 1, "\u5D50"], [63778, 1, "\u6FEB"], [63779, 1, "\u85CD"], [63780, 1, "\u8964"], [63781, 1, "\u62C9"], [63782, 1, "\u81D8"], [63783, 1, "\u881F"], [63784, 1, "\u5ECA"], [63785, 1, "\u6717"], [63786, 1, "\u6D6A"], [63787, 1, "\u72FC"], [63788, 1, "\u90CE"], [63789, 1, "\u4F86"], [63790, 1, "\u51B7"], [63791, 1, "\u52DE"], [63792, 1, "\u64C4"], [63793, 1, "\u6AD3"], [63794, 1, "\u7210"], [63795, 1, "\u76E7"], [63796, 1, "\u8001"], [63797, 1, "\u8606"], [63798, 1, "\u865C"], [63799, 1, "\u8DEF"], [63800, 1, "\u9732"], [63801, 1, "\u9B6F"], [63802, 1, "\u9DFA"], [63803, 1, "\u788C"], [63804, 1, "\u797F"], [63805, 1, "\u7DA0"], [63806, 1, "\u83C9"], [63807, 1, "\u9304"], [63808, 1, "\u9E7F"], [63809, 1, "\u8AD6"], [63810, 1, "\u58DF"], [63811, 1, "\u5F04"], [63812, 1, "\u7C60"], [63813, 1, "\u807E"], [63814, 1, "\u7262"], [63815, 1, "\u78CA"], [63816, 1, "\u8CC2"], [63817, 1, "\u96F7"], [63818, 1, "\u58D8"], [63819, 1, "\u5C62"], [63820, 1, "\u6A13"], [63821, 1, "\u6DDA"], [63822, 1, "\u6F0F"], [63823, 1, "\u7D2F"], [63824, 1, "\u7E37"], [63825, 1, "\u964B"], [63826, 1, "\u52D2"], [63827, 1, "\u808B"], [63828, 1, "\u51DC"], [63829, 1, "\u51CC"], [63830, 1, "\u7A1C"], [63831, 1, "\u7DBE"], [63832, 1, "\u83F1"], [63833, 1, "\u9675"], [63834, 1, "\u8B80"], [63835, 1, "\u62CF"], [63836, 1, "\u6A02"], [63837, 1, "\u8AFE"], [63838, 1, "\u4E39"], [63839, 1, "\u5BE7"], [63840, 1, "\u6012"], [63841, 1, "\u7387"], [63842, 1, "\u7570"], [63843, 1, "\u5317"], [63844, 1, "\u78FB"], [63845, 1, "\u4FBF"], [63846, 1, "\u5FA9"], [63847, 1, "\u4E0D"], [63848, 1, "\u6CCC"], [63849, 1, "\u6578"], [63850, 1, "\u7D22"], [63851, 1, "\u53C3"], [63852, 1, "\u585E"], [63853, 1, "\u7701"], [63854, 1, "\u8449"], [63855, 1, "\u8AAA"], [63856, 1, "\u6BBA"], [63857, 1, "\u8FB0"], [63858, 1, "\u6C88"], [63859, 1, "\u62FE"], [63860, 1, "\u82E5"], [63861, 1, "\u63A0"], [63862, 1, "\u7565"], [63863, 1, "\u4EAE"], [63864, 1, "\u5169"], [63865, 1, "\u51C9"], [63866, 1, "\u6881"], [63867, 1, "\u7CE7"], [63868, 1, "\u826F"], [63869, 1, "\u8AD2"], [63870, 1, "\u91CF"], [63871, 1, "\u52F5"], [63872, 1, "\u5442"], [63873, 1, "\u5973"], [63874, 1, "\u5EEC"], [63875, 1, "\u65C5"], [63876, 1, "\u6FFE"], [63877, 1, "\u792A"], [63878, 1, "\u95AD"], [63879, 1, "\u9A6A"], [63880, 1, "\u9E97"], [63881, 1, "\u9ECE"], [63882, 1, "\u529B"], [63883, 1, "\u66C6"], [63884, 1, "\u6B77"], [63885, 1, "\u8F62"], [63886, 1, "\u5E74"], [63887, 1, "\u6190"], [63888, 1, "\u6200"], [63889, 1, "\u649A"], [63890, 1, "\u6F23"], [63891, 1, "\u7149"], [63892, 1, "\u7489"], [63893, 1, "\u79CA"], [63894, 1, "\u7DF4"], [63895, 1, "\u806F"], [63896, 1, "\u8F26"], [63897, 1, "\u84EE"], [63898, 1, "\u9023"], [63899, 1, "\u934A"], [63900, 1, "\u5217"], [63901, 1, "\u52A3"], [63902, 1, "\u54BD"], [63903, 1, "\u70C8"], [63904, 1, "\u88C2"], [63905, 1, "\u8AAA"], [63906, 1, "\u5EC9"], [63907, 1, "\u5FF5"], [63908, 1, "\u637B"], [63909, 1, "\u6BAE"], [63910, 1, "\u7C3E"], [63911, 1, "\u7375"], [63912, 1, "\u4EE4"], [63913, 1, "\u56F9"], [63914, 1, "\u5BE7"], [63915, 1, "\u5DBA"], [63916, 1, "\u601C"], [63917, 1, "\u73B2"], [63918, 1, "\u7469"], [63919, 1, "\u7F9A"], [63920, 1, "\u8046"], [63921, 1, "\u9234"], [63922, 1, "\u96F6"], [63923, 1, "\u9748"], [63924, 1, "\u9818"], [63925, 1, "\u4F8B"], [63926, 1, "\u79AE"], [63927, 1, "\u91B4"], [63928, 1, "\u96B8"], [63929, 1, "\u60E1"], [63930, 1, "\u4E86"], [63931, 1, "\u50DA"], [63932, 1, "\u5BEE"], [63933, 1, "\u5C3F"], [63934, 1, "\u6599"], [63935, 1, "\u6A02"], [63936, 1, "\u71CE"], [63937, 1, "\u7642"], [63938, 1, "\u84FC"], [63939, 1, "\u907C"], [63940, 1, "\u9F8D"], [63941, 1, "\u6688"], [63942, 1, "\u962E"], [63943, 1, "\u5289"], [63944, 1, "\u677B"], [63945, 1, "\u67F3"], [63946, 1, "\u6D41"], [63947, 1, "\u6E9C"], [63948, 1, "\u7409"], [63949, 1, "\u7559"], [63950, 1, "\u786B"], [63951, 1, "\u7D10"], [63952, 1, "\u985E"], [63953, 1, "\u516D"], [63954, 1, "\u622E"], [63955, 1, "\u9678"], [63956, 1, "\u502B"], [63957, 1, "\u5D19"], [63958, 1, "\u6DEA"], [63959, 1, "\u8F2A"], [63960, 1, "\u5F8B"], [63961, 1, "\u6144"], [63962, 1, "\u6817"], [63963, 1, "\u7387"], [63964, 1, "\u9686"], [63965, 1, "\u5229"], [63966, 1, "\u540F"], [63967, 1, "\u5C65"], [63968, 1, "\u6613"], [63969, 1, "\u674E"], [63970, 1, "\u68A8"], [63971, 1, "\u6CE5"], [63972, 1, "\u7406"], [63973, 1, "\u75E2"], [63974, 1, "\u7F79"], [63975, 1, "\u88CF"], [63976, 1, "\u88E1"], [63977, 1, "\u91CC"], [63978, 1, "\u96E2"], [63979, 1, "\u533F"], [63980, 1, "\u6EBA"], [63981, 1, "\u541D"], [63982, 1, "\u71D0"], [63983, 1, "\u7498"], [63984, 1, "\u85FA"], [63985, 1, "\u96A3"], [63986, 1, "\u9C57"], [63987, 1, "\u9E9F"], [63988, 1, "\u6797"], [63989, 1, "\u6DCB"], [63990, 1, "\u81E8"], [63991, 1, "\u7ACB"], [63992, 1, "\u7B20"], [63993, 1, "\u7C92"], [63994, 1, "\u72C0"], [63995, 1, "\u7099"], [63996, 1, "\u8B58"], [63997, 1, "\u4EC0"], [63998, 1, "\u8336"], [63999, 1, "\u523A"], [64e3, 1, "\u5207"], [64001, 1, "\u5EA6"], [64002, 1, "\u62D3"], [64003, 1, "\u7CD6"], [64004, 1, "\u5B85"], [64005, 1, "\u6D1E"], [64006, 1, "\u66B4"], [64007, 1, "\u8F3B"], [64008, 1, "\u884C"], [64009, 1, "\u964D"], [64010, 1, "\u898B"], [64011, 1, "\u5ED3"], [64012, 1, "\u5140"], [64013, 1, "\u55C0"], [[64014, 64015], 2], [64016, 1, "\u585A"], [64017, 2], [64018, 1, "\u6674"], [[64019, 64020], 2], [64021, 1, "\u51DE"], [64022, 1, "\u732A"], [64023, 1, "\u76CA"], [64024, 1, "\u793C"], [64025, 1, "\u795E"], [64026, 1, "\u7965"], [64027, 1, "\u798F"], [64028, 1, "\u9756"], [64029, 1, "\u7CBE"], [64030, 1, "\u7FBD"], [64031, 2], [64032, 1, "\u8612"], [64033, 2], [64034, 1, "\u8AF8"], [[64035, 64036], 2], [64037, 1, "\u9038"], [64038, 1, "\u90FD"], [[64039, 64041], 2], [64042, 1, "\u98EF"], [64043, 1, "\u98FC"], [64044, 1, "\u9928"], [64045, 1, "\u9DB4"], [64046, 1, "\u90DE"], [64047, 1, "\u96B7"], [64048, 1, "\u4FAE"], [64049, 1, "\u50E7"], [64050, 1, "\u514D"], [64051, 1, "\u52C9"], [64052, 1, "\u52E4"], [64053, 1, "\u5351"], [64054, 1, "\u559D"], [64055, 1, "\u5606"], [64056, 1, "\u5668"], [64057, 1, "\u5840"], [64058, 1, "\u58A8"], [64059, 1, "\u5C64"], [64060, 1, "\u5C6E"], [64061, 1, "\u6094"], [64062, 1, "\u6168"], [64063, 1, "\u618E"], [64064, 1, "\u61F2"], [64065, 1, "\u654F"], [64066, 1, "\u65E2"], [64067, 1, "\u6691"], [64068, 1, "\u6885"], [64069, 1, "\u6D77"], [64070, 1, "\u6E1A"], [64071, 1, "\u6F22"], [64072, 1, "\u716E"], [64073, 1, "\u722B"], [64074, 1, "\u7422"], [64075, 1, "\u7891"], [64076, 1, "\u793E"], [64077, 1, "\u7949"], [64078, 1, "\u7948"], [64079, 1, "\u7950"], [64080, 1, "\u7956"], [64081, 1, "\u795D"], [64082, 1, "\u798D"], [64083, 1, "\u798E"], [64084, 1, "\u7A40"], [64085, 1, "\u7A81"], [64086, 1, "\u7BC0"], [64087, 1, "\u7DF4"], [64088, 1, "\u7E09"], [64089, 1, "\u7E41"], [64090, 1, "\u7F72"], [64091, 1, "\u8005"], [64092, 1, "\u81ED"], [[64093, 64094], 1, "\u8279"], [64095, 1, "\u8457"], [64096, 1, "\u8910"], [64097, 1, "\u8996"], [64098, 1, "\u8B01"], [64099, 1, "\u8B39"], [64100, 1, "\u8CD3"], [64101, 1, "\u8D08"], [64102, 1, "\u8FB6"], [64103, 1, "\u9038"], [64104, 1, "\u96E3"], [64105, 1, "\u97FF"], [64106, 1, "\u983B"], [64107, 1, "\u6075"], [64108, 1, "\u{242EE}"], [64109, 1, "\u8218"], [[64110, 64111], 3], [64112, 1, "\u4E26"], [64113, 1, "\u51B5"], [64114, 1, "\u5168"], [64115, 1, "\u4F80"], [64116, 1, "\u5145"], [64117, 1, "\u5180"], [64118, 1, "\u52C7"], [64119, 1, "\u52FA"], [64120, 1, "\u559D"], [64121, 1, "\u5555"], [64122, 1, "\u5599"], [64123, 1, "\u55E2"], [64124, 1, "\u585A"], [64125, 1, "\u58B3"], [64126, 1, "\u5944"], [64127, 1, "\u5954"], [64128, 1, "\u5A62"], [64129, 1, "\u5B28"], [64130, 1, "\u5ED2"], [64131, 1, "\u5ED9"], [64132, 1, "\u5F69"], [64133, 1, "\u5FAD"], [64134, 1, "\u60D8"], [64135, 1, "\u614E"], [64136, 1, "\u6108"], [64137, 1, "\u618E"], [64138, 1, "\u6160"], [64139, 1, "\u61F2"], [64140, 1, "\u6234"], [64141, 1, "\u63C4"], [64142, 1, "\u641C"], [64143, 1, "\u6452"], [64144, 1, "\u6556"], [64145, 1, "\u6674"], [64146, 1, "\u6717"], [64147, 1, "\u671B"], [64148, 1, "\u6756"], [64149, 1, "\u6B79"], [64150, 1, "\u6BBA"], [64151, 1, "\u6D41"], [64152, 1, "\u6EDB"], [64153, 1, "\u6ECB"], [64154, 1, "\u6F22"], [64155, 1, "\u701E"], [64156, 1, "\u716E"], [64157, 1, "\u77A7"], [64158, 1, "\u7235"], [64159, 1, "\u72AF"], [64160, 1, "\u732A"], [64161, 1, "\u7471"], [64162, 1, "\u7506"], [64163, 1, "\u753B"], [64164, 1, "\u761D"], [64165, 1, "\u761F"], [64166, 1, "\u76CA"], [64167, 1, "\u76DB"], [64168, 1, "\u76F4"], [64169, 1, "\u774A"], [64170, 1, "\u7740"], [64171, 1, "\u78CC"], [64172, 1, "\u7AB1"], [64173, 1, "\u7BC0"], [64174, 1, "\u7C7B"], [64175, 1, "\u7D5B"], [64176, 1, "\u7DF4"], [64177, 1, "\u7F3E"], [64178, 1, "\u8005"], [64179, 1, "\u8352"], [64180, 1, "\u83EF"], [64181, 1, "\u8779"], [64182, 1, "\u8941"], [64183, 1, "\u8986"], [64184, 1, "\u8996"], [64185, 1, "\u8ABF"], [64186, 1, "\u8AF8"], [64187, 1, "\u8ACB"], [64188, 1, "\u8B01"], [64189, 1, "\u8AFE"], [64190, 1, "\u8AED"], [64191, 1, "\u8B39"], [64192, 1, "\u8B8A"], [64193, 1, "\u8D08"], [64194, 1, "\u8F38"], [64195, 1, "\u9072"], [64196, 1, "\u9199"], [64197, 1, "\u9276"], [64198, 1, "\u967C"], [64199, 1, "\u96E3"], [64200, 1, "\u9756"], [64201, 1, "\u97DB"], [64202, 1, "\u97FF"], [64203, 1, "\u980B"], [64204, 1, "\u983B"], [64205, 1, "\u9B12"], [64206, 1, "\u9F9C"], [64207, 1, "\u{2284A}"], [64208, 1, "\u{22844}"], [64209, 1, "\u{233D5}"], [64210, 1, "\u3B9D"], [64211, 1, "\u4018"], [64212, 1, "\u4039"], [64213, 1, "\u{25249}"], [64214, 1, "\u{25CD0}"], [64215, 1, "\u{27ED3}"], [64216, 1, "\u9F43"], [64217, 1, "\u9F8E"], [[64218, 64255], 3], [64256, 1, "ff"], [64257, 1, "fi"], [64258, 1, "fl"], [64259, 1, "ffi"], [64260, 1, "ffl"], [[64261, 64262], 1, "st"], [[64263, 64274], 3], [64275, 1, "\u0574\u0576"], [64276, 1, "\u0574\u0565"], [64277, 1, "\u0574\u056B"], [64278, 1, "\u057E\u0576"], [64279, 1, "\u0574\u056D"], [[64280, 64284], 3], [64285, 1, "\u05D9\u05B4"], [64286, 2], [64287, 1, "\u05F2\u05B7"], [64288, 1, "\u05E2"], [64289, 1, "\u05D0"], [64290, 1, "\u05D3"], [64291, 1, "\u05D4"], [64292, 1, "\u05DB"], [64293, 1, "\u05DC"], [64294, 1, "\u05DD"], [64295, 1, "\u05E8"], [64296, 1, "\u05EA"], [64297, 5, "+"], [64298, 1, "\u05E9\u05C1"], [64299, 1, "\u05E9\u05C2"], [64300, 1, "\u05E9\u05BC\u05C1"], [64301, 1, "\u05E9\u05BC\u05C2"], [64302, 1, "\u05D0\u05B7"], [64303, 1, "\u05D0\u05B8"], [64304, 1, "\u05D0\u05BC"], [64305, 1, "\u05D1\u05BC"], [64306, 1, "\u05D2\u05BC"], [64307, 1, "\u05D3\u05BC"], [64308, 1, "\u05D4\u05BC"], [64309, 1, "\u05D5\u05BC"], [64310, 1, "\u05D6\u05BC"], [64311, 3], [64312, 1, "\u05D8\u05BC"], [64313, 1, "\u05D9\u05BC"], [64314, 1, "\u05DA\u05BC"], [64315, 1, "\u05DB\u05BC"], [64316, 1, "\u05DC\u05BC"], [64317, 3], [64318, 1, "\u05DE\u05BC"], [64319, 3], [64320, 1, "\u05E0\u05BC"], [64321, 1, "\u05E1\u05BC"], [64322, 3], [64323, 1, "\u05E3\u05BC"], [64324, 1, "\u05E4\u05BC"], [64325, 3], [64326, 1, "\u05E6\u05BC"], [64327, 1, "\u05E7\u05BC"], [64328, 1, "\u05E8\u05BC"], [64329, 1, "\u05E9\u05BC"], [64330, 1, "\u05EA\u05BC"], [64331, 1, "\u05D5\u05B9"], [64332, 1, "\u05D1\u05BF"], [64333, 1, "\u05DB\u05BF"], [64334, 1, "\u05E4\u05BF"], [64335, 1, "\u05D0\u05DC"], [[64336, 64337], 1, "\u0671"], [[64338, 64341], 1, "\u067B"], [[64342, 64345], 1, "\u067E"], [[64346, 64349], 1, "\u0680"], [[64350, 64353], 1, "\u067A"], [[64354, 64357], 1, "\u067F"], [[64358, 64361], 1, "\u0679"], [[64362, 64365], 1, "\u06A4"], [[64366, 64369], 1, "\u06A6"], [[64370, 64373], 1, "\u0684"], [[64374, 64377], 1, "\u0683"], [[64378, 64381], 1, "\u0686"], [[64382, 64385], 1, "\u0687"], [[64386, 64387], 1, "\u068D"], [[64388, 64389], 1, "\u068C"], [[64390, 64391], 1, "\u068E"], [[64392, 64393], 1, "\u0688"], [[64394, 64395], 1, "\u0698"], [[64396, 64397], 1, "\u0691"], [[64398, 64401], 1, "\u06A9"], [[64402, 64405], 1, "\u06AF"], [[64406, 64409], 1, "\u06B3"], [[64410, 64413], 1, "\u06B1"], [[64414, 64415], 1, "\u06BA"], [[64416, 64419], 1, "\u06BB"], [[64420, 64421], 1, "\u06C0"], [[64422, 64425], 1, "\u06C1"], [[64426, 64429], 1, "\u06BE"], [[64430, 64431], 1, "\u06D2"], [[64432, 64433], 1, "\u06D3"], [[64434, 64449], 2], [64450, 2], [[64451, 64466], 3], [[64467, 64470], 1, "\u06AD"], [[64471, 64472], 1, "\u06C7"], [[64473, 64474], 1, "\u06C6"], [[64475, 64476], 1, "\u06C8"], [64477, 1, "\u06C7\u0674"], [[64478, 64479], 1, "\u06CB"], [[64480, 64481], 1, "\u06C5"], [[64482, 64483], 1, "\u06C9"], [[64484, 64487], 1, "\u06D0"], [[64488, 64489], 1, "\u0649"], [[64490, 64491], 1, "\u0626\u0627"], [[64492, 64493], 1, "\u0626\u06D5"], [[64494, 64495], 1, "\u0626\u0648"], [[64496, 64497], 1, "\u0626\u06C7"], [[64498, 64499], 1, "\u0626\u06C6"], [[64500, 64501], 1, "\u0626\u06C8"], [[64502, 64504], 1, "\u0626\u06D0"], [[64505, 64507], 1, "\u0626\u0649"], [[64508, 64511], 1, "\u06CC"], [64512, 1, "\u0626\u062C"], [64513, 1, "\u0626\u062D"], [64514, 1, "\u0626\u0645"], [64515, 1, "\u0626\u0649"], [64516, 1, "\u0626\u064A"], [64517, 1, "\u0628\u062C"], [64518, 1, "\u0628\u062D"], [64519, 1, "\u0628\u062E"], [64520, 1, "\u0628\u0645"], [64521, 1, "\u0628\u0649"], [64522, 1, "\u0628\u064A"], [64523, 1, "\u062A\u062C"], [64524, 1, "\u062A\u062D"], [64525, 1, "\u062A\u062E"], [64526, 1, "\u062A\u0645"], [64527, 1, "\u062A\u0649"], [64528, 1, "\u062A\u064A"], [64529, 1, "\u062B\u062C"], [64530, 1, "\u062B\u0645"], [64531, 1, "\u062B\u0649"], [64532, 1, "\u062B\u064A"], [64533, 1, "\u062C\u062D"], [64534, 1, "\u062C\u0645"], [64535, 1, "\u062D\u062C"], [64536, 1, "\u062D\u0645"], [64537, 1, "\u062E\u062C"], [64538, 1, "\u062E\u062D"], [64539, 1, "\u062E\u0645"], [64540, 1, "\u0633\u062C"], [64541, 1, "\u0633\u062D"], [64542, 1, "\u0633\u062E"], [64543, 1, "\u0633\u0645"], [64544, 1, "\u0635\u062D"], [64545, 1, "\u0635\u0645"], [64546, 1, "\u0636\u062C"], [64547, 1, "\u0636\u062D"], [64548, 1, "\u0636\u062E"], [64549, 1, "\u0636\u0645"], [64550, 1, "\u0637\u062D"], [64551, 1, "\u0637\u0645"], [64552, 1, "\u0638\u0645"], [64553, 1, "\u0639\u062C"], [64554, 1, "\u0639\u0645"], [64555, 1, "\u063A\u062C"], [64556, 1, "\u063A\u0645"], [64557, 1, "\u0641\u062C"], [64558, 1, "\u0641\u062D"], [64559, 1, "\u0641\u062E"], [64560, 1, "\u0641\u0645"], [64561, 1, "\u0641\u0649"], [64562, 1, "\u0641\u064A"], [64563, 1, "\u0642\u062D"], [64564, 1, "\u0642\u0645"], [64565, 1, "\u0642\u0649"], [64566, 1, "\u0642\u064A"], [64567, 1, "\u0643\u0627"], [64568, 1, "\u0643\u062C"], [64569, 1, "\u0643\u062D"], [64570, 1, "\u0643\u062E"], [64571, 1, "\u0643\u0644"], [64572, 1, "\u0643\u0645"], [64573, 1, "\u0643\u0649"], [64574, 1, "\u0643\u064A"], [64575, 1, "\u0644\u062C"], [64576, 1, "\u0644\u062D"], [64577, 1, "\u0644\u062E"], [64578, 1, "\u0644\u0645"], [64579, 1, "\u0644\u0649"], [64580, 1, "\u0644\u064A"], [64581, 1, "\u0645\u062C"], [64582, 1, "\u0645\u062D"], [64583, 1, "\u0645\u062E"], [64584, 1, "\u0645\u0645"], [64585, 1, "\u0645\u0649"], [64586, 1, "\u0645\u064A"], [64587, 1, "\u0646\u062C"], [64588, 1, "\u0646\u062D"], [64589, 1, "\u0646\u062E"], [64590, 1, "\u0646\u0645"], [64591, 1, "\u0646\u0649"], [64592, 1, "\u0646\u064A"], [64593, 1, "\u0647\u062C"], [64594, 1, "\u0647\u0645"], [64595, 1, "\u0647\u0649"], [64596, 1, "\u0647\u064A"], [64597, 1, "\u064A\u062C"], [64598, 1, "\u064A\u062D"], [64599, 1, "\u064A\u062E"], [64600, 1, "\u064A\u0645"], [64601, 1, "\u064A\u0649"], [64602, 1, "\u064A\u064A"], [64603, 1, "\u0630\u0670"], [64604, 1, "\u0631\u0670"], [64605, 1, "\u0649\u0670"], [64606, 5, " \u064C\u0651"], [64607, 5, " \u064D\u0651"], [64608, 5, " \u064E\u0651"], [64609, 5, " \u064F\u0651"], [64610, 5, " \u0650\u0651"], [64611, 5, " \u0651\u0670"], [64612, 1, "\u0626\u0631"], [64613, 1, "\u0626\u0632"], [64614, 1, "\u0626\u0645"], [64615, 1, "\u0626\u0646"], [64616, 1, "\u0626\u0649"], [64617, 1, "\u0626\u064A"], [64618, 1, "\u0628\u0631"], [64619, 1, "\u0628\u0632"], [64620, 1, "\u0628\u0645"], [64621, 1, "\u0628\u0646"], [64622, 1, "\u0628\u0649"], [64623, 1, "\u0628\u064A"], [64624, 1, "\u062A\u0631"], [64625, 1, "\u062A\u0632"], [64626, 1, "\u062A\u0645"], [64627, 1, "\u062A\u0646"], [64628, 1, "\u062A\u0649"], [64629, 1, "\u062A\u064A"], [64630, 1, "\u062B\u0631"], [64631, 1, "\u062B\u0632"], [64632, 1, "\u062B\u0645"], [64633, 1, "\u062B\u0646"], [64634, 1, "\u062B\u0649"], [64635, 1, "\u062B\u064A"], [64636, 1, "\u0641\u0649"], [64637, 1, "\u0641\u064A"], [64638, 1, "\u0642\u0649"], [64639, 1, "\u0642\u064A"], [64640, 1, "\u0643\u0627"], [64641, 1, "\u0643\u0644"], [64642, 1, "\u0643\u0645"], [64643, 1, "\u0643\u0649"], [64644, 1, "\u0643\u064A"], [64645, 1, "\u0644\u0645"], [64646, 1, "\u0644\u0649"], [64647, 1, "\u0644\u064A"], [64648, 1, "\u0645\u0627"], [64649, 1, "\u0645\u0645"], [64650, 1, "\u0646\u0631"], [64651, 1, "\u0646\u0632"], [64652, 1, "\u0646\u0645"], [64653, 1, "\u0646\u0646"], [64654, 1, "\u0646\u0649"], [64655, 1, "\u0646\u064A"], [64656, 1, "\u0649\u0670"], [64657, 1, "\u064A\u0631"], [64658, 1, "\u064A\u0632"], [64659, 1, "\u064A\u0645"], [64660, 1, "\u064A\u0646"], [64661, 1, "\u064A\u0649"], [64662, 1, "\u064A\u064A"], [64663, 1, "\u0626\u062C"], [64664, 1, "\u0626\u062D"], [64665, 1, "\u0626\u062E"], [64666, 1, "\u0626\u0645"], [64667, 1, "\u0626\u0647"], [64668, 1, "\u0628\u062C"], [64669, 1, "\u0628\u062D"], [64670, 1, "\u0628\u062E"], [64671, 1, "\u0628\u0645"], [64672, 1, "\u0628\u0647"], [64673, 1, "\u062A\u062C"], [64674, 1, "\u062A\u062D"], [64675, 1, "\u062A\u062E"], [64676, 1, "\u062A\u0645"], [64677, 1, "\u062A\u0647"], [64678, 1, "\u062B\u0645"], [64679, 1, "\u062C\u062D"], [64680, 1, "\u062C\u0645"], [64681, 1, "\u062D\u062C"], [64682, 1, "\u062D\u0645"], [64683, 1, "\u062E\u062C"], [64684, 1, "\u062E\u0645"], [64685, 1, "\u0633\u062C"], [64686, 1, "\u0633\u062D"], [64687, 1, "\u0633\u062E"], [64688, 1, "\u0633\u0645"], [64689, 1, "\u0635\u062D"], [64690, 1, "\u0635\u062E"], [64691, 1, "\u0635\u0645"], [64692, 1, "\u0636\u062C"], [64693, 1, "\u0636\u062D"], [64694, 1, "\u0636\u062E"], [64695, 1, "\u0636\u0645"], [64696, 1, "\u0637\u062D"], [64697, 1, "\u0638\u0645"], [64698, 1, "\u0639\u062C"], [64699, 1, "\u0639\u0645"], [64700, 1, "\u063A\u062C"], [64701, 1, "\u063A\u0645"], [64702, 1, "\u0641\u062C"], [64703, 1, "\u0641\u062D"], [64704, 1, "\u0641\u062E"], [64705, 1, "\u0641\u0645"], [64706, 1, "\u0642\u062D"], [64707, 1, "\u0642\u0645"], [64708, 1, "\u0643\u062C"], [64709, 1, "\u0643\u062D"], [64710, 1, "\u0643\u062E"], [64711, 1, "\u0643\u0644"], [64712, 1, "\u0643\u0645"], [64713, 1, "\u0644\u062C"], [64714, 1, "\u0644\u062D"], [64715, 1, "\u0644\u062E"], [64716, 1, "\u0644\u0645"], [64717, 1, "\u0644\u0647"], [64718, 1, "\u0645\u062C"], [64719, 1, "\u0645\u062D"], [64720, 1, "\u0645\u062E"], [64721, 1, "\u0645\u0645"], [64722, 1, "\u0646\u062C"], [64723, 1, "\u0646\u062D"], [64724, 1, "\u0646\u062E"], [64725, 1, "\u0646\u0645"], [64726, 1, "\u0646\u0647"], [64727, 1, "\u0647\u062C"], [64728, 1, "\u0647\u0645"], [64729, 1, "\u0647\u0670"], [64730, 1, "\u064A\u062C"], [64731, 1, "\u064A\u062D"], [64732, 1, "\u064A\u062E"], [64733, 1, "\u064A\u0645"], [64734, 1, "\u064A\u0647"], [64735, 1, "\u0626\u0645"], [64736, 1, "\u0626\u0647"], [64737, 1, "\u0628\u0645"], [64738, 1, "\u0628\u0647"], [64739, 1, "\u062A\u0645"], [64740, 1, "\u062A\u0647"], [64741, 1, "\u062B\u0645"], [64742, 1, "\u062B\u0647"], [64743, 1, "\u0633\u0645"], [64744, 1, "\u0633\u0647"], [64745, 1, "\u0634\u0645"], [64746, 1, "\u0634\u0647"], [64747, 1, "\u0643\u0644"], [64748, 1, "\u0643\u0645"], [64749, 1, "\u0644\u0645"], [64750, 1, "\u0646\u0645"], [64751, 1, "\u0646\u0647"], [64752, 1, "\u064A\u0645"], [64753, 1, "\u064A\u0647"], [64754, 1, "\u0640\u064E\u0651"], [64755, 1, "\u0640\u064F\u0651"], [64756, 1, "\u0640\u0650\u0651"], [64757, 1, "\u0637\u0649"], [64758, 1, "\u0637\u064A"], [64759, 1, "\u0639\u0649"], [64760, 1, "\u0639\u064A"], [64761, 1, "\u063A\u0649"], [64762, 1, "\u063A\u064A"], [64763, 1, "\u0633\u0649"], [64764, 1, "\u0633\u064A"], [64765, 1, "\u0634\u0649"], [64766, 1, "\u0634\u064A"], [64767, 1, "\u062D\u0649"], [64768, 1, "\u062D\u064A"], [64769, 1, "\u062C\u0649"], [64770, 1, "\u062C\u064A"], [64771, 1, "\u062E\u0649"], [64772, 1, "\u062E\u064A"], [64773, 1, "\u0635\u0649"], [64774, 1, "\u0635\u064A"], [64775, 1, "\u0636\u0649"], [64776, 1, "\u0636\u064A"], [64777, 1, "\u0634\u062C"], [64778, 1, "\u0634\u062D"], [64779, 1, "\u0634\u062E"], [64780, 1, "\u0634\u0645"], [64781, 1, "\u0634\u0631"], [64782, 1, "\u0633\u0631"], [64783, 1, "\u0635\u0631"], [64784, 1, "\u0636\u0631"], [64785, 1, "\u0637\u0649"], [64786, 1, "\u0637\u064A"], [64787, 1, "\u0639\u0649"], [64788, 1, "\u0639\u064A"], [64789, 1, "\u063A\u0649"], [64790, 1, "\u063A\u064A"], [64791, 1, "\u0633\u0649"], [64792, 1, "\u0633\u064A"], [64793, 1, "\u0634\u0649"], [64794, 1, "\u0634\u064A"], [64795, 1, "\u062D\u0649"], [64796, 1, "\u062D\u064A"], [64797, 1, "\u062C\u0649"], [64798, 1, "\u062C\u064A"], [64799, 1, "\u062E\u0649"], [64800, 1, "\u062E\u064A"], [64801, 1, "\u0635\u0649"], [64802, 1, "\u0635\u064A"], [64803, 1, "\u0636\u0649"], [64804, 1, "\u0636\u064A"], [64805, 1, "\u0634\u062C"], [64806, 1, "\u0634\u062D"], [64807, 1, "\u0634\u062E"], [64808, 1, "\u0634\u0645"], [64809, 1, "\u0634\u0631"], [64810, 1, "\u0633\u0631"], [64811, 1, "\u0635\u0631"], [64812, 1, "\u0636\u0631"], [64813, 1, "\u0634\u062C"], [64814, 1, "\u0634\u062D"], [64815, 1, "\u0634\u062E"], [64816, 1, "\u0634\u0645"], [64817, 1, "\u0633\u0647"], [64818, 1, "\u0634\u0647"], [64819, 1, "\u0637\u0645"], [64820, 1, "\u0633\u062C"], [64821, 1, "\u0633\u062D"], [64822, 1, "\u0633\u062E"], [64823, 1, "\u0634\u062C"], [64824, 1, "\u0634\u062D"], [64825, 1, "\u0634\u062E"], [64826, 1, "\u0637\u0645"], [64827, 1, "\u0638\u0645"], [[64828, 64829], 1, "\u0627\u064B"], [[64830, 64831], 2], [[64832, 64847], 2], [64848, 1, "\u062A\u062C\u0645"], [[64849, 64850], 1, "\u062A\u062D\u062C"], [64851, 1, "\u062A\u062D\u0645"], [64852, 1, "\u062A\u062E\u0645"], [64853, 1, "\u062A\u0645\u062C"], [64854, 1, "\u062A\u0645\u062D"], [64855, 1, "\u062A\u0645\u062E"], [[64856, 64857], 1, "\u062C\u0645\u062D"], [64858, 1, "\u062D\u0645\u064A"], [64859, 1, "\u062D\u0645\u0649"], [64860, 1, "\u0633\u062D\u062C"], [64861, 1, "\u0633\u062C\u062D"], [64862, 1, "\u0633\u062C\u0649"], [[64863, 64864], 1, "\u0633\u0645\u062D"], [64865, 1, "\u0633\u0645\u062C"], [[64866, 64867], 1, "\u0633\u0645\u0645"], [[64868, 64869], 1, "\u0635\u062D\u062D"], [64870, 1, "\u0635\u0645\u0645"], [[64871, 64872], 1, "\u0634\u062D\u0645"], [64873, 1, "\u0634\u062C\u064A"], [[64874, 64875], 1, "\u0634\u0645\u062E"], [[64876, 64877], 1, "\u0634\u0645\u0645"], [64878, 1, "\u0636\u062D\u0649"], [[64879, 64880], 1, "\u0636\u062E\u0645"], [[64881, 64882], 1, "\u0637\u0645\u062D"], [64883, 1, "\u0637\u0645\u0645"], [64884, 1, "\u0637\u0645\u064A"], [64885, 1, "\u0639\u062C\u0645"], [[64886, 64887], 1, "\u0639\u0645\u0645"], [64888, 1, "\u0639\u0645\u0649"], [64889, 1, "\u063A\u0645\u0645"], [64890, 1, "\u063A\u0645\u064A"], [64891, 1, "\u063A\u0645\u0649"], [[64892, 64893], 1, "\u0641\u062E\u0645"], [64894, 1, "\u0642\u0645\u062D"], [64895, 1, "\u0642\u0645\u0645"], [64896, 1, "\u0644\u062D\u0645"], [64897, 1, "\u0644\u062D\u064A"], [64898, 1, "\u0644\u062D\u0649"], [[64899, 64900], 1, "\u0644\u062C\u062C"], [[64901, 64902], 1, "\u0644\u062E\u0645"], [[64903, 64904], 1, "\u0644\u0645\u062D"], [64905, 1, "\u0645\u062D\u062C"], [64906, 1, "\u0645\u062D\u0645"], [64907, 1, "\u0645\u062D\u064A"], [64908, 1, "\u0645\u062C\u062D"], [64909, 1, "\u0645\u062C\u0645"], [64910, 1, "\u0645\u062E\u062C"], [64911, 1, "\u0645\u062E\u0645"], [[64912, 64913], 3], [64914, 1, "\u0645\u062C\u062E"], [64915, 1, "\u0647\u0645\u062C"], [64916, 1, "\u0647\u0645\u0645"], [64917, 1, "\u0646\u062D\u0645"], [64918, 1, "\u0646\u062D\u0649"], [[64919, 64920], 1, "\u0646\u062C\u0645"], [64921, 1, "\u0646\u062C\u0649"], [64922, 1, "\u0646\u0645\u064A"], [64923, 1, "\u0646\u0645\u0649"], [[64924, 64925], 1, "\u064A\u0645\u0645"], [64926, 1, "\u0628\u062E\u064A"], [64927, 1, "\u062A\u062C\u064A"], [64928, 1, "\u062A\u062C\u0649"], [64929, 1, "\u062A\u062E\u064A"], [64930, 1, "\u062A\u062E\u0649"], [64931, 1, "\u062A\u0645\u064A"], [64932, 1, "\u062A\u0645\u0649"], [64933, 1, "\u062C\u0645\u064A"], [64934, 1, "\u062C\u062D\u0649"], [64935, 1, "\u062C\u0645\u0649"], [64936, 1, "\u0633\u062E\u0649"], [64937, 1, "\u0635\u062D\u064A"], [64938, 1, "\u0634\u062D\u064A"], [64939, 1, "\u0636\u062D\u064A"], [64940, 1, "\u0644\u062C\u064A"], [64941, 1, "\u0644\u0645\u064A"], [64942, 1, "\u064A\u062D\u064A"], [64943, 1, "\u064A\u062C\u064A"], [64944, 1, "\u064A\u0645\u064A"], [64945, 1, "\u0645\u0645\u064A"], [64946, 1, "\u0642\u0645\u064A"], [64947, 1, "\u0646\u062D\u064A"], [64948, 1, "\u0642\u0645\u062D"], [64949, 1, "\u0644\u062D\u0645"], [64950, 1, "\u0639\u0645\u064A"], [64951, 1, "\u0643\u0645\u064A"], [64952, 1, "\u0646\u062C\u062D"], [64953, 1, "\u0645\u062E\u064A"], [64954, 1, "\u0644\u062C\u0645"], [64955, 1, "\u0643\u0645\u0645"], [64956, 1, "\u0644\u062C\u0645"], [64957, 1, "\u0646\u062C\u062D"], [64958, 1, "\u062C\u062D\u064A"], [64959, 1, "\u062D\u062C\u064A"], [64960, 1, "\u0645\u062C\u064A"], [64961, 1, "\u0641\u0645\u064A"], [64962, 1, "\u0628\u062D\u064A"], [64963, 1, "\u0643\u0645\u0645"], [64964, 1, "\u0639\u062C\u0645"], [64965, 1, "\u0635\u0645\u0645"], [64966, 1, "\u0633\u062E\u064A"], [64967, 1, "\u0646\u062C\u064A"], [[64968, 64974], 3], [64975, 2], [[64976, 65007], 3], [65008, 1, "\u0635\u0644\u06D2"], [65009, 1, "\u0642\u0644\u06D2"], [65010, 1, "\u0627\u0644\u0644\u0647"], [65011, 1, "\u0627\u0643\u0628\u0631"], [65012, 1, "\u0645\u062D\u0645\u062F"], [65013, 1, "\u0635\u0644\u0639\u0645"], [65014, 1, "\u0631\u0633\u0648\u0644"], [65015, 1, "\u0639\u0644\u064A\u0647"], [65016, 1, "\u0648\u0633\u0644\u0645"], [65017, 1, "\u0635\u0644\u0649"], [65018, 5, "\u0635\u0644\u0649 \u0627\u0644\u0644\u0647 \u0639\u0644\u064A\u0647 \u0648\u0633\u0644\u0645"], [65019, 5, "\u062C\u0644 \u062C\u0644\u0627\u0644\u0647"], [65020, 1, "\u0631\u06CC\u0627\u0644"], [65021, 2], [[65022, 65023], 2], [[65024, 65039], 7], [65040, 5, ","], [65041, 1, "\u3001"], [65042, 3], [65043, 5, ":"], [65044, 5, ";"], [65045, 5, "!"], [65046, 5, "?"], [65047, 1, "\u3016"], [65048, 1, "\u3017"], [65049, 3], [[65050, 65055], 3], [[65056, 65059], 2], [[65060, 65062], 2], [[65063, 65069], 2], [[65070, 65071], 2], [65072, 3], [65073, 1, "\u2014"], [65074, 1, "\u2013"], [[65075, 65076], 5, "_"], [65077, 5, "("], [65078, 5, ")"], [65079, 5, "{"], [65080, 5, "}"], [65081, 1, "\u3014"], [65082, 1, "\u3015"], [65083, 1, "\u3010"], [65084, 1, "\u3011"], [65085, 1, "\u300A"], [65086, 1, "\u300B"], [65087, 1, "\u3008"], [65088, 1, "\u3009"], [65089, 1, "\u300C"], [65090, 1, "\u300D"], [65091, 1, "\u300E"], [65092, 1, "\u300F"], [[65093, 65094], 2], [65095, 5, "["], [65096, 5, "]"], [[65097, 65100], 5, " \u0305"], [[65101, 65103], 5, "_"], [65104, 5, ","], [65105, 1, "\u3001"], [65106, 3], [65107, 3], [65108, 5, ";"], [65109, 5, ":"], [65110, 5, "?"], [65111, 5, "!"], [65112, 1, "\u2014"], [65113, 5, "("], [65114, 5, ")"], [65115, 5, "{"], [65116, 5, "}"], [65117, 1, "\u3014"], [65118, 1, "\u3015"], [65119, 5, "#"], [65120, 5, "&"], [65121, 5, "*"], [65122, 5, "+"], [65123, 1, "-"], [65124, 5, "<"], [65125, 5, ">"], [65126, 5, "="], [65127, 3], [65128, 5, "\\"], [65129, 5, "$"], [65130, 5, "%"], [65131, 5, "@"], [[65132, 65135], 3], [65136, 5, " \u064B"], [65137, 1, "\u0640\u064B"], [65138, 5, " \u064C"], [65139, 2], [65140, 5, " \u064D"], [65141, 3], [65142, 5, " \u064E"], [65143, 1, "\u0640\u064E"], [65144, 5, " \u064F"], [65145, 1, "\u0640\u064F"], [65146, 5, " \u0650"], [65147, 1, "\u0640\u0650"], [65148, 5, " \u0651"], [65149, 1, "\u0640\u0651"], [65150, 5, " \u0652"], [65151, 1, "\u0640\u0652"], [65152, 1, "\u0621"], [[65153, 65154], 1, "\u0622"], [[65155, 65156], 1, "\u0623"], [[65157, 65158], 1, "\u0624"], [[65159, 65160], 1, "\u0625"], [[65161, 65164], 1, "\u0626"], [[65165, 65166], 1, "\u0627"], [[65167, 65170], 1, "\u0628"], [[65171, 65172], 1, "\u0629"], [[65173, 65176], 1, "\u062A"], [[65177, 65180], 1, "\u062B"], [[65181, 65184], 1, "\u062C"], [[65185, 65188], 1, "\u062D"], [[65189, 65192], 1, "\u062E"], [[65193, 65194], 1, "\u062F"], [[65195, 65196], 1, "\u0630"], [[65197, 65198], 1, "\u0631"], [[65199, 65200], 1, "\u0632"], [[65201, 65204], 1, "\u0633"], [[65205, 65208], 1, "\u0634"], [[65209, 65212], 1, "\u0635"], [[65213, 65216], 1, "\u0636"], [[65217, 65220], 1, "\u0637"], [[65221, 65224], 1, "\u0638"], [[65225, 65228], 1, "\u0639"], [[65229, 65232], 1, "\u063A"], [[65233, 65236], 1, "\u0641"], [[65237, 65240], 1, "\u0642"], [[65241, 65244], 1, "\u0643"], [[65245, 65248], 1, "\u0644"], [[65249, 65252], 1, "\u0645"], [[65253, 65256], 1, "\u0646"], [[65257, 65260], 1, "\u0647"], [[65261, 65262], 1, "\u0648"], [[65263, 65264], 1, "\u0649"], [[65265, 65268], 1, "\u064A"], [[65269, 65270], 1, "\u0644\u0622"], [[65271, 65272], 1, "\u0644\u0623"], [[65273, 65274], 1, "\u0644\u0625"], [[65275, 65276], 1, "\u0644\u0627"], [[65277, 65278], 3], [65279, 7], [65280, 3], [65281, 5, "!"], [65282, 5, '"'], [65283, 5, "#"], [65284, 5, "$"], [65285, 5, "%"], [65286, 5, "&"], [65287, 5, "'"], [65288, 5, "("], [65289, 5, ")"], [65290, 5, "*"], [65291, 5, "+"], [65292, 5, ","], [65293, 1, "-"], [65294, 1, "."], [65295, 5, "/"], [65296, 1, "0"], [65297, 1, "1"], [65298, 1, "2"], [65299, 1, "3"], [65300, 1, "4"], [65301, 1, "5"], [65302, 1, "6"], [65303, 1, "7"], [65304, 1, "8"], [65305, 1, "9"], [65306, 5, ":"], [65307, 5, ";"], [65308, 5, "<"], [65309, 5, "="], [65310, 5, ">"], [65311, 5, "?"], [65312, 5, "@"], [65313, 1, "a"], [65314, 1, "b"], [65315, 1, "c"], [65316, 1, "d"], [65317, 1, "e"], [65318, 1, "f"], [65319, 1, "g"], [65320, 1, "h"], [65321, 1, "i"], [65322, 1, "j"], [65323, 1, "k"], [65324, 1, "l"], [65325, 1, "m"], [65326, 1, "n"], [65327, 1, "o"], [65328, 1, "p"], [65329, 1, "q"], [65330, 1, "r"], [65331, 1, "s"], [65332, 1, "t"], [65333, 1, "u"], [65334, 1, "v"], [65335, 1, "w"], [65336, 1, "x"], [65337, 1, "y"], [65338, 1, "z"], [65339, 5, "["], [65340, 5, "\\"], [65341, 5, "]"], [65342, 5, "^"], [65343, 5, "_"], [65344, 5, "`"], [65345, 1, "a"], [65346, 1, "b"], [65347, 1, "c"], [65348, 1, "d"], [65349, 1, "e"], [65350, 1, "f"], [65351, 1, "g"], [65352, 1, "h"], [65353, 1, "i"], [65354, 1, "j"], [65355, 1, "k"], [65356, 1, "l"], [65357, 1, "m"], [65358, 1, "n"], [65359, 1, "o"], [65360, 1, "p"], [65361, 1, "q"], [65362, 1, "r"], [65363, 1, "s"], [65364, 1, "t"], [65365, 1, "u"], [65366, 1, "v"], [65367, 1, "w"], [65368, 1, "x"], [65369, 1, "y"], [65370, 1, "z"], [65371, 5, "{"], [65372, 5, "|"], [65373, 5, "}"], [65374, 5, "~"], [65375, 1, "\u2985"], [65376, 1, "\u2986"], [65377, 1, "."], [65378, 1, "\u300C"], [65379, 1, "\u300D"], [65380, 1, "\u3001"], [65381, 1, "\u30FB"], [65382, 1, "\u30F2"], [65383, 1, "\u30A1"], [65384, 1, "\u30A3"], [65385, 1, "\u30A5"], [65386, 1, "\u30A7"], [65387, 1, "\u30A9"], [65388, 1, "\u30E3"], [65389, 1, "\u30E5"], [65390, 1, "\u30E7"], [65391, 1, "\u30C3"], [65392, 1, "\u30FC"], [65393, 1, "\u30A2"], [65394, 1, "\u30A4"], [65395, 1, "\u30A6"], [65396, 1, "\u30A8"], [65397, 1, "\u30AA"], [65398, 1, "\u30AB"], [65399, 1, "\u30AD"], [65400, 1, "\u30AF"], [65401, 1, "\u30B1"], [65402, 1, "\u30B3"], [65403, 1, "\u30B5"], [65404, 1, "\u30B7"], [65405, 1, "\u30B9"], [65406, 1, "\u30BB"], [65407, 1, "\u30BD"], [65408, 1, "\u30BF"], [65409, 1, "\u30C1"], [65410, 1, "\u30C4"], [65411, 1, "\u30C6"], [65412, 1, "\u30C8"], [65413, 1, "\u30CA"], [65414, 1, "\u30CB"], [65415, 1, "\u30CC"], [65416, 1, "\u30CD"], [65417, 1, "\u30CE"], [65418, 1, "\u30CF"], [65419, 1, "\u30D2"], [65420, 1, "\u30D5"], [65421, 1, "\u30D8"], [65422, 1, "\u30DB"], [65423, 1, "\u30DE"], [65424, 1, "\u30DF"], [65425, 1, "\u30E0"], [65426, 1, "\u30E1"], [65427, 1, "\u30E2"], [65428, 1, "\u30E4"], [65429, 1, "\u30E6"], [65430, 1, "\u30E8"], [65431, 1, "\u30E9"], [65432, 1, "\u30EA"], [65433, 1, "\u30EB"], [65434, 1, "\u30EC"], [65435, 1, "\u30ED"], [65436, 1, "\u30EF"], [65437, 1, "\u30F3"], [65438, 1, "\u3099"], [65439, 1, "\u309A"], [65440, 3], [65441, 1, "\u1100"], [65442, 1, "\u1101"], [65443, 1, "\u11AA"], [65444, 1, "\u1102"], [65445, 1, "\u11AC"], [65446, 1, "\u11AD"], [65447, 1, "\u1103"], [65448, 1, "\u1104"], [65449, 1, "\u1105"], [65450, 1, "\u11B0"], [65451, 1, "\u11B1"], [65452, 1, "\u11B2"], [65453, 1, "\u11B3"], [65454, 1, "\u11B4"], [65455, 1, "\u11B5"], [65456, 1, "\u111A"], [65457, 1, "\u1106"], [65458, 1, "\u1107"], [65459, 1, "\u1108"], [65460, 1, "\u1121"], [65461, 1, "\u1109"], [65462, 1, "\u110A"], [65463, 1, "\u110B"], [65464, 1, "\u110C"], [65465, 1, "\u110D"], [65466, 1, "\u110E"], [65467, 1, "\u110F"], [65468, 1, "\u1110"], [65469, 1, "\u1111"], [65470, 1, "\u1112"], [[65471, 65473], 3], [65474, 1, "\u1161"], [65475, 1, "\u1162"], [65476, 1, "\u1163"], [65477, 1, "\u1164"], [65478, 1, "\u1165"], [65479, 1, "\u1166"], [[65480, 65481], 3], [65482, 1, "\u1167"], [65483, 1, "\u1168"], [65484, 1, "\u1169"], [65485, 1, "\u116A"], [65486, 1, "\u116B"], [65487, 1, "\u116C"], [[65488, 65489], 3], [65490, 1, "\u116D"], [65491, 1, "\u116E"], [65492, 1, "\u116F"], [65493, 1, "\u1170"], [65494, 1, "\u1171"], [65495, 1, "\u1172"], [[65496, 65497], 3], [65498, 1, "\u1173"], [65499, 1, "\u1174"], [65500, 1, "\u1175"], [[65501, 65503], 3], [65504, 1, "\xA2"], [65505, 1, "\xA3"], [65506, 1, "\xAC"], [65507, 5, " \u0304"], [65508, 1, "\xA6"], [65509, 1, "\xA5"], [65510, 1, "\u20A9"], [65511, 3], [65512, 1, "\u2502"], [65513, 1, "\u2190"], [65514, 1, "\u2191"], [65515, 1, "\u2192"], [65516, 1, "\u2193"], [65517, 1, "\u25A0"], [65518, 1, "\u25CB"], [[65519, 65528], 3], [[65529, 65531], 3], [65532, 3], [65533, 3], [[65534, 65535], 3], [[65536, 65547], 2], [65548, 3], [[65549, 65574], 2], [65575, 3], [[65576, 65594], 2], [65595, 3], [[65596, 65597], 2], [65598, 3], [[65599, 65613], 2], [[65614, 65615], 3], [[65616, 65629], 2], [[65630, 65663], 3], [[65664, 65786], 2], [[65787, 65791], 3], [[65792, 65794], 2], [[65795, 65798], 3], [[65799, 65843], 2], [[65844, 65846], 3], [[65847, 65855], 2], [[65856, 65930], 2], [[65931, 65932], 2], [[65933, 65934], 2], [65935, 3], [[65936, 65947], 2], [65948, 2], [[65949, 65951], 3], [65952, 2], [[65953, 65999], 3], [[66e3, 66044], 2], [66045, 2], [[66046, 66175], 3], [[66176, 66204], 2], [[66205, 66207], 3], [[66208, 66256], 2], [[66257, 66271], 3], [66272, 2], [[66273, 66299], 2], [[66300, 66303], 3], [[66304, 66334], 2], [66335, 2], [[66336, 66339], 2], [[66340, 66348], 3], [[66349, 66351], 2], [[66352, 66368], 2], [66369, 2], [[66370, 66377], 2], [66378, 2], [[66379, 66383], 3], [[66384, 66426], 2], [[66427, 66431], 3], [[66432, 66461], 2], [66462, 3], [66463, 2], [[66464, 66499], 2], [[66500, 66503], 3], [[66504, 66511], 2], [[66512, 66517], 2], [[66518, 66559], 3], [66560, 1, "\u{10428}"], [66561, 1, "\u{10429}"], [66562, 1, "\u{1042A}"], [66563, 1, "\u{1042B}"], [66564, 1, "\u{1042C}"], [66565, 1, "\u{1042D}"], [66566, 1, "\u{1042E}"], [66567, 1, "\u{1042F}"], [66568, 1, "\u{10430}"], [66569, 1, "\u{10431}"], [66570, 1, "\u{10432}"], [66571, 1, "\u{10433}"], [66572, 1, "\u{10434}"], [66573, 1, "\u{10435}"], [66574, 1, "\u{10436}"], [66575, 1, "\u{10437}"], [66576, 1, "\u{10438}"], [66577, 1, "\u{10439}"], [66578, 1, "\u{1043A}"], [66579, 1, "\u{1043B}"], [66580, 1, "\u{1043C}"], [66581, 1, "\u{1043D}"], [66582, 1, "\u{1043E}"], [66583, 1, "\u{1043F}"], [66584, 1, "\u{10440}"], [66585, 1, "\u{10441}"], [66586, 1, "\u{10442}"], [66587, 1, "\u{10443}"], [66588, 1, "\u{10444}"], [66589, 1, "\u{10445}"], [66590, 1, "\u{10446}"], [66591, 1, "\u{10447}"], [66592, 1, "\u{10448}"], [66593, 1, "\u{10449}"], [66594, 1, "\u{1044A}"], [66595, 1, "\u{1044B}"], [66596, 1, "\u{1044C}"], [66597, 1, "\u{1044D}"], [66598, 1, "\u{1044E}"], [66599, 1, "\u{1044F}"], [[66600, 66637], 2], [[66638, 66717], 2], [[66718, 66719], 3], [[66720, 66729], 2], [[66730, 66735], 3], [66736, 1, "\u{104D8}"], [66737, 1, "\u{104D9}"], [66738, 1, "\u{104DA}"], [66739, 1, "\u{104DB}"], [66740, 1, "\u{104DC}"], [66741, 1, "\u{104DD}"], [66742, 1, "\u{104DE}"], [66743, 1, "\u{104DF}"], [66744, 1, "\u{104E0}"], [66745, 1, "\u{104E1}"], [66746, 1, "\u{104E2}"], [66747, 1, "\u{104E3}"], [66748, 1, "\u{104E4}"], [66749, 1, "\u{104E5}"], [66750, 1, "\u{104E6}"], [66751, 1, "\u{104E7}"], [66752, 1, "\u{104E8}"], [66753, 1, "\u{104E9}"], [66754, 1, "\u{104EA}"], [66755, 1, "\u{104EB}"], [66756, 1, "\u{104EC}"], [66757, 1, "\u{104ED}"], [66758, 1, "\u{104EE}"], [66759, 1, "\u{104EF}"], [66760, 1, "\u{104F0}"], [66761, 1, "\u{104F1}"], [66762, 1, "\u{104F2}"], [66763, 1, "\u{104F3}"], [66764, 1, "\u{104F4}"], [66765, 1, "\u{104F5}"], [66766, 1, "\u{104F6}"], [66767, 1, "\u{104F7}"], [66768, 1, "\u{104F8}"], [66769, 1, "\u{104F9}"], [66770, 1, "\u{104FA}"], [66771, 1, "\u{104FB}"], [[66772, 66775], 3], [[66776, 66811], 2], [[66812, 66815], 3], [[66816, 66855], 2], [[66856, 66863], 3], [[66864, 66915], 2], [[66916, 66926], 3], [66927, 2], [66928, 1, "\u{10597}"], [66929, 1, "\u{10598}"], [66930, 1, "\u{10599}"], [66931, 1, "\u{1059A}"], [66932, 1, "\u{1059B}"], [66933, 1, "\u{1059C}"], [66934, 1, "\u{1059D}"], [66935, 1, "\u{1059E}"], [66936, 1, "\u{1059F}"], [66937, 1, "\u{105A0}"], [66938, 1, "\u{105A1}"], [66939, 3], [66940, 1, "\u{105A3}"], [66941, 1, "\u{105A4}"], [66942, 1, "\u{105A5}"], [66943, 1, "\u{105A6}"], [66944, 1, "\u{105A7}"], [66945, 1, "\u{105A8}"], [66946, 1, "\u{105A9}"], [66947, 1, "\u{105AA}"], [66948, 1, "\u{105AB}"], [66949, 1, "\u{105AC}"], [66950, 1, "\u{105AD}"], [66951, 1, "\u{105AE}"], [66952, 1, "\u{105AF}"], [66953, 1, "\u{105B0}"], [66954, 1, "\u{105B1}"], [66955, 3], [66956, 1, "\u{105B3}"], [66957, 1, "\u{105B4}"], [66958, 1, "\u{105B5}"], [66959, 1, "\u{105B6}"], [66960, 1, "\u{105B7}"], [66961, 1, "\u{105B8}"], [66962, 1, "\u{105B9}"], [66963, 3], [66964, 1, "\u{105BB}"], [66965, 1, "\u{105BC}"], [66966, 3], [[66967, 66977], 2], [66978, 3], [[66979, 66993], 2], [66994, 3], [[66995, 67001], 2], [67002, 3], [[67003, 67004], 2], [[67005, 67071], 3], [[67072, 67382], 2], [[67383, 67391], 3], [[67392, 67413], 2], [[67414, 67423], 3], [[67424, 67431], 2], [[67432, 67455], 3], [67456, 2], [67457, 1, "\u02D0"], [67458, 1, "\u02D1"], [67459, 1, "\xE6"], [67460, 1, "\u0299"], [67461, 1, "\u0253"], [67462, 3], [67463, 1, "\u02A3"], [67464, 1, "\uAB66"], [67465, 1, "\u02A5"], [67466, 1, "\u02A4"], [67467, 1, "\u0256"], [67468, 1, "\u0257"], [67469, 1, "\u1D91"], [67470, 1, "\u0258"], [67471, 1, "\u025E"], [67472, 1, "\u02A9"], [67473, 1, "\u0264"], [67474, 1, "\u0262"], [67475, 1, "\u0260"], [67476, 1, "\u029B"], [67477, 1, "\u0127"], [67478, 1, "\u029C"], [67479, 1, "\u0267"], [67480, 1, "\u0284"], [67481, 1, "\u02AA"], [67482, 1, "\u02AB"], [67483, 1, "\u026C"], [67484, 1, "\u{1DF04}"], [67485, 1, "\uA78E"], [67486, 1, "\u026E"], [67487, 1, "\u{1DF05}"], [67488, 1, "\u028E"], [67489, 1, "\u{1DF06}"], [67490, 1, "\xF8"], [67491, 1, "\u0276"], [67492, 1, "\u0277"], [67493, 1, "q"], [67494, 1, "\u027A"], [67495, 1, "\u{1DF08}"], [67496, 1, "\u027D"], [67497, 1, "\u027E"], [67498, 1, "\u0280"], [67499, 1, "\u02A8"], [67500, 1, "\u02A6"], [67501, 1, "\uAB67"], [67502, 1, "\u02A7"], [67503, 1, "\u0288"], [67504, 1, "\u2C71"], [67505, 3], [67506, 1, "\u028F"], [67507, 1, "\u02A1"], [67508, 1, "\u02A2"], [67509, 1, "\u0298"], [67510, 1, "\u01C0"], [67511, 1, "\u01C1"], [67512, 1, "\u01C2"], [67513, 1, "\u{1DF0A}"], [67514, 1, "\u{1DF1E}"], [[67515, 67583], 3], [[67584, 67589], 2], [[67590, 67591], 3], [67592, 2], [67593, 3], [[67594, 67637], 2], [67638, 3], [[67639, 67640], 2], [[67641, 67643], 3], [67644, 2], [[67645, 67646], 3], [67647, 2], [[67648, 67669], 2], [67670, 3], [[67671, 67679], 2], [[67680, 67702], 2], [[67703, 67711], 2], [[67712, 67742], 2], [[67743, 67750], 3], [[67751, 67759], 2], [[67760, 67807], 3], [[67808, 67826], 2], [67827, 3], [[67828, 67829], 2], [[67830, 67834], 3], [[67835, 67839], 2], [[67840, 67861], 2], [[67862, 67865], 2], [[67866, 67867], 2], [[67868, 67870], 3], [67871, 2], [[67872, 67897], 2], [[67898, 67902], 3], [67903, 2], [[67904, 67967], 3], [[67968, 68023], 2], [[68024, 68027], 3], [[68028, 68029], 2], [[68030, 68031], 2], [[68032, 68047], 2], [[68048, 68049], 3], [[68050, 68095], 2], [[68096, 68099], 2], [68100, 3], [[68101, 68102], 2], [[68103, 68107], 3], [[68108, 68115], 2], [68116, 3], [[68117, 68119], 2], [68120, 3], [[68121, 68147], 2], [[68148, 68149], 2], [[68150, 68151], 3], [[68152, 68154], 2], [[68155, 68158], 3], [68159, 2], [[68160, 68167], 2], [68168, 2], [[68169, 68175], 3], [[68176, 68184], 2], [[68185, 68191], 3], [[68192, 68220], 2], [[68221, 68223], 2], [[68224, 68252], 2], [[68253, 68255], 2], [[68256, 68287], 3], [[68288, 68295], 2], [68296, 2], [[68297, 68326], 2], [[68327, 68330], 3], [[68331, 68342], 2], [[68343, 68351], 3], [[68352, 68405], 2], [[68406, 68408], 3], [[68409, 68415], 2], [[68416, 68437], 2], [[68438, 68439], 3], [[68440, 68447], 2], [[68448, 68466], 2], [[68467, 68471], 3], [[68472, 68479], 2], [[68480, 68497], 2], [[68498, 68504], 3], [[68505, 68508], 2], [[68509, 68520], 3], [[68521, 68527], 2], [[68528, 68607], 3], [[68608, 68680], 2], [[68681, 68735], 3], [68736, 1, "\u{10CC0}"], [68737, 1, "\u{10CC1}"], [68738, 1, "\u{10CC2}"], [68739, 1, "\u{10CC3}"], [68740, 1, "\u{10CC4}"], [68741, 1, "\u{10CC5}"], [68742, 1, "\u{10CC6}"], [68743, 1, "\u{10CC7}"], [68744, 1, "\u{10CC8}"], [68745, 1, "\u{10CC9}"], [68746, 1, "\u{10CCA}"], [68747, 1, "\u{10CCB}"], [68748, 1, "\u{10CCC}"], [68749, 1, "\u{10CCD}"], [68750, 1, "\u{10CCE}"], [68751, 1, "\u{10CCF}"], [68752, 1, "\u{10CD0}"], [68753, 1, "\u{10CD1}"], [68754, 1, "\u{10CD2}"], [68755, 1, "\u{10CD3}"], [68756, 1, "\u{10CD4}"], [68757, 1, "\u{10CD5}"], [68758, 1, "\u{10CD6}"], [68759, 1, "\u{10CD7}"], [68760, 1, "\u{10CD8}"], [68761, 1, "\u{10CD9}"], [68762, 1, "\u{10CDA}"], [68763, 1, "\u{10CDB}"], [68764, 1, "\u{10CDC}"], [68765, 1, "\u{10CDD}"], [68766, 1, "\u{10CDE}"], [68767, 1, "\u{10CDF}"], [68768, 1, "\u{10CE0}"], [68769, 1, "\u{10CE1}"], [68770, 1, "\u{10CE2}"], [68771, 1, "\u{10CE3}"], [68772, 1, "\u{10CE4}"], [68773, 1, "\u{10CE5}"], [68774, 1, "\u{10CE6}"], [68775, 1, "\u{10CE7}"], [68776, 1, "\u{10CE8}"], [68777, 1, "\u{10CE9}"], [68778, 1, "\u{10CEA}"], [68779, 1, "\u{10CEB}"], [68780, 1, "\u{10CEC}"], [68781, 1, "\u{10CED}"], [68782, 1, "\u{10CEE}"], [68783, 1, "\u{10CEF}"], [68784, 1, "\u{10CF0}"], [68785, 1, "\u{10CF1}"], [68786, 1, "\u{10CF2}"], [[68787, 68799], 3], [[68800, 68850], 2], [[68851, 68857], 3], [[68858, 68863], 2], [[68864, 68903], 2], [[68904, 68911], 3], [[68912, 68921], 2], [[68922, 69215], 3], [[69216, 69246], 2], [69247, 3], [[69248, 69289], 2], [69290, 3], [[69291, 69292], 2], [69293, 2], [[69294, 69295], 3], [[69296, 69297], 2], [[69298, 69375], 3], [[69376, 69404], 2], [[69405, 69414], 2], [69415, 2], [[69416, 69423], 3], [[69424, 69456], 2], [[69457, 69465], 2], [[69466, 69487], 3], [[69488, 69509], 2], [[69510, 69513], 2], [[69514, 69551], 3], [[69552, 69572], 2], [[69573, 69579], 2], [[69580, 69599], 3], [[69600, 69622], 2], [[69623, 69631], 3], [[69632, 69702], 2], [[69703, 69709], 2], [[69710, 69713], 3], [[69714, 69733], 2], [[69734, 69743], 2], [[69744, 69749], 2], [[69750, 69758], 3], [69759, 2], [[69760, 69818], 2], [[69819, 69820], 2], [69821, 3], [[69822, 69825], 2], [69826, 2], [[69827, 69836], 3], [69837, 3], [[69838, 69839], 3], [[69840, 69864], 2], [[69865, 69871], 3], [[69872, 69881], 2], [[69882, 69887], 3], [[69888, 69940], 2], [69941, 3], [[69942, 69951], 2], [[69952, 69955], 2], [[69956, 69958], 2], [69959, 2], [[69960, 69967], 3], [[69968, 70003], 2], [[70004, 70005], 2], [70006, 2], [[70007, 70015], 3], [[70016, 70084], 2], [[70085, 70088], 2], [[70089, 70092], 2], [70093, 2], [[70094, 70095], 2], [[70096, 70105], 2], [70106, 2], [70107, 2], [70108, 2], [[70109, 70111], 2], [70112, 3], [[70113, 70132], 2], [[70133, 70143], 3], [[70144, 70161], 2], [70162, 3], [[70163, 70199], 2], [[70200, 70205], 2], [70206, 2], [[70207, 70271], 3], [[70272, 70278], 2], [70279, 3], [70280, 2], [70281, 3], [[70282, 70285], 2], [70286, 3], [[70287, 70301], 2], [70302, 3], [[70303, 70312], 2], [70313, 2], [[70314, 70319], 3], [[70320, 70378], 2], [[70379, 70383], 3], [[70384, 70393], 2], [[70394, 70399], 3], [70400, 2], [[70401, 70403], 2], [70404, 3], [[70405, 70412], 2], [[70413, 70414], 3], [[70415, 70416], 2], [[70417, 70418], 3], [[70419, 70440], 2], [70441, 3], [[70442, 70448], 2], [70449, 3], [[70450, 70451], 2], [70452, 3], [[70453, 70457], 2], [70458, 3], [70459, 2], [[70460, 70468], 2], [[70469, 70470], 3], [[70471, 70472], 2], [[70473, 70474], 3], [[70475, 70477], 2], [[70478, 70479], 3], [70480, 2], [[70481, 70486], 3], [70487, 2], [[70488, 70492], 3], [[70493, 70499], 2], [[70500, 70501], 3], [[70502, 70508], 2], [[70509, 70511], 3], [[70512, 70516], 2], [[70517, 70655], 3], [[70656, 70730], 2], [[70731, 70735], 2], [[70736, 70745], 2], [70746, 2], [70747, 2], [70748, 3], [70749, 2], [70750, 2], [70751, 2], [[70752, 70753], 2], [[70754, 70783], 3], [[70784, 70853], 2], [70854, 2], [70855, 2], [[70856, 70863], 3], [[70864, 70873], 2], [[70874, 71039], 3], [[71040, 71093], 2], [[71094, 71095], 3], [[71096, 71104], 2], [[71105, 71113], 2], [[71114, 71127], 2], [[71128, 71133], 2], [[71134, 71167], 3], [[71168, 71232], 2], [[71233, 71235], 2], [71236, 2], [[71237, 71247], 3], [[71248, 71257], 2], [[71258, 71263], 3], [[71264, 71276], 2], [[71277, 71295], 3], [[71296, 71351], 2], [71352, 2], [71353, 2], [[71354, 71359], 3], [[71360, 71369], 2], [[71370, 71423], 3], [[71424, 71449], 2], [71450, 2], [[71451, 71452], 3], [[71453, 71467], 2], [[71468, 71471], 3], [[71472, 71481], 2], [[71482, 71487], 2], [[71488, 71494], 2], [[71495, 71679], 3], [[71680, 71738], 2], [71739, 2], [[71740, 71839], 3], [71840, 1, "\u{118C0}"], [71841, 1, "\u{118C1}"], [71842, 1, "\u{118C2}"], [71843, 1, "\u{118C3}"], [71844, 1, "\u{118C4}"], [71845, 1, "\u{118C5}"], [71846, 1, "\u{118C6}"], [71847, 1, "\u{118C7}"], [71848, 1, "\u{118C8}"], [71849, 1, "\u{118C9}"], [71850, 1, "\u{118CA}"], [71851, 1, "\u{118CB}"], [71852, 1, "\u{118CC}"], [71853, 1, "\u{118CD}"], [71854, 1, "\u{118CE}"], [71855, 1, "\u{118CF}"], [71856, 1, "\u{118D0}"], [71857, 1, "\u{118D1}"], [71858, 1, "\u{118D2}"], [71859, 1, "\u{118D3}"], [71860, 1, "\u{118D4}"], [71861, 1, "\u{118D5}"], [71862, 1, "\u{118D6}"], [71863, 1, "\u{118D7}"], [71864, 1, "\u{118D8}"], [71865, 1, "\u{118D9}"], [71866, 1, "\u{118DA}"], [71867, 1, "\u{118DB}"], [71868, 1, "\u{118DC}"], [71869, 1, "\u{118DD}"], [71870, 1, "\u{118DE}"], [71871, 1, "\u{118DF}"], [[71872, 71913], 2], [[71914, 71922], 2], [[71923, 71934], 3], [71935, 2], [[71936, 71942], 2], [[71943, 71944], 3], [71945, 2], [[71946, 71947], 3], [[71948, 71955], 2], [71956, 3], [[71957, 71958], 2], [71959, 3], [[71960, 71989], 2], [71990, 3], [[71991, 71992], 2], [[71993, 71994], 3], [[71995, 72003], 2], [[72004, 72006], 2], [[72007, 72015], 3], [[72016, 72025], 2], [[72026, 72095], 3], [[72096, 72103], 2], [[72104, 72105], 3], [[72106, 72151], 2], [[72152, 72153], 3], [[72154, 72161], 2], [72162, 2], [[72163, 72164], 2], [[72165, 72191], 3], [[72192, 72254], 2], [[72255, 72262], 2], [72263, 2], [[72264, 72271], 3], [[72272, 72323], 2], [[72324, 72325], 2], [[72326, 72345], 2], [[72346, 72348], 2], [72349, 2], [[72350, 72354], 2], [[72355, 72367], 3], [[72368, 72383], 2], [[72384, 72440], 2], [[72441, 72703], 3], [[72704, 72712], 2], [72713, 3], [[72714, 72758], 2], [72759, 3], [[72760, 72768], 2], [[72769, 72773], 2], [[72774, 72783], 3], [[72784, 72793], 2], [[72794, 72812], 2], [[72813, 72815], 3], [[72816, 72817], 2], [[72818, 72847], 2], [[72848, 72849], 3], [[72850, 72871], 2], [72872, 3], [[72873, 72886], 2], [[72887, 72959], 3], [[72960, 72966], 2], [72967, 3], [[72968, 72969], 2], [72970, 3], [[72971, 73014], 2], [[73015, 73017], 3], [73018, 2], [73019, 3], [[73020, 73021], 2], [73022, 3], [[73023, 73031], 2], [[73032, 73039], 3], [[73040, 73049], 2], [[73050, 73055], 3], [[73056, 73061], 2], [73062, 3], [[73063, 73064], 2], [73065, 3], [[73066, 73102], 2], [73103, 3], [[73104, 73105], 2], [73106, 3], [[73107, 73112], 2], [[73113, 73119], 3], [[73120, 73129], 2], [[73130, 73439], 3], [[73440, 73462], 2], [[73463, 73464], 2], [[73465, 73647], 3], [73648, 2], [[73649, 73663], 3], [[73664, 73713], 2], [[73714, 73726], 3], [73727, 2], [[73728, 74606], 2], [[74607, 74648], 2], [74649, 2], [[74650, 74751], 3], [[74752, 74850], 2], [[74851, 74862], 2], [74863, 3], [[74864, 74867], 2], [74868, 2], [[74869, 74879], 3], [[74880, 75075], 2], [[75076, 77711], 3], [[77712, 77808], 2], [[77809, 77810], 2], [[77811, 77823], 3], [[77824, 78894], 2], [78895, 3], [[78896, 78904], 3], [[78905, 82943], 3], [[82944, 83526], 2], [[83527, 92159], 3], [[92160, 92728], 2], [[92729, 92735], 3], [[92736, 92766], 2], [92767, 3], [[92768, 92777], 2], [[92778, 92781], 3], [[92782, 92783], 2], [[92784, 92862], 2], [92863, 3], [[92864, 92873], 2], [[92874, 92879], 3], [[92880, 92909], 2], [[92910, 92911], 3], [[92912, 92916], 2], [92917, 2], [[92918, 92927], 3], [[92928, 92982], 2], [[92983, 92991], 2], [[92992, 92995], 2], [[92996, 92997], 2], [[92998, 93007], 3], [[93008, 93017], 2], [93018, 3], [[93019, 93025], 2], [93026, 3], [[93027, 93047], 2], [[93048, 93052], 3], [[93053, 93071], 2], [[93072, 93759], 3], [93760, 1, "\u{16E60}"], [93761, 1, "\u{16E61}"], [93762, 1, "\u{16E62}"], [93763, 1, "\u{16E63}"], [93764, 1, "\u{16E64}"], [93765, 1, "\u{16E65}"], [93766, 1, "\u{16E66}"], [93767, 1, "\u{16E67}"], [93768, 1, "\u{16E68}"], [93769, 1, "\u{16E69}"], [93770, 1, "\u{16E6A}"], [93771, 1, "\u{16E6B}"], [93772, 1, "\u{16E6C}"], [93773, 1, "\u{16E6D}"], [93774, 1, "\u{16E6E}"], [93775, 1, "\u{16E6F}"], [93776, 1, "\u{16E70}"], [93777, 1, "\u{16E71}"], [93778, 1, "\u{16E72}"], [93779, 1, "\u{16E73}"], [93780, 1, "\u{16E74}"], [93781, 1, "\u{16E75}"], [93782, 1, "\u{16E76}"], [93783, 1, "\u{16E77}"], [93784, 1, "\u{16E78}"], [93785, 1, "\u{16E79}"], [93786, 1, "\u{16E7A}"], [93787, 1, "\u{16E7B}"], [93788, 1, "\u{16E7C}"], [93789, 1, "\u{16E7D}"], [93790, 1, "\u{16E7E}"], [93791, 1, "\u{16E7F}"], [[93792, 93823], 2], [[93824, 93850], 2], [[93851, 93951], 3], [[93952, 94020], 2], [[94021, 94026], 2], [[94027, 94030], 3], [94031, 2], [[94032, 94078], 2], [[94079, 94087], 2], [[94088, 94094], 3], [[94095, 94111], 2], [[94112, 94175], 3], [94176, 2], [94177, 2], [94178, 2], [94179, 2], [94180, 2], [[94181, 94191], 3], [[94192, 94193], 2], [[94194, 94207], 3], [[94208, 100332], 2], [[100333, 100337], 2], [[100338, 100343], 2], [[100344, 100351], 3], [[100352, 101106], 2], [[101107, 101589], 2], [[101590, 101631], 3], [[101632, 101640], 2], [[101641, 110575], 3], [[110576, 110579], 2], [110580, 3], [[110581, 110587], 2], [110588, 3], [[110589, 110590], 2], [110591, 3], [[110592, 110593], 2], [[110594, 110878], 2], [[110879, 110882], 2], [[110883, 110927], 3], [[110928, 110930], 2], [[110931, 110947], 3], [[110948, 110951], 2], [[110952, 110959], 3], [[110960, 111355], 2], [[111356, 113663], 3], [[113664, 113770], 2], [[113771, 113775], 3], [[113776, 113788], 2], [[113789, 113791], 3], [[113792, 113800], 2], [[113801, 113807], 3], [[113808, 113817], 2], [[113818, 113819], 3], [113820, 2], [[113821, 113822], 2], [113823, 2], [[113824, 113827], 7], [[113828, 118527], 3], [[118528, 118573], 2], [[118574, 118575], 3], [[118576, 118598], 2], [[118599, 118607], 3], [[118608, 118723], 2], [[118724, 118783], 3], [[118784, 119029], 2], [[119030, 119039], 3], [[119040, 119078], 2], [[119079, 119080], 3], [119081, 2], [[119082, 119133], 2], [119134, 1, "\u{1D157}\u{1D165}"], [119135, 1, "\u{1D158}\u{1D165}"], [119136, 1, "\u{1D158}\u{1D165}\u{1D16E}"], [119137, 1, "\u{1D158}\u{1D165}\u{1D16F}"], [119138, 1, "\u{1D158}\u{1D165}\u{1D170}"], [119139, 1, "\u{1D158}\u{1D165}\u{1D171}"], [119140, 1, "\u{1D158}\u{1D165}\u{1D172}"], [[119141, 119154], 2], [[119155, 119162], 3], [[119163, 119226], 2], [119227, 1, "\u{1D1B9}\u{1D165}"], [119228, 1, "\u{1D1BA}\u{1D165}"], [119229, 1, "\u{1D1B9}\u{1D165}\u{1D16E}"], [119230, 1, "\u{1D1BA}\u{1D165}\u{1D16E}"], [119231, 1, "\u{1D1B9}\u{1D165}\u{1D16F}"], [119232, 1, "\u{1D1BA}\u{1D165}\u{1D16F}"], [[119233, 119261], 2], [[119262, 119272], 2], [[119273, 119274], 2], [[119275, 119295], 3], [[119296, 119365], 2], [[119366, 119519], 3], [[119520, 119539], 2], [[119540, 119551], 3], [[119552, 119638], 2], [[119639, 119647], 3], [[119648, 119665], 2], [[119666, 119672], 2], [[119673, 119807], 3], [119808, 1, "a"], [119809, 1, "b"], [119810, 1, "c"], [119811, 1, "d"], [119812, 1, "e"], [119813, 1, "f"], [119814, 1, "g"], [119815, 1, "h"], [119816, 1, "i"], [119817, 1, "j"], [119818, 1, "k"], [119819, 1, "l"], [119820, 1, "m"], [119821, 1, "n"], [119822, 1, "o"], [119823, 1, "p"], [119824, 1, "q"], [119825, 1, "r"], [119826, 1, "s"], [119827, 1, "t"], [119828, 1, "u"], [119829, 1, "v"], [119830, 1, "w"], [119831, 1, "x"], [119832, 1, "y"], [119833, 1, "z"], [119834, 1, "a"], [119835, 1, "b"], [119836, 1, "c"], [119837, 1, "d"], [119838, 1, "e"], [119839, 1, "f"], [119840, 1, "g"], [119841, 1, "h"], [119842, 1, "i"], [119843, 1, "j"], [119844, 1, "k"], [119845, 1, "l"], [119846, 1, "m"], [119847, 1, "n"], [119848, 1, "o"], [119849, 1, "p"], [119850, 1, "q"], [119851, 1, "r"], [119852, 1, "s"], [119853, 1, "t"], [119854, 1, "u"], [119855, 1, "v"], [119856, 1, "w"], [119857, 1, "x"], [119858, 1, "y"], [119859, 1, "z"], [119860, 1, "a"], [119861, 1, "b"], [119862, 1, "c"], [119863, 1, "d"], [119864, 1, "e"], [119865, 1, "f"], [119866, 1, "g"], [119867, 1, "h"], [119868, 1, "i"], [119869, 1, "j"], [119870, 1, "k"], [119871, 1, "l"], [119872, 1, "m"], [119873, 1, "n"], [119874, 1, "o"], [119875, 1, "p"], [119876, 1, "q"], [119877, 1, "r"], [119878, 1, "s"], [119879, 1, "t"], [119880, 1, "u"], [119881, 1, "v"], [119882, 1, "w"], [119883, 1, "x"], [119884, 1, "y"], [119885, 1, "z"], [119886, 1, "a"], [119887, 1, "b"], [119888, 1, "c"], [119889, 1, "d"], [119890, 1, "e"], [119891, 1, "f"], [119892, 1, "g"], [119893, 3], [119894, 1, "i"], [119895, 1, "j"], [119896, 1, "k"], [119897, 1, "l"], [119898, 1, "m"], [119899, 1, "n"], [119900, 1, "o"], [119901, 1, "p"], [119902, 1, "q"], [119903, 1, "r"], [119904, 1, "s"], [119905, 1, "t"], [119906, 1, "u"], [119907, 1, "v"], [119908, 1, "w"], [119909, 1, "x"], [119910, 1, "y"], [119911, 1, "z"], [119912, 1, "a"], [119913, 1, "b"], [119914, 1, "c"], [119915, 1, "d"], [119916, 1, "e"], [119917, 1, "f"], [119918, 1, "g"], [119919, 1, "h"], [119920, 1, "i"], [119921, 1, "j"], [119922, 1, "k"], [119923, 1, "l"], [119924, 1, "m"], [119925, 1, "n"], [119926, 1, "o"], [119927, 1, "p"], [119928, 1, "q"], [119929, 1, "r"], [119930, 1, "s"], [119931, 1, "t"], [119932, 1, "u"], [119933, 1, "v"], [119934, 1, "w"], [119935, 1, "x"], [119936, 1, "y"], [119937, 1, "z"], [119938, 1, "a"], [119939, 1, "b"], [119940, 1, "c"], [119941, 1, "d"], [119942, 1, "e"], [119943, 1, "f"], [119944, 1, "g"], [119945, 1, "h"], [119946, 1, "i"], [119947, 1, "j"], [119948, 1, "k"], [119949, 1, "l"], [119950, 1, "m"], [119951, 1, "n"], [119952, 1, "o"], [119953, 1, "p"], [119954, 1, "q"], [119955, 1, "r"], [119956, 1, "s"], [119957, 1, "t"], [119958, 1, "u"], [119959, 1, "v"], [119960, 1, "w"], [119961, 1, "x"], [119962, 1, "y"], [119963, 1, "z"], [119964, 1, "a"], [119965, 3], [119966, 1, "c"], [119967, 1, "d"], [[119968, 119969], 3], [119970, 1, "g"], [[119971, 119972], 3], [119973, 1, "j"], [119974, 1, "k"], [[119975, 119976], 3], [119977, 1, "n"], [119978, 1, "o"], [119979, 1, "p"], [119980, 1, "q"], [119981, 3], [119982, 1, "s"], [119983, 1, "t"], [119984, 1, "u"], [119985, 1, "v"], [119986, 1, "w"], [119987, 1, "x"], [119988, 1, "y"], [119989, 1, "z"], [119990, 1, "a"], [119991, 1, "b"], [119992, 1, "c"], [119993, 1, "d"], [119994, 3], [119995, 1, "f"], [119996, 3], [119997, 1, "h"], [119998, 1, "i"], [119999, 1, "j"], [12e4, 1, "k"], [120001, 1, "l"], [120002, 1, "m"], [120003, 1, "n"], [120004, 3], [120005, 1, "p"], [120006, 1, "q"], [120007, 1, "r"], [120008, 1, "s"], [120009, 1, "t"], [120010, 1, "u"], [120011, 1, "v"], [120012, 1, "w"], [120013, 1, "x"], [120014, 1, "y"], [120015, 1, "z"], [120016, 1, "a"], [120017, 1, "b"], [120018, 1, "c"], [120019, 1, "d"], [120020, 1, "e"], [120021, 1, "f"], [120022, 1, "g"], [120023, 1, "h"], [120024, 1, "i"], [120025, 1, "j"], [120026, 1, "k"], [120027, 1, "l"], [120028, 1, "m"], [120029, 1, "n"], [120030, 1, "o"], [120031, 1, "p"], [120032, 1, "q"], [120033, 1, "r"], [120034, 1, "s"], [120035, 1, "t"], [120036, 1, "u"], [120037, 1, "v"], [120038, 1, "w"], [120039, 1, "x"], [120040, 1, "y"], [120041, 1, "z"], [120042, 1, "a"], [120043, 1, "b"], [120044, 1, "c"], [120045, 1, "d"], [120046, 1, "e"], [120047, 1, "f"], [120048, 1, "g"], [120049, 1, "h"], [120050, 1, "i"], [120051, 1, "j"], [120052, 1, "k"], [120053, 1, "l"], [120054, 1, "m"], [120055, 1, "n"], [120056, 1, "o"], [120057, 1, "p"], [120058, 1, "q"], [120059, 1, "r"], [120060, 1, "s"], [120061, 1, "t"], [120062, 1, "u"], [120063, 1, "v"], [120064, 1, "w"], [120065, 1, "x"], [120066, 1, "y"], [120067, 1, "z"], [120068, 1, "a"], [120069, 1, "b"], [120070, 3], [120071, 1, "d"], [120072, 1, "e"], [120073, 1, "f"], [120074, 1, "g"], [[120075, 120076], 3], [120077, 1, "j"], [120078, 1, "k"], [120079, 1, "l"], [120080, 1, "m"], [120081, 1, "n"], [120082, 1, "o"], [120083, 1, "p"], [120084, 1, "q"], [120085, 3], [120086, 1, "s"], [120087, 1, "t"], [120088, 1, "u"], [120089, 1, "v"], [120090, 1, "w"], [120091, 1, "x"], [120092, 1, "y"], [120093, 3], [120094, 1, "a"], [120095, 1, "b"], [120096, 1, "c"], [120097, 1, "d"], [120098, 1, "e"], [120099, 1, "f"], [120100, 1, "g"], [120101, 1, "h"], [120102, 1, "i"], [120103, 1, "j"], [120104, 1, "k"], [120105, 1, "l"], [120106, 1, "m"], [120107, 1, "n"], [120108, 1, "o"], [120109, 1, "p"], [120110, 1, "q"], [120111, 1, "r"], [120112, 1, "s"], [120113, 1, "t"], [120114, 1, "u"], [120115, 1, "v"], [120116, 1, "w"], [120117, 1, "x"], [120118, 1, "y"], [120119, 1, "z"], [120120, 1, "a"], [120121, 1, "b"], [120122, 3], [120123, 1, "d"], [120124, 1, "e"], [120125, 1, "f"], [120126, 1, "g"], [120127, 3], [120128, 1, "i"], [120129, 1, "j"], [120130, 1, "k"], [120131, 1, "l"], [120132, 1, "m"], [120133, 3], [120134, 1, "o"], [[120135, 120137], 3], [120138, 1, "s"], [120139, 1, "t"], [120140, 1, "u"], [120141, 1, "v"], [120142, 1, "w"], [120143, 1, "x"], [120144, 1, "y"], [120145, 3], [120146, 1, "a"], [120147, 1, "b"], [120148, 1, "c"], [120149, 1, "d"], [120150, 1, "e"], [120151, 1, "f"], [120152, 1, "g"], [120153, 1, "h"], [120154, 1, "i"], [120155, 1, "j"], [120156, 1, "k"], [120157, 1, "l"], [120158, 1, "m"], [120159, 1, "n"], [120160, 1, "o"], [120161, 1, "p"], [120162, 1, "q"], [120163, 1, "r"], [120164, 1, "s"], [120165, 1, "t"], [120166, 1, "u"], [120167, 1, "v"], [120168, 1, "w"], [120169, 1, "x"], [120170, 1, "y"], [120171, 1, "z"], [120172, 1, "a"], [120173, 1, "b"], [120174, 1, "c"], [120175, 1, "d"], [120176, 1, "e"], [120177, 1, "f"], [120178, 1, "g"], [120179, 1, "h"], [120180, 1, "i"], [120181, 1, "j"], [120182, 1, "k"], [120183, 1, "l"], [120184, 1, "m"], [120185, 1, "n"], [120186, 1, "o"], [120187, 1, "p"], [120188, 1, "q"], [120189, 1, "r"], [120190, 1, "s"], [120191, 1, "t"], [120192, 1, "u"], [120193, 1, "v"], [120194, 1, "w"], [120195, 1, "x"], [120196, 1, "y"], [120197, 1, "z"], [120198, 1, "a"], [120199, 1, "b"], [120200, 1, "c"], [120201, 1, "d"], [120202, 1, "e"], [120203, 1, "f"], [120204, 1, "g"], [120205, 1, "h"], [120206, 1, "i"], [120207, 1, "j"], [120208, 1, "k"], [120209, 1, "l"], [120210, 1, "m"], [120211, 1, "n"], [120212, 1, "o"], [120213, 1, "p"], [120214, 1, "q"], [120215, 1, "r"], [120216, 1, "s"], [120217, 1, "t"], [120218, 1, "u"], [120219, 1, "v"], [120220, 1, "w"], [120221, 1, "x"], [120222, 1, "y"], [120223, 1, "z"], [120224, 1, "a"], [120225, 1, "b"], [120226, 1, "c"], [120227, 1, "d"], [120228, 1, "e"], [120229, 1, "f"], [120230, 1, "g"], [120231, 1, "h"], [120232, 1, "i"], [120233, 1, "j"], [120234, 1, "k"], [120235, 1, "l"], [120236, 1, "m"], [120237, 1, "n"], [120238, 1, "o"], [120239, 1, "p"], [120240, 1, "q"], [120241, 1, "r"], [120242, 1, "s"], [120243, 1, "t"], [120244, 1, "u"], [120245, 1, "v"], [120246, 1, "w"], [120247, 1, "x"], [120248, 1, "y"], [120249, 1, "z"], [120250, 1, "a"], [120251, 1, "b"], [120252, 1, "c"], [120253, 1, "d"], [120254, 1, "e"], [120255, 1, "f"], [120256, 1, "g"], [120257, 1, "h"], [120258, 1, "i"], [120259, 1, "j"], [120260, 1, "k"], [120261, 1, "l"], [120262, 1, "m"], [120263, 1, "n"], [120264, 1, "o"], [120265, 1, "p"], [120266, 1, "q"], [120267, 1, "r"], [120268, 1, "s"], [120269, 1, "t"], [120270, 1, "u"], [120271, 1, "v"], [120272, 1, "w"], [120273, 1, "x"], [120274, 1, "y"], [120275, 1, "z"], [120276, 1, "a"], [120277, 1, "b"], [120278, 1, "c"], [120279, 1, "d"], [120280, 1, "e"], [120281, 1, "f"], [120282, 1, "g"], [120283, 1, "h"], [120284, 1, "i"], [120285, 1, "j"], [120286, 1, "k"], [120287, 1, "l"], [120288, 1, "m"], [120289, 1, "n"], [120290, 1, "o"], [120291, 1, "p"], [120292, 1, "q"], [120293, 1, "r"], [120294, 1, "s"], [120295, 1, "t"], [120296, 1, "u"], [120297, 1, "v"], [120298, 1, "w"], [120299, 1, "x"], [120300, 1, "y"], [120301, 1, "z"], [120302, 1, "a"], [120303, 1, "b"], [120304, 1, "c"], [120305, 1, "d"], [120306, 1, "e"], [120307, 1, "f"], [120308, 1, "g"], [120309, 1, "h"], [120310, 1, "i"], [120311, 1, "j"], [120312, 1, "k"], [120313, 1, "l"], [120314, 1, "m"], [120315, 1, "n"], [120316, 1, "o"], [120317, 1, "p"], [120318, 1, "q"], [120319, 1, "r"], [120320, 1, "s"], [120321, 1, "t"], [120322, 1, "u"], [120323, 1, "v"], [120324, 1, "w"], [120325, 1, "x"], [120326, 1, "y"], [120327, 1, "z"], [120328, 1, "a"], [120329, 1, "b"], [120330, 1, "c"], [120331, 1, "d"], [120332, 1, "e"], [120333, 1, "f"], [120334, 1, "g"], [120335, 1, "h"], [120336, 1, "i"], [120337, 1, "j"], [120338, 1, "k"], [120339, 1, "l"], [120340, 1, "m"], [120341, 1, "n"], [120342, 1, "o"], [120343, 1, "p"], [120344, 1, "q"], [120345, 1, "r"], [120346, 1, "s"], [120347, 1, "t"], [120348, 1, "u"], [120349, 1, "v"], [120350, 1, "w"], [120351, 1, "x"], [120352, 1, "y"], [120353, 1, "z"], [120354, 1, "a"], [120355, 1, "b"], [120356, 1, "c"], [120357, 1, "d"], [120358, 1, "e"], [120359, 1, "f"], [120360, 1, "g"], [120361, 1, "h"], [120362, 1, "i"], [120363, 1, "j"], [120364, 1, "k"], [120365, 1, "l"], [120366, 1, "m"], [120367, 1, "n"], [120368, 1, "o"], [120369, 1, "p"], [120370, 1, "q"], [120371, 1, "r"], [120372, 1, "s"], [120373, 1, "t"], [120374, 1, "u"], [120375, 1, "v"], [120376, 1, "w"], [120377, 1, "x"], [120378, 1, "y"], [120379, 1, "z"], [120380, 1, "a"], [120381, 1, "b"], [120382, 1, "c"], [120383, 1, "d"], [120384, 1, "e"], [120385, 1, "f"], [120386, 1, "g"], [120387, 1, "h"], [120388, 1, "i"], [120389, 1, "j"], [120390, 1, "k"], [120391, 1, "l"], [120392, 1, "m"], [120393, 1, "n"], [120394, 1, "o"], [120395, 1, "p"], [120396, 1, "q"], [120397, 1, "r"], [120398, 1, "s"], [120399, 1, "t"], [120400, 1, "u"], [120401, 1, "v"], [120402, 1, "w"], [120403, 1, "x"], [120404, 1, "y"], [120405, 1, "z"], [120406, 1, "a"], [120407, 1, "b"], [120408, 1, "c"], [120409, 1, "d"], [120410, 1, "e"], [120411, 1, "f"], [120412, 1, "g"], [120413, 1, "h"], [120414, 1, "i"], [120415, 1, "j"], [120416, 1, "k"], [120417, 1, "l"], [120418, 1, "m"], [120419, 1, "n"], [120420, 1, "o"], [120421, 1, "p"], [120422, 1, "q"], [120423, 1, "r"], [120424, 1, "s"], [120425, 1, "t"], [120426, 1, "u"], [120427, 1, "v"], [120428, 1, "w"], [120429, 1, "x"], [120430, 1, "y"], [120431, 1, "z"], [120432, 1, "a"], [120433, 1, "b"], [120434, 1, "c"], [120435, 1, "d"], [120436, 1, "e"], [120437, 1, "f"], [120438, 1, "g"], [120439, 1, "h"], [120440, 1, "i"], [120441, 1, "j"], [120442, 1, "k"], [120443, 1, "l"], [120444, 1, "m"], [120445, 1, "n"], [120446, 1, "o"], [120447, 1, "p"], [120448, 1, "q"], [120449, 1, "r"], [120450, 1, "s"], [120451, 1, "t"], [120452, 1, "u"], [120453, 1, "v"], [120454, 1, "w"], [120455, 1, "x"], [120456, 1, "y"], [120457, 1, "z"], [120458, 1, "a"], [120459, 1, "b"], [120460, 1, "c"], [120461, 1, "d"], [120462, 1, "e"], [120463, 1, "f"], [120464, 1, "g"], [120465, 1, "h"], [120466, 1, "i"], [120467, 1, "j"], [120468, 1, "k"], [120469, 1, "l"], [120470, 1, "m"], [120471, 1, "n"], [120472, 1, "o"], [120473, 1, "p"], [120474, 1, "q"], [120475, 1, "r"], [120476, 1, "s"], [120477, 1, "t"], [120478, 1, "u"], [120479, 1, "v"], [120480, 1, "w"], [120481, 1, "x"], [120482, 1, "y"], [120483, 1, "z"], [120484, 1, "\u0131"], [120485, 1, "\u0237"], [[120486, 120487], 3], [120488, 1, "\u03B1"], [120489, 1, "\u03B2"], [120490, 1, "\u03B3"], [120491, 1, "\u03B4"], [120492, 1, "\u03B5"], [120493, 1, "\u03B6"], [120494, 1, "\u03B7"], [120495, 1, "\u03B8"], [120496, 1, "\u03B9"], [120497, 1, "\u03BA"], [120498, 1, "\u03BB"], [120499, 1, "\u03BC"], [120500, 1, "\u03BD"], [120501, 1, "\u03BE"], [120502, 1, "\u03BF"], [120503, 1, "\u03C0"], [120504, 1, "\u03C1"], [120505, 1, "\u03B8"], [120506, 1, "\u03C3"], [120507, 1, "\u03C4"], [120508, 1, "\u03C5"], [120509, 1, "\u03C6"], [120510, 1, "\u03C7"], [120511, 1, "\u03C8"], [120512, 1, "\u03C9"], [120513, 1, "\u2207"], [120514, 1, "\u03B1"], [120515, 1, "\u03B2"], [120516, 1, "\u03B3"], [120517, 1, "\u03B4"], [120518, 1, "\u03B5"], [120519, 1, "\u03B6"], [120520, 1, "\u03B7"], [120521, 1, "\u03B8"], [120522, 1, "\u03B9"], [120523, 1, "\u03BA"], [120524, 1, "\u03BB"], [120525, 1, "\u03BC"], [120526, 1, "\u03BD"], [120527, 1, "\u03BE"], [120528, 1, "\u03BF"], [120529, 1, "\u03C0"], [120530, 1, "\u03C1"], [[120531, 120532], 1, "\u03C3"], [120533, 1, "\u03C4"], [120534, 1, "\u03C5"], [120535, 1, "\u03C6"], [120536, 1, "\u03C7"], [120537, 1, "\u03C8"], [120538, 1, "\u03C9"], [120539, 1, "\u2202"], [120540, 1, "\u03B5"], [120541, 1, "\u03B8"], [120542, 1, "\u03BA"], [120543, 1, "\u03C6"], [120544, 1, "\u03C1"], [120545, 1, "\u03C0"], [120546, 1, "\u03B1"], [120547, 1, "\u03B2"], [120548, 1, "\u03B3"], [120549, 1, "\u03B4"], [120550, 1, "\u03B5"], [120551, 1, "\u03B6"], [120552, 1, "\u03B7"], [120553, 1, "\u03B8"], [120554, 1, "\u03B9"], [120555, 1, "\u03BA"], [120556, 1, "\u03BB"], [120557, 1, "\u03BC"], [120558, 1, "\u03BD"], [120559, 1, "\u03BE"], [120560, 1, "\u03BF"], [120561, 1, "\u03C0"], [120562, 1, "\u03C1"], [120563, 1, "\u03B8"], [120564, 1, "\u03C3"], [120565, 1, "\u03C4"], [120566, 1, "\u03C5"], [120567, 1, "\u03C6"], [120568, 1, "\u03C7"], [120569, 1, "\u03C8"], [120570, 1, "\u03C9"], [120571, 1, "\u2207"], [120572, 1, "\u03B1"], [120573, 1, "\u03B2"], [120574, 1, "\u03B3"], [120575, 1, "\u03B4"], [120576, 1, "\u03B5"], [120577, 1, "\u03B6"], [120578, 1, "\u03B7"], [120579, 1, "\u03B8"], [120580, 1, "\u03B9"], [120581, 1, "\u03BA"], [120582, 1, "\u03BB"], [120583, 1, "\u03BC"], [120584, 1, "\u03BD"], [120585, 1, "\u03BE"], [120586, 1, "\u03BF"], [120587, 1, "\u03C0"], [120588, 1, "\u03C1"], [[120589, 120590], 1, "\u03C3"], [120591, 1, "\u03C4"], [120592, 1, "\u03C5"], [120593, 1, "\u03C6"], [120594, 1, "\u03C7"], [120595, 1, "\u03C8"], [120596, 1, "\u03C9"], [120597, 1, "\u2202"], [120598, 1, "\u03B5"], [120599, 1, "\u03B8"], [120600, 1, "\u03BA"], [120601, 1, "\u03C6"], [120602, 1, "\u03C1"], [120603, 1, "\u03C0"], [120604, 1, "\u03B1"], [120605, 1, "\u03B2"], [120606, 1, "\u03B3"], [120607, 1, "\u03B4"], [120608, 1, "\u03B5"], [120609, 1, "\u03B6"], [120610, 1, "\u03B7"], [120611, 1, "\u03B8"], [120612, 1, "\u03B9"], [120613, 1, "\u03BA"], [120614, 1, "\u03BB"], [120615, 1, "\u03BC"], [120616, 1, "\u03BD"], [120617, 1, "\u03BE"], [120618, 1, "\u03BF"], [120619, 1, "\u03C0"], [120620, 1, "\u03C1"], [120621, 1, "\u03B8"], [120622, 1, "\u03C3"], [120623, 1, "\u03C4"], [120624, 1, "\u03C5"], [120625, 1, "\u03C6"], [120626, 1, "\u03C7"], [120627, 1, "\u03C8"], [120628, 1, "\u03C9"], [120629, 1, "\u2207"], [120630, 1, "\u03B1"], [120631, 1, "\u03B2"], [120632, 1, "\u03B3"], [120633, 1, "\u03B4"], [120634, 1, "\u03B5"], [120635, 1, "\u03B6"], [120636, 1, "\u03B7"], [120637, 1, "\u03B8"], [120638, 1, "\u03B9"], [120639, 1, "\u03BA"], [120640, 1, "\u03BB"], [120641, 1, "\u03BC"], [120642, 1, "\u03BD"], [120643, 1, "\u03BE"], [120644, 1, "\u03BF"], [120645, 1, "\u03C0"], [120646, 1, "\u03C1"], [[120647, 120648], 1, "\u03C3"], [120649, 1, "\u03C4"], [120650, 1, "\u03C5"], [120651, 1, "\u03C6"], [120652, 1, "\u03C7"], [120653, 1, "\u03C8"], [120654, 1, "\u03C9"], [120655, 1, "\u2202"], [120656, 1, "\u03B5"], [120657, 1, "\u03B8"], [120658, 1, "\u03BA"], [120659, 1, "\u03C6"], [120660, 1, "\u03C1"], [120661, 1, "\u03C0"], [120662, 1, "\u03B1"], [120663, 1, "\u03B2"], [120664, 1, "\u03B3"], [120665, 1, "\u03B4"], [120666, 1, "\u03B5"], [120667, 1, "\u03B6"], [120668, 1, "\u03B7"], [120669, 1, "\u03B8"], [120670, 1, "\u03B9"], [120671, 1, "\u03BA"], [120672, 1, "\u03BB"], [120673, 1, "\u03BC"], [120674, 1, "\u03BD"], [120675, 1, "\u03BE"], [120676, 1, "\u03BF"], [120677, 1, "\u03C0"], [120678, 1, "\u03C1"], [120679, 1, "\u03B8"], [120680, 1, "\u03C3"], [120681, 1, "\u03C4"], [120682, 1, "\u03C5"], [120683, 1, "\u03C6"], [120684, 1, "\u03C7"], [120685, 1, "\u03C8"], [120686, 1, "\u03C9"], [120687, 1, "\u2207"], [120688, 1, "\u03B1"], [120689, 1, "\u03B2"], [120690, 1, "\u03B3"], [120691, 1, "\u03B4"], [120692, 1, "\u03B5"], [120693, 1, "\u03B6"], [120694, 1, "\u03B7"], [120695, 1, "\u03B8"], [120696, 1, "\u03B9"], [120697, 1, "\u03BA"], [120698, 1, "\u03BB"], [120699, 1, "\u03BC"], [120700, 1, "\u03BD"], [120701, 1, "\u03BE"], [120702, 1, "\u03BF"], [120703, 1, "\u03C0"], [120704, 1, "\u03C1"], [[120705, 120706], 1, "\u03C3"], [120707, 1, "\u03C4"], [120708, 1, "\u03C5"], [120709, 1, "\u03C6"], [120710, 1, "\u03C7"], [120711, 1, "\u03C8"], [120712, 1, "\u03C9"], [120713, 1, "\u2202"], [120714, 1, "\u03B5"], [120715, 1, "\u03B8"], [120716, 1, "\u03BA"], [120717, 1, "\u03C6"], [120718, 1, "\u03C1"], [120719, 1, "\u03C0"], [120720, 1, "\u03B1"], [120721, 1, "\u03B2"], [120722, 1, "\u03B3"], [120723, 1, "\u03B4"], [120724, 1, "\u03B5"], [120725, 1, "\u03B6"], [120726, 1, "\u03B7"], [120727, 1, "\u03B8"], [120728, 1, "\u03B9"], [120729, 1, "\u03BA"], [120730, 1, "\u03BB"], [120731, 1, "\u03BC"], [120732, 1, "\u03BD"], [120733, 1, "\u03BE"], [120734, 1, "\u03BF"], [120735, 1, "\u03C0"], [120736, 1, "\u03C1"], [120737, 1, "\u03B8"], [120738, 1, "\u03C3"], [120739, 1, "\u03C4"], [120740, 1, "\u03C5"], [120741, 1, "\u03C6"], [120742, 1, "\u03C7"], [120743, 1, "\u03C8"], [120744, 1, "\u03C9"], [120745, 1, "\u2207"], [120746, 1, "\u03B1"], [120747, 1, "\u03B2"], [120748, 1, "\u03B3"], [120749, 1, "\u03B4"], [120750, 1, "\u03B5"], [120751, 1, "\u03B6"], [120752, 1, "\u03B7"], [120753, 1, "\u03B8"], [120754, 1, "\u03B9"], [120755, 1, "\u03BA"], [120756, 1, "\u03BB"], [120757, 1, "\u03BC"], [120758, 1, "\u03BD"], [120759, 1, "\u03BE"], [120760, 1, "\u03BF"], [120761, 1, "\u03C0"], [120762, 1, "\u03C1"], [[120763, 120764], 1, "\u03C3"], [120765, 1, "\u03C4"], [120766, 1, "\u03C5"], [120767, 1, "\u03C6"], [120768, 1, "\u03C7"], [120769, 1, "\u03C8"], [120770, 1, "\u03C9"], [120771, 1, "\u2202"], [120772, 1, "\u03B5"], [120773, 1, "\u03B8"], [120774, 1, "\u03BA"], [120775, 1, "\u03C6"], [120776, 1, "\u03C1"], [120777, 1, "\u03C0"], [[120778, 120779], 1, "\u03DD"], [[120780, 120781], 3], [120782, 1, "0"], [120783, 1, "1"], [120784, 1, "2"], [120785, 1, "3"], [120786, 1, "4"], [120787, 1, "5"], [120788, 1, "6"], [120789, 1, "7"], [120790, 1, "8"], [120791, 1, "9"], [120792, 1, "0"], [120793, 1, "1"], [120794, 1, "2"], [120795, 1, "3"], [120796, 1, "4"], [120797, 1, "5"], [120798, 1, "6"], [120799, 1, "7"], [120800, 1, "8"], [120801, 1, "9"], [120802, 1, "0"], [120803, 1, "1"], [120804, 1, "2"], [120805, 1, "3"], [120806, 1, "4"], [120807, 1, "5"], [120808, 1, "6"], [120809, 1, "7"], [120810, 1, "8"], [120811, 1, "9"], [120812, 1, "0"], [120813, 1, "1"], [120814, 1, "2"], [120815, 1, "3"], [120816, 1, "4"], [120817, 1, "5"], [120818, 1, "6"], [120819, 1, "7"], [120820, 1, "8"], [120821, 1, "9"], [120822, 1, "0"], [120823, 1, "1"], [120824, 1, "2"], [120825, 1, "3"], [120826, 1, "4"], [120827, 1, "5"], [120828, 1, "6"], [120829, 1, "7"], [120830, 1, "8"], [120831, 1, "9"], [[120832, 121343], 2], [[121344, 121398], 2], [[121399, 121402], 2], [[121403, 121452], 2], [[121453, 121460], 2], [121461, 2], [[121462, 121475], 2], [121476, 2], [[121477, 121483], 2], [[121484, 121498], 3], [[121499, 121503], 2], [121504, 3], [[121505, 121519], 2], [[121520, 122623], 3], [[122624, 122654], 2], [[122655, 122879], 3], [[122880, 122886], 2], [122887, 3], [[122888, 122904], 2], [[122905, 122906], 3], [[122907, 122913], 2], [122914, 3], [[122915, 122916], 2], [122917, 3], [[122918, 122922], 2], [[122923, 123135], 3], [[123136, 123180], 2], [[123181, 123183], 3], [[123184, 123197], 2], [[123198, 123199], 3], [[123200, 123209], 2], [[123210, 123213], 3], [123214, 2], [123215, 2], [[123216, 123535], 3], [[123536, 123566], 2], [[123567, 123583], 3], [[123584, 123641], 2], [[123642, 123646], 3], [123647, 2], [[123648, 124895], 3], [[124896, 124902], 2], [124903, 3], [[124904, 124907], 2], [124908, 3], [[124909, 124910], 2], [124911, 3], [[124912, 124926], 2], [124927, 3], [[124928, 125124], 2], [[125125, 125126], 3], [[125127, 125135], 2], [[125136, 125142], 2], [[125143, 125183], 3], [125184, 1, "\u{1E922}"], [125185, 1, "\u{1E923}"], [125186, 1, "\u{1E924}"], [125187, 1, "\u{1E925}"], [125188, 1, "\u{1E926}"], [125189, 1, "\u{1E927}"], [125190, 1, "\u{1E928}"], [125191, 1, "\u{1E929}"], [125192, 1, "\u{1E92A}"], [125193, 1, "\u{1E92B}"], [125194, 1, "\u{1E92C}"], [125195, 1, "\u{1E92D}"], [125196, 1, "\u{1E92E}"], [125197, 1, "\u{1E92F}"], [125198, 1, "\u{1E930}"], [125199, 1, "\u{1E931}"], [125200, 1, "\u{1E932}"], [125201, 1, "\u{1E933}"], [125202, 1, "\u{1E934}"], [125203, 1, "\u{1E935}"], [125204, 1, "\u{1E936}"], [125205, 1, "\u{1E937}"], [125206, 1, "\u{1E938}"], [125207, 1, "\u{1E939}"], [125208, 1, "\u{1E93A}"], [125209, 1, "\u{1E93B}"], [125210, 1, "\u{1E93C}"], [125211, 1, "\u{1E93D}"], [125212, 1, "\u{1E93E}"], [125213, 1, "\u{1E93F}"], [125214, 1, "\u{1E940}"], [125215, 1, "\u{1E941}"], [125216, 1, "\u{1E942}"], [125217, 1, "\u{1E943}"], [[125218, 125258], 2], [125259, 2], [[125260, 125263], 3], [[125264, 125273], 2], [[125274, 125277], 3], [[125278, 125279], 2], [[125280, 126064], 3], [[126065, 126132], 2], [[126133, 126208], 3], [[126209, 126269], 2], [[126270, 126463], 3], [126464, 1, "\u0627"], [126465, 1, "\u0628"], [126466, 1, "\u062C"], [126467, 1, "\u062F"], [126468, 3], [126469, 1, "\u0648"], [126470, 1, "\u0632"], [126471, 1, "\u062D"], [126472, 1, "\u0637"], [126473, 1, "\u064A"], [126474, 1, "\u0643"], [126475, 1, "\u0644"], [126476, 1, "\u0645"], [126477, 1, "\u0646"], [126478, 1, "\u0633"], [126479, 1, "\u0639"], [126480, 1, "\u0641"], [126481, 1, "\u0635"], [126482, 1, "\u0642"], [126483, 1, "\u0631"], [126484, 1, "\u0634"], [126485, 1, "\u062A"], [126486, 1, "\u062B"], [126487, 1, "\u062E"], [126488, 1, "\u0630"], [126489, 1, "\u0636"], [126490, 1, "\u0638"], [126491, 1, "\u063A"], [126492, 1, "\u066E"], [126493, 1, "\u06BA"], [126494, 1, "\u06A1"], [126495, 1, "\u066F"], [126496, 3], [126497, 1, "\u0628"], [126498, 1, "\u062C"], [126499, 3], [126500, 1, "\u0647"], [[126501, 126502], 3], [126503, 1, "\u062D"], [126504, 3], [126505, 1, "\u064A"], [126506, 1, "\u0643"], [126507, 1, "\u0644"], [126508, 1, "\u0645"], [126509, 1, "\u0646"], [126510, 1, "\u0633"], [126511, 1, "\u0639"], [126512, 1, "\u0641"], [126513, 1, "\u0635"], [126514, 1, "\u0642"], [126515, 3], [126516, 1, "\u0634"], [126517, 1, "\u062A"], [126518, 1, "\u062B"], [126519, 1, "\u062E"], [126520, 3], [126521, 1, "\u0636"], [126522, 3], [126523, 1, "\u063A"], [[126524, 126529], 3], [126530, 1, "\u062C"], [[126531, 126534], 3], [126535, 1, "\u062D"], [126536, 3], [126537, 1, "\u064A"], [126538, 3], [126539, 1, "\u0644"], [126540, 3], [126541, 1, "\u0646"], [126542, 1, "\u0633"], [126543, 1, "\u0639"], [126544, 3], [126545, 1, "\u0635"], [126546, 1, "\u0642"], [126547, 3], [126548, 1, "\u0634"], [[126549, 126550], 3], [126551, 1, "\u062E"], [126552, 3], [126553, 1, "\u0636"], [126554, 3], [126555, 1, "\u063A"], [126556, 3], [126557, 1, "\u06BA"], [126558, 3], [126559, 1, "\u066F"], [126560, 3], [126561, 1, "\u0628"], [126562, 1, "\u062C"], [126563, 3], [126564, 1, "\u0647"], [[126565, 126566], 3], [126567, 1, "\u062D"], [126568, 1, "\u0637"], [126569, 1, "\u064A"], [126570, 1, "\u0643"], [126571, 3], [126572, 1, "\u0645"], [126573, 1, "\u0646"], [126574, 1, "\u0633"], [126575, 1, "\u0639"], [126576, 1, "\u0641"], [126577, 1, "\u0635"], [126578, 1, "\u0642"], [126579, 3], [126580, 1, "\u0634"], [126581, 1, "\u062A"], [126582, 1, "\u062B"], [126583, 1, "\u062E"], [126584, 3], [126585, 1, "\u0636"], [126586, 1, "\u0638"], [126587, 1, "\u063A"], [126588, 1, "\u066E"], [126589, 3], [126590, 1, "\u06A1"], [126591, 3], [126592, 1, "\u0627"], [126593, 1, "\u0628"], [126594, 1, "\u062C"], [126595, 1, "\u062F"], [126596, 1, "\u0647"], [126597, 1, "\u0648"], [126598, 1, "\u0632"], [126599, 1, "\u062D"], [126600, 1, "\u0637"], [126601, 1, "\u064A"], [126602, 3], [126603, 1, "\u0644"], [126604, 1, "\u0645"], [126605, 1, "\u0646"], [126606, 1, "\u0633"], [126607, 1, "\u0639"], [126608, 1, "\u0641"], [126609, 1, "\u0635"], [126610, 1, "\u0642"], [126611, 1, "\u0631"], [126612, 1, "\u0634"], [126613, 1, "\u062A"], [126614, 1, "\u062B"], [126615, 1, "\u062E"], [126616, 1, "\u0630"], [126617, 1, "\u0636"], [126618, 1, "\u0638"], [126619, 1, "\u063A"], [[126620, 126624], 3], [126625, 1, "\u0628"], [126626, 1, "\u062C"], [126627, 1, "\u062F"], [126628, 3], [126629, 1, "\u0648"], [126630, 1, "\u0632"], [126631, 1, "\u062D"], [126632, 1, "\u0637"], [126633, 1, "\u064A"], [126634, 3], [126635, 1, "\u0644"], [126636, 1, "\u0645"], [126637, 1, "\u0646"], [126638, 1, "\u0633"], [126639, 1, "\u0639"], [126640, 1, "\u0641"], [126641, 1, "\u0635"], [126642, 1, "\u0642"], [126643, 1, "\u0631"], [126644, 1, "\u0634"], [126645, 1, "\u062A"], [126646, 1, "\u062B"], [126647, 1, "\u062E"], [126648, 1, "\u0630"], [126649, 1, "\u0636"], [126650, 1, "\u0638"], [126651, 1, "\u063A"], [[126652, 126703], 3], [[126704, 126705], 2], [[126706, 126975], 3], [[126976, 127019], 2], [[127020, 127023], 3], [[127024, 127123], 2], [[127124, 127135], 3], [[127136, 127150], 2], [[127151, 127152], 3], [[127153, 127166], 2], [127167, 2], [127168, 3], [[127169, 127183], 2], [127184, 3], [[127185, 127199], 2], [[127200, 127221], 2], [[127222, 127231], 3], [127232, 3], [127233, 5, "0,"], [127234, 5, "1,"], [127235, 5, "2,"], [127236, 5, "3,"], [127237, 5, "4,"], [127238, 5, "5,"], [127239, 5, "6,"], [127240, 5, "7,"], [127241, 5, "8,"], [127242, 5, "9,"], [[127243, 127244], 2], [[127245, 127247], 2], [127248, 5, "(a)"], [127249, 5, "(b)"], [127250, 5, "(c)"], [127251, 5, "(d)"], [127252, 5, "(e)"], [127253, 5, "(f)"], [127254, 5, "(g)"], [127255, 5, "(h)"], [127256, 5, "(i)"], [127257, 5, "(j)"], [127258, 5, "(k)"], [127259, 5, "(l)"], [127260, 5, "(m)"], [127261, 5, "(n)"], [127262, 5, "(o)"], [127263, 5, "(p)"], [127264, 5, "(q)"], [127265, 5, "(r)"], [127266, 5, "(s)"], [127267, 5, "(t)"], [127268, 5, "(u)"], [127269, 5, "(v)"], [127270, 5, "(w)"], [127271, 5, "(x)"], [127272, 5, "(y)"], [127273, 5, "(z)"], [127274, 1, "\u3014s\u3015"], [127275, 1, "c"], [127276, 1, "r"], [127277, 1, "cd"], [127278, 1, "wz"], [127279, 2], [127280, 1, "a"], [127281, 1, "b"], [127282, 1, "c"], [127283, 1, "d"], [127284, 1, "e"], [127285, 1, "f"], [127286, 1, "g"], [127287, 1, "h"], [127288, 1, "i"], [127289, 1, "j"], [127290, 1, "k"], [127291, 1, "l"], [127292, 1, "m"], [127293, 1, "n"], [127294, 1, "o"], [127295, 1, "p"], [127296, 1, "q"], [127297, 1, "r"], [127298, 1, "s"], [127299, 1, "t"], [127300, 1, "u"], [127301, 1, "v"], [127302, 1, "w"], [127303, 1, "x"], [127304, 1, "y"], [127305, 1, "z"], [127306, 1, "hv"], [127307, 1, "mv"], [127308, 1, "sd"], [127309, 1, "ss"], [127310, 1, "ppv"], [127311, 1, "wc"], [[127312, 127318], 2], [127319, 2], [[127320, 127326], 2], [127327, 2], [[127328, 127337], 2], [127338, 1, "mc"], [127339, 1, "md"], [127340, 1, "mr"], [[127341, 127343], 2], [[127344, 127352], 2], [127353, 2], [127354, 2], [[127355, 127356], 2], [[127357, 127358], 2], [127359, 2], [[127360, 127369], 2], [[127370, 127373], 2], [[127374, 127375], 2], [127376, 1, "dj"], [[127377, 127386], 2], [[127387, 127404], 2], [127405, 2], [[127406, 127461], 3], [[127462, 127487], 2], [127488, 1, "\u307B\u304B"], [127489, 1, "\u30B3\u30B3"], [127490, 1, "\u30B5"], [[127491, 127503], 3], [127504, 1, "\u624B"], [127505, 1, "\u5B57"], [127506, 1, "\u53CC"], [127507, 1, "\u30C7"], [127508, 1, "\u4E8C"], [127509, 1, "\u591A"], [127510, 1, "\u89E3"], [127511, 1, "\u5929"], [127512, 1, "\u4EA4"], [127513, 1, "\u6620"], [127514, 1, "\u7121"], [127515, 1, "\u6599"], [127516, 1, "\u524D"], [127517, 1, "\u5F8C"], [127518, 1, "\u518D"], [127519, 1, "\u65B0"], [127520, 1, "\u521D"], [127521, 1, "\u7D42"], [127522, 1, "\u751F"], [127523, 1, "\u8CA9"], [127524, 1, "\u58F0"], [127525, 1, "\u5439"], [127526, 1, "\u6F14"], [127527, 1, "\u6295"], [127528, 1, "\u6355"], [127529, 1, "\u4E00"], [127530, 1, "\u4E09"], [127531, 1, "\u904A"], [127532, 1, "\u5DE6"], [127533, 1, "\u4E2D"], [127534, 1, "\u53F3"], [127535, 1, "\u6307"], [127536, 1, "\u8D70"], [127537, 1, "\u6253"], [127538, 1, "\u7981"], [127539, 1, "\u7A7A"], [127540, 1, "\u5408"], [127541, 1, "\u6E80"], [127542, 1, "\u6709"], [127543, 1, "\u6708"], [127544, 1, "\u7533"], [127545, 1, "\u5272"], [127546, 1, "\u55B6"], [127547, 1, "\u914D"], [[127548, 127551], 3], [127552, 1, "\u3014\u672C\u3015"], [127553, 1, "\u3014\u4E09\u3015"], [127554, 1, "\u3014\u4E8C\u3015"], [127555, 1, "\u3014\u5B89\u3015"], [127556, 1, "\u3014\u70B9\u3015"], [127557, 1, "\u3014\u6253\u3015"], [127558, 1, "\u3014\u76D7\u3015"], [127559, 1, "\u3014\u52DD\u3015"], [127560, 1, "\u3014\u6557\u3015"], [[127561, 127567], 3], [127568, 1, "\u5F97"], [127569, 1, "\u53EF"], [[127570, 127583], 3], [[127584, 127589], 2], [[127590, 127743], 3], [[127744, 127776], 2], [[127777, 127788], 2], [[127789, 127791], 2], [[127792, 127797], 2], [127798, 2], [[127799, 127868], 2], [127869, 2], [[127870, 127871], 2], [[127872, 127891], 2], [[127892, 127903], 2], [[127904, 127940], 2], [127941, 2], [[127942, 127946], 2], [[127947, 127950], 2], [[127951, 127955], 2], [[127956, 127967], 2], [[127968, 127984], 2], [[127985, 127991], 2], [[127992, 127999], 2], [[128e3, 128062], 2], [128063, 2], [128064, 2], [128065, 2], [[128066, 128247], 2], [128248, 2], [[128249, 128252], 2], [[128253, 128254], 2], [128255, 2], [[128256, 128317], 2], [[128318, 128319], 2], [[128320, 128323], 2], [[128324, 128330], 2], [[128331, 128335], 2], [[128336, 128359], 2], [[128360, 128377], 2], [128378, 2], [[128379, 128419], 2], [128420, 2], [[128421, 128506], 2], [[128507, 128511], 2], [128512, 2], [[128513, 128528], 2], [128529, 2], [[128530, 128532], 2], [128533, 2], [128534, 2], [128535, 2], [128536, 2], [128537, 2], [128538, 2], [128539, 2], [[128540, 128542], 2], [128543, 2], [[128544, 128549], 2], [[128550, 128551], 2], [[128552, 128555], 2], [128556, 2], [128557, 2], [[128558, 128559], 2], [[128560, 128563], 2], [128564, 2], [[128565, 128576], 2], [[128577, 128578], 2], [[128579, 128580], 2], [[128581, 128591], 2], [[128592, 128639], 2], [[128640, 128709], 2], [[128710, 128719], 2], [128720, 2], [[128721, 128722], 2], [[128723, 128724], 2], [128725, 2], [[128726, 128727], 2], [[128728, 128732], 3], [[128733, 128735], 2], [[128736, 128748], 2], [[128749, 128751], 3], [[128752, 128755], 2], [[128756, 128758], 2], [[128759, 128760], 2], [128761, 2], [128762, 2], [[128763, 128764], 2], [[128765, 128767], 3], [[128768, 128883], 2], [[128884, 128895], 3], [[128896, 128980], 2], [[128981, 128984], 2], [[128985, 128991], 3], [[128992, 129003], 2], [[129004, 129007], 3], [129008, 2], [[129009, 129023], 3], [[129024, 129035], 2], [[129036, 129039], 3], [[129040, 129095], 2], [[129096, 129103], 3], [[129104, 129113], 2], [[129114, 129119], 3], [[129120, 129159], 2], [[129160, 129167], 3], [[129168, 129197], 2], [[129198, 129199], 3], [[129200, 129201], 2], [[129202, 129279], 3], [[129280, 129291], 2], [129292, 2], [[129293, 129295], 2], [[129296, 129304], 2], [[129305, 129310], 2], [129311, 2], [[129312, 129319], 2], [[129320, 129327], 2], [129328, 2], [[129329, 129330], 2], [[129331, 129342], 2], [129343, 2], [[129344, 129355], 2], [129356, 2], [[129357, 129359], 2], [[129360, 129374], 2], [[129375, 129387], 2], [[129388, 129392], 2], [129393, 2], [129394, 2], [[129395, 129398], 2], [[129399, 129400], 2], [129401, 2], [129402, 2], [129403, 2], [[129404, 129407], 2], [[129408, 129412], 2], [[129413, 129425], 2], [[129426, 129431], 2], [[129432, 129442], 2], [[129443, 129444], 2], [[129445, 129450], 2], [[129451, 129453], 2], [[129454, 129455], 2], [[129456, 129465], 2], [[129466, 129471], 2], [129472, 2], [[129473, 129474], 2], [[129475, 129482], 2], [129483, 2], [129484, 2], [[129485, 129487], 2], [[129488, 129510], 2], [[129511, 129535], 2], [[129536, 129619], 2], [[129620, 129631], 3], [[129632, 129645], 2], [[129646, 129647], 3], [[129648, 129651], 2], [129652, 2], [[129653, 129655], 3], [[129656, 129658], 2], [[129659, 129660], 2], [[129661, 129663], 3], [[129664, 129666], 2], [[129667, 129670], 2], [[129671, 129679], 3], [[129680, 129685], 2], [[129686, 129704], 2], [[129705, 129708], 2], [[129709, 129711], 3], [[129712, 129718], 2], [[129719, 129722], 2], [[129723, 129727], 3], [[129728, 129730], 2], [[129731, 129733], 2], [[129734, 129743], 3], [[129744, 129750], 2], [[129751, 129753], 2], [[129754, 129759], 3], [[129760, 129767], 2], [[129768, 129775], 3], [[129776, 129782], 2], [[129783, 129791], 3], [[129792, 129938], 2], [129939, 3], [[129940, 129994], 2], [[129995, 130031], 3], [130032, 1, "0"], [130033, 1, "1"], [130034, 1, "2"], [130035, 1, "3"], [130036, 1, "4"], [130037, 1, "5"], [130038, 1, "6"], [130039, 1, "7"], [130040, 1, "8"], [130041, 1, "9"], [[130042, 131069], 3], [[131070, 131071], 3], [[131072, 173782], 2], [[173783, 173789], 2], [[173790, 173791], 2], [[173792, 173823], 3], [[173824, 177972], 2], [[177973, 177976], 2], [[177977, 177983], 3], [[177984, 178205], 2], [[178206, 178207], 3], [[178208, 183969], 2], [[183970, 183983], 3], [[183984, 191456], 2], [[191457, 194559], 3], [194560, 1, "\u4E3D"], [194561, 1, "\u4E38"], [194562, 1, "\u4E41"], [194563, 1, "\u{20122}"], [194564, 1, "\u4F60"], [194565, 1, "\u4FAE"], [194566, 1, "\u4FBB"], [194567, 1, "\u5002"], [194568, 1, "\u507A"], [194569, 1, "\u5099"], [194570, 1, "\u50E7"], [194571, 1, "\u50CF"], [194572, 1, "\u349E"], [194573, 1, "\u{2063A}"], [194574, 1, "\u514D"], [194575, 1, "\u5154"], [194576, 1, "\u5164"], [194577, 1, "\u5177"], [194578, 1, "\u{2051C}"], [194579, 1, "\u34B9"], [194580, 1, "\u5167"], [194581, 1, "\u518D"], [194582, 1, "\u{2054B}"], [194583, 1, "\u5197"], [194584, 1, "\u51A4"], [194585, 1, "\u4ECC"], [194586, 1, "\u51AC"], [194587, 1, "\u51B5"], [194588, 1, "\u{291DF}"], [194589, 1, "\u51F5"], [194590, 1, "\u5203"], [194591, 1, "\u34DF"], [194592, 1, "\u523B"], [194593, 1, "\u5246"], [194594, 1, "\u5272"], [194595, 1, "\u5277"], [194596, 1, "\u3515"], [194597, 1, "\u52C7"], [194598, 1, "\u52C9"], [194599, 1, "\u52E4"], [194600, 1, "\u52FA"], [194601, 1, "\u5305"], [194602, 1, "\u5306"], [194603, 1, "\u5317"], [194604, 1, "\u5349"], [194605, 1, "\u5351"], [194606, 1, "\u535A"], [194607, 1, "\u5373"], [194608, 1, "\u537D"], [[194609, 194611], 1, "\u537F"], [194612, 1, "\u{20A2C}"], [194613, 1, "\u7070"], [194614, 1, "\u53CA"], [194615, 1, "\u53DF"], [194616, 1, "\u{20B63}"], [194617, 1, "\u53EB"], [194618, 1, "\u53F1"], [194619, 1, "\u5406"], [194620, 1, "\u549E"], [194621, 1, "\u5438"], [194622, 1, "\u5448"], [194623, 1, "\u5468"], [194624, 1, "\u54A2"], [194625, 1, "\u54F6"], [194626, 1, "\u5510"], [194627, 1, "\u5553"], [194628, 1, "\u5563"], [[194629, 194630], 1, "\u5584"], [194631, 1, "\u5599"], [194632, 1, "\u55AB"], [194633, 1, "\u55B3"], [194634, 1, "\u55C2"], [194635, 1, "\u5716"], [194636, 1, "\u5606"], [194637, 1, "\u5717"], [194638, 1, "\u5651"], [194639, 1, "\u5674"], [194640, 1, "\u5207"], [194641, 1, "\u58EE"], [194642, 1, "\u57CE"], [194643, 1, "\u57F4"], [194644, 1, "\u580D"], [194645, 1, "\u578B"], [194646, 1, "\u5832"], [194647, 1, "\u5831"], [194648, 1, "\u58AC"], [194649, 1, "\u{214E4}"], [194650, 1, "\u58F2"], [194651, 1, "\u58F7"], [194652, 1, "\u5906"], [194653, 1, "\u591A"], [194654, 1, "\u5922"], [194655, 1, "\u5962"], [194656, 1, "\u{216A8}"], [194657, 1, "\u{216EA}"], [194658, 1, "\u59EC"], [194659, 1, "\u5A1B"], [194660, 1, "\u5A27"], [194661, 1, "\u59D8"], [194662, 1, "\u5A66"], [194663, 1, "\u36EE"], [194664, 3], [194665, 1, "\u5B08"], [[194666, 194667], 1, "\u5B3E"], [194668, 1, "\u{219C8}"], [194669, 1, "\u5BC3"], [194670, 1, "\u5BD8"], [194671, 1, "\u5BE7"], [194672, 1, "\u5BF3"], [194673, 1, "\u{21B18}"], [194674, 1, "\u5BFF"], [194675, 1, "\u5C06"], [194676, 3], [194677, 1, "\u5C22"], [194678, 1, "\u3781"], [194679, 1, "\u5C60"], [194680, 1, "\u5C6E"], [194681, 1, "\u5CC0"], [194682, 1, "\u5C8D"], [194683, 1, "\u{21DE4}"], [194684, 1, "\u5D43"], [194685, 1, "\u{21DE6}"], [194686, 1, "\u5D6E"], [194687, 1, "\u5D6B"], [194688, 1, "\u5D7C"], [194689, 1, "\u5DE1"], [194690, 1, "\u5DE2"], [194691, 1, "\u382F"], [194692, 1, "\u5DFD"], [194693, 1, "\u5E28"], [194694, 1, "\u5E3D"], [194695, 1, "\u5E69"], [194696, 1, "\u3862"], [194697, 1, "\u{22183}"], [194698, 1, "\u387C"], [194699, 1, "\u5EB0"], [194700, 1, "\u5EB3"], [194701, 1, "\u5EB6"], [194702, 1, "\u5ECA"], [194703, 1, "\u{2A392}"], [194704, 1, "\u5EFE"], [[194705, 194706], 1, "\u{22331}"], [194707, 1, "\u8201"], [[194708, 194709], 1, "\u5F22"], [194710, 1, "\u38C7"], [194711, 1, "\u{232B8}"], [194712, 1, "\u{261DA}"], [194713, 1, "\u5F62"], [194714, 1, "\u5F6B"], [194715, 1, "\u38E3"], [194716, 1, "\u5F9A"], [194717, 1, "\u5FCD"], [194718, 1, "\u5FD7"], [194719, 1, "\u5FF9"], [194720, 1, "\u6081"], [194721, 1, "\u393A"], [194722, 1, "\u391C"], [194723, 1, "\u6094"], [194724, 1, "\u{226D4}"], [194725, 1, "\u60C7"], [194726, 1, "\u6148"], [194727, 1, "\u614C"], [194728, 1, "\u614E"], [194729, 1, "\u614C"], [194730, 1, "\u617A"], [194731, 1, "\u618E"], [194732, 1, "\u61B2"], [194733, 1, "\u61A4"], [194734, 1, "\u61AF"], [194735, 1, "\u61DE"], [194736, 1, "\u61F2"], [194737, 1, "\u61F6"], [194738, 1, "\u6210"], [194739, 1, "\u621B"], [194740, 1, "\u625D"], [194741, 1, "\u62B1"], [194742, 1, "\u62D4"], [194743, 1, "\u6350"], [194744, 1, "\u{22B0C}"], [194745, 1, "\u633D"], [194746, 1, "\u62FC"], [194747, 1, "\u6368"], [194748, 1, "\u6383"], [194749, 1, "\u63E4"], [194750, 1, "\u{22BF1}"], [194751, 1, "\u6422"], [194752, 1, "\u63C5"], [194753, 1, "\u63A9"], [194754, 1, "\u3A2E"], [194755, 1, "\u6469"], [194756, 1, "\u647E"], [194757, 1, "\u649D"], [194758, 1, "\u6477"], [194759, 1, "\u3A6C"], [194760, 1, "\u654F"], [194761, 1, "\u656C"], [194762, 1, "\u{2300A}"], [194763, 1, "\u65E3"], [194764, 1, "\u66F8"], [194765, 1, "\u6649"], [194766, 1, "\u3B19"], [194767, 1, "\u6691"], [194768, 1, "\u3B08"], [194769, 1, "\u3AE4"], [194770, 1, "\u5192"], [194771, 1, "\u5195"], [194772, 1, "\u6700"], [194773, 1, "\u669C"], [194774, 1, "\u80AD"], [194775, 1, "\u43D9"], [194776, 1, "\u6717"], [194777, 1, "\u671B"], [194778, 1, "\u6721"], [194779, 1, "\u675E"], [194780, 1, "\u6753"], [194781, 1, "\u{233C3}"], [194782, 1, "\u3B49"], [194783, 1, "\u67FA"], [194784, 1, "\u6785"], [194785, 1, "\u6852"], [194786, 1, "\u6885"], [194787, 1, "\u{2346D}"], [194788, 1, "\u688E"], [194789, 1, "\u681F"], [194790, 1, "\u6914"], [194791, 1, "\u3B9D"], [194792, 1, "\u6942"], [194793, 1, "\u69A3"], [194794, 1, "\u69EA"], [194795, 1, "\u6AA8"], [194796, 1, "\u{236A3}"], [194797, 1, "\u6ADB"], [194798, 1, "\u3C18"], [194799, 1, "\u6B21"], [194800, 1, "\u{238A7}"], [194801, 1, "\u6B54"], [194802, 1, "\u3C4E"], [194803, 1, "\u6B72"], [194804, 1, "\u6B9F"], [194805, 1, "\u6BBA"], [194806, 1, "\u6BBB"], [194807, 1, "\u{23A8D}"], [194808, 1, "\u{21D0B}"], [194809, 1, "\u{23AFA}"], [194810, 1, "\u6C4E"], [194811, 1, "\u{23CBC}"], [194812, 1, "\u6CBF"], [194813, 1, "\u6CCD"], [194814, 1, "\u6C67"], [194815, 1, "\u6D16"], [194816, 1, "\u6D3E"], [194817, 1, "\u6D77"], [194818, 1, "\u6D41"], [194819, 1, "\u6D69"], [194820, 1, "\u6D78"], [194821, 1, "\u6D85"], [194822, 1, "\u{23D1E}"], [194823, 1, "\u6D34"], [194824, 1, "\u6E2F"], [194825, 1, "\u6E6E"], [194826, 1, "\u3D33"], [194827, 1, "\u6ECB"], [194828, 1, "\u6EC7"], [194829, 1, "\u{23ED1}"], [194830, 1, "\u6DF9"], [194831, 1, "\u6F6E"], [194832, 1, "\u{23F5E}"], [194833, 1, "\u{23F8E}"], [194834, 1, "\u6FC6"], [194835, 1, "\u7039"], [194836, 1, "\u701E"], [194837, 1, "\u701B"], [194838, 1, "\u3D96"], [194839, 1, "\u704A"], [194840, 1, "\u707D"], [194841, 1, "\u7077"], [194842, 1, "\u70AD"], [194843, 1, "\u{20525}"], [194844, 1, "\u7145"], [194845, 1, "\u{24263}"], [194846, 1, "\u719C"], [194847, 3], [194848, 1, "\u7228"], [194849, 1, "\u7235"], [194850, 1, "\u7250"], [194851, 1, "\u{24608}"], [194852, 1, "\u7280"], [194853, 1, "\u7295"], [194854, 1, "\u{24735}"], [194855, 1, "\u{24814}"], [194856, 1, "\u737A"], [194857, 1, "\u738B"], [194858, 1, "\u3EAC"], [194859, 1, "\u73A5"], [[194860, 194861], 1, "\u3EB8"], [194862, 1, "\u7447"], [194863, 1, "\u745C"], [194864, 1, "\u7471"], [194865, 1, "\u7485"], [194866, 1, "\u74CA"], [194867, 1, "\u3F1B"], [194868, 1, "\u7524"], [194869, 1, "\u{24C36}"], [194870, 1, "\u753E"], [194871, 1, "\u{24C92}"], [194872, 1, "\u7570"], [194873, 1, "\u{2219F}"], [194874, 1, "\u7610"], [194875, 1, "\u{24FA1}"], [194876, 1, "\u{24FB8}"], [194877, 1, "\u{25044}"], [194878, 1, "\u3FFC"], [194879, 1, "\u4008"], [194880, 1, "\u76F4"], [194881, 1, "\u{250F3}"], [194882, 1, "\u{250F2}"], [194883, 1, "\u{25119}"], [194884, 1, "\u{25133}"], [194885, 1, "\u771E"], [[194886, 194887], 1, "\u771F"], [194888, 1, "\u774A"], [194889, 1, "\u4039"], [194890, 1, "\u778B"], [194891, 1, "\u4046"], [194892, 1, "\u4096"], [194893, 1, "\u{2541D}"], [194894, 1, "\u784E"], [194895, 1, "\u788C"], [194896, 1, "\u78CC"], [194897, 1, "\u40E3"], [194898, 1, "\u{25626}"], [194899, 1, "\u7956"], [194900, 1, "\u{2569A}"], [194901, 1, "\u{256C5}"], [194902, 1, "\u798F"], [194903, 1, "\u79EB"], [194904, 1, "\u412F"], [194905, 1, "\u7A40"], [194906, 1, "\u7A4A"], [194907, 1, "\u7A4F"], [194908, 1, "\u{2597C}"], [[194909, 194910], 1, "\u{25AA7}"], [194911, 3], [194912, 1, "\u4202"], [194913, 1, "\u{25BAB}"], [194914, 1, "\u7BC6"], [194915, 1, "\u7BC9"], [194916, 1, "\u4227"], [194917, 1, "\u{25C80}"], [194918, 1, "\u7CD2"], [194919, 1, "\u42A0"], [194920, 1, "\u7CE8"], [194921, 1, "\u7CE3"], [194922, 1, "\u7D00"], [194923, 1, "\u{25F86}"], [194924, 1, "\u7D63"], [194925, 1, "\u4301"], [194926, 1, "\u7DC7"], [194927, 1, "\u7E02"], [194928, 1, "\u7E45"], [194929, 1, "\u4334"], [194930, 1, "\u{26228}"], [194931, 1, "\u{26247}"], [194932, 1, "\u4359"], [194933, 1, "\u{262D9}"], [194934, 1, "\u7F7A"], [194935, 1, "\u{2633E}"], [194936, 1, "\u7F95"], [194937, 1, "\u7FFA"], [194938, 1, "\u8005"], [194939, 1, "\u{264DA}"], [194940, 1, "\u{26523}"], [194941, 1, "\u8060"], [194942, 1, "\u{265A8}"], [194943, 1, "\u8070"], [194944, 1, "\u{2335F}"], [194945, 1, "\u43D5"], [194946, 1, "\u80B2"], [194947, 1, "\u8103"], [194948, 1, "\u440B"], [194949, 1, "\u813E"], [194950, 1, "\u5AB5"], [194951, 1, "\u{267A7}"], [194952, 1, "\u{267B5}"], [194953, 1, "\u{23393}"], [194954, 1, "\u{2339C}"], [194955, 1, "\u8201"], [194956, 1, "\u8204"], [194957, 1, "\u8F9E"], [194958, 1, "\u446B"], [194959, 1, "\u8291"], [194960, 1, "\u828B"], [194961, 1, "\u829D"], [194962, 1, "\u52B3"], [194963, 1, "\u82B1"], [194964, 1, "\u82B3"], [194965, 1, "\u82BD"], [194966, 1, "\u82E6"], [194967, 1, "\u{26B3C}"], [194968, 1, "\u82E5"], [194969, 1, "\u831D"], [194970, 1, "\u8363"], [194971, 1, "\u83AD"], [194972, 1, "\u8323"], [194973, 1, "\u83BD"], [194974, 1, "\u83E7"], [194975, 1, "\u8457"], [194976, 1, "\u8353"], [194977, 1, "\u83CA"], [194978, 1, "\u83CC"], [194979, 1, "\u83DC"], [194980, 1, "\u{26C36}"], [194981, 1, "\u{26D6B}"], [194982, 1, "\u{26CD5}"], [194983, 1, "\u452B"], [194984, 1, "\u84F1"], [194985, 1, "\u84F3"], [194986, 1, "\u8516"], [194987, 1, "\u{273CA}"], [194988, 1, "\u8564"], [194989, 1, "\u{26F2C}"], [194990, 1, "\u455D"], [194991, 1, "\u4561"], [194992, 1, "\u{26FB1}"], [194993, 1, "\u{270D2}"], [194994, 1, "\u456B"], [194995, 1, "\u8650"], [194996, 1, "\u865C"], [194997, 1, "\u8667"], [194998, 1, "\u8669"], [194999, 1, "\u86A9"], [195e3, 1, "\u8688"], [195001, 1, "\u870E"], [195002, 1, "\u86E2"], [195003, 1, "\u8779"], [195004, 1, "\u8728"], [195005, 1, "\u876B"], [195006, 1, "\u8786"], [195007, 3], [195008, 1, "\u87E1"], [195009, 1, "\u8801"], [195010, 1, "\u45F9"], [195011, 1, "\u8860"], [195012, 1, "\u8863"], [195013, 1, "\u{27667}"], [195014, 1, "\u88D7"], [195015, 1, "\u88DE"], [195016, 1, "\u4635"], [195017, 1, "\u88FA"], [195018, 1, "\u34BB"], [195019, 1, "\u{278AE}"], [195020, 1, "\u{27966}"], [195021, 1, "\u46BE"], [195022, 1, "\u46C7"], [195023, 1, "\u8AA0"], [195024, 1, "\u8AED"], [195025, 1, "\u8B8A"], [195026, 1, "\u8C55"], [195027, 1, "\u{27CA8}"], [195028, 1, "\u8CAB"], [195029, 1, "\u8CC1"], [195030, 1, "\u8D1B"], [195031, 1, "\u8D77"], [195032, 1, "\u{27F2F}"], [195033, 1, "\u{20804}"], [195034, 1, "\u8DCB"], [195035, 1, "\u8DBC"], [195036, 1, "\u8DF0"], [195037, 1, "\u{208DE}"], [195038, 1, "\u8ED4"], [195039, 1, "\u8F38"], [195040, 1, "\u{285D2}"], [195041, 1, "\u{285ED}"], [195042, 1, "\u9094"], [195043, 1, "\u90F1"], [195044, 1, "\u9111"], [195045, 1, "\u{2872E}"], [195046, 1, "\u911B"], [195047, 1, "\u9238"], [195048, 1, "\u92D7"], [195049, 1, "\u92D8"], [195050, 1, "\u927C"], [195051, 1, "\u93F9"], [195052, 1, "\u9415"], [195053, 1, "\u{28BFA}"], [195054, 1, "\u958B"], [195055, 1, "\u4995"], [195056, 1, "\u95B7"], [195057, 1, "\u{28D77}"], [195058, 1, "\u49E6"], [195059, 1, "\u96C3"], [195060, 1, "\u5DB2"], [195061, 1, "\u9723"], [195062, 1, "\u{29145}"], [195063, 1, "\u{2921A}"], [195064, 1, "\u4A6E"], [195065, 1, "\u4A76"], [195066, 1, "\u97E0"], [195067, 1, "\u{2940A}"], [195068, 1, "\u4AB2"], [195069, 1, "\u{29496}"], [[195070, 195071], 1, "\u980B"], [195072, 1, "\u9829"], [195073, 1, "\u{295B6}"], [195074, 1, "\u98E2"], [195075, 1, "\u4B33"], [195076, 1, "\u9929"], [195077, 1, "\u99A7"], [195078, 1, "\u99C2"], [195079, 1, "\u99FE"], [195080, 1, "\u4BCE"], [195081, 1, "\u{29B30}"], [195082, 1, "\u9B12"], [195083, 1, "\u9C40"], [195084, 1, "\u9CFD"], [195085, 1, "\u4CCE"], [195086, 1, "\u4CED"], [195087, 1, "\u9D67"], [195088, 1, "\u{2A0CE}"], [195089, 1, "\u4CF8"], [195090, 1, "\u{2A105}"], [195091, 1, "\u{2A20E}"], [195092, 1, "\u{2A291}"], [195093, 1, "\u9EBB"], [195094, 1, "\u4D56"], [195095, 1, "\u9EF9"], [195096, 1, "\u9EFE"], [195097, 1, "\u9F05"], [195098, 1, "\u9F0F"], [195099, 1, "\u9F16"], [195100, 1, "\u9F3B"], [195101, 1, "\u{2A600}"], [[195102, 196605], 3], [[196606, 196607], 3], [[196608, 201546], 2], [[201547, 262141], 3], [[262142, 262143], 3], [[262144, 327677], 3], [[327678, 327679], 3], [[327680, 393213], 3], [[393214, 393215], 3], [[393216, 458749], 3], [[458750, 458751], 3], [[458752, 524285], 3], [[524286, 524287], 3], [[524288, 589821], 3], [[589822, 589823], 3], [[589824, 655357], 3], [[655358, 655359], 3], [[655360, 720893], 3], [[720894, 720895], 3], [[720896, 786429], 3], [[786430, 786431], 3], [[786432, 851965], 3], [[851966, 851967], 3], [[851968, 917501], 3], [[917502, 917503], 3], [917504, 3], [917505, 3], [[917506, 917535], 3], [[917536, 917631], 3], [[917632, 917759], 3], [[917760, 917999], 7], [[918e3, 983037], 3], [[983038, 983039], 3], [[983040, 1048573], 3], [[1048574, 1048575], 3], [[1048576, 1114109], 3], [[1114110, 1114111], 3]];
- }
- });
- // node_modules/tr46/lib/statusMapping.js
- var require_statusMapping = __commonJS({
- "node_modules/tr46/lib/statusMapping.js"(exports2, module2) {
- "use strict";
- module2.exports.STATUS_MAPPING = {
- mapped: 1,
- valid: 2,
- disallowed: 3,
- disallowed_STD3_valid: 4,
- disallowed_STD3_mapped: 5,
- deviation: 6,
- ignored: 7
- };
- }
- });
- // node_modules/tr46/index.js
- var require_tr46 = __commonJS({
- "node_modules/tr46/index.js"(exports2, module2) {
- "use strict";
- var punycode = require("punycode");
- var regexes = require_regexes();
- var mappingTable = require_mappingTable();
- var { STATUS_MAPPING } = require_statusMapping();
- function containsNonASCII(str) {
- return /[^\x00-\x7F]/u.test(str);
- }
- function findStatus(val, { useSTD3ASCIIRules }) {
- let start = 0;
- let end = mappingTable.length - 1;
- while (start <= end) {
- const mid = Math.floor((start + end) / 2);
- const target = mappingTable[mid];
- const min = Array.isArray(target[0]) ? target[0][0] : target[0];
- const max = Array.isArray(target[0]) ? target[0][1] : target[0];
- if (min <= val && max >= val) {
- if (useSTD3ASCIIRules && (target[1] === STATUS_MAPPING.disallowed_STD3_valid || target[1] === STATUS_MAPPING.disallowed_STD3_mapped)) {
- return [STATUS_MAPPING.disallowed, ...target.slice(2)];
- } else if (target[1] === STATUS_MAPPING.disallowed_STD3_valid) {
- return [STATUS_MAPPING.valid, ...target.slice(2)];
- } else if (target[1] === STATUS_MAPPING.disallowed_STD3_mapped) {
- return [STATUS_MAPPING.mapped, ...target.slice(2)];
- }
- return target.slice(1);
- } else if (min > val) {
- end = mid - 1;
- } else {
- start = mid + 1;
- }
- }
- return null;
- }
- function mapChars(domainName, { useSTD3ASCIIRules, processingOption }) {
- let hasError = false;
- let processed = "";
- for (const ch of domainName) {
- const [status, mapping] = findStatus(ch.codePointAt(0), { useSTD3ASCIIRules });
- switch (status) {
- case STATUS_MAPPING.disallowed:
- hasError = true;
- processed += ch;
- break;
- case STATUS_MAPPING.ignored:
- break;
- case STATUS_MAPPING.mapped:
- processed += mapping;
- break;
- case STATUS_MAPPING.deviation:
- if (processingOption === "transitional") {
- processed += mapping;
- } else {
- processed += ch;
- }
- break;
- case STATUS_MAPPING.valid:
- processed += ch;
- break;
- }
- }
- return {
- string: processed,
- error: hasError
- };
- }
- function validateLabel(label, { checkHyphens, checkBidi, checkJoiners, processingOption, useSTD3ASCIIRules }) {
- if (label.normalize("NFC") !== label) {
- return false;
- }
- const codePoints = Array.from(label);
- if (checkHyphens) {
- if (codePoints[2] === "-" && codePoints[3] === "-" || (label.startsWith("-") || label.endsWith("-"))) {
- return false;
- }
- }
- if (label.includes(".") || codePoints.length > 0 && regexes.combiningMarks.test(codePoints[0])) {
- return false;
- }
- for (const ch of codePoints) {
- const [status] = findStatus(ch.codePointAt(0), { useSTD3ASCIIRules });
- if (processingOption === "transitional" && status !== STATUS_MAPPING.valid || processingOption === "nontransitional" && status !== STATUS_MAPPING.valid && status !== STATUS_MAPPING.deviation) {
- return false;
- }
- }
- if (checkJoiners) {
- let last = 0;
- for (const [i, ch] of codePoints.entries()) {
- if (ch === "\u200C" || ch === "\u200D") {
- if (i > 0) {
- if (regexes.combiningClassVirama.test(codePoints[i - 1])) {
- continue;
- }
- if (ch === "\u200C") {
- const next = codePoints.indexOf("\u200C", i + 1);
- const test = next < 0 ? codePoints.slice(last) : codePoints.slice(last, next);
- if (regexes.validZWNJ.test(test.join(""))) {
- last = i + 1;
- continue;
- }
- }
- }
- return false;
- }
- }
- }
- if (checkBidi) {
- let rtl;
- if (regexes.bidiS1LTR.test(codePoints[0])) {
- rtl = false;
- } else if (regexes.bidiS1RTL.test(codePoints[0])) {
- rtl = true;
- } else {
- return false;
- }
- if (rtl) {
- if (!regexes.bidiS2.test(label) || !regexes.bidiS3.test(label) || regexes.bidiS4EN.test(label) && regexes.bidiS4AN.test(label)) {
- return false;
- }
- } else if (!regexes.bidiS5.test(label) || !regexes.bidiS6.test(label)) {
- return false;
- }
- }
- return true;
- }
- function isBidiDomain(labels) {
- const domain = labels.map((label) => {
- if (label.startsWith("xn--")) {
- try {
- return punycode.decode(label.substring(4));
- } catch (err) {
- return "";
- }
- }
- return label;
- }).join(".");
- return regexes.bidiDomain.test(domain);
- }
- function processing(domainName, options) {
- const { processingOption } = options;
- let { string, error } = mapChars(domainName, options);
- string = string.normalize("NFC");
- const labels = string.split(".");
- const isBidi = isBidiDomain(labels);
- for (const [i, origLabel] of labels.entries()) {
- let label = origLabel;
- let curProcessing = processingOption;
- if (label.startsWith("xn--")) {
- try {
- label = punycode.decode(label.substring(4));
- labels[i] = label;
- } catch (err) {
- error = true;
- continue;
- }
- curProcessing = "nontransitional";
- }
- if (error) {
- continue;
- }
- const validation = validateLabel(label, {
- ...options,
- processingOption: curProcessing,
- checkBidi: options.checkBidi && isBidi
- });
- if (!validation) {
- error = true;
- }
- }
- return {
- string: labels.join("."),
- error
- };
- }
- function toASCII(domainName, {
- checkHyphens = false,
- checkBidi = false,
- checkJoiners = false,
- useSTD3ASCIIRules = false,
- processingOption = "nontransitional",
- verifyDNSLength = false
- } = {}) {
- if (processingOption !== "transitional" && processingOption !== "nontransitional") {
- throw new RangeError("processingOption must be either transitional or nontransitional");
- }
- const result = processing(domainName, {
- processingOption,
- checkHyphens,
- checkBidi,
- checkJoiners,
- useSTD3ASCIIRules
- });
- let labels = result.string.split(".");
- labels = labels.map((l) => {
- if (containsNonASCII(l)) {
- try {
- return `xn--${punycode.encode(l)}`;
- } catch (e) {
- result.error = true;
- }
- }
- return l;
- });
- if (verifyDNSLength) {
- const total = labels.join(".").length;
- if (total > 253 || total === 0) {
- result.error = true;
- }
- for (let i = 0; i < labels.length; ++i) {
- if (labels[i].length > 63 || labels[i].length === 0) {
- result.error = true;
- break;
- }
- }
- }
- if (result.error) {
- return null;
- }
- return labels.join(".");
- }
- function toUnicode(domainName, {
- checkHyphens = false,
- checkBidi = false,
- checkJoiners = false,
- useSTD3ASCIIRules = false,
- processingOption = "nontransitional"
- } = {}) {
- const result = processing(domainName, {
- processingOption,
- checkHyphens,
- checkBidi,
- checkJoiners,
- useSTD3ASCIIRules
- });
- return {
- domain: result.string,
- error: result.error
- };
- }
- module2.exports = {
- toASCII,
- toUnicode
- };
- }
- });
- // node_modules/whatwg-url/lib/infra.js
- var require_infra = __commonJS({
- "node_modules/whatwg-url/lib/infra.js"(exports2, module2) {
- "use strict";
- function isASCIIDigit(c) {
- return c >= 48 && c <= 57;
- }
- function isASCIIAlpha(c) {
- return c >= 65 && c <= 90 || c >= 97 && c <= 122;
- }
- function isASCIIAlphanumeric(c) {
- return isASCIIAlpha(c) || isASCIIDigit(c);
- }
- function isASCIIHex(c) {
- return isASCIIDigit(c) || c >= 65 && c <= 70 || c >= 97 && c <= 102;
- }
- module2.exports = {
- isASCIIDigit,
- isASCIIAlpha,
- isASCIIAlphanumeric,
- isASCIIHex
- };
- }
- });
- // node_modules/whatwg-url/lib/encoding.js
- var require_encoding = __commonJS({
- "node_modules/whatwg-url/lib/encoding.js"(exports2, module2) {
- "use strict";
- var utf8Encoder = new TextEncoder();
- var utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });
- function utf8Encode(string) {
- return utf8Encoder.encode(string);
- }
- function utf8DecodeWithoutBOM(bytes) {
- return utf8Decoder.decode(bytes);
- }
- module2.exports = {
- utf8Encode,
- utf8DecodeWithoutBOM
- };
- }
- });
- // node_modules/whatwg-url/lib/percent-encoding.js
- var require_percent_encoding = __commonJS({
- "node_modules/whatwg-url/lib/percent-encoding.js"(exports2, module2) {
- "use strict";
- var { isASCIIHex } = require_infra();
- var { utf8Encode } = require_encoding();
- function p(char) {
- return char.codePointAt(0);
- }
- function percentEncode(c) {
- let hex = c.toString(16).toUpperCase();
- if (hex.length === 1) {
- hex = `0${hex}`;
- }
- return `%${hex}`;
- }
- function percentDecodeBytes(input) {
- const output = new Uint8Array(input.byteLength);
- let outputIndex = 0;
- for (let i = 0; i < input.byteLength; ++i) {
- const byte = input[i];
- if (byte !== 37) {
- output[outputIndex++] = byte;
- } else if (byte === 37 && (!isASCIIHex(input[i + 1]) || !isASCIIHex(input[i + 2]))) {
- output[outputIndex++] = byte;
- } else {
- const bytePoint = parseInt(String.fromCodePoint(input[i + 1], input[i + 2]), 16);
- output[outputIndex++] = bytePoint;
- i += 2;
- }
- }
- return output.slice(0, outputIndex);
- }
- function percentDecodeString(input) {
- const bytes = utf8Encode(input);
- return percentDecodeBytes(bytes);
- }
- function isC0ControlPercentEncode(c) {
- return c <= 31 || c > 126;
- }
- var extraFragmentPercentEncodeSet = /* @__PURE__ */ new Set([p(" "), p('"'), p("<"), p(">"), p("`")]);
- function isFragmentPercentEncode(c) {
- return isC0ControlPercentEncode(c) || extraFragmentPercentEncodeSet.has(c);
- }
- var extraQueryPercentEncodeSet = /* @__PURE__ */ new Set([p(" "), p('"'), p("#"), p("<"), p(">")]);
- function isQueryPercentEncode(c) {
- return isC0ControlPercentEncode(c) || extraQueryPercentEncodeSet.has(c);
- }
- function isSpecialQueryPercentEncode(c) {
- return isQueryPercentEncode(c) || c === p("'");
- }
- var extraPathPercentEncodeSet = /* @__PURE__ */ new Set([p("?"), p("`"), p("{"), p("}")]);
- function isPathPercentEncode(c) {
- return isQueryPercentEncode(c) || extraPathPercentEncodeSet.has(c);
- }
- var extraUserinfoPercentEncodeSet = /* @__PURE__ */ new Set([p("/"), p(":"), p(";"), p("="), p("@"), p("["), p("\\"), p("]"), p("^"), p("|")]);
- function isUserinfoPercentEncode(c) {
- return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c);
- }
- var extraComponentPercentEncodeSet = /* @__PURE__ */ new Set([p("$"), p("%"), p("&"), p("+"), p(",")]);
- function isComponentPercentEncode(c) {
- return isUserinfoPercentEncode(c) || extraComponentPercentEncodeSet.has(c);
- }
- var extraURLEncodedPercentEncodeSet = /* @__PURE__ */ new Set([p("!"), p("'"), p("("), p(")"), p("~")]);
- function isURLEncodedPercentEncode(c) {
- return isComponentPercentEncode(c) || extraURLEncodedPercentEncodeSet.has(c);
- }
- function utf8PercentEncodeCodePointInternal(codePoint, percentEncodePredicate) {
- const bytes = utf8Encode(codePoint);
- let output = "";
- for (const byte of bytes) {
- if (!percentEncodePredicate(byte)) {
- output += String.fromCharCode(byte);
- } else {
- output += percentEncode(byte);
- }
- }
- return output;
- }
- function utf8PercentEncodeCodePoint(codePoint, percentEncodePredicate) {
- return utf8PercentEncodeCodePointInternal(String.fromCodePoint(codePoint), percentEncodePredicate);
- }
- function utf8PercentEncodeString(input, percentEncodePredicate, spaceAsPlus = false) {
- let output = "";
- for (const codePoint of input) {
- if (spaceAsPlus && codePoint === " ") {
- output += "+";
- } else {
- output += utf8PercentEncodeCodePointInternal(codePoint, percentEncodePredicate);
- }
- }
- return output;
- }
- module2.exports = {
- isC0ControlPercentEncode,
- isFragmentPercentEncode,
- isQueryPercentEncode,
- isSpecialQueryPercentEncode,
- isPathPercentEncode,
- isUserinfoPercentEncode,
- isURLEncodedPercentEncode,
- percentDecodeString,
- percentDecodeBytes,
- utf8PercentEncodeString,
- utf8PercentEncodeCodePoint
- };
- }
- });
- // node_modules/whatwg-url/lib/url-state-machine.js
- var require_url_state_machine = __commonJS({
- "node_modules/whatwg-url/lib/url-state-machine.js"(exports2, module2) {
- "use strict";
- var tr46 = require_tr46();
- var infra = require_infra();
- var { utf8DecodeWithoutBOM } = require_encoding();
- var {
- percentDecodeString,
- utf8PercentEncodeCodePoint,
- utf8PercentEncodeString,
- isC0ControlPercentEncode,
- isFragmentPercentEncode,
- isQueryPercentEncode,
- isSpecialQueryPercentEncode,
- isPathPercentEncode,
- isUserinfoPercentEncode
- } = require_percent_encoding();
- function p(char) {
- return char.codePointAt(0);
- }
- var specialSchemes = {
- ftp: 21,
- file: null,
- http: 80,
- https: 443,
- ws: 80,
- wss: 443
- };
- var failure = Symbol("failure");
- function countSymbols(str) {
- return [...str].length;
- }
- function at(input, idx) {
- const c = input[idx];
- return isNaN(c) ? void 0 : String.fromCodePoint(c);
- }
- function isSingleDot(buffer) {
- return buffer === "." || buffer.toLowerCase() === "%2e";
- }
- function isDoubleDot(buffer) {
- buffer = buffer.toLowerCase();
- return buffer === ".." || buffer === "%2e." || buffer === ".%2e" || buffer === "%2e%2e";
- }
- function isWindowsDriveLetterCodePoints(cp1, cp2) {
- return infra.isASCIIAlpha(cp1) && (cp2 === p(":") || cp2 === p("|"));
- }
- function isWindowsDriveLetterString(string) {
- return string.length === 2 && infra.isASCIIAlpha(string.codePointAt(0)) && (string[1] === ":" || string[1] === "|");
- }
- function isNormalizedWindowsDriveLetterString(string) {
- return string.length === 2 && infra.isASCIIAlpha(string.codePointAt(0)) && string[1] === ":";
- }
- function containsForbiddenHostCodePoint(string) {
- return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u) !== -1;
- }
- function containsForbiddenHostCodePointExcludingPercent(string) {
- return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u) !== -1;
- }
- function isSpecialScheme(scheme) {
- return specialSchemes[scheme] !== void 0;
- }
- function isSpecial(url) {
- return isSpecialScheme(url.scheme);
- }
- function isNotSpecial(url) {
- return !isSpecialScheme(url.scheme);
- }
- function defaultPort(scheme) {
- return specialSchemes[scheme];
- }
- function parseIPv4Number(input) {
- if (input === "") {
- return failure;
- }
- let R = 10;
- if (input.length >= 2 && input.charAt(0) === "0" && input.charAt(1).toLowerCase() === "x") {
- input = input.substring(2);
- R = 16;
- } else if (input.length >= 2 && input.charAt(0) === "0") {
- input = input.substring(1);
- R = 8;
- }
- if (input === "") {
- return 0;
- }
- let regex = /[^0-7]/u;
- if (R === 10) {
- regex = /[^0-9]/u;
- }
- if (R === 16) {
- regex = /[^0-9A-Fa-f]/u;
- }
- if (regex.test(input)) {
- return failure;
- }
- return parseInt(input, R);
- }
- function parseIPv4(input) {
- const parts = input.split(".");
- if (parts[parts.length - 1] === "") {
- if (parts.length > 1) {
- parts.pop();
- }
- }
- if (parts.length > 4) {
- return failure;
- }
- const numbers = [];
- for (const part of parts) {
- const n = parseIPv4Number(part);
- if (n === failure) {
- return failure;
- }
- numbers.push(n);
- }
- for (let i = 0; i < numbers.length - 1; ++i) {
- if (numbers[i] > 255) {
- return failure;
- }
- }
- if (numbers[numbers.length - 1] >= 256 ** (5 - numbers.length)) {
- return failure;
- }
- let ipv4 = numbers.pop();
- let counter = 0;
- for (const n of numbers) {
- ipv4 += n * 256 ** (3 - counter);
- ++counter;
- }
- return ipv4;
- }
- function serializeIPv4(address) {
- let output = "";
- let n = address;
- for (let i = 1; i <= 4; ++i) {
- output = String(n % 256) + output;
- if (i !== 4) {
- output = `.${output}`;
- }
- n = Math.floor(n / 256);
- }
- return output;
- }
- function parseIPv6(input) {
- const address = [0, 0, 0, 0, 0, 0, 0, 0];
- let pieceIndex = 0;
- let compress = null;
- let pointer = 0;
- input = Array.from(input, (c) => c.codePointAt(0));
- if (input[pointer] === p(":")) {
- if (input[pointer + 1] !== p(":")) {
- return failure;
- }
- pointer += 2;
- ++pieceIndex;
- compress = pieceIndex;
- }
- while (pointer < input.length) {
- if (pieceIndex === 8) {
- return failure;
- }
- if (input[pointer] === p(":")) {
- if (compress !== null) {
- return failure;
- }
- ++pointer;
- ++pieceIndex;
- compress = pieceIndex;
- continue;
- }
- let value = 0;
- let length = 0;
- while (length < 4 && infra.isASCIIHex(input[pointer])) {
- value = value * 16 + parseInt(at(input, pointer), 16);
- ++pointer;
- ++length;
- }
- if (input[pointer] === p(".")) {
- if (length === 0) {
- return failure;
- }
- pointer -= length;
- if (pieceIndex > 6) {
- return failure;
- }
- let numbersSeen = 0;
- while (input[pointer] !== void 0) {
- let ipv4Piece = null;
- if (numbersSeen > 0) {
- if (input[pointer] === p(".") && numbersSeen < 4) {
- ++pointer;
- } else {
- return failure;
- }
- }
- if (!infra.isASCIIDigit(input[pointer])) {
- return failure;
- }
- while (infra.isASCIIDigit(input[pointer])) {
- const number = parseInt(at(input, pointer));
- if (ipv4Piece === null) {
- ipv4Piece = number;
- } else if (ipv4Piece === 0) {
- return failure;
- } else {
- ipv4Piece = ipv4Piece * 10 + number;
- }
- if (ipv4Piece > 255) {
- return failure;
- }
- ++pointer;
- }
- address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
- ++numbersSeen;
- if (numbersSeen === 2 || numbersSeen === 4) {
- ++pieceIndex;
- }
- }
- if (numbersSeen !== 4) {
- return failure;
- }
- break;
- } else if (input[pointer] === p(":")) {
- ++pointer;
- if (input[pointer] === void 0) {
- return failure;
- }
- } else if (input[pointer] !== void 0) {
- return failure;
- }
- address[pieceIndex] = value;
- ++pieceIndex;
- }
- if (compress !== null) {
- let swaps = pieceIndex - compress;
- pieceIndex = 7;
- while (pieceIndex !== 0 && swaps > 0) {
- const temp = address[compress + swaps - 1];
- address[compress + swaps - 1] = address[pieceIndex];
- address[pieceIndex] = temp;
- --pieceIndex;
- --swaps;
- }
- } else if (compress === null && pieceIndex !== 8) {
- return failure;
- }
- return address;
- }
- function serializeIPv6(address) {
- let output = "";
- const compress = findLongestZeroSequence(address);
- let ignore0 = false;
- for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) {
- if (ignore0 && address[pieceIndex] === 0) {
- continue;
- } else if (ignore0) {
- ignore0 = false;
- }
- if (compress === pieceIndex) {
- const separator = pieceIndex === 0 ? "::" : ":";
- output += separator;
- ignore0 = true;
- continue;
- }
- output += address[pieceIndex].toString(16);
- if (pieceIndex !== 7) {
- output += ":";
- }
- }
- return output;
- }
- function parseHost(input, isNotSpecialArg = false) {
- if (input[0] === "[") {
- if (input[input.length - 1] !== "]") {
- return failure;
- }
- return parseIPv6(input.substring(1, input.length - 1));
- }
- if (isNotSpecialArg) {
- return parseOpaqueHost(input);
- }
- const domain = utf8DecodeWithoutBOM(percentDecodeString(input));
- const asciiDomain = domainToASCII(domain);
- if (asciiDomain === failure) {
- return failure;
- }
- if (containsForbiddenHostCodePoint(asciiDomain)) {
- return failure;
- }
- if (endsInANumber(asciiDomain)) {
- return parseIPv4(asciiDomain);
- }
- return asciiDomain;
- }
- function endsInANumber(input) {
- const parts = input.split(".");
- if (parts[parts.length - 1] === "") {
- if (parts.length === 1) {
- return false;
- }
- parts.pop();
- }
- const last = parts[parts.length - 1];
- if (parseIPv4Number(last) !== failure) {
- return true;
- }
- if (/^[0-9]+$/u.test(last)) {
- return true;
- }
- return false;
- }
- function parseOpaqueHost(input) {
- if (containsForbiddenHostCodePointExcludingPercent(input)) {
- return failure;
- }
- return utf8PercentEncodeString(input, isC0ControlPercentEncode);
- }
- function findLongestZeroSequence(arr) {
- let maxIdx = null;
- let maxLen = 1;
- let currStart = null;
- let currLen = 0;
- for (let i = 0; i < arr.length; ++i) {
- if (arr[i] !== 0) {
- if (currLen > maxLen) {
- maxIdx = currStart;
- maxLen = currLen;
- }
- currStart = null;
- currLen = 0;
- } else {
- if (currStart === null) {
- currStart = i;
- }
- ++currLen;
- }
- }
- if (currLen > maxLen) {
- return currStart;
- }
- return maxIdx;
- }
- function serializeHost(host) {
- if (typeof host === "number") {
- return serializeIPv4(host);
- }
- if (host instanceof Array) {
- return `[${serializeIPv6(host)}]`;
- }
- return host;
- }
- function domainToASCII(domain, beStrict = false) {
- const result = tr46.toASCII(domain, {
- checkBidi: true,
- checkHyphens: false,
- checkJoiners: true,
- useSTD3ASCIIRules: beStrict,
- verifyDNSLength: beStrict
- });
- if (result === null || result === "") {
- return failure;
- }
- return result;
- }
- function trimControlChars(url) {
- return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/ug, "");
- }
- function trimTabAndNewline(url) {
- return url.replace(/\u0009|\u000A|\u000D/ug, "");
- }
- function shortenPath(url) {
- const { path } = url;
- if (path.length === 0) {
- return;
- }
- if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) {
- return;
- }
- path.pop();
- }
- function includesCredentials(url) {
- return url.username !== "" || url.password !== "";
- }
- function cannotHaveAUsernamePasswordPort(url) {
- return url.host === null || url.host === "" || hasAnOpaquePath(url) || url.scheme === "file";
- }
- function hasAnOpaquePath(url) {
- return typeof url.path === "string";
- }
- function isNormalizedWindowsDriveLetter(string) {
- return /^[A-Za-z]:$/u.test(string);
- }
- function URLStateMachine(input, base, encodingOverride, url, stateOverride) {
- this.pointer = 0;
- this.input = input;
- this.base = base || null;
- this.encodingOverride = encodingOverride || "utf-8";
- this.stateOverride = stateOverride;
- this.url = url;
- this.failure = false;
- this.parseError = false;
- if (!this.url) {
- this.url = {
- scheme: "",
- username: "",
- password: "",
- host: null,
- port: null,
- path: [],
- query: null,
- fragment: null
- };
- const res2 = trimControlChars(this.input);
- if (res2 !== this.input) {
- this.parseError = true;
- }
- this.input = res2;
- }
- const res = trimTabAndNewline(this.input);
- if (res !== this.input) {
- this.parseError = true;
- }
- this.input = res;
- this.state = stateOverride || "scheme start";
- this.buffer = "";
- this.atFlag = false;
- this.arrFlag = false;
- this.passwordTokenSeenFlag = false;
- this.input = Array.from(this.input, (c) => c.codePointAt(0));
- for (; this.pointer <= this.input.length; ++this.pointer) {
- const c = this.input[this.pointer];
- const cStr = isNaN(c) ? void 0 : String.fromCodePoint(c);
- const ret = this[`parse ${this.state}`](c, cStr);
- if (!ret) {
- break;
- } else if (ret === failure) {
- this.failure = true;
- break;
- }
- }
- }
- URLStateMachine.prototype["parse scheme start"] = function parseSchemeStart(c, cStr) {
- if (infra.isASCIIAlpha(c)) {
- this.buffer += cStr.toLowerCase();
- this.state = "scheme";
- } else if (!this.stateOverride) {
- this.state = "no scheme";
- --this.pointer;
- } else {
- this.parseError = true;
- return failure;
- }
- return true;
- };
- URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) {
- if (infra.isASCIIAlphanumeric(c) || c === p("+") || c === p("-") || c === p(".")) {
- this.buffer += cStr.toLowerCase();
- } else if (c === p(":")) {
- if (this.stateOverride) {
- if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) {
- return false;
- }
- if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) {
- return false;
- }
- if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") {
- return false;
- }
- if (this.url.scheme === "file" && this.url.host === "") {
- return false;
- }
- }
- this.url.scheme = this.buffer;
- if (this.stateOverride) {
- if (this.url.port === defaultPort(this.url.scheme)) {
- this.url.port = null;
- }
- return false;
- }
- this.buffer = "";
- if (this.url.scheme === "file") {
- if (this.input[this.pointer + 1] !== p("/") || this.input[this.pointer + 2] !== p("/")) {
- this.parseError = true;
- }
- this.state = "file";
- } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) {
- this.state = "special relative or authority";
- } else if (isSpecial(this.url)) {
- this.state = "special authority slashes";
- } else if (this.input[this.pointer + 1] === p("/")) {
- this.state = "path or authority";
- ++this.pointer;
- } else {
- this.url.path = "";
- this.state = "opaque path";
- }
- } else if (!this.stateOverride) {
- this.buffer = "";
- this.state = "no scheme";
- this.pointer = -1;
- } else {
- this.parseError = true;
- return failure;
- }
- return true;
- };
- URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) {
- if (this.base === null || hasAnOpaquePath(this.base) && c !== p("#")) {
- return failure;
- } else if (hasAnOpaquePath(this.base) && c === p("#")) {
- this.url.scheme = this.base.scheme;
- this.url.path = this.base.path;
- this.url.query = this.base.query;
- this.url.fragment = "";
- this.state = "fragment";
- } else if (this.base.scheme === "file") {
- this.state = "file";
- --this.pointer;
- } else {
- this.state = "relative";
- --this.pointer;
- }
- return true;
- };
- URLStateMachine.prototype["parse special relative or authority"] = function parseSpecialRelativeOrAuthority(c) {
- if (c === p("/") && this.input[this.pointer + 1] === p("/")) {
- this.state = "special authority ignore slashes";
- ++this.pointer;
- } else {
- this.parseError = true;
- this.state = "relative";
- --this.pointer;
- }
- return true;
- };
- URLStateMachine.prototype["parse path or authority"] = function parsePathOrAuthority(c) {
- if (c === p("/")) {
- this.state = "authority";
- } else {
- this.state = "path";
- --this.pointer;
- }
- return true;
- };
- URLStateMachine.prototype["parse relative"] = function parseRelative(c) {
- this.url.scheme = this.base.scheme;
- if (c === p("/")) {
- this.state = "relative slash";
- } else if (isSpecial(this.url) && c === p("\\")) {
- this.parseError = true;
- this.state = "relative slash";
- } else {
- this.url.username = this.base.username;
- this.url.password = this.base.password;
- this.url.host = this.base.host;
- this.url.port = this.base.port;
- this.url.path = this.base.path.slice();
- this.url.query = this.base.query;
- if (c === p("?")) {
- this.url.query = "";
- this.state = "query";
- } else if (c === p("#")) {
- this.url.fragment = "";
- this.state = "fragment";
- } else if (!isNaN(c)) {
- this.url.query = null;
- this.url.path.pop();
- this.state = "path";
- --this.pointer;
- }
- }
- return true;
- };
- URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) {
- if (isSpecial(this.url) && (c === p("/") || c === p("\\"))) {
- if (c === p("\\")) {
- this.parseError = true;
- }
- this.state = "special authority ignore slashes";
- } else if (c === p("/")) {
- this.state = "authority";
- } else {
- this.url.username = this.base.username;
- this.url.password = this.base.password;
- this.url.host = this.base.host;
- this.url.port = this.base.port;
- this.state = "path";
- --this.pointer;
- }
- return true;
- };
- URLStateMachine.prototype["parse special authority slashes"] = function parseSpecialAuthoritySlashes(c) {
- if (c === p("/") && this.input[this.pointer + 1] === p("/")) {
- this.state = "special authority ignore slashes";
- ++this.pointer;
- } else {
- this.parseError = true;
- this.state = "special authority ignore slashes";
- --this.pointer;
- }
- return true;
- };
- URLStateMachine.prototype["parse special authority ignore slashes"] = function parseSpecialAuthorityIgnoreSlashes(c) {
- if (c !== p("/") && c !== p("\\")) {
- this.state = "authority";
- --this.pointer;
- } else {
- this.parseError = true;
- }
- return true;
- };
- URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) {
- if (c === p("@")) {
- this.parseError = true;
- if (this.atFlag) {
- this.buffer = `%40${this.buffer}`;
- }
- this.atFlag = true;
- const len = countSymbols(this.buffer);
- for (let pointer = 0; pointer < len; ++pointer) {
- const codePoint = this.buffer.codePointAt(pointer);
- if (codePoint === p(":") && !this.passwordTokenSeenFlag) {
- this.passwordTokenSeenFlag = true;
- continue;
- }
- const encodedCodePoints = utf8PercentEncodeCodePoint(codePoint, isUserinfoPercentEncode);
- if (this.passwordTokenSeenFlag) {
- this.url.password += encodedCodePoints;
- } else {
- this.url.username += encodedCodePoints;
- }
- }
- this.buffer = "";
- } else if (isNaN(c) || c === p("/") || c === p("?") || c === p("#") || isSpecial(this.url) && c === p("\\")) {
- if (this.atFlag && this.buffer === "") {
- this.parseError = true;
- return failure;
- }
- this.pointer -= countSymbols(this.buffer) + 1;
- this.buffer = "";
- this.state = "host";
- } else {
- this.buffer += cStr;
- }
- return true;
- };
- URLStateMachine.prototype["parse hostname"] = URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) {
- if (this.stateOverride && this.url.scheme === "file") {
- --this.pointer;
- this.state = "file host";
- } else if (c === p(":") && !this.arrFlag) {
- if (this.buffer === "") {
- this.parseError = true;
- return failure;
- }
- if (this.stateOverride === "hostname") {
- return false;
- }
- const host = parseHost(this.buffer, isNotSpecial(this.url));
- if (host === failure) {
- return failure;
- }
- this.url.host = host;
- this.buffer = "";
- this.state = "port";
- } else if (isNaN(c) || c === p("/") || c === p("?") || c === p("#") || isSpecial(this.url) && c === p("\\")) {
- --this.pointer;
- if (isSpecial(this.url) && this.buffer === "") {
- this.parseError = true;
- return failure;
- } else if (this.stateOverride && this.buffer === "" && (includesCredentials(this.url) || this.url.port !== null)) {
- this.parseError = true;
- return false;
- }
- const host = parseHost(this.buffer, isNotSpecial(this.url));
- if (host === failure) {
- return failure;
- }
- this.url.host = host;
- this.buffer = "";
- this.state = "path start";
- if (this.stateOverride) {
- return false;
- }
- } else {
- if (c === p("[")) {
- this.arrFlag = true;
- } else if (c === p("]")) {
- this.arrFlag = false;
- }
- this.buffer += cStr;
- }
- return true;
- };
- URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) {
- if (infra.isASCIIDigit(c)) {
- this.buffer += cStr;
- } else if (isNaN(c) || c === p("/") || c === p("?") || c === p("#") || isSpecial(this.url) && c === p("\\") || this.stateOverride) {
- if (this.buffer !== "") {
- const port = parseInt(this.buffer);
- if (port > 2 ** 16 - 1) {
- this.parseError = true;
- return failure;
- }
- this.url.port = port === defaultPort(this.url.scheme) ? null : port;
- this.buffer = "";
- }
- if (this.stateOverride) {
- return false;
- }
- this.state = "path start";
- --this.pointer;
- } else {
- this.parseError = true;
- return failure;
- }
- return true;
- };
- var fileOtherwiseCodePoints = /* @__PURE__ */ new Set([p("/"), p("\\"), p("?"), p("#")]);
- function startsWithWindowsDriveLetter(input, pointer) {
- const length = input.length - pointer;
- return length >= 2 && isWindowsDriveLetterCodePoints(input[pointer], input[pointer + 1]) && (length === 2 || fileOtherwiseCodePoints.has(input[pointer + 2]));
- }
- URLStateMachine.prototype["parse file"] = function parseFile(c) {
- this.url.scheme = "file";
- this.url.host = "";
- if (c === p("/") || c === p("\\")) {
- if (c === p("\\")) {
- this.parseError = true;
- }
- this.state = "file slash";
- } else if (this.base !== null && this.base.scheme === "file") {
- this.url.host = this.base.host;
- this.url.path = this.base.path.slice();
- this.url.query = this.base.query;
- if (c === p("?")) {
- this.url.query = "";
- this.state = "query";
- } else if (c === p("#")) {
- this.url.fragment = "";
- this.state = "fragment";
- } else if (!isNaN(c)) {
- this.url.query = null;
- if (!startsWithWindowsDriveLetter(this.input, this.pointer)) {
- shortenPath(this.url);
- } else {
- this.parseError = true;
- this.url.path = [];
- }
- this.state = "path";
- --this.pointer;
- }
- } else {
- this.state = "path";
- --this.pointer;
- }
- return true;
- };
- URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) {
- if (c === p("/") || c === p("\\")) {
- if (c === p("\\")) {
- this.parseError = true;
- }
- this.state = "file host";
- } else {
- if (this.base !== null && this.base.scheme === "file") {
- if (!startsWithWindowsDriveLetter(this.input, this.pointer) && isNormalizedWindowsDriveLetterString(this.base.path[0])) {
- this.url.path.push(this.base.path[0]);
- }
- this.url.host = this.base.host;
- }
- this.state = "path";
- --this.pointer;
- }
- return true;
- };
- URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) {
- if (isNaN(c) || c === p("/") || c === p("\\") || c === p("?") || c === p("#")) {
- --this.pointer;
- if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) {
- this.parseError = true;
- this.state = "path";
- } else if (this.buffer === "") {
- this.url.host = "";
- if (this.stateOverride) {
- return false;
- }
- this.state = "path start";
- } else {
- let host = parseHost(this.buffer, isNotSpecial(this.url));
- if (host === failure) {
- return failure;
- }
- if (host === "localhost") {
- host = "";
- }
- this.url.host = host;
- if (this.stateOverride) {
- return false;
- }
- this.buffer = "";
- this.state = "path start";
- }
- } else {
- this.buffer += cStr;
- }
- return true;
- };
- URLStateMachine.prototype["parse path start"] = function parsePathStart(c) {
- if (isSpecial(this.url)) {
- if (c === p("\\")) {
- this.parseError = true;
- }
- this.state = "path";
- if (c !== p("/") && c !== p("\\")) {
- --this.pointer;
- }
- } else if (!this.stateOverride && c === p("?")) {
- this.url.query = "";
- this.state = "query";
- } else if (!this.stateOverride && c === p("#")) {
- this.url.fragment = "";
- this.state = "fragment";
- } else if (c !== void 0) {
- this.state = "path";
- if (c !== p("/")) {
- --this.pointer;
- }
- } else if (this.stateOverride && this.url.host === null) {
- this.url.path.push("");
- }
- return true;
- };
- URLStateMachine.prototype["parse path"] = function parsePath(c) {
- if (isNaN(c) || c === p("/") || isSpecial(this.url) && c === p("\\") || !this.stateOverride && (c === p("?") || c === p("#"))) {
- if (isSpecial(this.url) && c === p("\\")) {
- this.parseError = true;
- }
- if (isDoubleDot(this.buffer)) {
- shortenPath(this.url);
- if (c !== p("/") && !(isSpecial(this.url) && c === p("\\"))) {
- this.url.path.push("");
- }
- } else if (isSingleDot(this.buffer) && c !== p("/") && !(isSpecial(this.url) && c === p("\\"))) {
- this.url.path.push("");
- } else if (!isSingleDot(this.buffer)) {
- if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) {
- this.buffer = `${this.buffer[0]}:`;
- }
- this.url.path.push(this.buffer);
- }
- this.buffer = "";
- if (c === p("?")) {
- this.url.query = "";
- this.state = "query";
- }
- if (c === p("#")) {
- this.url.fragment = "";
- this.state = "fragment";
- }
- } else {
- if (c === p("%") && (!infra.isASCIIHex(this.input[this.pointer + 1]) || !infra.isASCIIHex(this.input[this.pointer + 2]))) {
- this.parseError = true;
- }
- this.buffer += utf8PercentEncodeCodePoint(c, isPathPercentEncode);
- }
- return true;
- };
- URLStateMachine.prototype["parse opaque path"] = function parseOpaquePath(c) {
- if (c === p("?")) {
- this.url.query = "";
- this.state = "query";
- } else if (c === p("#")) {
- this.url.fragment = "";
- this.state = "fragment";
- } else {
- if (!isNaN(c) && c !== p("%")) {
- this.parseError = true;
- }
- if (c === p("%") && (!infra.isASCIIHex(this.input[this.pointer + 1]) || !infra.isASCIIHex(this.input[this.pointer + 2]))) {
- this.parseError = true;
- }
- if (!isNaN(c)) {
- this.url.path += utf8PercentEncodeCodePoint(c, isC0ControlPercentEncode);
- }
- }
- return true;
- };
- URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) {
- if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") {
- this.encodingOverride = "utf-8";
- }
- if (!this.stateOverride && c === p("#") || isNaN(c)) {
- const queryPercentEncodePredicate = isSpecial(this.url) ? isSpecialQueryPercentEncode : isQueryPercentEncode;
- this.url.query += utf8PercentEncodeString(this.buffer, queryPercentEncodePredicate);
- this.buffer = "";
- if (c === p("#")) {
- this.url.fragment = "";
- this.state = "fragment";
- }
- } else if (!isNaN(c)) {
- if (c === p("%") && (!infra.isASCIIHex(this.input[this.pointer + 1]) || !infra.isASCIIHex(this.input[this.pointer + 2]))) {
- this.parseError = true;
- }
- this.buffer += cStr;
- }
- return true;
- };
- URLStateMachine.prototype["parse fragment"] = function parseFragment(c) {
- if (!isNaN(c)) {
- if (c === p("%") && (!infra.isASCIIHex(this.input[this.pointer + 1]) || !infra.isASCIIHex(this.input[this.pointer + 2]))) {
- this.parseError = true;
- }
- this.url.fragment += utf8PercentEncodeCodePoint(c, isFragmentPercentEncode);
- }
- return true;
- };
- function serializeURL(url, excludeFragment) {
- let output = `${url.scheme}:`;
- if (url.host !== null) {
- output += "//";
- if (url.username !== "" || url.password !== "") {
- output += url.username;
- if (url.password !== "") {
- output += `:${url.password}`;
- }
- output += "@";
- }
- output += serializeHost(url.host);
- if (url.port !== null) {
- output += `:${url.port}`;
- }
- }
- if (url.host === null && !hasAnOpaquePath(url) && url.path.length > 1 && url.path[0] === "") {
- output += "/.";
- }
- output += serializePath(url);
- if (url.query !== null) {
- output += `?${url.query}`;
- }
- if (!excludeFragment && url.fragment !== null) {
- output += `#${url.fragment}`;
- }
- return output;
- }
- function serializeOrigin(tuple) {
- let result = `${tuple.scheme}://`;
- result += serializeHost(tuple.host);
- if (tuple.port !== null) {
- result += `:${tuple.port}`;
- }
- return result;
- }
- function serializePath(url) {
- if (hasAnOpaquePath(url)) {
- return url.path;
- }
- let output = "";
- for (const segment of url.path) {
- output += `/${segment}`;
- }
- return output;
- }
- module2.exports.serializeURL = serializeURL;
- module2.exports.serializePath = serializePath;
- module2.exports.serializeURLOrigin = function(url) {
- switch (url.scheme) {
- case "blob":
- try {
- return module2.exports.serializeURLOrigin(module2.exports.parseURL(serializePath(url)));
- } catch (e) {
- return "null";
- }
- case "ftp":
- case "http":
- case "https":
- case "ws":
- case "wss":
- return serializeOrigin({
- scheme: url.scheme,
- host: url.host,
- port: url.port
- });
- case "file":
- return "null";
- default:
- return "null";
- }
- };
- module2.exports.basicURLParse = function(input, options) {
- if (options === void 0) {
- options = {};
- }
- const usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride);
- if (usm.failure) {
- return null;
- }
- return usm.url;
- };
- module2.exports.setTheUsername = function(url, username) {
- url.username = utf8PercentEncodeString(username, isUserinfoPercentEncode);
- };
- module2.exports.setThePassword = function(url, password) {
- url.password = utf8PercentEncodeString(password, isUserinfoPercentEncode);
- };
- module2.exports.serializeHost = serializeHost;
- module2.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort;
- module2.exports.hasAnOpaquePath = hasAnOpaquePath;
- module2.exports.serializeInteger = function(integer) {
- return String(integer);
- };
- module2.exports.parseURL = function(input, options) {
- if (options === void 0) {
- options = {};
- }
- return module2.exports.basicURLParse(input, { baseURL: options.baseURL, encodingOverride: options.encodingOverride });
- };
- }
- });
- // node_modules/whatwg-url/lib/urlencoded.js
- var require_urlencoded = __commonJS({
- "node_modules/whatwg-url/lib/urlencoded.js"(exports2, module2) {
- "use strict";
- var { utf8Encode, utf8DecodeWithoutBOM } = require_encoding();
- var { percentDecodeBytes, utf8PercentEncodeString, isURLEncodedPercentEncode } = require_percent_encoding();
- function p(char) {
- return char.codePointAt(0);
- }
- function parseUrlencoded(input) {
- const sequences = strictlySplitByteSequence(input, p("&"));
- const output = [];
- for (const bytes of sequences) {
- if (bytes.length === 0) {
- continue;
- }
- let name, value;
- const indexOfEqual = bytes.indexOf(p("="));
- if (indexOfEqual >= 0) {
- name = bytes.slice(0, indexOfEqual);
- value = bytes.slice(indexOfEqual + 1);
- } else {
- name = bytes;
- value = new Uint8Array(0);
- }
- name = replaceByteInByteSequence(name, 43, 32);
- value = replaceByteInByteSequence(value, 43, 32);
- const nameString = utf8DecodeWithoutBOM(percentDecodeBytes(name));
- const valueString = utf8DecodeWithoutBOM(percentDecodeBytes(value));
- output.push([nameString, valueString]);
- }
- return output;
- }
- function parseUrlencodedString(input) {
- return parseUrlencoded(utf8Encode(input));
- }
- function serializeUrlencoded(tuples, encodingOverride = void 0) {
- let encoding = "utf-8";
- if (encodingOverride !== void 0) {
- encoding = encodingOverride;
- }
- let output = "";
- for (const [i, tuple] of tuples.entries()) {
- const name = utf8PercentEncodeString(tuple[0], isURLEncodedPercentEncode, true);
- let value = tuple[1];
- if (tuple.length > 2 && tuple[2] !== void 0) {
- if (tuple[2] === "hidden" && name === "_charset_") {
- value = encoding;
- } else if (tuple[2] === "file") {
- value = value.name;
- }
- }
- value = utf8PercentEncodeString(value, isURLEncodedPercentEncode, true);
- if (i !== 0) {
- output += "&";
- }
- output += `${name}=${value}`;
- }
- return output;
- }
- function strictlySplitByteSequence(buf, cp) {
- const list = [];
- let last = 0;
- let i = buf.indexOf(cp);
- while (i >= 0) {
- list.push(buf.slice(last, i));
- last = i + 1;
- i = buf.indexOf(cp, last);
- }
- if (last !== buf.length) {
- list.push(buf.slice(last));
- }
- return list;
- }
- function replaceByteInByteSequence(buf, from, to) {
- let i = buf.indexOf(from);
- while (i >= 0) {
- buf[i] = to;
- i = buf.indexOf(from, i + 1);
- }
- return buf;
- }
- module2.exports = {
- parseUrlencodedString,
- serializeUrlencoded
- };
- }
- });
- // node_modules/whatwg-url/lib/Function.js
- var require_Function = __commonJS({
- "node_modules/whatwg-url/lib/Function.js"(exports2) {
- "use strict";
- var conversions = require_lib();
- var utils = require_utils2();
- exports2.convert = (globalObject, value, { context = "The provided value" } = {}) => {
- if (typeof value !== "function") {
- throw new globalObject.TypeError(context + " is not a function");
- }
- function invokeTheCallbackFunction(...args) {
- const thisArg = utils.tryWrapperForImpl(this);
- let callResult;
- for (let i = 0; i < args.length; i++) {
- args[i] = utils.tryWrapperForImpl(args[i]);
- }
- callResult = Reflect.apply(value, thisArg, args);
- callResult = conversions["any"](callResult, { context, globals: globalObject });
- return callResult;
- }
- invokeTheCallbackFunction.construct = (...args) => {
- for (let i = 0; i < args.length; i++) {
- args[i] = utils.tryWrapperForImpl(args[i]);
- }
- let callResult = Reflect.construct(value, args);
- callResult = conversions["any"](callResult, { context, globals: globalObject });
- return callResult;
- };
- invokeTheCallbackFunction[utils.wrapperSymbol] = value;
- invokeTheCallbackFunction.objectReference = value;
- return invokeTheCallbackFunction;
- };
- }
- });
- // node_modules/whatwg-url/lib/URLSearchParams-impl.js
- var require_URLSearchParams_impl = __commonJS({
- "node_modules/whatwg-url/lib/URLSearchParams-impl.js"(exports2) {
- "use strict";
- var urlencoded = require_urlencoded();
- exports2.implementation = class URLSearchParamsImpl {
- constructor(globalObject, constructorArgs, { doNotStripQMark = false }) {
- let init = constructorArgs[0];
- this._list = [];
- this._url = null;
- if (!doNotStripQMark && typeof init === "string" && init[0] === "?") {
- init = init.slice(1);
- }
- if (Array.isArray(init)) {
- for (const pair of init) {
- if (pair.length !== 2) {
- throw new TypeError("Failed to construct 'URLSearchParams': parameter 1 sequence's element does not contain exactly two elements.");
- }
- this._list.push([pair[0], pair[1]]);
- }
- } else if (typeof init === "object" && Object.getPrototypeOf(init) === null) {
- for (const name of Object.keys(init)) {
- const value = init[name];
- this._list.push([name, value]);
- }
- } else {
- this._list = urlencoded.parseUrlencodedString(init);
- }
- }
- _updateSteps() {
- if (this._url !== null) {
- let query = urlencoded.serializeUrlencoded(this._list);
- if (query === "") {
- query = null;
- }
- this._url._url.query = query;
- }
- }
- append(name, value) {
- this._list.push([name, value]);
- this._updateSteps();
- }
- delete(name) {
- let i = 0;
- while (i < this._list.length) {
- if (this._list[i][0] === name) {
- this._list.splice(i, 1);
- } else {
- i++;
- }
- }
- this._updateSteps();
- }
- get(name) {
- for (const tuple of this._list) {
- if (tuple[0] === name) {
- return tuple[1];
- }
- }
- return null;
- }
- getAll(name) {
- const output = [];
- for (const tuple of this._list) {
- if (tuple[0] === name) {
- output.push(tuple[1]);
- }
- }
- return output;
- }
- has(name) {
- for (const tuple of this._list) {
- if (tuple[0] === name) {
- return true;
- }
- }
- return false;
- }
- set(name, value) {
- let found = false;
- let i = 0;
- while (i < this._list.length) {
- if (this._list[i][0] === name) {
- if (found) {
- this._list.splice(i, 1);
- } else {
- found = true;
- this._list[i][1] = value;
- i++;
- }
- } else {
- i++;
- }
- }
- if (!found) {
- this._list.push([name, value]);
- }
- this._updateSteps();
- }
- sort() {
- this._list.sort((a, b) => {
- if (a[0] < b[0]) {
- return -1;
- }
- if (a[0] > b[0]) {
- return 1;
- }
- return 0;
- });
- this._updateSteps();
- }
- [Symbol.iterator]() {
- return this._list[Symbol.iterator]();
- }
- toString() {
- return urlencoded.serializeUrlencoded(this._list);
- }
- };
- }
- });
- // node_modules/whatwg-url/lib/URLSearchParams.js
- var require_URLSearchParams = __commonJS({
- "node_modules/whatwg-url/lib/URLSearchParams.js"(exports2) {
- "use strict";
- var conversions = require_lib();
- var utils = require_utils2();
- var Function2 = require_Function();
- var newObjectInRealm = utils.newObjectInRealm;
- var implSymbol = utils.implSymbol;
- var ctorRegistrySymbol = utils.ctorRegistrySymbol;
- var interfaceName = "URLSearchParams";
- exports2.is = (value) => {
- return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
- };
- exports2.isImpl = (value) => {
- return utils.isObject(value) && value instanceof Impl.implementation;
- };
- exports2.convert = (globalObject, value, { context = "The provided value" } = {}) => {
- if (exports2.is(value)) {
- return utils.implForWrapper(value);
- }
- throw new globalObject.TypeError(`${context} is not of type 'URLSearchParams'.`);
- };
- exports2.createDefaultIterator = (globalObject, target, kind) => {
- const ctorRegistry = globalObject[ctorRegistrySymbol];
- const iteratorPrototype = ctorRegistry["URLSearchParams Iterator"];
- const iterator = Object.create(iteratorPrototype);
- Object.defineProperty(iterator, utils.iterInternalSymbol, {
- value: { target, kind, index: 0 },
- configurable: true
- });
- return iterator;
- };
- function makeWrapper(globalObject, newTarget) {
- let proto;
- if (newTarget !== void 0) {
- proto = newTarget.prototype;
- }
- if (!utils.isObject(proto)) {
- proto = globalObject[ctorRegistrySymbol]["URLSearchParams"].prototype;
- }
- return Object.create(proto);
- }
- exports2.create = (globalObject, constructorArgs, privateData) => {
- const wrapper = makeWrapper(globalObject);
- return exports2.setup(wrapper, globalObject, constructorArgs, privateData);
- };
- exports2.createImpl = (globalObject, constructorArgs, privateData) => {
- const wrapper = exports2.create(globalObject, constructorArgs, privateData);
- return utils.implForWrapper(wrapper);
- };
- exports2._internalSetup = (wrapper, globalObject) => {
- };
- exports2.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
- privateData.wrapper = wrapper;
- exports2._internalSetup(wrapper, globalObject);
- Object.defineProperty(wrapper, implSymbol, {
- value: new Impl.implementation(globalObject, constructorArgs, privateData),
- configurable: true
- });
- wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
- if (Impl.init) {
- Impl.init(wrapper[implSymbol]);
- }
- return wrapper;
- };
- exports2.new = (globalObject, newTarget) => {
- const wrapper = makeWrapper(globalObject, newTarget);
- exports2._internalSetup(wrapper, globalObject);
- Object.defineProperty(wrapper, implSymbol, {
- value: Object.create(Impl.implementation.prototype),
- configurable: true
- });
- wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
- if (Impl.init) {
- Impl.init(wrapper[implSymbol]);
- }
- return wrapper[implSymbol];
- };
- var exposed = /* @__PURE__ */ new Set(["Window", "Worker"]);
- exports2.install = (globalObject, globalNames) => {
- if (!globalNames.some((globalName) => exposed.has(globalName))) {
- return;
- }
- const ctorRegistry = utils.initCtorRegistry(globalObject);
- class URLSearchParams {
- constructor() {
- const args = [];
- {
- let curArg = arguments[0];
- if (curArg !== void 0) {
- if (utils.isObject(curArg)) {
- if (curArg[Symbol.iterator] !== void 0) {
- if (!utils.isObject(curArg)) {
- throw new globalObject.TypeError(
- "Failed to construct 'URLSearchParams': parameter 1 sequence is not an iterable object."
- );
- } else {
- const V = [];
- const tmp = curArg;
- for (let nextItem of tmp) {
- if (!utils.isObject(nextItem)) {
- throw new globalObject.TypeError(
- "Failed to construct 'URLSearchParams': parameter 1 sequence's element is not an iterable object."
- );
- } else {
- const V2 = [];
- const tmp2 = nextItem;
- for (let nextItem2 of tmp2) {
- nextItem2 = conversions["USVString"](nextItem2, {
- context: "Failed to construct 'URLSearchParams': parameter 1 sequence's element's element",
- globals: globalObject
- });
- V2.push(nextItem2);
- }
- nextItem = V2;
- }
- V.push(nextItem);
- }
- curArg = V;
- }
- } else {
- if (!utils.isObject(curArg)) {
- throw new globalObject.TypeError(
- "Failed to construct 'URLSearchParams': parameter 1 record is not an object."
- );
- } else {
- const result = /* @__PURE__ */ Object.create(null);
- for (const key of Reflect.ownKeys(curArg)) {
- const desc = Object.getOwnPropertyDescriptor(curArg, key);
- if (desc && desc.enumerable) {
- let typedKey = key;
- typedKey = conversions["USVString"](typedKey, {
- context: "Failed to construct 'URLSearchParams': parameter 1 record's key",
- globals: globalObject
- });
- let typedValue = curArg[key];
- typedValue = conversions["USVString"](typedValue, {
- context: "Failed to construct 'URLSearchParams': parameter 1 record's value",
- globals: globalObject
- });
- result[typedKey] = typedValue;
- }
- }
- curArg = result;
- }
- }
- } else {
- curArg = conversions["USVString"](curArg, {
- context: "Failed to construct 'URLSearchParams': parameter 1",
- globals: globalObject
- });
- }
- } else {
- curArg = "";
- }
- args.push(curArg);
- }
- return exports2.setup(Object.create(new.target.prototype), globalObject, args);
- }
- append(name, value) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError(
- "'append' called on an object that is not a valid instance of URLSearchParams."
- );
- }
- if (arguments.length < 2) {
- throw new globalObject.TypeError(
- `Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only ${arguments.length} present.`
- );
- }
- const args = [];
- {
- let curArg = arguments[0];
- curArg = conversions["USVString"](curArg, {
- context: "Failed to execute 'append' on 'URLSearchParams': parameter 1",
- globals: globalObject
- });
- args.push(curArg);
- }
- {
- let curArg = arguments[1];
- curArg = conversions["USVString"](curArg, {
- context: "Failed to execute 'append' on 'URLSearchParams': parameter 2",
- globals: globalObject
- });
- args.push(curArg);
- }
- return utils.tryWrapperForImpl(esValue[implSymbol].append(...args));
- }
- delete(name) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError(
- "'delete' called on an object that is not a valid instance of URLSearchParams."
- );
- }
- if (arguments.length < 1) {
- throw new globalObject.TypeError(
- `Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only ${arguments.length} present.`
- );
- }
- const args = [];
- {
- let curArg = arguments[0];
- curArg = conversions["USVString"](curArg, {
- context: "Failed to execute 'delete' on 'URLSearchParams': parameter 1",
- globals: globalObject
- });
- args.push(curArg);
- }
- return utils.tryWrapperForImpl(esValue[implSymbol].delete(...args));
- }
- get(name) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get' called on an object that is not a valid instance of URLSearchParams.");
- }
- if (arguments.length < 1) {
- throw new globalObject.TypeError(
- `Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only ${arguments.length} present.`
- );
- }
- const args = [];
- {
- let curArg = arguments[0];
- curArg = conversions["USVString"](curArg, {
- context: "Failed to execute 'get' on 'URLSearchParams': parameter 1",
- globals: globalObject
- });
- args.push(curArg);
- }
- return esValue[implSymbol].get(...args);
- }
- getAll(name) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError(
- "'getAll' called on an object that is not a valid instance of URLSearchParams."
- );
- }
- if (arguments.length < 1) {
- throw new globalObject.TypeError(
- `Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only ${arguments.length} present.`
- );
- }
- const args = [];
- {
- let curArg = arguments[0];
- curArg = conversions["USVString"](curArg, {
- context: "Failed to execute 'getAll' on 'URLSearchParams': parameter 1",
- globals: globalObject
- });
- args.push(curArg);
- }
- return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args));
- }
- has(name) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'has' called on an object that is not a valid instance of URLSearchParams.");
- }
- if (arguments.length < 1) {
- throw new globalObject.TypeError(
- `Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only ${arguments.length} present.`
- );
- }
- const args = [];
- {
- let curArg = arguments[0];
- curArg = conversions["USVString"](curArg, {
- context: "Failed to execute 'has' on 'URLSearchParams': parameter 1",
- globals: globalObject
- });
- args.push(curArg);
- }
- return esValue[implSymbol].has(...args);
- }
- set(name, value) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set' called on an object that is not a valid instance of URLSearchParams.");
- }
- if (arguments.length < 2) {
- throw new globalObject.TypeError(
- `Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only ${arguments.length} present.`
- );
- }
- const args = [];
- {
- let curArg = arguments[0];
- curArg = conversions["USVString"](curArg, {
- context: "Failed to execute 'set' on 'URLSearchParams': parameter 1",
- globals: globalObject
- });
- args.push(curArg);
- }
- {
- let curArg = arguments[1];
- curArg = conversions["USVString"](curArg, {
- context: "Failed to execute 'set' on 'URLSearchParams': parameter 2",
- globals: globalObject
- });
- args.push(curArg);
- }
- return utils.tryWrapperForImpl(esValue[implSymbol].set(...args));
- }
- sort() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'sort' called on an object that is not a valid instance of URLSearchParams.");
- }
- return utils.tryWrapperForImpl(esValue[implSymbol].sort());
- }
- toString() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError(
- "'toString' called on an object that is not a valid instance of URLSearchParams."
- );
- }
- return esValue[implSymbol].toString();
- }
- keys() {
- if (!exports2.is(this)) {
- throw new globalObject.TypeError("'keys' called on an object that is not a valid instance of URLSearchParams.");
- }
- return exports2.createDefaultIterator(globalObject, this, "key");
- }
- values() {
- if (!exports2.is(this)) {
- throw new globalObject.TypeError(
- "'values' called on an object that is not a valid instance of URLSearchParams."
- );
- }
- return exports2.createDefaultIterator(globalObject, this, "value");
- }
- entries() {
- if (!exports2.is(this)) {
- throw new globalObject.TypeError(
- "'entries' called on an object that is not a valid instance of URLSearchParams."
- );
- }
- return exports2.createDefaultIterator(globalObject, this, "key+value");
- }
- forEach(callback) {
- if (!exports2.is(this)) {
- throw new globalObject.TypeError(
- "'forEach' called on an object that is not a valid instance of URLSearchParams."
- );
- }
- if (arguments.length < 1) {
- throw new globalObject.TypeError(
- "Failed to execute 'forEach' on 'iterable': 1 argument required, but only 0 present."
- );
- }
- callback = Function2.convert(globalObject, callback, {
- context: "Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1"
- });
- const thisArg = arguments[1];
- let pairs = Array.from(this[implSymbol]);
- let i = 0;
- while (i < pairs.length) {
- const [key, value] = pairs[i].map(utils.tryWrapperForImpl);
- callback.call(thisArg, value, key, this);
- pairs = Array.from(this[implSymbol]);
- i++;
- }
- }
- }
- Object.defineProperties(URLSearchParams.prototype, {
- append: { enumerable: true },
- delete: { enumerable: true },
- get: { enumerable: true },
- getAll: { enumerable: true },
- has: { enumerable: true },
- set: { enumerable: true },
- sort: { enumerable: true },
- toString: { enumerable: true },
- keys: { enumerable: true },
- values: { enumerable: true },
- entries: { enumerable: true },
- forEach: { enumerable: true },
- [Symbol.toStringTag]: { value: "URLSearchParams", configurable: true },
- [Symbol.iterator]: { value: URLSearchParams.prototype.entries, configurable: true, writable: true }
- });
- ctorRegistry[interfaceName] = URLSearchParams;
- ctorRegistry["URLSearchParams Iterator"] = Object.create(ctorRegistry["%IteratorPrototype%"], {
- [Symbol.toStringTag]: {
- configurable: true,
- value: "URLSearchParams Iterator"
- }
- });
- utils.define(ctorRegistry["URLSearchParams Iterator"], {
- next() {
- const internal = this && this[utils.iterInternalSymbol];
- if (!internal) {
- throw new globalObject.TypeError("next() called on a value that is not a URLSearchParams iterator object");
- }
- const { target, kind, index } = internal;
- const values = Array.from(target[implSymbol]);
- const len = values.length;
- if (index >= len) {
- return newObjectInRealm(globalObject, { value: void 0, done: true });
- }
- const pair = values[index];
- internal.index = index + 1;
- return newObjectInRealm(globalObject, utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind));
- }
- });
- Object.defineProperty(globalObject, interfaceName, {
- configurable: true,
- writable: true,
- value: URLSearchParams
- });
- };
- var Impl = require_URLSearchParams_impl();
- }
- });
- // node_modules/whatwg-url/lib/URL-impl.js
- var require_URL_impl = __commonJS({
- "node_modules/whatwg-url/lib/URL-impl.js"(exports2) {
- "use strict";
- var usm = require_url_state_machine();
- var urlencoded = require_urlencoded();
- var URLSearchParams = require_URLSearchParams();
- exports2.implementation = class URLImpl {
- constructor(globalObject, constructorArgs) {
- const url = constructorArgs[0];
- const base = constructorArgs[1];
- let parsedBase = null;
- if (base !== void 0) {
- parsedBase = usm.basicURLParse(base);
- if (parsedBase === null) {
- throw new TypeError(`Invalid base URL: ${base}`);
- }
- }
- const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });
- if (parsedURL === null) {
- throw new TypeError(`Invalid URL: ${url}`);
- }
- const query = parsedURL.query !== null ? parsedURL.query : "";
- this._url = parsedURL;
- this._query = URLSearchParams.createImpl(globalObject, [query], { doNotStripQMark: true });
- this._query._url = this;
- }
- get href() {
- return usm.serializeURL(this._url);
- }
- set href(v) {
- const parsedURL = usm.basicURLParse(v);
- if (parsedURL === null) {
- throw new TypeError(`Invalid URL: ${v}`);
- }
- this._url = parsedURL;
- this._query._list.splice(0);
- const { query } = parsedURL;
- if (query !== null) {
- this._query._list = urlencoded.parseUrlencodedString(query);
- }
- }
- get origin() {
- return usm.serializeURLOrigin(this._url);
- }
- get protocol() {
- return `${this._url.scheme}:`;
- }
- set protocol(v) {
- usm.basicURLParse(`${v}:`, { url: this._url, stateOverride: "scheme start" });
- }
- get username() {
- return this._url.username;
- }
- set username(v) {
- if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
- return;
- }
- usm.setTheUsername(this._url, v);
- }
- get password() {
- return this._url.password;
- }
- set password(v) {
- if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
- return;
- }
- usm.setThePassword(this._url, v);
- }
- get host() {
- const url = this._url;
- if (url.host === null) {
- return "";
- }
- if (url.port === null) {
- return usm.serializeHost(url.host);
- }
- return `${usm.serializeHost(url.host)}:${usm.serializeInteger(url.port)}`;
- }
- set host(v) {
- if (usm.hasAnOpaquePath(this._url)) {
- return;
- }
- usm.basicURLParse(v, { url: this._url, stateOverride: "host" });
- }
- get hostname() {
- if (this._url.host === null) {
- return "";
- }
- return usm.serializeHost(this._url.host);
- }
- set hostname(v) {
- if (usm.hasAnOpaquePath(this._url)) {
- return;
- }
- usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" });
- }
- get port() {
- if (this._url.port === null) {
- return "";
- }
- return usm.serializeInteger(this._url.port);
- }
- set port(v) {
- if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
- return;
- }
- if (v === "") {
- this._url.port = null;
- } else {
- usm.basicURLParse(v, { url: this._url, stateOverride: "port" });
- }
- }
- get pathname() {
- return usm.serializePath(this._url);
- }
- set pathname(v) {
- if (usm.hasAnOpaquePath(this._url)) {
- return;
- }
- this._url.path = [];
- usm.basicURLParse(v, { url: this._url, stateOverride: "path start" });
- }
- get search() {
- if (this._url.query === null || this._url.query === "") {
- return "";
- }
- return `?${this._url.query}`;
- }
- set search(v) {
- const url = this._url;
- if (v === "") {
- url.query = null;
- this._query._list = [];
- return;
- }
- const input = v[0] === "?" ? v.substring(1) : v;
- url.query = "";
- usm.basicURLParse(input, { url, stateOverride: "query" });
- this._query._list = urlencoded.parseUrlencodedString(input);
- }
- get searchParams() {
- return this._query;
- }
- get hash() {
- if (this._url.fragment === null || this._url.fragment === "") {
- return "";
- }
- return `#${this._url.fragment}`;
- }
- set hash(v) {
- if (v === "") {
- this._url.fragment = null;
- return;
- }
- const input = v[0] === "#" ? v.substring(1) : v;
- this._url.fragment = "";
- usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" });
- }
- toJSON() {
- return this.href;
- }
- };
- }
- });
- // node_modules/whatwg-url/lib/URL.js
- var require_URL = __commonJS({
- "node_modules/whatwg-url/lib/URL.js"(exports2) {
- "use strict";
- var conversions = require_lib();
- var utils = require_utils2();
- var implSymbol = utils.implSymbol;
- var ctorRegistrySymbol = utils.ctorRegistrySymbol;
- var interfaceName = "URL";
- exports2.is = (value) => {
- return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
- };
- exports2.isImpl = (value) => {
- return utils.isObject(value) && value instanceof Impl.implementation;
- };
- exports2.convert = (globalObject, value, { context = "The provided value" } = {}) => {
- if (exports2.is(value)) {
- return utils.implForWrapper(value);
- }
- throw new globalObject.TypeError(`${context} is not of type 'URL'.`);
- };
- function makeWrapper(globalObject, newTarget) {
- let proto;
- if (newTarget !== void 0) {
- proto = newTarget.prototype;
- }
- if (!utils.isObject(proto)) {
- proto = globalObject[ctorRegistrySymbol]["URL"].prototype;
- }
- return Object.create(proto);
- }
- exports2.create = (globalObject, constructorArgs, privateData) => {
- const wrapper = makeWrapper(globalObject);
- return exports2.setup(wrapper, globalObject, constructorArgs, privateData);
- };
- exports2.createImpl = (globalObject, constructorArgs, privateData) => {
- const wrapper = exports2.create(globalObject, constructorArgs, privateData);
- return utils.implForWrapper(wrapper);
- };
- exports2._internalSetup = (wrapper, globalObject) => {
- };
- exports2.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
- privateData.wrapper = wrapper;
- exports2._internalSetup(wrapper, globalObject);
- Object.defineProperty(wrapper, implSymbol, {
- value: new Impl.implementation(globalObject, constructorArgs, privateData),
- configurable: true
- });
- wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
- if (Impl.init) {
- Impl.init(wrapper[implSymbol]);
- }
- return wrapper;
- };
- exports2.new = (globalObject, newTarget) => {
- const wrapper = makeWrapper(globalObject, newTarget);
- exports2._internalSetup(wrapper, globalObject);
- Object.defineProperty(wrapper, implSymbol, {
- value: Object.create(Impl.implementation.prototype),
- configurable: true
- });
- wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
- if (Impl.init) {
- Impl.init(wrapper[implSymbol]);
- }
- return wrapper[implSymbol];
- };
- var exposed = /* @__PURE__ */ new Set(["Window", "Worker"]);
- exports2.install = (globalObject, globalNames) => {
- if (!globalNames.some((globalName) => exposed.has(globalName))) {
- return;
- }
- const ctorRegistry = utils.initCtorRegistry(globalObject);
- class URL {
- constructor(url) {
- if (arguments.length < 1) {
- throw new globalObject.TypeError(
- `Failed to construct 'URL': 1 argument required, but only ${arguments.length} present.`
- );
- }
- const args = [];
- {
- let curArg = arguments[0];
- curArg = conversions["USVString"](curArg, {
- context: "Failed to construct 'URL': parameter 1",
- globals: globalObject
- });
- args.push(curArg);
- }
- {
- let curArg = arguments[1];
- if (curArg !== void 0) {
- curArg = conversions["USVString"](curArg, {
- context: "Failed to construct 'URL': parameter 2",
- globals: globalObject
- });
- }
- args.push(curArg);
- }
- return exports2.setup(Object.create(new.target.prototype), globalObject, args);
- }
- toJSON() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'toJSON' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol].toJSON();
- }
- get href() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get href' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["href"];
- }
- set href(V) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set href' called on an object that is not a valid instance of URL.");
- }
- V = conversions["USVString"](V, {
- context: "Failed to set the 'href' property on 'URL': The provided value",
- globals: globalObject
- });
- esValue[implSymbol]["href"] = V;
- }
- toString() {
- const esValue = this;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'toString' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["href"];
- }
- get origin() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get origin' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["origin"];
- }
- get protocol() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get protocol' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["protocol"];
- }
- set protocol(V) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set protocol' called on an object that is not a valid instance of URL.");
- }
- V = conversions["USVString"](V, {
- context: "Failed to set the 'protocol' property on 'URL': The provided value",
- globals: globalObject
- });
- esValue[implSymbol]["protocol"] = V;
- }
- get username() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get username' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["username"];
- }
- set username(V) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set username' called on an object that is not a valid instance of URL.");
- }
- V = conversions["USVString"](V, {
- context: "Failed to set the 'username' property on 'URL': The provided value",
- globals: globalObject
- });
- esValue[implSymbol]["username"] = V;
- }
- get password() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get password' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["password"];
- }
- set password(V) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set password' called on an object that is not a valid instance of URL.");
- }
- V = conversions["USVString"](V, {
- context: "Failed to set the 'password' property on 'URL': The provided value",
- globals: globalObject
- });
- esValue[implSymbol]["password"] = V;
- }
- get host() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get host' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["host"];
- }
- set host(V) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set host' called on an object that is not a valid instance of URL.");
- }
- V = conversions["USVString"](V, {
- context: "Failed to set the 'host' property on 'URL': The provided value",
- globals: globalObject
- });
- esValue[implSymbol]["host"] = V;
- }
- get hostname() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get hostname' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["hostname"];
- }
- set hostname(V) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set hostname' called on an object that is not a valid instance of URL.");
- }
- V = conversions["USVString"](V, {
- context: "Failed to set the 'hostname' property on 'URL': The provided value",
- globals: globalObject
- });
- esValue[implSymbol]["hostname"] = V;
- }
- get port() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get port' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["port"];
- }
- set port(V) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set port' called on an object that is not a valid instance of URL.");
- }
- V = conversions["USVString"](V, {
- context: "Failed to set the 'port' property on 'URL': The provided value",
- globals: globalObject
- });
- esValue[implSymbol]["port"] = V;
- }
- get pathname() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get pathname' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["pathname"];
- }
- set pathname(V) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set pathname' called on an object that is not a valid instance of URL.");
- }
- V = conversions["USVString"](V, {
- context: "Failed to set the 'pathname' property on 'URL': The provided value",
- globals: globalObject
- });
- esValue[implSymbol]["pathname"] = V;
- }
- get search() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get search' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["search"];
- }
- set search(V) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set search' called on an object that is not a valid instance of URL.");
- }
- V = conversions["USVString"](V, {
- context: "Failed to set the 'search' property on 'URL': The provided value",
- globals: globalObject
- });
- esValue[implSymbol]["search"] = V;
- }
- get searchParams() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get searchParams' called on an object that is not a valid instance of URL.");
- }
- return utils.getSameObject(this, "searchParams", () => {
- return utils.tryWrapperForImpl(esValue[implSymbol]["searchParams"]);
- });
- }
- get hash() {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'get hash' called on an object that is not a valid instance of URL.");
- }
- return esValue[implSymbol]["hash"];
- }
- set hash(V) {
- const esValue = this !== null && this !== void 0 ? this : globalObject;
- if (!exports2.is(esValue)) {
- throw new globalObject.TypeError("'set hash' called on an object that is not a valid instance of URL.");
- }
- V = conversions["USVString"](V, {
- context: "Failed to set the 'hash' property on 'URL': The provided value",
- globals: globalObject
- });
- esValue[implSymbol]["hash"] = V;
- }
- }
- Object.defineProperties(URL.prototype, {
- toJSON: { enumerable: true },
- href: { enumerable: true },
- toString: { enumerable: true },
- origin: { enumerable: true },
- protocol: { enumerable: true },
- username: { enumerable: true },
- password: { enumerable: true },
- host: { enumerable: true },
- hostname: { enumerable: true },
- port: { enumerable: true },
- pathname: { enumerable: true },
- search: { enumerable: true },
- searchParams: { enumerable: true },
- hash: { enumerable: true },
- [Symbol.toStringTag]: { value: "URL", configurable: true }
- });
- ctorRegistry[interfaceName] = URL;
- Object.defineProperty(globalObject, interfaceName, {
- configurable: true,
- writable: true,
- value: URL
- });
- if (globalNames.includes("Window")) {
- Object.defineProperty(globalObject, "webkitURL", {
- configurable: true,
- writable: true,
- value: URL
- });
- }
- };
- var Impl = require_URL_impl();
- }
- });
- // node_modules/whatwg-url/webidl2js-wrapper.js
- var require_webidl2js_wrapper = __commonJS({
- "node_modules/whatwg-url/webidl2js-wrapper.js"(exports2) {
- "use strict";
- var URL = require_URL();
- var URLSearchParams = require_URLSearchParams();
- exports2.URL = URL;
- exports2.URLSearchParams = URLSearchParams;
- }
- });
- // node_modules/whatwg-url/index.js
- var require_whatwg_url = __commonJS({
- "node_modules/whatwg-url/index.js"(exports2) {
- "use strict";
- var { URL, URLSearchParams } = require_webidl2js_wrapper();
- var urlStateMachine = require_url_state_machine();
- var percentEncoding = require_percent_encoding();
- var sharedGlobalObject = { Array, Object, Promise, String, TypeError };
- URL.install(sharedGlobalObject, ["Window"]);
- URLSearchParams.install(sharedGlobalObject, ["Window"]);
- exports2.URL = sharedGlobalObject.URL;
- exports2.URLSearchParams = sharedGlobalObject.URLSearchParams;
- exports2.parseURL = urlStateMachine.parseURL;
- exports2.basicURLParse = urlStateMachine.basicURLParse;
- exports2.serializeURL = urlStateMachine.serializeURL;
- exports2.serializePath = urlStateMachine.serializePath;
- exports2.serializeHost = urlStateMachine.serializeHost;
- exports2.serializeInteger = urlStateMachine.serializeInteger;
- exports2.serializeURLOrigin = urlStateMachine.serializeURLOrigin;
- exports2.setTheUsername = urlStateMachine.setTheUsername;
- exports2.setThePassword = urlStateMachine.setThePassword;
- exports2.cannotHaveAUsernamePasswordPort = urlStateMachine.cannotHaveAUsernamePasswordPort;
- exports2.hasAnOpaquePath = urlStateMachine.hasAnOpaquePath;
- exports2.percentDecodeString = percentEncoding.percentDecodeString;
- exports2.percentDecodeBytes = percentEncoding.percentDecodeBytes;
- }
- });
- // node_modules/mongodb-connection-string-url/lib/redact.js
- var require_redact = __commonJS({
- "node_modules/mongodb-connection-string-url/lib/redact.js"(exports2) {
- "use strict";
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() {
- return m[k];
- } };
- }
- Object.defineProperty(o, k2, desc);
- } : function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- o[k2] = m[k];
- });
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- } : function(o, v) {
- o["default"] = v;
- });
- var __importStar = exports2 && exports2.__importStar || function(mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) {
- for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- }
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.redactConnectionString = exports2.redactValidConnectionString = void 0;
- var index_1 = __importStar(require_lib2());
- function redactValidConnectionString(inputUrl, options) {
- var _a, _b;
- const url = inputUrl.clone();
- const replacementString = (_a = options === null || options === void 0 ? void 0 : options.replacementString) !== null && _a !== void 0 ? _a : "_credentials_";
- const redactUsernames = (_b = options === null || options === void 0 ? void 0 : options.redactUsernames) !== null && _b !== void 0 ? _b : true;
- if ((url.username || url.password) && redactUsernames) {
- url.username = replacementString;
- url.password = "";
- } else if (url.password) {
- url.password = replacementString;
- }
- if (url.searchParams.has("authMechanismProperties")) {
- const props = new index_1.CommaAndColonSeparatedRecord(url.searchParams.get("authMechanismProperties"));
- if (props.get("AWS_SESSION_TOKEN")) {
- props.set("AWS_SESSION_TOKEN", replacementString);
- url.searchParams.set("authMechanismProperties", props.toString());
- }
- }
- if (url.searchParams.has("tlsCertificateKeyFilePassword")) {
- url.searchParams.set("tlsCertificateKeyFilePassword", replacementString);
- }
- if (url.searchParams.has("proxyUsername") && redactUsernames) {
- url.searchParams.set("proxyUsername", replacementString);
- }
- if (url.searchParams.has("proxyPassword")) {
- url.searchParams.set("proxyPassword", replacementString);
- }
- return url;
- }
- exports2.redactValidConnectionString = redactValidConnectionString;
- function redactConnectionString(uri, options) {
- var _a, _b;
- const replacementString = (_a = options === null || options === void 0 ? void 0 : options.replacementString) !== null && _a !== void 0 ? _a : "<credentials>";
- const redactUsernames = (_b = options === null || options === void 0 ? void 0 : options.redactUsernames) !== null && _b !== void 0 ? _b : true;
- let parsed;
- try {
- parsed = new index_1.default(uri);
- } catch (_c) {
- }
- if (parsed) {
- options = { ...options, replacementString: "___credentials___" };
- return parsed.redact(options).toString().replace(/___credentials___/g, replacementString);
- }
- const R = replacementString;
- const replacements = [
- (uri2) => uri2.replace(redactUsernames ? /(\/\/)(.*)(@)/g : /(\/\/[^@]*:)(.*)(@)/g, `$1${R}$3`),
- (uri2) => uri2.replace(/(AWS_SESSION_TOKEN(:|%3A))([^,&]+)/gi, `$1${R}`),
- (uri2) => uri2.replace(/(tlsCertificateKeyFilePassword=)([^&]+)/gi, `$1${R}`),
- (uri2) => redactUsernames ? uri2.replace(/(proxyUsername=)([^&]+)/gi, `$1${R}`) : uri2,
- (uri2) => uri2.replace(/(proxyPassword=)([^&]+)/gi, `$1${R}`)
- ];
- for (const replacer of replacements) {
- uri = replacer(uri);
- }
- return uri;
- }
- exports2.redactConnectionString = redactConnectionString;
- }
- });
- // node_modules/mongodb-connection-string-url/lib/index.js
- var require_lib2 = __commonJS({
- "node_modules/mongodb-connection-string-url/lib/index.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.CommaAndColonSeparatedRecord = exports2.ConnectionString = exports2.redactConnectionString = void 0;
- var whatwg_url_1 = require_whatwg_url();
- var redact_1 = require_redact();
- Object.defineProperty(exports2, "redactConnectionString", { enumerable: true, get: function() {
- return redact_1.redactConnectionString;
- } });
- var DUMMY_HOSTNAME = "__this_is_a_placeholder__";
- function connectionStringHasValidScheme(connectionString) {
- return connectionString.startsWith("mongodb://") || connectionString.startsWith("mongodb+srv://");
- }
- var HOSTS_REGEX = /^(?<protocol>[^/]+):\/\/(?:(?<username>[^:@]*)(?::(?<password>[^@]*))?@)?(?<hosts>(?!:)[^/?@]*)(?<rest>.*)/;
- var CaseInsensitiveMap = class extends Map {
- delete(name) {
- return super.delete(this._normalizeKey(name));
- }
- get(name) {
- return super.get(this._normalizeKey(name));
- }
- has(name) {
- return super.has(this._normalizeKey(name));
- }
- set(name, value) {
- return super.set(this._normalizeKey(name), value);
- }
- _normalizeKey(name) {
- name = `${name}`;
- for (const key of this.keys()) {
- if (key.toLowerCase() === name.toLowerCase()) {
- name = key;
- break;
- }
- }
- return name;
- }
- };
- function caseInsenstiveURLSearchParams(Ctor) {
- return class CaseInsenstiveURLSearchParams extends Ctor {
- append(name, value) {
- return super.append(this._normalizeKey(name), value);
- }
- delete(name) {
- return super.delete(this._normalizeKey(name));
- }
- get(name) {
- return super.get(this._normalizeKey(name));
- }
- getAll(name) {
- return super.getAll(this._normalizeKey(name));
- }
- has(name) {
- return super.has(this._normalizeKey(name));
- }
- set(name, value) {
- return super.set(this._normalizeKey(name), value);
- }
- keys() {
- return super.keys();
- }
- values() {
- return super.values();
- }
- entries() {
- return super.entries();
- }
- [Symbol.iterator]() {
- return super[Symbol.iterator]();
- }
- _normalizeKey(name) {
- return CaseInsensitiveMap.prototype._normalizeKey.call(this, name);
- }
- };
- }
- var URLWithoutHost = class extends whatwg_url_1.URL {
- };
- var MongoParseError = class extends Error {
- get name() {
- return "MongoParseError";
- }
- };
- var ConnectionString = class _ConnectionString extends URLWithoutHost {
- constructor(uri, options = {}) {
- var _a;
- const { looseValidation } = options;
- if (!looseValidation && !connectionStringHasValidScheme(uri)) {
- throw new MongoParseError('Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"');
- }
- const match = uri.match(HOSTS_REGEX);
- if (!match) {
- throw new MongoParseError(`Invalid connection string "${uri}"`);
- }
- const { protocol, username, password, hosts, rest } = (_a = match.groups) !== null && _a !== void 0 ? _a : {};
- if (!looseValidation) {
- if (!protocol || !hosts) {
- throw new MongoParseError(`Protocol and host list are required in "${uri}"`);
- }
- try {
- decodeURIComponent(username !== null && username !== void 0 ? username : "");
- decodeURIComponent(password !== null && password !== void 0 ? password : "");
- } catch (err) {
- throw new MongoParseError(err.message);
- }
- const illegalCharacters = /[:/?#[\]@]/gi;
- if (username === null || username === void 0 ? void 0 : username.match(illegalCharacters)) {
- throw new MongoParseError(`Username contains unescaped characters ${username}`);
- }
- if (!username || !password) {
- const uriWithoutProtocol = uri.replace(`${protocol}://`, "");
- if (uriWithoutProtocol.startsWith("@") || uriWithoutProtocol.startsWith(":")) {
- throw new MongoParseError("URI contained empty userinfo section");
- }
- }
- if (password === null || password === void 0 ? void 0 : password.match(illegalCharacters)) {
- throw new MongoParseError("Password contains unescaped characters");
- }
- }
- let authString = "";
- if (typeof username === "string")
- authString += username;
- if (typeof password === "string")
- authString += `:${password}`;
- if (authString)
- authString += "@";
- try {
- super(`${protocol.toLowerCase()}://${authString}${DUMMY_HOSTNAME}${rest}`);
- } catch (err) {
- if (looseValidation) {
- new _ConnectionString(uri, {
- ...options,
- looseValidation: false
- });
- }
- if (typeof err.message === "string") {
- err.message = err.message.replace(DUMMY_HOSTNAME, hosts);
- }
- throw err;
- }
- this._hosts = hosts.split(",");
- if (!looseValidation) {
- if (this.isSRV && this.hosts.length !== 1) {
- throw new MongoParseError("mongodb+srv URI cannot have multiple service names");
- }
- if (this.isSRV && this.hosts.some((host) => host.includes(":"))) {
- throw new MongoParseError("mongodb+srv URI cannot have port number");
- }
- }
- if (!this.pathname) {
- this.pathname = "/";
- }
- Object.setPrototypeOf(this.searchParams, caseInsenstiveURLSearchParams(this.searchParams.constructor).prototype);
- }
- get host() {
- return DUMMY_HOSTNAME;
- }
- set host(_ignored) {
- throw new Error("No single host for connection string");
- }
- get hostname() {
- return DUMMY_HOSTNAME;
- }
- set hostname(_ignored) {
- throw new Error("No single host for connection string");
- }
- get port() {
- return "";
- }
- set port(_ignored) {
- throw new Error("No single host for connection string");
- }
- get href() {
- return this.toString();
- }
- set href(_ignored) {
- throw new Error("Cannot set href for connection strings");
- }
- get isSRV() {
- return this.protocol.includes("srv");
- }
- get hosts() {
- return this._hosts;
- }
- set hosts(list) {
- this._hosts = list;
- }
- toString() {
- return super.toString().replace(DUMMY_HOSTNAME, this.hosts.join(","));
- }
- clone() {
- return new _ConnectionString(this.toString(), {
- looseValidation: true
- });
- }
- redact(options) {
- return (0, redact_1.redactValidConnectionString)(this, options);
- }
- typedSearchParams() {
- const sametype = false;
- return this.searchParams;
- }
- [Symbol.for("nodejs.util.inspect.custom")]() {
- const { href, origin, protocol, username, password, hosts, pathname, search, searchParams, hash } = this;
- return { href, origin, protocol, username, password, hosts, pathname, search, searchParams, hash };
- }
- };
- exports2.ConnectionString = ConnectionString;
- var CommaAndColonSeparatedRecord = class extends CaseInsensitiveMap {
- constructor(from) {
- super();
- for (const entry of (from !== null && from !== void 0 ? from : "").split(",")) {
- if (!entry)
- continue;
- const colonIndex = entry.indexOf(":");
- if (colonIndex === -1) {
- this.set(entry, "");
- } else {
- this.set(entry.slice(0, colonIndex), entry.slice(colonIndex + 1));
- }
- }
- }
- toString() {
- return [...this].map((entry) => entry.join(":")).join(",");
- }
- };
- exports2.CommaAndColonSeparatedRecord = CommaAndColonSeparatedRecord;
- exports2.default = ConnectionString;
- }
- });
- // node_modules/mongodb/package.json
- var require_package = __commonJS({
- "node_modules/mongodb/package.json"(exports2, module2) {
- module2.exports = {
- name: "mongodb",
- version: "5.9.2",
- description: "The official MongoDB driver for Node.js",
- main: "lib/index.js",
- files: [
- "lib",
- "src",
- "etc/prepare.js",
- "mongodb.d.ts",
- "tsconfig.json"
- ],
- types: "mongodb.d.ts",
- repository: {
- type: "git",
- url: "git@github.com:mongodb/node-mongodb-native.git"
- },
- keywords: [
- "mongodb",
- "driver",
- "official"
- ],
- author: {
- name: "The MongoDB NodeJS Team",
- email: "dbx-node@mongodb.com"
- },
- dependencies: {
- bson: "^5.5.0",
- "mongodb-connection-string-url": "^2.6.0",
- socks: "^2.7.1"
- },
- optionalDependencies: {
- "@mongodb-js/saslprep": "^1.1.0"
- },
- peerDependencies: {
- "@aws-sdk/credential-providers": "^3.188.0",
- "@mongodb-js/zstd": "^1.0.0",
- kerberos: "^1.0.0 || ^2.0.0",
- "mongodb-client-encryption": ">=2.3.0 <3",
- snappy: "^7.2.2"
- },
- peerDependenciesMeta: {
- "@aws-sdk/credential-providers": {
- optional: true
- },
- "@mongodb-js/zstd": {
- optional: true
- },
- kerberos: {
- optional: true
- },
- snappy: {
- optional: true
- },
- "mongodb-client-encryption": {
- optional: true
- }
- },
- devDependencies: {
- "@iarna/toml": "^2.2.5",
- "@istanbuljs/nyc-config-typescript": "^1.0.2",
- "@microsoft/api-extractor": "^7.35.1",
- "@microsoft/tsdoc-config": "^0.16.2",
- "@mongodb-js/zstd": "^1.1.0",
- "@octokit/core": "^4.2.4",
- "@types/chai": "^4.3.5",
- "@types/chai-subset": "^1.3.3",
- "@types/express": "^4.17.17",
- "@types/kerberos": "^1.1.2",
- "@types/mocha": "^10.0.1",
- "@types/node": "^20.1.0",
- "@types/semver": "^7.5.0",
- "@types/sinon": "^10.0.14",
- "@types/sinon-chai": "^3.2.9",
- "@types/whatwg-url": "^11.0.0",
- "@typescript-eslint/eslint-plugin": "^5.59.5",
- "@typescript-eslint/parser": "^5.59.5",
- chai: "^4.3.7",
- "chai-subset": "^1.6.0",
- chalk: "^4.1.2",
- eslint: "^8.40.0",
- "eslint-config-prettier": "^8.8.0",
- "eslint-plugin-import": "^2.27.5",
- "eslint-plugin-prettier": "^4.2.1",
- "eslint-plugin-simple-import-sort": "^10.0.0",
- "eslint-plugin-tsdoc": "^0.2.17",
- express: "^4.18.2",
- "js-yaml": "^4.1.0",
- mocha: "^10.2.0",
- "mocha-sinon": "^2.1.2",
- "mongodb-legacy": "^5.0.0",
- nyc: "^15.1.0",
- prettier: "^2.8.8",
- semver: "^7.5.0",
- sinon: "^15.0.4",
- "sinon-chai": "^3.7.0",
- snappy: "^7.2.2",
- "source-map-support": "^0.5.21",
- "ts-node": "^10.9.1",
- tsd: "^0.28.1",
- typescript: "^5.0.4",
- "typescript-cached-transpile": "^0.0.6",
- "v8-heapsnapshot": "^1.2.0",
- yargs: "^17.7.2"
- },
- license: "Apache-2.0",
- engines: {
- node: ">=14.20.1"
- },
- bugs: {
- url: "https://jira.mongodb.org/projects/NODE/issues/"
- },
- homepage: "https://github.com/mongodb/node-mongodb-native",
- scripts: {
- "build:evergreen": "node .evergreen/generate_evergreen_tasks.js",
- "build:ts": "node ./node_modules/typescript/bin/tsc",
- "build:dts": "npm run build:ts && api-extractor run && node etc/clean_definition_files.cjs",
- "build:docs": "./etc/docs/build.ts",
- "build:typedoc": "typedoc",
- "build:nightly": "node ./.github/scripts/nightly.mjs",
- "check:bench": "node test/benchmarks/driverBench",
- "check:coverage": "nyc npm run test:all",
- "check:integration-coverage": "nyc npm run check:test",
- "check:lambda": "mocha --config test/mocha_lambda.json test/integration/node-specific/examples/handler.test.js",
- "check:lambda:aws": "mocha --config test/mocha_lambda.json test/integration/node-specific/examples/aws_handler.test.js",
- "check:lint": "npm run build:dts && npm run check:dts && npm run check:eslint && npm run check:tsd",
- "check:eslint": "eslint -v && eslint --max-warnings=0 --ext '.js,.ts' src test",
- "check:tsd": "tsd --version && tsd",
- "check:dependencies": "mocha test/action/dependency.test.ts",
- "check:dts": "node ./node_modules/typescript/bin/tsc --noEmit mongodb.d.ts && tsd",
- "check:search-indexes": "nyc mocha --config test/mocha_mongodb.json test/manual/search-index-management.spec.test.ts",
- "check:test": "mocha --config test/mocha_mongodb.json test/integration",
- "check:unit": "mocha test/unit",
- "check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit",
- "check:atlas": "mocha --config test/manual/mocharc.json test/manual/atlas_connectivity.test.js",
- "check:adl": "mocha --config test/mocha_mongodb.json test/manual/atlas-data-lake-testing",
- "check:aws": "nyc mocha --config test/mocha_mongodb.json test/integration/auth/mongodb_aws.test.ts",
- "check:oidc": "mocha --config test/mocha_mongodb.json test/manual/mongodb_oidc.prose.test.ts",
- "check:oidc-azure": "mocha --config test/mocha_mongodb.json test/integration/auth/mongodb_oidc_azure.prose.test.ts",
- "check:ocsp": "mocha --config test/manual/mocharc.json test/manual/ocsp_support.test.js",
- "check:kerberos": "nyc mocha --config test/manual/mocharc.json test/manual/kerberos.test.ts",
- "check:tls": "mocha --config test/manual/mocharc.json test/manual/tls_support.test.js",
- "check:ldap": "nyc mocha --config test/manual/mocharc.json test/manual/ldap.test.js",
- "check:socks5": "mocha --config test/manual/mocharc.json test/manual/socks5.test.ts",
- "check:csfle": "mocha --config test/mocha_mongodb.json test/integration/client-side-encryption",
- "check:snappy": "mocha test/unit/assorted/snappy.test.js",
- "fix:eslint": "npm run check:eslint -- --fix",
- prepare: "node etc/prepare.js",
- "preview:docs": "ts-node etc/docs/preview.ts",
- test: "npm run check:lint && npm run test:all",
- "test:all": "npm run check:unit && npm run check:test",
- "update:docs": "npm run build:docs -- --yes"
- },
- tsd: {
- directory: "test/types",
- compilerOptions: {
- strict: true,
- target: "esnext",
- module: "commonjs",
- moduleResolution: "node"
- }
- }
- };
- }
- });
- // node_modules/mongodb/lib/cmap/handshake/client_metadata.js
- var require_client_metadata = __commonJS({
- "node_modules/mongodb/lib/cmap/handshake/client_metadata.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.getFAASEnv = exports2.makeClientMetadata = exports2.LimitedSizeDocument = void 0;
- var os = require("os");
- var process2 = require("process");
- var bson_1 = require_bson2();
- var error_1 = require_error();
- var NODE_DRIVER_VERSION = require_package().version;
- var LimitedSizeDocument = class {
- constructor(maxSize) {
- this.maxSize = maxSize;
- this.document = /* @__PURE__ */ new Map();
- this.documentSize = 5;
- }
- /** Only adds key/value if the bsonByteLength is less than MAX_SIZE */
- ifItFitsItSits(key, value) {
- const newElementSize = bson_1.BSON.serialize((/* @__PURE__ */ new Map()).set(key, value)).byteLength - 5;
- if (newElementSize + this.documentSize > this.maxSize) {
- return false;
- }
- this.documentSize += newElementSize;
- this.document.set(key, value);
- return true;
- }
- toObject() {
- return bson_1.BSON.deserialize(bson_1.BSON.serialize(this.document), {
- promoteLongs: false,
- promoteBuffers: false,
- promoteValues: false,
- useBigInt64: false
- });
- }
- };
- exports2.LimitedSizeDocument = LimitedSizeDocument;
- function makeClientMetadata(options) {
- const metadataDocument = new LimitedSizeDocument(512);
- const { appName = "" } = options;
- if (appName.length > 0) {
- const name2 = Buffer.byteLength(appName, "utf8") <= 128 ? options.appName : Buffer.from(appName, "utf8").subarray(0, 128).toString("utf8");
- metadataDocument.ifItFitsItSits("application", { name: name2 });
- }
- const { name = "", version = "", platform = "" } = options.driverInfo;
- const driverInfo = {
- name: name.length > 0 ? `nodejs|${name}` : "nodejs",
- version: version.length > 0 ? `${NODE_DRIVER_VERSION}|${version}` : NODE_DRIVER_VERSION
- };
- if (!metadataDocument.ifItFitsItSits("driver", driverInfo)) {
- throw new error_1.MongoInvalidArgumentError("Unable to include driverInfo name and version, metadata cannot exceed 512 bytes");
- }
- let runtimeInfo = getRuntimeInfo();
- if (platform.length > 0) {
- runtimeInfo = `${runtimeInfo}|${platform}`;
- }
- if (!metadataDocument.ifItFitsItSits("platform", runtimeInfo)) {
- throw new error_1.MongoInvalidArgumentError("Unable to include driverInfo platform, metadata cannot exceed 512 bytes");
- }
- const osInfo = (/* @__PURE__ */ new Map()).set("name", process2.platform).set("architecture", process2.arch).set("version", os.release()).set("type", os.type());
- if (!metadataDocument.ifItFitsItSits("os", osInfo)) {
- for (const key of osInfo.keys()) {
- osInfo.delete(key);
- if (osInfo.size === 0)
- break;
- if (metadataDocument.ifItFitsItSits("os", osInfo))
- break;
- }
- }
- const faasEnv = getFAASEnv();
- if (faasEnv != null) {
- if (!metadataDocument.ifItFitsItSits("env", faasEnv)) {
- for (const key of faasEnv.keys()) {
- faasEnv.delete(key);
- if (faasEnv.size === 0)
- break;
- if (metadataDocument.ifItFitsItSits("env", faasEnv))
- break;
- }
- }
- }
- return metadataDocument.toObject();
- }
- exports2.makeClientMetadata = makeClientMetadata;
- function getFAASEnv() {
- const { AWS_EXECUTION_ENV = "", AWS_LAMBDA_RUNTIME_API = "", FUNCTIONS_WORKER_RUNTIME = "", K_SERVICE = "", FUNCTION_NAME = "", VERCEL = "", AWS_LAMBDA_FUNCTION_MEMORY_SIZE = "", AWS_REGION = "", FUNCTION_MEMORY_MB = "", FUNCTION_REGION = "", FUNCTION_TIMEOUT_SEC = "", VERCEL_REGION = "" } = process2.env;
- const isAWSFaaS = AWS_EXECUTION_ENV.startsWith("AWS_Lambda_") || AWS_LAMBDA_RUNTIME_API.length > 0;
- const isAzureFaaS = FUNCTIONS_WORKER_RUNTIME.length > 0;
- const isGCPFaaS = K_SERVICE.length > 0 || FUNCTION_NAME.length > 0;
- const isVercelFaaS = VERCEL.length > 0;
- const faasEnv = /* @__PURE__ */ new Map();
- if (isVercelFaaS && !(isAzureFaaS || isGCPFaaS)) {
- if (VERCEL_REGION.length > 0) {
- faasEnv.set("region", VERCEL_REGION);
- }
- faasEnv.set("name", "vercel");
- return faasEnv;
- }
- if (isAWSFaaS && !(isAzureFaaS || isGCPFaaS || isVercelFaaS)) {
- if (AWS_REGION.length > 0) {
- faasEnv.set("region", AWS_REGION);
- }
- if (AWS_LAMBDA_FUNCTION_MEMORY_SIZE.length > 0 && Number.isInteger(+AWS_LAMBDA_FUNCTION_MEMORY_SIZE)) {
- faasEnv.set("memory_mb", new bson_1.Int32(AWS_LAMBDA_FUNCTION_MEMORY_SIZE));
- }
- faasEnv.set("name", "aws.lambda");
- return faasEnv;
- }
- if (isAzureFaaS && !(isGCPFaaS || isAWSFaaS || isVercelFaaS)) {
- faasEnv.set("name", "azure.func");
- return faasEnv;
- }
- if (isGCPFaaS && !(isAzureFaaS || isAWSFaaS || isVercelFaaS)) {
- if (FUNCTION_REGION.length > 0) {
- faasEnv.set("region", FUNCTION_REGION);
- }
- if (FUNCTION_MEMORY_MB.length > 0 && Number.isInteger(+FUNCTION_MEMORY_MB)) {
- faasEnv.set("memory_mb", new bson_1.Int32(FUNCTION_MEMORY_MB));
- }
- if (FUNCTION_TIMEOUT_SEC.length > 0 && Number.isInteger(+FUNCTION_TIMEOUT_SEC)) {
- faasEnv.set("timeout_sec", new bson_1.Int32(FUNCTION_TIMEOUT_SEC));
- }
- faasEnv.set("name", "gcp.func");
- return faasEnv;
- }
- return null;
- }
- exports2.getFAASEnv = getFAASEnv;
- function getRuntimeInfo() {
- var _a, _b;
- if ("Deno" in globalThis) {
- const version = typeof ((_a = Deno == null ? void 0 : Deno.version) == null ? void 0 : _a.deno) === "string" ? (_b = Deno == null ? void 0 : Deno.version) == null ? void 0 : _b.deno : "0.0.0-unknown";
- return `Deno v${version}, ${os.endianness()}`;
- }
- if ("Bun" in globalThis) {
- const version = typeof (Bun == null ? void 0 : Bun.version) === "string" ? Bun == null ? void 0 : Bun.version : "0.0.0-unknown";
- return `Bun v${version}, ${os.endianness()}`;
- }
- return `Node.js ${process2.version}, ${os.endianness()}`;
- }
- }
- });
- // node_modules/mongodb/lib/cmap/wire_protocol/compression.js
- var require_compression = __commonJS({
- "node_modules/mongodb/lib/cmap/wire_protocol/compression.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.decompress = exports2.compress = exports2.uncompressibleCommands = exports2.Compressor = void 0;
- var util_1 = require("util");
- var zlib = require("zlib");
- var constants_1 = require_constants2();
- var deps_1 = require_deps();
- var error_1 = require_error();
- exports2.Compressor = Object.freeze({
- none: 0,
- snappy: 1,
- zlib: 2,
- zstd: 3
- });
- exports2.uncompressibleCommands = /* @__PURE__ */ new Set([
- constants_1.LEGACY_HELLO_COMMAND,
- "saslStart",
- "saslContinue",
- "getnonce",
- "authenticate",
- "createUser",
- "updateUser",
- "copydbSaslStart",
- "copydbgetnonce",
- "copydb"
- ]);
- var ZSTD_COMPRESSION_LEVEL = 3;
- var zlibInflate = (0, util_1.promisify)(zlib.inflate.bind(zlib));
- var zlibDeflate = (0, util_1.promisify)(zlib.deflate.bind(zlib));
- var zstd;
- var Snappy = null;
- function loadSnappy() {
- if (Snappy == null) {
- const snappyImport = (0, deps_1.getSnappy)();
- if ("kModuleError" in snappyImport) {
- throw snappyImport.kModuleError;
- }
- Snappy = snappyImport;
- }
- return Snappy;
- }
- async function compress(options, dataToBeCompressed) {
- const zlibOptions = {};
- switch (options.agreedCompressor) {
- case "snappy": {
- Snappy ?? (Snappy = loadSnappy());
- return Snappy.compress(dataToBeCompressed);
- }
- case "zstd": {
- loadZstd();
- if ("kModuleError" in zstd) {
- throw zstd["kModuleError"];
- }
- return zstd.compress(dataToBeCompressed, ZSTD_COMPRESSION_LEVEL);
- }
- case "zlib": {
- if (options.zlibCompressionLevel) {
- zlibOptions.level = options.zlibCompressionLevel;
- }
- return zlibDeflate(dataToBeCompressed, zlibOptions);
- }
- default: {
- throw new error_1.MongoInvalidArgumentError(`Unknown compressor ${options.agreedCompressor} failed to compress`);
- }
- }
- }
- exports2.compress = compress;
- async function decompress(compressorID, compressedData) {
- if (compressorID !== exports2.Compressor.snappy && compressorID !== exports2.Compressor.zstd && compressorID !== exports2.Compressor.zlib && compressorID !== exports2.Compressor.none) {
- throw new error_1.MongoDecompressionError(`Server sent message compressed using an unsupported compressor. (Received compressor ID ${compressorID})`);
- }
- switch (compressorID) {
- case exports2.Compressor.snappy: {
- Snappy ?? (Snappy = loadSnappy());
- return Snappy.uncompress(compressedData, { asBuffer: true });
- }
- case exports2.Compressor.zstd: {
- loadZstd();
- if ("kModuleError" in zstd) {
- throw zstd["kModuleError"];
- }
- return zstd.decompress(compressedData);
- }
- case exports2.Compressor.zlib: {
- return zlibInflate(compressedData);
- }
- default: {
- return compressedData;
- }
- }
- }
- exports2.decompress = decompress;
- function loadZstd() {
- if (!zstd) {
- zstd = (0, deps_1.getZstdLibrary)();
- }
- }
- }
- });
- // node_modules/mongodb/lib/encrypter.js
- var require_encrypter = __commonJS({
- "node_modules/mongodb/lib/encrypter.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.Encrypter = void 0;
- var constants_1 = require_constants2();
- var error_1 = require_error();
- var mongo_client_1 = require_mongo_client();
- var utils_1 = require_utils();
- var AutoEncrypterClass;
- var kInternalClient = Symbol("internalClient");
- var Encrypter = class {
- constructor(client, uri, options) {
- if (typeof options.autoEncryption !== "object") {
- throw new error_1.MongoInvalidArgumentError('Option "autoEncryption" must be specified');
- }
- this[kInternalClient] = null;
- this.bypassAutoEncryption = !!options.autoEncryption.bypassAutoEncryption;
- this.needsConnecting = false;
- if (options.maxPoolSize === 0 && options.autoEncryption.keyVaultClient == null) {
- options.autoEncryption.keyVaultClient = client;
- } else if (options.autoEncryption.keyVaultClient == null) {
- options.autoEncryption.keyVaultClient = this.getInternalClient(client, uri, options);
- }
- if (this.bypassAutoEncryption) {
- options.autoEncryption.metadataClient = void 0;
- } else if (options.maxPoolSize === 0) {
- options.autoEncryption.metadataClient = client;
- } else {
- options.autoEncryption.metadataClient = this.getInternalClient(client, uri, options);
- }
- if (options.proxyHost) {
- options.autoEncryption.proxyOptions = {
- proxyHost: options.proxyHost,
- proxyPort: options.proxyPort,
- proxyUsername: options.proxyUsername,
- proxyPassword: options.proxyPassword
- };
- }
- this.autoEncrypter = new AutoEncrypterClass(client, options.autoEncryption);
- }
- getInternalClient(client, uri, options) {
- let internalClient = this[kInternalClient];
- if (internalClient == null) {
- const clonedOptions = {};
- for (const key of [
- ...Object.getOwnPropertyNames(options),
- ...Object.getOwnPropertySymbols(options)
- ]) {
- if (["autoEncryption", "minPoolSize", "servers", "caseTranslate", "dbName"].includes(key))
- continue;
- Reflect.set(clonedOptions, key, Reflect.get(options, key));
- }
- clonedOptions.minPoolSize = 0;
- internalClient = new mongo_client_1.MongoClient(uri, clonedOptions);
- this[kInternalClient] = internalClient;
- for (const eventName of constants_1.MONGO_CLIENT_EVENTS) {
- for (const listener of client.listeners(eventName)) {
- internalClient.on(eventName, listener);
- }
- }
- client.on("newListener", (eventName, listener) => {
- internalClient == null ? void 0 : internalClient.on(eventName, listener);
- });
- this.needsConnecting = true;
- }
- return internalClient;
- }
- async connectInternalClient() {
- const internalClient = this[kInternalClient];
- if (this.needsConnecting && internalClient != null) {
- this.needsConnecting = false;
- await internalClient.connect();
- }
- }
- close(client, force, callback) {
- this.autoEncrypter.teardown(!!force, (e) => {
- const internalClient = this[kInternalClient];
- if (internalClient != null && client !== internalClient) {
- internalClient.close(force).then(() => callback(), (error) => callback(error));
- return;
- }
- callback(e);
- });
- }
- static checkForMongoCrypt() {
- const mongodbClientEncryption = (0, utils_1.getMongoDBClientEncryption)();
- if (mongodbClientEncryption == null) {
- throw new error_1.MongoMissingDependencyError("Auto-encryption requested, but the module is not installed. Please add `mongodb-client-encryption` as a dependency of your project");
- }
- AutoEncrypterClass = mongodbClientEncryption.extension(require_lib3()).AutoEncrypter;
- }
- };
- exports2.Encrypter = Encrypter;
- }
- });
- // node_modules/mongodb/lib/mongo_logger.js
- var require_mongo_logger = __commonJS({
- "node_modules/mongodb/lib/mongo_logger.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.MongoLogger = exports2.stringifyWithMaxLen = exports2.createStdioLogger = exports2.MongoLoggableComponent = exports2.SEVERITY_LEVEL_MAP = exports2.DEFAULT_MAX_DOCUMENT_LENGTH = exports2.SeverityLevel = void 0;
- var bson_1 = require_bson();
- var util_1 = require("util");
- var constants_1 = require_constants2();
- var utils_1 = require_utils();
- exports2.SeverityLevel = Object.freeze({
- EMERGENCY: "emergency",
- ALERT: "alert",
- CRITICAL: "critical",
- ERROR: "error",
- WARNING: "warn",
- NOTICE: "notice",
- INFORMATIONAL: "info",
- DEBUG: "debug",
- TRACE: "trace",
- OFF: "off"
- });
- exports2.DEFAULT_MAX_DOCUMENT_LENGTH = 1e3;
- var SeverityLevelMap = class extends Map {
- constructor(entries) {
- const newEntries = [];
- for (const [level, value] of entries) {
- newEntries.push([value, level]);
- }
- newEntries.push(...entries);
- super(newEntries);
- }
- getNumericSeverityLevel(severity) {
- return this.get(severity);
- }
- getSeverityLevelName(level) {
- return this.get(level);
- }
- };
- exports2.SEVERITY_LEVEL_MAP = new SeverityLevelMap([
- [exports2.SeverityLevel.OFF, -Infinity],
- [exports2.SeverityLevel.EMERGENCY, 0],
- [exports2.SeverityLevel.ALERT, 1],
- [exports2.SeverityLevel.CRITICAL, 2],
- [exports2.SeverityLevel.ERROR, 3],
- [exports2.SeverityLevel.WARNING, 4],
- [exports2.SeverityLevel.NOTICE, 5],
- [exports2.SeverityLevel.INFORMATIONAL, 6],
- [exports2.SeverityLevel.DEBUG, 7],
- [exports2.SeverityLevel.TRACE, 8]
- ]);
- exports2.MongoLoggableComponent = Object.freeze({
- COMMAND: "command",
- TOPOLOGY: "topology",
- SERVER_SELECTION: "serverSelection",
- CONNECTION: "connection"
- });
- function parseSeverityFromString(s) {
- const validSeverities = Object.values(exports2.SeverityLevel);
- const lowerSeverity = s == null ? void 0 : s.toLowerCase();
- if (lowerSeverity != null && validSeverities.includes(lowerSeverity)) {
- return lowerSeverity;
- }
- return null;
- }
- function createStdioLogger(stream) {
- return {
- write: (log) => {
- stream.write((0, util_1.inspect)(log, { compact: true, breakLength: Infinity }), "utf-8");
- return;
- }
- };
- }
- exports2.createStdioLogger = createStdioLogger;
- function resolveLogPath({ MONGODB_LOG_PATH }, { mongodbLogPath }) {
- if (typeof mongodbLogPath === "string" && /^stderr$/i.test(mongodbLogPath)) {
- return createStdioLogger(process.stderr);
- }
- if (typeof mongodbLogPath === "string" && /^stdout$/i.test(mongodbLogPath)) {
- return createStdioLogger(process.stdout);
- }
- if (typeof mongodbLogPath === "object" && typeof (mongodbLogPath == null ? void 0 : mongodbLogPath.write) === "function") {
- return mongodbLogPath;
- }
- if (MONGODB_LOG_PATH && /^stderr$/i.test(MONGODB_LOG_PATH)) {
- return createStdioLogger(process.stderr);
- }
- if (MONGODB_LOG_PATH && /^stdout$/i.test(MONGODB_LOG_PATH)) {
- return createStdioLogger(process.stdout);
- }
- return createStdioLogger(process.stderr);
- }
- function compareSeverity(s0, s1) {
- const s0Num = exports2.SEVERITY_LEVEL_MAP.getNumericSeverityLevel(s0);
- const s1Num = exports2.SEVERITY_LEVEL_MAP.getNumericSeverityLevel(s1);
- return s0Num < s1Num ? -1 : s0Num > s1Num ? 1 : 0;
- }
- function stringifyWithMaxLen(value, maxDocumentLength) {
- const ejson = bson_1.EJSON.stringify(value);
- return maxDocumentLength !== 0 && ejson.length > maxDocumentLength ? `${ejson.slice(0, maxDocumentLength)}...` : ejson;
- }
- exports2.stringifyWithMaxLen = stringifyWithMaxLen;
- function isLogConvertible(obj) {
- const objAsLogConvertible = obj;
- return objAsLogConvertible.toLog !== void 0 && typeof objAsLogConvertible.toLog === "function";
- }
- function attachCommandFields(log, commandEvent) {
- log.commandName = commandEvent.commandName;
- log.requestId = commandEvent.requestId;
- log.driverConnectionId = commandEvent == null ? void 0 : commandEvent.connectionId;
- const { host, port } = utils_1.HostAddress.fromString(commandEvent.address).toHostPort();
- log.serverHost = host;
- log.serverPort = port;
- if (commandEvent == null ? void 0 : commandEvent.serviceId) {
- log.serviceId = commandEvent.serviceId.toHexString();
- }
- return log;
- }
- function attachConnectionFields(log, connectionPoolEvent) {
- const { host, port } = utils_1.HostAddress.fromString(connectionPoolEvent.address).toHostPort();
- log.serverHost = host;
- log.serverPort = port;
- return log;
- }
- function defaultLogTransform(logObject, maxDocumentLength = exports2.DEFAULT_MAX_DOCUMENT_LENGTH) {
- var _a;
- let log = /* @__PURE__ */ Object.create(null);
- switch (logObject.name) {
- case constants_1.COMMAND_STARTED:
- log = attachCommandFields(log, logObject);
- log.message = "Command started";
- log.command = stringifyWithMaxLen(logObject.command, maxDocumentLength);
- log.databaseName = logObject.databaseName;
- return log;
- case constants_1.COMMAND_SUCCEEDED:
- log = attachCommandFields(log, logObject);
- log.message = "Command succeeded";
- log.durationMS = logObject.duration;
- log.reply = stringifyWithMaxLen(logObject.reply, maxDocumentLength);
- return log;
- case constants_1.COMMAND_FAILED:
- log = attachCommandFields(log, logObject);
- log.message = "Command failed";
- log.durationMS = logObject.duration;
- log.failure = logObject.failure;
- return log;
- case constants_1.CONNECTION_POOL_CREATED:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection pool created";
- if (logObject.options) {
- const { maxIdleTimeMS, minPoolSize, maxPoolSize, maxConnecting, waitQueueTimeoutMS } = logObject.options;
- log = {
- ...log,
- maxIdleTimeMS,
- minPoolSize,
- maxPoolSize,
- maxConnecting,
- waitQueueTimeoutMS
- };
- }
- return log;
- case constants_1.CONNECTION_POOL_READY:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection pool ready";
- return log;
- case constants_1.CONNECTION_POOL_CLEARED:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection pool cleared";
- if (((_a = logObject.serviceId) == null ? void 0 : _a._bsontype) === "ObjectId") {
- log.serviceId = logObject.serviceId.toHexString();
- }
- return log;
- case constants_1.CONNECTION_POOL_CLOSED:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection pool closed";
- return log;
- case constants_1.CONNECTION_CREATED:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection created";
- log.driverConnectionId = logObject.connectionId;
- return log;
- case constants_1.CONNECTION_READY:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection ready";
- log.driverConnectionId = logObject.connectionId;
- return log;
- case constants_1.CONNECTION_CLOSED:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection closed";
- log.driverConnectionId = logObject.connectionId;
- switch (logObject.reason) {
- case "stale":
- log.reason = "Connection became stale because the pool was cleared";
- break;
- case "idle":
- log.reason = "Connection has been available but unused for longer than the configured max idle time";
- break;
- case "error":
- log.reason = "An error occurred while using the connection";
- if (logObject.error) {
- log.error = logObject.error;
- }
- break;
- case "poolClosed":
- log.reason = "Connection pool was closed";
- break;
- default:
- log.reason = `Unknown close reason: ${logObject.reason}`;
- }
- return log;
- case constants_1.CONNECTION_CHECK_OUT_STARTED:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection checkout started";
- return log;
- case constants_1.CONNECTION_CHECK_OUT_FAILED:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection checkout failed";
- switch (logObject.reason) {
- case "poolClosed":
- log.reason = "Connection pool was closed";
- break;
- case "timeout":
- log.reason = "Wait queue timeout elapsed without a connection becoming available";
- break;
- case "connectionError":
- log.reason = "An error occurred while trying to establish a new connection";
- if (logObject.error) {
- log.error = logObject.error;
- }
- break;
- default:
- log.reason = `Unknown close reason: ${logObject.reason}`;
- }
- return log;
- case constants_1.CONNECTION_CHECKED_OUT:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection checked out";
- log.driverConnectionId = logObject.connectionId;
- return log;
- case constants_1.CONNECTION_CHECKED_IN:
- log = attachConnectionFields(log, logObject);
- log.message = "Connection checked in";
- log.driverConnectionId = logObject.connectionId;
- return log;
- default:
- for (const [key, value] of Object.entries(logObject)) {
- if (value != null)
- log[key] = value;
- }
- }
- return log;
- }
- var MongoLogger = class {
- constructor(options) {
- this.error = this.log.bind(this, "error");
- this.warn = this.log.bind(this, "warn");
- this.info = this.log.bind(this, "info");
- this.debug = this.log.bind(this, "debug");
- this.trace = this.log.bind(this, "trace");
- this.componentSeverities = options.componentSeverities;
- this.maxDocumentLength = options.maxDocumentLength;
- this.logDestination = options.logDestination;
- }
- log(severity, component, message) {
- if (compareSeverity(severity, this.componentSeverities[component]) > 0)
- return;
- let logMessage = { t: /* @__PURE__ */ new Date(), c: component, s: severity };
- if (typeof message === "string") {
- logMessage.message = message;
- } else if (typeof message === "object") {
- if (isLogConvertible(message)) {
- logMessage = { ...logMessage, ...message.toLog() };
- } else {
- logMessage = { ...logMessage, ...defaultLogTransform(message, this.maxDocumentLength) };
- }
- }
- this.logDestination.write(logMessage);
- }
- /**
- * Merges options set through environment variables and the MongoClient, preferring environment
- * variables when both are set, and substituting defaults for values not set. Options set in
- * constructor take precedence over both environment variables and MongoClient options.
- *
- * @remarks
- * When parsing component severity levels, invalid values are treated as unset and replaced with
- * the default severity.
- *
- * @param envOptions - options set for the logger from the environment
- * @param clientOptions - options set for the logger in the MongoClient options
- * @returns a MongoLoggerOptions object to be used when instantiating a new MongoLogger
- */
- static resolveOptions(envOptions, clientOptions) {
- const combinedOptions = {
- ...envOptions,
- ...clientOptions,
- mongodbLogPath: resolveLogPath(envOptions, clientOptions)
- };
- const defaultSeverity = parseSeverityFromString(combinedOptions.MONGODB_LOG_ALL) ?? exports2.SeverityLevel.OFF;
- return {
- componentSeverities: {
- command: parseSeverityFromString(combinedOptions.MONGODB_LOG_COMMAND) ?? defaultSeverity,
- topology: parseSeverityFromString(combinedOptions.MONGODB_LOG_TOPOLOGY) ?? defaultSeverity,
- serverSelection: parseSeverityFromString(combinedOptions.MONGODB_LOG_SERVER_SELECTION) ?? defaultSeverity,
- connection: parseSeverityFromString(combinedOptions.MONGODB_LOG_CONNECTION) ?? defaultSeverity,
- default: defaultSeverity
- },
- maxDocumentLength: (0, utils_1.parseUnsignedInteger)(combinedOptions.MONGODB_LOG_MAX_DOCUMENT_LENGTH) ?? 1e3,
- logDestination: combinedOptions.mongodbLogPath
- };
- }
- };
- exports2.MongoLogger = MongoLogger;
- }
- });
- // node_modules/mongodb/lib/connection_string.js
- var require_connection_string = __commonJS({
- "node_modules/mongodb/lib/connection_string.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.FEATURE_FLAGS = exports2.DEFAULT_OPTIONS = exports2.OPTIONS = exports2.parseOptions = exports2.resolveSRVRecord = void 0;
- var dns = require("dns");
- var fs = require("fs");
- var mongodb_connection_string_url_1 = require_lib2();
- var url_1 = require("url");
- var mongo_credentials_1 = require_mongo_credentials();
- var providers_1 = require_providers();
- var client_metadata_1 = require_client_metadata();
- var compression_1 = require_compression();
- var encrypter_1 = require_encrypter();
- var error_1 = require_error();
- var mongo_client_1 = require_mongo_client();
- var mongo_logger_1 = require_mongo_logger();
- var read_concern_1 = require_read_concern();
- var read_preference_1 = require_read_preference();
- var utils_1 = require_utils();
- var write_concern_1 = require_write_concern();
- var VALID_TXT_RECORDS = ["authSource", "replicaSet", "loadBalanced"];
- var LB_SINGLE_HOST_ERROR = "loadBalanced option only supported with a single host in the URI";
- var LB_REPLICA_SET_ERROR = "loadBalanced option not supported with a replicaSet option";
- var LB_DIRECT_CONNECTION_ERROR = "loadBalanced option not supported when directConnection is provided";
- async function resolveSRVRecord(options) {
- if (typeof options.srvHost !== "string") {
- throw new error_1.MongoAPIError('Option "srvHost" must not be empty');
- }
- if (options.srvHost.split(".").length < 3) {
- throw new error_1.MongoAPIError("URI must include hostname, domain name, and tld");
- }
- const lookupAddress = options.srvHost;
- const addresses = await dns.promises.resolveSrv(`_${options.srvServiceName}._tcp.${lookupAddress}`);
- if (addresses.length === 0) {
- throw new error_1.MongoAPIError("No addresses found at host");
- }
- for (const { name } of addresses) {
- if (!(0, utils_1.matchesParentDomain)(name, lookupAddress)) {
- throw new error_1.MongoAPIError("Server record does not share hostname with parent URI");
- }
- }
- const hostAddresses = addresses.map((r) => utils_1.HostAddress.fromString(`${r.name}:${r.port ?? 27017}`));
- validateLoadBalancedOptions(hostAddresses, options, true);
- let record;
- try {
- record = await dns.promises.resolveTxt(lookupAddress);
- } catch (error) {
- if (error.code !== "ENODATA" && error.code !== "ENOTFOUND") {
- throw error;
- }
- return hostAddresses;
- }
- if (record.length > 1) {
- throw new error_1.MongoParseError("Multiple text records not allowed");
- }
- const txtRecordOptions = new url_1.URLSearchParams(record[0].join(""));
- const txtRecordOptionKeys = [...txtRecordOptions.keys()];
- if (txtRecordOptionKeys.some((key) => !VALID_TXT_RECORDS.includes(key))) {
- throw new error_1.MongoParseError(`Text record may only set any of: ${VALID_TXT_RECORDS.join(", ")}`);
- }
- if (VALID_TXT_RECORDS.some((option) => txtRecordOptions.get(option) === "")) {
- throw new error_1.MongoParseError("Cannot have empty URI params in DNS TXT Record");
- }
- const source = txtRecordOptions.get("authSource") ?? void 0;
- const replicaSet = txtRecordOptions.get("replicaSet") ?? void 0;
- const loadBalanced = txtRecordOptions.get("loadBalanced") ?? void 0;
- if (!options.userSpecifiedAuthSource && source && options.credentials && !providers_1.AUTH_MECHS_AUTH_SRC_EXTERNAL.has(options.credentials.mechanism)) {
- options.credentials = mongo_credentials_1.MongoCredentials.merge(options.credentials, { source });
- }
- if (!options.userSpecifiedReplicaSet && replicaSet) {
- options.replicaSet = replicaSet;
- }
- if (loadBalanced === "true") {
- options.loadBalanced = true;
- }
- if (options.replicaSet && options.srvMaxHosts > 0) {
- throw new error_1.MongoParseError("Cannot combine replicaSet option with srvMaxHosts");
- }
- validateLoadBalancedOptions(hostAddresses, options, true);
- return hostAddresses;
- }
- exports2.resolveSRVRecord = resolveSRVRecord;
- function checkTLSOptions(allOptions) {
- if (!allOptions)
- return;
- const check = (a, b) => {
- if (allOptions.has(a) && allOptions.has(b)) {
- throw new error_1.MongoAPIError(`The '${a}' option cannot be used with the '${b}' option`);
- }
- };
- check("tlsInsecure", "tlsAllowInvalidCertificates");
- check("tlsInsecure", "tlsAllowInvalidHostnames");
- check("tlsInsecure", "tlsDisableCertificateRevocationCheck");
- check("tlsInsecure", "tlsDisableOCSPEndpointCheck");
- check("tlsAllowInvalidCertificates", "tlsDisableCertificateRevocationCheck");
- check("tlsAllowInvalidCertificates", "tlsDisableOCSPEndpointCheck");
- check("tlsDisableCertificateRevocationCheck", "tlsDisableOCSPEndpointCheck");
- }
- var TRUTHS = /* @__PURE__ */ new Set(["true", "t", "1", "y", "yes"]);
- var FALSEHOODS = /* @__PURE__ */ new Set(["false", "f", "0", "n", "no", "-1"]);
- function getBoolean(name, value) {
- if (typeof value === "boolean")
- return value;
- const valueString = String(value).toLowerCase();
- if (TRUTHS.has(valueString)) {
- if (valueString !== "true") {
- (0, utils_1.emitWarningOnce)(`deprecated value for ${name} : ${valueString} - please update to ${name} : true instead`);
- }
- return true;
- }
- if (FALSEHOODS.has(valueString)) {
- if (valueString !== "false") {
- (0, utils_1.emitWarningOnce)(`deprecated value for ${name} : ${valueString} - please update to ${name} : false instead`);
- }
- return false;
- }
- throw new error_1.MongoParseError(`Expected ${name} to be stringified boolean value, got: ${value}`);
- }
- function getIntFromOptions(name, value) {
- const parsedInt = (0, utils_1.parseInteger)(value);
- if (parsedInt != null) {
- return parsedInt;
- }
- throw new error_1.MongoParseError(`Expected ${name} to be stringified int value, got: ${value}`);
- }
- function getUIntFromOptions(name, value) {
- const parsedValue = getIntFromOptions(name, value);
- if (parsedValue < 0) {
- throw new error_1.MongoParseError(`${name} can only be a positive int value, got: ${value}`);
- }
- return parsedValue;
- }
- function* entriesFromString(value) {
- const keyValuePairs = value.split(",");
- for (const keyValue of keyValuePairs) {
- const [key, value2] = keyValue.split(/:(.*)/);
- if (value2 == null) {
- throw new error_1.MongoParseError("Cannot have undefined values in key value pairs");
- }
- yield [key, value2];
- }
- }
- var CaseInsensitiveMap = class extends Map {
- constructor(entries = []) {
- super(entries.map(([k, v]) => [k.toLowerCase(), v]));
- }
- has(k) {
- return super.has(k.toLowerCase());
- }
- get(k) {
- return super.get(k.toLowerCase());
- }
- set(k, v) {
- return super.set(k.toLowerCase(), v);
- }
- delete(k) {
- return super.delete(k.toLowerCase());
- }
- };
- function parseOptions(uri, mongoClient = void 0, options = {}) {
- if (mongoClient != null && !(mongoClient instanceof mongo_client_1.MongoClient)) {
- options = mongoClient;
- mongoClient = void 0;
- }
- if (options.useBigInt64 && typeof options.promoteLongs === "boolean" && !options.promoteLongs) {
- throw new error_1.MongoAPIError("Must request either bigint or Long for int64 deserialization");
- }
- if (options.useBigInt64 && typeof options.promoteValues === "boolean" && !options.promoteValues) {
- throw new error_1.MongoAPIError("Must request either bigint or Long for int64 deserialization");
- }
- const url = new mongodb_connection_string_url_1.default(uri);
- const { hosts, isSRV } = url;
- const mongoOptions = /* @__PURE__ */ Object.create(null);
- for (const flag of Object.getOwnPropertySymbols(options)) {
- if (exports2.FEATURE_FLAGS.has(flag)) {
- mongoOptions[flag] = options[flag];
- }
- }
- mongoOptions.hosts = isSRV ? [] : hosts.map(utils_1.HostAddress.fromString);
- const urlOptions = new CaseInsensitiveMap();
- if (url.pathname !== "/" && url.pathname !== "") {
- const dbName = decodeURIComponent(url.pathname[0] === "/" ? url.pathname.slice(1) : url.pathname);
- if (dbName) {
- urlOptions.set("dbName", [dbName]);
- }
- }
- if (url.username !== "") {
- const auth = {
- username: decodeURIComponent(url.username)
- };
- if (typeof url.password === "string") {
- auth.password = decodeURIComponent(url.password);
- }
- urlOptions.set("auth", [auth]);
- }
- for (const key of url.searchParams.keys()) {
- const values = [...url.searchParams.getAll(key)];
- if (values.includes("")) {
- throw new error_1.MongoAPIError("URI cannot contain options with no value");
- }
- if (!urlOptions.has(key)) {
- urlOptions.set(key, values);
- }
- }
- const objectOptions = new CaseInsensitiveMap(Object.entries(options).filter(([, v]) => v != null));
- if (urlOptions.has("serverApi")) {
- throw new error_1.MongoParseError("URI cannot contain `serverApi`, it can only be passed to the client");
- }
- const uriMechanismProperties = urlOptions.get("authMechanismProperties");
- if (uriMechanismProperties) {
- for (const property of uriMechanismProperties) {
- if (/(^|,)ALLOWED_HOSTS:/.test(property)) {
- throw new error_1.MongoParseError("Auth mechanism property ALLOWED_HOSTS is not allowed in the connection string.");
- }
- }
- }
- if (objectOptions.has("loadBalanced")) {
- throw new error_1.MongoParseError("loadBalanced is only a valid option in the URI");
- }
- const allProvidedOptions = new CaseInsensitiveMap();
- const allProvidedKeys = /* @__PURE__ */ new Set([...urlOptions.keys(), ...objectOptions.keys()]);
- for (const key of allProvidedKeys) {
- const values = [];
- const objectOptionValue = objectOptions.get(key);
- if (objectOptionValue != null) {
- values.push(objectOptionValue);
- }
- const urlValues = urlOptions.get(key) ?? [];
- values.push(...urlValues);
- allProvidedOptions.set(key, values);
- }
- const didMapTLSCertificateFile = allProvidedOptions.has("tlsCertificateKeyFile") && !allProvidedOptions.has("tlsCertificateFile");
- if (didMapTLSCertificateFile) {
- allProvidedOptions.set("tlsCertificateFile", allProvidedOptions.get("tlsCertificateKeyFile"));
- }
- if (allProvidedOptions.has("tls") || allProvidedOptions.has("ssl")) {
- const tlsAndSslOpts = (allProvidedOptions.get("tls") || []).concat(allProvidedOptions.get("ssl") || []).map(getBoolean.bind(null, "tls/ssl"));
- if (new Set(tlsAndSslOpts).size !== 1) {
- throw new error_1.MongoParseError("All values of tls/ssl must be the same.");
- }
- }
- checkTLSOptions(allProvidedOptions);
- const unsupportedOptions = (0, utils_1.setDifference)(allProvidedKeys, Array.from(Object.keys(exports2.OPTIONS)).map((s) => s.toLowerCase()));
- if (unsupportedOptions.size !== 0) {
- const optionWord = unsupportedOptions.size > 1 ? "options" : "option";
- const isOrAre = unsupportedOptions.size > 1 ? "are" : "is";
- throw new error_1.MongoParseError(`${optionWord} ${Array.from(unsupportedOptions).join(", ")} ${isOrAre} not supported`);
- }
- for (const [key, descriptor] of Object.entries(exports2.OPTIONS)) {
- const values = allProvidedOptions.get(key);
- if (!values || values.length === 0) {
- if (exports2.DEFAULT_OPTIONS.has(key)) {
- setOption(mongoOptions, key, descriptor, [exports2.DEFAULT_OPTIONS.get(key)]);
- }
- } else {
- const { deprecated } = descriptor;
- const shouldEmitTLSCertificateFileDeprecation = didMapTLSCertificateFile && key === "tlsCertificateFile";
- if (deprecated && !shouldEmitTLSCertificateFileDeprecation) {
- const deprecatedMsg = typeof deprecated === "string" ? `: ${deprecated}` : "";
- (0, utils_1.emitWarning)(`${key} is a deprecated option${deprecatedMsg}`);
- }
- setOption(mongoOptions, key, descriptor, values);
- }
- }
- if (mongoOptions.credentials) {
- const isGssapi = mongoOptions.credentials.mechanism === providers_1.AuthMechanism.MONGODB_GSSAPI;
- const isX509 = mongoOptions.credentials.mechanism === providers_1.AuthMechanism.MONGODB_X509;
- const isAws = mongoOptions.credentials.mechanism === providers_1.AuthMechanism.MONGODB_AWS;
- const isOidc = mongoOptions.credentials.mechanism === providers_1.AuthMechanism.MONGODB_OIDC;
- if ((isGssapi || isX509) && allProvidedOptions.has("authSource") && mongoOptions.credentials.source !== "$external") {
- throw new error_1.MongoParseError(`authMechanism ${mongoOptions.credentials.mechanism} requires an authSource of '$external'`);
- }
- if (!(isGssapi || isX509 || isAws || isOidc) && mongoOptions.dbName && !allProvidedOptions.has("authSource")) {
- mongoOptions.credentials = mongo_credentials_1.MongoCredentials.merge(mongoOptions.credentials, {
- source: mongoOptions.dbName
- });
- }
- if (isAws && mongoOptions.credentials.username && !mongoOptions.credentials.password) {
- throw new error_1.MongoMissingCredentialsError(`When using ${mongoOptions.credentials.mechanism} password must be set when a username is specified`);
- }
- mongoOptions.credentials.validate();
- if (mongoOptions.credentials.password === "" && mongoOptions.credentials.username === "" && mongoOptions.credentials.mechanism === providers_1.AuthMechanism.MONGODB_DEFAULT && Object.keys(mongoOptions.credentials.mechanismProperties).length === 0) {
- delete mongoOptions.credentials;
- }
- }
- if (!mongoOptions.dbName) {
- mongoOptions.dbName = "test";
- }
- validateLoadBalancedOptions(hosts, mongoOptions, isSRV);
- if (mongoClient && mongoOptions.autoEncryption) {
- encrypter_1.Encrypter.checkForMongoCrypt();
- mongoOptions.encrypter = new encrypter_1.Encrypter(mongoClient, uri, options);
- mongoOptions.autoEncrypter = mongoOptions.encrypter.autoEncrypter;
- }
- mongoOptions.userSpecifiedAuthSource = objectOptions.has("authSource") || urlOptions.has("authSource");
- mongoOptions.userSpecifiedReplicaSet = objectOptions.has("replicaSet") || urlOptions.has("replicaSet");
- if (isSRV) {
- mongoOptions.srvHost = hosts[0];
- if (mongoOptions.directConnection) {
- throw new error_1.MongoAPIError("SRV URI does not support directConnection");
- }
- if (mongoOptions.srvMaxHosts > 0 && typeof mongoOptions.replicaSet === "string") {
- throw new error_1.MongoParseError("Cannot use srvMaxHosts option with replicaSet");
- }
- const noUserSpecifiedTLS = !objectOptions.has("tls") && !urlOptions.has("tls");
- const noUserSpecifiedSSL = !objectOptions.has("ssl") && !urlOptions.has("ssl");
- if (noUserSpecifiedTLS && noUserSpecifiedSSL) {
- mongoOptions.tls = true;
- }
- } else {
- const userSpecifiedSrvOptions = urlOptions.has("srvMaxHosts") || objectOptions.has("srvMaxHosts") || urlOptions.has("srvServiceName") || objectOptions.has("srvServiceName");
- if (userSpecifiedSrvOptions) {
- throw new error_1.MongoParseError("Cannot use srvMaxHosts or srvServiceName with a non-srv connection string");
- }
- }
- if (mongoOptions.directConnection && mongoOptions.hosts.length !== 1) {
- throw new error_1.MongoParseError("directConnection option requires exactly one host");
- }
- if (!mongoOptions.proxyHost && (mongoOptions.proxyPort || mongoOptions.proxyUsername || mongoOptions.proxyPassword)) {
- throw new error_1.MongoParseError("Must specify proxyHost if other proxy options are passed");
- }
- if (mongoOptions.proxyUsername && !mongoOptions.proxyPassword || !mongoOptions.proxyUsername && mongoOptions.proxyPassword) {
- throw new error_1.MongoParseError("Can only specify both of proxy username/password or neither");
- }
- const proxyOptions = ["proxyHost", "proxyPort", "proxyUsername", "proxyPassword"].map((key) => urlOptions.get(key) ?? []);
- if (proxyOptions.some((options2) => options2.length > 1)) {
- throw new error_1.MongoParseError("Proxy options cannot be specified multiple times in the connection string");
- }
- const loggerFeatureFlag = Symbol.for("@@mdb.enableMongoLogger");
- mongoOptions[loggerFeatureFlag] = mongoOptions[loggerFeatureFlag] ?? false;
- let loggerEnvOptions = {};
- let loggerClientOptions = {};
- if (mongoOptions[loggerFeatureFlag]) {
- loggerEnvOptions = {
- MONGODB_LOG_COMMAND: process.env.MONGODB_LOG_COMMAND,
- MONGODB_LOG_TOPOLOGY: process.env.MONGODB_LOG_TOPOLOGY,
- MONGODB_LOG_SERVER_SELECTION: process.env.MONGODB_LOG_SERVER_SELECTION,
- MONGODB_LOG_CONNECTION: process.env.MONGODB_LOG_CONNECTION,
- MONGODB_LOG_ALL: process.env.MONGODB_LOG_ALL,
- MONGODB_LOG_MAX_DOCUMENT_LENGTH: process.env.MONGODB_LOG_MAX_DOCUMENT_LENGTH,
- MONGODB_LOG_PATH: process.env.MONGODB_LOG_PATH,
- ...mongoOptions[Symbol.for("@@mdb.internalLoggerConfig")]
- };
- loggerClientOptions = {
- mongodbLogPath: mongoOptions.mongodbLogPath
- };
- }
- mongoOptions.mongoLoggerOptions = mongo_logger_1.MongoLogger.resolveOptions(loggerEnvOptions, loggerClientOptions);
- mongoOptions.metadata = (0, client_metadata_1.makeClientMetadata)(mongoOptions);
- return mongoOptions;
- }
- exports2.parseOptions = parseOptions;
- function validateLoadBalancedOptions(hosts, mongoOptions, isSrv) {
- if (mongoOptions.loadBalanced) {
- if (hosts.length > 1) {
- throw new error_1.MongoParseError(LB_SINGLE_HOST_ERROR);
- }
- if (mongoOptions.replicaSet) {
- throw new error_1.MongoParseError(LB_REPLICA_SET_ERROR);
- }
- if (mongoOptions.directConnection) {
- throw new error_1.MongoParseError(LB_DIRECT_CONNECTION_ERROR);
- }
- if (isSrv && mongoOptions.srvMaxHosts > 0) {
- throw new error_1.MongoParseError("Cannot limit srv hosts with loadBalanced enabled");
- }
- }
- return;
- }
- function setOption(mongoOptions, key, descriptor, values) {
- const { target, type, transform } = descriptor;
- const name = target ?? key;
- switch (type) {
- case "boolean":
- mongoOptions[name] = getBoolean(name, values[0]);
- break;
- case "int":
- mongoOptions[name] = getIntFromOptions(name, values[0]);
- break;
- case "uint":
- mongoOptions[name] = getUIntFromOptions(name, values[0]);
- break;
- case "string":
- if (values[0] == null) {
- break;
- }
- mongoOptions[name] = String(values[0]);
- break;
- case "record":
- if (!(0, utils_1.isRecord)(values[0])) {
- throw new error_1.MongoParseError(`${name} must be an object`);
- }
- mongoOptions[name] = values[0];
- break;
- case "any":
- mongoOptions[name] = values[0];
- break;
- default: {
- if (!transform) {
- throw new error_1.MongoParseError("Descriptors missing a type must define a transform");
- }
- const transformValue = transform({ name, options: mongoOptions, values });
- mongoOptions[name] = transformValue;
- break;
- }
- }
- }
- exports2.OPTIONS = {
- appName: {
- type: "string"
- },
- auth: {
- target: "credentials",
- transform({ name, options, values: [value] }) {
- if (!(0, utils_1.isRecord)(value, ["username", "password"])) {
- throw new error_1.MongoParseError(`${name} must be an object with 'username' and 'password' properties`);
- }
- return mongo_credentials_1.MongoCredentials.merge(options.credentials, {
- username: value.username,
- password: value.password
- });
- }
- },
- authMechanism: {
- target: "credentials",
- transform({ options, values: [value] }) {
- var _a, _b;
- const mechanisms = Object.values(providers_1.AuthMechanism);
- const [mechanism] = mechanisms.filter((m) => m.match(RegExp(String.raw`\b${value}\b`, "i")));
- if (!mechanism) {
- throw new error_1.MongoParseError(`authMechanism one of ${mechanisms}, got ${value}`);
- }
- let source = (_a = options.credentials) == null ? void 0 : _a.source;
- if (mechanism === providers_1.AuthMechanism.MONGODB_PLAIN || providers_1.AUTH_MECHS_AUTH_SRC_EXTERNAL.has(mechanism)) {
- source = "$external";
- }
- let password = (_b = options.credentials) == null ? void 0 : _b.password;
- if (mechanism === providers_1.AuthMechanism.MONGODB_X509 && password === "") {
- password = void 0;
- }
- return mongo_credentials_1.MongoCredentials.merge(options.credentials, {
- mechanism,
- source,
- password
- });
- }
- },
- authMechanismProperties: {
- target: "credentials",
- transform({ options, values }) {
- let mechanismProperties = /* @__PURE__ */ Object.create(null);
- for (const optionValue of values) {
- if (typeof optionValue === "string") {
- for (const [key, value] of entriesFromString(optionValue)) {
- try {
- mechanismProperties[key] = getBoolean(key, value);
- } catch {
- mechanismProperties[key] = value;
- }
- }
- } else {
- if (!(0, utils_1.isRecord)(optionValue)) {
- throw new error_1.MongoParseError("AuthMechanismProperties must be an object");
- }
- mechanismProperties = { ...optionValue };
- }
- }
- return mongo_credentials_1.MongoCredentials.merge(options.credentials, {
- mechanismProperties
- });
- }
- },
- authSource: {
- target: "credentials",
- transform({ options, values: [value] }) {
- const source = String(value);
- return mongo_credentials_1.MongoCredentials.merge(options.credentials, { source });
- }
- },
- autoEncryption: {
- type: "record"
- },
- bsonRegExp: {
- type: "boolean"
- },
- serverApi: {
- target: "serverApi",
- transform({ values: [version] }) {
- const serverApiToValidate = typeof version === "string" ? { version } : version;
- const versionToValidate = serverApiToValidate && serverApiToValidate.version;
- if (!versionToValidate) {
- throw new error_1.MongoParseError(`Invalid \`serverApi\` property; must specify a version from the following enum: ["${Object.values(mongo_client_1.ServerApiVersion).join('", "')}"]`);
- }
- if (!Object.values(mongo_client_1.ServerApiVersion).some((v) => v === versionToValidate)) {
- throw new error_1.MongoParseError(`Invalid server API version=${versionToValidate}; must be in the following enum: ["${Object.values(mongo_client_1.ServerApiVersion).join('", "')}"]`);
- }
- return serverApiToValidate;
- }
- },
- checkKeys: {
- type: "boolean"
- },
- compressors: {
- default: "none",
- target: "compressors",
- transform({ values }) {
- const compressionList = /* @__PURE__ */ new Set();
- for (const compVal of values) {
- const compValArray = typeof compVal === "string" ? compVal.split(",") : compVal;
- if (!Array.isArray(compValArray)) {
- throw new error_1.MongoInvalidArgumentError("compressors must be an array or a comma-delimited list of strings");
- }
- for (const c of compValArray) {
- if (Object.keys(compression_1.Compressor).includes(String(c))) {
- compressionList.add(String(c));
- } else {
- throw new error_1.MongoInvalidArgumentError(`${c} is not a valid compression mechanism. Must be one of: ${Object.keys(compression_1.Compressor)}.`);
- }
- }
- }
- return [...compressionList];
- }
- },
- connectTimeoutMS: {
- default: 3e4,
- type: "uint"
- },
- dbName: {
- type: "string"
- },
- directConnection: {
- default: false,
- type: "boolean"
- },
- driverInfo: {
- default: {},
- type: "record"
- },
- enableUtf8Validation: { type: "boolean", default: true },
- family: {
- transform({ name, values: [value] }) {
- const transformValue = getIntFromOptions(name, value);
- if (transformValue === 4 || transformValue === 6) {
- return transformValue;
- }
- throw new error_1.MongoParseError(`Option 'family' must be 4 or 6 got ${transformValue}.`);
- }
- },
- fieldsAsRaw: {
- type: "record"
- },
- forceServerObjectId: {
- default: false,
- type: "boolean"
- },
- fsync: {
- deprecated: "Please use journal instead",
- target: "writeConcern",
- transform({ name, options, values: [value] }) {
- const wc = write_concern_1.WriteConcern.fromOptions({
- writeConcern: {
- ...options.writeConcern,
- fsync: getBoolean(name, value)
- }
- });
- if (!wc)
- throw new error_1.MongoParseError(`Unable to make a writeConcern from fsync=${value}`);
- return wc;
- }
- },
- heartbeatFrequencyMS: {
- default: 1e4,
- type: "uint"
- },
- ignoreUndefined: {
- type: "boolean"
- },
- j: {
- deprecated: "Please use journal instead",
- target: "writeConcern",
- transform({ name, options, values: [value] }) {
- const wc = write_concern_1.WriteConcern.fromOptions({
- writeConcern: {
- ...options.writeConcern,
- journal: getBoolean(name, value)
- }
- });
- if (!wc)
- throw new error_1.MongoParseError(`Unable to make a writeConcern from journal=${value}`);
- return wc;
- }
- },
- journal: {
- target: "writeConcern",
- transform({ name, options, values: [value] }) {
- const wc = write_concern_1.WriteConcern.fromOptions({
- writeConcern: {
- ...options.writeConcern,
- journal: getBoolean(name, value)
- }
- });
- if (!wc)
- throw new error_1.MongoParseError(`Unable to make a writeConcern from journal=${value}`);
- return wc;
- }
- },
- keepAlive: {
- default: true,
- type: "boolean",
- deprecated: "Will not be able to turn off in the future."
- },
- keepAliveInitialDelay: {
- default: 12e4,
- type: "uint",
- deprecated: "Will not be configurable in the future."
- },
- loadBalanced: {
- default: false,
- type: "boolean"
- },
- localThresholdMS: {
- default: 15,
- type: "uint"
- },
- maxConnecting: {
- default: 2,
- transform({ name, values: [value] }) {
- const maxConnecting = getUIntFromOptions(name, value);
- if (maxConnecting === 0) {
- throw new error_1.MongoInvalidArgumentError("maxConnecting must be > 0 if specified");
- }
- return maxConnecting;
- }
- },
- maxIdleTimeMS: {
- default: 0,
- type: "uint"
- },
- maxPoolSize: {
- default: 100,
- type: "uint"
- },
- maxStalenessSeconds: {
- target: "readPreference",
- transform({ name, options, values: [value] }) {
- const maxStalenessSeconds = getUIntFromOptions(name, value);
- if (options.readPreference) {
- return read_preference_1.ReadPreference.fromOptions({
- readPreference: { ...options.readPreference, maxStalenessSeconds }
- });
- } else {
- return new read_preference_1.ReadPreference("secondary", void 0, { maxStalenessSeconds });
- }
- }
- },
- minInternalBufferSize: {
- type: "uint"
- },
- minPoolSize: {
- default: 0,
- type: "uint"
- },
- minHeartbeatFrequencyMS: {
- default: 500,
- type: "uint"
- },
- monitorCommands: {
- default: false,
- type: "boolean"
- },
- name: {
- target: "driverInfo",
- transform({ values: [value], options }) {
- return { ...options.driverInfo, name: String(value) };
- }
- },
- noDelay: {
- default: true,
- type: "boolean"
- },
- pkFactory: {
- default: utils_1.DEFAULT_PK_FACTORY,
- transform({ values: [value] }) {
- if ((0, utils_1.isRecord)(value, ["createPk"]) && typeof value.createPk === "function") {
- return value;
- }
- throw new error_1.MongoParseError(`Option pkFactory must be an object with a createPk function, got ${value}`);
- }
- },
- promoteBuffers: {
- type: "boolean"
- },
- promoteLongs: {
- type: "boolean"
- },
- promoteValues: {
- type: "boolean"
- },
- useBigInt64: {
- type: "boolean"
- },
- proxyHost: {
- type: "string"
- },
- proxyPassword: {
- type: "string"
- },
- proxyPort: {
- type: "uint"
- },
- proxyUsername: {
- type: "string"
- },
- raw: {
- default: false,
- type: "boolean"
- },
- readConcern: {
- transform({ values: [value], options }) {
- if (value instanceof read_concern_1.ReadConcern || (0, utils_1.isRecord)(value, ["level"])) {
- return read_concern_1.ReadConcern.fromOptions({ ...options.readConcern, ...value });
- }
- throw new error_1.MongoParseError(`ReadConcern must be an object, got ${JSON.stringify(value)}`);
- }
- },
- readConcernLevel: {
- target: "readConcern",
- transform({ values: [level], options }) {
- return read_concern_1.ReadConcern.fromOptions({
- ...options.readConcern,
- level
- });
- }
- },
- readPreference: {
- default: read_preference_1.ReadPreference.primary,
- transform({ values: [value], options }) {
- var _a, _b, _c;
- if (value instanceof read_preference_1.ReadPreference) {
- return read_preference_1.ReadPreference.fromOptions({
- readPreference: { ...options.readPreference, ...value },
- ...value
- });
- }
- if ((0, utils_1.isRecord)(value, ["mode"])) {
- const rp = read_preference_1.ReadPreference.fromOptions({
- readPreference: { ...options.readPreference, ...value },
- ...value
- });
- if (rp)
- return rp;
- else
- throw new error_1.MongoParseError(`Cannot make read preference from ${JSON.stringify(value)}`);
- }
- if (typeof value === "string") {
- const rpOpts = {
- hedge: (_a = options.readPreference) == null ? void 0 : _a.hedge,
- maxStalenessSeconds: (_b = options.readPreference) == null ? void 0 : _b.maxStalenessSeconds
- };
- return new read_preference_1.ReadPreference(value, (_c = options.readPreference) == null ? void 0 : _c.tags, rpOpts);
- }
- throw new error_1.MongoParseError(`Unknown ReadPreference value: ${value}`);
- }
- },
- readPreferenceTags: {
- target: "readPreference",
- transform({ values, options }) {
- const tags = Array.isArray(values[0]) ? values[0] : values;
- const readPreferenceTags = [];
- for (const tag of tags) {
- const readPreferenceTag = /* @__PURE__ */ Object.create(null);
- if (typeof tag === "string") {
- for (const [k, v] of entriesFromString(tag)) {
- readPreferenceTag[k] = v;
- }
- }
- if ((0, utils_1.isRecord)(tag)) {
- for (const [k, v] of Object.entries(tag)) {
- readPreferenceTag[k] = v;
- }
- }
- readPreferenceTags.push(readPreferenceTag);
- }
- return read_preference_1.ReadPreference.fromOptions({
- readPreference: options.readPreference,
- readPreferenceTags
- });
- }
- },
- replicaSet: {
- type: "string"
- },
- retryReads: {
- default: true,
- type: "boolean"
- },
- retryWrites: {
- default: true,
- type: "boolean"
- },
- serializeFunctions: {
- type: "boolean"
- },
- serverSelectionTimeoutMS: {
- default: 3e4,
- type: "uint"
- },
- servername: {
- type: "string"
- },
- socketTimeoutMS: {
- default: 0,
- type: "uint"
- },
- srvMaxHosts: {
- type: "uint",
- default: 0
- },
- srvServiceName: {
- type: "string",
- default: "mongodb"
- },
- ssl: {
- target: "tls",
- type: "boolean"
- },
- sslCA: {
- deprecated: "sslCA is deprecated and will be removed in the next major version. Please use tlsCAFile instead.",
- target: "ca",
- transform({ values: [value] }) {
- return fs.readFileSync(String(value), { encoding: "ascii" });
- }
- },
- sslCRL: {
- deprecated: "sslCRL is deprecated and will be removed in the next major version and be replaced by tlsCRLFile in that release.",
- target: "crl",
- transform({ values: [value] }) {
- return fs.readFileSync(String(value), { encoding: "ascii" });
- }
- },
- sslCert: {
- deprecated: "sslCert is deprecated and will be removed in the next major version. Please use tlsCertificateKeyFile instead.",
- target: "cert",
- transform({ values: [value] }) {
- return fs.readFileSync(String(value), { encoding: "ascii" });
- }
- },
- sslKey: {
- deprecated: "sslKey is deprecated and will be removed in the next major version. Please use tlsCertificateKeyFile instead.",
- target: "key",
- transform({ values: [value] }) {
- return fs.readFileSync(String(value), { encoding: "ascii" });
- }
- },
- sslPass: {
- deprecated: "sslPass is deprecated and will be removed in the next major version. Please use tlsCertificateKeyFilePassword instead.",
- target: "passphrase",
- type: "string"
- },
- sslValidate: {
- deprecated: "sslValidate is deprecated and will be removed in the next major version. Please use tlsAllowInvalidCertificates instead.",
- target: "rejectUnauthorized",
- type: "boolean"
- },
- tls: {
- type: "boolean"
- },
- tlsAllowInvalidCertificates: {
- target: "rejectUnauthorized",
- transform({ name, values: [value] }) {
- return !getBoolean(name, value);
- }
- },
- tlsAllowInvalidHostnames: {
- target: "checkServerIdentity",
- transform({ name, values: [value] }) {
- return getBoolean(name, value) ? () => void 0 : void 0;
- }
- },
- tlsCAFile: {
- target: "ca",
- transform({ values: [value] }) {
- return fs.readFileSync(String(value), { encoding: "ascii" });
- }
- },
- tlsCertificateFile: {
- deprecated: "tlsCertificateFile is deprecated and will be removed in the next major version. Please use tlsCertificateKeyFile instead.",
- target: "cert",
- transform({ values: [value] }) {
- return fs.readFileSync(String(value), { encoding: "ascii" });
- }
- },
- tlsCertificateKeyFile: {
- target: "key",
- transform({ values: [value] }) {
- return fs.readFileSync(String(value), { encoding: "ascii" });
- }
- },
- tlsCertificateKeyFilePassword: {
- target: "passphrase",
- type: "any"
- },
- tlsInsecure: {
- transform({ name, options, values: [value] }) {
- const tlsInsecure = getBoolean(name, value);
- if (tlsInsecure) {
- options.checkServerIdentity = () => void 0;
- options.rejectUnauthorized = false;
- } else {
- options.checkServerIdentity = options.tlsAllowInvalidHostnames ? () => void 0 : void 0;
- options.rejectUnauthorized = options.tlsAllowInvalidCertificates ? false : true;
- }
- return tlsInsecure;
- }
- },
- w: {
- target: "writeConcern",
- transform({ values: [value], options }) {
- return write_concern_1.WriteConcern.fromOptions({ writeConcern: { ...options.writeConcern, w: value } });
- }
- },
- waitQueueTimeoutMS: {
- default: 0,
- type: "uint"
- },
- writeConcern: {
- target: "writeConcern",
- transform({ values: [value], options }) {
- if ((0, utils_1.isRecord)(value) || value instanceof write_concern_1.WriteConcern) {
- return write_concern_1.WriteConcern.fromOptions({
- writeConcern: {
- ...options.writeConcern,
- ...value
- }
- });
- } else if (value === "majority" || typeof value === "number") {
- return write_concern_1.WriteConcern.fromOptions({
- writeConcern: {
- ...options.writeConcern,
- w: value
- }
- });
- }
- throw new error_1.MongoParseError(`Invalid WriteConcern cannot parse: ${JSON.stringify(value)}`);
- }
- },
- wtimeout: {
- deprecated: "Please use wtimeoutMS instead",
- target: "writeConcern",
- transform({ values: [value], options }) {
- const wc = write_concern_1.WriteConcern.fromOptions({
- writeConcern: {
- ...options.writeConcern,
- wtimeout: getUIntFromOptions("wtimeout", value)
- }
- });
- if (wc)
- return wc;
- throw new error_1.MongoParseError(`Cannot make WriteConcern from wtimeout`);
- }
- },
- wtimeoutMS: {
- target: "writeConcern",
- transform({ values: [value], options }) {
- const wc = write_concern_1.WriteConcern.fromOptions({
- writeConcern: {
- ...options.writeConcern,
- wtimeoutMS: getUIntFromOptions("wtimeoutMS", value)
- }
- });
- if (wc)
- return wc;
- throw new error_1.MongoParseError(`Cannot make WriteConcern from wtimeout`);
- }
- },
- zlibCompressionLevel: {
- default: 0,
- type: "int"
- },
- // Custom types for modifying core behavior
- connectionType: { type: "any" },
- srvPoller: { type: "any" },
- // Accepted NodeJS Options
- minDHSize: { type: "any" },
- pskCallback: { type: "any" },
- secureContext: { type: "any" },
- enableTrace: { type: "any" },
- requestCert: { type: "any" },
- rejectUnauthorized: { type: "any" },
- checkServerIdentity: { type: "any" },
- ALPNProtocols: { type: "any" },
- SNICallback: { type: "any" },
- session: { type: "any" },
- requestOCSP: { type: "any" },
- localAddress: { type: "any" },
- localPort: { type: "any" },
- hints: { type: "any" },
- lookup: { type: "any" },
- ca: { type: "any" },
- cert: { type: "any" },
- ciphers: { type: "any" },
- crl: { type: "any" },
- ecdhCurve: { type: "any" },
- key: { type: "any" },
- passphrase: { type: "any" },
- pfx: { type: "any" },
- secureProtocol: { type: "any" },
- index: { type: "any" },
- // Legacy Options, these are unused but left here to avoid errors with CSFLE lib
- useNewUrlParser: { type: "boolean" },
- useUnifiedTopology: { type: "boolean" },
- // MongoLogger
- // TODO(NODE-4849): Tighten the type of mongodbLogPath
- mongodbLogPath: { type: "any" }
- };
- exports2.DEFAULT_OPTIONS = new CaseInsensitiveMap(Object.entries(exports2.OPTIONS).filter(([, descriptor]) => descriptor.default != null).map(([k, d]) => [k, d.default]));
- exports2.FEATURE_FLAGS = /* @__PURE__ */ new Set([
- Symbol.for("@@mdb.skipPingOnConnect"),
- Symbol.for("@@mdb.enableMongoLogger"),
- Symbol.for("@@mdb.internalLoggerConfig")
- ]);
- }
- });
- // node_modules/mongodb/lib/sdam/events.js
- var require_events = __commonJS({
- "node_modules/mongodb/lib/sdam/events.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ServerHeartbeatFailedEvent = exports2.ServerHeartbeatSucceededEvent = exports2.ServerHeartbeatStartedEvent = exports2.TopologyClosedEvent = exports2.TopologyOpeningEvent = exports2.TopologyDescriptionChangedEvent = exports2.ServerClosedEvent = exports2.ServerOpeningEvent = exports2.ServerDescriptionChangedEvent = void 0;
- var ServerDescriptionChangedEvent = class {
- /** @internal */
- constructor(topologyId, address, previousDescription, newDescription) {
- this.topologyId = topologyId;
- this.address = address;
- this.previousDescription = previousDescription;
- this.newDescription = newDescription;
- }
- };
- exports2.ServerDescriptionChangedEvent = ServerDescriptionChangedEvent;
- var ServerOpeningEvent = class {
- /** @internal */
- constructor(topologyId, address) {
- this.topologyId = topologyId;
- this.address = address;
- }
- };
- exports2.ServerOpeningEvent = ServerOpeningEvent;
- var ServerClosedEvent = class {
- /** @internal */
- constructor(topologyId, address) {
- this.topologyId = topologyId;
- this.address = address;
- }
- };
- exports2.ServerClosedEvent = ServerClosedEvent;
- var TopologyDescriptionChangedEvent = class {
- /** @internal */
- constructor(topologyId, previousDescription, newDescription) {
- this.topologyId = topologyId;
- this.previousDescription = previousDescription;
- this.newDescription = newDescription;
- }
- };
- exports2.TopologyDescriptionChangedEvent = TopologyDescriptionChangedEvent;
- var TopologyOpeningEvent = class {
- /** @internal */
- constructor(topologyId) {
- this.topologyId = topologyId;
- }
- };
- exports2.TopologyOpeningEvent = TopologyOpeningEvent;
- var TopologyClosedEvent = class {
- /** @internal */
- constructor(topologyId) {
- this.topologyId = topologyId;
- }
- };
- exports2.TopologyClosedEvent = TopologyClosedEvent;
- var ServerHeartbeatStartedEvent = class {
- /** @internal */
- constructor(connectionId) {
- this.connectionId = connectionId;
- }
- };
- exports2.ServerHeartbeatStartedEvent = ServerHeartbeatStartedEvent;
- var ServerHeartbeatSucceededEvent = class {
- /** @internal */
- constructor(connectionId, duration, reply) {
- this.connectionId = connectionId;
- this.duration = duration;
- this.reply = reply ?? {};
- }
- };
- exports2.ServerHeartbeatSucceededEvent = ServerHeartbeatSucceededEvent;
- var ServerHeartbeatFailedEvent = class {
- /** @internal */
- constructor(connectionId, duration, failure) {
- this.connectionId = connectionId;
- this.duration = duration;
- this.failure = failure;
- }
- };
- exports2.ServerHeartbeatFailedEvent = ServerHeartbeatFailedEvent;
- }
- });
- // node_modules/mongodb/lib/cmap/commands.js
- var require_commands = __commonJS({
- "node_modules/mongodb/lib/cmap/commands.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.BinMsg = exports2.Msg = exports2.Response = exports2.Query = void 0;
- var BSON = require_bson2();
- var error_1 = require_error();
- var read_preference_1 = require_read_preference();
- var utils_1 = require_utils();
- var constants_1 = require_constants();
- var _requestId = 0;
- var OPTS_TAILABLE_CURSOR = 2;
- var OPTS_SECONDARY = 4;
- var OPTS_OPLOG_REPLAY = 8;
- var OPTS_NO_CURSOR_TIMEOUT = 16;
- var OPTS_AWAIT_DATA = 32;
- var OPTS_EXHAUST = 64;
- var OPTS_PARTIAL = 128;
- var CURSOR_NOT_FOUND = 1;
- var QUERY_FAILURE = 2;
- var SHARD_CONFIG_STALE = 4;
- var AWAIT_CAPABLE = 8;
- var Query = class _Query {
- constructor(ns, query, options) {
- if (ns == null)
- throw new error_1.MongoRuntimeError("Namespace must be specified for query");
- if (query == null)
- throw new error_1.MongoRuntimeError("A query document must be specified for query");
- if (ns.indexOf("\0") !== -1) {
- throw new error_1.MongoRuntimeError("Namespace cannot contain a null character");
- }
- this.ns = ns;
- this.query = query;
- this.numberToSkip = options.numberToSkip || 0;
- this.numberToReturn = options.numberToReturn || 0;
- this.returnFieldSelector = options.returnFieldSelector || void 0;
- this.requestId = _Query.getRequestId();
- this.pre32Limit = options.pre32Limit;
- this.serializeFunctions = typeof options.serializeFunctions === "boolean" ? options.serializeFunctions : false;
- this.ignoreUndefined = typeof options.ignoreUndefined === "boolean" ? options.ignoreUndefined : false;
- this.maxBsonSize = options.maxBsonSize || 1024 * 1024 * 16;
- this.checkKeys = typeof options.checkKeys === "boolean" ? options.checkKeys : false;
- this.batchSize = this.numberToReturn;
- this.tailable = false;
- this.secondaryOk = typeof options.secondaryOk === "boolean" ? options.secondaryOk : false;
- this.oplogReplay = false;
- this.noCursorTimeout = false;
- this.awaitData = false;
- this.exhaust = false;
- this.partial = false;
- }
- /** Assign next request Id. */
- incRequestId() {
- this.requestId = _requestId++;
- }
- /** Peek next request Id. */
- nextRequestId() {
- return _requestId + 1;
- }
- /** Increment then return next request Id. */
- static getRequestId() {
- return ++_requestId;
- }
- // Uses a single allocated buffer for the process, avoiding multiple memory allocations
- toBin() {
- const buffers = [];
- let projection = null;
- let flags = 0;
- if (this.tailable) {
- flags |= OPTS_TAILABLE_CURSOR;
- }
- if (this.secondaryOk) {
- flags |= OPTS_SECONDARY;
- }
- if (this.oplogReplay) {
- flags |= OPTS_OPLOG_REPLAY;
- }
- if (this.noCursorTimeout) {
- flags |= OPTS_NO_CURSOR_TIMEOUT;
- }
- if (this.awaitData) {
- flags |= OPTS_AWAIT_DATA;
- }
- if (this.exhaust) {
- flags |= OPTS_EXHAUST;
- }
- if (this.partial) {
- flags |= OPTS_PARTIAL;
- }
- if (this.batchSize !== this.numberToReturn)
- this.numberToReturn = this.batchSize;
- const header = Buffer.alloc(
- 4 * 4 + // Header
- 4 + // Flags
- Buffer.byteLength(this.ns) + 1 + // namespace
- 4 + // numberToSkip
- 4
- // numberToReturn
- );
- buffers.push(header);
- const query = BSON.serialize(this.query, {
- checkKeys: this.checkKeys,
- serializeFunctions: this.serializeFunctions,
- ignoreUndefined: this.ignoreUndefined
- });
- buffers.push(query);
- if (this.returnFieldSelector && Object.keys(this.returnFieldSelector).length > 0) {
- projection = BSON.serialize(this.returnFieldSelector, {
- checkKeys: this.checkKeys,
- serializeFunctions: this.serializeFunctions,
- ignoreUndefined: this.ignoreUndefined
- });
- buffers.push(projection);
- }
- const totalLength = header.length + query.length + (projection ? projection.length : 0);
- let index = 4;
- header[3] = totalLength >> 24 & 255;
- header[2] = totalLength >> 16 & 255;
- header[1] = totalLength >> 8 & 255;
- header[0] = totalLength & 255;
- header[index + 3] = this.requestId >> 24 & 255;
- header[index + 2] = this.requestId >> 16 & 255;
- header[index + 1] = this.requestId >> 8 & 255;
- header[index] = this.requestId & 255;
- index = index + 4;
- header[index + 3] = 0 >> 24 & 255;
- header[index + 2] = 0 >> 16 & 255;
- header[index + 1] = 0 >> 8 & 255;
- header[index] = 0 & 255;
- index = index + 4;
- header[index + 3] = constants_1.OP_QUERY >> 24 & 255;
- header[index + 2] = constants_1.OP_QUERY >> 16 & 255;
- header[index + 1] = constants_1.OP_QUERY >> 8 & 255;
- header[index] = constants_1.OP_QUERY & 255;
- index = index + 4;
- header[index + 3] = flags >> 24 & 255;
- header[index + 2] = flags >> 16 & 255;
- header[index + 1] = flags >> 8 & 255;
- header[index] = flags & 255;
- index = index + 4;
- index = index + header.write(this.ns, index, "utf8") + 1;
- header[index - 1] = 0;
- header[index + 3] = this.numberToSkip >> 24 & 255;
- header[index + 2] = this.numberToSkip >> 16 & 255;
- header[index + 1] = this.numberToSkip >> 8 & 255;
- header[index] = this.numberToSkip & 255;
- index = index + 4;
- header[index + 3] = this.numberToReturn >> 24 & 255;
- header[index + 2] = this.numberToReturn >> 16 & 255;
- header[index + 1] = this.numberToReturn >> 8 & 255;
- header[index] = this.numberToReturn & 255;
- index = index + 4;
- return buffers;
- }
- };
- exports2.Query = Query;
- var Response = class {
- constructor(message, msgHeader, msgBody, opts) {
- this.documents = new Array(0);
- this.parsed = false;
- this.raw = message;
- this.data = msgBody;
- this.opts = opts ?? {
- useBigInt64: false,
- promoteLongs: true,
- promoteValues: true,
- promoteBuffers: false,
- bsonRegExp: false
- };
- this.length = msgHeader.length;
- this.requestId = msgHeader.requestId;
- this.responseTo = msgHeader.responseTo;
- this.opCode = msgHeader.opCode;
- this.fromCompressed = msgHeader.fromCompressed;
- this.useBigInt64 = typeof this.opts.useBigInt64 === "boolean" ? this.opts.useBigInt64 : false;
- this.promoteLongs = typeof this.opts.promoteLongs === "boolean" ? this.opts.promoteLongs : true;
- this.promoteValues = typeof this.opts.promoteValues === "boolean" ? this.opts.promoteValues : true;
- this.promoteBuffers = typeof this.opts.promoteBuffers === "boolean" ? this.opts.promoteBuffers : false;
- this.bsonRegExp = typeof this.opts.bsonRegExp === "boolean" ? this.opts.bsonRegExp : false;
- }
- isParsed() {
- return this.parsed;
- }
- parse(options) {
- if (this.parsed)
- return;
- options = options ?? {};
- const raw = options.raw || false;
- const documentsReturnedIn = options.documentsReturnedIn || null;
- const useBigInt64 = options.useBigInt64 ?? this.opts.useBigInt64;
- const promoteLongs = options.promoteLongs ?? this.opts.promoteLongs;
- const promoteValues = options.promoteValues ?? this.opts.promoteValues;
- const promoteBuffers = options.promoteBuffers ?? this.opts.promoteBuffers;
- const bsonRegExp = options.bsonRegExp ?? this.opts.bsonRegExp;
- let bsonSize;
- const _options = {
- useBigInt64,
- promoteLongs,
- promoteValues,
- promoteBuffers,
- bsonRegExp
- };
- this.index = 20;
- this.responseFlags = this.data.readInt32LE(0);
- this.cursorId = new BSON.Long(this.data.readInt32LE(4), this.data.readInt32LE(8));
- this.startingFrom = this.data.readInt32LE(12);
- this.numberReturned = this.data.readInt32LE(16);
- this.documents = new Array(this.numberReturned);
- this.cursorNotFound = (this.responseFlags & CURSOR_NOT_FOUND) !== 0;
- this.queryFailure = (this.responseFlags & QUERY_FAILURE) !== 0;
- this.shardConfigStale = (this.responseFlags & SHARD_CONFIG_STALE) !== 0;
- this.awaitCapable = (this.responseFlags & AWAIT_CAPABLE) !== 0;
- for (let i = 0; i < this.numberReturned; i++) {
- bsonSize = this.data[this.index] | this.data[this.index + 1] << 8 | this.data[this.index + 2] << 16 | this.data[this.index + 3] << 24;
- if (raw) {
- this.documents[i] = this.data.slice(this.index, this.index + bsonSize);
- } else {
- this.documents[i] = BSON.deserialize(this.data.slice(this.index, this.index + bsonSize), _options);
- }
- this.index = this.index + bsonSize;
- }
- if (this.documents.length === 1 && documentsReturnedIn != null && raw) {
- const fieldsAsRaw = {};
- fieldsAsRaw[documentsReturnedIn] = true;
- _options.fieldsAsRaw = fieldsAsRaw;
- const doc = BSON.deserialize(this.documents[0], _options);
- this.documents = [doc];
- }
- this.parsed = true;
- }
- };
- exports2.Response = Response;
- var OPTS_CHECKSUM_PRESENT = 1;
- var OPTS_MORE_TO_COME = 2;
- var OPTS_EXHAUST_ALLOWED = 1 << 16;
- var Msg = class _Msg {
- constructor(ns, command, options) {
- if (command == null)
- throw new error_1.MongoInvalidArgumentError("Query document must be specified for query");
- this.ns = ns;
- this.command = command;
- this.command.$db = (0, utils_1.databaseNamespace)(ns);
- if (options.readPreference && options.readPreference.mode !== read_preference_1.ReadPreference.PRIMARY) {
- this.command.$readPreference = options.readPreference.toJSON();
- }
- this.options = options ?? {};
- this.requestId = options.requestId ? options.requestId : _Msg.getRequestId();
- this.serializeFunctions = typeof options.serializeFunctions === "boolean" ? options.serializeFunctions : false;
- this.ignoreUndefined = typeof options.ignoreUndefined === "boolean" ? options.ignoreUndefined : false;
- this.checkKeys = typeof options.checkKeys === "boolean" ? options.checkKeys : false;
- this.maxBsonSize = options.maxBsonSize || 1024 * 1024 * 16;
- this.checksumPresent = false;
- this.moreToCome = options.moreToCome || false;
- this.exhaustAllowed = typeof options.exhaustAllowed === "boolean" ? options.exhaustAllowed : false;
- }
- toBin() {
- const buffers = [];
- let flags = 0;
- if (this.checksumPresent) {
- flags |= OPTS_CHECKSUM_PRESENT;
- }
- if (this.moreToCome) {
- flags |= OPTS_MORE_TO_COME;
- }
- if (this.exhaustAllowed) {
- flags |= OPTS_EXHAUST_ALLOWED;
- }
- const header = Buffer.alloc(
- 4 * 4 + // Header
- 4
- // Flags
- );
- buffers.push(header);
- let totalLength = header.length;
- const command = this.command;
- totalLength += this.makeDocumentSegment(buffers, command);
- header.writeInt32LE(totalLength, 0);
- header.writeInt32LE(this.requestId, 4);
- header.writeInt32LE(0, 8);
- header.writeInt32LE(constants_1.OP_MSG, 12);
- header.writeUInt32LE(flags, 16);
- return buffers;
- }
- makeDocumentSegment(buffers, document) {
- const payloadTypeBuffer = Buffer.alloc(1);
- payloadTypeBuffer[0] = 0;
- const documentBuffer = this.serializeBson(document);
- buffers.push(payloadTypeBuffer);
- buffers.push(documentBuffer);
- return payloadTypeBuffer.length + documentBuffer.length;
- }
- serializeBson(document) {
- return BSON.serialize(document, {
- checkKeys: this.checkKeys,
- serializeFunctions: this.serializeFunctions,
- ignoreUndefined: this.ignoreUndefined
- });
- }
- static getRequestId() {
- _requestId = _requestId + 1 & 2147483647;
- return _requestId;
- }
- };
- exports2.Msg = Msg;
- var BinMsg = class {
- constructor(message, msgHeader, msgBody, opts) {
- this.parsed = false;
- this.raw = message;
- this.data = msgBody;
- this.opts = opts ?? {
- useBigInt64: false,
- promoteLongs: true,
- promoteValues: true,
- promoteBuffers: false,
- bsonRegExp: false
- };
- this.length = msgHeader.length;
- this.requestId = msgHeader.requestId;
- this.responseTo = msgHeader.responseTo;
- this.opCode = msgHeader.opCode;
- this.fromCompressed = msgHeader.fromCompressed;
- this.responseFlags = msgBody.readInt32LE(0);
- this.checksumPresent = (this.responseFlags & OPTS_CHECKSUM_PRESENT) !== 0;
- this.moreToCome = (this.responseFlags & OPTS_MORE_TO_COME) !== 0;
- this.exhaustAllowed = (this.responseFlags & OPTS_EXHAUST_ALLOWED) !== 0;
- this.useBigInt64 = typeof this.opts.useBigInt64 === "boolean" ? this.opts.useBigInt64 : false;
- this.promoteLongs = typeof this.opts.promoteLongs === "boolean" ? this.opts.promoteLongs : true;
- this.promoteValues = typeof this.opts.promoteValues === "boolean" ? this.opts.promoteValues : true;
- this.promoteBuffers = typeof this.opts.promoteBuffers === "boolean" ? this.opts.promoteBuffers : false;
- this.bsonRegExp = typeof this.opts.bsonRegExp === "boolean" ? this.opts.bsonRegExp : false;
- this.documents = [];
- }
- isParsed() {
- return this.parsed;
- }
- parse(options) {
- if (this.parsed)
- return;
- options = options ?? {};
- this.index = 4;
- const raw = options.raw || false;
- const documentsReturnedIn = options.documentsReturnedIn || null;
- const useBigInt64 = options.useBigInt64 ?? this.opts.useBigInt64;
- const promoteLongs = options.promoteLongs ?? this.opts.promoteLongs;
- const promoteValues = options.promoteValues ?? this.opts.promoteValues;
- const promoteBuffers = options.promoteBuffers ?? this.opts.promoteBuffers;
- const bsonRegExp = options.bsonRegExp ?? this.opts.bsonRegExp;
- const validation = this.parseBsonSerializationOptions(options);
- const bsonOptions = {
- useBigInt64,
- promoteLongs,
- promoteValues,
- promoteBuffers,
- bsonRegExp,
- validation
- // Due to the strictness of the BSON libraries validation option we need this cast
- };
- while (this.index < this.data.length) {
- const payloadType = this.data.readUInt8(this.index++);
- if (payloadType === 0) {
- const bsonSize = this.data.readUInt32LE(this.index);
- const bin = this.data.slice(this.index, this.index + bsonSize);
- this.documents.push(raw ? bin : BSON.deserialize(bin, bsonOptions));
- this.index += bsonSize;
- } else if (payloadType === 1) {
- throw new error_1.MongoRuntimeError("OP_MSG Payload Type 1 detected unsupported protocol");
- }
- }
- if (this.documents.length === 1 && documentsReturnedIn != null && raw) {
- const fieldsAsRaw = {};
- fieldsAsRaw[documentsReturnedIn] = true;
- bsonOptions.fieldsAsRaw = fieldsAsRaw;
- const doc = BSON.deserialize(this.documents[0], bsonOptions);
- this.documents = [doc];
- }
- this.parsed = true;
- }
- parseBsonSerializationOptions({ enableUtf8Validation }) {
- if (enableUtf8Validation === false) {
- return { utf8: false };
- }
- return { utf8: { writeErrors: false } };
- }
- };
- exports2.BinMsg = BinMsg;
- }
- });
- // node_modules/mongodb/lib/cmap/command_monitoring_events.js
- var require_command_monitoring_events = __commonJS({
- "node_modules/mongodb/lib/cmap/command_monitoring_events.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.SENSITIVE_COMMANDS = exports2.CommandFailedEvent = exports2.CommandSucceededEvent = exports2.CommandStartedEvent = void 0;
- var constants_1 = require_constants2();
- var utils_1 = require_utils();
- var commands_1 = require_commands();
- var CommandStartedEvent = class {
- /**
- * Create a started event
- *
- * @internal
- * @param pool - the pool that originated the command
- * @param command - the command
- */
- constructor(connection, command) {
- this.name = constants_1.COMMAND_STARTED;
- const cmd = extractCommand(command);
- const commandName = extractCommandName(cmd);
- const { address, connectionId, serviceId } = extractConnectionDetails(connection);
- if (exports2.SENSITIVE_COMMANDS.has(commandName)) {
- this.commandObj = {};
- this.commandObj[commandName] = true;
- }
- this.address = address;
- this.connectionId = connectionId;
- this.serviceId = serviceId;
- this.requestId = command.requestId;
- this.databaseName = databaseName(command);
- this.commandName = commandName;
- this.command = maybeRedact(commandName, cmd, cmd);
- }
- /* @internal */
- get hasServiceId() {
- return !!this.serviceId;
- }
- };
- exports2.CommandStartedEvent = CommandStartedEvent;
- var CommandSucceededEvent = class {
- /**
- * Create a succeeded event
- *
- * @internal
- * @param pool - the pool that originated the command
- * @param command - the command
- * @param reply - the reply for this command from the server
- * @param started - a high resolution tuple timestamp of when the command was first sent, to calculate duration
- */
- constructor(connection, command, reply, started) {
- this.name = constants_1.COMMAND_SUCCEEDED;
- const cmd = extractCommand(command);
- const commandName = extractCommandName(cmd);
- const { address, connectionId, serviceId } = extractConnectionDetails(connection);
- this.address = address;
- this.connectionId = connectionId;
- this.serviceId = serviceId;
- this.requestId = command.requestId;
- this.commandName = commandName;
- this.duration = (0, utils_1.calculateDurationInMs)(started);
- this.reply = maybeRedact(commandName, cmd, extractReply(command, reply));
- }
- /* @internal */
- get hasServiceId() {
- return !!this.serviceId;
- }
- };
- exports2.CommandSucceededEvent = CommandSucceededEvent;
- var CommandFailedEvent = class {
- /**
- * Create a failure event
- *
- * @internal
- * @param pool - the pool that originated the command
- * @param command - the command
- * @param error - the generated error or a server error response
- * @param started - a high resolution tuple timestamp of when the command was first sent, to calculate duration
- */
- constructor(connection, command, error, started) {
- this.name = constants_1.COMMAND_FAILED;
- const cmd = extractCommand(command);
- const commandName = extractCommandName(cmd);
- const { address, connectionId, serviceId } = extractConnectionDetails(connection);
- this.address = address;
- this.connectionId = connectionId;
- this.serviceId = serviceId;
- this.requestId = command.requestId;
- this.commandName = commandName;
- this.duration = (0, utils_1.calculateDurationInMs)(started);
- this.failure = maybeRedact(commandName, cmd, error);
- }
- /* @internal */
- get hasServiceId() {
- return !!this.serviceId;
- }
- };
- exports2.CommandFailedEvent = CommandFailedEvent;
- exports2.SENSITIVE_COMMANDS = /* @__PURE__ */ new Set([
- "authenticate",
- "saslStart",
- "saslContinue",
- "getnonce",
- "createUser",
- "updateUser",
- "copydbgetnonce",
- "copydbsaslstart",
- "copydb"
- ]);
- var HELLO_COMMANDS = /* @__PURE__ */ new Set(["hello", constants_1.LEGACY_HELLO_COMMAND, constants_1.LEGACY_HELLO_COMMAND_CAMEL_CASE]);
- var extractCommandName = (commandDoc) => Object.keys(commandDoc)[0];
- var namespace = (command) => command.ns;
- var databaseName = (command) => command.ns.split(".")[0];
- var collectionName = (command) => command.ns.split(".")[1];
- var maybeRedact = (commandName, commandDoc, result) => exports2.SENSITIVE_COMMANDS.has(commandName) || HELLO_COMMANDS.has(commandName) && commandDoc.speculativeAuthenticate ? {} : result;
- var LEGACY_FIND_QUERY_MAP = {
- $query: "filter",
- $orderby: "sort",
- $hint: "hint",
- $comment: "comment",
- $maxScan: "maxScan",
- $max: "max",
- $min: "min",
- $returnKey: "returnKey",
- $showDiskLoc: "showRecordId",
- $maxTimeMS: "maxTimeMS",
- $snapshot: "snapshot"
- };
- var LEGACY_FIND_OPTIONS_MAP = {
- numberToSkip: "skip",
- numberToReturn: "batchSize",
- returnFieldSelector: "projection"
- };
- var OP_QUERY_KEYS = [
- "tailable",
- "oplogReplay",
- "noCursorTimeout",
- "awaitData",
- "partial",
- "exhaust"
- ];
- function extractCommand(command) {
- var _a;
- if (command instanceof commands_1.Msg) {
- return (0, utils_1.deepCopy)(command.command);
- }
- if ((_a = command.query) == null ? void 0 : _a.$query) {
- let result;
- if (command.ns === "admin.$cmd") {
- result = Object.assign({}, command.query.$query);
- } else {
- result = { find: collectionName(command) };
- Object.keys(LEGACY_FIND_QUERY_MAP).forEach((key) => {
- if (command.query[key] != null) {
- result[LEGACY_FIND_QUERY_MAP[key]] = (0, utils_1.deepCopy)(command.query[key]);
- }
- });
- }
- Object.keys(LEGACY_FIND_OPTIONS_MAP).forEach((key) => {
- const legacyKey = key;
- if (command[legacyKey] != null) {
- result[LEGACY_FIND_OPTIONS_MAP[legacyKey]] = (0, utils_1.deepCopy)(command[legacyKey]);
- }
- });
- OP_QUERY_KEYS.forEach((key) => {
- if (command[key]) {
- result[key] = command[key];
- }
- });
- if (command.pre32Limit != null) {
- result.limit = command.pre32Limit;
- }
- if (command.query.$explain) {
- return { explain: result };
- }
- return result;
- }
- const clonedQuery = {};
- const clonedCommand = {};
- if (command.query) {
- for (const k in command.query) {
- clonedQuery[k] = (0, utils_1.deepCopy)(command.query[k]);
- }
- clonedCommand.query = clonedQuery;
- }
- for (const k in command) {
- if (k === "query")
- continue;
- clonedCommand[k] = (0, utils_1.deepCopy)(command[k]);
- }
- return command.query ? clonedQuery : clonedCommand;
- }
- function extractReply(command, reply) {
- if (!reply) {
- return reply;
- }
- if (command instanceof commands_1.Msg) {
- return (0, utils_1.deepCopy)(reply.result ? reply.result : reply);
- }
- if (command.query && command.query.$query != null) {
- return {
- ok: 1,
- cursor: {
- id: (0, utils_1.deepCopy)(reply.cursorId),
- ns: namespace(command),
- firstBatch: (0, utils_1.deepCopy)(reply.documents)
- }
- };
- }
- return (0, utils_1.deepCopy)(reply.result ? reply.result : reply);
- }
- function extractConnectionDetails(connection) {
- let connectionId;
- if ("id" in connection) {
- connectionId = connection.id;
- }
- return {
- address: connection.address,
- serviceId: connection.serviceId,
- connectionId
- };
- }
- }
- });
- // node_modules/mongodb/lib/cmap/message_stream.js
- var require_message_stream = __commonJS({
- "node_modules/mongodb/lib/cmap/message_stream.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.MessageStream = void 0;
- var stream_1 = require("stream");
- var error_1 = require_error();
- var utils_1 = require_utils();
- var commands_1 = require_commands();
- var compression_1 = require_compression();
- var constants_1 = require_constants();
- var MESSAGE_HEADER_SIZE = 16;
- var COMPRESSION_DETAILS_SIZE = 9;
- var kDefaultMaxBsonMessageSize = 1024 * 1024 * 16 * 4;
- var kBuffer = Symbol("buffer");
- var MessageStream = class extends stream_1.Duplex {
- constructor(options = {}) {
- super(options);
- this.isMonitoringConnection = false;
- this.maxBsonMessageSize = options.maxBsonMessageSize || kDefaultMaxBsonMessageSize;
- this[kBuffer] = new utils_1.BufferPool();
- }
- get buffer() {
- return this[kBuffer];
- }
- _write(chunk, _, callback) {
- this[kBuffer].append(chunk);
- processIncomingData(this, callback);
- }
- _read() {
- return;
- }
- writeCommand(command, operationDescription) {
- const agreedCompressor = operationDescription.agreedCompressor ?? "none";
- if (agreedCompressor === "none" || !canCompress(command)) {
- const data = command.toBin();
- this.push(Array.isArray(data) ? Buffer.concat(data) : data);
- return;
- }
- const concatenatedOriginalCommandBuffer = Buffer.concat(command.toBin());
- const messageToBeCompressed = concatenatedOriginalCommandBuffer.slice(MESSAGE_HEADER_SIZE);
- const originalCommandOpCode = concatenatedOriginalCommandBuffer.readInt32LE(12);
- const options = {
- agreedCompressor,
- zlibCompressionLevel: operationDescription.zlibCompressionLevel ?? 0
- };
- (0, compression_1.compress)(options, messageToBeCompressed).then((compressedMessage) => {
- const msgHeader = Buffer.alloc(MESSAGE_HEADER_SIZE);
- msgHeader.writeInt32LE(MESSAGE_HEADER_SIZE + COMPRESSION_DETAILS_SIZE + compressedMessage.length, 0);
- msgHeader.writeInt32LE(command.requestId, 4);
- msgHeader.writeInt32LE(0, 8);
- msgHeader.writeInt32LE(constants_1.OP_COMPRESSED, 12);
- const compressionDetails = Buffer.alloc(COMPRESSION_DETAILS_SIZE);
- compressionDetails.writeInt32LE(originalCommandOpCode, 0);
- compressionDetails.writeInt32LE(messageToBeCompressed.length, 4);
- compressionDetails.writeUInt8(compression_1.Compressor[agreedCompressor], 8);
- this.push(Buffer.concat([msgHeader, compressionDetails, compressedMessage]));
- }, (error) => {
- operationDescription.cb(error);
- });
- }
- };
- exports2.MessageStream = MessageStream;
- function canCompress(command) {
- const commandDoc = command instanceof commands_1.Msg ? command.command : command.query;
- const commandName = Object.keys(commandDoc)[0];
- return !compression_1.uncompressibleCommands.has(commandName);
- }
- function processIncomingData(stream, callback) {
- const buffer = stream[kBuffer];
- const sizeOfMessage = buffer.getInt32();
- if (sizeOfMessage == null) {
- return callback();
- }
- if (sizeOfMessage < 0) {
- return callback(new error_1.MongoParseError(`Invalid message size: ${sizeOfMessage}`));
- }
- if (sizeOfMessage > stream.maxBsonMessageSize) {
- return callback(new error_1.MongoParseError(`Invalid message size: ${sizeOfMessage}, max allowed: ${stream.maxBsonMessageSize}`));
- }
- if (sizeOfMessage > buffer.length) {
- return callback();
- }
- const message = buffer.read(sizeOfMessage);
- const messageHeader = {
- length: message.readInt32LE(0),
- requestId: message.readInt32LE(4),
- responseTo: message.readInt32LE(8),
- opCode: message.readInt32LE(12)
- };
- const monitorHasAnotherHello = () => {
- if (stream.isMonitoringConnection) {
- const sizeOfMessage2 = buffer.getInt32();
- if (sizeOfMessage2 != null && sizeOfMessage2 <= buffer.length) {
- return true;
- }
- }
- return false;
- };
- let ResponseType = messageHeader.opCode === constants_1.OP_MSG ? commands_1.BinMsg : commands_1.Response;
- if (messageHeader.opCode !== constants_1.OP_COMPRESSED) {
- const messageBody = message.subarray(MESSAGE_HEADER_SIZE);
- if (monitorHasAnotherHello()) {
- return processIncomingData(stream, callback);
- }
- stream.emit("message", new ResponseType(message, messageHeader, messageBody));
- if (buffer.length >= 4) {
- return processIncomingData(stream, callback);
- }
- return callback();
- }
- messageHeader.fromCompressed = true;
- messageHeader.opCode = message.readInt32LE(MESSAGE_HEADER_SIZE);
- messageHeader.length = message.readInt32LE(MESSAGE_HEADER_SIZE + 4);
- const compressorID = message[MESSAGE_HEADER_SIZE + 8];
- const compressedBuffer = message.slice(MESSAGE_HEADER_SIZE + 9);
- ResponseType = messageHeader.opCode === constants_1.OP_MSG ? commands_1.BinMsg : commands_1.Response;
- (0, compression_1.decompress)(compressorID, compressedBuffer).then((messageBody) => {
- if (messageBody.length !== messageHeader.length) {
- return callback(new error_1.MongoDecompressionError("Message body and message header must be the same length"));
- }
- if (monitorHasAnotherHello()) {
- return processIncomingData(stream, callback);
- }
- stream.emit("message", new ResponseType(message, messageHeader, messageBody));
- if (buffer.length >= 4) {
- return processIncomingData(stream, callback);
- }
- return callback();
- }, (error) => {
- return callback(error);
- });
- }
- }
- });
- // node_modules/mongodb/lib/cmap/stream_description.js
- var require_stream_description = __commonJS({
- "node_modules/mongodb/lib/cmap/stream_description.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.StreamDescription = void 0;
- var common_1 = require_common();
- var server_description_1 = require_server_description();
- var RESPONSE_FIELDS = [
- "minWireVersion",
- "maxWireVersion",
- "maxBsonObjectSize",
- "maxMessageSizeBytes",
- "maxWriteBatchSize",
- "logicalSessionTimeoutMinutes"
- ];
- var StreamDescription = class {
- constructor(address, options) {
- this.address = address;
- this.type = common_1.ServerType.Unknown;
- this.minWireVersion = void 0;
- this.maxWireVersion = void 0;
- this.maxBsonObjectSize = 16777216;
- this.maxMessageSizeBytes = 48e6;
- this.maxWriteBatchSize = 1e5;
- this.logicalSessionTimeoutMinutes = options == null ? void 0 : options.logicalSessionTimeoutMinutes;
- this.loadBalanced = !!(options == null ? void 0 : options.loadBalanced);
- this.compressors = options && options.compressors && Array.isArray(options.compressors) ? options.compressors : [];
- }
- receiveResponse(response) {
- if (response == null) {
- return;
- }
- this.type = (0, server_description_1.parseServerType)(response);
- for (const field of RESPONSE_FIELDS) {
- if (response[field] != null) {
- this[field] = response[field];
- }
- if ("__nodejs_mock_server__" in response) {
- this.__nodejs_mock_server__ = response["__nodejs_mock_server__"];
- }
- }
- if (response.compression) {
- this.compressor = this.compressors.filter((c) => {
- var _a;
- return (_a = response.compression) == null ? void 0 : _a.includes(c);
- })[0];
- }
- }
- };
- exports2.StreamDescription = StreamDescription;
- }
- });
- // node_modules/mongodb/lib/cmap/connection.js
- var require_connection = __commonJS({
- "node_modules/mongodb/lib/cmap/connection.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.hasSessionSupport = exports2.CryptoConnection = exports2.Connection = void 0;
- var timers_1 = require("timers");
- var util_1 = require("util");
- var constants_1 = require_constants2();
- var error_1 = require_error();
- var mongo_types_1 = require_mongo_types();
- var sessions_1 = require_sessions();
- var utils_1 = require_utils();
- var command_monitoring_events_1 = require_command_monitoring_events();
- var commands_1 = require_commands();
- var message_stream_1 = require_message_stream();
- var stream_description_1 = require_stream_description();
- var shared_1 = require_shared();
- var kStream = Symbol("stream");
- var kQueue = Symbol("queue");
- var kMessageStream = Symbol("messageStream");
- var kGeneration = Symbol("generation");
- var kLastUseTime = Symbol("lastUseTime");
- var kClusterTime = Symbol("clusterTime");
- var kDescription = Symbol("description");
- var kHello = Symbol("hello");
- var kAutoEncrypter = Symbol("autoEncrypter");
- var kDelayedTimeoutId = Symbol("delayedTimeoutId");
- var INVALID_QUEUE_SIZE = "Connection internal queue contains more than 1 operation description";
- var Connection = class _Connection extends mongo_types_1.TypedEventEmitter {
- constructor(stream, options) {
- var _a;
- super();
- this.commandAsync = (0, util_1.promisify)((ns, cmd, options2, callback) => this.command(ns, cmd, options2, callback));
- this.id = options.id;
- this.address = streamIdentifier(stream, options);
- this.socketTimeoutMS = options.socketTimeoutMS ?? 0;
- this.monitorCommands = options.monitorCommands;
- this.serverApi = options.serverApi;
- this.closed = false;
- this[kHello] = null;
- this[kClusterTime] = null;
- this[kDescription] = new stream_description_1.StreamDescription(this.address, options);
- this[kGeneration] = options.generation;
- this[kLastUseTime] = (0, utils_1.now)();
- this[kQueue] = /* @__PURE__ */ new Map();
- this[kMessageStream] = new message_stream_1.MessageStream({
- ...options,
- maxBsonMessageSize: (_a = this.hello) == null ? void 0 : _a.maxBsonMessageSize
- });
- this[kStream] = stream;
- this[kDelayedTimeoutId] = null;
- this[kMessageStream].on("message", (message) => this.onMessage(message));
- this[kMessageStream].on("error", (error) => this.onError(error));
- this[kStream].on("close", () => this.onClose());
- this[kStream].on("timeout", () => this.onTimeout());
- this[kStream].on("error", () => {
- });
- this[kStream].pipe(this[kMessageStream]);
- this[kMessageStream].pipe(this[kStream]);
- }
- get description() {
- return this[kDescription];
- }
- get hello() {
- return this[kHello];
- }
- // the `connect` method stores the result of the handshake hello on the connection
- set hello(response) {
- this[kDescription].receiveResponse(response);
- this[kDescription] = Object.freeze(this[kDescription]);
- this[kHello] = response;
- }
- // Set the whether the message stream is for a monitoring connection.
- set isMonitoringConnection(value) {
- this[kMessageStream].isMonitoringConnection = value;
- }
- get isMonitoringConnection() {
- return this[kMessageStream].isMonitoringConnection;
- }
- get serviceId() {
- var _a;
- return (_a = this.hello) == null ? void 0 : _a.serviceId;
- }
- get loadBalanced() {
- return this.description.loadBalanced;
- }
- get generation() {
- return this[kGeneration] || 0;
- }
- set generation(generation) {
- this[kGeneration] = generation;
- }
- get idleTime() {
- return (0, utils_1.calculateDurationInMs)(this[kLastUseTime]);
- }
- get clusterTime() {
- return this[kClusterTime];
- }
- get stream() {
- return this[kStream];
- }
- markAvailable() {
- this[kLastUseTime] = (0, utils_1.now)();
- }
- onError(error) {
- this.cleanup(true, error);
- }
- onClose() {
- const message = `connection ${this.id} to ${this.address} closed`;
- this.cleanup(true, new error_1.MongoNetworkError(message));
- }
- onTimeout() {
- this[kDelayedTimeoutId] = (0, timers_1.setTimeout)(() => {
- const message = `connection ${this.id} to ${this.address} timed out`;
- const beforeHandshake = this.hello == null;
- this.cleanup(true, new error_1.MongoNetworkTimeoutError(message, { beforeHandshake }));
- }, 1).unref();
- }
- onMessage(message) {
- const delayedTimeoutId = this[kDelayedTimeoutId];
- if (delayedTimeoutId != null) {
- (0, timers_1.clearTimeout)(delayedTimeoutId);
- this[kDelayedTimeoutId] = null;
- }
- const socketTimeoutMS = this[kStream].timeout ?? 0;
- this[kStream].setTimeout(0);
- this.emit("message", message);
- let operationDescription = this[kQueue].get(message.responseTo);
- if (!operationDescription && this.isMonitoringConnection) {
- if (this[kQueue].size > 1) {
- this.cleanup(true, new error_1.MongoRuntimeError(INVALID_QUEUE_SIZE));
- } else {
- const entry = this[kQueue].entries().next();
- if (entry.value != null) {
- const [requestId, orphaned] = entry.value;
- operationDescription = orphaned;
- this[kQueue].delete(requestId);
- }
- }
- }
- if (!operationDescription) {
- return;
- }
- const callback = operationDescription.cb;
- this[kQueue].delete(message.responseTo);
- if ("moreToCome" in message && message.moreToCome) {
- this[kQueue].set(message.requestId, operationDescription);
- this[kStream].setTimeout(socketTimeoutMS);
- }
- try {
- message.parse(operationDescription);
- } catch (err) {
- callback(err);
- return;
- }
- if (message.documents[0]) {
- const document = message.documents[0];
- const session = operationDescription.session;
- if (session) {
- (0, sessions_1.updateSessionFromResponse)(session, document);
- }
- if (document.$clusterTime) {
- this[kClusterTime] = document.$clusterTime;
- this.emit(_Connection.CLUSTER_TIME_RECEIVED, document.$clusterTime);
- }
- if (document.writeConcernError) {
- callback(new error_1.MongoWriteConcernError(document.writeConcernError, document), document);
- return;
- }
- if (document.ok === 0 || document.$err || document.errmsg || document.code) {
- callback(new error_1.MongoServerError(document));
- return;
- }
- }
- callback(void 0, message.documents[0]);
- }
- destroy(options, callback) {
- if (this.closed) {
- process.nextTick(() => callback == null ? void 0 : callback());
- return;
- }
- if (typeof callback === "function") {
- this.once("close", () => process.nextTick(() => callback()));
- }
- this.removeAllListeners(_Connection.PINNED);
- this.removeAllListeners(_Connection.UNPINNED);
- const message = `connection ${this.id} to ${this.address} closed`;
- this.cleanup(options.force, new error_1.MongoNetworkError(message));
- }
- /**
- * A method that cleans up the connection. When `force` is true, this method
- * forcibly destroys the socket.
- *
- * If an error is provided, any in-flight operations will be closed with the error.
- *
- * This method does nothing if the connection is already closed.
- */
- cleanup(force, error) {
- if (this.closed) {
- return;
- }
- this.closed = true;
- const completeCleanup = () => {
- for (const op of this[kQueue].values()) {
- op.cb(error);
- }
- this[kQueue].clear();
- this.emit(_Connection.CLOSE);
- };
- this[kStream].removeAllListeners();
- this[kMessageStream].removeAllListeners();
- this[kMessageStream].destroy();
- if (force) {
- this[kStream].destroy();
- completeCleanup();
- return;
- }
- if (!this[kStream].writableEnded) {
- this[kStream].end(() => {
- this[kStream].destroy();
- completeCleanup();
- });
- } else {
- completeCleanup();
- }
- }
- command(ns, command, options, callback) {
- let cmd = { ...command };
- const readPreference = (0, shared_1.getReadPreference)(options);
- const shouldUseOpMsg = supportsOpMsg(this);
- const session = options == null ? void 0 : options.session;
- let clusterTime = this.clusterTime;
- if (this.serverApi) {
- const { version, strict, deprecationErrors } = this.serverApi;
- cmd.apiVersion = version;
- if (strict != null)
- cmd.apiStrict = strict;
- if (deprecationErrors != null)
- cmd.apiDeprecationErrors = deprecationErrors;
- }
- if (hasSessionSupport(this) && session) {
- if (session.clusterTime && clusterTime && session.clusterTime.clusterTime.greaterThan(clusterTime.clusterTime)) {
- clusterTime = session.clusterTime;
- }
- const err = (0, sessions_1.applySession)(session, cmd, options);
- if (err) {
- return callback(err);
- }
- } else if (session == null ? void 0 : session.explicit) {
- return callback(new error_1.MongoCompatibilityError("Current topology does not support sessions"));
- }
- if (clusterTime) {
- cmd.$clusterTime = clusterTime;
- }
- if ((0, shared_1.isSharded)(this) && !shouldUseOpMsg && readPreference && readPreference.mode !== "primary") {
- cmd = {
- $query: cmd,
- $readPreference: readPreference.toJSON()
- };
- }
- const commandOptions = Object.assign({
- numberToSkip: 0,
- numberToReturn: -1,
- checkKeys: false,
- // This value is not overridable
- secondaryOk: readPreference.secondaryOk()
- }, options);
- const cmdNs = `${ns.db}.$cmd`;
- const message = shouldUseOpMsg ? new commands_1.Msg(cmdNs, cmd, commandOptions) : new commands_1.Query(cmdNs, cmd, commandOptions);
- try {
- write(this, message, commandOptions, callback);
- } catch (err) {
- callback(err);
- }
- }
- };
- Connection.COMMAND_STARTED = constants_1.COMMAND_STARTED;
- Connection.COMMAND_SUCCEEDED = constants_1.COMMAND_SUCCEEDED;
- Connection.COMMAND_FAILED = constants_1.COMMAND_FAILED;
- Connection.CLUSTER_TIME_RECEIVED = constants_1.CLUSTER_TIME_RECEIVED;
- Connection.CLOSE = constants_1.CLOSE;
- Connection.MESSAGE = constants_1.MESSAGE;
- Connection.PINNED = constants_1.PINNED;
- Connection.UNPINNED = constants_1.UNPINNED;
- exports2.Connection = Connection;
- var CryptoConnection = class extends Connection {
- constructor(stream, options) {
- super(stream, options);
- this[kAutoEncrypter] = options.autoEncrypter;
- }
- /** @internal @override */
- command(ns, cmd, options, callback) {
- const autoEncrypter = this[kAutoEncrypter];
- if (!autoEncrypter) {
- return callback(new error_1.MongoMissingDependencyError("No AutoEncrypter available for encryption"));
- }
- const serverWireVersion = (0, utils_1.maxWireVersion)(this);
- if (serverWireVersion === 0) {
- return super.command(ns, cmd, options, callback);
- }
- if (serverWireVersion < 8) {
- callback(new error_1.MongoCompatibilityError("Auto-encryption requires a minimum MongoDB version of 4.2"));
- return;
- }
- const sort = cmd.find || cmd.findAndModify ? cmd.sort : null;
- const indexKeys = cmd.createIndexes ? cmd.indexes.map((index) => index.key) : null;
- autoEncrypter.encrypt(ns.toString(), cmd, options, (err, encrypted) => {
- if (err || encrypted == null) {
- callback(err, null);
- return;
- }
- if (sort != null && (cmd.find || cmd.findAndModify)) {
- encrypted.sort = sort;
- }
- if (indexKeys != null && cmd.createIndexes) {
- for (const [offset, index] of indexKeys.entries()) {
- encrypted.indexes[offset].key = index;
- }
- }
- super.command(ns, encrypted, options, (err2, response) => {
- if (err2 || response == null) {
- callback(err2, response);
- return;
- }
- autoEncrypter.decrypt(response, options, callback);
- });
- });
- }
- };
- exports2.CryptoConnection = CryptoConnection;
- function hasSessionSupport(conn) {
- const description = conn.description;
- return description.logicalSessionTimeoutMinutes != null;
- }
- exports2.hasSessionSupport = hasSessionSupport;
- function supportsOpMsg(conn) {
- const description = conn.description;
- if (description == null) {
- return false;
- }
- return (0, utils_1.maxWireVersion)(conn) >= 6 && !description.__nodejs_mock_server__;
- }
- function streamIdentifier(stream, options) {
- if (options.proxyHost) {
- return options.hostAddress.toString();
- }
- const { remoteAddress, remotePort } = stream;
- if (typeof remoteAddress === "string" && typeof remotePort === "number") {
- return utils_1.HostAddress.fromHostPort(remoteAddress, remotePort).toString();
- }
- return (0, utils_1.uuidV4)().toString("hex");
- }
- function write(conn, command, options, callback) {
- options = options ?? {};
- const operationDescription = {
- requestId: command.requestId,
- cb: callback,
- session: options.session,
- noResponse: typeof options.noResponse === "boolean" ? options.noResponse : false,
- documentsReturnedIn: options.documentsReturnedIn,
- // for BSON parsing
- useBigInt64: typeof options.useBigInt64 === "boolean" ? options.useBigInt64 : false,
- promoteLongs: typeof options.promoteLongs === "boolean" ? options.promoteLongs : true,
- promoteValues: typeof options.promoteValues === "boolean" ? options.promoteValues : true,
- promoteBuffers: typeof options.promoteBuffers === "boolean" ? options.promoteBuffers : false,
- bsonRegExp: typeof options.bsonRegExp === "boolean" ? options.bsonRegExp : false,
- enableUtf8Validation: typeof options.enableUtf8Validation === "boolean" ? options.enableUtf8Validation : true,
- raw: typeof options.raw === "boolean" ? options.raw : false,
- started: 0
- };
- if (conn[kDescription] && conn[kDescription].compressor) {
- operationDescription.agreedCompressor = conn[kDescription].compressor;
- if (conn[kDescription].zlibCompressionLevel) {
- operationDescription.zlibCompressionLevel = conn[kDescription].zlibCompressionLevel;
- }
- }
- if (typeof options.socketTimeoutMS === "number") {
- conn[kStream].setTimeout(options.socketTimeoutMS);
- } else if (conn.socketTimeoutMS !== 0) {
- conn[kStream].setTimeout(conn.socketTimeoutMS);
- }
- if (conn.monitorCommands) {
- conn.emit(Connection.COMMAND_STARTED, new command_monitoring_events_1.CommandStartedEvent(conn, command));
- operationDescription.started = (0, utils_1.now)();
- operationDescription.cb = (err, reply) => {
- if (err && (reply == null ? void 0 : reply.ok) !== 1) {
- conn.emit(Connection.COMMAND_FAILED, new command_monitoring_events_1.CommandFailedEvent(conn, command, err, operationDescription.started));
- } else {
- if (reply && (reply.ok === 0 || reply.$err)) {
- conn.emit(Connection.COMMAND_FAILED, new command_monitoring_events_1.CommandFailedEvent(conn, command, reply, operationDescription.started));
- } else {
- conn.emit(Connection.COMMAND_SUCCEEDED, new command_monitoring_events_1.CommandSucceededEvent(conn, command, reply, operationDescription.started));
- }
- }
- if (typeof callback === "function") {
- callback(err, err instanceof error_1.MongoWriteConcernError ? void 0 : reply);
- }
- };
- }
- if (!operationDescription.noResponse) {
- conn[kQueue].set(operationDescription.requestId, operationDescription);
- }
- try {
- conn[kMessageStream].writeCommand(command, operationDescription);
- } catch (e) {
- if (!operationDescription.noResponse) {
- conn[kQueue].delete(operationDescription.requestId);
- operationDescription.cb(e);
- return;
- }
- }
- if (operationDescription.noResponse) {
- operationDescription.cb();
- }
- }
- }
- });
- // node_modules/smart-buffer/build/utils.js
- var require_utils3 = __commonJS({
- "node_modules/smart-buffer/build/utils.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- var buffer_1 = require("buffer");
- var ERRORS = {
- INVALID_ENCODING: "Invalid encoding provided. Please specify a valid encoding the internal Node.js Buffer supports.",
- INVALID_SMARTBUFFER_SIZE: "Invalid size provided. Size must be a valid integer greater than zero.",
- INVALID_SMARTBUFFER_BUFFER: "Invalid Buffer provided in SmartBufferOptions.",
- INVALID_SMARTBUFFER_OBJECT: "Invalid SmartBufferOptions object supplied to SmartBuffer constructor or factory methods.",
- INVALID_OFFSET: "An invalid offset value was provided.",
- INVALID_OFFSET_NON_NUMBER: "An invalid offset value was provided. A numeric value is required.",
- INVALID_LENGTH: "An invalid length value was provided.",
- INVALID_LENGTH_NON_NUMBER: "An invalid length value was provived. A numeric value is required.",
- INVALID_TARGET_OFFSET: "Target offset is beyond the bounds of the internal SmartBuffer data.",
- INVALID_TARGET_LENGTH: "Specified length value moves cursor beyong the bounds of the internal SmartBuffer data.",
- INVALID_READ_BEYOND_BOUNDS: "Attempted to read beyond the bounds of the managed data.",
- INVALID_WRITE_BEYOND_BOUNDS: "Attempted to write beyond the bounds of the managed data."
- };
- exports2.ERRORS = ERRORS;
- function checkEncoding(encoding) {
- if (!buffer_1.Buffer.isEncoding(encoding)) {
- throw new Error(ERRORS.INVALID_ENCODING);
- }
- }
- exports2.checkEncoding = checkEncoding;
- function isFiniteInteger(value) {
- return typeof value === "number" && isFinite(value) && isInteger(value);
- }
- exports2.isFiniteInteger = isFiniteInteger;
- function checkOffsetOrLengthValue(value, offset) {
- if (typeof value === "number") {
- if (!isFiniteInteger(value) || value < 0) {
- throw new Error(offset ? ERRORS.INVALID_OFFSET : ERRORS.INVALID_LENGTH);
- }
- } else {
- throw new Error(offset ? ERRORS.INVALID_OFFSET_NON_NUMBER : ERRORS.INVALID_LENGTH_NON_NUMBER);
- }
- }
- function checkLengthValue(length) {
- checkOffsetOrLengthValue(length, false);
- }
- exports2.checkLengthValue = checkLengthValue;
- function checkOffsetValue(offset) {
- checkOffsetOrLengthValue(offset, true);
- }
- exports2.checkOffsetValue = checkOffsetValue;
- function checkTargetOffset(offset, buff) {
- if (offset < 0 || offset > buff.length) {
- throw new Error(ERRORS.INVALID_TARGET_OFFSET);
- }
- }
- exports2.checkTargetOffset = checkTargetOffset;
- function isInteger(value) {
- return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
- }
- function bigIntAndBufferInt64Check(bufferMethod) {
- if (typeof BigInt === "undefined") {
- throw new Error("Platform does not support JS BigInt type.");
- }
- if (typeof buffer_1.Buffer.prototype[bufferMethod] === "undefined") {
- throw new Error(`Platform does not support Buffer.prototype.${bufferMethod}.`);
- }
- }
- exports2.bigIntAndBufferInt64Check = bigIntAndBufferInt64Check;
- }
- });
- // node_modules/smart-buffer/build/smartbuffer.js
- var require_smartbuffer = __commonJS({
- "node_modules/smart-buffer/build/smartbuffer.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- var utils_1 = require_utils3();
- var DEFAULT_SMARTBUFFER_SIZE = 4096;
- var DEFAULT_SMARTBUFFER_ENCODING = "utf8";
- var SmartBuffer = class _SmartBuffer {
- /**
- * Creates a new SmartBuffer instance.
- *
- * @param options { SmartBufferOptions } The SmartBufferOptions to apply to this instance.
- */
- constructor(options) {
- this.length = 0;
- this._encoding = DEFAULT_SMARTBUFFER_ENCODING;
- this._writeOffset = 0;
- this._readOffset = 0;
- if (_SmartBuffer.isSmartBufferOptions(options)) {
- if (options.encoding) {
- utils_1.checkEncoding(options.encoding);
- this._encoding = options.encoding;
- }
- if (options.size) {
- if (utils_1.isFiniteInteger(options.size) && options.size > 0) {
- this._buff = Buffer.allocUnsafe(options.size);
- } else {
- throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_SIZE);
- }
- } else if (options.buff) {
- if (Buffer.isBuffer(options.buff)) {
- this._buff = options.buff;
- this.length = options.buff.length;
- } else {
- throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_BUFFER);
- }
- } else {
- this._buff = Buffer.allocUnsafe(DEFAULT_SMARTBUFFER_SIZE);
- }
- } else {
- if (typeof options !== "undefined") {
- throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_OBJECT);
- }
- this._buff = Buffer.allocUnsafe(DEFAULT_SMARTBUFFER_SIZE);
- }
- }
- /**
- * Creates a new SmartBuffer instance with the provided internal Buffer size and optional encoding.
- *
- * @param size { Number } The size of the internal Buffer.
- * @param encoding { String } The BufferEncoding to use for strings.
- *
- * @return { SmartBuffer }
- */
- static fromSize(size, encoding) {
- return new this({
- size,
- encoding
- });
- }
- /**
- * Creates a new SmartBuffer instance with the provided Buffer and optional encoding.
- *
- * @param buffer { Buffer } The Buffer to use as the internal Buffer value.
- * @param encoding { String } The BufferEncoding to use for strings.
- *
- * @return { SmartBuffer }
- */
- static fromBuffer(buff, encoding) {
- return new this({
- buff,
- encoding
- });
- }
- /**
- * Creates a new SmartBuffer instance with the provided SmartBufferOptions options.
- *
- * @param options { SmartBufferOptions } The options to use when creating the SmartBuffer instance.
- */
- static fromOptions(options) {
- return new this(options);
- }
- /**
- * Type checking function that determines if an object is a SmartBufferOptions object.
- */
- static isSmartBufferOptions(options) {
- const castOptions = options;
- return castOptions && (castOptions.encoding !== void 0 || castOptions.size !== void 0 || castOptions.buff !== void 0);
- }
- // Signed integers
- /**
- * Reads an Int8 value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readInt8(offset) {
- return this._readNumberValue(Buffer.prototype.readInt8, 1, offset);
- }
- /**
- * Reads an Int16BE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readInt16BE(offset) {
- return this._readNumberValue(Buffer.prototype.readInt16BE, 2, offset);
- }
- /**
- * Reads an Int16LE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readInt16LE(offset) {
- return this._readNumberValue(Buffer.prototype.readInt16LE, 2, offset);
- }
- /**
- * Reads an Int32BE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readInt32BE(offset) {
- return this._readNumberValue(Buffer.prototype.readInt32BE, 4, offset);
- }
- /**
- * Reads an Int32LE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readInt32LE(offset) {
- return this._readNumberValue(Buffer.prototype.readInt32LE, 4, offset);
- }
- /**
- * Reads a BigInt64BE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { BigInt }
- */
- readBigInt64BE(offset) {
- utils_1.bigIntAndBufferInt64Check("readBigInt64BE");
- return this._readNumberValue(Buffer.prototype.readBigInt64BE, 8, offset);
- }
- /**
- * Reads a BigInt64LE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { BigInt }
- */
- readBigInt64LE(offset) {
- utils_1.bigIntAndBufferInt64Check("readBigInt64LE");
- return this._readNumberValue(Buffer.prototype.readBigInt64LE, 8, offset);
- }
- /**
- * Writes an Int8 value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeInt8(value, offset) {
- this._writeNumberValue(Buffer.prototype.writeInt8, 1, value, offset);
- return this;
- }
- /**
- * Inserts an Int8 value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertInt8(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeInt8, 1, value, offset);
- }
- /**
- * Writes an Int16BE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeInt16BE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeInt16BE, 2, value, offset);
- }
- /**
- * Inserts an Int16BE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertInt16BE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeInt16BE, 2, value, offset);
- }
- /**
- * Writes an Int16LE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeInt16LE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeInt16LE, 2, value, offset);
- }
- /**
- * Inserts an Int16LE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertInt16LE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeInt16LE, 2, value, offset);
- }
- /**
- * Writes an Int32BE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeInt32BE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeInt32BE, 4, value, offset);
- }
- /**
- * Inserts an Int32BE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertInt32BE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeInt32BE, 4, value, offset);
- }
- /**
- * Writes an Int32LE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeInt32LE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeInt32LE, 4, value, offset);
- }
- /**
- * Inserts an Int32LE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertInt32LE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeInt32LE, 4, value, offset);
- }
- /**
- * Writes a BigInt64BE value to the current write position (or at optional offset).
- *
- * @param value { BigInt } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeBigInt64BE(value, offset) {
- utils_1.bigIntAndBufferInt64Check("writeBigInt64BE");
- return this._writeNumberValue(Buffer.prototype.writeBigInt64BE, 8, value, offset);
- }
- /**
- * Inserts a BigInt64BE value at the given offset value.
- *
- * @param value { BigInt } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertBigInt64BE(value, offset) {
- utils_1.bigIntAndBufferInt64Check("writeBigInt64BE");
- return this._insertNumberValue(Buffer.prototype.writeBigInt64BE, 8, value, offset);
- }
- /**
- * Writes a BigInt64LE value to the current write position (or at optional offset).
- *
- * @param value { BigInt } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeBigInt64LE(value, offset) {
- utils_1.bigIntAndBufferInt64Check("writeBigInt64LE");
- return this._writeNumberValue(Buffer.prototype.writeBigInt64LE, 8, value, offset);
- }
- /**
- * Inserts a Int64LE value at the given offset value.
- *
- * @param value { BigInt } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertBigInt64LE(value, offset) {
- utils_1.bigIntAndBufferInt64Check("writeBigInt64LE");
- return this._insertNumberValue(Buffer.prototype.writeBigInt64LE, 8, value, offset);
- }
- // Unsigned Integers
- /**
- * Reads an UInt8 value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readUInt8(offset) {
- return this._readNumberValue(Buffer.prototype.readUInt8, 1, offset);
- }
- /**
- * Reads an UInt16BE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readUInt16BE(offset) {
- return this._readNumberValue(Buffer.prototype.readUInt16BE, 2, offset);
- }
- /**
- * Reads an UInt16LE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readUInt16LE(offset) {
- return this._readNumberValue(Buffer.prototype.readUInt16LE, 2, offset);
- }
- /**
- * Reads an UInt32BE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readUInt32BE(offset) {
- return this._readNumberValue(Buffer.prototype.readUInt32BE, 4, offset);
- }
- /**
- * Reads an UInt32LE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readUInt32LE(offset) {
- return this._readNumberValue(Buffer.prototype.readUInt32LE, 4, offset);
- }
- /**
- * Reads a BigUInt64BE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { BigInt }
- */
- readBigUInt64BE(offset) {
- utils_1.bigIntAndBufferInt64Check("readBigUInt64BE");
- return this._readNumberValue(Buffer.prototype.readBigUInt64BE, 8, offset);
- }
- /**
- * Reads a BigUInt64LE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { BigInt }
- */
- readBigUInt64LE(offset) {
- utils_1.bigIntAndBufferInt64Check("readBigUInt64LE");
- return this._readNumberValue(Buffer.prototype.readBigUInt64LE, 8, offset);
- }
- /**
- * Writes an UInt8 value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeUInt8(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeUInt8, 1, value, offset);
- }
- /**
- * Inserts an UInt8 value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertUInt8(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeUInt8, 1, value, offset);
- }
- /**
- * Writes an UInt16BE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeUInt16BE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeUInt16BE, 2, value, offset);
- }
- /**
- * Inserts an UInt16BE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertUInt16BE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeUInt16BE, 2, value, offset);
- }
- /**
- * Writes an UInt16LE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeUInt16LE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeUInt16LE, 2, value, offset);
- }
- /**
- * Inserts an UInt16LE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertUInt16LE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeUInt16LE, 2, value, offset);
- }
- /**
- * Writes an UInt32BE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeUInt32BE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeUInt32BE, 4, value, offset);
- }
- /**
- * Inserts an UInt32BE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertUInt32BE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeUInt32BE, 4, value, offset);
- }
- /**
- * Writes an UInt32LE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeUInt32LE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeUInt32LE, 4, value, offset);
- }
- /**
- * Inserts an UInt32LE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertUInt32LE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeUInt32LE, 4, value, offset);
- }
- /**
- * Writes a BigUInt64BE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeBigUInt64BE(value, offset) {
- utils_1.bigIntAndBufferInt64Check("writeBigUInt64BE");
- return this._writeNumberValue(Buffer.prototype.writeBigUInt64BE, 8, value, offset);
- }
- /**
- * Inserts a BigUInt64BE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertBigUInt64BE(value, offset) {
- utils_1.bigIntAndBufferInt64Check("writeBigUInt64BE");
- return this._insertNumberValue(Buffer.prototype.writeBigUInt64BE, 8, value, offset);
- }
- /**
- * Writes a BigUInt64LE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeBigUInt64LE(value, offset) {
- utils_1.bigIntAndBufferInt64Check("writeBigUInt64LE");
- return this._writeNumberValue(Buffer.prototype.writeBigUInt64LE, 8, value, offset);
- }
- /**
- * Inserts a BigUInt64LE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertBigUInt64LE(value, offset) {
- utils_1.bigIntAndBufferInt64Check("writeBigUInt64LE");
- return this._insertNumberValue(Buffer.prototype.writeBigUInt64LE, 8, value, offset);
- }
- // Floating Point
- /**
- * Reads an FloatBE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readFloatBE(offset) {
- return this._readNumberValue(Buffer.prototype.readFloatBE, 4, offset);
- }
- /**
- * Reads an FloatLE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readFloatLE(offset) {
- return this._readNumberValue(Buffer.prototype.readFloatLE, 4, offset);
- }
- /**
- * Writes a FloatBE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeFloatBE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeFloatBE, 4, value, offset);
- }
- /**
- * Inserts a FloatBE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertFloatBE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeFloatBE, 4, value, offset);
- }
- /**
- * Writes a FloatLE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeFloatLE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeFloatLE, 4, value, offset);
- }
- /**
- * Inserts a FloatLE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertFloatLE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeFloatLE, 4, value, offset);
- }
- // Double Floating Point
- /**
- * Reads an DoublEBE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readDoubleBE(offset) {
- return this._readNumberValue(Buffer.prototype.readDoubleBE, 8, offset);
- }
- /**
- * Reads an DoubleLE value from the current read position or an optionally provided offset.
- *
- * @param offset { Number } The offset to read data from (optional)
- * @return { Number }
- */
- readDoubleLE(offset) {
- return this._readNumberValue(Buffer.prototype.readDoubleLE, 8, offset);
- }
- /**
- * Writes a DoubleBE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeDoubleBE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeDoubleBE, 8, value, offset);
- }
- /**
- * Inserts a DoubleBE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertDoubleBE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeDoubleBE, 8, value, offset);
- }
- /**
- * Writes a DoubleLE value to the current write position (or at optional offset).
- *
- * @param value { Number } The value to write.
- * @param offset { Number } The offset to write the value at.
- *
- * @return this
- */
- writeDoubleLE(value, offset) {
- return this._writeNumberValue(Buffer.prototype.writeDoubleLE, 8, value, offset);
- }
- /**
- * Inserts a DoubleLE value at the given offset value.
- *
- * @param value { Number } The value to insert.
- * @param offset { Number } The offset to insert the value at.
- *
- * @return this
- */
- insertDoubleLE(value, offset) {
- return this._insertNumberValue(Buffer.prototype.writeDoubleLE, 8, value, offset);
- }
- // Strings
- /**
- * Reads a String from the current read position.
- *
- * @param arg1 { Number | String } The number of bytes to read as a String, or the BufferEncoding to use for
- * the string (Defaults to instance level encoding).
- * @param encoding { String } The BufferEncoding to use for the string (Defaults to instance level encoding).
- *
- * @return { String }
- */
- readString(arg1, encoding) {
- let lengthVal;
- if (typeof arg1 === "number") {
- utils_1.checkLengthValue(arg1);
- lengthVal = Math.min(arg1, this.length - this._readOffset);
- } else {
- encoding = arg1;
- lengthVal = this.length - this._readOffset;
- }
- if (typeof encoding !== "undefined") {
- utils_1.checkEncoding(encoding);
- }
- const value = this._buff.slice(this._readOffset, this._readOffset + lengthVal).toString(encoding || this._encoding);
- this._readOffset += lengthVal;
- return value;
- }
- /**
- * Inserts a String
- *
- * @param value { String } The String value to insert.
- * @param offset { Number } The offset to insert the string at.
- * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
- *
- * @return this
- */
- insertString(value, offset, encoding) {
- utils_1.checkOffsetValue(offset);
- return this._handleString(value, true, offset, encoding);
- }
- /**
- * Writes a String
- *
- * @param value { String } The String value to write.
- * @param arg2 { Number | String } The offset to write the string at, or the BufferEncoding to use.
- * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
- *
- * @return this
- */
- writeString(value, arg2, encoding) {
- return this._handleString(value, false, arg2, encoding);
- }
- /**
- * Reads a null-terminated String from the current read position.
- *
- * @param encoding { String } The BufferEncoding to use for the string (Defaults to instance level encoding).
- *
- * @return { String }
- */
- readStringNT(encoding) {
- if (typeof encoding !== "undefined") {
- utils_1.checkEncoding(encoding);
- }
- let nullPos = this.length;
- for (let i = this._readOffset; i < this.length; i++) {
- if (this._buff[i] === 0) {
- nullPos = i;
- break;
- }
- }
- const value = this._buff.slice(this._readOffset, nullPos);
- this._readOffset = nullPos + 1;
- return value.toString(encoding || this._encoding);
- }
- /**
- * Inserts a null-terminated String.
- *
- * @param value { String } The String value to write.
- * @param arg2 { Number | String } The offset to write the string to, or the BufferEncoding to use.
- * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
- *
- * @return this
- */
- insertStringNT(value, offset, encoding) {
- utils_1.checkOffsetValue(offset);
- this.insertString(value, offset, encoding);
- this.insertUInt8(0, offset + value.length);
- return this;
- }
- /**
- * Writes a null-terminated String.
- *
- * @param value { String } The String value to write.
- * @param arg2 { Number | String } The offset to write the string to, or the BufferEncoding to use.
- * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
- *
- * @return this
- */
- writeStringNT(value, arg2, encoding) {
- this.writeString(value, arg2, encoding);
- this.writeUInt8(0, typeof arg2 === "number" ? arg2 + value.length : this.writeOffset);
- return this;
- }
- // Buffers
- /**
- * Reads a Buffer from the internal read position.
- *
- * @param length { Number } The length of data to read as a Buffer.
- *
- * @return { Buffer }
- */
- readBuffer(length) {
- if (typeof length !== "undefined") {
- utils_1.checkLengthValue(length);
- }
- const lengthVal = typeof length === "number" ? length : this.length;
- const endPoint = Math.min(this.length, this._readOffset + lengthVal);
- const value = this._buff.slice(this._readOffset, endPoint);
- this._readOffset = endPoint;
- return value;
- }
- /**
- * Writes a Buffer to the current write position.
- *
- * @param value { Buffer } The Buffer to write.
- * @param offset { Number } The offset to write the Buffer to.
- *
- * @return this
- */
- insertBuffer(value, offset) {
- utils_1.checkOffsetValue(offset);
- return this._handleBuffer(value, true, offset);
- }
- /**
- * Writes a Buffer to the current write position.
- *
- * @param value { Buffer } The Buffer to write.
- * @param offset { Number } The offset to write the Buffer to.
- *
- * @return this
- */
- writeBuffer(value, offset) {
- return this._handleBuffer(value, false, offset);
- }
- /**
- * Reads a null-terminated Buffer from the current read poisiton.
- *
- * @return { Buffer }
- */
- readBufferNT() {
- let nullPos = this.length;
- for (let i = this._readOffset; i < this.length; i++) {
- if (this._buff[i] === 0) {
- nullPos = i;
- break;
- }
- }
- const value = this._buff.slice(this._readOffset, nullPos);
- this._readOffset = nullPos + 1;
- return value;
- }
- /**
- * Inserts a null-terminated Buffer.
- *
- * @param value { Buffer } The Buffer to write.
- * @param offset { Number } The offset to write the Buffer to.
- *
- * @return this
- */
- insertBufferNT(value, offset) {
- utils_1.checkOffsetValue(offset);
- this.insertBuffer(value, offset);
- this.insertUInt8(0, offset + value.length);
- return this;
- }
- /**
- * Writes a null-terminated Buffer.
- *
- * @param value { Buffer } The Buffer to write.
- * @param offset { Number } The offset to write the Buffer to.
- *
- * @return this
- */
- writeBufferNT(value, offset) {
- if (typeof offset !== "undefined") {
- utils_1.checkOffsetValue(offset);
- }
- this.writeBuffer(value, offset);
- this.writeUInt8(0, typeof offset === "number" ? offset + value.length : this._writeOffset);
- return this;
- }
- /**
- * Clears the SmartBuffer instance to its original empty state.
- */
- clear() {
- this._writeOffset = 0;
- this._readOffset = 0;
- this.length = 0;
- return this;
- }
- /**
- * Gets the remaining data left to be read from the SmartBuffer instance.
- *
- * @return { Number }
- */
- remaining() {
- return this.length - this._readOffset;
- }
- /**
- * Gets the current read offset value of the SmartBuffer instance.
- *
- * @return { Number }
- */
- get readOffset() {
- return this._readOffset;
- }
- /**
- * Sets the read offset value of the SmartBuffer instance.
- *
- * @param offset { Number } - The offset value to set.
- */
- set readOffset(offset) {
- utils_1.checkOffsetValue(offset);
- utils_1.checkTargetOffset(offset, this);
- this._readOffset = offset;
- }
- /**
- * Gets the current write offset value of the SmartBuffer instance.
- *
- * @return { Number }
- */
- get writeOffset() {
- return this._writeOffset;
- }
- /**
- * Sets the write offset value of the SmartBuffer instance.
- *
- * @param offset { Number } - The offset value to set.
- */
- set writeOffset(offset) {
- utils_1.checkOffsetValue(offset);
- utils_1.checkTargetOffset(offset, this);
- this._writeOffset = offset;
- }
- /**
- * Gets the currently set string encoding of the SmartBuffer instance.
- *
- * @return { BufferEncoding } The string Buffer encoding currently set.
- */
- get encoding() {
- return this._encoding;
- }
- /**
- * Sets the string encoding of the SmartBuffer instance.
- *
- * @param encoding { BufferEncoding } The string Buffer encoding to set.
- */
- set encoding(encoding) {
- utils_1.checkEncoding(encoding);
- this._encoding = encoding;
- }
- /**
- * Gets the underlying internal Buffer. (This includes unmanaged data in the Buffer)
- *
- * @return { Buffer } The Buffer value.
- */
- get internalBuffer() {
- return this._buff;
- }
- /**
- * Gets the value of the internal managed Buffer (Includes managed data only)
- *
- * @param { Buffer }
- */
- toBuffer() {
- return this._buff.slice(0, this.length);
- }
- /**
- * Gets the String value of the internal managed Buffer
- *
- * @param encoding { String } The BufferEncoding to display the Buffer as (defaults to instance level encoding).
- */
- toString(encoding) {
- const encodingVal = typeof encoding === "string" ? encoding : this._encoding;
- utils_1.checkEncoding(encodingVal);
- return this._buff.toString(encodingVal, 0, this.length);
- }
- /**
- * Destroys the SmartBuffer instance.
- */
- destroy() {
- this.clear();
- return this;
- }
- /**
- * Handles inserting and writing strings.
- *
- * @param value { String } The String value to insert.
- * @param isInsert { Boolean } True if inserting a string, false if writing.
- * @param arg2 { Number | String } The offset to insert the string at, or the BufferEncoding to use.
- * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
- */
- _handleString(value, isInsert, arg3, encoding) {
- let offsetVal = this._writeOffset;
- let encodingVal = this._encoding;
- if (typeof arg3 === "number") {
- offsetVal = arg3;
- } else if (typeof arg3 === "string") {
- utils_1.checkEncoding(arg3);
- encodingVal = arg3;
- }
- if (typeof encoding === "string") {
- utils_1.checkEncoding(encoding);
- encodingVal = encoding;
- }
- const byteLength = Buffer.byteLength(value, encodingVal);
- if (isInsert) {
- this.ensureInsertable(byteLength, offsetVal);
- } else {
- this._ensureWriteable(byteLength, offsetVal);
- }
- this._buff.write(value, offsetVal, byteLength, encodingVal);
- if (isInsert) {
- this._writeOffset += byteLength;
- } else {
- if (typeof arg3 === "number") {
- this._writeOffset = Math.max(this._writeOffset, offsetVal + byteLength);
- } else {
- this._writeOffset += byteLength;
- }
- }
- return this;
- }
- /**
- * Handles writing or insert of a Buffer.
- *
- * @param value { Buffer } The Buffer to write.
- * @param offset { Number } The offset to write the Buffer to.
- */
- _handleBuffer(value, isInsert, offset) {
- const offsetVal = typeof offset === "number" ? offset : this._writeOffset;
- if (isInsert) {
- this.ensureInsertable(value.length, offsetVal);
- } else {
- this._ensureWriteable(value.length, offsetVal);
- }
- value.copy(this._buff, offsetVal);
- if (isInsert) {
- this._writeOffset += value.length;
- } else {
- if (typeof offset === "number") {
- this._writeOffset = Math.max(this._writeOffset, offsetVal + value.length);
- } else {
- this._writeOffset += value.length;
- }
- }
- return this;
- }
- /**
- * Ensures that the internal Buffer is large enough to read data.
- *
- * @param length { Number } The length of the data that needs to be read.
- * @param offset { Number } The offset of the data that needs to be read.
- */
- ensureReadable(length, offset) {
- let offsetVal = this._readOffset;
- if (typeof offset !== "undefined") {
- utils_1.checkOffsetValue(offset);
- offsetVal = offset;
- }
- if (offsetVal < 0 || offsetVal + length > this.length) {
- throw new Error(utils_1.ERRORS.INVALID_READ_BEYOND_BOUNDS);
- }
- }
- /**
- * Ensures that the internal Buffer is large enough to insert data.
- *
- * @param dataLength { Number } The length of the data that needs to be written.
- * @param offset { Number } The offset of the data to be written.
- */
- ensureInsertable(dataLength, offset) {
- utils_1.checkOffsetValue(offset);
- this._ensureCapacity(this.length + dataLength);
- if (offset < this.length) {
- this._buff.copy(this._buff, offset + dataLength, offset, this._buff.length);
- }
- if (offset + dataLength > this.length) {
- this.length = offset + dataLength;
- } else {
- this.length += dataLength;
- }
- }
- /**
- * Ensures that the internal Buffer is large enough to write data.
- *
- * @param dataLength { Number } The length of the data that needs to be written.
- * @param offset { Number } The offset of the data to be written (defaults to writeOffset).
- */
- _ensureWriteable(dataLength, offset) {
- const offsetVal = typeof offset === "number" ? offset : this._writeOffset;
- this._ensureCapacity(offsetVal + dataLength);
- if (offsetVal + dataLength > this.length) {
- this.length = offsetVal + dataLength;
- }
- }
- /**
- * Ensures that the internal Buffer is large enough to write at least the given amount of data.
- *
- * @param minLength { Number } The minimum length of the data needs to be written.
- */
- _ensureCapacity(minLength) {
- const oldLength = this._buff.length;
- if (minLength > oldLength) {
- let data = this._buff;
- let newLength = oldLength * 3 / 2 + 1;
- if (newLength < minLength) {
- newLength = minLength;
- }
- this._buff = Buffer.allocUnsafe(newLength);
- data.copy(this._buff, 0, 0, oldLength);
- }
- }
- /**
- * Reads a numeric number value using the provided function.
- *
- * @typeparam T { number | bigint } The type of the value to be read
- *
- * @param func { Function(offset: number) => number } The function to read data on the internal Buffer with.
- * @param byteSize { Number } The number of bytes read.
- * @param offset { Number } The offset to read from (optional). When this is not provided, the managed readOffset is used instead.
- *
- * @returns { T } the number value
- */
- _readNumberValue(func, byteSize, offset) {
- this.ensureReadable(byteSize, offset);
- const value = func.call(this._buff, typeof offset === "number" ? offset : this._readOffset);
- if (typeof offset === "undefined") {
- this._readOffset += byteSize;
- }
- return value;
- }
- /**
- * Inserts a numeric number value based on the given offset and value.
- *
- * @typeparam T { number | bigint } The type of the value to be written
- *
- * @param func { Function(offset: T, offset?) => number} The function to write data on the internal Buffer with.
- * @param byteSize { Number } The number of bytes written.
- * @param value { T } The number value to write.
- * @param offset { Number } the offset to write the number at (REQUIRED).
- *
- * @returns SmartBuffer this buffer
- */
- _insertNumberValue(func, byteSize, value, offset) {
- utils_1.checkOffsetValue(offset);
- this.ensureInsertable(byteSize, offset);
- func.call(this._buff, value, offset);
- this._writeOffset += byteSize;
- return this;
- }
- /**
- * Writes a numeric number value based on the given offset and value.
- *
- * @typeparam T { number | bigint } The type of the value to be written
- *
- * @param func { Function(offset: T, offset?) => number} The function to write data on the internal Buffer with.
- * @param byteSize { Number } The number of bytes written.
- * @param value { T } The number value to write.
- * @param offset { Number } the offset to write the number at (REQUIRED).
- *
- * @returns SmartBuffer this buffer
- */
- _writeNumberValue(func, byteSize, value, offset) {
- if (typeof offset === "number") {
- if (offset < 0) {
- throw new Error(utils_1.ERRORS.INVALID_WRITE_BEYOND_BOUNDS);
- }
- utils_1.checkOffsetValue(offset);
- }
- const offsetVal = typeof offset === "number" ? offset : this._writeOffset;
- this._ensureWriteable(byteSize, offsetVal);
- func.call(this._buff, value, offsetVal);
- if (typeof offset === "number") {
- this._writeOffset = Math.max(this._writeOffset, offsetVal + byteSize);
- } else {
- this._writeOffset += byteSize;
- }
- return this;
- }
- };
- exports2.SmartBuffer = SmartBuffer;
- }
- });
- // node_modules/socks/build/common/constants.js
- var require_constants3 = __commonJS({
- "node_modules/socks/build/common/constants.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.SOCKS5_NO_ACCEPTABLE_AUTH = exports2.SOCKS5_CUSTOM_AUTH_END = exports2.SOCKS5_CUSTOM_AUTH_START = exports2.SOCKS_INCOMING_PACKET_SIZES = exports2.SocksClientState = exports2.Socks5Response = exports2.Socks5HostType = exports2.Socks5Auth = exports2.Socks4Response = exports2.SocksCommand = exports2.ERRORS = exports2.DEFAULT_TIMEOUT = void 0;
- var DEFAULT_TIMEOUT = 3e4;
- exports2.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
- var ERRORS = {
- InvalidSocksCommand: "An invalid SOCKS command was provided. Valid options are connect, bind, and associate.",
- InvalidSocksCommandForOperation: "An invalid SOCKS command was provided. Only a subset of commands are supported for this operation.",
- InvalidSocksCommandChain: "An invalid SOCKS command was provided. Chaining currently only supports the connect command.",
- InvalidSocksClientOptionsDestination: "An invalid destination host was provided.",
- InvalidSocksClientOptionsExistingSocket: "An invalid existing socket was provided. This should be an instance of stream.Duplex.",
- InvalidSocksClientOptionsProxy: "Invalid SOCKS proxy details were provided.",
- InvalidSocksClientOptionsTimeout: "An invalid timeout value was provided. Please enter a value above 0 (in ms).",
- InvalidSocksClientOptionsProxiesLength: "At least two socks proxies must be provided for chaining.",
- InvalidSocksClientOptionsCustomAuthRange: "Custom auth must be a value between 0x80 and 0xFE.",
- InvalidSocksClientOptionsCustomAuthOptions: "When a custom_auth_method is provided, custom_auth_request_handler, custom_auth_response_size, and custom_auth_response_handler must also be provided and valid.",
- NegotiationError: "Negotiation error",
- SocketClosed: "Socket closed",
- ProxyConnectionTimedOut: "Proxy connection timed out",
- InternalError: "SocksClient internal error (this should not happen)",
- InvalidSocks4HandshakeResponse: "Received invalid Socks4 handshake response",
- Socks4ProxyRejectedConnection: "Socks4 Proxy rejected connection",
- InvalidSocks4IncomingConnectionResponse: "Socks4 invalid incoming connection response",
- Socks4ProxyRejectedIncomingBoundConnection: "Socks4 Proxy rejected incoming bound connection",
- InvalidSocks5InitialHandshakeResponse: "Received invalid Socks5 initial handshake response",
- InvalidSocks5IntiailHandshakeSocksVersion: "Received invalid Socks5 initial handshake (invalid socks version)",
- InvalidSocks5InitialHandshakeNoAcceptedAuthType: "Received invalid Socks5 initial handshake (no accepted authentication type)",
- InvalidSocks5InitialHandshakeUnknownAuthType: "Received invalid Socks5 initial handshake (unknown authentication type)",
- Socks5AuthenticationFailed: "Socks5 Authentication failed",
- InvalidSocks5FinalHandshake: "Received invalid Socks5 final handshake response",
- InvalidSocks5FinalHandshakeRejected: "Socks5 proxy rejected connection",
- InvalidSocks5IncomingConnectionResponse: "Received invalid Socks5 incoming connection response",
- Socks5ProxyRejectedIncomingBoundConnection: "Socks5 Proxy rejected incoming bound connection"
- };
- exports2.ERRORS = ERRORS;
- var SOCKS_INCOMING_PACKET_SIZES = {
- Socks5InitialHandshakeResponse: 2,
- Socks5UserPassAuthenticationResponse: 2,
- // Command response + incoming connection (bind)
- Socks5ResponseHeader: 5,
- // We need at least 5 to read the hostname length, then we wait for the address+port information.
- Socks5ResponseIPv4: 10,
- // 4 header + 4 ip + 2 port
- Socks5ResponseIPv6: 22,
- // 4 header + 16 ip + 2 port
- Socks5ResponseHostname: (hostNameLength) => hostNameLength + 7,
- // 4 header + 1 host length + host + 2 port
- // Command response + incoming connection (bind)
- Socks4Response: 8
- // 2 header + 2 port + 4 ip
- };
- exports2.SOCKS_INCOMING_PACKET_SIZES = SOCKS_INCOMING_PACKET_SIZES;
- var SocksCommand;
- (function(SocksCommand2) {
- SocksCommand2[SocksCommand2["connect"] = 1] = "connect";
- SocksCommand2[SocksCommand2["bind"] = 2] = "bind";
- SocksCommand2[SocksCommand2["associate"] = 3] = "associate";
- })(SocksCommand || (exports2.SocksCommand = SocksCommand = {}));
- var Socks4Response;
- (function(Socks4Response2) {
- Socks4Response2[Socks4Response2["Granted"] = 90] = "Granted";
- Socks4Response2[Socks4Response2["Failed"] = 91] = "Failed";
- Socks4Response2[Socks4Response2["Rejected"] = 92] = "Rejected";
- Socks4Response2[Socks4Response2["RejectedIdent"] = 93] = "RejectedIdent";
- })(Socks4Response || (exports2.Socks4Response = Socks4Response = {}));
- var Socks5Auth;
- (function(Socks5Auth2) {
- Socks5Auth2[Socks5Auth2["NoAuth"] = 0] = "NoAuth";
- Socks5Auth2[Socks5Auth2["GSSApi"] = 1] = "GSSApi";
- Socks5Auth2[Socks5Auth2["UserPass"] = 2] = "UserPass";
- })(Socks5Auth || (exports2.Socks5Auth = Socks5Auth = {}));
- var SOCKS5_CUSTOM_AUTH_START = 128;
- exports2.SOCKS5_CUSTOM_AUTH_START = SOCKS5_CUSTOM_AUTH_START;
- var SOCKS5_CUSTOM_AUTH_END = 254;
- exports2.SOCKS5_CUSTOM_AUTH_END = SOCKS5_CUSTOM_AUTH_END;
- var SOCKS5_NO_ACCEPTABLE_AUTH = 255;
- exports2.SOCKS5_NO_ACCEPTABLE_AUTH = SOCKS5_NO_ACCEPTABLE_AUTH;
- var Socks5Response;
- (function(Socks5Response2) {
- Socks5Response2[Socks5Response2["Granted"] = 0] = "Granted";
- Socks5Response2[Socks5Response2["Failure"] = 1] = "Failure";
- Socks5Response2[Socks5Response2["NotAllowed"] = 2] = "NotAllowed";
- Socks5Response2[Socks5Response2["NetworkUnreachable"] = 3] = "NetworkUnreachable";
- Socks5Response2[Socks5Response2["HostUnreachable"] = 4] = "HostUnreachable";
- Socks5Response2[Socks5Response2["ConnectionRefused"] = 5] = "ConnectionRefused";
- Socks5Response2[Socks5Response2["TTLExpired"] = 6] = "TTLExpired";
- Socks5Response2[Socks5Response2["CommandNotSupported"] = 7] = "CommandNotSupported";
- Socks5Response2[Socks5Response2["AddressNotSupported"] = 8] = "AddressNotSupported";
- })(Socks5Response || (exports2.Socks5Response = Socks5Response = {}));
- var Socks5HostType;
- (function(Socks5HostType2) {
- Socks5HostType2[Socks5HostType2["IPv4"] = 1] = "IPv4";
- Socks5HostType2[Socks5HostType2["Hostname"] = 3] = "Hostname";
- Socks5HostType2[Socks5HostType2["IPv6"] = 4] = "IPv6";
- })(Socks5HostType || (exports2.Socks5HostType = Socks5HostType = {}));
- var SocksClientState;
- (function(SocksClientState2) {
- SocksClientState2[SocksClientState2["Created"] = 0] = "Created";
- SocksClientState2[SocksClientState2["Connecting"] = 1] = "Connecting";
- SocksClientState2[SocksClientState2["Connected"] = 2] = "Connected";
- SocksClientState2[SocksClientState2["SentInitialHandshake"] = 3] = "SentInitialHandshake";
- SocksClientState2[SocksClientState2["ReceivedInitialHandshakeResponse"] = 4] = "ReceivedInitialHandshakeResponse";
- SocksClientState2[SocksClientState2["SentAuthentication"] = 5] = "SentAuthentication";
- SocksClientState2[SocksClientState2["ReceivedAuthenticationResponse"] = 6] = "ReceivedAuthenticationResponse";
- SocksClientState2[SocksClientState2["SentFinalHandshake"] = 7] = "SentFinalHandshake";
- SocksClientState2[SocksClientState2["ReceivedFinalResponse"] = 8] = "ReceivedFinalResponse";
- SocksClientState2[SocksClientState2["BoundWaitingForConnection"] = 9] = "BoundWaitingForConnection";
- SocksClientState2[SocksClientState2["Established"] = 10] = "Established";
- SocksClientState2[SocksClientState2["Disconnected"] = 11] = "Disconnected";
- SocksClientState2[SocksClientState2["Error"] = 99] = "Error";
- })(SocksClientState || (exports2.SocksClientState = SocksClientState = {}));
- }
- });
- // node_modules/socks/build/common/util.js
- var require_util = __commonJS({
- "node_modules/socks/build/common/util.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.shuffleArray = exports2.SocksClientError = void 0;
- var SocksClientError = class extends Error {
- constructor(message, options) {
- super(message);
- this.options = options;
- }
- };
- exports2.SocksClientError = SocksClientError;
- function shuffleArray(array) {
- for (let i = array.length - 1; i > 0; i--) {
- const j = Math.floor(Math.random() * (i + 1));
- [array[i], array[j]] = [array[j], array[i]];
- }
- }
- exports2.shuffleArray = shuffleArray;
- }
- });
- // node_modules/ip-address/dist/common.js
- var require_common3 = __commonJS({
- "node_modules/ip-address/dist/common.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.isCorrect = exports2.isInSubnet = void 0;
- function isInSubnet(address) {
- if (this.subnetMask < address.subnetMask) {
- return false;
- }
- if (this.mask(address.subnetMask) === address.mask()) {
- return true;
- }
- return false;
- }
- exports2.isInSubnet = isInSubnet;
- function isCorrect(defaultBits) {
- return function() {
- if (this.addressMinusSuffix !== this.correctForm()) {
- return false;
- }
- if (this.subnetMask === defaultBits && !this.parsedSubnet) {
- return true;
- }
- return this.parsedSubnet === String(this.subnetMask);
- };
- }
- exports2.isCorrect = isCorrect;
- }
- });
- // node_modules/ip-address/dist/v4/constants.js
- var require_constants4 = __commonJS({
- "node_modules/ip-address/dist/v4/constants.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.RE_SUBNET_STRING = exports2.RE_ADDRESS = exports2.GROUPS = exports2.BITS = void 0;
- exports2.BITS = 32;
- exports2.GROUPS = 4;
- exports2.RE_ADDRESS = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g;
- exports2.RE_SUBNET_STRING = /\/\d{1,2}$/;
- }
- });
- // node_modules/ip-address/dist/address-error.js
- var require_address_error = __commonJS({
- "node_modules/ip-address/dist/address-error.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AddressError = void 0;
- var AddressError = class extends Error {
- constructor(message, parseMessage) {
- super(message);
- this.name = "AddressError";
- if (parseMessage !== null) {
- this.parseMessage = parseMessage;
- }
- }
- };
- exports2.AddressError = AddressError;
- }
- });
- // node_modules/jsbn/index.js
- var require_jsbn = __commonJS({
- "node_modules/jsbn/index.js"(exports2, module2) {
- (function() {
- var dbits;
- var canary = 244837814094590;
- var j_lm = (canary & 16777215) == 15715070;
- function BigInteger(a, b, c) {
- if (a != null)
- if ("number" == typeof a) this.fromNumber(a, b, c);
- else if (b == null && "string" != typeof a) this.fromString(a, 256);
- else this.fromString(a, b);
- }
- function nbi() {
- return new BigInteger(null);
- }
- function am1(i, x, w, j, c, n) {
- while (--n >= 0) {
- var v = x * this[i++] + w[j] + c;
- c = Math.floor(v / 67108864);
- w[j++] = v & 67108863;
- }
- return c;
- }
- function am2(i, x, w, j, c, n) {
- var xl = x & 32767, xh = x >> 15;
- while (--n >= 0) {
- var l = this[i] & 32767;
- var h = this[i++] >> 15;
- var m = xh * l + h * xl;
- l = xl * l + ((m & 32767) << 15) + w[j] + (c & 1073741823);
- c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
- w[j++] = l & 1073741823;
- }
- return c;
- }
- function am3(i, x, w, j, c, n) {
- var xl = x & 16383, xh = x >> 14;
- while (--n >= 0) {
- var l = this[i] & 16383;
- var h = this[i++] >> 14;
- var m = xh * l + h * xl;
- l = xl * l + ((m & 16383) << 14) + w[j] + c;
- c = (l >> 28) + (m >> 14) + xh * h;
- w[j++] = l & 268435455;
- }
- return c;
- }
- var inBrowser = typeof navigator !== "undefined";
- if (inBrowser && j_lm && navigator.appName == "Microsoft Internet Explorer") {
- BigInteger.prototype.am = am2;
- dbits = 30;
- } else if (inBrowser && j_lm && navigator.appName != "Netscape") {
- BigInteger.prototype.am = am1;
- dbits = 26;
- } else {
- BigInteger.prototype.am = am3;
- dbits = 28;
- }
- BigInteger.prototype.DB = dbits;
- BigInteger.prototype.DM = (1 << dbits) - 1;
- BigInteger.prototype.DV = 1 << dbits;
- var BI_FP = 52;
- BigInteger.prototype.FV = Math.pow(2, BI_FP);
- BigInteger.prototype.F1 = BI_FP - dbits;
- BigInteger.prototype.F2 = 2 * dbits - BI_FP;
- var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
- var BI_RC = new Array();
- var rr, vv;
- rr = "0".charCodeAt(0);
- for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
- rr = "a".charCodeAt(0);
- for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
- rr = "A".charCodeAt(0);
- for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
- function int2char(n) {
- return BI_RM.charAt(n);
- }
- function intAt(s, i) {
- var c = BI_RC[s.charCodeAt(i)];
- return c == null ? -1 : c;
- }
- function bnpCopyTo(r) {
- for (var i = this.t - 1; i >= 0; --i) r[i] = this[i];
- r.t = this.t;
- r.s = this.s;
- }
- function bnpFromInt(x) {
- this.t = 1;
- this.s = x < 0 ? -1 : 0;
- if (x > 0) this[0] = x;
- else if (x < -1) this[0] = x + this.DV;
- else this.t = 0;
- }
- function nbv(i) {
- var r = nbi();
- r.fromInt(i);
- return r;
- }
- function bnpFromString(s, b) {
- var k;
- if (b == 16) k = 4;
- else if (b == 8) k = 3;
- else if (b == 256) k = 8;
- else if (b == 2) k = 1;
- else if (b == 32) k = 5;
- else if (b == 4) k = 2;
- else {
- this.fromRadix(s, b);
- return;
- }
- this.t = 0;
- this.s = 0;
- var i = s.length, mi = false, sh = 0;
- while (--i >= 0) {
- var x = k == 8 ? s[i] & 255 : intAt(s, i);
- if (x < 0) {
- if (s.charAt(i) == "-") mi = true;
- continue;
- }
- mi = false;
- if (sh == 0)
- this[this.t++] = x;
- else if (sh + k > this.DB) {
- this[this.t - 1] |= (x & (1 << this.DB - sh) - 1) << sh;
- this[this.t++] = x >> this.DB - sh;
- } else
- this[this.t - 1] |= x << sh;
- sh += k;
- if (sh >= this.DB) sh -= this.DB;
- }
- if (k == 8 && (s[0] & 128) != 0) {
- this.s = -1;
- if (sh > 0) this[this.t - 1] |= (1 << this.DB - sh) - 1 << sh;
- }
- this.clamp();
- if (mi) BigInteger.ZERO.subTo(this, this);
- }
- function bnpClamp() {
- var c = this.s & this.DM;
- while (this.t > 0 && this[this.t - 1] == c) --this.t;
- }
- function bnToString(b) {
- if (this.s < 0) return "-" + this.negate().toString(b);
- var k;
- if (b == 16) k = 4;
- else if (b == 8) k = 3;
- else if (b == 2) k = 1;
- else if (b == 32) k = 5;
- else if (b == 4) k = 2;
- else return this.toRadix(b);
- var km = (1 << k) - 1, d, m = false, r = "", i = this.t;
- var p = this.DB - i * this.DB % k;
- if (i-- > 0) {
- if (p < this.DB && (d = this[i] >> p) > 0) {
- m = true;
- r = int2char(d);
- }
- while (i >= 0) {
- if (p < k) {
- d = (this[i] & (1 << p) - 1) << k - p;
- d |= this[--i] >> (p += this.DB - k);
- } else {
- d = this[i] >> (p -= k) & km;
- if (p <= 0) {
- p += this.DB;
- --i;
- }
- }
- if (d > 0) m = true;
- if (m) r += int2char(d);
- }
- }
- return m ? r : "0";
- }
- function bnNegate() {
- var r = nbi();
- BigInteger.ZERO.subTo(this, r);
- return r;
- }
- function bnAbs() {
- return this.s < 0 ? this.negate() : this;
- }
- function bnCompareTo(a) {
- var r = this.s - a.s;
- if (r != 0) return r;
- var i = this.t;
- r = i - a.t;
- if (r != 0) return this.s < 0 ? -r : r;
- while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r;
- return 0;
- }
- function nbits(x) {
- var r = 1, t2;
- if ((t2 = x >>> 16) != 0) {
- x = t2;
- r += 16;
- }
- if ((t2 = x >> 8) != 0) {
- x = t2;
- r += 8;
- }
- if ((t2 = x >> 4) != 0) {
- x = t2;
- r += 4;
- }
- if ((t2 = x >> 2) != 0) {
- x = t2;
- r += 2;
- }
- if ((t2 = x >> 1) != 0) {
- x = t2;
- r += 1;
- }
- return r;
- }
- function bnBitLength() {
- if (this.t <= 0) return 0;
- return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);
- }
- function bnpDLShiftTo(n, r) {
- var i;
- for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i];
- for (i = n - 1; i >= 0; --i) r[i] = 0;
- r.t = this.t + n;
- r.s = this.s;
- }
- function bnpDRShiftTo(n, r) {
- for (var i = n; i < this.t; ++i) r[i - n] = this[i];
- r.t = Math.max(this.t - n, 0);
- r.s = this.s;
- }
- function bnpLShiftTo(n, r) {
- var bs = n % this.DB;
- var cbs = this.DB - bs;
- var bm = (1 << cbs) - 1;
- var ds = Math.floor(n / this.DB), c = this.s << bs & this.DM, i;
- for (i = this.t - 1; i >= 0; --i) {
- r[i + ds + 1] = this[i] >> cbs | c;
- c = (this[i] & bm) << bs;
- }
- for (i = ds - 1; i >= 0; --i) r[i] = 0;
- r[ds] = c;
- r.t = this.t + ds + 1;
- r.s = this.s;
- r.clamp();
- }
- function bnpRShiftTo(n, r) {
- r.s = this.s;
- var ds = Math.floor(n / this.DB);
- if (ds >= this.t) {
- r.t = 0;
- return;
- }
- var bs = n % this.DB;
- var cbs = this.DB - bs;
- var bm = (1 << bs) - 1;
- r[0] = this[ds] >> bs;
- for (var i = ds + 1; i < this.t; ++i) {
- r[i - ds - 1] |= (this[i] & bm) << cbs;
- r[i - ds] = this[i] >> bs;
- }
- if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;
- r.t = this.t - ds;
- r.clamp();
- }
- function bnpSubTo(a, r) {
- var i = 0, c = 0, m = Math.min(a.t, this.t);
- while (i < m) {
- c += this[i] - a[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- if (a.t < this.t) {
- c -= a.s;
- while (i < this.t) {
- c += this[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- c += this.s;
- } else {
- c += this.s;
- while (i < a.t) {
- c -= a[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- c -= a.s;
- }
- r.s = c < 0 ? -1 : 0;
- if (c < -1) r[i++] = this.DV + c;
- else if (c > 0) r[i++] = c;
- r.t = i;
- r.clamp();
- }
- function bnpMultiplyTo(a, r) {
- var x = this.abs(), y = a.abs();
- var i = x.t;
- r.t = i + y.t;
- while (--i >= 0) r[i] = 0;
- for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
- r.s = 0;
- r.clamp();
- if (this.s != a.s) BigInteger.ZERO.subTo(r, r);
- }
- function bnpSquareTo(r) {
- var x = this.abs();
- var i = r.t = 2 * x.t;
- while (--i >= 0) r[i] = 0;
- for (i = 0; i < x.t - 1; ++i) {
- var c = x.am(i, x[i], r, 2 * i, 0, 1);
- if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
- r[i + x.t] -= x.DV;
- r[i + x.t + 1] = 1;
- }
- }
- if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
- r.s = 0;
- r.clamp();
- }
- function bnpDivRemTo(m, q, r) {
- var pm = m.abs();
- if (pm.t <= 0) return;
- var pt = this.abs();
- if (pt.t < pm.t) {
- if (q != null) q.fromInt(0);
- if (r != null) this.copyTo(r);
- return;
- }
- if (r == null) r = nbi();
- var y = nbi(), ts = this.s, ms = m.s;
- var nsh = this.DB - nbits(pm[pm.t - 1]);
- if (nsh > 0) {
- pm.lShiftTo(nsh, y);
- pt.lShiftTo(nsh, r);
- } else {
- pm.copyTo(y);
- pt.copyTo(r);
- }
- var ys = y.t;
- var y0 = y[ys - 1];
- if (y0 == 0) return;
- var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0);
- var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;
- var i = r.t, j = i - ys, t2 = q == null ? nbi() : q;
- y.dlShiftTo(j, t2);
- if (r.compareTo(t2) >= 0) {
- r[r.t++] = 1;
- r.subTo(t2, r);
- }
- BigInteger.ONE.dlShiftTo(ys, t2);
- t2.subTo(y, y);
- while (y.t < ys) y[y.t++] = 0;
- while (--j >= 0) {
- var qd = r[--i] == y0 ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
- if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {
- y.dlShiftTo(j, t2);
- r.subTo(t2, r);
- while (r[i] < --qd) r.subTo(t2, r);
- }
- }
- if (q != null) {
- r.drShiftTo(ys, q);
- if (ts != ms) BigInteger.ZERO.subTo(q, q);
- }
- r.t = ys;
- r.clamp();
- if (nsh > 0) r.rShiftTo(nsh, r);
- if (ts < 0) BigInteger.ZERO.subTo(r, r);
- }
- function bnMod(a) {
- var r = nbi();
- this.abs().divRemTo(a, null, r);
- if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);
- return r;
- }
- function Classic(m) {
- this.m = m;
- }
- function cConvert(x) {
- if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
- else return x;
- }
- function cRevert(x) {
- return x;
- }
- function cReduce(x) {
- x.divRemTo(this.m, null, x);
- }
- function cMulTo(x, y, r) {
- x.multiplyTo(y, r);
- this.reduce(r);
- }
- function cSqrTo(x, r) {
- x.squareTo(r);
- this.reduce(r);
- }
- Classic.prototype.convert = cConvert;
- Classic.prototype.revert = cRevert;
- Classic.prototype.reduce = cReduce;
- Classic.prototype.mulTo = cMulTo;
- Classic.prototype.sqrTo = cSqrTo;
- function bnpInvDigit() {
- if (this.t < 1) return 0;
- var x = this[0];
- if ((x & 1) == 0) return 0;
- var y = x & 3;
- y = y * (2 - (x & 15) * y) & 15;
- y = y * (2 - (x & 255) * y) & 255;
- y = y * (2 - ((x & 65535) * y & 65535)) & 65535;
- y = y * (2 - x * y % this.DV) % this.DV;
- return y > 0 ? this.DV - y : -y;
- }
- function Montgomery(m) {
- this.m = m;
- this.mp = m.invDigit();
- this.mpl = this.mp & 32767;
- this.mph = this.mp >> 15;
- this.um = (1 << m.DB - 15) - 1;
- this.mt2 = 2 * m.t;
- }
- function montConvert(x) {
- var r = nbi();
- x.abs().dlShiftTo(this.m.t, r);
- r.divRemTo(this.m, null, r);
- if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);
- return r;
- }
- function montRevert(x) {
- var r = nbi();
- x.copyTo(r);
- this.reduce(r);
- return r;
- }
- function montReduce(x) {
- while (x.t <= this.mt2)
- x[x.t++] = 0;
- for (var i = 0; i < this.m.t; ++i) {
- var j = x[i] & 32767;
- var u0 = j * this.mpl + ((j * this.mph + (x[i] >> 15) * this.mpl & this.um) << 15) & x.DM;
- j = i + this.m.t;
- x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
- while (x[j] >= x.DV) {
- x[j] -= x.DV;
- x[++j]++;
- }
- }
- x.clamp();
- x.drShiftTo(this.m.t, x);
- if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
- }
- function montSqrTo(x, r) {
- x.squareTo(r);
- this.reduce(r);
- }
- function montMulTo(x, y, r) {
- x.multiplyTo(y, r);
- this.reduce(r);
- }
- Montgomery.prototype.convert = montConvert;
- Montgomery.prototype.revert = montRevert;
- Montgomery.prototype.reduce = montReduce;
- Montgomery.prototype.mulTo = montMulTo;
- Montgomery.prototype.sqrTo = montSqrTo;
- function bnpIsEven() {
- return (this.t > 0 ? this[0] & 1 : this.s) == 0;
- }
- function bnpExp(e, z2) {
- if (e > 4294967295 || e < 1) return BigInteger.ONE;
- var r = nbi(), r2 = nbi(), g = z2.convert(this), i = nbits(e) - 1;
- g.copyTo(r);
- while (--i >= 0) {
- z2.sqrTo(r, r2);
- if ((e & 1 << i) > 0) z2.mulTo(r2, g, r);
- else {
- var t2 = r;
- r = r2;
- r2 = t2;
- }
- }
- return z2.revert(r);
- }
- function bnModPowInt(e, m) {
- var z2;
- if (e < 256 || m.isEven()) z2 = new Classic(m);
- else z2 = new Montgomery(m);
- return this.exp(e, z2);
- }
- BigInteger.prototype.copyTo = bnpCopyTo;
- BigInteger.prototype.fromInt = bnpFromInt;
- BigInteger.prototype.fromString = bnpFromString;
- BigInteger.prototype.clamp = bnpClamp;
- BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
- BigInteger.prototype.drShiftTo = bnpDRShiftTo;
- BigInteger.prototype.lShiftTo = bnpLShiftTo;
- BigInteger.prototype.rShiftTo = bnpRShiftTo;
- BigInteger.prototype.subTo = bnpSubTo;
- BigInteger.prototype.multiplyTo = bnpMultiplyTo;
- BigInteger.prototype.squareTo = bnpSquareTo;
- BigInteger.prototype.divRemTo = bnpDivRemTo;
- BigInteger.prototype.invDigit = bnpInvDigit;
- BigInteger.prototype.isEven = bnpIsEven;
- BigInteger.prototype.exp = bnpExp;
- BigInteger.prototype.toString = bnToString;
- BigInteger.prototype.negate = bnNegate;
- BigInteger.prototype.abs = bnAbs;
- BigInteger.prototype.compareTo = bnCompareTo;
- BigInteger.prototype.bitLength = bnBitLength;
- BigInteger.prototype.mod = bnMod;
- BigInteger.prototype.modPowInt = bnModPowInt;
- BigInteger.ZERO = nbv(0);
- BigInteger.ONE = nbv(1);
- function bnClone() {
- var r = nbi();
- this.copyTo(r);
- return r;
- }
- function bnIntValue() {
- if (this.s < 0) {
- if (this.t == 1) return this[0] - this.DV;
- else if (this.t == 0) return -1;
- } else if (this.t == 1) return this[0];
- else if (this.t == 0) return 0;
- return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0];
- }
- function bnByteValue() {
- return this.t == 0 ? this.s : this[0] << 24 >> 24;
- }
- function bnShortValue() {
- return this.t == 0 ? this.s : this[0] << 16 >> 16;
- }
- function bnpChunkSize(r) {
- return Math.floor(Math.LN2 * this.DB / Math.log(r));
- }
- function bnSigNum() {
- if (this.s < 0) return -1;
- else if (this.t <= 0 || this.t == 1 && this[0] <= 0) return 0;
- else return 1;
- }
- function bnpToRadix(b) {
- if (b == null) b = 10;
- if (this.signum() == 0 || b < 2 || b > 36) return "0";
- var cs = this.chunkSize(b);
- var a = Math.pow(b, cs);
- var d = nbv(a), y = nbi(), z2 = nbi(), r = "";
- this.divRemTo(d, y, z2);
- while (y.signum() > 0) {
- r = (a + z2.intValue()).toString(b).substr(1) + r;
- y.divRemTo(d, y, z2);
- }
- return z2.intValue().toString(b) + r;
- }
- function bnpFromRadix(s, b) {
- this.fromInt(0);
- if (b == null) b = 10;
- var cs = this.chunkSize(b);
- var d = Math.pow(b, cs), mi = false, j = 0, w = 0;
- for (var i = 0; i < s.length; ++i) {
- var x = intAt(s, i);
- if (x < 0) {
- if (s.charAt(i) == "-" && this.signum() == 0) mi = true;
- continue;
- }
- w = b * w + x;
- if (++j >= cs) {
- this.dMultiply(d);
- this.dAddOffset(w, 0);
- j = 0;
- w = 0;
- }
- }
- if (j > 0) {
- this.dMultiply(Math.pow(b, j));
- this.dAddOffset(w, 0);
- }
- if (mi) BigInteger.ZERO.subTo(this, this);
- }
- function bnpFromNumber(a, b, c) {
- if ("number" == typeof b) {
- if (a < 2) this.fromInt(1);
- else {
- this.fromNumber(a, c);
- if (!this.testBit(a - 1))
- this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
- if (this.isEven()) this.dAddOffset(1, 0);
- while (!this.isProbablePrime(b)) {
- this.dAddOffset(2, 0);
- if (this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
- }
- }
- } else {
- var x = new Array(), t2 = a & 7;
- x.length = (a >> 3) + 1;
- b.nextBytes(x);
- if (t2 > 0) x[0] &= (1 << t2) - 1;
- else x[0] = 0;
- this.fromString(x, 256);
- }
- }
- function bnToByteArray() {
- var i = this.t, r = new Array();
- r[0] = this.s;
- var p = this.DB - i * this.DB % 8, d, k = 0;
- if (i-- > 0) {
- if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p)
- r[k++] = d | this.s << this.DB - p;
- while (i >= 0) {
- if (p < 8) {
- d = (this[i] & (1 << p) - 1) << 8 - p;
- d |= this[--i] >> (p += this.DB - 8);
- } else {
- d = this[i] >> (p -= 8) & 255;
- if (p <= 0) {
- p += this.DB;
- --i;
- }
- }
- if ((d & 128) != 0) d |= -256;
- if (k == 0 && (this.s & 128) != (d & 128)) ++k;
- if (k > 0 || d != this.s) r[k++] = d;
- }
- }
- return r;
- }
- function bnEquals(a) {
- return this.compareTo(a) == 0;
- }
- function bnMin(a) {
- return this.compareTo(a) < 0 ? this : a;
- }
- function bnMax(a) {
- return this.compareTo(a) > 0 ? this : a;
- }
- function bnpBitwiseTo(a, op, r) {
- var i, f, m = Math.min(a.t, this.t);
- for (i = 0; i < m; ++i) r[i] = op(this[i], a[i]);
- if (a.t < this.t) {
- f = a.s & this.DM;
- for (i = m; i < this.t; ++i) r[i] = op(this[i], f);
- r.t = this.t;
- } else {
- f = this.s & this.DM;
- for (i = m; i < a.t; ++i) r[i] = op(f, a[i]);
- r.t = a.t;
- }
- r.s = op(this.s, a.s);
- r.clamp();
- }
- function op_and(x, y) {
- return x & y;
- }
- function bnAnd(a) {
- var r = nbi();
- this.bitwiseTo(a, op_and, r);
- return r;
- }
- function op_or(x, y) {
- return x | y;
- }
- function bnOr(a) {
- var r = nbi();
- this.bitwiseTo(a, op_or, r);
- return r;
- }
- function op_xor(x, y) {
- return x ^ y;
- }
- function bnXor(a) {
- var r = nbi();
- this.bitwiseTo(a, op_xor, r);
- return r;
- }
- function op_andnot(x, y) {
- return x & ~y;
- }
- function bnAndNot(a) {
- var r = nbi();
- this.bitwiseTo(a, op_andnot, r);
- return r;
- }
- function bnNot() {
- var r = nbi();
- for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i];
- r.t = this.t;
- r.s = ~this.s;
- return r;
- }
- function bnShiftLeft(n) {
- var r = nbi();
- if (n < 0) this.rShiftTo(-n, r);
- else this.lShiftTo(n, r);
- return r;
- }
- function bnShiftRight(n) {
- var r = nbi();
- if (n < 0) this.lShiftTo(-n, r);
- else this.rShiftTo(n, r);
- return r;
- }
- function lbit(x) {
- if (x == 0) return -1;
- var r = 0;
- if ((x & 65535) == 0) {
- x >>= 16;
- r += 16;
- }
- if ((x & 255) == 0) {
- x >>= 8;
- r += 8;
- }
- if ((x & 15) == 0) {
- x >>= 4;
- r += 4;
- }
- if ((x & 3) == 0) {
- x >>= 2;
- r += 2;
- }
- if ((x & 1) == 0) ++r;
- return r;
- }
- function bnGetLowestSetBit() {
- for (var i = 0; i < this.t; ++i)
- if (this[i] != 0) return i * this.DB + lbit(this[i]);
- if (this.s < 0) return this.t * this.DB;
- return -1;
- }
- function cbit(x) {
- var r = 0;
- while (x != 0) {
- x &= x - 1;
- ++r;
- }
- return r;
- }
- function bnBitCount() {
- var r = 0, x = this.s & this.DM;
- for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x);
- return r;
- }
- function bnTestBit(n) {
- var j = Math.floor(n / this.DB);
- if (j >= this.t) return this.s != 0;
- return (this[j] & 1 << n % this.DB) != 0;
- }
- function bnpChangeBit(n, op) {
- var r = BigInteger.ONE.shiftLeft(n);
- this.bitwiseTo(r, op, r);
- return r;
- }
- function bnSetBit(n) {
- return this.changeBit(n, op_or);
- }
- function bnClearBit(n) {
- return this.changeBit(n, op_andnot);
- }
- function bnFlipBit(n) {
- return this.changeBit(n, op_xor);
- }
- function bnpAddTo(a, r) {
- var i = 0, c = 0, m = Math.min(a.t, this.t);
- while (i < m) {
- c += this[i] + a[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- if (a.t < this.t) {
- c += a.s;
- while (i < this.t) {
- c += this[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- c += this.s;
- } else {
- c += this.s;
- while (i < a.t) {
- c += a[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- c += a.s;
- }
- r.s = c < 0 ? -1 : 0;
- if (c > 0) r[i++] = c;
- else if (c < -1) r[i++] = this.DV + c;
- r.t = i;
- r.clamp();
- }
- function bnAdd(a) {
- var r = nbi();
- this.addTo(a, r);
- return r;
- }
- function bnSubtract(a) {
- var r = nbi();
- this.subTo(a, r);
- return r;
- }
- function bnMultiply(a) {
- var r = nbi();
- this.multiplyTo(a, r);
- return r;
- }
- function bnSquare() {
- var r = nbi();
- this.squareTo(r);
- return r;
- }
- function bnDivide(a) {
- var r = nbi();
- this.divRemTo(a, r, null);
- return r;
- }
- function bnRemainder(a) {
- var r = nbi();
- this.divRemTo(a, null, r);
- return r;
- }
- function bnDivideAndRemainder(a) {
- var q = nbi(), r = nbi();
- this.divRemTo(a, q, r);
- return new Array(q, r);
- }
- function bnpDMultiply(n) {
- this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
- ++this.t;
- this.clamp();
- }
- function bnpDAddOffset(n, w) {
- if (n == 0) return;
- while (this.t <= w) this[this.t++] = 0;
- this[w] += n;
- while (this[w] >= this.DV) {
- this[w] -= this.DV;
- if (++w >= this.t) this[this.t++] = 0;
- ++this[w];
- }
- }
- function NullExp() {
- }
- function nNop(x) {
- return x;
- }
- function nMulTo(x, y, r) {
- x.multiplyTo(y, r);
- }
- function nSqrTo(x, r) {
- x.squareTo(r);
- }
- NullExp.prototype.convert = nNop;
- NullExp.prototype.revert = nNop;
- NullExp.prototype.mulTo = nMulTo;
- NullExp.prototype.sqrTo = nSqrTo;
- function bnPow(e) {
- return this.exp(e, new NullExp());
- }
- function bnpMultiplyLowerTo(a, n, r) {
- var i = Math.min(this.t + a.t, n);
- r.s = 0;
- r.t = i;
- while (i > 0) r[--i] = 0;
- var j;
- for (j = r.t - this.t; i < j; ++i) r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
- for (j = Math.min(a.t, n); i < j; ++i) this.am(0, a[i], r, i, 0, n - i);
- r.clamp();
- }
- function bnpMultiplyUpperTo(a, n, r) {
- --n;
- var i = r.t = this.t + a.t - n;
- r.s = 0;
- while (--i >= 0) r[i] = 0;
- for (i = Math.max(n - this.t, 0); i < a.t; ++i)
- r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
- r.clamp();
- r.drShiftTo(1, r);
- }
- function Barrett(m) {
- this.r2 = nbi();
- this.q3 = nbi();
- BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
- this.mu = this.r2.divide(m);
- this.m = m;
- }
- function barrettConvert(x) {
- if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m);
- else if (x.compareTo(this.m) < 0) return x;
- else {
- var r = nbi();
- x.copyTo(r);
- this.reduce(r);
- return r;
- }
- }
- function barrettRevert(x) {
- return x;
- }
- function barrettReduce(x) {
- x.drShiftTo(this.m.t - 1, this.r2);
- if (x.t > this.m.t + 1) {
- x.t = this.m.t + 1;
- x.clamp();
- }
- this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
- this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
- while (x.compareTo(this.r2) < 0) x.dAddOffset(1, this.m.t + 1);
- x.subTo(this.r2, x);
- while (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
- }
- function barrettSqrTo(x, r) {
- x.squareTo(r);
- this.reduce(r);
- }
- function barrettMulTo(x, y, r) {
- x.multiplyTo(y, r);
- this.reduce(r);
- }
- Barrett.prototype.convert = barrettConvert;
- Barrett.prototype.revert = barrettRevert;
- Barrett.prototype.reduce = barrettReduce;
- Barrett.prototype.mulTo = barrettMulTo;
- Barrett.prototype.sqrTo = barrettSqrTo;
- function bnModPow(e, m) {
- var i = e.bitLength(), k, r = nbv(1), z2;
- if (i <= 0) return r;
- else if (i < 18) k = 1;
- else if (i < 48) k = 3;
- else if (i < 144) k = 4;
- else if (i < 768) k = 5;
- else k = 6;
- if (i < 8)
- z2 = new Classic(m);
- else if (m.isEven())
- z2 = new Barrett(m);
- else
- z2 = new Montgomery(m);
- var g = new Array(), n = 3, k1 = k - 1, km = (1 << k) - 1;
- g[1] = z2.convert(this);
- if (k > 1) {
- var g2 = nbi();
- z2.sqrTo(g[1], g2);
- while (n <= km) {
- g[n] = nbi();
- z2.mulTo(g2, g[n - 2], g[n]);
- n += 2;
- }
- }
- var j = e.t - 1, w, is1 = true, r2 = nbi(), t2;
- i = nbits(e[j]) - 1;
- while (j >= 0) {
- if (i >= k1) w = e[j] >> i - k1 & km;
- else {
- w = (e[j] & (1 << i + 1) - 1) << k1 - i;
- if (j > 0) w |= e[j - 1] >> this.DB + i - k1;
- }
- n = k;
- while ((w & 1) == 0) {
- w >>= 1;
- --n;
- }
- if ((i -= n) < 0) {
- i += this.DB;
- --j;
- }
- if (is1) {
- g[w].copyTo(r);
- is1 = false;
- } else {
- while (n > 1) {
- z2.sqrTo(r, r2);
- z2.sqrTo(r2, r);
- n -= 2;
- }
- if (n > 0) z2.sqrTo(r, r2);
- else {
- t2 = r;
- r = r2;
- r2 = t2;
- }
- z2.mulTo(r2, g[w], r);
- }
- while (j >= 0 && (e[j] & 1 << i) == 0) {
- z2.sqrTo(r, r2);
- t2 = r;
- r = r2;
- r2 = t2;
- if (--i < 0) {
- i = this.DB - 1;
- --j;
- }
- }
- }
- return z2.revert(r);
- }
- function bnGCD(a) {
- var x = this.s < 0 ? this.negate() : this.clone();
- var y = a.s < 0 ? a.negate() : a.clone();
- if (x.compareTo(y) < 0) {
- var t2 = x;
- x = y;
- y = t2;
- }
- var i = x.getLowestSetBit(), g = y.getLowestSetBit();
- if (g < 0) return x;
- if (i < g) g = i;
- if (g > 0) {
- x.rShiftTo(g, x);
- y.rShiftTo(g, y);
- }
- while (x.signum() > 0) {
- if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x);
- if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y);
- if (x.compareTo(y) >= 0) {
- x.subTo(y, x);
- x.rShiftTo(1, x);
- } else {
- y.subTo(x, y);
- y.rShiftTo(1, y);
- }
- }
- if (g > 0) y.lShiftTo(g, y);
- return y;
- }
- function bnpModInt(n) {
- if (n <= 0) return 0;
- var d = this.DV % n, r = this.s < 0 ? n - 1 : 0;
- if (this.t > 0)
- if (d == 0) r = this[0] % n;
- else for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n;
- return r;
- }
- function bnModInverse(m) {
- var ac = m.isEven();
- if (this.isEven() && ac || m.signum() == 0) return BigInteger.ZERO;
- var u = m.clone(), v = this.clone();
- var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
- while (u.signum() != 0) {
- while (u.isEven()) {
- u.rShiftTo(1, u);
- if (ac) {
- if (!a.isEven() || !b.isEven()) {
- a.addTo(this, a);
- b.subTo(m, b);
- }
- a.rShiftTo(1, a);
- } else if (!b.isEven()) b.subTo(m, b);
- b.rShiftTo(1, b);
- }
- while (v.isEven()) {
- v.rShiftTo(1, v);
- if (ac) {
- if (!c.isEven() || !d.isEven()) {
- c.addTo(this, c);
- d.subTo(m, d);
- }
- c.rShiftTo(1, c);
- } else if (!d.isEven()) d.subTo(m, d);
- d.rShiftTo(1, d);
- }
- if (u.compareTo(v) >= 0) {
- u.subTo(v, u);
- if (ac) a.subTo(c, a);
- b.subTo(d, b);
- } else {
- v.subTo(u, v);
- if (ac) c.subTo(a, c);
- d.subTo(b, d);
- }
- }
- if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
- if (d.compareTo(m) >= 0) return d.subtract(m);
- if (d.signum() < 0) d.addTo(m, d);
- else return d;
- if (d.signum() < 0) return d.add(m);
- else return d;
- }
- var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
- var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
- function bnIsProbablePrime(t2) {
- var i, x = this.abs();
- if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
- for (i = 0; i < lowprimes.length; ++i)
- if (x[0] == lowprimes[i]) return true;
- return false;
- }
- if (x.isEven()) return false;
- i = 1;
- while (i < lowprimes.length) {
- var m = lowprimes[i], j = i + 1;
- while (j < lowprimes.length && m < lplim) m *= lowprimes[j++];
- m = x.modInt(m);
- while (i < j) if (m % lowprimes[i++] == 0) return false;
- }
- return x.millerRabin(t2);
- }
- function bnpMillerRabin(t2) {
- var n1 = this.subtract(BigInteger.ONE);
- var k = n1.getLowestSetBit();
- if (k <= 0) return false;
- var r = n1.shiftRight(k);
- t2 = t2 + 1 >> 1;
- if (t2 > lowprimes.length) t2 = lowprimes.length;
- var a = nbi();
- for (var i = 0; i < t2; ++i) {
- a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
- var y = a.modPow(r, this);
- if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
- var j = 1;
- while (j++ < k && y.compareTo(n1) != 0) {
- y = y.modPowInt(2, this);
- if (y.compareTo(BigInteger.ONE) == 0) return false;
- }
- if (y.compareTo(n1) != 0) return false;
- }
- }
- return true;
- }
- BigInteger.prototype.chunkSize = bnpChunkSize;
- BigInteger.prototype.toRadix = bnpToRadix;
- BigInteger.prototype.fromRadix = bnpFromRadix;
- BigInteger.prototype.fromNumber = bnpFromNumber;
- BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
- BigInteger.prototype.changeBit = bnpChangeBit;
- BigInteger.prototype.addTo = bnpAddTo;
- BigInteger.prototype.dMultiply = bnpDMultiply;
- BigInteger.prototype.dAddOffset = bnpDAddOffset;
- BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
- BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
- BigInteger.prototype.modInt = bnpModInt;
- BigInteger.prototype.millerRabin = bnpMillerRabin;
- BigInteger.prototype.clone = bnClone;
- BigInteger.prototype.intValue = bnIntValue;
- BigInteger.prototype.byteValue = bnByteValue;
- BigInteger.prototype.shortValue = bnShortValue;
- BigInteger.prototype.signum = bnSigNum;
- BigInteger.prototype.toByteArray = bnToByteArray;
- BigInteger.prototype.equals = bnEquals;
- BigInteger.prototype.min = bnMin;
- BigInteger.prototype.max = bnMax;
- BigInteger.prototype.and = bnAnd;
- BigInteger.prototype.or = bnOr;
- BigInteger.prototype.xor = bnXor;
- BigInteger.prototype.andNot = bnAndNot;
- BigInteger.prototype.not = bnNot;
- BigInteger.prototype.shiftLeft = bnShiftLeft;
- BigInteger.prototype.shiftRight = bnShiftRight;
- BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
- BigInteger.prototype.bitCount = bnBitCount;
- BigInteger.prototype.testBit = bnTestBit;
- BigInteger.prototype.setBit = bnSetBit;
- BigInteger.prototype.clearBit = bnClearBit;
- BigInteger.prototype.flipBit = bnFlipBit;
- BigInteger.prototype.add = bnAdd;
- BigInteger.prototype.subtract = bnSubtract;
- BigInteger.prototype.multiply = bnMultiply;
- BigInteger.prototype.divide = bnDivide;
- BigInteger.prototype.remainder = bnRemainder;
- BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
- BigInteger.prototype.modPow = bnModPow;
- BigInteger.prototype.modInverse = bnModInverse;
- BigInteger.prototype.pow = bnPow;
- BigInteger.prototype.gcd = bnGCD;
- BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
- BigInteger.prototype.square = bnSquare;
- BigInteger.prototype.Barrett = Barrett;
- var rng_state;
- var rng_pool;
- var rng_pptr;
- function rng_seed_int(x) {
- rng_pool[rng_pptr++] ^= x & 255;
- rng_pool[rng_pptr++] ^= x >> 8 & 255;
- rng_pool[rng_pptr++] ^= x >> 16 & 255;
- rng_pool[rng_pptr++] ^= x >> 24 & 255;
- if (rng_pptr >= rng_psize) rng_pptr -= rng_psize;
- }
- function rng_seed_time() {
- rng_seed_int((/* @__PURE__ */ new Date()).getTime());
- }
- if (rng_pool == null) {
- rng_pool = new Array();
- rng_pptr = 0;
- var t;
- if (typeof window !== "undefined" && window.crypto) {
- if (window.crypto.getRandomValues) {
- var ua = new Uint8Array(32);
- window.crypto.getRandomValues(ua);
- for (t = 0; t < 32; ++t)
- rng_pool[rng_pptr++] = ua[t];
- } else if (navigator.appName == "Netscape" && navigator.appVersion < "5") {
- var z = window.crypto.random(32);
- for (t = 0; t < z.length; ++t)
- rng_pool[rng_pptr++] = z.charCodeAt(t) & 255;
- }
- }
- while (rng_pptr < rng_psize) {
- t = Math.floor(65536 * Math.random());
- rng_pool[rng_pptr++] = t >>> 8;
- rng_pool[rng_pptr++] = t & 255;
- }
- rng_pptr = 0;
- rng_seed_time();
- }
- function rng_get_byte() {
- if (rng_state == null) {
- rng_seed_time();
- rng_state = prng_newstate();
- rng_state.init(rng_pool);
- for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr)
- rng_pool[rng_pptr] = 0;
- rng_pptr = 0;
- }
- return rng_state.next();
- }
- function rng_get_bytes(ba) {
- var i;
- for (i = 0; i < ba.length; ++i) ba[i] = rng_get_byte();
- }
- function SecureRandom() {
- }
- SecureRandom.prototype.nextBytes = rng_get_bytes;
- function Arcfour() {
- this.i = 0;
- this.j = 0;
- this.S = new Array();
- }
- function ARC4init(key) {
- var i, j, t2;
- for (i = 0; i < 256; ++i)
- this.S[i] = i;
- j = 0;
- for (i = 0; i < 256; ++i) {
- j = j + this.S[i] + key[i % key.length] & 255;
- t2 = this.S[i];
- this.S[i] = this.S[j];
- this.S[j] = t2;
- }
- this.i = 0;
- this.j = 0;
- }
- function ARC4next() {
- var t2;
- this.i = this.i + 1 & 255;
- this.j = this.j + this.S[this.i] & 255;
- t2 = this.S[this.i];
- this.S[this.i] = this.S[this.j];
- this.S[this.j] = t2;
- return this.S[t2 + this.S[this.i] & 255];
- }
- Arcfour.prototype.init = ARC4init;
- Arcfour.prototype.next = ARC4next;
- function prng_newstate() {
- return new Arcfour();
- }
- var rng_psize = 256;
- if (typeof exports2 !== "undefined") {
- exports2 = module2.exports = {
- default: BigInteger,
- BigInteger,
- SecureRandom
- };
- } else {
- this.jsbn = {
- BigInteger,
- SecureRandom
- };
- }
- }).call(exports2);
- }
- });
- // node_modules/sprintf-js/src/sprintf.js
- var require_sprintf = __commonJS({
- "node_modules/sprintf-js/src/sprintf.js"(exports2) {
- !function() {
- "use strict";
- var re = {
- not_string: /[^s]/,
- not_bool: /[^t]/,
- not_type: /[^T]/,
- not_primitive: /[^v]/,
- number: /[diefg]/,
- numeric_arg: /[bcdiefguxX]/,
- json: /[j]/,
- not_json: /[^j]/,
- text: /^[^\x25]+/,
- modulo: /^\x25{2}/,
- placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
- key: /^([a-z_][a-z_\d]*)/i,
- key_access: /^\.([a-z_][a-z_\d]*)/i,
- index_access: /^\[(\d+)\]/,
- sign: /^[+-]/
- };
- function sprintf(key) {
- return sprintf_format(sprintf_parse(key), arguments);
- }
- function vsprintf(fmt, argv) {
- return sprintf.apply(null, [fmt].concat(argv || []));
- }
- function sprintf_format(parse_tree, argv) {
- var cursor = 1, tree_length = parse_tree.length, arg, output = "", i, k, ph, pad, pad_character, pad_length, is_positive, sign;
- for (i = 0; i < tree_length; i++) {
- if (typeof parse_tree[i] === "string") {
- output += parse_tree[i];
- } else if (typeof parse_tree[i] === "object") {
- ph = parse_tree[i];
- if (ph.keys) {
- arg = argv[cursor];
- for (k = 0; k < ph.keys.length; k++) {
- if (arg == void 0) {
- throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k - 1]));
- }
- arg = arg[ph.keys[k]];
- }
- } else if (ph.param_no) {
- arg = argv[ph.param_no];
- } else {
- arg = argv[cursor++];
- }
- if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {
- arg = arg();
- }
- if (re.numeric_arg.test(ph.type) && (typeof arg !== "number" && isNaN(arg))) {
- throw new TypeError(sprintf("[sprintf] expecting number but found %T", arg));
- }
- if (re.number.test(ph.type)) {
- is_positive = arg >= 0;
- }
- switch (ph.type) {
- case "b":
- arg = parseInt(arg, 10).toString(2);
- break;
- case "c":
- arg = String.fromCharCode(parseInt(arg, 10));
- break;
- case "d":
- case "i":
- arg = parseInt(arg, 10);
- break;
- case "j":
- arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0);
- break;
- case "e":
- arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential();
- break;
- case "f":
- arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg);
- break;
- case "g":
- arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg);
- break;
- case "o":
- arg = (parseInt(arg, 10) >>> 0).toString(8);
- break;
- case "s":
- arg = String(arg);
- arg = ph.precision ? arg.substring(0, ph.precision) : arg;
- break;
- case "t":
- arg = String(!!arg);
- arg = ph.precision ? arg.substring(0, ph.precision) : arg;
- break;
- case "T":
- arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase();
- arg = ph.precision ? arg.substring(0, ph.precision) : arg;
- break;
- case "u":
- arg = parseInt(arg, 10) >>> 0;
- break;
- case "v":
- arg = arg.valueOf();
- arg = ph.precision ? arg.substring(0, ph.precision) : arg;
- break;
- case "x":
- arg = (parseInt(arg, 10) >>> 0).toString(16);
- break;
- case "X":
- arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase();
- break;
- }
- if (re.json.test(ph.type)) {
- output += arg;
- } else {
- if (re.number.test(ph.type) && (!is_positive || ph.sign)) {
- sign = is_positive ? "+" : "-";
- arg = arg.toString().replace(re.sign, "");
- } else {
- sign = "";
- }
- pad_character = ph.pad_char ? ph.pad_char === "0" ? "0" : ph.pad_char.charAt(1) : " ";
- pad_length = ph.width - (sign + arg).length;
- pad = ph.width ? pad_length > 0 ? pad_character.repeat(pad_length) : "" : "";
- output += ph.align ? sign + arg + pad : pad_character === "0" ? sign + pad + arg : pad + sign + arg;
- }
- }
- }
- return output;
- }
- var sprintf_cache = /* @__PURE__ */ Object.create(null);
- function sprintf_parse(fmt) {
- if (sprintf_cache[fmt]) {
- return sprintf_cache[fmt];
- }
- var _fmt = fmt, match, parse_tree = [], arg_names = 0;
- while (_fmt) {
- if ((match = re.text.exec(_fmt)) !== null) {
- parse_tree.push(match[0]);
- } else if ((match = re.modulo.exec(_fmt)) !== null) {
- parse_tree.push("%");
- } else if ((match = re.placeholder.exec(_fmt)) !== null) {
- if (match[2]) {
- arg_names |= 1;
- var field_list = [], replacement_field = match[2], field_match = [];
- if ((field_match = re.key.exec(replacement_field)) !== null) {
- field_list.push(field_match[1]);
- while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") {
- if ((field_match = re.key_access.exec(replacement_field)) !== null) {
- field_list.push(field_match[1]);
- } else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
- field_list.push(field_match[1]);
- } else {
- throw new SyntaxError("[sprintf] failed to parse named argument key");
- }
- }
- } else {
- throw new SyntaxError("[sprintf] failed to parse named argument key");
- }
- match[2] = field_list;
- } else {
- arg_names |= 2;
- }
- if (arg_names === 3) {
- throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");
- }
- parse_tree.push(
- {
- placeholder: match[0],
- param_no: match[1],
- keys: match[2],
- sign: match[3],
- pad_char: match[4],
- align: match[5],
- width: match[6],
- precision: match[7],
- type: match[8]
- }
- );
- } else {
- throw new SyntaxError("[sprintf] unexpected placeholder");
- }
- _fmt = _fmt.substring(match[0].length);
- }
- return sprintf_cache[fmt] = parse_tree;
- }
- if (typeof exports2 !== "undefined") {
- exports2["sprintf"] = sprintf;
- exports2["vsprintf"] = vsprintf;
- }
- if (typeof window !== "undefined") {
- window["sprintf"] = sprintf;
- window["vsprintf"] = vsprintf;
- if (typeof define === "function" && define["amd"]) {
- define(function() {
- return {
- "sprintf": sprintf,
- "vsprintf": vsprintf
- };
- });
- }
- }
- }();
- }
- });
- // node_modules/ip-address/dist/ipv4.js
- var require_ipv4 = __commonJS({
- "node_modules/ip-address/dist/ipv4.js"(exports2) {
- "use strict";
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() {
- return m[k];
- } };
- }
- Object.defineProperty(o, k2, desc);
- } : function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- o[k2] = m[k];
- });
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- } : function(o, v) {
- o["default"] = v;
- });
- var __importStar = exports2 && exports2.__importStar || function(mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) {
- for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- }
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.Address4 = void 0;
- var common = __importStar(require_common3());
- var constants = __importStar(require_constants4());
- var address_error_1 = require_address_error();
- var jsbn_1 = require_jsbn();
- var sprintf_js_1 = require_sprintf();
- var Address4 = class _Address4 {
- constructor(address) {
- this.groups = constants.GROUPS;
- this.parsedAddress = [];
- this.parsedSubnet = "";
- this.subnet = "/32";
- this.subnetMask = 32;
- this.v4 = true;
- this.isCorrect = common.isCorrect(constants.BITS);
- this.isInSubnet = common.isInSubnet;
- this.address = address;
- const subnet = constants.RE_SUBNET_STRING.exec(address);
- if (subnet) {
- this.parsedSubnet = subnet[0].replace("/", "");
- this.subnetMask = parseInt(this.parsedSubnet, 10);
- this.subnet = `/${this.subnetMask}`;
- if (this.subnetMask < 0 || this.subnetMask > constants.BITS) {
- throw new address_error_1.AddressError("Invalid subnet mask.");
- }
- address = address.replace(constants.RE_SUBNET_STRING, "");
- }
- this.addressMinusSuffix = address;
- this.parsedAddress = this.parse(address);
- }
- static isValid(address) {
- try {
- new _Address4(address);
- return true;
- } catch (e) {
- return false;
- }
- }
- /*
- * Parses a v4 address
- */
- parse(address) {
- const groups = address.split(".");
- if (!address.match(constants.RE_ADDRESS)) {
- throw new address_error_1.AddressError("Invalid IPv4 address.");
- }
- return groups;
- }
- /**
- * Returns the correct form of an address
- * @memberof Address4
- * @instance
- * @returns {String}
- */
- correctForm() {
- return this.parsedAddress.map((part) => parseInt(part, 10)).join(".");
- }
- /**
- * Converts a hex string to an IPv4 address object
- * @memberof Address4
- * @static
- * @param {string} hex - a hex string to convert
- * @returns {Address4}
- */
- static fromHex(hex) {
- const padded = hex.replace(/:/g, "").padStart(8, "0");
- const groups = [];
- let i;
- for (i = 0; i < 8; i += 2) {
- const h = padded.slice(i, i + 2);
- groups.push(parseInt(h, 16));
- }
- return new _Address4(groups.join("."));
- }
- /**
- * Converts an integer into a IPv4 address object
- * @memberof Address4
- * @static
- * @param {integer} integer - a number to convert
- * @returns {Address4}
- */
- static fromInteger(integer) {
- return _Address4.fromHex(integer.toString(16));
- }
- /**
- * Return an address from in-addr.arpa form
- * @memberof Address4
- * @static
- * @param {string} arpaFormAddress - an 'in-addr.arpa' form ipv4 address
- * @returns {Adress4}
- * @example
- * var address = Address4.fromArpa(42.2.0.192.in-addr.arpa.)
- * address.correctForm(); // '192.0.2.42'
- */
- static fromArpa(arpaFormAddress) {
- const leader = arpaFormAddress.replace(/(\.in-addr\.arpa)?\.$/, "");
- const address = leader.split(".").reverse().join(".");
- return new _Address4(address);
- }
- /**
- * Converts an IPv4 address object to a hex string
- * @memberof Address4
- * @instance
- * @returns {String}
- */
- toHex() {
- return this.parsedAddress.map((part) => (0, sprintf_js_1.sprintf)("%02x", parseInt(part, 10))).join(":");
- }
- /**
- * Converts an IPv4 address object to an array of bytes
- * @memberof Address4
- * @instance
- * @returns {Array}
- */
- toArray() {
- return this.parsedAddress.map((part) => parseInt(part, 10));
- }
- /**
- * Converts an IPv4 address object to an IPv6 address group
- * @memberof Address4
- * @instance
- * @returns {String}
- */
- toGroup6() {
- const output = [];
- let i;
- for (i = 0; i < constants.GROUPS; i += 2) {
- const hex = (0, sprintf_js_1.sprintf)("%02x%02x", parseInt(this.parsedAddress[i], 10), parseInt(this.parsedAddress[i + 1], 10));
- output.push((0, sprintf_js_1.sprintf)("%x", parseInt(hex, 16)));
- }
- return output.join(":");
- }
- /**
- * Returns the address as a BigInteger
- * @memberof Address4
- * @instance
- * @returns {BigInteger}
- */
- bigInteger() {
- return new jsbn_1.BigInteger(this.parsedAddress.map((n) => (0, sprintf_js_1.sprintf)("%02x", parseInt(n, 10))).join(""), 16);
- }
- /**
- * Helper function getting start address.
- * @memberof Address4
- * @instance
- * @returns {BigInteger}
- */
- _startAddress() {
- return new jsbn_1.BigInteger(this.mask() + "0".repeat(constants.BITS - this.subnetMask), 2);
- }
- /**
- * The first address in the range given by this address' subnet.
- * Often referred to as the Network Address.
- * @memberof Address4
- * @instance
- * @returns {Address4}
- */
- startAddress() {
- return _Address4.fromBigInteger(this._startAddress());
- }
- /**
- * The first host address in the range given by this address's subnet ie
- * the first address after the Network Address
- * @memberof Address4
- * @instance
- * @returns {Address4}
- */
- startAddressExclusive() {
- const adjust = new jsbn_1.BigInteger("1");
- return _Address4.fromBigInteger(this._startAddress().add(adjust));
- }
- /**
- * Helper function getting end address.
- * @memberof Address4
- * @instance
- * @returns {BigInteger}
- */
- _endAddress() {
- return new jsbn_1.BigInteger(this.mask() + "1".repeat(constants.BITS - this.subnetMask), 2);
- }
- /**
- * The last address in the range given by this address' subnet
- * Often referred to as the Broadcast
- * @memberof Address4
- * @instance
- * @returns {Address4}
- */
- endAddress() {
- return _Address4.fromBigInteger(this._endAddress());
- }
- /**
- * The last host address in the range given by this address's subnet ie
- * the last address prior to the Broadcast Address
- * @memberof Address4
- * @instance
- * @returns {Address4}
- */
- endAddressExclusive() {
- const adjust = new jsbn_1.BigInteger("1");
- return _Address4.fromBigInteger(this._endAddress().subtract(adjust));
- }
- /**
- * Converts a BigInteger to a v4 address object
- * @memberof Address4
- * @static
- * @param {BigInteger} bigInteger - a BigInteger to convert
- * @returns {Address4}
- */
- static fromBigInteger(bigInteger) {
- return _Address4.fromInteger(parseInt(bigInteger.toString(), 10));
- }
- /**
- * Returns the first n bits of the address, defaulting to the
- * subnet mask
- * @memberof Address4
- * @instance
- * @returns {String}
- */
- mask(mask) {
- if (mask === void 0) {
- mask = this.subnetMask;
- }
- return this.getBitsBase2(0, mask);
- }
- /**
- * Returns the bits in the given range as a base-2 string
- * @memberof Address4
- * @instance
- * @returns {string}
- */
- getBitsBase2(start, end) {
- return this.binaryZeroPad().slice(start, end);
- }
- /**
- * Return the reversed ip6.arpa form of the address
- * @memberof Address4
- * @param {Object} options
- * @param {boolean} options.omitSuffix - omit the "in-addr.arpa" suffix
- * @instance
- * @returns {String}
- */
- reverseForm(options) {
- if (!options) {
- options = {};
- }
- const reversed = this.correctForm().split(".").reverse().join(".");
- if (options.omitSuffix) {
- return reversed;
- }
- return (0, sprintf_js_1.sprintf)("%s.in-addr.arpa.", reversed);
- }
- /**
- * Returns true if the given address is a multicast address
- * @memberof Address4
- * @instance
- * @returns {boolean}
- */
- isMulticast() {
- return this.isInSubnet(new _Address4("224.0.0.0/4"));
- }
- /**
- * Returns a zero-padded base-2 string representation of the address
- * @memberof Address4
- * @instance
- * @returns {string}
- */
- binaryZeroPad() {
- return this.bigInteger().toString(2).padStart(constants.BITS, "0");
- }
- /**
- * Groups an IPv4 address for inclusion at the end of an IPv6 address
- * @returns {String}
- */
- groupForV6() {
- const segments = this.parsedAddress;
- return this.address.replace(constants.RE_ADDRESS, (0, sprintf_js_1.sprintf)('<span class="hover-group group-v4 group-6">%s</span>.<span class="hover-group group-v4 group-7">%s</span>', segments.slice(0, 2).join("."), segments.slice(2, 4).join(".")));
- }
- };
- exports2.Address4 = Address4;
- }
- });
- // node_modules/ip-address/dist/v6/constants.js
- var require_constants5 = __commonJS({
- "node_modules/ip-address/dist/v6/constants.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.RE_URL_WITH_PORT = exports2.RE_URL = exports2.RE_ZONE_STRING = exports2.RE_SUBNET_STRING = exports2.RE_BAD_ADDRESS = exports2.RE_BAD_CHARACTERS = exports2.TYPES = exports2.SCOPES = exports2.GROUPS = exports2.BITS = void 0;
- exports2.BITS = 128;
- exports2.GROUPS = 8;
- exports2.SCOPES = {
- 0: "Reserved",
- 1: "Interface local",
- 2: "Link local",
- 4: "Admin local",
- 5: "Site local",
- 8: "Organization local",
- 14: "Global",
- 15: "Reserved"
- };
- exports2.TYPES = {
- "ff01::1/128": "Multicast (All nodes on this interface)",
- "ff01::2/128": "Multicast (All routers on this interface)",
- "ff02::1/128": "Multicast (All nodes on this link)",
- "ff02::2/128": "Multicast (All routers on this link)",
- "ff05::2/128": "Multicast (All routers in this site)",
- "ff02::5/128": "Multicast (OSPFv3 AllSPF routers)",
- "ff02::6/128": "Multicast (OSPFv3 AllDR routers)",
- "ff02::9/128": "Multicast (RIP routers)",
- "ff02::a/128": "Multicast (EIGRP routers)",
- "ff02::d/128": "Multicast (PIM routers)",
- "ff02::16/128": "Multicast (MLDv2 reports)",
- "ff01::fb/128": "Multicast (mDNSv6)",
- "ff02::fb/128": "Multicast (mDNSv6)",
- "ff05::fb/128": "Multicast (mDNSv6)",
- "ff02::1:2/128": "Multicast (All DHCP servers and relay agents on this link)",
- "ff05::1:2/128": "Multicast (All DHCP servers and relay agents in this site)",
- "ff02::1:3/128": "Multicast (All DHCP servers on this link)",
- "ff05::1:3/128": "Multicast (All DHCP servers in this site)",
- "::/128": "Unspecified",
- "::1/128": "Loopback",
- "ff00::/8": "Multicast",
- "fe80::/10": "Link-local unicast"
- };
- exports2.RE_BAD_CHARACTERS = /([^0-9a-f:/%])/gi;
- exports2.RE_BAD_ADDRESS = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;
- exports2.RE_SUBNET_STRING = /\/\d{1,3}(?=%|$)/;
- exports2.RE_ZONE_STRING = /%.*$/;
- exports2.RE_URL = new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);
- exports2.RE_URL_WITH_PORT = new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);
- }
- });
- // node_modules/ip-address/dist/v6/helpers.js
- var require_helpers = __commonJS({
- "node_modules/ip-address/dist/v6/helpers.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.simpleGroup = exports2.spanLeadingZeroes = exports2.spanAll = exports2.spanAllZeroes = void 0;
- var sprintf_js_1 = require_sprintf();
- function spanAllZeroes(s) {
- return s.replace(/(0+)/g, '<span class="zero">$1</span>');
- }
- exports2.spanAllZeroes = spanAllZeroes;
- function spanAll(s, offset = 0) {
- const letters = s.split("");
- return letters.map(
- (n, i) => (0, sprintf_js_1.sprintf)('<span class="digit value-%s position-%d">%s</span>', n, i + offset, spanAllZeroes(n))
- // XXX Use #base-2 .value-0 instead?
- ).join("");
- }
- exports2.spanAll = spanAll;
- function spanLeadingZeroesSimple(group) {
- return group.replace(/^(0+)/, '<span class="zero">$1</span>');
- }
- function spanLeadingZeroes(address) {
- const groups = address.split(":");
- return groups.map((g) => spanLeadingZeroesSimple(g)).join(":");
- }
- exports2.spanLeadingZeroes = spanLeadingZeroes;
- function simpleGroup(addressString, offset = 0) {
- const groups = addressString.split(":");
- return groups.map((g, i) => {
- if (/group-v4/.test(g)) {
- return g;
- }
- return (0, sprintf_js_1.sprintf)('<span class="hover-group group-%d">%s</span>', i + offset, spanLeadingZeroesSimple(g));
- });
- }
- exports2.simpleGroup = simpleGroup;
- }
- });
- // node_modules/ip-address/dist/v6/regular-expressions.js
- var require_regular_expressions = __commonJS({
- "node_modules/ip-address/dist/v6/regular-expressions.js"(exports2) {
- "use strict";
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() {
- return m[k];
- } };
- }
- Object.defineProperty(o, k2, desc);
- } : function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- o[k2] = m[k];
- });
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- } : function(o, v) {
- o["default"] = v;
- });
- var __importStar = exports2 && exports2.__importStar || function(mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) {
- for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- }
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.possibleElisions = exports2.simpleRegularExpression = exports2.ADDRESS_BOUNDARY = exports2.padGroup = exports2.groupPossibilities = void 0;
- var v6 = __importStar(require_constants5());
- var sprintf_js_1 = require_sprintf();
- function groupPossibilities(possibilities) {
- return (0, sprintf_js_1.sprintf)("(%s)", possibilities.join("|"));
- }
- exports2.groupPossibilities = groupPossibilities;
- function padGroup(group) {
- if (group.length < 4) {
- return (0, sprintf_js_1.sprintf)("0{0,%d}%s", 4 - group.length, group);
- }
- return group;
- }
- exports2.padGroup = padGroup;
- exports2.ADDRESS_BOUNDARY = "[^A-Fa-f0-9:]";
- function simpleRegularExpression(groups) {
- const zeroIndexes = [];
- groups.forEach((group, i) => {
- const groupInteger = parseInt(group, 16);
- if (groupInteger === 0) {
- zeroIndexes.push(i);
- }
- });
- const possibilities = zeroIndexes.map((zeroIndex) => groups.map((group, i) => {
- if (i === zeroIndex) {
- const elision = i === 0 || i === v6.GROUPS - 1 ? ":" : "";
- return groupPossibilities([padGroup(group), elision]);
- }
- return padGroup(group);
- }).join(":"));
- possibilities.push(groups.map(padGroup).join(":"));
- return groupPossibilities(possibilities);
- }
- exports2.simpleRegularExpression = simpleRegularExpression;
- function possibleElisions(elidedGroups, moreLeft, moreRight) {
- const left = moreLeft ? "" : ":";
- const right = moreRight ? "" : ":";
- const possibilities = [];
- if (!moreLeft && !moreRight) {
- possibilities.push("::");
- }
- if (moreLeft && moreRight) {
- possibilities.push("");
- }
- if (moreRight && !moreLeft || !moreRight && moreLeft) {
- possibilities.push(":");
- }
- possibilities.push((0, sprintf_js_1.sprintf)("%s(:0{1,4}){1,%d}", left, elidedGroups - 1));
- possibilities.push((0, sprintf_js_1.sprintf)("(0{1,4}:){1,%d}%s", elidedGroups - 1, right));
- possibilities.push((0, sprintf_js_1.sprintf)("(0{1,4}:){%d}0{1,4}", elidedGroups - 1));
- for (let groups = 1; groups < elidedGroups - 1; groups++) {
- for (let position = 1; position < elidedGroups - groups; position++) {
- possibilities.push((0, sprintf_js_1.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}", position, elidedGroups - position - groups - 1));
- }
- }
- return groupPossibilities(possibilities);
- }
- exports2.possibleElisions = possibleElisions;
- }
- });
- // node_modules/ip-address/dist/ipv6.js
- var require_ipv6 = __commonJS({
- "node_modules/ip-address/dist/ipv6.js"(exports2) {
- "use strict";
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() {
- return m[k];
- } };
- }
- Object.defineProperty(o, k2, desc);
- } : function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- o[k2] = m[k];
- });
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- } : function(o, v) {
- o["default"] = v;
- });
- var __importStar = exports2 && exports2.__importStar || function(mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) {
- for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- }
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.Address6 = void 0;
- var common = __importStar(require_common3());
- var constants4 = __importStar(require_constants4());
- var constants6 = __importStar(require_constants5());
- var helpers = __importStar(require_helpers());
- var ipv4_1 = require_ipv4();
- var regular_expressions_1 = require_regular_expressions();
- var address_error_1 = require_address_error();
- var jsbn_1 = require_jsbn();
- var sprintf_js_1 = require_sprintf();
- function assert(condition) {
- if (!condition) {
- throw new Error("Assertion failed.");
- }
- }
- function addCommas(number) {
- const r = /(\d+)(\d{3})/;
- while (r.test(number)) {
- number = number.replace(r, "$1,$2");
- }
- return number;
- }
- function spanLeadingZeroes4(n) {
- n = n.replace(/^(0{1,})([1-9]+)$/, '<span class="parse-error">$1</span>$2');
- n = n.replace(/^(0{1,})(0)$/, '<span class="parse-error">$1</span>$2');
- return n;
- }
- function compact(address, slice) {
- const s1 = [];
- const s2 = [];
- let i;
- for (i = 0; i < address.length; i++) {
- if (i < slice[0]) {
- s1.push(address[i]);
- } else if (i > slice[1]) {
- s2.push(address[i]);
- }
- }
- return s1.concat(["compact"]).concat(s2);
- }
- function paddedHex(octet) {
- return (0, sprintf_js_1.sprintf)("%04x", parseInt(octet, 16));
- }
- function unsignByte(b) {
- return b & 255;
- }
- var Address6 = class _Address6 {
- constructor(address, optionalGroups) {
- this.addressMinusSuffix = "";
- this.parsedSubnet = "";
- this.subnet = "/128";
- this.subnetMask = 128;
- this.v4 = false;
- this.zone = "";
- this.isInSubnet = common.isInSubnet;
- this.isCorrect = common.isCorrect(constants6.BITS);
- if (optionalGroups === void 0) {
- this.groups = constants6.GROUPS;
- } else {
- this.groups = optionalGroups;
- }
- this.address = address;
- const subnet = constants6.RE_SUBNET_STRING.exec(address);
- if (subnet) {
- this.parsedSubnet = subnet[0].replace("/", "");
- this.subnetMask = parseInt(this.parsedSubnet, 10);
- this.subnet = `/${this.subnetMask}`;
- if (Number.isNaN(this.subnetMask) || this.subnetMask < 0 || this.subnetMask > constants6.BITS) {
- throw new address_error_1.AddressError("Invalid subnet mask.");
- }
- address = address.replace(constants6.RE_SUBNET_STRING, "");
- } else if (/\//.test(address)) {
- throw new address_error_1.AddressError("Invalid subnet mask.");
- }
- const zone = constants6.RE_ZONE_STRING.exec(address);
- if (zone) {
- this.zone = zone[0];
- address = address.replace(constants6.RE_ZONE_STRING, "");
- }
- this.addressMinusSuffix = address;
- this.parsedAddress = this.parse(this.addressMinusSuffix);
- }
- static isValid(address) {
- try {
- new _Address6(address);
- return true;
- } catch (e) {
- return false;
- }
- }
- /**
- * Convert a BigInteger to a v6 address object
- * @memberof Address6
- * @static
- * @param {BigInteger} bigInteger - a BigInteger to convert
- * @returns {Address6}
- * @example
- * var bigInteger = new BigInteger('1000000000000');
- * var address = Address6.fromBigInteger(bigInteger);
- * address.correctForm(); // '::e8:d4a5:1000'
- */
- static fromBigInteger(bigInteger) {
- const hex = bigInteger.toString(16).padStart(32, "0");
- const groups = [];
- let i;
- for (i = 0; i < constants6.GROUPS; i++) {
- groups.push(hex.slice(i * 4, (i + 1) * 4));
- }
- return new _Address6(groups.join(":"));
- }
- /**
- * Convert a URL (with optional port number) to an address object
- * @memberof Address6
- * @static
- * @param {string} url - a URL with optional port number
- * @example
- * var addressAndPort = Address6.fromURL('http://[ffff::]:8080/foo/');
- * addressAndPort.address.correctForm(); // 'ffff::'
- * addressAndPort.port; // 8080
- */
- static fromURL(url) {
- let host;
- let port = null;
- let result;
- if (url.indexOf("[") !== -1 && url.indexOf("]:") !== -1) {
- result = constants6.RE_URL_WITH_PORT.exec(url);
- if (result === null) {
- return {
- error: "failed to parse address with port",
- address: null,
- port: null
- };
- }
- host = result[1];
- port = result[2];
- } else if (url.indexOf("/") !== -1) {
- url = url.replace(/^[a-z0-9]+:\/\//, "");
- result = constants6.RE_URL.exec(url);
- if (result === null) {
- return {
- error: "failed to parse address from URL",
- address: null,
- port: null
- };
- }
- host = result[1];
- } else {
- host = url;
- }
- if (port) {
- port = parseInt(port, 10);
- if (port < 0 || port > 65536) {
- port = null;
- }
- } else {
- port = null;
- }
- return {
- address: new _Address6(host),
- port
- };
- }
- /**
- * Create an IPv6-mapped address given an IPv4 address
- * @memberof Address6
- * @static
- * @param {string} address - An IPv4 address string
- * @returns {Address6}
- * @example
- * var address = Address6.fromAddress4('192.168.0.1');
- * address.correctForm(); // '::ffff:c0a8:1'
- * address.to4in6(); // '::ffff:192.168.0.1'
- */
- static fromAddress4(address) {
- const address4 = new ipv4_1.Address4(address);
- const mask6 = constants6.BITS - (constants4.BITS - address4.subnetMask);
- return new _Address6(`::ffff:${address4.correctForm()}/${mask6}`);
- }
- /**
- * Return an address from ip6.arpa form
- * @memberof Address6
- * @static
- * @param {string} arpaFormAddress - an 'ip6.arpa' form address
- * @returns {Adress6}
- * @example
- * var address = Address6.fromArpa(e.f.f.f.3.c.2.6.f.f.f.e.6.6.8.e.1.0.6.7.9.4.e.c.0.0.0.0.1.0.0.2.ip6.arpa.)
- * address.correctForm(); // '2001:0:ce49:7601:e866:efff:62c3:fffe'
- */
- static fromArpa(arpaFormAddress) {
- let address = arpaFormAddress.replace(/(\.ip6\.arpa)?\.$/, "");
- const semicolonAmount = 7;
- if (address.length !== 63) {
- throw new address_error_1.AddressError("Invalid 'ip6.arpa' form.");
- }
- const parts = address.split(".").reverse();
- for (let i = semicolonAmount; i > 0; i--) {
- const insertIndex = i * 4;
- parts.splice(insertIndex, 0, ":");
- }
- address = parts.join("");
- return new _Address6(address);
- }
- /**
- * Return the Microsoft UNC transcription of the address
- * @memberof Address6
- * @instance
- * @returns {String} the Microsoft UNC transcription of the address
- */
- microsoftTranscription() {
- return (0, sprintf_js_1.sprintf)("%s.ipv6-literal.net", this.correctForm().replace(/:/g, "-"));
- }
- /**
- * Return the first n bits of the address, defaulting to the subnet mask
- * @memberof Address6
- * @instance
- * @param {number} [mask=subnet] - the number of bits to mask
- * @returns {String} the first n bits of the address as a string
- */
- mask(mask = this.subnetMask) {
- return this.getBitsBase2(0, mask);
- }
- /**
- * Return the number of possible subnets of a given size in the address
- * @memberof Address6
- * @instance
- * @param {number} [size=128] - the subnet size
- * @returns {String}
- */
- // TODO: probably useful to have a numeric version of this too
- possibleSubnets(subnetSize = 128) {
- const availableBits = constants6.BITS - this.subnetMask;
- const subnetBits = Math.abs(subnetSize - constants6.BITS);
- const subnetPowers = availableBits - subnetBits;
- if (subnetPowers < 0) {
- return "0";
- }
- return addCommas(new jsbn_1.BigInteger("2", 10).pow(subnetPowers).toString(10));
- }
- /**
- * Helper function getting start address.
- * @memberof Address6
- * @instance
- * @returns {BigInteger}
- */
- _startAddress() {
- return new jsbn_1.BigInteger(this.mask() + "0".repeat(constants6.BITS - this.subnetMask), 2);
- }
- /**
- * The first address in the range given by this address' subnet
- * Often referred to as the Network Address.
- * @memberof Address6
- * @instance
- * @returns {Address6}
- */
- startAddress() {
- return _Address6.fromBigInteger(this._startAddress());
- }
- /**
- * The first host address in the range given by this address's subnet ie
- * the first address after the Network Address
- * @memberof Address6
- * @instance
- * @returns {Address6}
- */
- startAddressExclusive() {
- const adjust = new jsbn_1.BigInteger("1");
- return _Address6.fromBigInteger(this._startAddress().add(adjust));
- }
- /**
- * Helper function getting end address.
- * @memberof Address6
- * @instance
- * @returns {BigInteger}
- */
- _endAddress() {
- return new jsbn_1.BigInteger(this.mask() + "1".repeat(constants6.BITS - this.subnetMask), 2);
- }
- /**
- * The last address in the range given by this address' subnet
- * Often referred to as the Broadcast
- * @memberof Address6
- * @instance
- * @returns {Address6}
- */
- endAddress() {
- return _Address6.fromBigInteger(this._endAddress());
- }
- /**
- * The last host address in the range given by this address's subnet ie
- * the last address prior to the Broadcast Address
- * @memberof Address6
- * @instance
- * @returns {Address6}
- */
- endAddressExclusive() {
- const adjust = new jsbn_1.BigInteger("1");
- return _Address6.fromBigInteger(this._endAddress().subtract(adjust));
- }
- /**
- * Return the scope of the address
- * @memberof Address6
- * @instance
- * @returns {String}
- */
- getScope() {
- let scope = constants6.SCOPES[this.getBits(12, 16).intValue()];
- if (this.getType() === "Global unicast" && scope !== "Link local") {
- scope = "Global";
- }
- return scope || "Unknown";
- }
- /**
- * Return the type of the address
- * @memberof Address6
- * @instance
- * @returns {String}
- */
- getType() {
- for (const subnet of Object.keys(constants6.TYPES)) {
- if (this.isInSubnet(new _Address6(subnet))) {
- return constants6.TYPES[subnet];
- }
- }
- return "Global unicast";
- }
- /**
- * Return the bits in the given range as a BigInteger
- * @memberof Address6
- * @instance
- * @returns {BigInteger}
- */
- getBits(start, end) {
- return new jsbn_1.BigInteger(this.getBitsBase2(start, end), 2);
- }
- /**
- * Return the bits in the given range as a base-2 string
- * @memberof Address6
- * @instance
- * @returns {String}
- */
- getBitsBase2(start, end) {
- return this.binaryZeroPad().slice(start, end);
- }
- /**
- * Return the bits in the given range as a base-16 string
- * @memberof Address6
- * @instance
- * @returns {String}
- */
- getBitsBase16(start, end) {
- const length = end - start;
- if (length % 4 !== 0) {
- throw new Error("Length of bits to retrieve must be divisible by four");
- }
- return this.getBits(start, end).toString(16).padStart(length / 4, "0");
- }
- /**
- * Return the bits that are set past the subnet mask length
- * @memberof Address6
- * @instance
- * @returns {String}
- */
- getBitsPastSubnet() {
- return this.getBitsBase2(this.subnetMask, constants6.BITS);
- }
- /**
- * Return the reversed ip6.arpa form of the address
- * @memberof Address6
- * @param {Object} options
- * @param {boolean} options.omitSuffix - omit the "ip6.arpa" suffix
- * @instance
- * @returns {String}
- */
- reverseForm(options) {
- if (!options) {
- options = {};
- }
- const characters = Math.floor(this.subnetMask / 4);
- const reversed = this.canonicalForm().replace(/:/g, "").split("").slice(0, characters).reverse().join(".");
- if (characters > 0) {
- if (options.omitSuffix) {
- return reversed;
- }
- return (0, sprintf_js_1.sprintf)("%s.ip6.arpa.", reversed);
- }
- if (options.omitSuffix) {
- return "";
- }
- return "ip6.arpa.";
- }
- /**
- * Return the correct form of the address
- * @memberof Address6
- * @instance
- * @returns {String}
- */
- correctForm() {
- let i;
- let groups = [];
- let zeroCounter = 0;
- const zeroes = [];
- for (i = 0; i < this.parsedAddress.length; i++) {
- const value = parseInt(this.parsedAddress[i], 16);
- if (value === 0) {
- zeroCounter++;
- }
- if (value !== 0 && zeroCounter > 0) {
- if (zeroCounter > 1) {
- zeroes.push([i - zeroCounter, i - 1]);
- }
- zeroCounter = 0;
- }
- }
- if (zeroCounter > 1) {
- zeroes.push([this.parsedAddress.length - zeroCounter, this.parsedAddress.length - 1]);
- }
- const zeroLengths = zeroes.map((n) => n[1] - n[0] + 1);
- if (zeroes.length > 0) {
- const index = zeroLengths.indexOf(Math.max(...zeroLengths));
- groups = compact(this.parsedAddress, zeroes[index]);
- } else {
- groups = this.parsedAddress;
- }
- for (i = 0; i < groups.length; i++) {
- if (groups[i] !== "compact") {
- groups[i] = parseInt(groups[i], 16).toString(16);
- }
- }
- let correct = groups.join(":");
- correct = correct.replace(/^compact$/, "::");
- correct = correct.replace(/^compact|compact$/, ":");
- correct = correct.replace(/compact/, "");
- return correct;
- }
- /**
- * Return a zero-padded base-2 string representation of the address
- * @memberof Address6
- * @instance
- * @returns {String}
- * @example
- * var address = new Address6('2001:4860:4001:803::1011');
- * address.binaryZeroPad();
- * // '0010000000000001010010000110000001000000000000010000100000000011
- * // 0000000000000000000000000000000000000000000000000001000000010001'
- */
- binaryZeroPad() {
- return this.bigInteger().toString(2).padStart(constants6.BITS, "0");
- }
- // TODO: Improve the semantics of this helper function
- parse4in6(address) {
- const groups = address.split(":");
- const lastGroup = groups.slice(-1)[0];
- const address4 = lastGroup.match(constants4.RE_ADDRESS);
- if (address4) {
- this.parsedAddress4 = address4[0];
- this.address4 = new ipv4_1.Address4(this.parsedAddress4);
- for (let i = 0; i < this.address4.groups; i++) {
- if (/^0[0-9]+/.test(this.address4.parsedAddress[i])) {
- throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.", address.replace(constants4.RE_ADDRESS, this.address4.parsedAddress.map(spanLeadingZeroes4).join(".")));
- }
- }
- this.v4 = true;
- groups[groups.length - 1] = this.address4.toGroup6();
- address = groups.join(":");
- }
- return address;
- }
- // TODO: Make private?
- parse(address) {
- address = this.parse4in6(address);
- const badCharacters = address.match(constants6.RE_BAD_CHARACTERS);
- if (badCharacters) {
- throw new address_error_1.AddressError((0, sprintf_js_1.sprintf)("Bad character%s detected in address: %s", badCharacters.length > 1 ? "s" : "", badCharacters.join("")), address.replace(constants6.RE_BAD_CHARACTERS, '<span class="parse-error">$1</span>'));
- }
- const badAddress = address.match(constants6.RE_BAD_ADDRESS);
- if (badAddress) {
- throw new address_error_1.AddressError((0, sprintf_js_1.sprintf)("Address failed regex: %s", badAddress.join("")), address.replace(constants6.RE_BAD_ADDRESS, '<span class="parse-error">$1</span>'));
- }
- let groups = [];
- const halves = address.split("::");
- if (halves.length === 2) {
- let first = halves[0].split(":");
- let last = halves[1].split(":");
- if (first.length === 1 && first[0] === "") {
- first = [];
- }
- if (last.length === 1 && last[0] === "") {
- last = [];
- }
- const remaining = this.groups - (first.length + last.length);
- if (!remaining) {
- throw new address_error_1.AddressError("Error parsing groups");
- }
- this.elidedGroups = remaining;
- this.elisionBegin = first.length;
- this.elisionEnd = first.length + this.elidedGroups;
- groups = groups.concat(first);
- for (let i = 0; i < remaining; i++) {
- groups.push("0");
- }
- groups = groups.concat(last);
- } else if (halves.length === 1) {
- groups = address.split(":");
- this.elidedGroups = 0;
- } else {
- throw new address_error_1.AddressError("Too many :: groups found");
- }
- groups = groups.map((group) => (0, sprintf_js_1.sprintf)("%x", parseInt(group, 16)));
- if (groups.length !== this.groups) {
- throw new address_error_1.AddressError("Incorrect number of groups found");
- }
- return groups;
- }
- /**
- * Return the canonical form of the address
- * @memberof Address6
- * @instance
- * @returns {String}
- */
- canonicalForm() {
- return this.parsedAddress.map(paddedHex).join(":");
- }
- /**
- * Return the decimal form of the address
- * @memberof Address6
- * @instance
- * @returns {String}
- */
- decimal() {
- return this.parsedAddress.map((n) => (0, sprintf_js_1.sprintf)("%05d", parseInt(n, 16))).join(":");
- }
- /**
- * Return the address as a BigInteger
- * @memberof Address6
- * @instance
- * @returns {BigInteger}
- */
- bigInteger() {
- return new jsbn_1.BigInteger(this.parsedAddress.map(paddedHex).join(""), 16);
- }
- /**
- * Return the last two groups of this address as an IPv4 address string
- * @memberof Address6
- * @instance
- * @returns {Address4}
- * @example
- * var address = new Address6('2001:4860:4001::1825:bf11');
- * address.to4().correctForm(); // '24.37.191.17'
- */
- to4() {
- const binary = this.binaryZeroPad().split("");
- return ipv4_1.Address4.fromHex(new jsbn_1.BigInteger(binary.slice(96, 128).join(""), 2).toString(16));
- }
- /**
- * Return the v4-in-v6 form of the address
- * @memberof Address6
- * @instance
- * @returns {String}
- */
- to4in6() {
- const address4 = this.to4();
- const address6 = new _Address6(this.parsedAddress.slice(0, 6).join(":"), 6);
- const correct = address6.correctForm();
- let infix = "";
- if (!/:$/.test(correct)) {
- infix = ":";
- }
- return correct + infix + address4.address;
- }
- /**
- * Return an object containing the Teredo properties of the address
- * @memberof Address6
- * @instance
- * @returns {Object}
- */
- inspectTeredo() {
- const prefix = this.getBitsBase16(0, 32);
- const udpPort = this.getBits(80, 96).xor(new jsbn_1.BigInteger("ffff", 16)).toString();
- const server4 = ipv4_1.Address4.fromHex(this.getBitsBase16(32, 64));
- const client4 = ipv4_1.Address4.fromHex(this.getBits(96, 128).xor(new jsbn_1.BigInteger("ffffffff", 16)).toString(16));
- const flags = this.getBits(64, 80);
- const flagsBase2 = this.getBitsBase2(64, 80);
- const coneNat = flags.testBit(15);
- const reserved = flags.testBit(14);
- const groupIndividual = flags.testBit(8);
- const universalLocal = flags.testBit(9);
- const nonce = new jsbn_1.BigInteger(flagsBase2.slice(2, 6) + flagsBase2.slice(8, 16), 2).toString(10);
- return {
- prefix: (0, sprintf_js_1.sprintf)("%s:%s", prefix.slice(0, 4), prefix.slice(4, 8)),
- server4: server4.address,
- client4: client4.address,
- flags: flagsBase2,
- coneNat,
- microsoft: {
- reserved,
- universalLocal,
- groupIndividual,
- nonce
- },
- udpPort
- };
- }
- /**
- * Return an object containing the 6to4 properties of the address
- * @memberof Address6
- * @instance
- * @returns {Object}
- */
- inspect6to4() {
- const prefix = this.getBitsBase16(0, 16);
- const gateway = ipv4_1.Address4.fromHex(this.getBitsBase16(16, 48));
- return {
- prefix: (0, sprintf_js_1.sprintf)("%s", prefix.slice(0, 4)),
- gateway: gateway.address
- };
- }
- /**
- * Return a v6 6to4 address from a v6 v4inv6 address
- * @memberof Address6
- * @instance
- * @returns {Address6}
- */
- to6to4() {
- if (!this.is4()) {
- return null;
- }
- const addr6to4 = [
- "2002",
- this.getBitsBase16(96, 112),
- this.getBitsBase16(112, 128),
- "",
- "/16"
- ].join(":");
- return new _Address6(addr6to4);
- }
- /**
- * Return a byte array
- * @memberof Address6
- * @instance
- * @returns {Array}
- */
- toByteArray() {
- const byteArray = this.bigInteger().toByteArray();
- if (byteArray.length === 17 && byteArray[0] === 0) {
- return byteArray.slice(1);
- }
- return byteArray;
- }
- /**
- * Return an unsigned byte array
- * @memberof Address6
- * @instance
- * @returns {Array}
- */
- toUnsignedByteArray() {
- return this.toByteArray().map(unsignByte);
- }
- /**
- * Convert a byte array to an Address6 object
- * @memberof Address6
- * @static
- * @returns {Address6}
- */
- static fromByteArray(bytes) {
- return this.fromUnsignedByteArray(bytes.map(unsignByte));
- }
- /**
- * Convert an unsigned byte array to an Address6 object
- * @memberof Address6
- * @static
- * @returns {Address6}
- */
- static fromUnsignedByteArray(bytes) {
- const BYTE_MAX = new jsbn_1.BigInteger("256", 10);
- let result = new jsbn_1.BigInteger("0", 10);
- let multiplier = new jsbn_1.BigInteger("1", 10);
- for (let i = bytes.length - 1; i >= 0; i--) {
- result = result.add(multiplier.multiply(new jsbn_1.BigInteger(bytes[i].toString(10), 10)));
- multiplier = multiplier.multiply(BYTE_MAX);
- }
- return _Address6.fromBigInteger(result);
- }
- /**
- * Returns true if the address is in the canonical form, false otherwise
- * @memberof Address6
- * @instance
- * @returns {boolean}
- */
- isCanonical() {
- return this.addressMinusSuffix === this.canonicalForm();
- }
- /**
- * Returns true if the address is a link local address, false otherwise
- * @memberof Address6
- * @instance
- * @returns {boolean}
- */
- isLinkLocal() {
- if (this.getBitsBase2(0, 64) === "1111111010000000000000000000000000000000000000000000000000000000") {
- return true;
- }
- return false;
- }
- /**
- * Returns true if the address is a multicast address, false otherwise
- * @memberof Address6
- * @instance
- * @returns {boolean}
- */
- isMulticast() {
- return this.getType() === "Multicast";
- }
- /**
- * Returns true if the address is a v4-in-v6 address, false otherwise
- * @memberof Address6
- * @instance
- * @returns {boolean}
- */
- is4() {
- return this.v4;
- }
- /**
- * Returns true if the address is a Teredo address, false otherwise
- * @memberof Address6
- * @instance
- * @returns {boolean}
- */
- isTeredo() {
- return this.isInSubnet(new _Address6("2001::/32"));
- }
- /**
- * Returns true if the address is a 6to4 address, false otherwise
- * @memberof Address6
- * @instance
- * @returns {boolean}
- */
- is6to4() {
- return this.isInSubnet(new _Address6("2002::/16"));
- }
- /**
- * Returns true if the address is a loopback address, false otherwise
- * @memberof Address6
- * @instance
- * @returns {boolean}
- */
- isLoopback() {
- return this.getType() === "Loopback";
- }
- // #endregion
- // #region HTML
- /**
- * @returns {String} the address in link form with a default port of 80
- */
- href(optionalPort) {
- if (optionalPort === void 0) {
- optionalPort = "";
- } else {
- optionalPort = (0, sprintf_js_1.sprintf)(":%s", optionalPort);
- }
- return (0, sprintf_js_1.sprintf)("http://[%s]%s/", this.correctForm(), optionalPort);
- }
- /**
- * @returns {String} a link suitable for conveying the address via a URL hash
- */
- link(options) {
- if (!options) {
- options = {};
- }
- if (options.className === void 0) {
- options.className = "";
- }
- if (options.prefix === void 0) {
- options.prefix = "/#address=";
- }
- if (options.v4 === void 0) {
- options.v4 = false;
- }
- let formFunction = this.correctForm;
- if (options.v4) {
- formFunction = this.to4in6;
- }
- if (options.className) {
- return (0, sprintf_js_1.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>', options.prefix, formFunction.call(this), options.className);
- }
- return (0, sprintf_js_1.sprintf)('<a href="%1$s%2$s">%2$s</a>', options.prefix, formFunction.call(this));
- }
- /**
- * Groups an address
- * @returns {String}
- */
- group() {
- if (this.elidedGroups === 0) {
- return helpers.simpleGroup(this.address).join(":");
- }
- assert(typeof this.elidedGroups === "number");
- assert(typeof this.elisionBegin === "number");
- const output = [];
- const [left, right] = this.address.split("::");
- if (left.length) {
- output.push(...helpers.simpleGroup(left));
- } else {
- output.push("");
- }
- const classes = ["hover-group"];
- for (let i = this.elisionBegin; i < this.elisionBegin + this.elidedGroups; i++) {
- classes.push((0, sprintf_js_1.sprintf)("group-%d", i));
- }
- output.push((0, sprintf_js_1.sprintf)('<span class="%s"></span>', classes.join(" ")));
- if (right.length) {
- output.push(...helpers.simpleGroup(right, this.elisionEnd));
- } else {
- output.push("");
- }
- if (this.is4()) {
- assert(this.address4 instanceof ipv4_1.Address4);
- output.pop();
- output.push(this.address4.groupForV6());
- }
- return output.join(":");
- }
- // #endregion
- // #region Regular expressions
- /**
- * Generate a regular expression string that can be used to find or validate
- * all variations of this address
- * @memberof Address6
- * @instance
- * @param {boolean} substringSearch
- * @returns {string}
- */
- regularExpressionString(substringSearch = false) {
- let output = [];
- const address6 = new _Address6(this.correctForm());
- if (address6.elidedGroups === 0) {
- output.push((0, regular_expressions_1.simpleRegularExpression)(address6.parsedAddress));
- } else if (address6.elidedGroups === constants6.GROUPS) {
- output.push((0, regular_expressions_1.possibleElisions)(constants6.GROUPS));
- } else {
- const halves = address6.address.split("::");
- if (halves[0].length) {
- output.push((0, regular_expressions_1.simpleRegularExpression)(halves[0].split(":")));
- }
- assert(typeof address6.elidedGroups === "number");
- output.push((0, regular_expressions_1.possibleElisions)(address6.elidedGroups, halves[0].length !== 0, halves[1].length !== 0));
- if (halves[1].length) {
- output.push((0, regular_expressions_1.simpleRegularExpression)(halves[1].split(":")));
- }
- output = [output.join(":")];
- }
- if (!substringSearch) {
- output = [
- "(?=^|",
- regular_expressions_1.ADDRESS_BOUNDARY,
- "|[^\\w\\:])(",
- ...output,
- ")(?=[^\\w\\:]|",
- regular_expressions_1.ADDRESS_BOUNDARY,
- "|$)"
- ];
- }
- return output.join("");
- }
- /**
- * Generate a regular expression that can be used to find or validate all
- * variations of this address.
- * @memberof Address6
- * @instance
- * @param {boolean} substringSearch
- * @returns {RegExp}
- */
- regularExpression(substringSearch = false) {
- return new RegExp(this.regularExpressionString(substringSearch), "i");
- }
- };
- exports2.Address6 = Address6;
- }
- });
- // node_modules/ip-address/dist/ip-address.js
- var require_ip_address = __commonJS({
- "node_modules/ip-address/dist/ip-address.js"(exports2) {
- "use strict";
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() {
- return m[k];
- } };
- }
- Object.defineProperty(o, k2, desc);
- } : function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- o[k2] = m[k];
- });
- var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- } : function(o, v) {
- o["default"] = v;
- });
- var __importStar = exports2 && exports2.__importStar || function(mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) {
- for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- }
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.v6 = exports2.AddressError = exports2.Address6 = exports2.Address4 = void 0;
- var ipv4_1 = require_ipv4();
- Object.defineProperty(exports2, "Address4", { enumerable: true, get: function() {
- return ipv4_1.Address4;
- } });
- var ipv6_1 = require_ipv6();
- Object.defineProperty(exports2, "Address6", { enumerable: true, get: function() {
- return ipv6_1.Address6;
- } });
- var address_error_1 = require_address_error();
- Object.defineProperty(exports2, "AddressError", { enumerable: true, get: function() {
- return address_error_1.AddressError;
- } });
- var helpers = __importStar(require_helpers());
- exports2.v6 = { helpers };
- }
- });
- // node_modules/socks/build/common/helpers.js
- var require_helpers2 = __commonJS({
- "node_modules/socks/build/common/helpers.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ipToBuffer = exports2.int32ToIpv4 = exports2.ipv4ToInt32 = exports2.validateSocksClientChainOptions = exports2.validateSocksClientOptions = void 0;
- var util_1 = require_util();
- var constants_1 = require_constants3();
- var stream = require("stream");
- var ip_address_1 = require_ip_address();
- var net = require("net");
- function validateSocksClientOptions(options, acceptedCommands = ["connect", "bind", "associate"]) {
- if (!constants_1.SocksCommand[options.command]) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksCommand, options);
- }
- if (acceptedCommands.indexOf(options.command) === -1) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksCommandForOperation, options);
- }
- if (!isValidSocksRemoteHost(options.destination)) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsDestination, options);
- }
- if (!isValidSocksProxy(options.proxy)) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsProxy, options);
- }
- validateCustomProxyAuth(options.proxy, options);
- if (options.timeout && !isValidTimeoutValue(options.timeout)) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsTimeout, options);
- }
- if (options.existing_socket && !(options.existing_socket instanceof stream.Duplex)) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsExistingSocket, options);
- }
- }
- exports2.validateSocksClientOptions = validateSocksClientOptions;
- function validateSocksClientChainOptions(options) {
- if (options.command !== "connect") {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksCommandChain, options);
- }
- if (!isValidSocksRemoteHost(options.destination)) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsDestination, options);
- }
- if (!(options.proxies && Array.isArray(options.proxies) && options.proxies.length >= 2)) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsProxiesLength, options);
- }
- options.proxies.forEach((proxy) => {
- if (!isValidSocksProxy(proxy)) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsProxy, options);
- }
- validateCustomProxyAuth(proxy, options);
- });
- if (options.timeout && !isValidTimeoutValue(options.timeout)) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsTimeout, options);
- }
- }
- exports2.validateSocksClientChainOptions = validateSocksClientChainOptions;
- function validateCustomProxyAuth(proxy, options) {
- if (proxy.custom_auth_method !== void 0) {
- if (proxy.custom_auth_method < constants_1.SOCKS5_CUSTOM_AUTH_START || proxy.custom_auth_method > constants_1.SOCKS5_CUSTOM_AUTH_END) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthRange, options);
- }
- if (proxy.custom_auth_request_handler === void 0 || typeof proxy.custom_auth_request_handler !== "function") {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthOptions, options);
- }
- if (proxy.custom_auth_response_size === void 0) {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthOptions, options);
- }
- if (proxy.custom_auth_response_handler === void 0 || typeof proxy.custom_auth_response_handler !== "function") {
- throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthOptions, options);
- }
- }
- }
- function isValidSocksRemoteHost(remoteHost) {
- return remoteHost && typeof remoteHost.host === "string" && typeof remoteHost.port === "number" && remoteHost.port >= 0 && remoteHost.port <= 65535;
- }
- function isValidSocksProxy(proxy) {
- return proxy && (typeof proxy.host === "string" || typeof proxy.ipaddress === "string") && typeof proxy.port === "number" && proxy.port >= 0 && proxy.port <= 65535 && (proxy.type === 4 || proxy.type === 5);
- }
- function isValidTimeoutValue(value) {
- return typeof value === "number" && value > 0;
- }
- function ipv4ToInt32(ip) {
- const address = new ip_address_1.Address4(ip);
- return address.toArray().reduce((acc, part) => (acc << 8) + part, 0);
- }
- exports2.ipv4ToInt32 = ipv4ToInt32;
- function int32ToIpv4(int32) {
- const octet1 = int32 >>> 24 & 255;
- const octet2 = int32 >>> 16 & 255;
- const octet3 = int32 >>> 8 & 255;
- const octet4 = int32 & 255;
- return [octet1, octet2, octet3, octet4].join(".");
- }
- exports2.int32ToIpv4 = int32ToIpv4;
- function ipToBuffer(ip) {
- if (net.isIPv4(ip)) {
- const address = new ip_address_1.Address4(ip);
- return Buffer.from(address.toArray());
- } else if (net.isIPv6(ip)) {
- const address = new ip_address_1.Address6(ip);
- return Buffer.from(address.canonicalForm().split(":").map((segment) => segment.padStart(4, "0")).join(""), "hex");
- } else {
- throw new Error("Invalid IP address format");
- }
- }
- exports2.ipToBuffer = ipToBuffer;
- }
- });
- // node_modules/socks/build/common/receivebuffer.js
- var require_receivebuffer = __commonJS({
- "node_modules/socks/build/common/receivebuffer.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ReceiveBuffer = void 0;
- var ReceiveBuffer = class {
- constructor(size = 4096) {
- this.buffer = Buffer.allocUnsafe(size);
- this.offset = 0;
- this.originalSize = size;
- }
- get length() {
- return this.offset;
- }
- append(data) {
- if (!Buffer.isBuffer(data)) {
- throw new Error("Attempted to append a non-buffer instance to ReceiveBuffer.");
- }
- if (this.offset + data.length >= this.buffer.length) {
- const tmp = this.buffer;
- this.buffer = Buffer.allocUnsafe(Math.max(this.buffer.length + this.originalSize, this.buffer.length + data.length));
- tmp.copy(this.buffer);
- }
- data.copy(this.buffer, this.offset);
- return this.offset += data.length;
- }
- peek(length) {
- if (length > this.offset) {
- throw new Error("Attempted to read beyond the bounds of the managed internal data.");
- }
- return this.buffer.slice(0, length);
- }
- get(length) {
- if (length > this.offset) {
- throw new Error("Attempted to read beyond the bounds of the managed internal data.");
- }
- const value = Buffer.allocUnsafe(length);
- this.buffer.slice(0, length).copy(value);
- this.buffer.copyWithin(0, length, length + this.offset - length);
- this.offset -= length;
- return value;
- }
- };
- exports2.ReceiveBuffer = ReceiveBuffer;
- }
- });
- // node_modules/socks/build/client/socksclient.js
- var require_socksclient = __commonJS({
- "node_modules/socks/build/client/socksclient.js"(exports2) {
- "use strict";
- var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
- function adopt(value) {
- return value instanceof P ? value : new P(function(resolve) {
- resolve(value);
- });
- }
- return new (P || (P = Promise))(function(resolve, reject) {
- function fulfilled(value) {
- try {
- step(generator.next(value));
- } catch (e) {
- reject(e);
- }
- }
- function rejected(value) {
- try {
- step(generator["throw"](value));
- } catch (e) {
- reject(e);
- }
- }
- function step(result) {
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
- }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.SocksClientError = exports2.SocksClient = void 0;
- var events_1 = require("events");
- var net = require("net");
- var smart_buffer_1 = require_smartbuffer();
- var constants_1 = require_constants3();
- var helpers_1 = require_helpers2();
- var receivebuffer_1 = require_receivebuffer();
- var util_1 = require_util();
- Object.defineProperty(exports2, "SocksClientError", { enumerable: true, get: function() {
- return util_1.SocksClientError;
- } });
- var ip_address_1 = require_ip_address();
- var SocksClient = class _SocksClient extends events_1.EventEmitter {
- constructor(options) {
- super();
- this.options = Object.assign({}, options);
- (0, helpers_1.validateSocksClientOptions)(options);
- this.setState(constants_1.SocksClientState.Created);
- }
- /**
- * Creates a new SOCKS connection.
- *
- * Note: Supports callbacks and promises. Only supports the connect command.
- * @param options { SocksClientOptions } Options.
- * @param callback { Function } An optional callback function.
- * @returns { Promise }
- */
- static createConnection(options, callback) {
- return new Promise((resolve, reject) => {
- try {
- (0, helpers_1.validateSocksClientOptions)(options, ["connect"]);
- } catch (err) {
- if (typeof callback === "function") {
- callback(err);
- return resolve(err);
- } else {
- return reject(err);
- }
- }
- const client = new _SocksClient(options);
- client.connect(options.existing_socket);
- client.once("established", (info) => {
- client.removeAllListeners();
- if (typeof callback === "function") {
- callback(null, info);
- resolve(info);
- } else {
- resolve(info);
- }
- });
- client.once("error", (err) => {
- client.removeAllListeners();
- if (typeof callback === "function") {
- callback(err);
- resolve(err);
- } else {
- reject(err);
- }
- });
- });
- }
- /**
- * Creates a new SOCKS connection chain to a destination host through 2 or more SOCKS proxies.
- *
- * Note: Supports callbacks and promises. Only supports the connect method.
- * Note: Implemented via createConnection() factory function.
- * @param options { SocksClientChainOptions } Options
- * @param callback { Function } An optional callback function.
- * @returns { Promise }
- */
- static createConnectionChain(options, callback) {
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
- try {
- (0, helpers_1.validateSocksClientChainOptions)(options);
- } catch (err) {
- if (typeof callback === "function") {
- callback(err);
- return resolve(err);
- } else {
- return reject(err);
- }
- }
- if (options.randomizeChain) {
- (0, util_1.shuffleArray)(options.proxies);
- }
- try {
- let sock;
- for (let i = 0; i < options.proxies.length; i++) {
- const nextProxy = options.proxies[i];
- const nextDestination = i === options.proxies.length - 1 ? options.destination : {
- host: options.proxies[i + 1].host || options.proxies[i + 1].ipaddress,
- port: options.proxies[i + 1].port
- };
- const result = yield _SocksClient.createConnection({
- command: "connect",
- proxy: nextProxy,
- destination: nextDestination,
- existing_socket: sock
- });
- sock = sock || result.socket;
- }
- if (typeof callback === "function") {
- callback(null, { socket: sock });
- resolve({ socket: sock });
- } else {
- resolve({ socket: sock });
- }
- } catch (err) {
- if (typeof callback === "function") {
- callback(err);
- resolve(err);
- } else {
- reject(err);
- }
- }
- }));
- }
- /**
- * Creates a SOCKS UDP Frame.
- * @param options
- */
- static createUDPFrame(options) {
- const buff = new smart_buffer_1.SmartBuffer();
- buff.writeUInt16BE(0);
- buff.writeUInt8(options.frameNumber || 0);
- if (net.isIPv4(options.remoteHost.host)) {
- buff.writeUInt8(constants_1.Socks5HostType.IPv4);
- buff.writeUInt32BE((0, helpers_1.ipv4ToInt32)(options.remoteHost.host));
- } else if (net.isIPv6(options.remoteHost.host)) {
- buff.writeUInt8(constants_1.Socks5HostType.IPv6);
- buff.writeBuffer((0, helpers_1.ipToBuffer)(options.remoteHost.host));
- } else {
- buff.writeUInt8(constants_1.Socks5HostType.Hostname);
- buff.writeUInt8(Buffer.byteLength(options.remoteHost.host));
- buff.writeString(options.remoteHost.host);
- }
- buff.writeUInt16BE(options.remoteHost.port);
- buff.writeBuffer(options.data);
- return buff.toBuffer();
- }
- /**
- * Parses a SOCKS UDP frame.
- * @param data
- */
- static parseUDPFrame(data) {
- const buff = smart_buffer_1.SmartBuffer.fromBuffer(data);
- buff.readOffset = 2;
- const frameNumber = buff.readUInt8();
- const hostType = buff.readUInt8();
- let remoteHost;
- if (hostType === constants_1.Socks5HostType.IPv4) {
- remoteHost = (0, helpers_1.int32ToIpv4)(buff.readUInt32BE());
- } else if (hostType === constants_1.Socks5HostType.IPv6) {
- remoteHost = ip_address_1.Address6.fromByteArray(Array.from(buff.readBuffer(16))).canonicalForm();
- } else {
- remoteHost = buff.readString(buff.readUInt8());
- }
- const remotePort = buff.readUInt16BE();
- return {
- frameNumber,
- remoteHost: {
- host: remoteHost,
- port: remotePort
- },
- data: buff.readBuffer()
- };
- }
- /**
- * Internal state setter. If the SocksClient is in an error state, it cannot be changed to a non error state.
- */
- setState(newState) {
- if (this.state !== constants_1.SocksClientState.Error) {
- this.state = newState;
- }
- }
- /**
- * Starts the connection establishment to the proxy and destination.
- * @param existingSocket Connected socket to use instead of creating a new one (internal use).
- */
- connect(existingSocket) {
- this.onDataReceived = (data) => this.onDataReceivedHandler(data);
- this.onClose = () => this.onCloseHandler();
- this.onError = (err) => this.onErrorHandler(err);
- this.onConnect = () => this.onConnectHandler();
- const timer = setTimeout(() => this.onEstablishedTimeout(), this.options.timeout || constants_1.DEFAULT_TIMEOUT);
- if (timer.unref && typeof timer.unref === "function") {
- timer.unref();
- }
- if (existingSocket) {
- this.socket = existingSocket;
- } else {
- this.socket = new net.Socket();
- }
- this.socket.once("close", this.onClose);
- this.socket.once("error", this.onError);
- this.socket.once("connect", this.onConnect);
- this.socket.on("data", this.onDataReceived);
- this.setState(constants_1.SocksClientState.Connecting);
- this.receiveBuffer = new receivebuffer_1.ReceiveBuffer();
- if (existingSocket) {
- this.socket.emit("connect");
- } else {
- this.socket.connect(this.getSocketOptions());
- if (this.options.set_tcp_nodelay !== void 0 && this.options.set_tcp_nodelay !== null) {
- this.socket.setNoDelay(!!this.options.set_tcp_nodelay);
- }
- }
- this.prependOnceListener("established", (info) => {
- setImmediate(() => {
- if (this.receiveBuffer.length > 0) {
- const excessData = this.receiveBuffer.get(this.receiveBuffer.length);
- info.socket.emit("data", excessData);
- }
- info.socket.resume();
- });
- });
- }
- // Socket options (defaults host/port to options.proxy.host/options.proxy.port)
- getSocketOptions() {
- return Object.assign(Object.assign({}, this.options.socket_options), { host: this.options.proxy.host || this.options.proxy.ipaddress, port: this.options.proxy.port });
- }
- /**
- * Handles internal Socks timeout callback.
- * Note: If the Socks client is not BoundWaitingForConnection or Established, the connection will be closed.
- */
- onEstablishedTimeout() {
- if (this.state !== constants_1.SocksClientState.Established && this.state !== constants_1.SocksClientState.BoundWaitingForConnection) {
- this.closeSocket(constants_1.ERRORS.ProxyConnectionTimedOut);
- }
- }
- /**
- * Handles Socket connect event.
- */
- onConnectHandler() {
- this.setState(constants_1.SocksClientState.Connected);
- if (this.options.proxy.type === 4) {
- this.sendSocks4InitialHandshake();
- } else {
- this.sendSocks5InitialHandshake();
- }
- this.setState(constants_1.SocksClientState.SentInitialHandshake);
- }
- /**
- * Handles Socket data event.
- * @param data
- */
- onDataReceivedHandler(data) {
- this.receiveBuffer.append(data);
- this.processData();
- }
- /**
- * Handles processing of the data we have received.
- */
- processData() {
- while (this.state !== constants_1.SocksClientState.Established && this.state !== constants_1.SocksClientState.Error && this.receiveBuffer.length >= this.nextRequiredPacketBufferSize) {
- if (this.state === constants_1.SocksClientState.SentInitialHandshake) {
- if (this.options.proxy.type === 4) {
- this.handleSocks4FinalHandshakeResponse();
- } else {
- this.handleInitialSocks5HandshakeResponse();
- }
- } else if (this.state === constants_1.SocksClientState.SentAuthentication) {
- this.handleInitialSocks5AuthenticationHandshakeResponse();
- } else if (this.state === constants_1.SocksClientState.SentFinalHandshake) {
- this.handleSocks5FinalHandshakeResponse();
- } else if (this.state === constants_1.SocksClientState.BoundWaitingForConnection) {
- if (this.options.proxy.type === 4) {
- this.handleSocks4IncomingConnectionResponse();
- } else {
- this.handleSocks5IncomingConnectionResponse();
- }
- } else {
- this.closeSocket(constants_1.ERRORS.InternalError);
- break;
- }
- }
- }
- /**
- * Handles Socket close event.
- * @param had_error
- */
- onCloseHandler() {
- this.closeSocket(constants_1.ERRORS.SocketClosed);
- }
- /**
- * Handles Socket error event.
- * @param err
- */
- onErrorHandler(err) {
- this.closeSocket(err.message);
- }
- /**
- * Removes internal event listeners on the underlying Socket.
- */
- removeInternalSocketHandlers() {
- this.socket.pause();
- this.socket.removeListener("data", this.onDataReceived);
- this.socket.removeListener("close", this.onClose);
- this.socket.removeListener("error", this.onError);
- this.socket.removeListener("connect", this.onConnect);
- }
- /**
- * Closes and destroys the underlying Socket. Emits an error event.
- * @param err { String } An error string to include in error event.
- */
- closeSocket(err) {
- if (this.state !== constants_1.SocksClientState.Error) {
- this.setState(constants_1.SocksClientState.Error);
- this.socket.destroy();
- this.removeInternalSocketHandlers();
- this.emit("error", new util_1.SocksClientError(err, this.options));
- }
- }
- /**
- * Sends initial Socks v4 handshake request.
- */
- sendSocks4InitialHandshake() {
- const userId = this.options.proxy.userId || "";
- const buff = new smart_buffer_1.SmartBuffer();
- buff.writeUInt8(4);
- buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
- buff.writeUInt16BE(this.options.destination.port);
- if (net.isIPv4(this.options.destination.host)) {
- buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
- buff.writeStringNT(userId);
- } else {
- buff.writeUInt8(0);
- buff.writeUInt8(0);
- buff.writeUInt8(0);
- buff.writeUInt8(1);
- buff.writeStringNT(userId);
- buff.writeStringNT(this.options.destination.host);
- }
- this.nextRequiredPacketBufferSize = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks4Response;
- this.socket.write(buff.toBuffer());
- }
- /**
- * Handles Socks v4 handshake response.
- * @param data
- */
- handleSocks4FinalHandshakeResponse() {
- const data = this.receiveBuffer.get(8);
- if (data[1] !== constants_1.Socks4Response.Granted) {
- this.closeSocket(`${constants_1.ERRORS.Socks4ProxyRejectedConnection} - (${constants_1.Socks4Response[data[1]]})`);
- } else {
- if (constants_1.SocksCommand[this.options.command] === constants_1.SocksCommand.bind) {
- const buff = smart_buffer_1.SmartBuffer.fromBuffer(data);
- buff.readOffset = 2;
- const remoteHost = {
- port: buff.readUInt16BE(),
- host: (0, helpers_1.int32ToIpv4)(buff.readUInt32BE())
- };
- if (remoteHost.host === "0.0.0.0") {
- remoteHost.host = this.options.proxy.ipaddress;
- }
- this.setState(constants_1.SocksClientState.BoundWaitingForConnection);
- this.emit("bound", { remoteHost, socket: this.socket });
- } else {
- this.setState(constants_1.SocksClientState.Established);
- this.removeInternalSocketHandlers();
- this.emit("established", { socket: this.socket });
- }
- }
- }
- /**
- * Handles Socks v4 incoming connection request (BIND)
- * @param data
- */
- handleSocks4IncomingConnectionResponse() {
- const data = this.receiveBuffer.get(8);
- if (data[1] !== constants_1.Socks4Response.Granted) {
- this.closeSocket(`${constants_1.ERRORS.Socks4ProxyRejectedIncomingBoundConnection} - (${constants_1.Socks4Response[data[1]]})`);
- } else {
- const buff = smart_buffer_1.SmartBuffer.fromBuffer(data);
- buff.readOffset = 2;
- const remoteHost = {
- port: buff.readUInt16BE(),
- host: (0, helpers_1.int32ToIpv4)(buff.readUInt32BE())
- };
- this.setState(constants_1.SocksClientState.Established);
- this.removeInternalSocketHandlers();
- this.emit("established", { remoteHost, socket: this.socket });
- }
- }
- /**
- * Sends initial Socks v5 handshake request.
- */
- sendSocks5InitialHandshake() {
- const buff = new smart_buffer_1.SmartBuffer();
- const supportedAuthMethods = [constants_1.Socks5Auth.NoAuth];
- if (this.options.proxy.userId || this.options.proxy.password) {
- supportedAuthMethods.push(constants_1.Socks5Auth.UserPass);
- }
- if (this.options.proxy.custom_auth_method !== void 0) {
- supportedAuthMethods.push(this.options.proxy.custom_auth_method);
- }
- buff.writeUInt8(5);
- buff.writeUInt8(supportedAuthMethods.length);
- for (const authMethod of supportedAuthMethods) {
- buff.writeUInt8(authMethod);
- }
- this.nextRequiredPacketBufferSize = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5InitialHandshakeResponse;
- this.socket.write(buff.toBuffer());
- this.setState(constants_1.SocksClientState.SentInitialHandshake);
- }
- /**
- * Handles initial Socks v5 handshake response.
- * @param data
- */
- handleInitialSocks5HandshakeResponse() {
- const data = this.receiveBuffer.get(2);
- if (data[0] !== 5) {
- this.closeSocket(constants_1.ERRORS.InvalidSocks5IntiailHandshakeSocksVersion);
- } else if (data[1] === constants_1.SOCKS5_NO_ACCEPTABLE_AUTH) {
- this.closeSocket(constants_1.ERRORS.InvalidSocks5InitialHandshakeNoAcceptedAuthType);
- } else {
- if (data[1] === constants_1.Socks5Auth.NoAuth) {
- this.socks5ChosenAuthType = constants_1.Socks5Auth.NoAuth;
- this.sendSocks5CommandRequest();
- } else if (data[1] === constants_1.Socks5Auth.UserPass) {
- this.socks5ChosenAuthType = constants_1.Socks5Auth.UserPass;
- this.sendSocks5UserPassAuthentication();
- } else if (data[1] === this.options.proxy.custom_auth_method) {
- this.socks5ChosenAuthType = this.options.proxy.custom_auth_method;
- this.sendSocks5CustomAuthentication();
- } else {
- this.closeSocket(constants_1.ERRORS.InvalidSocks5InitialHandshakeUnknownAuthType);
- }
- }
- }
- /**
- * Sends Socks v5 user & password auth handshake.
- *
- * Note: No auth and user/pass are currently supported.
- */
- sendSocks5UserPassAuthentication() {
- const userId = this.options.proxy.userId || "";
- const password = this.options.proxy.password || "";
- const buff = new smart_buffer_1.SmartBuffer();
- buff.writeUInt8(1);
- buff.writeUInt8(Buffer.byteLength(userId));
- buff.writeString(userId);
- buff.writeUInt8(Buffer.byteLength(password));
- buff.writeString(password);
- this.nextRequiredPacketBufferSize = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5UserPassAuthenticationResponse;
- this.socket.write(buff.toBuffer());
- this.setState(constants_1.SocksClientState.SentAuthentication);
- }
- sendSocks5CustomAuthentication() {
- return __awaiter(this, void 0, void 0, function* () {
- this.nextRequiredPacketBufferSize = this.options.proxy.custom_auth_response_size;
- this.socket.write(yield this.options.proxy.custom_auth_request_handler());
- this.setState(constants_1.SocksClientState.SentAuthentication);
- });
- }
- handleSocks5CustomAuthHandshakeResponse(data) {
- return __awaiter(this, void 0, void 0, function* () {
- return yield this.options.proxy.custom_auth_response_handler(data);
- });
- }
- handleSocks5AuthenticationNoAuthHandshakeResponse(data) {
- return __awaiter(this, void 0, void 0, function* () {
- return data[1] === 0;
- });
- }
- handleSocks5AuthenticationUserPassHandshakeResponse(data) {
- return __awaiter(this, void 0, void 0, function* () {
- return data[1] === 0;
- });
- }
- /**
- * Handles Socks v5 auth handshake response.
- * @param data
- */
- handleInitialSocks5AuthenticationHandshakeResponse() {
- return __awaiter(this, void 0, void 0, function* () {
- this.setState(constants_1.SocksClientState.ReceivedAuthenticationResponse);
- let authResult = false;
- if (this.socks5ChosenAuthType === constants_1.Socks5Auth.NoAuth) {
- authResult = yield this.handleSocks5AuthenticationNoAuthHandshakeResponse(this.receiveBuffer.get(2));
- } else if (this.socks5ChosenAuthType === constants_1.Socks5Auth.UserPass) {
- authResult = yield this.handleSocks5AuthenticationUserPassHandshakeResponse(this.receiveBuffer.get(2));
- } else if (this.socks5ChosenAuthType === this.options.proxy.custom_auth_method) {
- authResult = yield this.handleSocks5CustomAuthHandshakeResponse(this.receiveBuffer.get(this.options.proxy.custom_auth_response_size));
- }
- if (!authResult) {
- this.closeSocket(constants_1.ERRORS.Socks5AuthenticationFailed);
- } else {
- this.sendSocks5CommandRequest();
- }
- });
- }
- /**
- * Sends Socks v5 final handshake request.
- */
- sendSocks5CommandRequest() {
- const buff = new smart_buffer_1.SmartBuffer();
- buff.writeUInt8(5);
- buff.writeUInt8(constants_1.SocksCommand[this.options.command]);
- buff.writeUInt8(0);
- if (net.isIPv4(this.options.destination.host)) {
- buff.writeUInt8(constants_1.Socks5HostType.IPv4);
- buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
- } else if (net.isIPv6(this.options.destination.host)) {
- buff.writeUInt8(constants_1.Socks5HostType.IPv6);
- buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host));
- } else {
- buff.writeUInt8(constants_1.Socks5HostType.Hostname);
- buff.writeUInt8(this.options.destination.host.length);
- buff.writeString(this.options.destination.host);
- }
- buff.writeUInt16BE(this.options.destination.port);
- this.nextRequiredPacketBufferSize = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader;
- this.socket.write(buff.toBuffer());
- this.setState(constants_1.SocksClientState.SentFinalHandshake);
- }
- /**
- * Handles Socks v5 final handshake response.
- * @param data
- */
- handleSocks5FinalHandshakeResponse() {
- const header = this.receiveBuffer.peek(5);
- if (header[0] !== 5 || header[1] !== constants_1.Socks5Response.Granted) {
- this.closeSocket(`${constants_1.ERRORS.InvalidSocks5FinalHandshakeRejected} - ${constants_1.Socks5Response[header[1]]}`);
- } else {
- const addressType = header[3];
- let remoteHost;
- let buff;
- if (addressType === constants_1.Socks5HostType.IPv4) {
- const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;
- if (this.receiveBuffer.length < dataNeeded) {
- this.nextRequiredPacketBufferSize = dataNeeded;
- return;
- }
- buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(4));
- remoteHost = {
- host: (0, helpers_1.int32ToIpv4)(buff.readUInt32BE()),
- port: buff.readUInt16BE()
- };
- if (remoteHost.host === "0.0.0.0") {
- remoteHost.host = this.options.proxy.ipaddress;
- }
- } else if (addressType === constants_1.Socks5HostType.Hostname) {
- const hostLength = header[4];
- const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(hostLength);
- if (this.receiveBuffer.length < dataNeeded) {
- this.nextRequiredPacketBufferSize = dataNeeded;
- return;
- }
- buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(5));
- remoteHost = {
- host: buff.readString(hostLength),
- port: buff.readUInt16BE()
- };
- } else if (addressType === constants_1.Socks5HostType.IPv6) {
- const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6;
- if (this.receiveBuffer.length < dataNeeded) {
- this.nextRequiredPacketBufferSize = dataNeeded;
- return;
- }
- buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(4));
- remoteHost = {
- host: ip_address_1.Address6.fromByteArray(Array.from(buff.readBuffer(16))).canonicalForm(),
- port: buff.readUInt16BE()
- };
- }
- this.setState(constants_1.SocksClientState.ReceivedFinalResponse);
- if (constants_1.SocksCommand[this.options.command] === constants_1.SocksCommand.connect) {
- this.setState(constants_1.SocksClientState.Established);
- this.removeInternalSocketHandlers();
- this.emit("established", { remoteHost, socket: this.socket });
- } else if (constants_1.SocksCommand[this.options.command] === constants_1.SocksCommand.bind) {
- this.setState(constants_1.SocksClientState.BoundWaitingForConnection);
- this.nextRequiredPacketBufferSize = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader;
- this.emit("bound", { remoteHost, socket: this.socket });
- } else if (constants_1.SocksCommand[this.options.command] === constants_1.SocksCommand.associate) {
- this.setState(constants_1.SocksClientState.Established);
- this.removeInternalSocketHandlers();
- this.emit("established", {
- remoteHost,
- socket: this.socket
- });
- }
- }
- }
- /**
- * Handles Socks v5 incoming connection request (BIND).
- */
- handleSocks5IncomingConnectionResponse() {
- const header = this.receiveBuffer.peek(5);
- if (header[0] !== 5 || header[1] !== constants_1.Socks5Response.Granted) {
- this.closeSocket(`${constants_1.ERRORS.Socks5ProxyRejectedIncomingBoundConnection} - ${constants_1.Socks5Response[header[1]]}`);
- } else {
- const addressType = header[3];
- let remoteHost;
- let buff;
- if (addressType === constants_1.Socks5HostType.IPv4) {
- const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;
- if (this.receiveBuffer.length < dataNeeded) {
- this.nextRequiredPacketBufferSize = dataNeeded;
- return;
- }
- buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(4));
- remoteHost = {
- host: (0, helpers_1.int32ToIpv4)(buff.readUInt32BE()),
- port: buff.readUInt16BE()
- };
- if (remoteHost.host === "0.0.0.0") {
- remoteHost.host = this.options.proxy.ipaddress;
- }
- } else if (addressType === constants_1.Socks5HostType.Hostname) {
- const hostLength = header[4];
- const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(hostLength);
- if (this.receiveBuffer.length < dataNeeded) {
- this.nextRequiredPacketBufferSize = dataNeeded;
- return;
- }
- buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(5));
- remoteHost = {
- host: buff.readString(hostLength),
- port: buff.readUInt16BE()
- };
- } else if (addressType === constants_1.Socks5HostType.IPv6) {
- const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6;
- if (this.receiveBuffer.length < dataNeeded) {
- this.nextRequiredPacketBufferSize = dataNeeded;
- return;
- }
- buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(4));
- remoteHost = {
- host: ip_address_1.Address6.fromByteArray(Array.from(buff.readBuffer(16))).canonicalForm(),
- port: buff.readUInt16BE()
- };
- }
- this.setState(constants_1.SocksClientState.Established);
- this.removeInternalSocketHandlers();
- this.emit("established", { remoteHost, socket: this.socket });
- }
- }
- get socksClientOptions() {
- return Object.assign({}, this.options);
- }
- };
- exports2.SocksClient = SocksClient;
- }
- });
- // node_modules/socks/build/index.js
- var require_build = __commonJS({
- "node_modules/socks/build/index.js"(exports2) {
- "use strict";
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() {
- return m[k];
- } };
- }
- Object.defineProperty(o, k2, desc);
- } : function(o, m, k, k2) {
- if (k2 === void 0) k2 = k;
- o[k2] = m[k];
- });
- var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
- };
- Object.defineProperty(exports2, "__esModule", { value: true });
- __exportStar(require_socksclient(), exports2);
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongocr.js
- var require_mongocr = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongocr.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.MongoCR = void 0;
- var crypto = require("crypto");
- var error_1 = require_error();
- var utils_1 = require_utils();
- var auth_provider_1 = require_auth_provider();
- var MongoCR = class extends auth_provider_1.AuthProvider {
- async auth(authContext) {
- const { connection, credentials } = authContext;
- if (!credentials) {
- throw new error_1.MongoMissingCredentialsError("AuthContext must provide credentials.");
- }
- const { username, password, source } = credentials;
- const { nonce } = await connection.commandAsync((0, utils_1.ns)(`${source}.$cmd`), { getnonce: 1 }, void 0);
- const hashPassword = crypto.createHash("md5").update(`${username}:mongo:${password}`, "utf8").digest("hex");
- const key = crypto.createHash("md5").update(`${nonce}${username}${hashPassword}`, "utf8").digest("hex");
- const authenticateCommand = {
- authenticate: 1,
- user: username,
- nonce,
- key
- };
- await connection.commandAsync((0, utils_1.ns)(`${source}.$cmd`), authenticateCommand, void 0);
- }
- };
- exports2.MongoCR = MongoCR;
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongodb_aws.js
- var require_mongodb_aws = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongodb_aws.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.MongoDBAWS = void 0;
- var crypto = require("crypto");
- var process2 = require("process");
- var util_1 = require("util");
- var BSON = require_bson2();
- var deps_1 = require_deps();
- var error_1 = require_error();
- var utils_1 = require_utils();
- var auth_provider_1 = require_auth_provider();
- var mongo_credentials_1 = require_mongo_credentials();
- var providers_1 = require_providers();
- var LEGACY_REGIONS = /* @__PURE__ */ new Set([
- "ap-northeast-1",
- "ap-south-1",
- "ap-southeast-1",
- "ap-southeast-2",
- "aws-global",
- "ca-central-1",
- "eu-central-1",
- "eu-north-1",
- "eu-west-1",
- "eu-west-2",
- "eu-west-3",
- "sa-east-1",
- "us-east-1",
- "us-east-2",
- "us-west-1",
- "us-west-2"
- ]);
- var ASCII_N = 110;
- var AWS_RELATIVE_URI = "http://169.254.170.2";
- var AWS_EC2_URI = "http://169.254.169.254";
- var AWS_EC2_PATH = "/latest/meta-data/iam/security-credentials";
- var bsonOptions = {
- useBigInt64: false,
- promoteLongs: true,
- promoteValues: true,
- promoteBuffers: false,
- bsonRegExp: false
- };
- var MongoDBAWS = class extends auth_provider_1.AuthProvider {
- constructor() {
- super();
- this.randomBytesAsync = (0, util_1.promisify)(crypto.randomBytes);
- }
- async auth(authContext) {
- const { connection } = authContext;
- if (!authContext.credentials) {
- throw new error_1.MongoMissingCredentialsError("AuthContext must provide credentials.");
- }
- if ("kModuleError" in deps_1.aws4) {
- throw deps_1.aws4["kModuleError"];
- }
- const { sign } = deps_1.aws4;
- if ((0, utils_1.maxWireVersion)(connection) < 9) {
- throw new error_1.MongoCompatibilityError("MONGODB-AWS authentication requires MongoDB version 4.4 or later");
- }
- if (!authContext.credentials.username) {
- authContext.credentials = await makeTempCredentials(authContext.credentials);
- }
- const { credentials } = authContext;
- const accessKeyId = credentials.username;
- const secretAccessKey = credentials.password;
- const sessionToken = credentials.mechanismProperties.AWS_SESSION_TOKEN;
- const awsCredentials = accessKeyId && secretAccessKey && sessionToken ? { accessKeyId, secretAccessKey, sessionToken } : accessKeyId && secretAccessKey ? { accessKeyId, secretAccessKey } : void 0;
- const db = credentials.source;
- const nonce = await this.randomBytesAsync(32);
- const saslStart = {
- saslStart: 1,
- mechanism: "MONGODB-AWS",
- payload: BSON.serialize({ r: nonce, p: ASCII_N }, bsonOptions)
- };
- const saslStartResponse = await connection.commandAsync((0, utils_1.ns)(`${db}.$cmd`), saslStart, void 0);
- const serverResponse = BSON.deserialize(saslStartResponse.payload.buffer, bsonOptions);
- const host = serverResponse.h;
- const serverNonce = serverResponse.s.buffer;
- if (serverNonce.length !== 64) {
- throw new error_1.MongoRuntimeError(`Invalid server nonce length ${serverNonce.length}, expected 64`);
- }
- if (!utils_1.ByteUtils.equals(serverNonce.subarray(0, nonce.byteLength), nonce)) {
- throw new error_1.MongoRuntimeError("Server nonce does not begin with client nonce");
- }
- if (host.length < 1 || host.length > 255 || host.indexOf("..") !== -1) {
- throw new error_1.MongoRuntimeError(`Server returned an invalid host: "${host}"`);
- }
- const body = "Action=GetCallerIdentity&Version=2011-06-15";
- const options = sign({
- method: "POST",
- host,
- region: deriveRegion(serverResponse.h),
- service: "sts",
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- "Content-Length": body.length,
- "X-MongoDB-Server-Nonce": utils_1.ByteUtils.toBase64(serverNonce),
- "X-MongoDB-GS2-CB-Flag": "n"
- },
- path: "/",
- body
- }, awsCredentials);
- const payload = {
- a: options.headers.Authorization,
- d: options.headers["X-Amz-Date"]
- };
- if (sessionToken) {
- payload.t = sessionToken;
- }
- const saslContinue = {
- saslContinue: 1,
- conversationId: 1,
- payload: BSON.serialize(payload, bsonOptions)
- };
- await connection.commandAsync((0, utils_1.ns)(`${db}.$cmd`), saslContinue, void 0);
- }
- };
- MongoDBAWS.credentialProvider = null;
- exports2.MongoDBAWS = MongoDBAWS;
- async function makeTempCredentials(credentials) {
- function makeMongoCredentialsFromAWSTemp(creds) {
- if (!creds.AccessKeyId || !creds.SecretAccessKey || !creds.Token) {
- throw new error_1.MongoMissingCredentialsError("Could not obtain temporary MONGODB-AWS credentials");
- }
- return new mongo_credentials_1.MongoCredentials({
- username: creds.AccessKeyId,
- password: creds.SecretAccessKey,
- source: credentials.source,
- mechanism: providers_1.AuthMechanism.MONGODB_AWS,
- mechanismProperties: {
- AWS_SESSION_TOKEN: creds.Token
- }
- });
- }
- MongoDBAWS.credentialProvider ?? (MongoDBAWS.credentialProvider = (0, deps_1.getAwsCredentialProvider)());
- if ("kModuleError" in MongoDBAWS.credentialProvider) {
- if (process2.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI) {
- return makeMongoCredentialsFromAWSTemp(await (0, utils_1.request)(`${AWS_RELATIVE_URI}${process2.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}`));
- }
- const token = await (0, utils_1.request)(`${AWS_EC2_URI}/latest/api/token`, {
- method: "PUT",
- json: false,
- headers: { "X-aws-ec2-metadata-token-ttl-seconds": 30 }
- });
- const roleName = await (0, utils_1.request)(`${AWS_EC2_URI}/${AWS_EC2_PATH}`, {
- json: false,
- headers: { "X-aws-ec2-metadata-token": token }
- });
- const creds = await (0, utils_1.request)(`${AWS_EC2_URI}/${AWS_EC2_PATH}/${roleName}`, {
- headers: { "X-aws-ec2-metadata-token": token }
- });
- return makeMongoCredentialsFromAWSTemp(creds);
- } else {
- let { AWS_STS_REGIONAL_ENDPOINTS = "", AWS_REGION = "" } = process2.env;
- AWS_STS_REGIONAL_ENDPOINTS = AWS_STS_REGIONAL_ENDPOINTS.toLowerCase();
- AWS_REGION = AWS_REGION.toLowerCase();
- const awsRegionSettingsExist = AWS_REGION.length !== 0 && AWS_STS_REGIONAL_ENDPOINTS.length !== 0;
- const useRegionalSts = AWS_STS_REGIONAL_ENDPOINTS === "regional" || AWS_STS_REGIONAL_ENDPOINTS === "legacy" && !LEGACY_REGIONS.has(AWS_REGION);
- const provider = awsRegionSettingsExist && useRegionalSts ? MongoDBAWS.credentialProvider.fromNodeProviderChain({
- clientConfig: { region: AWS_REGION }
- }) : MongoDBAWS.credentialProvider.fromNodeProviderChain();
- try {
- const creds = await provider();
- return makeMongoCredentialsFromAWSTemp({
- AccessKeyId: creds.accessKeyId,
- SecretAccessKey: creds.secretAccessKey,
- Token: creds.sessionToken,
- Expiration: creds.expiration
- });
- } catch (error) {
- throw new error_1.MongoAWSError(error.message);
- }
- }
- }
- function deriveRegion(host) {
- const parts = host.split(".");
- if (parts.length === 1 || parts[1] === "amazonaws") {
- return "us-east-1";
- }
- return parts[1];
- }
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongodb_oidc/service_workflow.js
- var require_service_workflow = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongodb_oidc/service_workflow.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.commandDocument = exports2.ServiceWorkflow = void 0;
- var bson_1 = require_bson();
- var utils_1 = require_utils();
- var providers_1 = require_providers();
- var ServiceWorkflow = class {
- /**
- * Execute the workflow. Looks for AWS_WEB_IDENTITY_TOKEN_FILE in the environment
- * and then attempts to read the token from that path.
- */
- async execute(connection, credentials) {
- const token = await this.getToken(credentials);
- const command = commandDocument(token);
- return connection.commandAsync((0, utils_1.ns)(credentials.source), command, void 0);
- }
- /**
- * Get the document to add for speculative authentication.
- */
- async speculativeAuth(credentials) {
- const token = await this.getToken(credentials);
- const document = commandDocument(token);
- document.db = credentials.source;
- return { speculativeAuthenticate: document };
- }
- };
- exports2.ServiceWorkflow = ServiceWorkflow;
- function commandDocument(token) {
- return {
- saslStart: 1,
- mechanism: providers_1.AuthMechanism.MONGODB_OIDC,
- payload: bson_1.BSON.serialize({ jwt: token })
- };
- }
- exports2.commandDocument = commandDocument;
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js
- var require_aws_service_workflow = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AwsServiceWorkflow = void 0;
- var fs = require("fs");
- var error_1 = require_error();
- var service_workflow_1 = require_service_workflow();
- var TOKEN_MISSING_ERROR = "AWS_WEB_IDENTITY_TOKEN_FILE must be set in the environment.";
- var AwsServiceWorkflow = class extends service_workflow_1.ServiceWorkflow {
- constructor() {
- super();
- }
- /**
- * Get the token from the environment.
- */
- async getToken() {
- const tokenFile = process.env.AWS_WEB_IDENTITY_TOKEN_FILE;
- if (!tokenFile) {
- throw new error_1.MongoAWSError(TOKEN_MISSING_ERROR);
- }
- return fs.promises.readFile(tokenFile, "utf8");
- }
- };
- exports2.AwsServiceWorkflow = AwsServiceWorkflow;
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongodb_oidc/cache.js
- var require_cache = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongodb_oidc/cache.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.Cache = exports2.ExpiringCacheEntry = void 0;
- var EXPIRATION_BUFFER_MS = 3e5;
- var ExpiringCacheEntry = class {
- /**
- * Create a new expiring token entry.
- */
- constructor(expiration) {
- this.expiration = this.expirationTime(expiration);
- }
- /**
- * The entry is still valid if the expiration is more than
- * 5 minutes from the expiration time.
- */
- isValid() {
- return this.expiration - Date.now() > EXPIRATION_BUFFER_MS;
- }
- /**
- * Get an expiration time in milliseconds past epoch.
- */
- expirationTime(expiresInSeconds) {
- return Date.now() + expiresInSeconds * 1e3;
- }
- };
- exports2.ExpiringCacheEntry = ExpiringCacheEntry;
- var Cache = class {
- /**
- * Create a new cache.
- */
- constructor() {
- this.entries = /* @__PURE__ */ new Map();
- }
- /**
- * Clear the cache.
- */
- clear() {
- this.entries.clear();
- }
- /**
- * Create a cache key from the address and username.
- */
- hashedCacheKey(address, username, callbackHash) {
- return JSON.stringify([address, username, callbackHash]);
- }
- };
- exports2.Cache = Cache;
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_token_cache.js
- var require_azure_token_cache = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_token_cache.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AzureTokenCache = exports2.AzureTokenEntry = void 0;
- var cache_1 = require_cache();
- var AzureTokenEntry = class extends cache_1.ExpiringCacheEntry {
- /**
- * Instantiate the entry.
- */
- constructor(token, expiration) {
- super(expiration);
- this.token = token;
- }
- };
- exports2.AzureTokenEntry = AzureTokenEntry;
- var AzureTokenCache = class extends cache_1.Cache {
- /**
- * Add an entry to the cache.
- */
- addEntry(tokenAudience, token) {
- const entry = new AzureTokenEntry(token.access_token, token.expires_in);
- this.entries.set(tokenAudience, entry);
- return entry;
- }
- /**
- * Create a cache key.
- */
- cacheKey(tokenAudience) {
- return tokenAudience;
- }
- /**
- * Delete an entry from the cache.
- */
- deleteEntry(tokenAudience) {
- this.entries.delete(tokenAudience);
- }
- /**
- * Get an Azure token entry from the cache.
- */
- getEntry(tokenAudience) {
- return this.entries.get(tokenAudience);
- }
- };
- exports2.AzureTokenCache = AzureTokenCache;
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_service_workflow.js
- var require_azure_service_workflow = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_service_workflow.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AzureServiceWorkflow = void 0;
- var error_1 = require_error();
- var utils_1 = require_utils();
- var azure_token_cache_1 = require_azure_token_cache();
- var service_workflow_1 = require_service_workflow();
- var AZURE_BASE_URL = "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01";
- var AZURE_HEADERS = Object.freeze({ Metadata: "true", Accept: "application/json" });
- var ENDPOINT_RESULT_ERROR = "Azure endpoint did not return a value with only access_token and expires_in properties";
- var TOKEN_AUDIENCE_MISSING_ERROR = "TOKEN_AUDIENCE must be set in the auth mechanism properties when PROVIDER_NAME is azure.";
- var AzureServiceWorkflow = class extends service_workflow_1.ServiceWorkflow {
- constructor() {
- super(...arguments);
- this.cache = new azure_token_cache_1.AzureTokenCache();
- }
- /**
- * Get the token from the environment.
- */
- async getToken(credentials) {
- const tokenAudience = credentials == null ? void 0 : credentials.mechanismProperties.TOKEN_AUDIENCE;
- if (!tokenAudience) {
- throw new error_1.MongoAzureError(TOKEN_AUDIENCE_MISSING_ERROR);
- }
- let token;
- const entry = this.cache.getEntry(tokenAudience);
- if (entry == null ? void 0 : entry.isValid()) {
- token = entry.token;
- } else {
- this.cache.deleteEntry(tokenAudience);
- const response = await getAzureTokenData(tokenAudience);
- if (!isEndpointResultValid(response)) {
- throw new error_1.MongoAzureError(ENDPOINT_RESULT_ERROR);
- }
- this.cache.addEntry(tokenAudience, response);
- token = response.access_token;
- }
- return token;
- }
- };
- exports2.AzureServiceWorkflow = AzureServiceWorkflow;
- async function getAzureTokenData(tokenAudience) {
- const url = `${AZURE_BASE_URL}&resource=${tokenAudience}`;
- const data = await (0, utils_1.request)(url, {
- json: true,
- headers: AZURE_HEADERS
- });
- return data;
- }
- function isEndpointResultValid(token) {
- if (token == null || typeof token !== "object")
- return false;
- return "access_token" in token && "expires_in" in token;
- }
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_lock_cache.js
- var require_callback_lock_cache = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_lock_cache.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.CallbackLockCache = void 0;
- var error_1 = require_error();
- var cache_1 = require_cache();
- var REQUEST_CALLBACK_REQUIRED_ERROR = "Auth mechanism property REQUEST_TOKEN_CALLBACK is required.";
- var FN_HASH_COUNTER = 0;
- var NO_FUNCTION = async () => ({ accessToken: "test" });
- var FN_HASHES = /* @__PURE__ */ new WeakMap();
- FN_HASHES.set(NO_FUNCTION, FN_HASH_COUNTER);
- var CallbackLockCache = class extends cache_1.Cache {
- /**
- * Get the callbacks for the connection and credentials. If an entry does not
- * exist a new one will get set.
- */
- getEntry(connection, credentials) {
- const requestCallback = credentials.mechanismProperties.REQUEST_TOKEN_CALLBACK;
- const refreshCallback = credentials.mechanismProperties.REFRESH_TOKEN_CALLBACK;
- if (!requestCallback) {
- throw new error_1.MongoInvalidArgumentError(REQUEST_CALLBACK_REQUIRED_ERROR);
- }
- const callbackHash = hashFunctions(requestCallback, refreshCallback);
- const key = this.cacheKey(connection.address, credentials.username, callbackHash);
- const entry = this.entries.get(key);
- if (entry) {
- return entry;
- }
- return this.addEntry(key, callbackHash, requestCallback, refreshCallback);
- }
- /**
- * Set locked callbacks on for connection and credentials.
- */
- addEntry(key, callbackHash, requestCallback, refreshCallback) {
- const entry = {
- requestCallback: withLock(requestCallback),
- refreshCallback: refreshCallback ? withLock(refreshCallback) : void 0,
- callbackHash
- };
- this.entries.set(key, entry);
- return entry;
- }
- /**
- * Create a cache key from the address and username.
- */
- cacheKey(address, username, callbackHash) {
- return this.hashedCacheKey(address, username, callbackHash);
- }
- };
- exports2.CallbackLockCache = CallbackLockCache;
- function withLock(callback) {
- let lock = Promise.resolve();
- return async (info, context) => {
- await lock;
- lock = lock.then(() => callback(info, context));
- return lock;
- };
- }
- function hashFunctions(requestFn, refreshFn) {
- let requestHash = FN_HASHES.get(requestFn);
- let refreshHash = FN_HASHES.get(refreshFn ?? NO_FUNCTION);
- if (requestHash == null) {
- FN_HASH_COUNTER++;
- requestHash = FN_HASH_COUNTER;
- FN_HASHES.set(requestFn, FN_HASH_COUNTER);
- }
- if (refreshHash == null && refreshFn) {
- FN_HASH_COUNTER++;
- refreshHash = FN_HASH_COUNTER;
- FN_HASHES.set(refreshFn, FN_HASH_COUNTER);
- }
- return `${requestHash}-${refreshHash}`;
- }
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_entry_cache.js
- var require_token_entry_cache = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_entry_cache.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.TokenEntryCache = exports2.TokenEntry = void 0;
- var cache_1 = require_cache();
- var DEFAULT_EXPIRATION_SECS = 0;
- var TokenEntry = class extends cache_1.ExpiringCacheEntry {
- /**
- * Instantiate the entry.
- */
- constructor(tokenResult, serverInfo, expiration) {
- super(expiration);
- this.tokenResult = tokenResult;
- this.serverInfo = serverInfo;
- }
- };
- exports2.TokenEntry = TokenEntry;
- var TokenEntryCache = class extends cache_1.Cache {
- /**
- * Set an entry in the token cache.
- */
- addEntry(address, username, callbackHash, tokenResult, serverInfo) {
- const entry = new TokenEntry(tokenResult, serverInfo, tokenResult.expiresInSeconds ?? DEFAULT_EXPIRATION_SECS);
- this.entries.set(this.cacheKey(address, username, callbackHash), entry);
- return entry;
- }
- /**
- * Delete an entry from the cache.
- */
- deleteEntry(address, username, callbackHash) {
- this.entries.delete(this.cacheKey(address, username, callbackHash));
- }
- /**
- * Get an entry from the cache.
- */
- getEntry(address, username, callbackHash) {
- return this.entries.get(this.cacheKey(address, username, callbackHash));
- }
- /**
- * Delete all expired entries from the cache.
- */
- deleteExpiredEntries() {
- for (const [key, entry] of this.entries) {
- if (!entry.isValid()) {
- this.entries.delete(key);
- }
- }
- }
- /**
- * Create a cache key from the address and username.
- */
- cacheKey(address, username, callbackHash) {
- return this.hashedCacheKey(address, username, callbackHash);
- }
- };
- exports2.TokenEntryCache = TokenEntryCache;
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js
- var require_callback_workflow = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.CallbackWorkflow = void 0;
- var bson_1 = require_bson();
- var error_1 = require_error();
- var utils_1 = require_utils();
- var providers_1 = require_providers();
- var callback_lock_cache_1 = require_callback_lock_cache();
- var token_entry_cache_1 = require_token_entry_cache();
- var OIDC_VERSION = 0;
- var TIMEOUT_S = 300;
- var RESULT_PROPERTIES = ["accessToken", "expiresInSeconds", "refreshToken"];
- var CALLBACK_RESULT_ERROR = "User provided OIDC callbacks must return a valid object with an accessToken.";
- var CallbackWorkflow = class {
- /**
- * Instantiate the workflow
- */
- constructor() {
- this.cache = new token_entry_cache_1.TokenEntryCache();
- this.callbackCache = new callback_lock_cache_1.CallbackLockCache();
- }
- /**
- * Get the document to add for speculative authentication. This also needs
- * to add a db field from the credentials source.
- */
- async speculativeAuth(credentials) {
- const document = startCommandDocument(credentials);
- document.db = credentials.source;
- return { speculativeAuthenticate: document };
- }
- /**
- * Execute the OIDC callback workflow.
- */
- async execute(connection, credentials, reauthenticating, response) {
- var _a, _b;
- const { requestCallback, refreshCallback, callbackHash } = this.callbackCache.getEntry(connection, credentials);
- const entry = this.cache.getEntry(connection.address, credentials.username, callbackHash);
- let result;
- if (entry) {
- if (entry.isValid() && !reauthenticating) {
- result = await this.finishAuthentication(connection, credentials, entry.tokenResult, (_a = response == null ? void 0 : response.speculativeAuthenticate) == null ? void 0 : _a.conversationId);
- } else {
- const tokenResult = await this.fetchAccessToken(connection, credentials, entry.serverInfo, reauthenticating, callbackHash, requestCallback, refreshCallback);
- try {
- result = await this.finishAuthentication(connection, credentials, tokenResult, reauthenticating ? void 0 : (_b = response == null ? void 0 : response.speculativeAuthenticate) == null ? void 0 : _b.conversationId);
- } catch (error) {
- if (reauthenticating && error instanceof error_1.MongoError && error.code === error_1.MONGODB_ERROR_CODES.Reauthenticate) {
- this.cache.deleteEntry(connection.address, credentials.username, callbackHash);
- result = await this.execute(connection, credentials, reauthenticating);
- } else {
- throw error;
- }
- }
- }
- } else {
- const startDocument = await this.startAuthentication(connection, credentials, reauthenticating, response);
- const conversationId = startDocument.conversationId;
- const serverResult = bson_1.BSON.deserialize(startDocument.payload.buffer);
- const tokenResult = await this.fetchAccessToken(connection, credentials, serverResult, reauthenticating, callbackHash, requestCallback, refreshCallback);
- result = await this.finishAuthentication(connection, credentials, tokenResult, conversationId);
- }
- return result;
- }
- /**
- * Starts the callback authentication process. If there is a speculative
- * authentication document from the initial handshake, then we will use that
- * value to get the issuer, otherwise we will send the saslStart command.
- */
- async startAuthentication(connection, credentials, reauthenticating, response) {
- let result;
- if (!reauthenticating && (response == null ? void 0 : response.speculativeAuthenticate)) {
- result = response.speculativeAuthenticate;
- } else {
- result = await connection.commandAsync((0, utils_1.ns)(credentials.source), startCommandDocument(credentials), void 0);
- }
- return result;
- }
- /**
- * Finishes the callback authentication process.
- */
- async finishAuthentication(connection, credentials, tokenResult, conversationId) {
- const result = await connection.commandAsync((0, utils_1.ns)(credentials.source), finishCommandDocument(tokenResult.accessToken, conversationId), void 0);
- return result;
- }
- /**
- * Fetches an access token using either the request or refresh callbacks and
- * puts it in the cache.
- */
- async fetchAccessToken(connection, credentials, serverInfo, reauthenticating, callbackHash, requestCallback, refreshCallback) {
- const entry = this.cache.getEntry(connection.address, credentials.username, callbackHash);
- let result;
- const context = { timeoutSeconds: TIMEOUT_S, version: OIDC_VERSION };
- if (entry) {
- if (entry.isValid() && !reauthenticating) {
- return entry.tokenResult;
- }
- if (refreshCallback) {
- context.refreshToken = entry.tokenResult.refreshToken;
- result = await refreshCallback(serverInfo, context);
- } else {
- result = await requestCallback(serverInfo, context);
- }
- } else {
- result = await requestCallback(serverInfo, context);
- }
- if (isCallbackResultInvalid(result)) {
- this.cache.deleteEntry(connection.address, credentials.username, callbackHash);
- throw new error_1.MongoMissingCredentialsError(CALLBACK_RESULT_ERROR);
- }
- this.cache.deleteExpiredEntries();
- this.cache.addEntry(connection.address, credentials.username || "", callbackHash, result, serverInfo);
- return result;
- }
- };
- exports2.CallbackWorkflow = CallbackWorkflow;
- function finishCommandDocument(token, conversationId) {
- if (conversationId != null && typeof conversationId === "number") {
- return {
- saslContinue: 1,
- conversationId,
- payload: new bson_1.Binary(bson_1.BSON.serialize({ jwt: token }))
- };
- }
- return {
- saslStart: 1,
- mechanism: providers_1.AuthMechanism.MONGODB_OIDC,
- payload: new bson_1.Binary(bson_1.BSON.serialize({ jwt: token }))
- };
- }
- function isCallbackResultInvalid(tokenResult) {
- if (tokenResult == null || typeof tokenResult !== "object")
- return true;
- if (!("accessToken" in tokenResult))
- return true;
- return !Object.getOwnPropertyNames(tokenResult).every((prop) => RESULT_PROPERTIES.includes(prop));
- }
- function startCommandDocument(credentials) {
- const payload = {};
- if (credentials.username) {
- payload.n = credentials.username;
- }
- return {
- saslStart: 1,
- autoAuthorize: 1,
- mechanism: providers_1.AuthMechanism.MONGODB_OIDC,
- payload: new bson_1.Binary(bson_1.BSON.serialize(payload))
- };
- }
- }
- });
- // node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js
- var require_mongodb_oidc = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.MongoDBOIDC = exports2.OIDC_WORKFLOWS = void 0;
- var error_1 = require_error();
- var auth_provider_1 = require_auth_provider();
- var aws_service_workflow_1 = require_aws_service_workflow();
- var azure_service_workflow_1 = require_azure_service_workflow();
- var callback_workflow_1 = require_callback_workflow();
- var MISSING_CREDENTIALS_ERROR = "AuthContext must provide credentials.";
- exports2.OIDC_WORKFLOWS = /* @__PURE__ */ new Map();
- exports2.OIDC_WORKFLOWS.set("callback", new callback_workflow_1.CallbackWorkflow());
- exports2.OIDC_WORKFLOWS.set("aws", new aws_service_workflow_1.AwsServiceWorkflow());
- exports2.OIDC_WORKFLOWS.set("azure", new azure_service_workflow_1.AzureServiceWorkflow());
- var MongoDBOIDC = class extends auth_provider_1.AuthProvider {
- /**
- * Instantiate the auth provider.
- */
- constructor() {
- super();
- }
- /**
- * Authenticate using OIDC
- */
- async auth(authContext) {
- const { connection, reauthenticating, response } = authContext;
- const credentials = getCredentials(authContext);
- const workflow = getWorkflow(credentials);
- await workflow.execute(connection, credentials, reauthenticating, response);
- }
- /**
- * Add the speculative auth for the initial handshake.
- */
- async prepare(handshakeDoc, authContext) {
- const credentials = getCredentials(authContext);
- const workflow = getWorkflow(credentials);
- const result = await workflow.speculativeAuth(credentials);
- return { ...handshakeDoc, ...result };
- }
- };
- exports2.MongoDBOIDC = MongoDBOIDC;
- function getCredentials(authContext) {
- const { credentials } = authContext;
- if (!credentials) {
- throw new error_1.MongoMissingCredentialsError(MISSING_CREDENTIALS_ERROR);
- }
- return credentials;
- }
- function getWorkflow(credentials) {
- const providerName = credentials.mechanismProperties.PROVIDER_NAME;
- const workflow = exports2.OIDC_WORKFLOWS.get(providerName || "callback");
- if (!workflow) {
- throw new error_1.MongoInvalidArgumentError(`Could not load workflow for provider ${credentials.mechanismProperties.PROVIDER_NAME}`);
- }
- return workflow;
- }
- }
- });
- // node_modules/mongodb/lib/cmap/auth/plain.js
- var require_plain = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/plain.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.Plain = void 0;
- var bson_1 = require_bson2();
- var error_1 = require_error();
- var utils_1 = require_utils();
- var auth_provider_1 = require_auth_provider();
- var Plain = class extends auth_provider_1.AuthProvider {
- async auth(authContext) {
- const { connection, credentials } = authContext;
- if (!credentials) {
- throw new error_1.MongoMissingCredentialsError("AuthContext must provide credentials.");
- }
- const { username, password } = credentials;
- const payload = new bson_1.Binary(Buffer.from(`\0${username}\0${password}`));
- const command = {
- saslStart: 1,
- mechanism: "PLAIN",
- payload,
- autoAuthorize: 1
- };
- await connection.commandAsync((0, utils_1.ns)("$external.$cmd"), command, void 0);
- }
- };
- exports2.Plain = Plain;
- }
- });
- // node_modules/mongodb/lib/cmap/auth/scram.js
- var require_scram = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/scram.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ScramSHA256 = exports2.ScramSHA1 = void 0;
- var crypto = require("crypto");
- var util_1 = require("util");
- var bson_1 = require_bson2();
- var deps_1 = require_deps();
- var error_1 = require_error();
- var utils_1 = require_utils();
- var auth_provider_1 = require_auth_provider();
- var providers_1 = require_providers();
- var ScramSHA = class extends auth_provider_1.AuthProvider {
- constructor(cryptoMethod) {
- super();
- this.cryptoMethod = cryptoMethod || "sha1";
- this.randomBytesAsync = (0, util_1.promisify)(crypto.randomBytes);
- }
- async prepare(handshakeDoc, authContext) {
- const cryptoMethod = this.cryptoMethod;
- const credentials = authContext.credentials;
- if (!credentials) {
- throw new error_1.MongoMissingCredentialsError("AuthContext must provide credentials.");
- }
- if (cryptoMethod === "sha256" && ("kModuleError" in deps_1.saslprep || typeof deps_1.saslprep !== "function")) {
- (0, utils_1.emitWarning)("Warning: no saslprep library specified. Passwords will not be sanitized");
- }
- const nonce = await this.randomBytesAsync(24);
- authContext.nonce = nonce;
- const request = {
- ...handshakeDoc,
- speculativeAuthenticate: {
- ...makeFirstMessage(cryptoMethod, credentials, nonce),
- db: credentials.source
- }
- };
- return request;
- }
- async auth(authContext) {
- const { reauthenticating, response } = authContext;
- if ((response == null ? void 0 : response.speculativeAuthenticate) && !reauthenticating) {
- return continueScramConversation(this.cryptoMethod, response.speculativeAuthenticate, authContext);
- }
- return executeScram(this.cryptoMethod, authContext);
- }
- };
- function cleanUsername(username) {
- return username.replace("=", "=3D").replace(",", "=2C");
- }
- function clientFirstMessageBare(username, nonce) {
- return Buffer.concat([
- Buffer.from("n=", "utf8"),
- Buffer.from(username, "utf8"),
- Buffer.from(",r=", "utf8"),
- Buffer.from(nonce.toString("base64"), "utf8")
- ]);
- }
- function makeFirstMessage(cryptoMethod, credentials, nonce) {
- const username = cleanUsername(credentials.username);
- const mechanism = cryptoMethod === "sha1" ? providers_1.AuthMechanism.MONGODB_SCRAM_SHA1 : providers_1.AuthMechanism.MONGODB_SCRAM_SHA256;
- return {
- saslStart: 1,
- mechanism,
- payload: new bson_1.Binary(Buffer.concat([Buffer.from("n,,", "utf8"), clientFirstMessageBare(username, nonce)])),
- autoAuthorize: 1,
- options: { skipEmptyExchange: true }
- };
- }
- async function executeScram(cryptoMethod, authContext) {
- const { connection, credentials } = authContext;
- if (!credentials) {
- throw new error_1.MongoMissingCredentialsError("AuthContext must provide credentials.");
- }
- if (!authContext.nonce) {
- throw new error_1.MongoInvalidArgumentError("AuthContext must contain a valid nonce property");
- }
- const nonce = authContext.nonce;
- const db = credentials.source;
- const saslStartCmd = makeFirstMessage(cryptoMethod, credentials, nonce);
- const response = await connection.commandAsync((0, utils_1.ns)(`${db}.$cmd`), saslStartCmd, void 0);
- await continueScramConversation(cryptoMethod, response, authContext);
- }
- async function continueScramConversation(cryptoMethod, response, authContext) {
- const connection = authContext.connection;
- const credentials = authContext.credentials;
- if (!credentials) {
- throw new error_1.MongoMissingCredentialsError("AuthContext must provide credentials.");
- }
- if (!authContext.nonce) {
- throw new error_1.MongoInvalidArgumentError("Unable to continue SCRAM without valid nonce");
- }
- const nonce = authContext.nonce;
- const db = credentials.source;
- const username = cleanUsername(credentials.username);
- const password = credentials.password;
- let processedPassword;
- if (cryptoMethod === "sha256") {
- processedPassword = "kModuleError" in deps_1.saslprep || typeof deps_1.saslprep !== "function" ? password : (0, deps_1.saslprep)(password);
- } else {
- processedPassword = passwordDigest(username, password);
- }
- const payload = Buffer.isBuffer(response.payload) ? new bson_1.Binary(response.payload) : response.payload;
- const dict = parsePayload(payload.value());
- const iterations = parseInt(dict.i, 10);
- if (iterations && iterations < 4096) {
- throw new error_1.MongoRuntimeError(`Server returned an invalid iteration count ${iterations}`);
- }
- const salt = dict.s;
- const rnonce = dict.r;
- if (rnonce.startsWith("nonce")) {
- throw new error_1.MongoRuntimeError(`Server returned an invalid nonce: ${rnonce}`);
- }
- const withoutProof = `c=biws,r=${rnonce}`;
- const saltedPassword = HI(processedPassword, Buffer.from(salt, "base64"), iterations, cryptoMethod);
- const clientKey = HMAC(cryptoMethod, saltedPassword, "Client Key");
- const serverKey = HMAC(cryptoMethod, saltedPassword, "Server Key");
- const storedKey = H(cryptoMethod, clientKey);
- const authMessage = [clientFirstMessageBare(username, nonce), payload.value(), withoutProof].join(",");
- const clientSignature = HMAC(cryptoMethod, storedKey, authMessage);
- const clientProof = `p=${xor(clientKey, clientSignature)}`;
- const clientFinal = [withoutProof, clientProof].join(",");
- const serverSignature = HMAC(cryptoMethod, serverKey, authMessage);
- const saslContinueCmd = {
- saslContinue: 1,
- conversationId: response.conversationId,
- payload: new bson_1.Binary(Buffer.from(clientFinal))
- };
- const r = await connection.commandAsync((0, utils_1.ns)(`${db}.$cmd`), saslContinueCmd, void 0);
- const parsedResponse = parsePayload(r.payload.value());
- if (!compareDigest(Buffer.from(parsedResponse.v, "base64"), serverSignature)) {
- throw new error_1.MongoRuntimeError("Server returned an invalid signature");
- }
- if (r.done !== false) {
- return;
- }
- const retrySaslContinueCmd = {
- saslContinue: 1,
- conversationId: r.conversationId,
- payload: Buffer.alloc(0)
- };
- await connection.commandAsync((0, utils_1.ns)(`${db}.$cmd`), retrySaslContinueCmd, void 0);
- }
- function parsePayload(payload) {
- const dict = {};
- const parts = payload.split(",");
- for (let i = 0; i < parts.length; i++) {
- const valueParts = parts[i].split("=");
- dict[valueParts[0]] = valueParts[1];
- }
- return dict;
- }
- function passwordDigest(username, password) {
- if (typeof username !== "string") {
- throw new error_1.MongoInvalidArgumentError("Username must be a string");
- }
- if (typeof password !== "string") {
- throw new error_1.MongoInvalidArgumentError("Password must be a string");
- }
- if (password.length === 0) {
- throw new error_1.MongoInvalidArgumentError("Password cannot be empty");
- }
- let md5;
- try {
- md5 = crypto.createHash("md5");
- } catch (err) {
- if (crypto.getFips()) {
- throw new Error("Auth mechanism SCRAM-SHA-1 is not supported in FIPS mode");
- }
- throw err;
- }
- md5.update(`${username}:mongo:${password}`, "utf8");
- return md5.digest("hex");
- }
- function xor(a, b) {
- if (!Buffer.isBuffer(a)) {
- a = Buffer.from(a);
- }
- if (!Buffer.isBuffer(b)) {
- b = Buffer.from(b);
- }
- const length = Math.max(a.length, b.length);
- const res = [];
- for (let i = 0; i < length; i += 1) {
- res.push(a[i] ^ b[i]);
- }
- return Buffer.from(res).toString("base64");
- }
- function H(method, text) {
- return crypto.createHash(method).update(text).digest();
- }
- function HMAC(method, key, text) {
- return crypto.createHmac(method, key).update(text).digest();
- }
- var _hiCache = {};
- var _hiCacheCount = 0;
- function _hiCachePurge() {
- _hiCache = {};
- _hiCacheCount = 0;
- }
- var hiLengthMap = {
- sha256: 32,
- sha1: 20
- };
- function HI(data, salt, iterations, cryptoMethod) {
- const key = [data, salt.toString("base64"), iterations].join("_");
- if (_hiCache[key] != null) {
- return _hiCache[key];
- }
- const saltedData = crypto.pbkdf2Sync(data, salt, iterations, hiLengthMap[cryptoMethod], cryptoMethod);
- if (_hiCacheCount >= 200) {
- _hiCachePurge();
- }
- _hiCache[key] = saltedData;
- _hiCacheCount += 1;
- return saltedData;
- }
- function compareDigest(lhs, rhs) {
- if (lhs.length !== rhs.length) {
- return false;
- }
- if (typeof crypto.timingSafeEqual === "function") {
- return crypto.timingSafeEqual(lhs, rhs);
- }
- let result = 0;
- for (let i = 0; i < lhs.length; i++) {
- result |= lhs[i] ^ rhs[i];
- }
- return result === 0;
- }
- var ScramSHA1 = class extends ScramSHA {
- constructor() {
- super("sha1");
- }
- };
- exports2.ScramSHA1 = ScramSHA1;
- var ScramSHA256 = class extends ScramSHA {
- constructor() {
- super("sha256");
- }
- };
- exports2.ScramSHA256 = ScramSHA256;
- }
- });
- // node_modules/mongodb/lib/cmap/auth/x509.js
- var require_x509 = __commonJS({
- "node_modules/mongodb/lib/cmap/auth/x509.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.X509 = void 0;
- var error_1 = require_error();
- var utils_1 = require_utils();
- var auth_provider_1 = require_auth_provider();
- var X509 = class extends auth_provider_1.AuthProvider {
- async prepare(handshakeDoc, authContext) {
- const { credentials } = authContext;
- if (!credentials) {
- throw new error_1.MongoMissingCredentialsError("AuthContext must provide credentials.");
- }
- return { ...handshakeDoc, speculativeAuthenticate: x509AuthenticateCommand(credentials) };
- }
- async auth(authContext) {
- const connection = authContext.connection;
- const credentials = authContext.credentials;
- if (!credentials) {
- throw new error_1.MongoMissingCredentialsError("AuthContext must provide credentials.");
- }
- const response = authContext.response;
- if (response == null ? void 0 : response.speculativeAuthenticate) {
- return;
- }
- await connection.commandAsync((0, utils_1.ns)("$external.$cmd"), x509AuthenticateCommand(credentials), void 0);
- }
- };
- exports2.X509 = X509;
- function x509AuthenticateCommand(credentials) {
- const command = { authenticate: 1, mechanism: "MONGODB-X509" };
- if (credentials.username) {
- command.user = credentials.username;
- }
- return command;
- }
- }
- });
- // node_modules/mongodb/lib/cmap/connect.js
- var require_connect = __commonJS({
- "node_modules/mongodb/lib/cmap/connect.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.LEGAL_TCP_SOCKET_OPTIONS = exports2.LEGAL_TLS_SOCKET_OPTIONS = exports2.prepareHandshakeDocument = exports2.connect = exports2.AUTH_PROVIDERS = void 0;
- var net = require("net");
- var socks_1 = require_build();
- var tls = require("tls");
- var constants_1 = require_constants2();
- var error_1 = require_error();
- var utils_1 = require_utils();
- var auth_provider_1 = require_auth_provider();
- var gssapi_1 = require_gssapi();
- var mongocr_1 = require_mongocr();
- var mongodb_aws_1 = require_mongodb_aws();
- var mongodb_oidc_1 = require_mongodb_oidc();
- var plain_1 = require_plain();
- var providers_1 = require_providers();
- var scram_1 = require_scram();
- var x509_1 = require_x509();
- var connection_1 = require_connection();
- var constants_2 = require_constants();
- exports2.AUTH_PROVIDERS = /* @__PURE__ */ new Map([
- [providers_1.AuthMechanism.MONGODB_AWS, new mongodb_aws_1.MongoDBAWS()],
- [providers_1.AuthMechanism.MONGODB_CR, new mongocr_1.MongoCR()],
- [providers_1.AuthMechanism.MONGODB_GSSAPI, new gssapi_1.GSSAPI()],
- [providers_1.AuthMechanism.MONGODB_OIDC, new mongodb_oidc_1.MongoDBOIDC()],
- [providers_1.AuthMechanism.MONGODB_PLAIN, new plain_1.Plain()],
- [providers_1.AuthMechanism.MONGODB_SCRAM_SHA1, new scram_1.ScramSHA1()],
- [providers_1.AuthMechanism.MONGODB_SCRAM_SHA256, new scram_1.ScramSHA256()],
- [providers_1.AuthMechanism.MONGODB_X509, new x509_1.X509()]
- ]);
- function connect(options, callback) {
- makeConnection({ ...options, existingSocket: void 0 }, (err, socket) => {
- if (err || !socket) {
- return callback(err);
- }
- let ConnectionType = options.connectionType ?? connection_1.Connection;
- if (options.autoEncrypter) {
- ConnectionType = connection_1.CryptoConnection;
- }
- const connection = new ConnectionType(socket, options);
- performInitialHandshake(connection, options).then(() => callback(void 0, connection), (error) => {
- connection.destroy({ force: false });
- callback(error);
- });
- });
- }
- exports2.connect = connect;
- function checkSupportedServer(hello, options) {
- const maxWireVersion = Number(hello.maxWireVersion);
- const minWireVersion = Number(hello.minWireVersion);
- const serverVersionHighEnough = !Number.isNaN(maxWireVersion) && maxWireVersion >= constants_2.MIN_SUPPORTED_WIRE_VERSION;
- const serverVersionLowEnough = !Number.isNaN(minWireVersion) && minWireVersion <= constants_2.MAX_SUPPORTED_WIRE_VERSION;
- if (serverVersionHighEnough) {
- if (serverVersionLowEnough) {
- return null;
- }
- const message2 = `Server at ${options.hostAddress} reports minimum wire version ${JSON.stringify(hello.minWireVersion)}, but this version of the Node.js Driver requires at most ${constants_2.MAX_SUPPORTED_WIRE_VERSION} (MongoDB ${constants_2.MAX_SUPPORTED_SERVER_VERSION})`;
- return new error_1.MongoCompatibilityError(message2);
- }
- const message = `Server at ${options.hostAddress} reports maximum wire version ${JSON.stringify(hello.maxWireVersion) ?? 0}, but this version of the Node.js Driver requires at least ${constants_2.MIN_SUPPORTED_WIRE_VERSION} (MongoDB ${constants_2.MIN_SUPPORTED_SERVER_VERSION})`;
- return new error_1.MongoCompatibilityError(message);
- }
- async function performInitialHandshake(conn, options) {
- const credentials = options.credentials;
- if (credentials) {
- if (!(credentials.mechanism === providers_1.AuthMechanism.MONGODB_DEFAULT) && !exports2.AUTH_PROVIDERS.get(credentials.mechanism)) {
- throw new error_1.MongoInvalidArgumentError(`AuthMechanism '${credentials.mechanism}' not supported`);
- }
- }
- const authContext = new auth_provider_1.AuthContext(conn, credentials, options);
- conn.authContext = authContext;
- const handshakeDoc = await prepareHandshakeDocument(authContext);
- const handshakeOptions = { ...options };
- if (typeof options.connectTimeoutMS === "number") {
- handshakeOptions.socketTimeoutMS = options.connectTimeoutMS;
- }
- const start = (/* @__PURE__ */ new Date()).getTime();
- const response = await conn.commandAsync((0, utils_1.ns)("admin.$cmd"), handshakeDoc, handshakeOptions);
- if (!("isWritablePrimary" in response)) {
- response.isWritablePrimary = response[constants_1.LEGACY_HELLO_COMMAND];
- }
- if (response.helloOk) {
- conn.helloOk = true;
- }
- const supportedServerErr = checkSupportedServer(response, options);
- if (supportedServerErr) {
- throw supportedServerErr;
- }
- if (options.loadBalanced) {
- if (!response.serviceId) {
- throw new error_1.MongoCompatibilityError("Driver attempted to initialize in load balancing mode, but the server does not support this mode.");
- }
- }
- conn.hello = response;
- conn.lastHelloMS = (/* @__PURE__ */ new Date()).getTime() - start;
- if (!response.arbiterOnly && credentials) {
- authContext.response = response;
- const resolvedCredentials = credentials.resolveAuthMechanism(response);
- const provider = exports2.AUTH_PROVIDERS.get(resolvedCredentials.mechanism);
- if (!provider) {
- throw new error_1.MongoInvalidArgumentError(`No AuthProvider for ${resolvedCredentials.mechanism} defined.`);
- }
- try {
- await provider.auth(authContext);
- } catch (error) {
- if (error instanceof error_1.MongoError) {
- error.addErrorLabel(error_1.MongoErrorLabel.HandshakeError);
- if ((0, error_1.needsRetryableWriteLabel)(error, response.maxWireVersion)) {
- error.addErrorLabel(error_1.MongoErrorLabel.RetryableWriteError);
- }
- }
- throw error;
- }
- }
- }
- async function prepareHandshakeDocument(authContext) {
- const options = authContext.options;
- const compressors = options.compressors ? options.compressors : [];
- const { serverApi } = authContext.connection;
- const handshakeDoc = {
- [(serverApi == null ? void 0 : serverApi.version) ? "hello" : constants_1.LEGACY_HELLO_COMMAND]: 1,
- helloOk: true,
- client: options.metadata,
- compression: compressors
- };
- if (options.loadBalanced === true) {
- handshakeDoc.loadBalanced = true;
- }
- const credentials = authContext.credentials;
- if (credentials) {
- if (credentials.mechanism === providers_1.AuthMechanism.MONGODB_DEFAULT && credentials.username) {
- handshakeDoc.saslSupportedMechs = `${credentials.source}.${credentials.username}`;
- const provider2 = exports2.AUTH_PROVIDERS.get(providers_1.AuthMechanism.MONGODB_SCRAM_SHA256);
- if (!provider2) {
- throw new error_1.MongoInvalidArgumentError(`No AuthProvider for ${providers_1.AuthMechanism.MONGODB_SCRAM_SHA256} defined.`);
- }
- return provider2.prepare(handshakeDoc, authContext);
- }
- const provider = exports2.AUTH_PROVIDERS.get(credentials.mechanism);
- if (!provider) {
- throw new error_1.MongoInvalidArgumentError(`No AuthProvider for ${credentials.mechanism} defined.`);
- }
- return provider.prepare(handshakeDoc, authContext);
- }
- return handshakeDoc;
- }
- exports2.prepareHandshakeDocument = prepareHandshakeDocument;
- exports2.LEGAL_TLS_SOCKET_OPTIONS = [
- "ALPNProtocols",
- "ca",
- "cert",
- "checkServerIdentity",
- "ciphers",
- "crl",
- "ecdhCurve",
- "key",
- "minDHSize",
- "passphrase",
- "pfx",
- "rejectUnauthorized",
- "secureContext",
- "secureProtocol",
- "servername",
- "session"
- ];
- exports2.LEGAL_TCP_SOCKET_OPTIONS = [
- "family",
- "hints",
- "localAddress",
- "localPort",
- "lookup"
- ];
- function parseConnectOptions(options) {
- const hostAddress = options.hostAddress;
- if (!hostAddress)
- throw new error_1.MongoInvalidArgumentError('Option "hostAddress" is required');
- const result = {};
- for (const name of exports2.LEGAL_TCP_SOCKET_OPTIONS) {
- if (options[name] != null) {
- result[name] = options[name];
- }
- }
- if (typeof hostAddress.socketPath === "string") {
- result.path = hostAddress.socketPath;
- return result;
- } else if (typeof hostAddress.host === "string") {
- result.host = hostAddress.host;
- result.port = hostAddress.port;
- return result;
- } else {
- throw new error_1.MongoRuntimeError(`Unexpected HostAddress ${JSON.stringify(hostAddress)}`);
- }
- }
- function parseSslOptions(options) {
- const result = parseConnectOptions(options);
- for (const name of exports2.LEGAL_TLS_SOCKET_OPTIONS) {
- if (options[name] != null) {
- result[name] = options[name];
- }
- }
- if (options.existingSocket) {
- result.socket = options.existingSocket;
- }
- if (result.servername == null && result.host && !net.isIP(result.host)) {
- result.servername = result.host;
- }
- return result;
- }
- var SOCKET_ERROR_EVENT_LIST = ["error", "close", "timeout", "parseError"];
- var SOCKET_ERROR_EVENTS = new Set(SOCKET_ERROR_EVENT_LIST);
- function makeConnection(options, _callback) {
- const useTLS = options.tls ?? false;
- const keepAlive = options.keepAlive ?? true;
- const socketTimeoutMS = options.socketTimeoutMS ?? Reflect.get(options, "socketTimeout") ?? 0;
- const noDelay = options.noDelay ?? true;
- const connectTimeoutMS = options.connectTimeoutMS ?? 3e4;
- const rejectUnauthorized = options.rejectUnauthorized ?? true;
- const keepAliveInitialDelay = ((options.keepAliveInitialDelay ?? 12e4) > socketTimeoutMS ? Math.round(socketTimeoutMS / 2) : options.keepAliveInitialDelay) ?? 12e4;
- const existingSocket = options.existingSocket;
- let socket;
- const callback = function(err, ret) {
- if (err && socket) {
- socket.destroy();
- }
- _callback(err, ret);
- };
- if (options.proxyHost != null) {
- return makeSocks5Connection({
- ...options,
- connectTimeoutMS
- // Should always be present for Socks5
- }, callback);
- }
- if (useTLS) {
- const tlsSocket = tls.connect(parseSslOptions(options));
- if (typeof tlsSocket.disableRenegotiation === "function") {
- tlsSocket.disableRenegotiation();
- }
- socket = tlsSocket;
- } else if (existingSocket) {
- socket = existingSocket;
- } else {
- socket = net.createConnection(parseConnectOptions(options));
- }
- socket.setKeepAlive(keepAlive, keepAliveInitialDelay);
- socket.setTimeout(connectTimeoutMS);
- socket.setNoDelay(noDelay);
- const connectEvent = useTLS ? "secureConnect" : "connect";
- let cancellationHandler;
- function errorHandler(eventName) {
- return (err) => {
- SOCKET_ERROR_EVENTS.forEach((event) => socket.removeAllListeners(event));
- if (cancellationHandler && options.cancellationToken) {
- options.cancellationToken.removeListener("cancel", cancellationHandler);
- }
- socket.removeListener(connectEvent, connectHandler);
- callback(connectionFailureError(eventName, err));
- };
- }
- function connectHandler() {
- SOCKET_ERROR_EVENTS.forEach((event) => socket.removeAllListeners(event));
- if (cancellationHandler && options.cancellationToken) {
- options.cancellationToken.removeListener("cancel", cancellationHandler);
- }
- if ("authorizationError" in socket) {
- if (socket.authorizationError && rejectUnauthorized) {
- return callback(socket.authorizationError);
- }
- }
- socket.setTimeout(0);
- callback(void 0, socket);
- }
- SOCKET_ERROR_EVENTS.forEach((event) => socket.once(event, errorHandler(event)));
- if (options.cancellationToken) {
- cancellationHandler = errorHandler("cancel");
- options.cancellationToken.once("cancel", cancellationHandler);
- }
- if (existingSocket) {
- process.nextTick(connectHandler);
- } else {
- socket.once(connectEvent, connectHandler);
- }
- }
- function makeSocks5Connection(options, callback) {
- const hostAddress = utils_1.HostAddress.fromHostPort(
- options.proxyHost ?? "",
- // proxyHost is guaranteed to set here
- options.proxyPort ?? 1080
- );
- makeConnection({
- ...options,
- hostAddress,
- tls: false,
- proxyHost: void 0
- }, (err, rawSocket) => {
- if (err) {
- return callback(err);
- }
- const destination = parseConnectOptions(options);
- if (typeof destination.host !== "string" || typeof destination.port !== "number") {
- return callback(new error_1.MongoInvalidArgumentError("Can only make Socks5 connections to TCP hosts"));
- }
- socks_1.SocksClient.createConnection({
- existing_socket: rawSocket,
- timeout: options.connectTimeoutMS,
- command: "connect",
- destination: {
- host: destination.host,
- port: destination.port
- },
- proxy: {
- // host and port are ignored because we pass existing_socket
- host: "iLoveJavaScript",
- port: 0,
- type: 5,
- userId: options.proxyUsername || void 0,
- password: options.proxyPassword || void 0
- }
- }).then(({ socket }) => {
- makeConnection({
- ...options,
- existingSocket: socket,
- proxyHost: void 0
- }, callback);
- }, (error) => callback(connectionFailureError("error", error)));
- });
- }
- function connectionFailureError(type, err) {
- switch (type) {
- case "error":
- return new error_1.MongoNetworkError(err);
- case "timeout":
- return new error_1.MongoNetworkTimeoutError("connection timed out");
- case "close":
- return new error_1.MongoNetworkError("connection closed");
- case "cancel":
- return new error_1.MongoNetworkError("connection establishment was cancelled");
- default:
- return new error_1.MongoNetworkError("unknown network error");
- }
- }
- }
- });
- // node_modules/mongodb/lib/cmap/connection_pool_events.js
- var require_connection_pool_events = __commonJS({
- "node_modules/mongodb/lib/cmap/connection_pool_events.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ConnectionPoolClearedEvent = exports2.ConnectionCheckedInEvent = exports2.ConnectionCheckedOutEvent = exports2.ConnectionCheckOutFailedEvent = exports2.ConnectionCheckOutStartedEvent = exports2.ConnectionClosedEvent = exports2.ConnectionReadyEvent = exports2.ConnectionCreatedEvent = exports2.ConnectionPoolClosedEvent = exports2.ConnectionPoolReadyEvent = exports2.ConnectionPoolCreatedEvent = exports2.ConnectionPoolMonitoringEvent = void 0;
- var constants_1 = require_constants2();
- var ConnectionPoolMonitoringEvent = class {
- /** @internal */
- constructor(pool) {
- this.time = /* @__PURE__ */ new Date();
- this.address = pool.address;
- }
- };
- exports2.ConnectionPoolMonitoringEvent = ConnectionPoolMonitoringEvent;
- var ConnectionPoolCreatedEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool) {
- super(pool);
- this.name = constants_1.CONNECTION_POOL_CREATED;
- if (pool.options.credentials != null) {
- this.options = { ...pool.options, credentials: {} };
- } else {
- this.options = pool.options;
- }
- }
- };
- exports2.ConnectionPoolCreatedEvent = ConnectionPoolCreatedEvent;
- var ConnectionPoolReadyEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool) {
- super(pool);
- this.name = constants_1.CONNECTION_POOL_READY;
- }
- };
- exports2.ConnectionPoolReadyEvent = ConnectionPoolReadyEvent;
- var ConnectionPoolClosedEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool) {
- super(pool);
- this.name = constants_1.CONNECTION_POOL_CLOSED;
- }
- };
- exports2.ConnectionPoolClosedEvent = ConnectionPoolClosedEvent;
- var ConnectionCreatedEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool, connection) {
- super(pool);
- this.name = constants_1.CONNECTION_CREATED;
- this.connectionId = connection.id;
- }
- };
- exports2.ConnectionCreatedEvent = ConnectionCreatedEvent;
- var ConnectionReadyEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool, connection) {
- super(pool);
- this.name = constants_1.CONNECTION_READY;
- this.connectionId = connection.id;
- }
- };
- exports2.ConnectionReadyEvent = ConnectionReadyEvent;
- var ConnectionClosedEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool, connection, reason, error) {
- super(pool);
- this.name = constants_1.CONNECTION_CLOSED;
- this.connectionId = connection.id;
- this.reason = reason;
- this.serviceId = connection.serviceId;
- this.error = error ?? null;
- }
- };
- exports2.ConnectionClosedEvent = ConnectionClosedEvent;
- var ConnectionCheckOutStartedEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool) {
- super(pool);
- this.name = constants_1.CONNECTION_CHECK_OUT_STARTED;
- }
- };
- exports2.ConnectionCheckOutStartedEvent = ConnectionCheckOutStartedEvent;
- var ConnectionCheckOutFailedEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool, reason, error) {
- super(pool);
- this.name = constants_1.CONNECTION_CHECK_OUT_FAILED;
- this.reason = reason;
- this.error = error;
- }
- };
- exports2.ConnectionCheckOutFailedEvent = ConnectionCheckOutFailedEvent;
- var ConnectionCheckedOutEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool, connection) {
- super(pool);
- this.name = constants_1.CONNECTION_CHECKED_OUT;
- this.connectionId = connection.id;
- }
- };
- exports2.ConnectionCheckedOutEvent = ConnectionCheckedOutEvent;
- var ConnectionCheckedInEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool, connection) {
- super(pool);
- this.name = constants_1.CONNECTION_CHECKED_IN;
- this.connectionId = connection.id;
- }
- };
- exports2.ConnectionCheckedInEvent = ConnectionCheckedInEvent;
- var ConnectionPoolClearedEvent = class extends ConnectionPoolMonitoringEvent {
- /** @internal */
- constructor(pool, options = {}) {
- super(pool);
- this.name = constants_1.CONNECTION_POOL_CLEARED;
- this.serviceId = options.serviceId;
- this.interruptInUseConnections = options.interruptInUseConnections;
- }
- };
- exports2.ConnectionPoolClearedEvent = ConnectionPoolClearedEvent;
- }
- });
- // node_modules/mongodb/lib/cmap/errors.js
- var require_errors = __commonJS({
- "node_modules/mongodb/lib/cmap/errors.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.WaitQueueTimeoutError = exports2.PoolClearedOnNetworkError = exports2.PoolClearedError = exports2.PoolClosedError = void 0;
- var error_1 = require_error();
- var PoolClosedError = class extends error_1.MongoDriverError {
- constructor(pool) {
- super("Attempted to check out a connection from closed connection pool");
- this.address = pool.address;
- }
- get name() {
- return "MongoPoolClosedError";
- }
- };
- exports2.PoolClosedError = PoolClosedError;
- var PoolClearedError = class extends error_1.MongoNetworkError {
- constructor(pool, message) {
- var _a;
- const errorMessage = message ? message : `Connection pool for ${pool.address} was cleared because another operation failed with: "${(_a = pool.serverError) == null ? void 0 : _a.message}"`;
- super(errorMessage);
- this.address = pool.address;
- this.addErrorLabel(error_1.MongoErrorLabel.RetryableWriteError);
- }
- get name() {
- return "MongoPoolClearedError";
- }
- };
- exports2.PoolClearedError = PoolClearedError;
- var PoolClearedOnNetworkError = class extends PoolClearedError {
- constructor(pool) {
- super(pool, `Connection to ${pool.address} interrupted due to server monitor timeout`);
- }
- get name() {
- return "PoolClearedOnNetworkError";
- }
- };
- exports2.PoolClearedOnNetworkError = PoolClearedOnNetworkError;
- var WaitQueueTimeoutError = class extends error_1.MongoDriverError {
- constructor(message, address) {
- super(message);
- this.address = address;
- }
- get name() {
- return "MongoWaitQueueTimeoutError";
- }
- };
- exports2.WaitQueueTimeoutError = WaitQueueTimeoutError;
- }
- });
- // node_modules/mongodb/lib/cmap/connection_pool.js
- var require_connection_pool = __commonJS({
- "node_modules/mongodb/lib/cmap/connection_pool.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ConnectionPool = exports2.PoolState = void 0;
- var timers_1 = require("timers");
- var constants_1 = require_constants2();
- var error_1 = require_error();
- var mongo_types_1 = require_mongo_types();
- var utils_1 = require_utils();
- var connect_1 = require_connect();
- var connection_1 = require_connection();
- var connection_pool_events_1 = require_connection_pool_events();
- var errors_1 = require_errors();
- var metrics_1 = require_metrics();
- var kServer = Symbol("server");
- var kConnections = Symbol("connections");
- var kPending = Symbol("pending");
- var kCheckedOut = Symbol("checkedOut");
- var kMinPoolSizeTimer = Symbol("minPoolSizeTimer");
- var kGeneration = Symbol("generation");
- var kServiceGenerations = Symbol("serviceGenerations");
- var kConnectionCounter = Symbol("connectionCounter");
- var kCancellationToken = Symbol("cancellationToken");
- var kWaitQueue = Symbol("waitQueue");
- var kCancelled = Symbol("cancelled");
- var kMetrics = Symbol("metrics");
- var kProcessingWaitQueue = Symbol("processingWaitQueue");
- var kPoolState = Symbol("poolState");
- exports2.PoolState = Object.freeze({
- paused: "paused",
- ready: "ready",
- closed: "closed"
- });
- var ConnectionPool = class _ConnectionPool extends mongo_types_1.TypedEventEmitter {
- constructor(server, options) {
- super();
- this.options = Object.freeze({
- ...options,
- connectionType: connection_1.Connection,
- maxPoolSize: options.maxPoolSize ?? 100,
- minPoolSize: options.minPoolSize ?? 0,
- maxConnecting: options.maxConnecting ?? 2,
- maxIdleTimeMS: options.maxIdleTimeMS ?? 0,
- waitQueueTimeoutMS: options.waitQueueTimeoutMS ?? 0,
- minPoolSizeCheckFrequencyMS: options.minPoolSizeCheckFrequencyMS ?? 100,
- autoEncrypter: options.autoEncrypter,
- metadata: options.metadata
- });
- if (this.options.minPoolSize > this.options.maxPoolSize) {
- throw new error_1.MongoInvalidArgumentError("Connection pool minimum size must not be greater than maximum pool size");
- }
- this[kPoolState] = exports2.PoolState.paused;
- this[kServer] = server;
- this[kConnections] = new utils_1.List();
- this[kPending] = 0;
- this[kCheckedOut] = /* @__PURE__ */ new Set();
- this[kMinPoolSizeTimer] = void 0;
- this[kGeneration] = 0;
- this[kServiceGenerations] = /* @__PURE__ */ new Map();
- this[kConnectionCounter] = (0, utils_1.makeCounter)(1);
- this[kCancellationToken] = new mongo_types_1.CancellationToken();
- this[kCancellationToken].setMaxListeners(Infinity);
- this[kWaitQueue] = new utils_1.List();
- this[kMetrics] = new metrics_1.ConnectionPoolMetrics();
- this[kProcessingWaitQueue] = false;
- this.mongoLogger = this[kServer].topology.client.mongoLogger;
- this.component = "connection";
- process.nextTick(() => {
- this.emitAndLog(_ConnectionPool.CONNECTION_POOL_CREATED, new connection_pool_events_1.ConnectionPoolCreatedEvent(this));
- });
- }
- /** The address of the endpoint the pool is connected to */
- get address() {
- return this.options.hostAddress.toString();
- }
- /**
- * Check if the pool has been closed
- *
- * TODO(NODE-3263): We can remove this property once shell no longer needs it
- */
- get closed() {
- return this[kPoolState] === exports2.PoolState.closed;
- }
- /** An integer representing the SDAM generation of the pool */
- get generation() {
- return this[kGeneration];
- }
- /** An integer expressing how many total connections (available + pending + in use) the pool currently has */
- get totalConnectionCount() {
- return this.availableConnectionCount + this.pendingConnectionCount + this.currentCheckedOutCount;
- }
- /** An integer expressing how many connections are currently available in the pool. */
- get availableConnectionCount() {
- return this[kConnections].length;
- }
- get pendingConnectionCount() {
- return this[kPending];
- }
- get currentCheckedOutCount() {
- return this[kCheckedOut].size;
- }
- get waitQueueSize() {
- return this[kWaitQueue].length;
- }
- get loadBalanced() {
- return this.options.loadBalanced;
- }
- get serviceGenerations() {
- return this[kServiceGenerations];
- }
- get serverError() {
- return this[kServer].description.error;
- }
- /**
- * This is exposed ONLY for use in mongosh, to enable
- * killing all connections if a user quits the shell with
- * operations in progress.
- *
- * This property may be removed as a part of NODE-3263.
- */
- get checkedOutConnections() {
- return this[kCheckedOut];
- }
- /**
- * Get the metrics information for the pool when a wait queue timeout occurs.
- */
- waitQueueErrorMetrics() {
- return this[kMetrics].info(this.options.maxPoolSize);
- }
- /**
- * Set the pool state to "ready"
- */
- ready() {
- if (this[kPoolState] !== exports2.PoolState.paused) {
- return;
- }
- this[kPoolState] = exports2.PoolState.ready;
- this.emitAndLog(_ConnectionPool.CONNECTION_POOL_READY, new connection_pool_events_1.ConnectionPoolReadyEvent(this));
- (0, timers_1.clearTimeout)(this[kMinPoolSizeTimer]);
- this.ensureMinPoolSize();
- }
- /**
- * Check a connection out of this pool. The connection will continue to be tracked, but no reference to it
- * will be held by the pool. This means that if a connection is checked out it MUST be checked back in or
- * explicitly destroyed by the new owner.
- */
- checkOut(callback) {
- this.emitAndLog(_ConnectionPool.CONNECTION_CHECK_OUT_STARTED, new connection_pool_events_1.ConnectionCheckOutStartedEvent(this));
- const waitQueueMember = { callback };
- const waitQueueTimeoutMS = this.options.waitQueueTimeoutMS;
- if (waitQueueTimeoutMS) {
- waitQueueMember.timer = (0, timers_1.setTimeout)(() => {
- waitQueueMember[kCancelled] = true;
- waitQueueMember.timer = void 0;
- this.emitAndLog(_ConnectionPool.CONNECTION_CHECK_OUT_FAILED, new connection_pool_events_1.ConnectionCheckOutFailedEvent(this, "timeout"));
- waitQueueMember.callback(new errors_1.WaitQueueTimeoutError(this.loadBalanced ? this.waitQueueErrorMetrics() : "Timed out while checking out a connection from connection pool", this.address));
- }, waitQueueTimeoutMS);
- }
- this[kWaitQueue].push(waitQueueMember);
- process.nextTick(() => this.processWaitQueue());
- }
- /**
- * Check a connection into the pool.
- *
- * @param connection - The connection to check in
- */
- checkIn(connection) {
- if (!this[kCheckedOut].has(connection)) {
- return;
- }
- const poolClosed = this.closed;
- const stale = this.connectionIsStale(connection);
- const willDestroy = !!(poolClosed || stale || connection.closed);
- if (!willDestroy) {
- connection.markAvailable();
- this[kConnections].unshift(connection);
- }
- this[kCheckedOut].delete(connection);
- this.emitAndLog(_ConnectionPool.CONNECTION_CHECKED_IN, new connection_pool_events_1.ConnectionCheckedInEvent(this, connection));
- if (willDestroy) {
- const reason = connection.closed ? "error" : poolClosed ? "poolClosed" : "stale";
- this.destroyConnection(connection, reason);
- }
- process.nextTick(() => this.processWaitQueue());
- }
- /**
- * Clear the pool
- *
- * Pool reset is handled by incrementing the pool's generation count. Any existing connection of a
- * previous generation will eventually be pruned during subsequent checkouts.
- */
- clear(options = {}) {
- if (this.closed) {
- return;
- }
- if (this.loadBalanced) {
- const { serviceId } = options;
- if (!serviceId) {
- throw new error_1.MongoRuntimeError("ConnectionPool.clear() called in load balanced mode with no serviceId.");
- }
- const sid = serviceId.toHexString();
- const generation = this.serviceGenerations.get(sid);
- if (generation == null) {
- throw new error_1.MongoRuntimeError("Service generations are required in load balancer mode.");
- } else {
- this.serviceGenerations.set(sid, generation + 1);
- }
- this.emitAndLog(_ConnectionPool.CONNECTION_POOL_CLEARED, new connection_pool_events_1.ConnectionPoolClearedEvent(this, { serviceId }));
- return;
- }
- const interruptInUseConnections = options.interruptInUseConnections ?? false;
- const oldGeneration = this[kGeneration];
- this[kGeneration] += 1;
- const alreadyPaused = this[kPoolState] === exports2.PoolState.paused;
- this[kPoolState] = exports2.PoolState.paused;
- this.clearMinPoolSizeTimer();
- if (!alreadyPaused) {
- this.emitAndLog(_ConnectionPool.CONNECTION_POOL_CLEARED, new connection_pool_events_1.ConnectionPoolClearedEvent(this, {
- interruptInUseConnections
- }));
- }
- if (interruptInUseConnections) {
- process.nextTick(() => this.interruptInUseConnections(oldGeneration));
- }
- this.processWaitQueue();
- }
- /**
- * Closes all stale in-use connections in the pool with a resumable PoolClearedOnNetworkError.
- *
- * Only connections where `connection.generation <= minGeneration` are killed.
- */
- interruptInUseConnections(minGeneration) {
- for (const connection of this[kCheckedOut]) {
- if (connection.generation <= minGeneration) {
- this.checkIn(connection);
- connection.onError(new errors_1.PoolClearedOnNetworkError(this));
- }
- }
- }
- close(_options, _cb) {
- let options = _options;
- const callback = _cb ?? _options;
- if (typeof options === "function") {
- options = {};
- }
- options = Object.assign({ force: false }, options);
- if (this.closed) {
- return callback();
- }
- this[kCancellationToken].emit("cancel");
- if (typeof this[kConnectionCounter].return === "function") {
- this[kConnectionCounter].return(void 0);
- }
- this[kPoolState] = exports2.PoolState.closed;
- this.clearMinPoolSizeTimer();
- this.processWaitQueue();
- (0, utils_1.eachAsync)(this[kConnections].toArray(), (conn, cb) => {
- this.emitAndLog(_ConnectionPool.CONNECTION_CLOSED, new connection_pool_events_1.ConnectionClosedEvent(this, conn, "poolClosed"));
- conn.destroy({ force: !!options.force }, cb);
- }, (err) => {
- this[kConnections].clear();
- this.emitAndLog(_ConnectionPool.CONNECTION_POOL_CLOSED, new connection_pool_events_1.ConnectionPoolClosedEvent(this));
- callback(err);
- });
- }
- /**
- * Runs a lambda with an implicitly checked out connection, checking that connection back in when the lambda
- * has completed by calling back.
- *
- * NOTE: please note the required signature of `fn`
- *
- * @remarks When in load balancer mode, connections can be pinned to cursors or transactions.
- * In these cases we pass the connection in to this method to ensure it is used and a new
- * connection is not checked out.
- *
- * @param conn - A pinned connection for use in load balancing mode.
- * @param fn - A function which operates on a managed connection
- * @param callback - The original callback
- */
- withConnection(conn, fn, callback) {
- if (conn) {
- fn(void 0, conn, (fnErr, result) => {
- if (fnErr) {
- return this.withReauthentication(fnErr, conn, fn, callback);
- }
- callback(void 0, result);
- });
- return;
- }
- this.checkOut((err, conn2) => {
- fn(err, conn2, (fnErr, result) => {
- if (fnErr) {
- if (conn2) {
- this.withReauthentication(fnErr, conn2, fn, callback);
- } else {
- callback(fnErr);
- }
- } else {
- callback(void 0, result);
- }
- if (conn2) {
- this.checkIn(conn2);
- }
- });
- });
- }
- withReauthentication(fnErr, conn, fn, callback) {
- if (fnErr instanceof error_1.MongoError && fnErr.code === error_1.MONGODB_ERROR_CODES.Reauthenticate) {
- this.reauthenticate(conn, fn, (error, res) => {
- if (error) {
- return callback(error);
- }
- callback(void 0, res);
- });
- } else {
- callback(fnErr);
- }
- }
- /**
- * Reauthenticate on the same connection and then retry the operation.
- */
- reauthenticate(connection, fn, callback) {
- const authContext = connection.authContext;
- if (!authContext) {
- return callback(new error_1.MongoRuntimeError("No auth context found on connection."));
- }
- const credentials = authContext.credentials;
- if (!credentials) {
- return callback(new error_1.MongoMissingCredentialsError("Connection is missing credentials when asked to reauthenticate"));
- }
- const resolvedCredentials = credentials.resolveAuthMechanism(connection.hello || void 0);
- const provider = connect_1.AUTH_PROVIDERS.get(resolvedCredentials.mechanism);
- if (!provider) {
- return callback(new error_1.MongoMissingCredentialsError(`Reauthenticate failed due to no auth provider for ${credentials.mechanism}`));
- }
- provider.reauth(authContext).then(() => {
- fn(void 0, connection, (fnErr, fnResult) => {
- if (fnErr) {
- return callback(fnErr);
- }
- callback(void 0, fnResult);
- });
- }, (error) => callback(error));
- }
- /** Clear the min pool size timer */
- clearMinPoolSizeTimer() {
- const minPoolSizeTimer = this[kMinPoolSizeTimer];
- if (minPoolSizeTimer) {
- (0, timers_1.clearTimeout)(minPoolSizeTimer);
- }
- }
- destroyConnection(connection, reason) {
- this.emitAndLog(_ConnectionPool.CONNECTION_CLOSED, new connection_pool_events_1.ConnectionClosedEvent(this, connection, reason));
- process.nextTick(() => connection.destroy({ force: false }));
- }
- connectionIsStale(connection) {
- const serviceId = connection.serviceId;
- if (this.loadBalanced && serviceId) {
- const sid = serviceId.toHexString();
- const generation = this.serviceGenerations.get(sid);
- return connection.generation !== generation;
- }
- return connection.generation !== this[kGeneration];
- }
- connectionIsIdle(connection) {
- return !!(this.options.maxIdleTimeMS && connection.idleTime > this.options.maxIdleTimeMS);
- }
- /**
- * Destroys a connection if the connection is perished.
- *
- * @returns `true` if the connection was destroyed, `false` otherwise.
- */
- destroyConnectionIfPerished(connection) {
- const isStale = this.connectionIsStale(connection);
- const isIdle = this.connectionIsIdle(connection);
- if (!isStale && !isIdle && !connection.closed) {
- return false;
- }
- const reason = connection.closed ? "error" : isStale ? "stale" : "idle";
- this.destroyConnection(connection, reason);
- return true;
- }
- createConnection(callback) {
- const connectOptions = {
- ...this.options,
- id: this[kConnectionCounter].next().value,
- generation: this[kGeneration],
- cancellationToken: this[kCancellationToken]
- };
- this[kPending]++;
- this.emitAndLog(_ConnectionPool.CONNECTION_CREATED, new connection_pool_events_1.ConnectionCreatedEvent(this, { id: connectOptions.id }));
- (0, connect_1.connect)(connectOptions, (err, connection) => {
- if (err || !connection) {
- this[kPending]--;
- this.emitAndLog(_ConnectionPool.CONNECTION_CLOSED, new connection_pool_events_1.ConnectionClosedEvent(
- this,
- { id: connectOptions.id, serviceId: void 0 },
- "error",
- // TODO(NODE-5192): Remove this cast
- err
- ));
- if (err instanceof error_1.MongoNetworkError || err instanceof error_1.MongoServerError) {
- err.connectionGeneration = connectOptions.generation;
- }
- callback(err ?? new error_1.MongoRuntimeError("Connection creation failed without error"));
- return;
- }
- if (this[kPoolState] !== exports2.PoolState.ready) {
- this[kPending]--;
- connection.destroy({ force: true });
- callback(this.closed ? new errors_1.PoolClosedError(this) : new errors_1.PoolClearedError(this));
- return;
- }
- for (const event of [...constants_1.APM_EVENTS, connection_1.Connection.CLUSTER_TIME_RECEIVED]) {
- connection.on(event, (e) => this.emit(event, e));
- }
- if (this.loadBalanced) {
- connection.on(connection_1.Connection.PINNED, (pinType) => this[kMetrics].markPinned(pinType));
- connection.on(connection_1.Connection.UNPINNED, (pinType) => this[kMetrics].markUnpinned(pinType));
- const serviceId = connection.serviceId;
- if (serviceId) {
- let generation;
- const sid = serviceId.toHexString();
- if (generation = this.serviceGenerations.get(sid)) {
- connection.generation = generation;
- } else {
- this.serviceGenerations.set(sid, 0);
- connection.generation = 0;
- }
- }
- }
- connection.markAvailable();
- this.emitAndLog(_ConnectionPool.CONNECTION_READY, new connection_pool_events_1.ConnectionReadyEvent(this, connection));
- this[kPending]--;
- callback(void 0, connection);
- return;
- });
- }
- ensureMinPoolSize() {
- const minPoolSize = this.options.minPoolSize;
- if (this[kPoolState] !== exports2.PoolState.ready || minPoolSize === 0) {
- return;
- }
- this[kConnections].prune((connection) => this.destroyConnectionIfPerished(connection));
- if (this.totalConnectionCount < minPoolSize && this.pendingConnectionCount < this.options.maxConnecting) {
- this.createConnection((err, connection) => {
- if (err) {
- this[kServer].handleError(err);
- }
- if (!err && connection) {
- this[kConnections].push(connection);
- process.nextTick(() => this.processWaitQueue());
- }
- if (this[kPoolState] === exports2.PoolState.ready) {
- (0, timers_1.clearTimeout)(this[kMinPoolSizeTimer]);
- this[kMinPoolSizeTimer] = (0, timers_1.setTimeout)(() => this.ensureMinPoolSize(), this.options.minPoolSizeCheckFrequencyMS);
- }
- });
- } else {
- (0, timers_1.clearTimeout)(this[kMinPoolSizeTimer]);
- this[kMinPoolSizeTimer] = (0, timers_1.setTimeout)(() => this.ensureMinPoolSize(), this.options.minPoolSizeCheckFrequencyMS);
- }
- }
- processWaitQueue() {
- if (this[kProcessingWaitQueue]) {
- return;
- }
- this[kProcessingWaitQueue] = true;
- while (this.waitQueueSize) {
- const waitQueueMember = this[kWaitQueue].first();
- if (!waitQueueMember) {
- this[kWaitQueue].shift();
- continue;
- }
- if (waitQueueMember[kCancelled]) {
- this[kWaitQueue].shift();
- continue;
- }
- if (this[kPoolState] !== exports2.PoolState.ready) {
- const reason = this.closed ? "poolClosed" : "connectionError";
- const error = this.closed ? new errors_1.PoolClosedError(this) : new errors_1.PoolClearedError(this);
- this.emitAndLog(_ConnectionPool.CONNECTION_CHECK_OUT_FAILED, new connection_pool_events_1.ConnectionCheckOutFailedEvent(this, reason, error));
- if (waitQueueMember.timer) {
- (0, timers_1.clearTimeout)(waitQueueMember.timer);
- }
- this[kWaitQueue].shift();
- waitQueueMember.callback(error);
- continue;
- }
- if (!this.availableConnectionCount) {
- break;
- }
- const connection = this[kConnections].shift();
- if (!connection) {
- break;
- }
- if (!this.destroyConnectionIfPerished(connection)) {
- this[kCheckedOut].add(connection);
- this.emitAndLog(_ConnectionPool.CONNECTION_CHECKED_OUT, new connection_pool_events_1.ConnectionCheckedOutEvent(this, connection));
- if (waitQueueMember.timer) {
- (0, timers_1.clearTimeout)(waitQueueMember.timer);
- }
- this[kWaitQueue].shift();
- waitQueueMember.callback(void 0, connection);
- }
- }
- const { maxPoolSize, maxConnecting } = this.options;
- while (this.waitQueueSize > 0 && this.pendingConnectionCount < maxConnecting && (maxPoolSize === 0 || this.totalConnectionCount < maxPoolSize)) {
- const waitQueueMember = this[kWaitQueue].shift();
- if (!waitQueueMember || waitQueueMember[kCancelled]) {
- continue;
- }
- this.createConnection((err, connection) => {
- if (waitQueueMember[kCancelled]) {
- if (!err && connection) {
- this[kConnections].push(connection);
- }
- } else {
- if (err) {
- this.emitAndLog(
- _ConnectionPool.CONNECTION_CHECK_OUT_FAILED,
- // TODO(NODE-5192): Remove this cast
- new connection_pool_events_1.ConnectionCheckOutFailedEvent(this, "connectionError", err)
- );
- } else if (connection) {
- this[kCheckedOut].add(connection);
- this.emitAndLog(_ConnectionPool.CONNECTION_CHECKED_OUT, new connection_pool_events_1.ConnectionCheckedOutEvent(this, connection));
- }
- if (waitQueueMember.timer) {
- (0, timers_1.clearTimeout)(waitQueueMember.timer);
- }
- waitQueueMember.callback(err, connection);
- }
- process.nextTick(() => this.processWaitQueue());
- });
- }
- this[kProcessingWaitQueue] = false;
- }
- };
- ConnectionPool.CONNECTION_POOL_CREATED = constants_1.CONNECTION_POOL_CREATED;
- ConnectionPool.CONNECTION_POOL_CLOSED = constants_1.CONNECTION_POOL_CLOSED;
- ConnectionPool.CONNECTION_POOL_CLEARED = constants_1.CONNECTION_POOL_CLEARED;
- ConnectionPool.CONNECTION_POOL_READY = constants_1.CONNECTION_POOL_READY;
- ConnectionPool.CONNECTION_CREATED = constants_1.CONNECTION_CREATED;
- ConnectionPool.CONNECTION_READY = constants_1.CONNECTION_READY;
- ConnectionPool.CONNECTION_CLOSED = constants_1.CONNECTION_CLOSED;
- ConnectionPool.CONNECTION_CHECK_OUT_STARTED = constants_1.CONNECTION_CHECK_OUT_STARTED;
- ConnectionPool.CONNECTION_CHECK_OUT_FAILED = constants_1.CONNECTION_CHECK_OUT_FAILED;
- ConnectionPool.CONNECTION_CHECKED_OUT = constants_1.CONNECTION_CHECKED_OUT;
- ConnectionPool.CONNECTION_CHECKED_IN = constants_1.CONNECTION_CHECKED_IN;
- exports2.ConnectionPool = ConnectionPool;
- }
- });
- // node_modules/mongodb/lib/sdam/monitor.js
- var require_monitor = __commonJS({
- "node_modules/mongodb/lib/sdam/monitor.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.MonitorInterval = exports2.RTTPinger = exports2.Monitor = void 0;
- var timers_1 = require("timers");
- var bson_1 = require_bson2();
- var connect_1 = require_connect();
- var connection_1 = require_connection();
- var constants_1 = require_constants2();
- var error_1 = require_error();
- var mongo_types_1 = require_mongo_types();
- var utils_1 = require_utils();
- var common_1 = require_common();
- var events_1 = require_events();
- var server_1 = require_server();
- var kServer = Symbol("server");
- var kMonitorId = Symbol("monitorId");
- var kConnection = Symbol("connection");
- var kCancellationToken = Symbol("cancellationToken");
- var kRoundTripTime = Symbol("roundTripTime");
- var STATE_IDLE = "idle";
- var STATE_MONITORING = "monitoring";
- var stateTransition = (0, utils_1.makeStateMachine)({
- [common_1.STATE_CLOSING]: [common_1.STATE_CLOSING, STATE_IDLE, common_1.STATE_CLOSED],
- [common_1.STATE_CLOSED]: [common_1.STATE_CLOSED, STATE_MONITORING],
- [STATE_IDLE]: [STATE_IDLE, STATE_MONITORING, common_1.STATE_CLOSING],
- [STATE_MONITORING]: [STATE_MONITORING, STATE_IDLE, common_1.STATE_CLOSING]
- });
- var INVALID_REQUEST_CHECK_STATES = /* @__PURE__ */ new Set([common_1.STATE_CLOSING, common_1.STATE_CLOSED, STATE_MONITORING]);
- function isInCloseState(monitor) {
- return monitor.s.state === common_1.STATE_CLOSED || monitor.s.state === common_1.STATE_CLOSING;
- }
- var Monitor = class extends mongo_types_1.TypedEventEmitter {
- get connection() {
- return this[kConnection];
- }
- constructor(server, options) {
- super();
- this[kServer] = server;
- this[kConnection] = void 0;
- this[kCancellationToken] = new mongo_types_1.CancellationToken();
- this[kCancellationToken].setMaxListeners(Infinity);
- this[kMonitorId] = void 0;
- this.s = {
- state: common_1.STATE_CLOSED
- };
- this.address = server.description.address;
- this.options = Object.freeze({
- connectTimeoutMS: options.connectTimeoutMS ?? 1e4,
- heartbeatFrequencyMS: options.heartbeatFrequencyMS ?? 1e4,
- minHeartbeatFrequencyMS: options.minHeartbeatFrequencyMS ?? 500
- });
- const cancellationToken = this[kCancellationToken];
- const connectOptions = Object.assign(
- {
- id: "<monitor>",
- generation: server.pool.generation,
- connectionType: connection_1.Connection,
- cancellationToken,
- hostAddress: server.description.hostAddress
- },
- options,
- // force BSON serialization options
- {
- raw: false,
- useBigInt64: false,
- promoteLongs: true,
- promoteValues: true,
- promoteBuffers: true
- }
- );
- delete connectOptions.credentials;
- if (connectOptions.autoEncrypter) {
- delete connectOptions.autoEncrypter;
- }
- this.connectOptions = Object.freeze(connectOptions);
- }
- connect() {
- if (this.s.state !== common_1.STATE_CLOSED) {
- return;
- }
- const heartbeatFrequencyMS = this.options.heartbeatFrequencyMS;
- const minHeartbeatFrequencyMS = this.options.minHeartbeatFrequencyMS;
- this[kMonitorId] = new MonitorInterval(monitorServer(this), {
- heartbeatFrequencyMS,
- minHeartbeatFrequencyMS,
- immediate: true
- });
- }
- requestCheck() {
- var _a;
- if (INVALID_REQUEST_CHECK_STATES.has(this.s.state)) {
- return;
- }
- (_a = this[kMonitorId]) == null ? void 0 : _a.wake();
- }
- reset() {
- const topologyVersion = this[kServer].description.topologyVersion;
- if (isInCloseState(this) || topologyVersion == null) {
- return;
- }
- stateTransition(this, common_1.STATE_CLOSING);
- resetMonitorState(this);
- stateTransition(this, STATE_IDLE);
- const heartbeatFrequencyMS = this.options.heartbeatFrequencyMS;
- const minHeartbeatFrequencyMS = this.options.minHeartbeatFrequencyMS;
- this[kMonitorId] = new MonitorInterval(monitorServer(this), {
- heartbeatFrequencyMS,
- minHeartbeatFrequencyMS
- });
- }
- close() {
- if (isInCloseState(this)) {
- return;
- }
- stateTransition(this, common_1.STATE_CLOSING);
- resetMonitorState(this);
- this.emit("close");
- stateTransition(this, common_1.STATE_CLOSED);
- }
- };
- exports2.Monitor = Monitor;
- function resetMonitorState(monitor) {
- var _a, _b, _c;
- (_a = monitor[kMonitorId]) == null ? void 0 : _a.stop();
- monitor[kMonitorId] = void 0;
- (_b = monitor.rttPinger) == null ? void 0 : _b.close();
- monitor.rttPinger = void 0;
- monitor[kCancellationToken].emit("cancel");
- (_c = monitor[kConnection]) == null ? void 0 : _c.destroy({ force: true });
- monitor[kConnection] = void 0;
- }
- function checkServer(monitor, callback) {
- let start = (0, utils_1.now)();
- monitor.emit(server_1.Server.SERVER_HEARTBEAT_STARTED, new events_1.ServerHeartbeatStartedEvent(monitor.address));
- function failureHandler(err) {
- var _a;
- (_a = monitor[kConnection]) == null ? void 0 : _a.destroy({ force: true });
- monitor[kConnection] = void 0;
- monitor.emit(server_1.Server.SERVER_HEARTBEAT_FAILED, new events_1.ServerHeartbeatFailedEvent(monitor.address, (0, utils_1.calculateDurationInMs)(start), err));
- const error = !(err instanceof error_1.MongoError) ? new error_1.MongoError(err) : err;
- error.addErrorLabel(error_1.MongoErrorLabel.ResetPool);
- if (error instanceof error_1.MongoNetworkTimeoutError) {
- error.addErrorLabel(error_1.MongoErrorLabel.InterruptInUseConnections);
- }
- monitor.emit("resetServer", error);
- callback(err);
- }
- const connection = monitor[kConnection];
- if (connection && !connection.closed) {
- const { serverApi, helloOk } = connection;
- const connectTimeoutMS = monitor.options.connectTimeoutMS;
- const maxAwaitTimeMS = monitor.options.heartbeatFrequencyMS;
- const topologyVersion = monitor[kServer].description.topologyVersion;
- const isAwaitable = topologyVersion != null;
- const cmd = {
- [(serverApi == null ? void 0 : serverApi.version) || helloOk ? "hello" : constants_1.LEGACY_HELLO_COMMAND]: 1,
- ...isAwaitable && topologyVersion ? { maxAwaitTimeMS, topologyVersion: makeTopologyVersion(topologyVersion) } : {}
- };
- const options = isAwaitable ? {
- socketTimeoutMS: connectTimeoutMS ? connectTimeoutMS + maxAwaitTimeMS : 0,
- exhaustAllowed: true
- } : { socketTimeoutMS: connectTimeoutMS };
- if (isAwaitable && monitor.rttPinger == null) {
- monitor.rttPinger = new RTTPinger(monitor[kCancellationToken], Object.assign({ heartbeatFrequencyMS: monitor.options.heartbeatFrequencyMS }, monitor.connectOptions));
- }
- connection.command((0, utils_1.ns)("admin.$cmd"), cmd, options, (err, hello) => {
- var _a;
- if (err) {
- return failureHandler(err);
- }
- if (!("isWritablePrimary" in hello)) {
- hello.isWritablePrimary = hello[constants_1.LEGACY_HELLO_COMMAND];
- }
- const duration = isAwaitable && monitor.rttPinger ? monitor.rttPinger.roundTripTime : (0, utils_1.calculateDurationInMs)(start);
- monitor.emit(server_1.Server.SERVER_HEARTBEAT_SUCCEEDED, new events_1.ServerHeartbeatSucceededEvent(monitor.address, duration, hello));
- if (isAwaitable && hello.topologyVersion) {
- monitor.emit(server_1.Server.SERVER_HEARTBEAT_STARTED, new events_1.ServerHeartbeatStartedEvent(monitor.address));
- start = (0, utils_1.now)();
- } else {
- (_a = monitor.rttPinger) == null ? void 0 : _a.close();
- monitor.rttPinger = void 0;
- callback(void 0, hello);
- }
- });
- return;
- }
- (0, connect_1.connect)(monitor.connectOptions, (err, conn) => {
- if (err) {
- monitor[kConnection] = void 0;
- failureHandler(err);
- return;
- }
- if (conn) {
- conn.isMonitoringConnection = true;
- if (isInCloseState(monitor)) {
- conn.destroy({ force: true });
- return;
- }
- monitor[kConnection] = conn;
- monitor.emit(server_1.Server.SERVER_HEARTBEAT_SUCCEEDED, new events_1.ServerHeartbeatSucceededEvent(monitor.address, (0, utils_1.calculateDurationInMs)(start), conn.hello));
- callback(void 0, conn.hello);
- }
- });
- }
- function monitorServer(monitor) {
- return (callback) => {
- if (monitor.s.state === STATE_MONITORING) {
- process.nextTick(callback);
- return;
- }
- stateTransition(monitor, STATE_MONITORING);
- function done() {
- if (!isInCloseState(monitor)) {
- stateTransition(monitor, STATE_IDLE);
- }
- callback();
- }
- checkServer(monitor, (err, hello) => {
- if (err) {
- if (monitor[kServer].description.type === common_1.ServerType.Unknown) {
- return done();
- }
- }
- if (hello && hello.topologyVersion) {
- (0, timers_1.setTimeout)(() => {
- var _a;
- if (!isInCloseState(monitor)) {
- (_a = monitor[kMonitorId]) == null ? void 0 : _a.wake();
- }
- }, 0);
- }
- done();
- });
- };
- }
- function makeTopologyVersion(tv) {
- return {
- processId: tv.processId,
- // tests mock counter as just number, but in a real situation counter should always be a Long
- // TODO(NODE-2674): Preserve int64 sent from MongoDB
- counter: bson_1.Long.isLong(tv.counter) ? tv.counter : bson_1.Long.fromNumber(tv.counter)
- };
- }
- var RTTPinger = class {
- constructor(cancellationToken, options) {
- this.connection = void 0;
- this[kCancellationToken] = cancellationToken;
- this[kRoundTripTime] = 0;
- this.closed = false;
- const heartbeatFrequencyMS = options.heartbeatFrequencyMS;
- this[kMonitorId] = (0, timers_1.setTimeout)(() => measureRoundTripTime(this, options), heartbeatFrequencyMS);
- }
- get roundTripTime() {
- return this[kRoundTripTime];
- }
- close() {
- var _a;
- this.closed = true;
- (0, timers_1.clearTimeout)(this[kMonitorId]);
- (_a = this.connection) == null ? void 0 : _a.destroy({ force: true });
- this.connection = void 0;
- }
- };
- exports2.RTTPinger = RTTPinger;
- function measureRoundTripTime(rttPinger, options) {
- var _a;
- const start = (0, utils_1.now)();
- options.cancellationToken = rttPinger[kCancellationToken];
- const heartbeatFrequencyMS = options.heartbeatFrequencyMS;
- if (rttPinger.closed) {
- return;
- }
- function measureAndReschedule(conn) {
- if (rttPinger.closed) {
- conn == null ? void 0 : conn.destroy({ force: true });
- return;
- }
- if (rttPinger.connection == null) {
- rttPinger.connection = conn;
- }
- rttPinger[kRoundTripTime] = (0, utils_1.calculateDurationInMs)(start);
- rttPinger[kMonitorId] = (0, timers_1.setTimeout)(() => measureRoundTripTime(rttPinger, options), heartbeatFrequencyMS);
- }
- const connection = rttPinger.connection;
- if (connection == null) {
- (0, connect_1.connect)(options, (err, conn) => {
- if (err) {
- rttPinger.connection = void 0;
- rttPinger[kRoundTripTime] = 0;
- return;
- }
- measureAndReschedule(conn);
- });
- return;
- }
- const commandName = ((_a = connection.serverApi) == null ? void 0 : _a.version) || connection.helloOk ? "hello" : constants_1.LEGACY_HELLO_COMMAND;
- connection.commandAsync((0, utils_1.ns)("admin.$cmd"), { [commandName]: 1 }, void 0).then(() => measureAndReschedule(), () => {
- var _a2;
- (_a2 = rttPinger.connection) == null ? void 0 : _a2.destroy({ force: true });
- rttPinger.connection = void 0;
- rttPinger[kRoundTripTime] = 0;
- });
- }
- var MonitorInterval = class {
- constructor(fn, options = {}) {
- this.isExpeditedCallToFnScheduled = false;
- this.stopped = false;
- this.isExecutionInProgress = false;
- this.hasExecutedOnce = false;
- this._executeAndReschedule = () => {
- if (this.stopped)
- return;
- if (this.timerId) {
- (0, timers_1.clearTimeout)(this.timerId);
- }
- this.isExpeditedCallToFnScheduled = false;
- this.isExecutionInProgress = true;
- this.fn(() => {
- this.lastExecutionEnded = (0, utils_1.now)();
- this.isExecutionInProgress = false;
- this._reschedule(this.heartbeatFrequencyMS);
- });
- };
- this.fn = fn;
- this.lastExecutionEnded = -Infinity;
- this.heartbeatFrequencyMS = options.heartbeatFrequencyMS ?? 1e3;
- this.minHeartbeatFrequencyMS = options.minHeartbeatFrequencyMS ?? 500;
- if (options.immediate) {
- this._executeAndReschedule();
- } else {
- this._reschedule(void 0);
- }
- }
- wake() {
- const currentTime = (0, utils_1.now)();
- const timeSinceLastCall = currentTime - this.lastExecutionEnded;
- if (timeSinceLastCall < 0) {
- return this._executeAndReschedule();
- }
- if (this.isExecutionInProgress) {
- return;
- }
- if (this.isExpeditedCallToFnScheduled) {
- return;
- }
- if (timeSinceLastCall < this.minHeartbeatFrequencyMS) {
- this.isExpeditedCallToFnScheduled = true;
- this._reschedule(this.minHeartbeatFrequencyMS - timeSinceLastCall);
- return;
- }
- this._executeAndReschedule();
- }
- stop() {
- this.stopped = true;
- if (this.timerId) {
- (0, timers_1.clearTimeout)(this.timerId);
- this.timerId = void 0;
- }
- this.lastExecutionEnded = -Infinity;
- this.isExpeditedCallToFnScheduled = false;
- }
- toString() {
- return JSON.stringify(this);
- }
- toJSON() {
- const currentTime = (0, utils_1.now)();
- const timeSinceLastCall = currentTime - this.lastExecutionEnded;
- return {
- timerId: this.timerId != null ? "set" : "cleared",
- lastCallTime: this.lastExecutionEnded,
- isExpeditedCheckScheduled: this.isExpeditedCallToFnScheduled,
- stopped: this.stopped,
- heartbeatFrequencyMS: this.heartbeatFrequencyMS,
- minHeartbeatFrequencyMS: this.minHeartbeatFrequencyMS,
- currentTime,
- timeSinceLastCall
- };
- }
- _reschedule(ms) {
- if (this.stopped)
- return;
- if (this.timerId) {
- (0, timers_1.clearTimeout)(this.timerId);
- }
- this.timerId = (0, timers_1.setTimeout)(this._executeAndReschedule, ms || this.heartbeatFrequencyMS);
- }
- };
- exports2.MonitorInterval = MonitorInterval;
- }
- });
- // node_modules/mongodb/lib/sdam/server.js
- var require_server = __commonJS({
- "node_modules/mongodb/lib/sdam/server.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.Server = void 0;
- var util_1 = require("util");
- var connection_1 = require_connection();
- var connection_pool_1 = require_connection_pool();
- var errors_1 = require_errors();
- var constants_1 = require_constants2();
- var error_1 = require_error();
- var mongo_types_1 = require_mongo_types();
- var transactions_1 = require_transactions();
- var utils_1 = require_utils();
- var common_1 = require_common();
- var monitor_1 = require_monitor();
- var server_description_1 = require_server_description();
- var stateTransition = (0, utils_1.makeStateMachine)({
- [common_1.STATE_CLOSED]: [common_1.STATE_CLOSED, common_1.STATE_CONNECTING],
- [common_1.STATE_CONNECTING]: [common_1.STATE_CONNECTING, common_1.STATE_CLOSING, common_1.STATE_CONNECTED, common_1.STATE_CLOSED],
- [common_1.STATE_CONNECTED]: [common_1.STATE_CONNECTED, common_1.STATE_CLOSING, common_1.STATE_CLOSED],
- [common_1.STATE_CLOSING]: [common_1.STATE_CLOSING, common_1.STATE_CLOSED]
- });
- var Server = class _Server extends mongo_types_1.TypedEventEmitter {
- /**
- * Create a server
- */
- constructor(topology, description, options) {
- super();
- this.commandAsync = (0, util_1.promisify)((ns, cmd, options2, callback) => this.command(ns, cmd, options2, callback));
- this.serverApi = options.serverApi;
- const poolOptions = { hostAddress: description.hostAddress, ...options };
- this.topology = topology;
- this.pool = new connection_pool_1.ConnectionPool(this, poolOptions);
- this.s = {
- description,
- options,
- state: common_1.STATE_CLOSED,
- operationCount: 0
- };
- for (const event of [...constants_1.CMAP_EVENTS, ...constants_1.APM_EVENTS]) {
- this.pool.on(event, (e) => this.emit(event, e));
- }
- this.pool.on(connection_1.Connection.CLUSTER_TIME_RECEIVED, (clusterTime) => {
- this.clusterTime = clusterTime;
- });
- if (this.loadBalanced) {
- this.monitor = null;
- return;
- }
- this.monitor = new monitor_1.Monitor(this, this.s.options);
- for (const event of constants_1.HEARTBEAT_EVENTS) {
- this.monitor.on(event, (e) => this.emit(event, e));
- }
- this.monitor.on("resetServer", (error) => markServerUnknown(this, error));
- this.monitor.on(_Server.SERVER_HEARTBEAT_SUCCEEDED, (event) => {
- this.emit(_Server.DESCRIPTION_RECEIVED, new server_description_1.ServerDescription(this.description.hostAddress, event.reply, {
- roundTripTime: calculateRoundTripTime(this.description.roundTripTime, event.duration)
- }));
- if (this.s.state === common_1.STATE_CONNECTING) {
- stateTransition(this, common_1.STATE_CONNECTED);
- this.emit(_Server.CONNECT, this);
- }
- });
- }
- get clusterTime() {
- return this.topology.clusterTime;
- }
- set clusterTime(clusterTime) {
- this.topology.clusterTime = clusterTime;
- }
- get description() {
- return this.s.description;
- }
- get name() {
- return this.s.description.address;
- }
- get autoEncrypter() {
- if (this.s.options && this.s.options.autoEncrypter) {
- return this.s.options.autoEncrypter;
- }
- return;
- }
- get loadBalanced() {
- return this.topology.description.type === common_1.TopologyType.LoadBalanced;
- }
- /**
- * Initiate server connect
- */
- connect() {
- var _a;
- if (this.s.state !== common_1.STATE_CLOSED) {
- return;
- }
- stateTransition(this, common_1.STATE_CONNECTING);
- if (!this.loadBalanced) {
- (_a = this.monitor) == null ? void 0 : _a.connect();
- } else {
- stateTransition(this, common_1.STATE_CONNECTED);
- this.emit(_Server.CONNECT, this);
- }
- }
- /** Destroy the server connection */
- destroy(options, callback) {
- var _a;
- if (typeof options === "function") {
- callback = options;
- options = { force: false };
- }
- options = Object.assign({}, { force: false }, options);
- if (this.s.state === common_1.STATE_CLOSED) {
- if (typeof callback === "function") {
- callback();
- }
- return;
- }
- stateTransition(this, common_1.STATE_CLOSING);
- if (!this.loadBalanced) {
- (_a = this.monitor) == null ? void 0 : _a.close();
- }
- this.pool.close(options, (err) => {
- stateTransition(this, common_1.STATE_CLOSED);
- this.emit("closed");
- if (typeof callback === "function") {
- callback(err);
- }
- });
- }
- /**
- * Immediately schedule monitoring of this server. If there already an attempt being made
- * this will be a no-op.
- */
- requestCheck() {
- var _a;
- if (!this.loadBalanced) {
- (_a = this.monitor) == null ? void 0 : _a.requestCheck();
- }
- }
- /**
- * Execute a command
- * @internal
- */
- command(ns, cmd, options, callback) {
- if (callback == null) {
- throw new error_1.MongoInvalidArgumentError("Callback must be provided");
- }
- if (ns.db == null || typeof ns === "string") {
- throw new error_1.MongoInvalidArgumentError("Namespace must not be a string");
- }
- if (this.s.state === common_1.STATE_CLOSING || this.s.state === common_1.STATE_CLOSED) {
- callback(new error_1.MongoServerClosedError());
- return;
- }
- const finalOptions = Object.assign({}, options, { wireProtocolCommand: false });
- if (finalOptions.omitReadPreference) {
- delete finalOptions.readPreference;
- }
- const session = finalOptions.session;
- const conn = session == null ? void 0 : session.pinnedConnection;
- if (this.loadBalanced && session && conn == null && isPinnableCommand(cmd, session)) {
- this.pool.checkOut((err, checkedOut) => {
- if (err || checkedOut == null) {
- if (callback)
- return callback(err);
- return;
- }
- session.pin(checkedOut);
- this.command(ns, cmd, finalOptions, callback);
- });
- return;
- }
- this.incrementOperationCount();
- this.pool.withConnection(conn, (err, conn2, cb) => {
- if (err || !conn2) {
- this.decrementOperationCount();
- if (!err) {
- return cb(new error_1.MongoRuntimeError("Failed to create connection without error"));
- }
- if (!(err instanceof errors_1.PoolClearedError)) {
- this.handleError(err);
- }
- return cb(err);
- }
- conn2.command(ns, cmd, finalOptions, makeOperationHandler(this, conn2, cmd, finalOptions, (error, response) => {
- this.decrementOperationCount();
- cb(error, response);
- }));
- }, callback);
- }
- /**
- * Handle SDAM error
- * @internal
- */
- handleError(error, connection) {
- if (!(error instanceof error_1.MongoError)) {
- return;
- }
- const isStaleError = error.connectionGeneration && error.connectionGeneration < this.pool.generation;
- if (isStaleError) {
- return;
- }
- const isNetworkNonTimeoutError = error instanceof error_1.MongoNetworkError && !(error instanceof error_1.MongoNetworkTimeoutError);
- const isNetworkTimeoutBeforeHandshakeError = (0, error_1.isNetworkErrorBeforeHandshake)(error);
- const isAuthHandshakeError = error.hasErrorLabel(error_1.MongoErrorLabel.HandshakeError);
- if (isNetworkNonTimeoutError || isNetworkTimeoutBeforeHandshakeError || isAuthHandshakeError) {
- if (!this.loadBalanced) {
- error.addErrorLabel(error_1.MongoErrorLabel.ResetPool);
- markServerUnknown(this, error);
- } else if (connection) {
- this.pool.clear({ serviceId: connection.serviceId });
- }
- } else {
- if ((0, error_1.isSDAMUnrecoverableError)(error)) {
- if (shouldHandleStateChangeError(this, error)) {
- const shouldClearPool = (0, utils_1.maxWireVersion)(this) <= 7 || (0, error_1.isNodeShuttingDownError)(error);
- if (this.loadBalanced && connection && shouldClearPool) {
- this.pool.clear({ serviceId: connection.serviceId });
- }
- if (!this.loadBalanced) {
- if (shouldClearPool) {
- error.addErrorLabel(error_1.MongoErrorLabel.ResetPool);
- }
- markServerUnknown(this, error);
- process.nextTick(() => this.requestCheck());
- }
- }
- }
- }
- }
- /**
- * Decrement the operation count, returning the new count.
- */
- decrementOperationCount() {
- return this.s.operationCount -= 1;
- }
- /**
- * Increment the operation count, returning the new count.
- */
- incrementOperationCount() {
- return this.s.operationCount += 1;
- }
- };
- Server.SERVER_HEARTBEAT_STARTED = constants_1.SERVER_HEARTBEAT_STARTED;
- Server.SERVER_HEARTBEAT_SUCCEEDED = constants_1.SERVER_HEARTBEAT_SUCCEEDED;
- Server.SERVER_HEARTBEAT_FAILED = constants_1.SERVER_HEARTBEAT_FAILED;
- Server.CONNECT = constants_1.CONNECT;
- Server.DESCRIPTION_RECEIVED = constants_1.DESCRIPTION_RECEIVED;
- Server.CLOSED = constants_1.CLOSED;
- Server.ENDED = constants_1.ENDED;
- exports2.Server = Server;
- function calculateRoundTripTime(oldRtt, duration) {
- if (oldRtt === -1) {
- return duration;
- }
- const alpha = 0.2;
- return alpha * duration + (1 - alpha) * oldRtt;
- }
- function markServerUnknown(server, error) {
- var _a;
- if (server.loadBalanced) {
- return;
- }
- if (error instanceof error_1.MongoNetworkError && !(error instanceof error_1.MongoNetworkTimeoutError)) {
- (_a = server.monitor) == null ? void 0 : _a.reset();
- }
- server.emit(Server.DESCRIPTION_RECEIVED, new server_description_1.ServerDescription(server.description.hostAddress, void 0, { error }));
- }
- function isPinnableCommand(cmd, session) {
- if (session) {
- return session.inTransaction() || "aggregate" in cmd || "find" in cmd || "getMore" in cmd || "listCollections" in cmd || "listIndexes" in cmd;
- }
- return false;
- }
- function connectionIsStale(pool, connection) {
- if (connection.serviceId) {
- return connection.generation !== pool.serviceGenerations.get(connection.serviceId.toHexString());
- }
- return connection.generation !== pool.generation;
- }
- function shouldHandleStateChangeError(server, err) {
- const etv = err.topologyVersion;
- const stv = server.description.topologyVersion;
- return (0, server_description_1.compareTopologyVersion)(stv, etv) < 0;
- }
- function inActiveTransaction(session, cmd) {
- return session && session.inTransaction() && !(0, transactions_1.isTransactionCommand)(cmd);
- }
- function isRetryableWritesEnabled(topology) {
- return topology.s.options.retryWrites !== false;
- }
- function makeOperationHandler(server, connection, cmd, options, callback) {
- const session = options == null ? void 0 : options.session;
- return function handleOperationResult(error, result) {
- if (error == null && result != null) {
- return callback(void 0, result);
- }
- if (options != null && "noResponse" in options && options.noResponse === true) {
- return callback(void 0, null);
- }
- if (!error) {
- return callback(new error_1.MongoUnexpectedServerResponseError("Empty response with no error"));
- }
- if (!(error instanceof error_1.MongoError)) {
- return callback(error);
- }
- if (connectionIsStale(server.pool, connection)) {
- return callback(error);
- }
- if (error instanceof error_1.MongoNetworkError) {
- if (session && !session.hasEnded && session.serverSession) {
- session.serverSession.isDirty = true;
- }
- if (inActiveTransaction(session, cmd) && !error.hasErrorLabel(error_1.MongoErrorLabel.TransientTransactionError)) {
- error.addErrorLabel(error_1.MongoErrorLabel.TransientTransactionError);
- }
- if ((isRetryableWritesEnabled(server.topology) || (0, transactions_1.isTransactionCommand)(cmd)) && (0, utils_1.supportsRetryableWrites)(server) && !inActiveTransaction(session, cmd)) {
- error.addErrorLabel(error_1.MongoErrorLabel.RetryableWriteError);
- }
- } else {
- if ((isRetryableWritesEnabled(server.topology) || (0, transactions_1.isTransactionCommand)(cmd)) && (0, error_1.needsRetryableWriteLabel)(error, (0, utils_1.maxWireVersion)(server)) && !inActiveTransaction(session, cmd)) {
- error.addErrorLabel(error_1.MongoErrorLabel.RetryableWriteError);
- }
- }
- if (session && session.isPinned && error.hasErrorLabel(error_1.MongoErrorLabel.TransientTransactionError)) {
- session.unpin({ force: true });
- }
- server.handleError(error, connection);
- return callback(error);
- };
- }
- }
- });
- // node_modules/mongodb/lib/sdam/srv_polling.js
- var require_srv_polling = __commonJS({
- "node_modules/mongodb/lib/sdam/srv_polling.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.SrvPoller = exports2.SrvPollingEvent = void 0;
- var dns = require("dns");
- var timers_1 = require("timers");
- var error_1 = require_error();
- var mongo_types_1 = require_mongo_types();
- var utils_1 = require_utils();
- var SrvPollingEvent = class {
- constructor(srvRecords) {
- this.srvRecords = srvRecords;
- }
- hostnames() {
- return new Set(this.srvRecords.map((r) => utils_1.HostAddress.fromSrvRecord(r).toString()));
- }
- };
- exports2.SrvPollingEvent = SrvPollingEvent;
- var SrvPoller = class _SrvPoller extends mongo_types_1.TypedEventEmitter {
- constructor(options) {
- super();
- if (!options || !options.srvHost) {
- throw new error_1.MongoRuntimeError("Options for SrvPoller must exist and include srvHost");
- }
- this.srvHost = options.srvHost;
- this.srvMaxHosts = options.srvMaxHosts ?? 0;
- this.srvServiceName = options.srvServiceName ?? "mongodb";
- this.rescanSrvIntervalMS = 6e4;
- this.heartbeatFrequencyMS = options.heartbeatFrequencyMS ?? 1e4;
- this.haMode = false;
- this.generation = 0;
- this._timeout = void 0;
- }
- get srvAddress() {
- return `_${this.srvServiceName}._tcp.${this.srvHost}`;
- }
- get intervalMS() {
- return this.haMode ? this.heartbeatFrequencyMS : this.rescanSrvIntervalMS;
- }
- start() {
- if (!this._timeout) {
- this.schedule();
- }
- }
- stop() {
- if (this._timeout) {
- (0, timers_1.clearTimeout)(this._timeout);
- this.generation += 1;
- this._timeout = void 0;
- }
- }
- // TODO(NODE-4994): implement new logging logic for SrvPoller failures
- schedule() {
- if (this._timeout) {
- (0, timers_1.clearTimeout)(this._timeout);
- }
- this._timeout = (0, timers_1.setTimeout)(() => {
- this._poll().catch(() => null);
- }, this.intervalMS);
- }
- success(srvRecords) {
- this.haMode = false;
- this.schedule();
- this.emit(_SrvPoller.SRV_RECORD_DISCOVERY, new SrvPollingEvent(srvRecords));
- }
- failure() {
- this.haMode = true;
- this.schedule();
- }
- async _poll() {
- const generation = this.generation;
- let srvRecords;
- try {
- srvRecords = await dns.promises.resolveSrv(this.srvAddress);
- } catch (dnsError) {
- this.failure();
- return;
- }
- if (generation !== this.generation) {
- return;
- }
- const finalAddresses = [];
- for (const record of srvRecords) {
- if ((0, utils_1.matchesParentDomain)(record.name, this.srvHost)) {
- finalAddresses.push(record);
- }
- }
- if (!finalAddresses.length) {
- this.failure();
- return;
- }
- this.success(finalAddresses);
- }
- };
- SrvPoller.SRV_RECORD_DISCOVERY = "srvRecordDiscovery";
- exports2.SrvPoller = SrvPoller;
- }
- });
- // node_modules/mongodb/lib/sdam/topology.js
- var require_topology = __commonJS({
- "node_modules/mongodb/lib/sdam/topology.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ServerCapabilities = exports2.Topology = void 0;
- var timers_1 = require("timers");
- var util_1 = require("util");
- var connection_string_1 = require_connection_string();
- var constants_1 = require_constants2();
- var error_1 = require_error();
- var mongo_types_1 = require_mongo_types();
- var read_preference_1 = require_read_preference();
- var utils_1 = require_utils();
- var common_1 = require_common();
- var events_1 = require_events();
- var server_1 = require_server();
- var server_description_1 = require_server_description();
- var server_selection_1 = require_server_selection();
- var srv_polling_1 = require_srv_polling();
- var topology_description_1 = require_topology_description();
- var globalTopologyCounter = 0;
- var stateTransition = (0, utils_1.makeStateMachine)({
- [common_1.STATE_CLOSED]: [common_1.STATE_CLOSED, common_1.STATE_CONNECTING],
- [common_1.STATE_CONNECTING]: [common_1.STATE_CONNECTING, common_1.STATE_CLOSING, common_1.STATE_CONNECTED, common_1.STATE_CLOSED],
- [common_1.STATE_CONNECTED]: [common_1.STATE_CONNECTED, common_1.STATE_CLOSING, common_1.STATE_CLOSED],
- [common_1.STATE_CLOSING]: [common_1.STATE_CLOSING, common_1.STATE_CLOSED]
- });
- var kCancelled = Symbol("cancelled");
- var kWaitQueue = Symbol("waitQueue");
- var Topology = class _Topology extends mongo_types_1.TypedEventEmitter {
- /**
- * @param seedlist - a list of HostAddress instances to connect to
- */
- constructor(client, seeds, options) {
- super();
- this.client = client;
- this.selectServerAsync = (0, util_1.promisify)((selector, options2, callback) => this.selectServer(selector, options2, callback));
- options = options ?? {
- hosts: [utils_1.HostAddress.fromString("localhost:27017")],
- ...Object.fromEntries(connection_string_1.DEFAULT_OPTIONS.entries()),
- ...Object.fromEntries(connection_string_1.FEATURE_FLAGS.entries())
- };
- if (typeof seeds === "string") {
- seeds = [utils_1.HostAddress.fromString(seeds)];
- } else if (!Array.isArray(seeds)) {
- seeds = [seeds];
- }
- const seedlist = [];
- for (const seed of seeds) {
- if (typeof seed === "string") {
- seedlist.push(utils_1.HostAddress.fromString(seed));
- } else if (seed instanceof utils_1.HostAddress) {
- seedlist.push(seed);
- } else {
- throw new error_1.MongoRuntimeError(`Topology cannot be constructed from ${JSON.stringify(seed)}`);
- }
- }
- const topologyType = topologyTypeFromOptions(options);
- const topologyId = globalTopologyCounter++;
- const selectedHosts = options.srvMaxHosts == null || options.srvMaxHosts === 0 || options.srvMaxHosts >= seedlist.length ? seedlist : (0, utils_1.shuffle)(seedlist, options.srvMaxHosts);
- const serverDescriptions = /* @__PURE__ */ new Map();
- for (const hostAddress of selectedHosts) {
- serverDescriptions.set(hostAddress.toString(), new server_description_1.ServerDescription(hostAddress));
- }
- this[kWaitQueue] = new utils_1.List();
- this.s = {
- // the id of this topology
- id: topologyId,
- // passed in options
- options,
- // initial seedlist of servers to connect to
- seedlist,
- // initial state
- state: common_1.STATE_CLOSED,
- // the topology description
- description: new topology_description_1.TopologyDescription(topologyType, serverDescriptions, options.replicaSet, void 0, void 0, void 0, options),
- serverSelectionTimeoutMS: options.serverSelectionTimeoutMS,
- heartbeatFrequencyMS: options.heartbeatFrequencyMS,
- minHeartbeatFrequencyMS: options.minHeartbeatFrequencyMS,
- // a map of server instances to normalized addresses
- servers: /* @__PURE__ */ new Map(),
- credentials: options == null ? void 0 : options.credentials,
- clusterTime: void 0,
- // timer management
- connectionTimers: /* @__PURE__ */ new Set(),
- detectShardedTopology: (ev) => this.detectShardedTopology(ev),
- detectSrvRecords: (ev) => this.detectSrvRecords(ev)
- };
- if (options.srvHost && !options.loadBalanced) {
- this.s.srvPoller = options.srvPoller ?? new srv_polling_1.SrvPoller({
- heartbeatFrequencyMS: this.s.heartbeatFrequencyMS,
- srvHost: options.srvHost,
- srvMaxHosts: options.srvMaxHosts,
- srvServiceName: options.srvServiceName
- });
- this.on(_Topology.TOPOLOGY_DESCRIPTION_CHANGED, this.s.detectShardedTopology);
- }
- }
- detectShardedTopology(event) {
- var _a, _b, _c;
- const previousType = event.previousDescription.type;
- const newType = event.newDescription.type;
- const transitionToSharded = previousType !== common_1.TopologyType.Sharded && newType === common_1.TopologyType.Sharded;
- const srvListeners = (_a = this.s.srvPoller) == null ? void 0 : _a.listeners(srv_polling_1.SrvPoller.SRV_RECORD_DISCOVERY);
- const listeningToSrvPolling = !!(srvListeners == null ? void 0 : srvListeners.includes(this.s.detectSrvRecords));
- if (transitionToSharded && !listeningToSrvPolling) {
- (_b = this.s.srvPoller) == null ? void 0 : _b.on(srv_polling_1.SrvPoller.SRV_RECORD_DISCOVERY, this.s.detectSrvRecords);
- (_c = this.s.srvPoller) == null ? void 0 : _c.start();
- }
- }
- detectSrvRecords(ev) {
- const previousTopologyDescription = this.s.description;
- this.s.description = this.s.description.updateFromSrvPollingEvent(ev, this.s.options.srvMaxHosts);
- if (this.s.description === previousTopologyDescription) {
- return;
- }
- updateServers(this);
- this.emit(_Topology.TOPOLOGY_DESCRIPTION_CHANGED, new events_1.TopologyDescriptionChangedEvent(this.s.id, previousTopologyDescription, this.s.description));
- }
- /**
- * @returns A `TopologyDescription` for this topology
- */
- get description() {
- return this.s.description;
- }
- get loadBalanced() {
- return this.s.options.loadBalanced;
- }
- get capabilities() {
- return new ServerCapabilities(this.lastHello());
- }
- connect(options, callback) {
- if (typeof options === "function")
- callback = options, options = {};
- options = options ?? {};
- if (this.s.state === common_1.STATE_CONNECTED) {
- if (typeof callback === "function") {
- callback();
- }
- return;
- }
- stateTransition(this, common_1.STATE_CONNECTING);
- this.emit(_Topology.TOPOLOGY_OPENING, new events_1.TopologyOpeningEvent(this.s.id));
- this.emit(_Topology.TOPOLOGY_DESCRIPTION_CHANGED, new events_1.TopologyDescriptionChangedEvent(
- this.s.id,
- new topology_description_1.TopologyDescription(common_1.TopologyType.Unknown),
- // initial is always Unknown
- this.s.description
- ));
- const serverDescriptions = Array.from(this.s.description.servers.values());
- this.s.servers = new Map(serverDescriptions.map((serverDescription) => [
- serverDescription.address,
- createAndConnectServer(this, serverDescription)
- ]));
- if (this.s.options.loadBalanced) {
- for (const description of serverDescriptions) {
- const newDescription = new server_description_1.ServerDescription(description.hostAddress, void 0, {
- loadBalanced: this.s.options.loadBalanced
- });
- this.serverUpdateHandler(newDescription);
- }
- }
- const exitWithError = (error) => callback ? callback(error) : this.emit(_Topology.ERROR, error);
- const readPreference = options.readPreference ?? read_preference_1.ReadPreference.primary;
- this.selectServer((0, server_selection_1.readPreferenceServerSelector)(readPreference), options, (err, server) => {
- if (err) {
- return this.close({ force: false }, () => exitWithError(err));
- }
- const skipPingOnConnect = this.s.options[Symbol.for("@@mdb.skipPingOnConnect")] === true;
- if (!skipPingOnConnect && server && this.s.credentials) {
- server.command((0, utils_1.ns)("admin.$cmd"), { ping: 1 }, {}, (err2) => {
- if (err2) {
- return exitWithError(err2);
- }
- stateTransition(this, common_1.STATE_CONNECTED);
- this.emit(_Topology.OPEN, this);
- this.emit(_Topology.CONNECT, this);
- callback == null ? void 0 : callback(void 0, this);
- });
- return;
- }
- stateTransition(this, common_1.STATE_CONNECTED);
- this.emit(_Topology.OPEN, this);
- this.emit(_Topology.CONNECT, this);
- callback == null ? void 0 : callback(void 0, this);
- });
- }
- close(options, callback) {
- options = options ?? { force: false };
- if (this.s.state === common_1.STATE_CLOSED || this.s.state === common_1.STATE_CLOSING) {
- return callback == null ? void 0 : callback();
- }
- const destroyedServers = Array.from(this.s.servers.values(), (server) => {
- return (0, util_1.promisify)(destroyServer)(server, this, { force: !!(options == null ? void 0 : options.force) });
- });
- Promise.all(destroyedServers).then(() => {
- this.s.servers.clear();
- stateTransition(this, common_1.STATE_CLOSING);
- drainWaitQueue(this[kWaitQueue], new error_1.MongoTopologyClosedError());
- (0, common_1.drainTimerQueue)(this.s.connectionTimers);
- if (this.s.srvPoller) {
- this.s.srvPoller.stop();
- this.s.srvPoller.removeListener(srv_polling_1.SrvPoller.SRV_RECORD_DISCOVERY, this.s.detectSrvRecords);
- }
- this.removeListener(_Topology.TOPOLOGY_DESCRIPTION_CHANGED, this.s.detectShardedTopology);
- stateTransition(this, common_1.STATE_CLOSED);
- this.emit(_Topology.TOPOLOGY_CLOSED, new events_1.TopologyClosedEvent(this.s.id));
- }).finally(() => callback == null ? void 0 : callback());
- }
- /**
- * Selects a server according to the selection predicate provided
- *
- * @param selector - An optional selector to select servers by, defaults to a random selection within a latency window
- * @param options - Optional settings related to server selection
- * @param callback - The callback used to indicate success or failure
- * @returns An instance of a `Server` meeting the criteria of the predicate provided
- */
- selectServer(selector, options, callback) {
- let serverSelector;
- if (typeof selector !== "function") {
- if (typeof selector === "string") {
- serverSelector = (0, server_selection_1.readPreferenceServerSelector)(read_preference_1.ReadPreference.fromString(selector));
- } else {
- let readPreference;
- if (selector instanceof read_preference_1.ReadPreference) {
- readPreference = selector;
- } else {
- read_preference_1.ReadPreference.translate(options);
- readPreference = options.readPreference || read_preference_1.ReadPreference.primary;
- }
- serverSelector = (0, server_selection_1.readPreferenceServerSelector)(readPreference);
- }
- } else {
- serverSelector = selector;
- }
- options = Object.assign({}, { serverSelectionTimeoutMS: this.s.serverSelectionTimeoutMS }, options);
- const isSharded = this.description.type === common_1.TopologyType.Sharded;
- const session = options.session;
- const transaction = session && session.transaction;
- if (isSharded && transaction && transaction.server) {
- callback(void 0, transaction.server);
- return;
- }
- const waitQueueMember = {
- serverSelector,
- transaction,
- callback
- };
- const serverSelectionTimeoutMS = options.serverSelectionTimeoutMS;
- if (serverSelectionTimeoutMS) {
- waitQueueMember.timer = (0, timers_1.setTimeout)(() => {
- waitQueueMember[kCancelled] = true;
- waitQueueMember.timer = void 0;
- const timeoutError = new error_1.MongoServerSelectionError(`Server selection timed out after ${serverSelectionTimeoutMS} ms`, this.description);
- waitQueueMember.callback(timeoutError);
- }, serverSelectionTimeoutMS);
- }
- this[kWaitQueue].push(waitQueueMember);
- processWaitQueue(this);
- }
- /**
- * Update the internal TopologyDescription with a ServerDescription
- *
- * @param serverDescription - The server to update in the internal list of server descriptions
- */
- serverUpdateHandler(serverDescription) {
- if (!this.s.description.hasServer(serverDescription.address)) {
- return;
- }
- if (isStaleServerDescription(this.s.description, serverDescription)) {
- return;
- }
- const previousTopologyDescription = this.s.description;
- const previousServerDescription = this.s.description.servers.get(serverDescription.address);
- if (!previousServerDescription) {
- return;
- }
- const clusterTime = serverDescription.$clusterTime;
- if (clusterTime) {
- (0, common_1._advanceClusterTime)(this, clusterTime);
- }
- const equalDescriptions = previousServerDescription && previousServerDescription.equals(serverDescription);
- this.s.description = this.s.description.update(serverDescription);
- if (this.s.description.compatibilityError) {
- this.emit(_Topology.ERROR, new error_1.MongoCompatibilityError(this.s.description.compatibilityError));
- return;
- }
- if (!equalDescriptions) {
- const newDescription = this.s.description.servers.get(serverDescription.address);
- if (newDescription) {
- this.emit(_Topology.SERVER_DESCRIPTION_CHANGED, new events_1.ServerDescriptionChangedEvent(this.s.id, serverDescription.address, previousServerDescription, newDescription));
- }
- }
- updateServers(this, serverDescription);
- if (this[kWaitQueue].length > 0) {
- processWaitQueue(this);
- }
- if (!equalDescriptions) {
- this.emit(_Topology.TOPOLOGY_DESCRIPTION_CHANGED, new events_1.TopologyDescriptionChangedEvent(this.s.id, previousTopologyDescription, this.s.description));
- }
- }
- auth(credentials, callback) {
- if (typeof credentials === "function")
- callback = credentials, credentials = void 0;
- if (typeof callback === "function")
- callback(void 0, true);
- }
- get clientMetadata() {
- return this.s.options.metadata;
- }
- isConnected() {
- return this.s.state === common_1.STATE_CONNECTED;
- }
- isDestroyed() {
- return this.s.state === common_1.STATE_CLOSED;
- }
- // NOTE: There are many places in code where we explicitly check the last hello
- // to do feature support detection. This should be done any other way, but for
- // now we will just return the first hello seen, which should suffice.
- lastHello() {
- const serverDescriptions = Array.from(this.description.servers.values());
- if (serverDescriptions.length === 0)
- return {};
- const sd = serverDescriptions.filter((sd2) => sd2.type !== common_1.ServerType.Unknown)[0];
- const result = sd || { maxWireVersion: this.description.commonWireVersion };
- return result;
- }
- get commonWireVersion() {
- return this.description.commonWireVersion;
- }
- get logicalSessionTimeoutMinutes() {
- return this.description.logicalSessionTimeoutMinutes;
- }
- get clusterTime() {
- return this.s.clusterTime;
- }
- set clusterTime(clusterTime) {
- this.s.clusterTime = clusterTime;
- }
- };
- Topology.SERVER_OPENING = constants_1.SERVER_OPENING;
- Topology.SERVER_CLOSED = constants_1.SERVER_CLOSED;
- Topology.SERVER_DESCRIPTION_CHANGED = constants_1.SERVER_DESCRIPTION_CHANGED;
- Topology.TOPOLOGY_OPENING = constants_1.TOPOLOGY_OPENING;
- Topology.TOPOLOGY_CLOSED = constants_1.TOPOLOGY_CLOSED;
- Topology.TOPOLOGY_DESCRIPTION_CHANGED = constants_1.TOPOLOGY_DESCRIPTION_CHANGED;
- Topology.ERROR = constants_1.ERROR;
- Topology.OPEN = constants_1.OPEN;
- Topology.CONNECT = constants_1.CONNECT;
- Topology.CLOSE = constants_1.CLOSE;
- Topology.TIMEOUT = constants_1.TIMEOUT;
- exports2.Topology = Topology;
- function destroyServer(server, topology, options, callback) {
- options = options ?? { force: false };
- for (const event of constants_1.LOCAL_SERVER_EVENTS) {
- server.removeAllListeners(event);
- }
- server.destroy(options, () => {
- topology.emit(Topology.SERVER_CLOSED, new events_1.ServerClosedEvent(topology.s.id, server.description.address));
- for (const event of constants_1.SERVER_RELAY_EVENTS) {
- server.removeAllListeners(event);
- }
- if (typeof callback === "function") {
- callback();
- }
- });
- }
- function topologyTypeFromOptions(options) {
- if (options == null ? void 0 : options.directConnection) {
- return common_1.TopologyType.Single;
- }
- if (options == null ? void 0 : options.replicaSet) {
- return common_1.TopologyType.ReplicaSetNoPrimary;
- }
- if (options == null ? void 0 : options.loadBalanced) {
- return common_1.TopologyType.LoadBalanced;
- }
- return common_1.TopologyType.Unknown;
- }
- function createAndConnectServer(topology, serverDescription) {
- topology.emit(Topology.SERVER_OPENING, new events_1.ServerOpeningEvent(topology.s.id, serverDescription.address));
- const server = new server_1.Server(topology, serverDescription, topology.s.options);
- for (const event of constants_1.SERVER_RELAY_EVENTS) {
- server.on(event, (e) => topology.emit(event, e));
- }
- server.on(server_1.Server.DESCRIPTION_RECEIVED, (description) => topology.serverUpdateHandler(description));
- server.connect();
- return server;
- }
- function updateServers(topology, incomingServerDescription) {
- if (incomingServerDescription && topology.s.servers.has(incomingServerDescription.address)) {
- const server = topology.s.servers.get(incomingServerDescription.address);
- if (server) {
- server.s.description = incomingServerDescription;
- if (incomingServerDescription.error instanceof error_1.MongoError && incomingServerDescription.error.hasErrorLabel(error_1.MongoErrorLabel.ResetPool)) {
- const interruptInUseConnections = incomingServerDescription.error.hasErrorLabel(error_1.MongoErrorLabel.InterruptInUseConnections);
- server.pool.clear({ interruptInUseConnections });
- } else if (incomingServerDescription.error == null) {
- const newTopologyType = topology.s.description.type;
- const shouldMarkPoolReady = incomingServerDescription.isDataBearing || incomingServerDescription.type !== common_1.ServerType.Unknown && newTopologyType === common_1.TopologyType.Single;
- if (shouldMarkPoolReady) {
- server.pool.ready();
- }
- }
- }
- }
- for (const serverDescription of topology.description.servers.values()) {
- if (!topology.s.servers.has(serverDescription.address)) {
- const server = createAndConnectServer(topology, serverDescription);
- topology.s.servers.set(serverDescription.address, server);
- }
- }
- for (const entry of topology.s.servers) {
- const serverAddress = entry[0];
- if (topology.description.hasServer(serverAddress)) {
- continue;
- }
- if (!topology.s.servers.has(serverAddress)) {
- continue;
- }
- const server = topology.s.servers.get(serverAddress);
- topology.s.servers.delete(serverAddress);
- if (server) {
- destroyServer(server, topology);
- }
- }
- }
- function drainWaitQueue(queue, err) {
- while (queue.length) {
- const waitQueueMember = queue.shift();
- if (!waitQueueMember) {
- continue;
- }
- if (waitQueueMember.timer) {
- (0, timers_1.clearTimeout)(waitQueueMember.timer);
- }
- if (!waitQueueMember[kCancelled]) {
- waitQueueMember.callback(err);
- }
- }
- }
- function processWaitQueue(topology) {
- if (topology.s.state === common_1.STATE_CLOSED) {
- drainWaitQueue(topology[kWaitQueue], new error_1.MongoTopologyClosedError());
- return;
- }
- const isSharded = topology.description.type === common_1.TopologyType.Sharded;
- const serverDescriptions = Array.from(topology.description.servers.values());
- const membersToProcess = topology[kWaitQueue].length;
- for (let i = 0; i < membersToProcess; ++i) {
- const waitQueueMember = topology[kWaitQueue].shift();
- if (!waitQueueMember) {
- continue;
- }
- if (waitQueueMember[kCancelled]) {
- continue;
- }
- let selectedDescriptions;
- try {
- const serverSelector = waitQueueMember.serverSelector;
- selectedDescriptions = serverSelector ? serverSelector(topology.description, serverDescriptions) : serverDescriptions;
- } catch (e) {
- if (waitQueueMember.timer) {
- (0, timers_1.clearTimeout)(waitQueueMember.timer);
- }
- waitQueueMember.callback(e);
- continue;
- }
- let selectedServer;
- if (selectedDescriptions.length === 0) {
- topology[kWaitQueue].push(waitQueueMember);
- continue;
- } else if (selectedDescriptions.length === 1) {
- selectedServer = topology.s.servers.get(selectedDescriptions[0].address);
- } else {
- const descriptions = (0, utils_1.shuffle)(selectedDescriptions, 2);
- const server1 = topology.s.servers.get(descriptions[0].address);
- const server2 = topology.s.servers.get(descriptions[1].address);
- selectedServer = server1 && server2 && server1.s.operationCount < server2.s.operationCount ? server1 : server2;
- }
- if (!selectedServer) {
- waitQueueMember.callback(new error_1.MongoServerSelectionError("server selection returned a server description but the server was not found in the topology", topology.description));
- return;
- }
- const transaction = waitQueueMember.transaction;
- if (isSharded && transaction && transaction.isActive && selectedServer) {
- transaction.pinServer(selectedServer);
- }
- if (waitQueueMember.timer) {
- (0, timers_1.clearTimeout)(waitQueueMember.timer);
- }
- waitQueueMember.callback(void 0, selectedServer);
- }
- if (topology[kWaitQueue].length > 0) {
- for (const [, server] of topology.s.servers) {
- process.nextTick(function scheduleServerCheck() {
- return server.requestCheck();
- });
- }
- }
- }
- function isStaleServerDescription(topologyDescription, incomingServerDescription) {
- const currentServerDescription = topologyDescription.servers.get(incomingServerDescription.address);
- const currentTopologyVersion = currentServerDescription == null ? void 0 : currentServerDescription.topologyVersion;
- return (0, server_description_1.compareTopologyVersion)(currentTopologyVersion, incomingServerDescription.topologyVersion) > 0;
- }
- var ServerCapabilities = class {
- constructor(hello) {
- this.minWireVersion = hello.minWireVersion || 0;
- this.maxWireVersion = hello.maxWireVersion || 0;
- }
- get hasAggregationCursor() {
- return this.maxWireVersion >= 1;
- }
- get hasWriteCommands() {
- return this.maxWireVersion >= 2;
- }
- get hasTextSearch() {
- return this.minWireVersion >= 0;
- }
- get hasAuthCommands() {
- return this.maxWireVersion >= 1;
- }
- get hasListCollectionsCommand() {
- return this.maxWireVersion >= 3;
- }
- get hasListIndexesCommand() {
- return this.maxWireVersion >= 3;
- }
- get supportsSnapshotReads() {
- return this.maxWireVersion >= 13;
- }
- get commandsTakeWriteConcern() {
- return this.maxWireVersion >= 5;
- }
- get commandsTakeCollation() {
- return this.maxWireVersion >= 5;
- }
- };
- exports2.ServerCapabilities = ServerCapabilities;
- }
- });
- // node_modules/mongodb/lib/mongo_client.js
- var require_mongo_client = __commonJS({
- "node_modules/mongodb/lib/mongo_client.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.MongoClient = exports2.ServerApiVersion = void 0;
- var util_1 = require("util");
- var bson_1 = require_bson2();
- var change_stream_1 = require_change_stream();
- var mongo_credentials_1 = require_mongo_credentials();
- var providers_1 = require_providers();
- var connection_string_1 = require_connection_string();
- var constants_1 = require_constants2();
- var db_1 = require_db();
- var error_1 = require_error();
- var mongo_logger_1 = require_mongo_logger();
- var mongo_types_1 = require_mongo_types();
- var read_preference_1 = require_read_preference();
- var server_selection_1 = require_server_selection();
- var topology_1 = require_topology();
- var sessions_1 = require_sessions();
- var utils_1 = require_utils();
- exports2.ServerApiVersion = Object.freeze({
- v1: "1"
- });
- var kOptions = Symbol("options");
- var MongoClient2 = class extends mongo_types_1.TypedEventEmitter {
- constructor(url, options) {
- super();
- this[kOptions] = (0, connection_string_1.parseOptions)(url, this, options);
- this.mongoLogger = new mongo_logger_1.MongoLogger(this[kOptions].mongoLoggerOptions);
- const client = this;
- this.s = {
- url,
- bsonOptions: (0, bson_1.resolveBSONOptions)(this[kOptions]),
- namespace: (0, utils_1.ns)("admin"),
- hasBeenClosed: false,
- sessionPool: new sessions_1.ServerSessionPool(this),
- activeSessions: /* @__PURE__ */ new Set(),
- get options() {
- return client[kOptions];
- },
- get readConcern() {
- return client[kOptions].readConcern;
- },
- get writeConcern() {
- return client[kOptions].writeConcern;
- },
- get readPreference() {
- return client[kOptions].readPreference;
- },
- get isMongoClient() {
- return true;
- }
- };
- }
- /** @see MongoOptions */
- get options() {
- return Object.freeze({ ...this[kOptions] });
- }
- get serverApi() {
- return this[kOptions].serverApi && Object.freeze({ ...this[kOptions].serverApi });
- }
- /**
- * Intended for APM use only
- * @internal
- */
- get monitorCommands() {
- return this[kOptions].monitorCommands;
- }
- set monitorCommands(value) {
- this[kOptions].monitorCommands = value;
- }
- /**
- * @deprecated This method will be removed in the next major version.
- */
- get autoEncrypter() {
- return this[kOptions].autoEncrypter;
- }
- get readConcern() {
- return this.s.readConcern;
- }
- get writeConcern() {
- return this.s.writeConcern;
- }
- get readPreference() {
- return this.s.readPreference;
- }
- get bsonOptions() {
- return this.s.bsonOptions;
- }
- /**
- * Connect to MongoDB using a url
- *
- * @see docs.mongodb.org/manual/reference/connection-string/
- */
- async connect() {
- if (this.connectionLock) {
- return this.connectionLock;
- }
- try {
- this.connectionLock = this._connect();
- await this.connectionLock;
- } finally {
- this.connectionLock = void 0;
- }
- return this;
- }
- /**
- * Create a topology to open the connection, must be locked to avoid topology leaks in concurrency scenario.
- * Locking is enforced by the connect method.
- *
- * @internal
- */
- async _connect() {
- var _a, _b, _c, _d, _e;
- if (this.topology && this.topology.isConnected()) {
- return this;
- }
- const options = this[kOptions];
- if (typeof options.srvHost === "string") {
- const hosts = await (0, connection_string_1.resolveSRVRecord)(options);
- for (const [index, host] of hosts.entries()) {
- options.hosts[index] = host;
- }
- }
- if (((_a = options.credentials) == null ? void 0 : _a.mechanism) === providers_1.AuthMechanism.MONGODB_OIDC) {
- const allowedHosts = ((_c = (_b = options.credentials) == null ? void 0 : _b.mechanismProperties) == null ? void 0 : _c.ALLOWED_HOSTS) || mongo_credentials_1.DEFAULT_ALLOWED_HOSTS;
- const isServiceAuth = !!((_e = (_d = options.credentials) == null ? void 0 : _d.mechanismProperties) == null ? void 0 : _e.PROVIDER_NAME);
- if (!isServiceAuth) {
- for (const host of options.hosts) {
- if (!(0, utils_1.hostMatchesWildcards)(host.toHostPort().host, allowedHosts)) {
- throw new error_1.MongoInvalidArgumentError(`Host '${host}' is not valid for OIDC authentication with ALLOWED_HOSTS of '${allowedHosts.join(",")}'`);
- }
- }
- }
- }
- this.topology = new topology_1.Topology(this, options.hosts, options);
- this.topology.once(topology_1.Topology.OPEN, () => this.emit("open", this));
- for (const event of constants_1.MONGO_CLIENT_EVENTS) {
- this.topology.on(event, (...args) => this.emit(event, ...args));
- }
- const topologyConnect = async () => {
- var _a2;
- try {
- await (0, util_1.promisify)((callback) => {
- var _a3;
- return (_a3 = this.topology) == null ? void 0 : _a3.connect(options, callback);
- })();
- } catch (error) {
- (_a2 = this.topology) == null ? void 0 : _a2.close({ force: true });
- throw error;
- }
- };
- if (this.autoEncrypter) {
- const initAutoEncrypter = (0, util_1.promisify)((callback) => {
- var _a2;
- return (_a2 = this.autoEncrypter) == null ? void 0 : _a2.init(callback);
- });
- await initAutoEncrypter();
- await topologyConnect();
- await options.encrypter.connectInternalClient();
- } else {
- await topologyConnect();
- }
- return this;
- }
- /**
- * Close the client and its underlying connections
- *
- * @param force - Force close, emitting no events
- */
- async close(force = false) {
- Object.defineProperty(this.s, "hasBeenClosed", {
- value: true,
- enumerable: true,
- configurable: false,
- writable: false
- });
- const activeSessionEnds = Array.from(this.s.activeSessions, (session) => session.endSession());
- this.s.activeSessions.clear();
- await Promise.all(activeSessionEnds);
- if (this.topology == null) {
- return;
- }
- const selector = (0, server_selection_1.readPreferenceServerSelector)(read_preference_1.ReadPreference.primaryPreferred);
- const topologyDescription = this.topology.description;
- const serverDescriptions = Array.from(topologyDescription.servers.values());
- const servers = selector(topologyDescription, serverDescriptions);
- if (servers.length !== 0) {
- const endSessions = Array.from(this.s.sessionPool.sessions, ({ id }) => id);
- if (endSessions.length !== 0) {
- await this.db("admin").command({ endSessions }, { readPreference: read_preference_1.ReadPreference.primaryPreferred, noResponse: true }).catch(() => null);
- }
- }
- const topology = this.topology;
- this.topology = void 0;
- await new Promise((resolve, reject) => {
- topology.close({ force }, (error) => {
- if (error)
- return reject(error);
- const { encrypter } = this[kOptions];
- if (encrypter) {
- return encrypter.close(this, force, (error2) => {
- if (error2)
- return reject(error2);
- resolve();
- });
- }
- resolve();
- });
- });
- }
- /**
- * Create a new Db instance sharing the current socket connections.
- *
- * @param dbName - The name of the database we want to use. If not provided, use database name from connection string.
- * @param options - Optional settings for Db construction
- */
- db(dbName, options) {
- options = options ?? {};
- if (!dbName) {
- dbName = this.options.dbName;
- }
- const finalOptions = Object.assign({}, this[kOptions], options);
- const db = new db_1.Db(this, dbName, finalOptions);
- return db;
- }
- /**
- * Connect to MongoDB using a url
- *
- * @remarks
- * The programmatically provided options take precedence over the URI options.
- *
- * @see https://www.mongodb.com/docs/manual/reference/connection-string/
- */
- static async connect(url, options) {
- const client = new this(url, options);
- return client.connect();
- }
- /** Starts a new session on the server */
- startSession(options) {
- const session = new sessions_1.ClientSession(this, this.s.sessionPool, { explicit: true, ...options }, this[kOptions]);
- this.s.activeSessions.add(session);
- session.once("ended", () => {
- this.s.activeSessions.delete(session);
- });
- return session;
- }
- async withSession(optionsOrOperation, callback) {
- const options = {
- // Always define an owner
- owner: Symbol(),
- // If it's an object inherit the options
- ...typeof optionsOrOperation === "object" ? optionsOrOperation : {}
- };
- const withSessionCallback = typeof optionsOrOperation === "function" ? optionsOrOperation : callback;
- if (withSessionCallback == null) {
- throw new error_1.MongoInvalidArgumentError("Missing required callback parameter");
- }
- const session = this.startSession(options);
- try {
- await withSessionCallback(session);
- } finally {
- try {
- await session.endSession();
- } catch {
- }
- }
- }
- /**
- * Create a new Change Stream, watching for new changes (insertions, updates,
- * replacements, deletions, and invalidations) in this cluster. Will ignore all
- * changes to system collections, as well as the local, admin, and config databases.
- *
- * @remarks
- * watch() accepts two generic arguments for distinct use cases:
- * - The first is to provide the schema that may be defined for all the data within the current cluster
- * - The second is to override the shape of the change stream document entirely, if it is not provided the type will default to ChangeStreamDocument of the first argument
- *
- * @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
- * @param options - Optional settings for the command
- * @typeParam TSchema - Type of the data being detected by the change stream
- * @typeParam TChange - Type of the whole change stream document emitted
- */
- watch(pipeline = [], options = {}) {
- if (!Array.isArray(pipeline)) {
- options = pipeline;
- pipeline = [];
- }
- return new change_stream_1.ChangeStream(this, pipeline, (0, utils_1.resolveOptions)(this, options));
- }
- };
- exports2.MongoClient = MongoClient2;
- }
- });
- // node_modules/mongodb/lib/change_stream.js
- var require_change_stream = __commonJS({
- "node_modules/mongodb/lib/change_stream.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.ChangeStream = void 0;
- var collection_1 = require_collection();
- var constants_1 = require_constants2();
- var change_stream_cursor_1 = require_change_stream_cursor();
- var db_1 = require_db();
- var error_1 = require_error();
- var mongo_client_1 = require_mongo_client();
- var mongo_types_1 = require_mongo_types();
- var utils_1 = require_utils();
- var kCursorStream = Symbol("cursorStream");
- var kClosed = Symbol("closed");
- var kMode = Symbol("mode");
- var CHANGE_STREAM_OPTIONS = [
- "resumeAfter",
- "startAfter",
- "startAtOperationTime",
- "fullDocument",
- "fullDocumentBeforeChange",
- "showExpandedEvents"
- ];
- var CHANGE_DOMAIN_TYPES = {
- COLLECTION: Symbol("Collection"),
- DATABASE: Symbol("Database"),
- CLUSTER: Symbol("Cluster")
- };
- var CHANGE_STREAM_EVENTS = [constants_1.RESUME_TOKEN_CHANGED, constants_1.END, constants_1.CLOSE];
- var NO_RESUME_TOKEN_ERROR = "A change stream document has been received that lacks a resume token (_id).";
- var CHANGESTREAM_CLOSED_ERROR = "ChangeStream is closed";
- var ChangeStream = class _ChangeStream extends mongo_types_1.TypedEventEmitter {
- /**
- * @internal
- *
- * @param parent - The parent object that created this change stream
- * @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents
- */
- constructor(parent, pipeline = [], options = {}) {
- super();
- this.pipeline = pipeline;
- this.options = { ...options };
- delete this.options.writeConcern;
- if (parent instanceof collection_1.Collection) {
- this.type = CHANGE_DOMAIN_TYPES.COLLECTION;
- } else if (parent instanceof db_1.Db) {
- this.type = CHANGE_DOMAIN_TYPES.DATABASE;
- } else if (parent instanceof mongo_client_1.MongoClient) {
- this.type = CHANGE_DOMAIN_TYPES.CLUSTER;
- } else {
- throw new error_1.MongoChangeStreamError("Parent provided to ChangeStream constructor must be an instance of Collection, Db, or MongoClient");
- }
- this.parent = parent;
- this.namespace = parent.s.namespace;
- if (!this.options.readPreference && parent.readPreference) {
- this.options.readPreference = parent.readPreference;
- }
- this.cursor = this._createChangeStreamCursor(options);
- this[kClosed] = false;
- this[kMode] = false;
- this.on("newListener", (eventName) => {
- if (eventName === "change" && this.cursor && this.listenerCount("change") === 0) {
- this._streamEvents(this.cursor);
- }
- });
- this.on("removeListener", (eventName) => {
- var _a;
- if (eventName === "change" && this.listenerCount("change") === 0 && this.cursor) {
- (_a = this[kCursorStream]) == null ? void 0 : _a.removeAllListeners("data");
- }
- });
- }
- /** @internal */
- get cursorStream() {
- return this[kCursorStream];
- }
- /** The cached resume token that is used to resume after the most recently returned change. */
- get resumeToken() {
- var _a;
- return (_a = this.cursor) == null ? void 0 : _a.resumeToken;
- }
- /** Check if there is any document still available in the Change Stream */
- async hasNext() {
- this._setIsIterator();
- while (true) {
- try {
- const hasNext = await this.cursor.hasNext();
- return hasNext;
- } catch (error) {
- try {
- await this._processErrorIteratorMode(error);
- } catch (error2) {
- try {
- await this.close();
- } catch {
- }
- throw error2;
- }
- }
- }
- }
- /** Get the next available document from the Change Stream. */
- async next() {
- this._setIsIterator();
- while (true) {
- try {
- const change = await this.cursor.next();
- const processedChange = this._processChange(change ?? null);
- return processedChange;
- } catch (error) {
- try {
- await this._processErrorIteratorMode(error);
- } catch (error2) {
- try {
- await this.close();
- } catch {
- }
- throw error2;
- }
- }
- }
- }
- /**
- * Try to get the next available document from the Change Stream's cursor or `null` if an empty batch is returned
- */
- async tryNext() {
- this._setIsIterator();
- while (true) {
- try {
- const change = await this.cursor.tryNext();
- return change ?? null;
- } catch (error) {
- try {
- await this._processErrorIteratorMode(error);
- } catch (error2) {
- try {
- await this.close();
- } catch {
- }
- throw error2;
- }
- }
- }
- }
- async *[Symbol.asyncIterator]() {
- if (this.closed) {
- return;
- }
- try {
- while (true) {
- yield await this.next();
- }
- } finally {
- try {
- await this.close();
- } catch {
- }
- }
- }
- /** Is the cursor closed */
- get closed() {
- return this[kClosed] || this.cursor.closed;
- }
- /** Close the Change Stream */
- async close() {
- this[kClosed] = true;
- const cursor = this.cursor;
- try {
- await cursor.close();
- } finally {
- this._endStream();
- }
- }
- /**
- * Return a modified Readable stream including a possible transform method.
- *
- * NOTE: When using a Stream to process change stream events, the stream will
- * NOT automatically resume in the case a resumable error is encountered.
- *
- * @throws MongoChangeStreamError if the underlying cursor or the change stream is closed
- */
- stream(options) {
- if (this.closed) {
- throw new error_1.MongoChangeStreamError(CHANGESTREAM_CLOSED_ERROR);
- }
- this.streamOptions = options;
- return this.cursor.stream(options);
- }
- /** @internal */
- _setIsEmitter() {
- if (this[kMode] === "iterator") {
- throw new error_1.MongoAPIError("ChangeStream cannot be used as an EventEmitter after being used as an iterator");
- }
- this[kMode] = "emitter";
- }
- /** @internal */
- _setIsIterator() {
- if (this[kMode] === "emitter") {
- throw new error_1.MongoAPIError("ChangeStream cannot be used as an iterator after being used as an EventEmitter");
- }
- this[kMode] = "iterator";
- }
- /**
- * Create a new change stream cursor based on self's configuration
- * @internal
- */
- _createChangeStreamCursor(options) {
- const changeStreamStageOptions = (0, utils_1.filterOptions)(options, CHANGE_STREAM_OPTIONS);
- if (this.type === CHANGE_DOMAIN_TYPES.CLUSTER) {
- changeStreamStageOptions.allChangesForCluster = true;
- }
- const pipeline = [{ $changeStream: changeStreamStageOptions }, ...this.pipeline];
- const client = this.type === CHANGE_DOMAIN_TYPES.CLUSTER ? this.parent : this.type === CHANGE_DOMAIN_TYPES.DATABASE ? this.parent.client : this.type === CHANGE_DOMAIN_TYPES.COLLECTION ? this.parent.client : null;
- if (client == null) {
- throw new error_1.MongoRuntimeError(`Changestream type should only be one of cluster, database, collection. Found ${this.type.toString()}`);
- }
- const changeStreamCursor = new change_stream_cursor_1.ChangeStreamCursor(client, this.namespace, pipeline, options);
- for (const event of CHANGE_STREAM_EVENTS) {
- changeStreamCursor.on(event, (e) => this.emit(event, e));
- }
- if (this.listenerCount(_ChangeStream.CHANGE) > 0) {
- this._streamEvents(changeStreamCursor);
- }
- return changeStreamCursor;
- }
- /** @internal */
- _closeEmitterModeWithError(error) {
- this.emit(_ChangeStream.ERROR, error);
- this.close().catch(() => null);
- }
- /** @internal */
- _streamEvents(cursor) {
- this._setIsEmitter();
- const stream = this[kCursorStream] ?? cursor.stream();
- this[kCursorStream] = stream;
- stream.on("data", (change) => {
- try {
- const processedChange = this._processChange(change);
- this.emit(_ChangeStream.CHANGE, processedChange);
- } catch (error) {
- this.emit(_ChangeStream.ERROR, error);
- }
- });
- stream.on("error", (error) => this._processErrorStreamMode(error));
- }
- /** @internal */
- _endStream() {
- const cursorStream = this[kCursorStream];
- if (cursorStream) {
- ["data", "close", "end", "error"].forEach((event) => cursorStream.removeAllListeners(event));
- cursorStream.destroy();
- }
- this[kCursorStream] = void 0;
- }
- /** @internal */
- _processChange(change) {
- if (this[kClosed]) {
- throw new error_1.MongoAPIError(CHANGESTREAM_CLOSED_ERROR);
- }
- if (change == null) {
- throw new error_1.MongoRuntimeError(CHANGESTREAM_CLOSED_ERROR);
- }
- if (change && !change._id) {
- throw new error_1.MongoChangeStreamError(NO_RESUME_TOKEN_ERROR);
- }
- this.cursor.cacheResumeToken(change._id);
- this.options.startAtOperationTime = void 0;
- return change;
- }
- /** @internal */
- _processErrorStreamMode(changeStreamError) {
- if (this[kClosed])
- return;
- if ((0, error_1.isResumableError)(changeStreamError, this.cursor.maxWireVersion)) {
- this._endStream();
- this.cursor.close().catch(() => null);
- const topology = (0, utils_1.getTopology)(this.parent);
- topology.selectServer(this.cursor.readPreference, {}, (serverSelectionError) => {
- if (serverSelectionError)
- return this._closeEmitterModeWithError(changeStreamError);
- this.cursor = this._createChangeStreamCursor(this.cursor.resumeOptions);
- });
- } else {
- this._closeEmitterModeWithError(changeStreamError);
- }
- }
- /** @internal */
- async _processErrorIteratorMode(changeStreamError) {
- if (this[kClosed]) {
- throw new error_1.MongoAPIError(CHANGESTREAM_CLOSED_ERROR);
- }
- if (!(0, error_1.isResumableError)(changeStreamError, this.cursor.maxWireVersion)) {
- try {
- await this.close();
- } catch {
- }
- throw changeStreamError;
- }
- await this.cursor.close().catch(() => null);
- const topology = (0, utils_1.getTopology)(this.parent);
- try {
- await topology.selectServerAsync(this.cursor.readPreference, {});
- this.cursor = this._createChangeStreamCursor(this.cursor.resumeOptions);
- } catch {
- await this.close();
- throw changeStreamError;
- }
- }
- };
- ChangeStream.RESPONSE = constants_1.RESPONSE;
- ChangeStream.MORE = constants_1.MORE;
- ChangeStream.INIT = constants_1.INIT;
- ChangeStream.CLOSE = constants_1.CLOSE;
- ChangeStream.CHANGE = constants_1.CHANGE;
- ChangeStream.END = constants_1.END;
- ChangeStream.ERROR = constants_1.ERROR;
- ChangeStream.RESUME_TOKEN_CHANGED = constants_1.RESUME_TOKEN_CHANGED;
- exports2.ChangeStream = ChangeStream;
- }
- });
- // node_modules/mongodb/lib/gridfs/download.js
- var require_download = __commonJS({
- "node_modules/mongodb/lib/gridfs/download.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.GridFSBucketReadStream = void 0;
- var stream_1 = require("stream");
- var error_1 = require_error();
- var GridFSBucketReadStream = class _GridFSBucketReadStream extends stream_1.Readable {
- /**
- * @param chunks - Handle for chunks collection
- * @param files - Handle for files collection
- * @param readPreference - The read preference to use
- * @param filter - The filter to use to find the file document
- * @internal
- */
- constructor(chunks, files, readPreference, filter, options) {
- super();
- this.s = {
- bytesToTrim: 0,
- bytesToSkip: 0,
- bytesRead: 0,
- chunks,
- expected: 0,
- files,
- filter,
- init: false,
- expectedEnd: 0,
- options: {
- start: 0,
- end: 0,
- ...options
- },
- readPreference
- };
- }
- /**
- * Reads from the cursor and pushes to the stream.
- * Private Impl, do not call directly
- * @internal
- */
- _read() {
- if (this.destroyed)
- return;
- waitForFile(this, () => doRead(this));
- }
- /**
- * Sets the 0-based offset in bytes to start streaming from. Throws
- * an error if this stream has entered flowing mode
- * (e.g. if you've already called `on('data')`)
- *
- * @param start - 0-based offset in bytes to start streaming from
- */
- start(start = 0) {
- throwIfInitialized(this);
- this.s.options.start = start;
- return this;
- }
- /**
- * Sets the 0-based offset in bytes to start streaming from. Throws
- * an error if this stream has entered flowing mode
- * (e.g. if you've already called `on('data')`)
- *
- * @param end - Offset in bytes to stop reading at
- */
- end(end = 0) {
- throwIfInitialized(this);
- this.s.options.end = end;
- return this;
- }
- /**
- * Marks this stream as aborted (will never push another `data` event)
- * and kills the underlying cursor. Will emit the 'end' event, and then
- * the 'close' event once the cursor is successfully killed.
- */
- async abort() {
- this.push(null);
- this.destroyed = true;
- if (this.s.cursor) {
- try {
- await this.s.cursor.close();
- } finally {
- this.emit(_GridFSBucketReadStream.CLOSE);
- }
- } else {
- if (!this.s.init) {
- this.emit(_GridFSBucketReadStream.CLOSE);
- }
- }
- }
- };
- GridFSBucketReadStream.ERROR = "error";
- GridFSBucketReadStream.FILE = "file";
- GridFSBucketReadStream.DATA = "data";
- GridFSBucketReadStream.END = "end";
- GridFSBucketReadStream.CLOSE = "close";
- exports2.GridFSBucketReadStream = GridFSBucketReadStream;
- function throwIfInitialized(stream) {
- if (stream.s.init) {
- throw new error_1.MongoGridFSStreamError("Options cannot be changed after the stream is initialized");
- }
- }
- function doRead(stream) {
- if (stream.destroyed)
- return;
- if (!stream.s.cursor)
- return;
- if (!stream.s.file)
- return;
- const handleReadResult = ({ error, doc }) => {
- var _a;
- if (stream.destroyed) {
- return;
- }
- if (error) {
- stream.emit(GridFSBucketReadStream.ERROR, error);
- return;
- }
- if (!doc) {
- stream.push(null);
- (_a = stream.s.cursor) == null ? void 0 : _a.close().then(() => {
- stream.emit(GridFSBucketReadStream.CLOSE);
- }, (error2) => {
- stream.emit(GridFSBucketReadStream.ERROR, error2);
- });
- return;
- }
- if (!stream.s.file)
- return;
- const bytesRemaining = stream.s.file.length - stream.s.bytesRead;
- const expectedN = stream.s.expected++;
- const expectedLength = Math.min(stream.s.file.chunkSize, bytesRemaining);
- if (doc.n > expectedN) {
- return stream.emit(GridFSBucketReadStream.ERROR, new error_1.MongoGridFSChunkError(`ChunkIsMissing: Got unexpected n: ${doc.n}, expected: ${expectedN}`));
- }
- if (doc.n < expectedN) {
- return stream.emit(GridFSBucketReadStream.ERROR, new error_1.MongoGridFSChunkError(`ExtraChunk: Got unexpected n: ${doc.n}, expected: ${expectedN}`));
- }
- let buf = Buffer.isBuffer(doc.data) ? doc.data : doc.data.buffer;
- if (buf.byteLength !== expectedLength) {
- if (bytesRemaining <= 0) {
- return stream.emit(GridFSBucketReadStream.ERROR, new error_1.MongoGridFSChunkError(`ExtraChunk: Got unexpected n: ${doc.n}, expected file length ${stream.s.file.length} bytes but already read ${stream.s.bytesRead} bytes`));
- }
- return stream.emit(GridFSBucketReadStream.ERROR, new error_1.MongoGridFSChunkError(`ChunkIsWrongSize: Got unexpected length: ${buf.byteLength}, expected: ${expectedLength}`));
- }
- stream.s.bytesRead += buf.byteLength;
- if (buf.byteLength === 0) {
- return stream.push(null);
- }
- let sliceStart = null;
- let sliceEnd = null;
- if (stream.s.bytesToSkip != null) {
- sliceStart = stream.s.bytesToSkip;
- stream.s.bytesToSkip = 0;
- }
- const atEndOfStream = expectedN === stream.s.expectedEnd - 1;
- const bytesLeftToRead = stream.s.options.end - stream.s.bytesToSkip;
- if (atEndOfStream && stream.s.bytesToTrim != null) {
- sliceEnd = stream.s.file.chunkSize - stream.s.bytesToTrim;
- } else if (stream.s.options.end && bytesLeftToRead < doc.data.byteLength) {
- sliceEnd = bytesLeftToRead;
- }
- if (sliceStart != null || sliceEnd != null) {
- buf = buf.slice(sliceStart || 0, sliceEnd || buf.byteLength);
- }
- stream.push(buf);
- return;
- };
- stream.s.cursor.next().then((doc) => handleReadResult({ error: null, doc }), (error) => handleReadResult({ error, doc: null }));
- }
- function init(stream) {
- const findOneOptions = {};
- if (stream.s.readPreference) {
- findOneOptions.readPreference = stream.s.readPreference;
- }
- if (stream.s.options && stream.s.options.sort) {
- findOneOptions.sort = stream.s.options.sort;
- }
- if (stream.s.options && stream.s.options.skip) {
- findOneOptions.skip = stream.s.options.skip;
- }
- const handleReadResult = ({ error, doc }) => {
- if (error) {
- return stream.emit(GridFSBucketReadStream.ERROR, error);
- }
- if (!doc) {
- const identifier = stream.s.filter._id ? stream.s.filter._id.toString() : stream.s.filter.filename;
- const errmsg = `FileNotFound: file ${identifier} was not found`;
- const err = new error_1.MongoRuntimeError(errmsg);
- err.code = "ENOENT";
- return stream.emit(GridFSBucketReadStream.ERROR, err);
- }
- if (doc.length <= 0) {
- stream.push(null);
- return;
- }
- if (stream.destroyed) {
- stream.emit(GridFSBucketReadStream.CLOSE);
- return;
- }
- try {
- stream.s.bytesToSkip = handleStartOption(stream, doc, stream.s.options);
- } catch (error2) {
- return stream.emit(GridFSBucketReadStream.ERROR, error2);
- }
- const filter = { files_id: doc._id };
- if (stream.s.options && stream.s.options.start != null) {
- const skip = Math.floor(stream.s.options.start / doc.chunkSize);
- if (skip > 0) {
- filter["n"] = { $gte: skip };
- }
- }
- stream.s.cursor = stream.s.chunks.find(filter).sort({ n: 1 });
- if (stream.s.readPreference) {
- stream.s.cursor.withReadPreference(stream.s.readPreference);
- }
- stream.s.expectedEnd = Math.ceil(doc.length / doc.chunkSize);
- stream.s.file = doc;
- try {
- stream.s.bytesToTrim = handleEndOption(stream, doc, stream.s.cursor, stream.s.options);
- } catch (error2) {
- return stream.emit(GridFSBucketReadStream.ERROR, error2);
- }
- stream.emit(GridFSBucketReadStream.FILE, doc);
- return;
- };
- stream.s.files.findOne(stream.s.filter, findOneOptions).then((doc) => handleReadResult({ error: null, doc }), (error) => handleReadResult({ error, doc: null }));
- }
- function waitForFile(stream, callback) {
- if (stream.s.file) {
- return callback();
- }
- if (!stream.s.init) {
- init(stream);
- stream.s.init = true;
- }
- stream.once("file", () => {
- callback();
- });
- }
- function handleStartOption(stream, doc, options) {
- if (options && options.start != null) {
- if (options.start > doc.length) {
- throw new error_1.MongoInvalidArgumentError(`Stream start (${options.start}) must not be more than the length of the file (${doc.length})`);
- }
- if (options.start < 0) {
- throw new error_1.MongoInvalidArgumentError(`Stream start (${options.start}) must not be negative`);
- }
- if (options.end != null && options.end < options.start) {
- throw new error_1.MongoInvalidArgumentError(`Stream start (${options.start}) must not be greater than stream end (${options.end})`);
- }
- stream.s.bytesRead = Math.floor(options.start / doc.chunkSize) * doc.chunkSize;
- stream.s.expected = Math.floor(options.start / doc.chunkSize);
- return options.start - stream.s.bytesRead;
- }
- throw new error_1.MongoInvalidArgumentError("Start option must be defined");
- }
- function handleEndOption(stream, doc, cursor, options) {
- if (options && options.end != null) {
- if (options.end > doc.length) {
- throw new error_1.MongoInvalidArgumentError(`Stream end (${options.end}) must not be more than the length of the file (${doc.length})`);
- }
- if (options.start == null || options.start < 0) {
- throw new error_1.MongoInvalidArgumentError(`Stream end (${options.end}) must not be negative`);
- }
- const start = options.start != null ? Math.floor(options.start / doc.chunkSize) : 0;
- cursor.limit(Math.ceil(options.end / doc.chunkSize) - start);
- stream.s.expectedEnd = Math.ceil(options.end / doc.chunkSize);
- return Math.ceil(options.end / doc.chunkSize) * doc.chunkSize - options.end;
- }
- throw new error_1.MongoInvalidArgumentError("End option must be defined");
- }
- }
- });
- // node_modules/mongodb/lib/gridfs/upload.js
- var require_upload = __commonJS({
- "node_modules/mongodb/lib/gridfs/upload.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.GridFSBucketWriteStream = void 0;
- var stream_1 = require("stream");
- var bson_1 = require_bson2();
- var error_1 = require_error();
- var write_concern_1 = require_write_concern();
- var GridFSBucketWriteStream = class _GridFSBucketWriteStream extends stream_1.Writable {
- /**
- * @param bucket - Handle for this stream's corresponding bucket
- * @param filename - The value of the 'filename' key in the files doc
- * @param options - Optional settings.
- * @internal
- */
- constructor(bucket, filename, options) {
- super();
- options = options ?? {};
- this.bucket = bucket;
- this.chunks = bucket.s._chunksCollection;
- this.filename = filename;
- this.files = bucket.s._filesCollection;
- this.options = options;
- this.writeConcern = write_concern_1.WriteConcern.fromOptions(options) || bucket.s.options.writeConcern;
- this.done = false;
- this.id = options.id ? options.id : new bson_1.ObjectId();
- this.chunkSizeBytes = options.chunkSizeBytes || this.bucket.s.options.chunkSizeBytes;
- this.bufToStore = Buffer.alloc(this.chunkSizeBytes);
- this.length = 0;
- this.n = 0;
- this.pos = 0;
- this.state = {
- streamEnd: false,
- outstandingRequests: 0,
- errored: false,
- aborted: false
- };
- if (!this.bucket.s.calledOpenUploadStream) {
- this.bucket.s.calledOpenUploadStream = true;
- checkIndexes(this).then(() => {
- this.bucket.s.checkedIndexes = true;
- this.bucket.emit("index");
- }, () => null);
- }
- }
- write(chunk, encodingOrCallback, callback) {
- const encoding = typeof encodingOrCallback === "function" ? void 0 : encodingOrCallback;
- callback = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
- return waitForIndexes(this, () => doWrite(this, chunk, encoding, callback));
- }
- /**
- * Places this write stream into an aborted state (all future writes fail)
- * and deletes all chunks that have already been written.
- */
- async abort() {
- if (this.state.streamEnd) {
- throw new error_1.MongoAPIError("Cannot abort a stream that has already completed");
- }
- if (this.state.aborted) {
- throw new error_1.MongoAPIError("Cannot call abort() on a stream twice");
- }
- this.state.aborted = true;
- await this.chunks.deleteMany({ files_id: this.id });
- }
- end(chunkOrCallback, encodingOrCallback, callback) {
- const chunk = typeof chunkOrCallback === "function" ? void 0 : chunkOrCallback;
- const encoding = typeof encodingOrCallback === "function" ? void 0 : encodingOrCallback;
- callback = typeof chunkOrCallback === "function" ? chunkOrCallback : typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
- if (this.state.streamEnd || checkAborted(this, callback))
- return this;
- this.state.streamEnd = true;
- if (callback) {
- this.once(_GridFSBucketWriteStream.FINISH, (result) => {
- if (callback)
- callback(void 0, result);
- });
- }
- if (!chunk) {
- waitForIndexes(this, () => !!writeRemnant(this));
- return this;
- }
- this.write(chunk, encoding, () => {
- writeRemnant(this);
- });
- return this;
- }
- };
- GridFSBucketWriteStream.CLOSE = "close";
- GridFSBucketWriteStream.ERROR = "error";
- GridFSBucketWriteStream.FINISH = "finish";
- exports2.GridFSBucketWriteStream = GridFSBucketWriteStream;
- function __handleError(stream, error, callback) {
- if (stream.state.errored) {
- return;
- }
- stream.state.errored = true;
- if (callback) {
- return callback(error);
- }
- stream.emit(GridFSBucketWriteStream.ERROR, error);
- }
- function createChunkDoc(filesId, n, data) {
- return {
- _id: new bson_1.ObjectId(),
- files_id: filesId,
- n,
- data
- };
- }
- async function checkChunksIndex(stream) {
- const index = { files_id: 1, n: 1 };
- let indexes;
- try {
- indexes = await stream.chunks.listIndexes().toArray();
- } catch (error) {
- if (error instanceof error_1.MongoError && error.code === error_1.MONGODB_ERROR_CODES.NamespaceNotFound) {
- indexes = [];
- } else {
- throw error;
- }
- }
- const hasChunksIndex = !!indexes.find((index2) => {
- const keys = Object.keys(index2.key);
- if (keys.length === 2 && index2.key.files_id === 1 && index2.key.n === 1) {
- return true;
- }
- return false;
- });
- if (!hasChunksIndex) {
- await stream.chunks.createIndex(index, {
- ...stream.writeConcern,
- background: true,
- unique: true
- });
- }
- }
- function checkDone(stream, callback) {
- if (stream.done)
- return true;
- if (stream.state.streamEnd && stream.state.outstandingRequests === 0 && !stream.state.errored) {
- stream.done = true;
- const filesDoc = createFilesDoc(stream.id, stream.length, stream.chunkSizeBytes, stream.filename, stream.options.contentType, stream.options.aliases, stream.options.metadata);
- if (checkAborted(stream, callback)) {
- return false;
- }
- stream.files.insertOne(filesDoc, { writeConcern: stream.writeConcern }).then(() => {
- stream.emit(GridFSBucketWriteStream.FINISH, filesDoc);
- stream.emit(GridFSBucketWriteStream.CLOSE);
- }, (error) => {
- return __handleError(stream, error, callback);
- });
- return true;
- }
- return false;
- }
- async function checkIndexes(stream) {
- const doc = await stream.files.findOne({}, { projection: { _id: 1 } });
- if (doc != null) {
- return;
- }
- const index = { filename: 1, uploadDate: 1 };
- let indexes;
- try {
- indexes = await stream.files.listIndexes().toArray();
- } catch (error) {
- if (error instanceof error_1.MongoError && error.code === error_1.MONGODB_ERROR_CODES.NamespaceNotFound) {
- indexes = [];
- } else {
- throw error;
- }
- }
- const hasFileIndex = !!indexes.find((index2) => {
- const keys = Object.keys(index2.key);
- if (keys.length === 2 && index2.key.filename === 1 && index2.key.uploadDate === 1) {
- return true;
- }
- return false;
- });
- if (!hasFileIndex) {
- await stream.files.createIndex(index, { background: false });
- }
- await checkChunksIndex(stream);
- }
- function createFilesDoc(_id, length, chunkSize, filename, contentType, aliases, metadata) {
- const ret = {
- _id,
- length,
- chunkSize,
- uploadDate: /* @__PURE__ */ new Date(),
- filename
- };
- if (contentType) {
- ret.contentType = contentType;
- }
- if (aliases) {
- ret.aliases = aliases;
- }
- if (metadata) {
- ret.metadata = metadata;
- }
- return ret;
- }
- function doWrite(stream, chunk, encoding, callback) {
- if (checkAborted(stream, callback)) {
- return false;
- }
- const inputBuf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding);
- stream.length += inputBuf.length;
- if (stream.pos + inputBuf.length < stream.chunkSizeBytes) {
- inputBuf.copy(stream.bufToStore, stream.pos);
- stream.pos += inputBuf.length;
- callback && callback();
- return true;
- }
- let inputBufRemaining = inputBuf.length;
- let spaceRemaining = stream.chunkSizeBytes - stream.pos;
- let numToCopy = Math.min(spaceRemaining, inputBuf.length);
- let outstandingRequests = 0;
- while (inputBufRemaining > 0) {
- const inputBufPos = inputBuf.length - inputBufRemaining;
- inputBuf.copy(stream.bufToStore, stream.pos, inputBufPos, inputBufPos + numToCopy);
- stream.pos += numToCopy;
- spaceRemaining -= numToCopy;
- let doc;
- if (spaceRemaining === 0) {
- doc = createChunkDoc(stream.id, stream.n, Buffer.from(stream.bufToStore));
- ++stream.state.outstandingRequests;
- ++outstandingRequests;
- if (checkAborted(stream, callback)) {
- return false;
- }
- stream.chunks.insertOne(doc, { writeConcern: stream.writeConcern }).then(() => {
- --stream.state.outstandingRequests;
- --outstandingRequests;
- if (!outstandingRequests) {
- stream.emit("drain", doc);
- callback && callback();
- checkDone(stream);
- }
- }, (error) => {
- return __handleError(stream, error);
- });
- spaceRemaining = stream.chunkSizeBytes;
- stream.pos = 0;
- ++stream.n;
- }
- inputBufRemaining -= numToCopy;
- numToCopy = Math.min(spaceRemaining, inputBufRemaining);
- }
- return false;
- }
- function waitForIndexes(stream, callback) {
- if (stream.bucket.s.checkedIndexes) {
- return callback(false);
- }
- stream.bucket.once("index", () => {
- callback(true);
- });
- return true;
- }
- function writeRemnant(stream, callback) {
- if (stream.pos === 0) {
- return checkDone(stream, callback);
- }
- ++stream.state.outstandingRequests;
- const remnant = Buffer.alloc(stream.pos);
- stream.bufToStore.copy(remnant, 0, 0, stream.pos);
- const doc = createChunkDoc(stream.id, stream.n, remnant);
- if (checkAborted(stream, callback)) {
- return false;
- }
- stream.chunks.insertOne(doc, { writeConcern: stream.writeConcern }).then(() => {
- --stream.state.outstandingRequests;
- checkDone(stream);
- }, (error) => {
- return __handleError(stream, error);
- });
- return true;
- }
- function checkAborted(stream, callback) {
- if (stream.state.aborted) {
- if (typeof callback === "function") {
- callback(new error_1.MongoAPIError("Stream has been aborted"));
- }
- return true;
- }
- return false;
- }
- }
- });
- // node_modules/mongodb/lib/gridfs/index.js
- var require_gridfs = __commonJS({
- "node_modules/mongodb/lib/gridfs/index.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.GridFSBucket = void 0;
- var error_1 = require_error();
- var mongo_types_1 = require_mongo_types();
- var write_concern_1 = require_write_concern();
- var download_1 = require_download();
- var upload_1 = require_upload();
- var DEFAULT_GRIDFS_BUCKET_OPTIONS = {
- bucketName: "fs",
- chunkSizeBytes: 255 * 1024
- };
- var GridFSBucket = class extends mongo_types_1.TypedEventEmitter {
- constructor(db, options) {
- super();
- this.setMaxListeners(0);
- const privateOptions = {
- ...DEFAULT_GRIDFS_BUCKET_OPTIONS,
- ...options,
- writeConcern: write_concern_1.WriteConcern.fromOptions(options)
- };
- this.s = {
- db,
- options: privateOptions,
- _chunksCollection: db.collection(privateOptions.bucketName + ".chunks"),
- _filesCollection: db.collection(privateOptions.bucketName + ".files"),
- checkedIndexes: false,
- calledOpenUploadStream: false
- };
- }
- /**
- * Returns a writable stream (GridFSBucketWriteStream) for writing
- * buffers to GridFS. The stream's 'id' property contains the resulting
- * file's id.
- *
- * @param filename - The value of the 'filename' key in the files doc
- * @param options - Optional settings.
- */
- openUploadStream(filename, options) {
- return new upload_1.GridFSBucketWriteStream(this, filename, options);
- }
- /**
- * Returns a writable stream (GridFSBucketWriteStream) for writing
- * buffers to GridFS for a custom file id. The stream's 'id' property contains the resulting
- * file's id.
- */
- openUploadStreamWithId(id, filename, options) {
- return new upload_1.GridFSBucketWriteStream(this, filename, { ...options, id });
- }
- /** Returns a readable stream (GridFSBucketReadStream) for streaming file data from GridFS. */
- openDownloadStream(id, options) {
- return new download_1.GridFSBucketReadStream(this.s._chunksCollection, this.s._filesCollection, this.s.options.readPreference, { _id: id }, options);
- }
- /**
- * Deletes a file with the given id
- *
- * @param id - The id of the file doc
- */
- async delete(id) {
- const { deletedCount } = await this.s._filesCollection.deleteOne({ _id: id });
- await this.s._chunksCollection.deleteMany({ files_id: id });
- if (deletedCount === 0) {
- throw new error_1.MongoRuntimeError(`File not found for id ${id}`);
- }
- }
- /** Convenience wrapper around find on the files collection */
- find(filter = {}, options = {}) {
- return this.s._filesCollection.find(filter, options);
- }
- /**
- * Returns a readable stream (GridFSBucketReadStream) for streaming the
- * file with the given name from GridFS. If there are multiple files with
- * the same name, this will stream the most recent file with the given name
- * (as determined by the `uploadDate` field). You can set the `revision`
- * option to change this behavior.
- */
- openDownloadStreamByName(filename, options) {
- let sort = { uploadDate: -1 };
- let skip = void 0;
- if (options && options.revision != null) {
- if (options.revision >= 0) {
- sort = { uploadDate: 1 };
- skip = options.revision;
- } else {
- skip = -options.revision - 1;
- }
- }
- return new download_1.GridFSBucketReadStream(this.s._chunksCollection, this.s._filesCollection, this.s.options.readPreference, { filename }, { ...options, sort, skip });
- }
- /**
- * Renames the file with the given _id to the given string
- *
- * @param id - the id of the file to rename
- * @param filename - new name for the file
- */
- async rename(id, filename) {
- const filter = { _id: id };
- const update = { $set: { filename } };
- const { matchedCount } = await this.s._filesCollection.updateOne(filter, update);
- if (matchedCount === 0) {
- throw new error_1.MongoRuntimeError(`File with id ${id} not found`);
- }
- }
- /** Removes this bucket's files collection, followed by its chunks collection. */
- async drop() {
- await this.s._filesCollection.drop();
- await this.s._chunksCollection.drop();
- }
- };
- GridFSBucket.INDEX = "index";
- exports2.GridFSBucket = GridFSBucket;
- }
- });
- // node_modules/mongodb/lib/index.js
- var require_lib3 = __commonJS({
- "node_modules/mongodb/lib/index.js"(exports2) {
- "use strict";
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.AbstractCursor = exports2.MongoWriteConcernError = exports2.MongoUnexpectedServerResponseError = exports2.MongoTransactionError = exports2.MongoTopologyClosedError = exports2.MongoTailableCursorError = exports2.MongoSystemError = exports2.MongoServerSelectionError = exports2.MongoServerError = exports2.MongoServerClosedError = exports2.MongoRuntimeError = exports2.MongoParseError = exports2.MongoNotConnectedError = exports2.MongoNetworkTimeoutError = exports2.MongoNetworkError = exports2.MongoMissingDependencyError = exports2.MongoMissingCredentialsError = exports2.MongoKerberosError = exports2.MongoInvalidArgumentError = exports2.MongoGridFSStreamError = exports2.MongoGridFSChunkError = exports2.MongoExpiredSessionError = exports2.MongoError = exports2.MongoDriverError = exports2.MongoDecompressionError = exports2.MongoCursorInUseError = exports2.MongoCursorExhaustedError = exports2.MongoCompatibilityError = exports2.MongoChangeStreamError = exports2.MongoBatchReExecutionError = exports2.MongoAzureError = exports2.MongoAWSError = exports2.MongoAPIError = exports2.ChangeStreamCursor = exports2.MongoBulkWriteError = exports2.Timestamp = exports2.ObjectId = exports2.MinKey = exports2.MaxKey = exports2.Long = exports2.Int32 = exports2.Double = exports2.Decimal128 = exports2.DBRef = exports2.Code = exports2.BSONType = exports2.BSONSymbol = exports2.BSONRegExp = exports2.Binary = exports2.BSON = void 0;
- exports2.ServerClosedEvent = exports2.ConnectionReadyEvent = exports2.ConnectionPoolReadyEvent = exports2.ConnectionPoolMonitoringEvent = exports2.ConnectionPoolCreatedEvent = exports2.ConnectionPoolClosedEvent = exports2.ConnectionPoolClearedEvent = exports2.ConnectionCreatedEvent = exports2.ConnectionClosedEvent = exports2.ConnectionCheckOutStartedEvent = exports2.ConnectionCheckOutFailedEvent = exports2.ConnectionCheckedOutEvent = exports2.ConnectionCheckedInEvent = exports2.CommandSucceededEvent = exports2.CommandStartedEvent = exports2.CommandFailedEvent = exports2.WriteConcern = exports2.ReadPreference = exports2.ReadConcern = exports2.TopologyType = exports2.ServerType = exports2.ReadPreferenceMode = exports2.ReadConcernLevel = exports2.ProfilingLevel = exports2.ReturnDocument = exports2.ServerApiVersion = exports2.ExplainVerbosity = exports2.MongoErrorLabel = exports2.AutoEncryptionLoggerLevel = exports2.CURSOR_FLAGS = exports2.Compressor = exports2.AuthMechanism = exports2.GSSAPICanonicalizationValue = exports2.BatchType = exports2.UnorderedBulkOperation = exports2.OrderedBulkOperation = exports2.MongoClient = exports2.ListIndexesCursor = exports2.ListCollectionsCursor = exports2.GridFSBucketWriteStream = exports2.GridFSBucketReadStream = exports2.GridFSBucket = exports2.FindCursor = exports2.Db = exports2.Collection = exports2.ClientSession = exports2.ChangeStream = exports2.CancellationToken = exports2.AggregationCursor = exports2.Admin = void 0;
- exports2.SrvPollingEvent = exports2.TopologyOpeningEvent = exports2.TopologyDescriptionChangedEvent = exports2.TopologyClosedEvent = exports2.ServerOpeningEvent = exports2.ServerHeartbeatSucceededEvent = exports2.ServerHeartbeatStartedEvent = exports2.ServerHeartbeatFailedEvent = exports2.ServerDescriptionChangedEvent = void 0;
- var admin_1 = require_admin();
- Object.defineProperty(exports2, "Admin", { enumerable: true, get: function() {
- return admin_1.Admin;
- } });
- var ordered_1 = require_ordered();
- Object.defineProperty(exports2, "OrderedBulkOperation", { enumerable: true, get: function() {
- return ordered_1.OrderedBulkOperation;
- } });
- var unordered_1 = require_unordered();
- Object.defineProperty(exports2, "UnorderedBulkOperation", { enumerable: true, get: function() {
- return unordered_1.UnorderedBulkOperation;
- } });
- var change_stream_1 = require_change_stream();
- Object.defineProperty(exports2, "ChangeStream", { enumerable: true, get: function() {
- return change_stream_1.ChangeStream;
- } });
- var collection_1 = require_collection();
- Object.defineProperty(exports2, "Collection", { enumerable: true, get: function() {
- return collection_1.Collection;
- } });
- var abstract_cursor_1 = require_abstract_cursor();
- Object.defineProperty(exports2, "AbstractCursor", { enumerable: true, get: function() {
- return abstract_cursor_1.AbstractCursor;
- } });
- var aggregation_cursor_1 = require_aggregation_cursor();
- Object.defineProperty(exports2, "AggregationCursor", { enumerable: true, get: function() {
- return aggregation_cursor_1.AggregationCursor;
- } });
- var find_cursor_1 = require_find_cursor();
- Object.defineProperty(exports2, "FindCursor", { enumerable: true, get: function() {
- return find_cursor_1.FindCursor;
- } });
- var list_collections_cursor_1 = require_list_collections_cursor();
- Object.defineProperty(exports2, "ListCollectionsCursor", { enumerable: true, get: function() {
- return list_collections_cursor_1.ListCollectionsCursor;
- } });
- var list_indexes_cursor_1 = require_list_indexes_cursor();
- Object.defineProperty(exports2, "ListIndexesCursor", { enumerable: true, get: function() {
- return list_indexes_cursor_1.ListIndexesCursor;
- } });
- var db_1 = require_db();
- Object.defineProperty(exports2, "Db", { enumerable: true, get: function() {
- return db_1.Db;
- } });
- var gridfs_1 = require_gridfs();
- Object.defineProperty(exports2, "GridFSBucket", { enumerable: true, get: function() {
- return gridfs_1.GridFSBucket;
- } });
- var download_1 = require_download();
- Object.defineProperty(exports2, "GridFSBucketReadStream", { enumerable: true, get: function() {
- return download_1.GridFSBucketReadStream;
- } });
- var upload_1 = require_upload();
- Object.defineProperty(exports2, "GridFSBucketWriteStream", { enumerable: true, get: function() {
- return upload_1.GridFSBucketWriteStream;
- } });
- var mongo_client_1 = require_mongo_client();
- Object.defineProperty(exports2, "MongoClient", { enumerable: true, get: function() {
- return mongo_client_1.MongoClient;
- } });
- var mongo_types_1 = require_mongo_types();
- Object.defineProperty(exports2, "CancellationToken", { enumerable: true, get: function() {
- return mongo_types_1.CancellationToken;
- } });
- var sessions_1 = require_sessions();
- Object.defineProperty(exports2, "ClientSession", { enumerable: true, get: function() {
- return sessions_1.ClientSession;
- } });
- var bson_1 = require_bson2();
- Object.defineProperty(exports2, "BSON", { enumerable: true, get: function() {
- return bson_1.BSON;
- } });
- var bson_2 = require_bson2();
- Object.defineProperty(exports2, "Binary", { enumerable: true, get: function() {
- return bson_2.Binary;
- } });
- Object.defineProperty(exports2, "BSONRegExp", { enumerable: true, get: function() {
- return bson_2.BSONRegExp;
- } });
- Object.defineProperty(exports2, "BSONSymbol", { enumerable: true, get: function() {
- return bson_2.BSONSymbol;
- } });
- Object.defineProperty(exports2, "BSONType", { enumerable: true, get: function() {
- return bson_2.BSONType;
- } });
- Object.defineProperty(exports2, "Code", { enumerable: true, get: function() {
- return bson_2.Code;
- } });
- Object.defineProperty(exports2, "DBRef", { enumerable: true, get: function() {
- return bson_2.DBRef;
- } });
- Object.defineProperty(exports2, "Decimal128", { enumerable: true, get: function() {
- return bson_2.Decimal128;
- } });
- Object.defineProperty(exports2, "Double", { enumerable: true, get: function() {
- return bson_2.Double;
- } });
- Object.defineProperty(exports2, "Int32", { enumerable: true, get: function() {
- return bson_2.Int32;
- } });
- Object.defineProperty(exports2, "Long", { enumerable: true, get: function() {
- return bson_2.Long;
- } });
- Object.defineProperty(exports2, "MaxKey", { enumerable: true, get: function() {
- return bson_2.MaxKey;
- } });
- Object.defineProperty(exports2, "MinKey", { enumerable: true, get: function() {
- return bson_2.MinKey;
- } });
- Object.defineProperty(exports2, "ObjectId", { enumerable: true, get: function() {
- return bson_2.ObjectId;
- } });
- Object.defineProperty(exports2, "Timestamp", { enumerable: true, get: function() {
- return bson_2.Timestamp;
- } });
- var common_1 = require_common2();
- Object.defineProperty(exports2, "MongoBulkWriteError", { enumerable: true, get: function() {
- return common_1.MongoBulkWriteError;
- } });
- var change_stream_cursor_1 = require_change_stream_cursor();
- Object.defineProperty(exports2, "ChangeStreamCursor", { enumerable: true, get: function() {
- return change_stream_cursor_1.ChangeStreamCursor;
- } });
- var error_1 = require_error();
- Object.defineProperty(exports2, "MongoAPIError", { enumerable: true, get: function() {
- return error_1.MongoAPIError;
- } });
- Object.defineProperty(exports2, "MongoAWSError", { enumerable: true, get: function() {
- return error_1.MongoAWSError;
- } });
- Object.defineProperty(exports2, "MongoAzureError", { enumerable: true, get: function() {
- return error_1.MongoAzureError;
- } });
- Object.defineProperty(exports2, "MongoBatchReExecutionError", { enumerable: true, get: function() {
- return error_1.MongoBatchReExecutionError;
- } });
- Object.defineProperty(exports2, "MongoChangeStreamError", { enumerable: true, get: function() {
- return error_1.MongoChangeStreamError;
- } });
- Object.defineProperty(exports2, "MongoCompatibilityError", { enumerable: true, get: function() {
- return error_1.MongoCompatibilityError;
- } });
- Object.defineProperty(exports2, "MongoCursorExhaustedError", { enumerable: true, get: function() {
- return error_1.MongoCursorExhaustedError;
- } });
- Object.defineProperty(exports2, "MongoCursorInUseError", { enumerable: true, get: function() {
- return error_1.MongoCursorInUseError;
- } });
- Object.defineProperty(exports2, "MongoDecompressionError", { enumerable: true, get: function() {
- return error_1.MongoDecompressionError;
- } });
- Object.defineProperty(exports2, "MongoDriverError", { enumerable: true, get: function() {
- return error_1.MongoDriverError;
- } });
- Object.defineProperty(exports2, "MongoError", { enumerable: true, get: function() {
- return error_1.MongoError;
- } });
- Object.defineProperty(exports2, "MongoExpiredSessionError", { enumerable: true, get: function() {
- return error_1.MongoExpiredSessionError;
- } });
- Object.defineProperty(exports2, "MongoGridFSChunkError", { enumerable: true, get: function() {
- return error_1.MongoGridFSChunkError;
- } });
- Object.defineProperty(exports2, "MongoGridFSStreamError", { enumerable: true, get: function() {
- return error_1.MongoGridFSStreamError;
- } });
- Object.defineProperty(exports2, "MongoInvalidArgumentError", { enumerable: true, get: function() {
- return error_1.MongoInvalidArgumentError;
- } });
- Object.defineProperty(exports2, "MongoKerberosError", { enumerable: true, get: function() {
- return error_1.MongoKerberosError;
- } });
- Object.defineProperty(exports2, "MongoMissingCredentialsError", { enumerable: true, get: function() {
- return error_1.MongoMissingCredentialsError;
- } });
- Object.defineProperty(exports2, "MongoMissingDependencyError", { enumerable: true, get: function() {
- return error_1.MongoMissingDependencyError;
- } });
- Object.defineProperty(exports2, "MongoNetworkError", { enumerable: true, get: function() {
- return error_1.MongoNetworkError;
- } });
- Object.defineProperty(exports2, "MongoNetworkTimeoutError", { enumerable: true, get: function() {
- return error_1.MongoNetworkTimeoutError;
- } });
- Object.defineProperty(exports2, "MongoNotConnectedError", { enumerable: true, get: function() {
- return error_1.MongoNotConnectedError;
- } });
- Object.defineProperty(exports2, "MongoParseError", { enumerable: true, get: function() {
- return error_1.MongoParseError;
- } });
- Object.defineProperty(exports2, "MongoRuntimeError", { enumerable: true, get: function() {
- return error_1.MongoRuntimeError;
- } });
- Object.defineProperty(exports2, "MongoServerClosedError", { enumerable: true, get: function() {
- return error_1.MongoServerClosedError;
- } });
- Object.defineProperty(exports2, "MongoServerError", { enumerable: true, get: function() {
- return error_1.MongoServerError;
- } });
- Object.defineProperty(exports2, "MongoServerSelectionError", { enumerable: true, get: function() {
- return error_1.MongoServerSelectionError;
- } });
- Object.defineProperty(exports2, "MongoSystemError", { enumerable: true, get: function() {
- return error_1.MongoSystemError;
- } });
- Object.defineProperty(exports2, "MongoTailableCursorError", { enumerable: true, get: function() {
- return error_1.MongoTailableCursorError;
- } });
- Object.defineProperty(exports2, "MongoTopologyClosedError", { enumerable: true, get: function() {
- return error_1.MongoTopologyClosedError;
- } });
- Object.defineProperty(exports2, "MongoTransactionError", { enumerable: true, get: function() {
- return error_1.MongoTransactionError;
- } });
- Object.defineProperty(exports2, "MongoUnexpectedServerResponseError", { enumerable: true, get: function() {
- return error_1.MongoUnexpectedServerResponseError;
- } });
- Object.defineProperty(exports2, "MongoWriteConcernError", { enumerable: true, get: function() {
- return error_1.MongoWriteConcernError;
- } });
- var common_2 = require_common2();
- Object.defineProperty(exports2, "BatchType", { enumerable: true, get: function() {
- return common_2.BatchType;
- } });
- var gssapi_1 = require_gssapi();
- Object.defineProperty(exports2, "GSSAPICanonicalizationValue", { enumerable: true, get: function() {
- return gssapi_1.GSSAPICanonicalizationValue;
- } });
- var providers_1 = require_providers();
- Object.defineProperty(exports2, "AuthMechanism", { enumerable: true, get: function() {
- return providers_1.AuthMechanism;
- } });
- var compression_1 = require_compression();
- Object.defineProperty(exports2, "Compressor", { enumerable: true, get: function() {
- return compression_1.Compressor;
- } });
- var abstract_cursor_2 = require_abstract_cursor();
- Object.defineProperty(exports2, "CURSOR_FLAGS", { enumerable: true, get: function() {
- return abstract_cursor_2.CURSOR_FLAGS;
- } });
- var deps_1 = require_deps();
- Object.defineProperty(exports2, "AutoEncryptionLoggerLevel", { enumerable: true, get: function() {
- return deps_1.AutoEncryptionLoggerLevel;
- } });
- var error_2 = require_error();
- Object.defineProperty(exports2, "MongoErrorLabel", { enumerable: true, get: function() {
- return error_2.MongoErrorLabel;
- } });
- var explain_1 = require_explain();
- Object.defineProperty(exports2, "ExplainVerbosity", { enumerable: true, get: function() {
- return explain_1.ExplainVerbosity;
- } });
- var mongo_client_2 = require_mongo_client();
- Object.defineProperty(exports2, "ServerApiVersion", { enumerable: true, get: function() {
- return mongo_client_2.ServerApiVersion;
- } });
- var find_and_modify_1 = require_find_and_modify();
- Object.defineProperty(exports2, "ReturnDocument", { enumerable: true, get: function() {
- return find_and_modify_1.ReturnDocument;
- } });
- var set_profiling_level_1 = require_set_profiling_level();
- Object.defineProperty(exports2, "ProfilingLevel", { enumerable: true, get: function() {
- return set_profiling_level_1.ProfilingLevel;
- } });
- var read_concern_1 = require_read_concern();
- Object.defineProperty(exports2, "ReadConcernLevel", { enumerable: true, get: function() {
- return read_concern_1.ReadConcernLevel;
- } });
- var read_preference_1 = require_read_preference();
- Object.defineProperty(exports2, "ReadPreferenceMode", { enumerable: true, get: function() {
- return read_preference_1.ReadPreferenceMode;
- } });
- var common_3 = require_common();
- Object.defineProperty(exports2, "ServerType", { enumerable: true, get: function() {
- return common_3.ServerType;
- } });
- Object.defineProperty(exports2, "TopologyType", { enumerable: true, get: function() {
- return common_3.TopologyType;
- } });
- var read_concern_2 = require_read_concern();
- Object.defineProperty(exports2, "ReadConcern", { enumerable: true, get: function() {
- return read_concern_2.ReadConcern;
- } });
- var read_preference_2 = require_read_preference();
- Object.defineProperty(exports2, "ReadPreference", { enumerable: true, get: function() {
- return read_preference_2.ReadPreference;
- } });
- var write_concern_1 = require_write_concern();
- Object.defineProperty(exports2, "WriteConcern", { enumerable: true, get: function() {
- return write_concern_1.WriteConcern;
- } });
- var command_monitoring_events_1 = require_command_monitoring_events();
- Object.defineProperty(exports2, "CommandFailedEvent", { enumerable: true, get: function() {
- return command_monitoring_events_1.CommandFailedEvent;
- } });
- Object.defineProperty(exports2, "CommandStartedEvent", { enumerable: true, get: function() {
- return command_monitoring_events_1.CommandStartedEvent;
- } });
- Object.defineProperty(exports2, "CommandSucceededEvent", { enumerable: true, get: function() {
- return command_monitoring_events_1.CommandSucceededEvent;
- } });
- var connection_pool_events_1 = require_connection_pool_events();
- Object.defineProperty(exports2, "ConnectionCheckedInEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionCheckedInEvent;
- } });
- Object.defineProperty(exports2, "ConnectionCheckedOutEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionCheckedOutEvent;
- } });
- Object.defineProperty(exports2, "ConnectionCheckOutFailedEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionCheckOutFailedEvent;
- } });
- Object.defineProperty(exports2, "ConnectionCheckOutStartedEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionCheckOutStartedEvent;
- } });
- Object.defineProperty(exports2, "ConnectionClosedEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionClosedEvent;
- } });
- Object.defineProperty(exports2, "ConnectionCreatedEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionCreatedEvent;
- } });
- Object.defineProperty(exports2, "ConnectionPoolClearedEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionPoolClearedEvent;
- } });
- Object.defineProperty(exports2, "ConnectionPoolClosedEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionPoolClosedEvent;
- } });
- Object.defineProperty(exports2, "ConnectionPoolCreatedEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionPoolCreatedEvent;
- } });
- Object.defineProperty(exports2, "ConnectionPoolMonitoringEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionPoolMonitoringEvent;
- } });
- Object.defineProperty(exports2, "ConnectionPoolReadyEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionPoolReadyEvent;
- } });
- Object.defineProperty(exports2, "ConnectionReadyEvent", { enumerable: true, get: function() {
- return connection_pool_events_1.ConnectionReadyEvent;
- } });
- var events_1 = require_events();
- Object.defineProperty(exports2, "ServerClosedEvent", { enumerable: true, get: function() {
- return events_1.ServerClosedEvent;
- } });
- Object.defineProperty(exports2, "ServerDescriptionChangedEvent", { enumerable: true, get: function() {
- return events_1.ServerDescriptionChangedEvent;
- } });
- Object.defineProperty(exports2, "ServerHeartbeatFailedEvent", { enumerable: true, get: function() {
- return events_1.ServerHeartbeatFailedEvent;
- } });
- Object.defineProperty(exports2, "ServerHeartbeatStartedEvent", { enumerable: true, get: function() {
- return events_1.ServerHeartbeatStartedEvent;
- } });
- Object.defineProperty(exports2, "ServerHeartbeatSucceededEvent", { enumerable: true, get: function() {
- return events_1.ServerHeartbeatSucceededEvent;
- } });
- Object.defineProperty(exports2, "ServerOpeningEvent", { enumerable: true, get: function() {
- return events_1.ServerOpeningEvent;
- } });
- Object.defineProperty(exports2, "TopologyClosedEvent", { enumerable: true, get: function() {
- return events_1.TopologyClosedEvent;
- } });
- Object.defineProperty(exports2, "TopologyDescriptionChangedEvent", { enumerable: true, get: function() {
- return events_1.TopologyDescriptionChangedEvent;
- } });
- Object.defineProperty(exports2, "TopologyOpeningEvent", { enumerable: true, get: function() {
- return events_1.TopologyOpeningEvent;
- } });
- var srv_polling_1 = require_srv_polling();
- Object.defineProperty(exports2, "SrvPollingEvent", { enumerable: true, get: function() {
- return srv_polling_1.SrvPollingEvent;
- } });
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/utils/is-class.js
- function isClass(value) {
- if (!value) return false;
- return typeof value === "function" && /^class\s/.test(Function.prototype.toString.call(value));
- }
- var init_is_class = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/utils/is-class.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/utils/index.js
- var init_utils = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/utils/index.js"() {
- init_is_class();
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/value-to-string.js
- function valueToString(input) {
- if (input == null) return String(input);
- if (typeof input === "string") return `"${input}"`;
- if (typeof input === "number" || typeof input === "boolean")
- return String(input);
- if (isClass(input)) return input.name ? input.name : "Class";
- if (input.constructor && input.constructor.name)
- return input.constructor.name;
- if (typeof input === "object" && input.constructor == null) return "Object";
- return String(input);
- }
- var init_value_to_string = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/value-to-string.js"() {
- init_utils();
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/array-to-list.js
- function arrayToList(input) {
- if (Array.isArray(input) && input.length)
- return input.map(valueToString).join(SEPARATOR);
- return valueToString(input);
- }
- var SEPARATOR;
- var init_array_to_list = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/array-to-list.js"() {
- init_value_to_string();
- SEPARATOR = ", ";
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/format.js
- function format(pattern) {
- if (pattern instanceof Date) {
- pattern = pattern.toISOString();
- } else if (typeof pattern !== "string") {
- pattern = String(pattern);
- }
- const re = /(%?)(%([sdjvl]))/g;
- const args = Array.prototype.slice.call(arguments, 1);
- if (args.length) {
- pattern = pattern.replace(re, function(match, escaped, ptn, flag) {
- let arg = args.shift();
- switch (flag) {
- // eslint-disable-next-line no-fallthrough
- case "s":
- arg = String(arg);
- break;
- case "d":
- arg = Number(arg);
- break;
- case "j":
- arg = JSON.stringify(arg);
- break;
- case "v":
- arg = valueToString(arg);
- break;
- case "l":
- arg = arrayToList(arg);
- break;
- }
- if (!escaped) return arg;
- args.unshift(arg);
- return match;
- });
- }
- if (args.length) pattern += " " + args.join(" ");
- pattern = pattern.replace(/%{2,2}/g, "%");
- return "" + pattern;
- }
- var init_format = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/format.js"() {
- init_array_to_list();
- init_value_to_string();
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/errorf.js
- var Errorf;
- var init_errorf = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/errorf.js"() {
- init_format();
- Errorf = class extends Error {
- /**
- * Constructor.
- *
- * @param {string|undefined} pattern
- * @param {any} args
- */
- constructor(pattern = void 0, ...args) {
- const message = pattern != null ? format(pattern, ...args) : void 0;
- super(message);
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/index.js
- var init_src = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-format/src/index.js"() {
- init_format();
- init_errorf();
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-service/src/errors/invalid-argument-error.js
- var InvalidArgumentError;
- var init_invalid_argument_error = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-service/src/errors/invalid-argument-error.js"() {
- init_src();
- InvalidArgumentError = class extends Errorf {
- };
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-service/src/errors/index.js
- var init_errors = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-service/src/errors/index.js"() {
- init_invalid_argument_error();
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-service/src/service-container.js
- var ServiceContainer;
- var init_service_container = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-service/src/service-container.js"() {
- init_service();
- init_errors();
- ServiceContainer = class _ServiceContainer {
- /**
- * Services map.
- *
- * @type {Map<any, any>}
- * @private
- */
- _services = /* @__PURE__ */ new Map();
- /**
- * Parent container.
- *
- * @type {ServiceContainer}
- * @private
- */
- _parent;
- /**
- * Constructor.
- *
- * @param {ServiceContainer|undefined} parent
- */
- constructor(parent = void 0) {
- if (parent != null) {
- if (!(parent instanceof _ServiceContainer))
- throw new InvalidArgumentError(
- 'The provided parameter "parent" of ServicesContainer.constructor must be an instance ServiceContainer, but %v given.',
- parent
- );
- this._parent = parent;
- }
- }
- /**
- * Получить существующий или новый экземпляр.
- *
- * @param {*} ctor
- * @param {*} args
- * @return {*}
- */
- get(ctor, ...args) {
- if (!ctor || typeof ctor !== "function")
- throw new InvalidArgumentError(
- "The first argument of ServicesContainer.get must be a class constructor, but %v given.",
- ctor
- );
- if (!this._services.has(ctor) && this._parent && this._parent.has(ctor)) {
- return this._parent.get(ctor);
- }
- let service = this._services.get(ctor);
- if (!service || args.length) {
- service = "prototype" in ctor && ctor.prototype instanceof Service ? new ctor(this, ...args) : new ctor(...args);
- this._services.set(ctor, service);
- } else if (typeof service === "function") {
- service = service();
- this._services.set(ctor, service);
- }
- return service;
- }
- /**
- * Проверка существования конструктора в контейнере.
- *
- * @param {*} ctor
- * @return {boolean}
- */
- has(ctor) {
- if (this._services.has(ctor)) return true;
- if (this._parent) return this._parent.has(ctor);
- return false;
- }
- /**
- * Добавить конструктор в контейнер.
- *
- * @param {*} ctor
- * @param {*} args
- * @return {this}
- */
- add(ctor, ...args) {
- if (!ctor || typeof ctor !== "function")
- throw new InvalidArgumentError(
- "The first argument of ServicesContainer.add must be a class constructor, but %v given.",
- ctor
- );
- const factory = () => ctor.prototype instanceof Service ? new ctor(this, ...args) : new ctor(...args);
- this._services.set(ctor, factory);
- return this;
- }
- /**
- * Добавить конструктор и создать экземпляр.
- *
- * @param {*} ctor
- * @param {*} args
- * @return {this}
- */
- use(ctor, ...args) {
- if (!ctor || typeof ctor !== "function")
- throw new InvalidArgumentError(
- "The first argument of ServicesContainer.use must be a class constructor, but %v given.",
- ctor
- );
- const service = ctor.prototype instanceof Service ? new ctor(this, ...args) : new ctor(...args);
- this._services.set(ctor, service);
- return this;
- }
- /**
- * Добавить конструктор и связанный экземпляр.
- *
- * @param {*} ctor
- * @param {*} service
- * @return {this}
- */
- set(ctor, service) {
- if (!ctor || typeof ctor !== "function")
- throw new InvalidArgumentError(
- "The first argument of ServicesContainer.set must be a class constructor, but %v given.",
- ctor
- );
- if (!service || typeof service !== "object" || Array.isArray(service))
- throw new InvalidArgumentError(
- "The second argument of ServicesContainer.set must be an Object, but %v given.",
- service
- );
- this._services.set(ctor, service);
- return this;
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-service/src/service.js
- var Service;
- var init_service = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-service/src/service.js"() {
- init_service_container();
- Service = class {
- /**
- * Container.
- *
- * @type {ServiceContainer}
- */
- container;
- /**
- * Constructor.
- *
- * @param {ServiceContainer|undefined} container
- */
- constructor(container = void 0) {
- this.container = container instanceof ServiceContainer ? container : new ServiceContainer();
- }
- /**
- * Получить существующий или новый экземпляр.
- *
- * @param {*} ctor
- * @param {*} args
- * @return {*}
- */
- getService(ctor, ...args) {
- return this.container.get(ctor, ...args);
- }
- /**
- * Проверка существования конструктора в контейнере.
- *
- * @param {*} ctor
- * @return {boolean}
- */
- hasService(ctor) {
- return this.container.has(ctor);
- }
- /**
- * Добавить конструктор в контейнер.
- *
- * @param {*} ctor
- * @param {*} args
- * @return {this}
- */
- addService(ctor, ...args) {
- this.container.add(ctor, ...args);
- return this;
- }
- /**
- * Добавить конструктор и создать экземпляр.
- *
- * @param {*} ctor
- * @param {*} args
- * @return {this}
- */
- useService(ctor, ...args) {
- this.container.use(ctor, ...args);
- return this;
- }
- /**
- * Добавить конструктор и связанный экземпляр.
- *
- * @param {*} ctor
- * @param {*} service
- * @return {this}
- */
- setService(ctor, service) {
- this.container.set(ctor, service);
- return this;
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-service/src/index.js
- var init_src2 = __esm({
- "node_modules/@e22m4u/js-repository/node_modules/@e22m4u/js-service/src/index.js"() {
- init_service();
- init_service_container();
- }
- });
- // node_modules/@e22m4u/js-repository/src/errors/not-implemented-error.js
- var NotImplementedError;
- var init_not_implemented_error = __esm({
- "node_modules/@e22m4u/js-repository/src/errors/not-implemented-error.js"() {
- init_src();
- NotImplementedError = class extends Errorf {
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/errors/invalid-argument-error.js
- var InvalidArgumentError2;
- var init_invalid_argument_error2 = __esm({
- "node_modules/@e22m4u/js-repository/src/errors/invalid-argument-error.js"() {
- init_src();
- InvalidArgumentError2 = class extends Errorf {
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/errors/invalid-operator-value-error.js
- var InvalidOperatorValueError;
- var init_invalid_operator_value_error = __esm({
- "node_modules/@e22m4u/js-repository/src/errors/invalid-operator-value-error.js"() {
- init_src();
- InvalidOperatorValueError = class extends Error {
- /**
- * Constructor.
- *
- * @param {string} operator
- * @param {string} expected
- * @param {*} value
- */
- constructor(operator, expected, value) {
- super(
- format(
- "Condition of {%s: ...} should have %s, but %v given.",
- operator,
- expected,
- value
- )
- );
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/errors/index.js
- var init_errors2 = __esm({
- "node_modules/@e22m4u/js-repository/src/errors/index.js"() {
- init_not_implemented_error();
- init_invalid_argument_error2();
- init_invalid_operator_value_error();
- }
- });
- // node_modules/@e22m4u/js-repository/src/filter/slice-clause-tool.js
- var SliceClauseTool;
- var init_slice_clause_tool = __esm({
- "node_modules/@e22m4u/js-repository/src/filter/slice-clause-tool.js"() {
- init_src2();
- init_errors2();
- SliceClauseTool = class extends Service {
- /**
- * Slice.
- *
- * @param {object[]} entities
- * @param {number|undefined} skip
- * @param {number|undefined} limit
- * @returns {object[]}
- */
- slice(entities, skip = void 0, limit = void 0) {
- if (!Array.isArray(entities))
- throw new InvalidArgumentError2(
- "The first argument of SliceClauseTool.slice should be an Array, but %v given.",
- entities
- );
- if (skip != null && typeof skip !== "number")
- throw new InvalidArgumentError2(
- 'The provided option "skip" should be a Number, but %v given.',
- skip
- );
- if (limit != null && typeof limit !== "number")
- throw new InvalidArgumentError2(
- 'The provided option "limit" should be a Number, but %v given.',
- limit
- );
- skip = skip || 0;
- limit = limit || entities.length;
- return entities.slice(skip, skip + limit);
- }
- /**
- * Validate skip clause.
- *
- * @param {number|undefined} skip
- */
- static validateSkipClause(skip) {
- if (skip == null) return;
- if (typeof skip !== "number")
- throw new InvalidArgumentError2(
- 'The provided option "skip" should be a Number, but %v given.',
- skip
- );
- }
- /**
- * Validate limit clause.
- *
- * @param {number|undefined} limit
- */
- static validateLimitClause(limit) {
- if (limit == null) return;
- if (typeof limit !== "number")
- throw new InvalidArgumentError2(
- 'The provided option "limit" should be a Number, but %v given.',
- limit
- );
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/is-ctor.js
- var init_is_ctor = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/is-ctor.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/is-promise.js
- function isPromise(value) {
- if (!value) return false;
- if (typeof value !== "object") return false;
- return typeof value.then === "function";
- }
- var init_is_promise = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/is-promise.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/capitalize.js
- function capitalize(string) {
- if (!string || typeof string !== "string") return string;
- return string.charAt(0).toUpperCase() + string.slice(1);
- }
- var init_capitalize = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/capitalize.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/clone-deep.js
- function cloneDeep(value) {
- if (!value) return value;
- const types = [Number, String, Boolean];
- let result;
- types.forEach((type) => {
- if (value instanceof type) result = type(value);
- });
- if (result === void 0) {
- if (Array.isArray(value)) {
- result = [];
- value.forEach((child, index) => {
- result[index] = cloneDeep(child);
- });
- } else if (typeof value === "object") {
- if ("nodeType" in value && value.nodeType && "cloneNode" in value && typeof value.cloneNode === "function") {
- result = value.cloneNode(true);
- } else if (!("prototype" in value) || !value.prototype) {
- if (value instanceof Date) {
- result = new Date(value);
- } else if (value.constructor && value.constructor.name === "Object") {
- result = {};
- for (const key in value) {
- result[key] = cloneDeep(value[key]);
- }
- } else {
- result = value;
- }
- } else {
- result = value;
- }
- } else {
- result = value;
- }
- }
- return result;
- }
- var init_clone_deep = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/clone-deep.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/singularize.js
- function singularize(noun) {
- if (!noun || typeof noun !== "string") return noun;
- const endings = {
- ves: "fe",
- ies: "y",
- i: "us",
- zes: "ze",
- ses: "s",
- es: "e",
- s: ""
- };
- return noun.replace(
- new RegExp(`(${Object.keys(endings).join("|")})$`),
- (r) => endings[r]
- );
- }
- var init_singularize = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/singularize.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/is-deep-equal.js
- function isDeepEqual(firstValue, secondValue) {
- const cached = /* @__PURE__ */ new WeakMap();
- const compare = (a, b) => {
- if (a === null || b === null) return a === b;
- if (typeof a !== "object" || typeof b !== "object") return a === b;
- const dataTypeA = Array.isArray(a) ? "array" : "object";
- const dataTypeB = Array.isArray(b) ? "array" : "object";
- if (dataTypeA !== dataTypeB) return false;
- const keysA = Object.keys(a);
- const keysB = Object.keys(b);
- if (keysA.length !== keysB.length) return false;
- const symbolsA = Object.getOwnPropertySymbols(a);
- const symbolsB = Object.getOwnPropertySymbols(b);
- if (symbolsA.length !== symbolsB.length) return false;
- let setForA = cached.get(a);
- if (setForA == null) {
- setForA = /* @__PURE__ */ new Set();
- cached.set(a, setForA);
- } else if (setForA.has(b)) {
- return true;
- }
- setForA.add(b);
- let setForB = cached.get(b);
- if (setForB == null) {
- setForB = /* @__PURE__ */ new Set();
- cached.set(b, setForB);
- } else if (setForB.has(a)) {
- return true;
- }
- setForB.add(a);
- const propertyNamesA = [...keysA, ...symbolsA];
- for (const propertyNameA of propertyNamesA) {
- if (!b.hasOwnProperty(propertyNameA)) return false;
- const propertyValueA = a[propertyNameA];
- const propertyValueB = b[propertyNameA];
- if (!compare(propertyValueA, propertyValueB)) return false;
- }
- return true;
- };
- return compare(firstValue, secondValue);
- }
- var init_is_deep_equal = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/is-deep-equal.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/get-ctor-name.js
- function getCtorName(value) {
- if (value === null) return "Null";
- if (value === void 0) return "Undefined";
- return value.constructor && value.constructor.name || void 0;
- }
- var init_get_ctor_name = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/get-ctor-name.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/is-pure-object.js
- function isPureObject(value) {
- return Boolean(
- typeof value === "object" && value && !Array.isArray(value) && (!value.constructor || value.constructor && value.constructor.name === "Object")
- );
- }
- var init_is_pure_object = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/is-pure-object.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/string-to-regexp.js
- function stringToRegexp(pattern, flags = void 0) {
- if (pattern instanceof RegExp) {
- return new RegExp(pattern, flags);
- }
- let regex = "";
- for (let i = 0, n = pattern.length; i < n; i++) {
- const char = pattern.charAt(i);
- if (char === "%") {
- regex += ".*";
- } else {
- regex += char;
- }
- }
- return new RegExp(regex, flags);
- }
- var init_string_to_regexp = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/string-to-regexp.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/get-value-by-path.js
- function getValueByPath(obj, path, orElse = void 0) {
- if (!obj || typeof obj !== "object") return orElse;
- if (!path || typeof path !== "string") return orElse;
- const keys = path.split(".");
- let value = obj;
- for (const key of keys) {
- if (typeof value === "object" && value !== null && key in value) {
- value = value[key];
- } else {
- value = orElse;
- break;
- }
- }
- return value;
- }
- var init_get_value_by_path = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/get-value-by-path.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/transform-promise.js
- function transformPromise(valueOrPromise, transformer) {
- return isPromise(valueOrPromise) ? valueOrPromise.then(transformer) : transformer(valueOrPromise);
- }
- var init_transform_promise = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/transform-promise.js"() {
- init_is_promise();
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/select-object-keys.js
- function selectObjectKeys(obj, keys) {
- if (!obj || typeof obj !== "object" || Array.isArray(obj))
- throw new InvalidArgumentError2(
- "The first argument of selectObjectKeys should be an Object, but %v given.",
- obj
- );
- if (!Array.isArray(keys))
- throw new InvalidArgumentError2(
- "The second argument of selectObjectKeys should be an Array of String, but %v given.",
- keys
- );
- keys.forEach((key) => {
- if (typeof key !== "string")
- throw new InvalidArgumentError2(
- "The second argument of selectObjectKeys should be an Array of String, but %v given.",
- key
- );
- });
- const result = {};
- const allKeys = Object.keys(obj);
- allKeys.forEach((key) => {
- if (keys.includes(key)) result[key] = obj[key];
- });
- return result;
- }
- var init_select_object_keys = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/select-object-keys.js"() {
- init_errors2();
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/exclude-object-keys.js
- function excludeObjectKeys(obj, keys) {
- if (typeof obj !== "object" || !obj || Array.isArray(obj))
- throw new InvalidArgumentError2(
- "Cannot exclude keys from a non-Object value, %v given.",
- obj
- );
- const result = { ...obj };
- keys = Array.isArray(keys) ? keys : [keys];
- keys.forEach((key) => delete result[key]);
- return result;
- }
- var init_exclude_object_keys = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/exclude-object-keys.js"() {
- init_errors2();
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/get-decorator-target-type.js
- var init_get_decorator_target_type = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/get-decorator-target-type.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/utils/index.js
- var init_utils2 = __esm({
- "node_modules/@e22m4u/js-repository/src/utils/index.js"() {
- init_is_ctor();
- init_is_promise();
- init_capitalize();
- init_clone_deep();
- init_singularize();
- init_is_deep_equal();
- init_get_ctor_name();
- init_is_pure_object();
- init_string_to_regexp();
- init_get_value_by_path();
- init_transform_promise();
- init_select_object_keys();
- init_exclude_object_keys();
- init_get_decorator_target_type();
- }
- });
- // node_modules/@e22m4u/js-repository/src/filter/order-clause-tool.js
- function compareFn(a, b) {
- let undefinedA, undefinedB;
- for (let i = 0, l = this.length; i < l; i++) {
- const aVal = getValueByPath(a, this[i].key);
- const bVal = getValueByPath(b, this[i].key);
- undefinedB = bVal === void 0 && aVal !== void 0;
- undefinedA = aVal === void 0 && bVal !== void 0;
- if (undefinedB || aVal > bVal) {
- return this[i].reverse;
- } else if (undefinedA || aVal < bVal) {
- return -1 * this[i].reverse;
- }
- }
- return 0;
- }
- var OrderClauseTool;
- var init_order_clause_tool = __esm({
- "node_modules/@e22m4u/js-repository/src/filter/order-clause-tool.js"() {
- init_src2();
- init_utils2();
- init_errors2();
- OrderClauseTool = class extends Service {
- /**
- * Sort.
- *
- * @param {object[]} entities
- * @param {string|string[]|undefined} clause
- */
- sort(entities, clause) {
- if (clause == null) return;
- if (Array.isArray(clause) === false) clause = [clause];
- if (!clause.length) return;
- const mapping = [];
- clause.forEach((key, index) => {
- if (!key || typeof key !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "order" should be a non-empty String or an Array of non-empty String, but %v given.',
- key
- );
- let reverse = 1;
- const matches = key.match(/\s+(A|DE)SC$/i);
- if (matches) {
- key = key.replace(/\s+(A|DE)SC/i, "");
- if (matches[1].toLowerCase() === "de") reverse = -1;
- }
- mapping[index] = { key, reverse };
- });
- entities.sort(compareFn.bind(mapping));
- }
- /**
- * Validate order clause.
- *
- * @param {string|string[]|undefined} clause
- */
- static validateOrderClause(clause) {
- if (clause == null) return;
- if (Array.isArray(clause) === false) clause = [clause];
- if (!clause.length) return;
- clause.forEach((field) => {
- if (!field || typeof field !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "order" should be a non-empty String or an Array of non-empty String, but %v given.',
- field
- );
- });
- }
- /**
- * Normalize order clause.
- *
- * @param {string|string[]|undefined} clause
- * @returns {string[]|undefined}
- */
- static normalizeOrderClause(clause) {
- if (clause == null) return;
- if (Array.isArray(clause) === false) clause = [clause];
- if (!clause.length) return;
- clause.forEach((field) => {
- if (!field || typeof field !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "order" should be a non-empty String or an Array of non-empty String, but %v given.',
- field
- );
- });
- return clause;
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/filter/operator-clause-tool.js
- var OperatorClauseTool;
- var init_operator_clause_tool = __esm({
- "node_modules/@e22m4u/js-repository/src/filter/operator-clause-tool.js"() {
- init_src2();
- init_utils2();
- init_errors2();
- init_errors2();
- OperatorClauseTool = class extends Service {
- /**
- * Compare.
- *
- * @param {*} val1 The 1st value
- * @param {*} val2 The 2nd value
- * @returns {number} 0: =, positive: >, negative <
- */
- compare(val1, val2) {
- if (val1 == null || val2 == null) {
- return val1 == val2 ? 0 : NaN;
- }
- if (typeof val1 === "number") {
- if (typeof val2 === "number" || typeof val2 === "string" || typeof val2 === "boolean") {
- if (val1 === val2) return 0;
- return val1 - Number(val2);
- }
- return NaN;
- }
- if (typeof val1 === "string") {
- const isDigits = /^\d+$/.test(val1);
- if (isDigits) return this.compare(Number(val1), val2);
- try {
- if (val1 > val2) return 1;
- if (val1 < val2) return -1;
- if (val1 == val2) return 0;
- } catch (e) {
- }
- return NaN;
- }
- if (typeof val1 === "boolean") {
- return Number(val1) - Number(val2);
- }
- return val1 === val2 ? 0 : NaN;
- }
- /**
- * Test all operators.
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testAll(clause, value) {
- if (!clause || typeof clause !== "object" || Array.isArray(clause))
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testAll should be an Object, but %v given.",
- clause
- );
- const eqNeqTest = this.testEqNeq(clause, value);
- if (eqNeqTest !== void 0) return eqNeqTest;
- const gtLtTest = this.testGtLt(clause, value);
- if (gtLtTest !== void 0) return gtLtTest;
- const incTest = this.testInq(clause, value);
- if (incTest !== void 0) return incTest;
- const ninTest = this.testNin(clause, value);
- if (ninTest !== void 0) return ninTest;
- const betweenTest = this.testBetween(clause, value);
- if (betweenTest !== void 0) return betweenTest;
- const existsTest = this.testExists(clause, value);
- if (existsTest !== void 0) return existsTest;
- const likeTest = this.testLike(clause, value);
- if (likeTest !== void 0) return likeTest;
- const nlikeTest = this.testNlike(clause, value);
- if (nlikeTest !== void 0) return nlikeTest;
- const ilikeTest = this.testIlike(clause, value);
- if (ilikeTest !== void 0) return ilikeTest;
- const nilikeTest = this.testNilike(clause, value);
- if (nilikeTest !== void 0) return nilikeTest;
- const regExpTest = this.testRegexp(clause, value);
- if (regExpTest !== void 0) return regExpTest;
- }
- /**
- * Test eq/neq operator.
- *
- * @example
- * ```ts
- * {
- * eq: 'foo',
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- * neq: 'foo',
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testEqNeq(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testEqNeq should be an Object, but %v given.",
- clause
- );
- if ("eq" in clause) return this.compare(clause.eq, value) === 0;
- if ("neq" in clause) return this.compare(clause.neq, value) !== 0;
- }
- /**
- * Test lt/gt/lte/gte operator.
- *
- * @example
- * ```ts
- * {
- * lt: 10,
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- * lte: 10,
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- * gt: 10,
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- * gte: 10,
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testGtLt(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testGtLt should be an Object, but %v given.",
- clause
- );
- if ("gt" in clause) return this.compare(value, clause.gt) > 0;
- if ("gte" in clause) return this.compare(value, clause.gte) >= 0;
- if ("lt" in clause) return this.compare(value, clause.lt) < 0;
- if ("lte" in clause) return this.compare(value, clause.lte) <= 0;
- }
- /**
- * Test inc operator.
- *
- * @example
- * ```ts
- * {
- * inc: ['foo', 'bar'],
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testInq(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testInq should be an Object, but %v given.",
- clause
- );
- if ("inq" in clause && clause.inq !== void 0) {
- if (!clause.inq || !Array.isArray(clause.inq)) {
- throw new InvalidOperatorValueError(
- "inq",
- "an Array of possible values",
- clause.inq
- );
- }
- for (let i = 0; i < clause.inq.length; i++) {
- if (clause.inq[i] == value) return true;
- }
- return false;
- }
- }
- /**
- * Test nin operator.
- *
- * @example
- * ```ts
- * {
- * nin: ['foo', 'bar'],
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testNin(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testNin should be an Object, but %v given.",
- clause
- );
- if ("nin" in clause && clause.nin !== void 0) {
- if (!clause.nin || !Array.isArray(clause.nin)) {
- throw new InvalidOperatorValueError(
- "nin",
- "an Array of possible values",
- clause.nin
- );
- }
- for (let i = 0; i < clause.nin.length; i++) {
- if (clause.nin[i] == value) return false;
- }
- return true;
- }
- }
- /**
- * Test between operator.
- *
- * @example
- * ```ts
- * {
- * between: [10, 20],
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testBetween(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testBetween should be an Object, but %v given.",
- clause
- );
- if ("between" in clause && clause.between !== void 0) {
- if (!Array.isArray(clause.between) || clause.between.length !== 2) {
- throw new InvalidOperatorValueError(
- "between",
- "an Array of 2 elements",
- clause.between
- );
- }
- return this.testGtLt({ gte: clause.between[0] }, value) && this.testGtLt({ lte: clause.between[1] }, value);
- }
- }
- /**
- * Test exists operator.
- *
- * @example
- * ```ts
- * {
- * exists: true,
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testExists(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testExists should be an Object, but %v given.",
- clause
- );
- if ("exists" in clause && clause.exists !== void 0) {
- if (typeof clause.exists !== "boolean") {
- throw new InvalidOperatorValueError(
- "exists",
- "a Boolean",
- clause.exists
- );
- }
- return clause.exists ? value !== void 0 : value === void 0;
- }
- }
- /**
- * Test like operator.
- *
- * @example
- * ```ts
- * {
- * like: 'foo',
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testLike(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testLike should be an Object, but %v given.",
- clause
- );
- if ("like" in clause && clause.like !== void 0) {
- if (typeof clause.like !== "string" && !(clause.like instanceof RegExp))
- throw new InvalidOperatorValueError("like", "a String", clause.like);
- return stringToRegexp(clause.like).test(value);
- }
- }
- /**
- * Test nlike operator.
- *
- * @example
- * ```ts
- * {
- * nlike: 'foo',
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testNlike(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testNlike should be an Object, but %v given.",
- clause
- );
- if ("nlike" in clause && clause.nlike !== void 0) {
- if (typeof clause.nlike !== "string" && !(clause.nlike instanceof RegExp)) {
- throw new InvalidOperatorValueError("nlike", "a String", clause.nlike);
- }
- return !stringToRegexp(clause.nlike).test(value);
- }
- }
- /**
- * Test ilike operator.
- *
- * @example
- * ```ts
- * {
- * ilike: 'foo',
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testIlike(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testIlike should be an Object, but %v given.",
- clause
- );
- if ("ilike" in clause && clause.ilike !== void 0) {
- if (typeof clause.ilike !== "string" && !(clause.ilike instanceof RegExp)) {
- throw new InvalidOperatorValueError("ilike", "a String", clause.ilike);
- }
- return stringToRegexp(clause.ilike, "i").test(value);
- }
- }
- /**
- * Test nilike operator.
- *
- * @example
- * ```ts
- * {
- * nilike: 'foo',
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testNilike(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testNilike should be an Object, but %v given.",
- clause
- );
- if ("nilike" in clause && clause.nilike !== void 0) {
- if (typeof clause.nilike !== "string" && !(clause.nilike instanceof RegExp)) {
- throw new InvalidOperatorValueError(
- "nilike",
- "a String",
- clause.nilike
- );
- }
- return !stringToRegexp(clause.nilike, "i").test(value);
- }
- }
- /**
- * Test regexp.
- *
- * @example
- * ```ts
- * {
- * regexp: 'foo.*',
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- * regexp: 'foo.*',
- * flags: 'i',
- * }
- * ```
- *
- * @param {object} clause
- * @param {*} value
- * @returns {boolean|undefined}
- */
- testRegexp(clause, value) {
- if (!clause || typeof clause !== "object")
- throw new InvalidArgumentError2(
- "The first argument of OperatorUtils.testRegexp should be an Object, but %v given.",
- clause
- );
- if ("regexp" in clause && clause.regexp !== void 0) {
- if (typeof clause.regexp !== "string" && !(clause.regexp instanceof RegExp)) {
- throw new InvalidOperatorValueError(
- "regexp",
- "a String",
- clause.regexp
- );
- }
- const flags = clause.flags || void 0;
- if (flags && typeof flags !== "string")
- throw new InvalidArgumentError2(
- "RegExp flags should be a String, but %v given.",
- clause.flags
- );
- if (!value || typeof value !== "string") return false;
- const regExp = stringToRegexp(clause.regexp, flags);
- return !!value.match(regExp);
- }
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/filter/where-clause-tool.js
- var WhereClauseTool;
- var init_where_clause_tool = __esm({
- "node_modules/@e22m4u/js-repository/src/filter/where-clause-tool.js"() {
- init_src2();
- init_utils2();
- init_errors2();
- init_operator_clause_tool();
- WhereClauseTool = class extends Service {
- /**
- * Filter by where clause.
- *
- * @example
- * ```
- * const entities = [
- * {foo: 1, bar: 'a'},
- * {foo: 2, bar: 'b'},
- * {foo: 3, bar: 'b'},
- * {foo: 4, bar: 'b'},
- * ];
- *
- * const result = filterByWhereClause(entities, {
- * foo: {gt: 2},
- * bar: 'b',
- * });
- *
- * console.log(result);
- * // [
- * // {foo: 3, bar: 'b'},
- * // {foo: 4, bar: 'b'},
- * // ];
- *
- * ```
- *
- * @param {object[]} entities
- * @param {WhereClause|undefined} where
- * @returns {object[]}
- */
- filter(entities, where = void 0) {
- if (!Array.isArray(entities))
- throw new InvalidArgumentError2(
- "The first argument of WhereClauseTool.filter should be an Array of Object, but %v given.",
- entities
- );
- if (where == null) return entities;
- return entities.filter(this._createFilter(where));
- }
- /**
- * Create where filter.
- *
- * @param {WhereClause} whereClause
- * @returns {Function}
- */
- _createFilter(whereClause) {
- if (typeof whereClause !== "object" || Array.isArray(whereClause))
- throw new InvalidArgumentError2(
- 'The provided option "where" should be an Object, but %v given.',
- whereClause
- );
- const keys = Object.keys(whereClause);
- return (data) => {
- if (typeof data !== "object")
- throw new InvalidArgumentError2(
- "The first argument of WhereClauseTool.filter should be an Array of Object, but %v given.",
- data
- );
- return keys.every((key) => {
- if (key === "and" && key in whereClause) {
- const andClause = whereClause[key];
- if (Array.isArray(andClause))
- return andClause.every((clause) => this._createFilter(clause)(data));
- } else if (key === "or" && key in whereClause) {
- const orClause = whereClause[key];
- if (Array.isArray(orClause))
- return orClause.some((clause) => this._createFilter(clause)(data));
- }
- const value = getValueByPath(data, key);
- const matcher = whereClause[key];
- if (Array.isArray(value)) {
- if (typeof matcher === "object" && matcher !== null && "neq" in matcher && matcher.neq !== void 0) {
- if (value.length === 0) return true;
- return value.every((el, index) => {
- const where = {};
- where[index] = matcher;
- return this._createFilter(where)({ ...value });
- });
- }
- return value.some((el, index) => {
- const where = {};
- where[index] = matcher;
- return this._createFilter(where)({ ...value });
- });
- }
- if (this._test(matcher, value)) return true;
- });
- };
- }
- /**
- * Value testing.
- *
- * @param {*} example
- * @param {*} value
- * @returns {boolean}
- */
- _test(example, value) {
- if (example === null) {
- return value === null;
- }
- if (example === void 0) {
- return value === void 0;
- }
- if (example instanceof RegExp) {
- if (typeof value === "string") return !!value.match(example);
- return false;
- }
- if (typeof example === "object") {
- const operatorsTest = this.getService(OperatorClauseTool).testAll(
- example,
- value
- );
- if (operatorsTest !== void 0) return operatorsTest;
- }
- return example == value;
- }
- /**
- * Validate where clause.
- *
- * @param {WhereClause|undefined} clause
- */
- static validateWhereClause(clause) {
- if (clause == null || typeof clause === "function") return;
- if (typeof clause !== "object" || Array.isArray(clause))
- throw new InvalidArgumentError2(
- 'The provided option "where" should be an Object, but %v given.',
- clause
- );
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/relations/relation-type.js
- var RelationType;
- var init_relation_type = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/relations/relation-type.js"() {
- RelationType = {
- BELONGS_TO: "belongsTo",
- HAS_ONE: "hasOne",
- HAS_MANY: "hasMany",
- REFERENCES_MANY: "referencesMany"
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/relations/relation-definition.js
- var init_relation_definition = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/relations/relation-definition.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/relations/relations-definition-validator.js
- var RelationsDefinitionValidator;
- var init_relations_definition_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/relations/relations-definition-validator.js"() {
- init_src2();
- init_relation_type();
- init_relation_type();
- init_errors2();
- RelationsDefinitionValidator = class extends Service {
- /**
- * Validate.
- *
- * @param {string} modelName
- * @param {object} relDefs
- */
- validate(modelName, relDefs) {
- if (!modelName || typeof modelName !== "string")
- throw new InvalidArgumentError2(
- "The first argument of RelationsDefinitionValidator.validate should be a non-empty String, but %v given.",
- modelName
- );
- if (!relDefs || typeof relDefs !== "object" || Array.isArray(relDefs))
- throw new InvalidArgumentError2(
- 'The provided option "relations" of the model %v should be an Object, but %v given.',
- modelName,
- relDefs
- );
- const relNames = Object.keys(relDefs);
- relNames.forEach((relName) => {
- const relDef = relDefs[relName];
- this._validateRelation(modelName, relName, relDef);
- });
- }
- /**
- * Validate relation.
- *
- * @param {string} modelName
- * @param {string} relName
- * @param {object} relDef
- */
- _validateRelation(modelName, relName, relDef) {
- if (!modelName || typeof modelName !== "string")
- throw new InvalidArgumentError2(
- "The first argument of RelationsDefinitionValidator._validateRelation should be a non-empty String, but %v given.",
- modelName
- );
- if (!relName || typeof relName !== "string")
- throw new InvalidArgumentError2(
- "The relation name of the model %v should be a non-empty String, but %v given.",
- modelName,
- relName
- );
- if (!relDef || typeof relDef !== "object" || Array.isArray(relDef))
- throw new InvalidArgumentError2(
- "The relation %v of the model %v should be an Object, but %v given.",
- relName,
- modelName,
- relDef
- );
- if (!relDef.type || !Object.values(RelationType).includes(relDef.type))
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v requires the option "type" to have one of relation types: %l, but %v given.',
- relName,
- modelName,
- Object.values(RelationType),
- relDef.type
- );
- this._validateBelongsTo(modelName, relName, relDef);
- this._validateHasOne(modelName, relName, relDef);
- this._validateHasMany(modelName, relName, relDef);
- this._validateReferencesMany(modelName, relName, relDef);
- }
- /**
- * Validate "belongsTo".
- *
- * @example The regular "belongsTo" relation.
- * ```
- * {
- * type: RelationType.BELONGS_TO,
- * model: 'model',
- * foreignKey: 'modelId', // optional
- * }
- * ```
- *
- * @example The polymorphic "belongsTo" relation.
- * ```
- * {
- * type: RelationType.BELONGS_TO,
- * polymorphic: true,
- * foreignKey: 'referenceId', // optional
- * discriminator: 'referenceType', // optional
- * }
- * ```
- *
- * @param {string} modelName
- * @param {string} relName
- * @param {object} relDef
- * @private
- */
- _validateBelongsTo(modelName, relName, relDef) {
- if (relDef.type !== RelationType.BELONGS_TO) return;
- if (relDef.polymorphic) {
- if (typeof relDef.polymorphic !== "boolean")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "belongsTo", so it expects the option "polymorphic" to be a Boolean, but %v given.',
- relName,
- modelName,
- relDef.polymorphic
- );
- if (relDef.foreignKey && typeof relDef.foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v is a polymorphic "belongsTo" relation, so it expects the provided option "foreignKey" to be a String, but %v given.',
- relName,
- modelName,
- relDef.foreignKey
- );
- if (relDef.discriminator && typeof relDef.discriminator !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v is a polymorphic "belongsTo" relation, so it expects the provided option "discriminator" to be a String, but %v given.',
- relName,
- modelName,
- relDef.discriminator
- );
- } else {
- if (!relDef.model || typeof relDef.model !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "belongsTo", so it requires the option "model" to be a non-empty String, but %v given.',
- relName,
- modelName,
- relDef.model
- );
- if (relDef.foreignKey && typeof relDef.foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "belongsTo", so it expects the provided option "foreignKey" to be a String, but %v given.',
- relName,
- modelName,
- relDef.foreignKey
- );
- if (relDef.discriminator)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v is a non-polymorphic "belongsTo" relation, so it should not have the option "discriminator" to be provided.',
- relName,
- modelName
- );
- }
- }
- /**
- * Validate "hasOne".
- *
- * @example The regular "hasOne" relation.
- * ```
- * {
- * type: RelationType.HAS_ONE,
- * model: 'model',
- * foreignKey: 'modelId',
- * }
- * ```
- *
- * @example The polymorphic "hasOne" relation with a target relation name.
- * ```
- * {
- * type: RelationType.HAS_ONE,
- * model: 'model',
- * polymorphic: 'reference',
- * }
- * ```
- *
- * @example The polymorphic "hasOne" relation with target relation keys.
- * ```
- * {
- * type: RelationType.HAS_ONE,
- * model: 'model',
- * polymorphic: true,
- * foreignKey: 'referenceId',
- * discriminator: 'referenceType',
- * }
- * ```
- *
- * @param {string} modelName
- * @param {string} relName
- * @param {object} relDef
- * @private
- */
- _validateHasOne(modelName, relName, relDef) {
- if (relDef.type !== RelationType.HAS_ONE) return;
- if (!relDef.model || typeof relDef.model !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "hasOne", so it requires the option "model" to be a non-empty String, but %v given.',
- relName,
- modelName,
- relDef.model
- );
- if (relDef.polymorphic) {
- if (typeof relDef.polymorphic === "string") {
- if (relDef.foreignKey)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "foreignKey" to be provided.',
- relName,
- modelName
- );
- if (relDef.discriminator)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "discriminator" to be provided.',
- relName,
- modelName
- );
- } else if (typeof relDef.polymorphic === "boolean") {
- if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "foreignKey" to be a non-empty String, but %v given.',
- relName,
- modelName,
- relDef.foreignKey
- );
- if (!relDef.discriminator || typeof relDef.discriminator !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "discriminator" to be a non-empty String, but %v given.',
- relName,
- modelName,
- relDef.discriminator
- );
- } else {
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "hasOne", so it expects the provided option "polymorphic" to be a String or a Boolean, but %v given.',
- relName,
- modelName,
- relDef.polymorphic
- );
- }
- } else {
- if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "hasOne", so it requires the option "foreignKey" to be a non-empty String, but %v given.',
- relName,
- modelName,
- relDef.foreignKey
- );
- if (relDef.discriminator)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v is a non-polymorphic "hasOne" relation, so it should not have the option "discriminator" to be provided.',
- relName,
- modelName
- );
- }
- }
- /**
- * Validate "hasMany".
- *
- * @example The regular "hasMany" relation.
- * ```
- * {
- * type: RelationType.HAS_MANY,
- * model: 'model',
- * foreignKey: 'modelId',
- * }
- * ```
- *
- * @example The polymorphic "hasMany" relation with a target relation name.
- * ```
- * {
- * type: RelationType.HAS_MANY,
- * model: 'model',
- * polymorphic: 'reference',
- * }
- * ```
- *
- * @example The polymorphic "hasMany" relation with target relation keys.
- * ```
- * {
- * type: RelationType.HAS_MANY,
- * model: 'model',
- * polymorphic: true,
- * foreignKey: 'referenceId',
- * discriminator: 'referenceType',
- * }
- * ```
- *
- * @param {string} modelName
- * @param {string} relName
- * @param {object} relDef
- * @private
- */
- _validateHasMany(modelName, relName, relDef) {
- if (relDef.type !== RelationType.HAS_MANY) return;
- if (!relDef.model || typeof relDef.model !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "hasMany", so it requires the option "model" to be a non-empty String, but %v given.',
- relName,
- modelName,
- relDef.model
- );
- if (relDef.polymorphic) {
- if (typeof relDef.polymorphic === "string") {
- if (relDef.foreignKey)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "foreignKey" to be provided.',
- relName,
- modelName
- );
- if (relDef.discriminator)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "discriminator" to be provided.',
- relName,
- modelName
- );
- } else if (typeof relDef.polymorphic === "boolean") {
- if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "foreignKey" to be a non-empty String, but %v given.',
- relName,
- modelName,
- relDef.foreignKey
- );
- if (!relDef.discriminator || typeof relDef.discriminator !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "discriminator" to be a non-empty String, but %v given.',
- relName,
- modelName,
- relDef.discriminator
- );
- } else {
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "hasMany", so it expects the provided option "polymorphic" to be a String or a Boolean, but %v given.',
- relName,
- modelName,
- relDef.polymorphic
- );
- }
- } else {
- if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "hasMany", so it requires the option "foreignKey" to be a non-empty String, but %v given.',
- relName,
- modelName,
- relDef.foreignKey
- );
- if (relDef.discriminator)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v is a non-polymorphic "hasMany" relation, so it should not have the option "discriminator" to be provided.',
- relName,
- modelName
- );
- }
- }
- /**
- * Validate "referencesMany".
- *
- * @example
- * ```
- * {
- * type: RelationType.REFERENCES_MANY,
- * model: 'model',
- * foreignKey: 'modelIds', // optional
- * }
- * ```
- *
- * @param {string} modelName
- * @param {string} relName
- * @param {object} relDef
- * @private
- */
- _validateReferencesMany(modelName, relName, relDef) {
- if (relDef.type !== RelationType.REFERENCES_MANY) return;
- if (!relDef.model || typeof relDef.model !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "referencesMany", so it requires the option "model" to be a non-empty String, but %v given.',
- relName,
- modelName,
- relDef.model
- );
- if (relDef.foreignKey && typeof relDef.foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "referencesMany", so it expects the provided option "foreignKey" to be a String, but %v given.',
- relName,
- modelName,
- relDef.foreignKey
- );
- if (relDef.discriminator)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v has the type "referencesMany", so it should not have the option "discriminator" to be provided.',
- relName,
- modelName
- );
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/relations/index.js
- var init_relations = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/relations/index.js"() {
- init_relation_type();
- init_relation_definition();
- init_relations_definition_validator();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/data-type.js
- var DataType;
- var init_data_type = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/data-type.js"() {
- DataType = {
- ANY: "any",
- STRING: "string",
- NUMBER: "number",
- BOOLEAN: "boolean",
- ARRAY: "array",
- OBJECT: "object"
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-definition.js
- var init_property_definition = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-definition.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-uniqueness.js
- var PropertyUniqueness;
- var init_property_uniqueness = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-uniqueness.js"() {
- PropertyUniqueness = {
- STRICT: "strict",
- SPARSE: "sparse",
- NON_UNIQUE: "nonUnique"
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/empty-values-definer.js
- var EmptyValuesDefiner;
- var init_empty_values_definer = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/empty-values-definer.js"() {
- init_data_type();
- init_src2();
- init_utils2();
- init_errors2();
- EmptyValuesDefiner = class extends Service {
- /**
- * Empty values map.
- *
- * @type {Map<string, *[]>}
- */
- _emptyValuesMap = /* @__PURE__ */ new Map([
- [DataType.ANY, [void 0, null]],
- [DataType.STRING, [void 0, null, ""]],
- [DataType.NUMBER, [void 0, null, 0]],
- [DataType.BOOLEAN, [void 0, null]],
- [DataType.ARRAY, [void 0, null, []]],
- [DataType.OBJECT, [void 0, null, {}]]
- ]);
- /**
- * Set empty values of data type.
- *
- * @param {string} dataType
- * @param {*[]} emptyValues
- * @returns {EmptyValuesDefiner}
- */
- setEmptyValuesOf(dataType, emptyValues) {
- if (!Object.values(DataType).includes(dataType))
- throw new InvalidArgumentError2(
- 'The argument "dataType" of the EmptyValuesDefiner.setEmptyValuesOf must be one of data types: %l, but %v given.',
- Object.values(DataType),
- dataType
- );
- if (!Array.isArray(emptyValues))
- throw new InvalidArgumentError2(
- 'The argument "emptyValues" of the EmptyValuesDefiner.setEmptyValuesOf must be an Array, but %v given.',
- emptyValues
- );
- this._emptyValuesMap.set(dataType, emptyValues);
- return this;
- }
- /**
- * Is empty.
- *
- * @param {string} dataType
- * @param {*} value
- * @returns {boolean}
- */
- isEmpty(dataType, value) {
- if (!Object.values(DataType).includes(dataType))
- throw new InvalidArgumentError2(
- 'The argument "dataType" of the EmptyValuesDefiner.isEmpty must be one of data types: %l, but %v given.',
- Object.values(DataType),
- dataType
- );
- return this._emptyValuesMap.get(dataType).some((v) => isDeepEqual(v, value));
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/property-validator.js
- var init_property_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/property-validator.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/builtin/regexp-validator.js
- function regexpValidator(value, options, context) {
- if (value == null || options === false) return true;
- if (typeof options !== "string" && !(options instanceof RegExp))
- throw new InvalidArgumentError2(
- 'The validator %v requires the "options" argument as a String or RegExp, but %v given.',
- context.validatorName,
- options
- );
- if (typeof value === "string") {
- const regexp = stringToRegexp(options);
- return regexp.test(value);
- }
- throw new InvalidArgumentError2(
- "The property validator %v requires a String value, but %v given.",
- context.validatorName,
- value
- );
- }
- var init_regexp_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/builtin/regexp-validator.js"() {
- init_utils2();
- init_errors2();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/builtin/max-length-validator.js
- function maxLengthValidator(value, options, context) {
- if (value == null || options === false) return true;
- if (typeof options !== "number")
- throw new InvalidArgumentError2(
- 'The validator %v requires the "options" argument as a Number, but %v given.',
- context.validatorName,
- options
- );
- if (typeof value === "string" || Array.isArray(value))
- return value.length <= options;
- throw new InvalidArgumentError2(
- "The property validator %v requires a String or an Array value, but %v given.",
- context.validatorName,
- value
- );
- }
- var init_max_length_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/builtin/max-length-validator.js"() {
- init_errors2();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/builtin/min-length-validator.js
- function minLengthValidator(value, options, context) {
- if (value == null || options === false) return true;
- if (typeof options !== "number")
- throw new InvalidArgumentError2(
- 'The validator %v requires the "options" argument as a Number, but %v given.',
- context.validatorName,
- options
- );
- if (typeof value === "string" || Array.isArray(value))
- return value.length >= options;
- throw new InvalidArgumentError2(
- "The property validator %v requires a String or an Array value, but %v given.",
- context.validatorName,
- value
- );
- }
- var init_min_length_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/builtin/min-length-validator.js"() {
- init_errors2();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/builtin/index.js
- var init_builtin = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/builtin/index.js"() {
- init_regexp_validator();
- init_max_length_validator();
- init_min_length_validator();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/property-validator-registry.js
- var PropertyValidatorRegistry;
- var init_property_validator_registry = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/property-validator-registry.js"() {
- init_src2();
- init_builtin();
- init_builtin();
- init_builtin();
- init_errors2();
- PropertyValidatorRegistry = class extends Service {
- /**
- * Validators.
- *
- * @type {object}
- */
- _validators = {
- maxLength: maxLengthValidator,
- minLength: minLengthValidator,
- regexp: regexpValidator
- };
- /**
- * Add validator.
- *
- * @param {string} name
- * @param {Function} validator
- * @returns {PropertyValidatorRegistry}
- */
- addValidator(name, validator) {
- if (!name || typeof name !== "string")
- throw new InvalidArgumentError2(
- "A name of the property validator must be a non-empty String, but %v given.",
- name
- );
- if (name in this._validators)
- throw new InvalidArgumentError2(
- "The property validator %v is already defined.",
- name
- );
- if (typeof validator !== "function")
- throw new InvalidArgumentError2(
- "The property validator %v must be a Function, but %v given.",
- name,
- validator
- );
- this._validators[name] = validator;
- return this;
- }
- /**
- * Has validator.
- *
- * @param {string} name
- * @returns {boolean}
- */
- hasValidator(name) {
- return Boolean(this._validators[name]);
- }
- /**
- * Get validator.
- *
- * @param {string} name
- * @returns {Function}
- */
- getValidator(name) {
- const validator = this._validators[name];
- if (!validator)
- throw new InvalidArgumentError2(
- "The property validator %v is not defined.",
- name
- );
- return validator;
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/index.js
- var init_property_validator2 = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-validator/index.js"() {
- init_property_validator();
- init_property_validator_registry();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/property-transformer.js
- var init_property_transformer = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/property-transformer.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/builtin/trim-transformer.js
- function trimTransformer(value, options, context) {
- if (value == null) return value;
- if (typeof value === "string") return value.trim();
- throw new InvalidArgumentError2(
- "The property transformer %v requires a String value, but %v given.",
- context.transformerName,
- value
- );
- }
- var init_trim_transformer = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/builtin/trim-transformer.js"() {
- init_errors2();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.js
- function toLowerCaseTransformer(value, options, context) {
- if (value == null) return value;
- if (typeof value === "string") return value.toLowerCase();
- throw new InvalidArgumentError2(
- "The property transformer %v requires a String value, but %v given.",
- context.transformerName,
- value
- );
- }
- var init_to_lower_case_transformer = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.js"() {
- init_errors2();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.js
- function toUpperCaseTransformer(value, options, context) {
- if (value == null) return value;
- if (typeof value === "string") return value.toUpperCase();
- throw new InvalidArgumentError2(
- "The property transformer %v requires a String value, but %v given.",
- context.transformerName,
- value
- );
- }
- var init_to_upper_case_transformer = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.js"() {
- init_errors2();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/builtin/to-title-case-transformer.js
- function toTitleCaseTransformer(value, options, context) {
- if (value == null) return value;
- if (typeof value === "string")
- return value.replace(new RegExp("\\p{L}\\S*", "gu"), (text) => {
- return text.charAt(0).toUpperCase() + text.substring(1).toLowerCase();
- });
- throw new InvalidArgumentError2(
- "The property transformer %v requires a String value, but %v given.",
- context.transformerName,
- value
- );
- }
- var init_to_title_case_transformer = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/builtin/to-title-case-transformer.js"() {
- init_errors2();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/builtin/index.js
- var init_builtin2 = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/builtin/index.js"() {
- init_trim_transformer();
- init_to_lower_case_transformer();
- init_to_upper_case_transformer();
- init_to_title_case_transformer();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/property-transformer-registry.js
- var PropertyTransformerRegistry;
- var init_property_transformer_registry = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/property-transformer-registry.js"() {
- init_src2();
- init_builtin2();
- init_builtin2();
- init_builtin2();
- init_builtin2();
- init_errors2();
- PropertyTransformerRegistry = class extends Service {
- /**
- * Transformers.
- *
- * @type {object}
- */
- _transformers = {
- trim: trimTransformer,
- toUpperCase: toUpperCaseTransformer,
- toLowerCase: toLowerCaseTransformer,
- toTitleCase: toTitleCaseTransformer
- };
- /**
- * Add transformer.
- *
- * @param {string} name
- * @param {Function} transformer
- * @returns {PropertyTransformerRegistry}
- */
- addTransformer(name, transformer) {
- if (!name || typeof name !== "string")
- throw new InvalidArgumentError2(
- "A name of the property transformer must be a non-empty String, but %v given.",
- name
- );
- if (name in this._transformers)
- throw new InvalidArgumentError2(
- "The property transformer %v is already defined.",
- name
- );
- if (typeof transformer !== "function")
- throw new InvalidArgumentError2(
- "The property transformer %v must be a Function, but %v given.",
- name,
- transformer
- );
- this._transformers[name] = transformer;
- return this;
- }
- /**
- * Has transformer.
- *
- * @param {string} name
- * @returns {boolean}
- */
- hasTransformer(name) {
- return Boolean(this._transformers[name]);
- }
- /**
- * Get transformer.
- *
- * @param {string} name
- * @returns {Function}
- */
- getTransformer(name) {
- const transformer = this._transformers[name];
- if (!transformer)
- throw new InvalidArgumentError2(
- "The property transformer %v is not defined.",
- name
- );
- return transformer;
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/index.js
- var init_property_transformer2 = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-transformer/index.js"() {
- init_property_transformer();
- init_property_transformer_registry();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/definition-registry.js
- var DefinitionRegistry;
- var init_definition_registry = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/definition-registry.js"() {
- init_src2();
- init_errors2();
- init_model();
- init_definition();
- DefinitionRegistry = class extends Service {
- /**
- * Datasources.
- *
- * @type {object}
- */
- _datasources = {};
- /**
- * Models.
- *
- * @type {object}
- */
- _models = {};
- /**
- * Add datasource.
- *
- * @param {object} datasourceDef
- */
- addDatasource(datasourceDef) {
- this.getService(DatasourceDefinitionValidator).validate(datasourceDef);
- const name = datasourceDef.name;
- if (name in this._datasources)
- throw new InvalidArgumentError2(
- "The datasource %v is already defined.",
- name
- );
- this._datasources[name] = datasourceDef;
- }
- /**
- * Has datasource.
- *
- * @param {string} name
- * @returns {boolean}
- */
- hasDatasource(name) {
- return Boolean(this._datasources[name]);
- }
- /**
- * Get datasource.
- *
- * @param {string} name
- * @returns {object}
- */
- getDatasource(name) {
- const datasourceDef = this._datasources[name];
- if (!datasourceDef)
- throw new InvalidArgumentError2("The datasource %v is not defined.", name);
- return datasourceDef;
- }
- /**
- * Add model.
- *
- * @param {object} modelDef
- */
- addModel(modelDef) {
- this.getService(ModelDefinitionValidator).validate(modelDef);
- const name = modelDef.name;
- if (name in this._models)
- throw new InvalidArgumentError2("The model %v is already defined.", name);
- this._models[name] = modelDef;
- }
- /**
- * Has model.
- *
- * @param {string} name
- * @returns {boolean}
- */
- hasModel(name) {
- return Boolean(this._models[name]);
- }
- /**
- * Get model.
- *
- * @param {string} name
- * @returns {object}
- */
- getModel(name) {
- const modelDef = this._models[name];
- if (!modelDef)
- throw new InvalidArgumentError2("The model %v is not defined.", name);
- return modelDef;
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/model-definition-utils.js
- var DEFAULT_PRIMARY_KEY_PROPERTY_NAME, ModelDefinitionUtils;
- var init_model_definition_utils = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/model-definition-utils.js"() {
- init_src2();
- init_properties();
- init_utils2();
- init_utils2();
- init_properties();
- init_errors2();
- init_definition_registry();
- DEFAULT_PRIMARY_KEY_PROPERTY_NAME = "id";
- ModelDefinitionUtils = class extends Service {
- /**
- * Get primary key as property name.
- *
- * @param {string} modelName
- * @returns {string}
- */
- getPrimaryKeyAsPropertyName(modelName) {
- const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
- const propNames = Object.keys(propDefs).filter((propName) => {
- const propDef = propDefs[propName];
- return propDef && typeof propDef === "object" && propDef.primaryKey;
- });
- if (propNames.length < 1) {
- const isDefaultPrimaryKeyAlreadyInUse = Object.keys(propDefs).includes(
- DEFAULT_PRIMARY_KEY_PROPERTY_NAME
- );
- if (isDefaultPrimaryKeyAlreadyInUse)
- throw new InvalidArgumentError2(
- 'The property name %v of the model %v is defined as a regular property. In this case, a primary key should be defined explicitly. Do use the option "primaryKey" to specify the primary key.',
- DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
- modelName
- );
- return DEFAULT_PRIMARY_KEY_PROPERTY_NAME;
- }
- return propNames[0];
- }
- /**
- * Get primary key as column name.
- *
- * @param {string} modelName
- * @returns {string}
- */
- getPrimaryKeyAsColumnName(modelName) {
- const pkPropName = this.getPrimaryKeyAsPropertyName(modelName);
- let pkColName;
- try {
- pkColName = this.getColumnNameByPropertyName(modelName, pkPropName);
- } catch (error) {
- if (!(error instanceof InvalidArgumentError2)) throw error;
- }
- if (pkColName === void 0) return pkPropName;
- return pkColName;
- }
- /**
- * Get table name by model name.
- *
- * @param {string} modelName
- * @returns {string}
- */
- getTableNameByModelName(modelName) {
- const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
- return modelDef.tableName ?? modelName;
- }
- /**
- * Get column name by property name.
- *
- * @param {string} modelName
- * @param {string} propertyName
- * @returns {string}
- */
- getColumnNameByPropertyName(modelName, propertyName) {
- const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
- const propDef = propDefs[propertyName];
- if (!propDef)
- throw new InvalidArgumentError2(
- "The model %v does not have the property %v.",
- modelName,
- propertyName
- );
- if (propDef && typeof propDef === "object")
- return propDef.columnName ?? propertyName;
- return propertyName;
- }
- /**
- * Get default property value.
- *
- * @param {string} modelName
- * @param {string} propertyName
- * @returns {*}
- */
- getDefaultPropertyValue(modelName, propertyName) {
- const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
- const propDef = propDefs[propertyName];
- if (!propDef)
- throw new InvalidArgumentError2(
- "The model %v does not have the property %v.",
- modelName,
- propertyName
- );
- if (propDef && typeof propDef === "object")
- return propDef.default instanceof Function ? propDef.default() : propDef.default;
- }
- /**
- * Set default values for empty properties.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {boolean|undefined} onlyProvidedProperties
- * @returns {object}
- */
- setDefaultValuesToEmptyProperties(modelName, modelData, onlyProvidedProperties = false) {
- const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
- const propNames = onlyProvidedProperties ? Object.keys(modelData) : Object.keys(propDefs);
- const extendedData = cloneDeep(modelData);
- const emptyValueDefiner = this.getService(EmptyValuesDefiner);
- propNames.forEach((propName) => {
- const propDef = propDefs[propName];
- const propValue = extendedData[propName];
- const propType = propDef != null ? this.getDataTypeFromPropertyDefinition(propDef) : DataType.ANY;
- const isEmpty = emptyValueDefiner.isEmpty(propType, propValue);
- if (!isEmpty) return;
- if (propDef && typeof propDef === "object" && propDef.default !== void 0) {
- extendedData[propName] = this.getDefaultPropertyValue(
- modelName,
- propName
- );
- }
- });
- return extendedData;
- }
- /**
- * Convert property names to column names.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @returns {object}
- */
- convertPropertyNamesToColumnNames(modelName, modelData) {
- const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
- const propNames = Object.keys(propDefs);
- const convertedData = cloneDeep(modelData);
- propNames.forEach((propName) => {
- if (!(propName in convertedData)) return;
- const colName = this.getColumnNameByPropertyName(modelName, propName);
- if (propName === colName) return;
- const propValue = convertedData[propName];
- delete convertedData[propName];
- convertedData[colName] = propValue;
- });
- return convertedData;
- }
- /**
- * Convert column names to property names.
- *
- * @param {string} modelName
- * @param {object} tableData
- * @returns {object}
- */
- convertColumnNamesToPropertyNames(modelName, tableData) {
- const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
- const propNames = Object.keys(propDefs);
- const convertedData = cloneDeep(tableData);
- propNames.forEach((propName) => {
- const colName = this.getColumnNameByPropertyName(modelName, propName);
- if (!(colName in convertedData) || colName === propName) return;
- const colValue = convertedData[colName];
- delete convertedData[colName];
- convertedData[propName] = colValue;
- });
- return convertedData;
- }
- /**
- * Get data type by property name.
- *
- * @param {string} modelName
- * @param {string} propertyName
- * @returns {string}
- */
- getDataTypeByPropertyName(modelName, propertyName) {
- const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
- const propDef = propDefs[propertyName];
- if (!propDef) {
- const pkPropName = this.getPrimaryKeyAsPropertyName(modelName);
- if (pkPropName === propertyName) return DataType.ANY;
- throw new InvalidArgumentError2(
- "The model %v does not have the property %v.",
- modelName,
- propertyName
- );
- }
- if (typeof propDef === "string") return propDef;
- return propDef.type;
- }
- /**
- * Get data type from property definition.
- *
- * @param {object} propDef
- * @returns {string}
- */
- getDataTypeFromPropertyDefinition(propDef) {
- if ((!propDef || typeof propDef !== "object") && !Object.values(DataType).includes(propDef)) {
- throw new InvalidArgumentError2(
- 'The argument "propDef" of the ModelDefinitionUtils.getDataTypeFromPropertyDefinition should be an Object or the DataType enum, but %v given.',
- propDef
- );
- }
- if (typeof propDef === "string") return propDef;
- const dataType = propDef.type;
- if (!Object.values(DataType).includes(dataType))
- throw new InvalidArgumentError2(
- 'The given Object to the ModelDefinitionUtils.getDataTypeFromPropertyDefinition should have the "type" property with one of values: %l, but %v given.',
- Object.values(DataType),
- propDef.type
- );
- return dataType;
- }
- /**
- * Get own properties definition of primary keys.
- *
- * @param {string} modelName
- * @returns {object}
- */
- getOwnPropertiesDefinitionOfPrimaryKeys(modelName) {
- const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
- const propDefs = modelDef.properties ?? {};
- const pkPropNames = Object.keys(propDefs).filter((propName) => {
- const propDef = propDefs[propName];
- return typeof propDef === "object" && propDef.primaryKey;
- });
- return pkPropNames.reduce((a, k) => ({ ...a, [k]: propDefs[k] }), {});
- }
- /**
- * Get own properties definition without primary keys.
- *
- * @param {string} modelName
- * @returns {object}
- */
- getOwnPropertiesDefinitionWithoutPrimaryKeys(modelName) {
- const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
- const propDefs = modelDef.properties ?? {};
- return Object.keys(propDefs).reduce((result, propName) => {
- const propDef = propDefs[propName];
- if (typeof propDef === "object" && propDef.primaryKey) return result;
- return { ...result, [propName]: propDef };
- }, {});
- }
- /**
- * Get properties definition in base model hierarchy.
- *
- * @param {string} modelName
- * @returns {object}
- */
- getPropertiesDefinitionInBaseModelHierarchy(modelName) {
- let result = {};
- let pkPropDefs = {};
- const recursion = (currModelName, prevModelName = void 0) => {
- if (currModelName === prevModelName)
- throw new InvalidArgumentError2(
- "The model %v has a circular inheritance.",
- currModelName
- );
- if (Object.keys(pkPropDefs).length === 0) {
- pkPropDefs = this.getOwnPropertiesDefinitionOfPrimaryKeys(currModelName);
- result = { ...result, ...pkPropDefs };
- }
- const regularPropDefs = this.getOwnPropertiesDefinitionWithoutPrimaryKeys(currModelName);
- result = { ...regularPropDefs, ...result };
- const modelDef = this.getService(DefinitionRegistry).getModel(currModelName);
- if (modelDef.base) recursion(modelDef.base, currModelName);
- };
- recursion(modelName);
- return result;
- }
- /**
- * Get own relations definition.
- *
- * @param {string} modelName
- * @returns {object}
- */
- getOwnRelationsDefinition(modelName) {
- const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
- return modelDef.relations ?? {};
- }
- /**
- * Get relations definition in base model hierarchy.
- *
- * @param {string} modelName
- * @returns {object}
- */
- getRelationsDefinitionInBaseModelHierarchy(modelName) {
- let result = {};
- const recursion = (currModelName, prevModelName = void 0) => {
- if (currModelName === prevModelName)
- throw new InvalidArgumentError2(
- "The model %v has a circular inheritance.",
- currModelName
- );
- const modelDef = this.getService(DefinitionRegistry).getModel(currModelName);
- const ownRelDefs = modelDef.relations ?? {};
- result = { ...ownRelDefs, ...result };
- if (modelDef.base) recursion(modelDef.base, currModelName);
- };
- recursion(modelName);
- return result;
- }
- /**
- * Get relation definition by name.
- *
- * @param {string} modelName
- * @param {string} relationName
- * @returns {object}
- */
- getRelationDefinitionByName(modelName, relationName) {
- const relDefs = this.getRelationsDefinitionInBaseModelHierarchy(modelName);
- const relNames = Object.keys(relDefs);
- let foundDef;
- for (const relName of relNames) {
- if (relName === relationName) {
- foundDef = relDefs[relName];
- break;
- }
- }
- if (!foundDef)
- throw new InvalidArgumentError2(
- "The model %v does not have relation name %v.",
- modelName,
- relationName
- );
- return foundDef;
- }
- /**
- * Exclude object keys by relation names.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @returns {object}
- */
- excludeObjectKeysByRelationNames(modelName, modelData) {
- if (!modelData || typeof modelData !== "object" || Array.isArray(modelData))
- throw new InvalidArgumentError2(
- "The second argument of ModelDefinitionUtils.excludeObjectKeysByRelationNames should be an Object, but %v given.",
- modelData
- );
- const relDefs = this.getRelationsDefinitionInBaseModelHierarchy(modelName);
- const relNames = Object.keys(relDefs);
- return excludeObjectKeys(modelData, relNames);
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/property-uniqueness-validator.js
- var PropertyUniquenessValidator;
- var init_property_uniqueness_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/property-uniqueness-validator.js"() {
- init_data_type();
- init_src2();
- init_utils2();
- init_property_uniqueness();
- init_empty_values_definer();
- init_errors2();
- init_model_definition_utils();
- PropertyUniquenessValidator = class extends Service {
- /**
- * Validate.
- *
- * @param {Function} countMethod
- * @param {string} methodName
- * @param {string} modelName
- * @param {object} modelData
- * @param {*} modelId
- * @returns {Promise<undefined>}
- */
- async validate(countMethod, methodName, modelName, modelData, modelId = void 0) {
- if (typeof countMethod !== "function")
- throw new InvalidArgumentError2(
- 'The parameter "countMethod" of the PropertyUniquenessValidator must be a Function, but %v given.',
- countMethod
- );
- if (!methodName || typeof methodName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "methodName" of the PropertyUniquenessValidator must be a non-empty String, but %v given.',
- methodName
- );
- if (!modelName || typeof modelName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "modelName" of the PropertyUniquenessValidator must be a non-empty String, but %v given.',
- modelName
- );
- if (!isPureObject(modelData))
- throw new InvalidArgumentError2(
- "The data of the model %v should be an Object, but %v given.",
- modelName,
- modelData
- );
- const propDefs = this.getService(
- ModelDefinitionUtils
- ).getPropertiesDefinitionInBaseModelHierarchy(modelName);
- const isPartial = methodName === "patch" || methodName === "patchById";
- const propNames = Object.keys(isPartial ? modelData : propDefs);
- const idProp = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- modelName
- );
- const createError = (propName, propValue) => new InvalidArgumentError2(
- "An existing document of the model %v already has the property %v with the value %v and should be unique.",
- modelName,
- propName,
- propValue
- );
- let willBeReplaced = void 0;
- const emptyValuesDefiner = this.getService(EmptyValuesDefiner);
- for (const propName of propNames) {
- const propDef = propDefs[propName];
- if (!propDef || typeof propDef === "string" || !propDef.unique || propDef.unique === PropertyUniqueness.NON_UNIQUE) {
- continue;
- }
- const propValue = modelData[propName];
- if (propDef.unique === PropertyUniqueness.SPARSE) {
- const propType = propDef.type || DataType.ANY;
- const isEmpty = emptyValuesDefiner.isEmpty(propType, propValue);
- if (isEmpty) continue;
- }
- if (methodName === "create") {
- const count = await countMethod({ [propName]: propValue });
- if (count > 0) throw createError(propName, propValue);
- } else if (methodName === "replaceById") {
- const count = await countMethod({
- [idProp]: { neq: modelId },
- [propName]: propValue
- });
- if (count > 0) throw createError(propName, propValue);
- } else if (methodName === "replaceOrCreate") {
- const idFromData = modelData[idProp];
- if (willBeReplaced == null && idFromData != null) {
- const count = await countMethod({ [idProp]: idFromData });
- willBeReplaced = count > 0;
- }
- if (willBeReplaced) {
- const count = await countMethod({
- [idProp]: { neq: idFromData },
- [propName]: propValue
- });
- if (count > 0) throw createError(propName, propValue);
- } else {
- const count = await countMethod({ [propName]: propValue });
- if (count > 0) throw createError(propName, propValue);
- }
- } else if (methodName === "patch") {
- const count = await countMethod({ [propName]: propValue });
- if (count > 0) throw createError(propName, propValue);
- } else if (methodName === "patchById") {
- const count = await countMethod({
- [idProp]: { neq: modelId },
- [propName]: propValue
- });
- if (count > 0) throw createError(propName, propValue);
- } else {
- throw new InvalidArgumentError2(
- "The PropertyUniquenessValidator does not support the adapter method %v.",
- methodName
- );
- }
- }
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/primary-keys-definition-validator.js
- var PrimaryKeysDefinitionValidator;
- var init_primary_keys_definition_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/primary-keys-definition-validator.js"() {
- init_src2();
- init_errors2();
- init_model_definition_utils();
- PrimaryKeysDefinitionValidator = class extends Service {
- /**
- * Validate.
- *
- * @param {string} modelName
- * @param {object} propDefs
- */
- validate(modelName, propDefs) {
- const propNames = Object.keys(propDefs).filter((propName) => {
- const propDef = propDefs[propName];
- return propDef && typeof propDef === "object" && propDef.primaryKey;
- });
- if (propNames.length < 1) {
- const isDefaultPrimaryKeyAlreadyInUse = Object.keys(propDefs).includes(DEFAULT_PRIMARY_KEY_PROPERTY_NAME);
- if (isDefaultPrimaryKeyAlreadyInUse)
- throw new InvalidArgumentError2(
- 'The property name %v of the model %v is defined as a regular property. In this case, a primary key should be defined explicitly. Do use the option "primaryKey" to specify the primary key.',
- DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
- modelName
- );
- return;
- }
- if (propNames.length > 1)
- throw new InvalidArgumentError2(
- "The model definition %v should not have multiple primary keys, but %v keys given.",
- modelName,
- propNames.length
- );
- const pkPropName = propNames[0];
- const pkPropDef = propDefs[pkPropName];
- if (pkPropDef && typeof pkPropDef === "object" && pkPropDef.default !== void 0) {
- throw new InvalidArgumentError2(
- "Do not specify a default value for the primary key %v of the model %v.",
- pkPropName,
- modelName
- );
- }
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/properties-definition-validator.js
- var PropertiesDefinitionValidator;
- var init_properties_definition_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/properties-definition-validator.js"() {
- init_src2();
- init_data_type();
- init_utils2();
- init_property_uniqueness();
- init_errors2();
- init_property_validator2();
- init_property_transformer2();
- init_primary_keys_definition_validator();
- PropertiesDefinitionValidator = class extends Service {
- /**
- * Validate.
- *
- * @param {string} modelName
- * @param {object} propDefs
- */
- validate(modelName, propDefs) {
- if (!modelName || typeof modelName !== "string")
- throw new InvalidArgumentError2(
- "The first argument of PropertiesDefinitionValidator.validate should be a non-empty String, but %v given.",
- modelName
- );
- if (!propDefs || typeof propDefs !== "object" || Array.isArray(propDefs)) {
- throw new InvalidArgumentError2(
- 'The provided option "properties" of the model %v should be an Object, but %v given.',
- modelName,
- propDefs
- );
- }
- const propNames = Object.keys(propDefs);
- propNames.forEach((propName) => {
- const propDef = propDefs[propName];
- this._validateProperty(modelName, propName, propDef);
- });
- this.getService(PrimaryKeysDefinitionValidator).validate(
- modelName,
- propDefs
- );
- }
- /**
- * Validate property.
- *
- * @param {string} modelName
- * @param {string} propName
- * @param {object} propDef
- */
- _validateProperty(modelName, propName, propDef) {
- if (!modelName || typeof modelName !== "string")
- throw new InvalidArgumentError2(
- "The first argument of PropertiesDefinitionValidator._validateProperty should be a non-empty String, but %v given.",
- modelName
- );
- if (!propName || typeof propName !== "string")
- throw new InvalidArgumentError2(
- "The property name of the model %v should be a non-empty String, but %v given.",
- modelName,
- propName
- );
- if (!propDef)
- throw new InvalidArgumentError2(
- "The property %v of the model %v should have a property definition, but %v given.",
- propName,
- modelName,
- propDef
- );
- if (typeof propDef === "string") {
- if (!Object.values(DataType).includes(propDef))
- throw new InvalidArgumentError2(
- "In case of a short property definition, the property %v of the model %v should have one of data types: %l, but %v given.",
- propName,
- modelName,
- Object.values(DataType),
- propDef
- );
- return;
- }
- if (!propDef || typeof propDef !== "object" || Array.isArray(propDef)) {
- throw new InvalidArgumentError2(
- "In case of a full property definition, the property %v of the model %v should be an Object, but %v given.",
- propName,
- modelName,
- propDef
- );
- }
- if (!propDef.type || !Object.values(DataType).includes(propDef.type))
- throw new InvalidArgumentError2(
- 'The property %v of the model %v requires the option "type" to have one of data types: %l, but %v given.',
- propName,
- modelName,
- Object.values(DataType),
- propDef.type
- );
- if (propDef.itemType && !Object.values(DataType).includes(propDef.itemType)) {
- throw new InvalidArgumentError2(
- 'The provided option "itemType" of the property %v in the model %v should have one of data types: %l, but %v given.',
- propName,
- modelName,
- Object.values(DataType),
- propDef.itemType
- );
- }
- if (propDef.model && typeof propDef.model !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "model" of the property %v in the model %v should be a String, but %v given.',
- propName,
- modelName,
- propDef.model
- );
- if (propDef.primaryKey && typeof propDef.primaryKey !== "boolean")
- throw new InvalidArgumentError2(
- 'The provided option "primaryKey" of the property %v in the model %v should be a Boolean, but %v given.',
- propName,
- modelName,
- propDef.primaryKey
- );
- if (propDef.columnName && typeof propDef.columnName !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "columnName" of the property %v in the model %v should be a String, but %v given.',
- propName,
- modelName,
- propDef.columnName
- );
- if (propDef.columnType && typeof propDef.columnType !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "columnType" of the property %v in the model %v should be a String, but %v given.',
- propName,
- modelName,
- propDef.columnType
- );
- if (propDef.required && typeof propDef.required !== "boolean")
- throw new InvalidArgumentError2(
- 'The provided option "required" of the property %v in the model %v should be a Boolean, but %v given.',
- propName,
- modelName,
- propDef.required
- );
- if (propDef.required && propDef.default !== void 0)
- throw new InvalidArgumentError2(
- 'The property %v of the model %v is a required property, so it should not have the option "default" to be provided.',
- propName,
- modelName
- );
- if (propDef.primaryKey && propDef.required)
- throw new InvalidArgumentError2(
- 'The property %v of the model %v is a primary key, so it should not have the option "required" to be provided.',
- propName,
- modelName
- );
- if (propDef.primaryKey && propDef.default !== void 0)
- throw new InvalidArgumentError2(
- 'The property %v of the model %v is a primary key, so it should not have the option "default" to be provided.',
- propName,
- modelName
- );
- if (propDef.itemType && propDef.type !== DataType.ARRAY)
- throw new InvalidArgumentError2(
- 'The property %v of the model %v has the non-array type, so it should not have the option "itemType" to be provided.',
- propName,
- modelName,
- propDef.type
- );
- if (propDef.model && propDef.type !== DataType.OBJECT && propDef.itemType !== DataType.OBJECT) {
- if (propDef.type !== DataType.ARRAY) {
- throw new InvalidArgumentError2(
- 'The option "model" is not supported for %s property type, so the property %v of the model %v should not have the option "model" to be provided.',
- capitalize(propDef.type),
- propName,
- modelName
- );
- } else {
- throw new InvalidArgumentError2(
- 'The option "model" is not supported for Array property type of %s, so the property %v of the model %v should not have the option "model" to be provided.',
- capitalize(propDef.itemType),
- propName,
- modelName
- );
- }
- }
- if (propDef.validate != null) {
- const propertyValidatorRegistry = this.getService(
- PropertyValidatorRegistry
- );
- if (propDef.validate && typeof propDef.validate === "string") {
- if (!propertyValidatorRegistry.hasValidator(propDef.validate))
- throw new InvalidArgumentError2(
- "The property validator %v is not found.",
- propDef.validate
- );
- } else if (Array.isArray(propDef.validate)) {
- for (const validatorName of propDef.validate) {
- if (typeof validatorName !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "validate" of the property %v in the model %v has an Array value that should have a non-empty String, but %v given.',
- propName,
- modelName,
- validatorName
- );
- if (!propertyValidatorRegistry.hasValidator(validatorName))
- throw new InvalidArgumentError2(
- "The property validator %v is not found.",
- validatorName
- );
- }
- } else if (typeof propDef.validate === "object") {
- for (const validatorName in propDef.validate) {
- if (!propertyValidatorRegistry.hasValidator(validatorName))
- throw new InvalidArgumentError2(
- "The property validator %v is not found.",
- validatorName
- );
- }
- } else {
- throw new InvalidArgumentError2(
- 'The provided option "validate" of the property %v in the model %v should be a non-empty String, an Array of String or an Object, but %v given.',
- propName,
- modelName,
- propDef.validate
- );
- }
- }
- if (propDef.transform != null) {
- const propertyTransformerRegistry = this.getService(
- PropertyTransformerRegistry
- );
- if (propDef.transform && typeof propDef.transform === "string") {
- if (!propertyTransformerRegistry.hasTransformer(propDef.transform))
- throw new InvalidArgumentError2(
- "The property transformer %v is not found.",
- propDef.transform
- );
- } else if (Array.isArray(propDef.transform)) {
- for (const transformerName of propDef.transform) {
- if (typeof transformerName !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "transform" of the property %v in the model %v has an Array value that should have a non-empty String, but %v given.',
- propName,
- modelName,
- transformerName
- );
- if (!propertyTransformerRegistry.hasTransformer(transformerName))
- throw new InvalidArgumentError2(
- "The property transformer %v is not found.",
- transformerName
- );
- }
- } else if (typeof propDef.transform === "object") {
- for (const transformerName in propDef.transform) {
- if (!propertyTransformerRegistry.hasTransformer(transformerName))
- throw new InvalidArgumentError2(
- "The property transformer %v is not found.",
- transformerName
- );
- }
- } else {
- throw new InvalidArgumentError2(
- 'The provided option "transform" of the property %v in the model %v should be a non-empty String, an Array of String or an Object, but %v given.',
- propName,
- modelName,
- propDef.transform
- );
- }
- }
- if (propDef.unique) {
- if (typeof propDef.unique !== "boolean" && !Object.values(PropertyUniqueness).includes(propDef.unique)) {
- throw new InvalidArgumentError2(
- 'The provided option "unique" of the property %v in the model %v should be a Boolean or one of values: %l, but %v given.',
- propName,
- modelName,
- Object.values(PropertyUniqueness),
- propDef.unique
- );
- }
- }
- if (propDef.unique && propDef.primaryKey)
- throw new InvalidArgumentError2(
- 'The property %v of the model %v is a primary key, so it should not have the option "unique" to be provided.',
- propName,
- modelName
- );
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/properties/index.js
- var init_properties = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/properties/index.js"() {
- init_data_type();
- init_property_definition();
- init_property_uniqueness();
- init_empty_values_definer();
- init_property_validator2();
- init_property_transformer2();
- init_property_uniqueness_validator();
- init_properties_definition_validator();
- init_primary_keys_definition_validator();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/model-definition.js
- var init_model_definition = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/model-definition.js"() {
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/model-data-validator.js
- var ModelDataValidator;
- var init_model_data_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/model-data-validator.js"() {
- init_src2();
- init_properties();
- init_utils2();
- init_utils2();
- init_properties();
- init_errors2();
- init_properties();
- init_model_definition_utils();
- ModelDataValidator = class extends Service {
- /**
- * Validate.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {boolean} isPartial
- * @returns {undefined}
- */
- validate(modelName, modelData, isPartial = false) {
- if (!isPureObject(modelData))
- throw new InvalidArgumentError2(
- "The data of the model %v should be an Object, but %v given.",
- modelName,
- modelData
- );
- const propDefs = this.getService(
- ModelDefinitionUtils
- ).getPropertiesDefinitionInBaseModelHierarchy(modelName);
- const propNames = Object.keys(isPartial ? modelData : propDefs);
- propNames.forEach((propName) => {
- const propDef = propDefs[propName];
- if (!propDef) return;
- this._validatePropertyValue(
- modelName,
- propName,
- propDef,
- modelData[propName]
- );
- });
- }
- /**
- * Validate property value.
- *
- * @param {string} modelName
- * @param {string} propName
- * @param {string|object} propDef
- * @param {*} propValue
- * @returns {undefined}
- */
- _validatePropertyValue(modelName, propName, propDef, propValue) {
- const propType = this.getService(ModelDefinitionUtils).getDataTypeFromPropertyDefinition(
- propDef
- );
- const isEmpty = this.getService(EmptyValuesDefiner).isEmpty(
- propType,
- propValue
- );
- if (isEmpty) {
- const isRequired = typeof propDef === "string" ? false : Boolean(propDef.required);
- if (!isRequired) return;
- throw new InvalidArgumentError2(
- "The property %v of the model %v is required, but %v given.",
- propName,
- modelName,
- propValue
- );
- }
- this._validateValueByPropertyValidators(
- modelName,
- propName,
- propDef,
- propValue
- );
- this._validateValueByPropertyType(modelName, propName, propDef, propValue);
- }
- /**
- * Validate value by property type.
- *
- * @param {string} modelName
- * @param {string} propName
- * @param {string|object} propDef
- * @param {*} propValue
- * @param {boolean} isArrayValue
- * @returns {undefined}
- */
- _validateValueByPropertyType(modelName, propName, propDef, propValue, isArrayValue = false) {
- let expectingType;
- if (isArrayValue) {
- if (typeof propDef === "object") {
- expectingType = propDef.itemType ?? DataType.ANY;
- } else {
- expectingType = DataType.ANY;
- }
- } else {
- expectingType = typeof propDef !== "string" ? propDef.type : propDef;
- }
- const createError = (expected) => {
- const pattern = isArrayValue ? "The array property %v of the model %v must have %s element, but %s given." : "The property %v of the model %v must have %s, but %s given.";
- const ctorName = getCtorName(propValue);
- const givenStr = ctorName ?? typeof propValue;
- return new InvalidArgumentError2(
- pattern,
- propName,
- modelName,
- expected,
- givenStr
- );
- };
- switch (expectingType) {
- // STRING
- case DataType.STRING:
- if (typeof propValue !== "string") throw createError("a String");
- break;
- // NUMBER
- case DataType.NUMBER:
- if (typeof propValue !== "number") throw createError("a Number");
- break;
- // BOOLEAN
- case DataType.BOOLEAN:
- if (typeof propValue !== "boolean") throw createError("a Boolean");
- break;
- // ARRAY
- case DataType.ARRAY:
- if (!Array.isArray(propValue)) throw createError("an Array");
- propValue.forEach(
- (value) => this._validateValueByPropertyType(
- modelName,
- propName,
- propDef,
- value,
- true
- )
- );
- break;
- // OBJECT
- case DataType.OBJECT:
- if (!isPureObject(propValue)) throw createError("an Object");
- if (typeof propDef === "object" && propDef.model)
- this.validate(propDef.model, propValue);
- break;
- }
- }
- /**
- * Validate value by property validators.
- *
- * @param {string} modelName
- * @param {string} propName
- * @param {string|object} propDef
- * @param {*} propValue
- * @returns {undefined}
- */
- _validateValueByPropertyValidators(modelName, propName, propDef, propValue) {
- if (typeof propDef === "string" || propDef.validate == null) return;
- const validateDef = propDef.validate;
- const validatorRegistry = this.getService(PropertyValidatorRegistry);
- const createError = (validatorName) => new InvalidArgumentError2(
- "The property %v of the model %v has an invalid value %v that caught by the validator %v.",
- propName,
- modelName,
- propValue,
- validatorName
- );
- const validateBy = (validatorName, validatorOptions = void 0) => {
- const validator = validatorRegistry.getValidator(validatorName);
- const context = { validatorName, modelName, propName };
- const valid = validator(propValue, validatorOptions, context);
- if (valid instanceof Promise) {
- throw new InvalidArgumentError2(
- "Asynchronous property validators are not supported, but the property validator %v returns a Promise.",
- validatorName
- );
- } else if (valid !== true) {
- throw createError(validatorName);
- }
- };
- if (validateDef && typeof validateDef === "string") {
- validateBy(validateDef);
- } else if (Array.isArray(validateDef)) {
- validateDef.forEach((validatorName) => validateBy(validatorName));
- } else if (validateDef !== null && typeof validateDef === "object") {
- Object.keys(validateDef).forEach((validatorName) => {
- if (Object.prototype.hasOwnProperty.call(validateDef, validatorName)) {
- const validatorOptions = validateDef[validatorName];
- validateBy(validatorName, validatorOptions);
- }
- });
- } else {
- throw new InvalidArgumentError2(
- 'The provided option "validate" of the property %v in the model %v should be a non-empty String, an Array of String or an Object, but %v given.',
- propName,
- modelName,
- validateDef
- );
- }
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/model-data-sanitizer.js
- var ModelDataSanitizer;
- var init_model_data_sanitizer = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/model-data-sanitizer.js"() {
- init_src2();
- init_errors2();
- init_model_definition_utils();
- ModelDataSanitizer = class extends Service {
- /**
- * Validate.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @returns {object}
- */
- sanitize(modelName, modelData) {
- if (!modelName || typeof modelName !== "string")
- throw new InvalidArgumentError2(
- "The first argument of ModelDataSanitizer.sanitize should be a string, but %v given.",
- modelName
- );
- if (!modelData || typeof modelData !== "object")
- throw new InvalidArgumentError2(
- "The second argument of ModelDataSanitizer.sanitize should be an Object, but %v given.",
- modelData
- );
- return this.getService(
- ModelDefinitionUtils
- ).excludeObjectKeysByRelationNames(modelName, modelData);
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/model-data-transformer.js
- var ModelDataTransformer;
- var init_model_data_transformer = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/model-data-transformer.js"() {
- init_src2();
- init_utils2();
- init_utils2();
- init_utils2();
- init_properties();
- init_errors2();
- init_model_definition_utils();
- init_properties();
- ModelDataTransformer = class extends Service {
- /**
- * Transform.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {boolean} isPartial
- * @returns {object|Promise<object>}
- */
- transform(modelName, modelData, isPartial = false) {
- if (!isPureObject(modelData))
- throw new InvalidArgumentError2(
- "The data of the model %v should be an Object, but %v given.",
- modelName,
- modelData
- );
- const emptyValuesDefiner = this.getService(EmptyValuesDefiner);
- const modelDefinitionUtils = this.getService(ModelDefinitionUtils);
- const propDefs = modelDefinitionUtils.getPropertiesDefinitionInBaseModelHierarchy(
- modelName
- );
- const propNames = Object.keys(isPartial ? modelData : propDefs);
- const transformedData = cloneDeep(modelData);
- return propNames.reduce((transformedDataOrPromise, propName) => {
- const propDef = propDefs[propName];
- if (!propDef) return transformedDataOrPromise;
- const propType = modelDefinitionUtils.getDataTypeFromPropertyDefinition(propDef);
- const propValue = modelData[propName];
- const isEmpty = emptyValuesDefiner.isEmpty(propType, propValue);
- if (isEmpty) return transformedDataOrPromise;
- const newPropValueOrPromise = this._transformPropertyValue(
- modelName,
- propName,
- propDef,
- propValue
- );
- return transformPromise(newPropValueOrPromise, (newPropValue) => {
- return transformPromise(transformedDataOrPromise, (resolvedData) => {
- if (newPropValue !== propValue) resolvedData[propName] = newPropValue;
- return resolvedData;
- });
- });
- }, transformedData);
- }
- /**
- * Transform property value.
- *
- * @param {string} modelName
- * @param {string} propName
- * @param {string|object} propDef
- * @param {*} propValue
- * @returns {*}
- */
- _transformPropertyValue(modelName, propName, propDef, propValue) {
- if (typeof propDef === "string" || propDef.transform == null)
- return propValue;
- const transformDef = propDef.transform;
- const transformerRegistry = this.getService(PropertyTransformerRegistry);
- const transformFn = (value, transformerName, transformerOptions = void 0) => {
- const transformer = transformerRegistry.getTransformer(transformerName);
- const context = { transformerName, modelName, propName };
- return transformer(value, transformerOptions, context);
- };
- if (transformDef && typeof transformDef === "string") {
- return transformFn(propValue, transformDef);
- } else if (Array.isArray(transformDef)) {
- return transformDef.reduce((valueOrPromise, transformerName) => {
- return transformPromise(valueOrPromise, (value) => {
- return transformFn(value, transformerName);
- });
- }, propValue);
- } else if (transformDef !== null && typeof transformDef === "object") {
- return Object.keys(transformDef).reduce(
- (valueOrPromise, transformerName) => {
- const transformerOptions = transformDef[transformerName];
- return transformPromise(valueOrPromise, (value) => {
- return transformFn(value, transformerName, transformerOptions);
- });
- },
- propValue
- );
- } else {
- throw new InvalidArgumentError2(
- 'The provided option "transform" of the property %v in the model %v should be a non-empty String, an Array of String or an Object, but %v given.',
- propName,
- modelName,
- transformDef
- );
- }
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/model-definition-validator.js
- var ModelDefinitionValidator;
- var init_model_definition_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/model-definition-validator.js"() {
- init_src2();
- init_errors2();
- init_relations();
- init_properties();
- ModelDefinitionValidator = class extends Service {
- /**
- * Validate.
- *
- * @param {object} modelDef
- */
- validate(modelDef) {
- if (!modelDef || typeof modelDef !== "object" || Array.isArray(modelDef))
- throw new InvalidArgumentError2(
- "The model definition should be an Object, but %v given.",
- modelDef
- );
- if (!modelDef.name || typeof modelDef.name !== "string")
- throw new InvalidArgumentError2(
- 'The model definition requires the option "name" as a non-empty String, but %v given.',
- modelDef.name
- );
- if (modelDef.datasource && typeof modelDef.datasource !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "datasource" of the model %v should be a String, but %v given.',
- modelDef.name,
- modelDef.datasource
- );
- if (modelDef.base && typeof modelDef.base !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "base" of the model %v should be a String, but %v given.',
- modelDef.name,
- modelDef.base
- );
- if (modelDef.tableName && typeof modelDef.tableName !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "tableName" of the model %v should be a String, but %v given.',
- modelDef.name,
- modelDef.tableName
- );
- if (modelDef.properties) {
- if (typeof modelDef.properties !== "object" || Array.isArray(modelDef.properties)) {
- throw new InvalidArgumentError2(
- 'The provided option "properties" of the model %v should be an Object, but %v given.',
- modelDef.name,
- modelDef.properties
- );
- }
- this.getService(PropertiesDefinitionValidator).validate(
- modelDef.name,
- modelDef.properties
- );
- }
- if (modelDef.relations) {
- if (typeof modelDef.relations !== "object" || Array.isArray(modelDef.relations)) {
- throw new InvalidArgumentError2(
- 'The provided option "relations" of the model %v should be an Object, but %v given.',
- modelDef.name,
- modelDef.relations
- );
- }
- this.getService(RelationsDefinitionValidator).validate(
- modelDef.name,
- modelDef.relations
- );
- }
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/model/index.js
- var init_model = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/model/index.js"() {
- init_relations();
- init_properties();
- init_model_definition();
- init_model_data_validator();
- init_model_data_sanitizer();
- init_model_data_transformer();
- init_model_definition_utils();
- init_model_definition_validator();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/datasource/datasource-definition-validator.js
- var DatasourceDefinitionValidator;
- var init_datasource_definition_validator = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/datasource/datasource-definition-validator.js"() {
- init_src2();
- init_errors2();
- DatasourceDefinitionValidator = class extends Service {
- /**
- * Validate.
- *
- * @param {object} datasourceDef
- */
- validate(datasourceDef) {
- if (!datasourceDef || typeof datasourceDef !== "object")
- throw new InvalidArgumentError2(
- "The datasource definition should be an Object, but %v given.",
- datasourceDef
- );
- if (!datasourceDef.name || typeof datasourceDef.name !== "string")
- throw new InvalidArgumentError2(
- 'The datasource definition requires the option "name" as a non-empty String, but %v given.',
- datasourceDef.name
- );
- if (!datasourceDef.adapter || typeof datasourceDef.adapter !== "string")
- throw new InvalidArgumentError2(
- 'The datasource %v requires the option "adapter" as a non-empty String, but %v given.',
- datasourceDef.name,
- datasourceDef.adapter
- );
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/datasource/index.js
- var init_datasource = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/datasource/index.js"() {
- init_datasource_definition_validator();
- }
- });
- // node_modules/@e22m4u/js-repository/src/definition/index.js
- var init_definition = __esm({
- "node_modules/@e22m4u/js-repository/src/definition/index.js"() {
- init_model();
- init_datasource();
- init_definition_registry();
- }
- });
- // node_modules/@e22m4u/js-repository/src/filter/fields-clause-tool.js
- var FieldsClauseTool;
- var init_fields_clause_tool = __esm({
- "node_modules/@e22m4u/js-repository/src/filter/fields-clause-tool.js"() {
- init_src2();
- init_utils2();
- init_errors2();
- init_definition();
- FieldsClauseTool = class extends Service {
- /**
- * Filter.
- *
- * @param {object|object[]} input
- * @param {string} modelName
- * @param {string|string[]|undefined} clause
- * @returns {object|object[]}
- */
- filter(input, modelName, clause) {
- const isArray = Array.isArray(input);
- let entities = isArray ? input : [input];
- entities.forEach((entity) => {
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
- throw new InvalidArgumentError2(
- "The first argument of FieldsClauseTool.filter should be an Object or an Array of Object, but %v given.",
- entity
- );
- });
- if (!modelName || typeof modelName !== "string")
- throw new InvalidArgumentError2(
- "The second argument of FieldsClauseTool.filter should be a non-empty String, but %v given.",
- modelName
- );
- if (clause == null) return input;
- const fields = Array.isArray(clause) ? clause.slice() : [clause];
- if (!fields.length) return input;
- fields.forEach((field) => {
- if (!field || typeof field !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v given.',
- field
- );
- });
- const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- modelName
- );
- if (fields.indexOf(pkPropName) === -1) fields.push(pkPropName);
- entities = entities.map((entity) => selectObjectKeys(entity, fields));
- return isArray ? entities : entities[0];
- }
- /**
- * Validate fields clause.
- *
- * @param {string|string[]|undefined} clause
- */
- static validateFieldsClause(clause) {
- if (clause == null) return;
- const fields = Array.isArray(clause) ? clause : [clause];
- if (!fields.length) return;
- fields.forEach((field) => {
- if (!field || typeof field !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v given.',
- field
- );
- });
- }
- /**
- * Normalize fields clause.
- *
- * @param {string|string[]|undefined} clause
- * @returns {string[]|undefined}
- */
- static normalizeFieldsClause(clause) {
- if (clause == null) return;
- const fields = Array.isArray(clause) ? clause : [clause];
- if (!fields.length) return;
- fields.forEach((field) => {
- if (!field || typeof field !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v given.',
- field
- );
- });
- return fields;
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/relations/has-one-resolver.js
- var HasOneResolver;
- var init_has_one_resolver = __esm({
- "node_modules/@e22m4u/js-repository/src/relations/has-one-resolver.js"() {
- init_src2();
- init_utils2();
- init_definition();
- init_errors2();
- init_repository2();
- init_definition();
- HasOneResolver = class extends Service {
- /**
- * Include to.
- *
- * @param {object[]} entities
- * @param {string} sourceName
- * @param {string} targetName
- * @param {string} relationName
- * @param {string} foreignKey
- * @param {object|undefined} scope
- * @returns {Promise<void>}
- */
- async includeTo(entities, sourceName, targetName, relationName, foreignKey, scope = void 0) {
- if (!entities || !Array.isArray(entities))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of HasOneResolver.includeTo requires an Array of Object, but %v given.',
- entities
- );
- if (!sourceName || typeof sourceName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "sourceName" of HasOneResolver.includeTo requires a non-empty String, but %v given.',
- sourceName
- );
- if (!targetName || typeof targetName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "targetName" of HasOneResolver.includeTo requires a non-empty String, but %v given.',
- targetName
- );
- if (!relationName || typeof relationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "relationName" of HasOneResolver.includeTo requires a non-empty String, but %v given.',
- relationName
- );
- if (!foreignKey || typeof foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "foreignKey" of HasOneResolver.includeTo requires a non-empty String, but %v given.',
- foreignKey
- );
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
- throw new InvalidArgumentError2(
- 'The provided parameter "scope" of HasOneResolver.includeTo should be an Object, but %v given.',
- scope
- );
- const sourcePkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- sourceName
- );
- const sourceIds = [];
- entities.forEach((entity) => {
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of HasOneResolver.includeTo requires an Array of Object, but %v given.',
- entity
- );
- const sourceId = entity[sourcePkPropName];
- if (sourceIds.includes(sourceId)) return;
- sourceIds.push(sourceId);
- });
- const promises = [];
- const targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
- scope = scope ? cloneDeep(scope) : {};
- const targetBySourceId = /* @__PURE__ */ new Map();
- sourceIds.forEach((sourceId) => {
- const filter = cloneDeep(scope);
- filter.where = {
- and: [{ [foreignKey]: sourceId }, ...scope.where ? [scope.where] : []]
- };
- filter.limit = 1;
- promises.push(
- targetRepository.find(filter).then((result) => {
- if (result.length) targetBySourceId.set(sourceId, result[0]);
- })
- );
- });
- await Promise.all(promises);
- Array.from(targetBySourceId.keys()).forEach((sourceId) => {
- const sources = entities.filter((v) => v[sourcePkPropName] === sourceId);
- sources.forEach((v) => v[relationName] = targetBySourceId.get(sourceId));
- });
- }
- /**
- * Include polymorphic to.
- *
- * @param {object[]} entities
- * @param {string} sourceName
- * @param {string} targetName
- * @param {string} relationName
- * @param {string} foreignKey
- * @param {string} discriminator
- * @param {object|undefined} scope
- * @returns {Promise<void>}
- */
- async includePolymorphicTo(entities, sourceName, targetName, relationName, foreignKey, discriminator, scope = void 0) {
- if (!entities || !Array.isArray(entities))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of HasOneResolver.includePolymorphicTo requires an Array of Object, but %v given.',
- entities
- );
- if (!sourceName || typeof sourceName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "sourceName" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- sourceName
- );
- if (!targetName || typeof targetName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "targetName" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- targetName
- );
- if (!relationName || typeof relationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "relationName" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- relationName
- );
- if (!foreignKey || typeof foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "foreignKey" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- foreignKey
- );
- if (!discriminator || typeof discriminator !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "discriminator" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- discriminator
- );
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
- throw new InvalidArgumentError2(
- 'The provided parameter "scope" of HasOneResolver.includePolymorphicTo should be an Object, but %v given.',
- scope
- );
- const sourcePkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- sourceName
- );
- const sourceIds = [];
- entities.forEach((entity) => {
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of HasOneResolver.includePolymorphicTo requires an Array of Object, but %v given.',
- entity
- );
- const sourceId = entity[sourcePkPropName];
- if (sourceIds.includes(sourceId)) return;
- sourceIds.push(sourceId);
- });
- const promises = [];
- const targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
- scope = scope ? cloneDeep(scope) : {};
- const targetBySourceId = /* @__PURE__ */ new Map();
- sourceIds.forEach((sourceId) => {
- const filter = cloneDeep(scope);
- filter.where = {
- and: [
- { [foreignKey]: sourceId, [discriminator]: sourceName },
- ...scope.where ? [scope.where] : []
- ]
- };
- filter.limit = 1;
- promises.push(
- targetRepository.find(filter).then((result) => {
- if (result.length) targetBySourceId.set(sourceId, result[0]);
- })
- );
- });
- await Promise.all(promises);
- Array.from(targetBySourceId.keys()).forEach((sourceId) => {
- const sources = entities.filter((v) => v[sourcePkPropName] === sourceId);
- sources.forEach((v) => v[relationName] = targetBySourceId.get(sourceId));
- });
- }
- /**
- * Include polymorphic by relation name.
- *
- * @param {object[]} entities
- * @param {string} sourceName
- * @param {string} targetName
- * @param {string} relationName
- * @param {string} targetRelationName
- * @param {object|undefined} scope
- * @returns {Promise<void>}
- */
- async includePolymorphicByRelationName(entities, sourceName, targetName, relationName, targetRelationName, scope = void 0) {
- if (!entities || !Array.isArray(entities))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of HasOneResolver.includePolymorphicByRelationName requires an Array of Object, but %v given.',
- entities
- );
- if (!sourceName || typeof sourceName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "sourceName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
- sourceName
- );
- if (!targetName || typeof targetName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "targetName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
- targetName
- );
- if (!relationName || typeof relationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "relationName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
- relationName
- );
- if (!targetRelationName || typeof targetRelationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "targetRelationName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
- targetRelationName
- );
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
- throw new InvalidArgumentError2(
- 'The provided parameter "scope" of HasOneResolver.includePolymorphicByRelationName should be an Object, but %v given.',
- scope
- );
- const targetRelationDef = this.getService(
- ModelDefinitionUtils
- ).getRelationDefinitionByName(targetName, targetRelationName);
- if (targetRelationDef.type !== RelationType.BELONGS_TO)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v is a polymorphic "hasOne" relation, so it requires the target relation %v to be a polymorphic "belongsTo", but %v type given.',
- relationName,
- sourceName,
- targetRelationName,
- targetRelationDef.type
- );
- if (!targetRelationDef.polymorphic)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v is a polymorphic "hasOne" relation, so it requires the target relation %v to be a polymorphic too.',
- relationName,
- sourceName,
- targetRelationName
- );
- const foreignKey = targetRelationDef.foreignKey || `${targetRelationName}Id`;
- const discriminator = targetRelationDef.discriminator || `${targetRelationName}Type`;
- return this.includePolymorphicTo(
- entities,
- sourceName,
- targetName,
- relationName,
- foreignKey,
- discriminator,
- scope
- );
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/relations/has-many-resolver.js
- var HasManyResolver;
- var init_has_many_resolver = __esm({
- "node_modules/@e22m4u/js-repository/src/relations/has-many-resolver.js"() {
- init_src2();
- init_utils2();
- init_definition();
- init_errors2();
- init_repository2();
- init_definition();
- HasManyResolver = class extends Service {
- /**
- * Include to.
- *
- * @param {object[]} entities
- * @param {string} sourceName
- * @param {string} targetName
- * @param {string} relationName
- * @param {string} foreignKey
- * @param {object|undefined} scope
- * @returns {Promise<void>}
- */
- async includeTo(entities, sourceName, targetName, relationName, foreignKey, scope = void 0) {
- if (!entities || !Array.isArray(entities))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of HasManyResolver.includeTo requires an Array of Object, but %v given.',
- entities
- );
- if (!sourceName || typeof sourceName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "sourceName" of HasManyResolver.includeTo requires a non-empty String, but %v given.',
- sourceName
- );
- if (!targetName || typeof targetName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "targetName" of HasManyResolver.includeTo requires a non-empty String, but %v given.',
- targetName
- );
- if (!relationName || typeof relationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "relationName" of HasManyResolver.includeTo requires a non-empty String, but %v given.',
- relationName
- );
- if (!foreignKey || typeof foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "foreignKey" of HasManyResolver.includeTo requires a non-empty String, but %v given.',
- foreignKey
- );
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
- throw new InvalidArgumentError2(
- 'The provided parameter "scope" of HasManyResolver.includeTo should be an Object, but %v given.',
- scope
- );
- const sourcePkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- sourceName
- );
- const sourceIds = [];
- entities.forEach((entity) => {
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of HasManyResolver.includeTo requires an Array of Object, but %v given.',
- entity
- );
- const sourceId = entity[sourcePkPropName];
- if (sourceIds.includes(sourceId)) return;
- sourceIds.push(sourceId);
- });
- const promises = [];
- const targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
- scope = scope ? cloneDeep(scope) : {};
- const targetsBySourceId = /* @__PURE__ */ new Map();
- sourceIds.forEach((sourceId) => {
- const filter = cloneDeep(scope);
- filter.where = {
- and: [{ [foreignKey]: sourceId }, ...scope.where ? [scope.where] : []]
- };
- promises.push(
- targetRepository.find(filter).then((result) => {
- if (result.length) {
- let targets = targetsBySourceId.get(sourceId) ?? [];
- targets = [...targets, ...result];
- targetsBySourceId.set(sourceId, targets);
- }
- })
- );
- });
- await Promise.all(promises);
- entities.forEach((entity) => {
- const sourceId = entity[sourcePkPropName];
- entity[relationName] = targetsBySourceId.get(sourceId) ?? [];
- });
- }
- /**
- * Include polymorphic to.
- *
- * @param {object[]} entities
- * @param {string} sourceName
- * @param {string} targetName
- * @param {string} relationName
- * @param {string} foreignKey
- * @param {string} discriminator
- * @param {object|undefined} scope
- * @returns {Promise<void>}
- */
- async includePolymorphicTo(entities, sourceName, targetName, relationName, foreignKey, discriminator, scope = void 0) {
- if (!entities || !Array.isArray(entities))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of HasManyResolver.includePolymorphicTo requires an Array of Object, but %v given.',
- entities
- );
- if (!sourceName || typeof sourceName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "sourceName" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- sourceName
- );
- if (!targetName || typeof targetName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "targetName" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- targetName
- );
- if (!relationName || typeof relationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "relationName" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- relationName
- );
- if (!foreignKey || typeof foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "foreignKey" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- foreignKey
- );
- if (!discriminator || typeof discriminator !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "discriminator" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- discriminator
- );
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
- throw new InvalidArgumentError2(
- 'The provided parameter "scope" of HasManyResolver.includePolymorphicTo should be an Object, but %v given.',
- scope
- );
- const sourcePkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- sourceName
- );
- const sourceIds = [];
- entities.forEach((entity) => {
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of HasManyResolver.includePolymorphicTo requires an Array of Object, but %v given.',
- entity
- );
- const sourceId = entity[sourcePkPropName];
- if (sourceIds.includes(sourceId)) return;
- sourceIds.push(sourceId);
- });
- const promises = [];
- const targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
- scope = scope ? cloneDeep(scope) : {};
- const targetsBySourceId = /* @__PURE__ */ new Map();
- sourceIds.forEach((sourceId) => {
- const filter = cloneDeep(scope);
- filter.where = {
- and: [
- { [foreignKey]: sourceId, [discriminator]: sourceName },
- ...scope.where ? [scope.where] : []
- ]
- };
- promises.push(
- targetRepository.find(filter).then((result) => {
- if (result.length) {
- let targets = targetsBySourceId.get(sourceId) ?? [];
- targets = [...targets, ...result];
- targetsBySourceId.set(sourceId, targets);
- }
- })
- );
- });
- await Promise.all(promises);
- entities.forEach((entity) => {
- const sourceId = entity[sourcePkPropName];
- entity[relationName] = targetsBySourceId.get(sourceId) ?? [];
- });
- }
- /**
- * Include polymorphic by relation name.
- *
- * @param {object[]} entities
- * @param {string} sourceName
- * @param {string} targetName
- * @param {string} relationName
- * @param {string} targetRelationName
- * @param {object|undefined} scope
- * @returns {Promise<void>}
- */
- async includePolymorphicByRelationName(entities, sourceName, targetName, relationName, targetRelationName, scope = void 0) {
- if (!entities || !Array.isArray(entities))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of HasManyResolver.includePolymorphicByRelationName requires an Array of Object, but %v given.',
- entities
- );
- if (!sourceName || typeof sourceName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "sourceName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
- sourceName
- );
- if (!targetName || typeof targetName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "targetName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
- targetName
- );
- if (!relationName || typeof relationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "relationName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
- relationName
- );
- if (!targetRelationName || typeof targetRelationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "targetRelationName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
- targetRelationName
- );
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
- throw new InvalidArgumentError2(
- 'The provided parameter "scope" of HasManyResolver.includePolymorphicByRelationName should be an Object, but %v given.',
- scope
- );
- const targetRelationDef = this.getService(
- ModelDefinitionUtils
- ).getRelationDefinitionByName(targetName, targetRelationName);
- if (targetRelationDef.type !== RelationType.BELONGS_TO)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v is a polymorphic "hasMany" relation, so it requires the target relation %v to be a polymorphic "belongsTo", but %v type given.',
- relationName,
- sourceName,
- targetRelationName,
- targetRelationDef.type
- );
- if (!targetRelationDef.polymorphic)
- throw new InvalidArgumentError2(
- 'The relation %v of the model %v is a polymorphic "hasMany" relation, so it requires the target relation %v to be a polymorphic too.',
- relationName,
- sourceName,
- targetRelationName
- );
- const foreignKey = targetRelationDef.foreignKey || `${targetRelationName}Id`;
- const discriminator = targetRelationDef.discriminator || `${targetRelationName}Type`;
- return this.includePolymorphicTo(
- entities,
- sourceName,
- targetName,
- relationName,
- foreignKey,
- discriminator,
- scope
- );
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/relations/belongs-to-resolver.js
- var BelongsToResolver;
- var init_belongs_to_resolver = __esm({
- "node_modules/@e22m4u/js-repository/src/relations/belongs-to-resolver.js"() {
- init_src2();
- init_utils2();
- init_utils2();
- init_errors2();
- init_repository2();
- init_definition();
- BelongsToResolver = class extends Service {
- /**
- * Include to.
- *
- * @param {object[]} entities
- * @param {string} sourceName
- * @param {string} targetName
- * @param {string} relationName
- * @param {string|undefined} foreignKey
- * @param {object|undefined} scope
- * @returns {Promise<void>}
- */
- async includeTo(entities, sourceName, targetName, relationName, foreignKey = void 0, scope = void 0) {
- if (!entities || !Array.isArray(entities))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of BelongsToResolver.includeTo requires an Array of Object, but %v given.',
- entities
- );
- if (!sourceName || typeof sourceName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "sourceName" of BelongsToResolver.includeTo requires a non-empty String, but %v given.',
- sourceName
- );
- if (!targetName || typeof targetName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "targetName" of BelongsToResolver.includeTo requires a non-empty String, but %v given.',
- targetName
- );
- if (!relationName || typeof relationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "relationName" of BelongsToResolver.includeTo requires a non-empty String, but %v given.',
- relationName
- );
- if (foreignKey && typeof foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The provided parameter "foreignKey" of BelongsToResolver.includeTo should be a String, but %v given.',
- foreignKey
- );
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
- throw new InvalidArgumentError2(
- 'The provided parameter "scope" of BelongsToResolver.includeTo should be an Object, but %v given.',
- scope
- );
- if (foreignKey == null) foreignKey = `${relationName}Id`;
- const targetIds = entities.reduce((acc, entity) => {
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of BelongsToResolver.includeTo requires an Array of Object, but %v given.',
- entity
- );
- const targetId = entity[foreignKey];
- return targetId != null ? [...acc, targetId] : acc;
- }, []);
- const targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
- const targetPkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- targetName
- );
- scope = scope ? cloneDeep(scope) : {};
- const filter = cloneDeep(scope);
- filter.where = {
- and: [
- { [targetPkPropName]: { inq: targetIds } },
- ...scope.where ? [scope.where] : []
- ]
- };
- const targets = await targetRepository.find(filter);
- entities.forEach((entity) => {
- const target = targets.find(
- (e) => e[targetPkPropName] === entity[foreignKey]
- );
- if (target) entity[relationName] = target;
- });
- }
- /**
- * Include polymorphic to.
- *
- * @param {object[]} entities
- * @param {string} sourceName
- * @param {string} relationName
- * @param {string|undefined} foreignKey
- * @param {string|undefined} discriminator
- * @param {object|undefined} scope
- * @returns {Promise<void>}
- */
- async includePolymorphicTo(entities, sourceName, relationName, foreignKey = void 0, discriminator = void 0, scope = void 0) {
- if (!entities || !Array.isArray(entities))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of BelongsToResolver.includePolymorphicTo requires an Array of Object, but %v given.',
- entities
- );
- if (!sourceName || typeof sourceName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "sourceName" of BelongsToResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- sourceName
- );
- if (!relationName || typeof relationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "relationName" of BelongsToResolver.includePolymorphicTo requires a non-empty String, but %v given.',
- relationName
- );
- if (foreignKey && typeof foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The provided parameter "foreignKey" of BelongsToResolver.includePolymorphicTo should be a String, but %v given.',
- foreignKey
- );
- if (discriminator && typeof discriminator !== "string")
- throw new InvalidArgumentError2(
- 'The provided parameter "discriminator" of BelongsToResolver.includePolymorphicTo should be a String, but %v given.',
- discriminator
- );
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
- throw new InvalidArgumentError2(
- 'The provided parameter "scope" of BelongsToResolver.includePolymorphicTo should be an Object, but %v given.',
- scope
- );
- if (foreignKey == null) {
- const singularRelationName = singularize(relationName);
- foreignKey = `${singularRelationName}Id`;
- }
- if (discriminator == null) {
- const singularRelationName = singularize(relationName);
- discriminator = `${singularRelationName}Type`;
- }
- const targetIdsByTargetName = {};
- entities.forEach((entity) => {
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of BelongsToResolver.includePolymorphicTo requires an Array of Object, but %v given.',
- entity
- );
- const targetId = entity[foreignKey];
- const targetName = entity[discriminator];
- if (targetId == null || targetName == null) return;
- if (targetIdsByTargetName[targetName] == null)
- targetIdsByTargetName[targetName] = [];
- if (!targetIdsByTargetName[targetName].includes(targetId))
- targetIdsByTargetName[targetName].push(targetId);
- });
- const promises = [];
- const targetNames = Object.keys(targetIdsByTargetName);
- scope = scope ? cloneDeep(scope) : {};
- const targetEntitiesByTargetNames = {};
- targetNames.forEach((targetName) => {
- let targetRepository;
- try {
- targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
- } catch (error) {
- if (error instanceof InvalidArgumentError2) {
- if (error.message === `The model "${targetName}" is not defined.` || error.message === `The model "${targetName}" does not have a specified datasource.`) {
- return;
- }
- } else {
- throw error;
- }
- }
- const targetPkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- targetName
- );
- const targetFilter = cloneDeep(scope);
- const targetIds = targetIdsByTargetName[targetName];
- targetFilter.where = {
- and: [
- { [targetPkPropName]: { inq: targetIds } },
- ...scope.where ? [scope.where] : []
- ]
- };
- const promise = targetRepository.find(targetFilter).then((result) => {
- targetEntitiesByTargetNames[targetName] = [
- ...targetEntitiesByTargetNames[targetName] ?? [],
- ...result
- ];
- });
- promises.push(promise);
- });
- await Promise.all(promises);
- entities.forEach((entity) => {
- const targetId = entity[foreignKey];
- const targetName = entity[discriminator];
- if (targetId == null || targetName == null || targetEntitiesByTargetNames[targetName] == null) {
- return;
- }
- const targetEntities = targetEntitiesByTargetNames[targetName] ?? [];
- const targetPkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- targetName
- );
- const target = targetEntities.find((e) => e[targetPkPropName] === targetId);
- if (target) entity[relationName] = target;
- });
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/relations/references-many-resolver.js
- var ReferencesManyResolver;
- var init_references_many_resolver = __esm({
- "node_modules/@e22m4u/js-repository/src/relations/references-many-resolver.js"() {
- init_src2();
- init_utils2();
- init_utils2();
- init_errors2();
- init_repository2();
- init_definition();
- ReferencesManyResolver = class extends Service {
- /**
- * Include to.
- *
- * @param {object[]} entities
- * @param {string} sourceName
- * @param {string} targetName
- * @param {string} relationName
- * @param {string|undefined} foreignKey
- * @param {object|undefined} scope
- * @returns {Promise<void>}
- */
- async includeTo(entities, sourceName, targetName, relationName, foreignKey = void 0, scope = void 0) {
- if (!entities || !Array.isArray(entities))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of ReferencesManyResolver.includeTo requires an Array of Object, but %v given.',
- entities
- );
- if (!sourceName || typeof sourceName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "sourceName" of ReferencesManyResolver.includeTo requires a non-empty String, but %v given.',
- sourceName
- );
- if (!targetName || typeof targetName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "targetName" of ReferencesManyResolver.includeTo requires a non-empty String, but %v given.',
- targetName
- );
- if (!relationName || typeof relationName !== "string")
- throw new InvalidArgumentError2(
- 'The parameter "relationName" of ReferencesManyResolver.includeTo requires a non-empty String, but %v given.',
- relationName
- );
- if (foreignKey && typeof foreignKey !== "string")
- throw new InvalidArgumentError2(
- 'The provided parameter "foreignKey" of ReferencesManyResolver.includeTo should be a String, but %v given.',
- foreignKey
- );
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
- throw new InvalidArgumentError2(
- 'The provided parameter "scope" of ReferencesManyResolver.includeTo should be an Object, but %v given.',
- scope
- );
- if (foreignKey == null) {
- const singularRelationName = singularize(relationName);
- foreignKey = `${singularRelationName}Ids`;
- }
- const targetIds = entities.reduce((acc, entity) => {
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
- throw new InvalidArgumentError2(
- 'The parameter "entities" of ReferencesManyResolver.includeTo requires an Array of Object, but %v given.',
- entity
- );
- const ids = entity[foreignKey];
- if (Array.isArray(ids))
- ids.forEach((id) => {
- if (id == null || acc.includes(id)) return;
- acc.push(id);
- });
- return acc;
- }, []);
- const targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
- const targetPkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- targetName
- );
- scope = scope ? cloneDeep(scope) : {};
- const filter = cloneDeep(scope);
- filter.where = {
- and: [
- { [targetPkPropName]: { inq: targetIds } },
- ...scope.where ? [scope.where] : []
- ]
- };
- const targets = await targetRepository.find(filter);
- entities.forEach((entity) => {
- const ids = entity[foreignKey];
- entity[relationName] = [];
- if (Array.isArray(ids))
- targets.forEach((target) => {
- const targetId = target[targetPkPropName];
- if (ids.includes(targetId)) entity[relationName].push(target);
- });
- });
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/relations/index.js
- var init_relations2 = __esm({
- "node_modules/@e22m4u/js-repository/src/relations/index.js"() {
- init_has_one_resolver();
- init_has_many_resolver();
- init_belongs_to_resolver();
- init_references_many_resolver();
- }
- });
- // node_modules/@e22m4u/js-repository/src/filter/include-clause-tool.js
- var IncludeClauseTool;
- var init_include_clause_tool = __esm({
- "node_modules/@e22m4u/js-repository/src/filter/include-clause-tool.js"() {
- init_src2();
- init_definition();
- init_relations2();
- init_relations2();
- init_where_clause_tool();
- init_order_clause_tool();
- init_slice_clause_tool();
- init_errors2();
- init_relations2();
- init_fields_clause_tool();
- init_definition();
- init_relations2();
- IncludeClauseTool = class _IncludeClauseTool extends Service {
- /**
- * Include to.
- *
- * @param {object[]} entities
- * @param {string} modelName
- * @param {IncludeClause|undefined} clause
- * @returns {Promise<void>}
- */
- async includeTo(entities, modelName, clause) {
- clause = _IncludeClauseTool.normalizeIncludeClause(clause);
- const promises = [];
- clause.forEach((inclusion) => {
- const relDef = this.getService(
- ModelDefinitionUtils
- ).getRelationDefinitionByName(modelName, inclusion.relation);
- switch (relDef.type) {
- // BELONGS_TO
- case RelationType.BELONGS_TO:
- if (relDef.polymorphic) {
- promises.push(
- this.getService(BelongsToResolver).includePolymorphicTo(
- entities,
- modelName,
- inclusion.relation,
- relDef.foreignKey,
- relDef.discriminator,
- inclusion.scope
- )
- );
- } else {
- promises.push(
- this.getService(BelongsToResolver).includeTo(
- entities,
- modelName,
- relDef.model,
- inclusion.relation,
- relDef.foreignKey,
- inclusion.scope
- )
- );
- }
- break;
- // HAS_ONE
- case RelationType.HAS_ONE:
- if (relDef.polymorphic && typeof relDef.polymorphic === "string") {
- promises.push(
- this.getService(HasOneResolver).includePolymorphicByRelationName(
- entities,
- modelName,
- relDef.model,
- inclusion.relation,
- relDef.polymorphic,
- inclusion.scope
- )
- );
- } else if (relDef.polymorphic) {
- promises.push(
- this.getService(HasOneResolver).includePolymorphicTo(
- entities,
- modelName,
- relDef.model,
- inclusion.relation,
- relDef.foreignKey,
- relDef.discriminator,
- inclusion.scope
- )
- );
- } else {
- promises.push(
- this.getService(HasOneResolver).includeTo(
- entities,
- modelName,
- relDef.model,
- inclusion.relation,
- relDef.foreignKey,
- inclusion.scope
- )
- );
- }
- break;
- // HAS_MANY
- case RelationType.HAS_MANY:
- if (relDef.polymorphic && typeof relDef.polymorphic === "string") {
- promises.push(
- this.getService(HasManyResolver).includePolymorphicByRelationName(
- entities,
- modelName,
- relDef.model,
- inclusion.relation,
- relDef.polymorphic,
- inclusion.scope
- )
- );
- } else if (relDef.polymorphic) {
- promises.push(
- this.getService(HasManyResolver).includePolymorphicTo(
- entities,
- modelName,
- relDef.model,
- inclusion.relation,
- relDef.foreignKey,
- relDef.discriminator,
- inclusion.scope
- )
- );
- } else {
- promises.push(
- this.getService(HasManyResolver).includeTo(
- entities,
- modelName,
- relDef.model,
- inclusion.relation,
- relDef.foreignKey,
- inclusion.scope
- )
- );
- }
- break;
- case RelationType.REFERENCES_MANY:
- promises.push(
- this.getService(ReferencesManyResolver).includeTo(
- entities,
- modelName,
- relDef.model,
- inclusion.relation,
- relDef.foreignKey,
- inclusion.scope
- )
- );
- break;
- default:
- throw new InvalidArgumentError2(
- "The relation type %v does not have an inclusion resolver.",
- relDef.type
- );
- }
- });
- await Promise.all(promises);
- }
- /**
- * Validate include clause.
- *
- * @param {IncludeClause|undefined} clause
- */
- static validateIncludeClause(clause) {
- if (clause == null) {
- } else if (clause && typeof clause === "string") {
- } else if (Array.isArray(clause)) {
- const relNames = [];
- clause.flat(Infinity).forEach((el) => {
- this.validateIncludeClause(el);
- if (typeof el === "string") {
- relNames.push(el);
- } else if (typeof el === "object") {
- Object.keys(el).forEach((key) => {
- if (Object.prototype.hasOwnProperty.call(el, key))
- relNames.push(key);
- });
- }
- });
- const duplicateNames = relNames.filter(
- (name, i) => relNames.indexOf(name) !== i
- );
- if (duplicateNames.length)
- throw new InvalidArgumentError2(
- 'The provided option "include" has duplicates of %v.',
- duplicateNames[0]
- );
- } else if (typeof clause === "object") {
- if ("relation" in clause) {
- if (!clause.relation || typeof clause.relation !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "relation" should be a non-empty String, but %v given.',
- clause.relation
- );
- if ("scope" in clause && clause) this.validateScopeClause(clause.scope);
- } else {
- Object.keys(clause).forEach((key) => {
- if (!Object.prototype.hasOwnProperty.call(clause, key)) return;
- this.validateIncludeClause(key);
- this.validateIncludeClause(clause[key]);
- });
- }
- } else {
- throw new InvalidArgumentError2(
- 'The provided option "include" should have a non-empty String, an Object or an Array, but %v given.',
- clause
- );
- }
- }
- /**
- * Validate scope clause.
- *
- * @param {object|undefined} clause
- */
- static validateScopeClause(clause) {
- if (clause == null) return;
- if (typeof clause !== "object" || Array.isArray(clause))
- throw new InvalidArgumentError2(
- 'The provided option "scope" should be an Object, but %v given.',
- clause
- );
- if (clause.where != null) {
- WhereClauseTool.validateWhereClause(clause.where);
- }
- if (clause.order != null) {
- OrderClauseTool.validateOrderClause(clause.order);
- }
- if (clause.skip != null) {
- SliceClauseTool.validateSkipClause(clause.skip);
- }
- if (clause.limit != null) {
- SliceClauseTool.validateLimitClause(clause.limit);
- }
- if (clause.fields != null) {
- FieldsClauseTool.validateFieldsClause(clause.fields);
- }
- if (clause.include != null) {
- _IncludeClauseTool.validateIncludeClause(clause.include);
- }
- }
- /**
- * Normalize include clause.
- *
- * @param {IncludeClause|undefined} clause
- * @returns {object[]}
- */
- static normalizeIncludeClause(clause) {
- let result = [];
- if (clause == null) {
- return result;
- } else if (clause && typeof clause === "string") {
- result.push({ relation: clause });
- } else if (Array.isArray(clause)) {
- clause.flat(Infinity).forEach((el) => {
- el = this.normalizeIncludeClause(el);
- result = [...result, ...el];
- });
- const relNames = result.map((v) => v.relation);
- const duplicateNames = relNames.filter(
- (name, i) => relNames.indexOf(name) !== i
- );
- if (duplicateNames.length)
- throw new InvalidArgumentError2(
- 'The provided option "include" has duplicates of %v.',
- duplicateNames[0]
- );
- } else if (typeof clause === "object") {
- if ("relation" in clause) {
- if (!clause.relation || typeof clause.relation !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "relation" should be a non-empty String, but %v given.',
- clause.relation
- );
- const normalized = { relation: clause.relation };
- const scope = this.normalizeScopeClause(clause.scope);
- if (scope) normalized.scope = scope;
- result.push(normalized);
- } else {
- Object.keys(clause).forEach((key) => {
- if (!Object.prototype.hasOwnProperty.call(clause, key)) return;
- this.validateIncludeClause(key);
- const normalized = { relation: key };
- const include = this.normalizeIncludeClause(clause[key]);
- if (include.length) normalized.scope = { include };
- result.push(normalized);
- });
- }
- } else {
- throw new InvalidArgumentError2(
- 'The provided option "include" should have a non-empty String, an Object or an Array, but %v given.',
- clause
- );
- }
- return result;
- }
- /**
- * Normalize scope clause.
- *
- * @param {object|undefined} clause
- * @returns {object|undefined}
- */
- static normalizeScopeClause(clause) {
- if (clause == null) return;
- if (typeof clause !== "object" || Array.isArray(clause))
- throw new InvalidArgumentError2(
- 'The provided option "scope" should be an Object, but %v given.',
- clause
- );
- const result = {};
- if (clause.where != null) {
- WhereClauseTool.validateWhereClause(clause.where);
- result.where = clause.where;
- }
- if (clause.order != null) {
- OrderClauseTool.validateOrderClause(clause.order);
- result.order = clause.order;
- }
- if (clause.skip != null) {
- SliceClauseTool.validateSkipClause(clause.skip);
- result.skip = clause.skip;
- }
- if (clause.limit != null) {
- SliceClauseTool.validateLimitClause(clause.limit);
- result.limit = clause.limit;
- }
- if (clause.fields != null) {
- FieldsClauseTool.validateFieldsClause(clause.fields);
- result.fields = clause.fields;
- }
- if (clause.include != null) {
- result.include = this.normalizeIncludeClause(clause.include);
- }
- if (Object.keys(result).length) return result;
- return void 0;
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/filter/index.js
- var init_filter = __esm({
- "node_modules/@e22m4u/js-repository/src/filter/index.js"() {
- init_slice_clause_tool();
- init_order_clause_tool();
- init_where_clause_tool();
- init_fields_clause_tool();
- init_include_clause_tool();
- init_operator_clause_tool();
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/decorator/inclusion-decorator.js
- var InclusionDecorator;
- var init_inclusion_decorator = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/decorator/inclusion-decorator.js"() {
- init_adapter();
- init_src2();
- init_filter();
- init_errors2();
- InclusionDecorator = class extends Service {
- /**
- * Decorate.
- *
- * @param {Adapter} adapter
- */
- decorate(adapter) {
- if (!adapter || !(adapter instanceof Adapter))
- throw new InvalidArgumentError2(
- "The first argument of InclusionDecorator.decorate should be an Adapter instance, but %v given.",
- adapter
- );
- const tool = adapter.getService(IncludeClauseTool);
- const includeTo = (...args) => tool.includeTo(...args);
- const create = adapter.create;
- adapter.create = async function(modelName, modelData, filter) {
- const retvalData = await create.call(this, modelName, modelData, filter);
- if (filter && typeof filter === "object" && filter.include)
- await includeTo([retvalData], modelName, filter.include);
- return retvalData;
- };
- const replaceById = adapter.replaceById;
- adapter.replaceById = async function(modelName, id, modelData, filter) {
- const retvalData = await replaceById.call(
- this,
- modelName,
- id,
- modelData,
- filter
- );
- if (filter && typeof filter === "object" && filter.include)
- await includeTo([retvalData], modelName, filter.include);
- return retvalData;
- };
- const replaceOrCreate = adapter.replaceOrCreate;
- adapter.replaceOrCreate = async function(modelName, modelData, filter) {
- const retvalData = await replaceOrCreate.call(
- this,
- modelName,
- modelData,
- filter
- );
- if (filter && typeof filter === "object" && filter.include)
- await includeTo([retvalData], modelName, filter.include);
- return retvalData;
- };
- const patchById = adapter.patchById;
- adapter.patchById = async function(modelName, id, modelData, filter) {
- const retvalData = await patchById.call(
- this,
- modelName,
- id,
- modelData,
- filter
- );
- if (filter && typeof filter === "object" && filter.include)
- await includeTo([retvalData], modelName, filter.include);
- return retvalData;
- };
- const find = adapter.find;
- adapter.find = async function(modelName, filter) {
- const modelItems = await find.call(this, modelName, filter);
- if (filter && typeof filter === "object" && filter.include)
- await includeTo(modelItems, modelName, filter.include);
- return modelItems;
- };
- const findById = adapter.findById;
- adapter.findById = async function(modelName, id, filter) {
- const retvalData = await findById.call(this, modelName, id, filter);
- if (filter && typeof filter === "object" && filter.include)
- await includeTo([retvalData], modelName, filter.include);
- return retvalData;
- };
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/decorator/default-values-decorator.js
- var DefaultValuesDecorator;
- var init_default_values_decorator = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/decorator/default-values-decorator.js"() {
- init_adapter();
- init_src2();
- init_errors2();
- init_definition();
- DefaultValuesDecorator = class extends Service {
- /**
- * Decorate.
- *
- * @param {Adapter} adapter
- */
- decorate(adapter) {
- if (!adapter || !(adapter instanceof Adapter))
- throw new InvalidArgumentError2(
- "The first argument of DefaultValuesDecorator.decorate should be an Adapter instance, but %v given.",
- adapter
- );
- const utils = adapter.getService(ModelDefinitionUtils);
- const setDefaults = (...args) => utils.setDefaultValuesToEmptyProperties(...args);
- const create = adapter.create;
- adapter.create = function(modelName, modelData, filter) {
- modelData = setDefaults(modelName, modelData);
- return create.call(this, modelName, modelData, filter);
- };
- const replaceById = adapter.replaceById;
- adapter.replaceById = function(modelName, id, modelData, filter) {
- modelData = setDefaults(modelName, modelData);
- return replaceById.call(this, modelName, id, modelData, filter);
- };
- const replaceOrCreate = adapter.replaceOrCreate;
- adapter.replaceOrCreate = function(modelName, modelData, filter) {
- modelData = setDefaults(modelName, modelData);
- return replaceOrCreate.call(this, modelName, modelData, filter);
- };
- const patch = adapter.patch;
- adapter.patch = function(modelName, modelData, where) {
- modelData = setDefaults(modelName, modelData, true);
- return patch.call(this, modelName, modelData, where);
- };
- const patchById = adapter.patchById;
- adapter.patchById = function(modelName, id, modelData, filter) {
- modelData = setDefaults(modelName, modelData, true);
- return patchById.call(this, modelName, id, modelData, filter);
- };
- const find = adapter.find;
- adapter.find = async function(modelName, filter) {
- const modelItems = await find.call(this, modelName, filter);
- return modelItems.map((modelItem) => setDefaults(modelName, modelItem));
- };
- const findById = adapter.findById;
- adapter.findById = async function(modelName, id, filter) {
- const retvalData = await findById.call(this, modelName, id, filter);
- return setDefaults(modelName, retvalData);
- };
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/decorator/data-sanitizing-decorator.js
- var DataSanitizingDecorator;
- var init_data_sanitizing_decorator = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/decorator/data-sanitizing-decorator.js"() {
- init_adapter();
- init_src2();
- init_errors2();
- init_definition();
- DataSanitizingDecorator = class extends Service {
- /**
- * Decorate.
- *
- * @param {Adapter} adapter
- */
- decorate(adapter) {
- if (!adapter || !(adapter instanceof Adapter))
- throw new InvalidArgumentError2(
- "The first argument of DataSanitizingDecorator.decorate should be an Adapter instance, but %v given.",
- adapter
- );
- const sanitizer = adapter.getService(ModelDataSanitizer);
- const sanitize = (...args) => sanitizer.sanitize(...args);
- const create = adapter.create;
- adapter.create = async function(modelName, modelData, filter) {
- modelData = sanitize(modelName, modelData);
- return create.call(this, modelName, modelData, filter);
- };
- const replaceById = adapter.replaceById;
- adapter.replaceById = async function(modelName, id, modelData, filter) {
- modelData = sanitize(modelName, modelData);
- return replaceById.call(this, modelName, id, modelData, filter);
- };
- const replaceOrCreate = adapter.replaceOrCreate;
- adapter.replaceOrCreate = async function(modelName, modelData, filter) {
- modelData = sanitize(modelName, modelData);
- return replaceOrCreate.call(this, modelName, modelData, filter);
- };
- const patch = adapter.patch;
- adapter.patch = async function(modelName, modelData, where) {
- modelData = sanitize(modelName, modelData);
- return patch.call(this, modelName, modelData, where);
- };
- const patchById = adapter.patchById;
- adapter.patchById = async function(modelName, id, modelData, filter) {
- modelData = sanitize(modelName, modelData);
- return patchById.call(this, modelName, id, modelData, filter);
- };
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/decorator/data-validation-decorator.js
- var DataValidationDecorator;
- var init_data_validation_decorator = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/decorator/data-validation-decorator.js"() {
- init_adapter();
- init_src2();
- init_errors2();
- init_definition();
- DataValidationDecorator = class extends Service {
- /**
- * Decorate.
- *
- * @param {Adapter} adapter
- */
- decorate(adapter) {
- if (!adapter || !(adapter instanceof Adapter))
- throw new InvalidArgumentError2(
- "The first argument of DataValidationDecorator.decorate should be an Adapter instance, but %v given.",
- adapter
- );
- const validator = this.getService(ModelDataValidator);
- const create = adapter.create;
- adapter.create = function(modelName, modelData, filter) {
- validator.validate(modelName, modelData);
- return create.call(this, modelName, modelData, filter);
- };
- const replaceById = adapter.replaceById;
- adapter.replaceById = function(modelName, id, modelData, filter) {
- validator.validate(modelName, modelData);
- return replaceById.call(this, modelName, id, modelData, filter);
- };
- const replaceOrCreate = adapter.replaceOrCreate;
- adapter.replaceOrCreate = function(modelName, modelData, filter) {
- validator.validate(modelName, modelData);
- return replaceOrCreate.call(this, modelName, modelData, filter);
- };
- const patch = adapter.patch;
- adapter.patch = function(modelName, modelData, where) {
- validator.validate(modelName, modelData, true);
- return patch.call(this, modelName, modelData, where);
- };
- const patchById = adapter.patchById;
- adapter.patchById = function(modelName, id, modelData, filter) {
- validator.validate(modelName, modelData, true);
- return patchById.call(this, modelName, id, modelData, filter);
- };
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/decorator/fields-filtering-decorator.js
- var FieldsFilteringDecorator;
- var init_fields_filtering_decorator = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/decorator/fields-filtering-decorator.js"() {
- init_adapter();
- init_src2();
- init_filter();
- init_errors2();
- FieldsFilteringDecorator = class extends Service {
- /**
- * Decorate.
- *
- * @param {Adapter} adapter
- */
- decorate(adapter) {
- if (!adapter || !(adapter instanceof Adapter))
- throw new InvalidArgumentError2(
- "The first argument of FieldsFilteringDecorator.decorate should be an Adapter instance, but %v given.",
- adapter
- );
- const tool = adapter.getService(FieldsClauseTool);
- const selectFields = (...args) => tool.filter(...args);
- const create = adapter.create;
- adapter.create = async function(modelName, modelData, filter) {
- let result = await create.call(this, modelName, modelData, filter);
- if (filter && typeof filter === "object" && filter.fields)
- result = selectFields(result, modelName, filter.fields);
- return result;
- };
- const replaceById = adapter.replaceById;
- adapter.replaceById = async function(modelName, id, modelData, filter) {
- let result = await replaceById.call(
- this,
- modelName,
- id,
- modelData,
- filter
- );
- if (filter && typeof filter === "object" && filter.fields)
- result = selectFields(result, modelName, filter.fields);
- return result;
- };
- const replaceOrCreate = adapter.replaceOrCreate;
- adapter.replaceOrCreate = async function(modelName, modelData, filter) {
- let result = await replaceOrCreate.call(
- this,
- modelName,
- modelData,
- filter
- );
- if (filter && typeof filter === "object" && filter.fields)
- result = selectFields(result, modelName, filter.fields);
- return result;
- };
- const patchById = adapter.patchById;
- adapter.patchById = async function(modelName, id, modelData, filter) {
- let result = await patchById.call(this, modelName, id, modelData, filter);
- if (filter && typeof filter === "object" && filter.fields)
- result = selectFields(result, modelName, filter.fields);
- return result;
- };
- const find = adapter.find;
- adapter.find = async function(modelName, filter) {
- let result = await find.call(this, modelName, filter);
- if (filter && typeof filter === "object" && filter.fields)
- result = selectFields(result, modelName, filter.fields);
- return result;
- };
- const findById = adapter.findById;
- adapter.findById = async function(modelName, id, filter) {
- let result = await findById.call(this, modelName, id, filter);
- if (filter && typeof filter === "object" && filter.fields)
- result = selectFields(result, modelName, filter.fields);
- return result;
- };
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/decorator/data-transformation-decorator.js
- var DataTransformationDecorator;
- var init_data_transformation_decorator = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/decorator/data-transformation-decorator.js"() {
- init_adapter();
- init_src2();
- init_errors2();
- init_definition();
- DataTransformationDecorator = class extends Service {
- /**
- * Decorate.
- *
- * @param {Adapter} adapter
- */
- decorate(adapter) {
- if (!adapter || !(adapter instanceof Adapter))
- throw new InvalidArgumentError2(
- "The first argument of DataTransformerDecorator.decorate should be an Adapter instance, but %v given.",
- adapter
- );
- const transformer = this.getService(ModelDataTransformer);
- const create = adapter.create;
- adapter.create = async function(modelName, modelData, filter) {
- modelData = await transformer.transform(modelName, modelData);
- return create.call(this, modelName, modelData, filter);
- };
- const replaceById = adapter.replaceById;
- adapter.replaceById = async function(modelName, id, modelData, filter) {
- modelData = await transformer.transform(modelName, modelData);
- return replaceById.call(this, modelName, id, modelData, filter);
- };
- const replaceOrCreate = adapter.replaceOrCreate;
- adapter.replaceOrCreate = async function(modelName, modelData, filter) {
- modelData = await transformer.transform(modelName, modelData);
- return replaceOrCreate.call(this, modelName, modelData, filter);
- };
- const patch = adapter.patch;
- adapter.patch = async function(modelName, modelData, where) {
- modelData = await transformer.transform(modelName, modelData, true);
- return patch.call(this, modelName, modelData, where);
- };
- const patchById = adapter.patchById;
- adapter.patchById = async function(modelName, id, modelData, filter) {
- modelData = await transformer.transform(modelName, modelData, true);
- return patchById.call(this, modelName, id, modelData, filter);
- };
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/decorator/property-uniqueness-decorator.js
- var PropertyUniquenessDecorator;
- var init_property_uniqueness_decorator = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/decorator/property-uniqueness-decorator.js"() {
- init_adapter();
- init_src2();
- init_errors2();
- init_definition();
- PropertyUniquenessDecorator = class extends Service {
- /**
- * Decorate.
- *
- * @param {Adapter} adapter
- */
- decorate(adapter) {
- if (!adapter || !(adapter instanceof Adapter))
- throw new InvalidArgumentError2(
- "The first argument of PropertyUniquenessDecorator.decorate should be an Adapter instance, but %v given.",
- adapter
- );
- const validator = this.getService(PropertyUniquenessValidator);
- const create = adapter.create;
- adapter.create = async function(modelName, modelData, filter) {
- const countMethod = adapter.count.bind(adapter, modelName);
- await validator.validate(countMethod, "create", modelName, modelData);
- return create.call(this, modelName, modelData, filter);
- };
- const replaceById = adapter.replaceById;
- adapter.replaceById = async function(modelName, id, modelData, filter) {
- const countMethod = adapter.count.bind(adapter, modelName);
- await validator.validate(
- countMethod,
- "replaceById",
- modelName,
- modelData,
- id
- );
- return replaceById.call(this, modelName, id, modelData, filter);
- };
- const replaceOrCreate = adapter.replaceOrCreate;
- adapter.replaceOrCreate = async function(modelName, modelData, filter) {
- const countMethod = adapter.count.bind(adapter, modelName);
- await validator.validate(
- countMethod,
- "replaceOrCreate",
- modelName,
- modelData
- );
- return replaceOrCreate.call(this, modelName, modelData, filter);
- };
- const patch = adapter.patch;
- adapter.patch = async function(modelName, modelData, where) {
- const countMethod = adapter.count.bind(adapter, modelName);
- await validator.validate(countMethod, "patch", modelName, modelData);
- return patch.call(this, modelName, modelData, where);
- };
- const patchById = adapter.patchById;
- adapter.patchById = async function(modelName, id, modelData, filter) {
- const countMethod = adapter.count.bind(adapter, modelName);
- await validator.validate(
- countMethod,
- "patchById",
- modelName,
- modelData,
- id
- );
- return patchById.call(this, modelName, id, modelData, filter);
- };
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/decorator/index.js
- var init_decorator = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/decorator/index.js"() {
- init_inclusion_decorator();
- init_default_values_decorator();
- init_data_sanitizing_decorator();
- init_data_validation_decorator();
- init_fields_filtering_decorator();
- init_data_transformation_decorator();
- init_property_uniqueness_decorator();
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/adapter.js
- var Adapter;
- var init_adapter = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/adapter.js"() {
- init_src2();
- init_errors2();
- init_decorator();
- init_decorator();
- init_decorator();
- init_decorator();
- init_decorator();
- init_decorator();
- init_decorator();
- Adapter = class _Adapter extends Service {
- /**
- * Settings.
- *
- * @type {object|undefined}
- */
- _settings;
- /**
- * Settings.
- *
- * @returns {object|undefined}
- */
- get settings() {
- return this._settings;
- }
- /**
- * Constructor.
- *
- * @param {object|undefined} container
- * @param {object|undefined} settings
- */
- constructor(container = void 0, settings = void 0) {
- super(container);
- this._settings = settings;
- if (this.constructor !== _Adapter) {
- this.getService(DataSanitizingDecorator).decorate(this);
- this.getService(DefaultValuesDecorator).decorate(this);
- this.getService(DataTransformationDecorator).decorate(this);
- this.getService(DataValidationDecorator).decorate(this);
- this.getService(PropertyUniquenessDecorator).decorate(this);
- this.getService(FieldsFilteringDecorator).decorate(this);
- this.getService(InclusionDecorator).decorate(this);
- }
- }
- /**
- * Create.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- create(modelName, modelData, filter = void 0) {
- throw new NotImplementedError(
- "%s.create is not implemented.",
- this.constructor.name
- );
- }
- /**
- * Replace by id.
- *
- * @param {string} modelName
- * @param {number|string} id
- * @param {object} modelData
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- replaceById(modelName, id, modelData, filter = void 0) {
- throw new NotImplementedError(
- "%s.replaceById is not implemented.",
- this.constructor.name
- );
- }
- /**
- * Replace or create.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- replaceOrCreate(modelName, modelData, filter = void 0) {
- throw new NotImplementedError(
- "%s.replaceOrCreate is not implemented.",
- this.constructor.name
- );
- }
- /**
- * Patch.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {object|undefined} where
- * @returns {Promise<number>}
- */
- patch(modelName, modelData, where = void 0) {
- throw new NotImplementedError(
- "%s.patch is not implemented.",
- this.constructor.name
- );
- }
- /**
- * Patch by id.
- *
- * @param {string} modelName
- * @param {number|string} id
- * @param {object} modelData
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- patchById(modelName, id, modelData, filter = void 0) {
- throw new NotImplementedError(
- "%s.patchById is not implemented.",
- this.constructor.name
- );
- }
- /**
- * Find.
- *
- * @param {string} modelName
- * @param {object|undefined} filter
- * @returns {Promise<object[]>}
- */
- find(modelName, filter = void 0) {
- throw new NotImplementedError(
- "%s.find is not implemented.",
- this.constructor.name
- );
- }
- /**
- * Find by id.
- *
- * @param {string} modelName
- * @param {number|string} id
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- findById(modelName, id, filter = void 0) {
- throw new NotImplementedError(
- "%s.findById is not implemented.",
- this.constructor.name
- );
- }
- /**
- * Delete.
- *
- * @param {string} modelName
- * @param {object|undefined} where
- * @returns {Promise<number>}
- */
- delete(modelName, where = void 0) {
- throw new NotImplementedError(
- "%s.delete is not implemented.",
- this.constructor.name
- );
- }
- /**
- * Delete by id.
- *
- * @param {string} modelName
- * @param {number|string} id
- * @returns {Promise<boolean>}
- */
- deleteById(modelName, id) {
- throw new NotImplementedError(
- "%s.deleteById is not implemented.",
- this.constructor.name
- );
- }
- /**
- * Exists.
- *
- * @param {string} modelName
- * @param {number|string} id
- * @returns {Promise<boolean>}
- */
- exists(modelName, id) {
- throw new NotImplementedError(
- "%s.exists is not implemented.",
- this.constructor.name
- );
- }
- /**
- * Count.
- *
- * @param {string} modelName
- * @param {object|undefined} where
- * @returns {Promise<number>}
- */
- count(modelName, where = void 0) {
- throw new NotImplementedError(
- "%s.count is not implemented.",
- this.constructor.name
- );
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/builtin/memory-adapter.js
- var memory_adapter_exports = {};
- __export(memory_adapter_exports, {
- MemoryAdapter: () => MemoryAdapter
- });
- var MemoryAdapter;
- var init_memory_adapter = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/builtin/memory-adapter.js"() {
- init_adapter();
- init_utils2();
- init_utils2();
- init_definition();
- init_filter();
- init_filter();
- init_filter();
- init_errors2();
- init_definition();
- MemoryAdapter = class extends Adapter {
- /**
- * Tables.
- *
- * @type {Map<string, Map<number, Record<string, any>>>}
- */
- _tables = /* @__PURE__ */ new Map();
- /**
- * Last ids.
- *
- * @type {Map<string, number>}
- */
- _lastIds = /* @__PURE__ */ new Map();
- /**
- * Get table or create.
- *
- * @param {string} modelName
- * @returns {Map<number, object>}
- */
- _getTableOrCreate(modelName) {
- const tableName = this.getService(ModelDefinitionUtils).getTableNameByModelName(modelName);
- let table = this._tables.get(tableName);
- if (table) return table;
- table = /* @__PURE__ */ new Map();
- this._tables.set(tableName, table);
- return table;
- }
- /**
- * Gen next id value.
- *
- * @param {string} modelName
- * @param {string} propName
- * @returns {number}
- */
- _genNextIdValue(modelName, propName) {
- const propType = this.getService(
- ModelDefinitionUtils
- ).getDataTypeByPropertyName(modelName, propName);
- if (propType !== DataType.ANY && propType !== DataType.NUMBER)
- throw new InvalidArgumentError2(
- "The memory adapter able to generate only Number identifiers, but the primary key %v of the model %v is defined as %s. Do provide your own value for the %v property, or change the type in the primary key definition to a Number that will be generated automatically.",
- propName,
- modelName,
- capitalize(propType),
- propName
- );
- const tableName = this.getService(ModelDefinitionUtils).getTableNameByModelName(modelName);
- const lastId = this._lastIds.get(tableName) ?? 0;
- const nextId = lastId + 1;
- this._lastIds.set(tableName, nextId);
- const table = this._getTableOrCreate(modelName);
- const existedIds = Array.from(table.keys());
- if (existedIds.includes(nextId))
- return this._genNextIdValue(modelName, propName);
- return nextId;
- }
- /**
- * Create
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- // eslint-disable-next-line no-unused-vars
- async create(modelName, modelData, filter = void 0) {
- const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- modelName
- );
- let idValue = modelData[pkPropName];
- if (idValue == null || idValue === "" || idValue === 0) {
- idValue = this._genNextIdValue(modelName, pkPropName);
- }
- const table = this._getTableOrCreate(modelName);
- if (table.has(idValue))
- throw new InvalidArgumentError2(
- "The value %v of the primary key %v already exists in the model %v.",
- idValue,
- pkPropName,
- modelName
- );
- modelData = cloneDeep(modelData);
- modelData[pkPropName] = idValue;
- const tableData = this.getService(
- ModelDefinitionUtils
- ).convertPropertyNamesToColumnNames(modelName, modelData);
- table.set(idValue, tableData);
- return this.getService(
- ModelDefinitionUtils
- ).convertColumnNamesToPropertyNames(modelName, tableData);
- }
- /**
- * Replace by id.
- *
- * @param {string} modelName
- * @param {string|number} id
- * @param {object} modelData
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- // eslint-disable-next-line no-unused-vars
- async replaceById(modelName, id, modelData, filter = void 0) {
- const table = this._getTableOrCreate(modelName);
- const isExists = table.has(id);
- const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- modelName
- );
- if (!isExists)
- throw new InvalidArgumentError2(
- "The value %v of the primary key %v does not exist in the model %v.",
- id,
- pkPropName,
- modelName
- );
- modelData = cloneDeep(modelData);
- modelData[pkPropName] = id;
- const tableData = this.getService(
- ModelDefinitionUtils
- ).convertPropertyNamesToColumnNames(modelName, modelData);
- table.set(id, tableData);
- return this.getService(
- ModelDefinitionUtils
- ).convertColumnNamesToPropertyNames(modelName, tableData);
- }
- /**
- * Replace or create.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- async replaceOrCreate(modelName, modelData, filter = void 0) {
- const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- modelName
- );
- let idValue = modelData[pkPropName];
- if (idValue == null || idValue === "" || idValue === 0) {
- idValue = this._genNextIdValue(modelName, pkPropName);
- }
- const table = this._getTableOrCreate(modelName);
- modelData = cloneDeep(modelData);
- modelData[pkPropName] = idValue;
- const tableData = this.getService(
- ModelDefinitionUtils
- ).convertPropertyNamesToColumnNames(modelName, modelData);
- table.set(idValue, tableData);
- return this.getService(
- ModelDefinitionUtils
- ).convertColumnNamesToPropertyNames(modelName, tableData);
- }
- /**
- * Patch.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {object|undefined} where
- * @returns {Promise<number>}
- */
- async patch(modelName, modelData, where = void 0) {
- const table = this._getTableOrCreate(modelName);
- const tableItems = Array.from(table.values());
- if (!tableItems.length) return 0;
- let modelItems = tableItems.map(
- (tableItem) => this.getService(ModelDefinitionUtils).convertColumnNamesToPropertyNames(
- modelName,
- tableItem
- )
- );
- if (where && typeof where === "object")
- modelItems = this.getService(WhereClauseTool).filter(modelItems, where);
- const size = modelItems.length;
- const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- modelName
- );
- modelData = cloneDeep(modelData);
- delete modelData[pkPropName];
- modelItems.forEach((existingModelData) => {
- const mergedModelData = Object.assign({}, existingModelData, modelData);
- const mergedTableData = this.getService(
- ModelDefinitionUtils
- ).convertPropertyNamesToColumnNames(modelName, mergedModelData);
- const idValue = existingModelData[pkPropName];
- table.set(idValue, mergedTableData);
- });
- return size;
- }
- /**
- * Patch by id.
- *
- * @param {string} modelName
- * @param {string|number} id
- * @param {object} modelData
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- // eslint-disable-next-line no-unused-vars
- async patchById(modelName, id, modelData, filter = void 0) {
- const table = this._getTableOrCreate(modelName);
- const existingTableData = table.get(id);
- const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- modelName
- );
- if (existingTableData == null)
- throw new InvalidArgumentError2(
- "The value %v of the primary key %v does not exist in the model %v.",
- id,
- pkPropName,
- modelName
- );
- modelData = cloneDeep(modelData);
- delete modelData[pkPropName];
- const existingModelData = this.getService(
- ModelDefinitionUtils
- ).convertColumnNamesToPropertyNames(modelName, existingTableData);
- const mergedModelData = Object.assign({}, existingModelData, modelData);
- const mergedTableData = this.getService(
- ModelDefinitionUtils
- ).convertPropertyNamesToColumnNames(modelName, mergedModelData);
- table.set(id, mergedTableData);
- return this.getService(
- ModelDefinitionUtils
- ).convertColumnNamesToPropertyNames(modelName, mergedTableData);
- }
- /**
- * Find.
- *
- * @param {string} modelName
- * @param {object|undefined} filter
- * @returns {Promise<object[]>}
- */
- async find(modelName, filter = void 0) {
- const table = this._getTableOrCreate(modelName);
- const tableItems = Array.from(table.values());
- let modelItems = tableItems.map(
- (tableItem) => this.getService(ModelDefinitionUtils).convertColumnNamesToPropertyNames(
- modelName,
- tableItem
- )
- );
- if (filter && typeof filter === "object") {
- if (filter.where)
- modelItems = this.getService(WhereClauseTool).filter(
- modelItems,
- filter.where
- );
- if (filter.skip || filter.limit)
- modelItems = this.getService(SliceClauseTool).slice(
- modelItems,
- filter.skip,
- filter.limit
- );
- if (filter.order)
- this.getService(OrderClauseTool).sort(modelItems, filter.order);
- }
- return modelItems;
- }
- /**
- * Find by id.
- *
- * @param {string} modelName
- * @param {string|number} id
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- // eslint-disable-next-line no-unused-vars
- async findById(modelName, id, filter = void 0) {
- const table = this._getTableOrCreate(modelName);
- const tableData = table.get(id);
- const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- modelName
- );
- if (!tableData)
- throw new InvalidArgumentError2(
- "The value %v of the primary key %v does not exist in the model %v.",
- id,
- pkPropName,
- modelName
- );
- return this.getService(
- ModelDefinitionUtils
- ).convertColumnNamesToPropertyNames(modelName, tableData);
- }
- /**
- * Delete.
- *
- * @param {string} modelName
- * @param {object|undefined} where
- * @returns {Promise<number>}
- */
- async delete(modelName, where = void 0) {
- const table = this._getTableOrCreate(modelName);
- const tableItems = Array.from(table.values());
- if (!tableItems.length) return 0;
- let modelItems = tableItems.map(
- (tableItem) => this.getService(ModelDefinitionUtils).convertColumnNamesToPropertyNames(
- modelName,
- tableItem
- )
- );
- if (where && typeof where === "object")
- modelItems = this.getService(WhereClauseTool).filter(modelItems, where);
- const size = modelItems.length;
- const idPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- modelName
- );
- modelItems.forEach((modelData) => {
- const idValue = modelData[idPropName];
- table.delete(idValue);
- });
- return size;
- }
- /**
- * Delete by id.
- *
- * @param {string} modelName
- * @param {string|number} id
- * @returns {Promise<boolean>}
- */
- async deleteById(modelName, id) {
- const table = this._getTableOrCreate(modelName);
- const isExists = table.has(id);
- table.delete(id);
- return isExists;
- }
- /**
- * Exists.
- *
- * @param {string} modelName
- * @param {string|number} id
- * @returns {Promise<boolean>}
- */
- async exists(modelName, id) {
- const table = this._getTableOrCreate(modelName);
- return table.has(id);
- }
- /**
- * Count.
- *
- * @param {string} modelName
- * @param {object|undefined} where
- * @returns {Promise<number>}
- */
- async count(modelName, where = void 0) {
- const table = this._getTableOrCreate(modelName);
- const tableItems = Array.from(table.values());
- let modelItems = tableItems.map(
- (tableItem) => this.getService(ModelDefinitionUtils).convertColumnNamesToPropertyNames(
- modelName,
- tableItem
- )
- );
- if (where && typeof where === "object")
- modelItems = this.getService(WhereClauseTool).filter(modelItems, where);
- return modelItems.length;
- }
- };
- }
- });
- // import("./builtin/**/*-adapter.js") in node_modules/@e22m4u/js-repository/src/adapter/adapter-loader.js
- var globImport_builtin_adapter_js;
- var init_ = __esm({
- 'import("./builtin/**/*-adapter.js") in node_modules/@e22m4u/js-repository/src/adapter/adapter-loader.js'() {
- globImport_builtin_adapter_js = __glob({
- "./builtin/memory-adapter.js": () => Promise.resolve().then(() => (init_memory_adapter(), memory_adapter_exports))
- });
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/adapter-loader.js
- function findAdapterCtorInModule(module2) {
- let adapterCtor;
- if (!module2 || typeof module2 !== "object" || Array.isArray(module2)) return;
- for (const ctor of Object.values(module2)) {
- if (typeof ctor === "function" && ctor.prototype instanceof Adapter) {
- adapterCtor = ctor;
- break;
- }
- }
- return adapterCtor;
- }
- var AdapterLoader;
- var init_adapter_loader = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/adapter-loader.js"() {
- init_adapter();
- init_src2();
- init_errors2();
- init_();
- AdapterLoader = class extends Service {
- /**
- * Load by name.
- *
- * @param {string} adapterName
- * @param {object|undefined} settings
- * @returns {Promise<Adapter>}
- */
- async loadByName(adapterName, settings = void 0) {
- if (!adapterName || typeof adapterName !== "string")
- throw new InvalidArgumentError2(
- "The adapter name should be a non-empty String, but %v given.",
- adapterName
- );
- let adapterCtor;
- try {
- const module2 = await globImport_builtin_adapter_js(`./builtin/${adapterName}-adapter.js`);
- adapterCtor = findAdapterCtorInModule(module2);
- } catch (e) {
- }
- if (!adapterCtor)
- try {
- const module2 = await import(`@e22m4u/js-repository-${adapterName}-adapter`);
- adapterCtor = findAdapterCtorInModule(module2);
- } catch (e) {
- }
- if (!adapterCtor)
- throw new InvalidArgumentError2(
- "The adapter %v is not found.",
- adapterName
- );
- return new adapterCtor(this.container, settings);
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/adapter-registry.js
- var AdapterRegistry;
- var init_adapter_registry = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/adapter-registry.js"() {
- init_adapter();
- init_src2();
- init_adapter_loader();
- init_definition();
- AdapterRegistry = class extends Service {
- /**
- * Adapters.
- *
- * @type {object}
- */
- _adapters = {};
- /**
- * Get adapter.
- *
- * @param {string} datasourceName
- * @returns {Promise<Adapter>}
- */
- async getAdapter(datasourceName) {
- let adapter = this._adapters[datasourceName];
- if (adapter) return adapter;
- const datasource = this.getService(DefinitionRegistry).getDatasource(datasourceName);
- const adapterName = datasource.adapter;
- adapter = await this.getService(AdapterLoader).loadByName(
- adapterName,
- datasource
- );
- this._adapters[datasourceName] = adapter;
- return adapter;
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/adapter/index.js
- var init_adapter2 = __esm({
- "node_modules/@e22m4u/js-repository/src/adapter/index.js"() {
- init_adapter();
- init_adapter_loader();
- init_adapter_registry();
- }
- });
- // node_modules/@e22m4u/js-repository/src/repository/repository.js
- var Repository;
- var init_repository = __esm({
- "node_modules/@e22m4u/js-repository/src/repository/repository.js"() {
- init_src2();
- init_adapter2();
- init_adapter2();
- init_errors2();
- init_definition();
- Repository = class extends Service {
- /**
- * Model name.
- *
- * @type {string}
- */
- _modelName;
- /**
- * Model name.
- *
- * @returns {string}
- */
- get modelName() {
- return this._modelName;
- }
- /**
- * Datasource name.
- *
- * @type {string}
- */
- _datasourceName;
- /**
- * Datasource name.
- *
- * @returns {string}
- */
- get datasourceName() {
- return this._datasourceName;
- }
- /**
- * Constructor.
- *
- * @typedef {import('@e22m4u/js-service').ServiceContainer} ServiceContainer
- * @param {ServiceContainer} container
- * @param {string} modelName
- */
- constructor(container, modelName) {
- super(container);
- this._modelName = modelName;
- const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
- const datasourceName = modelDef.datasource;
- if (!datasourceName)
- throw new InvalidArgumentError2(
- "The model %v does not have a specified datasource.",
- modelName
- );
- this._datasourceName = datasourceName;
- }
- /**
- * Get adapter.
- *
- * @returns {Adapter}
- */
- async getAdapter() {
- return this.getService(AdapterRegistry).getAdapter(this.datasourceName);
- }
- /**
- * Create.
- *
- * @param {object} data
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- async create(data, filter = void 0) {
- const adapter = await this.getAdapter();
- return adapter.create(this.modelName, data, filter);
- }
- /**
- * Replace by id.
- *
- * @param {number|string} id
- * @param {object} data
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- async replaceById(id, data, filter = void 0) {
- const adapter = await this.getAdapter();
- return adapter.replaceById(this.modelName, id, data, filter);
- }
- /**
- * Replace or create.
- *
- * @param {object} data
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- async replaceOrCreate(data, filter = void 0) {
- const adapter = await this.getAdapter();
- return adapter.replaceOrCreate(this.modelName, data, filter);
- }
- /**
- * Patch.
- *
- * @param {object} data
- * @param {object|undefined} where
- * @returns {Promise<number>}
- */
- async patch(data, where = void 0) {
- const adapter = await this.getAdapter();
- return adapter.patch(this.modelName, data, where);
- }
- /**
- * Patch by id.
- *
- * @param {number|string} id
- * @param {object} data
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- async patchById(id, data, filter = void 0) {
- const adapter = await this.getAdapter();
- return adapter.patchById(this.modelName, id, data, filter);
- }
- /**
- * Find.
- *
- * @param {object|undefined} filter
- * @returns {Promise<object[]>}
- */
- async find(filter = void 0) {
- const adapter = await this.getAdapter();
- return adapter.find(this.modelName, filter);
- }
- /**
- * Find one.
- *
- * @param {object|undefined} filter
- * @returns {Promise<object|undefined>}
- */
- async findOne(filter = void 0) {
- const adapter = await this.getAdapter();
- filter = filter ?? {};
- filter.limit = 1;
- const result = await adapter.find(this.modelName, filter);
- return result.length ? result[0] : void 0;
- }
- /**
- * Find by id.
- *
- * @param {number|string} id
- * @param {object|undefined} filter
- * @returns {Promise<object>}
- */
- async findById(id, filter = void 0) {
- const adapter = await this.getAdapter();
- return adapter.findById(this.modelName, id, filter);
- }
- /**
- * Delete.
- *
- * @param {object|undefined} where
- * @returns {Promise<number>}
- */
- async delete(where = void 0) {
- const adapter = await this.getAdapter();
- return adapter.delete(this.modelName, where);
- }
- /**
- * Delete by id.
- *
- * @param {number|string} id
- * @returns {Promise<boolean>}
- */
- async deleteById(id) {
- const adapter = await this.getAdapter();
- return adapter.deleteById(this.modelName, id);
- }
- /**
- * Exists.
- *
- * @param {number|string} id
- * @returns {Promise<boolean>}
- */
- async exists(id) {
- const adapter = await this.getAdapter();
- return adapter.exists(this.modelName, id);
- }
- /**
- * Count.
- *
- * @param {object|undefined} where
- * @returns {Promise<number>}
- */
- async count(where = void 0) {
- const adapter = await this.getAdapter();
- return adapter.count(this.modelName, where);
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/repository/repository-registry.js
- var RepositoryRegistry;
- var init_repository_registry = __esm({
- "node_modules/@e22m4u/js-repository/src/repository/repository-registry.js"() {
- init_src2();
- init_repository();
- init_errors2();
- RepositoryRegistry = class extends Service {
- /**
- * Repositories.
- *
- * @type {object}
- */
- _repositories = {};
- /**
- * Repository ctor.
- *
- * @type {typeof Repository}
- * @private
- */
- _repositoryCtor = Repository;
- /**
- * Set repository ctor.
- *
- * @param {typeof Repository} ctor
- */
- setRepositoryCtor(ctor) {
- if (!ctor || typeof ctor !== "function" || !(ctor.prototype instanceof Repository)) {
- throw new InvalidArgumentError2(
- "The first argument of RepositoryRegistry.setRepositoryCtor must inherit from Repository class, but %v given.",
- ctor
- );
- }
- this._repositoryCtor = ctor;
- }
- /**
- * Get repository.
- *
- * @param {string} modelName
- * @returns {Repository}
- */
- getRepository(modelName) {
- let repository = this._repositories[modelName];
- if (repository) return repository;
- repository = new this._repositoryCtor(this.container, modelName);
- this._repositories[modelName] = repository;
- return repository;
- }
- };
- }
- });
- // node_modules/@e22m4u/js-repository/src/repository/index.js
- var init_repository2 = __esm({
- "node_modules/@e22m4u/js-repository/src/repository/index.js"() {
- init_repository();
- init_repository_registry();
- }
- });
- // src/index.js
- var src_exports = {};
- __export(src_exports, {
- MongodbAdapter: () => MongodbAdapter
- });
- module.exports = __toCommonJS(src_exports);
- // src/mongodb-adapter.js
- var import_mongodb2 = __toESM(require_lib3(), 1);
- var import_mongodb3 = __toESM(require_lib3(), 1);
- // src/utils/is-iso-date.js
- function isIsoDate(value) {
- if (!value) return false;
- if (value instanceof Date) return true;
- if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(value)) return false;
- const d = new Date(value);
- return d instanceof Date && !isNaN(d.getTime()) && d.toISOString() === value;
- }
- // src/utils/is-object-id.js
- var import_mongodb = __toESM(require_lib3(), 1);
- function isObjectId(value) {
- if (!value) return false;
- if (value instanceof import_mongodb.ObjectId) return true;
- if (typeof value !== "string") return false;
- return value.match(/^[a-fA-F0-9]{24}$/) != null;
- }
- // node_modules/@e22m4u/js-repository/src/schema.js
- init_src2();
- init_repository2();
- init_definition();
- init_repository2();
- // node_modules/@e22m4u/js-repository/src/index.js
- init_utils2();
- init_errors2();
- init_filter();
- init_adapter2();
- init_relations2();
- init_definition();
- init_repository2();
- // src/utils/create-mongodb-url.js
- function createMongodbUrl(options = {}) {
- if (!options || typeof options !== "object" || Array.isArray(options))
- throw new InvalidArgumentError2(
- 'The first argument of "createMongodbUrl" must be an Object, but %v given.',
- options
- );
- if (options.protocol && typeof options.protocol !== "string")
- throw new InvalidArgumentError2(
- 'MongoDB option "protocol" must be a String, but %v given.',
- options.protocol
- );
- if (options.hostname && typeof options.hostname !== "string")
- throw new InvalidArgumentError2(
- 'MongoDB option "hostname" must be a String, but %v given.',
- options.hostname
- );
- if (options.host && typeof options.host !== "string")
- throw new InvalidArgumentError2(
- 'MongoDB option "host" must be a String, but %v given.',
- options.host
- );
- if (options.port && typeof options.port !== "number" && typeof options.port !== "string") {
- throw new InvalidArgumentError2(
- 'MongoDB option "port" must be a Number or a String, but %v given.',
- options.port
- );
- }
- if (options.database && typeof options.database !== "string")
- throw new InvalidArgumentError2(
- 'MongoDB option "database" must be a String, but %v given.',
- options.database
- );
- if (options.db && typeof options.db !== "string")
- throw new InvalidArgumentError2(
- 'MongoDB option "db" must be a String, but %v given.',
- options.db
- );
- if (options.username && typeof options.username !== "string")
- throw new InvalidArgumentError2(
- 'MongoDB option "username" must be a String, but %v given.',
- options.username
- );
- if (options.password && typeof options.password !== "string" && typeof options.password !== "number") {
- throw new InvalidArgumentError2(
- 'MongoDB option "password" must be a String or a Number, but %v given.',
- options.password
- );
- }
- if (options.pass && typeof options.pass !== "string" && typeof options.pass !== "number") {
- throw new InvalidArgumentError2(
- 'MongoDB option "pass" must be a String or a Number, but %v given.',
- options.pass
- );
- }
- const protocol = options.protocol || "mongodb";
- const hostname = options.hostname || options.host || "127.0.0.1";
- const port = options.port || 27017;
- const database = options.database || options.db || "database";
- const username = options.username || options.user;
- const password = options.password || options.pass || void 0;
- let portUrl = "";
- if (protocol !== "mongodb+srv") {
- portUrl = ":" + port;
- }
- if (username && password) {
- return `${protocol}://${username}:${password}@${hostname}${portUrl}/${database}`;
- } else {
- return `${protocol}://${hostname}${portUrl}/${database}`;
- }
- }
- // src/utils/transform-values-deep.js
- function transformValuesDeep(value, transformer) {
- if (!transformer || typeof transformer !== "function")
- throw new InvalidArgumentError2(
- 'The second argument of "transformValuesDeep" must be a Function, but %v given.',
- transformer
- );
- if (Array.isArray(value)) {
- value.forEach((v, i) => value[i] = transformValuesDeep(v, transformer));
- return value;
- } else if (value && typeof value === "object") {
- if (!value.constructor || value.constructor && value.constructor.name === "Object") {
- Object.keys(value).forEach((key) => {
- if (Object.prototype.hasOwnProperty.call(value, key))
- value[key] = transformValuesDeep(value[key], transformer);
- });
- return value;
- } else {
- return transformer(value);
- }
- } else {
- return transformer(value);
- }
- }
- // src/mongodb-adapter.js
- var MONGODB_OPTION_NAMES = [
- "appname",
- "authMechanism",
- "authMechanismProperties",
- "authSource",
- "compressors",
- "connectTimeoutMS",
- "directConnection",
- "heartbeatFrequencyMS",
- "journal",
- "loadBalanced",
- "localThresholdMS",
- "maxIdleTimeMS",
- "maxPoolSize",
- "maxConnecting",
- "maxStalenessSeconds",
- "minPoolSize",
- "proxyHost",
- "proxyPort",
- "proxyUsername",
- "proxyPassword",
- "readConcernLevel",
- "readPreference",
- "readPreferenceTags",
- "replicaSet",
- "retryReads",
- "retryWrites",
- "serverSelectionTimeoutMS",
- "serverSelectionTryOnce",
- "socketTimeoutMS",
- "srvMaxHosts",
- "srvServiceName",
- "ssl",
- "timeoutMS",
- "tls",
- "tlsAllowInvalidCertificates",
- "tlsAllowInvalidHostnames",
- "tlsCAFile",
- "tlsCertificateKeyFile",
- "tlsCertificateKeyFilePassword",
- "tlsInsecure",
- "w",
- "waitQueueTimeoutMS",
- "wTimeoutMS",
- "zlibCompressionLevel"
- ];
- var DEFAULT_SETTINGS = {
- // connectTimeoutMS: 2500,
- // serverSelectionTimeoutMS: 2500,
- };
- var MongodbAdapter = class extends Adapter {
- /**
- * Mongodb instance.
- *
- * @type {MongoClient}
- * @private
- */
- _client;
- /**
- * Client.
- *
- * @returns {MongoClient}
- */
- get client() {
- return this._client;
- }
- /**
- * Collections.
- *
- * @type {Map<any, any>}
- * @private
- */
- _collections = /* @__PURE__ */ new Map();
- /**
- * Constructor.
- *
- * @param {ServiceContainer} container
- * @param settings
- */
- constructor(container, settings) {
- settings = Object.assign({}, DEFAULT_SETTINGS, settings || {});
- settings.protocol = settings.protocol || "mongodb";
- settings.hostname = settings.hostname || settings.host || "127.0.0.1";
- settings.port = settings.port || 27017;
- settings.database = settings.database || settings.db || "database";
- super(container, settings);
- const options = selectObjectKeys(this.settings, MONGODB_OPTION_NAMES);
- const url = createMongodbUrl(this.settings);
- this._client = new import_mongodb3.MongoClient(url, options);
- }
- /**
- * Get id prop name.
- *
- * @param modelName
- */
- _getIdPropName(modelName) {
- return this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
- modelName
- );
- }
- /**
- * Get id col name.
- *
- * @param modelName
- */
- _getIdColName(modelName) {
- return this.getService(ModelDefinitionUtils).getPrimaryKeyAsColumnName(
- modelName
- );
- }
- /**
- * Coerce id.
- *
- * @param value
- * @return {ObjectId|*}
- * @private
- */
- _coerceId(value) {
- if (value == null) return value;
- if (isObjectId(value)) return new import_mongodb2.ObjectId(value);
- return value;
- }
- /**
- * Coerce date.
- *
- * @param value
- * @returns {Date|*}
- * @private
- */
- _coerceDate(value) {
- if (value == null) return value;
- if (value instanceof Date) return value;
- if (isIsoDate(value)) return new Date(value);
- return value;
- }
- /**
- * To database.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @return {object}
- * @private
- */
- _toDatabase(modelName, modelData) {
- const tableData = this.getService(
- ModelDefinitionUtils
- ).convertPropertyNamesToColumnNames(modelName, modelData);
- const idColName = this._getIdColName(modelName);
- if (idColName !== "id" && idColName !== "_id")
- throw new InvalidArgumentError2(
- 'MongoDB is not supporting custom names of the primary key. Do use "id" as a primary key instead of %v.',
- idColName
- );
- if (idColName in tableData && idColName !== "_id") {
- tableData._id = tableData[idColName];
- delete tableData[idColName];
- }
- return transformValuesDeep(tableData, (value) => {
- if (value instanceof import_mongodb2.ObjectId) return value;
- if (value instanceof Date) return value;
- if (isObjectId(value)) return new import_mongodb2.ObjectId(value);
- if (isIsoDate(value)) return new Date(value);
- return value;
- });
- }
- /**
- * From database.
- *
- * @param {string} modelName
- * @param {object} tableData
- * @return {object}
- * @private
- */
- _fromDatabase(modelName, tableData) {
- if ("_id" in tableData) {
- const idColName = this._getIdColName(modelName);
- if (idColName !== "id" && idColName !== "_id")
- throw new InvalidArgumentError2(
- 'MongoDB is not supporting custom names of the primary key. Do use "id" as a primary key instead of %v.',
- idColName
- );
- if (idColName !== "_id") {
- tableData[idColName] = tableData._id;
- delete tableData._id;
- }
- }
- const modelData = this.getService(
- ModelDefinitionUtils
- ).convertColumnNamesToPropertyNames(modelName, tableData);
- return transformValuesDeep(modelData, (value) => {
- if (value instanceof import_mongodb2.ObjectId) return String(value);
- if (value instanceof Date) return value.toISOString();
- return value;
- });
- }
- /**
- * Get collection.
- *
- * @param {string} modelName
- * @return {*}
- * @private
- */
- _getCollection(modelName) {
- let collection = this._collections.get(modelName);
- if (collection) return collection;
- const tableName = this.getService(ModelDefinitionUtils).getTableNameByModelName(modelName);
- collection = this.client.db(this.settings.database).collection(tableName);
- this._collections.set(modelName, collection);
- return collection;
- }
- /**
- * Get id type.
- *
- * @param modelName
- * @return {string|*}
- * @private
- */
- _getIdType(modelName) {
- const utils = this.getService(ModelDefinitionUtils);
- const pkPropName = utils.getPrimaryKeyAsPropertyName(modelName);
- return utils.getDataTypeByPropertyName(modelName, pkPropName);
- }
- /**
- * Build projection.
- *
- * @param {string} modelName
- * @param {string|string[]} fields
- * @return {Record<string, number>|undefined}
- * @private
- */
- _buildProjection(modelName, fields) {
- if (fields == null) return;
- if (Array.isArray(fields) === false) fields = [fields];
- if (!fields.length) return;
- if (fields.indexOf("_id") === -1) fields.push("_id");
- return fields.reduce((acc, field) => {
- if (!field || typeof field !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v given.',
- field
- );
- let colName = this._getColName(modelName, field);
- acc[colName] = 1;
- return acc;
- }, {});
- }
- /**
- * Get col name.
- *
- * @param {string} modelName
- * @param {string} propName
- * @return {string}
- * @private
- */
- _getColName(modelName, propName) {
- if (!propName || typeof propName !== "string")
- throw new InvalidArgumentError2(
- "A property name must be a non-empty String, but %v given.",
- propName
- );
- const utils = this.getService(ModelDefinitionUtils);
- let colName = propName;
- try {
- colName = utils.getColumnNameByPropertyName(modelName, propName);
- } catch (error) {
- if (!(error instanceof InvalidArgumentError2) || error.message.indexOf("does not have the property") === -1) {
- throw error;
- }
- }
- return colName;
- }
- /**
- * Build sort.
- *
- * @param {string} modelName
- * @param {string|string[]} clause
- * @return {object|undefined}
- * @private
- */
- _buildSort(modelName, clause) {
- if (clause == null) return;
- if (Array.isArray(clause) === false) clause = [clause];
- if (!clause.length) return;
- const utils = this.getService(ModelDefinitionUtils);
- const idPropName = this._getIdPropName(modelName);
- return clause.reduce((acc, order) => {
- if (!order || typeof order !== "string")
- throw new InvalidArgumentError2(
- 'The provided option "order" should be a non-empty String or an Array of non-empty String, but %v given.',
- order
- );
- const direction = order.match(/\s+(A|DE)SC$/);
- let field = order.replace(/\s+(A|DE)SC$/, "").trim();
- if (field === idPropName) {
- field = "_id";
- } else {
- try {
- field = utils.getColumnNameByPropertyName(modelName, field);
- } catch (error) {
- if (!(error instanceof InvalidArgumentError2) || error.message.indexOf("does not have the property") === -1) {
- throw error;
- }
- }
- }
- acc[field] = direction && direction[1] === "DE" ? -1 : 1;
- return acc;
- }, {});
- }
- /**
- * Build query.
- *
- * @param {string} modelName
- * @param {object} clause
- * @return {object}
- * @private
- */
- _buildQuery(modelName, clause) {
- if (clause == null) return;
- if (typeof clause !== "object" || Array.isArray(clause))
- throw new InvalidArgumentError2(
- 'The provided option "where" should be an Object, but %v given.',
- clause
- );
- const query = {};
- const idPropName = this._getIdPropName(modelName);
- Object.keys(clause).forEach((key) => {
- if (String(key).indexOf("$") !== -1)
- throw new InvalidArgumentError2(
- 'The symbol "$" is not supported, but %v given.',
- key
- );
- let cond = clause[key];
- if (key === "and" || key === "or" || key === "nor") {
- if (cond == null) return;
- if (!Array.isArray(cond))
- throw new InvalidOperatorValueError(key, "an Array", cond);
- if (cond.length === 0) return;
- cond = cond.map((c) => this._buildQuery(modelName, c));
- cond = cond.filter((c) => c != null);
- const opKey = "$" + key;
- query[opKey] = query[opKey] ?? [];
- query[opKey] = [...query[opKey], ...cond];
- return;
- }
- if (key === idPropName) {
- key = "_id";
- } else {
- key = this._getColName(modelName, key);
- }
- if (typeof cond === "string") {
- query[key] = this._coerceId(cond);
- query[key] = this._coerceDate(query[key]);
- return;
- }
- if (cond instanceof import_mongodb2.ObjectId) {
- query[key] = cond;
- return;
- }
- if (cond && cond.constructor && cond.constructor.name === "Object") {
- const opConds = [];
- if ("eq" in cond) {
- let eq = this._coerceId(cond.eq);
- eq = this._coerceDate(eq);
- opConds.push({ $eq: eq });
- }
- if ("neq" in cond) {
- let neq = this._coerceId(cond.neq);
- neq = this._coerceDate(neq);
- opConds.push({ $ne: neq });
- }
- if ("gt" in cond) {
- const gt = this._coerceDate(cond.gt);
- opConds.push({ $gt: gt });
- }
- if ("lt" in cond) {
- const lt = this._coerceDate(cond.lt);
- opConds.push({ $lt: lt });
- }
- if ("gte" in cond) {
- const gte = this._coerceDate(cond.gte);
- opConds.push({ $gte: gte });
- }
- if ("lte" in cond) {
- const lte = this._coerceDate(cond.lte);
- opConds.push({ $lte: lte });
- }
- if ("inq" in cond) {
- if (!cond.inq || !Array.isArray(cond.inq))
- throw new InvalidOperatorValueError(
- "inq",
- "an Array of possible values",
- cond.inq
- );
- const inq = cond.inq.map((v) => {
- v = this._coerceId(v);
- v = this._coerceDate(v);
- return v;
- });
- opConds.push({ $in: inq });
- }
- if ("nin" in cond) {
- if (!cond.nin || !Array.isArray(cond.nin))
- throw new InvalidOperatorValueError(
- "nin",
- "an Array of possible values",
- cond
- );
- const nin = cond.nin.map((v) => {
- v = this._coerceId(v);
- v = this._coerceDate(v);
- return v;
- });
- opConds.push({ $nin: nin });
- }
- if ("between" in cond) {
- if (!Array.isArray(cond.between) || cond.between.length !== 2)
- throw new InvalidOperatorValueError(
- "between",
- "an Array of 2 elements",
- cond.between
- );
- const gte = this._coerceDate(cond.between[0]);
- const lte = this._coerceDate(cond.between[1]);
- opConds.push({ $gte: gte, $lte: lte });
- }
- if ("exists" in cond) {
- if (typeof cond.exists !== "boolean")
- throw new InvalidOperatorValueError(
- "exists",
- "a Boolean",
- cond.exists
- );
- opConds.push({ $exists: cond.exists });
- }
- if ("like" in cond) {
- if (typeof cond.like !== "string" && !(cond.like instanceof RegExp))
- throw new InvalidOperatorValueError(
- "like",
- "a String or RegExp",
- cond.like
- );
- opConds.push({ $regex: stringToRegexp(cond.like) });
- }
- if ("nlike" in cond) {
- if (typeof cond.nlike !== "string" && !(cond.nlike instanceof RegExp))
- throw new InvalidOperatorValueError(
- "nlike",
- "a String or RegExp",
- cond.nlike
- );
- opConds.push({ $not: stringToRegexp(cond.nlike) });
- }
- if ("ilike" in cond) {
- if (typeof cond.ilike !== "string" && !(cond.ilike instanceof RegExp))
- throw new InvalidOperatorValueError(
- "ilike",
- "a String or RegExp",
- cond.ilike
- );
- opConds.push({ $regex: stringToRegexp(cond.ilike, "i") });
- }
- if ("nilike" in cond) {
- if (typeof cond.nilike !== "string" && !(cond.nilike instanceof RegExp)) {
- throw new InvalidOperatorValueError(
- "nilike",
- "a String or RegExp",
- cond.nilike
- );
- }
- opConds.push({ $not: stringToRegexp(cond.nilike, "i") });
- }
- if ("regexp" in cond) {
- if (typeof cond.regexp !== "string" && !(cond.regexp instanceof RegExp)) {
- throw new InvalidOperatorValueError(
- "regexp",
- "a String or RegExp",
- cond.regexp
- );
- }
- const flags = cond.flags || void 0;
- if (flags && typeof flags !== "string")
- throw new InvalidArgumentError2(
- "RegExp flags must be a String, but %v given.",
- cond.flags
- );
- opConds.push({ $regex: stringToRegexp(cond.regexp, flags) });
- }
- if (opConds.length === 1) {
- query[key] = opConds[0];
- } else if (opConds.length > 1) {
- query["$and"] = query["$and"] ?? [];
- opConds.forEach((c) => query["$and"].push({ [key]: c }));
- }
- return;
- }
- query[key] = cond;
- });
- return Object.keys(query).length ? query : void 0;
- }
- /**
- * Create.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {object|undefined} filter
- * @return {Promise<object>}
- */
- async create(modelName, modelData, filter = void 0) {
- const idPropName = this._getIdPropName(modelName);
- const idValue = modelData[idPropName];
- if (idValue == null || idValue === "" || idValue === 0) {
- const pkType = this._getIdType(modelName);
- if (pkType !== DataType.STRING && pkType !== DataType.ANY)
- throw new InvalidArgumentError2(
- "MongoDB unable to generate primary keys of %s. Do provide your own value for the %v property or set property type to String.",
- capitalize(pkType),
- idPropName
- );
- delete modelData[idPropName];
- }
- const tableData = this._toDatabase(modelName, modelData);
- const table = this._getCollection(modelName);
- const { insertedId } = await table.insertOne(tableData);
- const projection = this._buildProjection(
- modelName,
- filter && filter.fields
- );
- const insertedData = await table.findOne({ _id: insertedId }, { projection });
- return this._fromDatabase(modelName, insertedData);
- }
- /**
- * Replace by id.
- *
- * @param {string} modelName
- * @param {string|number} id
- * @param {object} modelData
- * @param {object|undefined} filter
- * @return {Promise<object>}
- */
- async replaceById(modelName, id, modelData, filter = void 0) {
- id = this._coerceId(id);
- const idPropName = this._getIdPropName(modelName);
- modelData[idPropName] = id;
- const tableData = this._toDatabase(modelName, modelData);
- const table = this._getCollection(modelName);
- const { matchedCount } = await table.replaceOne({ _id: id }, tableData);
- if (matchedCount < 1)
- throw new InvalidArgumentError2("Identifier %v is not found.", String(id));
- const projection = this._buildProjection(
- modelName,
- filter && filter.fields
- );
- const replacedData = await table.findOne({ _id: id }, { projection });
- return this._fromDatabase(modelName, replacedData);
- }
- /**
- * Replace or create.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {object|undefined} filter
- * @return {Promise<object>}
- */
- async replaceOrCreate(modelName, modelData, filter = void 0) {
- const idPropName = this._getIdPropName(modelName);
- let idValue = modelData[idPropName];
- idValue = this._coerceId(idValue);
- if (idValue == null || idValue === "" || idValue === 0) {
- const pkType = this._getIdType(modelName);
- if (pkType !== DataType.STRING && pkType !== DataType.ANY)
- throw new InvalidArgumentError2(
- "MongoDB unable to generate primary keys of %s. Do provide your own value for the %v property or set property type to String.",
- capitalize(pkType),
- idPropName
- );
- delete modelData[idPropName];
- idValue = void 0;
- }
- const tableData = this._toDatabase(modelName, modelData);
- const table = this._getCollection(modelName);
- if (idValue == null) {
- const { insertedId } = await table.insertOne(tableData);
- idValue = insertedId;
- } else {
- const { upsertedId } = await table.replaceOne({ _id: idValue }, tableData, {
- upsert: true
- });
- if (upsertedId) idValue = upsertedId;
- }
- const projection = this._buildProjection(
- modelName,
- filter && filter.fields
- );
- const upsertedData = await table.findOne({ _id: idValue }, { projection });
- return this._fromDatabase(modelName, upsertedData);
- }
- /**
- * Patch.
- *
- * @param {string} modelName
- * @param {object} modelData
- * @param {object|undefined} where
- * @return {Promise<number>}
- */
- async patch(modelName, modelData, where = void 0) {
- const idPropName = this._getIdPropName(modelName);
- delete modelData[idPropName];
- const query = this._buildQuery(modelName, where) || {};
- const tableData = this._toDatabase(modelName, modelData);
- const table = this._getCollection(modelName);
- const { matchedCount } = await table.updateMany(query, { $set: tableData });
- return matchedCount;
- }
- /**
- * Patch by id.
- *
- * @param {string} modelName
- * @param {string|number} id
- * @param {object} modelData
- * @param {object|undefined} filter
- * @return {Promise<object>}
- */
- async patchById(modelName, id, modelData, filter = void 0) {
- id = this._coerceId(id);
- const idPropName = this._getIdPropName(modelName);
- delete modelData[idPropName];
- const tableData = this._toDatabase(modelName, modelData);
- const table = this._getCollection(modelName);
- const { matchedCount } = await table.updateOne({ _id: id }, { $set: tableData });
- if (matchedCount < 1)
- throw new InvalidArgumentError2("Identifier %v is not found.", String(id));
- const projection = this._buildProjection(
- modelName,
- filter && filter.fields
- );
- const patchedData = await table.findOne({ _id: id }, { projection });
- return this._fromDatabase(modelName, patchedData);
- }
- /**
- * Find.
- *
- * @param {string} modelName
- * @param {object|undefined} filter
- * @return {Promise<object[]>}
- */
- async find(modelName, filter = void 0) {
- filter = filter || {};
- const query = this._buildQuery(modelName, filter.where);
- const sort = this._buildSort(modelName, filter.order);
- const limit = filter.limit || void 0;
- const skip = filter.skip || void 0;
- const projection = this._buildProjection(modelName, filter.fields);
- const collection = this._getCollection(modelName);
- const options = { sort, limit, skip, projection };
- const tableItems = await collection.find(query, options).toArray();
- return tableItems.map((v) => this._fromDatabase(modelName, v));
- }
- /**
- * Find by id.
- *
- * @param {string} modelName
- * @param {string|number} id
- * @param {object|undefined} filter
- * @return {Promise<object>}
- */
- async findById(modelName, id, filter = void 0) {
- id = this._coerceId(id);
- const table = this._getCollection(modelName);
- const projection = this._buildProjection(
- modelName,
- filter && filter.fields
- );
- const patchedData = await table.findOne({ _id: id }, { projection });
- if (!patchedData)
- throw new InvalidArgumentError2("Identifier %v is not found.", String(id));
- return this._fromDatabase(modelName, patchedData);
- }
- /**
- * Delete.
- *
- * @param {string} modelName
- * @param {object|undefined} where
- * @return {Promise<number>}
- */
- async delete(modelName, where = void 0) {
- const table = this._getCollection(modelName);
- const query = this._buildQuery(modelName, where);
- const { deletedCount } = await table.deleteMany(query);
- return deletedCount;
- }
- /**
- * Delete by id.
- *
- * @param {string} modelName
- * @param {string|number} id
- * @return {Promise<boolean>}
- */
- async deleteById(modelName, id) {
- id = this._coerceId(id);
- const table = this._getCollection(modelName);
- const { deletedCount } = await table.deleteOne({ _id: id });
- return deletedCount > 0;
- }
- /**
- * Exists.
- *
- * @param {string} modelName
- * @param {string|number} id
- * @return {Promise<boolean>}
- */
- async exists(modelName, id) {
- id = this._coerceId(id);
- const table = this._getCollection(modelName);
- const result = await table.findOne({ _id: id }, {});
- return result != null;
- }
- /**
- * Count.
- *
- * @param {string} modelName
- * @param {object|undefined} where
- * @return {Promise<number>}
- */
- async count(modelName, where = void 0) {
- const query = this._buildQuery(modelName, where);
- const table = this._getCollection(modelName);
- return await table.count(query);
- }
- };
- // Annotate the CommonJS export names for ESM import in node:
- 0 && (module.exports = {
- MongodbAdapter
- });
|