| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607 |
- 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-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-format/src/utils/is-class.js"() {
- }
- });
- // node_modules/@e22m4u/js-format/src/utils/index.js
- var init_utils = __esm({
- "node_modules/@e22m4u/js-format/src/utils/index.js"() {
- init_is_class();
- }
- });
- // 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 BASE_CTOR_NAMES.includes(input.constructor.name) ? input.constructor.name : `${input.constructor.name} (instance)`;
- if (typeof input === "object" && input.constructor == null) return "Object";
- return String(input);
- }
- var BASE_CTOR_NAMES;
- var init_value_to_string = __esm({
- "node_modules/@e22m4u/js-format/src/value-to-string.js"() {
- init_utils();
- BASE_CTOR_NAMES = [
- "String",
- "Number",
- "Boolean",
- "Object",
- "Array",
- "Function",
- "Symbol",
- "Map",
- "Set",
- "Date"
- ];
- }
- });
- // 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-format/src/array-to-list.js"() {
- init_value_to_string();
- SEPARATOR = ", ";
- }
- });
- // 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) {
- 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}/g, "%");
- return "" + pattern;
- }
- var init_format = __esm({
- "node_modules/@e22m4u/js-format/src/format.js"() {
- init_array_to_list();
- init_value_to_string();
- }
- });
- // node_modules/@e22m4u/js-format/src/errorf.js
- var Errorf;
- var init_errorf = __esm({
- "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-format/src/index.js
- var init_src = __esm({
- "node_modules/@e22m4u/js-format/src/index.js"() {
- init_format();
- init_errorf();
- }
- });
- // node_modules/@e22m4u/js-service/src/errors/invalid-argument-error.js
- var InvalidArgumentError;
- var init_invalid_argument_error = __esm({
- "node_modules/@e22m4u/js-service/src/errors/invalid-argument-error.js"() {
- init_src();
- InvalidArgumentError = class extends Errorf {
- };
- }
- });
- // node_modules/@e22m4u/js-service/src/errors/index.js
- var init_errors = __esm({
- "node_modules/@e22m4u/js-service/src/errors/index.js"() {
- init_invalid_argument_error();
- }
- });
- // node_modules/@e22m4u/js-service/src/service-container.js
- var ServiceContainer;
- var init_service_container = __esm({
- "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-service/src/service.js
- var Service;
- var init_service = __esm({
- "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-service/src/index.js
- var init_src2 = __esm({
- "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 (!Object.prototype.hasOwnProperty.call(b, 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>}
- */
- // eslint-disable-next-line no-unused-vars
- 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
- init_src2();
- 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
- });
|