You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5747 lines
705 KiB

/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var Bo=Object.create;var Kt=Object.defineProperty;var Po=Object.getOwnPropertyDescriptor;var Io=Object.getOwnPropertyNames;var ko=Object.getPrototypeOf,Uo=Object.prototype.hasOwnProperty;var Fi=n=>Kt(n,"__esModule",{value:!0});var M0=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Oo=(n,e)=>{Fi(n);for(var t in e)Kt(n,t,{get:e[t],enumerable:!0})},Go=(n,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Io(e))!Uo.call(n,i)&&i!=="default"&&Kt(n,i,{get:()=>e[i],enumerable:!(t=Po(e,i))||t.enumerable});return n},w2=n=>Go(Fi(Kt(n!=null?Bo(ko(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var Bi=M0(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});require("obsidian");var qo=n=>{var e;return n?(e=n.plugins.plugins.dataview)===null||e===void 0?void 0:e.api:window.DataviewAPI},Wo=n=>n.plugins.enabledPlugins.has("dataview");Jt.getAPI=qo;Jt.isPluginEnabled=Wo});var Ma=M0((s6,bt)=>{(function(n){var e=typeof s6=="object"&&s6,t=typeof bt=="object"&&bt&&bt.exports==e&&bt,i=typeof global=="object"&&global;(i.global===i||i.window===i)&&(n=i);var a=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,r=/[\x01-\x7F]/g,s=/[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,o=/<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g,c={"\xAD":"shy","\u200C":"zwnj","\u200D":"zwj","\u200E":"lrm","\u2063":"ic","\u2062":"it","\u2061":"af","\u200F":"rlm","\u200B":"ZeroWidthSpace","\u2060":"NoBreak","\u0311":"DownBreve","\u20DB":"tdot","\u20DC":"DotDot"," ":"Tab","\n":"NewLine","\u2008":"puncsp","\u205F":"MediumSpace","\u2009":"thinsp","\u200A":"hairsp","\u2004":"emsp13","\u2002":"ensp","\u2005":"emsp14","\u2003":"emsp","\u2007":"numsp","\xA0":"nbsp","\u205F\u200A":"ThickSpace","\u203E":"oline",_:"lowbar","\u2010":"dash","\u2013":"ndash","\u2014":"mdash","\u2015":"horbar",",":"comma",";":"semi","\u204F":"bsemi",":":"colon","\u2A74":"Colone","!":"excl","\xA1":"iexcl","?":"quest","\xBF":"iquest",".":"period","\u2025":"nldr","\u2026":"mldr","\xB7":"middot","'":"apos","\u2018":"lsquo","\u2019":"rsquo","\u201A":"sbquo","\u2039":"lsaquo","\u203A":"rsaquo",'"':"quot","\u201C":"ldquo","\u201D":"rdquo","\u201E":"bdquo","\xAB":"laquo","\xBB":"raquo","(":"lpar",")":"rpar","[":"lsqb","]":"rsqb","{":"lcub","}":"rcub","\u2308":"lceil","\u2309":"rceil","\u230A":"lfloor","\u230B":"rfloor","\u2985":"lopar","\u2986":"ropar","\u298B":"lbrke","\u298C":"rbrke","\u298D":"lbrkslu","\u298E":"rbrksld","\u298F":"lbrksld","\u2990":"rbrkslu","\u2991":"langd","\u2992":"rangd","\u2993":"lparlt","\u2994":"rpargt","\u2995":"gtlPar","\u2996":"ltrPar","\u27E6":"lobrk","\u27E7":"robrk","\u27E8":"lang","\u27E9":"rang","\u27EA":"Lang","\u27EB":"Rang","\u27EC":"loang","\u27ED":"roang","\u2772":"lbbrk","\u2773":"rbbrk","\u2016":"Vert","\xA7":"sect","\xB6":"para","@":"commat","*":"ast","/":"sol",undefined:null,"&":"amp","#":"num","%":"percnt","\u2030":"permil","\u2031":"pertenk","\u2020":"dagger","\u2021":"Dagger","\u2022":"bull","\u2043":"hybull","\u2032":"prime","\u2033":"Prime","\u2034":"tprime","\u2057":"qprime","\u2035":"bprime","\u2041":"caret","`":"grave","\xB4":"acute","\u02DC":"tilde","^":"Hat","\xAF":"macr","\u02D8":"breve","\u02D9":"dot","\xA8":"die","\u02DA":"ring","\u02DD":"dblac","\xB8":"cedil","\u02DB":"ogon","\u02C6":"circ","\u02C7":"caron","\xB0":"deg","\xA9":"copy","\xAE":"reg","\u2117":"copysr","\u2118":"wp","\u211E":"rx","\u2127":"mho","\u2129":"iiota","\u2190":"larr","\u219A":"nlarr","\u2192":"rarr","\u219B":"nrarr","\u2191":"uarr","\u2193":"darr","\u2194":"harr","\u21AE":"nharr","\u2195":"varr","\u2196":"nwarr","\u2197":"nearr","\u2198":"searr","\u2199":"swarr","\u219D":"rarrw","\u219D\u0338":"nrarrw","\u219E":"Larr","\u219F":"Uarr","\u21A0":"Rarr","\u21A1":"Darr","\u21A2":"larrtl","\u21A3":"rarrtl","\u21A4":"mapstoleft","\u21A5":"mapstoup","\u21A6":"map","\u21A7":"mapstodown","\u21A9":"larrhk","\u21AA":"rarrhk","\u21AB":"larrlp","\u21AC":"rarrlp","\u21AD":"harrw","\u21B0":"lsh","\u21B1":"rsh","\u21B2":"ldsh","\u21B3":"rdsh","\u21B5":"crarr","\u21B6":"cularr","\u21B7":"curarr","\u21BA":"olarr","\u21BB":"orarr","\u21BC":"lharu","\u21BD":"lhard","\u21BE":"uharr","\u21BF":"uharl","\u21C0":"rharu","\u21C1":"rhard","\u21C2":"dharr","\u21C3":"dharl","\u21C4":"rlarr","\u21C5":"udarr","\u21C6":"lrarr","\u21C7":"llarr","\u21C8":"uuarr","\u21C9":"rrarr","\u21CA":"ddarr","\u21CB":"lrhar","\u21CC":"rlhar","\u21D0":"lArr","\u21CD":"nlArr","\u21D1":"uArr","\u21D2":"rArr","\u21CF":"nrArr","\u21D3":"dArr","\u21D4":"iff","\u21CE":"nhArr","\u21D5":"vArr","\u21D6":"nwArr","\u21D7":"neArr","\u21D8":"seArr","\u21D9":"swArr","\u21DA":"lAarr","\u21DB":"rAarr","\u21DD":"zigrarr","\u21E4":"larrb","\u21E5":"rarrb","\u21F5":"duarr","\u21FD":"loarr","\u21FE":"roarr","\u21FF":"hoarr","\u2200":"forall","\u2201":"comp","\u2202":"part","\u2202\u0338":"npart","\u2203":"exist","\u2204":"nexist","\u2205":"empty","\u2207":"Del","\u2208":"in","\u2209":"notin","\u220B":"ni","\u220C":"notni","\u03F6":"bepsi","\u220F":"prod","\u2210":"coprod","\u2211":"sum","+":"plus","\xB1":"pm","\xF7":"div","\xD7":"times","<":"lt","\u226E":"nlt","<\u20D2":"nvlt","=":"equals","\u2260":"ne","=\u20E5":"bne","\u2A75":"Equal",">":"gt","\u226F":"ngt",">\u20D2":"nvgt","\xAC":"not","|":"vert","\xA6":"brvbar","\u2212":"minus","\u2213":"mp","\u2214":"plusdo","\u2044":"frasl","\u2216":"setmn","\u2217":"lowast","\u2218":"compfn","\u221A":"Sqrt","\u221D":"prop","\u221E":"infin","\u221F":"angrt","\u2220":"ang","\u2220\u20D2":"nang","\u2221":"angmsd","\u2222":"angsph","\u2223":"mid","\u2224":"nmid","\u2225":"par","\u2226":"npar","\u2227":"and","\u2228":"or","\u2229":"cap","\u2229\uFE00":"caps","\u222A":"cup","\u222A\uFE00":"cups","\u222B":"int","\u222C":"Int","\u222D":"tint","\u2A0C":"qint","\u222E":"oint","\u222F":"Conint","\u2230":"Cconint","\u2231":"cwint","\u2232":"cwconint","\u2233":"awconint","\u2234":"there4","\u2235":"becaus","\u2236":"ratio","\u2237":"Colon","\u2238":"minusd","\u223A":"mDDot","\u223B":"homtht","\u223C":"sim","\u2241":"nsim","\u223C\u20D2":"nvsim","\u223D":"bsim","\u223D\u0331":"race","\u223E":"ac","\u223E\u0333":"acE","\u223F":"acd","\u2240":"wr","\u2242":"esim","\u2242\u0338":"nesim","\u2243":"sime","\u2244":"nsime","\u2245":"cong","\u2247":"ncong","\u2246":"simne","\u2248":"ap","\u2249":"nap","\u224A":"ape","\u224B":"apid","\u224B\u0338":"napid","\u224C":"bcong","\u224D":"CupCap","\u226D":"NotCupCap","\u224D\u20D2":"nvap","\u224E":"bump","\u224E\u0338":"nbump","\u224F":"bumpe","\u224F\u0338":"nbumpe","\u2250":"doteq","\u2250\u0338":"nedot","\u2251":"eDot","\u2252":"efDot","\u2253":"erDot","\u2254":"colone","\u2255":"ecolon","\u2256":"ecir","\u2257":"cire","\u2259":"wedgeq","\u225A":"veeeq","\u225C":"trie","\u225F":"equest","\u2261":"equiv","\u2262":"nequiv","\u2261\u20E5":"bnequiv","\u2264":"le","\u2270":"nle","\u2264\u20D2":"nvle","\u2265":"ge","\u2271":"nge","\u2265\u20D2":"nvge","\u2266":"lE","\u2266\u0338":"nlE","\u2267":"gE","\u2267\u0338":"ngE","\u2268\uFE00":"lvnE","\u2268":"lnE","\u2269":"gnE","\u2269\uFE00":"gvnE","\u226A":"ll","\u226A\u0338":"nLtv","\u226A\u20D2":"nLt","\u226B":"gg","\u226B\u0338":"nGtv","\u226B\u20D2":"nGt","\u226C":"twixt","\u2272":"lsim","\u2274":"nlsim","\u2273":"gsim","\u2275":"ngsim","\u2276":"lg","\u2278":"ntlg","\u2277":"gl","\u2279":"ntgl","\u227A":"pr","\u2280":"npr","\u227B":"sc","\u2281":"nsc","\u227C":"prcue","\u22E0":"nprcue","\u227D":"sccue","\u22E1":"nsccue","\u227E":"prsim","\u227F":"scsim","\u227F\u0338":"NotSucceedsTilde","\u2282":"sub","\u2284":"nsub","\u2282\u20D2":"vnsub","\u2283":"sup","\u2285":"nsup","\u2283\u20D2":"vnsup","\u2286":"sube","\u2288":"nsube","\u2287":"supe","\u2289":"nsupe","\u228A\uFE00":"vsubne","\u228A":"subne","\u228B\uFE00":"vsupne","\u228B":"supne","\u228D":"cupdot","\u228E":"uplus","\u228F":"sqsub","\u228F\u0338":"NotSquareSubset","\u2290":"sqsup","\u2290\u0338":"NotSquareSuperset","\u2291":"sqsube","\u22E2":"nsqsube","\u2292":"sqsupe","\u22E3":"nsqsupe","\u2293":"sqcap","\u2293\uFE00":"sqcaps","\u2294":"sqcup","\u2294\uFE00":"sqcups","\u2295":"oplus","\u2296":"ominus","\u2297":"otimes","\u2298":"osol","\u2299":"odot","\u229A":"ocir","\u229B":"oast","\u229D":"odash","\u229E":"plusb","\u229F":"minusb","\u22A0":"timesb","\u22A1":"sdotb","\u22A2":"vdash","\u22AC":"nvdash","\u22A3":"dashv","\u22A4":"top","\u22A5":"bot","\u22A7":"models","\u22A8":"vDash","\u22AD":"nvDash","\u22A9":"Vdash","\u22AE":"nVdash","\u22AA":"Vvdash","\u22AB":"VDash","\u22AF":"nVDash","\u22B0":"prurel","\u22B2":"vltri","\u22EA":"nltri","\u22B3":"vrtri","\u22EB":"nrtri","\u22B4":"ltrie","\u22EC":"nltrie","\u22B4\u20D2":"nvltrie","\u22B5":"rtrie","\u22ED":"nrtrie","\u22B5\u20D2":"nvrtrie","\u22B6":"origof","\u22B7":"imof","\u22B8":"mumap","\u22B9":"hercon","\u22BA":"intcal","\u22BB":"veebar","\u22BD":"barvee","\u22BE":"angrtvb","\u22BF":"lrtri","\u22C0":"Wedge","\u22C1":"Vee","\u22C2":"xcap","\u22C3":"xcup","\u22C4":"diam","\u22C5":"sdot","\u22C6":"Star","\u22C7":"divonx","\u22C8":"bowtie","\u22C9":"ltimes","\u22CA":"rtimes","\u22CB":"lthree","\u22CC":"rthree","\u22CD":"bsime","\u22CE":"cuvee","\u22CF":"cuwed","\u22D0":"Sub","\u22D1":"Sup","\u22D2":"Cap","\u22D3":"Cup","\u22D4":"fork","\u22D5":"epar","\u22D6":"ltdot","\u22D7":"gtdot","\u22D8":"Ll","\u22D8\u0338":"nLl","\u22D9":"Gg","\u22D9\u0338":"nGg","\u22DA\uFE00":"lesg","\u22DA":"leg","\u22DB":"gel","\u22DB\uFE00":"gesl","\u22DE":"cuepr","\u22DF":"cuesc","\u22E6":"lnsim","\u22E7":"gnsim","\u22E8":"prnsim","\u22E9":"scnsim","\u22EE":"vellip","\u22EF":"ctdot","\u22F0":"utdot","\u22F1":"dtdot","\u22F2":"disin","\u22F3":"isinsv","\u22F4":"isins","\u22F5":"isindot","\u22F5\u0338":"notindot","\u22F6":"notinvc","\u22F7":"notinvb","\u22F9":"isinE","\u22F9\u0338":"notinE","\u22FA":"nisd","\u22FB":"xnis","\u22FC":"nis","\u22FD":"notnivc","\u22FE":"notnivb","\u2305":"barwed","\u2306":"Barwed","\u230C":"drcrop","\u230D":"dlcrop","\u230E":"urcrop","\u230F":"ulcrop","\u2310":"bnot","\u2312":"profline","\u2313":"profsurf","\u2315":"telrec","\u2316":"target","\u231C":"ulcorn","\u231D":"urcorn","\u231E":"dlcorn","\u231F":"drcorn","\u2322":"frown","\u2323":"smile","\u232D":"cylcty","\u232E":"profalar","\u2336":"topbot","\u233D":"ovbar","\u233F":"solbar","\u237C":"angzarr","\u23B0":"lmoust","\u23B1":"rmoust","\u23B4":"tbrk","\u23B5":"bbrk","\u23B6":"bbrktbrk","\u23DC":"OverParenthesis","\u23DD":"UnderParenthesis","\u23DE":"OverBrace","\u23DF":"UnderBrace","\u23E2":"trpezium","\u23E7":"elinters","\u2423":"blank","\u2500":"boxh","\u2502":"boxv","\u250C":"boxdr","\u2510":"boxdl","\u2514":"boxur","\u2518":"boxul","\u251C":"boxvr","\u2524":"boxvl","\u252C":"boxhd","\u2534":"boxhu","\u253C":"boxvh","\u2550":"boxH","\u2551":"boxV","\u2552":"boxdR","\u2553":"boxDr","\u2554":"boxDR","\u2555":"boxdL","\u2556":"boxDl","\u2557":"boxDL","\u2558":"boxuR","\u2559":"boxUr","\u255A":"boxUR","\u255B":"boxuL","\u255C":"boxUl","\u255D":"boxUL","\u255E":"boxvR","\u255F":"boxVr","\u2560":"boxVR","\u2561":"boxvL","\u2562":"boxVl","\u2563":"boxVL","\u2564":"boxHd","\u2565":"boxhD","\u2566":"boxHD","\u2567":"boxHu","\u2568":"boxhU","\u2569":"boxHU","\u256A":"boxvH","\u256B":"boxVh","\u256C":"boxVH","\u2580":"uhblk","\u2584":"lhblk","\u2588":"block","\u2591":"blk14","\u2592":"blk12","\u2593":"blk34","\u25A1":"squ","\u25AA":"squf","\u25AB":"EmptyVerySmallSquare","\u25AD":"rect","\u25AE":"marker","\u25B1":"fltns","\u25B3":"xutri","\u25B4":"utrif","\u25B5":"utri","\u25B8":"rtrif","\u25B9":"rtri","\u25BD":"xdtri","\u25BE":"dtrif","\u25BF":"dtri","\u25C2":"ltrif","\u25C3":"ltri","\u25CA":"loz","\u25CB":"cir","\u25EC":"tridot","\u25EF":"xcirc","\u25F8":"ultri","\u25F9":"urtri","\u25FA":"lltri","\u25FB":"EmptySmallSquare","\u25FC":"FilledSmallSquare","\u2605":"starf","\u2606":"star","\u260E":"phone","\u2640":"female","\u2642":"male","\u2660":"spades","\u2663":"clubs","\u2665":"hearts","\u2666":"diams","\u266A":"sung","\u2713":"check","\u2717":"cross","\u2720":"malt","\u2736":"sext","\u2758":"VerticalSeparator","\u27C8":"bsolhsub","\u27C9":"suphsol","\u27F5":"xlarr","\u27F6":"xrarr","\u27F7":"xharr","\u27F8":"xlArr","\u27F9":"xrArr","\u27FA":"xhArr","\u27FC":"xmap","\u27FF":"dzigrarr","\u2902":"nvlArr","\u2903":"nvrArr","\u2904":"nvHarr","\u2905":"Map","\u290C":"lbarr","\u290D":"rbarr","\u290E":"lBarr","\u290F":"rBarr","\u2910":"RBarr","\u2911":"DDotrahd","\u2912":"UpArrowBar","\u2913":"DownArrowBar","\u2916":"Rarrtl","\u2919":"latail","\u291A":"ratail","\u291B":"lAtail","\u291C":"rAtail","\u291D":"larrfs","\u291E":"rarrfs","\u291F":"larrbfs","\u2920":"rarrbfs","\u2923":"nwarhk","\u2924":"nearhk","\u2925":"searhk","\u2926":"swarhk","\u2927":"nwnear","\u2928":"toea","\u2929":"tosa","\u292A":"swnwar","\u2933":"rarrc","\u2933\u0338":"nrarrc","\u2935":"cudarrr","\u2936":"ldca","\u2937":"rdca","\u2938":"cudarrl","\u2939":"larrpl","\u293C":"curarrm","\u293D":"cularrp","\u2945":"rarrpl","\u2948":"harrcir","\u2949":"Uarrocir","\u294A":"lurdshar","\u294B":"ldrushar","\u294E":"LeftRightVector","\u294F":"RightUpDownVector","\u2950":"DownLeftRightVector","\u2951":"LeftUpDownVector","\u2952":"LeftVectorBar","\u2953":"RightVectorBar","\u2954":"RightUpVectorBar","\u2955":"RightDownVectorBar","\u2956":"DownLeftVectorBar","\u2957":"DownRightVectorBar","\u2958":"LeftUpVectorBar","\u2959":"LeftDownVectorBar","\u295A":"LeftTeeVector","\u295B":"RightTeeVector","\u295C":"RightUpTeeVector","\u295D":"RightDownTeeVector","\u295E":"DownLeftTeeVector","\u295F":"DownRightTeeVector","\u2960":"LeftUpTeeVector","\u2961":"LeftDownTeeVector","\u2962":"lHar","\u2963":"uHar","\u2964":"rHar","\u2965":"dHar","\u2966":"luruhar","\u2967":"ldrdhar","\u2968":"ruluhar","\u2969":"rdldhar","\u296A":"lharul","\u296B":"llhard","\u296C":"rharul","\u296D":"lrhard","\u296E":"udhar","\u296F":"duhar","\u2970":"RoundImplies","\u2971":"erarr","\u2972":"simrarr","\u2973":"larrsim","\u2974":"rarrsim","\u2975":"rarrap","\u2976":"ltlarr","\u2978":"gtrarr","\u2979":"subrarr","\u297B":"suplarr","\u297C":"lfisht","\u297D":"rfisht","\u297E":"ufisht","\u297F":"dfisht","\u299A":"vzigzag","\u299C":"vangrt","\u299D":"angrtvbd","\u29A4":"ange","\u29A5":"range","\u29A6":"dwangle","\u29A7":"uwangle","\u29A8":"angmsdaa","\u29A9":"angmsdab","\u29AA":"angmsdac","\u29AB":"angmsdad","\u29AC":"angmsdae","\u29AD":"angmsdaf","\u29AE":"angmsdag","\u29AF":"angmsdah","\u29B0":"bemptyv","\u29B1":"demptyv","\u29B2":"cemptyv","\u29B3":"raemptyv","\u29B4":"laemptyv","\u29B5":"ohbar","\u29B6":"omid","\u29B7":"opar","\u29B9":"operp","\u29BB":"olcross","\u29BC":"odsold","\u29BE":"olcir","\u29BF":"ofcir","\u29C0":"olt","\u29C1":"ogt","\u29C2":"cirscir","\u29C3":"cirE","\u29C4":"solb","\u29C5":"bsolb","\u29C9":"boxbox","\u29CD":"trisb","\u29CE":"rtriltri","\u29CF":"LeftTriangleBar","\u29CF\u0338":"NotLeftTriangleBar","\u29D0":"RightTriangleBar","\u29D0\u0338":"NotRightTriangleBar","\u29DC":"iinfin","\u29DD":"infintie","\u29DE":"nvinfin","\u29E3":"eparsl","\u29E4":"smeparsl","\u29E5":"eqvparsl","\u29EB":"lozf","\u29F4":"RuleDelayed","\u29F6":"dsol","\u2A00":"xodot","\u2A01":"xoplus","\u2A02":"xotime","\u2A04":"xuplus","\u2A06":"xsqcup","\u2A0D":"fpartint","\u2A10":"cirfnint","\u2A11":"awint","\u2A12":"rppolint","\u2A13":"scpolint","\u2A14":"npolint","\u2A15":"pointint","\u2A16":"quatint","\u2A17":"intlarhk","\u2A22":"pluscir","\u2A23":"plusacir","\u2A24":"simplus","\u2A25":"plusdu","\u2A26":"plussim","\u2A27":"plustwo","\u2A29":"mcomma","\u2A2A":"minusdu","\u2A2D":"loplus","\u2A2E":"roplus","\u2A2F":"Cross","\u2A30":"timesd","\u2A31":"timesbar","\u2A33":"smashp","\u2A34":"lotimes","\u2A35":"rotimes","\u2A36":"otimesas","\u2A37":"Otimes","\u2A38":"odiv","\u2A39":"triplus","\u2A3A":"triminus","\u2A3B":"tritime","\u2A3C":"iprod","\u2A3F":"amalg","\u2A40":"capdot","\u2A42":"ncup","\u2A43":"ncap","\u2A44":"capand","\u2A45":"cupor","\u2A46":"cupcap","\u2A47":"capcup","\u2A48":"cupbrcap","\u2A49":"capbrcup","\u2A4A":"cupcup","\u2A4B":"capcap","\u2A4C":"ccups","\u2A4D":"ccaps","\u2A50":"ccupssm","\u2A53":"And","\u2A54":"Or","\u2A55":"andand","\u2A56":"oror","\u2A57":"orslope","\u2A58":"andslope","\u2A5A":"andv","\u2A5B":"orv","\u2A5C":"andd","\u2A5D":"ord","\u2A5F":"wedbar","\u2A66":"sdote","\u2A6A":"simdot","\u2A6D":"congdot","\u2A6D\u0338":"ncongdot","\u2A6E":"easter","\u2A6F":"apacir","\u2A70":"apE","\u2A70\u0338":"napE","\u2A71":"eplus","\u2A72":"pluse","\u2A73":"Esim","\u2A77":"eDDot","\u2A78":"equivDD","\u2A79":"ltcir","\u2A7A":"gtcir","\u2A7B":"ltquest","\u2A7C":"gtquest","\u2A7D":"les","\u2A7D\u0338":"nles","\u2A7E":"ges","\u2A7E\u0338":"nges","\u2A7F":"lesdot","\u2A80":"gesdot","\u2A81":"lesdoto","\u2A82":"gesdoto","\u2A83":"lesdotor","\u2A84":"gesdotol","\u2A85":"lap","\u2A86":"gap","\u2A87":"lne","\u2A88":"gne","\u2A89":"lnap","\u2A8A":"gnap","\u2A8B":"lEg","\u2A8C":"gEl","\u2A8D":"lsime","\u2A8E":"gsime","\u2A8F":"lsimg","\u2A90":"gsiml","\u2A91":"lgE","\u2A92":"glE","\u2A93":"lesges","\u2A94":"gesles","\u2A95":"els","\u2A96":"egs","\u2A97":"elsdot","\u2A98":"egsdot","\u2A99":"el","\u2A9A":"eg","\u2A9D":"siml","\u2A9E":"simg","\u2A9F":"simlE","\u2AA0":"simgE","\u2AA1":"LessLess","\u2AA1\u0338":"NotNestedLessLess","\u2AA2":"GreaterGreater","\u2AA2\u0338":"NotNestedGreaterGreater","\u2AA4":"glj","\u2AA5":"gla","\u2AA6":"ltcc","\u2AA7":"gtcc","\u2AA8":"lescc","\u2AA9":"gescc","\u2AAA":"smt","\u2AAB":"lat","\u2AAC":"smte","\u2AAC\uFE00":"smtes","\u2AAD":"late","\u2AAD\uFE00":"lates","\u2AAE":"bumpE","\u2AAF":"pre","\u2AAF\u0338":"npre","\u2AB0":"sce","\u2AB0\u0338":"nsce","\u2AB3":"prE","\u2AB4":"scE","\u2AB5":"prnE","\u2AB6":"scnE","\u2AB7":"prap","\u2AB8":"scap","\u2AB9":"prnap","\u2ABA":"scnap","\u2ABB":"Pr","\u2ABC":"Sc","\u2ABD":"subdot","\u2ABE":"supdot","\u2ABF":"subplus","\u2AC0":"supplus","\u2AC1":"submult","\u2AC2":"supmult","\u2AC3":"subedot","\u2AC4":"supedot","\u2AC5":"subE","\u2AC5\u0338":"nsubE","\u2AC6":"supE","\u2AC6\u0338":"nsupE","\u2AC7":"subsim","\u2AC8":"supsim","\u2ACB\uFE00":"vsubnE","\u2ACB":"subnE","\u2ACC\uFE00":"vsupnE","\u2ACC":"supnE","\u2ACF":"csub","\u2AD0":"csup","\u2AD1":"csube","\u2AD2":"csupe","\u2AD3":"subsup","\u2AD4":"supsub","\u2AD5":"subsub","\u2AD6":"supsup","\u2AD7":"suphsub","\u2AD8":"supdsub","\u2AD9":"forkv","\u2ADA":"topfork","\u2ADB":"mlcp","\u2AE4":"Dashv","\u2AE6":"Vdashl","\u2AE7":"Barv","\u2AE8":"vBar","\u2AE9":"vBarv","\u2AEB":"Vbar","\u2AEC":"Not","\u2AED":"bNot","\u2AEE":"rnmid","\u2AEF":"cirmid","\u2AF0":"midcir","\u2AF1":"topcir","\u2AF2":"nhpar","\u2AF3":"parsim","\u2AFD":"parsl","\u2AFD\u20E5":"nparsl","\u266D":"flat","\u266E":"natur","\u266F":"sharp","\xA4":"curren","\xA2":"cent",$:"dollar","\xA3":"pound","\xA5":"yen","\u20AC":"euro","\xB9":"sup1","\xBD":"half","\u2153":"frac13","\xBC":"frac14","\u2155":"frac15","\u2159":"frac16","\u215B":"frac18","\xB2":"sup2","\u2154":"frac23","\u2156":"frac25","\xB3":"sup3","\xBE":"frac34","\u2157":"frac35","\u215C":"frac38","\u2158":"frac45","\u215A":"frac56","\u215D":"frac58","\u215E":"frac78","\u{1D4B6}":"ascr","\u{1D552}":"aopf","\u{1D51E}":"afr","\u{1D538}":"Aopf","\u{1D504}":"Afr","\u{1D49C}":"Ascr",\u00AA:"ordf",\u00E1:"aacute",\u00C1:"Aacute",\u00E0:"agrave",\u00C0:"Agrave",\u0103:"abreve",\u0102:"Abreve",\u00E2:"acirc",\u00C2:"Acirc",\u00E5:"aring",\u00C5:"angst",\u00E4:"auml",\u00C4:"Auml",\u00E3:"atilde",\u00C3:"Atilde",\u0105:"aogon",\u0104:"Aogon",\u0101:"amacr",\u0100:"Amacr",\u00E6:"aelig",\u00C6:"AElig","\u{1D4B7}":"bscr","\u{1D553}":"bopf","\u{1D51F}":"bfr","\u{1D539}":"Bopf",\u212C:"Bscr","\u{1D505}":"Bfr","\u{1D520}":"cfr","\u{1D4B8}":"cscr","\u{1D554}":"copf",\u212D:"Cfr","\u{1D49E}":"Cscr",\u2102:"Copf",\u0107:"cacute",\u0106:"Cacute",\u0109:"ccirc",\u0108:"Ccirc",\u010D:"ccaron",\u010C:"Ccaron",\u010B:"cdot",\u010A:"Cdot",\u00E7:"ccedil",\u00C7:"Ccedil","\u2105":"incare","\u{1D521}":"dfr","\u2146":"dd","\u{1D555}":"dopf","\u{1D4B9}":"dscr","\u{1D49F}":"Dscr","\u{1D507}":"Dfr","\u2145":"DD","\u{1D53B}":"Dopf",\u010F:"dcaron",\u010E:"Dcaron",\u0111:"dstrok",\u0110:"Dstrok",\u00F0:"eth",\u00D0:"ETH","\u2147":"ee",\u212F:"escr","\u{1D522}":"efr","\u{1D556}":"eopf",\u2130:"Escr","\u{1D508}":"Efr","\u{1D53C}":"Eopf",\u00E9:"eacute",\u00C9:"Eacute",\u00E8:"egrave",\u00C8:"Egrave",\u00EA:"ecirc",\u00CA:"Ecirc",\u011B:"ecaron",\u011A:"Ecaron",\u00EB:"euml",\u00CB:"Euml",\u0117:"edot",\u0116:"Edot",\u0119:"eogon",\u0118:"Eogon",\u0113:"emacr",\u0112:"Emacr","\u{1D523}":"ffr","\u{1D557}":"fopf","\u{1D4BB}":"fscr","\u{1D509}":"Ffr","\u{1D53D}":"Fopf",\u2131:"Fscr",\uFB00:"fflig",\uFB03:"ffilig",\uFB04:"ffllig",\uFB01:"filig",fj:"fjlig",\uFB02:"fllig",\u0192:"fnof",\u210A:"gscr","\u{1D558}":"gopf","\u{1D524}":"gfr","\u{1D4A2}":"Gscr","\u{1D53E}":"Gopf","\u{1D50A}":"Gfr",\u01F5:"gacute",\u011F:"gbreve",\u011E:"Gbreve",\u011D:"gcirc",\u011C:"Gcirc",\u0121:"gdot",\u0120:"Gdot",\u0122:"Gcedil","\u{1D525}":"hfr",\u210E:"planckh","\u{1D4BD}":"hscr","\u{1D559}":"hopf",\u210B:"Hscr",\u210C:"Hfr",\u210D:"Hopf",\u0125:"hcirc",\u0124:"Hcirc",\u210F:"hbar",\u0127:"hstrok",\u0126:"Hstrok","\u{1D55A}":"iopf","\u{1D526}":"ifr","\u{1D4BE}":"iscr","\u2148":"ii","\u{1D540}":"Iopf",\u2110:"Iscr",\u2111:"Im",\u00ED:"iacute",\u00CD:"Iacute",\u00EC:"igrave",\u00CC:"Igrave",\u00EE:"icirc",\u00CE:"Icirc",\u00EF:"iuml",\u00CF:"Iuml",\u0129:"itilde",\u0128:"Itilde",\u0130:"Idot",\u012F:"iogon",\u012E:"Iogon",\u012B:"imacr",\u012A:"Imacr",\u0133:"ijlig",\u0132:"IJlig",\u0131:"imath","\u{1D4BF}":"jscr","\u{1D55B}":"jopf","\u{1D527}":"jfr","\u{1D4A5}":"Jscr","\u{1D50D}":"Jfr","\u{1D541}":"Jopf",\u0135:"jcirc",\u0134:"Jcirc","\u0237":"jmath","\u{1D55C}":"kopf","\u{1D4C0}":"kscr","\u{1D528}":"kfr","\u{1D4A6}":"Kscr","\u{1D542}":"Kopf","\u{1D50E}":"Kfr",\u0137:"kcedil",\u0136:"Kcedil","\u{1D529}":"lfr","\u{1D4C1}":"lscr",\u2113:"ell","\u{1D55D}":"lopf",\u2112:"Lscr","\u{1D50F}":"Lfr","\u{1D543}":"Lopf",\u013A:"lacute",\u0139:"Lacute",\u013E:"lcaron",\u013D:"Lcaron",\u013C:"lcedil",\u013B:"Lcedil",\u0142:"lstrok",\u0141:"Lstrok",\u0140:"lmidot",\u013F:"Lmidot","\u{1D52A}":"mfr","\u{1D55E}":"mopf","\u{1D4C2}":"mscr","\u{1D510}":"Mfr","\u{1D544}":"Mopf",\u2133:"Mscr","\u{1D52B}":"nfr","\u{1D55F}":"nopf","\u{1D4C3}":"nscr",\u2115:"Nopf","\u{1D4A9}":"Nscr","\u{1D511}":"Nfr",\u0144:"nacute",\u0143:"Nacute",\u0148:"ncaron",\u0147:"Ncaron",\u00F1:"ntilde",\u00D1:"Ntilde",\u0146:"ncedil",\u0145:"Ncedil","\u2116":"numero",\u014B:"eng",\u014A:"ENG","\u{1D560}":"oopf","\u{1D52C}":"ofr",\u2134:"oscr","\u{1D4AA}":"Oscr","\u{1D512}":"Ofr","\u{1D546}":"Oopf",\u00BA:"ordm",\u00F3:"oacute",\u00D3:"Oacute",\u00F2:"ograve",\u00D2:"Ograve",\u00F4:"ocirc",\u00D4:"Ocirc",\u00F6:"ouml",\u00D6:"Ouml",\u0151:"odblac",\u0150:"Odblac",\u00F5:"otilde",\u00D5:"Otilde",\u00F8:"oslash",\u00D8:"Oslash",\u014D:"omacr",\u014C:"Omacr",\u0153:"oelig",\u0152:"OElig","\u{1D52D}":"pfr","\u{1D4C5}":"pscr","\u{1D561}":"popf",\u2119:"Popf","\u{1D513}":"Pfr","\u{1D4AB}":"Pscr","\u{1D562}":"qopf","\u{1D52E}":"qfr","\u{1D4C6}":"qscr","\u{1D4AC}":"Qscr","\u{1D514}":"Qfr",\u211A:"Qopf",\u0138:"kgreen","\u{1D52F}":"rfr","\u{1D563}":"ropf","\u{1D4C7}":"rscr",\u211B:"Rscr",\u211C:"Re",\u211D:"Ropf",\u0155:"racute",\u0154:"Racute",\u0159:"rcaron",\u0158:"Rcaron",\u0157:"rcedil",\u0156:"Rcedil","\u{1D564}":"sopf","\u{1D4C8}":"sscr","\u{1D530}":"sfr","\u{1D54A}":"Sopf","\u{1D516}":"Sfr","\u{1D4AE}":"Sscr","\u24C8":"oS",\u015B:"sacute",\u015A:"Sacute",\u015D:"scirc",\u015C:"Scirc",\u0161:"scaron",\u0160:"Scaron",\u015F:"scedil",\u015E:"Scedil",\u00DF:"szlig","\u{1D531}":"tfr","\u{1D4C9}":"tscr","\u{1D565}":"topf","\u{1D4AF}":"Tscr","\u{1D517}":"Tfr","\u{1D54B}":"Topf",\u0165:"tcaron",\u0164:"Tcaron",\u0163:"tcedil",\u0162:"Tcedil","\u2122":"trade",\u0167:"tstrok",\u0166:"Tstrok","\u{1D4CA}":"uscr","\u{1D566}":"uopf","\u{1D532}":"ufr","\u{1D54C}":"Uopf","\u{1D518}":"Ufr","\u{1D4B0}":"Uscr",\u00FA:"uacute",\u00DA:"Uacute",\u00F9:"ugrave",\u00D9:"Ugrave",\u016D:"ubreve",\u016C:"Ubreve",\u00FB:"ucirc",\u00DB:"Ucirc",\u016F:"uring",\u016E:"Uring",\u00FC:"uuml",\u00DC:"Uuml",\u0171:"udblac",\u0170:"Udblac",\u0169:"utilde",\u0168:"Utilde",\u0173:"uogon",\u0172:"Uogon",\u016B:"umacr",\u016A:"Umacr","\u{1D533}":"vfr","\u{1D567}":"vopf","\u{1D4CB}":"vscr","\u{1D519}":"Vfr","\u{1D54D}":"Vopf","\u{1D4B1}":"Vscr","\u{1D568}":"wopf","\u{1D4CC}":"wscr","\u{1D534}":"wfr","\u{1D4B2}":"Wscr","\u{1D54E}":"Wopf","\u{1D51A}":"Wfr",\u0175:"wcirc",\u0174:"Wcirc","\u{1D535}":"xfr","\u{1D4CD}":"xscr","\u{1D569}":"xopf","\u{1D54F}":"Xopf","\u{1D51B}":"Xfr","\u{1D4B3}":"Xscr","\u{1D536}":"yfr","\u{1D4CE}":"yscr","\u{1D56A}":"yopf","\u{1D4B4}":"Yscr","\u{1D51C}":"Yfr","\u{1D550}":"Yopf",\u00FD:"yacute",\u00DD:"Yacute",\u0177:"ycirc",\u0176:"Ycirc",\u00FF:"yuml",\u0178:"Yuml","\u{1D4CF}":"zscr","\u{1D537}":"zfr","\u{1D56B}":"zopf",\u2128:"Zfr",\u2124:"Zopf","\u{1D4B5}":"Zscr",\u017A:"zacute",\u0179:"Zacute",\u017E:"zcaron",\u017D:"Zcaron",\u017C:"zdot",\u017B:"Zdot",\u01B5:"imped",\u00FE:"thorn",\u00DE:"THORN",\u0149:"napos",\u03B1:"alpha",\u0391:"Alpha",\u03B2:"beta",\u0392:"Beta",\u03B3:"gamma",\u0393:"Gamma",\u03B4:"delta",\u0394:"Delta",\u03B5:"epsi","\u03F5":"epsiv",\u0395:"Epsilon",\u03DD:"gammad",\u03DC:"Gammad",\u03B6:"zeta",\u0396:"Zeta",\u03B7:"eta",\u0397:"Eta",\u03B8:"theta",\u03D1:"thetav",\u0398:"Theta",\u03B9:"iota",\u0399:"Iota",\u03BA:"kappa",\u03F0:"kappav",\u039A:"Kappa",\u03BB:"lambda",\u039B:"Lambda",\u03BC:"mu",\u00B5:"micro",\u039C:"Mu",\u03BD:"nu",\u039D:"Nu",\u03BE:"xi",\u039E:"Xi",\u03BF:"omicron",\u039F:"Omicron",\u03C0:"pi",\u03D6:"piv",\u03A0:"Pi",\u03C1:"rho",\u03F1:"rhov",\u03A1:"Rho",\u03C3:"sigma",\u03A3:"Sigma",\u03C2:"sigmaf",\u03C4:"tau",\u03A4:"Tau",\u03C5:"upsi",\u03A5:"Upsilon",\u03D2:"Upsi",\u03C6:"phi",\u03D5:"phiv",\u03A6:"Phi",\u03C7:"chi",\u03A7:"Chi",\u03C8:"psi",\u03A8:"Psi",\u03C9:"omega",\u03A9:"ohm",\u0430:"acy",\u0410:"Acy",\u0431:"bcy",\u0411:"Bcy",\u0432:"vcy",\u0412:"Vcy",\u0433:"gcy",\u0413:"Gcy",\u0453:"gjcy",\u0403:"GJcy",\u0434:"dcy",\u0414:"Dcy",\u0452:"djcy",\u0402:"DJcy",\u0435:"iecy",\u0415:"IEcy",\u0451:"iocy",\u0401:"IOcy",\u0454:"jukcy",\u0404:"Jukcy",\u0436:"zhcy",\u0416:"ZHcy",\u0437:"zcy",\u0417:"Zcy",\u0455:"dscy",\u0405:"DScy",\u0438:"icy",\u0418:"Icy",\u0456:"iukcy",\u0406:"Iukcy",\u0457:"yicy",\u0407:"YIcy",\u0439:"jcy",\u0419:"Jcy",\u0458:"jsercy",\u0408:"Jsercy",\u043A:"kcy",\u041A:"Kcy",\u045C:"kjcy",\u040C:"KJcy",\u043B:"lcy",\u041B:"Lcy",\u0459:"ljcy",\u0409:"LJcy",\u043C:"mcy",\u041C:"Mcy",\u043D:"ncy",\u041D:"Ncy",\u045A:"njcy",\u040A:"NJcy",\u043E:"ocy",\u041E:"Ocy",\u043F:"pcy",\u041F:"Pcy",\u0440:"rcy",\u0420:"Rcy",\u0441:"scy",\u0421:"Scy",\u0442:"tcy",\u0422:"Tcy",\u045B:"tshcy",\u040B:"TSHcy",\u0443:"ucy",\u0423:"Ucy",\u045E:"ubrcy",\u040E:"Ubrcy",\u0444:"fcy",\u0424:"Fcy",\u0445:"khcy",\u0425:"KHcy",\u0446:"tscy",\u0426:"TScy",\u0447:"chcy",\u0427:"CHcy",\u045F:"dzcy",\u040F:"DZcy",\u0448:"shcy",\u0428:"SHcy",\u0449:"shchcy",\u0429:"SHCHcy",\u044A:"hardcy",\u042A:"HARDcy",\u044B:"ycy",\u042B:"Ycy",\u044C:"softcy",\u042C:"SOFTcy",\u044D:"ecy",\u042D:"Ecy",\u044E:"yucy",\u042E:"YUcy",\u044F:"yacy",\u042F:"YAcy",\u2135:"aleph",\u2136:"beth",\u2137:"gimel",\u2138:"daleth"},l=/["&'<>`]/g,u={'"':"&quot;","&":"&amp;","'":"&#x27;","<":"&lt;",">":"&gt;","`":"&#x60;"},f=/&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/,h=/[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,m=/&(CounterClockwiseContourIntegral|DoubleLongLeftRightArrow|ClockwiseContourIntegral|NotNestedGreaterGreater|NotSquareSupersetEqual|DiacriticalDoubleAcute|NotRightTriangleEqual|NotSucceedsSlantEqual|NotPrecedesSlantEqual|CloseCurlyDoubleQuote|NegativeVeryThinSpace|DoubleContourIntegral|FilledVerySmallSquare|CapitalDifferentialD|OpenCurlyDoubleQuote|EmptyVerySmallSquare|NestedGreaterGreater|DoubleLongRightArrow|NotLeftTriangleEqual|NotGreaterSlantEqual|ReverseUpEquilibrium|DoubleLeftRightArrow|NotSquareSubsetEqual|NotDoubleVerticalBar|RightArrowLeftArrow|NotGreaterFullEqual|NotRightTriangleBar|SquareSupersetEqual|DownLeftRightVector|DoubleLongLeftArrow|leftrightsquigarrow|LeftArrowRightArrow|NegativeMediumSpace|blacktriangleright|RightDownVectorBar|PrecedesSlantEqual|RightDoubleBracket|SucceedsSlantEqual|NotLeftTriangleBar|RightTriangleEqual|SquareIntersection|RightDownTeeVector|ReverseEquilibrium|NegativeThickSpace|longleftrightarrow|Longleftrightarrow|LongLeftRightArrow|DownRightTeeVector|DownRightVectorBar|GreaterSlantEqual|SquareSubsetEqual|LeftDownVectorBar|LeftDoubleBracket|VerticalSeparator|rightleftharpoons|NotGreaterGreater|NotSquareSuperset|blacktriangleleft|blacktriangledown|NegativeThinSpace|LeftDownTeeVector|NotLessSlantEqual|leftrightharpoons|DoubleUpDownArrow|DoubleVerticalBar|LeftTriangleEqual|FilledSmallSquare|twoheadrightarrow|NotNestedLessLess|DownLeftTeeVector|DownLeftVectorBar|RightAngleBracket|NotTildeFullEqual|NotReverseElement|RightUpDownVector|DiacriticalTilde|NotSucceedsTilde|circlearrowright|NotPrecedesEqual|rightharpoondown|DoubleRightArrow|NotSucceedsEqual|NonBreakingSpace|NotRightTriangle|LessEqualGreater|RightUpTeeVector|LeftAngleBracket|GreaterFullEqual|DownArrowUpArrow|RightUpVectorBar|twoheadleftarrow|GreaterEqualLess|downharpoonright|RightTriangleBar|ntrianglerighteq|NotSupersetEqual|LeftUpDownVector|DiacriticalAcute|rightrightarrows|vartriangleright|UpArrowDownArrow|DiacriticalGrave|UnderParenthesis|EmptySmallSquare|LeftUpVectorBar|leftrightarrows|DownRightVector|downharpoonleft|trianglerighteq|ShortRightArrow|OverParenthesis|DoubleLeftArrow|DoubleDownArrow|NotSquareSubset|bigtriangledown|ntrianglelefteq|UpperRightArrow|curvearrowright|vartriangleleft|NotLeftTriangle|nleftrightarrow|LowerRightArrow|NotHumpDownHump|NotGreaterTilde|rightthreetimes|LeftUpTeeVector|NotGreaterEqual|straightepsilon|LeftTriangleBar|rightsquigarrow|ContourIntegral|rightleftarrows|CloseCurlyQuote|RightDownVector|LeftRightVector|nLeftrightarrow|leftharpoondown|circlearrowleft|SquareSuperset|OpenCurlyQuote|hookrightarrow|HorizontalLine|DiacriticalDot|NotLessGreater|ntriangleright|DoubleRightTee|InvisibleComma|InvisibleTimes|LowerLeftArrow|DownLeftVector|NotSubsetEqual|curvearrowleft|trianglelefteq|NotVerticalBar|TildeFullEqual|downdownarrows|NotGreaterLess|RightTeeVector|ZeroWidthSpace|looparrowright|LongRightArrow|doublebarwedge|ShortLeftArrow|ShortDownArrow|RightVectorBar|GreaterGreater|ReverseElement|rightharpoonup|LessSlantEqual|leftthreetimes|upharpoonright|rightarrowtail|LeftDownVector|Longrightarrow|NestedLessLess|UpperLeftArrow|nshortparallel|leftleftarrows|leftrightarrow|Leftrightarrow|LeftRightArrow|longrightarrow|upharpoonleft|RightArrowBar|ApplyFunction|LeftTeeVector|leftarrowtail|NotEqualTilde|varsubsetneqq|varsupsetneqq|RightTeeArrow|SucceedsEqual|SucceedsTilde|LeftVectorBar|SupersetEqual|hookleftarrow|DifferentialD|VerticalTilde|VeryThinSpace|blacktriangle|bigtriangleup|LessFullEqual|divideontimes|leftharpoonup|UpEquilibrium|ntriangleleft|RightTriangle|measuredangle|shortparallel|longleftarrow|Longleftarrow|LongLeftArrow|DoubleLeftTee|Poincareplane|PrecedesEqual|triangleright|DoubleUpArrow|RightUpVector|fallingdotseq|looparrowleft|PrecedesTilde|NotTildeEqual|NotTildeTilde|smallsetminus|Proportional|triangleleft|triangledown|UnderBracket|NotHumpEqual|exponentiale|ExponentialE|NotLessTilde|HilbertSpace|RightCeiling|blacklozenge|varsupsetneq|HumpDownHump|GreaterEqual|VerticalLine|LeftTeeArrow|NotLessEqual|DownTeeArrow|LeftTriangle|varsubsetneq|Intersection|NotCongruent|DownArrowBar|LeftUpVector|LeftArrowBar|risingdotseq|GreaterTilde|RoundImplies|SquareSubset|ShortUpArrow|NotSuperset|quaternions|precnapprox|backepsilon|preccurlyeq|OverBracket|blacksquare|MediumSpace|VerticalBar|circledcirc|circleddash|CircleMinus|CircleTimes|LessGreater|curlyeqprec|curlyeqsucc|diamondsuit|UpDownArrow|Updownarrow|RuleDelayed|Rrightarrow|updownarrow|RightVector|nRightarrow|nrightarrow|eqslantless|LeftCeiling|Equilibrium|SmallCircle|expectation|NotSucceeds|thickapprox|GreaterLess|SquareUnion|NotPrecedes|NotLessLess|straightphi|succnapprox|succcurlyeq|SubsetEqual|sqsupseteq|Proportion|Laplacetrf|ImaginaryI|supsetneqq|NotGreater|gtreqqless|NotElement|ThickSpace|TildeEqual|TildeTilde|Fouriertrf|rmoustache|EqualTilde|eqslantgtr|UnderBrace|LeftVector|UpArrowBar|nLeftarrow|nsubseteqq|subsetneqq|nsupseteqq|nleftarrow|succapprox|lessapprox|UpTeeArrow|upuparrows|curlywedge|lesseqqgtr|varepsilon|varnothing|RightFloor|complement|CirclePlus|sqsubseteq|Lleftarrow|circledast|RightArrow|Rightarrow|rightarrow|lmoustache|Bernoullis|precapprox|mapstoleft|mapstodown|longmapsto|dotsquare|downarrow|DoubleDot|nsubseteq|supsetneq|leftarrow|nsupseteq|subsetneq|ThinSpace|ngeqslant|subseteqq|HumpEqual|NotSubset|triangleq|NotCupCap|lesseqgtr|heartsuit|TripleDot|Leftarrow|Coproduct|Congruent|varpropto|complexes|gvertneqq|LeftArrow|LessTilde|supseteqq|MinusPlus|CircleDot|nleqslant|NotExists|gtreqless|nparallel|UnionPlus|LeftFloor|checkmark|CenterDot|centerdot|Mellintrf|gtrapprox|bigotimes|OverBrace|spadesuit|therefore|pitchfork|rationals|PlusMinus|Backslash|Therefore|DownBreve|backsimeq|backprime|DownArrow|nshortmid|Downarrow|lvertneqq|eqvparsl|imagline|imagpart|infintie|integers|Integral|intercal|LessLess|Uarrocir|intlarhk|sqsupset|angmsdaf|sqsubset|llcorner|vartheta|cupbrcap|lnapprox|Superset|SuchThat|succnsim|succneqq|angmsdag|biguplus|curlyvee|trpezium|Succeeds|NotTilde|bigwedge|angmsdah|angrtvbd|triminus|cwconint|fpartint|lrcorner|smeparsl|subseteq|urcorner|lurdshar|laemptyv|DDotrahd|approxeq|ldrushar|awconint|mapstoup|backcong|shortmid|triangle|geqslant|gesdotol|timesbar|circledR|circledS|setminus|multimap|naturals|scpolint|ncongdot|RightTee|boxminus|gnapprox|boxtimes|andslope|thicksim|angmsdaa|varsigma|cirfnint|rtriltri|angmsdab|rppolint|angmsdac|barwedge|drbkarow|clubsuit|thetasym|bsolhsub|capbrcup|dzigrarr|doteqdot|DotEqual|dotminus|UnderBar|NotEqual|realpart|otimesas|ulcorner|hksearow|hkswarow|parallel|PartialD|elinters|emptyset|plusacir|bbrktbrk|angmsdad|pointint|bigoplus|angmsdae|Precedes|bigsqcup|varkappa|notindot|supseteq|precneqq|precnsim|profalar|profline|profsurf|leqslant|lesdotor|raemptyv|subplus|notnivb|notnivc|subrarr|zigrarr|vzigzag|submult|subedot|Element|between|cirscir|larrbfs|larrsim|lotimes|lbrksld|lbrkslu|lozenge|ldrdhar|dbkarow|bigcirc|epsilon|simrarr|simplus|ltquest|Epsilon|luruhar|gtquest|maltese|npolint|eqcolon|npreceq|bigodot|ddagger|gtrless|bnequiv|harrcir|ddotseq|equivDD|backsim|demptyv|nsqsube|nsqsupe|Upsilon|nsubset|upsilon|minusdu|nsucceq|swarrow|nsupset|coloneq|searrow|boxplus|napprox|natural|asympeq|alefsym|congdot|nearrow|bigstar|diamond|supplus|tritime|LeftTee|nvinfin|triplus|NewLine|nvltrie|nvrtrie|nwarrow|nexists|Diamond|ruluhar|Implies|supmult|angzarr|suplarr|suphsub|questeq|because|digamma|Because|olcross|bemptyv|omicron|Omicron|rotimes|NoBreak|intprod|angrtvb|orderof|uwangle|suphsol|lesdoto|orslope|DownTee|realine|cudarrl|rdldhar|OverBar|supedot|lessdot|supdsub|topfork|succsim|rbrkslu|rbrksld|pertenk|cudarrr|isindot|planckh|lessgtr|pluscir|gesdoto|plussim|plustwo|lesssim|cularrp|rarrsim|Cayleys|notinva|notinvb|notinvc|UpArrow|Uparrow|uparrow|NotLess|dwangle|precsim|Product|curarrm|Cconint|dotplus|rarrbfs|ccupssm|Cedilla|cemptyv|notniva|quatint|frac35|frac38|frac45|frac56|frac58|frac78|tridot|xoplus|gacute|gammad|Gammad|lfisht|lfloor|bigcup|sqsupe|gbreve|Gbreve|lharul|sqsube|sqcups|Gcedil|apacir|llhard|lmidot|Lmidot|lmoust|andand|sqcaps|approx|Abreve|spades|circeq|tprime|divide|topcir|Assign|topbot|gesdot|divonx|xuplus|timesd|gesles|atilde|solbar|SOFTcy|loplus|timesb|lowast|lowbar|dlcorn|dlcrop|softcy|dollar|lparlt|thksim|lrhard|Atilde|lsaquo|smashp|bigvee|thinsp|wreath|bkarow|lsquor|lstrok|Lstrok|lthree|ltimes|ltlarr|DotDot|simdot|ltrPar|weierp|xsqcup|angmsd|sigmav|sigmaf|zeetrf|Zcaron|zcaron|mapsto|vsupne|thetav|cirmid|marker|mcomma|Zacute|vsubnE|there4|gtlPar|vsubne|bottom|gtrarr|SHCHcy|shchcy|midast|midcir|middot|minusb|minusd|gtrdot|bowtie|sfrown|mnplus|models|colone|seswar|Colone|mstpos|searhk|gtrsim|nacute|Nacute|boxbox|telrec|hairsp|Tcedil|nbumpe|scnsim|ncaron|Ncaron|ncedil|Ncedil|hamilt|Scedil|nearhk|hardcy|HARDcy|tcedil|Tcaron|commat|nequiv|nesear|tcaron|target|hearts|nexist|varrho|scedil|Scaron|scaron|hellip|Sacute|sacute|hercon|swnwar|compfn|rtimes|rthree|rsquor|rsaquo|zacute|wedgeq|homtht|barvee|barwed|Barwed|rpargt|horbar|conint|swarhk|roplus|nltrie|hslash|hstrok|Hstrok|rmoust|Conint|bprime|hybull|hyphen|iacute|Iacute|supsup|supsub|supsim|varphi|coprod|brvbar|agrave|Supset|supset|igrave|Igrave|notinE|Agrave|iiiint|iinfin|copysr|wedbar|Verbar|vangrt|becaus|incare|verbar|inodot|bullet|drcorn|intcal|drcrop|cularr|vellip|Utilde|bumpeq|cupcap|dstrok|Dstrok|CupCap|cupcup|cupdot|eacute|Eacute|supdot|iquest|easter|ecaron|Ecaron|ecolon|isinsv|utilde|itilde|Itilde|curarr|succeq|Bumpeq|cacute|ulcrop|nparsl|Cacute|nprcue|egrave|Egrave|nrarrc|nrarrw|subsup|subsub|nrtrie|jsercy|nsccue|Jsercy|kappav|kcedil|Kcedil|subsim|ulcorn|nsimeq|egsdot|veebar|kgreen|capand|elsdot|Subset|subset|curren|aacute|lacute|Lacute|emptyv|ntilde|Ntilde|lagran|lambda|Lambda|capcap|Ugrave|langle|subdot|emsp13|numero|emsp14|nvdash|nvDash|nVdash|nVDash|ugrave|ufisht|nvHarr|larrfs|nvlArr|larrhk|larrlp|larrpl|nvrArr|Udblac|nwarhk|larrtl|nwnear|oacute|Oacute|latail|lAtail|sstarf|lbrace|odblac|Odblac|lbrack|udblac|odsold|eparsl|lcaron|Lcaron|ograve|Ograve|lcedil|Lcedil|Aacute|ssmile|ssetmn|squarf|ldquor|capcup|ominus|cylcty|rharul|eqcirc|dagger|rfloor|rfisht|Dagger|daleth|equals|origof|capdot|equest|dcaron|Dcaron|rdquor|oslash|Oslash|otilde|Otilde|otimes|Otimes|urcrop|Ubreve|ubreve|Yacute|Uacute|uacute|Rcedil|rcedil|urcorn|parsim|Rcaron|Vdashl|rcaron|Tstrok|percnt|period|permil|Exists|yacute|rbrack|rbrace|phmmat|ccaron|Ccaron|planck|ccedil|plankv|tstrok|female|plusdo|plusdu|ffilig|plusmn|ffllig|Ccedil|rAtail|dfisht|bernou|ratail|Rarrtl|rarrtl|angsph|rarrpl|rarrlp|rarrhk|xwedge|xotime|forall|ForAll|Vvdash|vsupnE|preceq|bigcap|frac12|frac13|frac14|primes|rarrfs|prnsim|frac15|Square|frac16|square|lesdot|frac18|frac23|propto|prurel|rarrap|rangle|puncsp|frac25|Racute|qprime|racute|lesges|frac34|abreve|AElig|eqsim|utdot|setmn|urtri|Equal|Uring|seArr|uring|searr|dashv|Dashv|mumap|nabla|iogon|Iogon|sdote|sdotb|scsim|napid|napos|equiv|natur|Acirc|dblac|erarr|nbump|iprod|erDot|ucirc|awint|esdot|angrt|ncong|isinE|scnap|Scirc|scirc|ndash|isins|Ubrcy|nearr|neArr|isinv|nedot|ubrcy|acute|Ycirc|iukcy|Iukcy|xutri|nesim|caret|jcirc|Jcirc|caron|twixt|ddarr|sccue|exist|jmath|sbquo|ngeqq|angst|ccaps|lceil|ngsim|UpTee|delta|Delta|rtrif|nharr|nhArr|nhpar|rtrie|jukcy|Jukcy|kappa|rsquo|Kappa|nlarr|nlArr|TSHcy|rrarr|aogon|Aogon|fflig|xrarr|tshcy|ccirc|nleqq|filig|upsih|nless|dharl|nlsim|fjlig|ropar|nltri|dharr|robrk|roarr|fllig|fltns|roang|rnmid|subnE|subne|lAarr|trisb|Ccirc|acirc|ccups|blank|VDash|forkv|Vdash|langd|cedil|blk12|blk14|laquo|strns|diams|notin|vDash|larrb|blk34|block|disin|uplus|vdash|vBarv|aelig|starf|Wedge|check|xrArr|lates|lbarr|lBarr|notni|lbbrk|bcong|frasl|lbrke|frown|vrtri|vprop|vnsup|gamma|Gamma|wedge|xodot|bdquo|srarr|doteq|ldquo|boxdl|boxdL|gcirc|Gcirc|boxDl|boxDL|boxdr|boxdR|boxDr|TRADE|trade|rlhar|boxDR|vnsub|npart|vltri|rlarr|boxhd|boxhD|nprec|gescc|nrarr|nrArr|boxHd|boxHD|boxhu|boxhU|nrtri|boxHu|clubs|boxHU|times|colon|Colon|gimel|xlArr|Tilde|nsime|tilde|nsmid|nspar|THORN|thorn|xlarr|nsube|nsubE|thkap|xhArr|comma|nsucc|boxul|boxuL|nsupe|nsupE|gneqq|gnsim|boxUl|boxUL|grave|boxur|boxuR|boxUr|boxUR|lescc|angle|bepsi|boxvh|varpi|boxvH|numsp|Theta|gsime|gsiml|theta|boxVh|boxVH|boxvl|gtcir|gtdot|boxvL|boxVl|boxVL|crarr|cross|Cross|nvsim|boxvr|nwarr|nwArr|sqsup|dtdot|Uogon|lhard|lharu|dtrif|ocirc|Ocirc|lhblk|duarr|odash|sqsub|Hacek|sqcup|llarr|duhar|oelig|OElig|ofcir|boxvR|uogon|lltri|boxVr|csube|uuarr|ohbar|csupe|ctdot|olarr|olcir|harrw|oline|sqcap|omacr|Omacr|omega|Omega|boxVR|aleph|lneqq|lnsim|loang|loarr|rharu|lobrk|hcirc|operp|oplus|rhard|Hcirc|orarr|Union|order|ecirc|Ecirc|cuepr|szlig|cuesc|breve|reals|eDDot|Breve|hoarr|lopar|utrif|rdquo|Umacr|umacr|efDot|swArr|ultri|alpha|rceil|ovbar|swarr|Wcirc|wcirc|smtes|smile|bsemi|lrarr|aring|parsl|lrhar|bsime|uhblk|lrtri|cupor|Aring|uharr|uharl|slarr|rbrke|bsolb|lsime|rbbrk|RBarr|lsimg|phone|rBarr|rbarr|icirc|lsquo|Icirc|emacr|Emacr|ratio|simne|plusb|simlE|simgE|simeq|pluse|ltcir|ltdot|empty|xharr|xdtri|iexcl|Alpha|ltrie|rarrw|pound|ltrif|xcirc|bumpe|prcue|bumpE|asymp|amacr|cuvee|Sigma|sigma|iiint|udhar|iiota|ijlig|IJlig|supnE|imacr|Imacr|prime|Prime|image|prnap|eogon|Eogon|rarrc|mdash|mDDot|cuwed|imath|supne|imped|Amacr|udarr|prsim|micro|rarrb|cwint|raquo|infin|eplus|range|rangd|Ucirc|radic|minus|amalg|veeeq|rAarr|epsiv|ycirc|quest|sharp|quot|zwnj|Qscr|race|qscr|Qopf|qopf|qint|rang|Rang|Zscr|zscr|Zopf|zopf|rarr|rArr|Rarr|Pscr|pscr|prop|prod|prnE|prec|ZHcy|zhcy|prap|Zeta|zeta|Popf|popf|Zdot|plus|zdot|Yuml|yuml|phiv|YUcy|yucy|Yscr|yscr|perp|Yopf|yopf|part|para|YIcy|Ouml|rcub|yicy|YAcy|rdca|ouml|osol|Oscr|rdsh|yacy|real|oscr|xvee|andd|rect|andv|Xscr|oror|ordm|ordf|xscr|ange|aopf|Aopf|rHar|Xopf|opar|Oopf|xopf|xnis|rhov|oopf|omid|xmap|oint|apid|apos|ogon|ascr|Ascr|odot|odiv|xcup|xcap|ocir|oast|nvlt|nvle|nvgt|nvge|nvap|Wscr|wscr|auml|ntlg|ntgl|nsup|nsub|nsim|Nscr|nscr|nsce|Wopf|ring|npre|wopf|npar|Auml|Barv|bbrk|Nopf|nopf|nmid|nLtv|beta|ropf|Ropf|Beta|beth|nles|rpar|nleq|bnot|bNot|nldr|NJcy|rscr|Rscr|Vscr|vscr|rsqb|njcy|bopf|nisd|Bopf|rtri|Vopf|nGtv|ngtr|vopf|boxh|boxH|boxv|nges|ngeq|boxV|bscr|scap|Bscr|bsim|Vert|vert|bsol|bull|bump|caps|cdot|ncup|scnE|ncap|nbsp|napE|Cdot|cent|sdot|Vbar|nang|vBar|chcy|Mscr|mscr|sect|semi|CHcy|Mopf|mopf|sext|circ|cire|mldr|mlcp|cirE|comp|shcy|SHcy|vArr|varr|cong|copf|Copf|copy|COPY|malt|male|macr|lvnE|cscr|ltri|sime|ltcc|simg|Cscr|siml|csub|Uuml|lsqb|lsim|uuml|csup|Lscr|lscr|utri|smid|lpar|cups|smte|lozf|darr|Lopf|Uscr|solb|lopf|sopf|Sopf|lneq|uscr|spar|dArr|lnap|Darr|dash|Sqrt|LJcy|ljcy|lHar|dHar|Upsi|upsi|diam|lesg|djcy|DJcy|leqq|dopf|Dopf|dscr|Dscr|dscy|ldsh|ldca|squf|DScy|sscr|Sscr|dsol|lcub|late|star|Star|Uopf|Larr|lArr|larr|uopf|dtri|dzcy|sube|subE|Lang|lang|Kscr|kscr|Kopf|kopf|KJcy|kjcy|KHcy|khcy|DZcy|ecir|edot|eDot|Jscr|jscr|succ|Jopf|jopf|Edot|uHar|emsp|ensp|Iuml|iuml|eopf|isin|Iscr|iscr|Eopf|epar|sung|epsi|escr|sup1|sup2|sup3|Iota|iota|supe|supE|Iopf|iopf|IOcy|iocy|Escr|esim|Esim|imof|Uarr|QUOT|uArr|uarr|euml|IEcy|iecy|Idot|Euml|euro|excl|Hscr|hscr|Hopf|hopf|TScy|tscy|Tscr|hbar|tscr|flat|tbrk|fnof|hArr|harr|half|fopf|Fopf|tdot|gvnE|fork|trie|gtcc|fscr|Fscr|gdot|gsim|Gscr|gscr|Gopf|gopf|gneq|Gdot|tosa|gnap|Topf|topf|geqq|toea|GJcy|gjcy|tint|gesl|mid|Sfr|ggg|top|ges|gla|glE|glj|geq|gne|gEl|gel|gnE|Gcy|gcy|gap|Tfr|tfr|Tcy|tcy|Hat|Tau|Ffr|tau|Tab|hfr|Hfr|ffr|Fcy|fcy|icy|Icy|iff|ETH|eth|ifr|Ifr|Eta|eta|int|Int|Sup|sup|ucy|Ucy|Sum|sum|jcy|ENG|ufr|Ufr|eng|Jcy|jfr|els|ell|egs|Efr|efr|Jfr|uml|kcy|Kcy|Ecy|ecy|kfr|Kfr|lap|Sub|sub|lat|lcy|Lcy|leg|Dot|dot|lEg|leq|les|squ|div|die|lfr|Lfr|lgE|Dfr|dfr|Del|deg|Dcy|dcy|lne|lnE|sol|loz|smt|Cup|lrm|cup|lsh|Lsh|sim|shy|map|Map|mcy|Mcy|mfr|Mfr|mho|gfr|Gfr|sfr|cir|Chi|chi|nap|Cfr|vcy|Vcy|cfr|Scy|scy|ncy|Ncy|vee|Vee|Cap|cap|nfr|scE|sce|Nfr|nge|ngE|nGg|vfr|Vfr|ngt|bot|nGt|nis|niv|Rsh|rsh|nle|nlE|bne|Bfr|bfr|nLl|nlt|nLt|Bcy|bcy|not|Not|rlm|wfr|Wfr|npr|nsc|num|ocy|ast|Ocy|ofr|xfr|Xfr|Ofr|ogt|ohm|apE|olt|Rho|ape|rho|Rfr|rfr|ord|REG|ang|reg|orv|And|and|AMP|Rcy|amp|Afr|ycy|Ycy|yen|yfr|Yfr|rcy|par|pcy|Pcy|pfr|Pfr|phi|Phi|afr|Acy|acy|zcy|Zcy|piv|acE|acd|zfr|Zfr|pre|prE|psi|Psi|qfr|Qfr|zwj|Or|ge|Gg|gt|gg|el|oS|lt|Lt|LT|Re|lg|gl|eg|ne|Im|it|le|DD|wp|wr|nu|Nu|dd|lE|Sc|sc|pi|Pi|ee|af|ll|Ll|rx|gE|xi|pm|Xi|ic|pr|Pr|in|ni|mp|mu|ac|Mu|or|ap|Gt|GT|ii);|&(Aacute|Agrave|Atilde|Ccedil|Eacute|Egrave|Iacute|Igrave|Ntilde|Oacute|Ograve|Oslash|Otilde|Uacute|Ugrave|Yacute|aacute|agrave|atilde|brvbar|ccedil|curren|divide|eacute|egrave|frac12|frac14|frac34|iacute|igrave|iquest|middot|ntilde|oacute|ograve|oslash|otilde|plusmn|uacute|ugrave|yacute|AElig|Acirc|Aring|Ecirc|Icirc|Ocirc|THORN|Ucirc|acirc|acute|aelig|aring|cedil|ecirc|icirc|iexcl|laquo|micro|ocirc|pound|raquo|szlig|thorn|times|ucirc|Auml|COPY|Euml|Iuml|Ouml|QUOT|Uuml|auml|cent|copy|euml|iuml|macr|nbsp|ordf|ordm|ouml|para|quot|sect|sup1|sup2|sup3|uuml|yuml|AMP|ETH|REG|amp|deg|eth|not|reg|shy|uml|yen|GT|LT|gt|lt)(?!;)([=a-zA-Z0-9]?)|&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+)/g,v={aacute:"\xE1",Aacute:"\xC1",abreve:"\u0103",Abreve:"\u0102",ac:"\u223E",acd:"\u223F",acE:"\u223E\u0333",acirc:"\xE2",Acirc:"\xC2",acute:"\xB4",acy:"\u0430",Acy:"\u0410",aelig:"\xE6",AElig:"\xC6",af:"\u2061",afr:"\u{1D51E}",Afr:"\u{1D504}",agrave:"\xE0",Agrave:"\xC0",alefsym:"\u2135",aleph:"\u2135",alpha:"\u03B1",Alpha:"\u0391",amacr:"\u0101",Amacr:"\u0100",amalg:"\u2A3F",amp:"&",AMP:"&",and:"\u2227",And:"\u2A53",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",aogon:"\u0105",Aogon:"\u0104",aopf:"\u{1D552}",Aopf:"\u{1D538}",ap:"\u2248",apacir:"\u2A6F",ape:"\u224A",apE:"\u2A70",apid:"\u224B",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224A",aring:"\xE5",Aring:"\xC5",ascr:"\u{1D4B6}",Ascr:"\u{1D49C}",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224D",atilde:"\xE3",Atilde:"\xC3",auml:"\xE4",Auml:"\xC4",awconint:"\u2233",awint:"\u2A11",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",Backslash:"\u2216",Barv:"\u2AE7",barvee:"\u22BD",barwed:"\u2305",Barwed:"\u2306",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",bcy:"\u0431",Bcy:"\u0411",bdquo:"\u201E",becaus:"\u2235",because:"\u2235",Because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",Bernoullis:"\u212C",beta:"\u03B2",Beta:"\u0392",beth:"\u2136",between:"\u226C",bfr:"\u{1D51F}",Bfr:"\u{1D505}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bnot:"\u2310",bNot:"\u2AED",bopf:"\u{1D553}",Bopf:"\u{1D539}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxbox:"\u29C9",boxdl:"\u2510",boxdL:"\u2555",boxDl:"\u2556",boxDL:"\u2557",boxdr:"\u250C",boxdR:"\u2552",boxDr:"\u2553",boxDR:"\u2554",boxh:"\u2500",boxH:"\u2550",boxhd:"\u252C",boxhD:"\u2565",boxHd:"\u2564",boxHD:"\u2566",boxhu:"\u2534",boxhU:"\u2568",boxHu:"\u2567",boxHU:"\u2569",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxul:"\u2518",boxuL:"\u255B",boxUl:"\u255C",boxUL:"\u255D",boxur:"\u2514",boxuR:"\u2558",boxUr:"\u2559",boxUR:"\u255A",boxv:"\u2502",boxV:"\u2551",boxvh:"\u253C",boxvH:"\u256A",boxVh:"\u256B",boxVH:"\u256C",boxvl:"\u2524",boxvL:"\u2561",boxVl:"\u2562",boxVL:"\u2563",boxvr:"\u251C",boxvR:"\u255E",boxVr:"\u255F",boxVR:"\u2560",bprime:"\u2035",breve:"\u02D8",Breve:"\u02D8",brvbar:"\xA6",bscr:"\u{1D4B7}",Bscr:"\u212C",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpe:"\u224F",bumpE:"\u2AAE",bumpeq:"\u224F",Bumpeq:"\u224E",cacute:"\u0107",Cacute:"\u0106",cap:"\u2229",Cap:"\u22D2",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",CapitalDifferentialD:"\u2145",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",Cayleys:"\u212D",ccaps:"\u2A4D",ccaron:"\u010D",Ccaron:"\u010C",ccedil:"\xE7",Ccedil:"\xC7",ccirc:"\u0109",Ccirc:"\u0108",Cconint:"\u2230",ccups:"\u2A4C",ccupssm:"\u2A50",cdot:"\u010B",Cdot:"\u010A",cedil:"\xB8",Cedilla:"\xB8",cemptyv:"\u29B2",cent:"\xA2",centerdot:"\xB7",CenterDot:"\xB7",cfr:"\u{1D520}",Cfr:"\u212D",chcy:"\u0447",CHcy:"\u0427",check:"\u2713",checkmark:"\u2713",chi:"\u03C7",Chi:"\u03A7",cir:"\u25CB",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",CircleDot:"\u2299",circledR:"\xAE",circledS:"\u24C8",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",cire:"\u2257",cirE:"\u29C3",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",clubs:"\u2663",clubsuit:"\u2663",colon:":",Colon:"\u2237",colone:"\u2254",Colone:"\u2A74",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",Congruent:"\u2261",conint:"\u222E",Conint:"\u222F",ContourIntegral:"\u222E",copf:"\u{1D554}",Copf:"\u2102",coprod:"\u2210",Coproduct:"\u2210",copy:"\xA9",COPY:"\xA9",copysr:"\u2117",CounterClockwiseContourIntegral:"\u2233",crarr:"\u21B5",cross:"\u2717",Cross:"\u2A2F",cscr:"\u{1D4B8}",Cscr:"\u{1D49E}",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",cup:"\u222A",Cup:"\u22D3",cupbrcap:"\u2A48",cupcap:"\u2A46",CupCap:"\u224D",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",dagger:"\u2020",Dagger:"\u2021",daleth:"\u2138",darr:"\u2193",dArr:"\u21D3",Darr:"\u21A1",dash:"\u2010",dashv:"\u22A3",Dashv:"\u2AE4",dbkarow:"\u290F",dblac:"\u02DD",dcaron:"\u010F",Dcaron:"\u010E",dcy:"\u0434",Dcy:"\u0414",dd:"\u2146",DD:"\u2145",ddagger:"\u2021",ddarr:"\u21CA",DDotrahd:"\u2911",ddotseq:"\u2A77",deg:"\xB0",Del:"\u2207",delta:"\u03B4",Delta:"\u0394",demptyv:"\u29B1",dfisht:"\u297F",dfr:"\u{1D521}",Dfr:"\u{1D507}",dHar:"\u2965",dharl:"\u21C3",dharr:"\u21C2",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",diam:"\u22C4",diamond:"\u22C4",Diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",DifferentialD:"\u2146",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",djcy:"\u0452",DJcy:"\u0402",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",dopf:"\u{1D555}",Dopf:"\u{1D53B}",dot:"\u02D9",Dot:"\xA8",DotDot:"\u20DC",doteq:"\u2250",doteqdot:"\u2251",DotEqual:"\u2250",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",downarrow:"\u2193",Downarrow:"\u21D3",DownArrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",dscr:"\u{1D4B9}",Dscr:"\u{1D49F}",dscy:"\u0455",DScy:"\u0405",dsol:"\u29F6",dstrok:"\u0111",Dstrok:"\u0110",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",dzcy:"\u045F",DZcy:"\u040F",dzigrarr:"\u27FF",eacute:"\xE9",Eacute:"\xC9",easter:"\u2A6E",ecaron:"\u011B",Ecaron:"\u011A",ecir:"\u2256",ecirc:"\xEA",Ecirc:"\xCA",ecolon:"\u2255",ecy:"\u044D",Ecy:"\u042D",eDDot:"\u2A77",edot:"\u0117",eDot:"\u2251",Edot:"\u0116",ee:"\u2147",efDot:"\u2252",efr:"\u{1D522}",Efr:"\u{1D508}",eg:"\u2A9A",egrave:"\xE8",Egrave:"\xC8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",Element:"\u2208",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",emacr:"\u0113",Emacr:"\u0112",empty:"\u2205",emptyset:"\u2205",EmptySmallSquare:"\u25FB",emptyv:"\u2205",EmptyVerySmallSquare:"\u25AB",emsp:"\u2003",emsp13:"\u2004",emsp14:"\u2005",eng:"\u014B",ENG:"\u014A",ensp:"\u2002",eogon:"\u0119",Eogon:"\u0118",eopf:"\u{1D556}",Eopf:"\u{1D53C}",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",epsilon:"\u03B5",Epsilon:"\u0395",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",Equal:"\u2A75",equals:"=",EqualTilde:"\u2242",equest:"\u225F",Equilibrium:"\u21CC",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erarr:"\u2971",erDot:"\u2253",escr:"\u212F",Escr:"\u2130",esdot:"\u2250",esim:"\u2242",Esim:"\u2A73",eta:"\u03B7",Eta:"\u0397",eth:"\xF0",ETH:"\xD0",euml:"\xEB",Euml:"\xCB",euro:"\u20AC",excl:"!",exist:"\u2203",Exists:"\u2203",expectation:"\u2130",exponentiale:"\u2147",ExponentialE:"\u2147",fallingdotseq:"\u2252",fcy:"\u0444",Fcy:"\u0424",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",ffr:"\u{1D523}",Ffr:"\u{1D509}",filig:"\uFB01",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",fopf:"\u{1D557}",Fopf:"\u{1D53D}",forall:"\u2200",ForAll:"\u2200",fork:"\u22D4",forkv:"\u2AD9",Fouriertrf:"\u2131",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",fscr:"\u{1D4BB}",Fscr:"\u2131",gacute:"\u01F5",gamma:"\u03B3",Gamma:"\u0393",gammad:"\u03DD",Gammad:"\u03DC",gap:"\u2A86",gbreve:"\u011F",Gbreve:"\u011E",Gcedil:"\u0122",gcirc:"\u011D",Gcirc:"\u011C",gcy:"\u0433",Gcy:"\u0413",gdot:"\u0121",Gdot:"\u0120",ge:"\u2265",gE:"\u2267",gel:"\u22DB",gEl:"\u2A8C",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",gfr:"\u{1D524}",Gfr:"\u{1D50A}",gg:"\u226B",Gg:"\u22D9",ggg:"\u22D9",gimel:"\u2137",gjcy:"\u0453",GJcy:"\u0403",gl:"\u2277",gla:"\u2AA5",glE:"\u2A92",glj:"\u2AA4",gnap:"\u2A8A",gnapprox:"\u2A8A",gne:"\u2A88",gnE:"\u2269",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",gopf:"\u{1D558}",Gopf:"\u{1D53E}",grave:"`",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",gscr:"\u210A",Gscr:"\u{1D4A2}",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",gt:">",Gt:"\u226B",GT:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",Hacek:"\u02C7",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",hardcy:"\u044A",HARDcy:"\u042A",harr:"\u2194",hArr:"\u21D4",harrcir:"\u2948",harrw:"\u21AD",Hat:"^",hbar:"\u210F",hcirc:"\u0125",Hcirc:"\u0124",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",hfr:"\u{1D525}",Hfr:"\u210C",HilbertSpace:"\u210B",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",hopf:"\u{1D559}",Hopf:"\u210D",horbar:"\u2015",HorizontalLine:"\u2500",hscr:"\u{1D4BD}",Hscr:"\u210B",hslash:"\u210F",hstrok:"\u0127",Hstrok:"\u0126",HumpDownHump:"\u224E",HumpEqual:"\u224F",hybull:"\u2043",hyphen:"\u2010",iacute:"\xED",Iacute:"\xCD",ic:"\u2063",icirc:"\xEE",Icirc:"\xCE",icy:"\u0438",Icy:"\u0418",Idot:"\u0130",iecy:"\u0435",IEcy:"\u0415",iexcl:"\xA1",iff:"\u21D4",ifr:"\u{1D526}",Ifr:"\u2111",igrave:"\xEC",Igrave:"\xCC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",ijlig:"\u0133",IJlig:"\u0132",Im:"\u2111",imacr:"\u012B",Imacr:"\u012A",image:"\u2111",ImaginaryI:"\u2148",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",Implies:"\u21D2",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",int:"\u222B",Int:"\u222C",intcal:"\u22BA",integers:"\u2124",Integral:"\u222B",intercal:"\u22BA",Intersection:"\u22C2",intlarhk:"\u2A17",intprod:"\u2A3C",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",iocy:"\u0451",IOcy:"\u0401",iogon:"\u012F",Iogon:"\u012E",iopf:"\u{1D55A}",Iopf:"\u{1D540}",iota:"\u03B9",Iota:"\u0399",iprod:"\u2A3C",iquest:"\xBF",iscr:"\u{1D4BE}",Iscr:"\u2110",isin:"\u2208",isindot:"\u22F5",isinE:"\u22F9",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",itilde:"\u0129",Itilde:"\u0128",iukcy:"\u0456",Iukcy:"\u0406",iuml:"\xEF",Iuml:"\xCF",jcirc:"\u0135",Jcirc:"\u0134",jcy:"\u0439",Jcy:"\u0419",jfr:"\u{1D527}",Jfr:"\u{1D50D}",jmath:"\u0237",jopf:"\u{1D55B}",Jopf:"\u{1D541}",jscr:"\u{1D4BF}",Jscr:"\u{1D4A5}",jsercy:"\u0458",Jsercy:"\u0408",jukcy:"\u0454",Jukcy:"\u0404",kappa:"\u03BA",Kappa:"\u039A",kappav:"\u03F0",kcedil:"\u0137",Kcedil:"\u0136",kcy:"\u043A",Kcy:"\u041A",kfr:"\u{1D528}",Kfr:"\u{1D50E}",kgreen:"\u0138",khcy:"\u0445",KHcy:"\u0425",kjcy:"\u045C",KJcy:"\u040C",kopf:"\u{1D55C}",Kopf:"\u{1D542}",kscr:"\u{1D4C0}",Kscr:"\u{1D4A6}",lAarr:"\u21DA",lacute:"\u013A",Lacute:"\u0139",laemptyv:"\u29B4",lagran:"\u2112",lambda:"\u03BB",Lambda:"\u039B",lang:"\u27E8",Lang:"\u27EA",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",Laplacetrf:"\u2112",laquo:"\xAB",larr:"\u2190",lArr:"\u21D0",Larr:"\u219E",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",latail:"\u2919",lAtail:"\u291B",late:"\u2AAD",lates:"\u2AAD\uFE00",lbarr:"\u290C",lBarr:"\u290E",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",lcaron:"\u013E",Lcaron:"\u013D",lcedil:"\u013C",Lcedil:"\u013B",lceil:"\u2308",lcub:"{",lcy:"\u043B",Lcy:"\u041B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",le:"\u2264",lE:"\u2266",LeftAngleBracket:"\u27E8",leftarrow:"\u2190",Leftarrow:"\u21D0",LeftArrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",leftarrowtail:"\u21A2",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",leftrightarrow:"\u2194",Leftrightarrow:"\u21D4",LeftRightArrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",leftthreetimes:"\u22CB",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",leg:"\u22DA",lEg:"\u2A8B",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",lessgtr:"\u2276",LessLess:"\u2AA1",lesssim:"\u2272",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",lfisht:"\u297C",lfloor:"\u230A",lfr:"\u{1D529}",Lfr:"\u{1D50F}",lg:"\u2276",lgE:"\u2A91",lHar:"\u2962",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",ljcy:"\u0459",LJcy:"\u0409",ll:"\u226A",Ll:"\u22D8",llarr:"\u21C7",llcorner:"\u231E",Lleftarrow:"\u21DA",llhard:"\u296B",lltri:"\u25FA",lmidot:"\u0140",Lmidot:"\u013F",lmoust:"\u23B0",lmoustache:"\u23B0",lnap:"\u2A89",lnapprox:"\u2A89",lne:"\u2A87",lnE:"\u2268",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",longleftarrow:"\u27F5",Longleftarrow:"\u27F8",LongLeftArrow:"\u27F5",longleftrightarrow:"\u27F7",Longleftrightarrow:"\u27FA",LongLeftRightArrow:"\u27F7",longmapsto:"\u27FC",longrightarrow:"\u27F6",Longrightarrow:"\u27F9",LongRightArrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",lopf:"\u{1D55D}",Lopf:"\u{1D543}",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",lscr:"\u{1D4C1}",Lscr:"\u2112",lsh:"\u21B0",Lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",lstrok:"\u0142",Lstrok:"\u0141",lt:"<",Lt:"\u226A",LT:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",ltrPar:"\u2996",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",map:"\u21A6",Map:"\u2905",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",mcy:"\u043C",Mcy:"\u041C",mdash:"\u2014",mDDot:"\u223A",measuredangle:"\u2221",MediumSpace:"\u205F",Mellintrf:"\u2133",mfr:"\u{1D52A}",Mfr:"\u{1D510}",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",MinusPlus:"\u2213",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",mopf:"\u{1D55E}",Mopf:"\u{1D544}",mp:"\u2213",mscr:"\u{1D4C2}",Mscr:"\u2133",mstpos:"\u223E",mu:"\u03BC",Mu:"\u039C",multimap:"\u22B8",mumap:"\u22B8",nabla:"\u2207",nacute:"\u0144",Nacute:"\u0143",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",ncaron:"\u0148",Ncaron:"\u0147",ncedil:"\u0146",Ncedil:"\u0145",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",ncy:"\u043D",Ncy:"\u041D",ndash:"\u2013",ne:"\u2260",nearhk:"\u2924",nearr:"\u2197",neArr:"\u21D7",nearrow:"\u2197",nedot:"\u2250\u0338",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
`,nexist:"\u2204",nexists:"\u2204",nfr:"\u{1D52B}",Nfr:"\u{1D511}",nge:"\u2271",ngE:"\u2267\u0338",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",ngt:"\u226F",nGt:"\u226B\u20D2",ngtr:"\u226F",nGtv:"\u226B\u0338",nharr:"\u21AE",nhArr:"\u21CE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",njcy:"\u045A",NJcy:"\u040A",nlarr:"\u219A",nlArr:"\u21CD",nldr:"\u2025",nle:"\u2270",nlE:"\u2266\u0338",nleftarrow:"\u219A",nLeftarrow:"\u21CD",nleftrightarrow:"\u21AE",nLeftrightarrow:"\u21CE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nlt:"\u226E",nLt:"\u226A\u20D2",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",nopf:"\u{1D55F}",Nopf:"\u2115",not:"\xAC",Not:"\u2AEC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrarr:"\u219B",nrArr:"\u21CF",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nrightarrow:"\u219B",nRightarrow:"\u21CF",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",nscr:"\u{1D4C3}",Nscr:"\u{1D4A9}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsube:"\u2288",nsubE:"\u2AC5\u0338",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupe:"\u2289",nsupE:"\u2AC6\u0338",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",ntilde:"\xF1",Ntilde:"\xD1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",nu:"\u03BD",Nu:"\u039D",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nvdash:"\u22AC",nvDash:"\u22AD",nVdash:"\u22AE",nVDash:"\u22AF",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwarr:"\u2196",nwArr:"\u21D6",nwarrow:"\u2196",nwnear:"\u2927",oacute:"\xF3",Oacute:"\xD3",oast:"\u229B",ocir:"\u229A",ocirc:"\xF4",Ocirc:"\xD4",ocy:"\u043E",Ocy:"\u041E",odash:"\u229D",odblac:"\u0151",Odblac:"\u0150",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",oelig:"\u0153",OElig:"\u0152",ofcir:"\u29BF",ofr:"\u{1D52C}",Ofr:"\u{1D512}",ogon:"\u02DB",ograve:"\xF2",Ograve:"\xD2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",omacr:"\u014D",Omacr:"\u014C",omega:"\u03C9",Omega:"\u03A9",omicron:"\u03BF",Omicron:"\u039F",omid:"\u29B6",ominus:"\u2296",oopf:"\u{1D560}",Oopf:"\u{1D546}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",or:"\u2228",Or:"\u2A54",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",oscr:"\u2134",Oscr:"\u{1D4AA}",oslash:"\xF8",Oslash:"\xD8",osol:"\u2298",otilde:"\xF5",Otilde:"\xD5",otimes:"\u2297",Otimes:"\u2A37",otimesas:"\u2A36",ouml:"\xF6",Ouml:"\xD6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",PartialD:"\u2202",pcy:"\u043F",Pcy:"\u041F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",pfr:"\u{1D52D}",Pfr:"\u{1D513}",phi:"\u03C6",Phi:"\u03A6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",pi:"\u03C0",Pi:"\u03A0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",PlusMinus:"\xB1",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",Poincareplane:"\u210C",pointint:"\u2A15",popf:"\u{1D561}",Popf:"\u2119",pound:"\xA3",pr:"\u227A",Pr:"\u2ABB",prap:"\u2AB7",prcue:"\u227C",pre:"\u2AAF",prE:"\u2AB3",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",prime:"\u2032",Prime:"\u2033",primes:"\u2119",prnap:"\u2AB9",prnE:"\u2AB5",prnsim:"\u22E8",prod:"\u220F",Product:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",Proportion:"\u2237",Proportional:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",pscr:"\u{1D4C5}",Pscr:"\u{1D4AB}",psi:"\u03C8",Psi:"\u03A8",puncsp:"\u2008",qfr:"\u{1D52E}",Qfr:"\u{1D514}",qint:"\u2A0C",qopf:"\u{1D562}",Qopf:"\u211A",qprime:"\u2057",qscr:"\u{1D4C6}",Qscr:"\u{1D4AC}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",quot:'"',QUOT:'"',rAarr:"\u21DB",race:"\u223D\u0331",racute:"\u0155",Racute:"\u0154",radic:"\u221A",raemptyv:"\u29B3",rang:"\u27E9",Rang:"\u27EB",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",rarr:"\u2192",rArr:"\u21D2",Rarr:"\u21A0",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",rarrtl:"\u21A3",Rarrtl:"\u2916",rarrw:"\u219D",ratail:"\u291A",rAtail:"\u291C",ratio:"\u2236",rationals:"\u211A",rbarr:"\u290D",rBarr:"\u290F",RBarr:"\u2910",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",rcaron:"\u0159",Rcaron:"\u0158",rcedil:"\u0157",Rcedil:"\u0156",rceil:"\u2309",rcub:"}",rcy:"\u0440",Rcy:"\u0420",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",Re:"\u211C",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",reg:"\xAE",REG:"\xAE",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",rfisht:"\u297D",rfloor:"\u230B",rfr:"\u{1D52F}",Rfr:"\u211C",rHar:"\u2964",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",rho:"\u03C1",Rho:"\u03A1",rhov:"\u03F1",RightAngleBracket:"\u27E9",rightarrow:"\u2192",Rightarrow:"\u21D2",RightArrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",rightarrowtail:"\u21A3",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",rightthreetimes:"\u22CC",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",ropf:"\u{1D563}",Ropf:"\u211D",roplus:"\u2A2E",rotimes:"\u2A35",RoundImplies:"\u2970",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",Rrightarrow:"\u21DB",rsaquo:"\u203A",rscr:"\u{1D4C7}",Rscr:"\u211B",rsh:"\u21B1",Rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",RuleDelayed:"\u29F4",ruluhar:"\u2968",rx:"\u211E",sacute:"\u015B",Sacute:"\u015A",sbquo:"\u201A",sc:"\u227B",Sc:"\u2ABC",scap:"\u2AB8",scaron:"\u0161",Scaron:"\u0160",sccue:"\u227D",sce:"\u2AB0",scE:"\u2AB4",scedil:"\u015F",Scedil:"\u015E",scirc:"\u015D",Scirc:"\u015C",scnap:"\u2ABA",scnE:"\u2AB6",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",scy:"\u0441",Scy:"\u0421",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",searhk:"\u2925",searr:"\u2198",seArr:"\u21D8",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",sfr:"\u{1D530}",Sfr:"\u{1D516}",sfrown:"\u2322",sharp:"\u266F",shchcy:"\u0449",SHCHcy:"\u0429",shcy:"\u0448",SHcy:"\u0428",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",shortmid:"\u2223",shortparallel:"\u2225",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",shy:"\xAD",sigma:"\u03C3",Sigma:"\u03A3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",SmallCircle:"\u2218",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",softcy:"\u044C",SOFTcy:"\u042C",sol:"/",solb:"\u29C4",solbar:"\u233F",sopf:"\u{1D564}",Sopf:"\u{1D54A}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",Sqrt:"\u221A",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",square:"\u25A1",Square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",sscr:"\u{1D4C8}",Sscr:"\u{1D4AE}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",star:"\u2606",Star:"\u22C6",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",sub:"\u2282",Sub:"\u22D0",subdot:"\u2ABD",sube:"\u2286",subE:"\u2AC5",subedot:"\u2AC3",submult:"\u2AC1",subne:"\u228A",subnE:"\u2ACB",subplus:"\u2ABF",subrarr:"\u2979",subset:"\u2282",Subset:"\u22D0",subseteq:"\u2286",subseteqq:"\u2AC5",SubsetEqual:"\u2286",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",SuchThat:"\u220B",sum:"\u2211",Sum:"\u2211",sung:"\u266A",sup:"\u2283",Sup:"\u22D1",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",supdot:"\u2ABE",supdsub:"\u2AD8",supe:"\u2287",supE:"\u2AC6",supedot:"\u2AC4",Superset:"\u2283",SupersetEqual:"\u2287",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supne:"\u228B",supnE:"\u2ACC",supplus:"\u2AC0",supset:"\u2283",Supset:"\u22D1",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swarhk:"\u2926",swarr:"\u2199",swArr:"\u21D9",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",Tab:" ",target:"\u2316",tau:"\u03C4",Tau:"\u03A4",tbrk:"\u23B4",tcaron:"\u0165",Tcaron:"\u0164",tcedil:"\u0163",Tcedil:"\u0162",tcy:"\u0442",Tcy:"\u0422",tdot:"\u20DB",telrec:"\u2315",tfr:"\u{1D531}",Tfr:"\u{1D517}",there4:"\u2234",therefore:"\u2234",Therefore:"\u2234",theta:"\u03B8",Theta:"\u0398",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",ThickSpace:"\u205F\u200A",thinsp:"\u2009",ThinSpace:"\u2009",thkap:"\u2248",thksim:"\u223C",thorn:"\xFE",THORN:"\xDE",tilde:"\u02DC",Tilde:"\u223C",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",topf:"\u{1D565}",Topf:"\u{1D54B}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",trade:"\u2122",TRADE:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",TripleDot:"\u20DB",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",tscr:"\u{1D4C9}",Tscr:"\u{1D4AF}",tscy:"\u0446",TScy:"\u0426",tshcy:"\u045B",TSHcy:"\u040B",tstrok:"\u0167",Tstrok:"\u0166",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",uacute:"\xFA",Uacute:"\xDA",uarr:"\u2191",uArr:"\u21D1",Uarr:"\u219F",Uarrocir:"\u2949",ubrcy:"\u045E",Ubrcy:"\u040E",ubreve:"\u016D",Ubreve:"\u016C",ucirc:"\xFB",Ucirc:"\xDB",ucy:"\u0443",Ucy:"\u0423",udarr:"\u21C5",udblac:"\u0171",Udblac:"\u0170",udhar:"\u296E",ufisht:"\u297E",ufr:"\u{1D532}",Ufr:"\u{1D518}",ugrave:"\xF9",Ugrave:"\xD9",uHar:"\u2963",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",umacr:"\u016B",Umacr:"\u016A",uml:"\xA8",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",uogon:"\u0173",Uogon:"\u0172",uopf:"\u{1D566}",Uopf:"\u{1D54C}",uparrow:"\u2191",Uparrow:"\u21D1",UpArrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",updownarrow:"\u2195",Updownarrow:"\u21D5",UpDownArrow:"\u2195",UpEquilibrium:"\u296E",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",upsi:"\u03C5",Upsi:"\u03D2",upsih:"\u03D2",upsilon:"\u03C5",Upsilon:"\u03A5",UpTee:"\u22A5",UpTeeArrow:"\u21A5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",uring:"\u016F",Uring:"\u016E",urtri:"\u25F9",uscr:"\u{1D4CA}",Uscr:"\u{1D4B0}",utdot:"\u22F0",utilde:"\u0169",Utilde:"\u0168",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",uuml:"\xFC",Uuml:"\xDC",uwangle:"\u29A7",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",varr:"\u2195",vArr:"\u21D5",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",vBar:"\u2AE8",Vbar:"\u2AEB",vBarv:"\u2AE9",vcy:"\u0432",Vcy:"\u0412",vdash:"\u22A2",vDash:"\u22A8",Vdash:"\u22A9",VDash:"\u22AB",Vdashl:"\u2AE6",vee:"\u2228",Vee:"\u22C1",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",verbar:"|",Verbar:"\u2016",vert:"|",Vert:"\u2016",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",vfr:"\u{1D533}",Vfr:"\u{1D519}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",vopf:"\u{1D567}",Vopf:"\u{1D54D}",vprop:"\u221D",vrtri:"\u22B3",vscr:"\u{1D4CB}",Vscr:"\u{1D4B1}",vsubne:"\u228A\uFE00",vsubnE:"\u2ACB\uFE00",vsupne:"\u228B\uFE00",vsupnE:"\u2ACC\uFE00",Vvdash:"\u22AA",vzigzag:"\u299A",wcirc:"\u0175",Wcirc:"\u0174",wedbar:"\u2A5F",wedge:"\u2227",Wedge:"\u22C0",wedgeq:"\u2259",weierp:"\u2118",wfr:"\u{1D534}",Wfr:"\u{1D51A}",wopf:"\u{1D568}",Wopf:"\u{1D54E}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",wscr:"\u{1D4CC}",Wscr:"\u{1D4B2}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",xfr:"\u{1D535}",Xfr:"\u{1D51B}",xharr:"\u27F7",xhArr:"\u27FA",xi:"\u03BE",Xi:"\u039E",xlarr:"\u27F5",xlArr:"\u27F8",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",xopf:"\u{1D569}",Xopf:"\u{1D54F}",xoplus:"\u2A01",xotime:"\u2A02",xrarr:"\u27F6",xrArr:"\u27F9",xscr:"\u{1D4CD}",Xscr:"\u{1D4B3}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",yacute:"\xFD",Yacute:"\xDD",yacy:"\u044F",YAcy:"\u042F",ycirc:"\u0177",Ycirc:"\u0176",ycy:"\u044B",Ycy:"\u042B",yen:"\xA5",yfr:"\u{1D536}",Yfr:"\u{1D51C}",yicy:"\u0457",YIcy:"\u0407",yopf:"\u{1D56A}",Yopf:"\u{1D550}",yscr:"\u{1D4CE}",Yscr:"\u{1D4B4}",yucy:"\u044E",YUcy:"\u042E",yuml:"\xFF",Yuml:"\u0178",zacute:"\u017A",Zacute:"\u0179",zcaron:"\u017E",Zcaron:"\u017D",zcy:"\u0437",Zcy:"\u0417",zdot:"\u017C",Zdot:"\u017B",zeetrf:"\u2128",ZeroWidthSpace:"\u200B",zeta:"\u03B6",Zeta:"\u0396",zfr:"\u{1D537}",Zfr:"\u2128",zhcy:"\u0436",ZHcy:"\u0416",zigrarr:"\u21DD",zopf:"\u{1D56B}",Zopf:"\u2124",zscr:"\u{1D4CF}",Zscr:"\u{1D4B5}",zwj:"\u200D",zwnj:"\u200C"},g={aacute:"\xE1",Aacute:"\xC1",acirc:"\xE2",Acirc:"\xC2",acute:"\xB4",aelig:"\xE6",AElig:"\xC6",agrave:"\xE0",Agrave:"\xC0",amp:"&",AMP:"&",aring:"\xE5",Aring:"\xC5",atilde:"\xE3",Atilde:"\xC3",auml:"\xE4",Auml:"\xC4",brvbar:"\xA6",ccedil:"\xE7",Ccedil:"\xC7",cedil:"\xB8",cent:"\xA2",copy:"\xA9",COPY:"\xA9",curren:"\xA4",deg:"\xB0",divide:"\xF7",eacute:"\xE9",Eacute:"\xC9",ecirc:"\xEA",Ecirc:"\xCA",egrave:"\xE8",Egrave:"\xC8",eth:"\xF0",ETH:"\xD0",euml:"\xEB",Euml:"\xCB",frac12:"\xBD",frac14:"\xBC",frac34:"\xBE",gt:">",GT:">",iacute:"\xED",Iacute:"\xCD",icirc:"\xEE",Icirc:"\xCE",iexcl:"\xA1",igrave:"\xEC",Igrave:"\xCC",iquest:"\xBF",iuml:"\xEF",Iuml:"\xCF",laquo:"\xAB",lt:"<",LT:"<",macr:"\xAF",micro:"\xB5",middot:"\xB7",nbsp:"\xA0",not:"\xAC",ntilde:"\xF1",Ntilde:"\xD1",oacute:"\xF3",Oacute:"\xD3",ocirc:"\xF4",Ocirc:"\xD4",ograve:"\xF2",Ograve:"\xD2",ordf:"\xAA",ordm:"\xBA",oslash:"\xF8",Oslash:"\xD8",otilde:"\xF5",Otilde:"\xD5",ouml:"\xF6",Ouml:"\xD6",para:"\xB6",plusmn:"\xB1",pound:"\xA3",quot:'"',QUOT:'"',raquo:"\xBB",reg:"\xAE",REG:"\xAE",sect:"\xA7",shy:"\xAD",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",szlig:"\xDF",thorn:"\xFE",THORN:"\xDE",times:"\xD7",uacute:"\xFA",Uacute:"\xDA",ucirc:"\xFB",Ucirc:"\xDB",ugrave:"\xF9",Ugrave:"\xD9",uml:"\xA8",uuml:"\xFC",Uuml:"\xDC",yacute:"\xFD",Yacute:"\xDD",yen:"\xA5",yuml:"\xFF"},x={"0":"\uFFFD","128":"\u20AC","130":"\u201A","131":"\u0192","132":"\u201E","133":"\u2026","134":"\u2020","135":"\u2021","136":"\u02C6","137":"\u2030","138":"\u0160","139":"\u2039","140":"\u0152","142":"\u017D","145":"\u2018","146":"\u2019","147":"\u201C","148":"\u201D","149":"\u2022","150":"\u2013","151":"\u2014","152":"\u02DC","153":"\u2122","154":"\u0161","155":"\u203A","156":"\u0153","158":"\u017E","159":"\u0178"},p=[1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65e3,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111],d=String.fromCharCode,A={},b=A.hasOwnProperty,C=function(N,U){return b.call(N,U)},E=function(N,U){for(var Z=-1,O=N.length;++Z<O;)if(N[Z]==U)return!0;return!1},T=function(N,U){if(!N)return U;var Z={},O;for(O in U)Z[O]=C(N,O)?N[O]:U[O];return Z},_=function(N,U){var Z="";return N>=55296&&N<=57343||N>1114111?(U&&M("character reference outside the permissible Unicode range"),"\uFFFD"):C(x,N)?(U&&M("disallowed character reference"),x[N]):(U&&E(p,N)&&M("disallowed character reference"),N>65535&&(N-=65536,Z+=d(N>>>10&1023|55296),N=56320|N&1023),Z+=d(N),Z)},P=function(N){return"&#x"+N.toString(16).toUpperCase()+";"},F=function(N){return"&#"+N+";"},M=function(N){throw Error("Parse error: "+N)},D=function(N,U){U=T(U,D.options);var Z=U.strict;Z&&h.test(N)&&M("forbidden code point");var O=U.encodeEverything,W=U.useNamedReferences,X=U.allowUnsafeSymbols,Q=U.decimal?F:P,a1=function(B){return Q(B.charCodeAt(0))};return O?(N=N.replace(r,function(B){return W&&C(c,B)?"&"+c[B]+";":a1(B)}),W&&(N=N.replace(/&gt;\u20D2/g,"&nvgt;").replace(/&lt;\u20D2/g,"&nvlt;").replace(/&#x66;&#x6A;/g,"&fjlig;")),W&&(N=N.replace(o,function(B){return"&"+c[B]+";"}))):W?(X||(N=N.replace(l,function(B){return"&"+c[B]+";"})),N=N.replace(/&gt;\u20D2/g,"&nvgt;").replace(/&lt;\u20D2/g,"&nvlt;"),N=N.replace(o,function(B){return"&"+c[B]+";"})):X||(N=N.replace(l,a1)),N.replace(a,function(B){var M1=B.charCodeAt(0),u1=B.charCodeAt(1),v1=(M1-55296)*1024+u1-56320+65536;return Q(v1)}).replace(s,a1)};D.options={allowUnsafeSymbols:!1,encodeEverything:!1,strict:!1,useNamedReferences:!1,decimal:!1};var z=function(N,U){U=T(U,z.options);var Z=U.strict;return Z&&f.test(N)&&M("malformed character reference"),N.replace(m,function(O,W,X,Q,a1,B,M1,u1,v1){var n1,T1,A1,C1,h2,K1;return W?(h2=W,v[h2]):X?(h2=X,K1=Q,K1&&U.isAttributeValue?(Z&&K1=="="&&M("`&` did not start a character reference"),O):(Z&&M("named character reference was not terminated by a semicolon"),g[h2]+(K1||""))):a1?(A1=a1,T1=B,Z&&!T1&&M("character reference was not terminated by a semicolon"),n1=parseInt(A1,10),_(n1,Z)):M1?(C1=M1,T1=u1,Z&&!T1&&M("character reference was not terminated by a semicolon"),n1=parseInt(C1,16),_(n1,Z)):(Z&&M("named character reference was not terminated by a semicolon"),O)})};z.options={isAttributeValue:!1,strict:!1};var H=function(N){return N.replace(l,function(U){return u[U]})},V={version:"1.2.0",encode:D,decode:z,escape:H,unescape:z};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd)define(function(){return V});else if(e&&!e.nodeType)if(t)t.exports=V;else for(var L in V)C(V,L)&&(e[L]=V[L]);else n.he=V})(s6)});var So=M0((wo,v0)=>{(function(n,e){typeof define=="function"&&define.amd?define([],e):typeof v0=="object"&&v0.exports?v0.exports=e():n.moo=e()})(wo,function(){"use strict";var n=Object.prototype.hasOwnProperty,e=Object.prototype.toString,t=typeof new RegExp().sticky=="boolean";function i(_){return _&&e.call(_)==="[object RegExp]"}function a(_){return _&&typeof _=="object"&&!i(_)&&!Array.isArray(_)}function r(_){return _.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function s(_){var P=new RegExp("|"+_);return P.exec("").length-1}function o(_){return"("+_+")"}function c(_){if(!_.length)return"(?!)";var P=_.map(function(F){return"(?:"+F+")"}).join("|");return"(?:"+P+")"}function l(_){if(typeof _=="string")return"(?:"+r(_)+")";if(i(_)){if(_.ignoreCase)throw new Error("RegExp /i flag not allowed");if(_.global)throw new Error("RegExp /g flag is implied");if(_.sticky)throw new Error("RegExp /y flag is implied");if(_.multiline)throw new Error("RegExp /m flag is implied");return _.source}else throw new Error("Not a pattern: "+_)}function u(_){for(var P=Object.getOwnPropertyNames(_),F=[],M=0;M<P.length;M++){var D=P[M],z=_[D],H=[].concat(z);if(D==="include"){for(var V=0;V<H.length;V++)F.push({include:H[V]});continue}var L=[];H.forEach(function(N){a(N)?(L.length&&F.push(h(D,L)),F.push(h(D,N)),L=[]):L.push(N)}),L.length&&F.push(h(D,L))}return F}function f(_){for(var P=[],F=0;F<_.length;F++){var M=_[F];if(M.include){for(var D=[].concat(M.include),z=0;z<D.length;z++)P.push({include:D[z]});continue}if(!M.type)throw new Error("Rule has no type: "+JSON.stringify(M));P.push(h(M.type,M))}return P}function h(_,P){if(a(P)||(P={match:P}),P.include)throw new Error("Matching rules cannot also include states");var F={defaultType:_,lineBreaks:!!P.error||!!P.fallback,pop:!1,next:null,push:null,error:!1,fallback:!1,value:null,type:null,shouldThrow:!1};for(var M in P)n.call(P,M)&&(F[M]=P[M]);if(typeof F.type=="string"&&_!==F.type)throw new Error("Type transform cannot be a string (type '"+F.type+"' for token '"+_+"')");var D=F.match;return F.match=Array.isArray(D)?D:D?[D]:[],F.match.sort(function(z,H){return i(z)&&i(H)?0:i(H)?-1:i(z)?1:H.length-z.length}),F}function m(_){return Array.isArray(_)?f(_):u(_)}var v=h("error",{lineBreaks:!0,shouldThrow:!0});function g(_,P){for(var F=null,M=Object.create(null),D=!0,z=null,H=[],V=[],L=0;L<_.length;L++)_[L].fallback&&(D=!1);for(var L=0;L<_.length;L++){var N=_[L];if(N.include)throw new Error("Inheritance is not allowed in stateless lexers");if(N.error||N.fallback){if(F)throw!N.fallback==!F.fallback?new Error("Multiple "+(N.fallback?"fallback":"error")+" rules not allowed (for token '"+N.defaultType+"')"):new Error("fallback and error are mutually exclusive (for token '"+N.defaultType+"')");F=N}var U=N.match.slice();if(D)for(;U.length&&typeof U[0]=="string"&&U[0].length===1;){var Z=U.shift();M[Z.charCodeAt(0)]=N}if(N.pop||N.push||N.next){if(!P)throw new Error("State-switching options are not allowed in stateless lexers (for token '"+N.defaultType+"')");if(N.fallback)throw new Error("State-switching options are not allowed on fallback tokens (for token '"+N.defaultType+"')")}if(U.length!==0){D=!1,H.push(N);for(var O=0;O<U.length;O++){var W=U[O];if(!!i(W)){if(z===null)z=W.unicode;else if(z!==W.unicode&&N.fallback===!1)throw new Error("If one rule is /u then all must be")}}var X=c(U.map(l)),Q=new RegExp(X);if(Q.test(""))throw new Error("RegExp matches empty string: "+Q);var a1=s(X);if(a1>0)throw new Error("RegExp has capture groups: "+Q+`
Use (?: \u2026 ) instead`);if(!N.lineBreaks&&Q.test(`
`))throw new Error("Rule should declare lineBreaks: "+Q);V.push(o(X))}}var B=F&&F.fallback,M1=t&&!B?"ym":"gm",u1=t||B?"":"|";z===!0&&(M1+="u");var v1=new RegExp(c(V)+u1,M1);return{regexp:v1,groups:H,fast:M,error:F||v}}function x(_){var P=g(m(_));return new b({start:P},"start")}function p(_,P,F){var M=_&&(_.push||_.next);if(M&&!F[M])throw new Error("Missing state '"+M+"' (in token '"+_.defaultType+"' of state '"+P+"')");if(_&&_.pop&&+_.pop!=1)throw new Error("pop must be 1 (in token '"+_.defaultType+"' of state '"+P+"')")}function d(_,P){var F=_.$all?m(_.$all):[];delete _.$all;var M=Object.getOwnPropertyNames(_);P||(P=M[0]);for(var D=Object.create(null),z=0;z<M.length;z++){var H=M[z];D[H]=m(_[H]).concat(F)}for(var z=0;z<M.length;z++)for(var H=M[z],V=D[H],L=Object.create(null),N=0;N<V.length;N++){var U=V[N];if(!!U.include){var Z=[N,1];if(U.include!==H&&!L[U.include]){L[U.include]=!0;var O=D[U.include];if(!O)throw new Error("Cannot include nonexistent state '"+U.include+"' (in state '"+H+"')");for(var W=0;W<O.length;W++){var X=O[W];V.indexOf(X)===-1&&Z.push(X)}}V.splice.apply(V,Z),N--}}for(var Q=Object.create(null),z=0;z<M.length;z++){var H=M[z];Q[H]=g(D[H],!0)}for(var z=0;z<M.length;z++){for(var a1=M[z],B=Q[a1],M1=B.groups,N=0;N<M1.length;N++)p(M1[N],a1,Q);for(var u1=Object.getOwnPropertyNames(B.fast),N=0;N<u1.length;N++)p(B.fast[u1[N]],a1,Q)}return new b(Q,P)}function A(_){for(var P=Object.create(null),F=Object.create(null),M=Object.getOwnPropertyNames(_),D=0;D<M.length;D++){var z=M[D],H=_[z],V=Array.isArray(H)?H:[H];V.forEach(function(O){if((F[O.length]=F[O.length]||[]).push(O),typeof O!="string")throw new Error("keyword must be string (in keyword '"+z+"')");P[O]=z})}function L(O){return JSON.stringify(O)}var N="";N+=`switch (value.length) {
`;for(var U in F){var Z=F[U];N+="case "+U+`:
`,N+=`switch (value) {
`,Z.forEach(function(O){var W=P[O];N+="case "+L(O)+": return "+L(W)+`
`}),N+=`}
`}return N+=`}
`,Function("value",N)}var b=function(_,P){this.startState=P,this.states=_,this.buffer="",this.stack=[],this.reset()};b.prototype.reset=function(_,P){return this.buffer=_||"",this.index=0,this.line=P?P.line:1,this.col=P?P.col:1,this.queuedToken=P?P.queuedToken:null,this.queuedThrow=P?P.queuedThrow:null,this.setState(P?P.state:this.startState),this.stack=P&&P.stack?P.stack.slice():[],this},b.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedThrow:this.queuedThrow}},b.prototype.setState=function(_){if(!(!_||this.state===_)){this.state=_;var P=this.states[_];this.groups=P.groups,this.error=P.error,this.re=P.regexp,this.fast=P.fast}},b.prototype.popState=function(){this.setState(this.stack.pop())},b.prototype.pushState=function(_){this.stack.push(this.state),this.setState(_)};var C=t?function(_,P){return _.exec(P)}:function(_,P){var F=_.exec(P);return F[0].length===0?null:F};b.prototype._getGroup=function(_){for(var P=this.groups.length,F=0;F<P;F++)if(_[F+1]!==void 0)return this.groups[F];throw new Error("Cannot find token type for matched text")};function E(){return this.value}if(b.prototype.next=function(){var _=this.index;if(this.queuedGroup){var P=this._token(this.queuedGroup,this.queuedText,_);return this.queuedGroup=null,this.queuedText="",P}var F=this.buffer;if(_!==F.length){var M=this.fast[F.charCodeAt(_)];if(M)return this._token(M,F.charAt(_),_);var D=this.re;D.lastIndex=_;var z=C(D,F),H=this.error;if(z==null)return this._token(H,F.slice(_,F.length),_);var M=this._getGroup(z),V=z[0];return H.fallback&&z.index!==_?(this.queuedGroup=M,this.queuedText=V,this._token(H,F.slice(_,z.index),_)):this._token(M,V,_)}},b.prototype._token=function(_,P,F){var M=0;if(_.lineBreaks){var D=/\n/g,z=1;if(P===`
`)M=1;else for(;D.exec(P);)M++,z=D.lastIndex}var H={type:typeof _.type=="function"&&_.type(P)||_.defaultType,value:typeof _.value=="function"?_.value(P):P,text:P,toString:E,offset:F,lineBreaks:M,line:this.line,col:this.col},V=P.length;if(this.index+=V,this.line+=M,M!==0?this.col=V-z+1:this.col+=V,_.shouldThrow)throw new Error(this.formatError(H,"invalid syntax"));return _.pop?this.popState():_.push?this.pushState(_.push):_.next&&this.setState(_.next),H},typeof Symbol!="undefined"&&Symbol.iterator){var T=function(_){this.lexer=_};T.prototype.next=function(){var _=this.lexer.next();return{value:_,done:!_}},T.prototype[Symbol.iterator]=function(){return this},b.prototype[Symbol.iterator]=function(){return new T(this)}}return b.prototype.formatError=function(_,P){if(_==null)var F=this.buffer.slice(this.index),_={text:F,offset:this.index,lineBreaks:F.indexOf(`
`)===-1?0:1,line:this.line,col:this.col};var M=Math.max(0,_.offset-_.col+1),D=_.lineBreaks?_.text.indexOf(`
`):_.text.length,z=this.buffer.substring(M,_.offset+D);return P+=" at line "+_.line+" col "+_.col+`:
`,P+=" "+z+`
`,P+=" "+Array(_.col).join(" ")+"^",P},b.prototype.clone=function(){return new b(this.states,this.state)},b.prototype.has=function(_){return!0},{compile:x,states:d,error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:A}})});Oo(exports,{DEFAULT_SETTINGS:()=>h6,default:()=>Ni});var e2=w2(require("obsidian")),Ho=w2(Bi());var Pi={prefix:"fas",iconName:"dice",icon:[640,512,[],"f522","M592 192H473.26c12.69 29.59 7.12 65.2-17 89.32L320 417.58V464c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48V240c0-26.51-21.49-48-48-48zM480 376c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm-46.37-186.7L258.7 14.37c-19.16-19.16-50.23-19.16-69.39 0L14.37 189.3c-19.16 19.16-19.16 50.23 0 69.39L189.3 433.63c19.16 19.16 50.23 19.16 69.39 0L433.63 258.7c19.16-19.17 19.16-50.24 0-69.4zM96 248c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm128 128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm0-128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm0-128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm128 128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"]};var Ii={prefix:"far",iconName:"copy",icon:[448,512,[],"f0c5","M433.941 65.941l-51.882-51.882A48 48 0 0 0 348.118 0H176c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48v-48h80c26.51 0 48-21.49 48-48V99.882a48 48 0 0 0-14.059-33.941zM266 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h74v224c0 26.51 21.49 48 48 48h96v42a6 6 0 0 1-6 6zm128-96H182a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h106v88c0 13.255 10.745 24 24 24h88v202a6 6 0 0 1-6 6zm6-256h-64V48h9.632c1.591 0 3.117.632 4.243 1.757l48.368 48.368a6 6 0 0 1 1.757 4.243V112z"]};function gt(n){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?gt=function(e){return typeof e}:gt=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gt(n)}function jo(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function ki(n,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}function Xo(n,e,t){return e&&ki(n.prototype,e),t&&ki(n,t),n}function Zo(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function F1(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},i=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable}))),i.forEach(function(a){Zo(n,a,t[a])})}return n}function Ui(n,e){return Yo(n)||$o(n,e)||Ko()}function Yo(n){if(Array.isArray(n))return n}function $o(n,e){var t=[],i=!0,a=!1,r=void 0;try{for(var s=n[Symbol.iterator](),o;!(i=(o=s.next()).done)&&(t.push(o.value),!(e&&t.length===e));i=!0);}catch(c){a=!0,r=c}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw r}}return t}function Ko(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var Oi=function(){},b0={},Gi={},Jo=null,qi={mark:Oi,measure:Oi};try{typeof window!="undefined"&&(b0=window),typeof document!="undefined"&&(Gi=document),typeof MutationObserver!="undefined"&&(Jo=MutationObserver),typeof performance!="undefined"&&(qi=performance)}catch{}var Qo=b0.navigator||{},Wi=Qo.userAgent,ji=Wi===void 0?"":Wi,Qt=b0,C2=Gi;var e6=qi,mh=!!Qt.document,y0=!!C2.documentElement&&!!C2.head&&typeof C2.addEventListener=="function"&&typeof C2.createElement=="function",vh=~ji.indexOf("MSIE")||~ji.indexOf("Trident/"),Le="___FONT_AWESOME___";var Xi="fa",Zi="svg-inline--fa",ec="data-fa-i2svg";var gh=function(){try{return!0}catch{return!1}}();var Yi=[1,2,3,4,5,6,7,8,9,10],tc=Yi.concat([11,12,13,14,15,16,17,18,19,20]);var m4={GROUP:"group",SWAP_OPACITY:"swap-opacity",PRIMARY:"primary",SECONDARY:"secondary"},xh=["xs","sm","lg","fw","ul","li","border","pull-left","pull-right","spin","pulse","rotate-90","rotate-180","rotate-270","flip-horizontal","flip-vertical","flip-both","stack","stack-1x","stack-2x","inverse","layers","layers-text","layers-counter",m4.GROUP,m4.SWAP_OPACITY,m4.PRIMARY,m4.SECONDARY].concat(Yi.map(function(n){return"".concat(n,"x")})).concat(tc.map(function(n){return"w-".concat(n)})),$i=Qt.FontAwesomeConfig||{};function ic(n){var e=C2.querySelector("script["+n+"]");if(e)return e.getAttribute(n)}function ac(n){return n===""?!0:n==="false"?!1:n==="true"?!0:n}C2&&typeof C2.querySelector=="function"&&(Ki=[["data-family-prefix","familyPrefix"],["data-replacement-class","replacementClass"],["data-auto-replace-svg","autoReplaceSvg"],["data-auto-add-css","autoAddCss"],["data-auto-a11y","autoA11y"],["data-search-pseudo-elements","searchPseudoElements"],["data-observe-mutations","observeMutations"],["data-mutate-approach","mutateApproach"],["data-keep-original-source","keepOriginalSource"],["data-measure-performance","measurePerformance"],["data-show-missing-icons","showMissingIcons"]],Ki.forEach(function(n){var e=Ui(n,2),t=e[0],i=e[1],a=ac(ic(t));a!=null&&($i[i]=a)}));var Ki,rc={familyPrefix:Xi,replacementClass:Zi,autoReplaceSvg:!0,autoAddCss:!0,autoA11y:!0,searchPseudoElements:!1,observeMutations:!0,mutateApproach:"async",keepOriginalSource:!0,measurePerformance:!1,showMissingIcons:!0},C0=F1({},rc,$i);C0.autoReplaceSvg||(C0.observeMutations=!1);var V2=F1({},C0);Qt.FontAwesomeConfig=V2;var De=Qt||{};De[Le]||(De[Le]={});De[Le].styles||(De[Le].styles={});De[Le].hooks||(De[Le].hooks={});De[Le].shims||(De[Le].shims=[]);var de=De[Le],nc=[],sc=function n(){C2.removeEventListener("DOMContentLoaded",n),z0=1,nc.map(function(e){return e()})},z0=!1;y0&&(z0=(C2.documentElement.doScroll?/^loaded|^c/:/^loaded|^i|^c/).test(C2.readyState),z0||C2.addEventListener("DOMContentLoaded",sc));var A0="pending",Ji="settled",t6="fulfilled",i6="rejected",oc=function(){},Qi=typeof global!="undefined"&&typeof global.process!="undefined"&&typeof global.process.emit=="function",cc=typeof setImmediate=="undefined"?setTimeout:setImmediate,xt=[],w0;function lc(){for(var n=0;n<xt.length;n++)xt[n][0](xt[n][1]);xt=[],w0=!1}function a6(n,e){xt.push([n,e]),w0||(w0=!0,cc(lc,0))}function uc(n,e){function t(a){S0(e,a)}function i(a){Mt(e,a)}try{n(t,i)}catch(a){i(a)}}function ea(n){var e=n.owner,t=e._state,i=e._data,a=n[t],r=n.then;if(typeof a=="function"){t=t6;try{i=a(i)}catch(s){Mt(r,s)}}ta(r,i)||(t===t6&&S0(r,i),t===i6&&Mt(r,i))}function ta(n,e){var t;try{if(n===e)throw new TypeError("A promises callback cannot return that same promise.");if(e&&(typeof e=="function"||gt(e)==="object")){var i=e.then;if(typeof i=="function")return i.call(e,function(a){t||(t=!0,e===a?ia(n,a):S0(n,a))},function(a){t||(t=!0,Mt(n,a))}),!0}}catch(a){return t||Mt(n,a),!0}return!1}function S0(n,e){(n===e||!ta(n,e))&&ia(n,e)}function ia(n,e){n._state===A0&&(n._state=Ji,n._data=e,a6(hc,n))}function Mt(n,e){n._state===A0&&(n._state=Ji,n._data=e,a6(fc,n))}function aa(n){n._then=n._then.forEach(ea)}function hc(n){n._state=t6,aa(n)}function fc(n){n._state=i6,aa(n),!n._handled&&Qi&&global.process.emit("unhandledRejection",n._data,n)}function dc(n){global.process.emit("rejectionHandled",n)}function I2(n){if(typeof n!="function")throw new TypeError("Promise resolver "+n+" is not a function");if(!(this instanceof I2))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._then=[],uc(n,this)}I2.prototype={constructor:I2,_state:A0,_then:null,_data:void 0,_handled:!1,then:function(e,t){var i={owner:this,then:new this.constructor(oc),fulfilled:e,rejected:t};return(t||e)&&!this._handled&&(this._handled=!0,this._state===i6&&Qi&&a6(dc,this)),this._state===t6||this._state===i6?a6(ea,i):this._then.push(i),i.then},catch:function(e){return this.then(null,e)}};I2.all=function(n){if(!Array.isArray(n))throw new TypeError("You must pass an array to Promise.all().");return new I2(function(e,t){var i=[],a=0;function r(c){return a++,function(l){i[c]=l,--a||e(i)}}for(var s=0,o;s<n.length;s++)o=n[s],o&&typeof o.then=="function"?o.then(r(s),t):i[s]=o;a||e(i)})};I2.race=function(n){if(!Array.isArray(n))throw new TypeError("You must pass an array to Promise.race().");return new I2(function(e,t){for(var i=0,a;i<n.length;i++)a=n[i],a&&typeof a.then=="function"?a.then(e,t):e(a)})};I2.resolve=function(n){return n&&gt(n)==="object"&&n.constructor===I2?n:new I2(function(e){e(n)})};I2.reject=function(n){return new I2(function(e,t){t(n)})};var F4={size:16,x:0,y:0,rotate:0,flipX:!1,flipY:!1};function pc(n){if(!(!n||!y0)){var e=C2.createElement("style");e.setAttribute("type","text/css"),e.innerHTML=n;for(var t=C2.head.childNodes,i=null,a=t.length-1;a>-1;a--){var r=t[a],s=(r.tagName||"").toUpperCase();["STYLE","LINK"].indexOf(s)>-1&&(i=r)}return C2.head.insertBefore(e,i),n}}var mc="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function r6(){for(var n=12,e="";n-- >0;)e+=mc[Math.random()*62|0];return e}function ra(n){return"".concat(n).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function vc(n){return Object.keys(n||{}).reduce(function(e,t){return e+"".concat(t,'="').concat(ra(n[t]),'" ')},"").trim()}function na(n){return Object.keys(n||{}).reduce(function(e,t){return e+"".concat(t,": ").concat(n[t],";")},"")}function sa(n){return n.size!==F4.size||n.x!==F4.x||n.y!==F4.y||n.rotate!==F4.rotate||n.flipX||n.flipY}function oa(n){var e=n.transform,t=n.containerWidth,i=n.iconWidth,a={transform:"translate(".concat(t/2," 256)")},r="translate(".concat(e.x*32,", ").concat(e.y*32,") "),s="scale(".concat(e.size/16*(e.flipX?-1:1),", ").concat(e.size/16*(e.flipY?-1:1),") "),o="rotate(".concat(e.rotate," 0 0)"),c={transform:"".concat(r," ").concat(s," ").concat(o)},l={transform:"translate(".concat(i/2*-1," -256)")};return{outer:a,inner:c,path:l}}var _0={x:0,y:0,width:"100%",height:"100%"};function ca(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return n.attributes&&(n.attributes.fill||e)&&(n.attributes.fill="black"),n}function gc(n){return n.tag==="g"?n.children:[n]}function xc(n){var e=n.children,t=n.attributes,i=n.main,a=n.mask,r=n.maskId,s=n.transform,o=i.width,c=i.icon,l=a.width,u=a.icon,f=oa({transform:s,containerWidth:l,iconWidth:o}),h={tag:"rect",attributes:F1({},_0,{fill:"white"})},m=c.children?{children:c.children.map(ca)}:{},v={tag:"g",attributes:F1({},f.inner),children:[ca(F1({tag:c.tag,attributes:F1({},c.attributes,f.path)},m))]},g={tag:"g",attributes:F1({},f.outer),children:[v]},x="mask-".concat(r||r6()),p="clip-".concat(r||r6()),d={tag:"mask",attributes:F1({},_0,{id:x,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse"}),children:[h,g]},A={tag:"defs",children:[{tag:"clipPath",attributes:{id:p},children:gc(u)},d]};return e.push(A,{tag:"rect",attributes:F1({fill:"currentColor","clip-path":"url(#".concat(p,")"),mask:"url(#".concat(x,")")},_0)}),{children:e,attributes:t}}function Mc(n){var e=n.children,t=n.attributes,i=n.main,a=n.transform,r=n.styles,s=na(r);if(s.length>0&&(t.style=s),sa(a)){var o=oa({transform:a,containerWidth:i.width,iconWidth:i.width});e.push({tag:"g",attributes:F1({},o.outer),children:[{tag:"g",attributes:F1({},o.inner),children:[{tag:i.icon.tag,children:i.icon.children,attributes:F1({},i.icon.attributes,o.path)}]}]})}else e.push(i.icon);return{children:e,attributes:t}}function bc(n){var e=n.children,t=n.main,i=n.mask,a=n.attributes,r=n.styles,s=n.transform;if(sa(s)&&t.found&&!i.found){var o=t.width,c=t.height,l={x:o/c/2,y:.5};a.style=na(F1({},r,{"transform-origin":"".concat(l.x+s.x/16,"em ").concat(l.y+s.y/16,"em")}))}return[{tag:"svg",attributes:a,children:e}]}function yc(n){var e=n.prefix,t=n.iconName,i=n.children,a=n.attributes,r=n.symbol,s=r===!0?"".concat(e,"-").concat(V2.familyPrefix,"-").concat(t):r;return[{tag:"svg",attributes:{style:"display: none;"},children:[{tag:"symbol",attributes:F1({},a,{id:s}),children:i}]}]}function Cc(n){var e=n.icons,t=e.main,i=e.mask,a=n.prefix,r=n.iconName,s=n.transform,o=n.symbol,c=n.title,l=n.maskId,u=n.titleId,f=n.extra,h=n.watchable,m=h===void 0?!1:h,v=i.found?i:t,g=v.width,x=v.height,p=a==="fak",d=p?"":"fa-w-".concat(Math.ceil(g/x*16)),A=[V2.replacementClass,r?"".concat(V2.familyPrefix,"-").concat(r):"",d].filter(function(F){return f.classes.indexOf(F)===-1}).filter(function(F){return F!==""||!!F}).concat(f.classes).join(" "),b={children:[],attributes:F1({},f.attributes,{"data-prefix":a,"data-icon":r,class:A,role:f.attributes.role||"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 ".concat(g," ").concat(x)})},C=p&&!~f.classes.indexOf("fa-fw")?{width:"".concat(g/x*16*.0625,"em")}:{};m&&(b.attributes[ec]=""),c&&b.children.push({tag:"title",attributes:{id:b.attributes["aria-labelledby"]||"title-".concat(u||r6())},children:[c]});var E=F1({},b,{prefix:a,iconName:r,main:t,mask:i,maskId:l,transform:s,symbol:o,styles:F1({},C,f.styles)}),T=i.found&&t.found?xc(E):Mc(E),_=T.children,P=T.attributes;return E.children=_,E.attributes=P,o?yc(E):bc(E)}var la=function(){},Mh=V2.measurePerformance&&e6&&e6.mark&&e6.measure?e6:{mark:la,measure:la};var zc=function(e,t){return function(i,a,r,s){return e.call(t,i,a,r,s)}},E0=function(e,t,i,a){var r=Object.keys(e),s=r.length,o=a!==void 0?zc(t,a):t,c,l,u;for(i===void 0?(c=1,u=e[r[0]]):(c=0,u=i);c<s;c++)l=r[c],u=o(u,e[l],l,e);return u};function ua(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=t.skipHooks,a=i===void 0?!1:i,r=Object.keys(e).reduce(function(s,o){var c=e[o],l=!!c.icon;return l?s[c.iconName]=c.icon:s[o]=c,s},{});typeof de.hooks.addPack=="function"&&!a?de.hooks.addPack(n,r):de.styles[n]=F1({},de.styles[n]||{},r),n==="fas"&&ua("fa",e)}var ha=de.styles,Ac=de.shims,wc={},Sc={},_c={},fa=function(){var e=function(a){return E0(ha,function(r,s,o){return r[o]=E0(s,a,{}),r},{})};wc=e(function(i,a,r){return a[3]&&(i[a[3]]=r),i}),Sc=e(function(i,a,r){var s=a[2];return i[r]=r,s.forEach(function(o){i[o]=r}),i});var t="far"in ha;_c=E0(Ac,function(i,a){var r=a[0],s=a[1],o=a[2];return s==="far"&&!t&&(s="fas"),i[r]={prefix:s,iconName:o},i},{})};fa();var bh=de.styles;function da(n,e,t){if(n&&n[e]&&n[e][t])return{prefix:e,iconName:t,icon:n[e][t]}}function pa(n){var e=n.tag,t=n.attributes,i=t===void 0?{}:t,a=n.children,r=a===void 0?[]:a;return typeof n=="string"?ra(n):"<".concat(e," ").concat(vc(i),">").concat(r.map(pa).join(""),"</").concat(e,">")}function L0(n){this.name="MissingIcon",this.message=n||"Icon unavailable",this.stack=new Error().stack}L0.prototype=Object.create(Error.prototype);L0.prototype.constructor=L0;var n6={fill:"currentColor"},ma={attributeType:"XML",repeatCount:"indefinite",dur:"2s"},yh={tag:"path",attributes:F1({},n6,{d:"M156.5,447.7l-12.6,29.5c-18.7-9.5-35.9-21.2-51.5-34.9l22.7-22.7C127.6,430.5,141.5,440,156.5,447.7z M40.6,272H8.5 c1.4,21.2,5.4,41.7,11.7,61.1L50,321.2C45.1,305.5,41.8,289,40.6,272z M40.6,240c1.4-18.8,5.2-37,11.1-54.1l-29.5-12.6 C14.7,194.3,10,216.7,8.5,240H40.6z M64.3,156.5c7.8-14.9,17.2-28.8,28.1-41.5L69.7,92.3c-13.7,15.6-25.5,32.8-34.9,51.5 L64.3,156.5z M397,419.6c-13.9,12-29.4,22.3-46.1,30.4l11.9,29.8c20.7-9.9,39.8-22.6,56.9-37.6L397,419.6z M115,92.4 c13.9-12,29.4-22.3,46.1-30.4l-11.9-29.8c-20.7,9.9-39.8,22.6-56.8,37.6L115,92.4z M447.7,355.5c-7.8,14.9-17.2,28.8-28.1,41.5 l22.7,22.7c13.7-15.6,25.5-32.9,34.9-51.5L447.7,355.5z M471.4,272c-1.4,18.8-5.2,37-11.1,54.1l29.5,12.6 c7.5-21.1,12.2-43.5,13.6-66.8H471.4z M321.2,462c-15.7,5-32.2,8.2-49.2,9.4v32.1c21.2-1.4,41.7-5.4,61.1-11.7L321.2,462z M240,471.4c-18.8-1.4-37-5.2-54.1-11.1l-12.6,29.5c21.1,7.5,43.5,12.2,66.8,13.6V471.4z M462,190.8c5,15.7,8.2,32.2,9.4,49.2h32.1 c-1.4-21.2-5.4-41.7-11.7-61.1L462,190.8z M92.4,397c-12-13.9-22.3-29.4-30.4-46.1l-29.8,11.9c9.9,20.7,22.6,39.8,37.6,56.9 L92.4,397z M272,40.6c18.8,1.4,36.9,5.2,54.1,11.1l12.6-29.5C317.7,14.7,295.3,10,272,8.5V40.6z M190.8,50 c15.7-5,32.2-8.2,49.2-9.4V8.5c-21.2,1.4-41.7,5.4-61.1,11.7L190.8,50z M442.3,92.3L419.6,115c12,13.9,22.3,29.4,30.5,46.1 l29.8-11.9C470,128.5,457.3,109.4,442.3,92.3z M397,92.4l22.7-22.7c-15.6-13.7-32.8-25.5-51.5-34.9l-12.6,29.5 C370.4,72.1,384.4,81.5,397,92.4z"})},D0=F1({},ma,{attributeName:"opacity"}),Ch={tag:"circle",attributes:F1({},n6,{cx:"256",cy:"364",r:"28"}),children:[{tag:"animate",attributes:F1({},ma,{attributeName:"r",values:"28;14;28;28;14;28;"})},{tag:"animate",attributes:F1({},D0,{values:"1;0;1;1;0;1;"})}]},zh={tag:"path",attributes:F1({},n6,{opacity:"1",d:"M263.7,312h-16c-6.6,0-12-5.4-12-12c0-71,77.4-63.9,77.4-107.8c0-20-17.8-40.2-57.4-40.2c-29.1,0-44.3,9.6-59.2,28.7 c-3.9,5-11.1,6-16.2,2.4l-13.1-9.2c-5.6-3.9-6.9-11.8-2.6-17.2c21.2-27.2,46.4-44.7,91.2-44.7c52.3,0,97.4,29.8,97.4,80.2 c0,67.6-77.4,63.5-77.4,107.8C275.7,306.6,270.3,312,263.7,312z"}),children:[{tag:"animate",attributes:F1({},D0,{values:"1;0;0;0;0;1;"})}]},Ah={tag:"path",attributes:F1({},n6,{opacity:"0",d:"M232.5,134.5l7,168c0.3,6.4,5.6,11.5,12,11.5h9c6.4,0,11.7-5.1,12-11.5l7-168c0.3-6.8-5.2-12.5-12-12.5h-23 C237.7,122,232.2,127.7,232.5,134.5z"}),children:[{tag:"animate",attributes:F1({},D0,{values:"0;0;1;1;0;0;"})}]};var wh=de.styles;function va(n){var e=n[0],t=n[1],i=n.slice(4),a=Ui(i,1),r=a[0],s=null;return Array.isArray(r)?s={tag:"g",attributes:{class:"".concat(V2.familyPrefix,"-").concat(m4.GROUP)},children:[{tag:"path",attributes:{class:"".concat(V2.familyPrefix,"-").concat(m4.SECONDARY),fill:"currentColor",d:r[0]}},{tag:"path",attributes:{class:"".concat(V2.familyPrefix,"-").concat(m4.PRIMARY),fill:"currentColor",d:r[1]}}]}:s={tag:"path",attributes:{fill:"currentColor",d:r}},{found:!0,width:e,height:t,icon:s}}var Sh=de.styles;var Ec=`svg:not(:root).svg-inline--fa {
overflow: visible;
}
.svg-inline--fa {
display: inline-block;
font-size: inherit;
height: 1em;
overflow: visible;
vertical-align: -0.125em;
}
.svg-inline--fa.fa-lg {
vertical-align: -0.225em;
}
.svg-inline--fa.fa-w-1 {
width: 0.0625em;
}
.svg-inline--fa.fa-w-2 {
width: 0.125em;
}
.svg-inline--fa.fa-w-3 {
width: 0.1875em;
}
.svg-inline--fa.fa-w-4 {
width: 0.25em;
}
.svg-inline--fa.fa-w-5 {
width: 0.3125em;
}
.svg-inline--fa.fa-w-6 {
width: 0.375em;
}
.svg-inline--fa.fa-w-7 {
width: 0.4375em;
}
.svg-inline--fa.fa-w-8 {
width: 0.5em;
}
.svg-inline--fa.fa-w-9 {
width: 0.5625em;
}
.svg-inline--fa.fa-w-10 {
width: 0.625em;
}
.svg-inline--fa.fa-w-11 {
width: 0.6875em;
}
.svg-inline--fa.fa-w-12 {
width: 0.75em;
}
.svg-inline--fa.fa-w-13 {
width: 0.8125em;
}
.svg-inline--fa.fa-w-14 {
width: 0.875em;
}
.svg-inline--fa.fa-w-15 {
width: 0.9375em;
}
.svg-inline--fa.fa-w-16 {
width: 1em;
}
.svg-inline--fa.fa-w-17 {
width: 1.0625em;
}
.svg-inline--fa.fa-w-18 {
width: 1.125em;
}
.svg-inline--fa.fa-w-19 {
width: 1.1875em;
}
.svg-inline--fa.fa-w-20 {
width: 1.25em;
}
.svg-inline--fa.fa-pull-left {
margin-right: 0.3em;
width: auto;
}
.svg-inline--fa.fa-pull-right {
margin-left: 0.3em;
width: auto;
}
.svg-inline--fa.fa-border {
height: 1.5em;
}
.svg-inline--fa.fa-li {
width: 2em;
}
.svg-inline--fa.fa-fw {
width: 1.25em;
}
.fa-layers svg.svg-inline--fa {
bottom: 0;
left: 0;
margin: auto;
position: absolute;
right: 0;
top: 0;
}
.fa-layers {
display: inline-block;
height: 1em;
position: relative;
text-align: center;
vertical-align: -0.125em;
width: 1em;
}
.fa-layers svg.svg-inline--fa {
-webkit-transform-origin: center center;
transform-origin: center center;
}
.fa-layers-counter, .fa-layers-text {
display: inline-block;
position: absolute;
text-align: center;
}
.fa-layers-text {
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
-webkit-transform-origin: center center;
transform-origin: center center;
}
.fa-layers-counter {
background-color: #ff253a;
border-radius: 1em;
-webkit-box-sizing: border-box;
box-sizing: border-box;
color: #fff;
height: 1.5em;
line-height: 1;
max-width: 5em;
min-width: 1.5em;
overflow: hidden;
padding: 0.25em;
right: 0;
text-overflow: ellipsis;
top: 0;
-webkit-transform: scale(0.25);
transform: scale(0.25);
-webkit-transform-origin: top right;
transform-origin: top right;
}
.fa-layers-bottom-right {
bottom: 0;
right: 0;
top: auto;
-webkit-transform: scale(0.25);
transform: scale(0.25);
-webkit-transform-origin: bottom right;
transform-origin: bottom right;
}
.fa-layers-bottom-left {
bottom: 0;
left: 0;
right: auto;
top: auto;
-webkit-transform: scale(0.25);
transform: scale(0.25);
-webkit-transform-origin: bottom left;
transform-origin: bottom left;
}
.fa-layers-top-right {
right: 0;
top: 0;
-webkit-transform: scale(0.25);
transform: scale(0.25);
-webkit-transform-origin: top right;
transform-origin: top right;
}
.fa-layers-top-left {
left: 0;
right: auto;
top: 0;
-webkit-transform: scale(0.25);
transform: scale(0.25);
-webkit-transform-origin: top left;
transform-origin: top left;
}
.fa-lg {
font-size: 1.3333333333em;
line-height: 0.75em;
vertical-align: -0.0667em;
}
.fa-xs {
font-size: 0.75em;
}
.fa-sm {
font-size: 0.875em;
}
.fa-1x {
font-size: 1em;
}
.fa-2x {
font-size: 2em;
}
.fa-3x {
font-size: 3em;
}
.fa-4x {
font-size: 4em;
}
.fa-5x {
font-size: 5em;
}
.fa-6x {
font-size: 6em;
}
.fa-7x {
font-size: 7em;
}
.fa-8x {
font-size: 8em;
}
.fa-9x {
font-size: 9em;
}
.fa-10x {
font-size: 10em;
}
.fa-fw {
text-align: center;
width: 1.25em;
}
.fa-ul {
list-style-type: none;
margin-left: 2.5em;
padding-left: 0;
}
.fa-ul > li {
position: relative;
}
.fa-li {
left: -2em;
position: absolute;
text-align: center;
width: 2em;
line-height: inherit;
}
.fa-border {
border: solid 0.08em #eee;
border-radius: 0.1em;
padding: 0.2em 0.25em 0.15em;
}
.fa-pull-left {
float: left;
}
.fa-pull-right {
float: right;
}
.fa.fa-pull-left,
.fas.fa-pull-left,
.far.fa-pull-left,
.fal.fa-pull-left,
.fab.fa-pull-left {
margin-right: 0.3em;
}
.fa.fa-pull-right,
.fas.fa-pull-right,
.far.fa-pull-right,
.fal.fa-pull-right,
.fab.fa-pull-right {
margin-left: 0.3em;
}
.fa-spin {
-webkit-animation: fa-spin 2s infinite linear;
animation: fa-spin 2s infinite linear;
}
.fa-pulse {
-webkit-animation: fa-spin 1s infinite steps(8);
animation: fa-spin 1s infinite steps(8);
}
@-webkit-keyframes fa-spin {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes fa-spin {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.fa-rotate-90 {
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.fa-rotate-180 {
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.fa-rotate-270 {
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
.fa-flip-horizontal {
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";
-webkit-transform: scale(-1, 1);
transform: scale(-1, 1);
}
.fa-flip-vertical {
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";
-webkit-transform: scale(1, -1);
transform: scale(1, -1);
}
.fa-flip-both, .fa-flip-horizontal.fa-flip-vertical {
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";
-webkit-transform: scale(-1, -1);
transform: scale(-1, -1);
}
:root .fa-rotate-90,
:root .fa-rotate-180,
:root .fa-rotate-270,
:root .fa-flip-horizontal,
:root .fa-flip-vertical,
:root .fa-flip-both {
-webkit-filter: none;
filter: none;
}
.fa-stack {
display: inline-block;
height: 2em;
position: relative;
width: 2.5em;
}
.fa-stack-1x,
.fa-stack-2x {
bottom: 0;
left: 0;
margin: auto;
position: absolute;
right: 0;
top: 0;
}
.svg-inline--fa.fa-stack-1x {
height: 1em;
width: 1.25em;
}
.svg-inline--fa.fa-stack-2x {
height: 2em;
width: 2.5em;
}
.fa-inverse {
color: #fff;
}
.sr-only {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.sr-only-focusable:active, .sr-only-focusable:focus {
clip: auto;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
}
.svg-inline--fa .fa-primary {
fill: var(--fa-primary-color, currentColor);
opacity: 1;
opacity: var(--fa-primary-opacity, 1);
}
.svg-inline--fa .fa-secondary {
fill: var(--fa-secondary-color, currentColor);
opacity: 0.4;
opacity: var(--fa-secondary-opacity, 0.4);
}
.svg-inline--fa.fa-swap-opacity .fa-primary {
opacity: 0.4;
opacity: var(--fa-secondary-opacity, 0.4);
}
.svg-inline--fa.fa-swap-opacity .fa-secondary {
opacity: 1;
opacity: var(--fa-primary-opacity, 1);
}
.svg-inline--fa mask .fa-primary,
.svg-inline--fa mask .fa-secondary {
fill: black;
}
.fad.fa-inverse {
color: #fff;
}`;function Lc(){var n=Xi,e=Zi,t=V2.familyPrefix,i=V2.replacementClass,a=Ec;if(t!==n||i!==e){var r=new RegExp("\\.".concat(n,"\\-"),"g"),s=new RegExp("\\--".concat(n,"\\-"),"g"),o=new RegExp("\\.".concat(e),"g");a=a.replace(r,".".concat(t,"-")).replace(s,"--".concat(t,"-")).replace(o,".".concat(i))}return a}var Dc=function(){function n(){jo(this,n),this.definitions={}}return Xo(n,[{key:"add",value:function(){for(var t=this,i=arguments.length,a=new Array(i),r=0;r<i;r++)a[r]=arguments[r];var s=a.reduce(this._pullDefinitions,{});Object.keys(s).forEach(function(o){t.definitions[o]=F1({},t.definitions[o]||{},s[o]),ua(o,s[o]),fa()})}},{key:"reset",value:function(){this.definitions={}}},{key:"_pullDefinitions",value:function(t,i){var a=i.prefix&&i.iconName&&i.icon?{0:i}:i;return Object.keys(a).map(function(r){var s=a[r],o=s.prefix,c=s.iconName,l=s.icon;t[o]||(t[o]={}),t[o][c]=l}),t}}]),n}();function Tc(){V2.autoAddCss&&!xa&&(pc(Lc()),xa=!0)}function Hc(n,e){return Object.defineProperty(n,"abstract",{get:e}),Object.defineProperty(n,"html",{get:function(){return n.abstract.map(function(i){return pa(i)})}}),Object.defineProperty(n,"node",{get:function(){if(!!y0){var i=C2.createElement("div");return i.innerHTML=n.html,i.children}}}),n}function ga(n){var e=n.prefix,t=e===void 0?"fa":e,i=n.iconName;if(!!i)return da(Nc.definitions,t,i)||da(de.styles,t,i)}function Vc(n){return function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=(e||{}).icon?e:ga(e||{}),a=t.mask;return a&&(a=(a||{}).icon?a:ga(a||{})),n(i,F1({},t,{mask:a}))}}var Nc=new Dc;var xa=!1;var T0=Vc(function(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.transform,i=t===void 0?F4:t,a=e.symbol,r=a===void 0?!1:a,s=e.mask,o=s===void 0?null:s,c=e.maskId,l=c===void 0?null:c,u=e.title,f=u===void 0?null:u,h=e.titleId,m=h===void 0?null:h,v=e.classes,g=v===void 0?[]:v,x=e.attributes,p=x===void 0?{}:x,d=e.styles,A=d===void 0?{}:d;if(!!n){var b=n.prefix,C=n.iconName,E=n.icon;return Hc(F1({type:"icon"},n),function(){return Tc(),V2.autoA11y&&(f?p["aria-labelledby"]="".concat(V2.replacementClass,"-title-").concat(m||r6()):(p["aria-hidden"]="true",p.focusable="false")),Cc({icons:{main:va(E),mask:o?va(o.icon):{found:!1,width:null,height:null,icon:{}}},prefix:b,iconName:C,transform:F1({},F4,i),symbol:r,title:f,maskId:l,titleId:m,extra:{attributes:p,styles:A,classes:g}})})}});function H0(n,e){let t=Object.keys(e).map(i=>Rc(n,i,e[i]));return t.length===1?t[0]:function(){t.forEach(i=>i())}}function Rc(n,e,t){let i=n[e],a=n.hasOwnProperty(e),r=t(i);return i&&Object.setPrototypeOf(r,i),Object.setPrototypeOf(s,r),n[e]=s,o;function s(...c){return r===i&&n[e]===s&&o(),r.apply(this,c)}function o(){n[e]===s&&(a?n[e]=i:delete n[e]),r!==i&&(r=i,Object.setPrototypeOf(s,i||Function))}}var Vi=w2(Ma());var V0=/(?:(?<roll>\d+)[Dd])?#(?<tag>[\p{Letter}\p{Emoji_Presentation}\w/-]+)(?:\|(?<collapse>[\+-]))?(?:\|(?<types>[^\+-]+))?/u,ba=/(?<diceRoll>.*)?(?:\[.*\]\(|\[\[)(?<link>.+?)#?\^(?<block>.+?)(?:\]\]|\))(?:\|(?<header>.+))?/,N0=/(?:(?<roll>\d+)[Dd])?(?:\[.*\]\(|\[\[)(?<link>.+)(?:\]\]|\))\|?(?<types>.+)?/;var Y2="dice-roller-icon",Te="dice-roller-copy";var g4=w2(require("obsidian"));var pe=(a=>(a.None="None",a.Normal="Normal",a.Up="Up",a.Down="Down",a))(pe||{}),f2=(i=>(i.None="None",i.Average="Average",i.Roll="Roll",i))(f2||{});function ya(n,e,t){[...n].slice(e).reverse().forEach(([a,r])=>{n.set(a+1,r)}),n.set(e,t)}var B4=w2(require("obsidian"));var R0=class extends B4.Events{constructor(e,t="",i=e.data.showDice){super();this.plugin=e;this.original=t;this.loaded=!1;this.containerEl=createSpan({cls:"dice-roller",attr:{"aria-label-position":"top","data-dice":this.original}});this.resultEl=this.containerEl.createSpan("dice-roller-result");if(i){let a=this.containerEl.createSpan({cls:"dice-roller-button"});(0,B4.setIcon)(a,Y2),a.onclick=this.onClick.bind(this)}else this.containerEl.addClass("no-icon");this.containerEl.onclick=this.onClick.bind(this)}setTooltip(){this.plugin.data.displayResultsInline||this.containerEl.setAttrs({"aria-label":this.tooltip})}getRandomBetween(e,t){let i=new Uint32Array(1);crypto.getRandomValues(i);let a=i[0]/(4294967295+1);return Math.floor(a*(t-e+1))+e}async render(){this.setTooltip(),await this.build()}async onClick(e){e.stopPropagation(),e.stopImmediatePropagation(),window.getSelection()?.isCollapsed&&await this.roll()}},Ca=class extends R0{constructor(e,t,i,a=e.data.showDice){super(e,t,a);this.plugin=e;this.original=t;this.lexemes=i;this.showDice=a;this.save=!1}get inlineText(){return`${this.tooltip.split(`
`).join(" -> ")} -> `}},v4=class extends Ca{},P4=class extends v4{constructor(e,t,i,a,r=e.data.showDice){super(e,t,[i],r);this.plugin=e;this.original=t;this.lexeme=i;this.source=a;this.watch=!0;this.getPath(),this.init=this.getFile()}async getFile(){if(this.file=this.plugin.app.metadataCache.getFirstLinkpathDest(this.path,this.source),!this.file||!(this.file instanceof B4.TFile))throw new Error("Could not load file.");await this.load()}},F0=class extends R0{constructor(e,t,i){super(e,"");this.options=t;this.rolls=i}get tooltip(){return`${this.options.toString()}
${this.results.toString()}`}async roll(){let e=[...this.options];return this.results=[...Array(this.rolls)].map(()=>{let t=e[this.getRandomBetween(0,e.length-1)];return e.splice(e.indexOf(t),1),t}).filter(t=>t),this.render(),this.trigger("new-result"),this.result=this.results[0],this.results[0]}async build(){this.resultEl.empty(),this.resultEl.setText(this.results.toString())}};var k2=class{constructor(e,t={value:e,conditions:[],type:"dice"}){this.lexeme=t;this.modifiers=new Map;this.modifiersAllowed=!0;this.static=!1;this.conditions=[];this.fudge=!1;if(!/(\-?\d+)[dD]?(\d+|%|\[\d+,\s?\d+\])?/.test(e))throw new Error("Non parseable dice string passed to DiceRoll.");this.dice=e.split(" ").join(""),/^-?\d+(?:\.\d+)?$/.test(this.dice)&&(this.static=!0,this.modifiersAllowed=!1);let[,i,a=null,r=1]=this.dice.match(/(\-?\d+)[dD]\[?(?:(-?\d+)\s?,)?\s?(-?\d+|%|F)\]?/)||[,1,null,1];this.multiplier=i<0?-1:1;let s=isNaN(Number(a))?null:Number(a),o;this.rolls=Math.abs(Number(i))||1,r==="%"?o=100:r==="F"?(o=1,s=-1,this.fudge=!0):o=Number(r),Number(o)<0&&!s&&(s=-1),Number(o)<Number(s)&&([o,s]=[s,o]),this.faces={max:o?Number(o):1,min:s?Number(s):1},this.conditions=this.lexeme.conditions??[],this.results=new Map([...this.roll()].map((c,l)=>[l,{usable:!0,value:c,display:`${c}`,modifiers:new Set}]))}get text(){return`${this.result}`}get result(){return this.static?Number(this.dice):[...this.results].map(([,{usable:t,value:i}])=>t?i:0).reduce((t,i)=>t+i,0)}get display(){return this.static?`${this.result}`:`[${[...this.results].map(([,{modifiers:e,display:t}])=>`${t}${[...e].join("")}`).join(", ")}]`}get modifierText(){if(!this.modifiers.size)return"";let e=[...this.conditions].map(({value:i})=>i).join(""),t=[...this.modifiers].map(([i,{conditionals:a,value:r}])=>{let s=a.map(o=>o.value);return`${r}${s.join("")}`}).join("");return`${e}${t}`}keepLow(e=1){if(!this.modifiersAllowed){new g4.Notice("Modifiers are only allowed on dice rolls.");return}[...this.results].sort((t,i)=>t[1].value-i[1].value).slice(e-this.results.size).forEach(([t])=>{let i=this.results.get(t);i.usable=!1,i.modifiers.add("d"),this.results.set(t,{...i})})}keepHigh(e=1){if(!this.modifiersAllowed){new g4.Notice("Modifiers are only allowed on dice rolls.");return}[...this.results].sort((t,i)=>i[1].value-t[1].value).slice(e).forEach(([t])=>{let i=this.results.get(t);i.usable=!1,i.modifiers.add("d"),this.results.set(t,{...i})})}reroll(e,t){if(!this.modifiersAllowed){new g4.Notice("Modifiers are only allowed on dice rolls.");return}t.length||t.push({operator:"=",comparer:this.faces.min,value:""});let i=0,a=[...this.results].filter(([,{value:r}])=>this.checkCondition(r,t));for(;i<e&&a.filter(([,{value:r}])=>this.checkCondition(r,t)).length>0;)i++,a.map(([,r])=>{r.modifiers.add("r"),r.value=this.getRandomBetween(this.faces.min,this.faces.max)});a.forEach(([r,s])=>{this.results.set(r,s)})}explodeAndCombine(e,t){if(!this.modifiersAllowed){new g4.Notice("Modifiers are only allowed on dice rolls.");return}t.length||t.push({operator:"=",comparer:this.faces.max,value:""});let i=0;[...this.results].filter(([,{value:r}])=>this.checkCondition(r,t)).forEach(([r,s])=>{let o=this.getRandomBetween(this.faces.min,this.faces.max);for(i++,s.modifiers.add("!"),s.value+=o,s.display=`${s.value}`,this.results.set(r,s);i<e&&this.checkCondition(o,t);)i++,o=this.getRandomBetween(this.faces.min,this.faces.max),s.value+=o,s.display=`${s.value}`,this.results.set(r,s)})}explode(e,t){if(!this.modifiersAllowed){new g4.Notice("Modifiers are only allowed on dice rolls.");return}t.length||t.push({operator:"=",comparer:this.faces.max,value:""});let i=[...this.results].filter(([,{value:r}])=>this.checkCondition(r,t)),a=0;i.forEach(([r,s])=>{let o=s.value,c=0;for(;c<e&&this.checkCondition(o,t);)this.results.get(r+a+c).modifiers.add("!"),o=this.getRandomBetween(this.faces.min,this.faces.max),ya(this.results,r+a+c+1,{usable:!0,value:o,display:`${o}`,modifiers:new Set}),c++;a+=c})}_roll(){return this.static?[Number(this.dice)]:[...Array(this.rolls)].map(()=>this.multiplier*this.getRandomBetween(this.faces.min,this.faces.max))}setResults(e){this.results=new Map([...e].map((t,i)=>[i,{usable:!0,value:t,display:`${t}`,modifiers:new Set}]))}applyModifiers(){for(let[e,t]of this.modifiers)this.applyModifier(e,t)}roll(){let e=this._roll();return this.results=new Map([...e].map((t,i)=>[i,{usable:!0,value:t,display:`${t}`,modifiers:new Set}])),this.applyModifiers(),this.conditions?.length&&this.applyConditions(),e}applyConditions(){for(let[e,t]of this.results){let i=this.conditions.find(({operator:r})=>r==="-="||r==="=-");if(i&&t.value===i.comparer){t.value=-1,t.modifiers.add("-");continue}this.checkCondition(t.value,this.conditions)?(t.modifiers.add("*"),t.value=1):t.usable=!1}}applyModifier(e,t){switch(e){case"sort":{let i;t.value=="sa"?i=[...this.results.values()].sort((a,r)=>a.value-r.value):i=[...this.results.values()].sort((a,r)=>r.value-a.value),this.results=new Map([...this.results.keys()].map(a=>[a,i[a]]));break}case"kh":{this.keepHigh(t.data);break}case"kl":{this.keepLow(t.data);break}case"!":{this.explode(t.data,t.conditionals);break}case"!!":{this.explodeAndCombine(t.data,t.conditionals);break}case"r":{this.reroll(t.data,t.conditionals);break}case"condition":}}checkCondition(e,t){return!t||!t.length?e:t.some(({operator:i,comparer:a})=>{if(Number.isNaN(e)||Number.isNaN(a))return!1;let r=!1;switch(i){case"=":r=e===a;break;case"!=":case"=!":r=e!==a;break;case"<":r=e<a;break;case"<=":r=e<=a;break;case">":r=e>a;break;case">=":r=e>=a;break}return r})}allowAverage(){return!0}average(){return(this.faces.min+this.faces.max)/2}getRandomBetween(e,t){return Math.floor(Math.random()*(t-e+1))+e}},yt=class extends k2{constructor(e,t){super("3d6",t);this.dice=e;this.lexeme=t}get doubles(){return new Set([...this.results].map(([,{usable:e,value:t}])=>e?t:0)).size<3}get result(){return this.static?Number(this.dice):[...this.results].map(([,{usable:t,value:i}])=>t?i:0).reduce((t,i)=>t+i,0)}get display(){let e=[];for(let t of this.results){if(t[0]==0&&this.doubles){e.push(`${t[1].value}S`);continue}e.push(`${t[1].value}`)}return`[${e.join(", ")}]`}allowAverage(){return!1}},za=class extends k2{constructor(e,t){super(e,t);this.dice=e;this.lexeme=t;this.stack=[];let i=`${this.faces.max}`.split("");for(let a=0;a<this.rolls;a++){let r=[];for(let s of i){let o=new k2(`1d${s}`);r.push(o),o.roll()}this.stack.push(r)}}get result(){return this.stack.map(e=>Number(e.map(t=>t.result).join(""))).reduce((e,t)=>e+t)}get display(){return this.stack.map(e=>e.map(t=>t.result).join(",")).join("|")}roll(){return!this.stack||!this.stack.length?super.roll():(this.stack.forEach(e=>e.map(t=>t.roll())),[...this.stack.map(e=>e.map(t=>t.result)).flat()])}allowAverage(){return!1}},S2=class extends v4{constructor(e,t,i,a=e.data.showDice,r,s,o=e.data.displayFormulaAfter){super(e,t,i,a);this.plugin=e;this.original=t;this.lexemes=i;this.displayFixedText=!1;this.stunted="";this.shouldRender=!1;this.showFormula=!1;this.operators={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"^":(e,t)=>Math.pow(e,t)};this.stack=[];this.stackCopy=[];this.dice=[];this.hasRunOnce=!1;o&&this.containerEl.createSpan({cls:"dice-roller-formula",text:`(${t})`}),this.fixedText=r,this.expectedValue=s,this.displayFixedText=this.fixedText!=="",this.loaded=!0,this.trigger("loaded")}get replacer(){return`${this.result}`}get resultText(){let e=[],t=0;return this.dice.forEach(i=>{let a=this.original.slice(t);e.push(a.slice(0,a.indexOf(i.lexeme.text)),i.display),t+=a.indexOf(i.lexeme.text)+i.lexeme.text.length+i.modifierText.length}),e.push(this.original.slice(t)),e.join("")}get tooltip(){return this._tooltip?this._tooltip:this.expectedValue===f2.Roll||this.shouldRender?this.displayFixedText?`${this.original}
${this.result} = ${this.resultText}`:`${this.original}
${this.resultText}`:this.expectedValue===f2.Average?this.displayFixedText?`${this.original}
${this.result} = average: ${this.resultText}`:`${this.original}
average: ${this.resultText}`:`${this.original}
empty`}allowAverage(){let e=t=>t.allowAverage();return this.dynamic.every(e)}async build(){if(this.expectedValue===f2.Average&&!this.shouldRender){if(this.allowAverage())for(let a of this.dynamic){let r=a.average();var e=Array(a.rolls).fill(r);a.setResults(e),this.recalculate()}else this.expectedValue=f2.Roll;this.result=Math.floor(this.result),this.setTooltip()}let t=this.result;switch(this.plugin.data.round){case pe.None:{t=Math.trunc(t*100)/100;break}case pe.Normal:{t=Math.round(t);break}case pe.Up:{t=Math.ceil(t);break}case pe.Down:{t=Math.floor(t);break}}let i;this.expectedValue===f2.None&&!this.shouldRender?(this.showDice?i=[""]:i=["\xA0"],this.showFormula&&i.unshift(this.original+" -> ")):(i=[`${t}`],this.showFormula&&i.unshift(this.inlineText)),this.expectedValue=f2.Roll,this.displayFixedText?this.resultEl.setText(this.fixedText):this.resultEl.setText(i.join("")+this.stunted)}async onClick(e){e.stopPropagation(),e.stopImmediatePropagation(),e.getModifierState("Alt")?this.expectedValue=f2.Average:e.getModifierState("Control")&&(this.expectedValue=f2.None),window.getSelection()?.isCollapsed&&await this.roll()}get dynamic(){return this.dice.filter(e=>!e.static)}get static(){return this.dice.filter(e=>e.static)}get isStatic(){return this.dice.every(e=>e.static)}async roll(){let e=0;this.stunted="";for(let t of this.lexemes)switch(t.type){case"+":case"-":case"*":case"/":case"^":case"math":let i=this.stack.pop(),a=this.stack.pop();if(!a){t.value==="-"&&(i=new k2(`-${i.dice}`,i.lexeme)),this.stackCopy.push(t.value),this.stack.push(i);continue}i.roll(),i instanceof yt&&i.doubles&&(this.stunted=` - ${i.results.get(0).value} Stunt Points`),a.roll(),a instanceof yt&&a.doubles&&(this.stunted=` - ${a.results.get(0).value} Stunt Points`);let r=this.operators[t.value](a.result,i.result);this.stackCopy.push(t.value),this.stack.push(new k2(`${r}`,t));break;case"kh":{let s=this.dice[e-1],o=t.value?Number(t.value):1;s.modifiers.set("kh",{data:o,conditionals:[],value:t.text});break}case"dl":{let s=this.dice[e-1],o=t.value?Number(t.value):1;o=s.results.size-o,s.modifiers.set("kh",{data:o,conditionals:[],value:t.text});break}case"kl":{let s=this.dice[e-1],o=t.value?Number(t.value):1;s.modifiers.set("kl",{data:o,conditionals:[],value:t.text});break}case"dh":{let s=this.dice[e-1],o=t.value?Number(t.value):1;o=s.results.size-o,s.modifiers.set("kl",{data:o,conditionals:[],value:t.text});break}case"!":{let s=this.dice[e-1],o=Number(t.value)||1;s.modifiers.set("!",{data:o,conditionals:t.conditions??[],value:t.text});break}case"!!":{let s=this.dice[e-1],o=Number(t.value)||1;s.modifiers.set("!!",{data:o,conditionals:t.conditions??[],value:t.text});break}case"r":{let s=this.dice[e-1],o=Number(t.value)||1;s.modifiers.set("r",{data:o,conditionals:t.conditions??[],value:t.text});break}case"sort":{let s=this.dice[e-1],o=Number(t.value);s.modifiers.set("sort",{data:o,conditionals:t.conditions??[],value:t.value});break}case"dice":{if(t.parenedDice&&/^d/.test(t.value)&&this.stack.length){let s=this.stack.pop();t.value=`${s.result}${t.value}`,this.dice[e]=new k2(t.value,t)}this.dice[e]||(this.dice[e]=new k2(t.value,t)),this.stack.push(this.dice[e]),this.stackCopy.push(this.dice[e]),e++;break}case"stunt":{this.dice[e]||(this.dice[e]=new yt(t.value,t)),this.stack.push(this.dice[e]),this.stackCopy.push(this.dice[e]),e++;break}case"%":{this.dice[e]||(this.dice[e]=new za(t.value,t)),this.stack.push(this.dice[e]),this.stackCopy.push(this.dice[e]),e++;break}}if(this.shouldRender&&this.hasRunOnce)await this.plugin.renderRoll(this),new g4.Notice(`${this.tooltip}
Result: ${this.result}`);else{let t=this.stack.pop();t.roll(),t instanceof yt&&t.doubles&&(this.stunted=` - ${t.results.get(0).value} Stunt Points`),this.result=t.result,this._tooltip=null}return this.render(),this.trigger("new-result"),this.hasRunOnce=!0,this.result}recalculate(){let e=[],t=0;for(let i of this.stackCopy)if(typeof i=="string"){let a=e.pop(),r=e.pop();if(!r){i==="-"&&(a=new k2(`-${a.result}`,a.lexeme)),e.push(a);continue}let s=this.operators[i](r.result,a.result);e.push(new k2(`${s}`))}else e.push(i),i instanceof k2&&i.applyModifiers();e.length&&e[0]instanceof k2&&(e[0].applyModifiers(),t+=e[0].result),this.result=t}toResult(){return{type:"dice",result:this.result,tooltip:this.tooltip}}async applyResult(e){e.type==="dice"&&(e.result&&(this.result=e.result),e.tooltip&&(this._tooltip=e.tooltip),await this.render())}setResult(e){}};var s2=w2(require("obsidian"));function Fc(n){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789",i=t.length;for(let a=0;a<n;a++)e+=t.charAt(Math.floor(Math.random()*i));return e}function Bc(n){return`dice-${Fc(4)}`}var Ct=class extends P4{constructor(e,t,i,a,r=!0,s=e.data.showDice){super(e,t,i,a,s);this.plugin=e;this.original=t;this.lexeme=i;this.inline=r;this.containerEl.addClasses(["has-embed","markdown-embed"]),this.resultEl.addClass("internal-embed"),this.resultEl.setAttrs({src:a}),this.copy=this.containerEl.createDiv({cls:"dice-content-copy dice-roller-button no-show",attr:{"aria-label":"Copy Contents"}}),this.copy.addEventListener("click",o=>{o.stopPropagation(),navigator.clipboard.writeText(this.displayFromCache(...this.results).trim()).then(async()=>{new s2.Notice("Result copied to clipboard.")})}),(0,s2.setIcon)(this.copy,Te)}get replacer(){let e=this.getBlockId(this.result);return e?`![[${this.path}#^${e}]]`:""}get tooltip(){return`${this.original}
${this.path}`}async build(){if(this.resultEl.empty(),this.plugin.data.displayResultsInline&&this.inline&&this.resultEl.createSpan({text:this.inlineText}),!this.results||!this.results.length){this.resultEl.createDiv({cls:"dice-no-results",text:"No results."});return}this.plugin.data.copyContentButton&&this.copy.removeClass("no-show");for(let e of this.results){this.resultEl.onclick=async i=>{if(i&&i.getModifierState("Control")||i.getModifierState("Meta")){i.stopPropagation();return}};let t=this.resultEl.createDiv({cls:"markdown-embed"});if(!this.plugin.data.displayResultsInline){let i="type"in e?e.type:"List Item";t.setAttrs({"aria-label":`${this.file.basename}: ${i}`})}if(!e){t.createDiv({cls:"dice-no-results",text:"No results."});continue}if(s2.MarkdownRenderer.renderMarkdown(this.displayFromCache(e),t.createDiv(),this.source,null),this.plugin.data.copyContentButton&&this.results.length>1){let i=t.createDiv({cls:"dice-content-copy dice-roller-button",attr:{"aria-label":"Copy Contents"}});i.addEventListener("click",a=>{a.stopPropagation(),navigator.clipboard.writeText(this.displayFromCache(e).trim()).then(async()=>{new s2.Notice("Result copied to clipboard.")})}),(0,s2.setIcon)(i,Te)}}}async load(){await this.getOptions()}displayFromCache(...e){let t=[];for(let i of e)t.push(this.content.slice(i.position.start.offset,i.position.end.offset));return t.join(`
`)}getBlockId(e){let t=this.cache.blocks??{},i=Object.entries(t).find(([a,r])=>Aa(r.position,e.position));if(!i){let a=`${Bc(4)}`,r=`${this.content.slice(0,this.result.position.end.offset+1)}^${a}${this.content.slice(this.result.position.end.offset)}`;return this.watch=!1,this.plugin.app.vault.modify(this.file,r),a}return i[0]}getPath(){let{groups:e}=this.lexeme.value.match(N0),{roll:t=1,link:i,types:a}=e;if(!i)throw new Error("Could not parse link.");this.rolls=(t&&!isNaN(Number(t))&&Number(t))??1,this.path=decodeURIComponent(i.replace(/(\[|\]|\(|\))/g,"")),this.types=a?.split(","),this.levels=a?.split(",").map(r=>/heading\-\d+/.test(r)?r.split("-").pop():null).filter(r=>r),this.types=a?.split(",").map(r=>/heading\-\d+/.test(r)?r.split("-").shift():r)}async getOptions(){if(this.cache=this.plugin.app.metadataCache.getFileCache(this.file),!this.cache||!this.cache.sections)throw new Error("Could not read file cache.");this.content=await this.plugin.app.vault.cachedRead(this.file),this.options=this.cache.sections.filter(({type:e,position:t})=>this.types?e=="heading"&&this.types.includes(e)&&this.levels.length?(this.cache.headings??[]).filter(({level:a})=>this.levels.includes(`${a}`)).some(({position:a})=>Aa(a,t)):this.types.includes(e):!["yaml","thematicBreak"].includes(e)),this.types&&this.types.includes("listItem")&&this.options.push(...this.cache.listItems),this.loaded=!0,this.trigger("loaded")}async roll(){return new Promise((e,t)=>{if(!this.loaded)this.on("loaded",()=>{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let a=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(a),1),a}).filter(a=>a),this.render(),this.trigger("new-result"),this.result=this.results[0],e(this.results[0])});else{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let a=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(a),1),a}).filter(a=>a),this.render(),this.trigger("new-result"),this.result=this.results[0],e(this.results[0])}})}toResult(){return{type:"section",result:this.results}}async applyResult(e){e.type==="section"&&(e.result&&(this.results=e.result),await this.render())}},o6=class extends v4{constructor(e,t,i,a,r=e.data.showDice){super(e,t,[i],r);this.plugin=e;this.original=t;this.lexeme=i;this.source=a;this.loaded=!1;if(!this.plugin.canUseDataview)throw new s2.Notice("A tag can only be rolled with the Dataview plugin enabled."),new Error("A tag can only be rolled with the Dataview plugin enabled.");this.containerEl.addClasses(["has-embed","markdown-embed"]);let{roll:s=1,tag:o,collapse:c,types:l}=i.value.match(V0).groups;this.collapse=c==="-"?!0:c==="+"?!1:!this.plugin.data.returnAllTags,this.tag=`#${o}`,this.rolls=Number(s),this.types=l,this.getFiles()}get replacer(){return this.result.replacer}get typeText(){return this.types?.length?`|${this.types}`:""}async getFiles(){if(!this.plugin.dataviewAPI){new s2.Notice("Dice Roller: Dataview must be installed and enabled to use tag rollers.");return}await this.plugin.dataviewReady();let e=await this.plugin.dataviewAPI.query(`list from ${this.tag}`);if(!e.successful)throw new Error(`No files found with that tag. Is the tag correct?
`+this.tag);let t=new Set(e.value.values.reduce((a,r)=>(r.type=="file"&&a.push(r.path),a),[]));if(t&&t.delete(this.source),!t||!t.size)throw new Error(`No files found with that tag. Is the tag correct?
`+this.tag);let i=Array.from(t).map(a=>`${this.rolls}d[[${a}]]${this.typeText}`);this.results=i.map(a=>new Ct(this.plugin,a,{...this.lexeme,value:a,type:"section"},this.source,!1)),this.loaded=!0,this.trigger("loaded")}async build(){if(this.resultEl.empty(),this.plugin.data.displayResultsInline&&this.resultEl.createSpan({text:this.inlineText}),this.collapse){this.chosen=this.random??this.getRandomBetween(0,this.results.length-1);let e=this.results[this.chosen];this.random=null;let t=this.resultEl.createDiv();t.createEl("h5",{cls:"dice-file-name",text:e.file.basename}),t.appendChild(e.containerEl)}else for(let e of this.results){let t=this.resultEl.createDiv();t.createEl("h5",{cls:"dice-file-name",text:e.file.basename}),t.appendChild(e.containerEl)}}async roll(){return new Promise((e,t)=>{this.loaded?(this.results.forEach(async i=>await i.roll()),this.render(),this.trigger("new-result"),this.result=this.results[0],e(this.result)):this.on("loaded",()=>{this.results.forEach(async i=>await i.roll()),this.render(),this.trigger("new-result"),this.result=this.results[0],e(this.result)})})}get tooltip(){return this.original}toResult(){return{type:"tag",random:this.chosen,result:Object.fromEntries(this.results.map(e=>[e.path,e.toResult()]))}}async applyResult(e){if(e.type==="tag"){if(e.result)for(let t in e.result){let i=this.results.find(a=>a.path===t);!i||i.applyResult(e.result[t])}e.random&&(this.random=e.random),await this.render()}}},c6=class extends v4{constructor(e,t,i,a,r=e.data.showDice){super(e,t,[i],r);this.plugin=e;this.original=t;this.lexeme=i;this.source=a;let{roll:s=1,tag:o}=i.value.match(V0).groups;this.tag=`#${o}`,this.rolls=(s&&!isNaN(Number(s))&&Number(s))??1,this.getFiles()}get replacer(){return`[[${this.result.basename}]]`}get tooltip(){return`${this.original}
${this.result.basename}`}async roll(){return new Promise((e,t)=>{this.loaded?(this.result=this.links[this.getRandomBetween(0,this.links.length-1)],this.render(),this.trigger("new-result"),e(this.result)):this.on("loaded",()=>{this.result=this.links[this.getRandomBetween(0,this.links.length-1)],this.render(),this.trigger("new-result"),e(this.result)})})}async build(){this.resultEl.empty(),this.plugin.data.displayResultsInline&&this.resultEl.createSpan({text:this.inlineText});let e=this.resultEl.createEl("a",{cls:"internal-link",text:this.result.basename});e.onclick=async t=>{t.stopPropagation(),this.plugin.app.workspace.openLinkText(this.result.path,this.plugin.app.workspace.getActiveFile()?.path,t.getModifierState("Control"))},e.onmouseenter=async t=>{this.plugin.app.workspace.trigger("link-hover",this,e,this.result.path,this.plugin.app.workspace.getActiveFile()?.path)}}async getFiles(){if(!this.plugin.dataviewAPI){new s2.Notice("Dice Roller: Dataview must be installed and enabled to use tag rollers.");return}await this.plugin.dataviewReady();let e=await this.plugin.dataviewAPI.query(`list from ${this.tag}`);if(!e.successful)throw new Error(`No files found with that tag. Is the tag correct?
`+this.tag);let t=new Set(e.value.values.reduce((i,a)=>(a.type=="file"&&i.push(a.path),i),[]));if(t&&t.delete(this.source),!t||!t.size)throw new Error(`No files found with that tag. Is the tag correct?
`+this.tag);this.links=Array.from(t).map(i=>this.plugin.app.metadataCache.getFirstLinkpathDest(i,this.source)),this.loaded=!0,this.trigger("loaded")}toResult(){return{type:"link",result:this.result.path}}async applyResult(e){if(e.type==="link"){if(e.result){let t=this.plugin.app.vault.getAbstractFileByPath(e.result);t&&t instanceof s2.TFile&&(this.result=t)}await this.render()}}},l6=class extends P4{constructor(e,t,i,a,r=!0,s=e.data.showDice){super(e,t,i,a,s);this.plugin=e;this.original=t;this.lexeme=i;this.inline=r;this.containerEl.addClasses(["has-embed","markdown-embed"]),this.resultEl.addClass("internal-embed"),this.resultEl.setAttrs({src:a}),this.copy=this.containerEl.createDiv({cls:"dice-content-copy dice-roller-button no-show",attr:{"aria-label":"Copy Contents"}}),this.copy.addEventListener("click",o=>{o.stopPropagation(),navigator.clipboard.writeText(this.results.join(`
`)).then(async()=>{new s2.Notice("Result copied to clipboard.")})}),(0,s2.setIcon)(this.copy,Te)}get replacer(){return this.result}get tooltip(){return`${this.original}
${this.path}`}async build(){if(this.resultEl.empty(),this.plugin.data.displayResultsInline&&this.inline&&this.resultEl.createSpan({text:this.inlineText}),!this.results||!this.results.length){this.resultEl.createDiv({cls:"dice-no-results",text:"No results."});return}this.plugin.data.copyContentButton&&this.copy.removeClass("no-show");for(let e of this.results){this.resultEl.onclick=async i=>{if(i&&i.getModifierState("Control")||i.getModifierState("Meta")){i.stopPropagation();return}};let t=this.resultEl.createDiv({cls:"markdown-embed"});if(!e){t.createDiv({cls:"dice-no-results",text:"No results."});continue}if(s2.MarkdownRenderer.renderMarkdown(e,t.createDiv(),this.source,null),this.plugin.data.copyContentButton&&this.results.length>1){let i=t.createDiv({cls:"dice-content-copy dice-roller-button",attr:{"aria-label":"Copy Contents"}});i.addEventListener("click",a=>{a.stopPropagation(),navigator.clipboard.writeText(e).then(async()=>{new s2.Notice("Result copied to clipboard.")})}),(0,s2.setIcon)(i,Te)}}}async load(){await this.getOptions()}getPath(){let{groups:e}=this.lexeme.value.match(N0),{roll:t=1,link:i,types:a}=e;if(!i)throw new Error("Could not parse link.");this.rolls=(t&&!isNaN(Number(t))&&Number(t))??1,this.path=i.replace(/(\[|\])/g,""),this.types=a?.split(",")}async getOptions(){if(this.content=await this.plugin.app.vault.cachedRead(this.file),!this.content)throw new Error("Could not read file cache.");this.options=this.content.trim().split(`
`).map(e=>e.trim()).filter(e=>e&&e.length),this.loaded=!0,this.trigger("loaded")}async roll(){return new Promise((e,t)=>{if(!this.loaded)this.on("loaded",()=>{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let a=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(a),1),a}).filter(a=>a),this.render(),this.trigger("new-result"),e(this.results[0])});else{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let a=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(a),1),a}).filter(a=>a),this.render(),this.trigger("new-result"),e(this.results[0])}})}toResult(){return{type:"section",result:this.results}}async applyResult(e){e.type==="section"&&(e.result&&(this.results=e.result),await this.render())}},Aa=(n,e)=>n.start.col==e.start.col&&n.start.line==e.start.line&&n.start.offset==e.start.offset;var x4=w2(require("obsidian"));var wa=class{constructor(){this.result="";this.combinedTooltip=""}},I4=class extends P4{constructor(){super(...arguments);this.combinedTooltip="";this.prettyTooltip=""}getPath(){let{groups:e}=this.lexeme.value.match(ba),{diceRoll:t="1",link:i,block:a,header:r}=e;if(!i||!a)throw new Error("Could not parse link.");let s=t.match(/(\d*?)[Dd]$/);if(s){let[,o="1"]=s;this.rollsFormula=o}else this.rollsFormula=t;this.rolls=1,this.path=decodeURIComponent(i.replace(/(\[|\]|\(|\))/g,"")),this.block=a.replace(/(\^|#)/g,"").trim().toLowerCase(),this.header=r}get tooltip(){return this.prettyTooltip}get replacer(){return this.result}async build(){this.resultEl.empty();let e=[this.result];this.plugin.data.displayResultsInline&&e.unshift(this.inlineText);let t=createSpan();await x4.MarkdownRenderer.renderMarkdown(e.join(""),t,this.source,null);let i=this.resultEl.createSpan("embedded-table-result");t.childElementCount==1&&t.firstElementChild instanceof HTMLParagraphElement?i.append(...Array.from(t.firstElementChild.childNodes)):i.append(...Array.from(t.childNodes))}prettify(e){let t=/(.*?)(\(|\)|;|\|\|)(.*)/,i=" ",a=0,r="",s=e,o;for(;o=s.match(t);){let[,c,l,u]=o;r+=c,l==")"?(a--,r+=`
`,r+=i.repeat(a),r+=")"):(l=="("?(a++,r+="("):l==";"?r+=",":l=="||"&&(r+="|"),r+=`
`,r+=i.repeat(a)),s=u}return r+=s,r}async getSubResult(e){let t=new wa;typeof e=="number"?t.result=e.toString():t.result=e;let i=[];if(typeof e=="string"){let a=/(?:\`dice:)(.*?)(?:\`)/g,r=e.matchAll(a);for(let s of r){let o=s[1].trim(),c=await this.plugin.getRoller(o,this.source);await c.roll();let l=await this.getSubResult(c.result),u;if(l.result instanceof x4.TFile?u=l.result.basename:u=l.result,t.result=t.result.replace(s[0],u),c instanceof I4)i.push(c.combinedTooltip);else{let[f,h]=c.tooltip.split(`
`);i.push(f+" --> "+h)}}}return t.combinedTooltip=i.join(";"),t}async getResult(){let e=[],t=[],i=this.original;if(this.rollsFormula)try{let a=await this.plugin.getRoller(this.rollsFormula,this.source);if(!(a instanceof S2))return this.prettyTooltip="TableRoller only supports dice rolls to select multiple elements.",new x4.Notice(this.prettyTooltip),"ERROR";let r=a;await r.roll(),this.rolls=r.result,r.isStatic||(i=i.replace(this.rollsFormula,`${this.rollsFormula.trim()} --> ${r.resultText} > `))}catch{return this.prettyTooltip=`TableRoller: '${this.rollsFormula}' is not a valid dice roll.`,new x4.Notice(this.prettyTooltip),"ERROR"}for(let a=0;a<this.rolls;a++){let r="",s,o="";if(this.isLookup){let c=await this.lookupRoller.roll(),l=this.lookupRanges.find(([u])=>u[1]===void 0&&c===u[0]||c>=u[0]&&u[1]>=c);l&&(r=this.lookupRoller.original.trim()+" --> "+`${this.lookupRoller.resultText}${this.header?" | "+this.header:""}`.trim(),o=l[1])}else{let c=[...this.options],l=this.getRandomBetween(0,c.length-1);r=c.length+" rows --> [row "+(l+1)+"]",o=c[l]}s=await this.getSubResult(o),e.push(s.result),s.combinedTooltip&&(r+=" > ("+s.combinedTooltip+")"),t.push(r)}return t.length==0?this.combinedTooltip=i:t.length==1?this.combinedTooltip=i+" "+t.join(""):this.combinedTooltip=i+" ==> ("+t.join(" ||")+")",this.prettyTooltip=this.prettify(this.combinedTooltip),e.join("||")}async roll(){return new Promise(async e=>{this.loaded?(this.result=await this.getResult(),this.render(),this.trigger("new-result"),e(this.result)):this.on("loaded",async()=>{this.result=await this.getResult(),this.render(),this.trigger("new-result"),e(this.result)})})}async load(){await this.getOptions()}async getOptions(){if(this.cache=this.plugin.app.metadataCache.getFileCache(this.file),!this.cache||!this.cache.blocks||!(this.block in this.cache.blocks))throw new Error(`Could not read file cache. Does the block reference exist?
${this.path} > ${this.block}`);let e=this.cache.sections?.find(t=>t.position==this.cache.blocks[this.block].position);if(this.position=this.cache.blocks[this.block].position,this.content=(await this.plugin.app.vault.cachedRead(this.file))?.slice(this.position.start.offset,this.position.end.offset),e&&e.type==="list")this.options=this.content.split(`
`);else{let t=Ic(this.content);if(Object.keys(t.columns).length===2&&/dice:\s*([\s\S]+)\s*?/.test(Object.keys(t.columns)[0])){let i=await this.plugin.getRoller(Object.keys(t.columns)[0].split(":").pop(),this.source);i instanceof S2&&(this.lookupRoller=i,this.lookupRanges=t.rows.map(a=>{let[r,s]=a.replace(/\\\|/g,"{ESCAPED_PIPE}").split("|").map(l=>l.replace(/{ESCAPED_PIPE}/g,"\\|")).map(l=>l.trim()),[,o,c]=r.match(/(\d+)(?:[^\d]+?(\d+))?/)??[];if(!(!o&&!c))return[[Number(o),c?Number(c):void 0],s]}),this.isLookup=!0)}if(this.header&&t.columns[this.header])this.options=t.columns[this.header];else{if(this.header)throw new Error(`Header ${this.header} was not found in table ${this.path} > ${this.block}.`);this.options=t.rows}}this.loaded=!0,this.trigger("loaded")}toResult(){return{type:"table",result:this.result}}async applyResult(e){e.type==="table"&&(e.result&&(this.result=e.result),await this.render())}},Pc=/^\|?([\s\S]+?)\|?$/,Sa=/\|/g;function Ic(n){let e=n.split(`
`),i=e.map(s=>(s.trim().match(Pc)??[,s.trim()])[1])[0].replace("\\|","{ESCAPED_PIPE}").split(Sa),a=[],r=[];for(let s in i){let o=i[s];o.trim().length||(o=s),r.push([o.trim(),[]])}for(let s of e.slice(2)){let o=s.trim().replace(/\\\|/g,"{ESCAPED_PIPE}").split(Sa).map(c=>c.replace(/{ESCAPED_PIPE}/g,"\\|")).map(c=>c.trim()).filter(c=>c.length);a.push(o.join(" | "));for(let c in o){let l=o[c].trim();!l.length||!r[c]||r[c][1].push(l)}}return{columns:Object.fromEntries(r),rows:a}}var E1=w2(require("obsidian"));var u6=class extends E1.PluginSettingTab{constructor(e,t){super(e,t);this.plugin=t;this.plugin=t}async display(){let{containerEl:e}=this;e.empty(),e.addClass("dice-roller-settings"),e.createEl("h2",{text:"Dice Roller Settings"}),this.buildGenerics(e.createDiv()),this.buildDisplay(e.createDiv()),this.buildDice(e.createDiv()),this.buildTables(e.createDiv()),this.buildSections(e.createDiv()),this.buildTags(e.createDiv()),this.buildView(e.createDiv()),this.buildRender(e.createDiv()),this.buildFormulaSettings(e.createDiv("dice-roller-setting-additional-container")),e.createDiv("coffee").createEl("a",{href:"https://www.buymeacoffee.com/valentine195"}).createEl("img",{attr:{src:"https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=\u2615&slug=valentine195&button_colour=e3e7ef&font_colour=262626&font_family=Inter&outline_colour=262626&coffee_colour=ff0000"}})}buildGenerics(e){e.empty(),new E1.Setting(e).setName("Globally Save Results").setDesc(createFragment(t=>{t.createSpan({text:"Dice results will be saved by default. This can be overridden using "}),t.createEl("code",{text:"dice-: formula"}),t.createEl("p",{text:"Please note that the plugin will attempt to save the result but may not be able to."})})).addToggle(t=>{t.setValue(this.plugin.data.persistResults),t.onChange(async i=>{this.plugin.data.persistResults=i,await this.plugin.saveSettings()})})}buildDisplay(e){e.empty(),new E1.Setting(e).setHeading().setName("Dice Display"),new E1.Setting(e).setName("Display Formula With Results").setDesc("Both the formula and the results will both be displayed in preview mode.").addToggle(t=>{t.setValue(this.plugin.data.displayResultsInline),t.onChange(async i=>{this.plugin.data.displayResultsInline=i,await this.plugin.saveSettings()})}),new E1.Setting(e).setName("Display Dice Button With Results").setDesc("A dice button will appear next to results.").addToggle(t=>{t.setValue(this.plugin.data.showDice),t.onChange(async i=>{this.plugin.data.showDice=i,await this.plugin.saveSettings()})}),new E1.Setting(e).setName("Add Formula When Using Modify Dice").setDesc(createFragment(t=>{t.createSpan({text:"Both the formula and the results will both be added to the note when using "}),t.createEl("code",{text:"dice-mod"}),t.createSpan({text:"."})})).addToggle(t=>{t.setValue(this.plugin.data.displayFormulaForMod),t.onChange(async i=>{this.plugin.data.displayFormulaForMod=i,await this.plugin.saveSettings()})}),new E1.Setting(e).setName("Display Formula in Parentheses After").setDesc(createFragment(t=>{t.createSpan({text:"For example, "}),t.createEl("code",{text:"`dice: 1d6`"}),t.createSpan({text:" will become "});let i=t.createSpan("dice-roller");i.createSpan({cls:"dice-roller-result",text:"3"}),(0,E1.setIcon)(i.createSpan("dice-roller-button"),Y2),t.createSpan({text:" (1d6). This only affects Dice Rollers."})})).addToggle(t=>{t.setValue(this.plugin.data.displayFormulaAfter),t.onChange(async i=>{this.plugin.data.displayFormulaAfter=i,await this.plugin.saveSettings()})})}buildDice(e){e.empty(),new E1.Setting(e).setHeading().setName("Dice Rollers"),new E1.Setting(e).setName("Default Face").setDesc("Use this as the number of faces when it is omitted.").addText(t=>{t.setValue(`${this.plugin.data.defaultFace}`),t.inputEl.onblur=async()=>{isNaN(Number(t.inputEl.value))&&new E1.Notice("The default face must be a number."),this.plugin.data.defaultFace=Number(t.inputEl.value),await this.plugin.saveSettings()}}),new E1.Setting(e).setName("Round Results").setDesc("Determine the rounding behavior for dice results.").addDropdown(t=>{t.addOptions(pe).setValue(this.plugin.data.round).onChange(i=>{this.plugin.data.round=i,this.plugin.saveSettings()})}),new E1.Setting(e).setName("Always Render Dice").setDesc(createFragment(t=>{t.createSpan({text:"Dice rolled in notes will always be rendered. Use the "}),t.createEl("code",{text:"|norender"}),t.createSpan({text:" flag to prevent it."})})).addToggle(t=>{t.setValue(this.plugin.data.renderAllDice).onChange(i=>{this.plugin.data.renderAllDice=i,this.plugin.saveSettings()})})}buildTables(e){e.empty(),new E1.Setting(e).setHeading().setName("Table Rollers"),new E1.Setting(e).setName("Display Lookup Table Roll").setDesc("Lookup table rolls will display the rolled number along with the result.").addToggle(t=>{t.setValue(this.plugin.data.displayLookupRoll),t.onChange(async i=>{this.plugin.data.displayLookupRoll=i,await this.plugin.saveSettings()})})}buildSections(e){e.empty(),new E1.Setting(e).setHeading().setName("Section Rollers"),new E1.Setting(e).setName("Add Copy Button to Section Results").setDesc("Randomly rolled sections will have a copy-content button to easy add result to clipboard.").addToggle(t=>{t.setValue(this.plugin.data.copyContentButton),t.onChange(async i=>{this.plugin.data.copyContentButton=i,await this.plugin.saveSettings()})})}buildTags(e){e.empty(),new E1.Setting(e).setHeading().setName("Tag Rollers"),new E1.Setting(e).setName("Roll All Files for Tags").setDesc("Return a result for each file when rolling tags.").addToggle(t=>{t.setValue(this.plugin.data.returnAllTags),t.onChange(async i=>{this.plugin.data.returnAllTags=i,await this.plugin.saveSettings()})}),new E1.Setting(e).setName("Always Return Links for Tags").setDesc("Enables random link rolling with the link parameter. Override by specifying a section type.").addToggle(t=>{t.setValue(this.plugin.data.rollLinksForTags),t.onChange(async i=>{this.plugin.data.rollLinksForTags=i,await this.plugin.saveSettings()})})}buildView(e){e.empty(),new E1.Setting(e).setHeading().setName("Dice View"),new E1.Setting(e).setName("Open Dice View on Startup").setDesc("The dice view can always be opened using the command from the command palette.").addToggle(t=>{t.setValue(this.plugin.data.showLeafOnStartup),t.onChange(async i=>{this.plugin.data.showLeafOnStartup=i,await this.plugin.saveSettings()})})}buildRender(e){e.empty(),new E1.Setting(e).setHeading().setName("Graphical Dice"),new E1.Setting(e).setName("Display graphics for Dice View Rolls").setDesc("Dice rolls from dice view will be displayed on screen.").addToggle(a=>{a.setValue(this.plugin.data.renderer),a.onChange(async r=>{this.plugin.data.renderer=r,await this.plugin.saveSettings()})}),new E1.Setting(e).setName("Display Time for Dice Graphics").setDesc("Rendered dice will stay on screen for this number of milliseconds. Leave blank to require a click to clear dice.").addText(a=>{a.inputEl.setAttr("type","number"),a.inputEl.onblur=r=>{Number(a.getValue())<0&&(new E1.Notice("Render time cannot be less than 0."),a.setValue("0"))},a.setValue(`${this.plugin.data.renderTime}`),a.onChange(async r=>{r&&Number(r)<0||isNaN(Number(r))||(this.plugin.data.renderTime=Number(r),await this.plugin.saveSettings())})}).addExtraButton(a=>{a.setIcon("reset").setTooltip("Reset to Default").onClick(async()=>{this.plugin.data.renderTime=h6.renderTime,await this.plugin.saveSettings(),this.buildRender(e)})}),new E1.Setting(e).setName("Dice Base Color").setDesc("Rendered dice will be this color.").controlEl.createEl("input",{type:"color",value:this.plugin.data.diceColor},a=>{a.value=this.plugin.data.diceColor,a.onchange=async({target:r})=>{let s=r.value;this.plugin.data.diceColor=s,await this.plugin.saveSettings(),this.plugin.app.workspace.trigger("dice-roller:update-colors")}}),new E1.Setting(e).setName("Dice Text Color").setDesc("Rendered dice will use this color for their numbers.").controlEl.createEl("input",{type:"color",value:this.plugin.data.textColor},a=>{a.value=this.plugin.data.textColor,a.onchange=async({target:r})=>{let s=r.value;!s||(this.plugin.data.textColor=s,await this.plugin.saveSettings(),this.plugin.app.workspace.trigger("dice-roller:update-colors"))}})}buildFormulaSettings(e){e.empty(),new E1.Setting(e).setHeading().setName("Saved Formulas");let t=e.createDiv();new E1.Setting(t).setName("Add Formula").setDesc("Add a new formula shortcut.").addButton(r=>r.setTooltip("Add Formula").setButtonText("+").onClick(async()=>{let o=await this.buildFormulaForm(t);o&&(this.plugin.data.formulas[o.alias]=o.formula,this.buildFormulaSettings(e),await this.plugin.saveSettings())}));let i=e.createDiv("additional"),a=this.plugin.data.formulas;for(let[r,s]of Object.entries(a)){let o=new E1.Setting(i).setName(r);o.controlEl.createSpan({text:s}),o.addExtraButton(c=>c.setIcon("pencil").setTooltip("Edit").onClick(async()=>{let l=await this.buildFormulaForm(t,{alias:r,formula:s});l&&(delete this.plugin.data.formulas[r],this.plugin.data.formulas[l.alias]=l.formula,this.buildFormulaSettings(e),await this.plugin.saveSettings())})).addExtraButton(c=>c.setIcon("trash").setTooltip("Delete").onClick(async()=>{delete this.plugin.data.formulas[r],await this.plugin.saveSettings(),this.buildFormulaSettings(e)}))}Object.values(a).length||i.createSpan({text:"Create a formula to see it here!",cls:"no-formulas"})}async buildFormulaForm(e,t={alias:null,formula:null}){return new Promise(i=>{let a=e.createDiv("add-new-formula"),r=a.createDiv("formula-data");new E1.Setting(r).setName("Alias").addText(o=>{o.setValue(t.alias).onChange(c=>t.alias=c)}),new E1.Setting(r).setName("Formula").addText(o=>{o.setValue(t.formula).onChange(c=>t.formula=c)});let s=a.createDiv("formula-buttons");new E1.Setting(s).addButton(o=>o.setCta().setButtonText("Save").onClick(async()=>{a.detach(),i(t)})).addExtraButton(o=>o.setIcon("cross").setTooltip("Cancel").onClick(()=>{a.detach(),i(null)}))})}};var L1=w2(require("obsidian"));var M4="DICE_ROLLER_VIEW",kc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><path class="cls-1" d="M244.62,49.31,40.31,403.19a6.21,6.21,0,0,0,5.38,9.31H454.31a6.21,6.21,0,0,0,5.38-9.31L255.38,49.31A6.21,6.21,0,0,0,244.62,49.31Z"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M270.21,278.16h21.7v16.22h-21.7v36.31h-20V294.38H179V282.67l70-108.39h21.16Zm-68.64,0h48.66v-76.7l-2.36,4.3Z"/></g></svg>',Uc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><rect class="cls-1" x="87.5" y="87.5" width="325" height="325" rx="10"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M279.22,174.18V191h-3.65q-23.2.44-37,13.75t-15.9,37.49q12.36-14.17,33.74-14.18,20.4,0,32.6,14.4t12.19,37.17q0,24.16-13.16,38.67t-35.29,14.5q-22.46,0-36.41-17.24t-14-44.42v-7.63q0-43.19,18.42-66t54.84-23.36Zm-26.1,70.47a33.41,33.41,0,0,0-30.73,21.48v7.31q0,19.33,8.7,31.15t21.7,11.81q13.43,0,21.11-9.88t7.68-25.89q0-16.11-7.79-26A25,25,0,0,0,253.12,244.65Z"/></g></svg>',Oc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><rect class="cls-1" x="102.75" y="102.75" width="294.51" height="294.51" rx="9.8" transform="translate(-103.55 250) rotate(-45)"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M292.08,215.1a36.35,36.35,0,0,1-6.17,20.84,42.05,42.05,0,0,1-16.71,14.29,44.8,44.8,0,0,1,19.39,15.36,38.7,38.7,0,0,1,7.15,22.88q0,20.31-13.7,32.34t-36,12q-22.56,0-36.15-12.09t-13.59-32.28a39.84,39.84,0,0,1,6.93-22.88,43.14,43.14,0,0,1,19.18-15.47,40.88,40.88,0,0,1-16.44-14.28,36.85,36.85,0,0,1-6-20.74q0-19.75,12.67-31.36T246,172.14q20.63,0,33.35,11.6T292.08,215.1ZM275.86,288q0-13.1-8.32-21.37t-21.75-8.27q-13.44,0-21.54,8.16T216.14,288q0,13.33,7.89,20.95t22,7.63q14,0,21.91-7.68T275.86,288ZM246,188.46q-11.72,0-19,7.26t-7.25,19.71q0,11.92,7.14,19.28T246,242.07q11.92,0,19.07-7.36t7.14-19.28q0-11.93-7.41-19.45T246,188.46Z"/></g></svg>',Gc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><rect class="cls-1" x="102.75" y="102.75" width="294.51" height="294.51" rx="9.8" transform="translate(-103.55 250) rotate(-45)"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M219,330.69H199V198.24L158.92,213V194.91l56.93-21.38H219Z"/><path d="M344.47,264q0,34.92-11.93,51.89t-37.27,17q-25,0-37.06-16.6t-12.46-49.57V240.13q0-34.47,11.92-51.24t37.38-16.75q25.24,0,37.17,16.16t12.25,49.9ZM324.59,236.8q0-25.23-7.09-36.79t-22.45-11.55q-15.26,0-22.23,11.5t-7.2,35.34v31.8q0,25.35,7.36,37.43t22.29,12.09q14.72,0,21.86-11.39t7.46-35.88Z"/></g></svg>',qc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><path class="cls-1" d="M244.31,29.14,52,168.87a9.72,9.72,0,0,0-3.52,10.84l73.47,226.1a9.69,9.69,0,0,0,9.21,6.69H368.87a9.69,9.69,0,0,0,9.21-6.69l73.47-226.1A9.72,9.72,0,0,0,448,168.87L255.69,29.14A9.66,9.66,0,0,0,244.31,29.14Z"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M208,330.69H188V198.24L147.93,213V194.91l56.93-21.38H208Z"/><path d="M342.28,330.69H239.8V316.4l54.14-60.15q12-13.65,16.6-22.19a37,37,0,0,0,4.56-17.67q0-12.24-7.41-20.08t-19.77-7.85q-14.82,0-23,8.44t-8.22,23.47H236.79q0-21.6,13.91-34.91t37.22-13.32q21.81,0,34.49,11.44T335.08,214q0,23.1-29.43,55l-41.9,45.44h78.53Z"/></g></svg>',Wc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><path class="cls-1" d="M55.14,143.27V356.73a10,10,0,0,0,5,8.66L245,472.11a10,10,0,0,0,10,0L439.86,365.39a10,10,0,0,0,5-8.66V143.27a10,10,0,0,0-5-8.66L255,27.89a10,10,0,0,0-10,0L60.14,134.61A10,10,0,0,0,55.14,143.27Z"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M251.34,330.69H148.86V316.4L203,256.25q12-13.65,16.6-22.19a37,37,0,0,0,4.57-17.67q0-12.24-7.42-20.08T197,188.46q-14.82,0-23,8.44t-8.22,23.47H145.86q0-21.6,13.91-34.91T197,172.14q21.81,0,34.48,11.44T244.15,214q0,23.1-29.44,55l-41.89,45.44h78.52Z"/><path d="M361.67,264q0,34.92-11.92,51.89t-37.27,17q-25,0-37.06-16.6T263,266.67V240.13q0-34.47,11.93-51.24t37.38-16.75q25.25,0,37.17,16.16t12.24,49.9ZM341.8,236.8q0-25.23-7.09-36.79t-22.45-11.55Q297,188.46,290,200t-7.19,35.34v31.8q0,25.35,7.36,37.43t22.29,12.09q14.72,0,21.86-11.39t7.46-35.88Z"/></g></svg>',jc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><circle class="cls-1" cx="246.23" cy="250" r="189.38"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M172.54,194.88q0-15.7,10.19-25.49t26.72-9.79q16.76,0,27,9.67t10.19,26.19v8.44q0,15.82-10.19,25.43t-26.72,9.61q-16.65,0-26.9-9.67T172.54,203.2Zm22.5,9.17q0,7.06,4,11.37a13.88,13.88,0,0,0,10.61,4.3,13.24,13.24,0,0,0,10.43-4.36Q224,211,224,203.69V195c0-4.71-1.28-8.53-3.86-11.43s-6.14-4.36-10.67-4.36a13.56,13.56,0,0,0-10.43,4.3q-4,4.31-4,12Zm21.33,115.87L199.84,311l83.32-133.36,16.53,8.91Zm37.73-29.06q0-15.83,10.31-25.49t26.72-9.67q16.65,0,26.9,9.55t10.25,26.31V300q0,15.71-10.08,25.37T291.37,335q-16.87,0-27.07-9.73t-10.2-25.78Zm22.5,9.28a15.82,15.82,0,0,0,4.22,11.08,13.71,13.71,0,0,0,10.55,4.6q14.29,0,14.29-15.92V291q0-7.08-4-11.38a15.08,15.08,0,0,0-21.09,0q-4,4.31-4,11.73Z"/></g></svg>';(0,L1.addIcon)("d4",kc);(0,L1.addIcon)("d6",Uc);(0,L1.addIcon)("d8",Oc);(0,L1.addIcon)("d10",Gc);(0,L1.addIcon)("d12",qc);(0,L1.addIcon)("d20",Wc);(0,L1.addIcon)("d100",jc);(0,L1.addIcon)("dice-roller-save",'<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" data-prefix="far" data-icon="save" class="svg-inline--fa fa-save fa-w-14" role="img" viewBox="0 0 448 512"><path fill="currentColor" d="M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM272 80v80H144V80h128zm122 352H54a6 6 0 0 1-6-6V86a6 6 0 0 1 6-6h42v104c0 13.255 10.745 24 24 24h176c13.255 0 24-10.745 24-24V83.882l78.243 78.243a6 6 0 0 1 1.757 4.243V426a6 6 0 0 1-6 6zM224 232c-48.523 0-88 39.477-88 88s39.477 88 88 88 88-39.477 88-88-39.477-88-88-88zm0 128c-22.056 0-40-17.944-40-40s17.944-40 40-40 40 17.944 40 40-17.944 40-40 40z"/></svg>');(0,L1.addIcon)("dice-roller-plus",'<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" data-prefix="far" data-icon="plus-square" class="svg-inline--fa fa-plus-square fa-w-14" role="img" viewBox="0 0 448 512"><path fill="currentColor" d="M352 240v32c0 6.6-5.4 12-12 12h-88v88c0 6.6-5.4 12-12 12h-32c-6.6 0-12-5.4-12-12v-88h-88c-6.6 0-12-5.4-12-12v-32c0-6.6 5.4-12 12-12h88v-88c0-6.6 5.4-12 12-12h32c6.6 0 12 5.4 12 12v88h88c6.6 0 12 5.4 12 12zm96-160v352c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V80c0-26.5 21.5-48 48-48h352c26.5 0 48 21.5 48 48zm-48 346V86c0-3.3-2.7-6-6-6H54c-3.3 0-6 2.7-6 6v340c0 3.3 2.7 6 6 6h340c3.3 0 6-2.7 6-6z"/></svg>');(0,L1.addIcon)("dice-roller-minus",'<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" data-prefix="far" data-icon="minus-square" class="svg-inline--fa fa-minus-square fa-w-14" role="img" viewBox="0 0 448 512"><path fill="currentColor" d="M108 284c-6.6 0-12-5.4-12-12v-32c0-6.6 5.4-12 12-12h232c6.6 0 12 5.4 12 12v32c0 6.6-5.4 12-12 12H108zM448 80v352c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V80c0-26.5 21.5-48 48-48h352c26.5 0 48 21.5 48 48zm-48 346V86c0-3.3-2.7-6-6-6H54c-3.3 0-6 2.7-6 6v340c0 3.3 2.7 6 6 6h340c3.3 0 6-2.7 6-6z"/></svg>');var Je=class extends L1.ItemView{constructor(e,t){super(t);this.plugin=e;this.leaf=t;this.dice=Je.DICE();this.custom="";this.adv=!1;this.dis=!1;this.add=0;this.contentEl.addClass("dice-roller-view"),this.registerEvent(this.plugin.app.workspace.on("dice-roller:update-colors",()=>{this.renderer.factory.updateColors()}))}static DICE(){return{d4:0,d6:0,d8:0,d10:0,d12:0,d20:0,d100:0}}get customFormulas(){return this.plugin.data.customFormulas}get renderer(){return this.plugin.renderer}async onOpen(){this.display()}async display(){this.contentEl.empty(),this.gridEl=this.contentEl.createDiv("dice-roller-grid"),this.formulaEl=this.contentEl.createDiv("dice-roller-formula");let e=this.contentEl.createDiv("dice-roller-results-container"),t=e.createDiv("dice-roller-results-header");t.createEl("h4",{text:"Results"}),new L1.ExtraButtonComponent(t.createDiv("clear-all")).setIcon("trash").setTooltip("Clear All").onClick(()=>{this.resultEl.empty(),this.resultEl.append(this.noResultsEl)}),this.resultEl=e.createDiv("dice-roller-results"),this.noResultsEl=this.resultEl.createSpan({text:"No results yet! Roll some dice to get started :)"}),this.buildButtons(),this.buildFormula()}buildButtons(){this.gridEl.empty();let e=this.gridEl.createDiv("dice-buttons");for(let o in this.dice){let c=new L1.ExtraButtonComponent(e.createDiv("dice-button")).setIcon(o);c.extraSettingsEl.onclick=async l=>{let u=l.getModifierState("Shift")?-1:1;this.dice[o]+=u,this.setFormula();let f=await this.plugin.getRoller(this.formulaComponent.inputEl.value,"view");f instanceof S2&&(this.stack=f)}}let t=this.gridEl.createDiv("advantage-disadvantage"),i=new L1.ButtonComponent(t).setButtonText("ADV").onClick(()=>{this.adv=!this.adv,this.dis=!1,this.adv?(i.setCta(),a.removeCta()):i.removeCta(),this.setFormula()}),a=new L1.ButtonComponent(t).setButtonText("DIS").onClick(()=>{this.dis=!this.dis,this.dis?(a.setCta(),i.removeCta()):a.removeCta(),this.adv=!1,this.setFormula()}),r=this.gridEl.createDiv("dice-context").createDiv("add-subtract");new L1.ExtraButtonComponent(r).setIcon("dice-roller-minus").onClick(()=>{this.add-=1,s.setValue(`${this.add}`),this.setFormula()});let s=new L1.TextComponent(r).setValue(`${this.add?this.add:""}`).onChange(o=>{isNaN(Number(o))||(this.add=Number(o)),this.setFormula()});if(new L1.ExtraButtonComponent(r).setIcon("dice-roller-plus").onClick(()=>{this.add+=1,s.setValue(`${this.add}`),this.setFormula()}),this.customFormulas.length){let o=this.gridEl.createDiv("dice-roller-results-container");o.createDiv("dice-roller-results-header").createEl("h4",{text:"Saved Formulas"});for(let l of this.customFormulas){let u=o.createDiv("dice-custom-formula-container"),f=u.createDiv("dice-custom-formula");new L1.ExtraButtonComponent(f).setIcon(Y2).setTooltip("Roll").onClick(()=>this.roll(l)),f.createSpan({text:l}),new L1.ExtraButtonComponent(u).setIcon("trash").setTooltip("Remove").onClick(()=>{this.plugin.data.customFormulas=this.plugin.data.customFormulas.filter(h=>h!=l),this.plugin.saveSettings(),this.buildButtons()})}}}async roll(e=this.formulaComponent.inputEl.value){if(!e)return;this.rollButton.setDisabled(!0);let t=await this.plugin.getRoller(e,"view");if(!(t instanceof S2)){new L1.Notice("The Dice View only supports dice rolls.");return}if(await t.roll(),!t.dice.length){new L1.Notice("Invalid formula.");return}try{this.plugin.data.renderer&&(this.addChild(this.renderer),this.renderer.setDice(t),await this.renderer.start(),t.recalculate())}catch(i){new L1.Notice("There was an error rendering the roll."),console.error(i)}this.rollButton.setDisabled(!1),this.addResult({result:t.result,original:t.original,resultText:t.resultText}),this.dice=Je.DICE(),this.add=null,this.adv=!1,this.dis=!1,this.buildButtons(),this.setFormula()}buildFormula(){this.formulaEl.empty(),this.formulaComponent=new L1.TextAreaComponent(this.formulaEl).setPlaceholder("Dice Formula"),this.formulaComponent.onChange((0,L1.debounce)(async t=>{},500,!0));let e=this.formulaEl.createDiv("action-buttons");this.saveButton=new L1.ButtonComponent(e).setIcon("plus-with-circle").setCta().setTooltip("Save Formula").onClick(()=>this.save()),this.saveButton.buttonEl.addClass("dice-roller-roll"),this.rollButton=new L1.ButtonComponent(e).setIcon(Y2).setCta().setTooltip("Roll").onClick(()=>this.roll()),this.rollButton.buttonEl.addClass("dice-roller-roll")}save(){!this.formulaComponent.inputEl.value||(this.plugin.data.customFormulas.push(this.formulaComponent.inputEl.value),this.buildButtons(),this.plugin.saveSettings())}addResult(e){this.noResultsEl&&this.noResultsEl.detach();let t=createDiv("view-result");t.createSpan({text:e.original}),t.createEl("strong",{text:`${e.result}`,attr:{"aria-label":e.resultText}});let i=t.createDiv("result-context");i.createEl("em",{text:new Date().toLocaleString()}),new L1.ExtraButtonComponent(i).setIcon("trash").onClick(()=>{t.detach(),this.resultEl.children.length===0&&this.resultEl.prepend(this.noResultsEl)}),new L1.ExtraButtonComponent(i).setIcon(Te).setTooltip("Copy Result").onClick(async()=>{await navigator.clipboard.writeText(`${e.result}`)}).extraSettingsEl.addClass("dice-content-copy"),new L1.ExtraButtonComponent(i).setIcon(Y2).setTooltip("Roll Again").onClick(()=>this.roll(e.original)).extraSettingsEl.addClass("dice-result-reroll"),this.resultEl.prepend(t)}get formulaString(){let e=[],t=Object.entries(this.dice).filter(([a,r])=>r!=0);if(!t.length)return"";t.sort((a,r)=>Number(r[0].slice(1))-Number(a[0].slice(1)));let i=t.shift();return e.push(`${i[1]}${i[0]}`),this.adv?e.push("kh"):this.dis&&e.push("dh"),t.length&&e.push(...t.map(([a,r])=>`${r>0?"+":"-"}${Math.abs(r)}${a}`)),this.add&&this.add!=0&&(e.push(this.add>0?"+":"-"),e.push(Math.abs(this.add))),e.join("")}setFormula(){this.formulaComponent.setValue(this.formulaString)}getDisplayText(){return"Dice Roller"}getViewType(){return M4}getIcon(){return Y2}async onClose(){await super.onClose(),this.renderer.unload()}};var Xt=w2(require("obsidian"));var _2=class{constructor(e=[0,0,0,0,0,0,0,0,0]){this.elements=void 0,this.elements=e}identity(){let e=this.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1}setZero(){let e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0}setTrace(e){let t=this.elements;t[0]=e.x,t[4]=e.y,t[8]=e.z}getTrace(e=new y){let t=this.elements;return e.x=t[0],e.y=t[4],e.z=t[8],e}vmult(e,t=new y){let i=this.elements,a=e.x,r=e.y,s=e.z;return t.x=i[0]*a+i[1]*r+i[2]*s,t.y=i[3]*a+i[4]*r+i[5]*s,t.z=i[6]*a+i[7]*r+i[8]*s,t}smult(e){for(let t=0;t<this.elements.length;t++)this.elements[t]*=e}mmult(e,t=new _2){let i=this.elements,a=e.elements,r=t.elements,s=i[0],o=i[1],c=i[2],l=i[3],u=i[4],f=i[5],h=i[6],m=i[7],v=i[8],g=a[0],x=a[1],p=a[2],d=a[3],A=a[4],b=a[5],C=a[6],E=a[7],T=a[8];return r[0]=s*g+o*d+c*C,r[1]=s*x+o*A+c*E,r[2]=s*p+o*b+c*T,r[3]=l*g+u*d+f*C,r[4]=l*x+u*A+f*E,r[5]=l*p+u*b+f*T,r[6]=h*g+m*d+v*C,r[7]=h*x+m*A+v*E,r[8]=h*p+m*b+v*T,t}scale(e,t=new _2){let i=this.elements,a=t.elements;for(let r=0;r!==3;r++)a[3*r+0]=e.x*i[3*r+0],a[3*r+1]=e.y*i[3*r+1],a[3*r+2]=e.z*i[3*r+2];return t}solve(e,t=new y){let i=3,a=4,r=[],s,o;for(s=0;s<i*a;s++)r.push(0);for(s=0;s<3;s++)for(o=0;o<3;o++)r[s+a*o]=this.elements[s+3*o];r[3+4*0]=e.x,r[3+4*1]=e.y,r[3+4*2]=e.z;let c=3,l=c,u,f=4,h;do{if(s=l-c,r[s+a*s]===0){for(o=s+1;o<l;o++)if(r[s+a*o]!==0){u=f;do h=f-u,r[h+a*s]+=r[h+a*o];while(--u);break}}if(r[s+a*s]!==0)for(o=s+1;o<l;o++){let m=r[s+a*o]/r[s+a*s];u=f;do h=f-u,r[h+a*o]=h<=s?0:r[h+a*o]-r[h+a*s]*m;while(--u)}}while(--c);if(t.z=r[2*a+3]/r[2*a+2],t.y=(r[1*a+3]-r[1*a+2]*t.z)/r[1*a+1],t.x=(r[0*a+3]-r[0*a+2]*t.z-r[0*a+1]*t.y)/r[0*a+0],isNaN(t.x)||isNaN(t.y)||isNaN(t.z)||t.x===1/0||t.y===1/0||t.z===1/0)throw"Could not solve equation! Got x=["+t.toString()+"], b=["+e.toString()+"], A=["+this.toString()+"]";return t}e(e,t,i){if(i===void 0)return this.elements[t+3*e];this.elements[t+3*e]=i}copy(e){for(let t=0;t<e.elements.length;t++)this.elements[t]=e.elements[t];return this}toString(){let e="",t=",";for(let i=0;i<9;i++)e+=this.elements[i]+t;return e}reverse(e=new _2){let t=3,i=6,a=Xc,r,s;for(r=0;r<3;r++)for(s=0;s<3;s++)a[r+i*s]=this.elements[r+3*s];a[3+6*0]=1,a[3+6*1]=0,a[3+6*2]=0,a[4+6*0]=0,a[4+6*1]=1,a[4+6*2]=0,a[5+6*0]=0,a[5+6*1]=0,a[5+6*2]=1;let o=3,c=o,l,u=i,f;do{if(r=c-o,a[r+i*r]===0){for(s=r+1;s<c;s++)if(a[r+i*s]!==0){l=u;do f=u-l,a[f+i*r]+=a[f+i*s];while(--l);break}}if(a[r+i*r]!==0)for(s=r+1;s<c;s++){let h=a[r+i*s]/a[r+i*r];l=u;do f=u-l,a[f+i*s]=f<=r?0:a[f+i*s]-a[f+i*r]*h;while(--l)}}while(--o);r=2;do{s=r-1;do{let h=a[r+i*s]/a[r+i*r];l=i;do f=i-l,a[f+i*s]=a[f+i*s]-a[f+i*r]*h;while(--l)}while(s--)}while(--r);r=2;do{let h=1/a[r+i*r];l=i;do f=i-l,a[f+i*r]=a[f+i*r]*h;while(--l)}while(r--);r=2;do{s=2;do{if(f=a[t+s+i*r],isNaN(f)||f===1/0)throw"Could not reverse! A=["+this.toString()+"]";e.e(r,s,f)}while(s--)}while(r--);return e}setRotationFromQuaternion(e){let t=e.x,i=e.y,a=e.z,r=e.w,s=t+t,o=i+i,c=a+a,l=t*s,u=t*o,f=t*c,h=i*o,m=i*c,v=a*c,g=r*s,x=r*o,p=r*c,d=this.elements;return d[3*0+0]=1-(h+v),d[3*0+1]=u-p,d[3*0+2]=f+x,d[3*1+0]=u+p,d[3*1+1]=1-(l+v),d[3*1+2]=m-g,d[3*2+0]=f-x,d[3*2+1]=m+g,d[3*2+2]=1-(l+h),this}transpose(e=new _2){let t=this.elements,i=e.elements,a;return i[0]=t[0],i[4]=t[4],i[8]=t[8],a=t[1],i[1]=t[3],i[3]=a,a=t[2],i[2]=t[6],i[6]=a,a=t[5],i[5]=t[7],i[7]=a,e}},Xc=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],y=class{constructor(e=0,t=0,i=0){this.x=void 0,this.y=void 0,this.z=void 0,this.x=e,this.y=t,this.z=i}cross(e,t=new y){let i=e.x,a=e.y,r=e.z,s=this.x,o=this.y,c=this.z;return t.x=o*r-c*a,t.y=c*i-s*r,t.z=s*a-o*i,t}set(e,t,i){return this.x=e,this.y=t,this.z=i,this}setZero(){this.x=this.y=this.z=0}vadd(e,t){if(t)t.x=e.x+this.x,t.y=e.y+this.y,t.z=e.z+this.z;else return new y(this.x+e.x,this.y+e.y,this.z+e.z)}vsub(e,t){if(t)t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z;else return new y(this.x-e.x,this.y-e.y,this.z-e.z)}crossmat(){return new _2([0,-this.z,this.y,this.z,0,-this.x,-this.y,this.x,0])}normalize(){let e=this.x,t=this.y,i=this.z,a=Math.sqrt(e*e+t*t+i*i);if(a>0){let r=1/a;this.x*=r,this.y*=r,this.z*=r}else this.x=0,this.y=0,this.z=0;return a}unit(e=new y){let t=this.x,i=this.y,a=this.z,r=Math.sqrt(t*t+i*i+a*a);return r>0?(r=1/r,e.x=t*r,e.y=i*r,e.z=a*r):(e.x=1,e.y=0,e.z=0),e}length(){let e=this.x,t=this.y,i=this.z;return Math.sqrt(e*e+t*t+i*i)}lengthSquared(){return this.dot(this)}distanceTo(e){let t=this.x,i=this.y,a=this.z,r=e.x,s=e.y,o=e.z;return Math.sqrt((r-t)*(r-t)+(s-i)*(s-i)+(o-a)*(o-a))}distanceSquared(e){let t=this.x,i=this.y,a=this.z,r=e.x,s=e.y,o=e.z;return(r-t)*(r-t)+(s-i)*(s-i)+(o-a)*(o-a)}scale(e,t=new y){let i=this.x,a=this.y,r=this.z;return t.x=e*i,t.y=e*a,t.z=e*r,t}vmul(e,t=new y){return t.x=e.x*this.x,t.y=e.y*this.y,t.z=e.z*this.z,t}addScaledVector(e,t,i=new y){return i.x=this.x+e*t.x,i.y=this.y+e*t.y,i.z=this.z+e*t.z,i}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}isZero(){return this.x===0&&this.y===0&&this.z===0}negate(e=new y){return e.x=-this.x,e.y=-this.y,e.z=-this.z,e}tangents(e,t){let i=this.length();if(i>0){let a=Zc,r=1/i;a.set(this.x*r,this.y*r,this.z*r);let s=Yc;Math.abs(a.x)<.9?(s.set(1,0,0),a.cross(s,e)):(s.set(0,1,0),a.cross(s,e)),a.cross(e,t)}else e.set(1,0,0),t.set(0,1,0)}toString(){return this.x+","+this.y+","+this.z}toArray(){return[this.x,this.y,this.z]}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}lerp(e,t,i){let a=this.x,r=this.y,s=this.z;i.x=a+(e.x-a)*t,i.y=r+(e.y-r)*t,i.z=s+(e.z-s)*t}almostEquals(e,t=1e-6){return!(Math.abs(this.x-e.x)>t||Math.abs(this.y-e.y)>t||Math.abs(this.z-e.z)>t)}almostZero(e=1e-6){return!(Math.abs(this.x)>e||Math.abs(this.y)>e||Math.abs(this.z)>e)}isAntiparallelTo(e,t){return this.negate(_a),_a.almostEquals(e,t)}clone(){return new y(this.x,this.y,this.z)}};y.ZERO=void 0;y.UNIT_X=void 0;y.UNIT_Y=void 0;y.UNIT_Z=void 0;y.ZERO=new y(0,0,0);y.UNIT_X=new y(1,0,0);y.UNIT_Y=new y(0,1,0);y.UNIT_Z=new y(0,0,1);var Zc=new y,Yc=new y,_a=new y,E2=class{constructor(e={}){this.lowerBound=void 0,this.upperBound=void 0,this.lowerBound=new y,this.upperBound=new y,e.lowerBound&&this.lowerBound.copy(e.lowerBound),e.upperBound&&this.upperBound.copy(e.upperBound)}setFromPoints(e,t,i,a){let r=this.lowerBound,s=this.upperBound,o=i;r.copy(e[0]),o&&o.vmult(r,r),s.copy(r);for(let c=1;c<e.length;c++){let l=e[c];o&&(o.vmult(l,Ea),l=Ea),l.x>s.x&&(s.x=l.x),l.x<r.x&&(r.x=l.x),l.y>s.y&&(s.y=l.y),l.y<r.y&&(r.y=l.y),l.z>s.z&&(s.z=l.z),l.z<r.z&&(r.z=l.z)}return t&&(t.vadd(r,r),t.vadd(s,s)),a&&(r.x-=a,r.y-=a,r.z-=a,s.x+=a,s.y+=a,s.z+=a),this}copy(e){return this.lowerBound.copy(e.lowerBound),this.upperBound.copy(e.upperBound),this}clone(){return new E2().copy(this)}extend(e){this.lowerBound.x=Math.min(this.lowerBound.x,e.lowerBound.x),this.upperBound.x=Math.max(this.upperBound.x,e.upperBound.x),this.lowerBound.y=Math.min(this.lowerBound.y,e.lowerBound.y),this.upperBound.y=Math.max(this.upperBound.y,e.upperBound.y),this.lowerBound.z=Math.min(this.lowerBound.z,e.lowerBound.z),this.upperBound.z=Math.max(this.upperBound.z,e.upperBound.z)}overlaps(e){let t=this.lowerBound,i=this.upperBound,a=e.lowerBound,r=e.upperBound,s=a.x<=i.x&&i.x<=r.x||t.x<=r.x&&r.x<=i.x,o=a.y<=i.y&&i.y<=r.y||t.y<=r.y&&r.y<=i.y,c=a.z<=i.z&&i.z<=r.z||t.z<=r.z&&r.z<=i.z;return s&&o&&c}volume(){let e=this.lowerBound,t=this.upperBound;return(t.x-e.x)*(t.y-e.y)*(t.z-e.z)}contains(e){let t=this.lowerBound,i=this.upperBound,a=e.lowerBound,r=e.upperBound;return t.x<=a.x&&i.x>=r.x&&t.y<=a.y&&i.y>=r.y&&t.z<=a.z&&i.z>=r.z}getCorners(e,t,i,a,r,s,o,c){let l=this.lowerBound,u=this.upperBound;e.copy(l),t.set(u.x,l.y,l.z),i.set(u.x,u.y,l.z),a.set(l.x,u.y,u.z),r.set(u.x,l.y,u.z),s.set(l.x,u.y,l.z),o.set(l.x,l.y,u.z),c.copy(u)}toLocalFrame(e,t){let i=La,a=i[0],r=i[1],s=i[2],o=i[3],c=i[4],l=i[5],u=i[6],f=i[7];this.getCorners(a,r,s,o,c,l,u,f);for(let h=0;h!==8;h++){let m=i[h];e.pointToLocal(m,m)}return t.setFromPoints(i)}toWorldFrame(e,t){let i=La,a=i[0],r=i[1],s=i[2],o=i[3],c=i[4],l=i[5],u=i[6],f=i[7];this.getCorners(a,r,s,o,c,l,u,f);for(let h=0;h!==8;h++){let m=i[h];e.pointToWorld(m,m)}return t.setFromPoints(i)}overlapsRay(e){let{direction:t,from:i}=e,a=1/t.x,r=1/t.y,s=1/t.z,o=(this.lowerBound.x-i.x)*a,c=(this.upperBound.x-i.x)*a,l=(this.lowerBound.y-i.y)*r,u=(this.upperBound.y-i.y)*r,f=(this.lowerBound.z-i.z)*s,h=(this.upperBound.z-i.z)*s,m=Math.max(Math.max(Math.min(o,c),Math.min(l,u)),Math.min(f,h)),v=Math.min(Math.min(Math.max(o,c),Math.max(l,u)),Math.max(f,h));return!(v<0||m>v)}},Ea=new y,La=[new y,new y,new y,new y,new y,new y,new y,new y],B0=class{constructor(){this.matrix=void 0,this.matrix=[]}get(e,t){let{index:i}=e,{index:a}=t;if(a>i){let r=a;a=i,i=r}return this.matrix[(i*(i+1)>>1)+a-1]}set(e,t,i){let{index:a}=e,{index:r}=t;if(r>a){let s=r;r=a,a=s}this.matrix[(a*(a+1)>>1)+r-1]=i?1:0}reset(){for(let e=0,t=this.matrix.length;e!==t;e++)this.matrix[e]=0}setNumObjects(e){this.matrix.length=e*(e-1)>>1}},P0=class{constructor(){this._listeners=void 0}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;return i[e]===void 0&&(i[e]=[]),i[e].includes(t)||i[e].push(t),this}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return!!(i[e]!==void 0&&i[e].includes(t))}hasAnyEventListener(e){return this._listeners===void 0?!1:this._listeners[e]!==void 0}removeEventListener(e,t){if(this._listeners===void 0)return this;let i=this._listeners;if(i[e]===void 0)return this;let a=i[e].indexOf(t);return a!==-1&&i[e].splice(a,1),this}dispatchEvent(e){if(this._listeners===void 0)return this;let i=this._listeners[e.type];if(i!==void 0){e.target=this;for(let a=0,r=i.length;a<r;a++)i[a].call(this,e)}return this}},O1=class{constructor(e=0,t=0,i=0,a=1){this.x=void 0,this.y=void 0,this.z=void 0,this.w=void 0,this.x=e,this.y=t,this.z=i,this.w=a}set(e,t,i,a){return this.x=e,this.y=t,this.z=i,this.w=a,this}toString(){return this.x+","+this.y+","+this.z+","+this.w}toArray(){return[this.x,this.y,this.z,this.w]}setFromAxisAngle(e,t){let i=Math.sin(t*.5);return this.x=e.x*i,this.y=e.y*i,this.z=e.z*i,this.w=Math.cos(t*.5),this}toAxisAngle(e=new y){this.normalize();let t=2*Math.acos(this.w),i=Math.sqrt(1-this.w*this.w);return i<.001?(e.x=this.x,e.y=this.y,e.z=this.z):(e.x=this.x/i,e.y=this.y/i,e.z=this.z/i),[e,t]}setFromVectors(e,t){if(e.isAntiparallelTo(t)){let i=$c,a=Kc;e.tangents(i,a),this.setFromAxisAngle(i,Math.PI)}else{let i=e.cross(t);this.x=i.x,this.y=i.y,this.z=i.z,this.w=Math.sqrt(e.length()**2*t.length()**2)+e.dot(t),this.normalize()}return this}mult(e,t=new O1){let i=this.x,a=this.y,r=this.z,s=this.w,o=e.x,c=e.y,l=e.z,u=e.w;return t.x=i*u+s*o+a*l-r*c,t.y=a*u+s*c+r*o-i*l,t.z=r*u+s*l+i*c-a*o,t.w=s*u-i*o-a*c-r*l,t}inverse(e=new O1){let t=this.x,i=this.y,a=this.z,r=this.w;this.conjugate(e);let s=1/(t*t+i*i+a*a+r*r);return e.x*=s,e.y*=s,e.z*=s,e.w*=s,e}conjugate(e=new O1){return e.x=-this.x,e.y=-this.y,e.z=-this.z,e.w=this.w,e}normalize(){let e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return e===0?(this.x=0,this.y=0,this.z=0,this.w=0):(e=1/e,this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}normalizeFast(){let e=(3-(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w))/2;return e===0?(this.x=0,this.y=0,this.z=0,this.w=0):(this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}vmult(e,t=new y){let i=e.x,a=e.y,r=e.z,s=this.x,o=this.y,c=this.z,l=this.w,u=l*i+o*r-c*a,f=l*a+c*i-s*r,h=l*r+s*a-o*i,m=-s*i-o*a-c*r;return t.x=u*l+m*-s+f*-c-h*-o,t.y=f*l+m*-o+h*-s-u*-c,t.z=h*l+m*-c+u*-o-f*-s,t}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}toEuler(e,t="YZX"){let i,a,r,s=this.x,o=this.y,c=this.z,l=this.w;switch(t){case"YZX":let u=s*o+c*l;if(u>.499&&(i=2*Math.atan2(s,l),a=Math.PI/2,r=0),u<-.499&&(i=-2*Math.atan2(s,l),a=-Math.PI/2,r=0),i===void 0){let f=s*s,h=o*o,m=c*c;i=Math.atan2(2*o*l-2*s*c,1-2*h-2*m),a=Math.asin(2*u),r=Math.atan2(2*s*l-2*o*c,1-2*f-2*m)}break;default:throw new Error("Euler order "+t+" not supported yet.")}e.y=i,e.z=a,e.x=r}setFromEuler(e,t,i,a="XYZ"){let r=Math.cos(e/2),s=Math.cos(t/2),o=Math.cos(i/2),c=Math.sin(e/2),l=Math.sin(t/2),u=Math.sin(i/2);return a==="XYZ"?(this.x=c*s*o+r*l*u,this.y=r*l*o-c*s*u,this.z=r*s*u+c*l*o,this.w=r*s*o-c*l*u):a==="YXZ"?(this.x=c*s*o+r*l*u,this.y=r*l*o-c*s*u,this.z=r*s*u-c*l*o,this.w=r*s*o+c*l*u):a==="ZXY"?(this.x=c*s*o-r*l*u,this.y=r*l*o+c*s*u,this.z=r*s*u+c*l*o,this.w=r*s*o-c*l*u):a==="ZYX"?(this.x=c*s*o-r*l*u,this.y=r*l*o+c*s*u,this.z=r*s*u-c*l*o,this.w=r*s*o+c*l*u):a==="YZX"?(this.x=c*s*o+r*l*u,this.y=r*l*o+c*s*u,this.z=r*s*u-c*l*o,this.w=r*s*o-c*l*u):a==="XZY"&&(this.x=c*s*o-r*l*u,this.y=r*l*o-c*s*u,this.z=r*s*u+c*l*o,this.w=r*s*o+c*l*u),this}clone(){return new O1(this.x,this.y,this.z,this.w)}slerp(e,t,i=new O1){let a=this.x,r=this.y,s=this.z,o=this.w,c=e.x,l=e.y,u=e.z,f=e.w,h,m,v,g,x;return m=a*c+r*l+s*u+o*f,m<0&&(m=-m,c=-c,l=-l,u=-u,f=-f),1-m>1e-6?(h=Math.acos(m),v=Math.sin(h),g=Math.sin((1-t)*h)/v,x=Math.sin(t*h)/v):(g=1-t,x=t),i.x=g*a+x*c,i.y=g*r+x*l,i.z=g*s+x*u,i.w=g*o+x*f,i}integrate(e,t,i,a=new O1){let r=e.x*i.x,s=e.y*i.y,o=e.z*i.z,c=this.x,l=this.y,u=this.z,f=this.w,h=t*.5;return a.x+=h*(r*f+s*u-o*l),a.y+=h*(s*f+o*c-r*u),a.z+=h*(o*f+r*l-s*c),a.w+=h*(-r*c-s*l-o*u),a}},$c=new y,Kc=new y,Jc={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256},c1=class{constructor(e={}){this.id=void 0,this.type=void 0,this.boundingSphereRadius=void 0,this.collisionResponse=void 0,this.collisionFilterGroup=void 0,this.collisionFilterMask=void 0,this.material=void 0,this.body=void 0,this.id=c1.idCounter++,this.type=e.type||0,this.boundingSphereRadius=0,this.collisionResponse=e.collisionResponse?e.collisionResponse:!0,this.collisionFilterGroup=e.collisionFilterGroup!==void 0?e.collisionFilterGroup:1,this.collisionFilterMask=e.collisionFilterMask!==void 0?e.collisionFilterMask:-1,this.material=e.material?e.material:null,this.body=null}updateBoundingSphereRadius(){throw"computeBoundingSphereRadius() not implemented for shape type "+this.type}volume(){throw"volume() not implemented for shape type "+this.type}calculateLocalInertia(e,t){throw"calculateLocalInertia() not implemented for shape type "+this.type}calculateWorldAABB(e,t,i,a){throw"calculateWorldAABB() not implemented for shape type "+this.type}};c1.idCounter=0;c1.types=Jc;var N1=class{constructor(e={}){this.position=void 0,this.quaternion=void 0,this.position=new y,this.quaternion=new O1,e.position&&this.position.copy(e.position),e.quaternion&&this.quaternion.copy(e.quaternion)}pointToLocal(e,t){return N1.pointToLocalFrame(this.position,this.quaternion,e,t)}pointToWorld(e,t){return N1.pointToWorldFrame(this.position,this.quaternion,e,t)}vectorToWorldFrame(e,t=new y){return this.quaternion.vmult(e,t),t}static pointToLocalFrame(e,t,i,a=new y){return i.vsub(e,a),t.conjugate(Da),Da.vmult(a,a),a}static pointToWorldFrame(e,t,i,a=new y){return t.vmult(i,a),a.vadd(e,a),a}static vectorToWorldFrame(e,t,i=new y){return e.vmult(t,i),i}static vectorToLocalFrame(e,t,i,a=new y){return t.w*=-1,t.vmult(i,a),t.w*=-1,a}},Da=new O1,Qe=class extends c1{constructor(e={}){let{vertices:t=[],faces:i=[],normals:a=[],axes:r,boundingSphereRadius:s}=e;super({type:c1.types.CONVEXPOLYHEDRON});this.vertices=void 0,this.faces=void 0,this.faceNormals=void 0,this.worldVertices=void 0,this.worldVerticesNeedsUpdate=void 0,this.worldFaceNormals=void 0,this.worldFaceNormalsNeedsUpdate=void 0,this.uniqueAxes=void 0,this.uniqueEdges=void 0,this.vertices=t,this.faces=i,this.faceNormals=a,this.faceNormals.length===0&&this.computeNormals(),s?this.boundingSphereRadius=s:this.updateBoundingSphereRadius(),this.worldVertices=[],this.worldVerticesNeedsUpdate=!0,this.worldFaceNormals=[],this.worldFaceNormalsNeedsUpdate=!0,this.uniqueAxes=r?r.slice():null,this.uniqueEdges=[],this.computeEdges()}computeEdges(){let e=this.faces,t=this.vertices,i=this.uniqueEdges;i.length=0;let a=new y;for(let r=0;r!==e.length;r++){let s=e[r],o=s.length;for(let c=0;c!==o;c++){let l=(c+1)%o;t[s[c]].vsub(t[s[l]],a),a.normalize();let u=!1;for(let f=0;f!==i.length;f++)if(i[f].almostEquals(a)||i[f].almostEquals(a)){u=!0;break}u||i.push(a.clone())}}}computeNormals(){this.faceNormals.length=this.faces.length;for(let e=0;e<this.faces.length;e++){for(let a=0;a<this.faces[e].length;a++)if(!this.vertices[this.faces[e][a]])throw new Error("Vertex "+this.faces[e][a]+" not found!");let t=this.faceNormals[e]||new y;this.getFaceNormal(e,t),t.negate(t),this.faceNormals[e]=t;let i=this.vertices[this.faces[e][0]];if(t.dot(i)<0){console.error(".faceNormals["+e+"] = Vec3("+t.toString()+") looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.");for(let a=0;a<this.faces[e].length;a++)console.warn(".vertices["+this.faces[e][a]+"] = Vec3("+this.vertices[this.faces[e][a]].toString()+")")}}}getFaceNormal(e,t){let i=this.faces[e],a=this.vertices[i[0]],r=this.vertices[i[1]],s=this.vertices[i[2]];Qe.computeNormal(a,r,s,t)}static computeNormal(e,t,i,a){let r=new y,s=new y;t.vsub(e,s),i.vsub(t,r),r.cross(s,a),a.isZero()||a.normalize()}clipAgainstHull(e,t,i,a,r,s,o,c,l){let u=new y,f=-1,h=-Number.MAX_VALUE;for(let v=0;v<i.faces.length;v++){u.copy(i.faceNormals[v]),r.vmult(u,u);let g=u.dot(s);g>h&&(h=g,f=v)}let m=[];for(let v=0;v<i.faces[f].length;v++){let g=i.vertices[i.faces[f][v]],x=new y;x.copy(g),r.vmult(x,x),a.vadd(x,x),m.push(x)}f>=0&&this.clipFaceAgainstHull(s,e,t,m,o,c,l)}findSeparatingAxis(e,t,i,a,r,s,o,c){let l=new y,u=new y,f=new y,h=new y,m=new y,v=new y,g=Number.MAX_VALUE,x=this;if(x.uniqueAxes)for(let p=0;p!==x.uniqueAxes.length;p++){i.vmult(x.uniqueAxes[p],l);let d=x.testSepAxis(l,e,t,i,a,r);if(d===!1)return!1;d<g&&(g=d,s.copy(l))}else{let p=o?o.length:x.faces.length;for(let d=0;d<p;d++){let A=o?o[d]:d;l.copy(x.faceNormals[A]),i.vmult(l,l);let b=x.testSepAxis(l,e,t,i,a,r);if(b===!1)return!1;b<g&&(g=b,s.copy(l))}}if(e.uniqueAxes)for(let p=0;p!==e.uniqueAxes.length;p++){r.vmult(e.uniqueAxes[p],u);let d=x.testSepAxis(u,e,t,i,a,r);if(d===!1)return!1;d<g&&(g=d,s.copy(u))}else{let p=c?c.length:e.faces.length;for(let d=0;d<p;d++){let A=c?c[d]:d;u.copy(e.faceNormals[A]),r.vmult(u,u);let b=x.testSepAxis(u,e,t,i,a,r);if(b===!1)return!1;b<g&&(g=b,s.copy(u))}}for(let p=0;p!==x.uniqueEdges.length;p++){i.vmult(x.uniqueEdges[p],h);for(let d=0;d!==e.uniqueEdges.length;d++)if(r.vmult(e.uniqueEdges[d],m),h.cross(m,v),!v.almostZero()){v.normalize();let A=x.testSepAxis(v,e,t,i,a,r);if(A===!1)return!1;A<g&&(g=A,s.copy(v))}}return a.vsub(t,f),f.dot(s)>0&&s.negate(s),!0}testSepAxis(e,t,i,a,r,s){let o=this;Qe.project(o,e,i,a,I0),Qe.project(t,e,r,s,k0);let c=I0[0],l=I0[1],u=k0[0],f=k0[1];if(c<f||u<l)return!1;let h=c-f,m=u-l;return h<m?h:m}calculateLocalInertia(e,t){let i=new y,a=new y;this.computeLocalAABB(a,i);let r=i.x-a.x,s=i.y-a.y,o=i.z-a.z;t.x=1/12*e*(2*s*2*s+2*o*2*o),t.y=1/12*e*(2*r*2*r+2*o*2*o),t.z=1/12*e*(2*s*2*s+2*r*2*r)}getPlaneConstantOfFace(e){let t=this.faces[e],i=this.faceNormals[e],a=this.vertices[t[0]];return-i.dot(a)}clipFaceAgainstHull(e,t,i,a,r,s,o){let c=new y,l=new y,u=new y,f=new y,h=new y,m=new y,v=new y,g=new y,x=this,p=[],d=a,A=p,b=-1,C=Number.MAX_VALUE;for(let F=0;F<x.faces.length;F++){c.copy(x.faceNormals[F]),i.vmult(c,c);let M=c.dot(e);M<C&&(C=M,b=F)}if(b<0)return;let E=x.faces[b];E.connectedFaces=[];for(let F=0;F<x.faces.length;F++)for(let M=0;M<x.faces[F].length;M++)E.indexOf(x.faces[F][M])!==-1&&F!==b&&E.connectedFaces.indexOf(F)===-1&&E.connectedFaces.push(F);let T=E.length;for(let F=0;F<T;F++){let M=x.vertices[E[F]],D=x.vertices[E[(F+1)%T]];M.vsub(D,l),u.copy(l),i.vmult(u,u),t.vadd(u,u),f.copy(this.faceNormals[b]),i.vmult(f,f),t.vadd(f,f),u.cross(f,h),h.negate(h),m.copy(M),i.vmult(m,m),t.vadd(m,m);let z=E.connectedFaces[F];v.copy(this.faceNormals[z]);let H=this.getPlaneConstantOfFace(z);g.copy(v),i.vmult(g,g);let V=H-g.dot(t);for(this.clipFaceAgainstPlane(d,A,g,V);d.length;)d.shift();for(;A.length;)d.push(A.shift())}v.copy(this.faceNormals[b]);let _=this.getPlaneConstantOfFace(b);g.copy(v),i.vmult(g,g);let P=_-g.dot(t);for(let F=0;F<d.length;F++){let M=g.dot(d[F])+P;if(M<=r&&(console.log("clamped: depth="+M+" to minDist="+r),M=r),M<=s){let D=d[F];if(M<=1e-6){let z={point:D,normal:g,depth:M};o.push(z)}}}}clipFaceAgainstPlane(e,t,i,a){let r,s,o=e.length;if(o<2)return t;let c=e[e.length-1],l=e[0];r=i.dot(c)+a;for(let u=0;u<o;u++){if(l=e[u],s=i.dot(l)+a,r<0)if(s<0){let f=new y;f.copy(l),t.push(f)}else{let f=new y;c.lerp(l,r/(r-s),f),t.push(f)}else if(s<0){let f=new y;c.lerp(l,r/(r-s),f),t.push(f),t.push(l)}c=l,r=s}return t}computeWorldVertices(e,t){for(;this.worldVertices.length<this.vertices.length;)this.worldVertices.push(new y);let i=this.vertices,a=this.worldVertices;for(let r=0;r!==this.vertices.length;r++)t.vmult(i[r],a[r]),e.vadd(a[r],a[r]);this.worldVerticesNeedsUpdate=!1}computeLocalAABB(e,t){let i=this.vertices;e.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),t.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let a=0;a<this.vertices.length;a++){let r=i[a];r.x<e.x?e.x=r.x:r.x>t.x&&(t.x=r.x),r.y<e.y?e.y=r.y:r.y>t.y&&(t.y=r.y),r.z<e.z?e.z=r.z:r.z>t.z&&(t.z=r.z)}}computeWorldFaceNormals(e){let t=this.faceNormals.length;for(;this.worldFaceNormals.length<t;)this.worldFaceNormals.push(new y);let i=this.faceNormals,a=this.worldFaceNormals;for(let r=0;r!==t;r++)e.vmult(i[r],a[r]);this.worldFaceNormalsNeedsUpdate=!1}updateBoundingSphereRadius(){let e=0,t=this.vertices;for(let i=0;i!==t.length;i++){let a=t[i].lengthSquared();a>e&&(e=a)}this.boundingSphereRadius=Math.sqrt(e)}calculateWorldAABB(e,t,i,a){let r=this.vertices,s,o,c,l,u,f,h=new y;for(let m=0;m<r.length;m++){h.copy(r[m]),t.vmult(h,h),e.vadd(h,h);let v=h;(s===void 0||v.x<s)&&(s=v.x),(l===void 0||v.x>l)&&(l=v.x),(o===void 0||v.y<o)&&(o=v.y),(u===void 0||v.y>u)&&(u=v.y),(c===void 0||v.z<c)&&(c=v.z),(f===void 0||v.z>f)&&(f=v.z)}i.set(s,o,c),a.set(l,u,f)}volume(){return 4*Math.PI*this.boundingSphereRadius/3}getAveragePointLocal(e=new y){let t=this.vertices;for(let i=0;i<t.length;i++)e.vadd(t[i],e);return e.scale(1/t.length,e),e}transformAllPoints(e,t){let i=this.vertices.length,a=this.vertices;if(t){for(let r=0;r<i;r++){let s=a[r];t.vmult(s,s)}for(let r=0;r<this.faceNormals.length;r++){let s=this.faceNormals[r];t.vmult(s,s)}}if(e)for(let r=0;r<i;r++){let s=a[r];s.vadd(e,s)}}pointIsInside(e){let t=this.vertices,i=this.faces,a=this.faceNormals,r=new y;this.getAveragePointLocal(r);for(let s=0;s<this.faces.length;s++){let o=a[s],c=t[i[s][0]],l=new y;e.vsub(c,l);let u=o.dot(l),f=new y;r.vsub(c,f);let h=o.dot(f);if(u<0&&h>0||u>0&&h<0)return!1}return-1}static project(e,t,i,a,r){let s=e.vertices.length,o=Qc,c=0,l=0,u=e7,f=e.vertices;u.setZero(),N1.vectorToLocalFrame(i,a,t,o),N1.pointToLocalFrame(i,a,u,u);let h=u.dot(o);l=c=f[0].dot(o);for(let m=1;m<s;m++){let v=f[m].dot(o);v>c&&(c=v),v<l&&(l=v)}if(l-=h,c-=h,l>c){let m=l;l=c,c=m}r[0]=c,r[1]=l}},I0=[],k0=[],Qc=new y,e7=new y,f6=class extends c1{constructor(e){super({type:c1.types.BOX});this.halfExtents=void 0,this.convexPolyhedronRepresentation=void 0,this.halfExtents=e,this.convexPolyhedronRepresentation=null,this.updateConvexPolyhedronRepresentation(),this.updateBoundingSphereRadius()}updateConvexPolyhedronRepresentation(){let e=this.halfExtents.x,t=this.halfExtents.y,i=this.halfExtents.z,a=y,r=[new a(-e,-t,-i),new a(e,-t,-i),new a(e,t,-i),new a(-e,t,-i),new a(-e,-t,i),new a(e,-t,i),new a(e,t,i),new a(-e,t,i)],s=[[3,2,1,0],[4,5,6,7],[5,4,0,1],[2,3,7,6],[0,4,7,3],[1,2,6,5]],o=[new a(0,0,1),new a(0,1,0),new a(1,0,0)],c=new Qe({vertices:r,faces:s,axes:o});this.convexPolyhedronRepresentation=c,c.material=this.material}calculateLocalInertia(e,t=new y){return f6.calculateInertia(this.halfExtents,e,t),t}static calculateInertia(e,t,i){let a=e;i.x=1/12*t*(2*a.y*2*a.y+2*a.z*2*a.z),i.y=1/12*t*(2*a.x*2*a.x+2*a.z*2*a.z),i.z=1/12*t*(2*a.y*2*a.y+2*a.x*2*a.x)}getSideNormals(e,t){let i=e,a=this.halfExtents;if(i[0].set(a.x,0,0),i[1].set(0,a.y,0),i[2].set(0,0,a.z),i[3].set(-a.x,0,0),i[4].set(0,-a.y,0),i[5].set(0,0,-a.z),t!==void 0)for(let r=0;r!==i.length;r++)t.vmult(i[r],i[r]);return i}volume(){return 8*this.halfExtents.x*this.halfExtents.y*this.halfExtents.z}updateBoundingSphereRadius(){this.boundingSphereRadius=this.halfExtents.length()}forEachWorldCorner(e,t,i){let a=this.halfExtents,r=[[a.x,a.y,a.z],[-a.x,a.y,a.z],[-a.x,-a.y,a.z],[-a.x,-a.y,-a.z],[a.x,-a.y,-a.z],[a.x,a.y,-a.z],[-a.x,a.y,-a.z],[a.x,-a.y,a.z]];for(let s=0;s<r.length;s++)e4.set(r[s][0],r[s][1],r[s][2]),t.vmult(e4,e4),e.vadd(e4,e4),i(e4.x,e4.y,e4.z)}calculateWorldAABB(e,t,i,a){let r=this.halfExtents;me[0].set(r.x,r.y,r.z),me[1].set(-r.x,r.y,r.z),me[2].set(-r.x,-r.y,r.z),me[3].set(-r.x,-r.y,-r.z),me[4].set(r.x,-r.y,-r.z),me[5].set(r.x,r.y,-r.z),me[6].set(-r.x,r.y,-r.z),me[7].set(r.x,-r.y,r.z);let s=me[0];t.vmult(s,s),e.vadd(s,s),a.copy(s),i.copy(s);for(let o=1;o<8;o++){let c=me[o];t.vmult(c,c),e.vadd(c,c);let l=c.x,u=c.y,f=c.z;l>a.x&&(a.x=l),u>a.y&&(a.y=u),f>a.z&&(a.z=f),l<i.x&&(i.x=l),u<i.y&&(i.y=u),f<i.z&&(i.z=f)}}},e4=new y,me=[new y,new y,new y,new y,new y,new y,new y,new y],U0={DYNAMIC:1,STATIC:2,KINEMATIC:4},O0={AWAKE:0,SLEEPY:1,SLEEPING:2},i1=class extends P0{constructor(e={}){super();this.id=void 0,this.index=void 0,this.world=void 0,this.preStep=void 0,this.postStep=void 0,this.vlambda=void 0,this.collisionFilterGroup=void 0,this.collisionFilterMask=void 0,this.collisionResponse=void 0,this.position=void 0,this.previousPosition=void 0,this.interpolatedPosition=void 0,this.initPosition=void 0,this.velocity=void 0,this.initVelocity=void 0,this.force=void 0,this.mass=void 0,this.invMass=void 0,this.material=void 0,this.linearDamping=void 0,this.type=void 0,this.allowSleep=void 0,this.sleepState=void 0,this.sleepSpeedLimit=void 0,this.sleepTimeLimit=void 0,this.timeLastSleepy=void 0,this.wakeUpAfterNarrowphase=void 0,this.torque=void 0,this.quaternion=void 0,this.initQuaternion=void 0,this.previousQuaternion=void 0,this.interpolatedQuaternion=void 0,this.angularVelocity=void 0,this.initAngularVelocity=void 0,this.shapes=void 0,this.shapeOffsets=void 0,this.shapeOrientations=void 0,this.inertia=void 0,this.invInertia=void 0,this.invInertiaWorld=void 0,this.invMassSolve=void 0,this.invInertiaSolve=void 0,this.invInertiaWorldSolve=void 0,this.fixedRotation=void 0,this.angularDamping=void 0,this.linearFactor=void 0,this.angularFactor=void 0,this.aabb=void 0,this.aabbNeedsUpdate=void 0,this.boundingRadius=void 0,this.wlambda=void 0,this.isTrigger=void 0,this.id=i1.idCounter++,this.index=-1,this.world=null,this.preStep=null,this.postStep=null,this.vlambda=new y,this.collisionFilterGroup=typeof e.collisionFilterGroup=="number"?e.collisionFilterGroup:1,this.collisionFilterMask=typeof e.collisionFilterMask=="number"?e.collisionFilterMask:-1,this.collisionResponse=typeof e.collisionResponse=="boolean"?e.collisionResponse:!0,this.position=new y,this.previousPosition=new y,this.interpolatedPosition=new y,this.initPosition=new y,e.position&&(this.position.copy(e.position),this.previousPosition.copy(e.position),this.interpolatedPosition.copy(e.position),this.initPosition.copy(e.position)),this.velocity=new y,e.velocity&&this.velocity.copy(e.velocity),this.initVelocity=new y,this.force=new y;let t=typeof e.mass=="number"?e.mass:0;this.mass=t,this.invMass=t>0?1/t:0,this.material=e.material||null,this.linearDamping=typeof e.linearDamping=="number"?e.linearDamping:.01,this.type=t<=0?i1.STATIC:i1.DYNAMIC,typeof e.type==typeof i1.STATIC&&(this.type=e.type),this.allowSleep=typeof e.allowSleep!="undefined"?e.allowSleep:!0,this.sleepState=i1.AWAKE,this.sleepSpeedLimit=typeof e.sleepSpeedLimit!="undefined"?e.sleepSpeedLimit:.1,this.sleepTimeLimit=typeof e.sleepTimeLimit!="undefined"?e.sleepTimeLimit:1,this.timeLastSleepy=0,this.wakeUpAfterNarrowphase=!1,this.torque=new y,this.quaternion=new O1,this.initQuaternion=new O1,this.previousQuaternion=new O1,this.interpolatedQuaternion=new O1,e.quaternion&&(this.quaternion.copy(e.quaternion),this.initQuaternion.copy(e.quaternion),this.previousQuaternion.copy(e.quaternion),this.interpolatedQuaternion.copy(e.quaternion)),this.angularVelocity=new y,e.angularVelocity&&this.angularVelocity.copy(e.angularVelocity),this.initAngularVelocity=new y,this.shapes=[],this.shapeOffsets=[],this.shapeOrientations=[],this.inertia=new y,this.invInertia=new y,this.invInertiaWorld=new _2,this.invMassSolve=0,this.invInertiaSolve=new y,this.invInertiaWorldSolve=new _2,this.fixedRotation=typeof e.fixedRotation!="undefined"?e.fixedRotation:!1,this.angularDamping=typeof e.angularDamping!="undefined"?e.angularDamping:.01,this.linearFactor=new y(1,1,1),e.linearFactor&&this.linearFactor.copy(e.linearFactor),this.angularFactor=new y(1,1,1),e.angularFactor&&this.angularFactor.copy(e.angularFactor),this.aabb=new E2,this.aabbNeedsUpdate=!0,this.boundingRadius=0,this.wlambda=new y,this.isTrigger=Boolean(e.isTrigger),e.shape&&this.addShape(e.shape),this.updateMassProperties()}wakeUp(){let e=this.sleepState;this.sleepState=i1.AWAKE,this.wakeUpAfterNarrowphase=!1,e===i1.SLEEPING&&this.dispatchEvent(i1.wakeupEvent)}sleep(){this.sleepState=i1.SLEEPING,this.velocity.set(0,0,0),this.angularVelocity.set(0,0,0),this.wakeUpAfterNarrowphase=!1}sleepTick(e){if(this.allowSleep){let t=this.sleepState,i=this.velocity.lengthSquared()+this.angularVelocity.lengthSquared(),a=this.sleepSpeedLimit**2;t===i1.AWAKE&&i<a?(this.sleepState=i1.SLEEPY,this.timeLastSleepy=e,this.dispatchEvent(i1.sleepyEvent)):t===i1.SLEEPY&&i>a?this.wakeUp():t===i1.SLEEPY&&e-this.timeLastSleepy>this.sleepTimeLimit&&(this.sleep(),this.dispatchEvent(i1.sleepEvent))}}updateSolveMassProperties(){this.sleepState===i1.SLEEPING||this.type===i1.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve.setZero(),this.invInertiaWorldSolve.setZero()):(this.invMassSolve=this.invMass,this.invInertiaSolve.copy(this.invInertia),this.invInertiaWorldSolve.copy(this.invInertiaWorld))}pointToLocalFrame(e,t=new y){return e.vsub(this.position,t),this.quaternion.conjugate().vmult(t,t),t}vectorToLocalFrame(e,t=new y){return this.quaternion.conjugate().vmult(e,t),t}pointToWorldFrame(e,t=new y){return this.quaternion.vmult(e,t),t.vadd(this.position,t),t}vectorToWorldFrame(e,t=new y){return this.quaternion.vmult(e,t),t}addShape(e,t,i){let a=new y,r=new O1;return t&&a.copy(t),i&&r.copy(i),this.shapes.push(e),this.shapeOffsets.push(a),this.shapeOrientations.push(r),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,e.body=this,this}removeShape(e){let t=this.shapes.indexOf(e);return t===-1?(console.warn("Shape does not belong to the body"),this):(this.shapes.splice(t,1),this.shapeOffsets.splice(t,1),this.shapeOrientations.splice(t,1),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,e.body=null,this)}updateBoundingRadius(){let e=this.shapes,t=this.shapeOffsets,i=e.length,a=0;for(let r=0;r!==i;r++){let s=e[r];s.updateBoundingSphereRadius();let o=t[r].length(),c=s.boundingSphereRadius;o+c>a&&(a=o+c)}this.boundingRadius=a}updateAABB(){let e=this.shapes,t=this.shapeOffsets,i=this.shapeOrientations,a=e.length,r=t7,s=i7,o=this.quaternion,c=this.aabb,l=a7;for(let u=0;u!==a;u++){let f=e[u];o.vmult(t[u],r),r.vadd(this.position,r),o.mult(i[u],s),f.calculateWorldAABB(r,s,l.lowerBound,l.upperBound),u===0?c.copy(l):c.extend(l)}this.aabbNeedsUpdate=!1}updateInertiaWorld(e){let t=this.invInertia;if(!(t.x===t.y&&t.y===t.z&&!e)){let i=r7,a=n7;i.setRotationFromQuaternion(this.quaternion),i.transpose(a),i.scale(t,i),i.mmult(a,this.invInertiaWorld)}}applyForce(e,t=new y){if(this.type!==i1.DYNAMIC)return;this.sleepState===i1.SLEEPING&&this.wakeUp();let i=s7;t.cross(e,i),this.force.vadd(e,this.force),this.torque.vadd(i,this.torque)}applyLocalForce(e,t=new y){if(this.type!==i1.DYNAMIC)return;let i=o7,a=c7;this.vectorToWorldFrame(e,i),this.vectorToWorldFrame(t,a),this.applyForce(i,a)}applyTorque(e){this.type===i1.DYNAMIC&&(this.sleepState===i1.SLEEPING&&this.wakeUp(),this.torque.vadd(e,this.torque))}applyImpulse(e,t=new y){if(this.type!==i1.DYNAMIC)return;this.sleepState===i1.SLEEPING&&this.wakeUp();let i=t,a=l7;a.copy(e),a.scale(this.invMass,a),this.velocity.vadd(a,this.velocity);let r=u7;i.cross(e,r),this.invInertiaWorld.vmult(r,r),this.angularVelocity.vadd(r,this.angularVelocity)}applyLocalImpulse(e,t=new y){if(this.type!==i1.DYNAMIC)return;let i=h7,a=f7;this.vectorToWorldFrame(e,i),this.vectorToWorldFrame(t,a),this.applyImpulse(i,a)}updateMassProperties(){let e=d7;this.invMass=this.mass>0?1/this.mass:0;let t=this.inertia,i=this.fixedRotation;this.updateAABB(),e.set((this.aabb.upperBound.x-this.aabb.lowerBound.x)/2,(this.aabb.upperBound.y-this.aabb.lowerBound.y)/2,(this.aabb.upperBound.z-this.aabb.lowerBound.z)/2),f6.calculateInertia(e,this.mass,t),this.invInertia.set(t.x>0&&!i?1/t.x:0,t.y>0&&!i?1/t.y:0,t.z>0&&!i?1/t.z:0),this.updateInertiaWorld(!0)}getVelocityAtWorldPoint(e,t){let i=new y;return e.vsub(this.position,i),this.angularVelocity.cross(i,t),this.velocity.vadd(t,t),t}integrate(e,t,i){if(this.previousPosition.copy(this.position),this.previousQuaternion.copy(this.quaternion),!(this.type===i1.DYNAMIC||this.type===i1.KINEMATIC)||this.sleepState===i1.SLEEPING)return;let a=this.velocity,r=this.angularVelocity,s=this.position,o=this.force,c=this.torque,l=this.quaternion,u=this.invMass,f=this.invInertiaWorld,h=this.linearFactor,m=u*e;a.x+=o.x*m*h.x,a.y+=o.y*m*h.y,a.z+=o.z*m*h.z;let v=f.elements,g=this.angularFactor,x=c.x*g.x,p=c.y*g.y,d=c.z*g.z;r.x+=e*(v[0]*x+v[1]*p+v[2]*d),r.y+=e*(v[3]*x+v[4]*p+v[5]*d),r.z+=e*(v[6]*x+v[7]*p+v[8]*d),s.x+=a.x*e,s.y+=a.y*e,s.z+=a.z*e,l.integrate(this.angularVelocity,e,this.angularFactor,l),t&&(i?l.normalizeFast():l.normalize()),this.aabbNeedsUpdate=!0,this.updateInertiaWorld()}};i1.idCounter=0;i1.COLLIDE_EVENT_NAME="collide";i1.DYNAMIC=U0.DYNAMIC;i1.STATIC=U0.STATIC;i1.KINEMATIC=U0.KINEMATIC;i1.AWAKE=O0.AWAKE;i1.SLEEPY=O0.SLEEPY;i1.SLEEPING=O0.SLEEPING;i1.wakeupEvent={type:"wakeup"};i1.sleepyEvent={type:"sleepy"};i1.sleepEvent={type:"sleep"};var t7=new y,i7=new O1,a7=new E2,r7=new _2,n7=new _2,s7=new y,o7=new y,c7=new y,l7=new y,u7=new y,h7=new y,f7=new y,d7=new y,Ta=class{constructor(){this.world=void 0,this.useBoundingBoxes=void 0,this.dirty=void 0,this.world=null,this.useBoundingBoxes=!1,this.dirty=!0}collisionPairs(e,t,i){throw new Error("collisionPairs not implemented for this BroadPhase class!")}needBroadphaseCollision(e,t){return!((e.collisionFilterGroup&t.collisionFilterMask)==0||(t.collisionFilterGroup&e.collisionFilterMask)==0||((e.type&i1.STATIC)!=0||e.sleepState===i1.SLEEPING)&&((t.type&i1.STATIC)!=0||t.sleepState===i1.SLEEPING))}intersectionTest(e,t,i,a){this.useBoundingBoxes?this.doBoundingBoxBroadphase(e,t,i,a):this.doBoundingSphereBroadphase(e,t,i,a)}doBoundingSphereBroadphase(e,t,i,a){let r=p7;t.position.vsub(e.position,r);let s=(e.boundingRadius+t.boundingRadius)**2;r.lengthSquared()<s&&(i.push(e),a.push(t))}doBoundingBoxBroadphase(e,t,i,a){e.aabbNeedsUpdate&&e.updateAABB(),t.aabbNeedsUpdate&&t.updateAABB(),e.aabb.overlaps(t.aabb)&&(i.push(e),a.push(t))}makePairsUnique(e,t){let i=m7,a=v7,r=g7,s=e.length;for(let o=0;o!==s;o++)a[o]=e[o],r[o]=t[o];e.length=0,t.length=0;for(let o=0;o!==s;o++){let c=a[o].id,l=r[o].id,u=c<l?c+","+l:l+","+c;i[u]=o,i.keys.push(u)}for(let o=0;o!==i.keys.length;o++){let c=i.keys.pop(),l=i[c];e.push(a[l]),t.push(r[l]),delete i[c]}}setWorld(e){}static boundingSphereCheck(e,t){let i=new y;e.position.vsub(t.position,i);let a=e.shapes[0],r=t.shapes[0];return Math.pow(a.boundingSphereRadius+r.boundingSphereRadius,2)>i.lengthSquared()}aabbQuery(e,t,i){return console.warn(".aabbQuery is not implemented in this Broadphase subclass."),[]}},p7=new y,m7={keys:[]},v7=[],g7=[];var Mf=new y,d6=class extends Ta{constructor(){super()}collisionPairs(e,t,i){let a=e.bodies,r=a.length,s,o;for(let c=0;c!==r;c++)for(let l=0;l!==c;l++)s=a[c],o=a[l],!!this.needBroadphaseCollision(s,o)&&this.intersectionTest(s,o,t,i)}aabbQuery(e,t,i=[]){for(let a=0;a<e.bodies.length;a++){let r=e.bodies[a];r.aabbNeedsUpdate&&r.updateAABB(),r.aabb.overlaps(t)&&i.push(r)}return i}},p6=class{constructor(){this.rayFromWorld=void 0,this.rayToWorld=void 0,this.hitNormalWorld=void 0,this.hitPointWorld=void 0,this.hasHit=void 0,this.shape=void 0,this.body=void 0,this.hitFaceIndex=void 0,this.distance=void 0,this.shouldStop=void 0,this.rayFromWorld=new y,this.rayToWorld=new y,this.hitNormalWorld=new y,this.hitPointWorld=new y,this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}reset(){this.rayFromWorld.setZero(),this.rayToWorld.setZero(),this.hitNormalWorld.setZero(),this.hitPointWorld.setZero(),this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}abort(){this.shouldStop=!0}set(e,t,i,a,r,s,o){this.rayFromWorld.copy(e),this.rayToWorld.copy(t),this.hitNormalWorld.copy(i),this.hitPointWorld.copy(a),this.shape=r,this.body=s,this.distance=o}},Ha,Va,Na,Ra,Fa,Ba,Pa,G0={CLOSEST:1,ANY:2,ALL:4};Ha=c1.types.SPHERE;Va=c1.types.PLANE;Na=c1.types.BOX;Ra=c1.types.CYLINDER;Fa=c1.types.CONVEXPOLYHEDRON;Ba=c1.types.HEIGHTFIELD;Pa=c1.types.TRIMESH;var J1=class{get[Ha](){return this._intersectSphere}get[Va](){return this._intersectPlane}get[Na](){return this._intersectBox}get[Ra](){return this._intersectConvex}get[Fa](){return this._intersectConvex}get[Ba](){return this._intersectHeightfield}get[Pa](){return this._intersectTrimesh}constructor(e=new y,t=new y){this.from=void 0,this.to=void 0,this.direction=void 0,this.precision=void 0,this.checkCollisionResponse=void 0,this.skipBackfaces=void 0,this.collisionFilterMask=void 0,this.collisionFilterGroup=void 0,this.mode=void 0,this.result=void 0,this.hasHit=void 0,this.callback=void 0,this.from=e.clone(),this.to=t.clone(),this.direction=new y,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=J1.ANY,this.result=new p6,this.hasHit=!1,this.callback=i=>{}}intersectWorld(e,t){return this.mode=t.mode||J1.ANY,this.result=t.result||new p6,this.skipBackfaces=!!t.skipBackfaces,this.collisionFilterMask=typeof t.collisionFilterMask!="undefined"?t.collisionFilterMask:-1,this.collisionFilterGroup=typeof t.collisionFilterGroup!="undefined"?t.collisionFilterGroup:-1,this.checkCollisionResponse=typeof t.checkCollisionResponse!="undefined"?t.checkCollisionResponse:!0,t.from&&this.from.copy(t.from),t.to&&this.to.copy(t.to),this.callback=t.callback||(()=>{}),this.hasHit=!1,this.result.reset(),this.updateDirection(),this.getAABB(Ia),q0.length=0,e.broadphase.aabbQuery(e,Ia,q0),this.intersectBodies(q0),this.hasHit}intersectBody(e,t){t&&(this.result=t,this.updateDirection());let i=this.checkCollisionResponse;if(i&&!e.collisionResponse||(this.collisionFilterGroup&e.collisionFilterMask)==0||(e.collisionFilterGroup&this.collisionFilterMask)==0)return;let a=x7,r=M7;for(let s=0,o=e.shapes.length;s<o;s++){let c=e.shapes[s];if(!(i&&!c.collisionResponse)&&(e.quaternion.mult(e.shapeOrientations[s],r),e.quaternion.vmult(e.shapeOffsets[s],a),a.vadd(e.position,a),this.intersectShape(c,r,a,e),this.result.shouldStop))break}}intersectBodies(e,t){t&&(this.result=t,this.updateDirection());for(let i=0,a=e.length;!this.result.shouldStop&&i<a;i++)this.intersectBody(e[i])}updateDirection(){this.to.vsub(this.from,this.direction),this.direction.normalize()}intersectShape(e,t,i,a){let r=this.from;if(V7(r,this.direction,i)>e.boundingSphereRadius)return;let o=this[e.type];o&&o.call(this,e,t,i,a,e)}_intersectBox(e,t,i,a,r){return this._intersectConvex(e.convexPolyhedronRepresentation,t,i,a,r)}_intersectPlane(e,t,i,a,r){let s=this.from,o=this.to,c=this.direction,l=new y(0,0,1);t.vmult(l,l);let u=new y;s.vsub(i,u);let f=u.dot(l);o.vsub(i,u);let h=u.dot(l);if(f*h>0||s.distanceTo(o)<f)return;let m=l.dot(c);if(Math.abs(m)<this.precision)return;let v=new y,g=new y,x=new y;s.vsub(i,v);let p=-l.dot(v)/m;c.scale(p,g),s.vadd(g,x),this.reportIntersection(l,x,r,a,-1)}getAABB(e){let{lowerBound:t,upperBound:i}=e,a=this.to,r=this.from;t.x=Math.min(a.x,r.x),t.y=Math.min(a.y,r.y),t.z=Math.min(a.z,r.z),i.x=Math.max(a.x,r.x),i.y=Math.max(a.y,r.y),i.z=Math.max(a.z,r.z)}_intersectHeightfield(e,t,i,a,r){e.data,e.elementSize;let s=b7;s.from.copy(this.from),s.to.copy(this.to),N1.pointToLocalFrame(i,t,s.from,s.from),N1.pointToLocalFrame(i,t,s.to,s.to),s.updateDirection();let o=y7,c,l,u,f;c=l=0,u=f=e.data.length-1;let h=new E2;s.getAABB(h),e.getIndexOfPosition(h.lowerBound.x,h.lowerBound.y,o,!0),c=Math.max(c,o[0]),l=Math.max(l,o[1]),e.getIndexOfPosition(h.upperBound.x,h.upperBound.y,o,!0),u=Math.min(u,o[0]+1),f=Math.min(f,o[1]+1);for(let m=c;m<u;m++)for(let v=l;v<f;v++){if(this.result.shouldStop)return;if(e.getAabbAtIndex(m,v,h),!!h.overlapsRay(s)){if(e.getConvexTrianglePillar(m,v,!1),N1.pointToWorldFrame(i,t,e.pillarOffset,m6),this._intersectConvex(e.pillarConvex,t,m6,a,r,ka),this.result.shouldStop)return;e.getConvexTrianglePillar(m,v,!0),N1.pointToWorldFrame(i,t,e.pillarOffset,m6),this._intersectConvex(e.pillarConvex,t,m6,a,r,ka)}}}_intersectSphere(e,t,i,a,r){let s=this.from,o=this.to,c=e.radius,l=(o.x-s.x)**2+(o.y-s.y)**2+(o.z-s.z)**2,u=2*((o.x-s.x)*(s.x-i.x)+(o.y-s.y)*(s.y-i.y)+(o.z-s.z)*(s.z-i.z)),f=(s.x-i.x)**2+(s.y-i.y)**2+(s.z-i.z)**2-c**2,h=u**2-4*l*f,m=C7,v=z7;if(!(h<0))if(h===0)s.lerp(o,h,m),m.vsub(i,v),v.normalize(),this.reportIntersection(v,m,r,a,-1);else{let g=(-u-Math.sqrt(h))/(2*l),x=(-u+Math.sqrt(h))/(2*l);if(g>=0&&g<=1&&(s.lerp(o,g,m),m.vsub(i,v),v.normalize(),this.reportIntersection(v,m,r,a,-1)),this.result.shouldStop)return;x>=0&&x<=1&&(s.lerp(o,x,m),m.vsub(i,v),v.normalize(),this.reportIntersection(v,m,r,a,-1))}}_intersectConvex(e,t,i,a,r,s){let o=A7,c=Ua,l=s&&s.faceList||null,u=e.faces,f=e.vertices,h=e.faceNormals,m=this.direction,v=this.from,g=this.to,x=v.distanceTo(g),p=l?l.length:u.length,d=this.result;for(let A=0;!d.shouldStop&&A<p;A++){let b=l?l[A]:A,C=u[b],E=h[b],T=t,_=i;c.copy(f[C[0]]),T.vmult(c,c),c.vadd(_,c),c.vsub(v,c),T.vmult(E,o);let P=m.dot(o);if(Math.abs(P)<this.precision)continue;let F=o.dot(c)/P;if(!(F<0)){m.scale(F,L2),L2.vadd(v,L2),$2.copy(f[C[0]]),T.vmult($2,$2),_.vadd($2,$2);for(let M=1;!d.shouldStop&&M<C.length-1;M++){ve.copy(f[C[M]]),ge.copy(f[C[M+1]]),T.vmult(ve,ve),T.vmult(ge,ge),_.vadd(ve,ve),_.vadd(ge,ge);let D=L2.distanceTo(v);!(J1.pointInTriangle(L2,$2,ve,ge)||J1.pointInTriangle(L2,ve,$2,ge))||D>x||this.reportIntersection(o,L2,r,a,b)}}}}_intersectTrimesh(e,t,i,a,r,s){let o=w7,c=T7,l=H7,u=Ua,f=S7,h=_7,m=E7,v=D7,g=L7,x=e.indices;e.vertices;let p=this.from,d=this.to,A=this.direction;l.position.copy(i),l.quaternion.copy(t),N1.vectorToLocalFrame(i,t,A,f),N1.pointToLocalFrame(i,t,p,h),N1.pointToLocalFrame(i,t,d,m),m.x*=e.scale.x,m.y*=e.scale.y,m.z*=e.scale.z,h.x*=e.scale.x,h.y*=e.scale.y,h.z*=e.scale.z,m.vsub(h,f),f.normalize();let b=h.distanceSquared(m);e.tree.rayQuery(this,l,c);for(let C=0,E=c.length;!this.result.shouldStop&&C!==E;C++){let T=c[C];e.getNormal(T,o),e.getVertex(x[T*3],$2),$2.vsub(h,u);let _=f.dot(o),P=o.dot(u)/_;if(P<0)continue;f.scale(P,L2),L2.vadd(h,L2),e.getVertex(x[T*3+1],ve),e.getVertex(x[T*3+2],ge);let F=L2.distanceSquared(h);!(J1.pointInTriangle(L2,ve,$2,ge)||J1.pointInTriangle(L2,$2,ve,ge))||F>b||(N1.vectorToWorldFrame(t,o,g),N1.pointToWorldFrame(i,t,L2,v),this.reportIntersection(g,v,r,a,T))}c.length=0}reportIntersection(e,t,i,a,r){let s=this.from,o=this.to,c=s.distanceTo(t),l=this.result;if(!(this.skipBackfaces&&e.dot(this.direction)>0))switch(l.hitFaceIndex=typeof r!="undefined"?r:-1,this.mode){case J1.ALL:this.hasHit=!0,l.set(s,o,e,t,i,a,c),l.hasHit=!0,this.callback(l);break;case J1.CLOSEST:(c<l.distance||!l.hasHit)&&(this.hasHit=!0,l.hasHit=!0,l.set(s,o,e,t,i,a,c));break;case J1.ANY:this.hasHit=!0,l.hasHit=!0,l.set(s,o,e,t,i,a,c),l.shouldStop=!0;break}}static pointInTriangle(e,t,i,a){a.vsub(t,b4),i.vsub(t,zt),e.vsub(t,W0);let r=b4.dot(b4),s=b4.dot(zt),o=b4.dot(W0),c=zt.dot(zt),l=zt.dot(W0),u,f;return(u=c*o-s*l)>=0&&(f=r*l-s*o)>=0&&u+f<r*c-s*s}};J1.CLOSEST=G0.CLOSEST;J1.ANY=G0.ANY;J1.ALL=G0.ALL;var Ia=new E2,q0=[],zt=new y,W0=new y,x7=new y,M7=new O1,L2=new y,$2=new y,ve=new y,ge=new y,ka={faceList:[0]},m6=new y,b7=new J1,y7=[],C7=new y,z7=new y,A7=new y,Ua=new y,w7=new y,S7=new y,_7=new y,E7=new y,L7=new y,D7=new y;new E2;var T7=[],H7=new N1,b4=new y,v6=new y;function V7(n,e,t){t.vsub(n,b4);let i=b4.dot(e);return e.scale(i,v6),v6.vadd(n,v6),t.distanceTo(v6)}var j0=class{static defaults(e={},t){for(let i in t)i in e||(e[i]=t[i]);return e}},g6=class{constructor(e,t,i={}){this.equations=void 0,this.bodyA=void 0,this.bodyB=void 0,this.id=void 0,this.collideConnected=void 0,i=j0.defaults(i,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=e,this.bodyB=t,this.id=g6.idCounter++,this.collideConnected=i.collideConnected,i.wakeUpBodies&&(e&&e.wakeUp(),t&&t.wakeUp())}update(){throw new Error("method update() not implmemented in this Constraint subclass!")}enable(){let e=this.equations;for(let t=0;t<e.length;t++)e[t].enabled=!0}disable(){let e=this.equations;for(let t=0;t<e.length;t++)e[t].enabled=!1}};g6.idCounter=0;var X0=class{constructor(){this.spatial=void 0,this.rotational=void 0,this.spatial=new y,this.rotational=new y}multiplyElement(e){return e.spatial.dot(this.spatial)+e.rotational.dot(this.rotational)}multiplyVectors(e,t){return e.dot(this.spatial)+t.dot(this.rotational)}},k4=class{constructor(e,t,i=-1e6,a=1e6){this.id=void 0,this.minForce=void 0,this.maxForce=void 0,this.bi=void 0,this.bj=void 0,this.si=void 0,this.sj=void 0,this.a=void 0,this.b=void 0,this.eps=void 0,this.jacobianElementA=void 0,this.jacobianElementB=void 0,this.enabled=void 0,this.multiplier=void 0,this.id=k4.idCounter++,this.minForce=i,this.maxForce=a,this.bi=e,this.bj=t,this.a=0,this.b=0,this.eps=0,this.jacobianElementA=new X0,this.jacobianElementB=new X0,this.enabled=!0,this.multiplier=0,this.setSpookParams(1e7,4,1/60)}setSpookParams(e,t,i){let a=t,r=e,s=i;this.a=4/(s*(1+4*a)),this.b=4*a/(1+4*a),this.eps=4/(s*s*r*(1+4*a))}computeB(e,t,i){let a=this.computeGW(),r=this.computeGq(),s=this.computeGiMf();return-r*e-a*t-s*i}computeGq(){let e=this.jacobianElementA,t=this.jacobianElementB,i=this.bi,a=this.bj,r=i.position,s=a.position;return e.spatial.dot(r)+t.spatial.dot(s)}computeGW(){let e=this.jacobianElementA,t=this.jacobianElementB,i=this.bi,a=this.bj,r=i.velocity,s=a.velocity,o=i.angularVelocity,c=a.angularVelocity;return e.multiplyVectors(r,o)+t.multiplyVectors(s,c)}computeGWlambda(){let e=this.jacobianElementA,t=this.jacobianElementB,i=this.bi,a=this.bj,r=i.vlambda,s=a.vlambda,o=i.wlambda,c=a.wlambda;return e.multiplyVectors(r,o)+t.multiplyVectors(s,c)}computeGiMf(){let e=this.jacobianElementA,t=this.jacobianElementB,i=this.bi,a=this.bj,r=i.force,s=i.torque,o=a.force,c=a.torque,l=i.invMassSolve,u=a.invMassSolve;return r.scale(l,Oa),o.scale(u,Ga),i.invInertiaWorldSolve.vmult(s,qa),a.invInertiaWorldSolve.vmult(c,Wa),e.multiplyVectors(Oa,qa)+t.multiplyVectors(Ga,Wa)}computeGiMGt(){let e=this.jacobianElementA,t=this.jacobianElementB,i=this.bi,a=this.bj,r=i.invMassSolve,s=a.invMassSolve,o=i.invInertiaWorldSolve,c=a.invInertiaWorldSolve,l=r+s;return o.vmult(e.rotational,x6),l+=x6.dot(e.rotational),c.vmult(t.rotational,x6),l+=x6.dot(t.rotational),l}addToWlambda(e){let t=this.jacobianElementA,i=this.jacobianElementB,a=this.bi,r=this.bj,s=N7;a.vlambda.addScaledVector(a.invMassSolve*e,t.spatial,a.vlambda),r.vlambda.addScaledVector(r.invMassSolve*e,i.spatial,r.vlambda),a.invInertiaWorldSolve.vmult(t.rotational,s),a.wlambda.addScaledVector(e,s,a.wlambda),r.invInertiaWorldSolve.vmult(i.rotational,s),r.wlambda.addScaledVector(e,s,r.wlambda)}computeC(){return this.computeGiMGt()+this.eps}};k4.idCounter=0;var Oa=new y,Ga=new y,qa=new y,Wa=new y,x6=new y,N7=new y,ja=class extends k4{constructor(e,t,i=1e6){super(e,t,0,i);this.restitution=void 0,this.ri=void 0,this.rj=void 0,this.ni=void 0,this.restitution=0,this.ri=new y,this.rj=new y,this.ni=new y}computeB(e){let t=this.a,i=this.b,a=this.bi,r=this.bj,s=this.ri,o=this.rj,c=R7,l=F7,u=a.velocity,f=a.angularVelocity;a.force,a.torque;let h=r.velocity,m=r.angularVelocity;r.force,r.torque;let v=B7,g=this.jacobianElementA,x=this.jacobianElementB,p=this.ni;s.cross(p,c),o.cross(p,l),p.negate(g.spatial),c.negate(g.rotational),x.spatial.copy(p),x.rotational.copy(l),v.copy(r.position),v.vadd(o,v),v.vsub(a.position,v),v.vsub(s,v);let d=p.dot(v),A=this.restitution+1,b=A*h.dot(p)-A*u.dot(p)+m.dot(l)-f.dot(c),C=this.computeGiMf();return-d*t-b*i-e*C}getImpactVelocityAlongNormal(){let e=P7,t=I7,i=k7,a=U7,r=O7;return this.bi.position.vadd(this.ri,i),this.bj.position.vadd(this.rj,a),this.bi.getVelocityAtWorldPoint(i,e),this.bj.getVelocityAtWorldPoint(a,t),e.vsub(t,r),this.ni.dot(r)}},R7=new y,F7=new y,B7=new y,P7=new y,I7=new y,k7=new y,U7=new y,O7=new y;var bf=new y,yf=new y;var Cf=new y,zf=new y;var Af=new y,wf=new y,Z0=class extends k4{constructor(e,t,i){super(e,t,-i,i);this.ri=void 0,this.rj=void 0,this.t=void 0,this.ri=new y,this.rj=new y,this.t=new y}computeB(e){this.a;let t=this.b;this.bi,this.bj;let i=this.ri,a=this.rj,r=G7,s=q7,o=this.t;i.cross(o,r),a.cross(o,s);let c=this.jacobianElementA,l=this.jacobianElementB;o.negate(c.spatial),r.negate(c.rotational),l.spatial.copy(o),l.rotational.copy(s);let u=this.computeGW(),f=this.computeGiMf();return-u*t-e*f}},G7=new y,q7=new y,He=class{constructor(e,t,i){this.id=void 0,this.materials=void 0,this.friction=void 0,this.restitution=void 0,this.contactEquationStiffness=void 0,this.contactEquationRelaxation=void 0,this.frictionEquationStiffness=void 0,this.frictionEquationRelaxation=void 0,i=j0.defaults(i,{friction:.3,restitution:.3,contactEquationStiffness:1e7,contactEquationRelaxation:3,frictionEquationStiffness:1e7,frictionEquationRelaxation:3}),this.id=He.idCounter++,this.materials=[e,t],this.friction=i.friction,this.restitution=i.restitution,this.contactEquationStiffness=i.contactEquationStiffness,this.contactEquationRelaxation=i.contactEquationRelaxation,this.frictionEquationStiffness=i.frictionEquationStiffness,this.frictionEquationRelaxation=i.frictionEquationRelaxation}};He.idCounter=0;var Ve=class{constructor(e={}){this.name=void 0,this.id=void 0,this.friction=void 0,this.restitution=void 0;let t="";typeof e=="string"&&(t=e,e={}),this.name=t,this.id=Ve.idCounter++,this.friction=typeof e.friction!="undefined"?e.friction:-1,this.restitution=typeof e.restitution!="undefined"?e.restitution:-1}};Ve.idCounter=0;var Sf=new y,_f=new y,Ef=new y,Lf=new y,Df=new y,Tf=new y,Hf=new y,Vf=new y,Nf=new y,Rf=new y,Ff=new y;var Bf=new y,Pf=new y;var If=new y,kf=new y,Uf=new y;new J1;var Of=new y,Gf=new y,qf=[new y(1,0,0),new y(0,1,0),new y(0,0,1)],Wf=new y;var jf=new y,Xf=new y,Zf=new y;var Yf=new y,$f=new y,Kf=new y,Jf=new y;var Qf=new y,ed=new y,td=new y;var id=new y,ad=new y;var rd=new y,nd=new y,sd=new y,od=new y,cd=new y,ld=new y,ud=new y;var t4=class extends c1{constructor(){super({type:c1.types.PLANE});this.worldNormal=void 0,this.worldNormalNeedsUpdate=void 0,this.boundingSphereRadius=void 0,this.worldNormal=new y,this.worldNormalNeedsUpdate=!0,this.boundingSphereRadius=Number.MAX_VALUE}computeWorldNormal(e){let t=this.worldNormal;t.set(0,0,1),e.vmult(t,t),this.worldNormalNeedsUpdate=!1}calculateLocalInertia(e,t=new y){return t}volume(){return Number.MAX_VALUE}calculateWorldAABB(e,t,i,a){Ne.set(0,0,1),t.vmult(Ne,Ne);let r=Number.MAX_VALUE;i.set(-r,-r,-r),a.set(r,r,r),Ne.x===1?a.x=e.x:Ne.x===-1&&(i.x=e.x),Ne.y===1?a.y=e.y:Ne.y===-1&&(i.y=e.y),Ne.z===1?a.z=e.z:Ne.z===-1&&(i.z=e.z)}updateBoundingSphereRadius(){this.boundingSphereRadius=Number.MAX_VALUE}},Ne=new y;var hd=new y,fd=new y,dd=new y,pd=new y,md=new y,vd=new y,gd=new y,xd=new y,Md=new y;var bd=new y,yd=new E2;var Cd=new y,zd=new E2,Ad=new y,wd=new y,Sd=new y,_d=new y,Ed=new y,Ld=new y,Dd=new y,Td=new E2,Hd=new y,Vd=new N1,Nd=new E2,Xa=class{constructor(){this.equations=void 0,this.equations=[]}solve(e,t){return 0}addEquation(e){e.enabled&&!e.bi.isTrigger&&!e.bj.isTrigger&&this.equations.push(e)}removeEquation(e){let t=this.equations,i=t.indexOf(e);i!==-1&&t.splice(i,1)}removeAllEquations(){this.equations.length=0}},Za=class extends Xa{constructor(){super();this.iterations=void 0,this.tolerance=void 0,this.iterations=10,this.tolerance=1e-7}solve(e,t){let i=0,a=this.iterations,r=this.tolerance*this.tolerance,s=this.equations,o=s.length,c=t.bodies,l=c.length,u=e,f,h,m,v,g,x;if(o!==0)for(let b=0;b!==l;b++)c[b].updateSolveMassProperties();let p=j7,d=X7,A=W7;p.length=o,d.length=o,A.length=o;for(let b=0;b!==o;b++){let C=s[b];A[b]=0,d[b]=C.computeB(u),p[b]=1/C.computeC()}if(o!==0){for(let E=0;E!==l;E++){let T=c[E],_=T.vlambda,P=T.wlambda;_.set(0,0,0),P.set(0,0,0)}for(i=0;i!==a;i++){v=0;for(let E=0;E!==o;E++){let T=s[E];f=d[E],h=p[E],x=A[E],g=T.computeGWlambda(),m=h*(f-g-T.eps*x),x+m<T.minForce?m=T.minForce-x:x+m>T.maxForce&&(m=T.maxForce-x),A[E]+=m,v+=m>0?m:-m,T.addToWlambda(m)}if(v*v<r)break}for(let E=0;E!==l;E++){let T=c[E],_=T.velocity,P=T.angularVelocity;T.vlambda.vmul(T.linearFactor,T.vlambda),_.vadd(T.vlambda,_),T.wlambda.vmul(T.angularFactor,T.wlambda),P.vadd(T.wlambda,P)}let b=s.length,C=1/u;for(;b--;)s[b].multiplier=A[b]*C}return i}},W7=[],j7=[],X7=[];var Rd=i1.STATIC;var Ya=class{constructor(){this.objects=[],this.type=Object}release(...e){let t=e.length;for(let i=0;i!==t;i++)this.objects.push(e[i]);return this}get(){return this.objects.length===0?this.constructObject():this.objects.pop()}constructObject(){throw new Error("constructObject() not implemented in this Pool subclass yet!")}resize(e){let t=this.objects;for(;t.length>e;)t.pop();for(;t.length<e;)t.push(this.constructObject());return this}},$a=class extends Ya{constructor(...e){super(...e);this.type=y}constructObject(){return new y}},Ka,Ja,Qa,er,tr,ir,ar,rr,nr,sr,or,cr,lr,ur,hr,fr,dr,pr,mr,vr,gr,xr,Mr,br,yr,G1={sphereSphere:c1.types.SPHERE,spherePlane:c1.types.SPHERE|c1.types.PLANE,boxBox:c1.types.BOX|c1.types.BOX,sphereBox:c1.types.SPHERE|c1.types.BOX,planeBox:c1.types.PLANE|c1.types.BOX,convexConvex:c1.types.CONVEXPOLYHEDRON,sphereConvex:c1.types.SPHERE|c1.types.CONVEXPOLYHEDRON,planeConvex:c1.types.PLANE|c1.types.CONVEXPOLYHEDRON,boxConvex:c1.types.BOX|c1.types.CONVEXPOLYHEDRON,sphereHeightfield:c1.types.SPHERE|c1.types.HEIGHTFIELD,boxHeightfield:c1.types.BOX|c1.types.HEIGHTFIELD,convexHeightfield:c1.types.CONVEXPOLYHEDRON|c1.types.HEIGHTFIELD,sphereParticle:c1.types.PARTICLE|c1.types.SPHERE,planeParticle:c1.types.PLANE|c1.types.PARTICLE,boxParticle:c1.types.BOX|c1.types.PARTICLE,convexParticle:c1.types.PARTICLE|c1.types.CONVEXPOLYHEDRON,cylinderCylinder:c1.types.CYLINDER,sphereCylinder:c1.types.SPHERE|c1.types.CYLINDER,planeCylinder:c1.types.PLANE|c1.types.CYLINDER,boxCylinder:c1.types.BOX|c1.types.CYLINDER,convexCylinder:c1.types.CONVEXPOLYHEDRON|c1.types.CYLINDER,heightfieldCylinder:c1.types.HEIGHTFIELD|c1.types.CYLINDER,particleCylinder:c1.types.PARTICLE|c1.types.CYLINDER,sphereTrimesh:c1.types.SPHERE|c1.types.TRIMESH,planeTrimesh:c1.types.PLANE|c1.types.TRIMESH};Ka=G1.sphereSphere;Ja=G1.spherePlane;Qa=G1.boxBox;er=G1.sphereBox;tr=G1.planeBox;ir=G1.convexConvex;ar=G1.sphereConvex;rr=G1.planeConvex;nr=G1.boxConvex;sr=G1.sphereHeightfield;or=G1.boxHeightfield;cr=G1.convexHeightfield;lr=G1.sphereParticle;ur=G1.planeParticle;hr=G1.boxParticle;fr=G1.convexParticle;dr=G1.cylinderCylinder;pr=G1.sphereCylinder;mr=G1.planeCylinder;vr=G1.boxCylinder;gr=G1.convexCylinder;xr=G1.heightfieldCylinder;Mr=G1.particleCylinder;br=G1.sphereTrimesh;yr=G1.planeTrimesh;var Cr=class{get[Ka](){return this.sphereSphere}get[Ja](){return this.spherePlane}get[Qa](){return this.boxBox}get[er](){return this.sphereBox}get[tr](){return this.planeBox}get[ir](){return this.convexConvex}get[ar](){return this.sphereConvex}get[rr](){return this.planeConvex}get[nr](){return this.boxConvex}get[sr](){return this.sphereHeightfield}get[or](){return this.boxHeightfield}get[cr](){return this.convexHeightfield}get[lr](){return this.sphereParticle}get[ur](){return this.planeParticle}get[hr](){return this.boxParticle}get[fr](){return this.convexParticle}get[dr](){return this.convexConvex}get[pr](){return this.sphereConvex}get[mr](){return this.planeConvex}get[vr](){return this.boxConvex}get[gr](){return this.convexConvex}get[xr](){return this.heightfieldCylinder}get[Mr](){return this.particleCylinder}get[br](){return this.sphereTrimesh}get[yr](){return this.planeTrimesh}constructor(e){this.contactPointPool=void 0,this.frictionEquationPool=void 0,this.result=void 0,this.frictionResult=void 0,this.v3pool=void 0,this.world=void 0,this.currentContactMaterial=void 0,this.enableFrictionReduction=void 0,this.contactPointPool=[],this.frictionEquationPool=[],this.result=[],this.frictionResult=[],this.v3pool=new $a,this.world=e,this.currentContactMaterial=e.defaultContactMaterial,this.enableFrictionReduction=!1}createContactEquation(e,t,i,a,r,s){let o;this.contactPointPool.length?(o=this.contactPointPool.pop(),o.bi=e,o.bj=t):o=new ja(e,t),o.enabled=e.collisionResponse&&t.collisionResponse&&i.collisionResponse&&a.collisionResponse;let c=this.currentContactMaterial;o.restitution=c.restitution,o.setSpookParams(c.contactEquationStiffness,c.contactEquationRelaxation,this.world.dt);let l=i.material||e.material,u=a.material||t.material;return l&&u&&l.restitution>=0&&u.restitution>=0&&(o.restitution=l.restitution*u.restitution),o.si=r||i,o.sj=s||a,o}createFrictionEquationsFromContact(e,t){let i=e.bi,a=e.bj,r=e.si,s=e.sj,o=this.world,c=this.currentContactMaterial,l=c.friction,u=r.material||i.material,f=s.material||a.material;if(u&&f&&u.friction>=0&&f.friction>=0&&(l=u.friction*f.friction),l>0){let h=l*o.gravity.length(),m=i.invMass+a.invMass;m>0&&(m=1/m);let v=this.frictionEquationPool,g=v.length?v.pop():new Z0(i,a,h*m),x=v.length?v.pop():new Z0(i,a,h*m);return g.bi=x.bi=i,g.bj=x.bj=a,g.minForce=x.minForce=-h*m,g.maxForce=x.maxForce=h*m,g.ri.copy(e.ri),g.rj.copy(e.rj),x.ri.copy(e.ri),x.rj.copy(e.rj),e.ni.tangents(g.t,x.t),g.setSpookParams(c.frictionEquationStiffness,c.frictionEquationRelaxation,o.dt),x.setSpookParams(c.frictionEquationStiffness,c.frictionEquationRelaxation,o.dt),g.enabled=x.enabled=e.enabled,t.push(g,x),!0}return!1}createFrictionFromAverage(e){let t=this.result[this.result.length-1];if(!this.createFrictionEquationsFromContact(t,this.frictionResult)||e===1)return;let i=this.frictionResult[this.frictionResult.length-2],a=this.frictionResult[this.frictionResult.length-1];y4.setZero(),U4.setZero(),O4.setZero();let r=t.bi;t.bj;for(let o=0;o!==e;o++)t=this.result[this.result.length-1-o],t.bi!==r?(y4.vadd(t.ni,y4),U4.vadd(t.ri,U4),O4.vadd(t.rj,O4)):(y4.vsub(t.ni,y4),U4.vadd(t.rj,U4),O4.vadd(t.ri,O4));let s=1/e;U4.scale(s,i.ri),O4.scale(s,i.rj),a.ri.copy(i.ri),a.rj.copy(i.rj),y4.normalize(),y4.tangents(i.t,a.t)}getContacts(e,t,i,a,r,s,o){this.contactPointPool=r,this.frictionEquationPool=o,this.result=a,this.frictionResult=s;let c=$7,l=K7,u=Z7,f=Y7;for(let h=0,m=e.length;h!==m;h++){let v=e[h],g=t[h],x=null;v.material&&g.material&&(x=i.getContactMaterial(v.material,g.material)||null);let p=v.type&i1.KINEMATIC&&g.type&i1.STATIC||v.type&i1.STATIC&&g.type&i1.KINEMATIC||v.type&i1.KINEMATIC&&g.type&i1.KINEMATIC;for(let d=0;d<v.shapes.length;d++){v.quaternion.mult(v.shapeOrientations[d],c),v.quaternion.vmult(v.shapeOffsets[d],u),u.vadd(v.position,u);let A=v.shapes[d];for(let b=0;b<g.shapes.length;b++){g.quaternion.mult(g.shapeOrientations[b],l),g.quaternion.vmult(g.shapeOffsets[b],f),f.vadd(g.position,f);let C=g.shapes[b];if(!(A.collisionFilterMask&C.collisionFilterGroup&&C.collisionFilterMask&A.collisionFilterGroup)||u.distanceTo(f)>A.boundingSphereRadius+C.boundingSphereRadius)continue;let E=null;A.material&&C.material&&(E=i.getContactMaterial(A.material,C.material)||null),this.currentContactMaterial=E||x||i.defaultContactMaterial;let T=A.type|C.type,_=this[T];if(_){let P=!1;A.type<C.type?P=_.call(this,A,C,u,f,c,l,v,g,A,C,p):P=_.call(this,C,A,f,u,l,c,g,v,A,C,p),P&&p&&(i.shapeOverlapKeeper.set(A.id,C.id),i.bodyOverlapKeeper.set(v.id,g.id))}}}}}sphereSphere(e,t,i,a,r,s,o,c,l,u,f){if(f)return i.distanceSquared(a)<(e.radius+t.radius)**2;let h=this.createContactEquation(o,c,e,t,l,u);a.vsub(i,h.ni),h.ni.normalize(),h.ri.copy(h.ni),h.rj.copy(h.ni),h.ri.scale(e.radius,h.ri),h.rj.scale(-t.radius,h.rj),h.ri.vadd(i,h.ri),h.ri.vsub(o.position,h.ri),h.rj.vadd(a,h.rj),h.rj.vsub(c.position,h.rj),this.result.push(h),this.createFrictionEquationsFromContact(h,this.frictionResult)}spherePlane(e,t,i,a,r,s,o,c,l,u,f){let h=this.createContactEquation(o,c,e,t,l,u);if(h.ni.set(0,0,1),s.vmult(h.ni,h.ni),h.ni.negate(h.ni),h.ni.normalize(),h.ni.scale(e.radius,h.ri),i.vsub(a,M6),h.ni.scale(h.ni.dot(M6),zr),M6.vsub(zr,h.rj),-M6.dot(h.ni)<=e.radius){if(f)return!0;let m=h.ri,v=h.rj;m.vadd(i,m),m.vsub(o.position,m),v.vadd(a,v),v.vsub(c.position,v),this.result.push(h),this.createFrictionEquationsFromContact(h,this.frictionResult)}}boxBox(e,t,i,a,r,s,o,c,l,u,f){return e.convexPolyhedronRepresentation.material=e.material,t.convexPolyhedronRepresentation.material=t.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexConvex(e.convexPolyhedronRepresentation,t.convexPolyhedronRepresentation,i,a,r,s,o,c,e,t,f)}sphereBox(e,t,i,a,r,s,o,c,l,u,f){let h=this.v3pool,m=zl;i.vsub(a,b6),t.getSideNormals(m,s);let v=e.radius,g=!1,x=wl,p=Sl,d=_l,A=null,b=0,C=0,E=0,T=null;for(let L=0,N=m.length;L!==N&&g===!1;L++){let U=bl;U.copy(m[L]);let Z=U.length();U.normalize();let O=b6.dot(U);if(O<Z+v&&O>0){let W=yl,X=Cl;W.copy(m[(L+1)%3]),X.copy(m[(L+2)%3]);let Q=W.length(),a1=X.length();W.normalize(),X.normalize();let B=b6.dot(W),M1=b6.dot(X);if(B<Q&&B>-Q&&M1<a1&&M1>-a1){let u1=Math.abs(O-Z-v);if((T===null||u1<T)&&(T=u1,C=B,E=M1,A=Z,x.copy(U),p.copy(W),d.copy(X),b++,f))return!0}}}if(b){g=!0;let L=this.createContactEquation(o,c,e,t,l,u);x.scale(-v,L.ri),L.ni.copy(x),L.ni.negate(L.ni),x.scale(A,x),p.scale(C,p),x.vadd(p,x),d.scale(E,d),x.vadd(d,L.rj),L.ri.vadd(i,L.ri),L.ri.vsub(o.position,L.ri),L.rj.vadd(a,L.rj),L.rj.vsub(c.position,L.rj),this.result.push(L),this.createFrictionEquationsFromContact(L,this.frictionResult)}let _=h.get(),P=Al;for(let L=0;L!==2&&!g;L++)for(let N=0;N!==2&&!g;N++)for(let U=0;U!==2&&!g;U++)if(_.set(0,0,0),L?_.vadd(m[0],_):_.vsub(m[0],_),N?_.vadd(m[1],_):_.vsub(m[1],_),U?_.vadd(m[2],_):_.vsub(m[2],_),a.vadd(_,P),P.vsub(i,P),P.lengthSquared()<v*v){if(f)return!0;g=!0;let Z=this.createContactEquation(o,c,e,t,l,u);Z.ri.copy(P),Z.ri.normalize(),Z.ni.copy(Z.ri),Z.ri.scale(v,Z.ri),Z.rj.copy(_),Z.ri.vadd(i,Z.ri),Z.ri.vsub(o.position,Z.ri),Z.rj.vadd(a,Z.rj),Z.rj.vsub(c.position,Z.rj),this.result.push(Z),this.createFrictionEquationsFromContact(Z,this.frictionResult)}h.release(_),_=null;let F=h.get(),M=h.get(),D=h.get(),z=h.get(),H=h.get(),V=m.length;for(let L=0;L!==V&&!g;L++)for(let N=0;N!==V&&!g;N++)if(L%3!=N%3){m[N].cross(m[L],F),F.normalize(),m[L].vadd(m[N],M),D.copy(i),D.vsub(M,D),D.vsub(a,D);let U=D.dot(F);F.scale(U,z);let Z=0;for(;Z===L%3||Z===N%3;)Z++;H.copy(i),H.vsub(z,H),H.vsub(M,H),H.vsub(a,H);let O=Math.abs(U),W=H.length();if(O<m[Z].length()&&W<v){if(f)return!0;g=!0;let X=this.createContactEquation(o,c,e,t,l,u);M.vadd(z,X.rj),X.rj.copy(X.rj),H.negate(X.ni),X.ni.normalize(),X.ri.copy(X.rj),X.ri.vadd(a,X.ri),X.ri.vsub(i,X.ri),X.ri.normalize(),X.ri.scale(v,X.ri),X.ri.vadd(i,X.ri),X.ri.vsub(o.position,X.ri),X.rj.vadd(a,X.rj),X.rj.vsub(c.position,X.rj),this.result.push(X),this.createFrictionEquationsFromContact(X,this.frictionResult)}}h.release(F,M,D,z,H)}planeBox(e,t,i,a,r,s,o,c,l,u,f){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,t.convexPolyhedronRepresentation.id=t.id,this.planeConvex(e,t.convexPolyhedronRepresentation,i,a,r,s,o,c,e,t,f)}convexConvex(e,t,i,a,r,s,o,c,l,u,f,h,m){let v=Ol;if(!(i.distanceTo(a)>e.boundingSphereRadius+t.boundingSphereRadius)&&e.findSeparatingAxis(t,i,r,a,s,v,h,m)){let g=[],x=Gl;e.clipAgainstHull(i,r,t,a,s,v,-100,100,g);let p=0;for(let d=0;d!==g.length;d++){if(f)return!0;let A=this.createContactEquation(o,c,e,t,l,u),b=A.ri,C=A.rj;v.negate(A.ni),g[d].normal.negate(x),x.scale(g[d].depth,x),g[d].point.vadd(x,b),C.copy(g[d].point),b.vsub(i,b),C.vsub(a,C),b.vadd(i,b),b.vsub(o.position,b),C.vadd(a,C),C.vsub(c.position,C),this.result.push(A),p++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(A,this.frictionResult)}this.enableFrictionReduction&&p&&this.createFrictionFromAverage(p)}}sphereConvex(e,t,i,a,r,s,o,c,l,u,f){let h=this.v3pool;i.vsub(a,El);let m=t.faceNormals,v=t.faces,g=t.vertices,x=e.radius,p=!1;for(let d=0;d!==g.length;d++){let A=g[d],b=Hl;s.vmult(A,b),a.vadd(b,b);let C=Tl;if(b.vsub(i,C),C.lengthSquared()<x*x){if(f)return!0;p=!0;let E=this.createContactEquation(o,c,e,t,l,u);E.ri.copy(C),E.ri.normalize(),E.ni.copy(E.ri),E.ri.scale(x,E.ri),b.vsub(a,E.rj),E.ri.vadd(i,E.ri),E.ri.vsub(o.position,E.ri),E.rj.vadd(a,E.rj),E.rj.vsub(c.position,E.rj),this.result.push(E),this.createFrictionEquationsFromContact(E,this.frictionResult);return}}for(let d=0,A=v.length;d!==A&&p===!1;d++){let b=m[d],C=v[d],E=Vl;s.vmult(b,E);let T=Nl;s.vmult(g[C[0]],T),T.vadd(a,T);let _=Rl;E.scale(-x,_),i.vadd(_,_);let P=Fl;_.vsub(T,P);let F=P.dot(E),M=Bl;if(i.vsub(T,M),F<0&&M.dot(E)>0){let D=[];for(let z=0,H=C.length;z!==H;z++){let V=h.get();s.vmult(g[C[z]],V),a.vadd(V,V),D.push(V)}if(Ml(D,E,i)){if(f)return!0;p=!0;let z=this.createContactEquation(o,c,e,t,l,u);E.scale(-x,z.ri),E.negate(z.ni);let H=h.get();E.scale(-F,H);let V=h.get();E.scale(-x,V),i.vsub(a,z.rj),z.rj.vadd(V,z.rj),z.rj.vadd(H,z.rj),z.rj.vadd(a,z.rj),z.rj.vsub(c.position,z.rj),z.ri.vadd(i,z.ri),z.ri.vsub(o.position,z.ri),h.release(H),h.release(V),this.result.push(z),this.createFrictionEquationsFromContact(z,this.frictionResult);for(let L=0,N=D.length;L!==N;L++)h.release(D[L]);return}else for(let z=0;z!==C.length;z++){let H=h.get(),V=h.get();s.vmult(g[C[(z+1)%C.length]],H),s.vmult(g[C[(z+2)%C.length]],V),a.vadd(H,H),a.vadd(V,V);let L=Ll;V.vsub(H,L);let N=Dl;L.unit(N);let U=h.get(),Z=h.get();i.vsub(H,Z);let O=Z.dot(N);N.scale(O,U),U.vadd(H,U);let W=h.get();if(U.vsub(i,W),O>0&&O*O<L.lengthSquared()&&W.lengthSquared()<x*x){if(f)return!0;let X=this.createContactEquation(o,c,e,t,l,u);U.vsub(a,X.rj),U.vsub(i,X.ni),X.ni.normalize(),X.ni.scale(x,X.ri),X.rj.vadd(a,X.rj),X.rj.vsub(c.position,X.rj),X.ri.vadd(i,X.ri),X.ri.vsub(o.position,X.ri),this.result.push(X),this.createFrictionEquationsFromContact(X,this.frictionResult);for(let Q=0,a1=D.length;Q!==a1;Q++)h.release(D[Q]);h.release(H),h.release(V),h.release(U),h.release(W),h.release(Z);return}h.release(H),h.release(V),h.release(U),h.release(W),h.release(Z)}for(let z=0,H=D.length;z!==H;z++)h.release(D[z])}}}planeConvex(e,t,i,a,r,s,o,c,l,u,f){let h=Pl,m=Il;m.set(0,0,1),r.vmult(m,m);let v=0,g=kl;for(let x=0;x!==t.vertices.length;x++)if(h.copy(t.vertices[x]),s.vmult(h,h),a.vadd(h,h),h.vsub(i,g),m.dot(g)<=0){if(f)return!0;let d=this.createContactEquation(o,c,e,t,l,u),A=Ul;m.scale(m.dot(g),A),h.vsub(A,A),A.vsub(i,d.ri),d.ni.copy(m),h.vsub(a,d.rj),d.ri.vadd(i,d.ri),d.ri.vsub(o.position,d.ri),d.rj.vadd(a,d.rj),d.rj.vsub(c.position,d.rj),this.result.push(d),v++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(d,this.frictionResult)}this.enableFrictionReduction&&v&&this.createFrictionFromAverage(v)}boxConvex(e,t,i,a,r,s,o,c,l,u,f){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexConvex(e.convexPolyhedronRepresentation,t,i,a,r,s,o,c,e,t,f)}sphereHeightfield(e,t,i,a,r,s,o,c,l,u,f){let h=t.data,m=e.radius,v=t.elementSize,g=t9,x=e9;N1.pointToLocalFrame(a,s,i,x);let p=Math.floor((x.x-m)/v)-1,d=Math.ceil((x.x+m)/v)+1,A=Math.floor((x.y-m)/v)-1,b=Math.ceil((x.y+m)/v)+1;if(d<0||b<0||p>h.length||A>h[0].length)return;p<0&&(p=0),d<0&&(d=0),A<0&&(A=0),b<0&&(b=0),p>=h.length&&(p=h.length-1),d>=h.length&&(d=h.length-1),b>=h[0].length&&(b=h[0].length-1),A>=h[0].length&&(A=h[0].length-1);let C=[];t.getRectMinMax(p,A,d,b,C);let E=C[0],T=C[1];if(x.z-m>T||x.z+m<E)return;let _=this.result;for(let P=p;P<d;P++)for(let F=A;F<b;F++){let M=_.length,D=!1;if(t.getConvexTrianglePillar(P,F,!1),N1.pointToWorldFrame(a,s,t.pillarOffset,g),i.distanceTo(g)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(D=this.sphereConvex(e,t.pillarConvex,i,g,r,s,o,c,e,t,f)),f&&D||(t.getConvexTrianglePillar(P,F,!0),N1.pointToWorldFrame(a,s,t.pillarOffset,g),i.distanceTo(g)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(D=this.sphereConvex(e,t.pillarConvex,i,g,r,s,o,c,e,t,f)),f&&D))return!0;if(_.length-M>2)return}}boxHeightfield(e,t,i,a,r,s,o,c,l,u,f){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexHeightfield(e.convexPolyhedronRepresentation,t,i,a,r,s,o,c,e,t,f)}convexHeightfield(e,t,i,a,r,s,o,c,l,u,f){let h=t.data,m=t.elementSize,v=e.boundingSphereRadius,g=Jl,x=Ql,p=Kl;N1.pointToLocalFrame(a,s,i,p);let d=Math.floor((p.x-v)/m)-1,A=Math.ceil((p.x+v)/m)+1,b=Math.floor((p.y-v)/m)-1,C=Math.ceil((p.y+v)/m)+1;if(A<0||C<0||d>h.length||b>h[0].length)return;d<0&&(d=0),A<0&&(A=0),b<0&&(b=0),C<0&&(C=0),d>=h.length&&(d=h.length-1),A>=h.length&&(A=h.length-1),C>=h[0].length&&(C=h[0].length-1),b>=h[0].length&&(b=h[0].length-1);let E=[];t.getRectMinMax(d,b,A,C,E);let T=E[0],_=E[1];if(!(p.z-v>_||p.z+v<T))for(let P=d;P<A;P++)for(let F=b;F<C;F++){let M=!1;if(t.getConvexTrianglePillar(P,F,!1),N1.pointToWorldFrame(a,s,t.pillarOffset,g),i.distanceTo(g)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(M=this.convexConvex(e,t.pillarConvex,i,g,r,s,o,c,null,null,f,x,null)),f&&M||(t.getConvexTrianglePillar(P,F,!0),N1.pointToWorldFrame(a,s,t.pillarOffset,g),i.distanceTo(g)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(M=this.convexConvex(e,t.pillarConvex,i,g,r,s,o,c,null,null,f,x,null)),f&&M))return!0}}sphereParticle(e,t,i,a,r,s,o,c,l,u,f){let h=Xl;if(h.set(0,0,1),a.vsub(i,h),h.lengthSquared()<=e.radius*e.radius){if(f)return!0;let v=this.createContactEquation(c,o,t,e,l,u);h.normalize(),v.rj.copy(h),v.rj.scale(e.radius,v.rj),v.ni.copy(h),v.ni.negate(v.ni),v.ri.set(0,0,0),this.result.push(v),this.createFrictionEquationsFromContact(v,this.frictionResult)}}planeParticle(e,t,i,a,r,s,o,c,l,u,f){let h=ql;h.set(0,0,1),o.quaternion.vmult(h,h);let m=Wl;if(a.vsub(o.position,m),h.dot(m)<=0){if(f)return!0;let g=this.createContactEquation(c,o,t,e,l,u);g.ni.copy(h),g.ni.negate(g.ni),g.ri.set(0,0,0);let x=jl;h.scale(h.dot(a),x),a.vsub(x,x),g.rj.copy(x),this.result.push(g),this.createFrictionEquationsFromContact(g,this.frictionResult)}}boxParticle(e,t,i,a,r,s,o,c,l,u,f){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexParticle(e.convexPolyhedronRepresentation,t,i,a,r,s,o,c,e,t,f)}convexParticle(e,t,i,a,r,s,o,c,l,u,f){let h=-1,m=Yl,v=$l,g=null,x=Zl;if(x.copy(a),x.vsub(i,x),r.conjugate(Ar),Ar.vmult(x,x),e.pointIsInside(x)){e.worldVerticesNeedsUpdate&&e.computeWorldVertices(i,r),e.worldFaceNormalsNeedsUpdate&&e.computeWorldFaceNormals(r);for(let p=0,d=e.faces.length;p!==d;p++){let A=[e.worldVertices[e.faces[p][0]]],b=e.worldFaceNormals[p];a.vsub(A[0],wr);let C=-b.dot(wr);if(g===null||Math.abs(C)<Math.abs(g)){if(f)return!0;g=C,h=p,m.copy(b)}}if(h!==-1){let p=this.createContactEquation(c,o,t,e,l,u);m.scale(g,v),v.vadd(a,v),v.vsub(i,v),p.rj.copy(v),m.negate(p.ni),p.ri.set(0,0,0);let d=p.ri,A=p.rj;d.vadd(a,d),d.vsub(c.position,d),A.vadd(i,A),A.vsub(o.position,A),this.result.push(p),this.createFrictionEquationsFromContact(p,this.frictionResult)}else console.warn("Point found inside convex, but did not find penetrating face!")}}heightfieldCylinder(e,t,i,a,r,s,o,c,l,u,f){return this.convexHeightfield(t,e,a,i,s,r,c,o,l,u,f)}particleCylinder(e,t,i,a,r,s,o,c,l,u,f){return this.convexParticle(t,e,a,i,s,r,c,o,l,u,f)}sphereTrimesh(e,t,i,a,r,s,o,c,l,u,f){let h=nl,m=sl,v=ol,g=cl,x=ll,p=ul,d=pl,A=rl,b=il,C=ml;N1.pointToLocalFrame(a,s,i,x);let E=e.radius;d.lowerBound.set(x.x-E,x.y-E,x.z-E),d.upperBound.set(x.x+E,x.y+E,x.z+E),t.getTrianglesInAABB(d,C);let T=al,_=e.radius*e.radius;for(let z=0;z<C.length;z++)for(let H=0;H<3;H++)if(t.getVertex(t.indices[C[z]*3+H],T),T.vsub(x,b),b.lengthSquared()<=_){if(A.copy(T),N1.pointToWorldFrame(a,s,A,T),T.vsub(i,b),f)return!0;let V=this.createContactEquation(o,c,e,t,l,u);V.ni.copy(b),V.ni.normalize(),V.ri.copy(V.ni),V.ri.scale(e.radius,V.ri),V.ri.vadd(i,V.ri),V.ri.vsub(o.position,V.ri),V.rj.copy(T),V.rj.vsub(c.position,V.rj),this.result.push(V),this.createFrictionEquationsFromContact(V,this.frictionResult)}for(let z=0;z<C.length;z++)for(let H=0;H<3;H++){t.getVertex(t.indices[C[z]*3+H],h),t.getVertex(t.indices[C[z]*3+(H+1)%3],m),m.vsub(h,v),x.vsub(m,p);let V=p.dot(v);x.vsub(h,p);let L=p.dot(v);if(L>0&&V<0&&(x.vsub(h,p),g.copy(v),g.normalize(),L=p.dot(g),g.scale(L,p),p.vadd(h,p),p.distanceTo(x)<e.radius)){if(f)return!0;let U=this.createContactEquation(o,c,e,t,l,u);p.vsub(x,U.ni),U.ni.normalize(),U.ni.scale(e.radius,U.ri),U.ri.vadd(i,U.ri),U.ri.vsub(o.position,U.ri),N1.pointToWorldFrame(a,s,p,p),p.vsub(c.position,U.rj),N1.vectorToWorldFrame(s,U.ni,U.ni),N1.vectorToWorldFrame(s,U.ri,U.ri),this.result.push(U),this.createFrictionEquationsFromContact(U,this.frictionResult)}}let P=hl,F=fl,M=dl,D=tl;for(let z=0,H=C.length;z!==H;z++){t.getTriangleVertices(C[z],P,F,M),t.getNormal(C[z],D),x.vsub(P,p);let V=p.dot(D);if(D.scale(V,p),x.vsub(p,p),V=p.distanceTo(x),J1.pointInTriangle(p,P,F,M)&&V<e.radius){if(f)return!0;let L=this.createContactEquation(o,c,e,t,l,u);p.vsub(x,L.ni),L.ni.normalize(),L.ni.scale(e.radius,L.ri),L.ri.vadd(i,L.ri),L.ri.vsub(o.position,L.ri),N1.pointToWorldFrame(a,s,p,p),p.vsub(c.position,L.rj),N1.vectorToWorldFrame(s,L.ni,L.ni),N1.vectorToWorldFrame(s,L.ri,L.ri),this.result.push(L),this.createFrictionEquationsFromContact(L,this.frictionResult)}}C.length=0}planeTrimesh(e,t,i,a,r,s,o,c,l,u,f){let h=new y,m=J7;m.set(0,0,1),r.vmult(m,m);for(let v=0;v<t.vertices.length/3;v++){t.getVertex(v,h);let g=new y;g.copy(h),N1.pointToWorldFrame(a,s,g,h);let x=Q7;if(h.vsub(i,x),m.dot(x)<=0){if(f)return!0;let d=this.createContactEquation(o,c,e,t,l,u);d.ni.copy(m);let A=el;m.scale(x.dot(m),A),h.vsub(A,A),d.ri.copy(A),d.ri.vsub(o.position,d.ri),d.rj.copy(h),d.rj.vsub(c.position,d.rj),this.result.push(d),this.createFrictionEquationsFromContact(d,this.frictionResult)}}}},y4=new y,U4=new y,O4=new y,Z7=new y,Y7=new y,$7=new O1,K7=new O1,J7=new y,Q7=new y,el=new y,tl=new y,il=new y,al=new y,rl=new y,nl=new y,sl=new y,ol=new y,cl=new y,ll=new y,ul=new y,hl=new y,fl=new y,dl=new y,pl=new E2,ml=[],M6=new y,zr=new y,vl=new y,gl=new y,xl=new y;function Ml(n,e,t){let i=null,a=n.length;for(let r=0;r!==a;r++){let s=n[r],o=vl;n[(r+1)%a].vsub(s,o);let c=gl;o.cross(e,c);let l=xl;t.vsub(s,l);let u=c.dot(l);if(i===null||u>0&&i===!0||u<=0&&i===!1){i===null&&(i=u>0);continue}else return!1}return!0}var b6=new y,bl=new y,yl=new y,Cl=new y,zl=[new y,new y,new y,new y,new y,new y],Al=new y,wl=new y,Sl=new y,_l=new y,El=new y,Ll=new y,Dl=new y,Tl=new y,Hl=new y,Vl=new y,Nl=new y,Rl=new y,Fl=new y,Bl=new y,Pl=new y,Il=new y,kl=new y,Ul=new y,Ol=new y,Gl=new y,ql=new y,Wl=new y,jl=new y,Xl=new y,Ar=new O1,Zl=new y,Yl=new y,wr=new y,$l=new y,Kl=new y,Jl=new y,Ql=[0],e9=new y,t9=new y,Y0=class{constructor(){this.current=void 0,this.previous=void 0,this.current=[],this.previous=[]}getKey(e,t){if(t<e){let i=t;t=e,e=i}return e<<16|t}set(e,t){let i=this.getKey(e,t),a=this.current,r=0;for(;i>a[r];)r++;if(i!==a[r]){for(let s=a.length-1;s>=r;s--)a[s+1]=a[s];a[r]=i}}tick(){let e=this.current;this.current=this.previous,this.previous=e,this.current.length=0}getDiff(e,t){let i=this.current,a=this.previous,r=i.length,s=a.length,o=0;for(let c=0;c<r;c++){let l=!1,u=i[c];for(;u>a[o];)o++;l=u===a[o],l||Sr(e,u)}o=0;for(let c=0;c<s;c++){let l=!1,u=a[c];for(;u>i[o];)o++;l=i[o]===u,l||Sr(t,u)}}};function Sr(n,e){n.push((e&4294901760)>>16,e&65535)}var _r=class{constructor(){this.data={keys:[]}}get(e,t){if(e>t){let i=t;t=e,e=i}return this.data[e+"-"+t]}set(e,t,i){if(e>t){let r=t;t=e,e=r}let a=e+"-"+t;this.get(e,t)||this.data.keys.push(a),this.data[a]=i}reset(){let e=this.data,t=e.keys;for(;t.length>0;){let i=t.pop();delete e[i]}}},$0=class extends P0{constructor(e={}){super();this.dt=void 0,this.allowSleep=void 0,this.contacts=void 0,this.frictionEquations=void 0,this.quatNormalizeSkip=void 0,this.quatNormalizeFast=void 0,this.time=void 0,this.stepnumber=void 0,this.default_dt=void 0,this.nextId=void 0,this.gravity=void 0,this.broadphase=void 0,this.bodies=void 0,this.hasActiveBodies=void 0,this.solver=void 0,this.constraints=void 0,this.narrowphase=void 0,this.collisionMatrix=void 0,this.collisionMatrixPrevious=void 0,this.bodyOverlapKeeper=void 0,this.shapeOverlapKeeper=void 0,this.materials=void 0,this.contactmaterials=void 0,this.contactMaterialTable=void 0,this.defaultMaterial=void 0,this.defaultContactMaterial=void 0,this.doProfiling=void 0,this.profile=void 0,this.accumulator=void 0,this.subsystems=void 0,this.addBodyEvent=void 0,this.removeBodyEvent=void 0,this.idToBodyMap=void 0,this.dt=-1,this.allowSleep=!!e.allowSleep,this.contacts=[],this.frictionEquations=[],this.quatNormalizeSkip=e.quatNormalizeSkip!==void 0?e.quatNormalizeSkip:0,this.quatNormalizeFast=e.quatNormalizeFast!==void 0?e.quatNormalizeFast:!1,this.time=0,this.stepnumber=0,this.default_dt=1/60,this.nextId=0,this.gravity=new y,e.gravity&&this.gravity.copy(e.gravity),this.broadphase=e.broadphase!==void 0?e.broadphase:new d6,this.bodies=[],this.hasActiveBodies=!1,this.solver=e.solver!==void 0?e.solver:new Za,this.constraints=[],this.narrowphase=new Cr(this),this.collisionMatrix=new B0,this.collisionMatrixPrevious=new B0,this.bodyOverlapKeeper=new Y0,this.shapeOverlapKeeper=new Y0,this.materials=[],this.contactmaterials=[],this.contactMaterialTable=new _r,this.defaultMaterial=new Ve("default"),this.defaultContactMaterial=new He(this.defaultMaterial,this.defaultMaterial,{friction:.3,restitution:0}),this.doProfiling=!1,this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},this.accumulator=0,this.subsystems=[],this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.idToBodyMap={},this.broadphase.setWorld(this)}getContactMaterial(e,t){return this.contactMaterialTable.get(e.id,t.id)}numObjects(){return this.bodies.length}collisionMatrixTick(){let e=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=e,this.collisionMatrix.reset(),this.bodyOverlapKeeper.tick(),this.shapeOverlapKeeper.tick()}addConstraint(e){this.constraints.push(e)}removeConstraint(e){let t=this.constraints.indexOf(e);t!==-1&&this.constraints.splice(t,1)}rayTest(e,t,i){i instanceof p6?this.raycastClosest(e,t,{skipBackfaces:!0},i):this.raycastAll(e,t,{skipBackfaces:!0},i)}raycastAll(e,t,i={},a){return i.mode=J1.ALL,i.from=e,i.to=t,i.callback=a,K0.intersectWorld(this,i)}raycastAny(e,t,i={},a){return i.mode=J1.ANY,i.from=e,i.to=t,i.result=a,K0.intersectWorld(this,i)}raycastClosest(e,t,i={},a){return i.mode=J1.CLOSEST,i.from=e,i.to=t,i.result=a,K0.intersectWorld(this,i)}addBody(e){this.bodies.includes(e)||(e.index=this.bodies.length,this.bodies.push(e),e.world=this,e.initPosition.copy(e.position),e.initVelocity.copy(e.velocity),e.timeLastSleepy=this.time,e instanceof i1&&(e.initAngularVelocity.copy(e.angularVelocity),e.initQuaternion.copy(e.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=e,this.idToBodyMap[e.id]=e,this.dispatchEvent(this.addBodyEvent))}removeBody(e){e.world=null;let t=this.bodies.length-1,i=this.bodies,a=i.indexOf(e);if(a!==-1){i.splice(a,1);for(let r=0;r!==i.length;r++)i[r].index=r;this.collisionMatrix.setNumObjects(t),this.removeBodyEvent.body=e,delete this.idToBodyMap[e.id],this.dispatchEvent(this.removeBodyEvent)}}getBodyById(e){return this.idToBodyMap[e]}getShapeById(e){let t=this.bodies;for(let i=0;i<t.length;i++){let a=t[i].shapes;for(let r=0;r<a.length;r++){let s=a[r];if(s.id===e)return s}}return null}addMaterial(e){this.materials.push(e)}addContactMaterial(e){this.contactmaterials.push(e),this.contactMaterialTable.set(e.materials[0].id,e.materials[1].id,e)}step(e,t,i=10){if(t===void 0)this.internalStep(e),this.time+=e;else{this.accumulator+=t;let a=o2.now(),r=0;for(;this.accumulator>=e&&r<i&&(this.internalStep(e),this.accumulator-=e,r++,!(o2.now()-a>e*1e3)););this.accumulator=this.accumulator%e;let s=this.accumulator/e;for(let o=0;o!==this.bodies.length;o++){let c=this.bodies[o];c.previousPosition.lerp(c.position,s,c.interpolatedPosition),c.previousQuaternion.slerp(c.quaternion,s,c.interpolatedQuaternion),c.previousQuaternion.normalize()}this.time+=t}}internalStep(e){this.dt=e;let t=this.contacts,i=s9,a=o9,r=this.numObjects(),s=this.bodies,o=this.solver,c=this.gravity,l=this.doProfiling,u=this.profile,f=i1.DYNAMIC,h=-1/0,m=this.constraints,v=n9;c.length();let g=c.x,x=c.y,p=c.z,d=0;for(l&&(h=o2.now()),d=0;d!==r;d++){let z=s[d];if(z.type===f){let H=z.force,V=z.mass;H.x+=V*g,H.y+=V*x,H.z+=V*p}}for(let z=0,H=this.subsystems.length;z!==H;z++)this.subsystems[z].update();l&&(h=o2.now()),i.length=0,a.length=0,this.broadphase.collisionPairs(this,i,a),l&&(u.broadphase=o2.now()-h);let A=m.length;for(d=0;d!==A;d++){let z=m[d];if(!z.collideConnected)for(let H=i.length-1;H>=0;H-=1)(z.bodyA===i[H]&&z.bodyB===a[H]||z.bodyB===i[H]&&z.bodyA===a[H])&&(i.splice(H,1),a.splice(H,1))}this.collisionMatrixTick(),l&&(h=o2.now());let b=r9,C=t.length;for(d=0;d!==C;d++)b.push(t[d]);t.length=0;let E=this.frictionEquations.length;for(d=0;d!==E;d++)v.push(this.frictionEquations[d]);for(this.frictionEquations.length=0,this.narrowphase.getContacts(i,a,this,t,b,this.frictionEquations,v),l&&(u.narrowphase=o2.now()-h),l&&(h=o2.now()),d=0;d<this.frictionEquations.length;d++)o.addEquation(this.frictionEquations[d]);let T=t.length;for(let z=0;z!==T;z++){let H=t[z],V=H.bi,L=H.bj,N=H.si,U=H.sj,Z;if(V.material&&L.material?Z=this.getContactMaterial(V.material,L.material)||this.defaultContactMaterial:Z=this.defaultContactMaterial,Z.friction,V.material&&L.material&&(V.material.friction>=0&&L.material.friction>=0&&V.material.friction*L.material.friction,V.material.restitution>=0&&L.material.restitution>=0&&(H.restitution=V.material.restitution*L.material.restitution)),o.addEquation(H),V.allowSleep&&V.type===i1.DYNAMIC&&V.sleepState===i1.SLEEPING&&L.sleepState===i1.AWAKE&&L.type!==i1.STATIC){let O=L.velocity.lengthSquared()+L.angularVelocity.lengthSquared(),W=L.sleepSpeedLimit**2;O>=W*2&&(V.wakeUpAfterNarrowphase=!0)}if(L.allowSleep&&L.type===i1.DYNAMIC&&L.sleepState===i1.SLEEPING&&V.sleepState===i1.AWAKE&&V.type!==i1.STATIC){let O=V.velocity.lengthSquared()+V.angularVelocity.lengthSquared(),W=V.sleepSpeedLimit**2;O>=W*2&&(L.wakeUpAfterNarrowphase=!0)}this.collisionMatrix.set(V,L,!0),this.collisionMatrixPrevious.get(V,L)||(At.body=L,At.contact=H,V.dispatchEvent(At),At.body=V,L.dispatchEvent(At)),this.bodyOverlapKeeper.set(V.id,L.id),this.shapeOverlapKeeper.set(N.id,U.id)}for(this.emitContactEvents(),l&&(u.makeContactConstraints=o2.now()-h,h=o2.now()),d=0;d!==r;d++){let z=s[d];z.wakeUpAfterNarrowphase&&(z.wakeUp(),z.wakeUpAfterNarrowphase=!1)}for(A=m.length,d=0;d!==A;d++){let z=m[d];z.update();for(let H=0,V=z.equations.length;H!==V;H++){let L=z.equations[H];o.addEquation(L)}}o.solve(e,this),l&&(u.solve=o2.now()-h),o.removeAllEquations();let _=Math.pow;for(d=0;d!==r;d++){let z=s[d];if(z.type&f){let H=_(1-z.linearDamping,e),V=z.velocity;V.scale(H,V);let L=z.angularVelocity;if(L){let N=_(1-z.angularDamping,e);L.scale(N,L)}}}for(this.dispatchEvent(a9),d=0;d!==r;d++){let z=s[d];z.preStep&&z.preStep.call(z)}l&&(h=o2.now());let F=this.stepnumber%(this.quatNormalizeSkip+1)==0,M=this.quatNormalizeFast;for(d=0;d!==r;d++)s[d].integrate(e,F,M);for(this.clearForces(),this.broadphase.dirty=!0,l&&(u.integrate=o2.now()-h),this.stepnumber+=1,this.dispatchEvent(i9),d=0;d!==r;d++){let z=s[d],H=z.postStep;H&&H.call(z)}let D=!0;if(this.allowSleep)for(D=!1,d=0;d!==r;d++){let z=s[d];z.sleepTick(this.time),z.sleepState!==i1.SLEEPING&&(D=!0)}this.hasActiveBodies=D}emitContactEvents(){let e=this.hasAnyEventListener("beginContact"),t=this.hasAnyEventListener("endContact");if((e||t)&&this.bodyOverlapKeeper.getDiff(Re,Fe),e){for(let r=0,s=Re.length;r<s;r+=2)wt.bodyA=this.getBodyById(Re[r]),wt.bodyB=this.getBodyById(Re[r+1]),this.dispatchEvent(wt);wt.bodyA=wt.bodyB=null}if(t){for(let r=0,s=Fe.length;r<s;r+=2)St.bodyA=this.getBodyById(Fe[r]),St.bodyB=this.getBodyById(Fe[r+1]),this.dispatchEvent(St);St.bodyA=St.bodyB=null}Re.length=Fe.length=0;let i=this.hasAnyEventListener("beginShapeContact"),a=this.hasAnyEventListener("endShapeContact");if((i||a)&&this.shapeOverlapKeeper.getDiff(Re,Fe),i){for(let r=0,s=Re.length;r<s;r+=2){let o=this.getShapeById(Re[r]),c=this.getShapeById(Re[r+1]);Be.shapeA=o,Be.shapeB=c,o&&(Be.bodyA=o.body),c&&(Be.bodyB=c.body),this.dispatchEvent(Be)}Be.bodyA=Be.bodyB=Be.shapeA=Be.shapeB=null}if(a){for(let r=0,s=Fe.length;r<s;r+=2){let o=this.getShapeById(Fe[r]),c=this.getShapeById(Fe[r+1]);Pe.shapeA=o,Pe.shapeB=c,o&&(Pe.bodyA=o.body),c&&(Pe.bodyB=c.body),this.dispatchEvent(Pe)}Pe.bodyA=Pe.bodyB=Pe.shapeA=Pe.shapeB=null}}clearForces(){let e=this.bodies,t=e.length;for(let i=0;i!==t;i++){let a=e[i];a.force,a.torque,a.force.set(0,0,0),a.torque.set(0,0,0)}}};new E2;var K0=new J1,o2=globalThis.performance||{};if(!o2.now){let n=Date.now();o2.timing&&o2.timing.navigationStart&&(n=o2.timing.navigationStart),o2.now=()=>Date.now()-n}var i9={type:"postStep"},a9={type:"preStep"},At={type:i1.COLLIDE_EVENT_NAME,body:null,contact:null},r9=[],n9=[],s9=[],o9=[],Re=[],Fe=[],wt={type:"beginContact",bodyA:null,bodyB:null},St={type:"endContact",bodyA:null,bodyB:null},Be={type:"beginShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null},Pe={type:"endShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null};var q1=class{constructor(e=0,t=0,i=0,a=1){this.x=e,this.y=t,this.z=i,this.w=a}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,a){return this.x=e,this.y=t,this.z=i,this.w=a,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,a=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*a+s[12]*r,this.y=s[1]*t+s[5]*i+s[9]*a+s[13]*r,this.z=s[2]*t+s[6]*i+s[10]*a+s[14]*r,this.w=s[3]*t+s[7]*i+s[11]*a+s[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,a,r,s=.01,o=.1,c=e.elements,l=c[0],u=c[4],f=c[8],h=c[1],m=c[5],v=c[9],g=c[2],x=c[6],p=c[10];if(Math.abs(u-h)<s&&Math.abs(f-g)<s&&Math.abs(v-x)<s){if(Math.abs(u+h)<o&&Math.abs(f+g)<o&&Math.abs(v+x)<o&&Math.abs(l+m+p-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let A=(l+1)/2,b=(m+1)/2,C=(p+1)/2,E=(u+h)/4,T=(f+g)/4,_=(v+x)/4;return A>b&&A>C?A<s?(i=0,a=.707106781,r=.707106781):(i=Math.sqrt(A),a=E/i,r=T/i):b>C?b<s?(i=.707106781,a=0,r=.707106781):(a=Math.sqrt(b),i=E/a,r=_/a):C<s?(i=.707106781,a=.707106781,r=0):(r=Math.sqrt(C),i=T/r,a=_/r),this.set(i,a,r,t),this}let d=Math.sqrt((x-v)*(x-v)+(f-g)*(f-g)+(h-u)*(h-u));return Math.abs(d)<.001&&(d=1),this.x=(x-v)/d,this.y=(f-g)/d,this.z=(h-u)/d,this.w=Math.acos((l+m+p-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,i){return i!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};q1.prototype.isVector4=!0;var d2=[];for(let n=0;n<256;n++)d2[n]=(n<16?"0":"")+n.toString(16);var y6=Math.PI/180,_t=180/Math.PI;function Ie(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(d2[n&255]+d2[n>>8&255]+d2[n>>16&255]+d2[n>>24&255]+"-"+d2[e&255]+d2[e>>8&255]+"-"+d2[e>>16&15|64]+d2[e>>24&255]+"-"+d2[t&63|128]+d2[t>>8&255]+"-"+d2[t>>16&255]+d2[t>>24&255]+d2[i&255]+d2[i>>8&255]+d2[i>>16&255]+d2[i>>24&255]).toUpperCase()}function D2(n,e,t){return Math.max(e,Math.min(t,n))}function Er(n,e){return(n%e+e)%e}function C6(n,e,t){return(1-t)*n+t*e}function J0(n){return(n&n-1)==0&&n!==0}function Lr(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}var Me=class{constructor(e=0,t=0,i=0,a=1){this._x=e,this._y=t,this._z=i,this._w=a}static slerp(e,t,i,a){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),i.slerpQuaternions(e,t,a)}static slerpFlat(e,t,i,a,r,s,o){let c=i[a+0],l=i[a+1],u=i[a+2],f=i[a+3],h=r[s+0],m=r[s+1],v=r[s+2],g=r[s+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f;return}if(o===1){e[t+0]=h,e[t+1]=m,e[t+2]=v,e[t+3]=g;return}if(f!==g||c!==h||l!==m||u!==v){let x=1-o,p=c*h+l*m+u*v+f*g,d=p>=0?1:-1,A=1-p*p;if(A>Number.EPSILON){let C=Math.sqrt(A),E=Math.atan2(C,p*d);x=Math.sin(x*E)/C,o=Math.sin(o*E)/C}let b=o*d;if(c=c*x+h*b,l=l*x+m*b,u=u*x+v*b,f=f*x+g*b,x===1-o){let C=1/Math.sqrt(c*c+l*l+u*u+f*f);c*=C,l*=C,u*=C,f*=C}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,i,a,r,s){let o=i[a],c=i[a+1],l=i[a+2],u=i[a+3],f=r[s],h=r[s+1],m=r[s+2],v=r[s+3];return e[t]=o*v+u*f+c*m-l*h,e[t+1]=c*v+u*h+l*f-o*m,e[t+2]=l*v+u*m+o*h-c*f,e[t+3]=u*v-o*f-c*h-l*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,a){return this._x=e,this._y=t,this._z=i,this._w=a,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");let i=e._x,a=e._y,r=e._z,s=e._order,o=Math.cos,c=Math.sin,l=o(i/2),u=o(a/2),f=o(r/2),h=c(i/2),m=c(a/2),v=c(r/2);switch(s){case"XYZ":this._x=h*u*f+l*m*v,this._y=l*m*f-h*u*v,this._z=l*u*v+h*m*f,this._w=l*u*f-h*m*v;break;case"YXZ":this._x=h*u*f+l*m*v,this._y=l*m*f-h*u*v,this._z=l*u*v-h*m*f,this._w=l*u*f+h*m*v;break;case"ZXY":this._x=h*u*f-l*m*v,this._y=l*m*f+h*u*v,this._z=l*u*v+h*m*f,this._w=l*u*f-h*m*v;break;case"ZYX":this._x=h*u*f-l*m*v,this._y=l*m*f+h*u*v,this._z=l*u*v-h*m*f,this._w=l*u*f+h*m*v;break;case"YZX":this._x=h*u*f+l*m*v,this._y=l*m*f+h*u*v,this._z=l*u*v-h*m*f,this._w=l*u*f-h*m*v;break;case"XZY":this._x=h*u*f-l*m*v,this._y=l*m*f-h*u*v,this._z=l*u*v+h*m*f,this._w=l*u*f+h*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,a=Math.sin(i);return this._x=e.x*a,this._y=e.y*a,this._z=e.z*a,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],a=t[4],r=t[8],s=t[1],o=t[5],c=t[9],l=t[2],u=t[6],f=t[10],h=i+o+f;if(h>0){let m=.5/Math.sqrt(h+1);this._w=.25/m,this._x=(u-c)*m,this._y=(r-l)*m,this._z=(s-a)*m}else if(i>o&&i>f){let m=2*Math.sqrt(1+i-o-f);this._w=(u-c)/m,this._x=.25*m,this._y=(a+s)/m,this._z=(r+l)/m}else if(o>f){let m=2*Math.sqrt(1+o-i-f);this._w=(r-l)/m,this._x=(a+s)/m,this._y=.25*m,this._z=(c+u)/m}else{let m=2*Math.sqrt(1+f-i-o);this._w=(s-a)/m,this._x=(r+l)/m,this._y=(c+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(D2(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let a=Math.min(1,t/i);return this.slerp(e,a),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return t!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,a=e._y,r=e._z,s=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=i*u+s*o+a*l-r*c,this._y=a*u+s*c+r*o-i*l,this._z=r*u+s*l+i*c-a*o,this._w=s*u-i*o-a*c-r*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,a=this._y,r=this._z,s=this._w,o=s*e._w+i*e._x+a*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=s,this._x=i,this._y=a,this._z=r,this;let c=1-o*o;if(c<=Number.EPSILON){let m=1-t;return this._w=m*s+t*this._w,this._x=m*i+t*this._x,this._y=m*a+t*this._y,this._z=m*r+t*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(c),u=Math.atan2(l,o),f=Math.sin((1-t)*u)/l,h=Math.sin(t*u)/l;return this._w=s*f+this._w*h,this._x=i*f+this._x*h,this._y=a*f+this._y*h,this._z=r*f+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),a=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(a),i*Math.sin(r),i*Math.cos(r),t*Math.sin(a))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}};Me.prototype.isQuaternion=!0;var k=class{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Dr.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Dr.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,a=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*a,this.y=r[1]*t+r[4]*i+r[7]*a,this.z=r[2]*t+r[5]*i+r[8]*a,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,a=this.z,r=e.elements,s=1/(r[3]*t+r[7]*i+r[11]*a+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*a+r[12])*s,this.y=(r[1]*t+r[5]*i+r[9]*a+r[13])*s,this.z=(r[2]*t+r[6]*i+r[10]*a+r[14])*s,this}applyQuaternion(e){let t=this.x,i=this.y,a=this.z,r=e.x,s=e.y,o=e.z,c=e.w,l=c*t+s*a-o*i,u=c*i+o*t-r*a,f=c*a+r*i-s*t,h=-r*t-s*i-o*a;return this.x=l*c+h*-r+u*-o-f*-s,this.y=u*c+h*-s+f*-r-l*-o,this.z=f*c+h*-o+l*-s-u*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,a=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*a,this.y=r[1]*t+r[5]*i+r[9]*a,this.z=r[2]*t+r[6]*i+r[10]*a,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e,t){return t!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,a=e.y,r=e.z,s=t.x,o=t.y,c=t.z;return this.x=a*c-r*o,this.y=r*s-i*c,this.z=i*o-a*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Q0.copy(this).projectOnVector(e),this.sub(Q0)}reflect(e){return this.sub(Q0.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(D2(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,a=this.z-e.z;return t*t+i*i+a*a}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let a=Math.sin(t)*e;return this.x=a*Math.sin(i),this.y=Math.cos(t)*e,this.z=a*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),a=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=a,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,i){return i!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};k.prototype.isVector3=!0;var Q0=new k,Dr=new Me;var z1=class{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6],this.y=a[1]*t+a[4]*i+a[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,i){return i!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),a=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*i-s*a+e.x,this.y=r*a+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};z1.prototype.isVector2=!0;var Tr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},K2={h:0,s:0,l:0},z6={h:0,s:0,l:0};function e3(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function C4(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function t3(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var x1=class{constructor(e,t,i){return t===void 0&&i===void 0?this.set(e):this.setRGB(e,t,i)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,this}setRGB(e,t,i){return this.r=e,this.g=t,this.b=i,this}setHSL(e,t,i){if(e=Er(e,1),t=D2(t,0,1),i=D2(i,0,1),t===0)this.r=this.g=this.b=i;else{let a=i<=.5?i*(1+t):i+t-i*t,r=2*i-a;this.r=e3(r,a,e+1/3),this.g=e3(r,a,e),this.b=e3(r,a,e-1/3)}return this}setStyle(e){function t(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let a,r=i[1],s=i[2];switch(r){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.r=Math.min(255,parseInt(a[1],10))/255,this.g=Math.min(255,parseInt(a[2],10))/255,this.b=Math.min(255,parseInt(a[3],10))/255,t(a[4]),this;if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.r=Math.min(100,parseInt(a[1],10))/100,this.g=Math.min(100,parseInt(a[2],10))/100,this.b=Math.min(100,parseInt(a[3],10))/100,t(a[4]),this;break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s)){let o=parseFloat(a[1])/360,c=parseInt(a[2],10)/100,l=parseInt(a[3],10)/100;return t(a[4]),this.setHSL(o,c,l)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let a=i[1],r=a.length;if(r===3)return this.r=parseInt(a.charAt(0)+a.charAt(0),16)/255,this.g=parseInt(a.charAt(1)+a.charAt(1),16)/255,this.b=parseInt(a.charAt(2)+a.charAt(2),16)/255,this;if(r===6)return this.r=parseInt(a.charAt(0)+a.charAt(1),16)/255,this.g=parseInt(a.charAt(2)+a.charAt(3),16)/255,this.b=parseInt(a.charAt(4)+a.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){let t=Tr[e.toLowerCase()];return t!==void 0?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=C4(e.r),this.g=C4(e.g),this.b=C4(e.b),this}copyLinearToSRGB(e){return this.r=t3(e.r),this.g=t3(e.g),this.b=t3(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return this.r*255<<16^this.g*255<<8^this.b*255<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){let t=this.r,i=this.g,a=this.b,r=Math.max(t,i,a),s=Math.min(t,i,a),o,c,l=(s+r)/2;if(s===r)o=0,c=0;else{let u=r-s;switch(c=l<=.5?u/(r+s):u/(2-r-s),r){case t:o=(i-a)/u+(i<a?6:0);break;case i:o=(a-t)/u+2;break;case a:o=(t-i)/u+4;break}o/=6}return e.h=o,e.s=c,e.l=l,e}getStyle(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"}offsetHSL(e,t,i){return this.getHSL(K2),K2.h+=e,K2.s+=t,K2.l+=i,this.setHSL(K2.h,K2.s,K2.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(K2),e.getHSL(z6);let i=C6(K2.h,z6.h,t),a=C6(K2.s,z6.s,t),r=C6(K2.l,z6.l,t);return this.setHSL(i,a,r),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}};x1.NAMES=Tr;x1.prototype.isColor=!0;x1.prototype.r=1;x1.prototype.g=1;x1.prototype.b=1;var Hr="137";var Vr=0,i3=1,Nr=2;var A6=1,w6=2,z4=3,ke=0,P1=1,J2=2,Rr=1;var U2=0,A4=1,a3=2,r3=3,n3=4,Fr=5,i4=100,Br=101,Pr=102,s3=103,o3=104,Ir=200,kr=201,Ur=202,Or=203,S6=204,_6=205,Gr=206,qr=207,Wr=208,jr=209,Xr=210,Zr=0,Yr=1,$r=2,Et=3,Kr=4,Jr=5,Qr=6,e8=7,G4=0,t8=1,i8=2,O2=0,a8=1,r8=2,n8=3,s8=4,o8=5,c3=300,be=301,Ue=302,Lt=303,Dt=304,a4=306,Tt=307,Ht=1e3,c2=1001,Vt=1002,Q1=1003,l3=1004;var u3=1005;var t2=1006,c8=1007;var r4=1008;var N2=1009,l8=1010,u8=1011,Oe=1012,h8=1013,q4=1014,Q2=1015,ye=1016,f8=1017,d8=1018,Ce=1020,p8=1021,W1=1023,m8=1024,v8=1025,ee=1026,ze=1027,g8=1028,x8=1029,M8=1030,b8=1031,y8=1033,E6=33776,L6=33777,D6=33778,T6=33779,h3=35840,f3=35841,d3=35842,p3=35843,C8=36196,m3=37492,v3=37496,g3=37808,x3=37809,M3=37810,b3=37811,y3=37812,C3=37813,z3=37814,A3=37815,w3=37816,S3=37817,_3=37818,E3=37819,L3=37820,D3=37821,T3=36492;var R2=3e3,I1=3001,z8=3200,A8=3201,H6=0,w8=1;var V6=7680;var S8=519,H3=35044;var V3="300 es",Nt=1035;var U1=new k,N6=new z1,M2=class{constructor(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i===!0,this.usage=H3,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let a=0,r=this.itemSize;a<r;a++)this.array[e+a]=t.array[i+a];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){let t=this.array,i=0;for(let a=0,r=e.length;a<r;a++){let s=e[a];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",a),s=new x1),t[i++]=s.r,t[i++]=s.g,t[i++]=s.b}return this}copyVector2sArray(e){let t=this.array,i=0;for(let a=0,r=e.length;a<r;a++){let s=e[a];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",a),s=new z1),t[i++]=s.x,t[i++]=s.y}return this}copyVector3sArray(e){let t=this.array,i=0;for(let a=0,r=e.length;a<r;a++){let s=e[a];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",a),s=new k),t[i++]=s.x,t[i++]=s.y,t[i++]=s.z}return this}copyVector4sArray(e){let t=this.array,i=0;for(let a=0,r=e.length;a<r;a++){let s=e[a];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",a),s=new q1),t[i++]=s.x,t[i++]=s.y,t[i++]=s.z,t[i++]=s.w}return this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)N6.fromBufferAttribute(this,t),N6.applyMatrix3(e),this.setXY(t,N6.x,N6.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)U1.fromBufferAttribute(this,t),U1.applyMatrix3(e),this.setXYZ(t,U1.x,U1.y,U1.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)U1.x=this.getX(t),U1.y=this.getY(t),U1.z=this.getZ(t),U1.applyMatrix4(e),this.setXYZ(t,U1.x,U1.y,U1.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)U1.x=this.getX(t),U1.y=this.getY(t),U1.z=this.getZ(t),U1.applyNormalMatrix(e),this.setXYZ(t,U1.x,U1.y,U1.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)U1.x=this.getX(t),U1.y=this.getY(t),U1.z=this.getZ(t),U1.transformDirection(e),this.setXYZ(t,U1.x,U1.y,U1.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,a){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=a,this}setXYZW(e,t,i,a,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=a,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==H3&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}};M2.prototype.isBufferAttribute=!0;var Rt=class extends M2{constructor(e,t,i){super(new Uint16Array(e),t,i)}};var Ft=class extends M2{constructor(e,t,i){super(new Uint32Array(e),t,i)}},_8=class extends M2{constructor(e,t,i){super(new Uint16Array(e),t,i)}};_8.prototype.isFloat16BufferAttribute=!0;var z2=class extends M2{constructor(e,t,i){super(new Float32Array(e),t,i)}};var Ge=class{constructor(e=new k(1/0,1/0,1/0),t=new k(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,i=1/0,a=1/0,r=-1/0,s=-1/0,o=-1/0;for(let c=0,l=e.length;c<l;c+=3){let u=e[c],f=e[c+1],h=e[c+2];u<t&&(t=u),f<i&&(i=f),h<a&&(a=h),u>r&&(r=u),f>s&&(s=f),h>o&&(o=h)}return this.min.set(t,i,a),this.max.set(r,s,o),this}setFromBufferAttribute(e){let t=1/0,i=1/0,a=1/0,r=-1/0,s=-1/0,o=-1/0;for(let c=0,l=e.count;c<l;c++){let u=e.getX(c),f=e.getY(c),h=e.getZ(c);u<t&&(t=u),f<i&&(i=f),h<a&&(a=h),u>r&&(r=u),f>s&&(s=f),h>o&&(o=h)}return this.min.set(t,i,a),this.max.set(r,s,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=w4.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0)if(t&&i.attributes!=null&&i.attributes.position!==void 0){let r=i.attributes.position;for(let s=0,o=r.count;s<o;s++)w4.fromBufferAttribute(r,s).applyMatrix4(e.matrixWorld),this.expandByPoint(w4)}else i.boundingBox===null&&i.computeBoundingBox(),N3.copy(i.boundingBox),N3.applyMatrix4(e.matrixWorld),this.union(N3);let a=e.children;for(let r=0,s=a.length;r<s;r++)this.expandByObject(a[r],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,w4),w4.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Bt),R6.subVectors(this.max,Bt),W4.subVectors(e.a,Bt),j4.subVectors(e.b,Bt),X4.subVectors(e.c,Bt),n4.subVectors(j4,W4),s4.subVectors(X4,j4),S4.subVectors(W4,X4);let t=[0,-n4.z,n4.y,0,-s4.z,s4.y,0,-S4.z,S4.y,n4.z,0,-n4.x,s4.z,0,-s4.x,S4.z,0,-S4.x,-n4.y,n4.x,0,-s4.y,s4.x,0,-S4.y,S4.x,0];return!R3(t,W4,j4,X4,R6)||(t=[1,0,0,0,1,0,0,0,1],!R3(t,W4,j4,X4,R6))?!1:(F6.crossVectors(n4,s4),t=[F6.x,F6.y,F6.z],R3(t,W4,j4,X4,R6))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return w4.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(w4).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(qe[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),qe[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),qe[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),qe[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),qe[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),qe[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),qe[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),qe[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(qe),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}};Ge.prototype.isBox3=!0;var qe=[new k,new k,new k,new k,new k,new k,new k,new k],w4=new k,N3=new Ge,W4=new k,j4=new k,X4=new k,n4=new k,s4=new k,S4=new k,Bt=new k,R6=new k,F6=new k,_4=new k;function R3(n,e,t,i,a){for(let r=0,s=n.length-3;r<=s;r+=3){_4.fromArray(n,r);let o=a.x*Math.abs(_4.x)+a.y*Math.abs(_4.y)+a.z*Math.abs(_4.z),c=e.dot(_4),l=t.dot(_4),u=i.dot(_4);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}var F2=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let a=this._listeners[e];if(a!==void 0){let r=a.indexOf(t);r!==-1&&a.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let i=this._listeners[e.type];if(i!==void 0){e.target=this;let a=i.slice(0);for(let r=0,s=a.length;r<s;r++)a[r].call(this,e);e.target=null}}};var c9=new Ge,E8=new k,B6=new k,F3=new k,We=class{constructor(e=new k,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):c9.setFromPoints(e).getCenter(i);let a=0;for(let r=0,s=e.length;r<s;r++)a=Math.max(a,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(a),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){F3.subVectors(e,this.center);let t=F3.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),a=(i-this.radius)*.5;this.center.add(F3.multiplyScalar(a/i)),this.radius+=a}return this}union(e){return this.center.equals(e.center)===!0?B6.set(0,0,1).multiplyScalar(e.radius):B6.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(E8.copy(e.center).add(B6)),this.expandByPoint(E8.copy(e.center).sub(B6)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}};var k1=class{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,i,a,r,s,o,c,l,u,f,h,m,v,g,x){let p=this.elements;return p[0]=e,p[4]=t,p[8]=i,p[12]=a,p[1]=r,p[5]=s,p[9]=o,p[13]=c,p[2]=l,p[6]=u,p[10]=f,p[14]=h,p[3]=m,p[7]=v,p[11]=g,p[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new k1().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,a=1/Z4.setFromMatrixColumn(e,0).length(),r=1/Z4.setFromMatrixColumn(e,1).length(),s=1/Z4.setFromMatrixColumn(e,2).length();return t[0]=i[0]*a,t[1]=i[1]*a,t[2]=i[2]*a,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");let t=this.elements,i=e.x,a=e.y,r=e.z,s=Math.cos(i),o=Math.sin(i),c=Math.cos(a),l=Math.sin(a),u=Math.cos(r),f=Math.sin(r);if(e.order==="XYZ"){let h=s*u,m=s*f,v=o*u,g=o*f;t[0]=c*u,t[4]=-c*f,t[8]=l,t[1]=m+v*l,t[5]=h-g*l,t[9]=-o*c,t[2]=g-h*l,t[6]=v+m*l,t[10]=s*c}else if(e.order==="YXZ"){let h=c*u,m=c*f,v=l*u,g=l*f;t[0]=h+g*o,t[4]=v*o-m,t[8]=s*l,t[1]=s*f,t[5]=s*u,t[9]=-o,t[2]=m*o-v,t[6]=g+h*o,t[10]=s*c}else if(e.order==="ZXY"){let h=c*u,m=c*f,v=l*u,g=l*f;t[0]=h-g*o,t[4]=-s*f,t[8]=v+m*o,t[1]=m+v*o,t[5]=s*u,t[9]=g-h*o,t[2]=-s*l,t[6]=o,t[10]=s*c}else if(e.order==="ZYX"){let h=s*u,m=s*f,v=o*u,g=o*f;t[0]=c*u,t[4]=v*l-m,t[8]=h*l+g,t[1]=c*f,t[5]=g*l+h,t[9]=m*l-v,t[2]=-l,t[6]=o*c,t[10]=s*c}else if(e.order==="YZX"){let h=s*c,m=s*l,v=o*c,g=o*l;t[0]=c*u,t[4]=g-h*f,t[8]=v*f+m,t[1]=f,t[5]=s*u,t[9]=-o*u,t[2]=-l*u,t[6]=m*f+v,t[10]=h-g*f}else if(e.order==="XZY"){let h=s*c,m=s*l,v=o*c,g=o*l;t[0]=c*u,t[4]=-f,t[8]=l*u,t[1]=h*f+g,t[5]=s*u,t[9]=m*f-v,t[2]=v*f-m,t[6]=o*u,t[10]=g*f+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(l9,e,u9)}lookAt(e,t,i){let a=this.elements;return B2.subVectors(e,t),B2.lengthSq()===0&&(B2.z=1),B2.normalize(),o4.crossVectors(i,B2),o4.lengthSq()===0&&(Math.abs(i.z)===1?B2.x+=1e-4:B2.z+=1e-4,B2.normalize(),o4.crossVectors(i,B2)),o4.normalize(),P6.crossVectors(B2,o4),a[0]=o4.x,a[4]=P6.x,a[8]=B2.x,a[1]=o4.y,a[5]=P6.y,a[9]=B2.y,a[2]=o4.z,a[6]=P6.z,a[10]=B2.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,a=t.elements,r=this.elements,s=i[0],o=i[4],c=i[8],l=i[12],u=i[1],f=i[5],h=i[9],m=i[13],v=i[2],g=i[6],x=i[10],p=i[14],d=i[3],A=i[7],b=i[11],C=i[15],E=a[0],T=a[4],_=a[8],P=a[12],F=a[1],M=a[5],D=a[9],z=a[13],H=a[2],V=a[6],L=a[10],N=a[14],U=a[3],Z=a[7],O=a[11],W=a[15];return r[0]=s*E+o*F+c*H+l*U,r[4]=s*T+o*M+c*V+l*Z,r[8]=s*_+o*D+c*L+l*O,r[12]=s*P+o*z+c*N+l*W,r[1]=u*E+f*F+h*H+m*U,r[5]=u*T+f*M+h*V+m*Z,r[9]=u*_+f*D+h*L+m*O,r[13]=u*P+f*z+h*N+m*W,r[2]=v*E+g*F+x*H+p*U,r[6]=v*T+g*M+x*V+p*Z,r[10]=v*_+g*D+x*L+p*O,r[14]=v*P+g*z+x*N+p*W,r[3]=d*E+A*F+b*H+C*U,r[7]=d*T+A*M+b*V+C*Z,r[11]=d*_+A*D+b*L+C*O,r[15]=d*P+A*z+b*N+C*W,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],a=e[8],r=e[12],s=e[1],o=e[5],c=e[9],l=e[13],u=e[2],f=e[6],h=e[10],m=e[14],v=e[3],g=e[7],x=e[11],p=e[15];return v*(+r*c*f-a*l*f-r*o*h+i*l*h+a*o*m-i*c*m)+g*(+t*c*m-t*l*h+r*s*h-a*s*m+a*l*u-r*c*u)+x*(+t*l*f-t*o*m-r*s*f+i*s*m+r*o*u-i*l*u)+p*(-a*o*u-t*c*f+t*o*h+a*s*f-i*s*h+i*c*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let a=this.elements;return e.isVector3?(a[12]=e.x,a[13]=e.y,a[14]=e.z):(a[12]=e,a[13]=t,a[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],a=e[2],r=e[3],s=e[4],o=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],m=e[11],v=e[12],g=e[13],x=e[14],p=e[15],d=f*x*l-g*h*l+g*c*m-o*x*m-f*c*p+o*h*p,A=v*h*l-u*x*l-v*c*m+s*x*m+u*c*p-s*h*p,b=u*g*l-v*f*l+v*o*m-s*g*m-u*o*p+s*f*p,C=v*f*c-u*g*c-v*o*h+s*g*h+u*o*x-s*f*x,E=t*d+i*A+a*b+r*C;if(E===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let T=1/E;return e[0]=d*T,e[1]=(g*h*r-f*x*r-g*a*m+i*x*m+f*a*p-i*h*p)*T,e[2]=(o*x*r-g*c*r+g*a*l-i*x*l-o*a*p+i*c*p)*T,e[3]=(f*c*r-o*h*r-f*a*l+i*h*l+o*a*m-i*c*m)*T,e[4]=A*T,e[5]=(u*x*r-v*h*r+v*a*m-t*x*m-u*a*p+t*h*p)*T,e[6]=(v*c*r-s*x*r-v*a*l+t*x*l+s*a*p-t*c*p)*T,e[7]=(s*h*r-u*c*r+u*a*l-t*h*l-s*a*m+t*c*m)*T,e[8]=b*T,e[9]=(v*f*r-u*g*r-v*i*m+t*g*m+u*i*p-t*f*p)*T,e[10]=(s*g*r-v*o*r+v*i*l-t*g*l-s*i*p+t*o*p)*T,e[11]=(u*o*r-s*f*r-u*i*l+t*f*l+s*i*m-t*o*m)*T,e[12]=C*T,e[13]=(u*g*a-v*f*a+v*i*h-t*g*h-u*i*x+t*f*x)*T,e[14]=(v*o*a-s*g*a-v*i*c+t*g*c+s*i*x-t*o*x)*T,e[15]=(s*f*a-u*o*a+u*i*c-t*f*c-s*i*h+t*o*h)*T,this}scale(e){let t=this.elements,i=e.x,a=e.y,r=e.z;return t[0]*=i,t[4]*=a,t[8]*=r,t[1]*=i,t[5]*=a,t[9]*=r,t[2]*=i,t[6]*=a,t[10]*=r,t[3]*=i,t[7]*=a,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],a=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,a))}makeTranslation(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),a=Math.sin(t),r=1-i,s=e.x,o=e.y,c=e.z,l=r*s,u=r*o;return this.set(l*s+i,l*o-a*c,l*c+a*o,0,l*o+a*c,u*o+i,u*c-a*s,0,l*c-a*o,u*c+a*s,r*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,a,r,s){return this.set(1,i,r,0,e,1,s,0,t,a,1,0,0,0,0,1),this}compose(e,t,i){let a=this.elements,r=t._x,s=t._y,o=t._z,c=t._w,l=r+r,u=s+s,f=o+o,h=r*l,m=r*u,v=r*f,g=s*u,x=s*f,p=o*f,d=c*l,A=c*u,b=c*f,C=i.x,E=i.y,T=i.z;return a[0]=(1-(g+p))*C,a[1]=(m+b)*C,a[2]=(v-A)*C,a[3]=0,a[4]=(m-b)*E,a[5]=(1-(h+p))*E,a[6]=(x+d)*E,a[7]=0,a[8]=(v+A)*T,a[9]=(x-d)*T,a[10]=(1-(h+g))*T,a[11]=0,a[12]=e.x,a[13]=e.y,a[14]=e.z,a[15]=1,this}decompose(e,t,i){let a=this.elements,r=Z4.set(a[0],a[1],a[2]).length(),s=Z4.set(a[4],a[5],a[6]).length(),o=Z4.set(a[8],a[9],a[10]).length();this.determinant()<0&&(r=-r),e.x=a[12],e.y=a[13],e.z=a[14],te.copy(this);let l=1/r,u=1/s,f=1/o;return te.elements[0]*=l,te.elements[1]*=l,te.elements[2]*=l,te.elements[4]*=u,te.elements[5]*=u,te.elements[6]*=u,te.elements[8]*=f,te.elements[9]*=f,te.elements[10]*=f,t.setFromRotationMatrix(te),i.x=r,i.y=s,i.z=o,this}makePerspective(e,t,i,a,r,s){s===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let o=this.elements,c=2*r/(t-e),l=2*r/(i-a),u=(t+e)/(t-e),f=(i+a)/(i-a),h=-(s+r)/(s-r),m=-2*s*r/(s-r);return o[0]=c,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=l,o[9]=f,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=m,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,i,a,r,s){let o=this.elements,c=1/(t-e),l=1/(i-a),u=1/(s-r),f=(t+e)*c,h=(i+a)*l,m=(s+r)*u;return o[0]=2*c,o[4]=0,o[8]=0,o[12]=-f,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-h,o[2]=0,o[6]=0,o[10]=-2*u,o[14]=-m,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let a=0;a<16;a++)if(t[a]!==i[a])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};k1.prototype.isMatrix4=!0;var Z4=new k,te=new k1,l9=new k(0,0,0),u9=new k(1,1,1),o4=new k,P6=new k,B2=new k;var L8=new k1,D8=new Me,c4=class{constructor(e=0,t=0,i=0,a=c4.DefaultOrder){this._x=e,this._y=t,this._z=i,this._order=a}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,a=this._order){return this._x=e,this._y=t,this._z=i,this._order=a,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let a=e.elements,r=a[0],s=a[4],o=a[8],c=a[1],l=a[5],u=a[9],f=a[2],h=a[6],m=a[10];switch(t){case"XYZ":this._y=Math.asin(D2(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-D2(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-f,r),this._z=0);break;case"ZXY":this._x=Math.asin(D2(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-D2(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,m),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(D2(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-f,r)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-D2(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return L8.makeRotationFromQuaternion(e),this.setFromRotationMatrix(L8,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return D8.setFromEuler(this),this.setFromQuaternion(D8,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new k(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}};c4.prototype.isEuler=!0;c4.DefaultOrder="XYZ";c4.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var Pt=class{constructor(){this.mask=1|0}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=4294967295|0}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!=0}isEnabled(e){return(this.mask&(1<<e|0))!=0}};var n2=class{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,i,a,r,s,o,c,l){let u=this.elements;return u[0]=e,u[1]=a,u[2]=o,u[3]=t,u[4]=r,u[5]=c,u[6]=i,u[7]=s,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,a=t.elements,r=this.elements,s=i[0],o=i[3],c=i[6],l=i[1],u=i[4],f=i[7],h=i[2],m=i[5],v=i[8],g=a[0],x=a[3],p=a[6],d=a[1],A=a[4],b=a[7],C=a[2],E=a[5],T=a[8];return r[0]=s*g+o*d+c*C,r[3]=s*x+o*A+c*E,r[6]=s*p+o*b+c*T,r[1]=l*g+u*d+f*C,r[4]=l*x+u*A+f*E,r[7]=l*p+u*b+f*T,r[2]=h*g+m*d+v*C,r[5]=h*x+m*A+v*E,r[8]=h*p+m*b+v*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],a=e[2],r=e[3],s=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*s*u-t*o*l-i*r*u+i*o*c+a*r*l-a*s*c}invert(){let e=this.elements,t=e[0],i=e[1],a=e[2],r=e[3],s=e[4],o=e[5],c=e[6],l=e[7],u=e[8],f=u*s-o*l,h=o*c-u*r,m=l*r-s*c,v=t*f+i*h+a*m;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/v;return e[0]=f*g,e[1]=(a*l-u*i)*g,e[2]=(o*i-a*s)*g,e[3]=h*g,e[4]=(u*t-a*c)*g,e[5]=(a*r-o*t)*g,e[6]=m*g,e[7]=(i*c-l*t)*g,e[8]=(s*t-i*r)*g,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,a,r,s,o){let c=Math.cos(r),l=Math.sin(r);return this.set(i*c,i*l,-i*(c*s+l*o)+s+e,-a*l,a*c,-a*(-l*s+c*o)+o+t,0,0,1),this}scale(e,t){let i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this}rotate(e){let t=Math.cos(e),i=Math.sin(e),a=this.elements,r=a[0],s=a[3],o=a[6],c=a[1],l=a[4],u=a[7];return a[0]=t*r+i*c,a[3]=t*s+i*l,a[6]=t*o+i*u,a[1]=-i*r+t*c,a[4]=-i*s+t*l,a[7]=-i*o+t*u,this}translate(e,t){let i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this}equals(e){let t=this.elements,i=e.elements;for(let a=0;a<9;a++)if(t[a]!==i[a])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};n2.prototype.isMatrix3=!0;var h9=0,T8=new k,Y4=new Me,je=new k1,I6=new k,It=new k,f9=new k,d9=new Me,H8=new k(1,0,0),V8=new k(0,1,0),N8=new k(0,0,1),p9={type:"added"},R8={type:"removed"},j1=class extends F2{constructor(){super();Object.defineProperty(this,"id",{value:h9++}),this.uuid=Ie(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=j1.DefaultUp.clone();let e=new k,t=new c4,i=new Me,a=new k(1,1,1);function r(){i.setFromEuler(t,!1)}function s(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),i._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:a},modelViewMatrix:{value:new k1},normalMatrix:{value:new n2}}),this.matrix=new k1,this.matrixWorld=new k1,this.matrixAutoUpdate=j1.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Pt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Y4.setFromAxisAngle(e,t),this.quaternion.multiply(Y4),this}rotateOnWorldAxis(e,t){return Y4.setFromAxisAngle(e,t),this.quaternion.premultiply(Y4),this}rotateX(e){return this.rotateOnAxis(H8,e)}rotateY(e){return this.rotateOnAxis(V8,e)}rotateZ(e){return this.rotateOnAxis(N8,e)}translateOnAxis(e,t){return T8.copy(e).applyQuaternion(this.quaternion),this.position.add(T8.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(H8,e)}translateY(e){return this.translateOnAxis(V8,e)}translateZ(e){return this.translateOnAxis(N8,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(je.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?I6.copy(e):I6.set(e,t,i);let a=this.parent;this.updateWorldMatrix(!0,!1),It.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?je.lookAt(It,I6,this.up):je.lookAt(I6,It,this.up),this.quaternion.setFromRotationMatrix(je),a&&(je.extractRotation(a.matrixWorld),Y4.setFromRotationMatrix(je),this.quaternion.premultiply(Y4.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(p9)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(R8)),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){let t=this.children[e];t.parent=null,t.dispatchEvent(R8)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),je.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),je.multiply(e.parent.matrixWorld)),e.applyMatrix4(je),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,a=this.children.length;i<a;i++){let s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(It,e,f9),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(It,d9,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,a=t.length;i<a;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,a=t.length;i<a;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,a=t.length;i<a;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){let i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let a=this.children;for(let r=0,s=a.length;r<s;r++)a[r].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let a={};a.uuid=this.uuid,a.type=this.type,this.name!==""&&(a.name=this.name),this.castShadow===!0&&(a.castShadow=!0),this.receiveShadow===!0&&(a.receiveShadow=!0),this.visible===!1&&(a.visible=!1),this.frustumCulled===!1&&(a.frustumCulled=!1),this.renderOrder!==0&&(a.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(a.userData=this.userData),a.layers=this.layers.mask,a.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(a.matrixAutoUpdate=!1),this.isInstancedMesh&&(a.type="InstancedMesh",a.count=this.count,a.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(a.instanceColor=this.instanceColor.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?a.background=this.background.toJSON():this.background.isTexture&&(a.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(a.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){a.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){let f=c[l];r(e.shapes,f)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(a.bindMode=this.bindMode,a.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),a.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));a.material=o}else a.material=r(e.materials,this.material);if(this.children.length>0){a.children=[];for(let o=0;o<this.children.length;o++)a.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){a.animations=[];for(let o=0;o<this.animations.length;o++){let c=this.animations[o];a.animations.push(r(e.animations,c))}}if(t){let o=s(e.geometries),c=s(e.materials),l=s(e.textures),u=s(e.images),f=s(e.shapes),h=s(e.skeletons),m=s(e.animations);o.length>0&&(i.geometries=o),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),u.length>0&&(i.images=u),f.length>0&&(i.shapes=f),h.length>0&&(i.skeletons=h),m.length>0&&(i.animations=m)}return i.object=a,i;function s(o){let c=[];for(let l in o){let u=o[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let a=e.children[i];this.add(a.clone())}return this}};j1.DefaultUp=new k(0,1,0);j1.DefaultMatrixAutoUpdate=!0;j1.prototype.isObject3D=!0;function k6(n){for(let e=n.length-1;e>=0;--e)if(n[e]>65535)return!0;return!1}function E4(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}var m9=0,G2=new k1,B3=new j1,$4=new k,P2=new Ge,kt=new Ge,l2=new k,b2=class extends F2{constructor(){super();Object.defineProperty(this,"id",{value:m9++}),this.uuid=Ie(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(k6(e)?Ft:Rt)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let r=new n2().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}let a=this.attributes.tangent;return a!==void 0&&(a.transformDirection(e),a.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return G2.makeRotationFromQuaternion(e),this.applyMatrix4(G2),this}rotateX(e){return G2.makeRotationX(e),this.applyMatrix4(G2),this}rotateY(e){return G2.makeRotationY(e),this.applyMatrix4(G2),this}rotateZ(e){return G2.makeRotationZ(e),this.applyMatrix4(G2),this}translate(e,t,i){return G2.makeTranslation(e,t,i),this.applyMatrix4(G2),this}scale(e,t,i){return G2.makeScale(e,t,i),this.applyMatrix4(G2),this}lookAt(e){return B3.lookAt(e),B3.updateMatrix(),this.applyMatrix4(B3.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($4).negate(),this.translate($4.x,$4.y,$4.z),this}setFromPoints(e){let t=[];for(let i=0,a=e.length;i<a;i++){let r=e[i];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new z2(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ge);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new k(-1/0,-1/0,-1/0),new k(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,a=t.length;i<a;i++){let r=t[i];P2.setFromBufferAttribute(r),this.morphTargetsRelative?(l2.addVectors(this.boundingBox.min,P2.min),this.boundingBox.expandByPoint(l2),l2.addVectors(this.boundingBox.max,P2.max),this.boundingBox.expandByPoint(l2)):(this.boundingBox.expandByPoint(P2.min),this.boundingBox.expandByPoint(P2.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new We);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new k,1/0);return}if(e){let i=this.boundingSphere.center;if(P2.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];kt.setFromBufferAttribute(o),this.morphTargetsRelative?(l2.addVectors(P2.min,kt.min),P2.expandByPoint(l2),l2.addVectors(P2.max,kt.max),P2.expandByPoint(l2)):(P2.expandByPoint(kt.min),P2.expandByPoint(kt.max))}P2.getCenter(i);let a=0;for(let r=0,s=e.count;r<s;r++)l2.fromBufferAttribute(e,r),a=Math.max(a,i.distanceToSquared(l2));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],c=this.morphTargetsRelative;for(let l=0,u=o.count;l<u;l++)l2.fromBufferAttribute(o,l),c&&($4.fromBufferAttribute(e,l),l2.add($4)),a=Math.max(a,i.distanceToSquared(l2))}this.boundingSphere.radius=Math.sqrt(a),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=e.array,a=t.position.array,r=t.normal.array,s=t.uv.array,o=a.length/3;t.tangent===void 0&&this.setAttribute("tangent",new M2(new Float32Array(4*o),4));let c=t.tangent.array,l=[],u=[];for(let F=0;F<o;F++)l[F]=new k,u[F]=new k;let f=new k,h=new k,m=new k,v=new z1,g=new z1,x=new z1,p=new k,d=new k;function A(F,M,D){f.fromArray(a,F*3),h.fromArray(a,M*3),m.fromArray(a,D*3),v.fromArray(s,F*2),g.fromArray(s,M*2),x.fromArray(s,D*2),h.sub(f),m.sub(f),g.sub(v),x.sub(v);let z=1/(g.x*x.y-x.x*g.y);!isFinite(z)||(p.copy(h).multiplyScalar(x.y).addScaledVector(m,-g.y).multiplyScalar(z),d.copy(m).multiplyScalar(g.x).addScaledVector(h,-x.x).multiplyScalar(z),l[F].add(p),l[M].add(p),l[D].add(p),u[F].add(d),u[M].add(d),u[D].add(d))}let b=this.groups;b.length===0&&(b=[{start:0,count:i.length}]);for(let F=0,M=b.length;F<M;++F){let D=b[F],z=D.start,H=D.count;for(let V=z,L=z+H;V<L;V+=3)A(i[V+0],i[V+1],i[V+2])}let C=new k,E=new k,T=new k,_=new k;function P(F){T.fromArray(r,F*3),_.copy(T);let M=l[F];C.copy(M),C.sub(T.multiplyScalar(T.dot(M))).normalize(),E.crossVectors(_,M);let z=E.dot(u[F])<0?-1:1;c[F*4]=C.x,c[F*4+1]=C.y,c[F*4+2]=C.z,c[F*4+3]=z}for(let F=0,M=b.length;F<M;++F){let D=b[F],z=D.start,H=D.count;for(let V=z,L=z+H;V<L;V+=3)P(i[V+0]),P(i[V+1]),P(i[V+2])}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new M2(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,m=i.count;h<m;h++)i.setXYZ(h,0,0,0);let a=new k,r=new k,s=new k,o=new k,c=new k,l=new k,u=new k,f=new k;if(e)for(let h=0,m=e.count;h<m;h+=3){let v=e.getX(h+0),g=e.getX(h+1),x=e.getX(h+2);a.fromBufferAttribute(t,v),r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),u.subVectors(s,r),f.subVectors(a,r),u.cross(f),o.fromBufferAttribute(i,v),c.fromBufferAttribute(i,g),l.fromBufferAttribute(i,x),o.add(u),c.add(u),l.add(u),i.setXYZ(v,o.x,o.y,o.z),i.setXYZ(g,c.x,c.y,c.z),i.setXYZ(x,l.x,l.y,l.z)}else for(let h=0,m=t.count;h<m;h+=3)a.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),u.subVectors(s,r),f.subVectors(a,r),u.cross(f),i.setXYZ(h+0,u.x,u.y,u.z),i.setXYZ(h+1,u.x,u.y,u.z),i.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}merge(e,t){if(!(e&&e.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);return}t===void 0&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));let i=this.attributes;for(let a in i){if(e.attributes[a]===void 0)continue;let s=i[a].array,o=e.attributes[a],c=o.array,l=o.itemSize*t,u=Math.min(c.length,s.length-l);for(let f=0,h=l;f<u;f++,h++)s[h]=c[f]}return this}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)l2.fromBufferAttribute(e,t),l2.normalize(),e.setXYZ(t,l2.x,l2.y,l2.z)}toNonIndexed(){function e(o,c){let l=o.array,u=o.itemSize,f=o.normalized,h=new l.constructor(c.length*u),m=0,v=0;for(let g=0,x=c.length;g<x;g++){o.isInterleavedBufferAttribute?m=c[g]*o.data.stride+o.offset:m=c[g]*u;for(let p=0;p<u;p++)h[v++]=l[m++]}return new M2(h,u,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new b2,i=this.index.array,a=this.attributes;for(let o in a){let c=a[o],l=e(c,i);t.setAttribute(o,l)}let r=this.morphAttributes;for(let o in r){let c=[],l=r[o];for(let u=0,f=l.length;u<f;u++){let h=l[u],m=e(h,i);c.push(m)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,c=s.length;o<c;o++){let l=s[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let c in i){let l=i[c];e.data.attributes[c]=l.toJSON(e.data)}let a={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let f=0,h=l.length;f<h;f++){let m=l[f];u.push(m.toJSON(e.data))}u.length>0&&(a[c]=u,r=!0)}r&&(e.data.morphAttributes=a,e.data.morphTargetsRelative=this.morphTargetsRelative);let s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let a=e.attributes;for(let l in a){let u=a[l];this.setAttribute(l,u.clone(t))}let r=e.morphAttributes;for(let l in r){let u=[],f=r[l];for(let h=0,m=f.length;h<m;h++)u.push(f[h].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let l=0,u=s.length;l<u;l++){let f=s[l];this.addGroup(f.start,f.count,f.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,e.parameters!==void 0&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}};b2.prototype.isBufferGeometry=!0;var v9=0,T2=class extends F2{constructor(){super();Object.defineProperty(this,"id",{value:v9++}),this.uuid=Ie(),this.name="",this.type="Material",this.fog=!0,this.blending=A4,this.side=ke,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=S6,this.blendDst=_6,this.blendEquation=i4,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Et,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=S8,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=V6,this.stencilZFail=V6,this.stencilZPass=V6,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.alphaWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=i===Rr;continue}let a=this[t];if(a===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}a&&a.isColor?a.set(i):a&&a.isVector3&&i&&i.isVector3?a.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==A4&&(i.blending=this.blending),this.side!==ke&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.alphaWrite=this.alphaWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(i.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=this.flatShading),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData);function a(r){let s=[];for(let o in r){let c=r[o];delete c.metadata,s.push(c)}return s}if(t){let r=a(e.textures),s=a(e.images);r.length>0&&(i.textures=r),s.length>0&&(i.images=s)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let a=t.length;i=new Array(a);for(let r=0;r!==a;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.alphaWrite=e.alphaWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};T2.prototype.isMaterial=!0;var Ut=class extends T2{constructor(e){super();this.type="MeshPhongMaterial",this.color=new x1(16777215),this.specular=new x1(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new x1(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=H6,this.normalScale=new z1(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=G4,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}};Ut.prototype.isMeshPhongMaterial=!0;var Xe=new k,P3=new k,U6=new k,l4=new k,I3=new k,O6=new k,k3=new k,U3=class{constructor(e=new k,t=new k(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Xe)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Xe.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Xe.copy(this.direction).multiplyScalar(t).add(this.origin),Xe.distanceToSquared(e))}distanceSqToSegment(e,t,i,a){P3.copy(e).add(t).multiplyScalar(.5),U6.copy(t).sub(e).normalize(),l4.copy(this.origin).sub(P3);let r=e.distanceTo(t)*.5,s=-this.direction.dot(U6),o=l4.dot(this.direction),c=-l4.dot(U6),l=l4.lengthSq(),u=Math.abs(1-s*s),f,h,m,v;if(u>0)if(f=s*c-o,h=s*o-c,v=r*u,f>=0)if(h>=-v)if(h<=v){let g=1/u;f*=g,h*=g,m=f*(f+s*h+2*o)+h*(s*f+h+2*c)+l}else h=r,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*c)+l;else h=-r,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*c)+l;else h<=-v?(f=Math.max(0,-(-s*r+o)),h=f>0?-r:Math.min(Math.max(-r,-c),r),m=-f*f+h*(h+2*c)+l):h<=v?(f=0,h=Math.min(Math.max(-r,-c),r),m=h*(h+2*c)+l):(f=Math.max(0,-(s*r+o)),h=f>0?r:Math.min(Math.max(-r,-c),r),m=-f*f+h*(h+2*c)+l);else h=s>0?-r:r,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*c)+l;return i&&i.copy(this.direction).multiplyScalar(f).add(this.origin),a&&a.copy(U6).multiplyScalar(h).add(P3),m}intersectSphere(e,t){Xe.subVectors(e.center,this.origin);let i=Xe.dot(this.direction),a=Xe.dot(Xe)-i*i,r=e.radius*e.radius;if(a>r)return null;let s=Math.sqrt(r-a),o=i-s,c=i+s;return o<0&&c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,a,r,s,o,c,l=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,a=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,a=(e.min.x-h.x)*l),u>=0?(r=(e.min.y-h.y)*u,s=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,s=(e.min.y-h.y)*u),i>s||r>a||((r>i||i!==i)&&(i=r),(s<a||a!==a)&&(a=s),f>=0?(o=(e.min.z-h.z)*f,c=(e.max.z-h.z)*f):(o=(e.max.z-h.z)*f,c=(e.min.z-h.z)*f),i>c||o>a)||((o>i||i!==i)&&(i=o),(c<a||a!==a)&&(a=c),a<0)?null:this.at(i>=0?i:a,t)}intersectsBox(e){return this.intersectBox(e,Xe)!==null}intersectTriangle(e,t,i,a,r){I3.subVectors(t,e),O6.subVectors(i,e),k3.crossVectors(I3,O6);let s=this.direction.dot(k3),o;if(s>0){if(a)return null;o=1}else if(s<0)o=-1,s=-s;else return null;l4.subVectors(this.origin,e);let c=o*this.direction.dot(O6.crossVectors(l4,O6));if(c<0)return null;let l=o*this.direction.dot(I3.cross(l4));if(l<0||c+l>s)return null;let u=-o*l4.dot(k3);return u<0?null:this.at(u/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}};var ie=new k,Ze=new k,O3=new k,Ye=new k,K4=new k,J4=new k,F8=new k,G3=new k,q3=new k,W3=new k,ae=class{constructor(e=new k,t=new k,i=new k){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,a){a.subVectors(i,t),ie.subVectors(e,t),a.cross(ie);let r=a.lengthSq();return r>0?a.multiplyScalar(1/Math.sqrt(r)):a.set(0,0,0)}static getBarycoord(e,t,i,a,r){ie.subVectors(a,t),Ze.subVectors(i,t),O3.subVectors(e,t);let s=ie.dot(ie),o=ie.dot(Ze),c=ie.dot(O3),l=Ze.dot(Ze),u=Ze.dot(O3),f=s*l-o*o;if(f===0)return r.set(-2,-1,-1);let h=1/f,m=(l*c-o*u)*h,v=(s*u-o*c)*h;return r.set(1-m-v,v,m)}static containsPoint(e,t,i,a){return this.getBarycoord(e,t,i,a,Ye),Ye.x>=0&&Ye.y>=0&&Ye.x+Ye.y<=1}static getUV(e,t,i,a,r,s,o,c){return this.getBarycoord(e,t,i,a,Ye),c.set(0,0),c.addScaledVector(r,Ye.x),c.addScaledVector(s,Ye.y),c.addScaledVector(o,Ye.z),c}static isFrontFacing(e,t,i,a){return ie.subVectors(i,t),Ze.subVectors(e,t),ie.cross(Ze).dot(a)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,a){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[a]),this}setFromAttributeAndIndices(e,t,i,a){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,a),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ie.subVectors(this.c,this.b),Ze.subVectors(this.a,this.b),ie.cross(Ze).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ae.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ae.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,a,r){return ae.getUV(e,this.a,this.b,this.c,t,i,a,r)}containsPoint(e){return ae.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ae.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,a=this.b,r=this.c,s,o;K4.subVectors(a,i),J4.subVectors(r,i),G3.subVectors(e,i);let c=K4.dot(G3),l=J4.dot(G3);if(c<=0&&l<=0)return t.copy(i);q3.subVectors(e,a);let u=K4.dot(q3),f=J4.dot(q3);if(u>=0&&f<=u)return t.copy(a);let h=c*f-u*l;if(h<=0&&c>=0&&u<=0)return s=c/(c-u),t.copy(i).addScaledVector(K4,s);W3.subVectors(e,r);let m=K4.dot(W3),v=J4.dot(W3);if(v>=0&&m<=v)return t.copy(r);let g=m*l-c*v;if(g<=0&&l>=0&&v<=0)return o=l/(l-v),t.copy(i).addScaledVector(J4,o);let x=u*v-m*f;if(x<=0&&f-u>=0&&m-v>=0)return F8.subVectors(r,a),o=(f-u)/(f-u+(m-v)),t.copy(a).addScaledVector(F8,o);let p=1/(x+g+h);return s=g*p,o=h*p,t.copy(i).addScaledVector(K4,s).addScaledVector(J4,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};var Q4=class extends T2{constructor(e){super();this.type="MeshBasicMaterial",this.color=new x1(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=G4,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}};Q4.prototype.isMeshBasicMaterial=!0;var B8=new k1,et=new U3,j3=new We,u4=new k,h4=new k,f4=new k,X3=new k,Z3=new k,Y3=new k,G6=new k,q6=new k,W6=new k,j6=new z1,X6=new z1,Z6=new z1,$3=new k,Y6=new k,u2=class extends j1{constructor(e=new b2,t=new Q4){super();this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,i=Object.keys(t);if(i.length>0){let a=t[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=a.length;r<s;r++){let o=a[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){let i=this.geometry,a=this.material,r=this.matrixWorld;if(a===void 0||(i.boundingSphere===null&&i.computeBoundingSphere(),j3.copy(i.boundingSphere),j3.applyMatrix4(r),e.ray.intersectsSphere(j3)===!1)||(B8.copy(r).invert(),et.copy(e.ray).applyMatrix4(B8),i.boundingBox!==null&&et.intersectsBox(i.boundingBox)===!1))return;let s;if(i.isBufferGeometry){let o=i.index,c=i.attributes.position,l=i.morphAttributes.position,u=i.morphTargetsRelative,f=i.attributes.uv,h=i.attributes.uv2,m=i.groups,v=i.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=m.length;g<x;g++){let p=m[g],d=a[p.materialIndex],A=Math.max(p.start,v.start),b=Math.min(o.count,Math.min(p.start+p.count,v.start+v.count));for(let C=A,E=b;C<E;C+=3){let T=o.getX(C),_=o.getX(C+1),P=o.getX(C+2);s=$6(this,d,e,et,c,l,u,f,h,T,_,P),s&&(s.faceIndex=Math.floor(C/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{let g=Math.max(0,v.start),x=Math.min(o.count,v.start+v.count);for(let p=g,d=x;p<d;p+=3){let A=o.getX(p),b=o.getX(p+1),C=o.getX(p+2);s=$6(this,a,e,et,c,l,u,f,h,A,b,C),s&&(s.faceIndex=Math.floor(p/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,x=m.length;g<x;g++){let p=m[g],d=a[p.materialIndex],A=Math.max(p.start,v.start),b=Math.min(c.count,Math.min(p.start+p.count,v.start+v.count));for(let C=A,E=b;C<E;C+=3){let T=C,_=C+1,P=C+2;s=$6(this,d,e,et,c,l,u,f,h,T,_,P),s&&(s.faceIndex=Math.floor(C/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{let g=Math.max(0,v.start),x=Math.min(c.count,v.start+v.count);for(let p=g,d=x;p<d;p+=3){let A=p,b=p+1,C=p+2;s=$6(this,a,e,et,c,l,u,f,h,A,b,C),s&&(s.faceIndex=Math.floor(p/3),t.push(s))}}}else i.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}};u2.prototype.isMesh=!0;function g9(n,e,t,i,a,r,s,o){let c;if(e.side===P1?c=i.intersectTriangle(s,r,a,!0,o):c=i.intersectTriangle(a,r,s,e.side!==J2,o),c===null)return null;Y6.copy(o),Y6.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(Y6);return l<t.near||l>t.far?null:{distance:l,point:Y6.clone(),object:n}}function $6(n,e,t,i,a,r,s,o,c,l,u,f){u4.fromBufferAttribute(a,l),h4.fromBufferAttribute(a,u),f4.fromBufferAttribute(a,f);let h=n.morphTargetInfluences;if(r&&h){G6.set(0,0,0),q6.set(0,0,0),W6.set(0,0,0);for(let v=0,g=r.length;v<g;v++){let x=h[v],p=r[v];x!==0&&(X3.fromBufferAttribute(p,l),Z3.fromBufferAttribute(p,u),Y3.fromBufferAttribute(p,f),s?(G6.addScaledVector(X3,x),q6.addScaledVector(Z3,x),W6.addScaledVector(Y3,x)):(G6.addScaledVector(X3.sub(u4),x),q6.addScaledVector(Z3.sub(h4),x),W6.addScaledVector(Y3.sub(f4),x)))}u4.add(G6),h4.add(q6),f4.add(W6)}n.isSkinnedMesh&&(n.boneTransform(l,u4),n.boneTransform(u,h4),n.boneTransform(f,f4));let m=g9(n,e,t,i,u4,h4,f4,$3);if(m){o&&(j6.fromBufferAttribute(o,l),X6.fromBufferAttribute(o,u),Z6.fromBufferAttribute(o,f),m.uv=ae.getUV($3,u4,h4,f4,j6,X6,Z6,new z1)),c&&(j6.fromBufferAttribute(c,l),X6.fromBufferAttribute(c,u),Z6.fromBufferAttribute(c,f),m.uv2=ae.getUV($3,u4,h4,f4,j6,X6,Z6,new z1));let v={a:l,b:u,c:f,normal:new k,materialIndex:0};ae.getNormal(u4,h4,f4,v.normal),m.face=v}return m}var tt,Ot=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{tt===void 0&&(tt=E4("canvas")),tt.width=e.width,tt.height=e.height;let i=tt.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=tt}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){let t=E4("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let a=i.getImageData(0,0,e.width,e.height),r=a.data;for(let s=0;s<r.length;s++)r[s]=C4(r[s]/255)*255;return i.putImageData(a,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(C4(t[i]/255)*255):t[i]=C4(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}};var x9=0,$1=class extends F2{constructor(e=$1.DEFAULT_IMAGE,t=$1.DEFAULT_MAPPING,i=c2,a=c2,r=t2,s=r4,o=W1,c=N2,l=1,u=R2){super();Object.defineProperty(this,"id",{value:x9++}),this.uuid=Ie(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=a,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new z1(0,0),this.repeat=new z1(1,1),this.center=new z1(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new n2,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(this.image!==void 0){let a=this.image;if(a.uuid===void 0&&(a.uuid=Ie()),!t&&e.images[a.uuid]===void 0){let r;if(Array.isArray(a)){r=[];for(let s=0,o=a.length;s<o;s++)a[s].isDataTexture?r.push(K3(a[s].image)):r.push(K3(a[s]))}else r=K3(a);e.images[a.uuid]={uuid:a.uuid,url:r}}i.image=a.uuid}return JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==c3)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ht:e.x=e.x-Math.floor(e.x);break;case c2:e.x=e.x<0?0:1;break;case Vt:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ht:e.y=e.y-Math.floor(e.y);break;case c2:e.y=e.y<0?0:1;break;case Vt:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&this.version++}};$1.DEFAULT_IMAGE=void 0;$1.DEFAULT_MAPPING=c3;$1.prototype.isTexture=!0;function K3(n){return typeof HTMLImageElement!="undefined"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&n instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&n instanceof ImageBitmap?Ot.getDataURL(n):n.data?{data:Array.prototype.slice.call(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var P8={specular:1515554,color:15790320,shininess:60,flatShading:!0},q2={diceColor:"#202020",textColor:"#ffffff"},re=class{constructor(e,t,i={diceColor:"#202020",textColor:"#aaaaaa"}){this.w=e;this.h=t;this.options=i;this.scale=50;this.labels=[" ","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"];this.fontFace="Arial";this.options={...q2,...i}}setColor({diceColor:e,textColor:t}){e&&(this.options.diceColor=e),t&&(this.options.textColor=t)}get radius(){return this.scale*this.scaleFactor}get diceColor(){return this.options.diceColor}get textColor(){return this.options.textColor}get buffer(){return this.geometry.geometry}create(){this.textureSize=this.calculateTextureSize(this.scale/2+this.scale*this.margin)*2;let e=this.getGeometry(),t=this.getMaterials();return this.geometry=new u2(e,t),this.geometry.receiveShadow=!0,this.geometry.castShadow=!0,this.body.position.set(0+this.radius*2*Math.random(),0+this.radius*2*Math.random(),0+this.radius*4),this.body.velocity.x=500*Math.random()*2-1,this.body.velocity.y=500*Math.random()*2-1,this.body.angularVelocity.x=100*Math.random(),this.body.angularVelocity.y=100*Math.random(),this}getGeometry(){let e=new Array(this.vertices.length);for(let i=0;i<this.vertices.length;++i)e[i]=new k().fromArray(this.vertices[i]).normalize();this.chamferGeometry=this.getChamferGeometry(e);let t=this.makeGeometry(this.chamferGeometry.vectors,this.chamferGeometry.faces);return this.shape=this.makeShape(e),this.body=new i1({mass:this.mass,shape:this.shape}),t}makeShape(e){let t=new Array(e.length),i=new Array(this.faces.length);for(let a=0;a<e.length;++a){let r=e[a];t[a]=new y(r.x*this.radius,r.y*this.radius,r.z*this.radius)}for(let a=0;a<this.faces.length;++a)i[a]=this.faces[a].slice(0,this.faces[a].length-1);return this.shapeData={vertices:t,faces:i},new Qe({vertices:t,faces:i})}getChamferGeometry(e){let t=[],i=[],a=new Array(e.length);for(let r=0;r<e.length;++r)a[r]=[];for(let r=0;r<this.faces.length;++r){let s=this.faces[r],o=s.length-1,c=new k,l=new Array(o);for(let u=0;u<o;++u){let f=e[s[u]].clone();c.add(f),a[s[u]].push(l[u]=t.push(f)-1)}c.divideScalar(o);for(let u=0;u<o;++u){let f=t[l[u]];f.subVectors(f,c).multiplyScalar(this.chamfer).addVectors(f,c)}l.push(s[o]),i.push(l)}for(let r=0;r<this.faces.length-1;++r)for(let s=r+1;s<this.faces.length;++s){let o=[],c=-1;for(let l=0;l<this.faces[r].length-1;++l){let u=this.faces[s].indexOf(this.faces[r][l]);u>=0&&u<this.faces[s].length-1&&(c>=0&&l!==c+1?o.unshift([r,l],[s,u]):o.push([r,l],[s,u]),c=l)}o.length===4&&i.push([i[o[0][0]][o[0][1]],i[o[1][0]][o[1][1]],i[o[3][0]][o[3][1]],i[o[2][0]][o[2][1]],-1])}for(let r=0;r<a.length;++r){let s=a[r],o=[s[0]],c=s.length-1;for(;c;){for(let l=this.faces.length;l<i.length;++l){let u=i[l].indexOf(o[o.length-1]);if(u>=0&&u<4){--u==-1&&(u=3);let f=i[l][u];if(s.indexOf(f)>=0){o.push(f);break}}}--c}o.push(-1),i.push(o)}return{vectors:t,faces:i}}makeGeometry(e,t){let i=new b2;for(let f=0;f<e.length;++f)e[f]=e[f].multiplyScalar(this.radius);let a=[],r=[],s=[],o=new k,c=new k,l,u=0;for(let f=0;f<t.length;++f){let h=t[f],m=h.length-1,v=Math.PI*2/m;l=h[m]+1;for(let x=0;x<m-2;++x)a.push(...e[h[0]].toArray()),a.push(...e[h[x+1]].toArray()),a.push(...e[h[x+2]].toArray()),o.subVectors(e[h[x+2]],e[h[x+1]]),c.subVectors(e[h[0]],e[h[x+1]]),o.cross(c),o.normalize(),r.push(...o.toArray()),r.push(...o.toArray()),r.push(...o.toArray()),s.push((Math.cos(this.af)+1+this.tab)/2/(1+this.tab),(Math.sin(this.af)+1+this.tab)/2/(1+this.tab)),s.push((Math.cos(v*(x+1)+this.af)+1+this.tab)/2/(1+this.tab),(Math.sin(v*(x+1)+this.af)+1+this.tab)/2/(1+this.tab)),s.push((Math.cos(v*(x+2)+this.af)+1+this.tab)/2/(1+this.tab),(Math.sin(v*(x+2)+this.af)+1+this.tab)/2/(1+this.tab));let g=(m-2)*3;for(let x=0;x<g/3;x++)i.addGroup(u,3,l),u+=3}return i.setAttribute("position",new z2(a,3)),i.setAttribute("normal",new z2(r,3)),i.setAttribute("uv",new z2(s,2)),i.boundingSphere=new We(new k,this.radius),i}getMaterials(){let e=[];for(let t=0;t<this.labels.length;t++){let i=this.createTextTexture(t);e.push(new Ut(Object.assign({},P8,{map:i})))}return e}calculateTextureSize(e){return Math.max(128,Math.pow(2,Math.floor(Math.log(e)/Math.log(2))))}createTextTexture(e){let t=this.labels[e];if(t==null)return null;let i=createEl("canvas");i.width=i.height=this.textureSize;let a=i.height/2,r=i.width/2,{context:s,fontsize:o}=this.getContext(i),c=s.measureText("M").width*1.4,l=t.split(`
`);l.length>1&&(o=o/l.length,s.font=`${o}pt '${this.fontFace}'`,c=s.measureText("M").width*1.2,a-=c*l.length/2);for(let f=0,h=l.length;f<h;f++){let m=l[f].trim();s.fillText(l[f],r,a),(m=="6"||m=="9")&&s.fillText(" .",r,a),a+=c*1.5}let u=new $1(i);return u.needsUpdate=!0,i.detach(),u}getContext(e){let t=e.getContext("2d",{alpha:!0});t.clearRect(0,0,e.width,e.height);let i=e.width/(1+2*this.margin);return this.sides==100&&(i*=.75),t.font=`${i}pt '${this.fontFace}'`,t.fillStyle=this.diceColor,t.fillRect(0,0,e.width,e.height),t.textAlign="center",t.textBaseline="middle",(this.sides==10||this.sides==100)&&(t.translate(e.width/2,e.height/2),t.rotate(60*Math.PI/180),t.translate(-e.width/2,-e.height/2)),t.fillStyle=this.textColor,{context:t,fontsize:i}}clone(){return{body:new i1({mass:this.mass,shape:this.shape}),geometry:this.geometry.clone(),values:this.values}}},J3=class extends re{constructor(e,t,i=q2){super(e,t,i);this.sides=20;this.tab=-.2;this.af=-Math.PI/4/2;this.chamfer=.955;this.vertices=[];this.faces=[[0,11,5,1],[0,5,1,2],[0,1,7,3],[0,7,10,4],[0,10,11,5],[1,5,9,6],[5,11,4,7],[11,10,2,8],[10,7,6,9],[7,1,8,10],[3,9,4,11],[3,4,2,12],[3,2,6,13],[3,6,8,14],[3,8,9,15],[4,9,5,16],[2,4,11,17],[6,2,10,18],[8,6,7,19],[9,8,1,20]];this.scaleFactor=1;this.values=[...Array(20).keys()];this.margin=1;this.mass=400;let a=(1+Math.sqrt(5))/2;this.vertices=[[-1,a,0],[1,a,0],[-1,-a,0],[1,-a,0],[0,-1,a],[0,1,a],[0,-1,-a],[0,1,-a],[a,0,-1],[a,0,1],[-a,0,-1],[-a,0,1]]}},Q3=class extends re{constructor(e,t,i=q2){super(e,t,i);this.mass=350;this.sides=12;this.tab=.2;this.af=-Math.PI/4/2;this.chamfer=.968;this.vertices=[];this.faces=[[2,14,4,12,0,1],[15,9,11,19,3,2],[16,10,17,7,6,3],[6,7,19,11,18,4],[6,18,2,0,16,5],[18,11,9,14,2,6],[1,17,10,8,13,7],[1,13,5,15,3,8],[13,8,12,4,5,9],[5,4,14,9,15,10],[0,12,8,10,16,11],[3,19,7,17,1,12]];this.scaleFactor=.9;this.values=[...Array(12).keys()];this.margin=1;let a=(1+Math.sqrt(5))/2,r=1/a;this.vertices=[[0,r,a],[0,r,-a],[0,-r,a],[0,-r,-a],[a,0,r],[a,0,-r],[-a,0,r],[-a,0,-r],[r,a,0],[r,-a,0],[-r,a,0],[-r,-a,0],[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]}},ei=class extends re{constructor(e,t,i=q2){super(e,t,i);this.mass=350;this.sides=10;this.tab=0;this.af=-Math.PI*6/5;this.chamfer=.945;this.vertices=[];this.faces=[[5,7,11,0],[4,2,10,1],[1,3,11,2],[0,8,10,3],[7,9,11,4],[8,6,10,5],[9,1,11,6],[2,0,10,7],[3,5,11,8],[6,4,10,9],[1,0,2,-1],[1,2,3,-1],[3,2,4,-1],[3,4,5,-1],[5,4,6,-1],[5,6,7,-1],[7,6,8,-1],[7,8,9,-1],[9,8,0,-1],[9,0,1,-1]];this.scaleFactor=.9;this.values=[...Array(10).keys()];this.margin=1;for(let a=0,r=0;a<10;++a,r+=Math.PI*2/10)this.vertices.push([Math.cos(r),Math.sin(r),.105*(a%2?1:-1)]);this.vertices.push([0,0,-1]),this.vertices.push([0,0,1])}},ti=class extends re{constructor(e,t,i=q2){super(e,t,i);this.labels=["","00","10","20","30","40","50","60","70","80","90"];this.sides=100;this.mass=350;this.tab=0;this.af=-Math.PI*6/5;this.chamfer=.945;this.vertices=[];this.faces=[[5,7,11,0],[4,2,10,1],[1,3,11,2],[0,8,10,3],[7,9,11,4],[8,6,10,5],[9,1,11,6],[2,0,10,7],[3,5,11,8],[6,4,10,9],[1,0,2,-1],[1,2,3,-1],[3,2,4,-1],[3,4,5,-1],[5,4,6,-1],[5,6,7,-1],[7,6,8,-1],[7,8,9,-1],[9,8,0,-1],[9,0,1,-1]];this.scaleFactor=.9;this.values=[...Array(10).keys()];this.margin=1;for(let a=0,r=0;a<10;++a,r+=Math.PI*2/10)this.vertices.push([Math.cos(r),Math.sin(r),.105*(a%2?1:-1)]);this.vertices.push([0,0,-1]),this.vertices.push([0,0,1])}},ii=class extends re{constructor(){super(...arguments);this.mass=340;this.sides=8;this.tab=0;this.af=-Math.PI/4/2;this.chamfer=.965;this.vertices=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]];this.faces=[[0,2,4,1],[0,4,3,2],[0,3,5,3],[0,5,2,4],[1,3,4,5],[1,4,2,6],[1,2,5,7],[1,5,3,8]];this.scaleFactor=1;this.values=[...Array(8).keys()];this.margin=1.2}},ai=class extends re{constructor(){super(...arguments);this.mass=300;this.tab=.1;this.af=Math.PI/4;this.chamfer=.96;this.vertices=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]];this.faces=[[0,3,2,1,1],[1,2,6,5,2],[0,1,5,4,3],[3,7,6,2,4],[0,4,7,3,5],[4,5,6,7,6]];this.scaleFactor=.9;this.sides=6;this.margin=1;this.values=[...Array(6).keys()]}},ri=class extends re{constructor(){super(...arguments);this.mass=300;this.tab=.1;this.af=Math.PI/4;this.chamfer=.96;this.vertices=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]];this.faces=[[0,3,2,1,1],[1,2,6,5,2],[0,1,5,4,3],[3,7,6,2,4],[0,4,7,3,5],[4,5,6,7,6]];this.scaleFactor=.9;this.sides=6;this.margin=1;this.labels=["","","+","-"," ","+","-"," "];this.values=[null,1,-1,0,1,-1,0]}},ni=class extends re{constructor(){super(...arguments);this.mass=300;this.tab=-.1;this.af=Math.PI*7/6;this.chamfer=.96;this.vertices=[[1,1,1],[-1,-1,1],[-1,1,-1],[1,-1,-1]];this.faces=[[1,0,2,1],[0,1,3,2],[0,3,2,3],[1,2,3,4]];this.scaleFactor=1.2;this.sides=4;this.margin=1;this.d4FaceTexts=[[[],[0,0,0],[2,4,3],[1,3,4],[2,1,4],[1,2,3]],[[],[0,0,0],[2,3,4],[3,1,4],[2,4,1],[3,2,1]],[[],[0,0,0],[4,3,2],[3,4,1],[4,2,1],[3,1,2]],[[],[0,0,0],[4,2,3],[1,4,3],[4,1,2],[1,3,2]]];this.faceTexts=this.d4FaceTexts[0];this.values=[...Array(4).keys()]}getMaterials(){let e=[];for(let t=0;t<this.d4FaceTexts[0].length;++t){let i=null;i=this.createTextTexture(t),e.push(new Ut(Object.assign({},P8,{map:i})))}return e}createTextTexture(e){let t=document.createElement("canvas"),i=t.getContext("2d"),a=this.calculateTextureSize(this.radius/2+this.radius*2)*2;t.width=t.height=a,i.font=`${a/5}pt '${this.fontFace}'`,i.fillStyle=this.diceColor,i.fillRect(0,0,t.width,t.height),i.textAlign="center",i.textBaseline="middle",i.fillStyle=this.textColor;for(let s in this.faceTexts[e])i.fillText(`${this.faceTexts[e][s]}`,t.width/2,t.height/2-a*.3),i.translate(t.width/2,t.height/2),i.rotate(Math.PI*2/3),i.translate(-t.width/2,-t.height/2);let r=new $1(t);return r.needsUpdate=!0,r}updateMaterialsForValue(e){e<0&&(e+=4),this.faceTexts=this.d4FaceTexts[e],this.geometry.material=this.getMaterials()}},K6=class extends re{constructor(){super(...arguments);this.fontFace="DICE_ROLLER_GENESYS_FONT"}},si=class extends K6{constructor(e,t,i=q2){super(e,t,i);this.mass=350;this.sides=12;this.tab=.2;this.af=-Math.PI/4/2;this.chamfer=.968;this.vertices=[];this.faces=[[2,14,4,12,0,1],[15,9,11,19,3,2],[16,10,17,7,6,3],[6,7,19,11,18,4],[6,18,2,0,16,5],[18,11,9,14,2,6],[1,17,10,8,13,7],[1,13,5,15,3,8],[13,8,12,4,5,9],[5,4,14,9,15,10],[0,12,8,10,16,11],[3,19,7,17,1,12]];this.scaleFactor=.9;this.values=[...Array(12).keys()];this.margin=1;let a=(1+Math.sqrt(5))/2,r=1/a;this.vertices=[[0,r,a],[0,r,-a],[0,-r,a],[0,-r,-a],[a,0,r],[a,0,-r],[-a,0,r],[-a,0,-r],[r,a,0],[r,-a,0],[-r,a,0],[-r,-a,0],[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]}},oi=class extends si{constructor(e,t,i=q2){super(e,t,i);this.labels=["","",`a
a`,"a",`a
a`,"x","s",`s
a`,"s",`s
a`,`s
s`,`s
a`,`s
s`,""];this.setColor({diceColor:"#FEF035",textColor:"#000000"})}},ci=class extends si{constructor(e,t,i=q2){super(e,t,i);this.labels=["","",`t
t`,"t",`t
t`,"t",`t
f`,"f",`t
f`,"f",`f
f`,"y",`f
f`,""];this.setColor({diceColor:"#751317",textColor:"#FFFFFF"})}},li=class extends K6{constructor(){super(...arguments);this.mass=340;this.sides=8;this.tab=0;this.af=-Math.PI/4/2;this.chamfer=.965;this.vertices=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]];this.faces=[[0,2,4,1],[0,4,3,2],[0,3,5,3],[0,5,2,4],[1,3,4,5],[1,4,2,6],[1,2,5,7],[1,5,3,8]];this.scaleFactor=1;this.values=[...Array(8).keys()];this.margin=1.2}},ui=class extends li{constructor(e,t,i=q2){super(e,t,i);this.labels=["","","s","a",`s
a`,`s
s`,"a","s",`a
a`,""];this.setColor({diceColor:"#46AC4E",textColor:"#000000"})}},hi=class extends li{constructor(e,t,i=q2){super(e,t,i);this.labels=["","","t","f",`f
t`,"t","",`t
t`,`f
f`,"t",""];this.setColor({diceColor:"#52287E",textColor:"#FFFFFF"})}},fi=class extends K6{constructor(){super(...arguments);this.mass=300;this.tab=.1;this.af=Math.PI/4;this.chamfer=.96;this.vertices=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]];this.faces=[[0,3,2,1,1],[1,2,6,5,2],[0,1,5,4,3],[3,7,6,2,4],[0,4,7,3,5],[4,5,6,7,6]];this.scaleFactor=.9;this.sides=6;this.margin=1;this.values=[null,1,-1,0,1,-1,0]}},di=class extends fi{constructor(e,t,i=q2){super(e,t,i);this.labels=["","","","","s",`s
a`,`a
a`,"a","",""];this.setColor({diceColor:"#76CDDB",textColor:"#000000"})}},pi=class extends fi{constructor(e,t,i=q2){super(e,t,i);this.labels=["","","","t","f","",""];this.setColor({diceColor:"#000000",textColor:"#FFFFFF"})}};var M9={pos:{x:0+100*Math.random(),y:0+100*Math.random(),z:0+250},velocity:{x:600*(Math.random()*2+1),y:750*(Math.random()*2+1),z:0},angular:{x:200*Math.random(),y:200*Math.random(),z:100*Math.random()},axis:{x:Math.random(),y:Math.random(),z:Math.random(),w:Math.random()}},L4=class{constructor(e,t,i){this.w=e;this.h=t;this.data=i;this.scale=50;this.stopped=!1;this.iteration=0;this.vector={...M9};this.exploded=!1;this.rerolled=0;this.geometry=i.geometry,this.body=i.body}generateVector(e){let t=Math.sqrt(e.x*e.x+e.y*e.y),i=(Math.random()+3)*t,a={x:e.x/t,y:e.y/t},r=this.makeRandomVector(a),s={x:this.w*(r.x>0?-1:1)*.9,y:this.h*(r.y>0?-1:1)*.9,z:Math.random()*200+200},o=Math.abs(r.x/r.y);o>1?s.y/=o:s.x*=o;let c=this.makeRandomVector(a),l={x:c.x*i,y:c.y*i,z:-10},u={x:-(Math.random()*r.y*5+this.inertia*r.y),y:Math.random()*r.x*5+this.inertia*r.x,z:0},f={x:Math.random(),y:Math.random(),z:Math.random(),w:Math.random()};return{pos:s,velocity:l,angular:u,axis:f}}makeRandomVector(e){let t=Math.random()*Math.PI/5-Math.PI/5/2,i={x:e.x*Math.cos(t)-e.y*Math.sin(t),y:e.x*Math.sin(t)+e.y*Math.cos(t)};return i.x==0&&(i.x=.01),i.y==0&&(i.y=.01),i}get buffer(){return this.geometry.geometry}get result(){return this.getUpsideValue()}getUpsideValue(){let e=new k(0,0,this.sides==4?-1:1),t,i=Math.PI*2,a=this.buffer.getAttribute("normal").array;for(let s=0,o=this.buffer.groups.length;s<o;++s){let c=this.buffer.groups[s];if(c.materialIndex==0)continue;let l=s*9,f=new k(a[l],a[l+1],a[l+2]).clone().applyQuaternion(new O1(this.body.quaternion.x,this.body.quaternion.y,this.body.quaternion.z,this.body.quaternion.w)).angleTo(e);f<i&&(i=f,t=c)}let r=t.materialIndex-1;return this.sides==10&&r==0&&(r=10),this.data.values?.[r]??r}shiftUpperValue(e){let t=this.geometry.geometry.clone(),i=this.getUpsideValue();for(let a=0,r=t.groups.length;a<r;++a){let s=t.groups[a].materialIndex;if(s!==0){for(s+=e-i-1;s>this.sides;)s-=this.sides;for(;s<1;)s+=this.sides;t.groups[a].materialIndex=s+1}}this.updateMaterialsForValue(e-i),this.geometry.geometry=t}resetBody(){this.body.vlambda=new y,this.body.position=new y,this.body.previousPosition=new y,this.body.initPosition=new y,this.body.velocity=new y,this.body.initVelocity=new y,this.body.force=new y,this.body.torque=new y,this.body.quaternion=new O1,this.body.initQuaternion=new O1,this.body.angularVelocity=new y,this.body.initAngularVelocity=new y,this.body.interpolatedPosition=new y,this.body.interpolatedQuaternion=new O1,this.body.inertia=new y,this.body.invInertia=new y,this.body.invInertiaWorld=new _2,this.body.invInertiaSolve=new y,this.body.invInertiaWorldSolve=new _2,this.body.wlambda=new y,this.body.updateMassProperties()}updateMaterialsForValue(e){}set(){this.geometry.position.set(this.body.position.x,this.body.position.y,this.body.position.z),this.geometry.quaternion.set(this.body.quaternion.x,this.body.quaternion.y,this.body.quaternion.z,this.body.quaternion.w)}create(){this.body.position.set(this.vector.pos.x,this.vector.pos.y,this.vector.pos.z),this.body.quaternion.setFromAxisAngle(new y(this.vector.axis.x,this.vector.axis.y,this.vector.axis.z),this.vector.axis.w*Math.PI*2),this.body.angularVelocity.set(this.vector.angular.x,this.vector.angular.y,this.vector.angular.z),this.body.velocity.set(this.vector.velocity.x,this.vector.velocity.y,this.vector.velocity.z),this.body.linearDamping=.1,this.body.angularDamping=.1}},mi=class extends L4{constructor(e,t,i,a){super(e,t,i);this.w=e;this.h=t;this.data=i;this.sides=20;this.inertia=6;a&&(this.vector=this.generateVector(a)),this.create()}},vi=class extends L4{constructor(e,t,i,a){super(e,t,i);this.w=e;this.h=t;this.data=i;this.sides=12;this.inertia=8;a&&(this.vector=this.generateVector(a)),this.create()}},D4=class extends L4{constructor(e,t,i,a,r=!1){super(e,t,i);this.w=e;this.h=t;this.data=i;this.isPercentile=r;this.sides=10;this.inertia=9;a&&(this.vector=this.generateVector(a)),this.create()}},gi=class extends L4{constructor(e,t,i,a){super(e,t,i);this.w=e;this.h=t;this.data=i;this.sides=8;this.inertia=10;a&&(this.vector=this.generateVector(a)),this.create()}},xi=class extends L4{constructor(e,t,i,a){super(e,t,i);this.w=e;this.h=t;this.data=i;this.sides=6;this.inertia=13;a&&(this.vector=this.generateVector(a)),this.create()}},Mi=class extends L4{constructor(e,t,i,a){super(e,t,i);this.w=e;this.h=t;this.data=i;this.sides=4;this.inertia=5;a&&(this.vector=this.generateVector(a)),this.create()}};var bi=new k,b9=new k,y9=new n2,ne=class{constructor(e=new k(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,a){return this.normal.set(e,t,i),this.constant=a,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let a=bi.subVectors(i,t).cross(b9.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(a,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){let i=e.delta(bi),a=this.normal.dot(i);if(a===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/a;return r<0||r>1?null:t.copy(i).multiplyScalar(r).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||y9.getNormalMatrix(e),a=this.coplanarPoint(bi).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-a.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};ne.prototype.isPlane=!0;var it=new We,J6=new k,T4=class{constructor(e=new ne,t=new ne,i=new ne,a=new ne,r=new ne,s=new ne){this.planes=[e,t,i,a,r,s]}set(e,t,i,a,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(a),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){let t=this.planes,i=e.elements,a=i[0],r=i[1],s=i[2],o=i[3],c=i[4],l=i[5],u=i[6],f=i[7],h=i[8],m=i[9],v=i[10],g=i[11],x=i[12],p=i[13],d=i[14],A=i[15];return t[0].setComponents(o-a,f-c,g-h,A-x).normalize(),t[1].setComponents(o+a,f+c,g+h,A+x).normalize(),t[2].setComponents(o+r,f+l,g+m,A+p).normalize(),t[3].setComponents(o-r,f-l,g-m,A-p).normalize(),t[4].setComponents(o-s,f-u,g-v,A-d).normalize(),t[5].setComponents(o+s,f+u,g+v,A+d).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),it.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(it)}intersectsSprite(e){return it.center.set(0,0,0),it.radius=.7071067811865476,it.applyMatrix4(e.matrixWorld),this.intersectsSphere(it)}intersectsSphere(e){let t=this.planes,i=e.center,a=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)<a)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let a=t[i];if(J6.x=a.normal.x>0?e.max.x:e.min.x,J6.y=a.normal.y>0?e.max.y:e.min.y,J6.z=a.normal.z>0?e.max.z:e.min.z,a.distanceToPoint(J6)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function Q6(){let n=null,e=!1,t=null,i=null;function a(r,s){t(r,s),i=n.requestAnimationFrame(a)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(a),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function I8(n,e){let t=e.isWebGL2,i=new WeakMap;function a(l,u){let f=l.array,h=l.usage,m=n.createBuffer();n.bindBuffer(u,m),n.bufferData(u,f,h),l.onUploadCallback();let v=n.FLOAT;return f instanceof Float32Array?v=n.FLOAT:f instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):f instanceof Uint16Array?l.isFloat16BufferAttribute?t?v=n.HALF_FLOAT:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):v=n.UNSIGNED_SHORT:f instanceof Int16Array?v=n.SHORT:f instanceof Uint32Array?v=n.UNSIGNED_INT:f instanceof Int32Array?v=n.INT:f instanceof Int8Array?v=n.BYTE:(f instanceof Uint8Array||f instanceof Uint8ClampedArray)&&(v=n.UNSIGNED_BYTE),{buffer:m,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:l.version}}function r(l,u,f){let h=u.array,m=u.updateRange;n.bindBuffer(f,l),m.count===-1?n.bufferSubData(f,0,h):(t?n.bufferSubData(f,m.offset*h.BYTES_PER_ELEMENT,h,m.offset,m.count):n.bufferSubData(f,m.offset*h.BYTES_PER_ELEMENT,h.subarray(m.offset,m.offset+m.count)),m.count=-1)}function s(l){return l.isInterleavedBufferAttribute&&(l=l.data),i.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);let u=i.get(l);u&&(n.deleteBuffer(u.buffer),i.delete(l))}function c(l,u){if(l.isGLBufferAttribute){let h=i.get(l);(!h||h.version<l.version)&&i.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);let f=i.get(l);f===void 0?i.set(l,a(l,u)):f.version<l.version&&(r(f.buffer,l,u),f.version=l.version)}return{get:s,remove:o,update:c}}var $e=class extends b2{constructor(e=1,t=1,i=1,a=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:a,heightSegments:r,depthSegments:s};let o=this;a=Math.floor(a),r=Math.floor(r),s=Math.floor(s);let c=[],l=[],u=[],f=[],h=0,m=0;v("z","y","x",-1,-1,i,t,e,s,r,0),v("z","y","x",1,-1,i,t,-e,s,r,1),v("x","z","y",1,1,e,i,t,a,s,2),v("x","z","y",1,-1,e,i,-t,a,s,3),v("x","y","z",1,-1,e,t,i,a,r,4),v("x","y","z",-1,-1,e,t,-i,a,r,5),this.setIndex(c),this.setAttribute("position",new z2(l,3)),this.setAttribute("normal",new z2(u,3)),this.setAttribute("uv",new z2(f,2));function v(g,x,p,d,A,b,C,E,T,_,P){let F=b/T,M=C/_,D=b/2,z=C/2,H=E/2,V=T+1,L=_+1,N=0,U=0,Z=new k;for(let O=0;O<L;O++){let W=O*M-z;for(let X=0;X<V;X++){let Q=X*F-D;Z[g]=Q*d,Z[x]=W*A,Z[p]=H,l.push(Z.x,Z.y,Z.z),Z[g]=0,Z[x]=0,Z[p]=E>0?1:-1,u.push(Z.x,Z.y,Z.z),f.push(X/T),f.push(1-O/_),N+=1}}for(let O=0;O<_;O++)for(let W=0;W<T;W++){let X=h+W+V*O,Q=h+W+V*(O+1),a1=h+(W+1)+V*(O+1),B=h+(W+1)+V*O;c.push(X,Q,B),c.push(Q,a1,B),U+=6}o.addGroup(m,U,P),m+=U,h+=N}}static fromJSON(e){return new $e(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var H4=class extends b2{constructor(e=1,t=1,i=1,a=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:a};let r=e/2,s=t/2,o=Math.floor(i),c=Math.floor(a),l=o+1,u=c+1,f=e/o,h=t/c,m=[],v=[],g=[],x=[];for(let p=0;p<u;p++){let d=p*h-s;for(let A=0;A<l;A++){let b=A*f-r;v.push(b,-d,0),g.push(0,0,1),x.push(A/o),x.push(1-p/c)}}for(let p=0;p<c;p++)for(let d=0;d<o;d++){let A=d+l*p,b=d+l*(p+1),C=d+1+l*(p+1),E=d+1+l*p;m.push(A,b,E),m.push(b,C,E)}this.setIndex(m),this.setAttribute("position",new z2(v,3)),this.setAttribute("normal",new z2(g,3)),this.setAttribute("uv",new z2(x,2))}static fromJSON(e){return new H4(e.width,e.height,e.widthSegments,e.heightSegments)}};function Ke(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let a=n[t][i];a&&(a.isColor||a.isMatrix3||a.isMatrix4||a.isVector2||a.isVector3||a.isVector4||a.isTexture||a.isQuaternion)?e[t][i]=a.clone():Array.isArray(a)?e[t][i]=a.slice():e[t][i]=a}}return e}function p2(n){let e={};for(let t=0;t<n.length;t++){let i=Ke(n[t]);for(let a in i)e[a]=i[a]}return e}var k8={clone:Ke,merge:p2};var U8=`
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`;var O8=`
void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}
`;var se=class extends T2{constructor(e){super();this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=U8,this.fragmentShader=O8,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ke(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let a in this.uniforms){let s=this.uniforms[a].value;s&&s.isTexture?t.uniforms[a]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[a]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[a]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[a]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[a]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[a]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[a]={type:"m4",value:s.toArray()}:t.uniforms[a]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;let i={};for(let a in this.extensions)this.extensions[a]===!0&&(i[a]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}};se.prototype.isShaderMaterial=!0;var G8=`
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vUv ).g;
#endif
`;var q8=`
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif
`;var W8=`
#ifdef USE_ALPHATEST
if ( diffuseColor.a < alphaTest ) discard;
#endif
`;var j8=`
#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif
`;var X8=`
#ifdef USE_AOMAP
// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_ENVMAP ) && defined( STANDARD )
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
#endif
`;var Z8=`
#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif
`;var Y8=`
vec3 transformed = vec3( position );
`;var $8=`
vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif
`;var K8=`
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
} // validated
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
// Original approximation by Christophe Schlick '94
// float fresnel = pow( 1.0 - dotVH, 5.0 );
// Optimized variant (presented by Epic at SIGGRAPH '13)
// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated
// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
float a2 = pow2( alpha );
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
// Microfacet Models for Refraction through Rough Surfaces - equation (33)
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// alpha is "roughness squared" in Disney\u2019s reparameterization
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1
return RECIPROCAL_PI * a2 / pow2( denom );
}
// GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {
float alpha = pow2( roughness ); // UE4's roughness
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
return F * ( V * D );
}
// Rect Area Light
// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines
// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt
// code: https://github.com/selfshadow/ltc_code/
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
const float LUT_BIAS = 0.5 / LUT_SIZE;
float dotNV = saturate( dot( N, V ) );
// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
uv = uv * LUT_SCALE + LUT_BIAS;
return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
// Real-Time Area Lighting: a Journey from Research to Production (p.102)
// An approximation of the form factor of a horizon-clipped rectangle.
float l = length( f );
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
float x = dot( v1, v2 );
float y = abs( x );
// rational polynomial approximation to theta / sin( theta ) / 2PI
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
float b = 3.4175940 + ( 4.1616724 + y ) * y;
float v = a / b;
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
// bail if point is on back side of plane of light
// assumes ccw winding order of light vertices
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
vec3 lightNormal = cross( v1, v2 );
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
// construct orthonormal basis around N
vec3 T1, T2;
T1 = normalize( V - N * dot( V, N ) );
T2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system
// compute transform
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
// transform rect
vec3 coords[ 4 ];
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
// project rect onto sphere
coords[ 0 ] = normalize( coords[ 0 ] );
coords[ 1 ] = normalize( coords[ 1 ] );
coords[ 2 ] = normalize( coords[ 2 ] );
coords[ 3 ] = normalize( coords[ 3 ] );
// calculate vector form factor
vec3 vectorFormFactor = vec3( 0.0 );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
// adjust for horizon clipping
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
/*
// alternate method of adjusting for horizon clipping (see referece)
// refactoring required
float len = length( vectorFormFactor );
float z = vectorFormFactor.z / len;
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
const float LUT_BIAS = 0.5 / LUT_SIZE;
// tabulated horizon-clipped sphere, apparently...
vec2 uv = vec2( z * 0.5 + 0.5, len );
uv = uv * LUT_SCALE + LUT_BIAS;
float scale = texture2D( ltc_2, uv ).w;
float result = len * scale;
*/
return vec3( result );
}
// End Rect Area Light
float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {
// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
} // validated
#if defined( USE_SHEEN )
// https://github.com/google/filament/blob/master/shaders/src/brdf.fs
float D_Charlie( float roughness, float dotNH ) {
float alpha = pow2( roughness );
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF"
float invAlpha = 1.0 / alpha;
float cos2h = dotNH * dotNH;
float sin2h = max( 1.0 - cos2h, 0.0078125 ); // 2^(-14/2), so sin2h^2 > 0 in fp16
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
// https://github.com/google/filament/blob/master/shaders/src/brdf.fs
float V_Neubelt( float dotNV, float dotNL ) {
// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float D = D_Charlie( sheenRoughness, dotNH );
float V = V_Neubelt( dotNV, dotNL );
return sheenColor * ( D * V );
}
#endif
`;var J8=`
#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen
// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf
// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)
vec2 dHdxy_fwd() {
vec2 dSTdx = dFdx( vUv );
vec2 dSTdy = dFdy( vUv );
float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
return vec2( dBx, dBy );
}
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
vec3 vN = surf_norm; // normalized
vec3 R1 = cross( vSigmaY, vN );
vec3 R2 = cross( vN, vSigmaX );
float fDet = dot( vSigmaX, R1 ) * faceDirection;
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
#endif
`;var Q8=`
#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
bool clipped = true;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
}
#pragma unroll_loop_end
if ( clipped ) discard;
#endif
#endif
`;var en=`
#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif
`;var tn=`
#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif
`;var an=`
#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif
`;var rn=`
#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif
`;var nn=`
#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif
`;var sn=`
#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
varying vec3 vColor;
#endif
`;var on=`
#if defined( USE_COLOR_ALPHA )
vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.xyz *= instanceColor.xyz;
#endif
`;var cn=`
#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
// <tonemapping_pars_fragment> may have defined saturate() already
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.
// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
float precisionSafeLength( vec3 v ) { return length( v ); }
#else
float precisionSafeLength( vec3 v ) {
float maxComponent = max3( abs( v ) );
return length( v / maxComponent ) * maxComponent;
}
#endif
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
struct GeometricContext {
vec3 position;
vec3 normal;
vec3 viewDir;
#ifdef USE_CLEARCOAT
vec3 clearcoatNormal;
#endif
};
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
// dir can be either a direction vector or a normal vector
// upper-left 3x3 of matrix is assumed to be orthogonal
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
mat3 tmp;
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
return tmp;
}
// https://en.wikipedia.org/wiki/Relative_luminance
float linearToRelativeLuminance( const in vec3 color ) {
vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
return dot( weights, color.rgb );
}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
// dir is assumed to be unit length
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
return vec2( u, v );
}
`;var ln=`
#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_maxMipLevel 8.0
#define cubeUV_minMipLevel 4.0
#define cubeUV_maxTileSize 256.0
#define cubeUV_minTileSize 16.0
// These shader functions convert between the UV coordinates of a single face of
// a cubemap, the 0-5 integer index of a cube face, and the direction vector for
// sampling a textureCube (not generally normalized ).
float getFace( vec3 direction ) {
vec3 absDirection = abs( direction );
float face = - 1.0;
if ( absDirection.x > absDirection.z ) {
if ( absDirection.x > absDirection.y )
face = direction.x > 0.0 ? 0.0 : 3.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
} else {
if ( absDirection.z > absDirection.y )
face = direction.z > 0.0 ? 2.0 : 5.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
}
return face;
}
// RH coordinate system; PMREM face-indexing convention
vec2 getUV( vec3 direction, float face ) {
vec2 uv;
if ( face == 0.0 ) {
uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x
} else if ( face == 1.0 ) {
uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y
} else if ( face == 2.0 ) {
uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z
} else if ( face == 3.0 ) {
uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x
} else if ( face == 4.0 ) {
uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y
} else {
uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z
}
return 0.5 * ( uv + 1.0 );
}
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
float face = getFace( direction );
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
mipInt = max( mipInt, cubeUV_minMipLevel );
float faceSize = exp2( mipInt );
float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );
vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;
if ( face > 2.0 ) {
uv.y += faceSize;
face -= 3.0;
}
uv.x += face * faceSize;
if ( mipInt < cubeUV_maxMipLevel ) {
uv.y += 2.0 * cubeUV_maxTileSize;
}
uv.y += filterInt * 2.0 * cubeUV_minTileSize;
uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );
uv *= texelSize;
return texture2D( envMap, uv ).rgb;
}
// These defines must match with PMREMGenerator
#define r0 1.0
#define v0 0.339
#define m0 - 2.0
#define r1 0.8
#define v1 0.276
#define m1 - 1.0
#define r4 0.4
#define v4 0.046
#define m4 2.0
#define r5 0.305
#define v5 0.016
#define m5 3.0
#define r6 0.21
#define v6 0.0038
#define m6 4.0
float roughnessToMip( float roughness ) {
float mip = 0.0;
if ( roughness >= r1 ) {
mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
} else if ( roughness >= r4 ) {
mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
} else if ( roughness >= r5 ) {
mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
} else if ( roughness >= r6 ) {
mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
} else {
mip = - 2.0 * log2( 1.16 * roughness ); // 1.16 = 1.79^0.25
}
return mip;
}
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );
float mipF = fract( mip );
float mipInt = floor( mip );
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
if ( mipF == 0.0 ) {
return vec4( color0, 1.0 );
} else {
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
#endif
`;var un=`
vec3 transformedNormal = objectNormal;
#ifdef USE_INSTANCING
// this is in lieu of a per-instance normal-matrix
// shear transforms in the instance matrix are not supported
mat3 m = mat3( instanceMatrix );
transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
transformedNormal = m * transformedNormal;
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#ifdef FLIP_SIDED
transformedTangent = - transformedTangent;
#endif
#endif
`;var hn=`
#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif
`;var fn=`
#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
#endif
`;var dn=`
#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vUv );
totalEmissiveRadiance *= emissiveColor.rgb;
#endif
`;var pn=`
#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif
`;var mn=`
gl_FragColor = linearToOutputTexel( gl_FragColor );
`;var vn=`
vec4 LinearToLinear( in vec4 value ) {
return value;
}
vec4 LinearTosRGB( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}
`;var gn=`
#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
// Transforming Normal Vectors with the Inverse Transformation
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
#else
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
#endif
#else
vec3 reflectVec = vReflect;
#endif
#ifdef ENVMAP_TYPE_CUBE
vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
#else
vec4 envColor = vec4( 0.0 );
#endif
#ifdef ENVMAP_BLENDING_MULTIPLY
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_MIX )
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_ADD )
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif
`;var xn=`
#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif
`;var Mn=`
#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
uniform float refractionRatio;
#else
varying vec3 vReflect;
#endif
#endif
`;var bn=`
#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
#else
varying vec3 vReflect;
uniform float refractionRatio;
#endif
#endif
`;var yn=`
#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
#endif
`;var Cn=`
#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif
`;var zn=`
#ifdef USE_FOG
varying float vFogDepth;
#endif
`;var An=`
#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif
`;var wn=`
#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif
`;var Sn=`
#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
// dotNL will be from -1.0 to 1.0
float dotNL = dot( normal, lightDirection );
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
#ifdef USE_GRADIENTMAP
return vec3( texture2D( gradientMap, coord ).r );
#else
return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
#endif
}
`;var _n=`
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
#ifndef PHYSICALLY_CORRECT_LIGHTS
lightMapIrradiance *= PI;
#endif
reflectedLight.indirectDiffuse += lightMapIrradiance;
#endif
`;var En=`
#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif
`;var Ln=`
vec3 diffuse = vec3( 1.0 );
GeometricContext geometry;
geometry.position = mvPosition.xyz;
geometry.normal = normalize( transformedNormal );
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
GeometricContext backGeometry;
backGeometry.position = geometry.position;
backGeometry.normal = -geometry.normal;
backGeometry.viewDir = geometry.viewDir;
vLightFront = vec3( 0.0 );
vIndirectFront = vec3( 0.0 );
#ifdef DOUBLE_SIDED
vLightBack = vec3( 0.0 );
vIndirectBack = vec3( 0.0 );
#endif
IncidentLight directLight;
float dotNL;
vec3 directLightColor_Diffuse;
vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
#ifdef DOUBLE_SIDED
vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
#endif
#if NUM_POINT_LIGHTS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
getPointLightInfo( pointLights[ i ], geometry, directLight );
dotNL = dot( geometry.normal, directLight.direction );
directLightColor_Diffuse = directLight.color;
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
#ifdef DOUBLE_SIDED
vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
#endif
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHTS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
getSpotLightInfo( spotLights[ i ], geometry, directLight );
dotNL = dot( geometry.normal, directLight.direction );
directLightColor_Diffuse = directLight.color;
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
#ifdef DOUBLE_SIDED
vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
#endif
}
#pragma unroll_loop_end
#endif
#if NUM_DIR_LIGHTS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
dotNL = dot( geometry.normal, directLight.direction );
directLightColor_Diffuse = directLight.color;
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
#ifdef DOUBLE_SIDED
vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
#endif
}
#pragma unroll_loop_end
#endif
#if NUM_HEMI_LIGHTS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
#ifdef DOUBLE_SIDED
vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
#endif
}
#pragma unroll_loop_end
#endif
`;var Dn=`
uniform bool receiveShadow;
uniform vec3 ambientLightColor;
uniform vec3 lightProbe[ 9 ];
// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere
// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
// normal is assumed to have unit length
float x = normal.x, y = normal.y, z = normal.z;
// band 0
vec3 result = shCoefficients[ 0 ] * 0.886227;
// band 1
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
// band 2
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor;
return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
#if defined ( PHYSICALLY_CORRECT_LIGHTS )
// based upon Frostbite 3 Moving to Physically-based Rendering
// page 32, equation 26: E[window1]
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
return distanceFalloff;
#else
if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
}
return 1.0;
#endif
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
struct DirectionalLight {
vec3 direction;
vec3 color;
};
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
light.color = directionalLight.color;
light.direction = directionalLight.direction;
light.visible = true;
}
#endif
#if NUM_POINT_LIGHTS > 0
struct PointLight {
vec3 position;
vec3 color;
float distance;
float decay;
};
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
// light is an out parameter as having it as a return value caused compiler errors on some devices
void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
vec3 lVector = pointLight.position - geometry.position;
light.direction = normalize( lVector );
float lightDistance = length( lVector );
light.color = pointLight.color;
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
}
#endif
#if NUM_SPOT_LIGHTS > 0
struct SpotLight {
vec3 position;
vec3 direction;
vec3 color;
float distance;
float decay;
float coneCos;
float penumbraCos;
};
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
// light is an out parameter as having it as a return value caused compiler errors on some devices
void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
vec3 lVector = spotLight.position - geometry.position;
light.direction = normalize( lVector );
float angleCos = dot( light.direction, spotLight.direction );
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
if ( spotAttenuation > 0.0 ) {
float lightDistance = length( lVector );
light.color = spotLight.color * spotAttenuation;
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
} else {
light.color = vec3( 0.0 );
light.visible = false;
}
}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
struct RectAreaLight {
vec3 color;
vec3 position;
vec3 halfWidth;
vec3 halfHeight;
};
// Pre-computed values of LinearTransformedCosine approximation of BRDF
// BRDF approximation Texture is 64x64
uniform sampler2D ltc_1; // RGBA Float
uniform sampler2D ltc_2; // RGBA Float
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
struct HemisphereLight {
vec3 direction;
vec3 skyColor;
vec3 groundColor;
};
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
float dotNL = dot( normal, hemiLight.direction );
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
return irradiance;
}
#endif
`;var Tn=`
#if defined( USE_ENVMAP )
#ifdef ENVMAP_MODE_REFRACTION
uniform float refractionRatio;
#endif
vec3 getIBLIrradiance( const in vec3 normal ) {
#if defined( ENVMAP_TYPE_CUBE_UV )
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
return PI * envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
#if defined( ENVMAP_TYPE_CUBE_UV )
vec3 reflectVec;
#ifdef ENVMAP_MODE_REFLECTION
reflectVec = reflect( - viewDir, normal );
// Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
#else
reflectVec = refract( - viewDir, normal, refractionRatio );
#endif
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
return envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
#endif
`;var Hn=`
ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;
`;var Vn=`
varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
#define Material_LightProbeLOD( material ) (0)
`;var Nn=`
BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;
`;var Rn=`
varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
float specularShininess;
float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong
#define Material_LightProbeLOD( material ) (0)
`;var Fn=`
PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.
material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
#ifdef SPECULAR
float specularIntensityFactor = specularIntensity;
vec3 specularColorFactor = specularColor;
#ifdef USE_SPECULARINTENSITYMAP
specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;
#endif
#ifdef USE_SPECULARCOLORMAP
specularColorFactor *= texture2D( specularColorMap, vUv ).rgb;
#endif
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
#else
float specularIntensityFactor = 1.0;
vec3 specularColorFactor = vec3( 1.0 );
material.specularF90 = 1.0;
#endif
material.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
material.clearcoat = clearcoat;
material.clearcoatRoughness = clearcoatRoughness;
material.clearcoatF0 = vec3( 0.04 );
material.clearcoatF90 = 1.0;
#ifdef USE_CLEARCOATMAP
material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
#endif
material.clearcoat = saturate( material.clearcoat ); // Burley clearcoat model
material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
material.clearcoatRoughness += geometryRoughness;
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_SHEEN
material.sheenColor = sheenColor;
#ifdef USE_SHEENCOLORMAP
material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;
#endif
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
#ifdef USE_SHEENROUGHNESSMAP
material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;
#endif
#endif
`;var Bn=`
struct PhysicalMaterial {
vec3 diffuseColor;
float roughness;
vec3 specularColor;
float specularF90;
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
vec3 clearcoatF0;
float clearcoatF90;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
float sheenRoughness;
#endif
};
// temporary
vec3 clearcoatSpecular = vec3( 0.0 );
vec3 sheenSpecular = vec3( 0.0 );
// This is a curve-fit approxmation to the "Charlie sheen" BRDF integrated over the hemisphere from
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF". The analysis can be found
// in the Sheen section of https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {
float dotNV = saturate( dot( normal, viewDir ) );
float r2 = roughness * roughness;
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
return saturate( DG * RECIPROCAL_PI );
}
// Analytical approximation of the DFG LUT, one half of the
// split-sum approximation used in indirect specular lighting.
// via 'environmentBRDF' from "Physically Based Shading on Mobile"
// https://www.unrealengine.com/blog/physically-based-shading-on-mobile
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
vec4 r = roughness * c0 + c1;
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
vec2 fab = DFGApprox( normal, viewDir, roughness );
return specularColor * fab.x + specularF90 * fab.y;
}
// Fdez-Ag\xFCera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"
// Approximates multiscattering in order to preserve energy.
// http://www.jcgt.org/published/0008/01/03/
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
vec2 fab = DFGApprox( normal, viewDir, roughness );
vec3 FssEss = specularColor * fab.x + specularF90 * fab.y;
float Ess = fab.x + fab.y;
float Ems = 1.0 - Ess;
vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21
vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
singleScatter += FssEss;
multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 normal = geometry.normal;
vec3 viewDir = geometry.viewDir;
vec3 position = geometry.position;
vec3 lightPos = rectAreaLight.position;
vec3 halfWidth = rectAreaLight.halfWidth;
vec3 halfHeight = rectAreaLight.halfHeight;
vec3 lightColor = rectAreaLight.color;
float roughness = material.roughness;
vec3 rectCoords[ 4 ];
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction
rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
vec2 uv = LTC_Uv( normal, viewDir, roughness );
vec4 t1 = texture2D( ltc_1, uv );
vec4 t2 = texture2D( ltc_2, uv );
mat3 mInv = mat3(
vec3( t1.x, 0, t1.y ),
vec3( 0, 1, 0 ),
vec3( t1.z, 0, t1.w )
);
// LTC Fresnel Approximation by Stephen Hill
// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
#ifdef USE_CLEARCOAT
float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
vec3 ccIrradiance = dotNLcc * directLight.color;
clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
#endif
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
#ifdef USE_CLEARCOAT
clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
#endif
// Both indirect specular and indirect diffuse light accumulate here
vec3 singleScattering = vec3( 0.0 );
vec3 multiScattering = vec3( 0.0 );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
reflectedLight.indirectSpecular += radiance * singleScattering;
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct RE_Direct_Physical
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}
`;var Pn=`
/**
* This is a template that can be used to light a material, it uses pluggable
* RenderEquations (RE)for specific lighting scenarios.
*
* Instructions for use:
* - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined
* - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???
* - Create a material parameter that is to be passed as the third parameter to your lighting functions.
*
* TODO:
* - Add area light support.
* - Add sphere light support.
* - Add diffuse light probe (irradiance cubemap) support.
*/
GeometricContext geometry;
geometry.position = - vViewPosition;
geometry.normal = normal;
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
#ifdef USE_CLEARCOAT
geometry.clearcoatNormal = clearcoatNormal;
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
pointLight = pointLights[ i ];
getPointLightInfo( pointLight, geometry, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
pointLightShadow = pointLightShadows[ i ];
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
RE_Direct( directLight, geometry, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
SpotLight spotLight;
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
spotLight = spotLights[ i ];
getSpotLightInfo( spotLight, geometry, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometry, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
DirectionalLight directionalLight;
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
directionalLight = directionalLights[ i ];
getDirectionalLightInfo( directionalLight, geometry, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometry, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
RectAreaLight rectAreaLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
rectAreaLight = rectAreaLights[ i ];
RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
vec3 iblIrradiance = vec3( 0.0 );
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
}
#pragma unroll_loop_end
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif
`;var In=`
#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
#ifndef PHYSICALLY_CORRECT_LIGHTS
lightMapIrradiance *= PI;
#endif
irradiance += lightMapIrradiance;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
iblIrradiance += getIBLIrradiance( geometry.normal );
#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
#endif
#endif
`;var kn=`
#if defined( RE_IndirectDiffuse )
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
#endif
`;var Un=`
#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
// Doing a strict comparison with == 1.0 can cause noise artifacts
// on some platforms. See issue #17623.
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif
`;var On=`
#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif
`;var Gn=`
#ifdef USE_LOGDEPTHBUF
#ifdef USE_LOGDEPTHBUF_EXT
varying float vFragDepth;
varying float vIsPerspective;
#else
uniform float logDepthBufFC;
#endif
#endif
`;var qn=`
#ifdef USE_LOGDEPTHBUF
#ifdef USE_LOGDEPTHBUF_EXT
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#else
if ( isPerspectiveMatrix( projectionMatrix ) ) {
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
gl_Position.z *= gl_Position.w;
}
#endif
#endif
`;var Wn=`
#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vUv );
#ifdef DECODE_VIDEO_TEXTURE
// inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)
sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
#endif
diffuseColor *= sampledDiffuseColor;
#endif
`;var jn=`
#ifdef USE_MAP
uniform sampler2D map;
#endif
`;var Xn=`
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#ifdef USE_MAP
diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif
`;var Zn=`
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
uniform mat3 uvTransform;
#endif
#ifdef USE_MAP
uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif
`;var Yn=`
float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vUv );
// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
metalnessFactor *= texelMetalness.b;
#endif
`;var $n=`
#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif
`;var Kn=`
#ifdef USE_MORPHNORMALS
// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:
// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)
// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting
objectNormal *= morphTargetBaseInfluence;
#ifdef MORPHTARGETS_TEXTURE
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];
}
#else
objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
#endif
#endif
`;var Jn=`
#ifdef USE_MORPHTARGETS
uniform float morphTargetBaseInfluence;
#ifdef MORPHTARGETS_TEXTURE
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
uniform sampler2DArray morphTargetsTexture;
uniform vec2 morphTargetsTextureSize;
vec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {
float texelIndex = float( vertexIndex * stride + offset );
float y = floor( texelIndex / morphTargetsTextureSize.x );
float x = texelIndex - y * morphTargetsTextureSize.x;
vec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );
return texture( morphTargetsTexture, morphUV ).xyz;
}
#else
#ifndef USE_MORPHNORMALS
uniform float morphTargetInfluences[ 8 ];
#else
uniform float morphTargetInfluences[ 4 ];
#endif
#endif
#endif
`;var Qn=`
#ifdef USE_MORPHTARGETS
// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:
// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)
// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting
transformed *= morphTargetBaseInfluence;
#ifdef MORPHTARGETS_TEXTURE
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#ifndef USE_MORPHNORMALS
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];
#else
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];
#endif
}
#else
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
#ifndef USE_MORPHNORMALS
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
#endif
#endif
#endif
`;var es=`
float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
// Workaround for Adreno GPUs not able to do dFdx( vViewPosition )
vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
#ifdef USE_TANGENT
vec3 tangent = normalize( vTangent );
vec3 bitangent = normalize( vBitangent );
#ifdef DOUBLE_SIDED
tangent = tangent * faceDirection;
bitangent = bitangent * faceDirection;
#endif
#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
mat3 vTBN = mat3( tangent, bitangent, normal );
#endif
#endif
#endif
// non perturbed normal for clearcoat among others
vec3 geometryNormal = normal;
`;var ts=`
#ifdef OBJECTSPACE_NORMALMAP
normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals
#ifdef FLIP_SIDED
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
normal = normalize( normalMatrix * normal );
#elif defined( TANGENTSPACE_NORMALMAP )
vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
mapN.xy *= normalScale;
#ifdef USE_TANGENT
normal = normalize( vTBN * mapN );
#else
normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );
#endif
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif
`;var is=`
#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif
`;var as=`
#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif
`;var rs=`
#ifndef FLAT_SHADED // normal is computed with derivatives when FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif
`;var ns=`
#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
#ifdef OBJECTSPACE_NORMALMAP
uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
// Normal Mapping Without Precomputed Tangents
// http://www.thetenthplanet.de/archives/1180
vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
vec2 st0 = dFdx( vUv.st );
vec2 st1 = dFdy( vUv.st );
vec3 N = surf_norm; // normalized
vec3 q1perp = cross( q1, N );
vec3 q0perp = cross( N, q0 );
vec3 T = q1perp * st0.x + q0perp * st1.x;
vec3 B = q1perp * st0.y + q0perp * st1.y;
float det = max( dot( T, T ), dot( B, B ) );
float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
}
#endif
`;var ss=`
#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = geometryNormal;
#endif
`;var os=`
#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
#ifdef USE_TANGENT
clearcoatNormal = normalize( vTBN * clearcoatMapN );
#else
clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );
#endif
#endif
`;var cs=`
#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform sampler2D clearcoatNormalMap;
uniform vec2 clearcoatNormalScale;
#endif
`;var ls=`
#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
// https://github.com/mrdoob/three.js/pull/22425
#ifdef USE_TRANSMISSION
diffuseColor.a *= transmissionAlpha + 0.1;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
`;var us=`
vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)
const float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
const float ShiftRight8 = 1. / 256.;
vec4 packDepthToRGBA( const in float v ) {
vec4 r = vec4( fract( v * PackFactors ), v );
r.yzw -= r.xyz * ShiftRight8; // tidy overflow
return r * PackUpscale;
}
float unpackRGBAToDepth( const in vec4 v ) {
return dot( v, UnpackFactors );
}
vec4 pack2HalfToRGBA( vec2 v ) {
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( vec4 v ) {
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
return linearClipZ * ( near - far ) - near;
}
// NOTE: https://twitter.com/gonnavis/status/1377183786949959682
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
return ( near * far ) / ( ( far - near ) * invClipZ - far );
}
`;var hs=`
#ifdef PREMULTIPLIED_ALPHA
// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.
gl_FragColor.rgb *= gl_FragColor.a;
#endif
`;var fs=`
vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;
`;var ds=`
#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif
`;var ps=`
#ifdef DITHERING
// based on https://www.shadertoy.com/view/MslGR8
vec3 dithering( vec3 color ) {
//Calculate grid position
float grid_position = rand( gl_FragCoord.xy );
//Shift the individual colors differently, thus making it even harder to see the dithering pattern
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
//modify shift acording to grid position.
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
//shift the color by dither_shift
return color + dither_shift_RGB;
}
#endif
`;var ms=`
float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vUv );
// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
roughnessFactor *= texelRoughness.g;
#endif
`;var vs=`
#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif
`;var gs=`
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
struct SpotLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
/*
#if NUM_RECT_AREA_LIGHTS > 0
// TODO (abelnation): create uniforms for area light shadows
#endif
*/
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
}
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
return unpackRGBATo2Half( texture2D( shadow, uv ) );
}
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
float occlusion = 1.0;
vec2 distribution = texture2DDistribution( shadow, uv );
float hard_shadow = step( compare , distribution.x ); // Hard Shadow
if (hard_shadow != 1.0 ) {
float distance = compare - distribution.x ;
float variance = max( 0.00000, distribution.y * distribution.y );
float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality
softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed
occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
}
return occlusion;
}
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.z += shadowBias;
// if ( something && something ) breaks ATI OpenGL shader compiler
// if ( all( something, something ) ) using this instead
bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
bool inFrustum = all( inFrustumVec );
bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
bool frustumTest = all( frustumTestVec );
if ( frustumTest ) {
#if defined( SHADOWMAP_TYPE_PCF )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx0 = - texelSize.x * shadowRadius;
float dy0 = - texelSize.y * shadowRadius;
float dx1 = + texelSize.x * shadowRadius;
float dy1 = + texelSize.y * shadowRadius;
float dx2 = dx0 / 2.0;
float dy2 = dy0 / 2.0;
float dx3 = dx1 / 2.0;
float dy3 = dy1 / 2.0;
shadow = (
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
) * ( 1.0 / 17.0 );
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx = texelSize.x;
float dy = texelSize.y;
vec2 uv = shadowCoord.xy;
vec2 f = fract( uv * shadowMapSize + 0.5 );
uv -= f * texelSize;
shadow = (
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
f.x ),
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
f.x ),
f.y )
) * ( 1.0 / 9.0 );
#elif defined( SHADOWMAP_TYPE_VSM )
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
#else // no percentage-closer filtering:
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
#endif
}
return shadow;
}
// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D
// vector suitable for 2D texture mapping. This code uses the following layout for the
// 2D texture:
//
// xzXZ
// y Y
//
// Y - Positive y direction
// y - Negative y direction
// X - Positive x direction
// x - Negative x direction
// Z - Positive z direction
// z - Negative z direction
//
// Source and test bed:
// https://gist.github.com/tschw/da10c43c467ce8afd0c4
vec2 cubeToUV( vec3 v, float texelSizeY ) {
// Number of texels to avoid at the edge of each square
vec3 absV = abs( v );
// Intersect unit cube
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
absV *= scaleToCube;
// Apply scale to avoid seams
// two texels less per square (one texel will do for NEAREST)
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
// Unwrap
// space: -1 ... 1 range for each square
//
// #X## dim := ( 4 , 2 )
// # # center := ( 1 , 1 )
vec2 planar = v.xy;
float almostATexel = 1.5 * texelSizeY;
float almostOne = 1.0 - almostATexel;
if ( absV.z >= almostOne ) {
if ( v.z > 0.0 )
planar.x = 4.0 - v.x;
} else if ( absV.x >= almostOne ) {
float signX = sign( v.x );
planar.x = v.z * signX + 2.0 * signX;
} else if ( absV.y >= almostOne ) {
float signY = sign( v.y );
planar.x = v.x + 2.0 * signY + 2.0;
planar.y = v.z * signY - 2.0;
}
// Transform to UV space
// scale := 0.5 / dim
// translate := ( center + 0.5 ) / dim
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
}
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
// for point lights, the uniform @vShadowCoord is re-purposed to hold
// the vector from the light to the world-space position of the fragment.
vec3 lightToPosition = shadowCoord.xyz;
// dp = normalized distance from light to fragment position
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
dp += shadowBias;
// bd3D = base direction 3D
vec3 bd3D = normalize( lightToPosition );
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
return (
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
) * ( 1.0 / 9.0 );
#else // no percentage-closer filtering
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
#endif
`;var xs=`
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
struct SpotLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
/*
#if NUM_RECT_AREA_LIGHTS > 0
// TODO (abelnation): uniforms for area light shadows
#endif
*/
#endif
`;var Ms=`
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
// Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
vec4 shadowWorldPosition;
#endif
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
/*
#if NUM_RECT_AREA_LIGHTS > 0
// TODO (abelnation): update vAreaShadowCoord with area light info
#endif
*/
#endif
`;var bs=`
float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
spotLight = spotLightShadows[ i ];
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
pointLight = pointLightShadows[ i ];
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
#endif
/*
#if NUM_RECT_AREA_LIGHTS > 0
// TODO (abelnation): update shadow for Area light
#endif
*/
#endif
return shadow;
}
`;var ys=`
#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif
`;var Cs=`
#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
#ifdef BONE_TEXTURE
uniform highp sampler2D boneTexture;
uniform int boneTextureSize;
mat4 getBoneMatrix( const in float i ) {
float j = i * 4.0;
float x = mod( j, float( boneTextureSize ) );
float y = floor( j / float( boneTextureSize ) );
float dx = 1.0 / float( boneTextureSize );
float dy = 1.0 / float( boneTextureSize );
y = dy * ( y + 0.5 );
vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
mat4 bone = mat4( v1, v2, v3, v4 );
return bone;
}
#else
uniform mat4 boneMatrices[ MAX_BONES ];
mat4 getBoneMatrix( const in float i ) {
mat4 bone = boneMatrices[ int(i) ];
return bone;
}
#endif
#endif
`;var zs=`
#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
skinned += boneMatY * skinVertex * skinWeight.y;
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
#endif
`;var As=`
#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
skinMatrix += skinWeight.z * boneMatZ;
skinMatrix += skinWeight.w * boneMatW;
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
#endif
`;var ws=`
float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif
`;var Ss=`
#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif
`;var _s=`
#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif
`;var Es=`
#ifndef saturate
// <common> may have defined saturate() already
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
// exposure only
vec3 LinearToneMapping( vec3 color ) {
return toneMappingExposure * color;
}
// source: https://www.cs.utah.edu/docs/techreports/2002/pdf/UUCS-02-001.pdf
vec3 ReinhardToneMapping( vec3 color ) {
color *= toneMappingExposure;
return saturate( color / ( vec3( 1.0 ) + color ) );
}
// source: http://filmicworlds.com/blog/filmic-tonemapping-operators/
vec3 OptimizedCineonToneMapping( vec3 color ) {
// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson
color *= toneMappingExposure;
color = max( vec3( 0.0 ), color - 0.004 );
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs
vec3 RRTAndODTFit( vec3 v ) {
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
return a / b;
}
// this implementation of ACES is modified to accommodate a brighter viewing environment.
// the scale factor of 1/0.6 is subjective. see discussion in #19621.
vec3 ACESFilmicToneMapping( vec3 color ) {
// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), // transposed from source
vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
// ODT_SAT => XYZ => D60_2_D65 => sRGB
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), // transposed from source
vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color *= toneMappingExposure / 0.6;
color = ACESInputMat * color;
// Apply RRT and ODT
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
// Clamp to [0, 1]
return saturate( color );
}
vec3 CustomToneMapping( vec3 color ) { return color; }
`;var Ls=`
#ifdef USE_TRANSMISSION
float transmissionAlpha = 1.0;
float transmissionFactor = transmission;
float thicknessFactor = thickness;
#ifdef USE_TRANSMISSIONMAP
transmissionFactor *= texture2D( transmissionMap, vUv ).r;
#endif
#ifdef USE_THICKNESSMAP
thicknessFactor *= texture2D( thicknessMap, vUv ).g;
#endif
vec3 pos = vWorldPosition;
vec3 v = normalize( cameraPosition - pos );
vec3 n = inverseTransformDirection( normal, viewMatrix );
vec4 transmission = getIBLVolumeRefraction(
n, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,
pos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,
attenuationColor, attenuationDistance );
totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );
transmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );
#endif
`;var Ds=`
#ifdef USE_TRANSMISSION
// Transmission code is based on glTF-Sampler-Viewer
// https://github.com/KhronosGroup/glTF-Sample-Viewer
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
uniform vec3 attenuationColor;
#ifdef USE_TRANSMISSIONMAP
uniform sampler2D transmissionMap;
#endif
#ifdef USE_THICKNESSMAP
uniform sampler2D thicknessMap;
#endif
uniform vec2 transmissionSamplerSize;
uniform sampler2D transmissionSamplerMap;
uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
varying vec3 vWorldPosition;
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
// Direction of refracted light.
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
// Compute rotation-independant scaling of the model matrix.
vec3 modelScale;
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
// The thickness is specified in local space.
return normalize( refractionVector ) * thickness * modelScale;
}
float applyIorToRoughness( const in float roughness, const in float ior ) {
// Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
// an IOR of 1.5 results in the default amount of microfacet refraction.
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
}
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
#ifdef TEXTURE_LOD_EXT
return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );
#else
return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );
#endif
}
vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
if ( attenuationDistance == 0.0 ) {
// Attenuation distance is +\u221E (which we indicate by zero), i.e. the transmitted color is not attenuated at all.
return radiance;
} else {
// Compute light attenuation using Beer's law.
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); // Beer's law
return transmittance * radiance;
}
}
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
const in vec3 attenuationColor, const in float attenuationDistance ) {
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
// Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
// Sample framebuffer to get pixel the refracted ray hits.
vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
// Get the specular component.
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
}
#endif
`;var Ts=`
#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
varying vec2 vUv;
#endif
`;var Hs=`
#ifdef USE_UV
#ifdef UVS_VERTEX_ONLY
vec2 vUv;
#else
varying vec2 vUv;
#endif
uniform mat3 uvTransform;
#endif
`;var Vs=`
#ifdef USE_UV
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif
`;var Ns=`
#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
varying vec2 vUv2;
#endif
`;var Rs=`
#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
attribute vec2 uv2;
varying vec2 vUv2;
uniform mat3 uv2Transform;
#endif
`;var Fs=`
#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
#endif
`;var Bs=`
#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_INSTANCING
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
#endif
`;var Ps=`
varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}
`,Is=`
uniform sampler2D t2D;
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( t2D, vUv );
#include <tonemapping_fragment>
#include <encodings_fragment>
}
`;var ks=`
varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w; // set z to camera.far
}
`,Us=`
#include <envmap_common_pars_fragment>
uniform float opacity;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
vec3 vReflect = vWorldDirection;
#include <envmap_fragment>
gl_FragColor = envColor;
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <encodings_fragment>
}
`;var Os=`
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.
// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for
// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.
varying vec2 vHighPrecisionZW;
void main() {
#include <uv_vertex>
#include <skinbase_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
}
`,Gs=`
#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( 1.0 );
#if DEPTH_PACKING == 3200
diffuseColor.a = opacity;
#endif
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <logdepthbuf_fragment>
// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
#if DEPTH_PACKING == 3200
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
#elif DEPTH_PACKING == 3201
gl_FragColor = packDepthToRGBA( fragCoordZ );
#endif
}
`;var qs=`
#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <skinbase_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
}
`,Ws=`
#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( 1.0 );
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
float dist = length( vWorldPosition - referencePosition );
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist ); // clamp to [ 0, 1 ]
gl_FragColor = packDepthToRGBA( dist );
}
`;var js=`
varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}
`,Xs=`
uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <encodings_fragment>
}
`;var Zs=`
uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
vLineDistance = scale * lineDistance;
#include <color_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}
`,Ys=`
uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
if ( mod( vLineDistance, totalSize ) > dashSize ) {
discard;
}
vec3 outgoingLight = vec3( 0.0 );
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <color_fragment>
outgoingLight = diffuseColor.rgb; // simple shader
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}
`;var $s=`
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
}
`,Ks=`
uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <specularmap_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
// accumulation (baked indirect lighting only)
#ifdef USE_LIGHTMAP
vec4 lightMapTexel= texture2D( lightMap, vUv2 );
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;
#else
reflectedLight.indirectDiffuse += vec3( 1.0 );
#endif
// modulation
#include <aomap_fragment>
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
vec3 outgoingLight = reflectedLight.indirectDiffuse;
#include <envmap_fragment>
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}
`;var Js=`
#define LAMBERT
varying vec3 vLightFront;
varying vec3 vIndirectFront;
#ifdef DOUBLE_SIDED
varying vec3 vLightBack;
varying vec3 vIndirectBack;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <bsdfs>
#include <lights_pars_begin>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <lights_lambert_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}
`,Qs=`
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
varying vec3 vLightFront;
varying vec3 vIndirectFront;
#ifdef DOUBLE_SIDED
varying vec3 vLightBack;
varying vec3 vIndirectBack;
#endif
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <fog_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <specularmap_fragment>
#include <emissivemap_fragment>
// accumulation
#ifdef DOUBLE_SIDED
reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
#else
reflectedLight.indirectDiffuse += vIndirectFront;
#endif
#include <lightmap_fragment>
reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );
#ifdef DOUBLE_SIDED
reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
#else
reflectedLight.directDiffuse = vLightFront;
#endif
reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();
// modulation
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <envmap_fragment>
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}
`;var e5=`
#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
}
`,t5=`
#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
vec3 viewDir = normalize( vViewPosition );
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
vec3 y = cross( viewDir, x );
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks
#ifdef USE_MATCAP
vec4 matcapColor = texture2D( matcap, uv );
#else
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); // default if matcap is missing
#endif
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}
`;var i5=`
#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
varying vec3 vViewPosition;
#endif
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
vViewPosition = - mvPosition.xyz;
#endif
}
`,a5=`
#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
}
`;var r5=`
#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}
`,n5=`
#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
// accumulation
#include <lights_phong_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
// modulation
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
#include <envmap_fragment>
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}
`;var s5=`
#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
}
`,o5=`
#define STANDARD
#ifdef PHYSICAL
#define IOR
#define SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
uniform float ior;
#endif
#ifdef SPECULAR
uniform float specularIntensity;
uniform vec3 specularColor;
#ifdef USE_SPECULARINTENSITYMAP
uniform sampler2D specularIntensityMap;
#endif
#ifdef USE_SPECULARCOLORMAP
uniform sampler2D specularColorMap;
#endif
#endif
#ifdef USE_CLEARCOAT
uniform float clearcoat;
uniform float clearcoatRoughness;
#endif
#ifdef USE_SHEEN
uniform vec3 sheenColor;
uniform float sheenRoughness;
#ifdef USE_SHEENCOLORMAP
uniform sampler2D sheenColorMap;
#endif
#ifdef USE_SHEENROUGHNESSMAP
uniform sampler2D sheenRoughnessMap;
#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <bsdfs>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <roughnessmap_fragment>
#include <metalnessmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <clearcoat_normal_fragment_begin>
#include <clearcoat_normal_fragment_maps>
#include <emissivemap_fragment>
// accumulation
#include <lights_physical_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
// modulation
#include <aomap_fragment>
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
#include <transmission_fragment>
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
#ifdef USE_SHEEN
// Sheen energy compensation approximation calculation can be found at the end of
// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
#endif
#ifdef USE_CLEARCOAT
float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
#endif
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}
`;var c5=`
#define TOON
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}
`,l5=`
#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
// accumulation
#include <lights_toon_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
// modulation
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}
`;var u5=`
uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <color_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
gl_PointSize = size;
#ifdef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
#endif
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
}
`,h5=`
uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_particle_fragment>
#include <color_fragment>
#include <alphatest_fragment>
outgoingLight = diffuseColor.rgb;
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}
`;var f5=`
#include <common>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}
`,d5=`
uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
}
`;var p5=`
uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
vec2 scale;
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
#ifndef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) scale *= - mvPosition.z;
#endif
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
vec2 rotatedPosition;
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
mvPosition.xy += rotatedPosition;
gl_Position = projectionMatrix * mvPosition;
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}
`,m5=`
uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
outgoingLight = diffuseColor.rgb;
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
}
`;var S1={alphamap_fragment:G8,alphamap_pars_fragment:q8,alphatest_fragment:W8,alphatest_pars_fragment:j8,aomap_fragment:X8,aomap_pars_fragment:Z8,begin_vertex:Y8,beginnormal_vertex:$8,bsdfs:K8,bumpmap_pars_fragment:J8,clipping_planes_fragment:Q8,clipping_planes_pars_fragment:en,clipping_planes_pars_vertex:tn,clipping_planes_vertex:an,color_fragment:rn,color_pars_fragment:nn,color_pars_vertex:sn,color_vertex:on,common:cn,cube_uv_reflection_fragment:ln,defaultnormal_vertex:un,displacementmap_pars_vertex:hn,displacementmap_vertex:fn,emissivemap_fragment:dn,emissivemap_pars_fragment:pn,encodings_fragment:mn,encodings_pars_fragment:vn,envmap_fragment:gn,envmap_common_pars_fragment:xn,envmap_pars_fragment:Mn,envmap_pars_vertex:bn,envmap_physical_pars_fragment:Tn,envmap_vertex:yn,fog_vertex:Cn,fog_pars_vertex:zn,fog_fragment:An,fog_pars_fragment:wn,gradientmap_pars_fragment:Sn,lightmap_fragment:_n,lightmap_pars_fragment:En,lights_lambert_vertex:Ln,lights_pars_begin:Dn,lights_toon_fragment:Hn,lights_toon_pars_fragment:Vn,lights_phong_fragment:Nn,lights_phong_pars_fragment:Rn,lights_physical_fragment:Fn,lights_physical_pars_fragment:Bn,lights_fragment_begin:Pn,lights_fragment_maps:In,lights_fragment_end:kn,logdepthbuf_fragment:Un,logdepthbuf_pars_fragment:On,logdepthbuf_pars_vertex:Gn,logdepthbuf_vertex:qn,map_fragment:Wn,map_pars_fragment:jn,map_particle_fragment:Xn,map_particle_pars_fragment:Zn,metalnessmap_fragment:Yn,metalnessmap_pars_fragment:$n,morphnormal_vertex:Kn,morphtarget_pars_vertex:Jn,morphtarget_vertex:Qn,normal_fragment_begin:es,normal_fragment_maps:ts,normal_pars_fragment:is,normal_pars_vertex:as,normal_vertex:rs,normalmap_pars_fragment:ns,clearcoat_normal_fragment_begin:ss,clearcoat_normal_fragment_maps:os,clearcoat_pars_fragment:cs,output_fragment:ls,packing:us,premultiplied_alpha_fragment:hs,project_vertex:fs,dithering_fragment:ds,dithering_pars_fragment:ps,roughnessmap_fragment:ms,roughnessmap_pars_fragment:vs,shadowmap_pars_fragment:gs,shadowmap_pars_vertex:xs,shadowmap_vertex:Ms,shadowmask_pars_fragment:bs,skinbase_vertex:ys,skinning_pars_vertex:Cs,skinning_vertex:zs,skinnormal_vertex:As,specularmap_fragment:ws,specularmap_pars_fragment:Ss,tonemapping_fragment:_s,tonemapping_pars_fragment:Es,transmission_fragment:Ls,transmission_pars_fragment:Ds,uv_pars_fragment:Ts,uv_pars_vertex:Hs,uv_vertex:Vs,uv2_pars_fragment:Ns,uv2_pars_vertex:Rs,uv2_vertex:Fs,worldpos_vertex:Bs,background_vert:Ps,background_frag:Is,cube_vert:ks,cube_frag:Us,depth_vert:Os,depth_frag:Gs,distanceRGBA_vert:qs,distanceRGBA_frag:Ws,equirect_vert:js,equirect_frag:Xs,linedashed_vert:Zs,linedashed_frag:Ys,meshbasic_vert:$s,meshbasic_frag:Ks,meshlambert_vert:Js,meshlambert_frag:Qs,meshmatcap_vert:e5,meshmatcap_frag:t5,meshnormal_vert:i5,meshnormal_frag:a5,meshphong_vert:r5,meshphong_frag:n5,meshphysical_vert:s5,meshphysical_frag:o5,meshtoon_vert:c5,meshtoon_frag:l5,points_vert:u5,points_frag:h5,shadow_vert:f5,shadow_frag:d5,sprite_vert:p5,sprite_frag:m5};var e1={common:{diffuse:{value:new x1(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new n2},uv2Transform:{value:new n2},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new z1(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new x1(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new x1(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new n2}},sprite:{diffuse:{value:new x1(16777215)},opacity:{value:1},center:{value:new z1(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new n2}}};var W2={basic:{uniforms:p2([e1.common,e1.specularmap,e1.envmap,e1.aomap,e1.lightmap,e1.fog]),vertexShader:S1.meshbasic_vert,fragmentShader:S1.meshbasic_frag},lambert:{uniforms:p2([e1.common,e1.specularmap,e1.envmap,e1.aomap,e1.lightmap,e1.emissivemap,e1.fog,e1.lights,{emissive:{value:new x1(0)}}]),vertexShader:S1.meshlambert_vert,fragmentShader:S1.meshlambert_frag},phong:{uniforms:p2([e1.common,e1.specularmap,e1.envmap,e1.aomap,e1.lightmap,e1.emissivemap,e1.bumpmap,e1.normalmap,e1.displacementmap,e1.fog,e1.lights,{emissive:{value:new x1(0)},specular:{value:new x1(1118481)},shininess:{value:30}}]),vertexShader:S1.meshphong_vert,fragmentShader:S1.meshphong_frag},standard:{uniforms:p2([e1.common,e1.envmap,e1.aomap,e1.lightmap,e1.emissivemap,e1.bumpmap,e1.normalmap,e1.displacementmap,e1.roughnessmap,e1.metalnessmap,e1.fog,e1.lights,{emissive:{value:new x1(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:S1.meshphysical_vert,fragmentShader:S1.meshphysical_frag},toon:{uniforms:p2([e1.common,e1.aomap,e1.lightmap,e1.emissivemap,e1.bumpmap,e1.normalmap,e1.displacementmap,e1.gradientmap,e1.fog,e1.lights,{emissive:{value:new x1(0)}}]),vertexShader:S1.meshtoon_vert,fragmentShader:S1.meshtoon_frag},matcap:{uniforms:p2([e1.common,e1.bumpmap,e1.normalmap,e1.displacementmap,e1.fog,{matcap:{value:null}}]),vertexShader:S1.meshmatcap_vert,fragmentShader:S1.meshmatcap_frag},points:{uniforms:p2([e1.points,e1.fog]),vertexShader:S1.points_vert,fragmentShader:S1.points_frag},dashed:{uniforms:p2([e1.common,e1.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:S1.linedashed_vert,fragmentShader:S1.linedashed_frag},depth:{uniforms:p2([e1.common,e1.displacementmap]),vertexShader:S1.depth_vert,fragmentShader:S1.depth_frag},normal:{uniforms:p2([e1.common,e1.bumpmap,e1.normalmap,e1.displacementmap,{opacity:{value:1}}]),vertexShader:S1.meshnormal_vert,fragmentShader:S1.meshnormal_frag},sprite:{uniforms:p2([e1.sprite,e1.fog]),vertexShader:S1.sprite_vert,fragmentShader:S1.sprite_frag},background:{uniforms:{uvTransform:{value:new n2},t2D:{value:null}},vertexShader:S1.background_vert,fragmentShader:S1.background_frag},cube:{uniforms:p2([e1.envmap,{opacity:{value:1}}]),vertexShader:S1.cube_vert,fragmentShader:S1.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:S1.equirect_vert,fragmentShader:S1.equirect_frag},distanceRGBA:{uniforms:p2([e1.common,e1.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:S1.distanceRGBA_vert,fragmentShader:S1.distanceRGBA_frag},shadow:{uniforms:p2([e1.lights,e1.fog,{color:{value:new x1(0)},opacity:{value:1}}]),vertexShader:S1.shadow_vert,fragmentShader:S1.shadow_frag}};W2.physical={uniforms:p2([W2.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new z1(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new x1(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new z1},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new x1(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new x1(1,1,1)},specularColorMap:{value:null}}]),vertexShader:S1.meshphysical_vert,fragmentShader:S1.meshphysical_frag};function v5(n,e,t,i,a,r){let s=new x1(0),o=a===!0?0:1,c,l,u=null,f=0,h=null;function m(g,x){let p=!1,d=x.isScene===!0?x.background:null;d&&d.isTexture&&(d=e.get(d));let A=n.xr,b=A.getSession&&A.getSession();b&&b.environmentBlendMode==="additive"&&(d=null),d===null?v(s,o):d&&d.isColor&&(v(d,1),p=!0),(n.autoClear||p)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),d&&(d.isCubeTexture||d.mapping===a4)?(l===void 0&&(l=new u2(new $e(1,1,1),new se({name:"BackgroundCubeMaterial",uniforms:Ke(W2.cube.uniforms),vertexShader:W2.cube.vertexShader,fragmentShader:W2.cube.fragmentShader,side:P1,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(C,E,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=d,l.material.uniforms.flipEnvMap.value=d.isCubeTexture&&d.isRenderTargetTexture===!1?-1:1,(u!==d||f!==d.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=d,f=d.version,h=n.toneMapping),g.unshift(l,l.geometry,l.material,0,0,null)):d&&d.isTexture&&(c===void 0&&(c=new u2(new H4(2,2),new se({name:"BackgroundMaterial",uniforms:Ke(W2.background.uniforms),vertexShader:W2.background.vertexShader,fragmentShader:W2.background.fragmentShader,side:ke,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=d,d.matrixAutoUpdate===!0&&d.updateMatrix(),c.material.uniforms.uvTransform.value.copy(d.matrix),(u!==d||f!==d.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=d,f=d.version,h=n.toneMapping),g.unshift(c,c.geometry,c.material,0,0,null))}function v(g,x){t.buffers.color.setClear(g.r,g.g,g.b,x,r)}return{getClearColor:function(){return s},setClearColor:function(g,x=1){s.set(g),o=x,v(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(g){o=g,v(s,o)},render:m}}function g5(n,e,t,i){let a=n.getParameter(n.MAX_VERTEX_ATTRIBS),r=i.isWebGL2?null:e.get("OES_vertex_array_object"),s=i.isWebGL2||r!==null,o={},c=g(null),l=c;function u(z,H,V,L,N){let U=!1;if(s){let Z=v(L,V,H);l!==Z&&(l=Z,h(l.object)),U=x(L,N),U&&p(L,N)}else{let Z=H.wireframe===!0;(l.geometry!==L.id||l.program!==V.id||l.wireframe!==Z)&&(l.geometry=L.id,l.program=V.id,l.wireframe=Z,U=!0)}z.isInstancedMesh===!0&&(U=!0),N!==null&&t.update(N,n.ELEMENT_ARRAY_BUFFER),U&&(T(z,H,V,L),N!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.get(N).buffer))}function f(){return i.isWebGL2?n.createVertexArray():r.createVertexArrayOES()}function h(z){return i.isWebGL2?n.bindVertexArray(z):r.bindVertexArrayOES(z)}function m(z){return i.isWebGL2?n.deleteVertexArray(z):r.deleteVertexArrayOES(z)}function v(z,H,V){let L=V.wireframe===!0,N=o[z.id];N===void 0&&(N={},o[z.id]=N);let U=N[H.id];U===void 0&&(U={},N[H.id]=U);let Z=U[L];return Z===void 0&&(Z=g(f()),U[L]=Z),Z}function g(z){let H=[],V=[],L=[];for(let N=0;N<a;N++)H[N]=0,V[N]=0,L[N]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:H,enabledAttributes:V,attributeDivisors:L,object:z,attributes:{},index:null}}function x(z,H){let V=l.attributes,L=z.attributes,N=0;for(let U in L){let Z=V[U],O=L[U];if(Z===void 0||Z.attribute!==O||Z.data!==O.data)return!0;N++}return l.attributesNum!==N||l.index!==H}function p(z,H){let V={},L=z.attributes,N=0;for(let U in L){let Z=L[U],O={};O.attribute=Z,Z.data&&(O.data=Z.data),V[U]=O,N++}l.attributes=V,l.attributesNum=N,l.index=H}function d(){let z=l.newAttributes;for(let H=0,V=z.length;H<V;H++)z[H]=0}function A(z){b(z,0)}function b(z,H){let V=l.newAttributes,L=l.enabledAttributes,N=l.attributeDivisors;V[z]=1,L[z]===0&&(n.enableVertexAttribArray(z),L[z]=1),N[z]!==H&&((i.isWebGL2?n:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](z,H),N[z]=H)}function C(){let z=l.newAttributes,H=l.enabledAttributes;for(let V=0,L=H.length;V<L;V++)H[V]!==z[V]&&(n.disableVertexAttribArray(V),H[V]=0)}function E(z,H,V,L,N,U){i.isWebGL2===!0&&(V===n.INT||V===n.UNSIGNED_INT)?n.vertexAttribIPointer(z,H,V,N,U):n.vertexAttribPointer(z,H,V,L,N,U)}function T(z,H,V,L){if(i.isWebGL2===!1&&(z.isInstancedMesh||L.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;d();let N=L.attributes,U=V.getAttributes(),Z=H.defaultAttributeValues;for(let O in U){let W=U[O];if(W.location>=0){let X=N[O];if(X===void 0&&(O==="instanceMatrix"&&z.instanceMatrix&&(X=z.instanceMatrix),O==="instanceColor"&&z.instanceColor&&(X=z.instanceColor)),X!==void 0){let Q=X.normalized,a1=X.itemSize,B=t.get(X);if(B===void 0)continue;let M1=B.buffer,u1=B.type,v1=B.bytesPerElement;if(X.isInterleavedBufferAttribute){let n1=X.data,T1=n1.stride,A1=X.offset;if(n1&&n1.isInstancedInterleavedBuffer){for(let C1=0;C1<W.locationSize;C1++)b(W.location+C1,n1.meshPerAttribute);z.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=n1.meshPerAttribute*n1.count)}else for(let C1=0;C1<W.locationSize;C1++)A(W.location+C1);n.bindBuffer(n.ARRAY_BUFFER,M1);for(let C1=0;C1<W.locationSize;C1++)E(W.location+C1,a1/W.locationSize,u1,Q,T1*v1,(A1+a1/W.locationSize*C1)*v1)}else{if(X.isInstancedBufferAttribute){for(let n1=0;n1<W.locationSize;n1++)b(W.location+n1,X.meshPerAttribute);z.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=X.meshPerAttribute*X.count)}else for(let n1=0;n1<W.locationSize;n1++)A(W.location+n1);n.bindBuffer(n.ARRAY_BUFFER,M1);for(let n1=0;n1<W.locationSize;n1++)E(W.location+n1,a1/W.locationSize,u1,Q,a1*v1,a1/W.locationSize*n1*v1)}}else if(Z!==void 0){let Q=Z[O];if(Q!==void 0)switch(Q.length){case 2:n.vertexAttrib2fv(W.location,Q);break;case 3:n.vertexAttrib3fv(W.location,Q);break;case 4:n.vertexAttrib4fv(W.location,Q);break;default:n.vertexAttrib1fv(W.location,Q)}}}}C()}function _(){M();for(let z in o){let H=o[z];for(let V in H){let L=H[V];for(let N in L)m(L[N].object),delete L[N];delete H[V]}delete o[z]}}function P(z){if(o[z.id]===void 0)return;let H=o[z.id];for(let V in H){let L=H[V];for(let N in L)m(L[N].object),delete L[N];delete H[V]}delete o[z.id]}function F(z){for(let H in o){let V=o[H];if(V[z.id]===void 0)continue;let L=V[z.id];for(let N in L)m(L[N].object),delete L[N];delete V[z.id]}}function M(){D(),l!==c&&(l=c,h(l.object))}function D(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:u,reset:M,resetDefaultState:D,dispose:_,releaseStatesOfGeometry:P,releaseStatesOfProgram:F,initAttributes:d,enableAttribute:A,disableUnusedAttributes:C}}function x5(n,e,t,i){let a=i.isWebGL2,r;function s(l){r=l}function o(l,u){n.drawArrays(r,l,u),t.update(u,r,1)}function c(l,u,f){if(f===0)return;let h,m;if(a)h=n,m="drawArraysInstanced";else if(h=e.get("ANGLE_instanced_arrays"),m="drawArraysInstancedANGLE",h===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}h[m](r,l,u,f),t.update(u,r,f)}this.setMode=s,this.render=o,this.renderInstances=c}function M5(n,e,t){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){let T=e.get("EXT_texture_filter_anisotropic");i=n.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function r(T){if(T==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=typeof WebGL2RenderingContext!="undefined"&&n instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&n instanceof WebGL2ComputeRenderingContext,o=t.precision!==void 0?t.precision:"highp",c=r(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);let l=s||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),h=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_TEXTURE_SIZE),v=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),x=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),p=n.getParameter(n.MAX_VARYING_VECTORS),d=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),A=h>0,b=s||e.has("OES_texture_float"),C=A&&b,E=s?n.getParameter(n.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:l,getMaxAnisotropy:a,getMaxPrecision:r,precision:o,logarithmicDepthBuffer:u,maxTextures:f,maxVertexTextures:h,maxTextureSize:m,maxCubemapSize:v,maxAttributes:g,maxVertexUniforms:x,maxVaryings:p,maxFragmentUniforms:d,vertexTextures:A,floatFragmentTextures:b,floatVertexTextures:C,maxSamples:E}}function b5(n){let e=this,t=null,i=0,a=!1,r=!1,s=new ne,o=new n2,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h,m){let v=f.length!==0||h||i!==0||a;return a=h,t=u(f,m,0),i=f.length,v},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1,l()},this.setState=function(f,h,m){let v=f.clippingPlanes,g=f.clipIntersection,x=f.clipShadows,p=n.get(f);if(!a||v===null||v.length===0||r&&!x)r?u(null):l();else{let d=r?0:i,A=d*4,b=p.clippingState||null;c.value=b,b=u(v,h,A,m);for(let C=0;C!==A;++C)b[C]=t[C];p.clippingState=b,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=d}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(f,h,m,v){let g=f!==null?f.length:0,x=null;if(g!==0){if(x=c.value,v!==!0||x===null){let p=m+g*4,d=h.matrixWorldInverse;o.getNormalMatrix(d),(x===null||x.length<p)&&(x=new Float32Array(p));for(let A=0,b=m;A!==g;++A,b+=4)s.copy(f[A]).applyMatrix4(d,o),s.normal.toArray(x,b),x[b+3]=s.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=g,e.numIntersection=0,x}}var m2=class extends F2{constructor(e,t,i={}){super();this.width=e,this.height=t,this.depth=1,this.scissor=new q1(0,0,e,t),this.scissorTest=!1,this.viewport=new q1(0,0,e,t),this.texture=new $1(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=i.generateMipmaps!==void 0?i.generateMipmaps:!1,this.texture.internalFormat=i.internalFormat!==void 0?i.internalFormat:null,this.texture.minFilter=i.minFilter!==void 0?i.minFilter:t2,this.depthBuffer=i.depthBuffer!==void 0?i.depthBuffer:!0,this.stencilBuffer=i.stencilBuffer!==void 0?i.stencilBuffer:!1,this.depthTexture=i.depthTexture!==void 0?i.depthTexture:null}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}setSize(e,t,i=1){(this.width!==e||this.height!==t||this.depth!==i)&&(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.image=Object.assign({},e.texture.image),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}};m2.prototype.isWebGLRenderTarget=!0;var at=class extends j1{constructor(){super();this.type="Camera",this.matrixWorldInverse=new k1,this.projectionMatrix=new k1,this.projectionMatrixInverse=new k1}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};at.prototype.isCamera=!0;var i2=class extends at{constructor(e=50,t=1,i=.1,a=2e3){super();this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=a,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=_t*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(y6*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return _t*2*Math.atan(Math.tan(y6*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,a,r,s){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=a,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(y6*.5*this.fov)/this.zoom,i=2*t,a=this.aspect*i,r=-.5*a,s=this.view;if(this.view!==null&&this.view.enabled){let c=s.fullWidth,l=s.fullHeight;r+=s.offsetX*a/c,t-=s.offsetY*i/l,a*=s.width/c,i*=s.height/l}let o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+a,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};i2.prototype.isPerspectiveCamera=!0;var rt=90,nt=1,yi=class extends j1{constructor(e,t,i){super();if(this.type="CubeCamera",i.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=i;let a=new i2(rt,nt,e,t);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new k(1,0,0)),this.add(a);let r=new i2(rt,nt,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new k(-1,0,0)),this.add(r);let s=new i2(rt,nt,e,t);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(new k(0,1,0)),this.add(s);let o=new i2(rt,nt,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new k(0,-1,0)),this.add(o);let c=new i2(rt,nt,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new k(0,0,1)),this.add(c);let l=new i2(rt,nt,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new k(0,0,-1)),this.add(l)}update(e,t){this.parent===null&&this.updateMatrixWorld();let i=this.renderTarget,[a,r,s,o,c,l]=this.children,u=e.xr.enabled,f=e.getRenderTarget();e.xr.enabled=!1;let h=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,a),e.setRenderTarget(i,1),e.render(t,r),e.setRenderTarget(i,2),e.render(t,s),e.setRenderTarget(i,3),e.render(t,o),e.setRenderTarget(i,4),e.render(t,c),i.texture.generateMipmaps=h,e.setRenderTarget(i,5),e.render(t,l),e.setRenderTarget(f),e.xr.enabled=u,i.texture.needsPMREMUpdate=!0}};var st=class extends $1{constructor(e,t,i,a,r,s,o,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:be;super(e,t,i,a,r,s,o,c,l,u);this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};st.prototype.isCubeTexture=!0;var e0=class extends m2{constructor(e,t,i){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=i);super(e,e,t);t=t||{},this.texture=new st(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:t2}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=W1,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}
`,fragmentShader:`
uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
}
`},a=new $e(5,5,5),r=new se({name:"CubemapFromEquirect",uniforms:Ke(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:P1,blending:U2});r.uniforms.tEquirect.value=t;let s=new u2(a,r),o=t.minFilter;return t.minFilter===r4&&(t.minFilter=t2),new yi(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,i,a){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,a);e.setRenderTarget(r)}};e0.prototype.isWebGLCubeRenderTarget=!0;function y5(n){let e=new WeakMap;function t(s,o){return o===Lt?s.mapping=be:o===Dt&&(s.mapping=Ue),s}function i(s){if(s&&s.isTexture&&s.isRenderTargetTexture===!1){let o=s.mapping;if(o===Lt||o===Dt)if(e.has(s)){let c=e.get(s).texture;return t(c,s.mapping)}else{let c=s.image;if(c&&c.height>0){let l=new e0(c.height/2);return l.fromEquirectangularTexture(n,s),e.set(s,l),s.addEventListener("dispose",a),t(l.texture,s.mapping)}else return null}}return s}function a(s){let o=s.target;o.removeEventListener("dispose",a);let c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}var t0=class extends at{constructor(e=-1,t=1,i=1,a=-1,r=.1,s=2e3){super();this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=a,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,a,r,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=a,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,a=(this.top+this.bottom)/2,r=i-e,s=i+e,o=a+t,c=a-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,s=r+l*this.view.width,o-=u*this.view.offsetY,c=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,c,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};t0.prototype.isOrthographicCamera=!0;var ot=class extends se{constructor(e){super(e);this.type="RawShaderMaterial"}};ot.prototype.isRawShaderMaterial=!0;var ct=4,d4=8,Ae=Math.pow(2,d4),C5=[.125,.215,.35,.446,.526,.582],z5=d4-ct+1+C5.length,lt=20,Ci=new t0,{_lodPlanes:Gt,_sizeLods:A5,_sigmas:i0}=P9(),w5=new x1,zi=null,V4=(1+Math.sqrt(5))/2,ut=1/V4,S5=[new k(1,1,1),new k(-1,1,1),new k(1,1,-1),new k(-1,1,-1),new k(0,V4,ut),new k(0,V4,-ut),new k(ut,0,V4),new k(-ut,0,V4),new k(V4,ut,0),new k(-V4,ut,0)],a0=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=I9(lt),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,a=100){zi=this._renderer.getRenderTarget();let r=this._allocateTargets();return this._sceneToCubeUV(e,i,a,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapShader===null&&(this._cubemapShader=L5(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){this._equirectShader===null&&(this._equirectShader=E5(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose(),this._cubemapShader!==null&&this._cubemapShader.dispose(),this._equirectShader!==null&&this._equirectShader.dispose();for(let e=0;e<Gt.length;e++)Gt[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(zi),e.scissorTest=!1,r0(e,0,0,e.width,e.height)}_fromTexture(e,t){zi=this._renderer.getRenderTarget();let i=t||this._allocateTargets(e);return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(e){let t={magFilter:t2,minFilter:t2,generateMipmaps:!1,type:ye,format:W1,encoding:R2,depthBuffer:!1},i=_5(t);return i.depthBuffer=!e,this._pingPongRenderTarget===null&&(this._pingPongRenderTarget=_5(t)),i}_compileMaterial(e){let t=new u2(Gt[0],e);this._renderer.compile(t,Ci)}_sceneToCubeUV(e,t,i,a){let r=90,s=1,o=new i2(r,s,t,i),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,f=u.autoClear,h=u.toneMapping;u.getClearColor(w5),u.toneMapping=O2,u.autoClear=!1;let m=new Q4({name:"PMREM.Background",side:P1,depthWrite:!1,depthTest:!1}),v=new u2(new $e,m),g=!1,x=e.background;x?x.isColor&&(m.color.copy(x),e.background=null,g=!0):(m.color.copy(w5),g=!0);for(let p=0;p<6;p++){let d=p%3;d===0?(o.up.set(0,c[p],0),o.lookAt(l[p],0,0)):d===1?(o.up.set(0,0,c[p]),o.lookAt(0,l[p],0)):(o.up.set(0,c[p],0),o.lookAt(0,0,l[p])),r0(a,d*Ae,p>2?Ae:0,Ae,Ae),u.setRenderTarget(a),g&&u.render(v,o),u.render(e,o)}v.geometry.dispose(),v.material.dispose(),u.toneMapping=h,u.autoClear=f,e.background=x}_textureToCubeUV(e,t){let i=this._renderer,a=e.mapping===be||e.mapping===Ue;a?(this._cubemapShader===null&&(this._cubemapShader=L5()),this._cubemapShader.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectShader===null&&(this._equirectShader=E5());let r=a?this._cubemapShader:this._equirectShader,s=new u2(Gt[0],r),o=r.uniforms;o.envMap.value=e,a||o.texelSize.value.set(1/e.image.width,1/e.image.height),r0(t,0,0,3*Ae,2*Ae),i.setRenderTarget(t),i.render(s,Ci)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let a=1;a<z5;a++){let r=Math.sqrt(i0[a]*i0[a]-i0[a-1]*i0[a-1]),s=S5[(a-1)%S5.length];this._blur(e,a-1,a,r,s)}t.autoClear=i}_blur(e,t,i,a,r){let s=this._pingPongRenderTarget;this._halfBlur(e,s,t,i,a,"latitudinal",r),this._halfBlur(s,e,i,i,a,"longitudinal",r)}_halfBlur(e,t,i,a,r,s,o){let c=this._renderer,l=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,f=new u2(Gt[a],l),h=l.uniforms,m=A5[i]-1,v=isFinite(r)?Math.PI/(2*m):2*Math.PI/(2*lt-1),g=r/v,x=isFinite(r)?1+Math.floor(u*g):lt;x>lt&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${lt}`);let p=[],d=0;for(let E=0;E<lt;++E){let T=E/g,_=Math.exp(-T*T/2);p.push(_),E===0?d+=_:E<x&&(d+=2*_)}for(let E=0;E<p.length;E++)p[E]=p[E]/d;h.envMap.value=e.texture,h.samples.value=x,h.weights.value=p,h.latitudinal.value=s==="latitudinal",o&&(h.poleAxis.value=o),h.dTheta.value=v,h.mipInt.value=d4-i;let A=A5[a],b=3*Math.max(0,Ae-2*A),C=(a===0?0:2*Ae)+2*A*(a>d4-ct?a-d4+ct:0);r0(t,b,C,3*A,2*A),c.setRenderTarget(t),c.render(f,Ci)}};function P9(){let n=[],e=[],t=[],i=d4;for(let a=0;a<z5;a++){let r=Math.pow(2,i);e.push(r);let s=1/r;a>d4-ct?s=C5[a-d4+ct-1]:a===0&&(s=0),t.push(s);let o=1/(r-1),c=-o/2,l=1+o/2,u=[c,c,l,c,l,l,c,c,l,l,c,l],f=6,h=6,m=3,v=2,g=1,x=new Float32Array(m*h*f),p=new Float32Array(v*h*f),d=new Float32Array(g*h*f);for(let b=0;b<f;b++){let C=b%3*2/3-1,E=b>2?0:-1,T=[C,E,0,C+2/3,E,0,C+2/3,E+1,0,C,E,0,C+2/3,E+1,0,C,E+1,0];x.set(T,m*h*b),p.set(u,v*h*b);let _=[b,b,b,b,b,b];d.set(_,g*h*b)}let A=new b2;A.setAttribute("position",new M2(x,m)),A.setAttribute("uv",new M2(p,v)),A.setAttribute("faceIndex",new M2(d,g)),n.push(A),i>ct&&i--}return{_lodPlanes:n,_sizeLods:e,_sigmas:t}}function _5(n){let e=new m2(3*Ae,3*Ae,n);return e.texture.mapping=a4,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function r0(n,e,t,i,a){n.viewport.set(e,t,i,a),n.scissor.set(e,t,i,a)}function I9(n){let e=new Float32Array(n),t=new k(0,1,0);return new ot({name:"SphericalGaussianBlur",defines:{n},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t}},vertexShader:Ai(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform int samples;
uniform float weights[ n ];
uniform bool latitudinal;
uniform float dTheta;
uniform float mipInt;
uniform vec3 poleAxis;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
vec3 getSample( float theta, vec3 axis ) {
float cosTheta = cos( theta );
// Rodrigues' axis-angle rotation
vec3 sampleDirection = vOutputDirection * cosTheta
+ cross( axis, vOutputDirection ) * sin( theta )
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
return bilinearCubeUV( envMap, sampleDirection, mipInt );
}
void main() {
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
}
axis = normalize( axis );
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
for ( int i = 1; i < n; i++ ) {
if ( i >= samples ) {
break;
}
float theta = dTheta * float( i );
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
}
}
`,blending:U2,depthTest:!1,depthWrite:!1})}function E5(){let n=new z1(1,1);return new ot({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:n}},vertexShader:Ai(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform vec2 texelSize;
#include <common>
void main() {
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
vec3 outputDirection = normalize( vOutputDirection );
vec2 uv = equirectUv( outputDirection );
vec2 f = fract( uv / texelSize - 0.5 );
uv -= f * texelSize;
vec3 tl = texture2D ( envMap, uv ).rgb;
uv.x += texelSize.x;
vec3 tr = texture2D ( envMap, uv ).rgb;
uv.y += texelSize.y;
vec3 br = texture2D ( envMap, uv ).rgb;
uv.x -= texelSize.x;
vec3 bl = texture2D ( envMap, uv ).rgb;
vec3 tm = mix( tl, tr, f.x );
vec3 bm = mix( bl, br, f.x );
gl_FragColor.rgb = mix( tm, bm, f.y );
}
`,blending:U2,depthTest:!1,depthWrite:!1})}function L5(){return new ot({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ai(),fragmentShader:`
precision mediump float;
precision mediump int;
uniform float flipEnvMap;
varying vec3 vOutputDirection;
uniform samplerCube envMap;
void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
`,blending:U2,depthTest:!1,depthWrite:!1})}function Ai(){return`
precision mediump float;
precision mediump int;
attribute vec3 position;
attribute vec2 uv;
attribute float faceIndex;
varying vec3 vOutputDirection;
// RH coordinate system; PMREM face-indexing convention
vec3 getDirection( vec2 uv, float face ) {
uv = 2.0 * uv - 1.0;
vec3 direction = vec3( uv, 1.0 );
if ( face == 0.0 ) {
direction = direction.zyx; // ( 1, v, u ) pos x
} else if ( face == 1.0 ) {
direction = direction.xzy;
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
} else if ( face == 2.0 ) {
direction.x *= -1.0; // ( -u, v, 1 ) pos z
} else if ( face == 3.0 ) {
direction = direction.zyx;
direction.xz *= -1.0; // ( -1, v, -u ) neg x
} else if ( face == 4.0 ) {
direction = direction.xzy;
direction.xy *= -1.0; // ( -u, -1, v ) neg y
} else if ( face == 5.0 ) {
direction.z *= -1.0; // ( u, v, -1 ) neg z
}
return direction;
}
void main() {
vOutputDirection = getDirection( uv, faceIndex );
gl_Position = vec4( position, 1.0 );
}
`}function D5(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){let c=o.mapping,l=c===Lt||c===Dt,u=c===be||c===Ue;if(l||u)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let f=e.get(o);return t===null&&(t=new a0(n)),f=l?t.fromEquirectangular(o,f):t.fromCubemap(o,f),e.set(o,f),f.texture}else{if(e.has(o))return e.get(o).texture;{let f=o.image;if(l&&f&&f.height>0||u&&f&&a(f)){t===null&&(t=new a0(n));let h=l?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,h),o.addEventListener("dispose",r),h.texture}else return null}}}return o}function a(o){let c=0,l=6;for(let u=0;u<l;u++)o[u]!==void 0&&c++;return c===l}function r(o){let c=o.target;c.removeEventListener("dispose",r);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function s(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:s}}function T5(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let a;switch(i){case"WEBGL_depth_texture":a=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":a=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":a=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":a=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:a=n.getExtension(i)}return e[i]=a,a}return{has:function(i){return t(i)!==null},init:function(i){i.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(i){let a=t(i);return a===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),a}}}function H5(n,e,t,i){let a={},r=new WeakMap;function s(f){let h=f.target;h.index!==null&&e.remove(h.index);for(let v in h.attributes)e.remove(h.attributes[v]);h.removeEventListener("dispose",s),delete a[h.id];let m=r.get(h);m&&(e.remove(m),r.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function o(f,h){return a[h.id]===!0||(h.addEventListener("dispose",s),a[h.id]=!0,t.memory.geometries++),h}function c(f){let h=f.attributes;for(let v in h)e.update(h[v],n.ARRAY_BUFFER);let m=f.morphAttributes;for(let v in m){let g=m[v];for(let x=0,p=g.length;x<p;x++)e.update(g[x],n.ARRAY_BUFFER)}}function l(f){let h=[],m=f.index,v=f.attributes.position,g=0;if(m!==null){let d=m.array;g=m.version;for(let A=0,b=d.length;A<b;A+=3){let C=d[A+0],E=d[A+1],T=d[A+2];h.push(C,E,E,T,T,C)}}else{let d=v.array;g=v.version;for(let A=0,b=d.length/3-1;A<b;A+=3){let C=A+0,E=A+1,T=A+2;h.push(C,E,E,T,T,C)}}let x=new(k6(h)?Ft:Rt)(h,1);x.version=g;let p=r.get(f);p&&e.remove(p),r.set(f,x)}function u(f){let h=r.get(f);if(h){let m=f.index;m!==null&&h.version<m.version&&l(f)}else l(f);return r.get(f)}return{get:o,update:c,getWireframeAttribute:u}}function V5(n,e,t,i){let a=i.isWebGL2,r;function s(h){r=h}let o,c;function l(h){o=h.type,c=h.bytesPerElement}function u(h,m){n.drawElements(r,m,o,h*c),t.update(m,r,1)}function f(h,m,v){if(v===0)return;let g,x;if(a)g=n,x="drawElementsInstanced";else if(g=e.get("ANGLE_instanced_arrays"),x="drawElementsInstancedANGLE",g===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[x](r,m,o,h*c,v),t.update(m,r,v)}this.setMode=s,this.setIndex=l,this.render=u,this.renderInstances=f}function N5(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,s,o){switch(t.calls++,s){case n.TRIANGLES:t.triangles+=o*(r/3);break;case n.LINES:t.lines+=o*(r/2);break;case n.LINE_STRIP:t.lines+=o*(r-1);break;case n.LINE_LOOP:t.lines+=o*r;break;case n.POINTS:t.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",s);break}}function a(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:a,update:i}}var ht=class extends $1{constructor(e=null,t=1,i=1,a=1){super(null);this.image={data:e,width:t,height:i,depth:a},this.magFilter=Q1,this.minFilter=Q1,this.wrapR=c2,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};ht.prototype.isDataTexture2DArray=!0;function k9(n,e){return n[0]-e[0]}function U9(n,e){return Math.abs(e[1])-Math.abs(n[1])}function R5(n,e){let t=1,i=e.isInterleavedBufferAttribute?e.data.array:e.array;i instanceof Int8Array?t=127:i instanceof Int16Array?t=32767:i instanceof Int32Array?t=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",i),n.divideScalar(t)}function F5(n,e,t){let i={},a=new Float32Array(8),r=new WeakMap,s=new k,o=[];for(let l=0;l<8;l++)o[l]=[l,0];function c(l,u,f,h){let m=l.morphTargetInfluences;if(e.isWebGL2===!0){let v=u.morphAttributes.position.length,g=r.get(u);if(g===void 0||g.count!==v){let D=function(){F.dispose(),r.delete(u),u.removeEventListener("dispose",D)};g!==void 0&&g.texture.dispose();let d=u.morphAttributes.normal!==void 0,A=u.morphAttributes.position,b=u.morphAttributes.normal||[],C=u.attributes.position.count,E=d===!0?2:1,T=C*E,_=1;T>e.maxTextureSize&&(_=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);let P=new Float32Array(T*_*4*v),F=new ht(P,T,_,v);F.format=W1,F.type=Q2,F.needsUpdate=!0;let M=E*4;for(let z=0;z<v;z++){let H=A[z],V=b[z],L=T*_*4*z;for(let N=0;N<H.count;N++){s.fromBufferAttribute(H,N),H.normalized===!0&&R5(s,H);let U=N*M;P[L+U+0]=s.x,P[L+U+1]=s.y,P[L+U+2]=s.z,P[L+U+3]=0,d===!0&&(s.fromBufferAttribute(V,N),V.normalized===!0&&R5(s,V),P[L+U+4]=s.x,P[L+U+5]=s.y,P[L+U+6]=s.z,P[L+U+7]=0)}}g={count:v,texture:F,size:new z1(T,_)},r.set(u,g),u.addEventListener("dispose",D)}let x=0;for(let d=0;d<m.length;d++)x+=m[d];let p=u.morphTargetsRelative?1:1-x;h.getUniforms().setValue(n,"morphTargetBaseInfluence",p),h.getUniforms().setValue(n,"morphTargetInfluences",m),h.getUniforms().setValue(n,"morphTargetsTexture",g.texture,t),h.getUniforms().setValue(n,"morphTargetsTextureSize",g.size)}else{let v=m===void 0?0:m.length,g=i[u.id];if(g===void 0||g.length!==v){g=[];for(let b=0;b<v;b++)g[b]=[b,0];i[u.id]=g}for(let b=0;b<v;b++){let C=g[b];C[0]=b,C[1]=m[b]}g.sort(U9);for(let b=0;b<8;b++)b<v&&g[b][1]?(o[b][0]=g[b][0],o[b][1]=g[b][1]):(o[b][0]=Number.MAX_SAFE_INTEGER,o[b][1]=0);o.sort(k9);let x=u.morphAttributes.position,p=u.morphAttributes.normal,d=0;for(let b=0;b<8;b++){let C=o[b],E=C[0],T=C[1];E!==Number.MAX_SAFE_INTEGER&&T?(x&&u.getAttribute("morphTarget"+b)!==x[E]&&u.setAttribute("morphTarget"+b,x[E]),p&&u.getAttribute("morphNormal"+b)!==p[E]&&u.setAttribute("morphNormal"+b,p[E]),a[b]=T,d+=T):(x&&u.hasAttribute("morphTarget"+b)===!0&&u.deleteAttribute("morphTarget"+b),p&&u.hasAttribute("morphNormal"+b)===!0&&u.deleteAttribute("morphNormal"+b),a[b]=0)}let A=u.morphTargetsRelative?1:1-d;h.getUniforms().setValue(n,"morphTargetBaseInfluence",A),h.getUniforms().setValue(n,"morphTargetInfluences",a)}}return{update:c}}var ft=class extends m2{constructor(e,t,i={}){super(e,t,i);this.samples=4,this.ignoreDepthForMultisampleCopy=i.ignoreDepth!==void 0?i.ignoreDepth:!0,this.useRenderToTexture=i.useRenderToTexture!==void 0?i.useRenderToTexture:!1,this.useRenderbuffer=this.useRenderToTexture===!1}copy(e){return super.copy.call(this,e),this.samples=e.samples,this.useRenderToTexture=e.useRenderToTexture,this.useRenderbuffer=e.useRenderbuffer,this}};ft.prototype.isWebGLMultisampleRenderTarget=!0;function B5(n,e,t,i){let a=new WeakMap;function r(c){let l=i.render.frame,u=c.geometry,f=e.get(c,u);return a.get(f)!==l&&(e.update(f),a.set(f,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER)),f}function s(){a=new WeakMap}function o(c){let l=c.target;l.removeEventListener("dispose",o),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:r,dispose:s}}var n0=class extends $1{constructor(e=null,t=1,i=1,a=1){super(null);this.image={data:e,width:t,height:i,depth:a},this.magFilter=Q1,this.minFilter=Q1,this.wrapR=c2,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};n0.prototype.isDataTexture3D=!0;var P5=new $1,I5=new ht,k5=new n0,U5=new st,O5=[],G5=[],q5=new Float32Array(16),W5=new Float32Array(9),j5=new Float32Array(4);function dt(n,e,t){let i=n[0];if(i<=0||i>0)return n;let a=e*t,r=O5[a];if(r===void 0&&(r=new Float32Array(a),O5[a]=r),e!==0){i.toArray(r,0);for(let s=1,o=0;s!==e;++s)o+=t,n[s].toArray(r,o)}return r}function A2(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function y2(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function s0(n,e){let t=G5[e];t===void 0&&(t=new Int32Array(e),G5[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function O9(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function G9(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(A2(t,e))return;n.uniform2fv(this.addr,e),y2(t,e)}}function q9(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(A2(t,e))return;n.uniform3fv(this.addr,e),y2(t,e)}}function W9(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(A2(t,e))return;n.uniform4fv(this.addr,e),y2(t,e)}}function j9(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(A2(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),y2(t,e)}else{if(A2(t,i))return;j5.set(i),n.uniformMatrix2fv(this.addr,!1,j5),y2(t,i)}}function X9(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(A2(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),y2(t,e)}else{if(A2(t,i))return;W5.set(i),n.uniformMatrix3fv(this.addr,!1,W5),y2(t,i)}}function Z9(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(A2(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),y2(t,e)}else{if(A2(t,i))return;q5.set(i),n.uniformMatrix4fv(this.addr,!1,q5),y2(t,i)}}function Y9(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function $9(n,e){let t=this.cache;A2(t,e)||(n.uniform2iv(this.addr,e),y2(t,e))}function K9(n,e){let t=this.cache;A2(t,e)||(n.uniform3iv(this.addr,e),y2(t,e))}function J9(n,e){let t=this.cache;A2(t,e)||(n.uniform4iv(this.addr,e),y2(t,e))}function Q9(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function eu(n,e){let t=this.cache;A2(t,e)||(n.uniform2uiv(this.addr,e),y2(t,e))}function tu(n,e){let t=this.cache;A2(t,e)||(n.uniform3uiv(this.addr,e),y2(t,e))}function iu(n,e){let t=this.cache;A2(t,e)||(n.uniform4uiv(this.addr,e),y2(t,e))}function au(n,e,t){let i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a),t.safeSetTexture2D(e||P5,a)}function ru(n,e,t){let i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a),t.setTexture3D(e||k5,a)}function nu(n,e,t){let i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a),t.safeSetTextureCube(e||U5,a)}function su(n,e,t){let i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a),t.setTexture2DArray(e||I5,a)}function ou(n){switch(n){case 5126:return O9;case 35664:return G9;case 35665:return q9;case 35666:return W9;case 35674:return j9;case 35675:return X9;case 35676:return Z9;case 5124:case 35670:return Y9;case 35667:case 35671:return $9;case 35668:case 35672:return K9;case 35669:case 35673:return J9;case 5125:return Q9;case 36294:return eu;case 36295:return tu;case 36296:return iu;case 35678:case 36198:case 36298:case 36306:case 35682:return au;case 35679:case 36299:case 36307:return ru;case 35680:case 36300:case 36308:case 36293:return nu;case 36289:case 36303:case 36311:case 36292:return su}}function cu(n,e){n.uniform1fv(this.addr,e)}function lu(n,e){let t=dt(e,this.size,2);n.uniform2fv(this.addr,t)}function uu(n,e){let t=dt(e,this.size,3);n.uniform3fv(this.addr,t)}function hu(n,e){let t=dt(e,this.size,4);n.uniform4fv(this.addr,t)}function fu(n,e){let t=dt(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function du(n,e){let t=dt(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function pu(n,e){let t=dt(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function mu(n,e){n.uniform1iv(this.addr,e)}function vu(n,e){n.uniform2iv(this.addr,e)}function gu(n,e){n.uniform3iv(this.addr,e)}function xu(n,e){n.uniform4iv(this.addr,e)}function Mu(n,e){n.uniform1uiv(this.addr,e)}function bu(n,e){n.uniform2uiv(this.addr,e)}function yu(n,e){n.uniform3uiv(this.addr,e)}function Cu(n,e){n.uniform4uiv(this.addr,e)}function zu(n,e,t){let i=e.length,a=s0(t,i);n.uniform1iv(this.addr,a);for(let r=0;r!==i;++r)t.safeSetTexture2D(e[r]||P5,a[r])}function Au(n,e,t){let i=e.length,a=s0(t,i);n.uniform1iv(this.addr,a);for(let r=0;r!==i;++r)t.setTexture3D(e[r]||k5,a[r])}function wu(n,e,t){let i=e.length,a=s0(t,i);n.uniform1iv(this.addr,a);for(let r=0;r!==i;++r)t.safeSetTextureCube(e[r]||U5,a[r])}function Su(n,e,t){let i=e.length,a=s0(t,i);n.uniform1iv(this.addr,a);for(let r=0;r!==i;++r)t.setTexture2DArray(e[r]||I5,a[r])}function _u(n){switch(n){case 5126:return cu;case 35664:return lu;case 35665:return uu;case 35666:return hu;case 35674:return fu;case 35675:return du;case 35676:return pu;case 5124:case 35670:return mu;case 35667:case 35671:return vu;case 35668:case 35672:return gu;case 35669:case 35673:return xu;case 5125:return Mu;case 36294:return bu;case 36295:return yu;case 36296:return Cu;case 35678:case 36198:case 36298:case 36306:case 35682:return zu;case 35679:case 36299:case 36307:return Au;case 35680:case 36300:case 36308:case 36293:return wu;case 36289:case 36303:case 36311:case 36292:return Su}}function Eu(n,e,t){this.id=n,this.addr=t,this.cache=[],this.setValue=ou(e.type)}function X5(n,e,t){this.id=n,this.addr=t,this.cache=[],this.size=e.size,this.setValue=_u(e.type)}X5.prototype.updateCache=function(n){let e=this.cache;n instanceof Float32Array&&e.length!==n.length&&(this.cache=new Float32Array(n.length)),y2(e,n)};function Z5(n){this.id=n,this.seq=[],this.map={}}Z5.prototype.setValue=function(n,e,t){let i=this.seq;for(let a=0,r=i.length;a!==r;++a){let s=i[a];s.setValue(n,e[s.id],t)}};var wi=/(\w+)(\])?(\[|\.)?/g;function Y5(n,e){n.seq.push(e),n.map[e.id]=e}function Lu(n,e,t){let i=n.name,a=i.length;for(wi.lastIndex=0;;){let r=wi.exec(i),s=wi.lastIndex,o=r[1],c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&s+2===a){Y5(t,l===void 0?new Eu(o,n,e):new X5(o,n,e));break}else{let f=t.map[o];f===void 0&&(f=new Z5(o),Y5(t,f)),t=f}}}function we(n,e){this.seq=[],this.map={};let t=n.getProgramParameter(e,n.ACTIVE_UNIFORMS);for(let i=0;i<t;++i){let a=n.getActiveUniform(e,i),r=n.getUniformLocation(e,a.name);Lu(a,r,this)}}we.prototype.setValue=function(n,e,t,i){let a=this.map[e];a!==void 0&&a.setValue(n,t,i)};we.prototype.setOptional=function(n,e,t){let i=e[t];i!==void 0&&this.setValue(n,t,i)};we.upload=function(n,e,t,i){for(let a=0,r=e.length;a!==r;++a){let s=e[a],o=t[s.id];o.needsUpdate!==!1&&s.setValue(n,o.value,i)}};we.seqWithValue=function(n,e){let t=[];for(let i=0,a=n.length;i!==a;++i){let r=n[i];r.id in e&&t.push(r)}return t};function Si(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}var Du=0;function Tu(n){let e=n.split(`
`);for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join(`
`)}function Hu(n){switch(n){case R2:return["Linear","( value )"];case I1:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",n),["Linear","( value )"]}}function $5(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),a=n.getShaderInfoLog(e).trim();return i&&a===""?"":t.toUpperCase()+`
`+a+`
`+Tu(n.getShaderSource(e))}function Vu(n,e){let t=Hu(e);return"vec4 "+n+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function Nu(n,e){let t;switch(e){case a8:t="Linear";break;case r8:t="Reinhard";break;case n8:t="OptimizedCineon";break;case s8:t="ACESFilmic";break;case o8:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function Ru(n){return[n.extensionDerivatives||n.envMapCubeUV||n.bumpMap||n.tangentSpaceNormalMap||n.clearcoatNormalMap||n.flatShading||n.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap||n.transmission)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(qt).join(`
`)}function Fu(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
`)}function Bu(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let a=0;a<i;a++){let r=n.getActiveAttrib(e,a),s=r.name,o=1;r.type===n.FLOAT_MAT2&&(o=2),r.type===n.FLOAT_MAT3&&(o=3),r.type===n.FLOAT_MAT4&&(o=4),t[s]={type:r.type,location:n.getAttribLocation(e,s),locationSize:o}}return t}function qt(n){return n!==""}function K5(n,e){return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function J5(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var Pu=/^[ \t]*#include +<([\w\d./]+)>/gm;function _i(n){return n.replace(Pu,Iu)}function Iu(n,e){let t=S1[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return _i(t)}var ku=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Uu=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Q5(n){return n.replace(Uu,eo).replace(ku,Ou)}function Ou(n,e,t,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),eo(n,e,t,i)}function eo(n,e,t,i){let a="";for(let r=parseInt(e);r<parseInt(t);r++)a+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return a}function to(n){let e="precision "+n.precision+` float;
precision `+n.precision+" int;";return n.precision==="highp"?e+=`
#define HIGH_PRECISION`:n.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function Gu(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===A6?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===w6?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===z4&&(e="SHADOWMAP_TYPE_VSM"),e}function qu(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case be:case Ue:e="ENVMAP_TYPE_CUBE";break;case a4:case Tt:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Wu(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case Ue:case Tt:e="ENVMAP_MODE_REFRACTION";break}return e}function ju(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case G4:e="ENVMAP_BLENDING_MULTIPLY";break;case t8:e="ENVMAP_BLENDING_MIX";break;case i8:e="ENVMAP_BLENDING_ADD";break}return e}function io(n,e,t,i){let a=n.getContext(),r=t.defines,s=t.vertexShader,o=t.fragmentShader,c=Gu(t),l=qu(t),u=Wu(t),f=ju(t),h=t.isWebGL2?"":Ru(t),m=Fu(r),v=a.createProgram(),g,x,p=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(g=[m].filter(qt).join(`
`),g.length>0&&(g+=`
`),x=[h,m].filter(qt).join(`
`),x.length>0&&(x+=`
`)):(g=[to(t),"#define SHADER_NAME "+t.shaderName,m,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define MAX_BONES "+t.maxBones,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.useVertexTexture?"#define BONE_TEXTURE":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphTargets&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargets&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
`].filter(qt).join(`
`),x=[h,to(t),"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+f:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==O2?"#define TONE_MAPPING":"",t.toneMapping!==O2?S1.tonemapping_pars_fragment:"",t.toneMapping!==O2?Nu("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.alphaWrite?"":"#define OPAQUE",S1.encodings_pars_fragment,Vu("linearToOutputTexel",t.outputEncoding),t.depthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(qt).join(`
`)),s=_i(s),s=K5(s,t),s=J5(s,t),o=_i(o),o=K5(o,t),o=J5(o,t),s=Q5(s),o=Q5(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(p=`#version 300 es
`,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+g,x=["#define varying in",t.glslVersion===V3?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===V3?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+x);let d=p+g+s,A=p+x+o,b=Si(a,a.VERTEX_SHADER,d),C=Si(a,a.FRAGMENT_SHADER,A);if(a.attachShader(v,b),a.attachShader(v,C),t.index0AttributeName!==void 0?a.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&a.bindAttribLocation(v,0,"position"),a.linkProgram(v),n.debug.checkShaderErrors){let _=a.getProgramInfoLog(v).trim(),P=a.getShaderInfoLog(b).trim(),F=a.getShaderInfoLog(C).trim(),M=!0,D=!0;if(a.getProgramParameter(v,a.LINK_STATUS)===!1){M=!1;let z=$5(a,b,"vertex"),H=$5(a,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(v,a.VALIDATE_STATUS)+`
Program Info Log: `+_+`
`+z+`
`+H)}else _!==""?console.warn("THREE.WebGLProgram: Program Info Log:",_):(P===""||F==="")&&(D=!1);D&&(this.diagnostics={runnable:M,programLog:_,vertexShader:{log:P,prefix:g},fragmentShader:{log:F,prefix:x}})}a.deleteShader(b),a.deleteShader(C);let E;this.getUniforms=function(){return E===void 0&&(E=new we(a,v)),E};let T;return this.getAttributes=function(){return T===void 0&&(T=Bu(a,v)),T},this.destroy=function(){i.releaseStatesOfProgram(this),a.deleteProgram(v),this.program=void 0},this.name=t.shaderName,this.id=Du++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=b,this.fragmentShader=C,this}var Xu=0,Ei=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,a=this._getShaderStage(t),r=this._getShaderStage(i),s=this._getShaderCacheForMaterial(e);return s.has(a)===!1&&(s.add(a),a.usedTimes++),s.has(r)===!1&&(s.add(r),r.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){let t=this.shaderCache;if(t.has(e)===!1){let i=new ao;t.set(e,i)}return t.get(e)}},ao=class{constructor(){this.id=Xu++,this.usedTimes=0}};function ro(n,e,t,i,a,r,s){let o=new Pt,c=new Ei,l=[],u=a.isWebGL2,f=a.logarithmicDepthBuffer,h=a.floatVertexTextures,m=a.maxVertexUniforms,v=a.vertexTextures,g=a.precision,x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(M){let z=M.skeleton.bones;if(h)return 1024;{let V=Math.floor((m-20)/4),L=Math.min(V,z.length);return L<z.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+z.length+" bones. This GPU supports "+L+"."),0):L}}function d(M,D,z,H,V){let L=H.fog,N=M.isMeshStandardMaterial?H.environment:null,U=(M.isMeshStandardMaterial?t:e).get(M.envMap||N),Z=x[M.type],O=V.isSkinnedMesh?p(V):0;M.precision!==null&&(g=a.getMaxPrecision(M.precision),g!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",g,"instead."));let W,X,Q,a1;if(Z){let n1=W2[Z];W=n1.vertexShader,X=n1.fragmentShader}else W=M.vertexShader,X=M.fragmentShader,c.update(M),Q=c.getVertexShaderID(M),a1=c.getFragmentShaderID(M);let B=n.getRenderTarget(),M1=M.alphaTest>0,u1=M.clearcoat>0;return{isWebGL2:u,shaderID:Z,shaderName:M.type,vertexShader:W,fragmentShader:X,defines:M.defines,customVertexShaderID:Q,customFragmentShaderID:a1,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:g,instancing:V.isInstancedMesh===!0,instancingColor:V.isInstancedMesh===!0&&V.instanceColor!==null,supportsVertexTextures:v,outputEncoding:B===null?n.outputEncoding:B.isXRRenderTarget===!0?B.texture.encoding:R2,map:!!M.map,matcap:!!M.matcap,envMap:!!U,envMapMode:U&&U.mapping,envMapCubeUV:!!U&&(U.mapping===a4||U.mapping===Tt),lightMap:!!M.lightMap,aoMap:!!M.aoMap,emissiveMap:!!M.emissiveMap,bumpMap:!!M.bumpMap,normalMap:!!M.normalMap,objectSpaceNormalMap:M.normalMapType===w8,tangentSpaceNormalMap:M.normalMapType===H6,decodeVideoTexture:!!M.map&&M.map.isVideoTexture===!0&&M.map.encoding===I1,clearcoat:u1,clearcoatMap:u1&&!!M.clearcoatMap,clearcoatRoughnessMap:u1&&!!M.clearcoatRoughnessMap,clearcoatNormalMap:u1&&!!M.clearcoatNormalMap,displacementMap:!!M.displacementMap,roughnessMap:!!M.roughnessMap,metalnessMap:!!M.metalnessMap,specularMap:!!M.specularMap,specularIntensityMap:!!M.specularIntensityMap,specularColorMap:!!M.specularColorMap,alphaMap:!!M.alphaMap,alphaTest:M1,alphaWrite:M.alphaWrite||M.transparent,gradientMap:!!M.gradientMap,sheen:M.sheen>0,sheenColorMap:!!M.sheenColorMap,sheenRoughnessMap:!!M.sheenRoughnessMap,transmission:M.transmission>0,transmissionMap:!!M.transmissionMap,thicknessMap:!!M.thicknessMap,combine:M.combine,vertexTangents:!!M.normalMap&&!!V.geometry&&!!V.geometry.attributes.tangent,vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!V.geometry&&!!V.geometry.attributes.color&&V.geometry.attributes.color.itemSize===4,vertexUvs:!!M.map||!!M.bumpMap||!!M.normalMap||!!M.specularMap||!!M.alphaMap||!!M.emissiveMap||!!M.roughnessMap||!!M.metalnessMap||!!M.clearcoatMap||!!M.clearcoatRoughnessMap||!!M.clearcoatNormalMap||!!M.displacementMap||!!M.transmissionMap||!!M.thicknessMap||!!M.specularIntensityMap||!!M.specularColorMap||!!M.sheenColorMap||!!M.sheenRoughnessMap,uvsVertexOnly:!(!!M.map||!!M.bumpMap||!!M.normalMap||!!M.specularMap||!!M.alphaMap||!!M.emissiveMap||!!M.roughnessMap||!!M.metalnessMap||!!M.clearcoatNormalMap||M.transmission>0||!!M.transmissionMap||!!M.thicknessMap||!!M.specularIntensityMap||!!M.specularColorMap||M.sheen>0||!!M.sheenColorMap||!!M.sheenRoughnessMap)&&!!M.displacementMap,fog:!!L,useFog:M.fog,fogExp2:L&&L.isFogExp2,flatShading:!!M.flatShading,sizeAttenuation:M.sizeAttenuation,logarithmicDepthBuffer:f,skinning:V.isSkinnedMesh===!0&&O>0,maxBones:O,useVertexTexture:h,morphTargets:!!V.geometry&&!!V.geometry.morphAttributes.position,morphNormals:!!V.geometry&&!!V.geometry.morphAttributes.normal,morphTargetsCount:!!V.geometry&&!!V.geometry.morphAttributes.position?V.geometry.morphAttributes.position.length:0,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&z.length>0,shadowMapType:n.shadowMap.type,toneMapping:M.toneMapped?n.toneMapping:O2,physicallyCorrectLights:n.physicallyCorrectLights,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===J2,flipSided:M.side===P1,depthPacking:M.depthPacking!==void 0?M.depthPacking:!1,index0AttributeName:M.index0AttributeName,extensionDerivatives:M.extensions&&M.extensions.derivatives,extensionFragDepth:M.extensions&&M.extensions.fragDepth,extensionDrawBuffers:M.extensions&&M.extensions.drawBuffers,extensionShaderTextureLOD:M.extensions&&M.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||i.has("EXT_shader_texture_lod"),customProgramCacheKey:M.customProgramCacheKey()}}function A(M){let D=[];if(M.shaderID?D.push(M.shaderID):(D.push(M.customVertexShaderID),D.push(M.customFragmentShaderID)),M.defines!==void 0)for(let z in M.defines)D.push(z),D.push(M.defines[z]);return M.isRawShaderMaterial===!1&&(b(D,M),C(D,M),D.push(n.outputEncoding)),D.push(M.customProgramCacheKey),D.join()}function b(M,D){M.push(D.precision),M.push(D.outputEncoding),M.push(D.envMapMode),M.push(D.combine),M.push(D.vertexUvs),M.push(D.fogExp2),M.push(D.sizeAttenuation),M.push(D.maxBones),M.push(D.morphTargetsCount),M.push(D.numDirLights),M.push(D.numPointLights),M.push(D.numSpotLights),M.push(D.numHemiLights),M.push(D.numRectAreaLights),M.push(D.numDirLightShadows),M.push(D.numPointLightShadows),M.push(D.numSpotLightShadows),M.push(D.shadowMapType),M.push(D.toneMapping),M.push(D.numClippingPlanes),M.push(D.numClipIntersection),M.push(D.alphaWrite)}function C(M,D){o.disableAll(),D.isWebGL2&&o.enable(0),D.supportsVertexTextures&&o.enable(1),D.instancing&&o.enable(2),D.instancingColor&&o.enable(3),D.map&&o.enable(4),D.matcap&&o.enable(5),D.envMap&&o.enable(6),D.envMapCubeUV&&o.enable(7),D.lightMap&&o.enable(8),D.aoMap&&o.enable(9),D.emissiveMap&&o.enable(10),D.bumpMap&&o.enable(11),D.normalMap&&o.enable(12),D.objectSpaceNormalMap&&o.enable(13),D.tangentSpaceNormalMap&&o.enable(14),D.clearcoat&&o.enable(15),D.clearcoatMap&&o.enable(16),D.clearcoatRoughnessMap&&o.enable(17),D.clearcoatNormalMap&&o.enable(18),D.displacementMap&&o.enable(19),D.specularMap&&o.enable(20),D.roughnessMap&&o.enable(21),D.metalnessMap&&o.enable(22),D.gradientMap&&o.enable(23),D.alphaMap&&o.enable(24),D.alphaTest&&o.enable(25),D.vertexColors&&o.enable(26),D.vertexAlphas&&o.enable(27),D.vertexUvs&&o.enable(28),D.vertexTangents&&o.enable(29),D.uvsVertexOnly&&o.enable(30),D.fog&&o.enable(31),M.push(o.mask),o.disableAll(),D.useFog&&o.enable(0),D.flatShading&&o.enable(1),D.logarithmicDepthBuffer&&o.enable(2),D.skinning&&o.enable(3),D.useVertexTexture&&o.enable(4),D.morphTargets&&o.enable(5),D.morphNormals&&o.enable(6),D.premultipliedAlpha&&o.enable(7),D.shadowMapEnabled&&o.enable(8),D.physicallyCorrectLights&&o.enable(9),D.doubleSided&&o.enable(10),D.flipSided&&o.enable(11),D.depthPacking&&o.enable(12),D.dithering&&o.enable(13),D.specularIntensityMap&&o.enable(14),D.specularColorMap&&o.enable(15),D.transmission&&o.enable(16),D.transmissionMap&&o.enable(17),D.thicknessMap&&o.enable(18),D.sheen&&o.enable(19),D.sheenColorMap&&o.enable(20),D.sheenRoughnessMap&&o.enable(21),D.decodeVideoTexture&&o.enable(22),M.push(o.mask)}function E(M){let D=x[M.type],z;if(D){let H=W2[D];z=k8.clone(H.uniforms)}else z=M.uniforms;return z}function T(M,D){let z;for(let H=0,V=l.length;H<V;H++){let L=l[H];if(L.cacheKey===D){z=L,++z.usedTimes;break}}return z===void 0&&(z=new io(n,D,M,r),l.push(z)),z}function _(M){if(--M.usedTimes==0){let D=l.indexOf(M);l[D]=l[l.length-1],l.pop(),M.destroy()}}function P(M){c.remove(M)}function F(){c.dispose()}return{getParameters:d,getProgramCacheKey:A,getUniforms:E,acquireProgram:T,releaseProgram:_,releaseShaderCache:P,programs:l,dispose:F}}function no(){let n=new WeakMap;function e(r){let s=n.get(r);return s===void 0&&(s={},n.set(r,s)),s}function t(r){n.delete(r)}function i(r,s,o){n.get(r)[s]=o}function a(){n=new WeakMap}return{get:e,remove:t,update:i,dispose:a}}function Zu(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function so(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function oo(){let n=[],e=0,t=[],i=[],a=[];function r(){e=0,t.length=0,i.length=0,a.length=0}function s(f,h,m,v,g,x){let p=n[e];return p===void 0?(p={id:f.id,object:f,geometry:h,material:m,groupOrder:v,renderOrder:f.renderOrder,z:g,group:x},n[e]=p):(p.id=f.id,p.object=f,p.geometry=h,p.material=m,p.groupOrder=v,p.renderOrder=f.renderOrder,p.z=g,p.group=x),e++,p}function o(f,h,m,v,g,x){let p=s(f,h,m,v,g,x);m.transmission>0?i.push(p):m.transparent===!0?a.push(p):t.push(p)}function c(f,h,m,v,g,x){let p=s(f,h,m,v,g,x);m.transmission>0?i.unshift(p):m.transparent===!0?a.unshift(p):t.unshift(p)}function l(f,h){t.length>1&&t.sort(f||Zu),i.length>1&&i.sort(h||so),a.length>1&&a.sort(h||so)}function u(){for(let f=e,h=n.length;f<h;f++){let m=n[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:i,transparent:a,init:r,push:o,unshift:c,finish:u,sort:l}}function co(){let n=new WeakMap;function e(i,a){let r;return n.has(i)===!1?(r=new oo,n.set(i,[r])):a>=n.get(i).length?(r=new oo,n.get(i).push(r)):r=n.get(i)[a],r}function t(){n=new WeakMap}return{get:e,dispose:t}}function Yu(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new k,color:new x1};break;case"SpotLight":t={position:new k,direction:new k,color:new x1,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new k,color:new x1,distance:0,decay:0};break;case"HemisphereLight":t={direction:new k,skyColor:new x1,groundColor:new x1};break;case"RectAreaLight":t={color:new x1,position:new k,halfWidth:new k,halfHeight:new k};break}return n[e.id]=t,t}}}function $u(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new z1};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new z1};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new z1,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}var Ku=0;function Ju(n,e){return(e.castShadow?1:0)-(n.castShadow?1:0)}function lo(n,e){let t=new Yu,i=$u(),a={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let u=0;u<9;u++)a.probe.push(new k);let r=new k,s=new k1,o=new k1;function c(u,f){let h=0,m=0,v=0;for(let P=0;P<9;P++)a.probe[P].set(0,0,0);let g=0,x=0,p=0,d=0,A=0,b=0,C=0,E=0;u.sort(Ju);let T=f!==!0?Math.PI:1;for(let P=0,F=u.length;P<F;P++){let M=u[P],D=M.color,z=M.intensity,H=M.distance,V=M.shadow&&M.shadow.map?M.shadow.map.texture:null;if(M.isAmbientLight)h+=D.r*z*T,m+=D.g*z*T,v+=D.b*z*T;else if(M.isLightProbe)for(let L=0;L<9;L++)a.probe[L].addScaledVector(M.sh.coefficients[L],z);else if(M.isDirectionalLight){let L=t.get(M);if(L.color.copy(M.color).multiplyScalar(M.intensity*T),M.castShadow){let N=M.shadow,U=i.get(M);U.shadowBias=N.bias,U.shadowNormalBias=N.normalBias,U.shadowRadius=N.radius,U.shadowMapSize=N.mapSize,a.directionalShadow[g]=U,a.directionalShadowMap[g]=V,a.directionalShadowMatrix[g]=M.shadow.matrix,b++}a.directional[g]=L,g++}else if(M.isSpotLight){let L=t.get(M);if(L.position.setFromMatrixPosition(M.matrixWorld),L.color.copy(D).multiplyScalar(z*T),L.distance=H,L.coneCos=Math.cos(M.angle),L.penumbraCos=Math.cos(M.angle*(1-M.penumbra)),L.decay=M.decay,M.castShadow){let N=M.shadow,U=i.get(M);U.shadowBias=N.bias,U.shadowNormalBias=N.normalBias,U.shadowRadius=N.radius,U.shadowMapSize=N.mapSize,a.spotShadow[p]=U,a.spotShadowMap[p]=V,a.spotShadowMatrix[p]=M.shadow.matrix,E++}a.spot[p]=L,p++}else if(M.isRectAreaLight){let L=t.get(M);L.color.copy(D).multiplyScalar(z),L.halfWidth.set(M.width*.5,0,0),L.halfHeight.set(0,M.height*.5,0),a.rectArea[d]=L,d++}else if(M.isPointLight){let L=t.get(M);if(L.color.copy(M.color).multiplyScalar(M.intensity*T),L.distance=M.distance,L.decay=M.decay,M.castShadow){let N=M.shadow,U=i.get(M);U.shadowBias=N.bias,U.shadowNormalBias=N.normalBias,U.shadowRadius=N.radius,U.shadowMapSize=N.mapSize,U.shadowCameraNear=N.camera.near,U.shadowCameraFar=N.camera.far,a.pointShadow[x]=U,a.pointShadowMap[x]=V,a.pointShadowMatrix[x]=M.shadow.matrix,C++}a.point[x]=L,x++}else if(M.isHemisphereLight){let L=t.get(M);L.skyColor.copy(M.color).multiplyScalar(z*T),L.groundColor.copy(M.groundColor).multiplyScalar(z*T),a.hemi[A]=L,A++}}d>0&&(e.isWebGL2?(a.rectAreaLTC1=e1.LTC_FLOAT_1,a.rectAreaLTC2=e1.LTC_FLOAT_2):n.has("OES_texture_float_linear")===!0?(a.rectAreaLTC1=e1.LTC_FLOAT_1,a.rectAreaLTC2=e1.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(a.rectAreaLTC1=e1.LTC_HALF_1,a.rectAreaLTC2=e1.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),a.ambient[0]=h,a.ambient[1]=m,a.ambient[2]=v;let _=a.hash;(_.directionalLength!==g||_.pointLength!==x||_.spotLength!==p||_.rectAreaLength!==d||_.hemiLength!==A||_.numDirectionalShadows!==b||_.numPointShadows!==C||_.numSpotShadows!==E)&&(a.directional.length=g,a.spot.length=p,a.rectArea.length=d,a.point.length=x,a.hemi.length=A,a.directionalShadow.length=b,a.directionalShadowMap.length=b,a.pointShadow.length=C,a.pointShadowMap.length=C,a.spotShadow.length=E,a.spotShadowMap.length=E,a.directionalShadowMatrix.length=b,a.pointShadowMatrix.length=C,a.spotShadowMatrix.length=E,_.directionalLength=g,_.pointLength=x,_.spotLength=p,_.rectAreaLength=d,_.hemiLength=A,_.numDirectionalShadows=b,_.numPointShadows=C,_.numSpotShadows=E,a.version=Ku++)}function l(u,f){let h=0,m=0,v=0,g=0,x=0,p=f.matrixWorldInverse;for(let d=0,A=u.length;d<A;d++){let b=u[d];if(b.isDirectionalLight){let C=a.directional[h];C.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),C.direction.sub(r),C.direction.transformDirection(p),h++}else if(b.isSpotLight){let C=a.spot[v];C.position.setFromMatrixPosition(b.matrixWorld),C.position.applyMatrix4(p),C.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),C.direction.sub(r),C.direction.transformDirection(p),v++}else if(b.isRectAreaLight){let C=a.rectArea[g];C.position.setFromMatrixPosition(b.matrixWorld),C.position.applyMatrix4(p),o.identity(),s.copy(b.matrixWorld),s.premultiply(p),o.extractRotation(s),C.halfWidth.set(b.width*.5,0,0),C.halfHeight.set(0,b.height*.5,0),C.halfWidth.applyMatrix4(o),C.halfHeight.applyMatrix4(o),g++}else if(b.isPointLight){let C=a.point[m];C.position.setFromMatrixPosition(b.matrixWorld),C.position.applyMatrix4(p),m++}else if(b.isHemisphereLight){let C=a.hemi[x];C.direction.setFromMatrixPosition(b.matrixWorld),C.direction.transformDirection(p),C.direction.normalize(),x++}}}return{setup:c,setupView:l,state:a}}function uo(n,e){let t=new lo(n,e),i=[],a=[];function r(){i.length=0,a.length=0}function s(f){i.push(f)}function o(f){a.push(f)}function c(f){t.setup(i,f)}function l(f){t.setupView(i,f)}return{init:r,state:{lightsArray:i,shadowsArray:a,lights:t},setupLights:c,setupLightsView:l,pushLight:s,pushShadow:o}}function ho(n,e){let t=new WeakMap;function i(r,s=0){let o;return t.has(r)===!1?(o=new uo(n,e),t.set(r,[o])):s>=t.get(r).length?(o=new uo(n,e),t.get(r).push(o)):o=t.get(r)[s],o}function a(){t=new WeakMap}return{get:i,dispose:a}}var o0=class extends T2{constructor(e){super();this.type="MeshDepthMaterial",this.depthPacking=z8,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}};o0.prototype.isMeshDepthMaterial=!0;var c0=class extends T2{constructor(e){super();this.type="MeshDistanceMaterial",this.referencePosition=new k,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};c0.prototype.isMeshDistanceMaterial=!0;var fo=`
void main() {
gl_Position = vec4( position, 1.0 );
}
`,po=`
uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
const float samples = float( VSM_SAMPLES );
float mean = 0.0;
float squared_mean = 0.0;
// This seems totally useless but it's a crazy work around for a Adreno compiler bug
// float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
for ( float i = 0.0; i < samples; i ++ ) {
float uvOffset = uvStart + i * uvStride;
#ifdef HORIZONTAL_PASS
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
mean += distribution.x;
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
#else
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
mean += depth;
squared_mean += depth * depth;
#endif
}
mean = mean / samples;
squared_mean = squared_mean / samples;
float std_dev = sqrt( squared_mean - mean * mean );
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}
`;function mo(n,e,t){let i=new T4,a=new z1,r=new z1,s=new q1,o=new o0({depthPacking:A8}),c=new c0,l={},u=t.maxTextureSize,f={0:P1,1:ke,2:J2},h=new se({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new z1},radius:{value:4}},vertexShader:fo,fragmentShader:po}),m=h.clone();m.defines.HORIZONTAL_PASS=1;let v=new b2;v.setAttribute("position",new M2(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new u2(v,h),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=A6,this.render=function(b,C,E){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||b.length===0)return;let T=n.getRenderTarget(),_=n.getActiveCubeFace(),P=n.getActiveMipmapLevel(),F=n.state;F.setBlending(U2),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);for(let M=0,D=b.length;M<D;M++){let z=b[M],H=z.shadow;if(H===void 0){console.warn("THREE.WebGLShadowMap:",z,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;a.copy(H.mapSize);let V=H.getFrameExtents();if(a.multiply(V),r.copy(H.mapSize),(a.x>u||a.y>u)&&(a.x>u&&(r.x=Math.floor(u/V.x),a.x=r.x*V.x,H.mapSize.x=r.x),a.y>u&&(r.y=Math.floor(u/V.y),a.y=r.y*V.y,H.mapSize.y=r.y)),H.map===null&&!H.isPointLightShadow&&this.type===z4){let N={minFilter:t2,magFilter:t2,format:W1};H.map=new m2(a.x,a.y,N),H.map.texture.name=z.name+".shadowMap",H.mapPass=new m2(a.x,a.y,N),H.camera.updateProjectionMatrix()}if(H.map===null){let N={minFilter:Q1,magFilter:Q1,format:W1};H.map=new m2(a.x,a.y,N),H.map.texture.name=z.name+".shadowMap",H.camera.updateProjectionMatrix()}n.setRenderTarget(H.map),n.clear();let L=H.getViewportCount();for(let N=0;N<L;N++){let U=H.getViewport(N);s.set(r.x*U.x,r.y*U.y,r.x*U.z,r.y*U.w),F.viewport(s),H.updateMatrices(z,N),i=H.getFrustum(),A(C,E,H.camera,z,this.type)}!H.isPointLightShadow&&this.type===z4&&p(H,E),H.needsUpdate=!1}x.needsUpdate=!1,n.setRenderTarget(T,_,P)};function p(b,C){let E=e.update(g);h.defines.VSM_SAMPLES!==b.blurSamples&&(h.defines.VSM_SAMPLES=b.blurSamples,m.defines.VSM_SAMPLES=b.blurSamples,h.needsUpdate=!0,m.needsUpdate=!0),h.uniforms.shadow_pass.value=b.map.texture,h.uniforms.resolution.value=b.mapSize,h.uniforms.radius.value=b.radius,n.setRenderTarget(b.mapPass),n.clear(),n.renderBufferDirect(C,null,E,h,g,null),m.uniforms.shadow_pass.value=b.mapPass.texture,m.uniforms.resolution.value=b.mapSize,m.uniforms.radius.value=b.radius,n.setRenderTarget(b.map),n.clear(),n.renderBufferDirect(C,null,E,m,g,null)}function d(b,C,E,T,_,P,F){let M=null,D=T.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(D!==void 0?M=D:M=T.isPointLight===!0?c:o,n.localClippingEnabled&&E.clipShadows===!0&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0){let z=M.uuid,H=E.uuid,V=l[z];V===void 0&&(V={},l[z]=V);let L=V[H];L===void 0&&(L=M.clone(),V[H]=L),M=L}return M.visible=E.visible,M.wireframe=E.wireframe,F===z4?M.side=E.shadowSide!==null?E.shadowSide:E.side:M.side=E.shadowSide!==null?E.shadowSide:f[E.side],M.alphaMap=E.alphaMap,M.alphaTest=E.alphaTest,M.clipShadows=E.clipShadows,M.clippingPlanes=E.clippingPlanes,M.clipIntersection=E.clipIntersection,M.displacementMap=E.displacementMap,M.displacementScale=E.displacementScale,M.displacementBias=E.displacementBias,M.wireframeLinewidth=E.wireframeLinewidth,M.linewidth=E.linewidth,T.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(T.matrixWorld),M.nearDistance=_,M.farDistance=P),M}function A(b,C,E,T,_){if(b.visible===!1)return;if(b.layers.test(C.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&_===z4)&&(!b.frustumCulled||i.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,b.matrixWorld);let M=e.update(b),D=b.material;if(Array.isArray(D)){let z=M.groups;for(let H=0,V=z.length;H<V;H++){let L=z[H],N=D[L.materialIndex];if(N&&N.visible){let U=d(b,M,N,T,E.near,E.far,_);n.renderBufferDirect(E,null,M,U,b,L)}}}else if(D.visible){let z=d(b,M,D,T,E.near,E.far,_);n.renderBufferDirect(E,null,M,z,b,null)}}let F=b.children;for(let M=0,D=F.length;M<D;M++)A(F[M],C,E,T,_)}}function vo(n,e,t){let i=t.isWebGL2;function a(){let I=!1,l1=new q1,o1=null,m1=new q1(0,0,0,0);return{setMask:function($){o1!==$&&!I&&(n.colorMask($,$,$,$),o1=$)},setLocked:function($){I=$},setClear:function($,p1,D1,X1,H2){H2===!0&&($*=X1,p1*=X1,D1*=X1),l1.set($,p1,D1,X1),m1.equals(l1)===!1&&(n.clearColor($,p1,D1,X1),m1.copy(l1))},reset:function(){I=!1,o1=null,m1.set(-1,0,0,0)}}}function r(){let I=!1,l1=null,o1=null,m1=null;return{setTest:function($){$?B(n.DEPTH_TEST):M1(n.DEPTH_TEST)},setMask:function($){l1!==$&&!I&&(n.depthMask($),l1=$)},setFunc:function($){if(o1!==$){if($)switch($){case Zr:n.depthFunc(n.NEVER);break;case Yr:n.depthFunc(n.ALWAYS);break;case $r:n.depthFunc(n.LESS);break;case Et:n.depthFunc(n.LEQUAL);break;case Kr:n.depthFunc(n.EQUAL);break;case Jr:n.depthFunc(n.GEQUAL);break;case Qr:n.depthFunc(n.GREATER);break;case e8:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}else n.depthFunc(n.LEQUAL);o1=$}},setLocked:function($){I=$},setClear:function($){m1!==$&&(n.clearDepth($),m1=$)},reset:function(){I=!1,l1=null,o1=null,m1=null}}}function s(){let I=!1,l1=null,o1=null,m1=null,$=null,p1=null,D1=null,X1=null,H2=null;return{setTest:function(Z1){I||(Z1?B(n.STENCIL_TEST):M1(n.STENCIL_TEST))},setMask:function(Z1){l1!==Z1&&!I&&(n.stencilMask(Z1),l1=Z1)},setFunc:function(Z1,le,_e){(o1!==Z1||m1!==le||$!==_e)&&(n.stencilFunc(Z1,le,_e),o1=Z1,m1=le,$=_e)},setOp:function(Z1,le,_e){(p1!==Z1||D1!==le||X1!==_e)&&(n.stencilOp(Z1,le,_e),p1=Z1,D1=le,X1=_e)},setLocked:function(Z1){I=Z1},setClear:function(Z1){H2!==Z1&&(n.clearStencil(Z1),H2=Z1)},reset:function(){I=!1,l1=null,o1=null,m1=null,$=null,p1=null,D1=null,X1=null,H2=null}}}let o=new a,c=new r,l=new s,u={},f={},h=new WeakMap,m=[],v=null,g=!1,x=null,p=null,d=null,A=null,b=null,C=null,E=null,T=!1,_=null,P=null,F=null,M=null,D=null,z=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),H=!1,V=0,L=n.getParameter(n.VERSION);L.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(L)[1]),H=V>=1):L.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),H=V>=2);let N=null,U={},Z=n.getParameter(n.SCISSOR_BOX),O=n.getParameter(n.VIEWPORT),W=new q1().fromArray(Z),X=new q1().fromArray(O);function Q(I,l1,o1){let m1=new Uint8Array(4),$=n.createTexture();n.bindTexture(I,$),n.texParameteri(I,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(I,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let p1=0;p1<o1;p1++)n.texImage2D(l1+p1,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,m1);return $}let a1={};a1[n.TEXTURE_2D]=Q(n.TEXTURE_2D,n.TEXTURE_2D,1),a1[n.TEXTURE_CUBE_MAP]=Q(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),o.setClear(0,0,0,1),c.setClear(1),l.setClear(0),B(n.DEPTH_TEST),c.setFunc(Et),K1(!1),a2(i3),B(n.CULL_FACE),C1(U2);function B(I){u[I]!==!0&&(n.enable(I),u[I]=!0)}function M1(I){u[I]!==!1&&(n.disable(I),u[I]=!1)}function u1(I,l1){return f[I]!==l1?(n.bindFramebuffer(I,l1),f[I]=l1,i&&(I===n.DRAW_FRAMEBUFFER&&(f[n.FRAMEBUFFER]=l1),I===n.FRAMEBUFFER&&(f[n.DRAW_FRAMEBUFFER]=l1)),!0):!1}function v1(I,l1){let o1=m,m1=!1;if(I)if(o1=h.get(l1),o1===void 0&&(o1=[],h.set(l1,o1)),I.isWebGLMultipleRenderTargets){let $=I.texture;if(o1.length!==$.length||o1[0]!==n.COLOR_ATTACHMENT0){for(let p1=0,D1=$.length;p1<D1;p1++)o1[p1]=n.COLOR_ATTACHMENT0+p1;o1.length=$.length,m1=!0}}else o1[0]!==n.COLOR_ATTACHMENT0&&(o1[0]=n.COLOR_ATTACHMENT0,m1=!0);else o1[0]!==n.BACK&&(o1[0]=n.BACK,m1=!0);m1&&(t.isWebGL2?n.drawBuffers(o1):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(o1))}function n1(I){return v!==I?(n.useProgram(I),v=I,!0):!1}let T1={[i4]:n.FUNC_ADD,[Br]:n.FUNC_SUBTRACT,[Pr]:n.FUNC_REVERSE_SUBTRACT};if(i)T1[s3]=n.MIN,T1[o3]=n.MAX;else{let I=e.get("EXT_blend_minmax");I!==null&&(T1[s3]=I.MIN_EXT,T1[o3]=I.MAX_EXT)}let A1={[Ir]:n.ZERO,[kr]:n.ONE,[Ur]:n.SRC_COLOR,[S6]:n.SRC_ALPHA,[Xr]:n.SRC_ALPHA_SATURATE,[Wr]:n.DST_COLOR,[Gr]:n.DST_ALPHA,[Or]:n.ONE_MINUS_SRC_COLOR,[_6]:n.ONE_MINUS_SRC_ALPHA,[jr]:n.ONE_MINUS_DST_COLOR,[qr]:n.ONE_MINUS_DST_ALPHA};function C1(I,l1,o1,m1,$,p1,D1,X1){if(I===U2){g===!0&&(M1(n.BLEND),g=!1);return}if(g===!1&&(B(n.BLEND),g=!0),I!==Fr){if(I!==x||X1!==T){if((p!==i4||b!==i4)&&(n.blendEquation(n.FUNC_ADD),p=i4,b=i4),X1)switch(I){case A4:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case a3:n.blendFunc(n.ONE,n.ONE);break;case r3:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case n3:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",I);break}else switch(I){case A4:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case a3:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case r3:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case n3:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",I);break}d=null,A=null,C=null,E=null,x=I,T=X1}return}$=$||l1,p1=p1||o1,D1=D1||m1,(l1!==p||$!==b)&&(n.blendEquationSeparate(T1[l1],T1[$]),p=l1,b=$),(o1!==d||m1!==A||p1!==C||D1!==E)&&(n.blendFuncSeparate(A1[o1],A1[m1],A1[p1],A1[D1]),d=o1,A=m1,C=p1,E=D1),x=I,T=null}function h2(I,l1){I.side===J2?M1(n.CULL_FACE):B(n.CULL_FACE);let o1=I.side===P1;l1&&(o1=!o1),K1(o1),I.blending===A4&&I.transparent===!1?C1(U2):C1(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.premultipliedAlpha),c.setFunc(I.depthFunc),c.setTest(I.depthTest),c.setMask(I.depthWrite),o.setMask(I.colorWrite);let m1=I.stencilWrite;l.setTest(m1),m1&&(l.setMask(I.stencilWriteMask),l.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),l.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass)),v2(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),I.alphaToCoverage===!0?B(n.SAMPLE_ALPHA_TO_COVERAGE):M1(n.SAMPLE_ALPHA_TO_COVERAGE)}function K1(I){_!==I&&(I?n.frontFace(n.CW):n.frontFace(n.CCW),_=I)}function a2(I){I!==Vr?(B(n.CULL_FACE),I!==P&&(I===i3?n.cullFace(n.BACK):I===Nr?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):M1(n.CULL_FACE),P=I}function j2(I){I!==F&&(H&&n.lineWidth(I),F=I)}function v2(I,l1,o1){I?(B(n.POLYGON_OFFSET_FILL),(M!==l1||D!==o1)&&(n.polygonOffset(l1,o1),M=l1,D=o1)):M1(n.POLYGON_OFFSET_FILL)}function g2(I){I?B(n.SCISSOR_TEST):M1(n.SCISSOR_TEST)}function X2(I){I===void 0&&(I=n.TEXTURE0+z-1),N!==I&&(n.activeTexture(I),N=I)}function oe(I,l1){N===null&&X2();let o1=U[N];o1===void 0&&(o1={type:void 0,texture:void 0},U[N]=o1),(o1.type!==I||o1.texture!==l1)&&(n.bindTexture(I,l1||a1[I]),o1.type=I,o1.texture=l1)}function ce(){let I=U[N];I!==void 0&&I.type!==void 0&&(n.bindTexture(I.type,null),I.type=void 0,I.texture=void 0)}function R(){try{n.compressedTexImage2D.apply(n,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function w(){try{n.texSubImage2D.apply(n,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function J(){try{n.texSubImage3D.apply(n,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function t1(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function h1(){try{n.texStorage2D.apply(n,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function Y(){try{n.texStorage3D.apply(n,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function d1(){try{n.texImage2D.apply(n,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function f1(){try{n.texImage3D.apply(n,arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function s1(I){W.equals(I)===!1&&(n.scissor(I.x,I.y,I.z,I.w),W.copy(I))}function r1(I){X.equals(I)===!1&&(n.viewport(I.x,I.y,I.z,I.w),X.copy(I))}function b1(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),i===!0&&(n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null)),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),u={},N=null,U={},f={},h=new WeakMap,m=[],v=null,g=!1,x=null,p=null,d=null,A=null,b=null,C=null,E=null,T=!1,_=null,P=null,F=null,M=null,D=null,W.set(0,0,n.canvas.width,n.canvas.height),X.set(0,0,n.canvas.width,n.canvas.height),o.reset(),c.reset(),l.reset()}return{buffers:{color:o,depth:c,stencil:l},enable:B,disable:M1,bindFramebuffer:u1,drawBuffers:v1,useProgram:n1,setBlending:C1,setMaterial:h2,setFlipSided:K1,setCullFace:a2,setLineWidth:j2,setPolygonOffset:v2,setScissorTest:g2,activeTexture:X2,bindTexture:oe,unbindTexture:ce,compressedTexImage2D:R,texImage2D:d1,texImage3D:f1,texStorage2D:h1,texStorage3D:Y,texSubImage2D:w,texSubImage3D:J,compressedTexSubImage2D:t1,scissor:s1,viewport:r1,reset:b1}}function go(n,e,t,i,a,r,s){let o=a.isWebGL2,c=a.maxTextures,l=a.maxCubemapSize,u=a.maxTextureSize,f=a.maxSamples,m=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):void 0,v=new WeakMap,g,x=!1;try{x=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(R,w){return x?new OffscreenCanvas(R,w):E4("canvas")}function d(R,w,J,t1){let h1=1;if((R.width>t1||R.height>t1)&&(h1=t1/Math.max(R.width,R.height)),h1<1||w===!0)if(typeof HTMLImageElement!="undefined"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&R instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&R instanceof ImageBitmap){let Y=w?Lr:Math.floor,d1=Y(h1*R.width),f1=Y(h1*R.height);g===void 0&&(g=p(d1,f1));let s1=J?p(d1,f1):g;return s1.width=d1,s1.height=f1,s1.getContext("2d").drawImage(R,0,0,d1,f1),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+d1+"x"+f1+")."),s1}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function A(R){return J0(R.width)&&J0(R.height)}function b(R){return o?!1:R.wrapS!==c2||R.wrapT!==c2||R.minFilter!==Q1&&R.minFilter!==t2}function C(R,w){return R.generateMipmaps&&w&&R.minFilter!==Q1&&R.minFilter!==t2}function E(R){n.generateMipmap(R)}function T(R,w,J,t1,h1=!1){if(o===!1)return w;if(R!==null){if(n[R]!==void 0)return n[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Y=w;return w===n.RED&&(J===n.FLOAT&&(Y=n.R32F),J===n.HALF_FLOAT&&(Y=n.R16F),J===n.UNSIGNED_BYTE&&(Y=n.R8)),w===n.RG&&(J===n.FLOAT&&(Y=n.RG32F),J===n.HALF_FLOAT&&(Y=n.RG16F),J===n.UNSIGNED_BYTE&&(Y=n.RG8)),w===n.RGBA&&(J===n.FLOAT&&(Y=n.RGBA32F),J===n.HALF_FLOAT&&(Y=n.RGBA16F),J===n.UNSIGNED_BYTE&&(Y=t1===I1&&h1===!1?n.SRGB8_ALPHA8:n.RGBA8),J===n.UNSIGNED_SHORT_4_4_4_4&&(Y=n.RGBA4),J===n.UNSIGNED_SHORT_5_5_5_1&&(Y=n.RGB5_A1)),(Y===n.R16F||Y===n.R32F||Y===n.RG16F||Y===n.RG32F||Y===n.RGBA16F||Y===n.RGBA32F)&&e.get("EXT_color_buffer_float"),Y}function _(R,w,J){return C(R,J)===!0||R.isFramebufferTexture&&R.minFilter!==Q1&&R.minFilter!==t2?Math.log2(Math.max(w.width,w.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?w.mipmaps.length:1}function P(R){return R===Q1||R===l3||R===u3?n.NEAREST:n.LINEAR}function F(R){let w=R.target;w.removeEventListener("dispose",F),D(w),w.isVideoTexture&&v.delete(w),s.memory.textures--}function M(R){let w=R.target;w.removeEventListener("dispose",M),z(w)}function D(R){let w=i.get(R);w.__webglInit!==void 0&&(n.deleteTexture(w.__webglTexture),i.remove(R))}function z(R){let w=R.texture,J=i.get(R),t1=i.get(w);if(!!R){if(t1.__webglTexture!==void 0&&(n.deleteTexture(t1.__webglTexture),s.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let h1=0;h1<6;h1++)n.deleteFramebuffer(J.__webglFramebuffer[h1]),J.__webglDepthbuffer&&n.deleteRenderbuffer(J.__webglDepthbuffer[h1]);else n.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&n.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&n.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer&&n.deleteRenderbuffer(J.__webglColorRenderbuffer),J.__webglDepthRenderbuffer&&n.deleteRenderbuffer(J.__webglDepthRenderbuffer);if(R.isWebGLMultipleRenderTargets)for(let h1=0,Y=w.length;h1<Y;h1++){let d1=i.get(w[h1]);d1.__webglTexture&&(n.deleteTexture(d1.__webglTexture),s.memory.textures--),i.remove(w[h1])}i.remove(w),i.remove(R)}}let H=0;function V(){H=0}function L(){let R=H;return R>=c&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+c),H+=1,R}function N(R,w){let J=i.get(R);if(R.isVideoTexture&&j2(R),R.version>0&&J.__version!==R.version){let t1=R.image;if(t1===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(t1.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{B(J,R,w);return}}t.activeTexture(n.TEXTURE0+w),t.bindTexture(n.TEXTURE_2D,J.__webglTexture)}function U(R,w){let J=i.get(R);if(R.version>0&&J.__version!==R.version){B(J,R,w);return}t.activeTexture(n.TEXTURE0+w),t.bindTexture(n.TEXTURE_2D_ARRAY,J.__webglTexture)}function Z(R,w){let J=i.get(R);if(R.version>0&&J.__version!==R.version){B(J,R,w);return}t.activeTexture(n.TEXTURE0+w),t.bindTexture(n.TEXTURE_3D,J.__webglTexture)}function O(R,w){let J=i.get(R);if(R.version>0&&J.__version!==R.version){M1(J,R,w);return}t.activeTexture(n.TEXTURE0+w),t.bindTexture(n.TEXTURE_CUBE_MAP,J.__webglTexture)}let W={[Ht]:n.REPEAT,[c2]:n.CLAMP_TO_EDGE,[Vt]:n.MIRRORED_REPEAT},X={[Q1]:n.NEAREST,[l3]:n.NEAREST_MIPMAP_NEAREST,[u3]:n.NEAREST_MIPMAP_LINEAR,[t2]:n.LINEAR,[c8]:n.LINEAR_MIPMAP_NEAREST,[r4]:n.LINEAR_MIPMAP_LINEAR};function Q(R,w,J){if(J?(n.texParameteri(R,n.TEXTURE_WRAP_S,W[w.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,W[w.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,W[w.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,X[w.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,X[w.minFilter])):(n.texParameteri(R,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(R,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,n.CLAMP_TO_EDGE),(w.wrapS!==c2||w.wrapT!==c2)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(R,n.TEXTURE_MAG_FILTER,P(w.magFilter)),n.texParameteri(R,n.TEXTURE_MIN_FILTER,P(w.minFilter)),w.minFilter!==Q1&&w.minFilter!==t2&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let t1=e.get("EXT_texture_filter_anisotropic");if(w.type===Q2&&e.has("OES_texture_float_linear")===!1||o===!1&&w.type===ye&&e.has("OES_texture_half_float_linear")===!1)return;(w.anisotropy>1||i.get(w).__currentAnisotropy)&&(n.texParameterf(R,t1.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,a.getMaxAnisotropy())),i.get(w).__currentAnisotropy=w.anisotropy)}}function a1(R,w){R.__webglInit===void 0&&(R.__webglInit=!0,w.addEventListener("dispose",F),R.__webglTexture=n.createTexture(),s.memory.textures++)}function B(R,w,J){let t1=n.TEXTURE_2D;w.isDataTexture2DArray&&(t1=n.TEXTURE_2D_ARRAY),w.isDataTexture3D&&(t1=n.TEXTURE_3D),a1(R,w),t.activeTexture(n.TEXTURE0+J),t.bindTexture(t1,R.__webglTexture),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE);let h1=b(w)&&A(w.image)===!1,Y=d(w.image,h1,!1,u);Y=v2(w,Y);let d1=A(Y)||o,f1=r.convert(w.format,w.encoding),s1=r.convert(w.type),r1=T(w.internalFormat,f1,s1,w.encoding,w.isVideoTexture);Q(t1,w,d1);let b1,I=w.mipmaps,l1=o&&w.isVideoTexture!==!0,o1=R.__version===void 0,m1=_(w,Y,d1);if(w.isDepthTexture)r1=n.DEPTH_COMPONENT,o?w.type===Q2?r1=n.DEPTH_COMPONENT32F:w.type===q4?r1=n.DEPTH_COMPONENT24:w.type===Ce?r1=n.DEPTH24_STENCIL8:r1=n.DEPTH_COMPONENT16:w.type===Q2&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),w.format===ee&&r1===n.DEPTH_COMPONENT&&w.type!==Oe&&w.type!==q4&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),w.type=Oe,s1=r.convert(w.type)),w.format===ze&&r1===n.DEPTH_COMPONENT&&(r1=n.DEPTH_STENCIL,w.type!==Ce&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),w.type=Ce,s1=r.convert(w.type))),l1&&o1?t.texStorage2D(n.TEXTURE_2D,1,r1,Y.width,Y.height):t.texImage2D(n.TEXTURE_2D,0,r1,Y.width,Y.height,0,f1,s1,null);else if(w.isDataTexture)if(I.length>0&&d1){l1&&o1&&t.texStorage2D(n.TEXTURE_2D,m1,r1,I[0].width,I[0].height);for(let $=0,p1=I.length;$<p1;$++)b1=I[$],l1?t.texSubImage2D(n.TEXTURE_2D,0,0,0,b1.width,b1.height,f1,s1,b1.data):t.texImage2D(n.TEXTURE_2D,$,r1,b1.width,b1.height,0,f1,s1,b1.data);w.generateMipmaps=!1}else l1?(o1&&t.texStorage2D(n.TEXTURE_2D,m1,r1,Y.width,Y.height),t.texSubImage2D(n.TEXTURE_2D,0,0,0,Y.width,Y.height,f1,s1,Y.data)):t.texImage2D(n.TEXTURE_2D,0,r1,Y.width,Y.height,0,f1,s1,Y.data);else if(w.isCompressedTexture){l1&&o1&&t.texStorage2D(n.TEXTURE_2D,m1,r1,I[0].width,I[0].height);for(let $=0,p1=I.length;$<p1;$++)b1=I[$],w.format!==W1?f1!==null?l1?t.compressedTexSubImage2D(n.TEXTURE_2D,$,0,0,b1.width,b1.height,f1,b1.data):t.compressedTexImage2D(n.TEXTURE_2D,$,r1,b1.width,b1.height,0,b1.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):l1?t.texSubImage2D(n.TEXTURE_2D,$,0,0,b1.width,b1.height,f1,s1,b1.data):t.texImage2D(n.TEXTURE_2D,$,r1,b1.width,b1.height,0,f1,s1,b1.data)}else if(w.isDataTexture2DArray)l1?(o1&&t.texStorage3D(n.TEXTURE_2D_ARRAY,m1,r1,Y.width,Y.height,Y.depth),t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Y.width,Y.height,Y.depth,f1,s1,Y.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,r1,Y.width,Y.height,Y.depth,0,f1,s1,Y.data);else if(w.isDataTexture3D)l1?(o1&&t.texStorage3D(n.TEXTURE_3D,m1,r1,Y.width,Y.height,Y.depth),t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Y.width,Y.height,Y.depth,f1,s1,Y.data)):t.texImage3D(n.TEXTURE_3D,0,r1,Y.width,Y.height,Y.depth,0,f1,s1,Y.data);else if(w.isFramebufferTexture)l1&&o1?t.texStorage2D(n.TEXTURE_2D,m1,r1,Y.width,Y.height):t.texImage2D(n.TEXTURE_2D,0,r1,Y.width,Y.height,0,f1,s1,null);else if(I.length>0&&d1){l1&&o1&&t.texStorage2D(n.TEXTURE_2D,m1,r1,I[0].width,I[0].height);for(let $=0,p1=I.length;$<p1;$++)b1=I[$],l1?t.texSubImage2D(n.TEXTURE_2D,$,0,0,f1,s1,b1):t.texImage2D(n.TEXTURE_2D,$,r1,f1,s1,b1);w.generateMipmaps=!1}else l1?(o1&&t.texStorage2D(n.TEXTURE_2D,m1,r1,Y.width,Y.height),t.texSubImage2D(n.TEXTURE_2D,0,0,0,f1,s1,Y)):t.texImage2D(n.TEXTURE_2D,0,r1,f1,s1,Y);C(w,d1)&&E(t1),R.__version=w.version,w.onUpdate&&w.onUpdate(w)}function M1(R,w,J){if(w.image.length!==6)return;a1(R,w),t.activeTexture(n.TEXTURE0+J),t.bindTexture(n.TEXTURE_CUBE_MAP,R.__webglTexture),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE);let t1=w&&(w.isCompressedTexture||w.image[0].isCompressedTexture),h1=w.image[0]&&w.image[0].isDataTexture,Y=[];for(let $=0;$<6;$++)!t1&&!h1?Y[$]=d(w.image[$],!1,!0,l):Y[$]=h1?w.image[$].image:w.image[$],Y[$]=v2(w,Y[$]);let d1=Y[0],f1=A(d1)||o,s1=r.convert(w.format,w.encoding),r1=r.convert(w.type),b1=T(w.internalFormat,s1,r1,w.encoding),I=o&&w.isVideoTexture!==!0,l1=R.__version===void 0,o1=_(w,d1,f1);Q(n.TEXTURE_CUBE_MAP,w,f1);let m1;if(t1){I&&l1&&t.texStorage2D(n.TEXTURE_CUBE_MAP,o1,b1,d1.width,d1.height);for(let $=0;$<6;$++){m1=Y[$].mipmaps;for(let p1=0;p1<m1.length;p1++){let D1=m1[p1];w.format!==W1?s1!==null?I?t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,p1,0,0,D1.width,D1.height,s1,D1.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,p1,b1,D1.width,D1.height,0,D1.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):I?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,p1,0,0,D1.width,D1.height,s1,r1,D1.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,p1,b1,D1.width,D1.height,0,s1,r1,D1.data)}}}else{m1=w.mipmaps,I&&l1&&(m1.length>0&&o1++,t.texStorage2D(n.TEXTURE_CUBE_MAP,o1,b1,Y[0].width,Y[0].height));for(let $=0;$<6;$++)if(h1){I?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,Y[$].width,Y[$].height,s1,r1,Y[$].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,b1,Y[$].width,Y[$].height,0,s1,r1,Y[$].data);for(let p1=0;p1<m1.length;p1++){let X1=m1[p1].image[$].image;I?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,p1+1,0,0,X1.width,X1.height,s1,r1,X1.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,p1+1,b1,X1.width,X1.height,0,s1,r1,X1.data)}}else{I?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,s1,r1,Y[$]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,b1,s1,r1,Y[$]);for(let p1=0;p1<m1.length;p1++){let D1=m1[p1];I?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,p1+1,0,0,s1,r1,D1.image[$]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,p1+1,b1,s1,r1,D1.image[$])}}}C(w,f1)&&E(n.TEXTURE_CUBE_MAP),R.__version=w.version,w.onUpdate&&w.onUpdate(w)}function u1(R,w,J,t1,h1){let Y=r.convert(J.format,J.encoding),d1=r.convert(J.type),f1=T(J.internalFormat,Y,d1,J.encoding);i.get(w).__hasExternalTextures||(h1===n.TEXTURE_3D||h1===n.TEXTURE_2D_ARRAY?t.texImage3D(h1,0,f1,w.width,w.height,w.depth,0,Y,d1,null):t.texImage2D(h1,0,f1,w.width,w.height,0,Y,d1,null)),t.bindFramebuffer(n.FRAMEBUFFER,R),w.useRenderToTexture?m.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,t1,h1,i.get(J).__webglTexture,0,a2(w)):n.framebufferTexture2D(n.FRAMEBUFFER,t1,h1,i.get(J).__webglTexture,0),t.bindFramebuffer(n.FRAMEBUFFER,null)}function v1(R,w,J){if(n.bindRenderbuffer(n.RENDERBUFFER,R),w.depthBuffer&&!w.stencilBuffer){let t1=n.DEPTH_COMPONENT16;if(J||w.useRenderToTexture){let h1=w.depthTexture;h1&&h1.isDepthTexture&&(h1.type===Q2?t1=n.DEPTH_COMPONENT32F:h1.type===q4&&(t1=n.DEPTH_COMPONENT24));let Y=a2(w);w.useRenderToTexture?m.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Y,t1,w.width,w.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,Y,t1,w.width,w.height)}else n.renderbufferStorage(n.RENDERBUFFER,t1,w.width,w.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,R)}else if(w.depthBuffer&&w.stencilBuffer){let t1=a2(w);J&&w.useRenderbuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,t1,n.DEPTH24_STENCIL8,w.width,w.height):w.useRenderToTexture?m.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,t1,n.DEPTH24_STENCIL8,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,w.width,w.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,R)}else{let t1=w.isWebGLMultipleRenderTargets===!0?w.texture[0]:w.texture,h1=r.convert(t1.format,t1.encoding),Y=r.convert(t1.type),d1=T(t1.internalFormat,h1,Y,t1.encoding),f1=a2(w);J&&w.useRenderbuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,f1,d1,w.width,w.height):w.useRenderToTexture?m.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,f1,d1,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,d1,w.width,w.height)}n.bindRenderbuffer(n.RENDERBUFFER,null)}function n1(R,w){if(w&&w.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,R),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(w.depthTexture).__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)&&(w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0),N(w.depthTexture,0);let t1=i.get(w.depthTexture).__webglTexture,h1=a2(w);if(w.depthTexture.format===ee)w.useRenderToTexture?m.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,t1,0,h1):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,t1,0);else if(w.depthTexture.format===ze)w.useRenderToTexture?m.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,t1,0,h1):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,t1,0);else throw new Error("Unknown depthTexture format")}function T1(R){let w=i.get(R),J=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!w.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");n1(w.__webglFramebuffer,R)}else if(J){w.__webglDepthbuffer=[];for(let t1=0;t1<6;t1++)t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[t1]),w.__webglDepthbuffer[t1]=n.createRenderbuffer(),v1(w.__webglDepthbuffer[t1],R,!1)}else t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer),w.__webglDepthbuffer=n.createRenderbuffer(),v1(w.__webglDepthbuffer,R,!1);t.bindFramebuffer(n.FRAMEBUFFER,null)}function A1(R,w,J){let t1=i.get(R);w!==void 0&&u1(t1.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D),J!==void 0&&T1(R)}function C1(R){let w=R.texture,J=i.get(R),t1=i.get(w);R.addEventListener("dispose",M),R.isWebGLMultipleRenderTargets!==!0&&(t1.__webglTexture===void 0&&(t1.__webglTexture=n.createTexture()),t1.__version=w.version,s.memory.textures++);let h1=R.isWebGLCubeRenderTarget===!0,Y=R.isWebGLMultipleRenderTargets===!0,d1=w.isDataTexture3D||w.isDataTexture2DArray,f1=A(R)||o;if(h1){J.__webglFramebuffer=[];for(let s1=0;s1<6;s1++)J.__webglFramebuffer[s1]=n.createFramebuffer()}else if(J.__webglFramebuffer=n.createFramebuffer(),Y)if(a.drawBuffers){let s1=R.texture;for(let r1=0,b1=s1.length;r1<b1;r1++){let I=i.get(s1[r1]);I.__webglTexture===void 0&&(I.__webglTexture=n.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(R.useRenderbuffer)if(o){J.__webglMultisampledFramebuffer=n.createFramebuffer(),J.__webglColorRenderbuffer=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,J.__webglColorRenderbuffer);let s1=r.convert(w.format,w.encoding),r1=r.convert(w.type),b1=T(w.internalFormat,s1,r1,w.encoding),I=a2(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,I,b1,R.width,R.height),t.bindFramebuffer(n.FRAMEBUFFER,J.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,J.__webglColorRenderbuffer),n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(J.__webglDepthRenderbuffer=n.createRenderbuffer(),v1(J.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(h1){t.bindTexture(n.TEXTURE_CUBE_MAP,t1.__webglTexture),Q(n.TEXTURE_CUBE_MAP,w,f1);for(let s1=0;s1<6;s1++)u1(J.__webglFramebuffer[s1],R,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+s1);C(w,f1)&&E(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Y){let s1=R.texture;for(let r1=0,b1=s1.length;r1<b1;r1++){let I=s1[r1],l1=i.get(I);t.bindTexture(n.TEXTURE_2D,l1.__webglTexture),Q(n.TEXTURE_2D,I,f1),u1(J.__webglFramebuffer,R,I,n.COLOR_ATTACHMENT0+r1,n.TEXTURE_2D),C(I,f1)&&E(n.TEXTURE_2D)}t.unbindTexture()}else{let s1=n.TEXTURE_2D;d1&&(o?s1=w.isDataTexture3D?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),t.bindTexture(s1,t1.__webglTexture),Q(s1,w,f1),u1(J.__webglFramebuffer,R,w,n.COLOR_ATTACHMENT0,s1),C(w,f1)&&E(s1),t.unbindTexture()}R.depthBuffer&&T1(R)}function h2(R){let w=A(R)||o,J=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let t1=0,h1=J.length;t1<h1;t1++){let Y=J[t1];if(C(Y,w)){let d1=R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,f1=i.get(Y).__webglTexture;t.bindTexture(d1,f1),E(d1),t.unbindTexture()}}}function K1(R){if(R.useRenderbuffer)if(o){let w=R.width,J=R.height,t1=n.COLOR_BUFFER_BIT,h1=[n.COLOR_ATTACHMENT0],Y=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;R.depthBuffer&&h1.push(Y),R.ignoreDepthForMultisampleCopy||(R.depthBuffer&&(t1|=n.DEPTH_BUFFER_BIT),R.stencilBuffer&&(t1|=n.STENCIL_BUFFER_BIT));let d1=i.get(R);t.bindFramebuffer(n.READ_FRAMEBUFFER,d1.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,d1.__webglFramebuffer),R.ignoreDepthForMultisampleCopy&&(n.invalidateFramebuffer(n.READ_FRAMEBUFFER,[Y]),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[Y])),n.blitFramebuffer(0,0,w,J,0,0,w,J,t1,n.NEAREST),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,h1),t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,d1.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function a2(R){return o&&(R.useRenderbuffer||R.useRenderToTexture)?Math.min(f,R.samples):0}function j2(R){let w=s.render.frame;v.get(R)!==w&&(v.set(R,w),R.update())}function v2(R,w){let J=R.encoding,t1=R.format,h1=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===Nt||J!==R2&&(J===I1?o===!1?e.has("EXT_sRGB")===!0&&t1===W1?(R.format=Nt,R.minFilter=t2,R.generateMipmaps=!1):w=Ot.sRGBToLinear(w):(t1!==W1||h1!==N2)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",J)),w}let g2=!1,X2=!1;function oe(R,w){R&&R.isWebGLRenderTarget&&(g2===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),g2=!0),R=R.texture),N(R,w)}function ce(R,w){R&&R.isWebGLCubeRenderTarget&&(X2===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),X2=!0),R=R.texture),O(R,w)}this.allocateTextureUnit=L,this.resetTextureUnits=V,this.setTexture2D=N,this.setTexture2DArray=U,this.setTexture3D=Z,this.setTextureCube=O,this.rebindTextures=A1,this.setupRenderTarget=C1,this.updateRenderTargetMipmap=h2,this.updateMultisampleRenderTarget=K1,this.setupDepthRenderbuffer=T1,this.setupFrameBufferTexture=u1,this.safeSetTexture2D=oe,this.safeSetTextureCube=ce}function xo(n,e,t){let i=t.isWebGL2;function a(r,s=null){let o;if(r===N2)return n.UNSIGNED_BYTE;if(r===f8)return n.UNSIGNED_SHORT_4_4_4_4;if(r===d8)return n.UNSIGNED_SHORT_5_5_5_1;if(r===l8)return n.BYTE;if(r===u8)return n.SHORT;if(r===Oe)return n.UNSIGNED_SHORT;if(r===h8)return n.INT;if(r===q4)return n.UNSIGNED_INT;if(r===Q2)return n.FLOAT;if(r===ye)return i?n.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(r===p8)return n.ALPHA;if(r===W1)return n.RGBA;if(r===m8)return n.LUMINANCE;if(r===v8)return n.LUMINANCE_ALPHA;if(r===ee)return n.DEPTH_COMPONENT;if(r===ze)return n.DEPTH_STENCIL;if(r===g8)return n.RED;if(r===Nt)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(r===x8)return n.RED_INTEGER;if(r===M8)return n.RG;if(r===b8)return n.RG_INTEGER;if(r===y8)return n.RGBA_INTEGER;if(r===E6||r===L6||r===D6||r===T6)if(s===I1)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(r===E6)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===L6)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===D6)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===T6)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(r===E6)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===L6)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===D6)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===T6)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===h3||r===f3||r===d3||r===p3)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(r===h3)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===f3)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===d3)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===p3)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===C8)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===m3||r===v3)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(r===m3)return s===I1?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(r===v3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===g3||r===x3||r===M3||r===b3||r===y3||r===C3||r===z3||r===A3||r===w3||r===S3||r===_3||r===E3||r===L3||r===D3)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(r===g3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===x3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===M3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===b3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===y3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===C3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===z3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===A3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===w3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===S3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===_3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===E3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===L3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===D3)return s===I1?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===T3)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(r===T3)return s===I1?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(r===Ce)return i?n.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:a}}var l0=class extends i2{constructor(e=[]){super();this.cameras=e}};l0.prototype.isArrayCamera=!0;var N4=class extends j1{constructor(){super();this.type="Group"}};N4.prototype.isGroup=!0;var eh={type:"move"},Wt=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new N4,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new N4,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new k,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new k),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new N4,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new k,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new k),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let a=null,r=null,s=null,o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(o!==null&&(a=t.getPose(e.targetRaySpace,i),a!==null&&(o.matrix.fromArray(a.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),a.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(a.linearVelocity)):o.hasLinearVelocity=!1,a.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(a.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(eh))),l&&e.hand){s=!0;for(let g of e.hand.values()){let x=t.getJointPose(g,i);if(l.joints[g.jointName]===void 0){let d=new N4;d.matrixAutoUpdate=!1,d.visible=!1,l.joints[g.jointName]=d,l.add(d)}let p=l.joints[g.jointName];x!==null&&(p.matrix.fromArray(x.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.jointRadius=x.radius),p.visible=x!==null}let u=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],h=u.position.distanceTo(f.position),m=.02,v=.005;l.inputState.pinching&&h>m+v?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=m-v&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));return o!==null&&(o.visible=a!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=s!==null),this}};var jt=class extends $1{constructor(e,t,i,a,r,s,o,c,l,u){if(u=u!==void 0?u:ee,u!==ee&&u!==ze)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===ee&&(i=Oe),i===void 0&&u===ze&&(i=Ce);super(null,a,r,s,o,c,u,i,l);this.image={width:e,height:t},this.magFilter=o!==void 0?o:Q1,this.minFilter=c!==void 0?c:Q1,this.flipY=!1,this.generateMipmaps=!1}};jt.prototype.isDepthTexture=!0;var Li=class extends F2{constructor(e,t){super();let i=this,a=null,r=1,s=null,o="local-floor",c=e.extensions.has("WEBGL_multisampled_render_to_texture"),l=null,u=null,f=null,h=null,m=!1,v=null,g=t.getContextAttributes(),x=null,p=null,d=[],A=new Map,b=new i2;b.layers.enable(1),b.viewport=new q1;let C=new i2;C.layers.enable(2),C.viewport=new q1;let E=[b,C],T=new l0;T.layers.enable(1),T.layers.enable(2);let _=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(O){let W=d[O];return W===void 0&&(W=new Wt,d[O]=W),W.getTargetRaySpace()},this.getControllerGrip=function(O){let W=d[O];return W===void 0&&(W=new Wt,d[O]=W),W.getGripSpace()},this.getHand=function(O){let W=d[O];return W===void 0&&(W=new Wt,d[O]=W),W.getHandSpace()};function F(O){let W=A.get(O.inputSource);W&&W.dispatchEvent({type:O.type,data:O.inputSource})}function M(){A.forEach(function(O,W){O.disconnect(W)}),A.clear(),_=null,P=null,e.setRenderTarget(x),h=null,f=null,u=null,a=null,p=null,Z.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(O){r=O,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(O){o=O,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s},this.getBaseLayer=function(){return f!==null?f:h},this.getBinding=function(){return u},this.getFrame=function(){return v},this.getSession=function(){return a},this.setSession=async function(O){if(a=O,a!==null){if(x=e.getRenderTarget(),a.addEventListener("select",F),a.addEventListener("selectstart",F),a.addEventListener("selectend",F),a.addEventListener("squeeze",F),a.addEventListener("squeezestart",F),a.addEventListener("squeezeend",F),a.addEventListener("end",M),a.addEventListener("inputsourceschange",D),g.xrCompatible!==!0&&await t.makeXRCompatible(),a.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let W={antialias:a.renderState.layers===void 0?g.antialias:!0,alpha:g.alpha,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(a,t,W),a.updateRenderState({baseLayer:h}),p=new m2(h.framebufferWidth,h.framebufferHeight,{format:W1,type:N2,encoding:e.outputEncoding})}else{m=g.antialias;let W=null,X=null,Q=null;g.depth&&(Q=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,W=g.stencil?ze:ee,X=g.stencil?Ce:Oe);let a1={colorFormat:e.outputEncoding===I1?t.SRGB8_ALPHA8:t.RGBA8,depthFormat:Q,scaleFactor:r};u=new XRWebGLBinding(a,t),f=u.createProjectionLayer(a1),a.updateRenderState({layers:[f]}),m?p=new ft(f.textureWidth,f.textureHeight,{format:W1,type:N2,depthTexture:new jt(f.textureWidth,f.textureHeight,X,void 0,void 0,void 0,void 0,void 0,void 0,W),stencilBuffer:g.stencil,ignoreDepth:f.ignoreDepthValues,useRenderToTexture:c,encoding:e.outputEncoding}):p=new m2(f.textureWidth,f.textureHeight,{format:W1,type:N2,depthTexture:new jt(f.textureWidth,f.textureHeight,X,void 0,void 0,void 0,void 0,void 0,void 0,W),stencilBuffer:g.stencil,ignoreDepth:f.ignoreDepthValues,encoding:e.outputEncoding})}p.isXRRenderTarget=!0,this.setFoveation(1),s=await a.requestReferenceSpace(o),Z.setContext(a),Z.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function D(O){let W=a.inputSources;for(let X=0;X<d.length;X++)A.set(W[X],d[X]);for(let X=0;X<O.removed.length;X++){let Q=O.removed[X],a1=A.get(Q);a1&&(a1.dispatchEvent({type:"disconnected",data:Q}),A.delete(Q))}for(let X=0;X<O.added.length;X++){let Q=O.added[X],a1=A.get(Q);a1&&a1.dispatchEvent({type:"connected",data:Q})}}let z=new k,H=new k;function V(O,W,X){z.setFromMatrixPosition(W.matrixWorld),H.setFromMatrixPosition(X.matrixWorld);let Q=z.distanceTo(H),a1=W.projectionMatrix.elements,B=X.projectionMatrix.elements,M1=a1[14]/(a1[10]-1),u1=a1[14]/(a1[10]+1),v1=(a1[9]+1)/a1[5],n1=(a1[9]-1)/a1[5],T1=(a1[8]-1)/a1[0],A1=(B[8]+1)/B[0],C1=M1*T1,h2=M1*A1,K1=Q/(-T1+A1),a2=K1*-T1;W.matrixWorld.decompose(O.position,O.quaternion,O.scale),O.translateX(a2),O.translateZ(K1),O.matrixWorld.compose(O.position,O.quaternion,O.scale),O.matrixWorldInverse.copy(O.matrixWorld).invert();let j2=M1+K1,v2=u1+K1,g2=C1-a2,X2=h2+(Q-a2),oe=v1*u1/v2*j2,ce=n1*u1/v2*j2;O.projectionMatrix.makePerspective(g2,X2,oe,ce,j2,v2)}function L(O,W){W===null?O.matrixWorld.copy(O.matrix):O.matrixWorld.multiplyMatrices(W.matrixWorld,O.matrix),O.matrixWorldInverse.copy(O.matrixWorld).invert()}this.updateCamera=function(O){if(a===null)return;T.near=C.near=b.near=O.near,T.far=C.far=b.far=O.far,(_!==T.near||P!==T.far)&&(a.updateRenderState({depthNear:T.near,depthFar:T.far}),_=T.near,P=T.far);let W=O.parent,X=T.cameras;L(T,W);for(let a1=0;a1<X.length;a1++)L(X[a1],W);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),O.position.copy(T.position),O.quaternion.copy(T.quaternion),O.scale.copy(T.scale),O.matrix.copy(T.matrix),O.matrixWorld.copy(T.matrixWorld);let Q=O.children;for(let a1=0,B=Q.length;a1<B;a1++)Q[a1].updateMatrixWorld(!0);X.length===2?V(T,b,C):T.projectionMatrix.copy(b.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(f!==null)return f.fixedFoveation;if(h!==null)return h.fixedFoveation},this.setFoveation=function(O){f!==null&&(f.fixedFoveation=O),h!==null&&h.fixedFoveation!==void 0&&(h.fixedFoveation=O)};let N=null;function U(O,W){if(l=W.getViewerPose(s),v=W,l!==null){let Q=l.views;h!==null&&(e.setRenderTargetFramebuffer(p,h.framebuffer),e.setRenderTarget(p));let a1=!1;Q.length!==T.cameras.length&&(T.cameras.length=0,a1=!0);for(let B=0;B<Q.length;B++){let M1=Q[B],u1=null;if(h!==null)u1=h.getViewport(M1);else{let n1=u.getViewSubImage(f,M1);u1=n1.viewport,B===0&&(e.setRenderTargetTextures(p,n1.colorTexture,f.ignoreDepthValues?void 0:n1.depthStencilTexture),e.setRenderTarget(p))}let v1=E[B];v1.matrix.fromArray(M1.transform.matrix),v1.projectionMatrix.fromArray(M1.projectionMatrix),v1.viewport.set(u1.x,u1.y,u1.width,u1.height),B===0&&T.matrix.copy(v1.matrix),a1===!0&&T.cameras.push(v1)}}let X=a.inputSources;for(let Q=0;Q<d.length;Q++){let a1=d[Q],B=X[Q];a1.update(B,W,s)}N&&N(O,W),v=null}let Z=new Q6;Z.setAnimationLoop(U),this.setAnimationLoop=function(O){N=O},this.dispose=function(){}}};function Mo(n){function e(p,d){p.fogColor.value.copy(d.color),d.isFog?(p.fogNear.value=d.near,p.fogFar.value=d.far):d.isFogExp2&&(p.fogDensity.value=d.density)}function t(p,d,A,b,C){d.isMeshBasicMaterial?i(p,d):d.isMeshLambertMaterial?(i(p,d),c(p,d)):d.isMeshToonMaterial?(i(p,d),u(p,d)):d.isMeshPhongMaterial?(i(p,d),l(p,d)):d.isMeshStandardMaterial?(i(p,d),d.isMeshPhysicalMaterial?h(p,d,C):f(p,d)):d.isMeshMatcapMaterial?(i(p,d),m(p,d)):d.isMeshDepthMaterial?(i(p,d),v(p,d)):d.isMeshDistanceMaterial?(i(p,d),g(p,d)):d.isMeshNormalMaterial?(i(p,d),x(p,d)):d.isLineBasicMaterial?(a(p,d),d.isLineDashedMaterial&&r(p,d)):d.isPointsMaterial?s(p,d,A,b):d.isSpriteMaterial?o(p,d):d.isShadowMaterial?(p.color.value.copy(d.color),p.opacity.value=d.opacity):d.isShaderMaterial&&(d.uniformsNeedUpdate=!1)}function i(p,d){p.opacity.value=d.opacity,d.color&&p.diffuse.value.copy(d.color),d.emissive&&p.emissive.value.copy(d.emissive).multiplyScalar(d.emissiveIntensity),d.map&&(p.map.value=d.map),d.alphaMap&&(p.alphaMap.value=d.alphaMap),d.specularMap&&(p.specularMap.value=d.specularMap),d.alphaTest>0&&(p.alphaTest.value=d.alphaTest);let A=n.get(d).envMap;A&&(p.envMap.value=A,p.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=d.reflectivity,p.ior.value=d.ior,p.refractionRatio.value=d.refractionRatio),d.lightMap&&(p.lightMap.value=d.lightMap,p.lightMapIntensity.value=d.lightMapIntensity),d.aoMap&&(p.aoMap.value=d.aoMap,p.aoMapIntensity.value=d.aoMapIntensity);let b;d.map?b=d.map:d.specularMap?b=d.specularMap:d.displacementMap?b=d.displacementMap:d.normalMap?b=d.normalMap:d.bumpMap?b=d.bumpMap:d.roughnessMap?b=d.roughnessMap:d.metalnessMap?b=d.metalnessMap:d.alphaMap?b=d.alphaMap:d.emissiveMap?b=d.emissiveMap:d.clearcoatMap?b=d.clearcoatMap:d.clearcoatNormalMap?b=d.clearcoatNormalMap:d.clearcoatRoughnessMap?b=d.clearcoatRoughnessMap:d.specularIntensityMap?b=d.specularIntensityMap:d.specularColorMap?b=d.specularColorMap:d.transmissionMap?b=d.transmissionMap:d.thicknessMap?b=d.thicknessMap:d.sheenColorMap?b=d.sheenColorMap:d.sheenRoughnessMap&&(b=d.sheenRoughnessMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),p.uvTransform.value.copy(b.matrix));let C;d.aoMap?C=d.aoMap:d.lightMap&&(C=d.lightMap),C!==void 0&&(C.isWebGLRenderTarget&&(C=C.texture),C.matrixAutoUpdate===!0&&C.updateMatrix(),p.uv2Transform.value.copy(C.matrix))}function a(p,d){p.diffuse.value.copy(d.color),p.opacity.value=d.opacity}function r(p,d){p.dashSize.value=d.dashSize,p.totalSize.value=d.dashSize+d.gapSize,p.scale.value=d.scale}function s(p,d,A,b){p.diffuse.value.copy(d.color),p.opacity.value=d.opacity,p.size.value=d.size*A,p.scale.value=b*.5,d.map&&(p.map.value=d.map),d.alphaMap&&(p.alphaMap.value=d.alphaMap),d.alphaTest>0&&(p.alphaTest.value=d.alphaTest);let C;d.map?C=d.map:d.alphaMap&&(C=d.alphaMap),C!==void 0&&(C.matrixAutoUpdate===!0&&C.updateMatrix(),p.uvTransform.value.copy(C.matrix))}function o(p,d){p.diffuse.value.copy(d.color),p.opacity.value=d.opacity,p.rotation.value=d.rotation,d.map&&(p.map.value=d.map),d.alphaMap&&(p.alphaMap.value=d.alphaMap),d.alphaTest>0&&(p.alphaTest.value=d.alphaTest);let A;d.map?A=d.map:d.alphaMap&&(A=d.alphaMap),A!==void 0&&(A.matrixAutoUpdate===!0&&A.updateMatrix(),p.uvTransform.value.copy(A.matrix))}function c(p,d){d.emissiveMap&&(p.emissiveMap.value=d.emissiveMap)}function l(p,d){p.specular.value.copy(d.specular),p.shininess.value=Math.max(d.shininess,1e-4),d.emissiveMap&&(p.emissiveMap.value=d.emissiveMap),d.bumpMap&&(p.bumpMap.value=d.bumpMap,p.bumpScale.value=d.bumpScale,d.side===P1&&(p.bumpScale.value*=-1)),d.normalMap&&(p.normalMap.value=d.normalMap,p.normalScale.value.copy(d.normalScale),d.side===P1&&p.normalScale.value.negate()),d.displacementMap&&(p.displacementMap.value=d.displacementMap,p.displacementScale.value=d.displacementScale,p.displacementBias.value=d.displacementBias)}function u(p,d){d.gradientMap&&(p.gradientMap.value=d.gradientMap),d.emissiveMap&&(p.emissiveMap.value=d.emissiveMap),d.bumpMap&&(p.bumpMap.value=d.bumpMap,p.bumpScale.value=d.bumpScale,d.side===P1&&(p.bumpScale.value*=-1)),d.normalMap&&(p.normalMap.value=d.normalMap,p.normalScale.value.copy(d.normalScale),d.side===P1&&p.normalScale.value.negate()),d.displacementMap&&(p.displacementMap.value=d.displacementMap,p.displacementScale.value=d.displacementScale,p.displacementBias.value=d.displacementBias)}function f(p,d){p.roughness.value=d.roughness,p.metalness.value=d.metalness,d.roughnessMap&&(p.roughnessMap.value=d.roughnessMap),d.metalnessMap&&(p.metalnessMap.value=d.metalnessMap),d.emissiveMap&&(p.emissiveMap.value=d.emissiveMap),d.bumpMap&&(p.bumpMap.value=d.bumpMap,p.bumpScale.value=d.bumpScale,d.side===P1&&(p.bumpScale.value*=-1)),d.normalMap&&(p.normalMap.value=d.normalMap,p.normalScale.value.copy(d.normalScale),d.side===P1&&p.normalScale.value.negate()),d.displacementMap&&(p.displacementMap.value=d.displacementMap,p.displacementScale.value=d.displacementScale,p.displacementBias.value=d.displacementBias),n.get(d).envMap&&(p.envMapIntensity.value=d.envMapIntensity)}function h(p,d,A){f(p,d),p.ior.value=d.ior,d.sheen>0&&(p.sheenColor.value.copy(d.sheenColor).multiplyScalar(d.sheen),p.sheenRoughness.value=d.sheenRoughness,d.sheenColorMap&&(p.sheenColorMap.value=d.sheenColorMap),d.sheenRoughnessMap&&(p.sheenRoughnessMap.value=d.sheenRoughnessMap)),d.clearcoat>0&&(p.clearcoat.value=d.clearcoat,p.clearcoatRoughness.value=d.clearcoatRoughness,d.clearcoatMap&&(p.clearcoatMap.value=d.clearcoatMap),d.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=d.clearcoatRoughnessMap),d.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(d.clearcoatNormalScale),p.clearcoatNormalMap.value=d.clearcoatNormalMap,d.side===P1&&p.clearcoatNormalScale.value.negate())),d.transmission>0&&(p.transmission.value=d.transmission,p.transmissionSamplerMap.value=A.texture,p.transmissionSamplerSize.value.set(A.width,A.height),d.transmissionMap&&(p.transmissionMap.value=d.transmissionMap),p.thickness.value=d.thickness,d.thicknessMap&&(p.thicknessMap.value=d.thicknessMap),p.attenuationDistance.value=d.attenuationDistance,p.attenuationColor.value.copy(d.attenuationColor)),p.specularIntensity.value=d.specularIntensity,p.specularColor.value.copy(d.specularColor),d.specularIntensityMap&&(p.specularIntensityMap.value=d.specularIntensityMap),d.specularColorMap&&(p.specularColorMap.value=d.specularColorMap)}function m(p,d){d.matcap&&(p.matcap.value=d.matcap),d.bumpMap&&(p.bumpMap.value=d.bumpMap,p.bumpScale.value=d.bumpScale,d.side===P1&&(p.bumpScale.value*=-1)),d.normalMap&&(p.normalMap.value=d.normalMap,p.normalScale.value.copy(d.normalScale),d.side===P1&&p.normalScale.value.negate()),d.displacementMap&&(p.displacementMap.value=d.displacementMap,p.displacementScale.value=d.displacementScale,p.displacementBias.value=d.displacementBias)}function v(p,d){d.displacementMap&&(p.displacementMap.value=d.displacementMap,p.displacementScale.value=d.displacementScale,p.displacementBias.value=d.displacementBias)}function g(p,d){d.displacementMap&&(p.displacementMap.value=d.displacementMap,p.displacementScale.value=d.displacementScale,p.displacementBias.value=d.displacementBias),p.referencePosition.value.copy(d.referencePosition),p.nearDistance.value=d.nearDistance,p.farDistance.value=d.farDistance}function x(p,d){d.bumpMap&&(p.bumpMap.value=d.bumpMap,p.bumpScale.value=d.bumpScale,d.side===P1&&(p.bumpScale.value*=-1)),d.normalMap&&(p.normalMap.value=d.normalMap,p.normalScale.value.copy(d.normalScale),d.side===P1&&p.normalScale.value.negate()),d.displacementMap&&(p.displacementMap.value=d.displacementMap,p.displacementScale.value=d.displacementScale,p.displacementBias.value=d.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:t}}function th(){let n=E4("canvas");return n.style.display="block",n}function Di(n={}){let e=n.canvas!==void 0?n.canvas:th(),t=n.context!==void 0?n.context:null,i=n.alpha!==void 0?n.alpha:!1,a=n.depth!==void 0?n.depth:!0,r=n.stencil!==void 0?n.stencil:!0,s=n.antialias!==void 0?n.antialias:!1,o=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,c=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",u=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1,f=null,h=null,m=[],v=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=R2,this.physicallyCorrectLights=!1,this.toneMapping=O2,this.toneMappingExposure=1;let g=this,x=!1,p=0,d=0,A=null,b=-1,C=null,E=new q1,T=new q1,_=null,P=e.width,F=e.height,M=1,D=null,z=null,H=new q1(0,0,P,F),V=new q1(0,0,P,F),L=!1,N=new T4,U=!1,Z=!1,O=null,W=new k1,X=new k,Q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function a1(){return A===null?M:1}let B=t;function M1(S,G){for(let j=0;j<S.length;j++){let q=S[j],K=e.getContext(q,G);if(K!==null)return K}return null}try{let S={alpha:!0,depth:a,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Hr}`),e.addEventListener("webglcontextlost",b1,!1),e.addEventListener("webglcontextrestored",I,!1),B===null){let G=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&G.shift(),B=M1(G,S),B===null)throw M1(G)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}B.getShaderPrecisionFormat===void 0&&(B.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(S){throw console.error("THREE.WebGLRenderer: "+S.message),S}let u1,v1,n1,T1,A1,C1,h2,K1,a2,j2,v2,g2,X2,oe,ce,R,w,J,t1,h1,Y,d1,f1;function s1(){u1=new T5(B),v1=new M5(B,u1,n),u1.init(v1),d1=new xo(B,u1,v1),n1=new vo(B,u1,v1),T1=new N5(B),A1=new no,C1=new go(B,u1,n1,A1,v1,d1,T1),h2=new y5(g),K1=new D5(g),a2=new I8(B,v1),f1=new g5(B,u1,a2,v1),j2=new H5(B,a2,T1,f1),v2=new B5(B,j2,a2,T1),t1=new F5(B,v1,C1),R=new b5(A1),g2=new ro(g,h2,K1,u1,v1,f1,R),X2=new Mo(A1),oe=new co,ce=new ho(u1,v1),J=new v5(g,h2,n1,v2,i,o),w=new mo(g,v2,v1),h1=new x5(B,u1,T1,v1),Y=new V5(B,u1,T1,v1),T1.programs=g2.programs,g.capabilities=v1,g.extensions=u1,g.properties=A1,g.renderLists=oe,g.shadowMap=w,g.state=n1,g.info=T1}s1();let r1=new Li(g,B);this.xr=r1,this.getContext=function(){return B},this.getContextAttributes=function(){return B.getContextAttributes()},this.forceContextLoss=function(){let S=u1.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){let S=u1.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return M},this.setPixelRatio=function(S){S!==void 0&&(M=S,this.setSize(P,F,!1))},this.getSize=function(S){return S.set(P,F)},this.setSize=function(S,G,j){if(r1.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}P=S,F=G,e.width=Math.floor(S*M),e.height=Math.floor(G*M),j!==!1&&(e.style.width=S+"px",e.style.height=G+"px"),this.setViewport(0,0,S,G)},this.getDrawingBufferSize=function(S){return S.set(P*M,F*M).floor()},this.setDrawingBufferSize=function(S,G,j){P=S,F=G,M=j,e.width=Math.floor(S*j),e.height=Math.floor(G*j),this.setViewport(0,0,S,G)},this.getCurrentViewport=function(S){return S.copy(E)},this.getViewport=function(S){return S.copy(H)},this.setViewport=function(S,G,j,q){S.isVector4?H.set(S.x,S.y,S.z,S.w):H.set(S,G,j,q),n1.viewport(E.copy(H).multiplyScalar(M).floor())},this.getScissor=function(S){return S.copy(V)},this.setScissor=function(S,G,j,q){S.isVector4?V.set(S.x,S.y,S.z,S.w):V.set(S,G,j,q),n1.scissor(T.copy(V).multiplyScalar(M).floor())},this.getScissorTest=function(){return L},this.setScissorTest=function(S){n1.setScissorTest(L=S)},this.setOpaqueSort=function(S){D=S},this.setTransparentSort=function(S){z=S},this.getClearColor=function(S){return S.copy(J.getClearColor())},this.setClearColor=function(){J.setClearColor.apply(J,arguments)},this.getClearAlpha=function(){return J.getClearAlpha()},this.setClearAlpha=function(){J.setClearAlpha.apply(J,arguments)},this.clear=function(S,G,j){let q=0;(S===void 0||S)&&(q|=B.COLOR_BUFFER_BIT),(G===void 0||G)&&(q|=B.DEPTH_BUFFER_BIT),(j===void 0||j)&&(q|=B.STENCIL_BUFFER_BIT),B.clear(q)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",b1,!1),e.removeEventListener("webglcontextrestored",I,!1),oe.dispose(),ce.dispose(),A1.dispose(),h2.dispose(),K1.dispose(),v2.dispose(),f1.dispose(),g2.dispose(),r1.dispose(),r1.removeEventListener("sessionstart",D1),r1.removeEventListener("sessionend",X1),O&&(O.dispose(),O=null),H2.stop()};function b1(S){S.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function I(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;let S=T1.autoReset,G=w.enabled,j=w.autoUpdate,q=w.needsUpdate,K=w.type;s1(),T1.autoReset=S,w.enabled=G,w.autoUpdate=j,w.needsUpdate=q,w.type=K}function l1(S){let G=S.target;G.removeEventListener("dispose",l1),o1(G)}function o1(S){m1(S),A1.remove(S)}function m1(S){let G=A1.get(S).programs;G!==void 0&&(G.forEach(function(j){g2.releaseProgram(j)}),S.isShaderMaterial&&g2.releaseShaderCache(S))}this.renderBufferDirect=function(S,G,j,q,K,g1){G===null&&(G=Q);let y1=K.isMesh&&K.matrixWorld.determinant()<0,_1=No(S,G,j,q,K);n1.setMaterial(q,y1);let w1=j.index,B1=j.attributes.position;if(w1===null){if(B1===void 0||B1.count===0)return}else if(w1.count===0)return;let H1=1;q.wireframe===!0&&(w1=j2.getWireframeAttribute(j),H1=2),f1.setup(K,q,_1,j,w1);let V1,Y1=h1;w1!==null&&(V1=a2.get(w1),Y1=Y,Y1.setIndex(V1));let p4=w1!==null?w1.count:B1.count,R4=j.drawRange.start*H1,R1=j.drawRange.count*H1,ue=g1!==null?g1.start*H1:0,r2=g1!==null?g1.count*H1:1/0,he=Math.max(R4,ue),$t=Math.min(p4,R4+R1,ue+r2)-1,fe=Math.max(0,$t-he+1);if(fe!==0){if(K.isMesh)q.wireframe===!0?(n1.setLineWidth(q.wireframeLinewidth*a1()),Y1.setMode(B.LINES)):Y1.setMode(B.TRIANGLES);else if(K.isLine){let Ee=q.linewidth;Ee===void 0&&(Ee=1),n1.setLineWidth(Ee*a1()),K.isLineSegments?Y1.setMode(B.LINES):K.isLineLoop?Y1.setMode(B.LINE_LOOP):Y1.setMode(B.LINE_STRIP)}else K.isPoints?Y1.setMode(B.POINTS):K.isSprite&&Y1.setMode(B.TRIANGLES);if(K.isInstancedMesh)Y1.renderInstances(he,fe,K.count);else if(j.isInstancedBufferGeometry){let Ee=Math.min(j.instanceCount,j._maxInstanceCount);Y1.renderInstances(he,fe,Ee)}else Y1.render(he,fe)}},this.compile=function(S,G){h=ce.get(S),h.init(),v.push(h),S.traverseVisible(function(j){j.isLight&&j.layers.test(G.layers)&&(h.pushLight(j),j.castShadow&&h.pushShadow(j))}),h.setupLights(g.physicallyCorrectLights),S.traverse(function(j){let q=j.material;if(q)if(Array.isArray(q))for(let K=0;K<q.length;K++){let g1=q[K];x0(g1,S,j)}else x0(q,S,j)}),v.pop(),h=null};let $=null;function p1(S){$&&$(S)}function D1(){H2.stop()}function X1(){H2.start()}let H2=new Q6;H2.setAnimationLoop(p1),typeof window!="undefined"&&H2.setContext(window),this.setAnimationLoop=function(S){$=S,r1.setAnimationLoop(S),S===null?H2.stop():H2.start()},r1.addEventListener("sessionstart",D1),r1.addEventListener("sessionend",X1),this.render=function(S,G){if(G!==void 0&&G.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(x===!0)return;S.autoUpdate===!0&&S.updateMatrixWorld(),G.parent===null&&G.updateMatrixWorld(),r1.enabled===!0&&r1.isPresenting===!0&&(r1.cameraAutoUpdate===!0&&r1.updateCamera(G),G=r1.getCamera()),S.isScene===!0&&S.onBeforeRender(g,S,G,A),h=ce.get(S,v.length),h.init(),v.push(h),W.multiplyMatrices(G.projectionMatrix,G.matrixWorldInverse),N.setFromProjectionMatrix(W),Z=this.localClippingEnabled,U=R.init(this.clippingPlanes,Z,G),f=oe.get(S,m.length),f.init(),m.push(f),Z1(S,G,0,g.sortObjects),f.finish(),g.sortObjects===!0&&f.sort(D,z),U===!0&&R.beginShadows();let j=h.state.shadowsArray;if(w.render(j,S,G),U===!0&&R.endShadows(),this.info.autoReset===!0&&this.info.reset(),J.render(f,S),h.setupLights(g.physicallyCorrectLights),G.isArrayCamera){let q=G.cameras;for(let K=0,g1=q.length;K<g1;K++){let y1=q[K];le(f,S,y1,y1.viewport)}}else le(f,S,G);A!==null&&(C1.updateMultisampleRenderTarget(A),C1.updateRenderTargetMipmap(A)),S.isScene===!0&&S.onAfterRender(g,S,G),n1.buffers.depth.setTest(!0),n1.buffers.depth.setMask(!0),n1.buffers.color.setMask(!0),n1.setPolygonOffset(!1),f1.resetDefaultState(),b=-1,C=null,v.pop(),v.length>0?h=v[v.length-1]:h=null,m.pop(),m.length>0?f=m[m.length-1]:f=null};function Z1(S,G,j,q){if(S.visible===!1)return;if(S.layers.test(G.layers)){if(S.isGroup)j=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(G);else if(S.isLight)h.pushLight(S),S.castShadow&&h.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||N.intersectsSprite(S)){q&&X.setFromMatrixPosition(S.matrixWorld).applyMatrix4(W);let y1=v2.update(S),_1=S.material;_1.visible&&f.push(S,y1,_1,j,X.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(S.isSkinnedMesh&&S.skeleton.frame!==T1.render.frame&&(S.skeleton.update(),S.skeleton.frame=T1.render.frame),!S.frustumCulled||N.intersectsObject(S))){q&&X.setFromMatrixPosition(S.matrixWorld).applyMatrix4(W);let y1=v2.update(S),_1=S.material;if(Array.isArray(_1)){let w1=y1.groups;for(let B1=0,H1=w1.length;B1<H1;B1++){let V1=w1[B1],Y1=_1[V1.materialIndex];Y1&&Y1.visible&&f.push(S,y1,Y1,j,X.z,V1)}}else _1.visible&&f.push(S,y1,_1,j,X.z,null)}}let g1=S.children;for(let y1=0,_1=g1.length;y1<_1;y1++)Z1(g1[y1],G,j,q)}function le(S,G,j,q){let K=S.opaque,g1=S.transmissive,y1=S.transparent;h.setupLightsView(j),g1.length>0&&_e(K,G,j),q&&n1.viewport(E.copy(q)),K.length>0&&Yt(K,G,j),g1.length>0&&Yt(g1,G,j),y1.length>0&&Yt(y1,G,j)}function _e(S,G,j){if(O===null){let y1=s===!0&&v1.isWebGL2===!0?ft:m2;O=new y1(1024,1024,{generateMipmaps:!0,type:d1.convert(ye)!==null?ye:N2,minFilter:r4,magFilter:Q1,wrapS:c2,wrapT:c2,useRenderToTexture:u1.has("WEBGL_multisampled_render_to_texture")})}let q=g.getRenderTarget();g.setRenderTarget(O),g.clear();let K=g.toneMapping;g.toneMapping=O2,Yt(S,G,j),g.toneMapping=K,C1.updateMultisampleRenderTarget(O),C1.updateRenderTargetMipmap(O),g.setRenderTarget(q)}function Yt(S,G,j){let q=G.isScene===!0?G.overrideMaterial:null;for(let K=0,g1=S.length;K<g1;K++){let y1=S[K],_1=y1.object,w1=y1.geometry,B1=q===null?y1.material:q,H1=y1.group;_1.layers.test(j.layers)&&Vo(_1,G,j,w1,B1,H1)}}function Vo(S,G,j,q,K,g1){S.onBeforeRender(g,G,j,q,K,g1),S.modelViewMatrix.multiplyMatrices(j.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),K.onBeforeRender(g,G,j,q,S,g1),K.transparent===!0&&K.side===J2?(K.side=P1,K.needsUpdate=!0,g.renderBufferDirect(j,G,q,K,S,g1),K.side=ke,K.needsUpdate=!0,g.renderBufferDirect(j,G,q,K,S,g1),K.side=J2):g.renderBufferDirect(j,G,q,K,S,g1),S.onAfterRender(g,G,j,q,K,g1)}function x0(S,G,j){G.isScene!==!0&&(G=Q);let q=A1.get(S),K=h.state.lights,g1=h.state.shadowsArray,y1=K.state.version,_1=g2.getParameters(S,K.state,g1,G,j),w1=g2.getProgramCacheKey(_1),B1=q.programs;q.environment=S.isMeshStandardMaterial?G.environment:null,q.fog=G.fog,q.envMap=(S.isMeshStandardMaterial?K1:h2).get(S.envMap||q.environment),B1===void 0&&(S.addEventListener("dispose",l1),B1=new Map,q.programs=B1);let H1=B1.get(w1);if(H1!==void 0){if(q.currentProgram===H1&&q.lightsStateVersion===y1)return Ri(S,_1),H1}else _1.uniforms=g2.getUniforms(S),S.onBuild(j,_1,g),S.onBeforeCompile(_1,g),H1=g2.acquireProgram(_1,w1),B1.set(w1,H1),q.uniforms=_1.uniforms;let V1=q.uniforms;(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(V1.clippingPlanes=R.uniform),Ri(S,_1),q.needsLights=Fo(S),q.lightsStateVersion=y1,q.needsLights&&(V1.ambientLightColor.value=K.state.ambient,V1.lightProbe.value=K.state.probe,V1.directionalLights.value=K.state.directional,V1.directionalLightShadows.value=K.state.directionalShadow,V1.spotLights.value=K.state.spot,V1.spotLightShadows.value=K.state.spotShadow,V1.rectAreaLights.value=K.state.rectArea,V1.ltc_1.value=K.state.rectAreaLTC1,V1.ltc_2.value=K.state.rectAreaLTC2,V1.pointLights.value=K.state.point,V1.pointLightShadows.value=K.state.pointShadow,V1.hemisphereLights.value=K.state.hemi,V1.directionalShadowMap.value=K.state.directionalShadowMap,V1.directionalShadowMatrix.value=K.state.directionalShadowMatrix,V1.spotShadowMap.value=K.state.spotShadowMap,V1.spotShadowMatrix.value=K.state.spotShadowMatrix,V1.pointShadowMap.value=K.state.pointShadowMap,V1.pointShadowMatrix.value=K.state.pointShadowMatrix);let Y1=H1.getUniforms(),p4=we.seqWithValue(Y1.seq,V1);return q.currentProgram=H1,q.uniformsList=p4,H1}function Ri(S,G){let j=A1.get(S);j.outputEncoding=G.outputEncoding,j.instancing=G.instancing,j.skinning=G.skinning,j.morphTargets=G.morphTargets,j.morphNormals=G.morphNormals,j.morphTargetsCount=G.morphTargetsCount,j.numClippingPlanes=G.numClippingPlanes,j.numIntersection=G.numClipIntersection,j.vertexAlphas=G.vertexAlphas,j.vertexTangents=G.vertexTangents,j.toneMapping=G.toneMapping}function No(S,G,j,q,K){G.isScene!==!0&&(G=Q),C1.resetTextureUnits();let g1=G.fog,y1=q.isMeshStandardMaterial?G.environment:null,_1=A===null?g.outputEncoding:A.isXRRenderTarget===!0?A.texture.encoding:R2,w1=(q.isMeshStandardMaterial?K1:h2).get(q.envMap||y1),B1=q.vertexColors===!0&&!!j.attributes.color&&j.attributes.color.itemSize===4,H1=!!q.normalMap&&!!j.attributes.tangent,V1=!!j.morphAttributes.position,Y1=!!j.morphAttributes.normal,p4=j.morphAttributes.position?j.morphAttributes.position.length:0,R4=q.toneMapped?g.toneMapping:O2,R1=A1.get(q),ue=h.state.lights;if(U===!0&&(Z===!0||S!==C)){let Z2=S===C&&q.id===b;R.setState(q,S,Z2)}let r2=!1;q.version===R1.__version?(R1.needsLights&&R1.lightsStateVersion!==ue.state.version||R1.outputEncoding!==_1||K.isInstancedMesh&&R1.instancing===!1||!K.isInstancedMesh&&R1.instancing===!0||K.isSkinnedMesh&&R1.skinning===!1||!K.isSkinnedMesh&&R1.skinning===!0||R1.envMap!==w1||q.fog&&R1.fog!==g1||R1.numClippingPlanes!==void 0&&(R1.numClippingPlanes!==R.numPlanes||R1.numIntersection!==R.numIntersection)||R1.vertexAlphas!==B1||R1.vertexTangents!==H1||R1.morphTargets!==V1||R1.morphNormals!==Y1||R1.toneMapping!==R4||v1.isWebGL2===!0&&R1.morphTargetsCount!==p4)&&(r2=!0):(r2=!0,R1.__version=q.version);let he=R1.currentProgram;r2===!0&&(he=x0(q,G,K));let $t=!1,fe=!1,Ee=!1,x2=he.getUniforms(),vt=R1.uniforms;if(n1.useProgram(he.program)&&($t=!0,fe=!0,Ee=!0),q.id!==b&&(b=q.id,fe=!0),$t||C!==S){if(x2.setValue(B,"projectionMatrix",S.projectionMatrix),v1.logarithmicDepthBuffer&&x2.setValue(B,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),C!==S&&(C=S,fe=!0,Ee=!0),q.isShaderMaterial||q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshStandardMaterial||q.envMap){let Z2=x2.map.cameraPosition;Z2!==void 0&&Z2.setValue(B,X.setFromMatrixPosition(S.matrixWorld))}(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial)&&x2.setValue(B,"isOrthographic",S.isOrthographicCamera===!0),(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial||q.isShadowMaterial||K.isSkinnedMesh)&&x2.setValue(B,"viewMatrix",S.matrixWorldInverse)}if(K.isSkinnedMesh){x2.setOptional(B,K,"bindMatrix"),x2.setOptional(B,K,"bindMatrixInverse");let Z2=K.skeleton;Z2&&(v1.floatVertexTextures?(Z2.boneTexture===null&&Z2.computeBoneTexture(),x2.setValue(B,"boneTexture",Z2.boneTexture,C1),x2.setValue(B,"boneTextureSize",Z2.boneTextureSize)):x2.setOptional(B,Z2,"boneMatrices"))}return!!j&&(j.morphAttributes.position!==void 0||j.morphAttributes.normal!==void 0)&&t1.update(K,j,q,he),(fe||R1.receiveShadow!==K.receiveShadow)&&(R1.receiveShadow=K.receiveShadow,x2.setValue(B,"receiveShadow",K.receiveShadow)),fe&&(x2.setValue(B,"toneMappingExposure",g.toneMappingExposure),R1.needsLights&&Ro(vt,Ee),g1&&q.fog&&X2.refreshFogUniforms(vt,g1),X2.refreshMaterialUniforms(vt,q,M,F,O),we.upload(B,R1.uniformsList,vt,C1)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(we.upload(B,R1.uniformsList,vt,C1),q.uniformsNeedUpdate=!1),q.isSpriteMaterial&&x2.setValue(B,"center",K.center),x2.setValue(B,"modelViewMatrix",K.modelViewMatrix),x2.setValue(B,"normalMatrix",K.normalMatrix),x2.setValue(B,"modelMatrix",K.matrixWorld),he}function Ro(S,G){S.ambientLightColor.needsUpdate=G,S.lightProbe.needsUpdate=G,S.directionalLights.needsUpdate=G,S.directionalLightShadows.needsUpdate=G,S.pointLights.needsUpdate=G,S.pointLightShadows.needsUpdate=G,S.spotLights.needsUpdate=G,S.spotLightShadows.needsUpdate=G,S.rectAreaLights.needsUpdate=G,S.hemisphereLights.needsUpdate=G}function Fo(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return p},this.getActiveMipmapLevel=function(){return d},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(S,G,j){A1.get(S.texture).__webglTexture=G,A1.get(S.depthTexture).__webglTexture=j;let q=A1.get(S);q.__hasExternalTextures=!0,q.__hasExternalTextures&&(q.__autoAllocateDepthBuffer=j===void 0,q.__autoAllocateDepthBuffer||S.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),S.useRenderToTexture=!1,S.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(S,G){let j=A1.get(S);j.__webglFramebuffer=G,j.__useDefaultFramebuffer=G===void 0},this.setRenderTarget=function(S,G=0,j=0){A=S,p=G,d=j;let q=!0;if(S){let w1=A1.get(S);w1.__useDefaultFramebuffer!==void 0?(n1.bindFramebuffer(B.FRAMEBUFFER,null),q=!1):w1.__webglFramebuffer===void 0?C1.setupRenderTarget(S):w1.__hasExternalTextures&&C1.rebindTextures(S,A1.get(S.texture).__webglTexture,A1.get(S.depthTexture).__webglTexture)}let K=null,g1=!1,y1=!1;if(S){let w1=S.texture;(w1.isDataTexture3D||w1.isDataTexture2DArray)&&(y1=!0);let B1=A1.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(K=B1[G],g1=!0):S.useRenderbuffer?K=A1.get(S).__webglMultisampledFramebuffer:K=B1,E.copy(S.viewport),T.copy(S.scissor),_=S.scissorTest}else E.copy(H).multiplyScalar(M).floor(),T.copy(V).multiplyScalar(M).floor(),_=L;if(n1.bindFramebuffer(B.FRAMEBUFFER,K)&&v1.drawBuffers&&q&&n1.drawBuffers(S,K),n1.viewport(E),n1.scissor(T),n1.setScissorTest(_),g1){let w1=A1.get(S.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+G,w1.__webglTexture,j)}else if(y1){let w1=A1.get(S.texture),B1=G||0;B.framebufferTextureLayer(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,w1.__webglTexture,j||0,B1)}b=-1},this.readRenderTargetPixels=function(S,G,j,q,K,g1,y1){if(!(S&&S.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _1=A1.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&y1!==void 0&&(_1=_1[y1]),_1){n1.bindFramebuffer(B.FRAMEBUFFER,_1);try{let w1=S.texture,B1=w1.format,H1=w1.type;if(B1!==W1&&d1.convert(B1)!==B.getParameter(B.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let V1=H1===ye&&(u1.has("EXT_color_buffer_half_float")||v1.isWebGL2&&u1.has("EXT_color_buffer_float"));if(H1!==N2&&d1.convert(H1)!==B.getParameter(B.IMPLEMENTATION_COLOR_READ_TYPE)&&!(H1===Q2&&(v1.isWebGL2||u1.has("OES_texture_float")||u1.has("WEBGL_color_buffer_float")))&&!V1){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B.checkFramebufferStatus(B.FRAMEBUFFER)===B.FRAMEBUFFER_COMPLETE?G>=0&&G<=S.width-q&&j>=0&&j<=S.height-K&&B.readPixels(G,j,q,K,d1.convert(B1),d1.convert(H1),g1):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{let w1=A!==null?A1.get(A).__webglFramebuffer:null;n1.bindFramebuffer(B.FRAMEBUFFER,w1)}}},this.copyFramebufferToTexture=function(S,G,j=0){if(G.isFramebufferTexture!==!0){console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");return}let q=Math.pow(2,-j),K=Math.floor(G.image.width*q),g1=Math.floor(G.image.height*q);C1.setTexture2D(G,0),B.copyTexSubImage2D(B.TEXTURE_2D,j,0,0,S.x,S.y,K,g1),n1.unbindTexture()},this.copyTextureToTexture=function(S,G,j,q=0){let K=G.image.width,g1=G.image.height,y1=d1.convert(j.format),_1=d1.convert(j.type);C1.setTexture2D(j,0),B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,j.flipY),B.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),B.pixelStorei(B.UNPACK_ALIGNMENT,j.unpackAlignment),G.isDataTexture?B.texSubImage2D(B.TEXTURE_2D,q,S.x,S.y,K,g1,y1,_1,G.image.data):G.isCompressedTexture?B.compressedTexSubImage2D(B.TEXTURE_2D,q,S.x,S.y,G.mipmaps[0].width,G.mipmaps[0].height,y1,G.mipmaps[0].data):B.texSubImage2D(B.TEXTURE_2D,q,S.x,S.y,y1,_1,G.image),q===0&&j.generateMipmaps&&B.generateMipmap(B.TEXTURE_2D),n1.unbindTexture()},this.copyTextureToTexture3D=function(S,G,j,q,K=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let g1=S.max.x-S.min.x+1,y1=S.max.y-S.min.y+1,_1=S.max.z-S.min.z+1,w1=d1.convert(q.format),B1=d1.convert(q.type),H1;if(q.isDataTexture3D)C1.setTexture3D(q,0),H1=B.TEXTURE_3D;else if(q.isDataTexture2DArray)C1.setTexture2DArray(q,0),H1=B.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,q.flipY),B.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,q.premultiplyAlpha),B.pixelStorei(B.UNPACK_ALIGNMENT,q.unpackAlignment);let V1=B.getParameter(B.UNPACK_ROW_LENGTH),Y1=B.getParameter(B.UNPACK_IMAGE_HEIGHT),p4=B.getParameter(B.UNPACK_SKIP_PIXELS),R4=B.getParameter(B.UNPACK_SKIP_ROWS),R1=B.getParameter(B.UNPACK_SKIP_IMAGES),ue=j.isCompressedTexture?j.mipmaps[0]:j.image;B.pixelStorei(B.UNPACK_ROW_LENGTH,ue.width),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,ue.height),B.pixelStorei(B.UNPACK_SKIP_PIXELS,S.min.x),B.pixelStorei(B.UNPACK_SKIP_ROWS,S.min.y),B.pixelStorei(B.UNPACK_SKIP_IMAGES,S.min.z),j.isDataTexture||j.isDataTexture3D?B.texSubImage3D(H1,K,G.x,G.y,G.z,g1,y1,_1,w1,B1,ue.data):j.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),B.compressedTexSubImage3D(H1,K,G.x,G.y,G.z,g1,y1,_1,w1,ue.data)):B.texSubImage3D(H1,K,G.x,G.y,G.z,g1,y1,_1,w1,B1,ue),B.pixelStorei(B.UNPACK_ROW_LENGTH,V1),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,Y1),B.pixelStorei(B.UNPACK_SKIP_PIXELS,p4),B.pixelStorei(B.UNPACK_SKIP_ROWS,R4),B.pixelStorei(B.UNPACK_SKIP_IMAGES,R1),K===0&&q.generateMipmaps&&B.generateMipmap(H1),n1.unbindTexture()},this.initTexture=function(S){C1.setTexture2D(S,0),n1.unbindTexture()},this.resetState=function(){p=0,d=0,A=null,n1.reset(),f1.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}Di.prototype.isWebGLRenderer=!0;var u0=class extends j1{constructor(){super();this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}};u0.prototype.isScene=!0;var pt=class extends j1{constructor(e,t=1){super();this.type="Light",this.color=new x1(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}};pt.prototype.isLight=!0;var h0=class extends pt{constructor(e,t){super(e,t);this.type="AmbientLight"}};h0.prototype.isAmbientLight=!0;var bo=new k1,yo=new k,Co=new k,Ti=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new z1(512,512),this.map=null,this.mapPass=null,this.matrix=new k1,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new T4,this._frameExtents=new z1(1,1),this._viewportCount=1,this._viewports=[new q1(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;yo.setFromMatrixPosition(e.matrixWorld),t.position.copy(yo),Co.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Co),t.updateMatrixWorld(),bo.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bo),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t.projectionMatrix),i.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}};var f0=class extends Ti{constructor(){super(new i2(50,1,.5,500));this.focus=1}updateMatrices(e){let t=this.camera,i=_t*2*e.angle*this.focus,a=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(i!==t.fov||a!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=a,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}};f0.prototype.isSpotLightShadow=!0;var d0=class extends pt{constructor(e,t,i=0,a=Math.PI/3,r=0,s=1){super(e,t);this.type="SpotLight",this.position.copy(j1.DefaultUp),this.updateMatrix(),this.target=new j1,this.distance=i,this.angle=a,this.penumbra=r,this.decay=s,this.shadow=new f0}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};d0.prototype.isSpotLight=!0;var p0=class extends T2{constructor(e){super();this.type="ShadowMaterial",this.color=new x1(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}};p0.prototype.isShadowMaterial=!0;var m0=class extends Xt.Component{constructor(e){super();this.plugin=e;this.event=new Xt.Events;this.container=createDiv("renderer-container");this.shadows=!0;this.iterations=0;this.frame_rate=1/60;this.animating=!1;this.factory=new Ao(this.WIDTH,this.HEIGHT,this.plugin);this.colors={ambient:16777215,spotlight:16777215};this.display={currentWidth:null,currentHeight:null,containerWidth:null,containerHeight:null,aspect:null,scale:null};this.cameraHeight={max:null,close:null,medium:null,far:null};this.extraFrames=m0.DEFAULT_EXTRA_FRAMES;this.renderer=new Di({alpha:!0,antialias:!0})}get WIDTH(){return this.container.clientWidth/2}get HEIGHT(){return this.container.clientHeight/2}get ASPECT(){return this.WIDTH/this.HEIGHT}get scale(){return(this.WIDTH*this.WIDTH+this.HEIGHT*this.HEIGHT)/13}get canvasEl(){return this.renderer?this.renderer.domElement:null}setDice(e){this.animating&&(this.unload(),this.load()),this.stack=e,this.current=this.factory.getDice(this.stack,{x:(Math.random()*2-1)*this.WIDTH,y:-(Math.random()*2-1)*this.HEIGHT}),this.scene.add(...[...this.current.values()].flat().map(t=>t.geometry)),this.world.add(...[...this.current.values()].flat())}onload(){this.addChild(this.factory),this.container.empty(),this.container.style.opacity="1",document.body.appendChild(this.container),this.renderer.shadowMap.enabled=this.shadows,this.renderer.shadowMap.type=w6,this.container.appendChild(this.renderer.domElement),this.renderer.setClearColor(0,0),this.scene=new u0,this.initScene(),this.registerDomEvent(window,"resize",()=>{this.initScene()}),this.initWorld()}async start(){return new Promise(async(e,t)=>{this.current.size||t(),this.event.on("throw-finished",i=>{e(i)}),this.event.on("error",i=>{t(i)}),this.animating=!0,this.extraFrames=m0.DEFAULT_EXTRA_FRAMES,this.render()})}enableShadows(){this.shadows=!0,this.renderer&&(this.renderer.shadowMap.enabled=this.shadows),this.light&&(this.light.castShadow=this.shadows),this.desk&&(this.desk.receiveShadow=this.shadows)}disableShadows(){this.shadows=!1,this.renderer&&(this.renderer.shadowMap.enabled=this.shadows),this.light&&(this.light.castShadow=this.shadows),this.desk&&(this.desk.receiveShadow=this.shadows)}get mw(){return Math.max(this.WIDTH,this.HEIGHT)}setDimensions(e){this.display.currentWidth=this.container.clientWidth/2,this.display.currentHeight=this.container.clientHeight/2,e?(this.display.containerWidth=e.w,this.display.containerHeight=e.h):(this.display.containerWidth=this.display.currentWidth,this.display.containerHeight=this.display.currentHeight),this.display.aspect=Math.min(this.display.currentWidth/this.display.containerWidth,this.display.currentHeight/this.display.containerHeight),this.display.scale=Math.sqrt(this.display.containerWidth*this.display.containerWidth+this.display.containerHeight*this.display.containerHeight)/13,this.renderer.setSize(this.display.currentWidth*2,this.display.currentHeight*2),this.cameraHeight.max=this.display.currentHeight/this.display.aspect/Math.tan(10*Math.PI/180),this.factory.width=this.display.currentWidth,this.factory.height=this.display.currentHeight,this.cameraHeight.medium=this.cameraHeight.max/1.5,this.cameraHeight.far=this.cameraHeight.max,this.cameraHeight.close=this.cameraHeight.max/2}initCamera(){this.camera&&this.scene.remove(this.camera),this.camera=new i2(20,this.display.currentWidth/this.display.currentHeight,1,this.cameraHeight.max*1.3),this.camera.position.z=this.cameraHeight.far,this.camera.lookAt(new k(0,0,0))}initLighting(){let e=Math.max(this.display.containerWidth,this.display.containerHeight);this.light&&this.scene.remove(this.light),this.ambientLight&&this.scene.remove(this.ambientLight),this.light=new d0(this.colors.spotlight,.25),this.light.position.set(-e/2,e/2,e*3),this.light.target.position.set(0,0,0),this.light.distance=e*5,this.light.angle=Math.PI/4,this.light.castShadow=this.shadows,this.light.shadow.camera.near=e/10,this.light.shadow.camera.far=e*5,this.light.shadow.camera.fov=50,this.light.shadow.bias=.001,this.light.shadow.mapSize.width=1024,this.light.shadow.mapSize.height=1024,this.scene.add(this.light),this.ambientLight=new h0(16777215,.9),this.scene.add(this.ambientLight)}initDesk(){this.desk&&this.scene.remove(this.desk);let e=new p0;e.opacity=.5,this.desk=new u2(new H4(this.display.containerWidth*6,this.display.containerHeight*6,1,1),e),this.desk.receiveShadow=this.shadows,this.scene.add(this.desk)}initScene(){this.setDimensions(),this.initCamera(),this.initLighting(),this.initDesk(),this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera)}initWorld(){this.world=new zo(this.WIDTH,this.HEIGHT),this.iterations=0}getResultsForRoller(e){let t=this.current.get(e),i=t.filter(s=>s instanceof D4&&s.isPercentile),a=[];for(let s=0;s<i.length;s+=2)a.push(i.slice(s,s+2));return[...t.filter(s=>!(s instanceof D4&&s.isPercentile)).map(s=>s.getUpsideValue()).filter(s=>s),...a.map(([s,o])=>{let c=s.getUpsideValue();if(!o)return c;let l=o.getUpsideValue();return c===10&&l==10?100:(l==10&&(l=0),c==10&&(c=0),c*10+l)}).filter(s=>s)]}returnResult(){for(let e of this.stack.dynamic){if(!this.current.has(e))continue;let t=this.getResultsForRoller(e);!t||e.setResults(t)}this.event.trigger("throw-finished",this.stack)}unrender(e=this){e.container.style.opacity="0",e.registerInterval(window.setTimeout(()=>{e.animating=!1,e.unload()},1e3))}render(){if(this.throwFinished())if(this.extraFrames>10)this.extraFrames--;else{try{for(let[e,t]of this.current)if(!(!e.modifiers.size||!this.getResultsForRoller(e))&&e.modifiers.has("r")){let a=t.filter(r=>(e.conditions.length||e.conditions.push({operator:"=",comparer:e.faces.min,value:""}),e.checkCondition(r.result,e.conditions)&&r.rerolled<e.modifiers.get("r").data));if(a.length){a.forEach(r=>{r.rerolled++;let s={x:(Math.random()*2-1)*this.WIDTH,y:-(Math.random()*2-1)*this.HEIGHT};r.vector=r.generateVector(s),r.create(),r.set(),r.stopped=!1}),this.animation=requestAnimationFrame(()=>this.render());return}}if(this.returnResult(),this.plugin.data.renderTime)this.registerInterval(window.setTimeout(()=>this.unrender(),this.plugin.data.renderTime));else{let t=function(){e.unrender(e),document.body.removeEventListener("click",t)},e=this;this.registerDomEvent(document.body,"click",t)}}catch(e){this.event.trigger("error",e)}return}this.animation=requestAnimationFrame(()=>this.render()),this.world.step(this.frame_rate),this.iterations++,this.current.forEach(e=>{e.map(t=>t.set())}),this.renderer.render(this.scene,this.camera)}dispose(...e){e.forEach(t=>{"dispose"in t&&t.dispose(),t.children&&this.dispose(...t.children)})}detach(){}onunload(){cancelAnimationFrame(this.animation),this.container.detach(),this.container.empty(),this.renderer.domElement.detach(),this.renderer.dispose(),this.factory.dispose(),this.ambientLight.dispose(),this.light.dispose(),this.scene.children.forEach(e=>this.dispose(e)),this.scene.remove(this.scene,...this.scene.children,...[...this.current.values()].flat().map(e=>e.geometry)),this.current.forEach(e=>{e.forEach(t=>{[...Array.isArray(t.geometry.material)?t.geometry.material:[t.geometry.material]].forEach(a=>a&&a.dispose()),this.world.world.removeBody(t.body)})}),this.current=new Map}onThrowFinished(){}throwFinished(){let e=!0,t=4;if(this.iterations<10/this.frame_rate)for(let i of this.current.values())for(let a of i){if(a.stopped===!0)continue;let r=a.body.angularVelocity,s=a.body.velocity;if(Math.abs(r.x)<t&&Math.abs(r.y)<t&&Math.abs(r.z)<t&&Math.abs(s.x)<t&&Math.abs(s.y)<t&&Math.abs(s.z)<t){if(a.stopped){if(this.iterations-a.stopped>3){a.stopped=!0;continue}}else a.stopped=this.iterations;e=!1}else a.stopped=void 0,e=!1}return e}},Zt=m0;Zt.DEFAULT_EXTRA_FRAMES=30;var zo=class{constructor(e,t){this.WIDTH=e;this.HEIGHT=t;this.world=new $0({gravity:new y(0,0,-9.82*400)});this.ground=this.getPlane();this.diceMaterial=new Ve;this.deskMaterial=new Ve;this.barrierMaterial=new Ve;this.world.broadphase=new d6,this.world.allowSleep=!0,this.ground.position.set(0,0,0),this.world.addBody(this.ground),this.buildWalls()}add(...e){e.forEach(t=>{this.world.addBody(t.body)})}step(e=1/60){let t=performance.now()/1e3;if(!this.lastCallTime)this.world.step(e);else{let i=t-this.lastCallTime;this.world.step(e,i)}this.lastCallTime=t}buildWalls(){this.world.addContactMaterial(new He(this.deskMaterial,this.diceMaterial,{friction:.01,restitution:.5,contactEquationRelaxation:3,contactEquationStiffness:1e8})),this.world.addContactMaterial(new He(this.barrierMaterial,this.diceMaterial,{friction:.01,restitution:1,contactEquationRelaxation:3,contactEquationStiffness:1e8})),this.world.addContactMaterial(new He(this.diceMaterial,this.diceMaterial,{friction:.1,restitution:.5,contactEquationRelaxation:3,contactEquationStiffness:1e8})),this.world.addBody(new i1({allowSleep:!1,mass:0,shape:new t4,material:this.deskMaterial}));let e=new i1({allowSleep:!1,mass:0,shape:new t4,material:this.barrierMaterial});e.quaternion.setFromAxisAngle(new y(1,0,0),Math.PI/2),e.position.set(0,this.HEIGHT*.93,0),this.world.addBody(e),e=new i1({allowSleep:!1,mass:0,shape:new t4,material:this.barrierMaterial}),e.quaternion.setFromAxisAngle(new y(1,0,0),-Math.PI/2),e.position.set(0,-this.HEIGHT*.93,0),this.world.addBody(e),e=new i1({allowSleep:!1,mass:0,shape:new t4,material:this.barrierMaterial}),e.quaternion.setFromAxisAngle(new y(0,1,0),-Math.PI/2),e.position.set(this.WIDTH*.93,0,0),this.world.addBody(e),e=new i1({allowSleep:!1,mass:0,shape:new t4,material:this.barrierMaterial}),e.quaternion.setFromAxisAngle(new y(0,1,0),Math.PI/2),e.position.set(-this.WIDTH*.93,0,0),this.world.addBody(e)}getPlane(){return new i1({type:i1.STATIC,shape:new t4})}},Ao=class extends Xt.Component{constructor(e,t,i){super();this.width=e;this.height=t;this.plugin=i;this.dice={};this.buildDice()}get colors(){return{diceColor:this.plugin.data.diceColor,textColor:this.plugin.data.textColor}}updateColors(){this.dispose(),this.buildDice()}onunload(){this.dispose()}disposeChildren(...e){e.forEach(t=>{"dispose"in t&&t.dispose(),t.children&&this.disposeChildren(...t.children)})}dispose(){for(let e of Object.values(this.dice))this.disposeChildren(e.geometry.children)}getDiceForRoller(e,t){let i=[];switch(e.faces.max){case 4:{i.push(...new Array(e.rolls).fill(0).map(a=>new Mi(this.width,this.height,this.clone("d4"),t)));break}case 1:case 6:{i.push(...new Array(e.rolls).fill(0).map(a=>new xi(this.width,this.height,e.fudge?this.clone("fudge"):this.clone("d6"),t)));break}case 8:{i.push(...new Array(e.rolls).fill(0).map(a=>new gi(this.width,this.height,this.clone("d8"),t)));break}case 10:{i.push(...new Array(e.rolls).fill(0).map(a=>new D4(this.width,this.height,this.clone("d10"),t)));break}case 12:{i.push(...new Array(e.rolls).fill(0).map(a=>new vi(this.width,this.height,this.clone("d12"),t)));break}case 20:{i.push(...new Array(e.rolls).fill(0).map(a=>new mi(this.width,this.height,this.clone("d20"),t)));break}case 100:{i.push(...new Array(e.rolls).fill(0).map(a=>[new D4(this.width,this.height,this.clone("d100"),t,!0),new D4(this.width,this.height,this.clone("d10"),t,!0)]).flat());break}}return i}getDice(e,t){let i=new Map;for(let a of e.dynamic){let r=this.getDiceForRoller(a,t);r.length&&i.set(a,r)}return i}clone(e){if(!(e in this.dice))throw new Error("That dice type does not exist!");return this.dice[e].clone()}buildDice(){this.dice.d100=new ti(this.width,this.height,this.colors).create(),this.dice.d20=new J3(this.width,this.height,this.colors).create(),this.dice.d12=new Q3(this.width,this.height,this.colors).create(),this.dice.d10=new ei(this.width,this.height,this.colors).create(),this.dice.d8=new ii(this.width,this.height,this.colors).create(),this.dice.d6=new ai(this.width,this.height,this.colors).create(),this.dice.d4=new ni(this.width,this.height,this.colors).create(),this.dice.fudge=new ri(this.width,this.height,this.colors).create(),this.dice.boost=new di(this.width,this.height,this.colors).create(),this.dice.ability=new ui(this.width,this.height,this.colors).create(),this.dice.difficulty=new hi(this.width,this.height,this.colors).create(),this.dice.challenge=new ci(this.width,this.height,this.colors).create(),this.dice.proficiency=new oi(this.width,this.height,this.colors).create(),this.dice.setback=new pi(this.width,this.height,this.colors).create()}};var _o=w2(So());var Hi=class{constructor(e){this.table=e}parse(e){let t=e.length,i=this.table,a=[],r=[],s=0;for(;s<t;){let o=e[s++];switch(o.value){case"(":r.unshift(o);break;case")":for(e[s]&&e[s].type=="dice"&&/^d/.test(e[s].value)&&(e[s].parenedDice=!0);r.length&&(o=r.shift(),o.value!=="(");)a.push(o);if(o.value!=="(")throw new Error("Mismatched parentheses.");break;default:if(i.hasOwnProperty(o.value)){for(;r.length;){let c=r[0];if(c.value==="(")break;let l=i[o.value],u=l.precedence,f=i[c.value].precedence;if(u>f||u===f&&l.associativity==="right")break;a.push(r.shift())}r.unshift(o)}else a.push(o)}}for(;r.length;){let o=r.shift();if(o.value!=="(")a.push(o);else throw new Error("Mismatched parentheses.")}return a}};var ih=/(?:\d+[Dd])?#(?:[\p{Letter}\p{Emoji_Presentation}\w/-]+)(?:\|(?:[+-]))?(?:\|(?:[^+-]+))?/u,ah=/(?:\d+[Dd])?#(?:[\p{Letter}\p{Emoji_Presentation}\w/-]+)(?:\|(?:[+-]))?\|link/u,rh=/(?:.*)?(?:\[.*\]\(|\[\[)(?:.+?)#?\^(?:.+?)(?:\)|\]\])\|?(?:.+)?/u,nh=/(?:\d+[Dd])?(?:\[.*\]\(|\[\[)(?:.+)(?:\)|\]\])\|?(?:.+)?/u,sh=/(?:\d+[Dd])?(?:\[.*\]\(|\[\[)(?:.+)(?:\)|\]\])\|line/u,oh=/[\(\^\+\-\*\/\)]/u,ch=/(?:\d+|\b)[Dd](?:\[?(?:-?\d+[ \t]?,)?[ \t]?(?:-?\d+|%|F)\]?|\b)/u,lh=/(?:=|=!|<|>|<=|>=|=<|=>|-=|=-)\d+/u,g0=class{constructor(e){this.plugin=e;this.lexer=_o.compile({WS:[{match:/[ \t]+/u},{match:/[{}]+/u}],table:rh,line:sh,section:nh,link:ah,tag:ih,condition:lh,kl:{match:/kl\d*/u,value:this.clampInfinite},kh:[{match:/kh\d*/u,value:this.clampInfinite},{match:/k\d*/u,value:this.clampInfinite}],dh:{match:/dh\d*/u,value:this.clampInfinite},dl:[{match:/dl\d*/u,value:this.clampInfinite}],"!!":{match:/!!(?:i|\d+)?/u,value:this.clampInfinite},"!":{match:/!(?:i|\d+)?/u,value:this.clampInfinite},r:{match:/r(?:i|\d+)?/u,value:this.clampInfinite},stunt:/1[Dd]S/u,"%":/\d+[Dd]\d+%/u,dice:[{match:ch,value:e=>{let{roll:t=this.plugin.data.defaultRoll,faces:i=this.plugin.data.defaultFace}=e.match(/(?<roll>\d+)?[Dd](?<faces>\[?(?:-?\d+[ \t]?,)?[ \t]?(?:-?\d+|%|F)\]?)?/).groups;return`${t}d${i}`}},{match:/\d+/u},{match:/\b[A-Za-z][A-Za-z0-9_]+\b/u,value:e=>this.plugin.inline.has(e)?`${this.plugin.inline.get(e)}`:e}],sort:[{match:/s(?:a|d)*/u,value:e=>e=="s"||e=="sa"?"sa":"sd"}],math:oh});let t={precedence:3,associativity:"right"},i={precedence:2,associativity:"left"},a={precedence:1,associativity:"left"};this.parser=new Hi({"+":a,"-":a,"*":i,"/":i,"^":t})}clampInfinite(e){return/i$/.test(e)?"100":e.replace(/^\D+/g,"")}parse(e){let t=Array.from(this.lexer.reset(e));return this.lexer.reset(),this.parser.parse(this.transform(t))}transform(e){e=e.filter(i=>i.type!="WS");let t=[];for(let i of e)if(i.type=="condition"&&t.length>0){let a=t[t.length-1];a.conditions||(a.conditions=[]);let[r,s,o]=i.value.match(/(?<operator>=|=!|<|>|<=|>=|=<|=>|\-=|=\-)(?<comparer>\d+)/)??[];a.conditions.push({operator:s,comparer:Number(o),value:i.value})}else t.push(i);return t}getTypeFromLexemes(e){return e.some(({type:t})=>t==="table")?"table":e.some(({type:t})=>t==="section")?"section":e.some(({type:t})=>t==="tag")?"tag":e.some(({type:t})=>t==="link")?"link":e.some(({type:t})=>t==="line")?"line":"dice"}};var Se=w2(require("@codemirror/view")),Eo=w2(require("@codemirror/language")),mt=w2(require("obsidian"));function uh(n,e,t){for(let i of n.ranges)if(i.from<=t&&i.to>=e)return!0;return!1}function Lo(n,e){let t=app.workspace.getActiveFile();if(!t)return;let i=[],a=n.state.selection,r=new RegExp(".*?_?inline-code_?.*");for(let{from:s,to:o}of n.visibleRanges)(0,Eo.syntaxTree)(n.state).iterate({from:s,to:o,enter:({node:c})=>{let l=c.type;if(l.name.includes("formatting")||!r.test(l.name))return;let u=c.from,f=c.to;if(uh(a,u,f+1))return;let h=n.state.doc.sliceString(u,f).trim();if(/^dice-mod:\s*([\s\S]+)\s*?/.test(h)){let[,g]=h.match(/dice-mod:\s*([\s\S]+)\s*?/),x=app.workspace.getActiveFile(),p=e.getRollerSync(g,x.path);p.roll().then(d=>{let A=e.data.displayFormulaForMod?`${p.inlineText} **${p.replacer}**`:`${p.replacer}`,b={from:u-1,to:f+1,insert:A},C=n.state.update({changes:b});n.dispatch(C)});return}if(!/^dice(?:\+|\-)?:\s*([\s\S]+)\s*?/.test(h))return;let[,m]=h.match(/^dice(?:\+|\-)?:\s*([\s\S]+)\s*?/),v=e.getRollerSync(m,t.path);i.push(Se.Decoration.replace({widget:new Do(h,v,n),inclusive:!1,block:!1}).range(u-1,f+1))}});return Se.Decoration.set(i,!0)}var Do=class extends Se.WidgetType{constructor(e,t,i){super();this.rawQuery=e;this.roller=t;this.view=i}eq(e){return e.rawQuery===this.rawQuery}toDOM(e){return this.roller.roll(),this.roller.containerEl}ignoreEvent(e){if(e.type==="mousedown"){let t=this.view.posAtCoords({x:e.x,y:e.y});if(e.shiftKey){if(t){let{editor:i}=this.view.state.field(mt.editorEditorField).state.field(mt.editorViewField);i.setCursor(i.offsetToPos(t))}return!1}}return!0}};function To(n){return Se.ViewPlugin.fromClass(class{constructor(e){this.decorations=Lo(e,n)??Se.Decoration.none}update(e){if(!e.state.field(mt.editorLivePreviewField)){this.decorations=Se.Decoration.none;return}(e.docChanged||e.viewportChanged||e.selectionSet)&&(this.decorations=Lo(e.view,n)??Se.Decoration.none)}},{decorations:e=>e.decorations})}String.prototype.matchAll=String.prototype.matchAll||function*(e){let t=e.global?e.flags:e.flags+"g",i=new RegExp(e,t),a;for(;a=i.exec(this);)yield a};var h6={returnAllTags:!0,rollLinksForTags:!1,copyContentButton:!0,customFormulas:[],displayFormulaForMod:!0,displayResultsInline:!1,displayFormulaAfter:!1,displayLookupRoll:!0,formulas:{},persistResults:!1,results:{},defaultRoll:1,defaultFace:100,renderer:!1,renderAllDice:!1,renderTime:2e3,diceColor:"#202020",textColor:"#ffffff",showLeafOnStartup:!0,showDice:!0,round:pe.None},Ni=class extends e2.Plugin{constructor(){super(...arguments);this.fileMap=new Map;this.inline=new Map;this.operators={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"^":(e,t)=>Math.pow(e,t)};this.parser=new g0(this);this.persistingFiles=new Set}async onload(){console.log("DiceRoller plugin loaded"),this.data=Object.assign({},h6,await this.loadData()),this.renderer=new Zt(this),this.addSettingTab(new u6(this.app,this)),this.registerView(M4,i=>new Je(this,i)),this.app.workspace.onLayoutReady(()=>this.addDiceView(!0)),this.registerEvent(this.app.workspace.on("dice-roller:update-colors",()=>{this.renderer.factory.updateColors()})),this.registerEvent(this.app.workspace.on("dice-roller:render-dice",async i=>{let a=await this.getRoller(i,"external");if(!(a instanceof S2)){new e2.Notice("The Dice View only supports dice rolls.");return}if(await a.roll(),!a.dice.length){new e2.Notice("Invalid formula.");return}try{this.renderRoll(a)}catch(r){new e2.Notice("There was an error rendering the roll."),console.error(r)}this.app.workspace.trigger("dice-roller:rendered-result",a.result)})),this.addCommand({id:"open-view",name:"Open Dice View",callback:()=>{this.view?this.app.workspace.revealLeaf(this.view.leaf):this.addDiceView()}}),this.addCommand({id:"reroll",name:"Re-roll Dice",checkCallback:i=>{let a=this.app.workspace.getActiveViewOfType(e2.MarkdownView);if(a&&a.getMode()==="preview"&&this.fileMap.has(a.file))return i||this.fileMap.get(a.file).forEach(s=>{s.roll()}),!0}});let e=T0(Pi).html[0];(0,e2.addIcon)(Y2,e);let t=T0(Ii).html[0];(0,e2.addIcon)(Te,t),this.registerMarkdownPostProcessor(this.postprocessor.bind(this)),this.registerEditorExtension([To(this)]),this.app.workspace.onLayoutReady(async()=>{await this.registerDataviewInlineFields()})}async postprocessor(e,t){let i=e.querySelectorAll("code");if(!i.length)return;let a=t.sourcePath,r=t.getSectionInfo(e),s=t.getSectionInfo(e)?.lineStart,o=this.app.vault.getAbstractFileByPath(t.sourcePath);if((!o||!(o instanceof e2.TFile))&&a!="STATBLOCK_RENDERER")return;let c={},l,u=!1,f=[];for(let h=0;h<i.length;h++){let m=i.item(h);if(o&&o instanceof e2.TFile&&/^dice\-mod:\s*([\s\S]+)\s*?/.test(m.innerText)&&r)try{u||(l=(await this.app.vault.cachedRead(o)).split(`
`),u=!0);let[v,g]=m.innerText.match(/^dice\-mod:\s*([\s\S]+)\s*?/),x=this.data.displayFormulaForMod;g.includes("|noform")&&(x=!1),g.includes("|form")&&(x=!0),g=g.replace("|noform","").replace("|form","");let p=await this.getRoller(g,t.sourcePath);f.push(new Promise((d,A)=>{p.on("new-result",async()=>{let b=l.slice(r.lineStart,r.lineEnd+1),C=p.replacer;if(!C){new e2.Notice("Dice Roller: There was an issue modifying the file.");return}let E=x?`${p.inlineText} ${C}`:`${C}`;b=b.join(`
`).replace(`\`${v}\``,E).split(`
`),l.splice(r.lineStart,r.lineEnd-r.lineStart+1,...b),d()})})),await p.roll();continue}catch(v){console.error(v)}if(!!/^dice(?:\+|\-|\-mod)?:\s*([\s\S]+)\s*?/.test(m.innerText))try{let[,v]=m.innerText.match(/^dice(?:\+|\-|\-mod)?:\s*([\s\S]+)\s*?/),g=await this.getRoller(v,t.sourcePath),x=this.data.results?.[a]?.[s]?.[h]??null;(this.data.persistResults&&!/dice\-/.test(m.innerText)||/dice\+/.test(m.innerText))&&(this.persistingFiles.add(t.sourcePath),c[h]=g,g.save=!0);let p=this.data.renderAllDice;v.includes("|render")&&(p=!0),v.includes("|norender")&&(p=!1);let d=async()=>{await g.roll(),g.save&&x&&await g.applyResult(x),g instanceof S2&&(g.shouldRender=p),m.replaceWith(g.containerEl)};if(g.loaded?await d():g.on("loaded",async()=>{await d()}),!o||!(o instanceof e2.TFile))continue;this.fileMap.has(o)||this.fileMap.set(o,[]),this.fileMap.set(o,[...this.fileMap.get(o),g]);let A=this.app.workspace.getActiveViewOfType(e2.MarkdownView);if(A&&this.fileMap.has(o)&&this.fileMap.get(o).length===1){let b=this,C=H0(A,{onUnloadFile:function(E){return async function(T){return T==o&&(b.fileMap.delete(o),C()),await E.call(this,T)}}});A.register(C),A.register(()=>this.fileMap.delete(o))}}catch(v){console.error(v),new e2.Notice(`There was an error parsing the dice string: ${m.innerText}.
${v}`,5e3);continue}}if(!(!o||!(o instanceof e2.TFile))&&(u&&f.length&&(await Promise.all(f),await this.app.vault.modify(o,l.join(`
`))),a in this.data.results&&(this.data.results[a][s]={}),Object.entries(c).length)){let h=this.app.workspace.getActiveViewOfType(e2.MarkdownView);if(h){let m=this,v=H0(h,{onUnloadFile:function(g){return async function(x){if(x=o){m.persistingFiles.has(a)&&(m.persistingFiles.delete(a),m.data.results[a]={});for(let p in c){let d=c[p],A=t.getSectionInfo(e)?.lineStart;if(A==null)continue;let b={[A]:{...m.data.results[a]?.[A]??{},[p]:d.toResult()}};m.data.results[a]={...m.data.results[a]??{},...b},await m.saveSettings()}}return v(),await g.call(this,x)}}});h.register(v),h.register(async()=>{this.persistingFiles.has(a)&&(this.persistingFiles.delete(a),this.data.results[a]={});for(let g in c){let x=c[g],p=t.getSectionInfo(e)?.lineStart;if(p==null)continue;let d={[p]:{...this.data.results[a]?.[p]??{},[g]:x.toResult()}};this.data.results[a]={...this.data.results[a]??{},...d},await this.saveSettings()}})}}}get canUseDataview(){return this.app.plugins.getPlugin("dataview")!=null}get dataview(){return this.app.plugins.getPlugin("dataview")}get dataviewAPI(){return(0,Ho.getAPI)()}async dataviewReady(){return new Promise(e=>{this.canUseDataview||e(!1),this.dataview.api&&e(!0),this.registerEvent(this.app.metadataCache.on("dataview:api-ready",()=>{e(!0)}))})}get view(){let e=this.app.workspace.getLeavesOfType(M4),t=e.length?e[0]:null;if(t&&t.view&&t.view instanceof Je)return t.view}async getArrayRoller(e,t=1){let i=new F0(this,e,t);return await i.roll(),i}async addDiceView(e=!1){e&&!this.data.showLeafOnStartup||this.app.workspace.getLeavesOfType(M4).length||await this.app.workspace.getRightLeaf(!1).setViewState({type:M4})}async registerDataviewInlineFields(){if(!this.canUseDataview)return;await this.dataviewReady(),this.dataview.index.pages.forEach(({fields:t})=>{for(let[i,a]of t)typeof a!="number"||Number.isNaN(a)||a==null||this.inline.set(i,a)}),this.registerEvent(this.app.metadataCache.on("dataview:metadata-change",(t,i)=>{if(t==="update"){let a=this.dataview.api.page(i.path);if(!a)return;for(let r in a){let s=a[r];typeof s!="number"||Number.isNaN(s)||s==null||this.inline.set(r,s)}}}))}async renderRoll(e){if(!(e instanceof S2)||!e?.dice?.length){new e2.Notice(`This dice roll can't be rendered: ${e.original}`);return}this.addChild(this.renderer),this.renderer.setDice(e),await this.renderer.start(),e.recalculate()}async parseDice(e,t){let i=await this.getRoller(e,t);return{result:await i.roll(),roller:i}}parseDiceSync(e,t){let i=this.getRollerSync(e,t);if(i instanceof S2)return{result:i.result,roller:i}}clearEmpties(e){for(var t in e)!e[t]||typeof e[t]!="object"||(this.clearEmpties(e[t]),Object.keys(e[t]).length===0&&delete e[t])}async saveSettings(){this.clearEmpties(this.data.results),await this.saveData(this.data)}get dataview_regex(){let e=Array.from(this.inline.keys());return e.length?new RegExp(`(${e.join("|")})`,"g"):null}async getRoller(e,t="",i=this.data.showDice){e=e.replace(/\\\|/g,"|");let a=e.includes("|nodice")?!1:i,r=this.data.displayResultsInline,s=this.data.displayFormulaAfter,o=f2.Roll,c="",l=/\|text\((.*)\)/;if(e.includes("|form")&&(r=!0),e.includes("|noform")&&(r=!1),e.includes("|avg")&&(o=f2.Average),e.includes("|none")&&(o=f2.None),e.includes("|text(")){let[,h]=e.match(l)??[null,""];c=h}e.includes("|paren")&&(s=!0),e.includes("|noparen")&&(s=!1),e=(0,Vi.decode)(e.replace("|nodice","").replace("|render","").replace("|norender","").replace("|noform","").replace("|form","").replace("|noparen","").replace("|paren","").replace("|avg","").replace("|none","").replace(l,"")),e in this.data.formulas&&(e=this.data.formulas[e]);let u=this.parse(e);switch(this.getTypeFromLexemes(u)){case"dice":{let h=new S2(this,e,u,a,c,o,s);return h.showFormula=r,h}case"table":{let h=new I4(this,e,u[0],t,a);return await h.init,h}case"section":return new Ct(this,e,u[0],t,a);case"tag":{if(!this.canUseDataview)throw new Error("Tags are only supported with the Dataview plugin installed.");return new o6(this,e,u[0],t,a)}case"link":return new c6(this,e,u[0],t,a);case"line":return new l6(this,e,u[0],t,a)}}getRollerSync(e,t,i=this.data.showDice,a){e=e.replace(/\\\|/g,"|");let r=e.includes("|nodice")?!1:i,s=this.data.renderAllDice,o=!1,c=f2.Roll,l="",u=/\|text\((.*)\)/;if(e.includes("|render")&&(s=!0),e.includes("|norender")&&(s=!1),e.includes("|form")&&(o=!0),e.includes("|noform")&&(o=!1),e.includes("|avg")&&(c=f2.Average),e.includes("|none")&&(c=f2.None),e.includes("|text(")){let[,m]=e.match(u)??[null,""];l=m}e=(0,Vi.decode)(e.replace("|nodice","").replace("|render","").replace("|norender","").replace("|noform","").replace("|form","").replace("|avg","").replace("|none","").replace(u,"")),e in this.data.formulas&&(e=this.data.formulas[e]);let f=this.parse(e),h=this.getTypeFromLexemes(f);switch(a==null&&(a=this.data.displayFormulaAfter),h){case"dice":{let m=new S2(this,e,f,r,l,c,a);return m.shouldRender=s,m.showFormula=o,m}case"table":{let m=new I4(this,e,f[0],t,r);return m.init,m}case"section":return new Ct(this,e,f[0],t,r);case"tag":{if(!this.canUseDataview)throw new Error("Tags are only supported with the Dataview plugin installed.");return new o6(this,e,f[0],t,r)}case"link":return new c6(this,e,f[0],t,r);case"line":return new l6(this,e,f[0],t,r)}}getTypeFromLexemes(e){return e.some(({type:t})=>t==="table")?"table":e.some(({type:t})=>t==="section")?"section":e.some(({type:t})=>t==="tag")?"tag":e.some(({type:t})=>t==="link")?"link":e.some(({type:t})=>t==="line")?"line":"dice"}onunload(){console.log("DiceRoller unloaded"),this.app.workspace.getLeavesOfType(M4).forEach(e=>e.detach()),"__THREE__"in window&&delete window.__THREE__,this.renderer.unload(),this.app.workspace.trigger("dice-roller:unload")}parse(e){return this.parser.parse(e)}};
/*!
* Font Awesome Free 5.15.3 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
*/
/*!
* Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
*/
/*! https://mths.be/he v1.2.0 by @mathias | MIT license */