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.

3107 lines
881 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 v0=Object.create;var No=Object.defineProperty;var w0=Object.getOwnPropertyDescriptor;var b0=Object.getOwnPropertyNames;var _0=Object.getPrototypeOf,E0=Object.prototype.hasOwnProperty;var Ei=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),A0=(r,e)=>{for(var t in e)No(r,t,{get:e[t],enumerable:!0})},$d=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of b0(e))!E0.call(r,n)&&n!==t&&No(r,n,{get:()=>e[n],enumerable:!(i=w0(e,n))||i.enumerable});return r};var on=(r,e,t)=>(t=r!=null?v0(_0(r)):{},$d(e||!r||!r.__esModule?No(t,"default",{value:r,enumerable:!0}):t,r)),S0=r=>$d(No({},"__esModule",{value:!0}),r);var ag=Ei(Qi=>{"use strict";var UE=Qi&&Qi.__values||function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Qi,"__esModule",{value:!0});Qi.getWordsByCategory=Qi.wordList=void 0;Qi.wordList={noun:[{word:"accountant",categories:["profession"]},{word:"ability",categories:["thing"]},{word:"accident",categories:["thing"]},{word:"account",categories:["thing"]},{word:"action",categories:["thing"]},{word:"activity",categories:["thing"]},{word:"actor",categories:["profession"]},{word:"ad",categories:["media"]},{word:"addition",categories:["thing"]},{word:"address",categories:["thing"]},{word:"adult",categories:["people"]},{word:"advantage",categories:["thing"]},{word:"advertisement",categories:["media"]},{word:"afternoon",categories:["time"]},{word:"agency",categories:["thing"]},{word:"agent",categories:["people"]},{word:"air",categories:["thing"]},{word:"airline",categories:["transportation"]},{word:"airplane",categories:["transportation"]},{word:"airport",categories:["transportation","place"]},{word:"alarm",categories:["thing"]},{word:"alligator",categories:["animals"]},{word:"ambulance",categories:["health"]},{word:"analyst",categories:["profession"]},{word:"angle",categories:["thing"]},{word:"animal",categories:["animals"]},{word:"answer",categories:["thing"]},{word:"apartment",categories:["place"]},{word:"apple",categories:["food"]},{word:"application",categories:["thing"]},{word:"appointment",categories:["thing"]},{word:"architect",categories:["profession"]},{word:"argument",categories:["thing"]},{word:"area",categories:["thing"]},{word:"arm",categories:["thing"]},{word:"army",categories:["thing"]},{word:"art",categories:["thing"]},{word:"article",categories:["thing"]},{word:"artist",categories:["profession"]},{word:"australia",categories:["place"]},{word:"author",categories:["profession"]},{word:"autumn",categories:["time"]},{word:"baby",categories:["people","family"]},{word:"baker",categories:["profession"]},{word:"balloon",categories:["thing"]},{word:"banana",categories:["food"]},{word:"barista",categories:["profession"]},{word:"battery",categories:["thing"]},{word:"beach",categories:["place"]},{word:"bear",categories:["animals"]},{word:"beard",categories:["thing"]},{word:"bed",categories:["thing"]},{word:"belgium",categories:["place"]},{word:"bird",categories:["animals"]},{word:"bit",categories:["thing","technology"]},{word:"book",categories:["thing","education"]},{word:"boots",categories:["thing"]},{word:"boy",categories:["people"]},{word:"branch",categories:["thing"]},{word:"breakfast",categories:["thing"]},{word:"brother",categories:["family"]},{word:"businessperson",categories:["people","business"]},{word:"butcher",categories:["profession"]},{word:"byte",categories:["thing","technology"]},{word:"camera",categories:["thing"]},{word:"candle",categories:["thing"]},{word:"car",categories:["transportation"]},{word:"caravan",categories:["transportation"]},{word:"carpenter",categories:["profession"]},{word:"carpet",categories:["thing"]},{word:"cartoon",categories:["media"]},{word:"cat",categories:["animals"]},{word:"chef",categories:["profession"]},{word:"child",categories:["people","family"]},{word:"china",categories:["place"]},{word:"church",categories:["religion"]},{word:"city",categories:["place"]},{word:"coat",categories:["thing"]},{word:"coffeeshop",categories:["place"]},{word:"computer",categories:["thing","technology"]},{word:"continent",categories:["place"]},{word:"controller",categories:["thing","technology"]},{word:"country",categories:["place"]},{word:"cpu",categories:["thing","technology"]},{word:"crayon",categories:["thing"]},{word:"cricket",categories:["animals"]},{word:"crowd",categories:["people"]},{word:"daughter",categories:["family"]},{word:"dawn",categories:["time"]},{word:"daybreak",categories:["time"]},{word:"death",categories:["thing"]},{word:"denmark",categories:["place"]},{word:"dentist",categories:["profession"]},{word:"diamond",categories:["thing"]},{word:"dinner",categories:["food"]},{word:"disease",categories:["thing"]},{word:"doctor",categories:["profession"]},{word:"dog",categories:["animals"]},{word:"dream",categories:["thing"]},{word:"dress",categories:["thing"]},{word:"dusk",categories:["time"]},{word:"easter",categories:["religion"]},{word:"egg",categories:["food"]},{word:"eggplant",categories:["food"]},{word:"egypt",categories:["place"]},{word:"electrician",categories:["profession"]},{word:"elephant",categories:["animals"]},{word:"energy",categories:["thing"]},{word:"engine",categories:["transportation"]},{word:"engineer",categories:["profession"]},{word:"england",categories:["place"]},{word:"eve",categories:["time"]},{word:"evening",categories:["time"]},{word:"eventide",categories:["time"]},{word:"exabyte",categories:["thing","technology"]},{word:"eye",categories:["thing"]},{word:"fall",categories:["time"]},{word:"family",categories:["family"]},{word:"farmer",categories:["profession"]},{word:"father",categories:["people","family"]},{word:"finland",categories:["place"]},{word:"fireman",categories:["profession"]},{word:"fish",categories:["animals"]},{word:"flag",categories:["thing"]},{word:"florist",categories:["profession"]},{word:"flower",categories:["thing"]},{word:"football",categories:["sports"]},{word:"forest",categories:["place"]},{word:"fountain",categories:["thing"]},{word:"france",categories:["place"]},{word:"furniture",categories:["thing"]},{word:"garage",categories:["place"]},{word:"garden",categories:["food"]},{word:"gas",categories:["transportation"]},{word:"ghost",categories:["thing"]},{word:"gigabyte",categories:["thing","technology"]},{word:"girl",categories:["people"]},{word:"glass",categories:["thing"]},{word:"gold",categories:["thing"]},{word:"gpu",categories:["thing","technology"]},{word:"grandmother",categories:["people","family"]},{word:"grass",categories:["thing"]},{word:"greece",categories:["place"]},{word:"guitar",categories:["thing"]},{word:"hair",categories:["thing"]},{word:"hairdresser",categories:["profession"]},{word:"hamburger",categories:["food"]},{word:"helicopter",categories:["transportation"]},{word:"helmet",categories:["thing"]},{word:"holiday",categories:["thing"]},{word:"honey",categories:["food"]},{word:"horse",categories:["animals"]},{word:"hospital",categories:["place"]},{word:"house",categories:["place"]},{word:"hydrogen",categories:["science"]},{word:"ice",categories:["science"]},{word:"insect",categories:["animals"]},{word:"insurance",categories:["thing"]},{word:"intern",categories:["profession"]},{word:"iron",categories:["science"]},{word:"island",categories:["place"]},{word:"jackal",categories:["animals"]},{word:"jelly",categories:["food"]},{word:"jewellery",categories:["thing"]},{word:"jordan",categories:["place"]},{word:"journalist",categories:["profession"]},{word:"joystick",categories:["thing","technology"]},{word:"judge",categories:["profession"]},{word:"juice",categories:["food"]},{word:"kangaroo",categories:["animals"]},{word:"keyboard",categories:["thing","technology"]},{word:"kilobyte",categories:["thing","technology"]},{word:"king",categories:["people"]},{word:"kitchen",categories:["place"]},{word:"kite",categories:["thing"]},{word:"knife",categories:["thing"]},{word:"lamp",categories:["thing"]},{word:"laptop",categories:["thing","technology"]},{word:"lawyer",categories:["profession"]},{word:"leather",categories:["thing"]},{word:"librarian",categories:["profession"]},{word:"library",categories:["place"]},{word:"lifeguard",categories:["profession"]},{word:"lighter",categories:["thing"]},{word:"lion",categories:["animals"]},{word:"lizard",categories:["animals"]},{word:"lock",categories:["thing"]},{word:"london",categories:["place"]},{word:"lunch",categories:["food"]},{word:"machine",categories:["science"]},{word:"magazine",categories:["media"]},{word:"magician",categories:["people"]},{word:"man",categories:["people"]},{word:"manchester",categories:["place"]},{word:"market",categories:["place"]},{word:"match",categories:["thing"]},{word:"mechanic",categories:["profession"]},{word:"megabyte",categories:["thing","technology"]},{word:"memory",categories:["thing","technology"]},{word:"microphone",categories:["thing"]},{word:"midnight",categories:["time"]},{word:"minister",categories:["people","religion"]},{word:"monitor",categories:["thing","technology"]},{word:"monkey",categories:["animals"]},{word:"morn",categories:["time"]},{word:"morning",categories:["time"]},{word:"mother",categories:["people","family"]},{word:"motherboard",categories:["thing","technology"]},{word:"motorcycle",categories:["transportation"]},{word:"mouse",categories:["thing","technology","animals"]},{word:"musician",categories:["profession"]},{word:"nail",categories:["thing"]},{word:"napkin",categories:["thing"]},{word:"needle",categories:["thing"]},{word:"nest",categories:["thing"]},{word:"nigeria",categories:["place"]},{word:"night",categories:["time"]},{word:"nightfall",categories:["time"]},{word:"noon",categories:["time"]},{word:"notebook",categories:["thing"]},{word:"nurse",categories:["profession"]},{word:"ocean",categories:["place"]},{word:"oil",categories:["thing"]},{word:"optician",categories:["profession"]},{word:"orange",categories:["food"]},{word:"oxygen",categories:["science"]},{word:"oyster",categories:["animals"]},{word:"pager",categories:["thing","technology"]},{word:"painter",categories:["profession"]},{word:"painting",categories:["media"]},{word:"park",categories:["place"]},{word:"parrot",categories:["animals"]},{word:"pencil",categories:["thing","education"]},{word:"petabyte",categories:["thing","technology"]},{word:"pharmacist",categories:["profession"]},{word:"photographer",categories:["profession"]},{word:"piano",categories:["thing"]},{word:"pillow",categories:["thing"]},{word:"pilot",categories:["profession"]},{word:"pizza",categories:["food"]},{word:"planet",categories:["science"]},{word:"plastic",categories:["thing"]},{word:"plumber",categories:["profession"]},{word:"policeman",categories:["profession"]},{word:"portugal",categories:["place"]},{word:"postman",categories:["profession"]},{word:"potato",categories:["food"]},{word:"printer",categories:["thing","technology"]},{word:"processor",categories:["thing","technology"]},{word:"psychiatrist",categories:["profession"]},{word:"queen",categories:["people"]},{word:"quill",categories:["thing"]},{word:"rain",categories:["thing"]},{word:"rainbow",categories:["science"]},{word:"raincoat",categories:["thing"]},{word:"ram",categories:["thing","technology"]},{word:"receptionist",categories:["profession"]},{word:"refrigerator",categories:["food"]},{word:"restaurant",categories:["place"]},{word:"river",categories:["thing"]},{word:"rocket",categories:["science"]},{word:"room",categories:["place"]},{word:"rose",categories:["thing"]},{word:"russia",categories:["place"]},{word:"salesclerk",categories:["people","business"]},{word:"salesmen",categories:["profession"]},{word:"sandwich",categories:["food"]},{word:"school",categories:["education"]},{word:"scientist",categories:["profession"]},{word:"scooter",categories:["transportation"]},{word:"secretary",categories:["profession"]},{word:"shampoo",categories:["thing"]},{word:"shoe",categories:["thing"]},{word:"smartphone",categories:["thing","technology"]},{word:"soccer",categories:["sports"]},{word:"solstice",categories:["time"]},{word:"spoon",categories:["thing"]},{word:"spring",categories:["time"]},{word:"state",categories:["place"]},{word:"stone",categories:["thing"]},{word:"student",categories:["people","education"]},{word:"sugar",categories:["food"]},{word:"summer",categories:["time"]},{word:"sundown",categories:["time"]},{word:"sunset",categories:["time"]},{word:"sweden",categories:["place"]},{word:"table",categories:["thing"]},{word:"tailor",categories:["profession"]},{word:"teacher",categories:["people","education","profession"]},{word:"teenager",categories:["people","family"]},{word:"telephone",categories:["thing"]},{word:"television",categories:["media"]},{word:"tent",categories:["thing"]},{word:"terabyte",categories:["thing","technology"]},{word:"thailand",categories:["place"]},{word:"tiger",categories:["animals"]},{word:"toddler",categories:["people","family"]},{word:"tomato",categories:["food"]},{word:"toothbrush",categories:["thing"]},{word:"traffic",categories:["thing"]},{word:"train",categories:["transportation"]},{word:"translator",categories:["profession"]},{word:"truck",categories:["thing","transportation"]},{word:"twilight",categories:["time"]},{word:"uganda",categories:["place"]},{word:"umbrella",categories:["thing"]},{word:"van",categories:["transportation"]},{word:"vase",categories:["thing"]},{word:"vegetable",categories:["food"]},{word:"vr",categories:["thing","technology"]},{word:"vulture",categories:["animals"]},{word:"waiter",categories:["profession"]},{word:"waitress",categories:["profession"]},{word:"wall",categories:["thing"]},{word:"whale",categories:["animals"]},{word:"window",categories:["thing"]},{word:"winter",categories:["time"]},{word:"wire",categories:["thing"]},{word:"wolf",categories:["animals"]},{word:"woman",categories:["people"]},{word:"xylophone",categories:["thing"]},{word:"yacht",categories:["transportation"]},{word:"yak",categories:["animals"]},{word:"yottabyte",categories:["thing","technology"]},{word:"zebra",categories:["animals"]},{word:"zettabyte",categories:["thing","technology"]},{word:"zoo",categories:["animals"]}],adjective:[{word:"abandoned",categories:["condition"]},{word:"abiding",categories:["personality"]},{word:"able",categories:["condition"]},{word:"abrasive",categories:["condition","personality"]},{word:"abnormal",categories:["condition"]},{word:"absurd",categories:["condition"]},{word:"abundant",categories:["quantity"]},{word:"acceptable",categories:["condition"]},{word:"acidic",categories:["taste"]},{word:"acoustic",categories:["sounds"]},{word:"acrid",categories:["condition"]},{word:"adamant",categories:["personality"]},{word:"adorable",categories:["personality"]},{word:"adventurous",categories:["personality"]},{word:"aggressive",categories:["personality"]},{word:"agitated",categories:["personality"]},{word:"agreeable",categories:["personality"]},{word:"alert",categories:["condition"]},{word:"alive",categories:["condition"]},{word:"aloof",categories:["personality"]},{word:"ambitious",categories:["personality"]},{word:"ancient",categories:["time"]},{word:"angry",categories:["personality"]},{word:"annoyed",categories:["personality"]},{word:"antsy",categories:["personality"]},{word:"anxious",categories:["personality"]},{word:"appalling",categories:["personality"]},{word:"appetizing",categories:["taste"]},{word:"apprehensive",categories:["personality"]},{word:"arrogant",categories:["personality"]},{word:"ashamed",categories:["personality"]},{word:"astonishing",categories:["personality"]},{word:"attractive",categories:["appearance"]},{word:"average",categories:["appearance"]},{word:"bad",categories:["condition"]},{word:"bald",categories:["appearance"]},{word:"bashful",categories:["personality"]},{word:"beautiful",categories:["appearance"]},{word:"beefy",categories:["appearance"]},{word:"belligerent",categories:["personality"]},{word:"bent",categories:["condition"]},{word:"best",categories:["condition"]},{word:"better",categories:["condition"]},{word:"bewildered",categories:["personality"]},{word:"big",categories:["size"]},{word:"billions",categories:["quantity"]},{word:"billowy",categories:["appearance"]},{word:"bitter",categories:["taste"]},{word:"black",categories:["color"]},{word:"bland",categories:["taste"]},{word:"blue",categories:["color"]},{word:"blushing",categories:["appearance"]},{word:"bored",categories:["personality"]},{word:"boring",categories:["personality"]},{word:"boundless",categories:["personality"]},{word:"brainy",categories:["personality"]},{word:"brash",categories:["personality"]},{word:"brave",categories:["personality"]},{word:"breezy",categories:["touch"]},{word:"brief",categories:["time"]},{word:"bright",categories:["appearance"]},{word:"broad",categories:["shapes"]},{word:"broken",categories:["condition"]},{word:"brown",categories:["color"]},{word:"bulky",categories:["appearance"]},{word:"bumpy",categories:["touch"]},{word:"burly",categories:["appearance"]},{word:"busy",categories:["personality"]},{word:"cagey",categories:["personality"]},{word:"calm",categories:["personality"]},{word:"callous",categories:["personality"]},{word:"careful",categories:["condition"]},{word:"chilly",categories:["touch"]},{word:"chubby",categories:["appearance"]},{word:"clean",categories:["appearance"]},{word:"clever",categories:["condition"]},{word:"clumsy",categories:["personality"]},{word:"cold",categories:["touch"]},{word:"colossal",categories:["size"]},{word:"cool",categories:["touch"]},{word:"crashing",categories:["sounds"]},{word:"creamy",categories:["taste"]},{word:"crooked",categories:["shapes"]},{word:"cuddly",categories:["touch"]},{word:"curved",categories:["shapes"]},{word:"damaged",categories:["touch"]},{word:"damp",categories:["touch"]},{word:"dazzling",categories:["appearance"]},{word:"dead",categories:["condition"]},{word:"deafening",categories:["sounds"]},{word:"deep",categories:["shapes"]},{word:"defeated",categories:["personality"]},{word:"delicious",categories:["taste"]},{word:"delightful",categories:["personality"]},{word:"dirty",categories:["touch"]},{word:"disgusting",categories:["taste"]},{word:"drab",categories:["appearance"]},{word:"dry",categories:["touch"]},{word:"eager",categories:["personality"]},{word:"early",categories:["time"]},{word:"easy",categories:["condition"]},{word:"echoing",categories:["sounds"]},{word:"elegant",categories:["appearance"]},{word:"embarrassed",categories:["personality"]},{word:"enough",categories:["quantity"]},{word:"faint",categories:["sounds"]},{word:"faithful",categories:["personality"]},{word:"famous",categories:["condition"]},{word:"fancy",categories:["appearance"]},{word:"fast",categories:["time"]},{word:"fat",categories:["size"]},{word:"few",categories:["quantity"]},{word:"fierce",categories:["personality"]},{word:"fit",categories:["appearance"]},{word:"flabby",categories:["appearance"]},{word:"flaky",categories:["touch"]},{word:"flat",categories:["shapes"]},{word:"fluffy",categories:["touch"]},{word:"freezing",categories:["touch"]},{word:"fresh",categories:["taste"]},{word:"full",categories:["quantity"]},{word:"future",categories:["time"]},{word:"gentle",categories:["personality"]},{word:"gifted",categories:["condition"]},{word:"gigantic",categories:["size"]},{word:"glamorous",categories:["appearance"]},{word:"gorgeous",categories:["appearance"]},{word:"gray",categories:["color"]},{word:"greasy",categories:["touch","taste"]},{word:"great",categories:["size"]},{word:"green",categories:["color"]},{word:"grumpy",categories:["personality"]},{word:"hallowed",categories:["condition"]},{word:"handsome",categories:["appearance"]},{word:"happy",categories:["personality"]},{word:"harsh",categories:["sounds"]},{word:"helpful",categories:["condition"]},{word:"helpless",categories:["personality"]},{word:"high",categories:["shapes"]},{word:"hissing",categories:["sounds"]},{word:"hollow",categories:["shapes"]},{word:"hot",categories:["touch","taste"]},{word:"howling",categories:["sounds"]},{word:"huge",categories:["size"]},{word:"hundreds",categories:["quantity"]},{word:"icy",categories:["touch"]},{word:"immense",categories:["size"]},{word:"important",categories:["condition"]},{word:"incalculable",categories:["quantity"]},{word:"inexpensive",categories:["condition"]},{word:"itchy",categories:["personality"]},{word:"jealous",categories:["personality"]},{word:"jolly",categories:["personality"]},{word:"juicy",categories:["taste"]},{word:"kind",categories:["personality"]},{word:"large",categories:["size"]},{word:"late",categories:["time"]},{word:"lazy",categories:["personality"]},{word:"lemon",categories:["color"]},{word:"limited",categories:["quantity"]},{word:"little",categories:["size","quantity"]},{word:"lively",categories:["personality"]},{word:"long",categories:["time","appearance"]},{word:"loose",categories:["touch"]},{word:"loud",categories:["sounds"]},{word:"low",categories:["shapes"]},{word:"magnificent",categories:["appearance"]},{word:"mammoth",categories:["size"]},{word:"mango",categories:["color"]},{word:"many",categories:["quantity"]},{word:"massive",categories:["size"]},{word:"mealy",categories:["condition"]},{word:"melodic",categories:["sounds"]},{word:"melted",categories:["touch"]},{word:"microscopic",categories:["size"]},{word:"millions",categories:["quantity"]},{word:"miniature",categories:["size"]},{word:"modern",categories:["time"]},{word:"moldy",categories:["taste"]},{word:"most",categories:["quantity"]},{word:"muscular",categories:["appearance"]},{word:"mushy",categories:["condition"]},{word:"mysterious",categories:["personality"]},{word:"narrow",categories:["shapes"]},{word:"nervous",categories:["personality"]},{word:"nice",categories:["personality"]},{word:"noisy",categories:["sounds"]},{word:"numerous",categories:["quantity"]},{word:"nutritious",categories:["taste"]},{word:"nutty",categories:["taste"]},{word:"obedient",categories:["personality"]},{word:"obnoxious",categories:["personality"]},{word:"odd",categories:["condition"]},{word:"old",categories:["time"]},{word:"orange",categories:["color"]},{word:"panicky",categories:["personality"]},{word:"petite",categories:["size"]},{word:"pitiful",categories:["personality"]},{word:"plain",categories:["appearance"]},{word:"plump",categories:["appearance"]},{word:"polite",categories:["personality"]},{word:"poor",categories:["condition"]},{word:"powerful",categories:["condition"]},{word:"prehistoric",categories:["time"]},{word:"prickly",categories:["touch"]},{word:"proud",categories:["personality"]},{word:"puny",categories:["size"]},{word:"purple",categories:["color"]},{word:"purring",categories:["sounds"]},{word:"putrid",categories:["taste"]},{word:"quaint",categories:["appearance"]},{word:"quick",categories:["time"]},{word:"quiet",categories:["sounds"]},{word:"rancid",categories:["taste"]},{word:"rapid",categories:["time"]},{word:"rapping",categories:["sounds"]},{word:"raspy",categories:["sounds"]},{word:"red",categories:["color"]},{word:"refined",categories:["shapes"]},{word:"repulsive",categories:["personality"]},{word:"rhythmic",categories:["sounds"]},{word:"rich",categories:["condition"]},{word:"ripe",categories:["taste"]},{word:"rotten",categories:["taste"]},{word:"rough",categories:["touch"]},{word:"round",categories:["shapes"]},{word:"salmon",categories:["color"]},{word:"salty",categories:["taste"]},{word:"savory",categories:["taste"]},{word:"scarce",categories:["quantity"]},{word:"scary",categories:["personality"]},{word:"scrawny",categories:["size"]},{word:"screeching",categories:["sounds"]},{word:"scruffy",categories:["appearance"]},{word:"shaggy",categories:["touch"]},{word:"shallow",categories:["shapes"]},{word:"shapely",categories:["appearance"]},{word:"sharp",categories:["touch"]},{word:"short",categories:["size","appearance","time"]},{word:"shrilling",categories:["sounds"]},{word:"shy",categories:["condition"]},{word:"silly",categories:["personality"]},{word:"skinny",categories:["appearance","shapes"]},{word:"slimy",categories:["touch"]},{word:"slow",categories:["time"]},{word:"small",categories:["size"]},{word:"some",categories:["quantity"]},{word:"sour",categories:["taste"]},{word:"sparse",categories:["quantity"]},{word:"spicy",categories:["taste"]},{word:"spoiled",categories:["taste"]},{word:"square",categories:["shapes"]},{word:"squeaking",categories:["sounds"]},{word:"stale",categories:["taste"]},{word:"steep",categories:["shapes"]},{word:"sticky",categories:["touch"]},{word:"stocky",categories:["appearance"]},{word:"straight",categories:["shapes"]},{word:"strong",categories:["touch"]},{word:"substantial",categories:["quantity"]},{word:"sweet",categories:["taste"]},{word:"swift",categories:["time"]},{word:"tall",categories:["size"]},{word:"tangy",categories:["taste"]},{word:"tart",categories:["taste"]},{word:"tasteless",categories:["taste"]},{word:"tasty",categories:["taste"]},{word:"teeny",categories:["size"]},{word:"tender",categories:["condition"]},{word:"thankful",categories:["personality"]},{word:"thoughtless",categories:["personality"]},{word:"thousands",categories:["quantity"]},{word:"thundering",categories:["sounds"]},{word:"tight",categories:["touch"]},{word:"tinkling",categories:["sounds"]},{word:"tiny",categories:["size"]},{word:"ugly",categories:["appearance"]},{word:"uneven",categories:["touch"]},{word:"unimportant",categories:["condition"]},{word:"uninterested",categories:["condition"]},{word:"unkempt",categories:["appearance"]},{word:"unsightly",categories:["appearance"]},{word:"uptight",categories:["personality"]},{word:"vast",categories:["condition"]},{word:"victorious",categories:["personality"]},{word:"wailing",categories:["sounds"]},{word:"warm",categories:["touch"]},{word:"weak",categories:["touch"]},{word:"wet",categories:["touch"]},{word:"whining",categories:["sounds"]},{word:"whispering",categories:["sounds"]},{word:"white",categories:["color"]},{word:"wide",categories:["shapes"]},{word:"witty",categories:["personality"]},{word:"wonderful",categories:["personality"]},{word:"wooden",categories:["touch"]},{word:"worried",categories:["personality"]},{word:"wrong",categories:["condition"]},{word:"yellow",categories:["color"]},{word:"young",categories:["time"]},{word:"yummy",categories:["taste"]},{word:"zealous",categories:["personality"]}]};function HE(r,e){var t,i;e===void 0&&(e=[]);var n=new Set(e),s=[];try{for(var o=UE(Qi.wordList[r]),a=o.next();!a.done;a=o.next()){var l=a.value;(e.length===0||l.categories.some(function(c){return n.has(c)}))&&s.push(l.word)}}catch(c){t={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}return s}Qi.getWordsByCategory=HE});var ug=Ei(Cn=>{"use strict";var Zl=Cn&&Cn.__assign||function(){return Zl=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},Zl.apply(this,arguments)};Object.defineProperty(Cn,"__esModule",{value:!0});Cn.totalUniqueSlugs=Cn.generateSlug=void 0;var ad=ag(),lg=3;function GE(r,e){for(var t=r||lg,i={partsOfSpeech:cg(t),categories:{},format:"kebab"},n=Zl(Zl({},i),e),s=[],o=0;o<t;o++){var a=n.partsOfSpeech[o],l=ad.getWordsByCategory(n.partsOfSpeech[o],n.categories[a]),c=l[Math.floor(Math.random()*l.length)];s.push(c)}return qE(s,n.format)}Cn.generateSlug=GE;function cg(r){for(var e=[],t=0;t<r-1;t++)e.push("adjective");return e.push("noun"),e}function qE(r,e){return e==="kebab"?r.join("-").toLowerCase():e==="camel"?r.map(function(t,i){return i===0?t.toLowerCase():t[0].toUpperCase()+t.slice(1).toLowerCase()}).join(""):e==="lower"?r.join(" ").toLowerCase():e==="sentence"?r.map(function(t,i){return i===0?t[0].toUpperCase()+t.slice(1).toLowerCase():t}).join(" "):r.map(function(t){return t[0].toUpperCase()+t.slice(1).toLowerCase()}).join(" ")}function WE(r,e){for(var t,i,n=ad.getWordsByCategory("adjective",(t=e?.categories)===null||t===void 0?void 0:t.adjective).length,s=ad.getWordsByCategory("noun",(i=e?.categories)===null||i===void 0?void 0:i.noun).length,o={adjective:n,noun:s},a=r||lg,l=e?.partsOfSpeech||cg(a),c=1,u=0;u<a;u++)c*=o[l[u]];return c}Cn.totalUniqueSlugs=WE});var hd=Ei((iT,fg)=>{"use strict";var cd=Object.defineProperty,$E=Object.getOwnPropertyDescriptor,jE=Object.getOwnPropertyNames,XE=Object.prototype.hasOwnProperty,YE=(r,e)=>{for(var t in e)cd(r,t,{get:e[t],enumerable:!0})},ZE=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of jE(e))!XE.call(r,n)&&n!==t&&cd(r,n,{get:()=>e[n],enumerable:!(i=$E(e,n))||i.enumerable});return r},JE=r=>ZE(cd({},"__esModule",{value:!0}),r),pg={};YE(pg,{FileInputSuggest:()=>QE,FolderInputSuggest:()=>KE,FuzzyInputSuggest:()=>ud,setNodeIcon:()=>iA});fg.exports=JE(pg);var ld=require("obsidian"),ud=class extends ld.AbstractInputSuggest{constructor(r,e,t){super(r,e.inputEl),this.items=t}getSuggestions(r){let e=(0,ld.prepareSimpleSearch)(r),t=[];for(let i of this.items){let n=e(this.getItemText(i));n&&t.push({item:i,match:n})}return t}renderSuggestion(r,e){e.addClass("mod-complex");let t=e.createDiv({cls:"suggestion-content"});if(!r?.item){t.setText("No match found"),t.parentElement?.addClass("is-selected");return}let i=t.createDiv("suggestion-title");this.renderTitle(i,r);let n=t.createDiv("suggestion-note");this.renderNote(n,r)}renderMatches(r,e,t,i){(0,ld.renderMatches)(r,e,t,i)}},hg=require("obsidian"),KE=class extends ud{getItemText(r){return r.path}renderNote(r,e){let{item:t,match:i}=e;(0,hg.renderMatches)(r,t.path,i.matches)}renderTitle(r,e){let{item:t,match:i}=e;(0,hg.renderMatches)(r,t.name,i.matches,t.path.length-t.name.length)}},dg=require("obsidian"),QE=class extends ud{getItemText(r){return r.path}renderNote(r,e){let{item:t,match:i}=e;(0,dg.renderMatches)(r,t.path,i.matches)}renderTitle(r,e){let{item:t,match:i}=e;(0,dg.renderMatches)(r,t.name,i.matches,t.path.length-t.name.length)}},eA=require("obsidian"),tA={"has-node-icon":"helpers_has-node-icon","x-small":"helpers_x-small",small:"helpers_small",medium:"helpers_medium",large:"helpers_large","x-large":"helpers_x-large"};function iA(r,e){r.addClass(tA["has-node-icon"]),(0,eA.setIcon)(r,e)}});var xg=Ei((yg,Kl)=>{(function(r,e){typeof define=="function"&&define.amd?define([],e):typeof Kl=="object"&&Kl.exports?Kl.exports=e():r.moo=e()})(yg,function(){"use strict";var r=Object.prototype.hasOwnProperty,e=Object.prototype.toString,t=typeof new RegExp().sticky=="boolean";function i(A){return A&&e.call(A)==="[object RegExp]"}function n(A){return A&&typeof A=="object"&&!i(A)&&!Array.isArray(A)}function s(A){return A.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function o(A){var v=new RegExp("|"+A);return v.exec("").length-1}function a(A){return"("+A+")"}function l(A){if(!A.length)return"(?!)";var v=A.map(function(R){return"(?:"+R+")"}).join("|");return"(?:"+v+")"}function c(A){if(typeof A=="string")return"(?:"+s(A)+")";if(i(A)){if(A.ignoreCase)throw new Error("RegExp /i flag not allowed");if(A.global)throw new Error("RegExp /g flag is implied");if(A.sticky)throw new Error("RegExp /y flag is implied");if(A.multiline)throw new Error("RegExp /m flag is implied");return A.source}else throw new Error("Not a pattern: "+A)}function u(A,v){return A.length>v?A:Array(v-A.length+1).join(" ")+A}function h(A,v){for(var R=A.length,S=0;;){var B=A.lastIndexOf(`
`,R-1);if(B===-1||(S++,R=B,S===v)||R===0)break}var L=S<v?0:R+1;return A.substring(L).split(`
`)}function d(A){for(var v=Object.getOwnPropertyNames(A),R=[],S=0;S<v.length;S++){var B=v[S],L=A[B],C=[].concat(L);if(B==="include"){for(var N=0;N<C.length;N++)R.push({include:C[N]});continue}var k=[];C.forEach(function(V){n(V)?(k.length&&R.push(m(B,k)),R.push(m(B,V)),k=[]):k.push(V)}),k.length&&R.push(m(B,k))}return R}function p(A){for(var v=[],R=0;R<A.length;R++){var S=A[R];if(S.include){for(var B=[].concat(S.include),L=0;L<B.length;L++)v.push({include:B[L]});continue}if(!S.type)throw new Error("Rule has no type: "+JSON.stringify(S));v.push(m(S.type,S))}return v}function m(A,v){if(n(v)||(v={match:v}),v.include)throw new Error("Matching rules cannot also include states");var R={defaultType:A,lineBreaks:!!v.error||!!v.fallback,pop:!1,next:null,push:null,error:!1,fallback:!1,value:null,type:null,shouldThrow:!1};for(var S in v)r.call(v,S)&&(R[S]=v[S]);if(typeof R.type=="string"&&A!==R.type)throw new Error("Type transform cannot be a string (type '"+R.type+"' for token '"+A+"')");var B=R.match;return R.match=Array.isArray(B)?B:B?[B]:[],R.match.sort(function(L,C){return i(L)&&i(C)?0:i(C)?-1:i(L)?1:C.length-L.length}),R}function y(A){return Array.isArray(A)?p(A):d(A)}var x=m("error",{lineBreaks:!0,shouldThrow:!0});function g(A,v){for(var R=null,S=Object.create(null),B=!0,L=null,C=[],N=[],k=0;k<A.length;k++)A[k].fallback&&(B=!1);for(var k=0;k<A.length;k++){var V=A[k];if(V.include)throw new Error("Inheritance is not allowed in stateless lexers");if(V.error||V.fallback){if(R)throw!V.fallback==!R.fallback?new Error("Multiple "+(V.fallback?"fallback":"error")+" rules not allowed (for token '"+V.defaultType+"')"):new Error("fallback and error are mutually exclusive (for token '"+V.defaultType+"')");R=V}var U=V.match.slice();if(B)for(;U.length&&typeof U[0]=="string"&&U[0].length===1;){var q=U.shift();S[q.charCodeAt(0)]=V}if(V.pop||V.push||V.next){if(!v)throw new Error("State-switching options are not allowed in stateless lexers (for token '"+V.defaultType+"')");if(V.fallback)throw new Error("State-switching options are not allowed on fallback tokens (for token '"+V.defaultType+"')")}if(U.length!==0){B=!1,C.push(V);for(var j=0;j<U.length;j++){var ne=U[j];if(i(ne)){if(L===null)L=ne.unicode;else if(L!==ne.unicode&&V.fallback===!1)throw new Error("If one rule is /u then all must be")}}var ae=l(U.map(c)),H=new RegExp(ae);if(H.test(""))throw new Error("RegExp matches empty string: "+H);var Te=o(ae);if(Te>0)throw new Error("RegExp has capture groups: "+H+`
Use (?: \u2026 ) instead`);if(!V.lineBreaks&&H.test(`
`))throw new Error("Rule should declare lineBreaks: "+H);N.push(a(ae))}}var ue=R&&R.fallback,we=t&&!ue?"ym":"gm",oe=t||ue?"":"|";L===!0&&(we+="u");var Ce=new RegExp(l(N)+oe,we);return{regexp:Ce,groups:C,fast:S,error:R||x}}function f(A){var v=g(y(A));return new M({start:v},"start")}function E(A,v,R){var S=A&&(A.push||A.next);if(S&&!R[S])throw new Error("Missing state '"+S+"' (in token '"+A.defaultType+"' of state '"+v+"')");if(A&&A.pop&&+A.pop!=1)throw new Error("pop must be 1 (in token '"+A.defaultType+"' of state '"+v+"')")}function w(A,v){var R=A.$all?y(A.$all):[];delete A.$all;var S=Object.getOwnPropertyNames(A);v||(v=S[0]);for(var B=Object.create(null),L=0;L<S.length;L++){var C=S[L];B[C]=y(A[C]).concat(R)}for(var L=0;L<S.length;L++)for(var C=S[L],N=B[C],k=Object.create(null),V=0;V<N.length;V++){var U=N[V];if(U.include){var q=[V,1];if(U.include!==C&&!k[U.include]){k[U.include]=!0;var j=B[U.include];if(!j)throw new Error("Cannot include nonexistent state '"+U.include+"' (in state '"+C+"')");for(var ne=0;ne<j.length;ne++){var ae=j[ne];N.indexOf(ae)===-1&&q.push(ae)}}N.splice.apply(N,q),V--}}for(var H=Object.create(null),L=0;L<S.length;L++){var C=S[L];H[C]=g(B[C],!0)}for(var L=0;L<S.length;L++){for(var Te=S[L],ue=H[Te],we=ue.groups,V=0;V<we.length;V++)E(we[V],Te,H);for(var oe=Object.getOwnPropertyNames(ue.fast),V=0;V<oe.length;V++)E(ue.fast[oe[V]],Te,H)}return new M(H,v)}function _(A){for(var v=typeof Map<"u",R=v?new Map:Object.create(null),S=Object.getOwnPropertyNames(A),B=0;B<S.length;B++){var L=S[B],C=A[L],N=Array.isArray(C)?C:[C];N.forEach(function(k){if(typeof k!="string")throw new Error("keyword must be string (in keyword '"+L+"')");v?R.set(k,L):R[k]=L})}return function(k){return v?R.get(k):R[k]}}var M=function(A,v){this.startState=v,this.states=A,this.buffer="",this.stack=[],this.reset()};M.prototype.reset=function(A,v){return this.buffer=A||"",this.index=0,this.line=v?v.line:1,this.col=v?v.col:1,this.queuedToken=v?v.queuedToken:null,this.queuedText=v?v.queuedText:"",this.queuedThrow=v?v.queuedThrow:null,this.setState(v?v.state:this.startState),this.stack=v&&v.stack?v.stack.slice():[],this},M.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedText:this.queuedText,queuedThrow:this.queuedThrow}},M.prototype.setState=function(A){if(!(!A||this.state===A)){this.state=A;var v=this.states[A];this.groups=v.groups,this.error=v.error,this.re=v.regexp,this.fast=v.fast}},M.prototype.popState=function(){this.setState(this.stack.pop())},M.prototype.pushState=function(A){this.stack.push(this.state),this.setState(A)};var T=t?function(A,v){return A.exec(v)}:function(A,v){var R=A.exec(v);return R[0].length===0?null:R};M.prototype._getGroup=function(A){for(var v=this.groups.length,R=0;R<v;R++)if(A[R+1]!==void 0)return this.groups[R];throw new Error("Cannot find token type for matched text")};function z(){return this.value}if(M.prototype.next=function(){var A=this.index;if(this.queuedGroup){var v=this._token(this.queuedGroup,this.queuedText,A);return this.queuedGroup=null,this.queuedText="",v}var R=this.buffer;if(A!==R.length){var C=this.fast[R.charCodeAt(A)];if(C)return this._token(C,R.charAt(A),A);var S=this.re;S.lastIndex=A;var B=T(S,R),L=this.error;if(B==null)return this._token(L,R.slice(A,R.length),A);var C=this._getGroup(B),N=B[0];return L.fallback&&B.index!==A?(this.queuedGroup=C,this.queuedText=N,this._token(L,R.slice(A,B.index),A)):this._token(C,N,A)}},M.prototype._token=function(A,v,R){var S=0;if(A.lineBreaks){var B=/\n/g,L=1;if(v===`
`)S=1;else for(;B.exec(v);)S++,L=B.lastIndex}var C={type:typeof A.type=="function"&&A.type(v)||A.defaultType,value:typeof A.value=="function"?A.value(v):v,text:v,toString:z,offset:R,lineBreaks:S,line:this.line,col:this.col},N=v.length;if(this.index+=N,this.line+=S,S!==0?this.col=N-L+1:this.col+=N,A.shouldThrow){var k=new Error(this.formatError(C,"invalid syntax"));throw k}return A.pop?this.popState():A.push?this.pushState(A.push):A.next&&this.setState(A.next),C},typeof Symbol<"u"&&Symbol.iterator){var W=function(A){this.lexer=A};W.prototype.next=function(){var A=this.lexer.next();return{value:A,done:!A}},W.prototype[Symbol.iterator]=function(){return this},M.prototype[Symbol.iterator]=function(){return new W(this)}}return M.prototype.formatError=function(A,v){if(A==null)var R=this.buffer.slice(this.index),A={text:R,offset:this.index,lineBreaks:R.indexOf(`
`)===-1?0:1,line:this.line,col:this.col};var S=2,B=Math.max(A.line-S,1),L=A.line+S,C=String(L).length,N=h(this.buffer,this.line-A.line+S+1).slice(0,5),k=[];k.push(v+" at line "+A.line+" col "+A.col+":"),k.push("");for(var V=0;V<N.length;V++){var U=N[V],q=B+V;k.push(u(String(q),C)+" "+U),q===A.line&&k.push(u("",C+A.col+1)+"^")}return k.join(`
`)},M.prototype.clone=function(){return new M(this.states,this.state)},M.prototype.has=function(A){return!0},{compile:f,states:w,error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:_}})});var Ql=Ei($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.isNone=$t.isSome=$t.None=$t.Some=$t.OptionType=void 0;$t.OptionType={Some:Symbol(":some"),None:Symbol(":none")};function nA(r){return typeof r>"u"?bo():vg(r)}$t.Some=nA;$t.None=bo();function vg(r){return{type:$t.OptionType.Some,isSome(){return!0},isNone(){return!1},match(e){return e.some(r)},map(e){return vg(e(r))},andThen(e){return e(r)},or(e){return this},and(e){return e},unwrapOr(e){return r},unwrap(){return r}}}function bo(){return{type:$t.OptionType.None,isSome(){return!1},isNone(){return!0},match(r){let{none:e}=r;return typeof e=="function"?e():e},map(r){return bo()},andThen(r){return bo()},or(r){return r},and(r){return bo()},unwrapOr(r){if(r==null)throw new Error("Cannot call unwrapOr with a missing value.");return r},unwrap(){throw new ReferenceError("Trying to unwrap None.")}}}function sA(r){return r.isSome()}$t.isSome=sA;function rA(r){return r.isNone()}$t.isNone=rA});var wg=Ei(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.isRight=jt.isLeft=jt.Right=jt.Left=jt.EitherType=void 0;var ec=Ql();jt.EitherType={Left:Symbol(":left"),Right:Symbol(":right")};function _o(r){return{type:jt.EitherType.Left,isLeft(){return!0},isRight(){return!1},left(){return(0,ec.Some)(r)},leftAndThen(e){return e(r)},right(){return ec.None},rightAndThen(e){return _o(r)},unwrap(){return r},unwrapLeft(){return r},unwrapLeftOr(e){return r},unwrapLeftOrElse(e){return r},unwrapRight(){throw new ReferenceError("Cannot unwrap Right value of Either.Left")},unwrapRightOr(e){return e},unwrapRightOrElse(e){return e(r)},match(e){return e.left(r)},map(e){return _o(e(r))},mapLeft(e){return _o(e(r))},mapRight(e){return _o(r)}}}jt.Left=_o;function Eo(r){return{type:jt.EitherType.Right,isLeft(){return!1},isRight(){return!0},left(){return ec.None},leftAndThen(e){return Eo(r)},right(){return(0,ec.Some)(r)},rightAndThen(e){return e(r)},unwrap(){return r},unwrapLeft(){throw new ReferenceError("Cannot unwrap Left value of Either.Right")},unwrapLeftOr(e){return e},unwrapLeftOrElse(e){return e(r)},unwrapRight(){return r},unwrapRightOr(e){return r},unwrapRightOrElse(e){return r},match(e){return e.right(r)},map(e){return Eo(e(r))},mapLeft(e){return Eo(r)},mapRight(e){return Eo(e(r))}}}jt.Right=Eo;function oA(r){return r.isLeft()}jt.isLeft=oA;function aA(r){return r.isRight()}jt.isRight=aA});var bg=Ei(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.isErr=Xt.isOk=Xt.Err=Xt.Ok=Xt.ResultType=void 0;var nc=Ql();Xt.ResultType={Ok:Symbol(":ok"),Err:Symbol(":err")};function tc(r){return{type:Xt.ResultType.Ok,isOk(){return!0},isErr(){return!1},ok(){return(0,nc.Some)(r)},err(){return nc.None},unwrap(){return r},unwrapOr(e){return r},unwrapOrElse(e){return r},unwrapErr(){throw new ReferenceError("Cannot unwrap Err value of Result.Ok")},match(e){return e.ok(r)},map(e){return tc(e(r))},mapErr(e){return tc(r)},andThen(e){return e(r)},orElse(e){return tc(r)}}}Xt.Ok=tc;function ic(r){return{type:Xt.ResultType.Err,isOk(){return!1},isErr(){return!0},ok(){return nc.None},err(){return(0,nc.Some)(r)},unwrap(){throw new ReferenceError("Cannot unwrap Ok value of Result.Err")},unwrapOr(e){return e},unwrapOrElse(e){return e(r)},unwrapErr(){return r},match(e){return e.err(r)},map(e){return ic(r)},mapErr(e){return ic(e(r))},andThen(e){return ic(r)},orElse(e){return e(r)}}}Xt.Err=ic;function lA(r){return r.isOk()}Xt.isOk=lA;function cA(r){return r.isErr()}Xt.isErr=cA});var dd=Ei(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.Ok=et.isOk=et.isErr=et.Err=et.Some=et.None=et.isSome=et.isNone=et.Right=et.Left=et.isRight=et.isLeft=void 0;var sc=wg();Object.defineProperty(et,"isLeft",{enumerable:!0,get:function(){return sc.isLeft}});Object.defineProperty(et,"isRight",{enumerable:!0,get:function(){return sc.isRight}});Object.defineProperty(et,"Left",{enumerable:!0,get:function(){return sc.Left}});Object.defineProperty(et,"Right",{enumerable:!0,get:function(){return sc.Right}});var rc=Ql();Object.defineProperty(et,"isNone",{enumerable:!0,get:function(){return rc.isNone}});Object.defineProperty(et,"isSome",{enumerable:!0,get:function(){return rc.isSome}});Object.defineProperty(et,"None",{enumerable:!0,get:function(){return rc.None}});Object.defineProperty(et,"Some",{enumerable:!0,get:function(){return rc.Some}});var oc=bg();Object.defineProperty(et,"Err",{enumerable:!0,get:function(){return oc.Err}});Object.defineProperty(et,"isErr",{enumerable:!0,get:function(){return oc.isErr}});Object.defineProperty(et,"isOk",{enumerable:!0,get:function(){return oc.isOk}});Object.defineProperty(et,"Ok",{enumerable:!0,get:function(){return oc.Ok}})});var _g=Ei(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});require("obsidian");var uA=r=>{var e;return r?(e=r.plugins.plugins.dataview)===null||e===void 0?void 0:e.api:window.DataviewAPI},hA=r=>r.plugins.enabledPlugins.has("dataview");ac.getAPI=uA;ac.isPluginEnabled=hA});var Dg=Ei((cc,So)=>{(function(r){var e=typeof cc=="object"&&cc,t=typeof So=="object"&&So&&So.exports==e&&So,i=typeof global=="object"&&global;(i.global===i||i.window===i)&&(r=i);var n=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,s=/[\x01-\x7F]/g,o=/[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,a=/<\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,l={"\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"},c=/["&'<>`]/g,u={'"':"&quot;","&":"&amp;","'":"&#x27;","<":"&lt;",">":"&gt;","`":"&#x60;"},h=/&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/,d=/[\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]/,p=/&(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,m={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"},y={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"},g=[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],f=String.fromCharCode,E={},w=E.hasOwnProperty,_=function(N,k){return w.call(N,k)},M=function(N,k){for(var V=-1,U=N.length;++V<U;)if(N[V]==k)return!0;return!1},T=function(N,k){if(!N)return k;var V={},U;for(U in k)V[U]=_(N,U)?N[U]:k[U];return V},z=function(N,k){var V="";return N>=55296&&N<=57343||N>1114111?(k&&v("character reference outside the permissible Unicode range"),"\uFFFD"):_(x,N)?(k&&v("disallowed character reference"),x[N]):(k&&M(g,N)&&v("disallowed character reference"),N>65535&&(N-=65536,V+=f(N>>>10&1023|55296),N=56320|N&1023),V+=f(N),V)},W=function(N){return"&#x"+N.toString(16).toUpperCase()+";"},A=function(N){return"&#"+N+";"},v=function(N){throw Error("Parse error: "+N)},R=function(N,k){k=T(k,R.options);var V=k.strict;V&&d.test(N)&&v("forbidden code point");var U=k.encodeEverything,q=k.useNamedReferences,j=k.allowUnsafeSymbols,ne=k.decimal?A:W,ae=function(H){return ne(H.charCodeAt(0))};return U?(N=N.replace(s,function(H){return q&&_(l,H)?"&"+l[H]+";":ae(H)}),q&&(N=N.replace(/&gt;\u20D2/g,"&nvgt;").replace(/&lt;\u20D2/g,"&nvlt;").replace(/&#x66;&#x6A;/g,"&fjlig;")),q&&(N=N.replace(a,function(H){return"&"+l[H]+";"}))):q?(j||(N=N.replace(c,function(H){return"&"+l[H]+";"})),N=N.replace(/&gt;\u20D2/g,"&nvgt;").replace(/&lt;\u20D2/g,"&nvlt;"),N=N.replace(a,function(H){return"&"+l[H]+";"})):j||(N=N.replace(c,ae)),N.replace(n,function(H){var Te=H.charCodeAt(0),ue=H.charCodeAt(1),we=(Te-55296)*1024+ue-56320+65536;return ne(we)}).replace(o,ae)};R.options={allowUnsafeSymbols:!1,encodeEverything:!1,strict:!1,useNamedReferences:!1,decimal:!1};var S=function(N,k){k=T(k,S.options);var V=k.strict;return V&&h.test(N)&&v("malformed character reference"),N.replace(p,function(U,q,j,ne,ae,H,Te,ue,we){var oe,Ce,Ae,Z,ie,te;return q?(ie=q,m[ie]):j?(ie=j,te=ne,te&&k.isAttributeValue?(V&&te=="="&&v("`&` did not start a character reference"),U):(V&&v("named character reference was not terminated by a semicolon"),y[ie]+(te||""))):ae?(Ae=ae,Ce=H,V&&!Ce&&v("character reference was not terminated by a semicolon"),oe=parseInt(Ae,10),z(oe,V)):Te?(Z=Te,Ce=ue,V&&!Ce&&v("character reference was not terminated by a semicolon"),oe=parseInt(Z,16),z(oe,V)):(V&&v("named character reference was not terminated by a semicolon"),U)})};S.options={isAttributeValue:!1,strict:!1};var B=function(N){return N.replace(c,function(k){return u[k]})},L={version:"1.2.0",encode:R,decode:S,escape:B,unescape:S};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd)define(function(){return L});else if(e&&!e.nodeType)if(t)t.exports=L;else for(var C in L)_(L,C)&&(e[C]=L[C]);else r.he=L})(cc)});var nS={};A0(nS,{default:()=>Ac});module.exports=S0(nS);var is=require("obsidian");var Ym=require("obsidian");var Yn=require("obsidian");var po=require("obsidian");var rS=require("obsidian");function jd(r,e,t){[...r].slice(e).reverse().forEach(([n,s])=>{r.set(n+1,s)}),r.set(e,t)}function ko(r,e){return Object.entries(r).reduce((t,i)=>{let n=i[0],o=i[1]?e.parent.path.startsWith(n):e.parent.path==n;return t||o},!1)}var Di=class r{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 b){let t=this.elements;return e.x=t[0],e.y=t[4],e.z=t[8],e}vmult(e,t=new b){let i=this.elements,n=e.x,s=e.y,o=e.z;return t.x=i[0]*n+i[1]*s+i[2]*o,t.y=i[3]*n+i[4]*s+i[5]*o,t.z=i[6]*n+i[7]*s+i[8]*o,t}smult(e){for(let t=0;t<this.elements.length;t++)this.elements[t]*=e}mmult(e,t=new r){let i=this.elements,n=e.elements,s=t.elements,o=i[0],a=i[1],l=i[2],c=i[3],u=i[4],h=i[5],d=i[6],p=i[7],m=i[8],y=n[0],x=n[1],g=n[2],f=n[3],E=n[4],w=n[5],_=n[6],M=n[7],T=n[8];return s[0]=o*y+a*f+l*_,s[1]=o*x+a*E+l*M,s[2]=o*g+a*w+l*T,s[3]=c*y+u*f+h*_,s[4]=c*x+u*E+h*M,s[5]=c*g+u*w+h*T,s[6]=d*y+p*f+m*_,s[7]=d*x+p*E+m*M,s[8]=d*g+p*w+m*T,t}scale(e,t=new r){let i=this.elements,n=t.elements;for(let s=0;s!==3;s++)n[3*s+0]=e.x*i[3*s+0],n[3*s+1]=e.y*i[3*s+1],n[3*s+2]=e.z*i[3*s+2];return t}solve(e,t=new b){let s=[],o,a;for(o=0;o<3*4;o++)s.push(0);for(o=0;o<3;o++)for(a=0;a<3;a++)s[o+4*a]=this.elements[o+3*a];s[3+4*0]=e.x,s[3+4*1]=e.y,s[3+4*2]=e.z;let l=3,c=l,u,h=4,d;do{if(o=c-l,s[o+4*o]===0){for(a=o+1;a<c;a++)if(s[o+4*a]!==0){u=h;do d=h-u,s[d+4*o]+=s[d+4*a];while(--u);break}}if(s[o+4*o]!==0)for(a=o+1;a<c;a++){let p=s[o+4*a]/s[o+4*o];u=h;do d=h-u,s[d+4*a]=d<=o?0:s[d+4*a]-s[d+4*o]*p;while(--u)}}while(--l);if(t.z=s[2*4+3]/s[2*4+2],t.y=(s[1*4+3]-s[1*4+2]*t.z)/s[1*4+1],t.x=(s[0*4+3]-s[0*4+2]*t.z-s[0*4+1]*t.y)/s[0*4+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 r){let n=M0,s,o;for(s=0;s<3;s++)for(o=0;o<3;o++)n[s+6*o]=this.elements[s+3*o];n[3+6*0]=1,n[3+6*1]=0,n[3+6*2]=0,n[4+6*0]=0,n[4+6*1]=1,n[4+6*2]=0,n[5+6*0]=0,n[5+6*1]=0,n[5+6*2]=1;let a=3,l=a,c,u=6,h;do{if(s=l-a,n[s+6*s]===0){for(o=s+1;o<l;o++)if(n[s+6*o]!==0){c=u;do h=u-c,n[h+6*s]+=n[h+6*o];while(--c);break}}if(n[s+6*s]!==0)for(o=s+1;o<l;o++){let d=n[s+6*o]/n[s+6*s];c=u;do h=u-c,n[h+6*o]=h<=s?0:n[h+6*o]-n[h+6*s]*d;while(--c)}}while(--a);s=2;do{o=s-1;do{let d=n[s+6*o]/n[s+6*s];c=6;do h=6-c,n[h+6*o]=n[h+6*o]-n[h+6*s]*d;while(--c)}while(o--)}while(--s);s=2;do{let d=1/n[s+6*s];c=6;do h=6-c,n[h+6*s]=n[h+6*s]*d;while(--c)}while(s--);s=2;do{o=2;do{if(h=n[3+o+6*s],isNaN(h)||h===1/0)throw"Could not reverse! A=["+this.toString()+"]";e.e(s,o,h)}while(o--)}while(s--);return e}setRotationFromQuaternion(e){let t=e.x,i=e.y,n=e.z,s=e.w,o=t+t,a=i+i,l=n+n,c=t*o,u=t*a,h=t*l,d=i*a,p=i*l,m=n*l,y=s*o,x=s*a,g=s*l,f=this.elements;return f[3*0+0]=1-(d+m),f[3*0+1]=u-g,f[3*0+2]=h+x,f[3*1+0]=u+g,f[3*1+1]=1-(c+m),f[3*1+2]=p-y,f[3*2+0]=h-x,f[3*2+1]=p+y,f[3*2+2]=1-(c+d),this}transpose(e=new r){let t=this.elements,i=e.elements,n;return i[0]=t[0],i[4]=t[4],i[8]=t[8],n=t[1],i[1]=t[3],i[3]=n,n=t[2],i[2]=t[6],i[6]=n,n=t[5],i[5]=t[7],i[7]=n,e}},M0=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],b=class r{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 r){let i=e.x,n=e.y,s=e.z,o=this.x,a=this.y,l=this.z;return t.x=a*s-l*n,t.y=l*i-o*s,t.z=o*n-a*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 r(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 r(this.x-e.x,this.y-e.y,this.z-e.z)}crossmat(){return new Di([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,n=Math.sqrt(e*e+t*t+i*i);if(n>0){let s=1/n;this.x*=s,this.y*=s,this.z*=s}else this.x=0,this.y=0,this.z=0;return n}unit(e=new r){let t=this.x,i=this.y,n=this.z,s=Math.sqrt(t*t+i*i+n*n);return s>0?(s=1/s,e.x=t*s,e.y=i*s,e.z=n*s):(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,n=this.z,s=e.x,o=e.y,a=e.z;return Math.sqrt((s-t)*(s-t)+(o-i)*(o-i)+(a-n)*(a-n))}distanceSquared(e){let t=this.x,i=this.y,n=this.z,s=e.x,o=e.y,a=e.z;return(s-t)*(s-t)+(o-i)*(o-i)+(a-n)*(a-n)}scale(e,t=new r){let i=this.x,n=this.y,s=this.z;return t.x=e*i,t.y=e*n,t.z=e*s,t}vmul(e,t=new r){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 r){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 r){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 n=D0,s=1/i;n.set(this.x*s,this.y*s,this.z*s);let o=T0;Math.abs(n.x)<.9?(o.set(1,0,0),n.cross(o,e)):(o.set(0,1,0),n.cross(o,e)),n.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 n=this.x,s=this.y,o=this.z;i.x=n+(e.x-n)*t,i.y=s+(e.y-s)*t,i.z=o+(e.z-o)*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(Xd),Xd.almostEquals(e,t)}clone(){return new r(this.x,this.y,this.z)}};b.ZERO=void 0;b.UNIT_X=void 0;b.UNIT_Y=void 0;b.UNIT_Z=void 0;b.ZERO=new b(0,0,0);b.UNIT_X=new b(1,0,0);b.UNIT_Y=new b(0,1,0);b.UNIT_Z=new b(0,0,1);var D0=new b,T0=new b,Xd=new b,Zt=class r{constructor(e={}){this.lowerBound=void 0,this.upperBound=void 0,this.lowerBound=new b,this.upperBound=new b,e.lowerBound&&this.lowerBound.copy(e.lowerBound),e.upperBound&&this.upperBound.copy(e.upperBound)}setFromPoints(e,t,i,n){let s=this.lowerBound,o=this.upperBound,a=i;s.copy(e[0]),a&&a.vmult(s,s),o.copy(s);for(let l=1;l<e.length;l++){let c=e[l];a&&(a.vmult(c,Yd),c=Yd),c.x>o.x&&(o.x=c.x),c.x<s.x&&(s.x=c.x),c.y>o.y&&(o.y=c.y),c.y<s.y&&(s.y=c.y),c.z>o.z&&(o.z=c.z),c.z<s.z&&(s.z=c.z)}return t&&(t.vadd(s,s),t.vadd(o,o)),n&&(s.x-=n,s.y-=n,s.z-=n,o.x+=n,o.y+=n,o.z+=n),this}copy(e){return this.lowerBound.copy(e.lowerBound),this.upperBound.copy(e.upperBound),this}clone(){return new r().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,n=e.lowerBound,s=e.upperBound,o=n.x<=i.x&&i.x<=s.x||t.x<=s.x&&s.x<=i.x,a=n.y<=i.y&&i.y<=s.y||t.y<=s.y&&s.y<=i.y,l=n.z<=i.z&&i.z<=s.z||t.z<=s.z&&s.z<=i.z;return o&&a&&l}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,n=e.lowerBound,s=e.upperBound;return t.x<=n.x&&i.x>=s.x&&t.y<=n.y&&i.y>=s.y&&t.z<=n.z&&i.z>=s.z}getCorners(e,t,i,n,s,o,a,l){let c=this.lowerBound,u=this.upperBound;e.copy(c),t.set(u.x,c.y,c.z),i.set(u.x,u.y,c.z),n.set(c.x,u.y,u.z),s.set(u.x,c.y,u.z),o.set(c.x,u.y,c.z),a.set(c.x,c.y,u.z),l.copy(u)}toLocalFrame(e,t){let i=Zd,n=i[0],s=i[1],o=i[2],a=i[3],l=i[4],c=i[5],u=i[6],h=i[7];this.getCorners(n,s,o,a,l,c,u,h);for(let d=0;d!==8;d++){let p=i[d];e.pointToLocal(p,p)}return t.setFromPoints(i)}toWorldFrame(e,t){let i=Zd,n=i[0],s=i[1],o=i[2],a=i[3],l=i[4],c=i[5],u=i[6],h=i[7];this.getCorners(n,s,o,a,l,c,u,h);for(let d=0;d!==8;d++){let p=i[d];e.pointToWorld(p,p)}return t.setFromPoints(i)}overlapsRay(e){let{direction:t,from:i}=e,n=1/t.x,s=1/t.y,o=1/t.z,a=(this.lowerBound.x-i.x)*n,l=(this.upperBound.x-i.x)*n,c=(this.lowerBound.y-i.y)*s,u=(this.upperBound.y-i.y)*s,h=(this.lowerBound.z-i.z)*o,d=(this.upperBound.z-i.z)*o,p=Math.max(Math.max(Math.min(a,l),Math.min(c,u)),Math.min(h,d)),m=Math.min(Math.min(Math.max(a,l),Math.max(c,u)),Math.max(h,d));return!(m<0||p>m)}},Yd=new b,Zd=[new b,new b,new b,new b,new b,new b,new b,new b],Go=class{constructor(){this.matrix=void 0,this.matrix=[]}get(e,t){let{index:i}=e,{index:n}=t;if(n>i){let s=n;n=i,i=s}return this.matrix[(i*(i+1)>>1)+n-1]}set(e,t,i){let{index:n}=e,{index:s}=t;if(s>n){let o=s;s=n,n=o}this.matrix[(n*(n+1)>>1)+s-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}},qo=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 n=i[e].indexOf(t);return n!==-1&&i[e].splice(n,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 n=0,s=i.length;n<s;n++)i[n].call(this,e)}return this}},vt=class r{constructor(e=0,t=0,i=0,n=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=n}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,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 b){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=C0,n=R0;e.tangents(i,n),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 r){let i=this.x,n=this.y,s=this.z,o=this.w,a=e.x,l=e.y,c=e.z,u=e.w;return t.x=i*u+o*a+n*c-s*l,t.y=n*u+o*l+s*a-i*c,t.z=s*u+o*c+i*l-n*a,t.w=o*u-i*a-n*l-s*c,t}inverse(e=new r){let t=this.x,i=this.y,n=this.z,s=this.w;this.conjugate(e);let o=1/(t*t+i*i+n*n+s*s);return e.x*=o,e.y*=o,e.z*=o,e.w*=o,e}conjugate(e=new r){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 b){let i=e.x,n=e.y,s=e.z,o=this.x,a=this.y,l=this.z,c=this.w,u=c*i+a*s-l*n,h=c*n+l*i-o*s,d=c*s+o*n-a*i,p=-o*i-a*n-l*s;return t.x=u*c+p*-o+h*-l-d*-a,t.y=h*c+p*-a+d*-o-u*-l,t.z=d*c+p*-l+u*-a-h*-o,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,n,s,o=this.x,a=this.y,l=this.z,c=this.w;switch(t){case"YZX":let u=o*a+l*c;if(u>.499&&(i=2*Math.atan2(o,c),n=Math.PI/2,s=0),u<-.499&&(i=-2*Math.atan2(o,c),n=-Math.PI/2,s=0),i===void 0){let h=o*o,d=a*a,p=l*l;i=Math.atan2(2*a*c-2*o*l,1-2*d-2*p),n=Math.asin(2*u),s=Math.atan2(2*o*c-2*a*l,1-2*h-2*p)}break;default:throw new Error("Euler order "+t+" not supported yet.")}e.y=i,e.z=n,e.x=s}setFromEuler(e,t,i,n="XYZ"){let s=Math.cos(e/2),o=Math.cos(t/2),a=Math.cos(i/2),l=Math.sin(e/2),c=Math.sin(t/2),u=Math.sin(i/2);return n==="XYZ"?(this.x=l*o*a+s*c*u,this.y=s*c*a-l*o*u,this.z=s*o*u+l*c*a,this.w=s*o*a-l*c*u):n==="YXZ"?(this.x=l*o*a+s*c*u,this.y=s*c*a-l*o*u,this.z=s*o*u-l*c*a,this.w=s*o*a+l*c*u):n==="ZXY"?(this.x=l*o*a-s*c*u,this.y=s*c*a+l*o*u,this.z=s*o*u+l*c*a,this.w=s*o*a-l*c*u):n==="ZYX"?(this.x=l*o*a-s*c*u,this.y=s*c*a+l*o*u,this.z=s*o*u-l*c*a,this.w=s*o*a+l*c*u):n==="YZX"?(this.x=l*o*a+s*c*u,this.y=s*c*a+l*o*u,this.z=s*o*u-l*c*a,this.w=s*o*a-l*c*u):n==="XZY"&&(this.x=l*o*a-s*c*u,this.y=s*c*a-l*o*u,this.z=s*o*u+l*c*a,this.w=s*o*a+l*c*u),this}clone(){return new r(this.x,this.y,this.z,this.w)}slerp(e,t,i=new r){let n=this.x,s=this.y,o=this.z,a=this.w,l=e.x,c=e.y,u=e.z,h=e.w,d,p,m,y,x;return p=n*l+s*c+o*u+a*h,p<0&&(p=-p,l=-l,c=-c,u=-u,h=-h),1-p>1e-6?(d=Math.acos(p),m=Math.sin(d),y=Math.sin((1-t)*d)/m,x=Math.sin(t*d)/m):(y=1-t,x=t),i.x=y*n+x*l,i.y=y*s+x*c,i.z=y*o+x*u,i.w=y*a+x*h,i}integrate(e,t,i,n=new r){let s=e.x*i.x,o=e.y*i.y,a=e.z*i.z,l=this.x,c=this.y,u=this.z,h=this.w,d=t*.5;return n.x+=d*(s*h+o*u-a*c),n.y+=d*(o*h+a*l-s*u),n.z+=d*(a*h+s*c-o*l),n.w+=d*(-s*l-o*c-a*u),n}},C0=new b,R0=new b,F0={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256},me=class r{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=r.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,n){throw"calculateWorldAABB() not implemented for shape type "+this.type}};me.idCounter=0;me.types=F0;var Ge=class r{constructor(e={}){this.position=void 0,this.quaternion=void 0,this.position=new b,this.quaternion=new vt,e.position&&this.position.copy(e.position),e.quaternion&&this.quaternion.copy(e.quaternion)}pointToLocal(e,t){return r.pointToLocalFrame(this.position,this.quaternion,e,t)}pointToWorld(e,t){return r.pointToWorldFrame(this.position,this.quaternion,e,t)}vectorToWorldFrame(e,t=new b){return this.quaternion.vmult(e,t),t}static pointToLocalFrame(e,t,i,n=new b){return i.vsub(e,n),t.conjugate(Jd),Jd.vmult(n,n),n}static pointToWorldFrame(e,t,i,n=new b){return t.vmult(i,n),n.vadd(e,n),n}static vectorToWorldFrame(e,t,i=new b){return e.vmult(t,i),i}static vectorToLocalFrame(e,t,i,n=new b){return t.w*=-1,t.vmult(i,n),t.w*=-1,n}},Jd=new vt,mr=class r extends me{constructor(e={}){let{vertices:t=[],faces:i=[],normals:n=[],axes:s,boundingSphereRadius:o}=e;super({type:me.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=n,this.faceNormals.length===0&&this.computeNormals(),o?this.boundingSphereRadius=o:this.updateBoundingSphereRadius(),this.worldVertices=[],this.worldVerticesNeedsUpdate=!0,this.worldFaceNormals=[],this.worldFaceNormalsNeedsUpdate=!0,this.uniqueAxes=s?s.slice():null,this.uniqueEdges=[],this.computeEdges()}computeEdges(){let e=this.faces,t=this.vertices,i=this.uniqueEdges;i.length=0;let n=new b;for(let s=0;s!==e.length;s++){let o=e[s],a=o.length;for(let l=0;l!==a;l++){let c=(l+1)%a;t[o[l]].vsub(t[o[c]],n),n.normalize();let u=!1;for(let h=0;h!==i.length;h++)if(i[h].almostEquals(n)||i[h].almostEquals(n)){u=!0;break}u||i.push(n.clone())}}}computeNormals(){this.faceNormals.length=this.faces.length;for(let e=0;e<this.faces.length;e++){for(let n=0;n<this.faces[e].length;n++)if(!this.vertices[this.faces[e][n]])throw new Error("Vertex "+this.faces[e][n]+" not found!");let t=this.faceNormals[e]||new b;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 n=0;n<this.faces[e].length;n++)console.warn(".vertices["+this.faces[e][n]+"] = Vec3("+this.vertices[this.faces[e][n]].toString()+")")}}}getFaceNormal(e,t){let i=this.faces[e],n=this.vertices[i[0]],s=this.vertices[i[1]],o=this.vertices[i[2]];r.computeNormal(n,s,o,t)}static computeNormal(e,t,i,n){let s=new b,o=new b;t.vsub(e,o),i.vsub(t,s),s.cross(o,n),n.isZero()||n.normalize()}clipAgainstHull(e,t,i,n,s,o,a,l,c){let u=new b,h=-1,d=-Number.MAX_VALUE;for(let m=0;m<i.faces.length;m++){u.copy(i.faceNormals[m]),s.vmult(u,u);let y=u.dot(o);y>d&&(d=y,h=m)}let p=[];for(let m=0;m<i.faces[h].length;m++){let y=i.vertices[i.faces[h][m]],x=new b;x.copy(y),s.vmult(x,x),n.vadd(x,x),p.push(x)}h>=0&&this.clipFaceAgainstHull(o,e,t,p,a,l,c)}findSeparatingAxis(e,t,i,n,s,o,a,l){let c=new b,u=new b,h=new b,d=new b,p=new b,m=new b,y=Number.MAX_VALUE,x=this;if(x.uniqueAxes)for(let g=0;g!==x.uniqueAxes.length;g++){i.vmult(x.uniqueAxes[g],c);let f=x.testSepAxis(c,e,t,i,n,s);if(f===!1)return!1;f<y&&(y=f,o.copy(c))}else{let g=a?a.length:x.faces.length;for(let f=0;f<g;f++){let E=a?a[f]:f;c.copy(x.faceNormals[E]),i.vmult(c,c);let w=x.testSepAxis(c,e,t,i,n,s);if(w===!1)return!1;w<y&&(y=w,o.copy(c))}}if(e.uniqueAxes)for(let g=0;g!==e.uniqueAxes.length;g++){s.vmult(e.uniqueAxes[g],u);let f=x.testSepAxis(u,e,t,i,n,s);if(f===!1)return!1;f<y&&(y=f,o.copy(u))}else{let g=l?l.length:e.faces.length;for(let f=0;f<g;f++){let E=l?l[f]:f;u.copy(e.faceNormals[E]),s.vmult(u,u);let w=x.testSepAxis(u,e,t,i,n,s);if(w===!1)return!1;w<y&&(y=w,o.copy(u))}}for(let g=0;g!==x.uniqueEdges.length;g++){i.vmult(x.uniqueEdges[g],d);for(let f=0;f!==e.uniqueEdges.length;f++)if(s.vmult(e.uniqueEdges[f],p),d.cross(p,m),!m.almostZero()){m.normalize();let E=x.testSepAxis(m,e,t,i,n,s);if(E===!1)return!1;E<y&&(y=E,o.copy(m))}}return n.vsub(t,h),h.dot(o)>0&&o.negate(o),!0}testSepAxis(e,t,i,n,s,o){let a=this;r.project(a,e,i,n,Mc),r.project(t,e,s,o,Dc);let l=Mc[0],c=Mc[1],u=Dc[0],h=Dc[1];if(l<h||u<c)return!1;let d=l-h,p=u-c;return d<p?d:p}calculateLocalInertia(e,t){let i=new b,n=new b;this.computeLocalAABB(n,i);let s=i.x-n.x,o=i.y-n.y,a=i.z-n.z;t.x=1/12*e*(2*o*2*o+2*a*2*a),t.y=1/12*e*(2*s*2*s+2*a*2*a),t.z=1/12*e*(2*o*2*o+2*s*2*s)}getPlaneConstantOfFace(e){let t=this.faces[e],i=this.faceNormals[e],n=this.vertices[t[0]];return-i.dot(n)}clipFaceAgainstHull(e,t,i,n,s,o,a){let l=new b,c=new b,u=new b,h=new b,d=new b,p=new b,m=new b,y=new b,x=this,g=[],f=n,E=g,w=-1,_=Number.MAX_VALUE;for(let A=0;A<x.faces.length;A++){l.copy(x.faceNormals[A]),i.vmult(l,l);let v=l.dot(e);v<_&&(_=v,w=A)}if(w<0)return;let M=x.faces[w];M.connectedFaces=[];for(let A=0;A<x.faces.length;A++)for(let v=0;v<x.faces[A].length;v++)M.indexOf(x.faces[A][v])!==-1&&A!==w&&M.connectedFaces.indexOf(A)===-1&&M.connectedFaces.push(A);let T=M.length;for(let A=0;A<T;A++){let v=x.vertices[M[A]],R=x.vertices[M[(A+1)%T]];v.vsub(R,c),u.copy(c),i.vmult(u,u),t.vadd(u,u),h.copy(this.faceNormals[w]),i.vmult(h,h),t.vadd(h,h),u.cross(h,d),d.negate(d),p.copy(v),i.vmult(p,p),t.vadd(p,p);let S=M.connectedFaces[A];m.copy(this.faceNormals[S]);let B=this.getPlaneConstantOfFace(S);y.copy(m),i.vmult(y,y);let L=B-y.dot(t);for(this.clipFaceAgainstPlane(f,E,y,L);f.length;)f.shift();for(;E.length;)f.push(E.shift())}m.copy(this.faceNormals[w]);let z=this.getPlaneConstantOfFace(w);y.copy(m),i.vmult(y,y);let W=z-y.dot(t);for(let A=0;A<f.length;A++){let v=y.dot(f[A])+W;if(v<=s&&(console.log("clamped: depth="+v+" to minDist="+s),v=s),v<=o){let R=f[A];if(v<=1e-6){let S={point:R,normal:y,depth:v};a.push(S)}}}}clipFaceAgainstPlane(e,t,i,n){let s,o,a=e.length;if(a<2)return t;let l=e[e.length-1],c=e[0];s=i.dot(l)+n;for(let u=0;u<a;u++){if(c=e[u],o=i.dot(c)+n,s<0)if(o<0){let h=new b;h.copy(c),t.push(h)}else{let h=new b;l.lerp(c,s/(s-o),h),t.push(h)}else if(o<0){let h=new b;l.lerp(c,s/(s-o),h),t.push(h),t.push(c)}l=c,s=o}return t}computeWorldVertices(e,t){for(;this.worldVertices.length<this.vertices.length;)this.worldVertices.push(new b);let i=this.vertices,n=this.worldVertices;for(let s=0;s!==this.vertices.length;s++)t.vmult(i[s],n[s]),e.vadd(n[s],n[s]);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 n=0;n<this.vertices.length;n++){let s=i[n];s.x<e.x?e.x=s.x:s.x>t.x&&(t.x=s.x),s.y<e.y?e.y=s.y:s.y>t.y&&(t.y=s.y),s.z<e.z?e.z=s.z:s.z>t.z&&(t.z=s.z)}}computeWorldFaceNormals(e){let t=this.faceNormals.length;for(;this.worldFaceNormals.length<t;)this.worldFaceNormals.push(new b);let i=this.faceNormals,n=this.worldFaceNormals;for(let s=0;s!==t;s++)e.vmult(i[s],n[s]);this.worldFaceNormalsNeedsUpdate=!1}updateBoundingSphereRadius(){let e=0,t=this.vertices;for(let i=0;i!==t.length;i++){let n=t[i].lengthSquared();n>e&&(e=n)}this.boundingSphereRadius=Math.sqrt(e)}calculateWorldAABB(e,t,i,n){let s=this.vertices,o,a,l,c,u,h,d=new b;for(let p=0;p<s.length;p++){d.copy(s[p]),t.vmult(d,d),e.vadd(d,d);let m=d;(o===void 0||m.x<o)&&(o=m.x),(c===void 0||m.x>c)&&(c=m.x),(a===void 0||m.y<a)&&(a=m.y),(u===void 0||m.y>u)&&(u=m.y),(l===void 0||m.z<l)&&(l=m.z),(h===void 0||m.z>h)&&(h=m.z)}i.set(o,a,l),n.set(c,u,h)}volume(){return 4*Math.PI*this.boundingSphereRadius/3}getAveragePointLocal(e=new b){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,n=this.vertices;if(t){for(let s=0;s<i;s++){let o=n[s];t.vmult(o,o)}for(let s=0;s<this.faceNormals.length;s++){let o=this.faceNormals[s];t.vmult(o,o)}}if(e)for(let s=0;s<i;s++){let o=n[s];o.vadd(e,o)}}pointIsInside(e){let t=this.vertices,i=this.faces,n=this.faceNormals,s=new b;this.getAveragePointLocal(s);for(let o=0;o<this.faces.length;o++){let a=n[o],l=t[i[o][0]],c=new b;e.vsub(l,c);let u=a.dot(c),h=new b;s.vsub(l,h);let d=a.dot(h);if(u<0&&d>0||u>0&&d<0)return!1}return-1}static project(e,t,i,n,s){let o=e.vertices.length,a=L0,l=0,c=0,u=B0,h=e.vertices;u.setZero(),Ge.vectorToLocalFrame(i,n,t,a),Ge.pointToLocalFrame(i,n,u,u);let d=u.dot(a);c=l=h[0].dot(a);for(let p=1;p<o;p++){let m=h[p].dot(a);m>l&&(l=m),m<c&&(c=m)}if(c-=d,l-=d,c>l){let p=c;c=l,l=p}s[0]=l,s[1]=c}},Mc=[],Dc=[],L0=new b,B0=new b,Fc=class r extends me{constructor(e){super({type:me.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,n=b,s=[new n(-e,-t,-i),new n(e,-t,-i),new n(e,t,-i),new n(-e,t,-i),new n(-e,-t,i),new n(e,-t,i),new n(e,t,i),new n(-e,t,i)],o=[[3,2,1,0],[4,5,6,7],[5,4,0,1],[2,3,7,6],[0,4,7,3],[1,2,6,5]],a=[new n(0,0,1),new n(0,1,0),new n(1,0,0)],l=new mr({vertices:s,faces:o,axes:a});this.convexPolyhedronRepresentation=l,l.material=this.material}calculateLocalInertia(e,t=new b){return r.calculateInertia(this.halfExtents,e,t),t}static calculateInertia(e,t,i){let n=e;i.x=1/12*t*(2*n.y*2*n.y+2*n.z*2*n.z),i.y=1/12*t*(2*n.x*2*n.x+2*n.z*2*n.z),i.z=1/12*t*(2*n.y*2*n.y+2*n.x*2*n.x)}getSideNormals(e,t){let i=e,n=this.halfExtents;if(i[0].set(n.x,0,0),i[1].set(0,n.y,0),i[2].set(0,0,n.z),i[3].set(-n.x,0,0),i[4].set(0,-n.y,0),i[5].set(0,0,-n.z),t!==void 0)for(let s=0;s!==i.length;s++)t.vmult(i[s],i[s]);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 n=this.halfExtents,s=[[n.x,n.y,n.z],[-n.x,n.y,n.z],[-n.x,-n.y,n.z],[-n.x,-n.y,-n.z],[n.x,-n.y,-n.z],[n.x,n.y,-n.z],[-n.x,n.y,-n.z],[n.x,-n.y,n.z]];for(let o=0;o<s.length;o++)an.set(s[o][0],s[o][1],s[o][2]),t.vmult(an,an),e.vadd(an,an),i(an.x,an.y,an.z)}calculateWorldAABB(e,t,i,n){let s=this.halfExtents;Ai[0].set(s.x,s.y,s.z),Ai[1].set(-s.x,s.y,s.z),Ai[2].set(-s.x,-s.y,s.z),Ai[3].set(-s.x,-s.y,-s.z),Ai[4].set(s.x,-s.y,-s.z),Ai[5].set(s.x,s.y,-s.z),Ai[6].set(-s.x,s.y,-s.z),Ai[7].set(s.x,-s.y,s.z);let o=Ai[0];t.vmult(o,o),e.vadd(o,o),n.copy(o),i.copy(o);for(let a=1;a<8;a++){let l=Ai[a];t.vmult(l,l),e.vadd(l,l);let c=l.x,u=l.y,h=l.z;c>n.x&&(n.x=c),u>n.y&&(n.y=u),h>n.z&&(n.z=h),c<i.x&&(i.x=c),u<i.y&&(i.y=u),h<i.z&&(i.z=h)}}},an=new b,Ai=[new b,new b,new b,new b,new b,new b,new b,new b],Uc={DYNAMIC:1,STATIC:2,KINEMATIC:4},Hc={AWAKE:0,SLEEPY:1,SLEEPING:2},De=class r extends qo{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=r.idCounter++,this.index=-1,this.world=null,this.preStep=null,this.postStep=null,this.vlambda=new b,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 b,this.previousPosition=new b,this.interpolatedPosition=new b,this.initPosition=new b,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 b,e.velocity&&this.velocity.copy(e.velocity),this.initVelocity=new b,this.force=new b;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?r.STATIC:r.DYNAMIC,typeof e.type==typeof r.STATIC&&(this.type=e.type),this.allowSleep=typeof e.allowSleep<"u"?e.allowSleep:!0,this.sleepState=r.AWAKE,this.sleepSpeedLimit=typeof e.sleepSpeedLimit<"u"?e.sleepSpeedLimit:.1,this.sleepTimeLimit=typeof e.sleepTimeLimit<"u"?e.sleepTimeLimit:1,this.timeLastSleepy=0,this.wakeUpAfterNarrowphase=!1,this.torque=new b,this.quaternion=new vt,this.initQuaternion=new vt,this.previousQuaternion=new vt,this.interpolatedQuaternion=new vt,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 b,e.angularVelocity&&this.angularVelocity.copy(e.angularVelocity),this.initAngularVelocity=new b,this.shapes=[],this.shapeOffsets=[],this.shapeOrientations=[],this.inertia=new b,this.invInertia=new b,this.invInertiaWorld=new Di,this.invMassSolve=0,this.invInertiaSolve=new b,this.invInertiaWorldSolve=new Di,this.fixedRotation=typeof e.fixedRotation<"u"?e.fixedRotation:!1,this.angularDamping=typeof e.angularDamping<"u"?e.angularDamping:.01,this.linearFactor=new b(1,1,1),e.linearFactor&&this.linearFactor.copy(e.linearFactor),this.angularFactor=new b(1,1,1),e.angularFactor&&this.angularFactor.copy(e.angularFactor),this.aabb=new Zt,this.aabbNeedsUpdate=!0,this.boundingRadius=0,this.wlambda=new b,this.isTrigger=!!e.isTrigger,e.shape&&this.addShape(e.shape),this.updateMassProperties()}wakeUp(){let e=this.sleepState;this.sleepState=r.AWAKE,this.wakeUpAfterNarrowphase=!1,e===r.SLEEPING&&this.dispatchEvent(r.wakeupEvent)}sleep(){this.sleepState=r.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(),n=this.sleepSpeedLimit**2;t===r.AWAKE&&i<n?(this.sleepState=r.SLEEPY,this.timeLastSleepy=e,this.dispatchEvent(r.sleepyEvent)):t===r.SLEEPY&&i>n?this.wakeUp():t===r.SLEEPY&&e-this.timeLastSleepy>this.sleepTimeLimit&&(this.sleep(),this.dispatchEvent(r.sleepEvent))}}updateSolveMassProperties(){this.sleepState===r.SLEEPING||this.type===r.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 b){return e.vsub(this.position,t),this.quaternion.conjugate().vmult(t,t),t}vectorToLocalFrame(e,t=new b){return this.quaternion.conjugate().vmult(e,t),t}pointToWorldFrame(e,t=new b){return this.quaternion.vmult(e,t),t.vadd(this.position,t),t}vectorToWorldFrame(e,t=new b){return this.quaternion.vmult(e,t),t}addShape(e,t,i){let n=new b,s=new vt;return t&&n.copy(t),i&&s.copy(i),this.shapes.push(e),this.shapeOffsets.push(n),this.shapeOrientations.push(s),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,n=0;for(let s=0;s!==i;s++){let o=e[s];o.updateBoundingSphereRadius();let a=t[s].length(),l=o.boundingSphereRadius;a+l>n&&(n=a+l)}this.boundingRadius=n}updateAABB(){let e=this.shapes,t=this.shapeOffsets,i=this.shapeOrientations,n=e.length,s=P0,o=I0,a=this.quaternion,l=this.aabb,c=N0;for(let u=0;u!==n;u++){let h=e[u];a.vmult(t[u],s),s.vadd(this.position,s),a.mult(i[u],o),h.calculateWorldAABB(s,o,c.lowerBound,c.upperBound),u===0?l.copy(c):l.extend(c)}this.aabbNeedsUpdate=!1}updateInertiaWorld(e){let t=this.invInertia;if(!(t.x===t.y&&t.y===t.z&&!e)){let i=k0,n=O0;i.setRotationFromQuaternion(this.quaternion),i.transpose(n),i.scale(t,i),i.mmult(n,this.invInertiaWorld)}}applyForce(e,t=new b){if(this.type!==r.DYNAMIC)return;this.sleepState===r.SLEEPING&&this.wakeUp();let i=z0;t.cross(e,i),this.force.vadd(e,this.force),this.torque.vadd(i,this.torque)}applyLocalForce(e,t=new b){if(this.type!==r.DYNAMIC)return;let i=V0,n=U0;this.vectorToWorldFrame(e,i),this.vectorToWorldFrame(t,n),this.applyForce(i,n)}applyTorque(e){this.type===r.DYNAMIC&&(this.sleepState===r.SLEEPING&&this.wakeUp(),this.torque.vadd(e,this.torque))}applyImpulse(e,t=new b){if(this.type!==r.DYNAMIC)return;this.sleepState===r.SLEEPING&&this.wakeUp();let i=t,n=H0;n.copy(e),n.scale(this.invMass,n),this.velocity.vadd(n,this.velocity);let s=G0;i.cross(e,s),this.invInertiaWorld.vmult(s,s),this.angularVelocity.vadd(s,this.angularVelocity)}applyLocalImpulse(e,t=new b){if(this.type!==r.DYNAMIC)return;let i=q0,n=W0;this.vectorToWorldFrame(e,i),this.vectorToWorldFrame(t,n),this.applyImpulse(i,n)}updateMassProperties(){let e=$0;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),Fc.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 b;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===r.DYNAMIC||this.type===r.KINEMATIC)||this.sleepState===r.SLEEPING)return;let n=this.velocity,s=this.angularVelocity,o=this.position,a=this.force,l=this.torque,c=this.quaternion,u=this.invMass,h=this.invInertiaWorld,d=this.linearFactor,p=u*e;n.x+=a.x*p*d.x,n.y+=a.y*p*d.y,n.z+=a.z*p*d.z;let m=h.elements,y=this.angularFactor,x=l.x*y.x,g=l.y*y.y,f=l.z*y.z;s.x+=e*(m[0]*x+m[1]*g+m[2]*f),s.y+=e*(m[3]*x+m[4]*g+m[5]*f),s.z+=e*(m[6]*x+m[7]*g+m[8]*f),o.x+=n.x*e,o.y+=n.y*e,o.z+=n.z*e,c.integrate(this.angularVelocity,e,this.angularFactor,c),t&&(i?c.normalizeFast():c.normalize()),this.aabbNeedsUpdate=!0,this.updateInertiaWorld()}};De.idCounter=0;De.COLLIDE_EVENT_NAME="collide";De.DYNAMIC=Uc.DYNAMIC;De.STATIC=Uc.STATIC;De.KINEMATIC=Uc.KINEMATIC;De.AWAKE=Hc.AWAKE;De.SLEEPY=Hc.SLEEPY;De.SLEEPING=Hc.SLEEPING;De.wakeupEvent={type:"wakeup"};De.sleepyEvent={type:"sleepy"};De.sleepEvent={type:"sleep"};var P0=new b,I0=new vt,N0=new Zt,k0=new Di,O0=new Di,z0=new b,V0=new b,U0=new b,H0=new b,G0=new b,q0=new b,W0=new b,$0=new b,Lc=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)||!(t.collisionFilterGroup&e.collisionFilterMask)||(e.type&De.STATIC||e.sleepState===De.SLEEPING)&&(t.type&De.STATIC||t.sleepState===De.SLEEPING))}intersectionTest(e,t,i,n){this.useBoundingBoxes?this.doBoundingBoxBroadphase(e,t,i,n):this.doBoundingSphereBroadphase(e,t,i,n)}doBoundingSphereBroadphase(e,t,i,n){let s=j0;t.position.vsub(e.position,s);let o=(e.boundingRadius+t.boundingRadius)**2;s.lengthSquared()<o&&(i.push(e),n.push(t))}doBoundingBoxBroadphase(e,t,i,n){e.aabbNeedsUpdate&&e.updateAABB(),t.aabbNeedsUpdate&&t.updateAABB(),e.aabb.overlaps(t.aabb)&&(i.push(e),n.push(t))}makePairsUnique(e,t){let i=X0,n=Y0,s=Z0,o=e.length;for(let a=0;a!==o;a++)n[a]=e[a],s[a]=t[a];e.length=0,t.length=0;for(let a=0;a!==o;a++){let l=n[a].id,c=s[a].id,u=l<c?l+","+c:c+","+l;i[u]=a,i.keys.push(u)}for(let a=0;a!==i.keys.length;a++){let l=i.keys.pop(),c=i[l];e.push(n[c]),t.push(s[c]),delete i[l]}}setWorld(e){}static boundingSphereCheck(e,t){let i=new b;e.position.vsub(t.position,i);let n=e.shapes[0],s=t.shapes[0];return Math.pow(n.boundingSphereRadius+s.boundingSphereRadius,2)>i.lengthSquared()}aabbQuery(e,t,i){return console.warn(".aabbQuery is not implemented in this Broadphase subclass."),[]}},j0=new b,X0={keys:[]},Y0=[],Z0=[];var lS=new b,gr=class extends Lc{constructor(){super()}collisionPairs(e,t,i){let n=e.bodies,s=n.length,o,a;for(let l=0;l!==s;l++)for(let c=0;c!==l;c++)o=n[l],a=n[c],this.needBroadphaseCollision(o,a)&&this.intersectionTest(o,a,t,i)}aabbQuery(e,t,i=[]){for(let n=0;n<e.bodies.length;n++){let s=e.bodies[n];s.aabbNeedsUpdate&&s.updateAABB(),s.aabb.overlaps(t)&&i.push(s)}return i}},yr=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 b,this.rayToWorld=new b,this.hitNormalWorld=new b,this.hitPointWorld=new b,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,n,s,o,a){this.rayFromWorld.copy(e),this.rayToWorld.copy(t),this.hitNormalWorld.copy(i),this.hitPointWorld.copy(n),this.shape=s,this.body=o,this.distance=a}},cp,up,hp,dp,pp,fp,mp,Gc={CLOSEST:1,ANY:2,ALL:4};cp=me.types.SPHERE;up=me.types.PLANE;hp=me.types.BOX;dp=me.types.CYLINDER;pp=me.types.CONVEXPOLYHEDRON;fp=me.types.HEIGHTFIELD;mp=me.types.TRIMESH;var ni=class r{get[cp](){return this._intersectSphere}get[up](){return this._intersectPlane}get[hp](){return this._intersectBox}get[dp](){return this._intersectConvex}get[pp](){return this._intersectConvex}get[fp](){return this._intersectHeightfield}get[mp](){return this._intersectTrimesh}constructor(e=new b,t=new b){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 b,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=r.ANY,this.result=new yr,this.hasHit=!1,this.callback=i=>{}}intersectWorld(e,t){return this.mode=t.mode||r.ANY,this.result=t.result||new yr,this.skipBackfaces=!!t.skipBackfaces,this.collisionFilterMask=typeof t.collisionFilterMask<"u"?t.collisionFilterMask:-1,this.collisionFilterGroup=typeof t.collisionFilterGroup<"u"?t.collisionFilterGroup:-1,this.checkCollisionResponse=typeof t.checkCollisionResponse<"u"?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(Kd),Tc.length=0,e.broadphase.aabbQuery(e,Kd,Tc),this.intersectBodies(Tc),this.hasHit}intersectBody(e,t){t&&(this.result=t,this.updateDirection());let i=this.checkCollisionResponse;if(i&&!e.collisionResponse||!(this.collisionFilterGroup&e.collisionFilterMask)||!(e.collisionFilterGroup&this.collisionFilterMask))return;let n=J0,s=K0;for(let o=0,a=e.shapes.length;o<a;o++){let l=e.shapes[o];if(!(i&&!l.collisionResponse)&&(e.quaternion.mult(e.shapeOrientations[o],s),e.quaternion.vmult(e.shapeOffsets[o],n),n.vadd(e.position,n),this.intersectShape(l,s,n,e),this.result.shouldStop))break}}intersectBodies(e,t){t&&(this.result=t,this.updateDirection());for(let i=0,n=e.length;!this.result.shouldStop&&i<n;i++)this.intersectBody(e[i])}updateDirection(){this.to.vsub(this.from,this.direction),this.direction.normalize()}intersectShape(e,t,i,n){let s=this.from;if(dy(s,this.direction,i)>e.boundingSphereRadius)return;let a=this[e.type];a&&a.call(this,e,t,i,n,e)}_intersectBox(e,t,i,n,s){return this._intersectConvex(e.convexPolyhedronRepresentation,t,i,n,s)}_intersectPlane(e,t,i,n,s){let o=this.from,a=this.to,l=this.direction,c=new b(0,0,1);t.vmult(c,c);let u=new b;o.vsub(i,u);let h=u.dot(c);a.vsub(i,u);let d=u.dot(c);if(h*d>0||o.distanceTo(a)<h)return;let p=c.dot(l);if(Math.abs(p)<this.precision)return;let m=new b,y=new b,x=new b;o.vsub(i,m);let g=-c.dot(m)/p;l.scale(g,y),o.vadd(y,x),this.reportIntersection(c,x,s,n,-1)}getAABB(e){let{lowerBound:t,upperBound:i}=e,n=this.to,s=this.from;t.x=Math.min(n.x,s.x),t.y=Math.min(n.y,s.y),t.z=Math.min(n.z,s.z),i.x=Math.max(n.x,s.x),i.y=Math.max(n.y,s.y),i.z=Math.max(n.z,s.z)}_intersectHeightfield(e,t,i,n,s){e.data,e.elementSize;let o=Q0;o.from.copy(this.from),o.to.copy(this.to),Ge.pointToLocalFrame(i,t,o.from,o.from),Ge.pointToLocalFrame(i,t,o.to,o.to),o.updateDirection();let a=ey,l,c,u,h;l=c=0,u=h=e.data.length-1;let d=new Zt;o.getAABB(d),e.getIndexOfPosition(d.lowerBound.x,d.lowerBound.y,a,!0),l=Math.max(l,a[0]),c=Math.max(c,a[1]),e.getIndexOfPosition(d.upperBound.x,d.upperBound.y,a,!0),u=Math.min(u,a[0]+1),h=Math.min(h,a[1]+1);for(let p=l;p<u;p++)for(let m=c;m<h;m++){if(this.result.shouldStop)return;if(e.getAabbAtIndex(p,m,d),!!d.overlapsRay(o)){if(e.getConvexTrianglePillar(p,m,!1),Ge.pointToWorldFrame(i,t,e.pillarOffset,Oo),this._intersectConvex(e.pillarConvex,t,Oo,n,s,Qd),this.result.shouldStop)return;e.getConvexTrianglePillar(p,m,!0),Ge.pointToWorldFrame(i,t,e.pillarOffset,Oo),this._intersectConvex(e.pillarConvex,t,Oo,n,s,Qd)}}}_intersectSphere(e,t,i,n,s){let o=this.from,a=this.to,l=e.radius,c=(a.x-o.x)**2+(a.y-o.y)**2+(a.z-o.z)**2,u=2*((a.x-o.x)*(o.x-i.x)+(a.y-o.y)*(o.y-i.y)+(a.z-o.z)*(o.z-i.z)),h=(o.x-i.x)**2+(o.y-i.y)**2+(o.z-i.z)**2-l**2,d=u**2-4*c*h,p=ty,m=iy;if(!(d<0))if(d===0)o.lerp(a,d,p),p.vsub(i,m),m.normalize(),this.reportIntersection(m,p,s,n,-1);else{let y=(-u-Math.sqrt(d))/(2*c),x=(-u+Math.sqrt(d))/(2*c);if(y>=0&&y<=1&&(o.lerp(a,y,p),p.vsub(i,m),m.normalize(),this.reportIntersection(m,p,s,n,-1)),this.result.shouldStop)return;x>=0&&x<=1&&(o.lerp(a,x,p),p.vsub(i,m),m.normalize(),this.reportIntersection(m,p,s,n,-1))}}_intersectConvex(e,t,i,n,s,o){let a=ny,l=ep,c=o&&o.faceList||null,u=e.faces,h=e.vertices,d=e.faceNormals,p=this.direction,m=this.from,y=this.to,x=m.distanceTo(y),g=c?c.length:u.length,f=this.result;for(let E=0;!f.shouldStop&&E<g;E++){let w=c?c[E]:E,_=u[w],M=d[w],T=t,z=i;l.copy(h[_[0]]),T.vmult(l,l),l.vadd(z,l),l.vsub(m,l),T.vmult(M,a);let W=p.dot(a);if(Math.abs(W)<this.precision)continue;let A=a.dot(l)/W;if(!(A<0)){p.scale(A,Ut),Ut.vadd(m,Ut),ci.copy(h[_[0]]),T.vmult(ci,ci),z.vadd(ci,ci);for(let v=1;!f.shouldStop&&v<_.length-1;v++){Si.copy(h[_[v]]),Mi.copy(h[_[v+1]]),T.vmult(Si,Si),T.vmult(Mi,Mi),z.vadd(Si,Si),z.vadd(Mi,Mi);let R=Ut.distanceTo(m);!(r.pointInTriangle(Ut,ci,Si,Mi)||r.pointInTriangle(Ut,Si,ci,Mi))||R>x||this.reportIntersection(a,Ut,s,n,w)}}}}_intersectTrimesh(e,t,i,n,s,o){let a=sy,l=uy,c=hy,u=ep,h=ry,d=oy,p=ay,m=cy,y=ly,x=e.indices;e.vertices;let g=this.from,f=this.to,E=this.direction;c.position.copy(i),c.quaternion.copy(t),Ge.vectorToLocalFrame(i,t,E,h),Ge.pointToLocalFrame(i,t,g,d),Ge.pointToLocalFrame(i,t,f,p),p.x*=e.scale.x,p.y*=e.scale.y,p.z*=e.scale.z,d.x*=e.scale.x,d.y*=e.scale.y,d.z*=e.scale.z,p.vsub(d,h),h.normalize();let w=d.distanceSquared(p);e.tree.rayQuery(this,c,l);for(let _=0,M=l.length;!this.result.shouldStop&&_!==M;_++){let T=l[_];e.getNormal(T,a),e.getVertex(x[T*3],ci),ci.vsub(d,u);let z=h.dot(a),W=a.dot(u)/z;if(W<0)continue;h.scale(W,Ut),Ut.vadd(d,Ut),e.getVertex(x[T*3+1],Si),e.getVertex(x[T*3+2],Mi);let A=Ut.distanceSquared(d);!(r.pointInTriangle(Ut,Si,ci,Mi)||r.pointInTriangle(Ut,ci,Si,Mi))||A>w||(Ge.vectorToWorldFrame(t,a,y),Ge.pointToWorldFrame(i,t,Ut,m),this.reportIntersection(y,m,s,n,T))}l.length=0}reportIntersection(e,t,i,n,s){let o=this.from,a=this.to,l=o.distanceTo(t),c=this.result;if(!(this.skipBackfaces&&e.dot(this.direction)>0))switch(c.hitFaceIndex=typeof s<"u"?s:-1,this.mode){case r.ALL:this.hasHit=!0,c.set(o,a,e,t,i,n,l),c.hasHit=!0,this.callback(c);break;case r.CLOSEST:(l<c.distance||!c.hasHit)&&(this.hasHit=!0,c.hasHit=!0,c.set(o,a,e,t,i,n,l));break;case r.ANY:this.hasHit=!0,c.hasHit=!0,c.set(o,a,e,t,i,n,l),c.shouldStop=!0;break}}static pointInTriangle(e,t,i,n){n.vsub(t,Nn),i.vsub(t,hr),e.vsub(t,Cc);let s=Nn.dot(Nn),o=Nn.dot(hr),a=Nn.dot(Cc),l=hr.dot(hr),c=hr.dot(Cc),u,h;return(u=l*a-o*c)>=0&&(h=s*c-o*a)>=0&&u+h<s*l-o*o}};ni.CLOSEST=Gc.CLOSEST;ni.ANY=Gc.ANY;ni.ALL=Gc.ALL;var Kd=new Zt,Tc=[],hr=new b,Cc=new b,J0=new b,K0=new vt,Ut=new b,ci=new b,Si=new b,Mi=new b,Qd={faceList:[0]},Oo=new b,Q0=new ni,ey=[],ty=new b,iy=new b,ny=new b,ep=new b,sy=new b,ry=new b,oy=new b,ay=new b,ly=new b,cy=new b;new Zt;var uy=[],hy=new Ge,Nn=new b,zo=new b;function dy(r,e,t){t.vsub(r,Nn);let i=Nn.dot(e);return e.scale(i,zo),zo.vadd(r,zo),t.distanceTo(zo)}var Wo=class{static defaults(e={},t){for(let i in t)i in e||(e[i]=t[i]);return e}},Bc=class r{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=Wo.defaults(i,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=e,this.bodyB=t,this.id=r.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}};Bc.idCounter=0;var $o=class{constructor(){this.spatial=void 0,this.rotational=void 0,this.spatial=new b,this.rotational=new b}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)}},xr=class r{constructor(e,t,i=-1e6,n=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=r.idCounter++,this.minForce=i,this.maxForce=n,this.bi=e,this.bj=t,this.a=0,this.b=0,this.eps=0,this.jacobianElementA=new $o,this.jacobianElementB=new $o,this.enabled=!0,this.multiplier=0,this.setSpookParams(1e7,4,1/60)}setSpookParams(e,t,i){let n=t,s=e,o=i;this.a=4/(o*(1+4*n)),this.b=4*n/(1+4*n),this.eps=4/(o*o*s*(1+4*n))}computeB(e,t,i){let n=this.computeGW(),s=this.computeGq(),o=this.computeGiMf();return-s*e-n*t-o*i}computeGq(){let e=this.jacobianElementA,t=this.jacobianElementB,i=this.bi,n=this.bj,s=i.position,o=n.position;return e.spatial.dot(s)+t.spatial.dot(o)}computeGW(){let e=this.jacobianElementA,t=this.jacobianElementB,i=this.bi,n=this.bj,s=i.velocity,o=n.velocity,a=i.angularVelocity,l=n.angularVelocity;return e.multiplyVectors(s,a)+t.multiplyVectors(o,l)}computeGWlambda(){let e=this.jacobianElementA,t=this.jacobianElementB,i=this.bi,n=this.bj,s=i.vlambda,o=n.vlambda,a=i.wlambda,l=n.wlambda;return e.multiplyVectors(s,a)+t.multiplyVectors(o,l)}computeGiMf(){let e=this.jacobianElementA,t=this.jacobianElementB,i=this.bi,n=this.bj,s=i.force,o=i.torque,a=n.force,l=n.torque,c=i.invMassSolve,u=n.invMassSolve;return s.scale(c,tp),a.scale(u,ip),i.invInertiaWorldSolve.vmult(o,np),n.invInertiaWorldSolve.vmult(l,sp),e.multiplyVectors(tp,np)+t.multiplyVectors(ip,sp)}computeGiMGt(){let e=this.jacobianElementA,t=this.jacobianElementB,i=this.bi,n=this.bj,s=i.invMassSolve,o=n.invMassSolve,a=i.invInertiaWorldSolve,l=n.invInertiaWorldSolve,c=s+o;return a.vmult(e.rotational,Vo),c+=Vo.dot(e.rotational),l.vmult(t.rotational,Vo),c+=Vo.dot(t.rotational),c}addToWlambda(e){let t=this.jacobianElementA,i=this.jacobianElementB,n=this.bi,s=this.bj,o=py;n.vlambda.addScaledVector(n.invMassSolve*e,t.spatial,n.vlambda),s.vlambda.addScaledVector(s.invMassSolve*e,i.spatial,s.vlambda),n.invInertiaWorldSolve.vmult(t.rotational,o),n.wlambda.addScaledVector(e,o,n.wlambda),s.invInertiaWorldSolve.vmult(i.rotational,o),s.wlambda.addScaledVector(e,o,s.wlambda)}computeC(){return this.computeGiMGt()+this.eps}};xr.idCounter=0;var tp=new b,ip=new b,np=new b,sp=new b,Vo=new b,py=new b,Pc=class extends xr{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 b,this.rj=new b,this.ni=new b}computeB(e){let t=this.a,i=this.b,n=this.bi,s=this.bj,o=this.ri,a=this.rj,l=fy,c=my,u=n.velocity,h=n.angularVelocity;n.force,n.torque;let d=s.velocity,p=s.angularVelocity;s.force,s.torque;let m=gy,y=this.jacobianElementA,x=this.jacobianElementB,g=this.ni;o.cross(g,l),a.cross(g,c),g.negate(y.spatial),l.negate(y.rotational),x.spatial.copy(g),x.rotational.copy(c),m.copy(s.position),m.vadd(a,m),m.vsub(n.position,m),m.vsub(o,m);let f=g.dot(m),E=this.restitution+1,w=E*d.dot(g)-E*u.dot(g)+p.dot(c)-h.dot(l),_=this.computeGiMf();return-f*t-w*i-e*_}getImpactVelocityAlongNormal(){let e=yy,t=xy,i=vy,n=wy,s=by;return this.bi.position.vadd(this.ri,i),this.bj.position.vadd(this.rj,n),this.bi.getVelocityAtWorldPoint(i,e),this.bj.getVelocityAtWorldPoint(n,t),e.vsub(t,s),this.ni.dot(s)}},fy=new b,my=new b,gy=new b,yy=new b,xy=new b,vy=new b,wy=new b,by=new b;var cS=new b,uS=new b;var hS=new b,dS=new b;var pS=new b,fS=new b,jo=class extends xr{constructor(e,t,i){super(e,t,-i,i),this.ri=void 0,this.rj=void 0,this.t=void 0,this.ri=new b,this.rj=new b,this.t=new b}computeB(e){this.a;let t=this.b;this.bi,this.bj;let i=this.ri,n=this.rj,s=_y,o=Ey,a=this.t;i.cross(a,s),n.cross(a,o);let l=this.jacobianElementA,c=this.jacobianElementB;a.negate(l.spatial),s.negate(l.rotational),c.spatial.copy(a),c.rotational.copy(o);let u=this.computeGW(),h=this.computeGiMf();return-u*t-e*h}},_y=new b,Ey=new b,ln=class r{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=Wo.defaults(i,{friction:.3,restitution:.3,contactEquationStiffness:1e7,contactEquationRelaxation:3,frictionEquationStiffness:1e7,frictionEquationRelaxation:3}),this.id=r.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}};ln.idCounter=0;var cn=class r{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=r.idCounter++,this.friction=typeof e.friction<"u"?e.friction:-1,this.restitution=typeof e.restitution<"u"?e.restitution:-1}};cn.idCounter=0;var mS=new b,gS=new b,yS=new b,xS=new b,vS=new b,wS=new b,bS=new b,_S=new b,ES=new b,AS=new b,SS=new b;var MS=new b,DS=new b;var TS=new b,CS=new b,RS=new b;new ni;var FS=new b,LS=new b,BS=[new b(1,0,0),new b(0,1,0),new b(0,0,1)],PS=new b;var IS=new b,NS=new b,kS=new b;var OS=new b,zS=new b,VS=new b,US=new b;var HS=new b,GS=new b,qS=new b;var WS=new b,$S=new b;var jS=new b,XS=new b,YS=new b,ZS=new b,JS=new b,KS=new b,QS=new b;var Hi=class extends me{constructor(){super({type:me.types.PLANE}),this.worldNormal=void 0,this.worldNormalNeedsUpdate=void 0,this.boundingSphereRadius=void 0,this.worldNormal=new b,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 b){return t}volume(){return Number.MAX_VALUE}calculateWorldAABB(e,t,i,n){ki.set(0,0,1),t.vmult(ki,ki);let s=Number.MAX_VALUE;i.set(-s,-s,-s),n.set(s,s,s),ki.x===1?n.x=e.x:ki.x===-1&&(i.x=e.x),ki.y===1?n.y=e.y:ki.y===-1&&(i.y=e.y),ki.z===1?n.z=e.z:ki.z===-1&&(i.z=e.z)}updateBoundingSphereRadius(){this.boundingSphereRadius=Number.MAX_VALUE}},ki=new b;var eM=new b,tM=new b,iM=new b,nM=new b,sM=new b,rM=new b,oM=new b,aM=new b,lM=new b;var cM=new b,uM=new Zt;var hM=new b,dM=new Zt,pM=new b,fM=new b,mM=new b,gM=new b,yM=new b,xM=new b,vM=new b,wM=new Zt,bM=new b,_M=new Ge,EM=new Zt,Ic=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}},Nc=class extends Ic{constructor(){super(),this.iterations=void 0,this.tolerance=void 0,this.iterations=10,this.tolerance=1e-7}solve(e,t){let i=0,n=this.iterations,s=this.tolerance*this.tolerance,o=this.equations,a=o.length,l=t.bodies,c=l.length,u=e,h,d,p,m,y,x;if(a!==0)for(let w=0;w!==c;w++)l[w].updateSolveMassProperties();let g=Sy,f=My,E=Ay;g.length=a,f.length=a,E.length=a;for(let w=0;w!==a;w++){let _=o[w];E[w]=0,f[w]=_.computeB(u),g[w]=1/_.computeC()}if(a!==0){for(let M=0;M!==c;M++){let T=l[M],z=T.vlambda,W=T.wlambda;z.set(0,0,0),W.set(0,0,0)}for(i=0;i!==n;i++){m=0;for(let M=0;M!==a;M++){let T=o[M];h=f[M],d=g[M],x=E[M],y=T.computeGWlambda(),p=d*(h-y-T.eps*x),x+p<T.minForce?p=T.minForce-x:x+p>T.maxForce&&(p=T.maxForce-x),E[M]+=p,m+=p>0?p:-p,T.addToWlambda(p)}if(m*m<s)break}for(let M=0;M!==c;M++){let T=l[M],z=T.velocity,W=T.angularVelocity;T.vlambda.vmul(T.linearFactor,T.vlambda),z.vadd(T.vlambda,z),T.wlambda.vmul(T.angularFactor,T.wlambda),W.vadd(T.wlambda,W)}let w=o.length,_=1/u;for(;w--;)o[w].multiplier=E[w]*_}return i}},Ay=[],Sy=[],My=[];var AM=De.STATIC;var kc=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}},Oc=class extends kc{constructor(...e){super(...e),this.type=b}constructObject(){return new b}},gp,yp,xp,vp,wp,bp,_p,Ep,Ap,Sp,Mp,Dp,Tp,Cp,Rp,Fp,Lp,Bp,Pp,Ip,Np,kp,Op,zp,Vp,tt={sphereSphere:me.types.SPHERE,spherePlane:me.types.SPHERE|me.types.PLANE,boxBox:me.types.BOX|me.types.BOX,sphereBox:me.types.SPHERE|me.types.BOX,planeBox:me.types.PLANE|me.types.BOX,convexConvex:me.types.CONVEXPOLYHEDRON,sphereConvex:me.types.SPHERE|me.types.CONVEXPOLYHEDRON,planeConvex:me.types.PLANE|me.types.CONVEXPOLYHEDRON,boxConvex:me.types.BOX|me.types.CONVEXPOLYHEDRON,sphereHeightfield:me.types.SPHERE|me.types.HEIGHTFIELD,boxHeightfield:me.types.BOX|me.types.HEIGHTFIELD,convexHeightfield:me.types.CONVEXPOLYHEDRON|me.types.HEIGHTFIELD,sphereParticle:me.types.PARTICLE|me.types.SPHERE,planeParticle:me.types.PLANE|me.types.PARTICLE,boxParticle:me.types.BOX|me.types.PARTICLE,convexParticle:me.types.PARTICLE|me.types.CONVEXPOLYHEDRON,cylinderCylinder:me.types.CYLINDER,sphereCylinder:me.types.SPHERE|me.types.CYLINDER,planeCylinder:me.types.PLANE|me.types.CYLINDER,boxCylinder:me.types.BOX|me.types.CYLINDER,convexCylinder:me.types.CONVEXPOLYHEDRON|me.types.CYLINDER,heightfieldCylinder:me.types.HEIGHTFIELD|me.types.CYLINDER,particleCylinder:me.types.PARTICLE|me.types.CYLINDER,sphereTrimesh:me.types.SPHERE|me.types.TRIMESH,planeTrimesh:me.types.PLANE|me.types.TRIMESH};gp=tt.sphereSphere;yp=tt.spherePlane;xp=tt.boxBox;vp=tt.sphereBox;wp=tt.planeBox;bp=tt.convexConvex;_p=tt.sphereConvex;Ep=tt.planeConvex;Ap=tt.boxConvex;Sp=tt.sphereHeightfield;Mp=tt.boxHeightfield;Dp=tt.convexHeightfield;Tp=tt.sphereParticle;Cp=tt.planeParticle;Rp=tt.boxParticle;Fp=tt.convexParticle;Lp=tt.cylinderCylinder;Bp=tt.sphereCylinder;Pp=tt.planeCylinder;Ip=tt.boxCylinder;Np=tt.convexCylinder;kp=tt.heightfieldCylinder;Op=tt.particleCylinder;zp=tt.sphereTrimesh;Vp=tt.planeTrimesh;var zc=class{get[gp](){return this.sphereSphere}get[yp](){return this.spherePlane}get[xp](){return this.boxBox}get[vp](){return this.sphereBox}get[wp](){return this.planeBox}get[bp](){return this.convexConvex}get[_p](){return this.sphereConvex}get[Ep](){return this.planeConvex}get[Ap](){return this.boxConvex}get[Sp](){return this.sphereHeightfield}get[Mp](){return this.boxHeightfield}get[Dp](){return this.convexHeightfield}get[Tp](){return this.sphereParticle}get[Cp](){return this.planeParticle}get[Rp](){return this.boxParticle}get[Fp](){return this.convexParticle}get[Lp](){return this.convexConvex}get[Bp](){return this.sphereConvex}get[Pp](){return this.planeConvex}get[Ip](){return this.boxConvex}get[Np](){return this.convexConvex}get[kp](){return this.heightfieldCylinder}get[Op](){return this.particleCylinder}get[zp](){return this.sphereTrimesh}get[Vp](){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 Oc,this.world=e,this.currentContactMaterial=e.defaultContactMaterial,this.enableFrictionReduction=!1}createContactEquation(e,t,i,n,s,o){let a;this.contactPointPool.length?(a=this.contactPointPool.pop(),a.bi=e,a.bj=t):a=new Pc(e,t),a.enabled=e.collisionResponse&&t.collisionResponse&&i.collisionResponse&&n.collisionResponse;let l=this.currentContactMaterial;a.restitution=l.restitution,a.setSpookParams(l.contactEquationStiffness,l.contactEquationRelaxation,this.world.dt);let c=i.material||e.material,u=n.material||t.material;return c&&u&&c.restitution>=0&&u.restitution>=0&&(a.restitution=c.restitution*u.restitution),a.si=s||i,a.sj=o||n,a}createFrictionEquationsFromContact(e,t){let i=e.bi,n=e.bj,s=e.si,o=e.sj,a=this.world,l=this.currentContactMaterial,c=l.friction,u=s.material||i.material,h=o.material||n.material;if(u&&h&&u.friction>=0&&h.friction>=0&&(c=u.friction*h.friction),c>0){let d=c*a.gravity.length(),p=i.invMass+n.invMass;p>0&&(p=1/p);let m=this.frictionEquationPool,y=m.length?m.pop():new jo(i,n,d*p),x=m.length?m.pop():new jo(i,n,d*p);return y.bi=x.bi=i,y.bj=x.bj=n,y.minForce=x.minForce=-d*p,y.maxForce=x.maxForce=d*p,y.ri.copy(e.ri),y.rj.copy(e.rj),x.ri.copy(e.ri),x.rj.copy(e.rj),e.ni.tangents(y.t,x.t),y.setSpookParams(l.frictionEquationStiffness,l.frictionEquationRelaxation,a.dt),x.setSpookParams(l.frictionEquationStiffness,l.frictionEquationRelaxation,a.dt),y.enabled=x.enabled=e.enabled,t.push(y,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],n=this.frictionResult[this.frictionResult.length-1];In.setZero(),ss.setZero(),rs.setZero();let s=t.bi;t.bj;for(let a=0;a!==e;a++)t=this.result[this.result.length-1-a],t.bi!==s?(In.vadd(t.ni,In),ss.vadd(t.ri,ss),rs.vadd(t.rj,rs)):(In.vsub(t.ni,In),ss.vadd(t.rj,ss),rs.vadd(t.ri,rs));let o=1/e;ss.scale(o,i.ri),rs.scale(o,i.rj),n.ri.copy(i.ri),n.rj.copy(i.rj),In.normalize(),In.tangents(i.t,n.t)}getContacts(e,t,i,n,s,o,a){this.contactPointPool=s,this.frictionEquationPool=a,this.result=n,this.frictionResult=o;let l=Cy,c=Ry,u=Dy,h=Ty;for(let d=0,p=e.length;d!==p;d++){let m=e[d],y=t[d],x=null;m.material&&y.material&&(x=i.getContactMaterial(m.material,y.material)||null);let g=m.type&De.KINEMATIC&&y.type&De.STATIC||m.type&De.STATIC&&y.type&De.KINEMATIC||m.type&De.KINEMATIC&&y.type&De.KINEMATIC;for(let f=0;f<m.shapes.length;f++){m.quaternion.mult(m.shapeOrientations[f],l),m.quaternion.vmult(m.shapeOffsets[f],u),u.vadd(m.position,u);let E=m.shapes[f];for(let w=0;w<y.shapes.length;w++){y.quaternion.mult(y.shapeOrientations[w],c),y.quaternion.vmult(y.shapeOffsets[w],h),h.vadd(y.position,h);let _=y.shapes[w];if(!(E.collisionFilterMask&_.collisionFilterGroup&&_.collisionFilterMask&E.collisionFilterGroup)||u.distanceTo(h)>E.boundingSphereRadius+_.boundingSphereRadius)continue;let M=null;E.material&&_.material&&(M=i.getContactMaterial(E.material,_.material)||null),this.currentContactMaterial=M||x||i.defaultContactMaterial;let T=E.type|_.type,z=this[T];if(z){let W=!1;E.type<_.type?W=z.call(this,E,_,u,h,l,c,m,y,E,_,g):W=z.call(this,_,E,h,u,c,l,y,m,E,_,g),W&&g&&(i.shapeOverlapKeeper.set(E.id,_.id),i.bodyOverlapKeeper.set(m.id,y.id))}}}}}sphereSphere(e,t,i,n,s,o,a,l,c,u,h){if(h)return i.distanceSquared(n)<(e.radius+t.radius)**2;let d=this.createContactEquation(a,l,e,t,c,u);n.vsub(i,d.ni),d.ni.normalize(),d.ri.copy(d.ni),d.rj.copy(d.ni),d.ri.scale(e.radius,d.ri),d.rj.scale(-t.radius,d.rj),d.ri.vadd(i,d.ri),d.ri.vsub(a.position,d.ri),d.rj.vadd(n,d.rj),d.rj.vsub(l.position,d.rj),this.result.push(d),this.createFrictionEquationsFromContact(d,this.frictionResult)}spherePlane(e,t,i,n,s,o,a,l,c,u,h){let d=this.createContactEquation(a,l,e,t,c,u);if(d.ni.set(0,0,1),o.vmult(d.ni,d.ni),d.ni.negate(d.ni),d.ni.normalize(),d.ni.scale(e.radius,d.ri),i.vsub(n,Uo),d.ni.scale(d.ni.dot(Uo),rp),Uo.vsub(rp,d.rj),-Uo.dot(d.ni)<=e.radius){if(h)return!0;let p=d.ri,m=d.rj;p.vadd(i,p),p.vsub(a.position,p),m.vadd(n,m),m.vsub(l.position,m),this.result.push(d),this.createFrictionEquationsFromContact(d,this.frictionResult)}}boxBox(e,t,i,n,s,o,a,l,c,u,h){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,n,s,o,a,l,e,t,h)}sphereBox(e,t,i,n,s,o,a,l,c,u,h){let d=this.v3pool,p=ix;i.vsub(n,Ho),t.getSideNormals(p,o);let m=e.radius,y=!1,x=sx,g=rx,f=ox,E=null,w=0,_=0,M=0,T=null;for(let C=0,N=p.length;C!==N&&y===!1;C++){let k=Qy;k.copy(p[C]);let V=k.length();k.normalize();let U=Ho.dot(k);if(U<V+m&&U>0){let q=ex,j=tx;q.copy(p[(C+1)%3]),j.copy(p[(C+2)%3]);let ne=q.length(),ae=j.length();q.normalize(),j.normalize();let H=Ho.dot(q),Te=Ho.dot(j);if(H<ne&&H>-ne&&Te<ae&&Te>-ae){let ue=Math.abs(U-V-m);if((T===null||ue<T)&&(T=ue,_=H,M=Te,E=V,x.copy(k),g.copy(q),f.copy(j),w++,h))return!0}}}if(w){y=!0;let C=this.createContactEquation(a,l,e,t,c,u);x.scale(-m,C.ri),C.ni.copy(x),C.ni.negate(C.ni),x.scale(E,x),g.scale(_,g),x.vadd(g,x),f.scale(M,f),x.vadd(f,C.rj),C.ri.vadd(i,C.ri),C.ri.vsub(a.position,C.ri),C.rj.vadd(n,C.rj),C.rj.vsub(l.position,C.rj),this.result.push(C),this.createFrictionEquationsFromContact(C,this.frictionResult)}let z=d.get(),W=nx;for(let C=0;C!==2&&!y;C++)for(let N=0;N!==2&&!y;N++)for(let k=0;k!==2&&!y;k++)if(z.set(0,0,0),C?z.vadd(p[0],z):z.vsub(p[0],z),N?z.vadd(p[1],z):z.vsub(p[1],z),k?z.vadd(p[2],z):z.vsub(p[2],z),n.vadd(z,W),W.vsub(i,W),W.lengthSquared()<m*m){if(h)return!0;y=!0;let V=this.createContactEquation(a,l,e,t,c,u);V.ri.copy(W),V.ri.normalize(),V.ni.copy(V.ri),V.ri.scale(m,V.ri),V.rj.copy(z),V.ri.vadd(i,V.ri),V.ri.vsub(a.position,V.ri),V.rj.vadd(n,V.rj),V.rj.vsub(l.position,V.rj),this.result.push(V),this.createFrictionEquationsFromContact(V,this.frictionResult)}d.release(z),z=null;let A=d.get(),v=d.get(),R=d.get(),S=d.get(),B=d.get(),L=p.length;for(let C=0;C!==L&&!y;C++)for(let N=0;N!==L&&!y;N++)if(C%3!==N%3){p[N].cross(p[C],A),A.normalize(),p[C].vadd(p[N],v),R.copy(i),R.vsub(v,R),R.vsub(n,R);let k=R.dot(A);A.scale(k,S);let V=0;for(;V===C%3||V===N%3;)V++;B.copy(i),B.vsub(S,B),B.vsub(v,B),B.vsub(n,B);let U=Math.abs(k),q=B.length();if(U<p[V].length()&&q<m){if(h)return!0;y=!0;let j=this.createContactEquation(a,l,e,t,c,u);v.vadd(S,j.rj),j.rj.copy(j.rj),B.negate(j.ni),j.ni.normalize(),j.ri.copy(j.rj),j.ri.vadd(n,j.ri),j.ri.vsub(i,j.ri),j.ri.normalize(),j.ri.scale(m,j.ri),j.ri.vadd(i,j.ri),j.ri.vsub(a.position,j.ri),j.rj.vadd(n,j.rj),j.rj.vsub(l.position,j.rj),this.result.push(j),this.createFrictionEquationsFromContact(j,this.frictionResult)}}d.release(A,v,R,S,B)}planeBox(e,t,i,n,s,o,a,l,c,u,h){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,t.convexPolyhedronRepresentation.id=t.id,this.planeConvex(e,t.convexPolyhedronRepresentation,i,n,s,o,a,l,e,t,h)}convexConvex(e,t,i,n,s,o,a,l,c,u,h,d,p){let m=bx;if(!(i.distanceTo(n)>e.boundingSphereRadius+t.boundingSphereRadius)&&e.findSeparatingAxis(t,i,s,n,o,m,d,p)){let y=[],x=_x;e.clipAgainstHull(i,s,t,n,o,m,-100,100,y);let g=0;for(let f=0;f!==y.length;f++){if(h)return!0;let E=this.createContactEquation(a,l,e,t,c,u),w=E.ri,_=E.rj;m.negate(E.ni),y[f].normal.negate(x),x.scale(y[f].depth,x),y[f].point.vadd(x,w),_.copy(y[f].point),w.vsub(i,w),_.vsub(n,_),w.vadd(i,w),w.vsub(a.position,w),_.vadd(n,_),_.vsub(l.position,_),this.result.push(E),g++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(E,this.frictionResult)}this.enableFrictionReduction&&g&&this.createFrictionFromAverage(g)}}sphereConvex(e,t,i,n,s,o,a,l,c,u,h){let d=this.v3pool;i.vsub(n,ax);let p=t.faceNormals,m=t.faces,y=t.vertices,x=e.radius,g=!1;for(let f=0;f!==y.length;f++){let E=y[f],w=hx;o.vmult(E,w),n.vadd(w,w);let _=ux;if(w.vsub(i,_),_.lengthSquared()<x*x){if(h)return!0;g=!0;let M=this.createContactEquation(a,l,e,t,c,u);M.ri.copy(_),M.ri.normalize(),M.ni.copy(M.ri),M.ri.scale(x,M.ri),w.vsub(n,M.rj),M.ri.vadd(i,M.ri),M.ri.vsub(a.position,M.ri),M.rj.vadd(n,M.rj),M.rj.vsub(l.position,M.rj),this.result.push(M),this.createFrictionEquationsFromContact(M,this.frictionResult);return}}for(let f=0,E=m.length;f!==E&&g===!1;f++){let w=p[f],_=m[f],M=dx;o.vmult(w,M);let T=px;o.vmult(y[_[0]],T),T.vadd(n,T);let z=fx;M.scale(-x,z),i.vadd(z,z);let W=mx;z.vsub(T,W);let A=W.dot(M),v=gx;if(i.vsub(T,v),A<0&&v.dot(M)>0){let R=[];for(let S=0,B=_.length;S!==B;S++){let L=d.get();o.vmult(y[_[S]],L),n.vadd(L,L),R.push(L)}if(Ky(R,M,i)){if(h)return!0;g=!0;let S=this.createContactEquation(a,l,e,t,c,u);M.scale(-x,S.ri),M.negate(S.ni);let B=d.get();M.scale(-A,B);let L=d.get();M.scale(-x,L),i.vsub(n,S.rj),S.rj.vadd(L,S.rj),S.rj.vadd(B,S.rj),S.rj.vadd(n,S.rj),S.rj.vsub(l.position,S.rj),S.ri.vadd(i,S.ri),S.ri.vsub(a.position,S.ri),d.release(B),d.release(L),this.result.push(S),this.createFrictionEquationsFromContact(S,this.frictionResult);for(let C=0,N=R.length;C!==N;C++)d.release(R[C]);return}else for(let S=0;S!==_.length;S++){let B=d.get(),L=d.get();o.vmult(y[_[(S+1)%_.length]],B),o.vmult(y[_[(S+2)%_.length]],L),n.vadd(B,B),n.vadd(L,L);let C=lx;L.vsub(B,C);let N=cx;C.unit(N);let k=d.get(),V=d.get();i.vsub(B,V);let U=V.dot(N);N.scale(U,k),k.vadd(B,k);let q=d.get();if(k.vsub(i,q),U>0&&U*U<C.lengthSquared()&&q.lengthSquared()<x*x){if(h)return!0;let j=this.createContactEquation(a,l,e,t,c,u);k.vsub(n,j.rj),k.vsub(i,j.ni),j.ni.normalize(),j.ni.scale(x,j.ri),j.rj.vadd(n,j.rj),j.rj.vsub(l.position,j.rj),j.ri.vadd(i,j.ri),j.ri.vsub(a.position,j.ri),this.result.push(j),this.createFrictionEquationsFromContact(j,this.frictionResult);for(let ne=0,ae=R.length;ne!==ae;ne++)d.release(R[ne]);d.release(B),d.release(L),d.release(k),d.release(q),d.release(V);return}d.release(B),d.release(L),d.release(k),d.release(q),d.release(V)}for(let S=0,B=R.length;S!==B;S++)d.release(R[S])}}}planeConvex(e,t,i,n,s,o,a,l,c,u,h){let d=yx,p=xx;p.set(0,0,1),s.vmult(p,p);let m=0,y=vx;for(let x=0;x!==t.vertices.length;x++)if(d.copy(t.vertices[x]),o.vmult(d,d),n.vadd(d,d),d.vsub(i,y),p.dot(y)<=0){if(h)return!0;let f=this.createContactEquation(a,l,e,t,c,u),E=wx;p.scale(p.dot(y),E),d.vsub(E,E),E.vsub(i,f.ri),f.ni.copy(p),d.vsub(n,f.rj),f.ri.vadd(i,f.ri),f.ri.vsub(a.position,f.ri),f.rj.vadd(n,f.rj),f.rj.vsub(l.position,f.rj),this.result.push(f),m++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(f,this.frictionResult)}this.enableFrictionReduction&&m&&this.createFrictionFromAverage(m)}boxConvex(e,t,i,n,s,o,a,l,c,u,h){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexConvex(e.convexPolyhedronRepresentation,t,i,n,s,o,a,l,e,t,h)}sphereHeightfield(e,t,i,n,s,o,a,l,c,u,h){let d=t.data,p=e.radius,m=t.elementSize,y=Px,x=Bx;Ge.pointToLocalFrame(n,o,i,x);let g=Math.floor((x.x-p)/m)-1,f=Math.ceil((x.x+p)/m)+1,E=Math.floor((x.y-p)/m)-1,w=Math.ceil((x.y+p)/m)+1;if(f<0||w<0||g>d.length||E>d[0].length)return;g<0&&(g=0),f<0&&(f=0),E<0&&(E=0),w<0&&(w=0),g>=d.length&&(g=d.length-1),f>=d.length&&(f=d.length-1),w>=d[0].length&&(w=d[0].length-1),E>=d[0].length&&(E=d[0].length-1);let _=[];t.getRectMinMax(g,E,f,w,_);let M=_[0],T=_[1];if(x.z-p>T||x.z+p<M)return;let z=this.result;for(let W=g;W<f;W++)for(let A=E;A<w;A++){let v=z.length,R=!1;if(t.getConvexTrianglePillar(W,A,!1),Ge.pointToWorldFrame(n,o,t.pillarOffset,y),i.distanceTo(y)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(R=this.sphereConvex(e,t.pillarConvex,i,y,s,o,a,l,e,t,h)),h&&R||(t.getConvexTrianglePillar(W,A,!0),Ge.pointToWorldFrame(n,o,t.pillarOffset,y),i.distanceTo(y)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(R=this.sphereConvex(e,t.pillarConvex,i,y,s,o,a,l,e,t,h)),h&&R))return!0;if(z.length-v>2)return}}boxHeightfield(e,t,i,n,s,o,a,l,c,u,h){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexHeightfield(e.convexPolyhedronRepresentation,t,i,n,s,o,a,l,e,t,h)}convexHeightfield(e,t,i,n,s,o,a,l,c,u,h){let d=t.data,p=t.elementSize,m=e.boundingSphereRadius,y=Fx,x=Lx,g=Rx;Ge.pointToLocalFrame(n,o,i,g);let f=Math.floor((g.x-m)/p)-1,E=Math.ceil((g.x+m)/p)+1,w=Math.floor((g.y-m)/p)-1,_=Math.ceil((g.y+m)/p)+1;if(E<0||_<0||f>d.length||w>d[0].length)return;f<0&&(f=0),E<0&&(E=0),w<0&&(w=0),_<0&&(_=0),f>=d.length&&(f=d.length-1),E>=d.length&&(E=d.length-1),_>=d[0].length&&(_=d[0].length-1),w>=d[0].length&&(w=d[0].length-1);let M=[];t.getRectMinMax(f,w,E,_,M);let T=M[0],z=M[1];if(!(g.z-m>z||g.z+m<T))for(let W=f;W<E;W++)for(let A=w;A<_;A++){let v=!1;if(t.getConvexTrianglePillar(W,A,!1),Ge.pointToWorldFrame(n,o,t.pillarOffset,y),i.distanceTo(y)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(v=this.convexConvex(e,t.pillarConvex,i,y,s,o,a,l,null,null,h,x,null)),h&&v||(t.getConvexTrianglePillar(W,A,!0),Ge.pointToWorldFrame(n,o,t.pillarOffset,y),i.distanceTo(y)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(v=this.convexConvex(e,t.pillarConvex,i,y,s,o,a,l,null,null,h,x,null)),h&&v))return!0}}sphereParticle(e,t,i,n,s,o,a,l,c,u,h){let d=Mx;if(d.set(0,0,1),n.vsub(i,d),d.lengthSquared()<=e.radius*e.radius){if(h)return!0;let m=this.createContactEquation(l,a,t,e,c,u);d.normalize(),m.rj.copy(d),m.rj.scale(e.radius,m.rj),m.ni.copy(d),m.ni.negate(m.ni),m.ri.set(0,0,0),this.result.push(m),this.createFrictionEquationsFromContact(m,this.frictionResult)}}planeParticle(e,t,i,n,s,o,a,l,c,u,h){let d=Ex;d.set(0,0,1),a.quaternion.vmult(d,d);let p=Ax;if(n.vsub(a.position,p),d.dot(p)<=0){if(h)return!0;let y=this.createContactEquation(l,a,t,e,c,u);y.ni.copy(d),y.ni.negate(y.ni),y.ri.set(0,0,0);let x=Sx;d.scale(d.dot(n),x),n.vsub(x,x),y.rj.copy(x),this.result.push(y),this.createFrictionEquationsFromContact(y,this.frictionResult)}}boxParticle(e,t,i,n,s,o,a,l,c,u,h){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexParticle(e.convexPolyhedronRepresentation,t,i,n,s,o,a,l,e,t,h)}convexParticle(e,t,i,n,s,o,a,l,c,u,h){let d=-1,p=Tx,m=Cx,y=null,x=Dx;if(x.copy(n),x.vsub(i,x),s.conjugate(op),op.vmult(x,x),e.pointIsInside(x)){e.worldVerticesNeedsUpdate&&e.computeWorldVertices(i,s),e.worldFaceNormalsNeedsUpdate&&e.computeWorldFaceNormals(s);for(let g=0,f=e.faces.length;g!==f;g++){let E=[e.worldVertices[e.faces[g][0]]],w=e.worldFaceNormals[g];n.vsub(E[0],ap);let _=-w.dot(ap);if(y===null||Math.abs(_)<Math.abs(y)){if(h)return!0;y=_,d=g,p.copy(w)}}if(d!==-1){let g=this.createContactEquation(l,a,t,e,c,u);p.scale(y,m),m.vadd(n,m),m.vsub(i,m),g.rj.copy(m),p.negate(g.ni),g.ri.set(0,0,0);let f=g.ri,E=g.rj;f.vadd(n,f),f.vsub(l.position,f),E.vadd(i,E),E.vsub(a.position,E),this.result.push(g),this.createFrictionEquationsFromContact(g,this.frictionResult)}else console.warn("Point found inside convex, but did not find penetrating face!")}}heightfieldCylinder(e,t,i,n,s,o,a,l,c,u,h){return this.convexHeightfield(t,e,n,i,o,s,l,a,c,u,h)}particleCylinder(e,t,i,n,s,o,a,l,c,u,h){return this.convexParticle(t,e,n,i,o,s,l,a,c,u,h)}sphereTrimesh(e,t,i,n,s,o,a,l,c,u,h){let d=Oy,p=zy,m=Vy,y=Uy,x=Hy,g=Gy,f=jy,E=ky,w=Iy,_=Xy;Ge.pointToLocalFrame(n,o,i,x);let M=e.radius;f.lowerBound.set(x.x-M,x.y-M,x.z-M),f.upperBound.set(x.x+M,x.y+M,x.z+M),t.getTrianglesInAABB(f,_);let T=Ny,z=e.radius*e.radius;for(let S=0;S<_.length;S++)for(let B=0;B<3;B++)if(t.getVertex(t.indices[_[S]*3+B],T),T.vsub(x,w),w.lengthSquared()<=z){if(E.copy(T),Ge.pointToWorldFrame(n,o,E,T),T.vsub(i,w),h)return!0;let L=this.createContactEquation(a,l,e,t,c,u);L.ni.copy(w),L.ni.normalize(),L.ri.copy(L.ni),L.ri.scale(e.radius,L.ri),L.ri.vadd(i,L.ri),L.ri.vsub(a.position,L.ri),L.rj.copy(T),L.rj.vsub(l.position,L.rj),this.result.push(L),this.createFrictionEquationsFromContact(L,this.frictionResult)}for(let S=0;S<_.length;S++)for(let B=0;B<3;B++){t.getVertex(t.indices[_[S]*3+B],d),t.getVertex(t.indices[_[S]*3+(B+1)%3],p),p.vsub(d,m),x.vsub(p,g);let L=g.dot(m);x.vsub(d,g);let C=g.dot(m);if(C>0&&L<0&&(x.vsub(d,g),y.copy(m),y.normalize(),C=g.dot(y),y.scale(C,g),g.vadd(d,g),g.distanceTo(x)<e.radius)){if(h)return!0;let k=this.createContactEquation(a,l,e,t,c,u);g.vsub(x,k.ni),k.ni.normalize(),k.ni.scale(e.radius,k.ri),k.ri.vadd(i,k.ri),k.ri.vsub(a.position,k.ri),Ge.pointToWorldFrame(n,o,g,g),g.vsub(l.position,k.rj),Ge.vectorToWorldFrame(o,k.ni,k.ni),Ge.vectorToWorldFrame(o,k.ri,k.ri),this.result.push(k),this.createFrictionEquationsFromContact(k,this.frictionResult)}}let W=qy,A=Wy,v=$y,R=Py;for(let S=0,B=_.length;S!==B;S++){t.getTriangleVertices(_[S],W,A,v),t.getNormal(_[S],R),x.vsub(W,g);let L=g.dot(R);if(R.scale(L,g),x.vsub(g,g),L=g.distanceTo(x),ni.pointInTriangle(g,W,A,v)&&L<e.radius){if(h)return!0;let C=this.createContactEquation(a,l,e,t,c,u);g.vsub(x,C.ni),C.ni.normalize(),C.ni.scale(e.radius,C.ri),C.ri.vadd(i,C.ri),C.ri.vsub(a.position,C.ri),Ge.pointToWorldFrame(n,o,g,g),g.vsub(l.position,C.rj),Ge.vectorToWorldFrame(o,C.ni,C.ni),Ge.vectorToWorldFrame(o,C.ri,C.ri),this.result.push(C),this.createFrictionEquationsFromContact(C,this.frictionResult)}}_.length=0}planeTrimesh(e,t,i,n,s,o,a,l,c,u,h){let d=new b,p=Fy;p.set(0,0,1),s.vmult(p,p);for(let m=0;m<t.vertices.length/3;m++){t.getVertex(m,d);let y=new b;y.copy(d),Ge.pointToWorldFrame(n,o,y,d);let x=Ly;if(d.vsub(i,x),p.dot(x)<=0){if(h)return!0;let f=this.createContactEquation(a,l,e,t,c,u);f.ni.copy(p);let E=By;p.scale(x.dot(p),E),d.vsub(E,E),f.ri.copy(E),f.ri.vsub(a.position,f.ri),f.rj.copy(d),f.rj.vsub(l.position,f.rj),this.result.push(f),this.createFrictionEquationsFromContact(f,this.frictionResult)}}}},In=new b,ss=new b,rs=new b,Dy=new b,Ty=new b,Cy=new vt,Ry=new vt,Fy=new b,Ly=new b,By=new b,Py=new b,Iy=new b,Ny=new b,ky=new b,Oy=new b,zy=new b,Vy=new b,Uy=new b,Hy=new b,Gy=new b,qy=new b,Wy=new b,$y=new b,jy=new Zt,Xy=[],Uo=new b,rp=new b,Yy=new b,Zy=new b,Jy=new b;function Ky(r,e,t){let i=null,n=r.length;for(let s=0;s!==n;s++){let o=r[s],a=Yy;r[(s+1)%n].vsub(o,a);let l=Zy;a.cross(e,l);let c=Jy;t.vsub(o,c);let u=l.dot(c);if(i===null||u>0&&i===!0||u<=0&&i===!1){i===null&&(i=u>0);continue}else return!1}return!0}var Ho=new b,Qy=new b,ex=new b,tx=new b,ix=[new b,new b,new b,new b,new b,new b],nx=new b,sx=new b,rx=new b,ox=new b,ax=new b,lx=new b,cx=new b,ux=new b,hx=new b,dx=new b,px=new b,fx=new b,mx=new b,gx=new b,yx=new b,xx=new b,vx=new b,wx=new b,bx=new b,_x=new b,Ex=new b,Ax=new b,Sx=new b,Mx=new b,op=new vt,Dx=new b,Tx=new b,ap=new b,Cx=new b,Rx=new b,Fx=new b,Lx=[0],Bx=new b,Px=new b,Xo=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),n=this.current,s=0;for(;i>n[s];)s++;if(i!==n[s]){for(let o=n.length-1;o>=s;o--)n[o+1]=n[o];n[s]=i}}tick(){let e=this.current;this.current=this.previous,this.previous=e,this.current.length=0}getDiff(e,t){let i=this.current,n=this.previous,s=i.length,o=n.length,a=0;for(let l=0;l<s;l++){let c=!1,u=i[l];for(;u>n[a];)a++;c=u===n[a],c||lp(e,u)}a=0;for(let l=0;l<o;l++){let c=!1,u=n[l];for(;u>i[a];)a++;c=i[a]===u,c||lp(t,u)}}};function lp(r,e){r.push((e&4294901760)>>16,e&65535)}var Vc=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 s=t;t=e,e=s}let n=e+"-"+t;this.get(e,t)||this.data.keys.push(n),this.data[n]=i}reset(){let e=this.data,t=e.keys;for(;t.length>0;){let i=t.pop();delete e[i]}}},Yo=class extends qo{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 b,e.gravity&&this.gravity.copy(e.gravity),this.broadphase=e.broadphase!==void 0?e.broadphase:new gr,this.bodies=[],this.hasActiveBodies=!1,this.solver=e.solver!==void 0?e.solver:new Nc,this.constraints=[],this.narrowphase=new zc(this),this.collisionMatrix=new Go,this.collisionMatrixPrevious=new Go,this.bodyOverlapKeeper=new Xo,this.shapeOverlapKeeper=new Xo,this.materials=[],this.contactmaterials=[],this.contactMaterialTable=new Vc,this.defaultMaterial=new cn("default"),this.defaultContactMaterial=new ln(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 yr?this.raycastClosest(e,t,{skipBackfaces:!0},i):this.raycastAll(e,t,{skipBackfaces:!0},i)}raycastAll(e,t,i={},n){return i.mode=ni.ALL,i.from=e,i.to=t,i.callback=n,Rc.intersectWorld(this,i)}raycastAny(e,t,i={},n){return i.mode=ni.ANY,i.from=e,i.to=t,i.result=n,Rc.intersectWorld(this,i)}raycastClosest(e,t,i={},n){return i.mode=ni.CLOSEST,i.from=e,i.to=t,i.result=n,Rc.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 De&&(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,n=i.indexOf(e);if(n!==-1){i.splice(n,1);for(let s=0;s!==i.length;s++)i[s].index=s;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 n=t[i].shapes;for(let s=0;s<n.length;s++){let o=n[s];if(o.id===e)return o}}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 n=At.now(),s=0;for(;this.accumulator>=e&&s<i&&(this.internalStep(e),this.accumulator-=e,s++,!(At.now()-n>e*1e3)););this.accumulator=this.accumulator%e;let o=this.accumulator/e;for(let a=0;a!==this.bodies.length;a++){let l=this.bodies[a];l.previousPosition.lerp(l.position,o,l.interpolatedPosition),l.previousQuaternion.slerp(l.quaternion,o,l.interpolatedQuaternion),l.previousQuaternion.normalize()}this.time+=t}}internalStep(e){this.dt=e;let t=this.contacts,i=zx,n=Vx,s=this.numObjects(),o=this.bodies,a=this.solver,l=this.gravity,c=this.doProfiling,u=this.profile,h=De.DYNAMIC,d=-1/0,p=this.constraints,m=Ox;l.length();let y=l.x,x=l.y,g=l.z,f=0;for(c&&(d=At.now()),f=0;f!==s;f++){let S=o[f];if(S.type===h){let B=S.force,L=S.mass;B.x+=L*y,B.y+=L*x,B.z+=L*g}}for(let S=0,B=this.subsystems.length;S!==B;S++)this.subsystems[S].update();c&&(d=At.now()),i.length=0,n.length=0,this.broadphase.collisionPairs(this,i,n),c&&(u.broadphase=At.now()-d);let E=p.length;for(f=0;f!==E;f++){let S=p[f];if(!S.collideConnected)for(let B=i.length-1;B>=0;B-=1)(S.bodyA===i[B]&&S.bodyB===n[B]||S.bodyB===i[B]&&S.bodyA===n[B])&&(i.splice(B,1),n.splice(B,1))}this.collisionMatrixTick(),c&&(d=At.now());let w=kx,_=t.length;for(f=0;f!==_;f++)w.push(t[f]);t.length=0;let M=this.frictionEquations.length;for(f=0;f!==M;f++)m.push(this.frictionEquations[f]);for(this.frictionEquations.length=0,this.narrowphase.getContacts(i,n,this,t,w,this.frictionEquations,m),c&&(u.narrowphase=At.now()-d),c&&(d=At.now()),f=0;f<this.frictionEquations.length;f++)a.addEquation(this.frictionEquations[f]);let T=t.length;for(let S=0;S!==T;S++){let B=t[S],L=B.bi,C=B.bj,N=B.si,k=B.sj,V;if(L.material&&C.material?V=this.getContactMaterial(L.material,C.material)||this.defaultContactMaterial:V=this.defaultContactMaterial,V.friction,L.material&&C.material&&(L.material.friction>=0&&C.material.friction>=0&&L.material.friction*C.material.friction,L.material.restitution>=0&&C.material.restitution>=0&&(B.restitution=L.material.restitution*C.material.restitution)),a.addEquation(B),L.allowSleep&&L.type===De.DYNAMIC&&L.sleepState===De.SLEEPING&&C.sleepState===De.AWAKE&&C.type!==De.STATIC){let U=C.velocity.lengthSquared()+C.angularVelocity.lengthSquared(),q=C.sleepSpeedLimit**2;U>=q*2&&(L.wakeUpAfterNarrowphase=!0)}if(C.allowSleep&&C.type===De.DYNAMIC&&C.sleepState===De.SLEEPING&&L.sleepState===De.AWAKE&&L.type!==De.STATIC){let U=L.velocity.lengthSquared()+L.angularVelocity.lengthSquared(),q=L.sleepSpeedLimit**2;U>=q*2&&(C.wakeUpAfterNarrowphase=!0)}this.collisionMatrix.set(L,C,!0),this.collisionMatrixPrevious.get(L,C)||(dr.body=C,dr.contact=B,L.dispatchEvent(dr),dr.body=L,C.dispatchEvent(dr)),this.bodyOverlapKeeper.set(L.id,C.id),this.shapeOverlapKeeper.set(N.id,k.id)}for(this.emitContactEvents(),c&&(u.makeContactConstraints=At.now()-d,d=At.now()),f=0;f!==s;f++){let S=o[f];S.wakeUpAfterNarrowphase&&(S.wakeUp(),S.wakeUpAfterNarrowphase=!1)}for(E=p.length,f=0;f!==E;f++){let S=p[f];S.update();for(let B=0,L=S.equations.length;B!==L;B++){let C=S.equations[B];a.addEquation(C)}}a.solve(e,this),c&&(u.solve=At.now()-d),a.removeAllEquations();let z=Math.pow;for(f=0;f!==s;f++){let S=o[f];if(S.type&h){let B=z(1-S.linearDamping,e),L=S.velocity;L.scale(B,L);let C=S.angularVelocity;if(C){let N=z(1-S.angularDamping,e);C.scale(N,C)}}}for(this.dispatchEvent(Nx),f=0;f!==s;f++){let S=o[f];S.preStep&&S.preStep.call(S)}c&&(d=At.now());let A=this.stepnumber%(this.quatNormalizeSkip+1)===0,v=this.quatNormalizeFast;for(f=0;f!==s;f++)o[f].integrate(e,A,v);for(this.clearForces(),this.broadphase.dirty=!0,c&&(u.integrate=At.now()-d),this.stepnumber+=1,this.dispatchEvent(Ix),f=0;f!==s;f++){let S=o[f],B=S.postStep;B&&B.call(S)}let R=!0;if(this.allowSleep)for(R=!1,f=0;f!==s;f++){let S=o[f];S.sleepTick(this.time),S.sleepState!==De.SLEEPING&&(R=!0)}this.hasActiveBodies=R}emitContactEvents(){let e=this.hasAnyEventListener("beginContact"),t=this.hasAnyEventListener("endContact");if((e||t)&&this.bodyOverlapKeeper.getDiff(Oi,zi),e){for(let s=0,o=Oi.length;s<o;s+=2)pr.bodyA=this.getBodyById(Oi[s]),pr.bodyB=this.getBodyById(Oi[s+1]),this.dispatchEvent(pr);pr.bodyA=pr.bodyB=null}if(t){for(let s=0,o=zi.length;s<o;s+=2)fr.bodyA=this.getBodyById(zi[s]),fr.bodyB=this.getBodyById(zi[s+1]),this.dispatchEvent(fr);fr.bodyA=fr.bodyB=null}Oi.length=zi.length=0;let i=this.hasAnyEventListener("beginShapeContact"),n=this.hasAnyEventListener("endShapeContact");if((i||n)&&this.shapeOverlapKeeper.getDiff(Oi,zi),i){for(let s=0,o=Oi.length;s<o;s+=2){let a=this.getShapeById(Oi[s]),l=this.getShapeById(Oi[s+1]);Vi.shapeA=a,Vi.shapeB=l,a&&(Vi.bodyA=a.body),l&&(Vi.bodyB=l.body),this.dispatchEvent(Vi)}Vi.bodyA=Vi.bodyB=Vi.shapeA=Vi.shapeB=null}if(n){for(let s=0,o=zi.length;s<o;s+=2){let a=this.getShapeById(zi[s]),l=this.getShapeById(zi[s+1]);Ui.shapeA=a,Ui.shapeB=l,a&&(Ui.bodyA=a.body),l&&(Ui.bodyB=l.body),this.dispatchEvent(Ui)}Ui.bodyA=Ui.bodyB=Ui.shapeA=Ui.shapeB=null}}clearForces(){let e=this.bodies,t=e.length;for(let i=0;i!==t;i++){let n=e[i];n.force,n.torque,n.force.set(0,0,0),n.torque.set(0,0,0)}}};new Zt;var Rc=new ni,At=globalThis.performance||{};if(!At.now){let r=Date.now();At.timing&&At.timing.navigationStart&&(r=At.timing.navigationStart),At.now=()=>Date.now()-r}var Ix={type:"postStep"},Nx={type:"preStep"},dr={type:De.COLLIDE_EVENT_NAME,body:null,contact:null},kx=[],Ox=[],zx=[],Vx=[],Oi=[],zi=[],pr={type:"beginContact",bodyA:null,bodyB:null},fr={type:"endContact",bodyA:null,bodyB:null},Vi={type:"beginShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null},Ui={type:"endShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null};var Gh="137";var Ux=0,Up=1,Hx=2;var Em=1,qh=2,Tr=3,Pr=0,wt=1,Bs=2,Am=1;var xn=0,Rr=1,Hp=2,Gp=3,qp=4,Gx=5,Ss=100,qx=101,Wx=102,Wp=103,$p=104,$x=200,jx=201,Xx=202,Yx=203,Sm=204,Mm=205,Zx=206,Jx=207,Kx=208,Qx=209,ev=210,tv=0,iv=1,nv=2,Cu=3,sv=4,rv=5,ov=6,av=7,rl=0,lv=1,cv=2,vn=0,uv=1,hv=2,dv=3,pv=4,fv=5,Dm=300,co=301,uo=302,Ru=303,Fu=304,ol=306,Wh=307,Lu=1e3,Qt=1001,Bu=1002,bt=1003,jp=1004;var Xp=1005;var Ft=1006,mv=1007;var al=1008;var wn=1009,gv=1010,yv=1011,Ir=1012,xv=1013,Ca=1014,Un=1015,Cs=1016,vv=1017,wv=1018,Rs=1020,bv=1021,_v=1022,kt=1023,Ev=1024,Av=1025,Gn=1026,Ps=1027,Sv=1028,Mv=1029,Dv=1030,Tv=1031,Cv=1033,qc=33776,Wc=33777,$c=33778,jc=33779,Yp=35840,Zp=35841,Jp=35842,Kp=35843,Rv=36196,Qp=37492,ef=37496,tf=37808,nf=37809,sf=37810,rf=37811,of=37812,af=37813,lf=37814,cf=37815,uf=37816,hf=37817,df=37818,pf=37819,ff=37820,mf=37821,gf=36492,Fv=2200,Lv=2201,Bv=2202,Ra=2300,Fa=2301,Xc=2302,Ms=2400,Ds=2401,La=2402,$h=2500,Tm=2501,Pv=0;var An=3e3,it=3001,Iv=3200,Nv=3201,Xs=0,kv=1;var Yc=7680;var Ov=519,Nr=35044,Ba=35048;var yf="300 es",Pu=1035,Yi=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 n=this._listeners[e];if(n!==void 0){let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let i=this._listeners[e.type];if(i!==void 0){e.target=this;let n=i.slice(0);for(let s=0,o=n.length;s<o;s++)n[s].call(this,e);e.target=null}}},Dt=[];for(let r=0;r<256;r++)Dt[r]=(r<16?"0":"")+r.toString(16);var Zc=Math.PI/180,Iu=180/Math.PI;function fi(){let r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Dt[r&255]+Dt[r>>8&255]+Dt[r>>16&255]+Dt[r>>24&255]+"-"+Dt[e&255]+Dt[e>>8&255]+"-"+Dt[e>>16&15|64]+Dt[e>>24&255]+"-"+Dt[t&63|128]+Dt[t>>8&255]+"-"+Dt[t>>16&255]+Dt[t>>24&255]+Dt[i&255]+Dt[i>>8&255]+Dt[i>>16&255]+Dt[i>>24&255]).toUpperCase()}function Ht(r,e,t){return Math.max(e,Math.min(t,r))}function zv(r,e){return(r%e+e)%e}function Jc(r,e,t){return(1-t)*r+t*e}function xf(r){return(r&r-1)===0&&r!==0}function Vv(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}var ee=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,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[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),n=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*n+e.x,this.y=s*n+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};ee.prototype.isVector2=!0;var _t=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,n,s,o,a,l,c){let u=this.elements;return u[0]=e,u[1]=n,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=o,u[8]=c,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,n=t.elements,s=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],p=i[5],m=i[8],y=n[0],x=n[3],g=n[6],f=n[1],E=n[4],w=n[7],_=n[2],M=n[5],T=n[8];return s[0]=o*y+a*f+l*_,s[3]=o*x+a*E+l*M,s[6]=o*g+a*w+l*T,s[1]=c*y+u*f+h*_,s[4]=c*x+u*E+h*M,s[7]=c*g+u*w+h*T,s[2]=d*y+p*f+m*_,s[5]=d*x+p*E+m*M,s[8]=d*g+p*w+m*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],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-i*s*u+i*a*l+n*s*c-n*o*l}invert(){let e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,d=a*l-u*s,p=c*s-o*l,m=t*h+i*d+n*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/m;return e[0]=h*y,e[1]=(n*c-u*i)*y,e[2]=(a*i-n*o)*y,e[3]=d*y,e[4]=(u*t-n*l)*y,e[5]=(n*s-a*t)*y,e[6]=p*y,e[7]=(i*l-c*t)*y,e[8]=(o*t-i*s)*y,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,n,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-n*c,n*l,-n*(-c*o+l*a)+a+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),n=this.elements,s=n[0],o=n[3],a=n[6],l=n[1],c=n[4],u=n[7];return n[0]=t*s+i*l,n[3]=t*o+i*c,n[6]=t*a+i*u,n[1]=-i*s+t*l,n[4]=-i*o+t*c,n[7]=-i*a+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 n=0;n<9;n++)if(t[n]!==i[n])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)}};_t.prototype.isMatrix3=!0;function Cm(r){for(let e=r.length-1;e>=0;--e)if(r[e]>65535)return!0;return!1}function kr(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}var Rm={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},ui={h:0,s:0,l:0},Zo={h:0,s:0,l:0};function Kc(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}function Fs(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Qc(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}var ye=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=zv(e,1),t=Ht(t,0,1),i=Ht(i,0,1),t===0)this.r=this.g=this.b=i;else{let n=i<=.5?i*(1+t):i+t-i*t,s=2*i-n;this.r=Kc(s,n,e+1/3),this.g=Kc(s,n,e),this.b=Kc(s,n,e-1/3)}return this}setStyle(e){function t(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let n,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,t(n[4]),this;if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,t(n[4]),this;break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){let a=parseFloat(n[1])/360,l=parseInt(n[2],10)/100,c=parseInt(n[3],10)/100;return t(n[4]),this.setHSL(a,l,c)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=i[1],s=n.length;if(s===3)return this.r=parseInt(n.charAt(0)+n.charAt(0),16)/255,this.g=parseInt(n.charAt(1)+n.charAt(1),16)/255,this.b=parseInt(n.charAt(2)+n.charAt(2),16)/255,this;if(s===6)return this.r=parseInt(n.charAt(0)+n.charAt(1),16)/255,this.g=parseInt(n.charAt(2)+n.charAt(3),16)/255,this.b=parseInt(n.charAt(4)+n.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){let t=Rm[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=Fs(e.r),this.g=Fs(e.g),this.b=Fs(e.b),this}copyLinearToSRGB(e){return this.r=Qc(e.r),this.g=Qc(e.g),this.b=Qc(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,n=this.b,s=Math.max(t,i,n),o=Math.min(t,i,n),a,l,c=(o+s)/2;if(o===s)a=0,l=0;else{let u=s-o;switch(l=c<=.5?u/(s+o):u/(2-s-o),s){case t:a=(i-n)/u+(i<n?6:0);break;case i:a=(n-t)/u+2;break;case n:a=(t-i)/u+4;break}a/=6}return e.h=a,e.s=l,e.l=c,e}getStyle(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"}offsetHSL(e,t,i){return this.getHSL(ui),ui.h+=e,ui.s+=t,ui.l+=i,this.setHSL(ui.h,ui.s,ui.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(ui),e.getHSL(Zo);let i=Jc(ui.h,Zo.h,t),n=Jc(ui.s,Zo.s,t),s=Jc(ui.l,Zo.l,t);return this.setHSL(i,n,s),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()}};ye.NAMES=Rm;ye.prototype.isColor=!0;ye.prototype.r=1;ye.prototype.g=1;ye.prototype.b=1;var os,Zi=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{os===void 0&&(os=kr("canvas")),os.width=e.width,os.height=e.height;let i=os.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=os}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<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=kr("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let n=i.getImageData(0,0,e.width,e.height),s=n.data;for(let o=0;o<s.length;o++)s[o]=Fs(s[o]/255)*255;return i.putImageData(n,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(Fs(t[i]/255)*255):t[i]=Fs(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}},Uv=0,ct=class r extends Yi{constructor(e=r.DEFAULT_IMAGE,t=r.DEFAULT_MAPPING,i=Qt,n=Qt,s=Ft,o=al,a=kt,l=wn,c=1,u=An){super(),Object.defineProperty(this,"id",{value:Uv++}),this.uuid=fi(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new ee(0,0),this.repeat=new ee(1,1),this.center=new ee(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new _t,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 n=this.image;if(n.uuid===void 0&&(n.uuid=fi()),!t&&e.images[n.uuid]===void 0){let s;if(Array.isArray(n)){s=[];for(let o=0,a=n.length;o<a;o++)n[o].isDataTexture?s.push(eu(n[o].image)):s.push(eu(n[o]))}else s=eu(n);e.images[n.uuid]={uuid:n.uuid,url:s}}i.image=n.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!==Dm)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Lu:e.x=e.x-Math.floor(e.x);break;case Qt:e.x=e.x<0?0:1;break;case Bu: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 Lu:e.y=e.y-Math.floor(e.y);break;case Qt:e.y=e.y<0?0:1;break;case Bu: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++}};ct.DEFAULT_IMAGE=void 0;ct.DEFAULT_MAPPING=Dm;ct.prototype.isTexture=!0;function eu(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Zi.getDataURL(r):r.data?{data:Array.prototype.slice.call(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var je=class{constructor(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}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,n){return this.x=e,this.y=t,this.z=i,this.w=n,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,n=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*n+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*n+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*n+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*n+o[15]*s,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,n,s,l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],p=l[5],m=l[9],y=l[2],x=l[6],g=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-y)<.01&&Math.abs(m-x)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+y)<.1&&Math.abs(m+x)<.1&&Math.abs(c+p+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(c+1)/2,w=(p+1)/2,_=(g+1)/2,M=(u+d)/4,T=(h+y)/4,z=(m+x)/4;return E>w&&E>_?E<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(E),n=M/i,s=T/i):w>_?w<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(w),i=M/n,s=z/n):_<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(_),i=T/s,n=z/s),this.set(i,n,s,t),this}let f=Math.sqrt((x-m)*(x-m)+(h-y)*(h-y)+(d-u)*(d-u));return Math.abs(f)<.001&&(f=1),this.x=(x-m)/f,this.y=(h-y)/f,this.z=(d-u)/f,this.w=Math.acos((c+p+g-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}};je.prototype.isVector4=!0;var Gt=class extends Yi{constructor(e,t,i={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new je(0,0,e,t),this.scissorTest=!1,this.viewport=new je(0,0,e,t),this.texture=new ct(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:Ft,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"})}};Gt.prototype.isWebGLRenderTarget=!0;var Nu=class extends Gt{constructor(e,t,i){super(e,t);let n=this.texture;this.texture=[];for(let s=0;s<i;s++)this.texture[s]=n.clone()}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,s=this.texture.length;n<s;n++)this.texture[n].image.width=e,this.texture[n].image.height=t,this.texture[n].image.depth=i;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this.texture.length=0;for(let t=0,i=e.texture.length;t<i;t++)this.texture[t]=e.texture[t].clone();return this}};Nu.prototype.isWebGLMultipleRenderTargets=!0;var Or=class extends Gt{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}};Or.prototype.isWebGLMultisampleRenderTarget=!0;var Lt=class{constructor(e=0,t=0,i=0,n=1){this._x=e,this._y=t,this._z=i,this._w=n}static slerp(e,t,i,n){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),i.slerpQuaternions(e,t,n)}static slerpFlat(e,t,i,n,s,o,a){let l=i[n+0],c=i[n+1],u=i[n+2],h=i[n+3],d=s[o+0],p=s[o+1],m=s[o+2],y=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=p,e[t+2]=m,e[t+3]=y;return}if(h!==y||l!==d||c!==p||u!==m){let x=1-a,g=l*d+c*p+u*m+h*y,f=g>=0?1:-1,E=1-g*g;if(E>Number.EPSILON){let _=Math.sqrt(E),M=Math.atan2(_,g*f);x=Math.sin(x*M)/_,a=Math.sin(a*M)/_}let w=a*f;if(l=l*x+d*w,c=c*x+p*w,u=u*x+m*w,h=h*x+y*w,x===1-a){let _=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=_,c*=_,u*=_,h*=_}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,n,s,o){let a=i[n],l=i[n+1],c=i[n+2],u=i[n+3],h=s[o],d=s[o+1],p=s[o+2],m=s[o+3];return e[t]=a*m+u*h+l*p-c*d,e[t+1]=l*m+u*d+c*h-a*p,e[t+2]=c*m+u*p+a*d-l*h,e[t+3]=u*m-a*h-l*d-c*p,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,n){return this._x=e,this._y=t,this._z=i,this._w=n,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,n=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),u=a(n/2),h=a(s/2),d=l(i/2),p=l(n/2),m=l(s/2);switch(o){case"XYZ":this._x=d*u*h+c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h-d*p*m;break;case"YXZ":this._x=d*u*h+c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h+d*p*m;break;case"ZXY":this._x=d*u*h-c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h-d*p*m;break;case"ZYX":this._x=d*u*h-c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h+d*p*m;break;case"YZX":this._x=d*u*h+c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h-d*p*m;break;case"XZY":this._x=d*u*h-c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h+d*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],n=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=i+a+h;if(d>0){let p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(o-n)*p}else if(i>a&&i>h){let p=2*Math.sqrt(1+i-a-h);this._w=(u-l)/p,this._x=.25*p,this._y=(n+o)/p,this._z=(s+c)/p}else if(a>h){let p=2*Math.sqrt(1+a-i-h);this._w=(s-c)/p,this._x=(n+o)/p,this._y=.25*p,this._z=(l+u)/p}else{let p=2*Math.sqrt(1+h-i-a);this._w=(o-n)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}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(Ht(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let n=Math.min(1,t/i);return this.slerp(e,n),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,n=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+o*a+n*c-s*l,this._y=n*u+o*l+s*a-i*c,this._z=s*u+o*c+i*l-n*a,this._w=o*u-i*a-n*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,n=this._y,s=this._z,o=this._w,a=o*e._w+i*e._x+n*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=n,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let p=1-t;return this._w=p*o+t*this._w,this._x=p*i+t*this._x,this._y=p*n+t*this._y,this._z=p*s+t*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=o*h+this._w*d,this._x=i*h+this._x*d,this._y=n*h+this._y*d,this._z=s*h+this._z*d,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),n=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(n),i*Math.sin(s),i*Math.cos(s),t*Math.sin(n))}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(){}};Lt.prototype.isQuaternion=!0;var P=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(vf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(vf.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*n,this.y=s[1]*t+s[4]*i+s[7]*n,this.z=s[2]*t+s[5]*i+s[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,n=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*n+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*n+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*n+s[14])*o,this}applyQuaternion(e){let t=this.x,i=this.y,n=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=l*t+o*n-a*i,u=l*i+a*t-s*n,h=l*n+s*i-o*t,d=-s*t-o*i-a*n;return this.x=c*l+d*-s+u*-a-h*-o,this.y=u*l+d*-o+h*-s-c*-a,this.z=h*l+d*-a+c*-o-u*-s,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,n=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n,this.y=s[1]*t+s[5]*i+s[9]*n,this.z=s[2]*t+s[6]*i+s[10]*n,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,n=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=n*l-s*a,this.y=s*o-i*l,this.z=i*a-n*o,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 tu.copy(this).projectOnVector(e),this.sub(tu)}reflect(e){return this.sub(tu.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(Ht(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}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 n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*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(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,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}};P.prototype.isVector3=!0;var tu=new P,vf=new Lt,ei=class{constructor(e=new P(1/0,1/0,1/0),t=new P(-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,n=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=e.length;l<c;l+=3){let u=e[l],h=e[l+1],d=e[l+2];u<t&&(t=u),h<i&&(i=h),d<n&&(n=d),u>s&&(s=u),h>o&&(o=h),d>a&&(a=d)}return this.min.set(t,i,n),this.max.set(s,o,a),this}setFromBufferAttribute(e){let t=1/0,i=1/0,n=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=e.count;l<c;l++){let u=e.getX(l),h=e.getY(l),d=e.getZ(l);u<t&&(t=u),h<i&&(i=h),d<n&&(n=d),u>s&&(s=u),h>o&&(o=h),d>a&&(a=d)}return this.min.set(t,i,n),this.max.set(s,o,a),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=kn.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 s=i.attributes.position;for(let o=0,a=s.count;o<a;o++)kn.fromBufferAttribute(s,o).applyMatrix4(e.matrixWorld),this.expandByPoint(kn)}else i.boundingBox===null&&i.computeBoundingBox(),iu.copy(i.boundingBox),iu.applyMatrix4(e.matrixWorld),this.union(iu);let n=e.children;for(let s=0,o=n.length;s<o;s++)this.expandByObject(n[s],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,kn),kn.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(vr),Jo.subVectors(this.max,vr),as.subVectors(e.a,vr),ls.subVectors(e.b,vr),cs.subVectors(e.c,vr),un.subVectors(ls,as),hn.subVectors(cs,ls),On.subVectors(as,cs);let t=[0,-un.z,un.y,0,-hn.z,hn.y,0,-On.z,On.y,un.z,0,-un.x,hn.z,0,-hn.x,On.z,0,-On.x,-un.y,un.x,0,-hn.y,hn.x,0,-On.y,On.x,0];return!nu(t,as,ls,cs,Jo)||(t=[1,0,0,0,1,0,0,0,1],!nu(t,as,ls,cs,Jo))?!1:(Ko.crossVectors(un,hn),t=[Ko.x,Ko.y,Ko.z],nu(t,as,ls,cs,Jo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return kn.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(kn).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:(Gi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Gi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Gi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Gi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Gi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Gi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Gi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Gi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Gi),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)}};ei.prototype.isBox3=!0;var Gi=[new P,new P,new P,new P,new P,new P,new P,new P],kn=new P,iu=new ei,as=new P,ls=new P,cs=new P,un=new P,hn=new P,On=new P,vr=new P,Jo=new P,Ko=new P,zn=new P;function nu(r,e,t,i,n){for(let s=0,o=r.length-3;s<=o;s+=3){zn.fromArray(r,s);let a=n.x*Math.abs(zn.x)+n.y*Math.abs(zn.y)+n.z*Math.abs(zn.z),l=e.dot(zn),c=t.dot(zn),u=i.dot(zn);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var Hv=new ei,wf=new P,Qo=new P,su=new P,Ri=class{constructor(e=new P,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):Hv.setFromPoints(e).getCenter(i);let n=0;for(let s=0,o=e.length;s<o;s++)n=Math.max(n,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(n),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){su.subVectors(e,this.center);let t=su.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.add(su.multiplyScalar(n/i)),this.radius+=n}return this}union(e){return this.center.equals(e.center)===!0?Qo.set(0,0,1).multiplyScalar(e.radius):Qo.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(wf.copy(e.center).add(Qo)),this.expandByPoint(wf.copy(e.center).sub(Qo)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},qi=new P,ru=new P,ea=new P,dn=new P,ou=new P,ta=new P,au=new P,Sn=class{constructor(e=new P,t=new P(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,qi)),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=qi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(qi.copy(this.direction).multiplyScalar(t).add(this.origin),qi.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){ru.copy(e).add(t).multiplyScalar(.5),ea.copy(t).sub(e).normalize(),dn.copy(this.origin).sub(ru);let s=e.distanceTo(t)*.5,o=-this.direction.dot(ea),a=dn.dot(this.direction),l=-dn.dot(ea),c=dn.lengthSq(),u=Math.abs(1-o*o),h,d,p,m;if(u>0)if(h=o*l-a,d=o*a-l,m=s*u,h>=0)if(d>=-m)if(d<=m){let y=1/u;h*=y,d*=y,p=h*(h+o*d+2*a)+d*(o*h+d+2*l)+c}else d=s,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*l)+c;else d<=-m?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c):d<=m?(h=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*l)+c;return i&&i.copy(this.direction).multiplyScalar(h).add(this.origin),n&&n.copy(ea).multiplyScalar(d).add(ru),p}intersectSphere(e,t){qi.subVectors(e.center,this.origin);let i=qi.dot(this.direction),n=qi.dot(qi)-i*i,s=e.radius*e.radius;if(n>s)return null;let o=Math.sqrt(s-n),a=i-o,l=i+o;return a<0&&l<0?null:a<0?this.at(l,t):this.at(a,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,n,s,o,a,l,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,n=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,n=(e.min.x-d.x)*c),u>=0?(s=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),i>o||s>n||((s>i||i!==i)&&(i=s),(o<n||n!==n)&&(n=o),h>=0?(a=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),i>l||a>n)||((a>i||i!==i)&&(i=a),(l<n||n!==n)&&(n=l),n<0)?null:this.at(i>=0?i:n,t)}intersectsBox(e){return this.intersectBox(e,qi)!==null}intersectTriangle(e,t,i,n,s){ou.subVectors(t,e),ta.subVectors(i,e),au.crossVectors(ou,ta);let o=this.direction.dot(au),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;dn.subVectors(this.origin,e);let l=a*this.direction.dot(ta.crossVectors(dn,ta));if(l<0)return null;let c=a*this.direction.dot(ou.cross(dn));if(c<0||l+c>o)return null;let u=-a*dn.dot(au);return u<0?null:this.at(u/o,s)}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)}},Ee=class r{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,n,s,o,a,l,c,u,h,d,p,m,y,x){let g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=s,g[5]=o,g[9]=a,g[13]=l,g[2]=c,g[6]=u,g[10]=h,g[14]=d,g[3]=p,g[7]=m,g[11]=y,g[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 r().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,n=1/us.setFromMatrixColumn(e,0).length(),s=1/us.setFromMatrixColumn(e,1).length(),o=1/us.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,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,n=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(n),c=Math.sin(n),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){let d=o*u,p=o*h,m=a*u,y=a*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=p+m*c,t[5]=d-y*c,t[9]=-a*l,t[2]=y-d*c,t[6]=m+p*c,t[10]=o*l}else if(e.order==="YXZ"){let d=l*u,p=l*h,m=c*u,y=c*h;t[0]=d+y*a,t[4]=m*a-p,t[8]=o*c,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=p*a-m,t[6]=y+d*a,t[10]=o*l}else if(e.order==="ZXY"){let d=l*u,p=l*h,m=c*u,y=c*h;t[0]=d-y*a,t[4]=-o*h,t[8]=m+p*a,t[1]=p+m*a,t[5]=o*u,t[9]=y-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let d=o*u,p=o*h,m=a*u,y=a*h;t[0]=l*u,t[4]=m*c-p,t[8]=d*c+y,t[1]=l*h,t[5]=y*c+d,t[9]=p*c-m,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let d=o*l,p=o*c,m=a*l,y=a*c;t[0]=l*u,t[4]=y-d*h,t[8]=m*h+p,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=p*h+m,t[10]=d-y*h}else if(e.order==="XZY"){let d=o*l,p=o*c,m=a*l,y=a*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+y,t[5]=o*u,t[9]=p*h-m,t[2]=m*h-p,t[6]=a*u,t[10]=y*h+d}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(Gv,e,qv)}lookAt(e,t,i){let n=this.elements;return Jt.subVectors(e,t),Jt.lengthSq()===0&&(Jt.z=1),Jt.normalize(),pn.crossVectors(i,Jt),pn.lengthSq()===0&&(Math.abs(i.z)===1?Jt.x+=1e-4:Jt.z+=1e-4,Jt.normalize(),pn.crossVectors(i,Jt)),pn.normalize(),ia.crossVectors(Jt,pn),n[0]=pn.x,n[4]=ia.x,n[8]=Jt.x,n[1]=pn.y,n[5]=ia.y,n[9]=Jt.y,n[2]=pn.z,n[6]=ia.z,n[10]=Jt.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,n=t.elements,s=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],p=i[13],m=i[2],y=i[6],x=i[10],g=i[14],f=i[3],E=i[7],w=i[11],_=i[15],M=n[0],T=n[4],z=n[8],W=n[12],A=n[1],v=n[5],R=n[9],S=n[13],B=n[2],L=n[6],C=n[10],N=n[14],k=n[3],V=n[7],U=n[11],q=n[15];return s[0]=o*M+a*A+l*B+c*k,s[4]=o*T+a*v+l*L+c*V,s[8]=o*z+a*R+l*C+c*U,s[12]=o*W+a*S+l*N+c*q,s[1]=u*M+h*A+d*B+p*k,s[5]=u*T+h*v+d*L+p*V,s[9]=u*z+h*R+d*C+p*U,s[13]=u*W+h*S+d*N+p*q,s[2]=m*M+y*A+x*B+g*k,s[6]=m*T+y*v+x*L+g*V,s[10]=m*z+y*R+x*C+g*U,s[14]=m*W+y*S+x*N+g*q,s[3]=f*M+E*A+w*B+_*k,s[7]=f*T+E*v+w*L+_*V,s[11]=f*z+E*R+w*C+_*U,s[15]=f*W+E*S+w*N+_*q,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],n=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],p=e[14],m=e[3],y=e[7],x=e[11],g=e[15];return m*(+s*l*h-n*c*h-s*a*d+i*c*d+n*a*p-i*l*p)+y*(+t*l*p-t*c*d+s*o*d-n*o*p+n*c*u-s*l*u)+x*(+t*c*h-t*a*p-s*o*h+i*o*p+s*a*u-i*c*u)+g*(-n*a*u-t*l*h+t*a*d+n*o*h-i*o*d+i*l*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 n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],m=e[12],y=e[13],x=e[14],g=e[15],f=h*x*c-y*d*c+y*l*p-a*x*p-h*l*g+a*d*g,E=m*d*c-u*x*c-m*l*p+o*x*p+u*l*g-o*d*g,w=u*y*c-m*h*c+m*a*p-o*y*p-u*a*g+o*h*g,_=m*h*l-u*y*l-m*a*d+o*y*d+u*a*x-o*h*x,M=t*f+i*E+n*w+s*_;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let T=1/M;return e[0]=f*T,e[1]=(y*d*s-h*x*s-y*n*p+i*x*p+h*n*g-i*d*g)*T,e[2]=(a*x*s-y*l*s+y*n*c-i*x*c-a*n*g+i*l*g)*T,e[3]=(h*l*s-a*d*s-h*n*c+i*d*c+a*n*p-i*l*p)*T,e[4]=E*T,e[5]=(u*x*s-m*d*s+m*n*p-t*x*p-u*n*g+t*d*g)*T,e[6]=(m*l*s-o*x*s-m*n*c+t*x*c+o*n*g-t*l*g)*T,e[7]=(o*d*s-u*l*s+u*n*c-t*d*c-o*n*p+t*l*p)*T,e[8]=w*T,e[9]=(m*h*s-u*y*s-m*i*p+t*y*p+u*i*g-t*h*g)*T,e[10]=(o*y*s-m*a*s+m*i*c-t*y*c-o*i*g+t*a*g)*T,e[11]=(u*a*s-o*h*s-u*i*c+t*h*c+o*i*p-t*a*p)*T,e[12]=_*T,e[13]=(u*y*n-m*h*n+m*i*d-t*y*d-u*i*x+t*h*x)*T,e[14]=(m*a*n-o*y*n-m*i*l+t*y*l+o*i*x-t*a*x)*T,e[15]=(o*h*n-u*a*n+u*i*l-t*h*l-o*i*d+t*a*d)*T,this}scale(e){let t=this.elements,i=e.x,n=e.y,s=e.z;return t[0]*=i,t[4]*=n,t[8]*=s,t[1]*=i,t[5]*=n,t[9]*=s,t[2]*=i,t[6]*=n,t[10]*=s,t[3]*=i,t[7]*=n,t[11]*=s,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],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}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),n=Math.sin(t),s=1-i,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+i,c*a-n*l,c*l+n*a,0,c*a+n*l,u*a+i,u*l-n*o,0,c*l-n*a,u*l+n*o,s*l*l+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,n,s,o){return this.set(1,i,s,0,e,1,o,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){let n=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,h=a+a,d=s*c,p=s*u,m=s*h,y=o*u,x=o*h,g=a*h,f=l*c,E=l*u,w=l*h,_=i.x,M=i.y,T=i.z;return n[0]=(1-(y+g))*_,n[1]=(p+w)*_,n[2]=(m-E)*_,n[3]=0,n[4]=(p-w)*M,n[5]=(1-(d+g))*M,n[6]=(x+f)*M,n[7]=0,n[8]=(m+E)*T,n[9]=(x-f)*T,n[10]=(1-(d+y))*T,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){let n=this.elements,s=us.set(n[0],n[1],n[2]).length(),o=us.set(n[4],n[5],n[6]).length(),a=us.set(n[8],n[9],n[10]).length();this.determinant()<0&&(s=-s),e.x=n[12],e.y=n[13],e.z=n[14],hi.copy(this);let c=1/s,u=1/o,h=1/a;return hi.elements[0]*=c,hi.elements[1]*=c,hi.elements[2]*=c,hi.elements[4]*=u,hi.elements[5]*=u,hi.elements[6]*=u,hi.elements[8]*=h,hi.elements[9]*=h,hi.elements[10]*=h,t.setFromRotationMatrix(hi),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,n,s,o){o===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let a=this.elements,l=2*s/(t-e),c=2*s/(i-n),u=(t+e)/(t-e),h=(i+n)/(i-n),d=-(o+s)/(o-s),p=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,i,n,s,o){let a=this.elements,l=1/(t-e),c=1/(i-n),u=1/(o-s),h=(t+e)*l,d=(i+n)*c,p=(o+s)*u;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let n=0;n<16;n++)if(t[n]!==i[n])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}};Ee.prototype.isMatrix4=!0;var us=new P,hi=new Ee,Gv=new P(0,0,0),qv=new P(1,1,1),pn=new P,ia=new P,Jt=new P,bf=new Ee,_f=new Lt,Is=class r{constructor(e=0,t=0,i=0,n=r.DefaultOrder){this._x=e,this._y=t,this._z=i,this._order=n}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,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,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 n=e.elements,s=n[0],o=n[4],a=n[8],l=n[1],c=n[5],u=n[9],h=n[2],d=n[6],p=n[10];switch(t){case"XYZ":this._y=Math.asin(Ht(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ht(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ht(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Ht(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Ht(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Ht(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,p),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 bf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(bf,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _f.setFromEuler(this),this.setFromQuaternion(_f,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 P(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}};Is.prototype.isEuler=!0;Is.DefaultOrder="XYZ";Is.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var Pa=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}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}},Wv=0,Ef=new P,hs=new Lt,Wi=new Ee,na=new P,wr=new P,$v=new P,jv=new Lt,Af=new P(1,0,0),Sf=new P(0,1,0),Mf=new P(0,0,1),Xv={type:"added"},Df={type:"removed"},qe=class r extends Yi{constructor(){super(),Object.defineProperty(this,"id",{value:Wv++}),this.uuid=fi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=r.DefaultUp.clone();let e=new P,t=new Is,i=new Lt,n=new P(1,1,1);function s(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(o),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:n},modelViewMatrix:{value:new Ee},normalMatrix:{value:new _t}}),this.matrix=new Ee,this.matrixWorld=new Ee,this.matrixAutoUpdate=r.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Pa,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 hs.setFromAxisAngle(e,t),this.quaternion.multiply(hs),this}rotateOnWorldAxis(e,t){return hs.setFromAxisAngle(e,t),this.quaternion.premultiply(hs),this}rotateX(e){return this.rotateOnAxis(Af,e)}rotateY(e){return this.rotateOnAxis(Sf,e)}rotateZ(e){return this.rotateOnAxis(Mf,e)}translateOnAxis(e,t){return Ef.copy(e).applyQuaternion(this.quaternion),this.position.add(Ef.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Af,e)}translateY(e){return this.translateOnAxis(Sf,e)}translateZ(e){return this.translateOnAxis(Mf,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(Wi.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?na.copy(e):na.set(e,t,i);let n=this.parent;this.updateWorldMatrix(!0,!1),wr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Wi.lookAt(wr,na,this.up):Wi.lookAt(na,wr,this.up),this.quaternion.setFromRotationMatrix(Wi),n&&(Wi.extractRotation(n.matrixWorld),hs.setFromRotationMatrix(Wi),this.quaternion.premultiply(hs.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(Xv)):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(Df)),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(Df)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Wi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Wi.multiply(e.parent.matrixWorld)),e.applyMatrix4(Wi),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,n=this.children.length;i<n;i++){let o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wr,e,$v),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wr,jv,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,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,n=t.length;i<n;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,n=t.length;i<n;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 n=this.children;for(let s=0,o=n.length;s<o;s++)n[s].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 n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){let h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));n.material=a}else n.material=s(e.materials,this.material);if(this.children.length>0){n.children=[];for(let a=0;a<this.children.length;a++)n.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];n.animations.push(s(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),u=o(e.images),h=o(e.shapes),d=o(e.skeletons),p=o(e.animations);a.length>0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),h.length>0&&(i.shapes=h),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p)}return i.object=n,i;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}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 n=e.children[i];this.add(n.clone())}return this}};qe.DefaultUp=new P(0,1,0);qe.DefaultMatrixAutoUpdate=!0;qe.prototype.isObject3D=!0;var di=new P,$i=new P,lu=new P,ji=new P,ds=new P,ps=new P,Tf=new P,cu=new P,uu=new P,hu=new P,Bt=class r{constructor(e=new P,t=new P,i=new P){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),di.subVectors(e,t),n.cross(di);let s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(e,t,i,n,s){di.subVectors(n,t),$i.subVectors(i,t),lu.subVectors(e,t);let o=di.dot(di),a=di.dot($i),l=di.dot(lu),c=$i.dot($i),u=$i.dot(lu),h=o*c-a*a;if(h===0)return s.set(-2,-1,-1);let d=1/h,p=(c*l-a*u)*d,m=(o*u-a*l)*d;return s.set(1-p-m,m,p)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,ji),ji.x>=0&&ji.y>=0&&ji.x+ji.y<=1}static getUV(e,t,i,n,s,o,a,l){return this.getBarycoord(e,t,i,n,ji),l.set(0,0),l.addScaledVector(s,ji.x),l.addScaledVector(o,ji.y),l.addScaledVector(a,ji.z),l}static isFrontFacing(e,t,i,n){return di.subVectors(i,t),$i.subVectors(e,t),di.cross($i).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),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 di.subVectors(this.c,this.b),$i.subVectors(this.a,this.b),di.cross($i).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return r.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return r.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,n,s){return r.getUV(e,this.a,this.b,this.c,t,i,n,s)}containsPoint(e){return r.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return r.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,n=this.b,s=this.c,o,a;ds.subVectors(n,i),ps.subVectors(s,i),cu.subVectors(e,i);let l=ds.dot(cu),c=ps.dot(cu);if(l<=0&&c<=0)return t.copy(i);uu.subVectors(e,n);let u=ds.dot(uu),h=ps.dot(uu);if(u>=0&&h<=u)return t.copy(n);let d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(i).addScaledVector(ds,o);hu.subVectors(e,s);let p=ds.dot(hu),m=ps.dot(hu);if(m>=0&&p<=m)return t.copy(s);let y=p*c-l*m;if(y<=0&&c>=0&&m<=0)return a=c/(c-m),t.copy(i).addScaledVector(ps,a);let x=u*m-p*h;if(x<=0&&h-u>=0&&p-m>=0)return Tf.subVectors(s,n),a=(h-u)/(h-u+(p-m)),t.copy(n).addScaledVector(Tf,a);let g=1/(x+y+d);return o=y*g,a=d*g,t.copy(i).addScaledVector(ds,o).addScaledVector(ps,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Yv=0,mt=class extends Yi{constructor(){super(),Object.defineProperty(this,"id",{value:Yv++}),this.uuid=fi(),this.name="",this.type="Material",this.fog=!0,this.blending=Rr,this.side=Pr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Sm,this.blendDst=Mm,this.blendEquation=Ss,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Cu,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ov,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yc,this.stencilZFail=Yc,this.stencilZPass=Yc,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!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===Am;continue}let n=this[t];if(n===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.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!==Rr&&(i.blending=this.blending),this.side!==Pr&&(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.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 n(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=n(e.textures),o=n(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}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 n=t.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,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++}};mt.prototype.isMaterial=!0;var zr=class extends mt{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new ye(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=rl,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}};zr.prototype.isMeshBasicMaterial=!0;var Ke=new P,sa=new ee,dt=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=Nr,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 n=0,s=this.itemSize;n<s;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){let t=this.array,i=0;for(let n=0,s=e.length;n<s;n++){let o=e[n];o===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),o=new ye),t[i++]=o.r,t[i++]=o.g,t[i++]=o.b}return this}copyVector2sArray(e){let t=this.array,i=0;for(let n=0,s=e.length;n<s;n++){let o=e[n];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),o=new ee),t[i++]=o.x,t[i++]=o.y}return this}copyVector3sArray(e){let t=this.array,i=0;for(let n=0,s=e.length;n<s;n++){let o=e[n];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),o=new P),t[i++]=o.x,t[i++]=o.y,t[i++]=o.z}return this}copyVector4sArray(e){let t=this.array,i=0;for(let n=0,s=e.length;n<s;n++){let o=e[n];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),o=new je),t[i++]=o.x,t[i++]=o.y,t[i++]=o.z,t[i++]=o.w}return this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)sa.fromBufferAttribute(this,t),sa.applyMatrix3(e),this.setXY(t,sa.x,sa.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Ke.fromBufferAttribute(this,t),Ke.applyMatrix3(e),this.setXYZ(t,Ke.x,Ke.y,Ke.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Ke.x=this.getX(t),Ke.y=this.getY(t),Ke.z=this.getZ(t),Ke.applyMatrix4(e),this.setXYZ(t,Ke.x,Ke.y,Ke.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ke.x=this.getX(t),Ke.y=this.getY(t),Ke.z=this.getZ(t),Ke.applyNormalMatrix(e),this.setXYZ(t,Ke.x,Ke.y,Ke.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ke.x=this.getX(t),Ke.y=this.getY(t),Ke.z=this.getZ(t),Ke.transformDirection(e),this.setXYZ(t,Ke.x,Ke.y,Ke.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,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=s,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!==Nr&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}};dt.prototype.isBufferAttribute=!0;var Ia=class extends dt{constructor(e,t,i){super(new Uint16Array(e),t,i)}};var Na=class extends dt{constructor(e,t,i){super(new Uint32Array(e),t,i)}},ku=class extends dt{constructor(e,t,i){super(new Uint16Array(e),t,i)}};ku.prototype.isFloat16BufferAttribute=!0;var st=class extends dt{constructor(e,t,i){super(new Float32Array(e),t,i)}};var Zv=0,si=new Ee,du=new qe,fs=new P,Kt=new ei,br=new ei,St=new P,Qe=class r extends Yi{constructor(){super(),Object.defineProperty(this,"id",{value:Zv++}),this.uuid=fi(),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(Cm(e)?Na:Ia)(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 s=new _t().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}let n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return si.makeRotationFromQuaternion(e),this.applyMatrix4(si),this}rotateX(e){return si.makeRotationX(e),this.applyMatrix4(si),this}rotateY(e){return si.makeRotationY(e),this.applyMatrix4(si),this}rotateZ(e){return si.makeRotationZ(e),this.applyMatrix4(si),this}translate(e,t,i){return si.makeTranslation(e,t,i),this.applyMatrix4(si),this}scale(e,t,i){return si.makeScale(e,t,i),this.applyMatrix4(si),this}lookAt(e){return du.lookAt(e),du.updateMatrix(),this.applyMatrix4(du.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(fs).negate(),this.translate(fs.x,fs.y,fs.z),this}setFromPoints(e){let t=[];for(let i=0,n=e.length;i<n;i++){let s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new st(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ei);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 P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){let s=t[i];Kt.setFromBufferAttribute(s),this.morphTargetsRelative?(St.addVectors(this.boundingBox.min,Kt.min),this.boundingBox.expandByPoint(St),St.addVectors(this.boundingBox.max,Kt.max),this.boundingBox.expandByPoint(St)):(this.boundingBox.expandByPoint(Kt.min),this.boundingBox.expandByPoint(Kt.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 Ri);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 P,1/0);return}if(e){let i=this.boundingSphere.center;if(Kt.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];br.setFromBufferAttribute(a),this.morphTargetsRelative?(St.addVectors(Kt.min,br.min),Kt.expandByPoint(St),St.addVectors(Kt.max,br.max),Kt.expandByPoint(St)):(Kt.expandByPoint(br.min),Kt.expandByPoint(br.max))}Kt.getCenter(i);let n=0;for(let s=0,o=e.count;s<o;s++)St.fromBufferAttribute(e,s),n=Math.max(n,i.distanceToSquared(St));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)St.fromBufferAttribute(a,c),l&&(fs.fromBufferAttribute(e,c),St.add(fs)),n=Math.max(n,i.distanceToSquared(St))}this.boundingSphere.radius=Math.sqrt(n),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,n=t.position.array,s=t.normal.array,o=t.uv.array,a=n.length/3;t.tangent===void 0&&this.setAttribute("tangent",new dt(new Float32Array(4*a),4));let l=t.tangent.array,c=[],u=[];for(let A=0;A<a;A++)c[A]=new P,u[A]=new P;let h=new P,d=new P,p=new P,m=new ee,y=new ee,x=new ee,g=new P,f=new P;function E(A,v,R){h.fromArray(n,A*3),d.fromArray(n,v*3),p.fromArray(n,R*3),m.fromArray(o,A*2),y.fromArray(o,v*2),x.fromArray(o,R*2),d.sub(h),p.sub(h),y.sub(m),x.sub(m);let S=1/(y.x*x.y-x.x*y.y);isFinite(S)&&(g.copy(d).multiplyScalar(x.y).addScaledVector(p,-y.y).multiplyScalar(S),f.copy(p).multiplyScalar(y.x).addScaledVector(d,-x.x).multiplyScalar(S),c[A].add(g),c[v].add(g),c[R].add(g),u[A].add(f),u[v].add(f),u[R].add(f))}let w=this.groups;w.length===0&&(w=[{start:0,count:i.length}]);for(let A=0,v=w.length;A<v;++A){let R=w[A],S=R.start,B=R.count;for(let L=S,C=S+B;L<C;L+=3)E(i[L+0],i[L+1],i[L+2])}let _=new P,M=new P,T=new P,z=new P;function W(A){T.fromArray(s,A*3),z.copy(T);let v=c[A];_.copy(v),_.sub(T.multiplyScalar(T.dot(v))).normalize(),M.crossVectors(z,v);let S=M.dot(u[A])<0?-1:1;l[A*4]=_.x,l[A*4+1]=_.y,l[A*4+2]=_.z,l[A*4+3]=S}for(let A=0,v=w.length;A<v;++A){let R=w[A],S=R.start,B=R.count;for(let L=S,C=S+B;L<C;L+=3)W(i[L+0]),W(i[L+1]),W(i[L+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 dt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,p=i.count;d<p;d++)i.setXYZ(d,0,0,0);let n=new P,s=new P,o=new P,a=new P,l=new P,c=new P,u=new P,h=new P;if(e)for(let d=0,p=e.count;d<p;d+=3){let m=e.getX(d+0),y=e.getX(d+1),x=e.getX(d+2);n.fromBufferAttribute(t,m),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,x),u.subVectors(o,s),h.subVectors(n,s),u.cross(h),a.fromBufferAttribute(i,m),l.fromBufferAttribute(i,y),c.fromBufferAttribute(i,x),a.add(u),l.add(u),c.add(u),i.setXYZ(m,a.x,a.y,a.z),i.setXYZ(y,l.x,l.y,l.z),i.setXYZ(x,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)n.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),u.subVectors(o,s),h.subVectors(n,s),u.cross(h),i.setXYZ(d+0,u.x,u.y,u.z),i.setXYZ(d+1,u.x,u.y,u.z),i.setXYZ(d+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 n in i){if(e.attributes[n]===void 0)continue;let o=i[n].array,a=e.attributes[n],l=a.array,c=a.itemSize*t,u=Math.min(l.length,o.length-c);for(let h=0,d=c;h<u;h++,d++)o[d]=l[h]}return this}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)St.fromBufferAttribute(e,t),St.normalize(),e.setXYZ(t,St.x,St.y,St.z)}toNonIndexed(){function e(a,l){let c=a.array,u=a.itemSize,h=a.normalized,d=new c.constructor(l.length*u),p=0,m=0;for(let y=0,x=l.length;y<x;y++){a.isInterleavedBufferAttribute?p=l[y]*a.data.stride+a.offset:p=l[y]*u;for(let g=0;g<u;g++)d[m++]=c[p++]}return new dt(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new r,i=this.index.array,n=this.attributes;for(let a in n){let l=n[a],c=e(l,i);t.setAttribute(a,c)}let s=this.morphAttributes;for(let a in s){let l=[],c=s[a];for(let u=0,h=c.length;u<h;u++){let d=c[u],p=e(d,i);l.push(p)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.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 l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);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 l in i){let c=i[l];e.data.attributes[l]=c.toJSON(e.data)}let n={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){let p=c[h];u.push(p.toJSON(e.data))}u.length>0&&(n[l]=u,s=!0)}s&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.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 n=e.attributes;for(let c in n){let u=n[c];this.setAttribute(c,u.clone(t))}let s=e.morphAttributes;for(let c in s){let u=[],h=s[c];for(let d=0,p=h.length;d<p;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,u=o.length;c<u;c++){let h=o[c];this.addGroup(h.start,h.count,h.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.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"})}};Qe.prototype.isBufferGeometry=!0;var Cf=new Ee,ms=new Sn,pu=new Ri,fn=new P,mn=new P,gn=new P,fu=new P,mu=new P,gu=new P,ra=new P,oa=new P,aa=new P,la=new ee,ca=new ee,ua=new ee,yu=new P,ha=new P,ft=class extends qe{constructor(e=new Qe,t=new zr){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 n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){let a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}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,n=this.material,s=this.matrixWorld;if(n===void 0||(i.boundingSphere===null&&i.computeBoundingSphere(),pu.copy(i.boundingSphere),pu.applyMatrix4(s),e.ray.intersectsSphere(pu)===!1)||(Cf.copy(s).invert(),ms.copy(e.ray).applyMatrix4(Cf),i.boundingBox!==null&&ms.intersectsBox(i.boundingBox)===!1))return;let o;if(i.isBufferGeometry){let a=i.index,l=i.attributes.position,c=i.morphAttributes.position,u=i.morphTargetsRelative,h=i.attributes.uv,d=i.attributes.uv2,p=i.groups,m=i.drawRange;if(a!==null)if(Array.isArray(n))for(let y=0,x=p.length;y<x;y++){let g=p[y],f=n[g.materialIndex],E=Math.max(g.start,m.start),w=Math.min(a.count,Math.min(g.start+g.count,m.start+m.count));for(let _=E,M=w;_<M;_+=3){let T=a.getX(_),z=a.getX(_+1),W=a.getX(_+2);o=da(this,f,e,ms,l,c,u,h,d,T,z,W),o&&(o.faceIndex=Math.floor(_/3),o.face.materialIndex=g.materialIndex,t.push(o))}}else{let y=Math.max(0,m.start),x=Math.min(a.count,m.start+m.count);for(let g=y,f=x;g<f;g+=3){let E=a.getX(g),w=a.getX(g+1),_=a.getX(g+2);o=da(this,n,e,ms,l,c,u,h,d,E,w,_),o&&(o.faceIndex=Math.floor(g/3),t.push(o))}}else if(l!==void 0)if(Array.isArray(n))for(let y=0,x=p.length;y<x;y++){let g=p[y],f=n[g.materialIndex],E=Math.max(g.start,m.start),w=Math.min(l.count,Math.min(g.start+g.count,m.start+m.count));for(let _=E,M=w;_<M;_+=3){let T=_,z=_+1,W=_+2;o=da(this,f,e,ms,l,c,u,h,d,T,z,W),o&&(o.faceIndex=Math.floor(_/3),o.face.materialIndex=g.materialIndex,t.push(o))}}else{let y=Math.max(0,m.start),x=Math.min(l.count,m.start+m.count);for(let g=y,f=x;g<f;g+=3){let E=g,w=g+1,_=g+2;o=da(this,n,e,ms,l,c,u,h,d,E,w,_),o&&(o.faceIndex=Math.floor(g/3),t.push(o))}}}else i.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}};ft.prototype.isMesh=!0;function Jv(r,e,t,i,n,s,o,a){let l;if(e.side===wt?l=i.intersectTriangle(o,s,n,!0,a):l=i.intersectTriangle(n,s,o,e.side!==Bs,a),l===null)return null;ha.copy(a),ha.applyMatrix4(r.matrixWorld);let c=t.ray.origin.distanceTo(ha);return c<t.near||c>t.far?null:{distance:c,point:ha.clone(),object:r}}function da(r,e,t,i,n,s,o,a,l,c,u,h){fn.fromBufferAttribute(n,c),mn.fromBufferAttribute(n,u),gn.fromBufferAttribute(n,h);let d=r.morphTargetInfluences;if(s&&d){ra.set(0,0,0),oa.set(0,0,0),aa.set(0,0,0);for(let m=0,y=s.length;m<y;m++){let x=d[m],g=s[m];x!==0&&(fu.fromBufferAttribute(g,c),mu.fromBufferAttribute(g,u),gu.fromBufferAttribute(g,h),o?(ra.addScaledVector(fu,x),oa.addScaledVector(mu,x),aa.addScaledVector(gu,x)):(ra.addScaledVector(fu.sub(fn),x),oa.addScaledVector(mu.sub(mn),x),aa.addScaledVector(gu.sub(gn),x)))}fn.add(ra),mn.add(oa),gn.add(aa)}r.isSkinnedMesh&&(r.boneTransform(c,fn),r.boneTransform(u,mn),r.boneTransform(h,gn));let p=Jv(r,e,t,i,fn,mn,gn,yu);if(p){a&&(la.fromBufferAttribute(a,c),ca.fromBufferAttribute(a,u),ua.fromBufferAttribute(a,h),p.uv=Bt.getUV(yu,fn,mn,gn,la,ca,ua,new ee)),l&&(la.fromBufferAttribute(l,c),ca.fromBufferAttribute(l,u),ua.fromBufferAttribute(l,h),p.uv2=Bt.getUV(yu,fn,mn,gn,la,ca,ua,new ee));let m={a:c,b:u,c:h,normal:new P,materialIndex:0};Bt.getNormal(fn,mn,gn,m.normal),p.face=m}return p}var Vr=class r extends Qe{constructor(e=1,t=1,i=1,n=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:s,depthSegments:o};let a=this;n=Math.floor(n),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],u=[],h=[],d=0,p=0;m("z","y","x",-1,-1,i,t,e,o,s,0),m("z","y","x",1,-1,i,t,-e,o,s,1),m("x","z","y",1,1,e,i,t,n,o,2),m("x","z","y",1,-1,e,i,-t,n,o,3),m("x","y","z",1,-1,e,t,i,n,s,4),m("x","y","z",-1,-1,e,t,-i,n,s,5),this.setIndex(l),this.setAttribute("position",new st(c,3)),this.setAttribute("normal",new st(u,3)),this.setAttribute("uv",new st(h,2));function m(y,x,g,f,E,w,_,M,T,z,W){let A=w/T,v=_/z,R=w/2,S=_/2,B=M/2,L=T+1,C=z+1,N=0,k=0,V=new P;for(let U=0;U<C;U++){let q=U*v-S;for(let j=0;j<L;j++){let ne=j*A-R;V[y]=ne*f,V[x]=q*E,V[g]=B,c.push(V.x,V.y,V.z),V[y]=0,V[x]=0,V[g]=M>0?1:-1,u.push(V.x,V.y,V.z),h.push(j/T),h.push(1-U/z),N+=1}}for(let U=0;U<z;U++)for(let q=0;q<T;q++){let j=d+q+L*U,ne=d+q+L*(U+1),ae=d+(q+1)+L*(U+1),H=d+(q+1)+L*U;l.push(j,ne,H),l.push(ne,ae,H),k+=6}a.addGroup(p,k,W),p+=k,d+=N}}static fromJSON(e){return new r(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Ns(r){let e={};for(let t in r){e[t]={};for(let i in r[t]){let n=r[t][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?e[t][i]=n.clone():Array.isArray(n)?e[t][i]=n.slice():e[t][i]=n}}return e}function Rt(r){let e={};for(let t=0;t<r.length;t++){let i=Ns(r[t]);for(let n in i)e[n]=i[n]}return e}var Kv={clone:Ns,merge:Rt},Qv=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,e2=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,Ji=class extends mt{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=Qv,this.fragmentShader=e2,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=Ns(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 n in this.uniforms){let o=this.uniforms[n].value;o&&o.isTexture?t.uniforms[n]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[n]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[n]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[n]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[n]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[n]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[n]={type:"m4",value:o.toArray()}:t.uniforms[n]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;let i={};for(let n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}};Ji.prototype.isShaderMaterial=!0;var Ur=class extends qe{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new Ee,this.projectionMatrix=new Ee,this.projectionMatrixInverse=new Ee}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)}};Ur.prototype.isCamera=!0;var Mt=class extends Ur{constructor(e=50,t=1,i=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,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=Iu*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Zc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Iu*2*Math.atan(Math.tan(Zc*.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,n,s,o){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=n,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Zc*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,s=-.5*n,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*n/l,t-=o.offsetY*i/c,n*=o.width/l,i*=o.height/c}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,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}};Mt.prototype.isPerspectiveCamera=!0;var gs=90,ys=1,Hr=class extends qe{constructor(e,t,i){if(super(),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 n=new Mt(gs,ys,e,t);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new P(1,0,0)),this.add(n);let s=new Mt(gs,ys,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new P(-1,0,0)),this.add(s);let o=new Mt(gs,ys,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new P(0,1,0)),this.add(o);let a=new Mt(gs,ys,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new P(0,-1,0)),this.add(a);let l=new Mt(gs,ys,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new P(0,0,1)),this.add(l);let c=new Mt(gs,ys,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new P(0,0,-1)),this.add(c)}update(e,t){this.parent===null&&this.updateMatrixWorld();let i=this.renderTarget,[n,s,o,a,l,c]=this.children,u=e.xr.enabled,h=e.getRenderTarget();e.xr.enabled=!1;let d=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,n),e.setRenderTarget(i,1),e.render(t,s),e.setRenderTarget(i,2),e.render(t,o),e.setRenderTarget(i,3),e.render(t,a),e.setRenderTarget(i,4),e.render(t,l),i.texture.generateMipmaps=d,e.setRenderTarget(i,5),e.render(t,c),e.setRenderTarget(h),e.xr.enabled=u,i.texture.needsPMREMUpdate=!0}},ks=class extends ct{constructor(e,t,i,n,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:co,super(e,t,i,n,s,o,a,l,c,u),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};ks.prototype.isCubeTexture=!0;var ka=class extends Gt{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 ks(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:Ft}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=kt,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 );
}
`},n=new Vr(5,5,5),s=new Ji({name:"CubemapFromEquirect",uniforms:Ns(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:wt,blending:xn});s.uniforms.tEquirect.value=t;let o=new ft(n,s),a=t.minFilter;return t.minFilter===al&&(t.minFilter=Ft),new Hr(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,n){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,n);e.setRenderTarget(s)}};ka.prototype.isWebGLCubeRenderTarget=!0;var xu=new P,t2=new P,i2=new _t,pi=class{constructor(e=new P(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,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let n=xu.subVectors(i,t).cross(t2.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,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(xu),n=this.normal.dot(i);if(n===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/n;return s<0||s>1?null:t.copy(i).multiplyScalar(s).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||i2.getNormalMatrix(e),n=this.coplanarPoint(xu).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),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)}};pi.prototype.isPlane=!0;var xs=new Ri,pa=new P,Os=class{constructor(e=new pi,t=new pi,i=new pi,n=new pi,s=new pi,o=new pi){this.planes=[e,t,i,n,s,o]}set(e,t,i,n,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(n),a[4].copy(s),a[5].copy(o),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,n=i[0],s=i[1],o=i[2],a=i[3],l=i[4],c=i[5],u=i[6],h=i[7],d=i[8],p=i[9],m=i[10],y=i[11],x=i[12],g=i[13],f=i[14],E=i[15];return t[0].setComponents(a-n,h-l,y-d,E-x).normalize(),t[1].setComponents(a+n,h+l,y+d,E+x).normalize(),t[2].setComponents(a+s,h+c,y+p,E+g).normalize(),t[3].setComponents(a-s,h-c,y-p,E-g).normalize(),t[4].setComponents(a-o,h-u,y-m,E-f).normalize(),t[5].setComponents(a+o,h+u,y+m,E+f).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),xs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(xs)}intersectsSprite(e){return xs.center.set(0,0,0),xs.radius=.7071067811865476,xs.applyMatrix4(e.matrixWorld),this.intersectsSphere(xs)}intersectsSphere(e){let t=this.planes,i=e.center,n=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let n=t[i];if(pa.x=n.normal.x>0?e.max.x:e.min.x,pa.y=n.normal.y>0?e.max.y:e.min.y,pa.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(pa)<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 Fm(){let r=null,e=!1,t=null,i=null;function n(s,o){t(s,o),i=r.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!==null&&(i=r.requestAnimationFrame(n),e=!0)},stop:function(){r.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function n2(r,e){let t=e.isWebGL2,i=new WeakMap;function n(c,u){let h=c.array,d=c.usage,p=r.createBuffer();r.bindBuffer(u,p),r.bufferData(u,h,d),c.onUploadCallback();let m=5126;return h instanceof Float32Array?m=5126:h instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):h instanceof Uint16Array?c.isFloat16BufferAttribute?t?m=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):m=5123:h instanceof Int16Array?m=5122:h instanceof Uint32Array?m=5125:h instanceof Int32Array?m=5124:h instanceof Int8Array?m=5120:(h instanceof Uint8Array||h instanceof Uint8ClampedArray)&&(m=5121),{buffer:p,type:m,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version}}function s(c,u,h){let d=u.array,p=u.updateRange;r.bindBuffer(h,c),p.count===-1?r.bufferSubData(h,0,d):(t?r.bufferSubData(h,p.offset*d.BYTES_PER_ELEMENT,d,p.offset,p.count):r.bufferSubData(h,p.offset*d.BYTES_PER_ELEMENT,d.subarray(p.offset,p.offset+p.count)),p.count=-1)}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),i.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let u=i.get(c);u&&(r.deleteBuffer(u.buffer),i.delete(c))}function l(c,u){if(c.isGLBufferAttribute){let d=i.get(c);(!d||d.version<c.version)&&i.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);let h=i.get(c);h===void 0?i.set(c,n(c,u)):h.version<c.version&&(s(h.buffer,c,u),h.version=c.version)}return{get:o,remove:a,update:l}}var Gr=class r extends Qe{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};let s=e/2,o=t/2,a=Math.floor(i),l=Math.floor(n),c=a+1,u=l+1,h=e/a,d=t/l,p=[],m=[],y=[],x=[];for(let g=0;g<u;g++){let f=g*d-o;for(let E=0;E<c;E++){let w=E*h-s;m.push(w,-f,0),y.push(0,0,1),x.push(E/a),x.push(1-g/l)}}for(let g=0;g<l;g++)for(let f=0;f<a;f++){let E=f+c*g,w=f+c*(g+1),_=f+1+c*(g+1),M=f+1+c*g;p.push(E,w,M),p.push(w,_,M)}this.setIndex(p),this.setAttribute("position",new st(m,3)),this.setAttribute("normal",new st(y,3)),this.setAttribute("uv",new st(x,2))}static fromJSON(e){return new r(e.width,e.height,e.widthSegments,e.heightSegments)}},s2=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vUv ).g;
#endif`,r2=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,o2=`#ifdef USE_ALPHATEST
if ( diffuseColor.a < alphaTest ) discard;
#endif`,a2=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,l2=`#ifdef USE_AOMAP
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`,c2=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,u2="vec3 transformed = vec3( position );",h2=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,d2=`vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
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 );
}
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
return RECIPROCAL_PI * a2 / pow2( denom );
}
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 );
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 );
}
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 ) );
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
uv = uv * LUT_SCALE + LUT_BIAS;
return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
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 );
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 ] ) {
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 );
vec3 T1, T2;
T1 = normalize( V - N * dot( V, N ) );
T2 = - cross( N, T1 );
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
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 );
coords[ 0 ] = normalize( coords[ 0 ] );
coords[ 1 ] = normalize( coords[ 1 ] );
coords[ 2 ] = normalize( coords[ 2 ] );
coords[ 3 ] = normalize( coords[ 3 ] );
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 ] );
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
return vec3( result );
}
float G_BlinnPhong_Implicit( ) {
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( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
float alpha = pow2( roughness );
float invAlpha = 1.0 / alpha;
float cos2h = dotNH * dotNH;
float sin2h = max( 1.0 - cos2h, 0.0078125 );
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
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`,p2=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
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 ) {
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;
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`,f2=`#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`,m2=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,g2=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,y2=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,x2=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,v2=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,w2=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
varying vec3 vColor;
#endif`,b2=`#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`,_2=`#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
#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 ) ); }
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 ) {
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;
}
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 ) {
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 );
}`,E2=`#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
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;
}
vec2 getUV( vec3 direction, float face ) {
vec2 uv;
if ( face == 0.0 ) {
uv = vec2( direction.z, direction.y ) / abs( direction.x );
} else if ( face == 1.0 ) {
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
} else if ( face == 2.0 ) {
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
} else if ( face == 3.0 ) {
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
} else if ( face == 4.0 ) {
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
} else {
uv = vec2( direction.x, direction.y ) / abs( direction.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;
}
#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 ); }
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`,A2=`vec3 transformedNormal = objectNormal;
#ifdef USE_INSTANCING
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`,S2=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,M2=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
#endif`,D2=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vUv );
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,T2=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,C2="gl_FragColor = linearToOutputTexel( gl_FragColor );",R2=`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 );
}`,F2=`#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 );
}
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`,L2=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,B2=`#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`,P2=`#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`,I2=`#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`,N2=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,k2=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,O2=`#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`,z2=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,V2=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
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
}`,U2=`#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
#ifndef PHYSICALLY_CORRECT_LIGHTS
lightMapIrradiance *= PI;
#endif
reflectedLight.indirectDiffuse += lightMapIrradiance;
#endif`,H2=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,G2=`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`,q2=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
uniform vec3 lightProbe[ 9 ];
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
float x = normal.x, y = normal.y, z = normal.z;
vec3 result = shCoefficients[ 0 ] * 0.886227;
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
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 )
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 ];
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 ];
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;
};
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
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`,W2=`#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 );
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`,$2=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,j2=`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)`,X2=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,Y2=`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)`,Z2=`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 );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 ); 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`,J2=`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
};
vec3 clearcoatSpecular = vec3( 0.0 );
vec3 sheenSpecular = vec3( 0.0 );
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 );
}
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;
}
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; 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; 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 )
);
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
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
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 );
}`,K2=`
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`,Q2=`#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`,ew=`#if defined( RE_IndirectDiffuse )
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
#endif`,tw=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,iw=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,nw=`#ifdef USE_LOGDEPTHBUF
#ifdef USE_LOGDEPTHBUF_EXT
varying float vFragDepth;
varying float vIsPerspective;
#else
uniform float logDepthBufFC;
#endif
#endif`,sw=`#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`,rw=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vUv );
#ifdef DECODE_VIDEO_TEXTURE
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`,ow=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,aw=`#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`,lw=`#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`,cw=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vUv );
metalnessFactor *= texelMetalness.b;
#endif`,uw=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,hw=`#ifdef USE_MORPHNORMALS
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`,dw=`#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`,pw=`#ifdef USE_MORPHTARGETS
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`,fw=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
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
vec3 geometryNormal = normal;`,mw=`#ifdef OBJECTSPACE_NORMALMAP
normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
#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`,gw=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,yw=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,xw=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,vw=`#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 ) )
vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
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;
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`,ww=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = geometryNormal;
#endif`,bw=`#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`,_w=`#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`,Ew=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= transmissionAlpha + 0.1;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Aw=`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.;const float UnpackDownscale = 255. / 256.;
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; 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 ) );
}
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;
}
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 );
}`,Sw=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,Mw=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,Dw=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,Tw=`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
#endif`,Cw=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vUv );
roughnessFactor *= texelRoughness.g;
#endif`,Rw=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,Fw=`#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
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 );
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 ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); 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;
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
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
#endif
}
return shadow;
}
vec2 cubeToUV( vec3 v, float texelSizeY ) {
vec3 absV = abs( v );
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
absV *= scaleToCube;
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
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;
}
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 ) );
vec3 lightToPosition = shadowCoord.xyz;
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
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
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
#endif`,Lw=`#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
#endif`,Bw=`#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
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
#endif`,Pw=`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
#endif
return shadow;
}`,Iw=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,Nw=`#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`,kw=`#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`,Ow=`#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`,zw=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,Vw=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,Uw=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,Hw=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
return toneMappingExposure * color;
}
vec3 ReinhardToneMapping( vec3 color ) {
color *= toneMappingExposure;
return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 OptimizedCineonToneMapping( vec3 color ) {
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 ) );
}
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;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color *= toneMappingExposure / 0.6;
color = ACESInputMat * color;
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
return saturate( color );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,Gw=`#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`,qw=`#ifdef USE_TRANSMISSION
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 ) {
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
vec3 modelScale;
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
return normalize( refractionVector ) * thickness * modelScale;
}
float applyIorToRoughness( const in float roughness, const in float ior ) {
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 ) {
return radiance;
} else {
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); 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;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
}
#endif`,Ww=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
varying vec2 vUv;
#endif`,$w=`#ifdef USE_UV
#ifdef UVS_VERTEX_ONLY
vec2 vUv;
#else
varying vec2 vUv;
#endif
uniform mat3 uvTransform;
#endif`,jw=`#ifdef USE_UV
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif`,Xw=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
varying vec2 vUv2;
#endif`,Yw=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
attribute vec2 uv2;
varying vec2 vUv2;
uniform mat3 uv2Transform;
#endif`,Zw=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
#endif`,Jw=`#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`,Kw=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,Qw=`uniform sampler2D t2D;
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( t2D, vUv );
#include <tonemapping_fragment>
#include <encodings_fragment>
}`,eb=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,tb=`#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>
}`,ib=`#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>
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;
}`,nb=`#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>
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
}`,sb=`#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;
}`,rb=`#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 );
gl_FragColor = packDepthToRGBA( dist );
}`,ob=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,ab=`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>
}`,lb=`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>
}`,cb=`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;
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,ub=`#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>
}`,hb=`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 ) );
#ifdef USE_LIGHTMAP
vec4 lightMapTexel= texture2D( lightMap, vUv2 );
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;
#else
reflectedLight.indirectDiffuse += vec3( 1.0 );
#endif
#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>
}`,db=`#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>
}`,pb=`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>
#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();
#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>
}`,fb=`#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;
}`,mb=`#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;
#ifdef USE_MATCAP
vec4 matcapColor = texture2D( matcap, uv );
#else
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
#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>
}`,gb=`#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
}`,yb=`#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 );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,xb=`#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>
}`,vb=`#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>
#include <lights_phong_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#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>
}`,wb=`#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
}`,bb=`#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>
#include <lights_physical_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#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
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>
}`,_b=`#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>
}`,Eb=`#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>
#include <lights_toon_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#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>
}`,Ab=`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>
}`,Sb=`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>
}`,Mb=`#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>
}`,Db=`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>
}`,Tb=`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>
}`,Cb=`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>
}`,Ne={alphamap_fragment:s2,alphamap_pars_fragment:r2,alphatest_fragment:o2,alphatest_pars_fragment:a2,aomap_fragment:l2,aomap_pars_fragment:c2,begin_vertex:u2,beginnormal_vertex:h2,bsdfs:d2,bumpmap_pars_fragment:p2,clipping_planes_fragment:f2,clipping_planes_pars_fragment:m2,clipping_planes_pars_vertex:g2,clipping_planes_vertex:y2,color_fragment:x2,color_pars_fragment:v2,color_pars_vertex:w2,color_vertex:b2,common:_2,cube_uv_reflection_fragment:E2,defaultnormal_vertex:A2,displacementmap_pars_vertex:S2,displacementmap_vertex:M2,emissivemap_fragment:D2,emissivemap_pars_fragment:T2,encodings_fragment:C2,encodings_pars_fragment:R2,envmap_fragment:F2,envmap_common_pars_fragment:L2,envmap_pars_fragment:B2,envmap_pars_vertex:P2,envmap_physical_pars_fragment:W2,envmap_vertex:I2,fog_vertex:N2,fog_pars_vertex:k2,fog_fragment:O2,fog_pars_fragment:z2,gradientmap_pars_fragment:V2,lightmap_fragment:U2,lightmap_pars_fragment:H2,lights_lambert_vertex:G2,lights_pars_begin:q2,lights_toon_fragment:$2,lights_toon_pars_fragment:j2,lights_phong_fragment:X2,lights_phong_pars_fragment:Y2,lights_physical_fragment:Z2,lights_physical_pars_fragment:J2,lights_fragment_begin:K2,lights_fragment_maps:Q2,lights_fragment_end:ew,logdepthbuf_fragment:tw,logdepthbuf_pars_fragment:iw,logdepthbuf_pars_vertex:nw,logdepthbuf_vertex:sw,map_fragment:rw,map_pars_fragment:ow,map_particle_fragment:aw,map_particle_pars_fragment:lw,metalnessmap_fragment:cw,metalnessmap_pars_fragment:uw,morphnormal_vertex:hw,morphtarget_pars_vertex:dw,morphtarget_vertex:pw,normal_fragment_begin:fw,normal_fragment_maps:mw,normal_pars_fragment:gw,normal_pars_vertex:yw,normal_vertex:xw,normalmap_pars_fragment:vw,clearcoat_normal_fragment_begin:ww,clearcoat_normal_fragment_maps:bw,clearcoat_pars_fragment:_w,output_fragment:Ew,packing:Aw,premultiplied_alpha_fragment:Sw,project_vertex:Mw,dithering_fragment:Dw,dithering_pars_fragment:Tw,roughnessmap_fragment:Cw,roughnessmap_pars_fragment:Rw,shadowmap_pars_fragment:Fw,shadowmap_pars_vertex:Lw,shadowmap_vertex:Bw,shadowmask_pars_fragment:Pw,skinbase_vertex:Iw,skinning_pars_vertex:Nw,skinning_vertex:kw,skinnormal_vertex:Ow,specularmap_fragment:zw,specularmap_pars_fragment:Vw,tonemapping_fragment:Uw,tonemapping_pars_fragment:Hw,transmission_fragment:Gw,transmission_pars_fragment:qw,uv_pars_fragment:Ww,uv_pars_vertex:$w,uv_vertex:jw,uv2_pars_fragment:Xw,uv2_pars_vertex:Yw,uv2_vertex:Zw,worldpos_vertex:Jw,background_vert:Kw,background_frag:Qw,cube_vert:eb,cube_frag:tb,depth_vert:ib,depth_frag:nb,distanceRGBA_vert:sb,distanceRGBA_frag:rb,equirect_vert:ob,equirect_frag:ab,linedashed_vert:lb,linedashed_frag:cb,meshbasic_vert:ub,meshbasic_frag:hb,meshlambert_vert:db,meshlambert_frag:pb,meshmatcap_vert:fb,meshmatcap_frag:mb,meshnormal_vert:gb,meshnormal_frag:yb,meshphong_vert:xb,meshphong_frag:vb,meshphysical_vert:wb,meshphysical_frag:bb,meshtoon_vert:_b,meshtoon_frag:Eb,points_vert:Ab,points_frag:Sb,shadow_vert:Mb,shadow_frag:Db,sprite_vert:Tb,sprite_frag:Cb},re={common:{diffuse:{value:new ye(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new _t},uv2Transform:{value:new _t},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 ee(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 ye(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 ye(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new _t}},sprite:{diffuse:{value:new ye(16777215)},opacity:{value:1},center:{value:new ee(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new _t}}},Ci={basic:{uniforms:Rt([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.fog]),vertexShader:Ne.meshbasic_vert,fragmentShader:Ne.meshbasic_frag},lambert:{uniforms:Rt([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.fog,re.lights,{emissive:{value:new ye(0)}}]),vertexShader:Ne.meshlambert_vert,fragmentShader:Ne.meshlambert_frag},phong:{uniforms:Rt([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.fog,re.lights,{emissive:{value:new ye(0)},specular:{value:new ye(1118481)},shininess:{value:30}}]),vertexShader:Ne.meshphong_vert,fragmentShader:Ne.meshphong_frag},standard:{uniforms:Rt([re.common,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.roughnessmap,re.metalnessmap,re.fog,re.lights,{emissive:{value:new ye(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag},toon:{uniforms:Rt([re.common,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.gradientmap,re.fog,re.lights,{emissive:{value:new ye(0)}}]),vertexShader:Ne.meshtoon_vert,fragmentShader:Ne.meshtoon_frag},matcap:{uniforms:Rt([re.common,re.bumpmap,re.normalmap,re.displacementmap,re.fog,{matcap:{value:null}}]),vertexShader:Ne.meshmatcap_vert,fragmentShader:Ne.meshmatcap_frag},points:{uniforms:Rt([re.points,re.fog]),vertexShader:Ne.points_vert,fragmentShader:Ne.points_frag},dashed:{uniforms:Rt([re.common,re.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ne.linedashed_vert,fragmentShader:Ne.linedashed_frag},depth:{uniforms:Rt([re.common,re.displacementmap]),vertexShader:Ne.depth_vert,fragmentShader:Ne.depth_frag},normal:{uniforms:Rt([re.common,re.bumpmap,re.normalmap,re.displacementmap,{opacity:{value:1}}]),vertexShader:Ne.meshnormal_vert,fragmentShader:Ne.meshnormal_frag},sprite:{uniforms:Rt([re.sprite,re.fog]),vertexShader:Ne.sprite_vert,fragmentShader:Ne.sprite_frag},background:{uniforms:{uvTransform:{value:new _t},t2D:{value:null}},vertexShader:Ne.background_vert,fragmentShader:Ne.background_frag},cube:{uniforms:Rt([re.envmap,{opacity:{value:1}}]),vertexShader:Ne.cube_vert,fragmentShader:Ne.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ne.equirect_vert,fragmentShader:Ne.equirect_frag},distanceRGBA:{uniforms:Rt([re.common,re.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ne.distanceRGBA_vert,fragmentShader:Ne.distanceRGBA_frag},shadow:{uniforms:Rt([re.lights,re.fog,{color:{value:new ye(0)},opacity:{value:1}}]),vertexShader:Ne.shadow_vert,fragmentShader:Ne.shadow_frag}};Ci.physical={uniforms:Rt([Ci.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ee(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new ye(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new ye(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new ye(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag};function Rb(r,e,t,i,n,s){let o=new ye(0),a=n===!0?0:1,l,c,u=null,h=0,d=null;function p(y,x){let g=!1,f=x.isScene===!0?x.background:null;f&&f.isTexture&&(f=e.get(f));let E=r.xr,w=E.getSession&&E.getSession();w&&w.environmentBlendMode==="additive"&&(f=null),f===null?m(o,a):f&&f.isColor&&(m(f,1),g=!0),(r.autoClear||g)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),f&&(f.isCubeTexture||f.mapping===ol)?(c===void 0&&(c=new ft(new Vr(1,1,1),new Ji({name:"BackgroundCubeMaterial",uniforms:Ns(Ci.cube.uniforms),vertexShader:Ci.cube.vertexShader,fragmentShader:Ci.cube.fragmentShader,side:wt,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(_,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=f,c.material.uniforms.flipEnvMap.value=f.isCubeTexture&&f.isRenderTargetTexture===!1?-1:1,(u!==f||h!==f.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,u=f,h=f.version,d=r.toneMapping),y.unshift(c,c.geometry,c.material,0,0,null)):f&&f.isTexture&&(l===void 0&&(l=new ft(new Gr(2,2),new Ji({name:"BackgroundMaterial",uniforms:Ns(Ci.background.uniforms),vertexShader:Ci.background.vertexShader,fragmentShader:Ci.background.fragmentShader,side:Pr,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=f,f.matrixAutoUpdate===!0&&f.updateMatrix(),l.material.uniforms.uvTransform.value.copy(f.matrix),(u!==f||h!==f.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,u=f,h=f.version,d=r.toneMapping),y.unshift(l,l.geometry,l.material,0,0,null))}function m(y,x){t.buffers.color.setClear(y.r,y.g,y.b,x,s)}return{getClearColor:function(){return o},setClearColor:function(y,x=1){o.set(y),a=x,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,m(o,a)},render:p}}function Fb(r,e,t,i){let n=r.getParameter(34921),s=i.isWebGL2?null:e.get("OES_vertex_array_object"),o=i.isWebGL2||s!==null,a={},l=y(null),c=l;function u(S,B,L,C,N){let k=!1;if(o){let V=m(C,L,B);c!==V&&(c=V,d(c.object)),k=x(C,N),k&&g(C,N)}else{let V=B.wireframe===!0;(c.geometry!==C.id||c.program!==L.id||c.wireframe!==V)&&(c.geometry=C.id,c.program=L.id,c.wireframe=V,k=!0)}S.isInstancedMesh===!0&&(k=!0),N!==null&&t.update(N,34963),k&&(T(S,B,L,C),N!==null&&r.bindBuffer(34963,t.get(N).buffer))}function h(){return i.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function d(S){return i.isWebGL2?r.bindVertexArray(S):s.bindVertexArrayOES(S)}function p(S){return i.isWebGL2?r.deleteVertexArray(S):s.deleteVertexArrayOES(S)}function m(S,B,L){let C=L.wireframe===!0,N=a[S.id];N===void 0&&(N={},a[S.id]=N);let k=N[B.id];k===void 0&&(k={},N[B.id]=k);let V=k[C];return V===void 0&&(V=y(h()),k[C]=V),V}function y(S){let B=[],L=[],C=[];for(let N=0;N<n;N++)B[N]=0,L[N]=0,C[N]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:L,attributeDivisors:C,object:S,attributes:{},index:null}}function x(S,B){let L=c.attributes,C=S.attributes,N=0;for(let k in C){let V=L[k],U=C[k];if(V===void 0||V.attribute!==U||V.data!==U.data)return!0;N++}return c.attributesNum!==N||c.index!==B}function g(S,B){let L={},C=S.attributes,N=0;for(let k in C){let V=C[k],U={};U.attribute=V,V.data&&(U.data=V.data),L[k]=U,N++}c.attributes=L,c.attributesNum=N,c.index=B}function f(){let S=c.newAttributes;for(let B=0,L=S.length;B<L;B++)S[B]=0}function E(S){w(S,0)}function w(S,B){let L=c.newAttributes,C=c.enabledAttributes,N=c.attributeDivisors;L[S]=1,C[S]===0&&(r.enableVertexAttribArray(S),C[S]=1),N[S]!==B&&((i.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](S,B),N[S]=B)}function _(){let S=c.newAttributes,B=c.enabledAttributes;for(let L=0,C=B.length;L<C;L++)B[L]!==S[L]&&(r.disableVertexAttribArray(L),B[L]=0)}function M(S,B,L,C,N,k){i.isWebGL2===!0&&(L===5124||L===5125)?r.vertexAttribIPointer(S,B,L,N,k):r.vertexAttribPointer(S,B,L,C,N,k)}function T(S,B,L,C){if(i.isWebGL2===!1&&(S.isInstancedMesh||C.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;f();let N=C.attributes,k=L.getAttributes(),V=B.defaultAttributeValues;for(let U in k){let q=k[U];if(q.location>=0){let j=N[U];if(j===void 0&&(U==="instanceMatrix"&&S.instanceMatrix&&(j=S.instanceMatrix),U==="instanceColor"&&S.instanceColor&&(j=S.instanceColor)),j!==void 0){let ne=j.normalized,ae=j.itemSize,H=t.get(j);if(H===void 0)continue;let Te=H.buffer,ue=H.type,we=H.bytesPerElement;if(j.isInterleavedBufferAttribute){let oe=j.data,Ce=oe.stride,Ae=j.offset;if(oe&&oe.isInstancedInterleavedBuffer){for(let Z=0;Z<q.locationSize;Z++)w(q.location+Z,oe.meshPerAttribute);S.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let Z=0;Z<q.locationSize;Z++)E(q.location+Z);r.bindBuffer(34962,Te);for(let Z=0;Z<q.locationSize;Z++)M(q.location+Z,ae/q.locationSize,ue,ne,Ce*we,(Ae+ae/q.locationSize*Z)*we)}else{if(j.isInstancedBufferAttribute){for(let oe=0;oe<q.locationSize;oe++)w(q.location+oe,j.meshPerAttribute);S.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let oe=0;oe<q.locationSize;oe++)E(q.location+oe);r.bindBuffer(34962,Te);for(let oe=0;oe<q.locationSize;oe++)M(q.location+oe,ae/q.locationSize,ue,ne,ae*we,ae/q.locationSize*oe*we)}}else if(V!==void 0){let ne=V[U];if(ne!==void 0)switch(ne.length){case 2:r.vertexAttrib2fv(q.location,ne);break;case 3:r.vertexAttrib3fv(q.location,ne);break;case 4:r.vertexAttrib4fv(q.location,ne);break;default:r.vertexAttrib1fv(q.location,ne)}}}}_()}function z(){v();for(let S in a){let B=a[S];for(let L in B){let C=B[L];for(let N in C)p(C[N].object),delete C[N];delete B[L]}delete a[S]}}function W(S){if(a[S.id]===void 0)return;let B=a[S.id];for(let L in B){let C=B[L];for(let N in C)p(C[N].object),delete C[N];delete B[L]}delete a[S.id]}function A(S){for(let B in a){let L=a[B];if(L[S.id]===void 0)continue;let C=L[S.id];for(let N in C)p(C[N].object),delete C[N];delete L[S.id]}}function v(){R(),c!==l&&(c=l,d(c.object))}function R(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:u,reset:v,resetDefaultState:R,dispose:z,releaseStatesOfGeometry:W,releaseStatesOfProgram:A,initAttributes:f,enableAttribute:E,disableUnusedAttributes:_}}function Lb(r,e,t,i){let n=i.isWebGL2,s;function o(c){s=c}function a(c,u){r.drawArrays(s,c,u),t.update(u,s,1)}function l(c,u,h){if(h===0)return;let d,p;if(n)d=r,p="drawArraysInstanced";else if(d=e.get("ANGLE_instanced_arrays"),p="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[p](s,c,u,h),t.update(u,s,h)}this.setMode=o,this.render=a,this.renderInstances=l}function Bb(r,e,t){let i;function n(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){let T=e.get("EXT_texture_filter_anisotropic");i=r.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function s(T){if(T==="highp"){if(r.getShaderPrecisionFormat(35633,36338).precision>0&&r.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";T="mediump"}return T==="mediump"&&r.getShaderPrecisionFormat(35633,36337).precision>0&&r.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&r instanceof WebGL2ComputeRenderingContext,a=t.precision!==void 0?t.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=r.getParameter(34930),d=r.getParameter(35660),p=r.getParameter(3379),m=r.getParameter(34076),y=r.getParameter(34921),x=r.getParameter(36347),g=r.getParameter(36348),f=r.getParameter(36349),E=d>0,w=o||e.has("OES_texture_float"),_=E&&w,M=o?r.getParameter(36183):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:n,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:d,maxTextureSize:p,maxCubemapSize:m,maxAttributes:y,maxVertexUniforms:x,maxVaryings:g,maxFragmentUniforms:f,vertexTextures:E,floatFragmentTextures:w,floatVertexTextures:_,maxSamples:M}}function Pb(r){let e=this,t=null,i=0,n=!1,s=!1,o=new pi,a=new _t,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d,p){let m=h.length!==0||d||i!==0||n;return n=d,t=u(h,p,0),i=h.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1,c()},this.setState=function(h,d,p){let m=h.clippingPlanes,y=h.clipIntersection,x=h.clipShadows,g=r.get(h);if(!n||m===null||m.length===0||s&&!x)s?u(null):c();else{let f=s?0:i,E=f*4,w=g.clippingState||null;l.value=w,w=u(m,d,E,p);for(let _=0;_!==E;++_)w[_]=t[_];g.clippingState=w,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=f}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,p,m){let y=h!==null?h.length:0,x=null;if(y!==0){if(x=l.value,m!==!0||x===null){let g=p+y*4,f=d.matrixWorldInverse;a.getNormalMatrix(f),(x===null||x.length<g)&&(x=new Float32Array(g));for(let E=0,w=p;E!==y;++E,w+=4)o.copy(h[E]).applyMatrix4(f,a),o.normal.toArray(x,w),x[w+3]=o.constant}l.value=x,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,x}}function Ib(r){let e=new WeakMap;function t(o,a){return a===Ru?o.mapping=co:a===Fu&&(o.mapping=uo),o}function i(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){let a=o.mapping;if(a===Ru||a===Fu)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let c=new ka(l.height/2);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",n),t(c.texture,o.mapping)}else return null}}return o}function n(o){let a=o.target;a.removeEventListener("dispose",n);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}var qr=class extends Ur{constructor(e=-1,t=1,i=1,n=-1,s=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=s,this.far=o,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,n,s,o){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=n,this.view.width=s,this.view.height=o,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,n=(this.top+this.bottom)/2,s=i-e,o=i+e,a=n+t,l=n-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,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}};qr.prototype.isOrthographicCamera=!0;var zs=class extends Ji{constructor(e){super(e),this.type="RawShaderMaterial"}};zs.prototype.isRawShaderMaterial=!0;var Ls=4,bn=8,Ti=Math.pow(2,bn),Lm=[.125,.215,.35,.446,.526,.582],Bm=bn-Ls+1+Lm.length,vs=20,vu=new qr,{_lodPlanes:_r,_sizeLods:Rf,_sigmas:fa}=Nb(),Ff=new ye,wu=null,Vn=(1+Math.sqrt(5))/2,ws=1/Vn,Lf=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,Vn,ws),new P(0,Vn,-ws),new P(ws,0,Vn),new P(-ws,0,Vn),new P(Vn,ws,0),new P(-Vn,ws,0)],Oa=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=kb(vs),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100){wu=this._renderer.getRenderTarget();let s=this._allocateTargets();return this._sceneToCubeUV(e,i,n,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapShader===null&&(this._cubemapShader=If(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){this._equirectShader===null&&(this._equirectShader=Pf(),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<_r.length;e++)_r[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(wu),e.scissorTest=!1,ma(e,0,0,e.width,e.height)}_fromTexture(e,t){wu=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:Ft,minFilter:Ft,generateMipmaps:!1,type:Cs,format:kt,encoding:An,depthBuffer:!1},i=Bf(t);return i.depthBuffer=!e,this._pingPongRenderTarget===null&&(this._pingPongRenderTarget=Bf(t)),i}_compileMaterial(e){let t=new ft(_r[0],e);this._renderer.compile(t,vu)}_sceneToCubeUV(e,t,i,n){let a=new Mt(90,1,t,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,d=u.toneMapping;u.getClearColor(Ff),u.toneMapping=vn,u.autoClear=!1;let p=new zr({name:"PMREM.Background",side:wt,depthWrite:!1,depthTest:!1}),m=new ft(new Vr,p),y=!1,x=e.background;x?x.isColor&&(p.color.copy(x),e.background=null,y=!0):(p.color.copy(Ff),y=!0);for(let g=0;g<6;g++){let f=g%3;f===0?(a.up.set(0,l[g],0),a.lookAt(c[g],0,0)):f===1?(a.up.set(0,0,l[g]),a.lookAt(0,c[g],0)):(a.up.set(0,l[g],0),a.lookAt(0,0,c[g])),ma(n,f*Ti,g>2?Ti:0,Ti,Ti),u.setRenderTarget(n),y&&u.render(m,a),u.render(e,a)}m.geometry.dispose(),m.material.dispose(),u.toneMapping=d,u.autoClear=h,e.background=x}_textureToCubeUV(e,t){let i=this._renderer,n=e.mapping===co||e.mapping===uo;n?(this._cubemapShader===null&&(this._cubemapShader=If()),this._cubemapShader.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectShader===null&&(this._equirectShader=Pf());let s=n?this._cubemapShader:this._equirectShader,o=new ft(_r[0],s),a=s.uniforms;a.envMap.value=e,n||a.texelSize.value.set(1/e.image.width,1/e.image.height),ma(t,0,0,3*Ti,2*Ti),i.setRenderTarget(t),i.render(o,vu)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let n=1;n<Bm;n++){let s=Math.sqrt(fa[n]*fa[n]-fa[n-1]*fa[n-1]),o=Lf[(n-1)%Lf.length];this._blur(e,n-1,n,s,o)}t.autoClear=i}_blur(e,t,i,n,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,n,"latitudinal",s),this._halfBlur(o,e,i,i,n,"longitudinal",s)}_halfBlur(e,t,i,n,s,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,h=new ft(_r[n],c),d=c.uniforms,p=Rf[i]-1,m=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*vs-1),y=s/m,x=isFinite(s)?1+Math.floor(u*y):vs;x>vs&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${vs}`);let g=[],f=0;for(let M=0;M<vs;++M){let T=M/y,z=Math.exp(-T*T/2);g.push(z),M===0?f+=z:M<x&&(f+=2*z)}for(let M=0;M<g.length;M++)g[M]=g[M]/f;d.envMap.value=e.texture,d.samples.value=x,d.weights.value=g,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a),d.dTheta.value=m,d.mipInt.value=bn-i;let E=Rf[n],w=3*Math.max(0,Ti-2*E),_=(n===0?0:2*Ti)+2*E*(n>bn-Ls?n-bn+Ls:0);ma(t,w,_,3*E,2*E),l.setRenderTarget(t),l.render(h,vu)}};function Nb(){let r=[],e=[],t=[],i=bn;for(let n=0;n<Bm;n++){let s=Math.pow(2,i);e.push(s);let o=1/s;n>bn-Ls?o=Lm[n-bn+Ls-1]:n===0&&(o=0),t.push(o);let a=1/(s-1),l=-a/2,c=1+a/2,u=[l,l,c,l,c,c,l,l,c,c,l,c],h=6,d=6,p=3,m=2,y=1,x=new Float32Array(p*d*h),g=new Float32Array(m*d*h),f=new Float32Array(y*d*h);for(let w=0;w<h;w++){let _=w%3*2/3-1,M=w>2?0:-1,T=[_,M,0,_+2/3,M,0,_+2/3,M+1,0,_,M,0,_+2/3,M+1,0,_,M+1,0];x.set(T,p*d*w),g.set(u,m*d*w);let z=[w,w,w,w,w,w];f.set(z,y*d*w)}let E=new Qe;E.setAttribute("position",new dt(x,p)),E.setAttribute("uv",new dt(g,m)),E.setAttribute("faceIndex",new dt(f,y)),r.push(E),i>Ls&&i--}return{_lodPlanes:r,_sizeLods:e,_sigmas:t}}function Bf(r){let e=new Gt(3*Ti,3*Ti,r);return e.texture.mapping=ol,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function ma(r,e,t,i,n){r.viewport.set(e,t,i,n),r.scissor.set(e,t,i,n)}function kb(r){let e=new Float32Array(r),t=new P(0,1,0);return new zs({name:"SphericalGaussianBlur",defines:{n:r},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t}},vertexShader:jh(),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:xn,depthTest:!1,depthWrite:!1})}function Pf(){let r=new ee(1,1);return new zs({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:r}},vertexShader:jh(),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:xn,depthTest:!1,depthWrite:!1})}function If(){return new zs({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:jh(),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:xn,depthTest:!1,depthWrite:!1})}function jh(){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 Ob(r){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let l=a.mapping,c=l===Ru||l===Fu,u=l===co||l===uo;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=e.get(a);return t===null&&(t=new Oa(r)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),e.set(a,h),h.texture}else{if(e.has(a))return e.get(a).texture;{let h=a.image;if(c&&h&&h.height>0||u&&h&&n(h)){t===null&&(t=new Oa(r));let d=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function n(a){let l=0,c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function s(a){let l=a.target;l.removeEventListener("dispose",s);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function zb(r){let e={};function t(i){if(e[i]!==void 0)return e[i];let n;switch(i){case"WEBGL_depth_texture":n=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=r.getExtension(i)}return e[i]=n,n}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 n=t(i);return n===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),n}}}function Vb(r,e,t,i){let n={},s=new WeakMap;function o(h){let d=h.target;d.index!==null&&e.remove(d.index);for(let m in d.attributes)e.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete n[d.id];let p=s.get(d);p&&(e.remove(p),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return n[d.id]===!0||(d.addEventListener("dispose",o),n[d.id]=!0,t.memory.geometries++),d}function l(h){let d=h.attributes;for(let m in d)e.update(d[m],34962);let p=h.morphAttributes;for(let m in p){let y=p[m];for(let x=0,g=y.length;x<g;x++)e.update(y[x],34962)}}function c(h){let d=[],p=h.index,m=h.attributes.position,y=0;if(p!==null){let f=p.array;y=p.version;for(let E=0,w=f.length;E<w;E+=3){let _=f[E+0],M=f[E+1],T=f[E+2];d.push(_,M,M,T,T,_)}}else{let f=m.array;y=m.version;for(let E=0,w=f.length/3-1;E<w;E+=3){let _=E+0,M=E+1,T=E+2;d.push(_,M,M,T,T,_)}}let x=new(Cm(d)?Na:Ia)(d,1);x.version=y;let g=s.get(h);g&&e.remove(g),s.set(h,x)}function u(h){let d=s.get(h);if(d){let p=h.index;p!==null&&d.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:u}}function Ub(r,e,t,i){let n=i.isWebGL2,s;function o(d){s=d}let a,l;function c(d){a=d.type,l=d.bytesPerElement}function u(d,p){r.drawElements(s,p,a,d*l),t.update(p,s,1)}function h(d,p,m){if(m===0)return;let y,x;if(n)y=r,x="drawElementsInstanced";else if(y=e.get("ANGLE_instanced_arrays"),x="drawElementsInstancedANGLE",y===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}y[x](s,p,a,d*l,m),t.update(p,s,m)}this.setMode=o,this.setIndex=c,this.render=u,this.renderInstances=h}function Hb(r){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(t.calls++,o){case 4:t.triangles+=a*(s/3);break;case 1:t.lines+=a*(s/2);break;case 3:t.lines+=a*(s-1);break;case 2:t.lines+=a*s;break;case 0:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function n(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:n,update:i}}var Wr=class extends ct{constructor(e=null,t=1,i=1,n=1){super(null),this.image={data:e,width:t,height:i,depth:n},this.magFilter=bt,this.minFilter=bt,this.wrapR=Qt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};Wr.prototype.isDataTexture2DArray=!0;function Gb(r,e){return r[0]-e[0]}function qb(r,e){return Math.abs(e[1])-Math.abs(r[1])}function Nf(r,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),r.divideScalar(t)}function Wb(r,e,t){let i={},n=new Float32Array(8),s=new WeakMap,o=new P,a=[];for(let c=0;c<8;c++)a[c]=[c,0];function l(c,u,h,d){let p=c.morphTargetInfluences;if(e.isWebGL2===!0){let m=u.morphAttributes.position.length,y=s.get(u);if(y===void 0||y.count!==m){let R=function(){A.dispose(),s.delete(u),u.removeEventListener("dispose",R)};y!==void 0&&y.texture.dispose();let f=u.morphAttributes.normal!==void 0,E=u.morphAttributes.position,w=u.morphAttributes.normal||[],_=u.attributes.position.count,M=f===!0?2:1,T=_*M,z=1;T>e.maxTextureSize&&(z=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);let W=new Float32Array(T*z*4*m),A=new Wr(W,T,z,m);A.format=kt,A.type=Un,A.needsUpdate=!0;let v=M*4;for(let S=0;S<m;S++){let B=E[S],L=w[S],C=T*z*4*S;for(let N=0;N<B.count;N++){o.fromBufferAttribute(B,N),B.normalized===!0&&Nf(o,B);let k=N*v;W[C+k+0]=o.x,W[C+k+1]=o.y,W[C+k+2]=o.z,W[C+k+3]=0,f===!0&&(o.fromBufferAttribute(L,N),L.normalized===!0&&Nf(o,L),W[C+k+4]=o.x,W[C+k+5]=o.y,W[C+k+6]=o.z,W[C+k+7]=0)}}y={count:m,texture:A,size:new ee(T,z)},s.set(u,y),u.addEventListener("dispose",R)}let x=0;for(let f=0;f<p.length;f++)x+=p[f];let g=u.morphTargetsRelative?1:1-x;d.getUniforms().setValue(r,"morphTargetBaseInfluence",g),d.getUniforms().setValue(r,"morphTargetInfluences",p),d.getUniforms().setValue(r,"morphTargetsTexture",y.texture,t),d.getUniforms().setValue(r,"morphTargetsTextureSize",y.size)}else{let m=p===void 0?0:p.length,y=i[u.id];if(y===void 0||y.length!==m){y=[];for(let w=0;w<m;w++)y[w]=[w,0];i[u.id]=y}for(let w=0;w<m;w++){let _=y[w];_[0]=w,_[1]=p[w]}y.sort(qb);for(let w=0;w<8;w++)w<m&&y[w][1]?(a[w][0]=y[w][0],a[w][1]=y[w][1]):(a[w][0]=Number.MAX_SAFE_INTEGER,a[w][1]=0);a.sort(Gb);let x=u.morphAttributes.position,g=u.morphAttributes.normal,f=0;for(let w=0;w<8;w++){let _=a[w],M=_[0],T=_[1];M!==Number.MAX_SAFE_INTEGER&&T?(x&&u.getAttribute("morphTarget"+w)!==x[M]&&u.setAttribute("morphTarget"+w,x[M]),g&&u.getAttribute("morphNormal"+w)!==g[M]&&u.setAttribute("morphNormal"+w,g[M]),n[w]=T,f+=T):(x&&u.hasAttribute("morphTarget"+w)===!0&&u.deleteAttribute("morphTarget"+w),g&&u.hasAttribute("morphNormal"+w)===!0&&u.deleteAttribute("morphNormal"+w),n[w]=0)}let E=u.morphTargetsRelative?1:1-f;d.getUniforms().setValue(r,"morphTargetBaseInfluence",E),d.getUniforms().setValue(r,"morphTargetInfluences",n)}}return{update:l}}function $b(r,e,t,i){let n=new WeakMap;function s(l){let c=i.render.frame,u=l.geometry,h=e.get(l,u);return n.get(h)!==c&&(e.update(h),n.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),t.update(l.instanceMatrix,34962),l.instanceColor!==null&&t.update(l.instanceColor,34962)),h}function o(){n=new WeakMap}function a(l){let c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:o}}var za=class extends ct{constructor(e=null,t=1,i=1,n=1){super(null),this.image={data:e,width:t,height:i,depth:n},this.magFilter=bt,this.minFilter=bt,this.wrapR=Qt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};za.prototype.isDataTexture3D=!0;var Pm=new ct,Im=new Wr,Nm=new za,km=new ks,kf=[],Of=[],zf=new Float32Array(16),Vf=new Float32Array(9),Uf=new Float32Array(4);function Ys(r,e,t){let i=r[0];if(i<=0||i>0)return r;let n=e*t,s=kf[n];if(s===void 0&&(s=new Float32Array(n),kf[n]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function Ot(r,e){if(r.length!==e.length)return!1;for(let t=0,i=r.length;t<i;t++)if(r[t]!==e[t])return!1;return!0}function Pt(r,e){for(let t=0,i=e.length;t<i;t++)r[t]=e[t]}function ll(r,e){let t=Of[e];t===void 0&&(t=new Int32Array(e),Of[e]=t);for(let i=0;i!==e;++i)t[i]=r.allocateTextureUnit();return t}function jb(r,e){let t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function Xb(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ot(t,e))return;r.uniform2fv(this.addr,e),Pt(t,e)}}function Yb(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.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)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Ot(t,e))return;r.uniform3fv(this.addr,e),Pt(t,e)}}function Zb(r,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)&&(r.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(Ot(t,e))return;r.uniform4fv(this.addr,e),Pt(t,e)}}function Jb(r,e){let t=this.cache,i=e.elements;if(i===void 0){if(Ot(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),Pt(t,e)}else{if(Ot(t,i))return;Uf.set(i),r.uniformMatrix2fv(this.addr,!1,Uf),Pt(t,i)}}function Kb(r,e){let t=this.cache,i=e.elements;if(i===void 0){if(Ot(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),Pt(t,e)}else{if(Ot(t,i))return;Vf.set(i),r.uniformMatrix3fv(this.addr,!1,Vf),Pt(t,i)}}function Qb(r,e){let t=this.cache,i=e.elements;if(i===void 0){if(Ot(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),Pt(t,e)}else{if(Ot(t,i))return;zf.set(i),r.uniformMatrix4fv(this.addr,!1,zf),Pt(t,i)}}function e1(r,e){let t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function t1(r,e){let t=this.cache;Ot(t,e)||(r.uniform2iv(this.addr,e),Pt(t,e))}function i1(r,e){let t=this.cache;Ot(t,e)||(r.uniform3iv(this.addr,e),Pt(t,e))}function n1(r,e){let t=this.cache;Ot(t,e)||(r.uniform4iv(this.addr,e),Pt(t,e))}function s1(r,e){let t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function r1(r,e){let t=this.cache;Ot(t,e)||(r.uniform2uiv(this.addr,e),Pt(t,e))}function o1(r,e){let t=this.cache;Ot(t,e)||(r.uniform3uiv(this.addr,e),Pt(t,e))}function a1(r,e){let t=this.cache;Ot(t,e)||(r.uniform4uiv(this.addr,e),Pt(t,e))}function l1(r,e,t){let i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.safeSetTexture2D(e||Pm,n)}function c1(r,e,t){let i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTexture3D(e||Nm,n)}function u1(r,e,t){let i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.safeSetTextureCube(e||km,n)}function h1(r,e,t){let i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTexture2DArray(e||Im,n)}function d1(r){switch(r){case 5126:return jb;case 35664:return Xb;case 35665:return Yb;case 35666:return Zb;case 35674:return Jb;case 35675:return Kb;case 35676:return Qb;case 5124:case 35670:return e1;case 35667:case 35671:return t1;case 35668:case 35672:return i1;case 35669:case 35673:return n1;case 5125:return s1;case 36294:return r1;case 36295:return o1;case 36296:return a1;case 35678:case 36198:case 36298:case 36306:case 35682:return l1;case 35679:case 36299:case 36307:return c1;case 35680:case 36300:case 36308:case 36293:return u1;case 36289:case 36303:case 36311:case 36292:return h1}}function p1(r,e){r.uniform1fv(this.addr,e)}function f1(r,e){let t=Ys(e,this.size,2);r.uniform2fv(this.addr,t)}function m1(r,e){let t=Ys(e,this.size,3);r.uniform3fv(this.addr,t)}function g1(r,e){let t=Ys(e,this.size,4);r.uniform4fv(this.addr,t)}function y1(r,e){let t=Ys(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function x1(r,e){let t=Ys(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function v1(r,e){let t=Ys(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function w1(r,e){r.uniform1iv(this.addr,e)}function b1(r,e){r.uniform2iv(this.addr,e)}function _1(r,e){r.uniform3iv(this.addr,e)}function E1(r,e){r.uniform4iv(this.addr,e)}function A1(r,e){r.uniform1uiv(this.addr,e)}function S1(r,e){r.uniform2uiv(this.addr,e)}function M1(r,e){r.uniform3uiv(this.addr,e)}function D1(r,e){r.uniform4uiv(this.addr,e)}function T1(r,e,t){let i=e.length,n=ll(t,i);r.uniform1iv(this.addr,n);for(let s=0;s!==i;++s)t.safeSetTexture2D(e[s]||Pm,n[s])}function C1(r,e,t){let i=e.length,n=ll(t,i);r.uniform1iv(this.addr,n);for(let s=0;s!==i;++s)t.setTexture3D(e[s]||Nm,n[s])}function R1(r,e,t){let i=e.length,n=ll(t,i);r.uniform1iv(this.addr,n);for(let s=0;s!==i;++s)t.safeSetTextureCube(e[s]||km,n[s])}function F1(r,e,t){let i=e.length,n=ll(t,i);r.uniform1iv(this.addr,n);for(let s=0;s!==i;++s)t.setTexture2DArray(e[s]||Im,n[s])}function L1(r){switch(r){case 5126:return p1;case 35664:return f1;case 35665:return m1;case 35666:return g1;case 35674:return y1;case 35675:return x1;case 35676:return v1;case 5124:case 35670:return w1;case 35667:case 35671:return b1;case 35668:case 35672:return _1;case 35669:case 35673:return E1;case 5125:return A1;case 36294:return S1;case 36295:return M1;case 36296:return D1;case 35678:case 36198:case 36298:case 36306:case 35682:return T1;case 35679:case 36299:case 36307:return C1;case 35680:case 36300:case 36308:case 36293:return R1;case 36289:case 36303:case 36311:case 36292:return F1}}function B1(r,e,t){this.id=r,this.addr=t,this.cache=[],this.setValue=d1(e.type)}function Om(r,e,t){this.id=r,this.addr=t,this.cache=[],this.size=e.size,this.setValue=L1(e.type)}Om.prototype.updateCache=function(r){let e=this.cache;r instanceof Float32Array&&e.length!==r.length&&(this.cache=new Float32Array(r.length)),Pt(e,r)};function zm(r){this.id=r,this.seq=[],this.map={}}zm.prototype.setValue=function(r,e,t){let i=this.seq;for(let n=0,s=i.length;n!==s;++n){let o=i[n];o.setValue(r,e[o.id],t)}};var bu=/(\w+)(\])?(\[|\.)?/g;function Hf(r,e){r.seq.push(e),r.map[e.id]=e}function P1(r,e,t){let i=r.name,n=i.length;for(bu.lastIndex=0;;){let s=bu.exec(i),o=bu.lastIndex,a=s[1],l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===n){Hf(t,c===void 0?new B1(a,r,e):new Om(a,r,e));break}else{let h=t.map[a];h===void 0&&(h=new zm(a),Hf(t,h)),t=h}}}function _n(r,e){this.seq=[],this.map={};let t=r.getProgramParameter(e,35718);for(let i=0;i<t;++i){let n=r.getActiveUniform(e,i),s=r.getUniformLocation(e,n.name);P1(n,s,this)}}_n.prototype.setValue=function(r,e,t,i){let n=this.map[e];n!==void 0&&n.setValue(r,t,i)};_n.prototype.setOptional=function(r,e,t){let i=e[t];i!==void 0&&this.setValue(r,t,i)};_n.upload=function(r,e,t,i){for(let n=0,s=e.length;n!==s;++n){let o=e[n],a=t[o.id];a.needsUpdate!==!1&&o.setValue(r,a.value,i)}};_n.seqWithValue=function(r,e){let t=[];for(let i=0,n=r.length;i!==n;++i){let s=r[i];s.id in e&&t.push(s)}return t};function Gf(r,e,t){let i=r.createShader(e);return r.shaderSource(i,t),r.compileShader(i),i}var I1=0;function N1(r){let e=r.split(`
`);for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join(`
`)}function k1(r){switch(r){case An:return["Linear","( value )"];case it:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",r),["Linear","( value )"]}}function qf(r,e,t){let i=r.getShaderParameter(e,35713),n=r.getShaderInfoLog(e).trim();return i&&n===""?"":t.toUpperCase()+`
`+n+`
`+N1(r.getShaderSource(e))}function O1(r,e){let t=k1(e);return"vec4 "+r+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function z1(r,e){let t;switch(e){case uv:t="Linear";break;case hv:t="Reinhard";break;case dv:t="OptimizedCineon";break;case pv:t="ACESFilmic";break;case fv:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function V1(r){return[r.extensionDerivatives||r.envMapCubeUV||r.bumpMap||r.tangentSpaceNormalMap||r.clearcoatNormalMap||r.flatShading||r.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Cr).join(`
`)}function U1(r){let e=[];for(let t in r){let i=r[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
`)}function H1(r,e){let t={},i=r.getProgramParameter(e,35721);for(let n=0;n<i;n++){let s=r.getActiveAttrib(e,n),o=s.name,a=1;s.type===35674&&(a=2),s.type===35675&&(a=3),s.type===35676&&(a=4),t[o]={type:s.type,location:r.getAttribLocation(e,o),locationSize:a}}return t}function Cr(r){return r!==""}function Wf(r,e){return r.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 $f(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var G1=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ou(r){return r.replace(G1,q1)}function q1(r,e){let t=Ne[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return Ou(t)}var W1=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,$1=/#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 jf(r){return r.replace($1,Vm).replace(W1,j1)}function j1(r,e,t,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),Vm(r,e,t,i)}function Vm(r,e,t,i){let n="";for(let s=parseInt(e);s<parseInt(t);s++)n+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return n}function Xf(r){let e="precision "+r.precision+` float;
precision `+r.precision+" int;";return r.precision==="highp"?e+=`
#define HIGH_PRECISION`:r.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function X1(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===Em?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===qh?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Tr&&(e="SHADOWMAP_TYPE_VSM"),e}function Y1(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case co:case uo:e="ENVMAP_TYPE_CUBE";break;case ol:case Wh:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Z1(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case uo:case Wh:e="ENVMAP_MODE_REFRACTION";break}return e}function J1(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case rl:e="ENVMAP_BLENDING_MULTIPLY";break;case lv:e="ENVMAP_BLENDING_MIX";break;case cv:e="ENVMAP_BLENDING_ADD";break}return e}function K1(r,e,t,i){let n=r.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,l=X1(t),c=Y1(t),u=Z1(t),h=J1(t),d=t.isWebGL2?"":V1(t),p=U1(s),m=n.createProgram(),y,x,g=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(y=[p].filter(Cr).join(`
`),y.length>0&&(y+=`
`),x=[d,p].filter(Cr).join(`
`),x.length>0&&(x+=`
`)):(y=[Xf(t),"#define SHADER_NAME "+t.shaderName,p,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 "+l:"",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(Cr).join(`
`),x=[d,Xf(t),"#define SHADER_NAME "+t.shaderName,p,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 "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",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 "+l:"",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!==vn?"#define TONE_MAPPING":"",t.toneMapping!==vn?Ne.tonemapping_pars_fragment:"",t.toneMapping!==vn?z1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.transparent?"":"#define OPAQUE",Ne.encodings_pars_fragment,O1("linearToOutputTexel",t.outputEncoding),t.depthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(Cr).join(`
`)),o=Ou(o),o=Wf(o,t),o=$f(o,t),a=Ou(a),a=Wf(a,t),a=$f(a,t),o=jf(o),a=jf(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(g=`#version 300 es
`,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+y,x=["#define varying in",t.glslVersion===yf?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===yf?"":"#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 f=g+y+o,E=g+x+a,w=Gf(n,35633,f),_=Gf(n,35632,E);if(n.attachShader(m,w),n.attachShader(m,_),t.index0AttributeName!==void 0?n.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&n.bindAttribLocation(m,0,"position"),n.linkProgram(m),r.debug.checkShaderErrors){let z=n.getProgramInfoLog(m).trim(),W=n.getShaderInfoLog(w).trim(),A=n.getShaderInfoLog(_).trim(),v=!0,R=!0;if(n.getProgramParameter(m,35714)===!1){v=!1;let S=qf(n,w,"vertex"),B=qf(n,_,"fragment");console.error("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(m,35715)+`
Program Info Log: `+z+`
`+S+`
`+B)}else z!==""?console.warn("THREE.WebGLProgram: Program Info Log:",z):(W===""||A==="")&&(R=!1);R&&(this.diagnostics={runnable:v,programLog:z,vertexShader:{log:W,prefix:y},fragmentShader:{log:A,prefix:x}})}n.deleteShader(w),n.deleteShader(_);let M;this.getUniforms=function(){return M===void 0&&(M=new _n(n,m)),M};let T;return this.getAttributes=function(){return T===void 0&&(T=H1(n,m)),T},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(m),this.program=void 0},this.name=t.shaderName,this.id=I1++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=_,this}var Q1=0,zu=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,n=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(n)===!1&&(o.add(n),n.usedTimes++),o.has(s)===!1&&(o.add(s),s.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 Vu;t.set(e,i)}return t.get(e)}},Vu=class{constructor(){this.id=Q1++,this.usedTimes=0}};function e_(r,e,t,i,n,s,o){let a=new Pa,l=new zu,c=[],u=n.isWebGL2,h=n.logarithmicDepthBuffer,d=n.floatVertexTextures,p=n.maxVertexUniforms,m=n.vertexTextures,y=n.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 g(v){let S=v.skeleton.bones;if(d)return 1024;{let L=Math.floor((p-20)/4),C=Math.min(L,S.length);return C<S.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+S.length+" bones. This GPU supports "+C+"."),0):C}}function f(v,R,S,B,L){let C=B.fog,N=v.isMeshStandardMaterial?B.environment:null,k=(v.isMeshStandardMaterial?t:e).get(v.envMap||N),V=x[v.type],U=L.isSkinnedMesh?g(L):0;v.precision!==null&&(y=n.getMaxPrecision(v.precision),y!==v.precision&&console.warn("THREE.WebGLProgram.getParameters:",v.precision,"not supported, using",y,"instead."));let q,j,ne,ae;if(V){let oe=Ci[V];q=oe.vertexShader,j=oe.fragmentShader}else q=v.vertexShader,j=v.fragmentShader,l.update(v),ne=l.getVertexShaderID(v),ae=l.getFragmentShaderID(v);let H=r.getRenderTarget(),Te=v.alphaTest>0,ue=v.clearcoat>0;return{isWebGL2:u,shaderID:V,shaderName:v.type,vertexShader:q,fragmentShader:j,defines:v.defines,customVertexShaderID:ne,customFragmentShaderID:ae,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:y,instancing:L.isInstancedMesh===!0,instancingColor:L.isInstancedMesh===!0&&L.instanceColor!==null,supportsVertexTextures:m,outputEncoding:H===null?r.outputEncoding:H.isXRRenderTarget===!0?H.texture.encoding:An,map:!!v.map,matcap:!!v.matcap,envMap:!!k,envMapMode:k&&k.mapping,envMapCubeUV:!!k&&(k.mapping===ol||k.mapping===Wh),lightMap:!!v.lightMap,aoMap:!!v.aoMap,emissiveMap:!!v.emissiveMap,bumpMap:!!v.bumpMap,normalMap:!!v.normalMap,objectSpaceNormalMap:v.normalMapType===kv,tangentSpaceNormalMap:v.normalMapType===Xs,decodeVideoTexture:!!v.map&&v.map.isVideoTexture===!0&&v.map.encoding===it,clearcoat:ue,clearcoatMap:ue&&!!v.clearcoatMap,clearcoatRoughnessMap:ue&&!!v.clearcoatRoughnessMap,clearcoatNormalMap:ue&&!!v.clearcoatNormalMap,displacementMap:!!v.displacementMap,roughnessMap:!!v.roughnessMap,metalnessMap:!!v.metalnessMap,specularMap:!!v.specularMap,specularIntensityMap:!!v.specularIntensityMap,specularColorMap:!!v.specularColorMap,transparent:v.transparent,alphaMap:!!v.alphaMap,alphaTest:Te,gradientMap:!!v.gradientMap,sheen:v.sheen>0,sheenColorMap:!!v.sheenColorMap,sheenRoughnessMap:!!v.sheenRoughnessMap,transmission:v.transmission>0,transmissionMap:!!v.transmissionMap,thicknessMap:!!v.thicknessMap,combine:v.combine,vertexTangents:!!v.normalMap&&!!L.geometry&&!!L.geometry.attributes.tangent,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!L.geometry&&!!L.geometry.attributes.color&&L.geometry.attributes.color.itemSize===4,vertexUvs:!!v.map||!!v.bumpMap||!!v.normalMap||!!v.specularMap||!!v.alphaMap||!!v.emissiveMap||!!v.roughnessMap||!!v.metalnessMap||!!v.clearcoatMap||!!v.clearcoatRoughnessMap||!!v.clearcoatNormalMap||!!v.displacementMap||!!v.transmissionMap||!!v.thicknessMap||!!v.specularIntensityMap||!!v.specularColorMap||!!v.sheenColorMap||!!v.sheenRoughnessMap,uvsVertexOnly:!(v.map||v.bumpMap||v.normalMap||v.specularMap||v.alphaMap||v.emissiveMap||v.roughnessMap||v.metalnessMap||v.clearcoatNormalMap||v.transmission>0||v.transmissionMap||v.thicknessMap||v.specularIntensityMap||v.specularColorMap||v.sheen>0||v.sheenColorMap||v.sheenRoughnessMap)&&!!v.displacementMap,fog:!!C,useFog:v.fog,fogExp2:C&&C.isFogExp2,flatShading:!!v.flatShading,sizeAttenuation:v.sizeAttenuation,logarithmicDepthBuffer:h,skinning:L.isSkinnedMesh===!0&&U>0,maxBones:U,useVertexTexture:d,morphTargets:!!L.geometry&&!!L.geometry.morphAttributes.position,morphNormals:!!L.geometry&&!!L.geometry.morphAttributes.normal,morphTargetsCount:L.geometry&&L.geometry.morphAttributes.position?L.geometry.morphAttributes.position.length:0,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:v.dithering,shadowMapEnabled:r.shadowMap.enabled&&S.length>0,shadowMapType:r.shadowMap.type,toneMapping:v.toneMapped?r.toneMapping:vn,physicallyCorrectLights:r.physicallyCorrectLights,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===Bs,flipSided:v.side===wt,depthPacking:v.depthPacking!==void 0?v.depthPacking:!1,index0AttributeName:v.index0AttributeName,extensionDerivatives:v.extensions&&v.extensions.derivatives,extensionFragDepth:v.extensions&&v.extensions.fragDepth,extensionDrawBuffers:v.extensions&&v.extensions.drawBuffers,extensionShaderTextureLOD:v.extensions&&v.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:v.customProgramCacheKey()}}function E(v){let R=[];if(v.shaderID?R.push(v.shaderID):(R.push(v.customVertexShaderID),R.push(v.customFragmentShaderID)),v.defines!==void 0)for(let S in v.defines)R.push(S),R.push(v.defines[S]);return v.isRawShaderMaterial===!1&&(w(R,v),_(R,v),R.push(r.outputEncoding)),R.push(v.customProgramCacheKey),R.join()}function w(v,R){v.push(R.precision),v.push(R.outputEncoding),v.push(R.envMapMode),v.push(R.combine),v.push(R.vertexUvs),v.push(R.fogExp2),v.push(R.sizeAttenuation),v.push(R.maxBones),v.push(R.morphTargetsCount),v.push(R.numDirLights),v.push(R.numPointLights),v.push(R.numSpotLights),v.push(R.numHemiLights),v.push(R.numRectAreaLights),v.push(R.numDirLightShadows),v.push(R.numPointLightShadows),v.push(R.numSpotLightShadows),v.push(R.shadowMapType),v.push(R.toneMapping),v.push(R.numClippingPlanes),v.push(R.numClipIntersection)}function _(v,R){a.disableAll(),R.isWebGL2&&a.enable(0),R.supportsVertexTextures&&a.enable(1),R.instancing&&a.enable(2),R.instancingColor&&a.enable(3),R.map&&a.enable(4),R.matcap&&a.enable(5),R.envMap&&a.enable(6),R.envMapCubeUV&&a.enable(7),R.lightMap&&a.enable(8),R.aoMap&&a.enable(9),R.emissiveMap&&a.enable(10),R.bumpMap&&a.enable(11),R.normalMap&&a.enable(12),R.objectSpaceNormalMap&&a.enable(13),R.tangentSpaceNormalMap&&a.enable(14),R.clearcoat&&a.enable(15),R.clearcoatMap&&a.enable(16),R.clearcoatRoughnessMap&&a.enable(17),R.clearcoatNormalMap&&a.enable(18),R.displacementMap&&a.enable(19),R.specularMap&&a.enable(20),R.roughnessMap&&a.enable(21),R.metalnessMap&&a.enable(22),R.gradientMap&&a.enable(23),R.alphaMap&&a.enable(24),R.alphaTest&&a.enable(25),R.vertexColors&&a.enable(26),R.vertexAlphas&&a.enable(27),R.vertexUvs&&a.enable(28),R.vertexTangents&&a.enable(29),R.uvsVertexOnly&&a.enable(30),R.fog&&a.enable(31),v.push(a.mask),a.disableAll(),R.useFog&&a.enable(0),R.flatShading&&a.enable(1),R.logarithmicDepthBuffer&&a.enable(2),R.skinning&&a.enable(3),R.useVertexTexture&&a.enable(4),R.morphTargets&&a.enable(5),R.morphNormals&&a.enable(6),R.premultipliedAlpha&&a.enable(7),R.shadowMapEnabled&&a.enable(8),R.physicallyCorrectLights&&a.enable(9),R.doubleSided&&a.enable(10),R.flipSided&&a.enable(11),R.depthPacking&&a.enable(12),R.dithering&&a.enable(13),R.specularIntensityMap&&a.enable(14),R.specularColorMap&&a.enable(15),R.transmission&&a.enable(16),R.transmissionMap&&a.enable(17),R.thicknessMap&&a.enable(18),R.sheen&&a.enable(19),R.sheenColorMap&&a.enable(20),R.sheenRoughnessMap&&a.enable(21),R.decodeVideoTexture&&a.enable(22),R.transparent&&a.enable(23),v.push(a.mask)}function M(v){let R=x[v.type],S;if(R){let B=Ci[R];S=Kv.clone(B.uniforms)}else S=v.uniforms;return S}function T(v,R){let S;for(let B=0,L=c.length;B<L;B++){let C=c[B];if(C.cacheKey===R){S=C,++S.usedTimes;break}}return S===void 0&&(S=new K1(r,R,v,s),c.push(S)),S}function z(v){if(--v.usedTimes===0){let R=c.indexOf(v);c[R]=c[c.length-1],c.pop(),v.destroy()}}function W(v){l.remove(v)}function A(){l.dispose()}return{getParameters:f,getProgramCacheKey:E,getUniforms:M,acquireProgram:T,releaseProgram:z,releaseShaderCache:W,programs:c,dispose:A}}function t_(){let r=new WeakMap;function e(s){let o=r.get(s);return o===void 0&&(o={},r.set(s,o)),o}function t(s){r.delete(s)}function i(s,o,a){r.get(s)[o]=a}function n(){r=new WeakMap}return{get:e,remove:t,update:i,dispose:n}}function i_(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function Yf(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function Zf(){let r=[],e=0,t=[],i=[],n=[];function s(){e=0,t.length=0,i.length=0,n.length=0}function o(h,d,p,m,y,x){let g=r[e];return g===void 0?(g={id:h.id,object:h,geometry:d,material:p,groupOrder:m,renderOrder:h.renderOrder,z:y,group:x},r[e]=g):(g.id=h.id,g.object=h,g.geometry=d,g.material=p,g.groupOrder=m,g.renderOrder=h.renderOrder,g.z=y,g.group=x),e++,g}function a(h,d,p,m,y,x){let g=o(h,d,p,m,y,x);p.transmission>0?i.push(g):p.transparent===!0?n.push(g):t.push(g)}function l(h,d,p,m,y,x){let g=o(h,d,p,m,y,x);p.transmission>0?i.unshift(g):p.transparent===!0?n.unshift(g):t.unshift(g)}function c(h,d){t.length>1&&t.sort(h||i_),i.length>1&&i.sort(d||Yf),n.length>1&&n.sort(d||Yf)}function u(){for(let h=e,d=r.length;h<d;h++){let p=r[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:n,init:s,push:a,unshift:l,finish:u,sort:c}}function n_(){let r=new WeakMap;function e(i,n){let s;return r.has(i)===!1?(s=new Zf,r.set(i,[s])):n>=r.get(i).length?(s=new Zf,r.get(i).push(s)):s=r.get(i)[n],s}function t(){r=new WeakMap}return{get:e,dispose:t}}function s_(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new ye};break;case"SpotLight":t={position:new P,direction:new P,color:new ye,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new ye,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new ye,groundColor:new ye};break;case"RectAreaLight":t={color:new ye,position:new P,halfWidth:new P,halfHeight:new P};break}return r[e.id]=t,t}}}function r_(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ee};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ee};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}var o_=0;function a_(r,e){return(e.castShadow?1:0)-(r.castShadow?1:0)}function l_(r,e){let t=new s_,i=r_(),n={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++)n.probe.push(new P);let s=new P,o=new Ee,a=new Ee;function l(u,h){let d=0,p=0,m=0;for(let W=0;W<9;W++)n.probe[W].set(0,0,0);let y=0,x=0,g=0,f=0,E=0,w=0,_=0,M=0;u.sort(a_);let T=h!==!0?Math.PI:1;for(let W=0,A=u.length;W<A;W++){let v=u[W],R=v.color,S=v.intensity,B=v.distance,L=v.shadow&&v.shadow.map?v.shadow.map.texture:null;if(v.isAmbientLight)d+=R.r*S*T,p+=R.g*S*T,m+=R.b*S*T;else if(v.isLightProbe)for(let C=0;C<9;C++)n.probe[C].addScaledVector(v.sh.coefficients[C],S);else if(v.isDirectionalLight){let C=t.get(v);if(C.color.copy(v.color).multiplyScalar(v.intensity*T),v.castShadow){let N=v.shadow,k=i.get(v);k.shadowBias=N.bias,k.shadowNormalBias=N.normalBias,k.shadowRadius=N.radius,k.shadowMapSize=N.mapSize,n.directionalShadow[y]=k,n.directionalShadowMap[y]=L,n.directionalShadowMatrix[y]=v.shadow.matrix,w++}n.directional[y]=C,y++}else if(v.isSpotLight){let C=t.get(v);if(C.position.setFromMatrixPosition(v.matrixWorld),C.color.copy(R).multiplyScalar(S*T),C.distance=B,C.coneCos=Math.cos(v.angle),C.penumbraCos=Math.cos(v.angle*(1-v.penumbra)),C.decay=v.decay,v.castShadow){let N=v.shadow,k=i.get(v);k.shadowBias=N.bias,k.shadowNormalBias=N.normalBias,k.shadowRadius=N.radius,k.shadowMapSize=N.mapSize,n.spotShadow[g]=k,n.spotShadowMap[g]=L,n.spotShadowMatrix[g]=v.shadow.matrix,M++}n.spot[g]=C,g++}else if(v.isRectAreaLight){let C=t.get(v);C.color.copy(R).multiplyScalar(S),C.halfWidth.set(v.width*.5,0,0),C.halfHeight.set(0,v.height*.5,0),n.rectArea[f]=C,f++}else if(v.isPointLight){let C=t.get(v);if(C.color.copy(v.color).multiplyScalar(v.intensity*T),C.distance=v.distance,C.decay=v.decay,v.castShadow){let N=v.shadow,k=i.get(v);k.shadowBias=N.bias,k.shadowNormalBias=N.normalBias,k.shadowRadius=N.radius,k.shadowMapSize=N.mapSize,k.shadowCameraNear=N.camera.near,k.shadowCameraFar=N.camera.far,n.pointShadow[x]=k,n.pointShadowMap[x]=L,n.pointShadowMatrix[x]=v.shadow.matrix,_++}n.point[x]=C,x++}else if(v.isHemisphereLight){let C=t.get(v);C.skyColor.copy(v.color).multiplyScalar(S*T),C.groundColor.copy(v.groundColor).multiplyScalar(S*T),n.hemi[E]=C,E++}}f>0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=re.LTC_FLOAT_1,n.rectAreaLTC2=re.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(n.rectAreaLTC1=re.LTC_HALF_1,n.rectAreaLTC2=re.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),n.ambient[0]=d,n.ambient[1]=p,n.ambient[2]=m;let z=n.hash;(z.directionalLength!==y||z.pointLength!==x||z.spotLength!==g||z.rectAreaLength!==f||z.hemiLength!==E||z.numDirectionalShadows!==w||z.numPointShadows!==_||z.numSpotShadows!==M)&&(n.directional.length=y,n.spot.length=g,n.rectArea.length=f,n.point.length=x,n.hemi.length=E,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=_,n.pointShadowMap.length=_,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=_,n.spotShadowMatrix.length=M,z.directionalLength=y,z.pointLength=x,z.spotLength=g,z.rectAreaLength=f,z.hemiLength=E,z.numDirectionalShadows=w,z.numPointShadows=_,z.numSpotShadows=M,n.version=o_++)}function c(u,h){let d=0,p=0,m=0,y=0,x=0,g=h.matrixWorldInverse;for(let f=0,E=u.length;f<E;f++){let w=u[f];if(w.isDirectionalLight){let _=n.directional[d];_.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),_.direction.sub(s),_.direction.transformDirection(g),d++}else if(w.isSpotLight){let _=n.spot[m];_.position.setFromMatrixPosition(w.matrixWorld),_.position.applyMatrix4(g),_.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),_.direction.sub(s),_.direction.transformDirection(g),m++}else if(w.isRectAreaLight){let _=n.rectArea[y];_.position.setFromMatrixPosition(w.matrixWorld),_.position.applyMatrix4(g),a.identity(),o.copy(w.matrixWorld),o.premultiply(g),a.extractRotation(o),_.halfWidth.set(w.width*.5,0,0),_.halfHeight.set(0,w.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),y++}else if(w.isPointLight){let _=n.point[p];_.position.setFromMatrixPosition(w.matrixWorld),_.position.applyMatrix4(g),p++}else if(w.isHemisphereLight){let _=n.hemi[x];_.direction.setFromMatrixPosition(w.matrixWorld),_.direction.transformDirection(g),_.direction.normalize(),x++}}}return{setup:l,setupView:c,state:n}}function Jf(r,e){let t=new l_(r,e),i=[],n=[];function s(){i.length=0,n.length=0}function o(h){i.push(h)}function a(h){n.push(h)}function l(h){t.setup(i,h)}function c(h){t.setupView(i,h)}return{init:s,state:{lightsArray:i,shadowsArray:n,lights:t},setupLights:l,setupLightsView:c,pushLight:o,pushShadow:a}}function c_(r,e){let t=new WeakMap;function i(s,o=0){let a;return t.has(s)===!1?(a=new Jf(r,e),t.set(s,[a])):o>=t.get(s).length?(a=new Jf(r,e),t.get(s).push(a)):a=t.get(s)[o],a}function n(){t=new WeakMap}return{get:i,dispose:n}}var Va=class extends mt{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=Iv,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}};Va.prototype.isMeshDepthMaterial=!0;var Ua=class extends mt{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new P,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}};Ua.prototype.isMeshDistanceMaterial=!0;var u_=`void main() {
gl_Position = vec4( position, 1.0 );
}`,h_=`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;
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 Um(r,e,t){let i=new Os,n=new ee,s=new ee,o=new je,a=new Va({depthPacking:Nv}),l=new Ua,c={},u=t.maxTextureSize,h={0:wt,1:Pr,2:Bs},d=new Ji({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ee},radius:{value:4}},vertexShader:u_,fragmentShader:h_}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let m=new Qe;m.setAttribute("position",new dt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new ft(m,d),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Em,this.render=function(w,_,M){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||w.length===0)return;let T=r.getRenderTarget(),z=r.getActiveCubeFace(),W=r.getActiveMipmapLevel(),A=r.state;A.setBlending(xn),A.buffers.color.setClear(1,1,1,1),A.buffers.depth.setTest(!0),A.setScissorTest(!1);for(let v=0,R=w.length;v<R;v++){let S=w[v],B=S.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",S,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;n.copy(B.mapSize);let L=B.getFrameExtents();if(n.multiply(L),s.copy(B.mapSize),(n.x>u||n.y>u)&&(n.x>u&&(s.x=Math.floor(u/L.x),n.x=s.x*L.x,B.mapSize.x=s.x),n.y>u&&(s.y=Math.floor(u/L.y),n.y=s.y*L.y,B.mapSize.y=s.y)),B.map===null&&!B.isPointLightShadow&&this.type===Tr){let N={minFilter:Ft,magFilter:Ft,format:kt};B.map=new Gt(n.x,n.y,N),B.map.texture.name=S.name+".shadowMap",B.mapPass=new Gt(n.x,n.y,N),B.camera.updateProjectionMatrix()}if(B.map===null){let N={minFilter:bt,magFilter:bt,format:kt};B.map=new Gt(n.x,n.y,N),B.map.texture.name=S.name+".shadowMap",B.camera.updateProjectionMatrix()}r.setRenderTarget(B.map),r.clear();let C=B.getViewportCount();for(let N=0;N<C;N++){let k=B.getViewport(N);o.set(s.x*k.x,s.y*k.y,s.x*k.z,s.y*k.w),A.viewport(o),B.updateMatrices(S,N),i=B.getFrustum(),E(_,M,B.camera,S,this.type)}!B.isPointLightShadow&&this.type===Tr&&g(B,M),B.needsUpdate=!1}x.needsUpdate=!1,r.setRenderTarget(T,z,W)};function g(w,_){let M=e.update(y);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,r.setRenderTarget(w.mapPass),r.clear(),r.renderBufferDirect(_,null,M,d,y,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,r.setRenderTarget(w.map),r.clear(),r.renderBufferDirect(_,null,M,p,y,null)}function f(w,_,M,T,z,W,A){let v=null,R=T.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(R!==void 0?v=R:v=T.isPointLight===!0?l:a,r.localClippingEnabled&&M.clipShadows===!0&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0){let S=v.uuid,B=M.uuid,L=c[S];L===void 0&&(L={},c[S]=L);let C=L[B];C===void 0&&(C=v.clone(),L[B]=C),v=C}return v.visible=M.visible,v.wireframe=M.wireframe,A===Tr?v.side=M.shadowSide!==null?M.shadowSide:M.side:v.side=M.shadowSide!==null?M.shadowSide:h[M.side],v.alphaMap=M.alphaMap,v.alphaTest=M.alphaTest,v.clipShadows=M.clipShadows,v.clippingPlanes=M.clippingPlanes,v.clipIntersection=M.clipIntersection,v.displacementMap=M.displacementMap,v.displacementScale=M.displacementScale,v.displacementBias=M.displacementBias,v.wireframeLinewidth=M.wireframeLinewidth,v.linewidth=M.linewidth,T.isPointLight===!0&&v.isMeshDistanceMaterial===!0&&(v.referencePosition.setFromMatrixPosition(T.matrixWorld),v.nearDistance=z,v.farDistance=W),v}function E(w,_,M,T,z){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&z===Tr)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,w.matrixWorld);let v=e.update(w),R=w.material;if(Array.isArray(R)){let S=v.groups;for(let B=0,L=S.length;B<L;B++){let C=S[B],N=R[C.materialIndex];if(N&&N.visible){let k=f(w,v,N,T,M.near,M.far,z);r.renderBufferDirect(M,null,v,k,w,C)}}}else if(R.visible){let S=f(w,v,R,T,M.near,M.far,z);r.renderBufferDirect(M,null,v,S,w,null)}}let A=w.children;for(let v=0,R=A.length;v<R;v++)E(A[v],_,M,T,z)}}function d_(r,e,t){let i=t.isWebGL2;function n(){let O=!1,ge=new je,pe=null,Me=new je(0,0,0,0);return{setMask:function(K){pe!==K&&!O&&(r.colorMask(K,K,K,K),pe=K)},setLocked:function(K){O=K},setClear:function(K,_e,ke,rt,Yt){Yt===!0&&(K*=rt,_e*=rt,ke*=rt),ge.set(K,_e,ke,rt),Me.equals(ge)===!1&&(r.clearColor(K,_e,ke,rt),Me.copy(ge))},reset:function(){O=!1,pe=null,Me.set(-1,0,0,0)}}}function s(){let O=!1,ge=null,pe=null,Me=null;return{setTest:function(K){K?H(2929):Te(2929)},setMask:function(K){ge!==K&&!O&&(r.depthMask(K),ge=K)},setFunc:function(K){if(pe!==K){if(K)switch(K){case tv:r.depthFunc(512);break;case iv:r.depthFunc(519);break;case nv:r.depthFunc(513);break;case Cu:r.depthFunc(515);break;case sv:r.depthFunc(514);break;case rv:r.depthFunc(518);break;case ov:r.depthFunc(516);break;case av:r.depthFunc(517);break;default:r.depthFunc(515)}else r.depthFunc(515);pe=K}},setLocked:function(K){O=K},setClear:function(K){Me!==K&&(r.clearDepth(K),Me=K)},reset:function(){O=!1,ge=null,pe=null,Me=null}}}function o(){let O=!1,ge=null,pe=null,Me=null,K=null,_e=null,ke=null,rt=null,Yt=null;return{setTest:function(at){O||(at?H(2960):Te(2960))},setMask:function(at){ge!==at&&!O&&(r.stencilMask(at),ge=at)},setFunc:function(at,vi,Ii){(pe!==at||Me!==vi||K!==Ii)&&(r.stencilFunc(at,vi,Ii),pe=at,Me=vi,K=Ii)},setOp:function(at,vi,Ii){(_e!==at||ke!==vi||rt!==Ii)&&(r.stencilOp(at,vi,Ii),_e=at,ke=vi,rt=Ii)},setLocked:function(at){O=at},setClear:function(at){Yt!==at&&(r.clearStencil(at),Yt=at)},reset:function(){O=!1,ge=null,pe=null,Me=null,K=null,_e=null,ke=null,rt=null,Yt=null}}}let a=new n,l=new s,c=new o,u={},h={},d=new WeakMap,p=[],m=null,y=!1,x=null,g=null,f=null,E=null,w=null,_=null,M=null,T=!1,z=null,W=null,A=null,v=null,R=null,S=r.getParameter(35661),B=!1,L=0,C=r.getParameter(7938);C.indexOf("WebGL")!==-1?(L=parseFloat(/^WebGL (\d)/.exec(C)[1]),B=L>=1):C.indexOf("OpenGL ES")!==-1&&(L=parseFloat(/^OpenGL ES (\d)/.exec(C)[1]),B=L>=2);let N=null,k={},V=r.getParameter(3088),U=r.getParameter(2978),q=new je().fromArray(V),j=new je().fromArray(U);function ne(O,ge,pe){let Me=new Uint8Array(4),K=r.createTexture();r.bindTexture(O,K),r.texParameteri(O,10241,9728),r.texParameteri(O,10240,9728);for(let _e=0;_e<pe;_e++)r.texImage2D(ge+_e,0,6408,1,1,0,6408,5121,Me);return K}let ae={};ae[3553]=ne(3553,3553,1),ae[34067]=ne(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),H(2929),l.setFunc(Cu),te(!1),fe(Up),H(2884),Z(xn);function H(O){u[O]!==!0&&(r.enable(O),u[O]=!0)}function Te(O){u[O]!==!1&&(r.disable(O),u[O]=!1)}function ue(O,ge){return h[O]!==ge?(r.bindFramebuffer(O,ge),h[O]=ge,i&&(O===36009&&(h[36160]=ge),O===36160&&(h[36009]=ge)),!0):!1}function we(O,ge){let pe=p,Me=!1;if(O)if(pe=d.get(ge),pe===void 0&&(pe=[],d.set(ge,pe)),O.isWebGLMultipleRenderTargets){let K=O.texture;if(pe.length!==K.length||pe[0]!==36064){for(let _e=0,ke=K.length;_e<ke;_e++)pe[_e]=36064+_e;pe.length=K.length,Me=!0}}else pe[0]!==36064&&(pe[0]=36064,Me=!0);else pe[0]!==1029&&(pe[0]=1029,Me=!0);Me&&(t.isWebGL2?r.drawBuffers(pe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(pe))}function oe(O){return m!==O?(r.useProgram(O),m=O,!0):!1}let Ce={[Ss]:32774,[qx]:32778,[Wx]:32779};if(i)Ce[Wp]=32775,Ce[$p]=32776;else{let O=e.get("EXT_blend_minmax");O!==null&&(Ce[Wp]=O.MIN_EXT,Ce[$p]=O.MAX_EXT)}let Ae={[$x]:0,[jx]:1,[Xx]:768,[Sm]:770,[ev]:776,[Kx]:774,[Zx]:772,[Yx]:769,[Mm]:771,[Qx]:775,[Jx]:773};function Z(O,ge,pe,Me,K,_e,ke,rt){if(O===xn){y===!0&&(Te(3042),y=!1);return}if(y===!1&&(H(3042),y=!0),O!==Gx){if(O!==x||rt!==T){if((g!==Ss||w!==Ss)&&(r.blendEquation(32774),g=Ss,w=Ss),rt)switch(O){case Rr:r.blendFuncSeparate(1,771,1,771);break;case Hp:r.blendFunc(1,1);break;case Gp:r.blendFuncSeparate(0,769,0,1);break;case qp:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}else switch(O){case Rr:r.blendFuncSeparate(770,771,1,771);break;case Hp:r.blendFunc(770,1);break;case Gp:r.blendFuncSeparate(0,769,0,1);break;case qp:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}f=null,E=null,_=null,M=null,x=O,T=rt}return}K=K||ge,_e=_e||pe,ke=ke||Me,(ge!==g||K!==w)&&(r.blendEquationSeparate(Ce[ge],Ce[K]),g=ge,w=K),(pe!==f||Me!==E||_e!==_||ke!==M)&&(r.blendFuncSeparate(Ae[pe],Ae[Me],Ae[_e],Ae[ke]),f=pe,E=Me,_=_e,M=ke),x=O,T=null}function ie(O,ge){O.side===Bs?Te(2884):H(2884);let pe=O.side===wt;ge&&(pe=!pe),te(pe),O.blending===Rr&&O.transparent===!1?Z(xn):Z(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.premultipliedAlpha),l.setFunc(O.depthFunc),l.setTest(O.depthTest),l.setMask(O.depthWrite),a.setMask(O.colorWrite);let Me=O.stencilWrite;c.setTest(Me),Me&&(c.setMask(O.stencilWriteMask),c.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),c.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),Se(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?H(32926):Te(32926)}function te(O){z!==O&&(O?r.frontFace(2304):r.frontFace(2305),z=O)}function fe(O){O!==Ux?(H(2884),O!==W&&(O===Up?r.cullFace(1029):O===Hx?r.cullFace(1028):r.cullFace(1032))):Te(2884),W=O}function de(O){O!==A&&(B&&r.lineWidth(O),A=O)}function Se(O,ge,pe){O?(H(32823),(v!==ge||R!==pe)&&(r.polygonOffset(ge,pe),v=ge,R=pe)):Te(32823)}function Re(O){O?H(3089):Te(3089)}function Oe(O){O===void 0&&(O=33984+S-1),N!==O&&(r.activeTexture(O),N=O)}function Je(O,ge){N===null&&Oe();let pe=k[N];pe===void 0&&(pe={type:void 0,texture:void 0},k[N]=pe),(pe.type!==O||pe.texture!==ge)&&(r.bindTexture(O,ge||ae[O]),pe.type=O,pe.texture=ge)}function Xe(){let O=k[N];O!==void 0&&O.type!==void 0&&(r.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function I(){try{r.compressedTexImage2D.apply(r,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function D(){try{r.texSubImage2D.apply(r,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function J(){try{r.texSubImage3D.apply(r,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function se(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function xe(){try{r.texStorage2D.apply(r,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Y(){try{r.texStorage3D.apply(r,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function be(){try{r.texImage2D.apply(r,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ve(){try{r.texImage3D.apply(r,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function he(O){q.equals(O)===!1&&(r.scissor(O.x,O.y,O.z,O.w),q.copy(O))}function ce(O){j.equals(O)===!1&&(r.viewport(O.x,O.y,O.z,O.w),j.copy(O))}function Le(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),i===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),u={},N=null,k={},h={},d=new WeakMap,p=[],m=null,y=!1,x=null,g=null,f=null,E=null,w=null,_=null,M=null,T=!1,z=null,W=null,A=null,v=null,R=null,q.set(0,0,r.canvas.width,r.canvas.height),j.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:H,disable:Te,bindFramebuffer:ue,drawBuffers:we,useProgram:oe,setBlending:Z,setMaterial:ie,setFlipSided:te,setCullFace:fe,setLineWidth:de,setPolygonOffset:Se,setScissorTest:Re,activeTexture:Oe,bindTexture:Je,unbindTexture:Xe,compressedTexImage2D:I,texImage2D:be,texImage3D:ve,texStorage2D:xe,texStorage3D:Y,texSubImage2D:D,texSubImage3D:J,compressedTexSubImage2D:se,scissor:he,viewport:ce,reset:Le}}function p_(r,e,t,i,n,s,o){let a=n.isWebGL2,l=n.maxTextures,c=n.maxCubemapSize,u=n.maxTextureSize,h=n.maxSamples,p=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):void 0,m=new WeakMap,y,x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(I,D){return x?new OffscreenCanvas(I,D):kr("canvas")}function f(I,D,J,se){let xe=1;if((I.width>se||I.height>se)&&(xe=se/Math.max(I.width,I.height)),xe<1||D===!0)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap){let Y=D?Vv:Math.floor,be=Y(xe*I.width),ve=Y(xe*I.height);y===void 0&&(y=g(be,ve));let he=J?g(be,ve):y;return he.width=be,he.height=ve,he.getContext("2d").drawImage(I,0,0,be,ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+I.width+"x"+I.height+") to ("+be+"x"+ve+")."),he}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+I.width+"x"+I.height+")."),I;return I}function E(I){return xf(I.width)&&xf(I.height)}function w(I){return a?!1:I.wrapS!==Qt||I.wrapT!==Qt||I.minFilter!==bt&&I.minFilter!==Ft}function _(I,D){return I.generateMipmaps&&D&&I.minFilter!==bt&&I.minFilter!==Ft}function M(I){r.generateMipmap(I)}function T(I,D,J,se,xe=!1){if(a===!1)return D;if(I!==null){if(r[I]!==void 0)return r[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let Y=D;return D===6403&&(J===5126&&(Y=33326),J===5131&&(Y=33325),J===5121&&(Y=33321)),D===33319&&(J===5126&&(Y=33328),J===5131&&(Y=33327),J===5121&&(Y=33323)),D===6408&&(J===5126&&(Y=34836),J===5131&&(Y=34842),J===5121&&(Y=se===it&&xe===!1?35907:32856),J===32819&&(Y=32854),J===32820&&(Y=32855)),(Y===33325||Y===33326||Y===33327||Y===33328||Y===34842||Y===34836)&&e.get("EXT_color_buffer_float"),Y}function z(I,D,J){return _(I,J)===!0||I.isFramebufferTexture&&I.minFilter!==bt&&I.minFilter!==Ft?Math.log2(Math.max(D.width,D.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?D.mipmaps.length:1}function W(I){return I===bt||I===jp||I===Xp?9728:9729}function A(I){let D=I.target;D.removeEventListener("dispose",A),R(D),D.isVideoTexture&&m.delete(D),o.memory.textures--}function v(I){let D=I.target;D.removeEventListener("dispose",v),S(D)}function R(I){let D=i.get(I);D.__webglInit!==void 0&&(r.deleteTexture(D.__webglTexture),i.remove(I))}function S(I){let D=I.texture,J=i.get(I),se=i.get(D);if(I){if(se.__webglTexture!==void 0&&(r.deleteTexture(se.__webglTexture),o.memory.textures--),I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++)r.deleteFramebuffer(J.__webglFramebuffer[xe]),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer[xe]);else r.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&r.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer&&r.deleteRenderbuffer(J.__webglColorRenderbuffer),J.__webglDepthRenderbuffer&&r.deleteRenderbuffer(J.__webglDepthRenderbuffer);if(I.isWebGLMultipleRenderTargets)for(let xe=0,Y=D.length;xe<Y;xe++){let be=i.get(D[xe]);be.__webglTexture&&(r.deleteTexture(be.__webglTexture),o.memory.textures--),i.remove(D[xe])}i.remove(D),i.remove(I)}}let B=0;function L(){B=0}function C(){let I=B;return I>=l&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+l),B+=1,I}function N(I,D){let J=i.get(I);if(I.isVideoTexture&&de(I),I.version>0&&J.__version!==I.version){let se=I.image;if(se===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(se.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{H(J,I,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,J.__webglTexture)}function k(I,D){let J=i.get(I);if(I.version>0&&J.__version!==I.version){H(J,I,D);return}t.activeTexture(33984+D),t.bindTexture(35866,J.__webglTexture)}function V(I,D){let J=i.get(I);if(I.version>0&&J.__version!==I.version){H(J,I,D);return}t.activeTexture(33984+D),t.bindTexture(32879,J.__webglTexture)}function U(I,D){let J=i.get(I);if(I.version>0&&J.__version!==I.version){Te(J,I,D);return}t.activeTexture(33984+D),t.bindTexture(34067,J.__webglTexture)}let q={[Lu]:10497,[Qt]:33071,[Bu]:33648},j={[bt]:9728,[jp]:9984,[Xp]:9986,[Ft]:9729,[mv]:9985,[al]:9987};function ne(I,D,J){if(J?(r.texParameteri(I,10242,q[D.wrapS]),r.texParameteri(I,10243,q[D.wrapT]),(I===32879||I===35866)&&r.texParameteri(I,32882,q[D.wrapR]),r.texParameteri(I,10240,j[D.magFilter]),r.texParameteri(I,10241,j[D.minFilter])):(r.texParameteri(I,10242,33071),r.texParameteri(I,10243,33071),(I===32879||I===35866)&&r.texParameteri(I,32882,33071),(D.wrapS!==Qt||D.wrapT!==Qt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(I,10240,W(D.magFilter)),r.texParameteri(I,10241,W(D.minFilter)),D.minFilter!==bt&&D.minFilter!==Ft&&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 se=e.get("EXT_texture_filter_anisotropic");if(D.type===Un&&e.has("OES_texture_float_linear")===!1||a===!1&&D.type===Cs&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||i.get(D).__currentAnisotropy)&&(r.texParameterf(I,se.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,n.getMaxAnisotropy())),i.get(D).__currentAnisotropy=D.anisotropy)}}function ae(I,D){I.__webglInit===void 0&&(I.__webglInit=!0,D.addEventListener("dispose",A),I.__webglTexture=r.createTexture(),o.memory.textures++)}function H(I,D,J){let se=3553;D.isDataTexture2DArray&&(se=35866),D.isDataTexture3D&&(se=32879),ae(I,D),t.activeTexture(33984+J),t.bindTexture(se,I.__webglTexture),r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let xe=w(D)&&E(D.image)===!1,Y=f(D.image,xe,!1,u);Y=Se(D,Y);let be=E(Y)||a,ve=s.convert(D.format,D.encoding),he=s.convert(D.type),ce=T(D.internalFormat,ve,he,D.encoding,D.isVideoTexture);ne(se,D,be);let Le,O=D.mipmaps,ge=a&&D.isVideoTexture!==!0,pe=I.__version===void 0,Me=z(D,Y,be);if(D.isDepthTexture)ce=6402,a?D.type===Un?ce=36012:D.type===Ca?ce=33190:D.type===Rs?ce=35056:ce=33189:D.type===Un&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===Gn&&ce===6402&&D.type!==Ir&&D.type!==Ca&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Ir,he=s.convert(D.type)),D.format===Ps&&ce===6402&&(ce=34041,D.type!==Rs&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=Rs,he=s.convert(D.type))),ge&&pe?t.texStorage2D(3553,1,ce,Y.width,Y.height):t.texImage2D(3553,0,ce,Y.width,Y.height,0,ve,he,null);else if(D.isDataTexture)if(O.length>0&&be){ge&&pe&&t.texStorage2D(3553,Me,ce,O[0].width,O[0].height);for(let K=0,_e=O.length;K<_e;K++)Le=O[K],ge?t.texSubImage2D(3553,0,0,0,Le.width,Le.height,ve,he,Le.data):t.texImage2D(3553,K,ce,Le.width,Le.height,0,ve,he,Le.data);D.generateMipmaps=!1}else ge?(pe&&t.texStorage2D(3553,Me,ce,Y.width,Y.height),t.texSubImage2D(3553,0,0,0,Y.width,Y.height,ve,he,Y.data)):t.texImage2D(3553,0,ce,Y.width,Y.height,0,ve,he,Y.data);else if(D.isCompressedTexture){ge&&pe&&t.texStorage2D(3553,Me,ce,O[0].width,O[0].height);for(let K=0,_e=O.length;K<_e;K++)Le=O[K],D.format!==kt?ve!==null?ge?t.compressedTexSubImage2D(3553,K,0,0,Le.width,Le.height,ve,Le.data):t.compressedTexImage2D(3553,K,ce,Le.width,Le.height,0,Le.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?t.texSubImage2D(3553,K,0,0,Le.width,Le.height,ve,he,Le.data):t.texImage2D(3553,K,ce,Le.width,Le.height,0,ve,he,Le.data)}else if(D.isDataTexture2DArray)ge?(pe&&t.texStorage3D(35866,Me,ce,Y.width,Y.height,Y.depth),t.texSubImage3D(35866,0,0,0,0,Y.width,Y.height,Y.depth,ve,he,Y.data)):t.texImage3D(35866,0,ce,Y.width,Y.height,Y.depth,0,ve,he,Y.data);else if(D.isDataTexture3D)ge?(pe&&t.texStorage3D(32879,Me,ce,Y.width,Y.height,Y.depth),t.texSubImage3D(32879,0,0,0,0,Y.width,Y.height,Y.depth,ve,he,Y.data)):t.texImage3D(32879,0,ce,Y.width,Y.height,Y.depth,0,ve,he,Y.data);else if(D.isFramebufferTexture)ge&&pe?t.texStorage2D(3553,Me,ce,Y.width,Y.height):t.texImage2D(3553,0,ce,Y.width,Y.height,0,ve,he,null);else if(O.length>0&&be){ge&&pe&&t.texStorage2D(3553,Me,ce,O[0].width,O[0].height);for(let K=0,_e=O.length;K<_e;K++)Le=O[K],ge?t.texSubImage2D(3553,K,0,0,ve,he,Le):t.texImage2D(3553,K,ce,ve,he,Le);D.generateMipmaps=!1}else ge?(pe&&t.texStorage2D(3553,Me,ce,Y.width,Y.height),t.texSubImage2D(3553,0,0,0,ve,he,Y)):t.texImage2D(3553,0,ce,ve,he,Y);_(D,be)&&M(se),I.__version=D.version,D.onUpdate&&D.onUpdate(D)}function Te(I,D,J){if(D.image.length!==6)return;ae(I,D),t.activeTexture(33984+J),t.bindTexture(34067,I.__webglTexture),r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let se=D&&(D.isCompressedTexture||D.image[0].isCompressedTexture),xe=D.image[0]&&D.image[0].isDataTexture,Y=[];for(let K=0;K<6;K++)!se&&!xe?Y[K]=f(D.image[K],!1,!0,c):Y[K]=xe?D.image[K].image:D.image[K],Y[K]=Se(D,Y[K]);let be=Y[0],ve=E(be)||a,he=s.convert(D.format,D.encoding),ce=s.convert(D.type),Le=T(D.internalFormat,he,ce,D.encoding),O=a&&D.isVideoTexture!==!0,ge=I.__version===void 0,pe=z(D,be,ve);ne(34067,D,ve);let Me;if(se){O&&ge&&t.texStorage2D(34067,pe,Le,be.width,be.height);for(let K=0;K<6;K++){Me=Y[K].mipmaps;for(let _e=0;_e<Me.length;_e++){let ke=Me[_e];D.format!==kt?he!==null?O?t.compressedTexSubImage2D(34069+K,_e,0,0,ke.width,ke.height,he,ke.data):t.compressedTexImage2D(34069+K,_e,Le,ke.width,ke.height,0,ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):O?t.texSubImage2D(34069+K,_e,0,0,ke.width,ke.height,he,ce,ke.data):t.texImage2D(34069+K,_e,Le,ke.width,ke.height,0,he,ce,ke.data)}}}else{Me=D.mipmaps,O&&ge&&(Me.length>0&&pe++,t.texStorage2D(34067,pe,Le,Y[0].width,Y[0].height));for(let K=0;K<6;K++)if(xe){O?t.texSubImage2D(34069+K,0,0,0,Y[K].width,Y[K].height,he,ce,Y[K].data):t.texImage2D(34069+K,0,Le,Y[K].width,Y[K].height,0,he,ce,Y[K].data);for(let _e=0;_e<Me.length;_e++){let rt=Me[_e].image[K].image;O?t.texSubImage2D(34069+K,_e+1,0,0,rt.width,rt.height,he,ce,rt.data):t.texImage2D(34069+K,_e+1,Le,rt.width,rt.height,0,he,ce,rt.data)}}else{O?t.texSubImage2D(34069+K,0,0,0,he,ce,Y[K]):t.texImage2D(34069+K,0,Le,he,ce,Y[K]);for(let _e=0;_e<Me.length;_e++){let ke=Me[_e];O?t.texSubImage2D(34069+K,_e+1,0,0,he,ce,ke.image[K]):t.texImage2D(34069+K,_e+1,Le,he,ce,ke.image[K])}}}_(D,ve)&&M(34067),I.__version=D.version,D.onUpdate&&D.onUpdate(D)}function ue(I,D,J,se,xe){let Y=s.convert(J.format,J.encoding),be=s.convert(J.type),ve=T(J.internalFormat,Y,be,J.encoding);i.get(D).__hasExternalTextures||(xe===32879||xe===35866?t.texImage3D(xe,0,ve,D.width,D.height,D.depth,0,Y,be,null):t.texImage2D(xe,0,ve,D.width,D.height,0,Y,be,null)),t.bindFramebuffer(36160,I),D.useRenderToTexture?p.framebufferTexture2DMultisampleEXT(36160,se,xe,i.get(J).__webglTexture,0,fe(D)):r.framebufferTexture2D(36160,se,xe,i.get(J).__webglTexture,0),t.bindFramebuffer(36160,null)}function we(I,D,J){if(r.bindRenderbuffer(36161,I),D.depthBuffer&&!D.stencilBuffer){let se=33189;if(J||D.useRenderToTexture){let xe=D.depthTexture;xe&&xe.isDepthTexture&&(xe.type===Un?se=36012:xe.type===Ca&&(se=33190));let Y=fe(D);D.useRenderToTexture?p.renderbufferStorageMultisampleEXT(36161,Y,se,D.width,D.height):r.renderbufferStorageMultisample(36161,Y,se,D.width,D.height)}else r.renderbufferStorage(36161,se,D.width,D.height);r.framebufferRenderbuffer(36160,36096,36161,I)}else if(D.depthBuffer&&D.stencilBuffer){let se=fe(D);J&&D.useRenderbuffer?r.renderbufferStorageMultisample(36161,se,35056,D.width,D.height):D.useRenderToTexture?p.renderbufferStorageMultisampleEXT(36161,se,35056,D.width,D.height):r.renderbufferStorage(36161,34041,D.width,D.height),r.framebufferRenderbuffer(36160,33306,36161,I)}else{let se=D.isWebGLMultipleRenderTargets===!0?D.texture[0]:D.texture,xe=s.convert(se.format,se.encoding),Y=s.convert(se.type),be=T(se.internalFormat,xe,Y,se.encoding),ve=fe(D);J&&D.useRenderbuffer?r.renderbufferStorageMultisample(36161,ve,be,D.width,D.height):D.useRenderToTexture?p.renderbufferStorageMultisampleEXT(36161,ve,be,D.width,D.height):r.renderbufferStorage(36161,be,D.width,D.height)}r.bindRenderbuffer(36161,null)}function oe(I,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,I),!(D.depthTexture&&D.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(D.depthTexture).__webglTexture||D.depthTexture.image.width!==D.width||D.depthTexture.image.height!==D.height)&&(D.depthTexture.image.width=D.width,D.depthTexture.image.height=D.height,D.depthTexture.needsUpdate=!0),N(D.depthTexture,0);let se=i.get(D.depthTexture).__webglTexture,xe=fe(D);if(D.depthTexture.format===Gn)D.useRenderToTexture?p.framebufferTexture2DMultisampleEXT(36160,36096,3553,se,0,xe):r.framebufferTexture2D(36160,36096,3553,se,0);else if(D.depthTexture.format===Ps)D.useRenderToTexture?p.framebufferTexture2DMultisampleEXT(36160,33306,3553,se,0,xe):r.framebufferTexture2D(36160,33306,3553,se,0);else throw new Error("Unknown depthTexture format")}function Ce(I){let D=i.get(I),J=I.isWebGLCubeRenderTarget===!0;if(I.depthTexture&&!D.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");oe(D.__webglFramebuffer,I)}else if(J){D.__webglDepthbuffer=[];for(let se=0;se<6;se++)t.bindFramebuffer(36160,D.__webglFramebuffer[se]),D.__webglDepthbuffer[se]=r.createRenderbuffer(),we(D.__webglDepthbuffer[se],I,!1)}else t.bindFramebuffer(36160,D.__webglFramebuffer),D.__webglDepthbuffer=r.createRenderbuffer(),we(D.__webglDepthbuffer,I,!1);t.bindFramebuffer(36160,null)}function Ae(I,D,J){let se=i.get(I);D!==void 0&&ue(se.__webglFramebuffer,I,I.texture,36064,3553),J!==void 0&&Ce(I)}function Z(I){let D=I.texture,J=i.get(I),se=i.get(D);I.addEventListener("dispose",v),I.isWebGLMultipleRenderTargets!==!0&&(se.__webglTexture===void 0&&(se.__webglTexture=r.createTexture()),se.__version=D.version,o.memory.textures++);let xe=I.isWebGLCubeRenderTarget===!0,Y=I.isWebGLMultipleRenderTargets===!0,be=D.isDataTexture3D||D.isDataTexture2DArray,ve=E(I)||a;if(xe){J.__webglFramebuffer=[];for(let he=0;he<6;he++)J.__webglFramebuffer[he]=r.createFramebuffer()}else if(J.__webglFramebuffer=r.createFramebuffer(),Y)if(n.drawBuffers){let he=I.texture;for(let ce=0,Le=he.length;ce<Le;ce++){let O=i.get(he[ce]);O.__webglTexture===void 0&&(O.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(I.useRenderbuffer)if(a){J.__webglMultisampledFramebuffer=r.createFramebuffer(),J.__webglColorRenderbuffer=r.createRenderbuffer(),r.bindRenderbuffer(36161,J.__webglColorRenderbuffer);let he=s.convert(D.format,D.encoding),ce=s.convert(D.type),Le=T(D.internalFormat,he,ce,D.encoding),O=fe(I);r.renderbufferStorageMultisample(36161,O,Le,I.width,I.height),t.bindFramebuffer(36160,J.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064,36161,J.__webglColorRenderbuffer),r.bindRenderbuffer(36161,null),I.depthBuffer&&(J.__webglDepthRenderbuffer=r.createRenderbuffer(),we(J.__webglDepthRenderbuffer,I,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(xe){t.bindTexture(34067,se.__webglTexture),ne(34067,D,ve);for(let he=0;he<6;he++)ue(J.__webglFramebuffer[he],I,D,36064,34069+he);_(D,ve)&&M(34067),t.unbindTexture()}else if(Y){let he=I.texture;for(let ce=0,Le=he.length;ce<Le;ce++){let O=he[ce],ge=i.get(O);t.bindTexture(3553,ge.__webglTexture),ne(3553,O,ve),ue(J.__webglFramebuffer,I,O,36064+ce,3553),_(O,ve)&&M(3553)}t.unbindTexture()}else{let he=3553;be&&(a?he=D.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),t.bindTexture(he,se.__webglTexture),ne(he,D,ve),ue(J.__webglFramebuffer,I,D,36064,he),_(D,ve)&&M(he),t.unbindTexture()}I.depthBuffer&&Ce(I)}function ie(I){let D=E(I)||a,J=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let se=0,xe=J.length;se<xe;se++){let Y=J[se];if(_(Y,D)){let be=I.isWebGLCubeRenderTarget?34067:3553,ve=i.get(Y).__webglTexture;t.bindTexture(be,ve),M(be),t.unbindTexture()}}}function te(I){if(I.useRenderbuffer)if(a){let D=I.width,J=I.height,se=16384,xe=[36064],Y=I.stencilBuffer?33306:36096;I.depthBuffer&&xe.push(Y),I.ignoreDepthForMultisampleCopy||(I.depthBuffer&&(se|=256),I.stencilBuffer&&(se|=1024));let be=i.get(I);t.bindFramebuffer(36008,be.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,be.__webglFramebuffer),I.ignoreDepthForMultisampleCopy&&(r.invalidateFramebuffer(36008,[Y]),r.invalidateFramebuffer(36009,[Y])),r.blitFramebuffer(0,0,D,J,0,0,D,J,se,9728),r.invalidateFramebuffer(36008,xe),t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,be.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function fe(I){return a&&(I.useRenderbuffer||I.useRenderToTexture)?Math.min(h,I.samples):0}function de(I){let D=o.render.frame;m.get(I)!==D&&(m.set(I,D),I.update())}function Se(I,D){let J=I.encoding,se=I.format,xe=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||I.format===Pu||J!==An&&(J===it?a===!1?e.has("EXT_sRGB")===!0&&se===kt?(I.format=Pu,I.minFilter=Ft,I.generateMipmaps=!1):D=Zi.sRGBToLinear(D):(se!==kt||xe!==wn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",J)),D}let Re=!1,Oe=!1;function Je(I,D){I&&I.isWebGLRenderTarget&&(Re===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),Re=!0),I=I.texture),N(I,D)}function Xe(I,D){I&&I.isWebGLCubeRenderTarget&&(Oe===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),Oe=!0),I=I.texture),U(I,D)}this.allocateTextureUnit=C,this.resetTextureUnits=L,this.setTexture2D=N,this.setTexture2DArray=k,this.setTexture3D=V,this.setTextureCube=U,this.rebindTextures=Ae,this.setupRenderTarget=Z,this.updateRenderTargetMipmap=ie,this.updateMultisampleRenderTarget=te,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=ue,this.safeSetTexture2D=Je,this.safeSetTextureCube=Xe}function f_(r,e,t){let i=t.isWebGL2;function n(s,o=null){let a;if(s===wn)return 5121;if(s===vv)return 32819;if(s===wv)return 32820;if(s===gv)return 5120;if(s===yv)return 5122;if(s===Ir)return 5123;if(s===xv)return 5124;if(s===Ca)return 5125;if(s===Un)return 5126;if(s===Cs)return i?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===bv)return 6406;if(s===kt)return 6408;if(s===Ev)return 6409;if(s===Av)return 6410;if(s===Gn)return 6402;if(s===Ps)return 34041;if(s===Sv)return 6403;if(s===_v)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===Pu)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===Mv)return 36244;if(s===Dv)return 33319;if(s===Tv)return 33320;if(s===Cv)return 36249;if(s===qc||s===Wc||s===$c||s===jc)if(o===it)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===qc)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Wc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===$c)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===jc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===qc)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Wc)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===$c)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===jc)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Yp||s===Zp||s===Jp||s===Kp)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Yp)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Zp)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Jp)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Kp)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Rv)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Qp||s===ef)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Qp)return o===it?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===ef)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===tf||s===nf||s===sf||s===rf||s===of||s===af||s===lf||s===cf||s===uf||s===hf||s===df||s===pf||s===ff||s===mf)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===tf)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===nf)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===sf)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===rf)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===of)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===af)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===lf)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===cf)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===uf)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===hf)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===df)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===pf)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===ff)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===mf)return o===it?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===gf)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===gf)return o===it?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===Rs)return i?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:n}}var Ha=class extends Mt{constructor(e=[]){super(),this.cameras=e}};Ha.prototype.isArrayCamera=!0;var Hn=class extends qe{constructor(){super(),this.type="Group"}};Hn.prototype.isGroup=!0;var m_={type:"move"},Fr=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Hn,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 Hn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Hn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),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 n=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(a!==null&&(n=t.getPose(e.targetRaySpace,i),n!==null&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(m_))),c&&e.hand){o=!0;for(let y of e.hand.values()){let x=t.getJointPose(y,i);if(c.joints[y.jointName]===void 0){let f=new Hn;f.matrixAutoUpdate=!1,f.visible=!1,c.joints[y.jointName]=f,c.add(f)}let g=c.joints[y.jointName];x!==null&&(g.matrix.fromArray(x.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=x.radius),g.visible=x!==null}let u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),p=.02,m=.005;c.inputState.pinching&&d>p+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));return a!==null&&(a.visible=n!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}},$r=class extends ct{constructor(e,t,i,n,s,o,a,l,c,u){if(u=u!==void 0?u:Gn,u!==Gn&&u!==Ps)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Gn&&(i=Ir),i===void 0&&u===Ps&&(i=Rs),super(null,n,s,o,a,l,u,i,c),this.image={width:e,height:t},this.magFilter=a!==void 0?a:bt,this.minFilter=l!==void 0?l:bt,this.flipY=!1,this.generateMipmaps=!1}};$r.prototype.isDepthTexture=!0;var Uu=class extends Yi{constructor(e,t){super();let i=this,n=null,s=1,o=null,a="local-floor",l=e.extensions.has("WEBGL_multisampled_render_to_texture"),c=null,u=null,h=null,d=null,p=!1,m=null,y=t.getContextAttributes(),x=null,g=null,f=[],E=new Map,w=new Mt;w.layers.enable(1),w.viewport=new je;let _=new Mt;_.layers.enable(2),_.viewport=new je;let M=[w,_],T=new Ha;T.layers.enable(1),T.layers.enable(2);let z=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let q=f[U];return q===void 0&&(q=new Fr,f[U]=q),q.getTargetRaySpace()},this.getControllerGrip=function(U){let q=f[U];return q===void 0&&(q=new Fr,f[U]=q),q.getGripSpace()},this.getHand=function(U){let q=f[U];return q===void 0&&(q=new Fr,f[U]=q),q.getHandSpace()};function A(U){let q=E.get(U.inputSource);q&&q.dispatchEvent({type:U.type,data:U.inputSource})}function v(){E.forEach(function(U,q){U.disconnect(q)}),E.clear(),z=null,W=null,e.setRenderTarget(x),d=null,h=null,u=null,n=null,g=null,V.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(U){s=U,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(U){a=U,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return o},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){return u},this.getFrame=function(){return m},this.getSession=function(){return n},this.setSession=async function(U){if(n=U,n!==null){if(x=e.getRenderTarget(),n.addEventListener("select",A),n.addEventListener("selectstart",A),n.addEventListener("selectend",A),n.addEventListener("squeeze",A),n.addEventListener("squeezestart",A),n.addEventListener("squeezeend",A),n.addEventListener("end",v),n.addEventListener("inputsourceschange",R),y.xrCompatible!==!0&&await t.makeXRCompatible(),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let q={antialias:n.renderState.layers===void 0?y.antialias:!0,alpha:y.alpha,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(n,t,q),n.updateRenderState({baseLayer:d}),g=new Gt(d.framebufferWidth,d.framebufferHeight,{format:kt,type:wn,encoding:e.outputEncoding})}else{p=y.antialias;let q=null,j=null,ne=null;y.depth&&(ne=y.stencil?35056:33190,q=y.stencil?Ps:Gn,j=y.stencil?Rs:Ir);let ae={colorFormat:e.outputEncoding===it?35907:32856,depthFormat:ne,scaleFactor:s};u=new XRWebGLBinding(n,t),h=u.createProjectionLayer(ae),n.updateRenderState({layers:[h]}),p?g=new Or(h.textureWidth,h.textureHeight,{format:kt,type:wn,depthTexture:new $r(h.textureWidth,h.textureHeight,j,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:y.stencil,ignoreDepth:h.ignoreDepthValues,useRenderToTexture:l,encoding:e.outputEncoding}):g=new Gt(h.textureWidth,h.textureHeight,{format:kt,type:wn,depthTexture:new $r(h.textureWidth,h.textureHeight,j,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:y.stencil,ignoreDepth:h.ignoreDepthValues,encoding:e.outputEncoding})}g.isXRRenderTarget=!0,this.setFoveation(1),o=await n.requestReferenceSpace(a),V.setContext(n),V.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function R(U){let q=n.inputSources;for(let j=0;j<f.length;j++)E.set(q[j],f[j]);for(let j=0;j<U.removed.length;j++){let ne=U.removed[j],ae=E.get(ne);ae&&(ae.dispatchEvent({type:"disconnected",data:ne}),E.delete(ne))}for(let j=0;j<U.added.length;j++){let ne=U.added[j],ae=E.get(ne);ae&&ae.dispatchEvent({type:"connected",data:ne})}}let S=new P,B=new P;function L(U,q,j){S.setFromMatrixPosition(q.matrixWorld),B.setFromMatrixPosition(j.matrixWorld);let ne=S.distanceTo(B),ae=q.projectionMatrix.elements,H=j.projectionMatrix.elements,Te=ae[14]/(ae[10]-1),ue=ae[14]/(ae[10]+1),we=(ae[9]+1)/ae[5],oe=(ae[9]-1)/ae[5],Ce=(ae[8]-1)/ae[0],Ae=(H[8]+1)/H[0],Z=Te*Ce,ie=Te*Ae,te=ne/(-Ce+Ae),fe=te*-Ce;q.matrixWorld.decompose(U.position,U.quaternion,U.scale),U.translateX(fe),U.translateZ(te),U.matrixWorld.compose(U.position,U.quaternion,U.scale),U.matrixWorldInverse.copy(U.matrixWorld).invert();let de=Te+te,Se=ue+te,Re=Z-fe,Oe=ie+(ne-fe),Je=we*ue/Se*de,Xe=oe*ue/Se*de;U.projectionMatrix.makePerspective(Re,Oe,Je,Xe,de,Se)}function C(U,q){q===null?U.matrixWorld.copy(U.matrix):U.matrixWorld.multiplyMatrices(q.matrixWorld,U.matrix),U.matrixWorldInverse.copy(U.matrixWorld).invert()}this.updateCamera=function(U){if(n===null)return;T.near=_.near=w.near=U.near,T.far=_.far=w.far=U.far,(z!==T.near||W!==T.far)&&(n.updateRenderState({depthNear:T.near,depthFar:T.far}),z=T.near,W=T.far);let q=U.parent,j=T.cameras;C(T,q);for(let ae=0;ae<j.length;ae++)C(j[ae],q);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),U.position.copy(T.position),U.quaternion.copy(T.quaternion),U.scale.copy(T.scale),U.matrix.copy(T.matrix),U.matrixWorld.copy(T.matrixWorld);let ne=U.children;for(let ae=0,H=ne.length;ae<H;ae++)ne[ae].updateMatrixWorld(!0);j.length===2?L(T,w,_):T.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(h!==null)return h.fixedFoveation;if(d!==null)return d.fixedFoveation},this.setFoveation=function(U){h!==null&&(h.fixedFoveation=U),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=U)};let N=null;function k(U,q){if(c=q.getViewerPose(o),m=q,c!==null){let ne=c.views;d!==null&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let ae=!1;ne.length!==T.cameras.length&&(T.cameras.length=0,ae=!0);for(let H=0;H<ne.length;H++){let Te=ne[H],ue=null;if(d!==null)ue=d.getViewport(Te);else{let oe=u.getViewSubImage(h,Te);ue=oe.viewport,H===0&&(e.setRenderTargetTextures(g,oe.colorTexture,h.ignoreDepthValues?void 0:oe.depthStencilTexture),e.setRenderTarget(g))}let we=M[H];we.matrix.fromArray(Te.transform.matrix),we.projectionMatrix.fromArray(Te.projectionMatrix),we.viewport.set(ue.x,ue.y,ue.width,ue.height),H===0&&T.matrix.copy(we.matrix),ae===!0&&T.cameras.push(we)}}let j=n.inputSources;for(let ne=0;ne<f.length;ne++){let ae=f[ne],H=j[ne];ae.update(H,q,o)}N&&N(U,q),m=null}let V=new Fm;V.setAnimationLoop(k),this.setAnimationLoop=function(U){N=U},this.dispose=function(){}}};function g_(r){function e(g,f){g.fogColor.value.copy(f.color),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function t(g,f,E,w,_){f.isMeshBasicMaterial?i(g,f):f.isMeshLambertMaterial?(i(g,f),l(g,f)):f.isMeshToonMaterial?(i(g,f),u(g,f)):f.isMeshPhongMaterial?(i(g,f),c(g,f)):f.isMeshStandardMaterial?(i(g,f),f.isMeshPhysicalMaterial?d(g,f,_):h(g,f)):f.isMeshMatcapMaterial?(i(g,f),p(g,f)):f.isMeshDepthMaterial?(i(g,f),m(g,f)):f.isMeshDistanceMaterial?(i(g,f),y(g,f)):f.isMeshNormalMaterial?(i(g,f),x(g,f)):f.isLineBasicMaterial?(n(g,f),f.isLineDashedMaterial&&s(g,f)):f.isPointsMaterial?o(g,f,E,w):f.isSpriteMaterial?a(g,f):f.isShadowMaterial?(g.color.value.copy(f.color),g.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function i(g,f){g.opacity.value=f.opacity,f.color&&g.diffuse.value.copy(f.color),f.emissive&&g.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(g.map.value=f.map),f.alphaMap&&(g.alphaMap.value=f.alphaMap),f.specularMap&&(g.specularMap.value=f.specularMap),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);let E=r.get(f).envMap;E&&(g.envMap.value=E,g.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity);let w;f.map?w=f.map:f.specularMap?w=f.specularMap:f.displacementMap?w=f.displacementMap:f.normalMap?w=f.normalMap:f.bumpMap?w=f.bumpMap:f.roughnessMap?w=f.roughnessMap:f.metalnessMap?w=f.metalnessMap:f.alphaMap?w=f.alphaMap:f.emissiveMap?w=f.emissiveMap:f.clearcoatMap?w=f.clearcoatMap:f.clearcoatNormalMap?w=f.clearcoatNormalMap:f.clearcoatRoughnessMap?w=f.clearcoatRoughnessMap:f.specularIntensityMap?w=f.specularIntensityMap:f.specularColorMap?w=f.specularColorMap:f.transmissionMap?w=f.transmissionMap:f.thicknessMap?w=f.thicknessMap:f.sheenColorMap?w=f.sheenColorMap:f.sheenRoughnessMap&&(w=f.sheenRoughnessMap),w!==void 0&&(w.isWebGLRenderTarget&&(w=w.texture),w.matrixAutoUpdate===!0&&w.updateMatrix(),g.uvTransform.value.copy(w.matrix));let _;f.aoMap?_=f.aoMap:f.lightMap&&(_=f.lightMap),_!==void 0&&(_.isWebGLRenderTarget&&(_=_.texture),_.matrixAutoUpdate===!0&&_.updateMatrix(),g.uv2Transform.value.copy(_.matrix))}function n(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity}function s(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function o(g,f,E,w){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*E,g.scale.value=w*.5,f.map&&(g.map.value=f.map),f.alphaMap&&(g.alphaMap.value=f.alphaMap),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);let _;f.map?_=f.map:f.alphaMap&&(_=f.alphaMap),_!==void 0&&(_.matrixAutoUpdate===!0&&_.updateMatrix(),g.uvTransform.value.copy(_.matrix))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map),f.alphaMap&&(g.alphaMap.value=f.alphaMap),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);let E;f.map?E=f.map:f.alphaMap&&(E=f.alphaMap),E!==void 0&&(E.matrixAutoUpdate===!0&&E.updateMatrix(),g.uvTransform.value.copy(E.matrix))}function l(g,f){f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap)}function c(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===wt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===wt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function u(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===wt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===wt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function h(g,f){g.roughness.value=f.roughness,g.metalness.value=f.metalness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap),f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===wt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===wt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),r.get(f).envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function d(g,f,E){h(g,f),g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap)),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap),f.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),g.clearcoatNormalMap.value=f.clearcoatNormalMap,f.side===wt&&g.clearcoatNormalScale.value.negate())),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=E.texture,g.transmissionSamplerSize.value.set(E.width,E.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap)}function p(g,f){f.matcap&&(g.matcap.value=f.matcap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===wt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===wt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function m(g,f){f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function y(g,f){f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),g.referencePosition.value.copy(f.referencePosition),g.nearDistance.value=f.nearDistance,g.farDistance.value=f.farDistance}function x(g,f){f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===wt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===wt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:t}}function y_(){let r=kr("canvas");return r.style.display="block",r}function We(r={}){let e=r.canvas!==void 0?r.canvas:y_(),t=r.context!==void 0?r.context:null,i=r.alpha!==void 0?r.alpha:!1,n=r.depth!==void 0?r.depth:!0,s=r.stencil!==void 0?r.stencil:!0,o=r.antialias!==void 0?r.antialias:!1,a=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,l=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,c=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,h=null,d=null,p=[],m=[];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=An,this.physicallyCorrectLights=!1,this.toneMapping=vn,this.toneMappingExposure=1;let y=this,x=!1,g=0,f=0,E=null,w=-1,_=null,M=new je,T=new je,z=null,W=e.width,A=e.height,v=1,R=null,S=null,B=new je(0,0,W,A),L=new je(0,0,W,A),C=!1,N=new Os,k=!1,V=!1,U=null,q=new Ee,j=new P,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ae(){return E===null?v:1}let H=t;function Te(F,G){for(let X=0;X<F.length;X++){let $=F[X],Q=e.getContext($,G);if(Q!==null)return Q}return null}try{let F={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Gh}`),e.addEventListener("webglcontextlost",Le,!1),e.addEventListener("webglcontextrestored",O,!1),H===null){let G=["webgl2","webgl","experimental-webgl"];if(y.isWebGL1Renderer===!0&&G.shift(),H=Te(G,F),H===null)throw Te(G)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}H.getShaderPrecisionFormat===void 0&&(H.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(F){throw console.error("THREE.WebGLRenderer: "+F.message),F}let ue,we,oe,Ce,Ae,Z,ie,te,fe,de,Se,Re,Oe,Je,Xe,I,D,J,se,xe,Y,be,ve;function he(){ue=new zb(H),we=new Bb(H,ue,r),ue.init(we),be=new f_(H,ue,we),oe=new d_(H,ue,we),Ce=new Hb(H),Ae=new t_,Z=new p_(H,ue,oe,Ae,we,be,Ce),ie=new Ib(y),te=new Ob(y),fe=new n2(H,we),ve=new Fb(H,ue,fe,we),de=new Vb(H,fe,Ce,ve),Se=new $b(H,de,fe,Ce),se=new Wb(H,we,Z),I=new Pb(Ae),Re=new e_(y,ie,te,ue,we,ve,I),Oe=new g_(Ae),Je=new n_,Xe=new c_(ue,we),J=new Rb(y,ie,oe,Se,i,a),D=new Um(y,Se,we),xe=new Lb(H,ue,Ce,we),Y=new Ub(H,ue,Ce,we),Ce.programs=Re.programs,y.capabilities=we,y.extensions=ue,y.properties=Ae,y.renderLists=Je,y.shadowMap=D,y.state=oe,y.info=Ce}he();let ce=new Uu(y,H);this.xr=ce,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){let F=ue.get("WEBGL_lose_context");F&&F.loseContext()},this.forceContextRestore=function(){let F=ue.get("WEBGL_lose_context");F&&F.restoreContext()},this.getPixelRatio=function(){return v},this.setPixelRatio=function(F){F!==void 0&&(v=F,this.setSize(W,A,!1))},this.getSize=function(F){return F.set(W,A)},this.setSize=function(F,G,X){if(ce.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=F,A=G,e.width=Math.floor(F*v),e.height=Math.floor(G*v),X!==!1&&(e.style.width=F+"px",e.style.height=G+"px"),this.setViewport(0,0,F,G)},this.getDrawingBufferSize=function(F){return F.set(W*v,A*v).floor()},this.setDrawingBufferSize=function(F,G,X){W=F,A=G,v=X,e.width=Math.floor(F*X),e.height=Math.floor(G*X),this.setViewport(0,0,F,G)},this.getCurrentViewport=function(F){return F.copy(M)},this.getViewport=function(F){return F.copy(B)},this.setViewport=function(F,G,X,$){F.isVector4?B.set(F.x,F.y,F.z,F.w):B.set(F,G,X,$),oe.viewport(M.copy(B).multiplyScalar(v).floor())},this.getScissor=function(F){return F.copy(L)},this.setScissor=function(F,G,X,$){F.isVector4?L.set(F.x,F.y,F.z,F.w):L.set(F,G,X,$),oe.scissor(T.copy(L).multiplyScalar(v).floor())},this.getScissorTest=function(){return C},this.setScissorTest=function(F){oe.setScissorTest(C=F)},this.setOpaqueSort=function(F){R=F},this.setTransparentSort=function(F){S=F},this.getClearColor=function(F){return F.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(F,G,X){let $=0;(F===void 0||F)&&($|=16384),(G===void 0||G)&&($|=256),(X===void 0||X)&&($|=1024),H.clear($)},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",Le,!1),e.removeEventListener("webglcontextrestored",O,!1),Je.dispose(),Xe.dispose(),Ae.dispose(),ie.dispose(),te.dispose(),Se.dispose(),ve.dispose(),Re.dispose(),ce.dispose(),ce.removeEventListener("sessionstart",ke),ce.removeEventListener("sessionend",rt),U&&(U.dispose(),U=null),Yt.stop()};function Le(F){F.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function O(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;let F=Ce.autoReset,G=D.enabled,X=D.autoUpdate,$=D.needsUpdate,Q=D.type;he(),Ce.autoReset=F,D.enabled=G,D.autoUpdate=X,D.needsUpdate=$,D.type=Q}function ge(F){let G=F.target;G.removeEventListener("dispose",ge),pe(G)}function pe(F){Me(F),Ae.remove(F)}function Me(F){let G=Ae.get(F).programs;G!==void 0&&(G.forEach(function(X){Re.releaseProgram(X)}),F.isShaderMaterial&&Re.releaseShaderCache(F))}this.renderBufferDirect=function(F,G,X,$,Q,Fe){G===null&&(G=ne);let Be=Q.isMesh&&Q.matrixWorld.determinant()<0,Ie=g0(F,G,X,$,Q);oe.setMaterial($,Be);let Pe=X.index,$e=X.attributes.position;if(Pe===null){if($e===void 0||$e.count===0)return}else if(Pe.count===0)return;let ze=1;$.wireframe===!0&&(Pe=de.getWireframeAttribute(X),ze=2),ve.setup(Q,$,Ie,X,Pe);let Ve,lt=xe;Pe!==null&&(Ve=fe.get(Pe),lt=Y,lt.setIndex(Ve));let Pn=Pe!==null?Pe.count:$e.count,ns=X.drawRange.start*ze,He=X.drawRange.count*ze,wi=Fe!==null?Fe.start*ze:0,xt=Fe!==null?Fe.count*ze:1/0,bi=Math.max(ns,wi),Io=Math.min(Pn,ns+He,wi+xt)-1,_i=Math.max(0,Io-bi+1);if(_i!==0){if(Q.isMesh)$.wireframe===!0?(oe.setLineWidth($.wireframeLinewidth*ae()),lt.setMode(1)):lt.setMode(4);else if(Q.isLine){let Ni=$.linewidth;Ni===void 0&&(Ni=1),oe.setLineWidth(Ni*ae()),Q.isLineSegments?lt.setMode(1):Q.isLineLoop?lt.setMode(2):lt.setMode(3)}else Q.isPoints?lt.setMode(0):Q.isSprite&&lt.setMode(4);if(Q.isInstancedMesh)lt.renderInstances(bi,_i,Q.count);else if(X.isInstancedBufferGeometry){let Ni=Math.min(X.instanceCount,X._maxInstanceCount);lt.renderInstances(bi,_i,Ni)}else lt.render(bi,_i)}},this.compile=function(F,G){d=Xe.get(F),d.init(),m.push(d),F.traverseVisible(function(X){X.isLight&&X.layers.test(G.layers)&&(d.pushLight(X),X.castShadow&&d.pushShadow(X))}),d.setupLights(y.physicallyCorrectLights),F.traverse(function(X){let $=X.material;if($)if(Array.isArray($))for(let Q=0;Q<$.length;Q++){let Fe=$[Q];Sc(Fe,F,X)}else Sc($,F,X)}),m.pop(),d=null};let K=null;function _e(F){K&&K(F)}function ke(){Yt.stop()}function rt(){Yt.start()}let Yt=new Fm;Yt.setAnimationLoop(_e),typeof window<"u"&&Yt.setContext(window),this.setAnimationLoop=function(F){K=F,ce.setAnimationLoop(F),F===null?Yt.stop():Yt.start()},ce.addEventListener("sessionstart",ke),ce.addEventListener("sessionend",rt),this.render=function(F,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;F.autoUpdate===!0&&F.updateMatrixWorld(),G.parent===null&&G.updateMatrixWorld(),ce.enabled===!0&&ce.isPresenting===!0&&(ce.cameraAutoUpdate===!0&&ce.updateCamera(G),G=ce.getCamera()),F.isScene===!0&&F.onBeforeRender(y,F,G,E),d=Xe.get(F,m.length),d.init(),m.push(d),q.multiplyMatrices(G.projectionMatrix,G.matrixWorldInverse),N.setFromProjectionMatrix(q),V=this.localClippingEnabled,k=I.init(this.clippingPlanes,V,G),h=Je.get(F,p.length),h.init(),p.push(h),at(F,G,0,y.sortObjects),h.finish(),y.sortObjects===!0&&h.sort(R,S),k===!0&&I.beginShadows();let X=d.state.shadowsArray;if(D.render(X,F,G),k===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),J.render(h,F),d.setupLights(y.physicallyCorrectLights),G.isArrayCamera){let $=G.cameras;for(let Q=0,Fe=$.length;Q<Fe;Q++){let Be=$[Q];vi(h,F,Be,Be.viewport)}}else vi(h,F,G);E!==null&&(Z.updateMultisampleRenderTarget(E),Z.updateRenderTargetMipmap(E)),F.isScene===!0&&F.onAfterRender(y,F,G),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1),ve.resetDefaultState(),w=-1,_=null,m.pop(),m.length>0?d=m[m.length-1]:d=null,p.pop(),p.length>0?h=p[p.length-1]:h=null};function at(F,G,X,$){if(F.visible===!1)return;if(F.layers.test(G.layers)){if(F.isGroup)X=F.renderOrder;else if(F.isLOD)F.autoUpdate===!0&&F.update(G);else if(F.isLight)d.pushLight(F),F.castShadow&&d.pushShadow(F);else if(F.isSprite){if(!F.frustumCulled||N.intersectsSprite(F)){$&&j.setFromMatrixPosition(F.matrixWorld).applyMatrix4(q);let Be=Se.update(F),Ie=F.material;Ie.visible&&h.push(F,Be,Ie,X,j.z,null)}}else if((F.isMesh||F.isLine||F.isPoints)&&(F.isSkinnedMesh&&F.skeleton.frame!==Ce.render.frame&&(F.skeleton.update(),F.skeleton.frame=Ce.render.frame),!F.frustumCulled||N.intersectsObject(F))){$&&j.setFromMatrixPosition(F.matrixWorld).applyMatrix4(q);let Be=Se.update(F),Ie=F.material;if(Array.isArray(Ie)){let Pe=Be.groups;for(let $e=0,ze=Pe.length;$e<ze;$e++){let Ve=Pe[$e],lt=Ie[Ve.materialIndex];lt&&lt.visible&&h.push(F,Be,lt,X,j.z,Ve)}}else Ie.visible&&h.push(F,Be,Ie,X,j.z,null)}}let Fe=F.children;for(let Be=0,Ie=Fe.length;Be<Ie;Be++)at(Fe[Be],G,X,$)}function vi(F,G,X,$){let Q=F.opaque,Fe=F.transmissive,Be=F.transparent;d.setupLightsView(X),Fe.length>0&&Ii(Q,G,X),$&&oe.viewport(M.copy($)),Q.length>0&&Po(Q,G,X),Fe.length>0&&Po(Fe,G,X),Be.length>0&&Po(Be,G,X)}function Ii(F,G,X){if(U===null){let Be=o===!0&&we.isWebGL2===!0?Or:Gt;U=new Be(1024,1024,{generateMipmaps:!0,type:be.convert(Cs)!==null?Cs:wn,minFilter:al,magFilter:bt,wrapS:Qt,wrapT:Qt,useRenderToTexture:ue.has("WEBGL_multisampled_render_to_texture")})}let $=y.getRenderTarget();y.setRenderTarget(U),y.clear();let Q=y.toneMapping;y.toneMapping=vn,Po(F,G,X),y.toneMapping=Q,Z.updateMultisampleRenderTarget(U),Z.updateRenderTargetMipmap(U),y.setRenderTarget($)}function Po(F,G,X){let $=G.isScene===!0?G.overrideMaterial:null;for(let Q=0,Fe=F.length;Q<Fe;Q++){let Be=F[Q],Ie=Be.object,Pe=Be.geometry,$e=$===null?Be.material:$,ze=Be.group;Ie.layers.test(X.layers)&&m0(Ie,G,X,Pe,$e,ze)}}function m0(F,G,X,$,Q,Fe){F.onBeforeRender(y,G,X,$,Q,Fe),F.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,F.matrixWorld),F.normalMatrix.getNormalMatrix(F.modelViewMatrix),Q.onBeforeRender(y,G,X,$,F,Fe),Q.transparent===!0&&Q.side===Bs?(Q.side=wt,Q.needsUpdate=!0,y.renderBufferDirect(X,G,$,Q,F,Fe),Q.side=Pr,Q.needsUpdate=!0,y.renderBufferDirect(X,G,$,Q,F,Fe),Q.side=Bs):y.renderBufferDirect(X,G,$,Q,F,Fe),F.onAfterRender(y,G,X,$,Q,Fe)}function Sc(F,G,X){G.isScene!==!0&&(G=ne);let $=Ae.get(F),Q=d.state.lights,Fe=d.state.shadowsArray,Be=Q.state.version,Ie=Re.getParameters(F,Q.state,Fe,G,X),Pe=Re.getProgramCacheKey(Ie),$e=$.programs;$.environment=F.isMeshStandardMaterial?G.environment:null,$.fog=G.fog,$.envMap=(F.isMeshStandardMaterial?te:ie).get(F.envMap||$.environment),$e===void 0&&(F.addEventListener("dispose",ge),$e=new Map,$.programs=$e);let ze=$e.get(Pe);if(ze!==void 0){if($.currentProgram===ze&&$.lightsStateVersion===Be)return Wd(F,Ie),ze}else Ie.uniforms=Re.getUniforms(F),F.onBuild(X,Ie,y),F.onBeforeCompile(Ie,y),ze=Re.acquireProgram(Ie,Pe),$e.set(Pe,ze),$.uniforms=Ie.uniforms;let Ve=$.uniforms;(!F.isShaderMaterial&&!F.isRawShaderMaterial||F.clipping===!0)&&(Ve.clippingPlanes=I.uniform),Wd(F,Ie),$.needsLights=x0(F),$.lightsStateVersion=Be,$.needsLights&&(Ve.ambientLightColor.value=Q.state.ambient,Ve.lightProbe.value=Q.state.probe,Ve.directionalLights.value=Q.state.directional,Ve.directionalLightShadows.value=Q.state.directionalShadow,Ve.spotLights.value=Q.state.spot,Ve.spotLightShadows.value=Q.state.spotShadow,Ve.rectAreaLights.value=Q.state.rectArea,Ve.ltc_1.value=Q.state.rectAreaLTC1,Ve.ltc_2.value=Q.state.rectAreaLTC2,Ve.pointLights.value=Q.state.point,Ve.pointLightShadows.value=Q.state.pointShadow,Ve.hemisphereLights.value=Q.state.hemi,Ve.directionalShadowMap.value=Q.state.directionalShadowMap,Ve.directionalShadowMatrix.value=Q.state.directionalShadowMatrix,Ve.spotShadowMap.value=Q.state.spotShadowMap,Ve.spotShadowMatrix.value=Q.state.spotShadowMatrix,Ve.pointShadowMap.value=Q.state.pointShadowMap,Ve.pointShadowMatrix.value=Q.state.pointShadowMatrix);let lt=ze.getUniforms(),Pn=_n.seqWithValue(lt.seq,Ve);return $.currentProgram=ze,$.uniformsList=Pn,ze}function Wd(F,G){let X=Ae.get(F);X.outputEncoding=G.outputEncoding,X.instancing=G.instancing,X.skinning=G.skinning,X.morphTargets=G.morphTargets,X.morphNormals=G.morphNormals,X.morphTargetsCount=G.morphTargetsCount,X.numClippingPlanes=G.numClippingPlanes,X.numIntersection=G.numClipIntersection,X.vertexAlphas=G.vertexAlphas,X.vertexTangents=G.vertexTangents,X.toneMapping=G.toneMapping}function g0(F,G,X,$,Q){G.isScene!==!0&&(G=ne),Z.resetTextureUnits();let Fe=G.fog,Be=$.isMeshStandardMaterial?G.environment:null,Ie=E===null?y.outputEncoding:E.isXRRenderTarget===!0?E.texture.encoding:An,Pe=($.isMeshStandardMaterial?te:ie).get($.envMap||Be),$e=$.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,ze=!!$.normalMap&&!!X.attributes.tangent,Ve=!!X.morphAttributes.position,lt=!!X.morphAttributes.normal,Pn=X.morphAttributes.position?X.morphAttributes.position.length:0,ns=$.toneMapped?y.toneMapping:vn,He=Ae.get($),wi=d.state.lights;if(k===!0&&(V===!0||F!==_)){let li=F===_&&$.id===w;I.setState($,F,li)}let xt=!1;$.version===He.__version?(He.needsLights&&He.lightsStateVersion!==wi.state.version||He.outputEncoding!==Ie||Q.isInstancedMesh&&He.instancing===!1||!Q.isInstancedMesh&&He.instancing===!0||Q.isSkinnedMesh&&He.skinning===!1||!Q.isSkinnedMesh&&He.skinning===!0||He.envMap!==Pe||$.fog&&He.fog!==Fe||He.numClippingPlanes!==void 0&&(He.numClippingPlanes!==I.numPlanes||He.numIntersection!==I.numIntersection)||He.vertexAlphas!==$e||He.vertexTangents!==ze||He.morphTargets!==Ve||He.morphNormals!==lt||He.toneMapping!==ns||we.isWebGL2===!0&&He.morphTargetsCount!==Pn)&&(xt=!0):(xt=!0,He.__version=$.version);let bi=He.currentProgram;xt===!0&&(bi=Sc($,G,Q));let Io=!1,_i=!1,Ni=!1,Ct=bi.getUniforms(),ur=He.uniforms;if(oe.useProgram(bi.program)&&(Io=!0,_i=!0,Ni=!0),$.id!==w&&(w=$.id,_i=!0),Io||_!==F){if(Ct.setValue(H,"projectionMatrix",F.projectionMatrix),we.logarithmicDepthBuffer&&Ct.setValue(H,"logDepthBufFC",2/(Math.log(F.far+1)/Math.LN2)),_!==F&&(_=F,_i=!0,Ni=!0),$.isShaderMaterial||$.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshStandardMaterial||$.envMap){let li=Ct.map.cameraPosition;li!==void 0&&li.setValue(H,j.setFromMatrixPosition(F.matrixWorld))}($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&Ct.setValue(H,"isOrthographic",F.isOrthographicCamera===!0),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial||$.isShadowMaterial||Q.isSkinnedMesh)&&Ct.setValue(H,"viewMatrix",F.matrixWorldInverse)}if(Q.isSkinnedMesh){Ct.setOptional(H,Q,"bindMatrix"),Ct.setOptional(H,Q,"bindMatrixInverse");let li=Q.skeleton;li&&(we.floatVertexTextures?(li.boneTexture===null&&li.computeBoneTexture(),Ct.setValue(H,"boneTexture",li.boneTexture,Z),Ct.setValue(H,"boneTextureSize",li.boneTextureSize)):Ct.setOptional(H,li,"boneMatrices"))}return X&&(X.morphAttributes.position!==void 0||X.morphAttributes.normal!==void 0)&&se.update(Q,X,$,bi),(_i||He.receiveShadow!==Q.receiveShadow)&&(He.receiveShadow=Q.receiveShadow,Ct.setValue(H,"receiveShadow",Q.receiveShadow)),_i&&(Ct.setValue(H,"toneMappingExposure",y.toneMappingExposure),He.needsLights&&y0(ur,Ni),Fe&&$.fog&&Oe.refreshFogUniforms(ur,Fe),Oe.refreshMaterialUniforms(ur,$,v,A,U),_n.upload(H,He.uniformsList,ur,Z)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(_n.upload(H,He.uniformsList,ur,Z),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&Ct.setValue(H,"center",Q.center),Ct.setValue(H,"modelViewMatrix",Q.modelViewMatrix),Ct.setValue(H,"normalMatrix",Q.normalMatrix),Ct.setValue(H,"modelMatrix",Q.matrixWorld),bi}function y0(F,G){F.ambientLightColor.needsUpdate=G,F.lightProbe.needsUpdate=G,F.directionalLights.needsUpdate=G,F.directionalLightShadows.needsUpdate=G,F.pointLights.needsUpdate=G,F.pointLightShadows.needsUpdate=G,F.spotLights.needsUpdate=G,F.spotLightShadows.needsUpdate=G,F.rectAreaLights.needsUpdate=G,F.hemisphereLights.needsUpdate=G}function x0(F){return F.isMeshLambertMaterial||F.isMeshToonMaterial||F.isMeshPhongMaterial||F.isMeshStandardMaterial||F.isShadowMaterial||F.isShaderMaterial&&F.lights===!0}this.getActiveCubeFace=function(){return g},this.getActiveMipmapLevel=function(){return f},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(F,G,X){Ae.get(F.texture).__webglTexture=G,Ae.get(F.depthTexture).__webglTexture=X;let $=Ae.get(F);$.__hasExternalTextures=!0,$.__hasExternalTextures&&($.__autoAllocateDepthBuffer=X===void 0,$.__autoAllocateDepthBuffer||F.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),F.useRenderToTexture=!1,F.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(F,G){let X=Ae.get(F);X.__webglFramebuffer=G,X.__useDefaultFramebuffer=G===void 0},this.setRenderTarget=function(F,G=0,X=0){E=F,g=G,f=X;let $=!0;if(F){let Pe=Ae.get(F);Pe.__useDefaultFramebuffer!==void 0?(oe.bindFramebuffer(36160,null),$=!1):Pe.__webglFramebuffer===void 0?Z.setupRenderTarget(F):Pe.__hasExternalTextures&&Z.rebindTextures(F,Ae.get(F.texture).__webglTexture,Ae.get(F.depthTexture).__webglTexture)}let Q=null,Fe=!1,Be=!1;if(F){let Pe=F.texture;(Pe.isDataTexture3D||Pe.isDataTexture2DArray)&&(Be=!0);let $e=Ae.get(F).__webglFramebuffer;F.isWebGLCubeRenderTarget?(Q=$e[G],Fe=!0):F.useRenderbuffer?Q=Ae.get(F).__webglMultisampledFramebuffer:Q=$e,M.copy(F.viewport),T.copy(F.scissor),z=F.scissorTest}else M.copy(B).multiplyScalar(v).floor(),T.copy(L).multiplyScalar(v).floor(),z=C;if(oe.bindFramebuffer(36160,Q)&&we.drawBuffers&&$&&oe.drawBuffers(F,Q),oe.viewport(M),oe.scissor(T),oe.setScissorTest(z),Fe){let Pe=Ae.get(F.texture);H.framebufferTexture2D(36160,36064,34069+G,Pe.__webglTexture,X)}else if(Be){let Pe=Ae.get(F.texture),$e=G||0;H.framebufferTextureLayer(36160,36064,Pe.__webglTexture,X||0,$e)}w=-1},this.readRenderTargetPixels=function(F,G,X,$,Q,Fe,Be){if(!(F&&F.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ie=Ae.get(F).__webglFramebuffer;if(F.isWebGLCubeRenderTarget&&Be!==void 0&&(Ie=Ie[Be]),Ie){oe.bindFramebuffer(36160,Ie);try{let Pe=F.texture,$e=Pe.format,ze=Pe.type;if($e!==kt&&be.convert($e)!==H.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Ve=ze===Cs&&(ue.has("EXT_color_buffer_half_float")||we.isWebGL2&&ue.has("EXT_color_buffer_float"));if(ze!==wn&&be.convert(ze)!==H.getParameter(35738)&&!(ze===Un&&(we.isWebGL2||ue.has("OES_texture_float")||ue.has("WEBGL_color_buffer_float")))&&!Ve){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H.checkFramebufferStatus(36160)===36053?G>=0&&G<=F.width-$&&X>=0&&X<=F.height-Q&&H.readPixels(G,X,$,Q,be.convert($e),be.convert(ze),Fe):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{let Pe=E!==null?Ae.get(E).__webglFramebuffer:null;oe.bindFramebuffer(36160,Pe)}}},this.copyFramebufferToTexture=function(F,G,X=0){if(G.isFramebufferTexture!==!0){console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");return}let $=Math.pow(2,-X),Q=Math.floor(G.image.width*$),Fe=Math.floor(G.image.height*$);Z.setTexture2D(G,0),H.copyTexSubImage2D(3553,X,0,0,F.x,F.y,Q,Fe),oe.unbindTexture()},this.copyTextureToTexture=function(F,G,X,$=0){let Q=G.image.width,Fe=G.image.height,Be=be.convert(X.format),Ie=be.convert(X.type);Z.setTexture2D(X,0),H.pixelStorei(37440,X.flipY),H.pixelStorei(37441,X.premultiplyAlpha),H.pixelStorei(3317,X.unpackAlignment),G.isDataTexture?H.texSubImage2D(3553,$,F.x,F.y,Q,Fe,Be,Ie,G.image.data):G.isCompressedTexture?H.compressedTexSubImage2D(3553,$,F.x,F.y,G.mipmaps[0].width,G.mipmaps[0].height,Be,G.mipmaps[0].data):H.texSubImage2D(3553,$,F.x,F.y,Be,Ie,G.image),$===0&&X.generateMipmaps&&H.generateMipmap(3553),oe.unbindTexture()},this.copyTextureToTexture3D=function(F,G,X,$,Q=0){if(y.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Fe=F.max.x-F.min.x+1,Be=F.max.y-F.min.y+1,Ie=F.max.z-F.min.z+1,Pe=be.convert($.format),$e=be.convert($.type),ze;if($.isDataTexture3D)Z.setTexture3D($,0),ze=32879;else if($.isDataTexture2DArray)Z.setTexture2DArray($,0),ze=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(37440,$.flipY),H.pixelStorei(37441,$.premultiplyAlpha),H.pixelStorei(3317,$.unpackAlignment);let Ve=H.getParameter(3314),lt=H.getParameter(32878),Pn=H.getParameter(3316),ns=H.getParameter(3315),He=H.getParameter(32877),wi=X.isCompressedTexture?X.mipmaps[0]:X.image;H.pixelStorei(3314,wi.width),H.pixelStorei(32878,wi.height),H.pixelStorei(3316,F.min.x),H.pixelStorei(3315,F.min.y),H.pixelStorei(32877,F.min.z),X.isDataTexture||X.isDataTexture3D?H.texSubImage3D(ze,Q,G.x,G.y,G.z,Fe,Be,Ie,Pe,$e,wi.data):X.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),H.compressedTexSubImage3D(ze,Q,G.x,G.y,G.z,Fe,Be,Ie,Pe,wi.data)):H.texSubImage3D(ze,Q,G.x,G.y,G.z,Fe,Be,Ie,Pe,$e,wi),H.pixelStorei(3314,Ve),H.pixelStorei(32878,lt),H.pixelStorei(3316,Pn),H.pixelStorei(3315,ns),H.pixelStorei(32877,He),Q===0&&$.generateMipmaps&&H.generateMipmap(ze),oe.unbindTexture()},this.initTexture=function(F){Z.setTexture2D(F,0),oe.unbindTexture()},this.resetState=function(){g=0,f=0,E=null,oe.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}We.prototype.isWebGLRenderer=!0;var Hu=class extends We{};Hu.prototype.isWebGL1Renderer=!0;var Gu=class r{constructor(e,t=25e-5){this.name="",this.color=new ye(e),this.density=t}clone(){return new r(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}};Gu.prototype.isFogExp2=!0;var qu=class r{constructor(e,t=1,i=1e3){this.name="",this.color=new ye(e),this.near=t,this.far=i}clone(){return new r(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}};qu.prototype.isFog=!0;var Vs=class extends qe{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__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}};Vs.prototype.isScene=!0;var qn=class{constructor(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Nr,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=fi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,s=this.stride;n<s;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=fi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=fi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};qn.prototype.isInterleavedBuffer=!0;var ht=new P,jr=class r{constructor(e,t,i,n=!1){this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n===!0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)ht.x=this.getX(t),ht.y=this.getY(t),ht.z=this.getZ(t),ht.applyMatrix4(e),this.setXYZ(t,ht.x,ht.y,ht.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ht.x=this.getX(t),ht.y=this.getY(t),ht.z=this.getZ(t),ht.applyNormalMatrix(e),this.setXYZ(t,ht.x,ht.y,ht.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ht.x=this.getX(t),ht.y=this.getY(t),ht.z=this.getZ(t),ht.transformDirection(e),this.setXYZ(t,ht.x,ht.y,ht.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return new dt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new r(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};jr.prototype.isInterleavedBufferAttribute=!0;var Ga=class extends mt{constructor(e){super(),this.type="SpriteMaterial",this.color=new ye(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this}};Ga.prototype.isSpriteMaterial=!0;var bs,Er=new P,_s=new P,Es=new P,As=new ee,Ar=new ee,Hm=new Ee,ga=new P,Sr=new P,ya=new P,Kf=new ee,_u=new ee,Qf=new ee,Wu=class extends qe{constructor(e){if(super(),this.type="Sprite",bs===void 0){bs=new Qe;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new qn(t,5);bs.setIndex([0,1,2,0,2,3]),bs.setAttribute("position",new jr(i,3,0,!1)),bs.setAttribute("uv",new jr(i,2,3,!1))}this.geometry=bs,this.material=e!==void 0?e:new Ga,this.center=new ee(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),_s.setFromMatrixScale(this.matrixWorld),Hm.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Es.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&_s.multiplyScalar(-Es.z);let i=this.material.rotation,n,s;i!==0&&(s=Math.cos(i),n=Math.sin(i));let o=this.center;xa(ga.set(-.5,-.5,0),Es,o,_s,n,s),xa(Sr.set(.5,-.5,0),Es,o,_s,n,s),xa(ya.set(.5,.5,0),Es,o,_s,n,s),Kf.set(0,0),_u.set(1,0),Qf.set(1,1);let a=e.ray.intersectTriangle(ga,Sr,ya,!1,Er);if(a===null&&(xa(Sr.set(-.5,.5,0),Es,o,_s,n,s),_u.set(0,1),a=e.ray.intersectTriangle(ga,ya,Sr,!1,Er),a===null))return;let l=e.ray.origin.distanceTo(Er);l<e.near||l>e.far||t.push({distance:l,point:Er.clone(),uv:Bt.getUV(Er,ga,Sr,ya,Kf,_u,Qf,new ee),face:null,object:this})}copy(e){return super.copy(e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};Wu.prototype.isSprite=!0;function xa(r,e,t,i,n,s){As.subVectors(r,t).addScalar(.5).multiply(i),n!==void 0?(Ar.x=s*As.x-n*As.y,Ar.y=n*As.x+s*As.y):Ar.copy(As),r.copy(e),r.x+=Ar.x,r.y+=Ar.y,r.applyMatrix4(Hm)}var em=new P,tm=new je,im=new je,x_=new P,nm=new Ee,qa=class extends ft{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ee,this.bindMatrixInverse=new Ee}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new je,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.w=t.getW(i);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){let i=this.skeleton,n=this.geometry;tm.fromBufferAttribute(n.attributes.skinIndex,e),im.fromBufferAttribute(n.attributes.skinWeight,e),em.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=im.getComponent(s);if(o!==0){let a=tm.getComponent(s);nm.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(x_.copy(em).applyMatrix4(nm),o)}}return t.applyMatrix4(this.bindMatrixInverse)}};qa.prototype.isSkinnedMesh=!0;var $u=class extends qe{constructor(){super(),this.type="Bone"}};$u.prototype.isBone=!0;var ju=class extends ct{constructor(e=null,t=1,i=1,n,s,o,a,l,c=bt,u=bt,h,d){super(null,o,a,l,c,u,n,s,h,d),this.image={data:e,width:t,height:i},this.magFilter=c,this.minFilter=u,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};ju.prototype.isDataTexture=!0;var Xr=class extends dt{constructor(e,t,i,n=1){typeof i=="number"&&(n=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,i),this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};Xr.prototype.isInstancedBufferAttribute=!0;var sm=new Ee,rm=new Ee,va=[],Mr=new ft,Xu=class extends ft{constructor(e,t,i){super(e,t),this.instanceMatrix=new Xr(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){let i=this.matrixWorld,n=this.count;if(Mr.geometry=this.geometry,Mr.material=this.material,Mr.material!==void 0)for(let s=0;s<n;s++){this.getMatrixAt(s,sm),rm.multiplyMatrices(i,sm),Mr.matrixWorld=rm,Mr.raycast(e,va);for(let o=0,a=va.length;o<a;o++){let l=va[o];l.instanceId=s,l.object=this,t.push(l)}va.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Xr(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}};Xu.prototype.isInstancedMesh=!0;var Wn=class extends mt{constructor(e){super(),this.type="LineBasicMaterial",this.color=new ye(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this}};Wn.prototype.isLineBasicMaterial=!0;var om=new P,am=new P,lm=new Ee,Eu=new Sn,wa=new Ri,Yr=class extends qe{constructor(e=new Qe,t=new Wn){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.isBufferGeometry)if(e.index===null){let t=e.attributes.position,i=[0];for(let n=1,s=t.count;n<s;n++)om.fromBufferAttribute(t,n-1),am.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=om.distanceTo(am);e.setAttribute("lineDistance",new st(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(e,t){let i=this.geometry,n=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),wa.copy(i.boundingSphere),wa.applyMatrix4(n),wa.radius+=s,e.ray.intersectsSphere(wa)===!1)return;lm.copy(n).invert(),Eu.copy(e.ray).applyMatrix4(lm);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new P,u=new P,h=new P,d=new P,p=this.isLineSegments?2:1;if(i.isBufferGeometry){let m=i.index,x=i.attributes.position;if(m!==null){let g=Math.max(0,o.start),f=Math.min(m.count,o.start+o.count);for(let E=g,w=f-1;E<w;E+=p){let _=m.getX(E),M=m.getX(E+1);if(c.fromBufferAttribute(x,_),u.fromBufferAttribute(x,M),Eu.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let z=e.ray.origin.distanceTo(d);z<e.near||z>e.far||t.push({distance:z,point:h.clone().applyMatrix4(this.matrixWorld),index:E,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,o.start),f=Math.min(x.count,o.start+o.count);for(let E=g,w=f-1;E<w;E+=p){if(c.fromBufferAttribute(x,E),u.fromBufferAttribute(x,E+1),Eu.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(d);M<e.near||M>e.far||t.push({distance:M,point:h.clone().applyMatrix4(this.matrixWorld),index:E,face:null,faceIndex:null,object:this})}}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,i=Object.keys(t);if(i.length>0){let n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){let a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}};Yr.prototype.isLine=!0;var cm=new P,um=new P,Zr=class extends Yr{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.isBufferGeometry)if(e.index===null){let t=e.attributes.position,i=[];for(let n=0,s=t.count;n<s;n+=2)cm.fromBufferAttribute(t,n),um.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+cm.distanceTo(um);e.setAttribute("lineDistance",new st(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}};Zr.prototype.isLineSegments=!0;var Yu=class extends Yr{constructor(e,t){super(e,t),this.type="LineLoop"}};Yu.prototype.isLineLoop=!0;var Wa=class extends mt{constructor(e){super(),this.type="PointsMaterial",this.color=new ye(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this}};Wa.prototype.isPointsMaterial=!0;var hm=new Ee,Zu=new Sn,ba=new Ri,_a=new P,Ju=class extends qe{constructor(e=new Qe,t=new Wa){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){let i=this.geometry,n=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),ba.copy(i.boundingSphere),ba.applyMatrix4(n),ba.radius+=s,e.ray.intersectsSphere(ba)===!1)return;hm.copy(n).invert(),Zu.copy(e.ray).applyMatrix4(hm);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a;if(i.isBufferGeometry){let c=i.index,h=i.attributes.position;if(c!==null){let d=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let m=d,y=p;m<y;m++){let x=c.getX(m);_a.fromBufferAttribute(h,x),dm(_a,x,l,n,e,t,this)}}else{let d=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let m=d,y=p;m<y;m++)_a.fromBufferAttribute(h,m),dm(_a,m,l,n,e,t,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,i=Object.keys(t);if(i.length>0){let n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){let a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}};Ju.prototype.isPoints=!0;function dm(r,e,t,i,n,s,o){let a=Zu.distanceSqToPoint(r);if(a<t){let l=new P;Zu.closestPointToPoint(r,l),l.applyMatrix4(i);let c=n.ray.origin.distanceTo(l);if(c<n.near||c>n.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}var Ku=class extends ct{constructor(e,t,i,n,s,o,a,l,c){super(e,t,i,n,s,o,a,l,c),this.minFilter=o!==void 0?o:Ft,this.magFilter=s!==void 0?s:Ft,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};Ku.prototype.isVideoTexture=!0;var Qu=class extends ct{constructor(e,t,i){super({width:e,height:t}),this.format=i,this.magFilter=bt,this.minFilter=bt,this.generateMipmaps=!1,this.needsUpdate=!0}};Qu.prototype.isFramebufferTexture=!0;var eh=class extends ct{constructor(e,t,i,n,s,o,a,l,c,u,h,d){super(null,o,a,l,c,u,n,s,h,d),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}};eh.prototype.isCompressedTexture=!0;var th=class extends ct{constructor(e,t,i,n,s,o,a,l,c){super(e,t,i,n,s,o,a,l,c),this.needsUpdate=!0}};th.prototype.isCanvasTexture=!0;var MM=new P,DM=new P,TM=new P,CM=new Bt;var qt=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,n=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(n),t.push(s),n=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),n=0,s=i.length,o;t?o=t:o=e*i[s-1];let a=0,l=s-1,c;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),c=i[n]-o,c<0)a=n+1;else if(c>0)l=n-1;else{l=n;break}if(n=l,i[n]===o)return n/(s-1);let u=i[n],d=i[n+1]-u,p=(o-u)/d;return(n+p)/(s-1)}getTangent(e,t){let n=e-1e-4,s=e+1e-4;n<0&&(n=0),s>1&&(s=1);let o=this.getPoint(n),a=this.getPoint(s),l=t||(o.isVector2?new ee:new P);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new P,n=[],s=[],o=[],a=new P,l=new Ee;for(let p=0;p<=e;p++){let m=p/e;n[p]=this.getTangentAt(m,new P)}s[0]=new P,o[0]=new P;let c=Number.MAX_VALUE,u=Math.abs(n[0].x),h=Math.abs(n[0].y),d=Math.abs(n[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),s[0].crossVectors(n[0],a),o[0].crossVectors(n[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(n[p-1],n[p]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(Ht(n[p-1].dot(n[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(a,m))}o[p].crossVectors(n[p],s[p])}if(t===!0){let p=Math.acos(Ht(s[0].dot(s[e]),-1,1));p/=e,n[0].dot(a.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(n[m],p*m)),o[m].crossVectors(n[m],s[m])}return{tangents:n,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Us=class extends qt{constructor(e=0,t=0,i=1,n=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let i=t||new ee,n=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=n;for(;s>n;)s-=n;s<Number.EPSILON&&(o?s=0:s=n),this.aClockwise===!0&&!o&&(s===n?s=-n:s=s-n);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,p=c-this.aY;l=d*u-p*h+this.aX,c=d*h+p*u+this.aY}return i.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}};Us.prototype.isEllipseCurve=!0;var $a=class extends Us{constructor(e,t,i,n,s,o){super(e,t,i,i,n,s,o),this.type="ArcCurve"}};$a.prototype.isArcCurve=!0;function Xh(){let r=0,e=0,t=0,i=0;function n(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,i=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){n(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,h){let d=(o-s)/c-(a-s)/(c+u)+(a-o)/u,p=(a-o)/u-(l-o)/(u+h)+(l-a)/h;d*=u,p*=u,n(o,a,d,p)},calc:function(s){let o=s*s,a=o*s;return r+e*s+t*o+i*a}}}var Ea=new P,Au=new Xh,Su=new Xh,Mu=new Xh,ja=class extends qt{constructor(e=[],t=!1,i="centripetal",n=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=n}getPoint(e,t=new P){let i=t,n=this.points,s=n.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=n[(a-1)%s]:(Ea.subVectors(n[0],n[1]).add(n[0]),c=Ea);let h=n[a%s],d=n[(a+1)%s];if(this.closed||a+2<s?u=n[(a+2)%s]:(Ea.subVectors(n[s-1],n[s-2]).add(n[s-1]),u=Ea),this.curveType==="centripetal"||this.curveType==="chordal"){let p=this.curveType==="chordal"?.5:.25,m=Math.pow(c.distanceToSquared(h),p),y=Math.pow(h.distanceToSquared(d),p),x=Math.pow(d.distanceToSquared(u),p);y<1e-4&&(y=1),m<1e-4&&(m=y),x<1e-4&&(x=y),Au.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,y,x),Su.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,y,x),Mu.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,y,x)}else this.curveType==="catmullrom"&&(Au.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),Su.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),Mu.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(Au.calc(l),Su.calc(l),Mu.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let n=e.points[t];this.points.push(new P().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};ja.prototype.isCatmullRomCurve3=!0;function pm(r,e,t,i,n){let s=(i-e)*.5,o=(n-t)*.5,a=r*r,l=r*a;return(2*t-2*i+s+o)*l+(-3*t+3*i-2*s-o)*a+s*r+t}function v_(r,e){let t=1-r;return t*t*e}function w_(r,e){return 2*(1-r)*r*e}function b_(r,e){return r*r*e}function Lr(r,e,t,i){return v_(r,e)+w_(r,t)+b_(r,i)}function __(r,e){let t=1-r;return t*t*t*e}function E_(r,e){let t=1-r;return 3*t*t*r*e}function A_(r,e){return 3*(1-r)*r*r*e}function S_(r,e){return r*r*r*e}function Br(r,e,t,i,n){return __(r,e)+E_(r,t)+A_(r,i)+S_(r,n)}var Jr=class extends qt{constructor(e=new ee,t=new ee,i=new ee,n=new ee){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new ee){let i=t,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Br(e,n.x,s.x,o.x,a.x),Br(e,n.y,s.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}};Jr.prototype.isCubicBezierCurve=!0;var Xa=class extends qt{constructor(e=new P,t=new P,i=new P,n=new P){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new P){let i=t,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Br(e,n.x,s.x,o.x,a.x),Br(e,n.y,s.y,o.y,a.y),Br(e,n.z,s.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}};Xa.prototype.isCubicBezierCurve3=!0;var Hs=class extends qt{constructor(e=new ee,t=new ee){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ee){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new ee;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}};Hs.prototype.isLineCurve=!0;var ih=class extends qt{constructor(e=new P,t=new P){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new P){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Kr=class extends qt{constructor(e=new ee,t=new ee,i=new ee){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ee){let i=t,n=this.v0,s=this.v1,o=this.v2;return i.set(Lr(e,n.x,s.x,o.x),Lr(e,n.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}};Kr.prototype.isQuadraticBezierCurve=!0;var Ya=class extends qt{constructor(e=new P,t=new P,i=new P){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new P){let i=t,n=this.v0,s=this.v1,o=this.v2;return i.set(Lr(e,n.x,s.x,o.x),Lr(e,n.y,s.y,o.y),Lr(e,n.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}};Ya.prototype.isQuadraticBezierCurve3=!0;var Qr=class extends qt{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new ee){let i=t,n=this.points,s=(n.length-1)*e,o=Math.floor(s),a=s-o,l=n[o===0?o:o-1],c=n[o],u=n[o>n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return i.set(pm(a,l.x,c.x,u.x,h.x),pm(a,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let n=e.points[t];this.points.push(new ee().fromArray(n))}return this}};Qr.prototype.isSplineCurve=!0;var Gm=Object.freeze({__proto__:null,ArcCurve:$a,CatmullRomCurve3:ja,CubicBezierCurve:Jr,CubicBezierCurve3:Xa,EllipseCurve:Us,LineCurve:Hs,LineCurve3:ih,QuadraticBezierCurve:Kr,QuadraticBezierCurve3:Ya,SplineCurve:Qr}),nh=class extends qt{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Hs(t,e))}getPoint(e,t){let i=e*this.getLength(),n=this.getCurveLengths(),s=0;for(;s<n.length;){if(n[s]>=i){let o=n[s]-i,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,n=this.curves.length;i<n;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let n=0,s=this.curves;n<s.length;n++){let o=s[n],a=o&&o.isEllipseCurve?e*2:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){let u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let n=e.curves[t];this.curves.push(new Gm[n.type]().fromJSON(n))}return this}},eo=class extends nh{constructor(e){super(),this.type="Path",this.currentPoint=new ee,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new Hs(this.currentPoint.clone(),new ee(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,n){let s=new Kr(this.currentPoint.clone(),new ee(e,t),new ee(i,n));return this.curves.push(s),this.currentPoint.set(i,n),this}bezierCurveTo(e,t,i,n,s,o){let a=new Jr(this.currentPoint.clone(),new ee(e,t),new ee(i,n),new ee(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Qr(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,n,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,i,n,s,o),this}absarc(e,t,i,n,s,o){return this.absellipse(e,t,i,i,n,s,o),this}ellipse(e,t,i,n,s,o,a,l){let c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,n,s,o,a,l),this}absellipse(e,t,i,n,s,o,a,l){let c=new Us(e,t,i,n,s,o,a,l);if(this.curves.length>0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},$n=class extends eo{constructor(e){super(e),this.uuid=fi(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,n=this.holes.length;i<n;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let n=e.holes[t];this.holes.push(new eo().fromJSON(n))}return this}},M_={triangulate:function(r,e,t=2){let i=e&&e.length,n=i?e[0]*t:r.length,s=qm(r,0,n,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,h,d,p;if(i&&(s=F_(r,e,s,t)),r.length>80*t){a=c=r[0],l=u=r[1];for(let m=t;m<n;m+=t)h=r[m],d=r[m+1],h<a&&(a=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);p=Math.max(c-a,u-l),p=p!==0?1/p:0}return to(s,o,t,a,l,p),o}};function qm(r,e,t,i,n){let s,o;if(n===H_(r,e,t,i)>0)for(s=e;s<t;s+=i)o=fm(s,r[s],r[s+1],o);else for(s=t-i;s>=e;s-=i)o=fm(s,r[s],r[s+1],o);return o&&cl(o,o.next)&&(no(o),o=o.next),o}function Mn(r,e){if(!r)return r;e||(e=r);let t=r,i;do if(i=!1,!t.steiner&&(cl(t,t.next)||ot(t.prev,t,t.next)===0)){if(no(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function to(r,e,t,i,n,s,o){if(!r)return;!o&&s&&N_(r,i,n,s);let a=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?T_(r,i,n,s):D_(r)){e.push(l.i/t),e.push(r.i/t),e.push(c.i/t),no(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=C_(Mn(r),e,t),to(r,e,t,i,n,s,2)):o===2&&R_(r,e,t,i,n,s):to(Mn(r),e,t,i,n,s,1);break}}}function D_(r){let e=r.prev,t=r,i=r.next;if(ot(e,t,i)>=0)return!1;let n=r.next.next;for(;n!==r.prev;){if(Ts(e.x,e.y,t.x,t.y,i.x,i.y,n.x,n.y)&&ot(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function T_(r,e,t,i){let n=r.prev,s=r,o=r.next;if(ot(n,s,o)>=0)return!1;let a=n.x<s.x?n.x<o.x?n.x:o.x:s.x<o.x?s.x:o.x,l=n.y<s.y?n.y<o.y?n.y:o.y:s.y<o.y?s.y:o.y,c=n.x>s.x?n.x>o.x?n.x:o.x:s.x>o.x?s.x:o.x,u=n.y>s.y?n.y>o.y?n.y:o.y:s.y>o.y?s.y:o.y,h=sh(a,l,e,t,i),d=sh(c,u,e,t,i),p=r.prevZ,m=r.nextZ;for(;p&&p.z>=h&&m&&m.z<=d;){if(p!==r.prev&&p!==r.next&&Ts(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&ot(p.prev,p,p.next)>=0||(p=p.prevZ,m!==r.prev&&m!==r.next&&Ts(n.x,n.y,s.x,s.y,o.x,o.y,m.x,m.y)&&ot(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;p&&p.z>=h;){if(p!==r.prev&&p!==r.next&&Ts(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&ot(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;m&&m.z<=d;){if(m!==r.prev&&m!==r.next&&Ts(n.x,n.y,s.x,s.y,o.x,o.y,m.x,m.y)&&ot(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function C_(r,e,t){let i=r;do{let n=i.prev,s=i.next.next;!cl(n,s)&&Wm(n,i,i.next,s)&&io(n,s)&&io(s,n)&&(e.push(n.i/t),e.push(i.i/t),e.push(s.i/t),no(i),no(i.next),i=r=s),i=i.next}while(i!==r);return Mn(i)}function R_(r,e,t,i,n,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&z_(o,a)){let l=$m(o,a);o=Mn(o,o.next),l=Mn(l,l.next),to(o,e,t,i,n,s),to(l,e,t,i,n,s);return}a=a.next}o=o.next}while(o!==r)}function F_(r,e,t,i){let n=[],s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*i,l=s<o-1?e[s+1]*i:r.length,c=qm(r,a,l,i,!1),c===c.next&&(c.steiner=!0),n.push(O_(c));for(n.sort(L_),s=0;s<n.length;s++)B_(n[s],t),t=Mn(t,t.next);return t}function L_(r,e){return r.x-e.x}function B_(r,e){if(e=P_(r,e),e){let t=$m(e,r);Mn(e,e.next),Mn(t,t.next)}}function P_(r,e){let t=e,i=r.x,n=r.y,s=-1/0,o;do{if(n<=t.y&&n>=t.next.y&&t.next.y!==t.y){let d=t.x+(n-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>s){if(s=d,d===i){if(n===t.y)return t;if(n===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(i===s)return o;let a=o,l=o.x,c=o.y,u=1/0,h;t=o;do i>=t.x&&t.x>=l&&i!==t.x&&Ts(n<c?i:s,n,l,c,n<c?s:i,n,t.x,t.y)&&(h=Math.abs(n-t.y)/(i-t.x),io(t,r)&&(h<u||h===u&&(t.x>o.x||t.x===o.x&&I_(o,t)))&&(o=t,u=h)),t=t.next;while(t!==a);return o}function I_(r,e){return ot(r.prev,r,e.prev)<0&&ot(e.next,r,r.next)<0}function N_(r,e,t,i){let n=r;do n.z===null&&(n.z=sh(n.x,n.y,e,t,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,k_(n)}function k_(r){let e,t,i,n,s,o,a,l,c=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<c&&(a++,i=i.nextZ,!!i);e++);for(l=c;a>0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(n=t,t=t.nextZ,a--):(n=i,i=i.nextZ,l--),s?s.nextZ=n:r=n,n.prevZ=s,s=n;t=i}s.nextZ=null,c*=2}while(o>1);return r}function sh(r,e,t,i,n){return r=32767*(r-t)*n,e=32767*(e-i)*n,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function O_(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Ts(r,e,t,i,n,s,o,a){return(n-o)*(e-a)-(r-o)*(s-a)>=0&&(r-o)*(i-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(n-o)*(i-a)>=0}function z_(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!V_(r,e)&&(io(r,e)&&io(e,r)&&U_(r,e)&&(ot(r.prev,r,e.prev)||ot(r,e.prev,e))||cl(r,e)&&ot(r.prev,r,r.next)>0&&ot(e.prev,e,e.next)>0)}function ot(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function cl(r,e){return r.x===e.x&&r.y===e.y}function Wm(r,e,t,i){let n=Sa(ot(r,e,t)),s=Sa(ot(r,e,i)),o=Sa(ot(t,i,r)),a=Sa(ot(t,i,e));return!!(n!==s&&o!==a||n===0&&Aa(r,t,e)||s===0&&Aa(r,i,e)||o===0&&Aa(t,r,i)||a===0&&Aa(t,e,i))}function Aa(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Sa(r){return r>0?1:r<0?-1:0}function V_(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Wm(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function io(r,e){return ot(r.prev,r,r.next)<0?ot(r,e,r.next)>=0&&ot(r,r.prev,e)>=0:ot(r,e,r.prev)<0||ot(r,r.next,e)<0}function U_(r,e){let t=r,i=!1,n=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&n<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==r);return i}function $m(r,e){let t=new rh(r.i,r.x,r.y),i=new rh(e.i,e.x,e.y),n=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=n,n.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function fm(r,e,t,i){let n=new rh(r,e,t);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function no(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function rh(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function H_(r,e,t,i){let n=0;for(let s=e,o=t-i;s<t;s+=i)n+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return n}var En=class r{static area(e){let t=e.length,i=0;for(let n=t-1,s=0;s<t;n=s++)i+=e[n].x*e[s].y-e[s].x*e[n].y;return i*.5}static isClockWise(e){return r.area(e)<0}static triangulateShape(e,t){let i=[],n=[],s=[];mm(e),gm(i,e);let o=e.length;t.forEach(mm);for(let l=0;l<t.length;l++)n.push(o),o+=t[l].length,gm(i,t[l]);let a=M_.triangulate(i,n);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function mm(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function gm(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var Gs=class r extends Qe{constructor(e=new $n([new ee(.5,.5),new ee(-.5,.5),new ee(-.5,-.5),new ee(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let i=this,n=[],s=[];for(let a=0,l=e.length;a<l;a++){let c=e[a];o(c)}this.setAttribute("position",new st(n,3)),this.setAttribute("uv",new st(s,2)),this.computeVertexNormals();function o(a){let l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1,d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,x=t.bevelSegments!==void 0?t.bevelSegments:3,g=t.extrudePath,f=t.UVGenerator!==void 0?t.UVGenerator:G_;t.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),h=t.amount);let E,w=!1,_,M,T,z;g&&(E=g.getSpacedPoints(u),w=!0,d=!1,_=g.computeFrenetFrames(u,!1),M=new P,T=new P,z=new P),d||(x=0,p=0,m=0,y=0);let W=a.extractPoints(c),A=W.shape,v=W.holes;if(!En.isClockWise(A)){A=A.reverse();for(let Z=0,ie=v.length;Z<ie;Z++){let te=v[Z];En.isClockWise(te)&&(v[Z]=te.reverse())}}let S=En.triangulateShape(A,v),B=A;for(let Z=0,ie=v.length;Z<ie;Z++){let te=v[Z];A=A.concat(te)}function L(Z,ie,te){return ie||console.error("THREE.ExtrudeGeometry: vec does not exist"),ie.clone().multiplyScalar(te).add(Z)}let C=A.length,N=S.length;function k(Z,ie,te){let fe,de,Se,Re=Z.x-ie.x,Oe=Z.y-ie.y,Je=te.x-Z.x,Xe=te.y-Z.y,I=Re*Re+Oe*Oe,D=Re*Xe-Oe*Je;if(Math.abs(D)>Number.EPSILON){let J=Math.sqrt(I),se=Math.sqrt(Je*Je+Xe*Xe),xe=ie.x-Oe/J,Y=ie.y+Re/J,be=te.x-Xe/se,ve=te.y+Je/se,he=((be-xe)*Xe-(ve-Y)*Je)/(Re*Xe-Oe*Je);fe=xe+Re*he-Z.x,de=Y+Oe*he-Z.y;let ce=fe*fe+de*de;if(ce<=2)return new ee(fe,de);Se=Math.sqrt(ce/2)}else{let J=!1;Re>Number.EPSILON?Je>Number.EPSILON&&(J=!0):Re<-Number.EPSILON?Je<-Number.EPSILON&&(J=!0):Math.sign(Oe)===Math.sign(Xe)&&(J=!0),J?(fe=-Oe,de=Re,Se=Math.sqrt(I)):(fe=Re,de=Oe,Se=Math.sqrt(I/2))}return new ee(fe/Se,de/Se)}let V=[];for(let Z=0,ie=B.length,te=ie-1,fe=Z+1;Z<ie;Z++,te++,fe++)te===ie&&(te=0),fe===ie&&(fe=0),V[Z]=k(B[Z],B[te],B[fe]);let U=[],q,j=V.concat();for(let Z=0,ie=v.length;Z<ie;Z++){let te=v[Z];q=[];for(let fe=0,de=te.length,Se=de-1,Re=fe+1;fe<de;fe++,Se++,Re++)Se===de&&(Se=0),Re===de&&(Re=0),q[fe]=k(te[fe],te[Se],te[Re]);U.push(q),j=j.concat(q)}for(let Z=0;Z<x;Z++){let ie=Z/x,te=p*Math.cos(ie*Math.PI/2),fe=m*Math.sin(ie*Math.PI/2)+y;for(let de=0,Se=B.length;de<Se;de++){let Re=L(B[de],V[de],fe);ue(Re.x,Re.y,-te)}for(let de=0,Se=v.length;de<Se;de++){let Re=v[de];q=U[de];for(let Oe=0,Je=Re.length;Oe<Je;Oe++){let Xe=L(Re[Oe],q[Oe],fe);ue(Xe.x,Xe.y,-te)}}}let ne=m+y;for(let Z=0;Z<C;Z++){let ie=d?L(A[Z],j[Z],ne):A[Z];w?(T.copy(_.normals[0]).multiplyScalar(ie.x),M.copy(_.binormals[0]).multiplyScalar(ie.y),z.copy(E[0]).add(T).add(M),ue(z.x,z.y,z.z)):ue(ie.x,ie.y,0)}for(let Z=1;Z<=u;Z++)for(let ie=0;ie<C;ie++){let te=d?L(A[ie],j[ie],ne):A[ie];w?(T.copy(_.normals[Z]).multiplyScalar(te.x),M.copy(_.binormals[Z]).multiplyScalar(te.y),z.copy(E[Z]).add(T).add(M),ue(z.x,z.y,z.z)):ue(te.x,te.y,h/u*Z)}for(let Z=x-1;Z>=0;Z--){let ie=Z/x,te=p*Math.cos(ie*Math.PI/2),fe=m*Math.sin(ie*Math.PI/2)+y;for(let de=0,Se=B.length;de<Se;de++){let Re=L(B[de],V[de],fe);ue(Re.x,Re.y,h+te)}for(let de=0,Se=v.length;de<Se;de++){let Re=v[de];q=U[de];for(let Oe=0,Je=Re.length;Oe<Je;Oe++){let Xe=L(Re[Oe],q[Oe],fe);w?ue(Xe.x,Xe.y+E[u-1].y,E[u-1].x+te):ue(Xe.x,Xe.y,h+te)}}}ae(),H();function ae(){let Z=n.length/3;if(d){let ie=0,te=C*ie;for(let fe=0;fe<N;fe++){let de=S[fe];we(de[2]+te,de[1]+te,de[0]+te)}ie=u+x*2,te=C*ie;for(let fe=0;fe<N;fe++){let de=S[fe];we(de[0]+te,de[1]+te,de[2]+te)}}else{for(let ie=0;ie<N;ie++){let te=S[ie];we(te[2],te[1],te[0])}for(let ie=0;ie<N;ie++){let te=S[ie];we(te[0]+C*u,te[1]+C*u,te[2]+C*u)}}i.addGroup(Z,n.length/3-Z,0)}function H(){let Z=n.length/3,ie=0;Te(B,ie),ie+=B.length;for(let te=0,fe=v.length;te<fe;te++){let de=v[te];Te(de,ie),ie+=de.length}i.addGroup(Z,n.length/3-Z,1)}function Te(Z,ie){let te=Z.length;for(;--te>=0;){let fe=te,de=te-1;de<0&&(de=Z.length-1);for(let Se=0,Re=u+x*2;Se<Re;Se++){let Oe=C*Se,Je=C*(Se+1),Xe=ie+fe+Oe,I=ie+de+Oe,D=ie+de+Je,J=ie+fe+Je;oe(Xe,I,D,J)}}}function ue(Z,ie,te){l.push(Z),l.push(ie),l.push(te)}function we(Z,ie,te){Ce(Z),Ce(ie),Ce(te);let fe=n.length/3,de=f.generateTopUV(i,n,fe-3,fe-2,fe-1);Ae(de[0]),Ae(de[1]),Ae(de[2])}function oe(Z,ie,te,fe){Ce(Z),Ce(ie),Ce(fe),Ce(ie),Ce(te),Ce(fe);let de=n.length/3,Se=f.generateSideWallUV(i,n,de-6,de-3,de-2,de-1);Ae(Se[0]),Ae(Se[1]),Ae(Se[3]),Ae(Se[1]),Ae(Se[2]),Ae(Se[3])}function Ce(Z){n.push(l[Z*3+0]),n.push(l[Z*3+1]),n.push(l[Z*3+2])}function Ae(Z){s.push(Z.x),s.push(Z.y)}}}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return q_(t,i,e)}static fromJSON(e,t){let i=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];i.push(a)}let n=e.options.extrudePath;return n!==void 0&&(e.options.extrudePath=new Gm[n.type]().fromJSON(n)),new r(i,e.options)}},G_={generateTopUV:function(r,e,t,i,n){let s=e[t*3],o=e[t*3+1],a=e[i*3],l=e[i*3+1],c=e[n*3],u=e[n*3+1];return[new ee(s,o),new ee(a,l),new ee(c,u)]},generateSideWallUV:function(r,e,t,i,n,s){let o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],h=e[i*3+2],d=e[n*3],p=e[n*3+1],m=e[n*3+2],y=e[s*3],x=e[s*3+1],g=e[s*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new ee(o,1-l),new ee(c,1-h),new ee(d,1-m),new ee(y,1-g)]:[new ee(a,1-l),new ee(u,1-h),new ee(p,1-m),new ee(x,1-g)]}};function q_(r,e,t){if(t.shapes=[],Array.isArray(r))for(let i=0,n=r.length;i<n;i++){let s=r[i];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}var oh=class r extends Qe{constructor(e=new $n([new ee(0,.5),new ee(-.5,-.5),new ee(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],n=[],s=[],o=[],a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(a,l,u),a+=l,l=0;this.setIndex(i),this.setAttribute("position",new st(n,3)),this.setAttribute("normal",new st(s,3)),this.setAttribute("uv",new st(o,2));function c(u){let h=n.length/3,d=u.extractPoints(t),p=d.shape,m=d.holes;En.isClockWise(p)===!1&&(p=p.reverse());for(let x=0,g=m.length;x<g;x++){let f=m[x];En.isClockWise(f)===!0&&(m[x]=f.reverse())}let y=En.triangulateShape(p,m);for(let x=0,g=m.length;x<g;x++){let f=m[x];p=p.concat(f)}for(let x=0,g=p.length;x<g;x++){let f=p[x];n.push(f.x,f.y,0),s.push(0,0,1),o.push(f.x,f.y)}for(let x=0,g=y.length;x<g;x++){let f=y[x],E=f[0]+h,w=f[1]+h,_=f[2]+h;i.push(E,w,_),l+=3}}}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return W_(t,e)}static fromJSON(e,t){let i=[];for(let n=0,s=e.shapes.length;n<s;n++){let o=t[e.shapes[n]];i.push(o)}return new r(i,e.curveSegments)}};function W_(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,i=r.length;t<i;t++){let n=r[t];e.shapes.push(n.uuid)}else e.shapes.push(r.uuid);return e}var so=class extends mt{constructor(e){super(),this.type="ShadowMaterial",this.color=new ye(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}};so.prototype.isShadowMaterial=!0;var Za=class extends mt{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ye(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=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.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,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.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,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}};Za.prototype.isMeshStandardMaterial=!0;var ah=class extends Za{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ee(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ht(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.sheenColor=new ye(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new ye(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ye(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};ah.prototype.isMeshPhysicalMaterial=!0;var qs=class extends mt{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new ye(16777215),this.specular=new ye(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=rl,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}};qs.prototype.isMeshPhongMaterial=!0;var lh=class extends mt{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ye(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}};lh.prototype.isMeshToonMaterial=!0;var ch=class extends mt{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}};ch.prototype.isMeshNormalMaterial=!0;var uh=class extends mt{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new ye(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=rl,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.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,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}};uh.prototype.isMeshLambertMaterial=!0;var hh=class extends mt{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ye(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,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.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}};hh.prototype.isMeshMatcapMaterial=!0;var dh=class extends Wn{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};dh.prototype.isLineDashedMaterial=!0;var nt={arraySlice:function(r,e,t){return nt.isTypedArray(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)},convertArray:function(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)},isTypedArray:function(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)},getKeyframeOrder:function(r){function e(n,s){return r[n]-r[s]}let t=r.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i},sortedArray:function(r,e,t){let i=r.length,n=new r.constructor(i);for(let s=0,o=0;o!==i;++s){let a=t[s]*e;for(let l=0;l!==e;++l)n[o++]=r[a+l]}return n},flattenJSON:function(r,e,t,i){let n=1,s=r[0];for(;s!==void 0&&s[i]===void 0;)s=r[n++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[n++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[n++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=r[n++];while(s!==void 0)},subclip:function(r,e,t,i,n=30){let s=r.clone();s.name=e;let o=[];for(let l=0;l<s.tracks.length;++l){let c=s.tracks[l],u=c.getValueSize(),h=[],d=[];for(let p=0;p<c.times.length;++p){let m=c.times[p]*n;if(!(m<t||m>=i)){h.push(c.times[p]);for(let y=0;y<u;++y)d.push(c.values[p*u+y])}}h.length!==0&&(c.times=nt.convertArray(h,c.times.constructor),c.values=nt.convertArray(d,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(r,e=0,t=r,i=30){i<=0&&(i=30);let n=t.tracks.length,s=e/i;for(let o=0;o<n;++o){let a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;let c=r.tracks.find(function(g){return g.name===a.name&&g.ValueTypeName===l});if(c===void 0)continue;let u=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0,p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);let m=a.times.length-1,y;if(s<=a.times[0]){let g=u,f=h-u;y=nt.arraySlice(a.values,g,f)}else if(s>=a.times[m]){let g=m*h+u,f=g+h-u;y=nt.arraySlice(a.values,g,f)}else{let g=a.createInterpolant(),f=u,E=h-u;g.evaluate(s),y=nt.arraySlice(g.resultBuffer,f,E)}l==="quaternion"&&new Lt().fromArray(y).normalize().conjugate().toArray(y);let x=c.times.length;for(let g=0;g<x;++g){let f=g*p+d;if(l==="quaternion")Lt.multiplyQuaternionsFlat(c.values,f,y,0,c.values,f);else{let E=p-d*2;for(let w=0;w<E;++w)c.values[f+w]-=y[w]}}}return r.blendMode=Tm,r}},Fi=class{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,n=t[i],s=t[i-1];e:{t:{let o;i:{n:if(!(e<n)){for(let a=i+2;;){if(n===void 0){if(e<s)break n;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,s)}if(i===a)break;if(s=n,n=t[++i],e<n)break t}o=t.length;break i}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,n);if(i===l)break;if(n=s,s=t[--i-1],e>=s)break t}o=i,i=0;break i}break e}for(;i<o;){let a=i+o>>>1;e<t[a]?o=a:i=a+1}if(n=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,n);if(n===void 0)return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,s,e)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=e*n;for(let o=0;o!==n;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}};Fi.prototype.beforeStart_=Fi.prototype.copySampleValue_;Fi.prototype.afterEnd_=Fi.prototype.copySampleValue_;var ph=class extends Fi{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ms,endingEnd:Ms}}intervalChanged_(e,t,i){let n=this.parameterPositions,s=e-2,o=e+1,a=n[s],l=n[o];if(a===void 0)switch(this.getSettings_().endingStart){case Ds:s=e,a=2*t-i;break;case La:s=n.length-2,a=t+n[s]-n[s+1];break;default:s=e,a=i}if(l===void 0)switch(this.getSettings_().endingEnd){case Ds:o=e,l=2*i-t;break;case La:o=1,l=i+n[1]-n[0];break;default:o=e-1,l=t}let c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,i,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,p=this._weightNext,m=(i-t)/(n-t),y=m*m,x=y*m,g=-d*x+2*d*y-d*m,f=(1+d)*x+(-1.5-2*d)*y+(-.5+d)*m+1,E=(-1-p)*x+(1.5+p)*y+.5*m,w=p*x-p*y;for(let _=0;_!==a;++_)s[_]=g*o[u+_]+f*o[c+_]+E*o[l+_]+w*o[h+_];return s}},Ja=class extends Fi{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(i-t)/(n-t),h=1-u;for(let d=0;d!==a;++d)s[d]=o[c+d]*h+o[l+d]*u;return s}},fh=class extends Fi{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}},ri=class{constructor(e,t,i,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=nt.convertArray(t,this.TimeBufferType),this.values=nt.convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:nt.convertArray(e.times,Array),values:nt.convertArray(e.values,Array)};let n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new fh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ja(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ph(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ra:t=this.InterpolantFactoryMethodDiscrete;break;case Fa:t=this.InterpolantFactoryMethodLinear;break;case Xc:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ra;case this.InterpolantFactoryMethodLinear:return Fa;case this.InterpolantFactoryMethodSmooth:return Xc}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){let i=this.times,n=i.length,s=0,o=n-1;for(;s!==n&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==n){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=nt.arraySlice(i,s,o),this.values=nt.arraySlice(this.values,s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,n=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(n!==void 0&&nt.isTypedArray(n))for(let a=0,l=n.length;a!==l;++a){let c=n[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=nt.arraySlice(this.times),t=nt.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===Xc,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(n)l=!0;else{let h=a*i,d=h-i,p=h+i;for(let m=0;m!==i;++m){let y=t[h+m];if(y!==t[d+m]||y!==t[p+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let h=a*i,d=o*i;for(let p=0;p!==i;++p)t[d+p]=t[h+p]}++o}}if(s>0){e[o]=e[s];for(let a=s*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=nt.arraySlice(e,0,o),this.values=nt.arraySlice(t,0,o*i)):(this.times=e,this.values=t),this}clone(){let e=nt.arraySlice(this.times,0),t=nt.arraySlice(this.values,0),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}};ri.prototype.TimeBufferType=Float32Array;ri.prototype.ValueBufferType=Float32Array;ri.prototype.DefaultInterpolation=Fa;var Dn=class extends ri{};Dn.prototype.ValueTypeName="bool";Dn.prototype.ValueBufferType=Array;Dn.prototype.DefaultInterpolation=Ra;Dn.prototype.InterpolantFactoryMethodLinear=void 0;Dn.prototype.InterpolantFactoryMethodSmooth=void 0;var Ka=class extends ri{};Ka.prototype.ValueTypeName="color";var Ws=class extends ri{};Ws.prototype.ValueTypeName="number";var mh=class extends Fi{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(n-t),c=e*a;for(let u=c+a;c!==u;c+=4)Lt.slerpFlat(s,0,o,c-a,o,c,l);return s}},jn=class extends ri{InterpolantFactoryMethodLinear(e){return new mh(this.times,this.values,this.getValueSize(),e)}};jn.prototype.ValueTypeName="quaternion";jn.prototype.DefaultInterpolation=Fa;jn.prototype.InterpolantFactoryMethodSmooth=void 0;var Tn=class extends ri{};Tn.prototype.ValueTypeName="string";Tn.prototype.ValueBufferType=Array;Tn.prototype.DefaultInterpolation=Ra;Tn.prototype.InterpolantFactoryMethodLinear=void 0;Tn.prototype.InterpolantFactoryMethodSmooth=void 0;var $s=class extends ri{};$s.prototype.ValueTypeName="vector";var Qa=class{constructor(e,t=-1,i,n=$h){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=fi(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,n=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(j_(i[o]).scale(n));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(ri.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(e,t,i,n){let s=t.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);let u=nt.getKeyframeOrder(l);l=nt.sortedArray(l,1,u),c=nt.sortedArray(c,1,u),!n&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new Ws(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let n=e;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let n={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){let c=e[a],u=c.name.match(s);if(u&&u.length>1){let h=u[1],d=n[h];d||(n[h]=d=[]),d.push(c)}}let o=[];for(let a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,d,p,m,y){if(p.length!==0){let x=[],g=[];nt.flattenJSON(p,x,g,m),x.length!==0&&y.push(new h(d,x,g))}},n=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let h=0;h<c.length;h++){let d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let p={},m;for(m=0;m<d.length;m++)if(d[m].morphTargets)for(let y=0;y<d[m].morphTargets.length;y++)p[d[m].morphTargets[y]]=-1;for(let y in p){let x=[],g=[];for(let f=0;f!==d[m].morphTargets.length;++f){let E=d[m];x.push(E.time),g.push(E.morphTarget===y?1:0)}n.push(new Ws(".morphTargetInfluence["+y+"]",x,g))}l=p.length*(o||1)}else{let p=".bones["+t[h].name+"]";i($s,p+".position",d,"pos",n),i(jn,p+".quaternion",d,"rot",n),i($s,p+".scale",d,"scl",n)}}return n.length===0?null:new this(s,l,n,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,n=e.length;i!==n;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function $_(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ws;case"vector":case"vector2":case"vector3":case"vector4":return $s;case"color":return Ka;case"quaternion":return jn;case"bool":case"boolean":return Dn;case"string":return Tn}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function j_(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=$_(r.type);if(r.times===void 0){let t=[],i=[];nt.flattenJSON(r.keys,t,i,"value"),r.times=t,r.values=i}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}var js={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},gh=class{constructor(e,t,i){let n=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&n.onStart!==void 0&&n.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,n.onProgress!==void 0&&n.onProgress(u,o,a),o===a&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(u){n.onError!==void 0&&n.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){let h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){let p=c[h],m=c[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}},X_=new gh,Li=class{constructor(e){this.manager=e!==void 0?e:X_,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(n,s){i.load(e,n,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},Xi={},yh=class extends Li{constructor(e){super(e)}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=js.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Xi[e]!==void 0){Xi[e].push({onLoad:t,onProgress:i,onError:n});return}Xi[e]=[],Xi[e].push({onLoad:t,onProgress:i,onError:n});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body.getReader===void 0)return c;let u=Xi[e],h=c.body.getReader(),d=c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0,y=0,x=new ReadableStream({start(g){f();function f(){h.read().then(({done:E,value:w})=>{if(E)g.close();else{y+=w.byteLength;let _=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:p});for(let M=0,T=u.length;M<T;M++){let z=u[M];z.onProgress&&z.onProgress(_)}g.enqueue(w),f()}})}}});return new Response(x)}else throw Error(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(m=>p.decode(m))}}}).then(c=>{js.add(e,c);let u=Xi[e];delete Xi[e];for(let h=0,d=u.length;h<d;h++){let p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{let u=Xi[e];if(u===void 0)throw this.manager.itemError(e),c;delete Xi[e];for(let h=0,d=u.length;h<d;h++){let p=u[h];p.onError&&p.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var el=class extends Li{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=js.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=kr("img");function l(){u(),js.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),n&&n(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},xh=class extends Li{constructor(e){super(e)}load(e,t,i,n){let s=new ks,o=new el(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){s.images[c]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,n)}for(let c=0;c<e.length;++c)l(c);return s}};var vh=class extends Li{constructor(e){super(e)}load(e,t,i,n){let s=new ct,o=new el(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,n),s}},oi=class extends qe{constructor(e,t=1){super(),this.type="Light",this.color=new ye(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}};oi.prototype.isLight=!0;var wh=class extends oi{constructor(e,t,i){super(e,i),this.type="HemisphereLight",this.position.copy(qe.DefaultUp),this.updateMatrix(),this.groundColor=new ye(t)}copy(e){return oi.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}};wh.prototype.isHemisphereLight=!0;var ym=new Ee,xm=new P,vm=new P,ro=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ee(512,512),this.map=null,this.mapPass=null,this.matrix=new Ee,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Os,this._frameExtents=new ee(1,1),this._viewportCount=1,this._viewports=[new je(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;xm.setFromMatrixPosition(e.matrixWorld),t.position.copy(xm),vm.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(vm),t.updateMatrixWorld(),ym.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ym),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}},tl=class extends ro{constructor(){super(new Mt(50,1,.5,500)),this.focus=1}updateMatrices(e){let t=this.camera,i=Iu*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||n!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=n,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}};tl.prototype.isSpotLightShadow=!0;var oo=class extends oi{constructor(e,t,i=0,n=Math.PI/3,s=0,o=1){super(e,t),this.type="SpotLight",this.position.copy(qe.DefaultUp),this.updateMatrix(),this.target=new qe,this.distance=i,this.angle=n,this.penumbra=s,this.decay=o,this.shadow=new tl}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}};oo.prototype.isSpotLight=!0;var wm=new Ee,Dr=new P,Du=new P,il=class extends ro{constructor(){super(new Mt(90,1,.5,500)),this._frameExtents=new ee(4,2),this._viewportCount=6,this._viewports=[new je(2,1,1,1),new je(0,1,1,1),new je(3,1,1,1),new je(1,1,1,1),new je(3,0,1,1),new je(1,0,1,1)],this._cubeDirections=[new P(1,0,0),new P(-1,0,0),new P(0,0,1),new P(0,0,-1),new P(0,1,0),new P(0,-1,0)],this._cubeUps=[new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,0,1),new P(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,n=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Dr.setFromMatrixPosition(e.matrixWorld),i.position.copy(Dr),Du.copy(i.position),Du.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Du),i.updateMatrixWorld(),n.makeTranslation(-Dr.x,-Dr.y,-Dr.z),wm.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(wm)}};il.prototype.isPointLightShadow=!0;var bh=class extends oi{constructor(e,t,i=0,n=1){super(e,t),this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new il}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}};bh.prototype.isPointLight=!0;var nl=class extends ro{constructor(){super(new qr(-5,5,5,-5,.5,500))}};nl.prototype.isDirectionalLightShadow=!0;var _h=class extends oi{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy(qe.DefaultUp),this.updateMatrix(),this.target=new qe,this.shadow=new nl}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};_h.prototype.isDirectionalLight=!0;var ao=class extends oi{constructor(e,t){super(e,t),this.type="AmbientLight"}};ao.prototype.isAmbientLight=!0;var Eh=class extends oi{constructor(e,t,i=10,n=10){super(e,t),this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}};Eh.prototype.isRectAreaLight=!0;var sl=class{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new P)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let i=e.x,n=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*n),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*n)),t.addScaledVector(o[5],1.092548*(n*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){let i=e.x,n=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*n),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*n),t.addScaledVector(o[5],2*.429043*n*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(e,t+n*3);return this}toArray(e=[],t=0){let i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(e,t+n*3);return e}static getBasisAt(e,t){let i=e.x,n=e.y,s=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-n*n)}};sl.prototype.isSphericalHarmonics3=!0;var lo=class extends oi{constructor(e=new sl,t=1){super(void 0,t),this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}};lo.prototype.isLightProbe=!0;var Ah=class{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,n=e.length;i<n;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.substr(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},Sh=class extends Qe{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){let e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}};Sh.prototype.isInstancedBufferGeometry=!0;var Mh=class extends Li{constructor(e){super(e),typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=js.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){js.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){n&&n(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}};Mh.prototype.isImageBitmapLoader=!0;var Ma,Y_={getContext:function(){return Ma===void 0&&(Ma=new(window.AudioContext||window.webkitAudioContext)),Ma},setContext:function(r){Ma=r}},Dh=class extends Li{constructor(e){super(e)}load(e,t,i,n){let s=this,o=new yh(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{let l=a.slice(0);Y_.getContext().decodeAudioData(l,function(u){t(u)})}catch(l){n?n(l):console.error(l),s.manager.itemError(e)}},i,n)}},Th=class extends lo{constructor(e,t,i=1){super(void 0,i);let n=new ye().set(e),s=new ye().set(t),o=new P(n.r,n.g,n.b),a=new P(s.r,s.g,s.b),l=Math.sqrt(Math.PI),c=l*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(l),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(c)}};Th.prototype.isHemisphereLightProbe=!0;var Ch=class extends lo{constructor(e,t=1){super(void 0,t);let i=new ye().set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}};Ch.prototype.isAmbientLightProbe=!0;var Rh=class extends qe{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}};var Fh=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}},Lh=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let n,s,o;switch(t){case"quaternion":n=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,n=this.valueSize,s=e*n+n,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==n;++a)i[s+a]=i[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(i,s,0,a,n)}this.cumulativeWeight=o}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,n=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,n=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=t*this._origIndex;this._mixBufferRegion(i,n,l,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){a.setValue(i,n);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let s=i,o=n;s!==o;++s)t[s]=t[n+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,n,s){if(n>=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,n){Lt.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,s){let o=this._workIndex*s;Lt.multiplyQuaternionsFlat(e,o,e,t,e,i),Lt.slerpFlat(e,t,e,t,e,o,n)}_lerp(e,t,i,n,s){let o=1-n;for(let a=0;a!==s;++a){let l=t+a;e[l]=e[l]*o+e[i+a]*n}}_lerpAdditive(e,t,i,n,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[i+o]*n}}},Yh="\\[\\]\\.:\\/",Z_=new RegExp("["+Yh+"]","g"),Zh="[^"+Yh+"]",J_="[^"+Yh.replace("\\.","")+"]",K_=/((?:WC+[\/:])*)/.source.replace("WC",Zh),Q_=/(WCOD+)?/.source.replace("WCOD",J_),eE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Zh),tE=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Zh),iE=new RegExp("^"+K_+Q_+eE+tE+"$"),nE=["material","materials","bones"],Bh=class{constructor(e,t,i){let n=i||Ye.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Ye=class r{constructor(e,t,i){this.path=t,this.parsedPath=i||r.parseTrackName(t),this.node=r.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new r.Composite(e,t,i):new r(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Z_,"")}static parseTrackName(e){let t=iE.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){let s=i.nodeName.substring(n+1);nE.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(!t||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=i(a.children);if(l)return l}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,n=t.propertyName,s=t.propertyIndex;if(e||(e=r.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[n];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+n+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(e.geometry.isBufferGeometry){if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}else{console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);return}}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ye.Composite=Bh;Ye.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ye.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ye.prototype.GetterByBindingType=[Ye.prototype._getValue_direct,Ye.prototype._getValue_array,Ye.prototype._getValue_arrayElement,Ye.prototype._getValue_toArray];Ye.prototype.SetterByBindingTypeAndVersioning=[[Ye.prototype._setValue_direct,Ye.prototype._setValue_direct_setNeedsUpdate,Ye.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ye.prototype._setValue_array,Ye.prototype._setValue_array_setNeedsUpdate,Ye.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ye.prototype._setValue_arrayElement,Ye.prototype._setValue_arrayElement_setNeedsUpdate,Ye.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ye.prototype._setValue_fromArray,Ye.prototype._setValue_fromArray_setNeedsUpdate,Ye.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Ph=class{constructor(){this.uuid=fi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let i=0,n=arguments.length;i!==n;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,i=this._paths,n=this._parsedPaths,s=this._bindings,o=s.length,a,l=e.length,c=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){let d=arguments[u],p=d.uuid,m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(d);for(let y=0,x=o;y!==x;++y)s[y].push(new Ye(d,i[y],n[y]))}else if(m<c){a=e[m];let y=--c,x=e[y];t[x.uuid]=m,e[m]=x,t[p]=y,e[y]=d;for(let g=0,f=o;g!==f;++g){let E=s[g],w=E[y],_=E[m];E[m]=w,_===void 0&&(_=new Ye(d,i[g],n[g])),E[y]=_}}else e[m]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length,s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let l=arguments[o],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){let h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let p=0,m=n;p!==m;++p){let y=i[p],x=y[h],g=y[u];y[u]=x,y[h]=g}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length,s=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){let c=arguments[a],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){let d=--s,p=e[d],m=--o,y=e[m];t[p.uuid]=h,e[h]=p,t[y.uuid]=d,e[d]=y,e.pop();for(let x=0,g=n;x!==g;++x){let f=i[x],E=f[d],w=f[m];f[h]=E,f[d]=w,f.pop()}}else{let d=--o,p=e[d];d>0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let m=0,y=n;m!==y;++m){let x=i[m];x[h]=x[d],x.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let i=this._bindingsIndicesByPath,n=i[e],s=this._bindings;if(n!==void 0)return s[n];let o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);n=s.length,i[e]=n,o.push(e),a.push(t),s.push(h);for(let d=u,p=l.length;d!==p;++d){let m=l[d];h[d]=new Ye(m,e,t)}return h}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let n=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=i,o[i]=l,o.pop(),s[i]=s[a],s.pop(),n[i]=n[a],n.pop()}}};Ph.prototype.isAnimationObjectGroup=!0;var Ih=class{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;let s=t.tracks,o=s.length,a=new Array(o),l={endingStart:Ms,endingEnd:Ms};for(let c=0;c!==o;++c){let u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Lv,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let n=this._clip.duration,s=e._clip.duration,o=s/n,a=n/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let n=this._mixer,s=n.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/o,c[1]=t/o,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let l=(e-s)*i;if(l<0||i===0)return;this._startTime=null,t=i*l}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Tm:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case $h:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(n,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,n=this.time+e,s=this._loopCount,o=i===Bv;if(e===0)return s===-1?n:o&&(s&1)===1?t-n:n;if(i===Fv){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=t||n<0){let a=Math.floor(n/t);n-=t*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return t-n}return n}_setEndings(e,t,i){let n=this._interpolantSettings;i?(n.endingStart=Ds,n.endingEnd=Ds):(e?n.endingStart=this.zeroSlopeAtStart?Ds:Ms:n.endingStart=La,t?n.endingEnd=this.zeroSlopeAtEnd?Ds:Ms:n.endingEnd=La)}_scheduleFading(e,t,i){let n=this._mixer,s=n.time,o=this._weightInterpolant;o===null&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=i,this}},Nh=class extends Yi{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,n=e._clip.tracks,s=n.length,o=e._propertyBindings,a=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){let d=n[h],p=d.name,m=u[p];if(m!==void 0)++m.referenceCount,o[h]=m;else{if(m=o[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}let y=t&&t._propertyBindings[h].binding.parsedPath;m=new Lh(Ye.create(i,p,y),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),o[h]=m}a[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,n=e._clip.uuid,s=this._actionsByClip[n];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,n,i)}let t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let n=this._actions,s=this._actionsByClip,o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=n.length,n.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;let h=a.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,s=t[n];e._cacheIndex=n,t[n]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,s=t[n];e._cacheIndex=n,t[n]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let n=this._bindingsByRootAndName,s=this._bindings,o=n[t];o===void 0&&(o={},n[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,n=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,a=o[n],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[n]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,s=t[n];e._cacheIndex=n,t[n]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,s=t[n];e._cacheIndex=n,t[n]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new Ja(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,s=t[n];e.__cacheIndex=n,t[n]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let n=t||this._root,s=n.uuid,o=typeof e=="string"?Qa.findByName(n,e):e,a=o!==null?o.uuid:e,l=this._actionsByClip[a],c=null;if(i===void 0&&(o!==null?i=o.blendMode:i=$h),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;let u=new Ih(this,o,t,i);return this._bindAction(u,c),this._addInactiveAction(u,a,s),u}existingAction(e,t){let i=t||this._root,n=i.uuid,s=typeof e=="string"?Qa.findByName(i,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[n]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,n=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(n,e,s,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,n=this._actionsByClip,s=n[i];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let c=o[a];this._deactivateAction(c);let u=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(c)}delete n[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let o in i){let a=i[o].actionByRoot,l=a[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let n=this._bindingsByRootAndName,s=n[t];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}};Nh.prototype._controlInterpolantsResultBuffer=new Float32Array(1);var kh=class r{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new r(this.value.clone===void 0?this.value:this.value.clone())}},Oh=class extends qn{constructor(e,t,i=1){super(e,t),this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}};Oh.prototype.isInstancedInterleavedBuffer=!0;var zh=class{constructor(e,t,i,n,s){this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=n,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}};zh.prototype.isGLBufferAttribute=!0;var bm=new ee,Xn=class{constructor(e=new ee(1/0,1/0),t=new ee(-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),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=bm.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(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}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}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}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))}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)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return bm.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),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)}};Xn.prototype.isBox2=!0;var _m=new P,Da=new P,Vh=class{constructor(e=new P,t=new P){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){_m.subVectors(e,this.start),Da.subVectors(this.end,this.start);let i=Da.dot(Da),s=Da.dot(_m)/i;return t&&(s=Ht(s,0,1)),s}closestPointToPoint(e,t,i){let n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}};var yn=new P,Ta=new Ee,Tu=new Ee,Uh=class extends Zr{constructor(e){let t=jm(e),i=new Qe,n=[],s=[],o=new ye(0,0,1),a=new ye(0,1,0);for(let c=0;c<t.length;c++){let u=t[c];u.parent&&u.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new st(n,3)),i.setAttribute("color",new st(s,3));let l=new Wn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,i=this.geometry,n=i.getAttribute("position");Tu.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){let a=t[s];a.parent&&a.parent.isBone&&(Ta.multiplyMatrices(Tu,a.matrixWorld),yn.setFromMatrixPosition(Ta),n.setXYZ(o,yn.x,yn.y,yn.z),Ta.multiplyMatrices(Tu,a.parent.matrixWorld),yn.setFromMatrixPosition(Ta),n.setXYZ(o+1,yn.x,yn.y,yn.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}};function jm(r){let e=[];r&&r.isBone&&e.push(r);for(let t=0;t<r.children.length;t++)e.push.apply(e,jm(r.children[t]));return e}var Hh=class extends Zr{constructor(e=10,t=10,i=4473924,n=8947848){i=new ye(i),n=new ye(n);let s=t/2,o=e/t,a=e/2,l=[],c=[];for(let d=0,p=0,m=-a;d<=t;d++,m+=o){l.push(-a,0,m,a,0,m),l.push(m,0,-a,m,0,a);let y=d===s?i:n;y.toArray(c,p),p+=3,y.toArray(c,p),p+=3,y.toArray(c,p),p+=3,y.toArray(c,p),p+=3}let u=new Qe;u.setAttribute("position",new st(l,3)),u.setAttribute("color",new st(c,3));let h=new Wn({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}};var sE=new Float32Array(1),RM=new Int32Array(sE.buffer);qt.create=function(r,e){return console.log("THREE.Curve.create() has been deprecated"),r.prototype=Object.create(qt.prototype),r.prototype.constructor=r,r.prototype.getPoint=e,r};eo.prototype.fromPoints=function(r){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(r)};Hh.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};Uh.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")};Li.prototype.extractUrlBase=function(r){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Ah.extractUrlBase(r)};Li.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}};Xn.prototype.center=function(r){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(r)};Xn.prototype.empty=function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()};Xn.prototype.isIntersectionBox=function(r){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(r)};Xn.prototype.size=function(r){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(r)};ei.prototype.center=function(r){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(r)};ei.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()};ei.prototype.isIntersectionBox=function(r){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(r)};ei.prototype.isIntersectionSphere=function(r){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(r)};ei.prototype.size=function(r){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(r)};Ri.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()};Os.prototype.setFromMatrix=function(r){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(r)};Vh.prototype.center=function(r){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(r)};_t.prototype.flattenToArrayOffset=function(r,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(r,e)};_t.prototype.multiplyVector3=function(r){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),r.applyMatrix3(this)};_t.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")};_t.prototype.applyToBufferAttribute=function(r){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),r.applyMatrix3(this)};_t.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")};_t.prototype.getInverse=function(r){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(r).invert()};Ee.prototype.extractPosition=function(r){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(r)};Ee.prototype.flattenToArrayOffset=function(r,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(r,e)};Ee.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),new P().setFromMatrixColumn(this,3)};Ee.prototype.setRotationFromQuaternion=function(r){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(r)};Ee.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")};Ee.prototype.multiplyVector3=function(r){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),r.applyMatrix4(this)};Ee.prototype.multiplyVector4=function(r){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),r.applyMatrix4(this)};Ee.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")};Ee.prototype.rotateAxis=function(r){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),r.transformDirection(this)};Ee.prototype.crossVector=function(r){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),r.applyMatrix4(this)};Ee.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")};Ee.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")};Ee.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")};Ee.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")};Ee.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")};Ee.prototype.applyToBufferAttribute=function(r){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),r.applyMatrix4(this)};Ee.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")};Ee.prototype.makeFrustum=function(r,e,t,i,n,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(r,e,i,t,n,s)};Ee.prototype.getInverse=function(r){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(r).invert()};pi.prototype.isIntersectionLine=function(r){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(r)};Lt.prototype.multiplyVector3=function(r){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),r.applyQuaternion(this)};Lt.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()};Sn.prototype.isIntersectionBox=function(r){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(r)};Sn.prototype.isIntersectionPlane=function(r){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(r)};Sn.prototype.isIntersectionSphere=function(r){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(r)};Bt.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()};Bt.prototype.barycoordFromPoint=function(r,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(r,e)};Bt.prototype.midpoint=function(r){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(r)};Bt.prototypenormal=function(r){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(r)};Bt.prototype.plane=function(r){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(r)};Bt.barycoordFromPoint=function(r,e,t,i,n){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Bt.getBarycoord(r,e,t,i,n)};Bt.normal=function(r,e,t,i){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Bt.getNormal(r,e,t,i)};$n.prototype.extractAllPoints=function(r){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(r)};$n.prototype.extrude=function(r){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Gs(this,r)};$n.prototype.makeGeometry=function(r){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new oh(this,r)};ee.prototype.fromAttribute=function(r,e,t){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(r,e,t)};ee.prototype.distanceToManhattan=function(r){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(r)};ee.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()};P.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")};P.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")};P.prototype.getPositionFromMatrix=function(r){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(r)};P.prototype.getScaleFromMatrix=function(r){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(r)};P.prototype.getColumnFromMatrix=function(r,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,r)};P.prototype.applyProjection=function(r){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(r)};P.prototype.fromAttribute=function(r,e,t){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(r,e,t)};P.prototype.distanceToManhattan=function(r){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(r)};P.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()};je.prototype.fromAttribute=function(r,e,t){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(r,e,t)};je.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()};qe.prototype.getChildByName=function(r){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(r)};qe.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")};qe.prototype.translate=function(r,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,r)};qe.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")};qe.prototype.applyMatrix=function(r){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)};Object.defineProperties(qe.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(r){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=r}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});ft.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")};Object.defineProperties(ft.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),Pv},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}});qa.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")};Mt.prototype.setLens=function(r,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),e!==void 0&&(this.filmGauge=e),this.setFocalLength(r)};Object.defineProperties(oi.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(r){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=r}},shadowCameraLeft:{set:function(r){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=r}},shadowCameraRight:{set:function(r){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=r}},shadowCameraTop:{set:function(r){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=r}},shadowCameraBottom:{set:function(r){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=r}},shadowCameraNear:{set:function(r){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=r}},shadowCameraFar:{set:function(r){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=r}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(r){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=r}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(r){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=r}},shadowMapHeight:{set:function(r){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=r}}});Object.defineProperties(dt.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Ba},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Ba)}}});dt.prototype.setDynamic=function(r){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(r===!0?Ba:Nr),this};dt.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},dt.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")};Qe.prototype.addIndex=function(r){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(r)};Qe.prototype.addAttribute=function(r,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),!(e&&e.isBufferAttribute)&&!(e&&e.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(r,new dt(arguments[1],arguments[2]))):r==="index"?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(r,e)};Qe.prototype.addDrawCall=function(r,e,t){t!==void 0&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(r,e)};Qe.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()};Qe.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")};Qe.prototype.removeAttribute=function(r){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(r)};Qe.prototype.applyMatrix=function(r){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)};Object.defineProperties(Qe.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}});qn.prototype.setDynamic=function(r){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(r===!0?Ba:Nr),this};qn.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")};Gs.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")};Gs.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")};Gs.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")};Vs.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")};kh.prototype.onUpdate=function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this};Object.defineProperties(mt.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new ye}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(r){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=r===Am}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(r){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=r}},vertexTangents:{get:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")},set:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}});Object.defineProperties(Ji.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(r){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=r}}});We.prototype.clearTarget=function(r,e,t,i){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(r),this.clear(e,t,i)};We.prototype.animate=function(r){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(r)};We.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()};We.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()};We.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision};We.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()};We.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")};We.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")};We.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")};We.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")};We.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")};We.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")};We.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures};We.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")};We.prototype.enableScissorTest=function(r){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(r)};We.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")};We.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")};We.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")};We.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")};We.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")};We.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")};We.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")};We.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")};We.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")};We.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()};Object.defineProperties(We.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(r){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=r}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(r){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=r}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(r){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=r===!0?it:An}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}},gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});Object.defineProperties(Um.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}});Object.defineProperties(Gt.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(r){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=r}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(r){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=r}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(r){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=r}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(r){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=r}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(r){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=r}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(r){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=r}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(r){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=r}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(r){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=r}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(r){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=r}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(r){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=r}}});Rh.prototype.load=function(r){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");let e=this;return new Dh().load(r,function(i){e.setBuffer(i)}),this};Fh.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()};Hr.prototype.updateCubeMap=function(r,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(r,e)};Hr.prototype.clear=function(r,e,t,i){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(r,e,t,i)};Zi.crossOrigin=void 0;Zi.loadTexture=function(r,e,t,i){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");let n=new vh;n.setCrossOrigin(this.crossOrigin);let s=n.load(r,t,void 0,i);return e&&(s.mapping=e),s};Zi.loadTextureCube=function(r,e,t,i){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");let n=new xh;n.setCrossOrigin(this.crossOrigin);let s=n.load(r,t,void 0,i);return e&&(s.mapping=e),s};Zi.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")};Zi.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Gh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Gh);var Ue={NONE:"none",D4:"D4",D6:"D6",D8:"D8",D10:"D10",D12:"D12",D20:"D20",D100:"D100",FUDGE:"fudge",STUNT:"stunt",BOOST:"boost",SETBACK:"setback",ABILITY:"ability",DIFFICULTY:"difficulty",PROFICIENCY:"proficiency",CHALLENGE:"challenge",FORCE:"force"};var rE={pos:{x:0+100*Math.random(),y:0+100*Math.random(),z: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()}},It=class{constructor(e,t,i){this.w=e;this.h=t;this.data=i;this.scale=50;this.values=[];this.stopped=!1;this.iterations=0;this.vector={...rE};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()+5)*t,n={x:e.x/t,y:e.y/t},s=this.makeRandomVector(n),o={x:this.w*(s.x>0?-1:1)*.9,y:this.h*(s.y>0?-1:1)*.9,z:Math.random()*200+200},a=Math.abs(s.x/s.y);a>1?o.y/=a:o.x*=a;let l=this.makeRandomVector(n),c={x:l.x*i,y:l.y*i,z:-10},u={x:-(Math.random()*s.y*5+this.inertia*s.y),y:Math.random()*s.x*5+this.inertia*s.x,z:0},h={x:Math.random(),y:Math.random(),z:Math.random(),w:Math.random()};return{pos:o,velocity:c,angular:u,axis:h}}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 P(0,0,this.sides==4?-1:1),t,i=Math.PI*2,n=this.buffer.getAttribute("normal").array;for(let o=0,a=this.buffer.groups.length;o<a;++o){let l=this.buffer.groups[o];if(l.materialIndex==0)continue;let c=o*9,h=new P(n[c],n[c+1],n[c+2]).clone().applyQuaternion(new vt(this.body.quaternion.x,this.body.quaternion.y,this.body.quaternion.z,this.body.quaternion.w)).angleTo(e);h<i&&(i=h,t=l)}let s=t.materialIndex-1;return this.sides==10&&s==0&&(s=10),this.data.values?.[s]??s}shiftUpperValue(e){let t=this.geometry.geometry.clone(),i=this.getUpsideValue();for(let n=0,s=t.groups.length;n<s;++n){let o=t.groups[n].materialIndex;if(o!==0){for(o+=e-i-1;o>this.sides;)o-=this.sides;for(;o<1;)o+=this.sides;t.groups[n].materialIndex=o+1}}this.updateMaterialsForValue(e-i),this.geometry.geometry=t}resetBody(){return this.body.vlambda=new b,this.body.position=new b,this.body.previousPosition=new b,this.body.initPosition=new b,this.body.velocity=new b,this.body.initVelocity=new b,this.body.force=new b,this.body.torque=new b,this.body.quaternion=new vt,this.body.initQuaternion=new vt,this.body.angularVelocity=new b,this.body.initAngularVelocity=new b,this.body.interpolatedPosition=new b,this.body.interpolatedQuaternion=new vt,this.body.inertia=new b,this.body.invInertia=new b,this.body.invInertiaWorld=new Di,this.body.invInertiaSolve=new b,this.body.invInertiaWorldSolve=new Di,this.body.wlambda=new b,this.body.updateMassProperties(),this}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)}recreate(e,t,i){this.w=t,this.h=i,this.vector=this.generateVector(e),this.stopped=!1,this.iterations=0,this.create()}create(){return this.body.position.set(this.vector.pos.x,this.vector.pos.y,this.vector.pos.z),this.body.quaternion.setFromAxisAngle(new b(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,this}},ul=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=20;this.inertia=6;s&&(this.vector=this.generateVector(s)),this.create()}},hl=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=12;this.inertia=8;s&&(this.vector=this.generateVector(s)),this.create()}},dl=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=12;this.inertia=8;s&&(this.vector=this.generateVector(s)),this.create()}},pl=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=12;this.inertia=8;s&&(this.vector=this.generateVector(s)),this.create()}},fl=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=12;this.inertia=8;s&&(this.vector=this.generateVector(s)),this.create()}},ho=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=10;this.inertia=9;s&&(this.vector=this.generateVector(s)),this.create()}},ml=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=10;this.inertia=9;s&&(this.vector=this.generateVector(s)),this.create()}},gl=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=8;this.inertia=10;s&&(this.vector=this.generateVector(s)),this.create()}},yl=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=8;this.inertia=10;s&&(this.vector=this.generateVector(s)),this.create()}},xl=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=8;this.inertia=10;s&&(this.vector=this.generateVector(s)),this.create()}};var Zs=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=6;this.inertia=13;s&&(this.vector=this.generateVector(s)),this.create()}},vl=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=6;this.inertia=13;s&&(this.vector=this.generateVector(s)),this.create()}},wl=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=6;this.inertia=13;s&&(this.vector=this.generateVector(s)),this.create()}};var bl=class extends It{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=4;this.inertia=5;s&&(this.vector=this.generateVector(s)),this.create()}};var gt=class{constructor(e,t={value:`${e}`,conditions:[],type:"dice"}){this.lexeme=t;this.modifiers=new Map;this.possibilities=[];this.results=new Map;this.shapes=new Map;this.modifiersAllowed=!0;this.static=!1;this.conditions=[];this.fudge=!1;this.shouldRender=!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,n="1"]=this.dice.match(/(\-?\d+)[dD](%|F|-?\d+|\[\d+(?:[ \t]*[,-][ \t]*\d+)+\])/)||[,1,"1"];i=Number(i),this.multiplier=i<0?-1:1;let s=1,o=isNaN(Number(n))?1:Number(n);this.rolls=Math.abs(Number(i))||1,/\[\d+(?:[ \t]*,[ \t]*\d+)+\]/.test(n)?this.possibilities=n.replace(/[\[\]\s]/g,"").split(",").map(a=>Number(a)):/\[\d+(?:[ \t]*-[ \t]*\d+)+\]/.test(n)?([s,o]=n.replace(/[\[\]\s]/g,"").split("-").map(a=>Number(a)),this.possibilities=Array.from({length:o-s},(a,l)=>l+s)):(n==="%"?o=100:o=Number(n),Number(o)<0&&!s&&(s=-1),Number(o)<Number(s)&&([o,s]=[s,o]),isNaN(o)&&(o=1),this.possibilities=[...Array(Number(o??1)).keys()].map(a=>a+s)),this.conditions=this.lexeme.conditions??[]}getType(){return`D${this.faces.max}`}get faces(){return{max:this.possibilities[this.possibilities.length-1],min:this.possibilities[0]}}getShapes(e){if(this.shapes.has(e))return this.shapes.get(e);let t=Et.getDiceForRoller(this);return e!=null&&this.shapes.set(e,t),t}get text(){return`${this.result}`}get result(){if(this.static)return this.multiplier*Number(this.dice);let e=[...this.results].map(([,{usable:t,value:i}])=>t?i:0);return this.multiplier*e.reduce((t,i)=>t+i,0)}get display(){if(this.static)return`${this.result}`;let e=[`[${[...this.results].map(([,{modifiers:t,display:i}])=>`${i}${[...t].join("")}`).join(", ")}]`];return this.conditions.length&&e.push(this.conditions.map(({result:t,operator:i})=>`${i}${t}`).join("")),e.join("")}get modifierText(){let e=this.conditions.map(({value:i})=>i).join(""),t=[...this.modifiers].map(([i,{conditionals:n,value:s}])=>{let o=n.map(a=>a.value);return`${s}${o.join("")}`}).join("");return`${e}${t}`}keepLow(e=1){if(!this.modifiersAllowed){new po.Notice("Modifiers are only allowed on dice rolls.");return}this.results.size!==1&&[...this.results].sort((t,i)=>t[1].value-i[1].value).slice(e>this.results.size?this.results.size: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 po.Notice("Modifiers are only allowed on dice rolls.");return}this.results.size!==1&&[...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})})}async reroll(e,t){if(!this.modifiersAllowed){new po.Notice("Modifiers are only allowed on dice rolls.");return}t.length||t.push({operator:"=",comparer:this.faces.min,lexemes:[{value:`${this.faces.min}`,text:`${this.faces.min}`,type:"dice"}],value:""});let i=0,n=[...this.results].filter(([,{value:s}])=>this.checkCondition(s,t));for(;i<e&&n.length>0;){let s=[];for(let[o,a]of n)s.push(new Promise(async l=>{a.modifiers.add("r");let c=this.getShapes(o),u=await this.getValue(c);a.value=u,a.display=`${u}`,l()}));await Promise.all(s),n=n.filter(([,{value:o}])=>this.checkCondition(o,t)),i++}n.forEach(([s,o])=>{this.results.set(s,o)})}async explode(e,t,i=!1){if(!this.modifiersAllowed){new po.Notice("Modifiers are only allowed on dice rolls.");return}t.length||t.push({operator:"=",comparer:this.faces.max,lexemes:[{value:`${this.faces.max}`,text:`${this.faces.max}`,type:"dice"}],value:""});let n=[...this.results].filter(([,{value:o}])=>this.checkCondition(o,t)),s=0;await Promise.all(n.map(async([o,a])=>{if(i){let l=await this.getValue(),c=0;for(a.modifiers.add("!"),a.value+=l,a.display=`${a.value}`,this.results.set(o,a);c<e&&this.checkCondition(l,t);)c++,l=await this.getValue(),a.value+=l,a.display=`${a.value}`,this.results.set(o,a)}else{let l=a.value,c=0;for(;c<e&&this.checkCondition(l,t);)this.results.get(o+s+c).modifiers.add("!"),l=await this.getValue(),jd(this.results,o+s+c+1,this.#t(l)),c++;s+=c}}))}canRender(){return this.possibilities.length!==this.faces.max&&!this.fudge?!1:[...Array(this.faces.max).keys()].map(t=>this.faces.min+t).every(t=>this.possibilities.includes(t))}async getValue(e){let t;if(this.shouldRender&&this.canRender()){let i=e??Et.getDiceForRoller(this)??[];await Et.addDice(i),t=this.#e(i)}else t=this.getValueSync();return t}getValueSync(){return this.getRandomValue()}getMaxPossible(){if(this.static)return Number(this.dice);let e=this.rolls;return this.modifiers.has("kl")&&(e=e-this.modifiers.get("kl").data),this.modifiers.has("kh")&&(e=e-this.modifiers.get("kh").data),e<1&&(e=0),this.multiplier===-1?this.multiplier*Math.min(...this.possibilities)*e:Math.max(...this.possibilities)*e}getMinPossible(){if(this.static)return Number(this.dice);let e=this.rolls;return this.modifiers.has("kl")&&(e=e-this.modifiers.get("kl").data),this.modifiers.has("kh")&&(e=e-this.modifiers.get("kh").data),e<1&&(e=0),this.multiplier===-1?this.multiplier*Math.max(...this.possibilities)*e:Math.min(...this.possibilities)*e}#e(e=[]){if(!e.length)return this.getValueSync();let t=e.map(i=>i.getUpsideValue());if(this.faces.max===100){let[i,n]=t;return i===10&&n==10?100:(n==10&&(n=0),i==10&&(i=0),i*10+n)}return t.reduce((i,n)=>i+n)}#t(e=0){return{usable:!0,value:e,display:`${e}`,modifiers:new Set}}async applyModifiers(){for(let[e,t]of this.modifiers)e=="kh"||e=="kl"||await this.applyModifier(e,t);this.modifiers.has("kh")&&await this.applyModifier("kh",this.modifiers.get("kh")),this.modifiers.has("kl")&&await this.applyModifier("kl",this.modifiers.get("kl"))}setResults(e){this.results=new Map([...e].map(([t,i])=>[t,this.#t(i)])),this.updateResultArray()}rollSync(){let e=new Map;for(let t=0;t<this.rolls;t++)e.set(t,this.getValueSync());return this.setResults(e),this.applyModifiers(),this.conditions?.length&&this.applyConditions(),[...e.values()]}async roll(){this.results=new Map,this.shapes=new Map;let e=await this.#i();this.setResults(e),await this.applyModifiers(),this.conditions?.length&&this.applyConditions()}async#i(){let e=new Map;if(this.static)e.set(0,Number(this.dice));else{let t=[];for(let i=0;i<this.rolls;i++)t.push(new Promise(async(n,s)=>{this.#n?.signal.addEventListener("abort",()=>{s()});let o=await this.getValue(this.getShapes(i));e.set(i,o),n()}));try{await Promise.all(t)}catch{}}return e}applyConditions(){for(let e of this.results.values()){let t=this.conditions.find(({operator:n})=>n==="-="||n==="=-");if(t&&e.value===t.comparer){e.value=-1,e.modifiers.add("-");continue}this.checkCondition(e.value,this.conditions)?(e.modifiers.add("*"),e.value=1):e.usable=!1}}updateResultArray(){this.resultArray=[...this.results.values()].map(e=>e.value)}async applyModifier(e,t){switch(e){case"sort":{let i;t.value=="sa"?i=[...this.results.values()].sort((n,s)=>n.value-s.value):i=[...this.results.values()].sort((n,s)=>s.value-n.value),this.results=new Map([...this.results.keys()].map(n=>[n,i[n]])),this.updateResultArray();break}case"kh":{this.keepHigh(t.data);break}case"kl":{this.keepLow(t.data);break}case"!":{await this.explode(t.data,t.conditionals);break}case"!!":{await this.explode(t.data,t.conditionals,!0);break}case"r":{await this.reroll(t.data,t.conditionals);break}case"u":{await this.makeUnique();break}case"condition":}}async makeUnique(){let e=[...this.results.values()];if(new Set(this.possibilities).size<this.rolls||new Set(e.map(i=>i.value)).size==this.results.size)return;let t=0;for(;new Set(e.map(i=>i.value)).size!=this.results.size&&t<100;){let i=[];for(let[n,s]of this.results)i.push(new Promise(async o=>{let a=e.find(l=>l.value==s.value&&l!=s);a&&(a.value=await this.getValue(this.getShapes(n)),a.display=`${a.value}`,a.modifiers.add("u")),o()}));await Promise.all(i),e=[...this.results.values()],t++}}checkCondition(e,t){if(!t||!t.length)return e;let i=!1;for(let n of t){let{operator:s,comparer:o,lexemes:a}=n;if(Number.isNaN(e)||!s?.length||!o)continue;let l=new _l(o,a);if(l.rollSync(),n.result=l.result,!Number.isNaN(n.result)){switch(s){case"=":i=e===n.result;break;case"!=":case"=!":i=e!==n.result;break;case"<":i=e<n.result;break;case"<=":i=e<=n.result;break;case">":i=e>n.result;break;case">=":i=e>=n.result;break}if(i)return i}}return i}allowAverage(){return!0}average(){return this.possibilities.reduce((e,t)=>e+t)/this.possibilities.length}getRandomValue(){let e=Math.floor(Math.random()*this.possibilities.length);return this.possibilities[e]}getGeometries(){return[...this.shapes.values()].flat()}#n;async render(e){this.shouldRender=!0,this.#n=e,await this.roll(),this.shouldRender=!1}};var Xm={specular:1515554,color:15790320,shininess:60,flatShading:!0},Ki={diceColor:"#202020",textColor:"#ffffff",textFont:"Arial",narrativeSymbolSet:"Genesys"},mi=class{constructor(e,t,i={diceColor:"#202020",textColor:"#aaaaaa",narrativeSymbolSet:"Genesys"},n){this.w=e;this.h=t;this.options=i;this.scaler=n;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={...Ki,...i},this.fontFace=this.options.textFont}setColor({diceColor:e,textColor:t,narrativeSymbolSet:i}){e&&(this.options.diceColor=e),t&&(this.options.textColor=t),i&&(this.options.narrativeSymbolSet=i)}get radius(){return this.scale*this.scaleFactor*(this.scaler??1)}get diceColor(){return this.options.diceColor}get textColor(){return this.options.textColor}get narrativeSymbolSet(){return this.options.narrativeSymbolSet}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 ft(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 P().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 De({mass:this.mass,shape:this.shape}),t}makeShape(e){let t=new Array(e.length),i=new Array(this.faces.length);for(let n=0;n<e.length;++n){let s=e[n];t[n]=new b(s.x*this.radius,s.y*this.radius,s.z*this.radius)}for(let n=0;n<this.faces.length;++n)i[n]=this.faces[n].slice(0,this.faces[n].length-1);return this.shapeData={vertices:t,faces:i},new mr({vertices:t,faces:i})}getChamferGeometry(e){let t=[],i=[],n=new Array(e.length);for(let s=0;s<e.length;++s)n[s]=[];for(let s=0;s<this.faces.length;++s){let o=this.faces[s],a=o.length-1,l=new P,c=new Array(a);for(let u=0;u<a;++u){let h=e[o[u]].clone();l.add(h),n[o[u]].push(c[u]=t.push(h)-1)}l.divideScalar(a);for(let u=0;u<a;++u){let h=t[c[u]];h.subVectors(h,l).multiplyScalar(this.chamfer).addVectors(h,l)}c.push(o[a]),i.push(c)}for(let s=0;s<this.faces.length-1;++s)for(let o=s+1;o<this.faces.length;++o){let a=[],l=-1;for(let c=0;c<this.faces[s].length-1;++c){let u=this.faces[o].indexOf(this.faces[s][c]);u>=0&&u<this.faces[o].length-1&&(l>=0&&c!==l+1?a.unshift([s,c],[o,u]):a.push([s,c],[o,u]),l=c)}a.length===4&&i.push([i[a[0][0]][a[0][1]],i[a[1][0]][a[1][1]],i[a[3][0]][a[3][1]],i[a[2][0]][a[2][1]],-1])}for(let s=0;s<n.length;++s){let o=n[s],a=[o[0]],l=o.length-1;for(;l;){for(let c=this.faces.length;c<i.length;++c){let u=i[c].indexOf(a[a.length-1]);if(u>=0&&u<4){--u===-1&&(u=3);let h=i[c][u];if(o.indexOf(h)>=0){a.push(h);break}}}--l}a.push(-1),i.push(a)}return{vectors:t,faces:i}}makeGeometry(e,t){let i=new Qe;for(let h=0;h<e.length;++h)e[h]=e[h].multiplyScalar(this.radius);let n=[],s=[],o=[],a=new P,l=new P,c,u=0;for(let h=0;h<t.length;++h){let d=t[h],p=d.length-1,m=Math.PI*2/p;c=d[p]+1;for(let x=0;x<p-2;++x)n.push(...e[d[0]].toArray()),n.push(...e[d[x+1]].toArray()),n.push(...e[d[x+2]].toArray()),a.subVectors(e[d[x+2]],e[d[x+1]]),l.subVectors(e[d[0]],e[d[x+1]]),a.cross(l),a.normalize(),s.push(...a.toArray()),s.push(...a.toArray()),s.push(...a.toArray()),o.push((Math.cos(this.af)+1+this.tab)/2/(1+this.tab),(Math.sin(this.af)+1+this.tab)/2/(1+this.tab)),o.push((Math.cos(m*(x+1)+this.af)+1+this.tab)/2/(1+this.tab),(Math.sin(m*(x+1)+this.af)+1+this.tab)/2/(1+this.tab)),o.push((Math.cos(m*(x+2)+this.af)+1+this.tab)/2/(1+this.tab),(Math.sin(m*(x+2)+this.af)+1+this.tab)/2/(1+this.tab));let y=(p-2)*3;for(let x=0;x<y/3;x++)i.addGroup(u,3,c),u+=3}return i.setAttribute("position",new st(n,3)),i.setAttribute("normal",new st(s,3)),i.setAttribute("uv",new st(o,2)),i.boundingSphere=new Ri(new P,this.radius),i}getMaterials(){let e=[];for(let t=0;t<this.labels.length;t++){let i=this.createTextTexture(t);e.push(new qs(Object.assign({},Xm,{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 n=i.height/2,s=i.width/2,{context:o,fontsize:a}=this.getContext(i),l=o.measureText("M").width*1.4,c=t.split(`
`);c.length>1&&(a=a/c.length,o.font=`${a}pt '${this.fontFace}'`,l=o.measureText("M").width*1.2,n-=l*c.length/2);for(let h=0,d=c.length;h<d;h++){let p=c[h].trim();o.fillText(c[h],s,n),(p=="6"||p=="9")&&o.fillText(" .",s,n),n+=l*1.5}let u=new ct(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 De({mass:this.mass,shape:this.shape}),geometry:this.geometry.clone(),values:this.values}}},El=class extends mi{constructor(t,i,n={diceColor:"#171120",textColor:"#FF0000"},s){super(t,i,n,s);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 o=(1+Math.sqrt(5))/2;this.vertices=[[-1,o,0],[1,o,0],[-1,-o,0],[1,-o,0],[0,-1,o],[0,1,o],[0,-1,-o],[0,1,-o],[o,0,-1],[o,0,1],[-o,0,-1],[-o,0,1]]}},Al=class extends mi{constructor(t,i,n={diceColor:"#7339BE",textColor:"#FFFFFF"},s){super(t,i,n,s);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 o=(1+Math.sqrt(5))/2,a=1/o;this.vertices=[[0,a,o],[0,a,-o],[0,-a,o],[0,-a,-o],[o,0,a],[o,0,-a],[-o,0,a],[-o,0,-a],[a,o,0],[a,-o,0],[-a,o,0],[-a,-o,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]]}},Sl=class extends mi{constructor(t,i,n={diceColor:"#c74749",textColor:"#FFFFFF"},s){super(t,i,n,s);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 o=0,a=0;o<10;++o,a+=Math.PI*2/10)this.vertices.push([Math.cos(a),Math.sin(a),.105*(o%2?1:-1)]);this.vertices.push([0,0,-1]),this.vertices.push([0,0,1])}},Ml=class extends mi{constructor(t,i,n={diceColor:"#7a2c2d",textColor:"#FFFFFF"},s){super(t,i,n,s);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 o=0,a=0;o<10;++o,a+=Math.PI*2/10)this.vertices.push([Math.cos(a),Math.sin(a),.105*(o%2?1:-1)]);this.vertices.push([0,0,-1]),this.vertices.push([0,0,1])}},Dl=class extends mi{constructor(t,i,n={diceColor:"#5eb0c5",textColor:"#FFFFFF"},s){super(t,i,n,s);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}},Js=class extends mi{constructor(t,i,n={diceColor:"#d68316",textColor:"#FFFFFF"},s){super(t,i,n,s);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()]}},Tl=class extends Js{constructor(){super(...arguments);this.labels=["","","+","-"," ","+","-"," "];this.values=[null,1,-1,0,1,-1,0]}},Cl=class extends Js{get diceColor(){return"red"}},Rl=class extends mi{constructor(t,i,n={diceColor:"#93b139",textColor:"#FFFFFF"},s){super(t,i,n,s);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 t=[];for(let i=0;i<this.d4FaceTexts[0].length;++i){let n=null;n=this.createTextTexture(i),t.push(new qs(Object.assign({},Xm,{map:n})))}return t}createTextTexture(t){let i=document.createElement("canvas"),n=i.getContext("2d"),s=this.calculateTextureSize(this.radius/2+this.radius*2)*2;i.width=i.height=s,n.font=`${s/5}pt '${this.fontFace}'`,n.fillStyle=this.diceColor,n.fillRect(0,0,i.width,i.height),n.textAlign="center",n.textBaseline="middle",n.fillStyle=this.textColor;for(let a in this.faceTexts[t])n.fillText(`${this.faceTexts[t][a]}`,i.width/2,i.height/2-s*.3),n.translate(i.width/2,i.height/2),n.rotate(Math.PI*2/3),n.translate(-i.width/2,-i.height/2);let o=new ct(i);return o.needsUpdate=!0,o}updateMaterialsForValue(t){t<0&&(t+=4),this.faceTexts=this.d4FaceTexts[t],this.geometry.material=this.getMaterials()}},fo=class extends mi{constructor(){super(...arguments);this.fontFace=this.narrativeSymbolSet}},mo=class extends fo{constructor(t,i,n=Ki,s){super(t,i,n,s);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 o=(1+Math.sqrt(5))/2,a=1/o;this.vertices=[[0,a,o],[0,a,-o],[0,-a,o],[0,-a,-o],[o,0,a],[o,0,-a],[-o,0,a],[-o,0,-a],[a,o,0],[a,-o,0],[-a,o,0],[-a,-o,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]]}},Fl=class extends mo{constructor(t,i,n=Ki,s){super(t,i,n,s);this.labels=["","","z","z","z","z","z","z",`z
z`,"Z","Z",`Z
Z`,`Z
Z`,`Z
Z`];this.setColor({diceColor:"white",textColor:"#000000"})}},Ll=class extends mo{constructor(t,i,n=Ki,s){super(t,i,n,s);this.labels=["","","","s","s",`s
s`,`s
s`,"a",`s
a`,`s
a`,`s
a`,`a
a`,`a
a`,"x"];this.setColor({diceColor:"#FEF035",textColor:"#000000"})}},Bl=class extends mo{constructor(t,i,n=Ki,s){super(t,i,n,s);this.labels=["","","","f","f",`f
f`,`f
f`,"t","t",`t
f`,`t
f`,`t
t`,`t
t`,"y"];this.setColor({diceColor:"#751317",textColor:"#FFFFFF"})}},Pl=class extends fo{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}},Il=class extends Pl{constructor(t,i,n=Ki,s){super(t,i,n,s);this.labels=["","","","s","s",`s
s`,"a","a",`s
a`,`a
a`];this.setColor({diceColor:"#46AC4E",textColor:"#000000"})}},Nl=class extends Pl{constructor(t,i,n=Ki,s){super(t,i,n,s);this.labels=["","","","f",`f
f`,"t","t","t",`t
t`,`f
t`];this.setColor({diceColor:"#52287E",textColor:"#FFFFFF"})}},kl=class extends fo{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]}},Ol=class extends kl{constructor(t,i,n=Ki,s){super(t,i,n,s);this.labels=["","","","",`a
a`,"a",`s
a`,"s"];this.setColor({diceColor:"#76CDDB",textColor:"#000000"})}},zl=class extends kl{constructor(t,i,n=Ki,s){super(t,i,n,s);this.labels=["","","","","f","f","t","t"];this.setColor({diceColor:"#000000",textColor:"#FFFFFF"})}};var Vl=class{constructor(){this.resources=new Map}isTracking(e){return this.resources.has(e)}#e(e,t){if(Array.isArray(e))e.forEach(i=>{(this.resources.get(t)??[]).push(i),this.#e(i,t)});else{let i=this.resources.get(t??e)??[];this.resources.set(t??e,i)}}track(e){if("dispose"in e&&this.#e(e),e instanceof qe&&this.#e(e),"geometry"in e&&this.#e(e.geometry,e),"material"in e&&this.#e(e.material,e),"children"in e&&this.#e(e.children,e),e instanceof mt)for(let t of Object.values(e))t instanceof ct&&this.#e(t);return e}untrack(e){this.resources.delete(e)}dispose(){for(let[e]of this.resources)this.disposeResource(e);this.resources.clear()}disposeResource(e){"parent"in e&&e.parent&&e.parent.remove(e),"dispose"in e&&e.dispose();for(let t of this.resources.get(e)??[])this.disposeResource(t);this.resources.delete(e)}};var Jh=class r extends Yn.Component{constructor(){super();this.event=new Yn.Events;this.tracker=new Vl;this.container=createDiv("renderer-container");this.#e=new Set;this.shadows=!0;this.iterations=0;this.frame_rate=1/60;this.loaded=!1;this.#t=!1;this.#i=new WeakMap;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.#n=new WeakMap;this.extraFrames=r.DEFAULT_EXTRA_FRAMES;this.renderer=new We({alpha:!0,antialias:!0})}#e;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}#t;setData(t){this.data=t,this.factory?(this.factory.width=this.WIDTH,this.factory.height=this.HEIGHT,this.factory.updateDice(this.data)):this.factory=new Qh(this.WIDTH,this.HEIGHT,{diceColor:this.data.diceColor,textColor:this.data.textColor,colorfulDice:this.data.colorfulDice,scaler:this.data.scaler,textFont:this.data.textFont,narrativeSymbolSet:this.data.narrativeSymbolSet})}getDiceForRoller(t){return this.factory.getDiceForRoller(t,this.getVector())}#i;async addDice(t){return new Promise(i=>{this.#t||this.start();for(let n of t)n.recreate(this.getVector(),this.WIDTH,this.HEIGHT),this.scene.add(this.tracker.track(n.geometry)),this.world.add(n);this.#e.add(t),this.#i.set(t,()=>{i()})})}onload(){this.loaded=!0,this.addChild(this.factory),this.container.empty(),this.container.style.opacity="1",this.renderer.shadowMap.enabled=this.shadows,this.renderer.shadowMap.type=qh,this.container.appendChild(this.renderer.domElement),document.body.appendChild(this.container),this.renderer.setClearColor(0,0),this.scene=new Vs,this.initScene(),this.initWorld(),this.registerDomEvent(window,"resize",()=>{this.initScene()})}onunload(){this.loaded=!1,cancelAnimationFrame(this.animation),this.container.detach(),this.container.empty(),this.renderer.domElement.detach(),this.factory.dispose(),this.renderer.renderLists.dispose(),this.renderer.dispose(),this.tracker.dispose(),[...this.#e.values()].flat().forEach(t=>{this.world.world.removeBody(t.body)}),this.#e=new Set}start(){this.#t&&this.stop(),this.loaded||this.load(),this.#t=!0,this.extraFrames=r.DEFAULT_EXTRA_FRAMES,this.render()}static{this.DEFAULT_EXTRA_FRAMES=30}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(t){this.display.currentWidth=this.container.clientWidth/2,this.display.currentHeight=this.container.clientHeight/2,t?(this.display.containerWidth=t.w,this.display.containerHeight=t.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.factory.updateDice(this.data),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 Mt(20,this.display.currentWidth/this.display.currentHeight,1,this.cameraHeight.max*1.3),this.camera.position.z=this.cameraHeight.far,this.camera.lookAt(new P(0,0,0))}initLighting(){let t=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 oo(this.colors.spotlight,.25),this.light.position.set(-t/2,t/2,t*3),this.light.target.position.set(0,0,0),this.light.distance=t*5,this.light.angle=Math.PI/4,this.light.castShadow=this.shadows,this.light.shadow.camera.near=t/10,this.light.shadow.camera.far=t*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.tracker.track(this.light)),this.ambientLight=new ao(16777215,.9),this.scene.add(this.tracker.track(this.ambientLight))}initDesk(){this.desk&&this.scene.remove(this.desk);let t=new so;t.opacity=.5,this.desk=new ft(new Gr(this.display.containerWidth*6,this.display.containerHeight*6,1,1),t),this.desk.receiveShadow=this.shadows,this.scene.add(this.tracker.track(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 Kh(this.WIDTH,this.HEIGHT),this.iterations=0}finishRender(){this.event.trigger("throw-finished")}#n;static{this.Threshold=5}throwFinished(){let t=!0;for(let i of this.#e){let n=!0;for(let s of i){if(s.iterations>10/this.frame_rate&&(s.stopped=!0),s.stopped===!0)continue;let o=s.body.angularVelocity,a=s.body.velocity;if(Math.abs(o.length())<r.Threshold&&Math.abs(a.length())<r.Threshold){if(this.iterations-s.iterations>5){s.stopped=!0;continue}n=!1,t=!1}else s.iterations++,s.stopped=!1,n=!1,t=!1}n&&this.#i.has(i)&&(this.#i.get(i)(),this.#i.delete(i))}return t}unrender(){this.container.style.opacity="0",cancelAnimationFrame(this.animation),this.registerInterval(window.setTimeout(()=>{this.stop()},1e3))}stop(){if(this.#t)for(let t of[...this.#e]){this.#i.has(t)&&(this.#i.get(t)(),this.#i.delete(t));for(let i of t)i.stopped=!0}this.#t=!1,this.unload()}resizeRendererToDisplaySize(){let t=this.renderer.domElement,i=window.devicePixelRatio,n=t.clientWidth*i|0,s=t.clientHeight*i|0,o=t.width!==n||t.height!==s;return o&&this.renderer.setSize(n,s,!1),o}render(){if(this.throwFinished())if(this.extraFrames>10)this.extraFrames--;else{try{if(this.data.renderTime)this.registerInterval(window.setTimeout(()=>this.unrender(),this.data.renderTime));else{let i=function(){t.stop(),document.body.removeEventListener("click",i)},t=this;this.registerDomEvent(document.body,"click",i)}}catch(t){this.event.trigger("error",t)}return}this.animation=requestAnimationFrame(()=>this.render()),this.resizeRendererToDisplaySize()&&(this.camera.aspect=this.canvasEl.clientWidth/this.canvasEl.clientHeight,this.camera.updateProjectionMatrix()),this.world.step(this.frame_rate),this.iterations++,[...this.#e.values()].forEach(t=>t.forEach(i=>i.set())),this.renderer.render(this.scene,this.camera)}getVector(){return{x:(Math.random()*2-1)*this.WIDTH,y:-(Math.random()*2-1)*this.HEIGHT}}dispose(...t){t.forEach(i=>{i.children&&this.dispose(...i.children),i.clear()})}},Et=new Jh,Kh=class{constructor(e,t){this.WIDTH=e;this.HEIGHT=t;this.world=new Yo({gravity:new b(0,0,-9.82*200)});this.ground=this.getPlane();this.diceMaterial=new cn;this.deskMaterial=new cn;this.barrierMaterial=new cn;this.world.broadphase=new gr,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)})}remove(...e){e.forEach(t=>this.world.removeBody(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 ln(this.deskMaterial,this.diceMaterial,{friction:.01,restitution:.5,contactEquationRelaxation:3,contactEquationStiffness:1e8})),this.world.addContactMaterial(new ln(this.barrierMaterial,this.diceMaterial,{friction:.01,restitution:1,contactEquationRelaxation:3,contactEquationStiffness:1e8})),this.world.addContactMaterial(new ln(this.diceMaterial,this.diceMaterial,{friction:.1,restitution:.5,contactEquationRelaxation:3,contactEquationStiffness:1e8})),this.world.addBody(new De({allowSleep:!1,mass:0,shape:new Hi,material:this.deskMaterial}));let e=new De({allowSleep:!1,mass:0,shape:new Hi,material:this.barrierMaterial});e.quaternion.setFromAxisAngle(new b(1,0,0),Math.PI/2),e.position.set(0,this.HEIGHT*.93,0),this.world.addBody(e),e=new De({allowSleep:!1,mass:0,shape:new Hi,material:this.barrierMaterial}),e.quaternion.setFromAxisAngle(new b(1,0,0),-Math.PI/2),e.position.set(0,-this.HEIGHT*.93,0),this.world.addBody(e),e=new De({allowSleep:!1,mass:0,shape:new Hi,material:this.barrierMaterial}),e.quaternion.setFromAxisAngle(new b(0,1,0),-Math.PI/2),e.position.set(this.WIDTH*.93,0,0),this.world.addBody(e),e=new De({allowSleep:!1,mass:0,shape:new Hi,material:this.barrierMaterial}),e.quaternion.setFromAxisAngle(new b(0,1,0),Math.PI/2),e.position.set(-this.WIDTH*.93,0,0),this.world.addBody(e)}getPlane(){return new De({type:De.STATIC,shape:new Hi})}},Qh=class extends Yn.Component{constructor(t,i,n){super();this.width=t;this.height=i;this.options=n;this.dice={};this.updateDice=(0,Yn.debounce)(t=>{this.options={...t},this.dispose(),this.buildDice()},200);this.buildDice()}get colors(){let t=this.options.diceColor,i=this.options.textColor,n=this.options.textFont,s=this.options.narrativeSymbolSet;if(!this.options.colorfulDice)return{diceColor:t,textFont:n,narrativeSymbolSet:s}}onunload(){this.dispose()}disposeChildren(...t){t.forEach(i=>{"dispose"in i&&i.dispose(),i.children&&this.disposeChildren(...i.children)})}dispose(){for(let t of Object.values(this.dice))this.disposeChildren(t.geometry.children)}getDiceForRoller(t,i){let n=[];switch(t.getType()){case Ue.D4:{n.push(new bl(this.width,this.height,this.clone("d4"),i));break}case Ue.FUDGE:{n.push(new Zs(this.width,this.height,this.clone("fudge"),i));break}case Ue.STUNT:{n.push(new Zs(this.width,this.height,this.clone("stunt"),i));break}case Ue.D6:{n.push(new Zs(this.width,this.height,this.clone("d6"),i));break}case Ue.D8:{n.push(new gl(this.width,this.height,this.clone("d8"),i));break}case Ue.D10:{n.push(new ho(this.width,this.height,this.clone("d10"),i));break}case Ue.D12:{n.push(new hl(this.width,this.height,this.clone("d12"),i));break}case Ue.D20:{n.push(new ul(this.width,this.height,this.clone("d20"),i));break}case Ue.D100:{n.push(new ml(this.width,this.height,this.clone("d100"),i),new ho(this.width,this.height,this.clone("d10"),i));break}case Ue.BOOST:{n.push(new vl(this.width,this.height,this.clone("boost"),i));break}case Ue.SETBACK:{n.push(new wl(this.width,this.height,this.clone("setback"),i));break}case Ue.ABILITY:{n.push(new yl(this.width,this.height,this.clone("ability"),i));break}case Ue.DIFFICULTY:{n.push(new xl(this.width,this.height,this.clone("difficulty"),i));break}case Ue.FORCE:{n.push(new pl(this.width,this.height,this.clone("force"),i));break}case Ue.PROFICIENCY:{n.push(new dl(this.width,this.height,this.clone("proficiency"),i));break}case Ue.CHALLENGE:{n.push(new fl(this.width,this.height,this.clone("challenge"),i));break}case Ue.NONE:break}return n}getDice(t,i){let n=new Map;for(let s of t.dynamic){let o=this.getDiceForRoller(s,i);o.length&&n.set(s,o)}return n}clone(t){if(!(t in this.dice))throw new Error("That dice type does not exist!");return this.dice[t].clone()}buildDice(){this.dice.d100=new Ml(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.d20=new El(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.d12=new Al(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.d10=new Sl(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.d8=new Dl(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.d6=new Js(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.d4=new Rl(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.fudge=new Tl(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.stunt=new Cl(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.boost=new Ol(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.ability=new Il(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.difficulty=new Nl(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.challenge=new Bl(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.proficiency=new Ll(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.force=new Fl(this.width,this.height,this.colors,this.options.scaler).create(),this.dice.setback=new zl(this.width,this.height,this.colors,this.options.scaler).create()}};var Ks=(n=>(n.None="None",n.Normal="Normal",n.Up="Up",n.Down="Down",n))(Ks||{});var zt={LEFT:"LEFT",RIGHT:"RIGHT",NONE:"NONE"};var ti=require("obsidian");var go=class extends ti.Component{constructor(){super(...arguments);this.components=[];this.loaded=!1;this.#e=new ti.Events}on(t,i,n){return this.#e.on(t,i)}once(t,i){let n=this.on(t,(...s)=>{i(...s),this.offref(n)})}off(t,i){return this.#e.off(t,i)}offref(t){return this.#e.offref(t)}trigger(t,...i){return this.#e.trigger(t,...i)}tryTrigger(t,i){return this.#e.tryTrigger(t,i)}onload(){this.loaded=!0,this.trigger("loaded")}onunload(){this.components=[]}addContexts(...t){this.components=t;for(let i of t)i.addChild(this)}#e;getRandomBetween(t,i){let n=new Uint32Array(1);crypto.getRandomValues(n);let s=n[0]/4294967296;return Math.floor(s*(i-t+1))+t}},Ul=class extends go{constructor(t,i="",n=t.position){super();this.data=t;this.original=i;this.loaded=!1;switch(this.original||(this.original=""),this.containerEl=createSpan({cls:"dice-roller",attr:{"aria-label-position":"top","data-dice":this.original}}),this.resultEl=this.containerEl.createSpan("dice-roller-result"),this.iconEl=createSpan({cls:"dice-roller-button"}),(0,ti.setIcon)(this.iconEl,"dices"),this.iconEl.onclick=this.onClick.bind(this),n){case"LEFT":{this.containerEl.prepend(this.iconEl);break}case"RIGHT":{this.containerEl.append(this.iconEl);break}case"NONE":{this.containerEl.addClass("no-icon");break}}this.containerEl.onclick=this.onClick.bind(this)}onLoad(t){this.loaded?t():this.on("loaded",()=>t())}onunload(){this.containerEl.empty();let t=createEl("pre");t.createEl("code",{text:this.original}),this.containerEl.append(t)}setTooltip(){this.data.displayResultsInline||this.containerEl.setAttrs({"aria-label":this.getTooltip()})}getRandomBetween(t,i){let n=new Uint32Array(1);crypto.getRandomValues(n);let s=n[0]/4294967296;return Math.floor(s*(i-t+1))+t}async render(){this.setTooltip(),await this.build()}async onClick(t){t.target instanceof HTMLAnchorElement||(t.stopPropagation(),t.stopImmediatePropagation(),window.getSelection()?.isCollapsed&&await this.roll())}},Qs=class extends Ul{constructor(t,i,n,s=t.position){super(t,i,s);this.data=t;this.original=i;this.lexemes=n;this.position=s;this.save=!1}setSpinner(){this.resultEl.empty(),(0,ti.setIcon)(this.resultEl.createDiv("should-spin"),"loader-2")}setSource(t){this.source=t}getSource(){return this.source}get inlineText(){return`${this.getTooltip().split(`
`).join(" -> ")} -> `}},er=class extends Qs{constructor(){super(...arguments);this.shouldRender=!1;this.isRendering=!1;this.hasRunOnce=!1}onunload(){this.isRendering&&Et.stop(),super.onunload()}async onClick(t){t.stopPropagation(),t.stopImmediatePropagation(),this.isRendering&&Et.stop(),this.#e?.abort(),t.getModifierState("Shift")?(await this.roll(!0),this.hasRunOnce=!0):window.getSelection()?.isCollapsed&&await this.roll()}#e;async renderChildren(){this.isRendering=!0,this.setTooltip(),this.setSpinner();let t=[];this.#e=new AbortController;for(let i of this.children)t.push(new Promise(async(n,s)=>{this.#e.signal.addEventListener("abort",()=>{s()}),await i.render(this.#e),n()}));try{await Promise.all(t)}catch{return}this.isRendering=!1,this.setTooltip()}},yo=class extends Qs{constructor(t,i,n,s,o,a=t.position){super(t,i,[n],a);this.data=t;this.original=i;this.lexeme=n;this.source=s;this.app=o;this.dirtyEl=this.containerEl.createDiv({cls:"dice-roller-dirty dice-roller-button",attr:{"aria-label":"The underlying data source for this roller was modified"}});this.#t=!1;this.getPath()}async getFile(){if(this.file=this.app.metadataCache.getFirstLinkpathDest(this.path,this.source),!this.file||!(this.file instanceof ti.TFile))throw new Error("Could not load file.")}#e;async render(){super.render(),this.dirtyEl.empty()}async checkForDirtiness(t){let i=await this.hash(t);return i===this.#e?(this.dirtyEl.empty(),!1):(this.#e&&(0,ti.setIcon)(this.dirtyEl,"alert-triangle"),this.#e=i,!0)}async hash(t){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t))),i=>i.toString(16).padStart(2,"0")).join("")}#t;async onload(){if(this.#t)return;this.#t=!0,await this.getFile();let t=this.app.metadataCache.getFileCache(this.file),i=await this.app.vault.cachedRead(this.file);await this.getOptions(t,i),this.loaded=!0,this.trigger("loaded"),this.registerEvent(this.app.metadataCache.on("changed",async(n,s,o)=>{n===this.file&&await this.getOptions(o,s)}))}},tr=class extends yo{constructor(t,i,n,s,o,a=t.position,l=!0){super(t,i,n,s,o,a);this.data=t;this.original=i;this.lexeme=n;this.app=o;this.inline=l;this.data.displayAsEmbed&&(this.containerEl.addClasses(["has-embed","markdown-embed"]),this.resultEl.addClass("internal-embed")),this.resultEl.setAttrs({src:s}),this.copy=this.containerEl.createDiv({cls:"dice-content-copy dice-roller-button no-show",attr:{"aria-label":"Copy Contents"}}),this.copy.addEventListener("click",c=>{c.stopPropagation(),navigator.clipboard.writeText(this.transformResultsToString()).then(async()=>{new ti.Notice("Result copied to clipboard.")})}),(0,ti.setIcon)(this.copy,"copy")}getEmbedClass(){return this.data.displayAsEmbed?"markdown-embed":""}},Hl=class extends Ul{constructor(t,i,n){super(t,"");this.options=i;this.rolls=n}getTooltip(){return`${this.options.toString()}
${this.results.toString()}`}async roll(){let t=[...this.options];return this.results=[...Array(this.rolls)].map(()=>{let i=t[this.getRandomBetween(0,t.length-1)];return t.splice(t.indexOf(i),1),i}).filter(i=>i),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 vo=class extends gt{constructor(t,i){super(t,i);this.dice=t;this.stack=[];let n=`${this.faces.max}`.split("");for(let s=0;s<this.rolls;s++){let o=[];for(let a of n){let l=new gt(`1d${a}`);o.push(l),l.roll()}this.stack.push(o)}}getType(){return Ue.NONE}canRender(){return!1}get result(){let t=0;for(let i of this.stack){let n=[];for(let s of i)s.rollSync(),n.push(s.result);t+=Number(n.join(""))}return t}get display(){return this.stack.map(t=>t.map(i=>i.result).join(",")).join("|")}async roll(){if(!this.stack||!this.stack.length)return super.roll();this.stack.forEach(t=>t.map(i=>i.roll()))}allowAverage(){return!1}};var ed=class extends gt{getType(){return Ue.STUNT}canRender(){return!0}constructor(){super("1d6")}allowAverage(){return!1}},gi=class extends gt{constructor(t,i){super(t,i);this.dice=t;this.pair=new gt("2d6");this.stunt=new ed}async roll(){await Promise.all([new Promise(async t=>{this.pair.shouldRender=this.shouldRender,await this.pair.roll(),t()}),new Promise(async t=>{this.stunt.shouldRender=this.shouldRender,await this.stunt.roll(),t()})])}get doubles(){return new Set([...this.pair.resultArray,this.stunt.result]).size<3}get result(){return this.pair.result+this.stunt.result}get display(){return`${[this.pair.display,`${this.stunt.display}${this.doubles?"S":""}`].join(", ")}`}};var wo=class extends gt{constructor(){super(...arguments);this.possibilities=[-1,0,1]}getType(){return Ue.FUDGE}canRender(){return!0}};var _l=class extends go{constructor(t,i){super();this.original=t;this.lexemes=i;this.operators={"+":(t,i)=>t+i,"-":(t,i)=>t-i,"*":(t,i)=>t*i,"/":(t,i)=>t/i,"^":(t,i)=>Math.pow(t,i)};this.stack=[];this.stackCopy=[];this.stunted="";this.dice=[]}async roll(){return this.rollSync()}rollSync(){this.stunted="",this.parseLexemes();let t=this.stack.pop();return t.rollSync(),t instanceof gi&&t.doubles&&(this.stunted=` - ${t.results.get(0).value} Stunt Points`),this.result=t.result,this.result}parseLexemes(){let t=0;for(let i of this.lexemes)switch(i.type){case"+":case"-":case"*":case"/":case"^":case"math":let n=this.stack.pop(),s=this.stack.pop();n.rollSync(),n instanceof gi&&n.doubles&&(this.stunted=` - ${n.results.get(0).value} Stunt Points`),s.rollSync(),s instanceof gi&&s.doubles&&(this.stunted=` - ${s.results.get(0).value} Stunt Points`);let o=this.operators[i.value](s.result,n.result);this.stackCopy.push(i.value),this.stack.push(new gt(`${o}`,i));break;case"u":{let a=this.dice[t-1],l=i.value?Number(i.value):1;a.modifiers.set("u",{data:l,conditionals:[],value:i.text});break}case"kh":{let a=this.dice[t-1],l=i.value?Number(i.value):1;a.modifiers.set("kh",{data:l,conditionals:[],value:i.text});break}case"dl":{let a=this.dice[t-1],l=i.value?Number(i.value):1;l=a.rolls-l,a.modifiers.set("kh",{data:l,conditionals:[],value:i.text});break}case"kl":{let a=this.dice[t-1],l=i.value?Number(i.value):1;a.modifiers.set("kl",{data:l,conditionals:[],value:i.text});break}case"dh":{let a=this.dice[t-1],l=i.value?Number(i.value):1;l=a.rolls-l,a.modifiers.set("kl",{data:l,conditionals:[],value:i.text});break}case"!":{let a=this.dice[t-1],l=Number(i.value)||1;a.modifiers.set("!",{data:l,conditionals:i.conditions??[],value:i.text});break}case"!!":{let a=this.dice[t-1],l=Number(i.value)||1;a.modifiers.set("!!",{data:l,conditionals:i.conditions??[],value:i.text});break}case"r":{let a=this.dice[t-1],l=Number(i.value)||1;a.modifiers.set("r",{data:l,conditionals:i.conditions??[],value:i.text});break}case"sort":{let a=this.dice[t-1],l=Number(i.value);a.modifiers.set("sort",{data:l,conditionals:i.conditions??[],value:i.value});break}case"dice":{if(i.parenedDice&&/^d/.test(i.value)&&this.stack.length){let a=this.stack.pop();i.value=`${a.result}${i.value}`,this.dice[t]=new gt(i.value,i)}this.dice[t]||(this.dice[t]=new gt(i.value,i)),this.stack.push(this.dice[t]),this.stackCopy.push(this.dice[t]),t++;break}case"fudge":{this.dice[t]||(this.dice[t]=new wo(i.value,i)),this.stack.push(this.dice[t]),this.stackCopy.push(this.dice[t]),t++;break}case"stunt":{this.dice[t]||(this.dice[t]=new gi(i.value,i)),this.stack.push(this.dice[t]),this.stackCopy.push(this.dice[t]),t++;break}case"%":{this.dice[t]||(this.dice[t]=new vo(i.value,i)),this.stack.push(this.dice[t]),this.stackCopy.push(this.dice[t]),t++;break}}}},Wt=class extends er{constructor(t,i,n,s,o=t.position,a,l=t.initialDisplay,c=t.displayFormulaAfter,u=t.round,h=t.signed){super(t,i,n,o);this.data=t;this.original=i;this.lexemes=n;this.app=s;this.displayFixedText=!1;this.stunted="";this.shouldRender=!1;this.isRendering=!1;this.showFormula=!1;this.operators={"+":(t,i)=>t+i,"-":(t,i)=>t-i,"*":(t,i)=>t*i,"/":(t,i)=>t/i,"^":(t,i)=>Math.pow(t,i)};this.stack=[];this.maxStack=[];this.minStack=[];this.stackCopy=[];this.children=[];this.hasRunOnce=!1;this.max=Number.MIN_VALUE;this.min=Number.MAX_VALUE;c&&this.containerEl.createSpan({cls:"dice-roller-formula",text:`(${i})`}),this.fixedText=a,this.expectedValue=l,this.displayFixedText=this.fixedText!=="",this.round=u,this.signed=h}async getReplacer(){return`${this.showFormula?`${this.inlineText} `:""}${this.result}`}getDisplayText(){let t=[],i=0;return this.children.forEach(n=>{let s=this.original.slice(i);t.push(s.slice(0,s.indexOf(n.lexeme.text)),n.display),i+=s.indexOf(n.lexeme.text)+n.lexeme.text.length+n.modifierText.length}),t.push(this.original.slice(i)),t.join("")}getResultText(){return`${this.result}`}getTooltip(){if(this.isRendering)return this.original;if(this._tooltip)return this._tooltip;let t=this.getDisplayText();return this.expectedValue==="Roll"||this.shouldRender?this.displayFixedText?`${this.original}
${this.result} = ${t}`:`${this.original}
${t}`:this.expectedValue==="Average"?this.displayFixedText?`${this.original}
${this.result} = average: ${t}`:`${this.original}
average: ${t}`:`${this.original}
empty`}allowAverage(){return this.dynamic.every(t=>t.allowAverage())}async build(){if(this.resultEl.empty(),this.expectedValue==="Average"&&!this.shouldRender){if(this.allowAverage()){for(let s of this.dynamic){let o=s.average(),a=new Map;for(let l=0;l<s.rolls;l++)a.set(l,o);s.setResults(a)}this.calculate()}else this.expectedValue="Roll";this.result=Math.floor(this.result),this.setTooltip()}let t=this.result;switch(this.round){case"None":{t=Math.trunc(t*100)/100;break}case"Normal":{t=Math.round(t);break}case"Up":{t=Math.ceil(t);break}case"Down":{t=Math.floor(t);break}}let i=this.signed&&t>0?"+":"",n;this.expectedValue==="None"&&!this.shouldRender?(this.position!=zt.NONE?n=[""]:n=["\xA0"],this.showFormula&&n.unshift(this.original+" -> ")):(n=[`${i}${t}`],this.showFormula&&n.unshift(this.inlineText)),this.expectedValue="Roll",this.displayFixedText?this.resultEl.setText(this.fixedText):this.resultEl.setText(n.join("")+this.stunted),this.result===this.max?this.containerEl.addClass("is-max"):this.containerEl.removeClass("is-max"),this.result===this.min?this.containerEl.addClass("is-min"):this.containerEl.removeClass("is-min")}async onClick(t){t.getModifierState("Alt")?this.expectedValue="Average":t.getModifierState("Control")&&(this.expectedValue="None"),super.onClick(t)}get dynamic(){return this.children.filter(t=>!t.static)}get static(){return this.children.filter(t=>t.static)}get isStatic(){return this.children.every(t=>t.static)}rollSync(){this.stunted="",this.buildDiceTree();for(let t of this.children)t.rollSync();return this.calculate(),this._tooltip=null,this.render(),this.trigger("new-result"),this.hasRunOnce=!0,this.result}buildDiceTree(){let t=0;for(let i of this.lexemes)switch(i.type){case"+":case"*":case"/":case"^":case"-":case"math":continue;case"u":{let n=this.children[t-1],s=i.value?Number(i.value):1;n.modifiers.set("u",{data:s,conditionals:[],value:i.text});break}case"kh":{let n=this.children[t-1],s=i.value?Number(i.value):1;n.modifiers.set("kh",{data:s,conditionals:[],value:i.text});break}case"dl":{let n=this.children[t-1],s=i.value?Number(i.value):1;s=n.rolls-s,n.modifiers.set("kh",{data:s,conditionals:[],value:i.text});break}case"kl":{let n=this.children[t-1],s=i.value?Number(i.value):1;n.modifiers.set("kl",{data:s,conditionals:[],value:i.text});break}case"dh":{let n=this.children[t-1],s=i.value?Number(i.value):1;s=n.rolls-s,n.modifiers.set("kl",{data:s,conditionals:[],value:i.text});break}case"!":{let n=this.children[t-1],s=Number(i.value)||1;n.modifiers.set("!",{data:s,conditionals:i.conditions??[],value:i.text});break}case"!!":{let n=this.children[t-1],s=Number(i.value)||1;n.modifiers.set("!!",{data:s,conditionals:i.conditions??[],value:i.text});break}case"r":{let n=this.children[t-1],s=Number(i.value)||1;n.modifiers.set("r",{data:s,conditionals:i.conditions??[],value:i.text});break}case"sort":{let n=this.children[t-1],s=Number(i.value);n.modifiers.set("sort",{data:s,conditionals:i.conditions??[],value:i.value});break}case"dice":{if(i.parenedDice&&/^d/.test(i.value)&&this.stack.length){let n=this.stack.pop();i.value=`${n.result}${i.value}`,this.children[t]=new gt(i.value,i)}this.children[t]||(this.children[t]=new gt(i.value,i)),t++;break}case"fudge":{this.children[t]||(this.children[t]=new wo(i.value,i)),t++;break}case"stunt":{this.children[t]||(this.children[t]=new gi(i.value,i)),t++;break}case"%":{this.children[t]||(this.children[t]=new vo(i.value,i)),t++;break}}}async roll(t){if(this.stunted="",this.stackCopy=[],this.children.length||this.buildDiceTree(),Et.stop(),this.children.forEach(i=>i.shouldRender=!1),t||this.shouldRender&&this.hasRunOnce)await this.renderChildren();else for(let i of this.children)await i.roll();return this.calculate(),this.render(),this.showRenderNotice&&(t||this.shouldRender&&this.hasRunOnce)&&new Ym.Notice(`${this.getTooltip()}
Result: ${this.result}`),this.trigger("new-result"),this.app.workspace.trigger("dice-roller:new-result",this),this.hasRunOnce=!0,this.result}calculate(){let t=0;for(let n of this.lexemes)switch(n.type){case"+":case"-":case"*":case"/":case"^":case"math":{let s=this.stack.pop(),o=this.stack.pop();s instanceof gi&&s.doubles&&(this.stunted=` - ${s.results.get(0).value} Stunt Points`),o instanceof gi&&o.doubles&&(this.stunted=` - ${o.results.get(0).value} Stunt Points`);let a=this.operators[n.value](o.result,s.result),l=this.operators[n.value](this.minStack.pop(),this.minStack.pop()),c=this.operators[n.value](this.maxStack.pop(),this.maxStack.pop());this.stackCopy.push(n.value),this.stack.push(new gt(`${a}`,n)),this.minStack.push(l),this.maxStack.push(c);break}case"stunt":case"fudge":case"%":case"dice":this.stack.push(this.children[t]),this.stackCopy.push(this.children[t]),this.minStack.push(this.children[t].getMinPossible()),this.maxStack.push(this.children[t].getMaxPossible()),t++;default:continue}let i=this.stack.pop();this.min=this.minStack.pop(),this.max=this.maxStack.pop(),i instanceof gi&&i.doubles&&(this.stunted=` - ${i.stunt.result} Stunt Points`),this.result=i.result}};var le=require("obsidian");var ir=require("obsidian"),oE=createSvg("svg",{attr:{viewBox:"0 0 500 500"}}),aE=createSvg("text",{attr:{class:"font",fill:"currentColor",x:"50%",y:"50%","text-anchor":"middle","dominant-baseline":"central"}}),ql=(a=>(a.NONE="None",a.TRIANGLE="Triangle",a.SQUARE="Square",a.DIAMOND="Diamond",a.DODECAHEDRON="Dodecahedron",a.ICOSAHEDRON="Icosahedron",a.CIRCLE="Circle",a))(ql||{}),Zm=[{id:"dice-roller-d4",shape:"Triangle",formula:"d4",text:"4"},{id:"dice-roller-d6",shape:"Square",formula:"d6",text:"6"},{id:"dice-roller-d8",shape:"Diamond",formula:"d8",text:"8"},{id:"dice-roller-d10",shape:"Diamond",formula:"d10",text:"10"},{id:"dice-roller-d12",shape:"Dodecahedron",formula:"d12",text:"12"},{id:"dice-roller-d20",shape:"Icosahedron",formula:"d20",text:"20"},{id:"dice-roller-d100",shape:"Circle",formula:"d%",text:"%"}],td=class extends ir.Component{#e(){return oE.cloneNode(!0)}#t(){return aE.cloneNode()}#i=new Set;registerIcon(e,t,i){this.#i.add(e);let n=this.#e(),s=this.#t();s.textContent=i,n.appendChild(s);let o;switch(t){case"Triangle":o=this.getTriangle();break;case"Square":{o=this.getSquare();break}case"Diamond":{o=this.getDiamond();break}case"Dodecahedron":{o=this.getDodecahedron();break}case"Icosahedron":{o=this.getIcosahedron();break}case"Circle":{o=this.getCircle();break}case"None":o=createSvg("defs")}n.appendChild(o),(0,ir.addIcon)(e,n.outerHTML),this.register(()=>(0,ir.removeIcon)(e))}getTriangle(){return this.#n("path",{d:"M244.6,49.3L40.3,403.2c-1.7,3-0.7,6.8,2.3,8.5c0.9,0.5,2,0.8,3.1,0.8h408.6c3.4,0,6.2-2.8,6.2-6.2 c0-1.1-0.3-2.2-0.8-3.1L255.4,49.3c-1.7-3-5.5-4-8.5-2.3C246,47.6,245.2,48.4,244.6,49.3z"})}getSquare(){return this.#n("rect",{x:"87.5",y:"87.5",width:"325",height:"325",rx:"10"})}getDiamond(){return this.#n("rect",{x:"102.75",y:"102.75",width:"294.51",height:"294.51",rx:"9.8",transform:"translate(-103.55 250) rotate(-45)"})}getDodecahedron(){return this.#n("path",{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"})}getIcosahedron(){return this.#n("path",{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"})}getCircle(){return this.#n("circle",{cx:"250",cy:"250",r:"190"})}#n(e,t){return createSvg(e,{cls:"shape",attr:{...t,stroke:"currentColor"}})}onunload(){}},Wl=new td;var lE=Function.prototype.toString,id=Object.create,cE=Object.prototype.toString,uE=function(){function r(){this._keys=[],this._values=[]}return r.prototype.has=function(e){return!!~this._keys.indexOf(e)},r.prototype.get=function(e){return this._values[this._keys.indexOf(e)]},r.prototype.set=function(e,t){this._keys.push(e),this._values.push(t)},r}();function hE(){return new uE}function dE(){return new WeakMap}var pE=typeof WeakMap<"u"?dE:hE;function sd(r){if(!r)return id(null);var e=r.constructor;if(e===Object)return r===Object.prototype?{}:id(r);if(e&&~lE.call(e).indexOf("[native code]"))try{return new e}catch{}return id(r)}function fE(r){var e="";return r.global&&(e+="g"),r.ignoreCase&&(e+="i"),r.multiline&&(e+="m"),r.unicode&&(e+="u"),r.sticky&&(e+="y"),e}function mE(r){return r.flags}var gE=/test/g.flags==="g"?mE:fE;function Jm(r){var e=cE.call(r);return e.substring(8,e.length-1)}function yE(r){return r[Symbol.toStringTag]||Jm(r)}var xE=typeof Symbol<"u"?yE:Jm,vE=Object.defineProperty,wE=Object.getOwnPropertyDescriptor,Km=Object.getOwnPropertyNames,rd=Object.getOwnPropertySymbols,Qm=Object.prototype,eg=Qm.hasOwnProperty,bE=Qm.propertyIsEnumerable,tg=typeof rd=="function";function _E(r){return Km(r).concat(rd(r))}var EE=tg?_E:Km;function jl(r,e,t){for(var i=EE(r),n=0,s=i.length,o=void 0,a=void 0;n<s;++n)if(o=i[n],!(o==="callee"||o==="caller")){if(a=wE(r,o),!a){e[o]=t.copier(r[o],t);continue}!a.get&&!a.set&&(a.value=t.copier(a.value,t));try{vE(e,o,a)}catch{e[o]=a.value}}return e}function AE(r,e){var t=new e.Constructor;e.cache.set(r,t);for(var i=0,n=r.length;i<n;++i)t[i]=e.copier(r[i],e);return t}function SE(r,e){var t=new e.Constructor;return e.cache.set(r,t),jl(r,t,e)}function ig(r,e){return r.slice(0)}function ME(r,e){return r.slice(0,r.size,r.type)}function DE(r,e){return new e.Constructor(ig(r.buffer))}function TE(r,e){return new e.Constructor(r.getTime())}function ng(r,e){var t=new e.Constructor;return e.cache.set(r,t),r.forEach(function(i,n){t.set(n,e.copier(i,e))}),t}function CE(r,e){return jl(r,ng(r,e),e)}function RE(r,e){var t=sd(e.prototype);e.cache.set(r,t);for(var i in r)eg.call(r,i)&&(t[i]=e.copier(r[i],e));return t}function FE(r,e){var t=sd(e.prototype);e.cache.set(r,t);for(var i in r)eg.call(r,i)&&(t[i]=e.copier(r[i],e));for(var n=rd(r),s=0,o=n.length,a=void 0;s<o;++s)a=n[s],bE.call(r,a)&&(t[a]=e.copier(r[a],e));return t}var LE=tg?FE:RE;function BE(r,e){var t=sd(e.prototype);return e.cache.set(r,t),jl(r,t,e)}function nd(r,e){return new e.Constructor(r.valueOf())}function PE(r,e){var t=new e.Constructor(r.source,gE(r));return t.lastIndex=r.lastIndex,t}function $l(r,e){return r}function sg(r,e){var t=new e.Constructor;return e.cache.set(r,t),r.forEach(function(i){t.add(e.copier(i,e))}),t}function IE(r,e){return jl(r,sg(r,e),e)}var NE=Array.isArray,od=Object.assign,kE=Object.getPrototypeOf||function(r){return r.__proto__},rg={array:AE,arrayBuffer:ig,blob:ME,dataView:DE,date:TE,error:$l,map:ng,object:LE,regExp:PE,set:sg},OE=od({},rg,{array:SE,map:CE,object:BE,set:IE});function zE(r){return{Arguments:r.object,Array:r.array,ArrayBuffer:r.arrayBuffer,Blob:r.blob,Boolean:nd,DataView:r.dataView,Date:r.date,Error:r.error,Float32Array:r.arrayBuffer,Float64Array:r.arrayBuffer,Int8Array:r.arrayBuffer,Int16Array:r.arrayBuffer,Int32Array:r.arrayBuffer,Map:r.map,Number:nd,Object:r.object,Promise:$l,RegExp:r.regExp,Set:r.set,String:nd,WeakMap:$l,WeakSet:$l,Uint8Array:r.arrayBuffer,Uint8ClampedArray:r.arrayBuffer,Uint16Array:r.arrayBuffer,Uint32Array:r.arrayBuffer,Uint64Array:r.arrayBuffer}}function og(r){var e=od({},rg,r),t=zE(e),i=t.Array,n=t.Object;function s(o,a){if(a.prototype=a.Constructor=void 0,!o||typeof o!="object")return o;if(a.cache.has(o))return a.cache.get(o);if(a.prototype=kE(o),a.Constructor=a.prototype&&a.prototype.constructor,!a.Constructor||a.Constructor===Object)return n(o,a);if(NE(o))return i(o,a);var l=t[xE(o)];return l?l(o,a):typeof o.then=="function"?o:n(o,a)}return function(a){return s(a,{Constructor:void 0,cache:pE(),copier:s,prototype:void 0})}}function VE(r){return og(od({},OE,r))}var jD=VE({}),Xl=og({});var Yl={position:zt.RIGHT,showFudgeIcon:!1,rollLinksForTags:!1,copyContentButton:!0,customFormulas:[],displayFormulaForMod:!0,displayResultsInline:!1,displayFormulaAfter:!1,escapeDiceMod:!0,signed:!1,displayLookupRoll:!0,formulas:{},defaultRoll:1,defaultFace:100,renderer:!1,renderAllDice:!1,addToView:!1,renderTime:2e3,colorfulDice:!1,scaler:1,diceColor:"#202020",textColor:"#ffffff",textFont:"Arial",showLeafOnStartup:!0,narrativeSymbolSet:"Genesys",displayAsSymbols:!1,displayAsEmbed:!0,round:"None",initialDisplay:"Roll",icons:Xl(Zm),showRenderNotice:!0,diceModTemplateFolders:{},replaceDiceModInLivePreview:!0,version:null,viewResults:[]};var Sg=on(ug());var mg=require("obsidian"),gg=on(hd()),Jl=class extends gg.FuzzyInputSuggest{getItemText(e){return e}renderNote(e,t){(0,mg.renderMatches)(e,t.item,t.match.matches)}renderTitle(e,t){}};var Mg=on(hd());var Ag=on(xg()),lc=on(dd());var Eg=require("obsidian"),pd=on(_g());var fd=class extends Eg.Component{constructor(){super(...arguments);this.inline=new Map;this.ready=!1}initialize(t){return this.app=t,this.api=(0,pd.getAPI)(),this.dataviewReady().then(()=>this.ready=!0),this}getFieldValueFromActiveFile(t){let i=this.app.workspace.getActiveFile();return!i||!this.canUseDataview||!this.ready?null:this.api.index.pages.get(i.path)?.fields.get(t)??null}get canUseDataview(){return this.app.plugins.getPlugin("dataview")!=null}async dataviewReady(){return new Promise(t=>{this.canUseDataview||t(!1),this.api&&t(!0),this.registerEvent(this.app.metadataCache.on("dataview:api-ready",()=>{this.api=(0,pd.getAPI)(),t(!0)}))})}},ai=new fd;var dA=/(?:\d+[Dd])?#(?:[\p{Letter}\p{Emoji_Presentation}\w/-]+)(?:\|(?:[+-]))?(?:\|(?:[^+-]+))?/u,pA=/(?:\d+[Dd]?)?dv\((?:.+)\)(?:\|(?:[+-]))?(?:\|(?:[^+-]+))?/u,fA=/(?:.*)?(?:\[.*\]\(|\[\[)(?:.+?)#?\^(?:.+?)(?:\)|\]\])\|?(?:.+)?/u,mA=/(?:\d+[Dd])?(?:\[.*\]\(|\[\[)(?:.+)(?:\)|\]\])\|?(?:.+)?/u,gA=/(?:\d+[Dd])?(?:\[.*\]\(|\[\[)(?:.+)(?:\)|\]\])\|line/u,yA=/[\(\^\+\-\*\/\)]/u,xA=/(?:\d+|\b)[Dd](?:%|F|-?\d+|\[\d+(?:[ \t]*[,-][ \t]*\d+)+\]|\b)/u,vA=/(?:=|=!|<|>|<=|>=|=<|=>|-=|=-)(?:\d+(?:[Dd](?:%|F|-?\d+|\[\d+(?:[ \t]*[,-][ \t]*\d+)+\]|\b))?)/u,md=class{constructor(e){this.table=e}parse(e){let t=e.length,i=this.table,n=[],s=[],o=0;for(;o<t;){let a=e[o++];switch(a.value){case"(":s.unshift(a);break;case")":for(e[o]&&e[o].type=="dice"&&/^d/.test(e[o].value)&&(e[o].parenedDice=!0);s.length&&(a=s.shift(),a.value!=="(");)n.push(a);if(a.value!=="(")throw new Error("Mismatched parentheses.");break;default:if(i.hasOwnProperty(a.value)){for(;s.length;){let l=s[0];if(l.value==="(")break;let c=i[a.value],u=c.precedence,h=i[l.value].precedence;if(u>h||u===h&&c.associativity==="right")break;n.push(s.shift())}s.unshift(a)}else n.push(a)}}for(;s.length;){let a=s.shift();if(a.value!=="(")n.push(a);else throw new Error("Mismatched parentheses.")}return n}},gd=class{constructor(){this.lexer=Ag.compile({WS:[{match:/[ \t]+/u},{match:/[{}]+/u}],table:fA,line:gA,section:mA,tag:dA,dataview:pA,condition:vA,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},u:/u/u,narrative:{match:/^(?:\d*(?:[GgYyBbRrPpSsWw]|[AaPpDdCcBbSsFf]|pro|boo|blk|k|sb|diff))(?: ?\d*(?:[GgYyBbRrPpSsWw]|[AaPpDdCcBbSsFf]|pro|boo|blk|k|sb|diff))+$/u,value:e=>{let t=/[AaCcDd]/.test(e);return e.toLowerCase().replace(/pro/g,"y").replace(/diff/g,"p").replace(/(blk|k|sb)/g,"s").replace(/boo/g,"b").replace(/p/g,t?"y":"p").replace(/a/g,"g").replace(/d/g,"p").replace(/c/g,"r").replace(/f/g,"w").replace(/ /g,"").replace(/(\d+)(\w)/g,(i,n,s)=>s.repeat(Number(n)))}},stunt:/1[Dd]S/u,"%":/\d+[Dd]\d+%/u,fudge:{match:/(?:\d*[Dd])?[Dd]?F/u,value:e=>{let{roll:t=this.defaultRoll}=e.match(/(?:(?<roll>\d*)[Dd])?F/).groups;return`${t}dF`}},dice:[{match:xA,value:e=>{let{roll:t=this.defaultRoll,faces:i=this.defaultFace}=e.match(/(?<roll>\d+)?[Dd](?<faces>%|-?\d+|\[\d+(?:[ \t]*[,-][ \t]*\d+)+\])?/).groups;return`${t}d${i}`}},{match:/\d+/u},{match:/\b[A-Za-z][A-Za-z0-9_]+\b/u,value:e=>ai.getFieldValueFromActiveFile(e)??e}],sort:[{match:/s(?:a|d)*/u,value:e=>e=="s"||e=="sa"?"sa":"sd"}],math:yA});this.inline=new Map;this.parser=new md({"+":{precedence:1,associativity:"left"},"-":{precedence:1,associativity:"left"},"*":{precedence:2,associativity:"left"},"/":{precedence:2,associativity:"left"},"^":{precedence:3,associativity:"right"}})}clampInfinite(e){return/i$/.test(e)?"100":e.replace(/^\D+/g,"")}setInlineFields(e){this.inline=e}setDefaults(e,t){this.defaultRoll=e,this.defaultFace=t}setDefaultRoll(e){this.defaultRoll=e}setDefaultFace(e){this.defaultFace=e}parse(e){try{let t=Array.from(this.lexer.reset(e));return this.lexer.reset(),(0,lc.Ok)(this.parser.parse(this.transform(t)))}catch(t){return console.error(t),(0,lc.Err)("Could not parse")}}transform(e){e=e.filter(l=>l.type!="WS");let t=l=>l.type==="+"||l.type==="math"&&l.value==="+",i=l=>l.type==="-"||l.type==="math"&&l.value==="-",n=l=>t(l)||i(l),s=l=>l[l.length-1],o=(l,c)=>l.splice(l.length-1,1,c);e=e.reduce((l,c)=>{if(l.length==0)l.push(c);else{let u=s(l);n(u)&&n(c)?i(u)!=i(c)?i(u)||o(l,c):i(u)&&(u.type=u.type==="math"?u.type:"+",u.value="+"):l.push(c)}return l},[]);let a=[];for(let l of e)if(l.type=="condition"&&a.length>0){let c=a[a.length-1];c.conditions||(c.conditions=[]);let[u,h,d]=l.value.match(/(?<operator>=|=!|<|>|<=|>=|=<|=>|-=|=-)(?<comparer>\d+(?:[Dd](?:%|F|-?\d+|\[\d+(?:[ \t]*[,-][ \t]*\d+)+\]|\b))?)/)??[],p=this.parse(d);p.isOk()&&c.conditions.push({operator:h,comparer:d,lexemes:p.unwrap(),value:l.value})}else a.push(l);return a}},nr=new gd;var Ao=class extends le.PluginSettingTab{constructor(t,i){super(t,i);this.plugin=i;this.#t=!0;this.allFolders=this.app.vault.getAllLoadedFiles().filter(t=>t instanceof le.TFolder);this.folders=[];this.plugin=i}async getFonts(){let t=[];try{le.Platform.isMobile&&window?.Capacitor?.isPluginAvailable("App")?t=await window?.Capacitor?.Plugins.App?.getFonts()?.catch(n=>[]):t=await require("get-fonts").getFonts().catch(n=>[])}catch{}let i=new Set;for(let n of t)i.add(n);return[...i].sort()}async display(){let{containerEl:t}=this;t.empty(),t.addClass("dice-roller-settings"),this.contentEl=this.containerEl.createDiv("dice-roller-settings-content"),this.buildGenerics(this.contentEl.createDiv()),this.buildDisplay(this.contentEl.createEl("details",{cls:"dice-roller-nested-settings"})),this.buildDice(this.contentEl.createEl("details",{cls:"dice-roller-nested-settings"})),this.buildView(this.contentEl.createEl("details",{cls:"dice-roller-nested-settings"})),this.buildRender(this.contentEl.createEl("details",{cls:"dice-roller-nested-settings"})),this.buildFormulaSettings(this.contentEl.createEl("details",{cls:"dice-roller-nested-settings"})),this.buildTables(this.contentEl.createEl("details",{cls:"dice-roller-nested-settings"})),this.buildSections(this.contentEl.createEl("details",{cls:"dice-roller-nested-settings"})),this.buildTags(this.contentEl.createEl("details",{cls:"dice-roller-nested-settings"})),this.buildNarrative(this.contentEl.createEl("details",{cls:"dice-roller-nested-settings"})),this.buildDiceModTemplateFoldersSettings(this.contentEl.createEl("details",{cls:"dice-roller-nested-settings"})),t.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(t){t.empty()}#e(t,i){let n=t.createEl("summary");new le.Setting(n).setHeading().setName(i),(0,le.setIcon)(n.createDiv("collapser").createDiv("handle"),"chevron-right")}buildDisplay(t){t.empty(),this.#e(t,"Dice Display"),new le.Setting(t).setName("Display Formula With Results").setDesc("Both the formula and the results will both be displayed in preview mode.").addToggle(i=>{i.setValue(this.plugin.data.displayResultsInline),i.onChange(async n=>{this.plugin.data.displayResultsInline=n,await this.plugin.saveSettings()})}),new le.Setting(t).setName("Re-roll button position").setDesc("Controls position of the re-roll button").addDropdown(i=>{i.addOption(zt.LEFT,"Left"),i.addOption(zt.RIGHT,"Right"),i.addOption(zt.NONE,"None"),i.setValue(this.plugin.data.position),i.onChange(async n=>{this.plugin.data.position=n,await this.plugin.saveSettings()})}),new le.Setting(t).setName("Display Formula in Parentheses After").setDesc(createFragment(i=>{i.createSpan({text:"For example, "}),i.createEl("code",{text:"`dice: 1d6`"}),i.createSpan({text:" will become "});let n=i.createSpan("dice-roller");n.createSpan({cls:"dice-roller-result",text:"3"}),(0,le.setIcon)(n.createSpan("dice-roller-button"),"dices"),i.createSpan({text:" (1d6). This only affects Dice Rollers."})})).addToggle(i=>{i.setValue(this.plugin.data.displayFormulaAfter),i.onChange(async n=>{this.plugin.data.displayFormulaAfter=n,await this.plugin.saveSettings()})})}buildDice(t){t.empty(),this.#e(t,"Dice Rollers"),new le.Setting(t).setName("Default Face").setDesc("Use this as the number of faces when it is omitted.").addText(i=>{i.setValue(`${this.plugin.data.defaultFace}`),i.inputEl.onblur=async()=>{isNaN(Number(i.inputEl.value))&&new le.Notice("The default face must be a number."),this.plugin.data.defaultFace=Number(i.inputEl.value),nr.setDefaultFace(this.plugin.data.defaultFace),await this.plugin.saveSettings()}}),new le.Setting(t).setName("Round Results").setDesc("Determine the rounding behavior for dice results.").addDropdown(i=>{i.addOptions(Ks).setValue(this.plugin.data.round).onChange(n=>{this.plugin.data.round=n,this.plugin.saveSettings()})}),new le.Setting(t).setName("Auto Roll dice").setDesc("On initial display, should dice be rolled or displayed empty.").addDropdown(i=>{i.addOption("None","Empty").addOption("Roll","Rolled").setValue(this.plugin.data.initialDisplay).onChange(n=>{this.plugin.data.initialDisplay=n,this.plugin.saveSettings()})}),new le.Setting(t).setName("Show Signed Results").setDesc("Positive results will show a '+'. This setting has no effect on negative results.").addToggle(i=>{i.setValue(this.plugin.data.signed).onChange(n=>{this.plugin.data.signed=n,this.plugin.saveSettings()})}),new le.Setting(t).setName("Always Render Dice").setDesc(createFragment(i=>{i.createSpan({text:"Dice rolled in notes will always be rendered. Use the "}),i.createEl("code",{text:"|norender"}),i.createSpan({text:" flag to prevent it."})})).addToggle(i=>{i.setValue(this.plugin.data.renderAllDice).onChange(n=>{this.plugin.data.renderAllDice=n,this.plugin.saveSettings()})}),new le.Setting(t).setName("Log All Rolls to Dice Tray").setDesc(createFragment(i=>{i.createSpan({text:"Dice rolled in notes will be added to the Dice Tray's Results section."})})).addToggle(i=>{i.setValue(this.plugin.data.addToView).onChange(n=>{this.plugin.data.addToView=n,this.plugin.saveSettings()})})}buildTables(t){t.empty(),this.#e(t,"Table Rollers"),new le.Setting(t).setName("Display Lookup Table Roll").setDesc("Lookup table rolls will display the rolled number along with the result.").addToggle(i=>{i.setValue(this.plugin.data.displayLookupRoll),i.onChange(async n=>{this.plugin.data.displayLookupRoll=n,await this.plugin.saveSettings()})})}buildSections(t){t.empty(),this.#e(t,"Section Rollers"),new le.Setting(t).setName("Add Copy Button to Section Results").setDesc("Randomly rolled sections will have a copy-content button to easy add result to clipboard.").addToggle(i=>{i.setValue(this.plugin.data.copyContentButton),i.onChange(async n=>{this.plugin.data.copyContentButton=n,await this.plugin.saveSettings()})}),new le.Setting(t).setName("Display As Embeds").setDesc("Sections returned from Section & Tag Rollers will display as embedded fields.").addToggle(i=>{i.setValue(this.plugin.data.displayAsEmbed),i.onChange(async n=>{this.plugin.data.displayAsEmbed=n,await this.plugin.saveSettings()})})}buildTags(t){t.empty(),this.#e(t,"Tag Rollers"),new le.Setting(t).setName("Always Return Links for Tags").setDesc("Enables random link rolling with the link parameter. Override by specifying a section type.").addToggle(i=>{i.setValue(this.plugin.data.rollLinksForTags),i.onChange(async n=>{this.plugin.data.rollLinksForTags=n,await this.plugin.saveSettings()})})}buildNarrative(t){t.empty(),this.#e(t,"Narrative Rollers"),new le.Setting(t).setName("Symbol Set").setDesc("Select between Genesys or SWRPG symbols.").addDropdown(i=>{i.addOption("Genesys","Genesys"),i.addOption("SWRPG","SWRPG"),i.setValue(this.plugin.data.narrativeSymbolSet),i.onChange(async n=>{this.plugin.data.narrativeSymbolSet=n,Et.setData(this.plugin.getRendererData()),await this.plugin.saveSettings()})}),new le.Setting(t).setName("Display Results as Symbols").setDesc("Toggle between text and symbol results.").addToggle(i=>{i.setValue(this.plugin.data.displayAsSymbols),i.onChange(async n=>{this.plugin.data.displayAsSymbols=n,await this.plugin.saveSettings()})})}buildView(t){t.empty(),this.#e(t,"Dice Tray"),new le.Setting(t).setName("Open Dice Tray on Startup").setDesc("The dice view can always be opened using the command from the command palette.").addToggle(i=>{i.setValue(this.plugin.data.showLeafOnStartup),i.onChange(async n=>{this.plugin.data.showLeafOnStartup=n,await this.plugin.saveSettings()})}),new le.Setting(t).setName("Dice Tray Buttons").setDesc("Add and remove the buttons available in the Dice Tray here, to customize what quick-actions are available to roll."),this.iconsEl=t.createDiv("dice-icons"),this.buildIcons()}buildIcons(){if(this.iconsEl.empty(),!this.plugin.data.icons){this.iconsEl.createSpan({cls:"no-icons",text:"No dice buttons created! Create a button to use this functionality."});return}let i=this.iconsEl.createDiv("existing-buttons has-table").createDiv("buttons-table");for(let u=0;u<this.plugin.data.icons.length;u++){let h=i.createDiv("icons-table-row");this.buildStaticIcon(h,u)}let n=i.createDiv("icons-table-row add-new"),s={text:null,formula:null,shape:"None",id:(0,Sg.generateSlug)()},o=n.createDiv("shape"),a=n.createDiv("formula");new le.TextComponent(a).setPlaceholder("Formula").onChange(u=>{s.formula=u,l.setDisabled(s.text?.length===0||s.formula?.length===0)}),new le.TextComponent(a).setPlaceholder("Display").onChange(u=>{s.text=u,l.setDisabled(s.text?.length===0||s.formula?.length===0)});let l=new le.ExtraButtonComponent(n.createDiv("actions")).setIcon("save").setDisabled(!0).onClick(async()=>{!s.text||!s.formula||(this.plugin.data.icons.push({...s}),this.buildIcons(),await this.plugin.view.buildButtons(),await this.plugin.saveSettings())}),c=new le.DropdownComponent(o);for(let[u,h]of Object.entries(ql))c.addOption(h,h);c.setValue(s.shape).onChange(u=>{s.shape=c.getValue()}),s.shape=c.getValue()}buildStaticIcon(t,i){t.empty(),t.removeClass("add-new");let n=this.plugin.data.icons[i],s=t.createDiv("shape dice-button");Wl.registerIcon(n.id,n.shape,n.text),(0,le.setIcon)(s,n.id),t.createDiv({cls:"formula",text:n.formula});let o=t.createDiv("actions");new le.ExtraButtonComponent(o).setIcon("edit").onClick(()=>{this.buildEditIcon(t,i,n)}),new le.ExtraButtonComponent(o).setIcon("trash").onClick(async()=>{this.plugin.data.icons.splice(i,1),await this.plugin.view.buildButtons(),this.buildIcons()})}buildEditIcon(t,i,n){t.empty(),t.addClass("add-new");let s={text:n.text,formula:n.formula,shape:n.shape,id:n.id},o=t.createDiv("shape"),a=t.createDiv("formula");new le.TextComponent(a).setPlaceholder("Formula").setValue(s.formula).onChange(h=>{s.formula=h,c.setDisabled(s.text.length===0||s.formula.length===0)}),new le.TextComponent(a).setPlaceholder("Display").setValue(s.text).onChange(h=>{s.text=h,c.setDisabled(s.text.length===0||s.formula.length===0)});let l=t.createDiv("actions"),c=new le.ExtraButtonComponent(l).setIcon("checkmark").setDisabled(s.text.length===0||s.formula.length===0).onClick(async()=>{!s.text||!s.formula||(this.plugin.data.icons.splice(i,1,{...s}),await this.plugin.saveSettings(),this.buildStaticIcon(t,i),await this.plugin.view.buildButtons())});new le.ExtraButtonComponent(l).setIcon("cross").onClick(()=>{this.buildStaticIcon(t,i)});let u=new le.DropdownComponent(o);for(let[h,d]of Object.entries(ql))u.addOption(d,d);u.setValue(s.shape).onChange(h=>{s.shape=h})}buildRender(t){t.empty(),this.#e(t,"Graphical Dice"),new le.Setting(t).setName("Display graphics for Dice Tray Rolls").setDesc("Dice rolls from dice view will be displayed on screen.").addToggle(s=>{s.setValue(this.plugin.data.renderer),s.onChange(async o=>{this.plugin.data.renderer=o,await this.plugin.saveSettings()})}),new le.Setting(t).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(s=>{s.inputEl.setAttr("type","number"),s.inputEl.onblur=o=>{Number(s.getValue())<0&&(new le.Notice("Render time cannot be less than 0."),s.setValue("0"))},s.setValue(`${this.plugin.data.renderTime}`),s.onChange(async o=>{o&&Number(o)<0||isNaN(Number(o))||(this.plugin.data.renderTime=Number(o),Et.setData(this.plugin.getRendererData()),await this.plugin.saveSettings())})}).addExtraButton(s=>{s.setIcon("reset").setTooltip("Reset to Default").onClick(async()=>{this.plugin.data.renderTime=Yl.renderTime,await this.plugin.saveSettings(),this.buildRender(t)})}),new le.Setting(t).setName("Use Colorful Dice").setDesc("Rendered dice will be varied colors based on the dice type. This will override manually set dice and text colors.").addToggle(s=>{s.setValue(this.plugin.data.colorfulDice),s.onChange(async o=>{this.plugin.data.colorfulDice=o,Et.setData(this.plugin.getRendererData()),await this.plugin.saveSettings()})}),new le.Setting(t).setName("Adjust Dice Scale").setDesc("Control the size of rendered dice.").addSlider(s=>{s.setLimits(.5,1.5,.1).setValue(this.plugin.data.scaler).onChange(o=>{this.plugin.data.scaler=o,Et.setData(this.plugin.getRendererData()),this.plugin.saveSettings()})}),new le.Setting(t).setName("Font for dice").setDesc("Select the font to use for the dice").addText(async s=>{let o=async()=>{this.plugin.data.textFont=s.getValue(),await this.plugin.saveSettings(),Et.setData(this.plugin.getRendererData())};new Jl(this.app,s,await this.getFonts()).onSelect(({item:l})=>{s.setValue(l),o()}),s.setValue(this.plugin.data.textFont),s.inputEl.onblur=async()=>{o()}}),new le.Setting(t).setName("Dice Base Color").setDesc("Rendered dice will be this color.").controlEl.createEl("input",{type:"color",value:this.plugin.data.diceColor},s=>{s.value=this.plugin.data.diceColor,s.onchange=async({target:o})=>{let a=o.value;this.plugin.data.diceColor=a,Et.setData(this.plugin.getRendererData()),await this.plugin.saveSettings()}}),new le.Setting(t).setName("Dice Text Color").setDesc("Rendered dice will use this color for their numbers.").controlEl.createEl("input",{type:"color",value:this.plugin.data.textColor},s=>{s.value=this.plugin.data.textColor,s.onchange=async({target:o})=>{let a=o.value;a&&(this.plugin.data.textColor=a,Et.setData(this.plugin.getRendererData()),await this.plugin.saveSettings())}}),new le.Setting(t).setName("Show Notice for Results").setDesc(createFragment(s=>{s.createSpan({text:"A notice will be displayed for each rendered dice roll."}),s.createEl("br"),s.createSpan({text:"Changing this setting will not effect any existing dice rollers in opened notes."})})).addToggle(s=>{s.setValue(this.plugin.data.showRenderNotice).onChange(async o=>{this.plugin.data.showRenderNotice=o,await this.plugin.saveSettings()})})}buildFormulaSettings(t){t.empty(),this.#e(t,"Saved Formulas");let i=t.createDiv("dice-roller-setting-additional-container"),n=i.createDiv();new le.Setting(n).setName("Add Formula").setDesc("Add a new formula shortcut.").addButton(a=>a.setTooltip("Add Formula").setButtonText("+").onClick(async()=>{let c=await this.buildFormulaForm(n);c&&(this.plugin.data.formulas[c.alias]=c.formula,this.buildFormulaSettings(t),await this.plugin.saveSettings())}));let s=i.createDiv("additional"),o=this.plugin.data.formulas;for(let[a,l]of Object.entries(o)){let c=new le.Setting(s).setName(a);c.controlEl.createSpan({text:l}),c.addExtraButton(u=>u.setIcon("edit").setTooltip("Edit").onClick(async()=>{let h=await this.buildFormulaForm(n,{alias:a,formula:l});h&&(delete this.plugin.data.formulas[a],this.plugin.data.formulas[h.alias]=h.formula,this.buildFormulaSettings(t),await this.plugin.saveSettings())})).addExtraButton(u=>u.setIcon("trash").setTooltip("Delete").onClick(async()=>{delete this.plugin.data.formulas[a],await this.plugin.saveSettings(),this.buildFormulaSettings(t)}))}Object.values(o).length||s.createSpan({text:"Create a formula to see it here!",cls:"no-formulas"})}async buildFormulaForm(t,i={alias:null,formula:null}){return new Promise(n=>{let s=t.createDiv("add-new-formula"),o=s.createDiv("formula-data");new le.Setting(o).setName("Alias").addText(l=>{l.setValue(i.alias).onChange(c=>i.alias=c)}),new le.Setting(o).setName("Formula").addText(l=>{l.setValue(i.formula).onChange(c=>i.formula=c)});let a=s.createDiv("formula-buttons");new le.Setting(a).addButton(l=>l.setCta().setButtonText("Save").onClick(async()=>{s.detach(),n(i)})).addExtraButton(l=>l.setIcon("cross").setTooltip("Cancel").onClick(()=>{s.detach(),n(null)}))})}#t;buildDiceModTemplateFoldersSettings(t){t.empty(),this.#e(t,"Modify Dice"),new le.Setting(t).setName(createFragment(i=>{i.createSpan({text:"Apply "}),i.createEl("code",{text:"dice-mod"}),i.createSpan({text:" in live-preview"})})).setDesc(createFragment(i=>{i.createSpan({text:"If not enabled "}),i.createEl("code",{text:"dice-mod"}),i.createSpan({text:" will only be applied/replaced in read mode."})})).addToggle(i=>{i.setValue(this.plugin.data.replaceDiceModInLivePreview),i.onChange(async n=>{this.plugin.data.replaceDiceModInLivePreview=n,await this.plugin.saveSettings()})}),new le.Setting(t).setName("Escape Markdown When Modifying").setDesc(createFragment(i=>{i.createSpan({text:"Markdown characters will be escaped when using "}),i.createEl("code",{text:"dice-mod"}),i.createSpan({text:"."})})).addToggle(i=>{i.setValue(this.plugin.data.escapeDiceMod),i.onChange(async n=>{this.plugin.data.escapeDiceMod=n,await this.plugin.saveSettings()})}),new le.Setting(t).setName("Add Formula When Using Modify Dice").setDesc(createFragment(i=>{i.createSpan({text:"Both the formula and the results will both be added to the note when using "}),i.createEl("code",{text:"dice-mod"}),i.createSpan({text:"."})})).addToggle(i=>{i.setValue(this.plugin.data.displayFormulaForMod),i.onChange(async n=>{this.plugin.data.displayFormulaForMod=n,await this.plugin.saveSettings()})}),this.pathsEl=t.createDiv("template-paths dice-roller-setting-additional-container"),this.buildPaths()}buildPaths(){if(this.#t){this.folders=this.allFolders.filter(n=>!(n.path in this.plugin.data.diceModTemplateFolders));let i=Object.entries(this.plugin.data.diceModTemplateFolders);i.sort((n,s)=>n[0].localeCompare(s[0])),this.plugin.data.diceModTemplateFolders=Object.fromEntries(i),this.#t=!1}this.pathsEl.empty(),new le.Setting(this.pathsEl).setName("Template Folders").setDesc(createFragment(i=>{i.createSpan({text:"Define folders where "}),i.createEl("code",{text:"dice-mod"}),i.createSpan({text:" is not applied/replaced and can be used in templates."})})).setHeading();let t=this.pathsEl.createDiv("additional");for(let i in this.plugin.data.diceModTemplateFolders)this.buildStaticPath(t.createDiv(),i);this.buildEditPath(t.createDiv())}buildStaticPath(t,i){t.empty();let n=this.plugin.data.diceModTemplateFolders[i],s=new le.Setting(t).setName(i);s.setDesc(createFragment(o=>{let a=o.createDiv({attr:{style:"display: flex;align-items: center;gap: 0.5rem;"}});n?((0,le.setIcon)(a,"folder-tree"),a.createSpan({text:"Includes Subfolders"})):((0,le.setIcon)(a,"folder-closed"),a.createSpan({text:"Root Only"}))})),s.addExtraButton(o=>o.setIcon("edit").onClick(()=>{this.buildEditPath(t,i)})).addExtraButton(o=>o.setIcon("trash").onClick(async()=>{delete this.plugin.data.diceModTemplateFolders[i],await this.plugin.saveSettings(),this.#t=!0,this.buildPaths()}))}buildEditPath(t,i){t.empty();let n={folder:i,useSubfolders:this.plugin.data.diceModTemplateFolders[i]??!0},s=t.createDiv("template-edit setting-item"),o=s.createDiv("template-input"),a=o.createDiv("folder-input"),l=new le.ExtraButtonComponent(o).onClick(()=>{n.useSubfolders=!n.useSubfolders,n.useSubfolders?l.setIcon("folder-tree").setTooltip("Including Subfolders"):l.setIcon("folder-closed").setTooltip("Not Including Subfolders")});this.plugin.data.diceModTemplateFolders[i]??!0?l.setIcon("folder-tree").setTooltip("Including Subfolders"):l.setIcon("folder-closed").setTooltip("Not Including Subfolders");let c=s.createDiv("actions");i||new le.ExtraButtonComponent(c).extraSettingsEl.setAttr("style","visibility: hidden;");let u=new le.ExtraButtonComponent(c).setIcon(i?"checkmark":"save").setDisabled(!i).onClick(async()=>{this.plugin.data.diceModTemplateFolders[n.folder]=n.useSubfolders,await this.plugin.saveSettings(),n.folder!=i?(this.#t=!0,this.buildPaths()):this.buildStaticPath(t,i)});i&&new le.ExtraButtonComponent(c).setIcon("cross").onClick(()=>this.buildStaticPath(t,i)),this.buildPathInput(a,u,h=>{n.folder=h},i)}buildPathInput(t,i,n,s="Folder"){let o=c=>{if(!c||!c.length||c in this.plugin.data.diceModTemplateFolders)return i.setDisabled(!0),!1;i.setDisabled(!1),n((0,le.normalizePath)(c))},a=new le.TextComponent(t).setPlaceholder(s).onChange(c=>{o(c)}),l=new Mg.FolderInputSuggest(this.app,a,this.folders);l.onSelect(async c=>{l.close(),l.setValue(c.item.path),o(c.item.path)})}};var pt=require("obsidian");var Bg=on(Dg());var o3=on(dd());var en=require("obsidian");var Tg=/(?:(?<roll>\d+)[Dd])?#(?<query>[\p{Letter}\p{Emoji_Presentation}\w/-]+)(?:\|(?<collapse>[\+-]))?(?:\|(?<types>[^\+-]+))?/u,Cg=/(?:(?<roll>\d+)[Dd]?)?dv\((?<query>.+)\)(?:\|(?<collapse>[\+-]))?(?:\|(?<types>[^\+-]+))?/u,Rg=/(?<diceRoll>.*)?(?:\[.*\]\(|\[\[)(?<link>.+?)#?\^(?<block>.+?)(?:\]\]|\))(?:\|(?<header>.+))?/,uc=/(?:(?<roll>\d+)[Dd])?(?:\[.*\]\(|\[\[)(?<link>.+)(?:\]\]|\))\|?(?<types>.+)?/;var yd=class{constructor(){this.result="";this.combinedTooltip=""}},hc=class r extends yo{constructor(t,i,n,s,o,a=t.position,l){super(t,i,n,s,o,a);this.lookup=l;this.isLookup=!1;this.combinedTooltip="";this.prettyTooltip="";this.getPath()}getPath(){let{groups:t}=this.lexeme.value.match(Rg)??{},{diceRoll:i="1",link:n,block:s,header:o}=t??{};if(!n||!s)throw new Error("Could not parse link.");let a=i.match(/(\d*?)[Dd]$/);if(a){let[,l="1"]=a;this.rollsFormula=l}else this.rollsFormula=i;this.rolls=1,this.path=decodeURIComponent(n.replace(/(\[|\]|\(|\))/g,"")),this.block=s.replace(/(\^|#)/g,"").trim().toLowerCase(),this.header=o}getTooltip(){return this.prettyTooltip}async getReplacer(){return this.result}getResultText(){let t=[this.result];return this.data.displayResultsInline&&t.unshift(this.inlineText),t.join("")}async build(){this.resultEl.empty();let t=[this.result];this.data.displayResultsInline&&t.unshift(this.inlineText);let i=this.resultEl.createSpan("embedded-table-result");en.MarkdownRenderer.render(this.app,this.getResultText(),i,this.source,new en.Component)}prettify(t){let i=/(.*?)(\(|\)|;|\|\|)(.*)/,n=" ",s=0,o="",a=t,l;for(;l=a.match(i);){let[,c,u,h]=l;o+=c,u==")"?(s--,o+=`
`,o+=n.repeat(s),o+=")"):(u=="("?(s++,o+="("):u==";"?o+=",":u=="||"&&(o+="|"),o+=`
`,o+=n.repeat(s)),a=h}return o+=a,o}async getSubResult(t){let i=new yd;typeof t=="number"?i.result=t.toString():i.result=t;let n=[];if(typeof t=="string"){let s=/(?:\`dice:)(.*?)(?:\`)/g,o=t.matchAll(s);for(let a of o){let l=a[1].trim(),c=await Tt.getRoller(l,this.source);if(c==null)continue;c.addContexts(...this.components),await c.roll();let u=await this.getSubResult(c.result),h;if(u.result instanceof en.TFile?h=u.result.basename:h=u.result,i.result=i.result.replace(a[0],h),c instanceof r)n.push(c.combinedTooltip);else{let[d,p]=c.getTooltip().split(`
`);n.push(d+" --> "+p)}}}return i.combinedTooltip=n.join(";"),i}async getResult(){let t=[],i=[],n=this.original;if(this.rollsFormula)try{let s=await Tt.getRoller(this.rollsFormula,this.source);if(s){if(!(s instanceof Wt))return this.prettyTooltip="TableRoller only supports dice rolls to select multiple elements.",new en.Notice(this.prettyTooltip),"ERROR";let o=s;o.addContexts(...this.components),await o.roll(),this.rolls=o.result,o.isStatic||(n=n.replace(this.rollsFormula,`${this.rollsFormula.trim()} --> ${o.getDisplayText()} > `))}}catch{return this.prettyTooltip=`TableRoller: '${this.rollsFormula}' is not a valid dice roll.`,new en.Notice(this.prettyTooltip),"ERROR"}for(let s=0;s<this.rolls;s++){let o="",a,l="";if(this.isLookup){let c=await this.lookupRoller.roll(),u=this.lookupRanges.find(([h])=>h[1]===void 0&&c===h[0]||c>=h[0]&&h[1]>=c);u&&(o=this.lookupRoller.original.trim()+" --> "+`${this.lookupRoller.getDisplayText()}${this.header?" | "+this.header:""}`.trim(),l=u[1])}else{let c=[...this.options],u=this.getRandomBetween(0,c.length-1);o=c.length+" rows --> [row "+(u+1)+"]",l=c[u]}a=await this.getSubResult(l),t.push(a.result),a.combinedTooltip&&(o+=" > ("+a.combinedTooltip+")"),i.push(o)}return i.length==0?this.combinedTooltip=n:i.length==1?this.combinedTooltip=n+" "+i.join(""):this.combinedTooltip=n+" ==> ("+i.join(" ||")+")",this.prettyTooltip=this.prettify(this.combinedTooltip),t.join("||")}async roll(){return new Promise(async t=>{this.loaded?(this.result=await this.getResult(),this.render(),this.trigger("new-result"),t(this.result)):(this.once("loaded",async()=>{this.result=await this.getResult(),this.render(),this.trigger("new-result"),t(this.result)}),this.load())})}async getOptions(t,i){if(this.cache=t,!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 n=this.cache.sections?.find(a=>a.position==this.cache.blocks[this.block].position),s=this.cache.blocks[this.block].position,o=i.slice(s.start.offset,s.end.offset);if(await this.checkForDirtiness(o))if(this.content=o,n&&n.type==="list")this.options=this.content.split(`
`);else{let a=bA(this.content);if(/dice:\s*([\s\S]+)\s*?/.test(Array.from(a.columns.keys())[0])||this.lookup){let l=this.lookup??Array.from(a.columns.keys())[0].split(":").pop().replace(/\`/g,""),c=await Tt.getRoller(l.replace(/{ESCAPED_PIPE}/g,"\\|"),this.source);c&&(c.addContexts(...this.components),c instanceof Wt&&(this.lookupRoller=c,this.lookupRanges=a.rows.map(u=>{let[h,d]=u.replace(/\\\|/g,"{ESCAPED_PIPE}").split("|").map(y=>y.replace(/{ESCAPED_PIPE}/g,"\\|")).map(y=>y.trim()),[,p,m]=h.match(/(\d+)(?:[^\d]+?(\d+))?/)??[];if(!(!p&&!m))return[[Number(p),m?Number(m):void 0],d]}),this.isLookup=!0))}if(this.header==="xy"&&!a.columns.has("xy")){this.options=[];for(let l of Array.from(a.columns.values()).slice(1))this.options.push(...l)}else if(this.header&&a.columns.has(this.header))this.options=a.columns.get(this.header);else{if(this.header)throw new Error(`Header ${this.header} was not found in table ${this.path} > ${this.block}.`);this.options=a.rows}}}},wA=/^\|?([\s\S]+?)\|?$/,Fg=/\|/g;function bA(r){let e=r.split(`
`),i=e.map(o=>(o.trim().match(wA)??[,o.trim()])[1])[0].replace("\\|","{ESCAPED_PIPE}").split(Fg),n=[],s=[];for(let o in i){let a=i[o];a.trim().length||(a=o),s.push([a.trim(),[]])}for(let o of e.slice(2)){let a=o.trim().replace(/\\\|/g,"{ESCAPED_PIPE}").split(Fg).map(l=>l.replace(/{ESCAPED_PIPE}/g,"\\|")).map(l=>l.trim()).filter(l=>l.length);n.push(a.join(" | "));for(let l in a){let c=a[l].trim();!c.length||!s[l]||s[l][1].push(c)}}return{columns:new Map(s),rows:n}}var Rn=require("obsidian");function _A(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789",i=t.length;for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*i));return e}function EA(r){return`dice-${_A(4)}`}var sr=class extends tr{async getReplacer(){let e=await this.getBlockId();return e?`![[${this.path}#^${e}]]`:""}getTooltip(){return`${this.original}
${this.path}`}async build(){if(this.resultEl.empty(),this.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.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:this.getEmbedClass()});if(!this.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(Rn.MarkdownRenderer.render(this.app,this.displayFromCache(e),t.createDiv(),this.source,new Rn.Component),this.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",n=>{n.stopPropagation(),navigator.clipboard.writeText(this.displayFromCache(e).trim()).then(async()=>{new Rn.Notice("Result copied to clipboard.")})}),(0,Rn.setIcon)(i,"copy")}}}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(`
`)}transformResultsToString(){return this.displayFromCache(...this.results)}async getBlockId(){this.result||await this.roll();let e=this.cache.blocks??{},t=Object.entries(e).find(([i,n])=>Lg(n.position,this.result.position));if(!t){let i=`${EA(4)}`,n=`${this.content.slice(0,this.result.position.end.offset+1)}^${i}${this.content.slice(this.result.position.end.offset)}`;return this.app.vault.modify(this.file,n),i}return t[0]}getPath(){let{groups:e}=this.lexeme.value.match(uc)??{},{roll:t=1,link:i,types:n}=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=n?.split(","),this.levels=n?.split(",").map(s=>/heading\-\d+/.test(s)?s.split("-").pop():null).filter(s=>s),this.types=n?.split(",").map(s=>/heading\-\d+/.test(s)?s.split("-").shift():s)}async getOptions(e,t){if(this.cache=e,!this.cache||!this.cache.sections)throw new Error("Could not read file cache.");let i=t;await this.checkForDirtiness(i)&&(this.content=i,this.content=t,this.options=this.cache.sections.filter(({type:n,position:s})=>this.types?n=="heading"&&this.types.includes(n)&&this.levels.length?(this.cache.headings??[]).filter(({level:a})=>this.levels.includes(`${a}`)).some(({position:a})=>Lg(a,s)):this.types.includes(n):!["yaml","thematicBreak"].includes(n)),this.types&&this.types.includes("listItem")&&this.options.push(...this.cache.listItems))}async roll(){return new Promise((e,t)=>{if(!this.loaded)this.once("loaded",()=>{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let n=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(n),1),n}).filter(n=>n),this.render(),this.trigger("new-result"),this.result=this.results[0],e(this.results[0])}),this.load();else{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let n=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(n),1),n}).filter(n=>n),this.render(),this.trigger("new-result"),this.result=this.results[0],e(this.results[0])}})}},Lg=(r,e)=>r.start.col==e.start.col&&r.start.line==e.start.line&&r.start.offset==e.start.offset;var Zn=require("obsidian");var dc=class extends Qs{constructor(t,i,n,s,o,a=t.position){super(t,i,[n],a);this.data=t;this.original=i;this.lexeme=n;this.source=s;this.app=o;this.isLink=!1;this.loaded=!1}async getReplacer(){return this.isLink?`[[${this.result.file.basename}]]`:await this.result.getReplacer()}guardDataview(){if(!ai.canUseDataview)throw new Zn.Notice("A query can only be rolled with the Dataview plugin enabled."),new Error("A query can only be rolled with the Dataview plugin enabled.")}initialize(){this.guardDataview();let{roll:t=1,query:i,types:n}=this.lexeme.value.match(this.regex).groups;this.base=i,this.rolls=Number(t),this.types=n,this.types&&(this.isLink=this.types.includes("link"),this.types=this.types.replace("link","")),!this.isLink&&this.data.displayAsEmbed&&this.containerEl.addClasses(["has-embed","markdown-embed"]),this.getFiles()}get typeText(){return this.types?.length?`|${this.types}`:""}async getFiles(){if(!ai.canUseDataview){new Zn.Notice("Dice Roller: Dataview must be installed and enabled to use query rollers.");return}await ai.dataviewReady();let t=await ai.api.query(this.query);if(!t.successful)throw new Error(`No files found with that query. Is the query correct?
`+this.query);let i=new Set(t.value.values.reduce((o,a)=>(a.type=="file"&&o.push(a.path),o),[]));if(i&&i.delete(this.source),!i||!i.size)throw new Error(`No files found with that query. Is the query correct?
`+this.query);let n=Array.from(i).map(o=>`[[${o}]]${this.typeText}`);this.results=[];let s=[];for(let o of n)s.push(new Promise(async a=>{let l=new sr(this.data,o,{...this.lexeme,value:o,type:"section"},this.source,this.app,this.position,!1);this.results.push(l),l.addContexts(...this.components),a()}));await Promise.all(s),this.loaded=!0,this.trigger("loaded")}async build(){this.resultEl.empty(),this.data.displayResultsInline&&this.resultEl.createSpan({text:this.inlineText});let t=[],i=new Map(this.results.map((n,s)=>[s,n]));for(let n=0;n<this.rolls;n++){if(!i.size)continue;let s=this.getRandomBetween(0,i.size-1),o=i.get(s);await o.roll(),t.push(o),i.delete(s)}if(this.isLink){let n=t.reduce((s,o,a,l)=>(s.push(`[[${o.file.basename}]]`),l.length>1&&a!=l.length-1&&s.push(","),s),[]);Zn.MarkdownRenderer.render(this.app,n.join(" "),this.resultEl,this.app.workspace.getActiveFile()?.path,new Zn.Component)}else for(let n of t){let s=this.resultEl.createDiv();s.createEl("h5",{cls:"dice-file-name",text:n.file.basename}),s.appendChild(n.containerEl)}}async roll(){return new Promise((t,i)=>{this.loaded?(this.result=this.results[0],this.render(),this.trigger("new-result"),t(this.result)):(this.on("loaded",()=>{this.result=this.results[0],this.render(),this.trigger("new-result"),t(this.result)}),this.load())})}getTooltip(){return this.original}},pc=class extends dc{constructor(t,i,n,s,o,a=t.position){super(t,i,n,s,o,a);this.data=t;this.original=i;this.lexeme=n;this.source=s;this.regex=Cg;this.initialize()}get query(){return this.base}},fc=class extends dc{constructor(t,i,n,s,o,a=t.position){super(t,i,n,s,o,a);this.data=t;this.original=i;this.lexeme=n;this.source=s;this.regex=Tg;this.initialize()}get query(){return`list from #${this.base}`}};var Fn=require("obsidian");var mc=class extends tr{async getReplacer(){return this.result}getTooltip(){return`${this.original}
${this.path}`}async build(){if(this.resultEl.empty(),this.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.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:this.getEmbedClass()});if(!e){t.createDiv({cls:"dice-no-results",text:"No results."});continue}if(Fn.MarkdownRenderer.render(this.app,e,t.createDiv(),this.source,new Fn.Component),this.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",n=>{n.stopPropagation(),navigator.clipboard.writeText(e).then(async()=>{new Fn.Notice("Result copied to clipboard.")})}),(0,Fn.setIcon)(i,"copy")}}}transformResultsToString(){return this.results.join(`
`)}getPath(){let{groups:e}=this.lexeme.value.match(uc)??{},{roll:t=1,link:i,types:n}=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=n?.split(",")}async getOptions(e,t){if(await this.checkForDirtiness(t)){if(this.content=t,!this.content)throw new Error("Could not read file cache.");this.options=this.content.trim().split(`
`).map(i=>i.trim()).filter(i=>i&&i.length)}}async roll(){return new Promise((e,t)=>{if(!this.loaded)this.once("loaded",()=>{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let n=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(n),1),n}).filter(n=>n),this.render(),this.trigger("new-result"),e(this.results[0])}),this.load();else{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let n=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(n),1),n}).filter(n=>n),this.render(),this.trigger("new-result"),e(this.results[0])}})}};var tn=class extends gt{canRender(){return!0}},xd=class extends tn{toNarrativeResult(){let e={success:0,advantage:0,triumph:0,despair:0,light:0,dark:0};for(let t of this.resultArray)t===6&&(e.success+=1),t===5&&(e.advantage+=1,e.success+=1),t===4&&(e.advantage+=1),t===3&&(e.advantage+=2);return e}getType(){return Ue.BOOST}canRender(){return!0}constructor(e){super(`${e}d6`)}},vd=class extends tn{toNarrativeResult(){let e={success:0,advantage:0,triumph:0,despair:0,light:0,dark:0};for(let t of this.resultArray)t===6&&(e.advantage-=1),t===5&&(e.advantage-=1),t===4&&(e.success-=1),t===3&&(e.success-=1);return e}getType(){return Ue.SETBACK}canRender(){return!0}constructor(e){super(`${e}d6`)}},wd=class extends tn{toNarrativeResult(){let e={success:0,advantage:0,triumph:0,despair:0,light:0,dark:0};for(let t of this.resultArray)t===8&&(e.advantage+=2),t===7&&(e.advantage+=1,e.success+=1),t===6&&(e.advantage+=1),t===5&&(e.advantage+=1),t===4&&(e.success+=2),t===3&&(e.success+=1),t===2&&(e.success+=1);return e}getType(){return Ue.ABILITY}canRender(){return!0}constructor(e){super(`${e}d8`)}},bd=class extends tn{toNarrativeResult(){let e={success:0,advantage:0,triumph:0,despair:0,light:0,dark:0};for(let t of this.resultArray)t===8&&(e.advantage-=1,e.success-=1),t===7&&(e.advantage-=2),t===6&&(e.advantage-=1),t===5&&(e.advantage-=1),t===4&&(e.advantage-=1),t===3&&(e.success-=2),t===2&&(e.success-=1);return e}getType(){return Ue.DIFFICULTY}canRender(){return!0}constructor(e){super(`${e}d8`)}},_d=class extends tn{toNarrativeResult(){let e={success:0,advantage:0,triumph:0,despair:0,light:0,dark:0};for(let t of this.resultArray)t===12&&(e.triumph+=1,e.success+=1),t===11&&(e.advantage+=2),t===10&&(e.advantage+=2),t===9&&(e.advantage+=1,e.success+=1),t===8&&(e.advantage+=1,e.success+=1),t===7&&(e.advantage+=1,e.success+=1),t===6&&(e.advantage+=1),t===5&&(e.success+=2),t===4&&(e.success+=2),t===3&&(e.success+=1),t===2&&(e.success+=1);return e}getType(){return Ue.PROFICIENCY}canRender(){return!0}constructor(e){super(`${e}d12`)}},Ed=class extends tn{toNarrativeResult(){let e={success:0,advantage:0,triumph:0,despair:0,light:0,dark:0};for(let t of this.resultArray)t===12&&(e.despair+=1,e.success-=1),t===11&&(e.advantage-=2),t===10&&(e.advantage-=2),t===9&&(e.advantage-=1,e.success-=1),t===8&&(e.advantage-=1,e.success-=1),t===7&&(e.advantage-=1),t===6&&(e.advantage-=1),t===5&&(e.success-=2),t===4&&(e.success-=2),t===3&&(e.success-=1),t===2&&(e.success-=1);return e}getType(){return Ue.CHALLENGE}canRender(){return!0}constructor(e){super(`${e}d12`)}},Ad=class extends tn{toNarrativeResult(){let e={success:0,advantage:0,triumph:0,despair:0,light:0,dark:0};for(let t of this.resultArray)t===12&&(e.light+=2),t===11&&(e.light+=2),t===10&&(e.light+=2),t===9&&(e.light+=1),t===8&&(e.light+=1),t===7&&(e.dark+=2),t===6&&(e.dark+=1),t===5&&(e.dark+=1),t===4&&(e.dark+=1),t===3&&(e.dark+=1),t===2&&(e.dark+=1),t===1&&(e.dark+=1);return e}getType(){return Ue.FORCE}canRender(){return!0}constructor(e){super(`${e}d12`)}},AA=["g","y","b","r","p","s","w"],gc=class extends er{constructor(t,i,n,s,o=t.position){super(t,i,n,o);this.data=t;this.original=i;this.lexemes=n;this.app=s;this.children=[]}getTooltip(){let t={success:0,failure:0,advantage:0,threat:0,triumph:0,despair:0,light:0,dark:0};for(let i of this.children){let n=i.toNarrativeResult();n.success>0?t.success+=n.success:t.failure+=n.success,n.advantage>0?t.advantage+=n.advantage:t.threat+=n.advantage,t.triumph+=n.triumph,t.despair+=n.despair,t.light+=n.light,t.dark+=n.dark}return`**Totals**
Successes: ${t.success}
Failures: ${t.failure}
Advantages: ${t.advantage}
Threats: ${t.threat}
Triumphs: ${t.triumph}
Despairs: ${t.despair}
${t.light>0?`Light Side: ${t.light}`:""}
${t.dark>0?`Dark Side: ${t.dark}`:""}`}formatSymbol(t,i){return`<span style="font-family: ${i}; font-weight: normal;">${t}</span>`}getResultText(){let t=[];return this.data.narrativeSymbolSet,this.data.displayAsSymbols?(this.result.success===0?t.push("Wash"):this.result.success>0?t.push(`${this.result.success} `+this.formatSymbol("s",this.data.narrativeSymbolSet)):this.result.success<0&&t.push(`${this.result.success} `+this.formatSymbol("f",this.data.narrativeSymbolSet)),this.result.advantage>0?t.push(`${this.result.advantage} `+this.formatSymbol("a",this.data.narrativeSymbolSet)):this.result.advantage<0&&t.push(`${Math.abs(this.result.advantage)} `+this.formatSymbol("t",this.data.narrativeSymbolSet)),this.result.triumph>0?t.push(`${this.result.triumph} `+this.formatSymbol("x",this.data.narrativeSymbolSet)):this.result.despair>0&&t.push(`${Math.abs(this.result.despair)} `+this.formatSymbol("y",this.data.narrativeSymbolSet)),this.result.light>0&&t.push(`${this.result.light} `+this.formatSymbol("z",this.data.narrativeSymbolSet)),this.result.dark>0&&t.push(`${this.result.dark} `+this.formatSymbol("Z",this.data.narrativeSymbolSet)),t.join(", ")):(this.result.success===0?t.push("Wash"):this.result.success>0?t.push(`${this.result.success} success`):this.result.success<0&&t.push(`${Math.abs(this.result.success)} failure`),this.result.advantage>0?t.push(`${this.result.advantage} advantage`):this.result.advantage<0&&t.push(`${Math.abs(this.result.advantage)} threat`),this.result.triumph>0?t.push(`${this.result.triumph} triumph`):this.result.despair>0&&t.push(`${Math.abs(this.result.despair)} despair`),this.result.light>0&&t.push(`${this.result.light} light side`),this.result.dark>0&&t.push(`${this.result.dark} dark side`),t.join(", "))}onload(){let t=new Map;for(let i of this.lexemes)for(let n of i.value){let s=n;AA.includes(s)&&t.set(s,(t.get(s)??0)+1)}for(let[i,n]of t){let s;switch(i){case"g":{s=new wd(n);break}case"y":{s=new _d(n);break}case"b":{s=new xd(n);break}case"r":{s=new Ed(n);break}case"p":{s=new bd(n);break}case"s":{s=new vd(n);break}case"w":{s=new Ad(n);break}}this.children.push(s)}super.onload()}getReplacer(){throw new Error("Method not implemented.")}async roll(t){if(t||this.shouldRender&&this.hasRunOnce)await this.renderChildren();else return this.rollSync();return this.hasRunOnce=!0,this.calculate(),this.trigger("new-result"),this.app.workspace.trigger("dice-roller:new-result",this),this.render(),this.result}rollSync(){for(let t of this.children)t.rollSync();return this.hasRunOnce=!0,this.calculate(),this.trigger("new-result"),this.app.workspace.trigger("dice-roller:new-result",this),this.render(),this.result}calculate(){this.result=this.children.reduce((t,i)=>(t.success+=i.toNarrativeResult().success,t.advantage+=i.toNarrativeResult().advantage,t.triumph+=i.toNarrativeResult().triumph,t.despair+=i.toNarrativeResult().despair,t.light+=i.toNarrativeResult().light,t.dark+=i.toNarrativeResult().dark,t),{success:0,advantage:0,triumph:0,despair:0,light:0,dark:0})}async build(){this.resultEl.empty(),this.resultEl.addClass("dice-roller-genesys"),this.resultEl.innerHTML=this.getResultText()}};var Sd=class{constructor(){this.sources=new Map}initialize(e,t){this.data=e,this.app=t}#e(e){return e.some(({type:t})=>t==="table")?"table":e.some(({type:t})=>t==="section")?"section":e.some(({type:t})=>t==="dataview")?"dataview":e.some(({type:t})=>t==="tag")?"tag":e.some(({type:t})=>t==="link")?"link":e.some(({type:t})=>t==="line")?"line":e.some(({type:t})=>t==="narrative")?"narrative":"dice"}getParametersForRoller(e,t){e=e.replace(/\\\|/g,"|");let i=t?.position??zt.LEFT,n=t?.shouldRender??this.data.renderAllDice,s=t?.showFormula??this.data.displayResultsInline,o=t?.showParens??this.data.displayFormulaAfter,a=t?.expectedValue??this.data.initialDisplay,l=t?.text??"",c=t?.round??this.data.round,u=t?.signed??this.data.signed,h=t?.lookup,d=/\|text\((.*)\)/;if(e.includes("|nodice")&&(i=zt.NONE),e.includes("|render")&&(n=!0),e.includes("|norender")&&(n=!1),e.includes("|form")&&(s=!0),e.includes("|noform")&&(s=!1),e.includes("|avg")&&(a="Average"),e.includes("|none")&&(a="None"),e.includes("|text(")){let[,p]=e.match(d)??[null,""];l=p}return e.includes("|paren")&&(o=!0),e.includes("|noparen")&&(o=!1),e.includes("|round")&&(c="Normal"),e.includes("|noround")&&(c="None"),e.includes("|ceil")&&(c="Up"),e.includes("|floor")&&(c="Down"),e.includes("|signed")&&(u=!0),e.includes("|lookup=")&&([,h]=e.match(/\|lookup=(.+?)(?:\||$)/)??[]),e=(0,Bg.decode)(e.replace(/\|(no)?(dice|render|form|paren|avg|none|round|floor|ceil|signed)/g,"").replace(/\|lookup=.+?(\||$)/,"").replace(d,"")),e in this.data.formulas&&(e=this.data.formulas[e]),{content:e,position:i,showParens:o,showFormula:s,expectedValue:a,shouldRender:n,text:l,round:c,signed:u,lookup:h}}registerSource(e,t){this.sources.set(e,t)}getRoller(e,t="",i=this.getRollerOptions(this.data)){let{content:n,position:s,showParens:o,showFormula:a,expectedValue:l,round:c,shouldRender:u,text:h,signed:d,lookup:p}=this.getParametersForRoller(e,i),m=nr.parse(n);if(m.isErr())return console.error(m.unwrapErr()),null;let y=m.unwrap();switch(this.#e(y)){case"narrative":return new gc(this.data,n,y,this.app,s);case"dice":{let g=new Wt(this.data,n,y,this.app,s,h,l,o,c,d);return g.showFormula=a,g.shouldRender=u,g.showRenderNotice=this.data.showRenderNotice,g.setSource(t),g}case"table":return new hc(this.data,n,y[0],t,this.app,s,p);case"section":return new sr(this.data,n,y[0],t,this.app,s);case"dataview":{if(!ai.canUseDataview)throw new Error("Tags are only supported with the Dataview plugin installed.");return new pc(this.data,n,y[0],t,this.app,s)}case"tag":{if(!ai.canUseDataview)throw new Error("Tags are only supported with the Dataview plugin installed.");return new fc(this.data,n,y[0],t,this.app,s)}case"line":return new mc(this.data,n,y[0],t,this.app,s)}}getRollerString(e,t){if(!t)return e;let i=this.sources.get(t)??this.getRollerOptions(this.data);if("position"in i&&(e+=i.position!==zt.NONE?"":"|nodice"),"shouldRender"in i&&(e+=i.shouldRender?"|render":"|norender"),"showFormula"in i&&(e+=i.showFormula?"|form":"|noform"),"expectedValue"in i&&(i.expectedValue=="Average"&&(e+="|avg"),i.expectedValue=="None"&&(e+="|none")),"text"in i&&i.text&&(e+="|text("+i.text+")"),"showParens"in i&&(e+=i.showParens?"|paren":"|noparen"),"round"in i)switch(i.round){case"Down":{e+="|floor";break}case"Up":{e+="|ceil";break}case"Normal":{e+="|round";break}case"None":e+="|noround"}return i.signed&&(e+="|signed"),e}async getArrayRoller(e,t=1){let i=new Hl(this.data,e,t);return await i.roll(),i}async parseDice(e,t=""){let i=await this.getRoller(e,t);return{result:await i?.roll(),roller:i}}getRollerOptions(e){return{position:e.position,shouldRender:e.renderAllDice,showFormula:e.displayResultsInline,showParens:e.displayFormulaAfter,expectedValue:e.initialDisplay,round:e.round,text:null,signed:e.signed}}},Tt=new Sd;var Pg="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Ig=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=Pg[t[r]&63];return e};function Ln(){}function SA(r,e){for(let t in e)r[t]=e[t];return r}function Md(r){return r()}function yc(){return Object.create(null)}function Vt(r){r.forEach(Md)}function Mo(r){return typeof r=="function"}function xc(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function Ng(r){return Object.keys(r).length===0}function Dd(r,e,t,i){if(r){let n=kg(r,e,t,i);return r[0](n)}}function kg(r,e,t,i){return r[1]&&i?SA(t.ctx.slice(),r[1](i(e))):t.ctx}function Td(r,e,t,i){if(r[2]&&i){let n=r[2](i(t));if(e.dirty===void 0)return n;if(typeof n=="object"){let s=[],o=Math.max(e.dirty.length,n.length);for(let a=0;a<o;a+=1)s[a]=e.dirty[a]|n[a];return s}return e.dirty|n}return e.dirty}function Cd(r,e,t,i,n,s){if(n){let o=kg(e,t,i,s);r.p(o,n)}}function Rd(r){if(r.ctx.length>32){let e=[],t=r.ctx.length/32;for(let i=0;i<t;i++)e[i]=-1;return e}return-1}function rr(r){return r&&Mo(r.destroy)?r.destroy:Ln}var Fd=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;var vc=class r{_listeners="WeakMap"in Fd?new WeakMap:void 0;_observer=void 0;options;constructor(e){this.options=e}observe(e,t){return this._listeners.set(e,t),this._getObserver().observe(e,this.options),()=>{this._listeners.delete(e),this._observer.unobserve(e)}}_getObserver(){return this._observer??(this._observer=new ResizeObserver(e=>{for(let t of e)r.entries.set(t.target,t),this._listeners.get(t.target)?.(t)}))}};vc.entries="WeakMap"in Fd?new WeakMap:void 0;var Og=!1;function zg(){Og=!0}function Vg(){Og=!1}function Ze(r,e){r.appendChild(e)}function wc(r,e,t){let i=Ug(r);if(!i.getElementById(e)){let n=ut("style");n.id=e,n.textContent=t,TA(i,n)}}function Ug(r){if(!r)return document;let e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function TA(r,e){return Ze(r.head||r,e),e.sheet}function nn(r,e,t){r.insertBefore(e,t||null)}function yi(r){r.parentNode&&r.parentNode.removeChild(r)}function ut(r){return document.createElement(r)}function Jn(r){return document.createTextNode(r)}function sn(){return Jn(" ")}function Hg(){return Jn("")}function Kn(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function yt(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function Gg(r){return Array.from(r.childNodes)}function Do(r,e){e=""+e,r.data!==e&&(r.data=e)}function Ld(r,e,t){r.classList.toggle(e,!!t)}function qg(r){let e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}var or;function rn(r){or=r}var Qn=[];var $g=[],lr=[],jg=[],PA=Promise.resolve(),Pd=!1;function Xg(){Pd||(Pd=!0,PA.then(bc))}function To(r){lr.push(r)}var Bd=new Set,ar=0;function bc(){if(ar!==0)return;let r=or;do{try{for(;ar<Qn.length;){let e=Qn[ar];ar++,rn(e),IA(e.$$)}}catch(e){throw Qn.length=0,ar=0,e}for(rn(null),Qn.length=0,ar=0;$g.length;)$g.pop()();for(let e=0;e<lr.length;e+=1){let t=lr[e];Bd.has(t)||(Bd.add(t),t())}lr.length=0}while(Qn.length);for(;jg.length;)jg.pop()();Pd=!1,Bd.clear(),rn(r)}function IA(r){if(r.fragment!==null){r.update(),Vt(r.before_update);let e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(To)}}function Yg(r){let e=[],t=[];lr.forEach(i=>r.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),lr=e}var _c=new Set,es;function Co(){es={r:0,c:[],p:es}}function Ro(){es.r||Vt(es.c),es=es.p}function Nt(r,e){r&&r.i&&(_c.delete(r),r.i(e))}function xi(r,e,t,i){if(r&&r.o){if(_c.has(r))return;_c.add(r),es.c.push(()=>{_c.delete(r),i&&(t&&r.d(1),i())}),r.o(e)}else i&&i()}function Fo(r){return r?.length!==void 0?r:Array.from(r)}function Zg(r,e){r.d(1),e.delete(r.key)}function Jg(r,e,t,i,n,s,o,a,l,c,u,h){let d=r.length,p=s.length,m=d,y={};for(;m--;)y[r[m].key]=m;let x=[],g=new Map,f=new Map,E=[];for(m=p;m--;){let T=h(n,s,m),z=t(T),W=o.get(z);W?i&&E.push(()=>W.p(T,e)):(W=c(z,T),W.c()),g.set(z,x[m]=W),z in y&&f.set(z,Math.abs(m-y[z]))}let w=new Set,_=new Set;function M(T){Nt(T,1),T.m(a,u),o.set(T.key,T),u=T.first,p--}for(;d&&p;){let T=x[p-1],z=r[d-1],W=T.key,A=z.key;T===z?(u=T.first,d--,p--):g.has(A)?!o.has(W)||w.has(W)?M(T):_.has(A)?d--:f.get(W)>f.get(A)?(_.add(W),M(T)):(w.add(A),d--):(l(z,o),d--)}for(;d--;){let T=r[d];g.has(T.key)||l(T,o)}for(;p;)M(x[p-1]);return Vt(E),x}var NA=["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],kA=new Set([...NA]);function Kg(r){r&&r.c()}function Nd(r,e,t){let{fragment:i,after_update:n}=r.$$;i&&i.m(e,t),To(()=>{let s=r.$$.on_mount.map(Md).filter(Mo);r.$$.on_destroy?r.$$.on_destroy.push(...s):Vt(s),r.$$.on_mount=[]}),n.forEach(To)}function kd(r,e){let t=r.$$;t.fragment!==null&&(Yg(t.after_update),Vt(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function zA(r,e){r.$$.dirty[0]===-1&&(Qn.push(r),Xg(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function Ec(r,e,t,i,n,s,o=null,a=[-1]){let l=or;rn(r);let c=r.$$={fragment:null,ctx:[],props:s,update:Ln,not_equal:n,bound:yc(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:yc(),dirty:a,skip_bound:!1,root:e.target||l.$$.root};o&&o(c.root);let u=!1;if(c.ctx=t?t(r,e.props||{},(h,d,...p)=>{let m=p.length?p[0]:d;return c.ctx&&n(c.ctx[h],c.ctx[h]=m)&&(!c.skip_bound&&c.bound[h]&&c.bound[h](m),u&&zA(r,h)),d}):[],c.update(),u=!0,Vt(c.before_update),c.fragment=i?i(c.ctx):!1,e.target){if(e.hydrate){zg();let h=Gg(e.target);c.fragment&&c.fragment.l(h),h.forEach(yi)}else c.fragment&&c.fragment.c();e.intro&&Nt(r.$$.fragment),Nd(r,e.target,e.anchor),Vg(),bc()}rn(l)}var VA;typeof HTMLElement=="function"&&(VA=class extends HTMLElement{$$ctor;$$s;$$c;$$cn=!1;$$d={};$$r=!1;$$p_d={};$$l={};$$l_u=new Map;constructor(r,e,t){super(),this.$$ctor=r,this.$$s=e,t&&this.attachShadow({mode:"open"})}addEventListener(r,e,t){if(this.$$l[r]=this.$$l[r]||[],this.$$l[r].push(e),this.$$c){let i=this.$$c.$on(r,e);this.$$l_u.set(e,i)}super.addEventListener(r,e,t)}removeEventListener(r,e,t){if(super.removeEventListener(r,e,t),this.$$c){let i=this.$$l_u.get(e);i&&(i(),this.$$l_u.delete(e))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let r=function(n){return()=>{let s;return{c:function(){s=ut("slot"),n!=="default"&&yt(s,"name",n)},m:function(l,c){nn(l,s,c)},d:function(l){l&&yi(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;let e={},t=qg(this);for(let n of this.$$s)n in t&&(e[n]=[r(n)]);for(let n of this.attributes){let s=this.$$g_p(n.name);s in this.$$d||(this.$$d[s]=Id(s,n.value,this.$$p_d,"toProp"))}for(let n in this.$$p_d)!(n in this.$$d)&&this[n]!==void 0&&(this.$$d[n]=this[n],delete this[n]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:e,$$scope:{ctx:[]}}});let i=()=>{this.$$r=!0;for(let n in this.$$p_d)if(this.$$d[n]=this.$$c.$$.ctx[this.$$c.$$.props[n]],this.$$p_d[n].reflect){let s=Id(n,this.$$d[n],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[n].attribute||n):this.setAttribute(this.$$p_d[n].attribute||n,s)}this.$$r=!1};this.$$c.$$.after_update.push(i),i();for(let n in this.$$l)for(let s of this.$$l[n]){let o=this.$$c.$on(n,s);this.$$l_u.set(s,o)}this.$$l={}}}attributeChangedCallback(r,e,t){this.$$r||(r=this.$$g_p(r),this.$$d[r]=Id(r,t,this.$$p_d,"toProp"),this.$$c?.$set({[r]:this.$$d[r]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(r){return Object.keys(this.$$p_d).find(e=>this.$$p_d[e].attribute===r||!this.$$p_d[e].attribute&&e.toLowerCase()===r)||r}});function Id(r,e,t,i){let n=t[r]?.type;if(e=n==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(n){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(n){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}var ts=class{$$=void 0;$$set=void 0;$destroy(){kd(this,1),this.$destroy=Ln}$on(e,t){if(!Mo(t))return Ln;let i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}$set(e){this.$$set&&!Ng(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var Qg="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Qg);var i0=require("obsidian");function UA(r){wc(r,"svelte-1my4lf",'.always-open.svelte-1my4lf.svelte-1my4lf{pointer-events:none}.creator-settings-container.svelte-1my4lf.svelte-1my4lf{pointer-events:initial}.calendarium-nested-settings.svelte-1my4lf.svelte-1my4lf{position:relative}.calendarium-nested-summary.svelte-1my4lf.svelte-1my4lf{outline:none;list-style:none !important;list-style-type:none !important;min-height:1rem;border-top-left-radius:0.1rem;border-top-right-radius:0.1rem;cursor:pointer;background-color:var(--creator-background-color);margin-right:0;display:flex;justify-content:space-between}.right-side.svelte-1my4lf.svelte-1my4lf{display:flex;align-items:center;gap:1rem}summary.svelte-1my4lf.svelte-1my4lf::-webkit-details-marker,summary.svelte-1my4lf.svelte-1my4lf::marker{display:none !important}.always-open.svelte-1my4lf .handle.svelte-1my4lf{display:none}.collapser.svelte-1my4lf.svelte-1my4lf{display:flex;flex-flow:column;justify-content:flex-start;align-items:flex-end;content:""}.handle.svelte-1my4lf.svelte-1my4lf{transform:rotate(0deg);transition:transform 0.25s;display:flex}details[open].svelte-1my4lf .handle.svelte-1my4lf{transform:rotate(90deg)}.creator-settings-container.svelte-1my4lf.svelte-1my4lf{padding:0.75em var(--size-4-3)}.calendarium-nested-settings.svelte-1my4lf.svelte-1my4lf{border-top:0px}')}var HA=r=>({}),e0=r=>({class:"context"});function t0(r){let e,t=r[8].context,i=Dd(t,r,r[7],e0);return{c(){i&&i.c()},m(n,s){i&&i.m(n,s),e=!0},p(n,s){i&&i.p&&(!e||s&128)&&Cd(i,t,n,n[7],e?Td(t,n[7],s,HA):Rd(n[7]),e0)},i(n){e||(Nt(i,n),e=!0)},o(n){xi(i,n),e=!1},d(n){i&&i.d(n)}}}function GA(r){let e,t,i,n,s,o,a,l,c,u,h,d,p,m,y,x,g,f,E,w,_,M,T=r[0]&&t0(r),z=r[8].default,W=Dd(z,r,r[7],null);return{c(){e=ut("details"),t=ut("summary"),i=ut("div"),n=ut("div"),s=ut("div"),o=Jn(r[1]),a=sn(),l=ut("div"),c=Jn(r[2]),u=sn(),h=ut("div"),T&&T.c(),d=sn(),p=ut("div"),m=ut("div"),y=ut("div"),g=sn(),f=ut("div"),W&&W.c(),yt(s,"class","setting-item-name"),yt(l,"class","setting-item-description"),yt(n,"class","setting-item-info"),yt(i,"class","setting-item setting-item-heading"),yt(y,"class","handle svelte-1my4lf"),yt(m,"class","warning-container"),yt(p,"class","collapser svelte-1my4lf"),yt(h,"class","right-side svelte-1my4lf"),yt(t,"class","calendarium-nested-summary svelte-1my4lf"),yt(f,"class","creator-settings-container svelte-1my4lf"),yt(e,"class","creator calendarium-nested-settings setting-item svelte-1my4lf"),Ld(e,"always-open",r[3])},m(A,v){nn(A,e,v),Ze(e,t),Ze(t,i),Ze(i,n),Ze(n,s),Ze(s,o),Ze(n,a),Ze(n,l),Ze(l,c),Ze(t,u),Ze(t,h),T&&T.m(h,null),Ze(h,d),Ze(h,p),Ze(p,m),Ze(m,y),Ze(e,g),Ze(e,f),W&&W.m(f,null),e.open=r[0],w=!0,_||(M=[rr(x=r[5].call(null,y)),Kn(t,"keyup",qA),Kn(e,"toggle",r[9]),rr(E=r[4].call(null,e))],_=!0)},p(A,[v]){(!w||v&2)&&Do(o,A[1]),(!w||v&4)&&Do(c,A[2]),A[0]?T?(T.p(A,v),v&1&&Nt(T,1)):(T=t0(A),T.c(),Nt(T,1),T.m(h,d)):T&&(Co(),xi(T,1,1,()=>{T=null}),Ro()),W&&W.p&&(!w||v&128)&&Cd(W,z,A,A[7],w?Td(z,A[7],v,null):Rd(A[7]),null),v&1&&(e.open=A[0]),(!w||v&8)&&Ld(e,"always-open",A[3])},i(A){w||(Nt(T),Nt(W,A),w=!0)},o(A){xi(T),xi(W,A),w=!1},d(A){A&&yi(e),T&&T.d(),W&&W.d(A),_=!1,Vt(M)}}}var qA=r=>r.preventDefault();function WA(r,e,t){let{$$slots:i={},$$scope:n}=e,{collapseIcon:s="chevron-right"}=e,{open:o=!0}=e,{name:a}=e,{desc:l=""}=e,{alwaysOpen:c=!1}=e,u=p=>{o&&p.setAttribute("open","open")},h=p=>{(0,i0.setIcon)(p,s)};function d(){o=this.open,t(0,o)}return r.$$set=p=>{"collapseIcon"in p&&t(6,s=p.collapseIcon),"open"in p&&t(0,o=p.open),"name"in p&&t(1,a=p.name),"desc"in p&&t(2,l=p.desc),"alwaysOpen"in p&&t(3,c=p.alwaysOpen),"$$scope"in p&&t(7,n=p.$$scope)},[o,a,l,c,u,h,s,n,i,d]}var Od=class extends ts{constructor(e){super(),Ec(this,e,WA,GA,xc,{collapseIcon:6,open:0,name:1,desc:2,alwaysOpen:3},UA)}},zd=Od;var Vd=require("obsidian");function $A(r){wc(r,"svelte-nmb05s",".saved-formulas.svelte-nmb05s{display:flex;flex-flow:column nowrap;gap:0.5rem}.formula-container.svelte-nmb05s{display:flex;justify-content:space-between;align-items:center}.formula-actions.svelte-nmb05s{display:flex;align-items:center;gap:0.25rem}")}function n0(r,e,t){let i=r.slice();return i[7]=e[t],i}function s0(r){let e,t;return e=new zd({props:{name:"Saved Formulas",open:!1,$$slots:{default:[jA]},$$scope:{ctx:r}}}),{c(){Kg(e.$$.fragment)},m(i,n){Nd(e,i,n),t=!0},p(i,n){let s={};n&1031&&(s.$$scope={dirty:n,ctx:i}),e.$set(s)},i(i){t||(Nt(e.$$.fragment,i),t=!0)},o(i){xi(e.$$.fragment,i),t=!1},d(i){kd(e,i)}}}function r0(r,e){let t,i,n,s,o,a,l=e[7]+"",c,u,h,d,p,m,y;function x(){return e[5](e[7])}function g(){return e[6](e[7])}return{key:r,first:null,c(){t=ut("div"),i=ut("div"),n=ut("div"),o=sn(),a=ut("span"),c=Jn(l),u=sn(),h=ut("div"),p=sn(),yt(a,"class","formula"),yt(i,"class","formula-actions svelte-nmb05s"),yt(t,"class","formula-container svelte-nmb05s"),this.first=t},m(f,E){nn(f,t,E),Ze(t,i),Ze(i,n),Ze(i,o),Ze(i,a),Ze(a,c),Ze(t,u),Ze(t,h),Ze(t,p),m||(y=[rr(s=e[3].call(null,n)),Kn(n,"click",x),rr(d=e[4].call(null,h)),Kn(h,"click",g)],m=!0)},p(f,E){e=f,E&1&&l!==(l=e[7]+"")&&Do(c,l)},d(f){f&&yi(t),m=!1,Vt(y)}}}function jA(r){let e,t=[],i=new Map,n=Fo(r[0].customFormulas),s=o=>o[7];for(let o=0;o<n.length;o+=1){let a=n0(r,n,o),l=s(a);i.set(l,t[o]=r0(l,a))}return{c(){e=ut("div");for(let o=0;o<t.length;o+=1)t[o].c();yt(e,"class","saved-formulas svelte-nmb05s")},m(o,a){nn(o,e,a);for(let l=0;l<t.length;l+=1)t[l]&&t[l].m(e,null)},p(o,a){a&7&&(n=Fo(o[0].customFormulas),t=Jg(t,a,s,1,o,n,i,e,Zg,r0,null,n0))},d(o){o&&yi(e);for(let a=0;a<t.length;a+=1)t[a].d()}}}function XA(r){let e,t,i=r[0].customFormulas.length&&s0(r);return{c(){i&&i.c(),e=Hg()},m(n,s){i&&i.m(n,s),nn(n,e,s),t=!0},p(n,[s]){n[0].customFormulas.length?i?(i.p(n,s),s&1&&Nt(i,1)):(i=s0(n),i.c(),Nt(i,1),i.m(e.parentNode,e)):i&&(Co(),xi(i,1,1,()=>{i=null}),Ro())},i(n){t||(Nt(i),t=!0)},o(n){xi(i),t=!1},d(n){n&&yi(e),i&&i.d(n)}}}function YA(r,e,t){let{settings:i}=e,{plugin:n}=e,{view:s}=e,o=u=>{new Vd.ExtraButtonComponent(u).setIcon("dices")},a=u=>{new Vd.ExtraButtonComponent(u).setIcon("trash")},l=u=>{s.roll(u)},c=async u=>{t(0,i.customFormulas=i.customFormulas.filter(h=>h!=u),i),n.saveSettings()};return r.$$set=u=>{"settings"in u&&t(0,i=u.settings),"plugin"in u&&t(1,n=u.plugin),"view"in u&&t(2,s=u.view)},[i,n,s,o,a,l,c]}var Ud=class extends ts{constructor(e){super(),Ec(this,e,YA,XA,xc,{settings:0,plugin:1,view:2},$A)}},o0=Ud;var Bi="DICE_ROLLER_VIEW",cr=class extends pt.ItemView{constructor(t,i){super(i);this.plugin=t;this.leaf=i;this.custom="";this.#e=!1;this.#t=!1;this.#i=0;this.#n=Wl;this.#s=new Map;this.Formatter=new Intl.DateTimeFormat(localStorage.getItem("language")??"en-US",{dateStyle:"medium",timeStyle:"short"});this.contentEl.addClass("dice-roller-view"),this.addChild(this.#n);for(let n of this.plugin.data.icons)this.#n.registerIcon(n.id,n.shape,n.text);this.registerEvent(this.plugin.app.workspace.on("dice-roller:new-result",async n=>{(this.plugin.data.addToView||n.getSource()==Bi)&&await this.addResult({result:n.getResultText(),original:n.original,resultText:n.getTooltip(),timestamp:new Date().valueOf(),id:Ig(12)})}))}get customFormulas(){return this.plugin.data.customFormulas}#e;#t;#i;#n;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 t=this.contentEl.createDiv("results-header-container");t.createEl("h4",{cls:"results-header",text:"Results"}),new pt.ExtraButtonComponent(t.createDiv("clear-all")).setIcon("trash").setTooltip("Clear All").onClick(async()=>{this.resultEl.empty(),this.resultEl.append(this.noResultsEl),this.plugin.data.viewResults=[],await this.plugin.saveSettings()});let i=this.contentEl.createDiv("dice-roller-results-container");this.resultEl=i.createDiv("dice-roller-results"),this.noResultsEl=this.resultEl.createSpan({text:"No results yet! Roll some dice to get started :)"});for(let n of this.plugin.data.viewResults)this.addResult(n,!1);this.buildButtons(),this.buildFormula()}#s;buildButtons(){this.gridEl.empty();let t=this.gridEl.createDiv("dice-buttons");for(let o of this.plugin.data.icons)this.#n.registerIcon(o.id,o.shape,o.text),new pt.ExtraButtonComponent(t.createDiv("dice-button")).setIcon(o.id).extraSettingsEl.onClickEvent(a=>{if(a.type==="auxclick"){this.roll(o.formula);return}this.#s.has(o)||this.#s.set(o,0);let l=this.#s.get(o)??0;l+=a.getModifierState("Shift")?-1:1,this.#s.set(o,l),this.setFormula()});let i=this.gridEl.createDiv("advantage-disadvantage");new pt.ExtraButtonComponent(i).setIcon("minus-square").onClick(()=>{this.#i-=1,this.setFormula()});let n=new pt.ButtonComponent(i).setButtonText("ADV").onClick(()=>{this.#e=!this.#e,this.#t=!1,this.#e?(n.setCta(),s.removeCta()):n.removeCta(),this.setFormula()});this.#e&&n.setCta();let s=new pt.ButtonComponent(i).setButtonText("DIS").onClick(()=>{this.#t=!this.#t,this.#e=!1,this.#t?(s.setCta(),n.removeCta()):s.removeCta(),this.setFormula()});this.#t&&s.setCta(),new pt.ExtraButtonComponent(i).setIcon("plus-square").onClick(()=>{this.#i+=1,this.setFormula()}),new o0({target:this.gridEl,props:{settings:this.plugin.data,plugin:this.plugin,view:this}})}setFormula(){if(!this.#s.size&&!this.#i){this.formulaComponent.inputEl.value="";return}let t=[];for(let[n,s]of this.#s){if(!s)continue;let o=s<0?"-":"+",a=/^(?:1)?d(\d|%|F)+$/.test(n.formula)?`${Math.abs(s)}${n.formula.replace(/^1/,"")}`:`${Math.abs(s)} * (${n.formula})`,l=Tt.getRoller(n.formula,Bi);l!=null&&l instanceof Wt&&(l.buildDiceTree(),l.calculate(),t.push({formula:a,max:l.max,sign:o}))}t.sort((n,s)=>s.max-n.max);let i=[];for(let n=0;n<t.length;n++){let s=t[n];n===0&&s.sign==="-"?s.formula=`${s.sign}${s.formula}`:n>0&&i.push(s.sign);let o="";n===0&&(this.#e?o="kh":this.#t&&(o="kl"),s.formula=s.formula.replace(/(d\d+)/,`$1${o}`)),i.push(`${s.formula}`)}this.#i!==0&&(i.length>0&&i.push(this.#i>0?"+":"-"),i.push(`${Math.abs(this.#i)}`)),this.formulaComponent.inputEl.value=i.join(" ")}async roll(t=this.formulaComponent.inputEl.value){if(!t)return;this.rollButton.setDisabled(!0);let i={...Tt.getRollerOptions(this.plugin.data)};i.expectedValue=="None"&&(i.expectedValue="Roll");try{let n=await Tt.getRoller(t,Bi,i);if(n==null)return;if(!(n instanceof Wt))throw new Error("The Dice Tray only supports dice rolls.");if(n.iconEl.detach(),n.containerEl.onclick=null,n.buildDiceTree(),!n.children.length)throw new Error("No dice.");await n.roll(this.plugin.data.renderer).catch(s=>{throw s})}catch(n){new pt.Notice("Invalid Formula: "+n.message)}finally{this.rollButton.setDisabled(!1),this.buildButtons(),this.#s=new Map,this.#i=0,this.setFormula()}}buildFormula(){this.formulaEl.empty(),this.formulaComponent=new pt.TextAreaComponent(this.formulaEl).setPlaceholder("Dice Formula").onChange(i=>this.#s=new Map);let t=this.formulaEl.createDiv("action-buttons");this.saveButton=new pt.ExtraButtonComponent(t).setIcon("save").setTooltip("Save Formula").onClick(()=>this.save()),this.saveButton.extraSettingsEl.addClass("dice-roller-roll"),this.rollButton=new pt.ButtonComponent(t).setIcon("dices").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())}async addResult(t,i=!0){this.noResultsEl&&this.noResultsEl.detach();let n=createDiv("view-result"),s=n.createDiv("result-actions");new pt.ExtraButtonComponent(s).setIcon("dices").setTooltip("Roll Again").onClick(()=>this.roll(t.original)).extraSettingsEl.addClass("dice-result-reroll"),s.createSpan({text:t.original}),new pt.ExtraButtonComponent(s).setIcon("copy").setTooltip("Copy Result").onClick(async()=>{await navigator.clipboard.writeText(`${t.resultText}`)}).extraSettingsEl.addClass("dice-content-copy"),pt.Platform.isMobile&&n.createSpan({cls:"dice-content-result",text:`${t.resultText}`}),n.createEl("strong",{attr:{"aria-label":t.resultText},text:`${t.result}`});let l=n.createDiv("result-context");l.createEl("em",{cls:"result-timestamp",text:this.Formatter.format(t.timestamp)}),new pt.ExtraButtonComponent(l).setIcon("trash").onClick(async()=>{n.detach(),this.resultEl.children.length===0&&this.resultEl.prepend(this.noResultsEl),this.plugin.data.viewResults.splice(this.plugin.data.viewResults.findIndex(c=>c.id===t.id),1),await this.plugin.saveSettings()}),this.resultEl.prepend(n),i&&(this.plugin.data.viewResults.push(t),this.plugin.data.viewResults=this.plugin.data.viewResults.slice(0,100),await this.plugin.saveSettings())}getDisplayText(){return"Dice Tray"}getViewType(){return Bi}getIcon(){return"dices"}async onClose(){await super.onClose()}};var Pi=require("@codemirror/view"),NR=require("@codemirror/state"),a0=require("@codemirror/language"),Bn=require("obsidian");function ZA(r,e,t){for(let i of r.ranges)if(i.from<=t&&i.to>=e)return!0;return!1}function JA(r,e,t){let i=e.app.workspace.getActiveFile();if(!i)return;let n=[],s=r.state.selection,o=new RegExp(".*?_?inline-code_?.*");for(let{from:a,to:l}of r.visibleRanges)(0,a0.syntaxTree)(r.state).iterate({from:a,to:l,enter:({node:c})=>{let u=c.type;if(u.name.includes("formatting")||!o.test(u.name))return;let h=c.from,d=c.to;if(ZA(s,h,d))return;let p=r.state.doc.sliceString(h,d).trim(),m=ko(e.data.diceModTemplateFolders,i);if(/^dice\-mod:\s*([\s\S]+)\s*?/.test(p)&&!m&&e.data.replaceDiceModInLivePreview){let[,f]=p.match(/dice\-mod:\s*([\s\S]+)\s*?/),E=e.app.workspace.getActiveFile(),w=Tt.getRoller(f,E.path);if(w==null)return;w.roll().then(async()=>{let M=`${await w.getReplacer()}`;e.data.escapeDiceMod&&M.replace(/([\*\[\]])/g,"\\$1");let T={from:h-1,to:d+1,insert:M},z=r.state.update({changes:T});r.dispatch(z)});return}if(!/^dice(?:\+|\-|\-mod)?:\s*([\s\S]+)\s*?/.test(p))return;let[,y]=p.match(/^dice(?:\+|\-|\-mod)?:\s*([\s\S]+)\s*?/),x=Tt.getRoller(y,i.path);if(x==null)return;x.addContexts(t,e);let g=new Hd(p,x,r,e,i);e.processor.trackRoller(i,x),n.push(Pi.Decoration.replace({widget:g,inclusive:!1,block:!1}).range(h-1,d+1))}});return Pi.Decoration.set(n,!0)}var Hd=class extends Pi.WidgetType{constructor(t,i,n,s,o){super();this.rawQuery=t;this.roller=i;this.view=n;this.plugin=s;this.file=o}eq(t){return t.rawQuery===this.rawQuery?!0:(this.plugin.processor.fileMap.get(this.file)?.remove(t.roller),!1)}toDOM(t){return this.roller.roll(),this.roller.containerEl}ignoreEvent(t){if(t.type==="mousedown"){let i=this.view.posAtCoords({x:t.x,y:t.y});if(t.shiftKey){if(i){let{editor:n}=this.view.state.field(Bn.editorEditorField).state.field(Bn.editorInfoField);n.setCursor(n.offsetToPos(i))}return!1}}return!0}};function l0(r){return Pi.ViewPlugin.fromClass(class{constructor(e){this.component=new Bn.Component;this.component.load(),this.decorations=Pi.Decoration.none}destroy(){this.component.unload()}update(e){if(!e.state.field(Bn.editorLivePreviewField)){this.decorations=Pi.Decoration.none;return}(e.docChanged||e.viewportChanged||e.selectionSet)&&(this.decorations=JA(e.view,r,this.component)??Pi.Decoration.none)}},{decorations:e=>e.decorations})}function c0(r,e){let t=Object.keys(e).map(i=>KA(r,i,e[i]));return t.length===1?t[0]:function(){t.forEach(i=>i())}}function KA(r,e,t){let i=r[e],n=r.hasOwnProperty(e),s=t(i);return i&&Object.setPrototypeOf(s,i),Object.setPrototypeOf(o,s),r[e]=o,a;function o(...l){return s===i&&r[e]===o&&a(),s.apply(this,l)}function a(){r[e]===o&&(n?r[e]=i:delete r[e]),s!==i&&(s=i,Object.setPrototypeOf(o,i||Function))}}var ii=require("obsidian");var Lo=class extends ii.Component{constructor(){super(...arguments);this.fileMap=new WeakMap}initialize(t){this.app=t.app,this.data=t.data,this.plugin=t,t.addCommand({id:"reroll",name:"Re-roll Dice",checkCallback:i=>{let n=this.app.workspace.getActiveViewOfType(ii.MarkdownView);if(n&&(n.getMode()==="preview"||n.editMode?.sourceMode==!1)&&this.fileMap.has(n.file))return i||this.fileMap.get(n.file).forEach(o=>{o.roll()}),!0}})}trackRoller(t,i){this.fileMap.has(t)||this.fileMap.set(t,[]),this.fileMap.get(t).push(i)}async postprocessor(t,i){let n=t.querySelectorAll("code");if(!n.length)return;let s=i.sourcePath,o=this.app.vault.getAbstractFileByPath(i.sourcePath),a=i.getSectionInfo(t);if(!((!o||!(o instanceof ii.TFile))&&s!="STATBLOCK_RENDERER"))for(let l=0;l<n.length;l++){let c=n.item(l);if(!/^dice(?:\+|\-|\-mod)?:/.test(c.innerText))continue;let[u,h]=c.innerText.match(/^dice(?:\+|\-|\-mod)?:\s*([\s\S]+)\s*?/);if(/^dice-mod/.test(c.innerText)){if(o&&o instanceof ii.TFile&&ko(this.data.diceModTemplateFolders,o))continue;let d=Tt.getRoller(h,i.sourcePath);if(d==null)return;if(d instanceof Wt&&d.shouldRender&&(d.hasRunOnce=!0),await d.roll(),!o||!(o instanceof ii.TFile)){c.replaceWith(d.containerEl);continue}let p=await d.getReplacer();if(!p){new ii.Notice("Dice Roller: There was an issue modifying the file.");return}this.app.vault.process(o,m=>{let y=m.split(`
`),x=y.slice(a.lineStart,a.lineEnd+1);return this.data.escapeDiceMod?x=x.join(`
`).replace(`\`${u}\``,p.replace(/([\*\[\]])/g,"\\$1")).split(`
`):x=x.join(`
`).replace(`\`${u}\``,p).split(`
`),y.splice(a.lineStart,a.lineEnd-a.lineStart+1,...x),y.join(`
`)});continue}try{let d=Tt.getRoller(h,i.sourcePath);if(d==null)return;if(d.onLoad(async()=>{await d.roll(),c.replaceWith(d.containerEl)}),d.addContexts(i,this.plugin),!o||!(o instanceof ii.TFile))continue;this.trackRoller(o,d);let p=this.app.workspace.getActiveViewOfType(ii.MarkdownView);if(p&&this.fileMap.has(o)&&this.fileMap.get(o).length===1){let m=this,y=c0(p,{onUnloadFile:function(x){return async function(g){return g==o&&(m.fileMap.delete(o),y()),await x.call(this,g)}}});p.register(y),p.register(()=>this.fileMap.delete(o))}}catch(d){console.error(d),new ii.Notice(`There was an error parsing the dice string: ${c.innerText}.
${d}`,5e3);continue}}}processContent(t){let i=this.data.displayFormulaForMod;return t.includes("|noform")&&(i=!1),t.includes("|form")&&(i=!0),i}};var QA=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Gd=r=>{if(typeof r!="string")throw new TypeError("Invalid argument expected string");let e=r.match(QA);if(!e)throw new Error(`Invalid argument not valid semver ('${r}' received)`);return e.shift(),e},u0=r=>r==="*"||r==="x"||r==="X",h0=r=>{let e=parseInt(r,10);return isNaN(e)?r:e},eS=(r,e)=>typeof r!=typeof e?[String(r),String(e)]:[r,e],tS=(r,e)=>{if(u0(r)||u0(e))return 0;let[t,i]=eS(h0(r),h0(e));return t>i?1:t<i?-1:0},qd=(r,e)=>{for(let t=0;t<Math.max(r.length,e.length);t++){let i=tS(r[t]||"0",e[t]||"0");if(i!==0)return i}return 0};var d0=(r,e)=>{let t=Gd(r),i=Gd(e),n=t.pop(),s=i.pop(),o=qd(t,i);return o!==0?o:n&&s?qd(n.split("."),s.split(".")):n||s?n?-1:1:0};var Bo=(r,e,t)=>{iS(t);let i=d0(r,e);return f0[t].includes(i)},f0={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},p0=Object.keys(f0),iS=r=>{if(typeof r!="string")throw new TypeError(`Invalid operator type, expected string but got ${typeof r}`);if(p0.indexOf(r)===-1)throw new Error(`Invalid operator, expected one of ${p0.join("|")}`)};var Ac=class extends is.Plugin{constructor(){super(...arguments);this.api=Tt}getRendererData(){return{diceColor:this.data.diceColor,textColor:this.data.textColor,narrativeSymbolSet:this.data.narrativeSymbolSet,colorfulDice:this.data.colorfulDice,scaler:this.data.scaler,renderTime:this.data.renderTime,textFont:this.data.textFont}}async onload(){await this.loadSettings(),console.log(`DiceRoller v${this.data.version} loaded`),Et.setData(this.getRendererData()),this.api.initialize(this.data,this.app),window.DiceRoller=this.api,this.register(()=>delete window.DiceRoller),this.addChild(ai.initialize(this.app)),nr.setDefaults(this.data.defaultRoll,this.data.defaultFace),this.addSettingTab(new Ao(this.app,this)),this.registerView(Bi,t=>new cr(this,t)),this.registerEvent(this.app.workspace.on("dice-roller:render-dice",async t=>{let i=await Tt.getRoller(t,"external");if(i!=null){if(!(i instanceof Wt)){new is.Notice("The Dice View only supports dice rolls.");return}if(await i.roll(),!i.children.length){new is.Notice("Invalid formula.");return}try{await i.roll(!0)}catch(n){new is.Notice("There was an error rendering the roll."),console.error(n)}this.app.workspace.trigger("dice-roller:rendered-result",i.result)}})),this.addCommand({id:"open-view",name:"Open Dice View",callback:()=>{this.view?this.app.workspace.revealLeaf(this.view.leaf):this.addDiceView()}}),this.processor=new Lo,this.processor.initialize(this),this.registerMarkdownPostProcessor((t,i)=>this.processor.postprocessor(t,i)),this.registerEditorExtension([l0(this)]),this.app.workspace.onLayoutReady(async()=>{this.addDiceView(!0)}),this.app.workspace.trigger("dice-roller:loaded")}get view(){let t=this.app.workspace.getLeavesOfType(Bi),i=t.length?t[0]:null;if(i&&i.view&&i.view instanceof cr)return i.view}async addDiceView(t=!1){t&&!this.data.showLeafOnStartup||this.app.workspace.getLeavesOfType(Bi).length||await this.app.workspace.getRightLeaf(!1).setViewState({type:Bi})}async loadSettings(){let t=Object.assign({},Yl,await this.loadData()),i=!1;typeof t.version!="string"&&delete t.version,Bo("11.2.0",t.version??"0.0.0",">")&&!("position"in t)&&(t.position=t.showDice?zt.RIGHT:zt.NONE,delete t.showDice,i=!0),Bo("11.0.0",t.version??"0.0.0",">")&&(delete t.persistResults,delete t.results,i=!0),Bo(t.version??"0.0.0",this.manifest.version,"!=")&&(t.version=this.manifest.version,i=!0),this.data=Xl(t),i&&await this.saveSettings()}async saveSettings(){await this.saveData(this.data)}async getArrayRoller(t,i=1){return new is.Notice("Using the Dice Roller plugin directly will be deprecated in a future version. Please use `window.DiceRoller` instead."),this.api.getArrayRoller(t,i)}onunload(){console.log("DiceRoller unloaded"),this.app.workspace.getLeavesOfType(Bi).forEach(t=>t.detach()),"__THREE__"in window&&delete window.__THREE__,this.app.workspace.trigger("dice-roller:unloaded")}};
/*! Bundled license information:
he/he.js:
(*! https://mths.be/he v1.2.0 by @mathias | MIT license *)
three/build/three.module.js:
(**
* @license
* Copyright 2010-2022 Three.js Authors
* SPDX-License-Identifier: MIT
*)
*/
/* nosourcemap */