4dmap.js 471 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013
  1. import { watch as fe, reactive as ti, ref as ei, watchEffect as Sn, toRaw as Rr, computed as mh } from "vue";
  2. var Or = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
  3. function vh(s) {
  4. return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
  5. }
  6. var Cn = {}, V = {}, st = {}, $ = {};
  7. (function(s) {
  8. Object.defineProperty(s, "__esModule", { value: !0 }), s._registerNode = s.Konva = s.glob = void 0;
  9. const t = Math.PI / 180;
  10. function e() {
  11. return typeof window < "u" && ({}.toString.call(window) === "[object Window]" || {}.toString.call(window) === "[object global]");
  12. }
  13. s.glob = typeof Or < "u" ? Or : typeof window < "u" ? window : typeof WorkerGlobalScope < "u" ? self : {}, s.Konva = {
  14. _global: s.glob,
  15. version: "9.3.6",
  16. isBrowser: e(),
  17. isUnminified: /param/.test((function(n) {
  18. }).toString()),
  19. dblClickWindow: 400,
  20. getAngle(n) {
  21. return s.Konva.angleDeg ? n * t : n;
  22. },
  23. enableTrace: !1,
  24. pointerEventsEnabled: !0,
  25. autoDrawEnabled: !0,
  26. hitOnDragEnabled: !1,
  27. capturePointerEventsEnabled: !1,
  28. _mouseListenClick: !1,
  29. _touchListenClick: !1,
  30. _pointerListenClick: !1,
  31. _mouseInDblClickWindow: !1,
  32. _touchInDblClickWindow: !1,
  33. _pointerInDblClickWindow: !1,
  34. _mouseDblClickPointerId: null,
  35. _touchDblClickPointerId: null,
  36. _pointerDblClickPointerId: null,
  37. pixelRatio: typeof window < "u" && window.devicePixelRatio || 1,
  38. dragDistance: 3,
  39. angleDeg: !0,
  40. showWarnings: !0,
  41. dragButtons: [0, 1],
  42. isDragging() {
  43. return s.Konva.DD.isDragging;
  44. },
  45. isTransforming() {
  46. var n;
  47. return (n = s.Konva.Transformer) === null || n === void 0 ? void 0 : n.isTransforming();
  48. },
  49. isDragReady() {
  50. return !!s.Konva.DD.node;
  51. },
  52. releaseCanvasOnDestroy: !0,
  53. document: s.glob.document,
  54. _injectGlobal(n) {
  55. s.glob.Konva = n;
  56. }
  57. };
  58. const i = (n) => {
  59. s.Konva[n.prototype.getClassName()] = n;
  60. };
  61. s._registerNode = i, s.Konva._injectGlobal(s.Konva);
  62. })($);
  63. (function(s) {
  64. Object.defineProperty(s, "__esModule", { value: !0 }), s.Util = s.Transform = void 0;
  65. const t = $;
  66. class e {
  67. constructor(y = [1, 0, 0, 1, 0, 0]) {
  68. this.dirty = !1, this.m = y && y.slice() || [1, 0, 0, 1, 0, 0];
  69. }
  70. reset() {
  71. this.m[0] = 1, this.m[1] = 0, this.m[2] = 0, this.m[3] = 1, this.m[4] = 0, this.m[5] = 0;
  72. }
  73. copy() {
  74. return new e(this.m);
  75. }
  76. copyInto(y) {
  77. y.m[0] = this.m[0], y.m[1] = this.m[1], y.m[2] = this.m[2], y.m[3] = this.m[3], y.m[4] = this.m[4], y.m[5] = this.m[5];
  78. }
  79. point(y) {
  80. var x = this.m;
  81. return {
  82. x: x[0] * y.x + x[2] * y.y + x[4],
  83. y: x[1] * y.x + x[3] * y.y + x[5]
  84. };
  85. }
  86. translate(y, x) {
  87. return this.m[4] += this.m[0] * y + this.m[2] * x, this.m[5] += this.m[1] * y + this.m[3] * x, this;
  88. }
  89. scale(y, x) {
  90. return this.m[0] *= y, this.m[1] *= y, this.m[2] *= x, this.m[3] *= x, this;
  91. }
  92. rotate(y) {
  93. var x = Math.cos(y), b = Math.sin(y), C = this.m[0] * x + this.m[2] * b, w = this.m[1] * x + this.m[3] * b, E = this.m[0] * -b + this.m[2] * x, S = this.m[1] * -b + this.m[3] * x;
  94. return this.m[0] = C, this.m[1] = w, this.m[2] = E, this.m[3] = S, this;
  95. }
  96. getTranslation() {
  97. return {
  98. x: this.m[4],
  99. y: this.m[5]
  100. };
  101. }
  102. skew(y, x) {
  103. var b = this.m[0] + this.m[2] * x, C = this.m[1] + this.m[3] * x, w = this.m[2] + this.m[0] * y, E = this.m[3] + this.m[1] * y;
  104. return this.m[0] = b, this.m[1] = C, this.m[2] = w, this.m[3] = E, this;
  105. }
  106. multiply(y) {
  107. var x = this.m[0] * y.m[0] + this.m[2] * y.m[1], b = this.m[1] * y.m[0] + this.m[3] * y.m[1], C = this.m[0] * y.m[2] + this.m[2] * y.m[3], w = this.m[1] * y.m[2] + this.m[3] * y.m[3], E = this.m[0] * y.m[4] + this.m[2] * y.m[5] + this.m[4], S = this.m[1] * y.m[4] + this.m[3] * y.m[5] + this.m[5];
  108. return this.m[0] = x, this.m[1] = b, this.m[2] = C, this.m[3] = w, this.m[4] = E, this.m[5] = S, this;
  109. }
  110. invert() {
  111. var y = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]), x = this.m[3] * y, b = -this.m[1] * y, C = -this.m[2] * y, w = this.m[0] * y, E = y * (this.m[2] * this.m[5] - this.m[3] * this.m[4]), S = y * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);
  112. return this.m[0] = x, this.m[1] = b, this.m[2] = C, this.m[3] = w, this.m[4] = E, this.m[5] = S, this;
  113. }
  114. getMatrix() {
  115. return this.m;
  116. }
  117. decompose() {
  118. var y = this.m[0], x = this.m[1], b = this.m[2], C = this.m[3], w = this.m[4], E = this.m[5], S = y * C - x * b;
  119. let P = {
  120. x: w,
  121. y: E,
  122. rotation: 0,
  123. scaleX: 0,
  124. scaleY: 0,
  125. skewX: 0,
  126. skewY: 0
  127. };
  128. if (y != 0 || x != 0) {
  129. var k = Math.sqrt(y * y + x * x);
  130. P.rotation = x > 0 ? Math.acos(y / k) : -Math.acos(y / k), P.scaleX = k, P.scaleY = S / k, P.skewX = (y * b + x * C) / S, P.skewY = 0;
  131. } else if (b != 0 || C != 0) {
  132. var F = Math.sqrt(b * b + C * C);
  133. P.rotation = Math.PI / 2 - (C > 0 ? Math.acos(-b / F) : -Math.acos(b / F)), P.scaleX = S / F, P.scaleY = F, P.skewX = 0, P.skewY = (y * b + x * C) / S;
  134. }
  135. return P.rotation = s.Util._getRotation(P.rotation), P;
  136. }
  137. }
  138. s.Transform = e;
  139. var i = "[object Array]", n = "[object Number]", r = "[object String]", a = "[object Boolean]", o = Math.PI / 180, h = 180 / Math.PI, l = "#", A = "", u = "0", f = "Konva warning: ", c = "Konva error: ", d = "rgb(", p = {
  140. aliceblue: [240, 248, 255],
  141. antiquewhite: [250, 235, 215],
  142. aqua: [0, 255, 255],
  143. aquamarine: [127, 255, 212],
  144. azure: [240, 255, 255],
  145. beige: [245, 245, 220],
  146. bisque: [255, 228, 196],
  147. black: [0, 0, 0],
  148. blanchedalmond: [255, 235, 205],
  149. blue: [0, 0, 255],
  150. blueviolet: [138, 43, 226],
  151. brown: [165, 42, 42],
  152. burlywood: [222, 184, 135],
  153. cadetblue: [95, 158, 160],
  154. chartreuse: [127, 255, 0],
  155. chocolate: [210, 105, 30],
  156. coral: [255, 127, 80],
  157. cornflowerblue: [100, 149, 237],
  158. cornsilk: [255, 248, 220],
  159. crimson: [220, 20, 60],
  160. cyan: [0, 255, 255],
  161. darkblue: [0, 0, 139],
  162. darkcyan: [0, 139, 139],
  163. darkgoldenrod: [184, 132, 11],
  164. darkgray: [169, 169, 169],
  165. darkgreen: [0, 100, 0],
  166. darkgrey: [169, 169, 169],
  167. darkkhaki: [189, 183, 107],
  168. darkmagenta: [139, 0, 139],
  169. darkolivegreen: [85, 107, 47],
  170. darkorange: [255, 140, 0],
  171. darkorchid: [153, 50, 204],
  172. darkred: [139, 0, 0],
  173. darksalmon: [233, 150, 122],
  174. darkseagreen: [143, 188, 143],
  175. darkslateblue: [72, 61, 139],
  176. darkslategray: [47, 79, 79],
  177. darkslategrey: [47, 79, 79],
  178. darkturquoise: [0, 206, 209],
  179. darkviolet: [148, 0, 211],
  180. deeppink: [255, 20, 147],
  181. deepskyblue: [0, 191, 255],
  182. dimgray: [105, 105, 105],
  183. dimgrey: [105, 105, 105],
  184. dodgerblue: [30, 144, 255],
  185. firebrick: [178, 34, 34],
  186. floralwhite: [255, 255, 240],
  187. forestgreen: [34, 139, 34],
  188. fuchsia: [255, 0, 255],
  189. gainsboro: [220, 220, 220],
  190. ghostwhite: [248, 248, 255],
  191. gold: [255, 215, 0],
  192. goldenrod: [218, 165, 32],
  193. gray: [128, 128, 128],
  194. green: [0, 128, 0],
  195. greenyellow: [173, 255, 47],
  196. grey: [128, 128, 128],
  197. honeydew: [240, 255, 240],
  198. hotpink: [255, 105, 180],
  199. indianred: [205, 92, 92],
  200. indigo: [75, 0, 130],
  201. ivory: [255, 255, 240],
  202. khaki: [240, 230, 140],
  203. lavender: [230, 230, 250],
  204. lavenderblush: [255, 240, 245],
  205. lawngreen: [124, 252, 0],
  206. lemonchiffon: [255, 250, 205],
  207. lightblue: [173, 216, 230],
  208. lightcoral: [240, 128, 128],
  209. lightcyan: [224, 255, 255],
  210. lightgoldenrodyellow: [250, 250, 210],
  211. lightgray: [211, 211, 211],
  212. lightgreen: [144, 238, 144],
  213. lightgrey: [211, 211, 211],
  214. lightpink: [255, 182, 193],
  215. lightsalmon: [255, 160, 122],
  216. lightseagreen: [32, 178, 170],
  217. lightskyblue: [135, 206, 250],
  218. lightslategray: [119, 136, 153],
  219. lightslategrey: [119, 136, 153],
  220. lightsteelblue: [176, 196, 222],
  221. lightyellow: [255, 255, 224],
  222. lime: [0, 255, 0],
  223. limegreen: [50, 205, 50],
  224. linen: [250, 240, 230],
  225. magenta: [255, 0, 255],
  226. maroon: [128, 0, 0],
  227. mediumaquamarine: [102, 205, 170],
  228. mediumblue: [0, 0, 205],
  229. mediumorchid: [186, 85, 211],
  230. mediumpurple: [147, 112, 219],
  231. mediumseagreen: [60, 179, 113],
  232. mediumslateblue: [123, 104, 238],
  233. mediumspringgreen: [0, 250, 154],
  234. mediumturquoise: [72, 209, 204],
  235. mediumvioletred: [199, 21, 133],
  236. midnightblue: [25, 25, 112],
  237. mintcream: [245, 255, 250],
  238. mistyrose: [255, 228, 225],
  239. moccasin: [255, 228, 181],
  240. navajowhite: [255, 222, 173],
  241. navy: [0, 0, 128],
  242. oldlace: [253, 245, 230],
  243. olive: [128, 128, 0],
  244. olivedrab: [107, 142, 35],
  245. orange: [255, 165, 0],
  246. orangered: [255, 69, 0],
  247. orchid: [218, 112, 214],
  248. palegoldenrod: [238, 232, 170],
  249. palegreen: [152, 251, 152],
  250. paleturquoise: [175, 238, 238],
  251. palevioletred: [219, 112, 147],
  252. papayawhip: [255, 239, 213],
  253. peachpuff: [255, 218, 185],
  254. peru: [205, 133, 63],
  255. pink: [255, 192, 203],
  256. plum: [221, 160, 203],
  257. powderblue: [176, 224, 230],
  258. purple: [128, 0, 128],
  259. rebeccapurple: [102, 51, 153],
  260. red: [255, 0, 0],
  261. rosybrown: [188, 143, 143],
  262. royalblue: [65, 105, 225],
  263. saddlebrown: [139, 69, 19],
  264. salmon: [250, 128, 114],
  265. sandybrown: [244, 164, 96],
  266. seagreen: [46, 139, 87],
  267. seashell: [255, 245, 238],
  268. sienna: [160, 82, 45],
  269. silver: [192, 192, 192],
  270. skyblue: [135, 206, 235],
  271. slateblue: [106, 90, 205],
  272. slategray: [119, 128, 144],
  273. slategrey: [119, 128, 144],
  274. snow: [255, 255, 250],
  275. springgreen: [0, 255, 127],
  276. steelblue: [70, 130, 180],
  277. tan: [210, 180, 140],
  278. teal: [0, 128, 128],
  279. thistle: [216, 191, 216],
  280. transparent: [255, 255, 255, 0],
  281. tomato: [255, 99, 71],
  282. turquoise: [64, 224, 208],
  283. violet: [238, 130, 238],
  284. wheat: [245, 222, 179],
  285. white: [255, 255, 255],
  286. whitesmoke: [245, 245, 245],
  287. yellow: [255, 255, 0],
  288. yellowgreen: [154, 205, 5]
  289. }, m = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/, v = [];
  290. const _ = typeof requestAnimationFrame < "u" && requestAnimationFrame || function(g) {
  291. setTimeout(g, 60);
  292. };
  293. s.Util = {
  294. _isElement(g) {
  295. return !!(g && g.nodeType == 1);
  296. },
  297. _isFunction(g) {
  298. return !!(g && g.constructor && g.call && g.apply);
  299. },
  300. _isPlainObject(g) {
  301. return !!g && g.constructor === Object;
  302. },
  303. _isArray(g) {
  304. return Object.prototype.toString.call(g) === i;
  305. },
  306. _isNumber(g) {
  307. return Object.prototype.toString.call(g) === n && !isNaN(g) && isFinite(g);
  308. },
  309. _isString(g) {
  310. return Object.prototype.toString.call(g) === r;
  311. },
  312. _isBoolean(g) {
  313. return Object.prototype.toString.call(g) === a;
  314. },
  315. isObject(g) {
  316. return g instanceof Object;
  317. },
  318. isValidSelector(g) {
  319. if (typeof g != "string")
  320. return !1;
  321. var y = g[0];
  322. return y === "#" || y === "." || y === y.toUpperCase();
  323. },
  324. _sign(g) {
  325. return g === 0 || g > 0 ? 1 : -1;
  326. },
  327. requestAnimFrame(g) {
  328. v.push(g), v.length === 1 && _(function() {
  329. const y = v;
  330. v = [], y.forEach(function(x) {
  331. x();
  332. });
  333. });
  334. },
  335. createCanvasElement() {
  336. var g = document.createElement("canvas");
  337. try {
  338. g.style = g.style || {};
  339. } catch {
  340. }
  341. return g;
  342. },
  343. createImageElement() {
  344. return document.createElement("img");
  345. },
  346. _isInDocument(g) {
  347. for (; g = g.parentNode; )
  348. if (g == document)
  349. return !0;
  350. return !1;
  351. },
  352. _urlToImage(g, y) {
  353. var x = s.Util.createImageElement();
  354. x.onload = function() {
  355. y(x);
  356. }, x.src = g;
  357. },
  358. _rgbToHex(g, y, x) {
  359. return ((1 << 24) + (g << 16) + (y << 8) + x).toString(16).slice(1);
  360. },
  361. _hexToRgb(g) {
  362. g = g.replace(l, A);
  363. var y = parseInt(g, 16);
  364. return {
  365. r: y >> 16 & 255,
  366. g: y >> 8 & 255,
  367. b: y & 255
  368. };
  369. },
  370. getRandomColor() {
  371. for (var g = (Math.random() * 16777215 << 0).toString(16); g.length < 6; )
  372. g = u + g;
  373. return l + g;
  374. },
  375. getRGB(g) {
  376. var y;
  377. return g in p ? (y = p[g], {
  378. r: y[0],
  379. g: y[1],
  380. b: y[2]
  381. }) : g[0] === l ? this._hexToRgb(g.substring(1)) : g.substr(0, 4) === d ? (y = m.exec(g.replace(/ /g, "")), {
  382. r: parseInt(y[1], 10),
  383. g: parseInt(y[2], 10),
  384. b: parseInt(y[3], 10)
  385. }) : {
  386. r: 0,
  387. g: 0,
  388. b: 0
  389. };
  390. },
  391. colorToRGBA(g) {
  392. return g = g || "black", s.Util._namedColorToRBA(g) || s.Util._hex3ColorToRGBA(g) || s.Util._hex4ColorToRGBA(g) || s.Util._hex6ColorToRGBA(g) || s.Util._hex8ColorToRGBA(g) || s.Util._rgbColorToRGBA(g) || s.Util._rgbaColorToRGBA(g) || s.Util._hslColorToRGBA(g);
  393. },
  394. _namedColorToRBA(g) {
  395. var y = p[g.toLowerCase()];
  396. return y ? {
  397. r: y[0],
  398. g: y[1],
  399. b: y[2],
  400. a: 1
  401. } : null;
  402. },
  403. _rgbColorToRGBA(g) {
  404. if (g.indexOf("rgb(") === 0) {
  405. g = g.match(/rgb\(([^)]+)\)/)[1];
  406. var y = g.split(/ *, */).map(Number);
  407. return {
  408. r: y[0],
  409. g: y[1],
  410. b: y[2],
  411. a: 1
  412. };
  413. }
  414. },
  415. _rgbaColorToRGBA(g) {
  416. if (g.indexOf("rgba(") === 0) {
  417. g = g.match(/rgba\(([^)]+)\)/)[1];
  418. var y = g.split(/ *, */).map((x, b) => x.slice(-1) === "%" ? b === 3 ? parseInt(x) / 100 : parseInt(x) / 100 * 255 : Number(x));
  419. return {
  420. r: y[0],
  421. g: y[1],
  422. b: y[2],
  423. a: y[3]
  424. };
  425. }
  426. },
  427. _hex8ColorToRGBA(g) {
  428. if (g[0] === "#" && g.length === 9)
  429. return {
  430. r: parseInt(g.slice(1, 3), 16),
  431. g: parseInt(g.slice(3, 5), 16),
  432. b: parseInt(g.slice(5, 7), 16),
  433. a: parseInt(g.slice(7, 9), 16) / 255
  434. };
  435. },
  436. _hex6ColorToRGBA(g) {
  437. if (g[0] === "#" && g.length === 7)
  438. return {
  439. r: parseInt(g.slice(1, 3), 16),
  440. g: parseInt(g.slice(3, 5), 16),
  441. b: parseInt(g.slice(5, 7), 16),
  442. a: 1
  443. };
  444. },
  445. _hex4ColorToRGBA(g) {
  446. if (g[0] === "#" && g.length === 5)
  447. return {
  448. r: parseInt(g[1] + g[1], 16),
  449. g: parseInt(g[2] + g[2], 16),
  450. b: parseInt(g[3] + g[3], 16),
  451. a: parseInt(g[4] + g[4], 16) / 255
  452. };
  453. },
  454. _hex3ColorToRGBA(g) {
  455. if (g[0] === "#" && g.length === 4)
  456. return {
  457. r: parseInt(g[1] + g[1], 16),
  458. g: parseInt(g[2] + g[2], 16),
  459. b: parseInt(g[3] + g[3], 16),
  460. a: 1
  461. };
  462. },
  463. _hslColorToRGBA(g) {
  464. if (/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(g)) {
  465. const [y, ...x] = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(g), b = Number(x[0]) / 360, C = Number(x[1]) / 100, w = Number(x[2]) / 100;
  466. let E, S, P;
  467. if (C === 0)
  468. return P = w * 255, {
  469. r: Math.round(P),
  470. g: Math.round(P),
  471. b: Math.round(P),
  472. a: 1
  473. };
  474. w < 0.5 ? E = w * (1 + C) : E = w + C - w * C;
  475. const k = 2 * w - E, F = [0, 0, 0];
  476. for (let L = 0; L < 3; L++)
  477. S = b + 1 / 3 * -(L - 1), S < 0 && S++, S > 1 && S--, 6 * S < 1 ? P = k + (E - k) * 6 * S : 2 * S < 1 ? P = E : 3 * S < 2 ? P = k + (E - k) * (2 / 3 - S) * 6 : P = k, F[L] = P * 255;
  478. return {
  479. r: Math.round(F[0]),
  480. g: Math.round(F[1]),
  481. b: Math.round(F[2]),
  482. a: 1
  483. };
  484. }
  485. },
  486. haveIntersection(g, y) {
  487. return !(y.x > g.x + g.width || y.x + y.width < g.x || y.y > g.y + g.height || y.y + y.height < g.y);
  488. },
  489. cloneObject(g) {
  490. var y = {};
  491. for (var x in g)
  492. this._isPlainObject(g[x]) ? y[x] = this.cloneObject(g[x]) : this._isArray(g[x]) ? y[x] = this.cloneArray(g[x]) : y[x] = g[x];
  493. return y;
  494. },
  495. cloneArray(g) {
  496. return g.slice(0);
  497. },
  498. degToRad(g) {
  499. return g * o;
  500. },
  501. radToDeg(g) {
  502. return g * h;
  503. },
  504. _degToRad(g) {
  505. return s.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."), s.Util.degToRad(g);
  506. },
  507. _radToDeg(g) {
  508. return s.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."), s.Util.radToDeg(g);
  509. },
  510. _getRotation(g) {
  511. return t.Konva.angleDeg ? s.Util.radToDeg(g) : g;
  512. },
  513. _capitalize(g) {
  514. return g.charAt(0).toUpperCase() + g.slice(1);
  515. },
  516. throw(g) {
  517. throw new Error(c + g);
  518. },
  519. error(g) {
  520. console.error(c + g);
  521. },
  522. warn(g) {
  523. t.Konva.showWarnings && console.warn(f + g);
  524. },
  525. each(g, y) {
  526. for (var x in g)
  527. y(x, g[x]);
  528. },
  529. _inRange(g, y, x) {
  530. return y <= g && g < x;
  531. },
  532. _getProjectionToSegment(g, y, x, b, C, w) {
  533. var E, S, P, k = (g - x) * (g - x) + (y - b) * (y - b);
  534. if (k == 0)
  535. E = g, S = y, P = (C - x) * (C - x) + (w - b) * (w - b);
  536. else {
  537. var F = ((C - g) * (x - g) + (w - y) * (b - y)) / k;
  538. F < 0 ? (E = g, S = y, P = (g - C) * (g - C) + (y - w) * (y - w)) : F > 1 ? (E = x, S = b, P = (x - C) * (x - C) + (b - w) * (b - w)) : (E = g + F * (x - g), S = y + F * (b - y), P = (E - C) * (E - C) + (S - w) * (S - w));
  539. }
  540. return [E, S, P];
  541. },
  542. _getProjectionToLine(g, y, x) {
  543. var b = s.Util.cloneObject(g), C = Number.MAX_VALUE;
  544. return y.forEach(function(w, E) {
  545. if (!(!x && E === y.length - 1)) {
  546. var S = y[(E + 1) % y.length], P = s.Util._getProjectionToSegment(w.x, w.y, S.x, S.y, g.x, g.y), k = P[0], F = P[1], L = P[2];
  547. L < C && (b.x = k, b.y = F, C = L);
  548. }
  549. }), b;
  550. },
  551. _prepareArrayForTween(g, y, x) {
  552. var b, C = [], w = [];
  553. if (g.length > y.length) {
  554. var E = y;
  555. y = g, g = E;
  556. }
  557. for (b = 0; b < g.length; b += 2)
  558. C.push({
  559. x: g[b],
  560. y: g[b + 1]
  561. });
  562. for (b = 0; b < y.length; b += 2)
  563. w.push({
  564. x: y[b],
  565. y: y[b + 1]
  566. });
  567. var S = [];
  568. return w.forEach(function(P) {
  569. var k = s.Util._getProjectionToLine(P, C, x);
  570. S.push(k.x), S.push(k.y);
  571. }), S;
  572. },
  573. _prepareToStringify(g) {
  574. var y;
  575. g.visitedByCircularReferenceRemoval = !0;
  576. for (var x in g)
  577. if (g.hasOwnProperty(x) && g[x] && typeof g[x] == "object") {
  578. if (y = Object.getOwnPropertyDescriptor(g, x), g[x].visitedByCircularReferenceRemoval || s.Util._isElement(g[x]))
  579. if (y.configurable)
  580. delete g[x];
  581. else
  582. return null;
  583. else if (s.Util._prepareToStringify(g[x]) === null)
  584. if (y.configurable)
  585. delete g[x];
  586. else
  587. return null;
  588. }
  589. return delete g.visitedByCircularReferenceRemoval, g;
  590. },
  591. _assign(g, y) {
  592. for (var x in y)
  593. g[x] = y[x];
  594. return g;
  595. },
  596. _getFirstPointerId(g) {
  597. return g.touches ? g.changedTouches[0].identifier : g.pointerId || 999;
  598. },
  599. releaseCanvas(...g) {
  600. t.Konva.releaseCanvasOnDestroy && g.forEach((y) => {
  601. y.width = 0, y.height = 0;
  602. });
  603. },
  604. drawRoundedRectPath(g, y, x, b) {
  605. let C = 0, w = 0, E = 0, S = 0;
  606. typeof b == "number" ? C = w = E = S = Math.min(b, y / 2, x / 2) : (C = Math.min(b[0] || 0, y / 2, x / 2), w = Math.min(b[1] || 0, y / 2, x / 2), S = Math.min(b[2] || 0, y / 2, x / 2), E = Math.min(b[3] || 0, y / 2, x / 2)), g.moveTo(C, 0), g.lineTo(y - w, 0), g.arc(y - w, w, w, Math.PI * 3 / 2, 0, !1), g.lineTo(y, x - S), g.arc(y - S, x - S, S, 0, Math.PI / 2, !1), g.lineTo(E, x), g.arc(E, x - E, E, Math.PI / 2, Math.PI, !1), g.lineTo(0, C), g.arc(C, C, C, Math.PI, Math.PI * 3 / 2, !1);
  607. }
  608. };
  609. })(st);
  610. var O = {};
  611. Object.defineProperty(O, "__esModule", { value: !0 });
  612. O.getComponentValidator = O.getBooleanValidator = O.getNumberArrayValidator = O.getFunctionValidator = O.getStringOrGradientValidator = O.getStringValidator = O.getNumberOrAutoValidator = O.getNumberOrArrayOfNumbersValidator = O.getNumberValidator = O.alphaComponent = O.RGBComponent = void 0;
  613. const Kt = $, ht = st;
  614. function Zt(s) {
  615. return ht.Util._isString(s) ? '"' + s + '"' : Object.prototype.toString.call(s) === "[object Number]" || ht.Util._isBoolean(s) ? s : Object.prototype.toString.call(s);
  616. }
  617. function _h(s) {
  618. return s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
  619. }
  620. O.RGBComponent = _h;
  621. function xh(s) {
  622. return s > 1 ? 1 : s < 1e-4 ? 1e-4 : s;
  623. }
  624. O.alphaComponent = xh;
  625. function bh() {
  626. if (Kt.Konva.isUnminified)
  627. return function(s, t) {
  628. return ht.Util._isNumber(s) || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a number.'), s;
  629. };
  630. }
  631. O.getNumberValidator = bh;
  632. function wh(s) {
  633. if (Kt.Konva.isUnminified)
  634. return function(t, e) {
  635. let i = ht.Util._isNumber(t), n = ht.Util._isArray(t) && t.length == s;
  636. return !i && !n && ht.Util.warn(Zt(t) + ' is a not valid value for "' + e + '" attribute. The value should be a number or Array<number>(' + s + ")"), t;
  637. };
  638. }
  639. O.getNumberOrArrayOfNumbersValidator = wh;
  640. function Sh() {
  641. if (Kt.Konva.isUnminified)
  642. return function(s, t) {
  643. var e = ht.Util._isNumber(s), i = s === "auto";
  644. return e || i || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a number or "auto".'), s;
  645. };
  646. }
  647. O.getNumberOrAutoValidator = Sh;
  648. function Ch() {
  649. if (Kt.Konva.isUnminified)
  650. return function(s, t) {
  651. return ht.Util._isString(s) || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a string.'), s;
  652. };
  653. }
  654. O.getStringValidator = Ch;
  655. function Mh() {
  656. if (Kt.Konva.isUnminified)
  657. return function(s, t) {
  658. const e = ht.Util._isString(s), i = Object.prototype.toString.call(s) === "[object CanvasGradient]" || s && s.addColorStop;
  659. return e || i || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a string or a native gradient.'), s;
  660. };
  661. }
  662. O.getStringOrGradientValidator = Mh;
  663. function Ph() {
  664. if (Kt.Konva.isUnminified)
  665. return function(s, t) {
  666. return ht.Util._isFunction(s) || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a function.'), s;
  667. };
  668. }
  669. O.getFunctionValidator = Ph;
  670. function Eh() {
  671. if (Kt.Konva.isUnminified)
  672. return function(s, t) {
  673. const e = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
  674. return e && s instanceof e || (ht.Util._isArray(s) ? s.forEach(function(i) {
  675. ht.Util._isNumber(i) || ht.Util.warn('"' + t + '" attribute has non numeric element ' + i + ". Make sure that all elements are numbers.");
  676. }) : ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a array of numbers.')), s;
  677. };
  678. }
  679. O.getNumberArrayValidator = Eh;
  680. function Fh() {
  681. if (Kt.Konva.isUnminified)
  682. return function(s, t) {
  683. var e = s === !0 || s === !1;
  684. return e || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a boolean.'), s;
  685. };
  686. }
  687. O.getBooleanValidator = Fh;
  688. function kh(s) {
  689. if (Kt.Konva.isUnminified)
  690. return function(t, e) {
  691. return t == null || ht.Util.isObject(t) || ht.Util.warn(Zt(t) + ' is a not valid value for "' + e + '" attribute. The value should be an object with properties ' + s), t;
  692. };
  693. }
  694. O.getComponentValidator = kh;
  695. (function(s) {
  696. Object.defineProperty(s, "__esModule", { value: !0 }), s.Factory = void 0;
  697. const t = st, e = O;
  698. var i = "get", n = "set";
  699. s.Factory = {
  700. addGetterSetter(r, a, o, h, l) {
  701. s.Factory.addGetter(r, a, o), s.Factory.addSetter(r, a, h, l), s.Factory.addOverloadedGetterSetter(r, a);
  702. },
  703. addGetter(r, a, o) {
  704. var h = i + t.Util._capitalize(a);
  705. r.prototype[h] = r.prototype[h] || function() {
  706. var l = this.attrs[a];
  707. return l === void 0 ? o : l;
  708. };
  709. },
  710. addSetter(r, a, o, h) {
  711. var l = n + t.Util._capitalize(a);
  712. r.prototype[l] || s.Factory.overWriteSetter(r, a, o, h);
  713. },
  714. overWriteSetter(r, a, o, h) {
  715. var l = n + t.Util._capitalize(a);
  716. r.prototype[l] = function(A) {
  717. return o && A !== void 0 && A !== null && (A = o.call(this, A, a)), this._setAttr(a, A), h && h.call(this), this;
  718. };
  719. },
  720. addComponentsGetterSetter(r, a, o, h, l) {
  721. var A = o.length, u = t.Util._capitalize, f = i + u(a), c = n + u(a), d, p;
  722. r.prototype[f] = function() {
  723. var v = {};
  724. for (d = 0; d < A; d++)
  725. p = o[d], v[p] = this.getAttr(a + u(p));
  726. return v;
  727. };
  728. var m = (0, e.getComponentValidator)(o);
  729. r.prototype[c] = function(v) {
  730. var _ = this.attrs[a], g;
  731. h && (v = h.call(this, v)), m && m.call(this, v, a);
  732. for (g in v)
  733. v.hasOwnProperty(g) && this._setAttr(a + u(g), v[g]);
  734. return v || o.forEach((y) => {
  735. this._setAttr(a + u(y), void 0);
  736. }), this._fireChangeEvent(a, _, v), l && l.call(this), this;
  737. }, s.Factory.addOverloadedGetterSetter(r, a);
  738. },
  739. addOverloadedGetterSetter(r, a) {
  740. var o = t.Util._capitalize(a), h = n + o, l = i + o;
  741. r.prototype[a] = function() {
  742. return arguments.length ? (this[h](arguments[0]), this) : this[l]();
  743. };
  744. },
  745. addDeprecatedGetterSetter(r, a, o, h) {
  746. t.Util.error("Adding deprecated " + a);
  747. var l = i + t.Util._capitalize(a), A = a + " property is deprecated and will be removed soon. Look at Konva change log for more information.";
  748. r.prototype[l] = function() {
  749. t.Util.error(A);
  750. var u = this.attrs[a];
  751. return u === void 0 ? o : u;
  752. }, s.Factory.addSetter(r, a, h, function() {
  753. t.Util.error(A);
  754. }), s.Factory.addOverloadedGetterSetter(r, a);
  755. },
  756. backCompat(r, a) {
  757. t.Util.each(a, function(o, h) {
  758. var l = r.prototype[h], A = i + t.Util._capitalize(o), u = n + t.Util._capitalize(o);
  759. function f() {
  760. l.apply(this, arguments), t.Util.error('"' + o + '" method is deprecated and will be removed soon. Use ""' + h + '" instead.');
  761. }
  762. r.prototype[o] = f, r.prototype[A] = f, r.prototype[u] = f;
  763. });
  764. },
  765. afterSetFilter() {
  766. this._filterUpToDate = !1;
  767. }
  768. };
  769. })(V);
  770. var ft = {}, rt = {}, It = {}, Xt = {};
  771. Object.defineProperty(Xt, "__esModule", { value: !0 });
  772. Xt.HitContext = Xt.SceneContext = Xt.Context = void 0;
  773. const Ka = st, Dh = $;
  774. function Ih(s) {
  775. var t = [], e = s.length, i = Ka.Util, n, r;
  776. for (n = 0; n < e; n++)
  777. r = s[n], i._isNumber(r) ? r = Math.round(r * 1e3) / 1e3 : i._isString(r) || (r = r + ""), t.push(r);
  778. return t;
  779. }
  780. var Nr = ",", Th = "(", Lh = ")", Rh = "([", Oh = "])", Nh = ";", Gh = "()", Bh = "=", Gr = [
  781. "arc",
  782. "arcTo",
  783. "beginPath",
  784. "bezierCurveTo",
  785. "clearRect",
  786. "clip",
  787. "closePath",
  788. "createLinearGradient",
  789. "createPattern",
  790. "createRadialGradient",
  791. "drawImage",
  792. "ellipse",
  793. "fill",
  794. "fillText",
  795. "getImageData",
  796. "createImageData",
  797. "lineTo",
  798. "moveTo",
  799. "putImageData",
  800. "quadraticCurveTo",
  801. "rect",
  802. "roundRect",
  803. "restore",
  804. "rotate",
  805. "save",
  806. "scale",
  807. "setLineDash",
  808. "setTransform",
  809. "stroke",
  810. "strokeText",
  811. "transform",
  812. "translate"
  813. ], zh = [
  814. "fillStyle",
  815. "strokeStyle",
  816. "shadowColor",
  817. "shadowBlur",
  818. "shadowOffsetX",
  819. "shadowOffsetY",
  820. "letterSpacing",
  821. "lineCap",
  822. "lineDashOffset",
  823. "lineJoin",
  824. "lineWidth",
  825. "miterLimit",
  826. "direction",
  827. "font",
  828. "textAlign",
  829. "textBaseline",
  830. "globalAlpha",
  831. "globalCompositeOperation",
  832. "imageSmoothingEnabled"
  833. ];
  834. const Uh = 100;
  835. class Mn {
  836. constructor(t) {
  837. this.canvas = t, Dh.Konva.enableTrace && (this.traceArr = [], this._enableTrace());
  838. }
  839. fillShape(t) {
  840. t.fillEnabled() && this._fill(t);
  841. }
  842. _fill(t) {
  843. }
  844. strokeShape(t) {
  845. t.hasStroke() && this._stroke(t);
  846. }
  847. _stroke(t) {
  848. }
  849. fillStrokeShape(t) {
  850. t.attrs.fillAfterStrokeEnabled ? (this.strokeShape(t), this.fillShape(t)) : (this.fillShape(t), this.strokeShape(t));
  851. }
  852. getTrace(t, e) {
  853. var i = this.traceArr, n = i.length, r = "", a, o, h, l;
  854. for (a = 0; a < n; a++)
  855. o = i[a], h = o.method, h ? (l = o.args, r += h, t ? r += Gh : Ka.Util._isArray(l[0]) ? r += Rh + l.join(Nr) + Oh : (e && (l = l.map((A) => typeof A == "number" ? Math.floor(A) : A)), r += Th + l.join(Nr) + Lh)) : (r += o.property, t || (r += Bh + o.val)), r += Nh;
  856. return r;
  857. }
  858. clearTrace() {
  859. this.traceArr = [];
  860. }
  861. _trace(t) {
  862. var e = this.traceArr, i;
  863. e.push(t), i = e.length, i >= Uh && e.shift();
  864. }
  865. reset() {
  866. var t = this.getCanvas().getPixelRatio();
  867. this.setTransform(1 * t, 0, 0, 1 * t, 0, 0);
  868. }
  869. getCanvas() {
  870. return this.canvas;
  871. }
  872. clear(t) {
  873. var e = this.getCanvas();
  874. t ? this.clearRect(t.x || 0, t.y || 0, t.width || 0, t.height || 0) : this.clearRect(0, 0, e.getWidth() / e.pixelRatio, e.getHeight() / e.pixelRatio);
  875. }
  876. _applyLineCap(t) {
  877. const e = t.attrs.lineCap;
  878. e && this.setAttr("lineCap", e);
  879. }
  880. _applyOpacity(t) {
  881. var e = t.getAbsoluteOpacity();
  882. e !== 1 && this.setAttr("globalAlpha", e);
  883. }
  884. _applyLineJoin(t) {
  885. const e = t.attrs.lineJoin;
  886. e && this.setAttr("lineJoin", e);
  887. }
  888. setAttr(t, e) {
  889. this._context[t] = e;
  890. }
  891. arc(t, e, i, n, r, a) {
  892. this._context.arc(t, e, i, n, r, a);
  893. }
  894. arcTo(t, e, i, n, r) {
  895. this._context.arcTo(t, e, i, n, r);
  896. }
  897. beginPath() {
  898. this._context.beginPath();
  899. }
  900. bezierCurveTo(t, e, i, n, r, a) {
  901. this._context.bezierCurveTo(t, e, i, n, r, a);
  902. }
  903. clearRect(t, e, i, n) {
  904. this._context.clearRect(t, e, i, n);
  905. }
  906. clip(...t) {
  907. this._context.clip.apply(this._context, t);
  908. }
  909. closePath() {
  910. this._context.closePath();
  911. }
  912. createImageData(t, e) {
  913. var i = arguments;
  914. if (i.length === 2)
  915. return this._context.createImageData(t, e);
  916. if (i.length === 1)
  917. return this._context.createImageData(t);
  918. }
  919. createLinearGradient(t, e, i, n) {
  920. return this._context.createLinearGradient(t, e, i, n);
  921. }
  922. createPattern(t, e) {
  923. return this._context.createPattern(t, e);
  924. }
  925. createRadialGradient(t, e, i, n, r, a) {
  926. return this._context.createRadialGradient(t, e, i, n, r, a);
  927. }
  928. drawImage(t, e, i, n, r, a, o, h, l) {
  929. var A = arguments, u = this._context;
  930. A.length === 3 ? u.drawImage(t, e, i) : A.length === 5 ? u.drawImage(t, e, i, n, r) : A.length === 9 && u.drawImage(t, e, i, n, r, a, o, h, l);
  931. }
  932. ellipse(t, e, i, n, r, a, o, h) {
  933. this._context.ellipse(t, e, i, n, r, a, o, h);
  934. }
  935. isPointInPath(t, e, i, n) {
  936. return i ? this._context.isPointInPath(i, t, e, n) : this._context.isPointInPath(t, e, n);
  937. }
  938. fill(...t) {
  939. this._context.fill.apply(this._context, t);
  940. }
  941. fillRect(t, e, i, n) {
  942. this._context.fillRect(t, e, i, n);
  943. }
  944. strokeRect(t, e, i, n) {
  945. this._context.strokeRect(t, e, i, n);
  946. }
  947. fillText(t, e, i, n) {
  948. n ? this._context.fillText(t, e, i, n) : this._context.fillText(t, e, i);
  949. }
  950. measureText(t) {
  951. return this._context.measureText(t);
  952. }
  953. getImageData(t, e, i, n) {
  954. return this._context.getImageData(t, e, i, n);
  955. }
  956. lineTo(t, e) {
  957. this._context.lineTo(t, e);
  958. }
  959. moveTo(t, e) {
  960. this._context.moveTo(t, e);
  961. }
  962. rect(t, e, i, n) {
  963. this._context.rect(t, e, i, n);
  964. }
  965. roundRect(t, e, i, n, r) {
  966. this._context.roundRect(t, e, i, n, r);
  967. }
  968. putImageData(t, e, i) {
  969. this._context.putImageData(t, e, i);
  970. }
  971. quadraticCurveTo(t, e, i, n) {
  972. this._context.quadraticCurveTo(t, e, i, n);
  973. }
  974. restore() {
  975. this._context.restore();
  976. }
  977. rotate(t) {
  978. this._context.rotate(t);
  979. }
  980. save() {
  981. this._context.save();
  982. }
  983. scale(t, e) {
  984. this._context.scale(t, e);
  985. }
  986. setLineDash(t) {
  987. this._context.setLineDash ? this._context.setLineDash(t) : "mozDash" in this._context ? this._context.mozDash = t : "webkitLineDash" in this._context && (this._context.webkitLineDash = t);
  988. }
  989. getLineDash() {
  990. return this._context.getLineDash();
  991. }
  992. setTransform(t, e, i, n, r, a) {
  993. this._context.setTransform(t, e, i, n, r, a);
  994. }
  995. stroke(t) {
  996. t ? this._context.stroke(t) : this._context.stroke();
  997. }
  998. strokeText(t, e, i, n) {
  999. this._context.strokeText(t, e, i, n);
  1000. }
  1001. transform(t, e, i, n, r, a) {
  1002. this._context.transform(t, e, i, n, r, a);
  1003. }
  1004. translate(t, e) {
  1005. this._context.translate(t, e);
  1006. }
  1007. _enableTrace() {
  1008. var t = this, e = Gr.length, i = this.setAttr, n, r, a = function(o) {
  1009. var h = t[o], l;
  1010. t[o] = function() {
  1011. return r = Ih(Array.prototype.slice.call(arguments, 0)), l = h.apply(t, arguments), t._trace({
  1012. method: o,
  1013. args: r
  1014. }), l;
  1015. };
  1016. };
  1017. for (n = 0; n < e; n++)
  1018. a(Gr[n]);
  1019. t.setAttr = function() {
  1020. i.apply(t, arguments);
  1021. var o = arguments[0], h = arguments[1];
  1022. (o === "shadowOffsetX" || o === "shadowOffsetY" || o === "shadowBlur") && (h = h / this.canvas.getPixelRatio()), t._trace({
  1023. property: o,
  1024. val: h
  1025. });
  1026. };
  1027. }
  1028. _applyGlobalCompositeOperation(t) {
  1029. const e = t.attrs.globalCompositeOperation;
  1030. var i = !e || e === "source-over";
  1031. i || this.setAttr("globalCompositeOperation", e);
  1032. }
  1033. }
  1034. Xt.Context = Mn;
  1035. zh.forEach(function(s) {
  1036. Object.defineProperty(Mn.prototype, s, {
  1037. get() {
  1038. return this._context[s];
  1039. },
  1040. set(t) {
  1041. this._context[s] = t;
  1042. }
  1043. });
  1044. });
  1045. class Hh extends Mn {
  1046. constructor(t, { willReadFrequently: e = !1 } = {}) {
  1047. super(t), this._context = t._canvas.getContext("2d", {
  1048. willReadFrequently: e
  1049. });
  1050. }
  1051. _fillColor(t) {
  1052. var e = t.fill();
  1053. this.setAttr("fillStyle", e), t._fillFunc(this);
  1054. }
  1055. _fillPattern(t) {
  1056. this.setAttr("fillStyle", t._getFillPattern()), t._fillFunc(this);
  1057. }
  1058. _fillLinearGradient(t) {
  1059. var e = t._getLinearGradient();
  1060. e && (this.setAttr("fillStyle", e), t._fillFunc(this));
  1061. }
  1062. _fillRadialGradient(t) {
  1063. const e = t._getRadialGradient();
  1064. e && (this.setAttr("fillStyle", e), t._fillFunc(this));
  1065. }
  1066. _fill(t) {
  1067. const e = t.fill(), i = t.getFillPriority();
  1068. if (e && i === "color") {
  1069. this._fillColor(t);
  1070. return;
  1071. }
  1072. const n = t.getFillPatternImage();
  1073. if (n && i === "pattern") {
  1074. this._fillPattern(t);
  1075. return;
  1076. }
  1077. const r = t.getFillLinearGradientColorStops();
  1078. if (r && i === "linear-gradient") {
  1079. this._fillLinearGradient(t);
  1080. return;
  1081. }
  1082. const a = t.getFillRadialGradientColorStops();
  1083. if (a && i === "radial-gradient") {
  1084. this._fillRadialGradient(t);
  1085. return;
  1086. }
  1087. e ? this._fillColor(t) : n ? this._fillPattern(t) : r ? this._fillLinearGradient(t) : a && this._fillRadialGradient(t);
  1088. }
  1089. _strokeLinearGradient(t) {
  1090. const e = t.getStrokeLinearGradientStartPoint(), i = t.getStrokeLinearGradientEndPoint(), n = t.getStrokeLinearGradientColorStops(), r = this.createLinearGradient(e.x, e.y, i.x, i.y);
  1091. if (n) {
  1092. for (var a = 0; a < n.length; a += 2)
  1093. r.addColorStop(n[a], n[a + 1]);
  1094. this.setAttr("strokeStyle", r);
  1095. }
  1096. }
  1097. _stroke(t) {
  1098. var e = t.dash(), i = t.getStrokeScaleEnabled();
  1099. if (t.hasStroke()) {
  1100. if (!i) {
  1101. this.save();
  1102. var n = this.getCanvas().getPixelRatio();
  1103. this.setTransform(n, 0, 0, n, 0, 0);
  1104. }
  1105. this._applyLineCap(t), e && t.dashEnabled() && (this.setLineDash(e), this.setAttr("lineDashOffset", t.dashOffset())), this.setAttr("lineWidth", t.strokeWidth()), t.getShadowForStrokeEnabled() || this.setAttr("shadowColor", "rgba(0,0,0,0)");
  1106. var r = t.getStrokeLinearGradientColorStops();
  1107. r ? this._strokeLinearGradient(t) : this.setAttr("strokeStyle", t.stroke()), t._strokeFunc(this), i || this.restore();
  1108. }
  1109. }
  1110. _applyShadow(t) {
  1111. var e, i, n, r = (e = t.getShadowRGBA()) !== null && e !== void 0 ? e : "black", a = (i = t.getShadowBlur()) !== null && i !== void 0 ? i : 5, o = (n = t.getShadowOffset()) !== null && n !== void 0 ? n : {
  1112. x: 0,
  1113. y: 0
  1114. }, h = t.getAbsoluteScale(), l = this.canvas.getPixelRatio(), A = h.x * l, u = h.y * l;
  1115. this.setAttr("shadowColor", r), this.setAttr("shadowBlur", a * Math.min(Math.abs(A), Math.abs(u))), this.setAttr("shadowOffsetX", o.x * A), this.setAttr("shadowOffsetY", o.y * u);
  1116. }
  1117. }
  1118. Xt.SceneContext = Hh;
  1119. class Vh extends Mn {
  1120. constructor(t) {
  1121. super(t), this._context = t._canvas.getContext("2d", {
  1122. willReadFrequently: !0
  1123. });
  1124. }
  1125. _fill(t) {
  1126. this.save(), this.setAttr("fillStyle", t.colorKey), t._fillFuncHit(this), this.restore();
  1127. }
  1128. strokeShape(t) {
  1129. t.hasHitStroke() && this._stroke(t);
  1130. }
  1131. _stroke(t) {
  1132. if (t.hasHitStroke()) {
  1133. const r = t.getStrokeScaleEnabled();
  1134. if (!r) {
  1135. this.save();
  1136. var e = this.getCanvas().getPixelRatio();
  1137. this.setTransform(e, 0, 0, e, 0, 0);
  1138. }
  1139. this._applyLineCap(t);
  1140. var i = t.hitStrokeWidth(), n = i === "auto" ? t.strokeWidth() : i;
  1141. this.setAttr("lineWidth", n), this.setAttr("strokeStyle", t.colorKey), t._strokeFuncHit(this), r || this.restore();
  1142. }
  1143. }
  1144. }
  1145. Xt.HitContext = Vh;
  1146. Object.defineProperty(It, "__esModule", { value: !0 });
  1147. It.HitCanvas = It.SceneCanvas = It.Canvas = void 0;
  1148. const on = st, Za = Xt, Ja = $, $h = V, Wh = O;
  1149. var $i;
  1150. function Yh() {
  1151. if ($i)
  1152. return $i;
  1153. var s = on.Util.createCanvasElement(), t = s.getContext("2d");
  1154. return $i = function() {
  1155. var e = Ja.Konva._global.devicePixelRatio || 1, i = t.webkitBackingStorePixelRatio || t.mozBackingStorePixelRatio || t.msBackingStorePixelRatio || t.oBackingStorePixelRatio || t.backingStorePixelRatio || 1;
  1156. return e / i;
  1157. }(), on.Util.releaseCanvas(s), $i;
  1158. }
  1159. class Pn {
  1160. constructor(t) {
  1161. this.pixelRatio = 1, this.width = 0, this.height = 0, this.isCache = !1;
  1162. var e = t || {}, i = e.pixelRatio || Ja.Konva.pixelRatio || Yh();
  1163. this.pixelRatio = i, this._canvas = on.Util.createCanvasElement(), this._canvas.style.padding = "0", this._canvas.style.margin = "0", this._canvas.style.border = "0", this._canvas.style.background = "transparent", this._canvas.style.position = "absolute", this._canvas.style.top = "0", this._canvas.style.left = "0";
  1164. }
  1165. getContext() {
  1166. return this.context;
  1167. }
  1168. getPixelRatio() {
  1169. return this.pixelRatio;
  1170. }
  1171. setPixelRatio(t) {
  1172. var e = this.pixelRatio;
  1173. this.pixelRatio = t, this.setSize(this.getWidth() / e, this.getHeight() / e);
  1174. }
  1175. setWidth(t) {
  1176. this.width = this._canvas.width = t * this.pixelRatio, this._canvas.style.width = t + "px";
  1177. var e = this.pixelRatio, i = this.getContext()._context;
  1178. i.scale(e, e);
  1179. }
  1180. setHeight(t) {
  1181. this.height = this._canvas.height = t * this.pixelRatio, this._canvas.style.height = t + "px";
  1182. var e = this.pixelRatio, i = this.getContext()._context;
  1183. i.scale(e, e);
  1184. }
  1185. getWidth() {
  1186. return this.width;
  1187. }
  1188. getHeight() {
  1189. return this.height;
  1190. }
  1191. setSize(t, e) {
  1192. this.setWidth(t || 0), this.setHeight(e || 0);
  1193. }
  1194. toDataURL(t, e) {
  1195. try {
  1196. return this._canvas.toDataURL(t, e);
  1197. } catch {
  1198. try {
  1199. return this._canvas.toDataURL();
  1200. } catch (n) {
  1201. return on.Util.error("Unable to get data URL. " + n.message + " For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."), "";
  1202. }
  1203. }
  1204. }
  1205. }
  1206. It.Canvas = Pn;
  1207. $h.Factory.addGetterSetter(Pn, "pixelRatio", void 0, (0, Wh.getNumberValidator)());
  1208. class Xh extends Pn {
  1209. constructor(t = { width: 0, height: 0, willReadFrequently: !1 }) {
  1210. super(t), this.context = new Za.SceneContext(this, {
  1211. willReadFrequently: t.willReadFrequently
  1212. }), this.setSize(t.width, t.height);
  1213. }
  1214. }
  1215. It.SceneCanvas = Xh;
  1216. class jh extends Pn {
  1217. constructor(t = { width: 0, height: 0 }) {
  1218. super(t), this.hitCanvas = !0, this.context = new Za.HitContext(this), this.setSize(t.width, t.height);
  1219. }
  1220. }
  1221. It.HitCanvas = jh;
  1222. var En = {};
  1223. (function(s) {
  1224. Object.defineProperty(s, "__esModule", { value: !0 }), s.DD = void 0;
  1225. const t = $, e = st;
  1226. s.DD = {
  1227. get isDragging() {
  1228. var i = !1;
  1229. return s.DD._dragElements.forEach((n) => {
  1230. n.dragStatus === "dragging" && (i = !0);
  1231. }), i;
  1232. },
  1233. justDragged: !1,
  1234. get node() {
  1235. var i;
  1236. return s.DD._dragElements.forEach((n) => {
  1237. i = n.node;
  1238. }), i;
  1239. },
  1240. _dragElements: /* @__PURE__ */ new Map(),
  1241. _drag(i) {
  1242. const n = [];
  1243. s.DD._dragElements.forEach((r, a) => {
  1244. const { node: o } = r, h = o.getStage();
  1245. h.setPointersPositions(i), r.pointerId === void 0 && (r.pointerId = e.Util._getFirstPointerId(i));
  1246. const l = h._changedPointerPositions.find((f) => f.id === r.pointerId);
  1247. if (l) {
  1248. if (r.dragStatus !== "dragging") {
  1249. var A = o.dragDistance(), u = Math.max(Math.abs(l.x - r.startPointerPos.x), Math.abs(l.y - r.startPointerPos.y));
  1250. if (u < A || (o.startDrag({ evt: i }), !o.isDragging()))
  1251. return;
  1252. }
  1253. o._setDragPosition(i, r), n.push(o);
  1254. }
  1255. }), n.forEach((r) => {
  1256. r.fire("dragmove", {
  1257. type: "dragmove",
  1258. target: r,
  1259. evt: i
  1260. }, !0);
  1261. });
  1262. },
  1263. _endDragBefore(i) {
  1264. const n = [];
  1265. s.DD._dragElements.forEach((r) => {
  1266. const { node: a } = r, o = a.getStage();
  1267. if (i && o.setPointersPositions(i), !o._changedPointerPositions.find((A) => A.id === r.pointerId))
  1268. return;
  1269. (r.dragStatus === "dragging" || r.dragStatus === "stopped") && (s.DD.justDragged = !0, t.Konva._mouseListenClick = !1, t.Konva._touchListenClick = !1, t.Konva._pointerListenClick = !1, r.dragStatus = "stopped");
  1270. const l = r.node.getLayer() || r.node instanceof t.Konva.Stage && r.node;
  1271. l && n.indexOf(l) === -1 && n.push(l);
  1272. }), n.forEach((r) => {
  1273. r.draw();
  1274. });
  1275. },
  1276. _endDragAfter(i) {
  1277. s.DD._dragElements.forEach((n, r) => {
  1278. n.dragStatus === "stopped" && n.node.fire("dragend", {
  1279. type: "dragend",
  1280. target: n.node,
  1281. evt: i
  1282. }, !0), n.dragStatus !== "dragging" && s.DD._dragElements.delete(r);
  1283. });
  1284. }
  1285. }, t.Konva.isBrowser && (window.addEventListener("mouseup", s.DD._endDragBefore, !0), window.addEventListener("touchend", s.DD._endDragBefore, !0), window.addEventListener("mousemove", s.DD._drag), window.addEventListener("touchmove", s.DD._drag), window.addEventListener("mouseup", s.DD._endDragAfter, !1), window.addEventListener("touchend", s.DD._endDragAfter, !1));
  1286. })(En);
  1287. Object.defineProperty(rt, "__esModule", { value: !0 });
  1288. rt.Node = void 0;
  1289. const W = st, Oi = V, mi = It, se = $, Ct = En, ct = O;
  1290. var rn = "absoluteOpacity", Wi = "allEventListeners", Wt = "absoluteTransform", Br = "absoluteScale", _e = "canvas", qh = "Change", Qh = "children", Kh = "konva", Ys = "listening", zr = "mouseenter", Ur = "mouseleave", Hr = "set", Vr = "Shape", an = " ", $r = "stage", he = "transform", Zh = "Stage", Xs = "visible", Jh = [
  1291. "xChange.konva",
  1292. "yChange.konva",
  1293. "scaleXChange.konva",
  1294. "scaleYChange.konva",
  1295. "skewXChange.konva",
  1296. "skewYChange.konva",
  1297. "rotationChange.konva",
  1298. "offsetXChange.konva",
  1299. "offsetYChange.konva",
  1300. "transformsEnabledChange.konva"
  1301. ].join(an);
  1302. let tl = 1, U = class js {
  1303. constructor(t) {
  1304. this._id = tl++, this.eventListeners = {}, this.attrs = {}, this.index = 0, this._allEventListeners = null, this.parent = null, this._cache = /* @__PURE__ */ new Map(), this._attachedDepsListeners = /* @__PURE__ */ new Map(), this._lastPos = null, this._batchingTransformChange = !1, this._needClearTransformCache = !1, this._filterUpToDate = !1, this._isUnderCache = !1, this._dragEventId = null, this._shouldFireChangeEvents = !1, this.setAttrs(t), this._shouldFireChangeEvents = !0;
  1305. }
  1306. hasChildren() {
  1307. return !1;
  1308. }
  1309. _clearCache(t) {
  1310. (t === he || t === Wt) && this._cache.get(t) ? this._cache.get(t).dirty = !0 : t ? this._cache.delete(t) : this._cache.clear();
  1311. }
  1312. _getCache(t, e) {
  1313. var i = this._cache.get(t), n = t === he || t === Wt, r = i === void 0 || n && i.dirty === !0;
  1314. return r && (i = e.call(this), this._cache.set(t, i)), i;
  1315. }
  1316. _calculate(t, e, i) {
  1317. if (!this._attachedDepsListeners.get(t)) {
  1318. const n = e.map((r) => r + "Change.konva").join(an);
  1319. this.on(n, () => {
  1320. this._clearCache(t);
  1321. }), this._attachedDepsListeners.set(t, !0);
  1322. }
  1323. return this._getCache(t, i);
  1324. }
  1325. _getCanvasCache() {
  1326. return this._cache.get(_e);
  1327. }
  1328. _clearSelfAndDescendantCache(t) {
  1329. this._clearCache(t), t === Wt && this.fire("absoluteTransformChange");
  1330. }
  1331. clearCache() {
  1332. if (this._cache.has(_e)) {
  1333. const { scene: t, filter: e, hit: i } = this._cache.get(_e);
  1334. W.Util.releaseCanvas(t, e, i), this._cache.delete(_e);
  1335. }
  1336. return this._clearSelfAndDescendantCache(), this._requestDraw(), this;
  1337. }
  1338. cache(t) {
  1339. var e = t || {}, i = {};
  1340. (e.x === void 0 || e.y === void 0 || e.width === void 0 || e.height === void 0) && (i = this.getClientRect({
  1341. skipTransform: !0,
  1342. relativeTo: this.getParent() || void 0
  1343. }));
  1344. var n = Math.ceil(e.width || i.width), r = Math.ceil(e.height || i.height), a = e.pixelRatio, o = e.x === void 0 ? Math.floor(i.x) : e.x, h = e.y === void 0 ? Math.floor(i.y) : e.y, l = e.offset || 0, A = e.drawBorder || !1, u = e.hitCanvasPixelRatio || 1;
  1345. if (!n || !r) {
  1346. W.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");
  1347. return;
  1348. }
  1349. const f = Math.abs(Math.round(i.x) - o) > 0.5 ? 1 : 0, c = Math.abs(Math.round(i.y) - h) > 0.5 ? 1 : 0;
  1350. n += l * 2 + f, r += l * 2 + c, o -= l, h -= l;
  1351. var d = new mi.SceneCanvas({
  1352. pixelRatio: a,
  1353. width: n,
  1354. height: r
  1355. }), p = new mi.SceneCanvas({
  1356. pixelRatio: a,
  1357. width: 0,
  1358. height: 0,
  1359. willReadFrequently: !0
  1360. }), m = new mi.HitCanvas({
  1361. pixelRatio: u,
  1362. width: n,
  1363. height: r
  1364. }), v = d.getContext(), _ = m.getContext();
  1365. return m.isCache = !0, d.isCache = !0, this._cache.delete(_e), this._filterUpToDate = !1, e.imageSmoothingEnabled === !1 && (d.getContext()._context.imageSmoothingEnabled = !1, p.getContext()._context.imageSmoothingEnabled = !1), v.save(), _.save(), v.translate(-o, -h), _.translate(-o, -h), this._isUnderCache = !0, this._clearSelfAndDescendantCache(rn), this._clearSelfAndDescendantCache(Br), this.drawScene(d, this), this.drawHit(m, this), this._isUnderCache = !1, v.restore(), _.restore(), A && (v.save(), v.beginPath(), v.rect(0, 0, n, r), v.closePath(), v.setAttr("strokeStyle", "red"), v.setAttr("lineWidth", 5), v.stroke(), v.restore()), this._cache.set(_e, {
  1366. scene: d,
  1367. filter: p,
  1368. hit: m,
  1369. x: o,
  1370. y: h
  1371. }), this._requestDraw(), this;
  1372. }
  1373. isCached() {
  1374. return this._cache.has(_e);
  1375. }
  1376. getClientRect(t) {
  1377. throw new Error('abstract "getClientRect" method call');
  1378. }
  1379. _transformedRect(t, e) {
  1380. var i = [
  1381. { x: t.x, y: t.y },
  1382. { x: t.x + t.width, y: t.y },
  1383. { x: t.x + t.width, y: t.y + t.height },
  1384. { x: t.x, y: t.y + t.height }
  1385. ], n = 1 / 0, r = 1 / 0, a = -1 / 0, o = -1 / 0, h = this.getAbsoluteTransform(e);
  1386. return i.forEach(function(l) {
  1387. var A = h.point(l);
  1388. n === void 0 && (n = a = A.x, r = o = A.y), n = Math.min(n, A.x), r = Math.min(r, A.y), a = Math.max(a, A.x), o = Math.max(o, A.y);
  1389. }), {
  1390. x: n,
  1391. y: r,
  1392. width: a - n,
  1393. height: o - r
  1394. };
  1395. }
  1396. _drawCachedSceneCanvas(t) {
  1397. t.save(), t._applyOpacity(this), t._applyGlobalCompositeOperation(this);
  1398. const e = this._getCanvasCache();
  1399. t.translate(e.x, e.y);
  1400. var i = this._getCachedSceneCanvas(), n = i.pixelRatio;
  1401. t.drawImage(i._canvas, 0, 0, i.width / n, i.height / n), t.restore();
  1402. }
  1403. _drawCachedHitCanvas(t) {
  1404. var e = this._getCanvasCache(), i = e.hit;
  1405. t.save(), t.translate(e.x, e.y), t.drawImage(i._canvas, 0, 0, i.width / i.pixelRatio, i.height / i.pixelRatio), t.restore();
  1406. }
  1407. _getCachedSceneCanvas() {
  1408. var t = this.filters(), e = this._getCanvasCache(), i = e.scene, n = e.filter, r = n.getContext(), a, o, h, l;
  1409. if (t) {
  1410. if (!this._filterUpToDate) {
  1411. var A = i.pixelRatio;
  1412. n.setSize(i.width / i.pixelRatio, i.height / i.pixelRatio);
  1413. try {
  1414. for (a = t.length, r.clear(), r.drawImage(i._canvas, 0, 0, i.getWidth() / A, i.getHeight() / A), o = r.getImageData(0, 0, n.getWidth(), n.getHeight()), h = 0; h < a; h++) {
  1415. if (l = t[h], typeof l != "function") {
  1416. W.Util.error("Filter should be type of function, but got " + typeof l + " instead. Please check correct filters");
  1417. continue;
  1418. }
  1419. l.call(this, o), r.putImageData(o, 0, 0);
  1420. }
  1421. } catch (u) {
  1422. W.Util.error("Unable to apply filter. " + u.message + " This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.");
  1423. }
  1424. this._filterUpToDate = !0;
  1425. }
  1426. return n;
  1427. }
  1428. return i;
  1429. }
  1430. on(t, e) {
  1431. if (this._cache && this._cache.delete(Wi), arguments.length === 3)
  1432. return this._delegate.apply(this, arguments);
  1433. var i = t.split(an), n = i.length, r, a, o, h, l;
  1434. for (r = 0; r < n; r++)
  1435. a = i[r], o = a.split("."), h = o[0], l = o[1] || "", this.eventListeners[h] || (this.eventListeners[h] = []), this.eventListeners[h].push({
  1436. name: l,
  1437. handler: e
  1438. });
  1439. return this;
  1440. }
  1441. off(t, e) {
  1442. var i = (t || "").split(an), n = i.length, r, a, o, h, l, A;
  1443. if (this._cache && this._cache.delete(Wi), !t)
  1444. for (a in this.eventListeners)
  1445. this._off(a);
  1446. for (r = 0; r < n; r++)
  1447. if (o = i[r], h = o.split("."), l = h[0], A = h[1], l)
  1448. this.eventListeners[l] && this._off(l, A, e);
  1449. else
  1450. for (a in this.eventListeners)
  1451. this._off(a, A, e);
  1452. return this;
  1453. }
  1454. dispatchEvent(t) {
  1455. var e = {
  1456. target: this,
  1457. type: t.type,
  1458. evt: t
  1459. };
  1460. return this.fire(t.type, e), this;
  1461. }
  1462. addEventListener(t, e) {
  1463. return this.on(t, function(i) {
  1464. e.call(this, i.evt);
  1465. }), this;
  1466. }
  1467. removeEventListener(t) {
  1468. return this.off(t), this;
  1469. }
  1470. _delegate(t, e, i) {
  1471. var n = this;
  1472. this.on(t, function(r) {
  1473. for (var a = r.target.findAncestors(e, !0, n), o = 0; o < a.length; o++)
  1474. r = W.Util.cloneObject(r), r.currentTarget = a[o], i.call(a[o], r);
  1475. });
  1476. }
  1477. remove() {
  1478. return this.isDragging() && this.stopDrag(), Ct.DD._dragElements.delete(this._id), this._remove(), this;
  1479. }
  1480. _clearCaches() {
  1481. this._clearSelfAndDescendantCache(Wt), this._clearSelfAndDescendantCache(rn), this._clearSelfAndDescendantCache(Br), this._clearSelfAndDescendantCache($r), this._clearSelfAndDescendantCache(Xs), this._clearSelfAndDescendantCache(Ys);
  1482. }
  1483. _remove() {
  1484. this._clearCaches();
  1485. var t = this.getParent();
  1486. t && t.children && (t.children.splice(this.index, 1), t._setChildrenIndices(), this.parent = null);
  1487. }
  1488. destroy() {
  1489. return this.remove(), this.clearCache(), this;
  1490. }
  1491. getAttr(t) {
  1492. var e = "get" + W.Util._capitalize(t);
  1493. return W.Util._isFunction(this[e]) ? this[e]() : this.attrs[t];
  1494. }
  1495. getAncestors() {
  1496. for (var t = this.getParent(), e = []; t; )
  1497. e.push(t), t = t.getParent();
  1498. return e;
  1499. }
  1500. getAttrs() {
  1501. return this.attrs || {};
  1502. }
  1503. setAttrs(t) {
  1504. return this._batchTransformChanges(() => {
  1505. var e, i;
  1506. if (!t)
  1507. return this;
  1508. for (e in t)
  1509. e !== Qh && (i = Hr + W.Util._capitalize(e), W.Util._isFunction(this[i]) ? this[i](t[e]) : this._setAttr(e, t[e]));
  1510. }), this;
  1511. }
  1512. isListening() {
  1513. return this._getCache(Ys, this._isListening);
  1514. }
  1515. _isListening(t) {
  1516. if (!this.listening())
  1517. return !1;
  1518. const i = this.getParent();
  1519. return i && i !== t && this !== t ? i._isListening(t) : !0;
  1520. }
  1521. isVisible() {
  1522. return this._getCache(Xs, this._isVisible);
  1523. }
  1524. _isVisible(t) {
  1525. if (!this.visible())
  1526. return !1;
  1527. const i = this.getParent();
  1528. return i && i !== t && this !== t ? i._isVisible(t) : !0;
  1529. }
  1530. shouldDrawHit(t, e = !1) {
  1531. if (t)
  1532. return this._isVisible(t) && this._isListening(t);
  1533. var i = this.getLayer(), n = !1;
  1534. Ct.DD._dragElements.forEach((a) => {
  1535. a.dragStatus === "dragging" && (a.node.nodeType === "Stage" || a.node.getLayer() === i) && (n = !0);
  1536. });
  1537. var r = !e && !se.Konva.hitOnDragEnabled && (n || se.Konva.isTransforming());
  1538. return this.isListening() && this.isVisible() && !r;
  1539. }
  1540. show() {
  1541. return this.visible(!0), this;
  1542. }
  1543. hide() {
  1544. return this.visible(!1), this;
  1545. }
  1546. getZIndex() {
  1547. return this.index || 0;
  1548. }
  1549. getAbsoluteZIndex() {
  1550. var t = this.getDepth(), e = this, i = 0, n, r, a, o;
  1551. function h(A) {
  1552. for (n = [], r = A.length, a = 0; a < r; a++)
  1553. o = A[a], i++, o.nodeType !== Vr && (n = n.concat(o.getChildren().slice())), o._id === e._id && (a = r);
  1554. n.length > 0 && n[0].getDepth() <= t && h(n);
  1555. }
  1556. const l = this.getStage();
  1557. return e.nodeType !== Zh && l && h(l.getChildren()), i;
  1558. }
  1559. getDepth() {
  1560. for (var t = 0, e = this.parent; e; )
  1561. t++, e = e.parent;
  1562. return t;
  1563. }
  1564. _batchTransformChanges(t) {
  1565. this._batchingTransformChange = !0, t(), this._batchingTransformChange = !1, this._needClearTransformCache && (this._clearCache(he), this._clearSelfAndDescendantCache(Wt)), this._needClearTransformCache = !1;
  1566. }
  1567. setPosition(t) {
  1568. return this._batchTransformChanges(() => {
  1569. this.x(t.x), this.y(t.y);
  1570. }), this;
  1571. }
  1572. getPosition() {
  1573. return {
  1574. x: this.x(),
  1575. y: this.y()
  1576. };
  1577. }
  1578. getRelativePointerPosition() {
  1579. const t = this.getStage();
  1580. if (!t)
  1581. return null;
  1582. var e = t.getPointerPosition();
  1583. if (!e)
  1584. return null;
  1585. var i = this.getAbsoluteTransform().copy();
  1586. return i.invert(), i.point(e);
  1587. }
  1588. getAbsolutePosition(t) {
  1589. let e = !1, i = this.parent;
  1590. for (; i; ) {
  1591. if (i.isCached()) {
  1592. e = !0;
  1593. break;
  1594. }
  1595. i = i.parent;
  1596. }
  1597. e && !t && (t = !0);
  1598. var n = this.getAbsoluteTransform(t).getMatrix(), r = new W.Transform(), a = this.offset();
  1599. return r.m = n.slice(), r.translate(a.x, a.y), r.getTranslation();
  1600. }
  1601. setAbsolutePosition(t) {
  1602. const { x: e, y: i, ...n } = this._clearTransform();
  1603. this.attrs.x = e, this.attrs.y = i, this._clearCache(he);
  1604. var r = this._getAbsoluteTransform().copy();
  1605. return r.invert(), r.translate(t.x, t.y), t = {
  1606. x: this.attrs.x + r.getTranslation().x,
  1607. y: this.attrs.y + r.getTranslation().y
  1608. }, this._setTransform(n), this.setPosition({ x: t.x, y: t.y }), this._clearCache(he), this._clearSelfAndDescendantCache(Wt), this;
  1609. }
  1610. _setTransform(t) {
  1611. var e;
  1612. for (e in t)
  1613. this.attrs[e] = t[e];
  1614. }
  1615. _clearTransform() {
  1616. var t = {
  1617. x: this.x(),
  1618. y: this.y(),
  1619. rotation: this.rotation(),
  1620. scaleX: this.scaleX(),
  1621. scaleY: this.scaleY(),
  1622. offsetX: this.offsetX(),
  1623. offsetY: this.offsetY(),
  1624. skewX: this.skewX(),
  1625. skewY: this.skewY()
  1626. };
  1627. return this.attrs.x = 0, this.attrs.y = 0, this.attrs.rotation = 0, this.attrs.scaleX = 1, this.attrs.scaleY = 1, this.attrs.offsetX = 0, this.attrs.offsetY = 0, this.attrs.skewX = 0, this.attrs.skewY = 0, t;
  1628. }
  1629. move(t) {
  1630. var e = t.x, i = t.y, n = this.x(), r = this.y();
  1631. return e !== void 0 && (n += e), i !== void 0 && (r += i), this.setPosition({ x: n, y: r }), this;
  1632. }
  1633. _eachAncestorReverse(t, e) {
  1634. var i = [], n = this.getParent(), r, a;
  1635. if (!(e && e._id === this._id)) {
  1636. for (i.unshift(this); n && (!e || n._id !== e._id); )
  1637. i.unshift(n), n = n.parent;
  1638. for (r = i.length, a = 0; a < r; a++)
  1639. t(i[a]);
  1640. }
  1641. }
  1642. rotate(t) {
  1643. return this.rotation(this.rotation() + t), this;
  1644. }
  1645. moveToTop() {
  1646. if (!this.parent)
  1647. return W.Util.warn("Node has no parent. moveToTop function is ignored."), !1;
  1648. var t = this.index, e = this.parent.getChildren().length;
  1649. return t < e - 1 ? (this.parent.children.splice(t, 1), this.parent.children.push(this), this.parent._setChildrenIndices(), !0) : !1;
  1650. }
  1651. moveUp() {
  1652. if (!this.parent)
  1653. return W.Util.warn("Node has no parent. moveUp function is ignored."), !1;
  1654. var t = this.index, e = this.parent.getChildren().length;
  1655. return t < e - 1 ? (this.parent.children.splice(t, 1), this.parent.children.splice(t + 1, 0, this), this.parent._setChildrenIndices(), !0) : !1;
  1656. }
  1657. moveDown() {
  1658. if (!this.parent)
  1659. return W.Util.warn("Node has no parent. moveDown function is ignored."), !1;
  1660. var t = this.index;
  1661. return t > 0 ? (this.parent.children.splice(t, 1), this.parent.children.splice(t - 1, 0, this), this.parent._setChildrenIndices(), !0) : !1;
  1662. }
  1663. moveToBottom() {
  1664. if (!this.parent)
  1665. return W.Util.warn("Node has no parent. moveToBottom function is ignored."), !1;
  1666. var t = this.index;
  1667. return t > 0 ? (this.parent.children.splice(t, 1), this.parent.children.unshift(this), this.parent._setChildrenIndices(), !0) : !1;
  1668. }
  1669. setZIndex(t) {
  1670. if (!this.parent)
  1671. return W.Util.warn("Node has no parent. zIndex parameter is ignored."), this;
  1672. (t < 0 || t >= this.parent.children.length) && W.Util.warn("Unexpected value " + t + " for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to " + (this.parent.children.length - 1) + ".");
  1673. var e = this.index;
  1674. return this.parent.children.splice(e, 1), this.parent.children.splice(t, 0, this), this.parent._setChildrenIndices(), this;
  1675. }
  1676. getAbsoluteOpacity() {
  1677. return this._getCache(rn, this._getAbsoluteOpacity);
  1678. }
  1679. _getAbsoluteOpacity() {
  1680. var t = this.opacity(), e = this.getParent();
  1681. return e && !e._isUnderCache && (t *= e.getAbsoluteOpacity()), t;
  1682. }
  1683. moveTo(t) {
  1684. return this.getParent() !== t && (this._remove(), t.add(this)), this;
  1685. }
  1686. toObject() {
  1687. var t = this.getAttrs(), e, i, n, r, a;
  1688. const o = {
  1689. attrs: {},
  1690. className: this.getClassName()
  1691. };
  1692. for (e in t)
  1693. i = t[e], a = W.Util.isObject(i) && !W.Util._isPlainObject(i) && !W.Util._isArray(i), !a && (n = typeof this[e] == "function" && this[e], delete t[e], r = n ? n.call(this) : null, t[e] = i, r !== i && (o.attrs[e] = i));
  1694. return W.Util._prepareToStringify(o);
  1695. }
  1696. toJSON() {
  1697. return JSON.stringify(this.toObject());
  1698. }
  1699. getParent() {
  1700. return this.parent;
  1701. }
  1702. findAncestors(t, e, i) {
  1703. var n = [];
  1704. e && this._isMatch(t) && n.push(this);
  1705. for (var r = this.parent; r; ) {
  1706. if (r === i)
  1707. return n;
  1708. r._isMatch(t) && n.push(r), r = r.parent;
  1709. }
  1710. return n;
  1711. }
  1712. isAncestorOf(t) {
  1713. return !1;
  1714. }
  1715. findAncestor(t, e, i) {
  1716. return this.findAncestors(t, e, i)[0];
  1717. }
  1718. _isMatch(t) {
  1719. if (!t)
  1720. return !1;
  1721. if (typeof t == "function")
  1722. return t(this);
  1723. var e = t.replace(/ /g, "").split(","), i = e.length, n, r;
  1724. for (n = 0; n < i; n++)
  1725. if (r = e[n], W.Util.isValidSelector(r) || (W.Util.warn('Selector "' + r + '" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'), W.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'), W.Util.warn("Konva is awesome, right?")), r.charAt(0) === "#") {
  1726. if (this.id() === r.slice(1))
  1727. return !0;
  1728. } else if (r.charAt(0) === ".") {
  1729. if (this.hasName(r.slice(1)))
  1730. return !0;
  1731. } else if (this.className === r || this.nodeType === r)
  1732. return !0;
  1733. return !1;
  1734. }
  1735. getLayer() {
  1736. var t = this.getParent();
  1737. return t ? t.getLayer() : null;
  1738. }
  1739. getStage() {
  1740. return this._getCache($r, this._getStage);
  1741. }
  1742. _getStage() {
  1743. var t = this.getParent();
  1744. return t ? t.getStage() : null;
  1745. }
  1746. fire(t, e = {}, i) {
  1747. return e.target = e.target || this, i ? this._fireAndBubble(t, e) : this._fire(t, e), this;
  1748. }
  1749. getAbsoluteTransform(t) {
  1750. return t ? this._getAbsoluteTransform(t) : this._getCache(Wt, this._getAbsoluteTransform);
  1751. }
  1752. _getAbsoluteTransform(t) {
  1753. var e;
  1754. if (t)
  1755. return e = new W.Transform(), this._eachAncestorReverse(function(n) {
  1756. var r = n.transformsEnabled();
  1757. r === "all" ? e.multiply(n.getTransform()) : r === "position" && e.translate(n.x() - n.offsetX(), n.y() - n.offsetY());
  1758. }, t), e;
  1759. e = this._cache.get(Wt) || new W.Transform(), this.parent ? this.parent.getAbsoluteTransform().copyInto(e) : e.reset();
  1760. var i = this.transformsEnabled();
  1761. if (i === "all")
  1762. e.multiply(this.getTransform());
  1763. else if (i === "position") {
  1764. const n = this.attrs.x || 0, r = this.attrs.y || 0, a = this.attrs.offsetX || 0, o = this.attrs.offsetY || 0;
  1765. e.translate(n - a, r - o);
  1766. }
  1767. return e.dirty = !1, e;
  1768. }
  1769. getAbsoluteScale(t) {
  1770. for (var e = this; e; )
  1771. e._isUnderCache && (t = e), e = e.getParent();
  1772. const n = this.getAbsoluteTransform(t).decompose();
  1773. return {
  1774. x: n.scaleX,
  1775. y: n.scaleY
  1776. };
  1777. }
  1778. getAbsoluteRotation() {
  1779. return this.getAbsoluteTransform().decompose().rotation;
  1780. }
  1781. getTransform() {
  1782. return this._getCache(he, this._getTransform);
  1783. }
  1784. _getTransform() {
  1785. var t, e, i = this._cache.get(he) || new W.Transform();
  1786. i.reset();
  1787. var n = this.x(), r = this.y(), a = se.Konva.getAngle(this.rotation()), o = (t = this.attrs.scaleX) !== null && t !== void 0 ? t : 1, h = (e = this.attrs.scaleY) !== null && e !== void 0 ? e : 1, l = this.attrs.skewX || 0, A = this.attrs.skewY || 0, u = this.attrs.offsetX || 0, f = this.attrs.offsetY || 0;
  1788. return (n !== 0 || r !== 0) && i.translate(n, r), a !== 0 && i.rotate(a), (l !== 0 || A !== 0) && i.skew(l, A), (o !== 1 || h !== 1) && i.scale(o, h), (u !== 0 || f !== 0) && i.translate(-1 * u, -1 * f), i.dirty = !1, i;
  1789. }
  1790. clone(t) {
  1791. var e = W.Util.cloneObject(this.attrs), i, n, r, a, o;
  1792. for (i in t)
  1793. e[i] = t[i];
  1794. var h = new this.constructor(e);
  1795. for (i in this.eventListeners)
  1796. for (n = this.eventListeners[i], r = n.length, a = 0; a < r; a++)
  1797. o = n[a], o.name.indexOf(Kh) < 0 && (h.eventListeners[i] || (h.eventListeners[i] = []), h.eventListeners[i].push(o));
  1798. return h;
  1799. }
  1800. _toKonvaCanvas(t) {
  1801. t = t || {};
  1802. var e = this.getClientRect(), i = this.getStage(), n = t.x !== void 0 ? t.x : Math.floor(e.x), r = t.y !== void 0 ? t.y : Math.floor(e.y), a = t.pixelRatio || 1, o = new mi.SceneCanvas({
  1803. width: t.width || Math.ceil(e.width) || (i ? i.width() : 0),
  1804. height: t.height || Math.ceil(e.height) || (i ? i.height() : 0),
  1805. pixelRatio: a
  1806. }), h = o.getContext();
  1807. const l = new mi.SceneCanvas({
  1808. width: o.width / o.pixelRatio + Math.abs(n),
  1809. height: o.height / o.pixelRatio + Math.abs(r),
  1810. pixelRatio: o.pixelRatio
  1811. });
  1812. return t.imageSmoothingEnabled === !1 && (h._context.imageSmoothingEnabled = !1), h.save(), (n || r) && h.translate(-1 * n, -1 * r), this.drawScene(o, void 0, l), h.restore(), o;
  1813. }
  1814. toCanvas(t) {
  1815. return this._toKonvaCanvas(t)._canvas;
  1816. }
  1817. toDataURL(t) {
  1818. t = t || {};
  1819. var e = t.mimeType || null, i = t.quality || null, n = this._toKonvaCanvas(t).toDataURL(e, i);
  1820. return t.callback && t.callback(n), n;
  1821. }
  1822. toImage(t) {
  1823. return new Promise((e, i) => {
  1824. try {
  1825. const n = t == null ? void 0 : t.callback;
  1826. n && delete t.callback, W.Util._urlToImage(this.toDataURL(t), function(r) {
  1827. e(r), n == null || n(r);
  1828. });
  1829. } catch (n) {
  1830. i(n);
  1831. }
  1832. });
  1833. }
  1834. toBlob(t) {
  1835. return new Promise((e, i) => {
  1836. try {
  1837. const n = t == null ? void 0 : t.callback;
  1838. n && delete t.callback, this.toCanvas(t).toBlob((r) => {
  1839. e(r), n == null || n(r);
  1840. }, t == null ? void 0 : t.mimeType, t == null ? void 0 : t.quality);
  1841. } catch (n) {
  1842. i(n);
  1843. }
  1844. });
  1845. }
  1846. setSize(t) {
  1847. return this.width(t.width), this.height(t.height), this;
  1848. }
  1849. getSize() {
  1850. return {
  1851. width: this.width(),
  1852. height: this.height()
  1853. };
  1854. }
  1855. getClassName() {
  1856. return this.className || this.nodeType;
  1857. }
  1858. getType() {
  1859. return this.nodeType;
  1860. }
  1861. getDragDistance() {
  1862. return this.attrs.dragDistance !== void 0 ? this.attrs.dragDistance : this.parent ? this.parent.getDragDistance() : se.Konva.dragDistance;
  1863. }
  1864. _off(t, e, i) {
  1865. var n = this.eventListeners[t], r, a, o;
  1866. for (r = 0; r < n.length; r++)
  1867. if (a = n[r].name, o = n[r].handler, (a !== "konva" || e === "konva") && (!e || a === e) && (!i || i === o)) {
  1868. if (n.splice(r, 1), n.length === 0) {
  1869. delete this.eventListeners[t];
  1870. break;
  1871. }
  1872. r--;
  1873. }
  1874. }
  1875. _fireChangeEvent(t, e, i) {
  1876. this._fire(t + qh, {
  1877. oldVal: e,
  1878. newVal: i
  1879. });
  1880. }
  1881. addName(t) {
  1882. if (!this.hasName(t)) {
  1883. var e = this.name(), i = e ? e + " " + t : t;
  1884. this.name(i);
  1885. }
  1886. return this;
  1887. }
  1888. hasName(t) {
  1889. if (!t)
  1890. return !1;
  1891. const e = this.name();
  1892. if (!e)
  1893. return !1;
  1894. var i = (e || "").split(/\s/g);
  1895. return i.indexOf(t) !== -1;
  1896. }
  1897. removeName(t) {
  1898. var e = (this.name() || "").split(/\s/g), i = e.indexOf(t);
  1899. return i !== -1 && (e.splice(i, 1), this.name(e.join(" "))), this;
  1900. }
  1901. setAttr(t, e) {
  1902. var i = this[Hr + W.Util._capitalize(t)];
  1903. return W.Util._isFunction(i) ? i.call(this, e) : this._setAttr(t, e), this;
  1904. }
  1905. _requestDraw() {
  1906. if (se.Konva.autoDrawEnabled) {
  1907. const t = this.getLayer() || this.getStage();
  1908. t == null || t.batchDraw();
  1909. }
  1910. }
  1911. _setAttr(t, e) {
  1912. var i = this.attrs[t];
  1913. i === e && !W.Util.isObject(e) || (e == null ? delete this.attrs[t] : this.attrs[t] = e, this._shouldFireChangeEvents && this._fireChangeEvent(t, i, e), this._requestDraw());
  1914. }
  1915. _setComponentAttr(t, e, i) {
  1916. var n;
  1917. i !== void 0 && (n = this.attrs[t], n || (this.attrs[t] = this.getAttr(t)), this.attrs[t][e] = i, this._fireChangeEvent(t, n, i));
  1918. }
  1919. _fireAndBubble(t, e, i) {
  1920. e && this.nodeType === Vr && (e.target = this);
  1921. var n = (t === zr || t === Ur) && (i && (this === i || this.isAncestorOf && this.isAncestorOf(i)) || this.nodeType === "Stage" && !i);
  1922. if (!n) {
  1923. this._fire(t, e);
  1924. var r = (t === zr || t === Ur) && i && i.isAncestorOf && i.isAncestorOf(this) && !i.isAncestorOf(this.parent);
  1925. (e && !e.cancelBubble || !e) && this.parent && this.parent.isListening() && !r && (i && i.parent ? this._fireAndBubble.call(this.parent, t, e, i) : this._fireAndBubble.call(this.parent, t, e));
  1926. }
  1927. }
  1928. _getProtoListeners(t) {
  1929. var e, i, n;
  1930. const r = (e = this._cache.get(Wi)) !== null && e !== void 0 ? e : {};
  1931. let a = r == null ? void 0 : r[t];
  1932. if (a === void 0) {
  1933. a = [];
  1934. let o = Object.getPrototypeOf(this);
  1935. for (; o; ) {
  1936. const h = (n = (i = o.eventListeners) === null || i === void 0 ? void 0 : i[t]) !== null && n !== void 0 ? n : [];
  1937. a.push(...h), o = Object.getPrototypeOf(o);
  1938. }
  1939. r[t] = a, this._cache.set(Wi, r);
  1940. }
  1941. return a;
  1942. }
  1943. _fire(t, e) {
  1944. e = e || {}, e.currentTarget = this, e.type = t;
  1945. const i = this._getProtoListeners(t);
  1946. if (i)
  1947. for (var n = 0; n < i.length; n++)
  1948. i[n].handler.call(this, e);
  1949. const r = this.eventListeners[t];
  1950. if (r)
  1951. for (var n = 0; n < r.length; n++)
  1952. r[n].handler.call(this, e);
  1953. }
  1954. draw() {
  1955. return this.drawScene(), this.drawHit(), this;
  1956. }
  1957. _createDragElement(t) {
  1958. var e = t ? t.pointerId : void 0, i = this.getStage(), n = this.getAbsolutePosition();
  1959. if (i) {
  1960. var r = i._getPointerById(e) || i._changedPointerPositions[0] || n;
  1961. Ct.DD._dragElements.set(this._id, {
  1962. node: this,
  1963. startPointerPos: r,
  1964. offset: {
  1965. x: r.x - n.x,
  1966. y: r.y - n.y
  1967. },
  1968. dragStatus: "ready",
  1969. pointerId: e
  1970. });
  1971. }
  1972. }
  1973. startDrag(t, e = !0) {
  1974. Ct.DD._dragElements.has(this._id) || this._createDragElement(t);
  1975. const i = Ct.DD._dragElements.get(this._id);
  1976. i.dragStatus = "dragging", this.fire("dragstart", {
  1977. type: "dragstart",
  1978. target: this,
  1979. evt: t && t.evt
  1980. }, e);
  1981. }
  1982. _setDragPosition(t, e) {
  1983. const i = this.getStage()._getPointerById(e.pointerId);
  1984. if (i) {
  1985. var n = {
  1986. x: i.x - e.offset.x,
  1987. y: i.y - e.offset.y
  1988. }, r = this.dragBoundFunc();
  1989. if (r !== void 0) {
  1990. const a = r.call(this, n, t);
  1991. a ? n = a : W.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.");
  1992. }
  1993. (!this._lastPos || this._lastPos.x !== n.x || this._lastPos.y !== n.y) && (this.setAbsolutePosition(n), this._requestDraw()), this._lastPos = n;
  1994. }
  1995. }
  1996. stopDrag(t) {
  1997. const e = Ct.DD._dragElements.get(this._id);
  1998. e && (e.dragStatus = "stopped"), Ct.DD._endDragBefore(t), Ct.DD._endDragAfter(t);
  1999. }
  2000. setDraggable(t) {
  2001. this._setAttr("draggable", t), this._dragChange();
  2002. }
  2003. isDragging() {
  2004. const t = Ct.DD._dragElements.get(this._id);
  2005. return t ? t.dragStatus === "dragging" : !1;
  2006. }
  2007. _listenDrag() {
  2008. this._dragCleanup(), this.on("mousedown.konva touchstart.konva", function(t) {
  2009. var e = t.evt.button !== void 0, i = !e || se.Konva.dragButtons.indexOf(t.evt.button) >= 0;
  2010. if (i && !this.isDragging()) {
  2011. var n = !1;
  2012. Ct.DD._dragElements.forEach((r) => {
  2013. this.isAncestorOf(r.node) && (n = !0);
  2014. }), n || this._createDragElement(t);
  2015. }
  2016. });
  2017. }
  2018. _dragChange() {
  2019. if (this.attrs.draggable)
  2020. this._listenDrag();
  2021. else {
  2022. this._dragCleanup();
  2023. var t = this.getStage();
  2024. if (!t)
  2025. return;
  2026. const e = Ct.DD._dragElements.get(this._id), i = e && e.dragStatus === "dragging", n = e && e.dragStatus === "ready";
  2027. i ? this.stopDrag() : n && Ct.DD._dragElements.delete(this._id);
  2028. }
  2029. }
  2030. _dragCleanup() {
  2031. this.off("mousedown.konva"), this.off("touchstart.konva");
  2032. }
  2033. isClientRectOnScreen(t = { x: 0, y: 0 }) {
  2034. const e = this.getStage();
  2035. if (!e)
  2036. return !1;
  2037. const i = {
  2038. x: -t.x,
  2039. y: -t.y,
  2040. width: e.width() + 2 * t.x,
  2041. height: e.height() + 2 * t.y
  2042. };
  2043. return W.Util.haveIntersection(i, this.getClientRect());
  2044. }
  2045. static create(t, e) {
  2046. return W.Util._isString(t) && (t = JSON.parse(t)), this._createNode(t, e);
  2047. }
  2048. static _createNode(t, e) {
  2049. var i = js.prototype.getClassName.call(t), n = t.children, r, a, o;
  2050. e && (t.attrs.container = e), se.Konva[i] || (W.Util.warn('Can not find a node with class name "' + i + '". Fallback to "Shape".'), i = "Shape");
  2051. const h = se.Konva[i];
  2052. if (r = new h(t.attrs), n)
  2053. for (a = n.length, o = 0; o < a; o++)
  2054. r.add(js._createNode(n[o]));
  2055. return r;
  2056. }
  2057. };
  2058. rt.Node = U;
  2059. U.prototype.nodeType = "Node";
  2060. U.prototype._attrsAffectingSize = [];
  2061. U.prototype.eventListeners = {};
  2062. U.prototype.on.call(U.prototype, Jh, function() {
  2063. if (this._batchingTransformChange) {
  2064. this._needClearTransformCache = !0;
  2065. return;
  2066. }
  2067. this._clearCache(he), this._clearSelfAndDescendantCache(Wt);
  2068. });
  2069. U.prototype.on.call(U.prototype, "visibleChange.konva", function() {
  2070. this._clearSelfAndDescendantCache(Xs);
  2071. });
  2072. U.prototype.on.call(U.prototype, "listeningChange.konva", function() {
  2073. this._clearSelfAndDescendantCache(Ys);
  2074. });
  2075. U.prototype.on.call(U.prototype, "opacityChange.konva", function() {
  2076. this._clearSelfAndDescendantCache(rn);
  2077. });
  2078. const J = Oi.Factory.addGetterSetter;
  2079. J(U, "zIndex");
  2080. J(U, "absolutePosition");
  2081. J(U, "position");
  2082. J(U, "x", 0, (0, ct.getNumberValidator)());
  2083. J(U, "y", 0, (0, ct.getNumberValidator)());
  2084. J(U, "globalCompositeOperation", "source-over", (0, ct.getStringValidator)());
  2085. J(U, "opacity", 1, (0, ct.getNumberValidator)());
  2086. J(U, "name", "", (0, ct.getStringValidator)());
  2087. J(U, "id", "", (0, ct.getStringValidator)());
  2088. J(U, "rotation", 0, (0, ct.getNumberValidator)());
  2089. Oi.Factory.addComponentsGetterSetter(U, "scale", ["x", "y"]);
  2090. J(U, "scaleX", 1, (0, ct.getNumberValidator)());
  2091. J(U, "scaleY", 1, (0, ct.getNumberValidator)());
  2092. Oi.Factory.addComponentsGetterSetter(U, "skew", ["x", "y"]);
  2093. J(U, "skewX", 0, (0, ct.getNumberValidator)());
  2094. J(U, "skewY", 0, (0, ct.getNumberValidator)());
  2095. Oi.Factory.addComponentsGetterSetter(U, "offset", ["x", "y"]);
  2096. J(U, "offsetX", 0, (0, ct.getNumberValidator)());
  2097. J(U, "offsetY", 0, (0, ct.getNumberValidator)());
  2098. J(U, "dragDistance", null, (0, ct.getNumberValidator)());
  2099. J(U, "width", 0, (0, ct.getNumberValidator)());
  2100. J(U, "height", 0, (0, ct.getNumberValidator)());
  2101. J(U, "listening", !0, (0, ct.getBooleanValidator)());
  2102. J(U, "preventDefault", !0, (0, ct.getBooleanValidator)());
  2103. J(U, "filters", null, function(s) {
  2104. return this._filterUpToDate = !1, s;
  2105. });
  2106. J(U, "visible", !0, (0, ct.getBooleanValidator)());
  2107. J(U, "transformsEnabled", "all", (0, ct.getStringValidator)());
  2108. J(U, "size");
  2109. J(U, "dragBoundFunc");
  2110. J(U, "draggable", !1, (0, ct.getBooleanValidator)());
  2111. Oi.Factory.backCompat(U, {
  2112. rotateDeg: "rotate",
  2113. setRotationDeg: "setRotation",
  2114. getRotationDeg: "getRotation"
  2115. });
  2116. var bt = {};
  2117. Object.defineProperty(bt, "__esModule", { value: !0 });
  2118. bt.releaseCapture = bt.setPointerCapture = bt.hasPointerCapture = bt.createEvent = bt.getCapturedShape = void 0;
  2119. const el = $, Ei = /* @__PURE__ */ new Map(), to = el.Konva._global.PointerEvent !== void 0;
  2120. function il(s) {
  2121. return Ei.get(s);
  2122. }
  2123. bt.getCapturedShape = il;
  2124. function Ar(s) {
  2125. return {
  2126. evt: s,
  2127. pointerId: s.pointerId
  2128. };
  2129. }
  2130. bt.createEvent = Ar;
  2131. function nl(s, t) {
  2132. return Ei.get(s) === t;
  2133. }
  2134. bt.hasPointerCapture = nl;
  2135. function sl(s, t) {
  2136. eo(s), t.getStage() && (Ei.set(s, t), to && t._fire("gotpointercapture", Ar(new PointerEvent("gotpointercapture"))));
  2137. }
  2138. bt.setPointerCapture = sl;
  2139. function eo(s, t) {
  2140. const e = Ei.get(s);
  2141. if (!e)
  2142. return;
  2143. const i = e.getStage();
  2144. i && i.content, Ei.delete(s), to && e._fire("lostpointercapture", Ar(new PointerEvent("lostpointercapture")));
  2145. }
  2146. bt.releaseCapture = eo;
  2147. (function(s) {
  2148. Object.defineProperty(s, "__esModule", { value: !0 }), s.Shape = s.shapes = void 0;
  2149. const t = $, e = st, i = V, n = rt, r = O, a = $, o = bt;
  2150. var h = "hasShadow", l = "shadowRGBA", A = "patternImage", u = "linearGradient", f = "radialGradient";
  2151. let c;
  2152. function d() {
  2153. return c || (c = e.Util.createCanvasElement().getContext("2d"), c);
  2154. }
  2155. s.shapes = {};
  2156. function p(E) {
  2157. const S = this.attrs.fillRule;
  2158. S ? E.fill(S) : E.fill();
  2159. }
  2160. function m(E) {
  2161. E.stroke();
  2162. }
  2163. function v(E) {
  2164. E.fill();
  2165. }
  2166. function _(E) {
  2167. E.stroke();
  2168. }
  2169. function g() {
  2170. this._clearCache(h);
  2171. }
  2172. function y() {
  2173. this._clearCache(l);
  2174. }
  2175. function x() {
  2176. this._clearCache(A);
  2177. }
  2178. function b() {
  2179. this._clearCache(u);
  2180. }
  2181. function C() {
  2182. this._clearCache(f);
  2183. }
  2184. class w extends n.Node {
  2185. constructor(S) {
  2186. super(S);
  2187. let P;
  2188. for (; P = e.Util.getRandomColor(), !(P && !(P in s.shapes)); )
  2189. ;
  2190. this.colorKey = P, s.shapes[P] = this;
  2191. }
  2192. getContext() {
  2193. return e.Util.warn("shape.getContext() method is deprecated. Please do not use it."), this.getLayer().getContext();
  2194. }
  2195. getCanvas() {
  2196. return e.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."), this.getLayer().getCanvas();
  2197. }
  2198. getSceneFunc() {
  2199. return this.attrs.sceneFunc || this._sceneFunc;
  2200. }
  2201. getHitFunc() {
  2202. return this.attrs.hitFunc || this._hitFunc;
  2203. }
  2204. hasShadow() {
  2205. return this._getCache(h, this._hasShadow);
  2206. }
  2207. _hasShadow() {
  2208. return this.shadowEnabled() && this.shadowOpacity() !== 0 && !!(this.shadowColor() || this.shadowBlur() || this.shadowOffsetX() || this.shadowOffsetY());
  2209. }
  2210. _getFillPattern() {
  2211. return this._getCache(A, this.__getFillPattern);
  2212. }
  2213. __getFillPattern() {
  2214. if (this.fillPatternImage()) {
  2215. var S = d();
  2216. const P = S.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || "repeat");
  2217. if (P && P.setTransform) {
  2218. const k = new e.Transform();
  2219. k.translate(this.fillPatternX(), this.fillPatternY()), k.rotate(t.Konva.getAngle(this.fillPatternRotation())), k.scale(this.fillPatternScaleX(), this.fillPatternScaleY()), k.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
  2220. const F = k.getMatrix(), L = typeof DOMMatrix > "u" ? {
  2221. a: F[0],
  2222. b: F[1],
  2223. c: F[2],
  2224. d: F[3],
  2225. e: F[4],
  2226. f: F[5]
  2227. } : new DOMMatrix(F);
  2228. P.setTransform(L);
  2229. }
  2230. return P;
  2231. }
  2232. }
  2233. _getLinearGradient() {
  2234. return this._getCache(u, this.__getLinearGradient);
  2235. }
  2236. __getLinearGradient() {
  2237. var S = this.fillLinearGradientColorStops();
  2238. if (S) {
  2239. for (var P = d(), k = this.fillLinearGradientStartPoint(), F = this.fillLinearGradientEndPoint(), L = P.createLinearGradient(k.x, k.y, F.x, F.y), I = 0; I < S.length; I += 2)
  2240. L.addColorStop(S[I], S[I + 1]);
  2241. return L;
  2242. }
  2243. }
  2244. _getRadialGradient() {
  2245. return this._getCache(f, this.__getRadialGradient);
  2246. }
  2247. __getRadialGradient() {
  2248. var S = this.fillRadialGradientColorStops();
  2249. if (S) {
  2250. for (var P = d(), k = this.fillRadialGradientStartPoint(), F = this.fillRadialGradientEndPoint(), L = P.createRadialGradient(k.x, k.y, this.fillRadialGradientStartRadius(), F.x, F.y, this.fillRadialGradientEndRadius()), I = 0; I < S.length; I += 2)
  2251. L.addColorStop(S[I], S[I + 1]);
  2252. return L;
  2253. }
  2254. }
  2255. getShadowRGBA() {
  2256. return this._getCache(l, this._getShadowRGBA);
  2257. }
  2258. _getShadowRGBA() {
  2259. if (this.hasShadow()) {
  2260. var S = e.Util.colorToRGBA(this.shadowColor());
  2261. if (S)
  2262. return "rgba(" + S.r + "," + S.g + "," + S.b + "," + S.a * (this.shadowOpacity() || 1) + ")";
  2263. }
  2264. }
  2265. hasFill() {
  2266. return this._calculate("hasFill", [
  2267. "fillEnabled",
  2268. "fill",
  2269. "fillPatternImage",
  2270. "fillLinearGradientColorStops",
  2271. "fillRadialGradientColorStops"
  2272. ], () => this.fillEnabled() && !!(this.fill() || this.fillPatternImage() || this.fillLinearGradientColorStops() || this.fillRadialGradientColorStops()));
  2273. }
  2274. hasStroke() {
  2275. return this._calculate("hasStroke", [
  2276. "strokeEnabled",
  2277. "strokeWidth",
  2278. "stroke",
  2279. "strokeLinearGradientColorStops"
  2280. ], () => this.strokeEnabled() && this.strokeWidth() && !!(this.stroke() || this.strokeLinearGradientColorStops()));
  2281. }
  2282. hasHitStroke() {
  2283. const S = this.hitStrokeWidth();
  2284. return S === "auto" ? this.hasStroke() : this.strokeEnabled() && !!S;
  2285. }
  2286. intersects(S) {
  2287. var P = this.getStage();
  2288. if (!P)
  2289. return !1;
  2290. const k = P.bufferHitCanvas;
  2291. return k.getContext().clear(), this.drawHit(k, void 0, !0), k.context.getImageData(Math.round(S.x), Math.round(S.y), 1, 1).data[3] > 0;
  2292. }
  2293. destroy() {
  2294. return n.Node.prototype.destroy.call(this), delete s.shapes[this.colorKey], delete this.colorKey, this;
  2295. }
  2296. _useBufferCanvas(S) {
  2297. var P;
  2298. if (!((P = this.attrs.perfectDrawEnabled) !== null && P !== void 0 ? P : !0))
  2299. return !1;
  2300. const F = S || this.hasFill(), L = this.hasStroke(), I = this.getAbsoluteOpacity() !== 1;
  2301. if (F && L && I)
  2302. return !0;
  2303. const z = this.hasShadow(), T = this.shadowForStrokeEnabled();
  2304. return !!(F && L && z && T);
  2305. }
  2306. setStrokeHitEnabled(S) {
  2307. e.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."), S ? this.hitStrokeWidth("auto") : this.hitStrokeWidth(0);
  2308. }
  2309. getStrokeHitEnabled() {
  2310. return this.hitStrokeWidth() !== 0;
  2311. }
  2312. getSelfRect() {
  2313. var S = this.size();
  2314. return {
  2315. x: this._centroid ? -S.width / 2 : 0,
  2316. y: this._centroid ? -S.height / 2 : 0,
  2317. width: S.width,
  2318. height: S.height
  2319. };
  2320. }
  2321. getClientRect(S = {}) {
  2322. const P = S.skipTransform, k = S.relativeTo, F = this.getSelfRect(), I = !S.skipStroke && this.hasStroke() && this.strokeWidth() || 0, z = F.width + I, T = F.height + I, G = !S.skipShadow && this.hasShadow(), H = G ? this.shadowOffsetX() : 0, R = G ? this.shadowOffsetY() : 0, N = z + Math.abs(H), q = T + Math.abs(R), et = G && this.shadowBlur() || 0, tt = N + et * 2, Ut = q + et * 2, dt = {
  2323. width: tt,
  2324. height: Ut,
  2325. x: -(I / 2 + et) + Math.min(H, 0) + F.x,
  2326. y: -(I / 2 + et) + Math.min(R, 0) + F.y
  2327. };
  2328. return P ? dt : this._transformedRect(dt, k);
  2329. }
  2330. drawScene(S, P, k) {
  2331. var F = this.getLayer(), L = S || F.getCanvas(), I = L.getContext(), z = this._getCanvasCache(), T = this.getSceneFunc(), G = this.hasShadow(), H, R, N = L.isCache, q = P === this;
  2332. if (!this.isVisible() && !q)
  2333. return this;
  2334. if (z) {
  2335. I.save();
  2336. var et = this.getAbsoluteTransform(P).getMatrix();
  2337. return I.transform(et[0], et[1], et[2], et[3], et[4], et[5]), this._drawCachedSceneCanvas(I), I.restore(), this;
  2338. }
  2339. if (!T)
  2340. return this;
  2341. if (I.save(), this._useBufferCanvas() && !N) {
  2342. H = this.getStage();
  2343. const dt = k || H.bufferCanvas;
  2344. R = dt.getContext(), R.clear(), R.save(), R._applyLineJoin(this);
  2345. var tt = this.getAbsoluteTransform(P).getMatrix();
  2346. R.transform(tt[0], tt[1], tt[2], tt[3], tt[4], tt[5]), T.call(this, R, this), R.restore();
  2347. var Ut = dt.pixelRatio;
  2348. G && I._applyShadow(this), I._applyOpacity(this), I._applyGlobalCompositeOperation(this), I.drawImage(dt._canvas, 0, 0, dt.width / Ut, dt.height / Ut);
  2349. } else {
  2350. if (I._applyLineJoin(this), !q) {
  2351. var tt = this.getAbsoluteTransform(P).getMatrix();
  2352. I.transform(tt[0], tt[1], tt[2], tt[3], tt[4], tt[5]), I._applyOpacity(this), I._applyGlobalCompositeOperation(this);
  2353. }
  2354. G && I._applyShadow(this), T.call(this, I, this);
  2355. }
  2356. return I.restore(), this;
  2357. }
  2358. drawHit(S, P, k = !1) {
  2359. if (!this.shouldDrawHit(P, k))
  2360. return this;
  2361. var F = this.getLayer(), L = S || F.hitCanvas, I = L && L.getContext(), z = this.hitFunc() || this.sceneFunc(), T = this._getCanvasCache(), G = T && T.hit;
  2362. if (this.colorKey || e.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"), G) {
  2363. I.save();
  2364. var H = this.getAbsoluteTransform(P).getMatrix();
  2365. return I.transform(H[0], H[1], H[2], H[3], H[4], H[5]), this._drawCachedHitCanvas(I), I.restore(), this;
  2366. }
  2367. if (!z)
  2368. return this;
  2369. if (I.save(), I._applyLineJoin(this), !(this === P)) {
  2370. var N = this.getAbsoluteTransform(P).getMatrix();
  2371. I.transform(N[0], N[1], N[2], N[3], N[4], N[5]);
  2372. }
  2373. return z.call(this, I, this), I.restore(), this;
  2374. }
  2375. drawHitFromCache(S = 0) {
  2376. var P = this._getCanvasCache(), k = this._getCachedSceneCanvas(), F = P.hit, L = F.getContext(), I = F.getWidth(), z = F.getHeight(), T, G, H, R, N, q;
  2377. L.clear(), L.drawImage(k._canvas, 0, 0, I, z);
  2378. try {
  2379. for (T = L.getImageData(0, 0, I, z), G = T.data, H = G.length, R = e.Util._hexToRgb(this.colorKey), N = 0; N < H; N += 4)
  2380. q = G[N + 3], q > S ? (G[N] = R.r, G[N + 1] = R.g, G[N + 2] = R.b, G[N + 3] = 255) : G[N + 3] = 0;
  2381. L.putImageData(T, 0, 0);
  2382. } catch (et) {
  2383. e.Util.error("Unable to draw hit graph from cached scene canvas. " + et.message);
  2384. }
  2385. return this;
  2386. }
  2387. hasPointerCapture(S) {
  2388. return o.hasPointerCapture(S, this);
  2389. }
  2390. setPointerCapture(S) {
  2391. o.setPointerCapture(S, this);
  2392. }
  2393. releaseCapture(S) {
  2394. o.releaseCapture(S, this);
  2395. }
  2396. }
  2397. s.Shape = w, w.prototype._fillFunc = p, w.prototype._strokeFunc = m, w.prototype._fillFuncHit = v, w.prototype._strokeFuncHit = _, w.prototype._centroid = !1, w.prototype.nodeType = "Shape", (0, a._registerNode)(w), w.prototype.eventListeners = {}, w.prototype.on.call(w.prototype, "shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva", g), w.prototype.on.call(w.prototype, "shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva", y), w.prototype.on.call(w.prototype, "fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva", x), w.prototype.on.call(w.prototype, "fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva", b), w.prototype.on.call(w.prototype, "fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva", C), i.Factory.addGetterSetter(w, "stroke", void 0, (0, r.getStringOrGradientValidator)()), i.Factory.addGetterSetter(w, "strokeWidth", 2, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillAfterStrokeEnabled", !1), i.Factory.addGetterSetter(w, "hitStrokeWidth", "auto", (0, r.getNumberOrAutoValidator)()), i.Factory.addGetterSetter(w, "strokeHitEnabled", !0, (0, r.getBooleanValidator)()), i.Factory.addGetterSetter(w, "perfectDrawEnabled", !0, (0, r.getBooleanValidator)()), i.Factory.addGetterSetter(w, "shadowForStrokeEnabled", !0, (0, r.getBooleanValidator)()), i.Factory.addGetterSetter(w, "lineJoin"), i.Factory.addGetterSetter(w, "lineCap"), i.Factory.addGetterSetter(w, "sceneFunc"), i.Factory.addGetterSetter(w, "hitFunc"), i.Factory.addGetterSetter(w, "dash"), i.Factory.addGetterSetter(w, "dashOffset", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "shadowColor", void 0, (0, r.getStringValidator)()), i.Factory.addGetterSetter(w, "shadowBlur", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "shadowOpacity", 1, (0, r.getNumberValidator)()), i.Factory.addComponentsGetterSetter(w, "shadowOffset", ["x", "y"]), i.Factory.addGetterSetter(w, "shadowOffsetX", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "shadowOffsetY", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternImage"), i.Factory.addGetterSetter(w, "fill", void 0, (0, r.getStringOrGradientValidator)()), i.Factory.addGetterSetter(w, "fillPatternX", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternY", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillLinearGradientColorStops"), i.Factory.addGetterSetter(w, "strokeLinearGradientColorStops"), i.Factory.addGetterSetter(w, "fillRadialGradientStartRadius", 0), i.Factory.addGetterSetter(w, "fillRadialGradientEndRadius", 0), i.Factory.addGetterSetter(w, "fillRadialGradientColorStops"), i.Factory.addGetterSetter(w, "fillPatternRepeat", "repeat"), i.Factory.addGetterSetter(w, "fillEnabled", !0), i.Factory.addGetterSetter(w, "strokeEnabled", !0), i.Factory.addGetterSetter(w, "shadowEnabled", !0), i.Factory.addGetterSetter(w, "dashEnabled", !0), i.Factory.addGetterSetter(w, "strokeScaleEnabled", !0), i.Factory.addGetterSetter(w, "fillPriority", "color"), i.Factory.addComponentsGetterSetter(w, "fillPatternOffset", ["x", "y"]), i.Factory.addGetterSetter(w, "fillPatternOffsetX", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternOffsetY", 0, (0, r.getNumberValidator)()), i.Factory.addComponentsGetterSetter(w, "fillPatternScale", ["x", "y"]), i.Factory.addGetterSetter(w, "fillPatternScaleX", 1, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternScaleY", 1, (0, r.getNumberValidator)()), i.Factory.addComponentsGetterSetter(w, "fillLinearGradientStartPoint", [
  2398. "x",
  2399. "y"
  2400. ]), i.Factory.addComponentsGetterSetter(w, "strokeLinearGradientStartPoint", [
  2401. "x",
  2402. "y"
  2403. ]), i.Factory.addGetterSetter(w, "fillLinearGradientStartPointX", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientStartPointX", 0), i.Factory.addGetterSetter(w, "fillLinearGradientStartPointY", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientStartPointY", 0), i.Factory.addComponentsGetterSetter(w, "fillLinearGradientEndPoint", [
  2404. "x",
  2405. "y"
  2406. ]), i.Factory.addComponentsGetterSetter(w, "strokeLinearGradientEndPoint", [
  2407. "x",
  2408. "y"
  2409. ]), i.Factory.addGetterSetter(w, "fillLinearGradientEndPointX", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientEndPointX", 0), i.Factory.addGetterSetter(w, "fillLinearGradientEndPointY", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientEndPointY", 0), i.Factory.addComponentsGetterSetter(w, "fillRadialGradientStartPoint", [
  2410. "x",
  2411. "y"
  2412. ]), i.Factory.addGetterSetter(w, "fillRadialGradientStartPointX", 0), i.Factory.addGetterSetter(w, "fillRadialGradientStartPointY", 0), i.Factory.addComponentsGetterSetter(w, "fillRadialGradientEndPoint", [
  2413. "x",
  2414. "y"
  2415. ]), i.Factory.addGetterSetter(w, "fillRadialGradientEndPointX", 0), i.Factory.addGetterSetter(w, "fillRadialGradientEndPointY", 0), i.Factory.addGetterSetter(w, "fillPatternRotation", 0), i.Factory.addGetterSetter(w, "fillRule", void 0, (0, r.getStringValidator)()), i.Factory.backCompat(w, {
  2416. dashArray: "dash",
  2417. getDashArray: "getDash",
  2418. setDashArray: "getDash",
  2419. drawFunc: "sceneFunc",
  2420. getDrawFunc: "getSceneFunc",
  2421. setDrawFunc: "setSceneFunc",
  2422. drawHitFunc: "hitFunc",
  2423. getDrawHitFunc: "getHitFunc",
  2424. setDrawHitFunc: "setHitFunc"
  2425. });
  2426. })(ft);
  2427. Object.defineProperty(Cn, "__esModule", { value: !0 });
  2428. var Ni = Cn.Circle = void 0;
  2429. const rl = V, al = ft, ol = O, hl = $;
  2430. class oi extends al.Shape {
  2431. _sceneFunc(t) {
  2432. t.beginPath(), t.arc(0, 0, this.attrs.radius || 0, 0, Math.PI * 2, !1), t.closePath(), t.fillStrokeShape(this);
  2433. }
  2434. getWidth() {
  2435. return this.radius() * 2;
  2436. }
  2437. getHeight() {
  2438. return this.radius() * 2;
  2439. }
  2440. setWidth(t) {
  2441. this.radius() !== t / 2 && this.radius(t / 2);
  2442. }
  2443. setHeight(t) {
  2444. this.radius() !== t / 2 && this.radius(t / 2);
  2445. }
  2446. }
  2447. Ni = Cn.Circle = oi;
  2448. oi.prototype._centroid = !0;
  2449. oi.prototype.className = "Circle";
  2450. oi.prototype._attrsAffectingSize = ["radius"];
  2451. (0, hl._registerNode)(oi);
  2452. rl.Factory.addGetterSetter(oi, "radius", 0, (0, ol.getNumberValidator)());
  2453. var Gi = {};
  2454. Object.defineProperty(Gi, "__esModule", { value: !0 });
  2455. var Fn = Gi.Line = void 0;
  2456. const kn = V, ll = ft, io = O, Al = $;
  2457. function qs(s, t, e, i, n, r, a) {
  2458. var o = Math.sqrt(Math.pow(e - s, 2) + Math.pow(i - t, 2)), h = Math.sqrt(Math.pow(n - e, 2) + Math.pow(r - i, 2)), l = a * o / (o + h), A = a * h / (o + h), u = e - l * (n - s), f = i - l * (r - t), c = e + A * (n - s), d = i + A * (r - t);
  2459. return [u, f, c, d];
  2460. }
  2461. function Wr(s, t) {
  2462. var e = s.length, i = [], n, r;
  2463. for (n = 2; n < e - 2; n += 2)
  2464. r = qs(s[n - 2], s[n - 1], s[n], s[n + 1], s[n + 2], s[n + 3], t), !isNaN(r[0]) && (i.push(r[0]), i.push(r[1]), i.push(s[n]), i.push(s[n + 1]), i.push(r[2]), i.push(r[3]));
  2465. return i;
  2466. }
  2467. class ge extends ll.Shape {
  2468. constructor(t) {
  2469. super(t), this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva", function() {
  2470. this._clearCache("tensionPoints");
  2471. });
  2472. }
  2473. _sceneFunc(t) {
  2474. var e = this.points(), i = e.length, n = this.tension(), r = this.closed(), a = this.bezier(), o, h, l;
  2475. if (i) {
  2476. if (t.beginPath(), t.moveTo(e[0], e[1]), n !== 0 && i > 4) {
  2477. for (o = this.getTensionPoints(), h = o.length, l = r ? 0 : 4, r || t.quadraticCurveTo(o[0], o[1], o[2], o[3]); l < h - 2; )
  2478. t.bezierCurveTo(o[l++], o[l++], o[l++], o[l++], o[l++], o[l++]);
  2479. r || t.quadraticCurveTo(o[h - 2], o[h - 1], e[i - 2], e[i - 1]);
  2480. } else if (a)
  2481. for (l = 2; l < i; )
  2482. t.bezierCurveTo(e[l++], e[l++], e[l++], e[l++], e[l++], e[l++]);
  2483. else
  2484. for (l = 2; l < i; l += 2)
  2485. t.lineTo(e[l], e[l + 1]);
  2486. r ? (t.closePath(), t.fillStrokeShape(this)) : t.strokeShape(this);
  2487. }
  2488. }
  2489. getTensionPoints() {
  2490. return this._getCache("tensionPoints", this._getTensionPoints);
  2491. }
  2492. _getTensionPoints() {
  2493. return this.closed() ? this._getTensionPointsClosed() : Wr(this.points(), this.tension());
  2494. }
  2495. _getTensionPointsClosed() {
  2496. var t = this.points(), e = t.length, i = this.tension(), n = qs(t[e - 2], t[e - 1], t[0], t[1], t[2], t[3], i), r = qs(t[e - 4], t[e - 3], t[e - 2], t[e - 1], t[0], t[1], i), a = Wr(t, i), o = [n[2], n[3]].concat(a).concat([
  2497. r[0],
  2498. r[1],
  2499. t[e - 2],
  2500. t[e - 1],
  2501. r[2],
  2502. r[3],
  2503. n[0],
  2504. n[1],
  2505. t[0],
  2506. t[1]
  2507. ]);
  2508. return o;
  2509. }
  2510. getWidth() {
  2511. return this.getSelfRect().width;
  2512. }
  2513. getHeight() {
  2514. return this.getSelfRect().height;
  2515. }
  2516. getSelfRect() {
  2517. var t = this.points();
  2518. if (t.length < 4)
  2519. return {
  2520. x: t[0] || 0,
  2521. y: t[1] || 0,
  2522. width: 0,
  2523. height: 0
  2524. };
  2525. this.tension() !== 0 ? t = [
  2526. t[0],
  2527. t[1],
  2528. ...this._getTensionPoints(),
  2529. t[t.length - 2],
  2530. t[t.length - 1]
  2531. ] : t = this.points();
  2532. for (var e = t[0], i = t[0], n = t[1], r = t[1], a, o, h = 0; h < t.length / 2; h++)
  2533. a = t[h * 2], o = t[h * 2 + 1], e = Math.min(e, a), i = Math.max(i, a), n = Math.min(n, o), r = Math.max(r, o);
  2534. return {
  2535. x: e,
  2536. y: n,
  2537. width: i - e,
  2538. height: r - n
  2539. };
  2540. }
  2541. }
  2542. Fn = Gi.Line = ge;
  2543. ge.prototype.className = "Line";
  2544. ge.prototype._attrsAffectingSize = ["points", "bezier", "tension"];
  2545. (0, Al._registerNode)(ge);
  2546. kn.Factory.addGetterSetter(ge, "closed", !1);
  2547. kn.Factory.addGetterSetter(ge, "bezier", !1);
  2548. kn.Factory.addGetterSetter(ge, "tension", 0, (0, io.getNumberValidator)());
  2549. kn.Factory.addGetterSetter(ge, "points", [], (0, io.getNumberArrayValidator)());
  2550. let qt = !1;
  2551. const qe = navigator.userAgent, Xu = (s) => qt = s, no = /iPhone|iPad|iPod|Android/i.test(qe);
  2552. let cl = /(?:Android)/.test(qe), dl = /(?:Firefox)/.test(qe);
  2553. const ul = /(?:iPad|PlayBook|Tablet)/.test(qe) || cl && !/(?:Mobile)/.test(qe) || dl && /(?:Tablet)/.test(qe) || no && (window.innerWidth < window.innerHeight ? window.innerWidth : window.innerHeight) > 600, hn = no || ul;
  2554. var hi = {}, so = {};
  2555. (function(s) {
  2556. Object.defineProperty(s, "__esModule", { value: !0 }), s.t2length = s.getQuadraticArcLength = s.getCubicArcLength = s.binomialCoefficients = s.cValues = s.tValues = void 0, s.tValues = [
  2557. [],
  2558. [],
  2559. [
  2560. -0.5773502691896257,
  2561. 0.5773502691896257
  2562. ],
  2563. [
  2564. 0,
  2565. -0.7745966692414834,
  2566. 0.7745966692414834
  2567. ],
  2568. [
  2569. -0.33998104358485626,
  2570. 0.33998104358485626,
  2571. -0.8611363115940526,
  2572. 0.8611363115940526
  2573. ],
  2574. [
  2575. 0,
  2576. -0.5384693101056831,
  2577. 0.5384693101056831,
  2578. -0.906179845938664,
  2579. 0.906179845938664
  2580. ],
  2581. [
  2582. 0.6612093864662645,
  2583. -0.6612093864662645,
  2584. -0.2386191860831969,
  2585. 0.2386191860831969,
  2586. -0.932469514203152,
  2587. 0.932469514203152
  2588. ],
  2589. [
  2590. 0,
  2591. 0.4058451513773972,
  2592. -0.4058451513773972,
  2593. -0.7415311855993945,
  2594. 0.7415311855993945,
  2595. -0.9491079123427585,
  2596. 0.9491079123427585
  2597. ],
  2598. [
  2599. -0.1834346424956498,
  2600. 0.1834346424956498,
  2601. -0.525532409916329,
  2602. 0.525532409916329,
  2603. -0.7966664774136267,
  2604. 0.7966664774136267,
  2605. -0.9602898564975363,
  2606. 0.9602898564975363
  2607. ],
  2608. [
  2609. 0,
  2610. -0.8360311073266358,
  2611. 0.8360311073266358,
  2612. -0.9681602395076261,
  2613. 0.9681602395076261,
  2614. -0.3242534234038089,
  2615. 0.3242534234038089,
  2616. -0.6133714327005904,
  2617. 0.6133714327005904
  2618. ],
  2619. [
  2620. -0.14887433898163122,
  2621. 0.14887433898163122,
  2622. -0.4333953941292472,
  2623. 0.4333953941292472,
  2624. -0.6794095682990244,
  2625. 0.6794095682990244,
  2626. -0.8650633666889845,
  2627. 0.8650633666889845,
  2628. -0.9739065285171717,
  2629. 0.9739065285171717
  2630. ],
  2631. [
  2632. 0,
  2633. -0.26954315595234496,
  2634. 0.26954315595234496,
  2635. -0.5190961292068118,
  2636. 0.5190961292068118,
  2637. -0.7301520055740494,
  2638. 0.7301520055740494,
  2639. -0.8870625997680953,
  2640. 0.8870625997680953,
  2641. -0.978228658146057,
  2642. 0.978228658146057
  2643. ],
  2644. [
  2645. -0.1252334085114689,
  2646. 0.1252334085114689,
  2647. -0.3678314989981802,
  2648. 0.3678314989981802,
  2649. -0.5873179542866175,
  2650. 0.5873179542866175,
  2651. -0.7699026741943047,
  2652. 0.7699026741943047,
  2653. -0.9041172563704749,
  2654. 0.9041172563704749,
  2655. -0.9815606342467192,
  2656. 0.9815606342467192
  2657. ],
  2658. [
  2659. 0,
  2660. -0.2304583159551348,
  2661. 0.2304583159551348,
  2662. -0.44849275103644687,
  2663. 0.44849275103644687,
  2664. -0.6423493394403402,
  2665. 0.6423493394403402,
  2666. -0.8015780907333099,
  2667. 0.8015780907333099,
  2668. -0.9175983992229779,
  2669. 0.9175983992229779,
  2670. -0.9841830547185881,
  2671. 0.9841830547185881
  2672. ],
  2673. [
  2674. -0.10805494870734367,
  2675. 0.10805494870734367,
  2676. -0.31911236892788974,
  2677. 0.31911236892788974,
  2678. -0.5152486363581541,
  2679. 0.5152486363581541,
  2680. -0.6872929048116855,
  2681. 0.6872929048116855,
  2682. -0.827201315069765,
  2683. 0.827201315069765,
  2684. -0.9284348836635735,
  2685. 0.9284348836635735,
  2686. -0.9862838086968123,
  2687. 0.9862838086968123
  2688. ],
  2689. [
  2690. 0,
  2691. -0.20119409399743451,
  2692. 0.20119409399743451,
  2693. -0.3941513470775634,
  2694. 0.3941513470775634,
  2695. -0.5709721726085388,
  2696. 0.5709721726085388,
  2697. -0.7244177313601701,
  2698. 0.7244177313601701,
  2699. -0.8482065834104272,
  2700. 0.8482065834104272,
  2701. -0.937273392400706,
  2702. 0.937273392400706,
  2703. -0.9879925180204854,
  2704. 0.9879925180204854
  2705. ],
  2706. [
  2707. -0.09501250983763744,
  2708. 0.09501250983763744,
  2709. -0.2816035507792589,
  2710. 0.2816035507792589,
  2711. -0.45801677765722737,
  2712. 0.45801677765722737,
  2713. -0.6178762444026438,
  2714. 0.6178762444026438,
  2715. -0.755404408355003,
  2716. 0.755404408355003,
  2717. -0.8656312023878318,
  2718. 0.8656312023878318,
  2719. -0.9445750230732326,
  2720. 0.9445750230732326,
  2721. -0.9894009349916499,
  2722. 0.9894009349916499
  2723. ],
  2724. [
  2725. 0,
  2726. -0.17848418149584785,
  2727. 0.17848418149584785,
  2728. -0.3512317634538763,
  2729. 0.3512317634538763,
  2730. -0.5126905370864769,
  2731. 0.5126905370864769,
  2732. -0.6576711592166907,
  2733. 0.6576711592166907,
  2734. -0.7815140038968014,
  2735. 0.7815140038968014,
  2736. -0.8802391537269859,
  2737. 0.8802391537269859,
  2738. -0.9506755217687678,
  2739. 0.9506755217687678,
  2740. -0.9905754753144174,
  2741. 0.9905754753144174
  2742. ],
  2743. [
  2744. -0.0847750130417353,
  2745. 0.0847750130417353,
  2746. -0.2518862256915055,
  2747. 0.2518862256915055,
  2748. -0.41175116146284263,
  2749. 0.41175116146284263,
  2750. -0.5597708310739475,
  2751. 0.5597708310739475,
  2752. -0.6916870430603532,
  2753. 0.6916870430603532,
  2754. -0.8037049589725231,
  2755. 0.8037049589725231,
  2756. -0.8926024664975557,
  2757. 0.8926024664975557,
  2758. -0.9558239495713977,
  2759. 0.9558239495713977,
  2760. -0.9915651684209309,
  2761. 0.9915651684209309
  2762. ],
  2763. [
  2764. 0,
  2765. -0.16035864564022537,
  2766. 0.16035864564022537,
  2767. -0.31656409996362983,
  2768. 0.31656409996362983,
  2769. -0.46457074137596094,
  2770. 0.46457074137596094,
  2771. -0.600545304661681,
  2772. 0.600545304661681,
  2773. -0.7209661773352294,
  2774. 0.7209661773352294,
  2775. -0.8227146565371428,
  2776. 0.8227146565371428,
  2777. -0.9031559036148179,
  2778. 0.9031559036148179,
  2779. -0.96020815213483,
  2780. 0.96020815213483,
  2781. -0.9924068438435844,
  2782. 0.9924068438435844
  2783. ],
  2784. [
  2785. -0.07652652113349734,
  2786. 0.07652652113349734,
  2787. -0.22778585114164507,
  2788. 0.22778585114164507,
  2789. -0.37370608871541955,
  2790. 0.37370608871541955,
  2791. -0.5108670019508271,
  2792. 0.5108670019508271,
  2793. -0.636053680726515,
  2794. 0.636053680726515,
  2795. -0.7463319064601508,
  2796. 0.7463319064601508,
  2797. -0.8391169718222188,
  2798. 0.8391169718222188,
  2799. -0.912234428251326,
  2800. 0.912234428251326,
  2801. -0.9639719272779138,
  2802. 0.9639719272779138,
  2803. -0.9931285991850949,
  2804. 0.9931285991850949
  2805. ],
  2806. [
  2807. 0,
  2808. -0.1455618541608951,
  2809. 0.1455618541608951,
  2810. -0.2880213168024011,
  2811. 0.2880213168024011,
  2812. -0.4243421202074388,
  2813. 0.4243421202074388,
  2814. -0.5516188358872198,
  2815. 0.5516188358872198,
  2816. -0.6671388041974123,
  2817. 0.6671388041974123,
  2818. -0.7684399634756779,
  2819. 0.7684399634756779,
  2820. -0.8533633645833173,
  2821. 0.8533633645833173,
  2822. -0.9200993341504008,
  2823. 0.9200993341504008,
  2824. -0.9672268385663063,
  2825. 0.9672268385663063,
  2826. -0.9937521706203895,
  2827. 0.9937521706203895
  2828. ],
  2829. [
  2830. -0.06973927331972223,
  2831. 0.06973927331972223,
  2832. -0.20786042668822127,
  2833. 0.20786042668822127,
  2834. -0.34193582089208424,
  2835. 0.34193582089208424,
  2836. -0.469355837986757,
  2837. 0.469355837986757,
  2838. -0.5876404035069116,
  2839. 0.5876404035069116,
  2840. -0.6944872631866827,
  2841. 0.6944872631866827,
  2842. -0.7878168059792081,
  2843. 0.7878168059792081,
  2844. -0.8658125777203002,
  2845. 0.8658125777203002,
  2846. -0.926956772187174,
  2847. 0.926956772187174,
  2848. -0.9700604978354287,
  2849. 0.9700604978354287,
  2850. -0.9942945854823992,
  2851. 0.9942945854823992
  2852. ],
  2853. [
  2854. 0,
  2855. -0.1332568242984661,
  2856. 0.1332568242984661,
  2857. -0.26413568097034495,
  2858. 0.26413568097034495,
  2859. -0.3903010380302908,
  2860. 0.3903010380302908,
  2861. -0.5095014778460075,
  2862. 0.5095014778460075,
  2863. -0.6196098757636461,
  2864. 0.6196098757636461,
  2865. -0.7186613631319502,
  2866. 0.7186613631319502,
  2867. -0.8048884016188399,
  2868. 0.8048884016188399,
  2869. -0.8767523582704416,
  2870. 0.8767523582704416,
  2871. -0.9329710868260161,
  2872. 0.9329710868260161,
  2873. -0.9725424712181152,
  2874. 0.9725424712181152,
  2875. -0.9947693349975522,
  2876. 0.9947693349975522
  2877. ],
  2878. [
  2879. -0.06405689286260563,
  2880. 0.06405689286260563,
  2881. -0.1911188674736163,
  2882. 0.1911188674736163,
  2883. -0.3150426796961634,
  2884. 0.3150426796961634,
  2885. -0.4337935076260451,
  2886. 0.4337935076260451,
  2887. -0.5454214713888396,
  2888. 0.5454214713888396,
  2889. -0.6480936519369755,
  2890. 0.6480936519369755,
  2891. -0.7401241915785544,
  2892. 0.7401241915785544,
  2893. -0.820001985973903,
  2894. 0.820001985973903,
  2895. -0.8864155270044011,
  2896. 0.8864155270044011,
  2897. -0.9382745520027328,
  2898. 0.9382745520027328,
  2899. -0.9747285559713095,
  2900. 0.9747285559713095,
  2901. -0.9951872199970213,
  2902. 0.9951872199970213
  2903. ]
  2904. ], s.cValues = [
  2905. [],
  2906. [],
  2907. [1, 1],
  2908. [
  2909. 0.8888888888888888,
  2910. 0.5555555555555556,
  2911. 0.5555555555555556
  2912. ],
  2913. [
  2914. 0.6521451548625461,
  2915. 0.6521451548625461,
  2916. 0.34785484513745385,
  2917. 0.34785484513745385
  2918. ],
  2919. [
  2920. 0.5688888888888889,
  2921. 0.47862867049936647,
  2922. 0.47862867049936647,
  2923. 0.23692688505618908,
  2924. 0.23692688505618908
  2925. ],
  2926. [
  2927. 0.3607615730481386,
  2928. 0.3607615730481386,
  2929. 0.46791393457269104,
  2930. 0.46791393457269104,
  2931. 0.17132449237917036,
  2932. 0.17132449237917036
  2933. ],
  2934. [
  2935. 0.4179591836734694,
  2936. 0.3818300505051189,
  2937. 0.3818300505051189,
  2938. 0.27970539148927664,
  2939. 0.27970539148927664,
  2940. 0.1294849661688697,
  2941. 0.1294849661688697
  2942. ],
  2943. [
  2944. 0.362683783378362,
  2945. 0.362683783378362,
  2946. 0.31370664587788727,
  2947. 0.31370664587788727,
  2948. 0.22238103445337448,
  2949. 0.22238103445337448,
  2950. 0.10122853629037626,
  2951. 0.10122853629037626
  2952. ],
  2953. [
  2954. 0.3302393550012598,
  2955. 0.1806481606948574,
  2956. 0.1806481606948574,
  2957. 0.08127438836157441,
  2958. 0.08127438836157441,
  2959. 0.31234707704000286,
  2960. 0.31234707704000286,
  2961. 0.26061069640293544,
  2962. 0.26061069640293544
  2963. ],
  2964. [
  2965. 0.29552422471475287,
  2966. 0.29552422471475287,
  2967. 0.26926671930999635,
  2968. 0.26926671930999635,
  2969. 0.21908636251598204,
  2970. 0.21908636251598204,
  2971. 0.1494513491505806,
  2972. 0.1494513491505806,
  2973. 0.06667134430868814,
  2974. 0.06667134430868814
  2975. ],
  2976. [
  2977. 0.2729250867779006,
  2978. 0.26280454451024665,
  2979. 0.26280454451024665,
  2980. 0.23319376459199048,
  2981. 0.23319376459199048,
  2982. 0.18629021092773426,
  2983. 0.18629021092773426,
  2984. 0.1255803694649046,
  2985. 0.1255803694649046,
  2986. 0.05566856711617366,
  2987. 0.05566856711617366
  2988. ],
  2989. [
  2990. 0.24914704581340277,
  2991. 0.24914704581340277,
  2992. 0.2334925365383548,
  2993. 0.2334925365383548,
  2994. 0.20316742672306592,
  2995. 0.20316742672306592,
  2996. 0.16007832854334622,
  2997. 0.16007832854334622,
  2998. 0.10693932599531843,
  2999. 0.10693932599531843,
  3000. 0.04717533638651183,
  3001. 0.04717533638651183
  3002. ],
  3003. [
  3004. 0.2325515532308739,
  3005. 0.22628318026289723,
  3006. 0.22628318026289723,
  3007. 0.2078160475368885,
  3008. 0.2078160475368885,
  3009. 0.17814598076194574,
  3010. 0.17814598076194574,
  3011. 0.13887351021978725,
  3012. 0.13887351021978725,
  3013. 0.09212149983772845,
  3014. 0.09212149983772845,
  3015. 0.04048400476531588,
  3016. 0.04048400476531588
  3017. ],
  3018. [
  3019. 0.2152638534631578,
  3020. 0.2152638534631578,
  3021. 0.2051984637212956,
  3022. 0.2051984637212956,
  3023. 0.18553839747793782,
  3024. 0.18553839747793782,
  3025. 0.15720316715819355,
  3026. 0.15720316715819355,
  3027. 0.12151857068790319,
  3028. 0.12151857068790319,
  3029. 0.08015808715976021,
  3030. 0.08015808715976021,
  3031. 0.03511946033175186,
  3032. 0.03511946033175186
  3033. ],
  3034. [
  3035. 0.2025782419255613,
  3036. 0.19843148532711158,
  3037. 0.19843148532711158,
  3038. 0.1861610000155622,
  3039. 0.1861610000155622,
  3040. 0.16626920581699392,
  3041. 0.16626920581699392,
  3042. 0.13957067792615432,
  3043. 0.13957067792615432,
  3044. 0.10715922046717194,
  3045. 0.10715922046717194,
  3046. 0.07036604748810812,
  3047. 0.07036604748810812,
  3048. 0.03075324199611727,
  3049. 0.03075324199611727
  3050. ],
  3051. [
  3052. 0.1894506104550685,
  3053. 0.1894506104550685,
  3054. 0.18260341504492358,
  3055. 0.18260341504492358,
  3056. 0.16915651939500254,
  3057. 0.16915651939500254,
  3058. 0.14959598881657674,
  3059. 0.14959598881657674,
  3060. 0.12462897125553388,
  3061. 0.12462897125553388,
  3062. 0.09515851168249279,
  3063. 0.09515851168249279,
  3064. 0.062253523938647894,
  3065. 0.062253523938647894,
  3066. 0.027152459411754096,
  3067. 0.027152459411754096
  3068. ],
  3069. [
  3070. 0.17944647035620653,
  3071. 0.17656270536699264,
  3072. 0.17656270536699264,
  3073. 0.16800410215645004,
  3074. 0.16800410215645004,
  3075. 0.15404576107681028,
  3076. 0.15404576107681028,
  3077. 0.13513636846852548,
  3078. 0.13513636846852548,
  3079. 0.11188384719340397,
  3080. 0.11188384719340397,
  3081. 0.08503614831717918,
  3082. 0.08503614831717918,
  3083. 0.0554595293739872,
  3084. 0.0554595293739872,
  3085. 0.02414830286854793,
  3086. 0.02414830286854793
  3087. ],
  3088. [
  3089. 0.1691423829631436,
  3090. 0.1691423829631436,
  3091. 0.16427648374583273,
  3092. 0.16427648374583273,
  3093. 0.15468467512626524,
  3094. 0.15468467512626524,
  3095. 0.14064291467065065,
  3096. 0.14064291467065065,
  3097. 0.12255520671147846,
  3098. 0.12255520671147846,
  3099. 0.10094204410628717,
  3100. 0.10094204410628717,
  3101. 0.07642573025488905,
  3102. 0.07642573025488905,
  3103. 0.0497145488949698,
  3104. 0.0497145488949698,
  3105. 0.02161601352648331,
  3106. 0.02161601352648331
  3107. ],
  3108. [
  3109. 0.1610544498487837,
  3110. 0.15896884339395434,
  3111. 0.15896884339395434,
  3112. 0.15276604206585967,
  3113. 0.15276604206585967,
  3114. 0.1426067021736066,
  3115. 0.1426067021736066,
  3116. 0.12875396253933621,
  3117. 0.12875396253933621,
  3118. 0.11156664554733399,
  3119. 0.11156664554733399,
  3120. 0.09149002162245,
  3121. 0.09149002162245,
  3122. 0.06904454273764123,
  3123. 0.06904454273764123,
  3124. 0.0448142267656996,
  3125. 0.0448142267656996,
  3126. 0.019461788229726478,
  3127. 0.019461788229726478
  3128. ],
  3129. [
  3130. 0.15275338713072584,
  3131. 0.15275338713072584,
  3132. 0.14917298647260374,
  3133. 0.14917298647260374,
  3134. 0.14209610931838204,
  3135. 0.14209610931838204,
  3136. 0.13168863844917664,
  3137. 0.13168863844917664,
  3138. 0.11819453196151841,
  3139. 0.11819453196151841,
  3140. 0.10193011981724044,
  3141. 0.10193011981724044,
  3142. 0.08327674157670475,
  3143. 0.08327674157670475,
  3144. 0.06267204833410907,
  3145. 0.06267204833410907,
  3146. 0.04060142980038694,
  3147. 0.04060142980038694,
  3148. 0.017614007139152118,
  3149. 0.017614007139152118
  3150. ],
  3151. [
  3152. 0.14608113364969041,
  3153. 0.14452440398997005,
  3154. 0.14452440398997005,
  3155. 0.13988739479107315,
  3156. 0.13988739479107315,
  3157. 0.13226893863333747,
  3158. 0.13226893863333747,
  3159. 0.12183141605372853,
  3160. 0.12183141605372853,
  3161. 0.10879729916714838,
  3162. 0.10879729916714838,
  3163. 0.09344442345603386,
  3164. 0.09344442345603386,
  3165. 0.0761001136283793,
  3166. 0.0761001136283793,
  3167. 0.057134425426857205,
  3168. 0.057134425426857205,
  3169. 0.036953789770852494,
  3170. 0.036953789770852494,
  3171. 0.016017228257774335,
  3172. 0.016017228257774335
  3173. ],
  3174. [
  3175. 0.13925187285563198,
  3176. 0.13925187285563198,
  3177. 0.13654149834601517,
  3178. 0.13654149834601517,
  3179. 0.13117350478706238,
  3180. 0.13117350478706238,
  3181. 0.12325237681051242,
  3182. 0.12325237681051242,
  3183. 0.11293229608053922,
  3184. 0.11293229608053922,
  3185. 0.10041414444288096,
  3186. 0.10041414444288096,
  3187. 0.08594160621706773,
  3188. 0.08594160621706773,
  3189. 0.06979646842452049,
  3190. 0.06979646842452049,
  3191. 0.052293335152683286,
  3192. 0.052293335152683286,
  3193. 0.03377490158481415,
  3194. 0.03377490158481415,
  3195. 0.0146279952982722,
  3196. 0.0146279952982722
  3197. ],
  3198. [
  3199. 0.13365457218610619,
  3200. 0.1324620394046966,
  3201. 0.1324620394046966,
  3202. 0.12890572218808216,
  3203. 0.12890572218808216,
  3204. 0.12304908430672953,
  3205. 0.12304908430672953,
  3206. 0.11499664022241136,
  3207. 0.11499664022241136,
  3208. 0.10489209146454141,
  3209. 0.10489209146454141,
  3210. 0.09291576606003515,
  3211. 0.09291576606003515,
  3212. 0.07928141177671895,
  3213. 0.07928141177671895,
  3214. 0.06423242140852585,
  3215. 0.06423242140852585,
  3216. 0.04803767173108467,
  3217. 0.04803767173108467,
  3218. 0.030988005856979445,
  3219. 0.030988005856979445,
  3220. 0.013411859487141771,
  3221. 0.013411859487141771
  3222. ],
  3223. [
  3224. 0.12793819534675216,
  3225. 0.12793819534675216,
  3226. 0.1258374563468283,
  3227. 0.1258374563468283,
  3228. 0.12167047292780339,
  3229. 0.12167047292780339,
  3230. 0.1155056680537256,
  3231. 0.1155056680537256,
  3232. 0.10744427011596563,
  3233. 0.10744427011596563,
  3234. 0.09761865210411388,
  3235. 0.09761865210411388,
  3236. 0.08619016153195327,
  3237. 0.08619016153195327,
  3238. 0.0733464814110803,
  3239. 0.0733464814110803,
  3240. 0.05929858491543678,
  3241. 0.05929858491543678,
  3242. 0.04427743881741981,
  3243. 0.04427743881741981,
  3244. 0.028531388628933663,
  3245. 0.028531388628933663,
  3246. 0.0123412297999872,
  3247. 0.0123412297999872
  3248. ]
  3249. ], s.binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
  3250. const t = (a, o, h) => {
  3251. let l, A, u;
  3252. l = h / 2, A = 0;
  3253. for (let c = 0; c < 20; c++)
  3254. u = l * s.tValues[20][c] + l, A += s.cValues[20][c] * i(a, o, u);
  3255. return l * A;
  3256. };
  3257. s.getCubicArcLength = t;
  3258. const e = (a, o, h) => {
  3259. h === void 0 && (h = 1);
  3260. const l = a[0] - 2 * a[1] + a[2], A = o[0] - 2 * o[1] + o[2], u = 2 * a[1] - 2 * a[0], f = 2 * o[1] - 2 * o[0], c = 4 * (l * l + A * A), d = 4 * (l * u + A * f), p = u * u + f * f;
  3261. if (c === 0)
  3262. return h * Math.sqrt(Math.pow(a[2] - a[0], 2) + Math.pow(o[2] - o[0], 2));
  3263. const m = d / (2 * c), v = p / c, _ = h + m, g = v - m * m, y = _ * _ + g > 0 ? Math.sqrt(_ * _ + g) : 0, x = m * m + g > 0 ? Math.sqrt(m * m + g) : 0, b = m + Math.sqrt(m * m + g) !== 0 ? g * Math.log(Math.abs((_ + y) / (m + x))) : 0;
  3264. return Math.sqrt(c) / 2 * (_ * y - m * x + b);
  3265. };
  3266. s.getQuadraticArcLength = e;
  3267. function i(a, o, h) {
  3268. const l = n(1, h, a), A = n(1, h, o), u = l * l + A * A;
  3269. return Math.sqrt(u);
  3270. }
  3271. const n = (a, o, h) => {
  3272. const l = h.length - 1;
  3273. let A, u;
  3274. if (l === 0)
  3275. return 0;
  3276. if (a === 0) {
  3277. u = 0;
  3278. for (let f = 0; f <= l; f++)
  3279. u += s.binomialCoefficients[l][f] * Math.pow(1 - o, l - f) * Math.pow(o, f) * h[f];
  3280. return u;
  3281. } else {
  3282. A = new Array(l);
  3283. for (let f = 0; f < l; f++)
  3284. A[f] = l * (h[f + 1] - h[f]);
  3285. return n(a - 1, o, A);
  3286. }
  3287. }, r = (a, o, h) => {
  3288. let l = 1, A = a / o, u = (a - h(A)) / o, f = 0;
  3289. for (; l > 1e-3; ) {
  3290. const c = h(A + u), d = Math.abs(a - c) / o;
  3291. if (d < l)
  3292. l = d, A += u;
  3293. else {
  3294. const p = h(A - u), m = Math.abs(a - p) / o;
  3295. m < l ? (l = m, A -= u) : u /= 2;
  3296. }
  3297. if (f++, f > 500)
  3298. break;
  3299. }
  3300. return A;
  3301. };
  3302. s.t2length = r;
  3303. })(so);
  3304. Object.defineProperty(hi, "__esModule", { value: !0 });
  3305. var Ci = hi.Path = void 0;
  3306. const fl = V, gl = ft, pl = $, Ge = so;
  3307. class ut extends gl.Shape {
  3308. constructor(t) {
  3309. super(t), this.dataArray = [], this.pathLength = 0, this._readDataAttribute(), this.on("dataChange.konva", function() {
  3310. this._readDataAttribute();
  3311. });
  3312. }
  3313. _readDataAttribute() {
  3314. this.dataArray = ut.parsePathData(this.data()), this.pathLength = ut.getPathLength(this.dataArray);
  3315. }
  3316. _sceneFunc(t) {
  3317. var e = this.dataArray;
  3318. t.beginPath();
  3319. for (var i = !1, n = 0; n < e.length; n++) {
  3320. var r = e[n].command, a = e[n].points;
  3321. switch (r) {
  3322. case "L":
  3323. t.lineTo(a[0], a[1]);
  3324. break;
  3325. case "M":
  3326. t.moveTo(a[0], a[1]);
  3327. break;
  3328. case "C":
  3329. t.bezierCurveTo(a[0], a[1], a[2], a[3], a[4], a[5]);
  3330. break;
  3331. case "Q":
  3332. t.quadraticCurveTo(a[0], a[1], a[2], a[3]);
  3333. break;
  3334. case "A":
  3335. var o = a[0], h = a[1], l = a[2], A = a[3], u = a[4], f = a[5], c = a[6], d = a[7], p = l > A ? l : A, m = l > A ? 1 : l / A, v = l > A ? A / l : 1;
  3336. t.translate(o, h), t.rotate(c), t.scale(m, v), t.arc(0, 0, p, u, u + f, 1 - d), t.scale(1 / m, 1 / v), t.rotate(-c), t.translate(-o, -h);
  3337. break;
  3338. case "z":
  3339. i = !0, t.closePath();
  3340. break;
  3341. }
  3342. }
  3343. !i && !this.hasFill() ? t.strokeShape(this) : t.fillStrokeShape(this);
  3344. }
  3345. getSelfRect() {
  3346. var t = [];
  3347. this.dataArray.forEach(function(l) {
  3348. if (l.command === "A") {
  3349. var A = l.points[4], u = l.points[5], f = l.points[4] + u, c = Math.PI / 180;
  3350. if (Math.abs(A - f) < c && (c = Math.abs(A - f)), u < 0)
  3351. for (let d = A - c; d > f; d -= c) {
  3352. const p = ut.getPointOnEllipticalArc(l.points[0], l.points[1], l.points[2], l.points[3], d, 0);
  3353. t.push(p.x, p.y);
  3354. }
  3355. else
  3356. for (let d = A + c; d < f; d += c) {
  3357. const p = ut.getPointOnEllipticalArc(l.points[0], l.points[1], l.points[2], l.points[3], d, 0);
  3358. t.push(p.x, p.y);
  3359. }
  3360. } else if (l.command === "C")
  3361. for (let d = 0; d <= 1; d += 0.01) {
  3362. const p = ut.getPointOnCubicBezier(d, l.start.x, l.start.y, l.points[0], l.points[1], l.points[2], l.points[3], l.points[4], l.points[5]);
  3363. t.push(p.x, p.y);
  3364. }
  3365. else
  3366. t = t.concat(l.points);
  3367. });
  3368. for (var e = t[0], i = t[0], n = t[1], r = t[1], a, o, h = 0; h < t.length / 2; h++)
  3369. a = t[h * 2], o = t[h * 2 + 1], isNaN(a) || (e = Math.min(e, a), i = Math.max(i, a)), isNaN(o) || (n = Math.min(n, o), r = Math.max(r, o));
  3370. return {
  3371. x: e,
  3372. y: n,
  3373. width: i - e,
  3374. height: r - n
  3375. };
  3376. }
  3377. getLength() {
  3378. return this.pathLength;
  3379. }
  3380. getPointAtLength(t) {
  3381. return ut.getPointAtLengthOfDataArray(t, this.dataArray);
  3382. }
  3383. static getLineLength(t, e, i, n) {
  3384. return Math.sqrt((i - t) * (i - t) + (n - e) * (n - e));
  3385. }
  3386. static getPathLength(t) {
  3387. let e = 0;
  3388. for (var i = 0; i < t.length; ++i)
  3389. e += t[i].pathLength;
  3390. return e;
  3391. }
  3392. static getPointAtLengthOfDataArray(t, e) {
  3393. var i, n = 0, r = e.length;
  3394. if (!r)
  3395. return null;
  3396. for (; n < r && t > e[n].pathLength; )
  3397. t -= e[n].pathLength, ++n;
  3398. if (n === r)
  3399. return i = e[n - 1].points.slice(-2), {
  3400. x: i[0],
  3401. y: i[1]
  3402. };
  3403. if (t < 0.01)
  3404. return i = e[n].points.slice(0, 2), {
  3405. x: i[0],
  3406. y: i[1]
  3407. };
  3408. var a = e[n], o = a.points;
  3409. switch (a.command) {
  3410. case "L":
  3411. return ut.getPointOnLine(t, a.start.x, a.start.y, o[0], o[1]);
  3412. case "C":
  3413. return ut.getPointOnCubicBezier((0, Ge.t2length)(t, ut.getPathLength(e), (p) => (0, Ge.getCubicArcLength)([a.start.x, o[0], o[2], o[4]], [a.start.y, o[1], o[3], o[5]], p)), a.start.x, a.start.y, o[0], o[1], o[2], o[3], o[4], o[5]);
  3414. case "Q":
  3415. return ut.getPointOnQuadraticBezier((0, Ge.t2length)(t, ut.getPathLength(e), (p) => (0, Ge.getQuadraticArcLength)([a.start.x, o[0], o[2]], [a.start.y, o[1], o[3]], p)), a.start.x, a.start.y, o[0], o[1], o[2], o[3]);
  3416. case "A":
  3417. var h = o[0], l = o[1], A = o[2], u = o[3], f = o[4], c = o[5], d = o[6];
  3418. return f += c * t / a.pathLength, ut.getPointOnEllipticalArc(h, l, A, u, f, d);
  3419. }
  3420. return null;
  3421. }
  3422. static getPointOnLine(t, e, i, n, r, a, o) {
  3423. a === void 0 && (a = e), o === void 0 && (o = i);
  3424. var h = (r - i) / (n - e + 1e-8), l = Math.sqrt(t * t / (1 + h * h));
  3425. n < e && (l *= -1);
  3426. var A = h * l, u;
  3427. if (n === e)
  3428. u = {
  3429. x: a,
  3430. y: o + A
  3431. };
  3432. else if ((o - i) / (a - e + 1e-8) === h)
  3433. u = {
  3434. x: a + l,
  3435. y: o + A
  3436. };
  3437. else {
  3438. var f, c, d = this.getLineLength(e, i, n, r), p = (a - e) * (n - e) + (o - i) * (r - i);
  3439. p = p / (d * d), f = e + p * (n - e), c = i + p * (r - i);
  3440. var m = this.getLineLength(a, o, f, c), v = Math.sqrt(t * t - m * m);
  3441. l = Math.sqrt(v * v / (1 + h * h)), n < e && (l *= -1), A = h * l, u = {
  3442. x: f + l,
  3443. y: c + A
  3444. };
  3445. }
  3446. return u;
  3447. }
  3448. static getPointOnCubicBezier(t, e, i, n, r, a, o, h, l) {
  3449. function A(m) {
  3450. return m * m * m;
  3451. }
  3452. function u(m) {
  3453. return 3 * m * m * (1 - m);
  3454. }
  3455. function f(m) {
  3456. return 3 * m * (1 - m) * (1 - m);
  3457. }
  3458. function c(m) {
  3459. return (1 - m) * (1 - m) * (1 - m);
  3460. }
  3461. var d = h * A(t) + a * u(t) + n * f(t) + e * c(t), p = l * A(t) + o * u(t) + r * f(t) + i * c(t);
  3462. return {
  3463. x: d,
  3464. y: p
  3465. };
  3466. }
  3467. static getPointOnQuadraticBezier(t, e, i, n, r, a, o) {
  3468. function h(c) {
  3469. return c * c;
  3470. }
  3471. function l(c) {
  3472. return 2 * c * (1 - c);
  3473. }
  3474. function A(c) {
  3475. return (1 - c) * (1 - c);
  3476. }
  3477. var u = a * h(t) + n * l(t) + e * A(t), f = o * h(t) + r * l(t) + i * A(t);
  3478. return {
  3479. x: u,
  3480. y: f
  3481. };
  3482. }
  3483. static getPointOnEllipticalArc(t, e, i, n, r, a) {
  3484. var o = Math.cos(a), h = Math.sin(a), l = {
  3485. x: i * Math.cos(r),
  3486. y: n * Math.sin(r)
  3487. };
  3488. return {
  3489. x: t + (l.x * o - l.y * h),
  3490. y: e + (l.x * h + l.y * o)
  3491. };
  3492. }
  3493. static parsePathData(t) {
  3494. if (!t)
  3495. return [];
  3496. var e = t, i = [
  3497. "m",
  3498. "M",
  3499. "l",
  3500. "L",
  3501. "v",
  3502. "V",
  3503. "h",
  3504. "H",
  3505. "z",
  3506. "Z",
  3507. "c",
  3508. "C",
  3509. "q",
  3510. "Q",
  3511. "t",
  3512. "T",
  3513. "s",
  3514. "S",
  3515. "a",
  3516. "A"
  3517. ];
  3518. e = e.replace(new RegExp(" ", "g"), ",");
  3519. for (var n = 0; n < i.length; n++)
  3520. e = e.replace(new RegExp(i[n], "g"), "|" + i[n]);
  3521. var r = e.split("|"), a = [], o = [], h = 0, l = 0, A = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi, u;
  3522. for (n = 1; n < r.length; n++) {
  3523. var f = r[n], c = f.charAt(0);
  3524. for (f = f.slice(1), o.length = 0; u = A.exec(f); )
  3525. o.push(u[0]);
  3526. for (var d = [], p = 0, m = o.length; p < m; p++) {
  3527. if (o[p] === "00") {
  3528. d.push(0, 0);
  3529. continue;
  3530. }
  3531. var v = parseFloat(o[p]);
  3532. isNaN(v) ? d.push(0) : d.push(v);
  3533. }
  3534. for (; d.length > 0 && !isNaN(d[0]); ) {
  3535. var _ = "", g = [], y = h, x = l, b, C, w, E, S, P, k, F, L, I;
  3536. switch (c) {
  3537. case "l":
  3538. h += d.shift(), l += d.shift(), _ = "L", g.push(h, l);
  3539. break;
  3540. case "L":
  3541. h = d.shift(), l = d.shift(), g.push(h, l);
  3542. break;
  3543. case "m":
  3544. var z = d.shift(), T = d.shift();
  3545. if (h += z, l += T, _ = "M", a.length > 2 && a[a.length - 1].command === "z") {
  3546. for (var G = a.length - 2; G >= 0; G--)
  3547. if (a[G].command === "M") {
  3548. h = a[G].points[0] + z, l = a[G].points[1] + T;
  3549. break;
  3550. }
  3551. }
  3552. g.push(h, l), c = "l";
  3553. break;
  3554. case "M":
  3555. h = d.shift(), l = d.shift(), _ = "M", g.push(h, l), c = "L";
  3556. break;
  3557. case "h":
  3558. h += d.shift(), _ = "L", g.push(h, l);
  3559. break;
  3560. case "H":
  3561. h = d.shift(), _ = "L", g.push(h, l);
  3562. break;
  3563. case "v":
  3564. l += d.shift(), _ = "L", g.push(h, l);
  3565. break;
  3566. case "V":
  3567. l = d.shift(), _ = "L", g.push(h, l);
  3568. break;
  3569. case "C":
  3570. g.push(d.shift(), d.shift(), d.shift(), d.shift()), h = d.shift(), l = d.shift(), g.push(h, l);
  3571. break;
  3572. case "c":
  3573. g.push(h + d.shift(), l + d.shift(), h + d.shift(), l + d.shift()), h += d.shift(), l += d.shift(), _ = "C", g.push(h, l);
  3574. break;
  3575. case "S":
  3576. C = h, w = l, b = a[a.length - 1], b.command === "C" && (C = h + (h - b.points[2]), w = l + (l - b.points[3])), g.push(C, w, d.shift(), d.shift()), h = d.shift(), l = d.shift(), _ = "C", g.push(h, l);
  3577. break;
  3578. case "s":
  3579. C = h, w = l, b = a[a.length - 1], b.command === "C" && (C = h + (h - b.points[2]), w = l + (l - b.points[3])), g.push(C, w, h + d.shift(), l + d.shift()), h += d.shift(), l += d.shift(), _ = "C", g.push(h, l);
  3580. break;
  3581. case "Q":
  3582. g.push(d.shift(), d.shift()), h = d.shift(), l = d.shift(), g.push(h, l);
  3583. break;
  3584. case "q":
  3585. g.push(h + d.shift(), l + d.shift()), h += d.shift(), l += d.shift(), _ = "Q", g.push(h, l);
  3586. break;
  3587. case "T":
  3588. C = h, w = l, b = a[a.length - 1], b.command === "Q" && (C = h + (h - b.points[0]), w = l + (l - b.points[1])), h = d.shift(), l = d.shift(), _ = "Q", g.push(C, w, h, l);
  3589. break;
  3590. case "t":
  3591. C = h, w = l, b = a[a.length - 1], b.command === "Q" && (C = h + (h - b.points[0]), w = l + (l - b.points[1])), h += d.shift(), l += d.shift(), _ = "Q", g.push(C, w, h, l);
  3592. break;
  3593. case "A":
  3594. E = d.shift(), S = d.shift(), P = d.shift(), k = d.shift(), F = d.shift(), L = h, I = l, h = d.shift(), l = d.shift(), _ = "A", g = this.convertEndpointToCenterParameterization(L, I, h, l, k, F, E, S, P);
  3595. break;
  3596. case "a":
  3597. E = d.shift(), S = d.shift(), P = d.shift(), k = d.shift(), F = d.shift(), L = h, I = l, h += d.shift(), l += d.shift(), _ = "A", g = this.convertEndpointToCenterParameterization(L, I, h, l, k, F, E, S, P);
  3598. break;
  3599. }
  3600. a.push({
  3601. command: _ || c,
  3602. points: g,
  3603. start: {
  3604. x: y,
  3605. y: x
  3606. },
  3607. pathLength: this.calcLength(y, x, _ || c, g)
  3608. });
  3609. }
  3610. (c === "z" || c === "Z") && a.push({
  3611. command: "z",
  3612. points: [],
  3613. start: void 0,
  3614. pathLength: 0
  3615. });
  3616. }
  3617. return a;
  3618. }
  3619. static calcLength(t, e, i, n) {
  3620. var r, a, o, h, l = ut;
  3621. switch (i) {
  3622. case "L":
  3623. return l.getLineLength(t, e, n[0], n[1]);
  3624. case "C":
  3625. return (0, Ge.getCubicArcLength)([t, n[0], n[2], n[4]], [e, n[1], n[3], n[5]], 1);
  3626. case "Q":
  3627. return (0, Ge.getQuadraticArcLength)([t, n[0], n[2]], [e, n[1], n[3]], 1);
  3628. case "A":
  3629. r = 0;
  3630. var A = n[4], u = n[5], f = n[4] + u, c = Math.PI / 180;
  3631. if (Math.abs(A - f) < c && (c = Math.abs(A - f)), a = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], A, 0), u < 0)
  3632. for (h = A - c; h > f; h -= c)
  3633. o = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], h, 0), r += l.getLineLength(a.x, a.y, o.x, o.y), a = o;
  3634. else
  3635. for (h = A + c; h < f; h += c)
  3636. o = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], h, 0), r += l.getLineLength(a.x, a.y, o.x, o.y), a = o;
  3637. return o = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], f, 0), r += l.getLineLength(a.x, a.y, o.x, o.y), r;
  3638. }
  3639. return 0;
  3640. }
  3641. static convertEndpointToCenterParameterization(t, e, i, n, r, a, o, h, l) {
  3642. var A = l * (Math.PI / 180), u = Math.cos(A) * (t - i) / 2 + Math.sin(A) * (e - n) / 2, f = -1 * Math.sin(A) * (t - i) / 2 + Math.cos(A) * (e - n) / 2, c = u * u / (o * o) + f * f / (h * h);
  3643. c > 1 && (o *= Math.sqrt(c), h *= Math.sqrt(c));
  3644. var d = Math.sqrt((o * o * (h * h) - o * o * (f * f) - h * h * (u * u)) / (o * o * (f * f) + h * h * (u * u)));
  3645. r === a && (d *= -1), isNaN(d) && (d = 0);
  3646. var p = d * o * f / h, m = d * -h * u / o, v = (t + i) / 2 + Math.cos(A) * p - Math.sin(A) * m, _ = (e + n) / 2 + Math.sin(A) * p + Math.cos(A) * m, g = function(S) {
  3647. return Math.sqrt(S[0] * S[0] + S[1] * S[1]);
  3648. }, y = function(S, P) {
  3649. return (S[0] * P[0] + S[1] * P[1]) / (g(S) * g(P));
  3650. }, x = function(S, P) {
  3651. return (S[0] * P[1] < S[1] * P[0] ? -1 : 1) * Math.acos(y(S, P));
  3652. }, b = x([1, 0], [(u - p) / o, (f - m) / h]), C = [(u - p) / o, (f - m) / h], w = [(-1 * u - p) / o, (-1 * f - m) / h], E = x(C, w);
  3653. return y(C, w) <= -1 && (E = Math.PI), y(C, w) >= 1 && (E = 0), a === 0 && E > 0 && (E = E - 2 * Math.PI), a === 1 && E < 0 && (E = E + 2 * Math.PI), [v, _, o, h, b, E, A, a];
  3654. }
  3655. }
  3656. Ci = hi.Path = ut;
  3657. ut.prototype.className = "Path";
  3658. ut.prototype._attrsAffectingSize = ["data"];
  3659. (0, pl._registerNode)(ut);
  3660. fl.Factory.addGetterSetter(ut, "data");
  3661. var Bi = {};
  3662. Object.defineProperty(Bi, "__esModule", { value: !0 });
  3663. var ro = Bi.Rect = void 0;
  3664. const yl = V, ml = ft, vl = $, _l = st, xl = O;
  3665. class Dn extends ml.Shape {
  3666. _sceneFunc(t) {
  3667. var e = this.cornerRadius(), i = this.width(), n = this.height();
  3668. t.beginPath(), e ? _l.Util.drawRoundedRectPath(t, i, n, e) : t.rect(0, 0, i, n), t.closePath(), t.fillStrokeShape(this);
  3669. }
  3670. }
  3671. ro = Bi.Rect = Dn;
  3672. Dn.prototype.className = "Rect";
  3673. (0, vl._registerNode)(Dn);
  3674. yl.Factory.addGetterSetter(Dn, "cornerRadius", 0, (0, xl.getNumberOrArrayOfNumbersValidator)(4));
  3675. const be = (s, t = !1) => {
  3676. let e = s;
  3677. const i = t ? s.getTransform().copy() : new st.Transform();
  3678. for (; e = e.parent; )
  3679. i.multiply(e.getTransform());
  3680. return i;
  3681. };
  3682. function ju(s) {
  3683. const [t, e, i, n] = s.m, r = Math.sqrt(t * t + i * i), a = Math.sqrt(e * e + n * n), o = Math.atan2(i, t), h = o, l = o + Math.PI / 2;
  3684. return console.log(h, l), { x: r, y: a };
  3685. }
  3686. const Gt = (s, t, e = !1) => {
  3687. let i = s, n = e ? s.scale() : { x: 1, y: 1 };
  3688. for (; i = i.parent; ) {
  3689. const r = i.scale();
  3690. n.x *= r.x, n.y *= r.y;
  3691. }
  3692. return [t[0] / n.x, t[1] / n.y];
  3693. };
  3694. var li = {}, Ee = {};
  3695. Object.defineProperty(Ee, "__esModule", { value: !0 });
  3696. Ee.Container = void 0;
  3697. const Ai = V, Ss = rt, In = O;
  3698. let Fe = class extends Ss.Node {
  3699. constructor() {
  3700. super(...arguments), this.children = [];
  3701. }
  3702. getChildren(t) {
  3703. if (!t)
  3704. return this.children || [];
  3705. const e = this.children || [];
  3706. var i = [];
  3707. return e.forEach(function(n) {
  3708. t(n) && i.push(n);
  3709. }), i;
  3710. }
  3711. hasChildren() {
  3712. return this.getChildren().length > 0;
  3713. }
  3714. removeChildren() {
  3715. return this.getChildren().forEach((t) => {
  3716. t.parent = null, t.index = 0, t.remove();
  3717. }), this.children = [], this._requestDraw(), this;
  3718. }
  3719. destroyChildren() {
  3720. return this.getChildren().forEach((t) => {
  3721. t.parent = null, t.index = 0, t.destroy();
  3722. }), this.children = [], this._requestDraw(), this;
  3723. }
  3724. add(...t) {
  3725. if (t.length === 0)
  3726. return this;
  3727. if (t.length > 1) {
  3728. for (var e = 0; e < t.length; e++)
  3729. this.add(t[e]);
  3730. return this;
  3731. }
  3732. const i = t[0];
  3733. return i.getParent() ? (i.moveTo(this), this) : (this._validateAdd(i), i.index = this.getChildren().length, i.parent = this, i._clearCaches(), this.getChildren().push(i), this._fire("add", {
  3734. child: i
  3735. }), this._requestDraw(), this);
  3736. }
  3737. destroy() {
  3738. return this.hasChildren() && this.destroyChildren(), super.destroy(), this;
  3739. }
  3740. find(t) {
  3741. return this._generalFind(t, !1);
  3742. }
  3743. findOne(t) {
  3744. var e = this._generalFind(t, !0);
  3745. return e.length > 0 ? e[0] : void 0;
  3746. }
  3747. _generalFind(t, e) {
  3748. var i = [];
  3749. return this._descendants((n) => {
  3750. const r = n._isMatch(t);
  3751. return r && i.push(n), !!(r && e);
  3752. }), i;
  3753. }
  3754. _descendants(t) {
  3755. let e = !1;
  3756. const i = this.getChildren();
  3757. for (const n of i) {
  3758. if (e = t(n), e)
  3759. return !0;
  3760. if (n.hasChildren() && (e = n._descendants(t), e))
  3761. return !0;
  3762. }
  3763. return !1;
  3764. }
  3765. toObject() {
  3766. var t = Ss.Node.prototype.toObject.call(this);
  3767. return t.children = [], this.getChildren().forEach((e) => {
  3768. t.children.push(e.toObject());
  3769. }), t;
  3770. }
  3771. isAncestorOf(t) {
  3772. for (var e = t.getParent(); e; ) {
  3773. if (e._id === this._id)
  3774. return !0;
  3775. e = e.getParent();
  3776. }
  3777. return !1;
  3778. }
  3779. clone(t) {
  3780. var e = Ss.Node.prototype.clone.call(this, t);
  3781. return this.getChildren().forEach(function(i) {
  3782. e.add(i.clone());
  3783. }), e;
  3784. }
  3785. getAllIntersections(t) {
  3786. var e = [];
  3787. return this.find("Shape").forEach((i) => {
  3788. i.isVisible() && i.intersects(t) && e.push(i);
  3789. }), e;
  3790. }
  3791. _clearSelfAndDescendantCache(t) {
  3792. var e;
  3793. super._clearSelfAndDescendantCache(t), !this.isCached() && ((e = this.children) === null || e === void 0 || e.forEach(function(i) {
  3794. i._clearSelfAndDescendantCache(t);
  3795. }));
  3796. }
  3797. _setChildrenIndices() {
  3798. var t;
  3799. (t = this.children) === null || t === void 0 || t.forEach(function(e, i) {
  3800. e.index = i;
  3801. }), this._requestDraw();
  3802. }
  3803. drawScene(t, e, i) {
  3804. var n = this.getLayer(), r = t || n && n.getCanvas(), a = r && r.getContext(), o = this._getCanvasCache(), h = o && o.scene, l = r && r.isCache;
  3805. if (!this.isVisible() && !l)
  3806. return this;
  3807. if (h) {
  3808. a.save();
  3809. var A = this.getAbsoluteTransform(e).getMatrix();
  3810. a.transform(A[0], A[1], A[2], A[3], A[4], A[5]), this._drawCachedSceneCanvas(a), a.restore();
  3811. } else
  3812. this._drawChildren("drawScene", r, e, i);
  3813. return this;
  3814. }
  3815. drawHit(t, e) {
  3816. if (!this.shouldDrawHit(e))
  3817. return this;
  3818. var i = this.getLayer(), n = t || i && i.hitCanvas, r = n && n.getContext(), a = this._getCanvasCache(), o = a && a.hit;
  3819. if (o) {
  3820. r.save();
  3821. var h = this.getAbsoluteTransform(e).getMatrix();
  3822. r.transform(h[0], h[1], h[2], h[3], h[4], h[5]), this._drawCachedHitCanvas(r), r.restore();
  3823. } else
  3824. this._drawChildren("drawHit", n, e);
  3825. return this;
  3826. }
  3827. _drawChildren(t, e, i, n) {
  3828. var r, a = e && e.getContext(), o = this.clipWidth(), h = this.clipHeight(), l = this.clipFunc(), A = typeof o == "number" && typeof h == "number" || l;
  3829. const u = i === this;
  3830. if (A) {
  3831. a.save();
  3832. var f = this.getAbsoluteTransform(i), c = f.getMatrix();
  3833. a.transform(c[0], c[1], c[2], c[3], c[4], c[5]), a.beginPath();
  3834. let v;
  3835. if (l)
  3836. v = l.call(this, a, this);
  3837. else {
  3838. var d = this.clipX(), p = this.clipY();
  3839. a.rect(d || 0, p || 0, o, h);
  3840. }
  3841. a.clip.apply(a, v), c = f.copy().invert().getMatrix(), a.transform(c[0], c[1], c[2], c[3], c[4], c[5]);
  3842. }
  3843. var m = !u && this.globalCompositeOperation() !== "source-over" && t === "drawScene";
  3844. m && (a.save(), a._applyGlobalCompositeOperation(this)), (r = this.children) === null || r === void 0 || r.forEach(function(v) {
  3845. v[t](e, i, n);
  3846. }), m && a.restore(), A && a.restore();
  3847. }
  3848. getClientRect(t = {}) {
  3849. var e, i = t.skipTransform, n = t.relativeTo, r, a, o, h, l = {
  3850. x: 1 / 0,
  3851. y: 1 / 0,
  3852. width: 0,
  3853. height: 0
  3854. }, A = this;
  3855. (e = this.children) === null || e === void 0 || e.forEach(function(p) {
  3856. if (p.visible()) {
  3857. var m = p.getClientRect({
  3858. relativeTo: A,
  3859. skipShadow: t.skipShadow,
  3860. skipStroke: t.skipStroke
  3861. });
  3862. m.width === 0 && m.height === 0 || (r === void 0 ? (r = m.x, a = m.y, o = m.x + m.width, h = m.y + m.height) : (r = Math.min(r, m.x), a = Math.min(a, m.y), o = Math.max(o, m.x + m.width), h = Math.max(h, m.y + m.height)));
  3863. }
  3864. });
  3865. for (var u = this.find("Shape"), f = !1, c = 0; c < u.length; c++) {
  3866. var d = u[c];
  3867. if (d._isVisible(this)) {
  3868. f = !0;
  3869. break;
  3870. }
  3871. }
  3872. return f && r !== void 0 ? l = {
  3873. x: r,
  3874. y: a,
  3875. width: o - r,
  3876. height: h - a
  3877. } : l = {
  3878. x: 0,
  3879. y: 0,
  3880. width: 0,
  3881. height: 0
  3882. }, i ? l : this._transformedRect(l, n);
  3883. }
  3884. };
  3885. Ee.Container = Fe;
  3886. Ai.Factory.addComponentsGetterSetter(Fe, "clip", [
  3887. "x",
  3888. "y",
  3889. "width",
  3890. "height"
  3891. ]);
  3892. Ai.Factory.addGetterSetter(Fe, "clipX", void 0, (0, In.getNumberValidator)());
  3893. Ai.Factory.addGetterSetter(Fe, "clipY", void 0, (0, In.getNumberValidator)());
  3894. Ai.Factory.addGetterSetter(Fe, "clipWidth", void 0, (0, In.getNumberValidator)());
  3895. Ai.Factory.addGetterSetter(Fe, "clipHeight", void 0, (0, In.getNumberValidator)());
  3896. Ai.Factory.addGetterSetter(Fe, "clipFunc");
  3897. Object.defineProperty(li, "__esModule", { value: !0 });
  3898. var Nt = li.Group = void 0;
  3899. const bl = st, wl = Ee, Sl = $;
  3900. class cr extends wl.Container {
  3901. _validateAdd(t) {
  3902. var e = t.getType();
  3903. e !== "Group" && e !== "Shape" && bl.Util.throw("You may only add groups and shapes to groups.");
  3904. }
  3905. }
  3906. Nt = li.Group = cr;
  3907. cr.prototype.nodeType = "Group";
  3908. (0, Sl._registerNode)(cr);
  3909. const Yr = document.createElement("div"), Cl = (s) => {
  3910. Yr.innerHTML = s;
  3911. const t = Yr.querySelector("svg"), e = [t.width.baseVal.value, t.height.baseVal.value];
  3912. return {
  3913. paths: Array.from(t.querySelectorAll("path")).map((r) => {
  3914. const a = r.getAttribute("fill"), o = r.getAttribute("d"), h = r.getAttribute("stroke"), l = r.getAttribute("stroke-width");
  3915. return {
  3916. fill: a,
  3917. data: o,
  3918. stroke: h,
  3919. strokeWidth: l && Number(l)
  3920. };
  3921. }),
  3922. size: e
  3923. };
  3924. }, Ml = (s, t = !1) => {
  3925. const e = s.size, n = (s.realWidth || s.size[0]) / e[0], r = e.map((m) => m * n), a = (s.offset || [0, 0]).map((m) => m * n), o = s.strokeWidth ? s.strokeWidth * n : 1, h = s.strokeColor || "#000", l = s.paths.map((m) => typeof m == "string" ? {
  3926. strokeWidth: o,
  3927. stroke: h,
  3928. fill: h,
  3929. data: m
  3930. } : m), A = l.map(
  3931. (m, v) => new Ci({
  3932. data: m.data,
  3933. id: `path-${v}`,
  3934. name: "path",
  3935. strokeScaleEnabled: !!s.fixed,
  3936. scale: { x: n, y: n }
  3937. })
  3938. ), u = () => {
  3939. A.forEach((m, v) => {
  3940. const _ = l[v];
  3941. _.fill && m.fill(_.fill), _.stroke && m.stroke(_.stroke), _.strokeWidth && m.strokeWidth(_.strokeWidth);
  3942. });
  3943. }, f = new ro({
  3944. x: a[0],
  3945. y: a[1],
  3946. name: "rect",
  3947. width: r[0],
  3948. height: r[1],
  3949. fill: `rgba(0, 0, 0, ${t ? 0.3 : 0})`
  3950. }), c = () => {
  3951. let [m, v] = Gt(p, [1, 1]);
  3952. p.scale({ x: m, y: v });
  3953. }, d = new Nt();
  3954. d.add(...A, f), d.x(-r[0] / 2), d.y(-r[1] / 2);
  3955. const p = new Nt();
  3956. return p.add(d), {
  3957. getSize: () => {
  3958. const m = f.getSize();
  3959. if (s.fixed) {
  3960. let [v] = Gt(p, [1, 1]);
  3961. return [m.width * v, m.height * v];
  3962. }
  3963. return [m.width, m.height];
  3964. },
  3965. shape: p,
  3966. setData(m) {
  3967. p.position(m), s.fixed && c(), m.rotate && p.rotation(m.rotate);
  3968. },
  3969. common: u
  3970. };
  3971. }, ao = (s) => {
  3972. const e = s.evt.target.getBoundingClientRect(), i = s.evt.changedTouches[0].pageX - e.left, n = s.evt.changedTouches[0].pageY - e.top;
  3973. return {
  3974. offsetX: i,
  3975. offsetY: n
  3976. };
  3977. };
  3978. /**
  3979. * @license
  3980. * Copyright 2010-2024 Three.js Authors
  3981. * SPDX-License-Identifier: MIT
  3982. */
  3983. const oo = "164", ho = 300, Xr = 1e3, Yi = 1001, jr = 1002, qr = 1003, Pl = 1006, El = 1008, Fl = 1009, kl = 1014, Dl = 1020, Il = 1023, Cs = 1026, Qr = 1027, lo = "", le = "srgb", dr = "srgb-linear", Tl = "display-p3", Ao = "display-p3-linear", Qs = "linear", Kr = "srgb", Zr = "rec709", Jr = "p3", Ll = 515, Xi = 2e3, ta = 2001;
  3984. class co {
  3985. addEventListener(t, e) {
  3986. this._listeners === void 0 && (this._listeners = {});
  3987. const i = this._listeners;
  3988. i[t] === void 0 && (i[t] = []), i[t].indexOf(e) === -1 && i[t].push(e);
  3989. }
  3990. hasEventListener(t, e) {
  3991. if (this._listeners === void 0)
  3992. return !1;
  3993. const i = this._listeners;
  3994. return i[t] !== void 0 && i[t].indexOf(e) !== -1;
  3995. }
  3996. removeEventListener(t, e) {
  3997. if (this._listeners === void 0)
  3998. return;
  3999. const n = this._listeners[t];
  4000. if (n !== void 0) {
  4001. const r = n.indexOf(e);
  4002. r !== -1 && n.splice(r, 1);
  4003. }
  4004. }
  4005. dispatchEvent(t) {
  4006. if (this._listeners === void 0)
  4007. return;
  4008. const i = this._listeners[t.type];
  4009. if (i !== void 0) {
  4010. t.target = this;
  4011. const n = i.slice(0);
  4012. for (let r = 0, a = n.length; r < a; r++)
  4013. n[r].call(this, t);
  4014. t.target = null;
  4015. }
  4016. }
  4017. }
  4018. const pt = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
  4019. let ea = 1234567;
  4020. const uo = Math.PI / 180, fo = 180 / Math.PI;
  4021. function Tn() {
  4022. const s = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, i = Math.random() * 4294967295 | 0;
  4023. return (pt[s & 255] + pt[s >> 8 & 255] + pt[s >> 16 & 255] + pt[s >> 24 & 255] + "-" + pt[t & 255] + pt[t >> 8 & 255] + "-" + pt[t >> 16 & 15 | 64] + pt[t >> 24 & 255] + "-" + pt[e & 63 | 128] + pt[e >> 8 & 255] + "-" + pt[e >> 16 & 255] + pt[e >> 24 & 255] + pt[i & 255] + pt[i >> 8 & 255] + pt[i >> 16 & 255] + pt[i >> 24 & 255]).toLowerCase();
  4024. }
  4025. function mt(s, t, e) {
  4026. return Math.max(t, Math.min(e, s));
  4027. }
  4028. function ur(s, t) {
  4029. return (s % t + t) % t;
  4030. }
  4031. function Rl(s, t, e, i, n) {
  4032. return i + (s - t) * (n - i) / (e - t);
  4033. }
  4034. function Ol(s, t, e) {
  4035. return s !== t ? (e - s) / (t - s) : 0;
  4036. }
  4037. function Mi(s, t, e) {
  4038. return (1 - e) * s + e * t;
  4039. }
  4040. function Nl(s, t, e, i) {
  4041. return Mi(s, t, 1 - Math.exp(-e * i));
  4042. }
  4043. function Gl(s, t = 1) {
  4044. return t - Math.abs(ur(s, t * 2) - t);
  4045. }
  4046. function Bl(s, t, e) {
  4047. return s <= t ? 0 : s >= e ? 1 : (s = (s - t) / (e - t), s * s * (3 - 2 * s));
  4048. }
  4049. function zl(s, t, e) {
  4050. return s <= t ? 0 : s >= e ? 1 : (s = (s - t) / (e - t), s * s * s * (s * (s * 6 - 15) + 10));
  4051. }
  4052. function Ul(s, t) {
  4053. return s + Math.floor(Math.random() * (t - s + 1));
  4054. }
  4055. function Hl(s, t) {
  4056. return s + Math.random() * (t - s);
  4057. }
  4058. function Vl(s) {
  4059. return s * (0.5 - Math.random());
  4060. }
  4061. function $l(s) {
  4062. s !== void 0 && (ea = s);
  4063. let t = ea += 1831565813;
  4064. return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
  4065. }
  4066. function Wl(s) {
  4067. return s * uo;
  4068. }
  4069. function Yl(s) {
  4070. return s * fo;
  4071. }
  4072. function Xl(s) {
  4073. return (s & s - 1) === 0 && s !== 0;
  4074. }
  4075. function jl(s) {
  4076. return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2));
  4077. }
  4078. function ql(s) {
  4079. return Math.pow(2, Math.floor(Math.log(s) / Math.LN2));
  4080. }
  4081. function Ql(s, t, e, i, n) {
  4082. const r = Math.cos, a = Math.sin, o = r(e / 2), h = a(e / 2), l = r((t + i) / 2), A = a((t + i) / 2), u = r((t - i) / 2), f = a((t - i) / 2), c = r((i - t) / 2), d = a((i - t) / 2);
  4083. switch (n) {
  4084. case "XYX":
  4085. s.set(o * A, h * u, h * f, o * l);
  4086. break;
  4087. case "YZY":
  4088. s.set(h * f, o * A, h * u, o * l);
  4089. break;
  4090. case "ZXZ":
  4091. s.set(h * u, h * f, o * A, o * l);
  4092. break;
  4093. case "XZX":
  4094. s.set(o * A, h * d, h * c, o * l);
  4095. break;
  4096. case "YXY":
  4097. s.set(h * c, o * A, h * d, o * l);
  4098. break;
  4099. case "ZYZ":
  4100. s.set(h * d, h * c, o * A, o * l);
  4101. break;
  4102. default:
  4103. console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + n);
  4104. }
  4105. }
  4106. function Kl(s, t) {
  4107. switch (t.constructor) {
  4108. case Float32Array:
  4109. return s;
  4110. case Uint32Array:
  4111. return s / 4294967295;
  4112. case Uint16Array:
  4113. return s / 65535;
  4114. case Uint8Array:
  4115. return s / 255;
  4116. case Int32Array:
  4117. return Math.max(s / 2147483647, -1);
  4118. case Int16Array:
  4119. return Math.max(s / 32767, -1);
  4120. case Int8Array:
  4121. return Math.max(s / 127, -1);
  4122. default:
  4123. throw new Error("Invalid component type.");
  4124. }
  4125. }
  4126. function Zl(s, t) {
  4127. switch (t.constructor) {
  4128. case Float32Array:
  4129. return s;
  4130. case Uint32Array:
  4131. return Math.round(s * 4294967295);
  4132. case Uint16Array:
  4133. return Math.round(s * 65535);
  4134. case Uint8Array:
  4135. return Math.round(s * 255);
  4136. case Int32Array:
  4137. return Math.round(s * 2147483647);
  4138. case Int16Array:
  4139. return Math.round(s * 32767);
  4140. case Int8Array:
  4141. return Math.round(s * 127);
  4142. default:
  4143. throw new Error("Invalid component type.");
  4144. }
  4145. }
  4146. const Se = {
  4147. DEG2RAD: uo,
  4148. RAD2DEG: fo,
  4149. generateUUID: Tn,
  4150. clamp: mt,
  4151. euclideanModulo: ur,
  4152. mapLinear: Rl,
  4153. inverseLerp: Ol,
  4154. lerp: Mi,
  4155. damp: Nl,
  4156. pingpong: Gl,
  4157. smoothstep: Bl,
  4158. smootherstep: zl,
  4159. randInt: Ul,
  4160. randFloat: Hl,
  4161. randFloatSpread: Vl,
  4162. seededRandom: $l,
  4163. degToRad: Wl,
  4164. radToDeg: Yl,
  4165. isPowerOfTwo: Xl,
  4166. ceilPowerOfTwo: jl,
  4167. floorPowerOfTwo: ql,
  4168. setQuaternionFromProperEuler: Ql,
  4169. normalize: Zl,
  4170. denormalize: Kl
  4171. };
  4172. class X {
  4173. constructor(t = 0, e = 0) {
  4174. X.prototype.isVector2 = !0, this.x = t, this.y = e;
  4175. }
  4176. get width() {
  4177. return this.x;
  4178. }
  4179. set width(t) {
  4180. this.x = t;
  4181. }
  4182. get height() {
  4183. return this.y;
  4184. }
  4185. set height(t) {
  4186. this.y = t;
  4187. }
  4188. set(t, e) {
  4189. return this.x = t, this.y = e, this;
  4190. }
  4191. setScalar(t) {
  4192. return this.x = t, this.y = t, this;
  4193. }
  4194. setX(t) {
  4195. return this.x = t, this;
  4196. }
  4197. setY(t) {
  4198. return this.y = t, this;
  4199. }
  4200. setComponent(t, e) {
  4201. switch (t) {
  4202. case 0:
  4203. this.x = e;
  4204. break;
  4205. case 1:
  4206. this.y = e;
  4207. break;
  4208. default:
  4209. throw new Error("index is out of range: " + t);
  4210. }
  4211. return this;
  4212. }
  4213. getComponent(t) {
  4214. switch (t) {
  4215. case 0:
  4216. return this.x;
  4217. case 1:
  4218. return this.y;
  4219. default:
  4220. throw new Error("index is out of range: " + t);
  4221. }
  4222. }
  4223. clone() {
  4224. return new this.constructor(this.x, this.y);
  4225. }
  4226. copy(t) {
  4227. return this.x = t.x, this.y = t.y, this;
  4228. }
  4229. add(t) {
  4230. return this.x += t.x, this.y += t.y, this;
  4231. }
  4232. addScalar(t) {
  4233. return this.x += t, this.y += t, this;
  4234. }
  4235. addVectors(t, e) {
  4236. return this.x = t.x + e.x, this.y = t.y + e.y, this;
  4237. }
  4238. addScaledVector(t, e) {
  4239. return this.x += t.x * e, this.y += t.y * e, this;
  4240. }
  4241. sub(t) {
  4242. return this.x -= t.x, this.y -= t.y, this;
  4243. }
  4244. subScalar(t) {
  4245. return this.x -= t, this.y -= t, this;
  4246. }
  4247. subVectors(t, e) {
  4248. return this.x = t.x - e.x, this.y = t.y - e.y, this;
  4249. }
  4250. multiply(t) {
  4251. return this.x *= t.x, this.y *= t.y, this;
  4252. }
  4253. multiplyScalar(t) {
  4254. return this.x *= t, this.y *= t, this;
  4255. }
  4256. divide(t) {
  4257. return this.x /= t.x, this.y /= t.y, this;
  4258. }
  4259. divideScalar(t) {
  4260. return this.multiplyScalar(1 / t);
  4261. }
  4262. applyMatrix3(t) {
  4263. const e = this.x, i = this.y, n = t.elements;
  4264. return this.x = n[0] * e + n[3] * i + n[6], this.y = n[1] * e + n[4] * i + n[7], this;
  4265. }
  4266. min(t) {
  4267. return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this;
  4268. }
  4269. max(t) {
  4270. return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this;
  4271. }
  4272. clamp(t, e) {
  4273. return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this;
  4274. }
  4275. clampScalar(t, e) {
  4276. return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this;
  4277. }
  4278. clampLength(t, e) {
  4279. const i = this.length();
  4280. return this.divideScalar(i || 1).multiplyScalar(Math.max(t, Math.min(e, i)));
  4281. }
  4282. floor() {
  4283. return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;
  4284. }
  4285. ceil() {
  4286. return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;
  4287. }
  4288. round() {
  4289. return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
  4290. }
  4291. roundToZero() {
  4292. return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;
  4293. }
  4294. negate() {
  4295. return this.x = -this.x, this.y = -this.y, this;
  4296. }
  4297. dot(t) {
  4298. return this.x * t.x + this.y * t.y;
  4299. }
  4300. cross(t) {
  4301. return this.x * t.y - this.y * t.x;
  4302. }
  4303. lengthSq() {
  4304. return this.x * this.x + this.y * this.y;
  4305. }
  4306. length() {
  4307. return Math.sqrt(this.x * this.x + this.y * this.y);
  4308. }
  4309. manhattanLength() {
  4310. return Math.abs(this.x) + Math.abs(this.y);
  4311. }
  4312. normalize() {
  4313. return this.divideScalar(this.length() || 1);
  4314. }
  4315. angle() {
  4316. return Math.atan2(-this.y, -this.x) + Math.PI;
  4317. }
  4318. angleTo(t) {
  4319. const e = Math.sqrt(this.lengthSq() * t.lengthSq());
  4320. if (e === 0)
  4321. return Math.PI / 2;
  4322. const i = this.dot(t) / e;
  4323. return Math.acos(mt(i, -1, 1));
  4324. }
  4325. distanceTo(t) {
  4326. return Math.sqrt(this.distanceToSquared(t));
  4327. }
  4328. distanceToSquared(t) {
  4329. const e = this.x - t.x, i = this.y - t.y;
  4330. return e * e + i * i;
  4331. }
  4332. manhattanDistanceTo(t) {
  4333. return Math.abs(this.x - t.x) + Math.abs(this.y - t.y);
  4334. }
  4335. setLength(t) {
  4336. return this.normalize().multiplyScalar(t);
  4337. }
  4338. lerp(t, e) {
  4339. return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this;
  4340. }
  4341. lerpVectors(t, e, i) {
  4342. return this.x = t.x + (e.x - t.x) * i, this.y = t.y + (e.y - t.y) * i, this;
  4343. }
  4344. equals(t) {
  4345. return t.x === this.x && t.y === this.y;
  4346. }
  4347. fromArray(t, e = 0) {
  4348. return this.x = t[e], this.y = t[e + 1], this;
  4349. }
  4350. toArray(t = [], e = 0) {
  4351. return t[e] = this.x, t[e + 1] = this.y, t;
  4352. }
  4353. fromBufferAttribute(t, e) {
  4354. return this.x = t.getX(e), this.y = t.getY(e), this;
  4355. }
  4356. rotateAround(t, e) {
  4357. const i = Math.cos(e), n = Math.sin(e), r = this.x - t.x, a = this.y - t.y;
  4358. return this.x = r * i - a * n + t.x, this.y = r * n + a * i + t.y, this;
  4359. }
  4360. random() {
  4361. return this.x = Math.random(), this.y = Math.random(), this;
  4362. }
  4363. *[Symbol.iterator]() {
  4364. yield this.x, yield this.y;
  4365. }
  4366. }
  4367. class Jt {
  4368. constructor(t, e, i, n, r, a, o, h, l) {
  4369. Jt.prototype.isMatrix3 = !0, this.elements = [
  4370. 1,
  4371. 0,
  4372. 0,
  4373. 0,
  4374. 1,
  4375. 0,
  4376. 0,
  4377. 0,
  4378. 1
  4379. ], t !== void 0 && this.set(t, e, i, n, r, a, o, h, l);
  4380. }
  4381. set(t, e, i, n, r, a, o, h, l) {
  4382. const A = this.elements;
  4383. return A[0] = t, A[1] = n, A[2] = o, A[3] = e, A[4] = r, A[5] = h, A[6] = i, A[7] = a, A[8] = l, this;
  4384. }
  4385. identity() {
  4386. return this.set(
  4387. 1,
  4388. 0,
  4389. 0,
  4390. 0,
  4391. 1,
  4392. 0,
  4393. 0,
  4394. 0,
  4395. 1
  4396. ), this;
  4397. }
  4398. copy(t) {
  4399. const e = this.elements, i = t.elements;
  4400. return e[0] = i[0], e[1] = i[1], e[2] = i[2], e[3] = i[3], e[4] = i[4], e[5] = i[5], e[6] = i[6], e[7] = i[7], e[8] = i[8], this;
  4401. }
  4402. extractBasis(t, e, i) {
  4403. return t.setFromMatrix3Column(this, 0), e.setFromMatrix3Column(this, 1), i.setFromMatrix3Column(this, 2), this;
  4404. }
  4405. setFromMatrix4(t) {
  4406. const e = t.elements;
  4407. return this.set(
  4408. e[0],
  4409. e[4],
  4410. e[8],
  4411. e[1],
  4412. e[5],
  4413. e[9],
  4414. e[2],
  4415. e[6],
  4416. e[10]
  4417. ), this;
  4418. }
  4419. multiply(t) {
  4420. return this.multiplyMatrices(this, t);
  4421. }
  4422. premultiply(t) {
  4423. return this.multiplyMatrices(t, this);
  4424. }
  4425. multiplyMatrices(t, e) {
  4426. const i = t.elements, n = e.elements, r = this.elements, a = i[0], o = i[3], h = i[6], l = i[1], A = i[4], u = i[7], f = i[2], c = i[5], d = i[8], p = n[0], m = n[3], v = n[6], _ = n[1], g = n[4], y = n[7], x = n[2], b = n[5], C = n[8];
  4427. return r[0] = a * p + o * _ + h * x, r[3] = a * m + o * g + h * b, r[6] = a * v + o * y + h * C, r[1] = l * p + A * _ + u * x, r[4] = l * m + A * g + u * b, r[7] = l * v + A * y + u * C, r[2] = f * p + c * _ + d * x, r[5] = f * m + c * g + d * b, r[8] = f * v + c * y + d * C, this;
  4428. }
  4429. multiplyScalar(t) {
  4430. const e = this.elements;
  4431. return e[0] *= t, e[3] *= t, e[6] *= t, e[1] *= t, e[4] *= t, e[7] *= t, e[2] *= t, e[5] *= t, e[8] *= t, this;
  4432. }
  4433. determinant() {
  4434. const t = this.elements, e = t[0], i = t[1], n = t[2], r = t[3], a = t[4], o = t[5], h = t[6], l = t[7], A = t[8];
  4435. return e * a * A - e * o * l - i * r * A + i * o * h + n * r * l - n * a * h;
  4436. }
  4437. invert() {
  4438. const t = this.elements, e = t[0], i = t[1], n = t[2], r = t[3], a = t[4], o = t[5], h = t[6], l = t[7], A = t[8], u = A * a - o * l, f = o * h - A * r, c = l * r - a * h, d = e * u + i * f + n * c;
  4439. if (d === 0)
  4440. return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
  4441. const p = 1 / d;
  4442. return t[0] = u * p, t[1] = (n * l - A * i) * p, t[2] = (o * i - n * a) * p, t[3] = f * p, t[4] = (A * e - n * h) * p, t[5] = (n * r - o * e) * p, t[6] = c * p, t[7] = (i * h - l * e) * p, t[8] = (a * e - i * r) * p, this;
  4443. }
  4444. transpose() {
  4445. let t;
  4446. const e = this.elements;
  4447. return t = e[1], e[1] = e[3], e[3] = t, t = e[2], e[2] = e[6], e[6] = t, t = e[5], e[5] = e[7], e[7] = t, this;
  4448. }
  4449. getNormalMatrix(t) {
  4450. return this.setFromMatrix4(t).invert().transpose();
  4451. }
  4452. transposeIntoArray(t) {
  4453. const e = this.elements;
  4454. return t[0] = e[0], t[1] = e[3], t[2] = e[6], t[3] = e[1], t[4] = e[4], t[5] = e[7], t[6] = e[2], t[7] = e[5], t[8] = e[8], this;
  4455. }
  4456. setUvTransform(t, e, i, n, r, a, o) {
  4457. const h = Math.cos(r), l = Math.sin(r);
  4458. return this.set(
  4459. i * h,
  4460. i * l,
  4461. -i * (h * a + l * o) + a + t,
  4462. -n * l,
  4463. n * h,
  4464. -n * (-l * a + h * o) + o + e,
  4465. 0,
  4466. 0,
  4467. 1
  4468. ), this;
  4469. }
  4470. //
  4471. scale(t, e) {
  4472. return this.premultiply(Ms.makeScale(t, e)), this;
  4473. }
  4474. rotate(t) {
  4475. return this.premultiply(Ms.makeRotation(-t)), this;
  4476. }
  4477. translate(t, e) {
  4478. return this.premultiply(Ms.makeTranslation(t, e)), this;
  4479. }
  4480. // for 2D Transforms
  4481. makeTranslation(t, e) {
  4482. return t.isVector2 ? this.set(
  4483. 1,
  4484. 0,
  4485. t.x,
  4486. 0,
  4487. 1,
  4488. t.y,
  4489. 0,
  4490. 0,
  4491. 1
  4492. ) : this.set(
  4493. 1,
  4494. 0,
  4495. t,
  4496. 0,
  4497. 1,
  4498. e,
  4499. 0,
  4500. 0,
  4501. 1
  4502. ), this;
  4503. }
  4504. makeRotation(t) {
  4505. const e = Math.cos(t), i = Math.sin(t);
  4506. return this.set(
  4507. e,
  4508. -i,
  4509. 0,
  4510. i,
  4511. e,
  4512. 0,
  4513. 0,
  4514. 0,
  4515. 1
  4516. ), this;
  4517. }
  4518. makeScale(t, e) {
  4519. return this.set(
  4520. t,
  4521. 0,
  4522. 0,
  4523. 0,
  4524. e,
  4525. 0,
  4526. 0,
  4527. 0,
  4528. 1
  4529. ), this;
  4530. }
  4531. //
  4532. equals(t) {
  4533. const e = this.elements, i = t.elements;
  4534. for (let n = 0; n < 9; n++)
  4535. if (e[n] !== i[n])
  4536. return !1;
  4537. return !0;
  4538. }
  4539. fromArray(t, e = 0) {
  4540. for (let i = 0; i < 9; i++)
  4541. this.elements[i] = t[i + e];
  4542. return this;
  4543. }
  4544. toArray(t = [], e = 0) {
  4545. const i = this.elements;
  4546. return t[e] = i[0], t[e + 1] = i[1], t[e + 2] = i[2], t[e + 3] = i[3], t[e + 4] = i[4], t[e + 5] = i[5], t[e + 6] = i[6], t[e + 7] = i[7], t[e + 8] = i[8], t;
  4547. }
  4548. clone() {
  4549. return new this.constructor().fromArray(this.elements);
  4550. }
  4551. }
  4552. const Ms = /* @__PURE__ */ new Jt();
  4553. function ia(s) {
  4554. return document.createElementNS("http://www.w3.org/1999/xhtml", s);
  4555. }
  4556. const na = /* @__PURE__ */ new Jt().set(
  4557. 0.8224621,
  4558. 0.177538,
  4559. 0,
  4560. 0.0331941,
  4561. 0.9668058,
  4562. 0,
  4563. 0.0170827,
  4564. 0.0723974,
  4565. 0.9105199
  4566. ), sa = /* @__PURE__ */ new Jt().set(
  4567. 1.2249401,
  4568. -0.2249404,
  4569. 0,
  4570. -0.0420569,
  4571. 1.0420571,
  4572. 0,
  4573. -0.0196376,
  4574. -0.0786361,
  4575. 1.0982735
  4576. ), ji = {
  4577. [dr]: {
  4578. transfer: Qs,
  4579. primaries: Zr,
  4580. toReference: (s) => s,
  4581. fromReference: (s) => s
  4582. },
  4583. [le]: {
  4584. transfer: Kr,
  4585. primaries: Zr,
  4586. toReference: (s) => s.convertSRGBToLinear(),
  4587. fromReference: (s) => s.convertLinearToSRGB()
  4588. },
  4589. [Ao]: {
  4590. transfer: Qs,
  4591. primaries: Jr,
  4592. toReference: (s) => s.applyMatrix3(sa),
  4593. fromReference: (s) => s.applyMatrix3(na)
  4594. },
  4595. [Tl]: {
  4596. transfer: Kr,
  4597. primaries: Jr,
  4598. toReference: (s) => s.convertSRGBToLinear().applyMatrix3(sa),
  4599. fromReference: (s) => s.applyMatrix3(na).convertLinearToSRGB()
  4600. }
  4601. }, Jl = /* @__PURE__ */ new Set([dr, Ao]), Ft = {
  4602. enabled: !0,
  4603. _workingColorSpace: dr,
  4604. get workingColorSpace() {
  4605. return this._workingColorSpace;
  4606. },
  4607. set workingColorSpace(s) {
  4608. if (!Jl.has(s))
  4609. throw new Error(`Unsupported working color space, "${s}".`);
  4610. this._workingColorSpace = s;
  4611. },
  4612. convert: function(s, t, e) {
  4613. if (this.enabled === !1 || t === e || !t || !e)
  4614. return s;
  4615. const i = ji[t].toReference, n = ji[e].fromReference;
  4616. return n(i(s));
  4617. },
  4618. fromWorkingColorSpace: function(s, t) {
  4619. return this.convert(s, this._workingColorSpace, t);
  4620. },
  4621. toWorkingColorSpace: function(s, t) {
  4622. return this.convert(s, t, this._workingColorSpace);
  4623. },
  4624. getPrimaries: function(s) {
  4625. return ji[s].primaries;
  4626. },
  4627. getTransfer: function(s) {
  4628. return s === lo ? Qs : ji[s].transfer;
  4629. }
  4630. };
  4631. function Qe(s) {
  4632. return s < 0.04045 ? s * 0.0773993808 : Math.pow(s * 0.9478672986 + 0.0521327014, 2.4);
  4633. }
  4634. function Ps(s) {
  4635. return s < 31308e-7 ? s * 12.92 : 1.055 * Math.pow(s, 0.41666) - 0.055;
  4636. }
  4637. let Be;
  4638. class tA {
  4639. static getDataURL(t) {
  4640. if (/^data:/i.test(t.src) || typeof HTMLCanvasElement > "u")
  4641. return t.src;
  4642. let e;
  4643. if (t instanceof HTMLCanvasElement)
  4644. e = t;
  4645. else {
  4646. Be === void 0 && (Be = ia("canvas")), Be.width = t.width, Be.height = t.height;
  4647. const i = Be.getContext("2d");
  4648. t instanceof ImageData ? i.putImageData(t, 0, 0) : i.drawImage(t, 0, 0, t.width, t.height), e = Be;
  4649. }
  4650. return e.width > 2048 || e.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", t), e.toDataURL("image/jpeg", 0.6)) : e.toDataURL("image/png");
  4651. }
  4652. static sRGBToLinear(t) {
  4653. if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap) {
  4654. const e = ia("canvas");
  4655. e.width = t.width, e.height = t.height;
  4656. const i = e.getContext("2d");
  4657. i.drawImage(t, 0, 0, t.width, t.height);
  4658. const n = i.getImageData(0, 0, t.width, t.height), r = n.data;
  4659. for (let a = 0; a < r.length; a++)
  4660. r[a] = Qe(r[a] / 255) * 255;
  4661. return i.putImageData(n, 0, 0), e;
  4662. } else if (t.data) {
  4663. const e = t.data.slice(0);
  4664. for (let i = 0; i < e.length; i++)
  4665. e instanceof Uint8Array || e instanceof Uint8ClampedArray ? e[i] = Math.floor(Qe(e[i] / 255) * 255) : e[i] = Qe(e[i]);
  4666. return {
  4667. data: e,
  4668. width: t.width,
  4669. height: t.height
  4670. };
  4671. } else
  4672. return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), t;
  4673. }
  4674. }
  4675. let eA = 0;
  4676. class iA {
  4677. constructor(t = null) {
  4678. this.isSource = !0, Object.defineProperty(this, "id", { value: eA++ }), this.uuid = Tn(), this.data = t, this.dataReady = !0, this.version = 0;
  4679. }
  4680. set needsUpdate(t) {
  4681. t === !0 && this.version++;
  4682. }
  4683. toJSON(t) {
  4684. const e = t === void 0 || typeof t == "string";
  4685. if (!e && t.images[this.uuid] !== void 0)
  4686. return t.images[this.uuid];
  4687. const i = {
  4688. uuid: this.uuid,
  4689. url: ""
  4690. }, n = this.data;
  4691. if (n !== null) {
  4692. let r;
  4693. if (Array.isArray(n)) {
  4694. r = [];
  4695. for (let a = 0, o = n.length; a < o; a++)
  4696. n[a].isDataTexture ? r.push(Es(n[a].image)) : r.push(Es(n[a]));
  4697. } else
  4698. r = Es(n);
  4699. i.url = r;
  4700. }
  4701. return e || (t.images[this.uuid] = i), i;
  4702. }
  4703. }
  4704. function Es(s) {
  4705. return typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap ? tA.getDataURL(s) : s.data ? {
  4706. data: Array.from(s.data),
  4707. width: s.width,
  4708. height: s.height,
  4709. type: s.data.constructor.name
  4710. } : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
  4711. }
  4712. let nA = 0;
  4713. class Ae extends co {
  4714. constructor(t = Ae.DEFAULT_IMAGE, e = Ae.DEFAULT_MAPPING, i = Yi, n = Yi, r = Pl, a = El, o = Il, h = Fl, l = Ae.DEFAULT_ANISOTROPY, A = lo) {
  4715. super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: nA++ }), this.uuid = Tn(), this.name = "", this.source = new iA(t), this.mipmaps = [], this.mapping = e, this.channel = 0, this.wrapS = i, this.wrapT = n, this.magFilter = r, this.minFilter = a, this.anisotropy = l, this.format = o, this.internalFormat = null, this.type = h, this.offset = new X(0, 0), this.repeat = new X(1, 1), this.center = new X(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new Jt(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = A, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.pmremVersion = 0;
  4716. }
  4717. get image() {
  4718. return this.source.data;
  4719. }
  4720. set image(t = null) {
  4721. this.source.data = t;
  4722. }
  4723. updateMatrix() {
  4724. this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
  4725. }
  4726. clone() {
  4727. return new this.constructor().copy(this);
  4728. }
  4729. copy(t) {
  4730. return this.name = t.name, this.source = t.source, this.mipmaps = t.mipmaps.slice(0), this.mapping = t.mapping, this.channel = t.channel, this.wrapS = t.wrapS, this.wrapT = t.wrapT, this.magFilter = t.magFilter, this.minFilter = t.minFilter, this.anisotropy = t.anisotropy, this.format = t.format, this.internalFormat = t.internalFormat, this.type = t.type, this.offset.copy(t.offset), this.repeat.copy(t.repeat), this.center.copy(t.center), this.rotation = t.rotation, this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrix.copy(t.matrix), this.generateMipmaps = t.generateMipmaps, this.premultiplyAlpha = t.premultiplyAlpha, this.flipY = t.flipY, this.unpackAlignment = t.unpackAlignment, this.colorSpace = t.colorSpace, this.userData = JSON.parse(JSON.stringify(t.userData)), this.needsUpdate = !0, this;
  4731. }
  4732. toJSON(t) {
  4733. const e = t === void 0 || typeof t == "string";
  4734. if (!e && t.textures[this.uuid] !== void 0)
  4735. return t.textures[this.uuid];
  4736. const i = {
  4737. metadata: {
  4738. version: 4.6,
  4739. type: "Texture",
  4740. generator: "Texture.toJSON"
  4741. },
  4742. uuid: this.uuid,
  4743. name: this.name,
  4744. image: this.source.toJSON(t).uuid,
  4745. mapping: this.mapping,
  4746. channel: this.channel,
  4747. repeat: [this.repeat.x, this.repeat.y],
  4748. offset: [this.offset.x, this.offset.y],
  4749. center: [this.center.x, this.center.y],
  4750. rotation: this.rotation,
  4751. wrap: [this.wrapS, this.wrapT],
  4752. format: this.format,
  4753. internalFormat: this.internalFormat,
  4754. type: this.type,
  4755. colorSpace: this.colorSpace,
  4756. minFilter: this.minFilter,
  4757. magFilter: this.magFilter,
  4758. anisotropy: this.anisotropy,
  4759. flipY: this.flipY,
  4760. generateMipmaps: this.generateMipmaps,
  4761. premultiplyAlpha: this.premultiplyAlpha,
  4762. unpackAlignment: this.unpackAlignment
  4763. };
  4764. return Object.keys(this.userData).length > 0 && (i.userData = this.userData), e || (t.textures[this.uuid] = i), i;
  4765. }
  4766. dispose() {
  4767. this.dispatchEvent({ type: "dispose" });
  4768. }
  4769. transformUv(t) {
  4770. if (this.mapping !== ho)
  4771. return t;
  4772. if (t.applyMatrix3(this.matrix), t.x < 0 || t.x > 1)
  4773. switch (this.wrapS) {
  4774. case Xr:
  4775. t.x = t.x - Math.floor(t.x);
  4776. break;
  4777. case Yi:
  4778. t.x = t.x < 0 ? 0 : 1;
  4779. break;
  4780. case jr:
  4781. Math.abs(Math.floor(t.x) % 2) === 1 ? t.x = Math.ceil(t.x) - t.x : t.x = t.x - Math.floor(t.x);
  4782. break;
  4783. }
  4784. if (t.y < 0 || t.y > 1)
  4785. switch (this.wrapT) {
  4786. case Xr:
  4787. t.y = t.y - Math.floor(t.y);
  4788. break;
  4789. case Yi:
  4790. t.y = t.y < 0 ? 0 : 1;
  4791. break;
  4792. case jr:
  4793. Math.abs(Math.floor(t.y) % 2) === 1 ? t.y = Math.ceil(t.y) - t.y : t.y = t.y - Math.floor(t.y);
  4794. break;
  4795. }
  4796. return this.flipY && (t.y = 1 - t.y), t;
  4797. }
  4798. set needsUpdate(t) {
  4799. t === !0 && (this.version++, this.source.needsUpdate = !0);
  4800. }
  4801. set needsPMREMUpdate(t) {
  4802. t === !0 && this.pmremVersion++;
  4803. }
  4804. }
  4805. Ae.DEFAULT_IMAGE = null;
  4806. Ae.DEFAULT_MAPPING = ho;
  4807. Ae.DEFAULT_ANISOTROPY = 1;
  4808. class ci {
  4809. constructor(t = 0, e = 0, i = 0, n = 1) {
  4810. this.isQuaternion = !0, this._x = t, this._y = e, this._z = i, this._w = n;
  4811. }
  4812. static slerpFlat(t, e, i, n, r, a, o) {
  4813. let h = i[n + 0], l = i[n + 1], A = i[n + 2], u = i[n + 3];
  4814. const f = r[a + 0], c = r[a + 1], d = r[a + 2], p = r[a + 3];
  4815. if (o === 0) {
  4816. t[e + 0] = h, t[e + 1] = l, t[e + 2] = A, t[e + 3] = u;
  4817. return;
  4818. }
  4819. if (o === 1) {
  4820. t[e + 0] = f, t[e + 1] = c, t[e + 2] = d, t[e + 3] = p;
  4821. return;
  4822. }
  4823. if (u !== p || h !== f || l !== c || A !== d) {
  4824. let m = 1 - o;
  4825. const v = h * f + l * c + A * d + u * p, _ = v >= 0 ? 1 : -1, g = 1 - v * v;
  4826. if (g > Number.EPSILON) {
  4827. const x = Math.sqrt(g), b = Math.atan2(x, v * _);
  4828. m = Math.sin(m * b) / x, o = Math.sin(o * b) / x;
  4829. }
  4830. const y = o * _;
  4831. if (h = h * m + f * y, l = l * m + c * y, A = A * m + d * y, u = u * m + p * y, m === 1 - o) {
  4832. const x = 1 / Math.sqrt(h * h + l * l + A * A + u * u);
  4833. h *= x, l *= x, A *= x, u *= x;
  4834. }
  4835. }
  4836. t[e] = h, t[e + 1] = l, t[e + 2] = A, t[e + 3] = u;
  4837. }
  4838. static multiplyQuaternionsFlat(t, e, i, n, r, a) {
  4839. const o = i[n], h = i[n + 1], l = i[n + 2], A = i[n + 3], u = r[a], f = r[a + 1], c = r[a + 2], d = r[a + 3];
  4840. return t[e] = o * d + A * u + h * c - l * f, t[e + 1] = h * d + A * f + l * u - o * c, t[e + 2] = l * d + A * c + o * f - h * u, t[e + 3] = A * d - o * u - h * f - l * c, t;
  4841. }
  4842. get x() {
  4843. return this._x;
  4844. }
  4845. set x(t) {
  4846. this._x = t, this._onChangeCallback();
  4847. }
  4848. get y() {
  4849. return this._y;
  4850. }
  4851. set y(t) {
  4852. this._y = t, this._onChangeCallback();
  4853. }
  4854. get z() {
  4855. return this._z;
  4856. }
  4857. set z(t) {
  4858. this._z = t, this._onChangeCallback();
  4859. }
  4860. get w() {
  4861. return this._w;
  4862. }
  4863. set w(t) {
  4864. this._w = t, this._onChangeCallback();
  4865. }
  4866. set(t, e, i, n) {
  4867. return this._x = t, this._y = e, this._z = i, this._w = n, this._onChangeCallback(), this;
  4868. }
  4869. clone() {
  4870. return new this.constructor(this._x, this._y, this._z, this._w);
  4871. }
  4872. copy(t) {
  4873. return this._x = t.x, this._y = t.y, this._z = t.z, this._w = t.w, this._onChangeCallback(), this;
  4874. }
  4875. setFromEuler(t, e = !0) {
  4876. const i = t._x, n = t._y, r = t._z, a = t._order, o = Math.cos, h = Math.sin, l = o(i / 2), A = o(n / 2), u = o(r / 2), f = h(i / 2), c = h(n / 2), d = h(r / 2);
  4877. switch (a) {
  4878. case "XYZ":
  4879. this._x = f * A * u + l * c * d, this._y = l * c * u - f * A * d, this._z = l * A * d + f * c * u, this._w = l * A * u - f * c * d;
  4880. break;
  4881. case "YXZ":
  4882. this._x = f * A * u + l * c * d, this._y = l * c * u - f * A * d, this._z = l * A * d - f * c * u, this._w = l * A * u + f * c * d;
  4883. break;
  4884. case "ZXY":
  4885. this._x = f * A * u - l * c * d, this._y = l * c * u + f * A * d, this._z = l * A * d + f * c * u, this._w = l * A * u - f * c * d;
  4886. break;
  4887. case "ZYX":
  4888. this._x = f * A * u - l * c * d, this._y = l * c * u + f * A * d, this._z = l * A * d - f * c * u, this._w = l * A * u + f * c * d;
  4889. break;
  4890. case "YZX":
  4891. this._x = f * A * u + l * c * d, this._y = l * c * u + f * A * d, this._z = l * A * d - f * c * u, this._w = l * A * u - f * c * d;
  4892. break;
  4893. case "XZY":
  4894. this._x = f * A * u - l * c * d, this._y = l * c * u - f * A * d, this._z = l * A * d + f * c * u, this._w = l * A * u + f * c * d;
  4895. break;
  4896. default:
  4897. console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + a);
  4898. }
  4899. return e === !0 && this._onChangeCallback(), this;
  4900. }
  4901. setFromAxisAngle(t, e) {
  4902. const i = e / 2, n = Math.sin(i);
  4903. return this._x = t.x * n, this._y = t.y * n, this._z = t.z * n, this._w = Math.cos(i), this._onChangeCallback(), this;
  4904. }
  4905. setFromRotationMatrix(t) {
  4906. const e = t.elements, i = e[0], n = e[4], r = e[8], a = e[1], o = e[5], h = e[9], l = e[2], A = e[6], u = e[10], f = i + o + u;
  4907. if (f > 0) {
  4908. const c = 0.5 / Math.sqrt(f + 1);
  4909. this._w = 0.25 / c, this._x = (A - h) * c, this._y = (r - l) * c, this._z = (a - n) * c;
  4910. } else if (i > o && i > u) {
  4911. const c = 2 * Math.sqrt(1 + i - o - u);
  4912. this._w = (A - h) / c, this._x = 0.25 * c, this._y = (n + a) / c, this._z = (r + l) / c;
  4913. } else if (o > u) {
  4914. const c = 2 * Math.sqrt(1 + o - i - u);
  4915. this._w = (r - l) / c, this._x = (n + a) / c, this._y = 0.25 * c, this._z = (h + A) / c;
  4916. } else {
  4917. const c = 2 * Math.sqrt(1 + u - i - o);
  4918. this._w = (a - n) / c, this._x = (r + l) / c, this._y = (h + A) / c, this._z = 0.25 * c;
  4919. }
  4920. return this._onChangeCallback(), this;
  4921. }
  4922. setFromUnitVectors(t, e) {
  4923. let i = t.dot(e) + 1;
  4924. return i < Number.EPSILON ? (i = 0, Math.abs(t.x) > Math.abs(t.z) ? (this._x = -t.y, this._y = t.x, this._z = 0, this._w = i) : (this._x = 0, this._y = -t.z, this._z = t.y, this._w = i)) : (this._x = t.y * e.z - t.z * e.y, this._y = t.z * e.x - t.x * e.z, this._z = t.x * e.y - t.y * e.x, this._w = i), this.normalize();
  4925. }
  4926. angleTo(t) {
  4927. return 2 * Math.acos(Math.abs(mt(this.dot(t), -1, 1)));
  4928. }
  4929. rotateTowards(t, e) {
  4930. const i = this.angleTo(t);
  4931. if (i === 0)
  4932. return this;
  4933. const n = Math.min(1, e / i);
  4934. return this.slerp(t, n), this;
  4935. }
  4936. identity() {
  4937. return this.set(0, 0, 0, 1);
  4938. }
  4939. invert() {
  4940. return this.conjugate();
  4941. }
  4942. conjugate() {
  4943. return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
  4944. }
  4945. dot(t) {
  4946. return this._x * t._x + this._y * t._y + this._z * t._z + this._w * t._w;
  4947. }
  4948. lengthSq() {
  4949. return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
  4950. }
  4951. length() {
  4952. return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
  4953. }
  4954. normalize() {
  4955. let t = this.length();
  4956. return t === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (t = 1 / t, this._x = this._x * t, this._y = this._y * t, this._z = this._z * t, this._w = this._w * t), this._onChangeCallback(), this;
  4957. }
  4958. multiply(t) {
  4959. return this.multiplyQuaternions(this, t);
  4960. }
  4961. premultiply(t) {
  4962. return this.multiplyQuaternions(t, this);
  4963. }
  4964. multiplyQuaternions(t, e) {
  4965. const i = t._x, n = t._y, r = t._z, a = t._w, o = e._x, h = e._y, l = e._z, A = e._w;
  4966. return this._x = i * A + a * o + n * l - r * h, this._y = n * A + a * h + r * o - i * l, this._z = r * A + a * l + i * h - n * o, this._w = a * A - i * o - n * h - r * l, this._onChangeCallback(), this;
  4967. }
  4968. slerp(t, e) {
  4969. if (e === 0)
  4970. return this;
  4971. if (e === 1)
  4972. return this.copy(t);
  4973. const i = this._x, n = this._y, r = this._z, a = this._w;
  4974. let o = a * t._w + i * t._x + n * t._y + r * t._z;
  4975. if (o < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, o = -o) : this.copy(t), o >= 1)
  4976. return this._w = a, this._x = i, this._y = n, this._z = r, this;
  4977. const h = 1 - o * o;
  4978. if (h <= Number.EPSILON) {
  4979. const c = 1 - e;
  4980. return this._w = c * a + e * this._w, this._x = c * i + e * this._x, this._y = c * n + e * this._y, this._z = c * r + e * this._z, this.normalize(), this;
  4981. }
  4982. const l = Math.sqrt(h), A = Math.atan2(l, o), u = Math.sin((1 - e) * A) / l, f = Math.sin(e * A) / l;
  4983. return this._w = a * u + this._w * f, this._x = i * u + this._x * f, this._y = n * u + this._y * f, this._z = r * u + this._z * f, this._onChangeCallback(), this;
  4984. }
  4985. slerpQuaternions(t, e, i) {
  4986. return this.copy(t).slerp(e, i);
  4987. }
  4988. random() {
  4989. const t = 2 * Math.PI * Math.random(), e = 2 * Math.PI * Math.random(), i = Math.random(), n = Math.sqrt(1 - i), r = Math.sqrt(i);
  4990. return this.set(
  4991. n * Math.sin(t),
  4992. n * Math.cos(t),
  4993. r * Math.sin(e),
  4994. r * Math.cos(e)
  4995. );
  4996. }
  4997. equals(t) {
  4998. return t._x === this._x && t._y === this._y && t._z === this._z && t._w === this._w;
  4999. }
  5000. fromArray(t, e = 0) {
  5001. return this._x = t[e], this._y = t[e + 1], this._z = t[e + 2], this._w = t[e + 3], this._onChangeCallback(), this;
  5002. }
  5003. toArray(t = [], e = 0) {
  5004. return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._w, t;
  5005. }
  5006. fromBufferAttribute(t, e) {
  5007. return this._x = t.getX(e), this._y = t.getY(e), this._z = t.getZ(e), this._w = t.getW(e), this._onChangeCallback(), this;
  5008. }
  5009. toJSON() {
  5010. return this.toArray();
  5011. }
  5012. _onChange(t) {
  5013. return this._onChangeCallback = t, this;
  5014. }
  5015. _onChangeCallback() {
  5016. }
  5017. *[Symbol.iterator]() {
  5018. yield this._x, yield this._y, yield this._z, yield this._w;
  5019. }
  5020. }
  5021. class j {
  5022. constructor(t = 0, e = 0, i = 0) {
  5023. j.prototype.isVector3 = !0, this.x = t, this.y = e, this.z = i;
  5024. }
  5025. set(t, e, i) {
  5026. return i === void 0 && (i = this.z), this.x = t, this.y = e, this.z = i, this;
  5027. }
  5028. setScalar(t) {
  5029. return this.x = t, this.y = t, this.z = t, this;
  5030. }
  5031. setX(t) {
  5032. return this.x = t, this;
  5033. }
  5034. setY(t) {
  5035. return this.y = t, this;
  5036. }
  5037. setZ(t) {
  5038. return this.z = t, this;
  5039. }
  5040. setComponent(t, e) {
  5041. switch (t) {
  5042. case 0:
  5043. this.x = e;
  5044. break;
  5045. case 1:
  5046. this.y = e;
  5047. break;
  5048. case 2:
  5049. this.z = e;
  5050. break;
  5051. default:
  5052. throw new Error("index is out of range: " + t);
  5053. }
  5054. return this;
  5055. }
  5056. getComponent(t) {
  5057. switch (t) {
  5058. case 0:
  5059. return this.x;
  5060. case 1:
  5061. return this.y;
  5062. case 2:
  5063. return this.z;
  5064. default:
  5065. throw new Error("index is out of range: " + t);
  5066. }
  5067. }
  5068. clone() {
  5069. return new this.constructor(this.x, this.y, this.z);
  5070. }
  5071. copy(t) {
  5072. return this.x = t.x, this.y = t.y, this.z = t.z, this;
  5073. }
  5074. add(t) {
  5075. return this.x += t.x, this.y += t.y, this.z += t.z, this;
  5076. }
  5077. addScalar(t) {
  5078. return this.x += t, this.y += t, this.z += t, this;
  5079. }
  5080. addVectors(t, e) {
  5081. return this.x = t.x + e.x, this.y = t.y + e.y, this.z = t.z + e.z, this;
  5082. }
  5083. addScaledVector(t, e) {
  5084. return this.x += t.x * e, this.y += t.y * e, this.z += t.z * e, this;
  5085. }
  5086. sub(t) {
  5087. return this.x -= t.x, this.y -= t.y, this.z -= t.z, this;
  5088. }
  5089. subScalar(t) {
  5090. return this.x -= t, this.y -= t, this.z -= t, this;
  5091. }
  5092. subVectors(t, e) {
  5093. return this.x = t.x - e.x, this.y = t.y - e.y, this.z = t.z - e.z, this;
  5094. }
  5095. multiply(t) {
  5096. return this.x *= t.x, this.y *= t.y, this.z *= t.z, this;
  5097. }
  5098. multiplyScalar(t) {
  5099. return this.x *= t, this.y *= t, this.z *= t, this;
  5100. }
  5101. multiplyVectors(t, e) {
  5102. return this.x = t.x * e.x, this.y = t.y * e.y, this.z = t.z * e.z, this;
  5103. }
  5104. applyEuler(t) {
  5105. return this.applyQuaternion(ra.setFromEuler(t));
  5106. }
  5107. applyAxisAngle(t, e) {
  5108. return this.applyQuaternion(ra.setFromAxisAngle(t, e));
  5109. }
  5110. applyMatrix3(t) {
  5111. const e = this.x, i = this.y, n = this.z, r = t.elements;
  5112. return this.x = r[0] * e + r[3] * i + r[6] * n, this.y = r[1] * e + r[4] * i + r[7] * n, this.z = r[2] * e + r[5] * i + r[8] * n, this;
  5113. }
  5114. applyNormalMatrix(t) {
  5115. return this.applyMatrix3(t).normalize();
  5116. }
  5117. applyMatrix4(t) {
  5118. const e = this.x, i = this.y, n = this.z, r = t.elements, a = 1 / (r[3] * e + r[7] * i + r[11] * n + r[15]);
  5119. return this.x = (r[0] * e + r[4] * i + r[8] * n + r[12]) * a, this.y = (r[1] * e + r[5] * i + r[9] * n + r[13]) * a, this.z = (r[2] * e + r[6] * i + r[10] * n + r[14]) * a, this;
  5120. }
  5121. applyQuaternion(t) {
  5122. const e = this.x, i = this.y, n = this.z, r = t.x, a = t.y, o = t.z, h = t.w, l = 2 * (a * n - o * i), A = 2 * (o * e - r * n), u = 2 * (r * i - a * e);
  5123. return this.x = e + h * l + a * u - o * A, this.y = i + h * A + o * l - r * u, this.z = n + h * u + r * A - a * l, this;
  5124. }
  5125. project(t) {
  5126. return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix);
  5127. }
  5128. unproject(t) {
  5129. return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld);
  5130. }
  5131. transformDirection(t) {
  5132. const e = this.x, i = this.y, n = this.z, r = t.elements;
  5133. return this.x = r[0] * e + r[4] * i + r[8] * n, this.y = r[1] * e + r[5] * i + r[9] * n, this.z = r[2] * e + r[6] * i + r[10] * n, this.normalize();
  5134. }
  5135. divide(t) {
  5136. return this.x /= t.x, this.y /= t.y, this.z /= t.z, this;
  5137. }
  5138. divideScalar(t) {
  5139. return this.multiplyScalar(1 / t);
  5140. }
  5141. min(t) {
  5142. return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this.z = Math.min(this.z, t.z), this;
  5143. }
  5144. max(t) {
  5145. return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this.z = Math.max(this.z, t.z), this;
  5146. }
  5147. clamp(t, e) {
  5148. return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this.z = Math.max(t.z, Math.min(e.z, this.z)), this;
  5149. }
  5150. clampScalar(t, e) {
  5151. return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this.z = Math.max(t, Math.min(e, this.z)), this;
  5152. }
  5153. clampLength(t, e) {
  5154. const i = this.length();
  5155. return this.divideScalar(i || 1).multiplyScalar(Math.max(t, Math.min(e, i)));
  5156. }
  5157. floor() {
  5158. return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
  5159. }
  5160. ceil() {
  5161. return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;
  5162. }
  5163. round() {
  5164. return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;
  5165. }
  5166. roundToZero() {
  5167. return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;
  5168. }
  5169. negate() {
  5170. return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;
  5171. }
  5172. dot(t) {
  5173. return this.x * t.x + this.y * t.y + this.z * t.z;
  5174. }
  5175. // TODO lengthSquared?
  5176. lengthSq() {
  5177. return this.x * this.x + this.y * this.y + this.z * this.z;
  5178. }
  5179. length() {
  5180. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  5181. }
  5182. manhattanLength() {
  5183. return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
  5184. }
  5185. normalize() {
  5186. return this.divideScalar(this.length() || 1);
  5187. }
  5188. setLength(t) {
  5189. return this.normalize().multiplyScalar(t);
  5190. }
  5191. lerp(t, e) {
  5192. return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this.z += (t.z - this.z) * e, this;
  5193. }
  5194. lerpVectors(t, e, i) {
  5195. return this.x = t.x + (e.x - t.x) * i, this.y = t.y + (e.y - t.y) * i, this.z = t.z + (e.z - t.z) * i, this;
  5196. }
  5197. cross(t) {
  5198. return this.crossVectors(this, t);
  5199. }
  5200. crossVectors(t, e) {
  5201. const i = t.x, n = t.y, r = t.z, a = e.x, o = e.y, h = e.z;
  5202. return this.x = n * h - r * o, this.y = r * a - i * h, this.z = i * o - n * a, this;
  5203. }
  5204. projectOnVector(t) {
  5205. const e = t.lengthSq();
  5206. if (e === 0)
  5207. return this.set(0, 0, 0);
  5208. const i = t.dot(this) / e;
  5209. return this.copy(t).multiplyScalar(i);
  5210. }
  5211. projectOnPlane(t) {
  5212. return Fs.copy(this).projectOnVector(t), this.sub(Fs);
  5213. }
  5214. reflect(t) {
  5215. return this.sub(Fs.copy(t).multiplyScalar(2 * this.dot(t)));
  5216. }
  5217. angleTo(t) {
  5218. const e = Math.sqrt(this.lengthSq() * t.lengthSq());
  5219. if (e === 0)
  5220. return Math.PI / 2;
  5221. const i = this.dot(t) / e;
  5222. return Math.acos(mt(i, -1, 1));
  5223. }
  5224. distanceTo(t) {
  5225. return Math.sqrt(this.distanceToSquared(t));
  5226. }
  5227. distanceToSquared(t) {
  5228. const e = this.x - t.x, i = this.y - t.y, n = this.z - t.z;
  5229. return e * e + i * i + n * n;
  5230. }
  5231. manhattanDistanceTo(t) {
  5232. return Math.abs(this.x - t.x) + Math.abs(this.y - t.y) + Math.abs(this.z - t.z);
  5233. }
  5234. setFromSpherical(t) {
  5235. return this.setFromSphericalCoords(t.radius, t.phi, t.theta);
  5236. }
  5237. setFromSphericalCoords(t, e, i) {
  5238. const n = Math.sin(e) * t;
  5239. return this.x = n * Math.sin(i), this.y = Math.cos(e) * t, this.z = n * Math.cos(i), this;
  5240. }
  5241. setFromCylindrical(t) {
  5242. return this.setFromCylindricalCoords(t.radius, t.theta, t.y);
  5243. }
  5244. setFromCylindricalCoords(t, e, i) {
  5245. return this.x = t * Math.sin(e), this.y = i, this.z = t * Math.cos(e), this;
  5246. }
  5247. setFromMatrixPosition(t) {
  5248. const e = t.elements;
  5249. return this.x = e[12], this.y = e[13], this.z = e[14], this;
  5250. }
  5251. setFromMatrixScale(t) {
  5252. const e = this.setFromMatrixColumn(t, 0).length(), i = this.setFromMatrixColumn(t, 1).length(), n = this.setFromMatrixColumn(t, 2).length();
  5253. return this.x = e, this.y = i, this.z = n, this;
  5254. }
  5255. setFromMatrixColumn(t, e) {
  5256. return this.fromArray(t.elements, e * 4);
  5257. }
  5258. setFromMatrix3Column(t, e) {
  5259. return this.fromArray(t.elements, e * 3);
  5260. }
  5261. setFromEuler(t) {
  5262. return this.x = t._x, this.y = t._y, this.z = t._z, this;
  5263. }
  5264. setFromColor(t) {
  5265. return this.x = t.r, this.y = t.g, this.z = t.b, this;
  5266. }
  5267. equals(t) {
  5268. return t.x === this.x && t.y === this.y && t.z === this.z;
  5269. }
  5270. fromArray(t, e = 0) {
  5271. return this.x = t[e], this.y = t[e + 1], this.z = t[e + 2], this;
  5272. }
  5273. toArray(t = [], e = 0) {
  5274. return t[e] = this.x, t[e + 1] = this.y, t[e + 2] = this.z, t;
  5275. }
  5276. fromBufferAttribute(t, e) {
  5277. return this.x = t.getX(e), this.y = t.getY(e), this.z = t.getZ(e), this;
  5278. }
  5279. random() {
  5280. return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;
  5281. }
  5282. randomDirection() {
  5283. const t = Math.random() * Math.PI * 2, e = Math.random() * 2 - 1, i = Math.sqrt(1 - e * e);
  5284. return this.x = i * Math.cos(t), this.y = e, this.z = i * Math.sin(t), this;
  5285. }
  5286. *[Symbol.iterator]() {
  5287. yield this.x, yield this.y, yield this.z;
  5288. }
  5289. }
  5290. const Fs = /* @__PURE__ */ new j(), ra = /* @__PURE__ */ new ci();
  5291. class ot {
  5292. constructor(t, e, i, n, r, a, o, h, l, A, u, f, c, d, p, m) {
  5293. ot.prototype.isMatrix4 = !0, this.elements = [
  5294. 1,
  5295. 0,
  5296. 0,
  5297. 0,
  5298. 0,
  5299. 1,
  5300. 0,
  5301. 0,
  5302. 0,
  5303. 0,
  5304. 1,
  5305. 0,
  5306. 0,
  5307. 0,
  5308. 0,
  5309. 1
  5310. ], t !== void 0 && this.set(t, e, i, n, r, a, o, h, l, A, u, f, c, d, p, m);
  5311. }
  5312. set(t, e, i, n, r, a, o, h, l, A, u, f, c, d, p, m) {
  5313. const v = this.elements;
  5314. return v[0] = t, v[4] = e, v[8] = i, v[12] = n, v[1] = r, v[5] = a, v[9] = o, v[13] = h, v[2] = l, v[6] = A, v[10] = u, v[14] = f, v[3] = c, v[7] = d, v[11] = p, v[15] = m, this;
  5315. }
  5316. identity() {
  5317. return this.set(
  5318. 1,
  5319. 0,
  5320. 0,
  5321. 0,
  5322. 0,
  5323. 1,
  5324. 0,
  5325. 0,
  5326. 0,
  5327. 0,
  5328. 1,
  5329. 0,
  5330. 0,
  5331. 0,
  5332. 0,
  5333. 1
  5334. ), this;
  5335. }
  5336. clone() {
  5337. return new ot().fromArray(this.elements);
  5338. }
  5339. copy(t) {
  5340. const e = this.elements, i = t.elements;
  5341. return e[0] = i[0], e[1] = i[1], e[2] = i[2], e[3] = i[3], e[4] = i[4], e[5] = i[5], e[6] = i[6], e[7] = i[7], e[8] = i[8], e[9] = i[9], e[10] = i[10], e[11] = i[11], e[12] = i[12], e[13] = i[13], e[14] = i[14], e[15] = i[15], this;
  5342. }
  5343. copyPosition(t) {
  5344. const e = this.elements, i = t.elements;
  5345. return e[12] = i[12], e[13] = i[13], e[14] = i[14], this;
  5346. }
  5347. setFromMatrix3(t) {
  5348. const e = t.elements;
  5349. return this.set(
  5350. e[0],
  5351. e[3],
  5352. e[6],
  5353. 0,
  5354. e[1],
  5355. e[4],
  5356. e[7],
  5357. 0,
  5358. e[2],
  5359. e[5],
  5360. e[8],
  5361. 0,
  5362. 0,
  5363. 0,
  5364. 0,
  5365. 1
  5366. ), this;
  5367. }
  5368. extractBasis(t, e, i) {
  5369. return t.setFromMatrixColumn(this, 0), e.setFromMatrixColumn(this, 1), i.setFromMatrixColumn(this, 2), this;
  5370. }
  5371. makeBasis(t, e, i) {
  5372. return this.set(
  5373. t.x,
  5374. e.x,
  5375. i.x,
  5376. 0,
  5377. t.y,
  5378. e.y,
  5379. i.y,
  5380. 0,
  5381. t.z,
  5382. e.z,
  5383. i.z,
  5384. 0,
  5385. 0,
  5386. 0,
  5387. 0,
  5388. 1
  5389. ), this;
  5390. }
  5391. extractRotation(t) {
  5392. const e = this.elements, i = t.elements, n = 1 / ze.setFromMatrixColumn(t, 0).length(), r = 1 / ze.setFromMatrixColumn(t, 1).length(), a = 1 / ze.setFromMatrixColumn(t, 2).length();
  5393. return e[0] = i[0] * n, e[1] = i[1] * n, e[2] = i[2] * n, e[3] = 0, e[4] = i[4] * r, e[5] = i[5] * r, e[6] = i[6] * r, e[7] = 0, e[8] = i[8] * a, e[9] = i[9] * a, e[10] = i[10] * a, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this;
  5394. }
  5395. makeRotationFromEuler(t) {
  5396. const e = this.elements, i = t.x, n = t.y, r = t.z, a = Math.cos(i), o = Math.sin(i), h = Math.cos(n), l = Math.sin(n), A = Math.cos(r), u = Math.sin(r);
  5397. if (t.order === "XYZ") {
  5398. const f = a * A, c = a * u, d = o * A, p = o * u;
  5399. e[0] = h * A, e[4] = -h * u, e[8] = l, e[1] = c + d * l, e[5] = f - p * l, e[9] = -o * h, e[2] = p - f * l, e[6] = d + c * l, e[10] = a * h;
  5400. } else if (t.order === "YXZ") {
  5401. const f = h * A, c = h * u, d = l * A, p = l * u;
  5402. e[0] = f + p * o, e[4] = d * o - c, e[8] = a * l, e[1] = a * u, e[5] = a * A, e[9] = -o, e[2] = c * o - d, e[6] = p + f * o, e[10] = a * h;
  5403. } else if (t.order === "ZXY") {
  5404. const f = h * A, c = h * u, d = l * A, p = l * u;
  5405. e[0] = f - p * o, e[4] = -a * u, e[8] = d + c * o, e[1] = c + d * o, e[5] = a * A, e[9] = p - f * o, e[2] = -a * l, e[6] = o, e[10] = a * h;
  5406. } else if (t.order === "ZYX") {
  5407. const f = a * A, c = a * u, d = o * A, p = o * u;
  5408. e[0] = h * A, e[4] = d * l - c, e[8] = f * l + p, e[1] = h * u, e[5] = p * l + f, e[9] = c * l - d, e[2] = -l, e[6] = o * h, e[10] = a * h;
  5409. } else if (t.order === "YZX") {
  5410. const f = a * h, c = a * l, d = o * h, p = o * l;
  5411. e[0] = h * A, e[4] = p - f * u, e[8] = d * u + c, e[1] = u, e[5] = a * A, e[9] = -o * A, e[2] = -l * A, e[6] = c * u + d, e[10] = f - p * u;
  5412. } else if (t.order === "XZY") {
  5413. const f = a * h, c = a * l, d = o * h, p = o * l;
  5414. e[0] = h * A, e[4] = -u, e[8] = l * A, e[1] = f * u + p, e[5] = a * A, e[9] = c * u - d, e[2] = d * u - c, e[6] = o * A, e[10] = p * u + f;
  5415. }
  5416. return e[3] = 0, e[7] = 0, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this;
  5417. }
  5418. makeRotationFromQuaternion(t) {
  5419. return this.compose(sA, t, rA);
  5420. }
  5421. lookAt(t, e, i) {
  5422. const n = this.elements;
  5423. return xt.subVectors(t, e), xt.lengthSq() === 0 && (xt.z = 1), xt.normalize(), re.crossVectors(i, xt), re.lengthSq() === 0 && (Math.abs(i.z) === 1 ? xt.x += 1e-4 : xt.z += 1e-4, xt.normalize(), re.crossVectors(i, xt)), re.normalize(), qi.crossVectors(xt, re), n[0] = re.x, n[4] = qi.x, n[8] = xt.x, n[1] = re.y, n[5] = qi.y, n[9] = xt.y, n[2] = re.z, n[6] = qi.z, n[10] = xt.z, this;
  5424. }
  5425. multiply(t) {
  5426. return this.multiplyMatrices(this, t);
  5427. }
  5428. premultiply(t) {
  5429. return this.multiplyMatrices(t, this);
  5430. }
  5431. multiplyMatrices(t, e) {
  5432. const i = t.elements, n = e.elements, r = this.elements, a = i[0], o = i[4], h = i[8], l = i[12], A = i[1], u = i[5], f = i[9], c = i[13], d = i[2], p = i[6], m = i[10], v = i[14], _ = i[3], g = i[7], y = i[11], x = i[15], b = n[0], C = n[4], w = n[8], E = n[12], S = n[1], P = n[5], k = n[9], F = n[13], L = n[2], I = n[6], z = n[10], T = n[14], G = n[3], H = n[7], R = n[11], N = n[15];
  5433. return r[0] = a * b + o * S + h * L + l * G, r[4] = a * C + o * P + h * I + l * H, r[8] = a * w + o * k + h * z + l * R, r[12] = a * E + o * F + h * T + l * N, r[1] = A * b + u * S + f * L + c * G, r[5] = A * C + u * P + f * I + c * H, r[9] = A * w + u * k + f * z + c * R, r[13] = A * E + u * F + f * T + c * N, r[2] = d * b + p * S + m * L + v * G, r[6] = d * C + p * P + m * I + v * H, r[10] = d * w + p * k + m * z + v * R, r[14] = d * E + p * F + m * T + v * N, r[3] = _ * b + g * S + y * L + x * G, r[7] = _ * C + g * P + y * I + x * H, r[11] = _ * w + g * k + y * z + x * R, r[15] = _ * E + g * F + y * T + x * N, this;
  5434. }
  5435. multiplyScalar(t) {
  5436. const e = this.elements;
  5437. return e[0] *= t, e[4] *= t, e[8] *= t, e[12] *= t, e[1] *= t, e[5] *= t, e[9] *= t, e[13] *= t, e[2] *= t, e[6] *= t, e[10] *= t, e[14] *= t, e[3] *= t, e[7] *= t, e[11] *= t, e[15] *= t, this;
  5438. }
  5439. determinant() {
  5440. const t = this.elements, e = t[0], i = t[4], n = t[8], r = t[12], a = t[1], o = t[5], h = t[9], l = t[13], A = t[2], u = t[6], f = t[10], c = t[14], d = t[3], p = t[7], m = t[11], v = t[15];
  5441. return d * (+r * h * u - n * l * u - r * o * f + i * l * f + n * o * c - i * h * c) + p * (+e * h * c - e * l * f + r * a * f - n * a * c + n * l * A - r * h * A) + m * (+e * l * u - e * o * c - r * a * u + i * a * c + r * o * A - i * l * A) + v * (-n * o * A - e * h * u + e * o * f + n * a * u - i * a * f + i * h * A);
  5442. }
  5443. transpose() {
  5444. const t = this.elements;
  5445. let e;
  5446. return e = t[1], t[1] = t[4], t[4] = e, e = t[2], t[2] = t[8], t[8] = e, e = t[6], t[6] = t[9], t[9] = e, e = t[3], t[3] = t[12], t[12] = e, e = t[7], t[7] = t[13], t[13] = e, e = t[11], t[11] = t[14], t[14] = e, this;
  5447. }
  5448. setPosition(t, e, i) {
  5449. const n = this.elements;
  5450. return t.isVector3 ? (n[12] = t.x, n[13] = t.y, n[14] = t.z) : (n[12] = t, n[13] = e, n[14] = i), this;
  5451. }
  5452. invert() {
  5453. const t = this.elements, e = t[0], i = t[1], n = t[2], r = t[3], a = t[4], o = t[5], h = t[6], l = t[7], A = t[8], u = t[9], f = t[10], c = t[11], d = t[12], p = t[13], m = t[14], v = t[15], _ = u * m * l - p * f * l + p * h * c - o * m * c - u * h * v + o * f * v, g = d * f * l - A * m * l - d * h * c + a * m * c + A * h * v - a * f * v, y = A * p * l - d * u * l + d * o * c - a * p * c - A * o * v + a * u * v, x = d * u * h - A * p * h - d * o * f + a * p * f + A * o * m - a * u * m, b = e * _ + i * g + n * y + r * x;
  5454. if (b === 0)
  5455. return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  5456. const C = 1 / b;
  5457. return t[0] = _ * C, t[1] = (p * f * r - u * m * r - p * n * c + i * m * c + u * n * v - i * f * v) * C, t[2] = (o * m * r - p * h * r + p * n * l - i * m * l - o * n * v + i * h * v) * C, t[3] = (u * h * r - o * f * r - u * n * l + i * f * l + o * n * c - i * h * c) * C, t[4] = g * C, t[5] = (A * m * r - d * f * r + d * n * c - e * m * c - A * n * v + e * f * v) * C, t[6] = (d * h * r - a * m * r - d * n * l + e * m * l + a * n * v - e * h * v) * C, t[7] = (a * f * r - A * h * r + A * n * l - e * f * l - a * n * c + e * h * c) * C, t[8] = y * C, t[9] = (d * u * r - A * p * r - d * i * c + e * p * c + A * i * v - e * u * v) * C, t[10] = (a * p * r - d * o * r + d * i * l - e * p * l - a * i * v + e * o * v) * C, t[11] = (A * o * r - a * u * r - A * i * l + e * u * l + a * i * c - e * o * c) * C, t[12] = x * C, t[13] = (A * p * n - d * u * n + d * i * f - e * p * f - A * i * m + e * u * m) * C, t[14] = (d * o * n - a * p * n - d * i * h + e * p * h + a * i * m - e * o * m) * C, t[15] = (a * u * n - A * o * n + A * i * h - e * u * h - a * i * f + e * o * f) * C, this;
  5458. }
  5459. scale(t) {
  5460. const e = this.elements, i = t.x, n = t.y, r = t.z;
  5461. return e[0] *= i, e[4] *= n, e[8] *= r, e[1] *= i, e[5] *= n, e[9] *= r, e[2] *= i, e[6] *= n, e[10] *= r, e[3] *= i, e[7] *= n, e[11] *= r, this;
  5462. }
  5463. getMaxScaleOnAxis() {
  5464. const t = this.elements, e = t[0] * t[0] + t[1] * t[1] + t[2] * t[2], i = t[4] * t[4] + t[5] * t[5] + t[6] * t[6], n = t[8] * t[8] + t[9] * t[9] + t[10] * t[10];
  5465. return Math.sqrt(Math.max(e, i, n));
  5466. }
  5467. makeTranslation(t, e, i) {
  5468. return t.isVector3 ? this.set(
  5469. 1,
  5470. 0,
  5471. 0,
  5472. t.x,
  5473. 0,
  5474. 1,
  5475. 0,
  5476. t.y,
  5477. 0,
  5478. 0,
  5479. 1,
  5480. t.z,
  5481. 0,
  5482. 0,
  5483. 0,
  5484. 1
  5485. ) : this.set(
  5486. 1,
  5487. 0,
  5488. 0,
  5489. t,
  5490. 0,
  5491. 1,
  5492. 0,
  5493. e,
  5494. 0,
  5495. 0,
  5496. 1,
  5497. i,
  5498. 0,
  5499. 0,
  5500. 0,
  5501. 1
  5502. ), this;
  5503. }
  5504. makeRotationX(t) {
  5505. const e = Math.cos(t), i = Math.sin(t);
  5506. return this.set(
  5507. 1,
  5508. 0,
  5509. 0,
  5510. 0,
  5511. 0,
  5512. e,
  5513. -i,
  5514. 0,
  5515. 0,
  5516. i,
  5517. e,
  5518. 0,
  5519. 0,
  5520. 0,
  5521. 0,
  5522. 1
  5523. ), this;
  5524. }
  5525. makeRotationY(t) {
  5526. const e = Math.cos(t), i = Math.sin(t);
  5527. return this.set(
  5528. e,
  5529. 0,
  5530. i,
  5531. 0,
  5532. 0,
  5533. 1,
  5534. 0,
  5535. 0,
  5536. -i,
  5537. 0,
  5538. e,
  5539. 0,
  5540. 0,
  5541. 0,
  5542. 0,
  5543. 1
  5544. ), this;
  5545. }
  5546. makeRotationZ(t) {
  5547. const e = Math.cos(t), i = Math.sin(t);
  5548. return this.set(
  5549. e,
  5550. -i,
  5551. 0,
  5552. 0,
  5553. i,
  5554. e,
  5555. 0,
  5556. 0,
  5557. 0,
  5558. 0,
  5559. 1,
  5560. 0,
  5561. 0,
  5562. 0,
  5563. 0,
  5564. 1
  5565. ), this;
  5566. }
  5567. makeRotationAxis(t, e) {
  5568. const i = Math.cos(e), n = Math.sin(e), r = 1 - i, a = t.x, o = t.y, h = t.z, l = r * a, A = r * o;
  5569. return this.set(
  5570. l * a + i,
  5571. l * o - n * h,
  5572. l * h + n * o,
  5573. 0,
  5574. l * o + n * h,
  5575. A * o + i,
  5576. A * h - n * a,
  5577. 0,
  5578. l * h - n * o,
  5579. A * h + n * a,
  5580. r * h * h + i,
  5581. 0,
  5582. 0,
  5583. 0,
  5584. 0,
  5585. 1
  5586. ), this;
  5587. }
  5588. makeScale(t, e, i) {
  5589. return this.set(
  5590. t,
  5591. 0,
  5592. 0,
  5593. 0,
  5594. 0,
  5595. e,
  5596. 0,
  5597. 0,
  5598. 0,
  5599. 0,
  5600. i,
  5601. 0,
  5602. 0,
  5603. 0,
  5604. 0,
  5605. 1
  5606. ), this;
  5607. }
  5608. makeShear(t, e, i, n, r, a) {
  5609. return this.set(
  5610. 1,
  5611. i,
  5612. r,
  5613. 0,
  5614. t,
  5615. 1,
  5616. a,
  5617. 0,
  5618. e,
  5619. n,
  5620. 1,
  5621. 0,
  5622. 0,
  5623. 0,
  5624. 0,
  5625. 1
  5626. ), this;
  5627. }
  5628. compose(t, e, i) {
  5629. const n = this.elements, r = e._x, a = e._y, o = e._z, h = e._w, l = r + r, A = a + a, u = o + o, f = r * l, c = r * A, d = r * u, p = a * A, m = a * u, v = o * u, _ = h * l, g = h * A, y = h * u, x = i.x, b = i.y, C = i.z;
  5630. return n[0] = (1 - (p + v)) * x, n[1] = (c + y) * x, n[2] = (d - g) * x, n[3] = 0, n[4] = (c - y) * b, n[5] = (1 - (f + v)) * b, n[6] = (m + _) * b, n[7] = 0, n[8] = (d + g) * C, n[9] = (m - _) * C, n[10] = (1 - (f + p)) * C, n[11] = 0, n[12] = t.x, n[13] = t.y, n[14] = t.z, n[15] = 1, this;
  5631. }
  5632. decompose(t, e, i) {
  5633. const n = this.elements;
  5634. let r = ze.set(n[0], n[1], n[2]).length();
  5635. const a = ze.set(n[4], n[5], n[6]).length(), o = ze.set(n[8], n[9], n[10]).length();
  5636. this.determinant() < 0 && (r = -r), t.x = n[12], t.y = n[13], t.z = n[14], kt.copy(this);
  5637. const l = 1 / r, A = 1 / a, u = 1 / o;
  5638. return kt.elements[0] *= l, kt.elements[1] *= l, kt.elements[2] *= l, kt.elements[4] *= A, kt.elements[5] *= A, kt.elements[6] *= A, kt.elements[8] *= u, kt.elements[9] *= u, kt.elements[10] *= u, e.setFromRotationMatrix(kt), i.x = r, i.y = a, i.z = o, this;
  5639. }
  5640. makePerspective(t, e, i, n, r, a, o = Xi) {
  5641. const h = this.elements, l = 2 * r / (e - t), A = 2 * r / (i - n), u = (e + t) / (e - t), f = (i + n) / (i - n);
  5642. let c, d;
  5643. if (o === Xi)
  5644. c = -(a + r) / (a - r), d = -2 * a * r / (a - r);
  5645. else if (o === ta)
  5646. c = -a / (a - r), d = -a * r / (a - r);
  5647. else
  5648. throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o);
  5649. return h[0] = l, h[4] = 0, h[8] = u, h[12] = 0, h[1] = 0, h[5] = A, h[9] = f, h[13] = 0, h[2] = 0, h[6] = 0, h[10] = c, h[14] = d, h[3] = 0, h[7] = 0, h[11] = -1, h[15] = 0, this;
  5650. }
  5651. makeOrthographic(t, e, i, n, r, a, o = Xi) {
  5652. const h = this.elements, l = 1 / (e - t), A = 1 / (i - n), u = 1 / (a - r), f = (e + t) * l, c = (i + n) * A;
  5653. let d, p;
  5654. if (o === Xi)
  5655. d = (a + r) * u, p = -2 * u;
  5656. else if (o === ta)
  5657. d = r * u, p = -1 * u;
  5658. else
  5659. throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o);
  5660. return h[0] = 2 * l, h[4] = 0, h[8] = 0, h[12] = -f, h[1] = 0, h[5] = 2 * A, h[9] = 0, h[13] = -c, h[2] = 0, h[6] = 0, h[10] = p, h[14] = -d, h[3] = 0, h[7] = 0, h[11] = 0, h[15] = 1, this;
  5661. }
  5662. equals(t) {
  5663. const e = this.elements, i = t.elements;
  5664. for (let n = 0; n < 16; n++)
  5665. if (e[n] !== i[n])
  5666. return !1;
  5667. return !0;
  5668. }
  5669. fromArray(t, e = 0) {
  5670. for (let i = 0; i < 16; i++)
  5671. this.elements[i] = t[i + e];
  5672. return this;
  5673. }
  5674. toArray(t = [], e = 0) {
  5675. const i = this.elements;
  5676. return t[e] = i[0], t[e + 1] = i[1], t[e + 2] = i[2], t[e + 3] = i[3], t[e + 4] = i[4], t[e + 5] = i[5], t[e + 6] = i[6], t[e + 7] = i[7], t[e + 8] = i[8], t[e + 9] = i[9], t[e + 10] = i[10], t[e + 11] = i[11], t[e + 12] = i[12], t[e + 13] = i[13], t[e + 14] = i[14], t[e + 15] = i[15], t;
  5677. }
  5678. }
  5679. const ze = /* @__PURE__ */ new j(), kt = /* @__PURE__ */ new ot(), sA = /* @__PURE__ */ new j(0, 0, 0), rA = /* @__PURE__ */ new j(1, 1, 1), re = /* @__PURE__ */ new j(), qi = /* @__PURE__ */ new j(), xt = /* @__PURE__ */ new j(), aa = /* @__PURE__ */ new ot(), oa = /* @__PURE__ */ new ci();
  5680. class zi {
  5681. constructor(t = 0, e = 0, i = 0, n = zi.DEFAULT_ORDER) {
  5682. this.isEuler = !0, this._x = t, this._y = e, this._z = i, this._order = n;
  5683. }
  5684. get x() {
  5685. return this._x;
  5686. }
  5687. set x(t) {
  5688. this._x = t, this._onChangeCallback();
  5689. }
  5690. get y() {
  5691. return this._y;
  5692. }
  5693. set y(t) {
  5694. this._y = t, this._onChangeCallback();
  5695. }
  5696. get z() {
  5697. return this._z;
  5698. }
  5699. set z(t) {
  5700. this._z = t, this._onChangeCallback();
  5701. }
  5702. get order() {
  5703. return this._order;
  5704. }
  5705. set order(t) {
  5706. this._order = t, this._onChangeCallback();
  5707. }
  5708. set(t, e, i, n = this._order) {
  5709. return this._x = t, this._y = e, this._z = i, this._order = n, this._onChangeCallback(), this;
  5710. }
  5711. clone() {
  5712. return new this.constructor(this._x, this._y, this._z, this._order);
  5713. }
  5714. copy(t) {
  5715. return this._x = t._x, this._y = t._y, this._z = t._z, this._order = t._order, this._onChangeCallback(), this;
  5716. }
  5717. setFromRotationMatrix(t, e = this._order, i = !0) {
  5718. const n = t.elements, r = n[0], a = n[4], o = n[8], h = n[1], l = n[5], A = n[9], u = n[2], f = n[6], c = n[10];
  5719. switch (e) {
  5720. case "XYZ":
  5721. this._y = Math.asin(mt(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(-A, c), this._z = Math.atan2(-a, r)) : (this._x = Math.atan2(f, l), this._z = 0);
  5722. break;
  5723. case "YXZ":
  5724. this._x = Math.asin(-mt(A, -1, 1)), Math.abs(A) < 0.9999999 ? (this._y = Math.atan2(o, c), this._z = Math.atan2(h, l)) : (this._y = Math.atan2(-u, r), this._z = 0);
  5725. break;
  5726. case "ZXY":
  5727. this._x = Math.asin(mt(f, -1, 1)), Math.abs(f) < 0.9999999 ? (this._y = Math.atan2(-u, c), this._z = Math.atan2(-a, l)) : (this._y = 0, this._z = Math.atan2(h, r));
  5728. break;
  5729. case "ZYX":
  5730. this._y = Math.asin(-mt(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._x = Math.atan2(f, c), this._z = Math.atan2(h, r)) : (this._x = 0, this._z = Math.atan2(-a, l));
  5731. break;
  5732. case "YZX":
  5733. this._z = Math.asin(mt(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._x = Math.atan2(-A, l), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(o, c));
  5734. break;
  5735. case "XZY":
  5736. this._z = Math.asin(-mt(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(f, l), this._y = Math.atan2(o, r)) : (this._x = Math.atan2(-A, c), this._y = 0);
  5737. break;
  5738. default:
  5739. console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + e);
  5740. }
  5741. return this._order = e, i === !0 && this._onChangeCallback(), this;
  5742. }
  5743. setFromQuaternion(t, e, i) {
  5744. return aa.makeRotationFromQuaternion(t), this.setFromRotationMatrix(aa, e, i);
  5745. }
  5746. setFromVector3(t, e = this._order) {
  5747. return this.set(t.x, t.y, t.z, e);
  5748. }
  5749. reorder(t) {
  5750. return oa.setFromEuler(this), this.setFromQuaternion(oa, t);
  5751. }
  5752. equals(t) {
  5753. return t._x === this._x && t._y === this._y && t._z === this._z && t._order === this._order;
  5754. }
  5755. fromArray(t) {
  5756. return this._x = t[0], this._y = t[1], this._z = t[2], t[3] !== void 0 && (this._order = t[3]), this._onChangeCallback(), this;
  5757. }
  5758. toArray(t = [], e = 0) {
  5759. return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._order, t;
  5760. }
  5761. _onChange(t) {
  5762. return this._onChangeCallback = t, this;
  5763. }
  5764. _onChangeCallback() {
  5765. }
  5766. *[Symbol.iterator]() {
  5767. yield this._x, yield this._y, yield this._z, yield this._order;
  5768. }
  5769. }
  5770. zi.DEFAULT_ORDER = "XYZ";
  5771. class aA {
  5772. constructor() {
  5773. this.mask = 1;
  5774. }
  5775. set(t) {
  5776. this.mask = (1 << t | 0) >>> 0;
  5777. }
  5778. enable(t) {
  5779. this.mask |= 1 << t | 0;
  5780. }
  5781. enableAll() {
  5782. this.mask = -1;
  5783. }
  5784. toggle(t) {
  5785. this.mask ^= 1 << t | 0;
  5786. }
  5787. disable(t) {
  5788. this.mask &= ~(1 << t | 0);
  5789. }
  5790. disableAll() {
  5791. this.mask = 0;
  5792. }
  5793. test(t) {
  5794. return (this.mask & t.mask) !== 0;
  5795. }
  5796. isEnabled(t) {
  5797. return (this.mask & (1 << t | 0)) !== 0;
  5798. }
  5799. }
  5800. let oA = 0;
  5801. const ha = /* @__PURE__ */ new j(), Ue = /* @__PURE__ */ new ci(), Vt = /* @__PURE__ */ new ot(), Qi = /* @__PURE__ */ new j(), vi = /* @__PURE__ */ new j(), hA = /* @__PURE__ */ new j(), lA = /* @__PURE__ */ new ci(), la = /* @__PURE__ */ new j(1, 0, 0), Aa = /* @__PURE__ */ new j(0, 1, 0), ca = /* @__PURE__ */ new j(0, 0, 1), da = { type: "added" }, AA = { type: "removed" }, He = { type: "childadded", child: null }, ks = { type: "childremoved", child: null };
  5802. class we extends co {
  5803. constructor() {
  5804. super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: oA++ }), this.uuid = Tn(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = we.DEFAULT_UP.clone();
  5805. const t = new j(), e = new zi(), i = new ci(), n = new j(1, 1, 1);
  5806. function r() {
  5807. i.setFromEuler(e, !1);
  5808. }
  5809. function a() {
  5810. e.setFromQuaternion(i, void 0, !1);
  5811. }
  5812. e._onChange(r), i._onChange(a), Object.defineProperties(this, {
  5813. position: {
  5814. configurable: !0,
  5815. enumerable: !0,
  5816. value: t
  5817. },
  5818. rotation: {
  5819. configurable: !0,
  5820. enumerable: !0,
  5821. value: e
  5822. },
  5823. quaternion: {
  5824. configurable: !0,
  5825. enumerable: !0,
  5826. value: i
  5827. },
  5828. scale: {
  5829. configurable: !0,
  5830. enumerable: !0,
  5831. value: n
  5832. },
  5833. modelViewMatrix: {
  5834. value: new ot()
  5835. },
  5836. normalMatrix: {
  5837. value: new Jt()
  5838. }
  5839. }), this.matrix = new ot(), this.matrixWorld = new ot(), this.matrixAutoUpdate = we.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = we.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new aA(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {};
  5840. }
  5841. onBeforeShadow() {
  5842. }
  5843. onAfterShadow() {
  5844. }
  5845. onBeforeRender() {
  5846. }
  5847. onAfterRender() {
  5848. }
  5849. applyMatrix4(t) {
  5850. this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(t), this.matrix.decompose(this.position, this.quaternion, this.scale);
  5851. }
  5852. applyQuaternion(t) {
  5853. return this.quaternion.premultiply(t), this;
  5854. }
  5855. setRotationFromAxisAngle(t, e) {
  5856. this.quaternion.setFromAxisAngle(t, e);
  5857. }
  5858. setRotationFromEuler(t) {
  5859. this.quaternion.setFromEuler(t, !0);
  5860. }
  5861. setRotationFromMatrix(t) {
  5862. this.quaternion.setFromRotationMatrix(t);
  5863. }
  5864. setRotationFromQuaternion(t) {
  5865. this.quaternion.copy(t);
  5866. }
  5867. rotateOnAxis(t, e) {
  5868. return Ue.setFromAxisAngle(t, e), this.quaternion.multiply(Ue), this;
  5869. }
  5870. rotateOnWorldAxis(t, e) {
  5871. return Ue.setFromAxisAngle(t, e), this.quaternion.premultiply(Ue), this;
  5872. }
  5873. rotateX(t) {
  5874. return this.rotateOnAxis(la, t);
  5875. }
  5876. rotateY(t) {
  5877. return this.rotateOnAxis(Aa, t);
  5878. }
  5879. rotateZ(t) {
  5880. return this.rotateOnAxis(ca, t);
  5881. }
  5882. translateOnAxis(t, e) {
  5883. return ha.copy(t).applyQuaternion(this.quaternion), this.position.add(ha.multiplyScalar(e)), this;
  5884. }
  5885. translateX(t) {
  5886. return this.translateOnAxis(la, t);
  5887. }
  5888. translateY(t) {
  5889. return this.translateOnAxis(Aa, t);
  5890. }
  5891. translateZ(t) {
  5892. return this.translateOnAxis(ca, t);
  5893. }
  5894. localToWorld(t) {
  5895. return this.updateWorldMatrix(!0, !1), t.applyMatrix4(this.matrixWorld);
  5896. }
  5897. worldToLocal(t) {
  5898. return this.updateWorldMatrix(!0, !1), t.applyMatrix4(Vt.copy(this.matrixWorld).invert());
  5899. }
  5900. lookAt(t, e, i) {
  5901. t.isVector3 ? Qi.copy(t) : Qi.set(t, e, i);
  5902. const n = this.parent;
  5903. this.updateWorldMatrix(!0, !1), vi.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Vt.lookAt(vi, Qi, this.up) : Vt.lookAt(Qi, vi, this.up), this.quaternion.setFromRotationMatrix(Vt), n && (Vt.extractRotation(n.matrixWorld), Ue.setFromRotationMatrix(Vt), this.quaternion.premultiply(Ue.invert()));
  5904. }
  5905. add(t) {
  5906. if (arguments.length > 1) {
  5907. for (let e = 0; e < arguments.length; e++)
  5908. this.add(arguments[e]);
  5909. return this;
  5910. }
  5911. return t === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", t), this) : (t && t.isObject3D ? (t.removeFromParent(), t.parent = this, this.children.push(t), t.dispatchEvent(da), He.child = t, this.dispatchEvent(He), He.child = null) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", t), this);
  5912. }
  5913. remove(t) {
  5914. if (arguments.length > 1) {
  5915. for (let i = 0; i < arguments.length; i++)
  5916. this.remove(arguments[i]);
  5917. return this;
  5918. }
  5919. const e = this.children.indexOf(t);
  5920. return e !== -1 && (t.parent = null, this.children.splice(e, 1), t.dispatchEvent(AA), ks.child = t, this.dispatchEvent(ks), ks.child = null), this;
  5921. }
  5922. removeFromParent() {
  5923. const t = this.parent;
  5924. return t !== null && t.remove(this), this;
  5925. }
  5926. clear() {
  5927. return this.remove(...this.children);
  5928. }
  5929. attach(t) {
  5930. return this.updateWorldMatrix(!0, !1), Vt.copy(this.matrixWorld).invert(), t.parent !== null && (t.parent.updateWorldMatrix(!0, !1), Vt.multiply(t.parent.matrixWorld)), t.applyMatrix4(Vt), t.removeFromParent(), t.parent = this, this.children.push(t), t.updateWorldMatrix(!1, !0), t.dispatchEvent(da), He.child = t, this.dispatchEvent(He), He.child = null, this;
  5931. }
  5932. getObjectById(t) {
  5933. return this.getObjectByProperty("id", t);
  5934. }
  5935. getObjectByName(t) {
  5936. return this.getObjectByProperty("name", t);
  5937. }
  5938. getObjectByProperty(t, e) {
  5939. if (this[t] === e)
  5940. return this;
  5941. for (let i = 0, n = this.children.length; i < n; i++) {
  5942. const a = this.children[i].getObjectByProperty(t, e);
  5943. if (a !== void 0)
  5944. return a;
  5945. }
  5946. }
  5947. getObjectsByProperty(t, e, i = []) {
  5948. this[t] === e && i.push(this);
  5949. const n = this.children;
  5950. for (let r = 0, a = n.length; r < a; r++)
  5951. n[r].getObjectsByProperty(t, e, i);
  5952. return i;
  5953. }
  5954. getWorldPosition(t) {
  5955. return this.updateWorldMatrix(!0, !1), t.setFromMatrixPosition(this.matrixWorld);
  5956. }
  5957. getWorldQuaternion(t) {
  5958. return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(vi, t, hA), t;
  5959. }
  5960. getWorldScale(t) {
  5961. return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(vi, lA, t), t;
  5962. }
  5963. getWorldDirection(t) {
  5964. this.updateWorldMatrix(!0, !1);
  5965. const e = this.matrixWorld.elements;
  5966. return t.set(e[8], e[9], e[10]).normalize();
  5967. }
  5968. raycast() {
  5969. }
  5970. traverse(t) {
  5971. t(this);
  5972. const e = this.children;
  5973. for (let i = 0, n = e.length; i < n; i++)
  5974. e[i].traverse(t);
  5975. }
  5976. traverseVisible(t) {
  5977. if (this.visible === !1)
  5978. return;
  5979. t(this);
  5980. const e = this.children;
  5981. for (let i = 0, n = e.length; i < n; i++)
  5982. e[i].traverseVisible(t);
  5983. }
  5984. traverseAncestors(t) {
  5985. const e = this.parent;
  5986. e !== null && (t(e), e.traverseAncestors(t));
  5987. }
  5988. updateMatrix() {
  5989. this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0;
  5990. }
  5991. updateMatrixWorld(t) {
  5992. this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || t) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, t = !0);
  5993. const e = this.children;
  5994. for (let i = 0, n = e.length; i < n; i++) {
  5995. const r = e[i];
  5996. (r.matrixWorldAutoUpdate === !0 || t === !0) && r.updateMatrixWorld(t);
  5997. }
  5998. }
  5999. updateWorldMatrix(t, e) {
  6000. const i = this.parent;
  6001. if (t === !0 && i !== null && i.matrixWorldAutoUpdate === !0 && i.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), e === !0) {
  6002. const n = this.children;
  6003. for (let r = 0, a = n.length; r < a; r++) {
  6004. const o = n[r];
  6005. o.matrixWorldAutoUpdate === !0 && o.updateWorldMatrix(!1, !0);
  6006. }
  6007. }
  6008. }
  6009. toJSON(t) {
  6010. const e = t === void 0 || typeof t == "string", i = {};
  6011. e && (t = {
  6012. geometries: {},
  6013. materials: {},
  6014. textures: {},
  6015. images: {},
  6016. shapes: {},
  6017. skeletons: {},
  6018. animations: {},
  6019. nodes: {}
  6020. }, i.metadata = {
  6021. version: 4.6,
  6022. type: "Object",
  6023. generator: "Object3D.toJSON"
  6024. });
  6025. const n = {};
  6026. n.uuid = this.uuid, n.type = this.type, this.name !== "" && (n.name = this.name), this.castShadow === !0 && (n.castShadow = !0), this.receiveShadow === !0 && (n.receiveShadow = !0), this.visible === !1 && (n.visible = !1), this.frustumCulled === !1 && (n.frustumCulled = !1), this.renderOrder !== 0 && (n.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (n.userData = this.userData), n.layers = this.layers.mask, n.matrix = this.matrix.toArray(), n.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (n.matrixAutoUpdate = !1), this.isInstancedMesh && (n.type = "InstancedMesh", n.count = this.count, n.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (n.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (n.type = "BatchedMesh", n.perObjectFrustumCulled = this.perObjectFrustumCulled, n.sortObjects = this.sortObjects, n.drawRanges = this._drawRanges, n.reservedRanges = this._reservedRanges, n.visibility = this._visibility, n.active = this._active, n.bounds = this._bounds.map((o) => ({
  6027. boxInitialized: o.boxInitialized,
  6028. boxMin: o.box.min.toArray(),
  6029. boxMax: o.box.max.toArray(),
  6030. sphereInitialized: o.sphereInitialized,
  6031. sphereRadius: o.sphere.radius,
  6032. sphereCenter: o.sphere.center.toArray()
  6033. })), n.maxGeometryCount = this._maxGeometryCount, n.maxVertexCount = this._maxVertexCount, n.maxIndexCount = this._maxIndexCount, n.geometryInitialized = this._geometryInitialized, n.geometryCount = this._geometryCount, n.matricesTexture = this._matricesTexture.toJSON(t), this.boundingSphere !== null && (n.boundingSphere = {
  6034. center: n.boundingSphere.center.toArray(),
  6035. radius: n.boundingSphere.radius
  6036. }), this.boundingBox !== null && (n.boundingBox = {
  6037. min: n.boundingBox.min.toArray(),
  6038. max: n.boundingBox.max.toArray()
  6039. }));
  6040. function r(o, h) {
  6041. return o[h.uuid] === void 0 && (o[h.uuid] = h.toJSON(t)), h.uuid;
  6042. }
  6043. if (this.isScene)
  6044. this.background && (this.background.isColor ? n.background = this.background.toJSON() : this.background.isTexture && (n.background = this.background.toJSON(t).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (n.environment = this.environment.toJSON(t).uuid);
  6045. else if (this.isMesh || this.isLine || this.isPoints) {
  6046. n.geometry = r(t.geometries, this.geometry);
  6047. const o = this.geometry.parameters;
  6048. if (o !== void 0 && o.shapes !== void 0) {
  6049. const h = o.shapes;
  6050. if (Array.isArray(h))
  6051. for (let l = 0, A = h.length; l < A; l++) {
  6052. const u = h[l];
  6053. r(t.shapes, u);
  6054. }
  6055. else
  6056. r(t.shapes, h);
  6057. }
  6058. }
  6059. if (this.isSkinnedMesh && (n.bindMode = this.bindMode, n.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (r(t.skeletons, this.skeleton), n.skeleton = this.skeleton.uuid)), this.material !== void 0)
  6060. if (Array.isArray(this.material)) {
  6061. const o = [];
  6062. for (let h = 0, l = this.material.length; h < l; h++)
  6063. o.push(r(t.materials, this.material[h]));
  6064. n.material = o;
  6065. } else
  6066. n.material = r(t.materials, this.material);
  6067. if (this.children.length > 0) {
  6068. n.children = [];
  6069. for (let o = 0; o < this.children.length; o++)
  6070. n.children.push(this.children[o].toJSON(t).object);
  6071. }
  6072. if (this.animations.length > 0) {
  6073. n.animations = [];
  6074. for (let o = 0; o < this.animations.length; o++) {
  6075. const h = this.animations[o];
  6076. n.animations.push(r(t.animations, h));
  6077. }
  6078. }
  6079. if (e) {
  6080. const o = a(t.geometries), h = a(t.materials), l = a(t.textures), A = a(t.images), u = a(t.shapes), f = a(t.skeletons), c = a(t.animations), d = a(t.nodes);
  6081. o.length > 0 && (i.geometries = o), h.length > 0 && (i.materials = h), l.length > 0 && (i.textures = l), A.length > 0 && (i.images = A), u.length > 0 && (i.shapes = u), f.length > 0 && (i.skeletons = f), c.length > 0 && (i.animations = c), d.length > 0 && (i.nodes = d);
  6082. }
  6083. return i.object = n, i;
  6084. function a(o) {
  6085. const h = [];
  6086. for (const l in o) {
  6087. const A = o[l];
  6088. delete A.metadata, h.push(A);
  6089. }
  6090. return h;
  6091. }
  6092. }
  6093. clone(t) {
  6094. return new this.constructor().copy(this, t);
  6095. }
  6096. copy(t, e = !0) {
  6097. if (this.name = t.name, this.up.copy(t.up), this.position.copy(t.position), this.rotation.order = t.rotation.order, this.quaternion.copy(t.quaternion), this.scale.copy(t.scale), this.matrix.copy(t.matrix), this.matrixWorld.copy(t.matrixWorld), this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrixWorldAutoUpdate = t.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = t.matrixWorldNeedsUpdate, this.layers.mask = t.layers.mask, this.visible = t.visible, this.castShadow = t.castShadow, this.receiveShadow = t.receiveShadow, this.frustumCulled = t.frustumCulled, this.renderOrder = t.renderOrder, this.animations = t.animations.slice(), this.userData = JSON.parse(JSON.stringify(t.userData)), e === !0)
  6098. for (let i = 0; i < t.children.length; i++) {
  6099. const n = t.children[i];
  6100. this.add(n.clone());
  6101. }
  6102. return this;
  6103. }
  6104. }
  6105. we.DEFAULT_UP = /* @__PURE__ */ new j(0, 1, 0);
  6106. we.DEFAULT_MATRIX_AUTO_UPDATE = !0;
  6107. we.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
  6108. const go = {
  6109. aliceblue: 15792383,
  6110. antiquewhite: 16444375,
  6111. aqua: 65535,
  6112. aquamarine: 8388564,
  6113. azure: 15794175,
  6114. beige: 16119260,
  6115. bisque: 16770244,
  6116. black: 0,
  6117. blanchedalmond: 16772045,
  6118. blue: 255,
  6119. blueviolet: 9055202,
  6120. brown: 10824234,
  6121. burlywood: 14596231,
  6122. cadetblue: 6266528,
  6123. chartreuse: 8388352,
  6124. chocolate: 13789470,
  6125. coral: 16744272,
  6126. cornflowerblue: 6591981,
  6127. cornsilk: 16775388,
  6128. crimson: 14423100,
  6129. cyan: 65535,
  6130. darkblue: 139,
  6131. darkcyan: 35723,
  6132. darkgoldenrod: 12092939,
  6133. darkgray: 11119017,
  6134. darkgreen: 25600,
  6135. darkgrey: 11119017,
  6136. darkkhaki: 12433259,
  6137. darkmagenta: 9109643,
  6138. darkolivegreen: 5597999,
  6139. darkorange: 16747520,
  6140. darkorchid: 10040012,
  6141. darkred: 9109504,
  6142. darksalmon: 15308410,
  6143. darkseagreen: 9419919,
  6144. darkslateblue: 4734347,
  6145. darkslategray: 3100495,
  6146. darkslategrey: 3100495,
  6147. darkturquoise: 52945,
  6148. darkviolet: 9699539,
  6149. deeppink: 16716947,
  6150. deepskyblue: 49151,
  6151. dimgray: 6908265,
  6152. dimgrey: 6908265,
  6153. dodgerblue: 2003199,
  6154. firebrick: 11674146,
  6155. floralwhite: 16775920,
  6156. forestgreen: 2263842,
  6157. fuchsia: 16711935,
  6158. gainsboro: 14474460,
  6159. ghostwhite: 16316671,
  6160. gold: 16766720,
  6161. goldenrod: 14329120,
  6162. gray: 8421504,
  6163. green: 32768,
  6164. greenyellow: 11403055,
  6165. grey: 8421504,
  6166. honeydew: 15794160,
  6167. hotpink: 16738740,
  6168. indianred: 13458524,
  6169. indigo: 4915330,
  6170. ivory: 16777200,
  6171. khaki: 15787660,
  6172. lavender: 15132410,
  6173. lavenderblush: 16773365,
  6174. lawngreen: 8190976,
  6175. lemonchiffon: 16775885,
  6176. lightblue: 11393254,
  6177. lightcoral: 15761536,
  6178. lightcyan: 14745599,
  6179. lightgoldenrodyellow: 16448210,
  6180. lightgray: 13882323,
  6181. lightgreen: 9498256,
  6182. lightgrey: 13882323,
  6183. lightpink: 16758465,
  6184. lightsalmon: 16752762,
  6185. lightseagreen: 2142890,
  6186. lightskyblue: 8900346,
  6187. lightslategray: 7833753,
  6188. lightslategrey: 7833753,
  6189. lightsteelblue: 11584734,
  6190. lightyellow: 16777184,
  6191. lime: 65280,
  6192. limegreen: 3329330,
  6193. linen: 16445670,
  6194. magenta: 16711935,
  6195. maroon: 8388608,
  6196. mediumaquamarine: 6737322,
  6197. mediumblue: 205,
  6198. mediumorchid: 12211667,
  6199. mediumpurple: 9662683,
  6200. mediumseagreen: 3978097,
  6201. mediumslateblue: 8087790,
  6202. mediumspringgreen: 64154,
  6203. mediumturquoise: 4772300,
  6204. mediumvioletred: 13047173,
  6205. midnightblue: 1644912,
  6206. mintcream: 16121850,
  6207. mistyrose: 16770273,
  6208. moccasin: 16770229,
  6209. navajowhite: 16768685,
  6210. navy: 128,
  6211. oldlace: 16643558,
  6212. olive: 8421376,
  6213. olivedrab: 7048739,
  6214. orange: 16753920,
  6215. orangered: 16729344,
  6216. orchid: 14315734,
  6217. palegoldenrod: 15657130,
  6218. palegreen: 10025880,
  6219. paleturquoise: 11529966,
  6220. palevioletred: 14381203,
  6221. papayawhip: 16773077,
  6222. peachpuff: 16767673,
  6223. peru: 13468991,
  6224. pink: 16761035,
  6225. plum: 14524637,
  6226. powderblue: 11591910,
  6227. purple: 8388736,
  6228. rebeccapurple: 6697881,
  6229. red: 16711680,
  6230. rosybrown: 12357519,
  6231. royalblue: 4286945,
  6232. saddlebrown: 9127187,
  6233. salmon: 16416882,
  6234. sandybrown: 16032864,
  6235. seagreen: 3050327,
  6236. seashell: 16774638,
  6237. sienna: 10506797,
  6238. silver: 12632256,
  6239. skyblue: 8900331,
  6240. slateblue: 6970061,
  6241. slategray: 7372944,
  6242. slategrey: 7372944,
  6243. snow: 16775930,
  6244. springgreen: 65407,
  6245. steelblue: 4620980,
  6246. tan: 13808780,
  6247. teal: 32896,
  6248. thistle: 14204888,
  6249. tomato: 16737095,
  6250. turquoise: 4251856,
  6251. violet: 15631086,
  6252. wheat: 16113331,
  6253. white: 16777215,
  6254. whitesmoke: 16119285,
  6255. yellow: 16776960,
  6256. yellowgreen: 10145074
  6257. }, ae = { h: 0, s: 0, l: 0 }, Ki = { h: 0, s: 0, l: 0 };
  6258. function Ds(s, t, e) {
  6259. return e < 0 && (e += 1), e > 1 && (e -= 1), e < 1 / 6 ? s + (t - s) * 6 * e : e < 1 / 2 ? t : e < 2 / 3 ? s + (t - s) * 6 * (2 / 3 - e) : s;
  6260. }
  6261. class fr {
  6262. constructor(t, e, i) {
  6263. return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(t, e, i);
  6264. }
  6265. set(t, e, i) {
  6266. if (e === void 0 && i === void 0) {
  6267. const n = t;
  6268. n && n.isColor ? this.copy(n) : typeof n == "number" ? this.setHex(n) : typeof n == "string" && this.setStyle(n);
  6269. } else
  6270. this.setRGB(t, e, i);
  6271. return this;
  6272. }
  6273. setScalar(t) {
  6274. return this.r = t, this.g = t, this.b = t, this;
  6275. }
  6276. setHex(t, e = le) {
  6277. return t = Math.floor(t), this.r = (t >> 16 & 255) / 255, this.g = (t >> 8 & 255) / 255, this.b = (t & 255) / 255, Ft.toWorkingColorSpace(this, e), this;
  6278. }
  6279. setRGB(t, e, i, n = Ft.workingColorSpace) {
  6280. return this.r = t, this.g = e, this.b = i, Ft.toWorkingColorSpace(this, n), this;
  6281. }
  6282. setHSL(t, e, i, n = Ft.workingColorSpace) {
  6283. if (t = ur(t, 1), e = mt(e, 0, 1), i = mt(i, 0, 1), e === 0)
  6284. this.r = this.g = this.b = i;
  6285. else {
  6286. const r = i <= 0.5 ? i * (1 + e) : i + e - i * e, a = 2 * i - r;
  6287. this.r = Ds(a, r, t + 1 / 3), this.g = Ds(a, r, t), this.b = Ds(a, r, t - 1 / 3);
  6288. }
  6289. return Ft.toWorkingColorSpace(this, n), this;
  6290. }
  6291. setStyle(t, e = le) {
  6292. function i(r) {
  6293. r !== void 0 && parseFloat(r) < 1 && console.warn("THREE.Color: Alpha component of " + t + " will be ignored.");
  6294. }
  6295. let n;
  6296. if (n = /^(\w+)\(([^\)]*)\)/.exec(t)) {
  6297. let r;
  6298. const a = n[1], o = n[2];
  6299. switch (a) {
  6300. case "rgb":
  6301. case "rgba":
  6302. if (r = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
  6303. return i(r[4]), this.setRGB(
  6304. Math.min(255, parseInt(r[1], 10)) / 255,
  6305. Math.min(255, parseInt(r[2], 10)) / 255,
  6306. Math.min(255, parseInt(r[3], 10)) / 255,
  6307. e
  6308. );
  6309. if (r = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
  6310. return i(r[4]), this.setRGB(
  6311. Math.min(100, parseInt(r[1], 10)) / 100,
  6312. Math.min(100, parseInt(r[2], 10)) / 100,
  6313. Math.min(100, parseInt(r[3], 10)) / 100,
  6314. e
  6315. );
  6316. break;
  6317. case "hsl":
  6318. case "hsla":
  6319. if (r = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
  6320. return i(r[4]), this.setHSL(
  6321. parseFloat(r[1]) / 360,
  6322. parseFloat(r[2]) / 100,
  6323. parseFloat(r[3]) / 100,
  6324. e
  6325. );
  6326. break;
  6327. default:
  6328. console.warn("THREE.Color: Unknown color model " + t);
  6329. }
  6330. } else if (n = /^\#([A-Fa-f\d]+)$/.exec(t)) {
  6331. const r = n[1], a = r.length;
  6332. if (a === 3)
  6333. return this.setRGB(
  6334. parseInt(r.charAt(0), 16) / 15,
  6335. parseInt(r.charAt(1), 16) / 15,
  6336. parseInt(r.charAt(2), 16) / 15,
  6337. e
  6338. );
  6339. if (a === 6)
  6340. return this.setHex(parseInt(r, 16), e);
  6341. console.warn("THREE.Color: Invalid hex color " + t);
  6342. } else if (t && t.length > 0)
  6343. return this.setColorName(t, e);
  6344. return this;
  6345. }
  6346. setColorName(t, e = le) {
  6347. const i = go[t.toLowerCase()];
  6348. return i !== void 0 ? this.setHex(i, e) : console.warn("THREE.Color: Unknown color " + t), this;
  6349. }
  6350. clone() {
  6351. return new this.constructor(this.r, this.g, this.b);
  6352. }
  6353. copy(t) {
  6354. return this.r = t.r, this.g = t.g, this.b = t.b, this;
  6355. }
  6356. copySRGBToLinear(t) {
  6357. return this.r = Qe(t.r), this.g = Qe(t.g), this.b = Qe(t.b), this;
  6358. }
  6359. copyLinearToSRGB(t) {
  6360. return this.r = Ps(t.r), this.g = Ps(t.g), this.b = Ps(t.b), this;
  6361. }
  6362. convertSRGBToLinear() {
  6363. return this.copySRGBToLinear(this), this;
  6364. }
  6365. convertLinearToSRGB() {
  6366. return this.copyLinearToSRGB(this), this;
  6367. }
  6368. getHex(t = le) {
  6369. return Ft.fromWorkingColorSpace(yt.copy(this), t), Math.round(mt(yt.r * 255, 0, 255)) * 65536 + Math.round(mt(yt.g * 255, 0, 255)) * 256 + Math.round(mt(yt.b * 255, 0, 255));
  6370. }
  6371. getHexString(t = le) {
  6372. return ("000000" + this.getHex(t).toString(16)).slice(-6);
  6373. }
  6374. getHSL(t, e = Ft.workingColorSpace) {
  6375. Ft.fromWorkingColorSpace(yt.copy(this), e);
  6376. const i = yt.r, n = yt.g, r = yt.b, a = Math.max(i, n, r), o = Math.min(i, n, r);
  6377. let h, l;
  6378. const A = (o + a) / 2;
  6379. if (o === a)
  6380. h = 0, l = 0;
  6381. else {
  6382. const u = a - o;
  6383. switch (l = A <= 0.5 ? u / (a + o) : u / (2 - a - o), a) {
  6384. case i:
  6385. h = (n - r) / u + (n < r ? 6 : 0);
  6386. break;
  6387. case n:
  6388. h = (r - i) / u + 2;
  6389. break;
  6390. case r:
  6391. h = (i - n) / u + 4;
  6392. break;
  6393. }
  6394. h /= 6;
  6395. }
  6396. return t.h = h, t.s = l, t.l = A, t;
  6397. }
  6398. getRGB(t, e = Ft.workingColorSpace) {
  6399. return Ft.fromWorkingColorSpace(yt.copy(this), e), t.r = yt.r, t.g = yt.g, t.b = yt.b, t;
  6400. }
  6401. getStyle(t = le) {
  6402. Ft.fromWorkingColorSpace(yt.copy(this), t);
  6403. const e = yt.r, i = yt.g, n = yt.b;
  6404. return t !== le ? `color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})` : `rgb(${Math.round(e * 255)},${Math.round(i * 255)},${Math.round(n * 255)})`;
  6405. }
  6406. offsetHSL(t, e, i) {
  6407. return this.getHSL(ae), this.setHSL(ae.h + t, ae.s + e, ae.l + i);
  6408. }
  6409. add(t) {
  6410. return this.r += t.r, this.g += t.g, this.b += t.b, this;
  6411. }
  6412. addColors(t, e) {
  6413. return this.r = t.r + e.r, this.g = t.g + e.g, this.b = t.b + e.b, this;
  6414. }
  6415. addScalar(t) {
  6416. return this.r += t, this.g += t, this.b += t, this;
  6417. }
  6418. sub(t) {
  6419. return this.r = Math.max(0, this.r - t.r), this.g = Math.max(0, this.g - t.g), this.b = Math.max(0, this.b - t.b), this;
  6420. }
  6421. multiply(t) {
  6422. return this.r *= t.r, this.g *= t.g, this.b *= t.b, this;
  6423. }
  6424. multiplyScalar(t) {
  6425. return this.r *= t, this.g *= t, this.b *= t, this;
  6426. }
  6427. lerp(t, e) {
  6428. return this.r += (t.r - this.r) * e, this.g += (t.g - this.g) * e, this.b += (t.b - this.b) * e, this;
  6429. }
  6430. lerpColors(t, e, i) {
  6431. return this.r = t.r + (e.r - t.r) * i, this.g = t.g + (e.g - t.g) * i, this.b = t.b + (e.b - t.b) * i, this;
  6432. }
  6433. lerpHSL(t, e) {
  6434. this.getHSL(ae), t.getHSL(Ki);
  6435. const i = Mi(ae.h, Ki.h, e), n = Mi(ae.s, Ki.s, e), r = Mi(ae.l, Ki.l, e);
  6436. return this.setHSL(i, n, r), this;
  6437. }
  6438. setFromVector3(t) {
  6439. return this.r = t.x, this.g = t.y, this.b = t.z, this;
  6440. }
  6441. applyMatrix3(t) {
  6442. const e = this.r, i = this.g, n = this.b, r = t.elements;
  6443. return this.r = r[0] * e + r[3] * i + r[6] * n, this.g = r[1] * e + r[4] * i + r[7] * n, this.b = r[2] * e + r[5] * i + r[8] * n, this;
  6444. }
  6445. equals(t) {
  6446. return t.r === this.r && t.g === this.g && t.b === this.b;
  6447. }
  6448. fromArray(t, e = 0) {
  6449. return this.r = t[e], this.g = t[e + 1], this.b = t[e + 2], this;
  6450. }
  6451. toArray(t = [], e = 0) {
  6452. return t[e] = this.r, t[e + 1] = this.g, t[e + 2] = this.b, t;
  6453. }
  6454. fromBufferAttribute(t, e) {
  6455. return this.r = t.getX(e), this.g = t.getY(e), this.b = t.getZ(e), this;
  6456. }
  6457. toJSON() {
  6458. return this.getHex();
  6459. }
  6460. *[Symbol.iterator]() {
  6461. yield this.r, yield this.g, yield this.b;
  6462. }
  6463. }
  6464. const yt = /* @__PURE__ */ new fr();
  6465. fr.NAMES = go;
  6466. class cA extends Ae {
  6467. constructor(t, e, i, n, r, a, o, h, l, A) {
  6468. if (A = A !== void 0 ? A : Cs, A !== Cs && A !== Qr)
  6469. throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
  6470. i === void 0 && A === Cs && (i = kl), i === void 0 && A === Qr && (i = Dl), super(null, n, r, a, o, h, A, i, l), this.isDepthTexture = !0, this.image = { width: t, height: e }, this.magFilter = o !== void 0 ? o : qr, this.minFilter = h !== void 0 ? h : qr, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null;
  6471. }
  6472. copy(t) {
  6473. return super.copy(t), this.compareFunction = t.compareFunction, this;
  6474. }
  6475. toJSON(t) {
  6476. const e = super.toJSON(t);
  6477. return this.compareFunction !== null && (e.compareFunction = this.compareFunction), e;
  6478. }
  6479. }
  6480. const dA = /* @__PURE__ */ new cA(1, 1);
  6481. dA.compareFunction = Ll;
  6482. const uA = {
  6483. triangulate: function(s, t, e = 2) {
  6484. const i = t && t.length, n = i ? t[0] * e : s.length;
  6485. let r = po(s, 0, n, e, !0);
  6486. const a = [];
  6487. if (!r || r.next === r.prev)
  6488. return a;
  6489. let o, h, l, A, u, f, c;
  6490. if (i && (r = mA(s, t, r, e)), s.length > 80 * e) {
  6491. o = l = s[0], h = A = s[1];
  6492. for (let d = e; d < n; d += e)
  6493. u = s[d], f = s[d + 1], u < o && (o = u), f < h && (h = f), u > l && (l = u), f > A && (A = f);
  6494. c = Math.max(l - o, A - h), c = c !== 0 ? 32767 / c : 0;
  6495. }
  6496. return Fi(r, a, e, o, h, c, 0), a;
  6497. }
  6498. };
  6499. function po(s, t, e, i, n) {
  6500. let r, a;
  6501. if (n === FA(s, t, e, i) > 0)
  6502. for (r = t; r < e; r += i)
  6503. a = ua(r, s[r], s[r + 1], a);
  6504. else
  6505. for (r = e - i; r >= t; r -= i)
  6506. a = ua(r, s[r], s[r + 1], a);
  6507. return a && Ln(a, a.next) && (Di(a), a = a.next), a;
  6508. }
  6509. function Ce(s, t) {
  6510. if (!s)
  6511. return s;
  6512. t || (t = s);
  6513. let e = s, i;
  6514. do
  6515. if (i = !1, !e.steiner && (Ln(e, e.next) || at(e.prev, e, e.next) === 0)) {
  6516. if (Di(e), e = t = e.prev, e === e.next)
  6517. break;
  6518. i = !0;
  6519. } else
  6520. e = e.next;
  6521. while (i || e !== t);
  6522. return t;
  6523. }
  6524. function Fi(s, t, e, i, n, r, a) {
  6525. if (!s)
  6526. return;
  6527. !a && r && wA(s, i, n, r);
  6528. let o = s, h, l;
  6529. for (; s.prev !== s.next; ) {
  6530. if (h = s.prev, l = s.next, r ? gA(s, i, n, r) : fA(s)) {
  6531. t.push(h.i / e | 0), t.push(s.i / e | 0), t.push(l.i / e | 0), Di(s), s = l.next, o = l.next;
  6532. continue;
  6533. }
  6534. if (s = l, s === o) {
  6535. a ? a === 1 ? (s = pA(Ce(s), t, e), Fi(s, t, e, i, n, r, 2)) : a === 2 && yA(s, t, e, i, n, r) : Fi(Ce(s), t, e, i, n, r, 1);
  6536. break;
  6537. }
  6538. }
  6539. }
  6540. function fA(s) {
  6541. const t = s.prev, e = s, i = s.next;
  6542. if (at(t, e, i) >= 0)
  6543. return !1;
  6544. const n = t.x, r = e.x, a = i.x, o = t.y, h = e.y, l = i.y, A = n < r ? n < a ? n : a : r < a ? r : a, u = o < h ? o < l ? o : l : h < l ? h : l, f = n > r ? n > a ? n : a : r > a ? r : a, c = o > h ? o > l ? o : l : h > l ? h : l;
  6545. let d = i.next;
  6546. for (; d !== t; ) {
  6547. if (d.x >= A && d.x <= f && d.y >= u && d.y <= c && Ye(n, o, r, h, a, l, d.x, d.y) && at(d.prev, d, d.next) >= 0)
  6548. return !1;
  6549. d = d.next;
  6550. }
  6551. return !0;
  6552. }
  6553. function gA(s, t, e, i) {
  6554. const n = s.prev, r = s, a = s.next;
  6555. if (at(n, r, a) >= 0)
  6556. return !1;
  6557. const o = n.x, h = r.x, l = a.x, A = n.y, u = r.y, f = a.y, c = o < h ? o < l ? o : l : h < l ? h : l, d = A < u ? A < f ? A : f : u < f ? u : f, p = o > h ? o > l ? o : l : h > l ? h : l, m = A > u ? A > f ? A : f : u > f ? u : f, v = Ks(c, d, t, e, i), _ = Ks(p, m, t, e, i);
  6558. let g = s.prevZ, y = s.nextZ;
  6559. for (; g && g.z >= v && y && y.z <= _; ) {
  6560. if (g.x >= c && g.x <= p && g.y >= d && g.y <= m && g !== n && g !== a && Ye(o, A, h, u, l, f, g.x, g.y) && at(g.prev, g, g.next) >= 0 || (g = g.prevZ, y.x >= c && y.x <= p && y.y >= d && y.y <= m && y !== n && y !== a && Ye(o, A, h, u, l, f, y.x, y.y) && at(y.prev, y, y.next) >= 0))
  6561. return !1;
  6562. y = y.nextZ;
  6563. }
  6564. for (; g && g.z >= v; ) {
  6565. if (g.x >= c && g.x <= p && g.y >= d && g.y <= m && g !== n && g !== a && Ye(o, A, h, u, l, f, g.x, g.y) && at(g.prev, g, g.next) >= 0)
  6566. return !1;
  6567. g = g.prevZ;
  6568. }
  6569. for (; y && y.z <= _; ) {
  6570. if (y.x >= c && y.x <= p && y.y >= d && y.y <= m && y !== n && y !== a && Ye(o, A, h, u, l, f, y.x, y.y) && at(y.prev, y, y.next) >= 0)
  6571. return !1;
  6572. y = y.nextZ;
  6573. }
  6574. return !0;
  6575. }
  6576. function pA(s, t, e) {
  6577. let i = s;
  6578. do {
  6579. const n = i.prev, r = i.next.next;
  6580. !Ln(n, r) && yo(n, i, i.next, r) && ki(n, r) && ki(r, n) && (t.push(n.i / e | 0), t.push(i.i / e | 0), t.push(r.i / e | 0), Di(i), Di(i.next), i = s = r), i = i.next;
  6581. } while (i !== s);
  6582. return Ce(i);
  6583. }
  6584. function yA(s, t, e, i, n, r) {
  6585. let a = s;
  6586. do {
  6587. let o = a.next.next;
  6588. for (; o !== a.prev; ) {
  6589. if (a.i !== o.i && MA(a, o)) {
  6590. let h = mo(a, o);
  6591. a = Ce(a, a.next), h = Ce(h, h.next), Fi(a, t, e, i, n, r, 0), Fi(h, t, e, i, n, r, 0);
  6592. return;
  6593. }
  6594. o = o.next;
  6595. }
  6596. a = a.next;
  6597. } while (a !== s);
  6598. }
  6599. function mA(s, t, e, i) {
  6600. const n = [];
  6601. let r, a, o, h, l;
  6602. for (r = 0, a = t.length; r < a; r++)
  6603. o = t[r] * i, h = r < a - 1 ? t[r + 1] * i : s.length, l = po(s, o, h, i, !1), l === l.next && (l.steiner = !0), n.push(CA(l));
  6604. for (n.sort(vA), r = 0; r < n.length; r++)
  6605. e = _A(n[r], e);
  6606. return e;
  6607. }
  6608. function vA(s, t) {
  6609. return s.x - t.x;
  6610. }
  6611. function _A(s, t) {
  6612. const e = xA(s, t);
  6613. if (!e)
  6614. return t;
  6615. const i = mo(e, s);
  6616. return Ce(i, i.next), Ce(e, e.next);
  6617. }
  6618. function xA(s, t) {
  6619. let e = t, i = -1 / 0, n;
  6620. const r = s.x, a = s.y;
  6621. do {
  6622. if (a <= e.y && a >= e.next.y && e.next.y !== e.y) {
  6623. const f = e.x + (a - e.y) * (e.next.x - e.x) / (e.next.y - e.y);
  6624. if (f <= r && f > i && (i = f, n = e.x < e.next.x ? e : e.next, f === r))
  6625. return n;
  6626. }
  6627. e = e.next;
  6628. } while (e !== t);
  6629. if (!n)
  6630. return null;
  6631. const o = n, h = n.x, l = n.y;
  6632. let A = 1 / 0, u;
  6633. e = n;
  6634. do
  6635. r >= e.x && e.x >= h && r !== e.x && Ye(a < l ? r : i, a, h, l, a < l ? i : r, a, e.x, e.y) && (u = Math.abs(a - e.y) / (r - e.x), ki(e, s) && (u < A || u === A && (e.x > n.x || e.x === n.x && bA(n, e))) && (n = e, A = u)), e = e.next;
  6636. while (e !== o);
  6637. return n;
  6638. }
  6639. function bA(s, t) {
  6640. return at(s.prev, s, t.prev) < 0 && at(t.next, s, s.next) < 0;
  6641. }
  6642. function wA(s, t, e, i) {
  6643. let n = s;
  6644. do
  6645. n.z === 0 && (n.z = Ks(n.x, n.y, t, e, i)), n.prevZ = n.prev, n.nextZ = n.next, n = n.next;
  6646. while (n !== s);
  6647. n.prevZ.nextZ = null, n.prevZ = null, SA(n);
  6648. }
  6649. function SA(s) {
  6650. let t, e, i, n, r, a, o, h, l = 1;
  6651. do {
  6652. for (e = s, s = null, r = null, a = 0; e; ) {
  6653. for (a++, i = e, o = 0, t = 0; t < l && (o++, i = i.nextZ, !!i); t++)
  6654. ;
  6655. for (h = l; o > 0 || h > 0 && i; )
  6656. o !== 0 && (h === 0 || !i || e.z <= i.z) ? (n = e, e = e.nextZ, o--) : (n = i, i = i.nextZ, h--), r ? r.nextZ = n : s = n, n.prevZ = r, r = n;
  6657. e = i;
  6658. }
  6659. r.nextZ = null, l *= 2;
  6660. } while (a > 1);
  6661. return s;
  6662. }
  6663. function Ks(s, t, e, i, n) {
  6664. return s = (s - e) * n | 0, t = (t - i) * n | 0, s = (s | s << 8) & 16711935, s = (s | s << 4) & 252645135, s = (s | s << 2) & 858993459, s = (s | s << 1) & 1431655765, t = (t | t << 8) & 16711935, t = (t | t << 4) & 252645135, t = (t | t << 2) & 858993459, t = (t | t << 1) & 1431655765, s | t << 1;
  6665. }
  6666. function CA(s) {
  6667. let t = s, e = s;
  6668. do
  6669. (t.x < e.x || t.x === e.x && t.y < e.y) && (e = t), t = t.next;
  6670. while (t !== s);
  6671. return e;
  6672. }
  6673. function Ye(s, t, e, i, n, r, a, o) {
  6674. return (n - a) * (t - o) >= (s - a) * (r - o) && (s - a) * (i - o) >= (e - a) * (t - o) && (e - a) * (r - o) >= (n - a) * (i - o);
  6675. }
  6676. function MA(s, t) {
  6677. return s.next.i !== t.i && s.prev.i !== t.i && !PA(s, t) && // dones't intersect other edges
  6678. (ki(s, t) && ki(t, s) && EA(s, t) && // locally visible
  6679. (at(s.prev, s, t.prev) || at(s, t.prev, t)) || // does not create opposite-facing sectors
  6680. Ln(s, t) && at(s.prev, s, s.next) > 0 && at(t.prev, t, t.next) > 0);
  6681. }
  6682. function at(s, t, e) {
  6683. return (t.y - s.y) * (e.x - t.x) - (t.x - s.x) * (e.y - t.y);
  6684. }
  6685. function Ln(s, t) {
  6686. return s.x === t.x && s.y === t.y;
  6687. }
  6688. function yo(s, t, e, i) {
  6689. const n = Ji(at(s, t, e)), r = Ji(at(s, t, i)), a = Ji(at(e, i, s)), o = Ji(at(e, i, t));
  6690. return !!(n !== r && a !== o || n === 0 && Zi(s, e, t) || r === 0 && Zi(s, i, t) || a === 0 && Zi(e, s, i) || o === 0 && Zi(e, t, i));
  6691. }
  6692. function Zi(s, t, e) {
  6693. return t.x <= Math.max(s.x, e.x) && t.x >= Math.min(s.x, e.x) && t.y <= Math.max(s.y, e.y) && t.y >= Math.min(s.y, e.y);
  6694. }
  6695. function Ji(s) {
  6696. return s > 0 ? 1 : s < 0 ? -1 : 0;
  6697. }
  6698. function PA(s, t) {
  6699. let e = s;
  6700. do {
  6701. if (e.i !== s.i && e.next.i !== s.i && e.i !== t.i && e.next.i !== t.i && yo(e, e.next, s, t))
  6702. return !0;
  6703. e = e.next;
  6704. } while (e !== s);
  6705. return !1;
  6706. }
  6707. function ki(s, t) {
  6708. return at(s.prev, s, s.next) < 0 ? at(s, t, s.next) >= 0 && at(s, s.prev, t) >= 0 : at(s, t, s.prev) < 0 || at(s, s.next, t) < 0;
  6709. }
  6710. function EA(s, t) {
  6711. let e = s, i = !1;
  6712. const n = (s.x + t.x) / 2, r = (s.y + t.y) / 2;
  6713. do
  6714. e.y > r != e.next.y > r && e.next.y !== e.y && n < (e.next.x - e.x) * (r - e.y) / (e.next.y - e.y) + e.x && (i = !i), e = e.next;
  6715. while (e !== s);
  6716. return i;
  6717. }
  6718. function mo(s, t) {
  6719. const e = new Zs(s.i, s.x, s.y), i = new Zs(t.i, t.x, t.y), n = s.next, r = t.prev;
  6720. return s.next = t, t.prev = s, e.next = n, n.prev = e, i.next = e, e.prev = i, r.next = i, i.prev = r, i;
  6721. }
  6722. function ua(s, t, e, i) {
  6723. const n = new Zs(s, t, e);
  6724. return i ? (n.next = i.next, n.prev = i, i.next.prev = n, i.next = n) : (n.prev = n, n.next = n), n;
  6725. }
  6726. function Di(s) {
  6727. s.next.prev = s.prev, s.prev.next = s.next, s.prevZ && (s.prevZ.nextZ = s.nextZ), s.nextZ && (s.nextZ.prevZ = s.prevZ);
  6728. }
  6729. function Zs(s, t, e) {
  6730. this.i = s, this.x = t, this.y = e, this.prev = null, this.next = null, this.z = 0, this.prevZ = null, this.nextZ = null, this.steiner = !1;
  6731. }
  6732. function FA(s, t, e, i) {
  6733. let n = 0;
  6734. for (let r = t, a = e - i; r < e; r += i)
  6735. n += (s[a] - s[r]) * (s[r + 1] + s[a + 1]), a = r;
  6736. return n;
  6737. }
  6738. class gr {
  6739. // calculate area of the contour polygon
  6740. static area(t) {
  6741. const e = t.length;
  6742. let i = 0;
  6743. for (let n = e - 1, r = 0; r < e; n = r++)
  6744. i += t[n].x * t[r].y - t[r].x * t[n].y;
  6745. return i * 0.5;
  6746. }
  6747. static isClockWise(t) {
  6748. return gr.area(t) < 0;
  6749. }
  6750. static triangulateShape(t, e) {
  6751. const i = [], n = [], r = [];
  6752. fa(t), ga(i, t);
  6753. let a = t.length;
  6754. e.forEach(fa);
  6755. for (let h = 0; h < e.length; h++)
  6756. n.push(a), a += e[h].length, ga(i, e[h]);
  6757. const o = uA.triangulate(i, n);
  6758. for (let h = 0; h < o.length; h += 3)
  6759. r.push(o.slice(h, h + 3));
  6760. return r;
  6761. }
  6762. }
  6763. function fa(s) {
  6764. const t = s.length;
  6765. t > 2 && s[t - 1].equals(s[0]) && s.pop();
  6766. }
  6767. function ga(s, t) {
  6768. for (let e = 0; e < t.length; e++)
  6769. s.push(t[e].x), s.push(t[e].y);
  6770. }
  6771. const pa = /* @__PURE__ */ new j(), tn = /* @__PURE__ */ new j();
  6772. class kA {
  6773. constructor(t = new j(), e = new j()) {
  6774. this.start = t, this.end = e;
  6775. }
  6776. set(t, e) {
  6777. return this.start.copy(t), this.end.copy(e), this;
  6778. }
  6779. copy(t) {
  6780. return this.start.copy(t.start), this.end.copy(t.end), this;
  6781. }
  6782. getCenter(t) {
  6783. return t.addVectors(this.start, this.end).multiplyScalar(0.5);
  6784. }
  6785. delta(t) {
  6786. return t.subVectors(this.end, this.start);
  6787. }
  6788. distanceSq() {
  6789. return this.start.distanceToSquared(this.end);
  6790. }
  6791. distance() {
  6792. return this.start.distanceTo(this.end);
  6793. }
  6794. at(t, e) {
  6795. return this.delta(e).multiplyScalar(t).add(this.start);
  6796. }
  6797. closestPointToPointParameter(t, e) {
  6798. pa.subVectors(t, this.start), tn.subVectors(this.end, this.start);
  6799. const i = tn.dot(tn);
  6800. let r = tn.dot(pa) / i;
  6801. return e && (r = mt(r, 0, 1)), r;
  6802. }
  6803. closestPointToPoint(t, e, i) {
  6804. const n = this.closestPointToPointParameter(t, e);
  6805. return this.delta(i).multiplyScalar(n).add(this.start);
  6806. }
  6807. applyMatrix4(t) {
  6808. return this.start.applyMatrix4(t), this.end.applyMatrix4(t), this;
  6809. }
  6810. equals(t) {
  6811. return t.start.equals(this.start) && t.end.equals(this.end);
  6812. }
  6813. clone() {
  6814. return new this.constructor().copy(this);
  6815. }
  6816. }
  6817. typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
  6818. revision: oo
  6819. } }));
  6820. typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = oo);
  6821. const Js = (s) => new X(s[2] - s[0], s[3] - s[1]).normalize(), ya = 1e-6, oe = (s, t) => Math.abs(s[0] - t[0]) < ya && Math.abs(s[1] - t[1]) < ya, Et = (s, t) => new X(s[0], s[1]).distanceTo({ x: t[0], y: t[1] }), Qu = (s) => new X(s[0], s[1]).length(), ce = (s) => Js(s).toArray(), pr = (s) => new X(-s[1], s[0]).normalize().toArray(), DA = (s, t) => {
  6822. const e = new Jt().set(
  6823. Math.cos(t),
  6824. -Math.sin(t),
  6825. 0,
  6826. Math.sin(t),
  6827. Math.cos(t),
  6828. 0,
  6829. 0,
  6830. 0,
  6831. 1
  6832. ), i = new X(s[0], s[1]);
  6833. return i.applyMatrix3(e), i.toArray();
  6834. }, Ke = (s, t, e) => {
  6835. const i = new X(s[0], s[1]);
  6836. return [
  6837. ...t,
  6838. ...i.multiplyScalar(e).add({ x: t[0], y: t[1] }).toArray()
  6839. ];
  6840. }, IA = (s) => pr(ce(s)), Ku = (s, t = [0, 0], e = 1) => {
  6841. const i = pr(s), n = new X(i[0], i[1]);
  6842. return n.multiplyScalar(e).add({ x: t[0], y: t[1] }), [...t, ...n.toArray()];
  6843. }, Xe = (s, t) => {
  6844. const e = new X(s[0], s[1]), i = new X(t[0], t[1]), n = e.angleTo(i);
  6845. return e.cross(i) > 0 ? n : -n;
  6846. }, TA = (s, t) => Xe(ce(s), ce(t)), LA = (s, t) => Xe(t, ce(s)), Zu = (s) => [(s[0] + s[2]) / 2, (s[1] + s[3]) / 2], Ot = (s, t = 2) => {
  6847. const e = Math.pow(10, t);
  6848. return Math.round(s * e) / e;
  6849. };
  6850. var vo = /* @__PURE__ */ ((s) => (s.Overlap = "Overlap", s.Intersect = "Intersect", s.ExtendIntersect = "ExtendIntersect", s.Parallel = "Parallel", s.Join = "Join", s.Equal = "Equal", s.None = "None", s))(vo || {});
  6851. const RA = (s, t) => {
  6852. const e = s.slice(0, 2), i = t.slice(0, 2), n = s.slice(2, 4), r = t.slice(2, 4);
  6853. if (oe(e, i) && oe(n, r))
  6854. return "Equal";
  6855. const a = oe(e, i) || oe(e, r) || oe(n, i) || oe(n, r), o = Js(s), h = Js(t), l = new X(-o.y, o.x).normalize(), A = new X(-h.y, h.x).normalize(), u = new X(s[0], s[1]), f = new X(t[0], t[1]), c = new X(s[2], s[3]), d = new X(t[2], t[3]), p = Ot(
  6856. A.dot(f.clone().sub(u).normalize()) / A.dot(o),
  6857. 6
  6858. ), m = Ot(
  6859. l.dot(u.clone().sub(f).normalize()) / l.dot(h),
  6860. 6
  6861. ), v = A.negate();
  6862. if (p === 0 && m === 0)
  6863. return "Overlap";
  6864. if (oe([l.x, l.y], [A.x, A.y]) || oe([l.x, l.y], [v.x, v.y]))
  6865. return a ? "Overlap" : "Parallel";
  6866. {
  6867. if (a)
  6868. return "Join";
  6869. const _ = (d.y - f.y) * (c.x - u.x) - (d.x - f.x) * (c.y - u.y), g = Ot(
  6870. ((d.x - f.x) * (u.y - f.y) - (d.y - f.y) * (u.x - f.x)) / _,
  6871. 6
  6872. ), y = Ot(
  6873. ((c.x - u.x) * (u.y - f.y) - (c.y - u.y) * (u.x - f.x)) / _,
  6874. 6
  6875. );
  6876. return g >= 0 && g <= 1 && y >= 0 && y <= 1 ? "Intersect" : "ExtendIntersect";
  6877. }
  6878. }, _o = (s, t, e = [
  6879. "Overlap",
  6880. "Intersect",
  6881. "ExtendIntersect",
  6882. "Parallel",
  6883. "Join",
  6884. "Equal",
  6885. "None"
  6886. /* None */
  6887. ]) => {
  6888. let i = RA(s, t);
  6889. if (!e.includes(i))
  6890. return null;
  6891. const n = new X(s[0], s[1]), r = new X(s[2], s[3]), a = new X(t[0], t[1]), o = new X(t[2], t[3]), h = r.clone().sub(n), l = o.clone().sub(a), A = h.x, u = -l.x, f = h.y, c = -l.y, d = a.x - n.x, p = a.y - n.y, m = (c * d - u * p) / (A * c - u * f);
  6892. return n.clone().add(h.clone().multiplyScalar(m)).toArray();
  6893. }, Ui = (s, t) => {
  6894. const e = new X(s[0], s[1]), i = new X(s[2], s[3]), n = new X(t[0], t[1]), r = i.clone().sub(e), o = n.clone().sub(e).dot(r.normalize()), h = e.add(r.multiplyScalar(o));
  6895. return {
  6896. point: h.toArray(),
  6897. len: h.distanceTo(e)
  6898. };
  6899. }, OA = (s, t) => {
  6900. const e = new kA(
  6901. new j(s[0], s[1], 0),
  6902. new j(s[2], s[3], 0)
  6903. ), i = new j(t[0], t[1], 0), n = e.closestPointToPoint(i, !0, new j());
  6904. return [n.x, n.y];
  6905. }, NA = (s, t) => {
  6906. const e = OA(s, t);
  6907. return Et(t, e);
  6908. }, Ju = (s) => {
  6909. const t = s.map((e) => new X(e[0], e[1]));
  6910. return gr.isClockWise(t);
  6911. }, t1 = (s, t, e = 5) => {
  6912. const i = [];
  6913. for (let n = 0; n < e; n++) {
  6914. const r = t.map((o) => o *= n + 1), a = Ui(s, [
  6915. s[0] + r[0],
  6916. s[1] + r[1]
  6917. ]).point;
  6918. i.push(a);
  6919. }
  6920. return i;
  6921. };
  6922. let xe = !1;
  6923. const Pi = [], xo = () => {
  6924. xe = !0, Pi.forEach((s) => s.draggable(!1));
  6925. }, bo = () => {
  6926. xe = !1, Pi.forEach((s) => s.draggable(!0));
  6927. }, Is = (s, t = []) => ["draging", "active", "hover", "common"].find((i) => s[i] && !t.includes(i)), ma = (s, t, e = "mouse-style") => {
  6928. s.listening(!0);
  6929. const i = [], n = (_, g) => {
  6930. s.on(_, g), i.push(_);
  6931. };
  6932. let r;
  6933. t.bus && t.bus.on("statusChange", (_) => {
  6934. r = _, A();
  6935. });
  6936. const a = {
  6937. hover: !1,
  6938. draging: !1,
  6939. active: !1,
  6940. common: !1
  6941. };
  6942. let o = "common", h = "common", l;
  6943. const A = (_, g) => {
  6944. const y = Is(a);
  6945. if (t.bus && (h !== y || l !== g)) {
  6946. const C = o;
  6947. h = y, t.bus.emit("shapeStatusChange", {
  6948. current: y,
  6949. before: C,
  6950. type: g
  6951. });
  6952. }
  6953. let x = r ? Is(r) : xe ? null : y;
  6954. const b = r ? [r, a] : [a];
  6955. for (const C of b) {
  6956. const w = { ...C };
  6957. for (; x && !(x in t); )
  6958. w[x] = !1, x = Is(w);
  6959. if (x)
  6960. break;
  6961. }
  6962. x = x || "common", o !== x && (t[x] && t[x](_), o = x);
  6963. };
  6964. n(`mouseenter.${e}`, (_) => {
  6965. a.hover = !0, A(_, "mouse");
  6966. }), n(`mouseleave.${e}`, (_) => {
  6967. a.hover = !1, A(_, "mouse");
  6968. });
  6969. let u, f = 0;
  6970. n(`click.${e} touchend.${e}`, (_) => {
  6971. a.active = !0, A(_, "click"), f = Date.now();
  6972. });
  6973. const c = `click.${e}${s.id()} touchend.${e}${s.id()}`;
  6974. let d = 3, p, m = !1;
  6975. const v = setInterval(() => {
  6976. if (!(p = s.getStage())) {
  6977. d < -5 && clearInterval(v), --d < 0 && (m && console.error("可能发生资源泄露"), m = !0);
  6978. return;
  6979. }
  6980. clearInterval(v), p.on(c, (_) => {
  6981. Date.now() - f > 50 && _.target !== s && (a.active = !1, A(_, "click"));
  6982. });
  6983. }, 100);
  6984. return u = () => {
  6985. p && p.off(c), clearInterval(v);
  6986. }, n(`dragstart.${e}`, (_) => {
  6987. a.draging = !0, A(_, "mouse");
  6988. }), n(`dragend.${e}`, (_) => {
  6989. setTimeout(() => {
  6990. a.draging = !1, A(_, "mouse");
  6991. }, 16);
  6992. }), () => {
  6993. s.listening(!1), s.off(i.join(" ")), u && u();
  6994. };
  6995. }, yr = (s, t, e = !0, i = !1) => {
  6996. let n = null;
  6997. return xe || s.draggable(!0), Pi.push(s), s.dragBoundFunc((r, a) => {
  6998. if (!xe) {
  6999. let o = r;
  7000. e && (o = be(s, i).invert().point(r)), t.moveHandler([o.x, o.y], n, a);
  7001. }
  7002. return s.absolutePosition();
  7003. }), t.readyHandler && s.on("dragstart.drag", (r) => {
  7004. xe || (n = t.readyHandler(r));
  7005. }), t.endHandler && s.on("dragend.drag", (r) => {
  7006. xe || t.endHandler(n, r);
  7007. }), () => {
  7008. const r = Pi.indexOf(s);
  7009. ~r && Pi.splice(r, 1), s.draggable(!1), s.off("dragstart.drag dragend.drag");
  7010. };
  7011. }, ln = (s, t) => {
  7012. s.enableDrag({
  7013. readyHandler(e) {
  7014. return t.readyHandler && t.readyHandler(s.attrib, e);
  7015. },
  7016. moveHandler(e, i, n) {
  7017. return t.moveHandler(s.attrib, e, i, n);
  7018. },
  7019. endHandler(e, i) {
  7020. return t.endHandler && t.endHandler(s.attrib, e, i);
  7021. }
  7022. });
  7023. }, wo = (s, t) => {
  7024. if (t(s))
  7025. return s;
  7026. if ("children" in s) {
  7027. for (const e of s.children)
  7028. if (wo(e, t))
  7029. return e;
  7030. }
  7031. return null;
  7032. }, So = (s, t) => {
  7033. for (; s; ) {
  7034. if (t(s))
  7035. return s;
  7036. s = s.parent;
  7037. }
  7038. return null;
  7039. }, e1 = (s, t) => !!wo(s, (i) => i === t), GA = Object.prototype.toString, BA = (s) => GA.call(s), An = (s) => BA(s).slice(8, -1), We = (s, t, e) => {
  7040. if (s === t)
  7041. return !1;
  7042. const i = An(s), n = An(t);
  7043. if (i !== n)
  7044. return !0;
  7045. if (i === "String" || i === "Number" || i === "Boolean")
  7046. return i === "Number" && isNaN(s) && isNaN(t) ? !1 : s !== t;
  7047. const r = Array.from(e.values());
  7048. for (const a of r)
  7049. if (a.includes(s) && a.includes(t))
  7050. return !1;
  7051. if (e.add([s, t]), i === "Array")
  7052. return s.length !== t.length || s.some((a, o) => We(a, t[o], e));
  7053. if (i === "Object") {
  7054. const a = Object.keys(s).sort(), o = Object.keys(t).sort();
  7055. return We(a, o, e) || a.some((h) => We(s[h], t[h], e));
  7056. } else if (i === "Map") {
  7057. const a = Array.from(s.keys()).sort(), o = Array.from(t.keys()).sort();
  7058. return We(a, o, e) || a.some((h) => We(s.get(h), t.get(h), e));
  7059. } else
  7060. return i === "Set" ? di(Array.from(s.values()), Array.from(t.values())) : s !== t;
  7061. }, di = (s, t) => We(s, t, /* @__PURE__ */ new Set()), i1 = (s, t) => {
  7062. for (const e in t)
  7063. typeof s[e] == "function" && s[e](t[e]);
  7064. }, Co = (s, t = []) => {
  7065. const e = s.filter((r) => !t.includes(r)), i = t.filter((r) => !s.includes(r)), n = t.filter((r) => s.includes(r));
  7066. return { addPort: e, delPort: i, holdPort: n };
  7067. }, Rn = (s, t) => {
  7068. const e = s.map(({ id: a }) => a), i = t.map(({ id: a }) => a), n = Co(e, i), r = s.filter(
  7069. (a) => !t.includes(a) && i.includes(a.id)
  7070. ).map((a) => a.id);
  7071. return t = s, { ...n, changePort: r };
  7072. }, n1 = (s, t, e = !0) => fe(
  7073. () => [...s],
  7074. (i, n = []) => {
  7075. t(Rn(i, n));
  7076. },
  7077. { immediate: e, flush: "sync" }
  7078. ), s1 = (s) => {
  7079. const t = ti(s()), e = fe(s, (i) => {
  7080. di(t, i) && (Array.isArray(i) ? i.forEach((n, r) => {
  7081. t[r] = n;
  7082. }) : (Object.keys(t).forEach((n) => delete t[n]), Object.assign(t, i)));
  7083. });
  7084. return {
  7085. data: t,
  7086. stop: e
  7087. };
  7088. }, r1 = (s) => {
  7089. const t = ti(s()), e = fe(s, (i, n) => {
  7090. const { addPort: r, delPort: a, changePort: o } = Rn(
  7091. i,
  7092. n
  7093. );
  7094. for (const h of a) {
  7095. const l = t.findIndex((A) => A.id === h);
  7096. ~l && t.splice(l, 1);
  7097. }
  7098. for (const h of r) {
  7099. const l = i.find((A) => A.id === h);
  7100. l && t.push(l);
  7101. }
  7102. for (const h of o) {
  7103. const l = t.findIndex((u) => u.id === h), A = i.findIndex((u) => u.id === h);
  7104. di(t[l], i[A]) && (t[l] = i[A]);
  7105. }
  7106. });
  7107. return {
  7108. data: t,
  7109. stop: e
  7110. };
  7111. }, Ts = (s, t) => {
  7112. var l, A;
  7113. if (!di(s, t))
  7114. return t;
  7115. if (!t)
  7116. return s;
  7117. const e = s, i = t, n = An(e);
  7118. if (An(t) !== n)
  7119. return s;
  7120. switch (n) {
  7121. case "Array":
  7122. if ((l = e[0]) != null && l.id || (A = i[0]) != null && A.id) {
  7123. var { changePort: r, addPort: a, delPort: o } = Rn(e, i);
  7124. a.forEach((p) => {
  7125. i.push(e.find(({ id: m }) => m === p));
  7126. }), o.forEach((p) => {
  7127. const m = i.findIndex(({ id: v }) => v === p);
  7128. ~m && i.splice(m, 1);
  7129. }), r.forEach((p) => {
  7130. const m = e.find(({ id: _ }) => _ === p), v = i.findIndex(({ id: _ }) => _ === p);
  7131. i[v] = Ts(m, i[v]);
  7132. });
  7133. } else {
  7134. for (let c = 0; c < e.length; c++)
  7135. i[c] = Ts(e[c], i[c]);
  7136. for (; i.length !== e.length; )
  7137. i.pop();
  7138. }
  7139. break;
  7140. case "Object":
  7141. const u = Object.keys(i).sort(), f = Object.keys(e).sort();
  7142. var { addPort: a, delPort: o, holdPort: h } = Co(f, u);
  7143. for (let c = 0; c < h.length; c++)
  7144. i[u[c]] = Ts(
  7145. e[h[c]],
  7146. i[h[c]]
  7147. );
  7148. a.forEach((c) => i[c] = e[c]), o.forEach((c) => delete i[c]);
  7149. break;
  7150. default:
  7151. return s;
  7152. }
  7153. return t;
  7154. }, a1 = (s, t) => {
  7155. t.forEach((e) => {
  7156. const i = new Ni({
  7157. fill: "red",
  7158. radius: 5,
  7159. x: e[0],
  7160. y: e[1]
  7161. });
  7162. s.children[0].add(i);
  7163. });
  7164. }, Mo = (s) => {
  7165. const t = [];
  7166. for (const e of s.children)
  7167. t.push(e, ...Mo(e));
  7168. return t;
  7169. }, zA = (s) => (Math.max(1, ...s.map(({ id: t }) => Number(t))) + 1).toString(), mr = (...s) => () => {
  7170. s.forEach((t) => {
  7171. Array.isArray(t) ? t.forEach((e) => e()) : t();
  7172. });
  7173. }, UA = (s) => s ? {
  7174. reactive: s.props.reactive,
  7175. readonly: s.props.reactive
  7176. } : {}, HA = (s, t, e, i, n) => {
  7177. const r = new t({
  7178. attrib: s,
  7179. ...UA(e)
  7180. });
  7181. return i && i(r), e && (r.container = e.container, r.setParent(e)), r.init(), r.mount(r.teleport), e != null && e.isMounted && r.mounted(), n && n(r), r;
  7182. }, Pt = (s, t, e, i) => {
  7183. let n = [];
  7184. const r = (l, A) => l.find((u) => u.id === A), a = {}, o = (l) => {
  7185. const A = a[l];
  7186. return A.destory(), delete a[l], A;
  7187. }, h = (l) => {
  7188. const A = HA(l, s, t, e, i);
  7189. return a[l.id] = A, A;
  7190. };
  7191. return (l) => {
  7192. const A = Array.isArray(l) ? l : [l], { addPort: u, delPort: f, changePort: c } = Rn(
  7193. A,
  7194. n
  7195. ), d = f.map(o), p = u.map((v) => h(r(A, v))), m = c.map((v) => {
  7196. const _ = r(A, v);
  7197. return a[v].setAttrib(_), a[v];
  7198. });
  7199. return n = [...A], {
  7200. adds: p,
  7201. dels: d,
  7202. upds: m
  7203. };
  7204. };
  7205. }, VA = (s) => {
  7206. const t = s.count || 1, e = s.dire || [1, 0], i = s.size, n = s.entity, r = n.shape.getPosition(), a = Ke(e, [r.x, r.y], 10), o = n.container.getSameLevelData(n);
  7207. for (let h = 0; h < t; h++) {
  7208. const l = i.map((f) => f *= h + 1), A = Ui(a, [
  7209. r.x + l[0],
  7210. r.y + l[1]
  7211. ]).point, u = {
  7212. ...s.factoryAttrib(A),
  7213. id: zA(o)
  7214. };
  7215. o.push(u);
  7216. }
  7217. }, Ls = /* @__PURE__ */ new WeakMap(), o1 = (s, t) => {
  7218. const e = Ls.get(s);
  7219. e && e();
  7220. let i = !1;
  7221. const n = () => {
  7222. i || (hn ? s.stage.off("touchend.addEntity") : s.stage.off("click.addEntity"), bo(), Ls.delete(s), i = !0);
  7223. }, r = (A) => {
  7224. n(), o(A);
  7225. }, a = () => {
  7226. n(), h("cancel");
  7227. };
  7228. let o, h;
  7229. return {
  7230. promise: new Promise((A, u) => {
  7231. o = A, h = u;
  7232. const f = (c) => {
  7233. let d = c.evt;
  7234. c.evt instanceof TouchEvent && (d = ao(c));
  7235. const p = s.getRealFromStage([d.offsetX, d.offsetY]);
  7236. r(t(p));
  7237. };
  7238. xo(), Ls.set(s, a), hn ? s.stage.on("touchend.addEntity", f) : s.stage.on("click.addEntity", f);
  7239. }),
  7240. interrupt: a
  7241. };
  7242. }, h1 = (s, t) => {
  7243. s.bus.emit("statusChange", { [t]: !0 });
  7244. }, $A = (s) => {
  7245. const t = ei(!1), e = ei(!1);
  7246. s.bus.on("shapeStatusChange", ({ current: r, type: a }) => {
  7247. r === "active" ? e.value = !e.value : a === "click" ? e.value = !1 : e.value || (t.value = !!r);
  7248. });
  7249. const i = (r) => {
  7250. s.bus.emit("statusChange", { [r]: !0 });
  7251. }, n = fe(
  7252. () => [t.value, e.value],
  7253. ([r, a]) => {
  7254. i(a ? "active" : r ? "hover" : "common");
  7255. },
  7256. { flush: "post" }
  7257. );
  7258. return {
  7259. light: t,
  7260. active: e,
  7261. stop: n
  7262. };
  7263. }, l1 = (s) => {
  7264. const t = ei(), e = ei(), i = s.map($A);
  7265. s.forEach((n) => {
  7266. n.bus.on("destroyed", () => {
  7267. const r = s.indexOf(n);
  7268. ~r && (i[r].stop(), i.splice(r, 1), s.splice(r, 1));
  7269. });
  7270. }), Sn(() => {
  7271. for (let n = 0; n < i.length; n++) {
  7272. const { active: r, light: a } = i[n];
  7273. r.value ? t.value = s[n].attrib.id : t.value === s[n].attrib.id && (t.value = null), a.value ? e.value = s[n].attrib.id : e.value === s[n].attrib.id && (e.value = null);
  7274. }
  7275. });
  7276. }, Mt = {
  7277. fill: "#ffffff",
  7278. radius: 6,
  7279. stroke: "#409EFF",
  7280. strokeWidth: 3,
  7281. zIndex: 3,
  7282. hitStrokeWidth: 5,
  7283. activeFill: "#ffffff",
  7284. activeStroke: "#E6A23C"
  7285. }, On = () => {
  7286. const s = new Ni({
  7287. radius: Mt.radius,
  7288. strokeWidth: Mt.strokeWidth,
  7289. hitStrokeWidth: Mt.hitStrokeWidth
  7290. }), t = () => {
  7291. const [n] = Gt(s, [1, 1]);
  7292. s.scale({ x: n, y: n });
  7293. }, e = () => {
  7294. t(), s.fill(Mt.fill).stroke(Mt.stroke);
  7295. }, i = () => {
  7296. t(), s.fill(Mt.activeFill).stroke(Mt.activeStroke);
  7297. };
  7298. return e(), {
  7299. shape: s,
  7300. setData(n) {
  7301. t(), s.x(n[0]), s.y(n[1]);
  7302. },
  7303. common: e,
  7304. hover: i,
  7305. active: i,
  7306. draging: i
  7307. };
  7308. }, je = {
  7309. strokeWidth: 5,
  7310. hitStrokeWidth: 20,
  7311. stroke: "rgba(230, 162, 60, 1)",
  7312. zIndex: 1,
  7313. activeStroke: "rgba(64, 158, 255, 1)"
  7314. }, ui = () => {
  7315. const s = new Fn({
  7316. strokeScaleEnabled: !1,
  7317. strokeWidth: je.strokeWidth,
  7318. hitStrokeWidth: je.hitStrokeWidth
  7319. }), t = () => {
  7320. s.stroke(je.stroke);
  7321. }, e = () => {
  7322. s.stroke(je.activeStroke);
  7323. };
  7324. return t(), {
  7325. shape: s,
  7326. setData(i) {
  7327. s.points(i);
  7328. },
  7329. common: t,
  7330. hover: t,
  7331. active: e,
  7332. draging: e
  7333. };
  7334. }, cn = {
  7335. fill: "rgba(230, 162, 60, 0.30)",
  7336. activeFill: "rgba(64, 158, 255, 0.3)",
  7337. zIndex: 0
  7338. }, Nn = (s = {}) => {
  7339. let t = "rgba(0, 0, 0, 0)";
  7340. if (qt) {
  7341. const o = new fr();
  7342. o.setHSL(Se.randFloat(0, 1), 1, 0.8), t = "#" + o.getHexString();
  7343. }
  7344. const e = new Nt(), i = new Fn({
  7345. name: "polygon-line",
  7346. closed: !0,
  7347. fill: t
  7348. }), n = s.autoClose ? s.lineFactory ? s.lineFactory() : ui() : null;
  7349. e.add(i), n && e.add(n.shape);
  7350. const r = (o) => {
  7351. i.fill(cn.fill), n && n.common(o);
  7352. }, a = (o) => {
  7353. i.fill(cn.activeFill), n && n.active && n.active(o);
  7354. };
  7355. return r(), {
  7356. closeLine: n,
  7357. shape: e,
  7358. setData(o) {
  7359. if (i.points(o), n)
  7360. if (o.length > 4) {
  7361. const h = [o.length - 2, o.length - 1, 0, 1];
  7362. n.setData(h.map((l) => o[l])), n.shape.visible(!0);
  7363. } else
  7364. n.shape.visible(!1);
  7365. },
  7366. common: r,
  7367. hover: r,
  7368. active: a,
  7369. draging: a
  7370. };
  7371. }, A1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  7372. __proto__: null,
  7373. line: je,
  7374. lineShapeFactory: ui,
  7375. point: Mt,
  7376. pointShapeFactory: On,
  7377. polygon: cn,
  7378. polygonShapeFactory: Nn
  7379. }, Symbol.toStringTag, { value: "Module" }));
  7380. var vr = { exports: {} }, Gn = {}, Po = {}, Ii = {};
  7381. (function(s) {
  7382. Object.defineProperty(s, "__esModule", { value: !0 }), s.Stage = s.stages = void 0;
  7383. const t = st, e = V, i = Ee, n = $, r = It, a = En, o = $, h = bt;
  7384. var l = "Stage", A = "string", u = "px", f = "mouseout", c = "mouseleave", d = "mouseover", p = "mouseenter", m = "mousemove", v = "mousedown", _ = "mouseup", g = "pointermove", y = "pointerdown", x = "pointerup", b = "pointercancel", C = "lostpointercapture", w = "pointerout", E = "pointerleave", S = "pointerover", P = "pointerenter", k = "contextmenu", F = "touchstart", L = "touchend", I = "touchmove", z = "touchcancel", T = "wheel", G = 5, H = [
  7385. [p, "_pointerenter"],
  7386. [v, "_pointerdown"],
  7387. [m, "_pointermove"],
  7388. [_, "_pointerup"],
  7389. [c, "_pointerleave"],
  7390. [F, "_pointerdown"],
  7391. [I, "_pointermove"],
  7392. [L, "_pointerup"],
  7393. [z, "_pointercancel"],
  7394. [d, "_pointerover"],
  7395. [T, "_wheel"],
  7396. [k, "_contextmenu"],
  7397. [y, "_pointerdown"],
  7398. [g, "_pointermove"],
  7399. [x, "_pointerup"],
  7400. [b, "_pointercancel"],
  7401. [C, "_lostpointercapture"]
  7402. ];
  7403. const R = {
  7404. mouse: {
  7405. [w]: f,
  7406. [E]: c,
  7407. [S]: d,
  7408. [P]: p,
  7409. [g]: m,
  7410. [y]: v,
  7411. [x]: _,
  7412. [b]: "mousecancel",
  7413. pointerclick: "click",
  7414. pointerdblclick: "dblclick"
  7415. },
  7416. touch: {
  7417. [w]: "touchout",
  7418. [E]: "touchleave",
  7419. [S]: "touchover",
  7420. [P]: "touchenter",
  7421. [g]: I,
  7422. [y]: F,
  7423. [x]: L,
  7424. [b]: z,
  7425. pointerclick: "tap",
  7426. pointerdblclick: "dbltap"
  7427. },
  7428. pointer: {
  7429. [w]: w,
  7430. [E]: E,
  7431. [S]: S,
  7432. [P]: P,
  7433. [g]: g,
  7434. [y]: y,
  7435. [x]: x,
  7436. [b]: b,
  7437. pointerclick: "pointerclick",
  7438. pointerdblclick: "pointerdblclick"
  7439. }
  7440. }, N = (dt) => dt.indexOf("pointer") >= 0 ? "pointer" : dt.indexOf("touch") >= 0 ? "touch" : "mouse", q = (dt) => {
  7441. const M = N(dt);
  7442. if (M === "pointer")
  7443. return n.Konva.pointerEventsEnabled && R.pointer;
  7444. if (M === "touch")
  7445. return R.touch;
  7446. if (M === "mouse")
  7447. return R.mouse;
  7448. };
  7449. function et(dt = {}) {
  7450. return (dt.clipFunc || dt.clipWidth || dt.clipHeight) && t.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."), dt;
  7451. }
  7452. const tt = "Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";
  7453. s.stages = [];
  7454. class Ut extends i.Container {
  7455. constructor(M) {
  7456. super(et(M)), this._pointerPositions = [], this._changedPointerPositions = [], this._buildDOM(), this._bindContentEvents(), s.stages.push(this), this.on("widthChange.konva heightChange.konva", this._resizeDOM), this.on("visibleChange.konva", this._checkVisibility), this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva", () => {
  7457. et(this.attrs);
  7458. }), this._checkVisibility();
  7459. }
  7460. _validateAdd(M) {
  7461. const D = M.getType() === "Layer", B = M.getType() === "FastLayer";
  7462. D || B || t.Util.throw("You may only add layers to the stage.");
  7463. }
  7464. _checkVisibility() {
  7465. if (!this.content)
  7466. return;
  7467. const M = this.visible() ? "" : "none";
  7468. this.content.style.display = M;
  7469. }
  7470. setContainer(M) {
  7471. if (typeof M === A) {
  7472. if (M.charAt(0) === ".") {
  7473. var D = M.slice(1);
  7474. M = document.getElementsByClassName(D)[0];
  7475. } else {
  7476. var B;
  7477. M.charAt(0) !== "#" ? B = M : B = M.slice(1), M = document.getElementById(B);
  7478. }
  7479. if (!M)
  7480. throw "Can not find container in document with id " + B;
  7481. }
  7482. return this._setAttr("container", M), this.content && (this.content.parentElement && this.content.parentElement.removeChild(this.content), M.appendChild(this.content)), this;
  7483. }
  7484. shouldDrawHit() {
  7485. return !0;
  7486. }
  7487. clear() {
  7488. var M = this.children, D = M.length, B;
  7489. for (B = 0; B < D; B++)
  7490. M[B].clear();
  7491. return this;
  7492. }
  7493. clone(M) {
  7494. return M || (M = {}), M.container = typeof document < "u" && document.createElement("div"), i.Container.prototype.clone.call(this, M);
  7495. }
  7496. destroy() {
  7497. super.destroy();
  7498. var M = this.content;
  7499. M && t.Util._isInDocument(M) && this.container().removeChild(M);
  7500. var D = s.stages.indexOf(this);
  7501. return D > -1 && s.stages.splice(D, 1), t.Util.releaseCanvas(this.bufferCanvas._canvas, this.bufferHitCanvas._canvas), this;
  7502. }
  7503. getPointerPosition() {
  7504. const M = this._pointerPositions[0] || this._changedPointerPositions[0];
  7505. return M ? {
  7506. x: M.x,
  7507. y: M.y
  7508. } : (t.Util.warn(tt), null);
  7509. }
  7510. _getPointerById(M) {
  7511. return this._pointerPositions.find((D) => D.id === M);
  7512. }
  7513. getPointersPositions() {
  7514. return this._pointerPositions;
  7515. }
  7516. getStage() {
  7517. return this;
  7518. }
  7519. getContent() {
  7520. return this.content;
  7521. }
  7522. _toKonvaCanvas(M) {
  7523. M = M || {}, M.x = M.x || 0, M.y = M.y || 0, M.width = M.width || this.width(), M.height = M.height || this.height();
  7524. var D = new r.SceneCanvas({
  7525. width: M.width,
  7526. height: M.height,
  7527. pixelRatio: M.pixelRatio || 1
  7528. }), B = D.getContext()._context, nt = this.children;
  7529. return (M.x || M.y) && B.translate(-1 * M.x, -1 * M.y), nt.forEach(function(K) {
  7530. if (K.isVisible()) {
  7531. var At = K._toKonvaCanvas(M);
  7532. B.drawImage(At._canvas, M.x, M.y, At.getWidth() / At.getPixelRatio(), At.getHeight() / At.getPixelRatio());
  7533. }
  7534. }), D;
  7535. }
  7536. getIntersection(M) {
  7537. if (!M)
  7538. return null;
  7539. var D = this.children, B = D.length, nt = B - 1, K;
  7540. for (K = nt; K >= 0; K--) {
  7541. const At = D[K].getIntersection(M);
  7542. if (At)
  7543. return At;
  7544. }
  7545. return null;
  7546. }
  7547. _resizeDOM() {
  7548. var M = this.width(), D = this.height();
  7549. this.content && (this.content.style.width = M + u, this.content.style.height = D + u), this.bufferCanvas.setSize(M, D), this.bufferHitCanvas.setSize(M, D), this.children.forEach((B) => {
  7550. B.setSize({ width: M, height: D }), B.draw();
  7551. });
  7552. }
  7553. add(M, ...D) {
  7554. if (arguments.length > 1) {
  7555. for (var B = 0; B < arguments.length; B++)
  7556. this.add(arguments[B]);
  7557. return this;
  7558. }
  7559. super.add(M);
  7560. var nt = this.children.length;
  7561. return nt > G && t.Util.warn("The stage has " + nt + " layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."), M.setSize({ width: this.width(), height: this.height() }), M.draw(), n.Konva.isBrowser && this.content.appendChild(M.canvas._canvas), this;
  7562. }
  7563. getParent() {
  7564. return null;
  7565. }
  7566. getLayer() {
  7567. return null;
  7568. }
  7569. hasPointerCapture(M) {
  7570. return h.hasPointerCapture(M, this);
  7571. }
  7572. setPointerCapture(M) {
  7573. h.setPointerCapture(M, this);
  7574. }
  7575. releaseCapture(M) {
  7576. h.releaseCapture(M, this);
  7577. }
  7578. getLayers() {
  7579. return this.children;
  7580. }
  7581. _bindContentEvents() {
  7582. n.Konva.isBrowser && H.forEach(([M, D]) => {
  7583. this.content.addEventListener(M, (B) => {
  7584. this[D](B);
  7585. }, { passive: !1 });
  7586. });
  7587. }
  7588. _pointerenter(M) {
  7589. this.setPointersPositions(M);
  7590. const D = q(M.type);
  7591. D && this._fire(D.pointerenter, {
  7592. evt: M,
  7593. target: this,
  7594. currentTarget: this
  7595. });
  7596. }
  7597. _pointerover(M) {
  7598. this.setPointersPositions(M);
  7599. const D = q(M.type);
  7600. D && this._fire(D.pointerover, {
  7601. evt: M,
  7602. target: this,
  7603. currentTarget: this
  7604. });
  7605. }
  7606. _getTargetShape(M) {
  7607. let D = this[M + "targetShape"];
  7608. return D && !D.getStage() && (D = null), D;
  7609. }
  7610. _pointerleave(M) {
  7611. const D = q(M.type), B = N(M.type);
  7612. if (D) {
  7613. this.setPointersPositions(M);
  7614. var nt = this._getTargetShape(B), K = !(n.Konva.isDragging() || n.Konva.isTransforming()) || n.Konva.hitOnDragEnabled;
  7615. nt && K ? (nt._fireAndBubble(D.pointerout, { evt: M }), nt._fireAndBubble(D.pointerleave, { evt: M }), this._fire(D.pointerleave, {
  7616. evt: M,
  7617. target: this,
  7618. currentTarget: this
  7619. }), this[B + "targetShape"] = null) : K && (this._fire(D.pointerleave, {
  7620. evt: M,
  7621. target: this,
  7622. currentTarget: this
  7623. }), this._fire(D.pointerout, {
  7624. evt: M,
  7625. target: this,
  7626. currentTarget: this
  7627. })), this.pointerPos = null, this._pointerPositions = [];
  7628. }
  7629. }
  7630. _pointerdown(M) {
  7631. const D = q(M.type), B = N(M.type);
  7632. if (D) {
  7633. this.setPointersPositions(M);
  7634. var nt = !1;
  7635. this._changedPointerPositions.forEach((K) => {
  7636. var At = this.getIntersection(K);
  7637. if (a.DD.justDragged = !1, n.Konva["_" + B + "ListenClick"] = !0, !At || !At.isListening())
  7638. return;
  7639. n.Konva.capturePointerEventsEnabled && At.setPointerCapture(K.id), this[B + "ClickStartShape"] = At, At._fireAndBubble(D.pointerdown, {
  7640. evt: M,
  7641. pointerId: K.id
  7642. }), nt = !0;
  7643. const St = M.type.indexOf("touch") >= 0;
  7644. At.preventDefault() && M.cancelable && St && M.preventDefault();
  7645. }), nt || this._fire(D.pointerdown, {
  7646. evt: M,
  7647. target: this,
  7648. currentTarget: this,
  7649. pointerId: this._pointerPositions[0].id
  7650. });
  7651. }
  7652. }
  7653. _pointermove(M) {
  7654. const D = q(M.type), B = N(M.type);
  7655. if (!D)
  7656. return;
  7657. n.Konva.isDragging() && a.DD.node.preventDefault() && M.cancelable && M.preventDefault(), this.setPointersPositions(M);
  7658. var nt = !(n.Konva.isDragging() || n.Konva.isTransforming()) || n.Konva.hitOnDragEnabled;
  7659. if (!nt)
  7660. return;
  7661. var K = {};
  7662. let At = !1;
  7663. var St = this._getTargetShape(B);
  7664. this._changedPointerPositions.forEach((ne) => {
  7665. const it = h.getCapturedShape(ne.id) || this.getIntersection(ne), Oe = ne.id, Ht = { evt: M, pointerId: Oe };
  7666. var Ne = St !== it;
  7667. if (Ne && St && (St._fireAndBubble(D.pointerout, { ...Ht }, it), St._fireAndBubble(D.pointerleave, { ...Ht }, it)), it) {
  7668. if (K[it._id])
  7669. return;
  7670. K[it._id] = !0;
  7671. }
  7672. it && it.isListening() ? (At = !0, Ne && (it._fireAndBubble(D.pointerover, { ...Ht }, St), it._fireAndBubble(D.pointerenter, { ...Ht }, St), this[B + "targetShape"] = it), it._fireAndBubble(D.pointermove, { ...Ht })) : St && (this._fire(D.pointerover, {
  7673. evt: M,
  7674. target: this,
  7675. currentTarget: this,
  7676. pointerId: Oe
  7677. }), this[B + "targetShape"] = null);
  7678. }), At || this._fire(D.pointermove, {
  7679. evt: M,
  7680. target: this,
  7681. currentTarget: this,
  7682. pointerId: this._changedPointerPositions[0].id
  7683. });
  7684. }
  7685. _pointerup(M) {
  7686. const D = q(M.type), B = N(M.type);
  7687. if (!D)
  7688. return;
  7689. this.setPointersPositions(M);
  7690. const nt = this[B + "ClickStartShape"], K = this[B + "ClickEndShape"];
  7691. var At = {};
  7692. let St = !1;
  7693. this._changedPointerPositions.forEach((ne) => {
  7694. const it = h.getCapturedShape(ne.id) || this.getIntersection(ne);
  7695. if (it) {
  7696. if (it.releaseCapture(ne.id), At[it._id])
  7697. return;
  7698. At[it._id] = !0;
  7699. }
  7700. const Oe = ne.id, Ht = { evt: M, pointerId: Oe };
  7701. let Ne = !1;
  7702. n.Konva["_" + B + "InDblClickWindow"] ? (Ne = !0, clearTimeout(this[B + "DblTimeout"])) : a.DD.justDragged || (n.Konva["_" + B + "InDblClickWindow"] = !0, clearTimeout(this[B + "DblTimeout"])), this[B + "DblTimeout"] = setTimeout(function() {
  7703. n.Konva["_" + B + "InDblClickWindow"] = !1;
  7704. }, n.Konva.dblClickWindow), it && it.isListening() ? (St = !0, this[B + "ClickEndShape"] = it, it._fireAndBubble(D.pointerup, { ...Ht }), n.Konva["_" + B + "ListenClick"] && nt && nt === it && (it._fireAndBubble(D.pointerclick, { ...Ht }), Ne && K && K === it && it._fireAndBubble(D.pointerdblclick, { ...Ht }))) : (this[B + "ClickEndShape"] = null, n.Konva["_" + B + "ListenClick"] && this._fire(D.pointerclick, {
  7705. evt: M,
  7706. target: this,
  7707. currentTarget: this,
  7708. pointerId: Oe
  7709. }), Ne && this._fire(D.pointerdblclick, {
  7710. evt: M,
  7711. target: this,
  7712. currentTarget: this,
  7713. pointerId: Oe
  7714. }));
  7715. }), St || this._fire(D.pointerup, {
  7716. evt: M,
  7717. target: this,
  7718. currentTarget: this,
  7719. pointerId: this._changedPointerPositions[0].id
  7720. }), n.Konva["_" + B + "ListenClick"] = !1, M.cancelable && B !== "touch" && M.preventDefault();
  7721. }
  7722. _contextmenu(M) {
  7723. this.setPointersPositions(M);
  7724. var D = this.getIntersection(this.getPointerPosition());
  7725. D && D.isListening() ? D._fireAndBubble(k, { evt: M }) : this._fire(k, {
  7726. evt: M,
  7727. target: this,
  7728. currentTarget: this
  7729. });
  7730. }
  7731. _wheel(M) {
  7732. this.setPointersPositions(M);
  7733. var D = this.getIntersection(this.getPointerPosition());
  7734. D && D.isListening() ? D._fireAndBubble(T, { evt: M }) : this._fire(T, {
  7735. evt: M,
  7736. target: this,
  7737. currentTarget: this
  7738. });
  7739. }
  7740. _pointercancel(M) {
  7741. this.setPointersPositions(M);
  7742. const D = h.getCapturedShape(M.pointerId) || this.getIntersection(this.getPointerPosition());
  7743. D && D._fireAndBubble(x, h.createEvent(M)), h.releaseCapture(M.pointerId);
  7744. }
  7745. _lostpointercapture(M) {
  7746. h.releaseCapture(M.pointerId);
  7747. }
  7748. setPointersPositions(M) {
  7749. var D = this._getContentPosition(), B = null, nt = null;
  7750. M = M || window.event, M.touches !== void 0 ? (this._pointerPositions = [], this._changedPointerPositions = [], Array.prototype.forEach.call(M.touches, (K) => {
  7751. this._pointerPositions.push({
  7752. id: K.identifier,
  7753. x: (K.clientX - D.left) / D.scaleX,
  7754. y: (K.clientY - D.top) / D.scaleY
  7755. });
  7756. }), Array.prototype.forEach.call(M.changedTouches || M.touches, (K) => {
  7757. this._changedPointerPositions.push({
  7758. id: K.identifier,
  7759. x: (K.clientX - D.left) / D.scaleX,
  7760. y: (K.clientY - D.top) / D.scaleY
  7761. });
  7762. })) : (B = (M.clientX - D.left) / D.scaleX, nt = (M.clientY - D.top) / D.scaleY, this.pointerPos = {
  7763. x: B,
  7764. y: nt
  7765. }, this._pointerPositions = [{ x: B, y: nt, id: t.Util._getFirstPointerId(M) }], this._changedPointerPositions = [
  7766. { x: B, y: nt, id: t.Util._getFirstPointerId(M) }
  7767. ]);
  7768. }
  7769. _setPointerPosition(M) {
  7770. t.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'), this.setPointersPositions(M);
  7771. }
  7772. _getContentPosition() {
  7773. if (!this.content || !this.content.getBoundingClientRect)
  7774. return {
  7775. top: 0,
  7776. left: 0,
  7777. scaleX: 1,
  7778. scaleY: 1
  7779. };
  7780. var M = this.content.getBoundingClientRect();
  7781. return {
  7782. top: M.top,
  7783. left: M.left,
  7784. scaleX: M.width / this.content.clientWidth || 1,
  7785. scaleY: M.height / this.content.clientHeight || 1
  7786. };
  7787. }
  7788. _buildDOM() {
  7789. if (this.bufferCanvas = new r.SceneCanvas({
  7790. width: this.width(),
  7791. height: this.height()
  7792. }), this.bufferHitCanvas = new r.HitCanvas({
  7793. pixelRatio: 1,
  7794. width: this.width(),
  7795. height: this.height()
  7796. }), !!n.Konva.isBrowser) {
  7797. var M = this.container();
  7798. if (!M)
  7799. throw "Stage has no container. A container is required.";
  7800. M.innerHTML = "", this.content = document.createElement("div"), this.content.style.position = "relative", this.content.style.userSelect = "none", this.content.className = "konvajs-content", this.content.setAttribute("role", "presentation"), M.appendChild(this.content), this._resizeDOM();
  7801. }
  7802. }
  7803. cache() {
  7804. return t.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."), this;
  7805. }
  7806. clearCache() {
  7807. return this;
  7808. }
  7809. batchDraw() {
  7810. return this.getChildren().forEach(function(M) {
  7811. M.batchDraw();
  7812. }), this;
  7813. }
  7814. }
  7815. s.Stage = Ut, Ut.prototype.nodeType = l, (0, o._registerNode)(Ut), e.Factory.addGetterSetter(Ut, "container");
  7816. })(Ii);
  7817. var Hi = {};
  7818. Object.defineProperty(Hi, "__esModule", { value: !0 });
  7819. var _r = Hi.Layer = void 0;
  7820. const $t = st, Rs = Ee, Ve = rt, xr = V, va = It, WA = O, YA = ft, XA = $;
  7821. var jA = "#", qA = "beforeDraw", QA = "draw", Eo = [
  7822. { x: 0, y: 0 },
  7823. { x: -1, y: -1 },
  7824. { x: 1, y: -1 },
  7825. { x: 1, y: 1 },
  7826. { x: -1, y: 1 }
  7827. ], KA = Eo.length;
  7828. class fi extends Rs.Container {
  7829. constructor(t) {
  7830. super(t), this.canvas = new va.SceneCanvas(), this.hitCanvas = new va.HitCanvas({
  7831. pixelRatio: 1
  7832. }), this._waitingForDraw = !1, this.on("visibleChange.konva", this._checkVisibility), this._checkVisibility(), this.on("imageSmoothingEnabledChange.konva", this._setSmoothEnabled), this._setSmoothEnabled();
  7833. }
  7834. createPNGStream() {
  7835. return this.canvas._canvas.createPNGStream();
  7836. }
  7837. getCanvas() {
  7838. return this.canvas;
  7839. }
  7840. getNativeCanvasElement() {
  7841. return this.canvas._canvas;
  7842. }
  7843. getHitCanvas() {
  7844. return this.hitCanvas;
  7845. }
  7846. getContext() {
  7847. return this.getCanvas().getContext();
  7848. }
  7849. clear(t) {
  7850. return this.getContext().clear(t), this.getHitCanvas().getContext().clear(t), this;
  7851. }
  7852. setZIndex(t) {
  7853. super.setZIndex(t);
  7854. var e = this.getStage();
  7855. return e && e.content && (e.content.removeChild(this.getNativeCanvasElement()), t < e.children.length - 1 ? e.content.insertBefore(this.getNativeCanvasElement(), e.children[t + 1].getCanvas()._canvas) : e.content.appendChild(this.getNativeCanvasElement())), this;
  7856. }
  7857. moveToTop() {
  7858. Ve.Node.prototype.moveToTop.call(this);
  7859. var t = this.getStage();
  7860. return t && t.content && (t.content.removeChild(this.getNativeCanvasElement()), t.content.appendChild(this.getNativeCanvasElement())), !0;
  7861. }
  7862. moveUp() {
  7863. var t = Ve.Node.prototype.moveUp.call(this);
  7864. if (!t)
  7865. return !1;
  7866. var e = this.getStage();
  7867. return !e || !e.content ? !1 : (e.content.removeChild(this.getNativeCanvasElement()), this.index < e.children.length - 1 ? e.content.insertBefore(this.getNativeCanvasElement(), e.children[this.index + 1].getCanvas()._canvas) : e.content.appendChild(this.getNativeCanvasElement()), !0);
  7868. }
  7869. moveDown() {
  7870. if (Ve.Node.prototype.moveDown.call(this)) {
  7871. var t = this.getStage();
  7872. if (t) {
  7873. var e = t.children;
  7874. t.content && (t.content.removeChild(this.getNativeCanvasElement()), t.content.insertBefore(this.getNativeCanvasElement(), e[this.index + 1].getCanvas()._canvas));
  7875. }
  7876. return !0;
  7877. }
  7878. return !1;
  7879. }
  7880. moveToBottom() {
  7881. if (Ve.Node.prototype.moveToBottom.call(this)) {
  7882. var t = this.getStage();
  7883. if (t) {
  7884. var e = t.children;
  7885. t.content && (t.content.removeChild(this.getNativeCanvasElement()), t.content.insertBefore(this.getNativeCanvasElement(), e[1].getCanvas()._canvas));
  7886. }
  7887. return !0;
  7888. }
  7889. return !1;
  7890. }
  7891. getLayer() {
  7892. return this;
  7893. }
  7894. remove() {
  7895. var t = this.getNativeCanvasElement();
  7896. return Ve.Node.prototype.remove.call(this), t && t.parentNode && $t.Util._isInDocument(t) && t.parentNode.removeChild(t), this;
  7897. }
  7898. getStage() {
  7899. return this.parent;
  7900. }
  7901. setSize({ width: t, height: e }) {
  7902. return this.canvas.setSize(t, e), this.hitCanvas.setSize(t, e), this._setSmoothEnabled(), this;
  7903. }
  7904. _validateAdd(t) {
  7905. var e = t.getType();
  7906. e !== "Group" && e !== "Shape" && $t.Util.throw("You may only add groups and shapes to a layer.");
  7907. }
  7908. _toKonvaCanvas(t) {
  7909. return t = t || {}, t.width = t.width || this.getWidth(), t.height = t.height || this.getHeight(), t.x = t.x !== void 0 ? t.x : this.x(), t.y = t.y !== void 0 ? t.y : this.y(), Ve.Node.prototype._toKonvaCanvas.call(this, t);
  7910. }
  7911. _checkVisibility() {
  7912. this.visible() ? this.canvas._canvas.style.display = "block" : this.canvas._canvas.style.display = "none";
  7913. }
  7914. _setSmoothEnabled() {
  7915. this.getContext()._context.imageSmoothingEnabled = this.imageSmoothingEnabled();
  7916. }
  7917. getWidth() {
  7918. if (this.parent)
  7919. return this.parent.width();
  7920. }
  7921. setWidth() {
  7922. $t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.');
  7923. }
  7924. getHeight() {
  7925. if (this.parent)
  7926. return this.parent.height();
  7927. }
  7928. setHeight() {
  7929. $t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.');
  7930. }
  7931. batchDraw() {
  7932. return this._waitingForDraw || (this._waitingForDraw = !0, $t.Util.requestAnimFrame(() => {
  7933. this.draw(), this._waitingForDraw = !1;
  7934. })), this;
  7935. }
  7936. getIntersection(t) {
  7937. if (!this.isListening() || !this.isVisible())
  7938. return null;
  7939. for (var e = 1, i = !1; ; ) {
  7940. for (let n = 0; n < KA; n++) {
  7941. const r = Eo[n], a = this._getIntersection({
  7942. x: t.x + r.x * e,
  7943. y: t.y + r.y * e
  7944. }), o = a.shape;
  7945. if (o)
  7946. return o;
  7947. if (i = !!a.antialiased, !a.antialiased)
  7948. break;
  7949. }
  7950. if (i)
  7951. e += 1;
  7952. else
  7953. return null;
  7954. }
  7955. }
  7956. _getIntersection(t) {
  7957. const e = this.hitCanvas.pixelRatio, i = this.hitCanvas.context.getImageData(Math.round(t.x * e), Math.round(t.y * e), 1, 1).data, n = i[3];
  7958. if (n === 255) {
  7959. const r = $t.Util._rgbToHex(i[0], i[1], i[2]), a = YA.shapes[jA + r];
  7960. return a ? {
  7961. shape: a
  7962. } : {
  7963. antialiased: !0
  7964. };
  7965. } else if (n > 0)
  7966. return {
  7967. antialiased: !0
  7968. };
  7969. return {};
  7970. }
  7971. drawScene(t, e) {
  7972. var i = this.getLayer(), n = t || i && i.getCanvas();
  7973. return this._fire(qA, {
  7974. node: this
  7975. }), this.clearBeforeDraw() && n.getContext().clear(), Rs.Container.prototype.drawScene.call(this, n, e), this._fire(QA, {
  7976. node: this
  7977. }), this;
  7978. }
  7979. drawHit(t, e) {
  7980. var i = this.getLayer(), n = t || i && i.hitCanvas;
  7981. return i && i.clearBeforeDraw() && i.getHitCanvas().getContext().clear(), Rs.Container.prototype.drawHit.call(this, n, e), this;
  7982. }
  7983. enableHitGraph() {
  7984. return this.hitGraphEnabled(!0), this;
  7985. }
  7986. disableHitGraph() {
  7987. return this.hitGraphEnabled(!1), this;
  7988. }
  7989. setHitGraphEnabled(t) {
  7990. $t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."), this.listening(t);
  7991. }
  7992. getHitGraphEnabled(t) {
  7993. return $t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."), this.listening();
  7994. }
  7995. toggleHitCanvas() {
  7996. if (!(!this.parent || !this.parent.content)) {
  7997. var t = this.parent, e = !!this.hitCanvas._canvas.parentNode;
  7998. e ? t.content.removeChild(this.hitCanvas._canvas) : t.content.appendChild(this.hitCanvas._canvas);
  7999. }
  8000. }
  8001. destroy() {
  8002. return $t.Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas), super.destroy();
  8003. }
  8004. }
  8005. _r = Hi.Layer = fi;
  8006. fi.prototype.nodeType = "Layer";
  8007. (0, XA._registerNode)(fi);
  8008. xr.Factory.addGetterSetter(fi, "imageSmoothingEnabled", !0);
  8009. xr.Factory.addGetterSetter(fi, "clearBeforeDraw", !0);
  8010. xr.Factory.addGetterSetter(fi, "hitGraphEnabled", !0, (0, WA.getBooleanValidator)());
  8011. var Bn = {};
  8012. Object.defineProperty(Bn, "__esModule", { value: !0 });
  8013. Bn.FastLayer = void 0;
  8014. const ZA = st, JA = Hi, t0 = $;
  8015. class br extends JA.Layer {
  8016. constructor(t) {
  8017. super(t), this.listening(!1), ZA.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.');
  8018. }
  8019. }
  8020. Bn.FastLayer = br;
  8021. br.prototype.nodeType = "FastLayer";
  8022. (0, t0._registerNode)(br);
  8023. var gi = {};
  8024. Object.defineProperty(gi, "__esModule", { value: !0 });
  8025. gi.Animation = void 0;
  8026. const Os = $, _a = st, Ns = function() {
  8027. return Os.glob.performance && Os.glob.performance.now ? function() {
  8028. return Os.glob.performance.now();
  8029. } : function() {
  8030. return (/* @__PURE__ */ new Date()).getTime();
  8031. };
  8032. }();
  8033. class Rt {
  8034. constructor(t, e) {
  8035. this.id = Rt.animIdCounter++, this.frame = {
  8036. time: 0,
  8037. timeDiff: 0,
  8038. lastTime: Ns(),
  8039. frameRate: 0
  8040. }, this.func = t, this.setLayers(e);
  8041. }
  8042. setLayers(t) {
  8043. let e = [];
  8044. return t && (e = Array.isArray(t) ? t : [t]), this.layers = e, this;
  8045. }
  8046. getLayers() {
  8047. return this.layers;
  8048. }
  8049. addLayer(t) {
  8050. const e = this.layers, i = e.length;
  8051. for (let n = 0; n < i; n++)
  8052. if (e[n]._id === t._id)
  8053. return !1;
  8054. return this.layers.push(t), !0;
  8055. }
  8056. isRunning() {
  8057. const e = Rt.animations, i = e.length;
  8058. for (let n = 0; n < i; n++)
  8059. if (e[n].id === this.id)
  8060. return !0;
  8061. return !1;
  8062. }
  8063. start() {
  8064. return this.stop(), this.frame.timeDiff = 0, this.frame.lastTime = Ns(), Rt._addAnimation(this), this;
  8065. }
  8066. stop() {
  8067. return Rt._removeAnimation(this), this;
  8068. }
  8069. _updateFrameObject(t) {
  8070. this.frame.timeDiff = t - this.frame.lastTime, this.frame.lastTime = t, this.frame.time += this.frame.timeDiff, this.frame.frameRate = 1e3 / this.frame.timeDiff;
  8071. }
  8072. static _addAnimation(t) {
  8073. this.animations.push(t), this._handleAnimation();
  8074. }
  8075. static _removeAnimation(t) {
  8076. const e = t.id, i = this.animations, n = i.length;
  8077. for (let r = 0; r < n; r++)
  8078. if (i[r].id === e) {
  8079. this.animations.splice(r, 1);
  8080. break;
  8081. }
  8082. }
  8083. static _runFrames() {
  8084. const t = {}, e = this.animations;
  8085. for (let i = 0; i < e.length; i++) {
  8086. const n = e[i], r = n.layers, a = n.func;
  8087. n._updateFrameObject(Ns());
  8088. const o = r.length;
  8089. let h;
  8090. if (a ? h = a.call(n, n.frame) !== !1 : h = !0, !!h)
  8091. for (let l = 0; l < o; l++) {
  8092. const A = r[l];
  8093. A._id !== void 0 && (t[A._id] = A);
  8094. }
  8095. }
  8096. for (let i in t)
  8097. t.hasOwnProperty(i) && t[i].batchDraw();
  8098. }
  8099. static _animationLoop() {
  8100. const t = Rt;
  8101. t.animations.length ? (t._runFrames(), _a.Util.requestAnimFrame(t._animationLoop)) : t.animRunning = !1;
  8102. }
  8103. static _handleAnimation() {
  8104. this.animRunning || (this.animRunning = !0, _a.Util.requestAnimFrame(this._animationLoop));
  8105. }
  8106. }
  8107. gi.Animation = Rt;
  8108. Rt.animations = [];
  8109. Rt.animIdCounter = 0;
  8110. Rt.animRunning = !1;
  8111. var Fo = {};
  8112. (function(s) {
  8113. Object.defineProperty(s, "__esModule", { value: !0 }), s.Easings = s.Tween = void 0;
  8114. const t = st, e = gi, i = rt, n = $;
  8115. var r = {
  8116. node: 1,
  8117. duration: 1,
  8118. easing: 1,
  8119. onFinish: 1,
  8120. yoyo: 1
  8121. }, a = 1, o = 2, h = 3, l = 0, A = ["fill", "stroke", "shadowColor"];
  8122. class u {
  8123. constructor(d, p, m, v, _, g, y) {
  8124. this.prop = d, this.propFunc = p, this.begin = v, this._pos = v, this.duration = g, this._change = 0, this.prevPos = 0, this.yoyo = y, this._time = 0, this._position = 0, this._startTime = 0, this._finish = 0, this.func = m, this._change = _ - this.begin, this.pause();
  8125. }
  8126. fire(d) {
  8127. var p = this[d];
  8128. p && p();
  8129. }
  8130. setTime(d) {
  8131. d > this.duration ? this.yoyo ? (this._time = this.duration, this.reverse()) : this.finish() : d < 0 ? this.yoyo ? (this._time = 0, this.play()) : this.reset() : (this._time = d, this.update());
  8132. }
  8133. getTime() {
  8134. return this._time;
  8135. }
  8136. setPosition(d) {
  8137. this.prevPos = this._pos, this.propFunc(d), this._pos = d;
  8138. }
  8139. getPosition(d) {
  8140. return d === void 0 && (d = this._time), this.func(d, this.begin, this._change, this.duration);
  8141. }
  8142. play() {
  8143. this.state = o, this._startTime = this.getTimer() - this._time, this.onEnterFrame(), this.fire("onPlay");
  8144. }
  8145. reverse() {
  8146. this.state = h, this._time = this.duration - this._time, this._startTime = this.getTimer() - this._time, this.onEnterFrame(), this.fire("onReverse");
  8147. }
  8148. seek(d) {
  8149. this.pause(), this._time = d, this.update(), this.fire("onSeek");
  8150. }
  8151. reset() {
  8152. this.pause(), this._time = 0, this.update(), this.fire("onReset");
  8153. }
  8154. finish() {
  8155. this.pause(), this._time = this.duration, this.update(), this.fire("onFinish");
  8156. }
  8157. update() {
  8158. this.setPosition(this.getPosition(this._time)), this.fire("onUpdate");
  8159. }
  8160. onEnterFrame() {
  8161. var d = this.getTimer() - this._startTime;
  8162. this.state === o ? this.setTime(d) : this.state === h && this.setTime(this.duration - d);
  8163. }
  8164. pause() {
  8165. this.state = a, this.fire("onPause");
  8166. }
  8167. getTimer() {
  8168. return (/* @__PURE__ */ new Date()).getTime();
  8169. }
  8170. }
  8171. class f {
  8172. constructor(d) {
  8173. var p = this, m = d.node, v = m._id, _, g = d.easing || s.Easings.Linear, y = !!d.yoyo, x;
  8174. typeof d.duration > "u" ? _ = 0.3 : d.duration === 0 ? _ = 1e-3 : _ = d.duration, this.node = m, this._id = l++;
  8175. var b = m.getLayer() || (m instanceof n.Konva.Stage ? m.getLayers() : null);
  8176. b || t.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."), this.anim = new e.Animation(function() {
  8177. p.tween.onEnterFrame();
  8178. }, b), this.tween = new u(x, function(C) {
  8179. p._tweenFunc(C);
  8180. }, g, 0, 1, _ * 1e3, y), this._addListeners(), f.attrs[v] || (f.attrs[v] = {}), f.attrs[v][this._id] || (f.attrs[v][this._id] = {}), f.tweens[v] || (f.tweens[v] = {});
  8181. for (x in d)
  8182. r[x] === void 0 && this._addAttr(x, d[x]);
  8183. this.reset(), this.onFinish = d.onFinish, this.onReset = d.onReset, this.onUpdate = d.onUpdate;
  8184. }
  8185. _addAttr(d, p) {
  8186. var m = this.node, v = m._id, _, g, y, x, b, C, w, E;
  8187. if (y = f.tweens[v][d], y && delete f.attrs[v][y][d], _ = m.getAttr(d), t.Util._isArray(p))
  8188. if (g = [], b = Math.max(p.length, _.length), d === "points" && p.length !== _.length && (p.length > _.length ? (w = _, _ = t.Util._prepareArrayForTween(_, p, m.closed())) : (C = p, p = t.Util._prepareArrayForTween(p, _, m.closed()))), d.indexOf("fill") === 0)
  8189. for (x = 0; x < b; x++)
  8190. if (x % 2 === 0)
  8191. g.push(p[x] - _[x]);
  8192. else {
  8193. var S = t.Util.colorToRGBA(_[x]);
  8194. E = t.Util.colorToRGBA(p[x]), _[x] = S, g.push({
  8195. r: E.r - S.r,
  8196. g: E.g - S.g,
  8197. b: E.b - S.b,
  8198. a: E.a - S.a
  8199. });
  8200. }
  8201. else
  8202. for (x = 0; x < b; x++)
  8203. g.push(p[x] - _[x]);
  8204. else
  8205. A.indexOf(d) !== -1 ? (_ = t.Util.colorToRGBA(_), E = t.Util.colorToRGBA(p), g = {
  8206. r: E.r - _.r,
  8207. g: E.g - _.g,
  8208. b: E.b - _.b,
  8209. a: E.a - _.a
  8210. }) : g = p - _;
  8211. f.attrs[v][this._id][d] = {
  8212. start: _,
  8213. diff: g,
  8214. end: p,
  8215. trueEnd: C,
  8216. trueStart: w
  8217. }, f.tweens[v][d] = this._id;
  8218. }
  8219. _tweenFunc(d) {
  8220. var p = this.node, m = f.attrs[p._id][this._id], v, _, g, y, x, b, C, w;
  8221. for (v in m) {
  8222. if (_ = m[v], g = _.start, y = _.diff, w = _.end, t.Util._isArray(g))
  8223. if (x = [], C = Math.max(g.length, w.length), v.indexOf("fill") === 0)
  8224. for (b = 0; b < C; b++)
  8225. b % 2 === 0 ? x.push((g[b] || 0) + y[b] * d) : x.push("rgba(" + Math.round(g[b].r + y[b].r * d) + "," + Math.round(g[b].g + y[b].g * d) + "," + Math.round(g[b].b + y[b].b * d) + "," + (g[b].a + y[b].a * d) + ")");
  8226. else
  8227. for (b = 0; b < C; b++)
  8228. x.push((g[b] || 0) + y[b] * d);
  8229. else
  8230. A.indexOf(v) !== -1 ? x = "rgba(" + Math.round(g.r + y.r * d) + "," + Math.round(g.g + y.g * d) + "," + Math.round(g.b + y.b * d) + "," + (g.a + y.a * d) + ")" : x = g + y * d;
  8231. p.setAttr(v, x);
  8232. }
  8233. }
  8234. _addListeners() {
  8235. this.tween.onPlay = () => {
  8236. this.anim.start();
  8237. }, this.tween.onReverse = () => {
  8238. this.anim.start();
  8239. }, this.tween.onPause = () => {
  8240. this.anim.stop();
  8241. }, this.tween.onFinish = () => {
  8242. var d = this.node, p = f.attrs[d._id][this._id];
  8243. p.points && p.points.trueEnd && d.setAttr("points", p.points.trueEnd), this.onFinish && this.onFinish.call(this);
  8244. }, this.tween.onReset = () => {
  8245. var d = this.node, p = f.attrs[d._id][this._id];
  8246. p.points && p.points.trueStart && d.points(p.points.trueStart), this.onReset && this.onReset();
  8247. }, this.tween.onUpdate = () => {
  8248. this.onUpdate && this.onUpdate.call(this);
  8249. };
  8250. }
  8251. play() {
  8252. return this.tween.play(), this;
  8253. }
  8254. reverse() {
  8255. return this.tween.reverse(), this;
  8256. }
  8257. reset() {
  8258. return this.tween.reset(), this;
  8259. }
  8260. seek(d) {
  8261. return this.tween.seek(d * 1e3), this;
  8262. }
  8263. pause() {
  8264. return this.tween.pause(), this;
  8265. }
  8266. finish() {
  8267. return this.tween.finish(), this;
  8268. }
  8269. destroy() {
  8270. var d = this.node._id, p = this._id, m = f.tweens[d], v;
  8271. this.pause();
  8272. for (v in m)
  8273. delete f.tweens[d][v];
  8274. delete f.attrs[d][p];
  8275. }
  8276. }
  8277. s.Tween = f, f.attrs = {}, f.tweens = {}, i.Node.prototype.to = function(c) {
  8278. var d = c.onFinish;
  8279. c.node = this, c.onFinish = function() {
  8280. this.destroy(), d && d();
  8281. };
  8282. var p = new f(c);
  8283. p.play();
  8284. }, s.Easings = {
  8285. BackEaseIn(c, d, p, m) {
  8286. var v = 1.70158;
  8287. return p * (c /= m) * c * ((v + 1) * c - v) + d;
  8288. },
  8289. BackEaseOut(c, d, p, m) {
  8290. var v = 1.70158;
  8291. return p * ((c = c / m - 1) * c * ((v + 1) * c + v) + 1) + d;
  8292. },
  8293. BackEaseInOut(c, d, p, m) {
  8294. var v = 1.70158;
  8295. return (c /= m / 2) < 1 ? p / 2 * (c * c * (((v *= 1.525) + 1) * c - v)) + d : p / 2 * ((c -= 2) * c * (((v *= 1.525) + 1) * c + v) + 2) + d;
  8296. },
  8297. ElasticEaseIn(c, d, p, m, v, _) {
  8298. var g = 0;
  8299. return c === 0 ? d : (c /= m) === 1 ? d + p : (_ || (_ = m * 0.3), !v || v < Math.abs(p) ? (v = p, g = _ / 4) : g = _ / (2 * Math.PI) * Math.asin(p / v), -(v * Math.pow(2, 10 * (c -= 1)) * Math.sin((c * m - g) * (2 * Math.PI) / _)) + d);
  8300. },
  8301. ElasticEaseOut(c, d, p, m, v, _) {
  8302. var g = 0;
  8303. return c === 0 ? d : (c /= m) === 1 ? d + p : (_ || (_ = m * 0.3), !v || v < Math.abs(p) ? (v = p, g = _ / 4) : g = _ / (2 * Math.PI) * Math.asin(p / v), v * Math.pow(2, -10 * c) * Math.sin((c * m - g) * (2 * Math.PI) / _) + p + d);
  8304. },
  8305. ElasticEaseInOut(c, d, p, m, v, _) {
  8306. var g = 0;
  8307. return c === 0 ? d : (c /= m / 2) === 2 ? d + p : (_ || (_ = m * (0.3 * 1.5)), !v || v < Math.abs(p) ? (v = p, g = _ / 4) : g = _ / (2 * Math.PI) * Math.asin(p / v), c < 1 ? -0.5 * (v * Math.pow(2, 10 * (c -= 1)) * Math.sin((c * m - g) * (2 * Math.PI) / _)) + d : v * Math.pow(2, -10 * (c -= 1)) * Math.sin((c * m - g) * (2 * Math.PI) / _) * 0.5 + p + d);
  8308. },
  8309. BounceEaseOut(c, d, p, m) {
  8310. return (c /= m) < 1 / 2.75 ? p * (7.5625 * c * c) + d : c < 2 / 2.75 ? p * (7.5625 * (c -= 1.5 / 2.75) * c + 0.75) + d : c < 2.5 / 2.75 ? p * (7.5625 * (c -= 2.25 / 2.75) * c + 0.9375) + d : p * (7.5625 * (c -= 2.625 / 2.75) * c + 0.984375) + d;
  8311. },
  8312. BounceEaseIn(c, d, p, m) {
  8313. return p - s.Easings.BounceEaseOut(m - c, 0, p, m) + d;
  8314. },
  8315. BounceEaseInOut(c, d, p, m) {
  8316. return c < m / 2 ? s.Easings.BounceEaseIn(c * 2, 0, p, m) * 0.5 + d : s.Easings.BounceEaseOut(c * 2 - m, 0, p, m) * 0.5 + p * 0.5 + d;
  8317. },
  8318. EaseIn(c, d, p, m) {
  8319. return p * (c /= m) * c + d;
  8320. },
  8321. EaseOut(c, d, p, m) {
  8322. return -p * (c /= m) * (c - 2) + d;
  8323. },
  8324. EaseInOut(c, d, p, m) {
  8325. return (c /= m / 2) < 1 ? p / 2 * c * c + d : -p / 2 * (--c * (c - 2) - 1) + d;
  8326. },
  8327. StrongEaseIn(c, d, p, m) {
  8328. return p * (c /= m) * c * c * c * c + d;
  8329. },
  8330. StrongEaseOut(c, d, p, m) {
  8331. return p * ((c = c / m - 1) * c * c * c * c + 1) + d;
  8332. },
  8333. StrongEaseInOut(c, d, p, m) {
  8334. return (c /= m / 2) < 1 ? p / 2 * c * c * c * c * c + d : p / 2 * ((c -= 2) * c * c * c * c + 2) + d;
  8335. },
  8336. Linear(c, d, p, m) {
  8337. return p * c / m + d;
  8338. }
  8339. };
  8340. })(Fo);
  8341. (function(s) {
  8342. Object.defineProperty(s, "__esModule", { value: !0 }), s.Konva = void 0;
  8343. const t = $, e = st, i = rt, n = Ee, r = Ii, a = Hi, o = Bn, h = li, l = En, A = ft, u = gi, f = Fo, c = Xt, d = It;
  8344. s.Konva = e.Util._assign(t.Konva, {
  8345. Util: e.Util,
  8346. Transform: e.Transform,
  8347. Node: i.Node,
  8348. Container: n.Container,
  8349. Stage: r.Stage,
  8350. stages: r.stages,
  8351. Layer: a.Layer,
  8352. FastLayer: o.FastLayer,
  8353. Group: h.Group,
  8354. DD: l.DD,
  8355. Shape: A.Shape,
  8356. shapes: A.shapes,
  8357. Animation: u.Animation,
  8358. Tween: f.Tween,
  8359. Easings: f.Easings,
  8360. Context: c.Context,
  8361. Canvas: d.Canvas
  8362. }), s.default = s.Konva;
  8363. })(Po);
  8364. var zn = {};
  8365. Object.defineProperty(zn, "__esModule", { value: !0 });
  8366. zn.Arc = void 0;
  8367. const Un = V, e0 = ft, xa = $, Hn = O, i0 = $;
  8368. class te extends e0.Shape {
  8369. _sceneFunc(t) {
  8370. var e = xa.Konva.getAngle(this.angle()), i = this.clockwise();
  8371. t.beginPath(), t.arc(0, 0, this.outerRadius(), 0, e, i), t.arc(0, 0, this.innerRadius(), e, 0, !i), t.closePath(), t.fillStrokeShape(this);
  8372. }
  8373. getWidth() {
  8374. return this.outerRadius() * 2;
  8375. }
  8376. getHeight() {
  8377. return this.outerRadius() * 2;
  8378. }
  8379. setWidth(t) {
  8380. this.outerRadius(t / 2);
  8381. }
  8382. setHeight(t) {
  8383. this.outerRadius(t / 2);
  8384. }
  8385. getSelfRect() {
  8386. const t = this.innerRadius(), e = this.outerRadius(), i = this.clockwise(), n = xa.Konva.getAngle(i ? 360 - this.angle() : this.angle()), r = Math.cos(Math.min(n, Math.PI)), a = 1, o = Math.sin(Math.min(Math.max(Math.PI, n), 3 * Math.PI / 2)), h = Math.sin(Math.min(n, Math.PI / 2)), l = r * (r > 0 ? t : e), A = a * e, u = o * (o > 0 ? t : e), f = h * (h > 0 ? e : t);
  8387. return {
  8388. x: l,
  8389. y: i ? -1 * f : u,
  8390. width: A - l,
  8391. height: f - u
  8392. };
  8393. }
  8394. }
  8395. zn.Arc = te;
  8396. te.prototype._centroid = !0;
  8397. te.prototype.className = "Arc";
  8398. te.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
  8399. (0, i0._registerNode)(te);
  8400. Un.Factory.addGetterSetter(te, "innerRadius", 0, (0, Hn.getNumberValidator)());
  8401. Un.Factory.addGetterSetter(te, "outerRadius", 0, (0, Hn.getNumberValidator)());
  8402. Un.Factory.addGetterSetter(te, "angle", 0, (0, Hn.getNumberValidator)());
  8403. Un.Factory.addGetterSetter(te, "clockwise", !1, (0, Hn.getBooleanValidator)());
  8404. var Vn = {};
  8405. Object.defineProperty(Vn, "__esModule", { value: !0 });
  8406. Vn.Arrow = void 0;
  8407. const $n = V, n0 = Gi, ko = O, s0 = $, ba = hi;
  8408. class ke extends n0.Line {
  8409. _sceneFunc(t) {
  8410. super._sceneFunc(t);
  8411. var e = Math.PI * 2, i = this.points(), n = i, r = this.tension() !== 0 && i.length > 4;
  8412. r && (n = this.getTensionPoints());
  8413. var a = this.pointerLength(), o = i.length, h, l;
  8414. if (r) {
  8415. const f = [
  8416. n[n.length - 4],
  8417. n[n.length - 3],
  8418. n[n.length - 2],
  8419. n[n.length - 1],
  8420. i[o - 2],
  8421. i[o - 1]
  8422. ], c = ba.Path.calcLength(n[n.length - 4], n[n.length - 3], "C", f), d = ba.Path.getPointOnQuadraticBezier(Math.min(1, 1 - a / c), f[0], f[1], f[2], f[3], f[4], f[5]);
  8423. h = i[o - 2] - d.x, l = i[o - 1] - d.y;
  8424. } else
  8425. h = i[o - 2] - i[o - 4], l = i[o - 1] - i[o - 3];
  8426. var A = (Math.atan2(l, h) + e) % e, u = this.pointerWidth();
  8427. this.pointerAtEnding() && (t.save(), t.beginPath(), t.translate(i[o - 2], i[o - 1]), t.rotate(A), t.moveTo(0, 0), t.lineTo(-a, u / 2), t.lineTo(-a, -u / 2), t.closePath(), t.restore(), this.__fillStroke(t)), this.pointerAtBeginning() && (t.save(), t.beginPath(), t.translate(i[0], i[1]), r ? (h = (n[0] + n[2]) / 2 - i[0], l = (n[1] + n[3]) / 2 - i[1]) : (h = i[2] - i[0], l = i[3] - i[1]), t.rotate((Math.atan2(-l, -h) + e) % e), t.moveTo(0, 0), t.lineTo(-a, u / 2), t.lineTo(-a, -u / 2), t.closePath(), t.restore(), this.__fillStroke(t));
  8428. }
  8429. __fillStroke(t) {
  8430. var e = this.dashEnabled();
  8431. e && (this.attrs.dashEnabled = !1, t.setLineDash([])), t.fillStrokeShape(this), e && (this.attrs.dashEnabled = !0);
  8432. }
  8433. getSelfRect() {
  8434. const t = super.getSelfRect(), e = this.pointerWidth() / 2;
  8435. return {
  8436. x: t.x - e,
  8437. y: t.y - e,
  8438. width: t.width + e * 2,
  8439. height: t.height + e * 2
  8440. };
  8441. }
  8442. }
  8443. Vn.Arrow = ke;
  8444. ke.prototype.className = "Arrow";
  8445. (0, s0._registerNode)(ke);
  8446. $n.Factory.addGetterSetter(ke, "pointerLength", 10, (0, ko.getNumberValidator)());
  8447. $n.Factory.addGetterSetter(ke, "pointerWidth", 10, (0, ko.getNumberValidator)());
  8448. $n.Factory.addGetterSetter(ke, "pointerAtBeginning", !1);
  8449. $n.Factory.addGetterSetter(ke, "pointerAtEnding", !0);
  8450. var Wn = {};
  8451. Object.defineProperty(Wn, "__esModule", { value: !0 });
  8452. Wn.Ellipse = void 0;
  8453. const wr = V, r0 = ft, Do = O, a0 = $;
  8454. class pe extends r0.Shape {
  8455. _sceneFunc(t) {
  8456. var e = this.radiusX(), i = this.radiusY();
  8457. t.beginPath(), t.save(), e !== i && t.scale(1, i / e), t.arc(0, 0, e, 0, Math.PI * 2, !1), t.restore(), t.closePath(), t.fillStrokeShape(this);
  8458. }
  8459. getWidth() {
  8460. return this.radiusX() * 2;
  8461. }
  8462. getHeight() {
  8463. return this.radiusY() * 2;
  8464. }
  8465. setWidth(t) {
  8466. this.radiusX(t / 2);
  8467. }
  8468. setHeight(t) {
  8469. this.radiusY(t / 2);
  8470. }
  8471. }
  8472. Wn.Ellipse = pe;
  8473. pe.prototype.className = "Ellipse";
  8474. pe.prototype._centroid = !0;
  8475. pe.prototype._attrsAffectingSize = ["radiusX", "radiusY"];
  8476. (0, a0._registerNode)(pe);
  8477. wr.Factory.addComponentsGetterSetter(pe, "radius", ["x", "y"]);
  8478. wr.Factory.addGetterSetter(pe, "radiusX", 0, (0, Do.getNumberValidator)());
  8479. wr.Factory.addGetterSetter(pe, "radiusY", 0, (0, Do.getNumberValidator)());
  8480. var Yn = {};
  8481. Object.defineProperty(Yn, "__esModule", { value: !0 });
  8482. Yn.Image = void 0;
  8483. const Gs = st, De = V, o0 = ft, h0 = $, Vi = O;
  8484. let Bt = class Io extends o0.Shape {
  8485. constructor(t) {
  8486. super(t), this.on("imageChange.konva", () => {
  8487. this._setImageLoad();
  8488. }), this._setImageLoad();
  8489. }
  8490. _setImageLoad() {
  8491. const t = this.image();
  8492. t && t.complete || t && t.readyState === 4 || t && t.addEventListener && t.addEventListener("load", () => {
  8493. this._requestDraw();
  8494. });
  8495. }
  8496. _useBufferCanvas() {
  8497. return super._useBufferCanvas(!0);
  8498. }
  8499. _sceneFunc(t) {
  8500. const e = this.getWidth(), i = this.getHeight(), n = this.cornerRadius(), r = this.attrs.image;
  8501. let a;
  8502. if (r) {
  8503. const o = this.attrs.cropWidth, h = this.attrs.cropHeight;
  8504. o && h ? a = [
  8505. r,
  8506. this.cropX(),
  8507. this.cropY(),
  8508. o,
  8509. h,
  8510. 0,
  8511. 0,
  8512. e,
  8513. i
  8514. ] : a = [r, 0, 0, e, i];
  8515. }
  8516. (this.hasFill() || this.hasStroke() || n) && (t.beginPath(), n ? Gs.Util.drawRoundedRectPath(t, e, i, n) : t.rect(0, 0, e, i), t.closePath(), t.fillStrokeShape(this)), r && (n && t.clip(), t.drawImage.apply(t, a));
  8517. }
  8518. _hitFunc(t) {
  8519. var e = this.width(), i = this.height(), n = this.cornerRadius();
  8520. t.beginPath(), n ? Gs.Util.drawRoundedRectPath(t, e, i, n) : t.rect(0, 0, e, i), t.closePath(), t.fillStrokeShape(this);
  8521. }
  8522. getWidth() {
  8523. var t, e;
  8524. return (t = this.attrs.width) !== null && t !== void 0 ? t : (e = this.image()) === null || e === void 0 ? void 0 : e.width;
  8525. }
  8526. getHeight() {
  8527. var t, e;
  8528. return (t = this.attrs.height) !== null && t !== void 0 ? t : (e = this.image()) === null || e === void 0 ? void 0 : e.height;
  8529. }
  8530. static fromURL(t, e, i = null) {
  8531. var n = Gs.Util.createImageElement();
  8532. n.onload = function() {
  8533. var r = new Io({
  8534. image: n
  8535. });
  8536. e(r);
  8537. }, n.onerror = i, n.crossOrigin = "Anonymous", n.src = t;
  8538. }
  8539. };
  8540. Yn.Image = Bt;
  8541. Bt.prototype.className = "Image";
  8542. (0, h0._registerNode)(Bt);
  8543. De.Factory.addGetterSetter(Bt, "cornerRadius", 0, (0, Vi.getNumberOrArrayOfNumbersValidator)(4));
  8544. De.Factory.addGetterSetter(Bt, "image");
  8545. De.Factory.addComponentsGetterSetter(Bt, "crop", ["x", "y", "width", "height"]);
  8546. De.Factory.addGetterSetter(Bt, "cropX", 0, (0, Vi.getNumberValidator)());
  8547. De.Factory.addGetterSetter(Bt, "cropY", 0, (0, Vi.getNumberValidator)());
  8548. De.Factory.addGetterSetter(Bt, "cropWidth", 0, (0, Vi.getNumberValidator)());
  8549. De.Factory.addGetterSetter(Bt, "cropHeight", 0, (0, Vi.getNumberValidator)());
  8550. var ii = {};
  8551. Object.defineProperty(ii, "__esModule", { value: !0 });
  8552. var To = ii.Tag = Oo = ii.Label = void 0;
  8553. const Xn = V, l0 = ft, A0 = li, Sr = O, Lo = $;
  8554. var Ro = [
  8555. "fontFamily",
  8556. "fontSize",
  8557. "fontStyle",
  8558. "padding",
  8559. "lineHeight",
  8560. "text",
  8561. "width",
  8562. "height",
  8563. "pointerDirection",
  8564. "pointerWidth",
  8565. "pointerHeight"
  8566. ], c0 = "Change.konva", d0 = "none", tr = "up", er = "right", ir = "down", nr = "left", u0 = Ro.length;
  8567. class Cr extends A0.Group {
  8568. constructor(t) {
  8569. super(t), this.on("add.konva", function(e) {
  8570. this._addListeners(e.child), this._sync();
  8571. });
  8572. }
  8573. getText() {
  8574. return this.find("Text")[0];
  8575. }
  8576. getTag() {
  8577. return this.find("Tag")[0];
  8578. }
  8579. _addListeners(t) {
  8580. var e = this, i, n = function() {
  8581. e._sync();
  8582. };
  8583. for (i = 0; i < u0; i++)
  8584. t.on(Ro[i] + c0, n);
  8585. }
  8586. getWidth() {
  8587. return this.getText().width();
  8588. }
  8589. getHeight() {
  8590. return this.getText().height();
  8591. }
  8592. _sync() {
  8593. var t = this.getText(), e = this.getTag(), i, n, r, a, o, h, l;
  8594. if (t && e) {
  8595. switch (i = t.width(), n = t.height(), r = e.pointerDirection(), a = e.pointerWidth(), l = e.pointerHeight(), o = 0, h = 0, r) {
  8596. case tr:
  8597. o = i / 2, h = -1 * l;
  8598. break;
  8599. case er:
  8600. o = i + a, h = n / 2;
  8601. break;
  8602. case ir:
  8603. o = i / 2, h = n + l;
  8604. break;
  8605. case nr:
  8606. o = -1 * a, h = n / 2;
  8607. break;
  8608. }
  8609. e.setAttrs({
  8610. x: -1 * o,
  8611. y: -1 * h,
  8612. width: i,
  8613. height: n
  8614. }), t.setAttrs({
  8615. x: -1 * o,
  8616. y: -1 * h
  8617. });
  8618. }
  8619. }
  8620. }
  8621. var Oo = ii.Label = Cr;
  8622. Cr.prototype.className = "Label";
  8623. (0, Lo._registerNode)(Cr);
  8624. class Ie extends l0.Shape {
  8625. _sceneFunc(t) {
  8626. var e = this.width(), i = this.height(), n = this.pointerDirection(), r = this.pointerWidth(), a = this.pointerHeight(), o = this.cornerRadius();
  8627. let h = 0, l = 0, A = 0, u = 0;
  8628. typeof o == "number" ? h = l = A = u = Math.min(o, e / 2, i / 2) : (h = Math.min(o[0] || 0, e / 2, i / 2), l = Math.min(o[1] || 0, e / 2, i / 2), u = Math.min(o[2] || 0, e / 2, i / 2), A = Math.min(o[3] || 0, e / 2, i / 2)), t.beginPath(), t.moveTo(h, 0), n === tr && (t.lineTo((e - r) / 2, 0), t.lineTo(e / 2, -1 * a), t.lineTo((e + r) / 2, 0)), t.lineTo(e - l, 0), t.arc(e - l, l, l, Math.PI * 3 / 2, 0, !1), n === er && (t.lineTo(e, (i - a) / 2), t.lineTo(e + r, i / 2), t.lineTo(e, (i + a) / 2)), t.lineTo(e, i - u), t.arc(e - u, i - u, u, 0, Math.PI / 2, !1), n === ir && (t.lineTo((e + r) / 2, i), t.lineTo(e / 2, i + a), t.lineTo((e - r) / 2, i)), t.lineTo(A, i), t.arc(A, i - A, A, Math.PI / 2, Math.PI, !1), n === nr && (t.lineTo(0, (i + a) / 2), t.lineTo(-1 * r, i / 2), t.lineTo(0, (i - a) / 2)), t.lineTo(0, h), t.arc(h, h, h, Math.PI, Math.PI * 3 / 2, !1), t.closePath(), t.fillStrokeShape(this);
  8629. }
  8630. getSelfRect() {
  8631. var t = 0, e = 0, i = this.pointerWidth(), n = this.pointerHeight(), r = this.pointerDirection(), a = this.width(), o = this.height();
  8632. return r === tr ? (e -= n, o += n) : r === ir ? o += n : r === nr ? (t -= i * 1.5, a += i) : r === er && (a += i * 1.5), {
  8633. x: t,
  8634. y: e,
  8635. width: a,
  8636. height: o
  8637. };
  8638. }
  8639. }
  8640. To = ii.Tag = Ie;
  8641. Ie.prototype.className = "Tag";
  8642. (0, Lo._registerNode)(Ie);
  8643. Xn.Factory.addGetterSetter(Ie, "pointerDirection", d0);
  8644. Xn.Factory.addGetterSetter(Ie, "pointerWidth", 0, (0, Sr.getNumberValidator)());
  8645. Xn.Factory.addGetterSetter(Ie, "pointerHeight", 0, (0, Sr.getNumberValidator)());
  8646. Xn.Factory.addGetterSetter(Ie, "cornerRadius", 0, (0, Sr.getNumberOrArrayOfNumbersValidator)(4));
  8647. var jn = {};
  8648. Object.defineProperty(jn, "__esModule", { value: !0 });
  8649. jn.RegularPolygon = void 0;
  8650. const No = V, f0 = ft, Go = O, g0 = $;
  8651. class Te extends f0.Shape {
  8652. _sceneFunc(t) {
  8653. const e = this._getPoints();
  8654. t.beginPath(), t.moveTo(e[0].x, e[0].y);
  8655. for (var i = 1; i < e.length; i++)
  8656. t.lineTo(e[i].x, e[i].y);
  8657. t.closePath(), t.fillStrokeShape(this);
  8658. }
  8659. _getPoints() {
  8660. const t = this.attrs.sides, e = this.attrs.radius || 0, i = [];
  8661. for (var n = 0; n < t; n++)
  8662. i.push({
  8663. x: e * Math.sin(n * 2 * Math.PI / t),
  8664. y: -1 * e * Math.cos(n * 2 * Math.PI / t)
  8665. });
  8666. return i;
  8667. }
  8668. getSelfRect() {
  8669. const t = this._getPoints();
  8670. var e = t[0].x, i = t[0].y, n = t[0].x, r = t[0].y;
  8671. return t.forEach((a) => {
  8672. e = Math.min(e, a.x), i = Math.max(i, a.x), n = Math.min(n, a.y), r = Math.max(r, a.y);
  8673. }), {
  8674. x: e,
  8675. y: n,
  8676. width: i - e,
  8677. height: r - n
  8678. };
  8679. }
  8680. getWidth() {
  8681. return this.radius() * 2;
  8682. }
  8683. getHeight() {
  8684. return this.radius() * 2;
  8685. }
  8686. setWidth(t) {
  8687. this.radius(t / 2);
  8688. }
  8689. setHeight(t) {
  8690. this.radius(t / 2);
  8691. }
  8692. }
  8693. jn.RegularPolygon = Te;
  8694. Te.prototype.className = "RegularPolygon";
  8695. Te.prototype._centroid = !0;
  8696. Te.prototype._attrsAffectingSize = ["radius"];
  8697. (0, g0._registerNode)(Te);
  8698. No.Factory.addGetterSetter(Te, "radius", 0, (0, Go.getNumberValidator)());
  8699. No.Factory.addGetterSetter(Te, "sides", 0, (0, Go.getNumberValidator)());
  8700. var qn = {};
  8701. Object.defineProperty(qn, "__esModule", { value: !0 });
  8702. qn.Ring = void 0;
  8703. const Bo = V, p0 = ft, zo = O, y0 = $;
  8704. var wa = Math.PI * 2;
  8705. class Le extends p0.Shape {
  8706. _sceneFunc(t) {
  8707. t.beginPath(), t.arc(0, 0, this.innerRadius(), 0, wa, !1), t.moveTo(this.outerRadius(), 0), t.arc(0, 0, this.outerRadius(), wa, 0, !0), t.closePath(), t.fillStrokeShape(this);
  8708. }
  8709. getWidth() {
  8710. return this.outerRadius() * 2;
  8711. }
  8712. getHeight() {
  8713. return this.outerRadius() * 2;
  8714. }
  8715. setWidth(t) {
  8716. this.outerRadius(t / 2);
  8717. }
  8718. setHeight(t) {
  8719. this.outerRadius(t / 2);
  8720. }
  8721. }
  8722. qn.Ring = Le;
  8723. Le.prototype.className = "Ring";
  8724. Le.prototype._centroid = !0;
  8725. Le.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
  8726. (0, y0._registerNode)(Le);
  8727. Bo.Factory.addGetterSetter(Le, "innerRadius", 0, (0, zo.getNumberValidator)());
  8728. Bo.Factory.addGetterSetter(Le, "outerRadius", 0, (0, zo.getNumberValidator)());
  8729. var Qn = {};
  8730. Object.defineProperty(Qn, "__esModule", { value: !0 });
  8731. Qn.Sprite = void 0;
  8732. const Re = V, m0 = ft, v0 = gi, Uo = O, _0 = $;
  8733. class zt extends m0.Shape {
  8734. constructor(t) {
  8735. super(t), this._updated = !0, this.anim = new v0.Animation(() => {
  8736. var e = this._updated;
  8737. return this._updated = !1, e;
  8738. }), this.on("animationChange.konva", function() {
  8739. this.frameIndex(0);
  8740. }), this.on("frameIndexChange.konva", function() {
  8741. this._updated = !0;
  8742. }), this.on("frameRateChange.konva", function() {
  8743. this.anim.isRunning() && (clearInterval(this.interval), this._setInterval());
  8744. });
  8745. }
  8746. _sceneFunc(t) {
  8747. var e = this.animation(), i = this.frameIndex(), n = i * 4, r = this.animations()[e], a = this.frameOffsets(), o = r[n + 0], h = r[n + 1], l = r[n + 2], A = r[n + 3], u = this.image();
  8748. if ((this.hasFill() || this.hasStroke()) && (t.beginPath(), t.rect(0, 0, l, A), t.closePath(), t.fillStrokeShape(this)), u)
  8749. if (a) {
  8750. var f = a[e], c = i * 2;
  8751. t.drawImage(u, o, h, l, A, f[c + 0], f[c + 1], l, A);
  8752. } else
  8753. t.drawImage(u, o, h, l, A, 0, 0, l, A);
  8754. }
  8755. _hitFunc(t) {
  8756. var e = this.animation(), i = this.frameIndex(), n = i * 4, r = this.animations()[e], a = this.frameOffsets(), o = r[n + 2], h = r[n + 3];
  8757. if (t.beginPath(), a) {
  8758. var l = a[e], A = i * 2;
  8759. t.rect(l[A + 0], l[A + 1], o, h);
  8760. } else
  8761. t.rect(0, 0, o, h);
  8762. t.closePath(), t.fillShape(this);
  8763. }
  8764. _useBufferCanvas() {
  8765. return super._useBufferCanvas(!0);
  8766. }
  8767. _setInterval() {
  8768. var t = this;
  8769. this.interval = setInterval(function() {
  8770. t._updateIndex();
  8771. }, 1e3 / this.frameRate());
  8772. }
  8773. start() {
  8774. if (!this.isRunning()) {
  8775. var t = this.getLayer();
  8776. this.anim.setLayers(t), this._setInterval(), this.anim.start();
  8777. }
  8778. }
  8779. stop() {
  8780. this.anim.stop(), clearInterval(this.interval);
  8781. }
  8782. isRunning() {
  8783. return this.anim.isRunning();
  8784. }
  8785. _updateIndex() {
  8786. var t = this.frameIndex(), e = this.animation(), i = this.animations(), n = i[e], r = n.length / 4;
  8787. t < r - 1 ? this.frameIndex(t + 1) : this.frameIndex(0);
  8788. }
  8789. }
  8790. Qn.Sprite = zt;
  8791. zt.prototype.className = "Sprite";
  8792. (0, _0._registerNode)(zt);
  8793. Re.Factory.addGetterSetter(zt, "animation");
  8794. Re.Factory.addGetterSetter(zt, "animations");
  8795. Re.Factory.addGetterSetter(zt, "frameOffsets");
  8796. Re.Factory.addGetterSetter(zt, "image");
  8797. Re.Factory.addGetterSetter(zt, "frameIndex", 0, (0, Uo.getNumberValidator)());
  8798. Re.Factory.addGetterSetter(zt, "frameRate", 17, (0, Uo.getNumberValidator)());
  8799. Re.Factory.backCompat(zt, {
  8800. index: "frameIndex",
  8801. getIndex: "getFrameIndex",
  8802. setIndex: "setFrameIndex"
  8803. });
  8804. var Kn = {};
  8805. Object.defineProperty(Kn, "__esModule", { value: !0 });
  8806. Kn.Star = void 0;
  8807. const Mr = V, x0 = ft, Pr = O, b0 = $;
  8808. class ye extends x0.Shape {
  8809. _sceneFunc(t) {
  8810. var e = this.innerRadius(), i = this.outerRadius(), n = this.numPoints();
  8811. t.beginPath(), t.moveTo(0, 0 - i);
  8812. for (var r = 1; r < n * 2; r++) {
  8813. var a = r % 2 === 0 ? i : e, o = a * Math.sin(r * Math.PI / n), h = -1 * a * Math.cos(r * Math.PI / n);
  8814. t.lineTo(o, h);
  8815. }
  8816. t.closePath(), t.fillStrokeShape(this);
  8817. }
  8818. getWidth() {
  8819. return this.outerRadius() * 2;
  8820. }
  8821. getHeight() {
  8822. return this.outerRadius() * 2;
  8823. }
  8824. setWidth(t) {
  8825. this.outerRadius(t / 2);
  8826. }
  8827. setHeight(t) {
  8828. this.outerRadius(t / 2);
  8829. }
  8830. }
  8831. Kn.Star = ye;
  8832. ye.prototype.className = "Star";
  8833. ye.prototype._centroid = !0;
  8834. ye.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
  8835. (0, b0._registerNode)(ye);
  8836. Mr.Factory.addGetterSetter(ye, "numPoints", 5, (0, Pr.getNumberValidator)());
  8837. Mr.Factory.addGetterSetter(ye, "innerRadius", 0, (0, Pr.getNumberValidator)());
  8838. Mr.Factory.addGetterSetter(ye, "outerRadius", 0, (0, Pr.getNumberValidator)());
  8839. var Me = {};
  8840. Object.defineProperty(Me, "__esModule", { value: !0 });
  8841. var dn = Me.Text = Me.stringToArray = void 0;
  8842. const sr = st, vt = V, w0 = ft, me = O, S0 = $;
  8843. function Ho(s) {
  8844. return Array.from(s);
  8845. }
  8846. Me.stringToArray = Ho;
  8847. var $e = "auto", C0 = "center", Vo = "inherit", _i = "justify", M0 = "Change.konva", P0 = "2d", Sa = "-", $o = "left", E0 = "text", F0 = "Text", k0 = "top", D0 = "bottom", Ca = "middle", Wo = "normal", I0 = "px ", en = " ", T0 = "right", Ma = "rtl", L0 = "word", R0 = "char", Pa = "none", Bs = "…", Yo = [
  8848. "direction",
  8849. "fontFamily",
  8850. "fontSize",
  8851. "fontStyle",
  8852. "fontVariant",
  8853. "padding",
  8854. "align",
  8855. "verticalAlign",
  8856. "lineHeight",
  8857. "text",
  8858. "width",
  8859. "height",
  8860. "wrap",
  8861. "ellipsis",
  8862. "letterSpacing"
  8863. ], O0 = Yo.length;
  8864. function N0(s) {
  8865. return s.split(",").map((t) => {
  8866. t = t.trim();
  8867. const e = t.indexOf(" ") >= 0, i = t.indexOf('"') >= 0 || t.indexOf("'") >= 0;
  8868. return e && !i && (t = `"${t}"`), t;
  8869. }).join(", ");
  8870. }
  8871. var nn;
  8872. function zs() {
  8873. return nn || (nn = sr.Util.createCanvasElement().getContext(P0), nn);
  8874. }
  8875. function G0(s) {
  8876. s.fillText(this._partialText, this._partialTextX, this._partialTextY);
  8877. }
  8878. function B0(s) {
  8879. s.setAttr("miterLimit", 2), s.strokeText(this._partialText, this._partialTextX, this._partialTextY);
  8880. }
  8881. function z0(s) {
  8882. return s = s || {}, !s.fillLinearGradientColorStops && !s.fillRadialGradientColorStops && !s.fillPatternImage && (s.fill = s.fill || "black"), s;
  8883. }
  8884. class lt extends w0.Shape {
  8885. constructor(t) {
  8886. super(z0(t)), this._partialTextX = 0, this._partialTextY = 0;
  8887. for (var e = 0; e < O0; e++)
  8888. this.on(Yo[e] + M0, this._setTextData);
  8889. this._setTextData();
  8890. }
  8891. _sceneFunc(t) {
  8892. var e = this.textArr, i = e.length;
  8893. if (this.text()) {
  8894. var n = this.padding(), r = this.fontSize(), a = this.lineHeight() * r, o = this.verticalAlign(), h = this.direction(), l = 0, A = this.align(), u = this.getWidth(), f = this.letterSpacing(), c = this.fill(), d = this.textDecoration(), p = d.indexOf("underline") !== -1, m = d.indexOf("line-through") !== -1, v;
  8895. h = h === Vo ? t.direction : h;
  8896. var _ = 0, _ = a / 2, g = 0, y = 0;
  8897. for (h === Ma && t.setAttr("direction", h), t.setAttr("font", this._getContextFont()), t.setAttr("textBaseline", Ca), t.setAttr("textAlign", $o), o === Ca ? l = (this.getHeight() - i * a - n * 2) / 2 : o === D0 && (l = this.getHeight() - i * a - n * 2), t.translate(n, l + n), v = 0; v < i; v++) {
  8898. var g = 0, y = 0, x = e[v], b = x.text, C = x.width, w = x.lastInParagraph, E, S, P;
  8899. if (t.save(), A === T0 ? g += u - C - n * 2 : A === C0 && (g += (u - C - n * 2) / 2), p) {
  8900. t.save(), t.beginPath(), t.moveTo(g, _ + y + Math.round(r / 2)), E = b.split(" ").length - 1, S = E === 0, P = A === _i && !w ? u - n * 2 : C, t.lineTo(g + Math.round(P), _ + y + Math.round(r / 2)), t.lineWidth = r / 15;
  8901. const T = this._getLinearGradient();
  8902. t.strokeStyle = T || c, t.stroke(), t.restore();
  8903. }
  8904. if (m) {
  8905. t.save(), t.beginPath(), t.moveTo(g, _ + y), E = b.split(" ").length - 1, S = E === 0, P = A === _i && w && !S ? u - n * 2 : C, t.lineTo(g + Math.round(P), _ + y), t.lineWidth = r / 15;
  8906. const T = this._getLinearGradient();
  8907. t.strokeStyle = T || c, t.stroke(), t.restore();
  8908. }
  8909. if (h !== Ma && (f !== 0 || A === _i)) {
  8910. E = b.split(" ").length - 1;
  8911. for (var k = Ho(b), F = 0; F < k.length; F++) {
  8912. var L = k[F];
  8913. L === " " && !w && A === _i && (g += (u - n * 2 - C) / E), this._partialTextX = g, this._partialTextY = _ + y, this._partialText = L, t.fillStrokeShape(this), g += this.measureSize(L).width + f;
  8914. }
  8915. } else
  8916. f !== 0 && t.setAttr("letterSpacing", `${f}px`), this._partialTextX = g, this._partialTextY = _ + y, this._partialText = b, t.fillStrokeShape(this);
  8917. t.restore(), i > 1 && (_ += a);
  8918. }
  8919. }
  8920. }
  8921. _hitFunc(t) {
  8922. var e = this.getWidth(), i = this.getHeight();
  8923. t.beginPath(), t.rect(0, 0, e, i), t.closePath(), t.fillStrokeShape(this);
  8924. }
  8925. setText(t) {
  8926. var e = sr.Util._isString(t) ? t : t == null ? "" : t + "";
  8927. return this._setAttr(E0, e), this;
  8928. }
  8929. getWidth() {
  8930. var t = this.attrs.width === $e || this.attrs.width === void 0;
  8931. return t ? this.getTextWidth() + this.padding() * 2 : this.attrs.width;
  8932. }
  8933. getHeight() {
  8934. var t = this.attrs.height === $e || this.attrs.height === void 0;
  8935. return t ? this.fontSize() * this.textArr.length * this.lineHeight() + this.padding() * 2 : this.attrs.height;
  8936. }
  8937. getTextWidth() {
  8938. return this.textWidth;
  8939. }
  8940. getTextHeight() {
  8941. return sr.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."), this.textHeight;
  8942. }
  8943. measureSize(t) {
  8944. var e = zs(), i = this.fontSize(), n;
  8945. return e.save(), e.font = this._getContextFont(), n = e.measureText(t), e.restore(), {
  8946. width: n.width,
  8947. height: i
  8948. };
  8949. }
  8950. _getContextFont() {
  8951. return this.fontStyle() + en + this.fontVariant() + en + (this.fontSize() + I0) + N0(this.fontFamily());
  8952. }
  8953. _addTextLine(t) {
  8954. this.align() === _i && (t = t.trim());
  8955. var i = this._getTextWidth(t);
  8956. return this.textArr.push({
  8957. text: t,
  8958. width: i,
  8959. lastInParagraph: !1
  8960. });
  8961. }
  8962. _getTextWidth(t) {
  8963. var e = this.letterSpacing(), i = t.length;
  8964. return zs().measureText(t).width + (i ? e * (i - 1) : 0);
  8965. }
  8966. _setTextData() {
  8967. var t = this.text().split(`
  8968. `), e = +this.fontSize(), i = 0, n = this.lineHeight() * e, r = this.attrs.width, a = this.attrs.height, o = r !== $e && r !== void 0, h = a !== $e && a !== void 0, l = this.padding(), A = r - l * 2, u = a - l * 2, f = 0, c = this.wrap(), d = c !== Pa, p = c !== R0 && d, m = this.ellipsis();
  8969. this.textArr = [], zs().font = this._getContextFont();
  8970. for (var v = m ? this._getTextWidth(Bs) : 0, _ = 0, g = t.length; _ < g; ++_) {
  8971. var y = t[_], x = this._getTextWidth(y);
  8972. if (o && x > A)
  8973. for (; y.length > 0; ) {
  8974. for (var b = 0, C = y.length, w = "", E = 0; b < C; ) {
  8975. var S = b + C >>> 1, P = y.slice(0, S + 1), k = this._getTextWidth(P) + v;
  8976. k <= A ? (b = S + 1, w = P, E = k) : C = S;
  8977. }
  8978. if (w) {
  8979. if (p) {
  8980. var F, L = y[w.length], I = L === en || L === Sa;
  8981. I && E <= A ? F = w.length : F = Math.max(w.lastIndexOf(en), w.lastIndexOf(Sa)) + 1, F > 0 && (b = F, w = w.slice(0, b), E = this._getTextWidth(w));
  8982. }
  8983. w = w.trimRight(), this._addTextLine(w), i = Math.max(i, E), f += n;
  8984. var z = this._shouldHandleEllipsis(f);
  8985. if (z) {
  8986. this._tryToAddEllipsisToLastLine();
  8987. break;
  8988. }
  8989. if (y = y.slice(b), y = y.trimLeft(), y.length > 0 && (x = this._getTextWidth(y), x <= A)) {
  8990. this._addTextLine(y), f += n, i = Math.max(i, x);
  8991. break;
  8992. }
  8993. } else
  8994. break;
  8995. }
  8996. else
  8997. this._addTextLine(y), f += n, i = Math.max(i, x), this._shouldHandleEllipsis(f) && _ < g - 1 && this._tryToAddEllipsisToLastLine();
  8998. if (this.textArr[this.textArr.length - 1] && (this.textArr[this.textArr.length - 1].lastInParagraph = !0), h && f + n > u)
  8999. break;
  9000. }
  9001. this.textHeight = e, this.textWidth = i;
  9002. }
  9003. _shouldHandleEllipsis(t) {
  9004. var e = +this.fontSize(), i = this.lineHeight() * e, n = this.attrs.height, r = n !== $e && n !== void 0, a = this.padding(), o = n - a * 2, h = this.wrap(), l = h !== Pa;
  9005. return !l || r && t + i > o;
  9006. }
  9007. _tryToAddEllipsisToLastLine() {
  9008. var t = this.attrs.width, e = t !== $e && t !== void 0, i = this.padding(), n = t - i * 2, r = this.ellipsis(), a = this.textArr[this.textArr.length - 1];
  9009. if (!(!a || !r)) {
  9010. if (e) {
  9011. var o = this._getTextWidth(a.text + Bs) < n;
  9012. o || (a.text = a.text.slice(0, a.text.length - 3));
  9013. }
  9014. this.textArr.splice(this.textArr.length - 1, 1), this._addTextLine(a.text + Bs);
  9015. }
  9016. }
  9017. getStrokeScaleEnabled() {
  9018. return !0;
  9019. }
  9020. _useBufferCanvas() {
  9021. const t = this.textDecoration().indexOf("underline") !== -1 || this.textDecoration().indexOf("line-through") !== -1, e = this.hasShadow();
  9022. return t && e ? !0 : super._useBufferCanvas();
  9023. }
  9024. }
  9025. dn = Me.Text = lt;
  9026. lt.prototype._fillFunc = G0;
  9027. lt.prototype._strokeFunc = B0;
  9028. lt.prototype.className = F0;
  9029. lt.prototype._attrsAffectingSize = [
  9030. "text",
  9031. "fontSize",
  9032. "padding",
  9033. "wrap",
  9034. "lineHeight",
  9035. "letterSpacing"
  9036. ];
  9037. (0, S0._registerNode)(lt);
  9038. vt.Factory.overWriteSetter(lt, "width", (0, me.getNumberOrAutoValidator)());
  9039. vt.Factory.overWriteSetter(lt, "height", (0, me.getNumberOrAutoValidator)());
  9040. vt.Factory.addGetterSetter(lt, "direction", Vo);
  9041. vt.Factory.addGetterSetter(lt, "fontFamily", "Arial");
  9042. vt.Factory.addGetterSetter(lt, "fontSize", 12, (0, me.getNumberValidator)());
  9043. vt.Factory.addGetterSetter(lt, "fontStyle", Wo);
  9044. vt.Factory.addGetterSetter(lt, "fontVariant", Wo);
  9045. vt.Factory.addGetterSetter(lt, "padding", 0, (0, me.getNumberValidator)());
  9046. vt.Factory.addGetterSetter(lt, "align", $o);
  9047. vt.Factory.addGetterSetter(lt, "verticalAlign", k0);
  9048. vt.Factory.addGetterSetter(lt, "lineHeight", 1, (0, me.getNumberValidator)());
  9049. vt.Factory.addGetterSetter(lt, "wrap", L0);
  9050. vt.Factory.addGetterSetter(lt, "ellipsis", !1, (0, me.getBooleanValidator)());
  9051. vt.Factory.addGetterSetter(lt, "letterSpacing", 0, (0, me.getNumberValidator)());
  9052. vt.Factory.addGetterSetter(lt, "text", "", (0, me.getStringValidator)());
  9053. vt.Factory.addGetterSetter(lt, "textDecoration", "");
  9054. var Zn = {};
  9055. Object.defineProperty(Zn, "__esModule", { value: !0 });
  9056. Zn.TextPath = void 0;
  9057. const Us = st, Lt = V, U0 = ft, xi = hi, Hs = Me, Xo = O, H0 = $;
  9058. var V0 = "", jo = "normal";
  9059. function qo(s) {
  9060. s.fillText(this.partialText, 0, 0);
  9061. }
  9062. function Qo(s) {
  9063. s.strokeText(this.partialText, 0, 0);
  9064. }
  9065. class gt extends U0.Shape {
  9066. constructor(t) {
  9067. super(t), this.dummyCanvas = Us.Util.createCanvasElement(), this.dataArray = [], this._readDataAttribute(), this.on("dataChange.konva", function() {
  9068. this._readDataAttribute(), this._setTextData();
  9069. }), this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva", this._setTextData), this._setTextData();
  9070. }
  9071. _getTextPathLength() {
  9072. return xi.Path.getPathLength(this.dataArray);
  9073. }
  9074. _getPointAtLength(t) {
  9075. if (!this.attrs.data)
  9076. return null;
  9077. const e = this.pathLength;
  9078. return t - 1 > e ? null : xi.Path.getPointAtLengthOfDataArray(t, this.dataArray);
  9079. }
  9080. _readDataAttribute() {
  9081. this.dataArray = xi.Path.parsePathData(this.attrs.data), this.pathLength = this._getTextPathLength();
  9082. }
  9083. _sceneFunc(t) {
  9084. t.setAttr("font", this._getContextFont()), t.setAttr("textBaseline", this.textBaseline()), t.setAttr("textAlign", "left"), t.save();
  9085. var e = this.textDecoration(), i = this.fill(), n = this.fontSize(), r = this.glyphInfo;
  9086. e === "underline" && t.beginPath();
  9087. for (var a = 0; a < r.length; a++) {
  9088. t.save();
  9089. var o = r[a].p0;
  9090. t.translate(o.x, o.y), t.rotate(r[a].rotation), this.partialText = r[a].text, t.fillStrokeShape(this), e === "underline" && (a === 0 && t.moveTo(0, n / 2 + 1), t.lineTo(n, n / 2 + 1)), t.restore();
  9091. }
  9092. e === "underline" && (t.strokeStyle = i, t.lineWidth = n / 20, t.stroke()), t.restore();
  9093. }
  9094. _hitFunc(t) {
  9095. t.beginPath();
  9096. var e = this.glyphInfo;
  9097. if (e.length >= 1) {
  9098. var i = e[0].p0;
  9099. t.moveTo(i.x, i.y);
  9100. }
  9101. for (var n = 0; n < e.length; n++) {
  9102. var r = e[n].p1;
  9103. t.lineTo(r.x, r.y);
  9104. }
  9105. t.setAttr("lineWidth", this.fontSize()), t.setAttr("strokeStyle", this.colorKey), t.stroke();
  9106. }
  9107. getTextWidth() {
  9108. return this.textWidth;
  9109. }
  9110. getTextHeight() {
  9111. return Us.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."), this.textHeight;
  9112. }
  9113. setText(t) {
  9114. return Hs.Text.prototype.setText.call(this, t);
  9115. }
  9116. _getContextFont() {
  9117. return Hs.Text.prototype._getContextFont.call(this);
  9118. }
  9119. _getTextSize(t) {
  9120. var e = this.dummyCanvas, i = e.getContext("2d");
  9121. i.save(), i.font = this._getContextFont();
  9122. var n = i.measureText(t);
  9123. return i.restore(), {
  9124. width: n.width,
  9125. height: parseInt(`${this.fontSize()}`, 10)
  9126. };
  9127. }
  9128. _setTextData() {
  9129. const { width: t, height: e } = this._getTextSize(this.attrs.text);
  9130. if (this.textWidth = t, this.textHeight = e, this.glyphInfo = [], !this.attrs.data)
  9131. return null;
  9132. const i = this.letterSpacing(), n = this.align(), r = this.kerningFunc(), a = Math.max(this.textWidth + ((this.attrs.text || "").length - 1) * i, 0);
  9133. let o = 0;
  9134. n === "center" && (o = Math.max(0, this.pathLength / 2 - a / 2)), n === "right" && (o = Math.max(0, this.pathLength - a));
  9135. const h = (0, Hs.stringToArray)(this.text());
  9136. let l = o;
  9137. for (var A = 0; A < h.length; A++) {
  9138. const u = this._getPointAtLength(l);
  9139. if (!u)
  9140. return;
  9141. let f = this._getTextSize(h[A]).width + i;
  9142. if (h[A] === " " && n === "justify") {
  9143. const _ = this.text().split(" ").length - 1;
  9144. f += (this.pathLength - a) / _;
  9145. }
  9146. const c = this._getPointAtLength(l + f);
  9147. if (!c)
  9148. return;
  9149. const d = xi.Path.getLineLength(u.x, u.y, c.x, c.y);
  9150. let p = 0;
  9151. if (r)
  9152. try {
  9153. p = r(h[A - 1], h[A]) * this.fontSize();
  9154. } catch {
  9155. p = 0;
  9156. }
  9157. u.x += p, c.x += p, this.textWidth += p;
  9158. const m = xi.Path.getPointOnLine(p + d / 2, u.x, u.y, c.x, c.y), v = Math.atan2(c.y - u.y, c.x - u.x);
  9159. this.glyphInfo.push({
  9160. transposeX: m.x,
  9161. transposeY: m.y,
  9162. text: h[A],
  9163. rotation: v,
  9164. p0: u,
  9165. p1: c
  9166. }), l += f;
  9167. }
  9168. }
  9169. getSelfRect() {
  9170. if (!this.glyphInfo.length)
  9171. return {
  9172. x: 0,
  9173. y: 0,
  9174. width: 0,
  9175. height: 0
  9176. };
  9177. var t = [];
  9178. this.glyphInfo.forEach(function(A) {
  9179. t.push(A.p0.x), t.push(A.p0.y), t.push(A.p1.x), t.push(A.p1.y);
  9180. });
  9181. for (var e = t[0] || 0, i = t[0] || 0, n = t[1] || 0, r = t[1] || 0, a, o, h = 0; h < t.length / 2; h++)
  9182. a = t[h * 2], o = t[h * 2 + 1], e = Math.min(e, a), i = Math.max(i, a), n = Math.min(n, o), r = Math.max(r, o);
  9183. var l = this.fontSize();
  9184. return {
  9185. x: e - l / 2,
  9186. y: n - l / 2,
  9187. width: i - e + l,
  9188. height: r - n + l
  9189. };
  9190. }
  9191. destroy() {
  9192. return Us.Util.releaseCanvas(this.dummyCanvas), super.destroy();
  9193. }
  9194. }
  9195. Zn.TextPath = gt;
  9196. gt.prototype._fillFunc = qo;
  9197. gt.prototype._strokeFunc = Qo;
  9198. gt.prototype._fillFuncHit = qo;
  9199. gt.prototype._strokeFuncHit = Qo;
  9200. gt.prototype.className = "TextPath";
  9201. gt.prototype._attrsAffectingSize = ["text", "fontSize", "data"];
  9202. (0, H0._registerNode)(gt);
  9203. Lt.Factory.addGetterSetter(gt, "data");
  9204. Lt.Factory.addGetterSetter(gt, "fontFamily", "Arial");
  9205. Lt.Factory.addGetterSetter(gt, "fontSize", 12, (0, Xo.getNumberValidator)());
  9206. Lt.Factory.addGetterSetter(gt, "fontStyle", jo);
  9207. Lt.Factory.addGetterSetter(gt, "align", "left");
  9208. Lt.Factory.addGetterSetter(gt, "letterSpacing", 0, (0, Xo.getNumberValidator)());
  9209. Lt.Factory.addGetterSetter(gt, "textBaseline", "middle");
  9210. Lt.Factory.addGetterSetter(gt, "fontVariant", jo);
  9211. Lt.Factory.addGetterSetter(gt, "text", V0);
  9212. Lt.Factory.addGetterSetter(gt, "textDecoration", null);
  9213. Lt.Factory.addGetterSetter(gt, "kerningFunc", null);
  9214. var Jn = {};
  9215. Object.defineProperty(Jn, "__esModule", { value: !0 });
  9216. Jn.Transformer = void 0;
  9217. const Z = st, Q = V, Ea = rt, $0 = ft, W0 = Bi, Fa = li, Dt = $, ve = O, Y0 = $;
  9218. var Ko = "tr-konva", X0 = [
  9219. "resizeEnabledChange",
  9220. "rotateAnchorOffsetChange",
  9221. "rotateEnabledChange",
  9222. "enabledAnchorsChange",
  9223. "anchorSizeChange",
  9224. "borderEnabledChange",
  9225. "borderStrokeChange",
  9226. "borderStrokeWidthChange",
  9227. "borderDashChange",
  9228. "anchorStrokeChange",
  9229. "anchorStrokeWidthChange",
  9230. "anchorFillChange",
  9231. "anchorCornerRadiusChange",
  9232. "ignoreStrokeChange",
  9233. "anchorStyleFuncChange"
  9234. ].map((s) => s + `.${Ko}`).join(" "), ka = "nodesRect", j0 = [
  9235. "widthChange",
  9236. "heightChange",
  9237. "scaleXChange",
  9238. "scaleYChange",
  9239. "skewXChange",
  9240. "skewYChange",
  9241. "rotationChange",
  9242. "offsetXChange",
  9243. "offsetYChange",
  9244. "transformsEnabledChange",
  9245. "strokeWidthChange"
  9246. ], q0 = {
  9247. "top-left": -45,
  9248. "top-center": 0,
  9249. "top-right": 45,
  9250. "middle-right": -90,
  9251. "middle-left": 90,
  9252. "bottom-left": -135,
  9253. "bottom-center": 180,
  9254. "bottom-right": 135
  9255. };
  9256. const Q0 = "ontouchstart" in Dt.Konva._global;
  9257. function K0(s, t, e) {
  9258. if (s === "rotater")
  9259. return e;
  9260. t += Z.Util.degToRad(q0[s] || 0);
  9261. var i = (Z.Util.radToDeg(t) % 360 + 360) % 360;
  9262. return Z.Util._inRange(i, 315 + 22.5, 360) || Z.Util._inRange(i, 0, 22.5) ? "ns-resize" : Z.Util._inRange(i, 45 - 22.5, 45 + 22.5) ? "nesw-resize" : Z.Util._inRange(i, 90 - 22.5, 90 + 22.5) ? "ew-resize" : Z.Util._inRange(i, 135 - 22.5, 135 + 22.5) ? "nwse-resize" : Z.Util._inRange(i, 180 - 22.5, 180 + 22.5) ? "ns-resize" : Z.Util._inRange(i, 225 - 22.5, 225 + 22.5) ? "nesw-resize" : Z.Util._inRange(i, 270 - 22.5, 270 + 22.5) ? "ew-resize" : Z.Util._inRange(i, 315 - 22.5, 315 + 22.5) ? "nwse-resize" : (Z.Util.error("Transformer has unknown angle for cursor detection: " + i), "pointer");
  9263. }
  9264. var un = [
  9265. "top-left",
  9266. "top-center",
  9267. "top-right",
  9268. "middle-right",
  9269. "middle-left",
  9270. "bottom-left",
  9271. "bottom-center",
  9272. "bottom-right"
  9273. ], Da = 1e8;
  9274. function Z0(s) {
  9275. return {
  9276. x: s.x + s.width / 2 * Math.cos(s.rotation) + s.height / 2 * Math.sin(-s.rotation),
  9277. y: s.y + s.height / 2 * Math.cos(s.rotation) + s.width / 2 * Math.sin(s.rotation)
  9278. };
  9279. }
  9280. function Zo(s, t, e) {
  9281. const i = e.x + (s.x - e.x) * Math.cos(t) - (s.y - e.y) * Math.sin(t), n = e.y + (s.x - e.x) * Math.sin(t) + (s.y - e.y) * Math.cos(t);
  9282. return {
  9283. ...s,
  9284. rotation: s.rotation + t,
  9285. x: i,
  9286. y: n
  9287. };
  9288. }
  9289. function J0(s, t) {
  9290. const e = Z0(s);
  9291. return Zo(s, t, e);
  9292. }
  9293. function tc(s, t, e) {
  9294. let i = t;
  9295. for (let n = 0; n < s.length; n++) {
  9296. const r = Dt.Konva.getAngle(s[n]), a = Math.abs(r - t) % (Math.PI * 2);
  9297. Math.min(a, Math.PI * 2 - a) < e && (i = r);
  9298. }
  9299. return i;
  9300. }
  9301. let rr = 0;
  9302. class Y extends Fa.Group {
  9303. constructor(t) {
  9304. super(t), this._movingAnchorName = null, this._transforming = !1, this._createElements(), this._handleMouseMove = this._handleMouseMove.bind(this), this._handleMouseUp = this._handleMouseUp.bind(this), this.update = this.update.bind(this), this.on(X0, this.update), this.getNode() && this.update();
  9305. }
  9306. attachTo(t) {
  9307. return this.setNode(t), this;
  9308. }
  9309. setNode(t) {
  9310. return Z.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."), this.setNodes([t]);
  9311. }
  9312. getNode() {
  9313. return this._nodes && this._nodes[0];
  9314. }
  9315. _getEventNamespace() {
  9316. return Ko + this._id;
  9317. }
  9318. setNodes(t = []) {
  9319. this._nodes && this._nodes.length && this.detach();
  9320. const e = t.filter((n) => n.isAncestorOf(this) ? (Z.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"), !1) : !0);
  9321. this._nodes = t = e, t.length === 1 && this.useSingleNodeRotation() ? this.rotation(t[0].getAbsoluteRotation()) : this.rotation(0), this._nodes.forEach((n) => {
  9322. const r = () => {
  9323. this.nodes().length === 1 && this.useSingleNodeRotation() && this.rotation(this.nodes()[0].getAbsoluteRotation()), this._resetTransformCache(), !this._transforming && !this.isDragging() && this.update();
  9324. }, a = n._attrsAffectingSize.map((o) => o + "Change." + this._getEventNamespace()).join(" ");
  9325. n.on(a, r), n.on(j0.map((o) => o + `.${this._getEventNamespace()}`).join(" "), r), n.on(`absoluteTransformChange.${this._getEventNamespace()}`, r), this._proxyDrag(n);
  9326. }), this._resetTransformCache();
  9327. var i = !!this.findOne(".top-left");
  9328. return i && this.update(), this;
  9329. }
  9330. _proxyDrag(t) {
  9331. let e;
  9332. t.on(`dragstart.${this._getEventNamespace()}`, (i) => {
  9333. e = t.getAbsolutePosition(), !this.isDragging() && t !== this.findOne(".back") && this.startDrag(i, !1);
  9334. }), t.on(`dragmove.${this._getEventNamespace()}`, (i) => {
  9335. if (!e)
  9336. return;
  9337. const n = t.getAbsolutePosition(), r = n.x - e.x, a = n.y - e.y;
  9338. this.nodes().forEach((o) => {
  9339. if (o === t || o.isDragging())
  9340. return;
  9341. const h = o.getAbsolutePosition();
  9342. o.setAbsolutePosition({
  9343. x: h.x + r,
  9344. y: h.y + a
  9345. }), o.startDrag(i);
  9346. }), e = null;
  9347. });
  9348. }
  9349. getNodes() {
  9350. return this._nodes || [];
  9351. }
  9352. getActiveAnchor() {
  9353. return this._movingAnchorName;
  9354. }
  9355. detach() {
  9356. this._nodes && this._nodes.forEach((t) => {
  9357. t.off("." + this._getEventNamespace());
  9358. }), this._nodes = [], this._resetTransformCache();
  9359. }
  9360. _resetTransformCache() {
  9361. this._clearCache(ka), this._clearCache("transform"), this._clearSelfAndDescendantCache("absoluteTransform");
  9362. }
  9363. _getNodeRect() {
  9364. return this._getCache(ka, this.__getNodeRect);
  9365. }
  9366. __getNodeShape(t, e = this.rotation(), i) {
  9367. var n = t.getClientRect({
  9368. skipTransform: !0,
  9369. skipShadow: !0,
  9370. skipStroke: this.ignoreStroke()
  9371. }), r = t.getAbsoluteScale(i), a = t.getAbsolutePosition(i), o = n.x * r.x - t.offsetX() * r.x, h = n.y * r.y - t.offsetY() * r.y;
  9372. const l = (Dt.Konva.getAngle(t.getAbsoluteRotation()) + Math.PI * 2) % (Math.PI * 2), A = {
  9373. x: a.x + o * Math.cos(l) + h * Math.sin(-l),
  9374. y: a.y + h * Math.cos(l) + o * Math.sin(l),
  9375. width: n.width * r.x,
  9376. height: n.height * r.y,
  9377. rotation: l
  9378. };
  9379. return Zo(A, -Dt.Konva.getAngle(e), {
  9380. x: 0,
  9381. y: 0
  9382. });
  9383. }
  9384. __getNodeRect() {
  9385. var t = this.getNode();
  9386. if (!t)
  9387. return {
  9388. x: -Da,
  9389. y: -Da,
  9390. width: 0,
  9391. height: 0,
  9392. rotation: 0
  9393. };
  9394. const e = [];
  9395. this.nodes().map((l) => {
  9396. const A = l.getClientRect({
  9397. skipTransform: !0,
  9398. skipShadow: !0,
  9399. skipStroke: this.ignoreStroke()
  9400. });
  9401. var u = [
  9402. { x: A.x, y: A.y },
  9403. { x: A.x + A.width, y: A.y },
  9404. { x: A.x + A.width, y: A.y + A.height },
  9405. { x: A.x, y: A.y + A.height }
  9406. ], f = l.getAbsoluteTransform();
  9407. u.forEach(function(c) {
  9408. var d = f.point(c);
  9409. e.push(d);
  9410. });
  9411. });
  9412. const i = new Z.Transform();
  9413. i.rotate(-Dt.Konva.getAngle(this.rotation()));
  9414. var n = 1 / 0, r = 1 / 0, a = -1 / 0, o = -1 / 0;
  9415. e.forEach(function(l) {
  9416. var A = i.point(l);
  9417. n === void 0 && (n = a = A.x, r = o = A.y), n = Math.min(n, A.x), r = Math.min(r, A.y), a = Math.max(a, A.x), o = Math.max(o, A.y);
  9418. }), i.invert();
  9419. const h = i.point({ x: n, y: r });
  9420. return {
  9421. x: h.x,
  9422. y: h.y,
  9423. width: a - n,
  9424. height: o - r,
  9425. rotation: Dt.Konva.getAngle(this.rotation())
  9426. };
  9427. }
  9428. getX() {
  9429. return this._getNodeRect().x;
  9430. }
  9431. getY() {
  9432. return this._getNodeRect().y;
  9433. }
  9434. getWidth() {
  9435. return this._getNodeRect().width;
  9436. }
  9437. getHeight() {
  9438. return this._getNodeRect().height;
  9439. }
  9440. _createElements() {
  9441. this._createBack(), un.forEach((t) => {
  9442. this._createAnchor(t);
  9443. }), this._createAnchor("rotater");
  9444. }
  9445. _createAnchor(t) {
  9446. var e = new W0.Rect({
  9447. stroke: "rgb(0, 161, 255)",
  9448. fill: "white",
  9449. strokeWidth: 1,
  9450. name: t + " _anchor",
  9451. dragDistance: 0,
  9452. draggable: !0,
  9453. hitStrokeWidth: Q0 ? 10 : "auto"
  9454. }), i = this;
  9455. e.on("mousedown touchstart", function(n) {
  9456. i._handleMouseDown(n);
  9457. }), e.on("dragstart", (n) => {
  9458. e.stopDrag(), n.cancelBubble = !0;
  9459. }), e.on("dragend", (n) => {
  9460. n.cancelBubble = !0;
  9461. }), e.on("mouseenter", () => {
  9462. var n = Dt.Konva.getAngle(this.rotation()), r = this.rotateAnchorCursor(), a = K0(t, n, r);
  9463. e.getStage().content && (e.getStage().content.style.cursor = a), this._cursorChange = !0;
  9464. }), e.on("mouseout", () => {
  9465. e.getStage().content && (e.getStage().content.style.cursor = ""), this._cursorChange = !1;
  9466. }), this.add(e);
  9467. }
  9468. _createBack() {
  9469. var t = new $0.Shape({
  9470. name: "back",
  9471. width: 0,
  9472. height: 0,
  9473. draggable: !0,
  9474. sceneFunc(e, i) {
  9475. var n = i.getParent(), r = n.padding();
  9476. e.beginPath(), e.rect(-r, -r, i.width() + r * 2, i.height() + r * 2), e.moveTo(i.width() / 2, -r), n.rotateEnabled() && n.rotateLineVisible() && e.lineTo(i.width() / 2, -n.rotateAnchorOffset() * Z.Util._sign(i.height()) - r), e.fillStrokeShape(i);
  9477. },
  9478. hitFunc: (e, i) => {
  9479. if (this.shouldOverdrawWholeArea()) {
  9480. var n = this.padding();
  9481. e.beginPath(), e.rect(-n, -n, i.width() + n * 2, i.height() + n * 2), e.fillStrokeShape(i);
  9482. }
  9483. }
  9484. });
  9485. this.add(t), this._proxyDrag(t), t.on("dragstart", (e) => {
  9486. e.cancelBubble = !0;
  9487. }), t.on("dragmove", (e) => {
  9488. e.cancelBubble = !0;
  9489. }), t.on("dragend", (e) => {
  9490. e.cancelBubble = !0;
  9491. }), this.on("dragmove", (e) => {
  9492. this.update();
  9493. });
  9494. }
  9495. _handleMouseDown(t) {
  9496. this._movingAnchorName = t.target.name().split(" ")[0];
  9497. var e = this._getNodeRect(), i = e.width, n = e.height, r = Math.sqrt(Math.pow(i, 2) + Math.pow(n, 2));
  9498. this.sin = Math.abs(n / r), this.cos = Math.abs(i / r), typeof window < "u" && (window.addEventListener("mousemove", this._handleMouseMove), window.addEventListener("touchmove", this._handleMouseMove), window.addEventListener("mouseup", this._handleMouseUp, !0), window.addEventListener("touchend", this._handleMouseUp, !0)), this._transforming = !0;
  9499. var a = t.target.getAbsolutePosition(), o = t.target.getStage().getPointerPosition();
  9500. this._anchorDragOffset = {
  9501. x: o.x - a.x,
  9502. y: o.y - a.y
  9503. }, rr++, this._fire("transformstart", { evt: t.evt, target: this.getNode() }), this._nodes.forEach((h) => {
  9504. h._fire("transformstart", { evt: t.evt, target: h });
  9505. });
  9506. }
  9507. _handleMouseMove(t) {
  9508. var e, i, n, r = this.findOne("." + this._movingAnchorName), a = r.getStage();
  9509. a.setPointersPositions(t);
  9510. const o = a.getPointerPosition();
  9511. let h = {
  9512. x: o.x - this._anchorDragOffset.x,
  9513. y: o.y - this._anchorDragOffset.y
  9514. };
  9515. const l = r.getAbsolutePosition();
  9516. this.anchorDragBoundFunc() && (h = this.anchorDragBoundFunc()(l, h, t)), r.setAbsolutePosition(h);
  9517. const A = r.getAbsolutePosition();
  9518. if (!(l.x === A.x && l.y === A.y)) {
  9519. if (this._movingAnchorName === "rotater") {
  9520. var u = this._getNodeRect();
  9521. e = r.x() - u.width / 2, i = -r.y() + u.height / 2;
  9522. let F = Math.atan2(-i, e) + Math.PI / 2;
  9523. u.height < 0 && (F -= Math.PI);
  9524. var f = Dt.Konva.getAngle(this.rotation());
  9525. const L = f + F, I = Dt.Konva.getAngle(this.rotationSnapTolerance()), T = tc(this.rotationSnaps(), L, I) - u.rotation, G = J0(u, T);
  9526. this._fitNodesInto(G, t);
  9527. return;
  9528. }
  9529. var c = this.shiftBehavior(), d;
  9530. c === "inverted" ? d = this.keepRatio() && !t.shiftKey : c === "none" ? d = this.keepRatio() : d = this.keepRatio() || t.shiftKey;
  9531. var g = this.centeredScaling() || t.altKey;
  9532. if (this._movingAnchorName === "top-left") {
  9533. if (d) {
  9534. var p = g ? {
  9535. x: this.width() / 2,
  9536. y: this.height() / 2
  9537. } : {
  9538. x: this.findOne(".bottom-right").x(),
  9539. y: this.findOne(".bottom-right").y()
  9540. };
  9541. n = Math.sqrt(Math.pow(p.x - r.x(), 2) + Math.pow(p.y - r.y(), 2));
  9542. var m = this.findOne(".top-left").x() > p.x ? -1 : 1, v = this.findOne(".top-left").y() > p.y ? -1 : 1;
  9543. e = n * this.cos * m, i = n * this.sin * v, this.findOne(".top-left").x(p.x - e), this.findOne(".top-left").y(p.y - i);
  9544. }
  9545. } else if (this._movingAnchorName === "top-center")
  9546. this.findOne(".top-left").y(r.y());
  9547. else if (this._movingAnchorName === "top-right") {
  9548. if (d) {
  9549. var p = g ? {
  9550. x: this.width() / 2,
  9551. y: this.height() / 2
  9552. } : {
  9553. x: this.findOne(".bottom-left").x(),
  9554. y: this.findOne(".bottom-left").y()
  9555. };
  9556. n = Math.sqrt(Math.pow(r.x() - p.x, 2) + Math.pow(p.y - r.y(), 2));
  9557. var m = this.findOne(".top-right").x() < p.x ? -1 : 1, v = this.findOne(".top-right").y() > p.y ? -1 : 1;
  9558. e = n * this.cos * m, i = n * this.sin * v, this.findOne(".top-right").x(p.x + e), this.findOne(".top-right").y(p.y - i);
  9559. }
  9560. var _ = r.position();
  9561. this.findOne(".top-left").y(_.y), this.findOne(".bottom-right").x(_.x);
  9562. } else if (this._movingAnchorName === "middle-left")
  9563. this.findOne(".top-left").x(r.x());
  9564. else if (this._movingAnchorName === "middle-right")
  9565. this.findOne(".bottom-right").x(r.x());
  9566. else if (this._movingAnchorName === "bottom-left") {
  9567. if (d) {
  9568. var p = g ? {
  9569. x: this.width() / 2,
  9570. y: this.height() / 2
  9571. } : {
  9572. x: this.findOne(".top-right").x(),
  9573. y: this.findOne(".top-right").y()
  9574. };
  9575. n = Math.sqrt(Math.pow(p.x - r.x(), 2) + Math.pow(r.y() - p.y, 2));
  9576. var m = p.x < r.x() ? -1 : 1, v = r.y() < p.y ? -1 : 1;
  9577. e = n * this.cos * m, i = n * this.sin * v, r.x(p.x - e), r.y(p.y + i);
  9578. }
  9579. _ = r.position(), this.findOne(".top-left").x(_.x), this.findOne(".bottom-right").y(_.y);
  9580. } else if (this._movingAnchorName === "bottom-center")
  9581. this.findOne(".bottom-right").y(r.y());
  9582. else if (this._movingAnchorName === "bottom-right") {
  9583. if (d) {
  9584. var p = g ? {
  9585. x: this.width() / 2,
  9586. y: this.height() / 2
  9587. } : {
  9588. x: this.findOne(".top-left").x(),
  9589. y: this.findOne(".top-left").y()
  9590. };
  9591. n = Math.sqrt(Math.pow(r.x() - p.x, 2) + Math.pow(r.y() - p.y, 2));
  9592. var m = this.findOne(".bottom-right").x() < p.x ? -1 : 1, v = this.findOne(".bottom-right").y() < p.y ? -1 : 1;
  9593. e = n * this.cos * m, i = n * this.sin * v, this.findOne(".bottom-right").x(p.x + e), this.findOne(".bottom-right").y(p.y + i);
  9594. }
  9595. } else
  9596. console.error(new Error("Wrong position argument of selection resizer: " + this._movingAnchorName));
  9597. var g = this.centeredScaling() || t.altKey;
  9598. if (g) {
  9599. var y = this.findOne(".top-left"), x = this.findOne(".bottom-right"), b = y.x(), C = y.y(), w = this.getWidth() - x.x(), E = this.getHeight() - x.y();
  9600. x.move({
  9601. x: -b,
  9602. y: -C
  9603. }), y.move({
  9604. x: w,
  9605. y: E
  9606. });
  9607. }
  9608. var S = this.findOne(".top-left").getAbsolutePosition();
  9609. e = S.x, i = S.y;
  9610. var P = this.findOne(".bottom-right").x() - this.findOne(".top-left").x(), k = this.findOne(".bottom-right").y() - this.findOne(".top-left").y();
  9611. this._fitNodesInto({
  9612. x: e,
  9613. y: i,
  9614. width: P,
  9615. height: k,
  9616. rotation: Dt.Konva.getAngle(this.rotation())
  9617. }, t);
  9618. }
  9619. }
  9620. _handleMouseUp(t) {
  9621. this._removeEvents(t);
  9622. }
  9623. getAbsoluteTransform() {
  9624. return this.getTransform();
  9625. }
  9626. _removeEvents(t) {
  9627. var e;
  9628. if (this._transforming) {
  9629. this._transforming = !1, typeof window < "u" && (window.removeEventListener("mousemove", this._handleMouseMove), window.removeEventListener("touchmove", this._handleMouseMove), window.removeEventListener("mouseup", this._handleMouseUp, !0), window.removeEventListener("touchend", this._handleMouseUp, !0));
  9630. var i = this.getNode();
  9631. rr--, this._fire("transformend", { evt: t, target: i }), (e = this.getLayer()) === null || e === void 0 || e.batchDraw(), i && this._nodes.forEach((n) => {
  9632. var r;
  9633. n._fire("transformend", { evt: t, target: n }), (r = n.getLayer()) === null || r === void 0 || r.batchDraw();
  9634. }), this._movingAnchorName = null;
  9635. }
  9636. }
  9637. _fitNodesInto(t, e) {
  9638. var i = this._getNodeRect();
  9639. const n = 1;
  9640. if (Z.Util._inRange(t.width, -this.padding() * 2 - n, n)) {
  9641. this.update();
  9642. return;
  9643. }
  9644. if (Z.Util._inRange(t.height, -this.padding() * 2 - n, n)) {
  9645. this.update();
  9646. return;
  9647. }
  9648. var r = new Z.Transform();
  9649. if (r.rotate(Dt.Konva.getAngle(this.rotation())), this._movingAnchorName && t.width < 0 && this._movingAnchorName.indexOf("left") >= 0) {
  9650. const f = r.point({
  9651. x: -this.padding() * 2,
  9652. y: 0
  9653. });
  9654. t.x += f.x, t.y += f.y, t.width += this.padding() * 2, this._movingAnchorName = this._movingAnchorName.replace("left", "right"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y;
  9655. } else if (this._movingAnchorName && t.width < 0 && this._movingAnchorName.indexOf("right") >= 0) {
  9656. const f = r.point({
  9657. x: this.padding() * 2,
  9658. y: 0
  9659. });
  9660. this._movingAnchorName = this._movingAnchorName.replace("right", "left"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, t.width += this.padding() * 2;
  9661. }
  9662. if (this._movingAnchorName && t.height < 0 && this._movingAnchorName.indexOf("top") >= 0) {
  9663. const f = r.point({
  9664. x: 0,
  9665. y: -this.padding() * 2
  9666. });
  9667. t.x += f.x, t.y += f.y, this._movingAnchorName = this._movingAnchorName.replace("top", "bottom"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, t.height += this.padding() * 2;
  9668. } else if (this._movingAnchorName && t.height < 0 && this._movingAnchorName.indexOf("bottom") >= 0) {
  9669. const f = r.point({
  9670. x: 0,
  9671. y: this.padding() * 2
  9672. });
  9673. this._movingAnchorName = this._movingAnchorName.replace("bottom", "top"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, t.height += this.padding() * 2;
  9674. }
  9675. if (this.boundBoxFunc()) {
  9676. const f = this.boundBoxFunc()(i, t);
  9677. f ? t = f : Z.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!");
  9678. }
  9679. const a = 1e7, o = new Z.Transform();
  9680. o.translate(i.x, i.y), o.rotate(i.rotation), o.scale(i.width / a, i.height / a);
  9681. const h = new Z.Transform(), l = t.width / a, A = t.height / a;
  9682. this.flipEnabled() === !1 ? (h.translate(t.x, t.y), h.rotate(t.rotation), h.translate(t.width < 0 ? t.width : 0, t.height < 0 ? t.height : 0), h.scale(Math.abs(l), Math.abs(A))) : (h.translate(t.x, t.y), h.rotate(t.rotation), h.scale(l, A));
  9683. const u = h.multiply(o.invert());
  9684. this._nodes.forEach((f) => {
  9685. var c;
  9686. const d = f.getParent().getAbsoluteTransform(), p = f.getTransform().copy();
  9687. p.translate(f.offsetX(), f.offsetY());
  9688. const m = new Z.Transform();
  9689. m.multiply(d.copy().invert()).multiply(u).multiply(d).multiply(p);
  9690. const v = m.decompose();
  9691. f.setAttrs(v), (c = f.getLayer()) === null || c === void 0 || c.batchDraw();
  9692. }), this.rotation(Z.Util._getRotation(t.rotation)), this._nodes.forEach((f) => {
  9693. this._fire("transform", { evt: e, target: f }), f._fire("transform", { evt: e, target: f });
  9694. }), this._resetTransformCache(), this.update(), this.getLayer().batchDraw();
  9695. }
  9696. forceUpdate() {
  9697. this._resetTransformCache(), this.update();
  9698. }
  9699. _batchChangeChild(t, e) {
  9700. this.findOne(t).setAttrs(e);
  9701. }
  9702. update() {
  9703. var t, e = this._getNodeRect();
  9704. this.rotation(Z.Util._getRotation(e.rotation));
  9705. var i = e.width, n = e.height, r = this.enabledAnchors(), a = this.resizeEnabled(), o = this.padding(), h = this.anchorSize();
  9706. const l = this.find("._anchor");
  9707. l.forEach((u) => {
  9708. u.setAttrs({
  9709. width: h,
  9710. height: h,
  9711. offsetX: h / 2,
  9712. offsetY: h / 2,
  9713. stroke: this.anchorStroke(),
  9714. strokeWidth: this.anchorStrokeWidth(),
  9715. fill: this.anchorFill(),
  9716. cornerRadius: this.anchorCornerRadius()
  9717. });
  9718. }), this._batchChangeChild(".top-left", {
  9719. x: 0,
  9720. y: 0,
  9721. offsetX: h / 2 + o,
  9722. offsetY: h / 2 + o,
  9723. visible: a && r.indexOf("top-left") >= 0
  9724. }), this._batchChangeChild(".top-center", {
  9725. x: i / 2,
  9726. y: 0,
  9727. offsetY: h / 2 + o,
  9728. visible: a && r.indexOf("top-center") >= 0
  9729. }), this._batchChangeChild(".top-right", {
  9730. x: i,
  9731. y: 0,
  9732. offsetX: h / 2 - o,
  9733. offsetY: h / 2 + o,
  9734. visible: a && r.indexOf("top-right") >= 0
  9735. }), this._batchChangeChild(".middle-left", {
  9736. x: 0,
  9737. y: n / 2,
  9738. offsetX: h / 2 + o,
  9739. visible: a && r.indexOf("middle-left") >= 0
  9740. }), this._batchChangeChild(".middle-right", {
  9741. x: i,
  9742. y: n / 2,
  9743. offsetX: h / 2 - o,
  9744. visible: a && r.indexOf("middle-right") >= 0
  9745. }), this._batchChangeChild(".bottom-left", {
  9746. x: 0,
  9747. y: n,
  9748. offsetX: h / 2 + o,
  9749. offsetY: h / 2 - o,
  9750. visible: a && r.indexOf("bottom-left") >= 0
  9751. }), this._batchChangeChild(".bottom-center", {
  9752. x: i / 2,
  9753. y: n,
  9754. offsetY: h / 2 - o,
  9755. visible: a && r.indexOf("bottom-center") >= 0
  9756. }), this._batchChangeChild(".bottom-right", {
  9757. x: i,
  9758. y: n,
  9759. offsetX: h / 2 - o,
  9760. offsetY: h / 2 - o,
  9761. visible: a && r.indexOf("bottom-right") >= 0
  9762. }), this._batchChangeChild(".rotater", {
  9763. x: i / 2,
  9764. y: -this.rotateAnchorOffset() * Z.Util._sign(n) - o,
  9765. visible: this.rotateEnabled()
  9766. }), this._batchChangeChild(".back", {
  9767. width: i,
  9768. height: n,
  9769. visible: this.borderEnabled(),
  9770. stroke: this.borderStroke(),
  9771. strokeWidth: this.borderStrokeWidth(),
  9772. dash: this.borderDash(),
  9773. x: 0,
  9774. y: 0
  9775. });
  9776. const A = this.anchorStyleFunc();
  9777. A && l.forEach((u) => {
  9778. A(u);
  9779. }), (t = this.getLayer()) === null || t === void 0 || t.batchDraw();
  9780. }
  9781. isTransforming() {
  9782. return this._transforming;
  9783. }
  9784. stopTransform() {
  9785. if (this._transforming) {
  9786. this._removeEvents();
  9787. var t = this.findOne("." + this._movingAnchorName);
  9788. t && t.stopDrag();
  9789. }
  9790. }
  9791. destroy() {
  9792. return this.getStage() && this._cursorChange && this.getStage().content && (this.getStage().content.style.cursor = ""), Fa.Group.prototype.destroy.call(this), this.detach(), this._removeEvents(), this;
  9793. }
  9794. toObject() {
  9795. return Ea.Node.prototype.toObject.call(this);
  9796. }
  9797. clone(t) {
  9798. var e = Ea.Node.prototype.clone.call(this, t);
  9799. return e;
  9800. }
  9801. getClientRect() {
  9802. return this.nodes().length > 0 ? super.getClientRect() : { x: 0, y: 0, width: 0, height: 0 };
  9803. }
  9804. }
  9805. Jn.Transformer = Y;
  9806. Y.isTransforming = () => rr > 0;
  9807. function ec(s) {
  9808. return s instanceof Array || Z.Util.warn("enabledAnchors value should be an array"), s instanceof Array && s.forEach(function(t) {
  9809. un.indexOf(t) === -1 && Z.Util.warn("Unknown anchor name: " + t + ". Available names are: " + un.join(", "));
  9810. }), s || [];
  9811. }
  9812. Y.prototype.className = "Transformer";
  9813. (0, Y0._registerNode)(Y);
  9814. Q.Factory.addGetterSetter(Y, "enabledAnchors", un, ec);
  9815. Q.Factory.addGetterSetter(Y, "flipEnabled", !0, (0, ve.getBooleanValidator)());
  9816. Q.Factory.addGetterSetter(Y, "resizeEnabled", !0);
  9817. Q.Factory.addGetterSetter(Y, "anchorSize", 10, (0, ve.getNumberValidator)());
  9818. Q.Factory.addGetterSetter(Y, "rotateEnabled", !0);
  9819. Q.Factory.addGetterSetter(Y, "rotateLineVisible", !0);
  9820. Q.Factory.addGetterSetter(Y, "rotationSnaps", []);
  9821. Q.Factory.addGetterSetter(Y, "rotateAnchorOffset", 50, (0, ve.getNumberValidator)());
  9822. Q.Factory.addGetterSetter(Y, "rotateAnchorCursor", "crosshair");
  9823. Q.Factory.addGetterSetter(Y, "rotationSnapTolerance", 5, (0, ve.getNumberValidator)());
  9824. Q.Factory.addGetterSetter(Y, "borderEnabled", !0);
  9825. Q.Factory.addGetterSetter(Y, "anchorStroke", "rgb(0, 161, 255)");
  9826. Q.Factory.addGetterSetter(Y, "anchorStrokeWidth", 1, (0, ve.getNumberValidator)());
  9827. Q.Factory.addGetterSetter(Y, "anchorFill", "white");
  9828. Q.Factory.addGetterSetter(Y, "anchorCornerRadius", 0, (0, ve.getNumberValidator)());
  9829. Q.Factory.addGetterSetter(Y, "borderStroke", "rgb(0, 161, 255)");
  9830. Q.Factory.addGetterSetter(Y, "borderStrokeWidth", 1, (0, ve.getNumberValidator)());
  9831. Q.Factory.addGetterSetter(Y, "borderDash");
  9832. Q.Factory.addGetterSetter(Y, "keepRatio", !0);
  9833. Q.Factory.addGetterSetter(Y, "shiftBehavior", "default");
  9834. Q.Factory.addGetterSetter(Y, "centeredScaling", !1);
  9835. Q.Factory.addGetterSetter(Y, "ignoreStroke", !1);
  9836. Q.Factory.addGetterSetter(Y, "padding", 0, (0, ve.getNumberValidator)());
  9837. Q.Factory.addGetterSetter(Y, "node");
  9838. Q.Factory.addGetterSetter(Y, "nodes");
  9839. Q.Factory.addGetterSetter(Y, "boundBoxFunc");
  9840. Q.Factory.addGetterSetter(Y, "anchorDragBoundFunc");
  9841. Q.Factory.addGetterSetter(Y, "anchorStyleFunc");
  9842. Q.Factory.addGetterSetter(Y, "shouldOverdrawWholeArea", !1);
  9843. Q.Factory.addGetterSetter(Y, "useSingleNodeRotation", !0);
  9844. Q.Factory.backCompat(Y, {
  9845. lineEnabled: "borderEnabled",
  9846. rotateHandlerOffset: "rotateAnchorOffset",
  9847. enabledHandlers: "enabledAnchors"
  9848. });
  9849. var ts = {};
  9850. Object.defineProperty(ts, "__esModule", { value: !0 });
  9851. ts.Wedge = void 0;
  9852. const es = V, ic = ft, nc = $, Jo = O, sc = $;
  9853. class ee extends ic.Shape {
  9854. _sceneFunc(t) {
  9855. t.beginPath(), t.arc(0, 0, this.radius(), 0, nc.Konva.getAngle(this.angle()), this.clockwise()), t.lineTo(0, 0), t.closePath(), t.fillStrokeShape(this);
  9856. }
  9857. getWidth() {
  9858. return this.radius() * 2;
  9859. }
  9860. getHeight() {
  9861. return this.radius() * 2;
  9862. }
  9863. setWidth(t) {
  9864. this.radius(t / 2);
  9865. }
  9866. setHeight(t) {
  9867. this.radius(t / 2);
  9868. }
  9869. }
  9870. ts.Wedge = ee;
  9871. ee.prototype.className = "Wedge";
  9872. ee.prototype._centroid = !0;
  9873. ee.prototype._attrsAffectingSize = ["radius"];
  9874. (0, sc._registerNode)(ee);
  9875. es.Factory.addGetterSetter(ee, "radius", 0, (0, Jo.getNumberValidator)());
  9876. es.Factory.addGetterSetter(ee, "angle", 0, (0, Jo.getNumberValidator)());
  9877. es.Factory.addGetterSetter(ee, "clockwise", !1);
  9878. es.Factory.backCompat(ee, {
  9879. angleDeg: "angle",
  9880. getAngleDeg: "getAngle",
  9881. setAngleDeg: "setAngle"
  9882. });
  9883. var is = {};
  9884. Object.defineProperty(is, "__esModule", { value: !0 });
  9885. is.Blur = void 0;
  9886. const Ia = V, rc = rt, ac = O;
  9887. function Ta() {
  9888. this.r = 0, this.g = 0, this.b = 0, this.a = 0, this.next = null;
  9889. }
  9890. var oc = [
  9891. 512,
  9892. 512,
  9893. 456,
  9894. 512,
  9895. 328,
  9896. 456,
  9897. 335,
  9898. 512,
  9899. 405,
  9900. 328,
  9901. 271,
  9902. 456,
  9903. 388,
  9904. 335,
  9905. 292,
  9906. 512,
  9907. 454,
  9908. 405,
  9909. 364,
  9910. 328,
  9911. 298,
  9912. 271,
  9913. 496,
  9914. 456,
  9915. 420,
  9916. 388,
  9917. 360,
  9918. 335,
  9919. 312,
  9920. 292,
  9921. 273,
  9922. 512,
  9923. 482,
  9924. 454,
  9925. 428,
  9926. 405,
  9927. 383,
  9928. 364,
  9929. 345,
  9930. 328,
  9931. 312,
  9932. 298,
  9933. 284,
  9934. 271,
  9935. 259,
  9936. 496,
  9937. 475,
  9938. 456,
  9939. 437,
  9940. 420,
  9941. 404,
  9942. 388,
  9943. 374,
  9944. 360,
  9945. 347,
  9946. 335,
  9947. 323,
  9948. 312,
  9949. 302,
  9950. 292,
  9951. 282,
  9952. 273,
  9953. 265,
  9954. 512,
  9955. 497,
  9956. 482,
  9957. 468,
  9958. 454,
  9959. 441,
  9960. 428,
  9961. 417,
  9962. 405,
  9963. 394,
  9964. 383,
  9965. 373,
  9966. 364,
  9967. 354,
  9968. 345,
  9969. 337,
  9970. 328,
  9971. 320,
  9972. 312,
  9973. 305,
  9974. 298,
  9975. 291,
  9976. 284,
  9977. 278,
  9978. 271,
  9979. 265,
  9980. 259,
  9981. 507,
  9982. 496,
  9983. 485,
  9984. 475,
  9985. 465,
  9986. 456,
  9987. 446,
  9988. 437,
  9989. 428,
  9990. 420,
  9991. 412,
  9992. 404,
  9993. 396,
  9994. 388,
  9995. 381,
  9996. 374,
  9997. 367,
  9998. 360,
  9999. 354,
  10000. 347,
  10001. 341,
  10002. 335,
  10003. 329,
  10004. 323,
  10005. 318,
  10006. 312,
  10007. 307,
  10008. 302,
  10009. 297,
  10010. 292,
  10011. 287,
  10012. 282,
  10013. 278,
  10014. 273,
  10015. 269,
  10016. 265,
  10017. 261,
  10018. 512,
  10019. 505,
  10020. 497,
  10021. 489,
  10022. 482,
  10023. 475,
  10024. 468,
  10025. 461,
  10026. 454,
  10027. 447,
  10028. 441,
  10029. 435,
  10030. 428,
  10031. 422,
  10032. 417,
  10033. 411,
  10034. 405,
  10035. 399,
  10036. 394,
  10037. 389,
  10038. 383,
  10039. 378,
  10040. 373,
  10041. 368,
  10042. 364,
  10043. 359,
  10044. 354,
  10045. 350,
  10046. 345,
  10047. 341,
  10048. 337,
  10049. 332,
  10050. 328,
  10051. 324,
  10052. 320,
  10053. 316,
  10054. 312,
  10055. 309,
  10056. 305,
  10057. 301,
  10058. 298,
  10059. 294,
  10060. 291,
  10061. 287,
  10062. 284,
  10063. 281,
  10064. 278,
  10065. 274,
  10066. 271,
  10067. 268,
  10068. 265,
  10069. 262,
  10070. 259,
  10071. 257,
  10072. 507,
  10073. 501,
  10074. 496,
  10075. 491,
  10076. 485,
  10077. 480,
  10078. 475,
  10079. 470,
  10080. 465,
  10081. 460,
  10082. 456,
  10083. 451,
  10084. 446,
  10085. 442,
  10086. 437,
  10087. 433,
  10088. 428,
  10089. 424,
  10090. 420,
  10091. 416,
  10092. 412,
  10093. 408,
  10094. 404,
  10095. 400,
  10096. 396,
  10097. 392,
  10098. 388,
  10099. 385,
  10100. 381,
  10101. 377,
  10102. 374,
  10103. 370,
  10104. 367,
  10105. 363,
  10106. 360,
  10107. 357,
  10108. 354,
  10109. 350,
  10110. 347,
  10111. 344,
  10112. 341,
  10113. 338,
  10114. 335,
  10115. 332,
  10116. 329,
  10117. 326,
  10118. 323,
  10119. 320,
  10120. 318,
  10121. 315,
  10122. 312,
  10123. 310,
  10124. 307,
  10125. 304,
  10126. 302,
  10127. 299,
  10128. 297,
  10129. 294,
  10130. 292,
  10131. 289,
  10132. 287,
  10133. 285,
  10134. 282,
  10135. 280,
  10136. 278,
  10137. 275,
  10138. 273,
  10139. 271,
  10140. 269,
  10141. 267,
  10142. 265,
  10143. 263,
  10144. 261,
  10145. 259
  10146. ], hc = [
  10147. 9,
  10148. 11,
  10149. 12,
  10150. 13,
  10151. 13,
  10152. 14,
  10153. 14,
  10154. 15,
  10155. 15,
  10156. 15,
  10157. 15,
  10158. 16,
  10159. 16,
  10160. 16,
  10161. 16,
  10162. 17,
  10163. 17,
  10164. 17,
  10165. 17,
  10166. 17,
  10167. 17,
  10168. 17,
  10169. 18,
  10170. 18,
  10171. 18,
  10172. 18,
  10173. 18,
  10174. 18,
  10175. 18,
  10176. 18,
  10177. 18,
  10178. 19,
  10179. 19,
  10180. 19,
  10181. 19,
  10182. 19,
  10183. 19,
  10184. 19,
  10185. 19,
  10186. 19,
  10187. 19,
  10188. 19,
  10189. 19,
  10190. 19,
  10191. 19,
  10192. 20,
  10193. 20,
  10194. 20,
  10195. 20,
  10196. 20,
  10197. 20,
  10198. 20,
  10199. 20,
  10200. 20,
  10201. 20,
  10202. 20,
  10203. 20,
  10204. 20,
  10205. 20,
  10206. 20,
  10207. 20,
  10208. 20,
  10209. 20,
  10210. 21,
  10211. 21,
  10212. 21,
  10213. 21,
  10214. 21,
  10215. 21,
  10216. 21,
  10217. 21,
  10218. 21,
  10219. 21,
  10220. 21,
  10221. 21,
  10222. 21,
  10223. 21,
  10224. 21,
  10225. 21,
  10226. 21,
  10227. 21,
  10228. 21,
  10229. 21,
  10230. 21,
  10231. 21,
  10232. 21,
  10233. 21,
  10234. 21,
  10235. 21,
  10236. 21,
  10237. 22,
  10238. 22,
  10239. 22,
  10240. 22,
  10241. 22,
  10242. 22,
  10243. 22,
  10244. 22,
  10245. 22,
  10246. 22,
  10247. 22,
  10248. 22,
  10249. 22,
  10250. 22,
  10251. 22,
  10252. 22,
  10253. 22,
  10254. 22,
  10255. 22,
  10256. 22,
  10257. 22,
  10258. 22,
  10259. 22,
  10260. 22,
  10261. 22,
  10262. 22,
  10263. 22,
  10264. 22,
  10265. 22,
  10266. 22,
  10267. 22,
  10268. 22,
  10269. 22,
  10270. 22,
  10271. 22,
  10272. 22,
  10273. 22,
  10274. 23,
  10275. 23,
  10276. 23,
  10277. 23,
  10278. 23,
  10279. 23,
  10280. 23,
  10281. 23,
  10282. 23,
  10283. 23,
  10284. 23,
  10285. 23,
  10286. 23,
  10287. 23,
  10288. 23,
  10289. 23,
  10290. 23,
  10291. 23,
  10292. 23,
  10293. 23,
  10294. 23,
  10295. 23,
  10296. 23,
  10297. 23,
  10298. 23,
  10299. 23,
  10300. 23,
  10301. 23,
  10302. 23,
  10303. 23,
  10304. 23,
  10305. 23,
  10306. 23,
  10307. 23,
  10308. 23,
  10309. 23,
  10310. 23,
  10311. 23,
  10312. 23,
  10313. 23,
  10314. 23,
  10315. 23,
  10316. 23,
  10317. 23,
  10318. 23,
  10319. 23,
  10320. 23,
  10321. 23,
  10322. 23,
  10323. 23,
  10324. 23,
  10325. 23,
  10326. 23,
  10327. 23,
  10328. 24,
  10329. 24,
  10330. 24,
  10331. 24,
  10332. 24,
  10333. 24,
  10334. 24,
  10335. 24,
  10336. 24,
  10337. 24,
  10338. 24,
  10339. 24,
  10340. 24,
  10341. 24,
  10342. 24,
  10343. 24,
  10344. 24,
  10345. 24,
  10346. 24,
  10347. 24,
  10348. 24,
  10349. 24,
  10350. 24,
  10351. 24,
  10352. 24,
  10353. 24,
  10354. 24,
  10355. 24,
  10356. 24,
  10357. 24,
  10358. 24,
  10359. 24,
  10360. 24,
  10361. 24,
  10362. 24,
  10363. 24,
  10364. 24,
  10365. 24,
  10366. 24,
  10367. 24,
  10368. 24,
  10369. 24,
  10370. 24,
  10371. 24,
  10372. 24,
  10373. 24,
  10374. 24,
  10375. 24,
  10376. 24,
  10377. 24,
  10378. 24,
  10379. 24,
  10380. 24,
  10381. 24,
  10382. 24,
  10383. 24,
  10384. 24,
  10385. 24,
  10386. 24,
  10387. 24,
  10388. 24,
  10389. 24,
  10390. 24,
  10391. 24,
  10392. 24,
  10393. 24,
  10394. 24,
  10395. 24,
  10396. 24,
  10397. 24,
  10398. 24,
  10399. 24,
  10400. 24,
  10401. 24
  10402. ];
  10403. function lc(s, t) {
  10404. var e = s.data, i = s.width, n = s.height, r, a, o, h, l, A, u, f, c, d, p, m, v, _, g, y, x, b, C, w, E, S, P, k, F = t + t + 1, L = i - 1, I = n - 1, z = t + 1, T = z * (z + 1) / 2, G = new Ta(), H = null, R = G, N = null, q = null, et = oc[t], tt = hc[t];
  10405. for (o = 1; o < F; o++)
  10406. R = R.next = new Ta(), o === z && (H = R);
  10407. for (R.next = G, u = A = 0, a = 0; a < n; a++) {
  10408. for (y = x = b = C = f = c = d = p = 0, m = z * (w = e[A]), v = z * (E = e[A + 1]), _ = z * (S = e[A + 2]), g = z * (P = e[A + 3]), f += T * w, c += T * E, d += T * S, p += T * P, R = G, o = 0; o < z; o++)
  10409. R.r = w, R.g = E, R.b = S, R.a = P, R = R.next;
  10410. for (o = 1; o < z; o++)
  10411. h = A + ((L < o ? L : o) << 2), f += (R.r = w = e[h]) * (k = z - o), c += (R.g = E = e[h + 1]) * k, d += (R.b = S = e[h + 2]) * k, p += (R.a = P = e[h + 3]) * k, y += w, x += E, b += S, C += P, R = R.next;
  10412. for (N = G, q = H, r = 0; r < i; r++)
  10413. e[A + 3] = P = p * et >> tt, P !== 0 ? (P = 255 / P, e[A] = (f * et >> tt) * P, e[A + 1] = (c * et >> tt) * P, e[A + 2] = (d * et >> tt) * P) : e[A] = e[A + 1] = e[A + 2] = 0, f -= m, c -= v, d -= _, p -= g, m -= N.r, v -= N.g, _ -= N.b, g -= N.a, h = u + ((h = r + t + 1) < L ? h : L) << 2, y += N.r = e[h], x += N.g = e[h + 1], b += N.b = e[h + 2], C += N.a = e[h + 3], f += y, c += x, d += b, p += C, N = N.next, m += w = q.r, v += E = q.g, _ += S = q.b, g += P = q.a, y -= w, x -= E, b -= S, C -= P, q = q.next, A += 4;
  10414. u += i;
  10415. }
  10416. for (r = 0; r < i; r++) {
  10417. for (x = b = C = y = c = d = p = f = 0, A = r << 2, m = z * (w = e[A]), v = z * (E = e[A + 1]), _ = z * (S = e[A + 2]), g = z * (P = e[A + 3]), f += T * w, c += T * E, d += T * S, p += T * P, R = G, o = 0; o < z; o++)
  10418. R.r = w, R.g = E, R.b = S, R.a = P, R = R.next;
  10419. for (l = i, o = 1; o <= t; o++)
  10420. A = l + r << 2, f += (R.r = w = e[A]) * (k = z - o), c += (R.g = E = e[A + 1]) * k, d += (R.b = S = e[A + 2]) * k, p += (R.a = P = e[A + 3]) * k, y += w, x += E, b += S, C += P, R = R.next, o < I && (l += i);
  10421. for (A = r, N = G, q = H, a = 0; a < n; a++)
  10422. h = A << 2, e[h + 3] = P = p * et >> tt, P > 0 ? (P = 255 / P, e[h] = (f * et >> tt) * P, e[h + 1] = (c * et >> tt) * P, e[h + 2] = (d * et >> tt) * P) : e[h] = e[h + 1] = e[h + 2] = 0, f -= m, c -= v, d -= _, p -= g, m -= N.r, v -= N.g, _ -= N.b, g -= N.a, h = r + ((h = a + z) < I ? h : I) * i << 2, f += y += N.r = e[h], c += x += N.g = e[h + 1], d += b += N.b = e[h + 2], p += C += N.a = e[h + 3], N = N.next, m += w = q.r, v += E = q.g, _ += S = q.b, g += P = q.a, y -= w, x -= E, b -= S, C -= P, q = q.next, A += i;
  10423. }
  10424. }
  10425. const Ac = function(t) {
  10426. var e = Math.round(this.blurRadius());
  10427. e > 0 && lc(t, e);
  10428. };
  10429. is.Blur = Ac;
  10430. Ia.Factory.addGetterSetter(rc.Node, "blurRadius", 0, (0, ac.getNumberValidator)(), Ia.Factory.afterSetFilter);
  10431. var ns = {};
  10432. Object.defineProperty(ns, "__esModule", { value: !0 });
  10433. ns.Brighten = void 0;
  10434. const La = V, cc = rt, dc = O, uc = function(s) {
  10435. var t = this.brightness() * 255, e = s.data, i = e.length, n;
  10436. for (n = 0; n < i; n += 4)
  10437. e[n] += t, e[n + 1] += t, e[n + 2] += t;
  10438. };
  10439. ns.Brighten = uc;
  10440. La.Factory.addGetterSetter(cc.Node, "brightness", 0, (0, dc.getNumberValidator)(), La.Factory.afterSetFilter);
  10441. var ss = {};
  10442. Object.defineProperty(ss, "__esModule", { value: !0 });
  10443. ss.Contrast = void 0;
  10444. const Ra = V, fc = rt, gc = O, pc = function(s) {
  10445. var t = Math.pow((this.contrast() + 100) / 100, 2), e = s.data, i = e.length, n = 150, r = 150, a = 150, o;
  10446. for (o = 0; o < i; o += 4)
  10447. n = e[o], r = e[o + 1], a = e[o + 2], n /= 255, n -= 0.5, n *= t, n += 0.5, n *= 255, r /= 255, r -= 0.5, r *= t, r += 0.5, r *= 255, a /= 255, a -= 0.5, a *= t, a += 0.5, a *= 255, n = n < 0 ? 0 : n > 255 ? 255 : n, r = r < 0 ? 0 : r > 255 ? 255 : r, a = a < 0 ? 0 : a > 255 ? 255 : a, e[o] = n, e[o + 1] = r, e[o + 2] = a;
  10448. };
  10449. ss.Contrast = pc;
  10450. Ra.Factory.addGetterSetter(fc.Node, "contrast", 0, (0, gc.getNumberValidator)(), Ra.Factory.afterSetFilter);
  10451. var rs = {};
  10452. Object.defineProperty(rs, "__esModule", { value: !0 });
  10453. rs.Emboss = void 0;
  10454. const de = V, as = rt, yc = st, th = O, mc = function(s) {
  10455. var t = this.embossStrength() * 10, e = this.embossWhiteLevel() * 255, i = this.embossDirection(), n = this.embossBlend(), r = 0, a = 0, o = s.data, h = s.width, l = s.height, A = h * 4, u = l;
  10456. switch (i) {
  10457. case "top-left":
  10458. r = -1, a = -1;
  10459. break;
  10460. case "top":
  10461. r = -1, a = 0;
  10462. break;
  10463. case "top-right":
  10464. r = -1, a = 1;
  10465. break;
  10466. case "right":
  10467. r = 0, a = 1;
  10468. break;
  10469. case "bottom-right":
  10470. r = 1, a = 1;
  10471. break;
  10472. case "bottom":
  10473. r = 1, a = 0;
  10474. break;
  10475. case "bottom-left":
  10476. r = 1, a = -1;
  10477. break;
  10478. case "left":
  10479. r = 0, a = -1;
  10480. break;
  10481. default:
  10482. yc.Util.error("Unknown emboss direction: " + i);
  10483. }
  10484. do {
  10485. var f = (u - 1) * A, c = r;
  10486. u + c < 1 && (c = 0), u + c > l && (c = 0);
  10487. var d = (u - 1 + c) * h * 4, p = h;
  10488. do {
  10489. var m = f + (p - 1) * 4, v = a;
  10490. p + v < 1 && (v = 0), p + v > h && (v = 0);
  10491. var _ = d + (p - 1 + v) * 4, g = o[m] - o[_], y = o[m + 1] - o[_ + 1], x = o[m + 2] - o[_ + 2], b = g, C = b > 0 ? b : -b, w = y > 0 ? y : -y, E = x > 0 ? x : -x;
  10492. if (w > C && (b = y), E > C && (b = x), b *= t, n) {
  10493. var S = o[m] + b, P = o[m + 1] + b, k = o[m + 2] + b;
  10494. o[m] = S > 255 ? 255 : S < 0 ? 0 : S, o[m + 1] = P > 255 ? 255 : P < 0 ? 0 : P, o[m + 2] = k > 255 ? 255 : k < 0 ? 0 : k;
  10495. } else {
  10496. var F = e - b;
  10497. F < 0 ? F = 0 : F > 255 && (F = 255), o[m] = o[m + 1] = o[m + 2] = F;
  10498. }
  10499. } while (--p);
  10500. } while (--u);
  10501. };
  10502. rs.Emboss = mc;
  10503. de.Factory.addGetterSetter(as.Node, "embossStrength", 0.5, (0, th.getNumberValidator)(), de.Factory.afterSetFilter);
  10504. de.Factory.addGetterSetter(as.Node, "embossWhiteLevel", 0.5, (0, th.getNumberValidator)(), de.Factory.afterSetFilter);
  10505. de.Factory.addGetterSetter(as.Node, "embossDirection", "top-left", null, de.Factory.afterSetFilter);
  10506. de.Factory.addGetterSetter(as.Node, "embossBlend", !1, null, de.Factory.afterSetFilter);
  10507. var os = {};
  10508. Object.defineProperty(os, "__esModule", { value: !0 });
  10509. os.Enhance = void 0;
  10510. const Oa = V, vc = rt, _c = O;
  10511. function Vs(s, t, e, i, n) {
  10512. var r = e - t, a = n - i, o;
  10513. return r === 0 ? i + a / 2 : a === 0 ? i : (o = (s - t) / r, o = a * o + i, o);
  10514. }
  10515. const xc = function(s) {
  10516. var t = s.data, e = t.length, i = t[0], n = i, r, a = t[1], o = a, h, l = t[2], A = l, u, f, c = this.enhance();
  10517. if (c !== 0) {
  10518. for (f = 0; f < e; f += 4)
  10519. r = t[f + 0], r < i ? i = r : r > n && (n = r), h = t[f + 1], h < a ? a = h : h > o && (o = h), u = t[f + 2], u < l ? l = u : u > A && (A = u);
  10520. n === i && (n = 255, i = 0), o === a && (o = 255, a = 0), A === l && (A = 255, l = 0);
  10521. var d, p, m, v, _, g, y, x, b;
  10522. for (c > 0 ? (p = n + c * (255 - n), m = i - c * (i - 0), _ = o + c * (255 - o), g = a - c * (a - 0), x = A + c * (255 - A), b = l - c * (l - 0)) : (d = (n + i) * 0.5, p = n + c * (n - d), m = i + c * (i - d), v = (o + a) * 0.5, _ = o + c * (o - v), g = a + c * (a - v), y = (A + l) * 0.5, x = A + c * (A - y), b = l + c * (l - y)), f = 0; f < e; f += 4)
  10523. t[f + 0] = Vs(t[f + 0], i, n, m, p), t[f + 1] = Vs(t[f + 1], a, o, g, _), t[f + 2] = Vs(t[f + 2], l, A, b, x);
  10524. }
  10525. };
  10526. os.Enhance = xc;
  10527. Oa.Factory.addGetterSetter(vc.Node, "enhance", 0, (0, _c.getNumberValidator)(), Oa.Factory.afterSetFilter);
  10528. var hs = {};
  10529. Object.defineProperty(hs, "__esModule", { value: !0 });
  10530. hs.Grayscale = void 0;
  10531. const bc = function(s) {
  10532. var t = s.data, e = t.length, i, n;
  10533. for (i = 0; i < e; i += 4)
  10534. n = 0.34 * t[i] + 0.5 * t[i + 1] + 0.16 * t[i + 2], t[i] = n, t[i + 1] = n, t[i + 2] = n;
  10535. };
  10536. hs.Grayscale = bc;
  10537. var ls = {};
  10538. Object.defineProperty(ls, "__esModule", { value: !0 });
  10539. ls.HSL = void 0;
  10540. const ni = V, Er = rt, Fr = O;
  10541. ni.Factory.addGetterSetter(Er.Node, "hue", 0, (0, Fr.getNumberValidator)(), ni.Factory.afterSetFilter);
  10542. ni.Factory.addGetterSetter(Er.Node, "saturation", 0, (0, Fr.getNumberValidator)(), ni.Factory.afterSetFilter);
  10543. ni.Factory.addGetterSetter(Er.Node, "luminance", 0, (0, Fr.getNumberValidator)(), ni.Factory.afterSetFilter);
  10544. const wc = function(s) {
  10545. var t = s.data, e = t.length, i = 1, n = Math.pow(2, this.saturation()), r = Math.abs(this.hue() + 360) % 360, a = this.luminance() * 127, o, h = i * n * Math.cos(r * Math.PI / 180), l = i * n * Math.sin(r * Math.PI / 180), A = 0.299 * i + 0.701 * h + 0.167 * l, u = 0.587 * i - 0.587 * h + 0.33 * l, f = 0.114 * i - 0.114 * h - 0.497 * l, c = 0.299 * i - 0.299 * h - 0.328 * l, d = 0.587 * i + 0.413 * h + 0.035 * l, p = 0.114 * i - 0.114 * h + 0.293 * l, m = 0.299 * i - 0.3 * h + 1.25 * l, v = 0.587 * i - 0.586 * h - 1.05 * l, _ = 0.114 * i + 0.886 * h - 0.2 * l, g, y, x, b;
  10546. for (o = 0; o < e; o += 4)
  10547. g = t[o + 0], y = t[o + 1], x = t[o + 2], b = t[o + 3], t[o + 0] = A * g + u * y + f * x + a, t[o + 1] = c * g + d * y + p * x + a, t[o + 2] = m * g + v * y + _ * x + a, t[o + 3] = b;
  10548. };
  10549. ls.HSL = wc;
  10550. var As = {};
  10551. Object.defineProperty(As, "__esModule", { value: !0 });
  10552. As.HSV = void 0;
  10553. const si = V, kr = rt, Dr = O, Sc = function(s) {
  10554. var t = s.data, e = t.length, i = Math.pow(2, this.value()), n = Math.pow(2, this.saturation()), r = Math.abs(this.hue() + 360) % 360, a, o = i * n * Math.cos(r * Math.PI / 180), h = i * n * Math.sin(r * Math.PI / 180), l = 0.299 * i + 0.701 * o + 0.167 * h, A = 0.587 * i - 0.587 * o + 0.33 * h, u = 0.114 * i - 0.114 * o - 0.497 * h, f = 0.299 * i - 0.299 * o - 0.328 * h, c = 0.587 * i + 0.413 * o + 0.035 * h, d = 0.114 * i - 0.114 * o + 0.293 * h, p = 0.299 * i - 0.3 * o + 1.25 * h, m = 0.587 * i - 0.586 * o - 1.05 * h, v = 0.114 * i + 0.886 * o - 0.2 * h, _, g, y, x;
  10555. for (a = 0; a < e; a += 4)
  10556. _ = t[a + 0], g = t[a + 1], y = t[a + 2], x = t[a + 3], t[a + 0] = l * _ + A * g + u * y, t[a + 1] = f * _ + c * g + d * y, t[a + 2] = p * _ + m * g + v * y, t[a + 3] = x;
  10557. };
  10558. As.HSV = Sc;
  10559. si.Factory.addGetterSetter(kr.Node, "hue", 0, (0, Dr.getNumberValidator)(), si.Factory.afterSetFilter);
  10560. si.Factory.addGetterSetter(kr.Node, "saturation", 0, (0, Dr.getNumberValidator)(), si.Factory.afterSetFilter);
  10561. si.Factory.addGetterSetter(kr.Node, "value", 0, (0, Dr.getNumberValidator)(), si.Factory.afterSetFilter);
  10562. var cs = {};
  10563. Object.defineProperty(cs, "__esModule", { value: !0 });
  10564. cs.Invert = void 0;
  10565. const Cc = function(s) {
  10566. var t = s.data, e = t.length, i;
  10567. for (i = 0; i < e; i += 4)
  10568. t[i] = 255 - t[i], t[i + 1] = 255 - t[i + 1], t[i + 2] = 255 - t[i + 2];
  10569. };
  10570. cs.Invert = Cc;
  10571. var ds = {};
  10572. Object.defineProperty(ds, "__esModule", { value: !0 });
  10573. ds.Kaleidoscope = void 0;
  10574. const fn = V, eh = rt, Na = st, ih = O;
  10575. var Mc = function(s, t, e) {
  10576. var i = s.data, n = t.data, r = s.width, a = s.height, o = e.polarCenterX || r / 2, h = e.polarCenterY || a / 2, l, A, u, f = 0, c = 0, d = 0, p = 0, m, v = Math.sqrt(o * o + h * h);
  10577. A = r - o, u = a - h, m = Math.sqrt(A * A + u * u), v = m > v ? m : v;
  10578. var _ = a, g = r, y, x, b = 360 / g * Math.PI / 180, C, w;
  10579. for (x = 0; x < g; x += 1)
  10580. for (C = Math.sin(x * b), w = Math.cos(x * b), y = 0; y < _; y += 1)
  10581. A = Math.floor(o + v * y / _ * w), u = Math.floor(h + v * y / _ * C), l = (u * r + A) * 4, f = i[l + 0], c = i[l + 1], d = i[l + 2], p = i[l + 3], l = (x + y * r) * 4, n[l + 0] = f, n[l + 1] = c, n[l + 2] = d, n[l + 3] = p;
  10582. }, Pc = function(s, t, e) {
  10583. var i = s.data, n = t.data, r = s.width, a = s.height, o = e.polarCenterX || r / 2, h = e.polarCenterY || a / 2, l, A, u, f, c, d = 0, p = 0, m = 0, v = 0, _, g = Math.sqrt(o * o + h * h);
  10584. A = r - o, u = a - h, _ = Math.sqrt(A * A + u * u), g = _ > g ? _ : g;
  10585. var y = a, x = r, b, C, w = 0, E, S;
  10586. for (A = 0; A < r; A += 1)
  10587. for (u = 0; u < a; u += 1)
  10588. f = A - o, c = u - h, b = Math.sqrt(f * f + c * c) * y / g, C = (Math.atan2(c, f) * 180 / Math.PI + 360 + w) % 360, C = C * x / 360, E = Math.floor(C), S = Math.floor(b), l = (S * r + E) * 4, d = i[l + 0], p = i[l + 1], m = i[l + 2], v = i[l + 3], l = (u * r + A) * 4, n[l + 0] = d, n[l + 1] = p, n[l + 2] = m, n[l + 3] = v;
  10589. };
  10590. const Ec = function(s) {
  10591. var t = s.width, e = s.height, i, n, r, a, o, h, l, A, u, f, c = Math.round(this.kaleidoscopePower()), d = Math.round(this.kaleidoscopeAngle()), p = Math.floor(t * (d % 360) / 360);
  10592. if (!(c < 1)) {
  10593. var m = Na.Util.createCanvasElement();
  10594. m.width = t, m.height = e;
  10595. var v = m.getContext("2d").getImageData(0, 0, t, e);
  10596. Na.Util.releaseCanvas(m), Mc(s, v, {
  10597. polarCenterX: t / 2,
  10598. polarCenterY: e / 2
  10599. });
  10600. for (var _ = t / Math.pow(2, c); _ <= 8; )
  10601. _ = _ * 2, c -= 1;
  10602. _ = Math.ceil(_);
  10603. var g = _, y = 0, x = g, b = 1;
  10604. for (p + _ > t && (y = g, x = 0, b = -1), n = 0; n < e; n += 1)
  10605. for (i = y; i !== x; i += b)
  10606. r = Math.round(i + p) % t, u = (t * n + r) * 4, o = v.data[u + 0], h = v.data[u + 1], l = v.data[u + 2], A = v.data[u + 3], f = (t * n + i) * 4, v.data[f + 0] = o, v.data[f + 1] = h, v.data[f + 2] = l, v.data[f + 3] = A;
  10607. for (n = 0; n < e; n += 1)
  10608. for (g = Math.floor(_), a = 0; a < c; a += 1) {
  10609. for (i = 0; i < g + 1; i += 1)
  10610. u = (t * n + i) * 4, o = v.data[u + 0], h = v.data[u + 1], l = v.data[u + 2], A = v.data[u + 3], f = (t * n + g * 2 - i - 1) * 4, v.data[f + 0] = o, v.data[f + 1] = h, v.data[f + 2] = l, v.data[f + 3] = A;
  10611. g *= 2;
  10612. }
  10613. Pc(v, s, { polarRotation: 0 });
  10614. }
  10615. };
  10616. ds.Kaleidoscope = Ec;
  10617. fn.Factory.addGetterSetter(eh.Node, "kaleidoscopePower", 2, (0, ih.getNumberValidator)(), fn.Factory.afterSetFilter);
  10618. fn.Factory.addGetterSetter(eh.Node, "kaleidoscopeAngle", 0, (0, ih.getNumberValidator)(), fn.Factory.afterSetFilter);
  10619. var us = {};
  10620. Object.defineProperty(us, "__esModule", { value: !0 });
  10621. us.Mask = void 0;
  10622. const Ga = V, Fc = rt, kc = O;
  10623. function sn(s, t, e) {
  10624. var i = (e * s.width + t) * 4, n = [];
  10625. return n.push(s.data[i++], s.data[i++], s.data[i++], s.data[i++]), n;
  10626. }
  10627. function bi(s, t) {
  10628. return Math.sqrt(Math.pow(s[0] - t[0], 2) + Math.pow(s[1] - t[1], 2) + Math.pow(s[2] - t[2], 2));
  10629. }
  10630. function Dc(s) {
  10631. for (var t = [0, 0, 0], e = 0; e < s.length; e++)
  10632. t[0] += s[e][0], t[1] += s[e][1], t[2] += s[e][2];
  10633. return t[0] /= s.length, t[1] /= s.length, t[2] /= s.length, t;
  10634. }
  10635. function Ic(s, t) {
  10636. var e = sn(s, 0, 0), i = sn(s, s.width - 1, 0), n = sn(s, 0, s.height - 1), r = sn(s, s.width - 1, s.height - 1), a = t || 10;
  10637. if (bi(e, i) < a && bi(i, r) < a && bi(r, n) < a && bi(n, e) < a) {
  10638. for (var o = Dc([i, e, r, n]), h = [], l = 0; l < s.width * s.height; l++) {
  10639. var A = bi(o, [
  10640. s.data[l * 4],
  10641. s.data[l * 4 + 1],
  10642. s.data[l * 4 + 2]
  10643. ]);
  10644. h[l] = A < a ? 0 : 255;
  10645. }
  10646. return h;
  10647. }
  10648. }
  10649. function Tc(s, t) {
  10650. for (var e = 0; e < s.width * s.height; e++)
  10651. s.data[4 * e + 3] = t[e];
  10652. }
  10653. function Lc(s, t, e) {
  10654. for (var i = [1, 1, 1, 1, 0, 1, 1, 1, 1], n = Math.round(Math.sqrt(i.length)), r = Math.floor(n / 2), a = [], o = 0; o < e; o++)
  10655. for (var h = 0; h < t; h++) {
  10656. for (var l = o * t + h, A = 0, u = 0; u < n; u++)
  10657. for (var f = 0; f < n; f++) {
  10658. var c = o + u - r, d = h + f - r;
  10659. if (c >= 0 && c < e && d >= 0 && d < t) {
  10660. var p = c * t + d, m = i[u * n + f];
  10661. A += s[p] * m;
  10662. }
  10663. }
  10664. a[l] = A === 255 * 8 ? 255 : 0;
  10665. }
  10666. return a;
  10667. }
  10668. function Rc(s, t, e) {
  10669. for (var i = [1, 1, 1, 1, 1, 1, 1, 1, 1], n = Math.round(Math.sqrt(i.length)), r = Math.floor(n / 2), a = [], o = 0; o < e; o++)
  10670. for (var h = 0; h < t; h++) {
  10671. for (var l = o * t + h, A = 0, u = 0; u < n; u++)
  10672. for (var f = 0; f < n; f++) {
  10673. var c = o + u - r, d = h + f - r;
  10674. if (c >= 0 && c < e && d >= 0 && d < t) {
  10675. var p = c * t + d, m = i[u * n + f];
  10676. A += s[p] * m;
  10677. }
  10678. }
  10679. a[l] = A >= 255 * 4 ? 255 : 0;
  10680. }
  10681. return a;
  10682. }
  10683. function Oc(s, t, e) {
  10684. for (var i = [0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111], n = Math.round(Math.sqrt(i.length)), r = Math.floor(n / 2), a = [], o = 0; o < e; o++)
  10685. for (var h = 0; h < t; h++) {
  10686. for (var l = o * t + h, A = 0, u = 0; u < n; u++)
  10687. for (var f = 0; f < n; f++) {
  10688. var c = o + u - r, d = h + f - r;
  10689. if (c >= 0 && c < e && d >= 0 && d < t) {
  10690. var p = c * t + d, m = i[u * n + f];
  10691. A += s[p] * m;
  10692. }
  10693. }
  10694. a[l] = A;
  10695. }
  10696. return a;
  10697. }
  10698. const Nc = function(s) {
  10699. var t = this.threshold(), e = Ic(s, t);
  10700. return e && (e = Lc(e, s.width, s.height), e = Rc(e, s.width, s.height), e = Oc(e, s.width, s.height), Tc(s, e)), s;
  10701. };
  10702. us.Mask = Nc;
  10703. Ga.Factory.addGetterSetter(Fc.Node, "threshold", 0, (0, kc.getNumberValidator)(), Ga.Factory.afterSetFilter);
  10704. var fs = {};
  10705. Object.defineProperty(fs, "__esModule", { value: !0 });
  10706. fs.Noise = void 0;
  10707. const Ba = V, Gc = rt, Bc = O, zc = function(s) {
  10708. var t = this.noise() * 255, e = s.data, i = e.length, n = t / 2, r;
  10709. for (r = 0; r < i; r += 4)
  10710. e[r + 0] += n - 2 * n * Math.random(), e[r + 1] += n - 2 * n * Math.random(), e[r + 2] += n - 2 * n * Math.random();
  10711. };
  10712. fs.Noise = zc;
  10713. Ba.Factory.addGetterSetter(Gc.Node, "noise", 0.2, (0, Bc.getNumberValidator)(), Ba.Factory.afterSetFilter);
  10714. var gs = {};
  10715. Object.defineProperty(gs, "__esModule", { value: !0 });
  10716. gs.Pixelate = void 0;
  10717. const za = V, Uc = st, Hc = rt, Vc = O, $c = function(s) {
  10718. var t = Math.ceil(this.pixelSize()), e = s.width, i = s.height, n, r, a, o, h, l, A, u = Math.ceil(e / t), f = Math.ceil(i / t), c, d, p, m, v, _, g, y = s.data;
  10719. if (t <= 0) {
  10720. Uc.Util.error("pixelSize value can not be <= 0");
  10721. return;
  10722. }
  10723. for (v = 0; v < u; v += 1)
  10724. for (_ = 0; _ < f; _ += 1) {
  10725. for (o = 0, h = 0, l = 0, A = 0, c = v * t, d = c + t, p = _ * t, m = p + t, g = 0, n = c; n < d; n += 1)
  10726. if (!(n >= e))
  10727. for (r = p; r < m; r += 1)
  10728. r >= i || (a = (e * r + n) * 4, o += y[a + 0], h += y[a + 1], l += y[a + 2], A += y[a + 3], g += 1);
  10729. for (o = o / g, h = h / g, l = l / g, A = A / g, n = c; n < d; n += 1)
  10730. if (!(n >= e))
  10731. for (r = p; r < m; r += 1)
  10732. r >= i || (a = (e * r + n) * 4, y[a + 0] = o, y[a + 1] = h, y[a + 2] = l, y[a + 3] = A);
  10733. }
  10734. };
  10735. gs.Pixelate = $c;
  10736. za.Factory.addGetterSetter(Hc.Node, "pixelSize", 8, (0, Vc.getNumberValidator)(), za.Factory.afterSetFilter);
  10737. var ps = {};
  10738. Object.defineProperty(ps, "__esModule", { value: !0 });
  10739. ps.Posterize = void 0;
  10740. const Ua = V, Wc = rt, Yc = O, Xc = function(s) {
  10741. var t = Math.round(this.levels() * 254) + 1, e = s.data, i = e.length, n = 255 / t, r;
  10742. for (r = 0; r < i; r += 1)
  10743. e[r] = Math.floor(e[r] / n) * n;
  10744. };
  10745. ps.Posterize = Xc;
  10746. Ua.Factory.addGetterSetter(Wc.Node, "levels", 0.5, (0, Yc.getNumberValidator)(), Ua.Factory.afterSetFilter);
  10747. var ys = {};
  10748. Object.defineProperty(ys, "__esModule", { value: !0 });
  10749. ys.RGB = void 0;
  10750. const gn = V, Ir = rt, jc = O, qc = function(s) {
  10751. var t = s.data, e = t.length, i = this.red(), n = this.green(), r = this.blue(), a, o;
  10752. for (a = 0; a < e; a += 4)
  10753. o = (0.34 * t[a] + 0.5 * t[a + 1] + 0.16 * t[a + 2]) / 255, t[a] = o * i, t[a + 1] = o * n, t[a + 2] = o * r, t[a + 3] = t[a + 3];
  10754. };
  10755. ys.RGB = qc;
  10756. gn.Factory.addGetterSetter(Ir.Node, "red", 0, function(s) {
  10757. return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
  10758. });
  10759. gn.Factory.addGetterSetter(Ir.Node, "green", 0, function(s) {
  10760. return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
  10761. });
  10762. gn.Factory.addGetterSetter(Ir.Node, "blue", 0, jc.RGBComponent, gn.Factory.afterSetFilter);
  10763. var ms = {};
  10764. Object.defineProperty(ms, "__esModule", { value: !0 });
  10765. ms.RGBA = void 0;
  10766. const Ti = V, vs = rt, Qc = O, Kc = function(s) {
  10767. var t = s.data, e = t.length, i = this.red(), n = this.green(), r = this.blue(), a = this.alpha(), o, h;
  10768. for (o = 0; o < e; o += 4)
  10769. h = 1 - a, t[o] = i * a + t[o] * h, t[o + 1] = n * a + t[o + 1] * h, t[o + 2] = r * a + t[o + 2] * h;
  10770. };
  10771. ms.RGBA = Kc;
  10772. Ti.Factory.addGetterSetter(vs.Node, "red", 0, function(s) {
  10773. return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
  10774. });
  10775. Ti.Factory.addGetterSetter(vs.Node, "green", 0, function(s) {
  10776. return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
  10777. });
  10778. Ti.Factory.addGetterSetter(vs.Node, "blue", 0, Qc.RGBComponent, Ti.Factory.afterSetFilter);
  10779. Ti.Factory.addGetterSetter(vs.Node, "alpha", 1, function(s) {
  10780. return this._filterUpToDate = !1, s > 1 ? 1 : s < 0 ? 0 : s;
  10781. });
  10782. var _s = {};
  10783. Object.defineProperty(_s, "__esModule", { value: !0 });
  10784. _s.Sepia = void 0;
  10785. const Zc = function(s) {
  10786. var t = s.data, e = t.length, i, n, r, a;
  10787. for (i = 0; i < e; i += 4)
  10788. n = t[i + 0], r = t[i + 1], a = t[i + 2], t[i + 0] = Math.min(255, n * 0.393 + r * 0.769 + a * 0.189), t[i + 1] = Math.min(255, n * 0.349 + r * 0.686 + a * 0.168), t[i + 2] = Math.min(255, n * 0.272 + r * 0.534 + a * 0.131);
  10789. };
  10790. _s.Sepia = Zc;
  10791. var xs = {};
  10792. Object.defineProperty(xs, "__esModule", { value: !0 });
  10793. xs.Solarize = void 0;
  10794. const Jc = function(s) {
  10795. var t = s.data, e = s.width, i = s.height, n = e * 4, r = i;
  10796. do {
  10797. var a = (r - 1) * n, o = e;
  10798. do {
  10799. var h = a + (o - 1) * 4, l = t[h], A = t[h + 1], u = t[h + 2];
  10800. l > 127 && (l = 255 - l), A > 127 && (A = 255 - A), u > 127 && (u = 255 - u), t[h] = l, t[h + 1] = A, t[h + 2] = u;
  10801. } while (--o);
  10802. } while (--r);
  10803. };
  10804. xs.Solarize = Jc;
  10805. var bs = {};
  10806. Object.defineProperty(bs, "__esModule", { value: !0 });
  10807. bs.Threshold = void 0;
  10808. const Ha = V, td = rt, ed = O, id = function(s) {
  10809. var t = this.threshold() * 255, e = s.data, i = e.length, n;
  10810. for (n = 0; n < i; n += 1)
  10811. e[n] = e[n] < t ? 0 : 255;
  10812. };
  10813. bs.Threshold = id;
  10814. Ha.Factory.addGetterSetter(td.Node, "threshold", 0.5, (0, ed.getNumberValidator)(), Ha.Factory.afterSetFilter);
  10815. Object.defineProperty(Gn, "__esModule", { value: !0 });
  10816. Gn.Konva = void 0;
  10817. const Va = Po, nd = zn, sd = Vn, rd = Cn, ad = Wn, od = Yn, $a = ii, hd = Gi, ld = hi, Ad = Bi, cd = jn, dd = qn, ud = Qn, fd = Kn, gd = Me, pd = Zn, yd = Jn, md = ts, vd = is, _d = ns, xd = ss, bd = rs, wd = os, Sd = hs, Cd = ls, Md = As, Pd = cs, Ed = ds, Fd = us, kd = fs, Dd = gs, Id = ps, Td = ys, Ld = ms, Rd = _s, Od = xs, Nd = bs;
  10818. Gn.Konva = Va.Konva.Util._assign(Va.Konva, {
  10819. Arc: nd.Arc,
  10820. Arrow: sd.Arrow,
  10821. Circle: rd.Circle,
  10822. Ellipse: ad.Ellipse,
  10823. Image: od.Image,
  10824. Label: $a.Label,
  10825. Tag: $a.Tag,
  10826. Line: hd.Line,
  10827. Path: ld.Path,
  10828. Rect: Ad.Rect,
  10829. RegularPolygon: cd.RegularPolygon,
  10830. Ring: dd.Ring,
  10831. Sprite: ud.Sprite,
  10832. Star: fd.Star,
  10833. Text: gd.Text,
  10834. TextPath: pd.TextPath,
  10835. Transformer: yd.Transformer,
  10836. Wedge: md.Wedge,
  10837. Filters: {
  10838. Blur: vd.Blur,
  10839. Brighten: _d.Brighten,
  10840. Contrast: xd.Contrast,
  10841. Emboss: bd.Emboss,
  10842. Enhance: wd.Enhance,
  10843. Grayscale: Sd.Grayscale,
  10844. HSL: Cd.HSL,
  10845. HSV: Md.HSV,
  10846. Invert: Pd.Invert,
  10847. Kaleidoscope: Ed.Kaleidoscope,
  10848. Mask: Fd.Mask,
  10849. Noise: kd.Noise,
  10850. Pixelate: Dd.Pixelate,
  10851. Posterize: Id.Posterize,
  10852. RGB: Td.RGB,
  10853. RGBA: Ld.RGBA,
  10854. Sepia: Rd.Sepia,
  10855. Solarize: Od.Solarize,
  10856. Threshold: Nd.Threshold
  10857. }
  10858. });
  10859. var Gd = vr.exports;
  10860. Object.defineProperty(Gd, "__esModule", { value: !0 });
  10861. const Bd = Gn;
  10862. vr.exports = Bd.Konva;
  10863. var zd = vr.exports;
  10864. const Yt = /* @__PURE__ */ vh(zd);
  10865. function Tr(s) {
  10866. return { all: s = s || /* @__PURE__ */ new Map(), on: function(t, e) {
  10867. var i = s.get(t);
  10868. i ? i.push(e) : s.set(t, [e]);
  10869. }, off: function(t, e) {
  10870. var i = s.get(t);
  10871. i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : s.set(t, []));
  10872. }, emit: function(t, e) {
  10873. var i = s.get(t);
  10874. i && i.slice().map(function(n) {
  10875. n(e);
  10876. }), (i = s.get("*")) && i.slice().map(function(n) {
  10877. n(t, e);
  10878. });
  10879. } };
  10880. }
  10881. class ie {
  10882. constructor(t) {
  10883. this.bus = Tr(), this.children = [], this.flush = "pre", this.isMounted = !1, this.name = t.name, this.teleport = t.teleport, this.props = t, this.attrib = t.reactive ? ti(t.attrib) : t.attrib, this.zIndex = t.zIndex || 0;
  10884. }
  10885. getShape() {
  10886. return this.shape;
  10887. }
  10888. redraw() {
  10889. this.diffRedraw(), this.children.forEach((t) => t.redraw());
  10890. }
  10891. setAttrib(t) {
  10892. "id" in t && t.id !== this.attrib.id && (console.log(t, this.attrib, t.id, this.attrib.id), console.error("id 确定后无法更改")), t.id = this.attrib.id, this.props.reactive ? Rr(t) !== Rr(this.attrib) && (this.attrib = this.props.reactive ? ti(t) : t, this.bus.emit("updateAttrib"), this.initReactive()) : (this.attrib = t, this.diffRedraw());
  10893. }
  10894. initReactive(t = this.flush) {
  10895. this.destoryReactive && this.destoryReactive();
  10896. let e = !1;
  10897. const i = Sn(
  10898. () => {
  10899. e || this.diffRedraw();
  10900. },
  10901. { flush: t }
  10902. );
  10903. return this.flush = t, () => {
  10904. e = !0, i();
  10905. };
  10906. }
  10907. init() {
  10908. this.shape = this.initShape(), this.shape.id(this.name), this.bus.emit("created");
  10909. }
  10910. mount(t) {
  10911. if (this.shape instanceof Ii.Stage)
  10912. throw "stage 为顶级容器无法挂载";
  10913. if (t && this.shape instanceof _r && !(t instanceof Ii.Stage))
  10914. throw console.log(this.name, t), "layer 只能挂载到 Stage";
  10915. if (this.teleport && this.teleport === t)
  10916. return;
  10917. this.children.sort((i, n) => i.zIndex - n.zIndex);
  10918. const e = t || this.parent.shape;
  10919. if (e.add(this.shape), this.teleport = e, this.setZIndex(this.zIndex), this.props.reactive && (this.destoryReactive = this.initReactive()), qt) {
  10920. let i = { ...this.attrib };
  10921. fe(
  10922. () => this.attrib.id,
  10923. (n, r) => {
  10924. n !== r && console.error("changeId", i, this.attrib, n, r);
  10925. },
  10926. { flush: "sync" }
  10927. );
  10928. }
  10929. }
  10930. mounted() {
  10931. this.diffRedraw(), this.children.forEach((t) => t.mounted()), this.isMounted = !0, this.bus.emit("mounted");
  10932. }
  10933. setParent(t) {
  10934. if (this.parent) {
  10935. const e = this.parent.children.indexOf(this);
  10936. ~e && this.parent.children.splice(e, 1);
  10937. }
  10938. this.parent = t, t && this.parent.children.push(this);
  10939. }
  10940. getLevelNdx(t = this.parent) {
  10941. if (t) {
  10942. const e = t.children;
  10943. for (let i = e.length - 1; i >= 0; i--)
  10944. if (e[i] !== this && e[i].zIndex <= this.zIndex)
  10945. return i;
  10946. return -1;
  10947. }
  10948. return null;
  10949. }
  10950. setZIndex(t) {
  10951. this.zIndex = t;
  10952. const e = this.getLevelNdx();
  10953. if (e === null)
  10954. return;
  10955. const i = this.parent.children;
  10956. if (i.indexOf(this) !== e + 1) {
  10957. let l = this;
  10958. for (let A = e + 1; A < i.length; A++) {
  10959. const u = i[A];
  10960. i[A] = l, l = u;
  10961. }
  10962. }
  10963. const r = this.teleport, a = r.children, o = e === -1 ? 0 : a.indexOf(i[e].getShape()) + 1;
  10964. if (a.indexOf(this.shape) !== o)
  10965. if (o !== 0) {
  10966. let l = this.shape;
  10967. for (let A = o; A < a.length; A++) {
  10968. const u = a[A];
  10969. r.add(l), l.zIndex(A), l = u;
  10970. }
  10971. } else
  10972. this.shape.zIndex(0);
  10973. }
  10974. enableDrag(t) {
  10975. this.disableDrag(), this.dragDestory = yr(this.shape, t);
  10976. }
  10977. disableDrag() {
  10978. this.dragDestory && this.dragDestory(), this.dragDestory = null;
  10979. }
  10980. enableActive(t) {
  10981. this.disableActive(), this.activeDestory = ma(
  10982. this.shape,
  10983. {
  10984. active: () => t(!0),
  10985. bus: this.bus,
  10986. common: () => t(!1)
  10987. },
  10988. "mouse-active"
  10989. );
  10990. }
  10991. disableActive() {
  10992. this.activeDestory && this.activeDestory(), this.activeDestory = null;
  10993. }
  10994. enableMouseAct(t) {
  10995. this.disableMouseAct(), this.mouseActDestory = ma(
  10996. this.shape,
  10997. { ...t, bus: this.bus },
  10998. "act-mouse"
  10999. );
  11000. }
  11001. disableMouseAct() {
  11002. this.mouseActDestory && this.mouseActDestory(), this.mouseActDestory = null;
  11003. }
  11004. visible(t) {
  11005. this.shape.visible(t);
  11006. }
  11007. destory() {
  11008. for (; this.children.length; )
  11009. this.children[0].destory();
  11010. if (this.setParent(null), this.destoryReactive && this.destoryReactive(), this.disableDrag(), this.disableActive(), this.disableMouseAct(), qt && console.log(this.name, "destory"), this.shape instanceof Yt.Group ? this.shape.destroyChildren() : this.shape.destroy(), this.parent) {
  11011. const t = this.parent.children.indexOf(this);
  11012. ~t && this.parent.children.splice(t, 1);
  11013. }
  11014. this.bus.emit("destroyed"), this.bus.off("*");
  11015. }
  11016. find(t) {
  11017. for (const e of this.children) {
  11018. if (e.name === t)
  11019. return e;
  11020. const i = e.find(t);
  11021. if (i)
  11022. return i;
  11023. }
  11024. return null;
  11025. }
  11026. }
  11027. const yn = class yn extends ie {
  11028. constructor(t) {
  11029. t.zIndex = t.zIndex || 4, t.name = t.name || yn.namespace + t.attrib.id, super(t);
  11030. }
  11031. setConfig(t) {
  11032. this.config = t;
  11033. }
  11034. initShape() {
  11035. const t = new Yt.Label({
  11036. opacity: 0.75,
  11037. name: "label",
  11038. listening: !1
  11039. });
  11040. t.add(
  11041. new Yt.Tag({
  11042. name: "tag",
  11043. fill: "rgba(0, 0, 0, 0.8)",
  11044. pointerDirection: "down",
  11045. pointerWidth: 5,
  11046. pointerHeight: 5,
  11047. lineJoin: "round",
  11048. shadowColor: "black",
  11049. shadowBlur: 10,
  11050. shadowOffsetX: 10,
  11051. shadowOffsetY: 10,
  11052. shadowOpacity: 0.5,
  11053. listening: !1
  11054. }),
  11055. new Yt.Text({
  11056. name: "text",
  11057. text: "text",
  11058. fontFamily: "Calibri",
  11059. fontSize: 10,
  11060. padding: 3,
  11061. fill: "white",
  11062. listening: !1
  11063. })
  11064. );
  11065. const e = 8, i = new Nt({ name: "offset" });
  11066. return i.add(t).add(
  11067. new Yt.Arrow({
  11068. name: "arrow-1",
  11069. visible: !1,
  11070. points: [0, 0],
  11071. pointerLength: e,
  11072. pointerWidth: e,
  11073. fill: "black",
  11074. stroke: "black",
  11075. strokeWidth: 4,
  11076. listening: !1
  11077. }),
  11078. new Yt.Arrow({
  11079. name: "arrow-2",
  11080. visible: !1,
  11081. points: [0, 0],
  11082. pointerLength: e,
  11083. pointerWidth: e,
  11084. fill: "black",
  11085. stroke: "black",
  11086. strokeWidth: 4,
  11087. listening: !1
  11088. })
  11089. ), i;
  11090. }
  11091. diffRedraw() {
  11092. const t = this.attrib.pointIds.map(
  11093. (o) => this.config.points.find((h) => h.id === o)
  11094. );
  11095. if (t.some((o) => !o))
  11096. return null;
  11097. let e = !1;
  11098. const i = [];
  11099. for (const o of this.config.polygons)
  11100. for (const h of o.lineIds) {
  11101. const l = this.config.lines.find(({ id: A }) => A === h);
  11102. l.pointIds.includes(this.attrib.pointIds[0]) && l.pointIds.includes(this.attrib.pointIds[1]) && (i.push(`${l.id} [${l.pointIds.join(",")}]`), e = e || l.pointIds[0] === this.attrib.pointIds[1]);
  11103. }
  11104. const n = [];
  11105. t.forEach(({ x: o, y: h }, l) => {
  11106. n[l * 2] = o, n[l * 2 + 1] = h;
  11107. });
  11108. let r = Gt(
  11109. this.shape.findOne(".label"),
  11110. [1, 1]
  11111. );
  11112. const a = Se.radToDeg(LA(n, [0, 1]));
  11113. this.shape.findOne(".label").x((n[0] + n[2]) / 2).y((n[1] + n[3]) / 2).scale({ x: r[0], y: r[1] }).rotation(a < 0 ? a + 90 : a - 90), this.shape.findOne(".arrow-1").x(n[2]).y(n[3]).scale({ x: r[0], y: r[1] }).rotation(a + 90).visible(!0), e ? this.shape.findOne(".arrow-2").x(n[0]).y(n[1]).rotation(a - 90).scale({ x: r[0], y: r[1] }).visible(!0) : this.shape.findOne(".arrow-2").visible(!1), this.shape.findOne(".text").text(i.join(" | "));
  11114. }
  11115. };
  11116. yn.namespace = "line-helper";
  11117. let ar = yn;
  11118. const mn = class mn extends ie {
  11119. constructor(t) {
  11120. t.zIndex = t.zIndex || 5, t.name = t.name || mn.namespace + t.attrib.id, super(t);
  11121. }
  11122. initShape() {
  11123. const t = new Yt.Label({ opacity: 0.75, name: "label" });
  11124. return t.add(
  11125. new Yt.Tag({
  11126. name: "tag",
  11127. fill: "rgba(0, 0, 0, 0.8)",
  11128. pointerDirection: "down",
  11129. pointerWidth: 5,
  11130. pointerHeight: 5,
  11131. lineJoin: "round",
  11132. shadowColor: "black",
  11133. shadowBlur: 10,
  11134. shadowOffsetX: 10,
  11135. shadowOffsetY: 10,
  11136. shadowOpacity: 0.5
  11137. }),
  11138. new Yt.Text({
  11139. name: "text",
  11140. text: `P${this.attrib.id}`,
  11141. fontFamily: "Calibri",
  11142. fontSize: 10,
  11143. padding: 3,
  11144. fill: "white"
  11145. })
  11146. ), t;
  11147. }
  11148. diffRedraw() {
  11149. this.shape.x(this.attrib.x).y(this.attrib.y);
  11150. const t = Gt(this.shape, [1, 1]);
  11151. this.shape.scale({ x: t[0], y: t[0] });
  11152. }
  11153. };
  11154. mn.namespace = "point-helper";
  11155. let or = mn;
  11156. const vn = class vn extends ie {
  11157. constructor(t) {
  11158. t.zIndex = t.zIndex || Mt.zIndex, t.name = t.name || vn.namespace + t.attrib.id, super(t), this.actShapeFactory = On;
  11159. }
  11160. setActShapeFactory(t) {
  11161. this.actShapeFactory = t;
  11162. }
  11163. initShape() {
  11164. return this.actShape = this.actShapeFactory(this.attrib, this), this.actShape.shape;
  11165. }
  11166. diffRedraw() {
  11167. this.actShape.setData([this.attrib.x, this.attrib.y]);
  11168. }
  11169. mounted() {
  11170. super.mounted(), this.actShape.common(null);
  11171. }
  11172. };
  11173. vn.namespace = "point";
  11174. let Tt = vn, ws = 0;
  11175. const Ud = (s) => ws = s, nh = (s) => (Math.max(1, ws, ...s.lines.map(({ id: t }) => Number(t))) + 1).toString(), sh = (s) => (Math.max(1, ws, ...s.points.map(({ id: t }) => Number(t))) + 1).toString(), rh = (s, t = []) => (Math.max(
  11176. 1,
  11177. ws,
  11178. ...s.polygons.map(({ id: e }) => Number(e)),
  11179. ...t.map(Number)
  11180. ) + 1).toString(), Pe = (s, t) => s.points.find((e) => e.id === t), _t = (s, t) => t ? t.map((e) => Pe(s, e)) : s.points, ah = (s, t) => s.lines.filter(({ pointIds: e }) => e.includes(t)), Hd = (s, t, e = !1) => s.lines.filter(({ pointIds: i }) => {
  11181. let n = i.includes(t[0]) && i.includes(t[1]);
  11182. return n || (e && (n = i.includes(t[1]) && i.includes(t[0])), n);
  11183. }), Vd = (s, t) => ah(s, t.id), wt = (s, t) => s.lines.find(({ id: e }) => e === t), oh = (s, t) => t.map((e) => wt(s, e)), pi = (s, t) => _t(s, wt(s, t).pointIds), c1 = (s) => s.lines.map((t) => _t(s, t.pointIds)), yi = (s, t) => s.polygons.find((e) => e.id === t), $d = (s, t) => yi(s, t).lineIds.map(
  11184. (e) => pi(s, e)
  11185. ), hh = (s, t) => {
  11186. const e = yi(s, t);
  11187. return e ? e.lineIds.map(
  11188. (i) => wt(s, i)
  11189. ) : [];
  11190. }, d1 = (s, t) => s.lines.filter(({ pointIds: e }) => e.includes(t)).map((e) => pi(s, e.id)), lh = (s, t) => {
  11191. const e = [];
  11192. for (const i of s.polygons) {
  11193. const n = i.lineIds.filter(
  11194. (r) => wt(s, r).pointIds.includes(t)
  11195. ).map((r) => pi(s, r));
  11196. n.length && e.push({
  11197. polygonId: i.id,
  11198. lines: n
  11199. });
  11200. }
  11201. return e;
  11202. }, u1 = (s, t) => s.polygons.filter((e) => e.lineIds.some(
  11203. (i) => wt(s, i).pointIds.includes(t)
  11204. )), ri = (s, t) => {
  11205. const e = yi(s, t);
  11206. if (!e)
  11207. return [];
  11208. const { lineIds: i } = e, n = [];
  11209. for (let r = 0; r < i.length; r++) {
  11210. const a = wt(s, i[r]);
  11211. n.push(Pe(s, a.pointIds[0])), r === i.length - 1 && n.push(Pe(s, a.pointIds[1]));
  11212. }
  11213. return n;
  11214. }, Si = (...s) => {
  11215. const t = {};
  11216. for (const e of s)
  11217. for (const i in e)
  11218. if (!t[i])
  11219. t[i] = Object.fromEntries(
  11220. Object.entries(e[i]).map(([n, r]) => [
  11221. n,
  11222. [...r]
  11223. ])
  11224. );
  11225. else
  11226. for (const n in e[i]) {
  11227. if (!t[i][n]) {
  11228. t[i][n] = [...e[i][n]];
  11229. break;
  11230. }
  11231. const r = e[i][n], a = t[i][n];
  11232. for (const o of r)
  11233. a.every(({ id: h }) => h !== o.id) && a.push(o);
  11234. }
  11235. return t;
  11236. }, Ah = (s, t) => s.lines.findIndex(
  11237. ({ pointIds: e }) => e[0] === t[0] && e[1] === t[1]
  11238. ), ue = (s, t) => {
  11239. const e = {
  11240. lineChange: { add: [] }
  11241. };
  11242. let i = Ah(s, t);
  11243. return ~i || (i = s.lines.push({
  11244. id: nh(s),
  11245. pointIds: [...t]
  11246. }) - 1, e.lineChange.add.push(s.lines[i])), { line: s.lines[i], change: e };
  11247. }, ai = (s, t, e = !0) => {
  11248. const i = {
  11249. lineChange: { del: [] },
  11250. pointChange: { del: [] }
  11251. }, n = Ah(s, t), r = s.lines[n];
  11252. return ~n ? (s.polygons.every(
  11253. ({ lineIds: o }) => !o.includes(r.id)
  11254. ) && (s.lines.splice(n, 1), i.lineChange.del.push(r)), e && t.forEach((o) => {
  11255. const h = s.points.findIndex(({ id: l }) => l === o);
  11256. ~h && s.lines.every(({ pointIds: l }) => !l.includes(o)) && (i.pointChange.del.push(s.points[h]), s.points.splice(h, 1));
  11257. }), { line: r, change: i }) : { change: i };
  11258. }, ch = (s, t) => {
  11259. const e = s.polygons.findIndex(({ id: i }) => t === i);
  11260. if (~e) {
  11261. const i = s.polygons[e];
  11262. s.polygons.splice(e, 1), i.lineIds.map(
  11263. (r) => wt(s, r)
  11264. ).forEach((r) => {
  11265. ai(s, r.pointIds);
  11266. });
  11267. }
  11268. }, Wa = (s, t, e = !0) => {
  11269. t = Array.isArray(t) ? t : [t];
  11270. const i = {
  11271. lineChange: {
  11272. del: [],
  11273. add: []
  11274. },
  11275. polygonChange: {
  11276. update: [],
  11277. del: []
  11278. },
  11279. pointChange: {
  11280. del: []
  11281. }
  11282. };
  11283. let n = 100;
  11284. for (let r = 0; r < s.polygons.length; r++) {
  11285. const a = s.polygons[r], o = a.lineIds;
  11286. let h = o.length, l;
  11287. for (let A = 0; A < h; A++) {
  11288. const u = oh(s, o), f = u[A], c = t.includes(f.pointIds[0]), d = t.includes(f.pointIds[1]);
  11289. if (!(c || d))
  11290. continue;
  11291. l = l || [...o];
  11292. let p = A, m = null;
  11293. if (d) {
  11294. let v = A + 1;
  11295. for (v; v < u.length; v++) {
  11296. const _ = u[v].pointIds[1];
  11297. if (!t.includes(_) && _ !== f.pointIds[0])
  11298. break;
  11299. }
  11300. if (v !== u.length) {
  11301. const _ = ue(s, [
  11302. f.pointIds[0],
  11303. u[v].pointIds[1]
  11304. ]);
  11305. i.lineChange.add.push(..._.change.lineChange.add), o[A] = _.line.id, m = _.line.id;
  11306. }
  11307. }
  11308. if (~p) {
  11309. const v = u[A].pointIds;
  11310. m ? o.splice(A, 1, m) : (o.splice(A, 1), u.splice(A, 1), h--, A--);
  11311. const _ = ai(
  11312. s,
  11313. v,
  11314. e
  11315. );
  11316. if (i.lineChange.del.push(..._.change.lineChange.del), i.pointChange.del.push(..._.change.pointChange.del), n-- < 0)
  11317. break;
  11318. }
  11319. }
  11320. if (l) {
  11321. const A = { ...a, lineIds: l };
  11322. a.lineIds.length === 0 ? (s.polygons.splice(r--, 1), i.polygonChange.del.push(A)) : i.polygonChange.update.push({
  11323. before: A,
  11324. after: a
  11325. });
  11326. }
  11327. }
  11328. return e && t.forEach((r) => {
  11329. if (!i.pointChange.del.some(({ id: a }) => a === r)) {
  11330. const a = s.points.findIndex(({ id: o }) => o === r);
  11331. ~a && (i.pointChange.del.push(s.points[a]), s.points.splice(a, 1));
  11332. }
  11333. }), i;
  11334. }, hr = (s, t, e) => {
  11335. const i = {
  11336. lineChange: {
  11337. del: [],
  11338. add: []
  11339. },
  11340. polygonChange: {
  11341. update: []
  11342. },
  11343. pointChange: {
  11344. add: [],
  11345. del: []
  11346. }
  11347. };
  11348. let n = null;
  11349. const r = t.map((a) => a.id);
  11350. if (r.includes(e))
  11351. return { addedPoints: n, change: i };
  11352. for (const a of s.polygons) {
  11353. let o;
  11354. for (let h = 0; h < a.lineIds.length; h++) {
  11355. const l = wt(s, a.lineIds[h]);
  11356. if (r.includes(l.pointIds[0]) && r.includes(l.pointIds[1])) {
  11357. o = o || [...a.lineIds], n = n || [
  11358. l.pointIds[0],
  11359. e,
  11360. l.pointIds[1]
  11361. ];
  11362. const A = ue(s, [
  11363. l.pointIds[0],
  11364. e
  11365. ]), u = ue(s, [
  11366. e,
  11367. l.pointIds[1]
  11368. ]);
  11369. i.lineChange.add.push(
  11370. ...A.change.lineChange.add,
  11371. ...u.change.lineChange.add
  11372. ), a.lineIds.splice(h, 1, A.line.id, u.line.id);
  11373. const f = ai(s, l.pointIds);
  11374. i.lineChange.del.push(...f.change.lineChange.del), i.pointChange.del.push(...f.change.pointChange.del);
  11375. }
  11376. }
  11377. o && i.polygonChange.update.push({
  11378. before: { ...a, lineIds: o },
  11379. after: a
  11380. });
  11381. }
  11382. return { addedPoints: n, change: i };
  11383. }, lr = (s, t, e) => {
  11384. const i = {
  11385. pointChange: {
  11386. del: []
  11387. },
  11388. lineChange: {
  11389. del: [],
  11390. add: [],
  11391. update: []
  11392. },
  11393. polygonChange: {
  11394. del: [],
  11395. update: []
  11396. }
  11397. }, n = [];
  11398. for (let r = 0; r < s.polygons.length; r++) {
  11399. const a = s.polygons[r];
  11400. let o;
  11401. for (const h of t) {
  11402. if (h === e)
  11403. break;
  11404. for (let l = 0; l < a.lineIds.length; l++) {
  11405. const A = wt(s, a.lineIds[l]);
  11406. let u = A.pointIds.indexOf(h);
  11407. if (!~u)
  11408. continue;
  11409. o = o || [...a.lineIds];
  11410. const f = [...A.pointIds];
  11411. if (f[u] = e, f[0] === f[1])
  11412. a.lineIds.splice(l, 1);
  11413. else {
  11414. const c = ue(s, f);
  11415. a.lineIds[l] = c.line.id, i.lineChange.del.push(...c.change.lineChange.add);
  11416. }
  11417. n.push(A.pointIds), l--;
  11418. }
  11419. if (o) {
  11420. const l = { ...a, lineIds: o };
  11421. a.lineIds.length === 0 ? (i.polygonChange.del.push(l), s.polygons.splice(r--, 1), console.log("del polygon")) : i.polygonChange.update.push({
  11422. before: l,
  11423. after: a
  11424. });
  11425. }
  11426. }
  11427. }
  11428. return n.forEach((r) => {
  11429. const a = ai(s, r);
  11430. i.lineChange.del.push(...a.change.lineChange.del), i.pointChange.del.push(...a.change.pointChange.del);
  11431. }), i;
  11432. }, Wd = (s, t, e, i) => {
  11433. const n = {
  11434. lineChange: {
  11435. update: [],
  11436. add: []
  11437. },
  11438. polygonChange: {
  11439. update: []
  11440. }
  11441. }, r = Hd(
  11442. s,
  11443. t.map(({ id: h }) => h),
  11444. !0
  11445. );
  11446. s.lines.forEach((h) => {
  11447. let l = -1;
  11448. if (r.includes(h) || !~(l = h.pointIds.indexOf(e)))
  11449. return;
  11450. const A = [...h.pointIds];
  11451. A[l] = i, n.lineChange.update.push({
  11452. before: { ...h, pointIds: [...h.pointIds] },
  11453. after: { ...h, pointIds: [...A] }
  11454. }), h.pointIds = A;
  11455. });
  11456. let a, o;
  11457. for (const h of s.polygons) {
  11458. let l;
  11459. for (let A = 0; A < h.lineIds.length; A++) {
  11460. if (!r.some(({ id: v }) => v === h.lineIds[A]))
  11461. continue;
  11462. const f = wt(s, h.lineIds[A]).pointIds.indexOf(e) === 1, c = ((f ? A + 1 : A - 1) + h.lineIds.length) % h.lineIds.length, d = wt(s, h.lineIds[c]);
  11463. if (f ? d.pointIds[0] === e : d.pointIds[1] === e)
  11464. continue;
  11465. l = l || [...h.lineIds];
  11466. let p;
  11467. if (f) {
  11468. if (!o) {
  11469. const { line: v, change: _ } = ue(s, [
  11470. e,
  11471. i
  11472. ]);
  11473. _.lineChange.add.push(..._.lineChange.add), o = v;
  11474. }
  11475. p = o;
  11476. } else {
  11477. if (!a) {
  11478. const { line: v, change: _ } = ue(s, [
  11479. i,
  11480. e
  11481. ]);
  11482. _.lineChange.add.push(..._.lineChange.add), a = v;
  11483. }
  11484. p = a;
  11485. }
  11486. const m = f ? A + 1 : A;
  11487. h.lineIds.splice(m, 0, p.id);
  11488. }
  11489. l && n.polygonChange.update.push({
  11490. before: { ...h, lineIds: l },
  11491. after: h
  11492. });
  11493. }
  11494. return { change: n };
  11495. }, _n = class _n extends ie {
  11496. constructor(t) {
  11497. t.zIndex = t.zIndex || je.zIndex, t.name = t.name || _n.namespace + t.attrib.id, super(t), this.actShapeFactory = ui;
  11498. }
  11499. setActShapeFactory(t) {
  11500. this.actShapeFactory = t;
  11501. }
  11502. initShape() {
  11503. return this.actShape = this.actShapeFactory(this.attrib, this), this.actShape.shape;
  11504. }
  11505. diffRedraw() {
  11506. const t = this.getCoords();
  11507. t.length ? this.actShape.setData(t) : console.error("line:", this.attrib, "找不到对应的点坐标", [
  11508. ...this.config.points
  11509. ]);
  11510. }
  11511. setConfig(t) {
  11512. this.config = t;
  11513. }
  11514. getCoords() {
  11515. const t = [], e = _t(this.config, this.attrib.pointIds);
  11516. return e.some((i) => !i) || e.forEach(({ x: i, y: n }, r) => {
  11517. t[r * 2] = i, t[r * 2 + 1] = n;
  11518. }), t;
  11519. }
  11520. initReactive() {
  11521. return super.initReactive("post");
  11522. }
  11523. mounted() {
  11524. super.mounted(), this.actShape.common(null);
  11525. }
  11526. };
  11527. _n.namespace = "line";
  11528. let Qt = _n;
  11529. const xn = class xn extends ie {
  11530. constructor(t) {
  11531. t.zIndex = t.zIndex || cn.zIndex, t.name = t.name || xn.namespace + t.attrib.id, super(t), this.actShapeFactory = Nn;
  11532. }
  11533. setActShapeFactory(t) {
  11534. this.actShapeFactory = t;
  11535. }
  11536. initShape() {
  11537. return this.actShape = this.actShapeFactory(this.attrib, this), this.actShape.shape;
  11538. }
  11539. diffRedraw() {
  11540. this.actShape.setData(this.getCoords());
  11541. }
  11542. setConfig(t) {
  11543. this.config = t;
  11544. }
  11545. getCoords() {
  11546. const t = [], e = ri(this.config, this.attrib.id);
  11547. return e.some((i) => !i) || e.forEach(({ x: i, y: n }, r) => {
  11548. t[r * 2] = i, t[r * 2 + 1] = n;
  11549. }), t;
  11550. }
  11551. mounted() {
  11552. super.mounted(), this.actShape.common(null);
  11553. }
  11554. };
  11555. xn.namespace = "polygon";
  11556. let Li = xn;
  11557. const bn = class bn extends ie {
  11558. constructor(t) {
  11559. t.name = t.name || bn.namespace + t.attrib.id, super(t);
  11560. }
  11561. initIncFactory() {
  11562. this.incLinesFactory = Pt(
  11563. Qt,
  11564. this,
  11565. (t) => {
  11566. t.setConfig(this.attrib);
  11567. }
  11568. ), this.incPointsFactory = Pt(
  11569. Tt,
  11570. this
  11571. ), this.incPolygonFactory = Pt(
  11572. Li,
  11573. this,
  11574. (t) => {
  11575. t.setConfig(this.attrib);
  11576. }
  11577. ), qt && (this.incLinesHelperFactory = Pt(
  11578. ar,
  11579. this,
  11580. (t) => {
  11581. t.setConfig(this.attrib);
  11582. }
  11583. ), this.incPointsHelperFactory = Pt(
  11584. or,
  11585. this
  11586. ));
  11587. }
  11588. init() {
  11589. this.initIncFactory(), super.init();
  11590. }
  11591. initShape() {
  11592. return new Nt({ id: this.name });
  11593. }
  11594. getRedrawLines() {
  11595. const t = [];
  11596. for (let e = this.attrib.lines.length - 1; e >= 0; e--) {
  11597. const i = this.attrib.lines[e];
  11598. let n = 0;
  11599. for (n = 0; n < e; n++) {
  11600. const r = this.attrib.lines[n];
  11601. if (r.pointIds.includes(i.pointIds[0]) && r.pointIds.includes(i.pointIds[1]))
  11602. break;
  11603. }
  11604. e === n && t.push(i);
  11605. }
  11606. return t;
  11607. }
  11608. diffRedraw() {
  11609. const t = this.getRedrawLines();
  11610. qt && (this.incLinesHelperFactory(t), this.incPointsHelperFactory(this.attrib.points));
  11611. const e = this.incPointsFactory(this.attrib.points), i = this.incLinesFactory(t), n = this.incPolygonFactory(
  11612. this.attrib.polygons
  11613. );
  11614. return { lineEntityInc: i, pointEntityInc: e, polygonEntityInc: n };
  11615. }
  11616. initReactive() {
  11617. return fe(
  11618. () => ({
  11619. pointIds: this.attrib.points.map(({ id: t }) => t),
  11620. lineIds: this.attrib.lines.map(({ id: t }) => t)
  11621. }),
  11622. this.diffRedraw.bind(this),
  11623. { immediate: !0, flush: "pre" }
  11624. );
  11625. }
  11626. };
  11627. bn.namespace = "whole-line";
  11628. let Ri = bn, jt;
  11629. const Yd = () => {
  11630. const s = {}, t = {}, e = (n, r) => {
  11631. s[n] = r, t[n] = r;
  11632. }, i = (n) => {
  11633. for (const r in s)
  11634. s[r] = t[r] / n;
  11635. };
  11636. return e("WHOLE_LINE_POINT_EQ_DIST", 1e-3), e("WHOLE_LINE_POINT_MERGE_DIST", 10), e("WHOLE_LINE_POINT_CHECK_DIST", 500), {
  11637. addConstant: e,
  11638. updateConstantScale: i,
  11639. use() {
  11640. jt = s;
  11641. },
  11642. unuse() {
  11643. jt === s && (jt = null);
  11644. }
  11645. };
  11646. }, Ze = (s, t) => {
  11647. const e = "id" in t && t.id ? t.id : sh(s);
  11648. if (s.points.some(({ id: i }) => i === e))
  11649. return t;
  11650. {
  11651. const i = {
  11652. ...t,
  11653. id: e
  11654. };
  11655. return s.points.push(i), i;
  11656. }
  11657. }, Xd = (s, t, e) => {
  11658. const i = pi(s, t), n = Ui(
  11659. i.flatMap(({ x: h, y: l }) => [h, l]),
  11660. [e.x, e.y]
  11661. ).point, r = Ze(s, {
  11662. ...e,
  11663. x: n[0],
  11664. y: n[1]
  11665. }), { change: a, addedPoints: o } = hr(
  11666. s,
  11667. i,
  11668. r.id
  11669. );
  11670. return a.pointChange.add.push(r), { change: a, addedPoints: o };
  11671. }, jd = (s, t, e) => {
  11672. const i = yi(s, t);
  11673. return qd(
  11674. s,
  11675. t,
  11676. i.lineIds[i.lineIds.length - 1],
  11677. e
  11678. );
  11679. }, qd = (s, t, e, i) => {
  11680. const n = yi(s, t), r = pi(s, e), a = Ze(s, i);
  11681. let { line: o, change: h } = ue(s, [
  11682. r[1].id,
  11683. a.id
  11684. ]);
  11685. return h = Si(h, {
  11686. pointChange: {
  11687. add: [a]
  11688. },
  11689. polygonChange: {
  11690. update: [
  11691. {
  11692. before: { ...n, lineIds: [...n.lineIds] },
  11693. after: {
  11694. ...n,
  11695. lineIds: [...n.lineIds, o.id]
  11696. }
  11697. }
  11698. ]
  11699. }
  11700. }), n.lineIds.push(o.id), { line: o, change: h };
  11701. }, Qd = (s) => {
  11702. let t = Math.max(...s.points.map((e) => Number(e.id) || 0));
  11703. return (e) => {
  11704. const i = {
  11705. ...e,
  11706. id: (++t).toString()
  11707. };
  11708. return s.points.push(i), i;
  11709. };
  11710. }, Kd = (s) => {
  11711. const t = (o) => [o[0].x, o[0].y, o[1].x, o[1].y].join("-"), e = {}, i = (o, h) => [t(o), t(h)].join("-"), n = {}, r = [], a = Qd(s);
  11712. return (o) => {
  11713. let h;
  11714. const l = t(o);
  11715. if (h = e[l])
  11716. return h;
  11717. if (h = e[t([o[1], o[0]])])
  11718. return h = [...h].reverse(), e[l] = h, h;
  11719. h = [];
  11720. const A = o;
  11721. for (const f of s.polygons) {
  11722. const c = $d(s, f.id);
  11723. for (const d of c) {
  11724. const p = i(o, d), m = {
  11725. polygonId: f.id,
  11726. line: d
  11727. };
  11728. if (p in n)
  11729. n[p] && h.push({
  11730. passive: m,
  11731. intersection: n[p]
  11732. });
  11733. else {
  11734. const v = d, _ = _o(
  11735. [A[0].x, A[0].y, A[1].x, A[1].y],
  11736. [v[0].x, v[0].y, v[1].x, v[1].y],
  11737. [vo.Intersect]
  11738. );
  11739. if (_) {
  11740. qt && console.log("join split", A[0].id, A[1].id, v[0].id, v[1].id);
  11741. let g = -1, y = Number.MAX_VALUE;
  11742. for (let b = 0; b < r.length; b++) {
  11743. const C = [r[b].x, r[b].y], w = Et(C, _);
  11744. y > w && (g = b, y = w);
  11745. }
  11746. let x;
  11747. y <= jt.WHOLE_LINE_POINT_EQ_DIST ? x = r[g] : (x = a({ x: _[0], y: _[1] }), console.log("add", x.id), r.push(x)), h.push({
  11748. passive: m,
  11749. intersection: x
  11750. }), n[p] = x;
  11751. } else
  11752. n[p] = null;
  11753. }
  11754. }
  11755. }
  11756. const u = [A[0].x, A[0].y];
  11757. return h.sort(
  11758. (f, c) => Et([f.intersection.x, f.intersection.y], u) - Et([c.intersection.x, c.intersection.y], u)
  11759. ), e[l] = h, h;
  11760. };
  11761. }, Ya = (s, t, e, i) => {
  11762. const n = s.map(({ id: h }) => h);
  11763. if (!(n.includes(e[0].id) && n.includes(e[1].id)))
  11764. return s;
  11765. let a = Number.MAX_VALUE, o = -1;
  11766. for (let h = 1; h < i.length; h++) {
  11767. const l = [i[h - 1], i[h]], A = NA(
  11768. [l[0].x, l[0].y, l[1].x, l[1].y],
  11769. [t.x, t.y]
  11770. );
  11771. A < a && (a = A, o = h);
  11772. }
  11773. return ~o ? s[0] === s[0] ? [i[o - 1], i[o]] : [i[o], i[o - 1]] : s;
  11774. }, Zd = (s, t) => {
  11775. const e = Kd(s), i = [];
  11776. for (let n = 1; n < t.length; n++) {
  11777. let r = 0;
  11778. for (; r < n && !(t[n].includes(t[r][0]) && t[n].includes(t[r][1])); r++)
  11779. ;
  11780. r !== n && t.splice(n--, 1);
  11781. }
  11782. for (const n of t) {
  11783. const r = e(n), a = n;
  11784. r.forEach((o) => {
  11785. const h = [...o.passive.line];
  11786. i.some((A) => {
  11787. if (o.intersection.id !== A.intersection.id)
  11788. return !1;
  11789. const u = [...A.passive], f = [...A.splitLine];
  11790. return f.includes(a[0]) && f.includes(a[1]) && u.includes(h[0]) && u.includes(h[1]) || u.includes(a[0]) && u.includes(a[1]) && f.includes(h[0]) && f.includes(h[1]);
  11791. }) || i.push({
  11792. splitLine: n,
  11793. passive: o.passive.line,
  11794. intersection: o.intersection
  11795. });
  11796. });
  11797. }
  11798. for (let n = 0; n < i.length; n++) {
  11799. const { passive: r, splitLine: a, intersection: o } = i[n], h = hr(
  11800. s,
  11801. a,
  11802. o.id
  11803. ).addedPoints, l = hr(
  11804. s,
  11805. r,
  11806. o.id
  11807. ).addedPoints;
  11808. if (qt && (h || console.error(
  11809. `添加 addedPointIds 失败,
  11810. 交点:`,
  11811. o.id,
  11812. `
  11813. 线段:`,
  11814. a
  11815. ), l || console.error(
  11816. `添加 passiveAddedPointIds 失败,
  11817. 交点:`,
  11818. o,
  11819. `
  11820. 线段:`,
  11821. r
  11822. )), !h && !l)
  11823. continue;
  11824. const A = h && _t(s, h), u = l && _t(s, l), f = (c, d) => {
  11825. const p = c;
  11826. return h && (c = Ya(
  11827. c,
  11828. d,
  11829. a,
  11830. A
  11831. )), l && (c = Ya(
  11832. c,
  11833. d,
  11834. r,
  11835. u
  11836. )), qt && p !== c && console.log(
  11837. "fix line",
  11838. p.map(({ id: m }) => m),
  11839. `
  11840. after: ,`,
  11841. c.map(({ id: m }) => m)
  11842. ), c;
  11843. };
  11844. for (let c = n + 1; c < i.length; c++) {
  11845. const d = i[c];
  11846. d.passive = f(d.passive, d.intersection), d.splitLine = f(d.splitLine, d.intersection);
  11847. }
  11848. }
  11849. }, $s = (s, t) => Zd(
  11850. s,
  11851. lh(s, t).reduce((e, i) => (e.push(...i.lines), e), [])
  11852. ), Jd = (s, t) => {
  11853. const e = [t], i = s.points.filter(
  11854. (n) => !e.includes(n) && Et([n.x, n.y], [t.x, t.y]) < jt.WHOLE_LINE_POINT_MERGE_DIST
  11855. );
  11856. return i.length ? i.length > 1 ? {
  11857. main: t,
  11858. merges: i,
  11859. mergeAfterPosition: [t.x, t.y]
  11860. } : {
  11861. main: i[0],
  11862. merges: [t],
  11863. mergeAfterPosition: [i[0].x, i[0].y]
  11864. } : null;
  11865. }, tu = (s, t) => {
  11866. const e = Jd(
  11867. s,
  11868. Pe(s, t)
  11869. );
  11870. if (!e)
  11871. return;
  11872. const i = lr(
  11873. s,
  11874. e.merges.map(({ id: r }) => r),
  11875. e.main.id
  11876. ), n = Pe(s, e.main.id);
  11877. return n && (n.x = e.mergeAfterPosition[0], n.y = e.mergeAfterPosition[1]), {
  11878. info: e,
  11879. change: i
  11880. };
  11881. }, eu = (s, t, e, i = [10, 170]) => {
  11882. const n = {}, r = t.pointIds, a = _t(s, [r[0], r[1]]), o = ce([
  11883. a[0].x,
  11884. a[0].y,
  11885. a[1].x,
  11886. a[1].y
  11887. ]), h = _t(s, [r[1], r[0]]), l = ce([
  11888. h[0].x,
  11889. h[0].y,
  11890. h[1].x,
  11891. h[1].y
  11892. ]), A = (u, f) => {
  11893. let c = !0;
  11894. const d = r[f];
  11895. if (!n[d])
  11896. n[d] = {};
  11897. else
  11898. return c = !1, { ...n[d], isFirst: c };
  11899. const p = ah(s, d).filter(
  11900. (F) => !(F.pointIds.includes(r[0]) && F.pointIds.includes(r[1]))
  11901. ), m = [], v = f === 0 ? o : l;
  11902. let _ = Number.MAX_VALUE, g, y = null, x = -Number.MAX_VALUE, b, C = null;
  11903. for (let { pointIds: F, id: L } of p) {
  11904. F = [
  11905. r[f],
  11906. ...F.filter((G) => G !== r[f])
  11907. ];
  11908. const I = _t(s, F), z = ce([
  11909. I[0].x,
  11910. I[0].y,
  11911. I[1].x,
  11912. I[1].y
  11913. ]);
  11914. m.push(z);
  11915. const T = Xe(v, z);
  11916. T > 0 ? T < _ && (_ = T, g = L, y = z) : T > x && (x = T, b = L, C = z);
  11917. }
  11918. let w = null, E = null, S = null;
  11919. !y || !C ? (w = y || C, S = y ? g : b, E = y ? _ : x) : Math.abs(Xe(u, y)) < Math.abs(Xe(u, C)) ? (w = y, S = g, E = _) : (w = C, S = b, E = x);
  11920. let P = !1, k = Math.abs(Se.radToDeg(E));
  11921. if (w !== null && k > i[1] || k < i[0])
  11922. console.log(
  11923. "夹角不在范围,分割",
  11924. S,
  11925. f === 0 ? a : h,
  11926. k
  11927. ), S = null, w = pr(w), P = !0;
  11928. else if (p.length > 1) {
  11929. const F = w;
  11930. for (let L = 0; L < p.length; L++) {
  11931. if (F === m[L])
  11932. continue;
  11933. const I = (Xe(F, m[L]) + Math.PI) % Math.PI;
  11934. if (Ot(I, 3) > 0) {
  11935. console.log("方向不同,分割"), P = !0;
  11936. break;
  11937. }
  11938. }
  11939. }
  11940. return n[d].refDire = w, n[d].lineDire = v, n[d].id = S, n[d].split = P, n[d].isFirst = c, n[d];
  11941. };
  11942. return (u) => {
  11943. const f = new X(u[0], u[1]).normalize().toArray(), c = [
  11944. A(f, 0),
  11945. A(f, 1)
  11946. ], d = [
  11947. [e[0][0] + u[0], e[0][1] + u[1]],
  11948. [e[1][0] + u[0], e[1][1] + u[1]]
  11949. ], p = _t(s, t.pointIds);
  11950. if (c[0].refDire || c[1].refDire) {
  11951. const m = [], v = c.map(
  11952. ({ refDire: S }) => S === null ? c[0].refDire || c[1].refDire : S
  11953. );
  11954. for (let S = 0; S < c.length; S++) {
  11955. const P = v[S], k = c[S].split && c[S].isFirst, F = Ke(P, e[S], 10);
  11956. if (k) {
  11957. const L = sh(s);
  11958. s.points.push({
  11959. ...p[S],
  11960. id: L
  11961. }), Wd(
  11962. s,
  11963. a,
  11964. t.pointIds[S],
  11965. L
  11966. );
  11967. }
  11968. m[S] = Ui(F, d[S]).point;
  11969. }
  11970. const _ = Et(m[0], e[0]) < Et(m[1], e[1]), g = _ ? o : l, y = _ ? m[0] : m[1], x = _ ? v[1] : v[0], b = _ ? e[1] : e[0], C = Ke(g, y, 10), w = Ke(x, b, 10), E = _o(C, w);
  11971. _ ? (d[0] = y, d[1] = E) : (d[1] = y, d[0] = E);
  11972. }
  11973. p[0].x = d[0][0], p[0].y = d[0][1], p[1].x = d[1][0], p[1].y = d[1][1];
  11974. };
  11975. }, Ws = (s) => {
  11976. for (let e = 0; e < s.lines.length; e++) {
  11977. const i = s.lines[e], n = _t(s, i.pointIds);
  11978. if (Ot(
  11979. Et([n[0].x, n[0].y], [n[1].x, n[1].y]),
  11980. 4
  11981. ) !== 0)
  11982. continue;
  11983. const a = lr(s, [n[1].id], n[0].id);
  11984. e = Math.max(e - a.lineChange.del.length, 0);
  11985. }
  11986. const t = [];
  11987. for (let e = 0; e < s.polygons.length; e++) {
  11988. const i = s.polygons[e];
  11989. for (let n = 0; n < i.lineIds.length; n++) {
  11990. const r = wt(s, i.lineIds[n]), a = (n + 1) % i.lineIds.length, o = wt(s, i.lineIds[a]);
  11991. if (r.pointIds[0] === o.pointIds[1] && r.pointIds[1] === o.pointIds[0]) {
  11992. t.push(_t(s, r.pointIds)), n > a ? (i.lineIds.splice(n, 1), i.lineIds.splice(a, 1)) : (i.lineIds.splice(n, 2), n -= 1), ai(s, r.pointIds), ai(s, o.pointIds);
  11993. continue;
  11994. }
  11995. const h = _t(s, r.pointIds);
  11996. Et(
  11997. [h[0].x, h[0].y],
  11998. [h[1].x, h[1].y]
  11999. ) < jt.WHOLE_LINE_POINT_MERGE_DIST && (lr(s, [h[0].id], h[1].id), n--);
  12000. }
  12001. i.lineIds.length === 0 && (console.log("del polygon"), s.polygons.splice(e--, 1));
  12002. }
  12003. t.forEach((e) => {
  12004. if (e[0].id === e[1].id)
  12005. return;
  12006. const i = rh(s), n = nh(s);
  12007. e = e.map((r) => s.points.some(({ id: a }) => a === r.id) ? r : Ze(s, { x: r.x, y: r.y })), s.lines.push({
  12008. id: n,
  12009. pointIds: e.map(({ id: r }) => r)
  12010. }), s.polygons.push({
  12011. id: i,
  12012. lineIds: [n]
  12013. });
  12014. });
  12015. }, iu = ({
  12016. tree: s,
  12017. position: t,
  12018. refPointName: e = "adsord-point",
  12019. exclusionIds: i = [],
  12020. radius: n = 10
  12021. }) => {
  12022. const r = s.stage.find(`.${e}`).filter((a) => !i.includes(a.id())).map((a) => {
  12023. const o = a.position();
  12024. return [o.x, o.y];
  12025. });
  12026. return nu({ refPositions: r, radius: n, position: t });
  12027. }, nu = ({
  12028. position: s,
  12029. radius: t = 10,
  12030. refPositions: e
  12031. }) => {
  12032. let i = null, n = Number.MAX_VALUE;
  12033. for (const r of e) {
  12034. const a = Et(r, s);
  12035. a < t && a < n && (n = a, i = r);
  12036. }
  12037. return i;
  12038. }, wi = [0, 90, 180, 270, 360], dh = ({
  12039. position: s,
  12040. refLines: t,
  12041. angle: e = 3
  12042. }) => {
  12043. let i = null, n = null, r = !1;
  12044. for (const a of t) {
  12045. const h = [
  12046. [a[0], a[1]],
  12047. [a[2], a[3]]
  12048. ].map((u) => (Se.radToDeg(
  12049. TA(a, [...u, ...s])
  12050. ) + 360) % 360);
  12051. let l = 0, A = 0;
  12052. for (l = 0; l < h.length; l++) {
  12053. for (A = 0; A < wi.length; A++) {
  12054. const u = wi[A];
  12055. if (h[l] >= u - e && h[l] <= u + e)
  12056. break;
  12057. }
  12058. if (A !== wi.length)
  12059. break;
  12060. }
  12061. if (A !== wi.length || l !== h.length) {
  12062. n = a, i = wi[A];
  12063. const u = DA(
  12064. ce(n),
  12065. Se.degToRad(i)
  12066. ), f = Et([n[0], n[1]], s) > Et([n[2], n[3]], s) ? [n[2], n[3]] : [n[0], n[1]];
  12067. n = Ke(u, f, 10), s = Ui(n, s).point, r = !0;
  12068. }
  12069. }
  12070. if (r)
  12071. return s;
  12072. }, su = ({
  12073. position: s,
  12074. angle: t,
  12075. points: e
  12076. }) => {
  12077. if (e != null && e.length && e.length === 1) {
  12078. const i = e[0], n = [
  12079. [i[0] - 1, i[1], i[0] + 1, i[1]],
  12080. [i[0], i[1] - 1, i[0], i[1] + 1]
  12081. ];
  12082. return dh({ position: s, refLines: n, angle: t });
  12083. }
  12084. }, Xa = ({
  12085. position: s,
  12086. points: t,
  12087. angle: e
  12088. }) => {
  12089. if (!(t != null && t.length))
  12090. return;
  12091. const i = t.slice(0, 2).flatMap((o) => o), n = t.slice(t.length - 2, t.length).flatMap((o) => o), r = [
  12092. i,
  12093. // createLineByDire(getVerticaLineDire(last), [last[2], last[3]], 10),
  12094. Ke(IA(n), [n[2], n[3]], 10)
  12095. ];
  12096. let a;
  12097. if (a = dh({
  12098. position: s,
  12099. refLines: r,
  12100. angle: e
  12101. }))
  12102. return a;
  12103. }, uh = (s) => {
  12104. const t = s.position || s.tree.getRealFromStage(s.pixel);
  12105. let e;
  12106. if (e = iu({ ...s, position: t }))
  12107. return e;
  12108. if (e = su({ ...s, position: t }))
  12109. return e;
  12110. if (e = Xa({ ...s, position: t }))
  12111. return e;
  12112. if (s.pointsArray) {
  12113. for (let i = 0; i < s.pointsArray.length; i++)
  12114. if (e = Xa({
  12115. ...s,
  12116. position: t,
  12117. points: s.pointsArray[i]
  12118. }))
  12119. return e;
  12120. }
  12121. return t;
  12122. }, ja = ({
  12123. tree: s,
  12124. config: t,
  12125. polygonId: e,
  12126. pointAttribFactory: i,
  12127. quotePoint: n,
  12128. canOper: r,
  12129. autoAdd: a,
  12130. adsorbRadius: o,
  12131. canDelPoint: h,
  12132. closeAutoQuit: l,
  12133. changePolygon: A,
  12134. autoClose: u
  12135. }) => {
  12136. i = i || ((b) => ({
  12137. x: b[0],
  12138. y: b[1]
  12139. }));
  12140. const f = (b) => {
  12141. if (b)
  12142. return t.polygons.find(({ id: C }) => C === b);
  12143. {
  12144. const C = rh(t);
  12145. return t.polygons.push({
  12146. id: C,
  12147. lineIds: []
  12148. }), t.polygons[t.polygons.length - 1];
  12149. }
  12150. };
  12151. let c, d = !1, p = null, m = !0;
  12152. const v = (b) => {
  12153. if (c = f(b), !c)
  12154. throw `${b}的多边形不存在!`;
  12155. A && A(c.id), e = c.id, d = !b, p = null, m = a || c.lineIds.length < 2;
  12156. };
  12157. v(e);
  12158. const _ = () => {
  12159. const b = t.polygons.indexOf(c);
  12160. ~b && t.polygons.splice(b, 1);
  12161. }, g = (b) => {
  12162. let C = {
  12163. lineChange: {
  12164. del: [],
  12165. update: [],
  12166. add: []
  12167. },
  12168. polygonChange: {
  12169. add: [],
  12170. update: [],
  12171. del: []
  12172. },
  12173. pointChange: {
  12174. add: [],
  12175. del: []
  12176. }
  12177. };
  12178. const w = So(b.target, (T) => {
  12179. const G = T.id();
  12180. return G.includes(Qt.namespace) || G.includes(Tt.namespace);
  12181. });
  12182. let E = w && s.find(w.id());
  12183. const S = [b.evt.offsetX, b.evt.offsetY];
  12184. if (E instanceof Qt && (!r || r(E, b.target)) && c.lineIds.includes(E.attrib.id)) {
  12185. const { change: T } = Xd(
  12186. t,
  12187. E.attrib.id,
  12188. i(s.getRealFromStage(S))
  12189. );
  12190. return { change: Si(C, T), isClose: !1 };
  12191. }
  12192. let P;
  12193. const k = ri(t, c.id);
  12194. let F;
  12195. for (; ; ) {
  12196. if (E instanceof Tt) {
  12197. if (r && !r(E, b.target))
  12198. return { change: C, isClose: !1 };
  12199. if (F = typeof n == "function" ? n(E.attrib) : !!n, P = F ? E.attrib : { ...E.attrib }, c.id === p)
  12200. return { change: C, isClose: !1 };
  12201. } else {
  12202. let T;
  12203. if (o) {
  12204. const R = k.map(({ x: N, y: q }) => [N, q]);
  12205. if (p) {
  12206. const N = Pe(t, p);
  12207. R.push([N.x, N.y]);
  12208. }
  12209. T = uh({
  12210. tree: s,
  12211. pixel: S,
  12212. radius: o,
  12213. points: [...R].reverse()
  12214. });
  12215. } else
  12216. T = s.getRealFromStage(S);
  12217. const G = Mo(s);
  12218. let H = 0;
  12219. for (; H < G.length; H++)
  12220. if (G[H] instanceof Tt) {
  12221. const R = G[H];
  12222. if (Ot(R.attrib.x - T[0], 4) === 0 && Ot(R.attrib.y - T[1], 4) === 0) {
  12223. E = s.children[H];
  12224. break;
  12225. }
  12226. }
  12227. if (H !== G.length) {
  12228. E = G[H];
  12229. continue;
  12230. }
  12231. P = i(T);
  12232. }
  12233. break;
  12234. }
  12235. const L = k.findIndex(({ id: T }) => T === P.id), I = L === 0 && (!u || k.length >= 3);
  12236. if (L >= 0 && !I) {
  12237. const T = Wa(
  12238. t,
  12239. P.id,
  12240. !h || h(P, b)
  12241. );
  12242. if (C = Si(C, T), c.lineIds.length === 0) {
  12243. ch(t, c.id);
  12244. const G = T.pointChange.del.find(
  12245. ({ id: R }) => R !== P.id
  12246. );
  12247. v(null);
  12248. const H = Ze(t, { ...G, id: void 0 });
  12249. p = H.id, C.pointChange.add.push(H);
  12250. }
  12251. return { change: C, isClose: I };
  12252. }
  12253. F || delete P.id;
  12254. const z = (T) => (!l && I && v(null), { change: T, isClose: I });
  12255. if (c.lineIds.length > 0)
  12256. if (d) {
  12257. const T = jd(
  12258. t,
  12259. e,
  12260. P
  12261. ).change;
  12262. return z(Si(C, T));
  12263. } else
  12264. return m ? (v(null), g(b)) : { change: C, isClose: I };
  12265. else if (p) {
  12266. const [T] = Gt(s.stage, [4, 4], !0), G = Pe(t, p);
  12267. if (!(Math.abs(P.x - G.x) > T || Math.abs(P.y - G.y) > T))
  12268. return z(C);
  12269. const { line: H, change: R } = ue(t, [
  12270. p,
  12271. Ze(t, P).id
  12272. ]);
  12273. return C = Si(C, R, {
  12274. polygonChange: {
  12275. update: [
  12276. {
  12277. before: { ...c, lineIds: [...c.lineIds] },
  12278. after: {
  12279. ...c,
  12280. lineIds: [...c.lineIds, H.id]
  12281. }
  12282. }
  12283. ]
  12284. },
  12285. pointChange: {
  12286. add: [P]
  12287. }
  12288. }), c.lineIds.push(H.id), p = null, z(C);
  12289. } else {
  12290. const T = Ze(t, P);
  12291. return p = T.id, C.pointChange.add.push(T), z(C);
  12292. }
  12293. };
  12294. return {
  12295. continuous: g,
  12296. end: () => {
  12297. c.lineIds.length === 0 && (p && Wa(t, p), _()), A && A(null);
  12298. },
  12299. getStatus: () => ({
  12300. newMode: d,
  12301. polyginAttribId: c.id,
  12302. prevId: p,
  12303. config: t
  12304. }),
  12305. setStatus: (b) => {
  12306. d = b.newMode, c = b.config.polygons.find(
  12307. ({ id: C }) => C === b.polyginAttribId
  12308. ), e = c.id, p = b.prevId, t = b.config;
  12309. }
  12310. };
  12311. }, ru = "data:image/x-icon;base64,AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAgAAAAH///8BAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAB////AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8BVVVVAwAAAAYAAAAIAAAABQAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAYAAAANAAAAFwAAADUAAAAUAAAACwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAAAwAAAAMAAAAHAAAAEQAAACIAAACVAAAA8gAAAFIAAAAbAAAADH9/fwIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAM8AAAD/AAAAjwAAAAAAAAABAAAABAAAAAkSEhIOAAAAEgAAABMAAAASDg4OEgAAABcAAAAnAAAAmgAAAP8wMDD/AAAA8gAAAFcAAAAcAAAADH9/fwIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACPICAg/5+fn/8AAAD/AAAAQhwcHAkAAAASAAAAHgAAACkAAABfAAAAYQMDA1MFBQUvAAAANQAAAJ4AAAD/f39///////9fX1//AAAA8gAAAFcAAAAcAAAAC1VVVQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAATwAAAL9gYGD//////wAAAP8AAACkAAAAUgQEBEQAAACyAAAA8gAAAP8AAAD/AAAA/wAAAPMAAADHAAAA/39/f/////////////////9fX1//AAAA8gAAAFcAAAAcAAAAC1VVVQMAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAN8AAAD/AAAA/2BgYP//////AAAA/wAAAP8AAAD/AAAA/yAgIP+fn5//z8/P/9/f3//f39//j4+P/09PT/9/f3////////////////////////////9fX1//AAAA8gMDA1cJCQkcGRkZCgAAAAMAAAAAAAAAAAAAAAAAAABgAAAA/9/f3////////////////////////////39/f/8AAAD///////////////////////////////////////////////////////////////////////////9fX1//AAAA8gAAAFMNDQ0TAAAABQAAAAAAAAAAAAAAAAAAACAAAAD/QEBA/2BgYP+fn5///////2BgYP9gYGD/ICAg/0BAQP////////////////////////////////////////////////////////////////////////////////8wMDD/AAAA8gAAACYAAAAHAAAAAQAAAAAAAAAAAAAAAAAAAEAAAACgAAAA4GBgYP//////AAAA/zAwMP9vb2//39/f////////////////////////////////////////////////////////////////////////////gICA/wAAAP8AAACWAAAAFwAAAAcAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAChUFBQ/9/f3/8AAAD/n5+f/////////////////////////////////////////////////////////////////////////////////4CAgP8AAAD/AAAAmgAAACIAAAANAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAFsAAAD/AAAA/yAgIP/v7+////////////////////////////////////////////////////////////////////////////+Pj4//AAAA/wAAAJ0AAAAmAAAAEDMzMwUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAIAAAAHAAAAJoQEBD/39/f///////////////////////v7+//n5+f/39/f/+/v7///////////////////////////////////////z8/P/8AAADSAAAAMwwMDBYAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA4GBgYoAAAA8n9/f///////////////////////39/f/yAgIP8AAAD/AAAA/wAAAP+AgID/////////////////////////////////n5+f/wAAAPMAAAAtAAAAEAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFDAwMFgAAAGQAAAD/v7+///////////////////////9PT0//AAAA/wAAAP8AAAD/AAAA/wAAAP+/v7/////////////////////////////Pz8//AAAA/wAAAFIODg4SAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhwcHAkAAAAeAAAAp0BAQP///////////////////////////x8fH/8AAAD/AAAA/wAAAP8AAAD/AAAA/39/f////////////////////////////9/f3/8AAAD/AAAAYA4ODhIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAADgYGBikAAADyf39/////////////////////////////MDAw/wAAAP8AAAD/AAAA/wAAAP8AAAD/j4+P////////////////////////////39/f/wAAAP8AAABSAAAAEQAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAADMzMwUAAAAUAAAAVwAAAP+/v7////////////////////////////9fX1//AAAA/wAAAP8AAAD/AAAA/yAgIP/v7+////////////////////////////+Pj4//AAAA8wAAADQAAAAOAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABKioqBgAAABoAAACMEBAQ////////////////////////////gICA/wAAAP9gYGD/Pz8//x8fH/9gYGD/39/f////////////////////////////7+/v/yAgIP8AAACnAAAAHgAAAAkAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAALAAAAIgAAAM1gYGD//////////////////////4CAgP8AAAD/f39///////////////////////////////////////////////////////9wcHD/AAAA8wAAAEUAAAASAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxAQEBAGBgYqAAAA84+Pj/////////////////+AgID/AAAA/39/f///////////////////////////////////////////////////////gICA/wAAAP8AAAB9AAAAGxwcHAkAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAFAAAAEoAAAD/z8/P////////////gICA/wAAAP9/f3//////////////////////////////////////////////////39/f/19fX/8AAAD/AAAAlgAAAB4AAAAMAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAZAAAAfxAQEP///////////4CAgP8AAAD/f39/////////////////////////////////////////////39/f/4+Pj/8gICD/AAAA5gAAAGQAAAAdAAAADQAAAAT///8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAACAAAAB4AAACnMDAw//////+AgID/AAAA/39/f///////////////////////////////////////39/f/19fX/8gICD/AAAA5wAAAJkAAAA2CwsLGBcXFwsAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAMAAAAJAAAAM5gYGD/gICA/wAAAP9/f3/////////////////////////////Pz8//f39//zAwMP8AAAD/AAAA5gAAAIAAAABDAAAAHRAQEBAAAAAIAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf39/AgAAAA4AAAApAAAA8yAgIP8AAAD/f39/////////////z8/P/4+Pj/9QUFD/ICAg/wAAAP8AAADmAAAAswAAAGQAAAAoCQkJGwAAABEgICAIAAAAAwAAAAL///8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVVUDAAAADwAAADcAAAD/AAAA/yAgIP9vb2//QEBA/wAAAP8AAAD/AAAA8wAAAM0AAACMAAAAVgAAACgAAAAeAAAAFgAAAA4AAAAIAAAAA////wEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAOAAAASgAAAP8AAAD/AAAA8wAAAM0AAACnAAAAfwAAAFYAAAArAAAAIwAAABsAAAAUAAAADgAAAAkAAAAEAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAgAAAAkAAAAVwUFBTgGBgYqBwcHJAAAAB4KCgoZDQ0NEwAAAA8XFxcLJCQkBwAAAAUAAAACAAAAAv///wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAgSEhIOERERDwAAAA4AAAALAAAACCoqKgZAQEAEAAAAAwAAAAH///8BAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wAAAAABAAAAAgAAAAMAAAADAAAAAwAAAAIAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////////////7/+f/8f/D//Hxgf/AAAD/gAAAf4AAAD/wAAA/8AAAf/AAAP/4AAH/+AAB//AAAP/wAAD/8AAA/+AAAf/gAAH/4AAD/+AAA//AAAf/wAAf/8AAf//AAf//wA///4D///+f///////////////////8=", au = "data:image/x-icon;base64,AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAgAAAAH///8BAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAB////AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8BVVVVAwAAAAYAAAAIAAAABQAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAYAAAANAAAAFwAAADUAAAAUAAAACwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAAAwAAAAMAAAAHAAAAEQAAACIAAACVAAAA8gAAAFIAAAAbAAAADH9/fwIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAABAAAAAkSEhIOAAAAEgAAABMAAAASDg4OEgAAABcAAAAnAAAAmgAAAP8wMDD/AAAA8gAAAFcAAAAcAAAADH9/fwIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAxwcHAkAAAASAAAAHgAAACkAAABfAAAAYQMDA1MFBQUvAAAANQAAAJ4AAAD/f39///////9fX1//AAAA8gAAAFcAAAAcAAAAC1VVVQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAATwAAAF8AAABfAAAAYAAAAGIAAABmAAAAUgQEBEQAAACyAAAA8gAAAP8AAAD/AAAA/wAAAPMAAADHAAAA/39/f/////////////////9fX1//AAAA8gAAAFcAAAAcAAAAC1VVVQMAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAN8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/yAgIP+fn5//z8/P/9/f3//f39//j4+P/09PT/9/f3////////////////////////////9fX1//AAAA8gMDA1cJCQkcGRkZCgAAAAMAAAAAAAAAAAAAAAAAAABgAAAA/9/f3////////////////////////////39/f/8AAAD///////////////////////////////////////////////////////////////////////////9fX1//AAAA8gAAAFMNDQ0TAAAABQAAAAAAAAAAAAAAAAAAACAAAAD/QEBA/2BgYP9gYGD/YGBg/2BgYP9gYGD/ICAg/0BAQP////////////////////////////////////////////////////////////////////////////////8wMDD/AAAA8gAAACYAAAAHAAAAAQAAAAAAAAAAAAAAAAAAAEAAAACgAAAAogAAAKcAAAC+AAAA/zAwMP9vb2//39/f////////////////////////////////////////////////////////////////////////////gICA/wAAAP8AAACWAAAAFwAAAAcAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAKAAAAHgAAAJoQEBD/7+/v/////////////////////////////////////////////////////////////////////////////////4CAgP8AAAD/AAAAmgAAACIAAAANAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAABIAAAA5AAAA839/f/////////////////////////////////////////////////////////////////////////////////+Pj4//AAAA/wAAAJ0AAAAmAAAAEDMzMwUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAIAAAAHAAAAJoQEBD/7+/v///////////////////////v7+//n5+f/39/f/+/v7///////////////////////////////////////z8/P/8AAADSAAAAMwwMDBYAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA4GBgYoAAAA8n9/f///////////////////////39/f/yAgIP8AAAD/AAAA/wAAAP+AgID/////////////////////////////////n5+f/wAAAPMAAAAtAAAAEAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFDAwMFgAAAGQAAAD/v7+///////////////////////9PT0//AAAA/wAAAP8AAAD/AAAA/wAAAP+/v7/////////////////////////////Pz8//AAAA/wAAAFIODg4SAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhwcHAkAAAAeAAAAp0BAQP///////////////////////////x8fH/8AAAD/AAAA/wAAAP8AAAD/AAAA/39/f////////////////////////////9/f3/8AAAD/AAAAYA4ODhIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAADgYGBikAAADyf39/////////////////////////////MDAw/wAAAP8AAAD/AAAA/wAAAP8AAAD/j4+P////////////////////////////39/f/wAAAP8AAABSAAAAEQAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAADMzMwUAAAAUAAAAVwAAAP+/v7////////////////////////////9fX1//AAAA/wAAAP8AAAD/AAAA/yAgIP/v7+////////////////////////////+Pj4//AAAA8wAAADQAAAAOAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABKioqBgAAABoAAACMEBAQ////////////////////////////gICA/wAAAP9gYGD/Pz8//x8fH/9gYGD/39/f////////////////////////////7+/v/yAgIP8AAACnAAAAHgAAAAkAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAALAAAAIgAAAM1gYGD//////////////////////4CAgP8AAAD/f39///////////////////////////////////////////////////////9wcHD/AAAA8wAAAEUAAAASAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxAQEBAGBgYqAAAA84+Pj/////////////////+AgID/AAAA/39/f///////////////////////////////////////////////////////gICA/wAAAP8AAAB9AAAAGxwcHAkAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAFAAAAEoAAAD/z8/P////////////gICA/wAAAP9/f3//////////////////////////////////////////////////39/f/19fX/8AAAD/AAAAlgAAAB4AAAAMAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAZAAAAfxAQEP///////////4CAgP8AAAD/f39/////////////////////////////////////////////39/f/4+Pj/8gICD/AAAA5gAAAGQAAAAdAAAADQAAAAT///8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAACAAAAB4AAACnMDAw//////+AgID/AAAA/39/f///////////////////////////////////////39/f/19fX/8gICD/AAAA5wAAAJkAAAA2CwsLGBcXFwsAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAMAAAAJAAAAM5gYGD/gICA/wAAAP9/f3/////////////////////////////Pz8//f39//zAwMP8AAAD/AAAA5gAAAIAAAABDAAAAHRAQEBAAAAAIAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf39/AgAAAA4AAAApAAAA8yAgIP8AAAD/f39/////////////z8/P/4+Pj/9QUFD/ICAg/wAAAP8AAADmAAAAswAAAGQAAAAoCQkJGwAAABEgICAIAAAAAwAAAAL///8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVVUDAAAADwAAADcAAAD/AAAA/yAgIP9vb2//QEBA/wAAAP8AAAD/AAAA8wAAAM0AAACMAAAAVgAAACgAAAAeAAAAFgAAAA4AAAAIAAAAA////wEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAOAAAASgAAAP8AAAD/AAAA8wAAAM0AAACnAAAAfwAAAFYAAAArAAAAIwAAABsAAAAUAAAADgAAAAkAAAAEAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAgAAAAkAAAAVwUFBTgGBgYqBwcHJAAAAB4KCgoZDQ0NEwAAAA8XFxcLJCQkBwAAAAUAAAACAAAAAv///wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAgSEhIOERERDwAAAA4AAAALAAAACCoqKgZAQEAEAAAAAwAAAAH///8BAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wAAAAABAAAAAgAAAAMAAAADAAAAAwAAAAIAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////+f////D///xgf/AAAD/gAAAf4AAAD/8AAA//AAAf/wAAP/4AAH/+AAB//AAAP/wAAD/8AAA/+AAAf/gAAH/4AAD/+AAA//AAAf/wAAf/8AAf//AAf//wA///4D///+f///////////////////8=", ou = (s) => {
  12312. const t = () => JSON.parse(JSON.stringify(s.config)), e = ja({ ...s }), i = ja({
  12313. ...s,
  12314. closeAutoQuit: !0,
  12315. changePolygon: void 0,
  12316. config: t()
  12317. }), n = () => {
  12318. const y = e.getStatus();
  12319. i.setStatus({
  12320. ...y,
  12321. config: t()
  12322. });
  12323. }, r = s.tree.stage, a = ei();
  12324. let o = !1;
  12325. const h = () => {
  12326. o = !0;
  12327. }, l = (y) => {
  12328. if (o)
  12329. return;
  12330. n();
  12331. const { change: x } = i.continuous(y), { config: b } = i.getStatus();
  12332. a.value = {
  12333. change: x,
  12334. config: b
  12335. };
  12336. }, A = (y) => {
  12337. o = !1, l(y);
  12338. };
  12339. let u, f;
  12340. const c = (y) => {
  12341. const [x] = Gt(r, [4, 4], !0);
  12342. u && Math.abs(y.evt.offsetX - u.x) < x && Math.abs(y.evt.offsetY - u.y) < x || (f = setTimeout(() => {
  12343. const { isClose: b, change: C } = e.continuous(y);
  12344. n(), b && s.closeAutoQuit && g(), s.onChange && s.onChange(C), u = null;
  12345. }));
  12346. }, d = (y) => {
  12347. const x = ao(y);
  12348. y.evt.offsetX = x.offsetX, y.evt.offsetY = x.offsetY;
  12349. }, p = (y) => {
  12350. y.evt.preventDefault(), d(y), l(y), !a.value.change.lineChange.add.length && !a.value.change.lineChange.del.length && (v(y), u = {
  12351. x: y.evt.offsetX,
  12352. y: y.evt.offsetY
  12353. });
  12354. }, m = (y) => {
  12355. y.evt.preventDefault(), d(y), l(y);
  12356. }, v = (y) => {
  12357. y.evt.preventDefault(), d(y), c(y), a.value = void 0;
  12358. }, _ = (y) => {
  12359. clearTimeout(f), y instanceof KeyboardEvent ? y.key === "Escape" && g() : (g(), y.preventDefault());
  12360. };
  12361. let g = () => {
  12362. hn ? (r.off("touchstart.editPolygonsMode", p), r.off("touchmove.editPolygonsMode", m), r.off("touchend.editPolygonsMode", v)) : (r.off("click.editPolygonsMode", c), r.off("mousedown.editPolygonsMode", h), r.off("mousemove.editPolygonsMode", l), r.off("mouseup.editPolygonsMode", A), document.removeEventListener("contextmenu", _), document.removeEventListener("keydown", _)), a.value = void 0, e.end(), i.end(), s.quitHandler && s.quitHandler();
  12363. };
  12364. return hn ? (r.on("touchstart.editPolygonsMode", p), r.on("touchmove.editPolygonsMode", m), r.on("touchend.editPolygonsMode", v)) : (r.on("click.editPolygonsMode", c), r.on("mousedown.editPolygonsMode", h), r.on("mousemove.editPolygonsMode", l), r.on("mouseup.editPolygonsMode", A), document.addEventListener("contextmenu", _), document.addEventListener("keydown", _)), {
  12365. helperInfo: a,
  12366. destory() {
  12367. g && (g(), g = null);
  12368. }
  12369. };
  12370. }, hu = (s, t) => {
  12371. var o, h, l;
  12372. const { lineChange: e, polygonChange: i } = s;
  12373. if (!e || !((o = i == null ? void 0 : i.update) != null && o.length))
  12374. return !1;
  12375. const n = i.update.find(
  12376. ({ after: A }) => A.id === t
  12377. );
  12378. if (!n)
  12379. return !1;
  12380. const { before: r, after: a } = n;
  12381. if ((h = e.del) != null && h.length) {
  12382. if ((l = e.add) != null && l.length)
  12383. return !1;
  12384. } else if (a.lineIds.length >= 2)
  12385. return "after";
  12386. if (a.lineIds.length !== r.lineIds.length)
  12387. if (a.lineIds.includes(r.lineIds[r.lineIds.length - 1])) {
  12388. if (!a.lineIds.includes(r.lineIds[0]))
  12389. return "before";
  12390. } else
  12391. return "after";
  12392. return !1;
  12393. }, lu = (s, t = !1) => {
  12394. var o, h, l, A, u, f, c, d, p, m, v, _, g, y, x, b;
  12395. const e = [];
  12396. (h = (o = s.change) == null ? void 0 : o.pointChange) != null && h.add && e.push(
  12397. ...(A = (l = s.change) == null ? void 0 : l.pointChange) == null ? void 0 : A.add.map(({ x: C, y: w }) => [C, w])
  12398. );
  12399. const i = [];
  12400. (f = (u = s.change) == null ? void 0 : u.pointChange) != null && f.del && i.push(...(d = (c = s.change) == null ? void 0 : c.pointChange) == null ? void 0 : d.del.map(({ id: C }) => C));
  12401. const n = [];
  12402. if ((m = (p = s.change) == null ? void 0 : p.lineChange) != null && m.add) {
  12403. const C = s.change.lineChange.add.map(
  12404. ({ pointIds: w }) => w
  12405. );
  12406. n.push(
  12407. ...C.map((w) => _t(s.config, w).flatMap(({ x: S, y: P }) => [S, P]))
  12408. );
  12409. }
  12410. const r = [];
  12411. (_ = (v = s.change) == null ? void 0 : v.lineChange) != null && _.del && r.push(...(y = (g = s.change) == null ? void 0 : g.lineChange) == null ? void 0 : y.del.map(({ id: C }) => C));
  12412. const a = {};
  12413. return t && ((b = (x = s.change) == null ? void 0 : x.polygonChange) != null && b.update) && s.change.polygonChange.update.forEach((C) => {
  12414. if (hu(s.change, C.after.id)) {
  12415. const w = oh(s.config, [
  12416. C.after.lineIds[C.after.lineIds.length - 1],
  12417. C.after.lineIds[0]
  12418. ]);
  12419. a[C.after.id] = _t(s.config, [
  12420. w[0].pointIds[1],
  12421. w[1].pointIds[0]
  12422. ]).flatMap(({ x: E, y: S }) => [E, S]);
  12423. }
  12424. }), {
  12425. addLines: n,
  12426. delLines: r,
  12427. addPoints: e,
  12428. delPoints: i,
  12429. cloneLines: a
  12430. };
  12431. }, Lr = (s, t) => {
  12432. const { helperInfo: e, destory: i } = ou({
  12433. ...s,
  12434. quitHandler: () => {
  12435. o(), s.quitHandler && s.quitHandler();
  12436. }
  12437. }), n = mh(
  12438. () => e.value && lu(e.value, s.autoClose)
  12439. ), r = On();
  12440. r.shape.listening(!1);
  12441. const a = ui();
  12442. a.active(), a.shape.dash([5, 5]), a.shape.listening(!1);
  12443. const o = Sn((h) => {
  12444. if (!n.value)
  12445. return;
  12446. const { addLines: l, cloneLines: A, addPoints: u } = n.value, f = [...l, ...Object.values(A)].map(
  12447. (m) => (a.setData(m), a.shape.clone())
  12448. ), [c] = Gt(t, [1, 1]), d = u.map((m) => (r.setData(m), r.shape.scale({ x: c, y: c }), r.shape.clone()));
  12449. t.add(...f, ...d);
  12450. let p;
  12451. n.value.delPoints.length ? p = s.tree.setCursor(au) : u.length && (p = s.tree.setCursor(ru)), h(() => {
  12452. [...f, ...d].forEach((m) => {
  12453. m.remove();
  12454. }), p && p();
  12455. });
  12456. });
  12457. return i;
  12458. };
  12459. class f1 extends Ri {
  12460. diffRedraw() {
  12461. const t = super.diffRedraw();
  12462. return t.lineEntityInc.adds.forEach((e) => {
  12463. ln(e, this.lineDragHandler), e.enableMouseAct({ ...e.actShape, active: void 0 }), e.shape.name("adsord-line");
  12464. }), t.pointEntityInc.adds.forEach((e) => {
  12465. ln(e, this.pointDragHandler), e.enableMouseAct({ ...e.actShape, active: void 0 }), e.shape.addName("adsord-point");
  12466. }), t;
  12467. }
  12468. getChildByPointsAttrib(t) {
  12469. const e = [];
  12470. for (let i = 0; i < t.length; i++) {
  12471. const n = Tt.namespace + t[i].id;
  12472. e.includes(n) || e.push(n), this.attrib.lines.filter(({ pointIds: r }) => r.includes(t[i].id)).forEach(({ id: r }) => {
  12473. const a = Qt.namespace + r;
  12474. e.includes(a) || e.push(a);
  12475. });
  12476. }
  12477. return this.children.filter((i) => e.includes(i.name));
  12478. }
  12479. editPolygon(t) {
  12480. xo(), this.container.constant.use();
  12481. const e = /* @__PURE__ */ new Set();
  12482. let i = !1;
  12483. this.endCreatePolygon && this.endCreatePolygon(), this.container.bus.emit("dataChangeBefore");
  12484. const n = Tr();
  12485. let r = !1;
  12486. const a = new Promise((o) => {
  12487. this.endCreatePolygon = Lr(
  12488. {
  12489. polygonId: t,
  12490. quotePoint: !0,
  12491. autoClose: !1,
  12492. tree: this.container,
  12493. autoAdd: !0,
  12494. adsorbRadius: jt.WHOLE_LINE_POINT_MERGE_DIST,
  12495. config: this.attrib,
  12496. changePolygon: (h) => {
  12497. console.log("changePolygon", h), h && e.add(h);
  12498. },
  12499. onChange(h) {
  12500. !r && h.pointChange.add.length && (n.emit("penStart"), r = !0);
  12501. },
  12502. quitHandler: () => {
  12503. this.endCreatePolygon = null, e.forEach((h) => {
  12504. const l = yi(this.attrib, h);
  12505. l && (i ? ch(this.attrib, h) : this.polygonAfterHandler(l));
  12506. }), o(i ? "cancel" : "submit"), bo(), this.container.constant.unuse(), this.container.bus.emit("dataChangeAfter");
  12507. }
  12508. },
  12509. this.shape
  12510. );
  12511. });
  12512. return {
  12513. bus: n,
  12514. submit: this.endCreatePolygon.bind(this),
  12515. cancel: () => {
  12516. i = !0, this.endCreatePolygon();
  12517. },
  12518. promise: a
  12519. };
  12520. }
  12521. createPolygon() {
  12522. return this.editPolygon();
  12523. }
  12524. pointAfterHandler(t) {
  12525. this.container.constant.use();
  12526. const e = tu(this.attrib, t.id);
  12527. $s(
  12528. this.attrib,
  12529. (e == null ? void 0 : e.info.main.id) || t.id
  12530. ), Ws(this.attrib), this.container.constant.unuse();
  12531. }
  12532. lineAfterHandler(t) {
  12533. this.container.constant.use();
  12534. for (let e = 0; e < t.pointIds.length; e++)
  12535. $s(this.attrib, t.pointIds[e]);
  12536. Ws(this.attrib), this.container.constant.unuse();
  12537. }
  12538. polygonAfterHandler(t) {
  12539. this.container.constant.use(), ri(this.attrib, t.id).forEach(
  12540. (e) => {
  12541. this.attrib.points.includes(e) && $s(this.attrib, e.id);
  12542. }
  12543. ), Ws(this.attrib), this.container.constant.unuse();
  12544. }
  12545. init() {
  12546. this.lineDragHandler = {
  12547. readyHandler: (t) => {
  12548. this.container.bus.emit("dataChangeBefore"), this.container.tempDraw();
  12549. const e = pi(this.attrib, t.id);
  12550. return eu(
  12551. this.attrib,
  12552. t,
  12553. e.map(({ x: i, y: n }) => [i, n])
  12554. );
  12555. },
  12556. moveHandler: (t, e, i) => {
  12557. i(e);
  12558. },
  12559. endHandler: (t) => {
  12560. this.lineAfterHandler(t), this.container.bus.emit("dataChangeAfter");
  12561. }
  12562. }, this.pointDragHandler = {
  12563. readyHandler: (t) => (this.container.constant.use(), this.container.bus.emit("dataChangeBefore"), lh(
  12564. this.attrib,
  12565. t.id
  12566. ).map(({ polygonId: n }) => {
  12567. let r = ri(this.attrib, n);
  12568. const a = r.indexOf(t), o = r[0] === r[r.length - 1] ? r.length - 1 : r.length;
  12569. return r = [
  12570. ...r.slice(a + 1, o),
  12571. ...r.slice(0, a)
  12572. ], console.log(r), r.map((h) => [h.x, h.y]);
  12573. })),
  12574. moveHandler: (t, e, i) => {
  12575. const n = Vd(
  12576. this.attrib,
  12577. t
  12578. ).map((a) => Qt.namespace + a.id);
  12579. n.push(Tt.namespace + t.id);
  12580. const r = uh({
  12581. tree: this.container,
  12582. position: e,
  12583. radius: jt.WHOLE_LINE_POINT_MERGE_DIST,
  12584. radiusInner: jt.WHOLE_LINE_POINT_CHECK_DIST,
  12585. pointsArray: i,
  12586. exclusionIds: n
  12587. });
  12588. t.x = r[0], t.y = r[1];
  12589. },
  12590. endHandler: (t) => {
  12591. this.container.constant.unuse(), this.pointAfterHandler(t), this.container.bus.emit("dataChangeAfter");
  12592. }
  12593. }, super.init();
  12594. }
  12595. destory() {
  12596. this.endCreatePolygon && this.endCreatePolygon(), super.destory();
  12597. }
  12598. }
  12599. const Au = (s, t) => {
  12600. const e = t.parent, i = ui(), n = () => !!(e.editPolygonId.value && hh(
  12601. e.attrib,
  12602. e.editPolygonId.value
  12603. ).some(({ id: o }) => o === s.id)), r = () => {
  12604. var o, h, l;
  12605. ((l = (h = (o = e.helperInfo) == null ? void 0 : o.value) == null ? void 0 : h.delLines) == null ? void 0 : l.includes(s.id)) ? i.shape.stroke("rgba(0, 0, 0, 0)") : n() ? i.active() : i.common();
  12606. };
  12607. return {
  12608. shape: i.shape,
  12609. setData(a) {
  12610. i.setData(a), r();
  12611. },
  12612. common: r
  12613. };
  12614. }, fh = (s) => (t, e) => {
  12615. const i = e.parent, n = () => i.editPolygonId.value === t.id, r = Nn({ autoClose: s }), a = (o) => {
  12616. n() ? r.active(o) : r.common(o);
  12617. };
  12618. return {
  12619. shape: r.shape,
  12620. setData(o) {
  12621. var l, A, u, f;
  12622. a(), r.setData(o);
  12623. const h = (A = (l = i.helperInfo) == null ? void 0 : l.value) != null && A.cloneLines ? Object.keys((f = (u = i.helperInfo) == null ? void 0 : u.value) == null ? void 0 : f.cloneLines).includes(
  12624. t.id
  12625. ) : !1;
  12626. r.shape.children[1].visible(!h);
  12627. },
  12628. common: a
  12629. };
  12630. }, cu = fh(!0), du = fh(!1);
  12631. class g1 extends Ri {
  12632. constructor() {
  12633. super(...arguments), this.editPolygonId = ei(), this.autoClose = !0, this._leaveEditMode = void 0;
  12634. }
  12635. dragAttach(t) {
  12636. t.pointEntityInc.adds.forEach((e) => {
  12637. ln(e, {
  12638. readyHandler: (i) => [i.x, i.y],
  12639. moveHandler: (i, n) => {
  12640. this.editPolygonId.value && (i.x = n[0], i.y = n[1]);
  12641. }
  12642. }), e.enableMouseAct(e.actShape);
  12643. }), t.lineEntityInc.adds.forEach((e) => {
  12644. e.enableMouseAct(e.actShape);
  12645. }), t.polygonEntityInc.adds.forEach((e) => {
  12646. e.enableMouseAct(e.actShape);
  12647. });
  12648. }
  12649. diffRedraw() {
  12650. const t = super.diffRedraw();
  12651. return this.dragAttach(t), t;
  12652. }
  12653. initIncFactory() {
  12654. super.initIncFactory(), this.incLinesFactory = Pt(
  12655. Qt,
  12656. this,
  12657. (t) => {
  12658. t.actShapeFactory = Au, t.setConfig(this.attrib);
  12659. }
  12660. ), this.incPointsFactory = Pt(
  12661. Tt,
  12662. this
  12663. ), this.incPolygonFactory = Pt(
  12664. Li,
  12665. this,
  12666. (t) => {
  12667. t.actShapeFactory = this.autoClose ? cu : du, t.setConfig(this.attrib);
  12668. }
  12669. );
  12670. }
  12671. enterEditMode(t) {
  12672. this._leaveEditMode && this._leaveEditMode(), this._leaveEditMode = Lr(
  12673. {
  12674. ...t,
  12675. closeAutoQuit: !0,
  12676. tree: this.container,
  12677. autoAdd: !1,
  12678. autoClose: this.autoClose,
  12679. config: this.attrib,
  12680. changePolygon: (e) => {
  12681. this.editPolygonId.value = e;
  12682. },
  12683. quitHandler: () => {
  12684. t.quitHandler && t.quitHandler();
  12685. }
  12686. },
  12687. this.shape
  12688. );
  12689. }
  12690. leaveEditMode() {
  12691. this._leaveEditMode && this._leaveEditMode();
  12692. }
  12693. destory() {
  12694. this.leaveEditMode(), super.destory();
  12695. }
  12696. }
  12697. class uu extends ie {
  12698. constructor(t) {
  12699. for (const i in t.types)
  12700. t.data[i] = t.data[i] || [];
  12701. for (const i in t.data)
  12702. i in t.types || delete t.data[i];
  12703. super({
  12704. name: "container",
  12705. attrib: { id: "0", data: t.data },
  12706. ...t
  12707. }), this.entrys = {}, this.incFactorys = {}, this.constant = Yd(), this.config = t, this.container = this;
  12708. const { dom: e } = this.config;
  12709. this.stage = new Ii.Stage({
  12710. container: e,
  12711. width: e.offsetWidth,
  12712. height: e.offsetHeight
  12713. });
  12714. }
  12715. initShape() {
  12716. return new _r();
  12717. }
  12718. init() {
  12719. this.initIncFactory(), super.init(), this.mount(this.stage), this.mounted();
  12720. }
  12721. initIncFactory() {
  12722. const t = this.config.types;
  12723. for (const e in t)
  12724. this.incFactorys[e] = Pt(
  12725. t[e],
  12726. this,
  12727. (i) => {
  12728. const n = i;
  12729. this.entrys[e] || (this.entrys[e] = []), this.entrys[e].push(n), n.bus.on("destroyed", () => {
  12730. const r = this.entrys[e].indexOf(n);
  12731. ~r && this.entrys[e].splice(r, 1);
  12732. });
  12733. }
  12734. );
  12735. }
  12736. diffRedraw() {
  12737. const t = this.attrib.data, e = {};
  12738. for (const i in t)
  12739. i in this.incFactorys && (e[i] = this.incFactorys[i](t[i]));
  12740. return e;
  12741. }
  12742. initReactive() {
  12743. return super.initReactive("sync");
  12744. }
  12745. // 临时绘制
  12746. tempDraw(...t) {
  12747. const e = t.map((i) => i.teleport);
  12748. return t.forEach((i) => {
  12749. i.mount(this.tempLayer);
  12750. }), () => {
  12751. t.forEach((i, n) => {
  12752. i.mount(e[n]);
  12753. });
  12754. };
  12755. }
  12756. getPixelFromStage(t) {
  12757. const e = be(this.stage, !0), { x: i, y: n } = e.point({ x: t[0], y: t[1] });
  12758. return [i, n];
  12759. }
  12760. getRealFromStage(t) {
  12761. const e = be(this.stage, !0).invert(), { x: i, y: n } = e.point({ x: t[0], y: t[1] });
  12762. return [i, n];
  12763. }
  12764. setCursor(t) {
  12765. return t = ["move", "inherit", "pointer"].includes(t) ? t : t ? `url("${t}"), auto` : "inherit", this.config.dom.style.cursor = t, this.prevCursor = t, () => {
  12766. this.prevCursor === t && (this.config.dom.style.cursor = "inherit", this.prevCursor = "inherit");
  12767. };
  12768. }
  12769. getSameLevelData(t) {
  12770. const e = this.attrib.data;
  12771. for (const i in e)
  12772. if (Array.isArray(e[i]) && ~e[i].indexOf(t.attrib))
  12773. return e[i];
  12774. }
  12775. updateViewMat(t) {
  12776. const e = new j(), i = new ci(), n = new j();
  12777. t.decompose(e, i, n);
  12778. const r = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
  12779. let a = new zi();
  12780. for (let l = 0; l < r.length; l++) {
  12781. a.setFromQuaternion(i, r[l]);
  12782. const A = Math.abs(Se.radToDeg(a.z) % 90);
  12783. if (Math.abs(A) < 5)
  12784. break;
  12785. }
  12786. a.setFromQuaternion(i, "XYZ");
  12787. const o = a.z, h = this.stage.scale();
  12788. this.stage.scale({ x: n.x, y: n.y }), this.stage.position({ x: e.x, y: e.y }), this.stage.rotation(Se.radToDeg(o)), Math.abs(h.x - n.x) < 1e-3 && Math.abs(h.y - n.y) < 1e-3 || this.redraw(), this.shape.batchDraw(), this.constant.updateConstantScale(Math.min(n.x, n.y)), this.bus.emit("viewChange", {
  12789. mat: be(this.shape, !0),
  12790. size: [this.stage.width(), this.stage.height()]
  12791. });
  12792. }
  12793. }
  12794. const fu = () => {
  12795. const s = new Ni({
  12796. radius: 3,
  12797. fill: "red"
  12798. }), t = () => {
  12799. const [e] = Gt(s, [1, 1]);
  12800. s.scale({ x: e, y: e });
  12801. };
  12802. return {
  12803. getSize: () => [3, 3],
  12804. shape: s,
  12805. common() {
  12806. },
  12807. setData(e) {
  12808. t(), s.position(e), e.rotate && s.rotate(e.rotate);
  12809. }
  12810. };
  12811. }, gh = {}, gu = (s, t) => {
  12812. gh[s] = t;
  12813. }, wn = class wn extends ie {
  12814. constructor(t) {
  12815. t.zIndex = t.zIndex || 5, t.name = t.name || wn.namespace + t.attrib.id, super(t), this.showLabel = !1;
  12816. }
  12817. setShowLabel(t) {
  12818. this.showLabel = t, this.diffRedraw();
  12819. }
  12820. initShape() {
  12821. const t = gh[this.attrib.type] || fu;
  12822. return this.actShape = t(this.attrib, this), this.actShape.shape;
  12823. }
  12824. diffRedraw() {
  12825. this.actShape.setData(this.attrib);
  12826. }
  12827. mounted() {
  12828. super.mounted(), this.actShape.common(null);
  12829. }
  12830. };
  12831. wn.namespace = "poi";
  12832. let pn = wn;
  12833. class p1 extends pn {
  12834. mounted() {
  12835. super.enableMouseAct(this.actShape), this.bus.on("shapeStatusChange", (t) => {
  12836. t.type === "click" && (t.current === "active" ? this.container.bus.emit("active", { active: !0, entity: this }) : this.container.bus.emit("active", { active: !1, entity: this }));
  12837. }), super.enableDrag({
  12838. readyHandler: () => {
  12839. this.container.bus.emit("dataChangeBefore");
  12840. },
  12841. moveHandler: (t) => {
  12842. this.attrib.x = t[0], this.attrib.y = t[1];
  12843. },
  12844. endHandler: () => {
  12845. this.container.bus.emit("dataChangeAfter");
  12846. }
  12847. }), super.mounted();
  12848. }
  12849. del() {
  12850. const t = this.container.getSameLevelData(this);
  12851. t && t.splice(t.indexOf(this.attrib), 1), this.container.bus.emit("dataChange");
  12852. }
  12853. copy(t = {}) {
  12854. VA({
  12855. ...t,
  12856. entity: this,
  12857. size: this.actShape.getSize(),
  12858. factoryAttrib: (e) => ({
  12859. x: e[0],
  12860. y: e[1],
  12861. type: this.attrib.type
  12862. })
  12863. }), this.container.bus.emit("dataChange");
  12864. }
  12865. }
  12866. const pu = (s, t) => (i, n, r = !1) => {
  12867. const a = document.createElement("div");
  12868. a.style.width = "100%", a.style.height = "100%";
  12869. const o = new uu({
  12870. dom: a,
  12871. readonly: r,
  12872. types: s,
  12873. data: n,
  12874. reactive: !r
  12875. });
  12876. o.init();
  12877. const h = {};
  12878. if (t)
  12879. for (const u in t) {
  12880. const f = t[u];
  12881. f.setTree(o), h[u] = f;
  12882. }
  12883. let l = null;
  12884. const A = (u) => {
  12885. a.parentElement && a.parentElement.removeChild(a), u.appendChild(a), a.style.width = "100%", a.style.height = "100%", o.stage.width(a.offsetWidth), o.stage.height(a.offsetHeight), l = u;
  12886. };
  12887. return i ? A(i) : (a.style.width = "300px", a.style.height = "300px"), {
  12888. types: s,
  12889. tree: o,
  12890. setData(u) {
  12891. o.setAttrib({ data: u });
  12892. },
  12893. getData() {
  12894. return o.attrib.data;
  12895. },
  12896. destory() {
  12897. for (const u in t) {
  12898. const f = t[u];
  12899. f.destory && f.destory();
  12900. }
  12901. o.destory();
  12902. },
  12903. mountedDom: l,
  12904. mount: A,
  12905. ...h
  12906. };
  12907. }, Je = new Jt(), yu = (s, t) => {
  12908. Je.identity().translate(-t[0], -t[1]);
  12909. const e = new X(s[0], s[1]).applyMatrix3(Je), i = new X(s[2], s[3]).applyMatrix3(Je);
  12910. return [e.x, e.y, i.x, i.y];
  12911. }, mu = (s, t, e) => {
  12912. Je.identity().translate(-t[0], -t[1]).scale(e, e).translate(t[0], t[1]);
  12913. const i = new X(s[0], s[1]).applyMatrix3(Je), n = new X(s[2], s[3]).applyMatrix3(Je);
  12914. return [i.x, i.y, n.x, n.y];
  12915. };
  12916. class vu {
  12917. constructor(t = {}) {
  12918. this.bound = t.bound, this.props = t, this.props.move = t.move || !1, this.props.wheel = t.wheel || !1;
  12919. }
  12920. disableMove() {
  12921. this.props.move = !1, this.dragDestory && this.dragDestory();
  12922. }
  12923. enableMove(t) {
  12924. if (this.disableMove(), this.props.move = !0, !this.tree)
  12925. return;
  12926. const { stage: e } = this.tree;
  12927. this.dragDestory = yr(
  12928. e,
  12929. {
  12930. readyHandler: () => ({
  12931. tf: be(e, !0).invert(),
  12932. initBound: this.bound
  12933. }),
  12934. moveHandler: (i, { tf: n, initBound: r }) => {
  12935. const a = n.point({ x: i[0], y: i[1] }), o = [a.x, a.y];
  12936. let h = yu(r, o);
  12937. if (t) {
  12938. const l = t(h, o);
  12939. if (typeof l != "boolean")
  12940. h = l;
  12941. else if (!l)
  12942. return;
  12943. }
  12944. this.setBound(h);
  12945. }
  12946. },
  12947. !1
  12948. );
  12949. }
  12950. disableWheel() {
  12951. this.props.wheel = !1, this.wheelDestory && this.wheelDestory();
  12952. }
  12953. enableWheel(t) {
  12954. if (this.disableWheel(), this.props.wheel = !0, !this.tree)
  12955. return;
  12956. const {
  12957. stage: e,
  12958. config: { dom: i }
  12959. } = this.tree, n = (r) => {
  12960. const a = 1 + r.deltaY / 1e3, o = e.getRelativePointerPosition(), h = [o.x, o.y];
  12961. let l = mu(this.bound, h, a);
  12962. if (t) {
  12963. const A = t(l, h, a);
  12964. if (typeof A != "boolean")
  12965. l = A;
  12966. else if (!A)
  12967. return;
  12968. }
  12969. this.bound = l, this.update();
  12970. };
  12971. i.addEventListener("wheel", n), this.wheelDestory = () => i.removeEventListener("wheel", n);
  12972. }
  12973. setBound(t) {
  12974. this.bound = t, this.update();
  12975. }
  12976. setSize(t, e) {
  12977. this.tree.stage.width(t), this.tree.stage.height(e);
  12978. }
  12979. setTree(t) {
  12980. if (this.tree = t, !this.bound) {
  12981. const e = t.stage.getSize(), i = t.stage.position();
  12982. this.bound = [i.x, i.y, e.width, e.height];
  12983. }
  12984. this.props.move && this.enableMove(), this.props.wheel && this.enableWheel();
  12985. }
  12986. update() {
  12987. const { stage: t } = this.tree, e = this.bound[2] - this.bound[0], i = this.bound[3] - this.bound[1], n = t.width() / e, r = t.height() / i, a = -this.bound[0] * n, o = -this.bound[1] * r;
  12988. t.scale({ x: n, y: r }), t.position({ x: a, y: o }), this.tree.redraw(), this.tree.bus.emit("viewChange", {
  12989. mat: t.getTransform(),
  12990. size: [t.width(), t.height()]
  12991. }), this.tree.shape.batchDraw();
  12992. }
  12993. }
  12994. var ph = {};
  12995. Object.defineProperty(ph, "__esModule", { value: !0 });
  12996. var _u = function(t) {
  12997. for (var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, i = t.length, n = e ^ i, r = 0, a = void 0; i >= 4; )
  12998. a = t.charCodeAt(r) & 255 | (t.charCodeAt(++r) & 255) << 8 | (t.charCodeAt(++r) & 255) << 16 | (t.charCodeAt(++r) & 255) << 24, a = (a & 65535) * 1540483477 + (((a >>> 16) * 1540483477 & 65535) << 16), a ^= a >>> 24, a = (a & 65535) * 1540483477 + (((a >>> 16) * 1540483477 & 65535) << 16), n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16) ^ a, i -= 4, ++r;
  12999. switch (i) {
  13000. case 3:
  13001. n ^= (t.charCodeAt(r + 2) & 255) << 16;
  13002. case 2:
  13003. n ^= (t.charCodeAt(r + 1) & 255) << 8;
  13004. case 1:
  13005. n ^= t.charCodeAt(r) & 255, n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16);
  13006. }
  13007. return n ^= n >>> 13, n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16), n ^= n >>> 15, n >>> 0;
  13008. }, xu = _u, bu = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(s) {
  13009. return typeof s;
  13010. } : function(s) {
  13011. return s && typeof Symbol == "function" && s.constructor === Symbol && s !== Symbol.prototype ? "symbol" : typeof s;
  13012. };
  13013. function wu(s) {
  13014. var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2, e = /* @__PURE__ */ new Set(), i = JSON.stringify(s, function(n, r) {
  13015. return (typeof r > "u" ? "undefined" : bu(r)) === "object" && r !== null ? e.has(r) ? void 0 : e.add(r) && r : r;
  13016. }, t);
  13017. return e = null, i;
  13018. }
  13019. var qa = Object.assign || function(s) {
  13020. for (var t = 1; t < arguments.length; t++) {
  13021. var e = arguments[t];
  13022. for (var i in e)
  13023. Object.prototype.hasOwnProperty.call(e, i) && (s[i] = e[i]);
  13024. }
  13025. return s;
  13026. };
  13027. function Su(s) {
  13028. if (Array.isArray(s)) {
  13029. for (var t = 0, e = Array(s.length); t < s.length; t++)
  13030. e[t] = s[t];
  13031. return e;
  13032. } else
  13033. return Array.from(s);
  13034. }
  13035. var yh = {
  13036. // StateNode => { Chunks, Children }
  13037. toRecord: function(t) {
  13038. return {
  13039. chunks: [qa({}, t, { children: void 0 })],
  13040. children: t.children
  13041. };
  13042. },
  13043. // { Chunks, Children } => StateNode
  13044. fromRecord: function(t) {
  13045. var e = t.chunks, i = t.children;
  13046. return qa({}, e[0], { children: i });
  13047. }
  13048. }, Cu = function s(t, e) {
  13049. for (var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null, r = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1, a = i.findIndex(function(v) {
  13050. var _ = v.match;
  13051. return _(t);
  13052. }), o = i[a] || yh, h = o.toRecord(t), l = h.chunks, A = h.children, u = A, f = [], c = 0; c < l.length; c++) {
  13053. var d = wu(l[c], 0), p = xu(d);
  13054. f.push(p), e[p] = d;
  13055. }
  13056. if (r !== -1 && Array.isArray(n && n.children)) {
  13057. var m = [].concat(Su(n.children));
  13058. return m[r] = s(u[r], e, i), { hashes: f, ruleIndex: a, children: m };
  13059. } else
  13060. return {
  13061. hashes: f,
  13062. ruleIndex: a,
  13063. children: A && A.map(function(v) {
  13064. return s(v, e, i);
  13065. })
  13066. };
  13067. }, Mu = function s(t, e) {
  13068. var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], n = t.hashes, r = t.ruleIndex, a = t.children, o = n.map(function(l) {
  13069. return JSON.parse(e[l]);
  13070. }), h = i[r] || yh;
  13071. return h.fromRecord({
  13072. chunks: o,
  13073. children: a && a.map(function(l) {
  13074. return s(l, e, i);
  13075. })
  13076. });
  13077. }, Pu = /* @__PURE__ */ function() {
  13078. function s(t, e) {
  13079. for (var i = 0; i < e.length; i++) {
  13080. var n = e[i];
  13081. n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n);
  13082. }
  13083. }
  13084. return function(t, e, i) {
  13085. return e && s(t.prototype, e), i && s(t, i), t;
  13086. };
  13087. }();
  13088. function Eu(s, t) {
  13089. if (!(s instanceof t))
  13090. throw new TypeError("Cannot call a class as a function");
  13091. }
  13092. var Qa = function() {
  13093. }, Fu = function() {
  13094. function s() {
  13095. var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
  13096. initialState: void 0,
  13097. rules: [],
  13098. delay: 50,
  13099. maxLength: 100,
  13100. onChange: Qa,
  13101. useChunks: !0
  13102. };
  13103. Eu(this, s), this.rules = t.rules || [], this.delay = t.delay || 50, this.maxLength = t.maxLength || 100, this.useChunks = t.useChunks === void 0 ? !0 : t.useChunks, this.onChange = Qa, this.$index = -1, this.$records = [], this.$chunks = {}, this.$pending = {
  13104. state: null,
  13105. pickIndex: null,
  13106. onResolves: [],
  13107. timer: null
  13108. }, this.$debounceTime = null, t.initialState !== void 0 && this.pushSync(t.initialState), t.onChange && (this.onChange = t.onChange);
  13109. }
  13110. return Pu(s, [{
  13111. key: "get",
  13112. // void => State
  13113. value: function() {
  13114. var e = this.$records[this.$index], i = void 0;
  13115. return e ? this.useChunks ? i = Mu(e, this.$chunks, this.rules) : i = e : i = null, this.onChange(i), i;
  13116. }
  13117. // (State, number?) => History
  13118. }, {
  13119. key: "pushSync",
  13120. value: function(e) {
  13121. var i = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -1, r = this.$records[this.$index] || null, a = this.useChunks ? Cu(e, this.$chunks, this.rules, r, n) : e;
  13122. this.$index++, this.$records[this.$index] = a;
  13123. for (var o = this.$index + 1; o < this.$records.length; o++)
  13124. this.$records[o] = null;
  13125. return this.$index >= this.maxLength && (this.$records[this.$index - this.maxLength] = null), this.$pending.timer && (clearTimeout(this.$pending.timer), this.$pending.state = null, this.$pending.pickIndex = null, this.$pending.timer = null, this.$debounceTime = null, this.$pending.onResolves.forEach(function(h) {
  13126. return h(i);
  13127. }), this.$pending.onResolves = []), this.onChange(e), this;
  13128. }
  13129. // (State, number?) => Promise<History>
  13130. }, {
  13131. key: "push",
  13132. value: function(e) {
  13133. var i = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -1, r = +/* @__PURE__ */ new Date(), a = function() {
  13134. i.$pending.state = e, i.$pending.pickIndex = n, i.$debounceTime = r;
  13135. var h = new Promise(function(l, A) {
  13136. i.$pending.onResolves.push(l), i.$pending.timer = setTimeout(function() {
  13137. i.pushSync(i.$pending.state, i.$pending.pickIndex);
  13138. }, i.delay);
  13139. });
  13140. return h;
  13141. };
  13142. return this.$pending.timer === null ? a() : r - this.$debounceTime < this.delay ? (clearTimeout(this.$pending.timer), this.$pending.timer = null, a()) : Promise.reject(new Error("Invalid push ops"));
  13143. }
  13144. // void => History
  13145. }, {
  13146. key: "undo",
  13147. value: function() {
  13148. return this.hasUndo && this.$index--, this;
  13149. }
  13150. // void => History
  13151. }, {
  13152. key: "redo",
  13153. value: function() {
  13154. return this.hasRedo && this.$index++, this;
  13155. }
  13156. // void => History
  13157. }, {
  13158. key: "reset",
  13159. value: function() {
  13160. var e = this;
  13161. return this.$index = -1, this.$records.forEach(function(i) {
  13162. }), Object.keys(this.$chunks).forEach(function(i) {
  13163. e.$chunks[i] = null;
  13164. }), this.$records = [], this.$chunks = {}, clearTimeout(this.$pending.timer), this.$pending = {
  13165. state: null,
  13166. pickIndex: null,
  13167. onResolves: [],
  13168. timer: null
  13169. }, this.$debounceTime = null, this;
  13170. }
  13171. }, {
  13172. key: "hasRedo",
  13173. get: function() {
  13174. if (this.$index === this.$records.length - 1)
  13175. return !1;
  13176. for (var e = !1, i = this.$index + 1; i < this.$records.length; i++)
  13177. this.$records[i] !== null && (e = !0);
  13178. return e;
  13179. }
  13180. // : boolean
  13181. }, {
  13182. key: "hasUndo",
  13183. get: function() {
  13184. var e = Math.max(this.$records.length - this.maxLength, 0);
  13185. return this.$index > e;
  13186. }
  13187. // : number
  13188. }, {
  13189. key: "length",
  13190. get: function() {
  13191. return Math.min(this.$records.length, this.maxLength);
  13192. }
  13193. }]), s;
  13194. }(), ku = ph.History = Fu;
  13195. class y1 {
  13196. constructor() {
  13197. this.state = ti({
  13198. hasUndo: !1,
  13199. hasRedo: !1
  13200. }), this.disabled = !0;
  13201. }
  13202. setDisable(t) {
  13203. this.disabled = t, t ? this.state.hasRedo = this.state.hasUndo = !1 : this.syncState();
  13204. }
  13205. syncState() {
  13206. !this.history || this.disabled || (this.state.hasRedo = this.history.hasRedo, this.state.hasUndo = this.history.hasUndo);
  13207. }
  13208. setTree(t) {
  13209. this.tree = t, this.history = new ku(), this.setDisable(!1), this.push(this.tree.attrib), this.timelyPush();
  13210. }
  13211. undo() {
  13212. !this.disabled && this.history.hasUndo && (this.history.undo(), this.tree.setAttrib(this.history.get()), this.syncState());
  13213. }
  13214. redo() {
  13215. !this.disabled && this.history.hasRedo && (this.history.redo(), this.tree.setAttrib(this.history.get()), this.syncState());
  13216. }
  13217. push(t) {
  13218. const e = this.history.get();
  13219. e && delete e.children, di(t, e) && (t = JSON.parse(JSON.stringify(t)), this.history.pushSync(t), this.syncState());
  13220. }
  13221. clear() {
  13222. this.history.reset();
  13223. }
  13224. timelyPush() {
  13225. this.timelyPushDestory && this.timelyPushDestory();
  13226. const t = () => {
  13227. this.push(this.tree.attrib);
  13228. }, e = () => {
  13229. this.setDisable(!0);
  13230. }, i = () => {
  13231. this.setDisable(!1), t();
  13232. };
  13233. this.tree.bus.on("dataChange", t), this.tree.bus.on("dataChangeBefore", e), this.tree.bus.on("dataChangeAfter", i), this.timelyPushDestory = () => {
  13234. this.tree.bus.off("dataChange", t), this.tree.bus.off("dataChangeBefore", e), this.tree.bus.off("dataChangeAfter", i), this.timelyPushDestory = null;
  13235. };
  13236. }
  13237. }
  13238. class m1 {
  13239. constructor(t = {}) {
  13240. this.clipMat = new ot(), this.bus = Tr(), this.props = t, this.props.move = t.move || !1, this.props.wheel = t.wheel || !1, this.cameraMat = new ot(), this.retainScale = t.retainScale || !1, t.size && this.setSize(t.size[0], t.size[1]), t.bound && this.setBound(t.bound, t.padding);
  13241. }
  13242. disableMove() {
  13243. this.props.move = !1, this.dragDestory && this.dragDestory();
  13244. }
  13245. enableMove() {
  13246. if (this.disableMove(), this.props.move = !0, !this.tree)
  13247. return;
  13248. const { stage: t } = this.tree;
  13249. this.dragDestory = yr(
  13250. t,
  13251. {
  13252. readyHandler: () => this.cameraMat.clone(),
  13253. moveHandler: (e, i) => {
  13254. const n = this.clipMat.clone().multiply(i).invert(), r = new j(e[0], e[1], 0).applyMatrix4(n);
  13255. this.move([r.x, r.y], i);
  13256. }
  13257. },
  13258. !1
  13259. );
  13260. }
  13261. disableWheel() {
  13262. this.props.wheel = !1, this.wheelDestory && this.wheelDestory();
  13263. }
  13264. enableWheel() {
  13265. if (this.disableWheel(), this.props.wheel = !0, !this.tree)
  13266. return;
  13267. const {
  13268. config: { dom: t }
  13269. } = this.tree, e = (i) => {
  13270. const n = 1 - i.deltaY / 1e3, r = new j(i.offsetX, i.offsetY, 0).applyMatrix4(
  13271. this.clipMat.clone().multiply(this.cameraMat).invert()
  13272. );
  13273. this.scale([r.x, r.y], n);
  13274. };
  13275. t.addEventListener("wheel", e), this.wheelDestory = () => t.removeEventListener("wheel", e);
  13276. }
  13277. move(t, e = this.cameraMat) {
  13278. this.mutMat(
  13279. new ot().setPosition(t[0], t[1], 0),
  13280. e
  13281. );
  13282. }
  13283. scale(t, e, i = this.cameraMat) {
  13284. this.mutMat(
  13285. new ot().makeTranslation(t[0], t[1], 0).multiply(
  13286. new ot().makeScale(e, e, 1).multiply(new ot().makeTranslation(-t[0], -t[1], 0))
  13287. ),
  13288. i
  13289. );
  13290. }
  13291. rotate(t, e, i = this.cameraMat) {
  13292. this.mutMat(
  13293. new ot().makeTranslation(t[0], t[1], 0).multiply(
  13294. new ot().makeRotationAxis(new j(0, 0, 1), e).multiply(new ot().makeTranslation(-t[0], -t[1], 0))
  13295. ),
  13296. i
  13297. );
  13298. }
  13299. mutMat(t, e = this.cameraMat) {
  13300. t instanceof ot ? e = e.clone().multiply(t) : e = e.multiply(new ot().fromArray(t)), this.setCameraMat(e), this.bus.emit("cameraChange", this.cameraMat.toArray());
  13301. }
  13302. setCameraMat(t) {
  13303. t instanceof ot ? this.cameraMat = t : this.cameraMat.fromArray(t), this.update();
  13304. }
  13305. autoBound(t, e = [".adsord-point"]) {
  13306. const i = e.flatMap(
  13307. (r) => this.tree.stage.find(r).map((a) => a.position())
  13308. );
  13309. if (i.length < 2)
  13310. return;
  13311. const n = [
  13312. Number.MAX_VALUE,
  13313. Number.MAX_VALUE,
  13314. -Number.MAX_VALUE,
  13315. -Number.MAX_VALUE
  13316. ];
  13317. for (const r of i)
  13318. n[0] = Math.min(n[0], r.x), n[1] = Math.min(n[1], r.y), n[2] = Math.max(n[2], r.x), n[3] = Math.max(n[3], r.y);
  13319. this.setBound(n, t);
  13320. }
  13321. setBound(t, e) {
  13322. e = Array.isArray(e) ? e : [e || 0, e || 0], e.length === 1 && e.push(e[0]);
  13323. const i = t[2] - t[0], n = t[3] - t[1], r = this.tree.stage.width(), a = this.tree.stage.height(), o = this.tree.stage.width() - e[0] * 2, h = this.tree.stage.height() - e[1] * 2;
  13324. let l = o / i, A = h / n;
  13325. if (this.retainScale) {
  13326. const d = Math.min(l, A);
  13327. l = d, A = d;
  13328. }
  13329. const u = (r - i * l) / 2 - t[0] * l, f = (a - n * A) / 2 - t[1] * A, c = new ot().scale(new j(l, A, 1)).setPosition(u, f, 0);
  13330. this.bound = t, this.padding = e, this.clipMat = c, this.update();
  13331. }
  13332. updateSelfBound() {
  13333. this.bound && this.setBound(this.bound, this.padding);
  13334. }
  13335. setRetainScale(t) {
  13336. this.retainScale = t, this.updateSelfBound();
  13337. }
  13338. setSize(t, e) {
  13339. this.tree.stage.width(t), this.tree.stage.height(e), this.updateSelfBound();
  13340. }
  13341. setTree(t) {
  13342. this.tree = t, this.props.move && this.enableMove(), this.props.wheel && this.enableWheel();
  13343. }
  13344. update() {
  13345. this.tree.updateViewMat(this.clipMat.clone().multiply(this.cameraMat));
  13346. }
  13347. }
  13348. const Du = (s, t) => {
  13349. const e = t.parent, i = { width: 43, height: 44 }, n = new Ci({
  13350. data: "M22 44C32.6667 33.891 38 25.891 38 20C38 11.1634 30.8366 4 22 4C13.1634 4 6 11.1634 6 20C6 25.891 11.3333 33.891 22 44Z",
  13351. strokeScaleEnabled: !0,
  13352. stroke: "#ffffff",
  13353. strokeWidth: 1
  13354. }), r = new Ci({
  13355. fill: "#fff",
  13356. data: "M22 30C27.5228 30 32 25.5228 32 20C32 14.4772 27.5228 10 22 10C16.4772 10 12 14.4772 12 20C12 25.5228 16.4772 30 22 30Z"
  13357. }), a = new Ci({
  13358. fill: "#409EFF",
  13359. offset: {
  13360. x: -5,
  13361. y: -5
  13362. },
  13363. data: "M20.5143 12.213C20.7983 12.497 20.7983 12.9575 20.5143 13.2415L15.2727 18.4831L11.8494 15.0597C11.5654 14.7757 11.5654 14.3152 11.8494 14.0312C12.1334 13.7472 12.5939 13.7472 12.8779 14.0312L15.2727 16.426L19.4857 12.213C19.7698 11.929 20.2302 11.929 20.5143 12.213Z"
  13364. }), o = new Nt({
  13365. name: "anchor-move"
  13366. }), h = new Ni({
  13367. name: "anchor-move",
  13368. radius: Math.min(i.width, i.height) / 2,
  13369. fill: "rgba(0, 0, 0, 0)",
  13370. offset: { x: -i.width / 2, y: -i.height / 2 }
  13371. }), l = On();
  13372. Mt.radius = 5, Mt.hitStrokeWidth = Mt.strokeWidth = 4, l.shape.name("anchor-point");
  13373. const A = new dn({
  13374. name: "text",
  13375. text: "1",
  13376. fontFamily: "Calibri",
  13377. fontSize: 12,
  13378. padding: 5,
  13379. offsetY: -8,
  13380. fill: "#000"
  13381. }), u = new Oo({
  13382. visible: !1,
  13383. opacity: 1,
  13384. name: "label",
  13385. offsetX: -i.width / 2,
  13386. offsetY: -6
  13387. });
  13388. o.add(A, u, h);
  13389. const f = new dn({
  13390. name: "text",
  13391. text: s.title || `P${s.id}`,
  13392. fontFamily: "Inter",
  13393. fontSize: 12,
  13394. padding: 8,
  13395. fill: "#303133"
  13396. });
  13397. u.add(
  13398. new To({
  13399. name: "tag",
  13400. fill: "rgba(255, 255, 255, 1)",
  13401. pointerDirection: "down",
  13402. pointerWidth: 8,
  13403. pointerHeight: 8,
  13404. lineJoin: "round",
  13405. shadowColor: "black",
  13406. cornerRadius: 2,
  13407. opacity: 1,
  13408. shadowBlur: 10,
  13409. shadowOffsetX: 10,
  13410. shadowOffsetY: 10,
  13411. shadowOpacity: 0.5
  13412. }),
  13413. f
  13414. );
  13415. const c = new Nt();
  13416. c.add(n, r, a, o), c.x(-i.width / 2), c.y(-i.height);
  13417. const d = new Nt();
  13418. return d.add(c, l.shape), {
  13419. shape: d,
  13420. common() {
  13421. n.fill(s.rtk ? "rgba(230, 162, 60, 1)" : "#409EFF"), a.fill(s.rtk ? "rgba(230, 162, 60, 1)" : "#409EFF"), l.common(), u.visible(!1);
  13422. },
  13423. hover: () => {
  13424. u.visible(!0), s.rtk || (n.fill("#409EFF"), a.fill("#409EFF"));
  13425. },
  13426. setData(m) {
  13427. let [v, _] = Gt(d, [1, 1]);
  13428. d.scale({ x: v, y: _ }), d.x(m[0]), d.y(m[1]), f.text(t.attrib.title || `P${s.id}`), ~t.editPolygonNdx ? (A.text((t.editPolygonNdx + 1).toString()).visible(!0), A.offsetX(-h.width() / 2 + A.width() / 2), l.shape.visible(!0), a.visible(!1)) : (A.visible(!1), l.shape.visible(!1), a.visible(e.status.selectPoiIds.includes(s.id)));
  13429. },
  13430. draging() {
  13431. ~t.editPolygonNdx && (n.fill("#e0403c"), a.fill("#e0403c"));
  13432. }
  13433. };
  13434. };
  13435. class Iu extends Tt {
  13436. constructor() {
  13437. super(...arguments), this.actShape = null;
  13438. }
  13439. get editPolygonNdx() {
  13440. const t = this.parent;
  13441. return t.status.editPolygonId ? ri(
  13442. t.attrib,
  13443. t.status.editPolygonId
  13444. ).map(({ id: i }) => i).indexOf(this.attrib.id) : -1;
  13445. }
  13446. init() {
  13447. this.actShapeFactory = Du, super.init(), this.enableMouseAct(this.actShape);
  13448. }
  13449. initReactive() {
  13450. const t = this.parent;
  13451. return this.bus.on("shapeStatusChange", ({ current: e, type: i }) => {
  13452. e === "active" && i === "click" && t.bus.emit("clickPoint", this.attrib);
  13453. }), mr(
  13454. super.initReactive(),
  13455. fe(
  13456. () => this.editPolygonNdx,
  13457. (e, i, n) => {
  13458. if (!~e || this.attrib.rtk)
  13459. return n(() => {
  13460. });
  13461. const r = this.shape.findOne(".anchor-move");
  13462. let a = null;
  13463. r.on("mouseenter.anchor", () => {
  13464. a && a(), a = this.container.setCursor("move");
  13465. }), r.on("mouseleave.anchor", () => {
  13466. a && a(), a = null;
  13467. }), ln(this, {
  13468. readyHandler: (o) => [o.x, o.y],
  13469. moveHandler: (o, h) => {
  13470. ~this.editPolygonNdx && (o.x = h[0], o.y = h[1]);
  13471. }
  13472. }), n(() => {
  13473. r.off("mouseenter.anchor mouseleave.anchor"), a && a(), this.disableDrag();
  13474. });
  13475. },
  13476. { immediate: !0 }
  13477. ),
  13478. Sn(
  13479. () => {
  13480. t.status.lightPointId === this.attrib.id ? this.bus.emit("statusChange", { hover: !0 }) : this.bus.emit("statusChange", null);
  13481. },
  13482. { flush: "post" }
  13483. )
  13484. );
  13485. }
  13486. }
  13487. const Tu = () => {
  13488. const s = Nn({
  13489. autoClose: !0
  13490. }), t = s.shape.findOne(".polygon-line");
  13491. return {
  13492. ...s,
  13493. common() {
  13494. t.fill("rgba(0, 0, 0, 0)"), s.closeLine.common();
  13495. },
  13496. hover() {
  13497. t.fill("rgba(230, 162, 60, 0.3)"), s.closeLine.hover();
  13498. },
  13499. active() {
  13500. t.fill("rgba(64, 158, 255, 0.3)"), s.closeLine.active();
  13501. }
  13502. };
  13503. };
  13504. class Lu extends Li {
  13505. constructor() {
  13506. super(...arguments), this.actShapeFactory = Tu;
  13507. }
  13508. init() {
  13509. super.init(), this.enableMouseAct(this.actShape);
  13510. }
  13511. initReactive() {
  13512. const t = (i) => {
  13513. this.bus.emit("statusChange", { [i]: !0 });
  13514. };
  13515. t("common");
  13516. const e = this.parent;
  13517. return this.bus.on("shapeStatusChange", ({ current: i, type: n }) => {
  13518. e.status.editPolygonId || (i === "active" ? n === "click" && e.bus.emit("activePolygonId", this.attrib.id) : e.status.lightPolygonId === this.attrib.id ? n === "click" && e.bus.emit("activePolygonId", null) : t(i));
  13519. }), mr(
  13520. super.initReactive(),
  13521. fe(
  13522. () => [e.status.editPolygonId, e.status.lightPolygonId],
  13523. ([i, n]) => {
  13524. i === this.attrib.id ? t("active") : n === this.attrib.id ? t("hover") : t("common");
  13525. },
  13526. { flush: "post" }
  13527. )
  13528. );
  13529. }
  13530. }
  13531. const Ru = (s) => ({
  13532. rtk: !1,
  13533. title: "",
  13534. x: s[0],
  13535. y: s[1]
  13536. }), Ou = (s, t) => {
  13537. const e = t.parent, i = ui(), n = () => !!(e.status.editPolygonId && hh(
  13538. e.attrib,
  13539. e.status.editPolygonId
  13540. ).some(({ id: o }) => o === s.id)), r = () => {
  13541. n() ? i.active() : i.common();
  13542. };
  13543. return {
  13544. shape: i.shape,
  13545. setData(a) {
  13546. i.setData(a), r();
  13547. },
  13548. common: r
  13549. };
  13550. };
  13551. class Nu extends Ri {
  13552. constructor() {
  13553. super(...arguments), this.status = ti({
  13554. selectPoiIds: [],
  13555. newModel: !1
  13556. });
  13557. }
  13558. removePolygon(t) {
  13559. const e = this.attrib.polygons.findIndex(({ id: r }) => r === t);
  13560. if (!~e)
  13561. return;
  13562. const i = this.attrib.polygons[e].lineIds;
  13563. let n = [];
  13564. for (; i.length; ) {
  13565. const r = this.attrib.lines.findIndex(
  13566. ({ id: a }) => a === i[0]
  13567. );
  13568. ~r && (n.push(...this.attrib.lines[r].pointIds), this.attrib.lines.splice(r, 1)), i.shift();
  13569. }
  13570. for (n = Array.from(new Set(n)); n.length; ) {
  13571. const r = this.attrib.points.findIndex(
  13572. ({ id: a }) => a === n[0]
  13573. );
  13574. ~r && !this.attrib.points[r].rtk && this.attrib.points.splice(r, 1), n.shift();
  13575. }
  13576. this.attrib.polygons.splice(e, 1);
  13577. }
  13578. initIncFactory() {
  13579. super.initIncFactory(), this.incPointsFactory = Pt(Iu, this), this.incLinesFactory = Pt(
  13580. Qt,
  13581. this,
  13582. (t) => {
  13583. t.setConfig(this.attrib), t.actShapeFactory = Ou;
  13584. }
  13585. ), this.incPolygonFactory = Pt(Lu, this, (t) => {
  13586. t.setConfig(this.attrib);
  13587. });
  13588. }
  13589. editPolygon(t) {
  13590. return this.endEditPolygon && this.endEditPolygon(), this.status.newModel = !t, this.endEditPolygon = Lr(
  13591. {
  13592. polygonId: t,
  13593. pointAttribFactory: Ru,
  13594. canOper: (e, i) => {
  13595. if (!e.name.includes(Tt.namespace))
  13596. return !0;
  13597. const n = ri(
  13598. this.attrib,
  13599. this.status.editPolygonId
  13600. ), r = e.attrib.id, a = n.some(({ id: o }) => o === r);
  13601. return !!So(
  13602. i,
  13603. (o) => o.name() === (a ? "anchor-point" : "anchor-move")
  13604. );
  13605. },
  13606. quitHandler: () => {
  13607. this.status.newModel = !1, this.bus.emit("penEndHandler"), this.endEditPolygon = null;
  13608. },
  13609. canDelPoint: (e) => !e.rtk,
  13610. quotePoint: (e) => e.rtk,
  13611. closeAutoQuit: !0,
  13612. tree: this.container,
  13613. autoAdd: !1,
  13614. autoClose: !0,
  13615. config: this.attrib,
  13616. changePolygon: (e) => {
  13617. this.status.editPolygonId = e;
  13618. }
  13619. },
  13620. this.shape
  13621. ), this.endEditPolygon;
  13622. }
  13623. destory() {
  13624. this.endEditPolygon && this.endEditPolygon(), super.destory();
  13625. }
  13626. }
  13627. function Gu(s) {
  13628. const t = Bu();
  13629. for (let e = 0, i = s.length; e < i; ++e)
  13630. zu(t, s[e]);
  13631. return t;
  13632. }
  13633. function Bu() {
  13634. return [1 / 0, 1 / 0, -1 / 0, -1 / 0];
  13635. }
  13636. function zu(s, t) {
  13637. t[0] < s[0] && (s[0] = t[0]), t[0] > s[2] && (s[2] = t[0]), t[1] < s[1] && (s[1] = t[1]), t[1] > s[3] && (s[3] = t[1]);
  13638. }
  13639. const Uu = `<svg width="96" height="96" viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">
  13640. <path
  13641. d="M72 48C72 61.2548 61.2548 72 48 72C34.7452 72 24 61.2548 24 48C24 34.7452 34.7452 24 48 24C61.2548 24 72 34.7452 72 48Z"
  13642. fill="white" />
  13643. <path
  13644. d="M38 58.2759L48 55.2017L58 58.2759L48 35L38 58.2759ZM48 37.5333L56.2281 56.685L48 54.1555V37.5333Z"
  13645. fill="black" />
  13646. <path
  13647. d="M41.0838 11.1168L40.0239 11.4601L41.4821 14.7157L44.326 13.5088V16.0501H47.698V1.42212H44.326V4.62812H40.854V7.95812H44.326V9.95863C43.082 10.4198 41.9096 10.8493 41.0838 11.1168Z"
  13648. fill="white" />
  13649. <path
  13650. d="M55.7856 5.90817L53.4853 3.10772L52.7077 3.8062C52.2849 4.18598 51.753 4.61099 51.17 5.03535V1.43612H47.784V12.6701C47.784 13.5379 47.8745 14.4323 48.4211 15.0717C49.0134 15.7645 49.8846 15.8821 50.66 15.8821H52.746C53.2147 15.8821 53.6913 15.8052 54.1254 15.5671C54.5733 15.3215 54.888 14.953 55.1053 14.5224C55.5006 13.7389 55.6219 12.635 55.6906 11.3515L55.7358 10.5057L54.9089 10.3219C54.6839 10.2719 54.2525 10.072 54.018 9.89612L52.4998 8.7575L52.4189 10.6535C52.3763 11.6524 52.3375 12.2352 52.2795 12.5801H51.17V8.87969C52.4714 8.15697 53.8241 7.34512 54.9329 6.53282L55.7856 5.90817Z"
  13651. fill="white" />
  13652. <path
  13653. d="M41.3921 12.0681C42.3861 11.7461 43.8561 11.2001 45.3261 10.6541V6.95812H41.8541V5.62812H45.3261V2.42212H46.6981V15.0501H45.3261V11.9981L41.9941 13.4121L41.3921 12.0681ZM53.3761 4.55012L54.3421 5.72612C53.1381 6.60812 51.6121 7.50412 50.1701 8.28812V12.6981C50.1701 13.4541 50.2681 13.5801 50.8281 13.5801C51.0941 13.5801 52.3121 13.5801 52.6201 13.5801C53.2361 13.5801 53.3201 12.9921 53.4181 10.6961C53.7541 10.9481 54.3141 11.2141 54.6921 11.2981C54.5521 13.9161 54.2021 14.8821 52.7461 14.8821C52.4381 14.8821 50.9401 14.8821 50.6601 14.8821C49.2181 14.8821 48.7841 14.3921 48.7841 12.6701V2.43612H50.1701V6.91612C51.3601 6.17412 52.5501 5.29212 53.3761 4.55012Z"
  13654. fill="black" />
  13655. </svg>`;
  13656. gu("compass", (s, t) => {
  13657. const e = Ml({
  13658. ...Cl(Uu),
  13659. fixed: !0
  13660. });
  13661. return {
  13662. ...e,
  13663. setData(i) {
  13664. const n = be(e.shape).copy().invert(), r = t.container.stage.width(), a = n.point({ x: r - 60, y: 120 });
  13665. e.setData({ ...i, ...a });
  13666. }
  13667. };
  13668. });
  13669. class Hu extends ie {
  13670. constructor(t) {
  13671. t.name = t.name || "pixel-scale", t.zIndex = 1e3, !t.attrib.left && !t.attrib.right && (t.attrib.left = 10), !t.attrib.top && !t.attrib.bottom && (t.attrib.bottom = 10), super(t), this.allowable = 1e-3, this.fontSize = 12, this.padding = 4, this.getScaleUnit = (e) => Math.max(...e) * 1e4, this.getScaleText = (e) => e + "";
  13672. }
  13673. get height() {
  13674. return this.fontSize + this.padding;
  13675. }
  13676. initShape() {
  13677. const t = new Nt();
  13678. return t.add(
  13679. new Fn({
  13680. name: "scale-line",
  13681. points: [
  13682. 0,
  13683. this.height / 2,
  13684. 0,
  13685. this.height,
  13686. 100,
  13687. this.height,
  13688. 100,
  13689. this.height / 2
  13690. ],
  13691. strokeScaleEnabled: !1,
  13692. strokeWidth: 1.5,
  13693. stroke: "#fff"
  13694. }),
  13695. new dn({
  13696. name: "scale-text",
  13697. text: "",
  13698. fontFamily: "Calibri",
  13699. x: 0,
  13700. y: 0,
  13701. align: "center",
  13702. fontSize: this.fontSize,
  13703. fill: "#fff"
  13704. })
  13705. ), t;
  13706. }
  13707. setColor(t) {
  13708. this.shape.findOne(".scale-line").stroke(t), this.shape.findOne(".scale-text").fill(t);
  13709. }
  13710. diffRedraw() {
  13711. if (!this.mat || !this.pixelScale || isNaN(this.pixelScale))
  13712. return;
  13713. let t = 1, e, i;
  13714. for (let c = this.attrib.minWidth; c <= this.attrib.maxWidth; c++) {
  13715. const d = c * this.pixelScale, p = Ot(d, 10) - d;
  13716. if (p < this.allowable && d % 5 < 1) {
  13717. e = c, i = d;
  13718. break;
  13719. } else
  13720. p < t && (e = c, i = d, t = p);
  13721. }
  13722. if (e === 0 || i === 0)
  13723. return;
  13724. const n = this.shape.findOne(".scale-line"), r = this.shape.findOne(".scale-text"), a = n.points();
  13725. a[4] = a[6] = e, r.width(e), r.text(this.getScaleText(i));
  13726. const o = this.container.stage;
  13727. let h = this.attrib.left, l = this.attrib.top;
  13728. typeof h != "number" && typeof this.attrib.right == "number" && (h = o.width() - e - this.attrib.right), typeof l != "number" && typeof this.attrib.bottom == "number" && (l = o.height() - this.height - this.attrib.bottom);
  13729. const A = this.mat.point({ x: 1, y: 1 }), u = this.mat.point({ x: 0, y: 0 }), f = {
  13730. x: A.x - u.x,
  13731. y: A.y - u.y
  13732. };
  13733. this.shape.position(this.mat.point({ x: h, y: l })).scale(f), this.shape.draw();
  13734. }
  13735. setPixelScale(t, e) {
  13736. t = t.copy().invert();
  13737. const i = t.point({ x: 0, y: 0 }), n = t.point({ x: e[0], y: e[1] });
  13738. this.mat = t, this.pixelScale = this.getScaleUnit([
  13739. (n.x - i.x) / e[0],
  13740. (n.y - i.y) / e[1]
  13741. ]);
  13742. }
  13743. initReactive() {
  13744. const t = ({ mat: e, size: i }) => {
  13745. this.setPixelScale(e, i);
  13746. };
  13747. return this.container.bus.on("viewChange", t), mr(
  13748. super.initReactive(),
  13749. () => this.container.bus.off("viewChange", t)
  13750. );
  13751. }
  13752. mounted() {
  13753. super.mounted();
  13754. const t = this.container.stage;
  13755. this.setPixelScale(be(t, !0), [
  13756. t.width(),
  13757. t.height()
  13758. ]), console.log(t), t.on("click", (e) => {
  13759. console.log(
  13760. this.container.getRealFromStage([e.evt.offsetX, e.evt.offsetY])
  13761. );
  13762. });
  13763. }
  13764. }
  13765. const Vu = (s, t, e) => {
  13766. let i = e == null ? void 0 : e.getView();
  13767. const n = () => i.calculateExtent(e.getSize()), r = (h) => {
  13768. const l = Gu([
  13769. [h[0], h[1]],
  13770. [h[2], h[3]]
  13771. ]);
  13772. i.fit(l, {
  13773. size: e.getSize(),
  13774. padding: [0, 0, 0, 0]
  13775. // 根据需要调整边距
  13776. });
  13777. }, a = () => {
  13778. if (t && e) {
  13779. const h = n();
  13780. (!s.bound || di(s.bound, h)) && (s.setSize(t.offsetWidth, t.offsetHeight), s.setBound([h[0], h[3], h[2], h[1]]));
  13781. }
  13782. }, o = (h) => {
  13783. e && (i.removeEventListener("change:center", a), i.removeEventListener("change:resolution", a), e.removeEventListener("moveend", a)), i = h.getView(), i.addEventListener("change:center", a), i.addEventListener("change:resolution", a), e.addEventListener("moveend", a), e = h, a();
  13784. };
  13785. return s.enableMove((h) => (e && r(h), !0)), s.enableWheel((h) => (e && r(h), !0)), {
  13786. setMap: o,
  13787. setBoardBound: a,
  13788. setMountDom(h) {
  13789. t = h, a();
  13790. },
  13791. destory() {
  13792. i.removeEventListener("change:center", a), i.removeEventListener("change:resolution", a), e.removeEventListener("moveend", a);
  13793. }
  13794. };
  13795. };
  13796. function $u(s, t, e) {
  13797. const i = t.getSize();
  13798. s.width = i[0] * e, s.height = i[1] * e, s.style.width = i[0] + "px", s.style.height = i[1] + "px";
  13799. const n = s.getContext("2d"), r = t.getViewport().querySelector("canvas");
  13800. return n.drawImage(r, 0, 0, s.width, s.height), s.toDataURL();
  13801. }
  13802. const Wu = pu(
  13803. { polygons: Nu, compass: pn, scale: Hu },
  13804. { bound: new vu() }
  13805. );
  13806. Ud(5e6);
  13807. const v1 = (s = {}) => {
  13808. const t = {
  13809. id: "0",
  13810. x: 0,
  13811. y: 0,
  13812. type: "compass"
  13813. }, e = {
  13814. id: "0",
  13815. left: 20,
  13816. bottom: 20,
  13817. minWidth: 100,
  13818. maxWidth: 150
  13819. }, i = s.store || [
  13820. { id: "0", points: [], polygons: [], lines: [] }
  13821. ], n = Wu(s.dom, { polygons: i, compass: t, scale: e }, !1), r = Vu(n.bound, s.dom, s.map), a = (l = {}) => {
  13822. l.dom && (n.mount(l.dom), r.setMountDom(l.dom)), l.map && r.setMap(l.map);
  13823. };
  13824. a(s);
  13825. let o;
  13826. const h = n.tree.entrys.scale[0];
  13827. return h.allowable = 1e-11, h.getScaleUnit = (l) => {
  13828. if (!s.map)
  13829. return;
  13830. const f = s.map.getView().getProjection().getMetersPerUnit();
  13831. return l[0] * f;
  13832. }, h.getScaleText = (l) => l > 1e3 ? Ot(l / 1e3, 1) + " km" : Math.floor(l) + " m", {
  13833. raw: n,
  13834. scale: h,
  13835. setProps: a,
  13836. getData() {
  13837. return n.getData().polygons[0];
  13838. },
  13839. setData(l) {
  13840. n.setData({ polygons: [l], compass: t, scale: e });
  13841. },
  13842. destory() {
  13843. r.destory(), n.destory();
  13844. },
  13845. get polygon() {
  13846. return n.tree.children[0];
  13847. },
  13848. getPixelFromCoordinate(l) {
  13849. return n.tree.getPixelFromStage(l);
  13850. },
  13851. async toDataURL(l = 1) {
  13852. const A = n.tree.stage.toDataURL({ pixelRatio: l });
  13853. if (!s.map)
  13854. return A;
  13855. const u = [n.tree.stage.width(), n.tree.stage.height()];
  13856. o || (o = document.createElement("canvas")), o.width = u[0] * l, o.height = u[1] * l, o.style.width = u[0] + "px", o.style.height = u[1] + "px";
  13857. const f = o.getContext("2d");
  13858. return f.clearRect(0, 0, o.width, o.height), f.save(), $u(o, s.map, l), f.restore(), new Promise((c, d) => {
  13859. const p = new Image();
  13860. p.src = A, p.onload = () => {
  13861. f.drawImage(
  13862. p,
  13863. 0,
  13864. 0,
  13865. o.width,
  13866. o.height
  13867. );
  13868. const m = o.toDataURL("image/png");
  13869. c(m);
  13870. }, p.onerror = d;
  13871. });
  13872. }
  13873. };
  13874. };
  13875. export {
  13876. vu as BoundQueryPlugin,
  13877. m1 as CameraQueryPlugin,
  13878. uu as Container,
  13879. qt as DEV,
  13880. p1 as EditPoi,
  13881. f1 as EditWholeLine,
  13882. ie as Entity,
  13883. y1 as HistoryPlugin,
  13884. g1 as PenEditWholeLine,
  13885. Lu as PoPath,
  13886. Iu as PoPoint,
  13887. pn as Poi,
  13888. Nu as Polygons,
  13889. vo as RelationshipEnum,
  13890. Ri as WholeLine,
  13891. Qt as WholeLineLine,
  13892. ar as WholeLineLineHelper,
  13893. Tt as WholeLinePoint,
  13894. or as WholeLinePointHelper,
  13895. Li as WholeLinePolygon,
  13896. o1 as addEntityAttrib,
  13897. Cl as analysisSvg,
  13898. Xu as changeEnv,
  13899. cu as closePenPolygonActShapeFactory,
  13900. VA as copyEntityAttrib,
  13901. v1 as createBoard,
  13902. Ke as createLineByDire,
  13903. fu as defaultPoiShapeFactory,
  13904. Ts as depPartialUpdate,
  13905. s1 as deptComputed,
  13906. xo as disableMouse,
  13907. bo as enableMouse,
  13908. $A as entityActiveDualControl,
  13909. HA as entityFactory,
  13910. l1 as entitysActiveDualControl,
  13911. oe as eqPoint,
  13912. Ws as fixWholeLineConfig,
  13913. zA as generateId,
  13914. nh as generateWholeLineLineId,
  13915. sh as generateWholeLinePointId,
  13916. rh as generateWholeLinePoygonId,
  13917. be as getAbsoluteTransform,
  13918. Is as getActiveKey,
  13919. Rn as getChangeAllPoart,
  13920. Co as getChangePart,
  13921. Xe as getDire2Angle,
  13922. Qu as getDireDist,
  13923. Mo as getFlatChildren,
  13924. TA as getLine2Angle,
  13925. Zu as getLineCenter,
  13926. ce as getLineDire,
  13927. LA as getLineDireAngle,
  13928. Et as getLineDist,
  13929. t1 as getLineInnerContinuityPoints,
  13930. _o as getLineIntersection,
  13931. OA as getLineNearPoint,
  13932. NA as getLineNearPointDist,
  13933. Ui as getLineProjection,
  13934. RA as getLineRelationship,
  13935. Gt as getRealAbsoluteSize,
  13936. DA as getRotateDire,
  13937. ju as getTfScaleFactors,
  13938. ao as getTouchOffset,
  13939. IA as getVerticaLineDire,
  13940. pr as getVerticalDire,
  13941. Ku as getVerticalDireLine,
  13942. pi as getWholeLineLine,
  13943. Ah as getWholeLineLineNdxByPointIds,
  13944. wt as getWholeLineLineRaw,
  13945. c1 as getWholeLineLines,
  13946. d1 as getWholeLineLinesByPointId,
  13947. oh as getWholeLineLinesRaw,
  13948. Vd as getWholeLineLinesRawByPoint,
  13949. ah as getWholeLineLinesRawByPointId,
  13950. Hd as getWholeLineLinesRawByPointIds,
  13951. Pe as getWholeLinePoint,
  13952. Jd as getWholeLinePointMerge,
  13953. _t as getWholeLinePoints,
  13954. u1 as getWholeLinePolygonByPoint,
  13955. $d as getWholeLinePolygonLines,
  13956. lh as getWholeLinePolygonLinesByPoint,
  13957. hh as getWholeLinePolygonLinesRaw,
  13958. ri as getWholeLinePolygonPoints,
  13959. yi as getWholeLinePolygonRaw,
  13960. hn as hasTouchEvents,
  13961. di as inRevise,
  13962. Pt as incEntitysFactoryGenerate,
  13963. gu as injectPoiType,
  13964. no as isMobile,
  13965. ul as isTablet,
  13966. Si as mergeChange,
  13967. mr as mergeFuns,
  13968. tu as mergeWholeLinePointsByPoint,
  13969. hu as needUpdatePolygonClose,
  13970. GA as objectToString,
  13971. ln as openEntityDrag,
  13972. yr as openShapeDrag,
  13973. ma as openShapeMouseStyles,
  13974. r1 as partialComputed,
  13975. Ml as pathsToActShape,
  13976. Au as penLineActShapeFactory,
  13977. du as penPolygonActShapeFactory,
  13978. ja as penWholeLinePoygonsEdit,
  13979. ou as penWholeLinePoygonsEditWithHelperMouse,
  13980. Lr as penWholeLinePoygonsEditWithHelperShapesMouse,
  13981. gh as poiTypes,
  13982. Ju as polygonCounterclockwise,
  13983. pu as register,
  13984. eu as repeatMoveWholeLineLine,
  13985. Qd as repeatablePushWholeLinePoint,
  13986. Kd as repeatableWholeLineLineIntersections,
  13987. Ot as round,
  13988. Ud as setGenerateStartId,
  13989. i1 as setShapeConfig,
  13990. So as shapeParentsEq,
  13991. e1 as shapeTreeContain,
  13992. wo as shapeTreeEq,
  13993. Zd as spliceWholeLineLineByLines,
  13994. $s as spliceWholeLineLineByPoint,
  13995. a1 as testPoint,
  13996. An as toRawType,
  13997. BA as toTypeString,
  13998. h1 as updateEntityStatus,
  13999. n1 as watchAttribs,
  14000. ue as wholeLineAddLineByPointIds,
  14001. Ze as wholeLineAddPoint,
  14002. lu as wholeLineAnalysisHelperInfo,
  14003. ai as wholeLineDelLineByPointIds,
  14004. Wa as wholeLineDelPointByPointIds,
  14005. ch as wholeLineDelPolygon,
  14006. Xd as wholeLineFixLineAddPoint,
  14007. hr as wholeLineLineAddPoint,
  14008. Wd as wholeLineLineIsolatePoint,
  14009. qd as wholeLinePolygonAddPoint,
  14010. jd as wholeLinePolygonLastAddPoint,
  14011. lr as wholeLineReplacePoint,
  14012. A1 as wholeLineStyle
  14013. };