12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906 |
- import {
- $R,
- AC,
- BehaviorSubject,
- Ct,
- DC,
- De,
- Fe,
- J0,
- KC,
- Mf,
- Mt,
- Observable,
- Op,
- Ot,
- Pt,
- Qr,
- Ra,
- SC,
- SE,
- SR,
- Subject,
- Vr,
- Ze,
- _n,
- ar,
- dn,
- en,
- filter,
- firstValueFrom,
- isObservable,
- jC,
- kt,
- ln,
- nf,
- nt,
- nu,
- of,
- ot,
- re,
- shareReplay,
- st,
- take,
- takeUntil,
- tt,
- ur,
- vC,
- we,
- xC,
- yC
- } from "./chunk-23V3HWTR.js";
- // node_modules/.pnpm/@univerjs+rpc@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/rpc/lib/es/index.js
- var X = Object.defineProperty;
- var Z = (r, t, e) => t in r ? X(r, t, { enumerable: true, configurable: true, writable: true, value: e }) : r[t] = e;
- var a = (r, t, e) => Z(r, typeof t != "symbol" ? t + "" : t, e);
- var he = "rpc.main-thread.config";
- var D = {};
- var _e = "rpc.worker-thread.config";
- var N = {};
- var le = Object.defineProperty;
- var ue = Object.getOwnPropertyDescriptor;
- var G = (r, t, e, n) => {
- for (var s = n > 1 ? void 0 : n ? ue(t, e) : t, i = r.length - 1, c; i >= 0; i--)
- (c = r[i]) && (s = (n ? c(t, e, s) : c(s)) || s);
- return n && s && le(t, e, s), s;
- };
- var p = (r, t) => (e, n) => t(e, n, r);
- var T = "rpc.remote-sync.service";
- var f = Ct(T);
- var M = class {
- constructor(r) {
- this._commandService = r;
- }
- async syncMutation(r) {
- return this._commandService.syncExecuteCommand(r.mutationInfo.id, r.mutationInfo.params, {
- onlyLocal: true,
- fromSync: true
- });
- }
- };
- M = G([
- p(0, Pt)
- ], M);
- var W = "univer.remote-instance-service";
- var m = Ct(W);
- var q = class {
- constructor(r, t, e) {
- this._univerInstanceService = r, this._commandService = t, this._logService = e;
- }
- whenReady() {
- return Promise.resolve(true);
- }
- async syncMutation(r) {
- return this._applyMutation(r.mutationInfo);
- }
- async createInstance(r) {
- const { type: t, snapshot: e } = r;
- try {
- switch (t) {
- case Fe.UNIVER_SHEET:
- return this._univerInstanceService.createUnit(Fe.UNIVER_SHEET, e), true;
- default:
- throw new Error(
- `[WebWorkerRemoteInstanceService]: cannot create replica for document type: ${t}.`
- );
- }
- } catch (n) {
- throw n instanceof Error ? n : new TypeError(`${n}`);
- }
- }
- async disposeInstance(r) {
- return this._univerInstanceService.disposeUnit(r.unitID);
- }
- _applyMutation(r) {
- const { id: t, params: e } = r;
- return this._commandService.syncExecuteCommand(t, e, {
- onlyLocal: true,
- fromSync: true
- });
- }
- };
- q = G([
- p(0, _n),
- p(1, Pt),
- p(2, Mt)
- ], q);
- function Y(r) {
- const t = r;
- return new class {
- call(e, n) {
- const s = t[e];
- if (typeof s == "function") {
- let i = n ? s.apply(t, n) : s.call(t);
- return i instanceof Promise || (i = Promise.resolve(i)), i;
- }
- throw new Error(`[RPC]: method not found for ${e}!`);
- }
- subscribe(e, n) {
- const s = t[e];
- if (typeof s == "function") {
- const i = n ? s.apply(t, n) : s.call(t);
- return isObservable(i) ? i : of(i);
- }
- throw new Error(`[RPC]: observable method not found for ${e}!`);
- }
- }();
- }
- function B(r) {
- return new Proxy({}, {
- get(t, e) {
- if (e !== "dispose")
- return function(...n) {
- return de(e) ? r.subscribe(e, n) : r.call(e, n);
- };
- }
- });
- }
- function de(r) {
- return r.endsWith("$");
- }
- var pe = class extends J0 {
- constructor(e) {
- super();
- a(this, "_initialized", new BehaviorSubject(false));
- a(this, "_lastRequestCounter", 0);
- a(this, "_pendingRequests", /* @__PURE__ */ new Map());
- this._protocol = e, this._protocol.send({
- type: 50
- /* REQUEST_INITIALIZATION */
- }), this._protocol.onMessage.pipe(takeUntil(this.dispose$)).subscribe((n) => this._onMessage(n));
- }
- dispose() {
- this._pendingRequests.clear();
- }
- getChannel(e) {
- const n = this;
- return {
- call(s, i) {
- return n._disposed ? Promise.reject() : n._remoteCall(e, s, i);
- },
- subscribe(s, i) {
- if (n._disposed)
- throw new Error("[ChannelClient]: client is disposed!");
- return n._remoteSubscribe(e, s, i);
- }
- };
- }
- _whenReady() {
- return firstValueFrom(
- this._initialized.pipe(
- filter((e) => e),
- take(1)
- )
- );
- }
- async _remoteCall(e, n, s) {
- await this._whenReady();
- const i = ++this._lastRequestCounter, h = { seq: i, type: 100, channelName: e, method: n, args: s }, o = this;
- return new Promise((w, _) => {
- const Q = {
- handle(P) {
- switch (P.type) {
- case 201:
- o._pendingRequests.delete(i), w(P.data);
- break;
- case 202:
- o._pendingRequests.delete(i), _(P.data);
- break;
- default:
- throw new Error("[ChannelClient]: unknown response type!");
- }
- }
- };
- this._pendingRequests.set(i, Q), this._sendRequest(h);
- });
- }
- _remoteSubscribe(e, n, s) {
- return new Observable((i) => {
- let c = -1;
- return this._whenReady().then(() => {
- c = ++this._lastRequestCounter;
- const o = { seq: c, type: 101, channelName: e, method: n, args: s }, w = {
- handle(_) {
- switch (_.type) {
- case 300:
- i.next(_.data);
- break;
- case 301:
- i.error(_.data);
- break;
- case 302:
- i.complete();
- break;
- default:
- throw new Error("[ChannelClient]: unknown response type!");
- }
- }
- };
- this._pendingRequests.set(c, w), this._sendRequest(o);
- }), () => {
- if (c === -1)
- return;
- const h = {
- type: 102,
- seq: c,
- channelName: e,
- method: n
- };
- this._sendRequest(h);
- };
- });
- }
- _sendRequest(e) {
- this._protocol.send(e);
- }
- _onMessage(e) {
- var n;
- switch (e.type) {
- case 0:
- this._initialized.next(true);
- break;
- case 201:
- case 202:
- case 300:
- case 302:
- case 301:
- (n = this._pendingRequests.get(e.seq)) == null || n.handle(e);
- break;
- }
- }
- };
- var ve = class extends J0 {
- constructor(e) {
- super();
- a(this, "_channels", /* @__PURE__ */ new Map());
- a(this, "_subscriptions", /* @__PURE__ */ new Map());
- this._protocol = e, this._protocol.onMessage.pipe(takeUntil(this.dispose$)).subscribe((n) => this._onRequest(n)), this._sendInitialize();
- }
- dispose() {
- super.dispose(), this._subscriptions.clear(), this._channels.clear();
- }
- registerChannel(e, n) {
- this._channels.set(e, n);
- }
- _onRequest(e) {
- switch (e.type) {
- case 50:
- this._sendInitialize();
- break;
- case 100:
- this._onMethodCall(e);
- break;
- case 101:
- this._onSubscribe(e);
- break;
- case 102:
- this._onUnsubscribe(e);
- break;
- }
- }
- _sendInitialize() {
- this._sendResponse({
- seq: -1,
- type: 0
- /* INITIALIZE */
- });
- }
- _onMethodCall(e) {
- const { channelName: n, method: s, args: i } = e, c = this._channels.get(n);
- let h;
- try {
- if (!c)
- throw new Error(`[ChannelServer]: Channel ${n} not found!`);
- h = i ? c.call(s, i) : c.call(s);
- } catch (o) {
- h = Promise.reject(o);
- }
- h.then((o) => {
- this._sendResponse({ seq: e.seq, type: 201, data: o });
- }).catch((o) => {
- o instanceof Error ? this._sendResponse({ seq: e.seq, type: 202, data: o.message }) : this._sendResponse({ seq: e.seq, type: 202, data: String(o) });
- });
- }
- _onSubscribe(e) {
- const { channelName: n, seq: s } = e, i = this._channels.get(n);
- try {
- if (!i)
- throw new Error(`[ChannelServer]: Channel ${n} not found!`);
- const h = i.subscribe(e.method, e.args).subscribe({
- next: (o) => {
- this._sendResponse({ seq: s, type: 300, data: o });
- },
- error: (o) => {
- this._sendResponse({ seq: s, type: 301, data: o.message }), this._sendResponse({
- seq: s,
- type: 302
- /* SUBSCRIBE_COMPLETE */
- });
- },
- complete: () => {
- this._sendResponse({
- seq: s,
- type: 302
- /* SUBSCRIBE_COMPLETE */
- });
- }
- });
- this._subscriptions.set(e.seq, h);
- } catch (c) {
- c instanceof Error ? this._sendResponse({ seq: e.seq, type: 301, data: c.message }) : this._sendResponse({ seq: e.seq, type: 301, data: String(c) });
- }
- }
- _onUnsubscribe(e) {
- const n = this._subscriptions.get(e.seq);
- n && (n.unsubscribe(), this._subscriptions.delete(e.seq));
- }
- _sendResponse(e) {
- this._protocol.send(e);
- }
- };
- var I = Ct("IRPCChannelService");
- var K = class {
- constructor(t) {
- a(this, "_client");
- a(this, "_server");
- this._client = new pe(t), this._server = new ve(t);
- }
- dispose() {
- this._client.dispose(), this._server.dispose();
- }
- requestChannel(t) {
- return this._client.getChannel(t);
- }
- registerChannel(t, e) {
- this._server.registerChannel(t, e);
- }
- };
- var fe = Object.defineProperty;
- var me = Object.getOwnPropertyDescriptor;
- var ge = (r, t, e, n) => {
- for (var s = n > 1 ? void 0 : n ? me(t, e) : t, i = r.length - 1, c; i >= 0; i--)
- (c = r[i]) && (s = (n ? c(t, e, s) : c(s)) || s);
- return n && s && fe(t, e, s), s;
- };
- var l = (r, t) => (e, n) => t(e, n, r);
- var g = class extends J0 {
- constructor(t, e, n, s, i) {
- super();
- a(this, "_remoteInstanceService");
- a(this, "_syncingUnits", /* @__PURE__ */ new Set());
- a(this, "_syncingMutations", /* @__PURE__ */ new Set());
- this._injector = t, this._commandService = e, this._univerInstanceService = n, this._rpcChannelService = s, this._remoteSyncService = i, this._initRPCChannels(), this._init();
- }
- registerSyncingMutations(t) {
- this._syncingMutations.add(t.id);
- }
- /**
- * Only spreadsheets would be synced to the web worker in normal situations. If you would like to
- * sync other types of documents, you should manually call this method with that document's id.
- */
- syncUnit(t) {
- return this._syncingUnits.add(t), Ze(() => this._syncingUnits.delete(t));
- }
- _initRPCChannels() {
- this._rpcChannelService.registerChannel(T, Y(this._remoteSyncService)), this._injector.add([
- m,
- { useFactory: () => B(this._rpcChannelService.requestChannel(W)) }
- ]), this._remoteInstanceService = this._injector.get(m);
- }
- _init() {
- this._univerInstanceService.getTypeOfUnitAdded$(Fe.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((t) => {
- this._syncingUnits.add(t.getUnitId()), this._remoteInstanceService.createInstance({
- unitID: t.getUnitId(),
- type: Fe.UNIVER_SHEET,
- snapshot: t.getSnapshot()
- });
- }), this._univerInstanceService.getTypeOfUnitDisposed$(Fe.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((t) => {
- this._syncingUnits.delete(t.getUnitId()), this._remoteInstanceService.disposeInstance({
- unitID: t.getUnitId()
- });
- }), this.disposeWithMe(this._commandService.onCommandExecuted((t, e) => {
- const { type: n, params: s, id: i } = t, c = (s == null ? void 0 : s.unitId) || "";
- n === ar.MUTATION && // only sync mutations to the worker thread
- (!c || this._syncingUnits.has(c)) && // do not sync mutations from the web worker back to the web worker
- !(e != null && e.fromSync) && // do not sync mutations those are not meant to be synced
- this._syncingMutations.has(i) && this._remoteInstanceService.syncMutation({ mutationInfo: t });
- }));
- }
- };
- g = ge([
- l(0, ot(Ot)),
- l(1, Pt),
- l(2, _n),
- l(3, I),
- l(4, f)
- ], g);
- var ye = Object.defineProperty;
- var Se = Object.getOwnPropertyDescriptor;
- var be = (r, t, e, n) => {
- for (var s = n > 1 ? void 0 : n ? Se(t, e) : t, i = r.length - 1, c; i >= 0; i--)
- (c = r[i]) && (s = (n ? c(t, e, s) : c(s)) || s);
- return n && s && ye(t, e, s), s;
- };
- var d = (r, t) => (e, n) => t(e, n, r);
- var y = class extends nt {
- constructor(t, e, n, s) {
- super();
- a(this, "_remoteSyncService");
- this._injector = t, this._remoteInstanceService = e, this._commandService = n, this._rpcChannelService = s, this._initRPCChannels(), this._init();
- }
- _initRPCChannels() {
- this._rpcChannelService.registerChannel(W, Y(this._remoteInstanceService)), this._injector.add([
- f,
- { useFactory: () => B(this._rpcChannelService.requestChannel(T)) }
- ]), this._remoteSyncService = this._injector.get(f);
- }
- _init() {
- this.disposeWithMe(
- // Mutations executed on the main thread should be synced to the worker thread.
- this._commandService.onCommandExecuted((t, e) => {
- t.type === ar.MUTATION && !(e != null && e.fromSync) && this._remoteSyncService.syncMutation({
- mutationInfo: t
- });
- })
- );
- }
- };
- y = be([
- d(0, ot(Ot)),
- d(1, m),
- d(2, Pt),
- d(3, I)
- ], y);
- function Ce() {
- return {
- send(r) {
- postMessage(r);
- },
- onMessage: new Observable((r) => {
- const t = (e) => {
- r.next(e.data);
- };
- return addEventListener("message", t), () => removeEventListener("message", t);
- }).pipe(shareReplay(1))
- };
- }
- function Re(r) {
- return {
- send(t) {
- r.postMessage(t);
- },
- onMessage: new Observable((t) => {
- const e = (n) => {
- t.next(n.data);
- };
- return r.addEventListener("message", e), () => r.removeEventListener("message", e);
- }).pipe(shareReplay(1))
- };
- }
- var Ie = Object.defineProperty;
- var we2 = Object.getOwnPropertyDescriptor;
- var J = (r, t, e, n) => {
- for (var s = n > 1 ? void 0 : n ? we2(t, e) : t, i = r.length - 1, c; i >= 0; i--)
- (c = r[i]) && (s = (n ? c(t, e, s) : c(s)) || s);
- return n && s && Ie(t, e, s), s;
- };
- var S = (r, t) => (e, n) => t(e, n, r);
- var E;
- var x = (E = class extends Ra {
- constructor(t = D, e, n) {
- super();
- a(this, "_internalWorker", null);
- this._config = t, this._injector = e, this._configService = n;
- const { ...s } = nu(
- {},
- D,
- this._config
- );
- this._configService.setConfig(he, s);
- }
- dispose() {
- super.dispose(), this._internalWorker && (this._internalWorker.terminate(), this._internalWorker = null);
- }
- onStarting() {
- const { workerURL: t } = this._config;
- if (!t)
- throw new Error("[UniverRPCMainThreadPlugin]: The workerURL is required for the RPC main thread plugin.");
- const e = t instanceof Worker ? t : new Worker(t);
- this._internalWorker = t instanceof Worker ? null : e;
- const n = Re(e);
- [
- [
- I,
- {
- useFactory: () => new K(n)
- }
- ],
- [g],
- [f, { useClass: M }]
- ].forEach((i) => this._injector.add(i)), this._injector.get(g);
- }
- }, a(E, "pluginName", "UNIVER_RPC_MAIN_THREAD_PLUGIN"), E);
- x = J([
- S(1, ot(Ot)),
- S(2, SE)
- ], x);
- var U;
- var L = (U = class extends Ra {
- constructor(r = N, t, e) {
- super(), this._config = r, this._injector = t, this._configService = e;
- const { ...n } = nu(
- {},
- N,
- this._config
- );
- this._configService.setConfig(_e, n);
- }
- onStarting() {
- [
- [y],
- [
- I,
- {
- useFactory: () => new K(Ce())
- }
- ],
- [m, { useClass: q }]
- ].forEach((r) => this._injector.add(r)), this._injector.get(y);
- }
- }, a(U, "pluginName", "UNIVER_RPC_WORKER_THREAD_PLUGIN"), U);
- L = J([
- S(1, ot(Ot)),
- S(2, SE)
- ], L);
- // node_modules/.pnpm/@univerjs+engine-formula@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/engine-formula/lib/es/index.js
- var vu = Object.defineProperty;
- var Tu = (i, a2, e) => a2 in i ? vu(i, a2, { enumerable: true, configurable: true, writable: true, value: e }) : i[a2] = e;
- var A = (i, a2, e) => Tu(i, typeof a2 != "symbol" ? a2 + "" : a2, e);
- var er = ((i) => (i.FALSE = "FALSE", i.TRUE = "TRUE", i))(er || {});
- var xt = ((i) => (i[i.SUCCESS = 0] = "SUCCESS", i[i.ERROR = 1] = "ERROR", i))(xt || {});
- var it = ((i) => (i[i.FRONT = 0] = "FRONT", i[i.BACK = 1] = "BACK", i))(it || {});
- function zu(i, a2, e, t, r) {
- for (let n = 0, s = i.length; n < s; n++) {
- const o = i[n];
- if (a2 !== o.unitId || e !== o.sheetId)
- continue;
- const { startRow: u, startColumn: c, endRow: l2, endColumn: f2 } = o.range;
- if (t >= u && t <= l2 && r >= c && r <= f2)
- return true;
- }
- return false;
- }
- var m2 = ((i) => (i.DIV_BY_ZERO = "#DIV/0!", i.NAME = "#NAME?", i.VALUE = "#VALUE!", i.NUM = "#NUM!", i.NA = "#N/A", i.CYCLE = "#CYCLE!", i.REF = "#REF!", i.SPILL = "#SPILL!", i.CALC = "#CALC!", i.ERROR = "#ERROR!", i.CONNECT = "#GETTING_DATA", i.NULL = "#NULL!", i))(m2 || {});
- var yr = new Set(Object.values(m2));
- var Ga = [...new Set(Object.values(m2).map((i) => i.length))];
- var Ju = ((i) => (i[i.Financial = 0] = "Financial", i[i.Date = 1] = "Date", i[i.Math = 2] = "Math", i[i.Statistical = 3] = "Statistical", i[i.Lookup = 4] = "Lookup", i[i.Database = 5] = "Database", i[i.Text = 6] = "Text", i[i.Logical = 7] = "Logical", i[i.Information = 8] = "Information", i[i.Engineering = 9] = "Engineering", i[i.Cube = 10] = "Cube", i[i.Compatibility = 11] = "Compatibility", i[i.Web = 12] = "Web", i[i.Array = 13] = "Array", i[i.Univer = 14] = "Univer", i[i.User = 15] = "User", i[i.DefinedName = 16] = "DefinedName", i))(Ju || {});
- var X2 = ((i) => (i.PLUS = "+", i.MINUS = "-", i.MULTIPLY = "*", i.DIVIDED = "/", i.CONCATENATE = "&", i.POWER = "^", i.EQUALS = "=", i.NOT_EQUAL = "<>", i.GREATER_THAN = ">", i.GREATER_THAN_OR_EQUAL = ">=", i.LESS_THAN = "<", i.LESS_THAN_OR_EQUAL = "<=", i))(X2 || {});
- var $ = ((i) => (i.EQUALS = "=", i.NOT_EQUAL = "<>", i.GREATER_THAN = ">", i.GREATER_THAN_OR_EQUAL = ">=", i.LESS_THAN = "<", i.LESS_THAN_OR_EQUAL = "<=", i))($ || {});
- var Jr = /* @__PURE__ */ new Map([
- ["<>", 4],
- ["<", 4],
- [">=", 4],
- ["=", 4],
- [">", 4],
- ["<=", 4],
- ["&", 3],
- ["+", 2],
- ["-", 2],
- ["/", 1],
- ["*", 1],
- ["^", 0]
- ]);
- var Dt = new Set(Jr.keys());
- var ec = /* @__PURE__ */ new Set([
- "=",
- "<>",
- ">",
- ">=",
- "<",
- "<="
- /* LESS_THAN_OR_EQUAL */
- ]);
- var K2 = ((i) => (i.OPEN_BRACKET = "(", i.CLOSE_BRACKET = ")", i.COMMA = ",", i.SINGLE_QUOTATION = "'", i.DOUBLE_QUOTATION = '"', i.OPEN_BRACES = "{", i.CLOSE_BRACES = "}", i.COLON = ":", i.OPEN_SQUARE_BRACKET = "[", i.CLOSE_SQUARE_BRACKET = "]", i))(K2 || {});
- var ze = ((i) => (i.PERCENTAGE = "%", i.POUND = "#", i))(ze || {});
- var rs = /* @__PURE__ */ new Set([
- "%",
- "#"
- /* POUND */
- ]);
- var Oe = ((i) => (i.AT = "@", i.MINUS = "-", i.PLUS = "+", i))(Oe || {});
- var tc = " ";
- var $i = [
- ...Object.values($),
- ...Object.values(X2),
- ...Object.values(K2),
- ...Object.values(ze),
- ...Object.values(Oe)
- ];
- function en2(i) {
- return $i.includes(i);
- }
- function rc(i) {
- for (const a2 of $i)
- if (i.indexOf(a2) > -1)
- return true;
- return false;
- }
- function Ib(i) {
- return i[0] === "'" && i[i.length - 1] === "'" ? i.substring(1, i.length - 1) : i;
- }
- function Fb(i) {
- return en2(i) && i !== K2.CLOSE_BRACES && i !== K2.CLOSE_BRACKET && i !== K2.SINGLE_QUOTATION && i !== K2.DOUBLE_QUOTATION || i === " ";
- }
- var nc = /* @__PURE__ */ new Set([
- X2.PLUS,
- X2.MINUS,
- X2.MULTIPLY,
- X2.DIVIDED,
- X2.CONCATENATE,
- X2.POWER,
- X2.EQUALS,
- X2.NOT_EQUAL,
- X2.GREATER_THAN,
- X2.GREATER_THAN_OR_EQUAL,
- X2.LESS_THAN,
- X2.LESS_THAN_OR_EQUAL,
- K2.OPEN_BRACKET,
- K2.COMMA,
- K2.COLON,
- K2.OPEN_BRACES,
- K2.OPEN_SQUARE_BRACKET
- ]);
- function sc(i) {
- return nc.has(i);
- }
- var ac = /* @__PURE__ */ new Set([
- X2.PLUS,
- X2.MINUS,
- X2.MULTIPLY,
- X2.DIVIDED,
- X2.CONCATENATE,
- X2.POWER,
- X2.EQUALS,
- X2.NOT_EQUAL,
- X2.GREATER_THAN,
- X2.GREATER_THAN_OR_EQUAL,
- X2.LESS_THAN,
- X2.LESS_THAN_OR_EQUAL,
- K2.OPEN_BRACKET,
- K2.COMMA,
- K2.COLON,
- K2.OPEN_BRACES,
- K2.OPEN_SQUARE_BRACKET,
- ze.PERCENTAGE,
- ze.POUND
- ]);
- function ic(i) {
- return ac.has(i);
- }
- function oc(i) {
- const a2 = {};
- return Object.keys(i).forEach((e) => {
- const t = i[e];
- if (t == null)
- return true;
- a2[e] == null && (a2[e] = {}), Object.keys(t).forEach((r) => {
- const n = t[r];
- a2[e][r] = new kt(n);
- });
- }), a2;
- }
- function uc(i) {
- const a2 = {};
- for (const e in i) {
- const t = i[e];
- if (t != null) {
- a2[e] == null && (a2[e] = {});
- for (const r in t) {
- const n = t[r], s = {};
- n.forValue((o, u, c) => {
- s[o] === void 0 && (s[o] = {}), s[o][u] = c;
- }), a2[e][r] = s;
- }
- }
- }
- return a2;
- }
- var Yi = '\\[([^\\[\\]\\/?:"<>|*\\\\]+)\\]';
- var Qa = new RegExp(Yi);
- var cc = "((?![\\[\\]\\/?*\\\\]).)*!";
- var Tt = "$";
- var ra = "\\s*?:\\s*?";
- var cn = "[A-Za-z]+";
- var ln2 = "[1-9][0-9]*";
- var Rr = `'?(${Yi})?(${cc})?'?`;
- var Es = `\\${Tt}?${cn}\\${Tt}?${ln2}`;
- var lc = `^(${Oe.AT})?${Rr}${Es}${ra}${Es}$`;
- var Wa = new RegExp(lc);
- var fc = `^${Rr}\\s*?${Es}(${ze.POUND})?$`;
- var qa = new RegExp(fc);
- var hc = `^${Rr}\\${Tt}?${ln2}${ra}\\${Tt}?${ln2}$`;
- var Ka = new RegExp(hc);
- var mc = `^${Rr}\\${Tt}?${cn}${ra}\\${Tt}?${cn}$`;
- var Xa = new RegExp(mc);
- var gc = `^${Rr}\\s*?\\${Tt}?${ln2}$`;
- var Za = new RegExp(gc);
- var dc = `^${Rr}\\s*?\\${Tt}?${cn}$`;
- var za = new RegExp(dc);
- var Cc = "{.*?}";
- var Ja = new RegExp(Cc, "g");
- function vr(i) {
- return qa.lastIndex = 0, qa.test(i);
- }
- function _c(i) {
- return Wa.lastIndex = 0, Wa.test(i);
- }
- function Hi(i) {
- return Ka.lastIndex = 0, Ka.test(i);
- }
- function Gi(i) {
- return Xa.lastIndex = 0, Xa.test(i);
- }
- function Qi(i) {
- return Za.lastIndex = 0, Za.test(i);
- }
- function Wi(i) {
- return za.lastIndex = 0, za.test(i);
- }
- function Ac(i) {
- return Ja.lastIndex = 0, Ja.test(i);
- }
- function Ec(i) {
- return vr(i) || _c(i) || Hi(i) || Gi(i);
- }
- var bc = {
- id: "formula.mutation.register-function",
- type: ar.MUTATION,
- handler: () => true
- };
- var bs = {
- id: "formula.mutation.set-array-formula-data",
- type: ar.MUTATION,
- handler: (i, a2) => true
- };
- var yc = /[^0-9]/g;
- var Rc = /[^A-Za-z]/g;
- function tn(i) {
- let a2 = i[0] === "$";
- const e = i.substring(1);
- let t = e.indexOf("$") > -1;
- return re.isStringNumber(e) && a2 && !t && (a2 = false, t = true), a2 && t ? tt.ALL : a2 ? tt.COLUMN : t ? tt.ROW : tt.NONE;
- }
- function kb(i) {
- const a2 = i.split("!");
- a2.length > 1 && (i = a2[a2.length - 1]);
- const e = i.split(":");
- return e.length > 1 ? {
- startAbsoluteRefType: tn(e[0]),
- endAbsoluteRefType: tn(e[1])
- } : { startAbsoluteRefType: tn(e[0]) };
- }
- function ei(i = tt.NONE) {
- let a2 = "", e = "";
- return i === tt.ROW ? a2 = "$" : i === tt.COLUMN ? e = "$" : i === tt.ALL && (a2 = "$", e = "$"), {
- rowAbsoluteString: a2,
- columnAbsoluteString: e
- };
- }
- function fr(i) {
- const {
- startColumn: a2,
- startRow: e,
- endColumn: t,
- endRow: r,
- startAbsoluteRefType: n,
- endAbsoluteRefType: s,
- rangeType: o = De.NORMAL
- } = i, u = ei(n), c = ei(s);
- if (o === De.ROW || o === De.ALL) {
- const h = `${u.rowAbsoluteString}${e + 1}`, d2 = `${c.rowAbsoluteString}${r + 1}`;
- return `${h}:${d2}`;
- }
- if (o === De.COLUMN) {
- const h = `${u.columnAbsoluteString}${re.chatAtABC(a2)}`, d2 = `${c.columnAbsoluteString}${re.chatAtABC(t)}`;
- return `${h}:${d2}`;
- }
- const l2 = `${u.columnAbsoluteString}${re.chatAtABC(a2)}${u.rowAbsoluteString}${e + 1}`, f2 = `${c.columnAbsoluteString}${re.chatAtABC(t)}${c.rowAbsoluteString}${r + 1}`;
- return l2 === f2 ? l2 : `${l2}:${f2}`;
- }
- function pc(i, a2) {
- return `${Ki(i)}!${fr(a2)}`;
- }
- function Vc(i, a2, e) {
- return Rs(i) || Rs(a2) ? `'[${ps(i)}]${ps(a2)}'!${fr(e)}` : `[${i}]${a2}!${fr(e)}`;
- }
- function ys(i) {
- const { unitId: a2, sheetName: e, range: t } = i;
- return a2 != null && a2.length > 0 && e != null && e.length > 0 ? Vc(a2, e, t) : e != null && e.length > 0 ? pc(e, t) : fr(t);
- }
- function ns(i) {
- const a2 = Number.parseInt(i.replace(yc, "")) - 1, e = re.ABCatNum(i.replace(Rc, "")), t = tn(i);
- return {
- row: a2,
- column: e,
- absoluteRefType: t
- };
- }
- function na(i) {
- const a2 = Qa.exec(i);
- let e = "";
- a2 != null && (e = a2[0].trim(), e = ti(e.slice(1, e.length - 1)), i = i.replace(Qa, ""));
- const t = i.indexOf("!");
- let r = "", n = "";
- return t > -1 ? (r = i.substring(0, t), r[0] === "'" && r[r.length - 1] === "'" && (r = r.substring(1, r.length - 1)), r = ti(r), n = i.substring(t + 1)) : n = i, {
- refBody: n,
- sheetName: r,
- unitId: e
- };
- }
- function fn(i) {
- const { refBody: a2, sheetName: e, unitId: t } = na(i), r = a2.indexOf(":");
- if (r === -1) {
- const _ = ns(a2), C = _.row, E2 = _.column, b = _.absoluteRefType;
- return {
- unitId: t,
- sheetName: e,
- range: {
- startRow: C,
- startColumn: E2,
- endRow: C,
- endColumn: E2,
- startAbsoluteRefType: b,
- endAbsoluteRefType: b
- }
- };
- }
- const n = a2.substring(0, r), s = a2.substring(r + 1), o = ns(n), u = ns(s), c = o.row > u.row ? u.row : o.row, l2 = o.column > u.column ? u.column : o.column, f2 = o.row > u.row ? o.row : u.row, h = o.column > u.column ? o.column : u.column;
- let d2 = De.NORMAL;
- return Number.isNaN(c) && Number.isNaN(f2) ? d2 = De.COLUMN : Number.isNaN(l2) && Number.isNaN(h) && (d2 = De.ROW), {
- unitId: t,
- sheetName: e,
- range: {
- startRow: c,
- startColumn: l2,
- endRow: f2,
- endColumn: h,
- startAbsoluteRefType: o.absoluteRefType,
- endAbsoluteRefType: u.absoluteRefType,
- rangeType: d2
- }
- };
- }
- var Nc = ["LOG10"];
- function rn(i) {
- const a2 = qi(i);
- if (!Ec(a2) || Nc.includes(a2.toUpperCase().trim()))
- return false;
- const { range: e } = fn(a2);
- return !(e.endColumn >= 16384);
- }
- function qi(i) {
- const a2 = [];
- let e = false;
- for (let t = 0, r = i.length; t < r; t++) {
- const n = i[t];
- if (n === tc && !e)
- a2.push(n);
- else {
- if (!e && (n === Oe.AT || n === Oe.MINUS || n === Oe.PLUS))
- continue;
- a2.push(n), e = true;
- }
- }
- return a2.join("");
- }
- function $b(i, a2) {
- const e = (i == null ? void 0 : i.split(",")) || [];
- return i === "" || e.length === 0 ? [] : Oc(i) ? e.map((n) => {
- const s = fn(n);
- return {
- unitId: s.unitId,
- sheetId: a2(s.sheetName),
- range: s.range,
- sheetName: s.sheetName
- };
- }) : [];
- }
- function Oc(i) {
- return ((i == null ? void 0 : i.split(",")) || []).every((e) => rn(e.trim()));
- }
- function Rs(i) {
- return i.length === 0 ? false : !!(rc(i) || Mc(i) || wc(i) || Dc(i) || /[\s!$%^&*()+\-=\[\]{};':"\\|,.<>\/?()]/.test(i));
- }
- function Ki(i) {
- return Rs(i) ? `'${ps(i)}'` : i;
- }
- function ps(i) {
- return i.replace(/'/g, "''");
- }
- function ti(i) {
- return i.replace(/''/g, "'");
- }
- function Mc(i) {
- const a2 = i.match(/[1-9][0-9]{0,6}/);
- return /^[A-Z]+[1-9][0-9]{0,6}$/.test(i) && a2 !== null;
- }
- function wc(i) {
- return /^(R(-?[0-9]+)?C(-?[0-9]+)?|C(-?[0-9]+)?|R(-?[0-9]+)?)$/.test(i);
- }
- function Dc(i) {
- return !new RegExp("^\\p{Letter}", "u").test(i.charAt(0));
- }
- var Sc = Object.defineProperty;
- var Pc = Object.getOwnPropertyDescriptor;
- var Lc = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Pc(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Sc(a2, e, r), r;
- };
- var xc = (i, a2) => (e, t) => a2(e, t, i);
- var Vs = class extends nt {
- constructor(a2) {
- super();
- A(this, "_definedNameMap", {});
- A(this, "_update$", new Subject());
- A(this, "update$", this._update$.asObservable());
- A(this, "_currentRange", {
- unitId: "",
- sheetId: "",
- range: {
- startRow: 0,
- endRow: 0,
- startColumn: 0,
- endColumn: 0
- }
- });
- A(this, "_currentRange$", new Subject());
- A(this, "currentRange$", this._currentRange$.asObservable());
- A(this, "_focusRange$", new Subject());
- A(this, "focusRange$", this._focusRange$.asObservable());
- this._univerInstanceService = a2;
- }
- dispose() {
- this._definedNameMap = {};
- }
- getWorksheetByRef(a2, e) {
- var r;
- const { sheetName: t } = na(e);
- return (r = this._univerInstanceService.getUnit(a2)) == null ? void 0 : r.getSheetBySheetName(t);
- }
- focusRange(a2, e) {
- const t = this.getValueById(a2, e);
- t != null && this._focusRange$.next({ ...t, unitId: a2 });
- }
- setCurrentRange(a2) {
- this._currentRange = a2, this._currentRange$.next(a2);
- }
- getCurrentRange() {
- return this._currentRange;
- }
- getCurrentRangeForString() {
- return fr(this._currentRange.range);
- }
- registerDefinedNames(a2, e) {
- this._definedNameMap[a2] = e, this._update();
- }
- registerDefinedName(a2, e) {
- this._definedNameMap[a2] == null && (this._definedNameMap[a2] = {}), this._definedNameMap[a2][e.id] = e, this._update();
- }
- removeDefinedName(a2, e) {
- var t;
- (t = this._definedNameMap[a2]) == null || delete t[e], this._update();
- }
- removeUnitDefinedName(a2) {
- delete this._definedNameMap[a2], this._update();
- }
- getDefinedNameMap(a2) {
- return this._definedNameMap[a2];
- }
- getValueByName(a2, e) {
- var r;
- const t = this._definedNameMap[a2];
- return t == null ? null : (r = Array.from(Object.values(t)).filter((n) => n.name === e)) == null ? void 0 : r[0];
- }
- getValueById(a2, e) {
- var t;
- return (t = this._definedNameMap[a2]) == null ? void 0 : t[e];
- }
- hasDefinedName(a2) {
- return this._definedNameMap[a2] == null ? false : (Array.from(Object.values(this._definedNameMap[a2])).length || 0) !== 0;
- }
- _update() {
- this._update$.next(null);
- }
- };
- Vs = Lc([
- xc(0, _n)
- ], Vs);
- var pr = Ct("univer.formula.defined-names.service");
- var Yb = (i, a2) => {
- const { unitId: e, id: t } = a2;
- return {
- ...i.get(pr).getValueById(e, t),
- unitId: e
- };
- };
- var sa = {
- id: "formula.mutation.set-defined-name",
- type: ar.MUTATION,
- handler: (i, a2) => {
- if (a2 == null)
- return false;
- const e = i.get(pr), { id: t, unitId: r, name: n, formulaOrRefString: s, comment: o, hidden: u, localSheetId: c } = a2;
- return e.registerDefinedName(r, {
- id: t,
- name: n.trim(),
- formulaOrRefString: s.trim(),
- comment: o == null ? void 0 : o.trim(),
- hidden: u,
- localSheetId: c
- }), true;
- }
- };
- var Xi = {
- id: "formula.mutation.remove-defined-name",
- type: ar.MUTATION,
- handler: (i, a2) => {
- if (a2 == null)
- return false;
- const e = i.get(pr), { unitId: t, id: r } = a2;
- return e.removeDefinedName(t, r), true;
- }
- };
- var aa = {
- id: "formula.mutation.set-feature-calculation",
- type: ar.MUTATION,
- handler: () => true
- };
- var ia = {
- id: "formula.mutation.remove-feature-calculation",
- type: ar.MUTATION,
- handler: () => true
- };
- var Zi = {
- id: "formula.mutation.set-formula-calculation-start",
- type: ar.MUTATION,
- handler: () => true
- };
- var zi = {
- id: "formula.mutation.set-formula-calculation-stop",
- type: ar.MUTATION,
- handler: () => true
- };
- var Ns = {
- id: "formula.mutation.set-formula-calculation-notification",
- type: ar.MUTATION,
- handler: () => true
- };
- var Ji = {
- id: "formula.mutation.set-formula-calculation-result",
- type: ar.MUTATION,
- handler: () => true
- };
- var eo = {
- id: "formula.mutation.set-formula-data",
- type: ar.MUTATION,
- handler: (i, a2) => true
- };
- var oa = {
- id: "formula.mutation.set-other-formula",
- type: ar.MUTATION,
- handler: () => true
- };
- var ua = {
- id: "formula.mutation.remove-other-formula",
- type: ar.MUTATION,
- handler: () => true
- };
- var jc = {
- id: "formula.mutation.set-super-table",
- type: ar.MUTATION,
- handler: () => true
- };
- var Uc = {
- id: "formula.mutation.remove-super-table",
- type: ar.MUTATION,
- handler: () => true
- };
- var to = {
- id: "formula.mutation.set-super-table-option",
- type: ar.MUTATION,
- handler: () => true
- };
- var Vt = class {
- constructor(a2) {
- A(this, "_cache");
- this._cache = new Qr(a2);
- }
- set(a2, e) {
- const t = this._hash(a2);
- this._cache.set(t, e);
- }
- get(a2) {
- const e = this._hash(a2);
- return this._cache.get(e);
- }
- clear() {
- this._cache.clear();
- }
- _hash(a2) {
- return a2.length <= 64 ? a2 : xC(a2).toString();
- }
- };
- var ht = "P_1";
- var Ut = "R_1";
- var hr = "L_1";
- var Tr = "LR_1";
- var ro = "LO_1";
- var vc = "LET";
- var Sr = "LAMBDA";
- var Tc = "CUBE";
- var Bc = /* @__PURE__ */ new Set(["RAND", "RANDBETWEEN", "NOW", "TODAY"]);
- var Os = new Vt(1e5);
- function mr(i) {
- const a2 = Os.get(i);
- if (a2)
- return a2;
- const e = fn(i);
- return Os.set(i, e), fn(i);
- }
- function Ic() {
- Os.clear();
- }
- var $e = ((i) => (i[i.NORMAL = 0] = "NORMAL", i[i.NUMBER = 1] = "NUMBER", i[i.STRING = 2] = "STRING", i[i.FUNCTION = 3] = "FUNCTION", i[i.REFERENCE = 4] = "REFERENCE", i[i.ARRAY = 5] = "ARRAY", i[i.DEFINED_NAME = 6] = "DEFINED_NAME", i))($e || {});
- function ri(i) {
- let a2 = "";
- for (const e of i)
- typeof e == "string" ? a2 += e : a2 += e.token;
- return a2;
- }
- var ae = class _ae {
- constructor() {
- A(this, "_parent");
- A(this, "_token", Ut);
- A(this, "_children", []);
- A(this, "_lambdaId");
- A(this, "_functionDefinitionPrivacyVar");
- A(this, "_lambdaParameter", "");
- A(this, "_startIndex", -1);
- A(this, "_endIndex", -1);
- A(this, "_definedNames", []);
- }
- dispose() {
- var a2;
- this._children.forEach((e) => {
- typeof e != "string" && e.dispose();
- }), (a2 = this._functionDefinitionPrivacyVar) == null || a2.clear(), this._functionDefinitionPrivacyVar = null, this._children = [], this._parent = null, this._definedNames = [];
- }
- getDefinedNames() {
- return this._definedNames;
- }
- getStartIndex() {
- return this._startIndex;
- }
- getLambdaId() {
- return this._lambdaId;
- }
- setLambdaId(a2) {
- this._lambdaId = a2;
- }
- getFunctionDefinitionPrivacyVar() {
- return this._functionDefinitionPrivacyVar;
- }
- setLambdaPrivacyVar(a2) {
- this._functionDefinitionPrivacyVar = a2;
- }
- getLambdaParameter() {
- return this._lambdaParameter;
- }
- setLambdaParameter(a2) {
- this._lambdaParameter = a2;
- }
- getParent() {
- return this._parent;
- }
- setParent(a2) {
- this._parent = a2;
- }
- getChildren() {
- return this._children;
- }
- setChildren(a2) {
- this._children = a2;
- }
- addChildren(a2) {
- this._children.push(a2);
- }
- addChildrenFirst(a2) {
- this._children.unshift(a2);
- }
- getToken() {
- return this._token;
- }
- setToken(a2) {
- this._token = a2;
- }
- setIndex(a2, e) {
- this._startIndex = a2, this._endIndex = e;
- }
- setDefinedNames(a2) {
- this._definedNames = a2;
- }
- hasDefinedNames() {
- return this._definedNames.length > 0;
- }
- replaceChild(a2, e) {
- const t = this._getIndexInParent(a2);
- t != null && (this.getChildren().splice(t, 1, e), e.setParent(this));
- }
- changeToParent(a2) {
- const e = this.getParent();
- e && e.removeChild(this), this.setParent(a2), a2.getChildren().push(this);
- }
- removeChild(a2) {
- const e = this._getIndexInParent(a2);
- e != null && this.getChildren().splice(e, 1);
- }
- serialize() {
- const a2 = this.getToken(), e = this.getChildren(), t = [], r = e.length;
- for (let n = 0; n < r; n++) {
- const s = e[n];
- s instanceof _ae ? t.push(s.serialize()) : t.push(s);
- }
- return {
- token: a2,
- st: this._startIndex,
- ed: this._endIndex,
- children: t
- };
- }
- _getIndexInParent(a2) {
- const e = this.getChildren(), t = e.length;
- for (let r = 0; r < t; r++)
- if (e[r] === a2)
- return r;
- }
- };
- var no = 2e3;
- var ss = new Vt(no);
- var as = new Vt(no);
- var ca = class extends nt {
- constructor() {
- super(...arguments);
- A(this, "_currentLexerNode", new ae());
- A(this, "_upLevel", 0);
- A(this, "_segment", "");
- A(this, "_bracketState", []);
- A(this, "_squareBracketState", 0);
- A(this, "_bracesState", 0);
- A(this, "_singleQuotationState", 0);
- A(this, "_doubleQuotationState", 0);
- A(this, "_lambdaState", false);
- A(this, "_colonState", false);
- A(this, "_formulaErrorCount", 0);
- A(this, "_tableBracketState", false);
- }
- // Table3[[#All],[Column1]:[Column2]]
- dispose() {
- this._resetTemp(), this._currentLexerNode.dispose(), ss.clear(), as.clear();
- }
- getUpLevel() {
- return this._upLevel;
- }
- isColonClose() {
- return this._colonState === false;
- }
- isColonOpen() {
- return this._colonState === true;
- }
- isDoubleQuotationClose() {
- return this._doubleQuotationState === 0;
- }
- isLambdaOpen() {
- return this._lambdaState === true;
- }
- isLambdaClose() {
- return this._lambdaState === false;
- }
- isSingleQuotationClose() {
- return this._singleQuotationState === 0;
- }
- isBracesClose() {
- return this._bracesState === 0;
- }
- isBracketClose() {
- return this._bracketState.length === 0;
- }
- isSquareBracketClose() {
- return this._squareBracketState === 0;
- }
- getCurrentLexerNode() {
- return this._currentLexerNode;
- }
- getFunctionAndParameter(e, t) {
- const r = this._getCurrentParamIndex(e, t);
- if (r == null || r === m2.VALUE)
- return;
- const n = r[0];
- if (typeof n == "string")
- return;
- let s = n.getParent(), o = n;
- for (; s; ) {
- const u = s.getToken();
- if (u !== ht && !en2(u) && s.getStartIndex() !== -1) {
- const c = s.getChildren().indexOf(o);
- return {
- functionName: u,
- paramIndex: c
- };
- }
- o = s, s = s.getParent();
- }
- }
- /**
- * Estimate the number of right brackets that need to be automatically added to the end of the formula.
- * @param formulaString
- */
- checkIfAddBracket(e) {
- let t = 0, r = e.length - 1, n = e[r];
- for (; (n === K2.CLOSE_BRACKET || n === " ") && r >= 0; )
- n === K2.CLOSE_BRACKET && t++, n = e[--r];
- const s = this._getCurrentParamIndex(e, e.length - 2);
- if (s == null || s === m2.VALUE)
- return 0;
- const o = s[0];
- if (typeof o == "string")
- return 0;
- let u = o.getParent(), c = 0;
- for (s[1] === K2.OPEN_BRACKET && c++; u; ) {
- const l2 = u.getToken();
- l2 !== ht && l2 !== K2.COLON && u.getStartIndex() !== -1 && l2.toUpperCase() !== Sr && (t === 0 ? c += 1 : t--), u = u.getParent();
- }
- return c;
- }
- sequenceNodesBuilder(e) {
- const t = as.get(e);
- if (t)
- return [...t];
- const r = this._getSequenceArray(e);
- if (r.length === 0)
- return;
- const n = this.getSequenceNode(r);
- return as.set(e, [...n]), n;
- }
- convertRefersToAbsolute(e, t, r, n = "") {
- const s = this.sequenceNodesBuilder(e);
- if (s == null)
- return e;
- let o = "";
- e.substring(0, 1) === X2.EQUALS && (o = X2.EQUALS);
- for (let u = 0, c = s.length; u < c; u++) {
- const l2 = s[u];
- if (typeof l2 != "string" && l2.nodeType === $e.REFERENCE) {
- const { token: f2, endIndex: h } = l2, d2 = mr(f2);
- if (d2 == null)
- continue;
- const { range: _, sheetName: C, unitId: E2 } = d2, b = {
- ..._,
- startAbsoluteRefType: t,
- endAbsoluteRefType: r
- }, R = ys({
- range: b,
- unitId: E2,
- sheetName: C || n
- }), p2 = R.length - f2.length;
- s[u] = {
- ...l2,
- token: R,
- endIndex: h + p2
- };
- for (let N2 = u + 1; N2 < c; N2++) {
- const M2 = s[N2];
- typeof M2 != "string" && (M2.startIndex += p2, M2.endIndex += p2);
- }
- }
- }
- return `${o}${ri(s)}`;
- }
- moveFormulaRefOffset(e, t, r, n = false) {
- const s = this.sequenceNodesBuilder(e);
- if (s == null)
- return e;
- const o = [];
- for (let u = 0, c = s.length; u < c; u++) {
- const l2 = s[u];
- if (typeof l2 == "string" || l2.nodeType !== $e.REFERENCE) {
- o.push(l2);
- continue;
- }
- const { token: f2 } = l2, h = mr(f2), { sheetName: d2, unitId: _ } = h;
- let C = h.range;
- if (!n && C.startAbsoluteRefType === tt.ALL && C.endAbsoluteRefType === tt.ALL) {
- o.push(l2);
- continue;
- } else
- C = jC(C, t, r, n);
- let E2 = "";
- SC(C) ? E2 = ys({
- range: C,
- unitId: _,
- sheetName: d2
- }) : E2 = m2.REF, o.push({
- ...l2,
- token: E2
- });
- }
- return `=${ri(o)}`;
- }
- /**
- * univer-pro/issues/1684
- * =sum({}{})
- */
- _formulaSpellCheck() {
- if (this._currentLexerNode.getChildren().length === 0)
- return true;
- const e = this._currentLexerNode.getChildren()[0];
- return !!(e instanceof ae || Dt.has(e) || rs.has(e) || e === Oe.AT || e === K2.COMMA || e === K2.COLON || e === K2.OPEN_BRACKET);
- }
- // eslint-disable-next-line complexity
- getSequenceNode(e) {
- const t = [];
- let r = false;
- for (let n = 0, s = e.length; n < s; n++) {
- const o = e[n], u = e[n - 1], { segment: c, currentString: l2 } = o;
- if (l2 === K2.DOUBLE_QUOTATION && (r = true), (c !== "" || n === 0) && n !== s - 1) {
- t.push(l2);
- continue;
- }
- let f2 = (u == null ? void 0 : u.segment) || "";
- const h = n - f2.length;
- let d2 = n - 1;
- const _ = n - 1;
- if (n === s - 1 && this._isLastMergeString(l2) && (f2 += l2, d2 += 1), f2 === "" || Jr.has(f2)) {
- t.push(l2);
- continue;
- }
- const C = f2.trim(), E2 = qi(C);
- r === true && C[C.length - 1] === K2.DOUBLE_QUOTATION && C[0] !== K2.OPEN_BRACES ? (r = false, this._processPushSequenceNode(t, $e.STRING, f2, h, d2, _)) : vr(E2) && rn(E2) ? this._processPushSequenceNode(t, $e.REFERENCE, f2, h, d2, _) : re.isStringNumber(C) ? this._processPushSequenceNode(t, $e.NUMBER, f2, h, d2, _) : C.length > 0 && this._processPushSequenceNode(t, $e.FUNCTION, f2, h, d2, _), (n !== s - 1 || !this._isLastMergeString(l2)) && t.push(l2);
- }
- return this._mergeSequenceNodeReference(t);
- }
- _processPushSequenceNode(e, t, r, n, s, o) {
- this._pushSequenceNode(
- e,
- {
- nodeType: t,
- token: r,
- startIndex: n,
- endIndex: s
- },
- o
- );
- }
- _getCurrentParamIndex(e, t) {
- return this._nodeMaker(e, void 0, t);
- }
- _isLastMergeString(e) {
- return e === K2.DOUBLE_QUOTATION || re.isStringNumber(e) || !en2(e);
- }
- /**
- * Merge array and handle ref operations
- *
- */
- _mergeSequenceNodeReference(e) {
- const t = [], r = e.length;
- let n = 0;
- for (; n < r; ) {
- const s = e[n];
- if (typeof s == "string") {
- const o = e[n - 1];
- if (s.trim() === K2.CLOSE_BRACES && o != null && typeof o != "string" && o.nodeType === $e.FUNCTION && o.token.trim().substring(0, 1) === K2.OPEN_BRACES) {
- o.nodeType = $e.ARRAY, o.token += s, o.endIndex += s.length, n++;
- continue;
- }
- t.push(s);
- } else {
- const o = e[n + 1], u = e[n + 2];
- o === K2.COLON && typeof s != "string" && u != null && typeof u != "string" && rn((s.token + o + u.token).trim()) && (s.nodeType = $e.REFERENCE, s.token += o + u.token, s.endIndex = u.endIndex, n += 2), t.push(s);
- }
- n++;
- }
- return this._minusSplitSequenceNode(t);
- }
- /**
- * =-A1 Separate the negative sign from the ref string.
- */
- _minusSplitSequenceNode(e) {
- const t = [];
- for (const r of e) {
- if (typeof r != "string") {
- const s = r.token.match(/^(\s*([-@+]\s*)+)(.*)$/);
- if (s) {
- const o = s[1], u = s[3];
- if (rn(u.trim())) {
- const c = o.length, l2 = r.startIndex, f2 = r.startIndex + c - 1, h = {
- nodeType: $e.NORMAL,
- // Use appropriate nodeType for operators
- token: o,
- startIndex: l2,
- endIndex: f2
- }, d2 = {
- nodeType: $e.REFERENCE,
- token: u,
- startIndex: f2 + 1,
- endIndex: r.endIndex
- };
- t.push(h), t.push(d2);
- continue;
- }
- }
- }
- t.push(r);
- }
- return t;
- }
- _pushSequenceNode(e, t, r) {
- const n = r - t.startIndex + 1;
- e.splice(e.length - n, n, t);
- }
- nodeMakerTest(e) {
- return this._nodeMaker(e);
- }
- treeBuilder(e, t = true, r, n) {
- if (t === true) {
- const h = ss.get(e), d2 = n == null ? void 0 : n(e);
- if (h && !d2)
- return h;
- }
- this._resetCurrentLexerNode(), this._currentLexerNode.setToken(Ut);
- const s = [];
- let o = this._nodeMaker(e, s);
- if (o === m2.VALUE || s.length === 0)
- return o;
- let u = false, c = "", l2 = [];
- if (r) {
- const { hasDefinedName: h, sequenceString: d2, definedNames: _ } = r(s);
- u = h, c = d2, l2 = _;
- }
- if (u && (this._resetCurrentLexerNode(), this._currentLexerNode.setToken(Ut), o = this._nodeMaker(`=${c}`), o === m2.VALUE))
- return o;
- const f2 = this._getTopNode(this._currentLexerNode);
- if (f2 && (this._currentLexerNode = f2), t) {
- if (!this._suffixExpressionHandler(this._currentLexerNode))
- return m2.VALUE;
- ss.set(e, this._currentLexerNode);
- }
- return u && this._currentLexerNode.setDefinedNames(l2), this._currentLexerNode;
- }
- // eslint-disable-next-line complexity
- _suffixExpressionHandler(e) {
- var u;
- const t = e.getChildren();
- if (!t)
- return false;
- const r = t.length, n = [], s = [];
- let o = true;
- for (let c = 0; c < r; c++) {
- const l2 = t[c];
- if (l2 instanceof ae)
- o = this._suffixExpressionHandler(l2), n.push(l2);
- else {
- const f2 = l2.trim();
- if (f2 === "")
- continue;
- if (Dt.has(f2)) {
- if (f2 === X2.PLUS && this._deletePlusForPreNode(t[c - 1]))
- continue;
- if (f2 !== X2.PLUS && f2 !== X2.MINUS && this._deletePlusForPreNode(t[c - 1]))
- return false;
- for (; s.length > 0; ) {
- const h = (u = s[s.length - 1]) == null ? void 0 : u.trim();
- if (!h || h === K2.OPEN_BRACKET)
- break;
- const d2 = Jr.get(h), _ = Jr.get(f2);
- if (!d2 || !_)
- break;
- if (_ >= d2)
- n.push(s.pop());
- else
- break;
- }
- s.push(l2);
- } else if (f2 === K2.OPEN_BRACKET)
- s.push(l2);
- else if (f2 === K2.CLOSE_BRACKET)
- this._processSuffixExpressionCloseBracket(n, s, t, c);
- else {
- if (this._checkCloseBracket(t[c - 1]))
- return false;
- n.push(l2);
- }
- }
- }
- return o ? this._processSuffixExpressionRemain(n, s, e) : false;
- }
- _processSuffixExpressionRemain(e, t, r) {
- const n = e.length, s = e[n - 1];
- for (; t.length > 0; ) {
- const o = t.pop();
- if (!(s instanceof ae) && (o === K2.OPEN_BRACKET || o === K2.CLOSE_BRACKET))
- return false;
- e.push(o);
- }
- return r.setChildren(e), true;
- }
- _processSuffixExpressionCloseBracket(e, t, r, n) {
- var s;
- if (this._checkOpenBracket(r[n - 1]) || this._checkOperator(r[n - 1]))
- return false;
- for (; t.length > 0; ) {
- const o = (s = t[t.length - 1]) == null ? void 0 : s.trim();
- if (!o)
- break;
- if (o === K2.OPEN_BRACKET) {
- t.pop();
- break;
- }
- e.push(t.pop());
- }
- }
- _checkCloseBracket(e) {
- return e === K2.CLOSE_BRACKET || e instanceof ae;
- }
- _checkOpenBracket(e) {
- return e === K2.OPEN_BRACKET;
- }
- _checkOperator(e) {
- return e == null || e instanceof ae ? false : Dt.has(e);
- }
- _deletePlusForPreNode(e) {
- if (e == null)
- return true;
- if (!(e instanceof ae)) {
- const t = e.trim();
- if (Dt.has(t) || t === K2.OPEN_BRACKET)
- return true;
- }
- return false;
- }
- _resetCurrentLexerNode() {
- this._currentLexerNode = new ae();
- }
- _resetSegment() {
- this._segment = "";
- }
- _openBracket(e = 0) {
- this._bracketState.push(e);
- }
- _closeBracket() {
- this._bracketState.pop();
- }
- _openSquareBracket() {
- this._squareBracketState += 1;
- }
- _closeSquareBracket() {
- this._squareBracketState -= 1;
- }
- _getCurrentBracket() {
- const e = this._bracketState;
- return e[e.length - 1];
- }
- _changeCurrentBracket(e) {
- const t = this._bracketState;
- t[t.length - 1] = e;
- }
- _openBraces() {
- this._bracesState += 1;
- }
- _closeBraces() {
- this._bracesState -= 1;
- }
- _openSingleQuotation() {
- this._singleQuotationState += 1;
- }
- _closeSingleQuotation() {
- this._singleQuotationState -= 1;
- }
- _openDoubleQuotation() {
- this._doubleQuotationState += 1;
- }
- _closeDoubleQuotation() {
- this._doubleQuotationState -= 1;
- }
- _openLambda() {
- this._lambdaState = true;
- }
- _closeLambda() {
- this._lambdaState = false;
- }
- _openColon(e) {
- this._upLevel = e, this._colonState = true;
- }
- _closeColon() {
- this._upLevel = 0, this._colonState = false;
- }
- _isTableBracket() {
- return this._tableBracketState;
- }
- _openTableBracket() {
- this._tableBracketState = true;
- }
- _closeTableBracket() {
- this._tableBracketState = false;
- }
- _formalErrorOccurred() {
- this._formulaErrorCount += 1;
- }
- _hasFormalError() {
- return this._formulaErrorCount > 0;
- }
- _getLastChildCurrentLexerNode() {
- const e = this._currentLexerNode.getChildren();
- if (e && e.length > 0) {
- const t = e[e.length - 1];
- if (t instanceof ae)
- return t;
- }
- return false;
- }
- _getLastChildCurrent() {
- const e = this._currentLexerNode.getChildren();
- return e && e.length > 0 ? e[e.length - 1] : false;
- }
- _setParentCurrentLexerNode() {
- const e = this._currentLexerNode.getParent();
- return e ? (this._currentLexerNode = e, true) : false;
- }
- _setAncestorCurrentLexerNode() {
- var r, n, s, o, u, c;
- const e = (r = this._currentLexerNode) == null ? void 0 : r.getParent();
- let t = false;
- if (e && e.getToken() === hr) {
- if ((n = e == null ? void 0 : e.getParent()) != null && n.getParent()) {
- const l2 = (o = (s = this._currentLexerNode.getParent()) == null ? void 0 : s.getParent()) == null ? void 0 : o.getParent();
- l2 && (this._currentLexerNode = l2), t = true;
- }
- } else if (e != null && e.getParent()) {
- const l2 = (u = this._currentLexerNode.getParent()) == null ? void 0 : u.getParent();
- l2 && (this._currentLexerNode = l2), t = true;
- }
- for (let l2 = 0; l2 < this._upLevel; l2++) {
- const f2 = (c = this._currentLexerNode) == null ? void 0 : c.getParent();
- f2 && (this._currentLexerNode = f2), this._currentLexerNode ? t = true : t = false;
- }
- return t;
- }
- _segmentCount() {
- return this._segment.trim().length;
- }
- _pushSegment(e) {
- this._segment += e;
- }
- _pushNodeToChildren(e, t = false) {
- let r = e;
- if (r !== "") {
- const n = this._currentLexerNode.getChildren();
- if (!(r instanceof ae) && this.isColonOpen()) {
- const s = new ae();
- s.setToken(r), s.setParent(this._currentLexerNode), r = s;
- }
- t ? n.unshift(r) : n.push(r);
- }
- this.isColonOpen() && (this._setAncestorCurrentLexerNode(), this._closeColon());
- }
- _setCurrentLexerNode(e, t = false) {
- this._pushNodeToChildren(e, t), e.setParent(this._currentLexerNode), this._currentLexerNode = e;
- }
- _newAndPushCurrentLexerNode(e, t, r = false) {
- const n = new ae();
- n.setToken(e), n.setIndex(t - e.length, t - 1), this._setCurrentLexerNode(n, r);
- }
- _getTopNode(e) {
- let t = e;
- for (; t != null && t.getParent(); )
- t = t.getParent();
- return t;
- }
- _removeLastChild() {
- this._currentLexerNode.getChildren().splice(-1);
- }
- /**
- * fix univer-pro/issues/2447
- * =1/3+
- * =+
- * =sum(A1+)
- */
- _formulaErrorLastTokenCheck(e, t) {
- const r = this._findPreviousToken(e, t) || "", n = e.length - 1 === t;
- if (!n && this._isOperatorToken(r) || n && sc(r))
- return true;
- if (rs.has(r)) {
- const s = this._findSecondLastNonSpaceToken(e, t);
- if (s == null || ic(s))
- return true;
- }
- return false;
- }
- _findPreviousToken(e, t) {
- let r = t;
- for (; r >= 0; ) {
- const n = e[r];
- if (n !== " ")
- return n;
- r--;
- }
- }
- _findSecondLastNonSpaceToken(e, t) {
- let r = t, n = 0;
- for (; r >= 0; ) {
- const s = e[r];
- if (s !== " " && (n++, n === 2))
- return s;
- r--;
- }
- return null;
- }
- _findNextToken(e, t) {
- let r = t;
- for (; r >= 0; ) {
- const n = e[r];
- if (n !== " ")
- return n;
- r++;
- }
- }
- _unexpectedEndingTokenExcludeOperator(e) {
- return (
- // OPERATOR_TOKEN_SET.has(prevString) ||
- e === K2.OPEN_BRACKET || e === K2.COMMA || e === X2.EQUALS || e === ""
- );
- }
- _unexpectedEndingToken(e) {
- return !!(this._isOperatorToken(e) || this._unexpectedEndingTokenExcludeOperator(e));
- }
- _isOperatorToken(e) {
- return !!Dt.has(e);
- }
- _getSequenceArray(e) {
- const t = [];
- return this._nodeMaker(e, t), t;
- }
- _resetTemp() {
- this._currentLexerNode = new ae(), this._upLevel = 0, this._segment = "", this._bracketState = [], this._bracesState = 0, this._singleQuotationState = 0, this._doubleQuotationState = 0, this._lambdaState = false, this._colonState = false, this._formulaErrorCount = 0;
- }
- _checkErrorState() {
- return !!(this._bracketState.length > 0 || this._bracesState > 0 || this._singleQuotationState > 0 || this._doubleQuotationState > 0 || this._hasFormalError());
- }
- _checkSimilarErrorToken(e, t, r) {
- let n = t;
- if (e !== ze.POUND)
- return true;
- let s = r[++n];
- for (; s === " "; )
- s = r[++n];
- return !!en2(s);
- }
- _checkIfErrorObject(e, t) {
- return !!this._findErrorObject(e, t);
- }
- _findErrorObject(e, t) {
- for (let r = 0; r < Ga.length; r++) {
- const n = Ga[r], s = t.slice(e, e + n).join("").toUpperCase();
- if (yr.has(s))
- return s;
- }
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- _nodeMaker(e, t, r) {
- let n = e.replace(/\r\n$/, "").replace(/\r/g, " ").replace(/\n/g, " ");
- n.substring(0, 1) === X2.EQUALS && (n = n.substring(1));
- const s = n.split(""), o = s.length;
- let u = 0;
- for (this._resetTemp(), this._formulaErrorLastTokenCheck(s, o - 1) && this._formalErrorOccurred(); u < o; ) {
- const c = s[u];
- if (r === u)
- return [this._currentLexerNode, c];
- if (c === ze.POUND && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isBracesClose() && this.isSquareBracketClose() && this._checkIfErrorObject(u, s)) {
- const l2 = this._findErrorObject(u, s);
- if (l2 == null)
- return m2.VALUE;
- this._pushNodeToChildren(l2);
- for (let f2 = 0; f2 < l2.length; f2++) {
- const h = s[u];
- this._pushSegment(h), this._addSequenceArray(t, h, u), u++;
- }
- this._resetSegment();
- continue;
- } else if (c === K2.OPEN_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
- if (this._segmentCount() > 0 || this.isLambdaOpen()) {
- this.isLambdaClose() && (this._newAndPushCurrentLexerNode(this._segment, u), this._resetSegment()), this._openBracket(
- 1
- /* FUNCTION */
- ), this._closeLambda();
- const l2 = s[u + 1];
- if (l2 && l2 === K2.CLOSE_BRACKET) {
- if (!this._setParentCurrentLexerNode() && u !== o - 1)
- return m2.VALUE;
- this._addSequenceArray(t, c, u), u++, this._addSequenceArray(t, l2, u), u++, this._closeBracket();
- continue;
- } else
- l2 && this._newAndPushCurrentLexerNode(ht, u);
- } else
- this._pushNodeToChildren(c), this._openBracket(
- 0
- /* NORMAL */
- ), this._resetSegment();
- else if (c === K2.CLOSE_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) {
- this._formulaErrorLastTokenCheck(s, u - 1) && this._formalErrorOccurred(), this._pushNodeToChildren(this._segment), this._resetSegment();
- const l2 = this._getCurrentBracket();
- if (l2 === 0)
- this._pushNodeToChildren(c);
- else if (l2 === 1) {
- const f2 = s[u + 1];
- if (f2 && f2 === K2.OPEN_BRACKET) {
- if (!this._setParentCurrentLexerNode() && u !== o - 1)
- return m2.VALUE;
- this._newAndPushCurrentLexerNode(hr, u, true), this._openLambda();
- } else if (!this._setAncestorCurrentLexerNode() && u !== o - 1)
- return m2.VALUE;
- } else
- return m2.VALUE;
- this._closeBracket();
- } else if (c === K2.OPEN_BRACES && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) {
- if (this._pushSegment(c), this._openBraces(), !this._formulaSpellCheck())
- return m2.VALUE;
- } else if (c === K2.CLOSE_BRACES && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
- this._pushSegment(c), this._pushNodeToChildren(this._segment), this._resetSegment(), this._closeBraces();
- else if (c === K2.OPEN_SQUARE_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
- this._segment.length > 0 && this._openTableBracket(), this._pushSegment(c), this._openSquareBracket();
- else if (c === K2.CLOSE_SQUARE_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
- this._closeSquareBracket(), this.isSquareBracketClose() ? (this._pushSegment(c), this._isTableBracket() && (this._pushNodeToChildren(this._segment), this._resetSegment()), this._closeTableBracket()) : this._pushSegment(c);
- else if (c === K2.DOUBLE_QUOTATION && this.isSingleQuotationClose() && this.isSquareBracketClose()) {
- if (this.isDoubleQuotationClose())
- this._openDoubleQuotation();
- else {
- const l2 = s[u + 1];
- l2 && l2 === K2.DOUBLE_QUOTATION ? u++ : this._closeDoubleQuotation();
- }
- this._pushSegment(c);
- } else if (c === K2.SINGLE_QUOTATION && this.isDoubleQuotationClose()) {
- if (this.isSingleQuotationClose())
- this._openSingleQuotation(), this._segmentCount() === 0 && this._resetSegment();
- else {
- const l2 = s[u + 1];
- if (l2 && l2 === K2.SINGLE_QUOTATION) {
- this._pushSegment(c), this._addSequenceArray(t, c, u), u++, this._pushSegment(l2), this._addSequenceArray(t, l2, u), u++;
- continue;
- } else
- this._closeSingleQuotation();
- }
- this._pushSegment(c);
- } else if (c === K2.COMMA && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isBracesClose() && this.isSquareBracketClose()) {
- this._formulaErrorLastTokenCheck(s, u - 1) && this._formalErrorOccurred();
- const l2 = this._getCurrentBracket();
- if (l2 === 1 || l2 == null) {
- if (this._pushNodeToChildren(this._segment), this._resetSegment(), !this._setParentCurrentLexerNode() && u !== o - 1 && l2 != null)
- return m2.VALUE;
- this._newAndPushCurrentLexerNode(ht, u);
- } else {
- const f2 = new ae();
- f2.setToken(Tc);
- const h = new ae();
- h.setToken(ht), h.changeToParent(f2);
- const d2 = this._currentLexerNode.getParent();
- if (d2 && d2.getToken() === K2.COLON) {
- const _ = d2.getParent();
- if (!_)
- return m2.VALUE;
- d2.changeToParent(h), _.setChildren([]), f2.changeToParent(_);
- } else
- return m2.VALUE;
- this._changeCurrentBracket(
- 1
- /* FUNCTION */
- ), this._pushNodeToChildren(this._segment), this._resetSegment(), this._currentLexerNode = f2, this._newAndPushCurrentLexerNode(ht, u);
- }
- } else if (c === K2.COLON && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isBracesClose() && this.isSquareBracketClose()) {
- const l2 = new ae();
- l2.setToken(c);
- const f2 = new ae();
- f2.setToken(ht), f2.setParent(l2);
- const h = new ae();
- h.setToken(ht), h.setParent(l2), l2.getChildren().push(f2, h);
- let d2 = l2, _ = 0;
- if (this._segmentCount() > 0) {
- let C, E2, b = 0;
- const R = this._segment.trim(), p2 = R[0], N2 = R[1];
- if (p2 === Oe.MINUS && (C = new ae(), C.setToken(Oe.MINUS), b++), (p2 === Oe.AT || N2 === Oe.AT) && (E2 = new ae(), E2.setToken(Oe.AT), C && (C.addChildren(E2), E2.setParent(C)), b++), b > 0 && (this._segment = R.slice(b)), _ = b, E2)
- if (E2.addChildren(l2), l2.setParent(E2), E2.getParent()) {
- const w = E2.getParent();
- w && (d2 = w);
- } else
- d2 = E2;
- else
- C && (d2 = C, C.addChildren(l2), l2.setParent(C));
- const M2 = new ae();
- M2.setToken(this._segment), M2.setParent(f2), f2.getChildren().push(M2), this._resetSegment();
- } else {
- const C = this._getLastChildCurrentLexerNode();
- C && C.changeToParent(f2);
- }
- this._setCurrentLexerNode(d2), this._currentLexerNode = h, this._openColon(_);
- } else if (rs.has(c) && this._checkSimilarErrorToken(c, u, s) && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose() && this.isBracesClose()) {
- this._pushNodeToChildren(this._segment);
- const l2 = new ae();
- l2.setToken(c);
- const f2 = this._getLastChildCurrent();
- f2 instanceof ae ? f2.changeToParent(l2) : f2 !== false && (l2.getChildren().push(f2), this._removeLastChild()), this._pushNodeToChildren(l2), l2.setParent(this._currentLexerNode), this._resetSegment();
- } else if (Dt.has(c) && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose() && this.isBracesClose()) {
- let l2 = this._segment.trim();
- if (c === X2.MINUS && l2 === "") {
- const f2 = this._findPreviousToken(s, u - 1) || "", h = this._findNextToken(s, u + 1) || "";
- if (this._unexpectedEndingTokenExcludeOperator(f2) && this._isOperatorToken(h)) {
- this._pushNodeToChildren("0"), this._pushNodeToChildren(X2.MINUS), this._addSequenceArray(t, c, u), this._resetSegment(), u++;
- continue;
- } else if (this._unexpectedEndingToken(f2))
- if (h === X2.PLUS) {
- this._pushSegment(X2.MINUS), this._addSequenceArray(t, c, u), this._addSequenceArray(t, X2.PLUS, u + 1), u += 2;
- continue;
- } else {
- this._pushSegment(X2.MINUS), this._addSequenceArray(t, c, u), u++;
- continue;
- }
- } else if (this._segment.length > 0 && this._isScientificNotation(s, u, c)) {
- this._pushSegment(c), this._addSequenceArray(t, c, u), u++;
- continue;
- } else
- this._segment.length > 0 && l2 === "" ? l2 = this._segment : (this._pushNodeToChildren(this._segment), l2 = "");
- if (c === X2.LESS_THAN || c === X2.GREATER_THAN) {
- const f2 = s[u + 1];
- if (f2 && Dt.has(c + f2)) {
- this._pushNodeToChildren(l2 + c + f2), this._resetSegment(), this._addSequenceArray(t, c, u), u++, this._addSequenceArray(t, f2, u), u++;
- continue;
- } else
- this._pushNodeToChildren(l2 + c);
- } else
- this._pushNodeToChildren(l2 + c);
- this._resetSegment();
- } else
- this._pushSegment(c);
- this._addSequenceArray(t, c, u), u++;
- }
- if (this._pushNodeToChildren(this._segment), this._checkErrorState())
- return m2.VALUE;
- }
- _isScientificNotation(e, t, r) {
- const n = e[t - 2];
- if (n && Number.isNaN(Number(n)) || !(r === X2.MINUS || r === X2.PLUS))
- return false;
- const s = e[t + 1];
- if (s && Number.isNaN(Number(s)))
- return false;
- const o = e[t - 1];
- return o && o.toUpperCase() === "E";
- }
- _addSequenceArray(e, t, r) {
- e == null || e.push({
- segment: this._segment,
- currentString: t,
- cur: r,
- currentLexerNode: this._currentLexerNode
- });
- }
- };
- function Fc(i, a2, e, t, r, n, s) {
- const o = (s == null ? void 0 : s.f) || "", u = (s == null ? void 0 : s.si) || "", c = vC(o), l2 = yC(u), f2 = i.getValue(r, n), h = (f2 == null ? void 0 : f2.f) || "", d2 = (f2 == null ? void 0 : f2.si) || "";
- function _() {
- var C;
- if (vC(h) && yC(d2)) {
- const E2 = (C = e == null ? void 0 : e[d2]) == null ? void 0 : C.f;
- E2 ? t.set(d2, E2) : t.set(d2, h);
- }
- }
- c && l2 ? (d2 !== u && _(), i.setValue(r, n, {
- f: o,
- si: u
- }), e[u] = { f: o, r, c: n }, a2.setValue(r, n, {
- f: o,
- si: u
- })) : c && !l2 ? (h !== o && _(), i.setValue(r, n, {
- f: o
- }), a2.setValue(r, n, {
- f: o
- })) : !c && l2 ? (d2 !== u && _(), i.setValue(r, n, {
- f: "",
- si: u
- })) : !c && !l2 && i.getValue(r, n) && (_(), i.realDeleteValue(r, n), a2.setValue(r, n, null));
- }
- function kc(i, a2, e, t) {
- const r = i == null ? void 0 : i.getValue(e, t);
- if (r == null)
- return true;
- const n = [];
- i.forValue((l2, f2, h) => {
- l2 === e && f2 === t || en.intersects(h, r) && n.push(h);
- });
- const { startRow: s, startColumn: o, endRow: u, endColumn: c } = r;
- for (let l2 = s; l2 <= u; l2++)
- for (let f2 = o; f2 <= c; f2++) {
- let h = false;
- const d2 = AC(l2, f2);
- n.some((_) => en.contains(_, d2) ? (h = true, true) : false), h || a2.realDeleteValue(l2, f2);
- }
- }
- var $c = Object.defineProperty;
- var Yc = Object.getOwnPropertyDescriptor;
- var Hc = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Yc(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && $c(a2, e, r), r;
- };
- var ni = (i, a2) => (e, t) => a2(e, t, i);
- var Pr = class extends nt {
- constructor(a2, e) {
- super();
- A(this, "_arrayFormulaRange", {});
- A(this, "_arrayFormulaCellData", {});
- this._univerInstanceService = a2, this._lexerTreeBuilder = e;
- }
- dispose() {
- super.dispose(), this._arrayFormulaRange = {}, this._arrayFormulaCellData = {};
- }
- clearPreviousArrayFormulaCellData(a2) {
- Object.keys(a2).forEach((e) => {
- const t = a2[e];
- if (t == null)
- return true;
- Object.keys(t).forEach((r) => {
- var c, l2, f2, h;
- const n = t[r], s = (l2 = (c = this._arrayFormulaRange) == null ? void 0 : c[e]) == null ? void 0 : l2[r];
- if (s == null)
- return true;
- const o = new kt(s);
- let u = new kt();
- ((f2 = this._arrayFormulaCellData[e]) == null ? void 0 : f2[r]) != null && (u = new kt(
- (h = this._arrayFormulaCellData[e]) == null ? void 0 : h[r]
- )), n.forValue((d2, _) => {
- const C = o.getValue(d2, _);
- if (C == null)
- return true;
- const { startRow: E2, startColumn: b, endRow: R, endColumn: p2 } = C;
- for (let N2 = E2; N2 <= R; N2++)
- for (let M2 = b; M2 <= p2; M2++)
- u.setValue(N2, M2, null);
- o.realDeleteValue(d2, _);
- }), this._arrayFormulaCellData[e] && (this._arrayFormulaCellData[e][r] = u.getData());
- });
- });
- }
- mergeArrayFormulaCellData(a2) {
- Object.keys(a2).forEach((e) => {
- const t = a2[e];
- if (t == null)
- return true;
- this._arrayFormulaRange[e] == null && (this._arrayFormulaRange[e] = {}), this._arrayFormulaCellData[e] == null && (this._arrayFormulaCellData[e] = {}), Object.keys(t).forEach((r) => {
- var u, c;
- const n = t[r], s = new kt((u = this._arrayFormulaRange[e]) == null ? void 0 : u[r]), o = new kt((c = this._arrayFormulaCellData[e]) == null ? void 0 : c[r]);
- n.forValue((l2, f2) => {
- const h = s == null ? void 0 : s.getValue(l2, f2);
- if (h == null)
- return true;
- const { startRow: d2, startColumn: _, endRow: C, endColumn: E2 } = h;
- for (let b = d2; b <= C; b++)
- for (let R = _; R <= E2; R++)
- o.setValue(b, R, null);
- }), n.forValue((l2, f2, h) => {
- o.setValue(l2, f2, h);
- }), this._arrayFormulaCellData[e] && (this._arrayFormulaCellData[e][r] = o.getData());
- });
- });
- }
- getFormulaData() {
- const a2 = {}, e = this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET);
- return e.length === 0 || e.forEach((t) => {
- const r = t.getUnitId();
- a2[r] = {}, t.getSheets().forEach((s) => {
- const o = s.getCellMatrix(), u = s.getSheetId();
- si(a2, r, u, o);
- });
- }), a2;
- }
- getSheetFormulaData(a2, e) {
- const t = {}, r = this._univerInstanceService.getUnit(a2);
- if (r == null)
- return {};
- t[a2] = {};
- const n = r.getSheetBySheetId(e);
- if (n == null)
- return {};
- const s = n.getCellMatrix();
- return si(t, a2, e, s), t[a2][e];
- }
- getArrayFormulaRange() {
- return this._arrayFormulaRange;
- }
- setArrayFormulaRange(a2) {
- this._arrayFormulaRange = a2;
- }
- getArrayFormulaCellData() {
- return this._arrayFormulaCellData;
- }
- setArrayFormulaCellData(a2) {
- this._arrayFormulaCellData = a2;
- }
- mergeArrayFormulaRange(a2) {
- Object.keys(a2).forEach((e) => {
- const t = a2[e];
- if (t == null)
- return true;
- this._arrayFormulaRange[e] || (this._arrayFormulaRange[e] = {}), Object.keys(t).forEach((r) => {
- var o;
- const n = new kt(t[r]), s = new kt((o = this._arrayFormulaRange[e]) == null ? void 0 : o[r]);
- n.forValue((u, c, l2) => {
- s.setValue(u, c, l2);
- }), this._arrayFormulaRange[e] && (this._arrayFormulaRange[e][r] = s.getData());
- });
- });
- }
- deleteArrayFormulaRange(a2, e, t, r) {
- var o;
- const n = (o = this._arrayFormulaRange[a2]) == null ? void 0 : o[e];
- if (n == null)
- return;
- const s = new kt(n);
- s.getValue(t, r) && (s.realDeleteValue(t, r), this._arrayFormulaRange[a2] && (this._arrayFormulaRange[a2][e] = s.getData()));
- }
- getCalculateData() {
- const a2 = this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET), e = {}, t = {};
- for (const r of a2) {
- const n = r.getUnitId(), s = r.getSheets(), o = {}, u = {};
- for (const c of s) {
- const l2 = c.getSheetId(), f2 = c.getConfig();
- o[l2] = {
- cellData: new kt(f2.cellData),
- rowCount: f2.rowCount,
- columnCount: f2.columnCount,
- rowData: f2.rowData,
- columnData: f2.columnData,
- defaultRowHeight: f2.defaultRowHeight,
- defaultColumnWidth: f2.defaultColumnWidth
- }, u[c.getName()] = c.getSheetId();
- }
- e[n] = o, t[n] = u;
- }
- return {
- allUnitData: e,
- unitSheetNameMap: t
- };
- }
- updateFormulaData(a2, e, t) {
- const r = new kt(t), n = this._getSheetFormulaIdMap(a2, e), s = /* @__PURE__ */ new Map(), o = this.getFormulaData();
- o[a2] == null && (o[a2] = {});
- const u = o[a2];
- u[e] == null && (u[e] = {});
- const c = new kt(u[e] || {}), l2 = new kt();
- return r.forValue((f2, h, d2) => {
- Fc(c, l2, n, s, f2, h, d2);
- }), c.forValue((f2, h, d2) => {
- const _ = (d2 == null ? void 0 : d2.f) || "", C = (d2 == null ? void 0 : d2.si) || "";
- if (yC(C)) {
- const E2 = n == null ? void 0 : n[C], b = s.get(C);
- if (E2 && !vC(_)) {
- const R = E2.f, p2 = h - E2.c, N2 = f2 - E2.r;
- c.setValue(f2, h, { f: R, si: C, x: p2, y: N2 }), l2.setValue(f2, h, { f: R, si: C, x: p2, y: N2 });
- } else if (typeof b == "string") {
- const R = (d2 == null ? void 0 : d2.x) || 0, p2 = (d2 == null ? void 0 : d2.y) || 0, N2 = this._lexerTreeBuilder.moveFormulaRefOffset(b, R, p2);
- s.set(C, { r: f2, c: h, f: N2 }), c.setValue(f2, h, { f: N2, si: C }), l2.setValue(f2, h, { f: N2, si: C });
- } else if (typeof b == "object") {
- const R = h - b.c, p2 = f2 - b.r;
- c.setValue(f2, h, { f: b.f, si: C, x: R, y: p2 }), l2.setValue(f2, h, { f: b.f, si: C, x: R, y: p2 });
- }
- }
- }), l2.getMatrix();
- }
- updateArrayFormulaRange(a2, e, t) {
- var o;
- const r = (o = this._arrayFormulaRange[a2]) == null ? void 0 : o[e];
- if (!r)
- return;
- const n = new kt(r);
- new kt(t).forValue((u, c, l2) => {
- n.realDeleteValue(u, c);
- });
- }
- updateArrayFormulaCellData(a2, e, t) {
- var c, l2;
- const r = (c = this._arrayFormulaRange[a2]) == null ? void 0 : c[e];
- if (!r)
- return;
- const n = new kt(r), s = (l2 = this._arrayFormulaCellData[a2]) == null ? void 0 : l2[e];
- if (!s)
- return;
- const o = new kt(s);
- new kt(t).forValue((f2, h, d2) => {
- kc(n, o, f2, h);
- });
- }
- getFormulaStringByCell(a2, e, t, r) {
- const n = this._univerInstanceService.getUnit(r);
- if (n == null)
- return null;
- const s = n.getSheetBySheetId(t);
- if (s == null)
- return null;
- const o = s.getCellMatrix(), u = o.getValue(a2, e);
- if (u == null)
- return null;
- const { f: c, si: l2 } = u;
- if (vC(c))
- return c;
- if (yC(l2)) {
- let f2 = null;
- return o.forValue((h, d2, _) => {
- if (_ == null)
- return true;
- const { f: C, si: E2 } = _;
- if (vC(C) && l2 === E2)
- return f2 = this._lexerTreeBuilder.moveFormulaRefOffset(
- C,
- e - d2,
- a2 - h
- ), false;
- }), f2;
- }
- return null;
- }
- /**
- * Function to get all formula ranges
- * @returns
- */
- getFormulaDirtyRanges() {
- const a2 = this.getFormulaData(), e = [];
- for (const t in a2) {
- const r = a2[t];
- if (!r)
- continue;
- const n = this._univerInstanceService.getUnit(t);
- if (n)
- for (const s in r) {
- const o = r[s];
- if (!o)
- continue;
- const u = n.getSheetBySheetId(s);
- if (!u)
- continue;
- const c = {};
- for (const l2 of Object.keys(o)) {
- const f2 = Number(l2);
- for (const h in o[f2]) {
- const d2 = Number(h), _ = u.getCellRaw(f2, d2), C = vC(_ == null ? void 0 : _.f) || yC(_ == null ? void 0 : _.si), E2 = (_ == null ? void 0 : _.v) === void 0;
- if (!(C && E2))
- continue;
- c[d2] || (c[d2] = []);
- const b = c[d2].slice(-1)[0];
- b && b.endRow === f2 - 1 ? b.endRow = f2 : c[d2].push({ startRow: f2, endRow: f2 });
- }
- }
- for (const l2 in c) {
- const f2 = c[l2];
- for (let h = 0; h < f2.length; h++) {
- const d2 = f2[h];
- e.push({
- unitId: t,
- sheetId: s,
- range: {
- rangeType: De.NORMAL,
- startRow: d2.startRow,
- endRow: d2.endRow,
- // Use endRow as the inclusive end row
- startColumn: Number(l2),
- endColumn: Number(l2)
- }
- });
- }
- }
- }
- }
- return e;
- }
- _getSheetFormulaIdMap(a2, e) {
- const t = {}, r = this._univerInstanceService.getUnit(a2);
- if (r == null)
- return t;
- const n = r.getSheetBySheetId(e);
- return n == null || n.getCellMatrix().forValue((o, u, c) => {
- if (c == null)
- return true;
- const { f: l2, si: f2 } = c;
- vC(l2) && yC(f2) && (t[f2] = { f: l2, r: o, c: u });
- }), t;
- }
- };
- Pr = Hc([
- ni(0, _n),
- ni(1, ot(ca))
- ], Pr);
- function si(i, a2, e, t) {
- i[a2] || (i[a2] = {}), i[a2][e] || (i[a2][e] = {});
- const r = /* @__PURE__ */ new Map(), n = new kt(i[a2][e]);
- t.forValue((o, u, c) => {
- const l2 = (c == null ? void 0 : c.f) || "", f2 = (c == null ? void 0 : c.si) || "", h = vC(l2), d2 = yC(f2);
- h && d2 ? (n.setValue(o, u, {
- f: l2,
- si: f2
- }), r.set(f2, { f: l2, r: o, c: u })) : h && !d2 ? n.setValue(o, u, {
- f: l2
- }) : !h && d2 && n.setValue(o, u, {
- f: "",
- si: f2
- });
- }), n.forValue((o, u, c) => {
- const l2 = (c == null ? void 0 : c.f) || "", f2 = (c == null ? void 0 : c.si) || "";
- if (yC(f2) && !vC(l2)) {
- const h = r.get(f2);
- if (h) {
- const d2 = h.f, _ = u - h.c, C = o - h.r;
- n.setValue(o, u, { f: d2, si: f2, x: _, y: C });
- } else
- n.realDeleteValue(o, u);
- }
- });
- const s = n.getMatrix();
- return {
- [a2]: {
- [e]: s
- }
- };
- }
- var Gc = class Ms {
- /**
- * Accept two comparable values and creates new instance of interval
- * Predicate Interval.comparable_less(low, high) supposed to return true on these values
- * @param low
- * @param high
- */
- constructor(a2, e) {
- this.low = a2, this.high = e;
- }
- /**
- * Clone interval
- * @returns {Interval}
- */
- clone() {
- return new Ms(this.low, this.high);
- }
- /**
- * Propery max returns clone of this interval
- * @returns {Interval}
- */
- get max() {
- return this.clone();
- }
- /**
- * Predicate returns true is this interval less than other interval
- * @param other_interval
- * @returns {boolean}
- */
- less_than(a2) {
- return this.low < a2.low || this.low === a2.low && this.high < a2.high;
- }
- /**
- * Predicate returns true is this interval equals to other interval
- * @param other_interval
- * @returns {boolean}
- */
- equal_to(a2) {
- return this.low === a2.low && this.high === a2.high;
- }
- /**
- * Predicate returns true if this interval intersects other interval
- * @param other_interval
- * @returns {boolean}
- */
- intersect(a2) {
- return !this.not_intersect(a2);
- }
- /**
- * Predicate returns true if this interval does not intersect other interval
- * @param other_interval
- * @returns {boolean}
- */
- not_intersect(a2) {
- return this.high < a2.low || a2.high < this.low;
- }
- /**
- * Returns new interval merged with other interval
- * @param {Interval} other_interval - Other interval to merge with
- * @returns {Interval}
- */
- merge(a2) {
- return new Ms(
- this.low === void 0 ? a2.low : this.low < a2.low ? this.low : a2.low,
- this.high === void 0 ? a2.high : this.high > a2.high ? this.high : a2.high
- );
- }
- /**
- * Returns how key should return
- */
- output() {
- return [this.low, this.high];
- }
- /**
- * Function returns maximum between two comparable values
- * @param interval1
- * @param interval2
- * @returns {Interval}
- */
- static comparable_max(a2, e) {
- return a2.merge(e);
- }
- /**
- * Predicate returns true if first value less than second value
- * @param val1
- * @param val2
- * @returns {boolean}
- */
- static comparable_less_than(a2, e) {
- return a2 < e;
- }
- };
- var je = 0;
- var Ae = 1;
- var Ht = class {
- constructor(a2 = void 0, e = void 0, t = null, r = null, n = null, s = Ae) {
- if (this.left = t, this.right = r, this.parent = n, this.color = s, this.item = { key: a2, value: e }, a2 && a2 instanceof Array && a2.length === 2 && !Number.isNaN(a2[0]) && !Number.isNaN(a2[1])) {
- let [o, u] = a2;
- o > u && ([o, u] = [u, o]), this.item.key = new Gc(o, u);
- }
- this.max = this.item.key ? this.item.key.max : void 0;
- }
- isNil() {
- return this.item.key === void 0 && this.item.value === void 0 && this.left === null && this.right === null && this.color === Ae;
- }
- _value_less_than(a2) {
- return this.item.value && a2.item.value && this.item.value.less_than ? this.item.value.less_than(a2.item.value) : this.item.value < a2.item.value;
- }
- less_than(a2) {
- return this.item.value === this.item.key && a2.item.value === a2.item.key ? this.item.key.less_than(a2.item.key) : this.item.key.less_than(a2.item.key) || this.item.key.equal_to(a2.item.key) && this._value_less_than(a2);
- }
- _value_equal(a2) {
- return this.item.value && a2.item.value && this.item.value.equal_to ? this.item.value.equal_to(a2.item.value) : this.item.value === a2.item.value;
- }
- equal_to(a2) {
- return this.item.value === this.item.key && a2.item.value === a2.item.key ? this.item.key.equal_to(a2.item.key) : this.item.key.equal_to(a2.item.key) && this._value_equal(a2);
- }
- intersect(a2) {
- return this.item.key.intersect(a2.item.key);
- }
- copy_data(a2) {
- this.item.key = a2.item.key, this.item.value = a2.item.value;
- }
- update_max() {
- if (this.max = this.item.key ? this.item.key.max : void 0, this.right && this.right.max) {
- const a2 = this.item.key.constructor.comparable_max;
- this.max = a2(this.max, this.right.max);
- }
- if (this.left && this.left.max) {
- const a2 = this.item.key.constructor.comparable_max;
- this.max = a2(this.max, this.left.max);
- }
- }
- // Other_node does not intersect any node of left subtree, if this.left.max < other_node.item.key.low
- not_intersect_left_subtree(a2) {
- const e = this.item.key.constructor.comparable_less_than;
- let t = this.left.max.high !== void 0 ? this.left.max.high : this.left.max;
- return e(t, a2.item.key.low);
- }
- // Other_node does not intersect right subtree if other_node.item.key.high < this.right.key.low
- not_intersect_right_subtree(a2) {
- const e = this.item.key.constructor.comparable_less_than;
- let t = this.right.max.low !== void 0 ? this.right.max.low : this.right.item.key.low;
- return e(a2.item.key.high, t);
- }
- };
- var la = class _la {
- /**
- * Construct new empty instance of IntervalTree
- */
- constructor() {
- this.root = null, this.nil_node = new Ht();
- }
- /**
- * Returns number of items stored in the interval tree
- * @returns {number}
- */
- get size() {
- let a2 = 0;
- return this.tree_walk(this.root, () => a2++), a2;
- }
- /**
- * Returns array of sorted keys in the ascending order
- * @returns {Array}
- */
- get keys() {
- let a2 = [];
- return this.tree_walk(this.root, (e) => a2.push(
- e.item.key.output ? e.item.key.output() : e.item.key
- )), a2;
- }
- /**
- * Return array of values in the ascending keys order
- * @returns {Array}
- */
- get values() {
- let a2 = [];
- return this.tree_walk(this.root, (e) => a2.push(e.item.value)), a2;
- }
- /**
- * Returns array of items (<key,value> pairs) in the ascended keys order
- * @returns {Array}
- */
- get items() {
- let a2 = [];
- return this.tree_walk(this.root, (e) => a2.push({
- key: e.item.key.output ? e.item.key.output() : e.item.key,
- value: e.item.value
- })), a2;
- }
- /**
- * Returns true if tree is empty
- * @returns {boolean}
- */
- isEmpty() {
- return this.root == null || this.root === this.nil_node;
- }
- /**
- * Clear tree
- */
- clear() {
- this.root = null;
- }
- /**
- * Insert new item into interval tree
- * @param {Interval} key - interval object or array of two numbers [low, high]
- * @param {any} value - value representing any object (optional)
- * @returns {Node} returns reference to inserted node as an object {key:interval, value: value}
- */
- insert(a2, e = a2) {
- if (a2 === void 0)
- return;
- let t = new Ht(a2, e, this.nil_node, this.nil_node, null, je);
- return this.tree_insert(t), this.recalc_max(t), t;
- }
- /**
- * Returns true if item {key,value} exist in the tree
- * @param {Interval} key - interval correspondent to keys stored in the tree
- * @param {any} value - value object to be checked
- * @returns {boolean} true if item {key, value} exist in the tree, false otherwise
- */
- exist(a2, e = a2) {
- let t = new Ht(a2, e);
- return !!this.tree_search(this.root, t);
- }
- /**
- * Remove entry {key, value} from the tree
- * @param {Interval} key - interval correspondent to keys stored in the tree
- * @param {any} value - value object
- * @returns {boolean} true if item {key, value} deleted, false if not found
- */
- remove(a2, e = a2) {
- let t = new Ht(a2, e), r = this.tree_search(this.root, t);
- return r && this.tree_delete(r), r;
- }
- /**
- * Returns array of entry values which keys intersect with given interval <br/>
- * If no values stored in the tree, returns array of keys which intersect given interval
- * @param {Interval} interval - search interval, or tuple [low, high]
- * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
- * @returns {Array}
- */
- search(a2, e = (t, r) => t === r ? r.output() : t) {
- let t = new Ht(a2), r = [];
- return this.tree_search_interval(this.root, t, r), r.map((n) => e(n.item.value, n.item.key));
- }
- /**
- * Returns true if intersection between given and any interval stored in the tree found
- * @param {Interval} interval - search interval or tuple [low, high]
- * @returns {boolean}
- */
- intersect_any(a2) {
- let e = new Ht(a2);
- return this.tree_find_any_interval(this.root, e);
- }
- /**
- * Tree visitor. For each node implement a callback function. <br/>
- * Method calls a callback function with two parameters (key, value)
- * @param visitor(key,value) - function to be called for each tree item
- */
- forEach(a2) {
- this.tree_walk(this.root, (e) => a2(e.item.key, e.item.value));
- }
- /**
- * Value Mapper. Walk through every node and map node value to another value
- * @param callback(value,key) - function to be called for each tree item
- */
- map(a2) {
- const e = new _la();
- return this.tree_walk(this.root, (t) => e.insert(t.item.key, a2(t.item.value, t.item.key))), e;
- }
- /**
- * @param {Interval} interval - optional if the iterator is intended to start from the beginning
- * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
- * @returns {Iterator}
- */
- *iterate(a2, e = (t, r) => t === r ? r.output() : t) {
- let t;
- for (a2 ? t = this.tree_search_nearest_forward(this.root, new Ht(a2)) : this.root && (t = this.local_minimum(this.root)); t; )
- yield e(t.item.value, t.item.key), t = this.tree_successor(t);
- }
- recalc_max(a2) {
- let e = a2;
- for (; e.parent != null; )
- e.parent.update_max(), e = e.parent;
- }
- tree_insert(a2) {
- let e = this.root, t = null;
- if (this.root == null || this.root === this.nil_node)
- this.root = a2;
- else {
- for (; e !== this.nil_node; )
- t = e, a2.less_than(e) ? e = e.left : e = e.right;
- a2.parent = t, a2.less_than(t) ? t.left = a2 : t.right = a2;
- }
- this.insert_fixup(a2);
- }
- // After insertion insert_node may have red-colored parent, and this is a single possible violation
- // Go upwords to the root and re-color until violation will be resolved
- insert_fixup(a2) {
- let e, t;
- for (e = a2; e !== this.root && e.parent.color === je; )
- e.parent === e.parent.parent.left ? (t = e.parent.parent.right, t.color === je ? (e.parent.color = Ae, t.color = Ae, e.parent.parent.color = je, e = e.parent.parent) : (e === e.parent.right && (e = e.parent, this.rotate_left(e)), e.parent.color = Ae, e.parent.parent.color = je, this.rotate_right(e.parent.parent))) : (t = e.parent.parent.left, t.color === je ? (e.parent.color = Ae, t.color = Ae, e.parent.parent.color = je, e = e.parent.parent) : (e === e.parent.left && (e = e.parent, this.rotate_right(e)), e.parent.color = Ae, e.parent.parent.color = je, this.rotate_left(e.parent.parent)));
- this.root.color = Ae;
- }
- tree_delete(a2) {
- let e, t;
- a2.left === this.nil_node || a2.right === this.nil_node ? e = a2 : e = this.tree_successor(a2), e.left !== this.nil_node ? t = e.left : t = e.right, t.parent = e.parent, e === this.root ? this.root = t : (e === e.parent.left ? e.parent.left = t : e.parent.right = t, e.parent.update_max()), this.recalc_max(t), e !== a2 && (a2.copy_data(e), a2.update_max(), this.recalc_max(a2)), /*fix_node != this.nil_node && */
- e.color === Ae && this.delete_fixup(t);
- }
- delete_fixup(a2) {
- let e = a2, t;
- for (; e !== this.root && e.parent != null && e.color === Ae; )
- e === e.parent.left ? (t = e.parent.right, t.color === je && (t.color = Ae, e.parent.color = je, this.rotate_left(e.parent), t = e.parent.right), t.left.color === Ae && t.right.color === Ae ? (t.color = je, e = e.parent) : (t.right.color === Ae && (t.color = je, t.left.color = Ae, this.rotate_right(t), t = e.parent.right), t.color = e.parent.color, e.parent.color = Ae, t.right.color = Ae, this.rotate_left(e.parent), e = this.root)) : (t = e.parent.left, t.color === je && (t.color = Ae, e.parent.color = je, this.rotate_right(e.parent), t = e.parent.left), t.left.color === Ae && t.right.color === Ae ? (t.color = je, e = e.parent) : (t.left.color === Ae && (t.color = je, t.right.color = Ae, this.rotate_left(t), t = e.parent.left), t.color = e.parent.color, e.parent.color = Ae, t.left.color = Ae, this.rotate_right(e.parent), e = this.root));
- e.color = Ae;
- }
- tree_search(a2, e) {
- if (!(a2 == null || a2 === this.nil_node))
- return e.equal_to(a2) ? a2 : e.less_than(a2) ? this.tree_search(a2.left, e) : this.tree_search(a2.right, e);
- }
- tree_search_nearest_forward(a2, e) {
- let t, r = a2;
- for (; r && r !== this.nil_node; )
- r.less_than(e) ? r.intersect(e) ? (t = r, r = r.left) : r = r.right : ((!t || r.less_than(t)) && (t = r), r = r.left);
- return t || null;
- }
- // Original search_interval method; container res support push() insertion
- // Search all intervals intersecting given one
- tree_search_interval(a2, e, t) {
- a2 != null && a2 !== this.nil_node && (a2.left !== this.nil_node && !a2.not_intersect_left_subtree(e) && this.tree_search_interval(a2.left, e, t), a2.intersect(e) && t.push(a2), a2.right !== this.nil_node && !a2.not_intersect_right_subtree(e) && this.tree_search_interval(a2.right, e, t));
- }
- tree_find_any_interval(a2, e) {
- let t = false;
- return a2 != null && a2 !== this.nil_node && (a2.left !== this.nil_node && !a2.not_intersect_left_subtree(e) && (t = this.tree_find_any_interval(a2.left, e)), t || (t = a2.intersect(e)), !t && a2.right !== this.nil_node && !a2.not_intersect_right_subtree(e) && (t = this.tree_find_any_interval(a2.right, e))), t;
- }
- local_minimum(a2) {
- let e = a2;
- for (; e.left != null && e.left !== this.nil_node; )
- e = e.left;
- return e;
- }
- // not in use
- local_maximum(a2) {
- let e = a2;
- for (; e.right != null && e.right !== this.nil_node; )
- e = e.right;
- return e;
- }
- tree_successor(a2) {
- let e, t, r;
- if (a2.right !== this.nil_node)
- e = this.local_minimum(a2.right);
- else {
- for (t = a2, r = a2.parent; r != null && r.right === t; )
- t = r, r = r.parent;
- e = r;
- }
- return e;
- }
- // | right-rotate(T,y) |
- // y ---------------. x
- // / \ / \
- // x c left-rotate(T,x) a y
- // / \ <--------------- / \
- // a b b c
- rotate_left(a2) {
- let e = a2.right;
- a2.right = e.left, e.left !== this.nil_node && (e.left.parent = a2), e.parent = a2.parent, a2 === this.root ? this.root = e : a2 === a2.parent.left ? a2.parent.left = e : a2.parent.right = e, e.left = a2, a2.parent = e, a2 != null && a2 !== this.nil_node && a2.update_max(), e = a2.parent, e != null && e !== this.nil_node && e.update_max();
- }
- rotate_right(a2) {
- let e = a2.left;
- a2.left = e.right, e.right !== this.nil_node && (e.right.parent = a2), e.parent = a2.parent, a2 === this.root ? this.root = e : a2 === a2.parent.left ? a2.parent.left = e : a2.parent.right = e, e.right = a2, a2.parent = e, a2 !== null && a2 !== this.nil_node && a2.update_max(), e = a2.parent, e != null && e !== this.nil_node && e.update_max();
- }
- tree_walk(a2, e) {
- a2 != null && a2 !== this.nil_node && (this.tree_walk(a2.left, e), e(a2), this.tree_walk(a2.right, e));
- }
- /* Return true if all red nodes have exactly two black child nodes */
- testRedBlackProperty() {
- let a2 = true;
- return this.tree_walk(this.root, function(e) {
- e.color === je && (e.left.color === Ae && e.right.color === Ae || (a2 = false));
- }), a2;
- }
- /* Throw error if not every path from root to bottom has same black height */
- testBlackHeightProperty(a2) {
- let e = 0, t = 0, r = 0;
- if (a2.color === Ae && e++, a2.left !== this.nil_node ? t = this.testBlackHeightProperty(a2.left) : t = 1, a2.right !== this.nil_node ? r = this.testBlackHeightProperty(a2.right) : r = 1, t !== r)
- throw new Error("Red-black height property violated");
- return e += t, e;
- }
- };
- var Qc = class {
- constructor() {
- A(this, "_cache", /* @__PURE__ */ new Map());
- A(this, "_continueBuildingCache", /* @__PURE__ */ new Map());
- }
- set(a2, e, t, r, n) {
- if (!this.shouldContinueBuildingCache(a2, e, t, n))
- return;
- let s = this._cache.get(a2);
- s == null && (s = /* @__PURE__ */ new Map(), this._cache.set(a2, s));
- let o = s.get(e);
- o == null && (o = /* @__PURE__ */ new Map(), s.set(e, o));
- let u = o.get(t);
- u == null && (u = /* @__PURE__ */ new Map(), o.set(t, u));
- let c = u.get(r);
- c == null && (c = /* @__PURE__ */ new Set(), u.set(r, c)), c.add(n);
- }
- getCellValuePositions(a2, e, t) {
- var r, n;
- return (n = (r = this._cache.get(a2)) == null ? void 0 : r.get(e)) == null ? void 0 : n.get(t);
- }
- getCellPositions(a2, e, t, r, n) {
- var o, u, c;
- const s = (c = (u = (o = this._cache.get(a2)) == null ? void 0 : o.get(e)) == null ? void 0 : u.get(t)) == null ? void 0 : c.get(r);
- return s && [...s].filter((l2) => n.some(([f2, h]) => l2 >= f2 && l2 <= h));
- }
- setContinueBuildingCache(a2, e, t, r, n) {
- if (t === -1 || r === -1 || n === -1)
- return;
- let s = this._continueBuildingCache.get(a2);
- s == null && (s = /* @__PURE__ */ new Map(), this._continueBuildingCache.set(a2, s));
- let o = s.get(e);
- o == null && (o = /* @__PURE__ */ new Map(), s.set(e, o));
- let u = o.get(t);
- if (u == null) {
- u = new la(), u.insert([r, n]), o.set(t, u);
- return;
- }
- this._handleNewInterval(u, r, n);
- }
- shouldContinueBuildingCache(a2, e, t, r) {
- var o, u;
- if (t === -1 || r === -1)
- return false;
- const n = (u = (o = this._continueBuildingCache.get(a2)) == null ? void 0 : o.get(e)) == null ? void 0 : u.get(t);
- return n ? n.search([r, r]).length === 0 : true;
- }
- canUseCache(a2, e, t, r, n) {
- var f2, h;
- const s = (h = (f2 = this._continueBuildingCache.get(a2)) == null ? void 0 : f2.get(e)) == null ? void 0 : h.get(t);
- if (t === -1 || r === -1 || n === -1 || !s)
- return {
- rowsInCache: [],
- rowsNotInCache: []
- };
- const o = s.search([r, n]);
- if (o.length === 0)
- return {
- rowsInCache: [],
- rowsNotInCache: []
- };
- o.sort((d2, _) => d2[0] - _[0]);
- const u = [], c = [];
- let l2 = r;
- for (let d2 = 0; d2 < o.length; d2++) {
- const [_, C] = o[d2];
- if (l2 >= _) {
- if (n <= C) {
- u.push([l2, n]);
- break;
- }
- u.push([l2, C]), l2 = C + 1, d2 === o.length - 1 && l2 <= n && c.push([l2, n]);
- } else {
- if (n > C) {
- u.push([_, C]), c.push([l2, _ - 1]), l2 = C + 1, d2 === o.length - 1 && l2 <= n && c.push([l2, n]);
- continue;
- }
- u.push([_, n]), c.push([l2, _ - 1]);
- }
- }
- return {
- rowsInCache: u,
- rowsNotInCache: c
- };
- }
- clear() {
- this._cache.clear(), this._continueBuildingCache.clear();
- }
- _handleNewInterval(a2, e, t) {
- let r = a2.search([e, t]);
- if (r.length === 0) {
- const o = [e - 1 < 0 ? 0 : e - 1, t + 1];
- if (r = a2.search(o), r.length === 0) {
- a2.insert([e, t]);
- return;
- }
- }
- let n = e, s = t;
- for (const o of r)
- n = Math.min(n, o[0]), s = Math.max(s, o[1]), a2.remove(o);
- a2.insert([n, s]);
- }
- };
- var St = new Qc();
- var fa = "engine-formula.config";
- var so = 1;
- var Hb = "CYCLE_REFERENCE_COUNT";
- var ai = {};
- var Wc = Object.defineProperty;
- var qc = Object.getOwnPropertyDescriptor;
- var Kc = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? qc(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Wc(a2, e, r), r;
- };
- var ii = (i, a2) => (e, t) => a2(e, t, i);
- var ws = class extends nt {
- constructor(a2, e) {
- super();
- A(this, "_unitData", {});
- A(this, "_unitStylesData", {});
- A(this, "_arrayFormulaCellData", {});
- A(this, "_arrayFormulaRange", {});
- A(this, "_formulaData", {});
- A(this, "_sheetNameMap", {});
- A(this, "_forceCalculate", false);
- A(this, "_clearDependencyTreeCache", {});
- A(this, "_dirtyRanges", []);
- A(this, "_dirtyNameMap", {});
- A(this, "_dirtyDefinedNameMap", {});
- A(this, "_dirtyUnitFeatureMap", {});
- A(this, "_dirtyUnitOtherFormulaMap", {});
- A(this, "_excludedCell");
- A(this, "_sheetIdToNameMap", {});
- A(this, "_executeUnitId", "");
- A(this, "_executeSubUnitId", "");
- this._univerInstanceService = a2, this._localeService = e;
- }
- dispose() {
- this._unitData = {}, this._unitStylesData = {}, this._formulaData = {}, this._arrayFormulaCellData = {}, this._arrayFormulaRange = {}, this._sheetNameMap = {}, this._dirtyRanges = [], this._dirtyNameMap = {}, this._dirtyDefinedNameMap = {}, this._dirtyUnitFeatureMap = {}, this._excludedCell = {}, this._sheetIdToNameMap = {}, this._dirtyUnitOtherFormulaMap = {};
- }
- getExecuteUnitId() {
- return this._executeUnitId;
- }
- getExecuteSubUnitId() {
- return this._executeSubUnitId;
- }
- setExecuteUnitId(a2) {
- this._executeUnitId = a2;
- }
- setExecuteSubUnitId(a2) {
- this._executeSubUnitId = a2;
- }
- getExcludedRange() {
- return this._excludedCell;
- }
- getUnitData() {
- return this._unitData;
- }
- getUnitStylesData() {
- return this._unitStylesData;
- }
- getFormulaData() {
- return this._formulaData;
- }
- getArrayFormulaCellData() {
- return this._arrayFormulaCellData;
- }
- getArrayFormulaRange() {
- return this._arrayFormulaRange;
- }
- getSheetNameMap() {
- return this._sheetNameMap;
- }
- isForceCalculate() {
- return this._forceCalculate;
- }
- getDirtyRanges() {
- return this._dirtyRanges;
- }
- getDirtyNameMap() {
- return this._dirtyNameMap;
- }
- getDirtyDefinedNameMap() {
- return this._dirtyDefinedNameMap;
- }
- getDirtyUnitFeatureMap() {
- return this._dirtyUnitFeatureMap;
- }
- getDirtyUnitOtherFormulaMap() {
- return this._dirtyUnitOtherFormulaMap;
- }
- getSheetName(a2, e) {
- return this._sheetIdToNameMap[a2] == null ? "" : this._sheetIdToNameMap[a2][e] || "";
- }
- getClearDependencyTreeCache() {
- return this._clearDependencyTreeCache;
- }
- getLocale() {
- return this._localeService.getCurrentLocale();
- }
- getSheetsInfo() {
- const a2 = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET), { id: e, sheetOrder: t } = a2.getSnapshot();
- return {
- sheetOrder: t,
- sheetNameMap: this._sheetIdToNameMap[e]
- };
- }
- getSheetRowColumnCount(a2, e) {
- const t = this._univerInstanceService.getUnit(a2), r = t == null ? void 0 : t.getSheetBySheetId(e), n = r == null ? void 0 : r.getSnapshot();
- if (!n)
- return { rowCount: 0, columnCount: 0 };
- const { rowCount: s, columnCount: o } = n;
- return { rowCount: s, columnCount: o };
- }
- load(a2) {
- if (a2.allUnitData && a2.unitSheetNameMap && a2.unitStylesData)
- this._unitData = a2.allUnitData, this._unitStylesData = a2.unitStylesData, this._sheetNameMap = a2.unitSheetNameMap;
- else {
- const { allUnitData: e, unitSheetNameMap: t, unitStylesData: r } = this._loadSheetData();
- this._unitData = e, this._unitStylesData = r, this._sheetNameMap = t;
- }
- this._formulaData = a2.formulaData, this._arrayFormulaCellData = oc(a2.arrayFormulaCellData), this._arrayFormulaRange = a2.arrayFormulaRange, this._forceCalculate = a2.forceCalculate, this._clearDependencyTreeCache = a2.clearDependencyTreeCache || {}, this._dirtyRanges = a2.dirtyRanges, this._dirtyNameMap = a2.dirtyNameMap, this._dirtyDefinedNameMap = a2.dirtyDefinedNameMap, this._dirtyUnitFeatureMap = a2.dirtyUnitFeatureMap, this._dirtyUnitOtherFormulaMap = a2.dirtyUnitOtherFormulaMap, this._excludedCell = a2.excludedCell, this._mergeNameMap(this._sheetNameMap, this._dirtyNameMap);
- }
- getDirtyData() {
- return {
- forceCalculation: this._forceCalculate,
- dirtyRanges: this._dirtyRanges,
- dirtyNameMap: this._dirtyNameMap,
- dirtyDefinedNameMap: this._dirtyDefinedNameMap,
- dirtyUnitFeatureMap: this._dirtyUnitFeatureMap,
- dirtyUnitOtherFormulaMap: this._dirtyUnitOtherFormulaMap,
- clearDependencyTreeCache: this._clearDependencyTreeCache
- };
- }
- loadDirtyRangesAndExcludedCell(a2, e) {
- this._dirtyRanges = a2, this._excludedCell = e, this._dirtyNameMap = {};
- }
- registerUnitData(a2) {
- this._unitData = a2;
- }
- registerFormulaData(a2) {
- this._formulaData = a2;
- }
- registerSheetNameMap(a2) {
- this._sheetNameMap = a2;
- }
- // private _loadOtherFormulaData() {
- // const unitAllDoc = this._univerInstanceService.getAllUniverDocsInstance();
- // const unitAllSlide = this._univerInstanceService.getAllUniverSlidesInstance();
- // const otherFormulaData: IOtherFormulaData = {};
- // for (const documentDataModel of unitAllDoc) {
- // const unitId = documentDataModel.getUnitId();
- // if (otherFormulaData[unitId] == null) {
- // otherFormulaData[unitId] = {};
- // }
- // if (otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] == null) {
- // otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] = {};
- // }
- // const subComponent = otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID];
- // const customRanges = documentDataModel.getBody()?.customRanges;
- // if (customRanges == null) {
- // continue;
- // }
- // for (const customRange of customRanges) {
- // subComponent[customRange.rangeId] = {
- // f: customRange.endIndex.toString(),
- // };
- // }
- // }
- // for (const slide of unitAllSlide) {
- // const unitId = slide.getUnitId();
- // if (otherFormulaData[unitId] == null) {
- // otherFormulaData[unitId] = {};
- // }
- // if (otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] == null) {
- // otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] = {};
- // }
- // const pages = slide.getPages();
- // if (pages == null) {
- // continue;
- // }
- // const pageIds = Object.keys(pages);
- // for (const pageId of pageIds) {
- // const page = pages[pageId];
- // const subComponent = otherFormulaData[unitId][pageId];
- // const pageElements = page.pageElements;
- // if (pageElements == null) {
- // continue;
- // }
- // const pageElementIds = Object.keys(pageElements);
- // for (const pageElementId of pageElementIds) {
- // const pageElement = pageElements[pageElementId];
- // subComponent[pageElementId] = {
- // f: pageElement.title,
- // };
- // }
- // }
- // }
- // return otherFormulaData;
- // }
- _mergeNameMap(a2, e) {
- Object.keys(e).forEach((t) => {
- e[t] && Object.keys(e[t]).forEach((r) => {
- a2[t] == null && (a2[t] = {}), a2[t][e[t][r]] = r;
- });
- }), this._sheetIdToNameMap = {}, Object.keys(a2).forEach((t) => {
- Object.keys(a2[t]).forEach((r) => {
- this._sheetIdToNameMap[t] == null && (this._sheetIdToNameMap[t] = {}), this._sheetIdToNameMap[t][a2[t][r]] = r;
- });
- });
- }
- _loadSheetData() {
- const a2 = this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET), e = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET), t = e == null ? void 0 : e.getActiveSheet();
- this._executeUnitId = e == null ? void 0 : e.getUnitId(), this._executeSubUnitId = t == null ? void 0 : t.getSheetId();
- const r = {}, n = {}, s = {};
- for (const o of a2) {
- const u = o.getUnitId(), c = o.getSheets(), l2 = {}, f2 = {};
- for (const h of c) {
- const d2 = h.getSheetId(), _ = h.getConfig();
- l2[d2] = {
- cellData: new kt(_.cellData),
- rowCount: _.rowCount,
- columnCount: _.columnCount,
- rowData: _.rowData,
- columnData: _.columnData,
- defaultRowHeight: _.defaultRowHeight,
- defaultColumnWidth: _.defaultColumnWidth
- }, f2[h.getName()] = h.getSheetId();
- }
- r[u] = l2, n[u] = o.getStyles(), s[u] = f2;
- }
- return {
- allUnitData: r,
- unitStylesData: n,
- unitSheetNameMap: s
- };
- }
- };
- ws = Kc([
- ii(0, _n),
- ii(1, ot(Vr))
- ], ws);
- var Ft = Ct(
- "univer.formula.current-data.service"
- );
- var Xc = Object.defineProperty;
- var Zc = Object.getOwnPropertyDescriptor;
- var zc = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Zc(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Xc(a2, e, r), r;
- };
- var is = (i, a2) => (e, t) => a2(e, t, i);
- var gr = class extends nt {
- constructor(i, a2, e) {
- super(), this._definedNamesService = i, this._lexerTreeBuilder = a2, this._formulaCurrentConfigService = e;
- }
- treeBuilder(i, a2 = true) {
- return this._lexerTreeBuilder.treeBuilder(i, a2, this._injectDefinedName.bind(this), this._simpleCheckDefinedName.bind(this));
- }
- _simpleCheckDefinedName(i) {
- const a2 = this._formulaCurrentConfigService.getDirtyDefinedNameMap(), e = this._formulaCurrentConfigService.getExecuteUnitId();
- if (e != null && a2[e] != null) {
- const t = Object.keys(a2[e]);
- for (let r = 0, n = t.length; r < n; r++) {
- const s = t[r];
- if (i.indexOf(s) > -1)
- return true;
- }
- }
- return false;
- }
- _checkDefinedNameDirty(i) {
- const a2 = this._formulaCurrentConfigService.getDirtyDefinedNameMap(), e = this._formulaCurrentConfigService.getExecuteUnitId();
- if (e != null && a2[e] != null) {
- const t = Object.keys(a2[e]);
- for (let r = 0, n = t.length; r < n; r++)
- if (t[r] === i)
- return true;
- }
- return false;
- }
- _injectDefinedName(i) {
- const a2 = this._formulaCurrentConfigService.getExecuteUnitId();
- if (a2 == null)
- return {
- sequenceString: "",
- hasDefinedName: false,
- definedNames: []
- };
- const e = this._lexerTreeBuilder.getSequenceNode(i);
- let t = "", r = false;
- const n = [];
- for (let s = 0, o = e.length; s < o; s++) {
- const u = e[s];
- if (typeof u == "string") {
- t += u;
- continue;
- }
- const { nodeType: c, token: l2 } = u;
- if (c === $e.REFERENCE || c === $e.FUNCTION) {
- const f2 = this._definedNamesService.getValueByName(a2, l2);
- if (f2) {
- let h = f2.formulaOrRefString;
- h.substring(0, 1) === X2.EQUALS && (h = h.substring(1)), t += h, n.push(f2.name), r = true;
- } else
- this._checkDefinedNameDirty(l2) ? (t += m2.NAME, r = true, n.push(l2)) : t += l2;
- } else
- t += l2;
- }
- return {
- sequenceString: t,
- hasDefinedName: r,
- definedNames: n
- };
- }
- };
- gr = zc([
- is(0, pr),
- is(1, ot(ca)),
- is(2, Ft)
- ], gr);
- function nn(i) {
- if (i == null)
- return true;
- const { v: a2, f: e, si: t, p: r } = i;
- return !(!(a2 == null || typeof a2 == "string" && a2.length === 0) || e != null && e.length > 0 || t != null && t.length > 0 || r != null);
- }
- function ao(i, a2, e, t, r) {
- var s;
- const n = Object.keys(r);
- for (const o of n) {
- const u = r[o], c = (s = u == null ? void 0 : u[t]) == null ? void 0 : s[e];
- if (c == null)
- continue;
- const l2 = c.getValue(i, a2);
- if (l2 != null)
- return l2;
- }
- }
- var Jc = [
- "$",
- "£",
- "¥",
- "¤",
- "֏",
- "؋",
- "৳",
- "฿",
- "៛",
- "₡",
- "₦",
- "₩",
- "₪",
- "₫",
- "€",
- "₭",
- "₮",
- "₱",
- "₲",
- "₴",
- "₸",
- "₹",
- "₺",
- "₼",
- "₽",
- "₾",
- "₿"
- ];
- var el = {
- currency: 2,
- date: 4,
- datetime: 5,
- error: 11,
- fraction: 7,
- general: 0,
- grouped: 11,
- number: 1,
- percent: 6,
- scientific: 8,
- text: 9,
- time: 5,
- unknown: 11
- /* Custom */
- };
- function Gb(i, a2, e) {
- var u, c;
- if (i == null || a2 == null)
- return a2;
- const t = (e == null ? void 0 : e.getStyleByCell(i)) || i.s, r = (e == null ? void 0 : e.getStyleByCell(a2)) || a2.s;
- if (t == null || r == null || typeof t != "object" || typeof r != "object")
- return a2;
- const n = (u = t == null ? void 0 : t.n) == null ? void 0 : u.pattern, s = (c = r == null ? void 0 : r.n) == null ? void 0 : c.pattern;
- if (n == null || s == null)
- return a2;
- const o = n || s;
- return r.n.pattern = o, a2;
- }
- var Ds = new Vt(1e5);
- function oi(i) {
- const a2 = Ds.get(i);
- if (a2 !== void 0)
- return a2;
- const e = rl(i);
- return Ds.set(i, e), e;
- }
- function tl() {
- Ds.clear();
- }
- function rl(i) {
- if (nl(i))
- return 3;
- const a2 = Op.getInfo(i).type || "unknown";
- return el[a2];
- }
- function nl(i) {
- return !!Jc.find((a2) => i.includes(a2)) && i.startsWith("_(");
- }
- function Wr(i, a2, e) {
- if (i === "")
- return a2;
- if (a2 === "")
- return i;
- const t = oi(i), r = oi(a2);
- return e === X2.PLUS || e === X2.MINUS ? t === 4 && r === 4 || t === 11 && r === 11 ? "" : a2 : e === X2.MULTIPLY || e === X2.DIVIDED ? t === 6 && r === 6 || t === 7 && r === 7 || t === 8 && r === 8 || t === 9 && r === 9 ? a2 : "" : i || a2;
- }
- var sl = /* @__PURE__ */ new Map([
- [ur.EN_US, "$"],
- // [LocaleType.JA_JP, '¥'],
- [ur.RU_RU, "₽"],
- [ur.VI_VN, "₫"],
- [ur.ZH_CN, "¥"],
- [ur.ZH_TW, "NT$"]
- ]);
- function ui(i) {
- return sl.get(i) || "$";
- }
- function Ke(i, a2 = 2) {
- let e = a2;
- a2 > 127 && (e = 127);
- let t = "";
- return e > 0 && (t = `.${"0".repeat(e)}`), `"${ui(i)}"#,##0${t}_);[Red]("${ui(i)}"#,##0${t})`;
- }
- function al(i, a2, e = 2) {
- return Op.format(Ke(i, e), a2);
- }
- var ha = new Vt(1e5);
- function il(i) {
- let a2 = i;
- a2.startsWith('"') && a2.endsWith('"') && (a2 = a2.slice(1, -1));
- const e = ha.get(a2);
- if (e)
- return {
- isNumberPattern: true,
- value: e.value,
- pattern: e.pattern
- };
- const t = Op.parseNumber(a2);
- if (t && t.z)
- return os(a2, t.v, t.z);
- const r = Op.parseDate(a2);
- if (r && r.z)
- return os(a2, r.v, r.z);
- const n = Op.parseTime(a2);
- return n && n.z ? os(a2, n.v, n.z) : {
- isNumberPattern: false
- };
- }
- function os(i, a2, e) {
- return ha.set(i, {
- value: a2,
- pattern: e
- }), {
- isNumberPattern: true,
- value: a2,
- pattern: e
- };
- }
- function ol() {
- ha.clear();
- }
- var jn = class {
- constructor() {
- A(this, "pattern", "");
- }
- dispose() {
- }
- getPattern() {
- return this.pattern;
- }
- /**
- * Only used in NumberValueObject
- * @param pattern
- */
- setPattern(a2) {
- this.pattern = a2;
- }
- isError() {
- return false;
- }
- isAsyncObject() {
- return false;
- }
- isAsyncArrayObject() {
- return false;
- }
- isReferenceObject() {
- return false;
- }
- isArray() {
- return false;
- }
- isValueObject() {
- return false;
- }
- isEqualType(a2) {
- return false;
- }
- };
- var kt2 = class extends jn {
- constructor(a2) {
- super(), this._rawValue = a2;
- }
- isValueObject() {
- return true;
- }
- toUnitRange() {
- return {
- range: {
- startColumn: -1,
- startRow: -1,
- endRow: -1,
- endColumn: -1
- },
- sheetId: "",
- unitId: ""
- };
- }
- getValue() {
- return 0;
- }
- getArrayValue() {
- return [];
- }
- setValue(a2) {
- }
- setArrayValue(a2) {
- }
- isCube() {
- return false;
- }
- isString() {
- return false;
- }
- isNumber() {
- return false;
- }
- isBoolean() {
- return false;
- }
- isLambda() {
- return false;
- }
- isError() {
- return false;
- }
- isNull() {
- return false;
- }
- sum() {
- return g2.create(m2.VALUE);
- }
- max() {
- return g2.create(m2.VALUE);
- }
- min() {
- return g2.create(m2.VALUE);
- }
- count() {
- return g2.create(m2.VALUE);
- }
- countA() {
- return g2.create(m2.VALUE);
- }
- countBlank() {
- return g2.create(m2.VALUE);
- }
- getNegative() {
- return g2.create(m2.VALUE);
- }
- getReciprocal() {
- return g2.create(m2.VALUE);
- }
- plus(a2) {
- return g2.create(m2.VALUE);
- }
- minus(a2) {
- return g2.create(m2.VALUE);
- }
- multiply(a2) {
- return g2.create(m2.VALUE);
- }
- divided(a2) {
- return g2.create(m2.VALUE);
- }
- mod(a2) {
- return g2.create(m2.VALUE);
- }
- /**
- * return every value in the array after the callback function, excluding the error value
- * @param callbackFn
- * @returns
- */
- map(a2) {
- return g2.create(m2.NAME);
- }
- /**
- * return every value in the array after the callback function
- * @param callbackFn
- * @returns
- */
- mapValue(a2) {
- return g2.create(m2.NAME);
- }
- compare(a2, e, t = false) {
- return g2.create(m2.NAME);
- }
- isEqual(a2) {
- return this.compare(a2, $.EQUALS);
- }
- isNotEqual(a2) {
- return this.compare(a2, $.NOT_EQUAL);
- }
- isGreaterThanOrEqual(a2) {
- return this.compare(a2, $.GREATER_THAN_OR_EQUAL);
- }
- isLessThanOrEqual(a2) {
- return this.compare(a2, $.LESS_THAN_OR_EQUAL);
- }
- isLessThan(a2) {
- return this.compare(a2, $.LESS_THAN);
- }
- isGreaterThan(a2) {
- return this.compare(a2, $.GREATER_THAN);
- }
- concatenateFront(a2) {
- return g2.create(m2.NAME);
- }
- concatenateBack(a2) {
- return g2.create(m2.NAME);
- }
- plusBy(a2) {
- return g2.create(m2.VALUE);
- }
- minusBy(a2) {
- return g2.create(m2.VALUE);
- }
- multiplyBy(a2) {
- return g2.create(m2.VALUE);
- }
- dividedBy(a2) {
- return g2.create(m2.VALUE);
- }
- modInverse(a2) {
- return g2.create(m2.VALUE);
- }
- compareBy(a2, e) {
- return g2.create(m2.NAME);
- }
- concatenate(a2, e = it.FRONT) {
- let t = this.getValue().toString();
- if (typeof a2 == "string")
- e === it.FRONT ? t = a2 + t : t += a2;
- else if (typeof a2 == "number")
- e === it.FRONT ? t = a2.toString() + t : t += a2.toString();
- else if (typeof a2 == "boolean") {
- const r = a2 ? "TRUE" : "FALSE";
- e === it.FRONT ? t = r + t : t += r;
- }
- return t;
- }
- pow(a2) {
- return g2.create(m2.VALUE);
- }
- powInverse(a2) {
- return g2.create(m2.VALUE);
- }
- sqrt() {
- return g2.create(m2.VALUE);
- }
- cbrt() {
- return g2.create(m2.VALUE);
- }
- cos() {
- return g2.create(m2.VALUE);
- }
- cosh() {
- return g2.create(m2.VALUE);
- }
- acos() {
- return g2.create(m2.VALUE);
- }
- acosh() {
- return g2.create(m2.VALUE);
- }
- sin() {
- return g2.create(m2.VALUE);
- }
- sinh() {
- return g2.create(m2.VALUE);
- }
- asin() {
- return g2.create(m2.VALUE);
- }
- asinh() {
- return g2.create(m2.VALUE);
- }
- tan() {
- return g2.create(m2.VALUE);
- }
- tanh() {
- return g2.create(m2.VALUE);
- }
- atan() {
- return g2.create(m2.VALUE);
- }
- atan2(a2) {
- return g2.create(m2.VALUE);
- }
- atan2Inverse(a2) {
- return g2.create(m2.VALUE);
- }
- atanh() {
- return g2.create(m2.VALUE);
- }
- /**
- * Calculate the mean of the entire array.
- *
- * reference https://numpy.org/doc/stable/reference/generated/numpy.mean.html#numpy.mean
- *
- */
- mean() {
- return this;
- }
- /**
- * Calculate the median of the entire array.
- *
- * reference https://numpy.org/doc/stable/reference/generated/numpy.median.html
- *
- */
- median() {
- return this;
- }
- /**
- * Calculate the variance of the entire array.
- *
- * reference https://numpy.org/doc/stable/reference/generated/numpy.var.html
- */
- var() {
- return this;
- }
- /**
- * Calculate the standard deviation of the entire array.
- *
- * reference https://numpy.org/doc/stable/reference/generated/numpy.std.html
- */
- std() {
- return this;
- }
- log() {
- return g2.create(m2.VALUE);
- }
- log10() {
- return g2.create(m2.VALUE);
- }
- exp() {
- return g2.create(m2.VALUE);
- }
- abs() {
- return g2.create(m2.VALUE);
- }
- round(a2) {
- return g2.create(m2.VALUE);
- }
- roundInverse(a2) {
- return g2.create(m2.VALUE);
- }
- floor(a2) {
- return g2.create(m2.VALUE);
- }
- floorInverse(a2) {
- return g2.create(m2.VALUE);
- }
- ceil(a2) {
- return g2.create(m2.VALUE);
- }
- ceilInverse(a2) {
- return g2.create(m2.VALUE);
- }
- convertToNumberObjectValue() {
- return g2.create(m2.VALUE);
- }
- convertToBooleanObjectValue() {
- return g2.create(m2.VALUE);
- }
- };
- var ul = 1e3;
- var ci = new Vt(ul);
- var g2 = class _g2 extends kt2 {
- constructor(a2, e = "") {
- super(a2), this._errorType = a2, this._errorContent = e;
- }
- static create(a2, e = "") {
- const t = `${a2}-${e}`, r = ci.get(t);
- if (r)
- return r;
- const n = new _g2(a2, e);
- return ci.set(t, n), n;
- }
- getValue() {
- return this._errorType;
- }
- getErrorType() {
- return this._errorType;
- }
- getErrorContent() {
- return this._errorContent;
- }
- isEqualType(a2) {
- return a2.getErrorType() === this.getErrorType();
- }
- isError() {
- return true;
- }
- };
- function cl(i) {
- if (i === null)
- return 0;
- if (i != null && i.p) {
- const a2 = i == null ? void 0 : i.p.body;
- if (a2 == null)
- return 0;
- const e = a2.dataStream;
- return st.transform.getPlainText(e);
- }
- return (i == null ? void 0 : i.v) || 0;
- }
- var Wt = ((i) => (i[i.MIN = 0] = "MIN", i[i.MAX = 1] = "MAX", i))(Wt || {});
- var Pe = ((i) => (i[i.NORMAL = 0] = "NORMAL", i[i.MIN = 1] = "MIN", i[i.MAX = 2] = "MAX", i))(Pe || {});
- function hn() {
- return Intl && Intl.Collator ? new Intl.Collator(void 0, { numeric: false }).compare : (i, a2) => i.localeCompare(a2);
- }
- function ll(i) {
- return i.indexOf("*") > -1 || i.indexOf("?") > -1;
- }
- function us(i, a2) {
- const e = hl(a2).replace(/~?[*?]/g, (r) => r.startsWith("~") ? `\\${r.substring(1)}` : r === "*" ? ".*" : r === "?" ? "." : r);
- return new RegExp(`^${e}$`).test(i);
- }
- function li(i) {
- return i.replace(/~?[*?]/g, (a2) => a2.startsWith("~") ? a2.substring(1) : " ");
- }
- function fl(i, a2, e) {
- let t = false;
- switch (e) {
- case $.EQUALS:
- t = us(i, a2);
- break;
- case $.NOT_EQUAL:
- t = !us(i, a2);
- break;
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- t = us(i, a2) || i > li(a2);
- break;
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- t = i < li(a2);
- break;
- }
- return t;
- }
- function hl(i) {
- return i.replace(/[.+^${}()|[\]\\]/g, "\\$&");
- }
- function Ss(i) {
- switch (i) {
- case 1:
- return 2;
- case 0:
- return 0;
- case -1:
- return 1;
- default:
- return 0;
- }
- }
- function Ps(i) {
- return i === -2 ? 1 : 0;
- }
- function ma(i) {
- let a2;
- switch (i) {
- case $.EQUALS:
- a2 = $.EQUALS;
- break;
- case $.GREATER_THAN:
- a2 = $.LESS_THAN;
- break;
- case $.GREATER_THAN_OR_EQUAL:
- a2 = $.LESS_THAN_OR_EQUAL;
- break;
- case $.LESS_THAN:
- a2 = $.GREATER_THAN;
- break;
- case $.LESS_THAN_OR_EQUAL:
- a2 = $.GREATER_THAN_OR_EQUAL;
- break;
- case $.NOT_EQUAL:
- a2 = $.NOT_EQUAL;
- break;
- }
- return a2;
- }
- var Ls = 9e15;
- var $t = 1e9;
- var xs = "0123456789abcdef";
- var mn = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
- var gn = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
- var js = {
- // These values must be integers within the stated ranges (inclusive).
- // Most of these values can be changed at run-time using the `Decimal.config` method.
- // The maximum number of significant digits of the result of a calculation or base conversion.
- // E.g. `Decimal.config({ precision: 20 });`
- precision: 20,
- // 1 to MAX_DIGITS
- // The rounding mode used when rounding to `precision`.
- //
- // ROUND_UP 0 Away from zero.
- // ROUND_DOWN 1 Towards zero.
- // ROUND_CEIL 2 Towards +Infinity.
- // ROUND_FLOOR 3 Towards -Infinity.
- // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
- // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
- // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
- // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
- // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
- //
- // E.g.
- // `Decimal.rounding = 4;`
- // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
- rounding: 4,
- // 0 to 8
- // The modulo mode used when calculating the modulus: a mod n.
- // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
- // The remainder (r) is calculated as: r = a - n * q.
- //
- // UP 0 The remainder is positive if the dividend is negative, else is negative.
- // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
- // FLOOR 3 The remainder has the same sign as the divisor (Python %).
- // HALF_EVEN 6 The IEEE 754 remainder function.
- // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
- //
- // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
- // division (9) are commonly used for the modulus operation. The other rounding modes can also
- // be used, but they may not give useful results.
- modulo: 1,
- // 0 to 9
- // The exponent value at and beneath which `toString` returns exponential notation.
- // JavaScript numbers: -7
- toExpNeg: -7,
- // 0 to -EXP_LIMIT
- // The exponent value at and above which `toString` returns exponential notation.
- // JavaScript numbers: 21
- toExpPos: 21,
- // 0 to EXP_LIMIT
- // The minimum exponent value, beneath which underflow to zero occurs.
- // JavaScript numbers: -324 (5e-324)
- minE: -9e15,
- // -1 to -EXP_LIMIT
- // The maximum exponent value, above which overflow to Infinity occurs.
- // JavaScript numbers: 308 (1.7976931348623157e+308)
- maxE: Ls,
- // 1 to EXP_LIMIT
- // Whether to use cryptographically-secure random number generation, if available.
- crypto: false
- // true/false
- };
- var io;
- var Rt;
- var ue2 = true;
- var Un = "[DecimalError] ";
- var Bt = Un + "Invalid argument: ";
- var oo = Un + "Precision limit exceeded";
- var uo = Un + "crypto unavailable";
- var co = "[object Decimal]";
- var Be = Math.floor;
- var Le = Math.pow;
- var ml = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
- var gl = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
- var dl = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
- var lo = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
- var ut = 1e7;
- var te = 7;
- var Cl = 9007199254740991;
- var _l = mn.length - 1;
- var Us = gn.length - 1;
- var B2 = { toStringTag: co };
- B2.absoluteValue = B2.abs = function() {
- var i = new this.constructor(this);
- return i.s < 0 && (i.s = 1), J2(i);
- };
- B2.ceil = function() {
- return J2(new this.constructor(this), this.e + 1, 2);
- };
- B2.clampedTo = B2.clamp = function(i, a2) {
- var e, t = this, r = t.constructor;
- if (i = new r(i), a2 = new r(a2), !i.s || !a2.s)
- return new r(NaN);
- if (i.gt(a2))
- throw Error(Bt + a2);
- return e = t.cmp(i), e < 0 ? i : t.cmp(a2) > 0 ? a2 : new r(t);
- };
- B2.comparedTo = B2.cmp = function(i) {
- var a2, e, t, r, n = this, s = n.d, o = (i = new n.constructor(i)).d, u = n.s, c = i.s;
- if (!s || !o)
- return !u || !c ? NaN : u !== c ? u : s === o ? 0 : !s ^ u < 0 ? 1 : -1;
- if (!s[0] || !o[0])
- return s[0] ? u : o[0] ? -c : 0;
- if (u !== c)
- return u;
- if (n.e !== i.e)
- return n.e > i.e ^ u < 0 ? 1 : -1;
- for (t = s.length, r = o.length, a2 = 0, e = t < r ? t : r; a2 < e; ++a2)
- if (s[a2] !== o[a2])
- return s[a2] > o[a2] ^ u < 0 ? 1 : -1;
- return t === r ? 0 : t > r ^ u < 0 ? 1 : -1;
- };
- B2.cosine = B2.cos = function() {
- var i, a2, e = this, t = e.constructor;
- return e.d ? e.d[0] ? (i = t.precision, a2 = t.rounding, t.precision = i + Math.max(e.e, e.sd()) + te, t.rounding = 1, e = Al(t, Co(t, e)), t.precision = i, t.rounding = a2, J2(Rt == 2 || Rt == 3 ? e.neg() : e, i, a2, true)) : new t(1) : new t(NaN);
- };
- B2.cubeRoot = B2.cbrt = function() {
- var i, a2, e, t, r, n, s, o, u, c, l2 = this, f2 = l2.constructor;
- if (!l2.isFinite() || l2.isZero())
- return new f2(l2);
- for (ue2 = false, n = l2.s * Le(l2.s * l2, 1 / 3), !n || Math.abs(n) == 1 / 0 ? (e = Ue(l2.d), i = l2.e, (n = (i - e.length + 1) % 3) && (e += n == 1 || n == -2 ? "0" : "00"), n = Le(e, 1 / 3), i = Be((i + 1) / 3) - (i % 3 == (i < 0 ? -1 : 2)), n == 1 / 0 ? e = "5e" + i : (e = n.toExponential(), e = e.slice(0, e.indexOf("e") + 1) + i), t = new f2(e), t.s = l2.s) : t = new f2(n.toString()), s = (i = f2.precision) + 3; ; )
- if (o = t, u = o.times(o).times(o), c = u.plus(l2), t = pe2(c.plus(l2).times(o), c.plus(u), s + 2, 1), Ue(o.d).slice(0, s) === (e = Ue(t.d)).slice(0, s))
- if (e = e.slice(s - 3, s + 1), e == "9999" || !r && e == "4999") {
- if (!r && (J2(o, i + 1, 0), o.times(o).times(o).eq(l2))) {
- t = o;
- break;
- }
- s += 4, r = 1;
- } else {
- (!+e || !+e.slice(1) && e.charAt(0) == "5") && (J2(t, i + 1, 1), a2 = !t.times(t).times(t).eq(l2));
- break;
- }
- return ue2 = true, J2(t, i, f2.rounding, a2);
- };
- B2.decimalPlaces = B2.dp = function() {
- var i, a2 = this.d, e = NaN;
- if (a2) {
- if (i = a2.length - 1, e = (i - Be(this.e / te)) * te, i = a2[i], i)
- for (; i % 10 == 0; i /= 10)
- e--;
- e < 0 && (e = 0);
- }
- return e;
- };
- B2.dividedBy = B2.div = function(i) {
- return pe2(this, new this.constructor(i));
- };
- B2.dividedToIntegerBy = B2.divToInt = function(i) {
- var a2 = this, e = a2.constructor;
- return J2(pe2(a2, new e(i), 0, 1, 1), e.precision, e.rounding);
- };
- B2.equals = B2.eq = function(i) {
- return this.cmp(i) === 0;
- };
- B2.floor = function() {
- return J2(new this.constructor(this), this.e + 1, 3);
- };
- B2.greaterThan = B2.gt = function(i) {
- return this.cmp(i) > 0;
- };
- B2.greaterThanOrEqualTo = B2.gte = function(i) {
- var a2 = this.cmp(i);
- return a2 == 1 || a2 === 0;
- };
- B2.hyperbolicCosine = B2.cosh = function() {
- var i, a2, e, t, r, n = this, s = n.constructor, o = new s(1);
- if (!n.isFinite())
- return new s(n.s ? 1 / 0 : NaN);
- if (n.isZero())
- return o;
- e = s.precision, t = s.rounding, s.precision = e + Math.max(n.e, n.sd()) + 4, s.rounding = 1, r = n.d.length, r < 32 ? (i = Math.ceil(r / 3), a2 = (1 / Tn(4, i)).toString()) : (i = 16, a2 = "2.3283064365386962890625e-10"), n = dr(s, 1, n.times(a2), new s(1), true);
- for (var u, c = i, l2 = new s(8); c--; )
- u = n.times(n), n = o.minus(u.times(l2.minus(u.times(l2))));
- return J2(n, s.precision = e, s.rounding = t, true);
- };
- B2.hyperbolicSine = B2.sinh = function() {
- var i, a2, e, t, r = this, n = r.constructor;
- if (!r.isFinite() || r.isZero())
- return new n(r);
- if (a2 = n.precision, e = n.rounding, n.precision = a2 + Math.max(r.e, r.sd()) + 4, n.rounding = 1, t = r.d.length, t < 3)
- r = dr(n, 2, r, r, true);
- else {
- i = 1.4 * Math.sqrt(t), i = i > 16 ? 16 : i | 0, r = r.times(1 / Tn(5, i)), r = dr(n, 2, r, r, true);
- for (var s, o = new n(5), u = new n(16), c = new n(20); i--; )
- s = r.times(r), r = r.times(o.plus(s.times(u.times(s).plus(c))));
- }
- return n.precision = a2, n.rounding = e, J2(r, a2, e, true);
- };
- B2.hyperbolicTangent = B2.tanh = function() {
- var i, a2, e = this, t = e.constructor;
- return e.isFinite() ? e.isZero() ? new t(e) : (i = t.precision, a2 = t.rounding, t.precision = i + 7, t.rounding = 1, pe2(e.sinh(), e.cosh(), t.precision = i, t.rounding = a2)) : new t(e.s);
- };
- B2.inverseCosine = B2.acos = function() {
- var i, a2 = this, e = a2.constructor, t = a2.abs().cmp(1), r = e.precision, n = e.rounding;
- return t !== -1 ? t === 0 ? a2.isNeg() ? ot2(e, r, n) : new e(0) : new e(NaN) : a2.isZero() ? ot2(e, r + 4, n).times(0.5) : (e.precision = r + 6, e.rounding = 1, a2 = a2.asin(), i = ot2(e, r + 4, n).times(0.5), e.precision = r, e.rounding = n, i.minus(a2));
- };
- B2.inverseHyperbolicCosine = B2.acosh = function() {
- var i, a2, e = this, t = e.constructor;
- return e.lte(1) ? new t(e.eq(1) ? 0 : NaN) : e.isFinite() ? (i = t.precision, a2 = t.rounding, t.precision = i + Math.max(Math.abs(e.e), e.sd()) + 4, t.rounding = 1, ue2 = false, e = e.times(e).minus(1).sqrt().plus(e), ue2 = true, t.precision = i, t.rounding = a2, e.ln()) : new t(e);
- };
- B2.inverseHyperbolicSine = B2.asinh = function() {
- var i, a2, e = this, t = e.constructor;
- return !e.isFinite() || e.isZero() ? new t(e) : (i = t.precision, a2 = t.rounding, t.precision = i + 2 * Math.max(Math.abs(e.e), e.sd()) + 6, t.rounding = 1, ue2 = false, e = e.times(e).plus(1).sqrt().plus(e), ue2 = true, t.precision = i, t.rounding = a2, e.ln());
- };
- B2.inverseHyperbolicTangent = B2.atanh = function() {
- var i, a2, e, t, r = this, n = r.constructor;
- return r.isFinite() ? r.e >= 0 ? new n(r.abs().eq(1) ? r.s / 0 : r.isZero() ? r : NaN) : (i = n.precision, a2 = n.rounding, t = r.sd(), Math.max(t, i) < 2 * -r.e - 1 ? J2(new n(r), i, a2, true) : (n.precision = e = t - r.e, r = pe2(r.plus(1), new n(1).minus(r), e + i, 1), n.precision = i + 4, n.rounding = 1, r = r.ln(), n.precision = i, n.rounding = a2, r.times(0.5))) : new n(NaN);
- };
- B2.inverseSine = B2.asin = function() {
- var i, a2, e, t, r = this, n = r.constructor;
- return r.isZero() ? new n(r) : (a2 = r.abs().cmp(1), e = n.precision, t = n.rounding, a2 !== -1 ? a2 === 0 ? (i = ot2(n, e + 4, t).times(0.5), i.s = r.s, i) : new n(NaN) : (n.precision = e + 6, n.rounding = 1, r = r.div(new n(1).minus(r.times(r)).sqrt().plus(1)).atan(), n.precision = e, n.rounding = t, r.times(2)));
- };
- B2.inverseTangent = B2.atan = function() {
- var i, a2, e, t, r, n, s, o, u, c = this, l2 = c.constructor, f2 = l2.precision, h = l2.rounding;
- if (c.isFinite()) {
- if (c.isZero())
- return new l2(c);
- if (c.abs().eq(1) && f2 + 4 <= Us)
- return s = ot2(l2, f2 + 4, h).times(0.25), s.s = c.s, s;
- } else {
- if (!c.s)
- return new l2(NaN);
- if (f2 + 4 <= Us)
- return s = ot2(l2, f2 + 4, h).times(0.5), s.s = c.s, s;
- }
- for (l2.precision = o = f2 + 10, l2.rounding = 1, e = Math.min(28, o / te + 2 | 0), i = e; i; --i)
- c = c.div(c.times(c).plus(1).sqrt().plus(1));
- for (ue2 = false, a2 = Math.ceil(o / te), t = 1, u = c.times(c), s = new l2(c), r = c; i !== -1; )
- if (r = r.times(u), n = s.minus(r.div(t += 2)), r = r.times(u), s = n.plus(r.div(t += 2)), s.d[a2] !== void 0)
- for (i = a2; s.d[i] === n.d[i] && i--; )
- ;
- return e && (s = s.times(2 << e - 1)), ue2 = true, J2(s, l2.precision = f2, l2.rounding = h, true);
- };
- B2.isFinite = function() {
- return !!this.d;
- };
- B2.isInteger = B2.isInt = function() {
- return !!this.d && Be(this.e / te) > this.d.length - 2;
- };
- B2.isNaN = function() {
- return !this.s;
- };
- B2.isNegative = B2.isNeg = function() {
- return this.s < 0;
- };
- B2.isPositive = B2.isPos = function() {
- return this.s > 0;
- };
- B2.isZero = function() {
- return !!this.d && this.d[0] === 0;
- };
- B2.lessThan = B2.lt = function(i) {
- return this.cmp(i) < 0;
- };
- B2.lessThanOrEqualTo = B2.lte = function(i) {
- return this.cmp(i) < 1;
- };
- B2.logarithm = B2.log = function(i) {
- var a2, e, t, r, n, s, o, u, c = this, l2 = c.constructor, f2 = l2.precision, h = l2.rounding, d2 = 5;
- if (i == null)
- i = new l2(10), a2 = true;
- else {
- if (i = new l2(i), e = i.d, i.s < 0 || !e || !e[0] || i.eq(1))
- return new l2(NaN);
- a2 = i.eq(10);
- }
- if (e = c.d, c.s < 0 || !e || !e[0] || c.eq(1))
- return new l2(e && !e[0] ? -1 / 0 : c.s != 1 ? NaN : e ? 0 : 1 / 0);
- if (a2)
- if (e.length > 1)
- n = true;
- else {
- for (r = e[0]; r % 10 === 0; )
- r /= 10;
- n = r !== 1;
- }
- if (ue2 = false, o = f2 + d2, s = jt(c, o), t = a2 ? dn2(l2, o + 10) : jt(i, o), u = pe2(s, t, o, 1), Lr(u.d, r = f2, h))
- do
- if (o += 10, s = jt(c, o), t = a2 ? dn2(l2, o + 10) : jt(i, o), u = pe2(s, t, o, 1), !n) {
- +Ue(u.d).slice(r + 1, r + 15) + 1 == 1e14 && (u = J2(u, f2 + 1, 0));
- break;
- }
- while (Lr(u.d, r += 10, h));
- return ue2 = true, J2(u, f2, h);
- };
- B2.minus = B2.sub = function(i) {
- var a2, e, t, r, n, s, o, u, c, l2, f2, h, d2 = this, _ = d2.constructor;
- if (i = new _(i), !d2.d || !i.d)
- return !d2.s || !i.s ? i = new _(NaN) : d2.d ? i.s = -i.s : i = new _(i.d || d2.s !== i.s ? d2 : NaN), i;
- if (d2.s != i.s)
- return i.s = -i.s, d2.plus(i);
- if (c = d2.d, h = i.d, o = _.precision, u = _.rounding, !c[0] || !h[0]) {
- if (h[0])
- i.s = -i.s;
- else if (c[0])
- i = new _(d2);
- else
- return new _(u === 3 ? -0 : 0);
- return ue2 ? J2(i, o, u) : i;
- }
- if (e = Be(i.e / te), l2 = Be(d2.e / te), c = c.slice(), n = l2 - e, n) {
- for (f2 = n < 0, f2 ? (a2 = c, n = -n, s = h.length) : (a2 = h, e = l2, s = c.length), t = Math.max(Math.ceil(o / te), s) + 2, n > t && (n = t, a2.length = 1), a2.reverse(), t = n; t--; )
- a2.push(0);
- a2.reverse();
- } else {
- for (t = c.length, s = h.length, f2 = t < s, f2 && (s = t), t = 0; t < s; t++)
- if (c[t] != h[t]) {
- f2 = c[t] < h[t];
- break;
- }
- n = 0;
- }
- for (f2 && (a2 = c, c = h, h = a2, i.s = -i.s), s = c.length, t = h.length - s; t > 0; --t)
- c[s++] = 0;
- for (t = h.length; t > n; ) {
- if (c[--t] < h[t]) {
- for (r = t; r && c[--r] === 0; )
- c[r] = ut - 1;
- --c[r], c[t] += ut;
- }
- c[t] -= h[t];
- }
- for (; c[--s] === 0; )
- c.pop();
- for (; c[0] === 0; c.shift())
- --e;
- return c[0] ? (i.d = c, i.e = vn(c, e), ue2 ? J2(i, o, u) : i) : new _(u === 3 ? -0 : 0);
- };
- B2.modulo = B2.mod = function(i) {
- var a2, e = this, t = e.constructor;
- return i = new t(i), !e.d || !i.s || i.d && !i.d[0] ? new t(NaN) : !i.d || e.d && !e.d[0] ? J2(new t(e), t.precision, t.rounding) : (ue2 = false, t.modulo == 9 ? (a2 = pe2(e, i.abs(), 0, 3, 1), a2.s *= i.s) : a2 = pe2(e, i, 0, t.modulo, 1), a2 = a2.times(i), ue2 = true, e.minus(a2));
- };
- B2.naturalExponential = B2.exp = function() {
- return vs(this);
- };
- B2.naturalLogarithm = B2.ln = function() {
- return jt(this);
- };
- B2.negated = B2.neg = function() {
- var i = new this.constructor(this);
- return i.s = -i.s, J2(i);
- };
- B2.plus = B2.add = function(i) {
- var a2, e, t, r, n, s, o, u, c, l2, f2 = this, h = f2.constructor;
- if (i = new h(i), !f2.d || !i.d)
- return !f2.s || !i.s ? i = new h(NaN) : f2.d || (i = new h(i.d || f2.s === i.s ? f2 : NaN)), i;
- if (f2.s != i.s)
- return i.s = -i.s, f2.minus(i);
- if (c = f2.d, l2 = i.d, o = h.precision, u = h.rounding, !c[0] || !l2[0])
- return l2[0] || (i = new h(f2)), ue2 ? J2(i, o, u) : i;
- if (n = Be(f2.e / te), t = Be(i.e / te), c = c.slice(), r = n - t, r) {
- for (r < 0 ? (e = c, r = -r, s = l2.length) : (e = l2, t = n, s = c.length), n = Math.ceil(o / te), s = n > s ? n + 1 : s + 1, r > s && (r = s, e.length = 1), e.reverse(); r--; )
- e.push(0);
- e.reverse();
- }
- for (s = c.length, r = l2.length, s - r < 0 && (r = s, e = l2, l2 = c, c = e), a2 = 0; r; )
- a2 = (c[--r] = c[r] + l2[r] + a2) / ut | 0, c[r] %= ut;
- for (a2 && (c.unshift(a2), ++t), s = c.length; c[--s] == 0; )
- c.pop();
- return i.d = c, i.e = vn(c, t), ue2 ? J2(i, o, u) : i;
- };
- B2.precision = B2.sd = function(i) {
- var a2, e = this;
- if (i !== void 0 && i !== !!i && i !== 1 && i !== 0)
- throw Error(Bt + i);
- return e.d ? (a2 = fo(e.d), i && e.e + 1 > a2 && (a2 = e.e + 1)) : a2 = NaN, a2;
- };
- B2.round = function() {
- var i = this, a2 = i.constructor;
- return J2(new a2(i), i.e + 1, a2.rounding);
- };
- B2.sine = B2.sin = function() {
- var i, a2, e = this, t = e.constructor;
- return e.isFinite() ? e.isZero() ? new t(e) : (i = t.precision, a2 = t.rounding, t.precision = i + Math.max(e.e, e.sd()) + te, t.rounding = 1, e = bl(t, Co(t, e)), t.precision = i, t.rounding = a2, J2(Rt > 2 ? e.neg() : e, i, a2, true)) : new t(NaN);
- };
- B2.squareRoot = B2.sqrt = function() {
- var i, a2, e, t, r, n, s = this, o = s.d, u = s.e, c = s.s, l2 = s.constructor;
- if (c !== 1 || !o || !o[0])
- return new l2(!c || c < 0 && (!o || o[0]) ? NaN : o ? s : 1 / 0);
- for (ue2 = false, c = Math.sqrt(+s), c == 0 || c == 1 / 0 ? (a2 = Ue(o), (a2.length + u) % 2 == 0 && (a2 += "0"), c = Math.sqrt(a2), u = Be((u + 1) / 2) - (u < 0 || u % 2), c == 1 / 0 ? a2 = "5e" + u : (a2 = c.toExponential(), a2 = a2.slice(0, a2.indexOf("e") + 1) + u), t = new l2(a2)) : t = new l2(c.toString()), e = (u = l2.precision) + 3; ; )
- if (n = t, t = n.plus(pe2(s, n, e + 2, 1)).times(0.5), Ue(n.d).slice(0, e) === (a2 = Ue(t.d)).slice(0, e))
- if (a2 = a2.slice(e - 3, e + 1), a2 == "9999" || !r && a2 == "4999") {
- if (!r && (J2(n, u + 1, 0), n.times(n).eq(s))) {
- t = n;
- break;
- }
- e += 4, r = 1;
- } else {
- (!+a2 || !+a2.slice(1) && a2.charAt(0) == "5") && (J2(t, u + 1, 1), i = !t.times(t).eq(s));
- break;
- }
- return ue2 = true, J2(t, u, l2.rounding, i);
- };
- B2.tangent = B2.tan = function() {
- var i, a2, e = this, t = e.constructor;
- return e.isFinite() ? e.isZero() ? new t(e) : (i = t.precision, a2 = t.rounding, t.precision = i + 10, t.rounding = 1, e = e.sin(), e.s = 1, e = pe2(e, new t(1).minus(e.times(e)).sqrt(), i + 10, 0), t.precision = i, t.rounding = a2, J2(Rt == 2 || Rt == 4 ? e.neg() : e, i, a2, true)) : new t(NaN);
- };
- B2.times = B2.mul = function(i) {
- var a2, e, t, r, n, s, o, u, c, l2 = this, f2 = l2.constructor, h = l2.d, d2 = (i = new f2(i)).d;
- if (i.s *= l2.s, !h || !h[0] || !d2 || !d2[0])
- return new f2(!i.s || h && !h[0] && !d2 || d2 && !d2[0] && !h ? NaN : !h || !d2 ? i.s / 0 : i.s * 0);
- for (e = Be(l2.e / te) + Be(i.e / te), u = h.length, c = d2.length, u < c && (n = h, h = d2, d2 = n, s = u, u = c, c = s), n = [], s = u + c, t = s; t--; )
- n.push(0);
- for (t = c; --t >= 0; ) {
- for (a2 = 0, r = u + t; r > t; )
- o = n[r] + d2[t] * h[r - t - 1] + a2, n[r--] = o % ut | 0, a2 = o / ut | 0;
- n[r] = (n[r] + a2) % ut | 0;
- }
- for (; !n[--s]; )
- n.pop();
- return a2 ? ++e : n.shift(), i.d = n, i.e = vn(n, e), ue2 ? J2(i, f2.precision, f2.rounding) : i;
- };
- B2.toBinary = function(i, a2) {
- return ga(this, 2, i, a2);
- };
- B2.toDecimalPlaces = B2.toDP = function(i, a2) {
- var e = this, t = e.constructor;
- return e = new t(e), i === void 0 ? e : (He(i, 0, $t), a2 === void 0 ? a2 = t.rounding : He(a2, 0, 8), J2(e, i + e.e + 1, a2));
- };
- B2.toExponential = function(i, a2) {
- var e, t = this, r = t.constructor;
- return i === void 0 ? e = Ct2(t, true) : (He(i, 0, $t), a2 === void 0 ? a2 = r.rounding : He(a2, 0, 8), t = J2(new r(t), i + 1, a2), e = Ct2(t, true, i + 1)), t.isNeg() && !t.isZero() ? "-" + e : e;
- };
- B2.toFixed = function(i, a2) {
- var e, t, r = this, n = r.constructor;
- return i === void 0 ? e = Ct2(r) : (He(i, 0, $t), a2 === void 0 ? a2 = n.rounding : He(a2, 0, 8), t = J2(new n(r), i + r.e + 1, a2), e = Ct2(t, false, i + t.e + 1)), r.isNeg() && !r.isZero() ? "-" + e : e;
- };
- B2.toFraction = function(i) {
- var a2, e, t, r, n, s, o, u, c, l2, f2, h, d2 = this, _ = d2.d, C = d2.constructor;
- if (!_)
- return new C(d2);
- if (c = e = new C(1), t = u = new C(0), a2 = new C(t), n = a2.e = fo(_) - d2.e - 1, s = n % te, a2.d[0] = Le(10, s < 0 ? te + s : s), i == null)
- i = n > 0 ? a2 : c;
- else {
- if (o = new C(i), !o.isInt() || o.lt(c))
- throw Error(Bt + o);
- i = o.gt(a2) ? n > 0 ? a2 : c : o;
- }
- for (ue2 = false, o = new C(Ue(_)), l2 = C.precision, C.precision = n = _.length * te * 2; f2 = pe2(o, a2, 0, 1, 1), r = e.plus(f2.times(t)), r.cmp(i) != 1; )
- e = t, t = r, r = c, c = u.plus(f2.times(r)), u = r, r = a2, a2 = o.minus(f2.times(r)), o = r;
- return r = pe2(i.minus(e), t, 0, 1, 1), u = u.plus(r.times(c)), e = e.plus(r.times(t)), u.s = c.s = d2.s, h = pe2(c, t, n, 1).minus(d2).abs().cmp(pe2(u, e, n, 1).minus(d2).abs()) < 1 ? [c, t] : [u, e], C.precision = l2, ue2 = true, h;
- };
- B2.toHexadecimal = B2.toHex = function(i, a2) {
- return ga(this, 16, i, a2);
- };
- B2.toNearest = function(i, a2) {
- var e = this, t = e.constructor;
- if (e = new t(e), i == null) {
- if (!e.d)
- return e;
- i = new t(1), a2 = t.rounding;
- } else {
- if (i = new t(i), a2 === void 0 ? a2 = t.rounding : He(a2, 0, 8), !e.d)
- return i.s ? e : i;
- if (!i.d)
- return i.s && (i.s = e.s), i;
- }
- return i.d[0] ? (ue2 = false, e = pe2(e, i, 0, a2, 1).times(i), ue2 = true, J2(e)) : (i.s = e.s, e = i), e;
- };
- B2.toNumber = function() {
- return +this;
- };
- B2.toOctal = function(i, a2) {
- return ga(this, 8, i, a2);
- };
- B2.toPower = B2.pow = function(i) {
- var a2, e, t, r, n, s, o = this, u = o.constructor, c = +(i = new u(i));
- if (!o.d || !i.d || !o.d[0] || !i.d[0])
- return new u(Le(+o, c));
- if (o = new u(o), o.eq(1))
- return o;
- if (t = u.precision, n = u.rounding, i.eq(1))
- return J2(o, t, n);
- if (a2 = Be(i.e / te), a2 >= i.d.length - 1 && (e = c < 0 ? -c : c) <= Cl)
- return r = ho(u, o, e, t), i.s < 0 ? new u(1).div(r) : J2(r, t, n);
- if (s = o.s, s < 0) {
- if (a2 < i.d.length - 1)
- return new u(NaN);
- if (i.d[a2] & 1 || (s = 1), o.e == 0 && o.d[0] == 1 && o.d.length == 1)
- return o.s = s, o;
- }
- return e = Le(+o, c), a2 = e == 0 || !isFinite(e) ? Be(c * (Math.log("0." + Ue(o.d)) / Math.LN10 + o.e + 1)) : new u(e + "").e, a2 > u.maxE + 1 || a2 < u.minE - 1 ? new u(a2 > 0 ? s / 0 : 0) : (ue2 = false, u.rounding = o.s = 1, e = Math.min(12, (a2 + "").length), r = vs(i.times(jt(o, t + e)), t), r.d && (r = J2(r, t + 5, 1), Lr(r.d, t, n) && (a2 = t + 10, r = J2(vs(i.times(jt(o, a2 + e)), a2), a2 + 5, 1), +Ue(r.d).slice(t + 1, t + 15) + 1 == 1e14 && (r = J2(r, t + 1, 0)))), r.s = s, ue2 = true, u.rounding = n, J2(r, t, n));
- };
- B2.toPrecision = function(i, a2) {
- var e, t = this, r = t.constructor;
- return i === void 0 ? e = Ct2(t, t.e <= r.toExpNeg || t.e >= r.toExpPos) : (He(i, 1, $t), a2 === void 0 ? a2 = r.rounding : He(a2, 0, 8), t = J2(new r(t), i, a2), e = Ct2(t, i <= t.e || t.e <= r.toExpNeg, i)), t.isNeg() && !t.isZero() ? "-" + e : e;
- };
- B2.toSignificantDigits = B2.toSD = function(i, a2) {
- var e = this, t = e.constructor;
- return i === void 0 ? (i = t.precision, a2 = t.rounding) : (He(i, 1, $t), a2 === void 0 ? a2 = t.rounding : He(a2, 0, 8)), J2(new t(e), i, a2);
- };
- B2.toString = function() {
- var i = this, a2 = i.constructor, e = Ct2(i, i.e <= a2.toExpNeg || i.e >= a2.toExpPos);
- return i.isNeg() && !i.isZero() ? "-" + e : e;
- };
- B2.truncated = B2.trunc = function() {
- return J2(new this.constructor(this), this.e + 1, 1);
- };
- B2.valueOf = B2.toJSON = function() {
- var i = this, a2 = i.constructor, e = Ct2(i, i.e <= a2.toExpNeg || i.e >= a2.toExpPos);
- return i.isNeg() ? "-" + e : e;
- };
- function Ue(i) {
- var a2, e, t, r = i.length - 1, n = "", s = i[0];
- if (r > 0) {
- for (n += s, a2 = 1; a2 < r; a2++)
- t = i[a2] + "", e = te - t.length, e && (n += Pt2(e)), n += t;
- s = i[a2], t = s + "", e = te - t.length, e && (n += Pt2(e));
- } else if (s === 0)
- return "0";
- for (; s % 10 === 0; )
- s /= 10;
- return n + s;
- }
- function He(i, a2, e) {
- if (i !== ~~i || i < a2 || i > e)
- throw Error(Bt + i);
- }
- function Lr(i, a2, e, t) {
- var r, n, s, o;
- for (n = i[0]; n >= 10; n /= 10)
- --a2;
- return --a2 < 0 ? (a2 += te, r = 0) : (r = Math.ceil((a2 + 1) / te), a2 %= te), n = Le(10, te - a2), o = i[r] % n | 0, t == null ? a2 < 3 ? (a2 == 0 ? o = o / 100 | 0 : a2 == 1 && (o = o / 10 | 0), s = e < 4 && o == 99999 || e > 3 && o == 49999 || o == 5e4 || o == 0) : s = (e < 4 && o + 1 == n || e > 3 && o + 1 == n / 2) && (i[r + 1] / n / 100 | 0) == Le(10, a2 - 2) - 1 || (o == n / 2 || o == 0) && (i[r + 1] / n / 100 | 0) == 0 : a2 < 4 ? (a2 == 0 ? o = o / 1e3 | 0 : a2 == 1 ? o = o / 100 | 0 : a2 == 2 && (o = o / 10 | 0), s = (t || e < 4) && o == 9999 || !t && e > 3 && o == 4999) : s = ((t || e < 4) && o + 1 == n || !t && e > 3 && o + 1 == n / 2) && (i[r + 1] / n / 1e3 | 0) == Le(10, a2 - 3) - 1, s;
- }
- function sn(i, a2, e) {
- for (var t, r = [0], n, s = 0, o = i.length; s < o; ) {
- for (n = r.length; n--; )
- r[n] *= a2;
- for (r[0] += xs.indexOf(i.charAt(s++)), t = 0; t < r.length; t++)
- r[t] > e - 1 && (r[t + 1] === void 0 && (r[t + 1] = 0), r[t + 1] += r[t] / e | 0, r[t] %= e);
- }
- return r.reverse();
- }
- function Al(i, a2) {
- var e, t, r;
- if (a2.isZero())
- return a2;
- t = a2.d.length, t < 32 ? (e = Math.ceil(t / 3), r = (1 / Tn(4, e)).toString()) : (e = 16, r = "2.3283064365386962890625e-10"), i.precision += e, a2 = dr(i, 1, a2.times(r), new i(1));
- for (var n = e; n--; ) {
- var s = a2.times(a2);
- a2 = s.times(s).minus(s).times(8).plus(1);
- }
- return i.precision -= e, a2;
- }
- var pe2 = function() {
- function i(t, r, n) {
- var s, o = 0, u = t.length;
- for (t = t.slice(); u--; )
- s = t[u] * r + o, t[u] = s % n | 0, o = s / n | 0;
- return o && t.unshift(o), t;
- }
- function a2(t, r, n, s) {
- var o, u;
- if (n != s)
- u = n > s ? 1 : -1;
- else
- for (o = u = 0; o < n; o++)
- if (t[o] != r[o]) {
- u = t[o] > r[o] ? 1 : -1;
- break;
- }
- return u;
- }
- function e(t, r, n, s) {
- for (var o = 0; n--; )
- t[n] -= o, o = t[n] < r[n] ? 1 : 0, t[n] = o * s + t[n] - r[n];
- for (; !t[0] && t.length > 1; )
- t.shift();
- }
- return function(t, r, n, s, o, u) {
- var c, l2, f2, h, d2, _, C, E2, b, R, p2, N2, M2, w, D2, S2, P, U2, x2, F, W2 = t.constructor, ne = t.s == r.s ? 1 : -1, z = t.d, G2 = r.d;
- if (!z || !z[0] || !G2 || !G2[0])
- return new W2(
- // Return NaN if either NaN, or both Infinity or 0.
- !t.s || !r.s || (z ? G2 && z[0] == G2[0] : !G2) ? NaN : (
- // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
- z && z[0] == 0 || !G2 ? ne * 0 : ne / 0
- )
- );
- for (u ? (d2 = 1, l2 = t.e - r.e) : (u = ut, d2 = te, l2 = Be(t.e / d2) - Be(r.e / d2)), x2 = G2.length, P = z.length, b = new W2(ne), R = b.d = [], f2 = 0; G2[f2] == (z[f2] || 0); f2++)
- ;
- if (G2[f2] > (z[f2] || 0) && l2--, n == null ? (w = n = W2.precision, s = W2.rounding) : o ? w = n + (t.e - r.e) + 1 : w = n, w < 0)
- R.push(1), _ = true;
- else {
- if (w = w / d2 + 2 | 0, f2 = 0, x2 == 1) {
- for (h = 0, G2 = G2[0], w++; (f2 < P || h) && w--; f2++)
- D2 = h * u + (z[f2] || 0), R[f2] = D2 / G2 | 0, h = D2 % G2 | 0;
- _ = h || f2 < P;
- } else {
- for (h = u / (G2[0] + 1) | 0, h > 1 && (G2 = i(G2, h, u), z = i(z, h, u), x2 = G2.length, P = z.length), S2 = x2, p2 = z.slice(0, x2), N2 = p2.length; N2 < x2; )
- p2[N2++] = 0;
- F = G2.slice(), F.unshift(0), U2 = G2[0], G2[1] >= u / 2 && ++U2;
- do
- h = 0, c = a2(G2, p2, x2, N2), c < 0 ? (M2 = p2[0], x2 != N2 && (M2 = M2 * u + (p2[1] || 0)), h = M2 / U2 | 0, h > 1 ? (h >= u && (h = u - 1), C = i(G2, h, u), E2 = C.length, N2 = p2.length, c = a2(C, p2, E2, N2), c == 1 && (h--, e(C, x2 < E2 ? F : G2, E2, u))) : (h == 0 && (c = h = 1), C = G2.slice()), E2 = C.length, E2 < N2 && C.unshift(0), e(p2, C, N2, u), c == -1 && (N2 = p2.length, c = a2(G2, p2, x2, N2), c < 1 && (h++, e(p2, x2 < N2 ? F : G2, N2, u))), N2 = p2.length) : c === 0 && (h++, p2 = [0]), R[f2++] = h, c && p2[0] ? p2[N2++] = z[S2] || 0 : (p2 = [z[S2]], N2 = 1);
- while ((S2++ < P || p2[0] !== void 0) && w--);
- _ = p2[0] !== void 0;
- }
- R[0] || R.shift();
- }
- if (d2 == 1)
- b.e = l2, io = _;
- else {
- for (f2 = 1, h = R[0]; h >= 10; h /= 10)
- f2++;
- b.e = f2 + l2 * d2 - 1, J2(b, o ? n + b.e + 1 : n, s, _);
- }
- return b;
- };
- }();
- function J2(i, a2, e, t) {
- var r, n, s, o, u, c, l2, f2, h, d2 = i.constructor;
- e:
- if (a2 != null) {
- if (f2 = i.d, !f2)
- return i;
- for (r = 1, o = f2[0]; o >= 10; o /= 10)
- r++;
- if (n = a2 - r, n < 0)
- n += te, s = a2, l2 = f2[h = 0], u = l2 / Le(10, r - s - 1) % 10 | 0;
- else if (h = Math.ceil((n + 1) / te), o = f2.length, h >= o)
- if (t) {
- for (; o++ <= h; )
- f2.push(0);
- l2 = u = 0, r = 1, n %= te, s = n - te + 1;
- } else
- break e;
- else {
- for (l2 = o = f2[h], r = 1; o >= 10; o /= 10)
- r++;
- n %= te, s = n - te + r, u = s < 0 ? 0 : l2 / Le(10, r - s - 1) % 10 | 0;
- }
- if (t = t || a2 < 0 || f2[h + 1] !== void 0 || (s < 0 ? l2 : l2 % Le(10, r - s - 1)), c = e < 4 ? (u || t) && (e == 0 || e == (i.s < 0 ? 3 : 2)) : u > 5 || u == 5 && (e == 4 || t || e == 6 && // Check whether the digit to the left of the rounding digit is odd.
- (n > 0 ? s > 0 ? l2 / Le(10, r - s) : 0 : f2[h - 1]) % 10 & 1 || e == (i.s < 0 ? 8 : 7)), a2 < 1 || !f2[0])
- return f2.length = 0, c ? (a2 -= i.e + 1, f2[0] = Le(10, (te - a2 % te) % te), i.e = -a2 || 0) : f2[0] = i.e = 0, i;
- if (n == 0 ? (f2.length = h, o = 1, h--) : (f2.length = h + 1, o = Le(10, te - n), f2[h] = s > 0 ? (l2 / Le(10, r - s) % Le(10, s) | 0) * o : 0), c)
- for (; ; )
- if (h == 0) {
- for (n = 1, s = f2[0]; s >= 10; s /= 10)
- n++;
- for (s = f2[0] += o, o = 1; s >= 10; s /= 10)
- o++;
- n != o && (i.e++, f2[0] == ut && (f2[0] = 1));
- break;
- } else {
- if (f2[h] += o, f2[h] != ut)
- break;
- f2[h--] = 0, o = 1;
- }
- for (n = f2.length; f2[--n] === 0; )
- f2.pop();
- }
- return ue2 && (i.e > d2.maxE ? (i.d = null, i.e = NaN) : i.e < d2.minE && (i.e = 0, i.d = [0])), i;
- }
- function Ct2(i, a2, e) {
- if (!i.isFinite())
- return go(i);
- var t, r = i.e, n = Ue(i.d), s = n.length;
- return a2 ? (e && (t = e - s) > 0 ? n = n.charAt(0) + "." + n.slice(1) + Pt2(t) : s > 1 && (n = n.charAt(0) + "." + n.slice(1)), n = n + (i.e < 0 ? "e" : "e+") + i.e) : r < 0 ? (n = "0." + Pt2(-r - 1) + n, e && (t = e - s) > 0 && (n += Pt2(t))) : r >= s ? (n += Pt2(r + 1 - s), e && (t = e - r - 1) > 0 && (n = n + "." + Pt2(t))) : ((t = r + 1) < s && (n = n.slice(0, t) + "." + n.slice(t)), e && (t = e - s) > 0 && (r + 1 === s && (n += "."), n += Pt2(t))), n;
- }
- function vn(i, a2) {
- var e = i[0];
- for (a2 *= te; e >= 10; e /= 10)
- a2++;
- return a2;
- }
- function dn2(i, a2, e) {
- if (a2 > _l)
- throw ue2 = true, e && (i.precision = e), Error(oo);
- return J2(new i(mn), a2, 1, true);
- }
- function ot2(i, a2, e) {
- if (a2 > Us)
- throw Error(oo);
- return J2(new i(gn), a2, e, true);
- }
- function fo(i) {
- var a2 = i.length - 1, e = a2 * te + 1;
- if (a2 = i[a2], a2) {
- for (; a2 % 10 == 0; a2 /= 10)
- e--;
- for (a2 = i[0]; a2 >= 10; a2 /= 10)
- e++;
- }
- return e;
- }
- function Pt2(i) {
- for (var a2 = ""; i--; )
- a2 += "0";
- return a2;
- }
- function ho(i, a2, e, t) {
- var r, n = new i(1), s = Math.ceil(t / te + 4);
- for (ue2 = false; ; ) {
- if (e % 2 && (n = n.times(a2), hi(n.d, s) && (r = true)), e = Be(e / 2), e === 0) {
- e = n.d.length - 1, r && n.d[e] === 0 && ++n.d[e];
- break;
- }
- a2 = a2.times(a2), hi(a2.d, s);
- }
- return ue2 = true, n;
- }
- function fi(i) {
- return i.d[i.d.length - 1] & 1;
- }
- function mo(i, a2, e) {
- for (var t, r = new i(a2[0]), n = 0; ++n < a2.length; )
- if (t = new i(a2[n]), t.s)
- r[e](t) && (r = t);
- else {
- r = t;
- break;
- }
- return r;
- }
- function vs(i, a2) {
- var e, t, r, n, s, o, u, c = 0, l2 = 0, f2 = 0, h = i.constructor, d2 = h.rounding, _ = h.precision;
- if (!i.d || !i.d[0] || i.e > 17)
- return new h(i.d ? i.d[0] ? i.s < 0 ? 0 : 1 / 0 : 1 : i.s ? i.s < 0 ? 0 : i : NaN);
- for (a2 == null ? (ue2 = false, u = _) : u = a2, o = new h(0.03125); i.e > -2; )
- i = i.times(o), f2 += 5;
- for (t = Math.log(Le(2, f2)) / Math.LN10 * 2 + 5 | 0, u += t, e = n = s = new h(1), h.precision = u; ; ) {
- if (n = J2(n.times(i), u, 1), e = e.times(++l2), o = s.plus(pe2(n, e, u, 1)), Ue(o.d).slice(0, u) === Ue(s.d).slice(0, u)) {
- for (r = f2; r--; )
- s = J2(s.times(s), u, 1);
- if (a2 == null)
- if (c < 3 && Lr(s.d, u - t, d2, c))
- h.precision = u += 10, e = n = o = new h(1), l2 = 0, c++;
- else
- return J2(s, h.precision = _, d2, ue2 = true);
- else
- return h.precision = _, s;
- }
- s = o;
- }
- }
- function jt(i, a2) {
- var e, t, r, n, s, o, u, c, l2, f2, h, d2 = 1, _ = 10, C = i, E2 = C.d, b = C.constructor, R = b.rounding, p2 = b.precision;
- if (C.s < 0 || !E2 || !E2[0] || !C.e && E2[0] == 1 && E2.length == 1)
- return new b(E2 && !E2[0] ? -1 / 0 : C.s != 1 ? NaN : E2 ? 0 : C);
- if (a2 == null ? (ue2 = false, l2 = p2) : l2 = a2, b.precision = l2 += _, e = Ue(E2), t = e.charAt(0), Math.abs(n = C.e) < 15e14) {
- for (; t < 7 && t != 1 || t == 1 && e.charAt(1) > 3; )
- C = C.times(i), e = Ue(C.d), t = e.charAt(0), d2++;
- n = C.e, t > 1 ? (C = new b("0." + e), n++) : C = new b(t + "." + e.slice(1));
- } else
- return c = dn2(b, l2 + 2, p2).times(n + ""), C = jt(new b(t + "." + e.slice(1)), l2 - _).plus(c), b.precision = p2, a2 == null ? J2(C, p2, R, ue2 = true) : C;
- for (f2 = C, u = s = C = pe2(C.minus(1), C.plus(1), l2, 1), h = J2(C.times(C), l2, 1), r = 3; ; ) {
- if (s = J2(s.times(h), l2, 1), c = u.plus(pe2(s, new b(r), l2, 1)), Ue(c.d).slice(0, l2) === Ue(u.d).slice(0, l2))
- if (u = u.times(2), n !== 0 && (u = u.plus(dn2(b, l2 + 2, p2).times(n + ""))), u = pe2(u, new b(d2), l2, 1), a2 == null)
- if (Lr(u.d, l2 - _, R, o))
- b.precision = l2 += _, c = s = C = pe2(f2.minus(1), f2.plus(1), l2, 1), h = J2(C.times(C), l2, 1), r = o = 1;
- else
- return J2(u, b.precision = p2, R, ue2 = true);
- else
- return b.precision = p2, u;
- u = c, r += 2;
- }
- }
- function go(i) {
- return String(i.s * i.s / 0);
- }
- function Ts(i, a2) {
- var e, t, r;
- for ((e = a2.indexOf(".")) > -1 && (a2 = a2.replace(".", "")), (t = a2.search(/e/i)) > 0 ? (e < 0 && (e = t), e += +a2.slice(t + 1), a2 = a2.substring(0, t)) : e < 0 && (e = a2.length), t = 0; a2.charCodeAt(t) === 48; t++)
- ;
- for (r = a2.length; a2.charCodeAt(r - 1) === 48; --r)
- ;
- if (a2 = a2.slice(t, r), a2) {
- if (r -= t, i.e = e = e - t - 1, i.d = [], t = (e + 1) % te, e < 0 && (t += te), t < r) {
- for (t && i.d.push(+a2.slice(0, t)), r -= te; t < r; )
- i.d.push(+a2.slice(t, t += te));
- a2 = a2.slice(t), t = te - a2.length;
- } else
- t -= r;
- for (; t--; )
- a2 += "0";
- i.d.push(+a2), ue2 && (i.e > i.constructor.maxE ? (i.d = null, i.e = NaN) : i.e < i.constructor.minE && (i.e = 0, i.d = [0]));
- } else
- i.e = 0, i.d = [0];
- return i;
- }
- function El(i, a2) {
- var e, t, r, n, s, o, u, c, l2;
- if (a2.indexOf("_") > -1) {
- if (a2 = a2.replace(/(\d)_(?=\d)/g, "$1"), lo.test(a2))
- return Ts(i, a2);
- } else if (a2 === "Infinity" || a2 === "NaN")
- return +a2 || (i.s = NaN), i.e = NaN, i.d = null, i;
- if (gl.test(a2))
- e = 16, a2 = a2.toLowerCase();
- else if (ml.test(a2))
- e = 2;
- else if (dl.test(a2))
- e = 8;
- else
- throw Error(Bt + a2);
- for (n = a2.search(/p/i), n > 0 ? (u = +a2.slice(n + 1), a2 = a2.substring(2, n)) : a2 = a2.slice(2), n = a2.indexOf("."), s = n >= 0, t = i.constructor, s && (a2 = a2.replace(".", ""), o = a2.length, n = o - n, r = ho(t, new t(e), n, n * 2)), c = sn(a2, e, ut), l2 = c.length - 1, n = l2; c[n] === 0; --n)
- c.pop();
- return n < 0 ? new t(i.s * 0) : (i.e = vn(c, l2), i.d = c, ue2 = false, s && (i = pe2(i, r, o * 4)), u && (i = i.times(Math.abs(u) < 54 ? Le(2, u) : L2.pow(2, u))), ue2 = true, i);
- }
- function bl(i, a2) {
- var e, t = a2.d.length;
- if (t < 3)
- return a2.isZero() ? a2 : dr(i, 2, a2, a2);
- e = 1.4 * Math.sqrt(t), e = e > 16 ? 16 : e | 0, a2 = a2.times(1 / Tn(5, e)), a2 = dr(i, 2, a2, a2);
- for (var r, n = new i(5), s = new i(16), o = new i(20); e--; )
- r = a2.times(a2), a2 = a2.times(n.plus(r.times(s.times(r).minus(o))));
- return a2;
- }
- function dr(i, a2, e, t, r) {
- var n, s, o, u, c = i.precision, l2 = Math.ceil(c / te);
- for (ue2 = false, u = e.times(e), o = new i(t); ; ) {
- if (s = pe2(o.times(u), new i(a2++ * a2++), c, 1), o = r ? t.plus(s) : t.minus(s), t = pe2(s.times(u), new i(a2++ * a2++), c, 1), s = o.plus(t), s.d[l2] !== void 0) {
- for (n = l2; s.d[n] === o.d[n] && n--; )
- ;
- if (n == -1)
- break;
- }
- n = o, o = t, t = s, s = n;
- }
- return ue2 = true, s.d.length = l2 + 1, s;
- }
- function Tn(i, a2) {
- for (var e = i; --a2; )
- e *= i;
- return e;
- }
- function Co(i, a2) {
- var e, t = a2.s < 0, r = ot2(i, i.precision, 1), n = r.times(0.5);
- if (a2 = a2.abs(), a2.lte(n))
- return Rt = t ? 4 : 1, a2;
- if (e = a2.divToInt(r), e.isZero())
- Rt = t ? 3 : 2;
- else {
- if (a2 = a2.minus(e.times(r)), a2.lte(n))
- return Rt = fi(e) ? t ? 2 : 3 : t ? 4 : 1, a2;
- Rt = fi(e) ? t ? 1 : 4 : t ? 3 : 2;
- }
- return a2.minus(r).abs();
- }
- function ga(i, a2, e, t) {
- var r, n, s, o, u, c, l2, f2, h, d2 = i.constructor, _ = e !== void 0;
- if (_ ? (He(e, 1, $t), t === void 0 ? t = d2.rounding : He(t, 0, 8)) : (e = d2.precision, t = d2.rounding), !i.isFinite())
- l2 = go(i);
- else {
- for (l2 = Ct2(i), s = l2.indexOf("."), _ ? (r = 2, a2 == 16 ? e = e * 4 - 3 : a2 == 8 && (e = e * 3 - 2)) : r = a2, s >= 0 && (l2 = l2.replace(".", ""), h = new d2(1), h.e = l2.length - s, h.d = sn(Ct2(h), 10, r), h.e = h.d.length), f2 = sn(l2, 10, r), n = u = f2.length; f2[--u] == 0; )
- f2.pop();
- if (!f2[0])
- l2 = _ ? "0p+0" : "0";
- else {
- if (s < 0 ? n-- : (i = new d2(i), i.d = f2, i.e = n, i = pe2(i, h, e, t, 0, r), f2 = i.d, n = i.e, c = io), s = f2[e], o = r / 2, c = c || f2[e + 1] !== void 0, c = t < 4 ? (s !== void 0 || c) && (t === 0 || t === (i.s < 0 ? 3 : 2)) : s > o || s === o && (t === 4 || c || t === 6 && f2[e - 1] & 1 || t === (i.s < 0 ? 8 : 7)), f2.length = e, c)
- for (; ++f2[--e] > r - 1; )
- f2[e] = 0, e || (++n, f2.unshift(1));
- for (u = f2.length; !f2[u - 1]; --u)
- ;
- for (s = 0, l2 = ""; s < u; s++)
- l2 += xs.charAt(f2[s]);
- if (_) {
- if (u > 1)
- if (a2 == 16 || a2 == 8) {
- for (s = a2 == 16 ? 4 : 3, --u; u % s; u++)
- l2 += "0";
- for (f2 = sn(l2, r, a2), u = f2.length; !f2[u - 1]; --u)
- ;
- for (s = 1, l2 = "1."; s < u; s++)
- l2 += xs.charAt(f2[s]);
- } else
- l2 = l2.charAt(0) + "." + l2.slice(1);
- l2 = l2 + (n < 0 ? "p" : "p+") + n;
- } else if (n < 0) {
- for (; ++n; )
- l2 = "0" + l2;
- l2 = "0." + l2;
- } else if (++n > u)
- for (n -= u; n--; )
- l2 += "0";
- else
- n < u && (l2 = l2.slice(0, n) + "." + l2.slice(n));
- }
- l2 = (a2 == 16 ? "0x" : a2 == 2 ? "0b" : a2 == 8 ? "0o" : "") + l2;
- }
- return i.s < 0 ? "-" + l2 : l2;
- }
- function hi(i, a2) {
- if (i.length > a2)
- return i.length = a2, true;
- }
- function yl(i) {
- return new this(i).abs();
- }
- function Rl(i) {
- return new this(i).acos();
- }
- function pl(i) {
- return new this(i).acosh();
- }
- function Vl(i, a2) {
- return new this(i).plus(a2);
- }
- function Nl(i) {
- return new this(i).asin();
- }
- function Ol(i) {
- return new this(i).asinh();
- }
- function Ml(i) {
- return new this(i).atan();
- }
- function wl(i) {
- return new this(i).atanh();
- }
- function Dl(i, a2) {
- i = new this(i), a2 = new this(a2);
- var e, t = this.precision, r = this.rounding, n = t + 4;
- return !i.s || !a2.s ? e = new this(NaN) : !i.d && !a2.d ? (e = ot2(this, n, 1).times(a2.s > 0 ? 0.25 : 0.75), e.s = i.s) : !a2.d || i.isZero() ? (e = a2.s < 0 ? ot2(this, t, r) : new this(0), e.s = i.s) : !i.d || a2.isZero() ? (e = ot2(this, n, 1).times(0.5), e.s = i.s) : a2.s < 0 ? (this.precision = n, this.rounding = 1, e = this.atan(pe2(i, a2, n, 1)), a2 = ot2(this, n, 1), this.precision = t, this.rounding = r, e = i.s < 0 ? e.minus(a2) : e.plus(a2)) : e = this.atan(pe2(i, a2, n, 1)), e;
- }
- function Sl(i) {
- return new this(i).cbrt();
- }
- function Pl(i) {
- return J2(i = new this(i), i.e + 1, 2);
- }
- function Ll(i, a2, e) {
- return new this(i).clamp(a2, e);
- }
- function xl(i) {
- if (!i || typeof i != "object")
- throw Error(Un + "Object expected");
- var a2, e, t, r = i.defaults === true, n = [
- "precision",
- 1,
- $t,
- "rounding",
- 0,
- 8,
- "toExpNeg",
- -9e15,
- 0,
- "toExpPos",
- 0,
- Ls,
- "maxE",
- 0,
- Ls,
- "minE",
- -9e15,
- 0,
- "modulo",
- 0,
- 9
- ];
- for (a2 = 0; a2 < n.length; a2 += 3)
- if (e = n[a2], r && (this[e] = js[e]), (t = i[e]) !== void 0)
- if (Be(t) === t && t >= n[a2 + 1] && t <= n[a2 + 2])
- this[e] = t;
- else
- throw Error(Bt + e + ": " + t);
- if (e = "crypto", r && (this[e] = js[e]), (t = i[e]) !== void 0)
- if (t === true || t === false || t === 0 || t === 1)
- if (t)
- if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
- this[e] = true;
- else
- throw Error(uo);
- else
- this[e] = false;
- else
- throw Error(Bt + e + ": " + t);
- return this;
- }
- function jl(i) {
- return new this(i).cos();
- }
- function Ul(i) {
- return new this(i).cosh();
- }
- function _o(i) {
- var a2, e, t;
- function r(n) {
- var s, o, u, c = this;
- if (!(c instanceof r))
- return new r(n);
- if (c.constructor = r, mi(n)) {
- c.s = n.s, ue2 ? !n.d || n.e > r.maxE ? (c.e = NaN, c.d = null) : n.e < r.minE ? (c.e = 0, c.d = [0]) : (c.e = n.e, c.d = n.d.slice()) : (c.e = n.e, c.d = n.d ? n.d.slice() : n.d);
- return;
- }
- if (u = typeof n, u === "number") {
- if (n === 0) {
- c.s = 1 / n < 0 ? -1 : 1, c.e = 0, c.d = [0];
- return;
- }
- if (n < 0 ? (n = -n, c.s = -1) : c.s = 1, n === ~~n && n < 1e7) {
- for (s = 0, o = n; o >= 10; o /= 10)
- s++;
- ue2 ? s > r.maxE ? (c.e = NaN, c.d = null) : s < r.minE ? (c.e = 0, c.d = [0]) : (c.e = s, c.d = [n]) : (c.e = s, c.d = [n]);
- return;
- } else if (n * 0 !== 0) {
- n || (c.s = NaN), c.e = NaN, c.d = null;
- return;
- }
- return Ts(c, n.toString());
- } else if (u !== "string")
- throw Error(Bt + n);
- return (o = n.charCodeAt(0)) === 45 ? (n = n.slice(1), c.s = -1) : (o === 43 && (n = n.slice(1)), c.s = 1), lo.test(n) ? Ts(c, n) : El(c, n);
- }
- if (r.prototype = B2, r.ROUND_UP = 0, r.ROUND_DOWN = 1, r.ROUND_CEIL = 2, r.ROUND_FLOOR = 3, r.ROUND_HALF_UP = 4, r.ROUND_HALF_DOWN = 5, r.ROUND_HALF_EVEN = 6, r.ROUND_HALF_CEIL = 7, r.ROUND_HALF_FLOOR = 8, r.EUCLID = 9, r.config = r.set = xl, r.clone = _o, r.isDecimal = mi, r.abs = yl, r.acos = Rl, r.acosh = pl, r.add = Vl, r.asin = Nl, r.asinh = Ol, r.atan = Ml, r.atanh = wl, r.atan2 = Dl, r.cbrt = Sl, r.ceil = Pl, r.clamp = Ll, r.cos = jl, r.cosh = Ul, r.div = vl, r.exp = Tl, r.floor = Bl, r.hypot = Il, r.ln = Fl, r.log = kl, r.log10 = Yl, r.log2 = $l, r.max = Hl, r.min = Gl, r.mod = Ql, r.mul = Wl, r.pow = ql, r.random = Kl, r.round = Xl, r.sign = Zl, r.sin = zl, r.sinh = Jl, r.sqrt = ef, r.sub = tf, r.sum = rf, r.tan = nf2, r.tanh = sf, r.trunc = af, i === void 0 && (i = {}), i && i.defaults !== true)
- for (t = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], a2 = 0; a2 < t.length; )
- i.hasOwnProperty(e = t[a2++]) || (i[e] = this[e]);
- return r.config(i), r;
- }
- function vl(i, a2) {
- return new this(i).div(a2);
- }
- function Tl(i) {
- return new this(i).exp();
- }
- function Bl(i) {
- return J2(i = new this(i), i.e + 1, 3);
- }
- function Il() {
- var i, a2, e = new this(0);
- for (ue2 = false, i = 0; i < arguments.length; )
- if (a2 = new this(arguments[i++]), a2.d)
- e.d && (e = e.plus(a2.times(a2)));
- else {
- if (a2.s)
- return ue2 = true, new this(1 / 0);
- e = a2;
- }
- return ue2 = true, e.sqrt();
- }
- function mi(i) {
- return i instanceof L2 || i && i.toStringTag === co || false;
- }
- function Fl(i) {
- return new this(i).ln();
- }
- function kl(i, a2) {
- return new this(i).log(a2);
- }
- function $l(i) {
- return new this(i).log(2);
- }
- function Yl(i) {
- return new this(i).log(10);
- }
- function Hl() {
- return mo(this, arguments, "lt");
- }
- function Gl() {
- return mo(this, arguments, "gt");
- }
- function Ql(i, a2) {
- return new this(i).mod(a2);
- }
- function Wl(i, a2) {
- return new this(i).mul(a2);
- }
- function ql(i, a2) {
- return new this(i).pow(a2);
- }
- function Kl(i) {
- var a2, e, t, r, n = 0, s = new this(1), o = [];
- if (i === void 0 ? i = this.precision : He(i, 1, $t), t = Math.ceil(i / te), this.crypto)
- if (crypto.getRandomValues)
- for (a2 = crypto.getRandomValues(new Uint32Array(t)); n < t; )
- r = a2[n], r >= 429e7 ? a2[n] = crypto.getRandomValues(new Uint32Array(1))[0] : o[n++] = r % 1e7;
- else if (crypto.randomBytes) {
- for (a2 = crypto.randomBytes(t *= 4); n < t; )
- r = a2[n] + (a2[n + 1] << 8) + (a2[n + 2] << 16) + ((a2[n + 3] & 127) << 24), r >= 214e7 ? crypto.randomBytes(4).copy(a2, n) : (o.push(r % 1e7), n += 4);
- n = t / 4;
- } else
- throw Error(uo);
- else
- for (; n < t; )
- o[n++] = Math.random() * 1e7 | 0;
- for (t = o[--n], i %= te, t && i && (r = Le(10, te - i), o[n] = (t / r | 0) * r); o[n] === 0; n--)
- o.pop();
- if (n < 0)
- e = 0, o = [0];
- else {
- for (e = -1; o[0] === 0; e -= te)
- o.shift();
- for (t = 1, r = o[0]; r >= 10; r /= 10)
- t++;
- t < te && (e -= te - t);
- }
- return s.e = e, s.d = o, s;
- }
- function Xl(i) {
- return J2(i = new this(i), i.e + 1, this.rounding);
- }
- function Zl(i) {
- return i = new this(i), i.d ? i.d[0] ? i.s : 0 * i.s : i.s || NaN;
- }
- function zl(i) {
- return new this(i).sin();
- }
- function Jl(i) {
- return new this(i).sinh();
- }
- function ef(i) {
- return new this(i).sqrt();
- }
- function tf(i, a2) {
- return new this(i).sub(a2);
- }
- function rf() {
- var i = 0, a2 = arguments, e = new this(a2[i]);
- for (ue2 = false; e.s && ++i < a2.length; )
- e = e.plus(a2[i]);
- return ue2 = true, J2(e, this.precision, this.rounding);
- }
- function nf2(i) {
- return new this(i).tan();
- }
- function sf(i) {
- return new this(i).tanh();
- }
- function af(i) {
- return J2(i = new this(i), i.e + 1, 1);
- }
- B2[Symbol.for("nodejs.util.inspect.custom")] = B2.toString;
- B2[Symbol.toStringTag] = "Decimal";
- var L2 = B2.constructor = _o(js);
- mn = new L2(mn);
- gn = new L2(gn);
- function of2(i, a2) {
- const e = i + a2;
- return Number.isSafeInteger(e) ? e : new L2(i).add(a2).toNumber();
- }
- function uf(i, a2) {
- const e = i - a2;
- return Number.isSafeInteger(e) ? e : new L2(i).sub(a2).toNumber();
- }
- function Vr2(i, a2) {
- const e = i * a2;
- return Number.isSafeInteger(e) ? e : new L2(i).mul(a2).toNumber();
- }
- function cf(i, a2) {
- const e = i / a2;
- return Number.isSafeInteger(e) ? e : new L2(i).div(a2).toNumber();
- }
- function vt(i, a2) {
- const e = 10 ** Math.trunc(a2), t = Bn(i, e);
- return Math.round(Vr2(i, e) + t) / e;
- }
- function We(i, a2) {
- const e = 10 ** Math.trunc(a2), t = Bn(i, e);
- return Math.floor(Vr2(i, e) + t) / e;
- }
- function Ye(i, a2) {
- const e = 10 ** Math.trunc(a2), t = Bn(i, e);
- return Math.ceil(Vr2(i, e) - t) / e;
- }
- function Bn(i, a2) {
- return Number.EPSILON * Math.max(1, Math.abs(Vr2(i, a2)));
- }
- function gi(i, a2) {
- return i - a2 * Math.floor(i / a2);
- }
- function lf(i, a2) {
- return i ** a2;
- }
- function ff(i) {
- return Math.sqrt(i);
- }
- function di(i, a2) {
- return i === a2;
- }
- function hf(i, a2) {
- return i > a2;
- }
- function mf(i, a2) {
- return i >= a2;
- }
- function gf(i, a2) {
- return i < a2;
- }
- function df(i, a2) {
- return i <= a2;
- }
- function Ci(i, a2 = 15) {
- return Number.parseFloat(i.toPrecision(a2));
- }
- function Cf(i, a2, e = Number.EPSILON) {
- return Math.abs(i - a2) < e;
- }
- function _f(i, a2 = 12, e = 1e-10) {
- const t = Ci(i, a2);
- return Cf(i, t, e) ? t : Ci(i);
- }
- function Af(i) {
- return i - Math.trunc(i);
- }
- var xn = class xn2 extends kt2 {
- static create() {
- return this._instance = this._instance || new xn2(0), this._instance;
- }
- isNull() {
- return true;
- }
- plus(a2) {
- return y2.create(0).plus(a2);
- }
- minus(a2) {
- return y2.create(0).minus(a2);
- }
- multiply(a2) {
- return y2.create(0).multiply(a2);
- }
- divided(a2) {
- return y2.create(0).divided(a2);
- }
- mod(a2) {
- return y2.create(0).mod(a2);
- }
- compare(a2, e) {
- return a2.isString() ? j.create("").compare(a2, e) : a2.isBoolean() ? T2.create(false).compare(a2, e) : y2.create(0).compare(a2, e);
- }
- concatenateFront(a2) {
- return a2.isArray() ? a2.concatenateBack(j.create("")) : j.create(this.concatenate(a2.getValue(), it.FRONT));
- }
- concatenateBack(a2) {
- return a2.isArray() ? a2.concatenateFront(j.create("")) : j.create(this.concatenate(a2.getValue(), it.BACK));
- }
- plusBy(a2) {
- return y2.create(0).plusBy(a2);
- }
- minusBy(a2) {
- return y2.create(0).minusBy(a2);
- }
- multiplyBy(a2) {
- return y2.create(0).multiplyBy(a2);
- }
- dividedBy(a2) {
- return y2.create(0).dividedBy(a2);
- }
- compareBy(a2, e) {
- return typeof a2 == "string" ? j.create("").compareBy(a2, e) : typeof a2 == "boolean" ? T2.create(false).compareBy(a2, e) : y2.create(0).compareBy(a2, e);
- }
- pow(a2) {
- return y2.create(0).pow(a2);
- }
- sqrt() {
- return y2.create(0).sqrt();
- }
- cbrt() {
- return y2.create(0).cbrt();
- }
- cos() {
- return y2.create(0).cos();
- }
- cosh() {
- return y2.create(0).cosh();
- }
- acos() {
- return y2.create(0).acos();
- }
- acosh() {
- return y2.create(0).acosh();
- }
- sin() {
- return y2.create(0).sin();
- }
- sinh() {
- return y2.create(0).sinh();
- }
- asin() {
- return y2.create(0).asin();
- }
- asinh() {
- return y2.create(0).asinh();
- }
- tan() {
- return y2.create(0).tan();
- }
- tanh() {
- return y2.create(0).tanh();
- }
- atan() {
- return y2.create(0).atan();
- }
- atan2(a2) {
- return y2.create(0).atan2(a2);
- }
- atanh() {
- return y2.create(0).atanh();
- }
- log() {
- return g2.create(m2.NUM);
- }
- log10() {
- return g2.create(m2.NUM);
- }
- exp() {
- return y2.create(0).exp();
- }
- abs() {
- return y2.create(0).abs();
- }
- round(a2) {
- return y2.create(0).round(a2);
- }
- floor(a2) {
- return y2.create(0).floor(a2);
- }
- ceil(a2) {
- return y2.create(0).ceil(a2);
- }
- convertToNumberObjectValue() {
- return y2.create(0);
- }
- convertToBooleanObjectValue() {
- return T2.create(false);
- }
- };
- A(xn, "_instance");
- var ie = xn;
- var qt = class qt2 extends kt2 {
- constructor(e) {
- super(e);
- A(this, "_value", false);
- this._value = e;
- }
- static create(e) {
- return e ? (this._instanceTrue = this._instanceTrue || new qt2(true), this._instanceTrue) : (this._instanceFalse = this._instanceFalse || new qt2(false), this._instanceFalse);
- }
- getValue() {
- return this._value;
- }
- isBoolean() {
- return true;
- }
- getNegative() {
- const e = this.getValue();
- let t = 0;
- return e && (t = 1), y2.create(-t);
- }
- getReciprocal() {
- return this.getValue() ? y2.create(1) : g2.create(m2.DIV_BY_ZERO);
- }
- plus(e) {
- return this._convertToNumber().plus(e);
- }
- minus(e) {
- return this._convertToNumber().minus(e);
- }
- multiply(e) {
- return this._convertToNumber().multiply(e);
- }
- divided(e) {
- return this._convertToNumber().divided(e);
- }
- mod(e) {
- return this._convertToNumber().mod(e);
- }
- compare(e, t) {
- return e.isArray() ? e.compare(this, ma(t)) : e.isNull() ? this._convertToNumber().compare(e, t) : this.compareBy(e.getValue(), t);
- }
- compareBy(e, t) {
- let r = false;
- if (typeof e == "string" || typeof e == "number")
- r = this._compareString(t);
- else if (typeof e == "boolean") {
- const n = y2.create(e ? 1 : 0);
- return this._convertToNumber().compare(n, t);
- }
- return qt2.create(r);
- }
- _compareString(e) {
- switch (e) {
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- return true;
- case $.EQUALS:
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- case $.NOT_EQUAL:
- return false;
- }
- }
- concatenateFront(e) {
- return this._convertToNumber().concatenateFront(e);
- }
- concatenateBack(e) {
- return this._convertToNumber().concatenateBack(e);
- }
- _convertToNumber() {
- const e = this.getValue();
- let t = 0;
- return e && (t = 1), y2.create(t);
- }
- pow(e) {
- return this._convertToNumber().pow(e);
- }
- sqrt() {
- return this._convertToNumber().sqrt();
- }
- cbrt() {
- return this._convertToNumber().cbrt();
- }
- cos() {
- return this._convertToNumber().cos();
- }
- cosh() {
- return this._convertToNumber().cosh();
- }
- acos() {
- return this._convertToNumber().acos();
- }
- acosh() {
- return this._convertToNumber().acosh();
- }
- sin() {
- return this._convertToNumber().sin();
- }
- sinh() {
- return this._convertToNumber().sinh();
- }
- asin() {
- return this._convertToNumber().asin();
- }
- asinh() {
- return this._convertToNumber().asinh();
- }
- tan() {
- return this._convertToNumber().tan();
- }
- tanh() {
- return this._convertToNumber().tanh();
- }
- atan() {
- return this._convertToNumber().atan();
- }
- atan2(e) {
- return this._convertToNumber().atan2(e);
- }
- atanh() {
- return this._convertToNumber().atanh();
- }
- log() {
- return this._convertToNumber().log();
- }
- log10() {
- return this._convertToNumber().log10();
- }
- exp() {
- return this._convertToNumber().exp();
- }
- abs() {
- return this._convertToNumber().abs();
- }
- round(e) {
- return this._convertToNumber().round(e);
- }
- floor(e) {
- return this._convertToNumber().floor(e);
- }
- ceil(e) {
- return this._convertToNumber().ceil(e);
- }
- convertToNumberObjectValue() {
- return Fn(this.getValue());
- }
- convertToBooleanObjectValue() {
- return this;
- }
- };
- A(qt, "_instanceTrue"), A(qt, "_instanceFalse");
- var T2 = qt;
- var y2 = class _y extends kt2 {
- constructor(e) {
- super(e);
- A(this, "_value", 0);
- this._value = Number(e);
- }
- static create(e, t = "") {
- const r = new _y(e);
- return t && r.setPattern(t), r;
- }
- getValue() {
- return this._value;
- }
- setValue(e) {
- this._value = e;
- }
- isNumber() {
- return true;
- }
- getNegative() {
- return _y.create(0).minus(this);
- }
- getReciprocal() {
- return _y.create(1).divided(this);
- }
- plus(e) {
- if (e.isArray())
- return e.plus(this);
- let t = this.plusBy(e.getValue());
- if (t.isError())
- return t;
- const r = Wr(this.getPattern(), e.getPattern(), X2.PLUS);
- return t = _y.create(Number(t.getValue()), r), t;
- }
- equalZero() {
- return this._value === 0;
- }
- minus(e) {
- if (e.isArray()) {
- const n = e.getNegative();
- return n.isError() ? n : n.plus(this);
- }
- let t = this.minusBy(e.getValue());
- if (t.isError())
- return t;
- const r = Wr(this.getPattern(), e.getPattern(), X2.MINUS);
- return t = _y.create(Number(t.getValue()), r), t;
- }
- multiply(e) {
- if (e.isArray())
- return e.multiply(this);
- let t = this.multiplyBy(e.getValue());
- if (t.isError())
- return t;
- const r = Wr(this.getPattern(), e.getPattern(), X2.MULTIPLY);
- return t = _y.create(Number(t.getValue()), r), t;
- }
- divided(e) {
- if (e.isArray()) {
- const n = e.getReciprocal();
- return n.isError() ? n : n.multiply(this);
- }
- let t = this.dividedBy(e.getValue());
- if (t.isError())
- return t;
- const r = Wr(this.getPattern(), e.getPattern(), X2.DIVIDED);
- return t = _y.create(Number(t.getValue()), r), t;
- }
- mod(e) {
- if (e.isArray())
- return e.modInverse(this);
- const t = this.getValue(), r = e.getValue();
- if (e.isNull())
- return g2.create(m2.DIV_BY_ZERO);
- if (typeof r == "string")
- return g2.create(m2.VALUE);
- if (typeof r == "number") {
- if (r === 0)
- return g2.create(m2.DIV_BY_ZERO);
- if (!Number.isFinite(t) || !Number.isFinite(r) || Math.abs(r) * 11259e8 <= Math.abs(t))
- return g2.create(m2.NUM);
- const n = gi(t, r);
- return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
- }
- if (typeof r == "boolean") {
- const n = r ? 1 : 0;
- return n === 0 ? g2.create(m2.DIV_BY_ZERO) : _y.create(gi(t, n));
- }
- return this;
- }
- concatenateFront(e) {
- return e.isArray() ? e.concatenateBack(this) : j.create(this.concatenate(e.getValue(), it.FRONT));
- }
- concatenateBack(e) {
- return e.isArray() ? e.concatenateFront(this) : j.create(this.concatenate(e.getValue(), it.BACK));
- }
- compare(e, t) {
- return e.isArray() ? e.compare(this, ma(t)) : this.compareBy(e.getValue(), t);
- }
- plusBy(e) {
- const t = +this.getValue(), r = +e;
- if (Number.isNaN(t) || Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g2.create(m2.NUM);
- const n = of2(t, r);
- return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
- }
- minusBy(e) {
- const t = +this.getValue(), r = +e;
- if (Number.isNaN(t) || Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g2.create(m2.NUM);
- const n = uf(t, r);
- return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
- }
- multiplyBy(e) {
- const t = +this.getValue(), r = +e;
- if (Number.isNaN(t) || Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g2.create(m2.NUM);
- const n = Vr2(t, r);
- return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
- }
- dividedBy(e) {
- const t = +this.getValue(), r = +e;
- if (Number.isNaN(t) || Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g2.create(m2.NUM);
- if (r === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const n = cf(t, r);
- return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
- }
- compareBy(e, t) {
- const r = this.getValue();
- let n = false;
- return typeof e == "string" ? n = this._compareString(t) : typeof e == "number" ? n = this._compareNumber(r, e, t) : typeof e == "boolean" && (n = this._compareBoolean(t)), T2.create(n);
- }
- _compareString(e) {
- switch (e) {
- case $.EQUALS:
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- return false;
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- case $.NOT_EQUAL:
- return true;
- }
- }
- _compareNumber(e, t, r) {
- return !Number.isFinite(e) || !Number.isFinite(t) ? this._compareInfinity(e, t, r) : this._compareFiniteNumber(e, t, r);
- }
- _compareFiniteNumber(e, t, r) {
- switch (r) {
- case $.EQUALS:
- return di(e, t);
- case $.GREATER_THAN:
- return hf(e, t);
- case $.GREATER_THAN_OR_EQUAL:
- return mf(e, t);
- case $.LESS_THAN:
- return gf(e, t);
- case $.LESS_THAN_OR_EQUAL:
- return df(e, t);
- case $.NOT_EQUAL:
- return !di(e, t);
- }
- }
- _compareBoolean(e) {
- switch (e) {
- case $.EQUALS:
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- return false;
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- case $.NOT_EQUAL:
- return true;
- }
- }
- pow(e) {
- if (e.isArray())
- return e.powInverse(this);
- if (this.isError())
- return this;
- const t = this.getValue();
- let r = e;
- if (e.isString() && (r = e.convertToNumberObjectValue()), r.isError())
- return r;
- const n = +r.getValue();
- if (Number.isNaN(n))
- return g2.create(m2.VALUE);
- if (!Number.isFinite(t) || !Number.isFinite(n))
- return g2.create(m2.NUM);
- if (t === 0)
- return n < 0 ? g2.create(m2.DIV_BY_ZERO) : n === 0 ? g2.create(m2.NUM) : _y.create(0);
- const s = lf(t, n);
- return Number.isFinite(s) ? _y.create(s) : g2.create(m2.NUM);
- }
- sqrt() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = ff(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- cbrt() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.cbrt(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- cos() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.cos(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- cosh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.cosh(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- acos() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.acos(e);
- return Number.isNaN(t) ? g2.create(m2.NUM) : _y.create(t);
- }
- acosh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.acosh(e);
- return Number.isNaN(t) ? g2.create(m2.NUM) : _y.create(t);
- }
- sin() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.sin(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- sinh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.sinh(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- asin() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.asin(e);
- return Number.isNaN(t) ? g2.create(m2.NUM) : _y.create(t);
- }
- asinh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.asinh(e);
- return Number.isNaN(t) ? g2.create(m2.NUM) : _y.create(t);
- }
- tan() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.tan(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- tanh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.tanh(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- atan() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.atan(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- atan2(e) {
- if (e.isArray())
- return e.atan2Inverse(this);
- const t = this.getValue(), r = e.getValue();
- if (typeof r == "string")
- return g2.create(m2.VALUE);
- if (typeof r == "number") {
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g2.create(m2.NUM);
- if (t === 0 && r === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const n = Math.atan2(t, r);
- return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
- }
- return typeof r == "boolean" ? _y.create(Math.atan2(t, r ? 1 : 0)) : this;
- }
- atanh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.atanh(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- log() {
- const e = this.getValue();
- if (typeof e == "number" && e <= 0 || !Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.log(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- log10() {
- const e = this.getValue();
- if (typeof e == "number" && e <= 0 || !Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.log10(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- exp() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.exp(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- abs() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g2.create(m2.NUM);
- const t = Math.abs(e);
- return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
- }
- round(e) {
- if (e.isArray())
- return e.roundInverse(this);
- const t = this.getValue(), r = e.getValue();
- if (typeof r == "string")
- return g2.create(m2.VALUE);
- if (typeof r == "number") {
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g2.create(m2.NUM);
- const n = t < 0 ? -vt(Math.abs(t), r) : vt(t, r);
- return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
- }
- return typeof r == "boolean" ? _y.create(vt(t, r ? 1 : 0)) : this;
- }
- floor(e) {
- if (e.isArray())
- return e.floorInverse(this);
- const t = this.getValue(), r = e.getValue();
- if (typeof r == "string")
- return g2.create(m2.VALUE);
- if (typeof r == "number") {
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g2.create(m2.NUM);
- const n = t < 0 ? -We(Math.abs(t), r) : We(t, r);
- return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
- }
- return typeof r == "boolean" ? _y.create(We(t, r ? 1 : 0)) : this;
- }
- ceil(e) {
- if (e.isArray())
- return e.ceilInverse(this);
- const t = this.getValue(), r = e.getValue();
- if (typeof r == "string")
- return g2.create(m2.VALUE);
- if (typeof r == "number") {
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g2.create(m2.NUM);
- const n = t < 0 ? -Ye(Math.abs(t), r) : Ye(t, r);
- return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
- }
- return typeof r == "boolean" ? _y.create(Ye(t, r ? 1 : 0)) : this;
- }
- convertToNumberObjectValue() {
- return this;
- }
- convertToBooleanObjectValue() {
- return In(true);
- }
- _compareInfinity(e, t, r) {
- let n = false;
- switch (r) {
- case $.EQUALS:
- n = e === t;
- break;
- case $.GREATER_THAN:
- n = e > t;
- break;
- case $.GREATER_THAN_OR_EQUAL:
- n = e >= t;
- break;
- case $.LESS_THAN:
- n = e < t;
- break;
- case $.LESS_THAN_OR_EQUAL:
- n = e <= t;
- break;
- case $.NOT_EQUAL:
- n = e !== t;
- break;
- }
- return n;
- }
- };
- var Ef = 1e5;
- var _i = new Vt(Ef);
- var j = class _j extends kt2 {
- constructor(e) {
- super(e);
- A(this, "_value");
- this._value = e;
- }
- static create(e) {
- const t = _i.get(e);
- if (t)
- return t;
- const r = new _j(e);
- return _i.set(e, r), r;
- }
- getValue() {
- return this._value;
- }
- isString() {
- return true;
- }
- concatenateFront(e) {
- return e.isArray() ? e.concatenateBack(this) : _j.create(this.concatenate(e.getValue(), it.FRONT));
- }
- concatenateBack(e) {
- return e.isArray() ? e.concatenateFront(this) : _j.create(this.concatenate(e.getValue(), it.BACK));
- }
- plus(e) {
- return this.convertToNumberObjectValue().plus(e);
- }
- minus(e) {
- return this.convertToNumberObjectValue().minus(e);
- }
- multiply(e) {
- return this.convertToNumberObjectValue().multiply(e);
- }
- divided(e) {
- return this.convertToNumberObjectValue().divided(e);
- }
- compare(e, t, r) {
- return e.isArray() ? e.compare(this, ma(t), r) : this.compareBy(e.getValue(), t, r);
- }
- compareBy(e, t, r = false) {
- let n = this.getValue(), s = false;
- if (typeof e == "string") {
- let o = e;
- if (r || (n = n.toLocaleLowerCase(), o = o.toLocaleLowerCase()), ll(o))
- return this._checkWildcard(o, t);
- s = this._compareString(n, o, t);
- } else
- typeof e == "number" ? s = this._compareNumber(t) : typeof e == "boolean" && (s = this._compareBoolean(t));
- return T2.create(s);
- }
- _compareString(e, t, r) {
- switch (r) {
- case $.EQUALS:
- return e === t;
- case $.GREATER_THAN:
- return e > t;
- case $.GREATER_THAN_OR_EQUAL:
- return e >= t;
- case $.LESS_THAN:
- return e < t;
- case $.LESS_THAN_OR_EQUAL:
- return e <= t;
- case $.NOT_EQUAL:
- return e !== t;
- }
- }
- _compareNumber(e) {
- switch (e) {
- case $.NOT_EQUAL:
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- return true;
- case $.EQUALS:
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- return false;
- }
- }
- _compareBoolean(e) {
- switch (e) {
- case $.EQUALS:
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- return false;
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- case $.NOT_EQUAL:
- return true;
- }
- }
- convertToNumberObjectValue() {
- return Fn(this.getValue());
- }
- convertToBooleanObjectValue() {
- return T2.create(true);
- }
- _checkWildcard(e, t) {
- const r = this.getValue().toLocaleLowerCase(), n = fl(r, e, t);
- return T2.create(n);
- }
- };
- function In(i) {
- if (typeof i == "boolean")
- return T2.create(i);
- let a2 = false;
- if (typeof i == "string") {
- const e = i.toLocaleUpperCase();
- e === er.TRUE ? a2 = true : e === er.FALSE && (a2 = false);
- } else
- i === 1 ? a2 = true : a2 = false;
- return T2.create(a2);
- }
- function bf(i) {
- let a2 = i.toString();
- return a2.charAt(0) === '"' && a2.charAt(a2.length - 1) === '"' && (a2 = a2.slice(1, -1), a2 = a2.replace(/""/g, '"')), j.create(a2);
- }
- function Fn(i, a2 = "") {
- if (typeof i == "boolean") {
- let e = 0;
- return i && (e = 1), y2.create(e, a2);
- } else {
- if (typeof i == "number")
- return Number.isFinite(i) ? y2.create(i, a2) : g2.create(m2.NUM);
- if (DC(i))
- return y2.create(Number(i), a2);
- }
- return g2.create(m2.VALUE);
- }
- function yf(i) {
- return "";
- }
- function Ao(i = []) {
- const a2 = [];
- for (let e = 0; e < i.length; e++) {
- const t = i[e];
- a2[e] == null && (a2[e] = []);
- for (let r = 0; r < t.length; r++) {
- const n = t[r];
- a2[e][r] = pt.create(n);
- }
- }
- return a2;
- }
- function Rf(i = []) {
- const a2 = [];
- for (let e = 0; e < i.length; e++) {
- const t = i[e];
- a2[e] == null && (a2[e] = []);
- for (let r = 0; r < t.length; r++) {
- const n = t[r];
- n == null ? a2[e][r] = null : n.isError() ? a2[e][r] = n.getErrorType() : a2[e][r] = n.getValue();
- }
- }
- return a2;
- }
- var q2 = class _q extends kt2 {
- constructor(e) {
- super(typeof e == "string" ? e : yf());
- A(this, "_values", []);
- A(this, "_rowCount", -1);
- A(this, "_columnCount", -1);
- A(this, "_unitId", "");
- A(this, "_sheetId", "");
- A(this, "_currentRow", -1);
- A(this, "_currentColumn", -1);
- A(this, "_sliceCache", /* @__PURE__ */ new Map());
- A(this, "_flattenCache");
- A(this, "_defaultValue", null);
- A(this, "_flattenPosition");
- this._values = this._formatValue(e);
- }
- /**
- * Create an array value object based on the string or IArrayValueObject data.
- * @param rawValue
- * @returns
- */
- static create(e) {
- return new _q(e);
- }
- /**
- * Create an array value object based on the array data.
- * @param array
- * @returns
- */
- static createByArray(e) {
- const r = {
- calculateValueList: Ao(e),
- rowCount: e.length,
- columnCount: e[0].length || 0,
- unitId: "",
- sheetId: "",
- row: -1,
- column: -1
- };
- return new _q(r);
- }
- dispose() {
- this._values = [], this._defaultValue = null, this._flattenPosition = null, this._clearCache();
- }
- clone() {
- return this.map((e) => e);
- }
- getRowCount() {
- return this._rowCount;
- }
- setRowCount(e) {
- this._rowCount = e;
- }
- getColumnCount() {
- return this._columnCount;
- }
- setColumnCount(e) {
- this._columnCount = e;
- }
- setCurrent(e, t) {
- this._currentRow = e, this._currentColumn = t;
- }
- setUnitId(e) {
- this._unitId = e;
- }
- getUnitId() {
- return this._unitId;
- }
- setSheetId(e) {
- this._sheetId = e;
- }
- getSheetId() {
- return this._sheetId;
- }
- getCurrentRow() {
- return this._currentRow;
- }
- getCurrentColumn() {
- return this._currentColumn;
- }
- getArrayValue() {
- return this._values;
- }
- setArrayValue(e) {
- this._clearCache(), this._values = e;
- }
- isArray() {
- return true;
- }
- setDefaultValue(e) {
- this._defaultValue = e;
- }
- get(e, t) {
- var r;
- return ((r = this._values[e]) == null ? void 0 : r[t]) || this._defaultValue;
- }
- getRealValue(e, t) {
- const r = this._values[e];
- if (r == null)
- return null;
- const n = r[t];
- return n == null ? null : n;
- }
- getValueOrDefault(e, t) {
- return this.get(e, t) || this._defaultValue;
- }
- set(e, t, r) {
- if (e >= this._rowCount || t >= this._columnCount)
- throw new Error("Exceeding array bounds.");
- this._clearCache(), this._values[e][t] = r;
- }
- getRangePosition() {
- const t = this.getRowCount(), r = 0, n = this.getColumnCount();
- return {
- startRow: 0,
- endRow: t - 1,
- startColumn: r,
- endColumn: n - 1
- };
- }
- iterator(e) {
- var u;
- const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition(), o = this.getArrayValue();
- for (let c = t; c <= r; c++)
- for (let l2 = n; l2 <= s; l2++)
- if (e(((u = o[c]) == null ? void 0 : u[l2]) || this._defaultValue, c, l2) === false)
- return;
- }
- iteratorReverse(e) {
- var u;
- const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition(), o = this.getArrayValue();
- for (let c = r; c >= t; c--)
- for (let l2 = s; l2 >= n; l2--)
- if (e(((u = o[c]) == null ? void 0 : u[l2]) || this._defaultValue, c, l2) === false)
- return;
- }
- getLastTruePosition() {
- let e;
- return this.iteratorReverse((t, r, n) => {
- if (t != null && t.isBoolean() && t.getValue() === true)
- return e = {
- row: r,
- column: n
- }, false;
- }), e;
- }
- getFirstTruePosition() {
- let e;
- return this.iterator((t, r, n) => {
- if (t != null && t.isBoolean() && t.getValue() === true)
- return e = {
- row: r,
- column: n
- }, false;
- }), e;
- }
- getFirstCell() {
- const { startRow: e, startColumn: t } = this.getRangePosition();
- return this.get(e, t) || this._defaultValue || ie.create();
- }
- getLastCell() {
- const { endRow: e, endColumn: t } = this.getRangePosition();
- return this.get(e, t) || this._defaultValue || ie.create();
- }
- /**
- * Referring to matrix calculations,
- * extract the matching values from a true/false matrix based on parameters and store them in a two-dimensional array.
- * implement x[x<10]
- * https://numpy.org/doc/stable/user/basics.indexing.html
- * @param takeArray
- */
- pick(e) {
- const t = this.pickRaw(e);
- return this._createNewArray(t, 1, t[0].length);
- }
- pickRaw(e) {
- const t = e.getRowCount(), r = e.getColumnCount();
- if (t !== this._rowCount || r !== this._columnCount)
- return [[ie.create()]];
- const n = [];
- n[0] = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.get(s, o);
- if (!(u == null || u.isError()) && u.getValue() === true) {
- const c = this.get(s, o);
- n[0].push(c);
- }
- }
- return n;
- }
- /**
- * Flatten a 2D array.
- * https://numpy.org/doc/stable/reference/generated/numpy.chararray.flatten.html#numpy.chararray.flatten
- */
- flatten() {
- if (this._flattenCache != null)
- return this._flattenCache;
- const e = [];
- e[0] = [];
- for (let r = 0; r < this._rowCount; r++)
- for (let n = 0; n < this._columnCount; n++) {
- const s = this.get(r, n);
- e[0].push(s);
- }
- const t = this._createNewArray(e, 1, e[0].length);
- return t.setDefaultValue(this._defaultValue), this._flattenCache = t, t;
- }
- /**
- * Flatten a 2D array.
- * In Excel, errors and blank cells are ignored, which results in a binary search that cannot strictly adhere to the number of cells.
- */
- flattenPosition() {
- if (this._flattenPosition != null)
- return this._flattenPosition;
- const e = [], t = [], r = [], n = [];
- let s = 0;
- for (let u = 0; u < this._rowCount; u++)
- for (let c = 0; c < this._columnCount; c++) {
- const l2 = this.get(u, c);
- if (l2 == null || l2.isError() || l2.isNull()) {
- s++;
- continue;
- }
- l2.isString() ? (e.push(l2), r.push(s++)) : (t.push(l2), n.push(s++));
- }
- const o = {
- stringArray: e,
- numberArray: t,
- stringPosition: r,
- numberPosition: n
- };
- return this._flattenPosition = o, o;
- }
- /**
- * I'm looking to perform slicing operations on 2D arrays, similar to the functionality provided by NumPy.
- * https://numpy.org/doc/stable/user/basics.indexing.html
- * @rowParam start:stop:step
- * @columnParam start:stop:step
- * @param takeArray
- */
- slice(e, t) {
- let r = 0, n = this._rowCount, s = 1, o = 0, u = this._columnCount, c = 1;
- if (e != null && (r = e[0] || 0, n = e[1] || this._rowCount, s = e[2] || 1), t != null && (o = t[0] || 0, u = t[1] || this._columnCount, c = t[2] || 1), r >= this._rowCount || o >= this._columnCount)
- return;
- const l2 = `${r}_${n}_${s}_${o}_${u}_${c}`, f2 = this._sliceCache.get(l2);
- if (f2 != null)
- return f2;
- const h = [], d2 = this._values;
- let _ = 0, C = 0;
- for (let p2 = r; p2 < n; p2 += s) {
- C = 0, h[_] == null && (h[_] = []);
- for (let N2 = o; N2 < u; N2 += c) {
- if (!d2[p2])
- return;
- let M2 = d2[p2][N2] || this._defaultValue;
- M2 == null && (M2 = ie.create()), h[_][C] = M2, C++;
- }
- _++;
- }
- if (h.length === 0 || h[0].length === 0)
- return;
- const E2 = s > 1 ? -1 : r + this._currentRow, b = c > 1 ? -1 : o + this._currentColumn, R = this._createNewArray(h, h.length, h[0].length, E2, b);
- return R.setDefaultValue(this._defaultValue), this._sliceCache.set(l2, R), R;
- }
- sortByRow(e) {
- const t = this._transposeArray(this._values);
- t.sort(this._sort(e)), this._clearCache(), this._values = this._transposeArray(t);
- }
- sortByColumn(e) {
- this._clearCache(), this._values.sort(this._sort(e));
- }
- transpose() {
- const e = this._transposeArray(this._values), t = this._rowCount, r = this._columnCount, n = this._createNewArray(e, r, t);
- return n.setDefaultValue(this._defaultValue), n;
- }
- /**
- * Due to the inability to effectively utilize the cache,
- * the sequential matching approach is only used for special matches in XLOOKUP and XMATCH.
- * For example, when match_mode is set to 1 and -1 for an exact match. If not found, it returns the next smaller item.
- */
- orderSearch(e, t = Pe.MIN, r = false, n = false) {
- let s, o, u, c;
- const l2 = (f2, h, d2) => {
- if (f2 == null)
- return true;
- let _;
- if (n === true ? _ = f2.compare(e, $.EQUALS) : _ = f2.isEqual(e), (_ == null ? void 0 : _.getValue()) === true)
- return s = f2, u = { row: h, column: d2 }, false;
- t === Pe.MAX ? f2.isGreaterThan(e).getValue() === true && (o == null || f2.minus(e).abs().isLessThanOrEqual(o.minus(e).abs()).getValue() === true) && (o = f2, c = { row: h, column: d2 }) : t === Pe.MIN && f2.isLessThan(e).getValue() === true && (o == null || f2.minus(e).abs().isLessThanOrEqual(o.minus(e).abs()).getValue() === true) && (o = f2, c = { row: h, column: d2 });
- };
- if (r ? this.iteratorReverse((f2, h, d2) => l2(f2, h, d2)) : this.iterator((f2, h, d2) => l2(f2, h, d2)), s != null)
- return u;
- if (o != null)
- return c;
- }
- binarySearch(e, t = Wt.MIN, r = Pe.MIN) {
- if (e.isError())
- return;
- const { stringArray: n, stringPosition: s, numberArray: o, numberPosition: u } = this.flattenPosition();
- return e.isString() ? this._binarySearch(e, n, s, t, r) : this._binarySearch(e, o, u, t, r);
- }
- /**
- * searchType defaults to ascending order
- *
- * matchType defaults to the maximum value less than the search value, which is used for the default matching mode of VLOOKUP/LOOKUP/HLOOKUP.
- * @param valueObject
- * @param searchArray
- * @param positionArray
- * @param searchType
- * @param matchType
- * @returns
- */
- _binarySearch(e, t, r, n = Wt.MIN, s = Pe.MIN) {
- const o = hn(), u = Number(e.getValue()), c = !Number.isNaN(u);
- let l2 = 0, f2 = t.length - 1, h = -1, d2 = -1, _ = -1;
- for (; l2 <= f2; ) {
- const C = Math.floor((l2 + f2) / 2), E2 = t[C];
- let b;
- if (E2.isNull())
- b = n === Wt.MIN ? 1 : -1;
- else {
- const R = E2.getValue();
- if (c) {
- const p2 = Number(R);
- b = Number.isNaN(p2) ? 1 : Math.sign(p2 - u);
- } else
- b = o(R.toString().toLocaleLowerCase(), e.getValue().toString().toLocaleLowerCase());
- }
- if (n === Wt.MAX && (b = -b), b === 0) {
- h = C;
- break;
- }
- b < 0 ? (d2 = C, l2 = C + 1) : (_ = C, f2 = C - 1);
- }
- if (s === Pe.NORMAL)
- return h !== -1 ? r[h] : void 0;
- if (s === Pe.MIN)
- return h !== -1 ? r[h] : n === Wt.MIN ? r[d2] : r[_];
- if (s === Pe.MAX)
- return h !== -1 ? r[h] : n === Wt.MIN ? r[_] : r[d2];
- }
- sum() {
- let e = y2.create(0);
- return this.iterator((t) => {
- if (t == null || t.isString() || t.isBoolean() || t.isNull())
- return true;
- if (t.isError())
- return e = t, false;
- e = e.plus(
- t
- );
- }), e;
- }
- max() {
- let e = y2.create(Number.NEGATIVE_INFINITY);
- return this.iterator((t) => {
- if (t == null)
- return true;
- if (t.isError())
- return e = t, false;
- if (t.isString() || t.isNull() || t.isBoolean())
- return true;
- e.isLessThan(t).getValue() && (e = t);
- }), e;
- }
- min() {
- let e = y2.create(Number.POSITIVE_INFINITY);
- return this.iterator((t) => {
- if (t == null)
- return true;
- if (t.isError())
- return e = t, false;
- if (t.isString() || t.isNull() || t.isBoolean())
- return true;
- e.isGreaterThan(t).getValue() && (e = t);
- }), e;
- }
- count() {
- let e = y2.create(0);
- return this.iterator((t) => {
- if (t == null || t.isError() || t.isString() || t.isNull() || t.isBoolean())
- return true;
- e = e.plusBy(1);
- }), e;
- }
- countA() {
- let e = y2.create(0);
- return this.iterator((t) => {
- if (t == null || t.isNull())
- return true;
- e = e.plusBy(1);
- }), e;
- }
- countBlank() {
- let e = y2.create(0);
- return this.iterator((t) => {
- (t == null || t.isNull() || t.getValue() === "") && (e = e.plusBy(1));
- }), e;
- }
- getNegative() {
- return _q.create("{0}").minus(this);
- }
- getReciprocal() {
- return _q.create("{1}").divided(this);
- }
- plus(e) {
- return this._batchOperator(
- e,
- 1
- /* PLUS */
- );
- }
- minus(e) {
- return this._batchOperator(
- e,
- 0
- /* MINUS */
- );
- }
- multiply(e) {
- return this._batchOperator(
- e,
- 2
- /* MULTIPLY */
- );
- }
- divided(e) {
- return this._batchOperator(
- e,
- 3
- /* DIVIDED */
- );
- }
- mod(e) {
- return this._batchOperator(
- e,
- 4
- /* MOD */
- );
- }
- modInverse(e) {
- return this.map((t) => t.isError() ? t : e.mod(t));
- }
- compare(e, t, r) {
- return this._batchOperator(e, 5, t, r);
- }
- concatenateFront(e) {
- return this._batchOperator(
- e,
- 6
- /* CONCATENATE_FRONT */
- );
- }
- concatenateBack(e) {
- return this._batchOperator(
- e,
- 7
- /* CONCATENATE_BACK */
- );
- }
- map(e) {
- const t = (r, n, s) => r == null ? ie.create() : r.isError() ? r : e(r, n, s);
- return this.mapValue(t);
- }
- mapValue(e) {
- var s;
- const t = this._rowCount, r = this._columnCount, n = [];
- for (let o = 0; o < t; o++) {
- const u = [];
- for (let c = 0; c < r; c++) {
- const l2 = (s = this._values) == null ? void 0 : s[o];
- if (l2 == null)
- u[c] = g2.create(m2.VALUE);
- else {
- const f2 = l2[c] || this._defaultValue;
- f2 ? u[c] = e(f2, o, c) : u[c] = ie.create();
- }
- }
- n.push(u);
- }
- return this._createNewArray(n, t, r);
- }
- pow(e) {
- return this._batchOperator(
- e,
- 8
- /* POW */
- );
- }
- /**
- *
- * @param valueObject In the case of an inverse, it is certainly not an array.
- * @returns
- */
- powInverse(e) {
- return this.map((t) => t.isError() ? t : e.pow(t));
- }
- sqrt() {
- return this.map((e) => e.isError() ? e : e.sqrt());
- }
- cbrt() {
- return this.map((e) => e.isError() ? e : e.cbrt());
- }
- cos() {
- return this.map((e) => e.isError() ? e : e.cos());
- }
- cosh() {
- return this.map((e) => e.isError() ? e : e.cosh());
- }
- acos() {
- return this.map((e) => e.isError() ? e : e.acos());
- }
- acosh() {
- return this.map((e) => e.isError() ? e : e.acosh());
- }
- sin() {
- return this.map((e) => e.isError() ? e : e.sin());
- }
- sinh() {
- return this.map((e) => e.isError() ? e : e.sinh());
- }
- asin() {
- return this.map((e) => e.isError() ? e : e.asin());
- }
- asinh() {
- return this.map((e) => e.isError() ? e : e.asinh());
- }
- tan() {
- return this.map((e) => e.isError() ? e : e.tan());
- }
- tanh() {
- return this.map((e) => e.isError() ? e : e.tanh());
- }
- atan() {
- return this.map((e) => e.isError() ? e : e.atan());
- }
- atanh() {
- return this.map((e) => e.isError() ? e : e.atanh());
- }
- atan2(e) {
- return this._batchOperator(
- e,
- 12
- /* ATAN2 */
- );
- }
- atan2Inverse(e) {
- return this.map((t) => t.isError() ? t : e.atan2(t));
- }
- mean(e = 0) {
- const t = this.sum(), r = this.count();
- return t.divided(e === 0 ? r : r.minusBy(1));
- }
- median() {
- const e = this.flattenPosition().numberArray, t = this._createNewArray([e], 1, e.length), r = t.getColumnCount();
- if (r <= 1)
- return t.get(0, 0) || ie.create();
- if (t.sortByRow(0), r % 2 === 0) {
- const n = t.get(0, r / 2) || ie.create(), s = t.get(0, r / 2 - 1) || ie.create();
- return n.plus(s).divided(y2.create(2));
- }
- return t.get(0, (r - 1) / 2) || ie.create();
- }
- /**
- * ┌──────────────┬────────────────────────────────┬───────────────────┐
- * │ Function │ Ignore logical values and text │ Type │
- * ├──────────────┼────────────────────────────────┼───────────────────┤
- * │ VAR.S (VAR) │ TRUE │ sample │
- * │ VAR.P (VARP) │ TRUE │ entire population │
- * │ VARA │ FALSE │ sample │
- * │ VARPA │ FALSE │ entire population │
- * └──────────────┴────────────────────────────────┴───────────────────┘
- *
- * for VARPA and VARA, strings and FALSE are counted as 0, TRUE is counted as 1
- * for VAR.S/VAR, or VAR.P/VARP, strings,TRUE and FALSE are ignored
- * Since sum ignores strings and booleans, they are ignored here too, and VAR.S and VAR.P are used more
- *
- * VAR.S assumes that its arguments are a sample of the population, like numpy.var(data, ddof=1)
- * VAR.P assumes that its arguments are the entire population, like numpy.var(data, ddof=0)
- * numpy.var uses ddof=0 (Delta Degrees of Freedom) by default, so we use ddof=0 here
- *
- */
- var(e = 0) {
- const t = this.mean(), r = [[]];
- this.iterator((l2) => {
- if (l2 == null || l2.isError() || l2.isString() || l2.isBoolean() || l2.isNull())
- return;
- const f2 = l2.minus(t).pow(y2.create(2));
- f2.isError() || r[0].push(f2);
- });
- const { _unitId: n, _sheetId: s, _currentRow: o, _currentColumn: u } = this;
- return _q.create({
- calculateValueList: r,
- rowCount: 1,
- columnCount: r[0].length,
- unitId: n,
- sheetId: s,
- row: o,
- column: u
- }).mean(e);
- }
- /**
- * STDEV.P (STDEVP): ddof=0, ignore strings and booleans
- * STDEV.S (STDEV): ddof=1, ignore strings and booleans
- *
- * STDEVPA: ddof=0,
- * STDEVA: ddof=1,
- * @returns
- */
- std(e = 0) {
- const t = this.var(e);
- return t.isError() ? t : t.sqrt();
- }
- log() {
- return this.map((e) => e.isError() ? e : e.log());
- }
- log10() {
- return this.map((e) => e.isError() ? e : e.log10());
- }
- exp() {
- return this.map((e) => e.isError() ? e : e.exp());
- }
- abs() {
- return this.map((e) => e.isError() ? e : e.abs());
- }
- round(e) {
- return this._batchOperator(
- e,
- 9
- /* ROUND */
- );
- }
- roundInverse(e) {
- return this.map((t) => t.isError() ? t : e.round(t));
- }
- floor(e) {
- return this._batchOperator(
- e,
- 10
- /* FLOOR */
- );
- }
- floorInverse(e) {
- return this.map((t) => t.isError() ? t : e.floor(t));
- }
- ceil(e) {
- return this._batchOperator(
- e,
- 11
- /* CEIL */
- );
- }
- ceilInverse(e) {
- return this.map((t) => t.isError() ? t : e.ceil(t));
- }
- toValue() {
- return Rf(this._values);
- }
- _clearCache() {
- this._flattenCache = null, this._sliceCache.clear();
- }
- _sort(e) {
- const t = hn();
- return (r, n) => {
- const s = r[e], o = n[e];
- return s == null ? 1 : o == null ? -1 : s.isError() && s.isError() ? 0 : s.isError() ? 1 : o.isError() ? -1 : t(
- s.getValue(),
- o.getValue()
- );
- };
- }
- _transposeArray(e) {
- const t = e.length, r = e[0].length, n = [];
- for (let s = 0; s < r; s++) {
- n[s] = [];
- for (let o = 0; o < t; o++)
- n[s][o] = e[o][s];
- }
- return n;
- }
- _batchOperator(e, t, r, n) {
- const s = [];
- let o = this._rowCount, u = this._columnCount;
- if (e.isArray()) {
- const f2 = e.getRowCount(), h = e.getColumnCount();
- if (o = Math.max(f2, o), u = Math.max(h, u), f2 === 1 && h === 1) {
- const d2 = e.getFirstCell();
- for (let _ = 0; _ < u; _++)
- s.push(d2);
- } else if (f2 === 1 && this._columnCount > 1) {
- const d2 = e.getArrayValue();
- for (let _ = 0; _ < u; _++)
- s.push(d2[0][_]);
- } else
- return this._batchOperatorArray(e, t, r, n);
- } else
- for (let f2 = 0; f2 < u; f2++)
- s.push(e);
- const c = [];
- for (let f2 = 0; f2 < u; f2++) {
- const h = s[f2];
- this._batchOperatorValue(h, f2, c, t, r, n);
- }
- const l2 = this._createNewArray(c, o, u);
- return l2.setDefaultValue(T2.create(false)), l2;
- }
- // eslint-disable-next-line max-lines-per-function
- _batchOperatorValue(e, t, r, n, s, o) {
- const u = this._rowCount, c = this.getUnitId(), l2 = this.getSheetId(), f2 = this.getCurrentRow(), h = this.getCurrentColumn();
- if (n === 5) {
- const { rowsInCache: d2, rowsNotInCache: _ } = St.canUseCache(
- c,
- l2,
- t + h,
- f2,
- f2 + u - 1
- );
- if (d2.length > 0) {
- if (s === $.EQUALS) {
- const C = St.getCellPositions(
- c,
- l2,
- t + h,
- e.getValue(),
- d2
- );
- C != null && C.forEach((E2) => {
- if (E2 < f2 || E2 > f2 + u - 1)
- return;
- const b = E2 - f2;
- r[b] == null && (r[b] = []), r[b][t] = T2.create(true);
- });
- } else {
- const C = St.getCellValuePositions(
- c,
- l2,
- t + h
- );
- C != null && C.forEach((E2, b) => {
- let R = ie.create();
- yr.has(b) ? R = g2.create(b) : typeof b == "string" ? R = j.create(b) : typeof b == "number" ? R = y2.create(b) : typeof b == "boolean" && (R = T2.create(b));
- let p2;
- R.isError() ? p2 = R : e.isError() ? p2 = e : p2 = R.compare(e, s, o), (p2.isError() || p2.getValue() === true) && E2.forEach((N2) => {
- N2 >= f2 && N2 <= f2 + u - 1 && (r[N2 - f2] == null && (r[N2 - f2] = []), r[N2 - f2][t] = p2);
- });
- });
- }
- if (_.length > 0)
- for (const C of _) {
- const [E2, b] = C;
- for (let R = E2; R <= b; R++)
- this.__batchOperatorRowValue(
- e,
- t,
- r,
- n,
- R - f2,
- c,
- l2,
- f2,
- h,
- s,
- o
- );
- St.setContinueBuildingCache(
- c,
- l2,
- t + h,
- E2,
- b
- );
- }
- return;
- }
- }
- for (let d2 = 0; d2 < u; d2++)
- this.__batchOperatorRowValue(
- e,
- t,
- r,
- n,
- d2,
- c,
- l2,
- f2,
- h,
- s,
- o
- );
- St.setContinueBuildingCache(
- c,
- l2,
- t + h,
- f2,
- f2 + u - 1
- );
- }
- // eslint-disable-next-line
- __batchOperatorRowValue(e, t, r, n, s, o, u, c, l2, f2, h) {
- const d2 = this.getValueOrDefault(s, t);
- if (r[s] == null && (r[s] = []), d2 && e)
- if (d2.isError())
- r[s][t] = d2;
- else if (e.isError())
- r[s][t] = e;
- else
- switch (n) {
- case 1:
- r[s][t] = d2.plus(e);
- break;
- case 0:
- r[s][t] = d2.minus(e);
- break;
- case 2:
- r[s][t] = d2.multiply(e);
- break;
- case 3:
- r[s][t] = d2.divided(e);
- break;
- case 4:
- r[s][t] = d2.mod(e);
- break;
- case 5:
- f2 ? r[s][t] = d2.compare(e, f2, h) : r[s][t] = g2.create(m2.VALUE);
- break;
- case 6:
- r[s][t] = d2.concatenateFront(e);
- break;
- case 7:
- r[s][t] = d2.concatenateBack(e);
- break;
- case 8:
- r[s][t] = d2.pow(e);
- break;
- case 9:
- r[s][t] = d2.round(e);
- break;
- case 10:
- r[s][t] = d2.floor(e);
- break;
- case 12:
- r[s][t] = d2.atan2(e);
- break;
- case 11:
- r[s][t] = d2.ceil(e);
- break;
- }
- else
- r[s][t] = g2.create(m2.NA);
- d2 != null && (d2.isError() ? St.set(
- o,
- u,
- t + l2,
- d2.getErrorType(),
- s + c
- ) : St.set(
- o,
- u,
- t + l2,
- d2.getValue(),
- s + c
- ));
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- _batchOperatorArray(e, t, r, n) {
- let s = e.getRowCount(), o = e.getColumnCount();
- s < this._rowCount && (s = this._rowCount), o < this._columnCount && (o = this._columnCount);
- const u = [], c = this._checkArrayCalculateType(this), l2 = this._checkArrayCalculateType(e);
- for (let f2 = 0; f2 < s; f2++) {
- const h = [];
- for (let d2 = 0; d2 < o; d2++) {
- let _;
- c === 3 ? _ = this.getValueOrDefault(0, 0) : c === 1 ? _ = this.getValueOrDefault(0, d2) : c === 2 ? _ = this.getValueOrDefault(f2, 0) : _ = this.getValueOrDefault(f2, d2);
- let C;
- if (l2 === 3 ? C = e.getValueOrDefault(0, 0) : l2 === 1 ? C = e.getValueOrDefault(0, d2) : l2 === 2 ? C = e.getValueOrDefault(f2, 0) : C = e.getValueOrDefault(f2, d2), _ && C)
- if (_.isError())
- h[d2] = _;
- else if (C.isError())
- h[d2] = C;
- else
- switch (t) {
- case 1:
- h[d2] = _.plus(C);
- break;
- case 0:
- h[d2] = _.minus(C);
- break;
- case 2:
- h[d2] = _.multiply(C);
- break;
- case 3:
- h[d2] = _.divided(C);
- break;
- case 4:
- h[d2] = _.mod(C);
- break;
- case 5:
- r ? h[d2] = _.compare(C, r, n) : h[d2] = g2.create(m2.VALUE);
- break;
- case 6:
- h[d2] = _.concatenateFront(C);
- break;
- case 7:
- h[d2] = _.concatenateBack(C);
- break;
- case 8:
- h[d2] = _.pow(C);
- break;
- case 9:
- h[d2] = _.round(C);
- break;
- case 12:
- h[d2] = _.atan2(C);
- break;
- case 10:
- h[d2] = _.floor(C);
- break;
- case 11:
- h[d2] = _.ceil(C);
- break;
- }
- else
- h[d2] = g2.create(m2.NA);
- }
- u.push(h);
- }
- return this._createNewArray(u, s, o);
- }
- _checkArrayCalculateType(e) {
- return e.getRowCount() === 1 && e.getColumnCount() === 1 ? 3 : e.getRowCount() === 1 ? 1 : e.getColumnCount() === 1 ? 2 : 0;
- }
- _formatValue(e) {
- if (typeof e != "string")
- return e = e, this._rowCount = e.rowCount, this._columnCount = e.columnCount, this._unitId = e.unitId, this._sheetId = e.sheetId, this._currentRow = e.row, this._currentColumn = e.column, e.calculateValueList;
- e = e.slice(1, -1);
- const t = e.split(";"), r = t.length, n = [];
- let s = 0;
- for (let o = 0; o < r; o++) {
- const c = t[o].split(","), l2 = c.length;
- s < l2 && (s = l2);
- const f2 = [];
- for (let h = 0; h < l2; h++) {
- const d2 = c[h].trim();
- f2.push(pt.create(d2));
- }
- n.push(f2);
- }
- return this._rowCount = r, this._columnCount = s, n;
- }
- _createNewArray(e, t, r, n = -1, s = -1) {
- (this._currentColumn === -1 || this._currentRow === -1) && (n = -1, s = -1);
- const o = {
- calculateValueList: e,
- rowCount: t,
- columnCount: r,
- unitId: this.getUnitId(),
- sheetId: this.getSheetId(),
- row: n,
- column: s
- };
- return _q.create(o);
- }
- };
- var pt = class {
- static create(a2) {
- if (a2 == null)
- return ie.create();
- if (typeof a2 == "boolean")
- return T2.create(a2);
- if (typeof a2 == "string") {
- const e = a2.toLocaleUpperCase().trim();
- if (yr.has(e))
- return g2.create(e);
- if (e === er.TRUE || e === er.FALSE)
- return In(a2);
- if (DC(a2))
- return y2.create(Number(a2));
- const { isNumberPattern: t, value: r, pattern: n } = il(a2);
- if (t)
- return y2.create(r, n);
- const s = a2.replace(/\n/g, "").replace(/\r/g, "");
- return !pf(s) && Ac(s) ? q2.create(s) : bf(a2);
- }
- return typeof a2 == "number" ? Fn(a2) : g2.create(m2.VALUE);
- }
- };
- function pf(i) {
- const a2 = i.trim();
- return a2.startsWith('"') && a2.endsWith('"');
- }
- var Vf = 1e4;
- var Bs = new Vt(Vf);
- var kn = class extends jn {
- constructor(e) {
- super();
- A(this, "_forcedSheetId", "");
- A(this, "_forcedSheetName", "");
- A(this, "_defaultSheetId", "");
- A(this, "_rangeData", {
- startColumn: -1,
- startRow: -1,
- endRow: -1,
- endColumn: -1
- });
- A(this, "_unitData", {});
- A(this, "_unitStylesData", {});
- A(this, "_defaultUnitId", "");
- A(this, "_forcedUnitId", "");
- A(this, "_runtimeData", {});
- A(this, "_arrayFormulaCellData", {});
- A(this, "_runtimeArrayFormulaCellData", {});
- A(this, "_runtimeFeatureCellData", {});
- A(this, "_refOffsetX", 0);
- A(this, "_refOffsetY", 0);
- this._token = e;
- }
- dispose() {
- this._unitData = {}, this._unitStylesData = {}, this._runtimeData = {};
- }
- getToken() {
- return this._token;
- }
- setToken(e) {
- this._token = e;
- }
- isExceedRange() {
- const { startRow: e, endRow: t, startColumn: r, endColumn: n } = this.getRangePosition();
- return e < 0 || r < 0 || t >= this.getActiveSheetRowCount() || n >= this.getActiveSheetColumnCount();
- }
- setRefOffset(e = 0, t = 0) {
- this._refOffsetX = e, this._refOffsetY = t;
- }
- getRefOffset() {
- return {
- x: this._refOffsetX,
- y: this._refOffsetY
- };
- }
- getRangePosition() {
- let { startRow: e, startColumn: t, endRow: r, endColumn: n } = jC(this._rangeData, this._refOffsetX, this._refOffsetY);
- return Number.isNaN(e) && (e = 0), Number.isNaN(t) && (t = 0), Number.isNaN(r) && (r = this.getActiveSheetRowCount() - 1), Number.isNaN(n) && (n = this.getActiveSheetColumnCount() - 1), {
- ...this._rangeData,
- startRow: e,
- endRow: r,
- startColumn: t,
- endColumn: n
- };
- }
- isReferenceObject() {
- return true;
- }
- iterator(e) {
- const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition();
- if (this._checkIfWorksheetMiss())
- return e(g2.create(m2.VALUE), t, n);
- const o = this._forcedUnitId || this._defaultUnitId, u = this._forcedSheetId || this._defaultSheetId;
- for (let c = t; c <= r; c++)
- for (let l2 = n; l2 <= s; l2++) {
- if (c < 0 || l2 < 0)
- return e(g2.create(m2.REF), c, l2);
- const f2 = this.getCellData(c, l2);
- let h = false;
- if (nn(f2)) {
- h = e(null, c, l2);
- continue;
- }
- let d2 = this.getCellValueObject(f2);
- if (c === t && l2 === n) {
- const _ = this.getCellPattern(o, u, c, l2);
- if (_ && d2.isNumber()) {
- const C = Number(d2.getValue());
- d2 = y2.create(C, _);
- }
- }
- if (h = e(d2, c, l2), h === false)
- return;
- }
- }
- getFirstCell() {
- const { startRow: e, startColumn: t } = this.getRangePosition(), r = this.getCellData(e, t);
- if (!r)
- return y2.create(0);
- let n = this.getCellValueObject(r);
- const s = this._forcedUnitId || this._defaultUnitId, o = this._forcedSheetId || this._defaultSheetId, u = this.getCellPattern(s, o, e, t);
- if (u && n.isNumber()) {
- const c = Number(n.getValue());
- n = y2.create(c, u);
- }
- return n;
- }
- getRangeData() {
- return this._rangeData;
- }
- setRangeData(e) {
- this._rangeData = e;
- }
- getUnitId() {
- return this._forcedUnitId && this._forcedUnitId.length > 0 ? this._forcedUnitId : this._defaultUnitId;
- }
- getSheetId() {
- return this._forcedSheetId && this._forcedSheetId.length > 0 ? this._forcedSheetId : this._defaultSheetId;
- }
- setForcedUnitIdDirect(e) {
- e.length > 0 && (this._forcedUnitId = e);
- }
- getForcedUnitId() {
- return this._forcedUnitId;
- }
- setForcedSheetId(e) {
- var t;
- this._forcedSheetId = (t = e[this.getUnitId()]) == null ? void 0 : t[this._forcedSheetName];
- }
- setForcedSheetIdDirect(e) {
- this._forcedSheetId = e;
- }
- getForcedSheetId() {
- return this._forcedSheetId;
- }
- setForcedSheetName(e) {
- e.length > 0 && (this._forcedSheetName = e);
- }
- getForcedSheetName() {
- return this._forcedSheetName;
- }
- setDefaultSheetId(e) {
- this._defaultSheetId = e;
- }
- getDefaultSheetId() {
- return this._defaultSheetId;
- }
- setDefaultUnitId(e) {
- this._defaultUnitId = e;
- }
- getDefaultUnitId() {
- return this._defaultUnitId;
- }
- getUnitData() {
- return this._unitData;
- }
- setUnitData(e) {
- this._unitData = e;
- }
- getUnitStylesData() {
- return this._unitStylesData;
- }
- setUnitStylesData(e) {
- this._unitStylesData = e;
- }
- getRuntimeData() {
- return this._runtimeData;
- }
- setRuntimeData(e) {
- this._runtimeData = e;
- }
- getArrayFormulaCellData() {
- return this._arrayFormulaCellData;
- }
- setArrayFormulaCellData(e) {
- this._arrayFormulaCellData = e;
- }
- getRuntimeArrayFormulaCellData() {
- return this._runtimeArrayFormulaCellData;
- }
- setRuntimeArrayFormulaCellData(e) {
- this._runtimeArrayFormulaCellData = e;
- }
- getRuntimeFeatureCellData() {
- return this._runtimeFeatureCellData;
- }
- setRuntimeFeatureCellData(e) {
- this._runtimeFeatureCellData = e;
- }
- getActiveSheetRowCount() {
- var e;
- return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.rowCount) || 0;
- }
- getActiveSheetColumnCount() {
- var e;
- return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.columnCount) || 0;
- }
- getRowCount() {
- return this._rangeData.endRow - this._rangeData.startRow + 1;
- }
- getColumnCount() {
- return this._rangeData.endColumn - this._rangeData.startColumn + 1;
- }
- getRowData() {
- var e;
- return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.rowData) || {};
- }
- getColumnData() {
- var e;
- return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.columnData) || {};
- }
- isCell() {
- return false;
- }
- isColumn() {
- return false;
- }
- isRow() {
- return false;
- }
- isRange() {
- return false;
- }
- isTable() {
- return false;
- }
- unionBy(e) {
- return g2.create(m2.REF);
- }
- unionRange(e, t) {
- return {
- startRow: -1,
- startColumn: -1,
- endRow: -1,
- endColumn: -1
- };
- }
- getCellValueObject(e) {
- const t = cl(e);
- if (yr.has(t))
- return g2.create(t);
- if (e.t === dn.NUMBER) {
- const r = this._getPatternByCell(e);
- return Fn(t, r);
- }
- return e.t === dn.STRING || e.t === dn.FORCE_STRING ? j.create(t.toString()) : e.t === dn.BOOLEAN ? In(t) : pt.create(t);
- }
- _getPatternByCell(e) {
- var n;
- const t = this._unitStylesData[this.getUnitId()];
- if (!t)
- return "";
- const r = t.getStyleByCell(e);
- return ((n = r == null ? void 0 : r.n) == null ? void 0 : n.pattern) || "";
- }
- getCellByRow(e) {
- return this.getCellByPosition(e);
- }
- getCellByColumn(e) {
- return this.getCellByPosition(void 0, e);
- }
- getCurrentActiveSheetData() {
- var e;
- return (e = this._unitData[this.getUnitId()]) == null ? void 0 : e[this.getSheetId()];
- }
- getCurrentStylesData() {
- return this._unitStylesData[this.getUnitId()];
- }
- getCurrentRuntimeSheetData() {
- var e, t;
- return (t = (e = this._runtimeData) == null ? void 0 : e[this.getUnitId()]) == null ? void 0 : t[this.getSheetId()];
- }
- getCurrentActiveArrayFormulaCellData() {
- var e, t;
- return (t = (e = this._arrayFormulaCellData) == null ? void 0 : e[this.getUnitId()]) == null ? void 0 : t[this.getSheetId()];
- }
- getCurrentRuntimeActiveArrayFormulaCellData() {
- var e, t;
- return (t = (e = this._runtimeArrayFormulaCellData) == null ? void 0 : e[this.getUnitId()]) == null ? void 0 : t[this.getSheetId()];
- }
- getCellData(e, t) {
- const r = this.getCurrentActiveSheetData(), n = this.getCurrentRuntimeSheetData(), s = this.getCurrentActiveArrayFormulaCellData(), o = this.getCurrentRuntimeActiveArrayFormulaCellData();
- return (n == null ? void 0 : n.getValue(e, t)) || (o == null ? void 0 : o.getValue(e, t)) || this.getRuntimeFeatureCellValue(e, t) || (s == null ? void 0 : s.getValue(e, t)) || (r == null ? void 0 : r.cellData.getValue(e, t));
- }
- getRuntimeFeatureCellValue(e, t) {
- return ao(e, t, this.getSheetId(), this.getUnitId(), this._runtimeFeatureCellData);
- }
- getCellByPosition(e, t) {
- let r = e, n = t;
- r || (r = this._rangeData.startRow), n || (n = this._rangeData.startColumn);
- const s = this.getCellData(r, n);
- return s ? this.getCellValueObject(s) : g2.create(m2.VALUE);
- }
- /**
- * Get the pattern of the cell
- * @param unitId
- * @param sheetId
- * @param row
- * @param column
- * @returns
- */
- getCellPattern(e, t, r, n) {
- var c, l2, f2, h;
- const s = this._unitStylesData[e];
- if (!s)
- return "";
- const o = (f2 = (l2 = (c = this._unitData[e]) == null ? void 0 : c[t]) == null ? void 0 : l2.cellData) == null ? void 0 : f2.getValue(r, n);
- if (!o)
- return "";
- const u = s.getStyleByCell(o);
- return ((h = u == null ? void 0 : u.n) == null ? void 0 : h.pattern) || "";
- }
- toArrayValueObject(e = true) {
- var _;
- const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition(), o = `${this.getUnitId()}_${this.getSheetId()}_${t}_${r}_${n}_${s}`, u = Bs.get(o);
- if (u && e)
- return u;
- const c = r - t + 1, l2 = s - n + 1;
- if (c < 0 || l2 < 0)
- return this._getBlankArrayValueObject();
- const f2 = new Array(c);
- this.iterator((C, E2, b) => {
- const R = E2 - t, p2 = b - n;
- f2[R] || (f2[R] = new Array(l2)), C == null && (C = ie.create()), f2[R][p2] = C;
- });
- const h = {
- calculateValueList: f2,
- rowCount: f2.length,
- columnCount: ((_ = f2[0]) == null ? void 0 : _.length) || 0,
- unitId: this.getUnitId(),
- sheetId: this.getSheetId(),
- row: t,
- column: n
- }, d2 = q2.create(h);
- return e && Bs.set(o, d2), d2;
- }
- toUnitRange() {
- return {
- range: this.getRangePosition(),
- sheetId: this.getSheetId(),
- unitId: this.getUnitId()
- };
- }
- _checkIfWorksheetMiss() {
- return (this._forcedSheetId == null || this._forcedSheetId.length === 0) && this._forcedSheetName.length > 0;
- }
- _getBlankArrayValueObject() {
- const e = {
- calculateValueList: [],
- rowCount: 0,
- columnCount: 0,
- unitId: this.getUnitId(),
- sheetId: this.getSheetId(),
- row: 0,
- column: 0
- };
- return q2.create(e);
- }
- };
- var Nf = class extends jn {
- constructor(a2) {
- super(), this._promise = a2;
- }
- isAsyncObject() {
- return true;
- }
- async getValue() {
- return this._promise;
- }
- };
- var Of = class extends jn {
- constructor(a2) {
- super(), this._promiseList = a2;
- }
- isAsyncArrayObject() {
- return true;
- }
- async getValue() {
- var t;
- const a2 = [];
- for (let r = 0; r < this._promiseList.length; r++) {
- const n = this._promiseList[r];
- a2[r] == null && (a2[r] = []);
- for (let s = 0; s < n.length; s++) {
- const o = n[s];
- o.isAsyncObject() ? a2[r][s] = await o.getValue() : a2[r][s] = o;
- }
- }
- const e = {
- calculateValueList: a2,
- rowCount: a2.length,
- columnCount: ((t = a2[0]) == null ? void 0 : t.length) || 0,
- unitId: "",
- sheetId: "",
- row: 0,
- column: 0
- };
- return q2.create(e);
- }
- };
- var Cn = class extends kn {
- constructor(a2, e, t) {
- super(""), this.setRangeData(a2), e && this.setForcedSheetIdDirect(e), t && this.setForcedUnitIdDirect(t);
- }
- isRange() {
- return true;
- }
- };
- var da = class extends kn {
- constructor(a2) {
- super(a2);
- const e = mr(a2);
- this.setForcedUnitIdDirect(e.unitId), this.setForcedSheetName(e.sheetName), this.setRangeData(e.range);
- }
- isCell() {
- return true;
- }
- unionBy(a2) {
- if (!a2.isCell())
- return g2.create(m2.REF);
- const e = a2, t = this.unionRange(this.getRangeData(), e.getRangeData());
- return this._createRange(t);
- }
- unionRange(a2, e) {
- const t = a2.startRow, r = a2.startColumn, n = e.startRow, s = e.startColumn, o = {
- startRow: -1,
- startColumn: -1,
- endRow: -1,
- endColumn: -1
- };
- return t > n ? (o.startRow = n, o.endRow = t) : (o.startRow = t, o.endRow = n), r > s ? (o.startColumn = s, o.endColumn = r) : (o.startColumn = r, o.endColumn = s), a2.startAbsoluteRefType && (o.startAbsoluteRefType = a2.startAbsoluteRefType), e.startAbsoluteRefType && (o.endAbsoluteRefType = e.startAbsoluteRefType), o;
- }
- _createRange(a2) {
- const e = new Cn(
- a2,
- this.getForcedSheetId(),
- this.getForcedUnitId()
- );
- e.setUnitData(this.getUnitData()), e.setDefaultSheetId(this.getDefaultSheetId()), e.setDefaultUnitId(this.getDefaultUnitId()), e.setRuntimeData(this.getRuntimeData()), e.setUnitStylesData(this.getUnitStylesData()), e.setArrayFormulaCellData(this.getArrayFormulaCellData()), e.setRuntimeArrayFormulaCellData(this.getRuntimeArrayFormulaCellData()), e.setRuntimeFeatureCellData(this.getRuntimeFeatureCellData());
- const { x: t, y: r } = this.getRefOffset();
- e.setRefOffset(t, r);
- const n = this.getForcedSheetId();
- e.setForcedSheetName(this.getForcedSheetName()), n != null && e.setForcedSheetIdDirect(n);
- const s = this.getForcedUnitId();
- return s && e.setForcedUnitIdDirect(s), e;
- }
- };
- var Ca = class extends kn {
- constructor(a2) {
- super(a2);
- const e = mr(a2);
- this.setForcedUnitIdDirect(e.unitId), this.setForcedSheetName(e.sheetName);
- const t = {
- ...e.range,
- startColumn: e.range.startColumn,
- startRow: Number.NaN,
- endColumn: e.range.endColumn,
- endRow: Number.NaN,
- rangeType: De.COLUMN
- };
- this.setRangeData(t);
- }
- isColumn() {
- return true;
- }
- unionBy(a2) {
- if (!a2.isColumn())
- return g2.create(m2.REF);
- const e = a2;
- if (e.getForcedSheetName() !== void 0 && e.getForcedSheetName() !== "")
- return g2.create(m2.REF);
- const t = this.getRangeData(), r = e.getRangeData(), n = r.startColumn;
- if (n >= t.startColumn && n <= t.endColumn)
- return this;
- const s = t.startColumn;
- return n > s ? t.endColumn = n : (t.startColumn = n, t.endColumn = s), r.startAbsoluteRefType && (t.endAbsoluteRefType = r.startAbsoluteRefType), t.rangeType = De.COLUMN, this.setToken(`${this.getToken()}${K2.COLON}${e.getToken()}`), this;
- }
- };
- var _a = class extends kn {
- constructor(a2) {
- super(a2);
- const e = mr(a2);
- this.setForcedUnitIdDirect(e.unitId), this.setForcedSheetName(e.sheetName);
- const t = {
- ...e.range,
- startColumn: Number.NaN,
- startRow: e.range.startRow,
- endColumn: Number.NaN,
- endRow: e.range.endRow,
- rangeType: De.ROW
- };
- this.setRangeData(t);
- }
- isRow() {
- return true;
- }
- unionBy(a2) {
- if (!a2.isRow())
- return g2.create(m2.REF);
- const e = a2;
- if (e.getForcedSheetName() !== void 0 && e.getForcedSheetName() !== "")
- return g2.create(m2.REF);
- const t = this.getRangeData(), r = e.getRangeData(), n = r.startRow;
- if (n >= t.startRow && n <= t.endRow)
- return this;
- const s = t.startRow;
- return n > s ? t.endRow = n : (t.startRow = n, t.endRow = s), r.startAbsoluteRefType && (t.endAbsoluteRefType = r.startAbsoluteRefType), t.rangeType = De.ROW, this.setToken(`${this.getToken()}${K2.COLON}${e.getToken()}`), this;
- }
- };
- function O(i, a2, e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = [];
- for (let o = 0; o < i; o++) {
- const u = [];
- for (let c = 0; c < a2; c++) {
- if (r === 1 && n === 1) {
- const f2 = e.isArray() ? e.get(0, 0) : e;
- u.push(f2);
- continue;
- }
- if (r === 1 && c < n) {
- const f2 = e.get(0, c);
- u.push(f2);
- continue;
- }
- if (n === 1 && o < r) {
- const f2 = e.get(o, 0);
- u.push(f2);
- continue;
- }
- if (o >= r || c >= n) {
- u.push(t != null ? t : ie.create());
- continue;
- }
- const l2 = e.get(o, c);
- u.push(l2);
- }
- s.push(u);
- }
- return tr(s, i, a2);
- }
- function tr(i, a2, e, t = "", r = "") {
- const n = {
- calculateValueList: i,
- rowCount: a2,
- columnCount: e,
- unitId: t,
- sheetId: r,
- row: -1,
- column: -1
- };
- return q2.create(n);
- }
- function Aa(i) {
- const a2 = [
- $.EQUALS,
- $.NOT_EQUAL,
- $.GREATER_THAN_OR_EQUAL,
- $.GREATER_THAN,
- $.LESS_THAN_OR_EQUAL,
- $.LESS_THAN
- ];
- for (const e of a2)
- if (i.startsWith(e)) {
- const t = i.substring(e.length);
- return [e, pt.create(t)];
- }
- return [$.EQUALS, pt.create(i)];
- }
- function $n(i, a2, e, t) {
- if (!e)
- if (a2.isString()) {
- const r = `${a2.getValue()}`, [n, s] = Aa(r);
- e = n, a2 = s;
- } else
- e = $.EQUALS;
- return i.compare(a2, e, t);
- }
- function Mf2(i, a2) {
- const e = Math.max(i.isArray() ? i.getRowCount() : 1, a2.isArray() ? a2.getRowCount() : 1), t = Math.max(i.isArray() ? i.getColumnCount() : 1, a2.isArray() ? a2.getColumnCount() : 1), r = O(e, t, i), n = O(e, t, a2);
- return r.mapValue((s, o, u) => {
- const c = n.get(o, u);
- return s != null && s.isError() ? s : c != null && c.isError() ? c : s != null && s.isBoolean() && (c != null && c.isBoolean()) ? In(s.getValue() && c.getValue()) : T2.create(false);
- });
- }
- function wf(i) {
- const a2 = i.getValue();
- let e = 0;
- return a2 && (e = 1), y2.create(e);
- }
- function Ai(i) {
- return i.isArray() && i.getRowCount() === 1 && i.getColumnCount() === 1 ? true : i.isReferenceObject() ? !!(i.isCell() || i.getRowCount() === 1 && i.getColumnCount() === 1) : (i = i, !!(i.isString() || i.isNumber() || i.isBoolean() || i.isError() || i.isNull()));
- }
- function Gt(i) {
- const a2 = i == null ? void 0 : i.getPattern();
- let e = {};
- if (a2 && (e = {
- s: {
- n: {
- pattern: a2
- }
- }
- }), i == null)
- return {
- v: null,
- ...e
- };
- if (i.isError())
- return {
- v: i.getErrorType(),
- t: dn.STRING,
- ...e
- };
- if (i.isValueObject()) {
- const t = i, r = t.getValue();
- return t.isNumber() ? {
- v: r,
- t: dn.NUMBER,
- ...e
- } : t.isBoolean() ? {
- v: r ? 1 : 0,
- t: dn.BOOLEAN,
- ...e
- } : t.isString() ? {
- v: r,
- t: dn.STRING,
- ...e
- } : t.isNull() ? {
- v: null,
- ...e
- } : {
- v: r,
- t: dn.STRING,
- ...e
- };
- }
- }
- function Nr(i) {
- let a2 = 0, e = 0;
- return i.forEach((t, r) => {
- if (r % 2 === 1)
- if (t.isArray()) {
- const n = t;
- a2 = Math.max(a2, n.getRowCount()), e = Math.max(e, n.getColumnCount());
- } else
- a2 = Math.max(a2, 1), e = Math.max(e, 1);
- }), { maxRowLength: a2, maxColumnLength: e };
- }
- function Br(i, a2, e, t) {
- const r = a2.getRowCount(), n = a2.getColumnCount();
- for (let s = 0; s < i.length; s++) {
- if (s % 2 === 1)
- continue;
- const o = i[s], u = o.getRowCount(), c = o.getColumnCount();
- if (u !== r || c !== n)
- return O(e, t, g2.create(m2.VALUE));
- }
- return null;
- }
- function Ir(i, a2, e, t = false) {
- const r = [];
- for (let n = 0; n < i.length; n++) {
- if (n % 2 === 1)
- continue;
- const s = i[n], o = i[n + 1];
- O(a2, e, o, g2.create(m2.NA)).iterator((c, l2, f2) => {
- if (!c)
- return;
- let h = $n(s, c);
- if (t && (h = Yn(h, s, c)), r[l2] === void 0 && (r[l2] = []), r[l2][f2] === void 0) {
- r[l2][f2] = h;
- return;
- }
- r[l2][f2] = Mf2(r[l2][f2], h);
- });
- }
- return r;
- }
- function Yn(i, a2, e) {
- const [t, r] = Aa(`${e.getValue()}`);
- return i.mapValue((n, s, o) => {
- const u = a2.get(s, o);
- if (u && Df(u, r))
- return n;
- if (u != null && u.isNumber()) {
- if (r.isString()) {
- const c = r.convertToNumberObjectValue();
- if (c.isNumber())
- return u.compare(c, t);
- }
- return T2.create(false);
- } else if (r.isNumber()) {
- if (u != null && u.isString()) {
- const c = u.convertToNumberObjectValue();
- if (c.isNumber())
- return c.compare(r, t);
- }
- return T2.create(false);
- } else
- return u != null && u.isError() && r.isError() && u.getValue() === r.getValue() ? T2.create(true) : T2.create(false);
- });
- }
- function Df(i, a2) {
- if (i.isNumber() && a2.isNumber() || i.isBoolean() && a2.isBoolean())
- return true;
- const e = i.isString() && i.getValue() === "", t = a2.isString() && a2.getValue() === "";
- return !!((e || i.isNull()) && (t || a2.isNull()) || i.isString() && !e && a2.isString() && !t);
- }
- var an = ((i) => (i[i.CELL = 0] = "CELL", i[i.COLUMN = 1] = "COLUMN", i[i.ROW = 2] = "ROW", i))(an || {});
- function Sf(i, a2) {
- let e;
- switch (a2) {
- case 0:
- e = new da(i);
- break;
- case 1:
- e = new Ca(i);
- break;
- case 2:
- e = new _a(i);
- break;
- default:
- throw new Error("Unknown reference object type");
- }
- return e;
- }
- function Pf(i, a2) {
- let e = g2.create(m2.NAME);
- return (i.isCell() && a2.isCell() || i.isRow() && a2.isRow() || i.isColumn() && a2.isColumn()) && (e = i.unionBy(a2)), e;
- }
- var Lf = Object.defineProperty;
- var xf = Object.getOwnPropertyDescriptor;
- var jf = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? xf(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Lf(a2, e, r), r;
- };
- var Uf = (i, a2) => (e, t) => a2(e, t, i);
- var ft = ((i) => (i[i.IDLE = 0] = "IDLE", i[i.START = 1] = "START", i[i.START_DEPENDENCY = 2] = "START_DEPENDENCY", i[i.START_CALCULATION = 3] = "START_CALCULATION", i[i.CURRENTLY_CALCULATING = 4] = "CURRENTLY_CALCULATING", i[i.START_DEPENDENCY_ARRAY_FORMULA = 5] = "START_DEPENDENCY_ARRAY_FORMULA", i[i.START_CALCULATION_ARRAY_FORMULA = 6] = "START_CALCULATION_ARRAY_FORMULA", i[i.CURRENTLY_CALCULATING_ARRAY_FORMULA = 7] = "CURRENTLY_CALCULATING_ARRAY_FORMULA", i[i.CALCULATION_COMPLETED = 8] = "CALCULATION_COMPLETED", i))(ft || {});
- var wr = ((i) => (i[i.INITIAL = 0] = "INITIAL", i[i.STOP_EXECUTION = 1] = "STOP_EXECUTION", i[i.NOT_EXECUTED = 2] = "NOT_EXECUTED", i[i.SUCCESS = 3] = "SUCCESS", i))(wr || {});
- var Is = class extends nt {
- constructor(a2) {
- super();
- A(this, "_formulaExecuteStage", 0);
- A(this, "_stopState", false);
- A(this, "_currentRow", -1);
- A(this, "_currentColumn", -1);
- A(this, "_currentRowCount", Number.NEGATIVE_INFINITY);
- A(this, "_currentColumnCount", Number.NEGATIVE_INFINITY);
- A(this, "_currentSubUnitId", "");
- A(this, "_currentUnitId", "");
- A(this, "_runtimeData", {});
- A(this, "_runtimeOtherData", {});
- A(this, "_unitArrayFormulaRange", {});
- A(this, "_runtimeArrayFormulaCellData", {});
- A(this, "_runtimeClearArrayFormulaCellData", {});
- A(this, "_runtimeFeatureRange", {});
- A(this, "_runtimeFeatureCellData", {});
- A(this, "_functionsExecutedState", 0);
- A(this, "_functionDefinitionPrivacyVar", /* @__PURE__ */ new Map());
- A(this, "_totalFormulasToCalculate", 0);
- A(this, "_completedFormulasCount", 0);
- A(this, "_totalArrayFormulasToCalculate", 0);
- A(this, "_completedArrayFormulasCount", 0);
- A(this, "_formulaCycleIndex", 0);
- A(this, "_isCycleDependency", false);
- this._currentConfigService = a2;
- }
- get currentRow() {
- return this._currentRow;
- }
- get currentColumn() {
- return this._currentColumn;
- }
- get currentRowCount() {
- return this._currentRowCount;
- }
- get currentColumnCount() {
- return this._currentColumnCount;
- }
- get currentSubUnitId() {
- return this._currentSubUnitId;
- }
- get currentUnitId() {
- return this._currentUnitId;
- }
- dispose() {
- this.reset(), this._runtimeFeatureCellData = {}, this._runtimeFeatureRange = {}, this.clearReferenceAndNumberformatCache();
- }
- enableCycleDependency() {
- this._isCycleDependency = true;
- }
- disableCycleDependency() {
- this._isCycleDependency = false;
- }
- isCycleDependency() {
- return this._isCycleDependency;
- }
- setFormulaCycleIndex(a2) {
- this._formulaCycleIndex = a2;
- }
- getFormulaCycleIndex() {
- return this._formulaCycleIndex;
- }
- setTotalArrayFormulasToCalculate(a2) {
- this._totalArrayFormulasToCalculate = a2;
- }
- getTotalArrayFormulasToCalculate() {
- return this._totalArrayFormulasToCalculate;
- }
- setCompletedArrayFormulasCount(a2) {
- this._completedArrayFormulasCount = a2;
- }
- getCompletedArrayFormulasCount() {
- return this._completedArrayFormulasCount;
- }
- setTotalFormulasToCalculate(a2) {
- this._totalFormulasToCalculate = a2;
- }
- getTotalFormulasToCalculate() {
- return this._totalFormulasToCalculate;
- }
- setCompletedFormulasCount(a2) {
- this._completedFormulasCount = a2;
- }
- getCompletedFormulasCount() {
- return this._completedFormulasCount;
- }
- markedAsSuccessfullyExecuted() {
- this._functionsExecutedState = 3;
- }
- markedAsNoFunctionsExecuted() {
- this._functionsExecutedState = 2;
- }
- markedAsStopFunctionsExecuted() {
- this._functionsExecutedState = 1;
- }
- markedAsInitialFunctionsExecuted() {
- this._functionsExecutedState = 0;
- }
- stopExecution() {
- this._stopState = true, this.setFormulaExecuteStage(
- 0
- /* IDLE */
- );
- }
- isStopExecution() {
- return this._stopState;
- }
- setFormulaExecuteStage(a2) {
- this._formulaExecuteStage = a2;
- }
- getFormulaExecuteStage() {
- return this._formulaExecuteStage;
- }
- reset() {
- this._formulaExecuteStage = 0, this._runtimeData = {}, this._runtimeOtherData = {}, this._unitArrayFormulaRange = {}, this._runtimeArrayFormulaCellData = {}, this._runtimeClearArrayFormulaCellData = {}, this._functionDefinitionPrivacyVar.clear(), this.markedAsInitialFunctionsExecuted(), this._stopState = false, this._isCycleDependency = false, this._totalFormulasToCalculate = 0, this._completedFormulasCount = 0, this.clearReferenceAndNumberformatCache();
- }
- clearReferenceAndNumberformatCache() {
- tl(), ol(), Ic();
- }
- setCurrent(a2, e, t, r, n, s) {
- this._currentRow = a2, this._currentColumn = e, this._currentRowCount = t, this._currentColumnCount = r, this._currentSubUnitId = n, this._currentUnitId = s;
- }
- clearFunctionDefinitionPrivacyVar() {
- this._functionDefinitionPrivacyVar.clear();
- }
- registerFunctionDefinitionPrivacyVar(a2, e) {
- this._functionDefinitionPrivacyVar.set(a2, e);
- }
- getFunctionDefinitionPrivacyVar(a2) {
- return this._functionDefinitionPrivacyVar.get(a2);
- }
- setRuntimeOtherData(a2, e, t, r) {
- const n = this._currentSubUnitId, s = this._currentUnitId;
- this._runtimeOtherData[s] === void 0 && (this._runtimeOtherData[s] = {});
- const o = this._runtimeOtherData[s];
- (o[n] === void 0 || o[n] === null) && (o[n] = {});
- const u = o[n];
- let c = [];
- if (r.isReferenceObject() || r.isValueObject() && r.isArray()) {
- const l2 = r, { startRow: f2, startColumn: h } = l2.getRangePosition();
- l2.iterator((d2, _, C) => {
- const E2 = Gt(d2), b = _ - f2, R = C - h;
- c[b] == null && (c[b] = []), c[b][R] = E2;
- });
- } else
- c = [[Gt(r)]];
- (u[a2] === void 0 || u[a2] === null) && (u[a2] = {}), (u[a2][t] === void 0 || u[a2][t] === null) && (u[a2][t] = {}), u[a2][t][e] = c;
- }
- // eslint-disable-next-line max-lines-per-function
- setRuntimeData(a2) {
- const e = this._currentRow, t = this._currentColumn, r = this._currentRowCount, n = this.currentColumnCount, s = this._currentSubUnitId, o = this._currentUnitId;
- this._runtimeData[o] == null && (this._runtimeData[o] = {});
- const u = this._runtimeData[o];
- u[s] == null && (u[s] = new kt()), this._unitArrayFormulaRange[o] == null && (this._unitArrayFormulaRange[o] = {});
- const c = this._unitArrayFormulaRange[o];
- (c[s] === null || c[s] === void 0) && (c[s] = {});
- const l2 = new kt(c[s]);
- this._runtimeArrayFormulaCellData[o] === void 0 && (this._runtimeArrayFormulaCellData[o] = {});
- const f2 = this._runtimeArrayFormulaCellData[o];
- f2[s] == null && (f2[s] = new kt()), this._runtimeClearArrayFormulaCellData[o] === void 0 && (this._runtimeClearArrayFormulaCellData[o] = {});
- const h = this._runtimeClearArrayFormulaCellData[o];
- h[s] == null && (h[s] = new kt());
- const d2 = u[s], _ = f2[s], C = h[s];
- if (a2.isReferenceObject() || a2.isValueObject() && a2.isArray()) {
- const E2 = a2, { startRow: b, startColumn: R, endRow: p2, endColumn: N2 } = E2.getRangePosition();
- if (b === p2 && R === N2) {
- const w = E2.getFirstCell(), D2 = Gt(w);
- d2.setValue(e, t, D2), C.setValue(e, t, D2);
- return;
- }
- const M2 = {
- startRow: e,
- startColumn: t,
- endRow: p2 - b + e,
- endColumn: N2 - R + t
- };
- if (l2.setValue(e, t, M2), this._checkIfArrayFormulaRangeHasData(o, s, e, t, M2) || this._checkIfArrayFormulaExceeded(r, n, M2)) {
- const w = Gt(g2.create(m2.SPILL));
- d2.setValue(e, t, w), C.setValue(e, t, w);
- const D2 = this._currentConfigService.getUnitData();
- E2.iterator((S2, P, U2) => {
- var ne, z;
- const x2 = P - b + e, F = U2 - R + t, W2 = (z = (ne = D2[o]) == null ? void 0 : ne[s]) == null ? void 0 : z.cellData.getValue(x2, F);
- if (P === b && U2 === R)
- _.setValue(e, t, w);
- else if (W2 != null)
- W2.v == null && (W2.v = ""), _.setValue(x2, F, W2);
- else {
- if (this._isInOtherArrayFormulaRange(o, s, e, t, x2, F))
- return true;
- _.setValue(x2, F, { v: "" });
- }
- });
- } else {
- const w = g2.create(m2.SPILL);
- E2.iterator((D2, S2, P) => {
- const U2 = Gt(D2);
- if (S2 === b && P === R) {
- if (D2 != null && D2.isError() && D2.isEqualType(w))
- return C.setValue(e, t, {}), d2.setValue(e, t, { ...Gt(w) }), false;
- d2.setValue(e, t, { ...U2 });
- }
- const x2 = S2 - b + e, F = P - R + t;
- _.setValue(x2, F, U2);
- });
- }
- } else {
- const E2 = Gt(a2);
- d2.setValue(e, t, E2), C.setValue(e, t, E2);
- }
- }
- getUnitData() {
- return this._runtimeData;
- }
- getUnitArrayFormula() {
- return this._unitArrayFormulaRange;
- }
- getRuntimeOtherData() {
- return this._runtimeOtherData;
- }
- getRuntimeArrayFormulaCellData() {
- return this._runtimeArrayFormulaCellData;
- }
- getRuntimeClearArrayFormulaCellData() {
- return this._runtimeClearArrayFormulaCellData;
- }
- getRuntimeFeatureRange() {
- return this._runtimeFeatureRange;
- }
- setRuntimeFeatureRange(a2, e) {
- this._runtimeFeatureRange[a2] = e;
- }
- getRuntimeFeatureCellData() {
- return this._runtimeFeatureCellData;
- }
- setRuntimeFeatureCellData(a2, e) {
- this._runtimeFeatureCellData[a2] = e;
- }
- getAllRuntimeData() {
- return {
- unitData: this.getUnitData(),
- arrayFormulaRange: this.getUnitArrayFormula(),
- unitOtherData: this.getRuntimeOtherData(),
- functionsExecutedState: this._functionsExecutedState,
- arrayFormulaCellData: this.getRuntimeArrayFormulaCellData(),
- clearArrayFormulaCellData: this.getRuntimeClearArrayFormulaCellData(),
- runtimeFeatureRange: this.getRuntimeFeatureRange(),
- runtimeFeatureCellData: this.getRuntimeFeatureCellData()
- };
- }
- getRuntimeState() {
- return {
- totalFormulasToCalculate: this.getTotalFormulasToCalculate(),
- completedFormulasCount: this.getCompletedFormulasCount(),
- totalArrayFormulasToCalculate: this.getTotalArrayFormulasToCalculate(),
- completedArrayFormulasCount: this.getCompletedArrayFormulasCount(),
- stage: this.getFormulaExecuteStage(),
- formulaCycleIndex: this.getFormulaCycleIndex()
- };
- }
- // eslint-disable-next-line complexity
- _checkIfArrayFormulaRangeHasData(a2, e, t, r, n) {
- var h, d2, _, C, E2, b, R, p2, N2, M2, w;
- const { startRow: s, startColumn: o, endRow: u, endColumn: c } = n, l2 = this._currentConfigService.getUnitData(), f2 = this._currentConfigService.getArrayFormulaCellData();
- (_ = (d2 = (h = this._unitArrayFormulaRange[a2]) == null ? void 0 : h[e]) == null ? void 0 : d2[t]) == null || _[r];
- for (let D2 = s; D2 <= u; D2++)
- for (let S2 = o; S2 <= c; S2++) {
- if (D2 === t && r === S2)
- continue;
- const P = (b = (E2 = (C = this._runtimeData) == null ? void 0 : C[a2]) == null ? void 0 : E2[e]) == null ? void 0 : b.getValue(D2, S2);
- (p2 = (R = f2 == null ? void 0 : f2[a2]) == null ? void 0 : R[e]) == null || p2.getValue(
- D2,
- S2
- );
- const U2 = (w = (M2 = (N2 = l2 == null ? void 0 : l2[a2]) == null ? void 0 : N2[e]) == null ? void 0 : M2.cellData) == null ? void 0 : w.getValue(D2, S2), x2 = this._getRuntimeFeatureCellValue(D2, S2, e, a2);
- if (!nn(P) || this._isInOtherArrayFormulaRange(a2, e, t, r, D2, S2) || !nn(U2) || !nn(x2))
- return true;
- }
- return false;
- }
- _getRuntimeFeatureCellValue(a2, e, t, r) {
- return ao(a2, e, t, r, this._runtimeFeatureCellData);
- }
- _arrayCellHasData(a2) {
- return a2 == null ? false : a2.v !== void 0;
- }
- /**
- * If the current array formula in the extended area intersects with the existing array formula, a #SPILL! error will be reported. Note that if other array formulas are already #SPILL!, they will not conflict with the current array formula
- * @param formulaUnitId
- * @param formulaSheetId
- * @param formulaRow
- * @param formulaColumn
- * @param r
- * @param c
- * @returns
- */
- _isInOtherArrayFormulaRange(a2, e, t, r, n, s) {
- var l2;
- const o = (l2 = this._currentConfigService.getArrayFormulaRange()[a2]) == null ? void 0 : l2[e];
- if (o == null)
- return false;
- let u = false;
- return new kt(o).forValue((f2, h, d2) => {
- var E2, b;
- if (f2 === t && h === r)
- return;
- const _ = this._isInArrayFormulaRange(d2, n, s), C = (b = (E2 = this._runtimeData[a2]) == null ? void 0 : E2[e]) == null ? void 0 : b.getValue(f2, h);
- _ && (C == null ? void 0 : C.v) !== m2.SPILL && (u = true);
- }), u;
- }
- _isInArrayFormulaRange(a2, e, t) {
- if (a2 == null)
- return false;
- const { startRow: r, startColumn: n, endRow: s, endColumn: o } = a2;
- return e >= r && e <= s && t >= n && t <= o;
- }
- _checkIfArrayFormulaExceeded(a2, e, t) {
- return t.endRow >= a2 || t.endColumn >= e;
- }
- _isInDirtyRange(a2, e, t, r) {
- const n = this._currentConfigService.getDirtyRanges();
- return n.length === 0 ? true : zu(n, a2, e, t, r);
- }
- };
- Is = jf([
- Uf(0, Ft)
- ], Is);
- var Nt = Ct("univer.formula.runtime.service");
- var oe = ((i) => (i[i.REFERENCE = 1] = "REFERENCE", i[i.VALUE = 2] = "VALUE", i[i.OPERATOR = 3] = "OPERATOR", i[i.FUNCTION = 4] = "FUNCTION", i[i.LAMBDA = 5] = "LAMBDA", i[i.LAMBDA_PARAMETER = 6] = "LAMBDA_PARAMETER", i[i.ERROR = 7] = "ERROR", i[i.BASE = 8] = "BASE", i[i.ROOT = 9] = "ROOT", i[i.UNION = 10] = "UNION", i[i.PREFIX = 11] = "PREFIX", i[i.SUFFIX = 12] = "SUFFIX", i[i.NULL = 13] = "NULL", i))(oe || {});
- var _t = /* @__PURE__ */ new Map([
- [1, 7],
- [2, 9],
- [3, 8],
- [4, 6],
- [5, 1],
- [6, 2],
- [9, 10],
- [10, 3],
- [11, 4],
- [12, 5]
- ]);
- var Ge = class {
- constructor(a2) {
- A(this, "_children", []);
- A(this, "_definedNames");
- A(this, "_parent");
- A(this, "_valueObject");
- A(this, "_calculateState", false);
- A(this, "_async", false);
- A(this, "_address", false);
- A(this, "_isForcedCalculateFunction", false);
- this._token = a2;
- }
- dispose() {
- var a2;
- this._children.forEach((e) => {
- e.dispose();
- }), (a2 = this._valueObject) == null || a2.dispose(), this._valueObject = null, this._children = [], this._definedNames = null, this._parent = null;
- }
- get nodeType() {
- return oe.BASE;
- }
- isAsync() {
- return this._async;
- }
- isAddress() {
- return this._address;
- }
- isForcedCalculateFunction() {
- return this._isForcedCalculateFunction;
- }
- setAsync() {
- this._async = true;
- }
- setAddress() {
- this._address = true;
- }
- getParent() {
- return this._parent;
- }
- setParent(a2) {
- this._parent = a2, a2.addChildren(this);
- }
- setForcedCalculateFunction() {
- this._isForcedCalculateFunction = true;
- }
- getChildren() {
- return this._children;
- }
- addChildren(...a2) {
- this._children.push(...a2);
- }
- getToken() {
- return this._token;
- }
- setValue(a2) {
- this._valueObject = a2;
- }
- getValue() {
- return this._valueObject;
- }
- isCalculated() {
- return this._calculateState;
- }
- setCalculated() {
- this._calculateState = true;
- }
- execute() {
- }
- setNotEmpty(a2 = true) {
- }
- async executeAsync() {
- return Promise.resolve(xt.SUCCESS);
- }
- serialize() {
- const a2 = this.getToken(), e = this.getChildren(), t = [], r = e.length;
- for (let s = 0; s < r; s++) {
- const o = e[s];
- t.push(o.serialize());
- }
- const n = {
- token: a2,
- nodeType: this.nodeType
- };
- return r > 0 && (n.children = t), n;
- }
- hasDefinedName(a2) {
- var e;
- return ((e = this._definedNames) == null ? void 0 : e.includes(a2)) || false;
- }
- setDefinedNames(a2) {
- this._definedNames = a2;
- }
- getDefinedNames() {
- return this._definedNames;
- }
- };
- var xe = class _xe extends Ge {
- constructor(e) {
- super(e);
- A(this, "_errorValueObject");
- this._errorValueObject = g2.create(e);
- }
- get nodeType() {
- return oe.ERROR;
- }
- static create(e) {
- return new _xe(e);
- }
- getValue() {
- return this._errorValueObject;
- }
- };
- var At = 100;
- var Et = class {
- get zIndex() {
- return 0;
- }
- dispose() {
- }
- create(a2, e, t) {
- let r;
- return a2 instanceof ae ? r = a2.getToken() : r = a2, new Ge(r);
- }
- };
- var Fs = class extends Ge {
- get nodeType() {
- return oe.ROOT;
- }
- execute() {
- const a2 = this.getChildren();
- if (a2.length > 1) {
- this.setValue(g2.create(m2.VALUE));
- return;
- }
- const e = a2[0];
- e == null ? this.setValue(g2.create(m2.VALUE)) : this.setValue(e.getValue());
- }
- };
- var Eo = class extends Et {
- get zIndex() {
- return _t.get(oe.ROOT) || At;
- }
- checkAndCreateNodeType(a2) {
- if (!(a2 instanceof ae))
- return;
- if (a2.getToken() === Ut)
- return new Fs(Ut);
- }
- };
- var Yt = Ct("univer.formula-function.service");
- var vf = class extends nt {
- constructor() {
- super(...arguments);
- A(this, "_functionExecutors", /* @__PURE__ */ new Map());
- A(this, "_functionDescriptions", /* @__PURE__ */ new Map());
- }
- dispose() {
- this._functionExecutors.clear(), this._functionDescriptions.clear();
- }
- registerExecutors(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- this._functionExecutors.set(r.name, r);
- }
- }
- getExecutors() {
- return this._functionExecutors;
- }
- getExecutor(e) {
- return this._functionExecutors.get(e);
- }
- hasExecutor(e) {
- return this._functionExecutors.has(e);
- }
- unregisterExecutors(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- this._functionExecutors.delete(r);
- }
- }
- registerDescriptions(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- this._functionDescriptions.set(r.functionName, r);
- }
- return Ze(() => {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- this._functionDescriptions.delete(r.functionName);
- }
- });
- }
- getDescriptions() {
- return this._functionDescriptions;
- }
- getDescription(e) {
- return this._functionDescriptions.get(e);
- }
- hasDescription(e) {
- return this._functionDescriptions.has(e);
- }
- unregisterDescriptions(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- this._functionDescriptions.delete(r);
- }
- }
- };
- var Te = ((i) => (i.COMPARE = "COMPARE", i.DIVIDED = "DIVIDED", i.MINUS = "MINUS", i.MULTIPLY = "MULTIPLY", i.PLUS = "PLUS", i.UNION = "UNION", i.CUBE = "CUBE", i))(Te || {});
- var Tf = Object.defineProperty;
- var Bf = Object.getOwnPropertyDescriptor;
- var If = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Bf(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Tf(a2, e, r), r;
- };
- var Ei = (i, a2) => (e, t) => a2(e, t, i);
- var _n2 = class extends Ge {
- constructor(a2, e, t) {
- super(e), this._runtimeService = a2, this._operatorString = e, this._functionExecutor = t;
- }
- get nodeType() {
- return oe.PREFIX;
- }
- execute() {
- let e = this.getChildren()[0].getValue(), t;
- if (e == null)
- throw new Error("object is null");
- this._operatorString === Oe.MINUS ? (e.isReferenceObject() && (e = e.toArrayValueObject()), t = this._functionExecutor.calculate(
- y2.create(0),
- e
- )) : this._operatorString === Oe.AT ? t = this._handlerAT(e) : t = g2.create(m2.VALUE), this.setValue(t);
- }
- _handlerAT(a2) {
- if (!a2.isReferenceObject())
- return g2.create(m2.VALUE);
- const e = a2;
- if (e.isCell())
- return g2.create(m2.VALUE);
- const t = this._runtimeService, r = t.currentRow || 0, n = t.currentColumn || 0, s = e.getRangePosition(), { startRow: o, startColumn: u, endRow: c, endColumn: l2 } = s;
- return l2 !== u && c !== o || o === c && u === l2 ? g2.create(m2.VALUE) : c === o && n >= u && n <= l2 ? e.getCellByColumn(n) : u === l2 && r >= o && r <= c ? e.getCellByRow(r) : e.isTable() ? e.getCellByPosition(r) : g2.create(m2.VALUE);
- }
- };
- var An = class extends Et {
- constructor(i, a2) {
- super(), this._functionService = i, this._runtimeService = a2;
- }
- get zIndex() {
- return _t.get(oe.PREFIX) || At;
- }
- checkAndCreateNodeType(i) {
- if (!(i instanceof ae))
- return;
- const a2 = i.getToken(), e = a2.trim();
- if (e.charAt(0) === '"' && e.charAt(e.length - 1) === '"')
- return;
- let t = "";
- if (e === Oe.MINUS)
- t = Te.MINUS;
- else
- return e === Oe.AT ? new _n2(this._runtimeService, e) : void 0;
- const r = this._functionService.getExecutor(t);
- return r ? new _n2(this._runtimeService, e, r) : (console.error(`No function ${a2}`), xe.create(m2.NAME));
- }
- };
- An = If([
- Ei(0, Yt),
- Ei(1, Nt)
- ], An);
- new RegExp(Oe.MINUS, "g");
- new RegExp(Oe.AT, "g");
- function bo(i, a2, e) {
- let t, r, n = i;
- const s = n.slice(0, 2);
- let o = 0;
- if (s[0] === Oe.MINUS) {
- const u = a2.getExecutor(Te.MINUS);
- t = new _n2(e, Oe.MINUS, u), o++;
- }
- return s[0] === Oe.AT && (r = new _n2(e, Oe.AT), t && r.setParent(t), o++), o > 0 && (n = n.slice(o)), { tokenTrim: n, minusPrefixNode: t, atPrefixNode: r };
- }
- var Ff = Object.defineProperty;
- var kf = Object.getOwnPropertyDescriptor;
- var $f = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? kf(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Ff(a2, e, r), r;
- };
- var ir = (i, a2) => (e, t) => a2(e, t, i);
- var Yf = class extends Ge {
- constructor(a2, e, t, r, n, s) {
- super(a2), this._functionExecutor = e, this._currentConfigService = t, this._runtimeService = r, this._definedNamesService = n, this._formulaDataModel = s, this._functionExecutor.isAsync() && this.setAsync(), this._functionExecutor.isAddress() && this.setAddress(), this._functionExecutor.needsLocale && this._setLocale(), this._functionExecutor.needsSheetsInfo && this._setSheetsInfo(), this._functionExecutor.needsFormulaDataModel && this._functionExecutor.setFormulaDataModel(this._formulaDataModel);
- }
- get nodeType() {
- return oe.FUNCTION;
- }
- async executeAsync() {
- const a2 = [], e = this.getChildren(), t = e.length;
- this._compatibility();
- for (let s = 0; s < t; s++) {
- const u = e[s].getValue();
- u != null && (u.isReferenceObject() && !this._functionExecutor.needsReferenceObject ? a2.push(u.toArrayValueObject()) : a2.push(u));
- }
- const r = await this._calculateAsync(a2);
- let n;
- return r.isAsyncObject() || r.isAsyncArrayObject() ? n = await r.getValue() : n = r, this._setRefData(n), this.setValue(n), Promise.resolve(xt.SUCCESS);
- }
- execute() {
- const a2 = [], e = this.getChildren(), t = e.length;
- this._compatibility();
- for (let n = 0; n < t; n++) {
- const o = e[n].getValue();
- o != null && (o.isReferenceObject() && !this._functionExecutor.needsReferenceObject ? a2.push(o.toArrayValueObject()) : a2.push(o));
- }
- const r = this._calculate(a2);
- this._setRefData(r), this.setValue(r);
- }
- /**
- * Compatibility handling for special functions.
- */
- _compatibility() {
- this._lookupCompatibility();
- }
- /**
- * The LOOKUP function follows the following rules when dealing with vectors of different sizes:
- * If the lookup_vector is larger than the result_vector,
- * the LOOKUP function will ignore the extra portion of the lookup_vector and only use the portion of the result_vector that is the same size as the lookup_vector for lookup and returning results.
- * If the lookup_vector is smaller than the result_vector,
- * the LOOKUP function will continue using the last value of the result_vector for lookup and returning results after the last value of the lookup_vector.
- */
- _lookupCompatibility() {
- const a2 = this.getChildren(), e = a2.length;
- if (!this._functionExecutor.needsExpandParams || e !== 3)
- return;
- const t = a2[1].getValue(), r = a2[2].getValue();
- if (!(t != null && t.isReferenceObject()) && !(r != null && r.isReferenceObject()))
- return;
- let n, s;
- if (t != null && t.isReferenceObject()) {
- const _ = t.getRangeData(), { startRow: C, startColumn: E2, endRow: b, endColumn: R } = _;
- n = b - C + 1, s = R - E2 + 1;
- } else
- n = t != null && t.isArray() ? t.getRowCount() : 1, s = t != null && t.isArray() ? t.getColumnCount() : 1;
- const o = r.getRangeData(), { startRow: u, startColumn: c, endRow: l2, endColumn: f2 } = o, h = l2 - u + 1, d2 = f2 - c + 1;
- n !== h && (o.endRow += n - h), s !== d2 && (o.endColumn += s - d2);
- }
- /**
- * Transform the result of a custom function to a NodeValueType.
- */
- _handleCustomResult(a2) {
- var t;
- if (typeof a2 != "object" || a2 == null)
- return pt.create(a2);
- const e = Ao(a2);
- return q2.create({
- calculateValueList: e,
- rowCount: e.length,
- columnCount: ((t = e[0]) == null ? void 0 : t.length) || 0,
- unitId: "",
- sheetId: "",
- row: -1,
- column: -1
- });
- }
- _handleAddressFunction() {
- this._functionExecutor.isAddress() && this._setDefinedNamesForFunction();
- }
- _mapVariantsToValues(a2) {
- return a2.map((e) => e.isArray() ? e.toValue() : e.isLambda() ? e : e.getValue());
- }
- _calculate(a2) {
- const { minParams: e, maxParams: t } = this._functionExecutor;
- if (e !== -1 && t !== -1 && (a2.length < e || a2.length > t))
- return g2.create(m2.NA);
- let r;
- if (this._setRefInfo(), this._functionExecutor.isCustom()) {
- const n = this._functionExecutor.calculateCustom(
- ...this._mapVariantsToValues(a2)
- );
- r = this._handleCustomResult(n);
- } else
- this._handleAddressFunction(), r = this._functionExecutor.calculate(...a2);
- return r;
- }
- async _calculateAsync(a2) {
- const { minParams: e, maxParams: t } = this._functionExecutor;
- if (e !== -1 && t !== -1 && (a2.length < e || a2.length > t))
- return g2.create(m2.NA);
- let r;
- if (this._setRefInfo(), this._functionExecutor.isCustom()) {
- const n = await this._functionExecutor.calculateCustom(
- ...this._mapVariantsToValues(a2)
- );
- r = this._handleCustomResult(n);
- } else
- this._handleAddressFunction(), r = this._functionExecutor.calculate(...a2);
- return r;
- }
- _setDefinedNamesForFunction() {
- const a2 = this._currentConfigService.getExecuteUnitId();
- if (a2 == null)
- return;
- const e = this._definedNamesService.getDefinedNameMap(a2);
- e != null && this._functionExecutor.setDefinedNames(e);
- }
- _setRefInfo() {
- const { currentUnitId: a2, currentSubUnitId: e, currentRow: t, currentColumn: r } = this._runtimeService;
- if (this._functionExecutor.setRefInfo(a2, e, t, r), this._functionExecutor.needsSheetRowColumnCount) {
- const { rowCount: n, columnCount: s } = this._currentConfigService.getSheetRowColumnCount(a2, e);
- this._functionExecutor.setSheetRowColumnCount(n, s);
- }
- }
- _setRefData(a2) {
- if (!a2.isReferenceObject())
- return;
- const e = a2;
- e.setForcedSheetId(this._currentConfigService.getSheetNameMap()), e.setUnitData(this._currentConfigService.getUnitData()), e.setArrayFormulaCellData(this._currentConfigService.getArrayFormulaCellData()), e.setRuntimeData(this._runtimeService.getUnitData()), e.setRuntimeArrayFormulaCellData(this._runtimeService.getRuntimeArrayFormulaCellData()), e.setRuntimeFeatureCellData(this._runtimeService.getRuntimeFeatureCellData());
- }
- _setLocale() {
- this._functionExecutor.setLocale(this._currentConfigService.getLocale());
- }
- _setSheetsInfo() {
- this._functionExecutor.setSheetsInfo(this._currentConfigService.getSheetsInfo());
- }
- };
- var Hf = class extends Ge {
- constructor(a2 = "Error") {
- super(a2);
- }
- get nodeType() {
- return oe.FUNCTION;
- }
- async executeAsync() {
- return this.setValue(g2.create(m2.NAME)), Promise.resolve(xt.SUCCESS);
- }
- execute() {
- this.setValue(g2.create(m2.NAME));
- }
- };
- var En = class extends Et {
- constructor(i, a2, e, t, r, n) {
- super(), this._functionService = i, this._currentConfigService = a2, this._runtimeService = e, this._definedNamesService = t, this._injector = r, this._formulaDataModel = n;
- }
- get zIndex() {
- return _t.get(oe.FUNCTION) || At;
- }
- create(i) {
- const a2 = this._functionService.getExecutor(i);
- return a2 ? new Yf(
- i,
- a2,
- this._currentConfigService,
- this._runtimeService,
- this._definedNamesService,
- this._formulaDataModel
- ) : (console.error(`No function ${i}`), xe.create(m2.NAME));
- }
- checkAndCreateNodeType(i) {
- if (typeof i == "string")
- return;
- const a2 = i.getToken(), { tokenTrim: e, minusPrefixNode: t, atPrefixNode: r } = bo(a2.trim(), this._functionService, this._runtimeService);
- if (!Number.isNaN(Number(e)) && !this._isParentUnionNode(i))
- return xe.create(m2.VALUE);
- const n = e.toUpperCase();
- if (this._functionService.hasExecutor(n)) {
- const s = this.create(n);
- return r ? s.setParent(r) : t && s.setParent(t), s;
- }
- }
- _isParentUnionNode(i) {
- var a2, e;
- return ((e = (a2 = i.getParent()) == null ? void 0 : a2.getParent()) == null ? void 0 : e.getToken()) === K2.COLON;
- }
- };
- En = $f([
- ir(0, Yt),
- ir(1, Ft),
- ir(2, Nt),
- ir(3, pr),
- ir(4, ot(Ot)),
- ir(5, ot(Pr))
- ], En);
- var Gf = Object.defineProperty;
- var Qf = Object.getOwnPropertyDescriptor;
- var Wf = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Qf(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Gf(a2, e, r), r;
- };
- var qf = (i, a2) => (e, t) => a2(e, t, i);
- var Cr = class extends nt {
- constructor(i) {
- super(), this._runtimeService = i;
- }
- async executeAsync(i) {
- if (!i || !i.node)
- return Promise.resolve(g2.create(m2.VALUE));
- const a2 = i.node, e = i.refOffsetX, t = i.refOffsetY;
- await this._executeAsync(a2, e, t);
- const r = a2.getValue();
- return r == null ? Promise.resolve(g2.create(m2.VALUE)) : Promise.resolve(r);
- }
- execute(i) {
- if (!i || !i.node)
- return g2.create(m2.VALUE);
- const a2 = i.node, e = i.refOffsetX, t = i.refOffsetY;
- this._execute(a2, e, t);
- const r = a2.getValue();
- return r == null ? g2.create(m2.VALUE) : r;
- }
- executePreCalculateNode(i) {
- return i.execute(), i.getValue();
- }
- checkAsyncNode(i) {
- if (i == null)
- return false;
- const a2 = [];
- this._checkAsyncNode(i, a2);
- for (let e = 0, t = a2.length; e < t; e++)
- if (a2[e] === true)
- return true;
- return false;
- }
- _checkAsyncNode(i, a2) {
- const e = i.getChildren(), t = e.length;
- for (let r = 0; r < t; r++) {
- const n = e[r];
- a2.push(n.isAsync()), this._checkAsyncNode(n, a2);
- }
- }
- async _executeAsync(i, a2 = 0, e = 0) {
- if (this._runtimeService.isStopExecution())
- return Promise.resolve(xt.ERROR);
- const t = i.getChildren(), r = t.length;
- for (let n = 0; n < r; n++) {
- const s = t[n];
- if (s.getToken().toUpperCase() === Sr && s.isEmptyParamFunction()) {
- s.execute();
- continue;
- }
- await this._executeAsync(s, a2, e);
- }
- return i.nodeType === oe.REFERENCE && i.setRefOffset(a2, e), i.nodeType === oe.FUNCTION && i.isAsync() ? await i.executeAsync() : i.execute(), Promise.resolve(xt.SUCCESS);
- }
- _execute(i, a2 = 0, e = 0) {
- if (this._runtimeService.isStopExecution())
- return xt.ERROR;
- const t = i.getChildren(), r = t.length;
- for (let n = 0; n < r; n++) {
- const s = t[n];
- if (s.getToken().toUpperCase() === Sr && s.isEmptyParamFunction()) {
- s.execute();
- continue;
- }
- this._execute(s, a2, e);
- }
- return i.nodeType === oe.REFERENCE && i.setRefOffset(a2, e), i.execute(), xt.SUCCESS;
- }
- };
- Cr = Wf([
- qf(0, Nt)
- ], Cr);
- function yo(i) {
- return i instanceof ae ? i.getToken() === hr : false;
- }
- function Kf(i) {
- return i instanceof ae ? i.getToken() === ro : false;
- }
- function Ea(i, a2, e) {
- const t = i.getChildren(), r = t.length, n = t[0];
- for (let s = 0; s < r; s++) {
- const o = t[s];
- if (!(yo(n) && s !== 0))
- if (o instanceof ae)
- Ea(o, a2, e);
- else {
- const u = o.trim();
- if (e.has(u)) {
- const c = new ae();
- c.setToken(Tr), c.setLambdaId(a2), c.setLambdaPrivacyVar(e), c.setLambdaParameter(u), t[s] = c;
- }
- }
- }
- }
- function Xf(i) {
- let a2 = i;
- for (; a2 != null && a2.getParent(); )
- a2 = a2.getParent();
- return a2;
- }
- function bi(i, a2 = 0, e = 0) {
- return {
- node: i,
- refOffsetX: a2,
- refOffsetY: e
- };
- }
- function Ro(i) {
- if (!i)
- return;
- if (i.getToken() !== Tr)
- return i;
- const a2 = i, e = a2.getCurrentLambdaPrivacyVar(), t = a2.getLambdaParameter();
- if (!e)
- return;
- const r = e.get(t);
- return r == null && i.getValue() ? i : Ro(r);
- }
- var ba = class _ba extends kt2 {
- constructor(e, t, r) {
- super(0);
- A(this, "_lambdaPrivacyValueMap", /* @__PURE__ */ new Map());
- this._lambdaNode = e, this._interpreter = t, this._lambdaPrivacyVarKeys = r, this._lambdaPrivacyValueMap.clear();
- }
- static create(e, t, r) {
- return new _ba(e, t, r);
- }
- dispose() {
- this._lambdaPrivacyValueMap.clear(), this._lambdaPrivacyValueMap = /* @__PURE__ */ new Map(), this._lambdaNode = null, this._interpreter = null, this._lambdaPrivacyVarKeys = [];
- }
- isLambda() {
- return true;
- }
- execute(...e) {
- const t = this._lambdaPrivacyVarKeys.length;
- if (e.length !== t || !this._interpreter || !this._lambdaNode)
- return g2.create(m2.VALUE);
- this._setLambdaPrivacyValueMap(e), this._setLambdaNodeValue(this._lambdaNode), this._lambdaNode.setNotEmpty(false);
- let r;
- if (this._interpreter.checkAsyncNode(this._lambdaNode))
- r = new Nf(this._interpreter.executeAsync(bi(this._lambdaNode)));
- else {
- const n = this._interpreter.execute(bi(this._lambdaNode));
- n.isReferenceObject() ? r = n.toArrayValueObject() : r = n;
- }
- return this._lambdaNode.setNotEmpty(true), r;
- }
- /**
- * Execute custom lambda function, handle basic types
- * @param variants
- */
- executeCustom(...e) {
- const t = e.map((r) => pt.create(r));
- return this.execute(...t);
- }
- _setLambdaNodeValue(e) {
- if (!e)
- return;
- const t = e.getChildren(), r = t.length;
- for (let n = 0; n < r; n++) {
- const s = t[n];
- if (s.getToken() === Tr) {
- const u = s.getLambdaParameter(), c = this._lambdaPrivacyValueMap.get(u);
- if (c)
- s.setValue(c);
- else {
- const l2 = s.getCurrentLambdaPrivacyVar(), f2 = Ro(l2.get(u));
- f2 != null && s.setValue(f2.getValue());
- }
- continue;
- }
- this._setLambdaNodeValue(s);
- }
- }
- _setLambdaPrivacyValueMap(e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t], n = this._lambdaPrivacyVarKeys[t];
- this._lambdaPrivacyValueMap.set(n, r);
- }
- }
- getLambdaPrivacyVarKeys() {
- return this._lambdaPrivacyVarKeys;
- }
- };
- var Zf = Object.defineProperty;
- var zf = Object.getOwnPropertyDescriptor;
- var Jf = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? zf(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Zf(a2, e, r), r;
- };
- var yi = (i, a2) => (e, t) => a2(e, t, i);
- var eh = class extends Ge {
- constructor(e, t, r, n) {
- super(e);
- A(this, "_isNotEmpty", true);
- this._lambdaId = t, this._interpreter = r, this._lambdaPrivacyVarKeys = n;
- }
- get nodeType() {
- return oe.LAMBDA;
- }
- setNotEmpty(e = false) {
- this._isNotEmpty = e;
- }
- isEmptyParamFunction() {
- return this.getChildren().length < 2 && this._isNotEmpty;
- }
- isFunctionParameter() {
- return this._lambdaId === null;
- }
- getLambdaId() {
- return this._lambdaId;
- }
- execute() {
- if (this.isEmptyParamFunction())
- this.setValue(ba.create(this, this._interpreter, this._lambdaPrivacyVarKeys));
- else {
- const e = this.getChildren(), t = e.length;
- this.setValue(e[t - 1].getValue());
- }
- }
- // override async executeAsync() {
- // if (this.isEmptyParamFunction()) {
- // await this.setValue(LambdaValueObjectObject.create(this, this._interpreter, this._lambdaPrivacyVarKeys));
- // } else {
- // const children = this.getChildren();
- // const childrenCount = children.length;
- // await this.setValue(children[childrenCount - 1].getValue());
- // }
- // return Promise.resolve(AstNodePromiseType.SUCCESS);
- // }
- };
- var bn = class extends Et {
- constructor(i, a2) {
- super(), this._runtimeService = i, this._interpreter = a2;
- }
- get zIndex() {
- return _t.get(oe.LAMBDA) || At;
- }
- create(i) {
- const a2 = i.getChildren(), e = a2[0];
- let t = a2.slice(1, -1);
- const r = a2[a2.length - 1];
- if (!(e instanceof ae && r instanceof ae))
- return xe.create(m2.NAME);
- if (e.getToken() === hr) {
- const o = e.getChildren();
- if (t.length !== o.length)
- return xe.create(m2.VALUE);
- } else
- t = a2.slice(0, -1);
- const n = re.generateRandomId(8), s = /* @__PURE__ */ new Map();
- for (let o = 0; o < t.length; o++) {
- const u = t[o];
- if (u instanceof ae) {
- const c = u.getChildren()[0];
- u.setToken(ro), s.set(c.trim(), void 0);
- } else
- return xe.create(m2.VALUE);
- }
- return this._runtimeService.registerFunctionDefinitionPrivacyVar(n, s), this._updateLambdaStatement(r, n, s), new eh(i.getToken(), n, this._interpreter, [...s.keys()]);
- }
- checkAndCreateNodeType(i) {
- if (!(!(i instanceof ae) || i.getToken().trim().toUpperCase() !== Sr))
- return this.create(i);
- }
- _updateLambdaStatement(i, a2, e) {
- Ea(i, a2, e);
- }
- };
- bn = Jf([
- yi(0, Nt),
- yi(1, ot(Cr))
- ], bn);
- function po(i) {
- if (!i)
- return;
- if (i.getToken() !== Tr)
- return i;
- const a2 = i, e = a2.getCurrentLambdaPrivacyVar(), t = a2.getLambdaParameter();
- if (e)
- return po(e.get(t));
- }
- var th = class extends Ge {
- constructor(a2, e, t) {
- super(a2), this._lambdaParameter = e, this._currentLambdaPrivacyVar = t;
- }
- getLambdaParameter() {
- return this._lambdaParameter;
- }
- getCurrentLambdaPrivacyVar() {
- return this._currentLambdaPrivacyVar;
- }
- get nodeType() {
- return oe.LAMBDA_PARAMETER;
- }
- execute() {
- const a2 = po(this._currentLambdaPrivacyVar.get(this._lambdaParameter));
- if (a2)
- this.setValue(a2.getValue());
- else {
- const e = this.getValue();
- (e == null || e.isError()) && this.setValue(g2.create(m2.NAME));
- }
- }
- };
- var Vo = class extends Et {
- get zIndex() {
- return _t.get(oe.LAMBDA_PARAMETER) || At;
- }
- create(a2) {
- const e = a2.getFunctionDefinitionPrivacyVar(), t = a2.getLambdaParameter();
- return e ? new th(a2.getToken(), t, e) : new xe(m2.NAME);
- }
- checkAndCreateNodeType(a2) {
- if (!(!(a2 instanceof ae) || a2.getToken().trim() !== Tr))
- return this.create(a2);
- }
- };
- var rh = class extends Ge {
- constructor(a2) {
- super(a2), this._operatorString = a2;
- }
- get nodeType() {
- return oe.NULL;
- }
- execute() {
- this.setValue(ie.create());
- }
- };
- var Y2 = ((i) => (i.ABS = "ABS", i.ACOS = "ACOS", i.ACOSH = "ACOSH", i.ACOT = "ACOT", i.ACOTH = "ACOTH", i.AGGREGATE = "AGGREGATE", i.ARABIC = "ARABIC", i.ASIN = "ASIN", i.ASINH = "ASINH", i.ATAN = "ATAN", i.ATAN2 = "ATAN2", i.ATANH = "ATANH", i.BASE = "BASE", i.CEILING = "CEILING", i.CEILING_MATH = "CEILING.MATH", i.CEILING_PRECISE = "CEILING.PRECISE", i.COMBIN = "COMBIN", i.COMBINA = "COMBINA", i.COS = "COS", i.COSH = "COSH", i.COT = "COT", i.COTH = "COTH", i.CSC = "CSC", i.CSCH = "CSCH", i.DECIMAL = "DECIMAL", i.DEGREES = "DEGREES", i.EVEN = "EVEN", i.EXP = "EXP", i.FACT = "FACT", i.FACTDOUBLE = "FACTDOUBLE", i.FLOOR = "FLOOR", i.FLOOR_MATH = "FLOOR.MATH", i.FLOOR_PRECISE = "FLOOR.PRECISE", i.GCD = "GCD", i.INT = "INT", i.ISO_CEILING = "ISO.CEILING", i.LCM = "LCM", i.LET = "LET", i.LN = "LN", i.LOG = "LOG", i.LOG10 = "LOG10", i.MDETERM = "MDETERM", i.MINVERSE = "MINVERSE", i.MMULT = "MMULT", i.MOD = "MOD", i.MROUND = "MROUND", i.MULTINOMIAL = "MULTINOMIAL", i.MUNIT = "MUNIT", i.ODD = "ODD", i.PI = "PI", i.POWER = "POWER", i.PRODUCT = "PRODUCT", i.QUOTIENT = "QUOTIENT", i.RADIANS = "RADIANS", i.RAND = "RAND", i.RANDARRAY = "RANDARRAY", i.RANDBETWEEN = "RANDBETWEEN", i.ROMAN = "ROMAN", i.ROUND = "ROUND", i.ROUNDBANK = "ROUNDBANK", i.ROUNDDOWN = "ROUNDDOWN", i.ROUNDUP = "ROUNDUP", i.SEC = "SEC", i.SECH = "SECH", i.SERIESSUM = "SERIESSUM", i.SEQUENCE = "SEQUENCE", i.SIGN = "SIGN", i.SIN = "SIN", i.SINH = "SINH", i.SQRT = "SQRT", i.SQRTPI = "SQRTPI", i.SUBTOTAL = "SUBTOTAL", i.SUM = "SUM", i.SUMIF = "SUMIF", i.SUMIFS = "SUMIFS", i.SUMPRODUCT = "SUMPRODUCT", i.SUMSQ = "SUMSQ", i.SUMX2MY2 = "SUMX2MY2", i.SUMX2PY2 = "SUMX2PY2", i.SUMXMY2 = "SUMXMY2", i.TAN = "TAN", i.TANH = "TANH", i.TRUNC = "TRUNC", i))(Y2 || {});
- var se = ((i) => (i.ASC = "ASC", i.ARRAYTOTEXT = "ARRAYTOTEXT", i.BAHTTEXT = "BAHTTEXT", i.CHAR = "CHAR", i.CLEAN = "CLEAN", i.CODE = "CODE", i.CONCAT = "CONCAT", i.CONCATENATE = "CONCATENATE", i.DBCS = "DBCS", i.DOLLAR = "DOLLAR", i.EXACT = "EXACT", i.FIND = "FIND", i.FINDB = "FINDB", i.FIXED = "FIXED", i.LEFT = "LEFT", i.LEFTB = "LEFTB", i.LEN = "LEN", i.LENB = "LENB", i.LOWER = "LOWER", i.MID = "MID", i.MIDB = "MIDB", i.NUMBERVALUE = "NUMBERVALUE", i.PHONETIC = "PHONETIC", i.PROPER = "PROPER", i.REGEXEXTRACT = "REGEXEXTRACT", i.REGEXMATCH = "REGEXMATCH", i.REGEXREPLACE = "REGEXREPLACE", i.REPLACE = "REPLACE", i.REPLACEB = "REPLACEB", i.REPT = "REPT", i.RIGHT = "RIGHT", i.RIGHTB = "RIGHTB", i.SEARCH = "SEARCH", i.SEARCHB = "SEARCHB", i.SUBSTITUTE = "SUBSTITUTE", i.T = "T", i.TEXT = "TEXT", i.TEXTAFTER = "TEXTAFTER", i.TEXTBEFORE = "TEXTBEFORE", i.TEXTJOIN = "TEXTJOIN", i.TEXTSPLIT = "TEXTSPLIT", i.TRIM = "TRIM", i.UNICHAR = "UNICHAR", i.UNICODE = "UNICODE", i.UPPER = "UPPER", i.VALUE = "VALUE", i.VALUETOTEXT = "VALUETOTEXT", i.CALL = "CALL", i.EUROCONVERT = "EUROCONVERT", i.REGISTER_ID = "REGISTER.ID", i))(se || {});
- var nh = Object.defineProperty;
- var sh = Object.getOwnPropertyDescriptor;
- var ah = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? sh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && nh(a2, e, r), r;
- };
- var ih = (i, a2) => (e, t) => a2(e, t, i);
- var oh = class extends Ge {
- constructor(a2, e) {
- super(a2), this._functionExecutor = e;
- }
- get nodeType() {
- return oe.OPERATOR;
- }
- execute() {
- const a2 = this.getChildren();
- this._functionExecutor.name === Te.COMPARE && this._functionExecutor.setCompareType(this.getToken());
- const e = a2[0], t = a2[1];
- let r = e == null ? void 0 : e.getValue(), n = t == null ? void 0 : t.getValue();
- const s = this.getToken();
- if ((r == null || n == null) && s !== X2.MINUS && s !== X2.PLUS) {
- this.setValue(g2.create(m2.VALUE));
- return;
- }
- r == null && (r = ie.create()), n == null && (n = ie.create()), r.isReferenceObject() && (r = r.toArrayValueObject()), n.isReferenceObject() && (n = n.toArrayValueObject()), this.setValue(
- this._functionExecutor.calculate(
- r,
- n
- )
- );
- }
- };
- var yn = class extends Et {
- constructor(i) {
- super(), this._functionService = i;
- }
- get zIndex() {
- return _t.get(oe.OPERATOR) || At;
- }
- create(i) {
- let a2 = "";
- const e = i;
- e === X2.PLUS ? a2 = Te.PLUS : e === X2.MINUS ? a2 = Te.MINUS : e === X2.MULTIPLY ? a2 = Te.MULTIPLY : e === X2.DIVIDED ? a2 = Te.DIVIDED : e === X2.CONCATENATE ? a2 = se.CONCATENATE : e === X2.POWER ? a2 = Y2.POWER : ec.has(e) && (a2 = Te.COMPARE);
- const t = this._functionService.getExecutor(a2);
- return t ? new oh(e, t) : (console.error(`No function ${i}`), xe.create(m2.NAME));
- }
- checkAndCreateNodeType(i) {
- if (i instanceof ae)
- return;
- const a2 = i.trim();
- if (!(a2.charAt(0) === '"' && a2.charAt(a2.length - 1) === '"') && Dt.has(a2))
- return this.create(a2);
- }
- };
- yn = ah([
- ih(0, Yt)
- ], yn);
- var uh = Object.defineProperty;
- var ch = Object.getOwnPropertyDescriptor;
- var lh = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? ch(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && uh(a2, e, r), r;
- };
- var cs = (i, a2) => (e, t) => a2(e, t, i);
- var ls = class extends Ge {
- constructor(e, t, r, n, s = false) {
- super(r);
- A(this, "_refOffsetX", 0);
- A(this, "_refOffsetY", 0);
- this._currentConfigService = e, this._runtimeService = t, this._referenceObjectType = n, this._isPrepareMerge = s;
- }
- get nodeType() {
- return oe.REFERENCE;
- }
- execute() {
- const e = this._currentConfigService, t = this._runtimeService, r = Sf(this.getToken(), this._referenceObjectType);
- r.setDefaultUnitId(t.currentUnitId), r.setDefaultSheetId(t.currentSubUnitId), r.setForcedSheetId(e.getSheetNameMap()), r.setUnitData(e.getUnitData()), r.setArrayFormulaCellData(e.getArrayFormulaCellData()), r.setRuntimeData(t.getUnitData()), r.setUnitStylesData(e.getUnitStylesData()), r.setRuntimeArrayFormulaCellData(t.getRuntimeArrayFormulaCellData()), r.setRuntimeFeatureCellData(t.getRuntimeFeatureCellData());
- const { x: n, y: s } = this.getRefOffset();
- r.setRefOffset(n, s), !this._isPrepareMerge && r.isExceedRange() ? this.setValue(g2.create(m2.NAME)) : this.setValue(r);
- }
- setRefOffset(e = 0, t = 0) {
- this._refOffsetX = e, this._refOffsetY = t;
- }
- getRefOffset() {
- return {
- x: this._refOffsetX,
- y: this._refOffsetY
- };
- }
- };
- var Rn = class extends Et {
- constructor(i, a2, e) {
- super(), this._currentConfigService = i, this._formulaRuntimeService = a2, this._functionService = e;
- }
- get zIndex() {
- return _t.get(oe.REFERENCE) || At;
- }
- checkAndCreateNodeType(i) {
- var l2, f2;
- let a2 = false, e, t = false;
- i instanceof ae ? (a2 = true, e = i.getToken().trim(), ((f2 = (l2 = i.getParent()) == null ? void 0 : l2.getParent()) == null ? void 0 : f2.getToken().trim()) === K2.COLON && (t = true)) : e = i.trim();
- const r = this._currentConfigService, n = this._formulaRuntimeService, { tokenTrim: s, minusPrefixNode: o, atPrefixNode: u } = bo(e, this._functionService, n);
- if (!a2 && s.charAt(0) === '"' && s.charAt(s.length - 1) === '"')
- return;
- let c;
- if (vr(s) ? c = new ls(r, n, s, an.CELL, t) : a2 && this._checkParentIsUnionOperator(i) && (Qi(s) ? c = new ls(r, n, s, an.ROW, t) : Wi(s) && (c = new ls(r, n, s, an.COLUMN, t))), c)
- return u ? c.setParent(u) : o && c.setParent(o), c;
- }
- _checkParentIsUnionOperator(i) {
- var a2, e;
- return ((e = (a2 = i.getParent()) == null ? void 0 : a2.getParent()) == null ? void 0 : e.getToken().trim()) === K2.COLON;
- }
- };
- Rn = lh([
- cs(0, Ft),
- cs(1, Nt),
- cs(2, Yt)
- ], Rn);
- var fh = Object.defineProperty;
- var hh = Object.getOwnPropertyDescriptor;
- var mh = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? hh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && fh(a2, e, r), r;
- };
- var fs = (i, a2) => (e, t) => a2(e, t, i);
- var Ri = class extends Ge {
- constructor(a2, e, t, r) {
- super(t), this._currentConfigService = a2, this._lexer = e, this._operatorString = t, this._functionExecutor = r;
- }
- get nodeType() {
- return oe.SUFFIX;
- }
- execute() {
- let e = this.getChildren()[0].getValue(), t;
- if (e == null)
- throw new Error("object is null");
- if (this._operatorString === ze.PERCENTAGE) {
- if (e.isReferenceObject() && (e = e.toArrayValueObject()), t = this._functionExecutor.calculate(
- e,
- y2.create(100)
- ), t.isNumber()) {
- const r = Number(t.getValue());
- t = y2.create(r, "0.00%");
- }
- } else
- this._operatorString === ze.POUND ? t = this._handlerPound(e) : t = g2.create(m2.VALUE);
- this.setValue(t);
- }
- _handlerPound(a2) {
- var u, c, l2, f2;
- if (!a2.isReferenceObject() || !a2.isCell())
- return g2.create(m2.VALUE);
- const e = a2, t = e.getRangePosition(), r = e.getUnitId(), n = e.getSheetId(), s = this._currentConfigService.getFormulaData(), o = (f2 = (l2 = (c = (u = s == null ? void 0 : s[r]) == null ? void 0 : u[n]) == null ? void 0 : c[t.startRow]) == null ? void 0 : l2[t.startColumn]) == null ? void 0 : f2.f;
- return o && this._lexer.treeBuilder(o), g2.create(m2.VALUE);
- }
- };
- var pn = class extends Et {
- constructor(i, a2, e) {
- super(), this._functionService = i, this._lexer = a2, this._currentConfigService = e;
- }
- get zIndex() {
- return _t.get(oe.SUFFIX) || At;
- }
- checkAndCreateNodeType(i) {
- if (!(i instanceof ae))
- return;
- const a2 = i.getToken().trim();
- if (a2.charAt(0) === '"' && a2.charAt(a2.length - 1) === '"')
- return;
- let e = "";
- if (a2 === ze.PERCENTAGE)
- e = Te.DIVIDED;
- else
- return a2 === ze.POUND ? new Ri(this._currentConfigService, this._lexer, a2) : void 0;
- const t = this._functionService.getExecutor(e);
- return t ? new Ri(this._currentConfigService, this._lexer, a2, t) : (console.error(`No function ${i}`), xe.create(m2.NAME));
- }
- };
- pn = mh([
- fs(0, Yt),
- fs(1, ot(gr)),
- fs(2, Ft)
- ], pn);
- var gh = Object.defineProperty;
- var dh = Object.getOwnPropertyDescriptor;
- var Ch = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? dh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && gh(a2, e, r), r;
- };
- var _h = (i, a2) => (e, t) => a2(e, t, i);
- var Ah = class extends Ge {
- constructor(a2) {
- super(a2);
- }
- get nodeType() {
- return oe.UNION;
- }
- execute() {
- const a2 = this.getChildren(), e = a2[0], t = a2[1], r = e.getValue(), n = t.getValue();
- if (r == null || n == null)
- throw new Error("leftNode and rightNode");
- let s;
- this.getToken() === K2.COLON ? s = this._unionFunction(r, n) : s = g2.create(m2.NAME), this.setValue(s);
- }
- _unionFunction(a2, e) {
- return a2.isError() || e.isError() || !a2.isReferenceObject() || !e.isReferenceObject() ? g2.create(m2.REF) : (a2 = a2, e = e, Pf(a2, e));
- }
- };
- var Vn = class extends Et {
- constructor(i) {
- super(), this._functionService = i;
- }
- get zIndex() {
- return _t.get(oe.UNION) || At;
- }
- create(i) {
- return new Ah(i);
- }
- checkAndCreateNodeType(i) {
- if (!(i instanceof ae))
- return;
- const e = i.getToken().trim();
- if (!(e.charAt(0) === '"' && e.charAt(e.length - 1) === '"') && e === K2.COLON)
- return this.create(e);
- }
- };
- Vn = Ch([
- _h(0, Yt)
- ], Vn);
- var Eh = class extends Ge {
- constructor(a2) {
- super(a2);
- }
- get nodeType() {
- return oe.VALUE;
- }
- execute() {
- this.setValue(pt.create(this.getToken()));
- }
- };
- var No = class extends Et {
- get zIndex() {
- return _t.get(oe.VALUE) || At;
- }
- _checkValueNode(a2) {
- if (Number.isNaN(Number(a2))) {
- const e = a2.trim(), t = e.charAt(0), r = e.charAt(e.length - 1);
- if (yr.has(e))
- return this.create(e);
- if (t === '"' && r === '"')
- return this.create(e);
- if (t === "{" && r === "}")
- return this.create(e);
- const n = e.toUpperCase();
- if (n === er.TRUE || n === er.FALSE)
- return this.create(n);
- } else
- return this.create(a2);
- }
- create(a2) {
- return new Eh(a2);
- }
- checkAndCreateNodeType(a2) {
- if (!(a2 instanceof ae))
- return this._checkValueNode(a2);
- }
- };
- var bh = Object.defineProperty;
- var yh = Object.getOwnPropertyDescriptor;
- var Rh = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? yh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && bh(a2, e, r), r;
- };
- var at = (i, a2) => (e, t) => a2(e, t, i);
- var xr = class extends nt {
- constructor(a2, e, t, r, n, s, o, u, c, l2, f2) {
- super();
- A(this, "_astNodeFactoryList", []);
- this._runtimeService = a2, this._astRootNodeFactory = e, this._functionNodeFactory = t, this._lambdaNodeFactory = r, this._lambdaParameterNodeFactory = n, this._operatorNodeFactory = s, this._prefixNodeFactory = o, this._referenceNodeFactory = u, this._suffixNodeFactory = c, this._unionNodeFactory = l2, this._valueNodeFactory = f2, this._initializeAstNode();
- }
- dispose() {
- this._astNodeFactoryList.forEach((a2) => {
- a2.dispose();
- }), this._astNodeFactoryList = [];
- }
- parse(a2) {
- const e = new Fs(Ut), t = this._parse(a2, e);
- return a2.hasDefinedNames() && (t == null || t.setDefinedNames(a2.getDefinedNames())), t;
- }
- _lambdaParameterHandler(a2, e) {
- if (e.getLambdaId == null)
- return xe.create(m2.VALUE);
- const t = e.getLambdaId(), r = new Fs(Ut), n = this._runtimeService.getFunctionDefinitionPrivacyVar(t);
- if (!n)
- return false;
- const s = [...n.keys()], o = a2.getChildren(), u = o.length;
- for (let c = 0; c < u; c++) {
- const l2 = o[c];
- if (l2 instanceof ae) {
- Ea(l2, t, n), this._parse(l2, r);
- const h = r.getChildren()[c];
- h != null && n.set(s[c], h);
- } else
- return false;
- }
- return r.setParent(e), e;
- }
- _changeLetToLambda(a2) {
- const e = a2.getChildren(), t = e.length;
- if (t % 2 !== 1 || t === 0)
- return;
- const r = new ae();
- r.setToken(Sr);
- const n = new ae();
- n.setToken(hr);
- const s = [...e];
- for (let u = 0; u < t; u++) {
- const c = s[u];
- if (!(c instanceof ae))
- return;
- u % 2 === 0 ? c.changeToParent(r) : c.changeToParent(n);
- }
- r.addChildrenFirst(n), n.setParent(r);
- const o = a2.getParent();
- return o == null || o.replaceChild(a2, r), r;
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- _parse(a2, e) {
- var l2;
- const t = a2.getChildren(), r = t.length, n = [];
- let s = null;
- const o = a2.getToken().trim().toUpperCase();
- if (o === vc) {
- const f2 = this._changeLetToLambda(a2);
- return f2 != null ? this._parse(f2, e) : xe.create(m2.ERROR);
- }
- if (o === ht) {
- if (s = e, r === 0)
- return new rh(Ut).setParent(e), s;
- } else {
- if (o === hr) {
- let f2 = this._lambdaParameterHandler(a2, e);
- return f2 === false && (f2 = xe.create(m2.ERROR)), f2;
- }
- if (s = this._checkAstNode(a2), s == null)
- return xe.create(m2.NAME);
- }
- const u = t[0];
- for (let f2 = 0; f2 < r; f2++) {
- const h = t[f2];
- if (yo(u)) {
- if (f2 !== 0 && f2 !== r - 1)
- continue;
- } else if (Kf(h) && f2 !== r - 1)
- continue;
- let d2 = null;
- if (h instanceof ae) {
- if (h.getToken() === ht && h.getChildren().length === 0) {
- const _ = (l2 = h.getParent()) == null ? void 0 : l2.getChildren();
- if (_ && _.length === 1)
- return xe.create(m2.NAME);
- }
- if (d2 = this._parse(h, s), d2 === s)
- continue;
- } else
- d2 = this._checkAstNode(h);
- if (d2 == null)
- return xe.create(m2.NAME);
- if (d2 = Xf(d2), d2 == null || (d2 == null ? void 0 : d2.nodeType) === oe.ERROR)
- return d2;
- switch (d2.nodeType) {
- case oe.FUNCTION: {
- const _ = d2.getToken().trim().toUpperCase();
- Bc.has(_) && d2.setForcedCalculateFunction(), n.push(d2);
- break;
- }
- case oe.LAMBDA:
- n.push(d2);
- break;
- case oe.LAMBDA_PARAMETER:
- n.push(d2);
- break;
- case oe.OPERATOR: {
- const _ = n.pop(), C = n.pop();
- C && C.setParent(d2), _ && _.setParent(d2), n.push(d2);
- break;
- }
- case oe.REFERENCE:
- n.push(d2);
- break;
- case oe.ROOT:
- n.push(d2);
- break;
- case oe.UNION:
- n.push(d2);
- break;
- case oe.VALUE:
- n.push(d2);
- break;
- case oe.PREFIX:
- n.push(d2);
- break;
- case oe.SUFFIX:
- n.push(d2);
- break;
- }
- }
- const c = n.length;
- for (let f2 = 0; f2 < c; f2++)
- n[f2].setParent(s);
- return s;
- }
- // private _setPrefixRefOffset(astNode: BaseAstNode) {
- // const children = astNode.getChildren();
- // const childrenCount = children.length;
- // for (let i = 0; i < childrenCount; i++) {
- // const item = children[i];
- // if (item.nodeType === NodeType.REFERENCE) {
- // item.setRefOffset(this._refOffsetX, this._refOffsetY);
- // }
- // }
- // }
- _checkAstNode(a2) {
- let e = null;
- const t = this._astNodeFactoryList.length;
- for (let r = 0; r < t && (e = this._astNodeFactoryList[r].checkAndCreateNodeType(a2), e == null); r++)
- ;
- return e == null ? new Hf() : e;
- }
- _initializeAstNode() {
- this._astNodeFactoryList = [
- this._astRootNodeFactory,
- this._functionNodeFactory,
- this._lambdaNodeFactory,
- this._lambdaParameterNodeFactory,
- this._operatorNodeFactory,
- this._prefixNodeFactory,
- this._referenceNodeFactory,
- this._suffixNodeFactory,
- this._unionNodeFactory,
- this._valueNodeFactory
- ].sort(KC);
- }
- };
- xr = Rh([
- at(0, Nt),
- at(1, ot(Eo)),
- at(2, ot(En)),
- at(3, ot(bn)),
- at(4, ot(Vo)),
- at(5, ot(yn)),
- at(6, ot(An)),
- at(7, ot(Rn)),
- at(8, ot(pn)),
- at(9, ot(Vn)),
- at(10, ot(No))
- ], xr);
- var ph = class extends nt {
- constructor() {
- super(...arguments);
- A(this, "_otherFormulaData", /* @__PURE__ */ new Map());
- A(this, "_featureFormulaData", /* @__PURE__ */ new Map());
- A(this, "_formulaData", /* @__PURE__ */ new Map());
- A(this, "_definedNameMap", /* @__PURE__ */ new Map());
- A(this, "_otherFormulaDataMainData", /* @__PURE__ */ new Set());
- A(this, "_dependencyRTreeCache", new $R());
- A(this, "_dependencyTreeIdLast", 0);
- }
- buildDependencyTree(e, t) {
- throw new Error("Method not implemented.");
- }
- getTreeById(e) {
- throw new Error("Method not implemented.");
- }
- getAllTree() {
- throw new Error("Method not implemented.");
- }
- reset() {
- throw new Error("Method not implemented.");
- }
- addOtherFormulaDependency(e, t, r, n) {
- throw new Error("Method not implemented.");
- }
- removeOtherFormulaDependency(e, t, r) {
- throw new Error("Method not implemented.");
- }
- clearOtherFormulaDependency(e, t) {
- throw new Error("Method not implemented.");
- }
- addFeatureFormulaDependency(e, t, r, n) {
- throw new Error("Method not implemented.");
- }
- removeFeatureFormulaDependency(e, t, r) {
- throw new Error("Method not implemented.");
- }
- clearFeatureFormulaDependency(e, t) {
- throw new Error("Method not implemented.");
- }
- addFormulaDependency(e, t, r, n, s) {
- throw new Error("Method not implemented.");
- }
- removeFormulaDependency(e, t, r, n) {
- throw new Error("Method not implemented.");
- }
- clearFormulaDependency(e, t) {
- throw new Error("Method not implemented.");
- }
- removeFormulaDependencyByDefinedName(e, t) {
- throw new Error("Method not implemented.");
- }
- searchDependency(e, t) {
- return this._dependencyRTreeCache.bulkSearch(e, t);
- }
- _restDependencyTreeId() {
- this._dependencyTreeIdLast = 0;
- }
- getOtherFormulaDependency(e, t, r) {
- var n, s;
- return (s = (n = this._otherFormulaData.get(e)) == null ? void 0 : n.get(t)) == null ? void 0 : s.get(r);
- }
- addOtherFormulaDependencyMainData(e) {
- this._otherFormulaDataMainData.add(e);
- }
- hasOtherFormulaDataMainData(e) {
- return this._otherFormulaDataMainData.has(e);
- }
- _removeDependencyRTreeCacheById(e, t) {
- this._dependencyRTreeCache.removeById(e, t);
- }
- getFeatureFormulaDependency(e, t, r) {
- var n, s;
- return (s = (n = this._featureFormulaData.get(e)) == null ? void 0 : n.get(t)) == null ? void 0 : s.get(r);
- }
- getFormulaDependency(e, t, r, n) {
- var s, o;
- return (o = (s = this._formulaData.get(e)) == null ? void 0 : s.get(t)) == null ? void 0 : o.getValue(r, n);
- }
- addDependencyRTreeCache(e) {
- const t = [];
- for (let r = 0; r < e.rangeList.length; r++) {
- const n = e.rangeList[r], { unitId: s, sheetId: o, range: u } = n;
- t.push({
- unitId: s,
- sheetId: o,
- range: u,
- id: e.treeId
- });
- }
- this._dependencyRTreeCache.bulkInsert(t), this._addAllTreeMap(e);
- }
- getLastTreeId() {
- const e = this._dependencyTreeIdLast;
- return this._dependencyTreeIdLast++, e;
- }
- _addAllTreeMap(e) {
- throw new Error("Method not implemented.");
- }
- _addDefinedName(e, t, r) {
- this._definedNameMap.has(e) || this._definedNameMap.set(e, /* @__PURE__ */ new Map());
- const n = this._definedNameMap.get(e);
- n.has(t) || n.set(t, /* @__PURE__ */ new Set()), n.get(t).add(r);
- }
- addFormulaDependencyByDefinedName(e, t) {
- const r = e.treeId, n = (t == null ? void 0 : t.getDefinedNames()) || [];
- for (const s of n)
- this._addDefinedName(e.unitId, s, r);
- }
- };
- var Vh = class extends ph {
- constructor() {
- super(...arguments);
- A(this, "_allTreeMap", /* @__PURE__ */ new Map());
- }
- dispose() {
- this.reset();
- }
- buildDependencyTree(e, t = []) {
- const r = this.getAllTree();
- return e.length === 0 ? (this._buildReverseDependency(r, t), r) : (this._buildDependencyTree(r, e), this._buildReverseDependency(r, e), r);
- }
- /**
- * Build the dependency relationship between the trees.
- * @param allTrees all FormulaDependencyTree
- * @param shouldBeBuildTrees FormulaDependencyTree[] | FormulaDependencyTreeCache
- */
- _buildDependencyTree(e, t) {
- const r = /* @__PURE__ */ new Map();
- for (let n = 0; n < t.length; n++) {
- const s = t[n];
- r.set(s.treeId, s);
- }
- for (let n = 0; n < e.length; n++) {
- const s = e[n], o = s.toRTreeItem(), u = this._dependencyRTreeCache.bulkSearch(o);
- for (const c of u) {
- const l2 = r.get(c);
- l2 && s !== l2 && !l2.hasChildren(s.treeId) && l2.pushChildren(s);
- }
- }
- r.clear();
- }
- /**
- * Build the reverse dependency relationship between the trees.
- * @param allTrees
- * @param dependencyTrees
- */
- _buildReverseDependency(e, t) {
- const r = /* @__PURE__ */ new Map();
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- r.set(s.treeId, s);
- }
- for (let n = 0; n < t.length; n++) {
- const s = t[n], o = s.toRTreeItem(), u = this._dependencyRTreeCache.bulkSearch(o);
- for (const c of u) {
- const l2 = r.get(c);
- l2 && s !== l2 && !l2.hasChildren(s.treeId) && l2.pushChildren(s);
- }
- }
- r.clear();
- }
- /**
- * Get all FormulaDependencyTree from _otherFormulaData, _featureFormulaData, _formulaData
- * return FormulaDependencyTree[]
- */
- getAllTree() {
- const e = [];
- return this._allTreeMap.forEach((t) => {
- t.resetState(), e.push(t);
- }), e;
- }
- getTreeById(e) {
- return this._allTreeMap.get(e);
- }
- reset() {
- this._otherFormulaData.clear(), this._featureFormulaData.clear(), this._formulaData.clear(), this._dependencyRTreeCache.clear(), this._allTreeMap.clear(), this._restDependencyTreeId(), this._otherFormulaDataMainData.clear();
- }
- addOtherFormulaDependency(e, t, r, n) {
- this._otherFormulaData.has(e) || this._otherFormulaData.set(e, /* @__PURE__ */ new Map());
- const s = this._otherFormulaData.get(e);
- s.has(t) || s.set(t, /* @__PURE__ */ new Map());
- const o = s.get(t);
- o.has(r) || o.set(r, new kt()), o.get(r).setValue(n.refOffsetX, n.refOffsetY, n.treeId), this._addAllTreeMap(n);
- }
- removeOtherFormulaDependency(e, t, r) {
- const n = this._otherFormulaData.get(e);
- if (n && n.has(t)) {
- const s = n.get(t);
- r.forEach((o) => {
- const u = s.get(o);
- u != null && (u.forValue((c, l2, f2) => {
- this._removeDependencyRTreeCache(f2), this.clearDependencyForTree(this._allTreeMap.get(f2)), this._removeAllTreeMap(f2);
- }), s.delete(o), this._otherFormulaDataMainData.delete(o));
- }), s.size === 0 && n.delete(t), n.size === 0 && this._otherFormulaData.delete(e);
- }
- }
- clearOtherFormulaDependency(e, t) {
- const r = this._otherFormulaData.get(e);
- if (t && r && r.has(t)) {
- const n = r.get(t);
- this._removeDependencyRTreeCacheById(e, t);
- for (const s of n.keys()) {
- const o = n.get(s);
- o != null && (o.forValue((u, c, l2) => {
- const f2 = this._allTreeMap.get(l2);
- f2 && (this.clearDependencyForTree(f2), this._removeAllTreeMap(l2));
- }), this._otherFormulaDataMainData.delete(s));
- }
- n.clear();
- } else if (r) {
- for (const n of r.keys()) {
- const s = r.get(n);
- this._removeDependencyRTreeCacheById(e, n);
- for (const o of s.keys()) {
- const u = s.get(o);
- u != null && (u.forValue((c, l2, f2) => {
- const h = this._allTreeMap.get(f2);
- h && (this.clearDependencyForTree(h), this._removeAllTreeMap(f2));
- }), this._otherFormulaDataMainData.delete(o));
- }
- }
- this._otherFormulaData.delete(e);
- }
- }
- addFeatureFormulaDependency(e, t, r, n) {
- this._featureFormulaData.has(e) || this._featureFormulaData.set(e, /* @__PURE__ */ new Map());
- const s = this._featureFormulaData.get(e);
- s.has(t) || s.set(t, /* @__PURE__ */ new Map()), s.get(t).set(r, n.treeId), this._addAllTreeMap(n);
- }
- removeFeatureFormulaDependency(e, t, r) {
- const n = this._featureFormulaData.get(e);
- if (n && n.has(t)) {
- const s = n.get(t);
- r.forEach((o) => {
- const u = s.get(o);
- u != null && (this._removeDependencyRTreeCache(u), s.delete(o), this.clearDependencyForTree(this._allTreeMap.get(u)), this._removeAllTreeMap(u));
- });
- }
- }
- clearFeatureFormulaDependency(e, t) {
- const r = this._featureFormulaData.get(e);
- if (t && r && r.has(t)) {
- const n = r.get(t);
- this._removeDependencyRTreeCacheById(e, t), n.forEach((s) => {
- s != null && (this.clearDependencyForTree(this._allTreeMap.get(s)), this._removeAllTreeMap(s));
- }), n.clear();
- } else
- r && (r.forEach((n, s) => {
- this._removeDependencyRTreeCacheById(e, s), n.forEach((o) => {
- o != null && (this.clearDependencyForTree(this._allTreeMap.get(o)), this._removeAllTreeMap(o));
- });
- }), this._featureFormulaData.delete(e));
- }
- addFormulaDependency(e, t, r, n, s) {
- this._formulaData.has(e) || this._formulaData.set(e, /* @__PURE__ */ new Map());
- const o = this._formulaData.get(e);
- o.has(t) || o.set(t, new kt()), o.get(t).setValue(r, n, s.treeId), this._addAllTreeMap(s);
- }
- removeFormulaDependency(e, t, r, n) {
- const s = this._formulaData.get(e);
- if (s && s.has(t)) {
- const o = s.get(t), u = o.getValue(r, n);
- if (u == null)
- return;
- this._removeDependencyRTreeCache(u), o.realDeleteValue(r, n), this.clearDependencyForTree(this._allTreeMap.get(u)), this._removeAllTreeMap(u);
- }
- }
- clearFormulaDependency(e, t) {
- const r = this._formulaData.get(e);
- if (t && r && r.has(t)) {
- const n = r.get(t);
- this._removeDependencyRTreeCacheById(e, t), n.forValue((s, o, u) => {
- if (u == null)
- return true;
- this.clearDependencyForTree(this._allTreeMap.get(u)), this._removeAllTreeMap(u);
- }), n.reset();
- } else
- r && (r.forEach((n, s) => {
- this._removeDependencyRTreeCacheById(e, s), n.forValue((o, u, c) => {
- if (c == null)
- return true;
- this.clearDependencyForTree(this._allTreeMap.get(c)), this._removeAllTreeMap(c);
- });
- }), this._formulaData.delete(e));
- }
- /**
- * Clear the dependency relationship of the tree.
- * establish the relationship between the parent and the child.
- * @param shouldBeClearTree
- */
- clearDependencyForTree(e) {
- if (e == null)
- return;
- const t = e.parents, r = e.children, n = this._allTreeMap;
- for (const s of t) {
- const o = n.get(s);
- o == null || o.children.delete(e.treeId);
- }
- for (const s of r) {
- const o = n.get(s);
- o == null || o.parents.delete(e.treeId);
- }
- e.dispose();
- }
- _removeDependencyRTreeCache(e) {
- if (e == null)
- return;
- const t = this._allTreeMap.get(e);
- if (t) {
- const r = [];
- for (let n = 0; n < t.rangeList.length; n++) {
- const s = t.rangeList[n], { unitId: o, sheetId: u, range: c } = s;
- r.push({
- unitId: o,
- sheetId: u,
- range: c,
- id: e
- });
- }
- this._dependencyRTreeCache.bulkRemove(r);
- }
- }
- removeFormulaDependencyByDefinedName(e, t) {
- const r = this._definedNameMap.get(e);
- if (r) {
- const n = r.get(t);
- if (n) {
- for (const s of n)
- this._removeDependencyRTreeCache(s), this.clearDependencyForTree(this._allTreeMap.get(s)), this._removeAllTreeMap(s);
- n.clear();
- }
- }
- }
- _removeAllTreeMap(e) {
- e != null && this._allTreeMap.delete(e);
- }
- _addAllTreeMap(e) {
- this._allTreeMap.set(e.treeId, e);
- }
- };
- var Hn = Ct(
- "univer.formula.dependency-manager.service"
- );
- var Nh = class extends nt {
- constructor() {
- super(...arguments);
- A(this, "_referenceExecutorMap", /* @__PURE__ */ new Map());
- A(this, "_onChanged$", new Subject());
- A(this, "onChanged$", this._onChanged$.asObservable());
- }
- dispose() {
- this._referenceExecutorMap.clear();
- }
- remove(e, t, r) {
- r.forEach((n) => {
- var s, o;
- (o = (s = this._referenceExecutorMap.get(e)) == null ? void 0 : s.get(t)) == null || o.delete(n);
- }), this._onChanged$.next({
- unitId: e,
- subUnitId: t,
- featureIds: r
- });
- }
- get(e, t, r) {
- var n, s;
- return (s = (n = this._referenceExecutorMap.get(e)) == null ? void 0 : n.get(t)) == null ? void 0 : s.get(r);
- }
- has(e, t, r) {
- var n, s;
- return !!((s = (n = this._referenceExecutorMap.get(e)) == null ? void 0 : n.get(t)) != null && s.has(r));
- }
- register(e, t, r, n) {
- let s = this._referenceExecutorMap.get(e);
- s || (s = /* @__PURE__ */ new Map(), this._referenceExecutorMap.set(e, s));
- let o = s.get(t);
- o || (o = /* @__PURE__ */ new Map(), s.set(t, o)), this._onChanged$.next({
- unitId: e,
- subUnitId: t,
- featureIds: [r]
- }), o.set(r, n);
- }
- getReferenceExecutorMap() {
- return this._referenceExecutorMap;
- }
- };
- var jr = Ct(
- "univer.formula.feature-calculation-manager.service"
- );
- var Oh = class extends nt {
- constructor() {
- super(...arguments);
- A(this, "_otherFormulaData", {});
- }
- dispose() {
- this._otherFormulaData = {};
- }
- remove(e) {
- var s, o, u;
- const { unitId: t, subUnitId: r, formulaId: n } = e;
- (u = (o = (s = this._otherFormulaData) == null ? void 0 : s[t]) == null ? void 0 : o[r]) == null || delete u[n];
- }
- get(e) {
- var s, o;
- const { unitId: t, subUnitId: r, formulaId: n } = e;
- return (o = (s = this._otherFormulaData[t]) == null ? void 0 : s[r]) == null ? void 0 : o[n];
- }
- has(e) {
- var s, o;
- const { unitId: t, subUnitId: r, formulaId: n } = e;
- return ((o = (s = this._otherFormulaData[t]) == null ? void 0 : s[r]) == null ? void 0 : o[n]) != null;
- }
- register(e) {
- const { unitId: t, subUnitId: r, formulaId: n, item: s } = e;
- this._otherFormulaData[t] || (this._otherFormulaData[t] = {}), this._otherFormulaData[t][r] || (this._otherFormulaData[t][r] = {}), this._otherFormulaData[t][r][n] = s;
- }
- batchRegister(e) {
- Object.keys(e).forEach((t) => {
- const r = e[t];
- if (r == null)
- return true;
- Object.keys(r).forEach((n) => {
- const s = r[n];
- if (s == null)
- return true;
- Object.keys(s).forEach((o) => {
- const u = s[o];
- if (u == null)
- return true;
- this.register({
- unitId: t,
- subUnitId: n,
- formulaId: o,
- item: u
- });
- });
- });
- });
- }
- batchRemove(e) {
- Object.keys(e).forEach((t) => {
- const r = e[t];
- if (r == null)
- return true;
- Object.keys(r).forEach((n) => {
- const s = r[n];
- if (s == null)
- return true;
- Object.keys(s).forEach((o) => {
- this.remove({
- unitId: t,
- subUnitId: n,
- formulaId: o
- });
- });
- });
- });
- }
- getOtherFormulaData() {
- return this._otherFormulaData;
- }
- };
- var ya = Ct(
- "univer.formula.other-formula-manager.service"
- );
- var Mh = 5e3;
- var ks = new Vt(Mh);
- function pi(i, a2, e, t, r) {
- let n = ks.get(`${i}${a2}`);
- if (n && !Oo(n, r))
- return n;
- const s = e.treeBuilder(a2);
- if (yr.has(s))
- return xe.create(s);
- if (n = t.parse(s), n == null)
- throw new Error("astNode is null");
- return ks.set(`${i}${a2}`, n), n;
- }
- function Oo(i, a2) {
- const e = a2.getDirtyDefinedNameMap(), t = a2.getExecuteUnitId();
- if (t != null && e[t] != null) {
- const r = Object.keys(e[t]);
- for (let n = 0, s = r.length; n < s; n++) {
- const o = r[n];
- if (i.hasDefinedName(o))
- return true;
- }
- }
- return false;
- }
- function wh(i, a2, e) {
- return !!(a2 != null && Oo(a2, e));
- }
- var $s = ((i) => (i[i.NORMAL_FORMULA = 0] = "NORMAL_FORMULA", i[i.OTHER_FORMULA = 1] = "OTHER_FORMULA", i[i.FEATURE_FORMULA = 2] = "FEATURE_FORMULA", i))($s || {});
- var Mo = class {
- constructor() {
- A(this, "_state", 0);
- A(this, "treeId");
- A(this, "children", /* @__PURE__ */ new Set());
- A(this, "parents", /* @__PURE__ */ new Set());
- }
- resetState() {
- this._state = 0;
- }
- setAdded() {
- this._state = 1;
- }
- isAdded() {
- return this._state === 1;
- }
- setSkip() {
- this._state = 2;
- }
- isSkip() {
- return this._state === 2;
- }
- pushChildren(a2) {
- this.children.add(a2.treeId), a2._pushParent(this);
- }
- hasChildren(a2) {
- return this.children.has(a2);
- }
- _pushParent(a2) {
- this.parents.add(a2.treeId);
- }
- };
- var Vi = class extends Mo {
- constructor() {
- super(...arguments);
- A(this, "refTree");
- A(this, "refOffsetX", -1);
- A(this, "refOffsetY", -1);
- A(this, "isCache", false);
- A(this, "isDirty", false);
- A(this, "addressFunctionNodes", []);
- A(this, "getDirtyData");
- A(this, "featureId");
- }
- get isVirtual() {
- return true;
- }
- get row() {
- return this.refTree == null ? -1 : this.refTree.row + this.refOffsetY;
- }
- get column() {
- return this.refTree == null ? -1 : this.refTree.column + this.refOffsetX;
- }
- get rowCount() {
- return this.refTree == null ? 0 : this.refTree.rowCount;
- }
- get columnCount() {
- return this.refTree == null ? 0 : this.refTree.columnCount;
- }
- get unitId() {
- return this.refTree == null ? "" : this.refTree.unitId;
- }
- get subUnitId() {
- return this.refTree == null ? "" : this.refTree.subUnitId;
- }
- get formula() {
- var e, t;
- return (t = (e = this.refTree) == null ? void 0 : e.formula) != null ? t : "";
- }
- get nodeData() {
- return {
- node: this.node,
- refOffsetX: this.refOffsetX,
- refOffsetY: this.refOffsetY
- };
- }
- get node() {
- var e;
- return (e = this.refTree) == null ? void 0 : e.node;
- }
- dispose() {
- this.refTree = null;
- }
- get rangeList() {
- const e = [];
- if (this.refTree == null)
- return [];
- for (let t = 0; t < this.refTree.rangeList.length; t++) {
- const r = this.refTree.rangeList[t];
- e.push({
- unitId: r.unitId,
- sheetId: r.sheetId,
- range: jC(r.range, this.refOffsetX, this.refOffsetY)
- });
- }
- return e;
- }
- toRTreeItem() {
- const e = this.row, t = this.column;
- return [{
- unitId: this.unitId,
- sheetId: this.subUnitId,
- range: {
- startRow: e,
- startColumn: t,
- endRow: e,
- endColumn: t
- }
- }];
- }
- inRangeData(e) {
- const t = e.startRow, r = e.startColumn, n = e.endRow, s = e.endColumn, o = this.row, u = this.column;
- return !(o < t || o > n || u < r || u > s);
- }
- dependencySheetName(e) {
- return this.refTree == null ? false : this.refTree.dependencySheetName(e);
- }
- isExcludeRange(e) {
- var r;
- const t = this.rangeList;
- if (t.length === 0)
- return false;
- for (let n = 0, s = t.length; n < s; n++) {
- const o = t[n], { unitId: u, sheetId: c, range: l2 } = o, f2 = (r = e == null ? void 0 : e[u]) == null ? void 0 : r[c];
- let { startRow: h, endRow: d2, startColumn: _, endColumn: C } = l2;
- Number.isNaN(h) && (h = 0), Number.isNaN(_) && (_ = 0), Number.isNaN(d2) && (d2 = Number.POSITIVE_INFINITY), Number.isNaN(C) && (C = Number.POSITIVE_INFINITY);
- let E2 = false;
- if (f2 == null || f2.forValue((b, R) => {
- if (b >= h && b <= d2 && R >= _ && R <= C)
- return E2 = true, false;
- }), E2)
- return true;
- }
- return false;
- }
- get formulaId() {
- return this.refTree == null ? "" : this.refTree.formulaId;
- }
- };
- var hs = class extends Mo {
- constructor(e) {
- super();
- A(this, "isCache", false);
- A(this, "featureId");
- A(this, "featureDirtyRanges", []);
- A(this, "refOffsetX", 0);
- A(this, "refOffsetY", 0);
- A(this, "type", 0);
- A(this, "formulaId");
- A(this, "subUnitId", "");
- A(this, "unitId", "");
- A(this, "rangeList", []);
- A(this, "formula", "");
- A(this, "row", -1);
- A(this, "column", -1);
- A(this, "rowCount", Number.NEGATIVE_INFINITY);
- A(this, "columnCount", Number.NEGATIVE_INFINITY);
- A(this, "isDirty", false);
- A(this, "node");
- A(this, "addressFunctionNodes", []);
- A(this, "getDirtyData");
- this.treeId = e;
- }
- get isVirtual() {
- return false;
- }
- get nodeData() {
- return {
- node: this.node,
- refOffsetX: 0,
- refOffsetY: 0
- };
- }
- toJson() {
- return {
- formula: this.formula,
- refOffsetX: this.refOffsetX,
- refOffsetY: this.refOffsetY
- };
- }
- dispose() {
- this.featureDirtyRanges = [], this.rangeList = [], this.addressFunctionNodes = [], this.getDirtyData = null;
- }
- inRangeData(e) {
- const t = e.startRow, r = e.startColumn, n = e.endRow, s = e.endColumn, o = this.row, u = this.column;
- return !(o < t || o > n || u < r || u > s);
- }
- dependencySheetName(e) {
- var r;
- const t = this.rangeList;
- if (t.length === 0 || e == null)
- return false;
- for (let n = 0, s = t.length; n < s; n++) {
- const o = t[n], { unitId: u, sheetId: c } = o;
- if (((r = e[u]) == null ? void 0 : r[c]) != null)
- return true;
- }
- return false;
- }
- isExcludeRange(e) {
- var r;
- const t = this.rangeList;
- if (t.length === 0)
- return false;
- for (let n = 0, s = t.length; n < s; n++) {
- const o = t[n], { unitId: u, sheetId: c, range: l2 } = o, f2 = (r = e == null ? void 0 : e[u]) == null ? void 0 : r[c];
- let { startRow: h, endRow: d2, startColumn: _, endColumn: C } = l2;
- Number.isNaN(h) && (h = 0), Number.isNaN(_) && (_ = 0), Number.isNaN(d2) && (d2 = Number.POSITIVE_INFINITY), Number.isNaN(C) && (C = Number.POSITIVE_INFINITY);
- let E2 = false;
- if (f2 == null || f2.forValue((b, R) => {
- if (b >= h && b <= d2 && R >= _ && R <= C)
- return E2 = true, false;
- }), E2)
- return true;
- }
- return false;
- }
- // pushChildren(tree: FormulaDependencyTree) {
- // this.children.add(tree.treeId);
- // tree._pushParent(this);
- // }
- /**
- * Add the range corresponding to the current ast node.
- * @param range
- */
- pushRangeList(e) {
- this.rangeList.push(...e);
- }
- shouldBePushRangeList() {
- return this.rangeList.length === 0 && this.type !== 2;
- }
- // hasChildren(treeId: number) {
- // return this.children.has(treeId);
- // }
- toRTreeItem() {
- if (this.featureId != null)
- return this.featureDirtyRanges;
- const e = this.row, t = this.column;
- return [{
- unitId: this.unitId,
- sheetId: this.subUnitId,
- range: {
- startRow: e,
- startColumn: t,
- endRow: e,
- endColumn: t
- }
- }];
- }
- /**
- * Determine whether it is dependent on other trees.
- * @param dependenceTree
- */
- // dependency(dependenceTree: FormulaDependencyTree) {
- // if (this.rangeList.length === 0) {
- // return false;
- // }
- // for (let r = 0, len = this.rangeList.length; r < len; r++) {
- // const unitRange = this.rangeList[r];
- // const unitId = unitRange.unitId;
- // const sheetId = unitRange.sheetId;
- // const range = unitRange.range;
- // if (
- // dependenceTree.unitId === unitId &&
- // dependenceTree.subUnitId === sheetId &&
- // dependenceTree.inRangeData(range)
- // ) {
- // return true;
- // }
- // }
- // return false;
- // }
- // private _pushParent(tree: FormulaDependencyTree) {
- // this.parents.add(tree.treeId);
- // }
- };
- var Dh = Object.defineProperty;
- var Sh = Object.getOwnPropertyDescriptor;
- var Ph = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Sh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Dh(a2, e, r), r;
- };
- var wt = (i, a2) => (e, t) => a2(e, t, i);
- function or(i) {
- return i.getLastTreeId() || 0;
- }
- var Ys = Ct("engine-formula.dependency-generator");
- var Hs = class extends nt {
- constructor(a2, e, t, r, n, s, o, u) {
- super();
- A(this, "_updateRangeFlattenCache", /* @__PURE__ */ new Map());
- A(this, "_dependencyRTreeCacheForAddressFunction", new $R());
- A(this, "_executedAddressFunctionNodeIds", /* @__PURE__ */ new Set());
- this._currentConfigService = a2, this._runtimeService = e, this._otherFormulaManagerService = t, this._featureCalculationManagerService = r, this._interpreter = n, this._astTreeBuilder = s, this._lexer = o, this._dependencyManagerService = u;
- }
- dispose() {
- this._updateRangeFlattenCache.clear(), this._dependencyRTreeCacheForAddressFunction.clear(), ks.clear();
- }
- async generate() {
- this._updateRangeFlatten();
- const a2 = this._currentConfigService.getFormulaData(), e = this._otherFormulaManagerService.getOtherFormulaData(), t = this._currentConfigService.getClearDependencyTreeCache();
- t != null && Object.keys(t).forEach((l2) => {
- l2 != null && Object.keys(t[l2]).forEach((f2) => {
- f2 != null && (this._dependencyManagerService.clearOtherFormulaDependency(l2, f2), this._dependencyManagerService.clearFeatureFormulaDependency(l2, f2), this._dependencyManagerService.clearFormulaDependency(l2, f2));
- });
- });
- const r = this._currentConfigService.getUnitData(), n = await this._generateTreeList(a2, e, r), s = this._getUpdateTreeListAndMakeDependency(n);
- let o = this._calculateRunList(s);
- return this._dependencyFeatureCalculation(o) && (o.forEach((l2) => {
- l2.resetState();
- }), o = this._calculateRunList(o)), this._checkIsCycleDependency(o) && this._runtimeService.enableCycleDependency(), this._dependencyRTreeCacheForAddressFunction.clear(), Promise.resolve(o);
- }
- _dependencyFeatureCalculation(a2) {
- const e = this._featureCalculationManagerService.getReferenceExecutorMap();
- if (e.size === 0)
- return;
- this._clearFeatureCalculationNode(a2);
- let t = false;
- return e.forEach((r, n) => {
- r.forEach((s, o) => {
- s.forEach((u, c) => {
- const { unitId: l2, subUnitId: f2, getDirtyData: h } = u, d2 = h(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData()), _ = this._convertDirtyRangesToUnitRange(d2.dirtyRanges), C = this._intersectFeatureCalculation(_, a2, { unitId: l2, subUnitId: f2, featureId: c });
- if (C.length > 0) {
- let E2 = this._getExistTreeList({ unitId: l2, subUnitId: f2, featureId: c }, a2);
- E2 == null && (E2 = this._getFeatureFormulaTree(c, or(this._dependencyManagerService), u), a2.push(E2)), E2.parents = /* @__PURE__ */ new Set(), C.forEach((b) => {
- b.hasChildren(E2.treeId) || b.pushChildren(E2);
- }), t = true;
- }
- });
- });
- }), t;
- }
- _clearFeatureCalculationNode(a2) {
- const e = this._featureCalculationManagerService.getReferenceExecutorMap();
- a2.forEach((t) => {
- var s, o, u, c;
- const r = /* @__PURE__ */ new Set();
- for (const l2 of t.children) {
- const f2 = this._dependencyManagerService.getTreeById(l2);
- f2 && (f2.featureId && (o = (s = e.get(t.unitId)) == null ? void 0 : s.get(t.subUnitId)) != null && o.has(f2.featureId) || r.add(l2));
- }
- t.children = r;
- const n = /* @__PURE__ */ new Set();
- for (const l2 of t.parents) {
- const f2 = this._dependencyManagerService.getTreeById(l2);
- f2 && (f2.featureId && (c = (u = e.get(t.unitId)) == null ? void 0 : u.get(t.subUnitId)) != null && c.has(f2.featureId) || n.add(l2));
- }
- t.parents = n;
- });
- }
- /**
- * TODO @DR-Univer: The next step will be to try changing the incoming dirtyRanges to an array, thus avoiding conversion.
- * @param dirtyRanges
- * @returns
- */
- _convertDirtyRangesToUnitRange(a2) {
- const e = [];
- for (const t in a2) {
- const r = a2[t];
- for (const n in r) {
- const s = r[n];
- for (const o of s)
- e.push({
- unitId: t,
- sheetId: n,
- range: o
- });
- }
- }
- return e;
- }
- _intersectFeatureCalculation(a2, e, t) {
- const r = [], n = this._dependencyManagerService.searchDependency(a2);
- for (let s = 0, o = e.length; s < o; s++) {
- const u = e[s];
- if (u.unitId === t.unitId && u.subUnitId === t.subUnitId && u.featureId === t.featureId)
- continue;
- n.has(u.treeId) && r.push(u);
- }
- return r;
- }
- _getExistTreeList(a2, e) {
- const { unitId: t, subUnitId: r, featureId: n } = a2;
- for (let s = 0, o = e.length; s < o; s++) {
- const u = e[s];
- if (u.unitId === t && u.subUnitId === r && u.featureId === n)
- return u;
- }
- }
- _isCyclicUtil(a2, e, t) {
- const r = this._dependencyManagerService.getTreeById(a2);
- if (r == null)
- return false;
- if (!e.has(r.treeId)) {
- e.add(r.treeId), t.add(r.treeId);
- for (const n of r.children)
- if (!e.has(n) && this._isCyclicUtil(n, e, t) || t.has(n))
- return true;
- }
- return t.delete(r.treeId), false;
- }
- _checkIsCycleDependency(a2) {
- const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
- for (let r = 0, n = a2.length; r < n; r++) {
- const s = a2[r];
- if (this._isCyclicUtil(s.treeId, e, t) === true)
- return true;
- }
- return false;
- }
- /**
- * Generate nodes for the dependency tree, where each node contains all the reference data ranges included in each formula.
- * @param formulaData
- */
- async _generateTreeList(a2, e, t) {
- const r = Object.keys(a2), n = Object.keys(e), s = [];
- this._currentConfigService.isForceCalculate() && this._dependencyManagerService.reset(), this._registerFormulas(r, a2, t, s), this._registerOtherFormulas(e, n, s), this._registerFeatureFormulas(s);
- for (let u = 0, c = s.length; u < c; u++) {
- const l2 = s[u], f2 = this._getTreeNode(l2);
- l2.isDirty = this._includeTree(l2, f2);
- const h = this._getAddressFunctionNodeList(f2);
- if (h.length > 0 && (l2.addressFunctionNodes = h), l2.isVirtual)
- continue;
- this._runtimeService.setCurrent(
- l2.row,
- l2.column,
- l2.rowCount,
- l2.columnCount,
- l2.subUnitId,
- l2.unitId
- );
- const d2 = await this._getRangeListByNode({
- node: f2,
- refOffsetX: l2.refOffsetX,
- refOffsetY: l2.refOffsetY
- });
- l2.pushRangeList(d2);
- }
- for (let u = 0, c = s.length; u < c; u++) {
- const l2 = s[u];
- l2.isCache || this._dependencyManagerService.addDependencyRTreeCache(l2);
- }
- return await this._calculateListByFunctionRefNode(s), s;
- }
- // private _moveRangeList(tree: FormulaDependencyTree, refOffsetX: number, refOffsetY: number) {
- // const rangeList = tree.rangeList;
- // const newRangeList = [];
- // for (let i = 0, len = rangeList.length; i < len; i++) {
- // const unitRange = rangeList[i];
- // const newRange = {
- // unitId: tree.unitId,
- // sheetId: tree.subUnitId,
- // range: moveRangeByOffset(unitRange.range, refOffsetX, refOffsetY),
- // };
- // newRangeList.push(newRange);
- // }
- // return newRangeList;
- // }
- _registerFeatureFormulas(a2) {
- this._featureCalculationManagerService.getReferenceExecutorMap().forEach((t, r) => {
- t.forEach((n, s) => {
- n.forEach((o, u) => {
- const c = this._dependencyManagerService.getFeatureFormulaDependency(o.unitId, o.subUnitId, u);
- a2.push(this._getFeatureFormulaTree(u, c, o));
- });
- });
- });
- }
- _getFeatureFormulaTree(a2, e, t) {
- const { unitId: r, subUnitId: n, dependencyRanges: s, getDirtyData: o } = t, u = e || or(this._dependencyManagerService), c = new hs(u);
- c.unitId = r, c.subUnitId = n, c.rangeList = s, c.getDirtyData = o;
- const l2 = o(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData()), f2 = this._convertDirtyRangesToUnitRange(l2.dirtyRanges);
- return c.featureDirtyRanges = f2, c.featureId = a2, c.type = $s.FEATURE_FORMULA, this._dependencyManagerService.addFeatureFormulaDependency(r, n, a2, c), this._dependencyManagerService.getFeatureFormulaDependency(t.unitId, t.subUnitId, a2) && (c.isCache = true), c;
- }
- _registerOtherFormulas(a2, e, t) {
- for (const r of e) {
- const n = a2[r];
- if (n == null)
- continue;
- const s = Object.keys(n);
- for (const o of s) {
- const u = n[o];
- if (u == null)
- continue;
- const c = Object.keys(u);
- for (const l2 of c) {
- const f2 = this._dependencyManagerService.hasOtherFormulaDataMainData(l2), h = u[l2], { f: d2, ranges: _ } = h;
- let C = false;
- f2 && (C = true);
- const E2 = pi(r, d2, this._lexer, this._astTreeBuilder, this._currentConfigService), { firstRow: b, firstColumn: R } = this._getFirstCellOfRange(_), p2 = this._dependencyManagerService.getOtherFormulaDependency(r, o, l2), N2 = (p2 == null ? void 0 : p2.getValue(0, 0)) || or(this._dependencyManagerService), M2 = new hs(N2);
- for (let w = 0; w < _.length; w++) {
- const D2 = _[w], { startRow: S2, startColumn: P, endRow: U2, endColumn: x2 } = D2;
- for (let F = S2; F <= U2; F++)
- for (let W2 = P; W2 <= x2; W2++) {
- const ne = W2 - R, z = F - b;
- if (ne === 0 && z === 0) {
- M2.node = E2, M2.formula = d2, M2.unitId = r, M2.subUnitId = o, M2.formulaId = l2, M2.type = $s.OTHER_FORMULA, M2.isCache = C, t.push(M2), this._dependencyManagerService.addOtherFormulaDependency(r, o, l2, M2), this._dependencyManagerService.addFormulaDependencyByDefinedName(M2);
- continue;
- }
- const G2 = new Vi();
- G2.treeId = (p2 == null ? void 0 : p2.getValue(ne, z)) || or(this._dependencyManagerService), G2.refTree = M2, G2.refOffsetX = ne, G2.refOffsetY = z, G2.isCache = C, this._dependencyManagerService.addOtherFormulaDependency(r, o, l2, G2), this._dependencyManagerService.addFormulaDependencyByDefinedName(G2), t.push(G2);
- }
- }
- this._dependencyManagerService.addOtherFormulaDependencyMainData(l2);
- }
- }
- }
- }
- _getFirstCellOfRange(a2) {
- const e = a2[0];
- return {
- firstRow: e.startRow,
- firstColumn: e.startColumn
- };
- }
- _registerFormulas(a2, e, t, r) {
- for (const n of a2) {
- const s = e[n];
- if (s == null)
- continue;
- const o = Object.keys(s);
- for (const u of o) {
- const c = new kt(s[u] || {}), l2 = /* @__PURE__ */ new Map();
- c.forValue((f2, h, d2) => {
- if (d2 == null)
- return true;
- const { x: _ = 0, y: C = 0, si: E2 } = d2;
- if (!(_ === 0 && C === 0 && E2 != null))
- return true;
- const b = this._createFDtree(n, u, f2, h, t, d2), R = this._dependencyManagerService.getFormulaDependency(n, u, f2, h);
- R != null ? b.treeId = R : (this._dependencyManagerService.addFormulaDependency(n, u, f2, h, b), this._dependencyManagerService.addFormulaDependencyByDefinedName(b)), l2.set(E2, b), r.push(b);
- }), c.forValue((f2, h, d2) => {
- if (d2 == null)
- return true;
- const { x: _ = 0, y: C = 0, si: E2 } = d2;
- if (_ === 0 && C === 0 && E2 != null)
- return true;
- let b;
- if (E2 && l2.has(E2)) {
- const p2 = l2.get(E2);
- b = this._createVirtualFDtree(p2, d2);
- } else
- b = this._createFDtree(n, u, f2, h, t, d2);
- const R = this._dependencyManagerService.getFormulaDependency(n, u, f2, h);
- R != null ? b.treeId = R : (this._dependencyManagerService.addFormulaDependency(n, u, f2, h, b), this._dependencyManagerService.addFormulaDependencyByDefinedName(b)), r.push(b);
- }), l2.clear();
- }
- }
- }
- _createFDtree(a2, e, t, r, n, s) {
- const { f: o, x: u = 0, y: c = 0 } = s, l2 = new hs(or(this._dependencyManagerService)), f2 = n[a2][e], h = pi(a2, o, this._lexer, this._astTreeBuilder, this._currentConfigService);
- return l2.node = h, l2.formula = o, l2.unitId = a2, l2.subUnitId = e, l2.row = t, l2.column = r, l2.rowCount = f2.rowCount, l2.columnCount = f2.columnCount, l2;
- }
- _createVirtualFDtree(a2, e) {
- const { x: t = 0, y: r = 0 } = e, n = new Vi();
- return n.treeId = or(this._dependencyManagerService), n.refTree = a2, n.refOffsetX = t, n.refOffsetY = r, n;
- }
- /**
- * Break down the dirty areas into ranges for subsequent matching.
- */
- _updateRangeFlatten() {
- const a2 = this._currentConfigService.isForceCalculate(), e = this._currentConfigService.getDirtyRanges();
- if (!a2) {
- this._updateRangeFlattenCache.clear();
- for (let t = 0; t < e.length; t++) {
- const r = e[t], n = r.range, s = r.sheetId, o = r.unitId;
- this._addFlattenCache(o, s, n);
- }
- }
- }
- _addFlattenCache(a2, e, t) {
- let r = this._updateRangeFlattenCache.get(a2);
- r == null && (r = /* @__PURE__ */ new Map(), this._updateRangeFlattenCache.set(a2, r));
- let n = r.get(e);
- n == null && (n = [], r.set(e, n)), n.push(t);
- }
- _isPreCalculateNode(a2) {
- return a2.nodeType === oe.UNION || a2.nodeType === oe.PREFIX && a2.getToken() === Oe.AT || a2.nodeType === oe.SUFFIX && a2.getToken() === ze.POUND;
- }
- _nodeTraversalRef(a2, e) {
- const t = a2.getChildren(), r = t.length;
- for (let n = 0; n < r; n++) {
- const s = t[n];
- if (this._isPreCalculateNode(s)) {
- if (e.push(s), s.nodeType === oe.UNION)
- for (const o of s.getChildren())
- o.nodeType === oe.FUNCTION && o.isAddress() && this._nodeTraversalRef(o, e);
- continue;
- } else
- s.nodeType === oe.REFERENCE && e.push(s);
- this._nodeTraversalRef(s, e);
- }
- }
- _nodeTraversalReferenceFunction(a2, e) {
- const t = a2.getChildren(), r = t.length;
- for (let n = 0; n < r; n++) {
- const s = t[n];
- if (s.nodeType === oe.FUNCTION && s.isAddress()) {
- e.push(s);
- continue;
- }
- this._nodeTraversalReferenceFunction(s, e);
- }
- }
- async _executeNode(a2, e = 0, t = 0) {
- let r;
- const n = {
- node: a2,
- refOffsetX: e,
- refOffsetY: t
- };
- return this._interpreter.checkAsyncNode(a2) ? r = await this._interpreter.executeAsync(n) : r = this._interpreter.execute(n), r;
- }
- /**
- * Calculate the range required for collection in advance,
- * including references and location functions (such as OFFSET, INDIRECT, INDEX, etc.).
- * @param node
- */
- async _getRangeListByNode(a2) {
- const e = [], t = a2.refOffsetX, r = a2.refOffsetY, n = a2.node;
- if (n == null)
- return [];
- this._nodeTraversalRef(n, e);
- const s = [];
- for (let o = 0, u = e.length; o < u; o++) {
- const c = e[o], f2 = (await this._executeNode(c, t, r)).toUnitRange();
- s.push(f2), c.setValue(null);
- }
- return s;
- }
- _getAddressFunctionNodeList(a2) {
- const e = [];
- return a2 == null ? [] : (this._nodeTraversalReferenceFunction(a2, e), e);
- }
- _getTreeNode(a2) {
- return a2.node;
- }
- async _buildDirtyRangesByAddressFunction(a2, e) {
- const t = e.addressFunctionNodes;
- if (t.length === 0)
- return;
- const r = e.refOffsetX, n = e.refOffsetY, s = await this._getRangeListByFunctionRefNode(t, r, n);
- e.addressFunctionNodes = [], this._addDependencyTreeByAddressFunction(e, s);
- const o = a2.bulkSearch(s), u = this._buildTreeNodeById(o);
- u.length !== 0 && await this._calculateAddressFunctionRuntimeData(a2, u);
- }
- async _calculateListByFunctionRefNode(a2) {
- const e = new $R();
- for (let t = 0, r = a2.length; t < r; t++) {
- const n = a2[t];
- e.insert({
- unitId: n.unitId,
- sheetId: n.subUnitId,
- range: {
- startRow: n.row,
- startColumn: n.column,
- endRow: n.row,
- endColumn: n.column
- },
- id: n.treeId
- });
- }
- this._executedAddressFunctionNodeIds.clear();
- for (let t = 0, r = a2.length; t < r; t++) {
- const n = a2[t];
- await this._calculateAddressFunction(e, n);
- }
- }
- async _calculateAddressFunction(a2, e) {
- const t = e.addressFunctionNodes;
- if (t.length === 0)
- return;
- const r = e.refOffsetX, n = e.refOffsetY;
- this._runtimeService.setCurrent(
- e.row,
- e.column,
- e.rowCount,
- e.columnCount,
- e.subUnitId,
- e.unitId
- );
- const s = [];
- for (let c = 0, l2 = t.length; c < l2; c++) {
- const f2 = await this._getRangeListByNode({
- node: t[c],
- refOffsetX: r,
- refOffsetY: n
- });
- s.push(...f2);
- }
- const o = /* @__PURE__ */ new Set();
- this._searchDependencyByAddressFunction(a2, s, o);
- const u = this._buildTreeNodeById(o);
- if (u.length === 0) {
- await this._buildDirtyRangesByAddressFunction(a2, e);
- return;
- }
- await this._calculateAddressFunctionRuntimeData(a2, u), await this._buildDirtyRangesByAddressFunction(a2, e);
- }
- async _calculateAddressFunctionRuntimeData(a2, e) {
- for (; e.length > 0; ) {
- const t = e.pop(), n = {
- node: this._getTreeNode(t),
- refOffsetX: t.refOffsetX,
- refOffsetY: t.refOffsetY
- };
- await this._calculateAddressFunction(a2, t), this._runtimeService.setCurrent(
- t.row,
- t.column,
- t.rowCount,
- t.columnCount,
- t.subUnitId,
- t.unitId
- );
- let s;
- this._interpreter.checkAsyncNode(n.node) ? s = await this._interpreter.executeAsync(n) : s = this._interpreter.execute(n), t.formulaId != null ? this._runtimeService.setRuntimeOtherData(t.formulaId, t.refOffsetX, t.refOffsetY, s) : this._runtimeService.setRuntimeData(s);
- }
- }
- _buildTreeNodeById(a2) {
- const e = [];
- for (const t of a2) {
- const r = this._getTreeById(t);
- !r || this._executedAddressFunctionNodeIds.has(t) || (this._executedAddressFunctionNodeIds.add(t), e.push(r));
- }
- return e;
- }
- _searchDependencyByAddressFunction(a2, e, t) {
- const r = a2.bulkSearch(e), n = this._dependencyRTreeCacheForAddressFunction.bulkSearch(e);
- for (const o of n)
- t.has(o) || t.add(o);
- const s = [];
- for (const o of r) {
- const u = this._getTreeById(o);
- u && !t.has(o) && (s.push(...u.rangeList), t.add(o));
- }
- return s.length > 0 && this._searchDependencyByAddressFunction(a2, s, t), t;
- }
- _getTreeById(a2) {
- return this._dependencyManagerService.getTreeById(a2);
- }
- _addDependencyTreeByAddressFunction(a2, e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- const n = e[r], { unitId: s, sheetId: o, range: u } = n;
- t.push({
- unitId: s,
- sheetId: o,
- range: u,
- id: a2.treeId
- });
- }
- this._dependencyRTreeCacheForAddressFunction.bulkInsert(t);
- }
- /**
- * Calculate the range required for collection in advance,
- * including references and location functions (such as OFFSET, INDIRECT, INDEX, etc.).
- * @param node
- */
- async _getRangeListByFunctionRefNode(a2, e, t) {
- const r = [];
- for (let n = 0, s = a2.length; n < s; n++) {
- const o = a2[n], c = (await this._executeNode(o, e, t)).toUnitRange();
- r.push(c), o.setValue(null);
- }
- return r;
- }
- /**
- * Build a formula dependency tree based on the dependency relationships.
- * @param treeList
- */
- _getUpdateTreeListAndMakeDependency(a2) {
- const e = [], t = /* @__PURE__ */ new Set(), r = this._currentConfigService.isForceCalculate(), n = this._currentConfigService.getDirtyRanges(), s = this._dependencyManagerService.searchDependency(n), o = this._dependencyRTreeCacheForAddressFunction.bulkSearch(n);
- for (const c of o)
- s.add(c);
- const u = this._dependencyManagerService.buildDependencyTree(a2);
- for (const c of u) {
- const l2 = c.treeId;
- (r || c.isDirty || c.dependencySheetName(this._currentConfigService.getDirtyNameMap()) || //O(n) n=tree.rangeList.length
- s.has(l2) && !c.isExcludeRange(this._currentConfigService.getExcludedRange())) && !t.has(l2) && (e.push(c), t.add(l2));
- }
- return e;
- }
- _includeTreeFeature(a2) {
- var n, s;
- const e = a2.unitId, t = a2.subUnitId, r = a2.featureId;
- if (r != null) {
- const o = this._currentConfigService.getDirtyUnitFeatureMap();
- if (((s = (n = o == null ? void 0 : o[e]) == null ? void 0 : n[t]) == null ? void 0 : s[r]) != null)
- return true;
- }
- return false;
- }
- _includeOtherFormula(a2) {
- var n, s;
- const e = a2.unitId, t = a2.subUnitId, r = a2.formulaId;
- if (r != null) {
- const o = this._currentConfigService.getDirtyUnitOtherFormulaMap();
- if (((s = (n = o == null ? void 0 : o[e]) == null ? void 0 : n[t]) == null ? void 0 : s[r]) != null)
- return true;
- }
- return false;
- }
- _detectForcedRecalculationNode(a2, e) {
- return e == null ? false : this._detectForcedRecalculationNodeRecursion(e);
- }
- _detectForcedRecalculationNodeRecursion(a2) {
- if (a2.isForcedCalculateFunction())
- return true;
- const e = a2.getChildren();
- for (let t = 0, r = e.length; t < r; t++) {
- const n = e[t];
- if (this._detectForcedRecalculationNodeRecursion(n))
- return true;
- }
- return false;
- }
- /**
- * Determine whether all ranges of the current node exist within the dirty area.
- * If they are within the dirty area, return true, indicating that this node needs to be calculated.
- * @param tree
- */
- _includeTree(a2, e) {
- var c, l2, f2;
- const t = a2.unitId, r = a2.subUnitId;
- if (this._detectForcedRecalculationNode(a2, e) === true || this._includeTreeFeature(a2) === true || this._includeOtherFormula(a2) === true || wh(a2, e, this._currentConfigService) === true)
- return true;
- const n = (l2 = (c = this._currentConfigService.getExcludedRange()) == null ? void 0 : c[t]) == null ? void 0 : l2[r];
- if ((n == null ? void 0 : n.getValue(a2.row, a2.column)) != null)
- return false;
- if (((f2 = this._currentConfigService.getDirtyNameMap()[t]) == null ? void 0 : f2[r]) != null)
- return true;
- if (!this._updateRangeFlattenCache.has(t))
- return false;
- const o = this._updateRangeFlattenCache.get(t);
- if (!o.has(r))
- return false;
- const u = o.get(r);
- for (const h of u)
- if (a2.inRangeData(h))
- return true;
- return false;
- }
- /**
- * Generate the final formula calculation order array by traversing the dependency tree established via depth-first search.
- * @param treeList
- */
- _calculateRunList(a2) {
- const e = a2, t = [], r = [];
- for (; e.length > 0; ) {
- const n = e.pop();
- if (n === void 0 || n.isSkip())
- continue;
- if (n.isAdded()) {
- t.push(n), n.setSkip();
- continue;
- }
- r.length = 0;
- for (const o of n.parents) {
- const u = this._dependencyManagerService.getTreeById(o);
- if (!u)
- throw new Error("ParentDependencyTree object is null");
- u.isAdded() || n.isSkip() || r.push(u);
- }
- const s = this._dependencyRTreeCacheForAddressFunction.bulkSearch(n.toRTreeItem());
- for (const o of s) {
- const u = this._dependencyManagerService.getTreeById(o);
- if (!u)
- throw new Error("ParentDependencyTree object is null");
- u.isAdded() || n.isSkip() || r.push(u);
- }
- r.length === 0 ? (t.push(n), n.setSkip()) : (n.setAdded(), e.push(n, ...r));
- }
- return t;
- }
- };
- Hs = Ph([
- wt(0, Ft),
- wt(1, Nt),
- wt(2, ya),
- wt(3, jr),
- wt(4, ot(Cr)),
- wt(5, ot(xr)),
- wt(6, ot(gr)),
- wt(7, Hn)
- ], Hs);
- var Lh = Object.defineProperty;
- var xh = Object.getOwnPropertyDescriptor;
- var jh = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? xh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Lh(a2, e, r), r;
- };
- var Qt = (i, a2) => (e, t) => a2(e, t, i);
- var Uh = 500;
- var Gs = Ct("engine-formula.calculate-formula.service");
- var Qs = class extends nt {
- constructor(a2, e, t, r, n, s, o) {
- super();
- A(this, "_executionInProgressListener$", new Subject());
- A(this, "executionInProgressListener$", this._executionInProgressListener$.asObservable());
- A(this, "_executionCompleteListener$", new Subject());
- A(this, "executionCompleteListener$", this._executionCompleteListener$.asObservable());
- this._configService = a2, this._lexer = e, this._currentConfigService = t, this._runtimeService = r, this._formulaDependencyGenerator = n, this._interpreter = s, this._astTreeBuilder = o;
- }
- /**
- * Stop the execution of the formula.
- */
- stopFormulaExecution() {
- this._runtimeService.stopExecution();
- }
- /**
- * When the feature is loading,
- * the pre-calculated content needs to be input to the formula engine in advance,
- * so that the formula can read the correct values.
- * @param featureId
- * @param featureData
- */
- setRuntimeFeatureCellData(a2, e) {
- this._runtimeService.setRuntimeFeatureCellData(a2, e);
- }
- setRuntimeFeatureRange(a2, e) {
- this._runtimeService.setRuntimeFeatureRange(a2, e);
- }
- async execute(a2) {
- this._runtimeService.setFormulaExecuteStage(ft.START), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()), this._currentConfigService.load(a2), this._runtimeService.reset();
- const e = a2.maxIteration || so;
- for (let t = 0; t < e && (this._runtimeService.setFormulaCycleIndex(t), await this._execute(), Bs.clear(), !!this._runtimeService.isCycleDependency()); t++)
- ;
- this._runtimeService.setFormulaExecuteStage(ft.CALCULATION_COMPLETED), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()), this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData()), St.clear(), this._runtimeService.reset();
- }
- async _execute() {
- const a2 = await this._apply();
- if (a2 == null)
- return;
- const { arrayFormulaRange: e, runtimeFeatureRange: t } = a2, { dirtyRanges: r, excludedCell: n } = this._getArrayFormulaDirtyRangeAndExcludedRange(
- e,
- t
- );
- return r == null || r.length === 0 || (this._currentConfigService.loadDirtyRangesAndExcludedCell(r, n), await this._apply(true)), true;
- }
- _getArrayFormulaDirtyRangeAndExcludedRange(a2, e) {
- const t = [], r = {};
- return Object.keys(a2).forEach((n) => {
- const s = a2[n];
- if (s == null)
- return true;
- Object.keys(s).forEach((o) => {
- const u = new kt(s[o]);
- if (u == null)
- return true;
- const c = new kt();
- u.forValue((l2, f2, h) => {
- c.setValue(l2, f2, true), t.push({ unitId: n, sheetId: o, range: h });
- }), r[n] == null && (r[n] = {}), r[n][o] = c;
- });
- }), Object.keys(e).forEach((n) => {
- const s = e[n];
- Object.keys(s).forEach((o) => {
- const u = s[o];
- if (u == null)
- return true;
- Object.keys(u).forEach((c) => {
- const l2 = u[c];
- if (l2 == null)
- return true;
- for (const f2 of l2)
- t.push({ unitId: o, sheetId: c, range: f2 });
- });
- });
- }), { dirtyRanges: t, excludedCell: r };
- }
- // eslint-disable-next-line max-lines-per-function
- async _apply(a2 = false) {
- a2 ? this._runtimeService.setFormulaExecuteStage(ft.START_DEPENDENCY_ARRAY_FORMULA) : this._runtimeService.setFormulaExecuteStage(ft.START_DEPENDENCY), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
- const e = (await this._formulaDependencyGenerator.generate()).reverse(), t = this._interpreter;
- a2 ? (this._runtimeService.setFormulaExecuteStage(ft.START_CALCULATION_ARRAY_FORMULA), this._runtimeService.setTotalArrayFormulasToCalculate(e.length)) : (this._runtimeService.setFormulaExecuteStage(ft.START_CALCULATION), this._runtimeService.setTotalFormulasToCalculate(e.length)), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
- let r = [];
- const n = this._configService.getConfig(fa), s = (n == null ? void 0 : n.intervalCount) || Uh, o = e.length;
- for (let u = 0; u < o; u++) {
- const c = e[u], l2 = c.nodeData, f2 = c.getDirtyData;
- if (u % s === 0 && (await new Promise((d2) => {
- const _ = SR(d2);
- r.push(_);
- }), a2 ? (this._runtimeService.setFormulaExecuteStage(
- ft.CURRENTLY_CALCULATING_ARRAY_FORMULA
- ), this._runtimeService.setCompletedArrayFormulasCount(u + 1)) : (this._runtimeService.setFormulaExecuteStage(ft.CURRENTLY_CALCULATING), this._runtimeService.setCompletedFormulasCount(u + 1)), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()), this._runtimeService.isStopExecution() || l2 == null && f2 == null)) {
- this._runtimeService.setFormulaExecuteStage(ft.IDLE), this._runtimeService.markedAsStopFunctionsExecuted(), this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData());
- return;
- }
- this._runtimeService.setCurrent(
- c.row,
- c.column,
- c.rowCount,
- c.columnCount,
- c.subUnitId,
- c.unitId
- );
- let h;
- if (f2 != null && c.featureId != null) {
- const { runtimeCellData: d2, dirtyRanges: _ } = f2(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData());
- this._runtimeService.setRuntimeFeatureCellData(c.featureId, d2), this._runtimeService.setRuntimeFeatureRange(c.featureId, _);
- } else
- l2 != null && (t.checkAsyncNode(l2.node) ? h = await t.executeAsync(l2) : h = t.execute(l2), c.formulaId != null ? this._runtimeService.setRuntimeOtherData(c.formulaId, c.refOffsetX, c.refOffsetY, h) : this._runtimeService.setRuntimeData(h));
- }
- return r.forEach((u) => u()), r = [], o > 0 ? this._runtimeService.markedAsSuccessfullyExecuted() : a2 || this._runtimeService.markedAsNoFunctionsExecuted(), this._runtimeService.getAllRuntimeData();
- }
- calculate(a2, e = true) {
- const t = this._lexer.treeBuilder(a2, e);
- if (Object.values(m2).includes(t))
- return xe.create(t);
- const r = this._astTreeBuilder.parse(t);
- r == null || r.serialize();
- }
- };
- Qs = jh([
- Qt(0, SE),
- Qt(1, ot(gr)),
- Qt(2, Ft),
- Qt(3, Nt),
- Qt(4, Ys),
- Qt(5, ot(Cr)),
- Qt(6, ot(xr))
- ], Qs);
- var vh = Object.defineProperty;
- var Th = Object.getOwnPropertyDescriptor;
- var Bh = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Th(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && vh(a2, e, r), r;
- };
- var ms = (i, a2) => (e, t) => a2(e, t, i);
- var Nn = class extends nt {
- constructor(i, a2, e) {
- super(), this._commandService = i, this._calculateFormulaService = a2, this._formulaDataModel = e, this._initialize();
- }
- _initialize() {
- this._commandExecutedListener(), this._initialExecuteFormulaListener();
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- if (i.id === zi.id)
- this._calculateFormulaService.stopFormulaExecution();
- else if (i.id === Zi.id) {
- const a2 = i.params;
- this._calculate(a2);
- } else if (i.id === bs.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const { arrayFormulaRange: e, arrayFormulaCellData: t } = a2;
- this._formulaDataModel.setArrayFormulaRange(e), this._formulaDataModel.setArrayFormulaCellData(t);
- }
- })
- );
- }
- async _calculate(i) {
- const { forceCalculation: a2 = false, dirtyRanges: e = [], dirtyNameMap: t = {}, dirtyDefinedNameMap: r = {}, dirtyUnitFeatureMap: n = {}, dirtyUnitOtherFormulaMap: s = {}, clearDependencyTreeCache: o = {}, maxIteration: u = so } = i, c = this._formulaDataModel.getFormulaData(), l2 = this._formulaDataModel.getArrayFormulaCellData(), f2 = this._formulaDataModel.getArrayFormulaRange();
- this._calculateFormulaService.execute({
- formulaData: c,
- arrayFormulaCellData: l2,
- arrayFormulaRange: f2,
- forceCalculate: a2,
- dirtyRanges: e,
- dirtyNameMap: t,
- dirtyDefinedNameMap: r,
- dirtyUnitFeatureMap: n,
- dirtyUnitOtherFormulaMap: s,
- clearDependencyTreeCache: o,
- maxIteration: u
- });
- }
- // Notification
- _initialExecuteFormulaListener() {
- this._calculateFormulaService.executionCompleteListener$.subscribe((i) => {
- const a2 = i.functionsExecutedState;
- switch (a2) {
- case wr.NOT_EXECUTED:
- break;
- case wr.STOP_EXECUTION:
- break;
- case wr.SUCCESS:
- this._applyResult(i);
- break;
- case wr.INITIAL:
- break;
- }
- this._commandService.executeCommand(
- Ns.id,
- {
- functionsExecutedState: a2
- },
- {
- onlyLocal: true
- }
- );
- }), this._calculateFormulaService.executionInProgressListener$.subscribe((i) => {
- this._commandService.executeCommand(
- Ns.id,
- {
- stageInfo: i
- },
- {
- onlyLocal: true
- }
- );
- });
- }
- async _applyResult(i) {
- const { unitData: a2, unitOtherData: e, arrayFormulaRange: t, arrayFormulaCellData: r, clearArrayFormulaCellData: n } = i;
- if (!a2) {
- console.error("No sheetData from Formula Engine!");
- return;
- }
- t && (this._formulaDataModel.clearPreviousArrayFormulaCellData(n), this._formulaDataModel.mergeArrayFormulaCellData(r), this._formulaDataModel.mergeArrayFormulaRange(t), this._commandService.executeCommand(
- bs.id,
- {
- arrayFormulaRange: this._formulaDataModel.getArrayFormulaRange(),
- arrayFormulaCellData: this._formulaDataModel.getArrayFormulaCellData()
- },
- {
- onlyLocal: true
- }
- )), this._commandService.executeCommand(
- Ji.id,
- {
- unitData: uc(a2),
- unitOtherData: e
- },
- {
- onlyLocal: true
- }
- );
- }
- };
- Nn = Bh([
- ms(0, Pt),
- ms(1, Gs),
- ms(2, ot(Pr))
- ], Nn);
- var Ni = /[\[\]]/g;
- function Oi(i, a2) {
- if (Ni.test(i)) {
- const e = Number(i.replace(Ni, ""));
- return a2 + e;
- }
- return Number(i) - 1;
- }
- function gs(i, a2 = 0, e = 0) {
- i = i.toLocaleUpperCase();
- const t = i.split(/[RC]/), r = t[1], n = t[2], s = Oi(r, a2), o = Oi(n, e);
- return {
- row: s,
- column: o,
- absoluteRefType: tt.NONE
- };
- }
- function Ih(i, a2 = 0, e = 0) {
- const { refBody: t, sheetName: r, unitId: n } = na(i), s = t.indexOf(":");
- if (s === -1) {
- const C = gs(t, a2, e), E2 = C.row, b = C.column, R = C.absoluteRefType;
- return {
- unitId: n,
- sheetName: r,
- range: {
- startRow: E2,
- startColumn: b,
- endRow: E2,
- endColumn: b,
- startAbsoluteRefType: R,
- endAbsoluteRefType: R
- }
- };
- }
- const o = t.substring(0, s), u = t.substring(s + 1), c = gs(o, a2, e), l2 = gs(u, a2, e), f2 = c.row, h = c.column, d2 = l2.row, _ = l2.column;
- return {
- unitId: n,
- sheetName: r,
- range: {
- startRow: f2,
- startColumn: h,
- endRow: d2,
- endColumn: _,
- startAbsoluteRefType: c.absoluteRefType,
- endAbsoluteRefType: l2.absoluteRefType
- }
- };
- }
- function Fh(i) {
- const a2 = qr(i.startRow, i.startAbsoluteRefType, true), e = qr(i.startColumn, i.startAbsoluteRefType, false), t = qr(i.endRow, i.endAbsoluteRefType, true), r = qr(i.endColumn, i.endAbsoluteRefType, false);
- return a2 === t && e === r ? `R${a2}C${e}` : `R${a2}C${e}:R${t}C${r}`;
- }
- function qr(i, a2 = tt.ALL, e) {
- switch (i += 1, a2) {
- case tt.ALL:
- return `${i}`;
- case tt.ROW:
- return e ? `${i}` : `[${i}]`;
- case tt.COLUMN:
- return e ? `[${i}]` : `${i}`;
- case tt.NONE:
- return `[${i}]`;
- }
- }
- function Xt(i) {
- let a2 = i;
- if (i.isArray()) {
- const e = i.getRowCount(), t = i.getColumnCount();
- if (e > 1 || t > 1)
- return g2.create(m2.VALUE);
- a2 = i.get(0, 0);
- }
- return a2.isError(), a2;
- }
- function Fr(...i) {
- for (let a2 = 0; a2 < i.length; a2++) {
- const e = Xt(i[a2]);
- if (e.isError())
- return {
- isError: true,
- errorObject: e
- };
- i[a2] = e;
- }
- return {
- isError: false,
- variants: i
- };
- }
- function H(...i) {
- for (let a2 = 0; a2 < i.length; a2++) {
- const e = Xt(i[a2]);
- if (e.isError())
- return {
- isError: true,
- errorObject: e
- };
- if (e.isBoolean())
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE)
- };
- i[a2] = e;
- }
- return {
- isError: false,
- variants: i
- };
- }
- function Fe2(...i) {
- for (let a2 = 0; a2 < i.length; a2++) {
- let e = i[a2];
- if (e.isError())
- return {
- isError: true,
- errorObject: e
- };
- if (e.isNull())
- return {
- isError: true,
- errorObject: g2.create(m2.NA)
- };
- if (e = Xt(i[a2]), e.isError())
- return {
- isError: true,
- errorObject: e
- };
- if (e.isBoolean())
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE)
- };
- i[a2] = e;
- }
- return {
- isError: false,
- variants: i
- };
- }
- function I2(...i) {
- for (let a2 = 0; a2 < i.length; a2++) {
- let e = i[a2];
- if (e.isString() && (e = e.convertToNumberObjectValue()), e.isError())
- return {
- isError: true,
- errorObject: e
- };
- i[a2] = e;
- }
- return {
- isError: false,
- variants: i
- };
- }
- var V = class {
- constructor(a2) {
- A(this, "_unitId");
- A(this, "_subUnitId");
- A(this, "_row", -1);
- A(this, "_column", -1);
- A(this, "_definedNames");
- A(this, "_locale");
- A(this, "_sheetOrder");
- A(this, "_sheetNameMap");
- A(this, "_formulaDataModel");
- A(this, "_rowCount", -1);
- A(this, "_columnCount", -1);
- A(this, "needsExpandParams", false);
- A(this, "needsReferenceObject", false);
- A(this, "needsLocale", false);
- A(this, "needsSheetsInfo", false);
- A(this, "needsFormulaDataModel", false);
- A(this, "needsSheetRowColumnCount", false);
- A(this, "minParams", -1);
- A(this, "maxParams", -1);
- this._name = a2;
- }
- get name() {
- return this._name;
- }
- get unitId() {
- return this._unitId;
- }
- get subUnitId() {
- return this._subUnitId;
- }
- get row() {
- return this._row;
- }
- get column() {
- return this._column;
- }
- dispose() {
- }
- /**
- * In Excel, to inject a defined name into a function that has positioning capabilities,
- * such as using the INDIRECT function to reference a named range,
- * you can write it as follows:
- * =INDIRECT("DefinedName1")
- */
- getDefinedName(a2) {
- var t;
- const e = this._definedNames;
- return e == null ? null : (t = Array.from(Object.values(e)).filter((r) => r.name === a2)) == null ? void 0 : t[0];
- }
- setDefinedNames(a2) {
- this._definedNames = a2;
- }
- getLocale() {
- return this._locale;
- }
- setLocale(a2) {
- this._locale = a2;
- }
- getSheetsInfo() {
- return {
- sheetOrder: this._sheetOrder,
- sheetNameMap: this._sheetNameMap
- };
- }
- setSheetsInfo({
- sheetOrder: a2,
- sheetNameMap: e
- }) {
- this._sheetOrder = a2, this._sheetNameMap = e;
- }
- setFormulaDataModel(a2) {
- this._formulaDataModel = a2;
- }
- setSheetRowColumnCount(a2, e) {
- this._rowCount = a2, this._columnCount = e;
- }
- isAsync() {
- return false;
- }
- isAddress() {
- return false;
- }
- isCustom() {
- return false;
- }
- setRefInfo(a2, e, t, r) {
- this._unitId = a2, this._subUnitId = e, this._row = t, this._column = r;
- }
- calculateCustom(...a2) {
- return null;
- }
- calculate(...a2) {
- return g2.create(m2.VALUE);
- }
- checkArrayType(a2) {
- return a2.isReferenceObject() || a2.isValueObject() && a2.isArray();
- }
- /**
- * Starting with 1
- * For instance, The column number (starting with 1 for the left-most column of table_array) that contains the return value.
- * https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
- * @param indexNum
- */
- getIndexNumValue(a2, e = 1) {
- let t = a2;
- if (t.isArray() && (t = t.getFirstCell()), t.isBoolean())
- return t.getValue() === false ? g2.create(m2.VALUE) : e;
- if (t.isString()) {
- const r = Number(t.getValue());
- return Number.isNaN(r) ? g2.create(m2.REF) : r;
- } else if (t.isNumber())
- return t.getValue();
- return g2.create(m2.VALUE);
- }
- /**
- * A logical value that specifies 1/TRUE , 0/FALSE, default 1
- * For instance range_lookup, A logical value that specifies whether you want VLOOKUP to find an approximate or an exact match
- * Approximate match - 1/TRUE
- * Exact match - 0/FALSE
- * https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
- * For instance A1, A logical value that specifies what type of reference is contained in the cell ref_text.
- * If a1 is TRUE or omitted, ref_text is interpreted as an A1-style reference.
- * If a1 is FALSE, ref_text is interpreted as an R1C1-style reference.
- * https://support.microsoft.com/zh-cn/office/indirect-%E5%87%BD%E6%95%B0-474b3a3a-8a26-4f44-b491-92b6306fa261
- * @param logicValueObject
- */
- getZeroOrOneByOneDefault(a2) {
- if (a2 == null)
- return 1;
- let e = 1;
- if (a2.isArray() && (a2 = a2.getFirstCell()), a2.isBoolean())
- a2.getValue() === false && (e = 0);
- else {
- if (a2.isString())
- return;
- a2.isNumber() && a2.getValue() === 0 && (e = 0);
- }
- return e;
- }
- /**
- * A logical value that specifies 1/TRUE , 0/FALSE, -1, default 1.
- * The difference from getZeroOrOneByOneDefault is that we need to get -1
- * @param logicValueObject
- */
- getMatchTypeValue(a2) {
- if (a2 == null)
- return 1;
- let e = 1;
- if (a2.isArray() && (a2 = a2.getFirstCell()), a2.isBoolean())
- a2.getValue() === false && (e = 0);
- else {
- if (a2.isString())
- return;
- if (a2.isNumber()) {
- const t = a2.getValue();
- t <= 0 && (e = t);
- }
- }
- return e;
- }
- binarySearch(a2, e, t, r, n) {
- const s = e.binarySearch(a2, r, n);
- if (s == null)
- return g2.create(m2.NA);
- let o;
- return t.getRowCount() === 1 ? o = t.get(0, s) || ie.create() : o = t.get(s, 0) || ie.create(), o.isNull() ? y2.create(0) : o;
- }
- _getOneFirstByRaw(a2) {
- return a2.length === 0 ? g2.create(m2.NA) : a2[0][0] || g2.create(m2.NA);
- }
- _getOneLastByRaw(a2) {
- return a2.length === 0 ? g2.create(m2.NA) : a2[a2.length - 1][a2[0].length - 1] || g2.create(m2.NA);
- }
- equalSearch(a2, e, t, r = true) {
- const n = t.pickRaw(e.isEqual(a2));
- return r ? this._getOneFirstByRaw(n) : this._getOneLastByRaw(n);
- }
- fuzzySearch(a2, e, t, r = true) {
- const n = t.pickRaw(e.compare(a2, $.EQUALS));
- return r ? this._getOneFirstByRaw(n) : this._getOneLastByRaw(n);
- }
- orderSearch(a2, e, t, r = Pe.MIN, n = false) {
- const s = e.orderSearch(a2, r, n);
- if (s == null)
- return g2.create(m2.NA);
- const o = t.get(s.row, s.column) || ie.create();
- return o.isNull() ? g2.create(m2.NA) : o;
- }
- binarySearchExpand(a2, e, t, r = 0, n, s) {
- const o = e.binarySearch(a2, n, s);
- return o == null ? g2.create(m2.NA) : r === 0 ? t.slice([o, o + 1]) : t.slice(void 0, [o, o + 1]);
- }
- equalSearchExpand(a2, e, t, r = true, n = 0) {
- const s = e.isEqual(a2);
- let o;
- return r ? o = s.getFirstTruePosition() : o = s.getLastTruePosition(), o == null ? g2.create(m2.NA) : n === 0 ? t.slice([o.row, o.row + 1]) : t.slice(void 0, [o.column, o.column + 1]);
- }
- fuzzySearchExpand(a2, e, t, r = true, n = 0) {
- const s = e.compare(a2, $.EQUALS);
- let o;
- return r ? o = s.getFirstTruePosition() : o = s.getLastTruePosition(), o == null ? g2.create(m2.NA) : n === 0 ? t.slice([o.row, o.row + 1]) : t.slice(void 0, [o.column, o.column + 1]);
- }
- orderSearchExpand(a2, e, t, r = Pe.MIN, n = false, s = 0) {
- const o = e.orderSearch(a2, r, n);
- return o == null ? g2.create(m2.NA) : s === 0 ? t.slice([o.row, o.row + 1]) : t.slice(void 0, [o.column, o.column + 1]);
- }
- flattenArray(a2, e = true) {
- const t = [];
- t[0] = [];
- for (let r = 0; r < a2.length; r++) {
- let n = a2[r];
- if ((n.isString() || n.isBoolean() || n.isNull()) && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- if (n.isArray()) {
- let s;
- if (n.iterator((o) => {
- if (o == null || o.isNull() || e && (o.isString() || o.isBoolean()))
- return true;
- if (o = this._includingLogicalValuesAndText(o), o.isError())
- return s = o, false;
- t[0].push(o);
- }), s != null && s.isError())
- return s;
- } else
- t[0].push(n);
- }
- return tr(t, 1, t[0].length);
- }
- _includingLogicalValuesAndText(a2) {
- if (a2.isBoolean() && (a2 = wf(a2)), a2.isString()) {
- const e = Number(a2.getValue());
- a2 = y2.create(Number.isNaN(e) ? 0 : e);
- }
- return a2;
- }
- createReferenceObject(a2, e) {
- const t = a2.getForcedUnitId(), r = a2.getForcedSheetId() || "", n = a2.getForcedSheetName(), o = ys({
- unitId: t,
- sheetName: n,
- range: e
- });
- let u;
- return vr(o) ? u = new da(o) : Qi(o) ? u = new _a(o) : Wi(o) ? u = new Ca(o) : u = new Cn(e, r, t), this._setReferenceDefault(a2, u);
- }
- _setReferenceDefault(a2, e) {
- return this.unitId == null || this.subUnitId == null ? g2.create(m2.REF) : (e.setDefaultUnitId(this.unitId), e.setDefaultSheetId(this.subUnitId), e.setUnitData(a2.getUnitData()), e.setRuntimeData(a2.getRuntimeData()), e.setArrayFormulaCellData(a2.getArrayFormulaCellData()), e.setRuntimeArrayFormulaCellData(a2.getRuntimeArrayFormulaCellData()), e);
- }
- };
- var kh = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isError())
- return e;
- const { isError: n, errorObject: s, variants: o } = Fr(t, r);
- if (n)
- return s;
- const { isError: u, errorObject: c, variants: l2 } = I2(...o);
- if (u)
- return c;
- const [f2, h] = l2, d2 = Math.floor(+f2.getValue()), _ = Math.floor(+h.getValue());
- if (d2 < 0 || _ < 0)
- return g2.create(m2.NUM);
- if (d2 === 0 || _ === 0)
- return g2.create(m2.REF);
- const C = e.isArray() ? e.getRowCount() : 1, E2 = e.isArray() ? e.getColumnCount() : 1;
- if (C === 1 && E2 === 1)
- return e.isArray() ? e.get(0, 0) : e;
- const b = d2 > C ? C : d2, R = _ > E2 ? E2 : _;
- return e.slice([0, b], [0, R]);
- }
- };
- var $h = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- const n = e[r], s = n.isArray() ? n.getRowCount() : 1, o = n.isArray() ? n.getColumnCount() : 1;
- for (let u = 0; u < s; u++)
- for (let c = 0; c < o; c++) {
- const l2 = n.isArray() ? n.get(u, c) : n;
- t.push([l2]);
- }
- }
- return q2.create({
- calculateValueList: t,
- rowCount: t.length,
- columnCount: 1,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- };
- var Ws = ((i) => (i.ARRAY_CONSTRAIN = "ARRAY_CONSTRAIN", i.FLATTEN = "FLATTEN", i))(Ws || {});
- var Yh = [
- [kh, Ws.ARRAY_CONSTRAIN],
- [$h, Ws.FLATTEN]
- ];
- var _r;
- ((i) => {
- const a2 = 0.636619772;
- function e(n, s) {
- let o = 0;
- for (let u = 0; u < n.length; ++u)
- o = s * o + n[u];
- return o;
- }
- function t(n, s, o, u, c) {
- if (s === 0)
- return o;
- if (s === 1)
- return u;
- const l2 = 2 / n;
- let f2 = o, h = u, d2 = u;
- for (let _ = 1; _ < s; ++_)
- d2 = h * _ * l2 + c * f2, f2 = h, h = d2;
- return d2;
- }
- function r(n, s, o, u) {
- return function(l2, f2) {
- if (o) {
- if (l2 === 0)
- return o === 1 ? -1 / 0 : 1 / 0;
- if (l2 < 0)
- return Number.NaN;
- }
- if (f2 === 0)
- return n(l2);
- if (f2 === 1)
- return s(l2);
- if (f2 < 0)
- return Number.NaN;
- const h = f2 | 0, d2 = n(l2), _ = s(l2);
- return t(l2, h, d2, _, u);
- };
- }
- i.besselj = (() => {
- const n = [-184.9052456, 77392.33017, -1121442418e-2, 6516196407e-1, -13362590354, 57568490574], s = [1, 267.8532712, 59272.64853, 9494680718e-3, 1029532985, 57568490411], o = [2093887211e-16, -2073370639e-15, 2734510407e-14, -0.001098628627, 1], u = [-934935152e-16, 7621095161e-16, -6911147651e-15, 1430488765e-13, -0.01562499995];
- function c(C) {
- let E2 = 0, b = 0, R = 0, p2 = C * C;
- if (C < 8)
- b = e(n, p2), R = e(s, p2), E2 = b / R;
- else {
- const N2 = C - 0.785398164;
- p2 = 64 / p2, b = e(o, p2), R = e(u, p2), E2 = Math.sqrt(a2 / C) * (Math.cos(N2) * b - Math.sin(N2) * R * 8 / C);
- }
- return E2;
- }
- const l2 = [-30.16036606, 15704.4826, -2972611439e-3, 2423968531e-1, -7895059235, 72362614232], f2 = [1, 376.9991397, 99447.43394, 1858330474e-2, 2300535178, 144725228442], h = [-240337019e-15, 2457520174e-15, -3516396496e-14, 183105e-8, 1], d2 = [105787412e-15, -88228987e-14, 8449199096e-15, -2002690873e-13, 0.04687499995];
- function _(C) {
- let E2 = 0, b = 0, R = 0, p2 = C * C;
- const N2 = Math.abs(C) - 2.356194491;
- return Math.abs(C) < 8 ? (b = C * e(l2, p2), R = e(f2, p2), E2 = b / R) : (p2 = 64 / p2, b = e(h, p2), R = e(d2, p2), E2 = Math.sqrt(a2 / Math.abs(C)) * (Math.cos(N2) * b - Math.sin(N2) * R * 8 / Math.abs(C)), C < 0 && (E2 = -E2)), E2;
- }
- return function C(E2, b) {
- const R = Math.round(b);
- if (!Number.isFinite(E2))
- return Number.isNaN(E2) ? E2 : 0;
- if (R < 0)
- return (R % 2 ? -1 : 1) * C(E2, -R);
- if (E2 < 0)
- return (R % 2 ? -1 : 1) * C(-E2, R);
- if (R === 0)
- return c(E2);
- if (R === 1)
- return _(E2);
- if (E2 === 0)
- return 0;
- let p2 = 0;
- if (E2 > R)
- p2 = t(E2, R, c(E2), _(E2), -1);
- else {
- const N2 = 2 * Math.floor((R + Math.floor(Math.sqrt(40 * R))) / 2);
- let M2 = false, w = 0, D2 = 0, S2 = 1, P = 0;
- const U2 = 2 / E2;
- for (let x2 = N2; x2 > 0; x2--)
- if (P = x2 * U2 * S2 - w, w = S2, S2 = P, Math.abs(S2) > 1e10 && (S2 *= 1e-10, w *= 1e-10, p2 *= 1e-10, D2 *= 1e-10), M2 && (D2 += S2), M2 = !M2, x2 === R && (p2 = w), N2 - x2 > 100 && p2 === 0)
- return Number.NaN;
- D2 = 2 * D2 - S2, p2 /= D2;
- }
- return p2;
- };
- })(), i.bessely = (() => {
- const n = [228.4622733, -86327.92757, 1087988129e-2, -5123598036e-1, 7062834065, -2957821389], s = [1, 226.1030244, 47447.2647, 7189466438e-3, 7452499648e-1, 40076544269], o = [2093887211e-16, -2073370639e-15, 2734510407e-14, -0.001098628627, 1], u = [-934945152e-16, 7621095161e-16, -6911147651e-15, 1430488765e-13, -0.01562499995];
- function c(C) {
- let E2 = 0, b = 0, R = 0, p2 = C * C;
- const N2 = C - 0.785398164;
- return C < 8 ? (b = e(n, p2), R = e(s, p2), E2 = b / R + a2 * (0, i.besselj)(C, 0) * Math.log(C)) : (p2 = 64 / p2, b = e(o, p2), R = e(u, p2), E2 = Math.sqrt(a2 / C) * (Math.sin(N2) * b + Math.cos(N2) * R * 8 / C)), E2;
- }
- const l2 = [8511.937935, -4237922726e-3, 7349264551e-1, -51534381390, 127527439e4, -4900604943e3], f2 = [1, 354.9632885, 102042.605, 2245904002e-2, 3733650367, 424441966400, 249958057e5], h = [-240337019e-15, 2457520174e-15, -3516396496e-14, 183105e-8, 1], d2 = [105787412e-15, -88228987e-14, 8449199096e-15, -2002690873e-13, 0.04687499995];
- function _(C) {
- let E2 = 0, b = 0, R = 0, p2 = C * C;
- const N2 = C - 2.356194491;
- return C < 8 ? (b = C * e(l2, p2), R = e(f2, p2), E2 = b / R + a2 * ((0, i.besselj)(C, 1) * Math.log(C) - 1 / C)) : (p2 = 64 / p2, b = e(h, p2), R = e(d2, p2), E2 = Math.sqrt(a2 / C) * (Math.sin(N2) * b + Math.cos(N2) * R * 8 / C)), E2;
- }
- return r(c, _, 1, -1);
- })(), i.besseli = (() => {
- const n = [45813e-7, 0.0360768, 0.2659732, 1.2067492, 3.0899424, 3.5156229, 1], s = [392377e-8, -0.01647633, 0.02635537, -0.02057706, 916281e-8, -157565e-8, 225319e-8, 0.01328592, 0.39894228];
- function o(f2) {
- return f2 <= 3.75 ? e(n, f2 * f2 / (3.75 * 3.75)) : Math.exp(Math.abs(f2)) / Math.sqrt(Math.abs(f2)) * e(s, 3.75 / Math.abs(f2));
- }
- const u = [32411e-8, 301532e-8, 0.02658733, 0.15084934, 0.51498869, 0.87890594, 0.5], c = [-420059e-8, 0.01787654, -0.02895312, 0.02282967, -0.01031555, 163801e-8, -362018e-8, -0.03988024, 0.39894228];
- function l2(f2) {
- return f2 < 3.75 ? f2 * e(u, f2 * f2 / (3.75 * 3.75)) : (f2 < 0 ? -1 : 1) * Math.exp(Math.abs(f2)) / Math.sqrt(Math.abs(f2)) * e(c, 3.75 / Math.abs(f2));
- }
- return function f2(h, d2) {
- const _ = Math.round(d2);
- if (_ === 0)
- return o(h);
- if (_ === 1)
- return l2(h);
- if (_ < 0)
- return Number.NaN;
- if (Math.abs(h) === 0)
- return 0;
- if (h === 1 / 0)
- return 1 / 0;
- let C = 0, E2;
- const b = 2 / Math.abs(h);
- let R = 0, p2 = 1, N2 = 0;
- const M2 = 2 * Math.round((_ + Math.round(Math.sqrt(40 * _))) / 2);
- for (E2 = M2; E2 > 0; E2--)
- if (N2 = E2 * b * p2 + R, R = p2, p2 = N2, Math.abs(p2) > 1e10 && (p2 *= 1e-10, R *= 1e-10, C *= 1e-10), E2 === _ && (C = R), M2 - E2 > 100 && C === 0)
- return Number.NaN;
- return C *= f2(h, 0) / p2, h < 0 && _ % 2 ? -C : C;
- };
- })(), i.besselk = (() => {
- const n = [74e-7, 1075e-7, 262698e-8, 0.0348859, 0.23069756, 0.4227842, -0.57721566], s = [53208e-8, -25154e-7, 587872e-8, -0.01062446, 0.02189568, -0.07832358, 1.25331414];
- function o(f2) {
- return f2 <= 2 ? -Math.log(f2 / 2) * (0, i.besseli)(f2, 0) + e(n, f2 * f2 / 4) : Math.exp(-f2) / Math.sqrt(f2) * e(s, 2 / f2);
- }
- const u = [-4686e-8, -110404e-8, -0.01919402, -0.18156897, -0.67278579, 0.15443144, 1], c = [-68245e-8, 325614e-8, -780353e-8, 0.01504268, -0.0365562, 0.23498619, 1.25331414];
- function l2(f2) {
- return f2 <= 2 ? Math.log(f2 / 2) * (0, i.besseli)(f2, 1) + 1 / f2 * e(u, f2 * f2 / 4) : Math.exp(-f2) / Math.sqrt(f2) * e(c, 2 / f2);
- }
- return r(o, l2, 2, 1);
- })();
- })(_r || (_r = {}));
- function Ra2(i) {
- return /^[01]{1,10}$/.test(i);
- }
- function pa(i) {
- return /^[0-7]{1,10}$/.test(i);
- }
- function Va(i) {
- return /^[0-9A-Fa-f]{1,10}$/.test(i);
- }
- function Zt(i) {
- if (i === 0)
- return 0;
- const a2 = [
- -1.3026537197817094,
- 0.6419697923564902,
- 0.019476473204185836,
- -0.00956151478680863,
- -946595344482036e-18,
- 366839497852761e-18,
- 42523324806907e-18,
- -20278578112534e-18,
- -1624290004647e-18,
- 130365583558e-17,
- 15626441722e-18,
- -85238095915e-18,
- 6529054439e-18,
- 5059343495e-18,
- -991364156e-18,
- -227365122e-18,
- 96467911e-18,
- 2394038e-18,
- -6886027e-18,
- 894487e-18,
- 313092e-18,
- -112708e-18,
- 381e-18,
- 7106e-18,
- -1523e-18,
- -94e-18,
- 121e-18,
- -28e-18
- ];
- let e = i, t = false;
- e < 0 && (e = -e, t = true);
- const r = 2 / (2 + e), n = 4 * r - 2;
- let s = 0, o = 0, u;
- for (let l2 = a2.length - 1; l2 > 0; l2--)
- u = s, s = n * s - o + a2[l2], o = u;
- const c = r * Math.exp(-e * e + 0.5 * (a2[0] + n * s) - o);
- return t ? c - 1 : 1 - c;
- }
- function Na(i) {
- return 1 - Zt(i);
- }
- function Hh(i) {
- if (i >= 2)
- return -100;
- if (i <= 0)
- return 100;
- const a2 = i < 1 ? i : 2 - i, e = Math.sqrt(-2 * Math.log(a2 / 2));
- let t = -0.70711 * ((2.30753 + e * 0.27061) / (1 + e * (0.99229 + e * 0.04481)) - e);
- for (let r = 0; r < 2; r++) {
- const n = Na(t) - a2;
- t += n / (1.1283791670955126 * Math.exp(-t * t) - t * n);
- }
- return i < 1 ? t : -t;
- }
- function cr(i, a2 = 1) {
- let e = Math.floor(i);
- if (i < 0)
- return Number.NaN;
- let t = 1;
- for (; e > 1 && Number.isFinite(t); )
- t *= e, e -= a2;
- return t;
- }
- function zt(i, a2) {
- const e = Math.min(i - a2, a2);
- let t = 1;
- for (let r = 1; r <= e && Number.isFinite(t); r++)
- t *= i - r + 1, t /= r;
- return t;
- }
- function qs(i, a2) {
- let e = Math.floor(i), t = Math.floor(a2);
- for (; t !== 0; ) {
- const r = t;
- t = e % t, e = r;
- }
- return e;
- }
- function Mi(i, a2) {
- const e = qs(i, a2);
- return e === 0 ? 0 : Math.abs(i * a2) / e;
- }
- function Gn(i) {
- const a2 = i.length;
- if (a2 === 1)
- return i[0][0];
- if (a2 === 2)
- return i[0][0] * i[1][1] - i[0][1] * i[1][0];
- let e = 0;
- for (let t = 0; t < a2; t++)
- e += (t % 2 === 0 ? 1 : -1) * i[0][t] * Gn(wo(i, 0, t));
- return e;
- }
- function Gh(i) {
- const a2 = Gn(i);
- return a2 === 0 ? null : i.length === 1 ? [[1 / a2]] : Qh(i).map((r) => r.map((n) => n / a2));
- }
- function wo(i, a2, e) {
- return i.filter((t, r) => r !== a2).map((t) => t.filter((r, n) => n !== e));
- }
- function Qh(i) {
- const a2 = i.length, e = Array.from({ length: a2 }, () => new Array(a2).fill(0));
- for (let t = 0; t < a2; t++)
- for (let r = 0; r < a2; r++) {
- const n = (t + r) % 2 === 0 ? 1 : -1;
- e[r][t] = n * Gn(wo(i, t, r));
- }
- return e;
- }
- function lr(i, a2) {
- return i.map((e) => a2[0].map(
- (t, r) => e.reduce((n, s, o) => n + s * a2[o][r], 0)
- ));
- }
- function mt(i) {
- return i[0].map((a2, e) => i.map((t) => t[e]));
- }
- function Wh(i) {
- const { smallPivotDetected: a2, luMatrix: e, permutation: t } = qh(i);
- return a2 ? null : Kh(e, t);
- }
- function qh(i) {
- const a2 = mt(i), e = a2.length, t = a2[0].length;
- let r = true, n = false;
- const s = Ks(e, t, 0), o = new Array(t).fill(0).map((u, c) => c);
- for (let u = 0; u < t; u++) {
- for (let h = 0; h < u; h++) {
- let d2 = a2[h][u];
- for (let _ = 0; _ < h; _++)
- d2 -= s[h][_] * s[_][u];
- s[h][u] = d2;
- }
- let c = -1 / 0, l2 = u;
- for (let h = u; h < e; h++) {
- let d2 = a2[h][u];
- for (let C = 0; C < u; C++)
- d2 -= s[h][C] * s[C][u];
- s[h][u] = d2;
- const _ = Math.abs(d2);
- _ > c && (c = _, l2 = h);
- }
- if (Math.abs(s[l2][u]) < 1e-11) {
- n = true;
- break;
- }
- l2 !== u && ([s[u], s[l2]] = [s[l2], s[u]], [a2[u], a2[l2]] = [a2[l2], a2[u]], [o[u], o[l2]] = [o[l2], o[u]], r = !r);
- const f2 = s[u][u];
- for (let h = u + 1; h < e; h++)
- s[h][u] /= f2;
- }
- return {
- rowSwap: r,
- smallPivotDetected: n,
- luMatrix: s,
- permutation: o
- };
- }
- function Kh(i, a2) {
- const e = a2.length, t = Ks(e, e, 0);
- for (let n = 0; n < e; n++)
- t[n][n] = 1;
- const r = Ks(e, e, 0);
- for (let n = 0; n < e; n++) {
- const s = a2[n];
- for (let o = 0; o < e; o++)
- r[n][o] = t[s][o];
- }
- for (let n = 0; n < e; n++) {
- const s = r[n];
- for (let o = n + 1; o < e; o++) {
- const u = i[o][n];
- for (let c = 0; c < e; c++)
- r[o][c] -= s[c] * u;
- }
- }
- for (let n = e - 1; n >= 0; n--) {
- const s = r[n], o = i[n][n];
- for (let u = 0; u < e; u++)
- s[u] /= o;
- for (let u = 0; u < n; u++) {
- const c = i[u][n];
- for (let l2 = 0; l2 < e; l2++)
- r[u][l2] -= s[l2] * c;
- }
- }
- return r;
- }
- function Ks(i, a2, e) {
- const t = [];
- for (let r = 0; r < i; r++) {
- t[r] = [];
- for (let n = 0; n < a2; n++)
- t[r].push(e);
- }
- return t;
- }
- function Xh(i) {
- const a2 = Zh(i);
- if (!a2)
- return null;
- const { matrixU: e, matrixS: t, matrixV: r } = a2, n = mt(e), s = Array.from({ length: t.length }, () => new Array(i[0].length).fill(0)), o = Math.max(i.length, i[0].length) * Number.EPSILON * t[0];
- for (let u = 0; u < t.length; u++)
- Math.abs(t[u]) > o && (s[u][u] = 1 / t[u]);
- return lr(r, lr(s, n));
- }
- function Zh(i) {
- const a2 = mt(i), e = a2.length, t = a2[0].length;
- if (e < t)
- return null;
- const r = new Array(t).fill(0), n = new Array(t).fill(0), s = Array.from({ length: t }, () => new Array(t).fill(0));
- let o = Number.EPSILON, u = 0, c = 0, l2 = 0;
- for (let C = 0; C < t; C++) {
- if (r[C] = u, c = ds(a2, C, e, C, C), c <= 1e-64 / o)
- u = 0;
- else {
- u = Math.sqrt(c), a2[C][C] >= 0 && (u = -u);
- const b = a2[C][C] * u - c;
- a2[C][C] -= u;
- for (let R = C + 1; R < t; R++) {
- c = ds(a2, C, e, C, R);
- for (let p2 = C; p2 < e; p2++)
- a2[p2][R] += c / b * a2[p2][C];
- }
- }
- if (n[C] = u, c = wi(a2, C + 1, t, C, C), c <= 1e-64 / o)
- u = 0;
- else {
- u = Math.sqrt(c), a2[C][C + 1] >= 0 && (u = -u);
- const b = a2[C][C + 1] * u - c;
- a2[C][C + 1] -= u;
- for (let R = C + 1; R < t; R++)
- r[R] = a2[C][R] / b;
- for (let R = C + 1; R < e; R++) {
- c = wi(a2, C + 1, t, R, C);
- for (let p2 = C + 1; p2 < t; p2++)
- a2[R][p2] += c * r[p2];
- }
- }
- const E2 = Math.abs(n[C]) + Math.abs(r[C]);
- E2 > l2 && (l2 = E2);
- }
- let f2 = 0;
- for (let C = t - 1; C >= 0; C--) {
- if (u !== 0) {
- for (let E2 = f2; E2 < t; E2++)
- s[E2][C] = a2[C][E2] / (u * a2[C][C + 1]);
- for (let E2 = f2; E2 < t; E2++) {
- c = 0;
- for (let b = f2; b < t; b++)
- c += a2[C][b] * s[b][E2];
- for (let b = f2; b < t; b++)
- s[b][E2] += c * s[b][C];
- }
- }
- for (let E2 = f2; E2 < t; E2++)
- s[C][E2] = 0, s[E2][C] = 0;
- s[C][C] = 1, u = r[C], f2 = C;
- }
- for (let C = t - 1; C >= 0; C--) {
- u = n[C];
- for (let E2 = C + 1; E2 < t; E2++)
- a2[C][E2] = 0;
- if (u !== 0) {
- for (let E2 = C + 1; E2 < t; E2++) {
- c = ds(a2, C + 1, e, C, E2);
- for (let b = C; b < e; b++)
- a2[b][E2] += c / (a2[C][C] * u) * a2[b][C];
- }
- for (let E2 = C; E2 < e; E2++)
- a2[E2][C] /= u;
- } else
- for (let E2 = C; E2 < e; E2++)
- a2[E2][C] = 0;
- a2[C][C] += 1;
- }
- o *= l2;
- let h = 0, d2 = 0, _ = 0;
- for (let C = t - 1; C >= 0; C--)
- for (let E2 = 0; E2 < 50; E2++) {
- let b = false, R = C;
- for (; R >= 0; R--) {
- if (Math.abs(r[R]) <= o) {
- b = true;
- break;
- }
- if (Math.abs(n[R - 1]) <= o)
- break;
- }
- if (!b) {
- let w = 0, D2 = 1;
- for (let S2 = R; S2 < C + 1 && (h = D2 * r[S2], d2 = n[S2], r[S2] *= w, !(Math.abs(h) <= o)); S2++) {
- _ = Kr(h, d2), n[S2] = _, w = d2 / _, D2 = -h / _;
- for (let P = 0; P < e; P++) {
- const U2 = a2[P][R - 1], x2 = a2[P][S2];
- a2[P][R - 1] = U2 * w + x2 * D2, a2[P][S2] = -U2 * D2 + x2 * w;
- }
- }
- }
- if (R === C) {
- if (n[C] < 0) {
- n[C] = -n[C];
- for (let w = 0; w < t; w++)
- s[w][C] = -s[w][C];
- }
- break;
- }
- if (E2 >= 49)
- return null;
- let p2 = n[R];
- h = ((n[C - 1] - n[C]) * (n[C - 1] + n[C]) + (r[C - 1] - r[C]) * (r[C - 1] + r[C])) / (2 * r[C] * n[C - 1]), _ = Kr(h, 1), h < 0 ? h = ((p2 - n[C]) * (p2 + n[C]) + r[C] * (n[C - 1] / (h - _) - r[C])) / p2 : h = ((p2 - n[C]) * (p2 + n[C]) + r[C] * (n[C - 1] / (h + _) - r[C])) / p2;
- let N2 = 1, M2 = 1;
- for (let w = R + 1; w < C + 1; w++) {
- let D2 = r[w], S2 = n[w];
- d2 = M2 * D2, D2 *= N2, _ = Kr(h, d2), r[w - 1] = _, N2 = h / _, M2 = d2 / _, h = p2 * N2 + D2 * M2, d2 = S2 * M2, D2 = -p2 * M2 + D2 * N2, S2 *= N2;
- for (let P = 0; P < t; P++) {
- const U2 = s[P][w - 1], x2 = s[P][w];
- s[P][w - 1] = U2 * N2 + x2 * M2, s[P][w] = -U2 * M2 + x2 * N2;
- }
- _ = Kr(h, d2), n[w - 1] = _, N2 = h / _, M2 = d2 / _, h = N2 * D2 + M2 * S2, p2 = -M2 * D2 + N2 * S2;
- for (let P = 0; P < e; P++) {
- const U2 = a2[P][w - 1], x2 = a2[P][w];
- a2[P][w - 1] = U2 * N2 + x2 * M2, a2[P][w] = -U2 * M2 + x2 * N2;
- }
- }
- r[R] = 0, r[C] = h, n[C] = p2;
- }
- for (let C = 0; C < n.length; C++)
- n[C] < o && (n[C] = 0);
- for (let C = 0; C < t; C++)
- for (let E2 = C - 1; E2 >= 0; E2--)
- if (n[E2] < n[C]) {
- const b = n[E2];
- n[E2] = n[C], n[C] = b;
- for (let R = 0; R < a2.length; R++) {
- const p2 = a2[R][C];
- a2[R][C] = a2[R][E2], a2[R][E2] = p2;
- }
- for (let R = 0; R < s.length; R++) {
- const p2 = s[R][C];
- s[R][C] = s[R][E2], s[R][E2] = p2;
- }
- C = E2;
- }
- return {
- matrixU: a2,
- matrixS: n,
- matrixV: s
- };
- }
- function Kr(i, a2) {
- let e = 0;
- return Math.abs(i) > Math.abs(a2) ? (e = a2 / i, Math.abs(i) * Math.sqrt(1 + e * e)) : a2 !== 0 ? (e = i / a2, Math.abs(a2) * Math.sqrt(1 + e * e)) : 0;
- }
- function ds(i, a2, e, t, r) {
- let n = 0;
- for (let s = a2; s < e; s++)
- n += i[s][t] * i[s][r];
- return n;
- }
- function wi(i, a2, e, t, r) {
- let n = 0;
- for (let s = a2; s < e; s++)
- n += i[t][s] * i[r][s];
- return n;
- }
- var Xr = /* @__PURE__ */ new Map([
- ["I", 1],
- ["V", 5],
- ["X", 10],
- ["L", 50],
- ["C", 100],
- ["D", 500],
- ["M", 1e3]
- ]);
- var zh = /* @__PURE__ */ new Map([
- [1, "I"],
- [4, "IV"],
- [5, "V"],
- [9, "IX"],
- [10, "X"],
- [40, "XL"],
- [45, "VL"],
- [49, "IL"],
- [50, "L"],
- [90, "XC"],
- [95, "VC"],
- [99, "IC"],
- [100, "C"],
- [400, "CD"],
- [450, "LD"],
- [490, "XD"],
- [495, "VD"],
- [499, "ID"],
- [500, "D"],
- [900, "CM"],
- [950, "LM"],
- [990, "XM"],
- [995, "VM"],
- [999, "IM"],
- [1e3, "M"]
- ]);
- var Jh = [
- [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1e3, 4e3],
- [1, 4, 5, 9, 10, 40, 45, 50, 90, 95, 100, 400, 450, 500, 900, 950, 1e3, 4e3],
- [1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 500, 900, 950, 990, 1e3, 4e3],
- [1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 495, 500, 900, 950, 990, 995, 1e3, 4e3],
- [1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 495, 499, 500, 900, 950, 990, 995, 999, 1e3, 4e3]
- ];
- function Do(i, a2, e) {
- return i <= 0 ? 0 : i >= 1 ? 1 : Qn(i, a2, e);
- }
- function em(i, a2, e) {
- return i <= 0 || i >= 1 ? 0 : a2 === 1 && e === 1 ? 1 : a2 < 512 && e < 512 ? i ** (a2 - 1) * (1 - i) ** (e - 1) / Ma(a2, e) : Math.exp((a2 - 1) * Math.log(i) + (e - 1) * Math.log(1 - i) - wa(a2, e));
- }
- function Oa(i, a2, e) {
- if (i <= 0)
- return 0;
- if (i >= 1)
- return 1;
- const t = 1e-8;
- let r;
- if (a2 >= 1 && e >= 1) {
- const c = i < 0.5 ? i : 1 - i, l2 = Math.sqrt(-2 * Math.log(c));
- r = (2.30753 + l2 * 0.27061) / (1 + l2 * (0.99229 + l2 * 0.04481)) - l2, i < 0.5 && (r = -r);
- const f2 = (r * r - 3) / 6, h = 2 / (1 / (2 * a2 - 1) + 1 / (2 * e - 1)), d2 = r * Math.sqrt(f2 + h) / h - (1 / (2 * e - 1) - 1 / (2 * a2 - 1)) * (f2 + 5 / 6 - 2 / (3 * h));
- r = a2 / (a2 + e * Math.exp(2 * d2));
- } else {
- const c = Math.exp(a2 * Math.log(a2 / (a2 + e))) / a2, l2 = Math.exp(e * Math.log(e / (a2 + e))) / e, f2 = c + l2;
- i < c / f2 ? r = (a2 * f2 * i) ** (1 / a2) : r = 1 - (e * f2 * (1 - i)) ** (1 / e);
- }
- const n = -wa(a2, e);
- let s, o, u;
- for (let c = 0; c < 10; c++) {
- if (r === 0 || r === 1)
- return r;
- if (s = Qn(r, a2, e) - i, o = Math.exp((a2 - 1) * Math.log(r) + (e - 1) * Math.log(1 - r) + n), u = s / o, r -= o = u / (1 - 0.5 * Math.min(1, u * ((a2 - 1) / r - (e - 1) / (1 - r)))), r <= 0 && (r = 0.5 * (r + o)), r >= 1 && (r = 0.5 * (r + o + 1)), Math.abs(o) < t * r && c > 0)
- break;
- }
- return r;
- }
- function Qn(i, a2, e) {
- const t = i === 0 || i === 1 ? 0 : Math.exp(ct(a2 + e) - ct(a2) - ct(e) + a2 * Math.log(i) + e * Math.log(1 - i));
- return i < (a2 + 1) / (a2 + e + 2) ? t * Di(i, a2, e) / a2 : 1 - t * Di(1 - i, e, a2) / e;
- }
- function Di(i, a2, e) {
- let n = 1 - (a2 + e) * i / (a2 + 1);
- Math.abs(n) < 1e-8 && (n = 1e-8), n = 1 / n;
- let s = 1, o = n;
- for (let u = 1; u <= 100; u++) {
- let c = u * (e - u) * i / ((a2 - 1 + u * 2) * (a2 + u * 2));
- if (n = 1 + c * n, Math.abs(n) < 1e-8 && (n = 1e-8), s = 1 + c / s, Math.abs(s) < 1e-8 && (s = 1e-8), n = 1 / n, o *= n * s, c = -(a2 + u) * (a2 + e + u) * i / ((a2 + u * 2) * (a2 + 1 + u * 2)), n = 1 + c * n, Math.abs(n) < 1e-8 && (n = 1e-8), s = 1 + c / s, Math.abs(s) < 1e-8 && (s = 1e-8), n = 1 / n, o *= n * s, Math.abs(n * s - 1) < 1e-8)
- break;
- }
- return o;
- }
- function Ma(i, a2) {
- return i + a2 > 170 ? Math.exp(wa(i, a2)) : on(i) * on(a2) / on(i + a2);
- }
- function wa(i, a2) {
- return ct(i) + ct(a2) - ct(i + a2);
- }
- function So(i, a2, e) {
- if (i < 0)
- return 0;
- if (i >= a2)
- return 1;
- if (e < 0 || e > 1 || a2 <= 0)
- return Number.NaN;
- let t = 0;
- for (let r = 0; r <= i; r++)
- t += Da(r, a2, e);
- return t;
- }
- function Da(i, a2, e) {
- return e === 0 || e === 1 ? a2 * e === i ? 1 : 0 : zt(a2, i) * e ** i * (1 - e) ** (a2 - i);
- }
- function Sa(i, a2) {
- return i <= 0 ? 0 : La(a2 / 2, i / 2);
- }
- function tm(i, a2) {
- return i < 0 ? 0 : i === 0 && a2 === 2 ? 0.5 : Math.exp((a2 / 2 - 1) * Math.log(i) - i / 2 - a2 / 2 * Math.log(2) - ct(a2 / 2));
- }
- function Po(i, a2) {
- return i <= 0 ? 0 : i >= 1 ? 1 / 0 : 2 * jo(i, a2 / 2);
- }
- function Pa(i, a2, e) {
- return i < 0 ? 0 : Qn(a2 * i / (a2 * i + e), a2 / 2, e / 2);
- }
- function rm(i, a2, e) {
- if (i < 0)
- return 0;
- if (i === 0 && a2 < 2)
- return 1 / 0;
- if (i === 0 && a2 === 2)
- return 1;
- let t = 1 / Ma(a2 / 2, e / 2);
- return t *= (a2 / e) ** (a2 / 2), t *= i ** (a2 / 2 - 1), t *= (1 + a2 / e * i) ** (-(a2 + e) / 2), t;
- }
- function Lo(i, a2, e) {
- return i <= 0 ? 0 : i >= 1 ? 1 / 0 : e / (a2 * (1 / Oa(i, a2 / 2, e / 2) - 1));
- }
- function nm(i, a2) {
- return i < 0 ? 0 : 1 - Math.exp(-a2 * i);
- }
- function sm(i, a2) {
- return i < 0 ? 0 : a2 * Math.exp(-a2 * i);
- }
- function xo(i, a2, e) {
- const t = a2.length;
- let r = 0, n = 0;
- for (let h = 0; h < t; h++)
- r += a2[h], n += e[h];
- const s = r / t, o = n / t;
- let u = 0, c = 0;
- for (let h = 0; h < t; h++)
- u += (a2[h] - s) * (e[h] - o), c += (e[h] - o) ** 2;
- if (c === 0)
- return 1 / 0;
- const l2 = u / c;
- return s - l2 * o + l2 * i;
- }
- function on(i) {
- const a2 = [
- -1.716185138865495,
- 24.76565080557592,
- -379.80425647094563,
- 629.3311553128184,
- 866.9662027904133,
- -31451.272968848367,
- -36144.413418691176,
- 66456.14382024054
- ], e = [
- -30.8402300119739,
- 315.35062697960416,
- -1015.1563674902192,
- -3107.771671572311,
- 22538.11842098015,
- 4755.846277527881,
- // eslint-disable-line
- -134659.9598649693,
- -115132.2596755535
- ];
- let t = 0, r = i;
- if (i > 171.6243769536076)
- return 1 / 0;
- if (r <= 0) {
- const f2 = r % 1 + 36e-17;
- if (f2)
- t = (r & 1 ? -1 : 1) * Math.PI / Math.sin(Math.PI * f2), r = 1 - r;
- else
- return 1 / 0;
- }
- const n = r;
- let s = 0, o;
- r < 1 ? o = r++ : o = (r -= s = (r | 0) - 1) - 1;
- let u = 0, c = 0;
- for (let f2 = 0; f2 < 8; ++f2)
- u = (u + a2[f2]) * o, c = c * o + e[f2];
- let l2 = u / c + 1;
- if (n < r)
- l2 /= n;
- else if (n > r)
- for (let f2 = 0; f2 < s; ++f2)
- l2 *= r, r++;
- return t && (l2 = t / l2), l2;
- }
- function am(i, a2, e) {
- return i <= 0 ? 0 : La(a2, i / e);
- }
- function im(i, a2, e) {
- return i < 0 ? 0 : i === 0 && a2 === 1 ? 1 / e : Math.exp((a2 - 1) * Math.log(i) - i / e - ct(a2) - a2 * Math.log(e));
- }
- function om(i, a2, e) {
- return i <= 0 ? 0 : i >= 1 ? 1 / 0 : e * jo(i, a2);
- }
- function ct(i) {
- const a2 = [
- 76.18009172947146,
- -86.50532032941678,
- 24.01409824083091,
- // eslint-disable-line
- -1.231739572450155,
- 0.001208650973866179,
- -5395239384953e-18
- ];
- let e = i, t = i + 5.5;
- t -= (i + 0.5) * Math.log(t);
- let r = 1.000000000190015;
- for (let n = 0; n < 6; n++)
- r += a2[n] / ++e;
- return -t + Math.log(2.5066282746310007 * r / i);
- }
- function La(i, a2) {
- if (a2 < 0 || i <= 0)
- return Number.NaN;
- const e = 1e-30, t = -~(Math.log(i >= 1 ? i : 1 / i) * 8.5 + i * 0.4 + 17), r = ct(i), n = Math.exp(-a2 + i * Math.log(a2) - r);
- let s = i, o = 1 / i, u = o;
- if (a2 < i + 1) {
- if (n === 0)
- return 0;
- for (let d2 = 1; d2 <= t && (o += u *= a2 / ++s, !(Math.abs(u) < Math.abs(o) * e)); d2++)
- ;
- return o * n;
- }
- if (n === 0)
- return 1;
- let c = a2 + 1 - i, l2 = 1 / e, f2 = 1 / c, h = f2;
- for (let d2 = 1; d2 <= t; d2++) {
- const _ = -d2 * (d2 - i);
- if (c += 2, f2 = _ * f2 + c, Math.abs(f2) < e && (f2 = e), l2 = c + _ / l2, Math.abs(l2) < e && (l2 = e), f2 = 1 / f2, h *= f2 * l2, Math.abs(f2 * l2 - 1) < e)
- break;
- }
- return 1 - h * n;
- }
- function jo(i, a2) {
- if (i <= 0)
- return 0;
- if (i >= 1)
- return Math.max(100, a2 + 100 * Math.sqrt(a2));
- let e;
- if (a2 > 1) {
- const o = i < 0.5 ? i : 1 - i, u = Math.sqrt(-2 * Math.log(o));
- e = (2.30753 + u * 0.27061) / (1 + u * (0.99229 + u * 0.04481)) - u, i < 0.5 && (e = -e), e = Math.max(1e-3, a2 * (1 - 1 / (9 * a2) - e / (3 * Math.sqrt(a2))) ** 3);
- } else {
- const o = 1 - a2 * (0.253 + a2 * 0.12);
- i < o ? e = (i / o) ** (1 / a2) : e = 1 - Math.log(1 - (i - o) / (1 - o));
- }
- const t = 1e-8, r = ct(a2);
- let n, s;
- for (let o = 0; o < 12; o++) {
- if (e <= 0)
- return 0;
- if (n = La(a2, e) - i, a2 > 1 ? s = Math.exp((a2 - 1) * (Math.log(a2 - 1) - 1) - r) * Math.exp(-(e - (a2 - 1)) + (a2 - 1) * (Math.log(e) - Math.log(a2 - 1))) : s = Math.exp(-e + (a2 - 1) * Math.log(e) - r), s !== 0 && (s = n / s / (1 - 0.5 * Math.min(1, n / s * ((a2 - 1) / e - 1)))), e -= s, e <= 0 && (e = 0.5 * (e + s)), Math.abs(s) < t * e)
- break;
- }
- return e;
- }
- function um(i, a2, e, t) {
- let r = 0;
- for (let n = 0; n <= i; n++)
- r += xa(n, a2, e, t);
- return r;
- }
- function xa(i, a2, e, t) {
- return a2 - i > t - e ? 0 : zt(e, i) * zt(t - e, a2 - i) / zt(t, a2);
- }
- function Uo(i, a2, e) {
- return i < 0 ? 0 : 0.5 + 0.5 * Zt((Math.log(i) - a2) / Math.sqrt(2 * e * e));
- }
- function cm(i, a2, e) {
- return i <= 0 ? 0 : Math.exp(-Math.log(i) - 0.5 * Math.log(2 * Math.PI) - Math.log(e) - (Math.log(i) - a2) ** 2 / (2 * e * e));
- }
- function lm(i, a2, e) {
- return Math.exp(Wn(i, a2, e));
- }
- function fm(i, a2, e) {
- if (i < 0)
- return 0;
- let t = 0;
- for (let r = 0; r <= i; r++)
- t += ja(r, a2, e);
- return t;
- }
- function ja(i, a2, e) {
- return i < 0 ? 0 : zt(i + a2 - 1, a2 - 1) * e ** a2 * (1 - e) ** i;
- }
- function kr(i, a2, e) {
- return 0.5 * (1 + Zt((i - a2) / Math.sqrt(2 * e * e)));
- }
- function vo(i, a2, e) {
- return Math.exp(-0.5 * Math.log(2 * Math.PI) - Math.log(e) - (i - a2) ** 2 / (2 * e * e));
- }
- function Wn(i, a2, e) {
- return -1.4142135623730951 * e * Hh(2 * i) + a2;
- }
- function hm(i, a2) {
- let e = 0;
- for (let t = 0; t <= i; t++)
- e += To(t, a2);
- return e;
- }
- function To(i, a2) {
- return Math.exp(-a2) * a2 ** i / cr(i);
- }
- function $r(i, a2) {
- const e = 0.5 * Qn(a2 / (i ** 2 + a2), a2 / 2, 0.5);
- return i < 0 ? e : 1 - e;
- }
- function mm(i, a2) {
- const e = (1 + i ** 2 / a2) ** (-(a2 + 1) / 2);
- return 1 / (Math.sqrt(a2) * Ma(0.5, a2 / 2)) * e;
- }
- function qn(i, a2) {
- let e = Oa(2 * Math.min(i, 1 - i), 0.5 * a2, 0.5);
- return e = Math.sqrt(a2 * (1 - e) / e), i > 0.5 ? e : -e;
- }
- function Je(i, a2, e, t, r) {
- const n = [], s = [];
- let o = true;
- for (let u = 0; u < e; u++) {
- const c = Math.floor(u / t), l2 = u % t, f2 = Math.floor(u / r), h = u % r, d2 = i.isArray() ? i.get(c, l2) : i, _ = a2.isArray() ? a2.get(f2, h) : a2;
- if (d2.isError())
- return {
- isError: true,
- errorObject: d2,
- array1Values: n,
- array2Values: s,
- noCalculate: o
- };
- if (_.isError())
- return {
- isError: true,
- errorObject: _,
- array1Values: n,
- array2Values: s,
- noCalculate: o
- };
- if (d2.isNull() || _.isNull() || d2.isBoolean() || _.isBoolean())
- continue;
- const C = d2.getValue(), E2 = _.getValue();
- !DC(C) || !DC(E2) || (n.push(+C), s.push(+E2), o = false);
- }
- return {
- isError: false,
- errorObject: null,
- array1Values: n,
- array2Values: s,
- noCalculate: o
- };
- }
- function Kn(i, a2, e) {
- const t = i.isArray() ? i.getRowCount() : 1, r = i.isArray() ? i.getColumnCount() : 1;
- let n = t, s = r;
- if (a2 && !a2.isNull() && (n = a2.isArray() ? a2.getRowCount() : 1, s = a2.isArray() ? a2.getColumnCount() : 1, t === 1 && s !== r || r === 1 && n !== t || t !== 1 && r !== 1 && (n !== t || s !== r)))
- return {
- isError: true,
- errorObject: g2.create(m2.REF)
- };
- if (e && !e.isNull()) {
- const o = e.isArray() ? e.getRowCount() : 1, u = e.isArray() ? e.getColumnCount() : 1;
- if (t === 1 && n > 1 && o !== n || r === 1 && s > 1 && u !== s)
- return {
- isError: true,
- errorObject: g2.create(m2.REF)
- };
- }
- return {
- isError: false,
- errorObject: null
- };
- }
- function dt(i) {
- const a2 = i.isArray() ? i.getRowCount() : 1, e = i.isArray() ? i.getColumnCount() : 1, t = [];
- for (let r = 0; r < a2; r++) {
- t[r] = [];
- for (let n = 0; n < e; n++) {
- const s = i.isArray() ? i.get(r, n) : i;
- if (s.isError() || s.isNull() || s.isBoolean() || s.isString())
- return g2.create(m2.VALUE);
- t[r].push(+s.getValue());
- }
- }
- return t;
- }
- function Xn(i, a2) {
- const e = [];
- let t = 1;
- for (let r = 0; r < i; r++) {
- e[r] = [];
- for (let n = 0; n < a2; n++)
- e[r].push(t++);
- }
- return e;
- }
- function Zn(i, a2, e, t) {
- let r = a2;
- t && (r = a2.map((o) => Math.log(o)));
- let n, s;
- return e ? { slope: n, intercept: s } = gm(i, r) : { slope: n, intercept: s } = dm(i, r), t && (n = Math.exp(n), s = Math.exp(s)), Number.isNaN(n) && !e && (n = 0), { slope: n, intercept: s, Y: r };
- }
- function gm(i, a2) {
- const e = a2.length;
- let t = 0, r = 0, n = 0, s = 0;
- for (let l2 = 0; l2 < e; l2++)
- t += i[l2], r += a2[l2], n += i[l2] * i[l2], s += i[l2] * a2[l2];
- const u = (e * s - t * r) / (e * n - t * t), c = 1 / e * r - u * (1 / e) * t;
- return {
- slope: u,
- intercept: c
- };
- }
- function dm(i, a2) {
- const e = [[...i]], t = [...a2];
- let r = e.length, n = e[0].length, s = Math.min(r, n);
- const o = new Array(s).fill(0);
- for (let c = 0; c < s; c++) {
- const l2 = e[c];
- let f2 = 0;
- for (let d2 = 0; d2 < n; d2++)
- f2 += l2[d2] ** 2;
- const h = l2[c] < 0 ? Math.sqrt(f2) : -Math.sqrt(f2);
- if (o[c] = h, h !== 0) {
- l2[c] -= h;
- for (let d2 = c + 1; d2 < r; d2++) {
- let _ = 0;
- for (let C = c; C < n; C++)
- _ -= e[d2][C] * l2[C];
- _ /= h * l2[c];
- for (let C = c; C < n; C++)
- e[d2][C] -= _ * l2[C];
- }
- }
- }
- r = e.length, n = e[0].length, s = Math.min(r, n);
- const u = new Array(r).fill(0);
- for (let c = 0; c < s; c++) {
- const l2 = e[c];
- let f2 = 0;
- for (let h = 0; h < n; h++)
- f2 += t[h] * l2[h];
- f2 /= o[c] * l2[c];
- for (let h = 0; h < n; h++)
- t[h] += f2 * l2[h];
- }
- for (let c = o.length - 1; c >= 0; c--) {
- t[c] /= o[c];
- const l2 = t[c], f2 = e[c];
- u[c] = l2;
- for (let h = 0; h < c; h++)
- t[h] -= l2 * f2[h];
- }
- return {
- slope: u[0],
- intercept: 0
- };
- }
- function zn(i, a2, e, t, r) {
- const n = i.length === 1 && i[0].length > 1;
- let s = i;
- r && (s = i.map((C) => C.map((E2) => Math.log(E2))));
- let o = a2, u = e;
- n && (s = mt(s), o = mt(o), u = mt(u)), t && (o = o.map((C) => [...C, 1]));
- const c = mt(o), l2 = lr(c, o), f2 = lr(c, s);
- let h = Wh(l2);
- if (!h && (h = Xh(l2), !h))
- return g2.create(m2.NA);
- let d2 = lr(h, f2);
- t || d2.push([0]), d2 = mt(d2);
- const _ = d2[0].pop();
- if (d2[0].reverse(), d2[0].push(_), r)
- for (let C = 0; C < d2[0].length; C++)
- d2[0][C] = Math.exp(d2[0][C]);
- return {
- coefficients: d2,
- Y: s,
- X: o,
- newX: u,
- XTXInverse: h
- };
- }
- var Bo = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- let o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(1);
- o.isNull() && (o = y2.create(0)), u.isNull() && (u = y2.create(1));
- const c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l2 = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.mapValue((b, R, p2) => {
- const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2);
- return this._handleSignleObject(b, N2, M2, w, D2);
- });
- return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
- }
- _handleSignleObject(e, t, r, n, s) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- if (n.isError())
- return n;
- if (s.isError())
- return s;
- const { isError: o, errorObject: u, variants: c } = I2(e, t, r, n, s);
- if (o)
- return u;
- const [l2, f2, h, d2, _] = c, C = +l2.getValue(), E2 = +f2.getValue(), b = +h.getValue(), R = +d2.getValue(), p2 = +_.getValue();
- if (E2 <= 0 || b <= 0 || C <= 0 || C >= 1 || R >= p2)
- return g2.create(m2.NUM);
- const N2 = Oa(C, E2, b) * (p2 - R) + R;
- return y2.create(N2);
- }
- };
- var Io = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
- if (s)
- return o;
- const [c, l2, f2, h] = u, d2 = Math.floor(+c.getValue()), _ = Math.floor(+l2.getValue()), C = +f2.getValue(), E2 = +h.getValue();
- if (d2 < 0 || d2 > _ || C < 0 || C > 1)
- return g2.create(m2.NUM);
- let b;
- return E2 ? b = So(d2, _, C) : b = Da(d2, _, C), y2.create(b);
- }
- };
- var Fo = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = Math.floor(+u.getValue()), h = +c.getValue(), d2 = +l2.getValue();
- if (f2 < 0 || h <= 0 || h >= 1 || d2 <= 0 || d2 >= 1)
- return g2.create(m2.NUM);
- let _ = 0;
- for (; _ <= f2 && !(So(_, f2, h) >= d2); )
- _++;
- return y2.create(_);
- }
- };
- var ko = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (c < 0 || l2 < 1 || l2 > 10 ** 10)
- return g2.create(m2.NUM);
- const f2 = 1 - Sa(c, l2);
- return y2.create(f2);
- }
- };
- var $o = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (c < 0 || c > 1 || l2 < 1 || l2 > 10 ** 10)
- return g2.create(m2.NUM);
- const f2 = Po(1 - c, l2);
- return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
- }
- };
- var Yo = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if (r * n === 1 || s * o === 1)
- return u.isNull() || c.isNull() ? g2.create(m2.VALUE) : g2.create(m2.NA);
- if (r * n !== s * o)
- return g2.create(m2.NA);
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2, r, n);
- }
- _getResult(e, t, r, n) {
- let s = 0;
- for (let c = 0; c < e.length; c++) {
- if (t[c] === 0)
- return g2.create(m2.DIV_BY_ZERO);
- s += (e[c] - t[c]) ** 2 / t[c];
- }
- let o = (r - 1) * (n - 1);
- r === 1 ? o = n - 1 : n === 1 && (o = r - 1);
- const u = 1 - Sa(s, o);
- return y2.create(u);
- }
- };
- var Ho = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- if (f2.isError())
- return f2;
- if (_.isError())
- return _;
- if (C.isError())
- return C;
- const { isError: E2, errorObject: b, variants: R } = I2(f2, _, C);
- if (E2)
- return b;
- const [p2, N2, M2] = R, w = +p2.getValue(), D2 = +N2.getValue(), S2 = Math.floor(+M2.getValue());
- if (w <= 0 || w >= 1 || D2 <= 0 || S2 < 1)
- return g2.create(m2.NUM);
- const P = Math.abs(Wn(w / 2, 0, 1) * D2 / Math.sqrt(S2));
- return y2.create(P);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- };
- var Go = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return g2.create(m2.VALUE);
- if (r * n !== s * o)
- return g2.create(m2.NA);
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
- }
- _getResult(e, t) {
- if (e.length === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const r = e.length;
- let n = 0, s = 0;
- for (let l2 = 0; l2 < r; l2++)
- n += e[l2], s += t[l2];
- const o = n / r, u = s / r;
- let c = 0;
- for (let l2 = 0; l2 < r; l2++) {
- const f2 = e[l2] - o, h = t[l2] - u;
- c += f2 * h;
- }
- return y2.create(c / r);
- }
- };
- var Qo = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
- if (f2 < 0 || h <= 0)
- return g2.create(m2.NUM);
- let _;
- return d2 ? _ = nm(f2, h) : _ = sm(f2, h), y2.create(_);
- }
- };
- var Wo = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = Math.floor(+l2.getValue());
- if (f2 < 0 || h < 1 || h > 10 ** 10 || d2 < 1 || d2 > 10 ** 10)
- return g2.create(m2.NUM);
- const _ = 1 - Pa(f2, h, d2);
- return y2.create(_);
- }
- };
- var qo = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = Math.floor(+l2.getValue());
- if (f2 < 0 || f2 > 1 || h < 1 || h > 10 ** 10 || d2 < 1 || d2 > 10 ** 10)
- return g2.create(m2.NUM);
- const _ = Lo(1 - f2, h, d2);
- return Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
- }
- };
- var Ko = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const {
- isError: r,
- errorObject: n,
- variance: s,
- ns1: o
- } = this._getValues(e);
- if (r)
- return n;
- const {
- isError: u,
- errorObject: c,
- variance: l2,
- ns1: f2
- } = this._getValues(t);
- if (u)
- return c;
- let h = 2 * (1 - Pa(s / l2, o, f2));
- return h > 1 && (h = 2 - h), y2.create(h);
- }
- // eslint-disable-next-line
- _getValues(e) {
- let t = 0, r = 0;
- const n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
- if (n === 1 && s === 1) {
- const f2 = e.isArray() ? e.get(0, 0) : e;
- return f2.isError() ? {
- isError: true,
- errorObject: f2,
- variance: t,
- ns1: r
- } : f2.isNull() ? {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- variance: t,
- ns1: r
- } : {
- isError: true,
- errorObject: g2.create(m2.DIV_BY_ZERO),
- variance: t,
- ns1: r
- };
- }
- const o = [];
- let u = 0;
- for (let f2 = 0; f2 < n; f2++)
- for (let h = 0; h < s; h++) {
- const d2 = e.isArray() ? e.get(f2, h) : e;
- if (d2.isError())
- return {
- isError: true,
- errorObject: d2,
- variance: t,
- ns1: r
- };
- if (d2.isNull() || d2.isBoolean())
- continue;
- const _ = d2.getValue();
- DC(_) && (o.push(+_), u += +_);
- }
- if (o.length <= 1)
- return {
- isError: true,
- errorObject: g2.create(m2.DIV_BY_ZERO),
- variance: t,
- ns1: r
- };
- const c = u / o.length;
- let l2 = 0;
- for (let f2 = 0; f2 < o.length; f2++)
- l2 += (o[f2] - c) ** 2;
- return r = o.length - 1, t = l2 / r, t === 0 ? {
- isError: true,
- errorObject: g2.create(m2.DIV_BY_ZERO),
- variance: t,
- ns1: r
- } : {
- isError: false,
- errorObject: null,
- variance: t,
- ns1: r
- };
- }
- };
- var Xo = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
- if (s)
- return o;
- const [c, l2, f2, h] = u, d2 = +c.getValue(), _ = +l2.getValue(), C = +f2.getValue(), E2 = +h.getValue();
- if (d2 < 0 || _ <= 0 || C <= 0)
- return g2.create(m2.NUM);
- let b;
- return E2 ? b = am(d2, _, C) : b = im(d2, _, C), y2.create(b);
- }
- };
- var Zo = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
- if (f2 < 0 || f2 > 1 || h <= 0 || d2 <= 0)
- return g2.create(m2.NUM);
- const _ = om(f2, h, d2);
- return Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
- }
- };
- var zo = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
- if (f2 <= 0 || f2 >= 1 || d2 <= 0)
- return g2.create(m2.NUM);
- const _ = lm(f2, h, d2);
- return Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
- }
- };
- var Jo = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = {};
- let r = 0, n = 1;
- for (let s = 0; s < e.length; s++) {
- const o = e[s];
- if (o.isError())
- return o;
- if (o.isString()) {
- const l2 = o.convertToNumberObjectValue();
- if (l2.isError())
- return l2;
- }
- const u = o.isArray() ? o.getRowCount() : 1, c = o.isArray() ? o.getColumnCount() : 1;
- for (let l2 = 0; l2 < u; l2++)
- for (let f2 = 0; f2 < c; f2++) {
- const h = o.isArray() ? o.get(l2, f2) : o;
- if (h.isError())
- return h;
- if (h.isNull() || h.isBoolean() || h.isString())
- continue;
- const d2 = h.getValue();
- DC(d2) && (t[+d2] ? (t[+d2].count++, t[+d2].count > n && (n = t[+d2].count)) : t[+d2] = { count: 1, order: r++ });
- }
- }
- return r === 0 || n === 1 ? new g2(m2.NA) : this._getResult(t, n);
- }
- _getResult(e, t) {
- const r = Object.entries(e).filter(([n, { count: s }]) => s === t).sort((n, s) => n[1].order - s[1].order).map(([n]) => +n);
- return y2.create(r[0]);
- }
- };
- var eu = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
- if (s)
- return o;
- const [c, l2, f2, h] = u, d2 = +c.getValue(), _ = +l2.getValue(), C = +f2.getValue(), E2 = +h.getValue();
- if (C <= 0)
- return g2.create(m2.NUM);
- let b;
- return E2 ? b = kr(d2, _, C) : b = vo(d2, _, C), y2.create(b);
- }
- };
- var tu = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
- if (f2 <= 0 || f2 >= 1 || d2 <= 0)
- return g2.create(m2.NUM);
- const _ = Wn(f2, h, d2);
- return y2.create(_);
- }
- };
- var ru = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSignleObject(r));
- return e.getRowCount() === 1 && e.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSignleObject(e);
- }
- _handleSignleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (o <= 0 || o >= 1)
- return g2.create(m2.NUM);
- const u = Wn(o, 0, 1);
- return y2.create(u);
- }
- };
- var nu2 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g2)
- return e;
- const { isError: r, errorObject: n, variants: s } = I2(t);
- if (r)
- return n;
- const [o] = s, u = +o.getValue(), c = e.length;
- if (u < 0 || u > 1)
- return g2.create(m2.NUM);
- const l2 = u * (c - 1), f2 = Math.floor(l2), h = l2 - f2;
- if (h === 0)
- return y2.create(e[f2]);
- const d2 = e[f2] + h * (e[f2 + 1] - e[f2]);
- return y2.create(d2);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean() || u.isString())
- continue;
- const c = u.getValue();
- DC(c) && n.push(+c);
- }
- return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
- }
- };
- var su = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = this._getValues(e);
- let s = r != null ? r : y2.create(3);
- s.isNull() && (s = y2.create(3));
- const o = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, t, g2.create(m2.NA)), l2 = O(o, u, s, g2.create(m2.NA)), f2 = c.mapValue((h, d2, _) => {
- const C = l2.get(d2, _);
- return h.isError() ? h : C.isError() ? C : this._handleSingleObject(n, h, C);
- });
- return o === 1 && u === 1 ? f2.get(0, 0) : f2;
- }
- _handleSingleObject(e, t, r) {
- if (e instanceof g2)
- return e;
- const { isError: n, errorObject: s, variants: o } = I2(t, r);
- if (n)
- return s;
- const [u, c] = o, l2 = +u.getValue(), f2 = Math.floor(+c.getValue()), h = e.length;
- if (h === 0 || l2 < e[0] || l2 > e[h - 1])
- return g2.create(m2.NA);
- if (h === 1)
- return l2 === e[0] ? y2.create(1) : g2.create(m2.NA);
- let d2 = 0, _ = false, C = 0;
- for (; !_ && C < h; )
- l2 === e[C] ? (d2 = C / (h - 1), _ = true) : l2 > e[C] && C + 1 < h && l2 < e[C + 1] && (d2 = (C + (l2 - e[C]) / (e[C + 1] - e[C])) / (h - 1), _ = true), C++;
- return _ ? f2 < 1 ? g2.create(m2.NUM) : (d2 = We(d2, f2), y2.create(d2)) : g2.create(m2.NA);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- DC(c) && n.push(+c);
- }
- return n.sort((s, o) => s - o);
- }
- };
- var au = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = Math.floor(+u.getValue()), h = +c.getValue(), d2 = +l2.getValue();
- if (f2 < 0 || h < 0)
- return g2.create(m2.NUM);
- let _;
- return d2 ? _ = hm(f2, h) : _ = To(f2, h), y2.create(_);
- }
- };
- var iu = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g2)
- return e;
- const { isError: r, errorObject: n, variants: s } = I2(t);
- if (r)
- return n;
- const [o] = s, u = Math.floor(+o.getValue());
- if (u < 0 || u > 4)
- return g2.create(m2.NUM);
- const c = u / 4, l2 = e.length, f2 = c * (l2 - 1), h = Math.floor(f2), d2 = f2 - h;
- if (d2 === 0)
- return y2.create(e[h]);
- const _ = e[h] + d2 * (e[h + 1] - e[h]);
- return y2.create(_);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- DC(c) && n.push(+c);
- }
- return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
- }
- };
- var ou = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e);
- return t.isError() ? t : t.std();
- }
- };
- var uu = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e);
- return t.isError() ? t : t.std(1);
- }
- };
- var cu = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (c <= 0 || c > 1 || l2 < 1 || l2 > 10 ** 10)
- return g2.create(m2.NUM);
- const f2 = Math.abs(qn(c / 2, l2));
- return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
- }
- };
- var lu = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- // eslint-disable-next-line
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o, array1Values: u, array2Values: c } = this._handleArray1AndArray2(e, t), l2 = this._getArrayValues(e), f2 = this._getArrayValues(t), h = Math.max(
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), d2 = Math.max(
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), _ = O(h, d2, r, g2.create(m2.NA)), C = O(h, d2, n, g2.create(m2.NA)), E2 = _.mapValue((b, R, p2) => {
- const N2 = C.get(R, p2);
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (b.isError())
- return b;
- if (N2.isError())
- return N2;
- const { isError: M2, errorObject: w, variants: D2 } = I2(b, N2);
- if (M2)
- return w;
- const [S2, P] = D2, U2 = Math.floor(+S2.getValue()), x2 = Math.floor(+P.getValue());
- return ![1, 2].includes(U2) || ![1, 2, 3].includes(x2) ? g2.create(m2.NUM) : x2 === 1 && s ? o : x2 !== 1 && l2 instanceof g2 ? l2 : x2 !== 1 && f2 instanceof g2 ? f2 : this._handleSignleObject(
- x2 === 1 ? u : l2,
- x2 === 1 ? c : f2,
- U2,
- x2
- );
- });
- return h === 1 && d2 === 1 ? E2.get(0, 0) : E2;
- }
- _handleSignleObject(e, t, r, n) {
- if (e.length < 2 || t.length < 2)
- return g2.create(m2.DIV_BY_ZERO);
- const { isError: s, errorObject: o, x: u, degFreedom: c } = this._getTDistParamByArrayValues(e, t, n);
- if (s)
- return o;
- let l2 = $r(-u, c);
- return r === 2 && (l2 *= 2), Number.isNaN(l2) || !Number.isFinite(l2) ? g2.create(m2.NUM) : y2.create(l2);
- }
- _getArrayValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull()) {
- if (t * r === 1)
- return g2.create(m2.VALUE);
- continue;
- }
- u.isBoolean() || u.isString() || n.push(+u.getValue());
- }
- return n;
- }
- // eslint-disable-next-line
- _handleArray1AndArray2(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return {
- isError: true,
- errorObject: u,
- array1Values: [],
- array2Values: []
- };
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return {
- isError: true,
- errorObject: c,
- array1Values: [],
- array2Values: []
- };
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- array1Values: [],
- array2Values: []
- };
- if (r * n !== s * o)
- return {
- isError: true,
- errorObject: g2.create(m2.NA),
- array1Values: [],
- array2Values: []
- };
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? {
- isError: true,
- errorObject: f2,
- array1Values: [],
- array2Values: []
- } : _ || h.length < 2 ? {
- isError: true,
- errorObject: g2.create(m2.DIV_BY_ZERO),
- array1Values: [],
- array2Values: []
- } : {
- isError: false,
- errorObject: null,
- array1Values: h,
- array2Values: d2
- };
- }
- _getTDistParamByArrayValues(e, t, r) {
- return r === 1 ? this._getTDistParamByType1(e, t) : r === 2 ? this._getTDistParamByType2(e, t) : this._getTDistParamByType3(e, t);
- }
- _getTDistParamByType1(e, t) {
- const r = e.length;
- let n = 0, s = 0, o = 0;
- for (let h = 0; h < r; h++)
- n += e[h], s += t[h], o += (e[h] - t[h]) ** 2;
- const u = n - s, c = r * o - u ** 2, l2 = r - 1;
- return c === 0 ? {
- isError: true,
- errorObject: g2.create(m2.DIV_BY_ZERO),
- x: 0,
- degFreedom: l2
- } : {
- isError: false,
- errorObject: null,
- x: Math.abs(u) * Math.sqrt(l2 / c),
- degFreedom: l2
- };
- }
- _getTDistParamByType2(e, t) {
- const r = e.length, n = t.length;
- let s = 0, o = 0;
- for (let E2 = 0; E2 < r; E2++)
- s += e[E2], o += e[E2] ** 2;
- let u = 0, c = 0;
- for (let E2 = 0; E2 < n; E2++)
- u += t[E2], c += t[E2] ** 2;
- const l2 = o - s ** 2 / r, f2 = c - u ** 2 / n, h = Math.sqrt(l2 + f2);
- if (h === 0)
- return {
- isError: true,
- errorObject: g2.create(m2.DIV_BY_ZERO),
- x: 0,
- degFreedom: 0
- };
- const d2 = r - 1 + n - 1, _ = Math.sqrt(r * n * d2 / (r + n));
- return {
- isError: false,
- errorObject: null,
- x: Math.abs(s / r - u / n) / h * _,
- degFreedom: d2
- };
- }
- _getTDistParamByType3(e, t) {
- const r = e.length, n = t.length;
- let s = 0, o = 0;
- for (let C = 0; C < r; C++)
- s += e[C], o += e[C] ** 2;
- let u = 0, c = 0;
- for (let C = 0; C < n; C++)
- u += t[C], c += t[C] ** 2;
- const l2 = (o - s ** 2 / r) / (r * (r - 1)), f2 = (c - u ** 2 / n) / (n * (n - 1));
- if (l2 + f2 === 0)
- return {
- isError: true,
- errorObject: g2.create(m2.DIV_BY_ZERO),
- x: 0,
- degFreedom: 0
- };
- const h = l2 / (l2 + f2), d2 = Math.abs(s / r - u / n) / Math.sqrt(l2 + f2), _ = 1 / (h ** 2 / (r - 1) + (1 - h) ** 2 / (n - 1));
- return {
- isError: false,
- errorObject: null,
- x: d2,
- degFreedom: _
- };
- }
- };
- var fu = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e);
- return t.isError() ? t : t.var();
- }
- };
- var hu = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e);
- return t.isError() ? t : t.var(1);
- }
- };
- var mu = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
- if (s)
- return o;
- const [c, l2, f2, h] = u, d2 = +c.getValue(), _ = +l2.getValue(), C = +f2.getValue(), E2 = +h.getValue();
- if (d2 < 0 || _ <= 0 || C <= 0)
- return g2.create(m2.NUM);
- const b = Math.exp(-((d2 / C) ** _));
- let R;
- return E2 ? R = 1 - b : R = _ / C ** _ * d2 ** (_ - 1) * b, Number.isNaN(R) || !Number.isFinite(R) ? g2.create(m2.NUM) : y2.create(R);
- }
- };
- var gu = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = this._getArrayValues(e), s = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- r != null && r.isArray() ? r.getRowCount() : 1
- ), o = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- r != null && r.isArray() ? r.getColumnCount() : 1
- ), u = O(s, o, t, g2.create(m2.NA)), c = r ? O(s, o, r, g2.create(m2.NA)) : void 0, l2 = u.mapValue((f2, h, d2) => {
- if (n instanceof g2)
- return n;
- if (f2.isError())
- return f2;
- const _ = r ? c.get(h, d2) : void 0;
- return _ != null && _.isError() ? _ : n.length === 0 ? g2.create(m2.NA) : n.length === 1 ? g2.create(m2.DIV_BY_ZERO) : this._handleSignleObject(n, f2, _);
- });
- return s === 1 && o === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(t);
- if (n)
- return s;
- const [u] = o, c = +u.getValue(), l2 = e.length;
- let f2 = 0, h = 0;
- for (let E2 = 0; E2 < l2; E2++)
- f2 += e[E2], h += e[E2] ** 2;
- let d2 = 0;
- if (r !== void 0) {
- const { isError: E2, errorObject: b, variants: R } = I2(r);
- if (E2)
- return b;
- const [p2] = R;
- d2 = +p2.getValue();
- } else {
- const E2 = f2 / l2;
- d2 = Math.sqrt((h - 2 * E2 * f2 + l2 * E2 ** 2) / (l2 - 1));
- }
- if (d2 <= 0)
- return g2.create(m2.NUM);
- const _ = (f2 / l2 - c) / (d2 / Math.sqrt(l2)), C = 1 - kr(_, 0, 1);
- return Number.isNaN(C) || !Number.isFinite(C) ? g2.create(m2.NUM) : y2.create(C);
- }
- _getArrayValues(e) {
- const t = [], r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1;
- for (let s = 0; s < r; s++)
- for (let o = 0; o < n; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean() || u.isString())
- continue;
- const c = u.getValue();
- DC(c) && t.push(+c);
- }
- return t;
- }
- };
- var Cm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- let o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(1);
- o.isNull() && (o = y2.create(0)), u.isNull() && (u = y2.create(1));
- const c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l2 = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.mapValue((b, R, p2) => {
- const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2);
- return this._handleSignleObject(b, N2, M2, w, D2);
- });
- return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
- }
- _handleSignleObject(e, t, r, n, s) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- if (n.isError())
- return n;
- if (s.isError())
- return s;
- const { isError: o, errorObject: u, variants: c } = I2(e, t, r, n, s);
- if (o)
- return u;
- const [l2, f2, h, d2, _] = c, C = +l2.getValue(), E2 = +f2.getValue(), b = +h.getValue(), R = +d2.getValue(), p2 = +_.getValue();
- if (E2 <= 0 || b <= 0 || C < R || C > p2 || R === p2)
- return g2.create(m2.NUM);
- const N2 = Do((C - R) / (p2 - R), E2, b);
- return y2.create(N2);
- }
- };
- var le2 = ((i) => (i.BETADIST = "BETADIST", i.BETAINV = "BETAINV", i.BINOMDIST = "BINOMDIST", i.CHIDIST = "CHIDIST", i.CHIINV = "CHIINV", i.CHITEST = "CHITEST", i.CONFIDENCE = "CONFIDENCE", i.COVAR = "COVAR", i.CRITBINOM = "CRITBINOM", i.EXPONDIST = "EXPONDIST", i.FDIST = "FDIST", i.FINV = "FINV", i.FTEST = "FTEST", i.GAMMADIST = "GAMMADIST", i.GAMMAINV = "GAMMAINV", i.HYPGEOMDIST = "HYPGEOMDIST", i.LOGINV = "LOGINV", i.LOGNORMDIST = "LOGNORMDIST", i.MODE = "MODE", i.NEGBINOMDIST = "NEGBINOMDIST", i.NORMDIST = "NORMDIST", i.NORMINV = "NORMINV", i.NORMSDIST = "NORMSDIST", i.NORMSINV = "NORMSINV", i.PERCENTILE = "PERCENTILE", i.PERCENTRANK = "PERCENTRANK", i.POISSON = "POISSON", i.QUARTILE = "QUARTILE", i.RANK = "RANK", i.STDEV = "STDEV", i.STDEVP = "STDEVP", i.TDIST = "TDIST", i.TINV = "TINV", i.TTEST = "TTEST", i.VAR = "VAR", i.VARP = "VARP", i.WEIBULL = "WEIBULL", i.ZTEST = "ZTEST", i))(le2 || {});
- var _m = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
- if (s)
- return o;
- const [c, l2, f2, h] = u, d2 = Math.floor(+c.getValue()), _ = Math.floor(+l2.getValue()), C = Math.floor(+f2.getValue()), E2 = Math.floor(+h.getValue());
- if (d2 < 0 || d2 > _ || d2 > C || d2 < _ - E2 + C || _ <= 0 || _ > E2 || C <= 0 || C > E2 || E2 <= 0)
- return g2.create(m2.NUM);
- let b = xa(d2, _, C, E2);
- return Number.isNaN(b) && (b = 0), y2.create(b);
- }
- };
- var Am = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
- if (f2 <= 0 || d2 <= 0)
- return g2.create(m2.NUM);
- const _ = Uo(f2, h, d2);
- return y2.create(_);
- }
- };
- var Em = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = Math.floor(+u.getValue()), h = Math.floor(+c.getValue()), d2 = +l2.getValue();
- if (f2 < 0 || h < 1 || d2 <= 0 || d2 >= 1)
- return g2.create(m2.NUM);
- const _ = ja(f2, h, d2);
- return y2.create(_);
- }
- };
- var bm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSignleObject(r));
- return e.getRowCount() === 1 && e.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSignleObject(e);
- }
- _handleSignleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue(), u = kr(o, 0, 1);
- return y2.create(u);
- }
- };
- var ym = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", true);
- }
- calculate(e, t, r) {
- let n = e;
- n.isReferenceObject() && (n = n.toArrayValueObject());
- const { refHasError: s, refErrorObject: o, refNumbers: u } = this._checkRefReferenceObject(t);
- let c = r != null ? r : y2.create(0);
- c.isReferenceObject() && (c = c.toArrayValueObject());
- const l2 = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f2 = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l2, f2, n, g2.create(m2.NA)), d2 = O(l2, f2, c, g2.create(m2.NA)), _ = h.map((C, E2, b) => {
- const R = d2.get(E2, b);
- if (!e.isReferenceObject() && e.isNull())
- return g2.create(m2.NA);
- if (s)
- return o;
- if (R.isError())
- return R;
- const p2 = +C.getValue(), N2 = +R.getValue();
- if (Number.isNaN(p2) || Number.isNaN(N2))
- return g2.create(m2.VALUE);
- const w = u.sort((D2, S2) => N2 ? D2 - S2 : S2 - D2).indexOf(p2);
- return w === -1 ? g2.create(m2.NA) : y2.create(w + 1);
- });
- return l2 === 1 && f2 === 1 ? _.get(0, 0) : _;
- }
- _checkRefReferenceObject(e) {
- let t = false, r = g2.create(m2.NA);
- const n = [];
- return e.isReferenceObject() ? (e.toArrayValueObject().iterator((o) => {
- const u = o;
- if (u.isError())
- return t = true, r = u, false;
- if (u.isNull() || u.isBoolean())
- return true;
- const c = +u.getValue();
- if (Number.isNaN(c))
- return true;
- n.push(c);
- }), {
- refHasError: t,
- refErrorObject: r,
- refNumbers: n
- }) : {
- refHasError: true,
- refErrorObject: r,
- refNumbers: n
- };
- }
- };
- var Rm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = Math.floor(+l2.getValue());
- if (f2 < 0 || h < 1 || h > 10 ** 10 || d2 < 1 || d2 > 2)
- return g2.create(m2.NUM);
- let _ = $r(-f2, h);
- return d2 === 2 && (_ *= 2), Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
- }
- };
- var pm = [
- [Cm, le2.BETADIST],
- [Bo, le2.BETAINV],
- [Io, le2.BINOMDIST],
- [ko, le2.CHIDIST],
- [$o, le2.CHIINV],
- [Yo, le2.CHITEST],
- [Ho, le2.CONFIDENCE],
- [Go, le2.COVAR],
- [Fo, le2.CRITBINOM],
- [Qo, le2.EXPONDIST],
- [Wo, le2.FDIST],
- [qo, le2.FINV],
- [Ko, le2.FTEST],
- [Xo, le2.GAMMADIST],
- [Zo, le2.GAMMAINV],
- [_m, le2.HYPGEOMDIST],
- [Am, le2.LOGNORMDIST],
- [zo, le2.LOGINV],
- [Jo, le2.MODE],
- [Em, le2.NEGBINOMDIST],
- [eu, le2.NORMDIST],
- [tu, le2.NORMINV],
- [bm, le2.NORMSDIST],
- [ru, le2.NORMSINV],
- [nu2, le2.PERCENTILE],
- [su, le2.PERCENTRANK],
- [au, le2.POISSON],
- [iu, le2.QUARTILE],
- [ym, le2.RANK],
- [uu, le2.STDEV],
- [ou, le2.STDEVP],
- [Rm, le2.TDIST],
- [cu, le2.TINV],
- [lu, le2.TTEST],
- [hu, le2.VAR],
- [fu, le2.VARP],
- [mu, le2.WEIBULL],
- [gu, le2.ZTEST]
- ];
- var Vm = [];
- var Nm = ((i) => (i.CUBEKPIMEMBER = "CUBEKPIMEMBER", i.CUBEMEMBER = "CUBEMEMBER", i.CUBEMEMBERPROPERTY = "CUBEMEMBERPROPERTY", i.CUBERANKEDMEMBER = "CUBERANKEDMEMBER", i.CUBESET = "CUBESET", i.CUBESETCOUNT = "CUBESETCOUNT", i.CUBEVALUE = "CUBEVALUE", i))(Nm || {});
- var Om = class extends V {
- isCustom() {
- return true;
- }
- };
- var Qb = class extends Om {
- isAsync() {
- return true;
- }
- };
- function et(i) {
- const a2 = [];
- if (i.isError())
- return {
- isError: true,
- errorObject: i,
- databaseValues: a2
- };
- const e = i.isArray() ? i.getRowCount() : 1, t = i.isArray() ? i.getColumnCount() : 1;
- if (e < 2)
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- databaseValues: a2
- };
- for (let r = 0; r < e; r++) {
- const n = [];
- for (let s = 0; s < t; s++) {
- const o = i.get(r, s);
- if (o.isNull()) {
- n.push(null);
- continue;
- }
- let u = `${o.getValue()}`;
- if (o.isBoolean() && (u = u.toLocaleUpperCase()), o.isNumber() || DC(u)) {
- n.push(+u);
- continue;
- }
- n.push(u);
- }
- a2.push(n);
- }
- return {
- isError: false,
- errorObject: null,
- databaseValues: a2
- };
- }
- function tt2(i, a2) {
- let e = -1;
- if (i.isError())
- return {
- isError: true,
- errorObject: i,
- fieldIndex: e
- };
- const t = i.isArray() ? i.getRowCount() : 1, r = i.isArray() ? i.getColumnCount() : 1;
- if (t > 1 || r > 1)
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- fieldIndex: e
- };
- const n = i.isArray() ? i.get(0, 0) : i;
- let s = `${n.getValue()}`;
- if (n.isNull() ? s = 0 : n.isBoolean() ? s = n.getValue() ? 1 : 0 : (n.isNumber() || DC(s)) && (s = Math.floor(+s)), typeof s == "number") {
- if (s < 1 || s > a2[0].length)
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- fieldIndex: e
- };
- e = s - 1;
- } else if (e = a2[0].findIndex((o) => o === null ? false : `${o}`.toLocaleLowerCase() === s.toLocaleLowerCase()), e === -1)
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- fieldIndex: e
- };
- return {
- isError: false,
- errorObject: null,
- fieldIndex: e
- };
- }
- function rt(i) {
- const a2 = [];
- if (i.isError())
- return {
- isError: true,
- errorObject: i,
- criteriaValues: a2
- };
- const e = i.isArray() ? i.getRowCount() : 1, t = i.isArray() ? i.getColumnCount() : 1;
- if (e < 2)
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- criteriaValues: a2
- };
- for (let r = 0; r < e; r++) {
- const n = [];
- for (let s = 0; s < t; s++) {
- const o = i.get(r, s);
- if (o.isNull()) {
- n.push(null);
- continue;
- }
- const u = `${o.getValue()}`;
- if (o.isBoolean()) {
- n.push(o.getValue() ? 1 : 0);
- continue;
- }
- if (o.isNumber() || DC(u)) {
- n.push(+u);
- continue;
- }
- n.push(u);
- }
- a2.push(n);
- }
- return {
- isError: false,
- errorObject: null,
- criteriaValues: a2
- };
- }
- function nt2(i, a2, e) {
- const t = i.length, r = i[0].length, n = {};
- let s = false;
- for (let o = 1; o < t; o++) {
- let u = true;
- for (let c = 0; c < r; c++) {
- const l2 = i[o][c];
- if (l2 === null)
- continue;
- let f2 = n[c];
- if (f2 === void 0) {
- const h = i[0][c];
- f2 = a2[0].findIndex((d2) => d2 === null || h === null ? false : `${d2}`.toLocaleLowerCase() === `${h}`.toLocaleLowerCase()), n[c] = f2;
- }
- if (f2 === -1 && (typeof l2 == "string" || l2 === 0)) {
- u = false;
- break;
- } else if (f2 > -1) {
- const h = a2[e][f2];
- if (h === null) {
- u = false;
- break;
- }
- const [d2, _] = Aa(`${l2}`);
- if (!pt.create(`${h}`).compare(_, d2).getValue()) {
- u = false;
- break;
- }
- }
- }
- if (u) {
- s = true;
- break;
- }
- }
- return s;
- }
- var Mm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- let _ = 0, C = 0;
- for (let E2 = 1; E2 < o.length; E2++) {
- const b = o[E2][l2];
- typeof b == "number" && nt2(d2, o, E2) && (_ += b, C++);
- }
- return C === 0 ? g2.create(m2.DIV_BY_ZERO) : y2.create(_ / C);
- }
- };
- var wm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- let _ = 0;
- for (let C = 1; C < o.length; C++)
- typeof o[C][l2] == "number" && nt2(d2, o, C) && _++;
- return y2.create(_);
- }
- };
- var Dm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- let _ = 0;
- for (let C = 1; C < o.length; C++) {
- const E2 = o[C][l2];
- E2 != null && nt2(d2, o, C) && _++;
- }
- return y2.create(_);
- }
- };
- var Sm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- let _ = 0, C = 0;
- for (let E2 = 1; E2 < o.length; E2++) {
- const b = o[E2][l2];
- b != null && nt2(d2, o, E2) && (_++, C = E2);
- }
- return _ === 0 ? g2.create(m2.VALUE) : _ > 1 ? g2.create(m2.NUM) : e.get(C, l2);
- }
- };
- var Pm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- let _ = -1 / 0, C = 0;
- for (let E2 = 1; E2 < o.length; E2++) {
- const b = o[E2][l2];
- typeof b == "number" && nt2(d2, o, E2) && (_ = Math.max(_, b), C++);
- }
- return C === 0 ? y2.create(0) : y2.create(_);
- }
- };
- var Lm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- let _ = 1 / 0, C = 0;
- for (let E2 = 1; E2 < o.length; E2++) {
- const b = o[E2][l2];
- typeof b == "number" && nt2(d2, o, E2) && (_ = Math.min(_, b), C++);
- }
- return C === 0 ? y2.create(0) : y2.create(_);
- }
- };
- var xm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- let _ = 1, C = 0;
- for (let E2 = 1; E2 < o.length; E2++) {
- const b = o[E2][l2];
- typeof b == "number" && nt2(d2, o, E2) && (_ *= b, C++);
- }
- return C === 0 ? y2.create(0) : y2.create(_);
- }
- };
- var jm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- const _ = [];
- let C = 0, E2 = 0;
- for (let N2 = 1; N2 < o.length; N2++) {
- const M2 = o[N2][l2];
- typeof M2 == "number" && nt2(d2, o, N2) && (_.push(M2), C += M2, E2++);
- }
- if (E2 <= 1)
- return g2.create(m2.DIV_BY_ZERO);
- const b = C / E2;
- let R = 0;
- for (let N2 = 0; N2 < E2; N2++)
- R += (_[N2] - b) ** 2;
- const p2 = Math.sqrt(R / (E2 - 1));
- return y2.create(p2);
- }
- };
- var Um = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- const _ = [];
- let C = 0, E2 = 0;
- for (let N2 = 1; N2 < o.length; N2++) {
- const M2 = o[N2][l2];
- typeof M2 == "number" && nt2(d2, o, N2) && (_.push(M2), C += M2, E2++);
- }
- if (E2 === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const b = C / E2;
- let R = 0;
- for (let N2 = 0; N2 < E2; N2++)
- R += (_[N2] - b) ** 2;
- const p2 = Math.sqrt(R / E2);
- return y2.create(p2);
- }
- };
- var vm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- let _ = 0;
- for (let C = 1; C < o.length; C++) {
- const E2 = o[C][l2];
- typeof E2 == "number" && nt2(d2, o, C) && (_ += E2);
- }
- return y2.create(_);
- }
- };
- var Tm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- const _ = [];
- let C = 0, E2 = 0;
- for (let N2 = 1; N2 < o.length; N2++) {
- const M2 = o[N2][l2];
- typeof M2 == "number" && nt2(d2, o, N2) && (_.push(M2), C += M2, E2++);
- }
- if (E2 <= 1)
- return g2.create(m2.DIV_BY_ZERO);
- const b = C / E2;
- let R = 0;
- for (let N2 = 0; N2 < E2; N2++)
- R += (_[N2] - b) ** 2;
- const p2 = R / (E2 - 1);
- return y2.create(p2);
- }
- };
- var Bm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
- if (u)
- return c;
- const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
- if (f2)
- return h;
- const _ = [];
- let C = 0, E2 = 0;
- for (let N2 = 1; N2 < o.length; N2++) {
- const M2 = o[N2][l2];
- typeof M2 == "number" && nt2(d2, o, N2) && (_.push(M2), C += M2, E2++);
- }
- if (E2 === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const b = C / E2;
- let R = 0;
- for (let N2 = 0; N2 < E2; N2++)
- R += (_[N2] - b) ** 2;
- const p2 = R / E2;
- return y2.create(p2);
- }
- };
- var Qe = ((i) => (i.DAVERAGE = "DAVERAGE", i.DCOUNT = "DCOUNT", i.DCOUNTA = "DCOUNTA", i.DGET = "DGET", i.DMAX = "DMAX", i.DMIN = "DMIN", i.DPRODUCT = "DPRODUCT", i.DSTDEV = "DSTDEV", i.DSTDEVP = "DSTDEVP", i.DSUM = "DSUM", i.DVAR = "DVAR", i.DVARP = "DVARP", i))(Qe || {});
- var Im = [
- [Mm, Qe.DAVERAGE],
- [wm, Qe.DCOUNT],
- [Dm, Qe.DCOUNTA],
- [Sm, Qe.DGET],
- [Pm, Qe.DMAX],
- [Lm, Qe.DMIN],
- [xm, Qe.DPRODUCT],
- [jm, Qe.DSTDEV],
- [Um, Qe.DSTDEVP],
- [vm, Qe.DSUM],
- [Tm, Qe.DVAR],
- [Bm, Qe.DVARP]
- ];
- var Ua = "yyyy/mm/dd;@";
- var Fm = "yyyy/mm/dd hh:mm";
- var km = "h:mm A/P";
- function ye2(i) {
- const a2 = new Date(Date.UTC(1900, 0, 1)), e = new Date(Date.UTC(1900, 1, 28)), t = Date.UTC(i.getFullYear(), i.getMonth(), i.getDate());
- let r = (t - a2.getTime()) / (1e3 * 3600 * 24);
- return t > e.getTime() && (r += 1), Math.floor(r) + 1;
- }
- function Yr(i) {
- const a2 = new Date(Date.UTC(1900, 0, 1, 0, 0, 0)), e = new Date(Date.UTC(1900, 1, 28, 0, 0, 0));
- let r = (i.getTime() - a2.getTime()) / (1e3 * 3600 * 24);
- return i > e && (r += 1), r + 1;
- }
- function re2(i) {
- const a2 = new Date(Date.UTC(1900, 0, 1)), e = new Date(Date.UTC(1900, 1, 28));
- let t = Math.floor(i) - 1;
- return t > (e.getTime() - a2.getTime()) / (1e3 * 3600 * 24) && (t -= 1), new Date(a2.getTime() + t * (1e3 * 3600 * 24));
- }
- function va(i) {
- const a2 = new Date(Date.UTC(1900, 0, 1, 0, 0, 0)), e = new Date(Date.UTC(1900, 1, 28, 0, 0, 0));
- let t = i - 1;
- return t > (e.getTime() - a2.getTime()) / (1e3 * 3600 * 24) && (t -= 1), t < 0 && (t = i), new Date(a2.getTime() + t * (1e3 * 3600 * 24));
- }
- function Ta(i) {
- if (!/^\d{4}[-/](0?[1-9]|1[012])[-/](0?[1-9]|[12][0-9]|3[01])$/.test(i))
- return false;
- const e = i.replace(/-/g, "/").replace(/T.+/, ""), t = /* @__PURE__ */ new Date(`${e}`);
- if (Number.isNaN(t.getTime()))
- return false;
- const r = t.getFullYear(), n = (t.getMonth() + 1).toString().padStart(2, "0"), s = t.getDate().toString().padStart(2, "0"), o = `${r}-${n}-${s}`;
- return i.replace(/\//g, "-").split("-").map((c) => c.padStart(2, "0")).join("-") === o;
- }
- function Xs(i) {
- return Op.parseDate(i);
- }
- function du(i) {
- return Op.parseValue(i);
- }
- function Zs(i) {
- return Op.parseTime(i);
- }
- function Ba(i) {
- return Op.isDate(i);
- }
- var Cu = {
- 1: [6, 0],
- // Saturday, Sunday
- 2: [0, 1],
- // Sunday, Monday
- 3: [1, 2],
- // Monday, Tuesday
- 4: [2, 3],
- // Tuesday, Wednesday
- 5: [3, 4],
- // Wednesday, Thursday
- 6: [4, 5],
- // Thursday, Friday
- 7: [5, 6],
- // Friday, Saturday
- 11: [0],
- // Sunday only
- 12: [1],
- // Monday only
- 13: [2],
- // Tuesday only
- 14: [3],
- // Wednesday only
- 15: [4],
- // Thursday only
- 16: [5],
- // Friday only
- 17: [6]
- // Saturday only
- };
- function Ur(i) {
- return !!(typeof i == "string" && /^[0|1]{7}/.test(i) || Cu[Number(i)]);
- }
- function _u(i) {
- if (!Ur(i))
- return [];
- if (typeof i == "string" && /^[0|1]{7}/.test(i)) {
- const a2 = [];
- for (let e = 1; e <= i.length; e++)
- `${i[e - 1]}` == "1" && (e === i.length ? a2.push(0) : a2.push(e));
- return a2;
- }
- return Cu[Number(i)] || [];
- }
- function On(i, a2, e = 1, t) {
- const r = _u(e), n = Math.floor(i), s = Math.floor(a2), o = s > n ? n : s;
- let u = 0;
- const c = Math.abs(Math.floor(a2) - Math.floor(i)) + 1;
- for (let l2 = 0; l2 < c; l2++) {
- const f2 = o + l2;
- if (t && t.length > 0 && t.some((d2) => Math.floor(d2) === f2))
- continue;
- const h = rr(f2);
- r.includes(h) || u++;
- }
- return s >= n ? u : -u;
- }
- function Mn(i, a2, e = 1, t) {
- const r = _u(e), n = Math.floor(i);
- let s = n, o = Math.abs(a2);
- for (let u = 1; u <= o; u++) {
- const c = a2 < 0 ? n - u : n + u;
- if (c < 0)
- return g2.create(m2.NUM);
- if (t && t.length > 0 && t.some((f2) => Math.floor(f2) === c)) {
- o++;
- continue;
- }
- const l2 = rr(c);
- if (r.includes(l2)) {
- o++;
- continue;
- }
- s = c;
- }
- return s;
- }
- function k(i) {
- if (i.isError())
- return i;
- const a2 = i.getValue();
- if (i.isString()) {
- let e;
- if (Xs(`${a2}`))
- e = Xs(`${a2}`).v;
- else if (Zs(`${a2}`))
- e = Zs(`${a2}`).v;
- else if (DC(a2))
- e = +a2;
- else
- return g2.create(m2.VALUE);
- return e instanceof Date && (e = Yr(e)), +e < 0 || +e > 2958465 ? g2.create(m2.NUM) : +e;
- } else {
- const e = +i.getValue();
- return e < 0 || e > 2958465 ? g2.create(m2.NUM) : e;
- }
- }
- function rr(i) {
- const a2 = Math.floor(i) === 60;
- let e = re2(i);
- const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate())).getTime(), r = new Date(Date.UTC(1900, 1, 28)).getTime();
- return !a2 && t <= r && (e = new Date(t - 24 * 3600 * 1e3)), new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate())).getUTCDay();
- }
- function _e2(i, a2, e) {
- switch (e) {
- case 0:
- return $m(i, a2);
- case 1:
- return Ym(i, a2);
- case 2:
- return {
- days: Math.abs(a2 - i),
- yearDays: 360
- };
- case 3:
- return {
- days: Math.abs(a2 - i),
- yearDays: 365
- };
- case 4:
- return Hm(i, a2);
- default:
- return {
- days: Math.abs(a2 - i),
- yearDays: 365
- };
- }
- }
- function $m(i, a2) {
- const e = re2(i), t = i > 0 ? e.getUTCFullYear() : 1900, r = i > 0 ? e.getUTCMonth() + 1 : 1;
- let n = i > 0 ? e.getUTCDate() : 0, s = re2(a2), o = a2 > 0 ? s.getUTCFullYear() : 1900, u = a2 > 0 ? s.getUTCMonth() + 1 : 1, c = a2 > 0 ? s.getUTCDate() : 0;
- r === 2 ? re2(i + 1).getUTCMonth() + 1 === 3 && (n = 30) : n === 31 && (n = 30), c === 31 && (n < 30 ? (s = re2(a2 + 1), o = s.getUTCFullYear(), u = s.getUTCMonth() + 1, c = s.getUTCDate()) : c = 30);
- const l2 = (o - t) * 360, f2 = a2 >= i ? 30 - n : -n, h = a2 >= i ? c : c - 30, d2 = (a2 >= i ? u - r - 1 : u - r + 1) * 30;
- return {
- days: Math.abs(l2 + f2 + h + d2),
- yearDays: 360
- };
- }
- function Ym(i, a2) {
- const e = re2(i), t = i > 0 ? e.getUTCFullYear() : 1900, r = re2(a2), n = a2 > 0 ? r.getUTCFullYear() : 1900, s = Math.abs(a2 - i), o = Math.abs(n - t) + 1;
- let u, c;
- if (n < t) {
- const l2 = new Date(Date.UTC(n, 0, 1)), f2 = new Date(Date.UTC(t, 11, 31));
- u = ye2(l2), c = ye2(f2), n === 1900 && (u += 1);
- } else {
- const l2 = new Date(Date.UTC(t, 0, 1)), f2 = new Date(Date.UTC(n, 11, 31));
- u = ye2(l2), c = ye2(f2), t === 1900 && (u += 1);
- }
- return {
- days: s,
- yearDays: (c - u + 1) / o
- };
- }
- function Hm(i, a2) {
- const e = re2(i), t = i > 0 ? e.getUTCFullYear() : 1900, r = i > 0 ? e.getUTCMonth() + 1 : 1;
- let n = i > 0 ? e.getUTCDate() : 0;
- const s = re2(a2), o = a2 > 0 ? s.getUTCFullYear() : 1900, u = a2 > 0 ? s.getUTCMonth() + 1 : 1;
- let c = a2 > 0 ? s.getUTCDate() : 0;
- n === 31 && (n = 30), c === 31 && (c = 30);
- const l2 = (o - t) * 360, f2 = a2 >= i ? 30 - n : -n, h = a2 >= i ? c : c - 30, d2 = (a2 >= i ? u - r - 1 : u - r + 1) * 30;
- return {
- days: Math.abs(l2 + f2 + h + d2),
- yearDays: 360
- };
- }
- function Gm(i) {
- return i % 4 === 0 && i % 100 !== 0 || i % 400 === 0;
- }
- function Qm(i) {
- return i % 4 === 0 && i % 100 !== 0 || i % 400 === 0 || i === 1900;
- }
- var Wm = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
- var qm = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
- function Hr(i, a2) {
- return Gm(i) ? Wm[a2] : qm[a2];
- }
- function Jn(i) {
- return Qm(i) ? 366 : 365;
- }
- function Au(i, a2) {
- switch (a2) {
- case 0:
- case 2:
- case 4:
- return 360;
- case 1:
- return Jn(re2(i).getUTCFullYear());
- case 3:
- return 365;
- default:
- return -1;
- }
- }
- function Ar(i, a2, e) {
- return Hr(i, a2) === e;
- }
- function Er(i, a2) {
- let e = i.getUTCFullYear(), t = i.getUTCMonth();
- const r = i.getUTCDate();
- return Ar(e, t, r) ? (i.setUTCDate(1), i.setUTCMonth(i.getUTCMonth() + a2), e = i.getUTCFullYear(), t = i.getUTCMonth(), i.setUTCDate(Hr(e, t))) : i.setUTCMonth(i.getUTCMonth() + a2), i;
- }
- var Km = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e), u = O(n, s, t), c = O(n, s, r);
- return o.map((l2, f2, h) => {
- const d2 = u.get(f2, h) || ie.create(), _ = c.get(f2, h) || ie.create();
- if (l2.isError())
- return l2;
- if (d2.isError())
- return d2;
- if (_.isError())
- return _;
- if (l2.isString() || d2.isString() || _.isString())
- return g2.create(m2.VALUE);
- let C = +l2.getValue();
- const E2 = Math.floor(+d2.getValue()), b = +_.getValue();
- if (C < 0 || C > 9999)
- return g2.create(m2.NUM);
- C >= 0 && C < 1899 && (C += 1900);
- const R = new Date(C, E2 - 1, b), p2 = ye2(R);
- return p2 < 0 ? g2.create(m2.NUM) : y2.create(p2, Ua);
- });
- }
- };
- var Xm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = e, s = t, o = r;
- if (n.isArray() && (n = n.get(0, 0)), s.isArray() && (s = s.get(0, 0)), o.isArray() && (o = o.get(0, 0)), n.isError())
- return n;
- if (s.isError())
- return s;
- if (o.isError())
- return o;
- const u = k(n);
- if (typeof u != "number")
- return u;
- const c = k(s);
- return typeof c != "number" ? c : c < u || !o.isString() ? g2.create(m2.NUM) : this._getResultByUnit(u, c, o);
- }
- _getResultByUnit(e, t, r) {
- const n = re2(e), s = n.getUTCFullYear(), o = n.getUTCMonth() + 1, u = n.getUTCDate(), c = re2(t), l2 = c.getUTCFullYear(), f2 = c.getUTCMonth() + 1, h = c.getUTCDate(), d2 = `${r.getValue()}`.toLocaleUpperCase();
- let _ = 0, C;
- switch (d2) {
- case "Y":
- _ = l2 - s, (f2 < o || f2 === o && h < u) && (_ -= 1);
- break;
- case "M":
- _ = (l2 - s) * 12 + f2 - o, h < u && (_ -= 1);
- break;
- case "D":
- _ = Math.floor(t) - Math.floor(e);
- break;
- case "MD":
- _ = h - u, h < u && (C = new Date(Date.UTC(l2, f2 - 1, 0)), _ += Hr(C.getUTCFullYear(), C.getUTCMonth()));
- break;
- case "YM":
- _ = f2 - o, (f2 < o || f2 === o && h < u) && (_ += 12), h < u && (_ -= 1);
- break;
- case "YD":
- C = new Date(Date.UTC(s, f2 - 1, h)), (f2 < o || f2 === o && h < u) && (C = new Date(Date.UTC(s + 1, f2 - 1, h))), _ = Math.floor(ye2(C)) - Math.floor(e);
- break;
- default:
- return g2.create(m2.NUM);
- }
- return y2.create(_);
- }
- };
- var Zm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isString()) {
- const t = `${e.getValue()}`, r = du(t);
- if (r) {
- let { v: n, z: s } = r;
- if (s && Ba(s))
- return n instanceof Date && (n = Yr(n)), y2.create(Math.trunc(+n));
- }
- }
- return g2.create(m2.VALUE);
- }
- };
- var zm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t;
- const r = e.getValue();
- if (e.isString()) {
- if (!Ta(`${r}`))
- return g2.create(m2.VALUE);
- t = /* @__PURE__ */ new Date(`${r}`);
- } else {
- const o = +e.getValue();
- if (o < 0)
- return g2.create(m2.NUM);
- if (o === 0)
- return y2.create(0);
- t = re2(o);
- }
- const n = t.getDate();
- return y2.create(n);
- }
- };
- var Jm = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e), o = O(r, n, t), u = s.map((c, l2, f2) => {
- const h = o.get(l2, f2);
- if (c.isError())
- return c;
- if (h.isError())
- return h;
- const d2 = k(c);
- if (typeof d2 != "number")
- return d2;
- const _ = k(h);
- if (typeof _ != "number")
- return _;
- const C = Math.floor(d2) - Math.floor(_);
- return y2.create(C);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var eg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : T2.create(false);
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (n.isError())
- return n;
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.map((h, d2, _) => {
- const C = c.get(d2, _);
- let E2 = l2.get(d2, _);
- if (h.isError())
- return h;
- const b = k(h);
- if (typeof b != "number")
- return b;
- if (C.isError())
- return C;
- const R = k(C);
- if (typeof R != "number")
- return R;
- if (E2.isString() && (E2 = E2.convertToNumberObjectValue()), E2.isError())
- return E2;
- const p2 = +E2.getValue(), { days: N2 } = _e2(b, R, p2 ? 4 : 0), M2 = R >= b ? N2 : -N2;
- return y2.create(M2);
- });
- return s === 1 && o === 1 ? f2.get(0, 0) : f2;
- }
- };
- var tg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e), o = O(r, n, t);
- return s.map((u, c, l2) => {
- const f2 = o.get(c, l2) || ie.create();
- if (u.isError())
- return u;
- if (f2.isError())
- return f2;
- if (u.isString() || u.isBoolean() || f2.isString() || f2.isBoolean())
- return g2.create(m2.VALUE);
- const h = +u.getValue();
- if (h < 0)
- return g2.create(m2.NUM);
- const d2 = Math.floor(+f2.getValue()), _ = re2(h), C = _.getUTCFullYear(), E2 = _.getUTCMonth() + d2, b = _.getUTCDate(), R = new Date(Date.UTC(C, E2, b)), p2 = ye2(R);
- return y2.create(p2, Ua);
- });
- }
- };
- var rg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e, n = t;
- if (r.isArray()) {
- const d2 = r.getRowCount(), _ = r.getColumnCount();
- if (d2 > 1 || _ > 1)
- return g2.create(m2.VALUE);
- r = r.get(0, 0);
- }
- if (n.isArray()) {
- const d2 = n.getRowCount(), _ = n.getColumnCount();
- if (d2 > 1 || _ > 1)
- return g2.create(m2.VALUE);
- n = n.get(0, 0);
- }
- if (r.isError())
- return r;
- if (n.isError())
- return n;
- const s = k(r);
- if (typeof s != "number")
- return s;
- if (n.isBoolean())
- return g2.create(m2.VALUE);
- const o = re2(s), u = s > 0 ? o.getUTCFullYear() : 1900, c = s > 0 ? o.getUTCMonth() : 0, l2 = Math.floor(+n.getValue());
- if (Number.isNaN(l2))
- return g2.create(m2.VALUE);
- const f2 = new Date(Date.UTC(u, c + l2 + 1, 0)), h = ye2(f2);
- return y2.create(h);
- }
- };
- var ng = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- A(this, "needsReferenceObject", true);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(1), { isError: n, errorObject: s, timestampIsReferenceObject: o, timestampObject: u, unitObject: c } = this._checkVariants(e, r);
- if (n)
- return s;
- if (u.isNull() || u.isBoolean() || u.isString() || !o && u.isNumber() && u.getPattern() !== "")
- return g2.create(m2.VALUE);
- let l2 = +u.getValue();
- const { isError: f2, errorObject: h, variants: d2 } = I2(c);
- if (f2)
- return h;
- const [_] = d2, C = Math.floor(+_.getValue());
- if (l2 < 0 || C < 1 || C > 3)
- return g2.create(m2.NUM);
- C === 1 && (l2 = l2 * 1e3), C === 3 && (l2 = l2 / 1e3);
- const E2 = new Date(Date.UTC(1970, 0, 1, 0, 0, 0, 0) + l2);
- if (Number.isNaN(E2.getTime())) {
- const b = 25569 + l2 / 864e5;
- return y2.create(b);
- } else {
- const b = Yr(E2);
- return y2.create(b, "yyyy-MM-dd AM/PM hh:mm:ss");
- }
- }
- _checkVariants(e, t) {
- const r = e.isReferenceObject(), n = t.isReferenceObject();
- let s = e;
- if (r && (s = e.toArrayValueObject()), s.isArray()) {
- const u = s.getRowCount(), c = s.getColumnCount();
- if (u > 1 || c > 1)
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE)
- };
- s = s.get(0, 0);
- }
- if (s.isError())
- return {
- isError: true,
- errorObject: s
- };
- let o = t;
- if (n && (o = t.toArrayValueObject()), o.isArray()) {
- const u = o.getRowCount(), c = o.getColumnCount();
- if (u > 1 || c > 1)
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE)
- };
- o = o.get(0, 0);
- }
- return o.isError() ? {
- isError: true,
- errorObject: o
- } : {
- isError: false,
- errorObject: null,
- timestampIsReferenceObject: r,
- timestampObject: s,
- unitIsReferenceObject: n,
- unitObject: o
- };
- }
- };
- var be2 = ((i) => (i.DATE = "DATE", i.DATEDIF = "DATEDIF", i.DATEVALUE = "DATEVALUE", i.DAY = "DAY", i.DAYS = "DAYS", i.DAYS360 = "DAYS360", i.EDATE = "EDATE", i.EOMONTH = "EOMONTH", i.EPOCHTODATE = "EPOCHTODATE", i.HOUR = "HOUR", i.ISOWEEKNUM = "ISOWEEKNUM", i.MINUTE = "MINUTE", i.MONTH = "MONTH", i.NETWORKDAYS = "NETWORKDAYS", i.NETWORKDAYS_INTL = "NETWORKDAYS.INTL", i.NOW = "NOW", i.SECOND = "SECOND", i.TIME = "TIME", i.TIMEVALUE = "TIMEVALUE", i.TO_DATE = "TO_DATE", i.TODAY = "TODAY", i.WEEKDAY = "WEEKDAY", i.WEEKNUM = "WEEKNUM", i.WORKDAY = "WORKDAY", i.WORKDAY_INTL = "WORKDAY.INTL", i.YEAR = "YEAR", i.YEARFRAC = "YEARFRAC", i))(be2 || {});
- var sg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const t = k(e);
- if (typeof t != "number")
- return t;
- if (t === 0)
- return y2.create(0);
- const n = va(t).getUTCHours();
- return y2.create(n);
- }
- };
- var ag = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const t = k(e);
- if (typeof t != "number")
- return t;
- const r = re2(t), n = t > 0 ? r.getUTCFullYear() : 1900;
- let s = new Date(Date.UTC(n, 0, 1)), o = ye2(s), u = rr(o), c;
- u < 1 ? c = o + 1 : u <= 4 ? c = o - (u - 1) : c = o + (11 - u), t < c && (s = new Date(Date.UTC(n - 1, 0, 1)), o = ye2(s), u = rr(o), u < 1 ? c = o + 1 : u <= 4 ? c = o - (u - 1) : c = o + (11 - u));
- const l2 = Math.ceil((t - c + 1) / 7);
- return y2.create(l2);
- }
- };
- var ig = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const t = k(e);
- if (typeof t != "number")
- return t;
- if (t === 0)
- return y2.create(0);
- const n = va(t).getUTCMinutes();
- return y2.create(n);
- }
- };
- var og = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- let t;
- const r = e.getValue();
- if (e.isString()) {
- if (!Ta(`${r}`))
- return g2.create(m2.VALUE);
- t = /* @__PURE__ */ new Date(`${r}`);
- } else {
- const o = +e.getValue();
- if (o < 0)
- return g2.create(m2.NUM);
- if (o === 0)
- return y2.create(1);
- t = re2(o);
- }
- const n = t.getUTCMonth() + 1;
- return y2.create(n);
- }
- };
- var ug = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = e, s = t;
- if (n.isArray()) {
- const l2 = n.getRowCount(), f2 = n.getColumnCount();
- if (l2 > 1 || f2 > 1)
- return g2.create(m2.VALUE);
- n = n.get(0, 0);
- }
- if (n.isError())
- return n;
- if (s.isArray()) {
- const l2 = s.getRowCount(), f2 = s.getColumnCount();
- if (l2 > 1 || f2 > 1)
- return g2.create(m2.VALUE);
- s = s.get(0, 0);
- }
- if (s.isError())
- return s;
- if (r != null && r.isError())
- return r;
- if (n.isBoolean() || s.isBoolean())
- return g2.create(m2.VALUE);
- const o = k(n);
- if (typeof o != "number")
- return o;
- const u = k(s);
- if (typeof u != "number")
- return u;
- if (r)
- return this._getResultByHolidays(o, u, r);
- const c = On(o, u);
- return y2.create(c);
- }
- _getResultByHolidays(e, t, r) {
- const n = [];
- if (r != null && r.isArray()) {
- const o = r.getRowCount(), u = r.getColumnCount();
- for (let c = 0; c < o; c++)
- for (let l2 = 0; l2 < u; l2++) {
- const f2 = r.get(c, l2);
- if (f2.isBoolean())
- return g2.create(m2.VALUE);
- const h = k(f2);
- if (typeof h != "number")
- return h;
- n.push(h);
- }
- } else {
- if (r.isBoolean())
- return g2.create(m2.VALUE);
- const o = k(r);
- if (typeof o != "number")
- return o;
- n.push(o);
- }
- const s = On(e, t, 1, n);
- return y2.create(s);
- }
- };
- var cg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- return e.isError() ? e : t.isError() ? t : r != null && r.isError() ? r : n != null && n.isError() ? n : r != null && r.isArray() ? r.map((s) => this._handleSingleObject(e, t, s, n)) : this._handleSingleObject(e, t, r, n);
- }
- _handleSingleObject(e, t, r, n) {
- let s = e, o = t;
- if (s.isArray()) {
- const h = s.getRowCount(), d2 = s.getColumnCount();
- if (h > 1 || d2 > 1)
- return g2.create(m2.VALUE);
- s = s.get(0, 0);
- }
- if (s.isError())
- return s;
- if (o.isArray()) {
- const h = o.getRowCount(), d2 = o.getColumnCount();
- if (h > 1 || d2 > 1)
- return g2.create(m2.VALUE);
- o = o.get(0, 0);
- }
- if (o.isError())
- return o;
- let u = 1;
- if (r) {
- if (u = r.getValue(), r.isBoolean() && (u = +u), r.isString() && !Ur(u))
- return g2.create(m2.VALUE);
- if (!Ur(u))
- return g2.create(m2.NUM);
- }
- if (s.isBoolean() || o.isBoolean())
- return g2.create(m2.VALUE);
- const c = k(s);
- if (typeof c != "number")
- return c;
- const l2 = k(o);
- if (typeof l2 != "number")
- return l2;
- if (n)
- return this._getResultByHolidays(c, l2, u, n);
- const f2 = On(c, l2, u);
- return y2.create(f2);
- }
- _getResultByHolidays(e, t, r, n) {
- const s = [];
- if (n != null && n.isArray()) {
- const u = n.getRowCount(), c = n.getColumnCount();
- for (let l2 = 0; l2 < u; l2++)
- for (let f2 = 0; f2 < c; f2++) {
- const h = n.get(l2, f2);
- if (h.isBoolean())
- return g2.create(m2.VALUE);
- const d2 = k(h);
- if (typeof d2 != "number")
- return d2;
- s.push(d2);
- }
- } else {
- if (n.isBoolean())
- return g2.create(m2.VALUE);
- const u = k(n);
- if (typeof u != "number")
- return u;
- s.push(u);
- }
- const o = On(e, t, r, s);
- return y2.create(o);
- }
- };
- var lg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- const e = /* @__PURE__ */ new Date(), t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds())), r = Yr(t);
- return y2.create(r, Fm);
- }
- };
- var fg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const t = k(e);
- if (typeof t != "number")
- return t;
- if (t === 0)
- return y2.create(0);
- const n = va(t).getUTCSeconds();
- return y2.create(n);
- }
- };
- var hg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e), u = O(n, s, t), c = O(n, s, r);
- return o.map((l2, f2, h) => this._calculateTime(l2, u, c, f2, h));
- }
- _calculateTime(e, t, r, n, s) {
- let o = e, u = t.get(n, s) || ie.create(), c = r.get(n, s) || ie.create();
- if ((o.isString() || o.isBoolean()) && (o = o.convertToNumberObjectValue()), (u.isString() || u.isBoolean()) && (u = u.convertToNumberObjectValue()), (c.isString() || c.isBoolean()) && (c = c.convertToNumberObjectValue()), o.isError())
- return o;
- if (u.isError())
- return u;
- if (c.isError())
- return c;
- let l2 = Math.floor(+o.getValue()), f2 = Math.floor(+u.getValue()), h = Math.floor(+c.getValue());
- if (l2 < 0 || f2 < 0 || h < 0 || l2 > 32767 || f2 > 32767 || h > 32767)
- return g2.create(m2.NUM);
- f2 += Math.floor(h / 60), h %= 60, l2 += Math.floor(f2 / 60), f2 %= 60, l2 %= 24;
- const _ = (l2 * 3600 + f2 * 60 + h) / 86400;
- return y2.create(_, km);
- }
- };
- var mg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isString()) {
- const t = `${e.getValue()}`, r = du(t);
- if (r) {
- let { v: n, z: s } = r;
- if (s && Ba(s))
- return n instanceof Date && (n = Yr(n)), y2.create(Af(+n));
- }
- }
- return g2.create(m2.VALUE);
- }
- };
- var gg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", true);
- }
- calculate(e) {
- const t = e.isReferenceObject();
- let r = e;
- if (t && (r = e.toArrayValueObject()), r.isArray()) {
- const s = r.getRowCount(), o = r.getColumnCount();
- if (s > 1 || o > 1)
- return g2.create(m2.VALUE);
- r = r.get(0, 0);
- }
- if (r.isError() || r.isNull() || r.isBoolean() || r.isString() || !t && r.isNumber() && r.getPattern() !== "")
- return r;
- const n = +r.getValue();
- return y2.create(n, "yyyy-MM-dd hh:mm:ss AM/PM");
- }
- };
- var dg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- const e = ye2(/* @__PURE__ */ new Date());
- return y2.create(e, Ua);
- }
- };
- var Cg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- A(this, "_returnTypeMap", {
- 1: [1, 2, 3, 4, 5, 6, 7],
- // Sunday = 1 ~ Saturday = 7
- 2: [7, 1, 2, 3, 4, 5, 6],
- // Monday = 1 ~ Sunday = 7
- 3: [6, 0, 1, 2, 3, 4, 5],
- // Monday = 0 ~ Sunday = 6
- 11: [7, 1, 2, 3, 4, 5, 6],
- // Monday = 1 ~ Sunday = 7
- 12: [6, 7, 1, 2, 3, 4, 5],
- // Tuesday = 1 ~ Monday = 7
- 13: [5, 6, 7, 1, 2, 3, 4],
- // Wednesday = 1 ~ Tuesday = 7
- 14: [4, 5, 6, 7, 1, 2, 3],
- // Thursday = 1 ~ Wednesday = 7
- 15: [3, 4, 5, 6, 7, 1, 2],
- // Friday = 1 ~ Thursday = 7
- 16: [2, 3, 4, 5, 6, 7, 1],
- // Saturday = 1 ~ Friday = 7
- 17: [1, 2, 3, 4, 5, 6, 7]
- // Sunday = 1 ~ Saturday = 7
- });
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(1);
- if (e.isError())
- return e;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.map((l2, f2, h) => {
- const d2 = u.get(f2, h);
- return this._handleSingleObject(l2, d2);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- let r = t;
- if (e.isError())
- return e;
- if (r.isError())
- return r;
- const n = k(e);
- if (typeof n != "number")
- return n;
- if (r.isString() && (r = r.convertToNumberObjectValue(), r.isError()))
- return r;
- const s = Math.floor(+r.getValue());
- if (!this._returnTypeMap[s])
- return g2.create(m2.NUM);
- const o = rr(n), u = this._returnTypeMap[s][o];
- return y2.create(u);
- }
- };
- var _g = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- A(this, "_returnTypeMap", {
- 1: 0,
- 2: 1,
- 11: 1,
- 12: 2,
- 13: 3,
- 14: 4,
- 15: 5,
- 16: 6,
- 17: 0,
- 21: 4
- });
- }
- calculate(e, t) {
- let r = e, n = t != null ? t : y2.create(1);
- if (r.isArray()) {
- const u = r.getRowCount(), c = r.getColumnCount();
- if (u > 1 || c > 1)
- return g2.create(m2.VALUE);
- r = r.get(0, 0);
- }
- if (r.isError())
- return r;
- if (n.isArray()) {
- const u = n.getRowCount(), c = n.getColumnCount();
- if (u > 1 || c > 1)
- return g2.create(m2.VALUE);
- n = n.get(0, 0);
- }
- if (n.isError())
- return n;
- if (r.isBoolean())
- return g2.create(m2.VALUE);
- const s = k(r);
- if (typeof s != "number")
- return s;
- if (n.isBoolean())
- return g2.create(m2.VALUE);
- const o = Math.floor(+n.getValue());
- return Number.isNaN(o) ? g2.create(m2.VALUE) : o in this._returnTypeMap ? this._getResult(s, o) : g2.create(m2.NUM);
- }
- _getResult(e, t) {
- const r = re2(e), n = e > 0 ? r.getUTCFullYear() : 1900;
- let s = new Date(Date.UTC(n, 0, 1)), o = ye2(s), u = rr(o), c;
- if (t === 21)
- u < 1 ? c = o + 1 : u <= 4 ? c = o - (u - 1) : c = o + (11 - u), e < c && (s = new Date(Date.UTC(n - 1, 0, 1)), o = ye2(s), u = rr(o), u < 1 ? c = o + 1 : u <= 4 ? c = o - (u - 1) : c = o + (11 - u));
- else {
- const f2 = this._returnTypeMap[t];
- u < f2 ? c = o - (u + 7 - f2) : c = o - (u - f2);
- }
- const l2 = Math.ceil((e - c + 1) / 7);
- return y2.create(l2);
- }
- };
- var Ag = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = e, s = t;
- if (n.isArray()) {
- const l2 = n.getRowCount(), f2 = n.getColumnCount();
- if (l2 > 1 || f2 > 1)
- return g2.create(m2.VALUE);
- n = n.get(0, 0);
- }
- if (n.isError())
- return n;
- if (s.isArray()) {
- const l2 = s.getRowCount(), f2 = s.getColumnCount();
- if (l2 > 1 || f2 > 1)
- return g2.create(m2.VALUE);
- s = s.get(0, 0);
- }
- if (s.isError())
- return s;
- if (r != null && r.isError())
- return r;
- if (n.isBoolean() || s.isBoolean())
- return g2.create(m2.VALUE);
- const o = k(n);
- if (typeof o != "number")
- return o;
- const u = +s.getValue();
- if (Number.isNaN(u))
- return g2.create(m2.VALUE);
- if (r)
- return this._getResultByHolidays(o, u, r);
- const c = Mn(o, u);
- return typeof c != "number" ? c : y2.create(c);
- }
- _getResultByHolidays(e, t, r) {
- const n = [];
- if (r != null && r.isArray()) {
- const o = r.getRowCount(), u = r.getColumnCount();
- for (let c = 0; c < o; c++)
- for (let l2 = 0; l2 < u; l2++) {
- const f2 = r.get(c, l2);
- if (f2.isBoolean())
- return g2.create(m2.VALUE);
- const h = k(f2);
- if (typeof h != "number")
- return h;
- n.push(h);
- }
- } else {
- if (r.isBoolean())
- return g2.create(m2.VALUE);
- const o = k(r);
- if (typeof o != "number")
- return o;
- n.push(o);
- }
- const s = Mn(e, t, 1, n);
- return typeof s != "number" ? s : y2.create(s);
- }
- };
- var Eg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- return e.isError() ? e : t.isError() ? t : r != null && r.isError() ? r : n != null && n.isError() ? n : r != null && r.isArray() ? r.map((s) => this._handleSingleObject(e, t, s, n)) : this._handleSingleObject(e, t, r, n);
- }
- _handleSingleObject(e, t, r, n) {
- const s = r != null ? r : y2.create(1), o = this._checkArrayError(e);
- if (o.isError())
- return o;
- const u = this._checkArrayError(t);
- if (u.isError())
- return u;
- if (o.isBoolean() || u.isBoolean())
- return g2.create(m2.VALUE);
- const c = k(e);
- if (typeof c != "number")
- return c;
- const l2 = +t.getValue();
- if (Number.isNaN(l2))
- return g2.create(m2.VALUE);
- let f2 = s.getValue();
- if (s.isBoolean() && (f2 = +f2), s.isString() && (!Ur(f2) || f2 === "1111111"))
- return g2.create(m2.VALUE);
- if (!Ur(f2))
- return g2.create(m2.NUM);
- if (n)
- return this._getResultByHolidays(c, l2, f2, n);
- const h = Mn(c, l2, f2);
- return typeof h != "number" ? h : y2.create(h);
- }
- _checkArrayError(e) {
- let t = e;
- if (t.isArray()) {
- const r = t.getRowCount(), n = t.getColumnCount();
- if (r > 1 || n > 1)
- return g2.create(m2.VALUE);
- t = t.get(0, 0);
- }
- return t.isError(), t;
- }
- _getResultByHolidays(e, t, r, n) {
- const s = [];
- if (n != null && n.isArray()) {
- const u = n.getRowCount(), c = n.getColumnCount();
- for (let l2 = 0; l2 < u; l2++)
- for (let f2 = 0; f2 < c; f2++) {
- const h = n.get(l2, f2);
- if (h.isBoolean())
- return g2.create(m2.VALUE);
- const d2 = k(h);
- if (typeof d2 != "number")
- return d2;
- s.push(d2);
- }
- } else {
- if (n.isBoolean())
- return g2.create(m2.VALUE);
- const u = k(n);
- if (typeof u != "number")
- return u;
- s.push(u);
- }
- const o = Mn(e, t, r, s);
- return typeof o != "number" ? o : y2.create(o);
- }
- };
- var bg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- let t;
- const r = e.getValue();
- if (e.isString()) {
- if (!Ta(`${r}`))
- return g2.create(m2.VALUE);
- t = /* @__PURE__ */ new Date(`${r}`);
- } else {
- const o = +r;
- if (o < 0)
- return g2.create(m2.NUM);
- if (o === 0)
- return y2.create(1900);
- t = re2(o);
- }
- const n = t.getUTCFullYear();
- return y2.create(n);
- }
- };
- var yg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = r != null ? r : y2.create(0);
- const s = Xt(e);
- if (s.isError())
- return s;
- const o = Xt(t);
- if (o.isError())
- return o;
- if (n = Xt(n), n.isError())
- return n;
- if (s.isBoolean() || o.isBoolean() || n.isBoolean())
- return g2.create(m2.VALUE);
- const u = k(s);
- if (typeof u != "number")
- return u;
- const c = k(o);
- if (typeof c != "number")
- return c;
- const l2 = Math.floor(+n.getValue());
- if (Number.isNaN(l2))
- return g2.create(m2.VALUE);
- if (l2 < 0 || l2 > 4)
- return g2.create(m2.NUM);
- const { days: f2, yearDays: h } = _e2(u, c, l2), d2 = f2 / h;
- return y2.create(d2);
- }
- };
- var Rg = [
- [Km, be2.DATE],
- [Xm, be2.DATEDIF],
- [Zm, be2.DATEVALUE],
- [zm, be2.DAY],
- [Jm, be2.DAYS],
- [eg, be2.DAYS360],
- [tg, be2.EDATE],
- [rg, be2.EOMONTH],
- [ng, be2.EPOCHTODATE],
- [sg, be2.HOUR],
- [ag, be2.ISOWEEKNUM],
- [ig, be2.MINUTE],
- [og, be2.MONTH],
- [ug, be2.NETWORKDAYS],
- [cg, be2.NETWORKDAYS_INTL],
- [lg, be2.NOW],
- [fg, be2.SECOND],
- [hg, be2.TIME],
- [mg, be2.TIMEVALUE],
- [gg, be2.TO_DATE],
- [dg, be2.TODAY],
- [Cg, be2.WEEKDAY],
- [_g, be2.WEEKNUM],
- [Ag, be2.WORKDAY],
- [Eg, be2.WORKDAY_INTL],
- [bg, be2.YEAR],
- [yg, be2.YEARFRAC]
- ];
- var pg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g2.create(m2.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l2))
- return g2.create(m2.VALUE);
- if (l2 < 0)
- return g2.create(m2.NUM);
- const f2 = _r.besseli(c, l2);
- return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
- }
- };
- var Vg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g2.create(m2.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l2))
- return g2.create(m2.VALUE);
- if (l2 < 0)
- return g2.create(m2.NUM);
- const f2 = _r.besselj(c, l2);
- return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
- }
- };
- var Ng = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g2.create(m2.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l2))
- return g2.create(m2.VALUE);
- if (l2 < 0)
- return g2.create(m2.NUM);
- const f2 = _r.besselk(c, l2);
- return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
- }
- };
- var Og = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g2.create(m2.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l2))
- return g2.create(m2.VALUE);
- if (l2 < 0)
- return g2.create(m2.NUM);
- const f2 = _r.bessely(c, l2);
- return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
- }
- };
- var Mg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`;
- if (!Ra2(o))
- return g2.create(m2.NUM);
- let u;
- return o.length === 10 && o.substring(0, 1) === "1" ? u = Number.parseInt(o.substring(1), 2) - 512 : u = Number.parseInt(o, 2), y2.create(u);
- }
- };
- var wg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g2.create(m2.NA);
- let r = 0;
- if (t) {
- const { isError: f2, errorObject: h, variants: d2 } = H(t);
- if (f2)
- return h;
- const [_] = d2;
- if (r = Math.floor(+_.getValue()), Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (r < 0 || r > 10)
- return g2.create(m2.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!Ra2(c))
- return g2.create(m2.NUM);
- let l2;
- if (c.length === 10 && c.substring(0, 1) === "1")
- l2 = (1099511627264 + Number.parseInt(c.substring(1), 2)).toString(16);
- else if (l2 = Number.parseInt(c, 2).toString(16), t) {
- if (r < l2.length)
- return g2.create(m2.NUM);
- l2 = "0".repeat(r - l2.length) + l2;
- }
- return j.create(l2.toLocaleUpperCase());
- }
- };
- var Dg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g2.create(m2.NA);
- let r = 0;
- if (t) {
- const { isError: f2, errorObject: h, variants: d2 } = H(t);
- if (f2)
- return h;
- const [_] = d2;
- if (r = Math.floor(+_.getValue()), Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (r < 0 || r > 10)
- return g2.create(m2.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!Ra2(c))
- return g2.create(m2.NUM);
- let l2;
- if (c.length === 10 && c.substring(0, 1) === "1")
- l2 = (1073741312 + Number.parseInt(c.substring(1), 2)).toString(8);
- else if (l2 = Number.parseInt(c, 2).toString(8), t) {
- if (r < l2.length)
- return g2.create(m2.NUM);
- l2 = "0".repeat(r - l2.length) + l2;
- }
- return j.create(l2);
- }
- };
- var Sg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
- let h = c;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- let d2 = o.get(l2, f2);
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- const _ = +h.getValue(), C = +d2.getValue();
- if (_ < 0 || C < 0 || Math.floor(_) !== _ || Math.floor(C) !== C || _ > 281474976710655 || C > 281474976710655)
- return g2.create(m2.NUM);
- const E2 = _ & C;
- return y2.create(E2);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var Pg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
- let h = c;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- let d2 = o.get(l2, f2);
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- const _ = +h.getValue();
- let C = +d2.getValue();
- if (_ < 0 || Math.floor(_) !== _ || _ > 281474976710655 || Math.abs(C) > 53)
- return g2.create(m2.NUM);
- C = Math.trunc(C);
- const E2 = Number(C >= 0 ? BigInt(_) << BigInt(C) : BigInt(_) >> BigInt(-C));
- return E2 > 281474976710655 ? g2.create(m2.NUM) : y2.create(E2);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var Lg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
- let h = c;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- let d2 = o.get(l2, f2);
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- const _ = +h.getValue(), C = +d2.getValue();
- if (_ < 0 || C < 0 || Math.floor(_) !== _ || Math.floor(C) !== C || _ > 281474976710655 || C > 281474976710655)
- return g2.create(m2.NUM);
- const E2 = Number(BigInt(_) | BigInt(C));
- return y2.create(E2);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var xg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
- let h = c;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- let d2 = o.get(l2, f2);
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- const _ = +h.getValue();
- let C = +d2.getValue();
- if (_ < 0 || Math.floor(_) !== _ || _ > 281474976710655 || Math.abs(C) > 53)
- return g2.create(m2.NUM);
- C = Math.trunc(C);
- const E2 = Number(C >= 0 ? BigInt(_) >> BigInt(C) : BigInt(_) << BigInt(-C));
- return E2 > 281474976710655 ? g2.create(m2.NUM) : y2.create(E2);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var jg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
- let h = c;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- let d2 = o.get(l2, f2);
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- const _ = +h.getValue(), C = +d2.getValue();
- if (_ < 0 || C < 0 || Math.floor(_) !== _ || Math.floor(C) !== C || _ > 281474976710655 || C > 281474976710655)
- return g2.create(m2.NUM);
- const E2 = _ ^ C;
- return y2.create(E2);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- L2.prototype.cos = function() {
- const i = this.toNumber();
- return new L2(Math.cos(i));
- };
- var fe2 = class ce {
- constructor(a2) {
- A(this, "_inumber", "");
- A(this, "_realNum", 0);
- A(this, "_iNum", 0);
- A(this, "_suffix", "");
- A(this, "_isError", false);
- if (`${a2}`.trim() === "") {
- this._isError = true;
- return;
- }
- this._inumber = a2, this._getImReal(), this._getImAginary(), this._getImSuffix();
- }
- static getComplex(a2, e, t) {
- const r = new L2(a2).toSignificantDigits(15).toNumber(), n = new L2(e).toSignificantDigits(15).toNumber(), s = t === "" ? "i" : t;
- let o;
- if (r === 0 && n === 0)
- o = 0;
- else if (r === 0)
- o = n === 1 ? s : `${n}${s}`;
- else if (n === 0)
- o = r;
- else {
- const u = n > 0 ? "+" : "", c = n === 1 ? s : `${n}${s}`;
- o = `${r}${u}${c}`;
- }
- return o;
- }
- static createByComplexStr(a2, e, t) {
- const r = ce.getComplex(a2, e, t);
- return new ce(r);
- }
- _getImReal() {
- if (this._inumber === 0 || this._inumber === "0") {
- this._realNum = 0;
- return;
- }
- const a2 = `${this._inumber}`;
- if (["i", "+i", "1i", "+1i", "-i", "-1i", "j", "+j", "1j", "+1j", "-j", "-1j"].indexOf(a2) >= 0) {
- this._realNum = 0;
- return;
- }
- let e = a2.indexOf("+"), t = a2.indexOf("-");
- e === 0 && (e = a2.indexOf("+", 1)), t === 0 && (t = a2.indexOf("-", 1));
- const r = a2.substring(a2.length - 1, a2.length), n = r === "i" || r === "j";
- if (e >= 0 || t >= 0) {
- if (!n) {
- this._isError = true;
- return;
- }
- e >= 0 ? Number.isNaN(+a2.substring(0, e)) || Number.isNaN(+a2.substring(e + 1, a2.length - 1)) ? this._isError = true : this._realNum = +a2.substring(0, e) : Number.isNaN(+a2.substring(0, t)) || Number.isNaN(+a2.substring(t + 1, a2.length - 1)) ? this._isError = true : this._realNum = +a2.substring(0, t);
- } else
- n ? Number.isNaN(+a2.substring(0, a2.length - 1)) ? this._isError = true : this._realNum = 0 : Number.isNaN(+a2) ? this._isError = true : this._realNum = +a2;
- }
- _getImAginary() {
- if (this._isError)
- return;
- if (this._inumber === 0 || this._inumber === "0") {
- this._iNum = 0;
- return;
- }
- let a2 = `${this._inumber}`;
- if (["i", "j"].indexOf(a2) >= 0) {
- this._iNum = 1;
- return;
- }
- a2 = a2.replace("+i", "+1i").replace("-i", "-1i").replace("+j", "+1j").replace("-j", "-1j");
- let e = a2.indexOf("+"), t = a2.indexOf("-");
- e === 0 && (e = a2.indexOf("+", 1)), t === 0 && (t = a2.indexOf("-", 1));
- const r = a2.substring(a2.length - 1, a2.length), n = r === "i" || r === "j";
- if (e >= 0 || t >= 0) {
- if (!n) {
- this._isError = true;
- return;
- }
- e >= 0 ? Number.isNaN(+a2.substring(0, e)) || Number.isNaN(+a2.substring(e + 1, a2.length - 1)) ? this._isError = true : this._iNum = +a2.substring(e + 1, a2.length - 1) : Number.isNaN(+a2.substring(0, t)) || Number.isNaN(+a2.substring(t + 1, a2.length - 1)) ? this._isError = true : this._iNum = -+a2.substring(t + 1, a2.length - 1);
- } else
- n ? Number.isNaN(+a2.substring(0, a2.length - 1)) ? this._isError = true : this._iNum = +a2.substring(0, a2.length - 1) : Number.isNaN(+a2) ? this._isError = true : this._iNum = 0;
- }
- _getImSuffix() {
- const a2 = `${this._inumber}`, e = a2.substring(a2.length - 1);
- this._suffix = e === "i" || e === "j" ? e : "";
- }
- getRealNum() {
- return this._realNum;
- }
- getINum() {
- return this._iNum;
- }
- getSuffix() {
- return this._suffix;
- }
- isError() {
- return this._isError;
- }
- toString() {
- return ce.getComplex(this._realNum, this._iNum, this._suffix);
- }
- isDifferentSuffixes(a2) {
- const e = a2.getSuffix();
- return this._suffix === "" || e === "" ? false : this._suffix !== e;
- }
- Abs() {
- return L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2))).toSignificantDigits(16).toNumber();
- }
- Argument() {
- const a2 = L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2)));
- let e = L2.acos(new L2(this._realNum).div(a2)).toSignificantDigits(16).toNumber();
- return this._iNum < 0 && (e = -e), e;
- }
- Conjugate() {
- return ce.getComplex(this._realNum, -this._iNum, this._suffix);
- }
- Cos() {
- if (this._iNum) {
- const a2 = L2.cos(this._realNum).mul(L2.cosh(this._iNum)).toNumber(), e = L2.sin(this._realNum).mul(L2.sinh(this._iNum)).negated().toNumber();
- return ce.getComplex(a2, e, this._suffix);
- } else {
- const a2 = L2.cos(this._realNum).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Cosh() {
- if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
- return this._isError = true, "";
- if (this._iNum) {
- const a2 = L2.cosh(this._realNum).mul(L2.cos(this._iNum)).toNumber(), e = L2.sinh(this._realNum).mul(L2.sin(this._iNum)).toNumber();
- return ce.getComplex(a2, e, this._suffix);
- } else {
- const a2 = L2.cosh(this._realNum).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Cot() {
- if (this._iNum) {
- const a2 = L2.cosh(this._iNum * 2).sub(L2.cos(this._realNum * 2)), e = L2.sin(this._realNum * 2).div(a2).toNumber(), t = L2.sinh(this._iNum * 2).div(a2).negated().toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a2 = new L2(1).div(L2.tan(this._realNum)).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Coth() {
- if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
- return this._isError = true, "";
- if (this._iNum) {
- const a2 = L2.cosh(this._realNum * 2).sub(L2.cos(this._iNum * 2)), e = L2.sinh(this._realNum * 2).div(a2).toNumber(), t = L2.sin(this._iNum * 2).div(a2).negated().toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a2 = new L2(1).div(L2.tanh(this._realNum)).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Csc() {
- if (this._iNum) {
- const a2 = L2.cosh(this._iNum * 2).sub(L2.cos(this._realNum * 2)), e = L2.sin(this._realNum).mul(L2.cosh(this._iNum)).mul(2).div(a2).toNumber(), t = L2.cos(this._realNum).mul(L2.sinh(this._iNum)).mul(-2).div(a2).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a2 = new L2(1).div(L2.sin(this._realNum)).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Csch() {
- if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
- return ce.getComplex(0, 0, this._suffix);
- if (this._iNum) {
- const a2 = L2.cosh(this._realNum * 2).sub(L2.cos(this._iNum * 2)), e = L2.sinh(this._realNum).mul(L2.cos(this._iNum)).mul(2).div(a2).toNumber(), t = L2.cosh(this._realNum).mul(L2.sin(this._iNum)).mul(-2).div(a2).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a2 = new L2(1).div(L2.sinh(this._realNum)).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Div(a2) {
- const e = new L2(this._realNum), t = new L2(this._iNum), r = new L2(a2.getRealNum()), n = new L2(a2.getINum()), s = r.mul(r).add(n.mul(n)), o = e.mul(r).add(t.mul(n)).div(s).toNumber(), u = t.mul(r).sub(e.mul(n)).div(s).toNumber(), c = this._suffix === "" ? a2.getSuffix() : this._suffix;
- return ce.getComplex(o, u, c);
- }
- Exp() {
- if (!Number.isFinite(Math.exp(this._realNum)))
- return this._isError = true, "";
- const a2 = L2.exp(this._realNum).mul(L2.cos(this._iNum)).toNumber(), e = L2.exp(this._realNum).mul(L2.sin(this._iNum)).toNumber();
- return ce.getComplex(a2, e, this._suffix);
- }
- Ln() {
- const a2 = L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2))), e = L2.ln(a2).toNumber(), t = L2.acos(new L2(this._realNum).div(a2)).toNumber();
- return ce.getComplex(e, t, this._suffix);
- }
- Log(a2) {
- const e = L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2))), t = L2.ln(e);
- let r = L2.acos(new L2(this._realNum).div(e));
- this._iNum < 0 && (r = r.negated());
- const n = L2.ln(a2), s = new L2(0), o = n.mul(n).add(s.mul(s));
- if (o.eq(0))
- return this._isError = true, "";
- const u = t.mul(n).add(r.mul(s)).div(o).toNumber(), c = r.mul(n).sub(t.mul(s)).div(o).toNumber();
- return ce.getComplex(u, c, this._suffix);
- }
- Power(a2) {
- if (this._realNum === 0 && this._iNum === 0)
- return a2 > 0 ? ce.getComplex(this._realNum, this._iNum, this._suffix) : (this._isError = true, "");
- let e = L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2))), t = L2.acos(new L2(this._realNum).div(e));
- this._iNum < 0 && (t = t.negated()), e = L2.pow(e, a2), t = t.mul(a2);
- const r = L2.cos(t).mul(e).toNumber(), n = L2.sin(t).mul(e).toNumber();
- return !Number.isFinite(r) || !Number.isFinite(n) ? (this._isError = true, "") : ce.getComplex(r, n, this._suffix);
- }
- Product(a2) {
- const e = new L2(this._realNum), t = new L2(this._iNum), r = new L2(a2.getRealNum()), n = new L2(a2.getINum()), s = e.mul(r).sub(t.mul(n)).toNumber(), o = e.mul(n).add(t.mul(r)).toNumber(), u = this._suffix === "" ? a2.getSuffix() : this._suffix;
- return ce.getComplex(s, o, u);
- }
- Sec() {
- if (this._iNum) {
- const a2 = L2.cosh(this._iNum * 2).add(L2.cos(this._realNum * 2)), e = L2.cos(this._realNum).mul(L2.cosh(this._iNum)).mul(2).div(a2).toNumber(), t = L2.sin(this._realNum).mul(L2.sinh(this._iNum)).mul(2).div(a2).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a2 = new L2(1).div(L2.cos(this._realNum)).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Sech() {
- if (!Number.isFinite(Math.sinh(this._realNum * 2)) || !Number.isFinite(Math.cosh(this._realNum * 2)))
- return ce.getComplex(0, 0, this._suffix);
- if (this._iNum) {
- const a2 = L2.cosh(this._realNum * 2).add(L2.cos(this._iNum * 2)), e = L2.cosh(this._realNum).mul(L2.cos(this._iNum)).mul(2).div(a2).toNumber(), t = L2.sinh(this._realNum).mul(L2.sin(this._iNum)).mul(-2).div(a2).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a2 = new L2(1).div(L2.cosh(this._realNum)).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Sin() {
- if (this._iNum) {
- const a2 = L2.sin(this._realNum).mul(L2.cosh(this._iNum)).toNumber(), e = L2.cos(this._realNum).mul(L2.sinh(this._iNum)).toNumber();
- return ce.getComplex(a2, e, this._suffix);
- } else {
- const a2 = L2.sin(this._realNum).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Sinh() {
- if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
- return this._isError = true, "";
- if (this._iNum) {
- const a2 = L2.sinh(this._realNum).mul(L2.cos(this._iNum)).toNumber(), e = L2.cosh(this._realNum).mul(L2.sin(this._iNum)).toNumber();
- return ce.getComplex(a2, e, this._suffix);
- } else {
- const a2 = L2.sinh(this._realNum).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Sqrt() {
- const a2 = L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2))), e = L2.sqrt(a2);
- let t = L2.acos(new L2(this._realNum).div(a2));
- this._iNum < 0 && (t = t.negated());
- const r = e.mul(L2.cos(t.div(2).toNumber())).toNumber(), n = e.mul(L2.sin(t.div(2))).toNumber();
- return ce.getComplex(r, n, this._suffix);
- }
- Sub(a2) {
- const e = new L2(this._realNum), t = new L2(this._iNum), r = new L2(a2.getRealNum()), n = new L2(a2.getINum()), s = e.sub(r).toNumber(), o = t.sub(n).toNumber(), u = this._suffix === "" ? a2.getSuffix() : this._suffix;
- return ce.getComplex(s, o, u);
- }
- Sum(a2) {
- const e = new L2(this._realNum), t = new L2(this._iNum), r = new L2(a2.getRealNum()), n = new L2(a2.getINum()), s = e.add(r).toNumber(), o = t.add(n).toNumber(), u = this._suffix === "" ? a2.getSuffix() : this._suffix;
- return ce.getComplex(s, o, u);
- }
- Tan() {
- if (this._iNum) {
- const a2 = L2.cos(this._realNum * 2).add(L2.cosh(this._iNum * 2)), e = L2.sin(this._realNum * 2).div(a2).toNumber(), t = L2.sinh(this._iNum * 2).div(a2).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a2 = L2.tan(this._realNum).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- Tanh() {
- if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
- return this._isError = true, "";
- if (this._iNum) {
- const a2 = L2.cosh(this._realNum * 2).add(L2.cos(this._iNum * 2)), e = L2.sinh(this._realNum * 2).div(a2).toNumber(), t = L2.sin(this._iNum * 2).div(a2).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a2 = L2.tanh(this._realNum).toNumber();
- return ce.getComplex(a2, this._iNum, this._suffix);
- }
- }
- };
- var Ug = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : j.create("i"), { isError: s, errorObject: o, variants: u } = H(e, t, n);
- if (s)
- return o;
- const [c, l2, f2] = u, h = +c.getValue(), d2 = +l2.getValue(), _ = `${f2.getValue()}`;
- if (Number.isNaN(h) || Number.isNaN(d2) || _ !== "i" && _ !== "j")
- return g2.create(m2.VALUE);
- const C = fe2.getComplex(h, d2, _);
- return typeof C == "number" ? y2.create(C) : j.create(C);
- }
- };
- var vg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- A(this, "_units", [
- ["a.u. of action", "?", null, "action", false, false, 105457168181818e-48],
- ["a.u. of charge", "e", null, "electric_charge", false, false, 160217653141414e-33],
- ["a.u. of energy", "Eh", null, "energy", false, false, 435974417757576e-32],
- ["a.u. of length", "a?", null, "length", false, false, 529177210818182e-25],
- ["a.u. of mass", "m?", null, "mass", false, false, 910938261616162e-45],
- ["a.u. of time", "?/Eh", null, "time", false, false, 241888432650516e-31],
- ["admiralty knot", "admkn", null, "speed", false, true, 0.514773333],
- ["ampere", "A", null, "electric_current", true, false, 1],
- ["ampere per meter", "A/m", null, "magnetic_field_intensity", true, false, 1],
- ["ångström", "Å", ["ang"], "length", false, true, 1e-10],
- ["are", "ar", null, "area", false, true, 100],
- ["astronomical unit", "ua", null, "length", false, false, 149597870691667e-25],
- ["bar", "bar", null, "pressure", false, false, 1e5],
- ["barn", "b", null, "area", false, false, 1e-28],
- ["becquerel", "Bq", null, "radioactivity", true, false, 1],
- ["bit", "bit", ["b"], "information", false, true, 1],
- ["btu", "BTU", ["btu"], "energy", false, true, 1055.05585262],
- ["byte", "byte", null, "information", false, true, 8],
- ["candela", "cd", null, "luminous_intensity", true, false, 1],
- ["candela per square metre", "cd/m?", null, "luminance", true, false, 1],
- ["centigrade", "C", ["cel"], "temperature", true, false, 1],
- ["cubic ångström", "ang3", ["ang^3"], "volume", false, true, 1e-30],
- ["cubic foot", "ft3", ["ft^3"], "volume", false, true, 0.028316846592],
- ["cubic inch", "in3", ["in^3"], "volume", false, true, 16387064e-12],
- ["cubic light-year", "ly3", ["ly^3"], "volume", false, true, 846786664623715e-61],
- ["cubic metre", "m3", ["m^3"], "volume", true, true, 1],
- ["cubic mile", "mi3", ["mi^3"], "volume", false, true, 416818182544058e-5],
- ["cubic nautical mile", "Nmi3", ["Nmi^3"], "volume", false, true, 6352182208],
- ["cubic Pica", "Pica3", ["Picapt3", "Pica^3", "Picapt^3"], "volume", false, true, 758660370370369e-22],
- ["cubic yard", "yd3", ["yd^3"], "volume", false, true, 0.764554857984],
- ["cup", "cup", null, "volume", false, true, 2365882365e-13],
- ["dalton", "Da", ["u"], "mass", false, false, 166053886282828e-41],
- ["day", "d", ["day"], "time", false, true, 86400],
- ["degree", "°", null, "angle", false, false, 0.0174532925199433],
- ["dyne", "dyn", ["dy"], "force", false, true, 1e-5],
- ["electronvolt", "eV", ["ev"], "energy", false, true, 1.60217656514141],
- ["ell", "ell", null, "length", false, true, 1.143],
- ["erg", "erg", ["e"], "energy", false, true, 1e-7],
- ["fahrenheit", "F", ["fah"], "temperature", true, false, 1],
- ["fluid ounce", "oz", null, "volume", false, true, 295735295625e-16],
- ["foot", "ft", null, "length", false, true, 0.3048],
- ["foot-pound", "flb", null, "energy", false, true, 1.3558179483314],
- ["gal", "Gal", null, "acceleration", false, false, 0.01],
- ["gallon", "gal", null, "volume", false, true, 0.003785411784],
- ["gauss", "G", ["ga"], "magnetic_flux_density", false, true, 1],
- ["grain", "grain", null, "mass", false, true, 647989e-10],
- ["gram", "g", null, "mass", false, true, 1e-3],
- ["gray", "Gy", null, "absorbed_dose", true, false, 1],
- ["gross registered ton", "GRT", ["regton"], "volume", false, true, 2.8316846592],
- ["hectare", "ha", null, "area", false, true, 1e4],
- ["henry", "H", null, "inductance", true, false, 1],
- ["hertz", "Hz", null, "frequency", true, false, 1],
- ["horsepower", "HP", ["h"], "power", false, true, 745.69987158227],
- ["horsepower-hour", "HPh", ["hh", "hph"], "energy", false, true, 2684519538e-3],
- ["hour", "h", ["hr"], "time", false, true, 3600],
- ["imperial gallon (U.K.)", "uk_gal", null, "volume", false, true, 454609e-8],
- ["imperial hundredweight", "lcwt", ["uk_cwt", "hweight"], "mass", false, true, 50.802345],
- ["imperial quart (U.K)", "uk_qt", null, "volume", false, true, 0.0011365225],
- ["imperial ton", "brton", ["uk_ton", "LTON"], "mass", false, true, 1016.046909],
- ["inch", "in", null, "length", false, true, 0.0254],
- ["international acre", "uk_acre", null, "area", false, true, 4046.8564224],
- ["IT calorie", "cal", null, "energy", false, true, 4.1868],
- ["joule", "J", null, "energy", true, true, 1],
- ["katal", "kat", null, "catalytic_activity", true, false, 1],
- ["kelvin", "K", ["kel"], "temperature", true, true, 1],
- ["kilogram", "kg", null, "mass", true, true, 1],
- ["knot", "kn", null, "speed", false, true, 0.514444444444444],
- ["light-year", "ly", null, "length", false, true, 9460730472580800],
- ["litre", "L", ["l", "lt"], "volume", false, true, 1e-3],
- ["lumen", "lm", null, "luminous_flux", true, false, 1],
- ["lux", "lx", null, "illuminance", true, false, 1],
- ["maxwell", "Mx", null, "magnetic_flux", false, false, 1e-18],
- ["measurement ton", "MTON", null, "volume", false, true, 1.13267386368],
- ["meter per hour", "m/h", ["m/hr"], "speed", false, true, 27777777777778e-17],
- ["meter per second", "m/s", ["m/sec"], "speed", true, true, 1],
- ["meter per second squared", "m?s??", null, "acceleration", true, false, 1],
- ["parsec", "pc", ["parsec"], "length", false, true, 30856775814671900],
- ["meter squared per second", "m?/s", null, "kinematic_viscosity", true, false, 1],
- ["metre", "m", null, "length", true, true, 1],
- ["miles per hour", "mph", null, "speed", false, true, 0.44704],
- ["millimetre of mercury", "mmHg", null, "pressure", false, false, 133.322],
- ["minute", "?", null, "angle", false, false, 290888208665722e-18],
- ["minute", "min", ["mn"], "time", false, true, 60],
- ["modern teaspoon", "tspm", null, "volume", false, true, 5e-6],
- ["mole", "mol", null, "amount_of_substance", true, false, 1],
- ["morgen", "Morgen", null, "area", false, true, 2500],
- ["n.u. of action", "?", null, "action", false, false, 105457168181818e-48],
- ["n.u. of mass", "m?", null, "mass", false, false, 910938261616162e-45],
- ["n.u. of speed", "c?", null, "speed", false, false, 299792458],
- ["n.u. of time", "?/(me?c??)", null, "time", false, false, 128808866778687e-35],
- ["nautical mile", "M", ["Nmi"], "length", false, true, 1852],
- ["newton", "N", null, "force", true, true, 1],
- ["œrsted", "Oe ", null, "magnetic_field_intensity", false, false, 79.5774715459477],
- ["ohm", "Ω", null, "electric_resistance", true, false, 1],
- ["ounce mass", "ozm", null, "mass", false, true, 0.028349523125],
- ["pascal", "Pa", null, "pressure", true, false, 1],
- ["pascal second", "Pa?s", null, "dynamic_viscosity", true, false, 1],
- ["pferdestärke", "PS", null, "power", false, true, 735.49875],
- ["phot", "ph", null, "illuminance", false, false, 1e-4],
- ["pica (1/6 inch)", "pica", null, "length", false, true, 35277777777778e-17],
- ["pica (1/72 inch)", "Pica", ["Picapt"], "length", false, true, 0.00423333333333333],
- ["poise", "P", null, "dynamic_viscosity", false, false, 0.1],
- ["pond", "pond", null, "force", false, true, 980665e-8],
- ["pound force", "lbf", null, "force", false, true, 4.4482216152605],
- ["pound mass", "lbm", null, "mass", false, true, 0.45359237],
- ["quart", "qt", null, "volume", false, true, 946352946e-12],
- ["radian", "rad", null, "angle", true, false, 1],
- ["rankine", "Rank", null, "temperature", false, true, 1],
- ["reaumur", "Reau", null, "temperature", false, true, 1],
- ["second", "?", null, "angle", false, false, 484813681109536e-20],
- ["second", "s", ["sec"], "time", true, true, 1],
- ["short hundredweight", "cwt", ["shweight"], "mass", false, true, 45.359237],
- ["siemens", "S", null, "electrical_conductance", true, false, 1],
- ["sievert", "Sv", null, "equivalent_dose", true, false, 1],
- ["slug", "sg", null, "mass", false, true, 14.59390294],
- ["square ångström", "ang2", ["ang^2"], "area", false, true, 1e-20],
- ["square foot", "ft2", ["ft^2"], "area", false, true, 0.09290304],
- ["square inch", "in2", ["in^2"], "area", false, true, 64516e-8],
- ["square light-year", "ly2", ["ly^2"], "area", false, true, 895054210748189e17],
- ["square meter", "m?", null, "area", true, true, 1],
- ["square mile", "mi2", ["mi^2"], "area", false, true, 2589988110336e-6],
- ["square nautical mile", "Nmi2", ["Nmi^2"], "area", false, true, 3429904],
- ["square Pica", "Pica2", ["Picapt2", "Pica^2", "Picapt^2"], "area", false, true, 1792111111111e-17],
- ["square yard", "yd2", ["yd^2"], "area", false, true, 0.83612736],
- ["statute mile", "mi", null, "length", false, true, 1609.344],
- ["steradian", "sr", null, "solid_angle", true, false, 1],
- ["stilb", "sb", null, "luminance", false, false, 1e-4],
- ["stokes", "St", null, "kinematic_viscosity", false, false, 1e-4],
- ["stone", "stone", null, "mass", false, true, 6.35029318],
- ["tablespoon", "tbs", null, "volume", false, true, 147868e-10],
- ["teaspoon", "tsp", null, "volume", false, true, 492892e-11],
- ["tesla", "T", null, "magnetic_flux_density", true, true, 1],
- ["thermodynamic calorie", "c", null, "energy", false, true, 4.184],
- ["ton", "ton", null, "mass", false, true, 907.18474],
- ["tonne", "t", null, "mass", false, false, 1e3],
- ["U.K. pint", "uk_pt", null, "volume", false, true, 56826125e-11],
- ["U.S. bushel", "bushel", null, "volume", false, true, 0.03523907],
- ["U.S. oil barrel", "barrel", null, "volume", false, true, 0.158987295],
- ["U.S. pint", "pt", ["us_pt"], "volume", false, true, 473176473e-12],
- ["U.S. survey mile", "survey_mi", null, "length", false, true, 1609.347219],
- ["U.S. survey/statute acre", "us_acre", null, "area", false, true, 4046.87261],
- ["volt", "V", null, "voltage", true, false, 1],
- ["watt", "W", null, "power", true, true, 1],
- ["watt-hour", "Wh", ["wh"], "energy", false, true, 3600],
- ["weber", "Wb", null, "magnetic_flux", true, false, 1],
- ["yard", "yd", null, "length", false, true, 0.9144],
- ["year", "yr", null, "time", false, true, 31557600]
- ]);
- A(this, "_binaryPrefixes", {
- Yi: ["yobi", 80, 12089258196146292e8, "Yi", "yotta"],
- Zi: ["zebi", 70, 11805916207174113e5, "Zi", "zetta"],
- Ei: ["exbi", 60, 1152921504606847e3, "Ei", "exa"],
- Pi: ["pebi", 50, 1125899906842624, "Pi", "peta"],
- Ti: ["tebi", 40, 1099511627776, "Ti", "tera"],
- Gi: ["gibi", 30, 1073741824, "Gi", "giga"],
- Mi: ["mebi", 20, 1048576, "Mi", "mega"],
- ki: ["kibi", 10, 1024, "ki", "kilo"]
- });
- A(this, "_unitPrefixes", {
- Y: ["yotta", 1e24, "Y"],
- Z: ["zetta", 1e21, "Z"],
- E: ["exa", 1e18, "E"],
- P: ["peta", 1e15, "P"],
- T: ["tera", 1e12, "T"],
- G: ["giga", 1e9, "G"],
- M: ["mega", 1e6, "M"],
- k: ["kilo", 1e3, "k"],
- h: ["hecto", 100, "h"],
- e: ["dekao", 10, "e"],
- d: ["deci", 0.1, "d"],
- c: ["centi", 0.01, "c"],
- m: ["milli", 1e-3, "m"],
- u: ["micro", 1e-6, "u"],
- n: ["nano", 1e-9, "n"],
- p: ["pico", 1e-12, "p"],
- f: ["femto", 1e-15, "f"],
- a: ["atto", 1e-18, "a"],
- z: ["zepto", 1e-21, "z"],
- y: ["yocto", 1e-24, "y"]
- });
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = H(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = `${c.getValue()}`, d2 = `${l2.getValue()}`;
- if (Number.isNaN(f2))
- return g2.create(m2.VALUE);
- let _, C = 1, E2, b = 1;
- const { _from: R, _to: p2 } = this._lookupFromAndToUnits(h, d2);
- if (_ = R, E2 = p2, _ === null) {
- const { _from: M2, _fromMultiplier: w } = this._lookupFromPrefix(h);
- _ = M2, C = w;
- }
- if (E2 === null) {
- const { _to: M2, _toMultiplier: w } = this._lookupToPrefix(d2);
- E2 = M2, b = w;
- }
- if (_ === null || E2 === null || _[3] !== E2[3])
- return g2.create(m2.NA);
- let N2;
- return _[3] === "temperature" ? (N2 = this._getTemperatureConversion(f2, _[1], E2[1]), N2 = +N2.toFixed(2)) : N2 = f2 * _[6] * C / (E2[6] * b), y2.create(N2);
- }
- _lookupFromAndToUnits(e, t) {
- let r = null, n = null, s;
- for (let o = 0; o < this._units.length; o++)
- s = this._units[o][2] === null ? [] : this._units[o][2], (this._units[o][1] === e || s.indexOf(e) >= 0) && (r = this._units[o]), (this._units[o][1] === t || s.indexOf(t) >= 0) && (n = this._units[o]);
- return {
- _from: r,
- _to: n
- };
- }
- _lookupFromPrefix(e) {
- let t = null, r = 1, n = e, s;
- const o = this._binaryPrefixes[e.substring(0, 2)];
- let u = this._unitPrefixes[e.substring(0, 1)];
- e.substring(0, 2) === "da" && (u = ["dekao", 10, "da"]), o ? (r = o[2], n = e.substring(2)) : u && (r = u[1], n = e.substring(u[2].length));
- for (let c = 0; c < this._units.length; c++)
- s = this._units[c][2] === null ? [] : this._units[c][2], (this._units[c][1] === n || s.indexOf(n) >= 0) && (t = this._units[c]);
- return {
- _from: t,
- _fromMultiplier: r
- };
- }
- _lookupToPrefix(e) {
- let t = null, r = 1, n = e, s;
- const o = this._binaryPrefixes[e.substring(0, 2)];
- let u = this._unitPrefixes[e.substring(0, 1)];
- e.substring(0, 2) === "da" && (u = ["dekao", 10, "da"]), o ? (r = o[2], n = e.substring(2)) : u && (r = u[1], n = e.substring(u[2].length));
- for (let c = 0; c < this._units.length; c++)
- s = this._units[c][2] === null ? [] : this._units[c][2], (this._units[c][1] === n || s.indexOf(n) >= 0) && (t = this._units[c]);
- return {
- _to: t,
- _toMultiplier: r
- };
- }
- _getTemperatureConversion(e, t, r) {
- switch (t) {
- case "C":
- return this._centigradeConversion(e, r);
- case "F":
- return this._fahrenheitConversion(e, r);
- case "K":
- return this._kelvinConversion(e, r);
- case "Rank":
- return this._rankineConversion(e, r);
- case "Reau":
- return this._reaumurConversion(e, r);
- default:
- return e;
- }
- }
- _centigradeConversion(e, t) {
- switch (t) {
- case "F":
- return e * 9 / 5 + 32;
- case "K":
- return e + 273.15;
- case "Rank":
- return (e + 273.15) * 9 / 5;
- case "Reau":
- return e * 4 / 5;
- default:
- return e;
- }
- }
- _fahrenheitConversion(e, t) {
- switch (t) {
- case "C":
- return (e - 32) * 5 / 9;
- case "K":
- return (e - 32) * 5 / 9 + 273.15;
- case "Rank":
- return e + 459.67;
- case "Reau":
- return (e - 32) * 4 / 9;
- default:
- return e;
- }
- }
- _kelvinConversion(e, t) {
- switch (t) {
- case "C":
- return e - 273.15;
- case "F":
- return (e - 273.15) * 9 / 5 + 32;
- case "Rank":
- return e * 9 / 5;
- case "Reau":
- return (e - 273.15) * 4 / 5;
- default:
- return e;
- }
- }
- _rankineConversion(e, t) {
- switch (t) {
- case "C":
- return (e - 491.67) * 5 / 9;
- case "F":
- return e - 459.67;
- case "K":
- return e * 5 / 9;
- case "Reau":
- return (e - 491.67) * 4 / 9;
- default:
- return e;
- }
- }
- _reaumurConversion(e, t) {
- switch (t) {
- case "C":
- return e * 5 / 4;
- case "F":
- return e * 9 / 4 + 32;
- case "K":
- return e * 5 / 4 + 273.15;
- case "Rank":
- return e * 9 / 4 + 491.67;
- default:
- return e;
- }
- }
- };
- var Tg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g2.create(m2.NA);
- let r = 0;
- if (t) {
- const { isError: f2, errorObject: h, variants: d2 } = H(t);
- if (f2)
- return h;
- const [_] = d2;
- if (r = Math.floor(+_.getValue()), Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (r < 0 || r > 10)
- return g2.create(m2.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = Math.trunc(+u.getValue());
- if (Number.isNaN(c))
- return g2.create(m2.VALUE);
- if (!/^-?[0-9]{1,3}$/.test(`${c}`) || c < -512 || c > 511)
- return g2.create(m2.NUM);
- let l2;
- if (c < 0) {
- const f2 = (512 + c).toString(2);
- l2 = `1${"0".repeat(9 - f2.length)}${f2}`;
- } else if (l2 = Number.parseInt(`${c}`, 10).toString(2), t) {
- if (r < l2.length)
- return g2.create(m2.NUM);
- l2 = "0".repeat(r - l2.length) + l2;
- }
- return j.create(l2);
- }
- };
- var Bg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g2.create(m2.NA);
- let r = 0;
- if (t) {
- const { isError: f2, errorObject: h, variants: d2 } = H(t);
- if (f2)
- return h;
- const [_] = d2;
- if (r = Math.floor(+_.getValue()), Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (r < 0 || r > 10)
- return g2.create(m2.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = Math.trunc(+u.getValue());
- if (Number.isNaN(c))
- return g2.create(m2.VALUE);
- if (!/^-?[0-9]{1,12}$/.test(`${c}`) || c < -549755813888 || c > 549755813887)
- return g2.create(m2.NUM);
- let l2;
- if (c < 0)
- l2 = (1099511627776 + c).toString(16);
- else if (l2 = Number.parseInt(`${c}`, 10).toString(16), t) {
- if (r < l2.length)
- return g2.create(m2.NUM);
- l2 = "0".repeat(r - l2.length) + l2;
- }
- return j.create(l2.toLocaleUpperCase());
- }
- };
- var Ig = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g2.create(m2.NA);
- let r = 0;
- if (t) {
- const { isError: f2, errorObject: h, variants: d2 } = H(t);
- if (f2)
- return h;
- const [_] = d2;
- if (r = Math.floor(+_.getValue()), Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (r < 0 || r > 10)
- return g2.create(m2.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = Math.trunc(+u.getValue());
- if (Number.isNaN(c))
- return g2.create(m2.VALUE);
- if (!/^-?[0-9]{1,9}$/.test(`${c}`) || c < -536870912 || c > 536870911)
- return g2.create(m2.NUM);
- let l2;
- if (c < 0)
- l2 = (1073741824 + c).toString(8);
- else if (l2 = Number.parseInt(`${c}`, 10).toString(8), t) {
- if (r < l2.length)
- return g2.create(m2.NUM);
- l2 = "0".repeat(r - l2.length) + l2;
- }
- return j.create(l2);
- }
- };
- var Fg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(0), { isError: n, errorObject: s, variants: o } = H(e, r);
- if (n)
- return s;
- const [u, c] = o, l2 = +u.getValue(), f2 = +c.getValue();
- if (Number.isNaN(l2) || Number.isNaN(f2))
- return g2.create(m2.VALUE);
- const h = l2 === f2 ? 1 : 0;
- return y2.create(h);
- }
- };
- var kg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r;
- if (t) {
- const { isError: n, errorObject: s, variants: o } = H(e, t);
- if (n)
- return s;
- const [u, c] = o, l2 = +u.getValue(), f2 = +c.getValue();
- if (Number.isNaN(l2) || Number.isNaN(f2))
- return g2.create(m2.VALUE);
- r = Zt(f2) - Zt(l2);
- } else {
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = +u.getValue();
- if (Number.isNaN(c))
- return g2.create(m2.VALUE);
- r = Zt(c);
- }
- return y2.create(r);
- }
- };
- var $g = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (Number.isNaN(o))
- return g2.create(m2.VALUE);
- const u = Zt(o);
- return y2.create(u);
- }
- };
- var Yg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (Number.isNaN(o))
- return g2.create(m2.VALUE);
- const u = Na(o);
- return y2.create(u);
- }
- };
- var Hg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (Number.isNaN(o))
- return g2.create(m2.VALUE);
- const u = Na(o);
- return y2.create(u);
- }
- };
- var Z2 = ((i) => (i.BESSELI = "BESSELI", i.BESSELJ = "BESSELJ", i.BESSELK = "BESSELK", i.BESSELY = "BESSELY", i.BIN2DEC = "BIN2DEC", i.BIN2HEX = "BIN2HEX", i.BIN2OCT = "BIN2OCT", i.BITAND = "BITAND", i.BITLSHIFT = "BITLSHIFT", i.BITOR = "BITOR", i.BITRSHIFT = "BITRSHIFT", i.BITXOR = "BITXOR", i.COMPLEX = "COMPLEX", i.CONVERT = "CONVERT", i.DEC2BIN = "DEC2BIN", i.DEC2HEX = "DEC2HEX", i.DEC2OCT = "DEC2OCT", i.DELTA = "DELTA", i.ERF = "ERF", i.ERF_PRECISE = "ERF.PRECISE", i.ERFC = "ERFC", i.ERFC_PRECISE = "ERFC.PRECISE", i.GESTEP = "GESTEP", i.HEX2BIN = "HEX2BIN", i.HEX2DEC = "HEX2DEC", i.HEX2OCT = "HEX2OCT", i.IMABS = "IMABS", i.IMAGINARY = "IMAGINARY", i.IMARGUMENT = "IMARGUMENT", i.IMCONJUGATE = "IMCONJUGATE", i.IMCOS = "IMCOS", i.IMCOSH = "IMCOSH", i.IMCOT = "IMCOT", i.IMCOTH = "IMCOTH", i.IMCSC = "IMCSC", i.IMCSCH = "IMCSCH", i.IMDIV = "IMDIV", i.IMEXP = "IMEXP", i.IMLN = "IMLN", i.IMLOG = "IMLOG", i.IMLOG10 = "IMLOG10", i.IMLOG2 = "IMLOG2", i.IMPOWER = "IMPOWER", i.IMPRODUCT = "IMPRODUCT", i.IMREAL = "IMREAL", i.IMSEC = "IMSEC", i.IMSECH = "IMSECH", i.IMSIN = "IMSIN", i.IMSINH = "IMSINH", i.IMSQRT = "IMSQRT", i.IMSUB = "IMSUB", i.IMSUM = "IMSUM", i.IMTAN = "IMTAN", i.IMTANH = "IMTANH", i.OCT2BIN = "OCT2BIN", i.OCT2DEC = "OCT2DEC", i.OCT2HEX = "OCT2HEX", i))(Z2 || {});
- var Gg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g2.create(m2.NA);
- const r = t != null ? t : y2.create(0), { isError: n, errorObject: s, variants: o } = H(e, r);
- if (n)
- return s;
- const [u, c] = o, l2 = +u.getValue(), f2 = +c.getValue();
- if (Number.isNaN(l2) || Number.isNaN(f2))
- return g2.create(m2.VALUE);
- const h = l2 >= f2 ? 1 : 0;
- return y2.create(h);
- }
- };
- var Qg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g2.create(m2.NA);
- let r = 0;
- if (t) {
- const { isError: d2, errorObject: _, variants: C } = H(t);
- if (d2)
- return _;
- const [E2] = C;
- if (r = Math.floor(+E2.getValue()), Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (r < 0 || r > 10)
- return g2.create(m2.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!Va(c))
- return g2.create(m2.NUM);
- const l2 = c.length === 10 && c.substring(0, 1).toLocaleUpperCase() === "F", f2 = l2 ? Number.parseInt(c, 16) - 1099511627776 : Number.parseInt(c, 16);
- if (f2 < -512 || f2 > 511)
- return g2.create(m2.NUM);
- let h;
- if (l2) {
- const d2 = (512 + f2).toString(2);
- h = `1${"0".repeat(9 - d2.length)}${d2}`;
- } else if (h = f2.toString(2), t) {
- if (r < h.length)
- return g2.create(m2.NUM);
- h = "0".repeat(r - h.length) + h;
- }
- return j.create(h);
- }
- };
- var Wg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`;
- if (!Va(o))
- return g2.create(m2.NUM);
- let u = Number.parseInt(o, 16);
- return u >= 549755813888 && (u -= 1099511627776), y2.create(u);
- }
- };
- var qg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g2.create(m2.NA);
- let r = 0;
- if (t) {
- const { isError: h, errorObject: d2, variants: _ } = H(t);
- if (h)
- return d2;
- const [C] = _;
- if (r = Math.floor(+C.getValue()), Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (r < 0 || r > 10)
- return g2.create(m2.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!Va(c))
- return g2.create(m2.NUM);
- const l2 = Number.parseInt(c, 16);
- if (l2 > 536870911 && l2 < 1098974756864)
- return g2.create(m2.NUM);
- let f2;
- if (l2 >= 1098974756864)
- f2 = (l2 - 1098437885952).toString(8);
- else if (f2 = l2.toString(8), t) {
- if (r < f2.length)
- return g2.create(m2.NUM);
- f2 = "0".repeat(r - f2.length) + f2;
- }
- return j.create(f2);
- }
- };
- var Kg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Abs();
- return y2.create(c);
- }
- };
- var Xg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.getINum();
- return y2.create(c);
- }
- };
- var Zg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- if (u.getRealNum() === 0 && u.getINum() === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const c = u.Argument();
- return y2.create(c);
- }
- };
- var zg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Conjugate();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var Jg = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Cos();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var e1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Cosh();
- return u.isError() ? g2.create(m2.NUM) : typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var t1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g2.create(m2.NUM);
- const c = u.Cot();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var r1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g2.create(m2.NUM);
- const c = u.Coth();
- return u.isError() ? g2.create(m2.NUM) : typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var n1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g2.create(m2.NUM);
- const c = u.Csc();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var s1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g2.create(m2.NUM);
- const c = u.Csch();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var a1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g2.create(m2.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = `${o.getValue()}`, l2 = `${u.getValue()}`, f2 = new fe2(c), h = new fe2(l2);
- if (f2.isError() || h.isError() || f2.isDifferentSuffixes(h) || h.getRealNum() === 0 && h.getINum() === 0)
- return g2.create(m2.NUM);
- const d2 = f2.Div(h);
- return typeof d2 == "number" || DC(d2) ? y2.create(+d2) : j.create(d2);
- }
- };
- var i1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Exp();
- return u.isError() ? g2.create(m2.NUM) : typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var o1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g2.create(m2.NUM);
- const c = u.Ln();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var u1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e);
- if (r)
- return n;
- const [o] = s;
- let u = t != null ? t : y2.create(10);
- if (u.isArray()) {
- const b = u.getRowCount(), R = u.getColumnCount();
- if (b > 1 || R > 1)
- return g2.create(m2.VALUE);
- u = u.get(0, 0);
- }
- const { isError: c, errorObject: l2, variants: f2 } = I2(u);
- if (c)
- return l2;
- const [h] = f2, d2 = `${o.getValue()}`, _ = +h.getValue(), C = new fe2(d2);
- if (C.isError() || C.getRealNum() === 0 && C.getINum() === 0 || _ <= 0)
- return g2.create(m2.NUM);
- const E2 = C.Log(_);
- return C.isError() ? g2.create(m2.NUM) : typeof E2 == "number" || DC(E2) ? y2.create(+E2) : j.create(E2);
- }
- };
- var c1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g2.create(m2.NUM);
- const c = u.Log(2);
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var l1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g2.create(m2.NUM);
- const c = u.Log(10);
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var f1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g2.create(m2.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = `${o.getValue()}`, l2 = new fe2(c);
- if (l2.isError())
- return g2.create(m2.NUM);
- const f2 = +u.getValue();
- if (Number.isNaN(f2))
- return g2.create(m2.VALUE);
- const h = l2.Power(f2);
- return l2.isError() ? g2.create(m2.NUM) : typeof h == "number" || DC(h) ? y2.create(+h) : j.create(h);
- }
- };
- var h1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = "";
- for (let r = 0; r < e.length; r++) {
- if (t instanceof g2)
- return t;
- const n = e[r];
- if (n.isArray()) {
- let s = false, o;
- if (n.iterator((u) => {
- if (t = this._handleSingleObject(u, t), t instanceof g2)
- return s = true, o = t, false;
- }), s)
- return o;
- } else
- t = this._handleSingleObject(n, t);
- }
- return t instanceof g2 ? t : typeof t == "number" || DC(t) ? y2.create(+t) : j.create(t);
- }
- _handleSingleObject(e, t) {
- let r = t;
- if (e.isError())
- return e;
- if (e.isBoolean())
- return g2.create(m2.VALUE);
- const n = `${e.getValue()}`;
- if (typeof t != "number" && !t) {
- const s = new fe2(n);
- if (s.isError())
- return g2.create(m2.NUM);
- r = s.toString();
- } else {
- const s = new fe2(t), o = new fe2(n);
- if (s.isError() || o.isError())
- return g2.create(m2.NUM);
- if (s.isDifferentSuffixes(o))
- return g2.create(m2.VALUE);
- r = s.Product(o);
- }
- return r;
- }
- };
- var m1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.getRealNum();
- return y2.create(c);
- }
- };
- var g1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Sec();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var d1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Sech();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var C1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Sin();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var _1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Sinh();
- return u.isError() ? g2.create(m2.NUM) : typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var A1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- if (u.getRealNum() === 0 && u.getINum() === 0)
- return y2.create(0);
- const c = u.Sqrt();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var E1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g2.create(m2.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = `${o.getValue()}`, l2 = `${u.getValue()}`, f2 = new fe2(c), h = new fe2(l2);
- if (f2.isError() || h.isError() || f2.isDifferentSuffixes(h))
- return g2.create(m2.NUM);
- const d2 = f2.Sub(h);
- return typeof d2 == "number" || DC(d2) ? y2.create(+d2) : j.create(d2);
- }
- };
- var b1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = "";
- for (let r = 0; r < e.length; r++) {
- if (t instanceof g2)
- return t;
- const n = e[r];
- if (n.isArray()) {
- let s = false, o;
- if (n.iterator((u) => {
- if (t = this._handleSingleObject(u, t), t instanceof g2)
- return s = true, o = t, false;
- }), s)
- return o;
- } else
- t = this._handleSingleObject(n, t);
- }
- return t instanceof g2 ? t : typeof t == "number" || DC(t) ? y2.create(+t) : j.create(t);
- }
- _handleSingleObject(e, t) {
- let r = t;
- if (e.isError())
- return e;
- if (e.isBoolean())
- return g2.create(m2.VALUE);
- const n = `${e.getValue()}`;
- if (typeof t != "number" && !t) {
- const s = new fe2(n);
- if (s.isError())
- return g2.create(m2.NUM);
- r = s.toString();
- } else {
- const s = new fe2(t), o = new fe2(n);
- if (s.isError() || o.isError())
- return g2.create(m2.NUM);
- if (s.isDifferentSuffixes(o))
- return g2.create(m2.VALUE);
- r = s.Sum(o);
- }
- return r;
- }
- };
- var y1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Tan();
- return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var R1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
- if (u.isError())
- return g2.create(m2.NUM);
- const c = u.Tanh();
- return u.isError() ? g2.create(m2.NUM) : typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
- }
- };
- var p1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g2.create(m2.NA);
- let r = 0;
- if (t) {
- const { isError: d2, errorObject: _, variants: C } = H(t);
- if (d2)
- return _;
- const [E2] = C;
- if (r = Math.floor(+E2.getValue()), Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (r < 0 || r > 10)
- return g2.create(m2.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!pa(c))
- return g2.create(m2.NUM);
- const l2 = c.length === 10 && c.substring(0, 1) === "7", f2 = l2 ? Number.parseInt(c, 8) - 1073741824 : Number.parseInt(c, 8);
- if (f2 < -512 || f2 > 511)
- return g2.create(m2.NUM);
- let h;
- if (l2) {
- const d2 = (512 + f2).toString(2);
- h = `1${"0".repeat(9 - d2.length)}${d2}`;
- } else if (h = f2.toString(2), t) {
- if (r < h.length)
- return g2.create(m2.NUM);
- h = "0".repeat(r - h.length) + h;
- }
- return j.create(h);
- }
- };
- var V1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`;
- if (!pa(o))
- return g2.create(m2.NUM);
- let u = Number.parseInt(o, 8);
- return u >= 536870912 && (u -= 1073741824), y2.create(u);
- }
- };
- var N1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g2.create(m2.NA);
- let r = 0;
- if (t) {
- const { isError: h, errorObject: d2, variants: _ } = H(t);
- if (h)
- return d2;
- const [C] = _;
- if (r = Math.floor(+C.getValue()), Number.isNaN(r))
- return g2.create(m2.VALUE);
- if (r < 0 || r > 10)
- return g2.create(m2.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!pa(c))
- return g2.create(m2.NUM);
- const l2 = Number.parseInt(c, 8);
- let f2;
- if (l2 >= 536870912)
- f2 = `ff${(l2 + 3221225472).toString(16)}`;
- else if (f2 = l2.toString(16), t) {
- if (r < f2.length)
- return g2.create(m2.NUM);
- f2 = "0".repeat(r - f2.length) + f2;
- }
- return j.create(f2.toLocaleUpperCase());
- }
- };
- var O1 = [
- [pg, Z2.BESSELI],
- [Vg, Z2.BESSELJ],
- [Ng, Z2.BESSELK],
- [Og, Z2.BESSELY],
- [Mg, Z2.BIN2DEC],
- [wg, Z2.BIN2HEX],
- [Dg, Z2.BIN2OCT],
- [Sg, Z2.BITAND],
- [Pg, Z2.BITLSHIFT],
- [Lg, Z2.BITOR],
- [xg, Z2.BITRSHIFT],
- [jg, Z2.BITXOR],
- [Ug, Z2.COMPLEX],
- [vg, Z2.CONVERT],
- [Tg, Z2.DEC2BIN],
- [Bg, Z2.DEC2HEX],
- [Ig, Z2.DEC2OCT],
- [Fg, Z2.DELTA],
- [kg, Z2.ERF],
- [$g, Z2.ERF_PRECISE],
- [Yg, Z2.ERFC],
- [Hg, Z2.ERFC_PRECISE],
- [Gg, Z2.GESTEP],
- [Qg, Z2.HEX2BIN],
- [Wg, Z2.HEX2DEC],
- [qg, Z2.HEX2OCT],
- [Kg, Z2.IMABS],
- [Xg, Z2.IMAGINARY],
- [Zg, Z2.IMARGUMENT],
- [zg, Z2.IMCONJUGATE],
- [Jg, Z2.IMCOS],
- [e1, Z2.IMCOSH],
- [t1, Z2.IMCOT],
- [r1, Z2.IMCOTH],
- [n1, Z2.IMCSC],
- [s1, Z2.IMCSCH],
- [a1, Z2.IMDIV],
- [i1, Z2.IMEXP],
- [o1, Z2.IMLN],
- [u1, Z2.IMLOG],
- [l1, Z2.IMLOG10],
- [c1, Z2.IMLOG2],
- [f1, Z2.IMPOWER],
- [h1, Z2.IMPRODUCT],
- [m1, Z2.IMREAL],
- [g1, Z2.IMSEC],
- [d1, Z2.IMSECH],
- [C1, Z2.IMSIN],
- [_1, Z2.IMSINH],
- [A1, Z2.IMSQRT],
- [E1, Z2.IMSUB],
- [b1, Z2.IMSUM],
- [y1, Z2.IMTAN],
- [R1, Z2.IMTANH],
- [p1, Z2.OCT2BIN],
- [V1, Z2.OCT2DEC],
- [N1, Z2.OCT2HEX]
- ];
- var ee = ((i) => (i.ACCRINT = "ACCRINT", i.ACCRINTM = "ACCRINTM", i.AMORDEGRC = "AMORDEGRC", i.AMORLINC = "AMORLINC", i.COUPDAYBS = "COUPDAYBS", i.COUPDAYS = "COUPDAYS", i.COUPDAYSNC = "COUPDAYSNC", i.COUPNCD = "COUPNCD", i.COUPNUM = "COUPNUM", i.COUPPCD = "COUPPCD", i.CUMIPMT = "CUMIPMT", i.CUMPRINC = "CUMPRINC", i.DB = "DB", i.DDB = "DDB", i.DISC = "DISC", i.DOLLARDE = "DOLLARDE", i.DOLLARFR = "DOLLARFR", i.DURATION = "DURATION", i.EFFECT = "EFFECT", i.FV = "FV", i.FVSCHEDULE = "FVSCHEDULE", i.INTRATE = "INTRATE", i.IPMT = "IPMT", i.IRR = "IRR", i.ISPMT = "ISPMT", i.MDURATION = "MDURATION", i.MIRR = "MIRR", i.NOMINAL = "NOMINAL", i.NPER = "NPER", i.NPV = "NPV", i.ODDFPRICE = "ODDFPRICE", i.ODDFYIELD = "ODDFYIELD", i.ODDLPRICE = "ODDLPRICE", i.ODDLYIELD = "ODDLYIELD", i.PDURATION = "PDURATION", i.PMT = "PMT", i.PPMT = "PPMT", i.PRICE = "PRICE", i.PRICEDISC = "PRICEDISC", i.PRICEMAT = "PRICEMAT", i.PV = "PV", i.RATE = "RATE", i.RECEIVED = "RECEIVED", i.RRI = "RRI", i.SLN = "SLN", i.SYD = "SYD", i.TBILLEQ = "TBILLEQ", i.TBILLPRICE = "TBILLPRICE", i.TBILLYIELD = "TBILLYIELD", i.VDB = "VDB", i.XIRR = "XIRR", i.XNPV = "XNPV", i.YIELD = "YIELD", i.YIELDDISC = "YIELDDISC", i.YIELDMAT = "YIELDMAT", i))(ee || {});
- function es(i, a2, e, t) {
- const r = It(i, a2, e), { days: n } = _e2(r, i, t);
- return n;
- }
- function qe(i, a2, e, t) {
- let r;
- if (t === 1) {
- const n = It(i, a2, e);
- let s = re2(n);
- s = Er(s, 12 / e);
- const o = ye2(s);
- n < 0 && e === 1 ? r = 365 : r = o - n;
- } else
- t === 3 ? r = 365 / e : r = 360 / e;
- return r;
- }
- function Eu(i, a2, e) {
- const t = re2(i);
- let r = re2(a2);
- for (r.setUTCFullYear(t.getUTCFullYear()), r < t && r.setUTCFullYear(r.getUTCFullYear() + 1); r > t; )
- r = Er(r, -12 / e);
- return r = Er(r, 12 / e), ye2(r);
- }
- function nr(i, a2, e) {
- let t = 0;
- const r = re2(i);
- let n = re2(a2);
- for (; n > r; )
- n = Er(n, -12 / e), t++;
- return t;
- }
- function It(i, a2, e) {
- const t = re2(i);
- let r = re2(a2);
- for (r.setUTCFullYear(t.getUTCFullYear()), r < t && r.setUTCFullYear(r.getUTCFullYear() + 1); r > t; )
- r = Er(r, -12 / e);
- return ye2(r);
- }
- function bu(i, a2, e, t, r, n) {
- const s = es(i, a2, r, n), o = qe(i, a2, r, n), u = nr(i, a2, r), c = (o - s) / o - 1, l2 = t / r + 1, f2 = e * 100 / r;
- let h = 0, d2 = 0;
- for (let E2 = 1; E2 <= u; E2++) {
- const b = E2 + c, R = f2 / l2 ** b;
- h += b * R, d2 += R;
- }
- const _ = u + c, C = 100 / l2 ** _;
- return h += _ * C, d2 += C, h / d2 / r;
- }
- function Gr(i, a2, e, t, r) {
- let n;
- if (i === 0)
- n = (e + t) / a2;
- else {
- const s = (1 + i) ** a2;
- n = r === 1 ? (t * i / (s - 1) + e * i / (1 - 1 / s)) / (1 + i) : t * i / (s - 1) + e * i / (1 - 1 / s);
- }
- return -n;
- }
- function sr(i, a2, e, t, r) {
- let n;
- if (i === 0)
- n = t + e * a2;
- else {
- if (i === -1 && a2 === 0)
- return Number.NaN;
- const s = (1 + i) ** a2;
- n = r === 1 ? t * s + e * (1 + i) * (s - 1) / i : t * s + e * (s - 1) / i;
- }
- return -n;
- }
- function yu(i, a2, e, t, r, n) {
- const s = Gr(i, e, t, r, n);
- return (a2 === 1 ? n === 1 ? 0 : -t : n === 1 ? sr(i, a2 - 2, s, t, 1) - s : sr(i, a2 - 1, s, t, 0)) * i;
- }
- function Ru(i, a2) {
- let e = 0;
- for (let t = 1; t <= a2.length; t++)
- e += a2[t - 1] / (1 + i) ** t;
- return e;
- }
- function pu(i, a2, e, t, r, n, s, o, u) {
- const c = Kt(e, t, u), l2 = qe(i, t, o, u);
- return c < l2 ? M1(
- i,
- a2,
- e,
- t,
- r,
- n,
- s,
- o,
- u,
- c,
- l2
- ) : w1(
- i,
- a2,
- e,
- t,
- r,
- n,
- s,
- o,
- u,
- l2
- );
- }
- function M1(i, a2, e, t, r, n, s, o, u, c, l2) {
- let f2 = 0;
- const h = nr(i, a2, o), d2 = Kt(i, t, u);
- f2 += s / (1 + n / o) ** (h - 1 + d2 / l2), f2 += 100 * r / o * c / l2 / (1 + n / o) ** (d2 / l2);
- for (let C = 2; C <= h; C++)
- f2 += 100 * r / o / (1 + n / o) ** (C - 1 + d2 / l2);
- const _ = Kt(e, i, u);
- return f2 -= 100 * r / o * _ / l2, f2;
- }
- function w1(i, a2, e, t, r, n, s, o, u, c) {
- let l2 = 0;
- const f2 = nr(t, a2, o), h = D1(t, i, 12 / o);
- let d2;
- if (u === 2 || u === 3) {
- const R = Eu(i, t, o);
- d2 = Kt(i, R, u);
- } else {
- const R = It(i, t, o), { days: p2 } = _e2(R, i, u);
- d2 = c - p2;
- }
- l2 += s / (1 + n / o) ** (f2 + h + d2 / c);
- const _ = nr(e, t, o);
- let C = t, E2 = 0, b = 0;
- for (let R = _; R >= 1; R--) {
- const p2 = Jt(C, -12 / o, false), N2 = u === 1 ? Kt(p2, C, u) : c, M2 = R > 1 ? N2 : Kt(e, C, u);
- E2 += M2 / N2;
- const w = e > p2 ? e : p2, D2 = i < C ? i : C, S2 = Kt(w, D2, u);
- b += S2 / N2, C = p2;
- }
- l2 += 100 * r / o * E2 / (1 + n / o) ** (h + d2 / c);
- for (let R = 1; R <= f2; R++)
- l2 += 100 * r / o / (1 + n / o) ** (R + h + d2 / c);
- return l2 -= 100 * r / o * b, l2;
- }
- function Kt(i, a2, e) {
- const { days: t } = _e2(i, a2, e);
- return i < a2 ? t : 0;
- }
- function Vu(i, a2, e) {
- const t = re2(i), r = t.getUTCFullYear(), n = t.getUTCMonth(), s = t.getUTCDate(), o = Ar(r, n, s), u = re2(a2), c = u.getUTCFullYear(), l2 = u.getUTCMonth(), f2 = u.getUTCDate(), h = Ar(c, l2, f2);
- return !(s !== f2 && !(o && h) || Math.abs((c - r) * 12 + (l2 - n)) % (12 / e) !== 0);
- }
- function Or(i, a2, e) {
- return It(i, a2, e) >= 0;
- }
- function Jt(i, a2, e) {
- let t = re2(i);
- if (t = Er(t, a2), e) {
- const r = t.getUTCFullYear(), n = t.getUTCMonth(), s = Hr(r, n);
- t.setUTCDate(s);
- }
- return ye2(t);
- }
- function D1(i, a2, e, t) {
- const r = re2(i), n = re2(a2), s = r.getUTCFullYear(), o = r.getUTCMonth(), u = r.getUTCDate(), c = n.getUTCFullYear(), l2 = n.getUTCMonth(), f2 = n.getUTCDate(), h = Ar(s, o, u), d2 = !h && o !== 1 && u > 28 && u < Hr(s, o) ? Ar(c, l2, f2) : h, _ = Jt(a2, 0, d2);
- let C = 1 + +(a2 < _), E2 = Jt(_, e, d2);
- for (; !(e > 0 ? E2 >= a2 : E2 <= a2); )
- E2 = Jt(E2, e, d2), C++;
- return C;
- }
- function Ia(i, a2) {
- let n = 1, s = 0, o = i, u;
- for (; n > 1e-7 && s < 500; ) {
- const c = (a2(o + 1e-7) - a2(o - 1e-7)) / 2e-7;
- u = o - a2(o) / c, s++, n = Math.abs(u - o), o = u;
- }
- return Number.isNaN(o) || Math.abs(o) === 1 / 0 || s === 500 ? S1(i, a2) : o;
- }
- function S1(i, a2) {
- const r = Number.MAX_VALUE, n = -1, s = 1.6;
- let o = i - 0.01 <= n ? n + 1e-7 : i - 0.01, u = i + 0.01 >= r ? r - 1e-7 : i + 0.01, c, l2, f2 = 0;
- if (i <= n || i >= r)
- return g2.create(m2.NUM);
- for (let E2 = 0; E2 < 60; E2++) {
- c = o <= n ? n + 1e-7 : o, l2 = u >= r ? r - 1e-7 : u;
- const b = a2(c), R = a2(l2);
- if (b * R <= 0)
- break;
- if (b * R > 0)
- o = c + s * (c - l2), u = l2 + s * (l2 - c);
- else
- return g2.create(m2.NUM);
- if (E2 === 59)
- return g2.create(m2.NUM);
- }
- c = c, l2 = l2;
- let h = a2(c);
- const d2 = a2(l2);
- let _, C;
- if (Math.abs(h) < 1e-7 || Math.abs(d2) < 1e-7)
- return g2.create(m2.NUM);
- do
- C = c + (l2 - c) / 2, _ = a2(C), h * _ < 0 ? l2 = C : c = C, h = a2(c), f2++;
- while (Math.abs(_) > 1e-7 && f2 < 60);
- return C;
- }
- function un(i, a2, e, t, r, n, s) {
- const o = nr(i, a2, n), u = qe(i, a2, n, s), c = es(i, a2, n, s);
- if (o === 1) {
- const h = u - c, d2 = 100 * e / n + r, _ = t / n * h / u + 1, C = 100 * e / n * c / u;
- return d2 / _ - C;
- }
- const l2 = u - c;
- let f2 = r / (1 + t / n) ** (o - 1 + l2 / u);
- for (let h = 1; h <= o; h++)
- f2 += 100 * e / n / (1 + t / n) ** (h - 1 + l2 / u);
- return f2 -= 100 * e / n * c / u, f2;
- }
- function zs(i, a2, e, t, r) {
- let n = 0, s = r / e;
- s >= 1 ? (s = 1, n = t === 1 ? i : 0) : n = i * (1 - s) ** (t - 1);
- const o = i * (1 - s) ** t;
- let u = 0;
- return o < a2 ? u = n - a2 : u = n - o, u < 0 && (u = 0), u;
- }
- var P1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 8);
- }
- calculate(e, t, r, n, s, o, u, c) {
- const l2 = u != null ? u : y2.create(0), f2 = c != null ? c : T2.create(true), { isError: h, errorObject: d2, variants: _ } = H(e, t, r, n, s, o, l2);
- if (h)
- return d2;
- const [C, E2, b, R, p2, N2, M2] = _, w = k(C);
- if (typeof w != "number")
- return w;
- const D2 = k(E2);
- if (typeof D2 != "number")
- return D2;
- const S2 = k(b);
- if (typeof S2 != "number")
- return S2;
- const P = +R.getValue(), U2 = +p2.getValue(), x2 = Math.floor(+N2.getValue()), F = Math.floor(+M2.getValue()), W2 = +f2.getValue();
- return Number.isNaN(P) || Number.isNaN(U2) || Number.isNaN(x2) || Number.isNaN(F) || Number.isNaN(W2) ? g2.create(m2.VALUE) : P <= 0 || U2 <= 0 || ![1, 2, 4].includes(x2) || F < 0 || F > 4 || Math.floor(w) >= Math.floor(S2) ? g2.create(m2.NUM) : this._getResult(w, D2, S2, P, U2, x2, F, W2);
- }
- _getResult(e, t, r, n, s, o, u, c) {
- let l2 = It(e, t, o);
- if (l2 <= 0)
- return y2.create(0);
- l2 = It(r, t, o);
- const f2 = 12 / o, h = re2(t), d2 = h.getUTCFullYear(), _ = h.getUTCMonth(), C = h.getUTCDate(), E2 = Ar(d2, _, C);
- let b = Jt(t, -f2, E2);
- if (r > t && c)
- for (b = t; b < r; )
- b = Jt(b, f2, E2);
- let R = e > b ? e : b, { days: p2 } = _e2(R, r, u);
- if (l2 >= e) {
- const { days: P } = _e2(R, r, u ? 4 : 0);
- p2 = P;
- }
- r < R && (p2 = -p2);
- let N2 = qe(b, t, o, u), M2 = p2 / N2, w = b, D2 = e;
- for (; w > e; ) {
- D2 = w, w = Jt(w, -f2, E2), R = e > w ? e : w;
- const { days: P } = _e2(R, D2, u);
- if (u === 0)
- D2 >= R || e <= w ? p2 = P : p2 = -P, N2 = qe(w, D2, o, u);
- else if (p2 = D2 < R ? -P : P, u === 3)
- N2 = 365 / o;
- else {
- const { days: U2 } = _e2(w, D2, u);
- N2 = D2 < w ? -U2 : U2;
- }
- M2 += e <= w ? c ? 1 : 0 : p2 / N2;
- }
- const S2 = s * n / o * M2;
- return y2.create(S2);
- }
- };
- var L1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = s != null ? s : y2.create(0), { isError: u, errorObject: c, variants: l2 } = H(e, t, r, n, o);
- if (u)
- return c;
- const [f2, h, d2, _, C] = l2, E2 = k(f2);
- if (typeof E2 != "number")
- return E2;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
- return g2.create(m2.VALUE);
- if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || Math.floor(E2) > Math.floor(b))
- return g2.create(m2.NUM);
- if (Math.floor(E2) === Math.floor(b))
- return y2.create(0);
- const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = p2 * R * M2 / w;
- return y2.create(D2);
- }
- };
- var x1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 7);
- }
- calculate(e, t, r, n, s, o, u) {
- const c = u != null ? u : y2.create(0), { isError: l2, errorObject: f2, variants: h } = H(e, t, r, n, s, o, c);
- if (l2)
- return f2;
- const [d2, _, C, E2, b, R, p2] = h, N2 = k(_);
- if (typeof N2 != "number")
- return N2;
- const M2 = k(C);
- if (typeof M2 != "number")
- return M2;
- const w = +d2.getValue(), D2 = +E2.getValue();
- let S2 = +b.getValue();
- const P = +R.getValue(), U2 = Math.floor(+p2.getValue());
- return Number.isNaN(w) || Number.isNaN(D2) || Number.isNaN(S2) || Number.isNaN(P) || Number.isNaN(U2) ? g2.create(m2.VALUE) : w <= 0 || D2 < 0 || w < D2 || Math.floor(N2) > Math.floor(M2) || S2 < 0 || P <= 0 || ![0, 1, 3, 4].includes(U2) ? g2.create(m2.NUM) : (S2 > 1 ? S2 = Math.floor(S2) : S2 = Math.ceil(S2), this._getResult(w, N2, M2, D2, S2, P, U2));
- }
- _getResult(e, t, r, n, s, o, u) {
- const c = e - n, l2 = e * o, { days: f2, yearDays: h } = _e2(t, r, u), d2 = f2 / h, _ = Math.ceil(c / l2 - d2);
- if (_ < 0)
- return y2.create(0);
- let C = l2;
- return s === 0 ? C = l2 * d2 : s === _ ? C = c - l2 * (d2 + s - 1) : s > _ && (C = 0), y2.create(C);
- }
- };
- var j1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l2, f2, h, d2] = c, _ = k(l2);
- if (typeof _ != "number")
- return _;
- const C = k(f2);
- if (typeof C != "number")
- return C;
- const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
- if (Number.isNaN(E2) || Number.isNaN(b))
- return g2.create(m2.VALUE);
- if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
- return g2.create(m2.NUM);
- const R = es(_, C, E2, b);
- return y2.create(R);
- }
- };
- var U1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l2, f2, h, d2] = c, _ = k(l2);
- if (typeof _ != "number")
- return _;
- const C = k(f2);
- if (typeof C != "number")
- return C;
- const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
- if (Number.isNaN(E2) || Number.isNaN(b))
- return g2.create(m2.VALUE);
- if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
- return g2.create(m2.NUM);
- const R = qe(_, C, E2, b);
- return y2.create(R);
- }
- };
- var v1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l2, f2, h, d2] = c, _ = k(l2);
- if (typeof _ != "number")
- return _;
- const C = k(f2);
- if (typeof C != "number")
- return C;
- const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
- if (Number.isNaN(E2) || Number.isNaN(b))
- return g2.create(m2.VALUE);
- if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
- return g2.create(m2.NUM);
- const R = re2(_), p2 = re2(C);
- for (p2.setUTCFullYear(R.getUTCFullYear()), p2 < R && p2.setUTCFullYear(p2.getUTCFullYear() + 1); p2 > R; )
- p2.setUTCMonth(p2.getUTCMonth() - 12 / E2);
- p2.setUTCMonth(p2.getUTCMonth() + 12 / E2);
- const N2 = ye2(p2), { days: M2 } = _e2(_, N2, b);
- return y2.create(M2);
- }
- };
- var T1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l2, f2, h, d2] = c, _ = k(l2);
- if (typeof _ != "number")
- return _;
- const C = k(f2);
- if (typeof C != "number")
- return C;
- const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
- if (Number.isNaN(E2) || Number.isNaN(b))
- return g2.create(m2.VALUE);
- if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
- return g2.create(m2.NUM);
- const R = Eu(_, C, E2);
- return y2.create(R);
- }
- };
- var B1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l2, f2, h, d2] = c, _ = k(l2);
- if (typeof _ != "number")
- return _;
- const C = k(f2);
- if (typeof C != "number")
- return C;
- const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
- if (Number.isNaN(E2) || Number.isNaN(b))
- return g2.create(m2.VALUE);
- if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C) || It(_, C, E2) < 0)
- return g2.create(m2.NUM);
- const p2 = nr(_, C, E2);
- return y2.create(p2);
- }
- };
- var I1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l2, f2, h, d2] = c, _ = k(l2);
- if (typeof _ != "number")
- return _;
- const C = k(f2);
- if (typeof C != "number")
- return C;
- const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
- if (Number.isNaN(E2) || Number.isNaN(b))
- return g2.create(m2.VALUE);
- if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
- return g2.create(m2.NUM);
- let R = It(_, C, E2);
- return R < 0 && (R = 0), y2.create(R);
- }
- };
- var F1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- const { isError: u, errorObject: c, variants: l2 } = H(e, t, r, n, s, o);
- if (u)
- return c;
- const [f2, h, d2, _, C, E2] = l2, b = +f2.getValue(), R = +h.getValue(), p2 = +d2.getValue(), N2 = +_.getValue(), M2 = +C.getValue(), w = +E2.getValue();
- return Number.isNaN(b) || Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2) || Number.isNaN(M2) || Number.isNaN(w) ? g2.create(m2.VALUE) : b <= 0 || R <= 0 || p2 <= 0 || N2 < 1 || M2 < 1 || N2 > M2 || N2 > R || M2 > R || ![0, 1].includes(w) ? g2.create(m2.NUM) : Math.trunc(N2) !== N2 && Math.trunc(M2) !== M2 && Math.trunc(N2) === Math.trunc(M2) ? y2.create(0) : this._getResult(b, R, p2, N2, M2, w);
- }
- _getResult(e, t, r, n, s, o) {
- const u = Gr(e, t, r, 0, o);
- let c = 0, l2 = Math.ceil(n);
- l2 === 1 && (o === 0 && (c = -r), l2++);
- let f2 = false;
- for (let h = l2; h <= s; h++) {
- const d2 = o === 1 ? sr(e, h - 2, u, r, 1) : sr(e, h - 1, u, r, 0);
- if (d2 === 0) {
- f2 = true;
- break;
- }
- c += o === 1 ? d2 - u : d2;
- }
- return c *= e, (c < u * (s - n + 1) || f2) && (c = u * (s - n + 1)), y2.create(c);
- }
- };
- var k1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- const { isError: u, errorObject: c, variants: l2 } = H(e, t, r, n, s, o);
- if (u)
- return c;
- const [f2, h, d2, _, C, E2] = l2, b = +f2.getValue(), R = +h.getValue(), p2 = +d2.getValue(), N2 = +_.getValue(), M2 = +C.getValue(), w = +E2.getValue();
- return Number.isNaN(b) || Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2) || Number.isNaN(M2) || Number.isNaN(w) ? g2.create(m2.VALUE) : b <= 0 || R <= 0 || p2 <= 0 || N2 < 1 || M2 < 1 || N2 > M2 || ![0, 1].includes(w) ? g2.create(m2.NUM) : Math.trunc(N2) !== N2 && Math.trunc(M2) !== M2 && Math.trunc(N2) === Math.trunc(M2) ? y2.create(0) : this._getResult(b, R, p2, N2, M2, w);
- }
- _getResult(e, t, r, n, s, o) {
- const u = Gr(e, t, r, 0, o);
- let c = 0, l2 = Math.ceil(n);
- l2 === 1 && (c = o === 0 ? u + r * e : u, l2++);
- for (let f2 = l2; f2 <= s; f2++)
- c += o === 1 ? u - (sr(e, f2 - 2, u, r, 1) - u) * e : u - sr(e, f2 - 1, u, r, 0) * e;
- return y2.create(c);
- }
- };
- var $1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r, n, s) {
- let o = s != null ? s : y2.create(12);
- o.isNull() && (o = y2.create(12));
- const u = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1
- ), c = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1
- ), l2 = O(u, c, e, g2.create(m2.NA)), f2 = O(u, c, t, g2.create(m2.NA)), h = O(u, c, r, g2.create(m2.NA)), d2 = O(u, c, n, g2.create(m2.NA)), _ = O(u, c, o, g2.create(m2.NA)), C = l2.map((E2, b, R) => {
- const p2 = f2.get(b, R), N2 = h.get(b, R), M2 = d2.get(b, R), w = _.get(b, R), { isError: D2, errorObject: S2, variants: P } = I2(E2, p2, N2, M2, w);
- if (D2)
- return S2;
- const [U2, x2, F, W2, ne] = P, z = +U2.getValue(), G2 = +x2.getValue(), ge2 = +F.getValue();
- let de2 = +W2.getValue();
- const Ee = Math.floor(+ne.getValue());
- return z < 0 || G2 < 0 || ge2 <= 0 || de2 <= 0 || Math.floor(de2) > Math.floor(ge2) || Ee < 1 || Ee > 12 ? g2.create(m2.NUM) : (de2 < 1 && (de2 = 1), de2 = Math.floor(de2), this._getResult(z, G2, ge2, de2, Ee, b, R));
- });
- return u === 1 && c === 1 ? C.get(0, 0) : C;
- }
- _getResult(e, t, r, n, s, o, u) {
- const c = +(1 - (t / e) ** (1 / r)).toFixed(3), l2 = e * c * s / 12;
- let f2 = l2, h = 0;
- const d2 = n === r ? r - 1 : n;
- for (let C = 2; C <= d2; C++)
- h = (e - f2) * c, f2 += h;
- let _;
- return n === 1 ? _ = l2 : n === r ? _ = (e - f2) * c : _ = h, Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : o === 0 && u === 0 ? y2.create(_, Ke(this.getLocale())) : y2.create(_);
- }
- };
- var Y1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r, n, s) {
- let o = s != null ? s : y2.create(2);
- o.isNull() && (o = y2.create(2));
- const u = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1
- ), c = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1
- ), l2 = O(u, c, e, g2.create(m2.NA)), f2 = O(u, c, t, g2.create(m2.NA)), h = O(u, c, r, g2.create(m2.NA)), d2 = O(u, c, n, g2.create(m2.NA)), _ = O(u, c, o, g2.create(m2.NA)), C = l2.map((E2, b, R) => {
- const p2 = f2.get(b, R), N2 = h.get(b, R), M2 = d2.get(b, R), w = _.get(b, R), { isError: D2, errorObject: S2, variants: P } = I2(E2, p2, N2, M2, w);
- if (D2)
- return S2;
- const [U2, x2, F, W2, ne] = P, z = +U2.getValue(), G2 = +x2.getValue(), ge2 = +F.getValue(), de2 = +W2.getValue(), Ee = +ne.getValue();
- if (z < 0 || G2 < 0 || ge2 <= 0 || de2 <= 0 || de2 > ge2 || Ee <= 0)
- return g2.create(m2.NUM);
- const Re2 = zs(z, G2, ge2, de2, Ee);
- return Number.isNaN(Re2) || !Number.isFinite(Re2) ? g2.create(m2.NUM) : b === 0 && R === 0 ? y2.create(Re2, Ke(this.getLocale())) : y2.create(Re2);
- });
- return u === 1 && c === 1 ? C.get(0, 0) : C;
- }
- };
- var H1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = s != null ? s : y2.create(0), { isError: u, errorObject: c, variants: l2 } = H(e, t, r, n, o);
- if (u)
- return c;
- const [f2, h, d2, _, C] = l2, E2 = k(f2);
- if (typeof E2 != "number")
- return E2;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
- return g2.create(m2.VALUE);
- if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || Math.floor(E2) >= Math.floor(b))
- return g2.create(m2.NUM);
- const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = (p2 - R) / p2 * (w / M2);
- return y2.create(D2);
- }
- };
- var G1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue();
- let l2 = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l2))
- return g2.create(m2.VALUE);
- if (l2 < 0)
- return g2.create(m2.NUM);
- if (l2 >= 0 && l2 < 1)
- return g2.create(m2.DIV_BY_ZERO);
- l2 = Number.parseInt(`${l2}`, 10);
- let f2 = Number.parseInt(`${c}`, 10);
- f2 += c % 1 * 10 ** Math.ceil(Math.log(l2) / Math.LN10) / l2;
- const h = 10 ** (Math.ceil(Math.log(l2) / Math.LN2) + 1);
- return f2 = Math.round(f2 * h) / h, y2.create(f2);
- }
- };
- var Q1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue();
- let l2 = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l2))
- return g2.create(m2.VALUE);
- if (l2 < 0)
- return g2.create(m2.NUM);
- if (l2 >= 0 && l2 < 1)
- return g2.create(m2.DIV_BY_ZERO);
- l2 = Number.parseInt(`${l2}`, 10);
- let f2 = Number.parseInt(`${c}`, 10);
- return f2 += c % 1 * 10 ** -Math.ceil(Math.log(l2) / Math.LN10) * l2, y2.create(f2);
- }
- };
- var W1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = o != null ? o : y2.create(0);
- u.isNull() && (u = y2.create(0));
- const { isError: c, errorObject: l2, variants: f2 } = Fe2(e, t, r, n, s, u);
- if (c)
- return l2;
- const [h, d2, _, C, E2, b] = f2, R = k(h);
- if (typeof R != "number")
- return R;
- const p2 = k(d2);
- if (typeof p2 != "number")
- return p2;
- const N2 = +_.getValue(), M2 = +C.getValue(), w = Math.floor(+E2.getValue()), D2 = Math.floor(+b.getValue());
- if (Number.isNaN(N2) || Number.isNaN(M2) || Number.isNaN(w) || Number.isNaN(D2))
- return g2.create(m2.VALUE);
- if (N2 < 0 || M2 < 0 || ![1, 2, 4].includes(w) || D2 < 0 || D2 > 4 || Math.floor(R) >= Math.floor(p2) || R <= 0 || p2 <= 366)
- return g2.create(m2.NUM);
- const S2 = bu(R, p2, N2, M2, w, D2);
- return y2.create(S2);
- }
- };
- var q1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue();
- let l2 = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l2))
- return g2.create(m2.VALUE);
- if (c <= 0 || l2 < 1)
- return g2.create(m2.NUM);
- l2 = Number.parseInt(`${l2}`, 10);
- const f2 = (1 + c / l2) ** l2 - 1;
- return y2.create(f2);
- }
- };
- var K1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r, n, s) {
- const o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(0), c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l2 = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.map((b, R, p2) => {
- const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2), { isError: S2, errorObject: P, variants: U2 } = I2(b, N2, M2, w, D2);
- if (S2)
- return P;
- const [x2, F, W2, ne, z] = U2, G2 = +x2.getValue(), ge2 = +F.getValue(), de2 = +W2.getValue(), Ee = +ne.getValue(), Re2 = +z.getValue(), he2 = sr(G2, ge2, de2, Ee, Re2 ? 1 : 0);
- return Number.isNaN(he2) || !Number.isFinite(he2) ? g2.create(m2.NUM) : R === 0 && p2 === 0 ? y2.create(he2, Ke(this.getLocale())) : y2.create(he2);
- });
- return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
- }
- };
- var X1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e);
- if (r)
- return n;
- const [o] = s, u = +o.getValue();
- if (Number.isNaN(u))
- return g2.create(m2.VALUE);
- let c = u;
- if (t.isArray()) {
- const l2 = t.getArrayValue().flat();
- for (let f2 = 0; f2 < l2.length; f2++) {
- const h = l2[f2];
- if (h.isBoolean())
- return g2.create(m2.VALUE);
- const d2 = +h.getValue();
- if (Number.isNaN(d2))
- return g2.create(m2.VALUE);
- c *= 1 + d2;
- }
- } else {
- if (t.isBoolean())
- return g2.create(m2.VALUE);
- const l2 = +t.getValue();
- if (Number.isNaN(l2))
- return g2.create(m2.VALUE);
- c *= 1 + l2;
- }
- return y2.create(c);
- }
- };
- var Z1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = s != null ? s : y2.create(0), { isError: u, errorObject: c, variants: l2 } = H(e, t, r, n, o);
- if (u)
- return c;
- const [f2, h, d2, _, C] = l2, E2 = k(f2);
- if (typeof E2 != "number")
- return E2;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
- return g2.create(m2.VALUE);
- if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || Math.floor(E2) >= Math.floor(b))
- return g2.create(m2.NUM);
- const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = (p2 - R) / R * (w / M2);
- return y2.create(D2);
- }
- };
- var z1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 6);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r, n, s, o) {
- const u = s != null ? s : y2.create(0), c = o != null ? o : y2.create(0), l2 = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f2 = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l2, f2, e, g2.create(m2.NA)), d2 = O(l2, f2, t, g2.create(m2.NA)), _ = O(l2, f2, r, g2.create(m2.NA)), C = O(l2, f2, n, g2.create(m2.NA)), E2 = O(l2, f2, u, g2.create(m2.NA)), b = O(l2, f2, c, g2.create(m2.NA)), R = h.map((p2, N2, M2) => {
- const w = d2.get(N2, M2), D2 = _.get(N2, M2), S2 = C.get(N2, M2), P = E2.get(N2, M2), U2 = b.get(N2, M2), { isError: x2, errorObject: F, variants: W2 } = I2(p2, w, D2, S2, P, U2);
- if (x2)
- return F;
- const [ne, z, G2, ge2, de2, Ee] = W2, Re2 = +ne.getValue(), he2 = +z.getValue(), ke = +G2.getValue(), Ot2 = +ge2.getValue(), ar2 = +de2.getValue(), Mt2 = +Ee.getValue();
- if (he2 < 1 || Math.floor(he2) > Math.ceil(ke))
- return g2.create(m2.NUM);
- const st2 = yu(Re2, he2, ke, Ot2, ar2, Mt2 ? 1 : 0);
- return Number.isNaN(st2) || !Number.isFinite(st2) ? g2.create(m2.NUM) : N2 === 0 && M2 === 0 ? y2.create(st2, Ke(this.getLocale())) : y2.create(st2);
- });
- return l2 === 1 && f2 === 1 ? R.get(0, 0) : R;
- }
- };
- var J1 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = t != null ? t : y2.create(0.1);
- return r.isNull() && (r = y2.create(0.1)), r.isArray() ? r.map((n, s, o) => this._handleSingleObject(e, n, s, o)) : this._handleSingleObject(e, r);
- }
- _handleSingleObject(e, t, r = 0, n = 0) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (e.isNull())
- return g2.create(m2.VALUE);
- if (!e.isArray())
- return g2.create(m2.NUM);
- const { _values: s, valuesHasError: o } = this._getValues(e);
- if (o)
- return g2.create(m2.VALUE);
- let u = t;
- if (u.isString() && (u = u.convertToNumberObjectValue(), u.isError()))
- return u;
- const c = +u.getValue(), { positive: l2, negative: f2 } = this._checkValues(s);
- if (!l2 || !f2)
- return g2.create(m2.NUM);
- const h = Ia(c, (d2) => Ru(d2, s));
- return typeof h != "number" ? h : r === 0 && n === 0 ? y2.create(h, "0%") : y2.create(h);
- }
- _getValues(e) {
- const t = [];
- let r = false;
- return e.iterator((n) => {
- const s = n;
- if (s.isError())
- return r = true, false;
- if (s.isNull() || s.isBoolean())
- return true;
- const o = +s.getValue();
- if (Number.isNaN(o))
- return true;
- t.push(o);
- }), {
- _values: t,
- valuesHasError: r
- };
- }
- _checkValues(e) {
- let t = false, r = false;
- for (let n = 0; n < e.length; n++)
- e[n] > 0 && (t = true), e[n] < 0 && (r = true);
- return {
- positive: t,
- negative: r
- };
- }
- };
- var e0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.map((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C), { isError: p2, errorObject: N2, variants: M2 } = I2(d2, E2, b, R);
- if (p2)
- return N2;
- const [w, D2, S2, P] = M2, U2 = +w.getValue(), x2 = +D2.getValue(), F = +S2.getValue(), W2 = +P.getValue();
- if (F === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const ne = W2 * U2 * (x2 / F - 1);
- return y2.create(ne);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- };
- var t0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = o != null ? o : y2.create(0);
- u.isNull() && (u = y2.create(0));
- const { isError: c, errorObject: l2, variants: f2 } = Fe2(e, t, r, n, s, u);
- if (c)
- return l2;
- const [h, d2, _, C, E2, b] = f2, R = k(h);
- if (typeof R != "number")
- return R;
- const p2 = k(d2);
- if (typeof p2 != "number")
- return p2;
- const N2 = +_.getValue(), M2 = +C.getValue(), w = Math.floor(+E2.getValue()), D2 = Math.floor(+b.getValue());
- if (Number.isNaN(N2) || Number.isNaN(M2) || Number.isNaN(w) || Number.isNaN(D2))
- return g2.create(m2.VALUE);
- if (N2 < 0 || M2 < 0 || ![1, 2, 4].includes(w) || D2 < 0 || D2 > 4 || Math.floor(R) >= Math.floor(p2))
- return g2.create(m2.NUM);
- let S2 = bu(R, p2, N2, M2, w, D2);
- return S2 /= 1 + M2 / w, y2.create(S2);
- }
- };
- var r0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { _values: n, numberValues: s, positive: o, negative: u } = this._getValues(e), c = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), l2 = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), f2 = O(c, l2, t, g2.create(m2.NA)), h = O(c, l2, r, g2.create(m2.NA)), d2 = f2.map((_, C, E2) => {
- const b = h.get(C, E2);
- if (e.isError())
- return e;
- if (b.isError())
- return b;
- if (n.isError())
- return n;
- if (!o || !u)
- return g2.create(m2.DIV_BY_ZERO);
- const R = +_.getValue(), p2 = +b.getValue();
- if (Number.isNaN(R) || Number.isNaN(p2))
- return g2.create(m2.VALUE);
- if (p2 === -1)
- return g2.create(m2.DIV_BY_ZERO);
- const N2 = this._getResult(s, R, p2);
- return C === 0 && E2 === 0 ? y2.create(N2, "0%") : y2.create(N2);
- });
- return c === 1 && l2 === 1 ? d2.get(0, 0) : d2;
- }
- _getValues(e) {
- let t = e, r = [], n = false, s = false;
- if (!e.isError())
- if (e.isNull())
- t = g2.create(m2.VALUE);
- else if (!e.isArray())
- t = g2.create(m2.DIV_BY_ZERO);
- else {
- const { numberValues: o, valuesHasError: u, errorObject: c, positive: l2, negative: f2 } = this._checkValues(e);
- u && (t = c), r = o, n = l2, s = f2;
- }
- return {
- _values: t,
- numberValues: r,
- positive: n,
- negative: s
- };
- }
- _checkValues(e) {
- const t = [];
- let r = false, n = g2.create(m2.VALUE), s = false, o = false;
- return e.iterator((u) => {
- const c = u;
- if (c.isError())
- return r = true, n = c, false;
- if (c.isNull() || c.isBoolean())
- return true;
- const l2 = +c.getValue();
- if (Number.isNaN(l2))
- return true;
- l2 > 0 && (s = true), l2 < 0 && (o = true), t.push(l2);
- }), {
- numberValues: t,
- valuesHasError: r,
- errorObject: n,
- positive: s,
- negative: o
- };
- }
- _getResult(e, t, r) {
- const n = e.length, s = [], o = [];
- for (let d2 = 0; d2 < n; d2++)
- e[d2] > 0 ? o.push(e[d2]) : e[d2] < 0 && s.push(e[d2]);
- const u = this._npv(r, e, "positive"), c = this._npv(t, e, "negative"), l2 = -u * (1 + r) ** n, f2 = c * (1 + t);
- return (l2 / f2) ** (1 / (n - 1)) - 1;
- }
- _npv(e, t, r) {
- let n = 0;
- for (let s = 1; s <= t.length; s++) {
- const o = t[s - 1];
- (r === "positive" && o > 0 || r === "negative" && o < 0) && (n += o / (1 + e) ** s);
- }
- return n;
- }
- };
- var n0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue();
- let l2 = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l2))
- return g2.create(m2.VALUE);
- if (c <= 0 || l2 < 1)
- return g2.create(m2.NUM);
- l2 = Number.parseInt(`${l2}`, 10);
- const f2 = ((c + 1) ** (1 / l2) - 1) * l2;
- return y2.create(f2);
- }
- };
- var s0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(0), c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l2 = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.map((b, R, p2) => {
- const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2), { isError: S2, errorObject: P, variants: U2 } = I2(b, N2, M2, w, D2);
- if (S2)
- return P;
- const [x2, F, W2, ne, z] = U2, G2 = +x2.getValue(), ge2 = +F.getValue(), de2 = +W2.getValue(), Ee = +ne.getValue();
- let Re2 = +z.getValue();
- if (Re2 = Re2 ? 1 : 0, G2 === 0 && ge2 === 0)
- return g2.create(m2.DIV_BY_ZERO);
- let he2;
- if (G2 === 0)
- he2 = -(de2 + Ee) / ge2;
- else {
- const ke = ge2 * (1 + G2 * Re2) - Ee * G2, Ot2 = de2 * G2 + ge2 * (1 + G2 * Re2);
- he2 = Math.log(ke / Ot2) / Math.log(1 + G2);
- }
- return Number.isNaN(he2) || !Number.isFinite(he2) ? g2.create(m2.NUM) : y2.create(he2);
- });
- return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
- }
- };
- var a0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- A(this, "needsLocale", true);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- const { isError: r, errorObject: n, values: s } = this._getValues(t);
- return e.isArray() ? e.map((o, u, c) => this._handleSingleObject(o, r, n, s, u, c)) : this._handleSingleObject(e, r, n, s);
- }
- _handleSingleObject(e, t, r, n, s = 0, o = 0) {
- let u = e;
- if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
- return u;
- if (t)
- return r;
- const c = +e.getValue(), l2 = Ru(c, n);
- return Number.isNaN(l2) || Math.abs(l2) === 1 / 0 ? g2.create(m2.DIV_BY_ZERO) : s === 0 && o === 0 ? y2.create(l2, Ke(this.getLocale())) : y2.create(l2);
- }
- _getValues(e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- const n = e[r];
- if (n.isError())
- return {
- isError: true,
- errorObject: n
- };
- if (n.isArray()) {
- let s = false, o = g2.create(m2.VALUE);
- if (n.iterator((u) => {
- const c = u;
- if (c.isError())
- return s = true, o = c, false;
- if (c.isNull() || c.isBoolean())
- return true;
- const l2 = +c.getValue();
- if (Number.isNaN(l2))
- return true;
- t.push(l2);
- }), s)
- return {
- isError: s,
- errorObject: o
- };
- } else {
- const s = +n.getValue();
- if (Number.isNaN(s))
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE)
- };
- t.push(s);
- }
- }
- return {
- isError: false,
- values: t
- };
- }
- };
- var i0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 8);
- A(this, "maxParams", 9);
- }
- calculate(e, t, r, n, s, o, u, c, l2) {
- let f2 = l2 != null ? l2 : y2.create(0);
- f2.isNull() && (f2 = y2.create(0));
- const { isError: h, errorObject: d2, variants: _ } = Fe2(e, t, r, n, s, o, u, c, f2);
- if (h)
- return d2;
- const [C, E2, b, R, p2, N2, M2, w, D2] = _, S2 = k(C);
- if (typeof S2 != "number")
- return S2;
- const P = k(E2);
- if (typeof P != "number")
- return P;
- const U2 = k(b);
- if (typeof U2 != "number")
- return U2;
- const x2 = k(R);
- if (typeof x2 != "number")
- return x2;
- const F = +p2.getValue(), W2 = +N2.getValue(), ne = +M2.getValue(), z = Math.floor(+w.getValue()), G2 = Math.floor(+D2.getValue());
- if (Number.isNaN(F) || Number.isNaN(W2) || Number.isNaN(ne) || Number.isNaN(z) || Number.isNaN(G2))
- return g2.create(m2.VALUE);
- if (F < 0 || W2 < 0 || ne <= 0 || ![1, 2, 4].includes(z) || G2 < 0 || G2 > 4 || !this._validDate(P, x2, S2, U2, z))
- return g2.create(m2.NUM);
- const ge2 = pu(S2, P, U2, x2, F, W2, ne, z, G2);
- return y2.create(ge2);
- }
- _validDate(e, t, r, n, s) {
- return this._getDateCorrectOrder(e, t, r, n) && Vu(e, t, s) && Or(n, e, s);
- }
- _getDateCorrectOrder(e, t, r, n) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Math.floor(r) > Math.floor(n);
- }
- };
- var o0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 8);
- A(this, "maxParams", 9);
- }
- calculate(e, t, r, n, s, o, u, c, l2) {
- let f2 = l2 != null ? l2 : y2.create(0);
- f2.isNull() && (f2 = y2.create(0));
- const { isError: h, errorObject: d2, variants: _ } = Fe2(e, t, r, n, s, o, u, c, f2);
- if (h)
- return d2;
- const [C, E2, b, R, p2, N2, M2, w, D2] = _, S2 = k(C);
- if (typeof S2 != "number")
- return S2;
- const P = k(E2);
- if (typeof P != "number")
- return P;
- const U2 = k(b);
- if (typeof U2 != "number")
- return U2;
- const x2 = k(R);
- if (typeof x2 != "number")
- return x2;
- const F = +p2.getValue(), W2 = +N2.getValue(), ne = +M2.getValue(), z = Math.floor(+w.getValue()), G2 = Math.floor(+D2.getValue());
- return Number.isNaN(F) || Number.isNaN(W2) || Number.isNaN(ne) || Number.isNaN(z) || Number.isNaN(G2) ? g2.create(m2.VALUE) : F < 0 || W2 <= 0 || ne <= 0 || ![1, 2, 4].includes(z) || G2 < 0 || G2 > 4 || !this._validDate(P, x2, S2, U2, z) ? g2.create(m2.NUM) : this._getResult(S2, P, U2, x2, F, W2, ne, z, G2);
- }
- _validDate(e, t, r, n, s) {
- return this._getDateCorrectOrder(e, t, r, n) && Vu(e, t, s) && Or(n, e, s);
- }
- _getDateCorrectOrder(e, t, r, n) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Math.floor(r) > Math.floor(n);
- }
- _getResult(e, t, r, n, s, o, u, c, l2) {
- const { days: f2 } = _e2(e, t, l2), h = (s * f2 * 100 - (o - 100)) / ((o - 100) * 0.25 * (1 + 2 * f2) + f2 * 100);
- function d2(C) {
- return o - pu(e, t, r, n, s, C, u, c, l2);
- }
- const _ = Ia(h, (C) => d2(C));
- return typeof _ != "number" ? _ : y2.create(_);
- }
- };
- var u0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 7);
- A(this, "maxParams", 8);
- }
- calculate(e, t, r, n, s, o, u, c) {
- let l2 = c != null ? c : y2.create(0);
- l2.isNull() && (l2 = y2.create(0));
- const { isError: f2, errorObject: h, variants: d2 } = Fe2(e, t, r, n, s, o, u, l2);
- if (f2)
- return h;
- const [_, C, E2, b, R, p2, N2, M2] = d2, w = k(_);
- if (typeof w != "number")
- return w;
- const D2 = k(C);
- if (typeof D2 != "number")
- return D2;
- const S2 = k(E2);
- if (typeof S2 != "number")
- return S2;
- const P = +b.getValue(), U2 = +R.getValue(), x2 = +p2.getValue(), F = Math.floor(+N2.getValue()), W2 = Math.floor(+M2.getValue());
- if (Number.isNaN(P) || Number.isNaN(U2) || Number.isNaN(x2) || Number.isNaN(F) || Number.isNaN(W2))
- return g2.create(m2.VALUE);
- if (P < 0 || U2 < 0 || x2 <= 0 || ![1, 2, 4].includes(F) || W2 < 0 || W2 > 4 || !this._validDate(D2, w, S2, F))
- return g2.create(m2.NUM);
- const ne = this._getResult(w, D2, S2, P, U2, x2, F, W2);
- return y2.create(ne);
- }
- _validDate(e, t, r, n) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Or(r, e, n);
- }
- _getResult(e, t, r, n, s, o, u, c) {
- const l2 = this._getCoupDate(t, r, u), f2 = this._getFrac(r, e, l2, u, c), h = this._getFrac(r, t, l2, u, c), d2 = this._getFrac(e, t, l2, u, c);
- return (o * u + 100 * n * (h - f2 * (1 + s * d2 / u))) / (s * d2 + u);
- }
- _getCoupDate(e, t, r) {
- const n = re2(e), s = re2(t);
- for (s.setUTCFullYear(n.getUTCFullYear()), s > n && s.setUTCFullYear(s.getUTCFullYear() - 1); s < n; )
- s.setUTCMonth(s.getUTCMonth() + 12 / r);
- return ye2(s);
- }
- _getFrac(e, t, r, n, s) {
- const o = re2(e), u = re2(t), c = re2(r);
- for (c.setUTCFullYear(o.getUTCFullYear()), c < o && c.setUTCFullYear(c.getUTCFullYear() + 1); c > o; )
- c.setUTCMonth(c.getUTCMonth() - 12 / n);
- let l2 = ye2(c);
- c.setUTCMonth(c.getUTCMonth() + 12 / n);
- let f2 = ye2(c);
- if (f2 >= t) {
- const { days: p2 } = _e2(e, t, s), N2 = qe(l2, f2, n, s);
- return p2 / N2;
- }
- const { days: h } = _e2(e, f2, s), d2 = qe(l2, f2, n, s);
- let _ = h / d2;
- const C = re2(f2), E2 = re2(f2);
- for (E2.setUTCMonth(E2.getUTCMonth() + 12 / n); E2 < u; )
- C.setUTCMonth(C.getUTCMonth() + 12 / n), E2.setUTCMonth(E2.getUTCMonth() + 12 / n), _ += 1;
- l2 = ye2(C), f2 = ye2(E2);
- const { days: b } = _e2(l2, t, s), R = qe(l2, f2, n, s);
- return _ += b / R, _;
- }
- };
- var c0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 8);
- A(this, "maxParams", 9);
- }
- calculate(e, t, r, n, s, o, u, c) {
- let l2 = c != null ? c : y2.create(0);
- l2.isNull() && (l2 = y2.create(0));
- const { isError: f2, errorObject: h, variants: d2 } = Fe2(e, t, r, n, s, o, u, l2);
- if (f2)
- return h;
- const [_, C, E2, b, R, p2, N2, M2] = d2, w = k(_);
- if (typeof w != "number")
- return w;
- const D2 = k(C);
- if (typeof D2 != "number")
- return D2;
- const S2 = k(E2);
- if (typeof S2 != "number")
- return S2;
- const P = +b.getValue(), U2 = +R.getValue(), x2 = +p2.getValue(), F = Math.floor(+N2.getValue()), W2 = Math.floor(+M2.getValue());
- if (Number.isNaN(P) || Number.isNaN(U2) || Number.isNaN(x2) || Number.isNaN(F) || Number.isNaN(W2))
- return g2.create(m2.VALUE);
- if (P < 0 || U2 <= 0 || x2 <= 0 || ![1, 2, 4].includes(F) || W2 < 0 || W2 > 4 || !this._validDate(D2, w, S2, F))
- return g2.create(m2.NUM);
- const ne = this._getResult(w, D2, S2, P, U2, x2, F, W2);
- return y2.create(ne);
- }
- _validDate(e, t, r, n) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Or(r, e, n);
- }
- _getResult(e, t, r, n, s, o, u, c) {
- const l2 = this._getCoupDate(t, r, u), f2 = this._getFrac(r, e, l2, u, c), h = this._getFrac(r, t, l2, u, c), d2 = this._getFrac(e, t, l2, u, c);
- return (u * (o - s) + 100 * n * (h - f2)) / (d2 * s + 100 * n * f2 * d2 / u);
- }
- _getCoupDate(e, t, r) {
- const n = re2(e), s = re2(t);
- for (s.setUTCFullYear(n.getUTCFullYear()), s > n && s.setUTCFullYear(s.getUTCFullYear() - 1); s < n; )
- s.setUTCMonth(s.getUTCMonth() + 12 / r);
- return ye2(s);
- }
- _getFrac(e, t, r, n, s) {
- const o = re2(e), u = re2(t), c = re2(r);
- for (c.setUTCFullYear(o.getUTCFullYear()), c < o && c.setUTCFullYear(c.getUTCFullYear() + 1); c > o; )
- c.setUTCMonth(c.getUTCMonth() - 12 / n);
- let l2 = ye2(c);
- c.setUTCMonth(c.getUTCMonth() + 12 / n);
- let f2 = ye2(c);
- if (f2 >= t) {
- const { days: p2 } = _e2(e, t, s), N2 = qe(l2, f2, n, s);
- return p2 / N2;
- }
- const { days: h } = _e2(e, f2, s), d2 = qe(l2, f2, n, s);
- let _ = h / d2;
- const C = re2(f2), E2 = re2(f2);
- for (E2.setUTCMonth(E2.getUTCMonth() + 12 / n); E2 < u; )
- C.setUTCMonth(C.getUTCMonth() + 12 / n), E2.setUTCMonth(E2.getUTCMonth() + 12 / n), _ += 1;
- l2 = ye2(C), f2 = ye2(E2);
- const { days: b } = _e2(l2, t, s), R = qe(l2, f2, n, s);
- return _ += b / R, _;
- }
- };
- var l0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.map((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2), { isError: E2, errorObject: b, variants: R } = I2(f2, _, C);
- if (E2)
- return b;
- const [p2, N2, M2] = R, w = +p2.getValue(), D2 = +N2.getValue(), S2 = +M2.getValue();
- if (w <= -1)
- return g2.create(m2.NUM);
- const P = (Math.log(S2) - Math.log(D2)) / Math.log(1 + w);
- return Number.isNaN(P) || !Number.isFinite(P) ? g2.create(m2.NUM) : y2.create(P);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- };
- var f0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r, n, s) {
- const o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(0), c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l2 = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.map((b, R, p2) => {
- const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2), { isError: S2, errorObject: P, variants: U2 } = I2(b, N2, M2, w, D2);
- if (S2)
- return P;
- const [x2, F, W2, ne, z] = U2, G2 = +x2.getValue(), ge2 = +F.getValue(), de2 = +W2.getValue(), Ee = +ne.getValue(), Re2 = +z.getValue();
- if (G2 <= -1)
- return g2.create(m2.NUM);
- const he2 = Gr(G2, ge2, de2, Ee, Re2 ? 1 : 0);
- return Number.isNaN(he2) || !Number.isFinite(he2) ? g2.create(m2.NUM) : R === 0 && p2 === 0 ? y2.create(he2, Ke(this.getLocale())) : y2.create(he2);
- });
- return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
- }
- };
- var h0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 6);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r, n, s, o) {
- const u = s != null ? s : y2.create(0), c = o != null ? o : y2.create(0), l2 = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f2 = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l2, f2, e, g2.create(m2.NA)), d2 = O(l2, f2, t, g2.create(m2.NA)), _ = O(l2, f2, r, g2.create(m2.NA)), C = O(l2, f2, n, g2.create(m2.NA)), E2 = O(l2, f2, u, g2.create(m2.NA)), b = O(l2, f2, c, g2.create(m2.NA)), R = h.map((p2, N2, M2) => {
- const w = d2.get(N2, M2), D2 = _.get(N2, M2), S2 = C.get(N2, M2), P = E2.get(N2, M2), U2 = b.get(N2, M2), { isError: x2, errorObject: F, variants: W2 } = I2(p2, w, D2, S2, P, U2);
- if (x2)
- return F;
- const [ne, z, G2, ge2, de2, Ee] = W2, Re2 = +ne.getValue(), he2 = +z.getValue(), ke = +G2.getValue(), Ot2 = +ge2.getValue(), ar2 = +de2.getValue(), Mt2 = +Ee.getValue();
- if (he2 < 1 || Math.floor(he2) > Math.ceil(ke) || he2 - ke >= 1)
- return g2.create(m2.NUM);
- const st2 = Gr(Re2, ke, Ot2, ar2, Mt2 ? 1 : 0) - yu(Re2, he2, ke, Ot2, ar2, Mt2 ? 1 : 0);
- return Number.isNaN(st2) || !Number.isFinite(st2) ? g2.create(m2.NUM) : N2 === 0 && M2 === 0 ? y2.create(st2, Ke(this.getLocale())) : y2.create(st2);
- });
- return l2 === 1 && f2 === 1 ? R.get(0, 0) : R;
- }
- };
- var m0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 7);
- }
- calculate(e, t, r, n, s, o, u) {
- let c = u != null ? u : y2.create(0);
- c.isNull() && (c = y2.create(0));
- const { isError: l2, errorObject: f2, variants: h } = Fe2(e, t, r, n, s, o, c);
- if (l2)
- return f2;
- const [d2, _, C, E2, b, R, p2] = h, N2 = k(d2);
- if (typeof N2 != "number")
- return N2;
- const M2 = k(_);
- if (typeof M2 != "number")
- return M2;
- const w = +C.getValue(), D2 = +E2.getValue(), S2 = +b.getValue(), P = Math.floor(+R.getValue()), U2 = Math.floor(+p2.getValue());
- if (Number.isNaN(w) || Number.isNaN(D2) || Number.isNaN(S2) || Number.isNaN(P) || Number.isNaN(U2))
- return g2.create(m2.VALUE);
- if (w < 0 || D2 < 0 || S2 <= 0 || ![1, 2, 4].includes(P) || U2 < 0 || U2 > 4 || N2 >= M2 || !Or(N2, M2, P))
- return g2.create(m2.NUM);
- const x2 = un(N2, M2, w, D2, S2, P, U2);
- return y2.create(x2);
- }
- };
- var g0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- let o = s != null ? s : y2.create(0);
- o.isNull() && (o = y2.create(0));
- const { isError: u, errorObject: c, variants: l2 } = Fe2(e, t, r, n, o);
- if (u)
- return c;
- const [f2, h, d2, _, C] = l2, E2 = k(f2);
- if (typeof E2 != "number")
- return E2;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
- return g2.create(m2.VALUE);
- if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || E2 >= b)
- return g2.create(m2.NUM);
- const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = p2 - R * p2 * M2 / w;
- return y2.create(D2);
- }
- };
- var d0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = o != null ? o : y2.create(0);
- u.isNull() && (u = y2.create(0));
- const { isError: c, errorObject: l2, variants: f2 } = Fe2(e, t, r, n, s, u);
- if (c)
- return l2;
- const [h, d2, _, C, E2, b] = f2, R = k(h);
- if (typeof R != "number")
- return R;
- const p2 = k(d2);
- if (typeof p2 != "number")
- return p2;
- const N2 = k(_);
- if (typeof N2 != "number")
- return N2;
- const M2 = +C.getValue(), w = +E2.getValue(), D2 = Math.floor(+b.getValue());
- if (Number.isNaN(M2) || Number.isNaN(w) || Number.isNaN(D2))
- return g2.create(m2.VALUE);
- const S2 = this._getDateCorrectOrder(p2, R, N2);
- if (M2 < 0 || w < 0 || D2 < 0 || D2 > 4 || !S2)
- return g2.create(m2.NUM);
- const P = Au(R, D2), { days: U2 } = _e2(R, p2, D2), { days: x2 } = _e2(N2, p2, D2), { days: F } = _e2(N2, R, D2), W2 = (100 + x2 / P * M2 * 100) / (1 + U2 / P * w) - F / P * M2 * 100;
- return y2.create(W2);
- }
- _getDateCorrectOrder(e, t, r) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r);
- }
- };
- var C0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r, n, s) {
- const o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(0), c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l2 = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.map((b, R, p2) => {
- const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2), { isError: S2, errorObject: P, variants: U2 } = I2(b, N2, M2, w, D2);
- if (S2)
- return P;
- const [x2, F, W2, ne, z] = U2, G2 = +x2.getValue(), ge2 = +F.getValue(), de2 = +W2.getValue(), Ee = +ne.getValue();
- let Re2 = +z.getValue();
- Re2 = Re2 ? 1 : 0;
- const he2 = G2 === 0 ? -de2 * ge2 - Ee : ((1 - (1 + G2) ** ge2) / G2 * de2 * (1 + G2 * Re2) - Ee) / (1 + G2) ** ge2;
- return Number.isNaN(he2) || !Number.isFinite(he2) ? g2.create(m2.NUM) : R === 0 && p2 === 0 ? y2.create(he2, Ke(this.getLocale())) : y2.create(he2);
- });
- return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
- }
- };
- var _0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- const u = n != null ? n : y2.create(0), c = s != null ? s : y2.create(0), l2 = o != null ? o : y2.create(0.1), f2 = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- l2.isArray() ? l2.getRowCount() : 1
- ), h = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- l2.isArray() ? l2.getColumnCount() : 1
- ), d2 = O(f2, h, e, g2.create(m2.NA)), _ = O(f2, h, t, g2.create(m2.NA)), C = O(f2, h, r, g2.create(m2.NA)), E2 = O(f2, h, u, g2.create(m2.NA)), b = O(f2, h, c, g2.create(m2.NA)), R = O(f2, h, l2, g2.create(m2.NA)), p2 = d2.map((N2, M2, w) => {
- const D2 = _.get(M2, w), S2 = C.get(M2, w), P = E2.get(M2, w), U2 = b.get(M2, w), x2 = R.get(M2, w), { isError: F, errorObject: W2, variants: ne } = I2(N2, D2, S2, P, U2, x2);
- if (F)
- return W2;
- const [z, G2, ge2, de2, Ee, Re2] = ne, he2 = +z.getValue(), ke = +G2.getValue(), Ot2 = +ge2.getValue(), ar2 = +de2.getValue();
- let Mt2 = +Ee.getValue();
- const st2 = +Re2.getValue();
- return Mt2 = Mt2 ? 1 : 0, he2 <= 0 || ke >= 0 ? g2.create(m2.NUM) : this._getResult(he2, ke, Ot2, ar2, Mt2, st2, M2, w);
- });
- return f2 === 1 && h === 1 ? p2.get(0, 0) : p2;
- }
- _getResult(e, t, r, n, s, o, u, c) {
- let h = o;
- for (let d2 = 0; d2 < 20; d2++) {
- if (h <= -1)
- return g2.create(m2.NUM);
- let _, C;
- if (Math.abs(h) < 1e-10 ? _ = r * (1 + e * h) + t * (1 + h * s) * e + n : (C = (1 + h) ** e, _ = r * C + t * (1 / h + s) * (C - 1) + n), Math.abs(_) < 1e-10)
- break;
- let E2;
- if (Math.abs(h) < 1e-10)
- E2 = r * e + t * s * e;
- else {
- C = (1 + h) ** e;
- const b = e * (1 + h) ** (e - 1);
- E2 = r * b + t * (1 / h + s) * b + t * (-1 / (h * h)) * (C - 1);
- }
- h -= _ / E2;
- }
- return u === 0 && c === 0 ? y2.create(h, "0%") : y2.create(h);
- }
- };
- var A0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- let o = s != null ? s : y2.create(0);
- o.isNull() && (o = y2.create(0));
- const { isError: u, errorObject: c, variants: l2 } = Fe2(e, t, r, n, o);
- if (u)
- return c;
- const [f2, h, d2, _, C] = l2, E2 = k(f2);
- if (typeof E2 != "number")
- return E2;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
- return g2.create(m2.VALUE);
- if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || E2 >= b)
- return g2.create(m2.NUM);
- const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = R / (1 - p2 * M2 / w);
- return D2 < 0 ? g2.create(m2.NUM) : y2.create(D2);
- }
- };
- var E0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.map((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2), { isError: E2, errorObject: b, variants: R } = I2(f2, _, C);
- if (E2)
- return b;
- const [p2, N2, M2] = R, w = +p2.getValue(), D2 = +N2.getValue(), S2 = +M2.getValue();
- if (w <= 0)
- return g2.create(m2.NUM);
- if (D2 === 0 && S2 === 0)
- return y2.create(0);
- const P = (S2 / D2) ** (1 / w) - 1;
- return Number.isNaN(P) || !Number.isFinite(P) || S2 / D2 < 0 ? g2.create(m2.NUM) : y2.create(P);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- };
- var b0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.map((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- if (_.isError())
- return _;
- if (C.isError())
- return C;
- const E2 = +f2.getValue(), b = +_.getValue(), R = +C.getValue();
- if (Number.isNaN(E2) || Number.isNaN(b) || Number.isNaN(R))
- return g2.create(m2.VALUE);
- if (R === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const p2 = (E2 - b) / R;
- return h === 0 && d2 === 0 ? y2.create(p2, Ke(this.getLocale())) : y2.create(p2);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- };
- var y0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.map((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- if (E2.isError())
- return E2;
- if (b.isError())
- return b;
- if (R.isError())
- return R;
- const p2 = +d2.getValue(), N2 = +E2.getValue(), M2 = +b.getValue(), w = +R.getValue();
- if (Number.isNaN(p2) || Number.isNaN(N2) || Number.isNaN(M2) || Number.isNaN(w))
- return g2.create(m2.VALUE);
- if (N2 < 0 || M2 <= 0 || w > M2)
- return g2.create(m2.NUM);
- const D2 = (p2 - N2) * (M2 - w + 1) * 2 / (M2 * (M2 + 1));
- return _ === 0 && C === 0 ? y2.create(D2, Ke(this.getLocale())) : y2.create(D2);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- };
- var R0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = Fe2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = k(u);
- if (typeof f2 != "number")
- return f2;
- const h = k(c);
- if (typeof h != "number")
- return h;
- const d2 = +l2.getValue();
- if (Number.isNaN(d2))
- return g2.create(m2.VALUE);
- if (d2 <= 0 || f2 >= h)
- return g2.create(m2.NUM);
- const _ = Math.floor(h) - Math.floor(f2), E2 = re2(f2).getUTCFullYear(), b = Jn(E2);
- if (_ > b)
- return g2.create(m2.NUM);
- let R = 365 * d2 / (360 - d2 * _);
- if (_ > 182) {
- const p2 = 100 * (1 - d2 * _ / 360), N2 = _ / 365;
- if (R = (-N2 + Math.sqrt(N2 * N2 - (N2 * 2 - 1) * (1 - 100 / p2))) / (N2 - 0.5), Number.isNaN(R))
- return g2.create(m2.NUM);
- }
- return R < 0 ? g2.create(m2.NUM) : y2.create(R);
- }
- };
- var p0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = Fe2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = k(u);
- if (typeof f2 != "number")
- return f2;
- const h = k(c);
- if (typeof h != "number")
- return h;
- const d2 = +l2.getValue();
- if (Number.isNaN(d2))
- return g2.create(m2.VALUE);
- if (d2 <= 0 || f2 >= h)
- return g2.create(m2.NUM);
- const _ = Math.floor(h) - Math.floor(f2), E2 = re2(f2).getUTCFullYear(), b = Jn(E2);
- if (_ > b)
- return g2.create(m2.NUM);
- const R = 100 * (1 - d2 * _ / 360);
- return R < 0 ? g2.create(m2.NUM) : y2.create(R, Ke(this.getLocale()));
- }
- };
- var V0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = Fe2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = k(u);
- if (typeof f2 != "number")
- return f2;
- const h = k(c);
- if (typeof h != "number")
- return h;
- const d2 = +l2.getValue();
- if (Number.isNaN(d2))
- return g2.create(m2.VALUE);
- if (d2 <= 0 || f2 >= h)
- return g2.create(m2.NUM);
- const _ = Math.floor(h) - Math.floor(f2), E2 = re2(f2).getUTCFullYear(), b = Jn(E2);
- if (_ > b)
- return g2.create(m2.NUM);
- const R = (100 - d2) / d2 * 360 / _;
- return y2.create(R);
- }
- };
- var N0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 7);
- A(this, "needsLocale", true);
- }
- calculate(e, t, r, n, s, o, u) {
- let c = o != null ? o : y2.create(2);
- c.isNull() && (c = y2.create(2));
- let l2 = u != null ? u : T2.create(false);
- l2.isNull() && (l2 = T2.create(false));
- const f2 = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- l2.isArray() ? l2.getRowCount() : 1
- ), h = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- l2.isArray() ? l2.getColumnCount() : 1
- ), d2 = O(f2, h, e, g2.create(m2.NA)), _ = O(f2, h, t, g2.create(m2.NA)), C = O(f2, h, r, g2.create(m2.NA)), E2 = O(f2, h, n, g2.create(m2.NA)), b = O(f2, h, s, g2.create(m2.NA)), R = O(f2, h, c, g2.create(m2.NA)), p2 = O(f2, h, l2, g2.create(m2.NA));
- return this._getResultArray(
- d2,
- _,
- C,
- E2,
- b,
- R,
- p2,
- f2,
- h
- );
- }
- _getResultArray(e, t, r, n, s, o, u, c, l2) {
- const f2 = e.map((h, d2, _) => {
- const C = t.get(d2, _), E2 = r.get(d2, _), b = n.get(d2, _), R = s.get(d2, _), p2 = o.get(d2, _), N2 = u.get(d2, _), { isError: M2, errorObject: w, variants: D2 } = I2(h, C, E2, b, R, p2, N2);
- if (M2)
- return w;
- const [S2, P, U2, x2, F, W2, ne] = D2, z = +S2.getValue(), G2 = +P.getValue(), ge2 = +U2.getValue(), de2 = +x2.getValue(), Ee = +F.getValue(), Re2 = +W2.getValue(), he2 = +ne.getValue();
- if (z < 0 || G2 < 0 || ge2 < 0 || de2 < 0 || Ee < 0 || Ee > ge2 || de2 > Ee || Re2 < 0)
- return g2.create(m2.NUM);
- if (ge2 === 0 && de2 === 0 && Ee === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const ke = this._getResult(z, G2, ge2, de2, Ee, Re2, he2);
- return d2 === 0 && _ === 0 ? y2.create(ke, Ke(this.getLocale())) : y2.create(ke);
- });
- return c === 1 && l2 === 1 ? f2.get(0, 0) : f2;
- }
- _getResult(e, t, r, n, s, o, u) {
- const c = Math.floor(n), l2 = Math.ceil(s);
- let f2 = 0;
- if (e < t) {
- if (n >= 1 || u)
- return f2;
- const h = Math.abs(e - t);
- return f2 = h * (s - n) > h ? h : h * (s - n), -f2;
- }
- if (u)
- for (let h = c + 1; h <= l2; h++) {
- let d2 = zs(e, t, r, h, o);
- h === c + 1 ? d2 *= Math.min(s, c + 1) - n : h === l2 && (d2 *= s + 1 - l2), f2 += d2;
- }
- else {
- const h = e - this._getVdb(e, t, r, r, n, o);
- f2 = this._getVdb(h, t, r, r - n, s - n, o);
- }
- return f2;
- }
- _getVdb(e, t, r, n, s, o) {
- const u = Math.ceil(s);
- let c = 0, l2 = e - t, f2 = 0, h = 0, d2 = false;
- for (let _ = 1; _ <= u; _++) {
- if (d2)
- h = f2;
- else {
- const C = zs(e, t, r, _, o);
- f2 = l2 / (n - (_ - 1)), f2 > C ? (h = f2, d2 = true) : (h = C, l2 -= C);
- }
- _ === u && (h *= s + 1 - u), c += h;
- }
- return c;
- }
- };
- var O0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isNull() || t.isNull())
- return g2.create(m2.NA);
- const { isError: n, errorObejct: s, _values: o, _dates: u } = this._checkErrors(e, t);
- if (n)
- return s;
- let c = r != null ? r : y2.create(0.1);
- c.isNull() && (c = y2.create(0.1));
- const { isError: l2, errorObject: f2, variants: h } = H(c);
- if (l2)
- return f2;
- const [d2] = h, _ = +d2.getValue();
- if (Number.isNaN(_))
- return g2.create(m2.VALUE);
- const { positive: C, negative: E2 } = this._checkValues(o);
- if (!C || !E2 || (o == null ? void 0 : o.length) !== (u == null ? void 0 : u.length) || _ < 0)
- return g2.create(m2.NUM);
- const b = Ia(_, (R) => this._iterF(o, u, R));
- return typeof b != "number" ? b : y2.create(b);
- }
- _checkErrors(e, t) {
- if (e.isError())
- return {
- isError: true,
- errorObejct: e
- };
- if (t.isError())
- return {
- isError: true,
- errorObejct: t
- };
- const { isError: r, errorObejct: n, _values: s } = this._checkErrorValues(e);
- if (r)
- return {
- isError: r,
- errorObejct: n
- };
- const { isError: o, errorObejct: u, _dates: c } = this._checkErrorDates(t);
- return o ? {
- isError: o,
- errorObejct: u
- } : {
- isError: false,
- _values: s,
- _dates: c
- };
- }
- _checkErrorValues(e) {
- const t = [];
- if (e.isArray()) {
- let r = false, n = g2.create(m2.VALUE);
- return e.iterator((s) => {
- const o = s;
- if (o.isError())
- return r = true, n = o, false;
- if (o.isBoolean())
- return r = true, n = g2.create(m2.VALUE), false;
- const u = +o.getValue();
- if (Number.isNaN(u))
- return r = true, n = g2.create(m2.VALUE), false;
- t.push(u);
- }), r ? {
- isError: r,
- errorObejct: n
- } : t.length <= 1 ? {
- isError: true,
- errorObejct: g2.create(m2.NA)
- } : {
- isError: r,
- _values: t
- };
- } else {
- const r = e.getValue();
- return e.isBoolean() || e.isString() && !DC(r) ? {
- isError: true,
- errorObejct: g2.create(m2.VALUE)
- } : {
- isError: true,
- errorObejct: g2.create(m2.NA)
- };
- }
- }
- _checkErrorDates(e) {
- const t = [];
- if (e.isArray()) {
- let r = false, n = g2.create(m2.VALUE);
- return e.iterator((s) => {
- if (s != null && s.isError())
- return r = true, n = s, false;
- if (s != null && s.isBoolean())
- return r = true, n = g2.create(m2.VALUE), false;
- const o = +s.getValue();
- if (Number.isNaN(o))
- return r = true, n = g2.create(m2.VALUE), false;
- if (o < 0)
- return r = true, n = g2.create(m2.NUM), false;
- t.push(Math.floor(o));
- }), r ? {
- isError: r,
- errorObejct: n
- } : t.length <= 1 ? {
- isError: true,
- errorObejct: g2.create(m2.NA)
- } : {
- isError: r,
- _dates: t
- };
- } else {
- const r = e.getValue();
- return e.isBoolean() || e.isString() && !DC(r) ? {
- isError: true,
- errorObejct: g2.create(m2.VALUE)
- } : +r < 0 ? {
- isError: true,
- errorObejct: g2.create(m2.NUM)
- } : {
- isError: true,
- errorObejct: g2.create(m2.NA)
- };
- }
- }
- _checkValues(e) {
- let t = false, r = false;
- for (let n = 0; n < e.length; n++)
- e[n] > 0 && (t = true), e[n] < 0 && (r = true);
- return {
- positive: t,
- negative: r
- };
- }
- _iterF(e, t, r) {
- return e.reduce((n, s, o) => n + s / (1 + r) ** ((t[o] - t[0]) / 365), 0);
- }
- };
- var M0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isNull() || t.isNull() || r.isNull())
- return g2.create(m2.NA);
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = +u.getValue();
- if (Number.isNaN(c))
- return g2.create(m2.VALUE);
- let { isError: l2, errorObejct: f2, _values: h, _dates: d2 } = this._checkErrors(t, r);
- if (l2)
- return f2;
- if (h = h, d2 = d2, c < 0 || h.length !== d2.length)
- return g2.create(m2.NUM);
- let _ = 0;
- const C = d2[0];
- for (let E2 = 0; E2 < d2.length; E2++) {
- const b = d2[E2], R = h[E2];
- _ += R / (1 + c) ** ((b - C) / 365);
- }
- return y2.create(_);
- }
- _checkErrors(e, t) {
- if (e.isError())
- return {
- isError: true,
- errorObejct: e
- };
- if (t.isError())
- return {
- isError: true,
- errorObejct: t
- };
- const { isError: r, errorObejct: n, _values: s } = this._checkErrorValues(e);
- if (r)
- return {
- isError: r,
- errorObejct: n
- };
- const { isError: o, errorObejct: u, _dates: c } = this._checkErrorDates(t);
- return o ? {
- isError: o,
- errorObejct: u
- } : {
- isError: false,
- _values: s,
- _dates: c
- };
- }
- _checkErrorValues(e) {
- const t = [];
- if (e.isArray()) {
- let r = false, n = g2.create(m2.VALUE);
- return e.iterator((s) => {
- const o = s;
- if (o.isError())
- return r = true, n = o, false;
- if (o.isNull() || o.isBoolean())
- return r = true, n = g2.create(m2.VALUE), false;
- const u = +o.getValue();
- if (Number.isNaN(u))
- return r = true, n = g2.create(m2.VALUE), false;
- t.push(u);
- }), r ? {
- isError: r,
- errorObejct: n
- } : t.length <= 1 ? {
- isError: true,
- errorObejct: g2.create(m2.NA)
- } : {
- isError: r,
- _values: t
- };
- } else {
- const r = e.getValue();
- return e.isNull() || e.isBoolean() || e.isString() && !DC(r) ? {
- isError: true,
- errorObejct: g2.create(m2.VALUE)
- } : {
- isError: true,
- errorObejct: g2.create(m2.NA)
- };
- }
- }
- _checkErrorDates(e) {
- const t = [];
- if (e.isArray()) {
- let r = false, n = g2.create(m2.VALUE);
- return e.iterator((s) => {
- const o = s;
- if (o.isError())
- return r = true, n = o, false;
- if (o.isNull() || o.isBoolean())
- return r = true, n = g2.create(m2.VALUE), false;
- const u = +o.getValue();
- if (Number.isNaN(u))
- return r = true, n = g2.create(m2.VALUE), false;
- if (u < 0)
- return r = true, n = g2.create(m2.NUM), false;
- t.push(Math.floor(u));
- }), r ? {
- isError: r,
- errorObejct: n
- } : t.length <= 1 ? {
- isError: true,
- errorObejct: g2.create(m2.NA)
- } : {
- isError: r,
- _dates: t
- };
- } else {
- const r = e.getValue();
- return e.isNull() || e.isBoolean() || e.isString() && !DC(r) ? {
- isError: true,
- errorObejct: g2.create(m2.VALUE)
- } : +r < 0 ? {
- isError: true,
- errorObejct: g2.create(m2.NUM)
- } : {
- isError: true,
- errorObejct: g2.create(m2.NA)
- };
- }
- }
- };
- var w0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 7);
- }
- calculate(e, t, r, n, s, o, u) {
- let c = u != null ? u : y2.create(0);
- c.isNull() && (c = y2.create(0));
- const { isError: l2, errorObject: f2, variants: h } = Fe2(e, t, r, n, s, o, c);
- if (l2)
- return f2;
- const [d2, _, C, E2, b, R, p2] = h, N2 = k(d2);
- if (typeof N2 != "number")
- return N2;
- const M2 = k(_);
- if (typeof M2 != "number")
- return M2;
- const w = +C.getValue(), D2 = +E2.getValue(), S2 = +b.getValue(), P = Math.floor(+R.getValue()), U2 = Math.floor(+p2.getValue());
- if (Number.isNaN(w) || Number.isNaN(D2) || Number.isNaN(S2) || Number.isNaN(P) || Number.isNaN(U2))
- return g2.create(m2.VALUE);
- if (w < 0 || D2 <= 0 || S2 <= 0 || ![1, 2, 4].includes(P) || U2 < 0 || U2 > 4 || N2 >= M2 || !Or(N2, M2, P))
- return g2.create(m2.NUM);
- const x2 = this._getResult(N2, M2, w, D2, S2, P, U2);
- return y2.create(x2);
- }
- _getResult(e, t, r, n, s, o, u) {
- if (nr(e, t, o) > 1) {
- let E2 = r || 0.01, b = un(e, t, r, E2, s, o, u), R = b - n;
- for (let p2 = 0; p2 < 100 && Math.abs(R) > 1e-7; p2++)
- b = un(e, t, r, 1.01 * E2, s, o, u), E2 += -R / (b - n - R) * E2 * 0.01, R = un(e, t, r, E2, s, o, u) - n;
- return E2;
- }
- const l2 = es(e, t, o, u), f2 = qe(e, t, o, u), { days: h } = _e2(e, t, u), d2 = n / 100 + l2 / f2 * r / o;
- return (s / 100 + r / o - d2) / d2 * o * f2 / h;
- }
- };
- var D0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- let o = s != null ? s : y2.create(0);
- o.isNull() && (o = y2.create(0));
- const { isError: u, errorObject: c, variants: l2 } = Fe2(e, t, r, n, o);
- if (u)
- return c;
- const [f2, h, d2, _, C] = l2, E2 = k(f2);
- if (typeof E2 != "number")
- return E2;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
- return g2.create(m2.VALUE);
- if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || E2 >= b)
- return g2.create(m2.NUM);
- const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = (p2 / R - 1) / (M2 / w);
- return y2.create(D2);
- }
- };
- var S0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = o != null ? o : y2.create(0);
- u.isNull() && (u = y2.create(0));
- const { isError: c, errorObject: l2, variants: f2 } = Fe2(e, t, r, n, s, u);
- if (c)
- return l2;
- const [h, d2, _, C, E2, b] = f2, R = k(h);
- if (typeof R != "number")
- return R;
- const p2 = k(d2);
- if (typeof p2 != "number")
- return p2;
- const N2 = k(_);
- if (typeof N2 != "number")
- return N2;
- const M2 = +C.getValue(), w = +E2.getValue(), D2 = Math.floor(+b.getValue());
- if (Number.isNaN(M2) || Number.isNaN(w) || Number.isNaN(D2))
- return g2.create(m2.VALUE);
- const S2 = this._getDateCorrectOrder(p2, R, N2);
- if (M2 < 0 || w <= 0 || D2 < 0 || D2 > 4 || !S2)
- return g2.create(m2.NUM);
- const P = Au(R, D2), { days: U2 } = _e2(R, p2, D2), { days: x2 } = _e2(N2, p2, D2), { days: F } = _e2(N2, R, D2), W2 = ((1 + x2 / P * M2) / (w / 100 + F / P * M2) - 1) / (U2 / P);
- return y2.create(W2);
- }
- _getDateCorrectOrder(e, t, r) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r);
- }
- };
- var P0 = [
- [P1, ee.ACCRINT],
- [L1, ee.ACCRINTM],
- [x1, ee.AMORLINC],
- [j1, ee.COUPDAYBS],
- [U1, ee.COUPDAYS],
- [v1, ee.COUPDAYSNC],
- [T1, ee.COUPNCD],
- [B1, ee.COUPNUM],
- [I1, ee.COUPPCD],
- [F1, ee.CUMIPMT],
- [k1, ee.CUMPRINC],
- [$1, ee.DB],
- [Y1, ee.DDB],
- [H1, ee.DISC],
- [G1, ee.DOLLARDE],
- [Q1, ee.DOLLARFR],
- [W1, ee.DURATION],
- [q1, ee.EFFECT],
- [K1, ee.FV],
- [X1, ee.FVSCHEDULE],
- [Z1, ee.INTRATE],
- [z1, ee.IPMT],
- [J1, ee.IRR],
- [e0, ee.ISPMT],
- [t0, ee.MDURATION],
- [r0, ee.MIRR],
- [n0, ee.NOMINAL],
- [s0, ee.NPER],
- [a0, ee.NPV],
- [i0, ee.ODDFPRICE],
- [o0, ee.ODDFYIELD],
- [u0, ee.ODDLPRICE],
- [c0, ee.ODDLYIELD],
- [l0, ee.PDURATION],
- [f0, ee.PMT],
- [h0, ee.PPMT],
- [m0, ee.PRICE],
- [g0, ee.PRICEDISC],
- [d0, ee.PRICEMAT],
- [C0, ee.PV],
- [_0, ee.RATE],
- [A0, ee.RECEIVED],
- [E0, ee.RRI],
- [b0, ee.SLN],
- [y0, ee.SYD],
- [R0, ee.TBILLEQ],
- [p0, ee.TBILLPRICE],
- [V0, ee.TBILLYIELD],
- [N0, ee.VDB],
- [O0, ee.XIRR],
- [M0, ee.XNPV],
- [w0, ee.YIELD],
- [D0, ee.YIELDDISC],
- [S0, ee.YIELDMAT]
- ];
- var L0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "needsReferenceObject", true);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isError())
- return r;
- if (r.isReferenceObject() && (r = r.toArrayValueObject()), r.isArray()) {
- const n = r.getRowCount(), s = r.getColumnCount();
- if (n === 1 && s === 1) {
- const o = r.get(0, 0);
- return this._handleSingleObject(o, t);
- }
- return r.map((o) => o.isError() ? o : this._handleSingleObject(o, t, true));
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t, r = false) {
- let n = t;
- if (n.isError())
- return n;
- if (!n.isReferenceObject())
- return g2.create(m2.NA);
- const s = n.getCurrentActiveSheetData(), { columnData: o, defaultColumnWidth: u } = s;
- n = n.toArrayValueObject();
- const c = n.getCurrentRow(), l2 = n.getCurrentColumn();
- n = n.getFirstCell();
- const f2 = `${e.getValue()}`;
- let h;
- switch (f2.toLocaleLowerCase()) {
- case "address":
- return j.create(`$${re.chatAtABC(l2)}$${c + 1}`);
- case "col":
- return y2.create(l2 + 1);
- case "color":
- return y2.create(0);
- case "contents":
- return n;
- case "filename":
- return g2.create(m2.VALUE);
- case "format":
- return j.create("G");
- case "parentheses":
- return y2.create(0);
- case "prefix":
- return j.create("");
- case "protect":
- return y2.create(1);
- case "row":
- return y2.create(c + 1);
- case "type":
- return h = "v", n.isNull() && (h = "b"), n.isString() && (h = "l"), j.create(h);
- case "width":
- return this._getWidthResult(o, u, l2, r);
- default:
- return g2.create(m2.VALUE);
- }
- }
- _getWidthResult(e, t, r, n) {
- var u;
- let s = (u = e[r]) == null ? void 0 : u.w;
- if (!s && s !== 0 && (s = t), n)
- return y2.create(s);
- const o = [[s, s === t]];
- return q2.createByArray(o);
- }
- };
- var x0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "_errorTypeValueMap", /* @__PURE__ */ new Map([
- [m2.NULL, 1],
- [m2.DIV_BY_ZERO, 2],
- [m2.VALUE, 3],
- [m2.REF, 4],
- [m2.NAME, 5],
- [m2.NUM, 6],
- [m2.NA, 7],
- [m2.CONNECT, 8],
- [m2.CALC, 14]
- ]));
- }
- calculate(e) {
- return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const t = e.getValue(), r = this._errorTypeValueMap.get(t);
- return r ? y2.create(r) : g2.create(m2.NA);
- }
- };
- var Ne = ((i) => (i.CELL = "CELL", i.ERROR_TYPE = "ERROR.TYPE", i.INFO = "INFO", i.ISBETWEEN = "ISBETWEEN", i.ISBLANK = "ISBLANK", i.ISDATE = "ISDATE", i.ISEMAIL = "ISEMAIL", i.ISERR = "ISERR", i.ISERROR = "ISERROR", i.ISEVEN = "ISEVEN", i.ISFORMULA = "ISFORMULA", i.ISLOGICAL = "ISLOGICAL", i.ISNA = "ISNA", i.ISNONTEXT = "ISNONTEXT", i.ISNUMBER = "ISNUMBER", i.ISODD = "ISODD", i.ISOMITTED = "ISOMITTED", i.ISREF = "ISREF", i.ISTEXT = "ISTEXT", i.ISURL = "ISURL", i.N = "N", i.NA = "NA", i.SHEET = "SHEET", i.SHEETS = "SHEETS", i.TYPE = "TYPE", i))(Ne || {});
- var j0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = n != null ? n : T2.create(true), u = s != null ? s : T2.create(true), { isError: c, errorObject: l2, variants: f2 } = Fr(e, t, r, o, u);
- if (c)
- return l2;
- const [h, d2, _, C, E2] = f2;
- if (C.isString() || E2.isString())
- return g2.create(m2.VALUE);
- if (d2.compare(_, ">").getValue() === true)
- return g2.create(m2.NUM);
- const R = +C.getValue(), p2 = +E2.getValue(), N2 = R ? ">=" : ">", M2 = p2 ? "<=" : "<";
- return h.compare(d2, N2).getValue() === false || h.compare(_, M2).getValue() === false ? T2.create(false) : T2.create(true);
- }
- };
- var U0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isNull() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isNull() ? T2.create(true) : T2.create(false)) : T2.create(false);
- }
- };
- var v0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const r = t.getRowCount(), n = t.getColumnCount();
- if (r > 1 || n > 1)
- return g2.create(m2.VALUE);
- t = t.get(0, 0);
- }
- return t.isError() ? t : t.isNumber() && t.getPattern() !== "" ? T2.create(Ba(t.getPattern())) : t.isString() && (Xs(`${t.getValue()}`) || Zs(`${t.getValue()}`)) ? T2.create(true) : T2.create(false);
- }
- };
- var T0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const o = t.getRowCount(), u = t.getColumnCount();
- if (o > 1 || u > 1)
- return g2.create(m2.VALUE);
- t = t.get(0, 0);
- }
- if (t.isError())
- return t;
- if (t.isNull() || t.isBoolean() || t.isNumber())
- return T2.create(false);
- const r = `${t.getValue()}`;
- if (r.length > 254)
- return T2.create(false);
- const n = re.topLevelDomainCombiningString(), s = new RegExp(
- `^(?:[\\w+-]+\\.)*[\\w+-]+@[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${n})$`,
- "i"
- );
- return T2.create(s.test(r));
- }
- };
- var B0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.getValue() === m2.NA ? T2.create(false) : e.isError() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.getValue() === m2.NA ? T2.create(false) : t.isError() ? T2.create(true) : T2.create(false)) : T2.create(false);
- }
- };
- var I0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isError() ? T2.create(true) : T2.create(false)) : T2.create(false);
- }
- };
- var F0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const s = t.getRowCount(), o = t.getColumnCount();
- if (s > 1 || o > 1)
- return g2.create(m2.VALUE);
- t = t.get(0, 0);
- }
- if (t.isError())
- return t;
- if (t.isBoolean())
- return g2.create(m2.VALUE);
- const r = Math.trunc(+t.getValue());
- if (Number.isNaN(r))
- return g2.create(m2.VALUE);
- const n = r % 2 === 0;
- return T2.create(n);
- }
- };
- var k0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", true);
- }
- calculate(e) {
- var u;
- if (e.isError())
- return e;
- if (!e.isReferenceObject())
- return g2.create(m2.NA);
- const t = (u = e.getCurrentActiveSheetData()) == null ? void 0 : u.cellData.getMatrix(), { startRow: r, startColumn: n } = e.getRangePosition(), s = e.toArrayValueObject(), o = s.mapValue((c, l2, f2) => {
- var d2;
- const h = (d2 = t == null ? void 0 : t[r + l2]) == null ? void 0 : d2[n + f2];
- return h != null && h.f || h != null && h.si ? T2.create(true) : T2.create(false);
- });
- return s.getRowCount() === 1 && s.getColumnCount() === 1 ? o.get(0, 0) : o;
- }
- };
- var $0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isBoolean() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isBoolean() ? T2.create(true) : T2.create(false)) : T2.create(false);
- }
- };
- var Y0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.getValue() === m2.NA ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.getValue() === m2.NA ? T2.create(true) : T2.create(false)) : T2.create(false);
- }
- };
- var H0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return !e.isArray() && !e.isString() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isString() ? T2.create(false) : T2.create(true)) : T2.create(false);
- }
- };
- var G0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isNumber() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isNumber() ? T2.create(true) : T2.create(false)) : T2.create(false);
- }
- };
- var Q0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const s = t.getRowCount(), o = t.getColumnCount();
- if (s > 1 || o > 1)
- return g2.create(m2.VALUE);
- t = t.get(0, 0);
- }
- if (t.isError())
- return t;
- if (t.isBoolean())
- return g2.create(m2.VALUE);
- const r = Math.trunc(+t.getValue());
- if (Number.isNaN(r))
- return g2.create(m2.VALUE);
- const n = r % 2 !== 0;
- return T2.create(n);
- }
- };
- var W0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", true);
- }
- calculate(e) {
- return e.isReferenceObject() ? T2.create(true) : T2.create(false);
- }
- };
- var q0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isString() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isString() ? T2.create(true) : T2.create(false)) : T2.create(false);
- }
- };
- var K0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const o = t.getRowCount(), u = t.getColumnCount();
- if (o > 1 || u > 1)
- return g2.create(m2.VALUE);
- t = t.get(0, 0);
- }
- if (t.isError())
- return t;
- if (t.isNull() || t.isBoolean() || t.isNumber())
- return T2.create(false);
- const r = `${t.getValue()}`.replace(/^\s+|\s+$/g, "");
- if (r.length > 1e3)
- return T2.create(false);
- const n = re.topLevelDomainCombiningString(), s = new RegExp(
- `^(?:(?:https?|s?ftp|ftps|nfs|ssh)://+[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*(?::[0-9]+)?(?:/(?:[A-Za-z0-9\\-._~!$&'()*+,;=:@]|%[A-Fa-f0-9]{2})*)*/?(?:[?#]\\S*)?|[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${n})(?::[0-9]+)?(?:/(?:[A-Za-z0-9\\-._~!$&'()*+,;=:@]|%[A-Fa-f0-9]{2})*)*/?(?:[?#]\\S*)?|mailto:(?:[\\w+-]+\\.)*[\\w+-]+@[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${n})|(?:news|aim):[%a-z0-9$_\\.+!*(),;/?#:@&~=-]+)$`,
- "i"
- );
- return T2.create(s.test(r));
- }
- };
- var X0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (e.isArray() && (t = e.get(0, 0)), t.isError())
- return t;
- if (t.isString())
- return y2.create(0);
- const r = +t.getValue();
- return y2.create(r);
- }
- };
- var Z0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- return g2.create(m2.NA);
- }
- };
- var z0 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", true);
- A(this, "needsSheetsInfo", true);
- }
- calculate(e) {
- var u;
- if (e != null && e.isError())
- return e;
- const { sheetOrder: t, sheetNameMap: r } = this.getSheetsInfo();
- if (!e) {
- const c = t.findIndex((l2) => l2 === this.subUnitId);
- return y2.create(c + 1);
- }
- if (e.isReferenceObject()) {
- const c = e.getForcedSheetId(), l2 = e.getDefaultSheetId(), f2 = t.findIndex((h) => c ? h === c : h === l2);
- return y2.create(f2 + 1);
- }
- if (e.isArray())
- return g2.create(m2.NA);
- const n = `${e.getValue()}`.toLocaleLowerCase(), s = (u = Object.entries(r).find(([c, l2]) => l2.toLocaleLowerCase() === n)) == null ? void 0 : u[0];
- if (!s)
- return g2.create(m2.NA);
- const o = t.findIndex((c) => c === s);
- return y2.create(o + 1);
- }
- };
- var J02 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- A(this, "needsSheetsInfo", true);
- }
- calculate() {
- const { sheetOrder: e } = this.getSheetsInfo();
- return y2.create(e.length);
- }
- };
- var ed = class extends V {
- constructor() {
- super(...arguments);
- A(this, "needsReferenceObject", true);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isReferenceObject()) {
- const t = e.getRowCount(), r = e.getColumnCount();
- if (t === 1 && r === 1) {
- const n = e.getFirstCell();
- if (n.isError())
- return y2.create(16);
- if (n.isBoolean())
- return y2.create(4);
- if (n.isString())
- return y2.create(2);
- if (n.isNumber() || n.isNull())
- return y2.create(1);
- } else
- return y2.create(64);
- } else {
- if (e.isArray())
- return y2.create(64);
- if (e.isError())
- return y2.create(16);
- if (e.isBoolean())
- return y2.create(4);
- if (e.isString())
- return y2.create(2);
- if (e.isNumber() || e.isNull())
- return y2.create(1);
- }
- return y2.create(128);
- }
- };
- var td = [
- [L0, Ne.CELL],
- [x0, Ne.ERROR_TYPE],
- [j0, Ne.ISBETWEEN],
- [U0, Ne.ISBLANK],
- [v0, Ne.ISDATE],
- [T0, Ne.ISEMAIL],
- [B0, Ne.ISERR],
- [I0, Ne.ISERROR],
- [F0, Ne.ISEVEN],
- [k0, Ne.ISFORMULA],
- [$0, Ne.ISLOGICAL],
- [Y0, Ne.ISNA],
- [H0, Ne.ISNONTEXT],
- [G0, Ne.ISNUMBER],
- [Q0, Ne.ISODD],
- [W0, Ne.ISREF],
- [q0, Ne.ISTEXT],
- [K0, Ne.ISURL],
- [X0, Ne.N],
- [Z0, Ne.NA],
- [z0, Ne.SHEET],
- [J02, Ne.SHEETS],
- [ed, Ne.TYPE]
- ];
- var rd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = true, r = true, n = null;
- for (const s of e) {
- if (s.isError())
- return s;
- if (s.isArray()) {
- if (s.iterator((o) => {
- if (o != null && o.isError())
- return n = o, false;
- (o != null && o.isBoolean() || o != null && o.isNumber()) && (t = t && !!o.getValue(), r = false);
- }), n)
- return n;
- } else
- (s.isBoolean() || s.isNumber()) && (t = t && !!s.getValue(), r = false);
- }
- return r ? g2.create(m2.VALUE) : T2.create(t);
- }
- };
- var nd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- A(this, "needsReferenceObject", true);
- }
- // eslint-disable-next-line
- calculate(e, t) {
- let r = e, n = null;
- if (e.isReferenceObject() && (r = e.toArrayValueObject(), n = e), r.isError())
- return r;
- if (t.isError())
- return t;
- if (!(t.isValueObject() && t.isLambda() && t.getLambdaPrivacyVarKeys().length === 1))
- return g2.create(m2.VALUE);
- const s = t, o = r.isArray() ? r.getRowCount() : 1, u = r.isArray() ? r.getColumnCount() : 1;
- r = O(o, u, r);
- const c = [[]];
- for (let l2 = 0; l2 < u; l2++) {
- const f2 = [];
- for (let _ = 0; _ < o; _++) {
- const C = r.get(_, l2);
- f2.push([C]);
- }
- let h = q2.create({
- calculateValueList: f2,
- rowCount: o,
- columnCount: 1,
- unitId: "",
- sheetId: "",
- row: 0,
- column: 0
- });
- if (n) {
- const { startRow: _, startColumn: C } = n.getRangePosition(), E2 = {
- startRow: _,
- startColumn: C + l2,
- endRow: _ + o - 1,
- endColumn: C + l2
- };
- h = this.createReferenceObject(n, E2);
- }
- let d2 = s.execute(h);
- if (d2.isArray()) {
- const _ = d2.getRowCount(), C = d2.getColumnCount();
- if (_ > 1 || C > 1)
- return g2.create(m2.CALC);
- d2 = d2.get(0, 0);
- }
- d2.isNull() && (d2 = y2.create(0)), c[0].push(d2);
- }
- return u === 1 ? c[0][0] : q2.create({
- calculateValueList: c,
- rowCount: 1,
- columnCount: u,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- };
- var sd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- A(this, "needsReferenceObject", true);
- }
- // eslint-disable-next-line
- calculate(e, t) {
- let r = e, n = null;
- if (e.isReferenceObject() && (r = e.toArrayValueObject(), n = e), r.isError())
- return r;
- if (t.isError())
- return t;
- if (!(t.isValueObject() && t.isLambda() && t.getLambdaPrivacyVarKeys().length === 1))
- return g2.create(m2.VALUE);
- const s = t, o = r.isArray() ? r.getRowCount() : 1, u = r.isArray() ? r.getColumnCount() : 1;
- r = O(o, u, r);
- const c = [];
- for (let l2 = 0; l2 < o; l2++) {
- const f2 = [[]];
- for (let _ = 0; _ < u; _++) {
- const C = r.get(l2, _);
- f2[0].push(C);
- }
- let h = q2.create({
- calculateValueList: f2,
- rowCount: 1,
- columnCount: u,
- unitId: "",
- sheetId: "",
- row: 0,
- column: 0
- });
- if (n) {
- const { startRow: _, startColumn: C } = n.getRangePosition(), E2 = {
- startRow: _ + l2,
- startColumn: C,
- endRow: _ + l2,
- endColumn: C + u - 1
- };
- h = this.createReferenceObject(n, E2);
- }
- let d2 = s.execute(h);
- if (d2.isArray()) {
- const _ = d2.getRowCount(), C = d2.getColumnCount();
- if (_ > 1 || C > 1)
- return g2.create(m2.CALC);
- d2 = d2.get(0, 0);
- }
- d2.isNull() && (d2 = y2.create(0)), c.push([d2]);
- }
- return o === 1 ? c[0][0] : q2.create({
- calculateValueList: c,
- rowCount: o,
- columnCount: 1,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- };
- var ad = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- return T2.create(false);
- }
- };
- var Se2 = ((i) => (i.AND = "AND", i.BYCOL = "BYCOL", i.BYROW = "BYROW", i.FALSE = "FALSE", i.IF = "IF", i.IFERROR = "IFERROR", i.IFNA = "IFNA", i.IFS = "IFS", i.LAMBDA = "LAMBDA", i.LET = "LET", i.MAKEARRAY = "MAKEARRAY", i.MAP = "MAP", i.NOT = "NOT", i.OR = "OR", i.REDUCE = "REDUCE", i.SCAN = "SCAN", i.SWITCH = "SWITCH", i.TRUE = "TRUE", i.XOR = "XOR", i))(Se2 || {});
- var id = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r = T2.create(false)) {
- const n = this._getSingleValueObject(e);
- if (n.isError())
- return n;
- if (!n.isArray())
- return n.getValue() ? t : r;
- const s = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), o = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), u = O(s, o, n), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA));
- return u.map((f2, h, d2) => {
- if (f2.isNull())
- return g2.create(m2.NA);
- {
- const _ = c.get(h, d2) || ie.create(), C = l2.get(h, d2) || ie.create();
- return this._calculateSingleCell(f2, _, C);
- }
- });
- }
- _getSingleValueObject(e) {
- return e.isArray() && e.getRowCount() === 1 && e.getColumnCount() === 1 ? e.getFirstCell() : e;
- }
- _calculateSingleCell(e, t, r) {
- return e.isNull() ? g2.create(m2.NA) : e.getValue() ? t.isNull() ? g2.create(m2.NA) : t : r.isNull() ? g2.create(m2.NA) : r;
- }
- };
- var od = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (!e.isArray())
- return e.isError() ? t : e;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e), o = O(r, n, t);
- return s.iterator((u, c, l2) => {
- u != null && u.isError() && s.set(c, l2, o.get(c, l2));
- }), s;
- }
- };
- var ud = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError() && e.getErrorType() !== m2.NA)
- return e;
- if (t.isError())
- return t;
- if (!e.isArray())
- return e.isError() && e.getErrorType() === m2.NA ? t : e;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e), o = O(r, n, t);
- return s.iterator((u, c, l2) => {
- u != null && u.isError() && u.getErrorType() === m2.NA && s.set(c, l2, o.get(c, l2));
- }), s;
- }
- };
- var cd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- if (e.length % 2 !== 0)
- return g2.create(m2.NA);
- for (let o = 0; o < e.length; o++)
- if (e[o].isError())
- return e[o];
- const t = Math.max(
- ...e.map((o) => o.isArray() ? o.getRowCount() : 1)
- ), r = Math.max(
- ...e.map((o) => o.isArray() ? o.getColumnCount() : 1)
- ), n = e.map(
- (o) => O(t, r, o, g2.create(m2.NA))
- ), s = n[0].map((o, u, c) => {
- for (let l2 = 0; l2 < n.length; l2 += 2) {
- const f2 = n[l2].get(u, c) || ie.create(), h = n[l2 + 1].get(u, c) || ie.create();
- if (f2.isNull())
- continue;
- if (f2.isError())
- return f2;
- const d2 = f2.getValue();
- if (f2.isString()) {
- if (`${d2}`.toLocaleUpperCase() === "TRUE")
- return h;
- if (`${d2}`.toLocaleUpperCase() === "FALSE")
- continue;
- return g2.create(m2.VALUE);
- }
- if (+d2)
- return h.isNull() ? g2.create(m2.NA) : h;
- }
- return g2.create(m2.NA);
- });
- return t === 1 && r === 1 ? s.get(0, 0) : s;
- }
- };
- var ld = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- return g2.create(m2.VALUE);
- }
- };
- var fd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- return g2.create(m2.VALUE);
- }
- };
- var hd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(...e) {
- const t = this.getIndexNumValue(e[0]);
- if (typeof t != "number")
- return t;
- const r = this.getIndexNumValue(e[1]);
- if (typeof r != "number")
- return r;
- if (!(e[2].isValueObject() && e[2].isLambda()))
- return g2.create(m2.VALUE);
- const n = e[2], s = [];
- for (let o = 0; o < t; o++) {
- s[o] == null && (s[o] = []);
- for (let u = 0; u < r; u++) {
- let c = n.execute(y2.create(o + 1), y2.create(u + 1));
- c.isArray() && (c = c.get(0, 0)), s[o][u] = c;
- }
- }
- return new Of(s);
- }
- isAsync() {
- return true;
- }
- };
- var md = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- A(this, "needsReferenceObject", true);
- }
- calculate(...e) {
- const t = [];
- let r = null, n = 0, s = 0;
- for (let u = 0; u < e.length; u++) {
- const c = e[u];
- let l2 = c;
- if (l2.isReferenceObject() && (l2 = c.toArrayValueObject()), l2.isError())
- return l2;
- if (u === e.length - 1) {
- if (!(c.isValueObject() && c.isLambda()))
- return g2.create(m2.VALUE);
- r = c;
- } else
- t.push(c), n = Math.max(n, l2.isArray() ? l2.getRowCount() : 1), s = Math.max(s, l2.isArray() ? l2.getColumnCount() : 1);
- }
- const o = this._getResultArray(t, r, n, s);
- return o instanceof g2 ? o : n === 1 && s === 1 ? o[0][0] : q2.create({
- calculateValueList: o,
- rowCount: n,
- columnCount: s,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- // eslint-disable-next-line
- _getResultArray(e, t, r, n) {
- const s = [];
- for (let o = 0; o < r; o++) {
- const u = [];
- for (let c = 0; c < n; c++) {
- const l2 = [];
- let f2 = false;
- for (let d2 = 0; d2 < e.length; d2++) {
- let _ = e[d2], C = null;
- if (_.isReferenceObject() && (C = _, _ = _.toArrayValueObject()), !_.isArray())
- if (o === 0 && c === 0) {
- l2.push(C || _);
- continue;
- } else {
- u.push(g2.create(m2.NA)), f2 = true;
- break;
- }
- let E2 = _.get(o, c);
- if (!E2) {
- u.push(g2.create(m2.NA)), f2 = true;
- break;
- }
- if (C) {
- const { startRow: b, startColumn: R } = C.getRangePosition(), p2 = {
- startRow: b + o,
- startColumn: R + c,
- endRow: b + o,
- endColumn: R + c
- };
- E2 = this.createReferenceObject(C, p2);
- }
- l2.push(E2);
- }
- if (f2 || l2.length === 0)
- continue;
- let h = t.execute(...l2);
- if (h.isArray()) {
- const d2 = h.getRowCount(), _ = h.getColumnCount();
- if (d2 > 1 || _ > 1)
- return g2.create(m2.CALC);
- h = h.get(0, 0);
- }
- h.isNull() && (h = y2.create(0)), u.push(h);
- }
- s.push(u);
- }
- return s;
- }
- };
- var gd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- const t = +e.getValue();
- return Number.isNaN(t) ? g2.create(m2.VALUE) : T2.create(!t);
- }
- };
- var dd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = false, r = true, n = null;
- for (const s of e) {
- if (s.isError())
- return s;
- if (s.isArray()) {
- if (s.iterator((o) => {
- if (o != null && o.isError())
- return n = o, false;
- (o != null && o.isBoolean() || o != null && o.isNumber()) && (t = t || !!o.getValue(), r = false);
- }), n)
- return n;
- } else
- (s.isBoolean() || s.isNumber()) && (t = t || !!s.getValue(), r = false);
- }
- return r ? new g2(m2.VALUE) : new T2(t);
- }
- };
- var Cd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", true);
- }
- calculate(e, t, r) {
- let n, s;
- e.isReferenceObject() ? (n = e.toArrayValueObject(), s = e) : (n = e, s = null);
- let o, u;
- return t.isReferenceObject() ? (o = t.toArrayValueObject(), u = t) : (o = t, u = null), n.isArray() ? n.mapValue((c) => this._handleSingleValueObject(c, o, r, s, u)) : this._handleSingleValueObject(n, o, r, s, u);
- }
- _handleSingleValueObject(e, t, r, n, s) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- if (!(r.isValueObject() && r.isLambda() && r.getLambdaPrivacyVarKeys().length === 2))
- return g2.create(m2.VALUE);
- const o = r, u = t.isArray() ? t.getRowCount() : 1, c = t.isArray() ? t.getColumnCount() : 1;
- let l2 = e;
- n && (l2 = n);
- for (let f2 = 0; f2 < u; f2++)
- for (let h = 0; h < c; h++) {
- let d2 = t.isArray() ? t.get(f2, h) : t;
- if (d2.isError())
- return d2;
- if (s) {
- const { startRow: C, startColumn: E2 } = s.getRangePosition(), b = {
- startRow: C + f2,
- startColumn: E2 + h,
- endRow: C + f2,
- endColumn: E2 + h
- };
- d2 = this.createReferenceObject(s, b);
- }
- let _ = o.execute(l2, d2);
- if (_.isError())
- return _;
- _.isNull() && (_ = y2.create(0)), l2 = _;
- }
- return l2.isReferenceObject() ? l2.toArrayValueObject() : l2;
- }
- };
- var _d = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", true);
- }
- calculate(e, t, r) {
- let n = e, s = null;
- e.isReferenceObject() && (n = e.toArrayValueObject(), s = e), n = n;
- let o = t, u = null;
- if (t.isReferenceObject() && (o = t.toArrayValueObject(), u = t), o = o, n.isError())
- return n;
- if (o.isError())
- return o;
- if (r.isError())
- return r;
- if (!(r.isValueObject() && r.isLambda() && r.getLambdaPrivacyVarKeys().length === 2))
- return g2.create(m2.VALUE);
- if (n.isArray()) {
- const c = n.getRowCount(), l2 = n.getColumnCount();
- if (c > 1 || l2 > 1)
- return g2.create(m2.CALC);
- n = n.get(0, 0);
- }
- return this._getResult(n, o, r, s, u);
- }
- // eslint-disable-next-line
- _getResult(e, t, r, n, s) {
- const o = [], u = t.isArray() ? t.getRowCount() : 1, c = t.isArray() ? t.getColumnCount() : 1;
- let l2 = e;
- n && (l2 = n);
- for (let f2 = 0; f2 < u; f2++) {
- const h = [];
- for (let d2 = 0; d2 < c; d2++) {
- if (l2.isError()) {
- h.push(l2);
- continue;
- }
- let _ = t.isArray() ? t.get(f2, d2) : t;
- if (_.isError()) {
- l2 = _, h.push(_);
- continue;
- }
- if (s) {
- const { startRow: E2, startColumn: b } = s.getRangePosition(), R = {
- startRow: E2 + f2,
- startColumn: b + d2,
- endRow: E2 + f2,
- endColumn: b + d2
- };
- _ = this.createReferenceObject(s, R);
- }
- let C = r.execute(l2, _);
- if (C.isArray()) {
- const E2 = C.getRowCount(), b = C.getColumnCount();
- if (E2 > 1 || b > 1)
- return g2.create(m2.CALC);
- C = C.get(0, 0);
- }
- C.isNull() && (C = y2.create(0)), l2 = C, h.push(C);
- }
- o.push(h);
- }
- return u === 1 && c === 1 ? o[0][0] : q2.create({
- calculateValueList: o,
- rowCount: u,
- columnCount: c,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- };
- var Ad = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- const r = t.length % 2 !== 0, n = r ? t[t.length - 1] : ie.create();
- return !e.isArray() && !t.some((s) => s.isArray()) ? this._handleNonArrayInputs(e, t, n, r) : this._handleArrayInputs(e, t, n, r);
- }
- _handleNonArrayInputs(e, t, r, n) {
- for (let s = 0; s < t.length - (n ? 1 : 0); s += 2) {
- const o = t[s], u = t[s + 1];
- if (!o.isNull()) {
- if (o.isError())
- return o;
- if (`${e.getValue()}`.toLocaleLowerCase() === `${o.getValue()}`.toLocaleLowerCase())
- return u.isNull() ? g2.create(m2.NA) : u;
- }
- }
- return r.isNull() ? g2.create(m2.NA) : r;
- }
- _handleArrayInputs(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- ...t.map((f2) => f2.isArray() ? f2.getRowCount() : 1),
- r.isArray() ? r.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- ...t.map((f2) => f2.isArray() ? f2.getColumnCount() : 1),
- r.isArray() ? r.getColumnCount() : 1
- ), u = O(s, o, e), c = t.map(
- (f2) => O(s, o, f2, g2.create(m2.NA))
- ), l2 = O(s, o, r, g2.create(m2.NA));
- return u.map((f2, h, d2) => {
- for (let C = 0; C < c.length - (n ? 1 : 0); C += 2) {
- const E2 = c[C].get(h, d2) || ie.create(), b = c[C + 1].get(h, d2) || ie.create();
- if (!E2.isNull()) {
- if (E2.isError() || f2.isError())
- return E2.isError() ? E2 : f2;
- if (`${f2.getValue()}`.toLocaleLowerCase() === `${E2.getValue()}`.toLocaleLowerCase())
- return b.isNull() ? g2.create(m2.NA) : b;
- }
- }
- const _ = l2.get(h, d2) || ie.create();
- return _.isNull() ? g2.create(m2.NA) : _;
- });
- }
- };
- var Ed = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- return T2.create(true);
- }
- };
- var bd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 0, r = true, n = null;
- for (const s of e) {
- if (s.isError())
- return s;
- if (s.isArray()) {
- if (s.iterator((o) => {
- if (o != null && o.isError())
- return n = o, false;
- (o != null && o.isBoolean() || o != null && o.isNumber()) && (o.getValue() && t++, r = false);
- }), n)
- return n;
- } else
- (s.isBoolean() || s.isNumber()) && (s.getValue() && t++, r = false);
- }
- return r ? g2.create(m2.VALUE) : T2.create(t % 2 === 1);
- }
- };
- var yd = [
- [rd, Se2.AND],
- [nd, Se2.BYCOL],
- [sd, Se2.BYROW],
- [ad, Se2.FALSE],
- [id, Se2.IF],
- [od, Se2.IFERROR],
- [ud, Se2.IFNA],
- [cd, Se2.IFS],
- [ld, Se2.LAMBDA],
- [fd, Se2.LET],
- [hd, Se2.MAKEARRAY],
- [md, Se2.MAP],
- [gd, Se2.NOT],
- [dd, Se2.OR],
- [Cd, Se2.REDUCE],
- [_d, Se2.SCAN],
- [Ad, Se2.SWITCH],
- [Ed, Se2.TRUE],
- [bd, Se2.XOR]
- ];
- var Rd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 5);
- }
- // eslint-disable-next-line max-lines-per-function
- calculate(e, t, r, n, s) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r != null && r.isError())
- return r;
- if (n != null && n.isError())
- return n;
- if (s != null && s.isError())
- return s;
- const o = r != null ? r : y2.create(1), u = n != null ? n : T2.create(true), c = s != null ? s : j.create(""), l2 = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f2 = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l2, f2, e, g2.create(m2.NA)), d2 = O(l2, f2, t, g2.create(m2.NA)), _ = O(l2, f2, o, g2.create(m2.NA)), C = O(l2, f2, u, g2.create(m2.NA)), E2 = O(l2, f2, c, g2.create(m2.NA));
- return h.map((b, R, p2) => {
- const N2 = d2.get(R, p2) || g2.create(m2.NA), M2 = _.get(R, p2) || g2.create(m2.NA), w = C.get(R, p2) || g2.create(m2.NA), D2 = E2.get(R, p2) || g2.create(m2.NA);
- return b.isError() ? b : N2.isError() ? N2 : M2.isError() ? M2 : w.isError() ? w : D2.isError() ? D2 : this._calculateSingleCell(b, N2, M2, w, D2);
- });
- }
- _calculateSingleCell(e, t, r, n, s) {
- const o = Number.parseInt(`${Number(e.getValue()) - 1}`), u = Number.parseInt(`${Number(t.getValue()) - 1}`), c = Number.parseInt(`${Number(r.getValue())}`);
- if (Number.isNaN(o) || Number.isNaN(u) || Number.isNaN(c) || c < 1 || c > 4)
- return g2.create(m2.VALUE);
- const l2 = pd(c), f2 = this.getZeroOrOneByOneDefault(n), h = `${s.getValue()}`, d2 = Ki(h), _ = {
- startRow: o,
- startColumn: u,
- endRow: o,
- endColumn: u,
- startAbsoluteRefType: l2,
- endAbsoluteRefType: l2
- }, C = n && !f2 ? Fh(_) : fr(_);
- return j.create(d2 !== "" ? `${d2}!${C}` : C);
- }
- };
- function pd(i) {
- switch (i) {
- case 1:
- return tt.ALL;
- case 2:
- return tt.ROW;
- case 3:
- return tt.COLUMN;
- case 4:
- return tt.NONE;
- default:
- return tt.ALL;
- }
- }
- var Vd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", true);
- }
- calculate(e) {
- return e.isReferenceObject() ? y2.create(1) : g2.create(m2.VALUE);
- }
- };
- var Nd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- A(this, "needsReferenceObject", true);
- }
- calculate(e, ...t) {
- let r = e;
- if (r.isError())
- return r;
- if (r.isReferenceObject() && (r = r.toArrayValueObject()), !r.isArray()) {
- const c = r.convertToNumberObjectValue();
- return c.isError() ? c : t[Math.trunc(+c.getValue()) - 1] || g2.create(m2.VALUE);
- }
- let n = r.isArray() ? r.getRowCount() : 1, s = r.isArray() ? r.getColumnCount() : 1;
- t.forEach((c, l2) => {
- if (c.isArray()) {
- const f2 = c;
- n = Math.max(n, f2.getRowCount()), s = Math.max(s, f2.getColumnCount());
- } else
- n = Math.max(n, 1), s = Math.max(s, 1);
- });
- const o = O(n, s, r, g2.create(m2.NA)), u = t.map((c) => {
- let l2 = c;
- return l2.isReferenceObject() && (l2 = l2.toArrayValueObject()), O(n, s, l2, g2.create(m2.NA));
- });
- return o.map((c, l2, f2) => {
- if (c.isError())
- return c;
- const h = c.convertToNumberObjectValue();
- if (h.isError())
- return h;
- const d2 = u[Math.trunc(+h.getValue()) - 1];
- let _ = (d2 == null ? void 0 : d2.get(l2, f2)) || g2.create(m2.VALUE);
- return _ != null && _.isNull() && (_ = y2.create(0)), _;
- });
- }
- };
- var Od = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = [];
- for (let o = 0; o < t.length; o++) {
- let u = t[o];
- if (u.isArray()) {
- const f2 = u.getRowCount(), h = u.getColumnCount();
- if (f2 > 1 || h > 1)
- return g2.create(m2.VALUE);
- u = u.get(0, 0);
- }
- if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
- return u;
- const c = Math.trunc(+u.getValue());
- if (c === 0 || Math.abs(c) > n)
- return g2.create(m2.VALUE);
- let l2 = e;
- n > 1 && (c < 0 ? l2 = e.slice(void 0, [c + n, c + 1 + n]) : l2 = e.slice(void 0, [c - 1, c]));
- for (let f2 = 0; f2 < r; f2++)
- s[f2] || (s[f2] = []), e.isArray() ? s[f2].push(l2.get(f2, 0)) : s[f2].push(e);
- }
- return q2.create({
- calculateValueList: s,
- rowCount: s.length,
- columnCount: s[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- };
- var Md = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- const r = e.isArray() ? e.getRowCount() : 1, n = [];
- for (let s = 0; s < t.length; s++) {
- let o = t[s];
- if (o.isArray()) {
- const l2 = o.getRowCount(), f2 = o.getColumnCount();
- if (l2 > 1 || f2 > 1)
- return g2.create(m2.VALUE);
- o = o.get(0, 0);
- }
- if (o.isString() && (o = o.convertToNumberObjectValue()), o.isError())
- return o;
- const u = Math.trunc(+o.getValue());
- if (u === 0 || Math.abs(u) > r)
- return g2.create(m2.VALUE);
- let c = e;
- r > 1 && (u < 0 ? c = e.slice([u + r, u + 1 + r]) : c = e.slice([u - 1, u])), e.isArray() ? n.push(c.getArrayValue()[0]) : n.push([e]);
- }
- return q2.create({
- calculateValueList: n,
- rowCount: n.length,
- columnCount: n[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- };
- var wd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e == null)
- return y2.create(this.column + 1);
- if (e.isError())
- return e;
- if (!e.isArray())
- return g2.create(m2.NA);
- const t = e.getCurrentColumn(), r = e.getColumnCount(), n = [];
- for (let o = 0; o < r; o++)
- n.push(y2.create(t + o + 1));
- const s = {
- calculateValueList: [n],
- rowCount: 1,
- columnCount: r,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q2.create(s);
- }
- };
- var Dd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isError())
- return e;
- if (e.isString() || e.isNumber() || e.isBoolean())
- return y2.create(1);
- if (!e.isArray())
- return g2.create(m2.NA);
- const t = e.getColumnCount();
- return y2.create(t);
- }
- };
- var Sd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y2.create(0), s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), c = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), l2 = O(u, c, t, g2.create(m2.NA)), f2 = O(u, c, n, g2.create(m2.NA));
- if (u > 1 || c > 1)
- return l2.mapValue((R, p2, N2) => {
- const M2 = f2.get(p2, N2);
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- const { isError: w, errorObject: D2 } = this._checkRowsColumns(R, M2, s, o);
- return w ? D2 : e.isArray() ? g2.create(m2.VALUE) : e;
- });
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- const h = t.isArray() ? t.get(0, 0) : t, d2 = n.isArray() ? n.get(0, 0) : n, { isError: _, errorObject: C, rowsValue: E2, columnsValue: b } = this._checkRowsColumns(h, d2, s, o);
- return _ ? C : this._getResultArray(e, E2, b, s, o);
- }
- _checkRowsColumns(e, t, r, n) {
- if (e.isError())
- return {
- isError: true,
- errorObject: e
- };
- if (t.isError())
- return {
- isError: true,
- errorObject: t
- };
- const s = Math.trunc(+e.getValue()), o = Math.trunc(+t.getValue());
- return Number.isNaN(s) || Number.isNaN(o) ? {
- isError: true,
- errorObject: g2.create(m2.VALUE)
- } : Math.abs(s) >= r || Math.abs(o) >= n ? {
- isError: true,
- errorObject: g2.create(m2.CALC)
- } : {
- isError: false,
- rowsValue: s,
- columnsValue: o
- };
- }
- _getResultArray(e, t, r, n, s) {
- const o = t >= 0 ? [t, n] : [0, n + t], u = r >= 0 ? [r, s] : [0, s + r];
- let c;
- return t === 0 && r === 0 ? c = e : t === 0 ? c = e.slice(void 0, u) : r === 0 ? c = e.slice(o, void 0) : c = e.slice(o, u), c = c.map((l2) => l2.isNull() ? y2.create(0) : l2), n - t === 1 && s - r === 1 ? c.get(0, 0) : c;
- }
- };
- var Pd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1;
- let u = t, c = r != null ? r : y2.create(o);
- const l2 = n != null ? n : g2.create(m2.NA);
- t.isNull() && (u = y2.create(s)), c.isNull() && (c = y2.create(o));
- const f2 = Math.max(
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), h = Math.max(
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), d2 = O(f2, h, u, g2.create(m2.NA)), _ = O(f2, h, c, g2.create(m2.NA));
- if (f2 > 1 || h > 1)
- return d2.mapValue((w, D2, S2) => {
- const P = _.get(D2, S2);
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- const { isError: U2, errorObject: x2 } = this._checkRowsColumnsPadWith(w, P, l2, s, o);
- return U2 ? x2 : e.isArray() ? e.get(0, 0) : e;
- });
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- const C = u.isArray() ? u.get(0, 0) : u, E2 = c.isArray() ? c.get(0, 0) : c, { isError: b, errorObject: R, rowsValue: p2, columnsValue: N2, padWithObject: M2 } = this._checkRowsColumnsPadWith(C, E2, l2, s, o);
- return b ? R : this._getResultArray(e, p2, N2, M2, s, o);
- }
- _checkRowsColumnsPadWith(e, t, r, n, s) {
- if (e.isError())
- return {
- isError: true,
- errorObject: e
- };
- if (t.isError())
- return {
- isError: true,
- errorObject: t
- };
- const o = Math.trunc(+e.getValue()), u = Math.trunc(+t.getValue());
- if (Number.isNaN(o) || Number.isNaN(u))
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE)
- };
- if (Math.abs(o) < n || Math.abs(u) < s)
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE)
- };
- let c = r;
- if (r.isArray()) {
- const l2 = r.getRowCount(), f2 = r.getColumnCount();
- if (l2 > 1 || f2 > 1)
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE)
- };
- c = r.get(0, 0);
- }
- return {
- isError: false,
- rowsValue: o,
- columnsValue: u,
- padWithObject: c
- };
- }
- _getResultArray(e, t, r, n, s, o) {
- let u = [];
- e.isArray() ? u = e.map((f2) => f2.isNull() ? y2.create(0) : f2).getArrayValue() : u = [[e]];
- const c = Math.max(0, t - s), l2 = Math.max(0, r - o);
- for (let f2 = 0; f2 < c; f2++)
- u.push(new Array(o).fill(n));
- for (let f2 = 0; f2 < l2; f2++)
- u.forEach((h) => {
- h.push(n);
- });
- return t === 1 && r === 1 ? u[0][0] : q2.create({
- calculateValueList: u,
- rowCount: u.length,
- columnCount: u[0].length,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- };
- var Ld = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : g2.create(m2.CALC);
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = t.isArray() ? t.getRowCount() : 1, c = t.isArray() ? t.getColumnCount() : 1;
- return u > 1 && c > 1 || u === 1 && c !== o || c === 1 && u !== s ? g2.create(m2.VALUE) : s === 1 && o === 1 ? this._getResultArrayByR1C1(e, t, n) : u === 1 ? c !== o ? g2.create(m2.VALUE) : this._getResultArrayByR1(s, o, e, t, n) : c === 1 ? u !== s ? g2.create(m2.VALUE) : this._getResultArrayByC1(s, o, e, t, n) : n;
- }
- _getResultArrayByR1C1(e, t, r) {
- let n = e, s = t;
- return n.isArray() && (n = n.get(0, 0)), s.isArray() && (s = s.get(0, 0)), s.isString() && (s = s.convertToNumberObjectValue()), s.isError() ? s : +s.getValue() ? n : r;
- }
- _getResultArrayByR1(e, t, r, n, s) {
- const o = [];
- for (let u = 0; u < t; u++) {
- let c = n.get(0, u);
- if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
- return c;
- if (+c.getValue())
- for (let f2 = 0; f2 < e; f2++) {
- o[f2] || (o[f2] = []);
- const h = r.get(f2, u);
- o[f2].push(h);
- }
- }
- return o.length === 0 ? s : q2.create({
- calculateValueList: o,
- rowCount: o.length,
- columnCount: o[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- _getResultArrayByC1(e, t, r, n, s) {
- const o = [];
- for (let u = 0; u < e; u++) {
- let c = n.get(u, 0);
- if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
- return c;
- if (!+c.getValue())
- continue;
- const f2 = [];
- for (let h = 0; h < t; h++) {
- const d2 = r.get(u, h);
- f2.push(d2);
- }
- o.push(f2);
- }
- return o.length === 0 ? s : q2.create({
- calculateValueList: o,
- rowCount: o.length,
- columnCount: o[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- };
- var xd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", true);
- A(this, "needsFormulaDataModel", true);
- }
- calculate(e) {
- var f2, h;
- if (!e.isReferenceObject())
- return g2.create(m2.NA);
- const t = e.getUnitId(), r = e.getSheetId(), s = (h = (f2 = e.getUnitData()[t]) == null ? void 0 : f2[r]) == null ? void 0 : h.cellData, { startRow: o, startColumn: u } = e.getRangePosition(), l2 = e.toArrayValueObject().mapValue((d2, _, C) => {
- const E2 = s.getValue(o + _, u + C);
- if (E2 != null && E2.f || E2 != null && E2.si) {
- const b = this._formulaDataModel.getFormulaStringByCell(o + _, u + C, r, t);
- return j.create(b);
- }
- return g2.create(m2.NA);
- });
- return l2.getRowCount() === 1 && l2.getColumnCount() === 1 ? l2.get(0, 0) : l2;
- }
- };
- var me2 = ((i) => (i.ADDRESS = "ADDRESS", i.AREAS = "AREAS", i.CHOOSE = "CHOOSE", i.CHOOSECOLS = "CHOOSECOLS", i.CHOOSEROWS = "CHOOSEROWS", i.COLUMN = "COLUMN", i.COLUMNS = "COLUMNS", i.DROP = "DROP", i.EXPAND = "EXPAND", i.FILTER = "FILTER", i.FORMULATEXT = "FORMULATEXT", i.GETPIVOTDATA = "GETPIVOTDATA", i.HLOOKUP = "HLOOKUP", i.HSTACK = "HSTACK", i.HYPERLINK = "HYPERLINK", i.IMAGE = "IMAGE", i.INDEX = "INDEX", i.INDIRECT = "INDIRECT", i.LOOKUP = "LOOKUP", i.MATCH = "MATCH", i.OFFSET = "OFFSET", i.ROW = "ROW", i.ROWS = "ROWS", i.RTD = "RTD", i.SORT = "SORT", i.SORTBY = "SORTBY", i.TAKE = "TAKE", i.TOCOL = "TOCOL", i.TOROW = "TOROW", i.TRANSPOSE = "TRANSPOSE", i.UNIQUE = "UNIQUE", i.VLOOKUP = "VLOOKUP", i.VSTACK = "VSTACK", i.WRAPCOLS = "WRAPCOLS", i.WRAPROWS = "WRAPROWS", i.XLOOKUP = "XLOOKUP", i.XMATCH = "XMATCH", i))(me2 || {});
- var jd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- if (e.isError())
- return e;
- if (t.isError())
- return g2.create(m2.REF);
- if (!t.isArray() || r.isError() || n != null && n.isError())
- return g2.create(m2.NA);
- const s = this.getZeroOrOneByOneDefault(n);
- if (s == null)
- return g2.create(m2.VALUE);
- const o = this.getIndexNumValue(r);
- if (o instanceof g2)
- return o;
- const u = t.slice([0, 1]), c = t.slice([o - 1, o]);
- return u == null || c == null ? g2.create(m2.REF) : e.isArray() ? e.map((l2) => this._handleSingleObject(l2, u, c, s)) : this._handleSingleObject(e, u, c, s);
- }
- _handleSingleObject(e, t, r, n) {
- return n === 0 ? this.equalSearch(e, t, r) : this.binarySearch(e, t, r);
- }
- };
- var Ud = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = Math.max(
- ...e.map((n) => n.isArray() ? n.getRowCount() : 1)
- ), r = [];
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (s.isError())
- return s;
- const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
- for (let c = 0; c < t; c++) {
- r[c] || (r[c] = []);
- for (let l2 = 0; l2 < u; l2++) {
- let f2 = s;
- s.isArray() && (f2 = s.get(c, l2)), c > o - 1 || !f2 ? r[c].push(g2.create(m2.NA)) : r[c].push(f2);
- }
- }
- }
- return q2.create({
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- };
- var vd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- A(this, "needsReferenceObject", true);
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- calculate(e, t, r, n) {
- if (e.isError())
- return e;
- if (t != null && t.isError())
- return t;
- if (r != null && r.isError())
- return r;
- if (n != null && n.isError())
- return n;
- let s = 0, o = 0;
- if (e.isValueObject())
- s = 1, o = 1;
- else if (e.isReferenceObject()) {
- const { startRow: d2, endRow: _, startColumn: C, endColumn: E2 } = e.getRangePosition();
- s = _ - d2 + 1, o = E2 - C + 1;
- } else
- return g2.create(m2.VALUE);
- let u, c;
- s === 1 && o > 1 && r == null ? (c = t != null ? t : y2.create(0), u = y2.create(0)) : (u = t != null ? t : y2.create(0), c = r != null ? r : y2.create(0));
- let l2 = n != null ? n : y2.create(1);
- u.isReferenceObject() && (u = u.toArrayValueObject()), c.isReferenceObject() && (c = c.toArrayValueObject()), l2.isReferenceObject() && (l2 = l2.toArrayValueObject());
- const f2 = Math.max(
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- l2.isArray() ? l2.getRowCount() : 1
- ), h = Math.max(
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- l2.isArray() ? l2.getColumnCount() : 1
- );
- if (u = u, c = c, l2 = l2, f2 === 1 && h === 1)
- return this._calculateSingleCell(e, u, c, l2);
- {
- const d2 = O(f2, h, u, g2.create(m2.NA)), _ = O(f2, h, c, g2.create(m2.NA)), C = O(f2, h, l2, g2.create(m2.NA));
- return d2.map((E2, b, R) => {
- const p2 = _.get(b, R) || ie.create(), N2 = C.get(b, R) || ie.create(), M2 = this._calculateSingleCell(e, E2, p2, N2);
- return M2.isReferenceObject() ? M2.toArrayValueObject().getFirstCell() : M2;
- });
- }
- }
- _calculateSingleCell(e, t, r, n) {
- if (t.isError())
- return t;
- const s = this._getNumberValue(t);
- if (s === void 0 || s < 0)
- return g2.create(m2.VALUE);
- if (r.isError())
- return r;
- const o = this._getNumberValue(r);
- if (o === void 0 || o < 0)
- return g2.create(m2.VALUE);
- if (n.isError())
- return n;
- const u = this._getAreaNumberValue(n);
- return u === void 0 || u < 1 ? g2.create(m2.VALUE) : e.isReferenceObject() ? this._getReferenceObject(e, s, o, u) : e.isValueObject() && s === 1 && o === 1 ? e : g2.create(m2.REF);
- }
- _getNumberValue(e) {
- if (e == null)
- return 0;
- let t = 0;
- if (e.isBoolean())
- e.getValue() === true && (t = 1);
- else {
- if (e.isString())
- return;
- e.isNumber() ? t = Math.floor(e.getValue()) : e.isNull() && (t = 0);
- }
- return t;
- }
- _getAreaNumberValue(e) {
- if (e == null)
- return 1;
- let t = 0;
- if (e.isBoolean())
- e.getValue() === true && (t = 1);
- else {
- if (e.isString())
- return;
- e.isNumber() ? t = Math.floor(e.getValue()) : e.isNull() && (t = 0);
- }
- return t;
- }
- _getReferenceObject(e, t, r, n) {
- const { startRow: s, endRow: o, startColumn: u, endColumn: c } = e.getRangePosition();
- let l2 = 0, f2 = 0, h = 0, d2 = 0;
- if (t === 0 ? (l2 = s, f2 = o) : l2 = f2 = s + t - 1, r === 0 ? (h = u, d2 = c) : h = d2 = u + r - 1, l2 > o || h > c)
- return g2.create(m2.REF);
- const _ = {
- startRow: l2,
- startColumn: h,
- endRow: f2,
- endColumn: d2
- };
- return this.createReferenceObject(e, _);
- }
- };
- var Td = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- isAddress() {
- return true;
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t != null && t.isError())
- return t;
- let r = this.getZeroOrOneByOneDefault(t);
- r == null && (r = 1);
- let n = e;
- if (e.isArray()) {
- const s = e.getRowCount(), o = e.getColumnCount();
- if (s > 1 || o > 1)
- return e.map(() => g2.create(m2.VALUE));
- n = e.getFirstCell();
- }
- return this._handleSingleObject(n, r);
- }
- _handleSingleObject(e, t) {
- const r = `${e.getValue()}`;
- if (r.trim() === "")
- return g2.create(m2.REF);
- const n = this._convertToDefinedName(r);
- if (t === 0) {
- const f2 = Ih(n), { range: h, sheetName: d2, unitId: _ } = f2, C = new Cn(h);
- return C.setForcedUnitIdDirect(_), C.setForcedSheetName(d2), this._setDefault(C);
- }
- if (vr(n))
- return this._setDefault(new da(n));
- if (Hi(n))
- return this._setDefault(new _a(n));
- if (Gi(n))
- return this._setDefault(new Ca(n));
- const s = mr(n), { range: o, sheetName: u, unitId: c } = s;
- if (Number.isNaN(o.startRow) || o.endRow + 1 > 1048576 || Number.isNaN(o.startColumn) || o.endColumn + 1 > 16384)
- return g2.create(m2.REF);
- const l2 = new Cn(o);
- return l2.setForcedUnitIdDirect(c), l2.setForcedSheetName(u), this._setDefault(l2);
- }
- _setDefault(e) {
- return this.unitId == null || this.subUnitId == null ? g2.create(m2.REF) : (e.setDefaultUnitId(this.unitId), e.setDefaultSheetId(this.subUnitId), e);
- }
- /**
- * In Excel, to inject a defined name into a function that has positioning capabilities,
- * such as using the INDIRECT function to reference a named range,
- * you can write it as follows:
- * =INDIRECT("DefinedName1")
- */
- _convertToDefinedName(e) {
- const t = this.getDefinedName(e);
- if (t == null)
- return e;
- const r = t.formulaOrRefString;
- return r == null ? e : r.startsWith(X2.EQUALS) ? r.slice(1) : r;
- }
- };
- var Bd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsExpandParams", true);
- }
- calculate(e, t, r) {
- return e.isError() ? e : t.isError() ? g2.create(m2.REF) : t.isArray() ? r != null && r.isError() ? r : t.getColumnCount() === 1 || t.getRowCount() === 1 ? r != null && !r.isArray() ? g2.create(m2.REF) : this._handleVector(e, t, r) : this._handleArray(e, t) : g2.create(m2.VALUE);
- }
- _handleVector(e, t, r) {
- let n = r;
- if (n == null)
- n = t;
- else if (n.getRowCount() !== t.getRowCount() || n.getColumnCount() !== t.getColumnCount())
- return g2.create(m2.REF);
- return e.isArray() ? e.map((s) => this.binarySearch(s, t, n)) : this.binarySearch(e, t, n);
- }
- _handleArray(e, t) {
- const r = t.getRowCount(), n = t.getColumnCount();
- let s, o;
- return n > r ? (s = t.slice([0, 1]), o = t.slice([r - 1, r])) : (s = t.slice(void 0, [0, 1]), o = t.slice(void 0, [n - 1, n])), s == null || o == null ? g2.create(m2.VALUE) : e.isArray() ? e.map((u) => this.binarySearch(u, s, o)) : this.binarySearch(e, s, o);
- }
- };
- var Id = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isError())
- return e;
- if (t.isError())
- return g2.create(m2.REF);
- if (!t.isArray())
- return g2.create(m2.VALUE);
- const n = t.getRowCount(), s = t.getColumnCount();
- if (n !== 1 && s !== 1 || r != null && r.isError())
- return g2.create(m2.NA);
- const o = this.getMatchTypeValue(r);
- return o == null ? g2.create(m2.VALUE) : e.isArray() ? e.map((u) => this._handleSingleObject(
- u,
- t,
- o
- )) : this._handleSingleObject(
- e,
- t,
- o
- );
- }
- _handleSingleObject(e, t, r) {
- const n = this._getSearchModeValue(r), s = t.orderSearch(e, n);
- if (s == null)
- return g2.create(m2.NA);
- if (s instanceof g2)
- return s;
- const o = t.getRowCount() === 1 ? s.column + 1 : s.row + 1;
- return y2.create(o);
- }
- _getSearchModeValue(e) {
- switch (e) {
- case 1:
- return Pe.MIN;
- case 0:
- return Pe.NORMAL;
- case -1:
- return Pe.MAX;
- }
- }
- };
- var Fd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- A(this, "needsReferenceObject", true);
- }
- isAddress() {
- return true;
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- calculate(e, t, r, n, s) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- if (n != null && n.isError())
- return n;
- if (s != null && s.isError())
- return s;
- if (!e.isReferenceObject())
- return g2.create(m2.VALUE);
- const o = e.getRowCount(), u = e.getColumnCount();
- let c = t;
- c.isReferenceObject() && (c = c.toArrayValueObject());
- let l2 = r;
- l2.isReferenceObject() && (l2 = l2.toArrayValueObject());
- let f2 = n != null ? n : y2.create(o);
- f2.isReferenceObject() && (f2 = f2.toArrayValueObject()), f2.isNull() && (f2 = y2.create(o));
- let h = s != null ? s : y2.create(u);
- h.isReferenceObject() && (h = h.toArrayValueObject()), h.isNull() && (h = y2.create(u));
- const d2 = Math.max(
- c.isArray() ? c.getRowCount() : 1,
- l2.isArray() ? l2.getRowCount() : 1,
- f2.isArray() ? f2.getRowCount() : 1,
- h.isArray() ? h.getRowCount() : 1
- ), _ = Math.max(
- c.isArray() ? c.getColumnCount() : 1,
- l2.isArray() ? l2.getColumnCount() : 1,
- f2.isArray() ? f2.getColumnCount() : 1,
- h.isArray() ? h.getColumnCount() : 1
- );
- if (c = c, l2 = l2, f2 = f2, h = h, d2 === 1 && _ === 1)
- return c = c.isArray() ? c.get(0, 0) : c, l2 = l2.isArray() ? l2.get(0, 0) : l2, f2 = f2.isArray() ? f2.get(0, 0) : f2, h = h.isArray() ? h.get(0, 0) : h, this._handleSingleObject(e, c, l2, f2, h);
- const C = O(d2, _, c, g2.create(m2.NA)), E2 = O(d2, _, l2, g2.create(m2.NA)), b = O(d2, _, f2, g2.create(m2.NA)), R = O(d2, _, h, g2.create(m2.NA));
- return C.mapValue((p2, N2, M2) => {
- const w = E2.get(N2, M2), D2 = b.get(N2, M2), S2 = R.get(N2, M2);
- return p2.isError() ? p2 : w.isError() ? w : D2.isError() ? D2 : S2.isError() ? S2 : this._handleSingleObject(e, p2, w, D2, S2, true);
- });
- }
- // eslint-disable-next-line
- _handleSingleObject(e, t, r, n, s, o = false) {
- const { startRow: u, startColumn: c } = e.getRangePosition();
- let l2 = t;
- if (l2.isString() && (l2 = l2.convertToNumberObjectValue()), l2.isError())
- return l2;
- let f2 = r;
- if (f2.isString() && (f2 = f2.convertToNumberObjectValue()), f2.isError())
- return f2;
- const h = +l2.getValue(), d2 = +f2.getValue();
- if (typeof h != "number" || typeof d2 != "number")
- return g2.create(m2.VALUE);
- const _ = u + h, C = c + d2;
- if (_ < 0 || C < 0)
- return g2.create(m2.REF);
- const E2 = this.getIndexNumValue(n), b = this.getIndexNumValue(s);
- if (typeof E2 != "number" || typeof b != "number")
- return g2.create(m2.VALUE);
- if (E2 === 0 || b === 0)
- return g2.create(m2.REF);
- const R = E2 > 0 ? _ + E2 - 1 : _ + E2 + 1, p2 = b > 0 ? C + b - 1 : C + b + 1;
- if (R < 0 || p2 < 0)
- return g2.create(m2.REF);
- if (o)
- return g2.create(m2.VALUE);
- const N2 = _ < R ? _ : R, M2 = C < p2 ? C : p2, w = _ > R ? _ : R, D2 = C > p2 ? C : p2, S2 = {
- startRow: N2,
- startColumn: M2,
- endRow: w,
- endColumn: D2
- };
- return this.createReferenceObject(e, S2);
- }
- };
- var kd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e == null)
- return y2.create(this.row + 1);
- if (e.isError())
- return e;
- if (!e.isArray())
- return g2.create(m2.NA);
- const t = e.getCurrentRow(), r = e.getRowCount(), n = [];
- for (let o = 0; o < r; o++)
- n.push([y2.create(t + o + 1)]);
- const s = {
- calculateValueList: n,
- rowCount: r,
- columnCount: 1,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q2.create(s);
- }
- };
- var $d = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isError())
- return e;
- if (e.isString() || e.isNumber() || e.isBoolean())
- return y2.create(1);
- if (!e.isArray())
- return g2.create(m2.NA);
- const t = e.getRowCount();
- return y2.create(t);
- }
- };
- var Yd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = t != null ? t : y2.create(1), o = r != null ? r : y2.create(1), u = n != null ? n : T2.create(false);
- if (u.isArray()) {
- const c = u.getRowCount(), l2 = u.getColumnCount();
- if (c === 1 && l2 === 1) {
- const f2 = u.get(0, 0);
- return this._handleSingleObject(e, s, o, f2);
- }
- return u.map((f2) => {
- const h = this._handleSingleObject(e, s, o, f2);
- return h.isArray() ? h.get(0, 0) : h;
- });
- }
- return this._handleSingleObject(e, s, o, u);
- }
- _handleSingleObject(e, t, r, n) {
- if (e.isError())
- return e;
- const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = this._checkArrayError(t);
- if (u.isError())
- return u;
- const c = Math.floor(+u.getValue());
- if (c < 1)
- return g2.create(m2.VALUE);
- const l2 = this._checkArrayError(r);
- if (l2.isError())
- return l2;
- const f2 = Math.floor(+l2.getValue());
- if (f2 !== -1 && f2 !== 1)
- return g2.create(m2.VALUE);
- let h = n;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- if (!e.isArray() || s === 1 && o === 1)
- return e;
- const d2 = +h.getValue();
- return this._getResult(e, c, f2, d2, s, o);
- }
- _checkArrayError(e) {
- let t = e;
- if (t.isArray()) {
- const r = t.getRowCount(), n = t.getColumnCount();
- if (r > 1 || n > 1)
- return g2.create(m2.VALUE);
- t = t.get(0, 0);
- }
- return t.isString() && (t = t.convertToNumberObjectValue()), t;
- }
- _getResult(e, t, r, n, s, o) {
- if (n) {
- if (t > s)
- return g2.create(m2.VALUE);
- const u = e.transpose().getArrayValue();
- return u.sort(this._sort(t - 1, r)), q2.create({
- calculateValueList: u,
- rowCount: u.length,
- columnCount: u[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- }).transpose();
- } else {
- if (t > o)
- return g2.create(m2.VALUE);
- const u = e.getArrayValue();
- return u.sort(this._sort(t - 1, r)), q2.create({
- calculateValueList: u,
- rowCount: u.length,
- columnCount: u[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- _sort(e, t = 1) {
- const r = hn();
- return t === 1 ? this._sortAsc(e, r) : this._sortDesc(e, r);
- }
- _sortAsc(e, t) {
- return (r, n) => {
- const s = r[e], o = n[e];
- if (s == null || s.isNull())
- return 1;
- if (o == null || o.isNull())
- return -1;
- if (s.isError() && o.isError())
- return 0;
- if (s.isError())
- return 1;
- if (o.isError())
- return -1;
- const u = s.getValue(), c = o.getValue();
- return s.isBoolean() && u === true ? 1 : o.isBoolean() && c === true ? -1 : s.isBoolean() && u === false ? 1 : o.isBoolean() && c === false ? -1 : s.isNumber() && o.isNumber() ? +u - +c : t(
- u,
- c
- );
- };
- }
- _sortDesc(e, t) {
- return (r, n) => {
- const s = r[e], o = n[e];
- if (s == null || s.isNull())
- return 1;
- if (o == null || o.isNull())
- return -1;
- if (s.isError() && o.isError())
- return 0;
- if (s.isError())
- return -1;
- if (o.isError())
- return 1;
- const u = s.getValue(), c = o.getValue();
- return s.isBoolean() && u === true ? -1 : o.isBoolean() && c === true ? 1 : s.isBoolean() && u === false ? -1 : o.isBoolean() && c === false ? 1 : s.isNumber() && o.isNumber() ? +c - +u : t(
- c,
- u
- );
- };
- }
- };
- var Hd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- t.length === 1 && t.push(y2.create(1));
- const r = this._getVariantsError(e, ...t), { maxRowLength: n, maxColumnLength: s } = Nr(t);
- if (r.isError()) {
- const c = O(n, s, r);
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- const o = t.map((c, l2) => l2 % 2 === 0 ? c : O(n, s, c, g2.create(m2.NA))), u = this._getResultArray(e, o, n, s);
- return n === 1 && s === 1 ? u[0][0] : q2.create({
- calculateValueList: u,
- rowCount: u.length,
- columnCount: u[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- // eslint-disable-next-line complexity
- _getVariantsError(e, ...t) {
- if (e.isError())
- return e;
- for (let u = 0; u < t.length; u++) {
- const c = t[u];
- if (c.isError())
- return c;
- }
- if (t.length < 2 || t.length % 2 !== 0)
- return g2.create(m2.VALUE);
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t[0].isArray() ? t[0].getRowCount() : 1, o = t[0].isArray() ? t[0].getColumnCount() : 1;
- if ((s > 1 || o > 1) && (s > 1 && o > 1 || s === 1 && o !== n || o === 1 && s !== r))
- return g2.create(m2.VALUE);
- for (let u = 2; u < t.length; u++) {
- if (u % 2 === 1)
- continue;
- const c = t[u].isArray() ? t[u].getRowCount() : 1, l2 = t[u].isArray() ? t[u].getColumnCount() : 1;
- if (c !== s || l2 !== o)
- return g2.create(m2.VALUE);
- }
- return T2.create(true);
- }
- _getResultArray(e, t, r, n) {
- const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = t[0].isArray() ? t[0].getRowCount() : 1, c = t[0].isArray() ? t[0].getColumnCount() : 1, l2 = [];
- for (let f2 = 0; f2 < r; f2++) {
- l2[f2] = [];
- for (let h = 0; h < n; h++) {
- const { isError: d2, errorObject: _, byArrays: C, sortOrders: E2 } = this._getByArraysAndSortOrders(t, f2, h, c);
- if (d2) {
- l2[f2].push(_);
- continue;
- }
- if (!e.isArray() || s === 1 && o === 1) {
- l2[f2].push(e);
- continue;
- }
- let b = e.getArrayValue();
- u === 1 && c === 1 || (u === 1 ? (b = b.concat(C), b = this._transposeArray(b), b.sort(this._sort(s, E2)), b = this._transposeArray(b).slice(0, s)) : c === 1 && (b = this._transposeArray(b), b = b.concat(C), b = this._transposeArray(b), b.sort(this._sort(o, E2)), b = b.map((p2) => p2.slice(0, o))));
- const R = q2.create({
- calculateValueList: b,
- rowCount: b.length,
- columnCount: b[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- if (r > 1 || n > 1) {
- l2[f2].push(R.get(0, 0));
- continue;
- }
- l2[f2].push(R);
- }
- }
- return l2;
- }
- _getByArraysAndSortOrders(e, t, r, n) {
- const s = [], o = [];
- let u = false, c = null;
- for (let l2 = 0; l2 < e.length; l2++) {
- if (l2 % 2 === 1)
- continue;
- const f2 = e[l2];
- let h = e[l2 + 1].get(t, r);
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError()) {
- u = true, c = h;
- break;
- }
- const d2 = Math.floor(+h.getValue());
- if (d2 !== -1 && d2 !== 1) {
- u = true, c = g2.create(m2.VALUE);
- break;
- }
- if (o.push(d2), f2.isArray()) {
- let _ = f2.getArrayValue();
- n === 1 && (_ = this._transposeArray(_)), s.push(_[0]);
- } else
- s.push([f2]);
- }
- return {
- isError: u,
- errorObject: c,
- byArrays: s,
- sortOrders: o
- };
- }
- _transposeArray(e) {
- const t = e.length, r = e[0].length, n = [];
- for (let s = 0; s < r; s++) {
- n[s] = [];
- for (let o = 0; o < t; o++)
- n[s][o] = e[o][s];
- }
- return n;
- }
- _sort(e, t) {
- const r = hn();
- return (n, s) => {
- let o = n[e], u = s[e], c = this._compare(o, u, t[0], r);
- if (c === 0 && t.length > 1) {
- for (let l2 = 1; l2 < t.length; l2++)
- if (o = n[e + l2], u = s[e + l2], c = this._compare(o, u, t[l2], r), c !== 0)
- return c;
- }
- return c;
- };
- }
- _compare(e, t, r, n) {
- return r === 1 ? this._asc(e, t, n) : this._desc(e, t, n);
- }
- _asc(e, t, r) {
- if (e == null || e.isNull())
- return 1;
- if (t == null || t.isNull())
- return -1;
- if (e.isError() && t.isError())
- return 0;
- if (e.isError())
- return 1;
- if (t.isError())
- return -1;
- const n = e.getValue(), s = t.getValue();
- return e.isBoolean() && n === true ? 1 : t.isBoolean() && s === true ? -1 : e.isBoolean() && n === false ? 1 : t.isBoolean() && s === false ? -1 : e.isNumber() && t.isNumber() ? +n - +s : r(
- n,
- s
- );
- }
- _desc(e, t, r) {
- if (e == null || e.isNull())
- return 1;
- if (t == null || t.isNull())
- return -1;
- if (e.isError() && t.isError())
- return 0;
- if (e.isError())
- return -1;
- if (t.isError())
- return 1;
- const n = e.getValue(), s = t.getValue();
- return e.isBoolean() && n === true ? -1 : t.isBoolean() && s === true ? 1 : e.isBoolean() && n === false ? -1 : t.isBoolean() && s === false ? 1 : e.isNumber() && t.isNumber() ? +s - +n : r(
- s,
- n
- );
- }
- };
- var Gd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
- let o = t, u = r != null ? r : y2.create(s);
- t.isNull() && (o = y2.create(n)), u.isNull() && (u = y2.create(s));
- const c = Math.max(
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l2 = Math.max(
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f2 = O(c, l2, o, g2.create(m2.NA)), h = O(c, l2, u, g2.create(m2.NA));
- if (c > 1 || l2 > 1)
- return f2.mapValue((p2, N2, M2) => {
- const w = h.get(N2, M2);
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- const { isError: D2, errorObject: S2 } = this._checkRowsColumns(p2, w, n, s);
- return D2 ? S2 : e.isArray() ? g2.create(m2.VALUE) : e;
- });
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- const d2 = o.isArray() ? o.get(0, 0) : o, _ = u.isArray() ? u.get(0, 0) : u, { isError: C, errorObject: E2, rowsValue: b, columnsValue: R } = this._checkRowsColumns(d2, _, n, s);
- return C ? E2 : this._getResultArray(e, b, R, n, s);
- }
- _checkRowsColumns(e, t, r, n) {
- if (e.isError())
- return {
- isError: true,
- errorObject: e
- };
- if (t.isError())
- return {
- isError: true,
- errorObject: t
- };
- let s = Math.trunc(+e.getValue()), o = Math.trunc(+t.getValue());
- return Number.isNaN(s) || Number.isNaN(o) ? {
- isError: true,
- errorObject: g2.create(m2.VALUE)
- } : Math.abs(s) === 0 || Math.abs(o) === 0 ? {
- isError: true,
- errorObject: g2.create(m2.CALC)
- } : (s > r && (s = r), o > n && (o = n), {
- isError: false,
- rowsValue: s,
- columnsValue: o
- });
- }
- _getResultArray(e, t, r, n, s) {
- if (!e.isArray())
- return e;
- const o = t >= 0 ? [0, t] : [n + t, n], u = r >= 0 ? [0, r] : [s + r, s];
- let c;
- return t === n && r === s ? c = e : t === n ? c = e.slice(void 0, u) : r === s ? c = e.slice(o, void 0) : c = e.slice(o, u), c = c.map((l2) => l2.isNull() ? y2.create(0) : l2), t === 1 && r === 1 ? c.get(0, 0) : c;
- }
- };
- var Qd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : y2.create(0), s = r != null ? r : T2.create(false), o = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, n, g2.create(m2.NA)), l2 = O(o, u, s, g2.create(m2.NA)), f2 = c.mapValue((h, d2, _) => {
- const C = l2.get(d2, _);
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- if (h.isError())
- return h;
- if (C.isError())
- return C;
- const E2 = Math.trunc(+h.getValue()), b = +C.getValue();
- if (Number.isNaN(E2) || E2 < 0 || E2 > 3 || Number.isNaN(b))
- return g2.create(m2.VALUE);
- if (!e.isArray())
- return e;
- let R = [];
- return b ? R = this._getArrayValueByColumn(e, E2) : R = this._getArrayValueByRow(e, E2), R.length === 0 ? g2.create(m2.CALC) : o > 1 || u > 1 || R.length === 1 ? R[0] : q2.create({
- calculateValueList: R.map((p2) => [p2]),
- rowCount: R.length,
- columnCount: 1,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- });
- return o === 1 && u === 1 ? f2.get(0, 0) : f2;
- }
- _getArrayValueByColumn(e, t) {
- const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
- for (let u = 0; u < s; u++)
- for (let c = 0; c < n; c++) {
- const l2 = r.get(c, u);
- this._isIgnore(l2, t) || o.push(l2.isNull() ? y2.create(0) : l2);
- }
- return o;
- }
- _getArrayValueByRow(e, t) {
- const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
- for (let u = 0; u < n; u++)
- for (let c = 0; c < s; c++) {
- const l2 = r.get(u, c);
- this._isIgnore(l2, t) || o.push(l2.isNull() ? y2.create(0) : l2);
- }
- return o;
- }
- _isIgnore(e, t) {
- switch (t) {
- case 0:
- return false;
- case 1:
- return e.isNull();
- case 2:
- return e.isError();
- case 3:
- return e.isNull() || e.isError();
- default:
- return false;
- }
- }
- };
- var Wd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : y2.create(0), s = r != null ? r : T2.create(false), o = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, n, g2.create(m2.NA)), l2 = O(o, u, s, g2.create(m2.NA)), f2 = c.mapValue((h, d2, _) => {
- const C = l2.get(d2, _);
- if (e.isError())
- return e;
- if (h.isError())
- return h;
- if (C.isError())
- return C;
- const E2 = Math.trunc(+h.getValue()), b = +C.getValue();
- if (Number.isNaN(E2) || E2 < 0 || E2 > 3 || Number.isNaN(b) || e.isNull())
- return g2.create(m2.VALUE);
- if (!e.isArray())
- return e;
- let R = [];
- return b ? R = this._getArrayValueByColumn(e, E2) : R = this._getArrayValueByRow(e, E2), R.length === 0 ? g2.create(m2.CALC) : o > 1 || u > 1 || R.length === 1 ? R[0] : q2.create({
- calculateValueList: [R],
- rowCount: 1,
- columnCount: R.length,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- });
- return o === 1 && u === 1 ? f2.get(0, 0) : f2;
- }
- _getArrayValueByColumn(e, t) {
- const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
- for (let u = 0; u < s; u++)
- for (let c = 0; c < n; c++) {
- const l2 = r.get(c, u);
- this._isIgnore(l2, t) || o.push(l2.isNull() ? y2.create(0) : l2);
- }
- return o;
- }
- _getArrayValueByRow(e, t) {
- const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
- for (let u = 0; u < n; u++)
- for (let c = 0; c < s; c++) {
- const l2 = r.get(u, c);
- this._isIgnore(l2, t) || o.push(l2.isNull() ? y2.create(0) : l2);
- }
- return o;
- }
- _isIgnore(e, t) {
- switch (t) {
- case 0:
- return false;
- case 1:
- return e.isNull();
- case 2:
- return e.isError();
- case 3:
- return e.isNull() || e.isError();
- default:
- return false;
- }
- }
- };
- var qd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isError())
- return e;
- if (e.isArray()) {
- const t = e.getRowCount(), r = e.getColumnCount();
- return t === 1 && r === 1 ? e.get(0, 0) : e.transpose();
- }
- return e;
- }
- };
- var Kd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : T2.create(false), s = r != null ? r : T2.create(false), o = e.isArray() ? e.getRowCount() : 1, u = e.isArray() ? e.getColumnCount() : 1, c = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), l2 = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), f2 = O(c, l2, n, g2.create(m2.NA)), h = O(c, l2, s, g2.create(m2.NA)), d2 = f2.map((_, C, E2) => {
- let b = _, R = h.get(C, E2);
- if (e.isError())
- return e;
- if (b.isString() && (b = b.convertToNumberObjectValue()), b.isError())
- return b;
- if (R.isString() && (R = R.convertToNumberObjectValue()), R.isError())
- return R;
- const p2 = +b.getValue(), N2 = +R.getValue();
- let M2;
- return !p2 && o === 1 || p2 && u === 1 ? M2 = e : M2 = this._getResult(e, p2, N2), (c > 1 || l2 > 1) && (M2 != null && M2.isArray()) ? M2.get(0, 0) : M2;
- });
- return c === 1 && l2 === 1 ? d2.get(0, 0) : d2;
- }
- _getResult(e, t, r) {
- const n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
- let o = e.getArrayValue(), u = n, c = s;
- t && (o = this._transposeArray(o), u = s, c = n);
- const l2 = this._getRepeatRows(o, u, c);
- if (l2.length > 0) {
- const f2 = [];
- l2.forEach((h) => {
- h.forEach((d2, _) => {
- (_ !== 0 || r) && f2.push(d2);
- });
- }), o = o.filter((h, d2) => !f2.includes(d2));
- }
- return o.length === 0 ? g2.create(m2.CALC) : (t && (o = this._transposeArray(o)), q2.create({
- calculateValueList: o,
- rowCount: o.length,
- columnCount: o[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- }));
- }
- _getRepeatRows(e, t, r) {
- let n = [];
- for (let s = 0; s < r; s++)
- if (s === 0) {
- const o = new Array(t).fill(null).map((u, c) => ({
- r: c,
- valueObject: e[c][s]
- }));
- n = this._getRepeatRowsByObjects(o);
- } else {
- if (n.length === 0)
- break;
- let o = [];
- n.forEach((u) => {
- const c = u.map((f2) => ({
- r: f2,
- valueObject: e[f2][s]
- })), l2 = this._getRepeatRowsByObjects(c);
- o = o.concat(l2);
- }), n = o;
- }
- return n;
- }
- _getRepeatRowsByObjects(e) {
- const t = /* @__PURE__ */ new Map();
- return e.forEach((r) => {
- const n = r.r, s = r.valueObject;
- let o = s.getValue();
- if (s.isNull() ? o = null : s.isString() && DC(o) && (o = +o), !t.has(o))
- t.set(o, [n]);
- else {
- const u = t.get(o);
- u.push(n), t.set(o, u);
- }
- }), Array.from(t.values()).filter((r) => r.length > 1);
- }
- _transposeArray(e) {
- const t = e.length, r = e[0].length, n = [];
- for (let s = 0; s < r; s++) {
- n[s] = [];
- for (let o = 0; o < t; o++)
- n[s][o] = e[o][s];
- }
- return n;
- }
- };
- var Xd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (!t.isArray())
- return g2.create(m2.VALUE);
- if (r.isError())
- return r;
- if (n != null && n.isError())
- return n;
- const s = n != null ? n : T2.create(true);
- return Ai(e) && Ai(s) && r.isArray() ? this._handleArrayColIndexNum(e, t, r, s) : this._handleNonArrayColIndexNum(e, t, r, s);
- }
- _handleArrayColIndexNum(e, t, r, n) {
- const s = e.isArray() ? e.getFirstCell() : e, o = this.getZeroOrOneByOneDefault(n);
- if (o == null)
- return g2.create(m2.VALUE);
- let u;
- const c = [];
- return r.iterator((l2, f2, h) => {
- if (l2 == null)
- return u = g2.create(m2.VALUE), false;
- const d2 = this._handleTableArray(s, t, l2, o);
- if (d2.isError())
- return u = d2, false;
- c[f2] === void 0 && (c[f2] = []), c[f2][h] = d2;
- }), u || tr(c, c.length, c[0].length, this.unitId || "", this.subUnitId || "");
- }
- _handleNonArrayColIndexNum(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e), c = O(s, o, n);
- return u.map((l2, f2, h) => {
- if (l2.isError())
- return l2;
- const d2 = c.get(f2, h);
- if (d2 == null)
- return g2.create(m2.VALUE);
- if (d2.isError())
- return d2;
- const _ = this.getZeroOrOneByOneDefault(d2);
- return _ == null ? g2.create(m2.VALUE) : this._handleTableArray(l2, t, r, _);
- });
- }
- _handleTableArray(e, t, r, n) {
- let s = this.getIndexNumValue(r);
- if (s instanceof g2)
- return s;
- if (s = Math.floor(s), s < 1)
- return g2.create(m2.VALUE);
- const o = t.slice(void 0, [0, 1]);
- if (o == null)
- return g2.create(m2.VALUE);
- const u = t.slice(void 0, [s - 1, s]);
- return u == null ? g2.create(m2.REF) : this._handleSingleObject(e, o, u, n);
- }
- _handleSingleObject(e, t, r, n) {
- return n === 0 ? this.equalSearch(e, t, r) : this.binarySearch(e, t, r);
- }
- };
- var Zd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = Math.max(
- ...e.map((n) => n.isArray() ? n.getColumnCount() : 1)
- ), r = [];
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (s.isError())
- return s;
- const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
- for (let c = 0; c < o; c++) {
- const l2 = [];
- for (let f2 = 0; f2 < t; f2++) {
- let h = s;
- s.isArray() && (h = s.get(c, f2)), f2 > u - 1 || !h ? l2.push(g2.create(m2.NA)) : l2.push(h);
- }
- r.push(l2);
- }
- }
- return q2.create({
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- };
- var zd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = r != null ? r : g2.create(m2.NA);
- n.isNull() && (n = g2.create(m2.NA));
- const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), c = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), l2 = O(u, c, t, g2.create(m2.NA)), f2 = O(u, c, n, g2.create(m2.NA)), h = l2.mapValue((d2, _, C) => {
- const E2 = f2.get(_, C);
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- if (d2.isError())
- return d2;
- const b = Math.trunc(+d2.getValue());
- if (s > 1 && o > 1 || Number.isNaN(b))
- return g2.create(m2.VALUE);
- if (b < 1)
- return g2.create(m2.NUM);
- const R = e.isArray() ? e.getArrayValue().flat() : [e], p2 = this._getWrapArray(R, b, E2);
- return u > 1 || c > 1 || p2.length === 1 && p2[0].length === 1 ? p2[0][0] : q2.create({
- calculateValueList: p2,
- rowCount: p2.length,
- columnCount: p2[0].length,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- });
- return u === 1 && c === 1 ? h.get(0, 0) : h;
- }
- _getWrapArray(e, t, r) {
- const n = Math.ceil(e.length / t), s = n > 1 ? t : e.length, o = [];
- for (let u = 0; u < n; u++)
- for (let c = 0; c < s; c++) {
- o[c] || (o[c] = []);
- const l2 = u * s + c;
- l2 < e.length ? o[c].push(e[l2].isNull() ? y2.create(0) : e[l2]) : o[c].push(r);
- }
- return o;
- }
- };
- var Jd = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = r != null ? r : g2.create(m2.NA);
- n.isNull() && (n = g2.create(m2.NA));
- const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), c = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), l2 = O(u, c, t, g2.create(m2.NA)), f2 = O(u, c, n, g2.create(m2.NA)), h = l2.mapValue((d2, _, C) => {
- const E2 = f2.get(_, C);
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- if (d2.isError())
- return d2;
- const b = Math.trunc(+d2.getValue());
- if (s > 1 && o > 1 || Number.isNaN(b))
- return g2.create(m2.VALUE);
- if (b < 1)
- return g2.create(m2.NUM);
- const R = e.isArray() ? e.getArrayValue().flat() : [e], p2 = this._getWrapArray(R, b, E2);
- return u > 1 || c > 1 || p2.length === 1 && p2[0].length === 1 ? p2[0][0] : q2.create({
- calculateValueList: p2,
- rowCount: p2.length,
- columnCount: p2[0].length,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- });
- return u === 1 && c === 1 ? h.get(0, 0) : h;
- }
- _getWrapArray(e, t, r) {
- const n = Math.ceil(e.length / t), s = n > 1 ? t : e.length, o = [];
- for (let u = 0; u < n; u++) {
- const c = [];
- for (let l2 = 0; l2 < s; l2++) {
- const f2 = u * s + l2;
- f2 < e.length ? c.push(e[f2].isNull() ? y2.create(0) : e[f2]) : c.push(r);
- }
- o.push(c);
- }
- return o;
- }
- };
- var eC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 6);
- }
- // eslint-disable-next-line
- calculate(e, t, r, n, s, o) {
- let u = n != null ? n : g2.create(m2.NA);
- n != null && n.isNull() && (u = g2.create(m2.NA));
- let c = s != null ? s : y2.create(0);
- s != null && s.isNull() && (c = y2.create(0));
- let l2 = o != null ? o : y2.create(1);
- if (o != null && o.isNull() && (l2 = y2.create(1)), e.isError())
- return e;
- if (t.isError() || r.isError())
- return g2.create(m2.REF);
- if (!t.isArray() || !r.isArray())
- return g2.create(m2.VALUE);
- const f2 = t.getRowCount(), h = t.getColumnCount(), d2 = r.getRowCount(), _ = r.getColumnCount();
- if (f2 !== 1 && h !== 1 || f2 === 1 && h > 1 && h !== _ || h === 1 && f2 > 1 && f2 !== d2)
- return g2.create(m2.VALUE);
- if (c.isError())
- return c;
- if (l2.isError())
- return l2;
- const C = this.getIndexNumValue(c);
- if (C instanceof g2)
- return C;
- const E2 = this.getIndexNumValue(l2);
- return E2 instanceof g2 ? E2 : this._getResult(
- e,
- t,
- r,
- u,
- C,
- E2,
- f2,
- h,
- d2,
- _
- );
- }
- _getResult(e, t, r, n, s, o, u, c, l2, f2) {
- const h = e.isArray() ? e.getRowCount() : 1, d2 = e.isArray() ? e.getColumnCount() : 1;
- if (h > 1 || d2 > 1) {
- let b;
- return u === 1 ? b = r.slice([0, 1]) : b = r.slice(void 0, [0, 1]), b == null ? g2.create(m2.NA) : e.map((R) => {
- const p2 = this._checkErrorCombination(s, o);
- if (p2)
- return p2;
- const N2 = this._handleSingleObject(R, t, b, s, o);
- return N2.isError() ? n : N2;
- });
- }
- const _ = e.isArray() ? e.get(0, 0) : e;
- if (c === f2 && u === l2) {
- const b = this._checkErrorCombination(s, o);
- if (b)
- return b;
- const R = this._handleSingleObject(_, t, r, s, o);
- return R.isError() ? n : R;
- }
- let C = 0;
- c === f2 && (C = 1);
- const E2 = this._handleExpandObject(_, t, r, s, o, C);
- return E2 == null ? g2.create(m2.NA) : E2;
- }
- _handleExpandObject(e, t, r, n, s, o = 0) {
- if ((s === 2 || s === -2) && n !== 2) {
- const u = Ps(s), c = Ss(n);
- return this.binarySearchExpand(
- e,
- t,
- r,
- o,
- u,
- c
- );
- }
- return n === 2 ? this.fuzzySearchExpand(e, t, r, s !== -1, o) : n === -1 || n === 1 ? this.orderSearchExpand(
- e,
- t,
- r,
- n === 1 ? Pe.MAX : Pe.MIN,
- s === -1,
- o
- ) : this.equalSearchExpand(e, t, r, s !== -1, o);
- }
- _handleSingleObject(e, t, r, n, s) {
- if ((s === 2 || s === -2) && n !== 2) {
- const o = Ps(s), u = Ss(n);
- return this.binarySearch(e, t, r, o, u);
- }
- return n === 2 ? this.fuzzySearch(e, t, r, s !== -1) : n === -1 || n === 1 ? this.orderSearch(
- e,
- t,
- r,
- n === 1 ? Pe.MAX : Pe.MIN,
- s === -1
- ) : this.equalSearch(e, t, r, s !== -1);
- }
- /**
- * Wildcard matching and binary search cannot appear at the same time
- * @param matchModeValue
- * @param searchModeValue
- * @returns
- */
- _checkErrorCombination(e, t) {
- return e === 2 && (t === -2 || t === 2) ? g2.create(m2.VALUE) : null;
- }
- };
- var tC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- if (e.isError())
- return e;
- if (t.isError())
- return g2.create(m2.REF);
- if (!t.isArray())
- return g2.create(m2.VALUE);
- const s = t.getRowCount(), o = t.getColumnCount();
- if (s !== 1 && o !== 1)
- return g2.create(m2.VALUE);
- if (r != null && r.isError() || n != null && n.isError())
- return g2.create(m2.NA);
- const u = this.getIndexNumValue(r || y2.create(0));
- if (u instanceof g2)
- return u;
- const c = this.getIndexNumValue(n || y2.create(1));
- return c instanceof g2 ? c : e.isArray() ? e.map((l2) => this._handleSingleObject(
- l2,
- t,
- u,
- c
- )) : this._handleSingleObject(
- e,
- t,
- u,
- c
- );
- }
- _handleSingleObject(e, t, r, n) {
- let s;
- if ((n === 2 || n === -2) && r !== 2) {
- const o = Ps(n), u = Ss(r);
- s = t.binarySearch(e, o, u);
- } else if (r === 2) {
- const o = t.compare(e, $.EQUALS);
- let u;
- if (n !== -1 ? u = o.getFirstTruePosition() : u = o.getLastTruePosition(), u == null)
- return g2.create(m2.NA);
- s = t.getRowCount() === 1 ? u.column : u.row;
- } else if (r === -1 || r === 1) {
- const o = t.orderSearch(e, r === 1 ? Pe.MAX : Pe.MIN, n === -1);
- if (o == null)
- return g2.create(m2.NA);
- if (o instanceof g2)
- return o;
- s = t.getRowCount() === 1 ? o.column : o.row;
- } else {
- const o = t.isEqual(e);
- let u;
- if (n !== -1 ? u = o.getFirstTruePosition() : u = o.getLastTruePosition(), u == null)
- return g2.create(m2.NA);
- s = t.getRowCount() === 1 ? u.column : u.row;
- }
- return s == null ? g2.create(m2.NA) : y2.create(s + 1);
- }
- };
- var rC = [
- [Rd, me2.ADDRESS],
- [Vd, me2.AREAS],
- [Nd, me2.CHOOSE],
- [Od, me2.CHOOSECOLS],
- [Md, me2.CHOOSEROWS],
- [wd, me2.COLUMN],
- [Dd, me2.COLUMNS],
- [Sd, me2.DROP],
- [Pd, me2.EXPAND],
- [Ld, me2.FILTER],
- [xd, me2.FORMULATEXT],
- [jd, me2.HLOOKUP],
- [Ud, me2.HSTACK],
- [vd, me2.INDEX],
- [Td, me2.INDIRECT],
- [Bd, me2.LOOKUP],
- [Id, me2.MATCH],
- [Fd, me2.OFFSET],
- [kd, me2.ROW],
- [$d, me2.ROWS],
- [Yd, me2.SORT],
- [Hd, me2.SORTBY],
- [Gd, me2.TAKE],
- [Qd, me2.TOCOL],
- [Wd, me2.TOROW],
- [qd, me2.TRANSPOSE],
- [Kd, me2.UNIQUE],
- [Xd, me2.VLOOKUP],
- [Zd, me2.VSTACK],
- [zd, me2.WRAPCOLS],
- [Jd, me2.WRAPROWS],
- [eC, me2.XLOOKUP],
- [tC, me2.XMATCH]
- ];
- var nC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.abs();
- }
- };
- var sC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.acos();
- }
- };
- var aC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.acosh();
- }
- };
- var iC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.isArray() ? t.map((r) => r.isError() ? r : Si(r)) : Si(t);
- }
- };
- function Si(i) {
- let a2 = i.getValue();
- if (i.isBoolean() && (a2 = a2 ? 1 : 0), !Number.isFinite(a2))
- return g2.create(m2.VALUE);
- a2 = Number(a2);
- let e = Math.atan(1 / a2);
- return a2 < 0 && (e += Math.PI), Number.isNaN(e) ? g2.create(m2.VALUE) : y2.create(e);
- }
- var oC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.isArray() ? t.map((r) => r.isError() ? r : Pi(r)) : Pi(t);
- }
- };
- function Pi(i) {
- let a2 = i.getValue();
- if (i.isBoolean() && (a2 = a2 ? 1 : 0), !Number.isFinite(a2))
- return g2.create(m2.VALUE);
- if (a2 = Number(a2), Math.abs(a2) <= 1)
- return g2.create(m2.NUM);
- const e = 1 / 2 * Math.log((a2 + 1) / (a2 - 1));
- return Number.isNaN(e) ? g2.create(m2.VALUE) : y2.create(e);
- }
- var uC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- // eslint-disable-next-line
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return y2.create(0);
- if (e.isBoolean() || e.isNumber())
- return g2.create(m2.VALUE);
- let t = e.getValue().toLocaleString().toLocaleUpperCase();
- if (t.length > 255)
- return g2.create(m2.VALUE);
- const r = t.startsWith("-");
- r && (t = t.slice(1));
- let n = 0;
- for (let s = 0; s < t.length; s++) {
- const o = Xr.get(t[s]) || 0, u = Xr.get(t[s + 1]) || 0, c = Xr.get(t[s + 2]) || 0, l2 = Xr.get(t[s + 3]) || 0;
- if (!o || c >= u && c > o || o === u && o === c && o === l2 || o === u / 2)
- return g2.create(m2.VALUE);
- o < u ? n -= o : n += o;
- }
- return y2.create(r ? -n : n);
- }
- };
- var cC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.asin();
- }
- };
- var lC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.asinh();
- }
- };
- var fC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.atan();
- }
- };
- var hC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e, n = t;
- return r.isString() && (r = r.convertToNumberObjectValue()), r.isError() ? r : (n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : n.atan2(r));
- }
- };
- var mC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.atanh();
- }
- };
- var gC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y2.create(0);
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (n.isError())
- return n;
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.map((h, d2, _) => {
- const C = c.get(d2, _), E2 = l2.get(d2, _);
- return this._handleSingleObject(h, C, E2);
- });
- return f2.getRowCount() === 1 && f2.getColumnCount() === 1 ? f2.getArrayValue()[0][0] : f2;
- }
- _handleSingleObject(e, t, r) {
- let n = e;
- if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- let s = t;
- if (s.isString() && (s = s.convertToNumberObjectValue()), s.isError())
- return s;
- let o = r;
- if (o.isString() && (o = o.convertToNumberObjectValue()), o.isError())
- return o;
- const u = Math.floor(+n.getValue()), c = Math.floor(+s.getValue()), l2 = Math.floor(+o.getValue());
- if (u < 0 || u >= 2 ** 53 || c < 2 || c > 36 || l2 < 0)
- return g2.create(m2.NUM);
- let f2 = u.toString(c);
- return f2.length < l2 && (f2 = new Array(l2 - f2.length + 1).join("0") + f2), j.create(f2.toLocaleUpperCase());
- }
- };
- var dC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
- let h = c, d2 = o.get(l2, f2);
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- const _ = +h.getValue(), C = +d2.getValue();
- if (_ > 0 && C < 0)
- return g2.create(m2.NUM);
- if (_ === 0 || C === 0)
- return y2.create(0);
- const E2 = Ye(_ / C, 0) * C;
- return y2.create(E2);
- });
- return u.getRowCount() === 1 && u.getColumnCount() === 1 ? u.getArrayValue()[0][0] : u;
- }
- };
- var CC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : y2.create(1), s = r != null ? r : y2.create(0);
- if (e.isError())
- return e;
- if (n.isError())
- return n;
- if (s.isError())
- return s;
- const o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, n, g2.create(m2.NA)), f2 = O(o, u, s, g2.create(m2.NA)), h = c.map((d2, _, C) => {
- let E2 = d2, b = l2.get(_, C), R = f2.get(_, C);
- if (E2.isString() && (E2 = E2.convertToNumberObjectValue()), E2.isError())
- return E2;
- if (b.isString() && (b = b.convertToNumberObjectValue()), b.isError())
- return b;
- if (R.isString() && (R = R.convertToNumberObjectValue()), R.isError())
- return R;
- const p2 = +E2.getValue(), N2 = +b.getValue(), M2 = +R.getValue();
- return p2 === 0 || N2 === 0 ? y2.create(0) : this._getResult(p2, N2, M2);
- });
- return o === 1 && u === 1 ? h.get(0, 0) : h;
- }
- _getResult(e, t, r) {
- let n;
- return e < 0 && r !== 0 ? n = (t < 0 ? Ye(Math.abs(e) / Math.abs(t), 0) : -Ye(Math.abs(e) / t, 0)) * t : n = (t < 0 ? -Ye(e / Math.abs(t), 0) : Ye(e / t, 0)) * t, y2.create(n);
- }
- };
- var _C = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(1);
- if (e.isError())
- return e;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.map((l2, f2, h) => {
- let d2 = u.get(f2, h), _ = l2;
- if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
- return _;
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- const C = +_.getValue(), E2 = +d2.getValue();
- if (C === 0 || E2 === 0)
- return y2.create(0);
- const b = (E2 < 0 ? -Ye(C / Math.abs(E2), 0) : Ye(C / E2, 0)) * E2;
- return y2.create(b);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- };
- var AC2 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- let h = c, d2 = o.get(l2, f2);
- if (h.isString() && (h = h.convertToNumberObjectValue()), d2.isString() && (d2 = d2.convertToNumberObjectValue()), h.isError())
- return h;
- if (d2.isError())
- return d2;
- const _ = Math.floor(+h.getValue()), C = Math.floor(+d2.getValue());
- if (_ < 0 || C < 0 || _ < C)
- return g2.create(m2.NUM);
- const E2 = zt(_, C);
- return Number.isNaN(E2) || !Number.isFinite(E2) ? g2.create(m2.NUM) : y2.create(E2);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var EC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- let h = c, d2 = o.get(l2, f2);
- if (h.isString() && (h = h.convertToNumberObjectValue()), d2.isString() && (d2 = d2.convertToNumberObjectValue()), h.isError())
- return h;
- if (d2.isError())
- return d2;
- const _ = Math.floor(+h.getValue()), C = Math.floor(+d2.getValue());
- if (_ < 0 || C < 0 || _ === 0 && _ < C)
- return g2.create(m2.NUM);
- const E2 = zt(_ + C - 1, _ - 1);
- return Number.isNaN(E2) || !Number.isFinite(E2) ? g2.create(m2.NUM) : y2.create(E2);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var bC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.cos();
- }
- };
- var yC2 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.cosh();
- }
- };
- var RC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- return Math.abs(r) >= 2 ** 27 ? g2.create(m2.NUM) : r === 0 ? g2.create(m2.DIV_BY_ZERO) : t.tan().getReciprocal();
- }
- };
- var pC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : +t.getValue() === 0 ? g2.create(m2.DIV_BY_ZERO) : t.tanh().getReciprocal();
- }
- };
- var VC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- return Math.abs(r) >= 2 ** 27 ? g2.create(m2.NUM) : r === 0 ? g2.create(m2.DIV_BY_ZERO) : t.sin().getReciprocal();
- }
- };
- var NC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- return r === 0 ? g2.create(m2.DIV_BY_ZERO) : !Number.isNaN(r) && !Number.isFinite(Math.sinh(r)) ? y2.create(0) : t.sinh().getReciprocal();
- }
- };
- var OC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
- if (c.isError())
- return c;
- let h = o.get(l2, f2);
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- const d2 = `${c.getValue()}`, _ = Math.floor(+h.getValue());
- if (DC(d2) && (+d2 < 0 || +d2 >= 2 ** 53 || !Number.isInteger(+d2)) || d2.toLocaleLowerCase() === "true" || d2.toLocaleLowerCase() === "false" || _ < 2 || _ > 36)
- return g2.create(m2.NUM);
- if (d2.replace(/\s/g, "") === "")
- return y2.create(0);
- if (!this._isValidCharForRadix(d2, _))
- return g2.create(m2.NUM);
- const C = Number.parseInt(d2, _);
- return Number.isNaN(C) ? g2.create(m2.NUM) : y2.create(C);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _isValidCharForRadix(e, t) {
- for (const r of e) {
- const n = r.toUpperCase().charCodeAt(0);
- if (t <= 10 && !(n >= 48 && n < 48 + t) || t > 10 && !(n >= 48 && n < 58 || n >= 65 && n < 65 + t - 10))
- return false;
- }
- return true;
- }
- };
- var MC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- if (!Number.isFinite(r))
- return g2.create(m2.VALUE);
- const n = r * (180 / Math.PI);
- return Number.isNaN(n) ? g2.create(m2.VALUE) : y2.create(n);
- }
- };
- var wC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- if (!Number.isFinite(r))
- return g2.create(m2.VALUE);
- const n = (r < 0 ? -Ye(Math.abs(r) / 2, 0) : Ye(r / 2, 0)) * 2;
- return Number.isNaN(n) ? g2.create(m2.VALUE) : n === 0 ? y2.create(0) : y2.create(n);
- }
- };
- var DC2 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.exp();
- }
- };
- var SC2 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = Math.floor(+t.getValue()), n = cr(r);
- return Number.isNaN(n) || !Number.isFinite(n) ? g2.create(m2.NUM) : y2.create(n);
- }
- };
- var PC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (e.isArray()) {
- const r = e.getRowCount(), n = e.getColumnCount();
- if (r > 1 || n > 1)
- return g2.create(m2.VALUE);
- t = e.get(0, 0);
- }
- return this._handleSingleObject(t);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = Math.floor(+t.getValue()), n = cr(r, 2);
- return Number.isNaN(n) || !Number.isFinite(n) ? g2.create(m2.NUM) : y2.create(n);
- }
- };
- var LC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
- let h = o.get(l2, f2), d2 = c;
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- const _ = +d2.getValue(), C = +h.getValue();
- if (_ > 0 && C < 0)
- return g2.create(m2.NUM);
- if (_ === 0)
- return y2.create(0);
- if (C === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const E2 = We(_ / C, 0) * C;
- return y2.create(E2);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var xC2 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : y2.create(1), s = r != null ? r : y2.create(0), o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, n, g2.create(m2.NA)), f2 = O(o, u, s, g2.create(m2.NA)), h = c.map((d2, _, C) => {
- let E2 = d2, b = l2.get(_, C), R = f2.get(_, C);
- if (E2.isString() && (E2 = E2.convertToNumberObjectValue()), E2.isError())
- return E2;
- if (b.isString() && (b = b.convertToNumberObjectValue()), b.isError())
- return b;
- if (R.isString() && (R = R.convertToNumberObjectValue()), R.isError())
- return R;
- const p2 = +E2.getValue(), N2 = +b.getValue(), M2 = +R.getValue();
- if (p2 === 0 || N2 === 0)
- return y2.create(0);
- let w;
- return p2 < 0 && M2 !== 0 ? w = (N2 < 0 ? We(Math.abs(p2) / Math.abs(N2), 0) : -We(Math.abs(p2) / N2, 0)) * N2 : w = (N2 < 0 ? -We(p2 / Math.abs(N2), 0) : We(p2 / N2, 0)) * N2, y2.create(w);
- });
- return o === 1 && u === 1 ? h.get(0, 0) : h;
- }
- };
- var jC2 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(1);
- if (e.isError())
- return e;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.map((l2, f2, h) => {
- let d2 = u.get(f2, h), _ = l2;
- if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
- return _;
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- const C = +_.getValue(), E2 = +d2.getValue();
- if (C === 0 || E2 === 0)
- return y2.create(0);
- const b = (E2 < 0 ? -We(C / Math.abs(E2), 0) : We(C / E2, 0)) * E2;
- return y2.create(b);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- };
- var UC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 0;
- for (let r = 0; r < e.length; r++) {
- const n = e[r];
- if (!n.isNull())
- if (n.isArray()) {
- let s = false, o = g2.create(m2.VALUE);
- if (n.iterator((u) => {
- if (u != null && u.isNull())
- return true;
- const { isError: c, errorObject: l2, number: f2 } = this._handleSingleObject(u);
- if (c)
- return s = true, o = l2, false;
- t = qs(t, f2);
- }), s)
- return o;
- } else {
- const { isError: s, errorObject: o, number: u } = this._handleSingleObject(n);
- if (s)
- return o;
- t = qs(t, u);
- }
- }
- return y2.create(t);
- }
- _handleSingleObject(e) {
- if (e.isBoolean())
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- number: null
- };
- let t = e;
- if (e.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return {
- isError: true,
- errorObject: t,
- number: null
- };
- const r = Math.floor(+t.getValue());
- return r < 0 || r >= 2 ** 53 ? {
- isError: true,
- errorObject: g2.create(m2.NUM),
- number: null
- } : {
- isError: false,
- errorObject: null,
- number: r
- };
- }
- };
- var vC2 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = Math.floor(+t.getValue());
- return y2.create(r);
- }
- };
- var TC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 1, r = true;
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (!s.isNull())
- if (s.isArray()) {
- let o = false, u = g2.create(m2.VALUE);
- if (s.iterator((c) => {
- if (c != null && c.isNull())
- return true;
- const { isError: l2, errorObject: f2, number: h } = this._handleSingleObject(c);
- if (l2)
- return o = true, u = f2, false;
- t = Mi(t, h), r = false;
- }), o)
- return u;
- } else {
- const { isError: o, errorObject: u, number: c } = this._handleSingleObject(s);
- if (o)
- return u;
- t = Mi(t, c), r = false;
- }
- }
- return r ? y2.create(0) : Number.isNaN(t) || !Number.isFinite(t) || t >= 2 ** 53 ? g2.create(m2.VALUE) : y2.create(t);
- }
- _handleSingleObject(e) {
- if (e.isBoolean())
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- number: null
- };
- let t = e;
- if (e.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return {
- isError: true,
- errorObject: t,
- number: null
- };
- const r = Math.floor(+t.getValue());
- return r < 0 ? {
- isError: true,
- errorObject: g2.create(m2.NUM),
- number: null
- } : {
- isError: false,
- errorObject: null,
- number: r
- };
- }
- };
- var BC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.log();
- }
- };
- var IC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(10);
- if (e.isError())
- return e;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.map((l2, f2, h) => {
- let d2 = u.get(f2, h), _ = l2;
- if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
- return _;
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- const C = +_.getValue(), E2 = +d2.getValue();
- if (C <= 0 || E2 <= 0)
- return g2.create(m2.NUM);
- const b = Math.log(E2);
- if (b === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const R = Math.log(C) / b;
- return y2.create(R);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- };
- var FC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.log10();
- }
- };
- var kC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let o = 0; o < t; o++) {
- const u = [];
- for (let c = 0; c < r; c++) {
- let l2 = e.isArray() ? e.get(o, c) : e;
- if (l2.isError())
- return l2;
- if (l2.isNull() || l2.isBoolean())
- return g2.create(m2.VALUE);
- if (l2.isString() && (l2 = l2.convertToNumberObjectValue()), l2.isError())
- return l2;
- const f2 = +l2.getValue();
- u.push(f2);
- }
- n.push(u);
- }
- if (t !== r)
- return g2.create(m2.VALUE);
- const s = Gn(n);
- return y2.create(s);
- }
- };
- var $C = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let o = 0; o < t; o++) {
- const u = [];
- for (let c = 0; c < r; c++) {
- let l2 = e.isArray() ? e.get(o, c) : e;
- if (l2.isError())
- return l2;
- if (l2.isNull() || l2.isBoolean())
- return g2.create(m2.VALUE);
- if (l2.isString() && (l2 = l2.convertToNumberObjectValue()), l2.isError())
- return l2;
- const f2 = +l2.getValue();
- u.push(f2);
- }
- n.push(u);
- }
- if (t !== r)
- return g2.create(m2.VALUE);
- const s = Gh(n);
- return s === null ? g2.create(m2.NUM) : q2.createByArray(s);
- }
- };
- var YC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- if (n !== s)
- return g2.create(m2.VALUE);
- const u = this._getMatrix(e, r, n), c = this._getMatrix(t, s, o);
- if (u instanceof g2)
- return u;
- if (c instanceof g2)
- return c;
- const l2 = lr(u, c);
- return q2.createByArray(l2);
- }
- _getMatrix(e, t, r) {
- const n = [];
- for (let s = 0; s < t; s++) {
- const o = [];
- for (let u = 0; u < r; u++) {
- let c = e.isArray() ? e.get(s, u) : e;
- if (c.isError())
- return c;
- if (c.isNull() || c.isBoolean())
- return g2.create(m2.VALUE);
- if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
- return c;
- const l2 = +c.getValue();
- o.push(l2);
- }
- n.push(o);
- }
- return n;
- }
- };
- var HC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
- return r;
- let n = t;
- return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.mod(n);
- }
- };
- var GC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isArray()) {
- const c = r.getRowCount(), l2 = r.getColumnCount();
- if (c > 1 || l2 > 1)
- return g2.create(m2.VALUE);
- r = r.get(0, 0);
- }
- if (r.isError())
- return r;
- let n = t;
- if (n.isArray()) {
- const c = n.getRowCount(), l2 = n.getColumnCount();
- if (c > 1 || l2 > 1)
- return g2.create(m2.VALUE);
- n = n.get(0, 0);
- }
- if (n.isError())
- return n;
- if (r.isBoolean() || n.isBoolean())
- return g2.create(m2.VALUE);
- const s = +r.getValue(), o = +n.getValue();
- if (Number.isNaN(s) || Number.isNaN(o))
- return g2.create(m2.VALUE);
- if (o === 0)
- return y2.create(0);
- if (s > 0 && o < 0 || s < 0 && o > 0)
- return g2.create(m2.NUM);
- const u = vt(s / o, 0) * o;
- return y2.create(u);
- }
- };
- var QC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 0, r = 1;
- for (let s = 0; s < e.length; s++) {
- const o = e[s];
- if (!o.isNull())
- if (o.isArray()) {
- let u = false, c = g2.create(m2.VALUE);
- if (o.iterator((l2) => {
- if (l2 != null && l2.isNull())
- return true;
- const { isError: f2, errorObject: h, number: d2 } = this._handleSingleObject(l2);
- if (f2)
- return u = true, c = h, false;
- if (t += d2, t > 170)
- return u = true, c = g2.create(m2.NUM), false;
- r *= cr(d2);
- }), u)
- return c;
- } else {
- const { isError: u, errorObject: c, number: l2 } = this._handleSingleObject(o);
- if (u)
- return c;
- if (t += l2, t > 170)
- return g2.create(m2.NUM);
- r *= cr(l2);
- }
- }
- const n = cr(t) / r;
- return y2.create(n);
- }
- _handleSingleObject(e) {
- if (e.isBoolean())
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- number: null
- };
- let t = e;
- if (e.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return {
- isError: true,
- errorObject: t,
- number: null
- };
- const r = Math.floor(+t.getValue());
- return r < 0 ? {
- isError: true,
- errorObject: g2.create(m2.NUM),
- number: null
- } : {
- isError: false,
- errorObject: null,
- number: r
- };
- }
- };
- var WC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.getRowCount(), r = e.getColumnCount(), n = e.mapValue((s) => {
- const o = this._handleSingleObject(s);
- return o.isError() ? o : t > 1 || r > 1 ? o.get(0, 0) : o;
- });
- return t === 1 && r === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = Math.floor(+t.getValue());
- if (r <= 0)
- return g2.create(m2.VALUE);
- const n = [];
- for (let s = 0; s < r; s++) {
- n[s] = [];
- for (let o = 0; o < r; o++)
- n[s][o] = s === o ? 1 : 0;
- }
- return q2.createByArray(n);
- }
- };
- var qC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- if (!Number.isFinite(r))
- return g2.create(m2.VALUE);
- let n = r < 0 ? -Ye(Math.abs(r), 0) : Ye(r, 0);
- return Number.isNaN(n) ? g2.create(m2.VALUE) : (Math.abs(n) % 2 === 0 && (r < 0 ? n-- : n++), y2.create(n));
- }
- };
- var KC2 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- return y2.create(Math.PI);
- }
- };
- var XC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
- return r;
- let n = t;
- return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.pow(n);
- }
- };
- var ZC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(1), r = true;
- for (let n = 0; n < e.length; n++) {
- let s = e[n];
- if (s.isError())
- return s;
- if (s.isArray()) {
- let o = false, u = null;
- if (s.iterator((c) => {
- if (c != null && c.isError())
- return o = true, u = c, false;
- if (!c || c.isNull() || c.isString() || c.isBoolean())
- return true;
- t = t.multiply(c), r = false;
- }), o)
- return u;
- } else {
- if (s.isNull())
- continue;
- if (s.isString() && (s = s.convertToNumberObjectValue()), s.isError())
- return s;
- t = t.multiply(s), r = false;
- }
- if (t.isError())
- return t;
- }
- return r ? y2.create(0) : t;
- }
- };
- var zC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = +u.getValue();
- if (Number.isNaN(c) || Number.isNaN(l2))
- return g2.create(m2.VALUE);
- if (l2 === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const f2 = Math.trunc(c / l2);
- return y2.create(f2);
- }
- };
- var JC = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- if (!Number.isFinite(r))
- return g2.create(m2.VALUE);
- const n = r * (Math.PI / 180);
- return Number.isNaN(n) ? g2.create(m2.VALUE) : y2.create(n);
- }
- };
- var e_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- return y2.create(Math.random());
- }
- };
- var t_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 5);
- A(this, "needsSheetRowColumnCount", true);
- }
- calculate(e, t, r, n, s) {
- if (e != null && e.isError())
- return e;
- if (t != null && t.isError())
- return t;
- if (r != null && r.isError())
- return r;
- if (n != null && n.isError())
- return n;
- if (s != null && s.isError())
- return s;
- const o = e != null ? e : y2.create(1), u = t != null ? t : y2.create(1), c = r != null ? r : y2.create(0), l2 = n != null ? n : y2.create(1), f2 = s != null ? s : y2.create(0);
- return this._calculateResult(o, u, c, l2, f2);
- }
- _calculateResult(e, t, r, n, s) {
- const o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- );
- if (o === 1 && u === 1)
- return this._calculateSingleCell(e, t, r, n, s);
- const c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, t, g2.create(m2.NA)), f2 = O(o, u, r, g2.create(m2.NA)), h = O(o, u, n, g2.create(m2.NA)), d2 = O(o, u, s, g2.create(m2.NA));
- return c.map((_, C, E2) => {
- const b = l2.get(C, E2), R = f2.get(C, E2), p2 = h.get(C, E2), N2 = d2.get(C, E2), M2 = this._handleError(_, b, R, p2, N2);
- if (M2.errorObject)
- return M2.errorObject;
- let { minValue: w, maxValue: D2, wholeNumberValue: S2 } = M2, P;
- return S2 ? (w = Math.ceil(w), D2 = Math.floor(D2), P = Math.floor(Math.random() * (D2 - w + 1)) + w) : P = Math.random() * (D2 - w) + w, P < w || P > D2 ? g2.create(m2.VALUE) : y2.create(P);
- });
- }
- _calculateSingleCell(e, t, r, n, s) {
- let o = e;
- o.isArray() && (o = o.get(0, 0));
- let u = t;
- u.isArray() && (u = u.get(0, 0));
- let c = r;
- c.isArray() && (c = c.get(0, 0));
- let l2 = n;
- l2.isArray() && (l2 = l2.get(0, 0));
- let f2 = s;
- f2.isArray() && (f2 = f2.get(0, 0));
- const h = this._handleError(o, u, c, l2, f2);
- if (h.errorObject)
- return h.errorObject;
- let { rowsValue: d2, columnsValue: _, minValue: C, maxValue: E2, wholeNumberValue: b } = h;
- if (b && (C = Math.ceil(C), E2 = Math.floor(E2), C > E2))
- return g2.create(m2.VALUE);
- const R = [];
- for (let p2 = 0; p2 < d2; p2++) {
- const N2 = [];
- for (let M2 = 0; M2 < _; M2++)
- b ? N2.push(Math.floor(Math.random() * (E2 - C + 1)) + C) : N2.push(Math.random() * (E2 - C) + C);
- R.push(N2);
- }
- return d2 === 1 && _ === 1 ? y2.create(R[0][0]) : q2.createByArray(R);
- }
- _handleError(e, t, r, n, s) {
- let o = e;
- if (o.isString() && (o = o.convertToNumberObjectValue()), o.isError())
- return {
- errorObject: o
- };
- let u = t;
- if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
- return {
- errorObject: u
- };
- let c = r;
- if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
- return {
- errorObject: c
- };
- let l2 = n;
- if (l2.isString() && (l2 = l2.convertToNumberObjectValue()), l2.isError())
- return {
- errorObject: l2
- };
- let f2 = s;
- return f2.isString() && (f2 = f2.convertToNumberObjectValue()), f2.isError() ? {
- errorObject: f2
- } : this._getValue(o, u, c, l2, f2);
- }
- _getValue(e, t, r, n, s) {
- const o = Math.floor(+e.getValue()), u = Math.floor(+t.getValue());
- if (o === 0 || u === 0)
- return {
- errorObject: g2.create(m2.CALC)
- };
- const c = this._rowCount - this.row, l2 = this._columnCount - this.column;
- if (o < 0 || u < 0 || o * u > 10 ** 7)
- return {
- errorObject: g2.create(m2.VALUE)
- };
- if (o > c || u > l2)
- return {
- errorObject: g2.create(m2.REF)
- };
- const f2 = +r.getValue(), h = +n.getValue(), d2 = +s.getValue();
- return f2 > h ? {
- errorObject: g2.create(m2.VALUE)
- } : d2 && (!Number.isInteger(f2) || !Number.isInteger(h)) ? {
- errorObject: g2.create(m2.VALUE)
- } : {
- rowsValue: o,
- columnsValue: u,
- minValue: f2,
- maxValue: h,
- wholeNumberValue: d2
- };
- }
- };
- var r_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isArray()) {
- const c = r.getRowCount(), l2 = r.getColumnCount();
- if (c > 1 || l2 > 1)
- return g2.create(m2.VALUE);
- r = r.get(0, 0);
- }
- if (r.isError())
- return r;
- let n = t;
- if (n.isArray()) {
- const c = n.getRowCount(), l2 = n.getColumnCount();
- if (c > 1 || l2 > 1)
- return g2.create(m2.VALUE);
- n = n.get(0, 0);
- }
- if (n.isError())
- return n;
- if (r.isBoolean() || n.isBoolean())
- return g2.create(m2.VALUE);
- let s = +r.getValue(), o = +n.getValue();
- if (Number.isNaN(s) || Number.isNaN(o))
- return g2.create(m2.VALUE);
- if (s > o)
- return g2.create(m2.NUM);
- s = Math.ceil(s), o = Math.floor(o);
- const u = Math.floor(Math.random() * (o - s + 1)) + s;
- return y2.create(u);
- }
- };
- var n_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(0), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
- const d2 = u.get(f2, h);
- return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(e);
- if (r)
- return n;
- const [o] = s;
- let u = Math.floor(+o.getValue()), c = t;
- if (c.isString() && (c = c.convertToNumberObjectValue(), c.isError()))
- return c;
- let l2 = Math.floor(+c.getValue());
- if (c.isBoolean() && (l2 = c.getValue() ? 0 : 4), u < 0 || u > 3999 || l2 < 0 || l2 > 4)
- return g2.create(m2.VALUE);
- const f2 = Jh[l2];
- let h = f2.length - 1, d2 = "";
- for (; u > 0; ) {
- h = this._binarySearch(u, 0, h, f2);
- const _ = f2[h];
- u -= _, d2 += zh.get(_);
- }
- return j.create(d2);
- }
- _binarySearch(e, t, r, n) {
- let s = t, o = r;
- for (; o - s > 1; ) {
- const u = Math.floor((s + o) / 2), c = n[u];
- if (c === e)
- return u;
- c > e ? o = u : s = u;
- }
- return s !== o && n[o] <= e ? o : s;
- }
- };
- var s_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
- return r;
- let n = t;
- return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.round(n);
- }
- };
- var a_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- if (c.isError())
- return c;
- if (h.isError())
- return h;
- const { isError: d2, errorObject: _, variants: C } = I2(c, h);
- if (d2)
- return _;
- const [E2, b] = C, R = +E2.getValue(), p2 = Math.trunc(+b.getValue()), N2 = this._roundBank(R, p2);
- return y2.create(N2);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _roundBank(e, t) {
- if (t > 16)
- return e;
- if (t < -16)
- return 0;
- const r = 1e-8, n = 10 ** t, s = +(e * n).toFixed(8), o = Math.floor(s), u = s - o;
- let c = Math.round(s);
- return u > 0.5 - r && u < 0.5 + r && (c = o % 2 === 0 ? o : o + 1), t ? c / n : c;
- }
- };
- var i_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
- return r;
- let n = t;
- return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.floor(n);
- }
- };
- var o_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
- return r;
- let n = t;
- return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.ceil(n);
- }
- };
- var u_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- return Math.abs(r) >= 2 ** 27 ? g2.create(m2.NUM) : t.cos().getReciprocal();
- }
- };
- var c_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- return Number.isFinite(Math.cosh(r)) ? Math.abs(r) >= 2 ** 27 ? g2.create(m2.NUM) : t.cosh().getReciprocal() : y2.create(0);
- }
- };
- var l_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- A(this, "needsSheetRowColumnCount", true);
- }
- calculate(e, t, r, n) {
- let s = e, o = t != null ? t : y2.create(1), u = r != null ? r : y2.create(1), c = n != null ? n : y2.create(1);
- s.isNull() && (s = y2.create(1)), o.isNull() && (o = y2.create(1)), u.isNull() && (u = y2.create(1)), c.isNull() && (c = y2.create(1));
- const l2 = Math.max(
- s.isArray() ? s.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f2 = Math.max(
- s.isArray() ? s.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l2, f2, s, g2.create(m2.NA)), d2 = O(l2, f2, o, g2.create(m2.NA)), _ = O(l2, f2, u, g2.create(m2.NA)), C = O(l2, f2, c, g2.create(m2.NA)), E2 = h.mapValue((b, R, p2) => {
- const N2 = d2.get(R, p2), M2 = _.get(R, p2), w = C.get(R, p2);
- return b.isError() ? b : N2.isError() ? N2 : M2.isError() ? M2 : w.isError() ? w : this._getResult(b, N2, M2, w, l2, f2);
- });
- return l2 === 1 && f2 === 1 ? E2.get(0, 0) : E2;
- }
- _getResult(e, t, r, n, s, o) {
- const { isError: u, errorObject: c, variants: l2 } = I2(e, t, r, n);
- if (u)
- return c;
- const [f2, h, d2, _] = l2, C = Math.floor(+f2.getValue()), E2 = Math.floor(+h.getValue()), b = +d2.getValue(), R = +_.getValue();
- if (C < 0 || E2 < 0 || C * E2 > 10 ** 7)
- return g2.create(m2.VALUE);
- if (C === 0 || E2 === 0)
- return g2.create(m2.CALC);
- const p2 = this._rowCount - this.row, N2 = this._columnCount - this.column;
- if (C > p2 || E2 > N2)
- return g2.create(m2.REF);
- const M2 = [];
- for (let w = 0; w < C; w++) {
- M2[w] = [];
- for (let D2 = 0; D2 < E2; D2++)
- M2[w][D2] = b + (w * E2 + D2) * R;
- }
- return s > 1 || o > 1 ? y2.create(M2[0][0]) : q2.createByArray(M2);
- }
- };
- var f_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- if (e.isNull() || t.isNull() || r.isNull() || n.isNull())
- return g2.create(m2.NA);
- const { isError: s, errorObject: o, variants: u } = H(e, t, r);
- if (s)
- return o;
- const { isError: c, errorObject: l2, variants: f2 } = I2(...u);
- if (c)
- return l2;
- const [h, d2, _] = f2, C = +h.getValue(), E2 = +d2.getValue(), b = +_.getValue(), R = [];
- if (n.isArray()) {
- let N2 = false, M2 = g2.create(m2.VALUE);
- if (n.iterator((w) => {
- const { isError: D2, errorObject: S2, coefficientsObject: P } = this._handleSingleObject(w);
- if (D2)
- return N2 = true, M2 = S2, false;
- const U2 = +P.getValue();
- R.push(U2);
- }), N2)
- return M2;
- } else {
- const { isError: N2, errorObject: M2, coefficientsObject: w } = this._handleSingleObject(n);
- if (N2)
- return M2;
- const D2 = +w.getValue();
- R.push(D2);
- }
- let p2 = 0;
- for (let N2 = 0; N2 < R.length; N2++)
- p2 += R[N2] * C ** (E2 + N2 * b);
- return Number.isNaN(p2) || !Number.isFinite(p2) ? g2.create(m2.NUM) : y2.create(p2);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return {
- isError: true,
- errorObject: e,
- coefficientsObject: null
- };
- if (e != null && e.isBoolean())
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- coefficientsObject: null
- };
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? {
- isError: true,
- errorObject: t,
- coefficientsObject: null
- } : {
- isError: false,
- errorObject: null,
- coefficientsObject: t
- };
- }
- };
- var h_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- return o > 0 ? y2.create(1) : o < 0 ? y2.create(-1) : y2.create(0);
- }
- };
- var m_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.sin();
- }
- };
- var g_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.sinh();
- }
- };
- var d_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.sqrt();
- }
- };
- var C_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const s = t.getRowCount(), o = t.getColumnCount();
- if (s > 1 || o > 1)
- return g2.create(m2.VALUE);
- t = t.get(0, 0);
- }
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- if (r < 0)
- return g2.create(m2.NUM);
- const n = Math.sqrt(r * Math.PI);
- return y2.create(n);
- }
- };
- var __ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- A(this, "needsReferenceObject", true);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- if (e.isReferenceObject()) {
- const r = [];
- return e.iterator((n, s, o) => {
- r[s] == null && (r[s] = []), r[s][o] = this._handleSingleObject(
- n,
- ...t
- );
- }), tr(r, r.length, r[0].length);
- }
- return this._handleSingleObject(e, ...t);
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- _handleSingleObject(e, ...t) {
- const r = this._getIndexNumValue(e);
- let n;
- if (r instanceof g2)
- return r;
- switch (r) {
- case 1:
- n = this._average(false, ...t);
- break;
- case 2:
- n = this._count(false, ...t);
- break;
- case 3:
- n = this._counta(false, ...t);
- break;
- case 4:
- n = this._max(false, ...t);
- break;
- case 5:
- n = this._min(false, ...t);
- break;
- case 6:
- n = this._product(false, ...t);
- break;
- case 7:
- n = this._stdev(false, ...t);
- break;
- case 8:
- n = this._stdevp(false, ...t);
- break;
- case 9:
- n = this._sum(false, ...t);
- break;
- case 10:
- n = this._var(false, ...t);
- break;
- case 11:
- n = this._varp(false, ...t);
- break;
- case 101:
- n = this._average(true, ...t);
- break;
- case 102:
- n = this._count(true, ...t);
- break;
- case 103:
- n = this._counta(true, ...t);
- break;
- case 104:
- n = this._max(true, ...t);
- break;
- case 105:
- n = this._min(true, ...t);
- break;
- case 106:
- n = this._product(true, ...t);
- break;
- case 107:
- n = this._stdev(true, ...t);
- break;
- case 108:
- n = this._stdevp(true, ...t);
- break;
- case 109:
- n = this._sum(true, ...t);
- break;
- case 110:
- n = this._var(true, ...t);
- break;
- case 111:
- n = this._varp(true, ...t);
- break;
- default:
- n = g2.create(m2.VALUE);
- }
- return n;
- }
- _getIndexNumValue(e) {
- const t = e ? Number(e.getValue()) : 0;
- if (Number.isNaN(t))
- return g2.create(m2.VALUE);
- const r = Math.floor(t);
- return r >= 1 && r <= 11 || r >= 101 && r <= 111 ? r : g2.create(m2.VALUE);
- }
- _average(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : r.mean();
- }
- _count(e, ...t) {
- let r = y2.create(0);
- for (let n = 0; n < t.length; n++) {
- const s = t[n];
- if (!s.isReferenceObject())
- return g2.create(m2.VALUE);
- const o = s.getRowData();
- s.iterator((u, c) => {
- if (e && this._isRowHidden(o, c))
- return true;
- u != null && u.isNumber() && (r = r.plusBy(1));
- });
- }
- return r;
- }
- _counta(e, ...t) {
- let r = y2.create(0);
- for (let n = 0; n < t.length; n++) {
- const s = t[n];
- if (!s.isReferenceObject())
- return g2.create(m2.VALUE);
- const o = s.getRowData();
- s.iterator((u, c) => {
- if (e && this._isRowHidden(o, c) || u == null || u.isNull())
- return true;
- r = r.plusBy(1);
- });
- }
- return r;
- }
- _max(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? y2.create(0) : r.max();
- }
- _min(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? y2.create(0) : r.min();
- }
- _product(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- if (r.isError())
- return r;
- if (this._isBlankArrayObject(r))
- return y2.create(0);
- let n = y2.create(1);
- return r.iterator((s) => {
- n = n.multiply(
- s
- );
- }), n;
- }
- _stdev(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? g2.create(m2.DIV_BY_ZERO) : r.std(1);
- }
- _stdevp(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? g2.create(m2.DIV_BY_ZERO) : r.std();
- }
- _sum(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : r.sum();
- }
- _var(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? g2.create(m2.DIV_BY_ZERO) : r.var(1);
- }
- _varp(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? g2.create(m2.DIV_BY_ZERO) : r.var();
- }
- _flattenRefArray(e, ...t) {
- const r = [];
- r[0] = [];
- for (let n = 0; n < t.length; n++) {
- const s = t[n];
- if (s.isError())
- return s;
- if (!s.isReferenceObject())
- return g2.create(m2.VALUE);
- const o = s.getRowData();
- let u;
- if (s.iterator((c, l2) => {
- if (e && this._isRowHidden(o, l2) || c == null || c.isNull() || c.isString() || c.isBoolean())
- return true;
- if (c.isError())
- return u = c, false;
- r[0].push(c);
- }), u != null && u.isError())
- return u;
- }
- return tr(r, 1, r[0].length);
- }
- _isRowHidden(e, t) {
- const r = e[t];
- return r ? r.hd === we.TRUE : false;
- }
- _isBlankArrayObject(e) {
- return e.getArrayValue()[0].length === 0;
- }
- };
- var A_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(0);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError() || (n.isArray() && (n = n.sum()), n.isError()))
- return n;
- if (t = t.plus(n), t.isError())
- return t;
- }
- return t;
- }
- };
- var E_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", true);
- }
- calculate(e, t, r) {
- let n = t;
- if (t.isReferenceObject() && (n = t.toArrayValueObject()), n.isArray()) {
- const s = n.mapValue((o) => this._handleSingleObject(e, o, r));
- return s.getRowCount() === 1 && s.getColumnCount() === 1 ? s.get(0, 0) : s;
- }
- return this._handleSingleObject(e, n, r);
- }
- _handleSingleObject(e, t, r) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r != null && r.isError())
- return r;
- if (!e.isReferenceObject() || r && !r.isReferenceObject())
- return g2.create(m2.VALUE);
- const n = e.toArrayValueObject();
- let s = $n(n, t);
- s = Yn(s, n, t);
- const o = n.getRowCount(), u = n.getColumnCount();
- let c = n;
- if (r) {
- c = r.toArrayValueObject();
- const l2 = c.getRowCount(), f2 = c.getColumnCount();
- if (o !== l2 || u !== f2) {
- const h = r.getRangeData();
- h.endRow = h.startRow + o - 1, h.endColumn = h.startColumn + u - 1, r.setRangeData(h), c = r.toArrayValueObject();
- }
- }
- return c.pick(s).sum();
- }
- };
- var b_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- if (!e.isArray() || t.length < 2 || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
- return g2.create(m2.VALUE);
- const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
- if (s)
- return s;
- const o = Ir(t, r, n, true);
- return this._aggregateResults(e, o);
- }
- _aggregateResults(e, t) {
- const r = t.map((s) => s.map((o) => e.pick(o).sum())), n = {
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q2.create(n);
- }
- };
- var y_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- const r = this._initArray1(e);
- if (t.length > 0) {
- const n = r.getRowCount(), s = r.getColumnCount();
- let o = this._getResultArrayByArray1(n, s, r);
- if (o instanceof g2)
- return o;
- o = o;
- for (let c = 0; c < t.length; c++) {
- if (t[c].isError())
- return t[c];
- let l2 = 1, f2 = 1;
- if (t[c].isArray() && (l2 = t[c].getRowCount(), f2 = t[c].getColumnCount()), l2 !== n || f2 !== s)
- return g2.create(m2.VALUE);
- for (let h = 0; h < n; h++) {
- const d2 = [];
- for (let _ = 0; _ < s; _++) {
- let C = t[c];
- if (t[c].isArray() && (C = t[c].get(h, _)), C.isError())
- return C;
- const E2 = C.getValue();
- !E2 || !DC(E2) ? d2.push(0) : d2.push(+E2 * o[h][_]);
- }
- o[h] = d2;
- }
- }
- const u = o.reduce((c, l2) => c.concat(l2)).reduce((c, l2) => c + l2, 0);
- return y2.create(u);
- } else
- return r.sum();
- }
- _initArray1(e) {
- let t = e;
- return t.isArray() || (t = q2.create({
- calculateValueList: [[t]],
- rowCount: 1,
- columnCount: 1,
- unitId: "",
- sheetId: "",
- row: 0,
- column: 0
- })), t;
- }
- _getResultArrayByArray1(e, t, r) {
- const n = [];
- for (let s = 0; s < e; s++) {
- const o = [];
- for (let u = 0; u < t; u++) {
- const c = r.get(s, u);
- if (c.isError())
- return c;
- const l2 = c.getValue();
- !l2 || !DC(l2) ? o.push(0) : o.push(+l2);
- }
- n.push(o);
- }
- return n;
- }
- };
- var R_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(0);
- const r = y2.create(2);
- for (let n = 0; n < e.length; n++) {
- let s = e[n];
- if (s.isString() && (s = s.convertToNumberObjectValue()), s.isError())
- return s;
- if (s.isArray() ? s.iterator((o) => {
- if (o == null || o.isString() || o.isBoolean() || o.isNull())
- return true;
- if (o.isError())
- return t = o, false;
- t = t.plus(
- o.pow(r)
- );
- }) : t = t.plus(s.pow(r)), t.isError())
- return t;
- }
- return t;
- }
- };
- var p_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = r * n, o = t.isArray() ? t.getRowCount() : 1, u = t.isArray() ? t.getColumnCount() : 1, c = o * u;
- if (s !== c)
- return g2.create(m2.NA);
- if (s === 1)
- return this._calculateSingleCell(e, t);
- {
- const l2 = e.flatten(), f2 = t.flatten();
- let h = ie.create();
- const d2 = [], _ = [];
- let C = 0;
- return l2.iterator((E2, b, R) => {
- const p2 = f2.get(b, R);
- if (E2 == null || E2.isString() || E2.isBoolean() || E2.isNull())
- return true;
- if (E2 != null && E2.isError())
- return h = E2, false;
- if (p2 == null || p2.isString() || p2.isBoolean() || p2.isNull())
- return true;
- if (p2 != null && p2.isError())
- return h = p2, false;
- const N2 = +E2.getValue(), M2 = +p2.getValue();
- d2.push(N2), _.push(M2), C += N2 ** 2 - M2 ** 2;
- }), h.isError() ? h : d2.length === 0 || _.length === 0 ? g2.create(m2.DIV_BY_ZERO) : y2.create(C);
- }
- }
- _calculateSingleCell(e, t) {
- let r = e;
- if (r.isArray() && (r = r.get(0, 0)), r.isError())
- return r;
- let n = t;
- if (n.isArray() && (n = n.get(0, 0)), n.isError())
- return n;
- if (r.isNull() || n.isNull())
- return g2.create(m2.VALUE);
- const s = +r.getValue(), o = +n.getValue();
- if (r.isString() && !DC(s) || r.isBoolean() || n.isString() && !DC(o) || n.isBoolean())
- return g2.create(m2.DIV_BY_ZERO);
- const u = s ** 2 - o ** 2;
- return y2.create(u);
- }
- };
- var V_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = r * n, o = t.isArray() ? t.getRowCount() : 1, u = t.isArray() ? t.getColumnCount() : 1, c = o * u;
- if (s !== c)
- return g2.create(m2.NA);
- if (s === 1)
- return this._calculateSingleCell(e, t);
- {
- const l2 = e.flatten(), f2 = t.flatten();
- let h = ie.create();
- const d2 = [], _ = [];
- let C = 0;
- return l2.iterator((E2, b, R) => {
- const p2 = f2.get(b, R);
- if (E2 == null || E2.isString() || E2.isBoolean() || E2.isNull())
- return true;
- if (E2 != null && E2.isError())
- return h = E2, false;
- if (p2 == null || p2.isString() || p2.isBoolean() || p2.isNull())
- return true;
- if (p2 != null && p2.isError())
- return h = p2, false;
- const N2 = +E2.getValue(), M2 = +p2.getValue();
- d2.push(N2), _.push(M2), C += N2 ** 2 + M2 ** 2;
- }), h.isError() ? h : d2.length === 0 || _.length === 0 ? g2.create(m2.DIV_BY_ZERO) : y2.create(C);
- }
- }
- _calculateSingleCell(e, t) {
- let r = e;
- if (r.isArray() && (r = r.get(0, 0)), r.isError())
- return r;
- let n = t;
- if (n.isArray() && (n = n.get(0, 0)), n.isError())
- return n;
- if (r.isNull() || n.isNull())
- return g2.create(m2.VALUE);
- const s = +r.getValue(), o = +n.getValue();
- if (r.isString() && !DC(s) || r.isBoolean() || n.isString() && !DC(o) || n.isBoolean())
- return g2.create(m2.DIV_BY_ZERO);
- const u = s ** 2 + o ** 2;
- return y2.create(u);
- }
- };
- var N_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = r * n, o = t.isArray() ? t.getRowCount() : 1, u = t.isArray() ? t.getColumnCount() : 1, c = o * u;
- if (s !== c)
- return g2.create(m2.NA);
- if (s === 1)
- return this._calculateSingleCell(e, t);
- {
- const l2 = e.flatten(), f2 = t.flatten();
- let h = ie.create();
- const d2 = [], _ = [];
- let C = 0;
- return l2.iterator((E2, b, R) => {
- const p2 = f2.get(b, R);
- if (E2 == null || E2.isString() || E2.isBoolean() || E2.isNull())
- return true;
- if (E2 != null && E2.isError())
- return h = E2, false;
- if (p2 == null || p2.isString() || p2.isBoolean() || p2.isNull())
- return true;
- if (p2 != null && p2.isError())
- return h = p2, false;
- const N2 = +E2.getValue(), M2 = +p2.getValue();
- d2.push(N2), _.push(M2), C += (N2 - M2) ** 2;
- }), h.isError() ? h : d2.length === 0 || _.length === 0 ? g2.create(m2.DIV_BY_ZERO) : y2.create(C);
- }
- }
- _calculateSingleCell(e, t) {
- let r = e;
- if (r.isArray() && (r = r.get(0, 0)), r.isError())
- return r;
- let n = t;
- if (n.isArray() && (n = n.get(0, 0)), n.isError())
- return n;
- if (r.isNull() || n.isNull())
- return g2.create(m2.VALUE);
- const s = +r.getValue(), o = +n.getValue();
- if (r.isString() && !DC(s) || r.isBoolean() || n.isString() && !DC(o) || n.isBoolean())
- return g2.create(m2.DIV_BY_ZERO);
- const u = (s - o) ** 2;
- return y2.create(u);
- }
- };
- var O_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.tan();
- }
- };
- var M_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.tanh();
- }
- };
- var w_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(0), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.map((l2, f2, h) => {
- let d2 = u.get(f2, h), _ = l2;
- if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
- return _;
- if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
- return d2;
- const C = +_.getValue(), E2 = +d2.getValue(), b = 10 ** Math.trunc(E2), R = Bn(C, b), p2 = Math.trunc(Vr2(C, b) + R) / b;
- return y2.create(p2);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- };
- var D_ = [
- [nC, Y2.ABS],
- [sC, Y2.ACOS],
- [aC, Y2.ACOSH],
- [iC, Y2.ACOT],
- [oC, Y2.ACOTH],
- [uC, Y2.ARABIC],
- [cC, Y2.ASIN],
- [lC, Y2.ASINH],
- [fC, Y2.ATAN],
- [hC, Y2.ATAN2],
- [mC, Y2.ATANH],
- [gC, Y2.BASE],
- [dC, Y2.CEILING],
- [CC, Y2.CEILING_MATH],
- [_C, Y2.CEILING_PRECISE],
- [AC2, Y2.COMBIN],
- [EC, Y2.COMBINA],
- [bC, Y2.COS],
- [yC2, Y2.COSH],
- [RC, Y2.COT],
- [pC, Y2.COTH],
- [VC, Y2.CSC],
- [NC, Y2.CSCH],
- [OC, Y2.DECIMAL],
- [MC, Y2.DEGREES],
- [wC, Y2.EVEN],
- [DC2, Y2.EXP],
- [SC2, Y2.FACT],
- [PC, Y2.FACTDOUBLE],
- [LC, Y2.FLOOR],
- [xC2, Y2.FLOOR_MATH],
- [jC2, Y2.FLOOR_PRECISE],
- [UC, Y2.GCD],
- [vC2, Y2.INT],
- [TC, Y2.LCM],
- [BC, Y2.LN],
- [IC, Y2.LOG],
- [FC, Y2.LOG10],
- [kC, Y2.MDETERM],
- [$C, Y2.MINVERSE],
- [YC, Y2.MMULT],
- [HC, Y2.MOD],
- [GC, Y2.MROUND],
- [QC, Y2.MULTINOMIAL],
- [WC, Y2.MUNIT],
- [qC, Y2.ODD],
- [KC2, Y2.PI],
- [XC, Y2.POWER],
- [ZC, Y2.PRODUCT],
- [zC, Y2.QUOTIENT],
- [JC, Y2.RADIANS],
- [e_, Y2.RAND],
- [t_, Y2.RANDARRAY],
- [r_, Y2.RANDBETWEEN],
- [n_, Y2.ROMAN],
- [s_, Y2.ROUND],
- [a_, Y2.ROUNDBANK],
- [i_, Y2.ROUNDDOWN],
- [o_, Y2.ROUNDUP],
- [u_, Y2.SEC],
- [c_, Y2.SECH],
- [f_, Y2.SERIESSUM],
- [l_, Y2.SEQUENCE],
- [h_, Y2.SIGN],
- [m_, Y2.SIN],
- [g_, Y2.SINH],
- [d_, Y2.SQRT],
- [C_, Y2.SQRTPI],
- [__, Y2.SUBTOTAL],
- [A_, Y2.SUM],
- [E_, Y2.SUMIF],
- [b_, Y2.SUMIFS],
- [y_, Y2.SUMPRODUCT],
- [R_, Y2.SUMSQ],
- [p_, Y2.SUMX2MY2],
- [V_, Y2.SUMX2PY2],
- [N_, Y2.SUMXMY2],
- [O_, Y2.TAN],
- [M_, Y2.TANH],
- [w_, Y2.TRUNC]
- ];
- var S_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- A(this, "_compareType", $.EQUALS);
- }
- setCompareType(e) {
- this._compareType = e;
- }
- calculate(e, t) {
- return e.isError() ? e : t.isError() ? t : e.compare(t, this._compareType);
- }
- };
- var Fa = class _Fa extends kt2 {
- constructor(e) {
- super("");
- A(this, "_values", []);
- this._values = e;
- }
- static create(e) {
- return new _Fa(e);
- }
- isCube() {
- return true;
- }
- dispose() {
- this._values.forEach((e) => {
- e.dispose();
- }), this._values = [];
- }
- sum() {
- const e = y2.create(0);
- return this._values.forEach((t) => {
- e.plus(t.sum());
- }), e;
- }
- max() {
- let e = y2.create(Number.NEGATIVE_INFINITY);
- return this._values.forEach((t) => {
- const r = t.max();
- e.isLessThan(r) && (e = r);
- }), e;
- }
- min() {
- let e = y2.create(Number.POSITIVE_INFINITY);
- return this._values.forEach((t) => {
- const r = t.max();
- e.isGreaterThan(r) && (e = r);
- }), e;
- }
- count() {
- const e = y2.create(0);
- return this._values.forEach((t) => {
- e.plus(t.count());
- }), e;
- }
- countA() {
- const e = y2.create(0);
- return this._values.forEach((t) => {
- e.plus(t.countA());
- }), e;
- }
- countBlank() {
- const e = y2.create(0);
- return this._values.forEach((t) => {
- e.plus(t.countBlank());
- }), e;
- }
- };
- var P_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- const n = e[r];
- if (n.isError())
- return n;
- if (!n.isArray())
- return g2.create(m2.VALUE);
- t.push(n);
- }
- return Fa.create(t);
- }
- };
- var L_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- return e.isError() ? e : t.isError() ? t : !t.isArray() && t.getValue() === 0 ? g2.create(m2.DIV_BY_ZERO) : e.divided(t);
- }
- };
- var x_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- return e.isError() ? e : t.isError() ? t : e.minus(t);
- }
- };
- var j_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- return e.isError() ? e : t.isError() ? t : e.multiply(t);
- }
- };
- var U_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- return e.isError() ? e : t.isError() ? t : e.plus(t);
- }
- };
- var v_ = [
- [S_, Te.COMPARE],
- [L_, Te.DIVIDED],
- [x_, Te.MINUS],
- [j_, Te.MULTIPLY],
- [U_, Te.PLUS],
- [P_, Te.CUBE]
- ];
- var T_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(0), r = y2.create(0);
- for (let o = 0; o < e.length; o++) {
- let u = e[o];
- if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
- return u;
- if (u.isArray()) {
- if (u = B_(u), u.isError())
- return u;
- if (e[o] = u, t = t.plus(u.sum()), t.isError())
- return t;
- r = r.plus(u.count());
- } else
- u.isNull() || (t = t.plus(u), r = r.plus(y2.create(1)));
- }
- if (r.getValue() === 0)
- return g2.create(m2.NUM);
- const n = t.divided(r);
- if (n.isError())
- return n;
- let s = y2.create(0);
- for (let o = 0; o < e.length; o++) {
- let u = e[o];
- if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
- return u;
- if (u.isArray()) {
- if (s = s.plus(u.minus(n).abs().sum()), s.isError())
- return s;
- } else
- u.isNull() || (s = s.plus(u.minus(n).abs()));
- }
- return s.divided(r);
- }
- };
- function B_(i) {
- const a2 = [];
- a2[0] = [];
- let e = null;
- return i.iterator((t, r, n) => {
- if (t != null && t.isError())
- return e = t, false;
- t != null && t.isNumber() && a2[0].push(t);
- }), e || tr(a2, 1, a2[0].length);
- }
- var I_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(0), r = y2.create(0);
- for (let n = 0; n < e.length; n++) {
- let s = e[n];
- if ((s.isString() || s.isBoolean()) && (s = s.convertToNumberObjectValue()), s.isError())
- return s;
- if (s.isArray()) {
- if (t = t.plus(s.sum()), t.isError())
- return t;
- r = r.plus(s.count());
- } else
- s.isNull() || (t = t.plus(s), r = r.plus(y2.create(1)));
- }
- return t.divided(r);
- }
- };
- var F_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 254);
- }
- // eslint-disable-next-line
- calculate(...e) {
- let t = false, r;
- e.length % 2 !== 0 && (t = true, r = g2.create(m2.NA));
- const n = [], s = [];
- for (let o = 0; o < e.length; o += 2) {
- const u = e[o], c = u.isArray() ? u.getRowCount() : 1, l2 = u.isArray() ? u.getColumnCount() : 1;
- for (let _ = 0; _ < c; _++)
- for (let C = 0; C < l2; C++) {
- const E2 = u.isArray() ? u.get(_, C) : u;
- if (E2.isError())
- return E2;
- if (t)
- continue;
- const b = E2.isNull() ? "" : E2.getValue();
- n.push(b);
- }
- if (o + 1 >= e.length)
- continue;
- const f2 = e[o + 1], h = f2.isArray() ? f2.getRowCount() : 1, d2 = f2.isArray() ? f2.getColumnCount() : 1;
- (h !== c || d2 !== l2) && (t = true, r = g2.create(m2.VALUE));
- for (let _ = 0; _ < h; _++)
- for (let C = 0; C < d2; C++) {
- const E2 = f2.isArray() ? f2.get(_, C) : f2;
- if (E2.isError())
- return E2;
- if (t)
- continue;
- const b = E2.isNull() ? "" : E2.getValue();
- s.push(b);
- }
- }
- return t ? r : this._getResult(n, s);
- }
- _getResult(e, t) {
- const r = e.length;
- let n = 0, s = 0;
- for (let u = 0; u < r; u++) {
- const c = e[u], l2 = t[u];
- if (!(typeof c != "number" && typeof l2 != "number")) {
- if (typeof c != "number" || typeof l2 != "number" || l2 < 0)
- return g2.create(m2.VALUE);
- n += c * l2, s += l2;
- }
- }
- if (s === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const o = n / s;
- return y2.create(o);
- }
- };
- var k_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(0), r = y2.create(0);
- for (let n = 0; n < e.length; n++) {
- let s = e[n];
- if ((s.isString() || s.isBoolean()) && (s = s.convertToNumberObjectValue()), s.isError())
- return s;
- if (s.isArray()) {
- if (s.iterator((o) => {
- if (o == null || o.isNull())
- return true;
- let u = o;
- if (u.isString() && (u = u.convertToNumberObjectValue(), u.isError() && (u = y2.create(0))), u.isBoolean() && (u = u.convertToNumberObjectValue()), u.isError())
- return t = u, false;
- t = t.plus(u), r = r.plus(y2.create(1));
- }), t.isError())
- return t;
- } else
- s.isNull() || (t = t.plus(s), r = r.plus(y2.create(1)));
- }
- return t.divided(r);
- }
- };
- var $_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", true);
- }
- calculate(e, t, r) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r != null && r.isError())
- return r;
- let n = e;
- n.isReferenceObject() && (n = n.toArrayValueObject()), n.isArray() || (n = tr([[n]], 1, 1));
- let s = t;
- return s.isReferenceObject() && (s = s.toArrayValueObject()), r && !(r != null && r.isReferenceObject()) ? g2.create(m2.NA) : (s = s, s.isArray() ? s.map((o) => this._handleSingleObject(n, o, r)) : this._handleSingleObject(n, s, r));
- }
- _handleSingleObject(e, t, r) {
- let n = $n(e, t);
- n = Yn(n, e, t);
- let s = r ? this._createRangeReferenceObject(r, e) : e;
- if (!s)
- return g2.create(m2.VALUE);
- if (s.isError())
- return s;
- s.isReferenceObject() && (s = s.toArrayValueObject()), s = s;
- const o = s.pick(n), u = o.sum(), c = o.count();
- return u.divided(c);
- }
- /**
- * Create reference object, starting from the first cell in the upper left corner, the height is rowCount and the width is columnCount
- * @param averageRange
- * @param rowCount
- * @param columnCount
- * @returns
- */
- _createRangeReferenceObject(e, t) {
- const r = e.getRowCount(), n = e.getColumnCount(), s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- if (r === s && n === o)
- return e;
- const { startRow: u, startColumn: c } = e.getRangePosition(), l2 = {
- startRow: u,
- startColumn: c,
- endRow: u + s - 1,
- endColumn: c + o - 1
- };
- return this.createReferenceObject(e, l2);
- }
- };
- var Y_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return g2.create(m2.NA);
- if (!e.isArray() || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
- return g2.create(m2.VALUE);
- const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
- if (s)
- return s;
- const o = Ir(t, r, n, true);
- return this._aggregateResults(e, o);
- }
- _aggregateResults(e, t) {
- const r = t.map((s) => s.map((o) => {
- const u = e.pick(o), c = u.sum(), l2 = u.count();
- return c.divided(l2);
- })), n = {
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q2.create(n);
- }
- };
- var H_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = s != null ? s : y2.create(0), c = o != null ? o : y2.create(1);
- u.isNull() && (u = y2.create(0)), c.isNull() && (c = y2.create(1));
- const l2 = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f2 = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l2, f2, e, g2.create(m2.NA)), d2 = O(l2, f2, t, g2.create(m2.NA)), _ = O(l2, f2, r, g2.create(m2.NA)), C = O(l2, f2, n, g2.create(m2.NA)), E2 = O(l2, f2, u, g2.create(m2.NA)), b = O(l2, f2, c, g2.create(m2.NA)), R = h.mapValue((p2, N2, M2) => {
- const w = d2.get(N2, M2), D2 = _.get(N2, M2), S2 = C.get(N2, M2), P = E2.get(N2, M2), U2 = b.get(N2, M2);
- return this._handleSignleObject(p2, w, D2, S2, P, U2);
- });
- return l2 === 1 && f2 === 1 ? R.get(0, 0) : R;
- }
- _handleSignleObject(e, t, r, n, s, o) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- if (n.isError())
- return n;
- if (s.isError())
- return s;
- if (o.isError())
- return o;
- const { isError: u, errorObject: c, variants: l2 } = I2(e, t, r, n, s, o);
- if (u)
- return c;
- const [f2, h, d2, _, C, E2] = l2, b = +f2.getValue(), R = +h.getValue(), p2 = +d2.getValue(), N2 = +_.getValue(), M2 = +C.getValue(), w = +E2.getValue();
- if (R <= 0 || p2 <= 0 || b < M2 || b > w || M2 === w)
- return g2.create(m2.NUM);
- let D2;
- return N2 ? D2 = Do((b - M2) / (w - M2), R, p2) : D2 = em((b - M2) / (w - M2), R, p2) / (w - M2), y2.create(D2);
- }
- };
- var G_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- let s = n != null ? n : r;
- s.isNull() && (s = r);
- const o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, t, g2.create(m2.NA)), f2 = O(o, u, r, g2.create(m2.NA)), h = O(o, u, s, g2.create(m2.NA)), d2 = c.mapValue((_, C, E2) => {
- const b = l2.get(C, E2), R = f2.get(C, E2), p2 = h.get(C, E2);
- return _.isError() ? _ : b.isError() ? b : R.isError() ? R : p2.isError() ? p2 : this._handleSignleObject(_, b, R, p2);
- });
- return o === 1 && u === 1 ? d2.get(0, 0) : d2;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
- if (s)
- return o;
- const [c, l2, f2, h] = u, d2 = Math.floor(+c.getValue()), _ = +l2.getValue(), C = Math.floor(+f2.getValue()), E2 = Math.floor(+h.getValue());
- if (d2 < 0 || _ < 0 || _ > 1 || C < 0 || C > d2 || E2 < 0 || E2 < C || E2 > d2)
- return g2.create(m2.NUM);
- let b = 0;
- for (let R = C; R <= E2; R++)
- b += Da(R, d2, _);
- return y2.create(b);
- }
- };
- var Q_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = +l2.getValue();
- if (f2 < 0 || h < 1 || h > 10 ** 10)
- return g2.create(m2.NUM);
- let _;
- return d2 ? _ = Sa(f2, h) : _ = tm(f2, h), y2.create(_);
- }
- };
- var W_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (c < 0 || c > 1 || l2 < 1 || l2 > 10 ** 10)
- return g2.create(m2.NUM);
- const f2 = Po(c, l2);
- return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
- }
- };
- var q_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- if (f2.isError())
- return f2;
- if (_.isError())
- return _;
- if (C.isError())
- return C;
- const { isError: E2, errorObject: b, variants: R } = I2(f2, _, C);
- if (E2)
- return b;
- const [p2, N2, M2] = R, w = +p2.getValue(), D2 = +N2.getValue(), S2 = Math.floor(+M2.getValue());
- if (w <= 0 || w >= 1 || D2 <= 0 || S2 < 1)
- return g2.create(m2.NUM);
- if (S2 === 1)
- return g2.create(m2.DIV_BY_ZERO);
- const P = Math.abs(qn(w / 2, S2 - 1) * D2 / Math.sqrt(S2));
- return y2.create(P);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- };
- var K_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if (r * n === 1 || s * o === 1)
- return u.isNull() || c.isNull() ? g2.create(m2.VALUE) : g2.create(m2.DIV_BY_ZERO);
- if (r * n !== s * o)
- return g2.create(m2.NA);
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
- }
- _getResult(e, t) {
- const r = e.length;
- let n = 0, s = 0;
- for (let d2 = 0; d2 < r; d2++)
- n += e[d2], s += t[d2];
- const o = n / r, u = s / r;
- let c = 0, l2 = 0, f2 = 0;
- for (let d2 = 0; d2 < r; d2++) {
- const _ = e[d2] - o, C = t[d2] - u;
- c += _ * C, l2 += _ ** 2, f2 += C ** 2;
- }
- const h = Math.sqrt(l2 * f2);
- return h === 0 ? g2.create(m2.DIV_BY_ZERO) : y2.create(c / h);
- }
- };
- var X_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(0);
- for (let r = 0; r < e.length; r++) {
- const n = e[r];
- n.isError() || (n.isArray() ? t = t.plus(n.count()) : n.isString() ? n.convertToNumberObjectValue().isError() || (t = t.plus(y2.create(1))) : n.isNull() || (t = t.plus(y2.create(1))));
- }
- return t;
- }
- };
- var Z_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(0);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (n.isError()) {
- t = t.plus(y2.create(1));
- continue;
- }
- n.isArray() ? (n = n.countA(), t = t.plus(n)) : n.isNull() || (t = t.plus(y2.create(1)));
- }
- return t;
- }
- };
- var z_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.getValue() === "" || e.isNull() ? y2.create(1) : e.isArray() ? e.countBlank() : y2.create(0);
- }
- };
- var J_ = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- return e.isError() || t.isError() ? g2.create(m2.NA) : e.isArray() ? t.isArray() ? t.mapValue((r) => this._handleSingleObject(e, r)) : this._handleSingleObject(e, t) : g2.create(m2.VALUE);
- }
- _handleSingleObject(e, t) {
- let r = $n(e, t);
- r = Yn(r, e, t);
- const n = e.pick(r);
- return this._countA(n);
- }
- _countA(e) {
- let t = y2.create(0);
- return e.iterator((r) => {
- if (r == null)
- return true;
- t = t.plusBy(1);
- }), t;
- }
- };
- var eA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- if (e.length % 2 !== 0 || e.some((o, u) => u % 2 === 0 && !o.isArray()))
- return g2.create(m2.VALUE);
- const { maxRowLength: t, maxColumnLength: r } = Nr(e), n = Br(e, e[0], t, r);
- if (n)
- return n;
- const s = Ir(e, t, r, true);
- return this._aggregateResults(s);
- }
- _aggregateResults(e) {
- const t = e.map((n) => n.map((s) => tA(s))), r = {
- calculateValueList: t,
- rowCount: t.length,
- columnCount: t[0].length,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q2.create(r);
- }
- };
- function tA(i) {
- let a2 = 0;
- return i.iterator((e) => {
- e != null && e.isBoolean() && e.getValue() === true && a2++;
- }), y2.create(a2);
- }
- var rA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return g2.create(m2.VALUE);
- if (r * n !== s * o)
- return g2.create(m2.NA);
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
- }
- _getResult(e, t) {
- if (e.length <= 1)
- return g2.create(m2.DIV_BY_ZERO);
- const r = e.length;
- let n = 0, s = 0;
- for (let l2 = 0; l2 < r; l2++)
- n += e[l2], s += t[l2];
- const o = n / r, u = s / r;
- let c = 0;
- for (let l2 = 0; l2 < r; l2++) {
- const f2 = e[l2] - o, h = t[l2] - u;
- c += f2 * h;
- }
- return y2.create(c / (r - 1));
- }
- };
- var nA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- let r = 0, n = true;
- for (let u = 0; u < e.length; u++) {
- const c = e[u];
- if (c.isArray()) {
- let l2 = false, f2 = g2.create(m2.VALUE);
- if (c.iterator((h) => {
- const d2 = this._handleSingleObject(h);
- if (d2.isError())
- return l2 = true, f2 = d2, false;
- if (d2.isNull())
- return true;
- const _ = d2.getValue();
- t.push(_), r += _, n = false;
- }), l2)
- return f2;
- } else {
- const l2 = this._handleSingleObject(c);
- if (l2.isError())
- return l2;
- if (l2.isNull())
- continue;
- const f2 = l2.getValue();
- t.push(f2), r += f2, n = false;
- }
- }
- if (n)
- return g2.create(m2.NUM);
- const s = r / t.length;
- let o = 0;
- for (let u = 0; u < t.length; u++)
- o += (t[u] - s) ** 2;
- return y2.create(o);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull() || e.isBoolean())
- return ie.create();
- const t = e.getValue();
- return DC(t) ? y2.create(+t) : ie.create();
- }
- };
- var sA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
- if (s)
- return o;
- const [c, l2, f2, h] = u, d2 = +c.getValue(), _ = Math.floor(+l2.getValue()), C = Math.floor(+f2.getValue()), E2 = +h.getValue();
- if (d2 < 0 || _ < 1 || _ > 10 ** 10 || C < 1 || C > 10 ** 10)
- return g2.create(m2.NUM);
- let b;
- return E2 ? b = Pa(d2, _, C) : b = rm(d2, _, C), Number.isNaN(b) || !Number.isFinite(b) ? g2.create(m2.NUM) : y2.create(b);
- }
- };
- var aA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = Math.floor(+l2.getValue());
- if (f2 < 0 || f2 > 1 || h < 1 || h > 10 ** 10 || d2 < 1 || d2 > 10 ** 10)
- return g2.create(m2.NUM);
- const _ = Lo(f2, h, d2);
- return Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
- }
- };
- var iA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = s.getValue();
- if (o <= -1 || o >= 1)
- return g2.create(m2.NUM);
- const u = Math.log((1 + o) / (1 - o)) / 2;
- return y2.create(u);
- }
- };
- var oA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue(), u = Math.exp(2 * o) - 1, c = Math.exp(2 * o) + 1;
- return !Number.isFinite(u) && u > 0 && !Number.isFinite(c) && c > 0 ? y2.create(1) : y2.create(u / c);
- }
- };
- var Li = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t.isArray() ? t.getRowCount() : 1, s = t.isArray() ? t.getColumnCount() : 1, o = r.isArray() ? r.getRowCount() : 1, u = r.isArray() ? r.getColumnCount() : 1;
- let c = t;
- t.isArray() && n === 1 && s === 1 && (c = t.get(0, 0));
- let l2 = r;
- return r.isArray() && o === 1 && u === 1 && (l2 = r.get(0, 0)), e.isArray() ? e.mapValue(
- (f2) => this._handleSignleObject(f2, c, l2, n, s, o, u)
- ) : this._handleSignleObject(e, c, l2, n, s, o, u);
- }
- _handleSignleObject(e, t, r, n, s, o, u) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- let c = e;
- if (e.isString() && (c = e.convertToNumberObjectValue()), c.isError())
- return c;
- const l2 = +c.getValue();
- if ((n * s === 1 || o * u === 1) && (t.isNull() || r.isNull()))
- return g2.create(m2.VALUE);
- if (n * s !== o * u)
- return g2.create(m2.NA);
- const {
- isError: f2,
- errorObject: h,
- array1Values: d2,
- array2Values: _,
- noCalculate: C
- } = Je(
- t,
- r,
- n * s,
- s,
- u
- );
- if (f2)
- return h;
- if (C)
- return g2.create(m2.DIV_BY_ZERO);
- const E2 = xo(l2, d2, _);
- return Number.isFinite(E2) ? y2.create(E2) : g2.create(m2.DIV_BY_ZERO);
- }
- };
- var uA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, values: s } = this._getValues(e);
- if (r)
- return n;
- if (e.isNull() || t.isNull())
- return g2.create(m2.VALUE);
- let { values: o } = this._getValues(t, true);
- o.length === 0 && (o = [0]);
- const u = this._getNewBinsArrayValues(o), c = new Array(u.length).fill(0);
- for (let l2 = 0; l2 < s.length; l2++) {
- const f2 = s[l2], h = u.findIndex((d2) => f2 > d2.start && f2 <= d2.end);
- c[h]++;
- }
- return q2.createByArray(c.map((l2) => [l2]));
- }
- _getValues(e, t = false) {
- const r = [], n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
- for (let o = 0; o < n; o++)
- for (let u = 0; u < s; u++) {
- const c = e.isArray() ? e.get(o, u) : e;
- if (c.isError()) {
- if (!t)
- return {
- isError: true,
- errorObject: c,
- values: r
- };
- continue;
- }
- if (c.isNull() || c.isBoolean())
- continue;
- const l2 = c.getValue();
- DC(l2) && r.push(+l2);
- }
- return {
- isError: false,
- errorObject: null,
- values: r
- };
- }
- _getNewBinsArrayValues(e) {
- const t = e.map((n, s) => ({
- value: n,
- index: s
- })).sort((n, s) => n.value - s.value), r = [];
- for (let n = 0; n < t.length; n++) {
- const s = t[n].index;
- if (n === 0) {
- r[s] = {
- start: -1 / 0,
- end: t[n].value
- };
- continue;
- }
- r[s] = {
- start: t[n - 1].value,
- end: t[n].value
- };
- }
- return r.push({
- start: t[t.length - 1].value,
- end: 1 / 0
- }), r;
- }
- };
- var v = ((i) => (i.AVEDEV = "AVEDEV", i.AVERAGE = "AVERAGE", i.AVERAGE_WEIGHTED = "AVERAGE.WEIGHTED", i.AVERAGEA = "AVERAGEA", i.AVERAGEIF = "AVERAGEIF", i.AVERAGEIFS = "AVERAGEIFS", i.BETA_DIST = "BETA.DIST", i.BETA_INV = "BETA.INV", i.BINOM_DIST = "BINOM.DIST", i.BINOM_DIST_RANGE = "BINOM.DIST.RANGE", i.BINOM_INV = "BINOM.INV", i.CHISQ_DIST = "CHISQ.DIST", i.CHISQ_DIST_RT = "CHISQ.DIST.RT", i.CHISQ_INV = "CHISQ.INV", i.CHISQ_INV_RT = "CHISQ.INV.RT", i.CHISQ_TEST = "CHISQ.TEST", i.CONFIDENCE_NORM = "CONFIDENCE.NORM", i.CONFIDENCE_T = "CONFIDENCE.T", i.CORREL = "CORREL", i.COUNT = "COUNT", i.COUNTA = "COUNTA", i.COUNTBLANK = "COUNTBLANK", i.COUNTIF = "COUNTIF", i.COUNTIFS = "COUNTIFS", i.COVARIANCE_P = "COVARIANCE.P", i.COVARIANCE_S = "COVARIANCE.S", i.DEVSQ = "DEVSQ", i.EXPON_DIST = "EXPON.DIST", i.F_DIST = "F.DIST", i.F_DIST_RT = "F.DIST.RT", i.F_INV = "F.INV", i.F_INV_RT = "F.INV.RT", i.F_TEST = "F.TEST", i.FISHER = "FISHER", i.FISHERINV = "FISHERINV", i.FORECAST = "FORECAST", i.FORECAST_ETS = "FORECAST.ETS", i.FORECAST_ETS_CONFINT = "FORECAST.ETS.CONFINT", i.FORECAST_ETS_SEASONALITY = "FORECAST.ETS.SEASONALITY", i.FORECAST_ETS_STAT = "FORECAST.ETS.STAT", i.FORECAST_LINEAR = "FORECAST.LINEAR", i.FREQUENCY = "FREQUENCY", i.GAMMA = "GAMMA", i.GAMMA_DIST = "GAMMA.DIST", i.GAMMA_INV = "GAMMA.INV", i.GAMMALN = "GAMMALN", i.GAMMALN_PRECISE = "GAMMALN.PRECISE", i.GAUSS = "GAUSS", i.GEOMEAN = "GEOMEAN", i.GROWTH = "GROWTH", i.HARMEAN = "HARMEAN", i.HYPGEOM_DIST = "HYPGEOM.DIST", i.INTERCEPT = "INTERCEPT", i.KURT = "KURT", i.LARGE = "LARGE", i.LINEST = "LINEST", i.LOGEST = "LOGEST", i.LOGNORM_DIST = "LOGNORM.DIST", i.LOGNORM_INV = "LOGNORM.INV", i.MARGINOFERROR = "MARGINOFERROR", i.MAX = "MAX", i.MAXA = "MAXA", i.MAXIFS = "MAXIFS", i.MEDIAN = "MEDIAN", i.MIN = "MIN", i.MINA = "MINA", i.MINIFS = "MINIFS", i.MODE_MULT = "MODE.MULT", i.MODE_SNGL = "MODE.SNGL", i.NEGBINOM_DIST = "NEGBINOM.DIST", i.NORM_DIST = "NORM.DIST", i.NORM_INV = "NORM.INV", i.NORM_S_DIST = "NORM.S.DIST", i.NORM_S_INV = "NORM.S.INV", i.PEARSON = "PEARSON", i.PERCENTILE_EXC = "PERCENTILE.EXC", i.PERCENTILE_INC = "PERCENTILE.INC", i.PERCENTRANK_EXC = "PERCENTRANK.EXC", i.PERCENTRANK_INC = "PERCENTRANK.INC", i.PERMUT = "PERMUT", i.PERMUTATIONA = "PERMUTATIONA", i.PHI = "PHI", i.POISSON_DIST = "POISSON.DIST", i.PROB = "PROB", i.QUARTILE_EXC = "QUARTILE.EXC", i.QUARTILE_INC = "QUARTILE.INC", i.RANK_AVG = "RANK.AVG", i.RANK_EQ = "RANK.EQ", i.RSQ = "RSQ", i.SKEW = "SKEW", i.SKEW_P = "SKEW.P", i.SLOPE = "SLOPE", i.SMALL = "SMALL", i.STANDARDIZE = "STANDARDIZE", i.STDEV_P = "STDEV.P", i.STDEV_S = "STDEV.S", i.STDEVA = "STDEVA", i.STDEVPA = "STDEVPA", i.STEYX = "STEYX", i.T_DIST = "T.DIST", i.T_DIST_2T = "T.DIST.2T", i.T_DIST_RT = "T.DIST.RT", i.T_INV = "T.INV", i.T_INV_2T = "T.INV.2T", i.T_TEST = "T.TEST", i.TREND = "TREND", i.TRIMMEAN = "TRIMMEAN", i.VAR_P = "VAR.P", i.VAR_S = "VAR.S", i.VARA = "VARA", i.VARPA = "VARPA", i.WEIBULL_DIST = "WEIBULL.DIST", i.Z_TEST = "Z.TEST", i))(v || {});
- var cA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (o === 0 || o < 0 && o % 1 === 0)
- return g2.create(m2.NUM);
- const u = on(o);
- return Number.isNaN(u) || !Number.isFinite(u) ? g2.create(m2.NUM) : y2.create(u);
- }
- };
- var xi = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (o <= 0)
- return g2.create(m2.NUM);
- const u = ct(o);
- return Math.abs(u) < 1e-15 ? y2.create(0) : y2.create(u);
- }
- };
- var lA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue(), u = kr(o, 0, 1) - 0.5;
- return y2.create(u);
- }
- };
- var fA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 1, r = 0, n = false;
- for (let o = 0; o < e.length; o++) {
- const u = e[o];
- if (u.isArray()) {
- let c = false, l2 = g2.create(m2.VALUE);
- if (u.iterator((f2) => {
- if (f2 != null && f2.isError())
- return c = true, l2 = f2, false;
- if (f2 != null && f2.isNull() || f2 != null && f2.isBoolean())
- return true;
- const h = f2.getValue();
- if (!DC(h))
- return true;
- +h <= 0 && (n = true), t *= +h, r++;
- }), c)
- return l2;
- } else {
- if (u.isError())
- return u;
- if (u.isString()) {
- const l2 = u.convertToNumberObjectValue();
- if (l2.isError())
- return l2;
- }
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- if (!DC(c))
- continue;
- +c <= 0 && (n = true), t *= +c, r++;
- }
- }
- if (r === 0 || n)
- return g2.create(m2.NUM);
- const s = t ** (1 / r);
- return y2.create(s);
- }
- };
- var hA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o } = Kn(e, t, r);
- if (s)
- return o;
- const u = dt(e);
- if (u instanceof g2)
- return u;
- const c = this._getKnownXsValues(u, t);
- if (c instanceof g2)
- return c;
- const l2 = this._getNewXsValues(c, r);
- if (l2 instanceof g2)
- return l2;
- let f2 = n != null ? n : T2.create(true);
- if (f2.isArray() && (f2 = f2.get(0, 0)), f2.isString() && (f2 = f2.convertToNumberObjectValue()), f2.isError())
- return f2;
- const h = +f2.getValue();
- return this._getResult(u, c, l2, h);
- }
- _getResult(e, t, r, n) {
- return e.length === 1 && t.length > 1 || e[0].length === 1 && t[0].length > 1 ? e.length === 1 && t.length > 1 && (n ? t.length + 1 : t.length) > e[0].length || e[0].length === 1 && t[0].length > 1 && (n ? t[0].length + 1 : t[0].length) > e.length ? g2.create(m2.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
- }
- _getResultByMultipleVariables(e, t, r, n) {
- const s = e.length === 1 && e[0].length > 1, o = zn(e, t, r, n, true);
- if (o instanceof g2)
- return o;
- const { coefficients: u, newX: c } = o, l2 = u[0].length, f2 = u[0][l2 - 1];
- let h = [];
- for (let d2 = 0; d2 < c.length; d2++) {
- h[d2] = [];
- let _ = f2;
- for (let C = l2 - 2; C >= 0; C--)
- _ *= u[0][l2 - 2 - C] ** c[d2][C];
- h[d2].push(_);
- }
- return s && (h = mt(h)), q2.createByArray(h);
- }
- _getResultBySimpleVariables(e, t, r, n) {
- const s = e.flat(), o = t.flat(), { slope: u, intercept: c } = Zn(o, s, n, true), l2 = r.map((f2) => f2.map((h) => c * u ** h));
- return q2.createByArray(l2);
- }
- _getKnownXsValues(e, t) {
- return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
- }
- _getNewXsValues(e, t) {
- return !t || t.isNull() ? e : dt(t);
- }
- };
- var mA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 0, r = 0, n = false;
- for (let o = 0; o < e.length; o++) {
- const u = e[o];
- if (u.isArray()) {
- let c = false, l2 = g2.create(m2.VALUE);
- if (u.iterator((f2) => {
- if (f2 != null && f2.isError())
- return c = true, l2 = f2, false;
- if (f2 != null && f2.isNull() || f2 != null && f2.isBoolean())
- return true;
- const h = f2.getValue();
- if (!DC(h))
- return true;
- +h <= 0 && (n = true), t += 1 / +h, r++;
- }), c)
- return l2;
- } else {
- if (u.isError())
- return u;
- if (u.isString()) {
- const l2 = u.convertToNumberObjectValue();
- if (l2.isError())
- return l2;
- }
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- if (!DC(c))
- continue;
- +c <= 0 && (n = true), t += 1 / +c, r++;
- }
- }
- if (r === 0)
- return g2.create(m2.NA);
- if (n)
- return g2.create(m2.NUM);
- const s = r / t;
- return y2.create(s);
- }
- };
- var gA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, t, g2.create(m2.NA)), f2 = O(o, u, r, g2.create(m2.NA)), h = O(o, u, n, g2.create(m2.NA)), d2 = O(o, u, s, g2.create(m2.NA)), _ = c.mapValue((C, E2, b) => {
- const R = l2.get(E2, b), p2 = f2.get(E2, b), N2 = h.get(E2, b), M2 = d2.get(E2, b);
- return C.isError() ? C : R.isError() ? R : p2.isError() ? p2 : N2.isError() ? N2 : M2.isError() ? M2 : this._handleSignleObject(C, R, p2, N2, M2);
- });
- return o === 1 && u === 1 ? _.get(0, 0) : _;
- }
- _handleSignleObject(e, t, r, n, s) {
- const { isError: o, errorObject: u, variants: c } = I2(e, t, r, n, s);
- if (o)
- return u;
- const [l2, f2, h, d2, _] = c, C = Math.floor(+l2.getValue()), E2 = Math.floor(+f2.getValue()), b = Math.floor(+h.getValue()), R = Math.floor(+d2.getValue()), p2 = +_.getValue();
- if (C < 0 || C > E2 || C > b || C < E2 - R + b || E2 <= 0 || E2 > R || b <= 0 || b > R || R <= 0)
- return g2.create(m2.NUM);
- let N2;
- return p2 ? N2 = um(C, E2, b, R) : N2 = xa(C, E2, b, R), Number.isNaN(N2) && (N2 = 0), y2.create(N2);
- }
- };
- var dA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if (r * n === 1 || s * o === 1)
- return u.isNull() || c.isNull() ? g2.create(m2.VALUE) : g2.create(m2.DIV_BY_ZERO);
- if (r * n !== s * o)
- return g2.create(m2.NA);
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
- }
- _getResult(e, t) {
- const r = xo(0, e, t);
- return Number.isFinite(r) ? y2.create(r) : g2.create(m2.DIV_BY_ZERO);
- }
- };
- var CA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- let r = 0;
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (s.isError())
- return s;
- if (s.isString()) {
- const c = s.convertToNumberObjectValue();
- if (c.isError())
- return c;
- }
- const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
- for (let c = 0; c < o; c++)
- for (let l2 = 0; l2 < u; l2++) {
- const f2 = s.isArray() ? s.get(c, l2) : s;
- if (f2.isError())
- return f2;
- if (f2.isNull() || f2.isBoolean())
- continue;
- const h = f2.getValue();
- DC(h) && (t.push(+h), r += +h);
- }
- }
- return t.length <= 3 ? g2.create(m2.DIV_BY_ZERO) : this._getResult(t, r);
- }
- _getResult(e, t) {
- const r = e.length, n = t / r;
- let s = 0;
- for (let l2 = 0; l2 < r; l2++)
- s += (e[l2] - n) ** 2;
- const o = Math.sqrt(s / (r - 1));
- if (o === 0)
- return g2.create(m2.DIV_BY_ZERO);
- let u = 0;
- for (let l2 = 0; l2 < r; l2++)
- u += ((e[l2] - n) / o) ** 4;
- const c = r * (r + 1) / ((r - 1) * (r - 2) * (r - 3)) * u - 3 * (r - 1) ** 2 / ((r - 2) * (r - 3));
- return y2.create(c);
- }
- };
- var _A = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g2)
- return e;
- const { isError: r, errorObject: n, variants: s } = I2(t);
- if (r)
- return n;
- const [o] = s;
- let u = +o.getValue();
- return u < 1 || u > e.length ? g2.create(m2.NUM) : (u = Math.ceil(u), y2.create(e[u - 1]));
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean() || u.isString())
- continue;
- const c = u.getValue();
- DC(c) && n.push(+c);
- }
- return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => o - s);
- }
- };
- var AA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o } = Kn(e, t);
- if (s)
- return o;
- const u = dt(e);
- if (u instanceof g2)
- return u;
- const c = this._getKnownXsValues(u, t);
- if (c instanceof g2)
- return c;
- let l2 = r != null ? r : T2.create(true);
- l2.isArray() && (l2 = l2.get(0, 0));
- let f2 = n != null ? n : T2.create(false);
- f2.isArray() && (f2 = f2.get(0, 0));
- const { isError: h, errorObject: d2, variants: _ } = I2(l2, f2);
- if (h)
- return d2;
- const [C, E2] = _;
- return this._getResult(u, c, +C.getValue(), +E2.getValue());
- }
- _getResult(e, t, r, n) {
- return e.length === 1 && t.length > 1 || e[0].length === 1 && t[0].length > 1 ? e.length === 1 && t.length > 1 && (r ? t.length + 1 : t.length) > e[0].length || e[0].length === 1 && t[0].length > 1 && (r ? t[0].length + 1 : t[0].length) > e.length ? g2.create(m2.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
- }
- _getResultByMultipleVariables(e, t, r, n) {
- const s = zn(e, t, t, r, false);
- if (s instanceof g2)
- return s;
- const { coefficients: o, X: u, XTXInverse: c } = s;
- let l2 = [];
- if (n) {
- const f2 = e.flat(), h = f2.length, d2 = r ? f2.reduce((x2, F) => x2 + F, 0) / h : 0, _ = c.length, C = h - _, E2 = o[0].length, b = new Array(E2 - 2).fill(m2.NA), R = o[0][E2 - 1], p2 = [];
- for (let x2 = 0; x2 < u.length; x2++) {
- let F = R;
- for (let W2 = E2 - 2; W2 >= 0; W2--)
- F += o[0][E2 - 2 - W2] * u[x2][W2];
- p2.push(F);
- }
- let N2 = 0, M2 = 0;
- for (let x2 = 0; x2 < h; x2++)
- N2 += (f2[x2] - d2) ** 2, M2 += (f2[x2] - p2[x2]) ** 2;
- const w = N2 - M2, D2 = N2 === 0 ? 0 : w / N2, S2 = [];
- for (let x2 = _ - 1; x2 >= 0; x2--) {
- const F = C > 0 ? Math.sqrt(M2 / C * c[x2][x2]) : 0;
- S2.push(F);
- }
- if (r) {
- const x2 = S2.shift();
- S2.push(x2);
- } else
- S2.push(m2.NA);
- const P = C > 0 ? Math.sqrt(M2 / C) : 0, U2 = C > 0 ? w / (E2 - 1) / (M2 / C) : m2.NUM;
- l2 = [
- o[0],
- // [mn, mn-1, ..., m1, b]
- [...S2],
- // [sen, sen-1, ..., se1, seb]
- [D2, P, ...b],
- // [r2, sey]
- [U2, C, ...b],
- // [F, df]
- [w, M2, ...b]
- // [ssreg, ssresid]
- ];
- } else
- l2 = [
- o[0]
- // [mn, mn-1, ..., m1, b]
- ];
- return q2.createByArray(l2);
- }
- _getResultBySimpleVariables(e, t, r, n) {
- const s = e.flat(), o = t.flat(), { slope: u, intercept: c } = Zn(o, s, r, false);
- if (Number.isNaN(u))
- return g2.create(m2.NA);
- let l2 = [];
- if (n) {
- const f2 = s.length;
- let h = 0, d2 = 0, _ = f2 - 1;
- if (r) {
- let S2 = 0, P = 0;
- for (let U2 = 0; U2 < f2; U2++)
- S2 += s[U2], P += o[U2];
- h = S2 / f2, d2 = P / f2, _ = f2 - 2;
- }
- let C = 0, E2 = 0, b = 0;
- for (let S2 = 0; S2 < f2; S2++)
- C += (s[S2] - h) ** 2, E2 += (s[S2] - (u * o[S2] + c)) ** 2, b += (o[S2] - d2) ** 2;
- const R = C - E2, p2 = R === C ? 1 : R / C;
- let N2 = 0, M2 = 0, w = 0;
- _ > 0 && (b > 0 && (N2 = Math.sqrt(E2 / _ / b), M2 = Math.sqrt(E2 / _ * (1 / f2 + d2 ** 2 / b))), w = Math.sqrt(E2 / _));
- const D2 = _ > 0 ? R / 1 / (E2 / _) : m2.NUM;
- r || (M2 = m2.NA), l2 = [
- [u, c],
- // [m, b]
- [N2, M2],
- // [se, seb]
- [p2, w],
- // [r2, sey]
- [D2, _],
- // [F, df]
- [R, E2]
- // [ssreg, ssresid]
- ];
- } else
- l2 = [
- [u, c]
- // [m, b]
- ];
- return q2.createByArray(l2);
- }
- _getKnownXsValues(e, t) {
- return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
- }
- };
- var EA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o } = Kn(e, t);
- if (s)
- return o;
- const u = dt(e);
- if (u instanceof g2)
- return u;
- const c = this._getKnownXsValues(u, t);
- if (c instanceof g2)
- return c;
- let l2 = r != null ? r : T2.create(true);
- l2.isArray() && (l2 = l2.get(0, 0));
- let f2 = n != null ? n : T2.create(false);
- f2.isArray() && (f2 = f2.get(0, 0));
- const { isError: h, errorObject: d2, variants: _ } = I2(l2, f2);
- if (h)
- return d2;
- const [C, E2] = _;
- return this._getResult(u, c, +C.getValue(), +E2.getValue());
- }
- _getResult(e, t, r, n) {
- return e.length === 1 && t.length > 1 || e[0].length === 1 && t[0].length > 1 ? e.length === 1 && t.length > 1 && (r ? t.length + 1 : t.length) > e[0].length || e[0].length === 1 && t[0].length > 1 && (r ? t[0].length + 1 : t[0].length) > e.length ? g2.create(m2.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
- }
- // eslint-disable-next-line max-lines-per-function
- _getResultByMultipleVariables(e, t, r, n) {
- const s = zn(e, t, t, r, true);
- if (s instanceof g2)
- return s;
- const { coefficients: o, Y: u, X: c, XTXInverse: l2 } = s;
- let f2 = [];
- if (n) {
- const h = u.flat(), d2 = h.length, _ = r ? h.reduce((F, W2) => F + W2, 0) / d2 : 0, C = l2.length, E2 = d2 - C, b = o[0].length, R = new Array(b - 2).fill(m2.NA), p2 = o[0][b - 1], N2 = [];
- for (let F = 0; F < c.length; F++) {
- let W2 = p2;
- for (let ne = b - 2; ne >= 0; ne--)
- W2 *= o[0][b - 2 - ne] ** c[F][ne];
- N2.push(Math.log(W2));
- }
- let M2 = 0, w = 0;
- for (let F = 0; F < d2; F++)
- M2 += (h[F] - _) ** 2, !(!r && !Number.isFinite(N2[F])) && (w += (h[F] - N2[F]) ** 2);
- Number.isFinite(w) || (w = 0);
- const D2 = M2 - w, S2 = M2 === 0 ? 0 : D2 / M2, P = [];
- for (let F = C - 1; F >= 0; F--) {
- const W2 = E2 > 0 ? Math.sqrt(w / E2 * l2[F][F]) : 0;
- P.push(W2);
- }
- if (r) {
- const F = P.shift();
- P.push(F);
- } else
- P.push(m2.NA);
- const U2 = E2 > 0 ? Math.sqrt(w / E2) : 0, x2 = E2 > 0 ? D2 / (b - 1) / (w / E2) : m2.NUM;
- f2 = [
- o[0],
- // [mn, mn-1, ..., m1, b]
- [...P],
- // [sen, sen-1, ..., se1, seb]
- [S2, U2, ...R],
- // [r2, sey]
- [x2, E2, ...R],
- // [F, df]
- [D2, w, ...R]
- // [ssreg, ssresid]
- ];
- } else
- f2 = [
- o[0]
- // [mn, mn-1, ..., m1, b]
- ];
- return q2.createByArray(f2);
- }
- _getResultBySimpleVariables(e, t, r, n) {
- const s = e.flat(), o = t.flat(), { slope: u, intercept: c, Y: l2 } = Zn(o, s, r, true);
- if (Number.isNaN(u))
- return g2.create(m2.NA);
- let f2 = [];
- if (n) {
- const h = l2.length;
- let d2 = 0, _ = 0, C = h - 1;
- if (r) {
- let P = 0, U2 = 0;
- for (let x2 = 0; x2 < h; x2++)
- P += l2[x2], U2 += o[x2];
- d2 = P / h, _ = U2 / h, C = h - 2;
- }
- let E2 = 0, b = 0, R = 0;
- for (let P = 0; P < h; P++)
- E2 += (l2[P] - d2) ** 2, b += (l2[P] - Math.log(c * u ** o[P])) ** 2, R += (o[P] - _) ** 2;
- const p2 = E2 - b, N2 = E2 === 0 ? 0 : p2 / E2;
- let M2 = 0, w = 0, D2 = 0, S2 = 0;
- C > 0 && (R > 0 && (M2 = Math.sqrt(b / C / R), w = Math.sqrt(b / C * (1 / h + _ ** 2 / R))), D2 = Math.sqrt(b / C), S2 = p2 / 1 / (b / C)), r || (w = m2.NA), f2 = [
- [u, c],
- // [m, b]
- [M2, w],
- // [se, seb]
- [N2, D2],
- // [r2, sey]
- [S2, C],
- // [F, df]
- [p2, b]
- // [ssreg, ssresid]
- ];
- } else
- f2 = [
- [u, c]
- // [m, b]
- ];
- return q2.createByArray(f2);
- }
- _getKnownXsValues(e, t) {
- return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
- }
- };
- var bA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
- if (s)
- return o;
- const [c, l2, f2, h] = u, d2 = +c.getValue(), _ = +l2.getValue(), C = +f2.getValue(), E2 = +h.getValue();
- if (d2 <= 0 || C <= 0)
- return g2.create(m2.NUM);
- let b;
- return E2 ? b = Uo(d2, _, C) : b = cm(d2, _, C), y2.create(b);
- }
- };
- var yA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getRangeValues(e);
- if (r instanceof g2)
- return r;
- const n = Xt(t);
- if (n.isError())
- return n;
- const { isError: s, errorObject: o, variants: u } = I2(n);
- if (s)
- return o;
- const [c] = u, l2 = +c.getValue();
- if (l2 <= 0 || l2 >= 1)
- return g2.create(m2.NUM);
- if (r.length < 2)
- return g2.create(m2.DIV_BY_ZERO);
- const f2 = 1 - l2, h = r.length, d2 = r.reduce((b, R) => b + R, 0) / h, _ = r.reduce((b, R) => b + (R - d2) ** 2, 0) / (h - 1), C = Math.sqrt(_);
- if (C <= 0)
- return g2.create(m2.NUM);
- const E2 = Math.abs(qn(f2 / 2, h - 1) * C / Math.sqrt(h));
- return y2.create(E2);
- }
- _getRangeValues(e) {
- const t = [], r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1;
- for (let s = 0; s < r; s++)
- for (let o = 0; o < n; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- u.isNull() || u.isBoolean() || u.isString() || t.push(+u.getValue());
- }
- return t;
- }
- };
- var RA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(Number.NEGATIVE_INFINITY);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (!n.isNull()) {
- if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isArray() && (n = n.max()), n.isError())
- return n;
- t = this._validator(t, n);
- }
- }
- return t.getValue() === Number.NEGATIVE_INFINITY ? y2.create(0) : t;
- }
- _validator(e, t) {
- const r = e.isLessThan(t);
- let n = e;
- return r.getValue() && (n = t), n;
- }
- };
- var pA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(Number.NEGATIVE_INFINITY);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (!n.isNull()) {
- if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- if (n.isArray() && n.iterator((s) => {
- let o = s;
- if ((o == null || o.isNull() || o.isString()) && (o = y2.create(0)), o.isBoolean() && (o = o.convertToNumberObjectValue()), o.isError())
- return t = o, false;
- t = this._validator(t, o);
- }), t.isError())
- return t;
- t = this._validator(t, n);
- }
- }
- return t.getValue() === Number.NEGATIVE_INFINITY ? y2.create(0) : t;
- }
- _validator(e, t) {
- const r = e.isLessThan(t);
- let n = e;
- return r.getValue() && (n = t), n;
- }
- };
- var VA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return g2.create(m2.NA);
- if (!e.isArray() || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
- return g2.create(m2.VALUE);
- const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
- if (s)
- return s;
- const o = Ir(t, r, n, true);
- return this._aggregateResults(e, o);
- }
- _aggregateResults(e, t) {
- const r = t.map((s) => s.map((o) => {
- const u = e.pick(o);
- return u.getColumnCount() === 0 ? q2.create("0") : u.max();
- })), n = {
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q2.create(n);
- }
- };
- var NA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- const n = e[r];
- if (n.isArray()) {
- let s = false, o = g2.create(m2.VALUE);
- if (n.iterator((u) => {
- if (u != null && u.isError())
- return s = true, o = u, false;
- if (u != null && u.isNull() || u != null && u.isBoolean())
- return true;
- const c = u.getValue();
- if (!DC(c))
- return true;
- t.push(+c);
- }), s)
- return o;
- } else {
- if (n.isError())
- return n;
- if (n.isNull() || n.isBoolean())
- continue;
- if (n.isString()) {
- const o = n.convertToNumberObjectValue();
- if (o.isError())
- return o;
- }
- const s = n.getValue();
- if (!DC(s))
- continue;
- t.push(+s);
- }
- }
- return t.length === 0 ? g2.create(m2.NUM) : this._getResult(t.sort((r, n) => r - n));
- }
- _getResult(e) {
- const t = e.length;
- let r;
- if (t % 2 === 0) {
- const n = t / 2;
- r = (e[n - 1] + e[n]) / 2;
- } else
- r = e[Math.floor(t / 2)];
- return y2.create(r);
- }
- };
- var OA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(Number.POSITIVE_INFINITY);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (!n.isNull()) {
- if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isArray() && (n = n.min()), n.isError())
- return n;
- t = this._validator(t, n);
- }
- }
- return t.getValue() === Number.POSITIVE_INFINITY ? y2.create(0) : t;
- }
- _validator(e, t) {
- const r = e.isGreaterThan(t);
- let n = e;
- return r.getValue() && (n = t), n;
- }
- };
- var MA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y2.create(Number.POSITIVE_INFINITY);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (!n.isNull()) {
- if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- if (n.isArray() && n.iterator((s) => {
- let o = s;
- if ((o == null || o.isNull() || o.isString()) && (o = y2.create(0)), o.isBoolean() && (o = o.convertToNumberObjectValue()), o.isError())
- return t = o, false;
- t = this._validator(t, o);
- }), t.isError())
- return t;
- t = this._validator(t, n);
- }
- }
- return t.getValue() === Number.POSITIVE_INFINITY ? y2.create(0) : t;
- }
- _validator(e, t) {
- const r = e.isGreaterThan(t);
- let n = e;
- return r.getValue() && (n = t), n;
- }
- };
- var wA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return g2.create(m2.NA);
- if (!e.isArray() || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
- return g2.create(m2.VALUE);
- const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
- if (s)
- return s;
- const o = Ir(t, r, n, true);
- return this._aggregateResults(e, o);
- }
- _aggregateResults(e, t) {
- const r = t.map((s) => s.map((o) => {
- const u = e.pick(o);
- return u.getColumnCount() === 0 ? q2.create("0") : u.min();
- })), n = {
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q2.create(n);
- }
- };
- var DA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = {};
- let r = 0, n = 1;
- for (let s = 0; s < e.length; s++) {
- const o = e[s];
- if (o.isError())
- return o;
- if (o.isString()) {
- const l2 = o.convertToNumberObjectValue();
- if (l2.isError())
- return l2;
- }
- const u = o.isArray() ? o.getRowCount() : 1, c = o.isArray() ? o.getColumnCount() : 1;
- for (let l2 = 0; l2 < u; l2++)
- for (let f2 = 0; f2 < c; f2++) {
- const h = o.isArray() ? o.get(l2, f2) : o;
- if (h.isError())
- return h;
- if (h.isNull() || h.isBoolean() || h.isString())
- continue;
- const d2 = h.getValue();
- DC(d2) && (t[+d2] ? (t[+d2].count++, t[+d2].count > n && (n = t[+d2].count)) : t[+d2] = { count: 1, order: r++ });
- }
- }
- return r === 0 || n === 1 ? new g2(m2.NA) : this._getResult(t, n);
- }
- _getResult(e, t) {
- const r = Object.entries(e).filter(([n, { count: s }]) => s === t).sort((n, s) => n[1].order - s[1].order).map(([n]) => +n);
- return r.length === 1 ? y2.create(r[0]) : q2.createByArray(r.map((n) => [n]));
- }
- };
- var SA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
- if (s)
- return o;
- const [c, l2, f2, h] = u, d2 = Math.floor(+c.getValue()), _ = Math.floor(+l2.getValue()), C = +f2.getValue(), E2 = +h.getValue();
- if (d2 < 0 || _ < 1 || C <= 0 || C >= 1)
- return g2.create(m2.NUM);
- let b;
- return E2 ? b = fm(d2, _, C) : b = ja(d2, _, C), y2.create(b);
- }
- };
- var PA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = +u.getValue();
- let f2;
- return l2 ? f2 = kr(c, 0, 1) : f2 = vo(c, 0, 1), y2.create(f2);
- }
- };
- var LA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if (r * n === 1 || s * o === 1)
- return u.isNull() || c.isNull() ? g2.create(m2.VALUE) : g2.create(m2.DIV_BY_ZERO);
- if (r * n !== s * o)
- return g2.create(m2.NA);
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
- }
- _getResult(e, t) {
- const r = e.length;
- let n = 0, s = 0;
- for (let d2 = 0; d2 < r; d2++)
- n += e[d2], s += t[d2];
- const o = n / r, u = s / r;
- let c = 0, l2 = 0, f2 = 0;
- for (let d2 = 0; d2 < r; d2++)
- c += (e[d2] - o) * (t[d2] - u), l2 += (e[d2] - o) ** 2, f2 += (t[d2] - u) ** 2;
- if (l2 === 0 || f2 === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const h = c / Math.sqrt(l2 * f2);
- return y2.create(h);
- }
- };
- var xA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g2)
- return e;
- const { isError: r, errorObject: n, variants: s } = I2(t);
- if (r)
- return n;
- const [o] = s, u = +o.getValue(), c = e.length;
- if (u < 1 / (c + 1) || u > 1 - 1 / (c + 1))
- return g2.create(m2.NUM);
- const l2 = u * (c + 1) - 1, f2 = Math.floor(l2), h = l2 - f2;
- if (h === 0)
- return y2.create(e[f2]);
- const d2 = e[f2] + h * (e[f2 + 1] - e[f2]);
- return y2.create(d2);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean() || u.isString())
- continue;
- const c = u.getValue();
- DC(c) && n.push(+c);
- }
- return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
- }
- };
- var jA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = this._getValues(e);
- let s = r != null ? r : y2.create(3);
- s.isNull() && (s = y2.create(3));
- const o = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, t, g2.create(m2.NA)), l2 = O(o, u, s, g2.create(m2.NA)), f2 = c.mapValue((h, d2, _) => {
- const C = l2.get(d2, _);
- return h.isError() ? h : C.isError() ? C : this._handleSingleObject(n, h, C);
- });
- return o === 1 && u === 1 ? f2.get(0, 0) : f2;
- }
- _handleSingleObject(e, t, r) {
- if (e instanceof g2)
- return e;
- const { isError: n, errorObject: s, variants: o } = I2(t, r);
- if (n)
- return s;
- const [u, c] = o, l2 = +u.getValue(), f2 = Math.floor(+c.getValue()), h = e.length;
- if (h === 0 || l2 < e[0] || l2 > e[h - 1])
- return g2.create(m2.NA);
- if (h === 1)
- return l2 === e[0] ? y2.create(1) : g2.create(m2.NA);
- let d2 = 0, _ = false, C = 0;
- for (; !_ && C < h; )
- l2 === e[C] ? (d2 = (C + 1) / (h + 1), _ = true) : l2 > e[C] && C + 1 < h && l2 < e[C + 1] && (d2 = (C + 1 + (l2 - e[C]) / (e[C + 1] - e[C])) / (h + 1), _ = true), C++;
- return _ ? f2 < 1 ? g2.create(m2.NUM) : (d2 = We(d2, f2), y2.create(d2)) : g2.create(m2.NA);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- DC(c) && n.push(+c);
- }
- return n.sort((s, o) => s - o);
- }
- };
- var UA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- if (c.isError())
- return c;
- if (h.isError())
- return h;
- const { isError: d2, errorObject: _, variants: C } = I2(c, h);
- if (d2)
- return _;
- const [E2, b] = C, R = Math.floor(+E2.getValue()), p2 = Math.floor(+b.getValue());
- if (R < 0 || R >= 2147483647 || p2 < 0 || R < p2)
- return g2.create(m2.NUM);
- let N2 = 1;
- for (let M2 = R - p2 + 1; M2 <= R; M2++)
- N2 *= M2;
- return Number.isFinite(N2) ? y2.create(N2) : g2.create(m2.NUM);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var vA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- if (c.isError())
- return c;
- if (h.isError())
- return h;
- const { isError: d2, errorObject: _, variants: C } = I2(c, h);
- if (d2)
- return _;
- const [E2, b] = C, R = Math.floor(+E2.getValue()), p2 = Math.floor(+b.getValue());
- if (R < 0 || R >= 2147483647 || p2 < 0)
- return g2.create(m2.NUM);
- if (R === 0)
- return p2 === 0 ? y2.create(1) : y2.create(0);
- const N2 = R ** p2;
- return Number.isFinite(N2) ? y2.create(N2) : g2.create(m2.NUM);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var TA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue(), u = Math.exp(-0.5 * o * o) / Math.sqrt(2 * Math.PI);
- return y2.create(u);
- }
- };
- var BA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o, xRangeValues: u, probRangeValues: c } = this._handleXRangeAndProbRange(e, t);
- let l2 = n != null ? n : r;
- n != null && n.isNull() && (l2 = r);
- const f2 = Math.max(
- r.isArray() ? r.getRowCount() : 1,
- l2.isArray() ? l2.getRowCount() : 1
- ), h = Math.max(
- r.isArray() ? r.getColumnCount() : 1,
- l2.isArray() ? l2.getColumnCount() : 1
- ), d2 = O(f2, h, r, g2.create(m2.NA)), _ = O(f2, h, l2, g2.create(m2.NA)), C = d2.mapValue((E2, b, R) => {
- const p2 = _.get(b, R);
- return e.isError() ? e : t.isError() ? t : E2.isError() ? E2 : p2.isError() ? p2 : s ? o : this._handleSignleObject(u, c, E2, p2);
- });
- return f2 === 1 && h === 1 ? C.get(0, 0) : C;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(r, n);
- if (s)
- return o;
- const [c, l2] = u, f2 = +c.getValue(), h = +l2.getValue();
- if (t.reduce((_, C) => _ + C, 0) !== 1)
- return g2.create(m2.NUM);
- let d2 = 0;
- for (let _ = 0; _ < e.length; _++)
- e[_] >= f2 && e[_] <= h && (d2 += t[_]);
- return y2.create(d2);
- }
- // eslint-disable-next-line
- _handleXRangeAndProbRange(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return {
- isError: true,
- errorObject: u,
- xRangeValues: [],
- probRangeValues: []
- };
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return {
- isError: true,
- errorObject: c,
- xRangeValues: [],
- probRangeValues: []
- };
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return {
- isError: true,
- errorObject: g2.create(m2.VALUE),
- xRangeValues: [],
- probRangeValues: []
- };
- if (r * n !== s * o)
- return {
- isError: true,
- errorObject: g2.create(m2.NA),
- xRangeValues: [],
- probRangeValues: []
- };
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? {
- isError: true,
- errorObject: f2,
- xRangeValues: [],
- probRangeValues: []
- } : _ ? {
- isError: true,
- errorObject: g2.create(m2.DIV_BY_ZERO),
- xRangeValues: [],
- probRangeValues: []
- } : {
- isError: false,
- errorObject: null,
- xRangeValues: h,
- probRangeValues: d2
- };
- }
- };
- var IA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g2)
- return e;
- const { isError: r, errorObject: n, variants: s } = I2(t);
- if (r)
- return n;
- const [o] = s, u = Math.floor(+o.getValue());
- if (u <= 0 || u >= 4)
- return g2.create(m2.NUM);
- const c = u / 4, l2 = e.length;
- if (c < 1 / (l2 + 1) || c > 1 - 1 / (l2 + 1))
- return g2.create(m2.NUM);
- const f2 = c * (l2 + 1) - 1, h = Math.floor(f2), d2 = f2 - h;
- if (d2 === 0)
- return y2.create(e[h]);
- const _ = e[h] + d2 * (e[h + 1] - e[h]);
- return y2.create(_);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- DC(c) && n.push(+c);
- }
- return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
- }
- };
- var FA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", true);
- }
- calculate(e, t, r) {
- let n = e;
- n.isReferenceObject() && (n = n.toArrayValueObject());
- const { refHasError: s, refErrorObject: o, refNumbers: u } = this._checkRefReferenceObject(t);
- let c = r != null ? r : y2.create(0);
- c.isReferenceObject() && (c = c.toArrayValueObject());
- const l2 = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f2 = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l2, f2, n, g2.create(m2.NA)), d2 = O(l2, f2, c, g2.create(m2.NA)), _ = h.map((C, E2, b) => {
- const R = d2.get(E2, b);
- if (!e.isReferenceObject() && e.isNull())
- return g2.create(m2.NA);
- if (s)
- return o;
- if (R.isError())
- return R;
- const p2 = +C.getValue(), N2 = +R.getValue();
- return Number.isNaN(p2) || Number.isNaN(N2) ? g2.create(m2.VALUE) : this._getResult(p2, N2, u);
- });
- return l2 === 1 && f2 === 1 ? _.get(0, 0) : _;
- }
- _getResult(e, t, r) {
- const n = r.sort((c, l2) => t ? c - l2 : l2 - c);
- let s = n.indexOf(e);
- const o = [];
- for (; s >= 0; ) {
- const c = s + 1;
- o.push(c), s = n.indexOf(e, c);
- }
- if (o.length === 0)
- return g2.create(m2.NA);
- const u = o.reduce((c, l2) => c + l2, 0) / o.length;
- return y2.create(u);
- }
- _checkRefReferenceObject(e) {
- let t = false, r = g2.create(m2.NA);
- const n = [];
- return e.isReferenceObject() ? (e.toArrayValueObject().iterator((o) => {
- const u = o;
- if (u.isError())
- return t = true, r = u, false;
- if (u.isNull() || u.isBoolean())
- return true;
- const c = +u.getValue();
- if (Number.isNaN(c))
- return true;
- n.push(c);
- }), {
- refHasError: t,
- refErrorObject: r,
- refNumbers: n
- }) : {
- refHasError: true,
- refErrorObject: r,
- refNumbers: n
- };
- }
- };
- var kA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", true);
- }
- calculate(e, t, r) {
- let n = e;
- n.isReferenceObject() && (n = n.toArrayValueObject());
- const { refHasError: s, refErrorObject: o, refNumbers: u } = this._checkRefReferenceObject(t);
- let c = r != null ? r : y2.create(0);
- c.isReferenceObject() && (c = c.toArrayValueObject());
- const l2 = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f2 = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l2, f2, n, g2.create(m2.NA)), d2 = O(l2, f2, c, g2.create(m2.NA)), _ = h.map((C, E2, b) => {
- const R = d2.get(E2, b);
- if (!e.isReferenceObject() && e.isNull())
- return g2.create(m2.NA);
- if (s)
- return o;
- if (R.isError())
- return R;
- const p2 = +C.getValue(), N2 = +R.getValue();
- if (Number.isNaN(p2) || Number.isNaN(N2))
- return g2.create(m2.VALUE);
- const w = u.sort((D2, S2) => N2 ? D2 - S2 : S2 - D2).indexOf(p2);
- return w === -1 ? g2.create(m2.NA) : y2.create(w + 1);
- });
- return l2 === 1 && f2 === 1 ? _.get(0, 0) : _;
- }
- _checkRefReferenceObject(e) {
- let t = false, r = g2.create(m2.NA);
- const n = [];
- return e.isReferenceObject() ? (e.toArrayValueObject().iterator((o) => {
- const u = o;
- if (u.isError())
- return t = true, r = u, false;
- if (u.isNull() || u.isBoolean())
- return true;
- const c = +u.getValue();
- if (Number.isNaN(c))
- return true;
- n.push(c);
- }), {
- refHasError: t,
- refErrorObject: r,
- refNumbers: n
- }) : {
- refHasError: true,
- refErrorObject: r,
- refNumbers: n
- };
- }
- };
- var $A = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return g2.create(m2.VALUE);
- if (r * n !== s * o)
- return g2.create(m2.NA);
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
- }
- _getResult(e, t) {
- if (e.length === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const r = e.length;
- let n = 0, s = 0;
- for (let d2 = 0; d2 < r; d2++)
- n += e[d2], s += t[d2];
- const o = n / r, u = s / r;
- let c = 0, l2 = 0, f2 = 0;
- for (let d2 = 0; d2 < r; d2++)
- c += (e[d2] - o) * (t[d2] - u), l2 += (e[d2] - o) ** 2, f2 += (t[d2] - u) ** 2;
- if (l2 === 0 || f2 === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const h = (c / Math.sqrt(l2 * f2)) ** 2;
- return y2.create(h);
- }
- };
- var YA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- let r = 0;
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (s.isError())
- return s;
- if (s.isString()) {
- const c = s.convertToNumberObjectValue();
- if (c.isError())
- return c;
- }
- const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
- for (let c = 0; c < o; c++)
- for (let l2 = 0; l2 < u; l2++) {
- const f2 = s.isArray() ? s.get(c, l2) : s;
- if (f2.isError())
- return f2;
- if (f2.isNull() || f2.isBoolean())
- continue;
- const h = f2.getValue();
- DC(h) && (t.push(+h), r += +h);
- }
- }
- return t.length <= 2 ? g2.create(m2.DIV_BY_ZERO) : this._getResult(t, r);
- }
- _getResult(e, t) {
- const r = e.length, n = t / r;
- let s = 0;
- for (let l2 = 0; l2 < r; l2++)
- s += (e[l2] - n) ** 2;
- const o = Math.sqrt(s / (r - 1));
- if (o === 0)
- return g2.create(m2.DIV_BY_ZERO);
- let u = 0;
- for (let l2 = 0; l2 < r; l2++)
- u += ((e[l2] - n) / o) ** 3;
- const c = r / ((r - 1) * (r - 2)) * u;
- return y2.create(c);
- }
- };
- var HA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- let r = 0;
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (s.isError())
- return s;
- if (s.isString()) {
- const c = s.convertToNumberObjectValue();
- if (c.isError())
- return c;
- }
- const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
- for (let c = 0; c < o; c++)
- for (let l2 = 0; l2 < u; l2++) {
- const f2 = s.isArray() ? s.get(c, l2) : s;
- if (f2.isError())
- return f2;
- if (f2.isNull() || f2.isBoolean())
- continue;
- const h = f2.getValue();
- DC(h) && (t.push(+h), r += +h);
- }
- }
- return t.length <= 2 ? g2.create(m2.DIV_BY_ZERO) : this._getResult(t, r);
- }
- _getResult(e, t) {
- const r = e.length, n = t / r;
- let s = 0;
- for (let l2 = 0; l2 < r; l2++)
- s += (e[l2] - n) ** 2;
- const o = Math.sqrt(s / r);
- if (o === 0)
- return g2.create(m2.DIV_BY_ZERO);
- let u = 0;
- for (let l2 = 0; l2 < r; l2++)
- u += ((e[l2] - n) / o) ** 3;
- const c = u / r;
- return y2.create(c);
- }
- };
- var GA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if (r * n === 1 || s * o === 1)
- return u.isNull() || c.isNull() ? g2.create(m2.VALUE) : g2.create(m2.DIV_BY_ZERO);
- if (r * n !== s * o)
- return g2.create(m2.NA);
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
- }
- _getResult(e, t) {
- const r = e.length;
- let n = 0, s = 0;
- for (let h = 0; h < r; h++)
- n += e[h], s += t[h];
- const o = n / r, u = s / r;
- let c = 0, l2 = 0;
- for (let h = 0; h < r; h++)
- c += (e[h] - o) * (t[h] - u), l2 += (t[h] - u) ** 2;
- if (l2 === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const f2 = c / l2;
- return y2.create(f2);
- }
- };
- var QA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g2)
- return e;
- const { isError: r, errorObject: n, variants: s } = I2(t);
- if (r)
- return n;
- const [o] = s;
- let u = +o.getValue();
- return u < 1 || u > e.length ? g2.create(m2.NUM) : (u = Math.floor(u), y2.create(e[u - 1]));
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean() || u.isString())
- continue;
- const c = u.getValue();
- DC(c) && n.push(+c);
- }
- return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
- }
- };
- var WA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
- if (d2 <= 0)
- return g2.create(m2.NUM);
- const _ = (f2 - h) / d2;
- return y2.create(_);
- }
- };
- var qA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e, false);
- return t.isError() ? t : t.std(1);
- }
- };
- var KA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e, false);
- return t.isError() ? t : t.std();
- }
- };
- var XA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return g2.create(m2.VALUE);
- if (r * n !== s * o)
- return g2.create(m2.NA);
- const {
- isError: l2,
- errorObject: f2,
- array1Values: h,
- array2Values: d2,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
- }
- _getResult(e, t) {
- const r = e.length;
- if (r <= 2)
- return g2.create(m2.DIV_BY_ZERO);
- let n = 0, s = 0;
- for (let d2 = 0; d2 < r; d2++)
- n += e[d2], s += t[d2];
- const o = n / r, u = s / r;
- let c = 0, l2 = 0, f2 = 0;
- for (let d2 = 0; d2 < r; d2++)
- c += (e[d2] - o) * (t[d2] - u), l2 += (e[d2] - o) ** 2, f2 += (t[d2] - u) ** 2;
- if (f2 === 0)
- return g2.create(m2.DIV_BY_ZERO);
- const h = Math.sqrt((l2 - c ** 2 / f2) / (r - 2));
- return Number.isNaN(h) || !Number.isFinite(h) ? g2.create(m2.NUM) : y2.create(h);
- }
- };
- var ZA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = +l2.getValue();
- if (h < 1)
- return g2.create(m2.NUM);
- let _;
- return d2 ? _ = $r(f2, h) : _ = mm(f2, h), Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
- }
- };
- var zA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (c < 0 || l2 < 1 || l2 > 10 ** 10)
- return g2.create(m2.NUM);
- const f2 = $r(-c, l2) * 2;
- return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
- }
- };
- var JA = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (l2 < 1 || l2 > 10 ** 10)
- return g2.create(m2.NUM);
- const f2 = $r(-c, l2);
- return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
- }
- };
- var eE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
- if (c <= 0 || c > 1 || l2 < 1 || l2 > 10 ** 10)
- return g2.create(m2.NUM);
- const f2 = qn(c, l2);
- return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
- }
- };
- var tE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o } = Kn(e, t, r);
- if (s)
- return o;
- const u = dt(e);
- if (u instanceof g2)
- return u;
- const c = this._getKnownXsValues(u, t);
- if (c instanceof g2)
- return c;
- const l2 = this._getNewXsValues(c, r);
- if (l2 instanceof g2)
- return l2;
- let f2 = n != null ? n : T2.create(true);
- if (f2.isArray() && (f2 = f2.get(0, 0)), f2.isString() && (f2 = f2.convertToNumberObjectValue()), f2.isError())
- return f2;
- const h = +f2.getValue();
- return this._getResult(u, c, l2, h);
- }
- _getResult(e, t, r, n) {
- return e.length === 1 && t.length > 1 || e[0].length === 1 && t[0].length > 1 ? e.length === 1 && t.length > 1 && (n ? t.length + 1 : t.length) > e[0].length || e[0].length === 1 && t[0].length > 1 && (n ? t[0].length + 1 : t[0].length) > e.length ? g2.create(m2.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
- }
- _getResultByMultipleVariables(e, t, r, n) {
- const s = e.length === 1 && e[0].length > 1, o = zn(e, t, r, n, false);
- if (o instanceof g2)
- return o;
- const { coefficients: u, newX: c } = o, l2 = u[0].length, f2 = u[0][l2 - 1];
- let h = [];
- for (let d2 = 0; d2 < c.length; d2++) {
- h[d2] = [];
- let _ = f2;
- for (let C = l2 - 2; C >= 0; C--)
- _ += u[0][l2 - 2 - C] * c[d2][C];
- h[d2].push(_);
- }
- return s && (h = mt(h)), q2.createByArray(h);
- }
- _getResultBySimpleVariables(e, t, r, n) {
- const s = e.flat(), o = t.flat(), { slope: u, intercept: c } = Zn(o, s, n, false);
- if (Number.isNaN(u))
- return g2.create(m2.NA);
- const l2 = r.map((f2) => f2.map((h) => u * h + c));
- return q2.createByArray(l2);
- }
- _getKnownXsValues(e, t) {
- return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
- }
- _getNewXsValues(e, t) {
- return !t || t.isNull() ? e : dt(t);
- }
- };
- var rE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g2)
- return e;
- const { isError: r, errorObject: n, variants: s } = I2(t);
- if (r)
- return n;
- const [o] = s, u = +o.getValue();
- if (u < 0 || u >= 1)
- return g2.create(m2.NUM);
- const c = We(e.length * u / 2, 0) * 2, l2 = e.slice(c / 2, e.length - c / 2), f2 = l2.reduce((h, d2) => h + d2, 0) / l2.length;
- return y2.create(f2);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- DC(c) && n.push(+c);
- }
- return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
- }
- };
- var nE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e, false);
- return t.isError() ? t : t.var(1);
- }
- };
- var sE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e, false);
- return t.isError() ? t : t.var();
- }
- };
- var aE = [
- [T_, v.AVEDEV],
- [I_, v.AVERAGE],
- [F_, v.AVERAGE_WEIGHTED],
- [k_, v.AVERAGEA],
- [$_, v.AVERAGEIF],
- [Y_, v.AVERAGEIFS],
- [H_, v.BETA_DIST],
- [Bo, v.BETA_INV],
- [Io, v.BINOM_DIST],
- [G_, v.BINOM_DIST_RANGE],
- [Fo, v.BINOM_INV],
- [Q_, v.CHISQ_DIST],
- [ko, v.CHISQ_DIST_RT],
- [W_, v.CHISQ_INV],
- [$o, v.CHISQ_INV_RT],
- [Yo, v.CHISQ_TEST],
- [Ho, v.CONFIDENCE_NORM],
- [q_, v.CONFIDENCE_T],
- [K_, v.CORREL],
- [X_, v.COUNT],
- [Z_, v.COUNTA],
- [z_, v.COUNTBLANK],
- [J_, v.COUNTIF],
- [eA, v.COUNTIFS],
- [Go, v.COVARIANCE_P],
- [rA, v.COVARIANCE_S],
- [nA, v.DEVSQ],
- [Qo, v.EXPON_DIST],
- [sA, v.F_DIST],
- [Wo, v.F_DIST_RT],
- [aA, v.F_INV],
- [qo, v.F_INV_RT],
- [Ko, v.F_TEST],
- [iA, v.FISHER],
- [oA, v.FISHERINV],
- [Li, v.FORECAST],
- [Li, v.FORECAST_LINEAR],
- [uA, v.FREQUENCY],
- [cA, v.GAMMA],
- [Xo, v.GAMMA_DIST],
- [Zo, v.GAMMA_INV],
- [xi, v.GAMMALN],
- [xi, v.GAMMALN_PRECISE],
- [lA, v.GAUSS],
- [fA, v.GEOMEAN],
- [hA, v.GROWTH],
- [mA, v.HARMEAN],
- [gA, v.HYPGEOM_DIST],
- [dA, v.INTERCEPT],
- [CA, v.KURT],
- [_A, v.LARGE],
- [AA, v.LINEST],
- [EA, v.LOGEST],
- [bA, v.LOGNORM_DIST],
- [zo, v.LOGNORM_INV],
- [yA, v.MARGINOFERROR],
- [RA, v.MAX],
- [pA, v.MAXA],
- [VA, v.MAXIFS],
- [NA, v.MEDIAN],
- [OA, v.MIN],
- [MA, v.MINA],
- [wA, v.MINIFS],
- [DA, v.MODE_MULT],
- [Jo, v.MODE_SNGL],
- [SA, v.NEGBINOM_DIST],
- [eu, v.NORM_DIST],
- [tu, v.NORM_INV],
- [PA, v.NORM_S_DIST],
- [ru, v.NORM_S_INV],
- [LA, v.PEARSON],
- [xA, v.PERCENTILE_EXC],
- [nu2, v.PERCENTILE_INC],
- [jA, v.PERCENTRANK_EXC],
- [su, v.PERCENTRANK_INC],
- [UA, v.PERMUT],
- [vA, v.PERMUTATIONA],
- [TA, v.PHI],
- [au, v.POISSON_DIST],
- [BA, v.PROB],
- [IA, v.QUARTILE_EXC],
- [iu, v.QUARTILE_INC],
- [FA, v.RANK_AVG],
- [kA, v.RANK_EQ],
- [$A, v.RSQ],
- [YA, v.SKEW],
- [HA, v.SKEW_P],
- [GA, v.SLOPE],
- [QA, v.SMALL],
- [WA, v.STANDARDIZE],
- [ou, v.STDEV_P],
- [uu, v.STDEV_S],
- [qA, v.STDEVA],
- [KA, v.STDEVPA],
- [XA, v.STEYX],
- [ZA, v.T_DIST],
- [zA, v.T_DIST_2T],
- [JA, v.T_DIST_RT],
- [eE, v.T_INV],
- [cu, v.T_INV_2T],
- [lu, v.T_TEST],
- [tE, v.TREND],
- [rE, v.TRIMMEAN],
- [fu, v.VAR_P],
- [hu, v.VAR_S],
- [nE, v.VARA],
- [sE, v.VARPA],
- [mu, v.WEIBULL_DIST],
- [gu, v.Z_TEST]
- ];
- var iE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = t != null ? t : y2.create(0);
- if (t != null && t.isNull() && (r = y2.create(0)), r.isArray()) {
- const n = r.mapValue((s) => this._handleSingleObject(e, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(e, r);
- }
- _handleSingleObject(e, t) {
- const r = this._checkArray(e);
- if (r.isError())
- return r;
- const { isError: n, errorObject: s, variants: o } = I2(t);
- if (n)
- return s;
- const [u] = o, c = +u.getValue(), l2 = e.isArray() ? e.getRowCount() : 1, f2 = e.isArray() ? e.getColumnCount() : 1;
- let h = "";
- for (let d2 = 0; d2 < l2; d2++)
- for (let _ = 0; _ < f2; _++) {
- const C = e.isArray() ? e.get(d2, _) : e;
- let E2 = `${C.getValue()}`;
- C.isNull() && (E2 = ""), C.isBoolean() && (E2 = E2.toLocaleUpperCase()), C.isString() && c ? h += `"${E2}"` : h += E2, d2 === l2 - 1 && _ === f2 - 1 || (c ? _ === f2 - 1 ? h += ";" : h += "," : h += ", ");
- }
- return c && (h = `{${h}}`), h.length > 32767 ? g2.create(m2.CALC) : j.create(h);
- }
- _checkArray(e) {
- if (e.isArray()) {
- const t = e.getRowCount(), r = e.getColumnCount();
- return t > 1 || r > 1 ? e : e.get(0, 0);
- }
- return e;
- }
- };
- var oE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError() || e.isNull() || e.isBoolean() || e.isNumber())
- return e;
- const t = e.getValue().toLocaleString();
- let r = "";
- for (let n = 0; n < t.length; n++) {
- let s = t.charCodeAt(n);
- s === 12288 ? s = 32 : s >= 65281 && s <= 65374 && (s -= 65248), r += String.fromCharCode(s);
- }
- return j.create(r);
- }
- };
- var uE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue(), u = Math.abs(Number.parseInt(o.toString(), 10)), c = Number.parseFloat((Math.abs(o) - u).toFixed(2));
- let l2 = "";
- return u === 0 ? c !== 0 ? l2 = `${o < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(c * 100)}สตางค์` : l2 = "ศูนย์บาทถ้วน" : c === 0 ? l2 = `${o < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(u)}บาทถ้วน` : l2 = `${o < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(u)}บาท${this._convertNumberToThaiText(c * 100)}สตางค์`, j.create(l2);
- }
- _convertNumberToThaiText(e) {
- const t = ["ล้าน", "สิบ", "ร้อย", "พัน", "หมื่น", "แสน", ""], r = ["ศูนย์", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า"], n = ["ลบ", "บาท", "ถ้วน", "สตางค์", "ยี่", "เอ็ด", ",", " ", "฿"], s = e.toString(), o = s.length;
- let u = "";
- for (let c = o; c > 0; c--) {
- const l2 = Number.parseInt(s.charAt(o - c), 10);
- let f2 = r[l2];
- const h = c > 1 ? (c - 1) % 6 : 6;
- if (h === 1 && l2 === 2 && (f2 = n[4]), l2 === 1)
- switch (h) {
- case 0:
- case 6:
- u += c < o ? n[5] : f2;
- break;
- case 1:
- break;
- default:
- u += f2;
- break;
- }
- else if (l2 === 0) {
- h === 0 && (u += t[h]);
- continue;
- } else
- u += f2;
- u += t[h];
- }
- return u;
- }
- };
- var cE = Object.values(ln).filter((i) => [
- ln.TABLE_START,
- ln.TABLE_ROW_START,
- ln.TABLE_CELL_START,
- ln.TABLE_CELL_END,
- ln.TABLE_ROW_END,
- ln.TABLE_END,
- ln.CUSTOM_BLOCK
- ].includes(i));
- var lE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = Math.floor(+s.getValue());
- if (o <= 0)
- return g2.create(m2.VALUE);
- let u = String.fromCharCode(o);
- return cE.some((c) => c === u) && (u = ""), j.create(u);
- }
- };
- var fE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError() || e.isBoolean() || e.isNumber())
- return e;
- if (e.isNull())
- return j.create("");
- const r = `${e.getValue()}`.replace(/[\0-\x1F]/g, "");
- return j.create(r);
- }
- };
- var hE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- let t = e.getValue().toLocaleString();
- if (e.isBoolean() && (t = t.toLocaleUpperCase()), t === "")
- return g2.create(m2.VALUE);
- const r = t.charCodeAt(0);
- return y2.create(r);
- }
- };
- var mE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = "", r = null;
- for (const n of e)
- if (n.isArray()) {
- if (n.iterator((s) => {
- if (s == null || s.isNull())
- return true;
- if (s.isError())
- return r = s, false;
- s.isBoolean() ? t += `${s.getValue()}`.toLocaleUpperCase() : (s.isString() || s.isNumber()) && (t += s.getValue());
- }), r)
- return r;
- } else
- !n.isError() && !n.isNull() && (t += n.getValue());
- return j.create(t);
- }
- };
- var gE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 0, r = 0;
- e.forEach((s) => {
- if (s.isArray()) {
- const o = s;
- t = Math.max(t, o.getRowCount()), r = Math.max(r, o.getColumnCount());
- } else
- t = Math.max(t, 1), r = Math.max(r, 1);
- });
- let n = null;
- for (const s of e)
- n = O(t, r, s, g2.create(m2.NA)).mapValue((u, c, l2) => {
- const f2 = n && n.get(c, l2);
- if (f2 != null && f2.isError())
- return f2;
- if (u.isError())
- return u;
- let h = f2 == null ? void 0 : f2.getValue(), d2 = u == null ? void 0 : u.getValue();
- f2 != null && f2.isBoolean() && (h = `${h}`.toLocaleUpperCase()), u != null && u.isBoolean() && (d2 = `${d2}`.toLocaleUpperCase());
- const _ = f2 != null && f2.isNull() ? "" : h != null ? h : "", C = u != null && u.isNull() ? "" : d2 != null ? d2 : "";
- return j.create(`${_}${C}`);
- });
- return n || g2.create(m2.VALUE);
- }
- };
- var dE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return j.create("");
- let t = `${e.getValue()}`;
- e.isBoolean() && (t = t.toLocaleUpperCase());
- let r = "";
- for (let n = 0; n < t.length; n++) {
- const s = t.charCodeAt(n);
- s >= 33 && s <= 126 ? r += String.fromCharCode(s + 65248) : s === 32 ? r += " " : r += t.charAt(n);
- }
- return j.create(r);
- }
- };
- var CE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- A(this, "needsLocale", true);
- }
- calculate(e, t) {
- let r = t != null ? t : y2.create(2);
- r.isNull() && (r = y2.create(2));
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
- const d2 = u.get(f2, h);
- return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(e, t);
- if (r)
- return n;
- const [o, u] = s;
- let c = +o.getValue(), l2 = Math.trunc(+u.getValue());
- if (l2 > 127)
- return g2.create(m2.VALUE);
- l2 < 0 && (`${c}`.length < Math.abs(l2) ? c = 0 : c = c < 0 ? -vt(Math.abs(c), l2) : vt(c, l2), l2 = 0);
- const f2 = al(this.getLocale(), c, l2);
- return j.create(f2);
- }
- };
- var _E = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, ie.create()), o = O(r, n, t, ie.create()), u = s.mapValue((c, l2, f2) => {
- const h = o.get(l2, f2);
- return c.isError() ? c : h.isError() ? h : this._handleSingleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSingleObject(e, t) {
- if (e.isNull() || t.isNull()) {
- const o = e.isNull() && t.isNull();
- return T2.create(o);
- }
- let r = `${e.getValue()}`;
- e.isBoolean() && (r = r.toLocaleUpperCase());
- let n = `${t.getValue()}`;
- t.isBoolean() && (n = n.toLocaleUpperCase());
- const s = r === n;
- return T2.create(s);
- }
- };
- var ka = (i, a2) => Op.format(i, a2, { throws: false });
- var De2 = (i) => {
- let a2 = `${i.getValue()}`;
- return i.isNull() && (a2 = ""), i.isBoolean() && (a2 = a2.toLocaleUpperCase()), i.isNumber() && (i.getPattern() !== "" ? a2 = ka(i.getPattern(), +i.getValue()) : a2 = `${_f(+i.getValue())}`), a2;
- };
- var AE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y2.create(1), s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.mapValue((h, d2, _) => {
- const C = c.get(d2, _), E2 = l2.get(d2, _);
- return h.isError() ? h : C.isError() ? C : E2.isError() ? E2 : this._handleSingleObject(h, C, E2);
- });
- return s === 1 && o === 1 ? f2.get(0, 0) : f2;
- }
- _handleSingleObject(e, t, r) {
- const n = De2(e), s = De2(t), { isError: o, errorObject: u, variants: c } = I2(r);
- if (o)
- return u;
- const [l2] = c, f2 = Math.floor(+l2.getValue());
- if (t.isNull() || f2 <= 0 || f2 > s.length)
- return g2.create(m2.VALUE);
- if (e.isNull() || n.length === 0)
- return y2.create(f2);
- const h = s.indexOf(n, f2 - 1);
- return h === -1 ? g2.create(m2.VALUE) : y2.create(h + 1);
- }
- };
- function $a(i) {
- let a2 = 0;
- for (let e = 0; e < i.length; e++)
- a2 += Qr2(i, e);
- return a2;
- }
- function Qr2(i, a2, e = "ltr") {
- return EE(i, a2, e) > 255 ? 2 : 1;
- }
- function ji(i) {
- return i >= 55296 && i <= 56319;
- }
- function Ui(i) {
- return i >= 56320 && i <= 57343;
- }
- function vi(i, a2) {
- const e = (i & 1023) << 10, t = a2 & 1023;
- return e + t + 65536;
- }
- function EE(i, a2, e = "ltr") {
- const t = i.charCodeAt(a2);
- if (e === "ltr" && ji(t) && a2 + 1 < i.length) {
- const r = i.charCodeAt(a2 + 1);
- if (Ui(r))
- return vi(t, r);
- }
- if (e === "rtl" && Ui(t) && a2 - 1 >= 0) {
- const r = i.charCodeAt(a2 - 1);
- if (ji(r))
- return vi(r, t);
- }
- return t;
- }
- var bE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y2.create(1), s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.mapValue((h, d2, _) => {
- const C = c.get(d2, _), E2 = l2.get(d2, _);
- return h.isError() ? h : C.isError() ? C : E2.isError() ? E2 : this._handleSingleObject(h, C, E2);
- });
- return s === 1 && o === 1 ? f2.get(0, 0) : f2;
- }
- _handleSingleObject(e, t, r) {
- const n = De2(e), s = De2(t), { isError: o, errorObject: u, variants: c } = I2(r);
- if (o)
- return u;
- const [l2] = c, f2 = Math.floor(+l2.getValue());
- if (t.isNull() || f2 <= 0 || f2 > s.length)
- return g2.create(m2.VALUE);
- if (e.isNull() || n.length === 0)
- return y2.create(f2);
- const h = s.indexOf(n, f2 - 1);
- if (h === -1)
- return g2.create(m2.VALUE);
- const d2 = $a(s.substring(0, h)) + 1;
- return y2.create(d2);
- }
- };
- var yE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = t != null ? t : y2.create(2);
- n.isNull() && (n = y2.create(2));
- let s = r != null ? r : T2.create(false);
- s.isNull() && (s = T2.create(false));
- const o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, n, g2.create(m2.NA)), f2 = O(o, u, s, g2.create(m2.NA)), h = c.mapValue((d2, _, C) => {
- const E2 = l2.get(_, C), b = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : this._handleSingleObject(d2, E2, b);
- });
- return o === 1 && u === 1 ? h.get(0, 0) : h;
- }
- _handleSingleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o;
- let f2 = +u.getValue(), h = Math.trunc(+c.getValue());
- const d2 = +l2.getValue();
- if (h > 127)
- return g2.create(m2.VALUE);
- h < 0 && (`${f2}`.length < Math.abs(h) ? f2 = 0 : f2 = f2 < 0 ? -vt(Math.abs(f2), h) : vt(f2, h), h = 0);
- let _ = d2 ? "###0" : "#,##0";
- h > 0 && (_ += `.${"0".repeat(h)}`);
- const C = ka(_, f2);
- return j.create(C);
- }
- };
- var RE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(1), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
- const d2 = u.get(f2, h);
- return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const r = De2(e), { isError: n, errorObject: s, variants: o } = I2(t);
- if (n)
- return s;
- const [u] = o, c = Math.floor(+u.getValue());
- if (c < 0)
- return g2.create(m2.VALUE);
- if (e.isNull() || c === 0)
- return j.create("");
- if (c >= r.length)
- return j.create(r);
- const l2 = r.substring(0, c);
- return j.create(l2);
- }
- };
- var pE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(1), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, ie.create()), u = O(n, s, r, ie.create()), c = o.mapValue((l2, f2, h) => {
- const d2 = u.get(f2, h);
- return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const r = De2(e), { isError: n, errorObject: s, variants: o } = I2(t);
- if (n)
- return s;
- const [u] = o, c = Math.floor(+u.getValue());
- if (c < 0)
- return g2.create(m2.VALUE);
- if (e.isNull() || c === 0)
- return j.create("");
- let l2 = 0, f2 = 0, h = "";
- for (; f2 < c && l2 < r.length; )
- f2 += Qr2(r, l2), h += r.charAt(l2), l2++;
- return j.create(h);
- }
- };
- var VE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleText(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleText(e);
- }
- _handleSingleText(e) {
- if (e.isError())
- return e;
- const t = De2(e);
- return y2.create(t.length);
- }
- };
- var NE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleText(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleText(e);
- }
- _handleSingleText(e) {
- if (e.isError())
- return e;
- const t = De2(e), r = $a(t);
- return y2.create(r);
- }
- };
- var OE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return j.create("");
- const t = `${e.getValue()}`.toLocaleLowerCase();
- return j.create(t);
- }
- };
- var ME = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSingleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSingleObject(e, t, r) {
- const n = De2(e), { isError: s, errorObject: o, variants: u } = I2(t, r);
- if (s)
- return o;
- const [c, l2] = u, f2 = Math.floor(+c.getValue()), h = Math.floor(+l2.getValue());
- if (f2 <= 0 || h < 0)
- return g2.create(m2.VALUE);
- if (e.isNull() || f2 > n.length || h === 0)
- return j.create("");
- const d2 = n.substring(f2 - 1, f2 - 1 + h);
- return j.create(d2);
- }
- };
- var wE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
- const _ = u.get(h, d2), C = c.get(h, d2);
- return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSingleObject(f2, _, C);
- });
- return n === 1 && s === 1 ? l2.get(0, 0) : l2;
- }
- _handleSingleObject(e, t, r) {
- let n = De2(e);
- const { isError: s, errorObject: o, variants: u } = I2(t, r);
- if (s)
- return o;
- const [c, l2] = u, f2 = Math.floor(+c.getValue()), h = Math.floor(+l2.getValue());
- if (f2 <= 0 || h < 0)
- return g2.create(m2.VALUE);
- if (e.isNull() || f2 > n.length || h === 0)
- return j.create("");
- n = n.substring(f2 - 1);
- let d2 = 0, _ = 0, C = "";
- for (; _ < h && d2 < n.length; )
- _ += Qr2(n, d2), C += n.charAt(d2), d2++;
- return j.create(C);
- }
- };
- var DE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : j.create("."), s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- r != null && r.isArray() ? r.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- r != null && r.isArray() ? r.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, n, g2.create(m2.NA)), l2 = r ? O(s, o, r, g2.create(m2.NA)) : void 0, f2 = u.mapValue((h, d2, _) => {
- const C = c.get(d2, _), E2 = r ? l2.get(d2, _) : void 0;
- return h.isError() ? h : C.isError() ? C : E2 != null && E2.isError() ? E2 : C.isNull() || E2 != null && E2.isNull() ? g2.create(m2.VALUE) : h.isNull() ? y2.create(0) : this._handleSingleObject(h, C, E2);
- });
- return s === 1 && o === 1 ? f2.get(0, 0) : f2;
- }
- // eslint-disable-next-line
- _handleSingleObject(e, t, r) {
- let n = `${e.getValue()}`;
- n = n.replace(/\s+/g, "");
- let s = `${t.getValue()}`;
- t.isBoolean() && (s = s.toLocaleUpperCase()), s = s.charAt(0);
- let o;
- if (r && (o = `${r.getValue()}`, r.isBoolean() && (o = o.toLocaleUpperCase()), o = o.charAt(0), s === o))
- return g2.create(m2.VALUE);
- if (n.trim() === "")
- return y2.create(0);
- if (!n.match(/^\s*[+-]?\s*(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?[ \t]*/))
- return g2.create(m2.VALUE);
- const u = n.split(s);
- if (u.length > 2)
- return g2.create(m2.VALUE);
- let c = u[0].replace(/,/g, "");
- r && (c = c.split(o).join(""));
- let l2 = 0;
- if (u.length === 1) {
- s === "," && (c = c.replace(/\./g, ""));
- let f2 = 0;
- for (; c.endsWith("%"); )
- c = c.slice(0, -1), f2++;
- f2 > 0 ? l2 = +c / 100 ** f2 : l2 = +c;
- } else {
- if (!DC(c))
- return g2.create(m2.VALUE);
- let f2 = u[1], h = 0;
- for (; f2.endsWith("%"); )
- f2 = f2.slice(0, -1), h++;
- const d2 = `${c}.${f2}`;
- if (!DC(d2))
- return g2.create(m2.VALUE);
- h > 0 ? l2 = +d2 / 100 ** h : l2 = +d2;
- }
- return Number.isNaN(l2) ? g2.create(m2.VALUE) : y2.create(l2);
- }
- };
- var SE2 = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError() || e.isNull() || e.isBoolean() || e.isNumber())
- return e;
- const r = e.getValue().toLocaleString().toLocaleLowerCase().replace(/(^|\b|\W|\d|_)[a-z]/g, (n) => n.toLocaleUpperCase());
- return j.create(r);
- }
- };
- var Nu = () => [
- {
- type: 4,
- from: 48,
- to: 57
- }
- ];
- var Ou = () => [
- {
- type: 7,
- value: 95
- },
- {
- type: 4,
- from: 97,
- to: 122
- },
- {
- type: 4,
- from: 65,
- to: 90
- },
- {
- type: 4,
- from: 48,
- to: 57
- }
- ];
- var Mu = () => [
- {
- type: 7,
- value: 9
- },
- {
- type: 7,
- value: 10
- },
- {
- type: 7,
- value: 11
- },
- {
- type: 7,
- value: 12
- },
- {
- type: 7,
- value: 13
- },
- {
- type: 7,
- value: 32
- },
- {
- type: 7,
- value: 160
- },
- {
- type: 7,
- value: 5760
- },
- {
- type: 4,
- from: 8192,
- to: 8202
- },
- {
- type: 7,
- value: 8232
- },
- {
- type: 7,
- value: 8233
- },
- {
- type: 7,
- value: 8239
- },
- {
- type: 7,
- value: 8287
- },
- {
- type: 7,
- value: 12288
- },
- {
- type: 7,
- value: 65279
- }
- ];
- var wu = () => ({
- type: 3,
- set: Ou(),
- not: false
- });
- var Du = () => ({
- type: 3,
- set: Ou(),
- not: true
- });
- var Su = () => ({
- type: 3,
- set: Nu(),
- not: false
- });
- var Pu = () => ({
- type: 3,
- set: Nu(),
- not: true
- });
- var Lu = () => ({
- type: 3,
- set: Mu(),
- not: false
- });
- var xu = () => ({
- type: 3,
- set: Mu(),
- not: true
- });
- var PE = () => ({
- type: 3,
- set: [
- {
- type: 7,
- value: 10
- },
- {
- type: 7,
- value: 13
- },
- {
- type: 7,
- value: 8232
- },
- {
- type: 7,
- value: 8233
- }
- ],
- not: true
- });
- function LE(i) {
- const a2 = {
- type: 0,
- stack: []
- };
- let e = a2, t = a2.stack;
- const r = [], n = [];
- let s = 0;
- const o = (f2) => {
- throw new SyntaxError(`Invalid regular expression: /${i}/: Nothing to repeat at column ${f2 - 1}`);
- }, u = jE(i);
- let c = 0, l2;
- for (; c < u.length; )
- switch (l2 = u[c++], l2) {
- case "\\":
- if (c === u.length)
- throw new SyntaxError(`Invalid regular expression: /${i}/: \\ at end of pattern`);
- switch (l2 = u[c++], l2) {
- case "b":
- t.push({
- type: 2,
- value: "b"
- });
- break;
- case "B":
- t.push({
- type: 2,
- value: "B"
- });
- break;
- case "w":
- t.push(wu());
- break;
- case "W":
- t.push(Du());
- break;
- case "d":
- t.push(Su());
- break;
- case "D":
- t.push(Pu());
- break;
- case "s":
- t.push(Lu());
- break;
- case "S":
- t.push(xu());
- break;
- default:
- if (/\d/.test(l2)) {
- for (; /\d/.test(u[c]) && c < u.length; )
- l2 += u[c++];
- const f2 = Number.parseInt(l2, 10);
- t.push({
- type: 6,
- value: f2
- }), n.push({
- reference: {
- type: 6,
- value: f2
- },
- stack: t,
- index: t.length - 1
- });
- } else
- t.push({
- type: 7,
- value: l2.charCodeAt(0)
- });
- }
- break;
- case "^":
- t.push({
- type: 2,
- value: "^"
- });
- break;
- case "$":
- t.push({
- type: 2,
- value: "$"
- });
- break;
- case "[": {
- const f2 = u[c] === "^";
- f2 && c++;
- const h = xE(u.slice(c), i);
- c += h[1], t.push({
- type: 3,
- set: h[0],
- not: f2
- });
- break;
- }
- case ".":
- t.push(PE());
- break;
- case "(": {
- const f2 = {
- type: 1,
- stack: [],
- remember: true
- // 默认情况下,捕获组是需要记住(捕获)的
- };
- if (u[c] === "?") {
- const h = u[c + 1];
- if (c += 2, h === "=")
- f2.followedBy = true;
- else if (h === "!")
- f2.notFollowedBy = true;
- else if (h !== ":")
- throw new SyntaxError(`Invalid regular expression: /${i}/: Invalid group, character '${h}' after '?' at column ${c - 1}`);
- f2.remember = false;
- } else
- s += 1;
- t.push(f2), r.push(e), e = f2, t = f2.stack;
- break;
- }
- case ")":
- if (r.length === 0)
- throw new SyntaxError(`Invalid regular expression: /${i}/: Unmatched ) at column ${c - 1}`);
- e = r.pop(), t = e.options ? e.options[e.options.length - 1] : e.stack;
- break;
- case "|": {
- e.options || (e.options = [e.stack], delete e.stack);
- const f2 = [];
- e.options.push(f2), t = f2;
- break;
- }
- case "{": {
- const f2 = /^(\d+)(,(\d+)?)?\}/.exec(u.slice(c));
- if (f2) {
- t.length === 0 && o(c);
- const h = Number.parseInt(f2[1], 10), d2 = f2[2] ? f2[3] ? Number.parseInt(f2[3], 10) : 1 / 0 : h;
- c += f2[0].length, t.push({
- type: 5,
- min: h,
- max: d2,
- value: t.pop()
- });
- } else
- t.push({
- // Assuming 123 is the character code for '{'
- type: 7,
- value: 123
- });
- break;
- }
- case "?":
- t.length === 0 && o(c), t.push({
- type: 5,
- min: 0,
- max: 1,
- value: t.pop()
- });
- break;
- case "+":
- t.length === 0 && o(c), t.push({
- type: 5,
- min: 1,
- max: 1 / 0,
- value: t.pop()
- });
- break;
- case "*":
- t.length === 0 && o(c), t.push({
- type: 5,
- min: 0,
- max: 1 / 0,
- value: t.pop()
- });
- break;
- default:
- t.push({
- type: 7,
- value: l2.charCodeAt(0)
- });
- }
- if (r.length > 0)
- throw new SyntaxError(`Invalid regular expression: /${i}/: Unterminated group`);
- return UE(n, s), a2;
- }
- function xE(i, a2) {
- let e;
- const t = [], r = /\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;
- for (; (e = r.exec(i)) !== null; ) {
- let n = null;
- const [, s, o, u, c, l2, f2, h, d2, _, C] = e;
- if (s || o || u || c || l2 || f2 ? n = (() => {
- let E2 = {
- type: 3,
- set: [],
- not: false
- };
- return s ? E2 = wu() : o ? E2 = Su() : u ? E2 = Lu() : c ? E2 = Du() : l2 ? E2 = Pu() : f2 && (E2 = xu()), E2;
- })() : h && C ? n = {
- type: 4,
- from: (d2 || _).charCodeAt(0),
- to: C.charCodeAt(C.length - 1)
- } : e[16] && (n = {
- type: 7,
- value: e[16].charCodeAt(0)
- }), !n)
- return [t, r.lastIndex];
- t.push(n);
- }
- throw new SyntaxError(`Invalid regular expression: /${a2}/: Unterminated character class`);
- }
- function jE(i) {
- return i.replace(
- /(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,
- (a2, e, t, r, n, s, o) => {
- if (t)
- return a2;
- let u;
- e ? u = 8 : r ? u = Number.parseInt(r, 16) : n ? u = Number.parseInt(n, 16) : s ? u = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s) : u = {
- 0: 0,
- t: 9,
- n: 10,
- v: 11,
- f: 12,
- r: 13
- }[o];
- const c = String.fromCharCode(u);
- return /[[\]{}^$.|?*+()]/.test(c) ? `\\${c}` : c;
- }
- );
- }
- function UE(i, a2) {
- for (const e of i.reverse()) {
- const t = e.reference.value;
- if (a2 < t) {
- e.reference.type = 7;
- const r = t.toString();
- if (e.reference.value = Number.parseInt(r, 8), !/^[0-7]+$/.test(r)) {
- let n = 0;
- for (; r[n] !== "8" && r[n] !== "9" && n < r.length; )
- n += 1;
- if (n === 0 ? (e.reference.value = r.charCodeAt(0), n += 1) : e.reference.value = Number.parseInt(r.slice(0, n), 8), r.length > n) {
- const s = e.stack.splice(e.index + 1);
- for (const o of r.slice(n))
- e.stack.push({
- type: 7,
- value: o.charCodeAt(0)
- });
- e.stack.push(...s);
- }
- }
- }
- }
- }
- function Ya(i, a2) {
- if (!vE(i))
- return {
- isError: true,
- regExp: null
- };
- try {
- const e = new RegExp(i, a2 ? "ug" : "u");
- return TE(e) ? {
- isError: false,
- regExp: e
- } : {
- isError: true,
- regExp: null
- };
- } catch {
- return {
- isError: true,
- regExp: null
- };
- }
- }
- function vE(i) {
- return !(/\(\?<=.*?\)/g.test(i) && !/\[.*?(\?<=.*?)\]/g.test(i) || /\(\?<!.*?\)/g.test(i) && !/\[.*?(\?<!.*?)\]/g.test(i));
- }
- function TE(i, a2) {
- let t;
- Object.prototype.toString.call(i) === "[object RegExp]" ? t = i.source : i && typeof i != "string" && (t = `${i}`);
- let r;
- try {
- r = LE(t);
- } catch {
- return false;
- }
- let n = 0;
- const s = (o, u) => {
- let c = u;
- if (o.type === 5 && (c++, n++, c > 1 || n > 25))
- return false;
- if (o.options) {
- for (const f2 of o.options)
- if (!s({ stack: f2 }, c))
- return false;
- }
- const l2 = o.stack || o.value && o.value.stack;
- if (!l2)
- return true;
- for (const f2 of l2)
- if (!s(f2, c))
- return false;
- return true;
- };
- return s(r, 0);
- }
- var BE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = Fr(e, t);
- if (r)
- return n;
- const [o, u] = s;
- let c = o.getValue();
- o.isNull() && (c = ""), o.isBoolean() && (c = c ? "TRUE" : "FALSE"), c = `${c}`;
- let l2 = u.getValue();
- u.isNull() && (l2 = ""), u.isBoolean() && (l2 = l2 ? "TRUE" : "FALSE"), l2 = `${l2}`;
- const { isError: f2, regExp: h } = Ya(l2, false);
- if (f2)
- return g2.create(m2.REF);
- const d2 = c.match(h);
- if (d2 === null)
- return g2.create(m2.NA);
- if (d2.length > 1) {
- const _ = d2.slice(1).map((C) => j.create(C));
- return _.length > 1 ? q2.create({
- calculateValueList: [_],
- rowCount: 1,
- columnCount: _.length,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- }) : _[0];
- }
- return j.create(d2[0]);
- }
- };
- var IE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = Fr(e, t);
- if (r)
- return n;
- const [o, u] = s;
- let c = o.getValue();
- o.isNull() && (c = ""), o.isBoolean() && (c = c ? "TRUE" : "FALSE"), c = `${c}`;
- let l2 = u.getValue();
- u.isNull() && (l2 = ""), u.isBoolean() && (l2 = l2 ? "TRUE" : "FALSE"), l2 = `${l2}`;
- const { isError: f2, regExp: h } = Ya(l2, false);
- return f2 ? g2.create(m2.REF) : c.match(h) === null ? T2.create(false) : T2.create(true);
- }
- };
- var FE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = Fr(e, t, r);
- if (n)
- return s;
- const [u, c, l2] = o;
- let f2 = u.getValue();
- u.isNull() && (f2 = ""), u.isBoolean() && (f2 = f2 ? "TRUE" : "FALSE"), f2 = `${f2}`;
- let h = c.getValue();
- c.isNull() && (h = ""), c.isBoolean() && (h = h ? "TRUE" : "FALSE"), h = `${h}`;
- let d2 = l2.getValue();
- l2.isNull() && (d2 = ""), l2.isBoolean() && (d2 = d2 ? "TRUE" : "FALSE"), d2 = `${d2}`;
- const { isError: _, regExp: C } = Ya(h, true);
- if (_)
- return g2.create(m2.REF);
- const E2 = f2.replace(C, d2);
- return j.create(E2);
- }
- };
- var kE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSingleObject(d2, E2, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSingleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(t, r);
- if (s)
- return o;
- const [c, l2] = u, f2 = Math.floor(+c.getValue()), h = Math.floor(+l2.getValue());
- if (f2 <= 0 || h < 0)
- return g2.create(m2.VALUE);
- const d2 = De2(e), _ = De2(n), C = d2.substring(0, f2 - 1) + _ + d2.substring(f2 - 1 + h);
- return j.create(C);
- }
- };
- var $E = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSingleObject(d2, E2, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSingleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I2(t, r);
- if (s)
- return o;
- const [c, l2] = u, f2 = Math.floor(+c.getValue()), h = Math.floor(+l2.getValue());
- if (f2 <= 0 || h < 0)
- return g2.create(m2.VALUE);
- let d2 = De2(e);
- const _ = De2(n);
- let C = d2.substring(0, f2 - 1);
- d2 = d2.substring(f2 - 1);
- let E2 = 0, b = 0;
- for (; b < h && E2 < d2.length; )
- b += Qr2(d2, E2), E2++;
- return C += _ + d2.substring(E2), j.create(C);
- }
- };
- var YE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
- let h = o.get(l2, f2);
- if (c.isError())
- return c;
- let d2 = c.getValue();
- if (c.isNull() && (d2 = ""), c.isBoolean() && (d2 = d2 ? "TRUE" : "FALSE"), d2 += "", h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- const _ = 32767, C = Math.floor(+h.getValue());
- if (C < 0 || C > _ / d2.length)
- return g2.create(m2.VALUE);
- const E2 = d2.repeat(C);
- return j.create(E2);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- };
- var HE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(1), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
- const d2 = u.get(f2, h);
- return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const r = De2(e), { isError: n, errorObject: s, variants: o } = I2(t);
- if (n)
- return s;
- const [u] = o, c = Math.floor(+u.getValue());
- if (c < 0)
- return g2.create(m2.VALUE);
- if (e.isNull() || c === 0)
- return j.create("");
- if (c >= r.length)
- return j.create(r);
- const l2 = r.substring(r.length - c);
- return j.create(l2);
- }
- };
- var GE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(1), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
- const d2 = u.get(f2, h);
- return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const r = De2(e), { isError: n, errorObject: s, variants: o } = I2(t);
- if (n)
- return s;
- const [u] = o, c = Math.floor(+u.getValue());
- if (c < 0)
- return g2.create(m2.VALUE);
- if (e.isNull() || c === 0)
- return j.create("");
- let l2 = r.length - 1, f2 = 0, h = "";
- for (; f2 < c && l2 >= 0; )
- f2 += Qr2(r, l2, "rtl"), h = r.charAt(l2) + h, l2--;
- return j.create(h);
- }
- };
- var QE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y2.create(1), s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.mapValue((h, d2, _) => {
- const C = c.get(d2, _), E2 = l2.get(d2, _);
- return h.isError() ? h : C.isError() ? C : E2.isError() ? E2 : this._handleSingleObject(h, C, E2);
- });
- return s === 1 && o === 1 ? f2.get(0, 0) : f2;
- }
- _handleSingleObject(e, t, r) {
- const n = De2(e).toLocaleUpperCase(), s = De2(t).toLocaleUpperCase(), { isError: o, errorObject: u, variants: c } = I2(r);
- if (o)
- return u;
- const [l2] = c, f2 = Math.floor(+l2.getValue());
- if (t.isNull() || f2 <= 0 || f2 > s.length)
- return g2.create(m2.VALUE);
- if (e.isNull() || n.length === 0)
- return y2.create(f2);
- const h = s.indexOf(n, f2 - 1);
- return h === -1 ? g2.create(m2.VALUE) : y2.create(h + 1);
- }
- };
- var WE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y2.create(1), s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.mapValue((h, d2, _) => {
- const C = c.get(d2, _), E2 = l2.get(d2, _);
- return h.isError() ? h : C.isError() ? C : E2.isError() ? E2 : this._handleSingleObject(h, C, E2);
- });
- return s === 1 && o === 1 ? f2.get(0, 0) : f2;
- }
- _handleSingleObject(e, t, r) {
- const n = De2(e).toLocaleUpperCase(), s = De2(t).toLocaleUpperCase(), { isError: o, errorObject: u, variants: c } = I2(r);
- if (o)
- return u;
- const [l2] = c, f2 = Math.floor(+l2.getValue());
- if (t.isNull() || f2 <= 0 || f2 > s.length)
- return g2.create(m2.VALUE);
- if (e.isNull() || n.length === 0)
- return y2.create(f2);
- const h = s.indexOf(n, f2 - 1);
- if (h === -1)
- return g2.create(m2.VALUE);
- const d2 = $a(s.substring(0, h)) + 1;
- return y2.create(d2);
- }
- };
- var qE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n != null && n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n != null && n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = n ? O(s, o, n, g2.create(m2.NA)) : void 0, h = u.mapValue((d2, _, C) => {
- const E2 = c.get(_, C), b = l2.get(_, C);
- let R = n ? f2.get(_, C) : void 0;
- return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R != null && R.isError() ? R : R != null && R.isNull() || R != null && R.isBoolean() ? g2.create(m2.VALUE) : (R != null && R.isString() && (R = R.convertToNumberObjectValue()), R != null && R.isError() ? R : this._handleSingleObject(d2, E2, b, R));
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSingleObject(e, t, r, n) {
- const s = this._getObjectString(e), o = this._getObjectString(t), u = this._getObjectString(r), c = n ? Math.floor(+n.getValue()) : void 0;
- if (n && c <= 0)
- return g2.create(m2.VALUE);
- if (o === "")
- return j.create(s);
- let l2 = "", f2 = 0;
- for (let h = 0; h < s.length; h++) {
- const d2 = s.substr(h, o.length);
- if (d2 === o || d2.length === o.length && d2.trim() === o.trim()) {
- if (f2++, f2 === c) {
- l2 = s.substr(0, h) + u + s.substr(h + o.length);
- break;
- }
- c === void 0 && (l2 += u), h += o.length - 1;
- } else
- c === void 0 && (l2 += s[h]);
- }
- return c && f2 < c && (l2 = s), j.create(l2);
- }
- _getObjectString(e) {
- let t = `${e.getValue()}`;
- return e.isNull() && (t = ""), e.isBoolean() && (t = t.toLocaleUpperCase()), t;
- }
- };
- var KE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return e.isArray() && (t = e.get(0, 0)), t.isError() ? t : t.isNull() || t.isBoolean() || t.isNumber() ? j.create("") : t;
- }
- };
- var XE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e), o = O(r, n, t);
- return s.map((u, c, l2) => {
- if (u.isError())
- return u;
- let f2 = o.get(c, l2) || j.create(" ");
- if (f2.isError())
- return f2;
- if (f2.isBoolean())
- return g2.create(m2.VALUE);
- if (u.isBoolean())
- return u;
- let h = u.getValue();
- if (u.isNull() && (h = 0), u.isString()) {
- if (!DC(h))
- return u;
- h = Number(h);
- }
- f2.isNull() && (f2 = j.create(" "));
- const d2 = `${f2.getValue()}`, _ = ka(d2, h);
- return j.create(d2 === " " ? _.trimEnd() : _);
- });
- }
- };
- var ZE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = false, c = r != null ? r : y2.create(1);
- c.isNull() && (u = true, c = y2.create(1));
- const l2 = !n, f2 = n != null ? n : y2.create(0), h = s != null ? s : y2.create(0), d2 = o != null ? o : g2.create(m2.NA), _ = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- f2.isArray() ? f2.getRowCount() : 1,
- h.isArray() ? h.getRowCount() : 1,
- d2.isArray() ? d2.getRowCount() : 1
- ), C = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- f2.isArray() ? f2.getColumnCount() : 1,
- h.isArray() ? h.getColumnCount() : 1,
- d2.isArray() ? d2.getColumnCount() : 1
- ), E2 = O(_, C, e, g2.create(m2.NA)), b = O(_, C, c, g2.create(m2.NA)), R = O(_, C, f2, g2.create(m2.NA)), p2 = O(_, C, h, g2.create(m2.NA)), N2 = O(_, C, d2, g2.create(m2.NA)), M2 = this._getResultArray(E2, t, b, R, p2, N2, u, l2);
- return _ === 1 && C === 1 ? M2.get(0, 0) : M2;
- }
- _getResultArray(e, t, r, n, s, o, u, c) {
- return e.map((f2, h, d2) => {
- const _ = r.get(h, d2), C = n.get(h, d2), E2 = s.get(h, d2), b = o.get(h, d2), R = this._checkVariantsError(f2, _, C, E2);
- if (R.isError())
- return R;
- const p2 = this._getStringValue(f2), N2 = this._getDelimiterValue(t);
- if (N2 instanceof g2)
- return N2;
- const M2 = this._getVariantsNumberFloorValue(_, C, E2);
- if (M2 instanceof g2)
- return M2;
- const [w, D2, S2] = M2;
- return w === 0 || D2 < 0 || D2 > 1 || S2 < 0 || S2 > 1 ? g2.create(m2.VALUE) : N2.includes("") ? w > 0 ? j.create(p2) : j.create("") : !u && Math.abs(w) > p2.length ? g2.create(m2.VALUE) : N2.every((P) => P.length > p2.length) ? g2.create(m2.NA) : this._getResult(p2, N2, w, D2, S2, b, c);
- });
- }
- _checkVariantsError(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- if (r.isError())
- return r;
- }
- return T2.create(true);
- }
- _getStringValue(e) {
- let t = `${e.getValue()}`;
- return e.isNull() && (t = ""), e.isBoolean() && (t = t.toLocaleUpperCase()), t;
- }
- _getDelimiterValue(e) {
- const t = [];
- if (e.isArray()) {
- let r = false, n = g2.create(m2.VALUE);
- if (e.iterator((s) => {
- const o = s;
- if (o.isError())
- return r = true, n = o, false;
- t.push(this._getStringValue(o));
- }), r)
- return n;
- } else {
- if (e.isError())
- return e;
- t.push(this._getStringValue(e));
- }
- return t;
- }
- _getVariantsNumberFloorValue(...e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- const s = Math.floor(+n.getValue());
- t.push(s);
- }
- return t;
- }
- _getResult(e, t, r, n, s, o, u) {
- let c = n ? e.toLocaleLowerCase() : e;
- const l2 = n ? t.map((C) => C.toLocaleLowerCase()) : t;
- let f2 = 0, h = 0, d2 = 0;
- for (let C = 0; C < Math.abs(r); C++)
- if (r < 0) {
- const E2 = l2.map((b) => ({
- index: c.lastIndexOf(b),
- length: b.length
- })).filter((b) => b.index !== -1).sort((b, R) => R.index - b.index)[0];
- if (!E2)
- break;
- f2 = E2.index, c = c.substr(0, E2.index), d2 = E2.length, h++;
- } else {
- const E2 = l2.map((b) => ({
- index: c.indexOf(b),
- length: b.length
- })).filter((b) => b.index !== -1).sort((b, R) => b.index - R.index)[0];
- if (!E2)
- break;
- f2 += E2.index + d2, c = c.substr(E2.index + E2.length), d2 = E2.length, h++;
- }
- if (h && h < Math.abs(r) && u)
- return g2.create(m2.NA);
- if (!h || h < Math.abs(r))
- return s ? r > 0 ? j.create("") : j.create(e) : o;
- const _ = e.substr(f2 + d2);
- return j.create(_);
- }
- };
- var zE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = false, c = r != null ? r : y2.create(1);
- c.isNull() && (u = true, c = y2.create(1));
- const l2 = !n, f2 = n != null ? n : y2.create(0), h = s != null ? s : y2.create(0), d2 = o != null ? o : g2.create(m2.NA), _ = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- f2.isArray() ? f2.getRowCount() : 1,
- h.isArray() ? h.getRowCount() : 1,
- d2.isArray() ? d2.getRowCount() : 1
- ), C = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- f2.isArray() ? f2.getColumnCount() : 1,
- h.isArray() ? h.getColumnCount() : 1,
- d2.isArray() ? d2.getColumnCount() : 1
- ), E2 = O(_, C, e, g2.create(m2.NA)), b = O(_, C, c, g2.create(m2.NA)), R = O(_, C, f2, g2.create(m2.NA)), p2 = O(_, C, h, g2.create(m2.NA)), N2 = O(_, C, d2, g2.create(m2.NA)), M2 = this._getResultArray(E2, t, b, R, p2, N2, u, l2);
- return _ === 1 && C === 1 ? M2.get(0, 0) : M2;
- }
- _getResultArray(e, t, r, n, s, o, u, c) {
- return e.map((f2, h, d2) => {
- const _ = r.get(h, d2), C = n.get(h, d2), E2 = s.get(h, d2), b = o.get(h, d2), R = this._checkVariantsError(f2, _, C, E2);
- if (R.isError())
- return R;
- const p2 = this._getStringValue(f2), N2 = this._getDelimiterValue(t);
- if (N2 instanceof g2)
- return N2;
- const M2 = this._getVariantsNumberFloorValue(_, C, E2);
- if (M2 instanceof g2)
- return M2;
- const [w, D2, S2] = M2;
- return w === 0 || D2 < 0 || D2 > 1 || S2 < 0 || S2 > 1 ? g2.create(m2.VALUE) : N2.includes("") ? w > 0 ? j.create("") : j.create(p2) : !u && Math.abs(w) > p2.length ? g2.create(m2.VALUE) : N2.every((P) => P.length > p2.length) ? g2.create(m2.NA) : this._getResult(p2, N2, w, D2, S2, b, c);
- });
- }
- _checkVariantsError(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- if (r.isError())
- return r;
- }
- return T2.create(true);
- }
- _getStringValue(e) {
- let t = `${e.getValue()}`;
- return e.isNull() && (t = ""), e.isBoolean() && (t = t.toLocaleUpperCase()), t;
- }
- _getDelimiterValue(e) {
- const t = [];
- if (e.isArray()) {
- let r = false, n = g2.create(m2.VALUE);
- if (e.iterator((s) => {
- const o = s;
- if (o.isError())
- return r = true, n = o, false;
- t.push(this._getStringValue(o));
- }), r)
- return n;
- } else {
- if (e.isError())
- return e;
- t.push(this._getStringValue(e));
- }
- return t;
- }
- _getVariantsNumberFloorValue(...e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- const s = Math.floor(+n.getValue());
- t.push(s);
- }
- return t;
- }
- _getResult(e, t, r, n, s, o, u) {
- let c = n ? e.toLocaleLowerCase() : e;
- const l2 = n ? t.map((C) => C.toLocaleLowerCase()) : t;
- let f2 = 0, h = 0, d2 = 0;
- for (let C = 0; C < Math.abs(r); C++)
- if (r < 0) {
- const E2 = l2.map((b) => ({
- index: c.lastIndexOf(b),
- length: b.length
- })).filter((b) => b.index !== -1).sort((b, R) => R.index - b.index)[0];
- if (!E2)
- break;
- f2 = E2.index, c = c.substr(0, E2.index), h++;
- } else {
- const E2 = l2.map((b) => ({
- index: c.indexOf(b),
- length: b.length
- })).filter((b) => b.index !== -1).sort((b, R) => b.index - R.index)[0];
- if (!E2)
- break;
- f2 += E2.index + d2, c = c.substr(E2.index + E2.length), d2 = E2.length, h++;
- }
- if (h && h < Math.abs(r) && u)
- return g2.create(m2.NA);
- if (!h || h < Math.abs(r))
- return s ? r > 0 ? j.create(e) : j.create("") : o;
- const _ = e.substr(0, f2);
- return j.create(_);
- }
- };
- var JE = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(e, t, ...r) {
- const n = this._getDelimiterValues(e), s = this._getTextValues(r);
- if (t.isArray()) {
- const u = t.mapValue((c) => this._handleSingleObject(n, c, s));
- return u.getRowCount() === 1 && u.getColumnCount() === 1 ? u.get(0, 0) : u;
- }
- const o = t;
- if (o.isString()) {
- const u = `${o.getValue()}`.toLocaleUpperCase();
- if (u === "TRUE")
- return this._handleSingleObject(n, T2.create(true), s);
- if (u === "FALSE")
- return this._handleSingleObject(n, T2.create(false), s);
- }
- return this._handleSingleObject(n, t, s);
- }
- _handleSingleObject(e, t, r) {
- if (e instanceof g2)
- return e;
- const { isError: n, errorObject: s, variants: o } = I2(t);
- if (n)
- return s;
- if (r instanceof g2)
- return r;
- const [u] = o, c = +u.getValue();
- let l2 = r;
- c && (l2 = r.filter((h) => h !== null));
- let f2 = "";
- for (let h = 0; h < l2.length; h++)
- l2[h] !== null && (f2 += l2[h]), h < l2.length - 1 && (f2 += e[h % e.length]);
- return j.create(f2);
- }
- _getDelimiterValues(e) {
- const t = [], r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1;
- for (let s = 0; s < r; s++)
- for (let o = 0; o < n; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- let c = `${u.getValue()}`;
- u.isNull() && (c = ""), u.isBoolean() && (c = c.toLocaleUpperCase()), t.push(c);
- }
- return t;
- }
- _getTextValues(e) {
- const t = [];
- for (const r of e) {
- const n = r.isArray() ? r.getRowCount() : 1, s = r.isArray() ? r.getColumnCount() : 1;
- for (let o = 0; o < n; o++)
- for (let u = 0; u < s; u++) {
- const c = r.isArray() ? r.get(o, u) : r;
- if (c.isError())
- return c;
- if (c.isNull()) {
- t.push(null);
- continue;
- }
- let l2 = `${c.getValue()}`;
- c.isBoolean() && (l2 = l2.toLocaleUpperCase()), t.push(l2);
- }
- }
- return t;
- }
- };
- var eb = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = r != null ? r : j.create("\\s");
- const c = n != null ? n : y2.create(0), l2 = s != null ? s : y2.create(0), f2 = o != null ? o : j.create(m2.NA), { _variant: h, values: d2 } = this._getStringValues(t), { _variant: _, values: C } = this._getStringValues(u, false);
- u = _;
- const E2 = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- l2.isArray() ? l2.getRowCount() : 1
- ), b = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- l2.isArray() ? l2.getColumnCount() : 1
- ), R = O(E2, b, e, g2.create(m2.NA)), p2 = O(E2, b, c, g2.create(m2.NA)), N2 = O(E2, b, l2, g2.create(m2.NA)), M2 = this._getResultArray(
- R,
- h,
- u,
- p2,
- N2,
- f2,
- d2,
- C
- );
- return E2 === 1 && b === 1 ? M2.get(0, 0) : M2.map((w) => w.get(0, 0));
- }
- _getStringValues(e, t = true) {
- let r = e;
- const n = [];
- if (r.isArray())
- r.iterator((s) => {
- if (s != null && s.isError())
- return r = s, false;
- if (s != null && s.isNull() && t)
- return r = g2.create(m2.VALUE), false;
- const o = this._getRegExpStringValue(s);
- if (o === "")
- return r = g2.create(m2.VALUE), false;
- n.push(o);
- });
- else {
- r.isNull() && t && (r = g2.create(m2.VALUE));
- const s = this._getRegExpStringValue(r);
- s === "" && (r = g2.create(m2.VALUE)), n.push(s);
- }
- return {
- _variant: r,
- values: n
- };
- }
- _getResultArray(e, t, r, n, s, o, u, c) {
- return e.map((f2, h, d2) => {
- let _ = n.get(h, d2), C = s.get(h, d2);
- const E2 = this._checkVariantsError(f2, t, r, _, C);
- if (E2.isError())
- return E2;
- if (f2.isNull())
- return g2.create(m2.VALUE);
- let b = o;
- if (b.isArray()) {
- const w = b.getRowCount(), D2 = b.getColumnCount();
- if (w > 1 || D2 > 1)
- return g2.create(m2.VALUE);
- b = b.get(0, 0);
- }
- let R = `${f2.getValue()}`;
- if (f2.isBoolean() && (R = R.toLocaleUpperCase()), _.isString() && (_ = _.convertToNumberObjectValue(), _.isError()))
- return _;
- const p2 = Math.floor(+_.getValue());
- if (C.isString() && (C = C.convertToNumberObjectValue(), C.isError()))
- return C;
- const N2 = Math.floor(+C.getValue());
- if (N2 < 0 || N2 > 1)
- return g2.create(m2.VALUE);
- let M2 = `${b.getValue()}`;
- return b.isBoolean() && (M2 = M2.toLocaleUpperCase()), this._getResult(R, u, c, p2, N2, M2);
- });
- }
- _getResult(e, t, r, n, s, o) {
- const u = new RegExp(r.join("|"), `g${s ? "i" : ""}`), c = new RegExp(t.join("|"), `g${s ? "i" : ""}`), l2 = e.split(u);
- let f2 = 1, h = l2.map((d2) => {
- let _ = d2.split(c);
- return n && (_ = _.filter((C) => C !== "")), f2 = Math.max(f2, _.length), _;
- });
- return h = h.map((d2) => {
- let _ = d2;
- return _.length < f2 && (_ = _.concat(new Array(f2 - _.length).fill(o))), _;
- }), q2.createByArray(h);
- }
- _checkVariantsError(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- if (r.isError())
- return r;
- }
- return T2.create(true);
- }
- _getRegExpStringValue(e) {
- let t = e.getValue();
- return e.isNull() && (t = "\\s"), e.isBoolean() && (t = t ? "TRUE" : "FALSE"), t += "", this._escapeRegExp(t);
- }
- _escapeRegExp(e) {
- return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
- }
- };
- var tb = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return j.create("");
- let t = `${e.getValue()}`;
- return e.isBoolean() && (t = t.toLocaleUpperCase()), t = t.trim().replace(/\s+/g, " "), j.create(t);
- }
- };
- var rb = Object.values(ln).filter((i) => [
- ln.TABLE_START,
- ln.TABLE_ROW_START,
- ln.TABLE_CELL_START,
- ln.TABLE_CELL_END,
- ln.TABLE_ROW_END,
- ln.TABLE_END,
- ln.CUSTOM_BLOCK
- ].includes(i));
- var nb = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I2(e);
- if (t)
- return r;
- const [s] = n, o = Math.floor(+s.getValue());
- if (o < 1 || o > 1114111)
- return g2.create(m2.VALUE);
- if (o === 1114111 || o === 1114110)
- return g2.create(m2.NA);
- let u = String.fromCharCode(o);
- return rb.some((c) => c === u) && (u = ""), j.create(u);
- }
- };
- var sb = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return g2.create(m2.VALUE);
- let t = e.getValue().toLocaleString();
- e.isBoolean() && (t = t.toLocaleUpperCase());
- const r = t.charCodeAt(0);
- return y2.create(r);
- }
- };
- var ab = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return j.create("");
- const t = `${e.getValue()}`.toLocaleUpperCase();
- return j.create(t);
- }
- };
- var ib = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isBoolean())
- return g2.create(m2.VALUE);
- let t = e;
- if (e.isString() && (t = t.convertToNumberObjectValue(), t.isError()))
- return t;
- const r = +t.getValue();
- return y2.create(r);
- }
- };
- var ob = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y2.create(0), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
- const d2 = u.get(f2, h);
- return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I2(t);
- if (r)
- return n;
- const [o] = s, u = Math.floor(+o.getValue());
- if (u < 0 || u > 1)
- return g2.create(m2.VALUE);
- if (e.isNull())
- return j.create("");
- if (e.isBoolean())
- return e;
- if (e.isNumber())
- return y2.create(e.getValue());
- const c = u ? `"${e.getValue()}"` : `${e.getValue()}`;
- return j.create(c);
- }
- };
- var ub = [
- [oE, se.ASC],
- [iE, se.ARRAYTOTEXT],
- [uE, se.BAHTTEXT],
- [lE, se.CHAR],
- [fE, se.CLEAN],
- [hE, se.CODE],
- [mE, se.CONCAT],
- [gE, se.CONCATENATE],
- [dE, se.DBCS],
- [CE, se.DOLLAR],
- [_E, se.EXACT],
- [AE, se.FIND],
- [bE, se.FINDB],
- [yE, se.FIXED],
- [RE, se.LEFT],
- [pE, se.LEFTB],
- [VE, se.LEN],
- [NE, se.LENB],
- [OE, se.LOWER],
- [ME, se.MID],
- [wE, se.MIDB],
- [DE, se.NUMBERVALUE],
- [BE, se.REGEXEXTRACT],
- [IE, se.REGEXMATCH],
- [FE, se.REGEXREPLACE],
- [SE2, se.PROPER],
- [kE, se.REPLACE],
- [$E, se.REPLACEB],
- [YE, se.REPT],
- [HE, se.RIGHT],
- [GE, se.RIGHTB],
- [QE, se.SEARCH],
- [WE, se.SEARCHB],
- [qE, se.SUBSTITUTE],
- [KE, se.T],
- [XE, se.TEXT],
- [ZE, se.TEXTAFTER],
- [zE, se.TEXTBEFORE],
- [JE, se.TEXTJOIN],
- [eb, se.TEXTSPLIT],
- [tb, se.TRIM],
- [nb, se.UNICHAR],
- [sb, se.UNICODE],
- [ab, se.UPPER],
- [ib, se.VALUE],
- [ob, se.VALUETOTEXT]
- ];
- var cb = [];
- var lb = ((i) => i)(lb || {});
- var fb = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- const t = De2(e), r = encodeURIComponent(t).replace(/[!~'()*]/g, (n) => `%${n.charCodeAt(0).toString(16).toLocaleUpperCase()}`);
- return j.create(r);
- }
- };
- var ju = ((i) => (i.ENCODEURL = "ENCODEURL", i.FILTERXML = "FILTERXML", i.WEBSERVICE = "WEBSERVICE", i))(ju || {});
- var hb = [
- [fb, ju.ENCODEURL]
- ];
- var mb = Object.defineProperty;
- var gb = Object.getOwnPropertyDescriptor;
- var db = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? gb(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && mb(a2, e, r), r;
- };
- var Zr = (i, a2) => (e, t) => a2(e, t, i);
- var wn = class extends nt {
- constructor(i, a2, e, t) {
- super(), this._commandService = i, this._functionService = a2, this._configService = e, this._dataSyncPrimaryController = t, this._initialize();
- }
- _initialize() {
- this._registerCommands(), this._registerFunctions();
- }
- _registerCommands() {
- [
- eo,
- bs,
- Zi,
- zi,
- Ns,
- Ji,
- sa,
- Xi,
- aa,
- ia,
- oa,
- ua,
- jc,
- Uc,
- to,
- bc
- ].forEach((i) => {
- var a2;
- this._commandService.registerCommand(i), (a2 = this._dataSyncPrimaryController) == null || a2.registerSyncingMutations(i);
- });
- }
- _registerFunctions() {
- var e;
- const i = this._configService.getConfig(fa), a2 = [
- ...Yh,
- ...pm,
- ...Vm,
- ...Im,
- ...Rg,
- ...O1,
- ...P0,
- ...td,
- ...yd,
- ...rC,
- ...D_,
- ...v_,
- ...aE,
- ...ub,
- ...cb,
- ...hb
- ].concat((e = i == null ? void 0 : i.function) != null ? e : []).map((t) => {
- const r = t[0], n = t[1];
- return new r(n);
- });
- this._functionService.registerExecutors(...a2);
- }
- };
- wn = db([
- Zr(0, Pt),
- Zr(1, Yt),
- Zr(2, SE),
- Zr(3, nf(g))
- ], wn);
- var Cb = Object.defineProperty;
- var _b = Object.getOwnPropertyDescriptor;
- var Ab = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? _b(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Cb(a2, e, r), r;
- };
- var zr = (i, a2) => (e, t) => a2(e, t, i);
- var Dn = class extends nt {
- constructor(i, a2, e) {
- super(), this._commandService = i, this._dependencyManagerService = a2, this._featureCalculationManagerService = e, this._initialize();
- }
- _initialize() {
- this._commandExecutedListener(), this._featureCalculationManagerServiceListener();
- }
- _featureCalculationManagerServiceListener() {
- this.disposeWithMe(
- this._featureCalculationManagerService.onChanged$.subscribe((i) => {
- const { unitId: a2, subUnitId: e, featureIds: t } = i;
- this._dependencyManagerService.removeFeatureFormulaDependency(a2, e, t);
- })
- );
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- if (i.id === ia.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const { featureIds: e, unitId: t, subUnitId: r } = a2;
- this._dependencyManagerService.removeFeatureFormulaDependency(t, r, e);
- } else if (i.id === aa.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const { featureId: e, calculationParam: t } = a2, { unitId: r, subUnitId: n } = t;
- this._dependencyManagerService.removeFeatureFormulaDependency(r, n, [e]);
- } else if (i.id === ua.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- this._dependencyManagerService.removeOtherFormulaDependency(a2.unitId, a2.subUnitId, a2.formulaIdList);
- } else if (i.id === oa.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const e = a2.formulaMap, t = [];
- Object.keys(e).forEach((r) => {
- t.push(r);
- }), this._dependencyManagerService.removeOtherFormulaDependency(a2.unitId, a2.subUnitId, t);
- } else if (i.id === eo.id) {
- const a2 = i.params.formulaData;
- Object.keys(a2).forEach((e) => {
- const t = a2[e];
- if (t !== void 0) {
- if (t === null) {
- this._dependencyManagerService.clearFormulaDependency(e);
- return;
- }
- Object.keys(t).forEach((r) => {
- const n = t[r];
- if (n !== void 0) {
- if (n === null)
- return this._dependencyManagerService.clearFormulaDependency(e, r), true;
- new kt(n).forValue((s, o) => {
- this._dependencyManagerService.removeFormulaDependency(e, r, s, o);
- });
- }
- });
- }
- });
- } else
- i.id === sa.id && this._handleSetDefinedName(i);
- })
- );
- }
- _handleSetDefinedName(i) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const { unitId: e, name: t } = a2;
- this._dependencyManagerService.removeFormulaDependencyByDefinedName(e, t);
- }
- };
- Dn = Ab([
- zr(0, Pt),
- zr(1, jr),
- zr(1, Hn),
- zr(2, jr)
- ], Dn);
- var Eb = Object.defineProperty;
- var bb = Object.getOwnPropertyDescriptor;
- var yb = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? bb(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Eb(a2, e, r), r;
- };
- var Ti = (i, a2) => (e, t) => a2(e, t, i);
- var Sn = class extends nt {
- constructor(i, a2) {
- super(), this._commandService = i, this._featureCalculationManagerService = a2, this._initialize();
- }
- _initialize() {
- this._commandExecutedListener();
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- if (i.id === aa.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const { featureId: e, calculationParam: t } = a2, { unitId: r, subUnitId: n } = t;
- this._featureCalculationManagerService.register(r, n, e, t);
- } else if (i.id === ia.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const { featureIds: e, unitId: t, subUnitId: r } = a2;
- this._featureCalculationManagerService.remove(t, r, e);
- }
- })
- );
- }
- };
- Sn = yb([
- Ti(0, Pt),
- Ti(1, jr)
- ], Sn);
- var Rb = Object.defineProperty;
- var pb = Object.getOwnPropertyDescriptor;
- var Vb = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? pb(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Rb(a2, e, r), r;
- };
- var Cs = (i, a2) => (e, t) => a2(e, t, i);
- var Pn = class extends nt {
- constructor(i, a2, e) {
- super(), this._commandService = i, this._otherFormulaManagerService = a2, this._dependencyManagerService = e, this._initialize();
- }
- _initialize() {
- this._commandExecutedListener();
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- if (i.id === oa.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const e = { [a2.unitId]: { [a2.subUnitId]: a2.formulaMap } };
- this._otherFormulaManagerService.batchRegister(e);
- } else if (i.id === ua.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const e = {};
- a2.formulaIdList.forEach((r) => e[r] = true);
- const t = { [a2.unitId]: { [a2.subUnitId]: e } };
- this._otherFormulaManagerService.batchRemove(t);
- }
- })
- );
- }
- };
- Pn = Vb([
- Cs(0, Pt),
- Cs(1, ya),
- Cs(2, Hn)
- ], Pn);
- var Nb = class extends nt {
- constructor() {
- super(...arguments);
- A(this, "_tableMap", /* @__PURE__ */ new Map());
- A(this, "_tableOptionMap", /* @__PURE__ */ new Map());
- }
- dispose() {
- this._tableMap.clear(), this._tableOptionMap.clear();
- }
- remove(e, t) {
- var r;
- (r = this._tableMap.get(e)) == null || r.delete(t);
- }
- getTableMap(e) {
- return this._tableMap.get(e);
- }
- getTableOptionMap() {
- return this._tableOptionMap;
- }
- registerTable(e, t, r) {
- var n;
- this._tableMap.get(e) == null && this._tableMap.set(e, /* @__PURE__ */ new Map()), (n = this._tableMap.get(e)) == null || n.set(t, r);
- }
- registerTableOptionMap(e, t) {
- this._tableOptionMap.set(e, t);
- }
- };
- var Uu = Ct("univer.formula.super-table.service");
- var Ob = Object.defineProperty;
- var Mb = Object.getOwnPropertyDescriptor;
- var wb = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Mb(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Ob(a2, e, r), r;
- };
- var Bi = (i, a2) => (e, t) => a2(e, t, i);
- var Ln = class extends nt {
- constructor(i, a2) {
- super(), this._commandService = i, this._superTableService = a2, this._initialize();
- }
- _initialize() {
- this._commandExecutedListener();
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- if (i.id === sa.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const { unitId: e, tableName: t, reference: r } = a2;
- this._superTableService.registerTable(e, t, r);
- } else if (i.id === Xi.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const { unitId: e, tableName: t } = a2;
- this._superTableService.remove(e, t);
- } else if (i.id === to.id) {
- const a2 = i.params;
- if (a2 == null)
- return;
- const { tableOption: e, tableOptionType: t } = a2;
- this._superTableService.registerTableOptionMap(e, t);
- }
- })
- );
- }
- };
- Ln = wb([
- Bi(0, Pt),
- Bi(1, Uu)
- ], Ln);
- var Db = class extends nt {
- constructor() {
- super(...arguments);
- A(this, "_dirtyConversionMap", /* @__PURE__ */ new Map());
- }
- dispose() {
- this._dirtyConversionMap.clear();
- }
- remove(e) {
- this._dirtyConversionMap.delete(e);
- }
- get(e) {
- return this._dirtyConversionMap.get(e);
- }
- has(e) {
- return this._dirtyConversionMap.has(e);
- }
- register(e, t) {
- this._dirtyConversionMap.set(e, t);
- }
- getDirtyConversionMap() {
- return this._dirtyConversionMap;
- }
- };
- var Sb = Ct(
- "univer.formula.active-dirty-manager.service"
- );
- var Pb = Object.defineProperty;
- var Lb = Object.getOwnPropertyDescriptor;
- var xb = (i, a2, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Lb(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
- return t && r && Pb(a2, e, r), r;
- };
- var Ii = (i, a2) => (e, t) => a2(e, t, i);
- var jb = "UNIVER_ENGINE_FORMULA_PLUGIN";
- var _s;
- var Fi = (_s = class extends Ra {
- constructor(i = ai, a2, e) {
- super(), this._config = i, this._injector = a2, this._configService = e;
- const { ...t } = nu(
- {},
- ai,
- this._config
- );
- this._configService.setConfig(fa, t);
- }
- onStarting() {
- this._initialize(), this._initializeWithOverride();
- }
- onReady() {
- var i;
- Mf(this._injector, [
- [wn],
- [Ln]
- ]), (i = this._config) != null && i.notExecuteFormula || Mf(this._injector, [
- [Pn],
- [Sn],
- [Dn],
- [Nn]
- ]);
- }
- onRendered() {
- var i;
- (i = this._config) != null && i.notExecuteFormula || Mf(this._injector, [
- [Gs],
- [Ys]
- ]);
- }
- _initialize() {
- var a2;
- const i = [
- // Services
- [Yt, { useClass: vf }],
- [pr, { useClass: Vs }],
- [Sb, { useClass: Db }],
- [Uu, { useClass: Nb }],
- // Models
- [Pr],
- // Engine
- [ca],
- //Controllers
- [wn],
- [Ln]
- ];
- (a2 = this._config) != null && a2.notExecuteFormula || i.push(
- // Services
- [ya, { useClass: Oh }],
- [Nt, { useClass: Is }],
- [Ft, { useClass: ws }],
- [jr, { useClass: Nh }],
- //Controller
- [Nn],
- [Pn],
- [Dn],
- [Sn],
- // Calculation engine
- [Cr],
- [xr],
- [gr],
- // AstNode factory
- [Eo],
- [En],
- [bn],
- [Vo],
- [yn],
- [An],
- [Rn],
- [pn],
- [Vn],
- [No]
- ), i.forEach((e) => this._injector.add(e));
- }
- _initializeWithOverride() {
- var i;
- (i = this._config) != null && i.notExecuteFormula || [
- [Gs, { useClass: Qs }],
- [Hn, { useClass: Vh }],
- [Ys, { useClass: Hs }]
- ].forEach((e) => this._injector.add(e));
- }
- }, A(_s, "pluginName", jb), _s);
- Fi = xb([
- Ii(1, ot(Ot)),
- Ii(2, SE)
- ], Fi);
- export {
- Y,
- B,
- I,
- g,
- er,
- zu,
- m2 as m,
- yr,
- Ju,
- X2 as X,
- $,
- K2 as K,
- en2 as en,
- rc,
- Ib,
- Fb,
- oc,
- Ec,
- bc,
- bs,
- tn,
- kb,
- fr,
- pc,
- Vc,
- ys,
- ns,
- na,
- fn,
- rn,
- $b,
- Oc,
- Vs,
- pr,
- Yb,
- sa,
- Xi,
- aa,
- ia,
- Zi,
- zi,
- Ns,
- Ji,
- eo,
- oa,
- ua,
- jc,
- Uc,
- to,
- mr,
- $e,
- ri,
- ae,
- ca,
- Pr,
- si,
- fa,
- Hb,
- ws,
- Ft,
- gr,
- Gb,
- kt2 as kt,
- g2,
- Ci,
- _f,
- ie,
- T2 as T,
- y2 as y,
- j,
- q2 as q,
- pt,
- kn,
- Nf,
- Of,
- Cn,
- ft,
- wr,
- Is,
- Nt,
- Eo,
- Yt,
- vf,
- An,
- En,
- Cr,
- ba,
- bn,
- Vo,
- Y2,
- se,
- yn,
- Rn,
- pn,
- Vn,
- No,
- xr,
- ph,
- Vh,
- Hn,
- Nh,
- jr,
- Oh,
- ya,
- pi,
- $s,
- Vi,
- hs,
- or,
- Ys,
- Hs,
- Uh,
- Gs,
- Qs,
- Nn,
- Ih,
- V,
- Ws,
- Yh,
- le2 as le,
- pm,
- Vm,
- Nm,
- Om,
- Qb,
- Qe,
- Im,
- be2 as be,
- Rg,
- Z2 as Z,
- O1,
- ee,
- P0,
- Ne,
- td,
- Se2 as Se,
- yd,
- me2 as me,
- rC,
- D_,
- v_,
- v,
- aE,
- ub,
- cb,
- lb,
- ju,
- hb,
- Nb,
- Uu,
- Db,
- Sb,
- Fi
- };
- /*! Bundled license information:
- @univerjs/engine-formula/lib/es/index.js:
- (*!
- * decimal.js v10.4.3
- * An arbitrary-precision Decimal type for JavaScript.
- * https://github.com/MikeMcl/decimal.js
- * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
- * MIT Licence
- *)
- */
- //# sourceMappingURL=chunk-QRYBFJ3R.js.map
|