diff --git a/build/utterance-queue.min.js b/build/utterance-queue.min.js index a3aeb66..ef52b2d 100644 --- a/build/utterance-queue.min.js +++ b/build/utterance-queue.min.js @@ -1 +1 @@ -!function(){if(window.phet=window.phet||{},phet.chipper=phet.chipper||{},phet.chipper.packageObject={name:"utterance-queue",version:"0.0.0",license:"MIT",repository:{type:"git",url:"https://github.com/phetsims/utternace-queue.git"},devDependencies:{grunt:"~1.4.0"},phet:{generatedUnitTests:!0,requirejsNamespace:"UTTERANCE_QUEUE",buildStandalone:!0,requiresLodash:!0,assignGlobals:{"phet.utteranceQueue":"UTTERANCE_QUEUE/main","phet.phetCore":"PHET_CORE/main","phet.axon":"AXON/main"}},eslintConfig:{extends:"../chipper/eslint/sim_eslintrc.js"}},!window.hasOwnProperty("_"))throw new Error("Underscore/Lodash not found: _");window.assertions=window.assertions||{},window.assertions.assertFunction=window.assertions.assertFunction||function(e,t){if(!e){if(window.navigator&&"Microsoft Internet Explorer"===window.navigator.appName)try{throw new Error}catch(r){t="".concat(t,", stack=\n").concat(r.stack)}var i=t?"Assertion failed: ".concat(t):"Assertion failed";throw console&&console.log&&console.log(i),window.phet&&phet.chipper&&phet.chipper.queryParameters&&phet.chipper.queryParameters.debugger,new Error(i)}},window.assert=window.assert||null,window.assertSlow=window.assertSlow||null,window.assertions.enableAssert=function(){window.assert=window.assertions.assertFunction,window.console&&window.console.log&&window.console.log("enabling assert")},window.assertions.disableAssert=function(){window.assert=null,window.console&&window.console.log&&window.console.log("disabling assert")},window.assertions.enableAssertSlow=function(){window.assertSlow=window.assertions.assertFunction,window.console&&window.console.log&&window.console.log("enabling assertSlow")},window.assertions.disableAssertSlow=function(){window.assertSlow=null,window.console&&window.console.log&&window.console.log("disabling assertSlow")},function(){window.phetio=window.phetio||{};window.phetio.PhetioIDUtils={append:function(e,...t){return t.forEach(t=>{e+="."+t}),e},getComponentName:function(e){var t=e.lastIndexOf(".");return-1===t?e:e.substring(t+1,e.length)},getParentID:function(e){var t=e.lastIndexOf(".");return-1===t?null:e.substring(0,t)},getDOMElementID:function(e){return"phetioID:".concat(e)},getScreenID:function(e){for(var t=[],i=e.split("."),r=0;r0&&n+"Screen".length===a.length)return t.join(".")}return null},getGroupElementIndex:function(e){return parseInt(e.split(window.phetio.PhetioIDUtils.GROUP_SEPARATOR)[1],10)},isAncestor:function(e,t){for(var i=e.split("."),r=t.split("."),a=0;a{"use strict";var e={340:(e,t,i)=>{var r;i.d(t,{Z:()=>a}),e=i.hmd(e);try{r=e&&e.hot}catch(n){r=!1}var a=r}},t={};function i(r){var a=t[r];if(void 0!==a)return a.exports;var n=t[r]={id:r,loaded:!1,exports:{}};return e[r](n,n.exports,i),n.loaded=!0,n.exports}i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e=i(340);var t=class{constructor(e){this.name=e,window.phet&&(window.phet[e]=this)}register(t,i){if(t.indexOf(".")<0)e.Z,this[t]=i;else{for(var r=t.split("."),a=this,n=0;n{if(t)for(var i in t)if(t.hasOwnProperty(i)){var r=t[i];_.endsWith(i,"Options")&&"Options"!==i?e[i]=o(e[i]||{},r):e[i]=r}}),e}a.register("merge",o);var l=o,h=new t("axon");_.hasIn(window,"phet.chipper.queryParameters")&&phet.chipper.queryParameters.shuffleListeners;class p{constructor(e){e&&(this.onBeforeNotify=e),this.listeners=new Set,this.emitContexts=[]}dispose(){this.removeAllListeners()}emit(...e){if(this.onBeforeNotify&&this.onBeforeNotify.apply(null,e),this.listeners.size>0){var t={index:0};for(var i of(this.emitContexts.push(t),this.listeners))if(i(...e),t.index++,t.listenerArray)break;if(t.listenerArray)for(var r=t.index;r=0&&!this.emitContexts[e].listenerArray;e--)this.emitContexts[e].listenerArray=Array.from(this.listeners)}hasListener(e){return this.listeners.has(e)}hasListeners(){return this.listeners.size>0}getListenerCount(){return this.listeners.size}forEachListener(e){this.listeners.forEach(e)}}h.register("TinyEmitter",p);var u=p;class d extends u{setTimeout(e,t){var i=0,r=a=>{1e3*(i+=a)>=t&&this.hasListener(r)&&(e(),this.removeListener(r))};return this.addListener(r),r}clearTimeout(e){this.hasListener(e)&&this.removeListener(e)}setInterval(e,t){var i=0,r=a=>{for(i+=a;1e3*i>=t&&-1!==this.hasListener(r);)e(),i-=t/1e3};return this.addListener(r),r}clearInterval(e){this.hasListener(e)&&this.removeListener(e)}runOnNextTick(e){this.setTimeout(e,0)}}h.register("Timer",d);var c=d,m=new c;h.register("animationFrameTimer",m);class y{constructor(e){e.keys,e.map;var t=e.keys||Object.keys(e.map),i=e.map||{};e=l({phetioDocumentation:null,beforeFreeze:null},e),this.phetioDocumentation=e.phetioDocumentation,this.KEYS=t,this.VALUES=[],t.forEach(e=>{var t=i[e]||{};t.name=e,t.toString=()=>e,this[e]=t,this.VALUES.push(t)}),e.beforeFreeze&&e.beforeFreeze(this)}includes(e){return _.includes(this.VALUES,e)}static byKeys(e,t){return new y(l({keys:e},t))}static byMap(e,t){return new y(l({map:e},t))}}a.register("Enumeration",y);var g=y,v=["string","number","boolean","function"],f={assertions:!1},T=["valueType","validValues","isValidValue","arrayElementType","phetioType"],E={isValidValidator(e,t){if(t=t||f,!(e instanceof Object))return!1;if(!(e.hasOwnProperty("isValidValue")||e.hasOwnProperty("valueType")||e.hasOwnProperty("arrayElementType")||e.hasOwnProperty("validValues")||e.hasOwnProperty("phetioType")))return!1;if(e.hasOwnProperty("valueType")&&!P(e.valueType,t))return!1;if(e.hasOwnProperty("arrayElementType")){if(e.hasOwnProperty("valueType"))return!1;if(!P(e.arrayElementType,t))return!1}if(e.hasOwnProperty("isValidValue")&&"function"!=typeof e.isValidValue&&null!==e.isValidValue&&void 0!==e.isValidValue)return!1;if(void 0!==e.validValues&&null!==e.validValues){if(!Array.isArray(e.validValues))return!1;var i=_.omit(e,"validValues");if(E.containsValidatorKey(i))for(var r=0;r("function"==typeof e||"string"==typeof e||e instanceof g||null==e)&&!("string"==typeof e&&!_.includes(v,e)),validateValidator(e){0},containsValidatorKey(e){for(var t=0;t(t&&(e="".concat(t,": ").concat(e)),e),isValueValid(e,t,i){if((i=l({validateValidator:!0,assertions:!1,message:null},i)).validateValidator&&!h.ValidatorDef.isValidValidator(t,i))return!1;if(t.hasOwnProperty("valueType")){var r=t.valueType;if(Array.isArray(r)){if(!_.some(r.map(t=>E.isValueValidValueType(e,t,i.message,f))))return!1}else if(r&&!E.isValueValidValueType(e,r,i.message,i))return!1}if(t.hasOwnProperty("arrayElementType")){var a=t.arrayElementType;if(!E.isValueValid(e,{valueType:Array},i))return!1;if(!_.every(e.map(e=>Array.isArray(a)?!!_.some(a.map(t=>E.isValueValidValueType(e,t,i.message,f))):E.isValueValidValueType(e,t.arrayElementType,i.message,i))))return!1}return(!t.hasOwnProperty("validValues")||-1!==t.validValues.indexOf(e))&&(!(t.hasOwnProperty("isValidValue")&&!t.isValidValue(e))&&!(t.hasOwnProperty("phetioType")&&!E.isValueValid(e,t.phetioType.validator,f)))},isValueValidValueType:(e,t,i,r)=>("string"!=typeof t||typeof e===t)&&(!(t===Array&&!Array.isArray(e))&&(!(t instanceof g&&!t.includes(e))&&(("function"!=typeof t||e instanceof t)&&(null!==t||null===e))))},P=(e,t)=>{if(Array.isArray(e)){if(!_.every(e.map(e=>E.validateValueType(e,t))))return!1}else if(e&&!E.validateValueType(e,t))return!1;return!0};E.VALIDATOR_KEYS=T,E.STRING_WITHOUT_TEMPLATE_VARS_VALIDATOR={valueType:"string",isValidValue:e=>!/\{\{\w*\}\}/.test(e)},h.register("ValidatorDef",E);var b=E,O=(e,t,i,r)=>{0};h.register("validate",O);var A=O;function I(e,t){var i=_.indexOf(e,t);e.splice(i,1)}a.register("arrayRemove",I);var w=I;function S(e){return e}a.register("required",S);var D=S,N=new t("tandem"),L={IO_TYPE_SUFFIX:"IO"};N.register("PhetioConstants",L);var M=L,x={OBJECT_IO_TYPE_NAME:"ObjectIO",EVENT_TYPE_MODEL:"MODEL",PHET_IO_OBJECT_METADATA_DEFAULTS:{phetioTypeName:"ObjectIO",phetioDocumentation:"",phetioState:!0,phetioReadOnly:!1,phetioEventType:"MODEL",phetioHighFrequency:!1,phetioPlayback:!1,phetioStudioControl:!0,phetioDynamicElement:!1,phetioIsArchetype:!1,phetioFeatured:!1,phetioDesigned:!1,phetioArchetypePhetioID:null}};N.register("TandemConstants",x);var V=x;class C{constructor(e){e=l({displayString:"",validator:null,compositeSchema:null},e),this.displayString=e.displayString,this.validator=e.validator,this.compositeSchema=e.compositeSchema}validateStateSchema(e){}isComposite(){return!!this.compositeSchema}checkStateObjectValid(e,t,i,r){if(this.isComposite()){var a=this.compositeSchema,n=null,s=(e,t,i,r)=>{Object.keys(e).filter(e=>e!==r).forEach(r=>{var a=t.hasOwnProperty(r);a||(n=!1),e[r].validateStateObject(t[r]),i.push(r)})};return s(a,e,i,"_private"),a._private&&s(a._private,e._private,r,null),n}return t&&A(e,this.validator),b.isValueValid(e,this.validator)}getRelatedTypes(){var e=[],t=t=>{Object.keys(t).forEach(i=>{t[i]instanceof B&&e.push(t[i])})};return this.compositeSchema&&(t(this.compositeSchema),this.compositeSchema._private&&t(this.compositeSchema._private)),e}getStateSchemaAPI(){if(this.isComposite()){var e=_.mapValues(this.compositeSchema,e=>e.typeName);return this.compositeSchema._private&&(e._private=_.mapValues(this.compositeSchema._private,e=>e.typeName)),e}return this.displayString}static asValue(e,t){return new C({validator:t,displayString:e})}}N.register("StateSchema",C);var R=C,k={validateValidator:!1},F=null,j=e=>{var t=e.indexOf(M.IO_TYPE_SUFFIX);return e.substring(0,t)};class U{constructor(e,t){var i=t.supertype||F;t.toStateObject,t.applyState,t.stateSchema;t=l({supertype:F,methods:{},events:[],metadataDefaults:{},dataDefaults:{},methodOrder:[],parameterTypes:[],documentation:"IO Type for ".concat(j(e)),isFunctionType:!1,toStateObject:i&&i.toStateObject,fromStateObject:i&&i.fromStateObject,stateToArgsForConstructor:i&&i.stateToArgsForConstructor,applyState:i&&i.applyState,stateSchema:null,addChildElement:i&&i.addChildElement},D(t)),this.supertype=i,this.typeName=e,this.documentation=t.documentation,this.methods=t.methods,this.events=t.events,this.metadataDefaults=t.metadataDefaults,this.dataDefaults=t.dataDefaults,this.methodOrder=t.methodOrder,this.parameterTypes=t.parameterTypes,this.validator=_.pick(t,b.VALIDATOR_KEYS),this.toStateObject=e=>{A(e,this.validator,"unexpected parameter to toStateObject",k);var i=t.toStateObject(e);return i},this.fromStateObject=t.fromStateObject,this.stateToArgsForConstructor=t.stateToArgsForConstructor,this.applyState=(e,i)=>{A(e,this.validator,"unexpected parameter to applyState",k),t.applyState(e,i)};var r=t.stateSchema;if(null!==r&&!(r instanceof R)){var a="function"==typeof r?r(this):r;r=new R({compositeSchema:a})}this.stateSchema=r,this.isFunctionType=t.isFunctionType,this.addChildElement=t.addChildElement;this.typeName.split(/[<(]/)[0];if(Object.values(this.methods).forEach(e=>{}),this.hasOwnProperty("methodOrder")&&this.methodOrder.forEach(e=>{}),i)i.getTypeHierarchy()}getTypeHierarchy(){for(var e=[],t=this;t;)e.push(t),t=t.supertype;return e}getAllMetadataDefaults(){return _.merge({},this.supertype?this.supertype.getAllMetadataDefaults():{},this.metadataDefaults)}getAllDataDefaults(){return _.merge({},this.supertype?this.supertype.getAllDataDefaults():{},this.dataDefaults)}isStateObjectValid(e,t=!1,i=[],r=[]){var a=!0;if(this.stateSchema){var n=this.stateSchema.checkStateObjectValid(e,t,i,r);if(null!==n)return n}if(this.supertype&&(!this.stateSchema||!this.stateSchema.isComposite()))return a&&this.supertype.isStateObjectValid(e,t,i,r);if(!this.supertype&&e&&"string"!=typeof e&&!Array.isArray(e)){var s=(e,t)=>{var n=("public"===e?i:r).includes(t);n||(a=!1)};return Object.keys(e).filter(e=>"_private"!==e).forEach(e=>s("public",e)),e._private&&Object.keys(e._private).forEach(e=>s("private",e)),a}return!0}validateStateObject(e){this.isStateObjectValid(e,!0)}static fromCoreType(e,t,i){for(var r=!1,a=t.prototype;a;)"function"==typeof a.toStateObject&&!0,"function"==typeof a.applyState&&(r=!0),a=Object.getPrototypeOf(a);return i=l({valueType:t,toStateObject:e=>e.toStateObject()},i),r&&(i.applyState=(e,t)=>e.applyState(t)),t.fromStateObject&&(i.fromStateObject=t.fromStateObject),t.STATE_SCHEMA&&(i.stateSchema=_.clone(t.STATE_SCHEMA)),t.stateToArgsForConstructor&&(i.stateToArgsForConstructor=t.stateToArgsForConstructor),new U(e,i)}}F=new U(V.OBJECT_IO_TYPE_NAME,{isValidValue:()=>!0,supertype:null,documentation:"The root of the IO Type hierarchy",toStateObject:e=>null,fromStateObject:e=>null,stateToArgsForConstructor:e=>[],applyState:(e,t)=>{},metadataDefaults:V.PHET_IO_OBJECT_METADATA_DEFAULTS,dataDefaults:{initialState:null},stateSchema:null}),U.ObjectIO=F,N.register("IOType",U);var B=U,z=new Map,H=e=>{if(!z.has(e)){var t=e=>e.name,i=e.VALUES.map(t),r=e.phetioDocumentation?" ".concat(e.phetioDocumentation):"";z.set(e,new B("EnumerationIO(".concat(i.join("|"),")"),{valueType:e,documentation:"Possible values: ".concat(i,".").concat(r),toStateObject:e=>t(e),fromStateObject:t=>e[t],stateSchema:R.asValue("".concat(i.join("|")),{isValidValue:e=>i.includes(e)})}))}return z.get(e)};a.register("EnumerationIO",H);var q=H,G=g.byKeys(["USER",V.EVENT_TYPE_MODEL,"WRAPPER","OPT_OUT"],{beforeFreeze:e=>{e.phetioType=q(e)}});N.register("EventType",G);var Y=G,W=_.hasIn(window,"phet.chipper.packageObject")?phet.chipper.packageObject:{name:"placeholder"},X=_.hasIn(window,"phet.preloads.phetio"),K=X&&phet.preloads.phetio.queryParameters.phetioPrintMissingTandems,J=!_.hasIn(W,"phet.phet-io.validation")||W.phet["phet-io"].validation,Q=window.QueryStringMachine&&QueryStringMachine.containsKey("phetioValidation"),Z=X&&Q?phet.preloads.phetio.queryParameters.phetioValidation:X&&J,$=X&&Z&&!K,ee={required:[],optional:[]},te=[],ie=[];class re{constructor(e,t,i){this.parentTandem=e,this.name=t,this.phetioID=this.parentTandem?window.phetio.PhetioIDUtils.append(this.parentTandem.phetioID,this.name):this.name,i=l({required:!0,supplied:!0},i),this.children={},this.parentTandem&&this.parentTandem.addChild(t,this),this.required=i.required,this.supplied=i.supplied,this.isDisposed=!1}getTermRegex(){return/^[a-zA-Z0-9[\],]+$/}static onMissingTandem(e){if(K&&!e.supplied){var t=(new Error).stack;e.required?ee.required.push({phetioID:this.phetioID,stack:t}):-1===t.indexOf("Font")&&ee.optional.push({phetioID:this.phetioID,stack:t})}}addPhetioObject(e){if(X){if(!this.required&&!this.supplied)return;if(re.launched)for(var t=0;t0;){var e=ie.shift();e.tandem.addPhetioObject(e)}}static unlaunch(){re.launched=!1,ie.length=0}}re.bufferedPhetioObjects=ie;re.ROOT=new class extends re{createTandem(e,t){if(re.VALIDATION)e===window.phetio.PhetioIDUtils.GLOBAL_COMPONENT_NAME||"requiredTandem"===e||"optionalTandem"===e||"test"===e||e===window.phetio.PhetioIDUtils.GENERAL_COMPONENT_NAME||_.endsWith(e,"Screen");return super.createTandem(e,t)}}(null,_.camelCase(W.name));var ae=re.ROOT.createTandem(window.phetio.PhetioIDUtils.GENERAL_COMPONENT_NAME);re.ROOT_TEST=re.ROOT.createTandem("test"),re.GENERAL_MODEL=ae.createTandem(window.phetio.PhetioIDUtils.MODEL_COMPONENT_NAME),re.GENERAL_VIEW=ae.createTandem(window.phetio.PhetioIDUtils.VIEW_COMPONENT_NAME),re.GENERAL_CONTROLLER=ae.createTandem(window.phetio.PhetioIDUtils.CONTROLLER_COMPONENT_NAME);var ne=re.ROOT.createTandem(window.phetio.PhetioIDUtils.GLOBAL_COMPONENT_NAME);re.GLOBAL_MODEL=ne.createTandem(window.phetio.PhetioIDUtils.MODEL_COMPONENT_NAME),re.GLOBAL_VIEW=ne.createTandem(window.phetio.PhetioIDUtils.VIEW_COMPONENT_NAME),re.COLORS=re.GLOBAL_VIEW.createTandem(window.phetio.PhetioIDUtils.COLORS_COMPONENT_NAME),re.OPTIONAL=re.ROOT.createTandem("optionalTandem",{required:!1,supplied:!1}),re.OPT_OUT=re.OPTIONAL,re.REQUIRED=re.ROOT.createTandem("requiredTandem",{required:$||K,supplied:!1}),re.missingTandems=ee,re.PHET_IO_ENABLED=X,re.API_GENERATION=re.PHET_IO_ENABLED&&(phet.preloads.phetio.queryParameters.phetioPrintAPI||phet.preloads.phetio.queryParameters.phetioCompareAPI),re.VALIDATION=$,re.METADATA_KEY="_metadata",re.DATA_KEY="_data";class se extends re{constructor(e,t){super(e,t),this.groupName=t,this.groupMemberIndex=0}createNextTandem(){var e=this.parentTandem.createTandem("".concat(this.groupName).concat(this.groupMemberIndex));return this.groupMemberIndex++,e}}re.launched=!1,N.register("Tandem",re);var oe=re,le=new B("ValueIO",{isValidValue:_.stubTrue,supertype:B.ObjectIO,toStateObject:e=>e,fromStateObject:e=>e,stateSchema:R.asValue("*",{isValidValue:_.stubTrue})});N.register("ValueIO",le);var he=le,pe=new B("StringIO",{supertype:he,valueType:"string",documentation:"IO Type for Javascript's string primitive type",stateSchema:R.asValue("string",{valueType:"string"})});N.register("StringIO",pe);var ue=pe,de=new B("LinkedElementIO",{isValidValue:()=>!0,documentation:"A LinkedElement",toStateObject:e=>({elementID:e.element.tandem.phetioID}),fromStateObject:e=>({}),stateSchema:{elementID:ue}});N.register("LinkedElementIO",de);var ce=de;class me extends oe{constructor(e,t,i){super(e,t,i)}getTermRegex(){return/^[a-zA-Z0-9_]+$/}getArchetypalPhetioID(){return window.phetio.PhetioIDUtils.append(this.parentTandem.getArchetypalPhetioID(),"archetype")}}me.DYNAMIC_ARCHETYPE_NAME="archetype",N.register("DynamicTandem",me);var ye=me,ge=["phetioDynamicElement","phetioEventType","phetioIsArchetype","phetioPlayback","phetioReadOnly","phetioState","phetioTypeName"];var ve=(e,t,i,r)=>{var a=t.getMetadata();ge.forEach(n=>{"phetioDynamicElement"!==n&&"phetioArchetypePhetioID"!==n&&"phetioIsArchetype"!==n&&i[n]!==a[n]&&e.assertAPIError({phetioID:t.tandem.phetioID,ruleInViolation:"5. Dynamic element metadata should match the archetype in the API.",source:r,message:"mismatched metadata: ".concat(n)})})},fe=new class{constructor(){this.apiMismatches=[],this.simHasStarted=!1,this.enabled=!1,this.everyPhetioType={}}onSimStarted(e){this.simHasStarted=!0,this.enabled&&phet.joist.sim.allScreensCreated&&this.validateOverridesFile()}onPhetioObjectRemoved(e){if(this.enabled){var t=e.tandem.phetioID;e.phetioDynamicElement||this.assertAPIError({phetioID:t,ruleInViolation:"2. Any static, registered PhetioObject can never be deregistered."})}}onPhetioObjectAdded(e){if(this.enabled){var t=e.phetioType;this.everyPhetioType[t.typeName]||(this.everyPhetioType[t.typeName]=t),this.simHasStarted&&phet.axon.animationFrameTimer.runOnNextTick(()=>{if(e.phetioDynamicElement){if(phet.preloads.phetio.createArchetypes){var t=e.tandem.getArchetypalPhetioID(),i=phet.phetio.phetioEngine.getPhetioObject(t).getMetadata();ve(this,e,i,"simulation archetype")}}else this.assertAPIError({phetioID:e.tandem.phetioID,ruleInViolation:"1. After startup, only dynamic instances prescribed by the baseline file can be registered."})})}}validateOverridesFile(){var e=phet.phetio.phetioEngine.getPhetioElementsBaseline();for(var t in window.phet.preloads.phetio.phetioElementsOverrides){t.indexOf(ye.DYNAMIC_ARCHETYPE_NAME);if(phet.preloads.phetio.createArchetypes||e.hasOwnProperty(t))if(e.hasOwnProperty(t)){var i=window.phet.preloads.phetio.phetioElementsOverrides[t],r=e[t];for(var a in 0===Object.keys(i).length&&this.assertAPIError({phetioID:t,ruleInViolation:"4. Any schema entries in the overrides file must be different from its baseline counterpart.",message:"no metadata keys found for this override."}),i)r.hasOwnProperty(a)||this.assertAPIError({phetioID:t,ruleInViolation:"8. Any schema entries in the overrides file must be different from its baseline counterpart.",message:"phetioID metadata key not found in the baseline: ".concat(a)}),i[a]===r[a]&&this.assertAPIError({phetioID:t,ruleInViolation:"8. Any schema entries in the overrides file must be different from its baseline counterpart.",message:"phetioID metadata override value is the same as the corresponding metadata value in the baseline."})}else this.assertAPIError({phetioID:t,ruleInViolation:"3. Any schema entries in the overrides file must exist in the baseline file.",message:"phetioID expected in the baseline file but does not exist"});else;}}assertAPIError(e){e.phetioID?"".concat(e.phetioID,": ").concat(e.ruleInViolation):"".concat(e.ruleInViolation);console.log("error data:",e)}};N.register("phetioAPIValidation",fe);var Te=fe,Ee=oe.PHET_IO_ENABLED,Pe=e=>e.tandem.phetioID,be={tandem:oe.OPTIONAL,phetioType:B.ObjectIO,phetioDocumentation:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioDocumentation,phetioState:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioState,phetioReadOnly:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioReadOnly,phetioEventType:Y.MODEL,phetioHighFrequency:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioHighFrequency,phetioPlayback:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioPlayback,phetioStudioControl:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioStudioControl,phetioFeatured:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioFeatured,phetioDynamicElement:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioDynamicElement,phetioDesigned:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioDesigned,phetioEventMetadata:null};class Oe{constructor(e){this.tandem=be.tandem,this.phetioObjectInitialized=!1,this.isDisposed=!1,e&&this.initializePhetioObject({},e)}initializePhetioObject(e,t){if(t.tandem&&oe.onMissingTandem(t.tandem),oe.VALIDATION&&t.tandem&&t.tandem.required,Ee&&t.tandem&&t.tandem.supplied){t=l({},be,e,t),this.phetioIsArchetype=!1,this.phetioBaselineMetadata=Te.enabled||phet.preloads.phetio.queryParameters.phetioEmitAPIBaseline?this.getMetadata(l({phetioIsArchetype:this.phetioIsArchetype},t)):null;var i=t.tandem.getArchetypalPhetioID();if(window.phet.preloads.phetio.phetioElementsOverrides){var r=window.phet.preloads.phetio.phetioElementsOverrides[i];r&&(t=l(t,r))}this.tandem=t.tandem,this._phetioType=t.phetioType,this._phetioState=t.phetioState,this._phetioReadOnly=t.phetioReadOnly,this._phetioDocumentation=t.phetioDocumentation,this._phetioEventType=t.phetioEventType,this._phetioHighFrequency=t.phetioHighFrequency,this._phetioPlayback=t.phetioPlayback,this._phetioStudioControl=t.phetioStudioControl,this._phetioDynamicElement=t.phetioDynamicElement,this._phetioFeatured=t.phetioFeatured,this._phetioEventMetadata=t.phetioEventMetadata,this._phetioDesigned=t.phetioDesigned,this.phetioArchetypePhetioID=null,this.linkedElements=[],this.phetioNotifiedObjectCreated=!1,this.phetioMessageStack=[],this._phetioPlayback&&(this._phetioEventMetadata=this._phetioEventMetadata||{},this._phetioEventMetadata.playback=!0),this.tandem.addPhetioObject(this),this.phetioObjectInitialized=!0}else t.tandem&&(this.tandem=t.tandem)}get phetioType(){return this._phetioType}get phetioState(){return this._phetioState}get phetioReadOnly(){return this._phetioReadOnly}get phetioDocumentation(){return this._phetioDocumentation}get phetioEventType(){return this._phetioEventType}get phetioHighFrequency(){return this._phetioHighFrequency}get phetioPlayback(){return this._phetioPlayback}get phetioStudioControl(){return this._phetioStudioControl}get phetioDynamicElement(){return this._phetioDynamicElement}get phetioFeatured(){return this._phetioFeatured}get phetioEventMetadata(){return this._phetioEventMetadata}get phetioDesigned(){return this._phetioDesigned}phetioStartEvent(e,t){if(Ee&&this.isPhetioInstrumented()){if(t=l({data:null,getData:null},t),this.phetioHighFrequency&&_.hasIn(window,"phet.preloads.phetio.queryParameters")&&!window.phet.preloads.phetio.queryParameters.phetioEmitHighFrequencyEvents&&!phet.phetio.dataStream.isEmittingLowFrequencyEvent()||this.phetioEventType===Y.OPT_OUT)return void this.phetioMessageStack.push(-1);var i=t.getData?t.getData():t.data;this.phetioMessageStack.push(phet.phetio.dataStream.start(this.phetioEventType,this.tandem.phetioID,this.phetioType,e,i,this.phetioEventMetadata,this.phetioHighFrequency)),this.phetioPlayback&&phet.phetio.dataStream.pushNonPlaybackable()}}phetioEndEvent(){if(Ee&&this.isPhetioInstrumented()){var e=this.phetioMessageStack.pop();if(-1===e)return;this.phetioPlayback&&phet.phetio.dataStream.popNonPlaybackable(),phet.phetio.dataStream.end(e)}}propagateDynamicFlagsToDescendants(){var e=phet.phetio.phetioEngine,t=oe.launched?[]:oe.bufferedPhetioObjects.map(Pe);this.tandem.iterateDescendants(i=>{var r=i.phetioID;if(e.hasPhetioObject(r)||!oe.launched&&t.includes(r)){var a=e.hasPhetioObject(r)?e.getPhetioObject(r):oe.bufferedPhetioObjects[t.indexOf(r)];a.phetioIsArchetype=this.phetioIsArchetype,a.setPhetioDynamicElement(this.phetioDynamicElement),a.phetioBaselineMetadata&&(a.phetioBaselineMetadata.phetioIsArchetype=this.phetioIsArchetype)}})}setPhetioDynamicElement(e){this._phetioDynamicElement=!this.phetioIsArchetype&&e,this.phetioArchetypePhetioID=e?this.tandem.getArchetypalPhetioID():null,this.phetioBaselineMetadata&&(this.phetioBaselineMetadata.phetioDynamicElement=this.phetioDynamicElement)}markDynamicElementArchetype(){this.phetioIsArchetype=!0,this.setPhetioDynamicElement(!1),this.phetioBaselineMetadata&&(this.phetioBaselineMetadata.phetioIsArchetype=this.phetioIsArchetype),oe.PHET_IO_ENABLED&&this.propagateDynamicFlagsToDescendants()}isPhetioInstrumented(){return this.tandem&&this.tandem.supplied}addLinkedElement(e,t){this.isPhetioInstrumented()?Ee&&e.isPhetioInstrumented()&&this.linkedElements.push(new Ae(e,t)):this.linkedElements=null}removeLinkedElements(e){this.isPhetioInstrumented()&&this.linkedElements&&this.linkedElements.filter(t=>t.element===e).forEach(e=>{e.dispose(),w(this.linkedElements,e)})}onSimulationConstructionCompleted(){this.phetioBaselineMetadata=null}dispose(){var e=[];if(oe.PHET_IO_ENABLED&&this.tandem.supplied){var t=phet.phetio.phetioEngine;this.tandem.iterateDescendants(i=>{t.hasPhetioObject(i.phetioID)&&e.push(t.getPhetioObject(i.phetioID))})}this.phetioObjectInitialized&&this.tandem.removePhetioObject(this),this.linkedElements&&(this.linkedElements.forEach(e=>e.dispose()),this.linkedElements.length=0),this.isDisposed=!0}getMetadata(e){var t={phetioTypeName:(e=e||this).phetioType.typeName,phetioDocumentation:e.phetioDocumentation,phetioState:e.phetioState,phetioReadOnly:e.phetioReadOnly,phetioEventType:Y.phetioType.toStateObject(e.phetioEventType),phetioHighFrequency:e.phetioHighFrequency,phetioPlayback:e.phetioPlayback,phetioStudioControl:e.phetioStudioControl,phetioDynamicElement:e.phetioDynamicElement,phetioIsArchetype:e.phetioIsArchetype,phetioFeatured:e.phetioFeatured,phetioDesigned:e.phetioDesigned};return e.phetioArchetypePhetioID&&(t.phetioArchetypePhetioID=e.phetioArchetypePhetioID),t}}Oe.DEFAULT_OPTIONS=be;class Ae extends Oe{constructor(e,t){(t=l({phetioType:ce},t)).phetioReadOnly=!0,t.phetioFeatured=e.phetioFeatured,super(t),this.element=e}getMetadata(e){var t=super.getMetadata(e);return delete t.phetioFeatured,t}}N.register("PhetioObject",Oe);var Ie=Oe,we=new B("VoidIO",{isValidValue:()=>!0,documentation:"Type for which there is no instance, usually to mark functions without a return value",toStateObject:e=>{}});N.register("VoidIO",we);var Se=we,De=[],_e=(["name","phetioType","phetioDocumentation","phetioPrivate"].concat(b.VALIDATOR_KEYS),e=>e.phetioType),Ne=e=>e.name;class Le extends Ie{constructor(e,t){var i=(t=l({parameters:De,tandem:oe.OPTIONAL,phetioOuterType:Le.ActionIO,phetioState:!1,phetioPlayback:Ie.DEFAULT_OPTIONS.phetioPlayback,phetioEventMetadata:Ie.DEFAULT_OPTIONS.phetioEventMetadata,phetioDocumentation:"A function that executes."},t)).parameters.filter(_e);t.phetioType=t.phetioOuterType(i.map(_e)),t.phetioPlayback&&(t.phetioEventMetadata=t.phetioEventMetadata||{},t.phetioEventMetadata.dataKeys=t.parameters.map(Ne)),t.phetioDocumentation=Le.getPhetioDocumentation(t.phetioDocumentation,i),super(t),this._parameters=t.parameters,this._action=e,this._phetioOuterType=t.phetioOuterType}static validateParameters(e,t){A(e,{valueType:Array});for(var i=!1,r=0;r0){t={};for(var i=0;iNo parameters.":"".concat("
The parameters are:
    ").concat(t.map(e=>{var t=e.phetioDocumentation?" - ".concat(e.phetioDocumentation):"";return"
  1. ".concat(e.name,": ").concat(e.phetioType.typeName).concat(t,"
  2. ")}).join("
    "),"
"))}execute(...e){this.phetioStartEvent("emitted",{getData:()=>this.getPhetioData(...e)}),this._action.apply(null,e),this.phetioEndEvent()}}var Me=e=>e.typeName,xe=new Map;Le.ActionIO=e=>{var t=e.map(Me).join(",");return xe.has(t)||xe.set(t,new B("ActionIO<".concat(e.map(Me).join(", "),">"),{valueType:Le,documentation:"Executes when an event occurs",events:["emitted"],parameterTypes:e,metadataDefaults:{phetioState:!1},methods:{execute:{returnType:Se,parameterTypes:e,implementation:function(...e){this.execute(...e)},documentation:"Executes the function the Action is wrapping.",invocableForReadOnlyElements:!1}}})),xe.get(t)},h.register("Action",Le);var Ve=Le,Ce=new B("BooleanIO",{supertype:he,valueType:"boolean",documentation:"IO Type for Javascript's boolean primitive type",stateSchema:R.asValue("boolean",{valueType:"boolean"})});N.register("BooleanIO",Ce);var Re=Ce,ke=new Map,Fe=e=>(ke.has(e)||ke.set(e,new B("ArrayIO<".concat(e.typeName,">"),{valueType:Array,isValidValue:t=>_.every(t,t=>b.isValueValid(t,e.validator)),parameterTypes:[e],toStateObject:t=>t.map(e.toStateObject),fromStateObject:t=>t.map(e.fromStateObject),documentation:"IO Type for the built-in JS array type, with the element type specified.",stateSchema:R.asValue("Array<".concat(e.typeName,">"),{isValidValue:t=>_.every(t,t=>e.isStateObjectValid(t))})})),ke.get(e));N.register("ArrayIO",Fe);var je=Fe,Ue=new Map,Be=(e,t)=>{for(var i=0;ie.typeName).join(","));if(!Ue.has(r)){var a=t.map(e=>e.typeName).join(", ");""===a&&(a="none");var n=t.map(e=>e.typeName).join(",");Ue.set(r,new B("FunctionIO(".concat(n,")=>").concat(e.typeName),{valueType:"function",isFunctionType:!0,parameterTypes:t.concat([e]),documentation:"".concat("Wrapper for the built-in JS function type.
Arguments: ").concat(a,"
")+"Return Type: ".concat(e.typeName)}))}return Ue.get(r)};N.register("FunctionIO",Be);var ze=Be,He=new Map,qe=e=>(He.has(e)||He.set(e,new B("NullableIO<".concat(e.typeName,">"),{documentation:"An IOType adding support for null in addition to the behavior of its parameter.",isValidValue:t=>null===t||b.isValueValid(t,e.validator),parameterTypes:[e],toStateObject:t=>null===t?null:e.toStateObject(t),fromStateObject:t=>null===t?null:e.fromStateObject(t),stateSchema:R.asValue("null|<".concat(e.typeName,">"),{isValidValue:t=>null===t||e.isStateObjectValid(t)})})),He.get(e));N.register("NullableIO",qe);var Ge=qe,Ye=e=>e.get();class We{constructor(e,t,i){this.dependencies=e,this.dependencyListeners=new Map,e.forEach(i=>{var r=()=>{this.isDisposed||t(...e.map(Ye))};this.dependencyListeners.set(i,r),i.lazyLink(r,{phetioDependencies:_.without(e,i)})}),i||t(...e.map(Ye)),this.isDisposed=!1}dispose(){for(var e=0;e{if(e instanceof ht&&!e.isDeferred){e.setDeferred(!0);var t=e.tandem.phetioID;this.phaseCallbackSets.addUndeferPhaseCallback(new Ze(t,()=>{var i=e.setDeferred(!1);this.phaseCallbackSets.addNotifyPhaseCallback(new Ze(t,i,Je.NOTIFY))},Je.UNDEFER))}}),e.stateSetEmitter.addListener(e=>{this.undeferAndNotifyProperties(new Set(Object.keys(e)))}),e.isSettingStateProperty.lazyLink(e=>{}),this.initialized=!0}validateInstrumentedProperty(e){}validatePropertyPhasePair(e,t){this.validateInstrumentedProperty(e)}getMapPairFromPhases(e,t){var i=this.mapPairs.filter(i=>e===i.beforePhase&&t===i.afterPhase);return i[0]}registerPhetioOrderDependency(e,t,i,r){oe.PHET_IO_ENABLED&&(this.validatePropertyPhasePair(e,t),this.validatePropertyPhasePair(i,r),this.getMapPairFromPhases(t,r).addOrderDependency(e.tandem.phetioID,i.tandem.phetioID))}propertyInAnOrderDependency(e){return this.validateInstrumentedProperty(e),_.some(this.mapPairs,t=>t.usesPhetioID(e.tandem.phetioID))}unregisterOrderDependenciesForProperty(e){oe.PHET_IO_ENABLED&&(this.validateInstrumentedProperty(e),this.propertyInAnOrderDependency(e)&&this.mapPairs.forEach(t=>t.unregisterOrderDependenciesForProperty(e)))}undeferAndNotifyProperties(e){for(var t={},i=0;this.phaseCallbackSets.size>0;)++i>5e3&&this.errorInUndeferAndNotifyStep(t),this.attemptToApplyPhases(Je.UNDEFER,t,e),this.attemptToApplyPhases(Je.NOTIFY,t,e)}errorInUndeferAndNotifyStep(e){var t=[];this.phaseCallbackSets.forEach(e=>t.push(e.getTerm()));var i=[];this.mapPairs.forEach(e=>{var r=e.beforeMap,a=function(e,a){a.forEach(a=>{var n=e+r.beforePhase,s=a+r.afterPhase;(t.includes(n)||t.includes(s))&&i.push({beforeTerm:n,afterTerm:s})})};for(var[n,s]of r)a(n,s)});var r="";console.log("still to be undeferred",this.phaseCallbackSets.undeferSet),console.log("still to be notified",this.phaseCallbackSets.notifySet),console.log("order dependencies that apply to the still todos",i),i.forEach(e=>{r+="".concat(e.beforeTerm,"\t").concat(e.afterTerm,"\n")}),console.log("\n\nin graphable form:\n\n",r);var a="Impossible set state: from undeferAndNotifyProperties; ordering constraints cannot be satisfied";throw new Error(a)}getNumberOfOrderDependencies(){var e=0;return this.mapPairs.forEach(t=>{t.afterMap.forEach(t=>{e+=t.size})}),e}attemptToApplyPhases(e,t,i){var r=this.phaseCallbackSets.getSetFromPhase(e);for(var a of r)this.phetioIDCanApplyPhase(a.phetioID,e,t,i)&&(a.listener(),r.delete(a),t[a.getTerm()]=!0)}phetioIDCanApplyPhase(e,t,i,r){if(t===Je.NOTIFY&&!i[e+Je.UNDEFER])return!1;var a=[];this.mapPairs.forEach(e=>{e.afterPhase===t&&a.push(e.afterMap)});for(var n=0;n{e.has(t)&&e.get(t).forEach(i=>{var r=e.otherMap.get(i);r&&r.delete(t),0===r.size&&e.otherMap.delete(i)}),e.delete(t)})}usesPhetioID(e){return this.beforeMap.has(e)||this.afterMap.has(e)}}class et{constructor(){this.undeferSet=new Set,this.notifySet=new Set}get size(){return this.undeferSet.size+this.notifySet.size}forEach(e){this.undeferSet.forEach(e),this.notifySet.forEach(e)}addUndeferPhaseCallback(e){this.undeferSet.add(e)}addNotifyPhaseCallback(e){this.notifySet.add(e)}getSetFromPhase(e){return e===Je.NOTIFY?this.notifySet:this.undeferSet}}h.register("PropertyStateHandler",Qe);var tt=new Qe;h.register("propertyStateHandlerSingleton",tt);var it=tt;class rt extends u{constructor(e,t){super(t),this._value=e}get(){return this._value}get value(){return this.get()}set(e){if(!this.equalsValue(e)){var t=this._value;this.setPropertyValue(e),this.notifyListeners(t)}return this}set value(e){this.set(e)}setPropertyValue(e){this._value=e}equalsValue(e){return this.areValuesEqual(e,this._value)}areValuesEqual(e,t){return this.useDeepEquality&&e&&t&&e.constructor===t.constructor?e.equals(t):e===t}notifyListeners(e){this.emit(this._value,e,this)}link(e){this.addListener(e),e(this._value,null,this)}lazyLink(e){this.addListener(e)}unlink(e){this.removeListener(e)}unlinkAll(){this.removeAllListeners()}linkAttribute(e,t){var i=i=>{e[t]=i};return this.link(i),i}unlinkAttribute(e){this.unlink(e)}isPhetioInstrumented(){return!1}isSettable(){return!0}dispose(){this.unlinkAll(),super.dispose()}}h.register("TinyProperty",rt);var at=rt,nt={values:["%","A","AMU","atm","cm","cm^2","C","°","°C","F","g","Hz","J","K","kg","kg/m^3","kg·m/s","kPa","L","L/s","m","m^3","m/s","m/s/s","m/s^2","mA","mm","mol","mol/L","N","N/m","nm","nm/ps","N·s/m","Ω","Ω·cm","Pa·s","particles/ps","pm","pm/ps","pm/s","pm/s^2","pm^3","ps","radians","radians/s","s","V","view-coordinates/s"],isValidUnits:function(e){return _.includes(nt.values,e)}};h.register("units",nt);var st=0;class ot extends Ie{constructor(e,t){t=l({tandem:oe.OPTIONAL,useDeepEquality:!1,units:null,reentrant:!1,onBeforeNotify:null},t),b.containsValidatorKey(t)||(t.isValidValue=()=>!0),t.units&&(t.phetioEventMetadata=t.phetioEventMetadata||{},t.phetioEventMetadata.units=t.units),super(t),this.id=st++,this.units=t.units,oe.VALIDATION&&this.isPhetioInstrumented(),this._initialValue=e,this.validValues=t.validValues,this.tinyProperty=new at(e,t.onBeforeNotify),this.tinyProperty.useDeepEquality=t.useDeepEquality,this.notifying=!1,this.reentrant=t.reentrant,this.isDeferred=!1,this.deferredValue=null,this.hasDeferredValue=!1}isSettable(){return!0}get(){return this.tinyProperty.get()}set(e){if(!this.isDisposed)if(this.isDeferred)this.deferredValue=e,this.hasDeferredValue=!0;else if(!this.equalsValue(e)){var t=this.get();this.setPropertyValue(e),this._notifyListeners(t)}return this}setPropertyValue(e){this.tinyProperty.setPropertyValue(e)}setInitialValue(e){this._initialValue=e}equalsValue(e){return this.areValuesEqual(e,this.get())}areValuesEqual(e,t){return this.tinyProperty.areValuesEqual(e,t)}getInitialValue(){return this._initialValue}get initialValue(){return this.getInitialValue()}_notifyListeners(e){var t=this.get();this.phetioStartEvent(ot.CHANGED_EVENT_NAME,{getData:()=>{var i=this.phetioType.parameterTypes[0];return{oldValue:Ge(i).toStateObject(e),newValue:i.toStateObject(t)}}}),this.notifying=!0,this.tinyProperty.emit(t,e,this),this.notifying=!1,this.phetioEndEvent()}notifyListenersStatic(){this._notifyListeners(null)}setDeferred(e){if(e)this.isDeferred=!0;else{this.isDeferred=!1;var t=this.get();if(this.hasDeferredValue&&(this.setPropertyValue(this.deferredValue),this.hasDeferredValue=!1),!this.equalsValue(t))return()=>!this.isDisposed&&this._notifyListeners(t)}return null}reset(){this.set(this._initialValue)}get value(){return this.get()}set value(e){this.set(e)}addPhetioStateDependencies(e){for(var t=0;t{e[t]=i};return this.link(i),i}unlinkAttribute(e){this.unlink(e)}toString(){return"Property#".concat(this.id,"{").concat(this.get(),"}")}valueOf(){return this.toString()}debug(e){var t=t=>console.log(e,t);return this.link(t),t}toggle(){this.value=!this.value}dispose(){this.isPhetioInstrumented()&&it.unregisterOrderDependenciesForProperty(this),super.dispose(),this.tinyProperty.dispose()}hasListener(e){return this.tinyProperty.hasListener(e)}getListenerCount(){return this.tinyProperty.getListenerCount()}forEachListener(e){this.tinyProperty.forEachListener(e)}hasListeners(){return this.tinyProperty.hasListeners()}static multilink(e,t){return new Xe(e,t,!1)}static lazyMultilink(e,t){return new Xe(e,t,!0)}static unmultilink(e){e.dispose()}}ot.CHANGED_EVENT_NAME="changed";var lt=new Map;ot.PropertyIO=e=>(lt.has(e)||lt.set(e,new B("PropertyIO<".concat(e.typeName,">"),{valueType:ot,documentation:"Observable values that send out notifications when the value changes. This differs from the traditional listener pattern in that added listeners also receive a callback with the current value when the listeners are registered. This is a widely-used pattern in PhET-iO simulations.",methodOrder:["link","lazyLink"],events:["changed"],parameterTypes:[e],toStateObject:t=>{var i={value:e.toStateObject(t.value)};return t.validValues?i.validValues=t.validValues.map(t=>e.toStateObject(t)):i.validValues=null,i.units=Ge(ue).toStateObject(t.units),i},applyState:(t,i)=>{t.units=Ge(ue).fromStateObject(i.units),t.set(e.fromStateObject(i.value)),i.validValues&&(t.validValues=i.validValues.map(t=>e.fromStateObject(t)))},stateSchema:{value:e,validValues:Ge(je(e)),units:Ge(ue)},methods:{getValue:{returnType:e,parameterTypes:[],implementation:function(){return this.get()},documentation:"Gets the current value."},setValue:{returnType:Se,parameterTypes:[e],implementation:function(e){this.set(e)},documentation:"Sets the value of the Property. If the value differs from the previous value, listeners are notified with the new value.",invocableForReadOnlyElements:!1},link:{returnType:Se,parameterTypes:[ze(Se,[e,Ge(e)])],implementation:function(e){this.link(e)},documentation:"Adds a listener which will be called when the value changes. On registration, the listener is also called with the current value. The listener takes two arguments, the new value and the previous value."},lazyLink:{returnType:Se,parameterTypes:[ze(Se,[e,Ge(e)])],implementation:function(e){this.lazyLink(e)},documentation:'Adds a listener which will be called when the value changes. This method is like "link", but without the current-value callback on registration. The listener takes two arguments, the new value and the previous value.'},unlink:{returnType:Se,parameterTypes:[ze(Se,[e])],implementation:function(e){this.unlink(e)},documentation:"Removes a listener."}}})),lt.get(e)),h.register("Property",ot);var ht=ot,pt=ht.PropertyIO(Re);class ut extends ht{constructor(e,t){super(e,t=l({valueType:"boolean",phetioType:pt},t))}}h.register("BooleanProperty",ut);var dt=ut,ct=new c;h.register("stepTimer",ct);var mt=ct;class yt{constructor(e){e=l({callback:null,delay:400,interval:100},e),this.delay=e.delay,this.interval=e.interval,this.callbacks=[],e.callback&&this.callbacks.push(e.callback),this.delayID=null,this.intervalID=null,this.fired=!1}isRunning(){return null!==this.delayID||null!==this.intervalID}start(){this.isRunning()||(this.fired=!1,this.delayID=mt.setTimeout(()=>{this.delayID=null,this.intervalID=mt.setInterval(()=>this.fire(),this.interval),this.fire()},this.delay))}stop(e){this.isRunning()&&(this.delayID&&(mt.clearTimeout(this.delayID),this.delayID=null),this.intervalID&&(mt.clearInterval(this.intervalID),this.intervalID=null),e&&!this.fired&&this.fire())}addCallback(e){-1===this.callbacks.indexOf(e)&&this.callbacks.push(e)}removeCallback(e){var t=this.callbacks.indexOf(e);-1!==t&&this.callbacks.splice(t,1)}fire(){for(var e=this.callbacks.slice(0),t=0;te(...t.map(e=>e.get()));class vt extends ht{constructor(e,t,i){i=l({tandem:oe.OPTIONAL,phetioReadOnly:!0},i),super(gt(t,e),i),oe.VALIDATION&&this.isPhetioInstrumented(),this.dependencies=e,this._initialValue=null,this.derivation=t,this.derivedPropertyListener=this.getDerivedPropertyListener.bind(this),e.forEach(e=>{e.lazyLink(this.derivedPropertyListener),e instanceof ht&&this.isPhetioInstrumented()&&e.isPhetioInstrumented()&&it.registerPhetioOrderDependency(e,Je.UNDEFER,this,Je.UNDEFER)})}isSettable(){return!1}getDerivedPropertyListener(){this.isDeferred?this.hasDeferredValue=!0:super.set(gt(this.derivation,this.dependencies))}dispose(){for(var e=0;e!e,t)}}var ft=(e,t)=>e===t,Tt=(e,t)=>e&&t.value,Et=(e,t)=>e||t.value,Pt=new Map;vt.DerivedPropertyIO=e=>(Pt.has(e)||Pt.set(e,new B("".concat("DerivedPropertyIO","<").concat(e.typeName,">"),{valueType:vt,parameterTypes:[e],supertype:ht.PropertyIO(e),documentation:"Like PropertyIO, but not settable. Instead it is derived from other DerivedPropertyIO or PropertyIO instances",applyState:()=>{},methods:{setValue:{returnType:Se,parameterTypes:[e],implementation:function(e){return this.set(e)},documentation:"Errors out when you try to set a derived property.",invocableForReadOnlyElements:!1}}})),Pt.get(e)),h.register("DerivedProperty",vt);class bt extends ht{constructor(e,t){var i="string"==typeof(t=l({bidirectional:!1,defaultValue:null,derive:_.identity,map:_.identity,inverseMap:_.identity},t)).derive?_.property(t.derive):t.derive,r="string"==typeof t.map?_.property(t.map):t.map;super(null===e.value?r(t.defaultValue):r(i(e.value).value),t),this.defaultValue=t.defaultValue,this.derive=i,this.map=r,this.inverseMap="string"==typeof t.inverseMap?_.property(t.inverseMap):t.inverseMap,this.bidirectional=t.bidirectional,this.valuePropertyProperty=e,this.isExternallyChanging=!1,this.bidirectional||(this._initialValue=null),this.propertyPropertyListener=this.onPropertyPropertyChange.bind(this),this.propertyListener=this.onPropertyChange.bind(this),e.link(this.propertyListener),t.bidirectional&&this.lazyLink(this.onSelfChange.bind(this))}onPropertyPropertyChange(e,t,i){if(this.bidirectional&&null!==this.valuePropertyProperty.value&&i&&(this.derive(this.valuePropertyProperty.value)===i&&i.equalsValue(this.inverseMap(this.value))))return;super.set(this.map(e))}onPropertyChange(e,t){t&&this.derive(t).unlink(this.propertyPropertyListener),e?this.derive(e).link(this.propertyPropertyListener):this.onPropertyPropertyChange(this.defaultValue,null,null)}onSelfChange(e){if(null!==this.valuePropertyProperty.value){var t=this.derive(this.valuePropertyProperty.value);this.areValuesEqual(e,this.map(t.value))||(t.value=this.inverseMap(e))}}dispose(){this.valuePropertyProperty.unlink(this.propertyListener),null!==this.valuePropertyProperty.value&&this.derive(this.valuePropertyProperty.value).unlink(this.propertyPropertyListener),super.dispose()}reset(){null!==this.valuePropertyProperty.value&&this.derive(this.valuePropertyProperty.value).reset()}getInitialValue(){return super.getInitialValue()}set(e){this.isExternallyChanging=!0,super.set(e),this.isExternallyChanging=!1}isSettable(){return super.isSettable()&&this.bidirectional}}h.register("DynamicProperty",bt);class Ot extends Ve{constructor(e){super((...e)=>{t.tinyEmitter.emit(...e)},e=l({phetioOuterType:Ot.EmitterIO,onBeforeNotify:null},e));var t=this;this.tinyEmitter=new u(e.onBeforeNotify)}execute(){}emit(...e){super.execute.apply(this,e)}dispose(){this.tinyEmitter.dispose(),super.dispose()}addListener(e){this.tinyEmitter.addListener(e)}removeListener(e){this.tinyEmitter.removeListener(e)}removeAllListeners(){this.tinyEmitter.removeAllListeners()}hasListener(e){return this.tinyEmitter.hasListener(e)}hasListeners(){return this.tinyEmitter.hasListeners()}getListenerCount(){return this.tinyEmitter.getListenerCount()}}var At=e=>e.typeName,It=new Map;Ot.EmitterIO=e=>{var t=e.map(At).join(",");return It.has(t)||It.set(t,new B("EmitterIO<".concat(e.map(At).join(", "),">"),{valueType:Ot,supertype:Ve.ActionIO(e),documentation:"Emits when an event occurs and calls added listeners.",parameterTypes:e,methods:{addListener:{returnType:Se,parameterTypes:[ze(Se,e)],implementation:function(e){this.addListener(e)},documentation:"Adds a listener which will be called when the emitter emits."},removeListener:{returnType:Se,parameterTypes:[ze(Se,e)],implementation:function(e){this.removeListener(e)},documentation:"Remove a listener."},emit:{returnType:Se,parameterTypes:e,implementation:function(...e){this.emit(...e)},documentation:"Emits a single event to all listeners.",invocableForReadOnlyElements:!1}}})),It.get(t)},h.register("Emitter",Ot);var wt=Ot;class St extends ht{constructor(e,t,i){super(t,i=l({valueType:e,phetioType:ht.PropertyIO(q(e)),validValues:e.VALUES},i)),this.enumeration=e}}h.register("EnumerationProperty",St);var Dt=new B("NumberIO",{valueType:"number",documentation:"IO Type for Javascript's number primitive type",toStateObject:e=>e===Number.POSITIVE_INFINITY?"POSITIVE_INFINITY":e===Number.NEGATIVE_INFINITY?"NEGATIVE_INFINITY":e,fromStateObject:e=>"POSITIVE_INFINITY"===e?Number.POSITIVE_INFINITY:"NEGATIVE_INFINITY"===e?Number.NEGATIVE_INFINITY:e,stateSchema:R.asValue("'POSITIVE_INFINITY'|'NEGATIVE_INFINITY'|number",{isValidValue:e=>"POSITIVE_INFINITY"===e||"NEGATIVE_INFINITY"===e||"number"==typeof e})});N.register("NumberIO",Dt);var _t=Dt,Nt=new t("dot");Nt.register("v2",(e,t)=>new Nt.Vector2(e,t)),Nt.register("v3",(e,t,i)=>new Nt.Vector3(e,t,i)),Nt.register("v4",(e,t,i,r)=>new Nt.Vector4(e,t,i,r)),Nt.register("FastArray",window.Float64Array?window.Float64Array:window.Array);var Lt=Nt;class Mt{constructor(e,t){this._min=e,this._max=t}getMin(){return this._min}get min(){return this.getMin()}setMin(e){this._min=e}set min(e){this.setMin(e)}getMax(){return this._max}get max(){return this.getMax()}setMax(e){this._max=e}set max(e){this.setMax(e)}setMinMax(e,t){this._min=e,this._max=t}copy(){return new Mt(this._min,this._max)}getLength(){return this._max-this._min}getCenter(){return(this._max+this._min)/2}contains(e){return e>=this._min&&e<=this._max}containsRange(e){return this._min<=e.min&&this._max>=e.max}intersects(e){return this._max>=e.min&&e.max>=this._min}intersectsExclusive(e){return this._max>e.min&&e.max>this._min}toString(){return"[Range (min:".concat(this._min," max:").concat(this._max,")]")}constrainValue(e){return Math.min(Math.max(e,this._min),this._max)}equals(e){return this.constructor===e.constructor&&this._min===e.min&&this._max===e.max}getNormalizedValue(e){return(e-this.min)/this.getLength()}get defaultValue(){throw new Error("defaultValue is undefined, did you mean to use RangeWithValue?")}}Lt.register("Range",Mt),Mt.RangeIO=new B("RangeIO",{valueType:Mt,documentation:'A range with "min" and a "max" members.',toStateObject:e=>({min:_t.toStateObject(e.min),max:_t.toStateObject(e.max)}),fromStateObject:e=>new Mt(_t.fromStateObject(e.min),_t.fromStateObject(e.max)),stateSchema:{min:_t,max:_t}});var xt=Mt,Vt=["FloatingPoint","Integer"],Ct=ht.PropertyIO(_t);class Rt extends ht{constructor(e,t){t=l({numberType:"FloatingPoint",range:null,step:null,rangePropertyOptions:{phetioDocumentation:"provides the range of possible values for the parent NumberProperty",phetioType:ht.PropertyIO(Ge(xt.RangeIO)),phetioReadOnly:!0},tandem:oe.OPTIONAL},t),(t=l({rangePropertyOptions:{tandem:t.tandem.createTandem("rangeProperty")}},t)).valueType="number",t.phetioType=Rt.NumberPropertyIO;var i=!(t.range&&t.range instanceof ht);super(e,t),this.numberType=t.numberType,this.step=t.step,this.validateNumberProperty=!1,this.rangeProperty=null,this.rangeProperty=i?new ht(t.range,t.rangePropertyOptions):t.range;var r=e=>{this.validateNumberProperty&&this.validateNumberProperty(this.value)};this.rangeProperty.link(r),this.rangeProperty.addPhetioStateDependencies([this]),this.addPhetioStateDependencies([this.rangeProperty]),t.validValues&&this.validateNumberProperty&&t.validValues.forEach(e=>this.validateNumberProperty(e)),this.validateNumberProperty&&this.link(e=>{this.validateNumberProperty(e)}),this.disposeNumberProperty=()=>{i?this.rangeProperty.dispose():this.rangeProperty.unlink(r)},this.resetNumberProperty=()=>{i&&this.rangeProperty.reset()}}get range(){return this.rangeProperty.value}set range(e){this.rangeProperty.value=e}reset(){super.reset(),this.resetNumberProperty()}dispose(){this.disposeNumberProperty(),super.dispose()}setValueAndRange(e,t){this.setDeferred(!0),this.rangeProperty.setDeferred(!0),this.set(e),this.rangeProperty.set(t);var i=this.setDeferred(!1),r=this.rangeProperty.setDeferred(!1);i&&i(),r&&r()}resetValueAndRange(){this.setValueAndRange(this.initialValue,this.rangeProperty.initialValue)}}Rt.NumberPropertyIO=new B("NumberPropertyIO",{valueType:Rt,supertype:Ct,parameterTypes:[_t],documentation:"Extends PropertyIO to add values for the numeric range ( min, max ) and numberType ( '".concat(Vt.join("' | '"),"' )"),toStateObject:e=>{var t=Ct.toStateObject(e);t.numberType=ue.toStateObject(e.numberType),t.range=Ge(xt.RangeIO).toStateObject(e.rangeProperty.value);var i=e.rangeProperty&&e.rangeProperty.isPhetioInstrumented();return t.rangePhetioID=i?ue.toStateObject(e.rangeProperty.tandem.phetioID):null,t.step=Ge(_t).toStateObject(e.step),t},applyState:(e,t)=>{Ct.applyState(e,t),e.step=t.step,e.numberType=t.numberType},stateSchema:{numberType:ue,range:Ge(xt.RangeIO),rangePhetioID:Ge(ue),step:Ge(_t),value:_t}}),h.register("NumberProperty",Rt);var kt=Rt,Ft=e=>{s(e,["length"],["elements"]);var t=null;if((e=l({length:0,elements:[],tandem:oe.OPTIONAL},e)).phetioType)t={name:"value",phetioType:e.phetioType.parameterTypes[0]};else if(b.isValidValidator(e)){var i=_.pick(e,b.VALIDATOR_KEYS);t=l({name:"value"},i)}else t=l({name:"value"},{isValidValue:_.stubTrue});var r=new wt({tandem:e.tandem.createTandem("elementAddedEmitter"),parameters:[t]}),a=new wt({tandem:e.tandem.createTandem("elementRemovedEmitter"),parameters:[t]}),n=new kt(0,{numberType:"Integer",tandem:e.tandem.createTandem("lengthProperty"),phetioReadOnly:!0}),o=[],h=new Proxy(o,{get:function(e,t,i){return Ut.hasOwnProperty(t)?Ut[t]:Reflect.get(e,t,i)},set:function(e,t,i){var s=e[t],o=null;"length"===t&&(o=e.slice(i));var l=Reflect.set(e,t,i),h=Number(t);return Number.isInteger(h)&&h>=0&&s!==i?(n.value=e.length,void 0!==s&&a.emit(e[t]),void 0!==i&&r.emit(i)):"length"===t&&(n.value=i,o&&o.forEach(e=>a.emit(e))),l},deleteProperty:function(e,t){var i,r=Number(t);Number.isInteger(r)&&r>=0&&(i=e[t]);var n=Reflect.deleteProperty(e,t);return void 0!==i&&a.emit(i),n}});h.targetArray=o,h.elementAddedEmitter=r,h.elementRemovedEmitter=a,h.lengthProperty=n;var p=()=>{e.length>=0&&(h.length=e.length),e.elements.length>0&&Array.prototype.push.apply(h,e.elements)};return p(),h.reset=()=>{h.length=0,p()},e.tandem.supplied&&(h.phetioElementType=e.phetioType.parameterTypes[0],h.observableArrayPhetioObject=new jt(h,e)),h};class jt extends Ie{constructor(e,t){super(t=l({phetioType:Ht},t)),this.observableArray=e}}var Ut={pop(...e){var t=this.targetArray.length,i=Array.prototype.pop.apply(this.targetArray,e);return this.lengthProperty.value=this.length,t>0&&this.elementRemovedEmitter.emit(i),i},shift(...e){var t=this.targetArray.length,i=Array.prototype.shift.apply(this.targetArray,e);return this.lengthProperty.value=this.length,t>0&&this.elementRemovedEmitter.emit(i),i},push(...e){var t=Array.prototype.push.apply(this.targetArray,e);this.lengthProperty.value=this.length;for(var i=0;ithis.elementRemovedEmitter.emit(e)),t},copyWithin(...e){var t=this.targetArray.slice(),i=Array.prototype.copyWithin.apply(this.targetArray,e);return Bt(t,this),i},fill(...e){var t=this.targetArray.slice(),i=Array.prototype.fill.apply(this.targetArray,e);return Bt(t,this),i},get:function(e){return this[e]},addItemAddedListener:function(e){this.elementAddedEmitter.addListener(e)},removeItemAddedListener:function(e){this.elementAddedEmitter.removeListener(e)},addItemRemovedListener:function(e){this.elementRemovedEmitter.addListener(e)},removeItemRemovedListener:function(e){this.elementRemovedEmitter.removeListener(e)},add:function(e){this.push(e)},addAll:function(e){this.push(...e)},remove:function(e){w(this,e)},removeAll:function(e){e.forEach(e=>w(this,e))},clear:function(){for(;this.length>0;)this.pop()},count:function(e){for(var t=0,i=0;ithis.phetioElementType.toStateObject(e))}},applyState:function(e){this.length=0;var t=e.array.map(e=>this.phetioElementType.fromStateObject(e));this.push(...t)}},Bt=(e,t)=>{for(var i=e,r=t.targetArray.slice(),a=0;a=0&&(i.splice(a,1),r.splice(s,1),a--)}i.forEach(e=>t.elementRemovedEmitter.emit(e)),r.forEach(e=>t.elementAddedEmitter.emit(e))},zt=new Map,Ht=e=>(zt.has(e)||zt.set(e,new B("ObservableArrayIO<".concat(e.typeName,">"),{valueType:jt,parameterTypes:[e],toStateObject:e=>e.observableArray.toStateObject(),applyState:(e,t)=>e.observableArray.applyState(t),stateSchema:{array:je(e)}})),zt.get(e));Ft.ObservableArrayIO=Ht,h.register("createObservableArray",Ft);var qt=ht.PropertyIO(ue);class Gt extends ht{constructor(e,t){super(e,t=l({valueType:"string",phetioType:qt},t))}}h.register("StringProperty",Gt);class Yt extends at{constructor(e,t,i){super(e,i),t&&(this.targetPropertyInstrumented=t)}setTargetProperty(e,t,i){if(this.targetProperty===i)return e;this.targetProperty&&this.targetProperty.isPhetioInstrumented();var r=this.targetProperty;this.ownedPhetioProperty&&i!==this.ownedPhetioProperty&&this.disposeOwnedPhetioProperty(),e&&e.updateLinkedElementForProperty(t,r,i),this.forwardingListener=this.forwardingListener||this.onTargetPropertyChange.bind(this);var a=this.get();this.targetProperty&&this.targetProperty.unlink(this.forwardingListener),this.targetProperty=i,this.targetProperty?this.targetProperty.lazyLink(this.forwardingListener):this._value=a;var n=this.get();return this.areValuesEqual(a,n)||this.notifyListeners(a),e}onTargetPropertyChange(e,t){this.notifyListeners(t)}get(){return this.targetProperty?this.targetProperty.value:super.get()}set(e){return this.targetProperty?this.targetProperty.set(e):super.set(e),this}notifyListeners(e){this.emit(this.get(),e,this)}link(e){this.addListener(e),e(this.get(),null,this)}setTargetPropertyInstrumented(e,t){return this.targetPropertyInstrumented=e,t}getTargetPropertyInstrumented(){return this.targetPropertyInstrumented}initializePhetio(e,t,i){!this.targetProperty&&this.targetPropertyInstrumented?(this.ownedPhetioProperty=i(),this.setTargetProperty(e,t,this.ownedPhetioProperty)):this.targetProperty&&this.targetProperty.isPhetioInstrumented()&&e.updateLinkedElementForProperty(t,null,this.targetProperty)}disposeOwnedPhetioProperty(){this.ownedPhetioProperty&&(this.ownedPhetioProperty.dispose(),delete this.ownedPhetioProperty)}dispose(){this.targetProperty&&this.targetProperty.unlink(this.forwardingListener),this.disposeOwnedPhetioProperty(),super.dispose()}}h.register("TinyForwardingProperty",Yt);class Wt extends at{constructor(e,t){super(e),this.onAccessAttempt=t}get(){return this.onAccessAttempt(),super.get()}set(e){throw new Error("Cannot set a TinyStaticProperty value")}isSettable(){return!1}notifyListeners(e){this.emit(this.get(),e,this)}link(e){this.addListener(e),e(this.get(),null,this)}equalsValue(e){return this.areValuesEqual(e,this.get())}}h.register("TinyStaticProperty",Wt);function Xt(e,t,i,r,a){i=i||[],r=r||[],a=a||[],Array.prototype.push.apply(i,e),Array.prototype.push.apply(r,t);e:for(var n=0;n{t.push(e)}),t}a.register("collect",Jt);function Qt(e,t){return void 0!==e[t]?t:(t=t.charAt(0).toUpperCase()+t.slice(1),void 0!==e["moz".concat(t)]?"moz".concat(t):void 0!==e["Moz".concat(t)]?"Moz".concat(t):void 0!==e["webkit".concat(t)]?"webkit".concat(t):void 0!==e["ms".concat(t)]?"ms".concat(t):void 0!==e["o".concat(t)]?"o".concat(t):void 0)}a.register("detectPrefix",Qt);function Zt(e,t,i){return void 0!==e["on".concat(t)]?t:void 0!==e["".concat("onmoz").concat(t)]?"moz".concat(t):void 0!==e["".concat("onMoz").concat(t)]?"Moz".concat(t):void 0!==e["".concat("onwebkit").concat(t)]?"webkit".concat(t):void 0!==e["".concat("onms").concat(t)]?"ms".concat(t):void 0!==e["".concat("ono").concat(t)]?"o".concat(t):void 0}a.register("detectPrefixEvent",Zt);function $t(e,t,i){var r=[];return function e(t,a){return a.forEach((a,n)=>{r.push(n),1===t?i(...[a].concat(r)):e(t-1,a),r.pop()})}(e,t)}a.register("dimensionForEach",$t);function ei(e,t,i){var r=[];return function e(t,a){return a.map((a,n)=>{r.push(n);var s=1===t?i(...[a].concat(r)):e(t-1,a);return r.pop(),s})}(e,t)}a.register("dimensionMap",ei);class ti{constructor(e,t){this._enumeration=e,e.VALUES.forEach(e=>{this[e]=t(e)})}get(e){return this[e]}set(e,t){this[e]=t}map(e){return new ti(this._enumeration,t=>e(this.get(t),t))}forEach(e){this._enumeration.VALUES.forEach(t=>e(this.get(t),t))}values(){return this._enumeration.VALUES.map(e=>this.get(e))}}a.register("EnumerationMap",ti);var ii=ti;function ri(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}a.register("escapeHTML",ri);class ai{constructor(e,t){this.eventModel=e,this.eventCallback=t,this.period=this.eventModel.getPeriodBeforeNextEvent(),this.timeBeforeNextEvent=this.period}step(e){for(;e>=this.timeBeforeNextEvent;)e-=this.timeBeforeNextEvent,this.period=this.eventModel.getPeriodBeforeNextEvent(),this.timeBeforeNextEvent=this.period,this.eventCallback(e);this.timeBeforeNextEvent-=e}getRatio(){return(this.period-this.timeBeforeNextEvent)/this.period}}a.register("EventTimer",ai);ai.ConstantEventModel=class{constructor(e){this.rate=e}getPeriodBeforeNextEvent(){return 1/this.rate}};ai.UniformEventModel=class{constructor(e,t){this.rate=e,this.pseudoRandomNumberSource=t}getPeriodBeforeNextEvent(){var e=this.pseudoRandomNumberSource();return 2*e/this.rate}};ai.PoissonEventModel=class{constructor(e,t){this.rate=e,this.pseudoRandomNumberSource=t}getPeriodBeforeNextEvent(){var e=this.pseudoRandomNumberSource();return-Math.log(e)/this.rate}};function ni(e){return _.each(Array.prototype.slice.call(arguments,1),t=>{if(t)for(var i in t)Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}a.register("extend",ni);var si=ni;function oi(e){return _.each(Array.prototype.slice.call(arguments,1),t=>{if(t)for(var i in t){var r=Object.getOwnPropertyDescriptor(t,i);!r||"function"!=typeof r.get&&void 0===t[i]||Object.defineProperty(e,i,r)}}),e}a.register("extendDefined",oi);function li(e){for(var t=[e],i=e.prototype;i&&(i=Object.getPrototypeOf(i));)i.constructor&&t.push(i.constructor);return t}a.register("inheritance",li);var hi=li;function pi(e,t){for(var i=[],r=2*e.length-1,a=0;a{if(t.has(i))return t.get(i);var r=e(i);return t.set(i,r),r}}a.register("memoize",ci);function mi(e,t,i){i&&_.each(t,t=>{void 0!==i[t]&&(e[t]=i[t])})}a.register("mutate",mi);function yi(e){var t=window.open(e,"_blank");t&&t.focus()}a.register("openPopup",yi);class gi{constructor(e,t,i,r,a,n,s,o,l,h,p){this.coordinate=e,this.centerCoordinate=t,this.minSide=i,this.maxSide=r,this.rectCoordinate=a,this.rectSize=n,this.layoutBoxOrientation=s,this.size=o,this.ariaOrientation=s,this.modelToView=l,this.viewToModel=h,this.toVector=p,this.opposite=null}}var vi=new gi("x","centerX","left","right","rectX","rectWidth","horizontal","width",(e,t)=>e.modelToViewX(t),(e,t)=>e.viewToModelX(t),(e,t,i)=>new i(e,t)),fi=new gi("y","centerY","top","bottom","rectY","rectHeight","vertical","height",(e,t)=>e.modelToViewY(t),(e,t)=>e.viewToModelY(t),(e,t,i)=>new i(t,e));vi.opposite=fi,fi.opposite=vi;var Ti=g.byMap({HORIZONTAL:vi,VERTICAL:fi});a.register("Orientation",Ti);var Ei=Ti;class Pi extends ii{constructor(e,t){super(Ei,i=>i===Ei.HORIZONTAL?e:t)}get horizontal(){return this.get(Ei.HORIZONTAL)}set horizontal(e){this.set(Ei.HORIZONTAL,e)}get vertical(){return this.get(Ei.VERTICAL)}set vertical(e){this.set(Ei.VERTICAL,e)}static create(e){return new Pi(e(Ei.HORIZONTAL),e(Ei.VERTICAL))}}a.register("OrientationPair",Pi);function bi(e){var t=[],i=e.length;if(i>1)for(var r=0;r=2)&&Ai.match(/AppleWebKit/))}function Si(){var e=-1;return"Microsoft Internet Explorer"===navigator.appName?null!==new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(Ai)&&(e=parseFloat(RegExp.$1)):"Netscape"===navigator.appName&&null!==new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})").exec(Ai)&&(e=parseFloat(RegExp.$1)),e}var Di={firefox:Ai.toLowerCase().indexOf("firefox")>-1,mobileSafari:wi(),safari5:!!(Ai.match(/Version\/5\./)&&Ai.match(/Safari\//)&&Ai.match(/AppleWebKit/)),safari6:!!(Ai.match(/Version\/6\./)&&Ai.match(/Safari\//)&&Ai.match(/AppleWebKit/)),safari7:!!(Ai.match(/Version\/7\./)&&Ai.match(/Safari\//)&&Ai.match(/AppleWebKit/)),safari10:!!(Ai.match(/Version\/10\./)&&Ai.match(/Safari\//)&&Ai.match(/AppleWebKit/)),safari11:!!(Ai.match(/Version\/11\./)&&Ai.match(/Safari\//)&&Ai.match(/AppleWebKit/)),safari9:!!(Ai.match(/Version\/9\./)&&Ai.match(/Safari\//)&&Ai.match(/AppleWebKit/)),safari:wi()||!!(Ai.match(/Version\//)&&Ai.match(/Safari\//)&&Ai.match(/AppleWebKit/)),ie:-1!==Si(),ie9:Ii(9),ie10:Ii(10),ie11:Ii(11),android:Ai.indexOf("Android")>0,edge:!!Ai.match(/Edge\//),chromium:/chrom(e|ium)/.test(Ai.toLowerCase())&&!Ai.match(/Edge\//)};a.register("platform",Di);var _i=Di,Ni={mixInto(e,t){t=l({defaultArguments:[],initialize:e.prototype.initialize,maxSize:100,initialSize:0,useDefaultConstruction:!1},t);var i=[],r=t.maxSize,a=Function.prototype.bind.bind(e,e),n=a(...t.defaultArguments),s=t.initialize,o=t.useDefaultConstruction,h=e.prototype;for(si(e,{pool:i,dirtyFromPool:()=>i.length?i.pop():new n,createFromPool:function(...e){var t;return i.length?(t=i.pop(),s.apply(t,e)):o?(t=new n,s.apply(t,e)):t=new(a(...e)),t},get poolSize(){return i.length},set maxPoolSize(e){r=e},get maxPoolSize(){return r}}),si(h,{freeToPool:function(){i.lengtht[+i+1])},fillIn:function(e,t){for(var i=e,r=e.match(/\{\{[^{}]+\}\}/g)||[],a=0;a=1&&Bi.isEmbeddingMark(e.charAt(i-1));)i--;if(t>=i||t>=e.length)return"";for(var n=0;n=0;){a.push(Bi.embeddedSlice(e,o,o+r.index));var l=r.index+r.length;n=n.slice(l),o+=l}return a.push(Bi.embeddedSlice(e,o)),void 0!==i&&(a=_.first(a,i)),a},embeddedDebugString:function(e){return e.replace(/\u202a/g,"[LTR]").replace(/\u202b/g,"[RTL]").replace(/\u202c/g,"[POP]")},assertContainsKey(e,t){},capitalize:e=>e[0].toUpperCase()+e.slice(1)};Ui.register("StringUtils",Bi);var zi=Bi;var Hi=new class{constructor(){this.nameResponsesEnabledProperty=new dt(!0),this.objectResponsesEnabledProperty=new dt(!1),this.contextResponsesEnabledProperty=new dt(!1),this.hintResponsesEnabledProperty=new dt(!1)}reset(){this.nameResponsesEnabledProperty.reset(),this.objectResponsesEnabledProperty.reset(),this.contextResponsesEnabledProperty.reset(),this.hintResponsesEnabledProperty.reset()}collectResponses(e){var t=(e=l({},ki.DEFAULT_OPTIONS,e)).nameResponse&&(this.nameResponsesEnabledProperty.get()||e.ignoreProperties),i=e.objectResponse&&(this.objectResponsesEnabledProperty.get()||e.ignoreProperties),r=e.contextResponse&&(this.contextResponsesEnabledProperty.get()||e.ignoreProperties),a=e.hintResponse&&(this.hintResponsesEnabledProperty.get()||e.ignoreProperties),n=Vi.createPatternKey(t,i,r,a),s="";if(n){var o=e.responsePatterns[n];s=zi.fillIn(o,{NAME:e.nameResponse,OBJECT:e.objectResponse,CONTEXT:e.contextResponse,HINT:e.hintResponse})}return s}};Li.register("responseCollector",Hi);var qi=Hi,Gi={isValidValue:e=>"string"==typeof e||Array.isArray(e)&&_.every(e,e=>"string"==typeof e)},Yi=1;class Wi{constructor(e){e=l({alert:null,loopAlerts:!1,predicate:function(){return!0},alertStableDelay:200,alertMaximumDelay:Number.MAX_VALUE,announcerOptions:{}},e),this.id=Yi++,this._alert=e.alert,this.loopAlerts=e.loopAlerts,this.numberOfTimesAlerted=0,this.predicate=e.predicate,this.alertStableDelay=e.alertStableDelay,this.alertMaximumDelay=e.alertMaximumDelay,this.announcerOptions=e.announcerOptions}getAlertStringFromResponsePacket(e,t){var i=_.extend({},e);return t||(i.ignoreProperties=!0),qi.collectResponses(i)}getAlertText(e=!1){var t;if("string"==typeof this._alert||this._alert instanceof ki)t=this._alert;else if(this.loopAlerts)t=this._alert[this.numberOfTimesAlerted%this._alert.length];else{var i=Math.min(this.numberOfTimesAlerted,this._alert.length-1);t=this._alert[i]}return t instanceof ki&&(t=this.getAlertStringFromResponsePacket(t,e)),t}getTextToAlert(e){var t=this.getAlertText(e);return this.numberOfTimesAlerted++,t}set alert(e){A(e,Gi),this.numberOfTimesAlerted=0,this._alert=e}get alert(){return this._alert}setAlertStableDelay(e){this.alertStableDelay=e}toString(){return"Utterance_".concat(this.id,"#").concat(this.getAlertText())}reset(){this.numberOfTimesAlerted=0}}Li.register("Utterance",Wi);var Xi=Wi;class Ki extends Xi{constructor(e){super(e=l({alertStableDelay:500},e))}}Li.register("ActivationUtterance",Ki);function Ji(e){return e.replace(/\u202a|\u202b|\u202c/g,"")}a.register("stripEmbeddingMarks",Ji);var Qi=Ji,Zi=new t("kite");Zi.register("svgNumber",e=>e.toFixed(20));var $i=Zi;window.sceneryLog=null;var er=document.createElement("canvas"),tr=er.getContext("2d"),ir="",rr=new t("scenery");function ar(e){rr.logString+="".concat(e.replace(/%c/g,""),"\n")}function nr(...e){window.console&&window.console.log&&window.console.log(...Array.prototype.slice.call(e,0))}rr.register("scratchCanvas",er),rr.register("scratchContext",tr);var sr={dirty:{name:"dirty",style:"color: #888;"},bounds:{name:"bounds",style:"color: #888;"},hitTest:{name:"hitTest",style:"color: #888;"},hitTestInternal:{name:"hitTestInternal",style:"color: #888;"},PerfCritical:{name:"Perf",style:"color: #f00;"},PerfMajor:{name:"Perf",style:"color: #aa0;"},PerfMinor:{name:"Perf",style:"color: #088;"},PerfVerbose:{name:"Perf",style:"color: #888;"},Cursor:{name:"Cursor",style:""},Stitch:{name:"Stitch",style:""},StitchDrawables:{name:"Stitch",style:""},GreedyStitcher:{name:"Greedy",style:"color: #088;"},GreedyVerbose:{name:"Greedy",style:"color: #888;"},RelativeTransform:{name:"RelativeTransform",style:"color: #606;"},BackboneDrawable:{name:"Backbone",style:"color: #a00;"},CanvasBlock:{name:"Canvas",style:""},WebGLBlock:{name:"WebGL",style:""},Display:{name:"Display",style:""},DOMBlock:{name:"DOM",style:""},Drawable:{name:"",style:""},FittedBlock:{name:"FittedBlock",style:""},Instance:{name:"Instance",style:""},InstanceTree:{name:"InstanceTree",style:""},ChangeInterval:{name:"ChangeInterval",style:"color: #0a0;"},SVGBlock:{name:"SVG",style:""},SVGGroup:{name:"SVGGroup",style:""},ImageSVGDrawable:{name:"ImageSVGDrawable",style:""},Paints:{name:"Paints",style:""},Filters:{name:"Filters",style:""},AlignBox:{name:"AlignBox",style:""},AlignGroup:{name:"AlignGroup",style:""},RichText:{name:"RichText",style:""},Sim:{name:"Sim",style:""},ParallelDOM:{name:"ParallelDOM",style:""},PDOMInstance:{name:"PDOMInstance",style:""},PDOMTree:{name:"PDOMTree",style:""},PDOMDisplaysInfo:{name:"PDOMDisplaysInfo",style:""},KeyboardFuzzer:{name:"KeyboardFuzzer",style:""},InputListener:{name:"InputListener",style:""},InputEvent:{name:"InputEvent",style:""},OnInput:{name:"OnInput",style:""},Pointer:{name:"Pointer",style:""},Input:{name:"Input",style:""},EventDispatch:{name:"EventDispatch",style:""},EventPath:{name:"EventPath",style:""}};si(rr,{logString:"",logFunction:function(...e){window.console&&window.console.log&&window.console.log(...Array.prototype.slice.call(e,0))},switchLogToConsole:function(){rr.logFunction=nr},switchLogToString:function(){window.console&&window.console.log("switching to string log"),rr.logFunction=ar},enableIndividualLog:function(e){return"stitch"===e?(this.enableIndividualLog("Stitch"),this.enableIndividualLog("StitchDrawables"),this.enableIndividualLog("GreedyStitcher"),void this.enableIndividualLog("GreedyVerbose")):"perf"===e?(this.enableIndividualLog("PerfCritical"),this.enableIndividualLog("PerfMajor"),this.enableIndividualLog("PerfMinor"),void this.enableIndividualLog("PerfVerbose")):"input"===e?(this.enableIndividualLog("InputListener"),this.enableIndividualLog("InputEvent"),this.enableIndividualLog("OnInput"),this.enableIndividualLog("Pointer"),this.enableIndividualLog("Input"),this.enableIndividualLog("EventDispatch"),void this.enableIndividualLog("EventPath")):"a11y"===e||"pdom"===e?(this.enableIndividualLog("ParallelDOM"),this.enableIndividualLog("PDOMInstance"),this.enableIndividualLog("PDOMTree"),void this.enableIndividualLog("PDOMDisplaysInfo")):void(e&&(window.sceneryLog[e]=window.sceneryLog[e]||function(t,i){var r=sr[e],a=r.name?"[".concat(r.name,"] "):"";rr.logFunction("%c".concat(ir,"%c").concat(a).concat(t),"color: #ddd;",i||r.style)}))},disableIndividualLog:function(e){e&&delete window.sceneryLog[e]},enableLogging:function(e){window.sceneryLog=function(e){rr.logFunction(e)},window.sceneryLog.push=function(){ir+="| "},window.sceneryLog.pop=function(){ir=ir.slice(0,-2)},window.sceneryLog.getDepth=function(){return ir.length/2};for(var t=0;t({ratio:e.ratio,stop:rr.serialize(e.color)})),t.start=rr.serialize(e.start),t.end=rr.serialize(e.end),rr.LinearGradient&&e instanceof rr.LinearGradient?t.type="LinearGradient":rr.RadialGradient&&e instanceof rr.RadialGradient&&(t.type="RadialGradient",t.startRadius=e.startRadius,t.endRadius=e.endRadius)),rr.Pattern&&e instanceof rr.Pattern&&(t.type="Pattern",t.url=e.image.src),t}if(e instanceof rr.Node){var i=e,r={},a={};["visible","opacity","disabledOpacity","pickable","inputEnabled","cursor","transformBounds","renderer","usesOpacity","layerSplit","cssTransform","excludeInvisible","webglScale","preventFit"].forEach(e=>{i[e]!==rr.Node.DEFAULT_OPTIONS[e]&&(r[e]=i[e])}),["maxWidth","maxHeight","clipArea","mouseArea","touchArea"].forEach(e=>{i[e]!==rr.Node.DEFAULT_OPTIONS[e]&&(a[e]=rr.serialize(i[e]))}),i.matrix.isIdentity()||(a.matrix=rr.serialize(i.matrix)),i._localBoundsOverridden&&(a.localBounds=rr.serialize(i.localBounds)),a.children=i.children.map(e=>e.id),a.hasInputListeners=i.inputListeners.length>0;var n={id:i.id,type:"Node",types:hi(i.constructor).map(e=>e.name).filter(e=>e&&"Object"!==e&&"Node"!==e),name:i.constructor.name,options:r,setup:a};if(rr.Path&&i instanceof rr.Path&&(n.type="Path",a.path=rr.serialize(i.shape),i.boundsMethod!==rr.Path.DEFAULT_OPTIONS.boundsMethod&&(r.boundsMethod=i.boundsMethod)),rr.Circle&&i instanceof rr.Circle&&(n.type="Circle",r.radius=i.radius),rr.Line&&i instanceof rr.Line&&(n.type="Line",r.x1=i.x1,r.y1=i.y1,r.x2=i.x2,r.y2=i.y2),rr.Rectangle&&i instanceof rr.Rectangle&&(n.type="Rectangle",r.rectX=i.rectX,r.rectY=i.rectY,r.rectWidth=i.rectWidth,r.rectHeight=i.rectHeight,r.cornerXRadius=i.cornerXRadius,r.cornerYRadius=i.cornerYRadius),rr.Text&&i instanceof rr.Text&&(n.type="Text","hybrid"!==i.boundsMethod&&(r.boundsMethod=i.boundsMethod),r.text=i.text,r.font=i.font),rr.Image&&i instanceof rr.Image&&(n.type="Image",["imageOpacity","initialWidth","initialHeight","mipmapBias","mipmapInitialLevel","mipmapMaxLevel"].forEach(e=>{i[e]!==rr.Image.DEFAULT_OPTIONS[e]&&(r[e]=i[e])}),a.width=i.imageWidth,a.height=i.imageHeight,i._mipmapData?(a.imageType="mipmapData",a.mipmapData=i._mipmapData.map(e=>({url:e.url,width:e.width,height:e.height}))):(i._mipmap&&(a.generateMipmaps=!0),i._image instanceof HTMLImageElement?(a.imageType="image",a.src=i._image.src):i._image instanceof HTMLCanvasElement&&(a.imageType="canvas",a.src=i._image.toDataURL()))),rr.CanvasNode&&i instanceof rr.CanvasNode||rr.WebGLNode&&i instanceof rr.WebGLNode){n.type=rr.CanvasNode&&i instanceof rr.CanvasNode?"CanvasNode":"WebGLNode",a.canvasBounds=rr.serialize(i.canvasBounds);Math.min(5,i._drawables.length?1/_.mean(i._drawables.map(e=>{var t=e.instance.trail.getMatrix().getScaleVector();return(t.x+t.y)/2})):1);1;var s=document.createElement("canvas");s.width=Math.ceil(1*i.canvasBounds.width),s.height=Math.ceil(1*i.canvasBounds.height);var o=s.getContext("2d"),l=new rr.CanvasContextWrapper(s,o),p=Lt.Matrix3.scale(1);l.context.setTransform(1,0,0,1,-i.canvasBounds.left,-i.canvasBounds.top),i.renderToCanvasSelf(l,p),a.url=s.toDataURL(),a.scale=1,a.offset=rr.serialize(i.canvasBounds.leftTop)}return rr.DOM&&i instanceof rr.DOM&&(n.type="DOM",n.element=(new window.XMLSerializer).serializeToString(i.element),i.element instanceof window.HTMLCanvasElement&&(n.dataURL=i.element.toDataURL()),r.preventTransform=i.preventTransform),(rr.Path&&i instanceof rr.Path||rr.Text&&i instanceof rr.Text)&&(["fillPickable","strokePickable","lineWidth","lineCap","lineJoin","lineDashOffset","miterLimit"].forEach(e=>{i[e]!==rr.Paintable.DEFAULT_OPTIONS[e]&&(r[e]=i[e])}),i.fill!==rr.Paintable.DEFAULT_OPTIONS.fill&&(a.fill=rr.serialize(i.fill)),i.stroke!==rr.Paintable.DEFAULT_OPTIONS.stroke&&(a.stroke=rr.serialize(i.stroke)),i.lineDash.length&&(a.lineDash=rr.serialize(i.lineDash))),n}return e instanceof rr.Display?{type:"Display",width:e.width,height:e.height,backgroundColor:rr.serialize(e.backgroundColor),tree:{type:"Subtree",rootNodeId:e.rootNode.id,nodes:rr.serializeConnectedNodes(e.rootNode)}}:{type:"value",value:e}},deserialize:function(e){if("Vector2"===e.type)return new Lt.Vector2(e.x,e.y);if("Matrix3"===e.type)return(new Lt.Matrix3).rowMajor(e.m00,e.m01,e.m02,e.m10,e.m11,e.m12,e.m20,e.m21,e.m22);if("Bounds2"===e.type)return new Lt.Bounds2(e.minX,e.minY,e.maxX,e.maxY);if("Shape"===e.type)return new $i.Shape(e.path);if("Array"===e.type)return e.value.map(rr.deserialize);if("Color"===e.type)return new rr.Color(e.red,e.green,e.blue,e.alpha);if("Property"===e.type)return new h.Property(rr.deserialize(e.value));if("Pattern"===e.type||"LinearGradient"===e.type||"RadialGradient"===e.type){var t;if("Pattern"===e.type){var i=new window.Image;i.src=e.url,t=new rr.Pattern(i)}else{var r=rr.deserialize(e.start),a=rr.deserialize(e.end);"LinearGradient"===e.type?t=new rr.LinearGradient(r.x,r.y,a.x,a.y):"RadialGradient"===e.type&&(t=new rr.RadialGradient(r.x,r.y,e.startRadius,a.x,a.y,e.endRadius)),e.stops.forEach(e=>{t.addColorStop(e.ratio,rr.deserialize(e.stop))})}return e.transformMatrix&&t.setTransformMatrix(rr.deserialize(e.transformMatrix)),t}if(_.includes(["Node","Path","Circle","Line","Rectangle","Text","Image","CanvasNode","WebGLNode","DOM"],e.type)){var n,s=e.setup;if("Node"===e.type)n=new rr.Node;else if("Path"===e.type)n=new rr.Path(rr.deserialize(s.path));else if("Circle"===e.type)n=new rr.Circle({});else if("Line"===e.type)n=new rr.Line({});else if("Rectangle"===e.type)n=new rr.Rectangle({});else if("Text"===e.type)n=new rr.Text("");else if("Image"===e.type){if("image"===s.imageType||"canvas"===s.imageType)n=new rr.Image(s.src),s.generateMipmaps&&(n.mipmaps=!0);else if("mipmapData"===s.imageType){var o=s.mipmapData.map(e=>{var t={width:e.width,height:e.height,url:e.url};t.img=new window.Image,t.img.src=e.url,t.canvas=document.createElement("canvas"),t.canvas.width=e.width,t.canvas.height=e.height;var i=t.canvas.getContext("2d");return t.updateCanvas=function(){t.img.complete&&(void 0===t.img.naturalWidth||t.img.naturalWidth>0)&&(i.drawImage(t.img,0,0),delete t.updateCanvas)},t});n=new rr.Image(o)}n.initialWidth=s.width,n.initialHeight=s.height}else if("CanvasNode"===e.type||"WebGLNode"===e.type)n=new rr.Node({children:[new rr.Image(s.url,{translation:rr.deserialize(s.offset),scale:1/s.scale})]});else if("DOM"===e.type){var l=document.createElement("div");l.innerHTML=e.element;var p=l.childNodes[0];if(l.removeChild(p),e.dataURL){var u=new window.Image;u.onload=()=>{p.getContext("2d").drawImage(u,0,0)},u.src=e.dataURL}n=new rr.DOM(p)}return s.clipArea&&(n.clipArea=rr.deserialize(s.clipArea)),s.mouseArea&&(n.mouseArea=rr.deserialize(s.mouseArea)),s.touchArea&&(n.touchArea=rr.deserialize(s.touchArea)),s.matrix&&(n.matrix=rr.deserialize(s.matrix)),s.localBounds&&(n.localBounds=rr.deserialize(s.localBounds)),s.fill&&(n.fill=rr.deserialize(s.fill)),s.stroke&&(n.stroke=rr.deserialize(s.stroke)),s.lineDash&&(n.lineDash=rr.deserialize(s.lineDash)),n.mutate(e.options),n._serialization=e,n}if("Subtree"===e.type){var d={},c=e.nodes.map(rr.deserialize);return c.forEach(e=>{d[e._serialization.id]=e}),c.forEach(e=>{e._serialization.setup.children.forEach(t=>{e.addChild(d[t])})}),d[e.rootNodeId]}return"value"===e.type?e.value:null},serializeConnectedNodes:function(e){return e.getSubtreeNodes().map(rr.serialize)}});var or=rr,lr=document.createElement("style");lr.type="text/css",document.head.appendChild(lr);var hr=document.styleSheets[document.styleSheets.length-1],pr={stylesheet:hr,styleElement:lr,addRule(e){this.stylesheet.insertRule(e,0)}};or.register("SceneryStyle",pr);var ur=pr;ur.addRule(".".concat("a11y-pdom-element","{")+"position: fixed;pointer-events: none;top: 0px;left: 0px;transform-origin: left top 0px;border-width: 0px;border: 0px;padding: 1px 1px;margin: 0px;white-space: nowrap;outline: none;box-shadow:none;border-color:transparent;font-size: 1px;clip: rect(1px, 1px, 1px, 1px);}"),ur.addRule(".".concat("a11y-pdom-root","{")+"position: absolute;z-index: 1;opacity: 0.0001;}"),ur.addRule(".".concat("a11y-pdom-list-item","{")+"list-style: none;");var dr={SIBLING_CLASS_NAME:"a11y-pdom-element",ROOT_CLASS_NAME:"a11y-pdom-root",LIST_ITEM_CLASS_NAME:"a11y-pdom-list-item"};or.register("PDOMSiblingStyle",dr);var cr=dr,mr=["A","AREA","INPUT","SELECT","TEXTAREA","BUTTON","IFRAME"],yr=["B","STRONG","I","EM","MARK","SMALL","DEL","INS","SUB","SUP","BR"],gr=["INPUT"];function vr(e){for(var t=e.getElementsByTagName("*"),i=[],r=0;r=0;){var s=i[n];if(n+=a,Er.isElementFocusable(s))return s}return r}function Tr(e){return!_.includes(gr,e.toUpperCase())}var Er={getNextFocusable:e=>fr("NEXT",e),getPreviousFocusable:e=>fr("PREVIOUS",e),getFirstFocusable(e){for(var t=vr(e||document.body),i=document.body,r=0;r",t);a>-1&&(i.push(a),t=a+1),n>-1?(r.push(n),t=n+1):t++}if(i.length!==r.length||0===i.length)return!1;for(var s=!0,o=e.toUpperCase(),l=0;l0||(_.includes(yr,h)||(s=!1))}return s},setTextContent(e,t){if(null===t)e.innerHTML="";else{var i=Qi(t);A(i,b.STRING_WITHOUT_TEMPLATE_VARS_VALIDATOR),Tr(e.tagName)&&(Er.containsFormattingTags(i)?e.innerHTML=i:e.textContent=i)}},tagIsDefaultFocusable:e=>_.includes(mr,e.toUpperCase()),isElementFocusable:e=>!!document.body.contains(e)&&(!function e(t){return!!t.hidden||t!==document.body&&e(t.parentElement)}(e)&&(!_.includes(yr,e.tagName)&&"true"===e.getAttribute("data-focusable"))),tagNameSupportsContent:e=>Tr(e),removeElements(e,t){for(var i=0;i{if(t===Ir.POLITE){var i=this.politeElements[this.politeElementIndex];this.updateLiveElement(i,e),this.politeElementIndex=(this.politeElementIndex+1)%this.politeElements.length}else if(t===Ir.ASSERTIVE){var r=this.assertiveElements[this.assertiveElementIndex];this.updateLiveElement(r,e),this.assertiveElementIndex=(this.assertiveElementIndex+1)%this.assertiveElements.length}}),Ar++}announce(e,t){t=l({ariaLivePriority:Ir.POLITE},t),this.announcingEmitter.emit(e.getTextToAlert(this.respectResponseCollectorProperties),t.ariaLivePriority)}updateLiveElement(e,t){e.textContent="",e.hidden=!1,mt.setTimeout(()=>{Pr.setTextContent(e,t),mt.setTimeout(()=>{_i.safari?e.hidden=!0:e.textContent=""},200)},0)}}Sr.AriaLive=Ir,Li.register("AriaHerald",Sr);var Dr=Sr;class _r extends Ie{constructor(e,t){(t=l({implementAsSkeleton:!1,tandem:oe.OPTIONAL,phetioType:_r.UtteranceQueueIO,phetioState:!1},t)).implementAsSkeleton&&(t.tandem=oe.OPT_OUT),super(t),this.announcer=e,this._initialized=!t.implementAsSkeleton,this.queue=[],this._muted=!1,this._enabled=!0,this._initialized&&(this.stepQueueListener=this.stepQueue.bind(this),mt.addListener(this.stepQueueListener))}get length(){return this.queue.length}addToBack(e){if(this.initializedAndEnabled){var t=this.prepareUtterance(e);this.queue.push(t)}}addToFront(e){if(this.initializedAndEnabled){var t=this.prepareUtterance(e);this.queue.unshift(t)}}prepareUtterance(e){e instanceof Xi||(e=new Xi({alert:e}));var t=new Nr(e);return this.removeOthersAndUpdateUtteranceWrapper(t),t.stableTime=0,t}removeUtterance(e,t){t=l({assertExists:!0},t),_.remove(this.queue,t=>t.utterance===e)}removeOthersAndUpdateUtteranceWrapper(e,t){for(var i=[],r=0;rt.utterance===e.utterance)}get initializedAndEnabled(){return this._enabled&&this._initialized}getNextUtterance(){for(var e=null,t=0;ti.utterance.alertStableDelay||i.timeInQueue>i.utterance.alertMaximumDelay){e=i.utterance,this.queue.splice(t,1);break}}return e}hasUtterance(e){for(var t=0;t{var t=e-r;r=e,console.log(t/1e3),phet.axon.stepTimer.emit(t/1e3),window.requestAnimationFrame(a)};return window.requestAnimationFrame(a),t}}class Nr{constructor(e){this.utterance=e,this.timeInQueue=0,this.stableTime=0}resetTimingVariables(){this.timeInQueue=0,this.stableTime=0}}_r.UtteranceQueueIO=new B("UtteranceQueueIO",{valueType:_r,documentation:"Manages a queue of Utterances that are read in order by a screen reader.",events:["announced"],methods:{addToBack:{returnType:Se,parameterTypes:[ue],implementation:function(e){return this.addToBack(e)},documentation:"Add the utterance (string) to the end of the queue.",invocableForReadOnlyElements:!1},addToFront:{returnType:Se,parameterTypes:[ue],implementation:function(e){return this.addToFront(e)},documentation:"Add the utterance (string) to the beginning of the queue.",invocableForReadOnlyElements:!1},setMuted:{returnType:Se,parameterTypes:[Re],implementation:function(e){this.muted(e)},documentation:"Set whether the utteranceQueue will be muted or not. If muted, utterances still move through the queue but will not be read by screen readers.",invocableForReadOnlyElements:!1},getMuted:{returnType:Re,parameterTypes:[Se],implementation:function(){return this.muted()},documentation:"Get whether the utteranceQueue is muted. If muted, utterances still move through the queue but will not be read by screen readers."},setEnabled:{returnType:Se,parameterTypes:[Re],implementation:function(e){this.enabled(e)},documentation:"Set whether the utteranceQueue will be enabled or not. When enabled, Utterances cannot be added to the queue, and the Queue cannot be cleared. Also nothing will be sent to assistive technology.",invocableForReadOnlyElements:!1},isEnabled:{returnType:Re,parameterTypes:[Se],implementation:function(){return this.enabled()},documentation:"Get whether the utteranceQueue is enabled. When enabled, Utterances cannot be added to the queue, and the Queue cannot be cleared. Also nothing will be sent to assistive technology."}}}),Li.register("UtteranceQueue",_r);var Lr={},Mr=e=>{window.phet&&window.phet.chipper&&window.phet.chipper.queryParameters&&phet.chipper.queryParameters.deprecationWarnings&&(Lr.hasOwnProperty(e)||(Lr[e]=!0,console.warn("Deprecation warning: ".concat(e))))};a.register("deprecationWarning",Mr);var xr=Mr;class Vr extends Xi{constructor(e){xr("Please use AccessibleValueHander.a11yCreateContextResponseAlert(), see https://github.com/phetsims/sun/issues/685"),super(e=l({alertStableDelay:1e3},e))}}Li.register("ValueChangeUtterance",Vr)})()})()}(); \ No newline at end of file +function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}!function(){if(window.phet=window.phet||{},phet.chipper=phet.chipper||{},phet.chipper.packageObject={name:"utterance-queue",version:"0.0.0",license:"MIT",repository:{type:"git",url:"https://github.com/phetsims/utternace-queue.git"},devDependencies:{grunt:"~1.5.3"},phet:{generatedUnitTests:!0,requirejsNamespace:"UTTERANCE_QUEUE",buildStandalone:!0,requiresLodash:!0,assignGlobals:{"phet.utteranceQueue":"UTTERANCE_QUEUE/main","phet.phetCore":"PHET_CORE/main","phet.axon":"AXON/main"},preload:["../sherpa/lib/himalaya-1.1.0.js"]},eslintConfig:{extends:"../chipper/eslint/sim_eslintrc.js",globals:{himalaya:"readonly",SpeechSynthesis:"readonly",SpeechSynthesisVoice:"readonly",SpeechSynthesisUtterance:"readonly"}}},!window.hasOwnProperty("_"))throw new Error("Underscore/Lodash not found: _");window.assertions=window.assertions||{},window.assertions.assertFunction=window.assertions.assertFunction||function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s!!i),window.navigator&&"Microsoft Internet Explorer"===window.navigator.appName&&i.push("stack=\n".concat((new Error).stack));var n=i.length>0?"Assertion failed: ":"Assertion failed";throw console&&console.log&&console.log(n,...i),window.phet&&phet.chipper&&phet.chipper.queryParameters&&phet.chipper.queryParameters.debugger,new Error(n+i.join("\n "))}},window.assert=window.assert||null,window.assertSlow=window.assertSlow||null,window.assertions.enableAssert=function(){window.assert=window.assertions.assertFunction,window.console&&window.console.log&&window.console.log("enabling assert")},window.assertions.disableAssert=function(){window.assert=null,window.console&&window.console.log&&window.console.log("disabling assert")},window.assertions.enableAssertSlow=function(){window.assertSlow=window.assertions.assertFunction,window.console&&window.console.log&&window.console.log("enabling assertSlow")},window.assertions.disableAssertSlow=function(){window.assertSlow=null,window.console&&window.console.log&&window.console.log("disabling assertSlow")},function(){window.phetio=window.phetio||{};window.phetio.PhetioIDUtils={append:function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s{t+="."+e}),t},getComponentName:function(t){var e=t.lastIndexOf(".");return-1===e?t:t.substring(e+1,t.length)},getParentID:function(t){var e=t.lastIndexOf(".");return-1===e?null:t.substring(0,e)},getDOMElementID:function(t){return"phetioID:".concat(t)},getScreenID:function(t){for(var e=[],i=t.split("."),s=0;s0&&r+"Screen".length===n.length)return e.join(".")}return null},getGroupElementIndex:function(t){return Number(t.split(window.phetio.PhetioIDUtils.GROUP_SEPARATOR)[1])},isAncestor:function(t,e){for(var i=t.split("."),s=e.split("."),n=0;n=0?(s.b[6][0]++,a):(s.b[6][1]++,r+a));s.s[12]++;for(;h1&&void 0!==arguments[1]?arguments[1]:(s.b[0][0]++,d);s.f[0]++;var i=(s.s[1]++,(0,n.default)(t,e)),o=(s.s[2]++,(0,r.default)(i,e));return s.s[3]++,(0,a.format)(o,e)},i.stringify=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(s.b[1][0]++,d);return s.f[1]++,s.s[4]++,(0,o.toHTML)(t,e)};var n=l(t("./lexer")),r=l(t("./parser")),a=t("./format"),o=t("./stringify"),h=t("./tags");function l(t){return t&&t.__esModule?t:{default:t}}var d=i.parseDefaults=(s.s[0]++,{voidTags:h.voidTags,closingTags:h.closingTags,childlessTags:h.childlessTags,closingTagAncestorBreakers:h.closingTagAncestorBreakers,includePositions:!1})},{"./format":2,"./lexer":4,"./parser":5,"./stringify":6,"./tags":7}],4:[function(t,e,i){"use strict";var s=function(){var t="/Users/chrisandrejewski/Desktop/Work/github-repos/himalaya/src/lexer.js",e="99f1269b85a36e02e6fcfa2eb5c9423a8a428848",i=new(0,function(){}.constructor)("return this")(),s="__coverage__",n={path:"/Users/chrisandrejewski/Desktop/Work/github-repos/himalaya/src/lexer.js",statementMap:{0:{start:{line:9,column:16},end:{line:9,column:30}},1:{start:{line:10,column:14},end:{line:10,column:42}},2:{start:{line:11,column:2},end:{line:19,column:3}},3:{start:{line:12,column:17},end:{line:12,column:30}},4:{start:{line:13,column:4},end:{line:18,column:5}},5:{start:{line:14,column:6},end:{line:14,column:21}},6:{start:{line:15,column:6},end:{line:15,column:25}},7:{start:{line:17,column:6},end:{line:17,column:23}},8:{start:{line:23,column:14},end:{line:23,column:34}},9:{start:{line:24,column:2},end:{line:24,column:41}},10:{start:{line:28,column:2},end:{line:32,column:3}},11:{start:{line:36,column:2},end:{line:40,column:3}},12:{start:{line:44,column:16},end:{line:49,column:3}},13:{start:{line:50,column:2},end:{line:50,column:12}},14:{start:{line:51,column:2},end:{line:51,column:21}},15:{start:{line:55,column:42},end:{line:55,column:47}},16:{start:{line:56,column:14},end:{line:56,column:24}},17:{start:{line:57,column:2},end:{line:72,column:3}},18:{start:{line:58,column:18},end:{line:58,column:38}},19:{start:{line:59,column:4},end:{line:59,column:18}},20:{start:{line:60,column:4},end:{line:71,column:5}},21:{start:{line:61,column:24},end:{line:61,column:57}},22:{start:{line:62,column:6},end:{line:70,column:7}},23:{start:{line:63,column:8},end:{line:63,column:25}},24:{start:{line:65,column:24},end:{line:65,column:37}},25:{start:{line:66,column:24},end:{line:66,column:45}},26:{start:{line:67,column:8},end:{line:69,column:9}},27:{start:{line:68,column:10},end:{line:68,column:36}},28:{start:{line:75,column:21},end:{line:75,column:34}},29:{start:{line:77,column:2},end:{line:87,column:3}},30:{start:{line:78,column:20},end:{line:78,column:43}},31:{start:{line:79,column:4},end:{line:81,column:5}},32:{start:{line:80,column:6},end:{line:80,column:20}},33:{start:{line:82,column:17},end:{line:82,column:40}},34:{start:{line:83,column:4},end:{line:85,column:5}},35:{start:{line:84,column:6},end:{line:84,column:20}},36:{start:{line:86,column:4},end:{line:86,column:23}},37:{start:{line:91,column:15},end:{line:91,column:21}},38:{start:{line:92,column:26},end:{line:92,column:31}},39:{start:{line:93,column:16},end:{line:93,column:48}},40:{start:{line:94,column:2},end:{line:94,column:40}},41:{start:{line:94,column:34},end:{line:94,column:40}},42:{start:{line:95,column:2},end:{line:97,column:3}},43:{start:{line:96,column:4},end:{line:96,column:24}},44:{start:{line:99,column:16},end:{line:99,column:38}},45:{start:{line:100,column:18},end:{line:100,column:52}},46:{start:{line:101,column:2},end:{line:101,column:38}},47:{start:{line:102,column:14},end:{line:102,column:36}},48:{start:{line:103,column:2},end:{line:103,column:60}},49:{start:{line:107,column:26},end:{line:107,column:31}},50:{start:{line:108,column:16},end:{line:108,column:38}},51:{start:{line:109,column:2},end:{line:109,column:32}},52:{start:{line:110,column:19},end:{line:110,column:53}},53:{start:{line:111,column:19},end:{line:111,column:33}},54:{start:{line:112,column:2},end:{line:114,column:3}},55:{start:{line:113,column:4},end:{line:113,column:40}},56:{start:{line:116,column:18},end:{line:116,column:55}},57:{start:{line:117,column:2},end:{line:117,column:41}},58:{start:{line:118,column:2},end:{line:125,column:4}},59:{start:{line:129,column:26},end:{line:129,column:31}},60:{start:{line:131,column:23},end:{line:131,column:53}},61:{start:{line:132,column:18},end:{line:132,column:36}},62:{start:{line:133,column:18},end:{line:133,column:40}},63:{start:{line:134,column:4},end:{line:134,column:46}},64:{start:{line:135,column:4},end:{line:135,column:68}},65:{start:{line:137,column:18},end:{line:137,column:35}},66:{start:{line:138,column:2},end:{line:138,column:25}},67:{start:{line:140,column:22},end:{line:140,column:48}},68:{start:{line:141,column:18},end:{line:141,column:35}},69:{start:{line:142,column:4},end:{line:142,column:46}},70:{start:{line:143,column:16},end:{line:143,column:38}},71:{start:{line:144,column:4},end:{line:144,column:64}},72:{start:{line:146,column:2},end:{line:146,column:16}},73:{start:{line:150,column:19},end:{line:150,column:23}},74:{start:{line:152,column:2},end:{line:152,column:30}},75:{start:{line:156,column:26},end:{line:156,column:31}},76:{start:{line:157,column:14},end:{line:157,column:24}},77:{start:{line:158,column:14},end:{line:158,column:28}},78:{start:{line:159,column:2},end:{line:164,column:3}},79:{start:{line:160,column:17},end:{line:160,column:34}},80:{start:{line:161,column:22},end:{line:161,column:79}},81:{start:{line:162,column:4},end:{line:162,column:24}},82:{start:{line:162,column:19},end:{line:162,column:24}},83:{start:{line:163,column:4},end:{line:163,column:11}},84:{start:{line:166,column:12},end:{line:166,column:21}},85:{start:{line:167,column:2},end:{line:172,column:3}},86:{start:{line:168,column:17},end:{line:168,column:32}},87:{start:{line:169,column:22},end:{line:169,column:79}},88:{start:{line:170,column:4},end:{line:170,column:25}},89:{start:{line:170,column:20},end:{line:170,column:25}},90:{start:{line:171,column:4},end:{line:171,column:9}},91:{start:{line:174,column:2},end:{line:174,column:34}},92:{start:{line:175,column:18},end:{line:175,column:39}},93:{start:{line:176,column:2},end:{line:179,column:4}},94:{start:{line:180,column:2},end:{line:180,column:16}},95:{start:{line:184,column:34},end:{line:184,column:39}},96:{start:{line:185,column:15},end:{line:185,column:29}},97:{start:{line:186,column:14},end:{line:186,column:18}},98:{start:{line:187,column:18},end:{line:187,column:24}},99:{start:{line:188,column:16},end:{line:188,column:18}},100:{start:{line:189,column:14},end:{line:189,column:24}},101:{start:{line:190,column:2},end:{line:227,column:3}},102:{start:{line:191,column:17},end:{line:191,column:35}},103:{start:{line:192,column:4},end:{line:199,column:5}},104:{start:{line:193,column:25},end:{line:193,column:39}},105:{start:{line:194,column:6},end:{line:196,column:7}},106:{start:{line:195,column:8},end:{line:195,column:20}},107:{start:{line:197,column:6},end:{line:197,column:14}},108:{start:{line:198,column:6},end:{line:198,column:14}},109:{start:{line:201,column:21},end:{line:201,column:49}},110:{start:{line:202,column:4},end:{line:207,column:5}},111:{start:{line:203,column:6},end:{line:205,column:7}},112:{start:{line:204,column:8},end:{line:204,column:48}},113:{start:{line:206,column:6},end:{line:206,column:11}},114:{start:{line:209,column:22},end:{line:209,column:44}},115:{start:{line:210,column:4},end:{line:217,column:5}},116:{start:{line:211,column:6},end:{line:213,column:7}},117:{start:{line:212,column:8},end:{line:212,column:48}},118:{start:{line:214,column:6},end:{line:214,column:28}},119:{start:{line:215,column:6},end:{line:215,column:14}},120:{start:{line:216,column:6},end:{line:216,column:14}},121:{start:{line:219,column:25},end:{line:219,column:54}},122:{start:{line:220,column:4},end:{line:224,column:5}},123:{start:{line:221,column:6},end:{line:221,column:18}},124:{start:{line:222,column:6},end:{line:222,column:14}},125:{start:{line:223,column:6},end:{line:223,column:14}},126:{start:{line:226,column:4},end:{line:226,column:12}},127:{start:{line:228,column:2},end:{line:228,column:37}},128:{start:{line:230,column:15},end:{line:230,column:27}},129:{start:{line:231,column:15},end:{line:231,column:26}},130:{start:{line:232,column:2},end:{line:269,column:3}},131:{start:{line:233,column:17},end:{line:233,column:25}},132:{start:{line:234,column:22},end:{line:234,column:46}},133:{start:{line:235,column:4},end:{line:253,column:5}},134:{start:{line:236,column:25},end:{line:236,column:37}},135:{start:{line:237,column:6},end:{line:252,column:7}},136:{start:{line:238,column:8},end:{line:243,column:9}},137:{start:{line:239,column:26},end:{line:239,column:43}},138:{start:{line:240,column:10},end:{line:240,column:47}},139:{start:{line:241,column:10},end:{line:241,column:16}},140:{start:{line:242,column:10},end:{line:242,column:18}},141:{start:{line:244,column:26},end:{line:244,column:38}},142:{start:{line:245,column:8},end:{line:245,column:14}},143:{start:{line:246,column:8},end:{line:251,column:9}},144:{start:{line:247,column:26},end:{line:247,column:48}},145:{start:{line:248,column:10},end:{line:248,column:47}},146:{start:{line:249,column:10},end:{line:249,column:16}},147:{start:{line:250,column:10},end:{line:250,column:18}},148:{start:{line:254,column:4},end:{line:266,column:5}},149:{start:{line:255,column:25},end:{line:255,column:37}},150:{start:{line:256,column:6},end:{line:261,column:7}},151:{start:{line:257,column:24},end:{line:257,column:41}},152:{start:{line:258,column:8},end:{line:258,column:45}},153:{start:{line:259,column:8},end:{line:259,column:14}},154:{start:{line:260,column:8},end:{line:260,column:16}},155:{start:{line:263,column:22},end:{line:263,column:39}},156:{start:{line:264,column:6},end:{line:264,column:43}},157:{start:{line:265,column:6},end:{line:265,column:14}},158:{start:{line:268,column:4},end:{line:268,column:38}},159:{start:{line:272,column:13},end:{line:272,column:20}},160:{start:{line:275,column:34},end:{line:275,column:39}},161:{start:{line:276,column:22},end:{line:276,column:43}},162:{start:{line:277,column:14},end:{line:277,column:24}},163:{start:{line:278,column:14},end:{line:278,column:28}},164:{start:{line:279,column:2},end:{line:311,column:3}},165:{start:{line:280,column:20},end:{line:280,column:44}},166:{start:{line:281,column:4},end:{line:284,column:5}},167:{start:{line:282,column:6},end:{line:282,column:20}},168:{start:{line:283,column:6},end:{line:283,column:11}},169:{start:{line:286,column:29},end:{line:286,column:51}},170:{start:{line:287,column:4},end:{line:287,column:48}},171:{start:{line:288,column:21},end:{line:288,column:66}},172:{start:{line:289,column:17},end:{line:289,column:33}},173:{start:{line:290,column:4},end:{line:293,column:5}},174:{start:{line:291,column:6},end:{line:291,column:37}},175:{start:{line:292,column:6},end:{line:292,column:14}},176:{start:{line:295,column:4},end:{line:306,column:5}},177:{start:{line:296,column:24},end:{line:296,column:46}},178:{start:{line:297,column:6},end:{line:297,column:42}},179:{start:{line:298,column:6},end:{line:305,column:8}},180:{start:{line:308,column:4},end:{line:308,column:39}},181:{start:{line:309,column:4},end:{line:309,column:56}},182:{start:{line:310,column:4},end:{line:310,column:9}}},fnMap:{0:{name:"feedPosition",decl:{start:{line:8,column:16},end:{line:8,column:28}},loc:{start:{line:8,column:50},end:{line:20,column:1}},line:8},1:{name:"jumpPosition",decl:{start:{line:22,column:16},end:{line:22,column:28}},loc:{start:{line:22,column:50},end:{line:25,column:1}},line:22},2:{name:"makeInitialPosition",decl:{start:{line:27,column:16},end:{line:27,column:35}},loc:{start:{line:27,column:39},end:{line:33,column:1}},line:27},3:{name:"copyPosition",decl:{start:{line:35,column:16},end:{line:35,column:28}},loc:{start:{line:35,column:40},end:{line:41,column:1}},line:35},4:{name:"lexer",decl:{start:{line:43,column:24},end:{line:43,column:29}},loc:{start:{line:43,column:45},end:{line:52,column:1}},line:43},5:{name:"lex",decl:{start:{line:54,column:16},end:{line:54,column:19}},loc:{start:{line:54,column:28},end:{line:73,column:1}},line:54},6:{name:"findTextEnd",decl:{start:{line:76,column:16},end:{line:76,column:27}},loc:{start:{line:76,column:41},end:{line:88,column:1}},line:76},7:{name:"lexText",decl:{start:{line:90,column:16},end:{line:90,column:23}},loc:{start:{line:90,column:32},end:{line:104,column:1}},line:90},8:{name:"lexComment",decl:{start:{line:106,column:16},end:{line:106,column:26}},loc:{start:{line:106,column:35},end:{line:126,column:1}},line:106},9:{name:"lexTag",decl:{start:{line:128,column:16},end:{line:128,column:22}},loc:{start:{line:128,column:31},end:{line:147,column:1}},line:128},10:{name:"isWhitespaceChar",decl:{start:{line:151,column:16},end:{line:151,column:32}},loc:{start:{line:151,column:40},end:{line:153,column:1}},line:151},11:{name:"lexTagName",decl:{start:{line:155,column:16},end:{line:155,column:26}},loc:{start:{line:155,column:35},end:{line:181,column:1}},line:155},12:{name:"lexTagAttributes",decl:{start:{line:183,column:16},end:{line:183,column:32}},loc:{start:{line:183,column:41},end:{line:270,column:1}},line:183},13:{name:"lexSkipTag",decl:{start:{line:274,column:16},end:{line:274,column:26}},loc:{start:{line:274,column:44},end:{line:312,column:1}},line:274}},branchMap:{0:{loc:{start:{line:13,column:4},end:{line:18,column:5}},type:"if",locations:[{start:{line:13,column:4},end:{line:18,column:5}},{start:{line:13,column:4},end:{line:18,column:5}}],line:13},1:{loc:{start:{line:60,column:4},end:{line:71,column:5}},type:"if",locations:[{start:{line:60,column:4},end:{line:71,column:5}},{start:{line:60,column:4},end:{line:71,column:5}}],line:60},2:{loc:{start:{line:62,column:6},end:{line:70,column:7}},type:"if",locations:[{start:{line:62,column:6},end:{line:70,column:7}},{start:{line:62,column:6},end:{line:70,column:7}}],line:62},3:{loc:{start:{line:67,column:8},end:{line:69,column:9}},type:"if",locations:[{start:{line:67,column:8},end:{line:69,column:9}},{start:{line:67,column:8},end:{line:69,column:9}}],line:67},4:{loc:{start:{line:79,column:4},end:{line:81,column:5}},type:"if",locations:[{start:{line:79,column:4},end:{line:81,column:5}},{start:{line:79,column:4},end:{line:81,column:5}}],line:79},5:{loc:{start:{line:83,column:4},end:{line:85,column:5}},type:"if",locations:[{start:{line:83,column:4},end:{line:85,column:5}},{start:{line:83,column:4},end:{line:85,column:5}}],line:83},6:{loc:{start:{line:83,column:8},end:{line:83,column:63}},type:"binary-expr",locations:[{start:{line:83,column:8},end:{line:83,column:20}},{start:{line:83,column:24},end:{line:83,column:36}},{start:{line:83,column:40},end:{line:83,column:63}}],line:83},7:{loc:{start:{line:94,column:2},end:{line:94,column:40}},type:"if",locations:[{start:{line:94,column:2},end:{line:94,column:40}},{start:{line:94,column:2},end:{line:94,column:40}}],line:94},8:{loc:{start:{line:95,column:2},end:{line:97,column:3}},type:"if",locations:[{start:{line:95,column:2},end:{line:97,column:3}},{start:{line:95,column:2},end:{line:97,column:3}}],line:95},9:{loc:{start:{line:112,column:2},end:{line:114,column:3}},type:"if",locations:[{start:{line:112,column:2},end:{line:114,column:3}},{start:{line:112,column:2},end:{line:114,column:3}}],line:112},10:{loc:{start:{line:134,column:32},end:{line:134,column:45}},type:"cond-expr",locations:[{start:{line:134,column:40},end:{line:134,column:41}},{start:{line:134,column:44},end:{line:134,column:45}}],line:134},11:{loc:{start:{line:142,column:32},end:{line:142,column:45}},type:"cond-expr",locations:[{start:{line:142,column:40},end:{line:142,column:41}},{start:{line:142,column:44},end:{line:142,column:45}}],line:142},12:{loc:{start:{line:161,column:24},end:{line:161,column:78}},type:"binary-expr",locations:[{start:{line:161,column:24},end:{line:161,column:46}},{start:{line:161,column:50},end:{line:161,column:62}},{start:{line:161,column:66},end:{line:161,column:78}}],line:161},13:{loc:{start:{line:162,column:4},end:{line:162,column:24}},type:"if",locations:[{start:{line:162,column:4},end:{line:162,column:24}},{start:{line:162,column:4},end:{line:162,column:24}}],line:162},14:{loc:{start:{line:169,column:24},end:{line:169,column:78}},type:"binary-expr",locations:[{start:{line:169,column:24},end:{line:169,column:46}},{start:{line:169,column:50},end:{line:169,column:62}},{start:{line:169,column:66},end:{line:169,column:78}}],line:169},15:{loc:{start:{line:170,column:4},end:{line:170,column:25}},type:"if",locations:[{start:{line:170,column:4},end:{line:170,column:25}},{start:{line:170,column:4},end:{line:170,column:25}}],line:170},16:{loc:{start:{line:192,column:4},end:{line:199,column:5}},type:"if",locations:[{start:{line:192,column:4},end:{line:199,column:5}},{start:{line:192,column:4},end:{line:199,column:5}}],line:192},17:{loc:{start:{line:194,column:6},end:{line:196,column:7}},type:"if",locations:[{start:{line:194,column:6},end:{line:196,column:7}},{start:{line:194,column:6},end:{line:196,column:7}}],line:194},18:{loc:{start:{line:201,column:21},end:{line:201,column:49}},type:"binary-expr",locations:[{start:{line:201,column:21},end:{line:201,column:33}},{start:{line:201,column:37},end:{line:201,column:49}}],line:201},19:{loc:{start:{line:202,column:4},end:{line:207,column:5}},type:"if",locations:[{start:{line:202,column:4},end:{line:207,column:5}},{start:{line:202,column:4},end:{line:207,column:5}}],line:202},20:{loc:{start:{line:203,column:6},end:{line:205,column:7}},type:"if",locations:[{start:{line:203,column:6},end:{line:205,column:7}},{start:{line:203,column:6},end:{line:205,column:7}}],line:203},21:{loc:{start:{line:210,column:4},end:{line:217,column:5}},type:"if",locations:[{start:{line:210,column:4},end:{line:217,column:5}},{start:{line:210,column:4},end:{line:217,column:5}}],line:210},22:{loc:{start:{line:211,column:6},end:{line:213,column:7}},type:"if",locations:[{start:{line:211,column:6},end:{line:213,column:7}},{start:{line:211,column:6},end:{line:213,column:7}}],line:211},23:{loc:{start:{line:219,column:25},end:{line:219,column:54}},type:"binary-expr",locations:[{start:{line:219,column:25},end:{line:219,column:38}},{start:{line:219,column:42},end:{line:219,column:54}}],line:219},24:{loc:{start:{line:220,column:4},end:{line:224,column:5}},type:"if",locations:[{start:{line:220,column:4},end:{line:224,column:5}},{start:{line:220,column:4},end:{line:224,column:5}}],line:220},25:{loc:{start:{line:235,column:4},end:{line:253,column:5}},type:"if",locations:[{start:{line:235,column:4},end:{line:253,column:5}},{start:{line:235,column:4},end:{line:253,column:5}}],line:235},26:{loc:{start:{line:237,column:6},end:{line:252,column:7}},type:"if",locations:[{start:{line:237,column:6},end:{line:252,column:7}},{start:{line:237,column:6},end:{line:252,column:7}}],line:237},27:{loc:{start:{line:237,column:10},end:{line:237,column:51}},type:"binary-expr",locations:[{start:{line:237,column:10},end:{line:237,column:20}},{start:{line:237,column:24},end:{line:237,column:51}}],line:237},28:{loc:{start:{line:238,column:8},end:{line:243,column:9}},type:"if",locations:[{start:{line:238,column:8},end:{line:243,column:9}},{start:{line:238,column:8},end:{line:243,column:9}}],line:238},29:{loc:{start:{line:246,column:8},end:{line:251,column:9}},type:"if",locations:[{start:{line:246,column:8},end:{line:251,column:9}},{start:{line:246,column:8},end:{line:251,column:9}}],line:246},30:{loc:{start:{line:254,column:4},end:{line:266,column:5}},type:"if",locations:[{start:{line:254,column:4},end:{line:266,column:5}},{start:{line:254,column:4},end:{line:266,column:5}}],line:254},31:{loc:{start:{line:256,column:6},end:{line:261,column:7}},type:"if",locations:[{start:{line:256,column:6},end:{line:261,column:7}},{start:{line:256,column:6},end:{line:261,column:7}}],line:256},32:{loc:{start:{line:256,column:10},end:{line:256,column:56}},type:"binary-expr",locations:[{start:{line:256,column:10},end:{line:256,column:20}},{start:{line:256,column:24},end:{line:256,column:56}}],line:256},33:{loc:{start:{line:281,column:4},end:{line:284,column:5}},type:"if",locations:[{start:{line:281,column:4},end:{line:284,column:5}},{start:{line:281,column:4},end:{line:284,column:5}}],line:281},34:{loc:{start:{line:290,column:4},end:{line:293,column:5}},type:"if",locations:[{start:{line:290,column:4},end:{line:293,column:5}},{start:{line:290,column:4},end:{line:293,column:5}}],line:290},35:{loc:{start:{line:295,column:4},end:{line:306,column:5}},type:"if",locations:[{start:{line:295,column:4},end:{line:306,column:5}},{start:{line:295,column:4},end:{line:306,column:5}}],line:295}},s:{0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,59:0,60:0,61:0,62:0,63:0,64:0,65:0,66:0,67:0,68:0,69:0,70:0,71:0,72:0,73:0,74:0,75:0,76:0,77:0,78:0,79:0,80:0,81:0,82:0,83:0,84:0,85:0,86:0,87:0,88:0,89:0,90:0,91:0,92:0,93:0,94:0,95:0,96:0,97:0,98:0,99:0,100:0,101:0,102:0,103:0,104:0,105:0,106:0,107:0,108:0,109:0,110:0,111:0,112:0,113:0,114:0,115:0,116:0,117:0,118:0,119:0,120:0,121:0,122:0,123:0,124:0,125:0,126:0,127:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:0,136:0,137:0,138:0,139:0,140:0,141:0,142:0,143:0,144:0,145:0,146:0,147:0,148:0,149:0,150:0,151:0,152:0,153:0,154:0,155:0,156:0,157:0,158:0,159:0,160:0,161:0,162:0,163:0,164:0,165:0,166:0,167:0,168:0,169:0,170:0,171:0,172:0,173:0,174:0,175:0,176:0,177:0,178:0,179:0,180:0,181:0,182:0},f:{0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},b:{0:[0,0],1:[0,0],2:[0,0],3:[0,0],4:[0,0],5:[0,0],6:[0,0,0],7:[0,0],8:[0,0],9:[0,0],10:[0,0],11:[0,0],12:[0,0,0],13:[0,0],14:[0,0,0],15:[0,0],16:[0,0],17:[0,0],18:[0,0],19:[0,0],20:[0,0],21:[0,0],22:[0,0],23:[0,0],24:[0,0],25:[0,0],26:[0,0],27:[0,0],28:[0,0],29:[0,0],30:[0,0],31:[0,0],32:[0,0],33:[0,0],34:[0,0],35:[0,0]},_coverageSchema:"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c"},r=i[s]||(i[s]={});return r[t]&&r[t].hash===e?r[t]:(n.hash=e,r[t]=n)}();Object.defineProperty(i,"__esModule",{value:!0}),i.feedPosition=r,i.jumpPosition=a,i.makeInitialPosition=o,i.copyPosition=h,i.default=function(t,e){s.f[4]++;var i=(s.s[12]++,{str:t,options:e,position:o(),tokens:[]});return s.s[13]++,l(i),s.s[14]++,i.tokens},i.lex=l,i.findTextEnd=u,i.lexText=c,i.lexComment=m,i.lexTag=p,i.isWhitespaceChar=v,i.lexTagName=f,i.lexTagAttributes=y,i.lexSkipTag=_;var n=t("./compat");function r(t,e,i){s.f[0]++;var n=(s.s[0]++,t.index),r=(s.s[1]++,t.index=n+i);s.s[2]++;for(var a=n;a"===h)));if(s.s[81]++,l){s.b[13][0]++,s.s[82]++;break}s.b[13][1]++,s.s[83]++,o++}var d=(s.s[84]++,o+1);for(s.s[85]++;d"===u)));if(s.s[88]++,!c){s.b[15][0]++,s.s[89]++;break}s.b[15][1]++,s.s[90]++,d++}s.s[91]++,a(n,i,d);var m=(s.s[92]++,i.slice(o,d));return s.s[93]++,t.tokens.push({type:"tag",content:m}),s.s[94]++,m}function y(t){s.f[12]++;var e=(s.s[95]++,t),i=e.str,r=e.position,o=e.tokens,h=(s.s[96]++,r.index),l=(s.s[97]++,null),d=(s.s[98]++,h),u=(s.s[99]++,[]),c=(s.s[100]++,i.length);for(s.s[101]++;h"===m));if(s.s[110]++,g){s.b[19][0]++,s.s[111]++,h!==d?(s.b[20][0]++,s.s[112]++,u.push(i.slice(d,h))):s.b[20][1]++,s.s[113]++;break}s.b[19][1]++;var f=(s.s[114]++,v(m));if(s.s[115]++,f)s.b[21][0]++,s.s[116]++,h!==d?(s.b[22][0]++,s.s[117]++,u.push(i.slice(d,h))):s.b[22][1]++,s.s[118]++,d=h+1,s.s[119]++,h++,s.s[120]++;else{s.b[21][1]++;var y=(s.s[121]++,s.b[23][0]++,"'"===m||(s.b[23][1]++,'"'===m));s.s[122]++,y?(s.b[24][0]++,s.s[123]++,l=m,s.s[124]++,h++,s.s[125]++):(s.b[24][1]++,s.s[126]++,h++)}}}s.s[127]++,a(r,i,h);var b=(s.s[128]++,u.length),_=(s.s[129]++,"attribute");s.s[130]++;for(var P=0;P1){s.b[28][0]++;var S=(s.s[137]++,w+T);s.s[138]++,o.push({type:_,content:S}),s.s[139]++,P+=1,s.s[140]++;continue}s.b[28][1]++;var A=(s.s[141]++,u[P+2]);if(s.s[142]++,P+=1,s.s[143]++,A){s.b[29][0]++;var E=(s.s[144]++,w+"="+A);s.s[145]++,o.push({type:_,content:E}),s.s[146]++,P+=1,s.s[147]++;continue}s.b[29][1]++}else s.b[26][1]++}else s.b[25][1]++;if(s.s[148]++,(0,n.endsWith)(w,"=")){s.b[30][0]++;var C=(s.s[149]++,u[P+1]);if(s.s[150]++,s.b[32][0]++,C&&(s.b[32][1]++,!(0,n.stringIncludes)(C,"="))){s.b[31][0]++;var D=(s.s[151]++,w+C);s.s[152]++,o.push({type:_,content:D}),s.s[153]++,P+=1,s.s[154]++;continue}s.b[31][1]++;var I=(s.s[155]++,w.slice(0,-1));s.s[156]++,o.push({type:_,content:I}),s.s[157]++}else s.b[30][1]++,s.s[158]++,o.push({type:_,content:w})}}var b=(s.s[159]++,[].push);function _(t,e){s.f[13]++;var i=(s.s[160]++,e),n=i.str,r=i.position,o=i.tokens,l=(s.s[161]++,t.toLowerCase()),d=(s.s[162]++,n.length),u=(s.s[163]++,r.index);for(s.s[164]++;u=0;){var o=(s.s[8]++,e[a].tagName);if(s.s[9]++,o===t){s.b[1][0]++,s.s[10]++;break}if(s.b[1][1]++,s.s[11]++,(0,n.arrayIncludes)(r,o))return s.b[2][0]++,s.s[12]++,!0;s.b[2][1]++,s.s[13]++,a--}}else s.b[0][1]++;return s.s[14]++,!1}function a(t,e,i,n){s.f[2]++,s.s[15]++,t[e].position.end=n,s.s[16]++;for(var r=e+1,a=t.length;r-1;){if(s.s[37]++,l[v].tagName===g){s.b[5][0]++,s.s[38]++,f=!0,s.s[39]++;break}s.b[5][1]++}for(s.s[40]++;c0;){if(s.s[57]++,g===l[w].tagName){s.b[10][0]++,s.s[58]++,a(l,w,m.position.start,m.position.start);var x=(s.s[59]++,w-1);s.s[60]++,d=l[x].children,s.s[61]++;break}s.b[10][1]++,s.s[62]++,w-=1}}else s.b[9][1]++;var T=(s.s[63]++,[]),S=void 0;for(s.s[64]++;c"):(s.b[4][1]++,"<"+o+r(h)+">"+a(l,e)+"")})).join("")}i.default={toHTML:a}},{"./compat":1}],7:[function(t,e,i){"use strict";var s=function(){var t="/Users/chrisandrejewski/Desktop/Work/github-repos/himalaya/src/tags.js",e="6039b9f65d15797c952509955976acf6930e65a4",i=new(0,function(){}.constructor)("return this")(),s="__coverage__",n={path:"/Users/chrisandrejewski/Desktop/Work/github-repos/himalaya/src/tags.js",statementMap:{0:{start:{line:5,column:29},end:{line:5,column:60}},1:{start:{line:11,column:27},end:{line:14,column:1}},2:{start:{line:23,column:42},end:{line:32,column:1}},3:{start:{line:38,column:24},end:{line:42,column:1}}},fnMap:{},branchMap:{},s:{0:0,1:0,2:0,3:0},f:{},b:{},_coverageSchema:"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c"},r=i[s]||(i[s]={});return r[t]&&r[t].hash===e?r[t]:(n.hash=e,r[t]=n)}();Object.defineProperty(i,"__esModule",{value:!0});i.childlessTags=(s.s[0]++,["style","script","template"]),i.closingTags=(s.s[1]++,["html","head","body","p","dt","dd","li","option","thead","th","tbody","tr","td","tfoot","colgroup"]),i.closingTagAncestorBreakers=(s.s[2]++,{li:["ul","ol","menu"],dt:["dl"],dd:["dl"],tbody:["table"],thead:["table"],tfoot:["table"],tr:["table"],td:["table"]}),i.voidTags=(s.s[3]++,["!doctype","area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"])},{}]},{},[3])(3)})),(()=>{"use strict";var t={897:(t,e,i)=>{var s;i.d(e,{Z:()=>n}),t=i.hmd(t);try{s=t&&t.hot}catch(r){s=!1}var n=s}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var r=e[s]={id:s,loaded:!1,exports:{}};return t[s](r,r.exports,i),r.loaded=!0,r.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t,e,s,n,r,a,o,h,l=i(897);var d=class{constructor(t){if(this.name=t,window.phet){if("chipper"===t)return window.phet.chipper.name="chipper",window.phet.chipper.register=this.register.bind(window.phet.chipper),window.phet.chipper;window.phet[t]=this}}register(t,e){if(t.indexOf(".")<0)l.Z,this[t]=e;else{for(var i=t.split("."),s=this,n=0;n0){var s={index:0};for(var n of(this.emitContexts.push(s),this.listeners))if(n(...e),s.index++,s.listenerArray)break;if(s.listenerArray)for(var r=s.index;r=0&&!this.emitContexts[t].listenerArray;t--)this.emitContexts[t].listenerArray=Array.from(this.listeners)}hasListener(t){return this.listeners.has(t)}hasListeners(){return this.listeners.size>0}getListenerCount(){return this.listeners.size}forEachListener(t){this.listeners.forEach(t)}}u.register("TinyEmitter",c);class m extends c{setTimeout(t,e){var i=0,s=n=>{1e3*(i+=n)>=e&&this.hasListener(s)&&(t(),this.removeListener(s))};return this.addListener(s),s}clearTimeout(t){this.hasListener(t)&&this.removeListener(t)}setInterval(t,e){var i=0,s=n=>{for(i+=n;1e3*i>=e&&this.hasListener(s);)t(),i-=e/1e3};return this.addListener(s),s}clearInterval(t){this.hasListener(t)&&this.removeListener(t)}runOnNextTick(t){this.setTimeout(t,0)}}u.register("Timer",m);var p=new m;u.register("animationFrameTimer",p);var g=p,v=new d("phetCore");v.register("Namespace",d);var f=v;function y(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s{if(e)for(var i in e)if(e.hasOwnProperty(i)&&void 0!==e[i]){var s=e[i];_.endsWith(i,"Options")&&"Options"!==i?t[i]=y(t[i]||{},s):t[i]=s}}),t}f.register("merge",y);var b=y,P=(t,e,i,s)=>b(t,e,i,s);function w(){return P}function x(){return P}function T(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s{window.phet&&window.phet.chipper&&window.phet.chipper.queryParameters&&phet.chipper.queryParameters.deprecationWarnings&&(A.hasOwnProperty(t)||(A[t]=!0,console.warn("Deprecation warning: ".concat(t))))};f.register("deprecationWarning",E);var C=E;class D{constructor(t){C("EnumerationDeprecated should be exchanged for classes that extend EnumerationValue, see WilderEnumerationPatterns for examples.");t.keys,t.map;var e=t.keys||Object.keys(t.map),i=t.map||{};t=b({phetioDocumentation:null,beforeFreeze:null},t),this.phetioDocumentation=t.phetioDocumentation,this.KEYS=e,this.VALUES=[],e.forEach(t=>{var e=i[t]||{};e.name=t,e.toString=()=>t,this[t]=e,this.VALUES.push(e)}),t.beforeFreeze&&t.beforeFreeze(this)}toString(){return this.KEYS.join(", ")}includes(t){return _.includes(this.VALUES,t)}getValue(t){return this[t]}getKey(t){return t.name}get values(){return this.VALUES}get keys(){return this.KEYS}get enumeration(){return this}static byKeys(t,e){return new D(b({keys:t},e))}static byMap(t,e){return new D(b({map:t},e))}}f.register("EnumerationDeprecated",D);var I=D,L=["string","number","boolean","function"],k=["valueType","validValues","isValidValue","phetioType","validators"];class M{static getValidatorValidationError(t){if(!(t instanceof Object))return"validator must be an Object";if(!(t.hasOwnProperty("isValidValue")||t.hasOwnProperty("valueType")||t.hasOwnProperty("validValues")||t.hasOwnProperty("phetioType")||t.hasOwnProperty("validators")))return this.combineErrorMessages("validator must have at least one of: ".concat(k.join(",")),t.validationMessage);if(t.hasOwnProperty("valueType")){var e=M.getValueOrElementTypeValidationError(t.valueType);if(e)return this.combineErrorMessages("Invalid valueType: ".concat(t.valueType,", error: ").concat(e),t.validationMessage)}if(t.hasOwnProperty("isValidValue")&&"function"!=typeof t.isValidValue&&null!==t.isValidValue&&void 0!==t.isValidValue)return this.combineErrorMessages("isValidValue must be a function: ".concat(t.isValidValue),t.validationMessage);if(void 0!==t.validValues&&null!==t.validValues){if(!Array.isArray(t.validValues))return this.combineErrorMessages("validValues must be an array: ".concat(t.validValues),t.validationMessage);var i=_.omit(t,"validValues");if(M.containsValidatorKey(i))for(var s=0;s!M.getValueTypeValidationError(t,i,e.validationMessage))))return this.combineErrorMessages("value not valid for any valueType in ".concat(r.toString().substring(0,100),", value: ").concat(t),e.validationMessage)}else if(r){var a=M.getValueTypeValidationError(t,r,e.validationMessage);if(a)return a}}if(e.hasOwnProperty("validValues")&&!e.validValues.includes(t))return this.combineErrorMessages("value not in validValues: ".concat(t),e.validationMessage);if(e.hasOwnProperty("isValidValue")&&!e.isValidValue(t))return this.combineErrorMessages("value failed isValidValue: ".concat(t),e.validationMessage);if(e.hasOwnProperty("phetioType")){var o=M.getValidationError(t,e.phetioType.validator,s);if(o)return this.combineErrorMessages("value failed phetioType validator: ".concat(t,", error: ").concat(o),e.validationMessage)}if(e.hasOwnProperty("validators"))for(var h=e.validators,l=0;l!/\{\{\w*\}\}/.test(t)}),u.register("Validation",M);var O=(t,e,i)=>{};u.register("validate",O);var R=O,N={IO_TYPE_SUFFIX:"IO"};S.register("PhetioConstants",N);var B=N,F={OBJECT_IO_TYPE_NAME:"ObjectIO",EVENT_TYPE_MODEL:"MODEL",PHET_IO_OBJECT_METADATA_DEFAULTS:{phetioTypeName:"ObjectIO",phetioDocumentation:"",phetioState:!0,phetioReadOnly:!1,phetioEventType:"MODEL",phetioHighFrequency:!1,phetioPlayback:!1,phetioDynamicElement:!1,phetioIsArchetype:!1,phetioFeatured:!1,phetioDesigned:!1,phetioArchetypePhetioID:null},METADATA_KEY_NAME:"_metadata",DATA_KEY_NAME:"_data"};S.register("TandemConstants",F);var V=F,H=function(t){};f.register("assertMutuallyExclusiveOptions",H);var Y=H;class z{constructor(t){var e=w()({displayString:"",validator:null,compositeSchema:null},t);this.displayString=e.displayString,this.validator=e.validator,this.compositeSchema=e.compositeSchema}validateStateSchema(t){}defaultApplyState(t,e){var i=(e,s)=>{for(var n in e)if(e.hasOwnProperty(n))if("_private"===n)i(e._private,s._private);else{var r=e[n];"fromStateObject"===r.defaultDeserializationMethod?t[n]=e[n].fromStateObject(s[n]):e[n].applyState(t[n],s[n])}};i(this.compositeSchema,e)}defaultToStateObject(t){var e=i=>{var s={};for(var n in i)i.hasOwnProperty(n)&&("_private"===n?s._private=e(i._private):s[n]=i[n].toStateObject(t[n]));return s};return e(this.compositeSchema)}isComposite(){return!!this.compositeSchema}checkStateObjectValid(t,e,i,s){if(this.isComposite()){var n=t,r=this.compositeSchema,a=null,o=(t,e,i,s)=>{Object.keys(t).filter(t=>t!==s).forEach(s=>{var n=e.hasOwnProperty(s);n||(a=!1),t[s].validateStateObject(e[s]),i.push(s)})};return o(r,n,i,"_private"),r._private&&o(r._private,n._private,s,null),a}var h=t;return e&&R(h,this.validator),M.isValueValid(h,this.validator)}getRelatedTypes(){var t=[],e=e=>{Object.keys(e).forEach(i=>{e[i]instanceof j&&t.push(e[i])})};return this.compositeSchema&&(e(this.compositeSchema),this.compositeSchema._private&&e(this.compositeSchema._private)),t}getStateSchemaAPI(){if(this.isComposite()){var t=_.mapValues(this.compositeSchema,t=>t.typeName);return this.compositeSchema._private&&(t._private=_.mapValues(this.compositeSchema._private,t=>t.typeName)),t}return this.displayString}static asValue(t,e){return new z({validator:e,displayString:t})}}S.register("StateSchema",z);var W=z,U={validateValidator:!1},G=t=>{var e=t.indexOf(B.IO_TYPE_SUFFIX);return t.substring(0,e)};class X{constructor(t,e){var i=e.supertype||X.ObjectIO,s=!!e.toStateObject,n=!!e.applyState,r=!!e.stateSchema,a=w()({supertype:X.ObjectIO,methods:{},events:[],metadataDefaults:{},dataDefaults:{},methodOrder:[],parameterTypes:[],documentation:"IO Type for ".concat(G(t)),isFunctionType:!1,toStateObject:i&&i.toStateObject,fromStateObject:i&&i.fromStateObject,stateToArgsForConstructor:i&&i.stateToArgsForConstructor,applyState:i&&i.applyState,stateSchema:null,defaultDeserializationMethod:"fromStateObject",addChildElement:i&&i.addChildElement},e);this.supertype=i,this.typeName=t,this.documentation=a.documentation,this.methods=a.methods,this.events=a.events,this.metadataDefaults=a.metadataDefaults,this.dataDefaults=a.dataDefaults,this.methodOrder=a.methodOrder,this.parameterTypes=a.parameterTypes,this.validator=_.pick(a,M.VALIDATOR_KEYS),this.validator.validationMessage=this.validator.validationMessage||"Validation failed IOType Validator: ".concat(this.typeName),this.defaultDeserializationMethod=a.defaultDeserializationMethod;var o=a.stateSchema;if(null!==o&&!(o instanceof W)){var h="function"==typeof o?o(this):o;o=new W({compositeSchema:h})}this.stateSchema=o,this.toStateObject=t=>(R(t,this.validator,U),!s&&r&&this.stateSchema.isComposite()?this.stateSchema.defaultToStateObject(t):a.toStateObject(t)),this.fromStateObject=a.fromStateObject,this.stateToArgsForConstructor=a.stateToArgsForConstructor,this.applyState=(t,e)=>{R(t,this.validator,U),!n&&r&&this.stateSchema.isComposite()?this.stateSchema.defaultApplyState(t,e):a.applyState(t,e)},this.isFunctionType=a.isFunctionType,this.addChildElement=a.addChildElement;this.typeName.split(/[<(]/)[0];if(this.methods&&Object.values(this.methods).forEach(t=>{}),this.methods&&this.hasOwnProperty("methodOrder")&&this.methodOrder.forEach(t=>{}),i)i.getTypeHierarchy()}getTypeHierarchy(){for(var t=[],e=this;e;)t.push(e),e=e.supertype;return t}extends(t){return this===t||!!this.supertype&&this.supertype.extends(t)}getAllMetadataDefaults(){return _.merge({},this.supertype?this.supertype.getAllMetadataDefaults():{},this.metadataDefaults)}getAllDataDefaults(){return _.merge({},this.supertype?this.supertype.getAllDataDefaults():{},this.dataDefaults)}isStateObjectValid(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],n=!0;if(this.stateSchema){var r=this.stateSchema.checkStateObjectValid(t,e,i,s);if(null!==r)return r}if(this.supertype&&(!this.stateSchema||!this.stateSchema.isComposite()))return n&&this.supertype.isStateObjectValid(t,e,i,s);if(!this.supertype&&t&&"string"!=typeof t&&!Array.isArray(t)){var a=(t,e)=>{var r=("public"===t?i:s).includes(e);r||(n=!1)};return Object.keys(t).filter(t=>"_private"!==t).forEach(t=>a("public",t)),t._private&&Object.keys(t._private).forEach(t=>a("private",t)),n}return!0}validateStateObject(t){this.isStateObjectValid(t,!0)}static fromCoreType(t,e,i){for(var s=!1,n=!1,r=e.prototype;r;)"function"==typeof r.toStateObject&&(s=!0),"function"==typeof r.applyState&&(n=!0),r=Object.getPrototypeOf(r);var a=T({valueType:e},i);return s&&(a.toStateObject=t=>t.toStateObject()),n&&(a.applyState=(t,e)=>t.applyState(e)),e.fromStateObject&&(a.fromStateObject=e.fromStateObject),e.stateToArgsForConstructor&&(a.stateToArgsForConstructor=e.stateToArgsForConstructor),e.STATE_SCHEMA&&(a.stateSchema=e.STATE_SCHEMA),new X(t,a)}}X.ObjectIO=new X(V.OBJECT_IO_TYPE_NAME,{isValidValue:()=>!0,supertype:null,documentation:"The root of the IO Type hierarchy",toStateObject:t=>null,fromStateObject:t=>null,stateToArgsForConstructor:t=>[],applyState:_.noop,metadataDefaults:V.PHET_IO_OBJECT_METADATA_DEFAULTS,dataDefaults:{initialState:null},stateSchema:null}),S.register("IOType",X);var j=X,q=new j("ValueIO",{isValidValue:_.stubTrue,supertype:j.ObjectIO,toStateObject:t=>t,fromStateObject:t=>t,stateSchema:W.asValue("*",{isValidValue:_.stubTrue})});S.register("ValueIO",q);var K=q,Z=new j("BooleanIO",{supertype:K,valueType:"boolean",documentation:"IO Type for Javascript's boolean primitive type",stateSchema:W.asValue("boolean",{valueType:"boolean"}),toStateObject:_.identity});S.register("BooleanIO",Z);var Q=Z;function J(t,e){var i=_.indexOf(t,e);t.splice(i,1)}f.register("arrayRemove",J);var tt=J;class et{toString(){return this.name}isEnumerationValue(){return!0}constructor(){this.constructor;this._name=null,this._enumeration=null}set name(t){this._name=t}get name(){return this._name}set enumeration(t){this._enumeration=t}get enumeration(){return this._enumeration}}_defineProperty(et,"sealedCache",new Set),f.register("EnumerationValue",et);var it=et;function st(t){for(var e=[t],i=t.prototype;i&&(i=Object.getPrototypeOf(i));)i.constructor&&e.push(i.constructor);return e}f.register("inheritance",st);var nt=st;class rt{constructor(t,e){var i=w()({phetioDocumentation:"",instanceType:t},e);this.phetioDocumentation=i.phetioDocumentation;var s=i.instanceType,n=_.reverse(nt(t));this.keys=[],this.values=[],n.forEach(e=>{Object.keys(e).forEach(i=>{var n=e[i];n instanceof s&&(this.keys.push(i),this.values.push(n),n instanceof t&&(n.name=i,n.enumeration=this))})}),this.Enumeration=t,it.sealedCache.add(t)}getKey(t){return t.name}getValue(t){return this.Enumeration[t]}includes(t){return this.values.includes(t)}}f.register("Enumeration",rt);var at=rt,ot=new Map,ht=t=>t.join("|"),lt=t=>{var e=t.enumeration;if(!ot.has(e)){var i=e.phetioDocumentation?" ".concat(e.phetioDocumentation):"",s=e.keys,n=e.values;ot.set(e,new j("EnumerationIO(".concat(ht(s),")"),{validValues:n,documentation:"Possible values: ".concat(s.join(", "),".").concat(i),toStateObject:t=>e.getKey(t),fromStateObject:t=>e.getValue(t),stateSchema:W.asValue("".concat(ht(s)),{isValidValue:t=>s.includes(t)})}))}return ot.get(e)};S.register("EnumerationIO",lt);var dt=lt;h=V.EVENT_TYPE_MODEL;class ut extends it{}_defineProperty(ut,"USER",new ut),_defineProperty(ut,h,new ut),_defineProperty(ut,"WRAPPER",new ut),_defineProperty(ut,"OPT_OUT",new ut),_defineProperty(ut,"enumeration",new at(ut)),_defineProperty(ut,"phetioType",dt(ut)),S.register("EventType",ut);var ct=ut,mt=_.hasIn(window,"phet.chipper.packageObject")?phet.chipper.packageObject:{name:"placeholder"},pt=_.hasIn(window,"phet.preloads.phetio"),gt=pt&&phet.preloads.phetio.queryParameters.phetioPrintMissingTandems,vt=!_.hasIn(mt,"phet.phet-io.validation")||!!mt.phet["phet-io"].validation,ft=window.QueryStringMachine&&QueryStringMachine.containsKey("phetioValidation"),yt=pt&&ft?!!phet.preloads.phetio.queryParameters.phetioValidation:pt&&vt,bt=pt&&yt&&!gt,_t=phetio.PhetioIDUtils.INTER_TERM_SEPARATOR,Pt={required:[],optional:[]},wt=[],xt=[];class Tt{constructor(t,e,i){_defineProperty(this,"children",{}),_defineProperty(this,"isDisposed",!1),this.parentTandem=t,this.name=e,this.phetioID=this.parentTandem?window.phetio.PhetioIDUtils.append(this.parentTandem.phetioID,this.name):this.name;var s=w()({required:!0,supplied:!0,isValidTandemName:t=>/^[a-zA-Z0-9[\],]+$/.test(t)},i);this.children={},this.parentTandem&&this.parentTandem.addChild(e,this),this.required=s.required,this.supplied=s.supplied}static onMissingTandem(t){if(gt&&!t.supplied){var e=(new Error).stack;t.required?Pt.required.push({phetioID:t.phetioID,stack:e}):e.includes("Font")||Pt.optional.push({phetioID:t.phetioID,stack:e})}}addPhetioObject(t){if(pt){if(!this.required&&!this.supplied)return;if(Tt.launched)for(var e=0;et.includes("_")?"archetype":t).join(_t):t}createGroupTandem(t){return this.children[t]?this.children[t]:new Et(this,t)}equals(t){return this.phetioID===t.phetioID}static addPhetioObjectListener(t){wt.push(t)}static launch(){for(Tt.launched=!0;xt.length>0;)xt.shift()()}static unlaunch(){Tt.launched=!1,Tt.bufferedPhetioObjects.length=0,xt.length=0}static addLaunchListener(t){xt.push(t)}createTandemFromPhetioID(t){return this.createTandem(t.split(window.phetio.PhetioIDUtils.SEPARATOR).join(_t),{isValidTandemName:t=>/^[a-zA-Z0-9[\],-_]+$/.test(t)})}}_defineProperty(Tt,"SCREEN_TANDEM_NAME_SUFFIX","Screen"),_defineProperty(Tt,"missingTandems",Pt),_defineProperty(Tt,"PHET_IO_ENABLED",pt),_defineProperty(Tt,"API_GENERATION",Tt.PHET_IO_ENABLED&&(phet.preloads.phetio.queryParameters.phetioPrintAPI||phet.preloads.phetio.queryParameters.phetioCompareAPI)),_defineProperty(Tt,"VALIDATION",bt),_defineProperty(Tt,"METADATA_KEY","_metadata"),_defineProperty(Tt,"DATA_KEY","_data"),_defineProperty(Tt,"launched",!1),_defineProperty(Tt,"bufferedPhetioObjects",[]),Tt.addLaunchListener(()=>{for(;Tt.bufferedPhetioObjects.length>0;){var t=Tt.bufferedPhetioObjects.shift();t.tandem.addPhetioObject(t)}});Tt.ROOT=new class extends Tt{createTandem(t,e){if(Tt.VALIDATION)t===window.phetio.PhetioIDUtils.GLOBAL_COMPONENT_NAME||"requiredTandem"===t||"optionalTandem"===t||"test"===t||t===window.phetio.PhetioIDUtils.GENERAL_COMPONENT_NAME||_.endsWith(t,Tt.SCREEN_TANDEM_NAME_SUFFIX);return super.createTandem(t,e)}}(null,_.camelCase(mt.name));var St=Tt.ROOT.createTandem(window.phetio.PhetioIDUtils.GENERAL_COMPONENT_NAME);Tt.ROOT_TEST=Tt.ROOT.createTandem("test"),Tt.GENERAL_MODEL=St.createTandem(window.phetio.PhetioIDUtils.MODEL_COMPONENT_NAME),Tt.GENERAL_VIEW=St.createTandem(window.phetio.PhetioIDUtils.VIEW_COMPONENT_NAME),Tt.GENERAL_CONTROLLER=St.createTandem(window.phetio.PhetioIDUtils.CONTROLLER_COMPONENT_NAME);var At=Tt.ROOT.createTandem(window.phetio.PhetioIDUtils.GLOBAL_COMPONENT_NAME);Tt.GLOBAL_MODEL=At.createTandem(window.phetio.PhetioIDUtils.MODEL_COMPONENT_NAME),Tt.GLOBAL_VIEW=At.createTandem(window.phetio.PhetioIDUtils.VIEW_COMPONENT_NAME),Tt.COLORS=Tt.GLOBAL_VIEW.createTandem(window.phetio.PhetioIDUtils.COLORS_COMPONENT_NAME),Tt.OPTIONAL=Tt.ROOT.createTandem("optionalTandem",{required:!1,supplied:!1}),Tt.OPT_OUT=Tt.OPTIONAL,Tt.REQUIRED=Tt.ROOT.createTandem("requiredTandem",{required:bt||gt,supplied:!1}),Tt.PREFERENCES=Tt.GLOBAL_MODEL.createTandem("preferences");class Et extends Tt{constructor(t,e){super(t,e),this.groupName=e,this.groupMemberIndex=0}createNextTandem(){var t=this.parentTandem.createTandem("".concat(this.groupName).concat(this.groupMemberIndex));return this.groupMemberIndex++,t}}S.register("Tandem",Tt);var Ct=Tt,Dt=new j("StringIO",{supertype:K,valueType:"string",documentation:"IO Type for Javascript's string primitive type",stateSchema:W.asValue("string",{valueType:"string"}),toStateObject:_.identity});S.register("StringIO",Dt);var It=Dt;var Lt=new class extends j{constructor(){super(...arguments),_defineProperty(this,"applyState",()=>{})}}("LinkedElementIO",{isValidValue:()=>!0,documentation:"A LinkedElement",toStateObject:t=>({elementID:t.element.tandem.phetioID}),fromStateObject:t=>({}),stateSchema:{elementID:It}});S.register("LinkedElementIO",Lt);var kt=Lt,Mt=["phetioDynamicElement","phetioEventType","phetioIsArchetype","phetioPlayback","phetioReadOnly","phetioState","phetioTypeName"];var Ot=new class{constructor(){_defineProperty(this,"apiMismatches",[]),_defineProperty(this,"simHasStarted",!1),_defineProperty(this,"enabled",!1),_defineProperty(this,"everyPhetioType",{})}onSimStarted(){this.simHasStarted=!0,this.enabled&&phet.joist.sim.allScreensCreated&&this.validateOverridesFile()}onPhetioObjectRemoved(t){if(this.enabled){var e=t.tandem.phetioID;t.phetioDynamicElement||this.assertAPIError({phetioID:e,ruleInViolation:"2. Any static, registered PhetioObject can never be deregistered."})}}onPhetioObjectAdded(t){if(this.enabled){var e=t.phetioType;this.everyPhetioType[e.typeName]||(this.everyPhetioType[e.typeName]=e),this.simHasStarted&&phet.axon.animationFrameTimer.runOnNextTick(()=>{if(t.phetioDynamicElement){if(phet.preloads.phetio.createArchetypes&&!t.isDisposed){var e=t.tandem.getArchetypalPhetioID(),i=phet.phetio.phetioEngine.getPhetioObject(e).getMetadata();this.checkDynamicInstanceAgainstArchetype(t,i,"simulation archetype")}}else this.assertAPIError({phetioID:t.tandem.phetioID,ruleInViolation:"1. After startup, only dynamic instances prescribed by the baseline file can be registered."})})}}validateOverridesFile(){var t=phet.phetio.phetioEngine.getPhetioElementsBaseline();for(var e in window.phet.preloads.phetio.phetioElementsOverrides){e.includes("archetype");if(phet.preloads.phetio.createArchetypes||t.hasOwnProperty(e))if(t.hasOwnProperty(e)){var i=window.phet.preloads.phetio.phetioElementsOverrides[e],s=t[e];for(var n in 0===Object.keys(i).length&&this.assertAPIError({phetioID:e,ruleInViolation:"4. Any schema entries in the overrides file must be different from its baseline counterpart.",message:"no metadata keys found for this override."}),i)s.hasOwnProperty(n)||this.assertAPIError({phetioID:e,ruleInViolation:"8. Any schema entries in the overrides file must be different from its baseline counterpart.",message:"phetioID metadata key not found in the baseline: ".concat(n)}),i[n]===s[n]&&this.assertAPIError({phetioID:e,ruleInViolation:"8. Any schema entries in the overrides file must be different from its baseline counterpart.",message:"phetioID metadata override value is the same as the corresponding metadata value in the baseline."})}else this.assertAPIError({phetioID:e,ruleInViolation:"3. Any schema entries in the overrides file must exist in the baseline file.",message:"phetioID expected in the baseline file but does not exist"});else;}}assertAPIError(t){t.phetioID?"".concat(t.phetioID,": ").concat(t.ruleInViolation):"".concat(t.ruleInViolation);this.apiMismatches.push(t),console.log("error data:",t)}checkDynamicInstanceAgainstArchetype(t,e,i){var s=t.getMetadata();Mt.forEach(n=>{"phetioDynamicElement"!==n&&"phetioArchetypePhetioID"!==n&&"phetioIsArchetype"!==n&&e[n]!==s[n]&&t.tandem&&this.assertAPIError({phetioID:t.tandem.phetioID,ruleInViolation:"5. Dynamic element metadata should match the archetype in the API.",source:i,message:"mismatched metadata: ".concat(n)})})}};S.register("phetioAPIValidation",Ot);var Rt=Ot,Nt=Ct.PHET_IO_ENABLED,Bt=t=>t.tandem.phetioID,Ft={tandem:Ct.OPTIONAL,phetioType:j.ObjectIO,phetioDocumentation:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioDocumentation,phetioState:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioState,phetioReadOnly:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioReadOnly,phetioEventType:ct.MODEL,phetioHighFrequency:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioHighFrequency,phetioPlayback:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioPlayback,phetioFeatured:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioFeatured,phetioDynamicElement:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioDynamicElement,phetioDesigned:V.PHET_IO_OBJECT_METADATA_DEFAULTS.phetioDesigned,phetioEventMetadata:null,tandemSuffix:null};class Vt{constructor(t){this.tandem=Ft.tandem,this.phetioID=this.tandem.phetioID,this.phetioObjectInitialized=!1,this.isDisposed=!1,t&&this.initializePhetioObject({},t)}initializePhetioObject(t,e){if(e.tandem&&Ct.onMissingTandem(e.tandem),Ct.VALIDATION&&e.tandem&&e.tandem.required,Nt&&e.tandem&&e.tandem.supplied){var i=T({},Ft,t),s=w()(i,e);this.phetioIsArchetype=!1,this.phetioBaselineMetadata=Rt.enabled||phet.preloads.phetio.queryParameters.phetioEmitAPIBaseline?this.getMetadata(b({phetioIsArchetype:this.phetioIsArchetype,phetioArchetypePhetioID:this.phetioArchetypePhetioID},s)):null;var n=s.tandem.getArchetypalPhetioID();if(window.phet.preloads.phetio.phetioElementsOverrides){var r=window.phet.preloads.phetio.phetioElementsOverrides[n];r&&(s=w()(s,r))}this.tandem=s.tandem,this.phetioID=this.tandem.phetioID,this._phetioType=s.phetioType,this._phetioState=s.phetioState,this._phetioReadOnly=s.phetioReadOnly,this._phetioDocumentation=s.phetioDocumentation,this._phetioEventType=s.phetioEventType,this._phetioHighFrequency=s.phetioHighFrequency,this._phetioPlayback=s.phetioPlayback,this._phetioDynamicElement=s.phetioDynamicElement,this._phetioFeatured=s.phetioFeatured,this._phetioEventMetadata=s.phetioEventMetadata,this._phetioDesigned=s.phetioDesigned,this.phetioArchetypePhetioID=null,this.linkedElements=[],this.phetioNotifiedObjectCreated=!1,this.phetioMessageStack=[],this._phetioPlayback&&(this._phetioEventMetadata=this._phetioEventMetadata||{},this._phetioEventMetadata.playback=!0),this.tandem.addPhetioObject(this),this.phetioObjectInitialized=!0}else e.tandem&&(this.tandem=e.tandem,this.phetioID=this.tandem.phetioID)}static swapCaseOfFirstCharacter(t){var e=t[0];return(e===e.toLowerCase()?e.toUpperCase():e.toLowerCase())+t.substring(1)}get phetioType(){return this._phetioType}get phetioState(){return this._phetioState}get phetioReadOnly(){return this._phetioReadOnly}get phetioDocumentation(){return this._phetioDocumentation}get phetioEventType(){return this._phetioEventType}get phetioHighFrequency(){return this._phetioHighFrequency}get phetioPlayback(){return this._phetioPlayback}get phetioDynamicElement(){return this._phetioDynamicElement}get phetioFeatured(){return this._phetioFeatured}get phetioEventMetadata(){return this._phetioEventMetadata}get phetioDesigned(){return this._phetioDesigned}phetioStartEvent(t,e){if(Nt&&this.isPhetioInstrumented()){var i=w()({data:null,getData:null},e),s=this.phetioHighFrequency&&_.hasIn(window,"phet.preloads.phetio.queryParameters")&&!window.phet.preloads.phetio.queryParameters.phetioEmitHighFrequencyEvents&&!phet.phetio.dataStream.isEmittingLowFrequencyEvent(),n=!_.hasIn(window,"phet.phetio.dataStream");if(s||this.phetioEventType===ct.OPT_OUT||n)return void this.phetioMessageStack.push(-1);var r=i.getData?i.getData():i.data;this.phetioMessageStack.push(phet.phetio.dataStream.start(this.phetioEventType,this.tandem.phetioID,this.phetioType,t,r,this.phetioEventMetadata,this.phetioHighFrequency)),this.phetioPlayback&&phet.phetio.dataStream.pushNonPlaybackable()}}phetioEndEvent(){if(Nt&&this.isPhetioInstrumented()){var t=this.phetioMessageStack.pop();if(-1===t)return;this.phetioPlayback&&phet.phetio.dataStream.popNonPlaybackable(),phet.phetio.dataStream.end(t)}}propagateDynamicFlagsToDescendants(){var t=phet.phetio.phetioEngine,e=Ct.launched?[]:Ct.bufferedPhetioObjects.map(Bt);this.tandem.iterateDescendants(i=>{var s=i.phetioID;if(t.hasPhetioObject(s)||!Ct.launched&&e.includes(s)){var n=t.hasPhetioObject(s)?t.getPhetioObject(s):Ct.bufferedPhetioObjects[e.indexOf(s)];n.phetioIsArchetype=this.phetioIsArchetype,n.setPhetioDynamicElement(this.phetioDynamicElement),n.phetioBaselineMetadata&&(n.phetioBaselineMetadata.phetioIsArchetype=this.phetioIsArchetype)}})}setPhetioDynamicElement(t){this._phetioDynamicElement=!this.phetioIsArchetype&&t,this.phetioArchetypePhetioID=t?this.tandem.getArchetypalPhetioID():null,this.phetioBaselineMetadata&&(this.phetioBaselineMetadata.phetioDynamicElement=this.phetioDynamicElement)}markDynamicElementArchetype(){this.phetioIsArchetype=!0,this.setPhetioDynamicElement(!1),this.phetioBaselineMetadata&&(this.phetioBaselineMetadata.phetioIsArchetype=this.phetioIsArchetype),Ct.PHET_IO_ENABLED&&this.propagateDynamicFlagsToDescendants()}isPhetioInstrumented(){return this.tandem&&this.tandem.supplied}addLinkedElement(t,e){this.isPhetioInstrumented()?Nt&&t.isPhetioInstrumented()&&this.linkedElements.push(new Ht(t,e)):this.linkedElements=null}removeLinkedElements(t){this.isPhetioInstrumented()&&this.linkedElements&&this.linkedElements.filter(e=>e.element===t).forEach(t=>{t.dispose(),tt(this.linkedElements,t)})}onSimulationConstructionCompleted(){this.phetioBaselineMetadata=null}dispose(){var t=[];if(Ct.PHET_IO_ENABLED&&this.tandem.supplied){var e=phet.phetio.phetioEngine;this.tandem.iterateDescendants(i=>{e.hasPhetioObject(i.phetioID)&&t.push(e.getPhetioObject(i.phetioID))})}this.phetioObjectInitialized&&this.tandem.removePhetioObject(this),this.linkedElements&&(this.linkedElements.forEach(t=>t.dispose()),this.linkedElements.length=0),this.isDisposed=!0}getMetadata(t){var e={phetioTypeName:(t=t||this).phetioType.typeName,phetioDocumentation:t.phetioDocumentation,phetioState:t.phetioState,phetioReadOnly:t.phetioReadOnly,phetioEventType:ct.phetioType.toStateObject(t.phetioEventType),phetioHighFrequency:t.phetioHighFrequency,phetioPlayback:t.phetioPlayback,phetioDynamicElement:t.phetioDynamicElement,phetioIsArchetype:t.phetioIsArchetype,phetioFeatured:t.phetioFeatured,phetioDesigned:t.phetioDesigned};return t.phetioArchetypePhetioID&&(e.phetioArchetypePhetioID=t.phetioArchetypePhetioID),e}}_defineProperty(Vt,"DEFAULT_OPTIONS",Ft);class Ht extends Vt{constructor(t,e){var i=w()({phetioType:kt},e);i.phetioReadOnly=!0,i.phetioFeatured=t.phetioFeatured,super(i),this.element=t}getMetadata(t){var e=super.getMetadata(t);return delete e.phetioFeatured,e}}S.register("PhetioObject",Vt);var Yt=new Map,zt=t=>(Yt.has(t)||Yt.set(t,new j("ArrayIO<".concat(t.typeName,">"),{valueType:Array,isValidValue:e=>_.every(e,e=>M.isValueValid(e,t.validator)),parameterTypes:[t],toStateObject:e=>e.map(t.toStateObject),fromStateObject:e=>e.map(t.fromStateObject),documentation:"IO Type for the built-in JS array type, with the element type specified.",stateSchema:W.asValue("Array<".concat(t.typeName,">"),{isValidValue:e=>_.every(e,e=>t.isStateObjectValid(e))})})),Yt.get(t));S.register("ArrayIO",zt);var Wt=zt,Ut=new Map,Gt=(t,e)=>{for(var i=0;it.typeName).join(","));if(!Ut.has(s)){var n=e.map(t=>t.typeName).join(", ");""===n&&(n="none");var r=e.map(t=>t.typeName).join(",");Ut.set(s,new j("FunctionIO(".concat(r,")=>").concat(t.typeName),{valueType:"function",isFunctionType:!0,parameterTypes:e.concat([t]),documentation:"".concat("Wrapper for the built-in JS function type.
Arguments: ").concat(n,"
")+"Return Type: ".concat(t.typeName)}))}return Ut.get(s)};S.register("FunctionIO",Gt);var Xt=Gt,jt=new Map,qt=t=>(jt.has(t)||jt.set(t,new j("NullableIO<".concat(t.typeName,">"),{documentation:"An IOType adding support for null in addition to the behavior of its parameter.",isValidValue:e=>null===e||M.isValueValid(e,t.validator),parameterTypes:[t],toStateObject:e=>null===e?null:t.toStateObject(e),fromStateObject:e=>null===e?null:t.fromStateObject(e),stateSchema:W.asValue("null|<".concat(t.typeName,">"),{isValidValue:e=>null===e||t.isStateObjectValid(e)})})),jt.get(t));S.register("NullableIO",qt);var Kt=qt,Zt=new j("VoidIO",{isValidValue:()=>!0,documentation:"Type for which there is no instance, usually to mark functions without a return value",toStateObject:()=>{}});S.register("VoidIO",Zt);var Qt=Zt;class Jt extends it{}_defineProperty(Jt,"UNDEFER",new Jt),_defineProperty(Jt,"NOTIFY",new Jt),_defineProperty(Jt,"enumeration",new at(Jt)),u.register("PropertyStatePhase",Jt);var $t=Jt;class te{constructor(t){this.phaseCallbackSets=new se,this.undeferBeforeUndeferMapPair=new ie($t.UNDEFER,$t.UNDEFER),this.undeferBeforeNotifyMapPair=new ie($t.UNDEFER,$t.NOTIFY),this.notifyBeforeUndeferMapPair=new ie($t.NOTIFY,$t.UNDEFER),this.notifyBeforeNotifyMapPair=new ie($t.NOTIFY,$t.NOTIFY),this.mapPairs=[this.undeferBeforeUndeferMapPair,this.undeferBeforeNotifyMapPair,this.notifyBeforeUndeferMapPair,this.notifyBeforeNotifyMapPair],this.initialized=!1}initialize(t){t.onBeforeApplyStateEmitter.addListener(t=>{if(t instanceof ce&&!t.isDeferred){t.setDeferred(!0);var e=t.tandem.phetioID;this.phaseCallbackSets.addUndeferPhaseCallback(new ee(e,()=>{var i=t.setDeferred(!1);this.phaseCallbackSets.addNotifyPhaseCallback(new ee(e,i,$t.NOTIFY))},$t.UNDEFER))}}),t.stateSetEmitter.addListener(t=>{this.undeferAndNotifyProperties(new Set(Object.keys(t)))}),t.isSettingStateProperty.lazyLink(t=>{}),this.initialized=!0}validateInstrumentedProperty(t){}validatePropertyPhasePair(t,e){this.validateInstrumentedProperty(t)}getMapPairFromPhases(t,e){var i=this.mapPairs.filter(i=>t===i.beforePhase&&e===i.afterPhase);return i[0]}registerPhetioOrderDependency(t,e,i,s){Ct.PHET_IO_ENABLED&&(this.validatePropertyPhasePair(t,e),this.validatePropertyPhasePair(i,s),this.getMapPairFromPhases(e,s).addOrderDependency(t.tandem.phetioID,i.tandem.phetioID))}propertyInAnOrderDependency(t){return this.validateInstrumentedProperty(t),_.some(this.mapPairs,e=>e.usesPhetioID(t.tandem.phetioID))}unregisterOrderDependenciesForProperty(t){Ct.PHET_IO_ENABLED&&(this.validateInstrumentedProperty(t),this.propertyInAnOrderDependency(t)&&this.mapPairs.forEach(e=>e.unregisterOrderDependenciesForProperty(t)))}undeferAndNotifyProperties(t){for(var e={},i=0;this.phaseCallbackSets.size>0;)++i>5e3&&this.errorInUndeferAndNotifyStep(e),this.attemptToApplyPhases($t.UNDEFER,e,t),this.attemptToApplyPhases($t.NOTIFY,e,t)}errorInUndeferAndNotifyStep(t){var e=[];this.phaseCallbackSets.forEach(t=>e.push(t.getTerm()));var i=[];this.mapPairs.forEach(t=>{var s=t.beforeMap,n=function(t,n){n.forEach(n=>{var r=t+s.beforePhase,a=n+s.afterPhase;(e.includes(r)||e.includes(a))&&i.push({beforeTerm:r,afterTerm:a})})};for(var[r,a]of s)n(r,a)});var s="";console.log("still to be undeferred",this.phaseCallbackSets.undeferSet),console.log("still to be notified",this.phaseCallbackSets.notifySet),console.log("order dependencies that apply to the still todos",i),i.forEach(t=>{s+="".concat(t.beforeTerm,"\t").concat(t.afterTerm,"\n")}),console.log("\n\nin graphable form:\n\n",s);var n="Impossible set state: from undeferAndNotifyProperties; ordering constraints cannot be satisfied";throw new Error(n)}getNumberOfOrderDependencies(){var t=0;return this.mapPairs.forEach(e=>{e.afterMap.forEach(e=>{t+=e.size})}),t}attemptToApplyPhases(t,e,i){var s=this.phaseCallbackSets.getSetFromPhase(t);for(var n of s)this.phetioIDCanApplyPhase(n.phetioID,t,e,i)&&(n.listener(),s.delete(n),e[n.getTerm()]=!0)}phetioIDCanApplyPhase(t,e,i,s){if(e===$t.NOTIFY&&!i[t+$t.UNDEFER])return!1;var n=[];this.mapPairs.forEach(t=>{t.afterPhase===e&&n.push(t.afterMap)});for(var r=0;r{t.has(e)&&t.get(e).forEach(i=>{var s=t.otherMap.get(i);s&&s.delete(e),0===s.size&&t.otherMap.delete(i)}),t.delete(e)})}usesPhetioID(t){return this.beforeMap.has(t)||this.afterMap.has(t)}}class se{constructor(){this.undeferSet=new Set,this.notifySet=new Set}get size(){return this.undeferSet.size+this.notifySet.size}forEach(t){this.undeferSet.forEach(t),this.notifySet.forEach(t)}addUndeferPhaseCallback(t){this.undeferSet.add(t)}addNotifyPhaseCallback(t){this.notifySet.add(t)}getSetFromPhase(t){return t===$t.NOTIFY?this.notifySet:this.undeferSet}}u.register("PropertyStateHandler",te);var ne=new te;u.register("propertyStateHandlerSingleton",ne);var re=ne;class ae extends c{constructor(t,e){super(e),this._value=t}get(){return this._value}get value(){return this.get()}set value(t){this.set(t)}set(t){if(!this.equalsValue(t)){var e=this._value;this.setPropertyValue(t),this.notifyListeners(e)}}setPropertyValue(t){this._value=t}equalsValue(t){return this.areValuesEqual(t,this._value)}areValuesEqual(t,e){if(this.useDeepEquality){var i=t,s=e;if(i&&s&&i.constructor===s.constructor)return i.equals(s)}return t===e}notifyListeners(t){this.emit(this._value,t,this)}link(t){this.addListener(t),t(this._value,null,this)}lazyLink(t){this.addListener(t)}unlink(t){this.removeListener(t)}unlinkAll(){this.removeAllListeners()}linkAttribute(t,e){this.link(i=>{t[e]=i})}isSettable(){return!0}dispose(){this.unlinkAll(),super.dispose()}}u.register("TinyProperty",ae);var oe={values:["%","A","AMU","atm","cm","cm^2","C","°","°C","F","g","Hz","J","K","kg","kg/m^3","kg·m/s","kPa","L","L/s","m","m^3","m/s","m/s/s","m/s^2","mA","mm","mol","mol/L","N","N/m","nm","nm/ps","N·s/m","Ω","Ω·cm","Pa·s","particles/ps","pm","pm/ps","pm/s","pm/s^2","pm^3","ps","radians","radians/s","s","V","view-coordinates/s","W"],isValidUnits:function(t){return _.includes(oe.values,t)}};u.register("units",oe);var le={validateValidator:!1},de=0,ue=new Map;class ce extends Vt{constructor(t,e){var i=w()({useDeepEquality:!1,units:null,reentrant:!1,tandem:Ct.OPTIONAL,phetioOuterType:ce.PropertyIO,phetioValueType:j.ObjectIO},e);M.containsValidatorKey(i)||(i.isValidValue=()=>!0),i.units&&(i.phetioEventMetadata=i.phetioEventMetadata||{},i.phetioEventMetadata.units=i.units),i.phetioOuterType&&i.phetioValueType&&(i.phetioType=i.phetioOuterType(i.phetioValueType)),super(i),this.id=de++,this.units=i.units,Ct.VALIDATION&&this.isPhetioInstrumented(),this.validValues=i.validValues,this.tinyProperty=new ae(t),this.tinyProperty.useDeepEquality=i.useDeepEquality,this.notifying=!1,this.reentrant=i.reentrant,this.isDeferred=!1,this.deferredValue=null,this.hasDeferredValue=!1,this.valueValidator=_.pick(i,M.VALIDATOR_KEYS),this.valueValidator.validationMessage=this.valueValidator.validationMessage||"Property value not valid",this.valueValidator.phetioType&&(this.valueValidator.phetioType=this.valueValidator.phetioType.parameterTypes[0])}isSettable(){return!1}get(){return this.tinyProperty.get()}set(t){_.hasIn(window,"phet.joist.sim.isSettingPhetioStateProperty")&&phet.joist.sim.isSettingPhetioStateProperty.value&&this.isPhetioInstrumented()&&this.phetioState&&this.isSettable()||this.unguardedSet(t)}unguardedSet(t){if(!this.isDisposed)if(this.isDeferred)this.deferredValue=t,this.hasDeferredValue=!0;else if(!this.equalsValue(t)){var e=this.get();this.setPropertyValue(t),this._notifyListeners(e)}}setPropertyValue(t){this.tinyProperty.setPropertyValue(t)}equalsValue(t){return this.areValuesEqual(t,this.get())}areValuesEqual(t,e){return this.tinyProperty.areValuesEqual(t,e)}_notifyListeners(t){var e=this.get();Ct.PHET_IO_ENABLED&&this.isPhetioInstrumented()&&this.phetioStartEvent(ce.CHANGED_EVENT_NAME,{getData:()=>{var i=this.phetioType.parameterTypes[0];return{oldValue:Kt(i).toStateObject(t),newValue:i.toStateObject(e)}}}),this.notifying=!0,this.tinyProperty.emit(e,t,this),this.notifying=!1,Ct.PHET_IO_ENABLED&&this.isPhetioInstrumented()&&this.phetioEndEvent()}notifyListenersStatic(){this._notifyListeners(null)}setDeferred(t){if(t)this.isDeferred=!0;else{this.isDeferred=!1;var e=this.get();if(this.hasDeferredValue&&(this.setPropertyValue(this.deferredValue),this.hasDeferredValue=!1,this.deferredValue=null),!this.equalsValue(e))return()=>!this.isDisposed&&this._notifyListeners(e)}return null}get value(){return this.get()}set value(t){this.set(t)}addPhetioStateDependencies(t){for(var e=0;e{t[e]=i})}toString(){return"Property#".concat(this.id,"{").concat(this.get(),"}")}debug(t){var e=e=>console.log(t,e);return this.link(e),e}isValueValid(t){return null===this.getValidationError(t)}getValidationError(t){return M.getValidationError(t,this.valueValidator,le)}dispose(){this.isPhetioInstrumented()&&re.unregisterOrderDependenciesForProperty(this),super.dispose(),this.tinyProperty.dispose()}hasListener(t){return this.tinyProperty.hasListener(t)}getListenerCount(){return this.tinyProperty.getListenerCount()}forEachListener(t){this.tinyProperty.forEachListener(t)}hasListeners(){return this.tinyProperty.hasListeners()}static PropertyIO(t){return ue.has(t)||ue.set(t,new j("PropertyIO<".concat(t.typeName,">"),{isValidValue:t=>t instanceof ce,documentation:"Observable values that send out notifications when the value changes. This differs from the traditional listener pattern in that added listeners also receive a callback with the current value when the listeners are registered. This is a widely-used pattern in PhET-iO simulations.",methodOrder:["link","lazyLink"],events:[ce.CHANGED_EVENT_NAME],parameterTypes:[t],toStateObject:e=>({value:t.toStateObject(e.value),validValues:e.validValues?e.validValues.map(e=>t.toStateObject(e)):null,units:Kt(It).toStateObject(e.units)}),applyState:(e,i)=>{Kt(It).fromStateObject(i.units);e.unguardedSet(t.fromStateObject(i.value)),i.validValues&&(e.validValues=i.validValues.map(e=>t.fromStateObject(e)))},stateSchema:{value:t,validValues:Kt(Wt(t)),units:Kt(It)},methods:{getValue:{returnType:t,parameterTypes:[],implementation:ce.prototype.get,documentation:"Gets the current value."},getValidationError:{returnType:Kt(It),parameterTypes:[t],implementation:ce.prototype.getValidationError,documentation:"Checks to see if a proposed value is valid. Returns the first validation error, or null if the value is valid."},setValue:{returnType:Qt,parameterTypes:[t],implementation:ce.prototype.set,documentation:"Sets the value of the Property. If the value differs from the previous value, listeners are notified with the new value.",invocableForReadOnlyElements:!1},link:{returnType:Qt,parameterTypes:[Xt(Qt,[t,Kt(t)])],implementation:ce.prototype.link,documentation:"Adds a listener which will be called when the value changes. On registration, the listener is also called with the current value. The listener takes two arguments, the new value and the previous value."},lazyLink:{returnType:Qt,parameterTypes:[Xt(Qt,[t,Kt(t)])],implementation:ce.prototype.lazyLink,documentation:'Adds a listener which will be called when the value changes. This method is like "link", but without the current-value callback on registration. The listener takes two arguments, the new value and the previous value.'},unlink:{returnType:Qt,parameterTypes:[Xt(Qt,[t])],implementation:ce.prototype.unlink,documentation:"Removes a listener."}}})),ue.get(t)}}_defineProperty(ce,"TANDEM_NAME_SUFFIX","Property"),_defineProperty(ce,"CHANGED_EVENT_NAME","changed"),u.register("ReadOnlyProperty",ce);class me extends ce{constructor(t,e){super(t,e),this._initialValue=t}getInitialValue(){return this._initialValue}get initialValue(){return this.getInitialValue()}setInitialValue(t){this._initialValue=t}get value(){return super.value}set value(t){super.set(t)}reset(){this.set(this._initialValue)}set(t){super.set(t)}isSettable(){return!0}}u.register("Property",me);class pe extends me{constructor(t,e){super(t,w()({valueType:"boolean",phetioValueType:Q},e))}toggle(){this.value=!this.value}}u.register("BooleanProperty",pe);var ge=new m;u.register("stepTimer",ge);var ve=ge;class fe{constructor(t){var e=w()({delay:400,interval:100},t);this.delay=e.delay,this.interval=e.interval,this.callbacks=[],e.callback&&this.callbacks.push(e.callback),this.delayID=null,this.intervalID=null,this.fired=!1}isRunning(){return null!==this.delayID||null!==this.intervalID}start(){this.isRunning()||(this.fired=!1,this.delayID=ve.setTimeout(()=>{this.delayID=null,this.intervalID=ve.setInterval(()=>this.fire(),this.interval),this.fire()},this.delay))}stop(t){this.isRunning()&&(this.delayID&&(ve.clearTimeout(this.delayID),this.delayID=null),this.intervalID&&(ve.clearInterval(this.intervalID),this.intervalID=null),t&&!this.fired&&this.fire())}addCallback(t){this.callbacks.includes(t)||this.callbacks.push(t)}removeCallback(t){var e=this.callbacks.indexOf(t);-1!==e&&this.callbacks.splice(e,1)}fire(){for(var t=this.callbacks.slice(0),e=0;et.phetioType),_e=t=>t.name;class Pe extends Vt{constructor(t){var e=w()({parameters:ye,tandem:Ct.OPTIONAL,phetioPlayback:Vt.DEFAULT_OPTIONS.phetioPlayback,phetioEventMetadata:Vt.DEFAULT_OPTIONS.phetioEventMetadata,phetioDocumentation:""},t),i=e.parameters.filter(be);e.phetioType=e.phetioOuterType(i.map(be)),e.phetioPlayback&&(e.phetioEventMetadata=e.phetioEventMetadata||{},e.phetioEventMetadata.dataKeys=e.parameters.map(_e)),e.phetioDocumentation=Pe.getPhetioDocumentation(e.phetioDocumentation,i),super(e),this.parameters=e.parameters}static validateParameters(t,e){R(t,{valueType:Array});for(var i=!1,s=0;s0){t={};for(var e=arguments.length,i=new Array(e),s=0;sNo parameters.":"".concat("
The parameters are:
    ").concat(e.map(t=>{var e=t.phetioDocumentation?" - ".concat(t.phetioDocumentation):"";return"
  1. ".concat(t.name,": ").concat(t.phetioType.typeName).concat(e,"
  2. ")}).join("
    "),"
"))}}u.register("PhetioDataHandler",Pe);var we=Pe;class xe extends we{constructor(t){super(w()({phetioOuterType:xe.EmitterIO,phetioState:!1},t)),this.tinyEmitter=new c}emit(){Ct.PHET_IO_ENABLED&&this.isPhetioInstrumented()&&this.phetioStartEvent("emitted",{data:this.getPhetioData(...arguments)}),this.tinyEmitter.emit(...arguments),Ct.PHET_IO_ENABLED&&this.isPhetioInstrumented()&&this.phetioEndEvent()}dispose(){this.tinyEmitter.dispose(),super.dispose()}addListener(t){this.tinyEmitter.addListener(t)}removeListener(t){this.tinyEmitter.removeListener(t)}removeAllListeners(){this.tinyEmitter.removeAllListeners()}hasListener(t){return this.tinyEmitter.hasListener(t)}hasListeners(){return this.tinyEmitter.hasListeners()}getListenerCount(){return this.tinyEmitter.getListenerCount()}debug(t){var e=function(){for(var e=arguments.length,i=new Array(e),s=0;st.typeName,Se=new Map;xe.EmitterIO=t=>{var e=t.map(Te).join(",");return Se.has(e)||Se.set(e,new j("EmitterIO<".concat(t.map(Te).join(", "),">"),{valueType:xe,documentation:"Emits when an event occurs and calls added listeners.",parameterTypes:t,events:["emitted"],metadataDefaults:{phetioState:!1},methods:{addListener:{returnType:Qt,parameterTypes:[Xt(Qt,t)],implementation:xe.prototype.addListener,documentation:"Adds a listener which will be called when the emitter emits."},removeListener:{returnType:Qt,parameterTypes:[Xt(Qt,t)],implementation:xe.prototype.removeListener,documentation:"Remove a listener."},emit:{returnType:Qt,parameterTypes:t,implementation:xe.prototype.emit,documentation:"Emits a single event to all listeners.",invocableForReadOnlyElements:!1}}})),Se.get(e)},u.register("Emitter",xe);var Ae=new j("NumberIO",{valueType:"number",documentation:"IO Type for Javascript's number primitive type",toStateObject:t=>t===Number.POSITIVE_INFINITY?"POSITIVE_INFINITY":t===Number.NEGATIVE_INFINITY?"NEGATIVE_INFINITY":t,fromStateObject:t=>"POSITIVE_INFINITY"===t?Number.POSITIVE_INFINITY:"NEGATIVE_INFINITY"===t?Number.NEGATIVE_INFINITY:t,stateSchema:W.asValue("'POSITIVE_INFINITY'|'NEGATIVE_INFINITY'|number",{isValidValue:t=>"POSITIVE_INFINITY"===t||"NEGATIVE_INFINITY"===t||"number"==typeof t&&!isNaN(t)})});S.register("NumberIO",Ae);var Ee=Ae,Ce=new d("dot");Ce.register("FastArray",window.Float64Array?window.Float64Array:window.Array);var De=Ce;class Ie{constructor(t,e){this._min=t,this._max=e}getMin(){return this._min}get min(){return this.getMin()}set min(t){this.setMin(t)}setMin(t){this._min=t}getMax(){return this._max}get max(){return this.getMax()}set max(t){this.setMax(t)}setMax(t){this._max=t}setMinMax(t,e){this._min=t,this._max=e}copy(){return new Ie(this._min,this._max)}getLength(){return this._max-this._min}getCenter(){return(this._max+this._min)/2}contains(t){return t>=this._min&&t<=this._max}containsRange(t){return this._min<=t.min&&this._max>=t.max}intersects(t){return this._max>=t.min&&t.max>=this._min}intersectsExclusive(t){return this._max>t.min&&t.max>this._min}toString(){return"[Range (min:".concat(this._min," max:").concat(this._max,")]")}constrainValue(t){return Math.min(Math.max(t,this._min),this._max)}equals(t){return this.constructor===t.constructor&&this._min===t.min&&this._max===t.max}getNormalizedValue(t){return(t-this.min)/this.getLength()}expandNormalizedValue(t){return t*this.getLength()+this.min}get defaultValue(){throw new Error("defaultValue is undefined, did you mean to use RangeWithValue?")}}_defineProperty(Ie,"RangeIO",new j("RangeIO",{valueType:Ie,documentation:'A range with "min" and a "max" members.',toStateObject:t=>({min:Ee.toStateObject(t.min),max:Ee.toStateObject(t.max)}),fromStateObject:t=>new Ie(Ee.fromStateObject(t.min),Ee.fromStateObject(t.max)),stateSchema:{min:Ee,max:Ee}})),De.register("Range",Ie);var Le=Ie,ke={valueType:"number",isValidValue:t=>t%1==0,validationMessage:"Should be a valid integer"},Me=me.PropertyIO(Ee),Oe=t=>t.range&&null!==t.range;class Re extends me{constructor(t,e){var i=w()({numberType:"FloatingPoint",range:null,validators:[],tandem:Ct.OPTIONAL},e);i.rangePropertyOptions=w()({phetioDocumentation:"provides the range of possible values for the parent NumberProperty",phetioValueType:Kt(Le.RangeIO),phetioReadOnly:!0,tandem:i.tandem.createTandem("rangeProperty")},i.rangePropertyOptions),i.valueType="number",i.phetioValueType=Ee;var s,n=!(i.range&&i.range instanceof ce);s=i.range instanceof ce?i.range:new me(i.range,i.rangePropertyOptions),"Integer"===i.numberType&&i.validators.push(ke),i.validators.push({isValidValue:t=>{var e=s.value;return null===e||e.contains(t)},validationMessage:"Number must be within rangeProperty value."}),super(t,i),this.numberType=i.numberType,this.rangeProperty=s;if(this.rangeProperty.addPhetioStateDependencies([this]),this.addPhetioStateDependencies([this.rangeProperty]),i.validValues&&this.validateNumberAndRangeProperty)for(var r=0;r{n&&this.rangeProperty.dispose()},this.resetNumberProperty=()=>{n&&this.rangeProperty.reset()}}get range(){return this.rangeProperty.value}set range(t){this.rangeProperty.value=t}reset(){super.reset(),this.resetNumberProperty()}dispose(){this.disposeNumberProperty(),super.dispose()}setValueAndRange(t,e){this.setDeferred(!0),this.rangeProperty.setDeferred(!0),this.set(t),this.rangeProperty.set(e);var i=this.setDeferred(!1),s=this.rangeProperty.setDeferred(!1);i&&i(),s&&s()}resetValueAndRange(){this.setValueAndRange(this.initialValue,this.rangeProperty.initialValue)}asRanged(){if(Oe(this))return this;throw new Error("Not a RangedProperty")}toStateObject(){var t=Me.toStateObject(this);t.numberType=It.toStateObject(this.numberType),t.range=Kt(Le.RangeIO).toStateObject(this.rangeProperty.value);var e=this.rangeProperty&&this.rangeProperty.isPhetioInstrumented();return t.rangePhetioID=e?It.toStateObject(this.rangeProperty.tandem.phetioID):null,t}}_defineProperty(Re,"NumberPropertyIO",new j("NumberPropertyIO",{valueType:Re,supertype:Me,parameterTypes:[Ee],documentation:"Extends PropertyIO to add values for the numeric range ( min, max ) and numberType ( '".concat(["FloatingPoint","Integer"].join("' | '"),"' )"),toStateObject:t=>t.toStateObject(),applyState:(t,e)=>{Me.applyState(t,e)},stateSchema:{numberType:It,range:Kt(Le.RangeIO),rangePhetioID:Kt(It),value:Ee}})),u.register("NumberProperty",Re);var Ne=t=>{Y(t,["length"],["elements"]);var e=w()({length:0,elements:[],tandem:Ct.OPTIONAL},t),i=null;if(e.phetioType)i={name:"value",phetioType:e.phetioType.parameterTypes[0]};else if(M.getValidatorValidationError(e))i=b({name:"value"},{isValidValue:_.stubTrue});else{var s=_.pick(e,M.VALIDATOR_KEYS);i=b({name:"value"},s)}var n=new xe({tandem:e.tandem.createTandem("elementAddedEmitter"),parameters:[i],phetioReadOnly:!0}),r=new xe({tandem:e.tandem.createTandem("elementRemovedEmitter"),parameters:[i],phetioReadOnly:!0}),a=new Re(0,{numberType:"Integer",tandem:e.tandem.createTandem("lengthProperty"),phetioReadOnly:!0}),o=[],h=new Proxy(o,{get:function(t,e,i){return Fe.hasOwnProperty(e)?Fe[e]:Reflect.get(t,e,i)},set:function(t,e,i){var s=t[e],o=null;"length"===e&&(o=t.slice(i));var h=Reflect.set(t,e,i),l=Number(e);return Number.isInteger(l)&&l>=0&&s!==i?(a.value=t.length,void 0!==s&&r.emit(t[e]),void 0!==i&&n.emit(i)):"length"===e&&(a.value=i,o&&o.forEach(t=>r.emit(t))),h},deleteProperty:function(t,e){var i,s=Number(e);Number.isInteger(s)&&s>=0&&(i=t[e]);var n=Reflect.deleteProperty(t,e);return void 0!==i&&r.emit(i),n}});h.targetArray=o,h.elementAddedEmitter=n,h.elementRemovedEmitter=r,h.lengthProperty=a;var l=()=>{e.length>=0&&(h.length=e.length),e.elements.length>0&&Array.prototype.push.apply(h,e.elements)};return l(),h.reset=()=>{h.length=0,l()},e.tandem.supplied&&(h.phetioElementType=e.phetioType.parameterTypes[0],h._observableArrayPhetioObject=new Be(h,e)),h};class Be extends Vt{constructor(t,e){super(w()({phetioType:Ye},e)),this.observableArray=t}}var Fe={pop(){for(var t=this.targetArray.length,e=arguments.length,i=new Array(e),s=0;s0&&this.elementRemovedEmitter.emit(n),n},shift(){for(var t=this.targetArray.length,e=arguments.length,i=new Array(e),s=0;s0&&this.elementRemovedEmitter.emit(n),n},push(){for(var t=arguments.length,e=new Array(t),i=0;it.elementRemovedEmitter.emit(e)),n},copyWithin(){for(var t=this.targetArray.slice(),e=arguments.length,i=new Array(e),s=0;stt(this,t))},clear:function(){for(;this.length>0;)this.pop()},count:function(t){for(var e=0,i=0;ithis.phetioElementType.toStateObject(t))}},applyState:function(t){this.length=0;var e=t.array.map(t=>this.phetioElementType.fromStateObject(t));this.push(...e)}},Ve=(t,e)=>{for(var i=t,s=e.targetArray.slice(),n=0;n=0&&(i.splice(n,1),s.splice(a,1),n--)}i.forEach(t=>e.elementRemovedEmitter.emit(t)),s.forEach(t=>e.elementAddedEmitter.emit(t))},He=new Map,Ye=t=>(He.has(t)||He.set(t,new j("ObservableArrayIO<".concat(t.typeName,">"),{valueType:Be,parameterTypes:[t],toStateObject:t=>t.observableArray.toStateObject(),applyState:(t,e)=>t.observableArray.applyState(e),stateSchema:{array:Wt(t)}})),He.get(t));Ne.ObservableArrayIO=Ye,u.register("createObservableArray",Ne);var ze=Ne;function We(t,e){return t(...e.map(t=>t.get()))}class Ue extends ce{constructor(t,e,i){var s=w()({tandem:Ct.OPTIONAL,phetioReadOnly:!0,phetioOuterType:Ue.DerivedPropertyIO,phetioLinkDependencies:!0},i);super(We(e,t),s),Ct.VALIDATION&&this.isPhetioInstrumented(),this.dependencies=t,this.derivation=e,this.derivedPropertyListener=this.getDerivedPropertyListener.bind(this),t.forEach(t=>{if(t.lazyLink(this.derivedPropertyListener),this.isPhetioInstrumented()&&t instanceof Vt&&t.isPhetioInstrumented()&&(t instanceof ce&&re.registerPhetioOrderDependency(t,$t.UNDEFER,this,$t.UNDEFER),s.phetioLinkDependencies)){var e=s.tandem.createTandem("dependencies");this.addLinkedElement(t,{tandem:e.createTandemFromPhetioID(t.tandem.phetioID)})}})}hasDependency(t){return this.definedDependencies.includes(t)}get definedDependencies(){return this.dependencies}getDerivedPropertyListener(){this.isDeferred?this.hasDeferredValue=!0:super.set(We(this.derivation,this.definedDependencies))}recomputeDerivation(){this.getDerivedPropertyListener()}dispose(){for(var t=this.definedDependencies,e=0;et===e,i)}static and(t,e){return new Ue(t,_.reduce.bind(null,t,Ge,!0),e)}static or(t,e){return new Ue(t,_.reduce.bind(null,t,Xe,!1),e)}static not(t,e){return new Ue([t],t=>!t,e)}static deriveAny(t,e,i){return new Ue(t,e,i)}}var Ge=(t,e)=>t&&e.value,Xe=(t,e)=>t||e.value,je=new Map;Ue.DerivedPropertyIO=t=>(je.has(t)||je.set(t,new j("".concat("DerivedPropertyIO","<").concat(t.typeName,">"),{valueType:Ue,parameterTypes:[t],supertype:me.PropertyIO(t),documentation:"Like PropertyIO, but not settable. Instead it is derived from other DerivedPropertyIO or PropertyIO instances",applyState:_.noop,methods:{setValue:{returnType:Qt,parameterTypes:[t],implementation:Ue.prototype.set,documentation:"Errors out when you try to set a derived property.",invocableForReadOnlyElements:!1}}})),je.get(t));class qe extends Ue{}u.register("DerivedProperty",Ue);class Ke extends ce{constructor(t,e){var i=w()({bidirectional:!1,defaultValue:null,derive:_.identity,map:_.identity,inverseMap:_.identity},e),s=i.derive,n=i.map,r=i.inverseMap,a="function"==typeof s?s:t=>t[s],o="function"==typeof n?n:t=>t[n],h="function"==typeof r?r:t=>t[r];super(null===t.value?o(i.defaultValue):o(a(t.value).value),i),this.defaultValue=i.defaultValue,this.derive=a,this.map=o,this.inverseMap=h,this.bidirectional=i.bidirectional,this.valuePropertyProperty=t,this.isExternallyChanging=!1,this.propertyPropertyListener=this.onPropertyPropertyChange.bind(this),this.propertyListener=this.onPropertyChange.bind(this),t.link(this.propertyListener),i.bidirectional&&this.lazyLink(this.onSelfChange.bind(this))}onPropertyPropertyChange(t,e,i){if(this.bidirectional&&null!==this.valuePropertyProperty.value&&i&&(this.derive(this.valuePropertyProperty.value)===i&&i.areValuesEqual(this.inverseMap(this.value),i.get())))return;super.set(this.map(t))}onPropertyChange(t,e){e&&this.derive(e).unlink(this.propertyPropertyListener),t?this.derive(t).link(this.propertyPropertyListener):this.onPropertyPropertyChange(this.defaultValue,null,null)}onSelfChange(t){if(null!==this.valuePropertyProperty.value){var e=this.derive(this.valuePropertyProperty.value);this.areValuesEqual(t,this.map(e.value))||(e.value=this.inverseMap(t))}}dispose(){this.valuePropertyProperty.unlink(this.propertyListener),null!==this.valuePropertyProperty.value&&this.derive(this.valuePropertyProperty.value).unlink(this.propertyPropertyListener),super.dispose()}reset(){null!==this.valuePropertyProperty.value&&this.derive(this.valuePropertyProperty.value).reset()}set(t){this.isExternallyChanging=!0,super.set(t),this.isExternallyChanging=!1}get value(){return super.value}set value(t){this.set(t)}isSettable(){return super.isSettable()||this.bidirectional}}u.register("DynamicProperty",Ke);class Ze extends me{constructor(t,e,i){C("Use EnumerationProperty. EnumerationDeprecated should be exchanged for classes that extend EnumerationValue, see WilderEnumerationPatterns for examples."),super(e,i=b({valueType:t,phetioValueType:dt(t),validValues:t.VALUES},i)),this.enumeration=t}}u.register("EnumerationDeprecatedProperty",Ze);class Qe extends Ke{constructor(t,e){super(new ae(t),e)}}u.register("MappedProperty",Qe);class Je{constructor(t,e,i){if(this.dependencies=t,this.dependencyListeners=new Map,t.forEach(i=>{var s=()=>{if(!this.isDisposed){var i=t.map(t=>t.get());e(...i)}};this.dependencyListeners.set(i,s),i.lazyLink(s,{phetioDependencies:_.without(t,i)})}),!i){var s=t.map(t=>t.get());e(...s)}this.isDisposed=!1}get definedDependencies(){return this.dependencies}dispose(){for(var t=this.definedDependencies,e=0;et*e.factor;super(t,w()({bidirectional:!0,map:i,inverseMap:t=>t/e.factor},e)),this._property=t,this.rangeProperty=new ae(null),t.rangeProperty&&(this._rangeListener=t=>{if(null===t)this.rangeProperty.value=null;else{var e=i(t.min),s=i(t.max);this.rangeProperty.value=new Le(Math.min(e,s),Math.max(e,s))}},t.rangeProperty.link(this._rangeListener))}get range(){return this.rangeProperty.value}set range(t){this.rangeProperty.value=t}asRanged(){if(Oe(this))return this;throw new Error("Not a RangedProperty")}dispose(){this._property.rangeProperty&&this._property.rangeProperty.unlink(this._rangeListener),this.rangeProperty.dispose()}});function ii(t,e,i,s,n){i=i||[],s=s||[],n=n||[],Array.prototype.push.apply(i,t),Array.prototype.push.apply(s,e);t:for(var r=0;r{e.push(t)}),e}f.register("collect",ai);function oi(t,e){return void 0!==t[e]?e:(e=e.charAt(0).toUpperCase()+e.slice(1),void 0!==t["moz".concat(e)]?"moz".concat(e):void 0!==t["Moz".concat(e)]?"Moz".concat(e):void 0!==t["webkit".concat(e)]?"webkit".concat(e):void 0!==t["ms".concat(e)]?"ms".concat(e):void 0!==t["o".concat(e)]?"o".concat(e):void 0)}f.register("detectPrefix",oi);var hi=oi;function li(t,e,i){return void 0!==t["on".concat(e)]?e:void 0!==t["".concat("onmoz").concat(e)]?"moz".concat(e):void 0!==t["".concat("onMoz").concat(e)]?"Moz".concat(e):void 0!==t["".concat("onwebkit").concat(e)]?"webkit".concat(e):void 0!==t["".concat("onms").concat(e)]?"ms".concat(e):void 0!==t["".concat("ono").concat(e)]?"o".concat(e):void 0}f.register("detectPrefixEvent",li);var di=li;function ui(t,e,i){var s=[];return function t(e,n){return n.forEach((n,r)=>{s.push(r),1===e?i(...[n].concat(s)):t(e-1,n),s.pop()})}(t,e)}f.register("dimensionForEach",ui);function ci(t,e,i){var s=[];return function t(e,n){return n.map((n,r)=>{s.push(r);var a=1===e?i(...[n].concat(s)):t(e-1,n);return s.pop(),a})}(t,e)}f.register("dimensionMap",ci);class mi{constructor(t,e){_defineProperty(this,"_map",new Map),this._enumeration=t,this._values=t.enumeration.values,this._values.forEach(t=>{this._map.set(t,e(t))})}get(t){return this._map.get(t)}set(t,e){this._map.set(t,e)}map(t){return new mi(this._enumeration,e=>t(this.get(e),e))}forEach(t){this._values.forEach(e=>t(this.get(e),e))}values(){return this._values.map(t=>this.get(t))}}f.register("EnumerationMap",mi);var pi=mi;function gi(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}f.register("escapeHTML",gi);var vi=gi;class fi{constructor(t,e){this.eventModel=t,this.eventCallback=e,this.period=this.eventModel.getPeriodBeforeNextEvent(),this.timeBeforeNextEvent=this.period}step(t){for(;t>=this.timeBeforeNextEvent;)t-=this.timeBeforeNextEvent,this.period=this.eventModel.getPeriodBeforeNextEvent(),this.timeBeforeNextEvent=this.period,this.eventCallback(t);this.timeBeforeNextEvent-=t}getRatio(){return(this.period-this.timeBeforeNextEvent)/this.period}}f.register("EventTimer",fi);fi.ConstantEventModel=class{constructor(t){this.rate=t}getPeriodBeforeNextEvent(){return 1/this.rate}};fi.UniformEventModel=class{constructor(t,e){this.rate=t,this.pseudoRandomNumberSource=e}getPeriodBeforeNextEvent(){var t=this.pseudoRandomNumberSource();return 2*t/this.rate}};fi.PoissonEventModel=class{constructor(t,e){this.rate=t,this.pseudoRandomNumberSource=e}getPeriodBeforeNextEvent(){var t=this.pseudoRandomNumberSource();return-Math.log(t)/this.rate}};function yi(t){return _.each(Array.prototype.slice.call(arguments,1),e=>{if(e)for(var i in e)Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i))}),t}f.register("extend",yi);var bi=yi;function _i(t){return _.each(Array.prototype.slice.call(arguments,1),e=>{if(e)for(var i in e){var s=Object.getOwnPropertyDescriptor(e,i);!s||"function"!=typeof s.get&&void 0===e[i]||Object.defineProperty(t,i,s)}}),t}f.register("extendDefined",_i);var Pi=_i;function wi(t,e){for(var i=[],s=2*t.length-1,n=0;n{if(e.has(i))return e.get(i);var s=t(i);return e.set(i,s),s}}f.register("memoize",Ai);var Ei=Ai;function Ci(t,e,i){i&&_.each(e,e=>{void 0!==i[e]&&(t[e]=i[e])})}f.register("mutate",Ci);var Di=Ci;class Ii extends it{constructor(t,e,i,s,n,r,a,o,h,l,d,u,c,m,p,g,v){super(),this.coordinate=t,this.centerCoordinate=e,this.minCoordinate=i,this.maxCoordinate=s,this.minSide=n,this.maxSide=r,this.rectCoordinate=a,this.rectSize=o,this.layoutBoxOrientation=h,this.size=l,this.line=d,this.preferredSize=u,this.localPreferredSize=c,this.sizable=m,this.ariaOrientation=h,this.modelToView=p,this.viewToModel=g,this.toVector=v}}_defineProperty(Ii,"HORIZONTAL",new Ii("x","centerX","minX","maxX","left","right","rectX","rectWidth","horizontal","width","column","preferredWidth","localPreferredWidth","widthSizable",(t,e)=>t.modelToViewX(e),(t,e)=>t.viewToModelX(e),(t,e,i)=>new i(t,e,0,0))),_defineProperty(Ii,"VERTICAL",new Ii("y","centerY","minY","maxY","top","bottom","rectY","rectHeight","vertical","height","row","preferredHeight","localPreferredHeight","heightSizable",(t,e)=>t.modelToViewY(e),(t,e)=>t.viewToModelY(e),(t,e,i)=>new i(e,t,0,0))),_defineProperty(Ii,"enumeration",new at(Ii,{phetioDocumentation:"Horizontal or vertical orientation"})),Ii.HORIZONTAL.opposite=Ii.VERTICAL,Ii.VERTICAL.opposite=Ii.HORIZONTAL,f.register("Orientation",Ii);var Li=Ii;class ki extends pi{constructor(t,e){super(Li,i=>i===Li.HORIZONTAL?t:e)}get horizontal(){return this.get(Li.HORIZONTAL)}set horizontal(t){this.set(Li.HORIZONTAL,t)}get vertical(){return this.get(Li.VERTICAL)}set vertical(t){this.set(Li.VERTICAL,t)}static create(t){return new ki(t(Li.HORIZONTAL),t(Li.VERTICAL))}}f.register("OrientationPair",ki);var Mi=ki;function Oi(t){var e=[],i=t.length;if(i>1)for(var s=0;s=2)&&Ni.match(/AppleWebKit/))}function Vi(){var t=-1;return"Microsoft Internet Explorer"===navigator.appName?null!==new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(Ni)&&(t=parseFloat(RegExp.$1)):"Netscape"===navigator.appName&&null!==new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})").exec(Ni)&&(t=parseFloat(RegExp.$1)),t}var Hi={firefox:Ni.toLowerCase().indexOf("firefox")>-1,mobileSafari:Fi(),safari5:!!(Ni.match(/Version\/5\./)&&Ni.match(/Safari\//)&&Ni.match(/AppleWebKit/)),safari6:!!(Ni.match(/Version\/6\./)&&Ni.match(/Safari\//)&&Ni.match(/AppleWebKit/)),safari7:!!(Ni.match(/Version\/7\./)&&Ni.match(/Safari\//)&&Ni.match(/AppleWebKit/)),safari10:!!(Ni.match(/Version\/10\./)&&Ni.match(/Safari\//)&&Ni.match(/AppleWebKit/)),safari11:!!(Ni.match(/Version\/11\./)&&Ni.match(/Safari\//)&&Ni.match(/AppleWebKit/)),safari9:!!(Ni.match(/Version\/9\./)&&Ni.match(/Safari\//)&&Ni.match(/AppleWebKit/)),safari:Fi()||!!(Ni.match(/Version\//)&&Ni.match(/Safari\//)&&Ni.match(/AppleWebKit/)),ie:-1!==Vi(),ie9:Bi(9),ie10:Bi(10),ie11:Bi(11),android:Ni.indexOf("Android")>0,edge:!!Ni.match(/Edge\//),chromium:/chrom(e|ium)/.test(Ni.toLowerCase())&&!Ni.match(/Edge\//)};f.register("platform",Hi);var Yi=Hi;class zi{constructor(t,e){var i=w()({defaultArguments:[],initialize:t.prototype.initialize,maxSize:100,initialSize:0,useDefaultConstruction:!1},e);for(this._maxPoolSize=i.maxSize,this.partialConstructor=Function.prototype.bind.bind(t,t),this.DefaultConstructor=this.partialConstructor(...i.defaultArguments),this.initialize=i.initialize,this.useDefaultConstruction=i.useDefaultConstruction,this.objects=[];this.objects.lengths.length?s.pop():new a,createFromPool(){for(var t,e=arguments.length,i=new Array(e),n=0;ne[+i+1])},fillIn:function(t,e){for(var i=t=t&&t.get?t.get():t,s=t.match(/\{\{[^{}]+\}\}/g)||[],n=0;n=1&&Xi.isEmbeddingMark(t.charAt(i-1));)i--;if(e>=i||e>=t.length)return"";for(var r=0;r=0;){n.push(Xi.embeddedSlice(t,o,o+s.index));var h=s.index+s.length;r=r.slice(h),o+=h}return n.push(Xi.embeddedSlice(t,o)),void 0!==i&&(n=_.first(n,i)),n},embeddedDebugString:function(t){return t.replace(/\u202a/g,"[LTR]").replace(/\u202b/g,"[RTL]").replace(/\u202c/g,"[POP]")},assertContainsKey(t,e){},capitalize:t=>t[0].toUpperCase()+t.slice(1)};Gi.register("StringUtils",Xi);var ji=Xi,qi=new d("utteranceQueue"),Ki={nameObjectContextHint:"{{NAME}}, {{OBJECT}}, {{CONTEXT}} {{HINT}}",nameObjectContext:"{{NAME}}, {{OBJECT}}, {{CONTEXT}}",nameObjectHint:"{{NAME}}, {{OBJECT}}, {{HINT}}",nameContextHint:"{{NAME}}, {{CONTEXT}} {{HINT}}",nameObject:"{{NAME}}, {{OBJECT}}",nameContext:"{{NAME}}, {{CONTEXT}}",nameHint:"{{NAME}}, {{HINT}}",name:"{{NAME}}",objectContextHint:"{{OBJECT}}, {{CONTEXT}} {{HINT}}",objectContext:"{{OBJECT}}, {{CONTEXT}}",objectHint:"{{OBJECT}}, {{HINT}}",contextHint:"{{CONTEXT}} {{HINT}}",object:"{{OBJECT}}",context:"{{CONTEXT}}",hint:"{{HINT}}"};class Zi{constructor(t){var e=x()({},Ki,t);this.nameObjectContextHint=e.nameObjectContextHint,this.nameObjectContext=e.nameObjectContext,this.nameObjectHint=e.nameObjectHint,this.nameContextHint=e.nameContextHint,this.nameObject=e.nameObject,this.nameContext=e.nameContext,this.nameHint=e.nameHint,this.name=e.name,this.objectContextHint=e.objectContextHint,this.objectContext=e.objectContext,this.objectHint=e.objectHint,this.contextHint=e.contextHint,this.object=e.object,this.context=e.context,this.hint=e.hint}getResponsePattern(t){var e=this[t];return e}static createPatternKey(t,e,i,s){var n="";return t&&(n=n.concat("NAME".concat("_"))),e&&(n=n.concat("OBJECT".concat("_"))),i&&(n=n.concat("CONTEXT".concat("_"))),s&&(n=n.concat("HINT".concat("_"))),_.camelCase(n)}}_defineProperty(Zi,"DEFAULT_RESPONSE_PATTERNS",new Zi),qi.register("ResponsePatternCollection",Zi);var Qi=Zi,Ji={nameResponse:null,objectResponse:null,contextResponse:null,hintResponse:null,ignoreProperties:!1,responsePatternCollection:Qi.DEFAULT_RESPONSE_PATTERNS};class $i{constructor(t){var e=x()({},Ji,t);this._nameResponse=e.nameResponse,this._objectResponse=e.objectResponse,this._contextResponse=e.contextResponse,this._hintResponse=e.hintResponse,this.ignoreProperties=e.ignoreProperties,this.responsePatternCollection=e.responsePatternCollection}getNameResponse(){return $i.getResponseText(this._nameResponse)}get nameResponse(){return this.getNameResponse()}set nameResponse(t){this.setNameResponse(t)}setNameResponse(t){this._nameResponse=t}getObjectResponse(){return $i.getResponseText(this._objectResponse)}get objectResponse(){return this.getObjectResponse()}set objectResponse(t){this.setObjectResponse(t)}setObjectResponse(t){this._objectResponse=t}getContextResponse(){return $i.getResponseText(this._contextResponse)}get contextResponse(){return this.getContextResponse()}set contextResponse(t){this.setContextResponse(t)}setContextResponse(t){this._contextResponse=t}getHintResponse(){return $i.getResponseText(this._hintResponse)}get hintResponse(){return this.getHintResponse()}set hintResponse(t){this.setHintResponse(t)}setHintResponse(t){this._hintResponse=t}static getResponseText(t){return t instanceof ce||t instanceof ae?t.value:"function"==typeof t?t():t}copy(){return new $i(this.serialize())}serialize(){return{nameResponse:this.nameResponse,objectResponse:this.objectResponse,contextResponse:this.contextResponse,hintResponse:this.hintResponse,ignoreProperties:this.ignoreProperties,responsePatternCollection:this.responsePatternCollection}}}_defineProperty($i,"DEFAULT_OPTIONS",Ji),qi.register("ResponsePacket",$i);var ts=$i;var es=new class extends Vt{constructor(t){super(),this.nameResponsesEnabledProperty=new pe(!0,{tandem:t.tandem.createTandem("nameResponsesEnabledProperty"),phetioReadOnly:!0,phetioState:!1}),this.objectResponsesEnabledProperty=new pe(!1,{tandem:t.tandem.createTandem("objectResponsesEnabledProperty"),phetioReadOnly:!0,phetioState:!1}),this.contextResponsesEnabledProperty=new pe(!1,{tandem:t.tandem.createTandem("contextResponsesEnabledProperty"),phetioReadOnly:!0,phetioState:!1}),this.hintResponsesEnabledProperty=new pe(!1,{tandem:t.tandem.createTandem("hintResponsesEnabledProperty"),phetioReadOnly:!0,phetioState:!1})}reset(){this.nameResponsesEnabledProperty.reset(),this.objectResponsesEnabledProperty.reset(),this.contextResponsesEnabledProperty.reset(),this.hintResponsesEnabledProperty.reset()}collectResponses(t){var e=x()({},ts.DEFAULT_OPTIONS,t),i=!(!e.nameResponse||!this.nameResponsesEnabledProperty.get()&&!e.ignoreProperties),s=!(!e.objectResponse||!this.objectResponsesEnabledProperty.get()&&!e.ignoreProperties),n=!(!e.contextResponse||!this.contextResponsesEnabledProperty.get()&&!e.ignoreProperties),r=!(!e.hintResponse||!this.hintResponsesEnabledProperty.get()&&!e.ignoreProperties),a=Qi.createPatternKey(i,s,n,r),o="";if(a){var h=e.responsePatternCollection.getResponsePattern(a);o=ji.fillIn(h,{NAME:e.nameResponse,OBJECT:e.objectResponse,CONTEXT:e.contextResponse,HINT:e.hintResponse})}return o}}({tandem:Ct.GENERAL_MODEL.createTandem("responseCollector"),phetioState:!1,phetioReadOnly:!0,phetioDocumentation:'A collection of Properties that determine what level of responses to provide through the "voicing" feature.'});qi.register("responseCollector",es);var is=es,ss=new Map,ns=t=>{var e=t.map(t=>t.typeName),i=e.join(",");if(!ss.has(i)){ss.set(i,new j("OrIO<".concat(e.join(", "),">"),{documentation:"An IOType adding support for a composite type that can be any of its parameters.",parameterTypes:t,isValidValue:e=>{for(var i=0;i{for(var i=0;it[e.index].fromStateObject(e.state),stateSchema:W.asValue("".concat(e.join("|")),{isValidValue:e=>"number"==typeof e.index&&t[e.index].isStateObjectValid(e.state)})}))}return ss.get(i)};S.register("OrIO",ns);var rs=ns,as=1;class os{constructor(t){var e=w()({alert:null,predicate:function(){return!0},canAnnounceProperties:[],descriptionCanAnnounceProperties:[],voicingCanAnnounceProperties:[],alertStableDelay:200,alertMaximumDelay:Number.MAX_VALUE,announcerOptions:{},priority:1},t);this.id=as++,this._alert=e.alert,this.predicate=e.predicate,this.canAnnounceProperty=new hs({dependentProperties:e.canAnnounceProperties}),this.descriptionCanAnnounceProperty=new hs({dependentProperties:e.descriptionCanAnnounceProperties}),this.voicingCanAnnounceProperty=new hs({dependentProperties:e.voicingCanAnnounceProperties}),this.alertStableDelay=e.alertStableDelay,this.alertMaximumDelay=e.alertMaximumDelay,this.announcerOptions=e.announcerOptions,this.priorityProperty=new Re(e.priority),this.previousAlertText=null}static getAlertStringFromResponsePacket(t,e){var i=t.serialize();return e||(i.ignoreProperties=!0),is.collectResponses(i)}getAlertText(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=os.alertableToText(this._alert,t);return this.previousAlertText=e,e}getAlert(){return this._alert}get alert(){return this.getAlert()}set alert(t){this.setAlert(t)}setAlert(t){this._alert=t}setAlertStableDelay(t){this.alertStableDelay=t}toString(){return"Utterance_".concat(this.id,"#").concat(this.getAlertText())}toStateObject(){return{alert:Kt(rs([It,Ee])).toStateObject(this.getAlertText())}}reset(){this.previousAlertText=null}setCanAnnounceProperties(t){this.canAnnounceProperty.setDependentProperties(t)}set canAnnounceProperties(t){this.setCanAnnounceProperties(t)}get canAnnounceProperties(){return this.getCanAnnounceProperties()}getCanAnnounceProperties(){return this.canAnnounceProperty.getDependentProperties()}setDescriptionCanAnnounceProperties(t){this.descriptionCanAnnounceProperty.setDependentProperties(t)}set descriptionCanAnnounceProperties(t){this.setDescriptionCanAnnounceProperties(t)}get descriptionCanAnnounceProperties(){return this.getDescriptionCanAnnounceProperties()}getDescriptionCanAnnounceProperties(){return this.descriptionCanAnnounceProperty.getDependentProperties()}setVoicingCanAnnounceProperties(t){this.voicingCanAnnounceProperty.setDependentProperties(t)}set voicingCanAnnounceProperties(t){this.setVoicingCanAnnounceProperties(t)}get voicingCanAnnounceProperties(){return this.getVoicingCanAnnounceProperties()}getVoicingCanAnnounceProperties(){return this.voicingCanAnnounceProperty.getDependentProperties()}dispose(){this.canAnnounceProperty.dispose(),this.descriptionCanAnnounceProperty.dispose(),this.voicingCanAnnounceProperty.dispose(),this.priorityProperty.dispose()}static alertableToText(t){var e,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("function"==typeof t)e=t();else if(t instanceof ts)e=os.getAlertStringFromResponsePacket(t,i);else{if(t instanceof os)return t.getAlertText(i);e=t instanceof ce||t instanceof ae?t.value:t}return e}}_defineProperty(os,"TOP_PRIORITY",10),_defineProperty(os,"HIGH_PRIORITY",5),_defineProperty(os,"MEDIUM_PRIORITY",2),_defineProperty(os,"DEFAULT_PRIORITY",1),_defineProperty(os,"LOW_PRIORITY",0),_defineProperty(os,"UtteranceIO",new j("UtteranceIO",{valueType:os,documentation:"Announces text to a specific browser technology (like aria-live or web speech)",toStateObject:t=>t.toStateObject(),stateSchema:{alert:Kt(rs([It,Ee]))}}));class hs extends Ke{constructor(t){var e=w()({dependentProperties:[]},t),i=new me(new ae(!1));super(i),this._dependentProperties=[],this.implementationProperty=i,this.setDependentProperties(e.dependentProperties)}setDependentProperties(t){this.implementationProperty.value&&this.implementationProperty.value.dispose();var e=0===t.length?[new ae(!0)]:t;this.implementationProperty.value=Ue.and(e),this._dependentProperties=t}set dependentProperties(t){this.setDependentProperties(t)}get dependentProperties(){return this.getDependentProperties()}getDependentProperties(){return this._dependentProperties.slice(0)}dispose(){this.implementationProperty.dispose(),this._dependentProperties=[],super.dispose()}}qi.register("Utterance",os);var ls=os;qi.register("ActivationUtterance",class extends ls{constructor(t){var e=w()({alertStableDelay:500},t);super(e)}});class ds extends Vt{constructor(t){var e=w()({respectResponseCollectorProperties:!0,tandem:Ct.OPTIONAL,phetioType:ds.AnnouncerIO,phetioState:!1},t);super(e),this.respectResponseCollectorProperties=e.respectResponseCollectorProperties,this.readyToAnnounce=!0,this.hasSpoken=!1,this.announcementCompleteEmitter=new xe({parameters:[{name:"utterance",phetioType:ls.UtteranceIO},{name:"text",phetioType:Kt(rs([It,Ee]))}],tandem:e.tandem.createTandem("announcementCompleteEmitter"),phetioReadOnly:!0,phetioDocumentation:"The announcement that has just completed. The Utterance text could potentially differ from the exact text that was announced, so both are emitted. Use `text` for an exact match of what was announced."})}shouldUtteranceCancelOther(t,e){return e.priorityProperty.value{throw new Error("Cannot call mutable method '".concat(t,"' on immutable Vector3"))}}}Ts.mutableOverrideHelper("setXYZW"),Ts.mutableOverrideHelper("setX"),Ts.mutableOverrideHelper("setY"),Ts.mutableOverrideHelper("setZ"),Ts.mutableOverrideHelper("setW"),ws.ZERO=new ws(0,0,0,0),ws.X_UNIT=new ws(1,0,0,0),ws.Y_UNIT=new ws(0,1,0,0),ws.Z_UNIT=new ws(0,0,1,0),ws.W_UNIT=new ws(0,0,0,1);var Ss=(t,e)=>t.add(e);class As{constructor(t,e,i){this.x=t,this.y=e,this.z=i}getMagnitude(){return Math.sqrt(this.magnitudeSquared)}get magnitude(){return this.getMagnitude()}getMagnitudeSquared(){return this.dot(this)}get magnitudeSquared(){return this.getMagnitudeSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceXYZ(t,e,i){var s=this.x-t,n=this.y-e,r=this.z-i;return Math.sqrt(s*s+n*n+r*r)}distanceSquared(t){var e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}distanceSquaredXYZ(t,e,i){var s=this.x-t,n=this.y-e,r=this.z-i;return s*s+n*n+r*r}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}dotXYZ(t,e,i){return this.x*t+this.y*e+this.z*i}angleBetween(t){return Math.acos(De.clamp(this.normalized().dot(t.normalized()),-1,1))}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}equalsEpsilon(t,e){return e||(e=0),Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)<=e}isFinite(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.z)}copy(t){return t?t.set(this):Es(this.x,this.y,this.z)}cross(t){return Es(this.y*t.z-this.z*t.y,this.z*t.x-this.x*t.z,this.x*t.y-this.y*t.x)}normalized(){var t=this.magnitude;if(0===t)throw new Error("Cannot normalize a zero-magnitude vector");return Es(this.x/t,this.y/t,this.z/t)}roundedSymmetric(){return this.copy().roundSymmetric()}withMagnitude(t){return this.copy().setMagnitude(t)}timesScalar(t){return Es(this.x*t,this.y*t,this.z*t)}times(t){return this.timesScalar(t)}componentTimes(t){return Es(this.x*t.x,this.y*t.y,this.z*t.z)}plus(t){return Es(this.x+t.x,this.y+t.y,this.z+t.z)}plusXYZ(t,e,i){return Es(this.x+t,this.y+e,this.z+i)}plusScalar(t){return Es(this.x+t,this.y+t,this.z+t)}minus(t){return Es(this.x-t.x,this.y-t.y,this.z-t.z)}minusXYZ(t,e,i){return Es(this.x-t,this.y-e,this.z-i)}minusScalar(t){return Es(this.x-t,this.y-t,this.z-t)}dividedScalar(t){return Es(this.x/t,this.y/t,this.z/t)}negated(){return Es(-this.x,-this.y,-this.z)}blend(t,e){return this.plus(t.minus(this).times(e))}average(t){return this.blend(t,.5)}static average(t){return _.reduce(t,Ss,new As(0,0,0)).divideScalar(t.length)}toString(){return"Vector3(".concat(this.x,", ").concat(this.y,", ").concat(this.z,")")}toVector2(){return Ls(this.x,this.y)}toVector4(){return xs(this.x,this.y,this.z,1)}setXYZ(t,e,i){return this.x=t,this.y=e,this.z=i,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}set(t){return this.setXYZ(t.x,t.y,t.z)}setMagnitude(t){var e=t/this.magnitude;return this.multiplyScalar(e)}add(t){return this.setXYZ(this.x+t.x,this.y+t.y,this.z+t.z)}addXYZ(t,e,i){return this.setXYZ(this.x+t,this.y+e,this.z+i)}addScalar(t){return this.setXYZ(this.x+t,this.y+t,this.z+t)}subtract(t){return this.setXYZ(this.x-t.x,this.y-t.y,this.z-t.z)}subtractXYZ(t,e,i){return this.setXYZ(this.x-t,this.y-e,this.z-i)}subtractScalar(t){return this.setXYZ(this.x-t,this.y-t,this.z-t)}multiplyScalar(t){return this.setXYZ(this.x*t,this.y*t,this.z*t)}multiply(t){return this.multiplyScalar(t)}componentMultiply(t){return this.setXYZ(this.x*t.x,this.y*t.y,this.z*t.z)}divideScalar(t){return this.setXYZ(this.x/t,this.y/t,this.z/t)}negate(){return this.setXYZ(-this.x,-this.y,-this.z)}setCross(t){return this.setXYZ(this.y*t.z-this.z*t.y,this.z*t.x-this.x*t.z,this.x*t.y-this.y*t.x)}normalize(){var t=this.magnitude;if(0===t)throw new Error("Cannot normalize a zero-magnitude vector");return this.divideScalar(t)}roundSymmetric(){return this.setXYZ(Vs.roundSymmetric(this.x),Vs.roundSymmetric(this.y),Vs.roundSymmetric(this.z))}toStateObject(){return{x:Ee.toStateObject(this.x),y:Ee.toStateObject(this.y),z:Ee.toStateObject(this.z)}}freeToPool(){As.pool.freeToPool(this)}static slerp(t,e,i){return De.Quaternion.slerp(new De.Quaternion,De.Quaternion.getRotationQuaternion(t,e),i).timesVector3(t)}static fromStateObject(t){return Es(Ee.fromStateObject(t.x),Ee.fromStateObject(t.y),Ee.fromStateObject(t.z))}}_defineProperty(As,"pool",new zi(As,{maxSize:1e3,initialize:As.prototype.setXYZ,defaultArguments:[0,0,0]})),As.prototype.isVector3=!0,As.prototype.dimension=3,De.register("Vector3",As);var Es=As.pool.create.bind(As.pool);De.register("v3",Es);class Cs extends As{static mutableOverrideHelper(t){Cs.prototype[t]=()=>{throw new Error("Cannot call mutable method '".concat(t,"' on immutable Vector3"))}}}Cs.mutableOverrideHelper("setXYZ"),Cs.mutableOverrideHelper("setX"),Cs.mutableOverrideHelper("setY"),Cs.mutableOverrideHelper("setZ"),As.ZERO=new As(0,0,0),As.X_UNIT=new As(1,0,0),As.Y_UNIT=new As(0,1,0),As.Z_UNIT=new As(0,0,1),As.Vector3IO=new j("Vector3IO",{valueType:As,documentation:"Basic 3-dimensional vector, represented as (x,y,z)",toStateObject:t=>t.toStateObject(),fromStateObject:As.fromStateObject,stateSchema:{x:Ee,y:Ee,z:Ee}});var Ds=(t,e)=>t.add(e);class Is{constructor(t,e){this.x=t,this.y=e}getMagnitude(){return Math.sqrt(this.magnitudeSquared)}get magnitude(){return this.getMagnitude()}getMagnitudeSquared(){return this.x*this.x+this.y*this.y}get magnitudeSquared(){return this.getMagnitudeSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceXY(t,e){var i=this.x-t,s=this.y-e;return Math.sqrt(i*i+s*s)}distanceSquared(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i}distanceSquaredXY(t,e){var i=this.x-t,s=this.y-e;return i*i+s*s}dot(t){return this.x*t.x+this.y*t.y}dotXY(t,e){return this.x*t+this.y*e}getAngle(){return Math.atan2(this.y,this.x)}get angle(){return this.getAngle()}angleBetween(t){var e=this.magnitude,i=t.magnitude;return Math.acos(De.clamp((this.x*t.x+this.y*t.y)/(e*i),-1,1))}equals(t){return this.x===t.x&&this.y===t.y}equalsEpsilon(t,e){return e||(e=0),Math.max(Math.abs(this.x-t.x),Math.abs(this.y-t.y))<=e}isFinite(){return isFinite(this.x)&&isFinite(this.y)}copy(t){return t?t.set(this):Ls(this.x,this.y)}crossScalar(t){return this.x*t.y-this.y*t.x}normalized(){var t=this.magnitude;if(0===t)throw new Error("Cannot normalize a zero-magnitude vector");return Ls(this.x/t,this.y/t)}roundedSymmetric(){return this.copy().roundSymmetric()}withMagnitude(t){return this.copy().setMagnitude(t)}timesScalar(t){return Ls(this.x*t,this.y*t)}times(t){return this.timesScalar(t)}componentTimes(t){return Ls(this.x*t.x,this.y*t.y)}plus(t){return Ls(this.x+t.x,this.y+t.y)}plusXY(t,e){return Ls(this.x+t,this.y+e)}plusScalar(t){return Ls(this.x+t,this.y+t)}minus(t){return Ls(this.x-t.x,this.y-t.y)}minusXY(t,e){return Ls(this.x-t,this.y-e)}minusScalar(t){return Ls(this.x-t,this.y-t)}dividedScalar(t){return Ls(this.x/t,this.y/t)}negated(){return Ls(-this.x,-this.y)}getPerpendicular(){return Ls(this.y,-this.x)}get perpendicular(){return this.getPerpendicular()}rotated(t){var e=this.angle+t,i=this.magnitude;return Ls(i*Math.cos(e),i*Math.sin(e))}rotateAboutXY(t,e,i){var s=this.x-t,n=this.y-e,r=Math.cos(i),a=Math.sin(i);return this.x=t+s*r-n*a,this.y=e+s*a+n*r,this}rotateAboutPoint(t,e){return this.rotateAboutXY(t.x,t.y,e)}rotatedAboutXY(t,e,i){return Ls(this.x,this.y).rotateAboutXY(t,e,i)}rotatedAboutPoint(t,e){return this.rotatedAboutXY(t.x,t.y,e)}blend(t,e){return Ls(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}average(t){return this.blend(t,.5)}static average(t){return _.reduce(t,Ds,new Is(0,0)).divideScalar(t.length)}toString(){return"Vector2(".concat(this.x,", ").concat(this.y,")")}toVector3(){return new As(this.x,this.y,0)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}set(t){return this.setXY(t.x,t.y)}setMagnitude(t){var e=t/this.magnitude;return this.multiplyScalar(e)}add(t){return this.setXY(this.x+t.x,this.y+t.y)}addXY(t,e){return this.setXY(this.x+t,this.y+e)}addScalar(t){return this.setXY(this.x+t,this.y+t)}subtract(t){return this.setXY(this.x-t.x,this.y-t.y)}subtractXY(t,e){return this.setXY(this.x-t,this.y-e)}subtractScalar(t){return this.setXY(this.x-t,this.y-t)}multiplyScalar(t){return this.setXY(this.x*t,this.y*t)}multiply(t){return this.multiplyScalar(t)}componentMultiply(t){return this.setXY(this.x*t.x,this.y*t.y)}divideScalar(t){return this.setXY(this.x/t,this.y/t)}negate(){return this.setXY(-this.x,-this.y)}normalize(){var t=this.magnitude;if(0===t)throw new Error("Cannot normalize a zero-magnitude vector");return this.divideScalar(t)}roundSymmetric(){return this.setXY(Vs.roundSymmetric(this.x),Vs.roundSymmetric(this.y))}rotate(t){var e=this.angle+t,i=this.magnitude;return this.setXY(i*Math.cos(e),i*Math.sin(e))}setPolar(t,e){return this.setXY(t*Math.cos(e),t*Math.sin(e))}toStateObject(){return{x:Ee.toStateObject(this.x),y:Ee.toStateObject(this.y)}}freeToPool(){Is.pool.freeToPool(this)}static get STATE_SCHEMA(){return{x:Ee,y:Ee}}static createPolar(t,e){return new Is(0,0).setPolar(t,e)}static fromStateObject(t){return Ls(Ee.fromStateObject(t.x),Ee.fromStateObject(t.y))}static getAngleBetweenVectors(t,e){var i=e.x-t.x,s=e.y-t.y;return Math.atan2(s,i)}static getDistanceBetweenVectors(t,e){var i=e.x-t.x,s=e.y-t.y;return Math.sqrt(i*i+s*s)}}_defineProperty(Is,"pool",new zi(Is,{maxSize:1e3,initialize:Is.prototype.setXY,defaultArguments:[0,0]})),Is.prototype.isVector2=!0,Is.prototype.dimension=2,De.register("Vector2",Is);var Ls=Is.pool.create.bind(Is.pool);De.register("v2",Ls);class ks extends Is{static mutableOverrideHelper(t){ks.prototype[t]=()=>{throw new Error("Cannot call mutable method '".concat(t,"' on immutable Vector2"))}}}ks.mutableOverrideHelper("setXY"),ks.mutableOverrideHelper("setX"),ks.mutableOverrideHelper("setY"),Is.ZERO=new Is(0,0),Is.X_UNIT=new Is(1,0),Is.Y_UNIT=new Is(0,1),Is.Vector2IO=j.fromCoreType("Vector2IO",Is,{documentation:"A numerical object with x and y properties, like {x:3,y:4}"});var Ms,Os,Rs,Ns=Number.MIN_VALUE,Bs=2*Math.PI,Fs={clamp:(t,e,i)=>ti?i:t,moduloBetweenDown(t,e,i){var s=i-e,n=(t-e)%s;return n<0&&(n+=s),n+e},moduloBetweenUp:(t,e,i)=>-Fs.moduloBetweenDown(-t,-i,-e),rangeInclusive(t,e){if(eFs.rangeInclusive(t+1,e-1),toRadians:t=>Math.PI*t/180,toDegrees:t=>180*t/Math.PI,mod:(t,e)=>t/e%1==0?0:t%e,gcd(t,e){return Math.abs(0===e?t:this.gcd(e,Fs.mod(t,e)))},lcm:(t,e)=>Fs.roundSymmetric(Math.abs(t*e)/Fs.gcd(t,e)),lineLineIntersection(t,e,i,s){if(t.equals(e)||i.equals(s))return null;var n=t.x-e.x,r=i.x-s.x,a=t.y-e.y,o=i.y-s.y,h=n*o-a*r;if(Math.abs(h)<1e-10)return null;var l=t.x*e.y-t.y*e.x,d=i.x*s.y-i.y*s.x;return new Is((l*r-n*d)/h,(l*o-a*d)/h)},circleCenterFromPoints(t,e,i){var s=new Is((t.x+e.x)/2,(t.y+e.y)/2),n=new Is((e.x+i.x)/2,(e.y+i.y)/2),r=new Is(s.x+(e.y-t.y),s.y-(e.x-t.x)),a=new Is(n.x+(i.y-e.y),n.y-(i.x-e.x));return Fs.lineLineIntersection(s,r,n,a)},pointInCircleFromPoints(t,e,i,s){var n=t.x-s.x,r=t.y-s.y,a=(t.x-s.x)*(t.x-s.x)+(t.y-s.y)*(t.y-s.y),o=e.x-s.x,h=e.y-s.y,l=(e.x-s.x)*(e.x-s.x)+(e.y-s.y)*(e.y-s.y),d=i.x-s.x,u=i.y-s.y,c=(i.x-s.x)*(i.x-s.x)+(i.y-s.y)*(i.y-s.y);return n*h*c+r*l*d+a*o*u-a*h*d-r*o*c-n*l*u>0},sphereRayIntersection(t,e,i){i=void 0===i?1e-5:i;var s=new De.Vector3(0,0,0),n=e.direction,r=e.position,a=r.minus(s),o=n.dot(a),h=4*o*o-4*(a.magnitudeSquared-t*t);if(h0===t?0===e?null:[]:[-e/t],solveQuadraticRootsReal(t,e,i){if(0===t||Math.abs(e/t)>1e7||Math.abs(i/t)>1e7)return Fs.solveLinearRootsReal(e,i);var s=e*e-4*t*i;if(s<0)return[];var n=Math.sqrt(s);return[(-e-n)/(2*t),(-e+n)/(2*t)]},solveCubicRootsReal(t,e,i,s){var n,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1e-7;if(0===t)n=Fs.solveQuadraticRootsReal(e,i,s);else{if(0===t||Math.abs(e/t)>1e7||Math.abs(i/t)>1e7||Math.abs(s/t)>1e7)n=Fs.solveQuadraticRootsReal(e,i,s);else if(0===s||Math.abs(t/s)>1e7||Math.abs(e/s)>1e7||Math.abs(i/s)>1e7)n=[0].concat(Fs.solveQuadraticRootsReal(t,e,i));else{var a=(3*(i/=t)-(e/=t)*e)/9,o=(-27*(s/=t)+e*(9*i-e*e*2))/54,h=a*a*a+o*o,l=e/3;if(h>r){var d=Math.sqrt(h);n=[Fs.cubeRoot(o+d)+Fs.cubeRoot(o-d)-l]}else if(h>-r){var u=Fs.cubeRoot(o),c=-l-u;n=[2*u-l,c,c]}else{var m=-a*a*a;m=Math.acos(o/Math.sqrt(m));var p=2*Math.sqrt(-a);n=[-l+p*Math.cos(m/3),-l+p*Math.cos((m+2*Math.PI)/3),-l+p*Math.cos((m+4*Math.PI)/3)]}}}return n},cubeRoot:t=>t>=0?Math.pow(t,1/3):-Math.pow(-t,1/3),linear:(t,e,i,s,n)=>(s-i)/(e-t)*(n-t)+i,roundSymmetric:t=>(t<0?-1:1)*Math.round(Math.abs(t)),toFixed(t,e){var i=Math.pow(10,e);return(Fs.roundSymmetric(t*i)/i).toFixed(e)},toFixedNumber:(t,e)=>parseFloat(Fs.toFixed(t,e)),equalsEpsilon:(t,e,i)=>Math.abs(t-e)<=i,lineSegmentIntersection(t,e,i,s,n,r,a,o){var h=(t,e,i,s,n,r)=>(r-e)*(i-t)-(s-e)*(n-t);if(h(t,e,n,r,a,o)*h(i,s,n,r,a,o)>0||h(n,r,t,e,i,s)*h(a,o,t,e,i,s)>0)return null;var l=(t-i)*(r-o)-(e-s)*(n-a);return Math.abs(l)<1e-10?null:t===n&&e===r||t===a&&e===o?new Is(t,e):i===n&&s===r||i===a&&s===o?new Is(i,s):new Is(((t*s-e*i)*(n-a)-(t-i)*(n*o-r*a))/l,((t*s-e*i)*(r-o)-(e-s)*(n*o-r*a))/l)},distToSegmentSquared(t,e,i){var s=e.distanceSquared(i);if(0===s)return t.distanceSquared(e);var n=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/s;return n<0?t.distanceSquared(e):n>1?t.distanceSquared(i):t.distanceSquared(new Is(e.x+n*(i.x-e.x),e.y+n*(i.y-e.y)))},distToSegment(t,e,i){return Math.sqrt(this.distToSegmentSquared(t,e,i))},arePointsCollinear:(t,e,i,s)=>(void 0===s&&(s=0),Fs.triangleArea(t,e,i)<=s),triangleArea:(t,e,i)=>Math.abs(Fs.triangleAreaSigned(t,e,i)),triangleAreaSigned:(t,e,i)=>t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y),centroidOfPolygon(t){var e=new Is(0,0),i=0;return t.forEach((s,n)=>{var r=t[(n+1)%t.length],a=s.x*r.y-r.x*s.y;i+=a/2,e.addXY((s.x+r.x)*a,(s.y+r.y)*a)}),e.divideScalar(6*i),e},cosh:t=>(Math.exp(t)+Math.exp(-t))/2,sinh:t=>(Math.exp(t)-Math.exp(-t))/2,log10:t=>Math.log(t)/Math.LN10,boxMullerTransform(t,e,i){if(!(Ms=!Ms))return Rs*e+t;var s,n;do{s=i.nextDouble(),n=i.nextDouble()}while(s<=Ns);return Os=Math.sqrt(-2*Math.log(s))*Math.cos(Bs*n),Rs=Math.sqrt(-2*Math.log(s))*Math.sin(Bs*n),Os*e+t},numberOfDecimalPlaces(t){if(Math.floor(t)===t)return 0;var e=t.toString();if(e.includes("e")){var i=e.split("e"),s=i[0],n=Number(i[1]),r=s.includes(".")?s.split(".")[1].length:0;return Math.max(r-n,0)}return e.split(".")[1].length},roundToInterval:(t,e)=>Fs.toFixedNumber(Fs.roundSymmetric(t/e)*e,Fs.numberOfDecimalPlaces(e))};De.register("Utils",Fs),De.clamp=Fs.clamp,De.moduloBetweenDown=Fs.moduloBetweenDown,De.moduloBetweenUp=Fs.moduloBetweenUp,De.rangeInclusive=Fs.rangeInclusive,De.rangeExclusive=Fs.rangeExclusive,De.toRadians=Fs.toRadians,De.toDegrees=Fs.toDegrees,De.lineLineIntersection=Fs.lineLineIntersection,De.lineSegmentIntersection=Fs.lineSegmentIntersection,De.sphereRayIntersection=Fs.sphereRayIntersection,De.solveQuadraticRootsReal=Fs.solveQuadraticRootsReal,De.solveCubicRootsReal=Fs.solveCubicRootsReal,De.cubeRoot=Fs.cubeRoot,De.linear=Fs.linear,De.boxMullerTransform=Fs.boxMullerTransform;var Vs=Fs,Hs=Vs.clamp,Ys=Vs.linear,zs="(-?\\d{1,3}%?)";function Ws(t){var e=1;return t.endsWith("%")&&(e=2.55,t=t.slice(0,t.length-1)),Vs.roundSymmetric(Number(t)*e)}class Us{constructor(t,e,i,s){this.changeEmitter=new c,this.set(t,e,i,s)}copy(){return new Us(this.r,this.g,this.b,this.a)}set(t,e,i,s){if(null===t)this.setRGBA(0,0,0,0);else if("string"==typeof t)this.setCSS(t);else if(t instanceof Us)this.setRGBA(t.r,t.g,t.b,t.a);else if(void 0===i){var n=t>>16&255,r=t>>8&255,a=t>>0&255,o=void 0===e?1:e;this.setRGBA(n,r,a,o)}else this.setRGBA(t,e,i,void 0===s?1:s);return this}getRed(){return this.r}get red(){return this.getRed()}set red(t){this.setRed(t)}setRed(t){return this.setRGBA(t,this.g,this.b,this.a)}getGreen(){return this.g}get green(){return this.getGreen()}set green(t){this.setGreen(t)}setGreen(t){return this.setRGBA(this.r,t,this.b,this.a)}getBlue(){return this.b}get blue(){return this.getBlue()}set blue(t){this.setBlue(t)}setBlue(t){return this.setRGBA(this.r,this.g,t,this.a)}getAlpha(){return this.a}get alpha(){return this.getAlpha()}set alpha(t){this.setAlpha(t)}setAlpha(t){return this.setRGBA(this.r,this.g,this.b,t)}setRGBA(t,e,i,s){return this.r=Vs.roundSymmetric(Hs(t,0,255)),this.g=Vs.roundSymmetric(Hs(e,0,255)),this.b=Vs.roundSymmetric(Hs(i,0,255)),this.a=Hs(s,0,1),this.updateColor(),this}blend(t,e){var i=Math.pow(this.r,2.4),s=Math.pow(t.r,2.4),n=Math.pow(this.g,2.4),r=Math.pow(t.g,2.4),a=Math.pow(this.b,2.4),o=Math.pow(t.b,2.4),h=Math.pow(i+(s-i)*e,1/2.4),l=Math.pow(n+(r-n)*e,1/2.4),d=Math.pow(a+(o-a)*e,1/2.4),u=this.a+(t.a-this.a)*e;return new Us(h,l,d,u)}computeCSS(){if(1===this.a)return"rgb(".concat(this.r,",").concat(this.g,",").concat(this.b,")");for(var t=this.a.toFixed(20);t.length>=2&&t.endsWith("0")&&"."!==t[t.length-2];)t=t.slice(0,t.length-1);var e=0===this.a||1===this.a?this.a:t;return"rgba(".concat(this.r,",").concat(this.g,",").concat(this.b,",").concat(e,")")}toCSS(){return this._css}setCSS(t){for(var e=!1,i=Us.preprocessCSS(t),s=0;s0?this.colorUtilsBrighter(t):this.colorUtilsDarker(-t)}toString(){return"".concat(this.constructor.name,"[r:").concat(this.r," g:").concat(this.g," b:").concat(this.b," a:").concat(this.a,"]")}toHexString(){for(var t=this.toNumber().toString(16);t.length<6;)t="0".concat(t);return"#".concat(t)}toStateObject(){return{r:this.r,g:this.g,b:this.b,a:this.a}}static hueToRGB(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}static toColor(t){return null===t?Us.TRANSPARENT:t instanceof Us?t:"string"==typeof t?new Us(t):Us.toColor(t.value)}static interpolateRGBA(t,e,i){if(i<0||i>1)throw new Error("distance must be between 0 and 1: ".concat(i));var s=Math.floor(Ys(0,1,t.r,e.r,i)),n=Math.floor(Ys(0,1,t.g,e.g,i)),r=Math.floor(Ys(0,1,t.b,e.b,i)),a=Ys(0,1,t.a,e.a,i);return new Us(s,n,r,a)}static supersampleBlend(t){var e=t.map(t=>Math.pow(t.r/255,2.2)),i=t.map(t=>Math.pow(t.g/255,2.2)),s=t.map(t=>Math.pow(t.b/255,2.2)),n=t.map(t=>Math.pow(t.a,2.2)),r=_.sum(n);if(0===r)return new Us(0,0,0,0);var a=_.sum(_.range(0,t.length).map(t=>e[t]*n[t]))/r,o=_.sum(_.range(0,t.length).map(t=>i[t]*n[t]))/r,h=_.sum(_.range(0,t.length).map(t=>s[t]*n[t]))/r,l=r/t.length;return new Us(Math.floor(255*Math.pow(a,1/2.2)),Math.floor(255*Math.pow(o,1/2.2)),Math.floor(255*Math.pow(h,1/2.2)),Math.pow(l,1/2.2))}static fromStateObject(t){return new Us(t.r,t.g,t.b,t.a)}static hsla(t,e,i,s){return new Us(0,0,0,1).setHSLA(t,e,i,s)}static checkPaintString(t){0}static checkPaint(t){"string"==typeof t?Us.checkPaintString(t):t instanceof ce&&"string"==typeof t.value&&Us.checkPaintString(t.value)}static getLuminance(t){var e=Us.toColor(t),i=.2126*e.red+.7152*e.green+.0722*e.blue;return i}static toGrayscale(t){var e=Us.getLuminance(t);return new Us(e,e,e)}static isDarkColor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:186;return Us.getLuminance(t){t.setRGBA(0,0,0,0)}},{regexp:/^#(\w{1})(\w{1})(\w{1})$/,apply:(t,e)=>{t.setRGBA(parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16),1)}},{regexp:/^#(\w{2})(\w{2})(\w{2})$/,apply:(t,e)=>{t.setRGBA(parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16),1)}},{regexp:new RegExp("^rgb\\(".concat(zs,",").concat(zs,",").concat(zs,"\\)$")),apply:(t,e)=>{t.setRGBA(Ws(e[1]),Ws(e[2]),Ws(e[3]),1)}},{regexp:new RegExp("^rgba\\(".concat(zs,",").concat(zs,",").concat(zs,",").concat("(\\d+|\\d*\\.\\d+)","\\)$")),apply:(t,e)=>{t.setRGBA(Ws(e[1]),Ws(e[2]),Ws(e[3]),Number(e[4]))}},{regexp:new RegExp("^hsl\\(".concat("(\\d{1,3})",",").concat("(\\d{1,3})","%,").concat("(\\d{1,3})","%\\)$")),apply:(t,e)=>{t.setHSLA(Number(e[1]),Number(e[2]),Number(e[3]),1)}},{regexp:new RegExp("^hsla\\(".concat("(\\d{1,3})",",").concat("(\\d{1,3})","%,").concat("(\\d{1,3})","%,").concat("(\\d+|\\d*\\.\\d+)","\\)$")),apply:(t,e)=>{t.setHSLA(Number(e[1]),Number(e[2]),Number(e[3]),Number(e[4]))}}]),_defineProperty(Us,"basicColorKeywords",{aqua:"00ffff",black:"000000",blue:"0000ff",fuchsia:"ff00ff",gray:"808080",green:"008000",lime:"00ff00",maroon:"800000",navy:"000080",olive:"808000",purple:"800080",red:"ff0000",silver:"c0c0c0",teal:"008080",white:"ffffff",yellow:"ffff00"}),_defineProperty(Us,"colorKeywords",{aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"778899",lightslategrey:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"}),bs.register("Color",Us),Us.BLACK=Us.black=new Us(0,0,0).setImmutable(),Us.BLUE=Us.blue=new Us(0,0,255).setImmutable(),Us.CYAN=Us.cyan=new Us(0,255,255).setImmutable(),Us.DARK_GRAY=Us.darkGray=new Us(64,64,64).setImmutable(),Us.GRAY=Us.gray=new Us(128,128,128).setImmutable(),Us.GREEN=Us.green=new Us(0,255,0).setImmutable(),Us.LIGHT_GRAY=Us.lightGray=new Us(192,192,192).setImmutable(),Us.MAGENTA=Us.magenta=new Us(255,0,255).setImmutable(),Us.ORANGE=Us.orange=new Us(255,200,0).setImmutable(),Us.PINK=Us.pink=new Us(255,175,175).setImmutable(),Us.RED=Us.red=new Us(255,0,0).setImmutable(),Us.WHITE=Us.white=new Us(255,255,255).setImmutable(),Us.YELLOW=Us.yellow=new Us(255,255,0).setImmutable(),Us.TRANSPARENT=Us.transparent=new Us(0,0,0,0).setImmutable();new Us("blue");Us.ColorIO=new j("ColorIO",{valueType:Us,documentation:"A color, with rgba",toStateObject:t=>t.toStateObject(),fromStateObject:t=>new Us(t.r,t.g,t.b,t.a),stateSchema:{r:Ee,g:Ee,b:Ee,a:Ee}});var Gs={};function Xs(t){try{var e=document.createElement("canvas");e.width=1,e.height=1;var i=e.getContext("2d");i.fillStyle="black",i.fillRect(0,0,1,1);var s=e.toDataURL([t]),n="data:".concat(t);return s.slice(0,n.length)===n}catch(r){return!1}}function js(t,e){var i=document.createElement("canvas");i.width=1,i.height=1;var s=i.getContext("2d"),n=document.createElement("img");n.crossOrigin="Anonymous";var r=()=>{try{s.drawImage(n,0,0),i.toDataURL(),Gs[t]=!0}catch(e){Gs[t]=!1}};n.onload=r;try{n.src=e,n.complete&&r()}catch(a){Gs[t]=!1}}bs.register("Features",Gs),Gs.canvasPNGOutput=Xs("image/png"),Gs.canvasJPEGOutput=Xs("image/jpeg"),Gs.canvasGIFOutput=Xs("image/gif"),Gs.canvasICONOutput=Xs("image/x-icon"),js("canvasPNGInput","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2NkYGD4DwABCQEBtxmN7wAAAABJRU5ErkJggg=="),js("canvasJPEGInput","data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCAABAAEDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD8qqKKKAP/2Q=="),js("canvasSVGInput","data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+DQo8c3ZnIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3cG9ydD0iMCAwIDEgMSIgd2lkdGg9IjEiIGhlaWdodD0iMSIgPg0KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiByeD0iMCIgcnk9IjAiIHN0eWxlPSJmaWxsOiBibGFjazsgc3Ryb2tlOiBub25lOyI+PC9yZWN0Pg0KPC9zdmc+DQo="),js("canvasGIFInput","data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAABAAEAAAICRAEAOw==");var qs=document.createElement("canvas"),Ks=qs.getContext("2d");Gs.toDataURLHD=hi(qs,"toDataURLHD"),Gs.createImageDataHD=hi(Ks,"createImageDataHD"),Gs.getImageDataHD=hi(Ks,"getImageDataHD"),Gs.putImageDataHD=hi(Ks,"putImageDataHD"),Gs.currentTransform=hi(Ks,"currentTransform"),Gs.canvasFilter=hi(Ks,"filter");var Zs=document.createElement("span"),Qs=document.createElement("div");Gs.textStroke=hi(Zs.style,"textStroke"),Gs.textStrokeColor=hi(Zs.style,"textStrokeColor"),Gs.textStrokeWidth=hi(Zs.style,"textStrokeWidth"),Gs.transform=hi(Qs.style,"transform"),Gs.transformOrigin=hi(Qs.style,"transformOrigin"),Gs.backfaceVisibility=hi(Qs.style,"backfaceVisibility"),Gs.borderRadius=hi(Qs.style,"borderRadius"),Gs.userSelect=hi(Qs.style,"userSelect"),Gs.touchAction=hi(Qs.style,"touchAction"),Gs.touchCallout=hi(Qs.style,"touchCallout"),Gs.userDrag=hi(Qs.style,"userDrag"),Gs.tapHighlightColor=hi(Qs.style,"tapHighlightColor"),Gs.fontSmoothing=hi(Qs.style,"fontSmoothing"),Gs.requestAnimationFrame=hi(window,"requestAnimationFrame"),Gs.cancelAnimationFrame=hi(window,"cancelAnimationFrame"),Gs.setStyle=(t,e,i)=>{void 0!==e&&(t.style[e]=i)},Gs.passive=!1,window.addEventListener("test",null,Object.defineProperty({},"passive",{get:()=>{Gs.passive=!0}}));var Js=Gs,$s=["normal","italic","oblique"],tn=["normal","small-caps"],en=["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900"],sn=["normal","ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded","ultra-expanded"];class nn extends Vt{constructor(t){var e=w()({style:"normal",variant:"normal",weight:"normal",stretch:"normal",size:"10px",lineHeight:"normal",family:"sans-serif",phetioType:nn.FontIO,tandem:Ct.OPTIONAL},t);super(e),this._style=e.style,this._variant=e.variant,this._weight="".concat(e.weight),this._stretch=e.stretch,this._size=nn.castSize(e.size),this._lineHeight=e.lineHeight,this._family=e.family,this._font=this.computeShorthand()}getFont(){return this._font}get font(){return this.getFont()}getStyle(){return this._style}get style(){return this.getStyle()}getVariant(){return this._variant}get variant(){return this.getVariant()}getWeight(){return this._weight}get weight(){return this.getWeight()}getStretch(){return this._stretch}get stretch(){return this.getStretch()}getSize(){return this._size}get size(){return this.getSize()}getNumericSize(){var t=this._size.match(/^(\d+)px$/);if(t)return Number(t[1]);var e=this._size.match(/^(\d+)pt$/);if(e)return.75*Number(e[1]);var i=this._size.match(/^(\d+)em$/);return i?Number(i[1])/16:12}get numericSize(){return this.getNumericSize()}getLineHeight(){return this._lineHeight}get lineHeight(){return this.getLineHeight()}getFamily(){return this._family}get family(){return this.getFamily()}copy(t){return new nn(T({style:this._style,variant:this._variant,weight:this._weight,stretch:this._stretch,size:this._size,lineHeight:this._lineHeight,family:this._family},t))}computeShorthand(){var t="";return"normal"!==this._style&&(t+="".concat(this._style," ")),"normal"!==this._variant&&(t+="".concat(this._variant," ")),"normal"!==this._weight&&(t+="".concat(this._weight," ")),"normal"!==this._stretch&&(t+="".concat(this._stretch," ")),t+=this._size,"normal"!==this._lineHeight&&(t+="/".concat(this._lineHeight)),t+=" ".concat(this._family)}toCSS(){return this.getFont()}static castSize(t){return"number"==typeof t?"".concat(t,"px"):t}static isFontStyle(t){return $s.includes(t)}static isFontVariant(t){return tn.includes(t)}static isFontWeight(t){return en.includes(t)}static isFontStretch(t){return sn.includes(t)}static fromCSS(t){for(var e={},i=_.filter(t.split(/[\x09\x0A\x0C\x0D\x20]/),t=>t.length>0),s=0;s
  • style: normal — normal | italic | oblique
  • variant: normal — normal | small-caps
  • weight: normal — normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
  • stretch: normal — normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
  • size: 10px — absolute-size | relative-size | length | percentage -- unitless number interpreted as px. absolute suffixes: cm, mm, in, pt, pc, px. relative suffixes: em, ex, ch, rem, vw, vh, vmin, vmax.
  • lineHeight: normal — normal | number | length | percentage -- NOTE: Canvas spec forces line-height to normal
  • family: sans-serif — comma-separated list of families, including generic families (serif, sans-serif, cursive, fantasy, monospace). ideally escape with double-quotes
  • ",toStateObject:t=>({style:t.getStyle(),variant:t.getVariant(),weight:t.getWeight(),stretch:t.getStretch(),size:t.getSize(),lineHeight:t.getLineHeight(),family:t.getFamily()}),fromStateObject:t=>new nn(t)}),nn.DEFAULT=new nn;var rn={};bs.register("Renderer",rn),rn.numActiveRenderers=4,rn.bitsPerRenderer=5,rn.bitmaskRendererArea=255,rn.bitmaskCurrentRendererArea=15,rn.bitmaskLacksOffset=65536,rn.bitmaskLacksShift=16,rn.bitmaskNodeDefault=rn.bitmaskRendererArea,rn.bitmaskCanvas=1,rn.bitmaskSVG=2,rn.bitmaskDOM=4,rn.bitmaskWebGL=8,rn.bitmaskSingleCanvas=256,rn.bitmaskSingleSVG=512,rn.bitmaskNotPainted=4096,rn.bitmaskBoundsValid=8192,rn.bitmaskNoPDOM=16384,rn.bitmaskLacksCanvas=rn.bitmaskCanvas<0&&(t>>=5*e),t&rn.bitmaskCurrentRendererArea},rn.bitmaskOrderFirst=function(t){return t&rn.bitmaskCurrentRendererArea},rn.bitmaskOrderSecond=function(t){return t>>5&rn.bitmaskCurrentRendererArea},rn.bitmaskOrderThird=function(t){return t>>10&rn.bitmaskCurrentRendererArea},rn.bitmaskOrderFourth=function(t){return t>>15&rn.bitmaskCurrentRendererArea},rn.pushOrderBitmask=function(t,e){for(var i=e,s=rn.bitsPerRenderer*rn.numActiveRenderers,n=0;n<=s;n+=rn.bitsPerRenderer){var r=t>>n&rn.bitmaskCurrentRendererArea;if(r===i)return t;if(0===r)return t|=i<0&&this.getHeight()>0}isValid(){return!this.isEmpty()&&this.isFinite()}closestPointTo(t){if(this.containsCoordinates(t.x,t.y))return t;var e=Math.max(Math.min(t.x,this.maxX),this.x),i=Math.max(Math.min(t.y,this.maxY),this.y);return new Is(e,i)}containsCoordinates(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}containsPoint(t){return this.containsCoordinates(t.x,t.y)}containsBounds(t){return this.minX<=t.minX&&this.maxX>=t.maxX&&this.minY<=t.minY&&this.maxY>=t.maxY}intersectsBounds(t){var e=Math.max(this.minX,t.minX),i=Math.max(this.minY,t.minY),s=Math.min(this.maxX,t.maxX),n=Math.min(this.maxY,t.maxY);return s-e>=0&&n-i>=0}minimumDistanceToPointSquared(t){var e,i=t.xthis.maxX?this.maxX:null,s=t.ythis.maxY?this.maxY:null;if(null===i&&null===s)return 0;if(null===i)return(e=s-t.y)*e;if(null===s)return(e=i-t.x)*e;var n=i-t.x,r=s-t.y;return n*n+r*r}maximumDistanceToPointSquared(t){var e=t.x>this.getCenterX()?this.minX:this.maxX,i=t.y>this.getCenterY()?this.minY:this.maxY;return(e-=t.x)*e+(i-=t.y)*i}toString(){return"[x:(".concat(this.minX,",").concat(this.maxX,"),y:(").concat(this.minY,",").concat(this.maxY,")]")}equals(t){return this.minX===t.minX&&this.minY===t.minY&&this.maxX===t.maxX&&this.maxY===t.maxY}equalsEpsilon(t,e){e=void 0!==e?e:0;var i=this.isFinite(),s=t.isFinite();return i&&s?Math.abs(this.minX-t.minX)this.maxX&&(i.x=this.maxX),i.ythis.maxY&&(i.y=this.maxY),i}freeToPool(){mn.pool.freeToPool(this)}static rect(t,e,i,s){return pn(t,e,t+i,e+s)}static oriented(t,e,i,s,n){return t===Li.HORIZONTAL?new mn(e,i,s,n):new mn(i,e,n,s)}static point(t,e){if(t instanceof Is){var i=t;return pn(i.x,i.y,i.x,i.y)}return pn(t,e,t,e)}}_defineProperty(mn,"pool",new zi(mn,{initialize:mn.prototype.setMinMax,defaultArguments:[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY]})),De.register("Bounds2",mn);var pn=mn.pool.create.bind(mn.pool);De.register("b2",pn),mn.prototype.isBounds=!0,mn.prototype.dimension=2,mn.NOTHING=new mn(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),mn.EVERYTHING=new mn(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),mn.Bounds2IO=new j("Bounds2IO",{valueType:mn,documentation:"a 2-dimensional bounds rectangle",toStateObject:t=>({minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}),fromStateObject:t=>new mn(Ee.fromStateObject(t.minX),Ee.fromStateObject(t.minY),Ee.fromStateObject(t.maxX),Ee.fromStateObject(t.maxY)),stateSchema:{minX:Ee,maxX:Ee,minY:Ee,maxY:Ee}});var gn=window.Float32Array||Array;class vn{constructor(t,e,i,s,n,r,a,o,h,l,d,u,c,m,p,g,v){this.entries=new gn(16),this.type=fn.OTHER,this.rowMajor(void 0!==t?t:1,void 0!==e?e:0,void 0!==i?i:0,void 0!==s?s:0,void 0!==n?n:0,void 0!==r?r:1,void 0!==a?a:0,void 0!==o?o:0,void 0!==h?h:0,void 0!==l?l:0,void 0!==d?d:1,void 0!==u?u:0,void 0!==c?c:0,void 0!==m?m:0,void 0!==p?p:0,void 0!==g?g:1,v)}rowMajor(t,e,i,s,n,r,a,o,h,l,d,u,c,m,p,g,v){return this.entries[0]=t,this.entries[1]=n,this.entries[2]=h,this.entries[3]=c,this.entries[4]=e,this.entries[5]=r,this.entries[6]=l,this.entries[7]=m,this.entries[8]=i,this.entries[9]=a,this.entries[10]=d,this.entries[11]=p,this.entries[12]=s,this.entries[13]=o,this.entries[14]=u,this.entries[15]=g,this.type=void 0===v?0===c&&0===m&&0===p&&1===g?fn.AFFINE:fn.OTHER:v,this}columnMajor(t,e,i,s,n,r,a,o,h,l,d,u,c,m,p,g,v){return this.rowMajor(t,n,h,c,e,r,l,m,i,a,d,p,s,o,u,g,v)}set(t){return this.rowMajor(t.m00(),t.m01(),t.m02(),t.m03(),t.m10(),t.m11(),t.m12(),t.m13(),t.m20(),t.m21(),t.m22(),t.m23(),t.m30(),t.m31(),t.m32(),t.m33(),t.type)}m00(){return this.entries[0]}m01(){return this.entries[4]}m02(){return this.entries[8]}m03(){return this.entries[12]}m10(){return this.entries[1]}m11(){return this.entries[5]}m12(){return this.entries[9]}m13(){return this.entries[13]}m20(){return this.entries[2]}m21(){return this.entries[6]}m22(){return this.entries[10]}m23(){return this.entries[14]}m30(){return this.entries[3]}m31(){return this.entries[7]}m32(){return this.entries[11]}m33(){return this.entries[15]}isFinite(){return isFinite(this.m00())&&isFinite(this.m01())&&isFinite(this.m02())&&isFinite(this.m03())&&isFinite(this.m10())&&isFinite(this.m11())&&isFinite(this.m12())&&isFinite(this.m13())&&isFinite(this.m20())&&isFinite(this.m21())&&isFinite(this.m22())&&isFinite(this.m23())&&isFinite(this.m30())&&isFinite(this.m31())&&isFinite(this.m32())&&isFinite(this.m33())}getTranslation(){return new As(this.m03(),this.m13(),this.m23())}get translation(){return this.getTranslation()}getScaleVector(){var t=this.m00()+this.m03(),e=this.m10()+this.m13(),i=this.m20()+this.m23(),s=this.m30()+this.m33(),n=this.m01()+this.m03(),r=this.m11()+this.m13(),a=this.m21()+this.m23(),o=this.m31()+this.m33(),h=this.m02()+this.m03(),l=this.m12()+this.m13(),d=this.m22()+this.m23(),u=this.m32()+this.m33();return new As(Math.sqrt(t*t+e*e+i*i+s*s),Math.sqrt(n*n+r*r+a*a+o*o),Math.sqrt(h*h+l*l+d*d+u*u))}get scaleVector(){return this.getScaleVector()}getCSSTransform(){return"matrix3d(".concat(this.entries[0].toFixed(20),",").concat(this.entries[1].toFixed(20),",").concat(this.entries[2].toFixed(20),",").concat(this.entries[3].toFixed(20),",").concat(this.entries[4].toFixed(20),",").concat(this.entries[5].toFixed(20),",").concat(this.entries[6].toFixed(20),",").concat(this.entries[7].toFixed(20),",").concat(this.entries[8].toFixed(20),",").concat(this.entries[9].toFixed(20),",").concat(this.entries[10].toFixed(20),",").concat(this.entries[11].toFixed(20),",").concat(this.entries[12].toFixed(20),",").concat(this.entries[13].toFixed(20),",").concat(this.entries[14].toFixed(20),",").concat(this.entries[15].toFixed(20),")")}get cssTransform(){return this.getCSSTransform()}equals(t){return this.m00()===t.m00()&&this.m01()===t.m01()&&this.m02()===t.m02()&&this.m03()===t.m03()&&this.m10()===t.m10()&&this.m11()===t.m11()&&this.m12()===t.m12()&&this.m13()===t.m13()&&this.m20()===t.m20()&&this.m21()===t.m21()&&this.m22()===t.m22()&&this.m23()===t.m23()&&this.m30()===t.m30()&&this.m31()===t.m31()&&this.m32()===t.m32()&&this.m33()===t.m33()}equalsEpsilon(t,e){return Math.abs(this.m00()-t.m00()).9999){var a=new As(i.x>0?i.x:-i.x,i.y>0?i.y:-i.y,i.z>0?i.z:-i.z),o=(a=a.xwn.toStateObject(t),fromStateObject:wn.fromStateObject,stateSchema:{entries:Wt(Ee),type:dt(Pn)}});class Sn{constructor(t,e){this.position=t,this.direction=e}shifted(t){return new Sn(this.pointAtDistance(t),this.direction)}pointAtDistance(t){return this.position.plus(this.direction.timesScalar(t))}toString(){return"".concat(this.position.toString()," => ").concat(this.direction.toString())}}De.register("Ray2",Sn);var An=new wn;class En{constructor(t){this.matrix=wn.IDENTITY.copy(),this.inverse=wn.IDENTITY.copy(),this.matrixTransposed=wn.IDENTITY.copy(),this.inverseTransposed=wn.IDENTITY.copy(),this.inverseValid=!0,this.transposeValid=!0,this.inverseTransposeValid=!0,this.changeEmitter=new c,t&&this.setMatrix(t)}setMatrix(t){this.matrix.set(t),this.invalidate()}validateMatrix(t){}invalidate(){this.inverseValid=!1,this.transposeValid=!1,this.inverseTransposeValid=!1,this.changeEmitter.emit()}prepend(t){An.set(this.matrix),this.matrix.set(t),this.matrix.multiplyMatrix(An),this.invalidate()}prependTranslation(t,e){this.matrix.prependTranslation(t,e),this.invalidate()}append(t){this.matrix.multiplyMatrix(t),this.invalidate()}prependTransform(t){this.prepend(t.matrix)}appendTransform(t){this.append(t.matrix)}applyToCanvasContext(t){t.setTransform(this.matrix.m00(),this.matrix.m10(),this.matrix.m01(),this.matrix.m11(),this.matrix.m02(),this.matrix.m12())}copy(){var t=new En(this.matrix);t.inverse=this.inverse,t.matrixTransposed=this.matrixTransposed,t.inverseTransposed=this.inverseTransposed,t.inverseValid=this.inverseValid,t.transposeValid=this.transposeValid,t.inverseTransposeValid=this.inverseTransposeValid}getMatrix(){return this.matrix}getInverse(){return this.inverseValid||(this.inverseValid=!0,this.inverse.set(this.matrix),this.inverse.invert()),this.inverse}getMatrixTransposed(){return this.transposeValid||(this.transposeValid=!0,this.matrixTransposed.set(this.matrix),this.matrixTransposed.transpose()),this.matrixTransposed}getInverseTransposed(){return this.inverseTransposeValid||(this.inverseTransposeValid=!0,this.inverseTransposed.set(this.getInverse()),this.inverseTransposed.transpose()),this.inverseTransposed}isIdentity(){return this.matrix.isFastIdentity()}isFinite(){return this.matrix.isFinite()}transformPosition2(t){return this.matrix.timesVector2(t)}transformDelta2(t){var e=this.getMatrix();return new Is(e.m00()*t.x+e.m01()*t.y,e.m10()*t.x+e.m11()*t.y)}transformNormal2(t){return this.getInverse().timesTransposeVector2(t).normalize()}transformX(t){var e=this.getMatrix();return e.m00()*t+e.m02()}transformY(t){var e=this.getMatrix();return e.m11()*t+e.m12()}transformDeltaX(t){return this.getMatrix().m00()*t}transformDeltaY(t){return this.getMatrix().m11()*t}transformBounds2(t){return t.transformed(this.matrix)}transformShape(t){return t.transformed(this.matrix)}transformRay2(t){return new Sn(this.transformPosition2(t.position),this.transformDelta2(t.direction).normalized())}inversePosition2(t){return this.getInverse().timesVector2(t)}inverseDelta2(t){var e=this.getInverse();return new Is(e.m00()*t.x+e.m01()*t.y,e.m10()*t.x+e.m11()*t.y)}inverseNormal2(t){return this.matrix.timesTransposeVector2(t).normalize()}inverseX(t){var e=this.getInverse();return e.m00()*t+e.m02()}inverseY(t){var e=this.getInverse();return e.m11()*t+e.m12()}inverseDeltaX(t){var e=this.getInverse();return e.m00()*t}inverseDeltaY(t){var e=this.getInverse();return e.m11()*t}inverseBounds2(t){return t.transformed(this.getInverse())}inverseShape(t){return t.transformed(this.getInverse())}inverseRay2(t){return new Sn(this.inversePosition2(t.position),this.inverseDelta2(t.direction).normalized())}}De.register("Transform3",En);var Cn=En;function Dn(t,e){return new Is(t,e)}var In,Ln=Js.transform,kn=Js.transformOrigin||"transformOrigin",Mn=!0,On={prepareForTransform(t){t.style[kn]="top left"},applyPreparedTransform(t,e){e.style[Ln]=t.getCSSTransform()},setTransform(t,e){e.style[Ln]=t},unsetTransform(t){t.style[Ln]=""},polyfillRequestAnimationFrame(){window.requestAnimationFrame&&window.cancelAnimationFrame||(Js.requestAnimationFrame&&Js.cancelAnimationFrame?(window.requestAnimationFrame=window[Js.requestAnimationFrame],window.cancelAnimationFrame=window[Js.cancelAnimationFrame]):(window.requestAnimationFrame=t=>{var e=Date.now();return window.setTimeout(()=>{t(Date.now()-e)},16)},window.cancelAnimationFrame=clearTimeout))},backingStorePixelRatio:t=>t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,backingScale(t){if("devicePixelRatio"in window){var e=On.backingStorePixelRatio(t);return window.devicePixelRatio/e}return 1},supportsNativeCanvasFilter:()=>!!Js.canvasFilter,supportsImageDataCanvasFilter:()=>1===On.backingStorePixelRatio(bs.scratchContext),scanBounds(t,e,i){for(var s=_.map(_.range(e),()=>!1),n=_.map(_.range(e),()=>!1),r=0;r=e-1?Number.POSITIVE_INFINITY:i.inversePosition2(Dn(h+1+c,0)).x,d<1||d>=e-1?Number.POSITIVE_INFINITY:i.inversePosition2(Dn(0,d+1+c)).y,l<1||l>=e-1?Number.NEGATIVE_INFINITY:i.inversePosition2(Dn(l-c,0)).x,u<1||u>=e-1?Number.NEGATIVE_INFINITY:i.inversePosition2(Dn(0,u-c)).y),maxBounds:new mn(h<1||h>=e-1?Number.NEGATIVE_INFINITY:i.inversePosition2(Dn(h-1-c,0)).x,d<1||d>=e-1?Number.NEGATIVE_INFINITY:i.inversePosition2(Dn(0,d-1-c)).y,l<1||l>=e-1?Number.POSITIVE_INFINITY:i.inversePosition2(Dn(l+2+c,0)).x,u<1||u>=e-1?Number.POSITIVE_INFINITY:i.inversePosition2(Dn(0,u+2+c)).y)}},canvasAccurateBounds(t,e){var i=e&&e.precision?e.precision:.001,s=e&&e.resolution?e.resolution:128,n=e&&e.initialScale?e.initialScale:1/16,r=mn.NOTHING,a=mn.EVERYTHING,o=document.createElement("canvas");o.width=s,o.height=s;var h=o.getContext("2d");function l(e){h.save(),e.matrix.canvasSetTransform(h),t(h),h.restore();var i=h.getImageData(0,0,s,s),n=On.scanBounds(i,s,e);return h.clearRect(0,0,s,s),n}function d(t){var e=(s-4)/(t.maxX-t.minX),i=(s-4)/(t.maxY-t.minY),n=-e*t.minX+2,r=-i*t.minY+2;return new Cn(wn.translation(n,r).timesMatrix(wn.scaling(e,i)))}var u=new Cn;u.append(wn.translation(s/2,s/2)),u.append(wn.scaling(n));var c,m,p,g=l(u);for(r=r.union(g.minBounds),c=(a=a.intersection(g.maxBounds)).minY,m=a.maxY;isFinite(r.minX)&&isFinite(a.minX)&&Math.abs(r.minX-a.minX)>i;){if(p=l(d(new mn(a.minX,c,r.minX,m))),r.minX<=p.minBounds.minX&&a.minX>=p.maxBounds.minX){0;break}r=r.withMinX(Math.min(r.minX,p.minBounds.minX)),a=a.withMinX(Math.max(a.minX,p.maxBounds.minX)),c=Math.max(c,p.maxBounds.minY),m=Math.min(m,p.maxBounds.maxY)}for(c=a.minY,m=a.maxY;isFinite(r.maxX)&&isFinite(a.maxX)&&Math.abs(r.maxX-a.maxX)>i;){if(p=l(d(new mn(r.maxX,c,a.maxX,m))),r.maxX>=p.minBounds.maxX&&a.maxX<=p.maxBounds.maxX){0;break}r=r.withMaxX(Math.max(r.maxX,p.minBounds.maxX)),a=a.withMaxX(Math.min(a.maxX,p.maxBounds.maxX)),c=Math.max(c,p.maxBounds.minY),m=Math.min(m,p.maxBounds.maxY)}for(c=a.minX,m=a.maxX;isFinite(r.minY)&&isFinite(a.minY)&&Math.abs(r.minY-a.minY)>i;){if(p=l(d(new mn(c,a.minY,m,r.minY))),r.minY<=p.minBounds.minY&&a.minY>=p.maxBounds.minY){0;break}r=r.withMinY(Math.min(r.minY,p.minBounds.minY)),a=a.withMinY(Math.max(a.minY,p.maxBounds.minY)),c=Math.max(c,p.maxBounds.minX),m=Math.min(m,p.maxBounds.maxX)}for(c=a.minX,m=a.maxX;isFinite(r.maxY)&&isFinite(a.maxY)&&Math.abs(r.maxY-a.maxY)>i;){if(p=l(d(new mn(c,r.maxY,m,a.maxY))),r.maxY>=p.minBounds.maxY&&a.maxY<=p.maxBounds.maxY){0;break}r=r.withMaxY(Math.max(r.maxY,p.minBounds.maxY)),a=a.withMaxY(Math.min(a.maxY,p.maxBounds.maxY)),c=Math.max(c,p.maxBounds.minX),m=Math.min(m,p.maxBounds.maxX)}var v=new mn(isFinite(r.minX)&&isFinite(a.minX)?(r.minX+a.minX)/2:Number.POSITIVE_INFINITY,isFinite(r.minY)&&isFinite(a.minY)?(r.minY+a.minY)/2:Number.POSITIVE_INFINITY,isFinite(r.maxX)&&isFinite(a.maxX)?(r.maxX+a.maxX)/2:Number.NEGATIVE_INFINITY,isFinite(r.maxY)&&isFinite(a.maxY)?(r.maxY+a.maxY)/2:Number.NEGATIVE_INFINITY);return v.minBounds=r,v.maxBounds=a,v.isConsistent=a.containsBounds(r),v.precision=Math.max(Math.abs(r.minX-a.minX),Math.abs(r.minY-a.minY),Math.abs(r.maxX-a.maxX),Math.abs(r.maxY-a.maxY)),v},toPowerOf2(t){for(var e=1;e{e.restoreContext()},1e3))},safariEmbeddingMarkWorkaround:t=>Yi.safari?t.split("").join("​"):t};bs.register("Utils",On);var Rn=On;class Nn{constructor(t,e){this.display=t,this.trail=e}}Nn.FocusIO=new j("FocusIO",{valueType:Nn,documentation:"A IO Type for the instance in the simulation which currently has keyboard focus. FocusIO is serialized into and Object with key `focusedPhetioElement` that is a list of PhET-iO elements, from parent-most to child-most corresponding to the PhET-iO element that was instrumented.",toStateObject:t=>{var e=[];return t.trail.nodes.forEach((t,i)=>{t.isPhetioInstrumented()&&e.push(t.tandem.phetioID)}),{focusedPhetioElement:e}},stateSchema:{focusedPhetioElement:Wt(It)}}),bs.register("Focus",Nn);var Bn=Nn,Fn=["ArrowRight","ArrowLeft","ArrowUp","ArrowDown"],Vn=["KeyW","KeyS","KeyA","KeyD"],Hn=["Digit0","Digit1","Digit2","Digit3","Digit4","Digit5","Digit6","Digit7","Digit8","Digit9"],Yn=["ShiftLeft","ShiftRight"],zn=["ControlLeft","ControlRight"],Wn=["AltLeft","AltRight"],Un={valueType:Event},Gn=[],Xn={KEY_SPACE:"Space",KEY_ENTER:"Enter",KEY_TAB:"Tab",KEY_RIGHT_ARROW:"ArrowRight",KEY_LEFT_ARROW:"ArrowLeft",KEY_UP_ARROW:"ArrowUp",KEY_DOWN_ARROW:"ArrowDown",KEY_SHIFT_LEFT:"ShiftLeft",KEY_SHIFT_RIGHT:"ShiftRight",KEY_ALT_LEFT:"AltLeft",KEY_ALT_RIGHT:"AltRight",KEY_CONTROL_LEFT:"ControlLeft",KEY_CONTROL_RIGHT:"ControlRight",KEY_ESCAPE:"Escape",KEY_DELETE:"Delete",KEY_BACKSPACE:"Backspace",KEY_PAGE_UP:"PageUp",KEY_PAGE_DOWN:"PageDown",KEY_END:"End",KEY_HOME:"Home",KEY_0:"Digit0",KEY_1:"Digit1",KEY_2:"Digit2",KEY_3:"Digit3",KEY_4:"Digit4",KEY_5:"Digit5",KEY_6:"Digit6",KEY_7:"Digit7",KEY_8:"Digit8",KEY_9:"Digit9",KEY_A:"KeyA",KEY_B:"KeyB",KEY_C:"KeyC",KEY_D:"KeyD",KEY_E:"KeyE",KEY_F:"KeyF",KEY_G:"KeyG",KEY_H:"KeyH",KEY_I:"KeyI",KEY_J:"KeyJ",KEY_K:"KeyK",KEY_L:"KeyL",KEY_M:"KeyM",KEY_N:"KeyN",KEY_O:"KeyO",KEY_P:"KeyP",KEY_Q:"KeyQ",KEY_R:"KeyR",KEY_S:"KeyS",KEY_T:"KeyT",KEY_U:"KeyU",KEY_V:"KeyV",KEY_W:"KeyW",KEY_X:"KeyX",KEY_Y:"KeyY",KEY_Z:"KeyZ",KEY_EQUALS:"Equal",KEY_PLUS:"Equal",KEY_MINUS:"Minus",ARROW_KEYS:Fn,WASD_KEYS:Vn,MOVEMENT_KEYS:Fn.concat(Vn),SHIFT_KEYS:Yn,CONTROL_KEYS:zn,ALT_KEYS:Wn,isArrowKey:t=>Xn.isAnyKeyEvent(t,Fn),isRangeKey:t=>Xn.isArrowKey(t)||Xn.isAnyKeyEvent(t,[Xn.KEY_PAGE_UP,Xn.KEY_PAGE_DOWN,Xn.KEY_HOME,Xn.KEY_END]),isNumberKey:t=>Xn.isAnyKeyEvent(t,Hn),getNumberFromCode:t=>Xn.isNumberKey(t)&&t instanceof KeyboardEvent?Number(t.code.replace("Digit","")):null,isShiftKey:t=>Xn.isAnyKeyEvent(t,Yn),isAltKey:t=>Xn.isAnyKeyEvent(t,Wn),isControlKey:t=>Xn.isAnyKeyEvent(t,zn),isWASDKey:t=>Xn.isAnyKeyEvent(t,Vn),isMovementKey:t=>Xn.isAnyKeyEvent(t,Xn.MOVEMENT_KEYS),isAnyKeyEvent(t,e){R(t,Un);var i=Xn.getEventCode(t);return!!i&&e.includes(i)},isKeyEvent:(t,e)=>Xn.getEventCode(t)===e,getEventCode:t=>t instanceof KeyboardEvent&&t.code?t.code:null,ALL_KEYS:Gn};for(var jn in Xn)Xn.hasOwnProperty(jn)&&"string"==typeof Xn[jn]&&Gn.push(Xn[jn]);bs.register("KeyboardUtils",Xn);var qn=Xn,Kn=t=>Object.getPrototypeOf(t)===Object.prototype,Zn=new j("ObjectLiteralIO",{documentation:"IO Type for object literals",isValidValue:Kn,supertype:K,stateSchema:W.asValue("object",{valueType:Object,isValidValue:Kn}),toStateObject:_.identity});S.register("ObjectLiteralIO",Zn);var Qn=Zn,Jn=new j("EventIO",{valueType:window.Event,documentation:"A DOM Event",toStateObject:t=>zu.serializeDomEvent(t),fromStateObject:t=>zu.deserializeDomEvent(t),stateSchema:()=>({pointerId:Kt(Ee),pointerType:Kt(It),clientX:Kt(Ee),clientY:Kt(Ee),ctrlKey:Kt(Q),shiftKey:Kt(Q),altKey:Kt(Q),metaKey:Kt(Q),button:Kt(Ee),relatedTarget:Kt(Qn),pageX:Kt(Ee),pageY:Kt(Ee),which:Kt(Ee),type:Kt(It),target:Kt(Qn),keyCode:Kt(Ee),key:Kt(It),deltaX:Kt(Ee),deltaY:Kt(Ee),deltaZ:Kt(Ee),deltaMode:Kt(Ee),charCode:Kt(Ee),scale:Kt(Ee)})});bs.register("EventIO",Jn);var $n=Jn,tr=document.createElement("style");tr.type="text/css",document.head.appendChild(tr);var er=document.styleSheets[document.styleSheets.length-1],ir={stylesheet:er,styleElement:tr,addRule(t){this.stylesheet.insertRule(t,0)}};bs.register("SceneryStyle",ir);var sr=ir;class nr{constructor(t,e){this.canvas=t,this.context=e,this.resetStyles()}resetStyles(){this.fillStyle=void 0,this.strokeStyle=void 0,this.lineWidth=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineDash=void 0,this.lineDashOffset=void 0,this.miterLimit=void 0,this.font=void 0,this.direction=void 0}setDimensions(t,e){this.canvas.width=t,this.canvas.height=e,this.resetStyles()}setFillStyle(t){t&&t instanceof ce&&(t=t.value),t&&t.getCanvasStyle&&(t=t.getCanvasStyle()),this.fillStyle!==t&&(this.fillStyle=t,this.context.fillStyle=t)}setStrokeStyle(t){t&&t instanceof ce&&(t=t.value),t&&t.getCanvasStyle&&(t=t.getCanvasStyle()),this.strokeStyle!==t&&(this.strokeStyle=t,this.context.strokeStyle=t)}setLineWidth(t){this.lineWidth!==t&&(this.lineWidth=t,this.context.lineWidth=t)}setLineCap(t){this.lineCap!==t&&(this.lineCap=t,this.context.lineCap=t)}setLineJoin(t){this.lineJoin!==t&&(this.lineJoin=t,this.context.lineJoin=t)}setMiterLimit(t){this.miterLimit!==t&&(this.miterLimit=t,this.context.miterLimit=t)}setLineDash(t){this.lineDash!==t&&(this.lineDash=t,this.context.setLineDash?this.context.setLineDash(null===t?[]:t):void 0!==this.context.mozDash?this.context.mozDash=t:void 0!==this.context.webkitLineDash&&(this.context.webkitLineDash=t||[]))}setLineDashOffset(t){this.lineDashOffset!==t&&(this.lineDashOffset=t,void 0!==this.context.lineDashOffset?this.context.lineDashOffset=t:void 0!==this.context.webkitLineDashOffset&&(this.context.webkitLineDashOffset=t))}setFont(t){this.font!==t&&(this.font=t,this.context.font=t)}setDirection(t){this.direction!==t&&(this.direction=t,this.context.direction=t)}}bs.register("CanvasContextWrapper",nr);var rr=nr,ar=hi(document,"exitFullscreen")||hi(document,"cancelFullScreen"),or=hi(document,"fullscreenElement")||hi(document,"fullScreenElement"),hr=hi(document,"fullscreenEnabled")||hi(document,"fullScreenEnabled"),lr=di(document,"fullscreenchange");"msfullscreenchange"===lr&&(lr="MSFullscreenChange");var dr={isFullScreen:()=>!!document[or],isFullScreenEnabled:()=>document[hr]&&!Yi.safari7,enterFullScreen(t){var e=hi(document.body,"requestFullscreen")||hi(document.body,"requestFullScreen");t.domElement[e]&&t.domElement[e]()},exitFullScreen(){document[ar]&&document[ar]()},toggleFullScreen(t){dr.isFullScreen()?dr.exitFullScreen():dr.enterFullScreen(t)},isFullScreenProperty:new me(!1)};document.addEventListener(lr,t=>{dr.isFullScreenProperty.set(dr.isFullScreen())}),bs.register("FullScreen",dr);var ur=dr;class cr{constructor(t,e){this.create=t,this.destroy=e,this.map=new Map}increment(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.map.has(t))this.map.get(t).count+=e;else{var i=this.create(t),s=mr.createFromPool(e,t,i);this.map.set(t,s)}}decrement(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=this.map.get(t);i&&(i.count-=e,i.count<1&&(this.destroy(t,i.value),this.map.delete(t),i.dispose()))}get(t){return this.map.get(t).value}clear(){this.map.clear()}}class mr{constructor(t,e,i){this.initialize(t,e,i)}initialize(t,e,i){this.count=t,this.key=e,this.value=i}dispose(){this.key=null,this.value=null,this.freeToPool()}}Ui.mixInto(mr,{initialize:mr.prototype.initialize}),bs.register("CountMap",cr);var pr=cr;class gr extends pe{constructor(t,e){super(!1,e=b({display:null},e)),this.node=t,this.display=e.display,this.updateListener=this.updateValue.bind(this),this.changedInstanceListener=this.changedInstance.bind(this),t.changedInstanceEmitter.addListener(this.changedInstanceListener);for(var i=t.instances,s=0;s{var e=this.toDataURL();this.img.onload=()=>{t(),delete this.img.onload},this.img.src=e})}}bs.register("SceneImage",vr);var fr=new pe(!(null!==(t=window)&&void 0!==t&&null!==(e=t.phet)&&void 0!==e&&null!==(s=e.chipper)&&void 0!==s&&s.queryParameters)||(null===(n=window)||void 0===n||null===(r=n.phet)||void 0===r||null===(a=r.chipper)||void 0===a||null===(o=a.queryParameters)||void 0===o?void 0:o.allowLinks),{tandem:Ct.GENERAL_MODEL.createTandem("allowLinksProperty")});bs.register("allowLinksProperty",fr);var yr=fr;function br(t){if(yr.value){var e=window.open(t,"_blank");e&&e.focus()}}bs.register("openPopup",br);var _r=br,Pr=new d("kite"),wr=Vs.lineLineIntersection,xr={lineWidth:1,lineCap:"butt",lineJoin:"miter",lineDash:[],lineDashOffset:0,miterLimit:10};class Tr{constructor(t){var e=b({},xr,t);this.lineWidth=e.lineWidth,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineDash=e.lineDash,this.lineDashOffset=e.lineDashOffset,this.miterLimit=e.miterLimit}equals(t){if(!(this.lineWidth===t.lineWidth&&this.lineCap===t.lineCap&&this.lineJoin===t.lineJoin&&this.miterLimit===t.miterLimit&&this.lineDashOffset===t.lineDashOffset))return!1;if(this.lineDash.length!==t.lineDash.length)return!1;for(var e=0;e1e-12))return h;switch(this.lineJoin){case"round":return s=e.angle+Math.PI/2,n=i.angle+Math.PI/2,[new Zr(t,this.lineWidth/2,s,n,!0)];case"miter":if(r=e.angleBetween(i.negated()),1/Math.sin(r/2)<=this.miterLimit&&r1&&(n=1,i=this.applyInverse(n)),n<0&&(n=0,i=this.applyInverse(n)),r>1&&(r=1,s=this.applyInverse(r)),r<0&&(r=0,s=this.applyInverse(r)),this.t0=i,this.t1=s,t>0?(this.qt0=n,this.qt1=r):(this.qt0=r,this.qt1=n),this.t0<0&&this.t0>-1e-8&&(this.t0=0),this.t0>1&&this.t0<1+1e-8&&(this.t0=1),this.t1<0&&this.t1>-1e-8&&(this.t1=0),this.t1>1&&this.t1<1+1e-8&&(this.t1=1),this.qt0<0&&this.qt0>-1e-8&&(this.qt0=0),this.qt0>1&&this.qt0<1+1e-8&&(this.qt0=1),this.qt1<0&&this.qt1>-1e-8&&(this.qt1=0),this.qt1>1&&this.qt1<1+1e-8&&(this.qt1=1)}apply(t){return this.a*t+this.b}applyInverse(t){return(t-this.b)/this.a}static createLinear(t,e,i,s){var n=(s-e)/(i-t);return new Sr(n,e-t*n)}}Pr.register("Overlap",Sr);class Ar{constructor(t,e,i,s,n){this.point=e,this.normal=i,this.distance=t,this.wind=s,this.t=Vs.clamp(n,0,1)}}Pr.register("RayIntersection",Ar);class Er{constructor(t,e,i){this.point=t,this.aT=Vs.clamp(e,0,1),this.bT=Vs.clamp(i,0,1)}getSwapped(){return new Er(this.point,this.bT,this.aT)}}Pr.register("SegmentIntersection",Er);var Cr=t=>t.toFixed(20);Pr.register("svgNumber",Cr);var Dr=Cr;function Ir(t){return'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var Lr={parse:function(t,e){var i={svgPath:function(){var t,e,i,n,r,a;r=s,a=s,t=[],e=X();for(;null!==e;)t.push(e),e=X();if(null!==t)if(null!==(e=null!==(e=o())?e:"")){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i?t=[t,e,i]:(t=null,s=a)}else t=null,s=a;else t=null,s=a;null!==t&&(h=t[1],t=h||[]);var h;null===t&&(s=r);return t},movetoDrawtoCommandGroups:o,movetoDrawtoCommandGroup:h,drawtoCommands:l,drawtoCommand:d,moveto:u,movetoArgumentSequence:c,closepath:m,lineto:p,linetoArgumentSequence:g,horizontalLineto:v,horizontalLinetoArgumentSequence:f,verticalLineto:y,verticalLinetoArgumentSequence:b,curveto:_,curvetoArgumentSequence:P,curvetoArgument:w,smoothCurveto:x,smoothCurvetoArgumentSequence:T,smoothCurvetoArgument:S,quadraticBezierCurveto:A,quadraticBezierCurvetoArgumentSequence:E,quadraticBezierCurvetoArgument:C,smoothQuadraticBezierCurveto:D,smoothQuadraticBezierCurvetoArgumentSequence:I,ellipticalArc:L,ellipticalArcArgumentSequence:k,ellipticalArcArgument:M,coordinatePair:O,nonnegativeNumber:R,number:N,flag:B,commaWsp:F,comma:V,floatingPointConstant:H,fractionalConstant:Y,exponent:z,sign:W,digitSequence:U,digit:G,wsp:X};if(void 0!==e){if(void 0===i[e])throw new Error("Invalid rule name: "+Ir(e)+".")}else e="svgPath";var s=0,n=0,r=[];function a(t){sn&&(n=s,r=[]),r.push(t))}function o(){var t,e,i,n,r,a,l;if(n=s,r=s,null!==(t=h())){for(e=[],i=X();null!==i;)e.push(i),i=X();null!==e&&null!==(i=o())?t=[t,e,i]:(t=null,s=r)}else t=null,s=r;return null!==t&&(a=t[0],l=t[2],t=a.concat(l)),null===t&&(s=n),null===t&&(n=s,null!==(t=h())&&(t=function(t,e){return e}(0,t)),null===t&&(s=n)),t}function h(){var t,e,i,n,r,a,o;if(n=s,r=s,null!==(t=u())){for(e=[],i=X();null!==i;)e.push(i),i=X();null!==e&&null!==(i=null!==(i=l())?i:"")?t=[t,e,i]:(t=null,s=r)}else t=null,s=r;return null!==t&&(a=t[0],t=(o=t[2]).length?a.concat(o):a),null===t&&(s=n),t}function l(){var t,e,i,n,r,a,o;if(n=s,r=s,null!==(t=d())){for(e=[],i=X();null!==i;)e.push(i),i=X();null!==e&&null!==(i=l())?t=[t,e,i]:(t=null,s=r)}else t=null,s=r;return null!==t&&(a=t[0],o=t[2],t=a.concat(o)),null===t&&(s=n),null===t&&(n=s,null!==(t=d())&&(t=function(t,e){return e}(0,t)),null===t&&(s=n)),t}function d(){var t;return null===(t=m())&&null===(t=p())&&null===(t=v())&&null===(t=y())&&null===(t=_())&&null===(t=x())&&null===(t=A())&&null===(t=D())&&(t=L()),t}function u(){var e,i,n,r,o;if(r=s,o=s,77===t.charCodeAt(s)?(e="M",s++):(e=null,a('"M"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=c())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;if(null!==e&&(e=j(e[2],!1)),null===e&&(s=r),null===e){if(r=s,o=s,109===t.charCodeAt(s)?(e="m",s++):(e=null,a('"m"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=c())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;null!==e&&(e=function(t,e){return j(e,!0)}(0,e[2])),null===e&&(s=r)}return e}function c(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=O())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=g())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a].concat(o)),null===t&&(s=n),null===t&&(n=s,null!==(t=O())&&(t=function(t,e){return[e]}(0,t)),null===t&&(s=n)),t}function m(){var e,i;return i=s,90===t.charCodeAt(s)?(e="Z",s++):(e=null,a('"Z"')),null===e&&(122===t.charCodeAt(s)?(e="z",s++):(e=null,a('"z"'))),null!==e&&(e={cmd:"close"}),null===e&&(s=i),e}function p(){var e,i,n,r,o;if(r=s,o=s,76===t.charCodeAt(s)?(e="L",s++):(e=null,a('"L"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=g())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;if(null!==e&&(e=e[2].map((function(t){return{cmd:"lineTo",args:[t.x,t.y]}}))),null===e&&(s=r),null===e){if(r=s,o=s,108===t.charCodeAt(s)?(e="l",s++):(e=null,a('"l"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=g())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;null!==e&&(e=function(t,e){return e.map((function(t){return{cmd:"lineToRelative",args:[t.x,t.y]}}))}(0,e[2])),null===e&&(s=r)}return e}function g(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=O())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=g())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a].concat(o)),null===t&&(s=n),null===t&&(n=s,null!==(t=O())&&(t=function(t,e){return[e]}(0,t)),null===t&&(s=n)),t}function v(){var e,i,n,r,o;if(r=s,o=s,72===t.charCodeAt(s)?(e="H",s++):(e=null,a('"H"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=f())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;if(null!==e&&(e=e[2].map((function(t){return{cmd:"horizontalLineTo",args:[t]}}))),null===e&&(s=r),null===e){if(r=s,o=s,104===t.charCodeAt(s)?(e="h",s++):(e=null,a('"h"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=f())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;null!==e&&(e=function(t,e){return e.map((function(t){return{cmd:"horizontalLineToRelative",args:[t]}}))}(0,e[2])),null===e&&(s=r)}return e}function f(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=N())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=f())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a].concat(o)),null===t&&(s=n),null===t&&(n=s,null!==(t=N())&&(t=function(t,e){return[e]}(0,t)),null===t&&(s=n)),t}function y(){var e,i,n,r,o;if(r=s,o=s,86===t.charCodeAt(s)?(e="V",s++):(e=null,a('"V"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=b())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;if(null!==e&&(e=e[2].map((function(t){return{cmd:"verticalLineTo",args:[t]}}))),null===e&&(s=r),null===e){if(r=s,o=s,118===t.charCodeAt(s)?(e="v",s++):(e=null,a('"v"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=b())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;null!==e&&(e=function(t,e){return e.map((function(t){return{cmd:"verticalLineToRelative",args:[t]}}))}(0,e[2])),null===e&&(s=r)}return e}function b(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=N())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=b())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a].concat(o)),null===t&&(s=n),null===t&&(n=s,null!==(t=N())&&(t=function(t,e){return[e]}(0,t)),null===t&&(s=n)),t}function _(){var e,i,n,r,o;if(r=s,o=s,67===t.charCodeAt(s)?(e="C",s++):(e=null,a('"C"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=P())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;if(null!==e&&(e=e[2].map((function(t){return{cmd:"cubicCurveTo",args:t}}))),null===e&&(s=r),null===e){if(r=s,o=s,99===t.charCodeAt(s)?(e="c",s++):(e=null,a('"c"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=P())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;null!==e&&(e=function(t,e){return e.map((function(t){return{cmd:"cubicCurveToRelative",args:t}}))}(0,e[2])),null===e&&(s=r)}return e}function P(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=w())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=P())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a].concat(o)),null===t&&(s=n),null===t&&(n=s,null!==(t=w())&&(t=function(t,e){return[e]}(0,t)),null===t&&(s=n)),t}function w(){var t,e,i,n,r,a,o,h,l,d;return a=s,o=s,null!==(t=O())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=O())&&null!==(n=null!==(n=F())?n:"")&&null!==(r=O())?t=[t,e,i,n,r]:(t=null,s=o),null!==t&&(h=t[0],l=t[2],d=t[4],t=[h.x,h.y,l.x,l.y,d.x,d.y]),null===t&&(s=a),t}function x(){var e,i,n,r,o;if(r=s,o=s,83===t.charCodeAt(s)?(e="S",s++):(e=null,a('"S"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=T())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;if(null!==e&&(e=e[2].map((function(t){return{cmd:"smoothCubicCurveTo",args:t}}))),null===e&&(s=r),null===e){if(r=s,o=s,115===t.charCodeAt(s)?(e="s",s++):(e=null,a('"s"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=T())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;null!==e&&(e=function(t,e){return e.map((function(t){return{cmd:"smoothCubicCurveToRelative",args:t}}))}(0,e[2])),null===e&&(s=r)}return e}function T(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=S())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=T())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a].concat(o)),null===t&&(s=n),null===t&&(n=s,null!==(t=S())&&(t=function(t,e){return[e]}(0,t)),null===t&&(s=n)),t}function S(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=O())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=O())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a.x,a.y,o.x,o.y]),null===t&&(s=n),t}function A(){var e,i,n,r,o;if(r=s,o=s,81===t.charCodeAt(s)?(e="Q",s++):(e=null,a('"Q"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=E())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;if(null!==e&&(e=e[2].map((function(t){return{cmd:"quadraticCurveTo",args:t}}))),null===e&&(s=r),null===e){if(r=s,o=s,113===t.charCodeAt(s)?(e="q",s++):(e=null,a('"q"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=E())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;null!==e&&(e=function(t,e){return e.map((function(t){return{cmd:"quadraticCurveToRelative",args:t}}))}(0,e[2])),null===e&&(s=r)}return e}function E(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=C())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=E())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a].concat(o)),null===t&&(s=n),null===t&&(n=s,null!==(t=C())&&(t=function(t,e){return[e]}(0,t)),null===t&&(s=n)),t}function C(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=O())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=O())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a.x,a.y,o.x,o.y]),null===t&&(s=n),t}function D(){var e,i,n,r,o;if(r=s,o=s,84===t.charCodeAt(s)?(e="T",s++):(e=null,a('"T"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=I())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;if(null!==e&&(e=e[2].map((function(t){return{cmd:"smoothQuadraticCurveTo",args:[t.x,t.y]}}))),null===e&&(s=r),null===e){if(r=s,o=s,116===t.charCodeAt(s)?(e="t",s++):(e=null,a('"t"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=I())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;null!==e&&(e=function(t,e){return e.map((function(t){return{cmd:"smoothQuadraticCurveToRelative",args:[t.x,t.y]}}))}(0,e[2])),null===e&&(s=r)}return e}function I(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=O())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=I())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a].concat(o)),null===t&&(s=n),null===t&&(n=s,null!==(t=O())&&(t=function(t,e){return[e]}(0,t)),null===t&&(s=n)),t}function L(){var e,i,n,r,o;if(r=s,o=s,65===t.charCodeAt(s)?(e="A",s++):(e=null,a('"A"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=k())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;if(null!==e&&(e=e[2].map((function(t){return t[2]*=Math.PI/180,{cmd:"ellipticalArcTo",args:t}}))),null===e&&(s=r),null===e){if(r=s,o=s,97===t.charCodeAt(s)?(e="a",s++):(e=null,a('"a"')),null!==e){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i&&null!==(n=k())?e=[e,i,n]:(e=null,s=o)}else e=null,s=o;null!==e&&(e=function(t,e){return e.map((function(t){return t[2]*=Math.PI/180,{cmd:"ellipticalArcToRelative",args:t}}))}(0,e[2])),null===e&&(s=r)}return e}function k(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=M())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=k())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t=[a].concat(o)),null===t&&(s=n),null===t&&(n=s,null!==(t=M())&&(t=function(t,e){return[e]}(0,t)),null===t&&(s=n)),t}function M(){var t,e,i,n,r,a,o,h,l,d,u,c,m,p,g,v,f,y,b;return c=s,m=s,null!==(t=R())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=R())&&null!==(n=null!==(n=F())?n:"")&&null!==(r=N())&&null!==(a=F())&&null!==(o=B())&&null!==(h=null!==(h=F())?h:"")&&null!==(l=B())&&null!==(d=null!==(d=F())?d:"")&&null!==(u=O())?t=[t,e,i,n,r,a,o,h,l,d,u]:(t=null,s=m),null!==t&&(p=t[0],g=t[2],v=t[4],f=t[6],y=t[8],b=t[10],t=[p,g,v,f,y,b.x,b.y]),null===t&&(s=c),t}function O(){var t,e,i,n,r,a,o;return n=s,r=s,null!==(t=N())&&null!==(e=null!==(e=F())?e:"")&&null!==(i=N())?t=[t,e,i]:(t=null,s=r),null!==t&&(a=t[0],o=t[2],t={x:a,y:o}),null===t&&(s=n),t}function R(){var t,e;return e=s,null!==(t=H())&&(t=parseFloat(t)),null===t&&(s=e),null===t&&(e=s,null!==(t=U())&&(t=function(t,e){return Number(e)}(0,t)),null===t&&(s=e)),t}function N(){var t,e,i,n,r,a;return i=s,n=s,null!==(t=null!==(t=W())?t:"")&&null!==(e=H())?t=[t,e]:(t=null,s=n),null!==t&&(r=t[0],a=t[1],t=parseFloat(r+a)),null===t&&(s=i),null===t&&(i=s,n=s,null!==(t=null!==(t=W())?t:"")&&null!==(e=U())?t=[t,e]:(t=null,s=n),null!==t&&(t=function(t,e,i){return Number(e+i)}(0,t[0],t[1])),null===t&&(s=i)),t}function B(){var e,i;return i=s,48===t.charCodeAt(s)?(e="0",s++):(e=null,a('"0"')),null!==e&&(e=!1),null===e&&(s=i),null===e&&(i=s,49===t.charCodeAt(s)?(e="1",s++):(e=null,a('"1"')),null!==e&&(e=!0),null===e&&(s=i)),e}function F(){var t,e,i,n,r;if(r=s,null!==(e=X()))for(t=[];null!==e;)t.push(e),e=X();else t=null;if(null!==t)if(null!==(e=null!==(e=V())?e:"")){for(i=[],n=X();null!==n;)i.push(n),n=X();null!==i?t=[t,e,i]:(t=null,s=r)}else t=null,s=r;else t=null,s=r;if(null===t)if(r=s,null!==(t=V())){for(e=[],i=X();null!==i;)e.push(i),i=X();null!==e?t=[t,e]:(t=null,s=r)}else t=null,s=r;return t}function V(){var e;return 44===t.charCodeAt(s)?(e=",",s++):(e=null,a('","')),e}function H(){var t,e,i,n,r,a;return i=s,n=s,null!==(t=Y())&&null!==(e=null!==(e=z())?e:"")?t=[t,e]:(t=null,s=n),null!==t&&(r=t[0],a=t[1],t=r+a),null===t&&(s=i),null===t&&(i=s,n=s,null!==(t=U())&&null!==(e=z())?t=[t,e]:(t=null,s=n),null!==t&&(t=function(t,e,i){return e+i}(0,t[0],t[1])),null===t&&(s=i)),t}function Y(){var e,i,n,r,o,h,l;return r=s,o=s,null!==(e=null!==(e=U())?e:"")?(46===t.charCodeAt(s)?(i=".",s++):(i=null,a('"."')),null!==i&&null!==(n=U())?e=[e,i,n]:(e=null,s=o)):(e=null,s=o),null!==e&&(h=e[0],l=e[2],e=h+"."+l),null===e&&(s=r),null===e&&(r=s,o=s,null!==(e=U())?(46===t.charCodeAt(s)?(i=".",s++):(i=null,a('"."')),null!==i?e=[e,i]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=function(t,e){return e}(0,e[0])),null===e&&(s=r)),e}function z(){var e,i,n,r,o,h,l,d;return r=s,o=s,101===t.charCodeAt(s)?(e="e",s++):(e=null,a('"e"')),null===e&&(69===t.charCodeAt(s)?(e="E",s++):(e=null,a('"E"'))),null!==e&&null!==(i=null!==(i=W())?i:"")&&null!==(n=U())?e=[e,i,n]:(e=null,s=o),null!==e&&(h=e[0],l=e[1],d=e[2],e=h+l+d),null===e&&(s=r),e}function W(){var e;return 43===t.charCodeAt(s)?(e="+",s++):(e=null,a('"+"')),null===e&&(45===t.charCodeAt(s)?(e="-",s++):(e=null,a('"-"'))),e}function U(){var t,e,i,n,r,a;return i=s,n=s,null!==(t=G())&&null!==(e=U())?t=[t,e]:(t=null,s=n),null!==t&&(r=t[0],a=t[1],t=r+a),null===t&&(s=i),null===t&&(t=G()),t}function G(){var e;return/^[0-9]/.test(t.charAt(s))?(e=t.charAt(s),s++):(e=null,a("[0-9]")),e}function X(){var e;return 32===t.charCodeAt(s)?(e=" ",s++):(e=null,a('" "')),null===e&&(9===t.charCodeAt(s)?(e="\t",s++):(e=null,a('"\\t"')),null===e&&(13===t.charCodeAt(s)?(e="\r",s++):(e=null,a('"\\r"')),null===e&&(10===t.charCodeAt(s)?(e="\n",s++):(e=null,a('"\\n"'))))),e}function j(t,e){var i=[{cmd:e?"moveToRelative":"moveTo",args:[t[0].x,t[0].y]}];if(t.length>1)for(var s=1;s0&&(i=i.subdivided(Vs.linear(0,e,0,1,t))[1]),i}subdivisions(t){for(var e=this,i=[],s=0;s0;)e>=t[h]?(e-=t[h],u()):(l=e,e=0);var c=d;return function e(o,d,c,m,p){var g=(o+d)/2,v=n.positionAt(g);if(p>14||Mr.isSufficientlyFlat(i,s,c,v,m)){var f=c.distance(v)+v.distance(m);a+=f;for(var y=f;l+y>=t[h];){var b=Vs.linear(0,f,o,d,f-y+t[h]-l);r.push(b),y-=t[h]-l,l=0,u()}l+=y}else e(o,g,c,v,p+1),e(g,d,v,m,p+1)}(0,1,this.start,this.end,0),{values:r,arcLength:a,initiallyInside:c}}toPiecewiseLinearSegments(t,e,i,s,n,r){e=void 0===e?t.minLevels:e,i=void 0===i?t.maxLevels:i,s=s||[];var a=t.pointMap||_.identity;n=n||a(this.start),r=r||a(this.end);var o=a(this.positionAt(.5)),h=0===i;if(!h&&e<=0&&(h=this.isSufficientlyFlat(null===t.distanceEpsilon||void 0===t.distanceEpsilon?Number.POSITIVE_INFINITY:t.distanceEpsilon,null===t.curveEpsilon||void 0===t.curveEpsilon?Number.POSITIVE_INFINITY:t.curveEpsilon)),h)s.push(new Nr(n,r));else{var l=this.subdivided(.5);l[0].toPiecewiseLinearSegments(t,e-1,i-1,s,n,o),l[1].toPiecewiseLinearSegments(t,e-1,i-1,s,o,r)}return s}toPiecewiseLinearOrArcSegments(t){var e=w()({minLevels:2,maxLevels:7,curvatureThreshold:.02,errorThreshold:10,errorPoints:[.25,.75]},t),i=[];return this.toPiecewiseLinearOrArcRecursion(e,e.minLevels,e.maxLevels,i,0,1,this.positionAt(0),this.positionAt(1),this.curvatureAt(0),this.curvatureAt(1)),i}toPiecewiseLinearOrArcRecursion(t,e,i,s,n,r,a,o,h,l){var d=(n+r)/2,u=this.positionAt(d),c=this.curvatureAt(d);if(i<=0||e<=0&&Math.abs(h-c)+Math.abs(c-l)<2*t.curvatureThreshold){var m=Zr.createFromPoints(a,u,o),p=!1;if(m instanceof Zr)for(var g=m.radius*m.radius,v=0;vt.errorThreshold){p=!0;break}}if(!p)return void s.push(m)}this.toPiecewiseLinearOrArcRecursion(t,e-1,i-1,s,n,d,a,u,h,c),this.toPiecewiseLinearOrArcRecursion(t,e-1,i-1,s,d,r,u,o,c,l)}toShape(){return new aa([new ea([this])])}static closestToPoint(t,e,i){var s=i*i,n=[],r=[],a=Number.POSITIVE_INFINITY,o=!1;for(_.each(t,t=>{if(t instanceof Nr){var i=t.explicitClosestToPoint(e);_.each(i,t=>{t.distanceSquareda)){o&&l.pa.distanceSquared(l.pb)>s&&(o=!1);var d=(l.ta+l.tb)/2,u=l.segment.positionAt(d),c=mn.point(l.pa).addPoint(u),m=mn.point(l.pb).addPoint(u),p=c.minimumDistanceToPointSquared(e),g=m.minimumDistanceToPointSquared(e);if(p<=a){var v=c.maximumDistanceToPointSquared(e);v{var i=(t.ta+t.tb)/2,s=t.segment.positionAt(i);r.push({segment:t.segment,t:i,closestPoint:s,distanceSquared:e.distanceSquared(s)})}),r}static polynomialGetOverlapCubic(t,e,i,s,n,r,a,o){if(0===o)return Mr.polynomialGetOverlapQuadratic(t,e,i,n,r,a);var h=Math.sign(s/o)*Math.pow(Math.abs(s/o),1/3);return 0===h?null:{a:h,b:(i-h*h*a)/(3*h*h*o)}}static polynomialGetOverlapQuadratic(t,e,i,s,n,r){if(0===r)return Mr.polynomialGetOverlapLinear(t,e,s,n);if(i/r<0)return null;var a=Math.sqrt(i/r);return 0===a?null:{a:a,b:(e-a*n)/(2*a*r)}}static polynomialGetOverlapLinear(t,e,i,s){if(0===s)return t===i||null;var n=e/s;return 0===n?null:{a:n,b:(t-i)/s}}static intersect(t,e){return Nr&&t instanceof Nr&&e instanceof Nr?Nr.intersect(t,e):Nr&&t instanceof Nr?Nr.intersectOther(t,e):Nr&&e instanceof Nr?Nr.intersectOther(e,t).map(Or):Zr&&t instanceof Zr&&e instanceof Zr?Zr.intersect(t,e):Jr&&t instanceof Jr&&e instanceof Jr?Jr.intersect(t,e):Sa.intersect(t,e)}static deserialize(t){return Pr[t.type].deserialize(t)}static isSufficientlyFlat(t,e,i,s,n){return!(Vs.distToSegmentSquared(s,i,n)/i.distanceSquared(n)>e)&&!(Vs.distToSegmentSquared(s,i,n)>t)}}function Or(t){return t.getSwapped()}Pr.register("Segment",Mr);var Rr=new Is(0,0);class Nr extends Mr{constructor(t,e){super(),this._start=t,this._end=e,this.invalidate()}setStart(t){return this._start.equals(t)||(this._start=t,this.invalidate()),this}set start(t){this.setStart(t)}get start(){return this.getStart()}getStart(){return this._start}setEnd(t){return this._end.equals(t)||(this._end=t,this.invalidate()),this}set end(t){this.setEnd(t)}get end(){return this.getEnd()}getEnd(){return this._end}positionAt(t){return this._start.plus(this._end.minus(this._start).times(t))}tangentAt(t){return this.getStartTangent()}curvatureAt(t){return 0}subdivided(t){if(0===t||1===t)return[this];var e=this.positionAt(t);return[new Nr(this._start,e),new Nr(e,this._end)]}invalidate(){this._tangent=null,this._bounds=null,this._svgPathFragment=null,this.invalidationEmitter.emit()}getStartTangent(){return null===this._tangent&&(this._tangent=this._end.minus(this._start).normalized()),this._tangent}get startTangent(){return this.getStartTangent()}getEndTangent(){return this.getStartTangent()}get endTangent(){return this.getEndTangent()}getBounds(){return null===this._bounds&&(this._bounds=mn.NOTHING.copy().addPoint(this._start).addPoint(this._end)),this._bounds}get bounds(){return this.getBounds()}getBoundsWithTransform(t){var e=mn.NOTHING.copy();return e.addPoint(t.multiplyVector2(Rr.set(this._start))),e.addPoint(t.multiplyVector2(Rr.set(this._end))),e}getNondegenerateSegments(){return this._start.equals(this._end)?[]:[this]}getSVGPathFragment(){return this._svgPathFragment||(this._svgPathFragment="L ".concat(Dr(this._end.x)," ").concat(Dr(this._end.y))),this._svgPathFragment}strokeLeft(t){var e=this.getEndTangent().perpendicular.negated().times(t/2);return[new Nr(this._start.plus(e),this._end.plus(e))]}strokeRight(t){var e=this.getStartTangent().perpendicular.times(t/2);return[new Nr(this._end.plus(e),this._start.plus(e))]}getInteriorExtremaTs(){return[]}intersection(t){var e=[],i=this._start,s=this._end.minus(i);if(0===s.magnitudeSquared)return e;var n=t.direction.y*s.x-t.direction.x*s.y;if(0===n)return e;var r=(t.direction.x*(i.y-t.position.y)-t.direction.y*(i.x-t.position.x))/n;if(r<0||r>=1)return e;var a=(s.x*(i.y-t.position.y)-s.y*(i.x-t.position.x))/n;if(a<1e-8)return e;var o=s.perpendicular,h=i.plus(s.times(r)),l=(o.dot(t.direction)>0?o.negated():o).normalized(),d=t.direction.perpendicular.dot(s)<0?1:-1;return e.push(new Ar(a,h,l,d,r)),e}windingIntersection(t){var e=this.intersection(t);return e.length?e[0].wind:0}writeToContext(t){t.lineTo(this._end.x,this._end.y)}transformed(t){return new Nr(t.timesVector2(this._start),t.timesVector2(this._end))}explicitClosestToPoint(t){var e=this._end.minus(this._start),i=t.minus(this._start).dot(e)/e.magnitudeSquared;i=Vs.clamp(i,0,1);var s=this.positionAt(i);return[{segment:this,t:i,closestPoint:s,distanceSquared:t.distanceSquared(s)}]}getSignedAreaFragment(){return.5*(this._start.x*this._end.y-this._start.y*this._end.x)}reparameterized(t,e){return new Nr(this.positionAt(e),this.positionAt(t+e))}reversed(){return new Nr(this._end,this._start)}polarToCartesian(t){return this._start.x===this._end.x?[new Nr(Is.createPolar(this._start.y,this._start.x),Is.createPolar(this._end.y,this._end.x))]:this._start.y===this._end.y?[new Zr(Is.ZERO,this._start.y,this._start.x,this._end.x,this._start.x>this._end.x)]:this.toPiecewiseLinearSegments(t)}getArcLength(){return this.start.distance(this.end)}toPiecewiseLinearOrArcSegments(){return[this]}serialize(){return{type:"Line",startX:this._start.x,startY:this._start.y,endX:this._end.x,endY:this._end.y}}getOverlaps(t){return t instanceof Nr?Nr.getOverlaps(this,t):null}static deserialize(t){return new Nr(new Is(t.startX,t.startY),new Is(t.endX,t.endY))}static getOverlaps(t,e){var i,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-6,n=[],r=t._start.x,a=-1*t._start.x+t._end.x,o=t._start.y,h=-1*t._start.y+t._end.y,l=e._start.x,d=-1*e._start.x+e._end.x,u=e._start.y,c=-1*e._start.y+e._end.y,m=Math.abs(Math.max(t._start.x,t._end.x,e._start.x,e._end.x)-Math.min(t._start.x,t._end.x,e._start.x,e._end.x)),p=Math.abs(Math.max(t._start.y,t._end.y,e._start.y,e._end.y)-Math.min(t._start.y,t._end.y,e._start.y,e._end.y)),g=Mr.polynomialGetOverlapLinear(r,a,l,d),v=Mr.polynomialGetOverlapLinear(o,h,u,c);if(null===(i=m>p?null===g||!0===g?v:g:null===v||!0===v?g:v)||!0===i)return n;var f=i.a,y=i.b,b=l+y*d-r,_=f*d-a,P=u+y*c-o,w=f*c-h;if(Math.abs(b)>s||Math.abs(_+b)>s||Math.abs(P)>s||Math.abs(w+P)>s)return n;var x=f+y;return y>1&&x>1||y<0&&x<0?n:[new Sr(f,y)]}static intersect(t,e){var i=Vs.lineSegmentIntersection(t.start.x,t.start.y,t.end.x,t.end.y,e.start.x,e.start.y,e.end.x,e.end.y);if(null!==i){var s=t.explicitClosestToPoint(i)[0].t,n=e.explicitClosestToPoint(i)[0].t;return[new Er(i,s,n)]}return[]}static intersectOther(t,e){for(var i=t.end.minus(t.start),s=i.magnitude,n=new Sn(t.start,i.normalize()),r=e.intersection(n),a=[],o=0;o1e-8&&l<1-1e-8&&a.push(new Er(h.point,l,h.t))}return a}}Pr.register("Line",Nr);var Br=Vs.solveQuadraticRootsReal,Fr=Vs.arePointsCollinear;function Vr(t){return t>=0&&t<=1}class Hr extends Mr{constructor(t,e,i){super(),this._start=t,this._control=e,this._end=i,this.invalidate()}setStart(t){return this._start.equals(t)||(this._start=t,this.invalidate()),this}set start(t){this.setStart(t)}get start(){return this.getStart()}getStart(){return this._start}setControl(t){return this._control.equals(t)||(this._control=t,this.invalidate()),this}set control(t){this.setControl(t)}get control(){return this.getControl()}getControl(){return this._control}setEnd(t){return this._end.equals(t)||(this._end=t,this.invalidate()),this}set end(t){this.setEnd(t)}get end(){return this.getEnd()}getEnd(){return this._end}positionAt(t){var e=1-t;return this._start.times(e*e).plus(this._control.times(2*e*t)).plus(this._end.times(t*t))}tangentAt(t){return this._control.minus(this._start).times(2*(1-t)).plus(this._end.minus(this._control).times(2*t))}curvatureAt(t){if(Math.abs(t-.5)>.5-1e-7){var e=t<.5,i=e?this._start:this._end,s=this._control,n=e?this._end:this._start,r=s.minus(i),a=r.magnitude;return(e?-1:1)*r.perpendicular.normalized().dot(n.minus(s))*(this.degree-1)/(this.degree*a*a)}return this.subdivided(t)[0].curvatureAt(1)}subdivided(t){if(0===t||1===t)return[this];var e=this._start.blend(this._control,t),i=this._control.blend(this._end,t),s=e.blend(i,t);return[new Hr(this._start,e,s),new Hr(s,i,this._end)]}invalidate(){this._startTangent=null,this._endTangent=null,this._tCriticalX=null,this._tCriticalY=null,this._bounds=null,this._svgPathFragment=null,this.invalidationEmitter.emit()}getStartTangent(){if(null===this._startTangent){var t=this._start.equals(this._control);this._startTangent=t?this._end.minus(this._start).normalized():this._control.minus(this._start).normalized()}return this._startTangent}get startTangent(){return this.getStartTangent()}getEndTangent(){if(null===this._endTangent){var t=this._end.equals(this._control);this._endTangent=t?this._end.minus(this._start).normalized():this._end.minus(this._control).normalized()}return this._endTangent}get endTangent(){return this.getEndTangent()}getTCriticalX(){return null===this._tCriticalX&&(this._tCriticalX=Hr.extremaT(this._start.x,this._control.x,this._end.x)),this._tCriticalX}get tCriticalX(){return this.getTCriticalX()}getTCriticalY(){return null===this._tCriticalY&&(this._tCriticalY=Hr.extremaT(this._start.y,this._control.y,this._end.y)),this._tCriticalY}get tCriticalY(){return this.getTCriticalY()}getNondegenerateSegments(){var t=this._start,e=this._control,i=this._end,s=t.equals(i),n=t.equals(e),r=t.equals(e);if(s&&n)return[];if(s){var a=this.positionAt(.5);return[new Nr(t,a),new Nr(a,i)]}if(Fr(t,e,i)){if(n||r)return[new Nr(t,i)];var o=i.minus(t),h=e.minus(t).dot(o.normalized())/o.magnitude,l=Hr.extremaT(0,h,1);if(!isNaN(l)&&l>0&&l<1){var d=this.positionAt(l);return _.flatten([new Nr(t,d).getNondegenerateSegments(),new Nr(d,i).getNondegenerateSegments()])}return[new Nr(t,i)]}return[this]}getBounds(){if(null===this._bounds){this._bounds=new mn(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));var t=this.getTCriticalX(),e=this.getTCriticalY();!isNaN(t)&&t>0&&t<1&&(this._bounds=this._bounds.withPoint(this.positionAt(t))),!isNaN(e)&&e>0&&e<1&&(this._bounds=this._bounds.withPoint(this.positionAt(e)))}return this._bounds}get bounds(){return this.getBounds()}offsetTo(t,e){for(var i=[this],s=0;s<5;s++)i=_.flatten(_.map(i,t=>t.subdivided(.5)));var n=_.map(i,e=>e.approximateOffset(t));return e&&(n.reverse(),n=_.map(n,t=>t.reversed())),n}degreeElevated(){return new qr(this._start,this._start.plus(this._control.timesScalar(2)).dividedScalar(3),this._end.plus(this._control.timesScalar(2)).dividedScalar(3),this._end)}approximateOffset(t){return new Hr(this._start.plus((this._start.equals(this._control)?this._end.minus(this._start):this._control.minus(this._start)).perpendicular.normalized().times(t)),this._control.plus(this._end.minus(this._start).perpendicular.normalized().times(t)),this._end.plus((this._end.equals(this._control)?this._end.minus(this._start):this._end.minus(this._control)).perpendicular.normalized().times(t)))}getSVGPathFragment(){return this._svgPathFragment||(this._svgPathFragment="Q ".concat(Dr(this._control.x)," ").concat(Dr(this._control.y)," ").concat(Dr(this._end.x)," ").concat(Dr(this._end.y))),this._svgPathFragment}strokeLeft(t){return this.offsetTo(-t/2,!1)}strokeRight(t){return this.offsetTo(t/2,!0)}getInteriorExtremaTs(){var t=[],e=this.getTCriticalX(),i=this.getTCriticalY();return!isNaN(e)&&e>1e-10&&e<1-1e-10&&t.push(this.tCriticalX),!isNaN(i)&&i>1e-10&&i<1-1e-10&&t.push(this.tCriticalY),t.sort()}intersection(t){var e=[],i=wn.rotation2(-t.direction.angle).timesMatrix(wn.translation(-t.position.x,-t.position.y)),s=i.timesVector2(this._start),n=i.timesVector2(this._control),r=i.timesVector2(this._end),a=s.y-2*n.y+r.y,o=-2*s.y+2*n.y,h=s.y,l=Br(a,o,h);return _.each(l,i=>{if(i>=0&&i<=1){var s=this.positionAt(i),n=this.tangentAt(i).normalized(),r=n.perpendicular,a=s.minus(t.position);if(a.dot(t.direction)>0){var o=r.dot(t.direction)>0?r.negated():r,h=t.direction.perpendicular.dot(n)<0?1:-1;e.push(new Ar(a.magnitude,s,o,h,i))}}}),e}windingIntersection(t){var e=0,i=this.intersection(t);return _.each(i,t=>{e+=t.wind}),e}writeToContext(t){t.quadraticCurveTo(this._control.x,this._control.y,this._end.x,this._end.y)}transformed(t){return new Hr(t.timesVector2(this._start),t.timesVector2(this._control),t.timesVector2(this._end))}getSignedAreaFragment(){return 1/6*(this._start.x*(2*this._control.y+this._end.y)+this._control.x*(-2*this._start.y+2*this._end.y)+this._end.x*(-this._start.y-2*this._control.y))}reparameterized(t,e){var i=this._start.plus(this._end.plus(this._control.timesScalar(-2))),s=this._control.minus(this._start).timesScalar(2),n=this._start,r=i.timesScalar(t*t),a=i.timesScalar(t*e).timesScalar(2).plus(s.timesScalar(t)),o=i.timesScalar(e*e).plus(s.timesScalar(e)).plus(n);return new Hr(o,a.timesScalar(.5).plus(o),r.plus(a).plus(o))}reversed(){return new Hr(this._end,this._control,this._start)}serialize(){return{type:"Quadratic",startX:this._start.x,startY:this._start.y,controlX:this._control.x,controlY:this._control.y,endX:this._end.x,endY:this._end.y}}getOverlaps(t){return t instanceof Hr?Hr.getOverlaps(this,t):null}static deserialize(t){return new Hr(new Is(t.startX,t.startY),new Is(t.controlX,t.controlY),new Is(t.endX,t.endY))}static extremaT(t,e,i){var s=2*(i-2*e+t);return 0!==s?-2*(e-t)/s:NaN}static getOverlaps(t,e){var i,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-6,n=[],r=t._start.x,a=-2*t._start.x+2*t._control.x,o=t._start.x-2*t._control.x+t._end.x,h=t._start.y,l=-2*t._start.y+2*t._control.y,d=t._start.y-2*t._control.y+t._end.y,u=e._start.x,c=-2*e._start.x+2*e._control.x,m=e._start.x-2*e._control.x+e._end.x,p=e._start.y,g=-2*e._start.y+2*e._control.y,v=e._start.y-2*e._control.y+e._end.y,f=Math.abs(Math.max(t._start.x,t._control.x,t._end.x,e._start.x,e._control.x,e._end.x)-Math.min(t._start.x,t._control.x,t._end.x,e._start.x,e._control.x,e._end.x)),y=Math.abs(Math.max(t._start.y,t._control.y,t._end.y,e._start.y,e._control.y,e._end.y)-Math.min(t._start.y,t._control.y,t._end.y,e._start.y,e._control.y,e._end.y)),b=Mr.polynomialGetOverlapQuadratic(r,a,o,u,c,m),P=Mr.polynomialGetOverlapQuadratic(h,l,d,p,g,v);if(null===(i=f>y?null===b||!0===b?P:b:null===P||!0===P?b:P)||!0===i)return n;for(var w=i.a,x=i.b,T=w*w,S=x*x,A=2*w*x,E=u+x*c+S*m-r,C=w*c+A*m-a,D=T*m-o,I=p+x*g+S*v-h,L=w*g+A*v-l,k=T*v-d,M=Vs.solveLinearRootsReal(2*D,C),O=Vs.solveLinearRootsReal(2*k,L),R=_.uniq([0,1].concat(M?M.filter(Vr):[])),N=_.uniq([0,1].concat(O?O.filter(Vr):[])),B=0;Bs)return n}for(var V=0;Vs)return n}var Y=w+x;return x>1&&Y>1||x<0&&Y<0?n:[new Sr(w,x)]}}Hr.prototype.degree=2,Pr.register("Quadratic",Hr);var Yr=Vs.solveQuadraticRootsReal,zr=Vs.solveCubicRootsReal,Wr=Vs.arePointsCollinear,Ur=new Is(0,0),Gr=new Is(0,0),Xr=new Is(0,0);function jr(t){return t>=0&&t<=1}class qr extends Mr{constructor(t,e,i,s){super(),this._start=t,this._control1=e,this._control2=i,this._end=s,this.invalidate()}setStart(t){return this._start.equals(t)||(this._start=t,this.invalidate()),this}set start(t){this.setStart(t)}get start(){return this.getStart()}getStart(){return this._start}setControl1(t){return this._control1.equals(t)||(this._control1=t,this.invalidate()),this}set control1(t){this.setControl1(t)}get control1(){return this.getControl1()}getControl1(){return this._control1}setControl2(t){return this._control2.equals(t)||(this._control2=t,this.invalidate()),this}set control2(t){this.setControl2(t)}get control2(){return this.getControl2()}getControl2(){return this._control2}setEnd(t){return this._end.equals(t)||(this._end=t,this.invalidate()),this}set end(t){this.setEnd(t)}get end(){return this.getEnd()}getEnd(){return this._end}positionAt(t){var e=1-t,i=e*e*e,s=3*e*e*t,n=3*e*t*t,r=t*t*t;return new Is(this._start.x*i+this._control1.x*s+this._control2.x*n+this._end.x*r,this._start.y*i+this._control1.y*s+this._control2.y*n+this._end.y*r)}tangentAt(t){var e=1-t;return new Is(0,0).set(this._start).multiplyScalar(-3*e*e).add(Ur.set(this._control1).multiplyScalar(3*e*e-6*e*t)).add(Ur.set(this._control2).multiplyScalar(6*e*t-3*t*t)).add(Ur.set(this._end).multiplyScalar(3*t*t))}curvatureAt(t){if(Math.abs(t-.5)>.5-1e-7){var e=t<.5,i=e?this._start:this._end,s=e?this._control1:this._control2,n=e?this._control2:this._control1,r=s.minus(i),a=r.magnitude;return(e?-1:1)*r.perpendicular.normalized().dot(n.minus(s))*(this.degree-1)/(this.degree*a*a)}return this.subdivided(t)[0].curvatureAt(1)}subdivided(t){if(0===t||1===t)return[this];var e=this._start.blend(this._control1,t),i=this._control2.blend(this._end,t),s=this._control1.blend(this._control2,t),n=e.blend(s,t),r=s.blend(i,t),a=n.blend(r,t);return[new qr(this._start,e,n,a),new qr(a,r,i,this._end)]}invalidate(){this._startTangent=null,this._endTangent=null,this._r=null,this._s=null,this._tCusp=null,this._tDeterminant=null,this._tInflection1=null,this._tInflection2=null,this._quadratics=null,this._xExtremaT=null,this._yExtremaT=null,this._bounds=null,this._svgPathFragment=null,this.invalidationEmitter.emit()}getStartTangent(){return null===this._startTangent&&(this._startTangent=this.tangentAt(0).normalized()),this._startTangent}get startTangent(){return this.getStartTangent()}getEndTangent(){return null===this._endTangent&&(this._endTangent=this.tangentAt(1).normalized()),this._endTangent}get endTangent(){return this.getEndTangent()}getR(){return null===this._r&&(this._r=this._control1.minus(this._start).normalized()),this._r}get r(){return this.getR()}getS(){return null===this._s&&(this._s=this.getR().perpendicular),this._s}get s(){return this.getS()}getTCusp(){return null===this._tCusp&&this.computeCuspInfo(),this._tCusp}get tCusp(){return this.getTCusp()}getTDeterminant(){return null===this._tDeterminant&&this.computeCuspInfo(),this._tDeterminant}get tDeterminant(){return this.getTDeterminant()}getTInflection1(){return null===this._tInflection1&&this.computeCuspInfo(),this._tInflection1}get tInflection1(){return this.getTInflection1()}getTInflection2(){return null===this._tInflection2&&this.computeCuspInfo(),this._tInflection2}get tInflection2(){return this.getTInflection2()}getQuadratics(){return null===this._quadratics&&this.computeCuspSegments(),this._quadratics}getXExtremaT(){return null===this._xExtremaT&&(this._xExtremaT=qr.extremaT(this._start.x,this._control1.x,this._control2.x,this._end.x)),this._xExtremaT}get xExtremaT(){return this.getXExtremaT()}getYExtremaT(){return null===this._yExtremaT&&(this._yExtremaT=qr.extremaT(this._start.y,this._control1.y,this._control2.y,this._end.y)),this._yExtremaT}get yExtremaT(){return this.getYExtremaT()}getBounds(){return null===this._bounds&&(this._bounds=mn.NOTHING,this._bounds=this._bounds.withPoint(this._start),this._bounds=this._bounds.withPoint(this._end),_.each(this.getXExtremaT(),t=>{t>=0&&t<=1&&(this._bounds=this._bounds.withPoint(this.positionAt(t)))}),_.each(this.getYExtremaT(),t=>{t>=0&&t<=1&&(this._bounds=this._bounds.withPoint(this.positionAt(t)))}),this.hasCusp()&&(this._bounds=this._bounds.withPoint(this.positionAt(this.getTCusp())))),this._bounds}get bounds(){return this.getBounds()}computeCuspInfo(){var t=this._start.times(-1).plus(this._control1.times(3)).plus(this._control2.times(-3)).plus(this._end),e=this._start.times(3).plus(this._control1.times(-6)).plus(this._control2.times(3)),i=this._start.times(-3).plus(this._control1.times(3)),s=t.perpendicular,n=e.perpendicular,r=s.dot(e);if(this._tCusp=s.dot(i)/r*-.5,this._tDeterminant=this._tCusp*this._tCusp-1/3*(n.dot(i)/r),this._tDeterminant>=0){var a=Math.sqrt(this._tDeterminant);this._tInflection1=this._tCusp-a,this._tInflection2=this._tCusp+a}else this._tInflection1=NaN,this._tInflection2=NaN}computeCuspSegments(){if(this.hasCusp()){this._quadratics=[];var t=this.getTCusp();if(0===t)this._quadratics.push(new Hr(this.start,this.control2,this.end));else if(1===t)this._quadratics.push(new Hr(this.start,this.control1,this.end));else{var e=this.subdivided(t);this._quadratics.push(new Hr(e[0].start,e[0].control1,e[0].end)),this._quadratics.push(new Hr(e[1].start,e[1].control2,e[1].end))}}else this._quadratics=null}getNondegenerateSegments(){var t=this._start,e=this._control1,i=this._control2,s=this._end,n=this.degreeReduced(1e-9);if(t.equals(s)&&t.equals(e)&&t.equals(i))return[];if(this.hasCusp())return _.flatten(this.getQuadratics().map(t=>t.getNondegenerateSegments()));if(n)return n.getNondegenerateSegments();if(Wr(t,e,s)&&Wr(t,i,s)&&!t.equalsEpsilon(s,1e-7)){var r=this.getXExtremaT().concat(this.getYExtremaT()).sort().map(t=>this.positionAt(t)),a=[],o=t;r.length&&(a.push(new Nr(t,r[0])),o=r[0]);for(var h=1;ht.getNondegenerateSegments()))}return[this]}hasCusp(){var t=this.getTCusp();return t>=0&&t<=1&&this.tangentAt(t).magnitude<1e-7}toRS(t){var e=t.minus(this._start);return new Is(e.dot(this.getR()),e.dot(this.getS()))}offsetTo(t,e){for(var i=[],s=[],n=0;n<32;n++){var r=n/31;e&&(r=1-r),i.push(this.positionAt(r).plus(this.tangentAt(r).perpendicular.normalized().times(t))),n>0&&s.push(new Nr(i[n-1],i[n]))}return s}getSVGPathFragment(){return this._svgPathFragment||(this._svgPathFragment="C ".concat(Dr(this._control1.x)," ").concat(Dr(this._control1.y)," ").concat(Dr(this._control2.x)," ").concat(Dr(this._control2.y)," ").concat(Dr(this._end.x)," ").concat(Dr(this._end.y))),this._svgPathFragment}strokeLeft(t){return this.offsetTo(-t/2,!1)}strokeRight(t){return this.offsetTo(t/2,!0)}getInteriorExtremaTs(){var t=this.getXExtremaT().concat(this.getYExtremaT()),e=[];return _.each(t,t=>{t>1e-10&&t<1-1e-10&&_.every(e,e=>Math.abs(t-e)>1e-10)&&e.push(t)}),e.sort()}intersection(t){var e=[],i=wn.rotation2(-t.direction.angle).timesMatrix(wn.translation(-t.position.x,-t.position.y)),s=i.timesVector2(this._start),n=i.timesVector2(this._control1),r=i.timesVector2(this._control2),a=i.timesVector2(this._end),o=-s.y+3*n.y-3*r.y+a.y,h=3*s.y-6*n.y+3*r.y,l=-3*s.y+3*n.y,d=s.y,u=zr(o,h,l,d);return _.each(u,i=>{if(i>=0&&i<=1){var s=this.positionAt(i),n=this.tangentAt(i).normalized(),r=n.perpendicular,a=s.minus(t.position);if(a.dot(t.direction)>0){var o=r.dot(t.direction)>0?r.negated():r,h=t.direction.perpendicular.dot(n)<0?1:-1;e.push(new Ar(a.magnitude,s,o,h,i))}}}),e}windingIntersection(t){var e=0,i=this.intersection(t);return _.each(i,t=>{e+=t.wind}),e}writeToContext(t){t.bezierCurveTo(this._control1.x,this._control1.y,this._control2.x,this._control2.y,this._end.x,this._end.y)}transformed(t){return new qr(t.timesVector2(this._start),t.timesVector2(this._control1),t.timesVector2(this._control2),t.timesVector2(this._end))}degreeReduced(t){t=t||0;var e=Ur.set(this._control1).multiplyScalar(3).subtract(this._start).divideScalar(2),i=Gr.set(this._control2).multiplyScalar(3).subtract(this._end).divideScalar(2);return Xr.set(e).subtract(i).magnitude<=t?new Hr(this._start,e.average(i),this._end):null}getSignedAreaFragment(){return.05*(this._start.x*(6*this._control1.y+3*this._control2.y+this._end.y)+this._control1.x*(-6*this._start.y+3*this._control2.y+3*this._end.y)+this._control2.x*(-3*this._start.y-3*this._control1.y+6*this._end.y)+this._end.x*(-this._start.y-3*this._control1.y-6*this._control2.y))}reversed(){return new qr(this._end,this._control2,this._control1,this._start)}getSelfIntersection(){var t=this.getInteriorExtremaTs(),e=[0].concat(t).concat([1]),i=this.subdivisions(t);if(i.length<3)return null;for(var s=0;s1e-7&&h.aT<1-1e-7&&h.bT>1e-7&&h.bT<1-1e-7){var l=e[s]+h.aT*(e[s+1]-e[s]),d=e[r]+h.bT*(e[r+1]-e[r]);return new Er(h.point,l,d)}}}return null}serialize(){return{type:"Cubic",startX:this._start.x,startY:this._start.y,control1X:this._control1.x,control1Y:this._control1.y,control2X:this._control2.x,control2Y:this._control2.y,endX:this._end.x,endY:this._end.y}}getOverlaps(t){return t instanceof qr?qr.getOverlaps(this,t):null}static deserialize(t){return new qr(new Is(t.startX,t.startY),new Is(t.control1X,t.control1Y),new Is(t.control2X,t.control2Y),new Is(t.endX,t.endY))}static extremaT(t,e,i,s){if(t===e&&t===i&&t===s)return[];var n=-3*t+9*e-9*i+3*s,r=6*t-12*e+6*i,a=-3*t+3*e;return _.filter(Yr(n,r,a),jr)}static getOverlaps(t,e){var i,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-6,n=[],r=t._start.x,a=-3*t._start.x+3*t._control1.x,o=3*t._start.x-6*t._control1.x+3*t._control2.x,h=-1*t._start.x+3*t._control1.x-3*t._control2.x+t._end.x,l=t._start.y,d=-3*t._start.y+3*t._control1.y,u=3*t._start.y-6*t._control1.y+3*t._control2.y,c=-1*t._start.y+3*t._control1.y-3*t._control2.y+t._end.y,m=e._start.x,p=-3*e._start.x+3*e._control1.x,g=3*e._start.x-6*e._control1.x+3*e._control2.x,v=-1*e._start.x+3*e._control1.x-3*e._control2.x+e._end.x,f=e._start.y,y=-3*e._start.y+3*e._control1.y,b=3*e._start.y-6*e._control1.y+3*e._control2.y,P=-1*e._start.y+3*e._control1.y-3*e._control2.y+e._end.y,w=Math.abs(Math.max(t._start.x,t._control1.x,t._control2.x,t._end.x,t._start.x,t._control1.x,t._control2.x,t._end.x)-Math.min(t._start.x,t._control1.x,t._control2.x,t._end.x,t._start.x,t._control1.x,t._control2.x,t._end.x)),x=Math.abs(Math.max(t._start.y,t._control1.y,t._control2.y,t._end.y,t._start.y,t._control1.y,t._control2.y,t._end.y)-Math.min(t._start.y,t._control1.y,t._control2.y,t._end.y,t._start.y,t._control1.y,t._control2.y,t._end.y)),T=Mr.polynomialGetOverlapCubic(r,a,o,h,m,p,g,v),S=Mr.polynomialGetOverlapCubic(l,d,u,c,f,y,b,P);if(null===(i=w>x?null===T||!0===T?S:T:null===S||!0===S?T:S)||!0===i)return n;for(var A=i.a,E=i.b,C=A*A,D=A*A*A,I=E*E,L=E*E*E,k=2*A*E,M=3*A*I,O=3*C*E,R=m+E*p+I*g+L*v-r,N=A*p+k*g+M*v-a,B=C*g+O*v-o,F=D*v-h,V=f+E*y+I*b+L*P-l,H=A*y+k*b+M*P-d,Y=C*b+O*P-u,z=D*P-c,W=Vs.solveQuadraticRootsReal(3*F,2*B,N),U=Vs.solveQuadraticRootsReal(3*z,2*Y,H),G=_.uniq([0,1].concat(null!==W?W.filter(jr):[])),X=_.uniq([0,1].concat(null!==U?U.filter(jr):[])),j=0;js)return n}for(var K=0;Ks)return n}var Q=A+E;return E>1&&Q>1||E<0&&Q<0?n:[new Sr(A,E)]}}qr.prototype.degree=3,Pr.register("Cubic",qr);var Kr=2*Math.PI;class Zr extends Mr{constructor(t,e,i,s,n){super(),this._center=t,this._radius=e,this._startAngle=i,this._endAngle=s,this._anticlockwise=n,this.invalidate()}setCenter(t){return this._center.equals(t)||(this._center=t,this.invalidate()),this}set center(t){this.setCenter(t)}get center(){return this.getCenter()}getCenter(){return this._center}setRadius(t){return this._radius!==t&&(this._radius=t,this.invalidate()),this}set radius(t){this.setRadius(t)}get radius(){return this.getRadius()}getRadius(){return this._radius}setStartAngle(t){return this._startAngle!==t&&(this._startAngle=t,this.invalidate()),this}set startAngle(t){this.setStartAngle(t)}get startAngle(){return this.getStartAngle()}getStartAngle(){return this._startAngle}setEndAngle(t){return this._endAngle!==t&&(this._endAngle=t,this.invalidate()),this}set endAngle(t){this.setEndAngle(t)}get endAngle(){return this.getEndAngle()}getEndAngle(){return this._endAngle}setAnticlockwise(t){return this._anticlockwise!==t&&(this._anticlockwise=t,this.invalidate()),this}set anticlockwise(t){this.setAnticlockwise(t)}get anticlockwise(){return this.getAnticlockwise()}getAnticlockwise(){return this._anticlockwise}positionAt(t){return this.positionAtAngle(this.angleAt(t))}tangentAt(t){return this.tangentAtAngle(this.angleAt(t))}curvatureAt(t){return(this._anticlockwise?-1:1)/this._radius}subdivided(t){if(0===t||1===t)return[this];var e=this.angleAt(0),i=this.angleAt(t),s=this.angleAt(1);return[new Zr(this._center,this._radius,e,i,this._anticlockwise),new Zr(this._center,this._radius,i,s,this._anticlockwise)]}invalidate(){this._start=null,this._end=null,this._startTangent=null,this._endTangent=null,this._actualEndAngle=null,this._isFullPerimeter=null,this._angleDifference=null,this._bounds=null,this._svgPathFragment=null,this._radius<0&&(this._radius=-this._radius,this._startAngle+=Math.PI,this._endAngle+=Math.PI),this.invalidationEmitter.emit()}getStart(){return null===this._start&&(this._start=this.positionAtAngle(this._startAngle)),this._start}get start(){return this.getStart()}getEnd(){return null===this._end&&(this._end=this.positionAtAngle(this._endAngle)),this._end}get end(){return this.getEnd()}getStartTangent(){return null===this._startTangent&&(this._startTangent=this.tangentAtAngle(this._startAngle)),this._startTangent}get startTangent(){return this.getStartTangent()}getEndTangent(){return null===this._endTangent&&(this._endTangent=this.tangentAtAngle(this._endAngle)),this._endTangent}get endTangent(){return this.getEndTangent()}getActualEndAngle(){return null===this._actualEndAngle&&(this._actualEndAngle=Zr.computeActualEndAngle(this._startAngle,this._endAngle,this._anticlockwise)),this._actualEndAngle}get actualEndAngle(){return this.getActualEndAngle()}getIsFullPerimeter(){return null===this._isFullPerimeter&&(this._isFullPerimeter=!this._anticlockwise&&this._endAngle-this._startAngle>=2*Math.PI||this._anticlockwise&&this._startAngle-this._endAngle>=2*Math.PI),this._isFullPerimeter}get isFullPerimeter(){return this.getIsFullPerimeter()}getAngleDifference(){return null===this._angleDifference&&(this._angleDifference=this._anticlockwise?this._startAngle-this._endAngle:this._endAngle-this._startAngle,this._angleDifference<0&&(this._angleDifference+=2*Math.PI)),this._angleDifference}get angleDifference(){return this.getAngleDifference()}getBounds(){return null===this._bounds&&(this._bounds=mn.NOTHING.copy().withPoint(this.getStart()).withPoint(this.getEnd()),this._startAngle!==this._endAngle&&(this.includeBoundsAtAngle(0),this.includeBoundsAtAngle(Math.PI/2),this.includeBoundsAtAngle(Math.PI),this.includeBoundsAtAngle(3*Math.PI/2))),this._bounds}get bounds(){return this.getBounds()}getNondegenerateSegments(){return this._radius<=0||this._startAngle===this._endAngle?[]:[this]}includeBoundsAtAngle(t){this.containsAngle(t)&&(this._bounds=this._bounds.withPoint(this._center.plus(Is.createPolar(this._radius,t))))}mapAngle(t){return Math.abs(Vs.moduloBetweenDown(t-this._startAngle,-Math.PI,Math.PI))<1e-8?this._startAngle:Math.abs(Vs.moduloBetweenDown(t-this.getActualEndAngle(),-Math.PI,Math.PI))<1e-8?this.getActualEndAngle():this._startAngle>this.getActualEndAngle()?Vs.moduloBetweenUp(t,this._startAngle-2*Math.PI,this._startAngle):Vs.moduloBetweenDown(t,this._startAngle,this._startAngle+2*Math.PI)}tAtAngle(t){var e=(this.mapAngle(t)-this._startAngle)/(this.getActualEndAngle()-this._startAngle);return e}angleAt(t){return this._startAngle+(this.getActualEndAngle()-this._startAngle)*t}positionAtAngle(t){return this._center.plus(Is.createPolar(this._radius,t))}tangentAtAngle(t){var e=Is.createPolar(1,t);return this._anticlockwise?e.perpendicular:e.perpendicular.negated()}containsAngle(t){var e=this._anticlockwise?t-this._endAngle:t-this._startAngle;return Vs.moduloBetweenDown(e,0,2*Math.PI)<=this.angleDifference}getSVGPathFragment(){if(!this._svgPathFragment){var t,e=this._anticlockwise?"0":"1";if(this.angleDifference<2*Math.PI-.01)t=this.angleDifference{if(this.containsAngle(e)){var i=this.tAtAngle(e);i>1e-10&&i<1-1e-10&&t.push(i)}}),t.sort()}intersection(t){var e=[],i=t.position.minus(this._center),s=t.direction.dot(i),n=4*s*s-4*(i.magnitudeSquared-this._radius*this._radius);if(n<0)return e;var r=t.direction.dot(this._center)-t.direction.dot(t.position),a=Math.sqrt(n)/2,o=r-a,h=r+a;if(h<0)return e;var l=t.pointAtDistance(h),d=l.minus(this._center).normalized(),u=d.angle;if(o<0)this.containsAngle(u)&&e.push(new Ar(h,l,d.negated(),this._anticlockwise?-1:1,this.tAtAngle(u)));else{var c=t.pointAtDistance(o),m=c.minus(this._center).normalized(),p=m.angle;this.containsAngle(p)&&e.push(new Ar(o,c,m,this._anticlockwise?1:-1,this.tAtAngle(p))),this.containsAngle(u)&&e.push(new Ar(h,l,d.negated(),this._anticlockwise?-1:1,this.tAtAngle(u)))}return e}windingIntersection(t){var e=0,i=this.intersection(t);return _.each(i,t=>{e+=t.wind}),e}writeToContext(t){t.arc(this._center.x,this._center.y,this._radius,this._startAngle,this._endAngle,this._anticlockwise)}transformed(t){var e=t.timesVector2(Is.createPolar(1,this._startAngle)).minus(t.timesVector2(Is.ZERO)).angle,i=t.timesVector2(Is.createPolar(1,this._endAngle)).minus(t.timesVector2(Is.ZERO)).angle,s=t.getDeterminant()>=0?this._anticlockwise:!this._anticlockwise;Math.abs(this._endAngle-this._startAngle)===2*Math.PI&&(i=s?e-2*Math.PI:e+2*Math.PI);var n=t.getScaleVector();if(n.x!==n.y){var r=n.x*this._radius,a=n.y*this._radius;return new Jr(t.timesVector2(this._center),r,a,0,e,i,s)}var o=n.x*this._radius;return new Zr(t.timesVector2(this._center),o,e,i,s)}getSignedAreaFragment(){var t=this._startAngle,e=this.getActualEndAngle();return.5*this._radius*(this._radius*(e-t)+this._center.x*(Math.sin(e)-Math.sin(t))-this._center.y*(Math.cos(e)-Math.cos(t)))}reversed(){return new Zr(this._center,this._radius,this._endAngle,this._startAngle,!this._anticlockwise)}getArcLength(){return this.getAngleDifference()*this._radius}toPiecewiseLinearOrArcSegments(){return[this]}serialize(){return{type:"Arc",centerX:this._center.x,centerY:this._center.y,radius:this._radius,startAngle:this._startAngle,endAngle:this._endAngle,anticlockwise:this._anticlockwise}}getOverlaps(t){return t instanceof Zr?Zr.getOverlaps(this,t):null}static deserialize(t){return new Zr(new Is(t.centerX,t.centerY),t.radius,t.startAngle,t.endAngle,t.anticlockwise)}static computeActualEndAngle(t,e,i){return i?t>e?e:te?e+2*Math.PI:t}static getPartialOverlap(t,e,i,s,n){var r=iKr+1e-10?(a=(Kr-o)/(h-o),Zr.getPartialOverlap(n,o,Kr,0,a).concat(Zr.getPartialOverlap(n,0,h-Kr,a,1))):Zr.getPartialOverlap(n,o,h,0,1)}static getOverlaps(t,e){return t._center.distance(e._center)>1e-8||Math.abs(t._radius-e._radius)>1e-8?[]:Zr.getAngularOverlaps(t._startAngle,t.getActualEndAngle(),e._startAngle,e.getActualEndAngle())}static getCircleIntersectionPoint(t,e,i,s){var n=i.minus(t),r=n.magnitude,a=[];if(r<1e-10||r>e+s+1e-10);else if(r>e+s-1e-10)a=[t.blend(i,e/r)];else{var o=.5*(r*r-s*s+e*e)/r,h=r*r-s*s+e*e,l=4*r*r*e*e-h*h,d=t.blend(i,o/r);if(l>=1e-10){var u=Math.sqrt(l)/r/2,c=n.perpendicular.setMagnitude(u);a=[d.plus(c),d.minus(c)]}else l>-1e-10&&(a=[d])}return a}static intersect(t,e){var i=[];if(t._center.equalsEpsilon(e._center,1e-8)&&Math.abs(t._radius-e._radius)<1e-8){var s=t.positionAt(0),n=t.positionAt(1),r=e.positionAt(0),a=e.positionAt(1);s.equalsEpsilon(r,1e-8)&&i.push(new Er(s.average(r),0,0)),s.equalsEpsilon(a,1e-8)&&i.push(new Er(s.average(a),0,1)),n.equalsEpsilon(r,1e-8)&&i.push(new Er(n.average(r),1,0)),n.equalsEpsilon(a,1e-8)&&i.push(new Er(n.average(a),1,1))}else for(var o=Zr.getCircleIntersectionPoint(t._center,t._radius,e._center,e._radius),h=0;h=2*Math.PI||this._anticlockwise&&this._startAngle-this._endAngle>=2*Math.PI),this._isFullPerimeter}get isFullPerimeter(){return this.getIsFullPerimeter()}getAngleDifference(){return null===this._angleDifference&&(this._angleDifference=this._anticlockwise?this._startAngle-this._endAngle:this._endAngle-this._startAngle,this._angleDifference<0&&(this._angleDifference+=2*Math.PI)),this._angleDifference}get angleDifference(){return this.getAngleDifference()}getUnitArcSegment(){return null===this._unitArcSegment&&(this._unitArcSegment=new Zr(Is.ZERO,1,this._startAngle,this._endAngle,this._anticlockwise)),this._unitArcSegment}get unitArcSegment(){return this.getUnitArcSegment()}getBounds(){if(null===this._bounds&&(this._bounds=mn.NOTHING.withPoint(this.getStart()).withPoint(this.getEnd()),this._startAngle!==this._endAngle)){var t=Math.atan(-this._radiusY/this._radiusX*Math.tan(this._rotation)),e=Math.atan(this._radiusY/this._radiusX/Math.tan(this._rotation));this.possibleExtremaAngles=[t,t+Math.PI,e,e+Math.PI],_.each(this.possibleExtremaAngles,this.includeBoundsAtAngle.bind(this))}return this._bounds}get bounds(){return this.getBounds()}getNondegenerateSegments(){if(this._radiusX<=0||this._radiusY<=0||this._startAngle===this._endAngle)return[];if(this._radiusX===this._radiusY){var t=this._startAngle+this._rotation,e=this._endAngle+this._rotation;return Math.abs(this._endAngle-this._startAngle)===2*Math.PI&&(e=this._anticlockwise?t-2*Math.PI:t+2*Math.PI),[new Zr(this._center,this._radiusX,t,e,this._anticlockwise)]}return[this]}includeBoundsAtAngle(t){this.unitArcSegment.containsAngle(t)&&(this._bounds=this._bounds.withPoint(this.positionAtAngle(t)))}mapAngle(t){return Math.abs(Vs.moduloBetweenDown(t-this._startAngle,-Math.PI,Math.PI))<1e-8?this._startAngle:Math.abs(Vs.moduloBetweenDown(t-this.getActualEndAngle(),-Math.PI,Math.PI))<1e-8?this.getActualEndAngle():this._startAngle>this.getActualEndAngle()?Vs.moduloBetweenUp(t,this._startAngle-2*Math.PI,this._startAngle):Vs.moduloBetweenDown(t,this._startAngle,this._startAngle+2*Math.PI)}tAtAngle(t){return(this.mapAngle(t)-this._startAngle)/(this.getActualEndAngle()-this._startAngle)}angleAt(t){return this._startAngle+(this.getActualEndAngle()-this._startAngle)*t}positionAtAngle(t){return this.getUnitTransform().transformPosition2(Is.createPolar(1,t))}tangentAtAngle(t){var e=this.getUnitTransform().transformNormal2(Is.createPolar(1,t));return this._anticlockwise?e.perpendicular:e.perpendicular.negated()}offsetTo(t,e){for(var i=[],s=[],n=0;n<32;n++){var r=n/31;e&&(r=1-r);var a=this.angleAt(r);i.push(this.positionAtAngle(a).plus(this.tangentAtAngle(a).perpendicular.normalized().times(t))),n>0&&s.push(new Nr(i[n-1],i[n]))}return s}getSVGPathFragment(){if(!this._svgPathFragment){var t,e=this._anticlockwise?"0":"1",i=Qr(this._rotation);if(this.getAngleDifference()<2*Math.PI-.01)t=this.getAngleDifference(){if(this.unitArcSegment.containsAngle(e)){var i=this.tAtAngle(e);i>1e-10&&i<1-1e-10&&t.push(i)}}),t.sort()}intersection(t){var e=this.getUnitTransform(),i=e.inverseRay2(t),s=this.getUnitArcSegment().intersection(i);return _.map(s,i=>{var s=e.transformPosition2(i.point),n=t.position.distance(s),r=e.inverseNormal2(i.normal);return new Ar(n,s,r,i.wind,i.t)})}windingIntersection(t){var e=this.getUnitTransform().inverseRay2(t);return this.getUnitArcSegment().windingIntersection(e)}writeToContext(t){t.ellipse?t.ellipse(this._center.x,this._center.y,this._radiusX,this._radiusY,this._rotation,this._startAngle,this._endAngle,this._anticlockwise):(this.getUnitTransform().getMatrix().canvasAppendTransform(t),t.arc(0,0,1,this._startAngle,this._endAngle,this._anticlockwise),this.getUnitTransform().getInverse().canvasAppendTransform(t))}transformed(t){var e=t.timesVector2(Is.createPolar(this._radiusX,this._rotation)).minus(t.timesVector2(Is.ZERO)),i=t.timesVector2(Is.createPolar(this._radiusY,this._rotation+Math.PI/2)).minus(t.timesVector2(Is.ZERO)),s=e.angle,n=e.magnitude,r=i.magnitude,a=t.getDeterminant()<0,o=a?!this._anticlockwise:this._anticlockwise,h=a?-this._startAngle:this._startAngle,l=a?-this._endAngle:this._endAngle;return Math.abs(this._endAngle-this._startAngle)===2*Math.PI&&(l=o?h-2*Math.PI:h+2*Math.PI),new Jr(t.timesVector2(this._center),n,r,s,h,l,o)}getSignedAreaFragment(){var t=this._startAngle,e=this.getActualEndAngle(),i=Math.sin(t),s=Math.sin(e),n=Math.cos(t),r=Math.cos(e);return.5*(this._radiusX*this._radiusY*(e-t)+Math.cos(this._rotation)*(this._radiusX*this._center.y*(n-r)+this._radiusY*this._center.x*(s-i))+Math.sin(this._rotation)*(this._radiusX*this._center.x*(r-n)+this._radiusY*this._center.y*(s-i)))}reversed(){return new Jr(this._center,this._radiusX,this._radiusY,this._rotation,this._endAngle,this._startAngle,!this._anticlockwise)}serialize(){return{type:"EllipticalArc",centerX:this._center.x,centerY:this._center.y,radiusX:this._radiusX,radiusY:this._radiusY,rotation:this._rotation,startAngle:this._startAngle,endAngle:this._endAngle,anticlockwise:this._anticlockwise}}getOverlaps(t){return t instanceof Jr?Jr.getOverlaps(this,t):null}static deserialize(t){return new Jr(new Is(t.centerX,t.centerY),t.radiusX,t.radiusY,t.rotation,t.startAngle,t.endAngle,t.anticlockwise)}static getOverlapType(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-10;if(t._center.distance(e._center)2&&void 0!==arguments[2]?arguments[2]:1e-10;if(Jr.getOverlapType(t,e,i)===$r.NONE)return Sa.intersect(t,e);var s=[],n=t.positionAt(0),r=t.positionAt(1),a=e.positionAt(0),o=e.positionAt(1);return n.equalsEpsilon(a,i)&&s.push(new Er(n.average(a),0,0)),n.equalsEpsilon(o,i)&&s.push(new Er(n.average(o),0,1)),r.equalsEpsilon(a,i)&&s.push(new Er(r.average(a),1,0)),r.equalsEpsilon(o,i)&&s.push(new Er(r.average(o),1,1)),s}static computeUnitTransform(t,e,i,s){return new Cn(wn.translation(t.x,t.y).timesMatrix(wn.rotation2(s)).timesMatrix(wn.scaling(e,i)))}}class $r extends it{}_defineProperty($r,"MATCHING_OVERLAP",new $r),_defineProperty($r,"OPPOSITE_OVERLAP",new $r),_defineProperty($r,"NONE",new $r),_defineProperty($r,"enumeration",new at($r)),Pr.register("EllipticalArc",Jr);class ta{constructor(t,e,i){if(this.invalidatedEmitter=new c,this.segments=[],this.points=e||(t&&t.length?_.map(t,t=>t.start).concat(t[t.length-1].end):[]),this.closed=!!i,this._strokedSubpaths=null,this._strokedSubpathsComputed=!1,this._strokedStyles=null,this._bounds=null,this._invalidateListener=this.invalidate.bind(this),this._invalidatingPoints=!1,t)for(var s=0;s{this.addSegmentDirectly(t)})}getBounds(){if(null===this._bounds){var t=mn.NOTHING.copy();_.each(this.segments,e=>{t.includeBounds(e.getBounds())}),this._bounds=t}return this._bounds}get bounds(){return this.getBounds()}getArcLength(t,e,i){for(var s=0,n=0;n0}isClosed(){return this.closed}hasClosingSegment(){return!this.getFirstPoint().equalsEpsilon(this.getLastPoint(),1e-9)}getClosingSegment(){return new Nr(this.getLastPoint(),this.getFirstPoint())}writeToContext(t){if(this.isDrawable()){var e=this.getFirstSegment().start;t.moveTo(e.x,e.y);var i=this.segments.length;this.closed&&i>=2&&this.segments[i-1]instanceof Nr&&i--;for(var s=0;se.toPiecewiseLinearSegments(t))),null,this.closed)}transformed(t){return new ta(_.map(this.segments,e=>e.transformed(t)),_.map(this.points,e=>t.timesVector2(e)),this.closed)}nonlinearTransformed(t){return new ta(_.flatten(_.map(this.segments,e=>t.methodName&&e[t.methodName]?e[t.methodName](t):e.toPiecewiseLinearSegments(t))),null,this.closed)}getBoundsWithTransform(t){for(var e=mn.NOTHING.copy(),i=this.segments.length,s=0;s0){var r=(e>0?e:i.length)-1,a=i[e].start,o=i[r].endTangent,h=i[e].startTangent,l=o.perpendicular.negated().times(t).angle,d=h.perpendicular.negated().times(t).angle,u=o.perpendicular.dot(h)>0;n.push(new Zr(a,Math.abs(t),l,d,u))}n=n.concat(s[e])}return new ta(n,null,this.closed)}stroked(t){if(!this.isDrawable())return[];if(void 0===t&&(t=new Tr),this._strokedSubpathsComputed&&this._strokedStyles.equals(t))return this._strokedSubpaths;var e,i=t.lineWidth,s=[],n=[],r=this.getFirstSegment(),a=this.getLastSegment();function o(t){s=s.concat(t)}function h(t){n=n.concat(t)}var l,d=a.end.equals(r.start),u=d?null:new Nr(this.segments[this.segments.length-1].end,this.segments[0].start);for(e=0;e0&&o(t.leftJoin(this.segments[e].start,this.segments[e-1].endTangent,this.segments[e].startTangent)),o(this.segments[e].strokeLeft(i));for(e=this.segments.length-1;e>=0;e--)e=1;m--){var p=a[m-1],g=a[m];r(p,g)&&a.splice(m-1,2,{segmentArrays:n(p.segmentArrays,g.segmentArrays),hasLeftFilled:p.hasLeftFilled,hasRightFilled:g.hasRightFilled})}if(a.length>1&&r(a[a.length-1],a[0])){var v=a.pop(),f=a.shift();a.push({segmentArrays:n(v.segmentArrays,f.segmentArrays),hasLeftFilled:v.hasLeftFilled,hasRightFilled:f.hasRightFilled})}return this.closed&&1===a.length&&1===a[0].segmentArrays.length&&a[0].hasLeftFilled&&a[0].hasRightFilled?[new ta(a[0].segmentArrays[0],null,!0)]:_.flatten(a.map(t=>t.segmentArrays)).map(t=>new ta(t))}serialize(){return{type:"Subpath",segments:this.segments.map(t=>t.serialize()),points:this.points.map(t=>({x:t.x,y:t.y})),closed:this.closed}}static deserialize(t){return new ta(t.segments.map(Mr.deserialize),t.points.map(t=>new Is(t.x,t.y)),t.closed)}}Pr.register("Subpath",ta);var ea=ta,ia=Math.random;function sa(t,e){return new Is(t,e)}function na(t,e,i,s){return i.copy().subtract(t).multiplyScalar((1-s)/6).add(e)}class ra{constructor(t,e){if(this.subpaths=[],this._bounds=e?e.copy():null,this.invalidatedEmitter=new c,this.resetControlPoints(),this._invalidateListener=this.invalidate.bind(this),this._invalidatingPoints=!1,this._immutable=!1,"object"==typeof t)for(var i=0;i{this[t.cmd].apply(this,t.args)}),this.invalidate()}resetControlPoints(){this.lastQuadraticControlPoint=null,this.lastCubicControlPoint=null}setQuadraticControlPoint(t){this.lastQuadraticControlPoint=t,this.lastCubicControlPoint=null}setCubicControlPoint(t){this.lastQuadraticControlPoint=null,this.lastCubicControlPoint=t}moveTo(t,e){return this.moveToPoint(sa(t,e))}moveToRelative(t,e){return this.moveToPointRelative(sa(t,e))}moveToPointRelative(t){return this.moveToPoint(this.getRelativePoint().plus(t))}moveToPoint(t){return this.addSubpath((new ea).addPoint(t)),this.resetControlPoints(),this}lineTo(t,e){return this.lineToPoint(sa(t,e))}lineToRelative(t,e){return this.lineToPointRelative(sa(t,e))}lineToPointRelative(t){return this.lineToPoint(this.getRelativePoint().plus(t))}lineToPoint(t){if(this.hasSubpaths()){var e=this.getLastSubpath().getLastPoint(),i=t,s=new Nr(e,i);this.getLastSubpath().addPoint(i),this.addSegmentAndBounds(s)}else this.ensure(t);return this.resetControlPoints(),this}horizontalLineTo(t){return this.lineTo(t,this.getRelativePoint().y)}horizontalLineToRelative(t){return this.lineToRelative(t,0)}verticalLineTo(t){return this.lineTo(this.getRelativePoint().x,t)}verticalLineToRelative(t){return this.lineToRelative(0,t)}zigZagTo(t,e,i,s,n){return this.zigZagToPoint(new Is(t,e),i,s,n)}zigZagToPoint(t,e,i,s){this.ensure(t);var n,r=this.getLastPoint(),a=t.minus(r),o=a.normalized(),h=o.perpendicular.times(e);n=s?a.magnitude/(i+.5):a.magnitude/i;for(var l=0;l{this.addSegmentAndBounds(t)}),this.setQuadraticControlPoint(t),this}cubicCurveTo(t,e,i,s,n,r){return this.cubicCurveToPoint(sa(t,e),sa(i,s),sa(n,r))}cubicCurveToRelative(t,e,i,s,n,r){return this.cubicCurveToPointRelative(sa(t,e),sa(i,s),sa(n,r))}cubicCurveToPointRelative(t,e,i){var s=this.getRelativePoint();return this.cubicCurveToPoint(s.plus(t),s.plus(e),s.plus(i))}smoothCubicCurveTo(t,e,i,s){return this.cubicCurveToPoint(this.getSmoothCubicControlPoint(),sa(t,e),sa(i,s))}smoothCubicCurveToRelative(t,e,i,s){return this.cubicCurveToPoint(this.getSmoothCubicControlPoint(),sa(t,e).plus(this.getRelativePoint()),sa(i,s).plus(this.getRelativePoint()))}cubicCurveToPoint(t,e,i){this.ensure(t);var s=this.getLastSubpath().getLastPoint(),n=new qr(s,t,e,i).getNondegenerateSegments();return _.each(n,t=>{this.addSegmentAndBounds(t)}),this.getLastSubpath().addPoint(i),this.setCubicControlPoint(e),this}arc(t,e,i,s,n,r){return this.arcPoint(sa(t,e),i,s,n,r)}arcPoint(t,e,i,s,n){void 0===n&&(n=!1);var r=new Zr(t,e,i,s,n),a=r.getStart(),o=r.getEnd();return this.hasSubpaths()&&this.getLastSubpath().getLength()>0&&!a.equals(this.getLastSubpath().getLastPoint(),0)&&this.addSegmentAndBounds(new Nr(this.getLastSubpath().getLastPoint(),a)),this.hasSubpaths()||this.addSubpath(new ea),this.getLastSubpath().addPoint(a),this.getLastSubpath().addPoint(o),this.addSegmentAndBounds(r),this.resetControlPoints(),this}ellipticalArc(t,e,i,s,n,r,a,o){return this.ellipticalArcPoint(sa(t,e),i,s,n,r,a,o)}ellipticalArcPoint(t,e,i,s,n,r,a){void 0===a&&(a=!1);var o=new Jr(t,e,i,s,n,r,a),h=o.start,l=o.end;return this.hasSubpaths()&&this.getLastSubpath().getLength()>0&&!h.equals(this.getLastSubpath().getLastPoint(),0)&&this.addSegmentAndBounds(new Nr(this.getLastSubpath().getLastPoint(),h)),this.hasSubpaths()||this.addSubpath(new ea),this.getLastSubpath().addPoint(h),this.getLastSubpath().addPoint(l),this.addSegmentAndBounds(o),this.resetControlPoints(),this}close(){if(this.hasSubpaths()){var t=this.getLastSubpath(),e=new ea;t.close(),this.addSubpath(e),e.addPoint(t.getFirstPoint())}return this.resetControlPoints(),this}newSubpath(){return this.addSubpath(new ea),this.resetControlPoints(),this}makeImmutable(){return this._immutable=!0,this.notifyInvalidationListeners(),this}isImmutable(){return this._immutable}ellipticalArcToRelative(t,e,i,s,n,r,a){var o=this.getRelativePoint();return this.ellipticalArcTo(t,e,i,s,n,r+o.x,a+o.y)}ellipticalArcTo(t,e,i,s,n,r,a){var o=new Is(r,a);this.ensure(o);var h=this.getLastSubpath().getLastPoint();this.getLastSubpath().addPoint(o),t<0&&(t*=-1),e<0&&(e*=-1);var l=t*t,d=e*e,u=h.minus(o).dividedScalar(2).rotated(-i),c=u.x*u.x,m=u.y*u.y,p=new Is(t*u.y/e,-e*u.x/t),g=c/l+m/d;g>1&&(l=(t*=Math.sqrt(g))*t,d=(e*=Math.sqrt(g))*e,p=new Is(t*u.y/e,-e*u.x/t)),p.multiplyScalar(Math.sqrt(Math.max(0,(l*d-l*m-d*c)/(l*m+d*c)))),s===n&&p.multiplyScalar(-1);var v=h.blend(o,.5).plus(p.rotated(i));function f(t,e){return(t.x*e.y-t.y*e.x>0?1:-1)*t.angleBetween(e)}var y=new Is((u.x-p.x)/t,(u.y-p.y)/e),b=new Is((-u.x-p.x)/t,(-u.y-p.y)/e),P=f(Is.X_UNIT,y),w=f(y,b)%(2*Math.PI);!n&&w>0&&(w-=2*Math.PI),n&&w<0&&(w+=2*Math.PI);var x=new Jr(v,t,e,i,P,P+w,!n).getNondegenerateSegments();return _.each(x,t=>{this.addSegmentAndBounds(t)}),this}circle(t,e,i){if("object"==typeof t){var s=t;return i=e,this.arcPoint(s,i,0,2*Math.PI,!1).close()}return this.arcPoint(sa(t,e),i,0,2*Math.PI,!1).close()}ellipse(t,e,i,s,n){if("object"==typeof t){var r=t;return n=s,s=i,i=e,this.ellipticalArcPoint(r,i,s,n||0,0,2*Math.PI,!1).close()}return this.ellipticalArcPoint(sa(t,e),i,s,n||0,0,2*Math.PI,!1).close()}rect(t,e,i,s){var n=new ea;return this.addSubpath(n),n.addPoint(sa(t,e)),n.addPoint(sa(t+i,e)),n.addPoint(sa(t+i,e+s)),n.addPoint(sa(t,e+s)),this.addSegmentAndBounds(new Nr(n.points[0],n.points[1])),this.addSegmentAndBounds(new Nr(n.points[1],n.points[2])),this.addSegmentAndBounds(new Nr(n.points[2],n.points[3])),n.close(),this.addSubpath(new ea),this.getLastSubpath().addPoint(sa(t,e)),this.resetControlPoints(),this}roundRect(t,e,i,s,n,r){var a=t+n,o=t+i-n,h=e+r,l=e+s-r;return n===r?this.arc(o,h,n,-Math.PI/2,0,!1).arc(o,l,n,0,Math.PI/2,!1).arc(a,l,n,Math.PI/2,Math.PI,!1).arc(a,h,n,Math.PI,3*Math.PI/2,!1).close():this.ellipticalArc(o,h,n,r,0,-Math.PI/2,0,!1).ellipticalArc(o,l,n,r,0,0,Math.PI/2,!1).ellipticalArc(a,l,n,r,0,Math.PI/2,Math.PI,!1).ellipticalArc(a,h,n,r,0,Math.PI,3*Math.PI/2,!1).close(),this}polygon(t){var e=t.length;if(e>0){this.moveToPoint(t[0]);for(var i=1;it.copy()),this.bounds)}writeToContext(t){for(var e=this.subpaths.length,i=0;ie.transformed(t)),i=_.reduce(e,(t,e)=>t.union(e.bounds),mn.NOTHING);return new ra(e,i)}nonlinearTransformed(t){t=b({minLevels:0,maxLevels:7,distanceEpsilon:.16,curveEpsilon:t&&t.includeCurvature?.002:null},t);var e=_.map(this.subpaths,e=>e.nonlinearTransformed(t)),i=_.reduce(e,(t,e)=>t.union(e.bounds),mn.NOTHING);return new ra(e,i)}polarToCartesian(t){return this.nonlinearTransformed(b({pointMap:t=>Is.createPolar(t.y,t.x),methodName:"polarToCartesian"},t))}toPiecewiseLinear(t){return this.nonlinearTransformed(t)}containsPoint(t){var e=new Sn(t,Is.X_UNIT);return 0!==this.windingIntersection(e)}intersection(t){for(var e=[],i=this.subpaths.length,s=0;st.distance)}interiorIntersectsLineSegment(t,e){var i=t.blend(e,.5);if(this.containsPoint(i))return!0;var s=e.minus(t),n=s.magnitude;if(0===n)return!1;s.normalize();for(var r=this.intersection(new Sn(t,s)),a=0;a=t.minX&&e.x<=t.maxX)return!0;var h=this.intersection(n).concat(this.intersection(a));for(i=0;i=t.minY&&e.y<=t.maxY)return!0;return!1}getStrokedShape(t){for(var e=[],i=mn.NOTHING.copy(),s=this.subpaths.length,n=0;ns.dashed(t,e,i.distanceEpsilon,i.curveEpsilon))))}getBounds(){if(null===this._bounds){var t=mn.NOTHING.copy();_.each(this.subpaths,e=>{t.includeBounds(e.getBounds())}),this._bounds=t}return this._bounds}get bounds(){return this.getBounds()}getStrokedBounds(t){for(var e=!0,i=0;i_.sum(t.getFillSegments().map(t=>t.getSignedAreaFragment())))))}getArea(){return this.getSimplifiedAreaShape().getNonoverlappingArea()}getApproximateCentroid(t){for(var e=this.bounds.minX,i=this.bounds.minY,s=this.bounds.width,n=this.bounds.height,r=0,a=new Is(0,0),o=new Is(0,0),h=0;h0}getLastSubpath(){return _.last(this.subpaths)}getLastPoint(){return this.hasSubpaths()?this.getLastSubpath().getLastPoint():null}getLastSegment(){if(!this.hasSubpaths())return null;var t=this.getLastSubpath();return t.isDrawable()?t.getLastSegment():null}getSmoothQuadraticControlPoint(){var t=this.getLastPoint();return this.lastQuadraticControlPoint?t.plus(t.minus(this.lastQuadraticControlPoint)):t}getSmoothCubicControlPoint(){var t=this.getLastPoint();return this.lastCubicControlPoint?t.plus(t.minus(this.lastCubicControlPoint)):t}getRelativePoint(){var t=this.getLastPoint();return t||Is.ZERO}shapeUnion(t){return Ra.binaryResult(this,t,Ra.BINARY_NONZERO_UNION)}shapeIntersection(t){return Ra.binaryResult(this,t,Ra.BINARY_NONZERO_INTERSECTION)}shapeDifference(t){return Ra.binaryResult(this,t,Ra.BINARY_NONZERO_DIFFERENCE)}shapeXor(t){return Ra.binaryResult(this,t,Ra.BINARY_NONZERO_XOR)}shapeClip(t,e){return Ra.clipShape(t,this,e)}getArcLength(t,e,i){for(var s=0,n=0;nt.serialize())}}static deserialize(t){return new ra(t.subpaths.map(ea.deserialize))}static rectangle(t,e,i,s){return(new ra).rect(t,e,i,s)}static roundRect(t,e,i,s,n,r){return(new ra).roundRect(t,e,i,s,n,r)}static roundedRectangleWithRadii(t,e,i,s,n){var r=n&&n.topLeft||0,a=n&&n.topRight||0,o=n&&n.bottomLeft||0,h=n&&n.bottomRight||0,l=new Pr.Shape,d=t+i,u=e+s;return h>0?l.arc(d-h,u-h,h,0,Math.PI/2,!1):l.moveTo(d,u),o>0?l.arc(t+o,u-o,o,Math.PI/2,Math.PI,!1):l.lineTo(t,u),r>0?l.arc(t+r,e+r,r,Math.PI,3*Math.PI/2,!1):l.lineTo(t,e),a>0?l.arc(d-a,e+a,a,3*Math.PI/2,2*Math.PI,!1):l.lineTo(d,e),l.close(),l}static boundsOffsetWithRadii(t,e,i){var s=t.withOffsets(e.left,e.top,e.right,e.bottom);return ra.roundedRectangleWithRadii(s.minX,s.minY,s.width,s.height,i)}static polygon(t){return(new ra).polygon(t)}static bounds(t){return(new ra).rect(t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY)}static lineSegment(t,e,i,s){return"number"==typeof t?(new ra).moveTo(t,e).lineTo(i,s):(new ra).moveToPoint(t).lineToPoint(e)}static regularPolygon(t,e){var i=new ra;return _.each(_.range(t),s=>{var n=Is.createPolar(e,2*Math.PI*s/t);0===s?i.moveToPoint(n):i.lineToPoint(n)}),i.close()}static circle(t,e,i){return void 0===e?(new ra).circle(0,0,t):(new ra).circle(t,e,i)}static ellipse(t,e,i,s,n){return void 0===s?(new ra).ellipse(0,0,t,e,i):(new ra).ellipse(t,e,i,s,n)}static arc(t,e,i,s,n,r){return(new ra).arc(t,e,i,s,n,r)}static union(t){return Ra.unionNonZero(t)}static intersection(t){return Ra.intersectionNonZero(t)}static xor(t){return Ra.xorNonZero(t)}static segments(t,e){return new ra([new ea(t,void 0,!!e)])}}Pr.register("Shape",ra),ra.rect=ra.rectangle,ra.roundRectangle=ra.roundRect;var aa=ra,oa=0;class ha{constructor(t,e){this.id=++oa,this.initialize(t,e)}initialize(t,e){return this.edge=t,this.face=null,this.isReversed=e,this.signedAreaFragment=t.signedAreaFragment*(e?-1:1),this.startVertex=null,this.endVertex=null,this.sortVector=this.sortVector||new Is(0,0),this.data=null,this.updateReferences(),this}serialize(){return{type:"HalfEdge",id:this.id,edge:this.edge.id,face:null===this.face?null:this.face.id,isReversed:this.isReversed,signedAreaFragment:this.signedAreaFragment,startVertex:null===this.startVertex?null:this.startVertex.id,endVertex:null===this.endVertex?null:this.endVertex.id,sortVector:Is.Vector2IO.toStateObject(this.sortVector),data:this.data}}dispose(){this.edge=null,this.face=null,this.startVertex=null,this.endVertex=null,this.data=null,this.freeToPool()}getNext(t){for(var e=1;;e++){var i=this.endVertex.incidentHalfEdges.indexOf(this)-e;i<0&&(i+=this.endVertex.incidentHalfEdges.length);var s=this.endVertex.incidentHalfEdges[i].getReversed();if(!t||t(s.edge))return s}}updateReferences(){this.startVertex=this.isReversed?this.edge.endVertex:this.edge.startVertex,this.endVertex=this.isReversed?this.edge.startVertex:this.edge.endVertex}getEndTangent(){return this.isReversed?this.edge.segment.startTangent:this.edge.segment.endTangent.negated()}getEndCurvature(){return this.isReversed?-this.edge.segment.curvatureAt(0):this.edge.segment.curvatureAt(1)}getReversed(){return this.isReversed?this.edge.forwardHalf:this.edge.reversedHalf}getDirectionalSegment(){return this.isReversed?this.edge.segment.reversed():this.edge.segment}}Pr.register("HalfEdge",ha),Ui.mixInto(ha);var la=ha,da=0;class ua{constructor(t){this.id=++da,this.initialize(t)}initialize(t){return this.point=t,this.incidentHalfEdges=ri(this.incidentHalfEdges),this.visited=!1,this.visitIndex=0,this.lowIndex=0,this.data=null,this.internalData={},this}serialize(){return{type:"Vertex",id:this.id,point:Is.Vector2IO.toStateObject(this.point),incidentHalfEdges:this.incidentHalfEdges.map(t=>t.id),visited:this.visited,visitIndex:this.visitIndex,lowIndex:this.lowIndex}}dispose(){this.point=Is.ZERO,ri(this.incidentHalfEdges),this.freeToPool()}sortEdges(){for(var t=[],e=0;e1e-5||i!==s&&t.edge.segment instanceof Nr&&e.edge.segment instanceof Nr)return i1e-5)return nt.id),windingMap:this.windingMap,filled:this.filled}}dispose(){this.boundary=null,ri(this.holes),this.windingMap=null,this.filled=null,this.freeToPool()}addBoundaryFaceReferences(t){for(var e=0;et.id)}}toSubpath(){for(var t=[],e=0;et.id),signedArea:this.signedArea,bounds:mn.Bounds2IO.toStateObject(this.bounds),childBoundaries:this.childBoundaries.map(t=>t.id)}}dispose(){this.halfEdges=[],ri(this.childBoundaries),this.freeToPool()}isInner(){return this.signedArea>0}computeSignedArea(){for(var t=0,e=0;e=0;b--)a[b].pushSubdivisions(y);a=y}return a}static boxIntersects(t,e,i,s){var n=Math.max(Math.min(t.x,e.x),Math.min(i.x,s.x)),r=Math.max(Math.min(t.y,e.y),Math.min(i.y,s.y)),a=Math.min(Math.max(t.x,e.x),Math.max(i.x,s.x)),o=Math.min(Math.max(t.y,e.y),Math.max(i.y,s.y));return a-n>=0&&o-r>=0}static cleanPool(){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:1e-6;this.rootNode=Da.createFromPool(this,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),this.rootNode.isBlack=!0,this.epsilon=t,this.items=new Set}query(t,e){var i=Aa++;return!!this.rootNode&&this.rootNode.query(t,this.getMinX(t,this.epsilon),this.getMaxX(t,this.epsilon),i,e)}addItem(t){var e=this.getMinX(t,this.epsilon),i=this.getMaxX(t,this.epsilon);this.rootNode.split(e,this),this.rootNode.split(i,this),this.rootNode.addItem(t,e,i),this.items.add(t)}removeItem(t){this.rootNode.removeItem(t,this.getMinX(t,this.epsilon),this.getMaxX(t,this.epsilon)),this.items.delete(t)}audit(){this.rootNode.audit(this.epsilon,this.items,[])}toString(){var t=0,e="";return function i(s){e+="".concat(_.repeat(" ",t)).concat(s.toString(),"\n"),t++,s.hasChildren()&&(i(s.left),i(s.right)),t--}(this.rootNode),e}}class Da{constructor(t,e,i){this.items=[],this.initialize(t,e,i)}initialize(t,e,i){return this.min=e,this.max=i,this.splitValue=null,this.left=null,this.right=null,this.parent=null,this.tree=t,this.isBlack=!1,ri(this.items),this}contains(t){return t>=this.min&&t<=this.max}hasChildren(){return null!==this.splitValue}query(t,e,i,s,n){var r=!1;if(this.min<=i&&this.max>=e){for(var a=0;a=0;a--){var o=i.items[a],h=s.items.indexOf(o);h>=0&&(i.items.splice(a,1),s.items.splice(h,1),this.items.push(o))}s.items.push(...e.items),n.items.push(...e.items),ri(e.items),e.items.push(...r)}}rightRotate(t){var e=this.left,i=this.right,s=e.left,n=e.right;e.parent=this.parent,this.parent?this.parent.swapChild(this,e):t.rootNode=e,this.parent=e,n.parent=this,e.right=this,this.left=n,this.right=i,this.min=n.min,this.splitValue=i.min,e.max=this.max,e.splitValue=this.min;var r=ri(Ea);r.push(...this.items),ri(this.items);for(var a=i.items.length-1;a>=0;a--){var o=i.items[a],h=n.items.indexOf(o);h>=0&&(i.items.splice(a,1),n.items.splice(h,1),this.items.push(o))}s.items.push(...e.items),n.items.push(...e.items),ri(e.items),e.items.push(...r)}fixRedBlack(t){if(this.parent){var e=this.parent;if(!e.isBlack){var i=e.parent,s=i.otherChild(e);s.isBlack?e===i.left?this===e.right?(e.leftRotate(t),e.parent.isBlack=!0,e.parent.parent.isBlack=!1,e.parent.parent.rightRotate(t)):(e.isBlack=!0,i.isBlack=!1,i.rightRotate(t)):this===e.left?(e.rightRotate(t),e.parent.isBlack=!0,e.parent.parent.isBlack=!1,e.parent.parent.leftRotate(t)):(e.isBlack=!0,i.isBlack=!1,i.leftRotate(t)):(e.isBlack=!0,s.isBlack=!0,i.isBlack=!1,i.fixRedBlack(t))}}else this.isBlack=!0}split(t,e){if(t!==this.min&&t!==this.max)if(this.hasChildren())this.splitValue!==t&&(t>this.splitValue?this.right:this.left).split(t,e);else{this.splitValue=t;var i=Da.createFromPool(this.tree,this.min,t);i.parent=this,this.left=i;var s=Da.createFromPool(this.tree,t,this.max);if(s.parent=this,this.right=s,!this.isBlack&&this.parent){var n=this.parent,r=n.otherChild(this);r.isBlack?(this===n.left?(n.rightRotate(e),i.isBlack=!0):(n.leftRotate(e),s.isBlack=!0),this.fixRedBlack(e)):(this.isBlack=!0,r.isBlack=!0,n.isBlack=!1,n.fixRedBlack(e))}}}addItem(t,e,i){this.min>i||this.max=e&&this.max<=i?this.items.push(t):this.hasChildren()&&(this.left.addItem(t,e,i),this.right.addItem(t,e,i)))}removeItem(t,e,i){this.min>i||this.max=e&&this.max<=i?tt(this.items,t):this.hasChildren()&&(this.left.removeItem(t,e,i),this.right.removeItem(t,e,i)))}audit(t,e){}toString(){return"[".concat(this.min," ").concat(this.max,"] split:").concat(this.splitValue," ").concat(this.isBlack?"black":"red"," ").concat(this.items)}}Ui.mixInto(Da),Pr.register("SegmentTree",Ca);class Ia extends Ca{getMinX(t,e){return t.segment.bounds.left-e}getMaxX(t,e){return t.segment.bounds.right+e}}Pr.register("EdgeSegmentTree",Ia);class La extends Ca{getMinX(t,e){return t.point.x-e}getMaxX(t,e){return t.point.x+e}}Pr.register("VertexSegmentTree",La);var ka=0,Ma=0;class Oa{constructor(){this.vertices=[],this.edges=[],this.innerBoundaries=[],this.outerBoundaries=[],this.boundaries=[],this.shapeIds=[],this.loops=[],this.unboundedFace=ya.createFromPool(null),this.faces=[this.unboundedFace]}serialize(){return{type:"Graph",vertices:this.vertices.map(t=>t.serialize()),edges:this.edges.map(t=>t.serialize()),boundaries:this.boundaries.map(t=>t.serialize()),innerBoundaries:this.innerBoundaries.map(t=>t.id),outerBoundaries:this.outerBoundaries.map(t=>t.id),shapeIds:this.shapeIds,loops:this.loops.map(t=>t.serialize()),unboundedFace:this.unboundedFace.id,faces:this.faces.map(t=>t.serialize())}}static deserialize(t){var e=new Oa,i={},s={},n={},r={},a={},o={};return e.vertices=t.vertices.map(t=>{var e=new ca(Is.Vector2IO.fromStateObject(t.point));return i[t.id]=e,e.visited=t.visited,e.visitIndex=t.visitIndex,e.lowIndex=t.lowIndex,e}),e.edges=t.edges.map(t=>{var e=new ga(Mr.deserialize(t.segment),i[t.startVertex],i[t.endVertex]);s[t.id]=e,e.signedAreaFragment=t.signedAreaFragment;var r=(t,e)=>{n[e.id]=t,t.isReversed=e.isReversed,t.signedAreaFragment=e.signedAreaFragment,t.startVertex=i[e.startVertex.id],t.endVertex=i[e.endVertex.id],t.sortVector=Is.Vector2IO.fromStateObject(e.sortVector),t.data=e.data};return r(e.forwardHalf,t.forwardHalf),r(e.reversedHalf,t.reversedHalf),e.visited=t.visited,e.data=t.data,e}),t.vertices.forEach((t,i)=>{e.vertices[i].incidentHalfEdges=t.incidentHalfEdges.map(t=>n[t])}),e.boundaries=t.boundaries.map(t=>{var e=new Ta(t.halfEdges.map(t=>n[t]));return r[t.id]=e,e.signedArea=t.signedArea,e.bounds=mn.Bounds2IO.fromStateObject(t.bounds),e}),t.boundaries.forEach((t,i)=>{e.boundaries[i].childBoundaries=t.childBoundaries.map(t=>r[t])}),e.innerBoundaries=t.innerBoundaries.map(t=>r[t]),e.outerBoundaries=t.outerBoundaries.map(t=>r[t]),e.shapeIds=t.shapeIds,e.loops=t.loops.map(t=>{var e=new Pa(t.shapeId,t.closed);return a[t.id]=e,e.halfEdges=t.halfEdges.map(t=>n[t]),e}),e.faces=t.faces.map((t,i)=>{var s=0===i?e.unboundedFace:new ya(r[t.boundary]);return o[t.id]=s,s.holes=t.holes.map(t=>r[t]),s.windingMap=t.windingMap,s.filled=t.filled,s}),t.edges.forEach((t,i)=>{var s=e.edges[i];s.forwardHalf.face=null===t.forwardHalf.face?null:o[t.forwardHalf.face],s.reversedHalf.face=null===t.reversedHalf.face?null:o[t.reversedHalf.face]}),e}addShape(t,e,i){for(var s=0;s=0;a--){var o=r.halfEdges[a];if(o.edge===t){var h=o===t.forwardHalf?e:i;Array.prototype.splice.apply(r.halfEdges,[a,1].concat(h))}}}collapseAdjacentEdges(){for(var t=!0;t;){t=!1;for(var e=0;e{var i=t.segment.bounds;e.push({start:!0,edge:t},i.minY-1e-4),e.push({start:!1,edge:t},i.maxY+1e-4)},r=t=>{t.internalData.removedId=s},a=0;a{var i=h.segment.getOverlaps(e.segment);if(null!==i&&i.length)for(var s=0;s1e-5&&Math.abs(n.qt1-n.qt0)>1e-5)return d=t.splitOverlap(h,e,n),u=!0,l=e,!0}return!1}),u){i.removeItem(l),r(l),r(h);for(var c=0;c.99999&&(o=1),h<1e-5&&(h=0),l>.99999&&(l=1);var d,u,c=a>0?n.subdivided(a)[0]:null,m=h>0?r.subdivided(h)[0]:null,p=o<1?n.subdivided(o)[1]:null,g=l<1?r.subdivided(l)[1]:null,v=n;a>0&&(v=v.subdivided(a)[1]),o<1&&(v=v.subdivided(Vs.linear(a,1,0,1,o))[0]),c&&m?(d=ca.createFromPool(v.start),this.vertices.push(d)):d=c?i.a>0?e.startVertex:e.endVertex:t.startVertex,p&&g?(u=ca.createFromPool(v.end),this.vertices.push(u)):u=p?i.a>0?e.endVertex:e.startVertex:t.endVertex;var f,y,b,_,P=ga.createFromPool(v,d,u);s.push(P),c&&(f=ga.createFromPool(c,t.startVertex,d),s.push(f)),p&&(y=ga.createFromPool(p,u,t.endVertex),s.push(y)),m&&(b=ga.createFromPool(m,e.startVertex,i.a>0?d:u),s.push(b)),g&&(_=ga.createFromPool(g,i.a>0?u:d,e.endVertex),s.push(_));for(var w=0;w0;A.push(D?T[C].forwardHalf:T[C].reversedHalf)}return this.replaceEdgeInLoops(t,S),this.replaceEdgeInLoops(e,A),s}eliminateSelfIntersection(){for(var t=this.edges.length-1;t>=0;t--){var e=this.edges[t],i=e.segment;if(i instanceof qr){var s=i.getSelfIntersection();if(s){var n=i.subdivisions([s.aT,s.bT]),r=ca.createFromPool(s.point);this.vertices.push(r);var a=ga.createFromPool(n[0],e.startVertex,r),o=ga.createFromPool(n[1],r,r),h=ga.createFromPool(n[2],r,e.endVertex);this.removeEdge(e),this.addEdge(a),this.addEdge(o),this.addEdge(h),this.replaceEdgeInLoops(e,[a.forwardHalf,o.forwardHalf,h.forwardHalf]),e.dispose()}}}}eliminateIntersection(){for(var t=this,e=new window.FlatQueue,i=new Ia(1e-4),s=Ma++,n=t=>{var i=t.segment.bounds;e.push({start:!0,edge:t},i.minY-1e-4),e.push({start:!1,edge:t},i.maxY+1e-4)},r=t=>{t.internalData.removedId=s},a=0;a{var i=h.segment,s=e.segment,n=Mr.intersect(i,s);if((n=n.filter(t=>{var e=t.aT,i=t.bT;return e>1e-5&&e<.99999||i>1e-5&&i<.99999})).length){var r=n[0],a=t.simpleSplit(h,e,r.aT,r.bT,r.point);if(a)return c=!0,l=e,d=a.addedEdges,u=a.removedEdges,!0}return!1}),c){u.includes(h)?(r(h),o.push(h)):i.addItem(h),u.includes(l)&&(i.removeItem(l),r(l),o.push(l));for(var m=0;m1e-6&&i<.999999,a=s>1e-6&&s<.999999,o=null;r?a?(o=ca.createFromPool(n),this.vertices.push(o)):o=s<.5?e.startVertex:e.endVertex:o=i<.5?t.startVertex:t.endVertex;var h=!1,l=[],d=[];return r&&o!==t.startVertex&&o!==t.endVertex&&(l.push(...this.splitEdge(t,i,o)),d.push(t),h=!0),a&&o!==e.startVertex&&o!==e.endVertex&&(l.push(...this.splitEdge(e,s,o)),d.push(e),h=!0),h?{addedEdges:l,removedEdges:d}:null}splitEdge(t,e,i){var s=t.segment.subdivided(e),n=ga.createFromPool(s[0],t.startVertex,i),r=ga.createFromPool(s[1],i,t.endVertex);return this.removeEdge(t),this.addEdge(n),this.addEdge(r),this.replaceEdgeInLoops(t,[n.forwardHalf,r.forwardHalf]),[n,r]}collapseVertices(){for(var t=this,e=new window.FlatQueue,i=new La(1e-4),s=Ma++,n=t=>{e.push({start:!0,vertex:t},t.point.y-1e-4),e.push({start:!1,vertex:t},t.point.y+1e-4)},r=t=>{t.internalData.removedId=s},a=0;a{var i=h.point.distance(e.point);if(i<1e-5){var s=ca.createFromPool(0===i?h.point:h.point.average(e.point));t.vertices.push(s),tt(t.vertices,h),tt(t.vertices,e);for(var n=t.edges.length-1;n>=0;n--){var r=t.edges[n],a=r.startVertex===h||r.startVertex===e,o=r.endVertex===h||r.endVertex===e;if(a&&o){if((r.segment.bounds.width>1e-5||r.segment.bounds.height>1e-5)&&(r.segment instanceof qr||r.segment instanceof Zr||r.segment instanceof Jr)){var c=ga.createFromPool(r.segment,s,s);t.addEdge(c),t.replaceEdgeInLoops(r,[c.forwardHalf])}else t.replaceEdgeInLoops(r,[]);t.removeEdge(r),r.dispose()}else a?(r.startVertex=s,s.incidentHalfEdges.push(r.reversedHalf),r.updateReferences()):o&&(r.endVertex=s,s.incidentHalfEdges.push(r.forwardHalf),r.updateReferences())}return d=[s],u=!0,l=e,!0}return!1}),u){i.removeItem(l),r(l),r(h);for(var c=0;ce.visitIndex&&t.push(s))}}removeBridges(){for(var t=[],e=0;e=0;e--){var i=this.vertices[e];if(i.incidentHalfEdges.length<2){for(var s=0;s0?this.innerBoundaries:this.outerBoundaries).push(r),this.boundaries.push(r)}for(var a=0;a=0;s--){var n=t[s],r=n.forwardHalf,a=n.reversedHalf,o=r.face,h=a.face,l=null!==o.windingMap,d=null!==h.windingMap;if(l&&d){t.splice(s,1)}else{if(!l&&!d)continue;for(var u=l?o:h,c=l?h:o,m={},p=0;p{for(var i=0;i{for(var i=0;i{for(var i=!1,s=0;s0!==t[0]);var i=e.createFilledSubGraph(),s=i.facesToShape();return e.dispose(),i.dispose(),s}static clipShape(t,e,i){var s,n,r;i=b({includeExterior:!1,includeBoundary:!0,includeInterior:!0},i);var a=Oa.simplifyNonZero(t),o=new Oa;for(o.addShape(0,e,{ensureClosed:!1}),o.addShape(1,a),o.eliminateOverlap(),o.eliminateSelfIntersection(),o.eliminateIntersection(),o.collapseVertices(),s=0;s{this.attributeLocations[t]=this.gl.getAttribLocation(this.program,t),this.activeAttributes[t]=!0}),_.each(this.uniformNames,t=>{this.uniformLocations[t]=this.gl.getUniformLocation(this.program,t)}),this.isInitialized=!0}use(){this.used||(this.used=!0,this.gl.useProgram(this.program),_.each(this.attributeNames,t=>{this.activeAttributes[t]&&this.enableVertexAttribArray(t)}))}activateAttribute(t){this.activeAttributes[t]||(this.activeAttributes[t]=!0,this.used&&this.enableVertexAttribArray(t))}enableVertexAttribArray(t){this.gl.enableVertexAttribArray(this.attributeLocations[t])}unuse(){this.used&&(this.used=!1,_.each(this.attributeNames,t=>{this.activeAttributes[t]&&this.disableVertexAttribArray(t)}))}disableVertexAttribArray(t){this.gl.disableVertexAttribArray(this.attributeLocations[t])}deactivateAttribute(t){this.activeAttributes[t]&&(this.activeAttributes[t]=!1,this.used&&this.disableVertexAttribArray(t))}dispose(){this.gl.deleteProgram(this.program)}}bs.register("ShaderProgram",ja);class qa extends me{constructor(t,e){super(t,w()({valueType:Us,phetioValueType:Us.ColorIO},e))}}bs.register("ColorProperty",qa);var Ka,Za,Qa={},Ja=!1,$a={approximateSVGBounds(t,e){if(!Ka.parentNode){if(!document.body)throw new Error("No document.body and trying to get approximate SVG bounds of a Text node");document.body.appendChild(Ka)}$a.setSVGTextAttributes(Za,t,e);var i=Za.getBBox();return 0===i.width&&0===i.height&&e.length>0?(Ja||(Ja=!0,console.log("WARNING: Guessing text bounds, is the simulation hidden? See https://github.com/phetsims/chipper/issues/768")),$a.guessSVGBounds(t,e)):new mn(i.x,i.y,i.x+i.width,i.y+i.height)},guessSVGBounds(t,e){var i=t.getNumericSize(),s="bold"===t.weight;return new mn(0,-.9*i,(s?.435:.4)*i*e.length,.22*i)},accurateCanvasBounds(t){var e=$a.approximateSVGBounds(t._font,t.renderedText);if(!t.renderedText.length||0===e.width)return e;var i=Rn.canvasAccurateBounds(e=>{if(e.font=t._font.toCSS(),e.direction="ltr",e.fillText(t.renderedText,0,0),t.hasPaintableStroke()){var i=new rr(null,e);t.beforeCanvasStroke(i),e.strokeText(t.renderedText,0,0),t.afterCanvasStroke(i)}},{precision:.5,resolution:128,initialScale:32/Math.max(Math.abs(e.minX),Math.abs(e.minY),Math.abs(e.maxX),Math.abs(e.maxY))});return i.isFinite()?i:e},getVerticalBounds(t){var e=t.toCSS(),i=Qa[e];return i||(i=Qa[e]=$a.approximateSVGBounds(t,"m")),i},approximateCanvasWidth(t,e){var i=bs.scratchContext;return i.font=t.toCSS(),i.direction="ltr",i.measureText(e).width},approximateHybridBounds(t,e){var i=$a.getVerticalBounds(t),s=$a.approximateCanvasWidth(t,e);return new mn(0,i.minY,s,i.maxY)},approximateDOMBounds(t,e){var i=document.createElement("div");$(i).css({position:"absolute",left:0,top:0,padding:"0 !important",margin:"0 !important",display:"hidden"});var s=document.createElement("span");$(s).css("font",t.toCSS()),s.appendChild(e),s.setAttribute("direction","ltr");var n=document.createElement("div");$(n).css({"vertical-align":"baseline",display:"inline-block",width:0,height:"".concat(1024,"px"),margin:"0 !important",padding:"0 !important"}),i.appendChild(s),i.appendChild(n),document.body.appendChild(i);var r=s.getBoundingClientRect(),a=i.getBoundingClientRect(),o=new mn(r.left,r.top-1024,r.right+1,r.bottom-1024).shiftedXY(-a.left,-a.top);return document.body.removeChild(i),o},approximateImprovedDOMBounds(t,e){var i=document.createElement("div");i.style.display="inline-block",i.style.font=t.toCSS(),i.style.color="transparent",i.style.padding="0 !important",i.style.margin="0 !important",i.style.position="absolute",i.style.left="0",i.style.top="0",i.setAttribute("direction","ltr"),i.appendChild(e),document.body.appendChild(i);var s=new mn(i.offsetLeft,i.offsetTop,i.offsetLeft+i.offsetWidth+1,i.offsetTop+i.offsetHeight+1);document.body.removeChild(i);var n=$a.getVerticalBounds(t);return s.shiftedY(n.minY)},setSVGTextAttributes(t,e,i){t.setAttribute("direction","ltr"),t.setAttribute("font-family",e.getFamily()),t.setAttribute("font-size",e.getSize()),t.setAttribute("font-style",e.getStyle()),t.setAttribute("font-weight",e.getWeight()),t.setAttribute("font-stretch",e.getStretch()),t.lastChild.nodeValue=i},initializeTextBounds(){(Ka=document.getElementById("sceneryTextSizeContainer"))||((Ka=document.createElementNS(ln,"svg")).setAttribute("width","2"),Ka.setAttribute("height","2"),Ka.setAttribute("id","sceneryTextSizeContainer"),Ka.setAttribute("style","visibility: hidden; pointer-events: none; position: absolute; left: -65535px; right: -65535px;")),(Za=document.getElementById("sceneryTextSizeElement"))||((Za=document.createElementNS(ln,"text")).appendChild(document.createTextNode("")),Za.setAttribute("dominant-baseline","alphabetic"),Za.setAttribute("text-rendering","geometricPrecision"),Za.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),Za.setAttribute("id","sceneryTextSizeElement"),Ka.appendChild(Za))}};bs.register("TextBounds",$a);var to=$a;class eo{constructor(t,e,i){this.pdomInstance=t,this.trail=e,this.isRoot=i,this.fullTrail=this.pdomInstance.trail.copy();for(var s=this.isRoot?0:1;s=0;){var a=i[r];if(r+=n,po.isElementFocusable(a))return a}return s}function mo(t){return!_.includes(lo,t.toUpperCase())}var po={getNextFocusable:t=>co("NEXT",t),getPreviousFocusable:t=>co("PREVIOUS",t),getFirstFocusable(t){for(var e=uo(t||document.body),i=document.body,s=0;s",e);n>-1&&(i.push(n),e=n+1),r>-1?(s.push(r),e=r+1):e++}if(i.length!==s.length||0===i.length)return!1;for(var a=!0,o=t.toUpperCase(),h=0;h0||(_.includes(ho,l)||(a=!1))}return a},setTextContent(t,e){if(null===e)t.innerHTML="";else{var i=e.replaceAll("
    ","
    "),s=ao(i);R(s,M.STRING_WITHOUT_TEMPLATE_VARS_VALIDATOR),mo(t.tagName)&&(po.containsFormattingTags(s)?t.innerHTML=s:t.textContent=s)}},tagIsDefaultFocusable:t=>_.includes(oo,t.toUpperCase()),isElementFocusable:t=>!!document.body.contains(t)&&(!function t(e){return!!e.hidden||e!==document.body&&t(e.parentElement)}(t)&&(!_.includes(ho,t.tagName)&&"true"===t.getAttribute("data-focusable"))),tagNameSupportsContent:t=>mo(t),removeElements(t,e){for(var i=0;iUs.toColor(t).setImmutable()),super(Us.toColor(i[bo.value]||i[Ps.DEFAULT_COLOR_PROFILE]),n),this.colorProfileMap=i,bo.link(t=>{this.value=Us.toColor(this.colorProfileMap[t]||this.colorProfileMap[Ps.DEFAULT_COLOR_PROFILE])}),this.name="".concat(t.name).concat(".").concat(e),this.link(t=>{window.parent!==window&&window.parent.postMessage(JSON.stringify({type:"reportColor",name:this.name,value:t.toHexString(),alpha:t.getAlpha()}),"*")}),_o.push(this)}dispose(){tt(_o,this),super.dispose()}}_defineProperty(Po,"TANDEM_NAME_SUFFIX","ColorProperty"),window.addEventListener("message",t=>{var e;try{e=JSON.parse(t.data)}catch(n){}if(e&&"setColor"===e.type)for(var i=0;i<_o.length;i++){var s=_o[i];s.name===e.name&&(s.colorProfileMap[bo.value]=new Us(e.value).withAlpha(e.alpha),s.value=Us.toColor(s.colorProfileMap[bo.value]))}}),bs.register("ProfileColorProperty",Po);var wo=1;class xo{constructor(){this.id="paint".concat(wo++),this.transformMatrix=null}setTransformMatrix(t){return this.transformMatrix!==t&&(this.transformMatrix=t),this}toString(){return this.id}}xo.prototype.isPaint=!0,bs.register("Paint",xo);class To extends xo{constructor(){super(),this.stops=[],this.lastStopRatio=0,this.canvasGradient=null,this.colorStopsDirty=!1,this.lastColorStopValues=[]}addColorStop(t,e){if(this.lastStopRatio>t)throw new Error("Color stops not specified in the order of increasing ratios");return this.lastStopRatio=t,this.stops.push({ratio:t,color:e}),this.lastColorStopValues.push(""),this}getSVGStops(){return this.stops}invalidateCanvasGradient(){this.colorStopsDirty=!0}haveCanvasColorStopsChanged(){if(null===this.lastColorStopValues)return!0;for(var t=0;t{t+=".addColorStop( ".concat(e.ratio,", ").concat(Bo.scenerySerialize(e.color)," )")}),t}}So.prototype.isLinearGradient=!0,bs.register("LinearGradient",So);class Ao extends To{constructor(t,e,i,s,n,r){if(super(),this.start=new Is(t,e),this.end=new Is(s,n),Yi.safari){var a=(t+s)/2,o=(e+n)/2;this.start.x=a,this.start.y=o,this.end.x=a,this.end.y=o}this.startRadius=i,this.endRadius=r,this.focalPoint=this.start.plus(this.end.minus(this.start).times(this.startRadius/(this.startRadius-this.endRadius))),this.startIsLarger=this.startRadius>this.endRadius,this.largePoint=this.startIsLarger?this.start:this.end,this.maxRadius=Math.max(this.startRadius,this.endRadius),this.minRadius=Math.min(this.startRadius,this.endRadius),this.startRadius,this.endRadius}createCanvasGradient(){return bs.scratchContext.createRadialGradient(this.start.x,this.start.y,this.startRadius,this.end.x,this.end.y,this.endRadius)}createSVGPaint(t){return Ol.pool.create(t,this)}getSVGStops(){var t=this.startIsLarger,e=this.maxRadius,i=this.minRadius;var s=this.stops.map((function(s){var n,r,a=t?1-s.ratio:s.ratio;return i>0&&(a=(r=i/e)+(a-(n=0))*(1-r)/(1-n)),{ratio:a,color:s.color}}));return t&&s.reverse(),s}toString(){var t="new scenery.RadialGradient( ".concat(this.start.x,", ").concat(this.start.y,", ").concat(this.startRadius,", ").concat(this.end.x,", ").concat(this.end.y,", ").concat(this.endRadius," )");return _.each(this.stops,e=>{t+=".addColorStop( ".concat(e.ratio,", ").concat(Bo.scenerySerialize(e.color)," )")}),t}}Ao.prototype.isRadialGradient=!0,bs.register("RadialGradient",Ao);class Eo extends xo{constructor(t){super(),this.image=t,this.canvasPattern=bs.scratchContext.createPattern(t,"repeat")}getCanvasStyle(){return this.canvasPattern}createSVGPaint(t){return Rl.pool.create(this)}toString(){return"new scenery.Pattern( $( '' )[0] )")}}Eo.prototype.isPattern=!0,bs.register("Pattern",Eo);class Co extends Eo{constructor(t,e,i,s,n,r){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:wn.IDENTITY,o=document.createElement("img");new uh({scale:e,children:[t]}).toCanvas((function(t,e,i,s,n){o.src=t.toDataURL()}),-i*e,-s*e,n*e,r*e),super(o),this.setTransformMatrix(a.timesMatrix(wn.scaling(1/e)))}}bs.register("NodePattern",Co);var Do=1;class Io{constructor(){this.id="filter".concat(Do++),this.filterRegionPercentageIncrease=0}isDOMCompatible(){return!1}isSVGCompatible(){return!1}isCanvasCompatible(){return!!Js.canvasFilter&&this.isDOMCompatible()}isWebGLCompatible(){return!1}toString(){return this.id}static applyColorMatrix(t,e,i,s){var n=document.createElementNS(ln,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values",t),n.setAttribute("in",i),n.setAttribute("color-interpolation-filters","sRGB"),s&&n.setAttribute("result",s),e.appendChild(n)}}bs.register("Filter",Io);class Lo extends Error{constructor(){super("CouldNotYetDeserializeError")}}S.register("CouldNotYetDeserializeError",Lo);var ko=Lo,Mo=new Map,Oo=t=>{var e=t;return Mo.has(e)||Mo.set(e,new j("ReferenceIO<".concat(t.typeName,">"),{isValidValue:e=>M.isValueValid(e,t.validator),documentation:"Uses reference identity for serializing and deserializing, and validates based on its parameter IO Type.",parameterTypes:[t],toStateObject:t=>({phetioID:t.tandem.phetioID}),stateSchema:{phetioID:It},fromStateObject(t){if(phet.phetio.phetioEngine.hasPhetioObject(t.phetioID))return phet.phetio.phetioEngine.getPhetioObject(t.phetioID);throw new ko},applyState(t){}})),Mo.get(e)};S.register("ReferenceIO",Oo);var Ro=Oo,No={isColorDef:t=>null===t||"string"==typeof t||t instanceof Us||t instanceof ce&&(null===t.value||"string"==typeof t.value||t.value instanceof Us),scenerySerialize:t=>null===t?"null":t instanceof Us?"'".concat(t.toCSS(),"'"):"string"==typeof t?"'".concat(t,"'"):No.scenerySerialize(t.value),ColorDefIO:null};No.ColorDefIO=new j("ColorDefIO",{isValidValue:No.isColorDef,supertype:Kt(rs([It,Us.ColorIO,Ro(me.PropertyIO(Kt(rs([It,Us.ColorIO]))))]))}),bs.register("ColorDef",No);var Bo=No,Fo={isPaintDef:t=>null===t||"string"==typeof t||t instanceof Us||t instanceof xo||t instanceof ce&&(null===t.value||"string"==typeof t.value||t.value instanceof Us),toColor(t){if("string"==typeof t)return new Us(t);if(t instanceof Us)return t.copy();if(t instanceof ce)return Fo.toColor(t.value);if(t instanceof To){var e=Us.TRANSPARENT;return t.stops.forEach(t=>{e=e.blend(Fo.toColor(t.color),1)}),e}return Us.TRANSPARENT}};bs.register("PaintDef",Fo);var Vo=Fo,Ho=Rn.supportsImageDataCanvasFilter(),Yo=Yi.chromium;class zo extends Io{constructor(t,e,i,s,n,r,a,o,h,l,d,u,c,m,p,g,v,f,y,b){super(),this.m00=t,this.m01=e,this.m02=i,this.m03=s,this.m04=n,this.m10=r,this.m11=a,this.m12=o,this.m13=h,this.m14=l,this.m20=d,this.m21=u,this.m22=c,this.m23=m,this.m24=p,this.m30=g,this.m31=v,this.m32=f,this.m33=y,this.m34=b}applySVGFilter(t,e,i){Io.applyColorMatrix("".concat(_n(this.m00)," ").concat(_n(this.m01)," ").concat(_n(this.m02)," ").concat(_n(this.m03)," ").concat(_n(this.m04)," ")+"".concat(_n(this.m10)," ").concat(_n(this.m11)," ").concat(_n(this.m12)," ").concat(_n(this.m13)," ").concat(_n(this.m14)," ")+"".concat(_n(this.m20)," ").concat(_n(this.m21)," ").concat(_n(this.m22)," ").concat(_n(this.m23)," ").concat(_n(this.m24)," ")+"".concat(_n(this.m30)," ").concat(_n(this.m31)," ").concat(_n(this.m32)," ").concat(_n(this.m33)," ").concat(_n(this.m34)),t,e,i)}applyCanvasFilter(t){for(var e=t.canvas.width,i=t.canvas.height,s=t.context.getImageData(0,0,e,i),n=e*i,r=0;r3&&void 0!==arguments[3]?arguments[3]:15;super(),this.offset=t,this.blurRadius=e,this.color=i,this.colorCSS=Vo.toColor(i).toCSS(),this.filterRegionPercentageIncrease=s}getCSSFilterString(){return"drop-shadow(".concat(_n(this.offset.x),"px ").concat(_n(this.offset.y),"px ").concat(_n(this.blurRadius),"px ").concat(this.colorCSS,")")}isDOMCompatible(){return!0}applyCanvasFilter(){throw new Error("unimplemented")}applySVGFilter(t,e,i){throw new Error("unimplemented")}});bs.register("GaussianBlur",class extends Io{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;super(),this.standardDeviation=t,this.filterRegionPercentageIncrease=e}getCSSFilterString(){return"blur(".concat(_n(this.standardDeviation),"px)")}applySVGFilter(t,e,i){var s=document.createElementNS(ln,"feGaussianBlur");s.setAttribute("stdDeviation",_n(this.standardDeviation)),s.setAttribute("edgeMode","none"),t.appendChild(s),s.setAttribute("in",e),i&&s.setAttribute("result",i),t.appendChild(s)}isDOMCompatible(){return!0}isSVGCompatible(){return!0}applyCanvasFilter(t){throw new Error("unimplemented")}});class Go extends zo{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=1-t;super(.2126+.7874*e,.7152-.7152*e,.0722-.0722*e,0,0,.2126-.2126*e,.7152+.2848*e,.0722-.0722*e,0,0,.2126-.2126*e,.7152-.7152*e,.0722+.9278*e,0,0,0,0,0,1,0),this.amount=t}getCSSFilterString(){return"grayscale(".concat(_n(this.amount),")")}isDOMCompatible(){return!0}}Go.FULL=new Go(1),bs.register("Grayscale",Go);bs.register("HueRotate",class extends zo{constructor(t){var e=Math.cos(t),i=Math.sin(t);super(.213+.787*e-.213*i,.715-.715*e-.715*i,.072-.072*e+.928*i,0,0,.213-.213*e+.143*i,.715+.285*e+.14*i,.072-.072*e-.283*i,0,0,.213-.213*e-.787*i,.715-.715*e+.715*i,.072+.928*e+.072*i,0,0,0,0,0,1,0),this.amount=t}getCSSFilterString(){return"hue-rotate(".concat(_n(Vs.toDegrees(this.amount)),"deg)")}isDOMCompatible(){return!0}});class Xo extends Io{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;super(),this.amount=t}getCSSFilterString(){return"invert(".concat(_n(this.amount),")")}isDOMCompatible(){return!0}applyCanvasFilter(t){throw new Error("unimplemented")}applySVGFilter(t,e,i){throw new Error("unimplemented")}}Xo.FULL=new Xo(1),bs.register("Invert",Xo);bs.register("Opacity",class extends Io{constructor(t){super(),this.amount=t}getCSSFilterString(){return"opacity(".concat(_n(this.amount),")")}isDOMCompatible(){return!0}applyCanvasFilter(t){throw new Error("unimplemented")}applySVGFilter(t,e,i){throw new Error("unimplemented")}});bs.register("Saturate",class extends zo{constructor(t){super(.213+.787*t,.715-.715*t,.072-.072*t,0,0,.213-.213*t,.715-.285*t,.072-.072*t,0,0,.213-.213*t,.715-.715*t,.072-.928*t,0,0,0,0,0,1,0),this.amount=t}getCSSFilterString(){return"saturate(".concat(_n(this.amount),")")}isDOMCompatible(){return!0}});class jo extends zo{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;super(.393+.607*(1-t),.769-.769*(1-t),.189-.189*(1-t),0,0,.349-.349*(1-t),.686+.314*(1-t),.168-.168*(1-t),0,0,.272-.272*(1-t),.534-.534*(1-t),.131+.869*(1-t),0,0,0,0,0,1,0),this.amount=t}getCSSFilterString(){return"sepia(".concat(_n(this.amount),")")}isDOMCompatible(){return!0}}jo.FULL=new jo(1),bs.register("Sepia",jo);go.TAGS.INPUT;var qo=go.TAGS.P,Ko=qo,Zo=qo,Qo=(t,e,i)=>(e.labelTagName="h".concat(t.headingLevel),e.labelContent=i,e),Jo=t=>{var e=null===t?null:"string"==typeof t?t:t.value;return e},$o=(go.FORM_ELEMENTS,go.INPUT_TYPES_THAT_SUPPORT_CHECKED,go.ASSOCIATION_ATTRIBUTES,["focusable","tagName","accessibleName","accessibleNameBehavior","helpText","helpTextBehavior","pdomHeading","pdomHeadingBehavior","containerTagName","containerAriaRole","innerContent","inputType","inputValue","pdomChecked","pdomNamespace","ariaLabel","ariaRole","ariaValueText","labelTagName","labelContent","appendLabel","descriptionTagName","descriptionContent","appendDescription","focusHighlight","focusHighlightLayerable","groupFocusHighlight","pdomVisible","pdomOrder","ariaLabelledbyAssociations","ariaDescribedbyAssociations","activeDescendantAssociations","positionInPDOM","pdomTransformSourceNode"]);class th extends Vt{constructor(t){super(t),this._tagName=null,this._containerTagName=null,this._labelTagName=null,this._descriptionTagName=null,this._inputType=null,this._inputValue=null,this._pdomChecked=!1,this._appendLabel=!1,this._appendDescription=!1,this._pdomAttributes=[],this._pdomClasses=[],this._labelContent=null,this._innerContent=null,this._descriptionContent=null,this._pdomNamespace=null,this._ariaLabel=null,this._ariaRole=null,this._containerAriaRole=null,this._ariaValueText=null,this._ariaLabelledbyAssociations=[],this._nodesThatAreAriaLabelledbyThisNode=[],this._ariaDescribedbyAssociations=[],this._nodesThatAreAriaDescribedbyThisNode=[],this._activeDescendantAssociations=[],this._nodesThatAreActiveDescendantToThisNode=[],this._focusableOverride=null,this._focusHighlight=null,this._focusHighlightLayerable=!1,this._groupFocusHighlight=!1,this._pdomVisible=!0,this._pdomOrder=null,this._pdomParent=null,this._pdomTransformSourceNode=null,this._pdomDisplaysInfo=new _h(this),this._pdomInstances=[],this._positionInPDOM=!1,this.excludeLabelSiblingFromInput=!1,this._accessibleName=null,this._accessibleNameBehavior=th.BASIC_ACCESSIBLE_NAME_BEHAVIOR,this._helpText=null,this._helpTextBehavior=th.HELP_TEXT_AFTER_CONTENT,this._pdomHeading=null,this._headingLevel=null,this._pdomHeadingBehavior=Qo,this.focusHighlightChangedEmitter=new c,this.pdomDisplaysEmitter=new c,this.pdomBoundInputEnabledListener=this.pdomInputEnabledListener.bind(this)}disposeParallelDOM(){this.inputEnabledProperty.unlink(this.pdomBoundInputEnabledListener),this.pdomOrder=null,this.setPDOMTransformSourceNode(null),this.setAriaLabelledbyAssociations([]),this.setAriaDescribedbyAssociations([]),this.setActiveDescendantAssociations([])}pdomInputEnabledListener(t){this.setPDOMAttribute("aria-disabled",!t),this.setPDOMAttribute("onclick",t?"":"return false")}isFocused(){for(var t=0;t0){var t=this._pdomInstances[0].peer;t.focus()}}blur(){if(this._pdomInstances.length>0){var t=this._pdomInstances[0].peer;t.blur()}}pdomAudit(){this.hasPDOMContent;for(var t=0;t1||null!==this._pdomOrder[0])}getPDOMParent(){return this._pdomParent}get pdomParent(){return this.getPDOMParent()}getEffectiveChildren(){for(var t=[],e=0;e=0?(t.unshift(n,1),Array.prototype.splice.apply(s,t)):Array.prototype.push.apply(s,t),s}return t}setPDOMVisible(t){this._pdomVisible!==t&&(this._pdomVisible=t,this._pdomDisplaysInfo.onPDOMVisibilityChange(t))}set pdomVisible(t){this.setPDOMVisible(t)}get pdomVisible(){return this.isPDOMVisible()}isPDOMVisible(){return this._pdomVisible}isPDOMDisplayed(){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:this;if(t.isPhetioInstrumented())return t.phetioIsArchetype;for(var e=0;e{n===t&&a++}),!(a>1||1===a&&!r)){if(n.hasPDOMContent){var o={trail:t.copy(),children:[]};s[s.length-1].push(o),s.push(o.children)}var h=null===n._pdomOrder?[]:n._pdomOrder;e=e.concat(h),_.each(h,e=>{_.each(n.getLeafTrailsTo(e),s=>{s.removeAncestor(),t.addDescendantTrail(s),i(e,!0),t.removeDescendantTrail(s)})});for(var l=n._children.length,d=0;d{e.pop()}),n.hasPDOMContent&&s.pop()}}(this,!1),i}onPDOMContentChange(){Eu.pdomContentChange(this),this._pdomHeading&&this.computeHeadingLevel(),this.rendererSummaryRefreshEmitter.emit()}get hasPDOMContent(){return!!this._tagName}onPDOMAddChild(t){this._pdomDisplaysInfo.onAddChild(t),Eu.addChild(this,t)}onPDOMRemoveChild(t){this._pdomDisplaysInfo.onRemoveChild(t),Eu.removeChild(this,t),t.updateOtherNodesAriaLabelledby(),t.updateOtherNodesAriaDescribedby(),t.updateOtherNodesActiveDescendant()}onPDOMReorderedChildren(){Eu.childrenOrderChange(this)}getPDOMInstances(){return this._pdomInstances}get pdomInstances(){return this.getPDOMInstances()}addPDOMInstance(t){this._pdomInstances.push(t)}removePDOMInstance(t){var e=_.indexOf(this._pdomInstances,t);this._pdomInstances.splice(e,1)}static BASIC_ACCESSIBLE_NAME_BEHAVIOR(t,e,i){return"input"===t.tagName?(e.labelTagName="label",e.labelContent=i):go.tagNameSupportsContent(t.tagName)?e.innerContent=i:e.ariaLabel=i,e}static HELP_TEXT_BEFORE_CONTENT(t,e,i){return e.descriptionTagName=go.DEFAULT_DESCRIPTION_TAG_NAME,e.descriptionContent=i,e.appendDescription=!1,e}static HELP_TEXT_AFTER_CONTENT(t,e,i){return e.descriptionTagName=go.DEFAULT_DESCRIPTION_TAG_NAME,e.descriptionContent=i,e.appendDescription=!0,e}}bs.register("ParallelDOM",th);class eh extends pe{constructor(t,e){var i=w()({phetioDocumentation:"Determines whether the element is enabled (true) or disabled (false).",phetioFeatured:!0,checkTandemName:!0},e);super(t,i)}static get TANDEM_NAME(){return"enabledProperty"}}u.register("EnabledProperty",eh);var ih=1,sh=mn.NOTHING.copy(),nh=mn.NOTHING.copy(),rh=new wn,ah=eh.TANDEM_NAME,oh=["leftTop","centerTop","rightTop","leftCenter","center","rightCenter","leftBottom","centerBottom","rightBottom","left","right","top","bottom","centerX","centerY"],hh=["children","cursor","phetioVisiblePropertyInstrumented","visibleProperty","visible","pickableProperty","pickable","phetioEnabledPropertyInstrumented","enabledProperty","enabled","phetioInputEnabledPropertyInstrumented","inputEnabledProperty","inputEnabled","inputListeners","opacity","disabledOpacity","filters","matrix","translation","x","y","rotation","scale","excludeInvisibleChildrenFromBounds","layoutOptions","localBounds","maxWidth","maxHeight","renderer","layerSplit","usesOpacity","cssTransform","excludeInvisible","webglScale","preventFit","mouseArea","touchArea","clipArea","transformBounds",...oh],lh={phetioVisiblePropertyInstrumented:!0,visible:!0,opacity:1,disabledOpacity:1,pickable:null,enabled:!0,phetioEnabledPropertyInstrumented:!1,inputEnabled:!0,phetioInputEnabledPropertyInstrumented:!1,clipArea:null,mouseArea:null,touchArea:null,cursor:null,transformBounds:!1,maxWidth:null,maxHeight:null,renderer:null,usesOpacity:!1,layerSplit:!1,cssTransform:!1,excludeInvisible:!1,webglScale:null,preventFit:!1};class dh extends th{constructor(t){super(),_defineProperty(this,"parentAddedEmitter",new c),_defineProperty(this,"parentRemovedEmitter",new c),_defineProperty(this,"_activeParentLayoutConstraint",null),this._id=ih++,this._instances=[],this._rootedDisplays=[],this._drawables=[],this._visibleProperty=new ti(lh.visible,lh.phetioVisiblePropertyInstrumented,this.onVisiblePropertyChange.bind(this)),this.opacityProperty=new ae(lh.opacity,this.onOpacityPropertyChange.bind(this)),this.disabledOpacityProperty=new ae(lh.disabledOpacity,this.onDisabledOpacityPropertyChange.bind(this)),this._pickableProperty=new ti(lh.pickable,!1,this.onPickablePropertyChange.bind(this)),this._enabledProperty=new ti(lh.enabled,lh.phetioEnabledPropertyInstrumented,this.onEnabledPropertyChange.bind(this)),this._inputEnabledProperty=new ti(lh.inputEnabled,lh.phetioInputEnabledPropertyInstrumented),this.clipAreaProperty=new ae(lh.clipArea),this.voicingVisibleProperty=new ae(!0),this._mouseArea=lh.mouseArea,this._touchArea=lh.touchArea,this._cursor=lh.cursor,this._children=[],this._parents=[],this._transformBounds=lh.transformBounds,this._transform=new Cn,this._transformListener=this.onTransformChange.bind(this),this._transform.changeEmitter.addListener(this._transformListener),this._maxWidth=lh.maxWidth,this._maxHeight=lh.maxHeight,this._appliedScaleFactor=1,this._inputListeners=[],this.inputEnabledProperty.lazyLink(this.pdomBoundInputEnabledListener);var e=this.onBoundsListenersAddedOrRemoved.bind(this),i=this.validateBounds.bind(this),s=this.validateSelfBounds.bind(this);this.boundsProperty=new ei(mn.NOTHING.copy(),i),this.boundsProperty.changeCount=e,this.localBoundsProperty=new ei(mn.NOTHING.copy(),i),this.localBoundsProperty.changeCount=e,this.childBoundsProperty=new ei(mn.NOTHING.copy(),i),this.childBoundsProperty.changeCount=e,this.selfBoundsProperty=new ei(mn.NOTHING.copy(),s),this._localBoundsOverridden=!1,this._excludeInvisibleChildrenFromBounds=!1,this._layoutOptions=null,this._boundsDirty=!0,this._localBoundsDirty=!0,this._selfBoundsDirty=!0,this._childBoundsDirty=!0,this._filters=[],this._hints={renderer:null===lh.renderer?0:on.fromName(lh.renderer),usesOpacity:lh.usesOpacity,layerSplit:lh.layerSplit,cssTransform:lh.cssTransform,fullResolution:!1,excludeInvisible:lh.excludeInvisible,webglScale:lh.webglScale,preventFit:lh.preventFit},this.childrenChangedEmitter=new c,this.childInsertedEmitter=new c,this.childRemovedEmitter=new c,this.childrenReorderedEmitter=new c,this.transformEmitter=new c,this.instanceRefreshEmitter=new c,this.rendererSummaryRefreshEmitter=new c,this.filterChangeEmitter=new c,this.changedInstanceEmitter=new c,this.layoutOptionsChangedEmitter=new c,this._rendererBitmask=on.bitmaskNodeDefault,this._rendererSummary=new yh(this),this._boundsEventCount=0,this._boundsEventSelfCount=0,this._picker=new ch(this),this._isGettingRemovedFromParent=!1,t&&this.mutate(t)}insertChild(t,e,i){return this._picker.onInsertChild(e),this.changeBoundsEventCount(e._boundsEventCount>0?1:0),this._rendererSummary.summaryChange(yh.bitmaskAll,e._rendererSummary.bitmask),e._parents.push(this),this._children.splice(t,0,e),e._rendererSummary.hasNoPDOM()||this.onPDOMAddChild(e),e.invalidateBounds(),this._boundsDirty=!0,this.childInsertedEmitter.emit(e,t),e.parentAddedEmitter.emit(this),!i&&this.childrenChangedEmitter.emit(),this}addChild(t,e){return this.insertChild(this._children.length,t,e),this}removeChild(t,e){var i=_.indexOf(this._children,t);return this.removeChildWithIndex(t,i,e),this}removeChildAt(t,e){var i=this._children[t];return this.removeChildWithIndex(i,t,e),this}removeChildWithIndex(t,e,i){var s=_.indexOf(t._parents,this);t._isGettingRemovedFromParent=!0,t._rendererSummary.hasNoPDOM()||this.onPDOMRemoveChild(t),this._picker.onRemoveChild(t),this.changeBoundsEventCount(t._boundsEventCount>0?-1:0),this._rendererSummary.summaryChange(t._rendererSummary.bitmask,yh.bitmaskAll),t._parents.splice(s,1),this._children.splice(e,1),t._isGettingRemovedFromParent=!1,this.invalidateBounds(),this._childBoundsDirty=!0,this.childRemovedEmitter.emit(t,e),t.parentRemovedEmitter.emit(this),!i&&this.childrenChangedEmitter.emit()}moveChildToIndex(t,e){var i=this.indexOfChild(t);return this._children[e]!==t&&(this._children.splice(i,1),this._children.splice(e,0,t),this._rendererSummary.hasNoPDOM()||this.onPDOMReorderedChildren(),this.childrenReorderedEmitter.emit(Math.min(i,e),Math.max(i,e)),this.childrenChangedEmitter.emit()),this}removeAllChildren(){return this.setChildren([]),this}setChildren(t){var e,i=[],s=[],n=[];for(si(t,this._children,s,i,n),e=i.length-1;e>=0;e--)this.removeChild(i[e],!0);var r=-1,a=-1;for(e=0;et.moveChildToFront(this)),this}moveChildToFront(t){return this.moveChildToIndex(t,this._children.length-1)}moveForward(){return this._parents.forEach(t=>t.moveChildForward(this)),this}moveChildForward(t){var e=this.indexOfChild(t);return et.moveChildBackward(this)),this}moveChildBackward(t){var e=this.indexOfChild(t);return e>0&&this.moveChildToIndex(t,e-1),this}moveToBack(){return _.each(this._parents.slice(),t=>t.moveChildToBack(this)),this}moveChildToBack(t){return this.moveChildToIndex(t,0)}replaceChild(t,e){var i=this.indexOfChild(t),s=t.focused;return this.removeChild(t,!0),this.insertChild(i,e,!0),this.childrenChangedEmitter.emit(),s&&e.focusable&&e.focus(),this}detach(){return _.each(this._parents.slice(0),t=>t.removeChild(this)),this}changeBoundsEventCount(t){if(0!==t){var e=0===this._boundsEventCount;if(this._boundsEventCount+=t,e!==(0===this._boundsEventCount))for(var i=e?1:-1,s=this._parents.length,n=0;n0&&this._childBoundsDirty){for(var t=!1,e=this._children.length,i=0;i=0;i--){var s=this._children[i].getPhetioMouseHit(e);if(s)return s.isPhetioInstrumented()?s:this}return this._mouseArea?this._mouseArea.containsPoint(e)?this:null:this.selfBounds.containsPoint(e)&&this.containsPointSelf(e)?this:null}isPainted(){return!1}areSelfBoundsValid(){return!0}hasParent(){return 0!==this._parents.length}hasChildren(){return this._children.length>0}isChildIncludedInLayout(t){return t.bounds.isValid()&&(!this._excludeInvisibleChildrenFromBounds||t.visible)}walkDepthFirst(t){t(this);for(var e=this._children.length,i=0;i=0&&(this._inputListeners.splice(e,1),this._picker.onRemoveInputListener()),this}hasInputListener(t){for(var e=0;ethis._maxWidth&&(i=Math.min(i,this._maxWidth/s))}if(null!==this._maxHeight){var n=t.height;n>this._maxHeight&&(i=Math.min(i,this._maxHeight/n))}var r=i/e;1!==r&&(this._appliedScaleFactor=i,this.scale(r))}onMaxDimensionChange(t,e){null===t&&null!==e?(this.changeBoundsEventCount(1),this._boundsEventSelfCount++):null!==t&&null===e&&(this.changeBoundsEventCount(-1),this._boundsEventSelfCount--)}setMaxWidth(t){this._maxWidth!==t&&(this.onMaxDimensionChange(this._maxWidth,t),this._maxWidth=t,this.updateMaxDimension(this.localBoundsProperty.value))}set maxWidth(t){this.setMaxWidth(t)}get maxWidth(){return this.getMaxWidth()}getMaxWidth(){return this._maxWidth}setMaxHeight(t){this._maxHeight!==t&&(this.onMaxDimensionChange(this._maxHeight,t),this._maxHeight=t,this.updateMaxDimension(this.localBoundsProperty.value))}set maxHeight(t){this.setMaxHeight(t)}get maxHeight(){return this.getMaxHeight()}getMaxHeight(){return this._maxHeight}setLeft(t){var e=this.getLeft();return isFinite(e)&&this.translate(t-e,0,!0),this}set left(t){this.setLeft(t)}get left(){return this.getLeft()}getLeft(){return this.getBounds().minX}setRight(t){var e=this.getRight();return isFinite(e)&&this.translate(t-e,0,!0),this}set right(t){this.setRight(t)}get right(){return this.getRight()}getRight(){return this.getBounds().maxX}setCenterX(t){var e=this.getCenterX();return isFinite(e)&&this.translate(t-e,0,!0),this}set centerX(t){this.setCenterX(t)}get centerX(){return this.getCenterX()}getCenterX(){return this.getBounds().getCenterX()}setCenterY(t){var e=this.getCenterY();return isFinite(e)&&this.translate(0,t-e,!0),this}set centerY(t){this.setCenterY(t)}get centerY(){return this.getCenterY()}getCenterY(){return this.getBounds().getCenterY()}setTop(t){var e=this.getTop();return isFinite(e)&&this.translate(0,t-e,!0),this}set top(t){this.setTop(t)}get top(){return this.getTop()}getTop(){return this.getBounds().minY}setBottom(t){var e=this.getBottom();return isFinite(e)&&this.translate(0,t-e,!0),this}set bottom(t){this.setBottom(t)}get bottom(){return this.getBottom()}getBottom(){return this.getBounds().maxY}setLeftTop(t){var e=this.getLeftTop();return e.isFinite()&&this.translate(t.minus(e),!0),this}set leftTop(t){this.setLeftTop(t)}get leftTop(){return this.getLeftTop()}getLeftTop(){return this.getBounds().getLeftTop()}setCenterTop(t){var e=this.getCenterTop();return e.isFinite()&&this.translate(t.minus(e),!0),this}set centerTop(t){this.setCenterTop(t)}get centerTop(){return this.getCenterTop()}getCenterTop(){return this.getBounds().getCenterTop()}setRightTop(t){var e=this.getRightTop();return e.isFinite()&&this.translate(t.minus(e),!0),this}set rightTop(t){this.setRightTop(t)}get rightTop(){return this.getRightTop()}getRightTop(){return this.getBounds().getRightTop()}setLeftCenter(t){var e=this.getLeftCenter();return e.isFinite()&&this.translate(t.minus(e),!0),this}set leftCenter(t){this.setLeftCenter(t)}get leftCenter(){return this.getLeftCenter()}getLeftCenter(){return this.getBounds().getLeftCenter()}setCenter(t){var e=this.getCenter();return e.isFinite()&&this.translate(t.minus(e),!0),this}set center(t){this.setCenter(t)}get center(){return this.getCenter()}getCenter(){return this.getBounds().getCenter()}setRightCenter(t){var e=this.getRightCenter();return e.isFinite()&&this.translate(t.minus(e),!0),this}set rightCenter(t){this.setRightCenter(t)}get rightCenter(){return this.getRightCenter()}getRightCenter(){return this.getBounds().getRightCenter()}setLeftBottom(t){var e=this.getLeftBottom();return e.isFinite()&&this.translate(t.minus(e),!0),this}set leftBottom(t){this.setLeftBottom(t)}get leftBottom(){return this.getLeftBottom()}getLeftBottom(){return this.getBounds().getLeftBottom()}setCenterBottom(t){var e=this.getCenterBottom();return e.isFinite()&&this.translate(t.minus(e),!0),this}set centerBottom(t){this.setCenterBottom(t)}get centerBottom(){return this.getCenterBottom()}getCenterBottom(){return this.getBounds().getCenterBottom()}setRightBottom(t){var e=this.getRightBottom();return e.isFinite()&&this.translate(t.minus(e),!0),this}set rightBottom(t){this.setRightBottom(t)}get rightBottom(){return this.getRightBottom()}getRightBottom(){return this.getBounds().getRightBottom()}getWidth(){return this.getBounds().getWidth()}get width(){return this.getWidth()}getHeight(){return this.getBounds().getHeight()}get height(){return this.getHeight()}getLocalWidth(){return this.getLocalBounds().getWidth()}get localWidth(){return this.getLocalWidth()}getLocalHeight(){return this.getLocalBounds().getHeight()}get localHeight(){return this.getLocalHeight()}getLocalLeft(){return this.getLocalBounds().minX}get localLeft(){return this.getLocalLeft()}getLocalRight(){return this.getLocalBounds().maxX}get localRight(){return this.getLocalRight()}getLocalCenterX(){return this.getLocalBounds().getCenterX()}get localCenterX(){return this.getLocalCenterX()}getLocalCenterY(){return this.getLocalBounds().getCenterY()}get localCenterY(){return this.getLocalCenterY()}getLocalTop(){return this.getLocalBounds().minY}get localTop(){return this.getLocalTop()}getLocalBottom(){return this.getLocalBounds().maxY}get localBottom(){return this.getLocalBottom()}getLocalLeftTop(){return this.getLocalBounds().getLeftTop()}get localLeftTop(){return this.getLocalLeftTop()}getLocalCenterTop(){return this.getLocalBounds().getCenterTop()}get localCenterTop(){return this.getLocalCenterTop()}getLocalRightTop(){return this.getLocalBounds().getRightTop()}get localRightTop(){return this.getLocalRightTop()}getLocalLeftCenter(){return this.getLocalBounds().getLeftCenter()}get localLeftCenter(){return this.getLocalLeftCenter()}getLocalCenter(){return this.getLocalBounds().getCenter()}get localCenter(){return this.getLocalCenter()}getLocalRightCenter(){return this.getLocalBounds().getRightCenter()}get localRightCenter(){return this.getLocalRightCenter()}getLocalLeftBottom(){return this.getLocalBounds().getLeftBottom()}get localLeftBottom(){return this.getLocalLeftBottom()}getLocalCenterBottom(){return this.getLocalBounds().getCenterBottom()}get localCenterBottom(){return this.getLocalCenterBottom()}getLocalRightBottom(){return this.getLocalBounds().getRightBottom()}get localRightBottom(){return this.getLocalRightBottom()}getId(){return this._id}get id(){return this.getId()}onVisiblePropertyChange(t){this._picker.onVisibilityChange(),this._pdomDisplaysInfo.onVisibilityChange(t);for(var e=0;e1)throw new Error("opacity out of range: ".concat(t));this.opacityProperty.value=t}set opacity(t){this.setOpacity(t)}get opacity(){return this.getOpacity()}getOpacity(){return this.opacityProperty.value}setDisabledOpacity(t){if(t<0||t>1)throw new Error("disabledOpacity out of range: ".concat(t));return this.disabledOpacityProperty.value=t,this}set disabledOpacity(t){this.setDisabledOpacity(t)}get disabledOpacity(){return this.getDisabledOpacity()}getDisabledOpacity(){return this.disabledOpacityProperty.value}getEffectiveOpacity(){return this.opacityProperty.value*(this.enabledProperty.value?1:this.disabledOpacityProperty.value)}get effectiveOpacity(){return this.getEffectiveOpacity()}onOpacityPropertyChange(){this.filterChangeEmitter.emit()}onDisabledOpacityPropertyChange(){this._enabledProperty.value||this.filterChangeEmitter.emit()}setFilters(t){this._filters.length=0,this._filters.push(...t),this.invalidateHint(),this.filterChangeEmitter.emit()}set filters(t){this.setFilters(t)}get filters(){return this.getFilters()}getFilters(){return this._filters.slice()}setPickableProperty(t){return this._pickableProperty.setTargetProperty(this,null,t)}set pickableProperty(t){this.setPickableProperty(t)}get pickableProperty(){return this.getPickableProperty()}getPickableProperty(){return this._pickableProperty}setPickable(t){return this._pickableProperty.set(t),this}set pickable(t){this.setPickable(t)}get pickable(){return this.isPickable()}isPickable(){return this._pickableProperty.value}onPickablePropertyChange(t,e){this._picker.onPickableChange(e,t)}updateLinkedElementForProperty(t,e,i){if(this.isPhetioInstrumented()){e&&e instanceof ce&&e.isPhetioInstrumented()&&e instanceof Vt&&this.removeLinkedElements(e);var s=this.tandem.createTandem(t);i&&i instanceof ce&&i.isPhetioInstrumented()&&i instanceof Vt&&s!==i.tandem&&this.addLinkedElement(i,{tandem:s})}}setEnabledProperty(t){return this._enabledProperty.setTargetProperty(this,ah,t)}set enabledProperty(t){this.setEnabledProperty(t)}get enabledProperty(){return this.getEnabledProperty()}getEnabledProperty(){return this._enabledProperty}setPhetioEnabledPropertyInstrumented(t){return this._enabledProperty.setTargetPropertyInstrumented(t,this)}set phetioEnabledPropertyInstrumented(t){this.setPhetioEnabledPropertyInstrumented(t)}get phetioEnabledPropertyInstrumented(){return this.getPhetioEnabledPropertyInstrumented()}getPhetioEnabledPropertyInstrumented(){return this._enabledProperty.getTargetPropertyInstrumented()}setEnabled(t){return this._enabledProperty.set(t),this}set enabled(t){this.setEnabled(t)}get enabled(){return this.isEnabled()}isEnabled(){return this._enabledProperty.value}onEnabledPropertyChange(t){!t&&this.interruptSubtreeInput(),this.inputEnabled=t,1!==this.disabledOpacityProperty.value&&this.filterChangeEmitter.emit()}setInputEnabledProperty(t){return this._inputEnabledProperty.setTargetProperty(this,"inputEnabledProperty",t)}set inputEnabledProperty(t){this.setInputEnabledProperty(t)}get inputEnabledProperty(){return this.getInputEnabledProperty()}getInputEnabledProperty(){return this._inputEnabledProperty}setPhetioInputEnabledPropertyInstrumented(t){return this._inputEnabledProperty.setTargetPropertyInstrumented(t,this)}set phetioInputEnabledPropertyInstrumented(t){this.setPhetioInputEnabledPropertyInstrumented(t)}get phetioInputEnabledPropertyInstrumented(){return this.getPhetioInputEnabledPropertyInstrumented()}getPhetioInputEnabledPropertyInstrumented(){return this._inputEnabledProperty.getTargetPropertyInstrumented()}setInputEnabled(t){this.inputEnabledProperty.value=t}set inputEnabled(t){this.setInputEnabled(t)}get inputEnabled(){return this.isInputEnabled()}isInputEnabled(){return this.inputEnabledProperty.value}setInputListeners(t){for(;this._inputListeners.length;)this.removeInputListener(this._inputListeners[0]);for(var e=0;et===e)}getTrails(t){t=t||dh.defaultTrailPredicate;var e=[],i=new Nh(this);return Nh.appendAncestorTrailsWithPredicate(e,i,t),e}getTrailsTo(t){return this.getTrails(e=>e===t)}getLeafTrails(t){t=t||dh.defaultLeafTrailPredicate;var e=[],i=new Nh(this);return Nh.appendDescendantTrailsWithPredicate(e,i,t),e}getLeafTrailsTo(t){return this.getLeafTrails(e=>e===t)}getUniqueLeafTrail(t){var e=this.getLeafTrails(t);return e[0]}getUniqueLeafTrailTo(t){return this.getUniqueLeafTrail(e=>e===t)}getConnectedNodes(){for(var t=[],e=this._children.concat(this._parents).concat(this);e.length;){var i=e.pop();_.includes(t,i)||(t.push(i),e=e.concat(i._children,i._parents))}return t}getSubtreeNodes(){for(var t=[],e=this._children.concat(this);e.length;){var i=e.pop();_.includes(t,i)||(t.push(i),e=e.concat(i._children))}return t}getTopologicallySortedNodes(){var t,e={},i=[],s=[];function n(s){delete e[t.id][s.id],_.every(e,t=>!t[s.id])&&i.push(s)}for(_.each(this.getConnectedNodes(),t=>{e[t.id]={},_.each(t._children,i=>{e[t.id][i.id]=!0}),t.parents.length||i.push(t)});i.length;)t=i.pop(),s.push(t),_.each(t._children,n);return s}canAddChild(t){if(this===t||_.includes(this._children,t))return!1;var e,i={},s=[],n=[];function r(t){delete i[e.id][t.id],_.every(i,e=>!e[t.id])&&s.push(t)}for(_.each(this.getConnectedNodes().concat(t.getConnectedNodes()),e=>{i[e.id]={},_.each(e._children,t=>{i[e.id][t.id]=!0}),e.parents.length||e===t||s.push(e)}),i[this.id][t.id]=!0;s.length;)e=s.pop(),n.push(e),_.each(e._children,r),e===this&&r(t);return _.every(i,t=>_.every(t,t=>!1))}canvasPaintSelf(t,e){}renderToCanvasSelf(t,e){this.isPainted()&&this._rendererBitmask&on.bitmaskCanvas&&this.canvasPaintSelf(t,e)}renderToCanvasSubtree(t,e){e=e||wn.identity(),t.resetStyles(),this.renderToCanvasSelf(t,e);for(var i=0;i0&&r.height>0&&function(){var i=document.createElement("canvas");i.width=r.width,i.height=r.height;var n=i.getContext("2d"),a=new rr(i,n),o=e.copy().prependTranslation(-r.minX,-r.minY);o.canvasSetTransform(n),s.renderToCanvasSubtree(a,o),t.context.save(),s.clipArea&&(t.context.beginPath(),s.clipArea.writeToContext(t.context),t.context.clip()),t.context.setTransform(1,0,0,1,0,0),t.context.globalAlpha=s.effectiveOpacity;var h=!1;s._filters.length&&(Js.canvasFilter&&_.every(s._filters,t=>t.isDOMCompatible())?(t.context.filter=s._filters.map(t=>t.getCSSFilterString()).join(" "),h=!0):s._filters.forEach(t=>t.applyCanvasFilter(a))),t.context.drawImage(i,r.minX,r.minY),t.context.restore(),h&&(t.context.filter="none")}()}else s.renderToCanvasSubtree(t,e);e.multiplyMatrix(s._transform.getInverse()),t.context.restore()}}}renderToCanvas(t,e,i,s){t.width=t.width,s&&(e.fillStyle=s,e.fillRect(0,0,t.width,t.height));var n=new rr(t,e);this.renderToCanvasSubtree(n,wn.identity()),i&&i()}toCanvas(t,e,i,s,n){var r=this.getBounds().union(this.localToParentBounds(this.getSafeSelfBounds()));e=void 0!==e?e:Math.ceil(2-r.minX),i=void 0!==i?i:Math.ceil(2-r.minY),s=void 0!==s?s:Math.ceil(r.getWidth()+4),n=void 0!==n?n:Math.ceil(r.getHeight()+4);var a=document.createElement("canvas");a.width=s,a.height=n;var o=a.getContext("2d");o.translate(e,i),this._transform.getMatrix().canvasAppendTransform(o);var h=new rr(a,o);this.renderToCanvasSubtree(h,wn.translation(e,i).timesMatrix(this._transform.getMatrix())),t(a,e,i,s,n)}toDataURL(t,e,i,s,n){this.toCanvas((e,i,s,n,r)=>{t(e.toDataURL(),i,s,n,r)},e,i,s,n)}toImage(t,e,i,s,n){this.toDataURL((e,i,s)=>{var n=document.createElement("img");n.onload=()=>{t(n,i,s);try{delete n.onload}catch(e){}},n.src=e},e,i,s,n)}toImageNodeAsynchronous(t,e,i,s,n){this.toImage((e,i,s)=>{t(new dh({children:[new el(e,{x:-i,y:-s})]}))},e,i,s,n)}toCanvasNodeSynchronous(t,e,i,s){var n=null;return this.toCanvas((t,e,i)=>{n=new dh({children:[new el(t,{x:-e,y:-i})]})},t,e,i,s),n}toDataURLImageSynchronous(t,e,i,s){var n=null;return this.toDataURL((t,e,i,s,r)=>{n=new el(t,{x:-e,y:-i,initialWidth:s,initialHeight:r})},t,e,i,s),n}toDataURLNodeSynchronous(t,e,i,s){return new dh({children:[this.toDataURLImageSynchronous(t,e,i,s)]})}rasterized(t){var e=w()({resolution:1,sourceBounds:null,useTargetBounds:!0,wrap:!0,useCanvas:!1,imageOptions:{}},t),i=e.resolution,s=e.sourceBounds;var n=new dh({scale:i,children:[this]}),r=s||this.getSafeTransformedVisibleBounds().dilated(2).roundedOut();1!==i&&((r=new mn(i*r.minX,i*r.minY,i*r.maxX,i*r.maxY)).width%1!=0&&(r.maxX+=1-r.width%1),r.height%1!=0&&(r.maxY+=1-r.height%1));var a=null;n.toCanvas((function(t,s,n,r,o){var h=e.useCanvas?t:t.toDataURL();(a=new el(h,T({},e.imageOptions,{x:-s,y:-n,initialWidth:r,initialHeight:o}))).scale(1/i,1/i,!0)}),-r.minX,-r.minY,Vs.roundSymmetric(r.width),Vs.roundSymmetric(r.height)),n.dispose();var o=this.getVisibleBounds();if(s&&(o=s.intersection(o)),e.useTargetBounds&&(a.imageBounds=a.parentToLocalBounds(o)),e.wrap){var h=new dh({children:[a]});return e.useTargetBounds&&(h.localBounds=o),h}return e.useTargetBounds&&(a.localBounds=a.parentToLocalBounds(o)),a}createDOMDrawable(t,e){throw new Error("createDOMDrawable is abstract. The subtype should either override this method, or not support the DOM renderer")}createSVGDrawable(t,e){throw new Error("createSVGDrawable is abstract. The subtype should either override this method, or not support the DOM renderer")}createCanvasDrawable(t,e){throw new Error("createCanvasDrawable is abstract. The subtype should either override this method, or not support the DOM renderer")}createWebGLDrawable(t,e){throw new Error("createWebGLDrawable is abstract. The subtype should either override this method, or not support the DOM renderer")}getInstances(){return this._instances}get instances(){return this.getInstances()}addInstance(t){this._instances.push(t),this.changedInstanceEmitter.emit(t,!0)}removeInstance(t){var e=_.indexOf(this._instances,t);this._instances.splice(e,1),this.changedInstanceEmitter.emit(t,!1)}wasVisuallyDisplayed(t){for(var e=0;e=0;s--)i.multiplyMatrix(e[s]);return i}getUniqueTransform(){return new Cn(this.getLocalToGlobalMatrix())}getGlobalToLocalMatrix(){return this.getLocalToGlobalMatrix().invert()}localToGlobalPoint(t){for(var e=this,i=t.copy();e;)e._transform.getMatrix().multiplyVector2(i),e=e._parents[0];return i}globalToLocalPoint(t){for(var e=this,i=[];e;)i.push(e._transform),e=e._parents[0];for(var s=t.copy(),n=i.length-1;n>=0;n--)i[n].getInverse().multiplyVector2(s);return s}localToGlobalBounds(t){return t.transformed(this.getLocalToGlobalMatrix())}globalToLocalBounds(t){return t.transformed(this.getGlobalToLocalMatrix())}parentToGlobalPoint(t){return this.parents.length?this.parents[0].localToGlobalPoint(t):t}parentToGlobalBounds(t){return this.parents.length?this.parents[0].localToGlobalBounds(t):t}globalToParentPoint(t){return this.parents.length?this.parents[0].globalToLocalPoint(t):t}globalToParentBounds(t){return this.parents.length?this.parents[0].globalToLocalBounds(t):t}getGlobalBounds(){return this.parentToGlobalBounds(this.getBounds())}get globalBounds(){return this.getGlobalBounds()}boundsOf(t){return this.globalToLocalBounds(t.getGlobalBounds())}boundsTo(t){return t.globalToLocalBounds(this.getGlobalBounds())}attachDrawable(t){return this._drawables.push(t),this}detachDrawable(t){var e=_.indexOf(this._drawables,t);return this._drawables.splice(e,1),this}mutate(t){return t?(_.each(this._mutatorKeys,e=>{if(void 0!==t[e]){var i=Object.getOwnPropertyDescriptor(dh.prototype,e);i&&"function"==typeof i.value?this[e](t[e]):this[e]=t[e]}}),this.initializePhetioObject({phetioType:dh.NodeIO,phetioState:!1},t),this):this}initializePhetioObject(t,e){var i=this.isPhetioInstrumented();super.initializePhetioObject(t,e),Ct.PHET_IO_ENABLED&&!i&&this.isPhetioInstrumented()&&(this._visibleProperty.initializePhetio(this,"visibleProperty",()=>new pe(this.visible,T({phetioReadOnly:this.phetioReadOnly,tandem:this.tandem.createTandem("visibleProperty"),phetioDocumentation:"Controls whether the Node will be visible (and interactive)."},e.visiblePropertyOptions))),this._enabledProperty.initializePhetio(this,ah,()=>new eh(this.enabled,T({phetioReadOnly:this.phetioReadOnly,phetioDocumentation:'Sets whether the node is enabled. This will set whether input is enabled for this Node and most often children as well. It will also control and toggle the "disabled look" of the node.',tandem:this.tandem.createTandem(ah)},e.enabledPropertyOptions))),this._inputEnabledProperty.initializePhetio(this,"inputEnabledProperty",()=>new me(this.inputEnabled,T({phetioReadOnly:this.phetioReadOnly,tandem:this.tandem.createTandem("inputEnabledProperty"),phetioValueType:Q,phetioFeatured:!0,phetioDocumentation:"Sets whether the element will have input enabled, and hence be interactive."},e.inputEnabledPropertyOptions))))}setVoicingVisible(t){this.voicingVisibleProperty.value!==t&&(this.voicingVisibleProperty.value=t)}set voicingVisible(t){this.setVoicingVisible(t)}get voicingVisible(){return this.isVoicingVisible()}isVoicingVisible(){return this.voicingVisibleProperty.value}getDebugHTMLExtras(){return""}inspect(){localStorage.scenerySnapshot=JSON.stringify({type:"Subtree",rootNodeId:this.id,nodes:dp(this)})}toString(t,e){return"".concat(this.constructor.name,"#").concat(this.id)}auditInstanceSubtreeForDisplay(t){}onBoundsListenersAddedOrRemoved(t){this.changeBoundsEventCount(t),this._boundsEventSelfCount+=t}dispose(){this.disposeParallelDOM(),this.removeAllChildren(),this.detach(),this._inputEnabledProperty.dispose(),this._enabledProperty.dispose(),this._pickableProperty.dispose(),this._visibleProperty.dispose(),super.dispose()}disposeSubtree(){if(!this.isDisposed){var t=this.children;this.dispose();for(var e=0;e=0;a--){var o=this.node._children[a]._picker.recursiveHitTest(n,e,i,s);if(o)return o.addAncestor(this.node,a)}return e&&this.node._mouseArea?this.node._mouseArea.containsPoint(n)?new Nh(this.node):null:i&&this.node._touchArea?this.node._touchArea.containsPoint(n)?new Nh(this.node):null:this.node.selfBounds.containsPoint(n)&&this.node.containsPointSelf(n)?new Nh(this.node):null}invalidate(t,e){var i=!!e||!this.mouseInclusiveDirty||!this.touchInclusiveDirty;if(this.mouseInclusiveDirty=!0,this.touchInclusiveDirty=!0,t&&(i=i||!this.mouseExclusiveDirty||!this.touchExclusiveDirty,this.mouseExclusiveDirty=!0,this.touchExclusiveDirty=!0),!this.selfPruned&&i)for(var s=this.node._parents,n=0;n0;e&&this.changePickableCount(1),this.invalidate(e,!0)}}onRemoveChild(t){if(!t._picker.selfPruned){var e=t._picker.subtreePickableCount>0;e&&this.changePickableCount(-1),this.invalidate(e,!0)}}onAddInputListener(){this.checkSelfInclusive(),this.checkSubtreePrunable(),this.changePickableCount(1)}onRemoveInputListener(){this.checkSelfInclusive(),this.checkSubtreePrunable(),this.changePickableCount(-1)}onPickableChange(t,e){this.checkSelfPruned(),this.checkSelfInclusive(),this.checkSubtreePrunable();var i=(!0===t?-1:0)+(!0===e?1:0);i&&this.changePickableCount(i)}onVisibilityChange(){this.checkSelfPruned(),this.checkSubtreePrunable()}onMouseAreaChange(){this.invalidate(!0)}onTouchAreaChange(){this.invalidate(!0)}onTransformChange(){this.invalidate(!0)}onSelfBoundsDirty(){this.invalidate(!0)}onClipAreaChange(){this.invalidate(!0)}checkSelfPruned(){var t=!1===this.node.pickableProperty.value||!this.node.isVisible();if(this.selfPruned!==t){this.selfPruned=t;for(var e=this.node._parents,i=0;i0?(s.invalidate(!0,!0),s.changePickableCount(this.selfPruned?-1:1)):s.invalidate(!1,!0)}}}checkSelfInclusive(){var t=!0===this.node.pickableProperty.value||this.node._inputListeners.length>0;this.selfInclusive!==t&&(this.selfInclusive=t,this.invalidate(!0,!0))}checkSubtreePrunable(){var t=!1===this.node.pickableProperty.value||!this.node.isVisible()||!0!==this.node.pickableProperty.value&&0===this.subtreePickableCount;this.subtreePrunable!==t&&(this.subtreePrunable=t,this.invalidate(!0,!0))}changePickableCount(t){if(0!==t){var e=0===this.subtreePickableCount;this.subtreePickableCount+=t;var i=0===this.subtreePickableCount;if(this.checkSubtreePrunable(),!this.selfPruned&&e!==i)for(var s=this.node._parents.length,n=0;nthis.set(t[i]),this.property.lazyLink(this.changeListener)}dispose(){this.property.unlink(this.changeListener),super.dispose(),this.node=null}setPropertyValue(t){this.node[this.attribute]=t,super.setPropertyValue(t)}}bs.register("NodeProperty",bh);class _h{constructor(t){this.node=t,this.pdomDisplays=[]}onAddChild(t){t._pdomDisplaysInfo.canHavePDOMDisplays()&&t._pdomDisplaysInfo.addPDOMDisplays(this.pdomDisplays)}onRemoveChild(t){t._pdomDisplaysInfo.canHavePDOMDisplays()&&t._pdomDisplaysInfo.removePDOMDisplays(this.pdomDisplays)}onSummaryChange(t,e){if(this.node.visible&&this.node.pdomVisible){var i=!(on.bitmaskNoPDOM&t),s=!(on.bitmaskNoPDOM&e);s&&!i&&this.addAllPDOMDisplays(),!s&&i&&this.removeAllPDOMDisplays()}}onVisibilityChange(t){this.node.pdomVisible&&!this.node._rendererSummary.hasNoPDOM()&&(t?this.addAllPDOMDisplays():this.removeAllPDOMDisplays())}onPDOMVisibilityChange(t){this.node.visible&&!this.node._rendererSummary.hasNoPDOM()&&(t?this.addAllPDOMDisplays():this.removeAllPDOMDisplays())}onAddedRootedDisplay(t){t._accessible&&this.canHavePDOMDisplays()&&this.addPDOMDisplays([t])}onRemovedRootedDisplay(t){t._accessible&&this.canHavePDOMDisplays()&&this.removePDOMDisplays([t])}canHavePDOMDisplays(){return this.node.visible&&this.node.pdomVisible&&!this.node._rendererSummary.hasNoPDOM()}addAllPDOMDisplays(){var t,e=[];for(t=0;t=0;e--){this.pdomDisplays.lastIndexOf(t[e]);this.pdomDisplays.splice(e,1)}for(e=0;e{var e=tl("WidthSizable",Ph,class extends t{constructor(){super(...arguments),_defineProperty(this,"preferredWidthProperty",new ae(null)),_defineProperty(this,"minimumWidthProperty",new ae(null)),_defineProperty(this,"localPreferredWidthProperty",new ae(null)),_defineProperty(this,"localMinimumWidthProperty",new ae(null)),_defineProperty(this,"isWidthResizableProperty",new ae(!0)),_defineProperty(this,"_preferredWidthChanging",!1),_defineProperty(this,"_minimumWidthChanging",!1);var t=this._updatePreferredWidth.bind(this),e=this._updateLocalPreferredWidth.bind(this),i=this._updateMinimumWidth.bind(this),s=this._updateLocalMinimumWidth.bind(this);this.preferredWidthProperty.lazyLink(e),this.localPreferredWidthProperty.lazyLink(t),this.minimumWidthProperty.lazyLink(s),this.localMinimumWidthProperty.lazyLink(i),this.transformEmitter.addListener(e),this.transformEmitter.addListener(i)}get preferredWidth(){return this.preferredWidthProperty.value}set preferredWidth(t){this.preferredWidthProperty.value=t}get localPreferredWidth(){return this.localPreferredWidthProperty.value}set localPreferredWidth(t){this.localPreferredWidthProperty.value=t}get minimumWidth(){return this.minimumWidthProperty.value}set minimumWidth(t){this.minimumWidthProperty.value=t}get localMinimumWidth(){return this.localMinimumWidthProperty.value}set localMinimumWidth(t){this.localMinimumWidthProperty.value=t}get widthSizable(){return this.isWidthResizableProperty.value}set widthSizable(t){this.isWidthResizableProperty.value=t}get mixesWidthSizable(){return!0}validateLocalPreferredWidth(){}_updateLocalPreferredWidth(){if(!this._preferredWidthChanging){this._preferredWidthChanging=!0;var t=this.matrix.isAligned()&&null!==this.preferredWidth?Math.abs(this.transform.inverseDeltaX(this.preferredWidth)):null;(null===this.localPreferredWidthProperty.value||null===t||Math.abs(this.localPreferredWidthProperty.value-t)>1e-9)&&(this.localPreferredWidthProperty.value=t),this._preferredWidthChanging=!1}}_updatePreferredWidth(){if(!this._preferredWidthChanging){this._preferredWidthChanging=!0;var t=this.matrix.isAligned()&&null!==this.localPreferredWidth?Math.abs(this.transform.transformDeltaX(this.localPreferredWidth)):null;(null===this.preferredWidthProperty.value||null===t||Math.abs(this.preferredWidthProperty.value-t)>1e-9)&&(this.preferredWidthProperty.value=t),this._preferredWidthChanging=!1}}_updateLocalMinimumWidth(){if(!this._minimumWidthChanging){this._minimumWidthChanging=!0;var t=this.matrix.isAligned()&&null!==this.minimumWidth?Math.abs(this.transform.inverseDeltaX(this.minimumWidth)):null;(null===this.localMinimumWidthProperty.value||null===t||Math.abs(this.localMinimumWidthProperty.value-t)>1e-9)&&(this.localMinimumWidthProperty.value=t),this._minimumWidthChanging=!1}}_updateMinimumWidth(){if(!this._minimumWidthChanging){this._minimumWidthChanging=!0;var t=this.matrix.isAligned()&&null!==this.localMinimumWidth?Math.abs(this.transform.transformDeltaX(this.localMinimumWidth)):null;(null===this.minimumWidthProperty.value||null===t||Math.abs(this.minimumWidthProperty.value-t)>1e-9)&&(this.minimumWidthProperty.value=t),this._minimumWidthChanging=!1}}});if(t.prototype._mutatorKeys){var i=t.prototype._mutatorKeys,s=Ph,n=i.indexOf(oh[0]);e.prototype._mutatorKeys=[...i.slice(0,n),...s,...i.slice(n)]}return e}),xh=t=>t.widthSizable,Th=t=>t.mixesWidthSizable;bs.register("WidthSizable",wh);var Sh=wh,Ah=["preferredHeight","minimumHeight","localPreferredHeight","localMinimumHeight","heightSizable"],Eh=Ei(t=>{var e=tl("HeightSizable",Ah,class extends t{constructor(){super(...arguments),_defineProperty(this,"preferredHeightProperty",new ae(null)),_defineProperty(this,"minimumHeightProperty",new ae(null)),_defineProperty(this,"localPreferredHeightProperty",new ae(null)),_defineProperty(this,"localMinimumHeightProperty",new ae(null)),_defineProperty(this,"isHeightResizableProperty",new ae(!0)),_defineProperty(this,"_preferredHeightChanging",!1),_defineProperty(this,"_minimumHeightChanging",!1);var t=this._updatePreferredHeight.bind(this),e=this._updateLocalPreferredHeight.bind(this),i=this._updateMinimumHeight.bind(this),s=this._updateLocalMinimumHeight.bind(this);this.preferredHeightProperty.lazyLink(e),this.localPreferredHeightProperty.lazyLink(t),this.minimumHeightProperty.lazyLink(s),this.localMinimumHeightProperty.lazyLink(i),this.transformEmitter.addListener(e),this.transformEmitter.addListener(i)}get preferredHeight(){return this.preferredHeightProperty.value}set preferredHeight(t){this.preferredHeightProperty.value=t}get localPreferredHeight(){return this.localPreferredHeightProperty.value}set localPreferredHeight(t){this.localPreferredHeightProperty.value=t}get minimumHeight(){return this.minimumHeightProperty.value}set minimumHeight(t){this.minimumHeightProperty.value=t}get localMinimumHeight(){return this.localMinimumHeightProperty.value}set localMinimumHeight(t){this.localMinimumHeightProperty.value=t}get heightSizable(){return this.isHeightResizableProperty.value}set heightSizable(t){this.isHeightResizableProperty.value=t}get mixesHeightSizable(){return!0}validateLocalPreferredHeight(){}_updateLocalPreferredHeight(){if(!this._preferredHeightChanging){this._preferredHeightChanging=!0;var t=this.matrix.isAligned()&&null!==this.preferredHeight?Math.abs(this.transform.inverseDeltaY(this.preferredHeight)):null;(null===this.localPreferredHeightProperty.value||null===t||Math.abs(this.localPreferredHeightProperty.value-t)>1e-9)&&(this.localPreferredHeightProperty.value=t),this._preferredHeightChanging=!1}}_updatePreferredHeight(){if(!this._preferredHeightChanging){this._preferredHeightChanging=!0;var t=this.matrix.isAligned()&&null!==this.localPreferredHeight?Math.abs(this.transform.transformDeltaY(this.localPreferredHeight)):null;(null===this.preferredHeightProperty.value||null===t||Math.abs(this.preferredHeightProperty.value-t)>1e-9)&&(this.preferredHeightProperty.value=t),this._preferredHeightChanging=!1}}_updateLocalMinimumHeight(){if(!this._minimumHeightChanging){this._minimumHeightChanging=!0;var t=this.matrix.isAligned()&&null!==this.minimumHeight?Math.abs(this.transform.inverseDeltaY(this.minimumHeight)):null;(null===this.localMinimumHeightProperty.value||null===t||Math.abs(this.localMinimumHeightProperty.value-t)>1e-9)&&(this.localMinimumHeightProperty.value=t),this._minimumHeightChanging=!1}}_updateMinimumHeight(){if(!this._minimumHeightChanging){this._minimumHeightChanging=!0;var t=this.matrix.isAligned()&&null!==this.localMinimumHeight?Math.abs(this.transform.transformDeltaY(this.localMinimumHeight)):null;(null===this.minimumHeightProperty.value||null===t||Math.abs(this.minimumHeightProperty.value-t)>1e-9)&&(this.minimumHeightProperty.value=t),this._minimumHeightChanging=!1}}});if(t.prototype._mutatorKeys){var i=t.prototype._mutatorKeys,s=Ah,n=i.indexOf(oh[0]);e.prototype._mutatorKeys=[...i.slice(0,n),...s,...i.slice(n)]}return e}),Ch=t=>t.heightSizable,Dh=t=>t.mixesHeightSizable;bs.register("HeightSizable",Eh);var Ih=Eh,Lh=["preferredSize","minimumSize","localPreferredSize","localMinimumSize","sizable"],kh=["preferredSize","minimumSize","localPreferredSize","localMinimumSize","sizable",...Ph,...Ah],Mh=Ei(t=>{var e=Sh(Ih(t)),i=tl("Sizable",Lh,class extends e{constructor(){super(...arguments)}get preferredSize(){return null===this.preferredWidth||null===this.preferredHeight?null:new Wa(this.preferredWidth,this.preferredHeight)}set preferredSize(t){this.preferredWidth=null===t?null:t.width,this.preferredHeight=null===t?null:t.height}get localPreferredSize(){return null===this.localPreferredWidth||null===this.localPreferredHeight?null:new Wa(this.localPreferredWidth,this.localPreferredHeight)}set localPreferredSize(t){this.localPreferredWidth=null===t?null:t.width,this.localPreferredHeight=null===t?null:t.height}get minimumSize(){return null===this.minimumWidth||null===this.minimumHeight?null:new Wa(this.minimumWidth,this.minimumHeight)}set minimumSize(t){this.minimumWidth=null===t?null:t.width,this.minimumHeight=null===t?null:t.height}get localMinimumSize(){return null===this.localMinimumWidth||null===this.localMinimumHeight?null:new Wa(this.localMinimumWidth,this.localMinimumHeight)}set localMinimumSize(t){this.localMinimumWidth=null===t?null:t.width,this.localMinimumHeight=null===t?null:t.height}get sizable(){return this.widthSizable}set sizable(t){this.widthSizable=t,this.heightSizable=t}get mixesSizable(){return!0}validateLocalPreferredSize(){0}mutate(t){return Y(t,["preferredSize"],["preferredWidth","preferredHeight"]),Y(t,["localPreferredSize"],["localPreferredWidth","localPreferredHeight"]),Y(t,["minimumSize"],["minimumWidth","minimumHeight"]),Y(t,["localMinimumSize"],["localMinimumWidth","localMinimumHeight"]),Y(t,["sizable"],["widthSizable","heightSizable"]),super.mutate(t)}});if(e.prototype._mutatorKeys){var s=e.prototype._mutatorKeys,n=Lh,r=s.indexOf(oh[0]);i.prototype._mutatorKeys=[...s.slice(0,r),...n,...s.slice(r)]}return i});bs.register("Sizable",Mh);var Oh=Mh,Rh=go.PDOM_UNIQUE_ID_SEPARATOR;class Nh{constructor(t){if(t instanceof Nh){var e=t;return this.nodes=e.nodes.slice(0),this.length=e.length,this.uniqueId=e.uniqueId,void(this.indices=e.indices.slice(0))}if(this.nodes=[],this.length=0,this.uniqueId="",this.indices=[],t)if(t instanceof uh){var i=t;this.addDescendant(i)}else for(var s=t.length,n=0;n!1===t.pickable||!t.visible)&&!!_.some(this.nodes,t=>t._inputListeners.length>0||!0===t.pickableProperty.value)}get(t){return t>=0?this.nodes[t]:this.nodes[this.nodes.length+t]}slice(t,e){return new Nh(this.nodes.slice(t,e))}subtrailTo(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.slice(0,_.indexOf(this.nodes,t)+(e?0:1))}isEmpty(){return 0===this.nodes.length}getMatrix(){for(var t=wn.identity(),e=this.nodes,i=e.length,s=0;s=0;e--)this.removeDescendant()}reindex(){for(var t=this.length,e=1;e=i;e--)s=this.nodes[e].getMatrix().timesMatrix(s);for(e=i;e0)return t.push(e._children[0]),new Nh(t);for(var i=this.nodes.length-1;i>0;){var s=this.nodes[i],n=this.nodes[i-1];t.pop();var r=_.indexOf(n._children,s);if(r!==n._children.length-1)return t.push(n._children[r+1]),new Nh(t);i--}return null}nextPainted(){for(var t=this.next();t&&!t.isPainted();)t=t.next();return t}eachTrailUnder(t){new Bh(this,!0).eachTrailBetween(new Bh(this,!1),t)}compare(t){for(var e=Math.min(this.nodes.length,t.nodes.length),i=0;it.nodes.length?1:0}isBefore(t){return-1===this.compare(t)}isAfter(t){return 1===this.compare(t)}localToGlobalPoint(t){return this.getMatrix().timesVector2(t)}localToGlobalBounds(t){return t.transformed(this.getMatrix())}globalToLocalPoint(t){return this.getTransform().inversePosition2(t)}globalToLocalBounds(t){return this.getTransform().inverseBounds2(t)}parentToGlobalPoint(t){return this.getParentMatrix().timesVector2(t)}parentToGlobalBounds(t){return t.transformed(this.getParentMatrix())}globalToParentPoint(t){return this.getParentTransform().inversePosition2(t)}globalToParentBounds(t){return this.getParentTransform().inverseBounds2(t)}updateUniqueId(){var t="",e=this.nodes.length;e>0&&(t+=this.nodes[0]._id);for(var i=1;i{var e=t.constructor.name;return"Node"===e&&(e="."),e}).join("/")}toDebugString(){return"".concat(this.toString()," ").concat(this.toPathString())}static eachPaintedTrailBetween(t,e,i,s,n){Nh.eachTrailBetween(t,e,t=>!!t.isPainted()&&i(t),s,n)}static eachTrailBetween(t,e,i,s,n){var r=new Bh(t?t.copy():new Nh(n),!0),a=e?new Bh(e.copy(),!0):new Bh(new Nh(n),!1);s&&(r.nestedForwards(),a.nestedBackwards(),1===r.compareNested(a))||r.depthFirstUntil(a,t=>!!t.isBefore&&i(t.trail),!1)}static branchIndex(t,e){var i,s=Math.min(t.length,e.length);for(i=0;iNumber(t)),s=t,n=(i.shift(),[s]);i.length>0;)for(var r=i.shift(),a=(s.pdomOrder||[]).concat(s.children),o=0;o0?this.trail.addDescendant(t[0],0):this.setBefore(!1)}else{if(0===this.trail.indices.length)return this.trail=null,null;var e=this.trail.indices[this.trail.indices.length-1];this.trail.removeDescendant();var i=this.trail.lastNode()._children;i.length>e+1&&(this.trail.addDescendant(i[e+1],e+1),this.setBefore(!0))}return this}nestedBackwards(){if(this.isBefore){if(0===this.trail.indices.length)return this.trail=null,null;var t=this.trail.indices[this.trail.indices.length-1];this.trail.removeDescendant(),t-1>=0&&(this.trail.addDescendant(this.trail.lastNode()._children[t-1],t-1),this.setBefore(!1))}else if(this.trail.lastNode()._children.length>0){var e=this.trail.lastNode()._children;this.trail.addDescendant(e[e.length-1],e.length-1)}else this.setBefore(!0);return this}eachNodeBetween(t,e){this.eachTrailBetween(t,t=>e(t.lastNode()))}eachTrailBetween(t,e){this.isBefore&&e(this.trail),this.depthFirstUntil(t,t=>!!t.isBefore&&e(t.trail),!0)}depthFirstUntil(t,e,i){var s=t;this.trail.reindex(),s.trail.reindex();var n=this.copy();n.trail.setMutable();for(var r=!0;!n.equalsNested(t);){var a=!1;if(r?(i||(a=e(n)),r=!1):a=e(n),a&&n.isBefore){if(n.setBefore(!1),1===n.compareNested(t))break}else n.nestedForwards()}i||e(n)}toString(){return"[".concat(this.isBefore?"before":"after"," ").concat(this.trail.toString().slice(1))}static compareNested(t,e,i,s){var n=t.compare(i);return 0===n?e===s?0:e?-1:1:t.isExtensionOf(i)?s?1:-1:i.isExtensionOf(t)?e?-1:1:n}}bs.register("TrailPointer",Bh);class Fh extends ae{constructor(t,e){super([]),_defineProperty(this,"listenedNodeSet",new Set),this.rootNode=t,this.leafNode=e,this._trailUpdateListener=this.update.bind(this),this.update()}update(){var t=[],e=new Set,i=new Nh(this.leafNode),s=this.rootNode;!function n(){var r=i.rootNode();e.add(r),r===s&&t.push(i.copy()),r.parents.forEach(t=>{i.addAncestor(t),n(),i.removeAncestor()})}(),e.forEach(t=>{this.listenedNodeSet.has(t)||this.addNodeListener(t)}),this.listenedNodeSet.forEach(t=>{e.has(t)||this.removeNodeListener(t)});var n=this.value,r=n.length===t.length;if(r)for(var a=0;athis.removeNodeListener(t)),super.dispose()}}bs.register("TrailsBetweenProperty",Fh);var Vh=(t,e)=>{0};f.register("assertHasProperties",Vh);var Hh=Vh,Yh=Yi.safari5,zh=["fill","fillPickable","stroke","strokePickable","lineWidth","lineCap","lineJoin","miterLimit","lineDash","lineDashOffset","cachedPaints"],Wh={fill:null,fillPickable:!0,stroke:null,strokePickable:!1,lineWidth:xr.lineWidth,lineCap:xr.lineCap,lineJoin:xr.lineJoin,lineDashOffset:xr.lineDashOffset,miterLimit:xr.miterLimit},Uh=["fill","stroke","lineWidth","lineOptions","cachedPaints"],Gh=Ei(t=>class extends t{constructor(){super(...arguments),Hh(this,["_drawables"]),this._fill=Wh.fill,this._fillPickable=Wh.fillPickable,this._stroke=Wh.stroke,this._strokePickable=Wh.strokePickable,this._cachedPaints=[],this._lineDrawingStyles=new Tr}setFill(t){return this._fill!==t&&(this._fill=t,this.invalidateFill()),this}set fill(t){this.setFill(t)}get fill(){return this.getFill()}getFill(){return this._fill}hasFill(){return null!==this.getFillValue()}getFillValue(){var t=this.getFill();return t instanceof ce?t.get():t}get fillValue(){return this.getFillValue()}setStroke(t){return this._stroke!==t&&(this._stroke=t,this.invalidateStroke()),this}set stroke(t){this.setStroke(t)}get stroke(){return this.getStroke()}getStroke(){return this._stroke}hasStroke(){return null!==this.getStrokeValue()}hasPaintableStroke(){return this.hasStroke()&&this.getLineWidth()>0}getStrokeValue(){var t=this.getStroke();return t instanceof ce?t.get():t}get strokeValue(){return this.getStrokeValue()}setFillPickable(t){return this._fillPickable!==t&&(this._fillPickable=t,this.invalidateFill()),this}set fillPickable(t){this.setFillPickable(t)}get fillPickable(){return this.isFillPickable()}isFillPickable(){return this._fillPickable}setStrokePickable(t){return this._strokePickable!==t&&(this._strokePickable=t,this.invalidateStroke()),this}set strokePickable(t){this.setStrokePickable(t)}get strokePickable(){return this.isStrokePickable()}isStrokePickable(){return this._strokePickable}setLineWidth(t){if(this.getLineWidth()!==t){this._lineDrawingStyles.lineWidth=t,this.invalidateStroke();for(var e=this._drawables.length,i=0;it instanceof xo);for(var e=this._drawables.length,i=0;i{this[t]!==s[t]&&i(t,this[t])}),this.lineDash.length&&i("lineDash",JSON.stringify(this.lineDash),!0)}return e}getFillRendererBitmask(){var t=0;return Yh&&this._fill instanceof To||(t|=on.bitmaskSVG),t|=on.bitmaskCanvas,this.hasFill()&&(this._fill instanceof Eo||this._fill instanceof To)||(t|=on.bitmaskDOM,t|=on.bitmaskWebGL),t}getStrokeRendererBitmask(){var t=0;return t|=on.bitmaskCanvas,t|=on.bitmaskSVG,this.hasStroke()||(t|=on.bitmaskDOM,t|=on.bitmaskWebGL),t}invalidateFill(){this.invalidateSupportedRenderers();for(var t=this._drawables.length,e=0;e(qh||(qh=document.createElement("canvas")),qh),Qh=t=>class extends t{constructor(){super(...arguments),this._image=null,this._initialWidth=jh.initialWidth,this._initialHeight=jh.initialHeight,this._imageOpacity=jh.imageOpacity,this._mipmap=jh.mipmap,this._mipmapBias=jh.mipmapBias,this._mipmapInitialLevel=jh.mipmapInitialLevel,this._mipmapMaxLevel=jh.mipmapMaxLevel,this._hitTestPixels=jh.hitTestPixels,this._mipmapCanvases=[],this._mipmapURLs=[],this._mipmapData=null,this._imageLoadListener=this._onImageLoad.bind(this),this._imageLoadListenerAttached=!1,this._hitTestImageData=null,this.mipmapEmitter=new c}setImage(t){var e=this._image!==t;if(e&&"string"==typeof t&&this._image&&this._image instanceof HTMLImageElement&&t===this._image.src&&(e=!1),e&&t===this._mipmapData&&(e=!1),e){if(this._initialWidth=0,this._initialHeight=0,this._image&&this._imageLoadListenerAttached&&this._detachImageLoadListener(),this._mipmapData=null,"string"==typeof t){var i=t;(t=document.createElement("img")).src=i}else Array.isArray(t)&&(this._mipmapData=t,t=t[0].img,this._mipmapInitialLevel=this._mipmapMaxLevel=this._mipmapData.length,this._mipmap=!0);this._image=t,!(this._image instanceof HTMLImageElement)||this._image.width&&this._image.height||this._attachImageLoadListener(),this.invalidateImage()}return this}set image(t){this.setImage(t)}get image(){return this.getImage()}getImage(){return this._image}invalidateImage(){this.invalidateMipmaps(),this._invalidateHitTestData()}setImageWithSize(t,e,i){return this.setImage(t),this.setInitialWidth(e),this.setInitialHeight(i),this}setImageOpacity(t){this._imageOpacity!==t&&(this._imageOpacity=t)}set imageOpacity(t){this.setImageOpacity(t)}get imageOpacity(){return this.getImageOpacity()}getImageOpacity(){return this._imageOpacity}setInitialWidth(t){return t!==this._initialWidth&&(this._initialWidth=t,this.invalidateImage()),this}set initialWidth(t){this.setInitialWidth(t)}get initialWidth(){return this.getInitialWidth()}getInitialWidth(){return this._initialWidth}setInitialHeight(t){return t!==this._initialHeight&&(this._initialHeight=t,this.invalidateImage()),this}set initialHeight(t){this.setInitialHeight(t)}get initialHeight(){return this.getInitialHeight()}getInitialHeight(){return this._initialHeight}setMipmap(t){return this._mipmap!==t&&(this._mipmap=t,this.invalidateMipmaps()),this}set mipmap(t){this.setMipmap(t)}get mipmap(){return this.isMipmap()}isMipmap(){return this._mipmap}setMipmapBias(t){return this._mipmapBias!==t&&(this._mipmapBias=t,this.invalidateMipmaps()),this}set mipmapBias(t){this.setMipmapBias(t)}get mipmapBias(){return this.getMipmapBias()}getMipmapBias(){return this._mipmapBias}setMipmapInitialLevel(t){return this._mipmapInitialLevel!==t&&(this._mipmapInitialLevel=t,this.invalidateMipmaps()),this}set mipmapInitialLevel(t){this.setMipmapInitialLevel(t)}get mipmapInitialLevel(){return this.getMipmapInitialLevel()}getMipmapInitialLevel(){return this._mipmapInitialLevel}setMipmapMaxLevel(t){return this._mipmapMaxLevel!==t&&(this._mipmapMaxLevel=t,this.invalidateMipmaps()),this}set mipmapMaxLevel(t){this.setMipmapMaxLevel(t)}get mipmapMaxLevel(){return this.getMipmapMaxLevel()}getMipmapMaxLevel(){return this._mipmapMaxLevel}setHitTestPixels(t){return this._hitTestPixels!==t&&(this._hitTestPixels=t,this._invalidateHitTestData()),this}set hitTestPixels(t){this.setHitTestPixels(t)}get hitTestPixels(){return this.getHitTestPixels()}getHitTestPixels(){return this._hitTestPixels}_constructNextMipmap(){var t=this._mipmapCanvases.length,e=this._mipmapCanvases[t-1];if(e.width*e.height>2){var i=document.createElement("canvas");if(i.width=Math.ceil(e.width/2),i.height=Math.ceil(e.height/2),i.width>0&&i.height>0){var s=i.getContext("2d");s.scale(.5,.5),s.drawImage(e,0,0),this._mipmapCanvases.push(i),this._mipmapURLs.push(i.toDataURL())}}}invalidateMipmaps(){if(ri(this._mipmapCanvases),ri(this._mipmapURLs),this._image&&this._mipmap)if(this._mipmapData)for(var t=0;t1&&void 0!==arguments[1]?arguments[1]:0,i=Qh.getApproximateMatrixScale(t)*(window.devicePixelRatio||1);return this.getMipmapLevelFromScale(i,e)}getMipmapLevelFromScale(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t>=1)return 0;var i=Xh(1/t);if((i=Vs.roundSymmetric(i+this._mipmapBias+e-.7))<0&&(i=0),i>this._mipmapMaxLevel&&(i=this._mipmapMaxLevel),this.mipmap&&!this._mipmapCanvases[i]){for(var s=this._mipmapCanvases.length-1;++s<=i;)this._constructNextMipmap();return Math.min(i,this._mipmapCanvases.length-1)}return i}getMipmapCanvas(t){if(this._mipmapData){var e=this._mipmapData[t]&&this._mipmapData[t].updateCanvas;e&&e()}return this._mipmapCanvases[t]}getMipmapURL(t){return this._mipmapURLs[t]}hasMipmaps(){return this._mipmapCanvases.length>0}_invalidateHitTestData(){this._hitTestPixels&&null!==this._image&&(this._hitTestImageData=Qh.getHitTestData(this._image,this.imageWidth,this.imageHeight))}getImageWidth(){if(null===this._image)return 0;var t=this._mipmapData?this._mipmapData[0].width:("naturalWidth"in this._image?this._image.naturalWidth:0)||this._image.width;return 0===t?this._initialWidth:t}get imageWidth(){return this.getImageWidth()}getImageHeight(){if(null===this._image)return 0;var t=this._mipmapData?this._mipmapData[0].height:("naturalHeight"in this._image?this._image.naturalHeight:0)||this._image.height;return 0===t?this._initialHeight:t}get imageHeight(){return this.getImageHeight()}getImageURL(){return this._image.src}_attachImageLoadListener(){this.isDisposed||(this._image.addEventListener("load",this._imageLoadListener),this._imageLoadListenerAttached=!0)}_detachImageLoadListener(){this._image.removeEventListener("load",this._imageLoadListener),this._imageLoadListenerAttached=!1}_onImageLoad(){this.invalidateImage(),this._detachImageLoadListener()}dispose(){this._image&&this._imageLoadListenerAttached&&this._detachImageLoadListener(),super.dispose&&super.dispose()}};Qh.getHitTestData=(t,e,i)=>{if(!("naturalWidth"in t&&t.naturalWidth||t.width)||!("naturalHeight"in t&&t.naturalHeight||t.height))return null;var s=Zh(),n=(Kh||(Kh=Zh().getContext("2d")),Kh);return s.width=e,s.height=i,n.drawImage(t,0,0),n.getImageData(0,0,e,i)},Qh.testHitTestData=(t,e,i,s)=>{var n=4*(Vs.clamp(Math.floor(s.x/e*t.width),0,t.width-1)+Vs.clamp(Math.floor(s.y/i*t.height),0,t.height-1)*t.width)+3;return 0!==t.data[n]},Qh.hitTestDataToShape=(t,e,i)=>{for(var s=e/t.width,n=i/t.height,r=new aa,a=!1,o=0,h=0;h{var s=document.createElementNS(ln,"image");return s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("width","".concat(e,"px")),s.setAttribute("height","".concat(i,"px")),s.setAttributeNS(un,"xlink:href",t),s},Qh.createFastMipmapFromCanvas=t=>{var e=[],i=t.toDataURL(),s=new window.Image;s.src=i,e.push({img:s,url:i,width:t.width,height:t.height,canvas:t});for(var n=t;n.width>=2&&n.height>=2;){var r=document.createElement("canvas");r.width=Math.ceil(n.width/2),r.height=Math.ceil(n.height/2);var a=r.getContext("2d");a.setTransform(.5,0,0,.5,0,0),a.drawImage(n,0,0);var o={width:r.width,height:r.height,canvas:r,url:r.toDataURL(),img:new window.Image};o.img.src=o.url,n=r,e.push(o)}return e},Qh.getApproximateMatrixScale=t=>(Math.sqrt(t.m00()*t.m00()+t.m10()*t.m10())+Math.sqrt(t.m01()*t.m01()+t.m11()*t.m11()))/2,Qh.CANVAS_MIPMAP_BIAS_ADJUSTMENT=.5,Qh.DEFAULT_OPTIONS=jh,bs.register("Imageable",Qh);var Jh=Qh,$h=(t,e,i)=>{var s="_".concat(t,"PendingOptions"),n="_".concat(t,"IsConstructed");return class extends i{constructor(){super(...arguments),this[n]=!0,this.mutate(this[s]),this[s]=void 0}mutate(t){return t&&!this[n]&&(this[s]=T(this[s]||{},_.pick(t,e)),t=_.omit(t,e)),super.mutate(t)}}};bs.register("DelayedMutate",$h);var tl=$h;class el extends(Jh(uh)){constructor(t,e){var i=w()({image:t},e);super(),this._imageBounds=null,this.mutate(i),this.invalidateSupportedRenderers()}invalidateImage(){this._image?this.invalidateSelf(this._imageBounds||new mn(0,0,this.getImageWidth(),this.getImageHeight())):this.invalidateSelf(mn.NOTHING);for(var t=this._drawables.length,e=0;epath)"):""}dispose(){this._invalidShapeListenerAttached&&this.detachShapeListener(),super.dispose()}}_defineProperty(sl,"DEFAULT_PATH_OPTIONS",T({},uh.DEFAULT_NODE_OPTIONS,il)),sl.prototype._mutatorKeys=[...zh,"boundsMethod","shape",...uh.prototype._mutatorKeys],sl.prototype.drawableMarkFlags=[...uh.prototype.drawableMarkFlags,...Uh,"shape"],bs.register("Path",sl);var nl=window.navigator.userAgent.includes("like Gecko) Version/5")&&window.navigator.userAgent.includes("Safari/");class rl extends(Gh(uh)){constructor(t,e){super(),this._textProperty=new ti("",!0,this.onTextPropertyChange.bind(this)),this._font=nn.DEFAULT,this._boundsMethod="hybrid",this._isHTML=!1,this._cachedRenderedText=null;var i=Pi({fill:"#000000",tandem:Ct.OPTIONAL,phetioType:rl.TextIO},e);"string"==typeof t||"number"==typeof t?i.text=t:i.textProperty=t,this.textTandem=i.tandem,this.mutate(i),this.invalidateSupportedRenderers()}mutate(t){return super.mutate(t)}setText(t){return t="".concat(t),this._textProperty.set(t),this}set text(t){this.setText(t)}get text(){return this.getText()}getText(){return this._textProperty.value}getRenderedText(){return null===this._cachedRenderedText&&(this._cachedRenderedText=this.text.replace(" "," "),Yi.edge&&(this._cachedRenderedText=rl.simplifyEmbeddingMarks(this._cachedRenderedText))),this._cachedRenderedText}get renderedText(){return this.getRenderedText()}onTextPropertyChange(){this._cachedRenderedText=null;for(var t=this._drawables.length,e=0;enew $e(this.text,T({phetioReadOnly:this.phetioReadOnly,tandem:this.tandem.createTandem("textProperty"),phetioDocumentation:"Property for the displayed text"},e.textPropertyOptions)))}setBoundsMethod(t){if(t!==this._boundsMethod){this._boundsMethod=t,this.invalidateSupportedRenderers();for(var e=this._drawables.length,i=0;i=0;e--){var i=t.children[e];"string"!=typeof i&&t.dir===i.dir&&t.children.splice(e,1,...i.children)}}(e),function t(e){for(var i=e.children.length-1;i>=1;i--){var s=e.children[i-1],n=e.children[i];"string"!=typeof n&&"string"!=typeof s&&n.dir&&s.dir===n.dir&&(s.children=s.children.concat(n.children),e.children.splice(i,1),t(s))}}(e)}return e}(e))}}rl.prototype._mutatorKeys=[...zh,"boundsMethod","textProperty","text","font","fontWeight","fontFamily","fontStretch","fontStyle","fontSize",...uh.prototype._mutatorKeys],rl.prototype.drawableMarkFlags=[...uh.prototype.drawableMarkFlags,...Uh,"text","font","bounds"],bs.register("Text",rl);var al="‪",ol="‫",hl="‬";to.initializeTextBounds(),rl.TextIO=new j("TextIO",{valueType:rl,supertype:uh.NodeIO,documentation:"Text that is displayed in the simulation. TextIO has a nested PropertyIO.<String> for the current string value."});class ll extends uh{constructor(t){super(t),this.setRendererBitmask(on.bitmaskCanvas)}setCanvasBounds(t){this.invalidateSelf(t)}set canvasBounds(t){this.setCanvasBounds(t)}get canvasBounds(){return this.getCanvasBounds()}getCanvasBounds(){return this.getSelfBounds()}isPainted(){return!0}invalidatePaint(){for(var t=this._drawables.length,e=0;es+this._radius||i>n+this._radius)&&(e<=s||i<=n||(e-=s)*e+(i-=n)*i<=this._radius*this._radius)}canvasPaintSelf(t,e){Kp.prototype.paintCanvas(t,this,e)}createDOMDrawable(t,e){return Qp.createFromPool(t,e)}createSVGDrawable(t,e){return $p.createFromPool(t,e)}createCanvasDrawable(t,e){return Kp.createFromPool(t,e)}setRadius(t){if(this._radius!==t){this._radius=t,this.invalidateCircle();for(var e=this._drawables.length,i=0;i=r*r}return!1}setShape(t){if(null!==t)throw new Error("Cannot set the shape of a Circle to something non-null");return this.invalidatePath(),this}getShape(){return this._shape||(this._shape=this.createCircleShape()),this._shape}hasShape(){return!0}}dl.prototype._mutatorKeys=["radius"].concat(sl.prototype._mutatorKeys),dl.prototype.drawableMarkFlags=sl.prototype.drawableMarkFlags.concat(["radius"]).filter(t=>"shape"!==t),bs.register("Circle",dl);class ul extends uh{constructor(t,e){(t=>!(!t||!t.jquery))(t)&&(t=t[0]),super(),this._container=document.createElement("div"),this._$container=$(this._container),this._$container.css("position","absolute"),this._$container.css("left",0),this._$container.css("top",0),this.invalidateDOMLock=!1,this._preventTransform=!1,e=Pi({element:t},e),this.mutate(e),this.setRendererBitmask(on.bitmaskDOM)}calculateDOMBounds(){var t=$(this._element);return new mn(0,0,t.width(),t.height())}invalidateDOM(){if(!this.invalidateDOMLock){this.invalidateDOMLock=!0;var t=document.createElement("div");$(t).css({display:"hidden",padding:"0 !important",margin:"0 !important",position:"absolute",left:0,top:0,width:65535,height:65535}),this._container.removeChild(this._element),t.appendChild(this._element),document.body.appendChild(t);var e=this.calculateDOMBounds();this.invalidateSelf(e),this._$container.width(e.getWidth()),this._$container.height(e.getHeight()),document.body.removeChild(t),t.removeChild(this._element),this._container.appendChild(this._element),this.invalidateDOMLock=!1}}createDOMDrawable(t,e){return eg.createFromPool(t,e)}isPainted(){return!0}setElement(t){return this._element!==t&&(this._element&&this._container.removeChild(this._element),this._element=t,this._container.appendChild(this._element),this.invalidateDOM()),this}set element(t){this.setElement(t)}get element(){return this.getElement()}getElement(){return this._element}setPreventTransform(t){this._preventTransform!==t&&(this._preventTransform=t)}set preventTransform(t){this.setPreventTransform(t)}get preventTransform(){return this.isTransformPrevented()}isTransformPrevented(){return this._preventTransform}}ul.prototype._mutatorKeys=["element","preventTransform"].concat(uh.prototype._mutatorKeys),bs.register("DOM",ul);class cl extends sl{constructor(t,e,i,s,n){super(null),this._x1=0,this._y1=0,this._x2=0,this._y2=0,n="object"==typeof t?t instanceof Is?Pi({x1:t.x,y1:t.y,x2:e.x,y2:e.y,strokePickable:!0},i):Pi({strokePickable:!0},t):Pi({x1:t,y1:e,x2:i,y2:s,strokePickable:!0},n),this.mutate(n)}setLine(t,e,i,s){this._x1=t,this._y1=e,this._x2=i,this._y2=s;for(var n=this._drawables.length,r=0;r"shape"!==t),bs.register("Line",cl);var ml=Oh(sl);class pl extends ml{constructor(t,e,i,s,n,r,a){super(null,{sizable:!1});var o={};this._rectX=0,this._rectY=0,this._rectWidth=0,this._rectHeight=0,this._cornerXRadius=0,this._cornerYRadius=0,o="object"==typeof t?t instanceof mn?"number"!=typeof e?T(o,{rectBounds:t},e):T(o,{rectBounds:t,cornerXRadius:e,cornerYRadius:i},s):T(o,t):void 0===r?T(o,{rectX:t,rectY:e,rectWidth:i,rectHeight:s},n):T(o,{rectX:t,rectY:e,rectWidth:i,rectHeight:s,cornerXRadius:n,cornerYRadius:r},a),this.localPreferredWidthProperty.lazyLink(this.updatePreferredSizes.bind(this)),this.localPreferredHeightProperty.lazyLink(this.updatePreferredSizes.bind(this)),this.mutate(o)}getMaximumArcSize(){return Math.min(this._rectWidth/2,this._rectHeight/2)}getStrokeRendererBitmask(){var t=super.getStrokeRendererBitmask(),e=this.getStroke();return!e||e instanceof To||e instanceof Eo||this.hasLineDash()||("miter"===this.getLineJoin()||"round"===this.getLineJoin()&&Js.borderRadius)&&(t|=on.bitmaskDOM),this.hasStroke()||(t|=on.bitmaskWebGL),t}getPathRendererBitmask(){var t=on.bitmaskCanvas|on.bitmaskSVG,e=this.getMaximumArcSize();return(!this.hasStroke()||this.getLineWidth()<=this._rectHeight&&this.getLineWidth()<=this._rectWidth)&&(!this.isRounded()||Js.borderRadius&&this._cornerXRadius===this._cornerYRadius)&&this._cornerYRadius<=e&&this._cornerXRadius<=e&&(t|=on.bitmaskDOM),this.hasStroke()||this.isRounded()||(t|=on.bitmaskWebGL),t}setRect(t,e,i,s,n,r){var a=void 0!==n,o=void 0!==r;if(!(this._rectX!==t||this._rectY!==e||this._rectWidth!==i||this._rectHeight!==s||a&&this._cornerXRadius!==n||o&&this._cornerYRadius!==r))return this;this._rectX=t,this._rectY=e,this._rectWidth=i,this._rectHeight=s,this._cornerXRadius=a?n:this._cornerXRadius,this._cornerYRadius=o?r:this._cornerYRadius;for(var h=this._drawables.length,l=0;l=t&&a.x<=t+i&&a.y>=e&&a.y<=e+s;if(!o||n<=0||r<=0)return o;var h,l,d=Math.min(i/2,s/2);n=Math.min(d,n),r=Math.min(d,r);var u=!1;if(a.x=h):(h=t+i-n,u=u||a.x<=h),u)return!0;if(a.y=l):(l=e+s-r,u=u||a.y<=l),u)return!0;var c=a.x-h,m=a.y-l;return c/=n,m/=r,(c*=c)+(m*=m)<=1}static rect(t,e,i,s,n){return new pl(t,e,i,s,0,0,n)}static roundedRect(t,e,i,s,n,r,a){return new pl(t,e,i,s,n,r,a)}static bounds(t,e){return new pl(t.minX,t.minY,t.width,t.height,e)}static roundedBounds(t,e,i,s){return new pl(t.minX,t.minY,t.width,t.height,e,i,s)}static dimension(t,e){return new pl(0,0,t.width,t.height,0,0,e)}}pl.prototype._mutatorKeys=["rectBounds","rectSize","rectX","rectY","rectWidth","rectHeight","cornerRadius","cornerXRadius","cornerYRadius",...ml.prototype._mutatorKeys],pl.prototype.drawableMarkFlags=sl.prototype.drawableMarkFlags.concat(["x","y","width","height","cornerXRadius","cornerYRadius"]).filter(t=>"shape"!==t),bs.register("Rectangle",pl);class gl extends uh{constructor(t){var e=w()({sprites:[],spriteInstances:[],hitTestSprites:!1,renderer:"webgl"},t);super(),this._sprites=e.sprites,this._spriteInstances=e.spriteInstances,this._hitTestSprites=e.hitTestSprites,this.setRendererBitmask(on.bitmaskCanvas|on.bitmaskWebGL),this.mutate(e)}setCanvasBounds(t){this.invalidateSelf(t)}set canvasBounds(t){this.setCanvasBounds(t)}get canvasBounds(){return this.getCanvasBounds()}getCanvasBounds(){return this.getSelfBounds()}canvasPaintSelf(t,e){Dg.prototype.paintCanvas(t,this,e)}createCanvasDrawable(t,e){return Dg.createFromPool(t,e)}createWebGLDrawable(t,e){return Rg.createFromPool(t,e)}containsPointSelf(t){return!!super.containsPointSelf(t)&&(!this._hitTestSprites||!!this.getSpriteInstanceFromPoint(t))}getSpriteInstanceFromPoint(t){for(var e=this._spriteInstances.length-1;e>=0;e--)if(this._spriteInstances[e].containsPoint(t))return this._spriteInstances[e];return null}getSelfShape(){return this._hitTestSprites?aa.union(this._spriteInstances.map(t=>t.getShape())):aa.bounds(this.selfBounds)}isPainted(){return!0}invalidatePaint(){for(var t=this._drawables.length,e=0;eclass extends t{constructor(){super(...arguments)}insertChild(t,e){throw new Error("Attempt to insert child into Leaf")}removeChildWithIndex(t,e){throw new Error("Attempt to remove child from Leaf")}});bs.register("Leaf",fl);var yl=fl;class bl extends(yl(uh)){constructor(t,e,i){super(),this.localBounds=new mn(0,0,t,e),this.mutate(i)}}bs.register("Spacer",bl);bs.register("HStrut",class extends bl{constructor(t,e){super(t,0,e)}});class _l extends bl{constructor(t,e){super(0,t,e)}}bs.register("VStrut",_l);var Pl=1,wl=new Is(0,0);class xl extends(Jh(Object)){constructor(t,e,i){var s=w()({hitTestPixels:!1,pickable:!0,image:t},i);super(),this.id=Pl++,this.offset=e,this.pickable=s.pickable,this.shape=null,this.imageData=null,this.setImage(t),Di(this,Object.keys(Jh.DEFAULT_OPTIONS),s)}get width(){return this.imageWidth}get height(){return this.imageHeight}getShape(){if(!this.pickable)return new aa;if(!this.shape){if(this.hitTestPixels){if(this.ensureImageData(),!this.imageData)return new aa;this.shape=Jh.hitTestDataToShape(this.imageData,this.width,this.height)}else{if(!this.width||!this.height)return new aa;this.shape=aa.rect(0,0,this.width,this.height)}this.shape=this.shape.transformed(wn.translation(-this.offset.x,-this.offset.y))}return this.shape}ensureImageData(){!this.imageData&&this.width&&this.height&&(this.imageData=Jh.getHitTestData(this.image,this.width,this.height))}containsPoint(t){if(!this.pickable)return!1;var e=this.width,i=this.height;if(!e&&!i)return!1;var s=wl.set(t).add(this.offset);return!(s.x<0||s.y<0||s.x>e||s.y>i)&&(!this.hitTestPixels||(this.ensureImageData(),!!this.imageData&&Jh.testHitTestData(this.imageData,e,i,s)))}}bs.register("SpriteImage",xl);bs.register("Sprite",class{constructor(t){this.imageProperty=new me(t)}getShape(){return this.imageProperty.value.getShape()}containsPoint(t){return this.imageProperty.value.containsPoint(t)}});class Tl{constructor(t){this.primary=null,this.changeCallback=t,this.notifyChangeCallback=this.notifyChanged.bind(this),this.updateSecondaryListener=this.updateSecondary.bind(this),this.secondaryPropertyCountsMap={}}setPrimary(t){t!==this.primary&&(this.detachPrimary(this.primary),this.primary=t,this.attachPrimary(t),this.notifyChangeCallback())}clean(){this.detachPrimary(this.primary),this.primary=null}updateSecondary(t,e,i){for(var s=this.secondaryPropertyCountsMap[i.id],n=0;n()=>{this.onTransformChange(t)})(s-1);this._nodeTransformListeners.push(n),t.nodes[s].transformEmitter.addListener(n)}}dispose(){for(var t=1;t{this.trailVisibleProperty.set(t.isVisible())};this._nodeVisibilityListeners.push(s),t.nodes[i].visibleProperty.link(s)}this.boundTrailVisibilityChangedListener=this.onVisibilityChange.bind(this),this.trailVisibleProperty.link(this.boundTrailVisibilityChangedListener)}addListener(t){this._listeners.push(t)}removeListener(t){var e=_.indexOf(this._listeners,t);this._listeners.splice(e,1)}dispose(){for(var t=0;t{this.focusable=!1}};this.addInputListener(i),this.disposeFocusableHeadingNode=()=>{this.removeInputListener(i)}}focus(){this.focusable=!0,super.focus()}dispose(){this.disposeFocusableHeadingNode(),super.dispose()}}bs.register("FocusableHeadingNode",Yl);class zl{constructor(t){var e=this;this.outputUtteranceProperty=new me(new Wl(document.title,"off")),this.linearDOM=this.getLinearDOMElements(t),this.activeElement=null,this.activeLine=null,this.letterPosition=0,this.positionInLine=0,this.wordPosition=0,this.observers=[],this.keyState={},document.addEventListener("keydown",e=>{var i;this.keyState[e.keyCode]=!0;var s=e.shiftKey?"PREVIOUS":"NEXT";if(this.linearDOM=this.getLinearDOMElements(t),this.updateLiveElementList(),!this.activeElement||"application"!==this.activeElement.getAttribute("role")){if(this.keyState[40]&&!this.keyState[45])i=this.readNextPreviousLine("NEXT");else if(this.keyState[38]&&!this.keyState[45])i=this.readNextPreviousLine("PREVIOUS");else if(this.keyState[72]){i=this.readNextPreviousHeading(["H1","H2","H3","H4","H5","H6"],s)}else this.keyState[9]||(this.keyState[39]&&!this.keyState[17]?i=this.readNextPreviousCharacter("NEXT"):this.keyState[37]&&!this.keyState[17]?i=this.readNextPreviousCharacter("PREVIOUS"):this.keyState[37]&&this.keyState[17]?i=this.readNextPreviousWord("PREVIOUS"):this.keyState[39]&&this.keyState[17]?i=this.readNextPreviousWord("NEXT"):this.keyState[45]&&this.keyState[38]?i=this.readActiveLine():this.keyState[49]?i=this.readNextPreviousHeading(["H1"],s):this.keyState[50]?i=this.readNextPreviousHeading(["H2"],s):this.keyState[51]?i=this.readNextPreviousHeading(["H3"],s):this.keyState[52]?i=this.readNextPreviousHeading(["H4"],s):this.keyState[53]?i=this.readNextPreviousHeading(["H5"],s):this.keyState[54]?i=this.readNextPreviousHeading(["H6"],s):this.keyState[70]?i=this.readNextPreviousFormElement(s):this.keyState[66]?i=this.readNextPreviousButton(s):this.keyState[76]?i=this.readNextPreviousList(s):this.keyState[73]?i=this.readNextPreviousListItem(s):this.keyState[45]&&this.keyState[40]&&this.readEntireDocument());this.activeElement&&this.isFocusable(this.activeElement)&&this.activeElement.focus()," "===i&&(i="space"),i&&this.outputUtteranceProperty.set(new Wl(i,"off"))}}),document.addEventListener("keyup",t=>{this.keyState[t.keyCode]=!1}),document.addEventListener("focusin",(function(t){if(t.target!==e.activeElement){e.activeElement=t.target;var i=e.getAccessibleText(this.activeElement,!0);if(i){var s=e.activeElement.getAttribute("aria-live");e.outputUtteranceProperty.set(new Wl(i,s))}}}))}getLinearDOMElements(t){for(var e=t.getElementsByTagName("*"),i=[],s=0;s{t.getAttribute("aria-live")!==i&&t.getAttribute("role")!==i||(e=i)}),e}getNextPreviousElement(t){this.activeElement||(this.activeElement=this.linearDOM[0]);var e="NEXT"===t?1:-1,i=this.linearDOM.indexOf(this.activeElement)+e;return this.linearDOM[i]}getLabel(t){var e,i=document.getElementsByTagName("label");return Array.prototype.forEach.call(i,t=>{t.getAttribute("for")&&(e=t)}),e}getAccessibleText(t,e){var i="";if(!t)return"End of Document";if("ScreenView"===t.getAttribute("class"))return null;if("HEADER"===t.tagName)return null;if("SECTION"===t.tagName)return null;if("LABEL"===t.tagName)return null;for(var s=t;s.parentElement;){if(s.getAttribute("aria-hidden")||s.hidden)return null;s=s.parentElement}if("P"===t.tagName&&(i+=t.textContent),"H1"===t.tagName&&(i+="Heading Level 1, ".concat(t.textContent)),"H2"===t.tagName&&(i+="Heading Level 2, ".concat(t.textContent)),"H3"===t.tagName&&(i+="Heading Level 3, ".concat(t.textContent)),"UL"===t.tagName){var n=t.children.length;i+="List with ".concat(n," items")}if("LI"===t.tagName&&(i+="List Item: ".concat(t.textContent)),"BUTTON"===t.tagName){if(t.getAttribute("aria-pressed")){var r=" toggle";r+=" Button,","true"===t.getAttribute("aria-pressed")?r+=" pressed":r+=" not pressed",i+=t.textContent+","+r}else i+=t.textContent+" Button"}if("INPUT"===t.tagName&&("reset"===t.type&&(i+="".concat(t.getAttribute("value")," Button")),"checkbox"===t.type)){var a=this.getLabel(t.id).textContent;if("switch"===t.getAttribute("role")){var o=t.getAttribute("aria-checked");if(o){var h="true"===o?"On":"Off";i+="".concat(a+", ","switch").concat(",").concat(" ").concat(h)}}else{var l=t.checked?" Checked":" Not Checked";i+="".concat(t.textContent," Checkbox").concat(l)}}if(e){i.length>0&&(i+=",");var d=t.getAttribute("aria-label");d&&(i+=" "+d+",");var u,c=t.getAttribute("aria-labelledBy");if(c){var m=document.getElementById(c).textContent;i+=" "+m+","}for(s=t;s.parentElement;){if("document"===(u=s.getAttribute("role"))||"application"===u){i+=" "+u+",";break}s=s.parentElement}t.getAttribute("role")&&"button"===(u=t.getAttribute("role"))&&(i+="".concat(" ","Button")),t.draggable&&(i+="".concat(" ","draggable").concat(",")),"true"===t.getAttribute("aria-grabbed")&&(i+="".concat(" ","grabbed").concat(","));var p,g,v=t.getAttribute("aria-describedby");if(v)v.split(" ").forEach(t=>{p=document.getElementById(t),g=p.textContent,i+=" "+g})}return","===i[i.length-1]&&(i=i.slice(0,-1)),i}getNextPreviousElementWithPDOMContent(t){for(var e;!e;)this.activeElement=this.getNextPreviousElement(t),e=this.getAccessibleText(this.activeElement,!1);return this.activeElement}getNextPreviousElementWithRole(t,e){var i=null,s="NEXT"===e?1:-1;this.activeElement||(this.activeElement=this.linearDOM[0]);for(var n=this.linearDOM.indexOf(this.activeElement)+s;this.linearDOM[n];){for(var r=0;r{(t=>{t.forEach(t=>{for(var i,s=t.target;!i;)i=e.getLiveRole(s),s=s.parentElement;if(t.addedNodes[0]){var n=t.addedNodes[0].data;e.outputUtteranceProperty.set(new Wl(n,i))}})})(t)})).observe(n,{childList:!0,subtree:!0}),e.observers.push(t))}}readEntireDocument(){for(var t=this.getAccessibleText(this.activeElement),e=this.activeElement;"End of Document"!==t;)e=this.activeElement,"End of Document"===(t=this.readNextPreviousLine("NEXT"))&&(this.activeElement=e),this.outputUtteranceProperty.set(new Wl(t,"polite"))}isFocusable(t){var e=!1;return["tabindex","BUTTON","INPUT"].forEach(i=>{(t.getAttribute(i)||t.tagName===i)&&(e=!0)}),e}}bs.register("Cursor",zl);class Wl{constructor(t,e){this.text=t,this.liveRole=e}}class Ul{constructor(t){this.speakingStartedEmitter=new xe({parameters:[{valueType:Object}]}),this.speakingEndedEmitter=new xe({parameters:[{valueType:Object}]}),this.speaking=!1,this.politeUtterances=[];var e=navigator.userAgent,i=e.match(/Windows/),s=!!(e.match(/Version\/[5-9]\./)&&e.match(/Safari\//)&&e.match(/AppleWebKit/));window.speechSynthesis&&SpeechSynthesisUtterance&&window.speechSynthesis.speak?(this.synth=window.speechSynthesis,t.outputUtteranceProperty.link(t=>{var e,n=new SpeechSynthesisUtterance(t.text);if(n.addEventListener("start",e=>{this.speakingStartedEmitter.emit(t)}),n.addEventListener("end",e=>{this.speakingEndedEmitter.emit(t)}),this.synth.getVoices().forEach(t=>{t.default&&(e=t)}),n.voice=e,n.rate=1.2,"assertive"!==t.liveRole&&"off"!==t.liveRole&&t.liveRole){if("polite"===t.liveRole)if(s){this.politeUtterances.push(n);var r=()=>{this.speaking=!0;var t=this.politeUtterances.shift();t?this.synth.speak(t):this.speaking=!1};if(this.speaking)setTimeout(()=>{r()},2e3);else{this.synth.speak(n);var a=this.politeUtterances.indexOf(n);a>0&&this.politeUtterances.splice(a,1)}}else this.synth.speak(n)}else this.politeUtterances=[],this.speaking=!0,i?(this.synth.pause(),this.synth.cancel(),this.synth.speak(n),this.synth.resume()):(this.synth.cancel(),this.synth.speak(n))})):t.outputUtteranceProperty.link(()=>{this.speakingStartedEmitter.emit({text:"Sorry! Web Speech API not supported on this platform."})})}}bs.register("Reader",Ul);var Gl=[];class Xl extends we{constructor(t,e){var i=w()({parameters:Gl,phetioOuterType:Xl.PhetioActionIO,tandem:Ct.OPTIONAL,phetioState:!1,phetioReadOnly:Vt.DEFAULT_OPTIONS.phetioReadOnly,phetioHighFrequency:Vt.DEFAULT_OPTIONS.phetioHighFrequency,phetioEventType:Vt.DEFAULT_OPTIONS.phetioEventType,phetioDocumentation:"A class that wraps a function, adding API to execute that function and data stream capture."},e);super(i),this.action=t,this.isExecutingCount=0,this.disposeOnExecuteCompletion=!1,this.executedEmitter=new xe({parameters:i.parameters,tandem:i.tandem.createTandem("executedEmitter"),phetioState:i.phetioState,phetioReadOnly:i.phetioReadOnly,phetioHighFrequency:i.phetioHighFrequency,phetioEventType:i.phetioEventType,phetioDocumentation:"Emitter that emits when this actions work is complete"}),this.disposePhetioAction=()=>{this.executedEmitter.dispose()}}execute(){this.isExecutingCount++;for(var t=arguments.length,e=new Array(t),i=0;i0?this.disposeOnExecuteCompletion=!0:this.disposePhetioAction(),super.dispose()}}var jl=t=>t.typeName,ql=new Map;Xl.PhetioActionIO=t=>{var e=t.map(jl).join(",");return ql.has(e)||ql.set(e,new j("PhetioActionIO<".concat(t.map(jl).join(", "),">"),{valueType:Xl,documentation:"Executes when an event occurs",events:["executed"],parameterTypes:t,metadataDefaults:{phetioState:!1},methods:{execute:{returnType:Qt,parameterTypes:t,implementation:Xl.prototype.execute,documentation:"Executes the function the PhetioAction is wrapping.",invocableForReadOnlyElements:!1}}})),ql.get(e)},S.register("PhetioAction",Xl);var Kl=Xl;class Zl{constructor(t){_defineProperty(this,"keyState",{}),_defineProperty(this,"attachedToDocument",!1),_defineProperty(this,"documentKeyupListener",null),_defineProperty(this,"documentKeydownListener",null),_defineProperty(this,"_enabled",!0),_defineProperty(this,"keydownEmitter",new xe({parameters:[{valueType:KeyboardEvent}]})),_defineProperty(this,"keyupEmitter",new xe({parameters:[{valueType:KeyboardEvent}]}));var e=w()({tandem:Ct.OPTIONAL},t);this.keydownUpdateAction=new Kl(t=>{var e=qn.getEventCode(t);if(e){if(this.correctModifierKeys(t),!this.isKeyDown(e)){var i=qn.getEventCode(t);this.keyState[i]={keyDown:!0,key:i,timeDown:0}}this.keydownEmitter.emit(t)}},{phetioPlayback:!0,tandem:e.tandem.createTandem("keydownUpdateAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Action that executes whenever a keydown occurs from the input listeners this keyStateTracker adds (most likely to the document)."}),this.keyupUpdateAction=new Kl(t=>{var e=qn.getEventCode(t);e&&(this.correctModifierKeys(t),this.isKeyDown(e)&&delete this.keyState[e],this.keyupEmitter.emit(t))},{phetioPlayback:!0,tandem:e.tandem.createTandem("keyupUpdateAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Action that executes whenever a keyup occurs from the input listeners this keyStateTracker adds (most likely to the document)."});var i=this.step.bind(this);ve.addListener(i),this.disposeKeyStateTracker=()=>{ve.removeListener(i),this.attachedToDocument&&this.detachFromDocument()}}keydownUpdate(t){this.enabled&&this.keydownUpdateAction.execute(t)}correctModifierKeys(t){var e=qn.getEventCode(t);t.shiftKey&&!this.shiftKeyDown&&(this.keyState[qn.KEY_SHIFT_LEFT]={keyDown:!0,key:e,timeDown:0}),t.altKey&&!this.altKeyDown&&(this.keyState[qn.KEY_ALT_LEFT]={keyDown:!0,key:e,timeDown:0}),t.ctrlKey&&!this.ctrlKeyDown&&(this.keyState[qn.KEY_CONTROL_LEFT]={keyDown:!0,key:e,timeDown:0}),!t.shiftKey&&this.shiftKeyDown&&(delete this.keyState[qn.KEY_SHIFT_LEFT],delete this.keyState[qn.KEY_SHIFT_RIGHT]),!t.altKey&&this.altKeyDown&&(delete this.keyState[qn.KEY_ALT_LEFT],delete this.keyState[qn.KEY_ALT_RIGHT]),!t.ctrlKey&&this.ctrlKeyDown&&(delete this.keyState[qn.KEY_CONTROL_LEFT],delete this.keyState[qn.KEY_CONTROL_RIGHT])}keyupUpdate(t){this.enabled&&this.keyupUpdateAction.execute(t)}get movementKeysDown(){return this.isAnyKeyInListDown(qn.MOVEMENT_KEYS)}isKeyDown(t){return!!this.keyState[t]&&this.keyState[t].keyDown}isAnyKeyInListDown(t){for(var e=0;e0}get enterKeyDown(){return this.isKeyDown(qn.KEY_ENTER)}get shiftKeyDown(){return this.isAnyKeyInListDown(qn.SHIFT_KEYS)}get altKeyDown(){return this.isAnyKeyInListDown(qn.ALT_KEYS)}get ctrlKeyDown(){return this.isAnyKeyInListDown(qn.CONTROL_KEYS)}timeDownForKey(t){return this.keyState[t].timeDown}clearState(){this.keyState={}}step(t){if(this.keysAreDown()){var e=1e3*t;for(var i in this.keyState)this.keyState.hasOwnProperty(i)&&this.keyState[i].keyDown&&(this.keyState[i].timeDown+=e)}}attachToWindow(){this.documentKeydownListener=t=>{this.keydownUpdate(t)},this.documentKeyupListener=t=>{this.keyupUpdate(t)};var t=()=>{window.addEventListener("keyup",this.documentKeyupListener,!0),window.addEventListener("keydown",this.documentKeydownListener,!0),this.attachedToDocument=!0};if(document)t();else{var e=()=>{t(),window.removeEventListener("load",e)};window.addEventListener("load",e)}}setEnabled(t){this._enabled!==t&&(this._enabled=t,!t&&this.clearState())}set enabled(t){this.setEnabled(t)}get enabled(){return this.isEnabled()}isEnabled(){return this._enabled}detachFromDocument(){window.removeEventListener("keyup",this.documentKeyupListener),window.removeEventListener("keydown",this.documentKeydownListener),this.documentKeyupListener=null,this.documentKeydownListener=null,this.attachedToDocument=!1}dispose(){this.disposeKeyStateTracker()}}bs.register("KeyStateTracker",Zl);var Ql=Zl;var Jl=new class extends Ql{constructor(t){super(t),this.attachToWindow()}}({tandem:Ct.GENERAL_CONTROLLER.createTandem("keyStateTracker")});bs.register("globalKeyStateTracker",Jl);var $l=Jl,td=["interactiveHighlight","interactiveHighlightLayerable"],ed=t=>{var e=tl("InteractiveHighlightingClass",td,class extends t{constructor(){super(...arguments),this._activationListener={enter:this._onPointerEntered.bind(this),move:this._onPointerMove.bind(this),exit:this._onPointerExited.bind(this),down:this._onPointerDown.bind(this)},this._pointer=null,this.displays={},this._interactiveHighlight=null,this._interactiveHighlightLayerable=!1,this.interactiveHighlightChangedEmitter=new c,this._changedInstanceListener=this.onChangedInstance.bind(this),this.changedInstanceEmitter.addListener(this._changedInstanceListener),this._interactiveHighlightingEnabledListener=this._onInteractiveHighlightingEnabledChange.bind(this);var t=this._onPointerRelease.bind(this),e=this._onPointerCancel.bind(this);this._pointerListener={up:t,cancel:e,interrupt:e}}get isInteractiveHighlighting(){return!0}static get _mixesInteractiveHighlighting(){return!0}setInteractiveHighlight(t){this._interactiveHighlight!==t&&(this._interactiveHighlight=t,this._interactiveHighlightLayerable&&(t.visible=!1),this.interactiveHighlightChangedEmitter.emit())}set interactiveHighlight(t){this.setInteractiveHighlight(t)}get interactiveHighlight(){return this.getInteractiveHighlight()}getInteractiveHighlight(){return this._interactiveHighlight}setInteractiveHighlightLayerable(t){this._interactiveHighlightLayerable!==t&&(this._interactiveHighlightLayerable=t,this._interactiveHighlight&&(this._interactiveHighlight.visible=!1,this.interactiveHighlightChangedEmitter.emit()))}set interactiveHighlightLayerable(t){this.setInteractiveHighlightLayerable(t)}get interactiveHighlightLayerable(){return this.getInteractiveHighlightLayerable()}getInteractiveHighlightLayerable(){return this._interactiveHighlightLayerable}isInteractiveHighlightActivated(){for(var t=!1,e=Object.keys(this.displays),i=0;i{i&&this.enabledProperty.dispose()}}setEnabled(t){this.enabledProperty.value=t}set enabled(t){this.setEnabled(t)}get enabled(){return this.isEnabled()}isEnabled(){return this.enabledProperty.value}dispose(){this.disposeEnabledComponent()}}u.register("EnabledComponent",nd);var rd={initialize(){if(window.speechSynthesis||window.SpeechSynthesis||window.SpeechSynthesisUtterance)throw new Error("SpeechSynthesis is supported here, the polyfill should not overwrite it");window.SpeechSynthesis=window.parent.SpeechSynthesis,window.speechSynthesis=new window.parent.SpeechSynthesis,window.SpeechSynthesisUtterance=window.parent.SpeechSynthesisUtterance}};qi.register("SpeechSynthesisParentPolyfill",rd);var ad=rd;window.phet&&phet.chipper&&phet.chipper.queryParameters&&phet.chipper.queryParameters.speechSynthesisFromParent&&ad.initialize();var od={cancelSelf:!0,cancelOther:!0};class hd extends us{constructor(t){var e=w()({respectResponseCollectorProperties:!1,tandem:Ct.OPTIONAL},t);super(e),this.voiceProperty=new me(null,{tandem:e.tandem.createTandem("voiceProperty"),phetioValueType:Kt(ud),phetioReadOnly:!0,phetioState:!1}),this.voiceRateProperty=new Re(1,{range:new Le(.75,2),tandem:e.tandem.createTandem("voiceRateProperty"),phetioReadOnly:!0,phetioState:!1}),this.voicePitchProperty=new Re(1,{range:new Le(.5,2),tandem:e.tandem.createTandem("voicePitchProperty"),phetioReadOnly:!0,phetioState:!1}),this.voiceVolumeProperty=new Re(1,{range:new Le(0,1),tandem:e.tandem.createTandem("voiceVolumeProperty"),phetioReadOnly:!0,phetioState:!1}),this.hasSpoken=!1,this.timeSinceWakingEngine=0,this.timeSincePauseResume=0,this.timeSincePendingUtterance=0,this.timeSinceUtteranceEnd=125,this.startSpeakingEmitter=new xe({parameters:[{valueType:"string"},{valueType:ls}]}),this.endSpeakingEmitter=new xe({parameters:[{valueType:"string"},{valueType:ls}]}),this.voicesChangedEmitter=new xe,this.enabledComponentImplementation=new nd({enabled:!1,tandem:e.tandem.createTandem("enabledProperty"),enabledPropertyOptions:{phetioReadOnly:!0,phetioState:!1}}),this.enabledProperty=this.enabledComponentImplementation.enabledProperty,this.mainWindowVoicingEnabledProperty=new pe(!0,{tandem:e.tandem.createTandem("mainWindowVoicingEnabledProperty"),phetioReadOnly:!0,phetioState:!1}),this.voicingFullyEnabledProperty=Ue.and([this.enabledProperty,this.mainWindowVoicingEnabledProperty]),this._speechAllowedAndFullyEnabledProperty=new pe(!1),this.speechAllowedAndFullyEnabledProperty=this._speechAllowedAndFullyEnabledProperty,this.synth=null,this.voices=[],this.speakingSpeechSynthesisUtteranceWrapper=null,this.initialized=!1,this.canSpeakProperty=null,this.boundHandleCanSpeakChange=this.handleCanSpeakChange.bind(this),this.boundHandleCanAnnounceChange=this.handleCanAnnounceChange.bind(this),this.currentlySpeakingUtterance=null,this.pendingSpeechSynthesisUtteranceWrapper=null}initialize(t,e){var i=w()({speechAllowedProperty:new pe(!0)},e);this.synth=window.speechSynthesis,this.canSpeakProperty=Ue.and([i.speechAllowedProperty,this.enabledProperty]),this.canSpeakProperty.link(this.boundHandleCanSpeakChange),Je.multilink([i.speechAllowedProperty,this.voicingFullyEnabledProperty],(t,e)=>{this._speechAllowedAndFullyEnabledProperty.value=t&&e}),this.getSynth().onvoiceschanged=()=>{this.populateVoices()},this.populateVoices();var s=()=>{this.timeSinceWakingEngine=5e3,t.removeListener(s)};t.addListener(s),ve.addListener(this.step.bind(this)),this.initialized=!0}step(t){t*=1e3;var e=this.getSynth();this.initialized&&e&&(this.hasSpoken||(this.hasSpoken=e.speaking),this.timeSinceUtteranceEnd=e.speaking?0:this.timeSinceUtteranceEnd+t,this.timeSincePendingUtterance=this.pendingSpeechSynthesisUtteranceWrapper?this.timeSincePendingUtterance+t:0,this.timeSincePendingUtterance>5e3&&(this.handleSpeechSynthesisEnd(this.pendingSpeechSynthesisUtteranceWrapper.announceText,this.pendingSpeechSynthesisUtteranceWrapper),this.pendingSpeechSynthesisUtteranceWrapper=null,this.cancelSynth()),this.timeSinceUtteranceEnd>125&&!this.pendingSpeechSynthesisUtteranceWrapper&&(this.readyToAnnounce=!0),Yi.chromium&&!Yi.android&&this.voiceProperty.value&&!this.voiceProperty.value.localService&&(this.timeSincePauseResume=e.speaking?this.timeSincePauseResume+t:0,this.timeSincePauseResume>1e4&&(this.timeSincePauseResume=0,e.pause(),e.resume())),this.timeSinceWakingEngine+=t,!e.speaking&&this.timeSinceWakingEngine>5e3&&(this.timeSinceWakingEngine=0,e.speak(new SpeechSynthesisUtterance(""))))}handleCanSpeakChange(t){t||this.cancel()}populateVoices(){var t=this.getSynth();t&&(this.voices=_.uniqBy(t.getVoices(),t=>t.name),this.voicesChangedEmitter.emit())}getPrioritizedVoices(){var t=this.voices.slice(),e=e=>e.name.includes("Google")?-1:e.name.includes("Fred")?t.length:t.indexOf(e);return t.sort((t,i)=>e(t)-e(i))}announce(t,e){this.initialized&&this.canSpeakProperty.value?this.requestSpeech(t,e):this.handleAnnouncementFailure(e,t)}handleAnnouncementFailure(t,e){this.announcementCompleteEmitter.emit(t,e)}speakIgnoringEnabled(t){this.initialized&&this.requestSpeech(t.getAlertText(this.respectResponseCollectorProperties),t)}requestSpeech(t,e){if(t){var i=function(t){var e=himalaya;if(e){var i=e.parse(t).filter(dd);return e.stringify(i)}return t}(ao(t+""));R(i,M.STRING_WITHOUT_TEMPLATE_VARS_VALIDATOR);var s=new SpeechSynthesisUtterance(i);s.voice=this.voiceProperty.value,s.pitch=this.voicePitchProperty.value,s.rate=this.voiceRateProperty.value,s.volume=this.voiceVolumeProperty.value;var n=()=>{this.startSpeakingEmitter.emit(i,e),this.pendingSpeechSynthesisUtteranceWrapper=null,this.currentlySpeakingUtterance=e,e.canAnnounceProperty.link(this.boundHandleCanAnnounceChange),e.voicingCanAnnounceProperty.link(this.boundHandleCanAnnounceChange),this.speakingSpeechSynthesisUtteranceWrapper=a,s.removeEventListener("start",n)},r=()=>{this.handleSpeechSynthesisEnd(i,a)};s.addEventListener("start",n),s.addEventListener("end",r);var a=new ld(e,t,s,r);s.addEventListener("error",r),this.readyToAnnounce=!1,this.timeSinceUtteranceEnd=0,this.pendingSpeechSynthesisUtteranceWrapper=a,this.getSynth().speak(s)}else this.handleAnnouncementFailure(e,t)}handleCanAnnounceChange(t){t||this.cancelUtterance(this.currentlySpeakingUtterance)}handleSpeechSynthesisEnd(t,e){this.endSpeakingEmitter.emit(t,e.utterance),this.announcementCompleteEmitter.emit(e.utterance,e.speechSynthesisUtterance.text),e.speechSynthesisUtterance.removeEventListener("end",e.endListener);var i=e.utterance.canAnnounceProperty;i.hasListener(this.boundHandleCanAnnounceChange)&&i.unlink(this.boundHandleCanAnnounceChange);var s=e.utterance.voicingCanAnnounceProperty;s.hasListener(this.boundHandleCanAnnounceChange)&&s.unlink(this.boundHandleCanAnnounceChange),this.speakingSpeechSynthesisUtteranceWrapper=null,this.pendingSpeechSynthesisUtteranceWrapper=null,this.currentlySpeakingUtterance=null}getSynth(){return this.synth}cancel(){if(this.initialized){var t=this.speakingSpeechSynthesisUtteranceWrapper?this.speakingSpeechSynthesisUtteranceWrapper.utterance:this.pendingSpeechSynthesisUtteranceWrapper?this.pendingSpeechSynthesisUtteranceWrapper.utterance:null;t&&this.cancelUtterance(t)}}cancelUtterance(t){var e=t===this.currentlySpeakingUtterance?this.speakingSpeechSynthesisUtteranceWrapper:this.pendingSpeechSynthesisUtteranceWrapper&&t===this.pendingSpeechSynthesisUtteranceWrapper.utterance?this.pendingSpeechSynthesisUtteranceWrapper:null;e&&(this.handleSpeechSynthesisEnd(e.announceText,e),this.cancelSynth())}shouldUtteranceCancelOther(t,e){var i,s=x()({},od,t.announcerOptions);return e.priorityProperty.value!==t.priorityProperty.value?i=e.priorityProperty.value!("element"===t.type.toLowerCase()&&"br"===t.tagName.toLowerCase());var ud=new j("SpeechSynthesisVoiceIO",{isValidValue:t=>!0,toStateObject:t=>t.name});qi.register("SpeechSynthesisAnnouncer",hd);var cd=hd;var md=new class extends cd{constructor(t){super(w()({respectResponseCollectorProperties:!0,tandem:Ct.OPTIONAL,phetioDocumentation:"Announcer that manages the voicing feature, providing audio responses via WebAudio."},t))}initialize(t,e){super.initialize(t,e),$l.keyupEmitter.addListener(t=>{qn.isControlKey(t)&&this.cancel()})}}({tandem:Ct.GLOBAL_VIEW.createTandem("voicingManager"),phetioDocumentation:'The Announcer responsible for announcing` to WebSpeech for the "voicing" feature.'});bs.register("voicingManager",md);var pd=md;class gd{constructor(t){this.utterance=t,this.timeInQueue=0,this.stableTime=0,this.announcingUtterancePriorityListener=null}resetTimingVariables(){this.timeInQueue=0,this.stableTime=0}}qi.register("UtteranceWrapper",gd);var vd=gd;class fd extends Vt{constructor(t,e){var i=w()({debug:!1,initialize:!0,featureSpecificAnnouncingControlPropertyName:null},e);super(i),this.announcer=t,this._initialized=i.initialize,this.featureSpecificAnnouncingControlPropertyName=i.featureSpecificAnnouncingControlPropertyName,this.queue=[],this._muted=!1,this._enabled=!0,this.utteranceToPriorityListenerMap=new Map,this.announcingUtteranceWrapper=null,this.debug=i.debug,this.announcer.announcementCompleteEmitter.addListener(t=>{if(this.announcingUtteranceWrapper&&t===this.announcingUtteranceWrapper.utterance){var e=this.announcingUtteranceWrapper.announcingUtterancePriorityListener;this.announcingUtteranceWrapper.utterance.priorityProperty.hasListener(e)&&(this.announcingUtteranceWrapper.utterance.priorityProperty.unlink(e),this.announcingUtteranceWrapper.announcingUtterancePriorityListener=null,this.announcingUtteranceWrapper=null)}}),this.stepQueueListener=null,this._initialized&&(this.stepQueueListener=this.stepQueue.bind(this),ve.addListener(this.stepQueueListener))}get length(){return this.queue.length}addToBack(t){if(this.initializedAndEnabled)if(this.announcer.hasSpoken){var e=this.prepareUtterance(t);this.queue.push(e),this.debug&&console.log("addToBack"),this.addPriorityListenerAndPrioritizeQueue(e)}else this.announceImmediately(t)}addToFront(t){if(C("`addToFront()` has been deprecated because it is confusing, and most of the time doesn't do what is expected, because Utterances are announced based on time-in-queue first, and then position in the queue. It is recommended to use addToBack, and then timing variables on Utterances, or instead call queue.clear() before adding a more important alert to the queue."),this.initializedAndEnabled){var e=this.prepareUtterance(t);this.queue.unshift(e)}}addPriorityListenerAndPrioritizeQueue(t){var e=()=>{this.prioritizeUtterances(t)};t.utterance.priorityProperty.lazyLink(e),this.utteranceToPriorityListenerMap.set(t.utterance,e),this.prioritizeUtterances(t)}prepareUtterance(t){t instanceof ls||(t=new ls({alert:t}));var e=new vd(t);return this.removeOthersAndUpdateUtteranceWrapper(e),e.stableTime=0,e}removeUtterance(t){var e=e=>e.utterance===t,i=_.remove(this.queue,e);this.removePriorityListeners(i)}prioritizeUtterances(t){for(var e=this.queue.indexOf(t),i=e>=0,s=i?e-1:-1;s>=0;s--){var n=this.queue[s];this.shouldUtteranceCancelOther(t.utterance,n.utterance)&&this.removeUtterance(n.utterance)}if(i){var r=this.queue[e+1];r&&this.shouldUtteranceCancelOther(r.utterance,t.utterance)&&this.removeUtterance(t.utterance)}this.queue.length>0&&this.announcer.onUtterancePriorityChange(this.queue[0].utterance)}shouldUtteranceCancelOther(t,e){return this.announcer.shouldUtteranceCancelOther(t,e)}removeOthersAndUpdateUtteranceWrapper(t){for(var e=[],i=0;i=1&&(t.timeInQueue=Math.max(...e));var n=_.remove(this.queue,e=>e.utterance===t.utterance);this.removePriorityListeners(n)}get initializedAndEnabled(){return this._enabled&&this._initialized}getNextUtterance(){for(var t=null,e=0;ei.utterance.alertStableDelay||i.timeInQueue>i.utterance.alertMaximumDelay){t=i;break}}return t}hasUtterance(t){for(var e=0;ethis.removePriorityListener(t.utterance))}removePriorityListener(t){var e=this.utteranceToPriorityListenerMap.get(t);e&&(t.priorityProperty.unlink(e),this.utteranceToPriorityListenerMap.delete(t))}setMuted(t){this._muted=t}set muted(t){this.setMuted(t)}get muted(){return this.getMuted()}getMuted(){return this._muted}setEnabled(t){this._enabled=t}set enabled(t){this.setEnabled(t)}get enabled(){return this.isEnabled()}isEnabled(){return this._enabled}stepQueue(t){if(this._enabled&&(t*=1e3,this.queue.length>0)){for(var e=0;e{this.prioritizeUtterances(t)},t.utterance.priorityProperty.link(this.announcingUtteranceWrapper.announcingUtterancePriorityListener),this.debug&&console.log("announcing: ",i),this.announcer.announce(i,e,e.announcerOptions)):this.debug&&console.log("announcer readyToAnnounce but utterance cannot announce, will not be spoken: ",i),this.queue.includes(t)&&this.removeUtterance(t.utterance)}else this.debug&&console.log("announcer not readyToAnnounce")}dispose(){this._initialized&&ve.removeListener(this.stepQueueListener),super.dispose()}static fromFactory(){var t=new lf,e=new fd(t),i=t.ariaLiveContainer;document.body?document.body.appendChild(i):document.children[0].appendChild(i);var s=0,n=t=>{var e=t-s;s=t,phet.axon.stepTimer.emit(e/1e3),window.requestAnimationFrame(n)};return window.requestAnimationFrame(n),e}}qi.register("UtteranceQueue",fd);var yd=fd,bd=new yd(pd,{featureSpecificAnnouncingControlPropertyName:"voicingCanAnnounceProperty"});bd.enabled=!1,bs.register("voicingUtteranceQueue",bd);var _d=bd;class Pd extends ls{constructor(t){super(t)}}var wd=["voicingNameResponse","voicingObjectResponse","voicingContextResponse","voicingHintResponse","voicingUtterance","voicingResponsePatternCollection","voicingIgnoreVoicingManagerProperties","voicingFocusListener"],xd=t=>{var e=tl("Voicing",wd,class e extends(id(t)){constructor(){super(...arguments),this._boundInstanceCanVoiceChangeListener=this.onInstanceCanVoiceChange.bind(this),this._voicingUtterance=null,e.prototype.initialize.call(this)}initialize(){for(var t=arguments.length,e=new Array(t),i=0;i{this._voicingFocusListener&&this._voicingFocusListener(t)}},this.addInputListener(this._speakContentOnFocusListener),this}voicingSpeakFullResponse(t){var e=T({},t);e.hasOwnProperty("nameResponse")||(e.nameResponse=this._voicingResponsePacket.nameResponse),e.hasOwnProperty("objectResponse")||(e.objectResponse=this._voicingResponsePacket.objectResponse),e.hasOwnProperty("contextResponse")||(e.contextResponse=this._voicingResponsePacket.contextResponse),e.hasOwnProperty("hintResponse")||(e.hintResponse=this._voicingResponsePacket.hintResponse),this.collectAndSpeakResponse(e)}voicingSpeakResponse(t){var e=T({nameResponse:null,objectResponse:null,contextResponse:null,hintResponse:null},t);this.collectAndSpeakResponse(e)}voicingSpeakNameResponse(t){var e=T({},t);e.hasOwnProperty("nameResponse")||(e.nameResponse=this._voicingResponsePacket.nameResponse),this.collectAndSpeakResponse(e)}voicingSpeakObjectResponse(t){var e=T({},t);e.hasOwnProperty("objectResponse")||(e.objectResponse=this._voicingResponsePacket.objectResponse),this.collectAndSpeakResponse(e)}voicingSpeakContextResponse(t){var e=T({},t);e.hasOwnProperty("contextResponse")||(e.contextResponse=this._voicingResponsePacket.contextResponse),this.collectAndSpeakResponse(e)}voicingSpeakHintResponse(t){var e=T({},t);e.hasOwnProperty("hintResponse")||(e.hintResponse=this._voicingResponsePacket.hintResponse),this.collectAndSpeakResponse(e)}collectAndSpeakResponse(t){this.speakContent(this.collectResponse(t))}collectResponse(t){var e=T({ignoreProperties:this._voicingResponsePacket.ignoreProperties,responsePatternCollection:this._voicingResponsePacket.responsePatternCollection,utterance:this.voicingUtterance},t),i=is.collectResponses(e);return e.utterance&&(e.utterance.alert=i,i=e.utterance),i}speakContent(t){var e=!Ct.PHET_IO_ENABLED||!this.isInsidePhetioArchetype();t&&e&&_d.addToBack(t)}setVoicingNameResponse(t){this._voicingResponsePacket.nameResponse=t}set voicingNameResponse(t){this.setVoicingNameResponse(t)}get voicingNameResponse(){return this.getVoicingNameResponse()}getVoicingNameResponse(){return this._voicingResponsePacket.nameResponse}setVoicingObjectResponse(t){this._voicingResponsePacket.objectResponse=t}set voicingObjectResponse(t){this.setVoicingObjectResponse(t)}get voicingObjectResponse(){return this.getVoicingObjectResponse()}getVoicingObjectResponse(){return this._voicingResponsePacket.objectResponse}setVoicingContextResponse(t){this._voicingResponsePacket.contextResponse=t}set voicingContextResponse(t){this.setVoicingContextResponse(t)}get voicingContextResponse(){return this.getVoicingContextResponse()}getVoicingContextResponse(){return this._voicingResponsePacket.contextResponse}setVoicingHintResponse(t){this._voicingResponsePacket.hintResponse=t}set voicingHintResponse(t){this.setVoicingHintResponse(t)}get voicingHintResponse(){return this.getVoicingHintResponse()}getVoicingHintResponse(){return this._voicingResponsePacket.hintResponse}setVoicingIgnoreVoicingManagerProperties(t){this._voicingResponsePacket.ignoreProperties=t}set voicingIgnoreVoicingManagerProperties(t){this.setVoicingIgnoreVoicingManagerProperties(t)}get voicingIgnoreVoicingManagerProperties(){return this.getVoicingIgnoreVoicingManagerProperties()}getVoicingIgnoreVoicingManagerProperties(){return this._voicingResponsePacket.ignoreProperties}setVoicingResponsePatternCollection(t){this._voicingResponsePacket.responsePatternCollection=t}set voicingResponsePatternCollection(t){this.setVoicingResponsePatternCollection(t)}get voicingResponsePatternCollection(){return this.getVoicingResponsePatternCollection()}getVoicingResponsePatternCollection(){return this._voicingResponsePacket.responsePatternCollection}setVoicingUtterance(t){if(this._voicingUtterance!==t){this._voicingUtterance&&this.cleanVoicingUtterance(),xd.registerUtteranceToVoicingNode(t,this),this._voicingUtterance=t}}set voicingUtterance(t){this.setVoicingUtterance(t)}get voicingUtterance(){return this.getVoicingUtterance()}getVoicingUtterance(){return function(t){if(!(t instanceof ls))throw new Error("utterance is not an Utterance")}(this._voicingUtterance),this._voicingUtterance}getVoicingCanSpeakProperty(){return this._voicingCanSpeakProperty}get voicingCanSpeakProperty(){return this.getVoicingCanSpeakProperty()}setVoicingFocusListener(t){this._voicingFocusListener=t}set voicingFocusListener(t){this.setVoicingFocusListener(t)}get voicingFocusListener(){return this.getVoicingFocusListener()}getVoicingFocusListener(){return this._voicingFocusListener}defaultFocusListener(){this.voicingSpeakFullResponse({contextResponse:null})}get isVoicing(){return!0}dispose(){this.removeInputListener(this._speakContentOnFocusListener),this.changedInstanceEmitter.removeListener(this._boundInstancesChangedListener),this._voicingUtterance&&(this.cleanVoicingUtterance(),this._voicingUtterance=null),super.dispose()}clean(){this.removeInputListener(this._speakContentOnFocusListener),this.changedInstanceEmitter.removeListener(this._boundInstancesChangedListener),this._voicingUtterance&&(this.cleanVoicingUtterance(),this._voicingUtterance=null),super.clean&&super.clean()}onInstanceCanVoiceChange(t){t?this._voicingCanSpeakCount++:this._voicingCanSpeakCount--,this._voicingCanSpeakProperty.value=this._voicingCanSpeakCount>0}handleInstancesChanged(t,e){t.visible&&t.voicingVisible&&(this._voicingCanSpeakCount=e?this._voicingCanSpeakCount+1:this._voicingCanSpeakCount-1),this._voicingCanSpeakProperty.value=this._voicingCanSpeakCount>0}addOrRemoveInstanceListeners(t,e){e?t.canVoiceEmitter.addListener(this._boundInstanceCanVoiceChangeListener):t.canVoiceEmitter.removeListener(this._boundInstanceCanVoiceChangeListener),this.handleInstancesChanged(t,e)}cleanVoicingUtterance(){this._voicingUtterance instanceof Pd?this._voicingUtterance.dispose():xd.unregisterUtteranceToVoicingNode(this._voicingUtterance,this)}});return e.prototype._mutatorKeys=wd.concat(e.prototype._mutatorKeys),e};xd.VOICING_OPTION_KEYS=wd,xd.alertUtterance=t=>{_d.addToBack(t)},xd.registerUtteranceToVoicingNode=(t,e)=>{var i=t.voicingCanAnnounceProperties;i.includes(e.voicingCanSpeakProperty)||(t.voicingCanAnnounceProperties=i.concat([e.voicingCanSpeakProperty]))},xd.unregisterUtteranceToVoicingNode=(t,e)=>{var i=t.voicingCanAnnounceProperties,s=i.indexOf(e.voicingCanSpeakProperty);t.voicingCanAnnounceProperties=i.splice(s,1)},xd.registerUtteranceToNode=(t,e)=>{var i=t.voicingCanAnnounceProperties;i.includes(e.visibleProperty)||(t.voicingCanAnnounceProperties=t.voicingCanAnnounceProperties.concat([e.visibleProperty])),i.includes(e.voicingVisibleProperty)||(t.voicingCanAnnounceProperties=t.voicingCanAnnounceProperties.concat([e.voicingVisibleProperty]))},xd.unregisterUtteranceToNode=(t,e)=>{var i=t.voicingCanAnnounceProperties,s=i.indexOf(e.visibleProperty),n=i.splice(s,1).indexOf(e.voicingVisibleProperty),r=i.splice(n,1);t.voicingCanAnnounceProperties=r};bs.register("Voicing",xd);var Td=xd;class Sd extends ls{constructor(t,e){super(e),this.readingBlockFocus=t}}bs.register("ReadingBlockUtterance",Sd);var Ad=Sd;class Ed{constructor(t,e){_defineProperty(this,"node",null),_defineProperty(this,"visibilityTracker",null);var i=w()({onRemoveFocus:_.noop},e);this.focusProperty=t,this.onRemoveFocus=i.onRemoveFocus,this.boundVisibilityListener=this.handleTrailVisibilityChange.bind(this),this.boundInstancesChangedListener=this.handleInstancesChange.bind(this),this.boundFocusListener=this.handleFocusChange.bind(this),this.focusProperty.link(this.boundFocusListener)}handleFocusChange(t){this.removeDisplayedListeners(),t&&this.addDisplayedListeners(t)}handleTrailVisibilityChange(){this.visibilityTracker&&!this.visibilityTracker.trailVisibleProperty.value&&(this.focusProperty.value=null,this.onRemoveFocus())}handleInstancesChange(t){t.node&&0===t.node.instances.length&&(this.focusProperty.value=null,this.onRemoveFocus())}addDisplayedListeners(t){this.visibilityTracker=new Vl(t.trail),this.visibilityTracker.addListener(this.boundVisibilityListener),this.node=t.trail.lastNode(),this.node.changedInstanceEmitter.addListener(this.boundInstancesChangedListener)}removeDisplayedListeners(){this.visibilityTracker&&(this.visibilityTracker.removeListener(this.boundVisibilityListener),this.visibilityTracker.dispose(),this.visibilityTracker=null),this.node&&(this.node.changedInstanceEmitter.removeListener(this.boundInstancesChangedListener),this.node=null)}dispose(){this.removeDisplayedListeners(),this.focusProperty.unlink(this.boundFocusListener),this.node=null,this.visibilityTracker=null,this.focusProperty=null}}bs.register("FocusDisplayedController",Ed);var Cd=Ed;class Dd{constructor(){this.pointerFocusProperty=new me(null),this.readingBlockFocusProperty=new me(null),this.lockedPointerFocusProperty=new me(null),this.pdomFocusHighlightsVisibleProperty=new pe(!0),this.interactiveHighlightsVisibleProperty=new pe(!1),this.readingBlockHighlightsVisibleProperty=new pe(!1),this.voicingFullyEnabledListener=t=>{this.readingBlockHighlightsVisibleProperty.value=t},pd.voicingFullyEnabledProperty.link(this.voicingFullyEnabledListener),this.pointerHighlightsVisibleProperty=new Ue([this.interactiveHighlightsVisibleProperty,this.readingBlockHighlightsVisibleProperty],(t,e)=>t||e),this.readingBlockFocusController=new Cd(this.readingBlockFocusProperty),this.startSpeakingListener=(t,e)=>{this.readingBlockFocusProperty.value=e instanceof Ad?e.readingBlockFocus:null},pd.startSpeakingEmitter.addListener(this.startSpeakingListener),this.endSpeakingListener=(t,e)=>{e instanceof Ad&&this.readingBlockFocusProperty.value&&e.readingBlockFocus.trail.equals(this.readingBlockFocusProperty.value.trail)&&(this.readingBlockFocusProperty.value=null)},pd.endSpeakingEmitter.addListener(this.endSpeakingListener),this.pointerFocusDisplayedController=new Cd(this.pointerFocusProperty,{onRemoveFocus:()=>{this.lockedPointerFocusProperty.value=null}})}dispose(){this.readingBlockFocusController.dispose(),this.pointerFocusDisplayedController.dispose(),this.pointerHighlightsVisibleProperty.dispose(),pd.startSpeakingEmitter.removeListener(this.startSpeakingListener),pd.endSpeakingEmitter.removeListener(this.endSpeakingListener),pd.voicingFullyEnabledProperty.unlink(this.voicingFullyEnabledListener)}static set pdomFocus(t){var e;Dd.pdomFocusProperty.value!==t&&(Dd.pdomFocusProperty.value&&(e=Dd.pdomFocusedNode),Dd.pdomFocusProperty.value=t,e&&!t&&e.blur())}static get pdomFocus(){return Dd.pdomFocusProperty.value}static getPDOMFocusedNode(){var t=null,e=Dd.pdomFocusProperty.get();return e&&(t=e.trail.lastNode()),t}static get pdomFocusedNode(){return this.getPDOMFocusedNode()}}_defineProperty(Dd,"pdomFocusProperty",new me(null,{tandem:Ct.GENERAL_MODEL.createTandem("pdomFocusProperty"),phetioDocumentation:"Stores the current focus in the Parallel DOM, null if nothing has focus. This is not updated based on mouse or touch input, only keyboard and other alternative inputs. Note that this only applies to simulations that support alternative input.",phetioValueType:Kt(Bn.FocusIO),phetioState:!1,phetioFeatured:!0,phetioReadOnly:!0})),bs.register("FocusManager",Dd);var Id=new Us("rgba(212,19,106,0.5)"),Ld=new Us("rgba(250,40,135,0.9)"),kd=new Us("rgba(233,113,166,1.0)"),Md=new Us("rgba(233,113,166,1.0)"),Od=new Us("rgba(159,15,80,1.0)"),Rd=new Us("rgba(159,15,80,1.0)");class Nd extends sl{constructor(t,e){var i=w()({outerStroke:Id,innerStroke:Ld,outerLineWidth:null,innerLineWidth:null,transformSourceNode:null},e);super(t),_defineProperty(this,"highlightChangedEmitter",new xe),this._innerHighlightColor=i.innerStroke,this._outerHighlightColor=i.outerStroke;var s=_.pick(i,Object.keys(sl.DEFAULT_PATH_OPTIONS));this.innerLineWidth=i.innerLineWidth,this.outerLineWidth=i.outerLineWidth,this.transformSourceNode=i.transformSourceNode,i.stroke=i.outerStroke,this.mutate(i);var n=T({},s,{stroke:i.innerStroke});this.innerHighlightPath=new sl(t,n),this.addChild(this.innerHighlightPath),this.updateLineWidth()}mutateWithInnerHighlight(t){super.mutate(t),this.innerHighlightPath&&this.innerHighlightPath.mutate(t),this.highlightChangedEmitter.emit()}makeDashed(){this.mutateWithInnerHighlight({lineDash:[7,7]})}setShape(t){return super.setShape(t),this.innerHighlightPath&&this.innerHighlightPath.setShape(t),this.highlightChangedEmitter&&this.highlightChangedEmitter.emit(),this}updateLineWidth(t){t=t||this,this.lineWidth=this.getOuterLineWidth(t),this.innerHighlightPath.lineWidth=this.getInnerLineWidth(t),this.highlightChangedEmitter.emit()}getOuterLineWidth(t){return this.outerLineWidth?this.outerLineWidth:Nd.getOuterLineWidthFromNode(t)}getInnerLineWidth(t){return this.innerLineWidth?this.innerLineWidth:Nd.getInnerLineWidthFromNode(t)}setInnerHighlightColor(t){this._innerHighlightColor=t,this.innerHighlightPath.setStroke(t),this.highlightChangedEmitter.emit()}set innerHighlightColor(t){this.setInnerHighlightColor(t)}get innerHighlightColor(){return this.getInnerHighlightColor()}getInnerHighlightColor(){return this._innerHighlightColor}setOuterHighlightColor(t){this._outerHighlightColor=t,this.setStroke(t),this.highlightChangedEmitter.emit()}set outerHighlightColor(t){this.setOuterHighlightColor(t)}get outerHighlightColor(){return this.getOuterHighlightColor()}getOuterHighlightColor(){return this._outerHighlightColor}getUniqueHighlightTrail(t){var e=this.transformSourceNode,i=null;if(e.instances.length<=1)i=e.getUniqueTrail();else{var s=e.getTrails().filter(e=>e.isExtensionOf(t,!0));i=s[0]}return i}static getInnerLineWidthFromNode(t){return 2.5/Nd.getWidthMagnitudeFromTransform(t)}static getOuterLineWidthFromNode(t){return 4/Nd.getWidthMagnitudeFromTransform(t)}static getWidthMagnitudeFromTransform(t){return t.transform.transformDelta2(Is.X_UNIT).magnitude}static getDilationCoefficient(t){return.75*Nd.getOuterLineWidthFromNode(t)}static getGroupDilationCoefficient(t){return 1.9*Nd.getOuterLineWidthFromNode(t)}}_defineProperty(Nd,"OUTER_FOCUS_COLOR",Id),_defineProperty(Nd,"INNER_FOCUS_COLOR",Ld),_defineProperty(Nd,"INNER_LIGHT_GROUP_FOCUS_COLOR",kd),_defineProperty(Nd,"OUTER_LIGHT_GROUP_FOCUS_COLOR",Md),_defineProperty(Nd,"INNER_DARK_GROUP_FOCUS_COLOR",Od),_defineProperty(Nd,"OUTER_DARK_GROUP_FOCUS_COLOR",Rd),_defineProperty(Nd,"GROUP_OUTER_LINE_WIDTH",2),_defineProperty(Nd,"GROUP_INNER_LINE_WIDTH",2),bs.register("FocusHighlightPath",Nd);var Bd=Nd;class Fd extends Bd{constructor(t,e){var i=w()({useLocalBounds:!0,dilationCoefficient:null,useGroupDilation:!1},e);i.transformSourceNode=t,super(null,i),_defineProperty(this,"observedBoundsProperty",null),_defineProperty(this,"boundsListener",null),this.useLocalBounds=i.useLocalBounds,this.useGroupDilation=i.useGroupDilation,this.dilationCoefficient=i.dilationCoefficient,t&&this.setShapeFromNode(t)}setShapeFromNode(t){this.observedBoundsProperty&&this.observedBoundsProperty.unlink(this.boundsListener),this.observedBoundsProperty=this.useLocalBounds?t.localBoundsProperty:t.boundsProperty,this.boundsListener=e=>{if(e.isFinite()){var i=this.dilationCoefficient;null===this.dilationCoefficient&&(i=this.useGroupDilation?Bd.getGroupDilationCoefficient(t):Bd.getDilationCoefficient(t));var s=e.dilated(i);this.updateLineWidthFromNode(t),this.setShape(aa.bounds(s))}},this.observedBoundsProperty.link(this.boundsListener)}updateLineWidthFromNode(t){this.lineWidth=this.getOuterLineWidth(t),this.innerHighlightPath.lineWidth=this.getInnerLineWidth(t)}}bs.register("FocusHighlightFromNode",Fd);var Vd=Fd;class Hd extends Vd{constructor(t,e){super(t,w()({outerStroke:"grey",innerStroke:"black"},e))}}bs.register("ReadingBlockHighlight",Hd);var Yd=Hd,zd=["readingBlockTagName","readingBlockNameResponse","readingBlockHintResponse","readingBlockResponsePatternCollection","readingBlockActiveHighlight"];class Wd extends Ad{constructor(t,e){super(t,e)}}var Ud=new Qi({nameHint:"{{NAME}}. {{HINT}}"}),Gd=t=>{var e=tl("ReadingBlock",zd,class extends(Td(t)){constructor(){super(...arguments),this._readingBlockTagName="button",this._readingBlockDisabledTagName="p",this._readingBlockActiveHighlight=null,this.readingBlockActiveHighlightChangedEmitter=new c,this.readingBlockResponsePatternCollection=Ud,this._localBoundsChangedListener=this._onLocalBoundsChanged.bind(this),this.localBoundsProperty.link(this._localBoundsChangedListener),this._readingBlockInputListener={focus:t=>this._speakReadingBlockContentListener(t),up:t=>this._speakReadingBlockContentListener(t),click:t=>this._speakReadingBlockContentListener(t)},this._readingBlockFocusableChangeListener=this._onReadingBlockFocusableChanged.bind(this),pd.speechAllowedAndFullyEnabledProperty.link(this._readingBlockFocusableChangeListener),this.focusHighlight=new Yd(this),this.voicingUtterance=new Wd(null)}get isReadingBlock(){return!0}setReadingBlockTagName(t){this._readingBlockTagName=t,this._onReadingBlockFocusableChanged(pd.speechAllowedAndFullyEnabledProperty.value)}set readingBlockTagName(t){this.setReadingBlockTagName(t)}get readingBlockTagName(){return this.getReadingBlockTagName()}getReadingBlockTagName(){return this._readingBlockTagName}setReadingBlockNameResponse(t){this._voicingResponsePacket.nameResponse=t}set readingBlockNameResponse(t){this.setReadingBlockNameResponse(t)}get readingBlockNameResponse(){return this.getReadingBlockNameResponse()}getReadingBlockNameResponse(){return this._voicingResponsePacket.nameResponse}setReadingBlockHintResponse(t){this._voicingResponsePacket.hintResponse=t}set readingBlockHintResponse(t){this.setReadingBlockHintResponse(t)}get readingBlockHintResponse(){return this.getReadingBlockHintResponse()}getReadingBlockHintResponse(){return this._voicingResponsePacket.hintResponse}setReadingBlockResponsePatternCollection(t){this._voicingResponsePacket.responsePatternCollection=t}set readingBlockResponsePatternCollection(t){this.setReadingBlockResponsePatternCollection(t)}get readingBlockResponsePatternCollection(){return this.getReadingBlockResponsePatternCollection()}getReadingBlockResponsePatternCollection(){return this._voicingResponsePacket.responsePatternCollection}setVoicingUtterance(t){super.setVoicingUtterance(t)}set voicingUtterance(t){super.voicingUtterance=t}get voicingUtterance(){return this.getVoicingUtterance()}getVoicingUtterance(){var t=super.getVoicingUtterance();return t}setVoicingNameResponse(){}getVoicingNameResponse(){}setVoicingObjectResponse(){}getVoicingObjectResponse(){}setVoicingContextResponse(){}getVoicingContextResponse(){}setVoicingHintResponse(){}getVoicingHintResponse(){}setVoicingResponsePatternCollection(){}getVoicingResponsePatternCollection(){}setReadingBlockActiveHighlight(t){this._readingBlockActiveHighlight!==t&&(this._readingBlockActiveHighlight=t,this.readingBlockActiveHighlightChangedEmitter.emit())}set readingBlockActiveHighlight(t){this.setReadingBlockActiveHighlight(t)}get readingBlockActiveHighlight(){return this._readingBlockActiveHighlight}getReadingBlockActiveHighlight(){return this._readingBlockActiveHighlight}isReadingBlockActivated(){for(var t=!1,e=Object.keys(this.displays),i=0;i_.includes(window.navigator.platform,"Mac"),getPlatformZoomMetaKey:()=>jd.isPlatformMac()?"metaKey":"ctrlKey",isZoomCommand:(t,e)=>{var i=e?qn.KEY_EQUALS:qn.KEY_MINUS;return t[jd.getPlatformZoomMetaKey()]&&qn.isKeyEvent(t,i)},isZoomResetCommand:t=>t[jd.getPlatformZoomMetaKey()]&&qn.isKeyEvent(t,qn.KEY_0)};bs.register("KeyboardZoomUtils",jd);var qd=jd;class Kd{constructor(t){t=b({seed:null},t),this.seed=null,this.seedrandom=null,this.setSeed(t.seed),this.numberOfCalls=0,Kd.allRandomInstances.add(this)}dispose(){Kd.allRandomInstances.delete(this)}getSeed(){return this.seed}nextBoolean(){return this.nextDouble()>=.5}nextInt(t){var e=this.nextDouble()*t;return Math.floor(e)}nextIntBetween(t,e){var i=e-t;return this.nextInt(i+1)+t}sample(t){return t[this.nextIntBetween(0,t.length-1)]}shuffle(t){var e=-1,i=new Array(t.length);return _.forEach(t,t=>{var s=this.nextIntBetween(0,++e);i[e]=i[s],i[s]=t}),i}nextDouble(){return this.numberOfCalls++,this.seedrandom()}nextDoubleBetween(t,e){var i=t+this.nextDouble()*(e-t);return i}nextGaussian(){return Vs.boxMullerTransform(0,1,this)}nextDoubleInRange(t){return t.minMath.random()}sampleProbabilities(t){for(var e=_.sum(t)*this.nextDouble(),i=0,s=0;s=e)return s;return t.length-1}}Kd.allRandomInstances=new Set,Kd.isNormalized=t=>{},De.register("Random",Kd);var Zd=Kd,Qd={INPUT:[...qn.ARROW_KEYS,qn.KEY_PAGE_UP,qn.KEY_PAGE_DOWN,qn.KEY_HOME,qn.KEY_END,qn.KEY_ENTER,qn.KEY_SPACE],DIV:[...qn.ARROW_KEYS,...qn.WASD_KEYS],P:[qn.KEY_ESCAPE],BUTTON:[qn.KEY_ENTER,qn.KEY_SPACE]},Jd=qn.ALL_KEYS;class $d{constructor(t,e){this.display=t,this.random=new Zd({seed:e}),this.numberOfComponentsTested=10,this.keyupListeners=[],this.currentElement=null}chooseNextElement(){if(null===this.currentElement)this.currentElement=document.activeElement;else if(this.random.nextDouble()<.1){this.clearListeners();var t=go.getRandomFocusable(this.random);t.focus(),this.currentElement=t}}clearListeners(){this.keyupListeners.forEach(t=>{ve.clearTimeout(t.timeout),t()})}triggerClickEvent(t){t instanceof HTMLElement&&t.click()}triggerKeyDownUpEvents(t,e){this.triggerDOMEvent("keydown",t,e);var i=this.random.nextInt(100),s=()=>{this.triggerDOMEvent("keyup",t,e),this.keyupListeners.includes(s)&&this.keyupListeners.splice(this.keyupListeners.indexOf(s),1)};s.timeout=ve.setTimeout(s,100===i?2e3:i),this.keyupListeners.push(s)}triggerRandomKeyDownUpEvents(t){var e=Jd[Math.floor(this.random.nextDouble()*(Jd.length-1))];this.triggerKeyDownUpEvents(t,e)}fuzzBoardEvents(t){if(this.display&&this.display._input&&this.display._input.pdomPointer){var e=this.display._input.pdomPointer;e&&!e.blockTrustedEvents&&(e.blockTrustedEvents=!0)}for(var i=0;i{this._primarySibling.addEventListener(t,t=>{t.stopPropagation()})})),this}update(t){var e=this.node.getBaseOptions(),i=[];null!==this.node.accessibleName&&(e=this.node.accessibleNameBehavior(this.node,e,this.node.accessibleName,i)),null!==this.node.pdomHeading&&(e=this.node.pdomHeadingBehavior(this.node,e,this.node.pdomHeading,i)),null!==this.node.helpText&&(e=this.node.helpTextBehavior(this.node,e,this.node.helpText,i)),this._primarySibling=mu(e.tagName,this.node.focusable,{namespace:e.pdomNamespace}),e.containerTagName&&(this._containerParent=mu(e.containerTagName,!1)),e.labelTagName&&(this._labelSibling=mu(e.labelTagName,!1,{excludeFromInput:this.node.excludeLabelSiblingFromInput})),e.descriptionTagName&&(this._descriptionSibling=mu(e.descriptionTagName,!1)),t&&this.updateIndicesStringAndElementIds(),this.orderElements(e),this.mutationObserver.disconnect(),this.mutationObserver.observe(this._primarySibling,ru),e.labelContent&&null!==e.labelTagName&&this.setLabelSiblingContent(e.labelContent),e.innerContent&&null!==e.tagName&&this.setPrimarySiblingContent(e.innerContent),e.descriptionContent&&null!==e.descriptionTagName&&this.setDescriptionSiblingContent(e.descriptionContent),e.tagName.toUpperCase()===nu&&e.inputType&&this.setAttributeToElement("type",e.inputType),this.setFocusable(this.node.focusable),this.setPositionInPDOM(this.node.positionInPDOM),this.onAriaLabelledbyAssociationChange(),this.onAriaDescribedbyAssociationChange(),this.onActiveDescendantAssociationChange(),this.onAttributeChange(e),this.onClassChange(),this.onInputValueChange(),this.node.updateOtherNodesAriaLabelledby(),this.node.updateOtherNodesAriaDescribedby(),this.node.updateOtherNodesActiveDescendant(),i.forEach(t=>{t()})}orderElements(t){this._containerParent?(this._containerParent.insertBefore(this._primarySibling,this._containerParent.children[0]||null),this.topLevelElements=[this._containerParent]):this.topLevelElements=[this._labelSibling,this._descriptionSibling,this._primarySibling].filter(_.identity),this._labelSibling&&this.arrangeContentElement(this._labelSibling,t.appendLabel),this._descriptionSibling&&this.arrangeContentElement(this._descriptionSibling,t.appendDescription)}getPrimarySibling(){return this._primarySibling}get primarySibling(){return this.getPrimarySibling()}getLabelSibling(){return this._labelSibling}get labelSibling(){return this.getLabelSibling()}getDescriptionSibling(){return this._descriptionSibling}get descriptionSibling(){return this.getDescriptionSibling()}getContainerParent(){return this._containerParent}get containerParent(){return this.getContainerParent()}onAriaLabelledbyAssociationChange(){this.removeAttributeFromAllElements("aria-labelledby");for(var t=0;t0){var s=i[0];s===this.pdomInstance&&(s.peer=this);var n=s.peer.getElementByName(e.otherElementName),r=this.getElementByName(e.thisElementName);if(r&&n){var a=r.getAttribute(t)||"",o=[a.trim(),n.id].join(" ").trim();this.setAttributeToElement(t,o,{elementName:e.thisElementName})}}}arrangeContentElement(t,e){if(this.topLevelElements[0]===this._containerParent)e?this._containerParent.appendChild(t):this._containerParent.insertBefore(t,this._primarySibling);else{tt(this.topLevelElements,t);var i=this.topLevelElements.indexOf(this._primarySibling),s=e?this.topLevelElements.length:i;this.topLevelElements.splice(s,0,t)}}isVisible(){return null===this.visible||this.visible}setVisible(t){if(this.visible!==t){this.visible=t;for(var e=0;e0&&r>0&&(hu.setMinMax(0,0,n,r),hu.transform(pu(n,r,ou)),vu(this._primarySibling,hu)),this.labelSibling&&(n=(s=gu(this._labelSibling)).width,(r=s.height)>0&&n>0&&(hu.setMinMax(0,0,n,r),hu.transform(pu(n,r,ou)),vu(this._labelSibling,hu)))}}}else hu.set(cu.OFFSCREEN_SIBLING_BOUNDS),vu(this._primarySibling,hu),this._labelSibling&&vu(this._labelSibling,hu);this.positionDirty=!1}updateSubtreePositioning(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.childPositionDirty=!1;var e=this.positionInPDOM||t;this.positionDirty&&this.positionElements(e);for(var i=0;i0;Array.prototype.push.apply(this.children,t);for(var i=0;i=0;e--){var i=this.children[e];i.trail.isExtensionOf(t,!0)&&(this.children.splice(e,1),i.dispose())}}checkAccessibleDisplayVisibility(t){var e=_.includes(this.relativeNodes[t]._pdomDisplaysInfo.pdomDisplays,this.display);if(e!==this.relativeVisibilities[t]){this.relativeVisibilities[t]=e;var i=0===this.invisibleCount;this.invisibleCount+=e?-1:1,0===this.invisibleCount!==i&&this.updateVisibility()}}updateVisibility(){this.peer.setVisible(this.invisibleCount<=0),!this.peer.isVisible()&&Dd.pdomFocusedNode&&Dd.pdomFocusedNode.pdomInstances[0].trail.containsNode(this.node)&&(Dd.pdomFocus=null)}isGloballyVisible(){return!!this.peer.isVisible()&&(!this.parent||this.parent.isGloballyVisible())}getChildOrdering(t){var e,i=t.lastNode(),s=i.getEffectiveChildren(),n=[];if(i.hasPDOMContent&&i!==this.node){var r=i.pdomInstances;t:for(e=0;e=0;s--)for(var n=this.children[s].peer,r=n.topLevelElements.length-1;r>=0;r--){var a=n.topLevelElements[r];e.childNodes[i]!==a&&e.insertBefore(a,e.childNodes[i+1]),i--}Pu===_u.INDICES&&this.updateDescendantPeerIds(this.children)}updateTransformTracker(t){this.transformTracker&&this.transformTracker.dispose();var e=null;e=t?t.getUniqueTrail():xu.guessVisualTrail(this.trail,this.display.rootNode),this.transformTracker=new Bl(e)}getPDOMInstanceUniqueId(){if(Pu===_u.INDICES){for(var t=[],e=this;e.parent;){var i=e.parent.children.indexOf(e);if(-1===i)return"STILL_BEING_CREATED"+bu.nextDouble();t.unshift(i),e=e.parent}return t.join(go.PDOM_UNIQUE_ID_SEPARATOR)}return this.trail.getUniqueId()}updateDescendantPeerIds(t){for(var e=[].concat(t);e.length>0;){var i=e.shift();i.peer.updateIndicesStringAndElementIds(),e.push(...i.children)}}static uniqueIdToTrail(t,e){return Pu===_u.INDICES?t.getTrailFromPDOMIndicesString(e):Nh.fromUniqueId(t.rootNode,e)}dispose(){if(!this.isRootInstance){go.removeElements(this.parent.peer.primarySibling,this.peer.topLevelElements);for(var t=0;tnull===t?"null":"[".concat(t.map(t=>null===t?"null":t._id).join(","),"]")};bs.register("PDOMTree",Au);var Eu=Au;class Cu{constructor(t){this.indices=t}size(){return this.indices.length}apply(t){if("number"==typeof t)return this.indices[t];if(t.length!==this.size())throw new Error("Permutation length ".concat(this.size()," not equal to list length ").concat(t.length));for(var e=new Array(t.length),i=0;i{for(var s=this.indices,n=s.slice(0),r=0;r{e.push(new Cu(t.slice()))}),e}static forEachPermutation(t,e){!function t(e,i,s){if(0===e.length)s(i);else for(var n=0;n{e.push(t.slice())}),e}}De.register("Permutation",Cu);var Du=Cu;class Iu{constructor(t,e,i){i=i||null,this.nodeCount=t,this.logToConsole=e,this.nodes=_.range(0,t).map(()=>new uh),this.display=new $v(this.nodes[0]),this.random=new Zd({seed:i}),this.actionsTaken=[]}step(){var t=this.random.sample(this.enumerateActions());if(this.logToConsole&&console.log(t.text),this.actionsTaken.push(t),t.execute(),this.display._rootPDOMInstance.auditRoot(),Eu.auditPDOMDisplays(this.display.rootNode),this.logToConsole)for(var e=0;e{t.push({text:"#".concat(e.id,".visible = ").concat(!e.visible),execute:()=>{e.visible=!e.visible}}),t.push({text:"#".concat(e.id,".pdomVisible = ").concat(!e.pdomVisible),execute:()=>{e.pdomVisible=!e.pdomVisible}}),["span","div",null].forEach(i=>{e.tagName!==i&&t.push({text:"#".concat(e.id,".tagName = ").concat(i),execute:()=>{e.tagName=i}})}),this.powerSet(si(this.nodes,[e]).concat([null])).forEach(i=>{Du.forEachPermutation(i,i=>{this.isPDOMOrderChangeLegal(e,i)&&t.push({text:"#".concat(e.id,".pdomOrder = ").concat(Eu.debugOrder(i)),execute:()=>{e.pdomOrder=i}})})}),this.nodes.forEach(i=>{this.isAddChildLegal(e,i)&&_.range(0,e.children.length+1).forEach(s=>{t.push({text:"#".concat(e.id,".insertChild(").concat(s,",#").concat(i.id,")"),execute:()=>{e.insertChild(s,i)}})}),e.hasChild(i)&&t.push({text:"#".concat(e.id,".removeChild(#").concat(i.id,")"),execute:()=>{e.removeChild(i)}})})}),t}isAddChildLegal(t,e){return!t.hasChild(e)&&this.isAcyclic(t,e)}powerSet(t){if(0===t.length)return[[]];var e=this.powerSet(t.slice(1));return e.concat(e.map(e=>[t[0]].concat(e)))}isPDOMOrderChangeLegal(t,e){if(null===e&&(e=[]),e=e.filter(t=>null!==t),_.includes(e,t)||_.uniq(e).lengthi===t?i.hasChild(s)||_.includes(e,s):i.hasChild(s)||!!i.pdomOrder&&_.includes(i.pdomOrder,s),n=t.children.concat(e);return _.every(n,e=>this.isAcyclic(t,e,s))}isAcyclic(t,e,i){var s=this;if(t===e)return!1;for(var n=e.children.concat(e.pdomOrder).filter(t=>null!==t),r=function(){var e=n.pop();if(e===t)return{v:!1};i?s.nodes.forEach(t=>{i(e,t)&&n.push(t)}):(Array.prototype.push.apply(n,e.children),e.pdomOrder&&Array.prototype.push.apply(n,e.pdomOrder.filter(t=>null!==t)))};n.length;){var a=r();if("object"==typeof a)return a.v}return!0}dispose(){this.display.dispose()}}bs.register("PDOMFuzzer",Iu);class Lu extends it{}_defineProperty(Lu,"DRAG",new Lu),_defineProperty(Lu,"KEYBOARD_DRAG",new Lu),_defineProperty(Lu,"enumeration",new at(Lu,{phetioDocumentation:"entries when signifying Intent of the pointer"}));class ku{constructor(t,e,i){this.point=t,this.type=i,this.trail=null,this.inputEnabledTrail=null,this.isDownProperty=new pe(e),this.attachedProperty=new pe(!1),this._listeners=[],this._attachedListener=null,this._cursor=null,this.lastDOMEvent=null,this._intents=[],this._pointerCaptured=!1,this._listenerForDragReserve=null,this._listenerForKeyboardDragReserve=null}setCursor(t){return this._cursor=t,this}set cursor(t){this.setCursor(t)}get cursor(){return this.getCursor()}getCursor(){return this._cursor}getListeners(){return this._listeners.slice()}get listeners(){return this.getListeners()}addInputListener(t,e){this._listeners.push(t),e&&this.attach(t)}removeInputListener(t){var e=_.indexOf(this._listeners,t);this.isAttached()&&t===this._attachedListener&&this.detach(t),this._listeners.splice(e,1)}getAttachedListener(){return this._attachedListener}get attachedListener(){return this.getAttachedListener()}isAttached(){return this.attachedProperty.value}isTouchLike(){return!1}set isDown(t){this.isDownProperty.value=t}get isDown(){return this.isDownProperty.value}interruptAttached(){this.isAttached()&&this._attachedListener.interrupt()}interruptAll(){for(var t=this._listeners.slice(),e=0;e{this.removeIntent(Lu.DRAG),this.removeInputListener(this._listenerForDragReserve),this._listenerForDragReserve=null}};this._listenerForDragReserve=t,this.addInputListener(this._listenerForDragReserve)}}reserveForKeyboardDrag(){if(!this._intents.includes(Lu.KEYBOARD_DRAG)){this.addIntent(Lu.KEYBOARD_DRAG);var t={keyup:t=>e(),blur:t=>e()},e=()=>{this.removeIntent(Lu.KEYBOARD_DRAG),this.removeInputListener(this._listenerForKeyboardDragReserve),this._listenerForKeyboardDragReserve=null};this._listenerForKeyboardDragReserve=t,this.addInputListener(this._listenerForKeyboardDragReserve)}}onGotPointerCapture(){this._pointerCaptured=!0}onLostPointerCapture(){this._pointerCaptured&&this.interruptAll(),this._pointerCaptured=!1}dispose(){this._listenerForDragReserve&&this._listeners.includes(this._listenerForDragReserve)&&this.removeInputListener(this._listenerForDragReserve),this._listenerForKeyboardDragReserve&&this._listeners.includes(this._listenerForKeyboardDragReserve)&&this.removeInputListener(this._listenerForKeyboardDragReserve)}}ku.PointerIO=new j("PointerIO",{isValidValue:t=>t instanceof ku,toStateObject:t=>({point:t.point.toStateObject(),type:t.type}),stateSchema:{point:Is.Vector2IO,type:It}}),bs.register("Pointer",ku);class Mu extends ku{constructor(t){super(t,!1,"mouse"),this.id=null,this.leftDown=!1,this.middleDown=!1,this.rightDown=!1,this.wheelDelta=new As(0,0,0),this.wheelDeltaMode=0}down(t,e){var i=e,s=this.hasPointChanged(t);switch(this.point=t,this.isDown=!0,i.button){case 0:this.leftDown=!0;break;case 1:this.middleDown=!0;break;case 2:this.rightDown=!0}return s}up(t,e){var i=e,s=this.hasPointChanged(t);switch(this.point=t,this.isDown=!1,i.button){case 0:this.leftDown=!1;break;case 1:this.middleDown=!1;break;case 2:this.rightDown=!1}return s}move(t,e){var i=this.hasPointChanged(t);return this.point=t,i}over(t,e){var i=this.hasPointChanged(t);return this.point=t,i}out(t,e){return this.hasPointChanged(t)}wheel(t){var e=t;this.wheelDelta.setXYZ(e.deltaX,e.deltaY,e.deltaZ),this.wheelDeltaMode=e.deltaMode}toString(){return"Mouse"}}bs.register("Mouse",Mu);class Ou extends ku{constructor(t,e,i){super(e,!0,"touch"),this.id=t}move(t,e){var i=this.hasPointChanged(t);return this.point=t,i}end(t,e){var i=this.hasPointChanged(t);return this.point=t,this.isDown=!1,i}cancel(t,e){var i=this.hasPointChanged(t);return this.point=t,this.isDown=!1,i}toString(){return"Touch#".concat(this.id)}isTouchLike(){return!0}}bs.register("Touch",Ou);class Ru extends ku{constructor(t,e,i){super(e,!0,"pen"),this.id=t}move(t,e){var i=this.hasPointChanged(t);return this.point=t,i}end(t,e){var i=this.hasPointChanged(t);return this.point=t,this.isDown=!1,i}cancel(t,e){var i=this.hasPointChanged(t);return this.point=t,this.isDown=!1,i}toString(){return"Pen#".concat(this.id)}isTouchLike(){return!0}}bs.register("Pen",Ru);class Nu extends ku{constructor(t){super(Is.ZERO,!1,"pdom"),this.display=t,this.initializeListeners(),this.blockTrustedEvents=!1,this.keydownTargetNode=null}initializeListeners(){this.addInputListener({focus:t=>{var e=this.trail.lastNode();if(e.focusable){var i=Tu.guessVisualTrail(this.trail,this.display.rootNode);Dd.pdomFocus=new Bn(this.display,i),this.point=i.parentToGlobalPoint(e.center),isNaN(this.point.x)&&this.point.setXY(0,0)}else t.target.blur(),t.abort()},blur:t=>{var e=this.display._input.getRelatedTargetTrail(t.domEvent);this.trail=null,e&&e.lastNode().focusable?Dd.pdomFocus=new Bn(this.display,Tu.guessVisualTrail(e,this.display.rootNode)):Dd.pdomFocus=null,this.keydownTargetNode=null},keydown:t=>{this.blockTrustedEvents&&t.domEvent.isTrusted||(this.keydownTargetNode=t.target)},keyup:t=>{this.blockTrustedEvents&&t.domEvent.isTrusted||this.keydownTargetNode!==t.target&&t.abort()}})}updateTrail(t){return this.trail&&this.trail.equals(t)||(this.trail=t),this.trail}}bs.register("PDOMPointer",Nu);class Bu{constructor(t,e,i,s){this.handled=!1,this.aborted=!1,this.trail=t,this.type=e,this.pointer=i,this.domEvent=s,this.currentTarget=null,this.target=t.lastNode(),this.isPrimary=!(i instanceof Mu&&s&&0!==s.button),s&&(i.lastDOMEvent=s)}handle(){this.handled=!0}abort(){this.aborted=!0}isFromPDOM(){return this.pointer instanceof Nu}canStartPress(){return!(this.pointer.isAttached()||this.pointer instanceof Mu&&0!==this.domEvent.button)}}Bu.SceneryEventIO=new j("SceneryEventIO",{valueType:Bu,documentation:'An event, with a "point" field',toStateObject:t=>({type:t.type,domEventType:Kt($n).toStateObject(t.domEvent),point:t.pointer&&t.pointer.point?Is.Vector2IO.toStateObject(t.pointer.point):null}),stateSchema:{type:It,domEventType:Kt($n),point:Kt(Is.Vector2IO)}}),bs.register("SceneryEvent",Bu);var Fu=["altKey","button","charCode","clientX","clientY","code","ctrlKey","deltaMode","deltaX","deltaY","deltaZ","key","keyCode","metaKey","pageX","pageY","pointerId","pointerType","scale","shiftKey","target","type","relatedTarget","which"],Vu=["deltaMode","deltaX","deltaY","deltaZ","altKey","button","charCode","clientX","clientY","code","ctrlKey","key","keyCode","metaKey","pageX","pageY","pointerId","pointerType","shiftKey","type","relatedTarget","which"],Hu=["target","relatedTarget"],Yu=["focus","blur","focusin","focusout"];class zu extends Vt{constructor(t,e,i,s,n,r){var a=w()({phetioType:zu.InputIO,tandem:Ct.OPTIONAL,phetioDocumentation:"Central point for user input events, such as mouse, touch"},r);super(a),this.display=t,this.rootNode=t.rootNode,this.attachToWindow=e,this.batchDOMEvents=i,this.assumeFullWindow=s,this.passiveEvents=n,this.batchedEvents=[],this.pdomPointer=null,this.mouse=null,this.pointers=[],this.pointerAddedEmitter=new c,this.currentlyFiringEvents=!1,this.upTimeStamp=0,this.validatePointersAction=new Kl(()=>{for(var t=this.pointers.length;t--;){var e=this.pointers[t];e.point&&e!==this.pdomPointer&&this.branchChangeEvents(e,e.lastDOMEvent,!1)}},{phetioPlayback:!0,tandem:a.tandem.createTandem("validatePointersAction"),phetioHighFrequency:!0}),this.mouseUpAction=new Kl((t,e)=>{var i=this.ensureMouse(t),s=i.up(t,e);i.id=null,this.upEvent(i,e,s)},{phetioPlayback:!0,tandem:a.tandem.createTandem("mouseUpAction"),parameters:[{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a mouse button is released."}),this.mouseDownAction=new Kl((t,e,i)=>{var s=this.ensureMouse(e);s.id=t;var n=s.down(e,i);this.downEvent(s,i,n)},{phetioPlayback:!0,tandem:a.tandem.createTandem("mouseDownAction"),parameters:[{name:"id",phetioType:Kt(Ee)},{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a mouse button is pressed."}),this.mouseMoveAction=new Kl((t,e)=>{var i=this.ensureMouse(t);i.move(t,e),this.moveEvent(i,e)},{phetioPlayback:!0,tandem:a.tandem.createTandem("mouseMoveAction"),parameters:[{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the mouse is moved.",phetioHighFrequency:!0}),this.mouseOverAction=new Kl((t,e)=>{this.ensureMouse(t).over(t,e)},{phetioPlayback:!0,tandem:a.tandem.createTandem("mouseOverAction"),parameters:[{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the mouse is moved while on the sim."}),this.mouseOutAction=new Kl((t,e)=>{this.ensureMouse(t).out(t,e)},{phetioPlayback:!0,tandem:a.tandem.createTandem("mouseOutAction"),parameters:[{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the mouse moves out of the display."}),this.wheelScrollAction=new Kl(t=>{var e=this.ensureMouse(this.pointFromEvent(t));if(e.wheel(t),e.point){var i=this.rootNode.trailUnderPointer(e)||new Nh(this.rootNode);this.dispatchEvent(i,"wheel",e,t,!0)}},{phetioPlayback:!0,tandem:a.tandem.createTandem("wheelScrollAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the mouse wheel scrolls.",phetioHighFrequency:!0}),this.touchStartAction=new Kl((t,e,i)=>{var s=new Ou(t,e,i);this.addPointer(s),this.downEvent(s,i,!1)},{phetioPlayback:!0,tandem:a.tandem.createTandem("touchStartAction"),parameters:[{name:"id",phetioType:Ee},{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a touch begins."}),this.touchEndAction=new Kl((t,e,i)=>{var s=this.findPointerById(t);if(s){var n=s.end(e,i);this.upEvent(s,i,n),this.removePointer(s)}},{phetioPlayback:!0,tandem:a.tandem.createTandem("touchEndAction"),parameters:[{name:"id",phetioType:Ee},{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a touch ends."}),this.touchMoveAction=new Kl((t,e,i)=>{var s=this.findPointerById(t);s&&(s.move(e,i),this.moveEvent(s,i))},{phetioPlayback:!0,tandem:a.tandem.createTandem("touchMoveAction"),parameters:[{name:"id",phetioType:Ee},{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a touch moves.",phetioHighFrequency:!0}),this.touchCancelAction=new Kl((t,e,i)=>{var s=this.findPointerById(t);if(s){var n=s.cancel(e,i);this.cancelEvent(s,i,n),this.removePointer(s)}},{phetioPlayback:!0,tandem:a.tandem.createTandem("touchCancelAction"),parameters:[{name:"id",phetioType:Ee},{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a touch is canceled."}),this.penStartAction=new Kl((t,e,i)=>{var s=new Ru(t,e,i);this.addPointer(s),this.downEvent(s,i,!1)},{phetioPlayback:!0,tandem:a.tandem.createTandem("penStartAction"),parameters:[{name:"id",phetioType:Ee},{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a pen touches the screen."}),this.penEndAction=new Kl((t,e,i)=>{var s=this.findPointerById(t);if(s){var n=s.end(e,i);this.upEvent(s,i,n),this.removePointer(s)}},{phetioPlayback:!0,tandem:a.tandem.createTandem("penEndAction"),parameters:[{name:"id",phetioType:Ee},{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a pen is lifted."}),this.penMoveAction=new Kl((t,e,i)=>{var s=this.findPointerById(t);s&&(s.move(e,i),this.moveEvent(s,i))},{phetioPlayback:!0,tandem:a.tandem.createTandem("penMoveAction"),parameters:[{name:"id",phetioType:Ee},{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a pen is moved.",phetioHighFrequency:!0}),this.penCancelAction=new Kl((t,e,i)=>{var s=this.findPointerById(t);if(s){var n=s.cancel(e,i);this.cancelEvent(s,i,n),this.removePointer(s)}},{phetioPlayback:!0,tandem:a.tandem.createTandem("penCancelAction"),parameters:[{name:"id",phetioType:Ee},{name:"point",phetioType:Is.Vector2IO},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a pen is canceled."}),this.gotPointerCaptureAction=new Kl((t,e)=>{var i=this.findPointerById(t);i&&i.onGotPointerCapture()},{phetioPlayback:!0,tandem:a.tandem.createTandem("gotPointerCaptureAction"),parameters:[{name:"id",phetioType:Ee},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a pointer is captured (normally at the start of an interaction)",phetioHighFrequency:!0}),this.lostPointerCaptureAction=new Kl((t,e)=>{var i=this.findPointerById(t);i&&i.onLostPointerCapture()},{phetioPlayback:!0,tandem:a.tandem.createTandem("lostPointerCaptureAction"),parameters:[{name:"id",phetioType:Ee},{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when a pointer loses its capture (normally at the end of an interaction)",phetioHighFrequency:!0}),this.display._accessible&&(this.focusinAction=new Kl(t=>{if(!this.display.blockFocusCallbacks){var e=this.updateTrailForPDOMDispatch(t);this.dispatchPDOMEvent(e,"focus",t,!1),this.dispatchPDOMEvent(e,"focusin",t,!0)}},{phetioPlayback:!0,tandem:a.tandem.createTandem("focusinAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the PDOM root gets the focusin DOM event."}),this.focusoutAction=new Kl(t=>{if(!this.display.blockFocusCallbacks){var e=this.updateTrailForPDOMDispatch(t);this.dispatchPDOMEvent(e,"blur",t,!1),this.dispatchPDOMEvent(e,"focusout",t,!0)}},{phetioPlayback:!0,tandem:a.tandem.createTandem("focusoutAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the PDOM root gets the focusout DOM event."}),this.clickAction=new Kl(t=>{var e=this.updateTrailForPDOMDispatch(t);this.dispatchPDOMEvent(e,"click",t,!0)},{phetioPlayback:!0,tandem:a.tandem.createTandem("clickAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the PDOM root gets the click DOM event."}),this.inputAction=new Kl(t=>{var e=this.updateTrailForPDOMDispatch(t);this.dispatchPDOMEvent(e,"input",t,!0)},{phetioPlayback:!0,tandem:a.tandem.createTandem("inputAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the PDOM root gets the input DOM event."}),this.changeAction=new Kl(t=>{var e=this.updateTrailForPDOMDispatch(t);this.dispatchPDOMEvent(e,"change",t,!0)},{phetioPlayback:!0,tandem:a.tandem.createTandem("changeAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the PDOM root gets the change DOM event."}),this.keydownAction=new Kl(t=>{var e=this.updateTrailForPDOMDispatch(t);this.dispatchPDOMEvent(e,"keydown",t,!0)},{phetioPlayback:!0,tandem:a.tandem.createTandem("keydownAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the PDOM root gets the keydown DOM event."}),this.keyupAction=new Kl(t=>{var e=this.updateTrailForPDOMDispatch(t);this.dispatchPDOMEvent(e,"keyup",t,!0)},{phetioPlayback:!0,tandem:a.tandem.createTandem("keyupAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Emits when the PDOM root gets the keyup DOM event."}),this.accessibleEventOptions=!!Js.passive&&{capture:!1,passive:!1},this.pdomEventListenerMap=new Map,go.DOM_EVENTS.forEach(t=>{var e="".concat(t,"Action");this.pdomEventListenerMap.set(t,i=>{if(this.display.interactive){var s=this.getTrailFromPDOMEvent(i),n=s&&!("click"===t&&_.some(s.nodes,t=>t.positionInPDOM)&&i.timeStamp-this.upTimeStamp<=80);s&&n&&this[e].execute(i)}})}))}interruptPointers(){_.each(this.pointers,t=>{t.interruptAll()})}batchEvent(t,e,i,s){this.display.interactive&&(this.batchedEvents.push(Gu.pool.create(t,e,i)),!s&&this.batchDOMEvents||this.fireBatchedEvents()),!0===this.passiveEvents||i===this.mouseDown&&!Yi.edge||t.preventDefault()}fireBatchedEvents(){if(!this.currentlyFiringEvents&&this.batchedEvents.length){this.currentlyFiringEvents=!0;for(var t=this.batchedEvents,e=0;e=0;e--){var i=this.pointers[e];if(!(i instanceof Mu)){this.pointers.splice(e,1);var s=i.trail||new Nh(this.rootNode);this.exitEvents(i,t,s,0,!0)}}}connectListeners(){qu.addDisplay(this.display,this.attachToWindow,this.passiveEvents),this.display._accessible&&this.pdomEventListenerMap.forEach((t,e)=>{this.display.pdomRootElement.addEventListener(e,t,this.accessibleEventOptions)})}disconnectListeners(){qu.removeDisplay(this.display,this.attachToWindow,this.passiveEvents),this.display._accessible&&this.pdomEventListenerMap.forEach((t,e)=>{this.display.pdomRootElement.removeEventListener(e,t,this.accessibleEventOptions)})}pointFromEvent(t){var e=Is.pool.create(t.clientX,t.clientY);if(!this.assumeFullWindow){var i=this.display.domElement.getBoundingClientRect();i.width>0&&i.height>0&&(e.subtractXY(i.left,i.top),i.width===this.display.width&&i.height===this.display.height||(e.x*=this.display.width/i.width,e.y*=this.display.height/i.height))}return e}addPointer(t){this.pointers.push(t),this.pointerAddedEmitter.emit(t)}removePointer(t){for(var e=this.pointers.length-1;e>=0;e--)this.pointers[e]===t&&this.pointers.splice(e,1);t.dispose()}findPointerById(t){for(var e=this.pointers.length;e--;){var i=this.pointers[e];if(i.id===t)return i}return null}initMouse(t){var e=new Mu(t);return this.mouse=e,this.addPointer(e),e}ensureMouse(t){var e=this.mouse;return e||this.initMouse(t)}initPDOMPointer(){var t=new Nu(this.display);return this.pdomPointer=t,this.addPointer(t),t}ensurePDOMPointer(){var t=this.pdomPointer;return t||this.initPDOMPointer()}dispatchPDOMEvent(t,e,i,s){(go.USER_GESTURE_EVENTS.includes(e)&&$v.userGestureEmitter.emit(),i.target&&i.target.hasAttribute(go.DATA_EXCLUDE_FROM_INPUT))||(t.isPickable()||Yu.includes(e)||(t=new Nh([])),this.dispatchEvent(t,e,this.pdomPointer,i,s))}getRelatedTargetTrail(t){var e=t.relatedTarget;if(e&&this.isTargetUnderPDOM(e)){var i=t.relatedTarget,s=i.getAttribute(go.DATA_PDOM_UNIQUE_ID);return Tu.uniqueIdToTrail(this.display,s)}return null}updateTrailForPDOMDispatch(t){var e=this.getTrailFromPDOMEvent(t);return this.ensurePDOMPointer().updateTrail(e)}getTrailFromPDOMEvent(t){if(t.targetSubstitute){var e=t.targetSubstitute.getAttribute(go.DATA_PDOM_UNIQUE_ID);return Tu.uniqueIdToTrail(this.display,e)}var i=t.target;if(i&&this.isTargetUnderPDOM(i)){var s=i.getAttribute(go.DATA_PDOM_UNIQUE_ID);return Tu.uniqueIdToTrail(this.display,s)}return null}mouseDown(t,e,i){this.mouseDownAction.execute(t,e,i)}mouseUp(t,e){this.mouseUpAction.execute(t,e)}mouseMove(t,e){this.mouseMoveAction.execute(t,e)}mouseOver(t,e){this.mouseOverAction.execute(t,e)}mouseOut(t,e){this.mouseOutAction.execute(t,e)}wheel(t){this.wheelScrollAction.execute(t)}touchStart(t,e,i){this.touchStartAction.execute(t,e,i)}touchEnd(t,e,i){this.touchEndAction.execute(t,e,i)}touchMove(t,e,i){this.touchMoveAction.execute(t,e,i)}touchCancel(t,e,i){this.touchCancelAction.execute(t,e,i)}penStart(t,e,i){this.penStartAction.execute(t,e,i)}penEnd(t,e,i){this.penEndAction.execute(t,e,i)}penMove(t,e,i){this.penMoveAction.execute(t,e,i)}penCancel(t,e,i){this.penCancelAction.execute(t,e,i)}pointerDown(t,e,i,s){var n=this.attachToWindow?document.body:this.display.domElement;switch(n.setPointerCapture&&s.pointerId&&n.setPointerCapture(s.pointerId),e=this.handleUnknownPointerType(e,t)){case"mouse":this.mouseDown(t,i,s);break;case"touch":this.touchStart(t,i,s);break;case"pen":this.penStart(t,i,s);break;default:0}}pointerUp(t,e,i,s){switch(this.upTimeStamp=s.timeStamp,e=this.handleUnknownPointerType(e,t)){case"mouse":this.mouseUp(i,s);break;case"touch":this.touchEnd(t,i,s);break;case"pen":this.penEnd(t,i,s);break;default:0}}pointerCancel(t,e,i,s){switch(e=this.handleUnknownPointerType(e,t)){case"mouse":console&&console.log&&console.log("WARNING: Pointer mouse cancel was received");break;case"touch":this.touchCancel(t,i,s);break;case"pen":this.penCancel(t,i,s);break;default:console.log&&console.log("Unknown pointer type: ".concat(e))}}gotPointerCapture(t,e,i,s){this.gotPointerCaptureAction.execute(t,s)}lostPointerCapture(t,e,i,s){this.lostPointerCaptureAction.execute(t,s)}pointerMove(t,e,i,s){switch(e=this.handleUnknownPointerType(e,t)){case"mouse":this.mouseMove(i,s);break;case"touch":this.touchMove(t,i,s);break;case"pen":this.penMove(t,i,s);break;default:console.log&&console.log("Unknown pointer type: ".concat(e))}}pointerOver(t,e,i,s){}pointerOut(t,e,i,s){}pointerEnter(t,e,i,s){}pointerLeave(t,e,i,s){}handleUnknownPointerType(t,e){return""!==t?t:this.mouse&&this.mouse.id===e?"mouse":"touch"}getPointerTrail(t){return this.rootNode.trailUnderPointer(t)||new Nh(this.rootNode)}upEvent(t,e,i){if(!this.isTargetUnderPDOM(e.target)){var s=this.branchChangeEvents(t,e,i);this.dispatchEvent(s,"up",t,e,!0),t.isTouchLike()&&this.exitEvents(t,e,s,0,!0)}}downEvent(t,e,i){if(!this.isTargetUnderPDOM(e.target)){var s=this.branchChangeEvents(t,e,i);this.dispatchEvent(s,"down",t,e,!0)}}moveEvent(t,e){this.branchChangeEvents(t,e,!0)}cancelEvent(t,e,i){var s=this.branchChangeEvents(t,e,i);this.dispatchEvent(s,"cancel",t,e,!0),t.isTouchLike()&&this.exitEvents(t,e,s,0,!0)}branchChangeEvents(t,e,i){var s=this.getPointerTrail(t),n=s.slice(0,Math.min(s.nodes.length,s.getLastInputEnabledIndex()+1)),r=t.inputEnabledTrail||new Nh(this.rootNode),a=Nh.branchIndex(n,r),o=r.lastNode()!==n.lastNode();return i&&this.dispatchEvent(s,"move",t,e,!0),this.exitEvents(t,e,r,a,o),this.enterEvents(t,e,n,a,o),t.trail=s,t.inputEnabledTrail=n,s}enterEvents(t,e,i,s,n){n&&this.dispatchEvent(i,"over",t,e,!0,!0);for(var r=s;r=s;r--)this.dispatchEvent(i.slice(0,r+1),"exit",t,e,!1,!0);n&&this.dispatchEvent(i,"out",t,e,!0)}dispatchEvent(t,e,i,s,n){var r=arguments.length>5&&void 0!==arguments[5]&&arguments[5],a=new Bu(t,e,i,s);this.dispatchToListeners(i,i.getListeners(),e,a),this.dispatchToTargets(t,e,i,a,n,r),this.dispatchToListeners(i,this.display.getInputListeners(),e,a),$v.inputListeners.length&&this.dispatchToListeners(i,$v.inputListeners.slice(),e,a)}dispatchToListeners(t,e,i,s){if(!s.handled)for(var n=t.type+i,r=0;r5&&void 0!==arguments[5]&&arguments[5];if(!s.aborted&&!s.handled)for(var a=t.getLastInputEnabledIndex(),o=t.nodes.length-1;o>=0;n?o--:o=-1){var h=t.nodes[o],l=a{var s=t[i];null==s?e[i]=null:s instanceof Element&&Hu.includes(i)&&"function"==typeof s.getAttribute&&s.hasAttribute(go.DATA_PDOM_UNIQUE_ID)?e[i]={[go.DATA_PDOM_UNIQUE_ID]:s.getAttribute(go.DATA_PDOM_UNIQUE_ID),id:s.getAttribute("id")}:e[i]="object"==typeof s?{}:JSON.parse(JSON.stringify(s))}),e}static deserializeDomEvent(t){var e=t.constructorName||"Event",i=_.pick(t,Vu);if(i.relatedTarget){var s=document.getElementById(i.relatedTarget.id);i.relatedTarget=s}var n=new window[e](e,i);for(var r in t){if(t.hasOwnProperty(r)&&!Vu.includes(r))if("target"===r)n.targetSubstitute=_.clone(t[r])||{},n.targetSubstitute.getAttribute=function(t){return this[t]};else n[r]=t[r]}return n}static debugText(t,e){var i="".concat(e.timeStamp," ").concat(e.type);return null!==t&&(i="".concat(t.x,",").concat(t.y," ").concat(i)),i}static msPointerType(t){return t.pointerType===window.MSPointerEvent.MSPOINTER_TYPE_TOUCH?"touch":t.pointerType===window.MSPointerEvent.MSPOINTER_TYPE_PEN?"pen":t.pointerType===window.MSPointerEvent.MSPOINTER_TYPE_MOUSE?"mouse":t.pointerType}}var Wu=Wt(ku.PointerIO);zu.InputIO=new j("InputIO",{valueType:zu,applyState:_.noop,toStateObject:t=>({pointers:Wu.toStateObject(t.pointers)}),stateSchema:{pointers:Wu}}),bs.register("Input",zu);class Uu extends it{}_defineProperty(Uu,"POINTER_TYPE",new Uu),_defineProperty(Uu,"MS_POINTER_TYPE",new Uu),_defineProperty(Uu,"TOUCH_TYPE",new Uu),_defineProperty(Uu,"MOUSE_TYPE",new Uu),_defineProperty(Uu,"WHEEL_TYPE",new Uu),_defineProperty(Uu,"enumeration",new at(Uu,{phetioDocumentation:"The type of batched event"}));class Gu{constructor(t,e,i){this.initialize(t,e,i)}initialize(t,e,i){this.domEvent=t,this.type=e,this.callback=i}run(t){var e=this.domEvent,i=this.callback;if(t.validatePointers(),this.type===Uu.POINTER_TYPE){var s=e;i.call(t,s.pointerId,s.pointerType,t.pointFromEvent(s),s)}else if(this.type===Uu.MS_POINTER_TYPE){var n=e;i.call(t,n.pointerId,zu.msPointerType(n),t.pointFromEvent(n),n)}else if(this.type===Uu.TOUCH_TYPE)for(var r=e,a=0;a{},ju={addDisplay(t,e,i){this.attachedDisplays.push(t),e?1===this.attachedDisplays.length&&this.connectWindowListeners(i):this.addOrRemoveListeners(t.domElement,!0,i),t.domElement.addEventListener("wheel",this.onwheel,ju.getEventOptions(i,!0))},removeDisplay(t,e,i){tt(this.attachedDisplays,t),e?0===this.attachedDisplays.length&&this.disconnectWindowListeners(i):this.addOrRemoveListeners(t.domElement,!1,i),t.domElement.removeEventListener("wheel",this.onwheel,ju.getEventOptions(i,!0))},getEventOptions:(t,e)=>!(!Js.passive||null===t)&&(e?{capture:!1,passive:t}:{passive:t}),listenersAttachedToWindow:0,listenersAttachedToElement:0,attachedDisplays:[],canUsePointerEvents:!!(window.navigator&&window.navigator.pointerEnabled||window.PointerEvent)&&!Yi.firefox,canUseMSPointerEvents:window.navigator&&window.navigator.msPointerEnabled,pointerListenerTypes:["pointerdown","pointerup","pointermove","pointerover","pointerout","pointercancel","gotpointercapture","lostpointercapture"],msPointerListenerTypes:["MSPointerDown","MSPointerUp","MSPointerMove","MSPointerOver","MSPointerOut","MSPointerCancel"],touchListenerTypes:["touchstart","touchend","touchmove","touchcancel"],mouseListenerTypes:["mousedown","mouseup","mousemove","mouseover","mouseout"],wheelListenerTypes:["wheel"],getNonWheelUsedTypes(){return this.canUsePointerEvents?this.pointerListenerTypes:this.canUseMSPointerEvents?this.msPointerListenerTypes:this.touchListenerTypes.concat(this.mouseListenerTypes)},connectWindowListeners(t){this.addOrRemoveListeners(window,!0,t)},disconnectWindowListeners(t){this.addOrRemoveListeners(window,!1,t)},addOrRemoveListeners(t,e,i){var s=t===window,n=e?1:-1;s?this.listenersAttachedToWindow+=n:this.listenersAttachedToElement+=n;for(var r=e?"addEventListener":"removeEventListener",a=this.getNonWheelUsedTypes(),o=0;o{this.mouseToggle()},this.mouseMoveAction=()=>{this.mouseMove()},this.touchStartAction=()=>{var t=this.createTouch(this.getRandomPosition());this.touchStart(t)},this.touchMoveAction=()=>{var t=this.random.sample(this.touches);this.touchMove(t)},this.touchEndAction=()=>{var t=this.random.sample(this.touches);this.touchEnd(t),this.removeTouch(t)},this.touchCancelAction=()=>{var t=this.random.sample(this.touches);this.touchCancel(t),this.removeTouch(t)}}fuzzEvents(t,e,i,s){for(;this.random.nextDouble()<1-1/(t+1);){var n=this.touches.length+(this.isMouseDown?1:0)({identifier:t.id,target:i,clientX:t.position.x,clientY:t.position.y}));if(void 0!==window.Touch&&void 0!==window.TouchEvent&&1===window.Touch.length&&1===window.TouchEvent.length){var n=s.map(t=>new window.Touch(t));return new window.TouchEvent(t,{cancelable:!0,bubbles:!0,touches:n,targetTouches:[],changedTouches:n,shiftKey:!1})}var r=document.createEvent("CustomEvent");return r.initCustomEvent(t,!0,!0,{touches:s,targetTouches:[],changedTouches:s}),r}getRandomPosition(){return new Is(Math.floor(this.random.nextDouble()*this.display.width),Math.floor(this.random.nextDouble()*this.display.height))}createTouch(t){var e={id:this.nextTouchID++,position:t};return this.touches.push(e),e}removeTouch(t){this.touches.splice(this.touches.indexOf(t),1)}touchStart(t){var e=this.createTouchEvent("touchstart",[t]);this.display._input.validatePointers(),this.display._input.touchStart(t.id,t.position,e)}touchMove(t){t.position=this.getRandomPosition();var e=this.createTouchEvent("touchmove",[t]);this.display._input.validatePointers(),this.display._input.touchMove(t.id,t.position,e)}touchEnd(t){var e=this.createTouchEvent("touchend",[t]);this.display._input.validatePointers(),this.display._input.touchEnd(t.id,t.position,e)}touchCancel(t){var e=this.createTouchEvent("touchcancel",[t]);this.display._input.validatePointers(),this.display._input.touchCancel(t.id,t.position,e)}mouseToggle(){var t=document.createEvent("MouseEvent");t.initMouseEvent(this.isMouseDown?"mouseup":"mousedown",!0,!0,window,1,this.mousePosition.x,this.mousePosition.y,this.mousePosition.x,this.mousePosition.y,!1,!1,!1,!1,0,null),this.display._input.validatePointers(),this.isMouseDown?(this.display._input.mouseUp(this.mousePosition,t),this.isMouseDown=!1):(this.display._input.mouseDown(null,this.mousePosition,t),this.isMouseDown=!0)}mouseMove(){this.mousePosition=this.getRandomPosition();var t=document.createEvent("MouseEvent");t.initMouseEvent("mousemove",!0,!0,window,0,this.mousePosition.x,this.mousePosition.y,this.mousePosition.x,this.mousePosition.y,!1,!1,!1,!1,0,null),this.display._input.validatePointers(),this.display._input.mouseMove(this.mousePosition,t)}}bs.register("InputFuzzer",Ku);class Zu extends Vt{constructor(t){super(t=b({mouseButton:0},t)),this.options=t,this.isDown=!1,this.downCurrentTarget=null,this.downTrail=null,this.pointer=null,this.interrupted=!1,this.downListener={up:t=>{t.pointer instanceof Mu&&t.domEvent.button!==this.options.mouseButton||this.buttonUp(t)},interrupt:()=>{this.interrupt()},cancel:t=>{this.buttonUp(t)}}}buttonDown(t){this.isDown||t.pointer instanceof Mu&&t.domEvent.button!==this.options.mouseButton||(t.pointer.addInputListener(this.downListener),this.isDown=!0,this.downCurrentTarget=t.currentTarget,this.downTrail=t.trail.subtrailTo(t.currentTarget,!1),this.pointer=t.pointer,this.options.down&&this.options.down(t,this.downTrail))}buttonUp(t){this.isDown=!1,this.pointer.removeInputListener(this.downListener);var e=t.currentTarget;if(t.currentTarget=this.downCurrentTarget,this.options.upInside||this.options.upOutside){var i=t.trail.isExtensionOf(this.downTrail,!0)&&!this.interrupted;i&&this.options.upInside?this.options.upInside(t,this.downTrail):!i&&this.options.upOutside&&this.options.upOutside(t,this.downTrail)}this.options.up&&this.options.up(t,this.downTrail),t.currentTarget=e}down(t){this.buttonDown(t)}interrupt(){if(this.isDown){this.interrupted=!0;var t=new Bu(new Nh,"synthetic",this.pointer,null);t.currentTarget=this.downCurrentTarget,this.buttonUp(t),this.interrupted=!1}}}bs.register("DownUpListener",Zu);var Qu=Zu;class Ju extends Qu{constructor(t){super({tandem:(t=b({tandem:Ct.OPTIONAL,phetioType:Ju.ButtonListenerIO,phetioState:!1,phetioEventType:ct.USER},t)).tandem,phetioType:t.phetioType,phetioState:t.phetioState,mouseButton:t.mouseButton||0,down:(t,e)=>{this.setButtonState(t,"down")},up:(t,e)=>{this.setButtonState(t,this._overCount>0?"over":"up")}}),this.buttonState="up",this._overCount=0,this._buttonOptions=t}setButtonState(t,e){if(e!==this.buttonState){var i=this.buttonState;this.buttonState=e,this._buttonOptions[e]&&(this.phetioStartEvent(e),this._buttonOptions[e](t,i),this.phetioEndEvent()),this._buttonOptions.fire&&this._overCount>0&&!this.interrupted&&(this._buttonOptions.fireOnDown?"down"===e:"down"===i)&&(this.phetioStartEvent("fire"),this._buttonOptions.fire(t),this.phetioEndEvent())}}enter(t){this._overCount++,1===this._overCount&&this.setButtonState(t,this.isDown?"down":"over")}exit(t){this._overCount--,0===this._overCount&&this.setButtonState(t,this.isDown?"out":"up")}focus(t){this.enter(t)}blur(t){this.exit(t)}click(t){this.setButtonState(t,"down"),this.setButtonState(t,"up")}}bs.register("ButtonListener",Ju),Ju.ButtonListenerIO=new j("ButtonListenerIO",{valueType:Ju,documentation:"Button listener",events:["up","over","down","out","fire"]});class $u extends Vt{constructor(t){t=b({start:null,drag:null,end:null,translate:null,allowTouchSnag:!1,mouseButton:0,dragCursor:"pointer",attach:!0,tandem:Ct.REQUIRED,phetioState:!1,phetioEventType:ct.USER,phetioReadOnly:!0},t),super(),this.options=t,this.isDraggingProperty=new pe(!1,{phetioReadOnly:t.phetioReadOnly,phetioState:!1,tandem:t.tandem.createTandem("isDraggingProperty"),phetioDocumentation:"Indicates whether the object is dragging"}),this.pointer=null,this.trail=null,this.transform=null,this.node=null,this.lastDragPoint=null,this.startTransformMatrix=null,this.mouseButton=void 0,this.interrupted=!1,this.lastInterruptedTouchLikePointer=null,this._attach=t.attach,this.dragStartAction=new Kl((t,e)=>{this.dragging||(this._attach&&(e.pointer.dragging=!0),e.pointer.cursor=this.options.dragCursor,e.pointer.addInputListener(this.dragListener,this.options.attach),e.pointer.reserveForDrag(),this.isDraggingProperty.set(!0),this.pointer=e.pointer,this.trail=e.trail.subtrailTo(e.currentTarget,!0),this.transform=this.trail.getTransform(),this.node=e.currentTarget,this.lastDragPoint=e.pointer.point,this.startTransformMatrix=e.currentTarget.getMatrix().copy(),this.mouseButton=e.pointer instanceof Mu?e.domEvent.button:void 0,this.options.start&&this.options.start.call(null,e,this.trail))},{tandem:t.tandem.createTandem("dragStartAction"),phetioReadOnly:t.phetioReadOnly,parameters:[{name:"point",phetioType:Is.Vector2IO,phetioDocumentation:"the position of the drag start in view coordinates"},{phetioPrivate:!0,valueType:[Bu,null]}]}),this.dragAction=new Kl((t,e)=>{if(this.dragging&&!this.isDisposed){var i=this.pointer.point.minus(this.lastDragPoint);if(0!==i.magnitudeSquared){var s=this.transform.inverseDelta2(i);if(this.options.translate){var n=this.node.getMatrix().getTranslation();this.options.translate.call(null,{delta:s,oldPosition:n,position:n.plus(s)})}if(this.lastDragPoint=this.pointer.point,this.options.drag){var r=e.currentTarget;e.currentTarget=this.node,this.options.drag.call(null,e,this.trail),e.currentTarget=r}}}},{phetioHighFrequency:!0,phetioReadOnly:t.phetioReadOnly,tandem:t.tandem.createTandem("dragAction"),parameters:[{name:"point",phetioType:Is.Vector2IO,phetioDocumentation:"the position of the drag in view coordinates"},{phetioPrivate:!0,valueType:[Bu,null]}]}),this.dragEndAction=new Kl((t,e)=>{this.dragging&&(this._attach&&(this.pointer.dragging=!1),this.pointer.cursor=null,this.pointer.removeInputListener(this.dragListener),this.isDraggingProperty.set(!1),this.options.end&&this.options.end.call(null,e,this.trail),this.pointer=null)},{tandem:t.tandem.createTandem("dragEndAction"),phetioReadOnly:t.phetioReadOnly,parameters:[{name:"point",phetioType:Is.Vector2IO,phetioDocumentation:"the position of the drag end in view coordinates"},{phetioPrivate:!0,isValidValue:t=>null===t||t instanceof Bu||t.pointer&&t.currentTarget}]}),this.transformListener={transform:t=>{if(this.trail.isExtensionOf(t.trail,!0)){var e=t.trail.getMatrix(),i=this.transform.getMatrix();this.node.prependMatrix(e.inverted().timesMatrix(i)),this.transform.setMatrix(e)}}},this.dragListener={up:t=>{if(this.dragging&&!this.isDisposed&&(!(t.pointer instanceof Mu)||t.domEvent.button===this.mouseButton)){var e=t.currentTarget;t.currentTarget=this.node,this.endDrag(t),t.currentTarget=e}},cancel:t=>{if(this.dragging&&!this.isDisposed){var e=t.currentTarget;t.currentTarget=this.node,this.endDrag(t),t.currentTarget=e,this.transform||this.node.setMatrix(this.startTransformMatrix)}},move:t=>{this.dragAction.execute(t.pointer.point,t)},interrupt:()=>{this.interrupt()}},this.initializePhetioObject({},t)}get dragging(){return this.isDraggingProperty.get()}set dragging(t){}startDrag(t){this.dragStartAction.execute(t.pointer.point,t)}endDrag(t){this.dragEndAction.execute(t?t.pointer.point:Is.ZERO,t)}interrupt(){this.dragging&&(this.interrupted=!0,this.pointer&&this.pointer.isTouchLike()&&(this.lastInterruptedTouchLikePointer=this.pointer),this.endDrag({pointer:this.pointer,currentTarget:this.node}),this.interrupted=!1)}tryToSnag(t){t.pointer instanceof Mu&&t.domEvent&&this.options.mouseButton!==t.domEvent.button&&-1!==this.options.mouseButton||this.isDisposed||this.dragging||t.pointer.dragging&&this._attach||t.pointer===this.lastInterruptedTouchLikePointer||!t.canStartPress()||this.startDrag(t)}tryTouchToSnag(t){this.options.allowTouchSnag&&(!0===this.options.allowTouchSnag||this.options.allowTouchSnag(t))&&this.tryToSnag(t)}down(t){this.tryToSnag(t)}touchenter(t){this.tryTouchToSnag(t)}touchmove(t){this.tryTouchToSnag(t)}dispose(){this.dragging&&(this._attach&&(this.pointer.dragging=!1),this.pointer.cursor=null,this.pointer.removeInputListener(this.dragListener)),this.isDraggingProperty.dispose(),this.dragEndAction.dispose(),this.dragAction.dispose(),this.dragStartAction.dispose(),super.dispose()}static createForwardingListener(t,e){return e=b({allowTouchSnag:!1},e),{down:e=>{!e.pointer.dragging&&e.canStartPress()&&t(e)},touchenter:function(t){e.allowTouchSnag&&this.down(t)},touchmove:function(t){e.allowTouchSnag&&this.down(t)}}}}bs.register("SimpleDragHandler",$u);var tc=0,ec=_.constant(!0);class ic extends nd{constructor(t){var e=w()({press:_.noop,release:_.noop,targetNode:null,drag:_.noop,attach:!0,mouseButton:0,pressCursor:"pointer",useInputListenerCursor:!1,canStartPress:ec,a11yLooksPressedInterval:100,collapseDragEvents:!1,phetioEnabledPropertyInstrumented:!1,tandem:Ct.REQUIRED,phetioReadOnly:!0,phetioFeatured:Vt.DEFAULT_OPTIONS.phetioFeatured},t);super(e),this._id=tc++,this._mouseButton=e.mouseButton,this._a11yLooksPressedInterval=e.a11yLooksPressedInterval,this._pressCursor=e.pressCursor,this._pressListener=e.press,this._releaseListener=e.release,this._dragListener=e.drag,this._canStartPress=e.canStartPress,this._targetNode=e.targetNode,this._attach=e.attach,this._collapseDragEvents=e.collapseDragEvents,this.overPointers=ze(),this.isPressedProperty=new pe(!1,{reentrant:!0}),this.isOverProperty=new pe(!1),this.looksOverProperty=new pe(!1),this.isHoveringProperty=new pe(!1),this.isHighlightedProperty=new pe(!1),this.isFocusedProperty=new pe(!1),this.cursorProperty=new Ue([this.enabledProperty],t=>e.useInputListenerCursor&&t&&this._attach?this._pressCursor:null),this.pointer=null,this.pressedTrail=null,this.interrupted=!1,this._pendingCollapsedDragEvent=null,this._listeningToPointer=!1,this._isHoveringListener=this.invalidateHovering.bind(this),this._isHighlightedListener=this.invalidateHighlighted.bind(this),this.pdomClickingProperty=new pe(!1),this.looksPressedProperty=Ue.or([this.pdomClickingProperty,this.isPressedProperty]),this._pdomClickingTimeoutListener=null,this._pointerListener={up:this.pointerUp.bind(this),cancel:this.pointerCancel.bind(this),move:this.pointerMove.bind(this),interrupt:this.pointerInterrupt.bind(this),listener:this},this._pressAction=new Kl(this.onPress.bind(this),{tandem:e.tandem.createTandem("pressAction"),phetioDocumentation:"Executes whenever a press occurs. The first argument when executing can be used to convey info about the SceneryEvent.",phetioReadOnly:!0,phetioFeatured:e.phetioFeatured,phetioEventType:ct.USER,parameters:[{name:"event",phetioType:Bu.SceneryEventIO},{phetioPrivate:!0,valueType:[uh,null]},{phetioPrivate:!0,valueType:["function",null]}]}),this._releaseAction=new Kl(this.onRelease.bind(this),{parameters:[{name:"event",phetioType:Kt(Bu.SceneryEventIO)},{phetioPrivate:!0,valueType:["function",null]}],tandem:e.tandem.createTandem("releaseAction"),phetioDocumentation:"Executes whenever a release occurs.",phetioReadOnly:!0,phetioFeatured:e.phetioFeatured,phetioEventType:ct.USER}),this.display=null,this.boundInvalidateOverListener=this.invalidateOver.bind(this),this.overPointers.lengthProperty.link(this.invalidateOver.bind(this)),this.isFocusedProperty.link(this.invalidateOver.bind(this)),this.overPointers.lengthProperty.link(this._isHoveringListener),this.isPressedProperty.link(this._isHoveringListener),this.overPointers.addItemAddedListener(t=>t.isDownProperty.link(this._isHoveringListener)),this.overPointers.addItemRemovedListener(t=>t.isDownProperty.unlink(this._isHoveringListener)),this.isHoveringProperty.link(this._isHighlightedListener),this.isPressedProperty.link(this._isHighlightedListener),this.enabledProperty.lazyLink(this.onEnabledPropertyChange.bind(this))}get isPressed(){return this.isPressedProperty.value}get cursor(){return this.cursorProperty.value}get attach(){return this._attach}get targetNode(){return this._targetNode}getCurrentTarget(){return this.pressedTrail.lastNode()}get currentTarget(){return this.getCurrentTarget()}canPress(t){return!!this.enabledProperty.value&&!this.isPressed&&this._canStartPress(t,this)&&(!(t.pointer instanceof Mu)||t.domEvent.button===this._mouseButton)&&(!this._attach||!t.pointer.isAttached())}canClick(){return this.enabledProperty.value&&!this.isPressed&&this._canStartPress(null,this)}press(t,e,i){return!!this.canPress(t)&&(this.flushCollapsedDrag(),this._pressAction.execute(t,e||null,i||null),!0)}release(t,e){this.flushCollapsedDrag(),this._releaseAction.execute(t||null,e||null)}drag(t){this._dragListener(t,this)}interrupt(){this.pdomClickingProperty.value?(this.interrupted=!0,this._listeningToPointer?this.release():(this.isPressedProperty.value=!1,this._releaseListener(null,this)),ve.hasListener(this._pdomClickingTimeoutListener)&&(ve.clearTimeout(this._pdomClickingTimeoutListener),this.pdomClickingProperty.isDisposed||(this.pdomClickingProperty.value=!1))):this.isPressed&&(this.interrupted=!0,this.release())}clearOverPointers(){this.overPointers.clear()}step(){this.flushCollapsedDrag()}setCreatePanTargetBounds(t){this._pointerListener.createPanTargetBounds=t}set createPanTargetBounds(t){this.setCreatePanTargetBounds(t)}setCreatePanTargetBoundsFromTrail(t){this.setCreatePanTargetBounds(()=>t.localToGlobalBounds(t.lastNode().localBounds))}set createPanTargetBoundsFromTrail(t){this.setCreatePanTargetBoundsFromTrail(t)}flushCollapsedDrag(){this._pendingCollapsedDragEvent&&this.drag(this._pendingCollapsedDragEvent),this._pendingCollapsedDragEvent=null}invalidateOver(){var t=!1;if(this._listeningToPointer)t=!1;else for(var e=0;e0&&!t,this.looksOverProperty.value=this.isOverProperty.value||this.isFocusedProperty.value&&!!this.display&&this.display.focusManager.pdomFocusHighlightsVisibleProperty.value}invalidateHovering(){for(var t=0;t{this.pdomClickingProperty.isDisposed||(this.pdomClickingProperty.value=!1)},this._a11yLooksPressedInterval)),!0}focus(t){var e=t.trail.rootNode().getRootedDisplays().filter(t=>t.isAccessible());this.display=e[0],this.display.focusManager.pdomFocusHighlightsVisibleProperty.hasListener(this.boundInvalidateOverListener)||this.display.focusManager.pdomFocusHighlightsVisibleProperty.link(this.boundInvalidateOverListener),this.isFocusedProperty.value=!0}blur(){this.display&&(this.display.focusManager.pdomFocusHighlightsVisibleProperty.hasListener(this.boundInvalidateOverListener)&&this.display.focusManager.pdomFocusHighlightsVisibleProperty.unlink(this.boundInvalidateOverListener),this.display=null),this.isFocusedProperty.value=!1}dispose(){this.overPointers.clear(),this._listeningToPointer&&this.isPressed&&this.pointer.removeInputListener(this._pointerListener),this.isPressedProperty.isDisposed||(this.isPressedProperty.unlink(this._isHighlightedListener),this.isPressedProperty.unlink(this._isHoveringListener)),!this.isHoveringProperty.isDisposed&&this.isHoveringProperty.unlink(this._isHighlightedListener),this.overPointers.dispose(),this.isPressedProperty.dispose(),this.isOverProperty.dispose(),this.isHoveringProperty.dispose(),this.isHighlightedProperty.dispose(),this.isFocusedProperty.dispose(),this.pdomClickingProperty.dispose(),this.looksPressedProperty.dispose(),this._pressAction.dispose(),this._releaseAction.dispose(),this.display&&(this.display.focusManager.pdomFocusHighlightsVisibleProperty.unlink(this.boundInvalidateOverListener),this.display=null),super.dispose()}}_defineProperty(ic,"phetioAPI",{pressAction:{phetioType:Kl.PhetioActionIO([Bu.SceneryEventIO])},releaseAction:{phetioType:Kl.PhetioActionIO([Kt(Bu.SceneryEventIO)])}}),bs.register("PressListener",ic);class sc extends ic{constructor(t){var e=w()({fire:_.noop,fireOnDown:!1,fireOnHold:!1,fireOnHoldDelay:400,fireOnHoldInterval:100,tandem:Ct.REQUIRED,phetioReadOnly:Vt.DEFAULT_OPTIONS.phetioReadOnly},t);super(e),this._fireOnDown=e.fireOnDown,this.firedEmitter=new xe({tandem:e.tandem.createTandem("firedEmitter"),phetioEventType:ct.USER,phetioReadOnly:e.phetioReadOnly,phetioDocumentation:"Emits at the time that the listener fires",parameters:[{name:"event",phetioType:Kt(Bu.SceneryEventIO)}]}),this.firedEmitter.addListener(e.fire),e.fireOnHold&&(this._timer=new fe({callback:this.fire.bind(this,null),delay:e.fireOnHoldDelay,interval:e.fireOnHoldInterval}))}fire(t){this.firedEmitter.emit(t)}press(t,e,i){return super.press(t,e,()=>{this._fireOnDown&&this.fire(t),this._timer&&this._timer.start(),i&&i()})}release(t,e){super.release(t,()=>{var i=!this._fireOnDown&&this.isHoveringProperty.value&&!this.interrupted;this._timer?this._timer.stop(i):i&&this.fire(t||null),e&&e()})}click(t,e){return super.click(t,()=>{this.interrupted||this.fire(t),e&&e()})}interrupt(){super.interrupt(),this._timer&&this._timer.stop(!1)}dispose(){this.firedEmitter.dispose(),this._timer&&this._timer.dispose(),super.dispose()}}bs.register("FireListener",sc);var nc=new Is(0,0);bs.register("DragListener",class extends ic{constructor(t){var e=w()({positionProperty:null,start:null,end:null,transform:null,dragBoundsProperty:null,allowTouchSnag:!0,applyOffset:!0,useParentOffset:!1,trackAncestors:!1,translateNode:!1,mapPosition:null,offsetPosition:null,allowClick:!1,tandem:Ct.REQUIRED,phetioReadOnly:!0,phetioFeatured:Vt.DEFAULT_OPTIONS.phetioFeatured},t);super(e),this._allowTouchSnag=e.allowTouchSnag,this._applyOffset=e.applyOffset,this._useParentOffset=e.useParentOffset,this._trackAncestors=e.trackAncestors,this._translateNode=e.translateNode,this._transform=e.transform,this._positionProperty=e.positionProperty,this._mapPosition=e.mapPosition,this._offsetPosition=e.offsetPosition,this._dragBoundsProperty=e.dragBoundsProperty||new me(null),this._start=e.start,this._end=e.end,this._allowClick=e.allowClick,this.isUserControlledProperty=this.isPressedProperty,this._globalPoint=new Is(0,0),this._localPoint=new Is(0,0),this._parentPoint=new Is(0,0),this._modelPoint=new Is(0,0),this._modelDelta=new Is(0,0),this._parentOffset=new Is(0,0),this._transformTracker=null,this._transformTrackerListener=this.ancestorTransformed.bind(this),this._lastInterruptedTouchLikePointer=null,this._dragAction=new Kl(t=>{var e=this.pointer.point;e&&(this._globalPoint.equals(e)||this.reposition(e)),ic.prototype.drag.call(this,t)},{parameters:[{name:"event",phetioType:Bu.SceneryEventIO}],phetioFeatured:e.phetioFeatured,tandem:e.tandem.createTandem("dragAction"),phetioHighFrequency:!0,phetioDocumentation:"Emits whenever a drag occurs with an SceneryEventIO argument.",phetioReadOnly:e.phetioReadOnly,phetioEventType:ct.USER})}press(t,e,i){return super.press(t,e,()=>{this.pointer.reserveForDrag(),this.attachTransformTracker();var e=this.pointer.point,s=this.globalToParentPoint(this._localPoint.set(e));this._useParentOffset&&this.modelToParentPoint(this._parentOffset.set(this._positionProperty.value)).subtract(s),this.parentToLocalPoint(s),this.reposition(e),this._start&&this._start(t,this),i&&i()})}release(t,e){super.release(t,()=>{this.detachTransformTracker(),this._end&&this._end(t||null,this),e&&e()})}canClick(){return super.canClick()&&this._allowClick}click(t,e){return super.click(t,()=>{this._start&&this._start(t,this),e&&e(),this._end&&this._end(t,this)})}drag(t){var e=this.pointer.point;e&&!this._globalPoint.equals(e)&&this._dragAction.execute(t)}tryTouchSnag(t){!this._allowTouchSnag||this.attach&&t.pointer.isAttached()||this.press(t)}getGlobalPoint(){return this._globalPoint.copy()}get globalPoint(){return this.getGlobalPoint()}getLocalPoint(){return this._localPoint.copy()}get localPoint(){return this.getLocalPoint()}getParentPoint(){return this._parentPoint.copy()}get parentPoint(){return this.getParentPoint()}getModelPoint(){return this._modelPoint.copy()}get modelPoint(){return this.getModelPoint()}getModelDelta(){return this._modelDelta.copy()}get modelDelta(){return this.getModelDelta()}globalToParentPoint(t){return this.pressedTrail.getParentTransform().getInverse().multiplyVector2(t),t}parentToLocalPoint(t){return this.pressedTrail.lastNode().getTransform().getInverse().multiplyVector2(t),t}localToParentPoint(t){return this.pressedTrail.lastNode().getMatrix().multiplyVector2(t),t}parentToModelPoint(t){return this._transform&&this._transform.getInverse().multiplyVector2(t),t}modelToParentPoint(t){return this._transform&&this._transform.getMatrix().multiplyVector2(t),t}mapModelPoint(t){return this._mapPosition?this._mapPosition(t):this._dragBoundsProperty.value?this._dragBoundsProperty.value.closestPointTo(t):t}applyParentOffset(t){this._offsetPosition&&t.add(this._offsetPosition(t,this)),this._applyOffset&&(this._useParentOffset?t.add(this._parentOffset):(t.subtract(this.localToParentPoint(nc.set(this._localPoint))),t.add(this.localToParentPoint(nc.setXY(0,0)))))}reposition(t){this._globalPoint.set(t),this.applyParentOffset(this.globalToParentPoint(this._parentPoint.set(t))),this._modelDelta.set(this._modelPoint).negate(),this._modelPoint.set(this.mapModelPoint(this.parentToModelPoint(nc.set(this._parentPoint)))),this._modelDelta.add(this._modelPoint),this.modelToParentPoint(this._parentPoint.set(this._modelPoint)),this._translateNode&&(this.pressedTrail.lastNode().translation=this._parentPoint),this._positionProperty&&(this._positionProperty.value=this._modelPoint.copy())}touchenter(t){this.tryTouchSnag(t)}touchmove(t){this.tryTouchSnag(t)}ancestorTransformed(){var t=this.pointer.point;t&&this.reposition(t)}attachTransformTracker(){this._trackAncestors&&(this._transformTracker=new Bl(this.pressedTrail.copy().removeDescendant()),this._transformTracker.addListener(this._transformTrackerListener))}detachTransformTracker(){this._transformTracker&&(this._transformTracker.removeListener(this._transformTrackerListener),this._transformTracker.dispose(),this._transformTracker=null)}getDragBounds(){return this._dragBoundsProperty.value}get dragBounds(){return this.getDragBounds()}setTransform(t){this._transform=t}set transform(t){this.setTransform(t)}get transform(){return this.getTransform()}getTransform(){return this._transform}interrupt(){this.pointer&&this.pointer.isTouchLike()&&(this._lastInterruptedTouchLikePointer=this.pointer),super.interrupt()}canPress(t){return t.pointer!==this._lastInterruptedTouchLikePointer&&super.canPress(t)}dispose(){this._dragAction.dispose(),this.detachTransformTracker(),super.dispose()}static createForwardingListener(t,e){var i=w()({allowTouchSnag:!0},e);return{down(e){e.canStartPress()&&t(e)},touchenter(t){i.allowTouchSnag&&this.down(t)},touchmove(t){i.allowTouchSnag&&this.down(t)}}}});var rc=window.Float64Array||Array;class ac{constructor(t){var e,i,s=t.entries;this.n=t.getColumnDimension();var n=this.n;for(this.V=new rc(n*n),this.d=new rc(n),this.e=new rc(n),this.issymmetric=!0,i=0;i0?n[r*this.n+r+1]=i[r]:i[r]<0&&(n[r*this.n+r-1]=i[r])}return s}tred2(){var t,e,i,s,n,r,a=this.n,o=this.V,h=this.d,l=this.e;for(e=0;e0;t--){var d=0;for(r=0,i=0;i0&&(n=-n),l[t]=d*n,r-=s*n,h[t-1]=s-n,e=0;es){0;do{1,n=h[s],r=(h[s+1]-n)/(2*l[s]);var p=yc.hypot(r,1);r<0&&(p=-p),h[s]=l[s]/(r+p),h[s+1]=l[s]*(r+p);var g=h[s+1],v=n-h[s];for(t=s+2;t=s;t--)for(b=y,y=f,w=P,n=f*l[t],v=f*r,p=yc.hypot(r,l[t]),l[t+1]=P*p,P=l[t]/p,r=(f=r/p)*h[t]-P*n,h[t+1]=v+P*(f*n+P*h[t]),i=0;ic*u)}h[s]=h[s]+d,l[s]=0}for(t=0;t=i;t--)h[t]=o[t*r+(i-1)]/d,u+=h[t]*h[t];for(n=Math.sqrt(u),h[i]>0&&(n=-n),u-=h[i]*n,h[i]=h[i]-n,e=i;e=i;t--)s+=h[t]*o[t*this.n+e];for(s/=u,t=i;t<=l;t++)o[t*this.n+e]-=s*h[t]}for(t=0;t<=l;t++){for(s=0,e=l;e>=i;e--)s+=h[e]*o[t*this.n+e];for(s/=u,e=i;e<=l;e++)o[t*this.n+e]-=s*h[e]}h[i]=d*h[i],o[i*r+(i-1)]=d*n}}for(t=0;t=1;i--)if(0!==o[i*r+(i-1)]){for(t=i+1;t<=l;t++)h[t]=o[t*r+(i-1)];for(e=i;e<=l;e++){for(n=0,t=i;t<=l;t++)n+=h[t]*a[t*this.n+e];for(n=n/h[i]/o[i*r+(i-1)],t=i;t<=l;t++)a[t*this.n+e]+=n*h[t]}}}cdiv(t,e,i,s){var n,r;Math.abs(i)>Math.abs(s)?(r=i+(n=s/i)*s,this.cdivr=(t+n*e)/r,this.cdivi=(e-n*t)/r):(r=s+(n=i/s)*i,this.cdivr=(n*t+e)/r,this.cdivi=(n*e-t)/r)}hqr2(){var t,e,i,s,n,r,a,o=this.V,h=this.d,l=this.e,d=this.H,u=this.n;t=u-1;var c,m,p,g,v=u-1,f=Math.pow(2,-52),y=0,b=0,_=0,P=0,w=0,x=0,T=0;for(e=0;ev)&&(h[e]=d[e*t+e],l[e]=0),i=Math.max(e-1,0);i=0;){for(n=t;n>0&&(0===(w=Math.abs(d[(n-1)*t+(n-1)])+Math.abs(d[n*t+n]))&&(w=T),!(Math.abs(d[n*t+(n-1)])=0){for(x=b>=0?b+x:b-x,h[t-1]=p+x,h[t]=h[t-1],0!==x&&(h[t]=p-m/x),l[t-1]=0,l[t]=0,b=(p=d[t*t+t-1])/(w=Math.abs(p)+Math.abs(x)),_=x/w,b/=P=Math.sqrt(b*b+_*_),_/=P,i=t-1;i0){for(w=Math.sqrt(w),g=n&&(b=((P=p-(x=d[r*t+r]))*(w=g-x)-m)/d[(r+1)*t+r]+d[r*t+r+1],_=d[(r+1)*t+r+1]-x-P-w,P=d[(r+2)*t+r+1],b/=w=Math.abs(b)+Math.abs(_)+Math.abs(P),_/=w,P/=w,r!==n)&&!(Math.abs(d[r*t+(r-1)])*(Math.abs(_)+Math.abs(P))r+2&&(d[e*t+e-3]=0);for(s=r;s<=t-1;s++){var S=s!==t-1;if(s!==r&&(b=d[s*t+s-1],_=d[(s+1)*t+s-1],P=S?d[(s+2)*t+s-1]:0,0!==(p=Math.abs(b)+Math.abs(_)+Math.abs(P))&&(b/=p,_/=p,P/=p)),0===p)break;if(w=Math.sqrt(b*b+_*_+P*P),b<0&&(w=-w),0!==w){for(s!==r?d[s*t+s-1]=-w*p:n!==r&&(d[s*t+s-1]=-d[s*t+s-1]),p=(b+=w)/w,g=_/w,x=P/w,_/=b,P/=b,i=s;i=0;t--)if(b=h[t],0===(_=l[t]))for(n=t,d[t*t+t]=1,e=t-1;e>=0;e--){for(m=d[e*t+e]-b,P=0,i=n;i<=t;i++)P+=d[e*this.n+i]*d[i*t+t];if(l[e]<0)x=m,w=P;else if(n=e,0===l[e]?d[e*t+t]=0!==m?-P/m:-P/(f*T):(p=d[e*t+e+1],g=d[(e+1)*t+e],c=(p*w-x*P)/(_=(h[e]-b)*(h[e]-b)+l[e]*l[e]),d[e*t+t]=c,Math.abs(p)>Math.abs(x)?d[(e+1)*t+t]=(-P-m*c)/p:d[(e+1)*t+t]=(-w-g*c)/x),f*(c=Math.abs(d[e*t+t]))*c>1)for(i=e;i<=t;i++)d[i*t+t]=d[i*t+t]/c}else if(_<0)for(n=t-1,Math.abs(d[t*t+t-1])>Math.abs(d[(t-1)*t+t])?(d[(t-1)*t+(t-1)]=_/d[t*t+t-1],d[(t-1)*t+t]=-(d[t*t+t]-b)/d[t*t+t-1]):(this.cdiv(0,-d[(t-1)*t+t],d[(t-1)*t+(t-1)]-b,_),d[(t-1)*t+(t-1)]=this.cdivr,d[(t-1)*t+t]=this.cdivi),d[t*t+t-1]=0,d[t*t+t]=1,e=t-2;e>=0;e--){var A=void 0,E=void 0,C=void 0,D=void 0;for(A=0,E=0,i=n;i<=t;i++)A+=d[e*this.n+i]*d[i*t+t-1],E+=d[e*this.n+i]*d[i*t+t];if(m=d[e*t+e]-b,l[e]<0)x=m,P=A,w=E;else if(n=e,0===l[e]?(this.cdiv(-A,-E,m,_),d[e*t+t-1]=this.cdivr,d[e*t+t]=this.cdivi):(p=d[e*t+e+1],g=d[(e+1)*t+e],C=(h[e]-b)*(h[e]-b)+l[e]*l[e]-_*_,D=2*(h[e]-b)*_,0===C&&0===D&&(C=f*T*(Math.abs(m)+Math.abs(_)+Math.abs(p)+Math.abs(g)+Math.abs(x))),this.cdiv(p*P-x*A+_*E,p*w-x*E-_*A,C,D),d[e*t+t-1]=this.cdivr,d[e*t+t]=this.cdivi,Math.abs(p)>Math.abs(x)+Math.abs(_)?(d[(e+1)*t+t-1]=(-A-m*d[e*t+t-1]+_*d[e*t+t])/p,d[(e+1)*t+t]=(-E-m*d[e*t+t]-_*d[e*t+t-1])/p):(this.cdiv(-P-g*d[e*t+t-1],-w-g*d[e*t+t],x,_),d[(e+1)*t+t-1]=this.cdivr,d[(e+1)*t+t]=this.cdivi)),f*(c=Math.max(Math.abs(d[e*t+t-1]),Math.abs(d[e*t+t])))*c>1)for(i=e;i<=t;i++)d[i*t+t-1]=d[i*t+t-1]/c,d[i*t+t]=d[i*t+t]/c}for(e=0;ev)for(i=e;i=0;i--)for(e=0;e<=v;e++){for(x=0,s=0;s<=Math.min(i,v);s++)x+=o[e*t+s]*d[s*t+i];o[e*this.n+i]=x}}}}De.register("EigenvalueDecomposition",ac);var oc=window.Float64Array||Array;class hc{constructor(t){var e,i,s;this.matrix=t,this.LU=t.getArrayCopy();var n=this.LU;this.m=t.getRowDimension();var r=this.m;this.n=t.getColumnDimension();var a=this.n;for(this.piv=new Uint32Array(r),e=0;eMath.abs(o[d])&&(d=e);if(d!==i){for(s=0;si?this.LU[this.matrix.index(e,i)]:e===i?1:0;return t}getU(){for(var t=new yc(this.n,this.n),e=0;e=0;s--){for(i=0;i=i?this.QR[this.matrix.index(e,i)]:0;return t}getR(){for(var t=new yc(this.n,this.n),e=0;e=0;i--){for(t=0;t=0;s--){for(i=0;i=0;p--)if(0!==d[p]){for(m=p+1;m=0;p--){if(p0;){var I=void 0;if(E>500)break;for(p=S-2;p>=-1&&-1!==p;p--)if(h(_[p])<=D+C*(h(d[p])+h(d[p+1]))){_[p]=0;break}if(p===S-2)I=4;else{var L=void 0;for(L=S-1;L>=p&&L!==p;L--)if(g=(L!==S?h(_[L]):0)+(L!==p+1?h(_[L-1]):0),h(d[L])<=D+C*g){d[L]=0;break}L===p?I=3:L===S-1?I=1:(I=2,p=L)}switch(p++,I){case 1:for(v=_[S-2],_[S-2]=0,m=S-2;m>=p;m--)for(g=w(d[m],v),f=d[m]/g,y=v/g,d[m]=g,m!==p&&(v=-y*_[m-1],_[m-1]=f*_[m-1]),c=0;c=d[p+1]);){if(g=d[p],d[p]=d[p+1],d[p+1]=g,pe&&i++;return i}static pseudoinverse(t){var e=new pc(t),i=yc.diagonalMatrix(e.getSingularValues().map(t=>Math.abs(t)<1e-300?0:1/t));return e.getV().times(i).times(e.getU().transpose())}}De.register("SingularValueDecomposition",pc);var gc=pc,vc=window.Float64Array||Array;class fc{constructor(t,e,i,s){this.m=t,this.n=e;var n,r=t*e;if(this.size=r,s)this.entries=i;else if(i||(i=0),this.entries=new vc(r),Ti(i))for(n=0;nMath.abs(e)?(i=e/t,i=Math.abs(t)*Math.sqrt(1+i*i)):0!==e?(i=t/e,i=Math.abs(e)*Math.sqrt(1+i*i)):i=0,i}static identity(t,e){for(var i=new fc(t,e),s=0;s{this._targetNode.matrix=t}),this._interrupted=!1,this._pressListener={move:t=>{this.movePress(this.findPress(t.pointer))},up:t=>{this.removePress(this.findPress(t.pointer))},cancel:t=>{var e=this.findPress(t.pointer);e.interrupted=!0,this.removePress(e)},interrupt:()=>{this.interrupt()}},this._backgroundListener={up:t=>{this._interrupted||this.removeBackgroundPress(this.findBackgroundPress(t.pointer))},move:t=>{if(this.canMoveFromPointer(t.pointer)&&!this.anyBackgroundPressesWithDragIntent()&&this._allowMoveInterruption){var e=this.findBackgroundPress(t.pointer).initialPoint.minus(t.pointer.point),i=this._backgroundPresses.length<=1&&1===this.getCurrentScale();e.magnitude>25&&!i&&(this.interruptOtherListeners(t.pointer),this.convertBackgroundPresses(),this.movePress(this.findPress(t.pointer)))}},cancel:t=>{this._interrupted||this.removeBackgroundPress(this.findBackgroundPress(t.pointer))},interrupt:()=>{this.interrupt()}}}findPress(t){for(var e=0;ee.pointer===t.pointer)}anyBackgroundPressesWithDragIntent(){return _.some(this._backgroundPresses,t=>!this.canMoveFromPointer(t.pointer))}interruptOtherListeners(t){for(var e=t._listeners.slice(),i=0;it.localPoint),e=this._presses.map(t=>t.targetPoint),i=new Is(0,0),s=new Is(0,0);t.forEach(t=>{i.add(t)}),e.forEach(t=>{s.add(t)}),i.divideScalar(this._presses.length),s.divideScalar(this._presses.length);var n=0,r=0;t.forEach(t=>{n+=t.distanceSquared(i)}),e.forEach(t=>{r+=t.distanceSquared(s)});var a=this.getCurrentScale();0!==r&&(a=this.limitScale(Math.sqrt(r/n)));var o=wn.translation(s.x,s.y),h=wn.translation(-i.x,-i.y);return o.timesMatrix(wn.scaling(a)).timesMatrix(h)}limitScale(t){var e=Math.max(t,this._minScale);return e=Math.min(e,this._maxScale)}computeTranslationRotationMatrix(){var t,e=new yc(2,this._presses.length),i=new yc(2,this._presses.length),s=new Is(0,0),n=new Is(0,0);for(t=0;t{if(_.hasIn(window,"phet.joist.sim")&&phet.joist.sim.isSettingPhetioStateProperty.value){var t=xc.createRectangleMapping(this.sourceFramePanBoundsProperty.get(),this._panBounds),e=this._targetNode.matrix.translation.componentMultiply(t.matrix.getScaleVector()),i=this.matrixProperty.get().getScaleVector();this.matrixProperty.set(wn.translationFromVector(e).timesMatrix(wn.scaling(i.x,i.y)))}},{phetioDependencies:[this.matrixProperty]})}correctReposition(){Tc.set(this._targetNode.matrix);var t=this._targetBounds.transformed(this._targetNode.getMatrix());t.left>this._panBounds.left&&(this._targetNode.left=this._panBounds.left-(t.left-this._targetNode.left)),t.top>this._panBounds.top&&(this._targetNode.top=this._panBounds.top-(t.top-this._targetNode.top)),t.right{t.preventDefault(),this.trackpadGestureStartScale=t.scale,this.scaleGestureTargetPosition=new Is(t.pageX,t.pageY)},{phetioPlayback:!0,tandem:e.tandem.createTandem("gestureStartAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Action that executes whenever a gesture starts on a trackpad in macOS Safari."}),this.gestureChangeAction=new Kl(t=>{t.preventDefault();var e=this.sourceScale+t.scale-this.trackpadGestureStartScale;this.setDestinationScale(e)},{phetioPlayback:!0,tandem:e.tandem.createTandem("gestureChangeAction"),parameters:[{name:"event",phetioType:$n}],phetioEventType:ct.USER,phetioDocumentation:"Action that executes whenever a gesture changes on a trackpad in macOS Safari."}),Yi.safari&&!Yi.mobileSafari&&(i=this.handleGestureStartEvent.bind(this),s=this.handleGestureChangeEvent.bind(this),this.trackpadGestureStartScale=this.getCurrentScale(),window.addEventListener("gesturestart",i),window.addEventListener("gesturechange",s)),$l.keydownEmitter.addListener(this.windowKeydown.bind(this));var n=t=>{t&&this.getCurrentScale()>1&&this.keepTrailInView(t.trail)};Dd.pdomFocusProperty.link(n),this.sourceFramePanBoundsProperty.lazyLink(()=>{_.hasIn(window,"phet.joist.sim")&&phet.joist.sim.isSettingPhetioStateProperty.value&&(this.initializePositions(),this.sourceScale=this.getCurrentScale(),this.setDestinationScale(this.sourceScale))},{phetioDependencies:[this.matrixProperty]}),this.disposeAnimatedPanZoomListener=()=>{i&&window.removeEventListener("gesturestart",i),s&&window.removeEventListener("gestureChange",s),Dd.pdomFocusProperty.unlink(n)}}step(t){this.middlePress&&this.handleMiddlePress(t),this._attachedPointers.length>0&&this.getCurrentScale()>1&&(this._attachedPointers.length>0&&(this._attachedPointers=this._attachedPointers.filter(t=>t.attachedListener)),(this._draggingInDragBounds||this._attachedPointers.some(t=>t instanceof Nu))&&this.repositionDuringDrag()),this.animateToTargets(t)}down(t){Ac.prototype.down.call(this,t),null!==this._dragBounds&&t.pointer.hasIntent(Lu.DRAG)&&(0===this._attachedPointers.length&&(this._draggingInDragBounds=this._dragBounds.containsPoint(t.pointer.point)),t.pointer.attachedListener&&(this._attachedPointers.includes(t.pointer)||this._attachedPointers.push(t.pointer))),"mouse"===t.pointer.type&&t.pointer.middleDown&&!this.middlePress?(this.middlePress=new Oc(t.pointer,t.trail),t.pointer.cursor="all-scroll"):this.cancelMiddlePress()}cancelMiddlePress(){this.middlePress&&(this.middlePress.pointer.cursor=null,this.middlePress=null,this.stopInProgressAnimation())}movePress(t){this.middlePress||Ac.prototype.movePress.call(this,t)}move(t){if(this._attachedPointers.length>0&&this.getCurrentScale()>1)if(this._draggingInDragBounds){if(!this._attachedPointers.includes(t.pointer)){var e=this.hasDragIntent(t.pointer);null!==t.currentTarget&&e&&t.pointer.attachedListener&&this._attachedPointers.push(t.pointer)}}else this._draggingInDragBounds=this._dragBounds.containsPoint(t.pointer.point)}getGlobalBoundsToViewDuringDrag(){var t=null;if(this._attachedPointers.length>0){var e=this._attachedPointers[0].attachedListener;if(e.createPanTargetBounds)t=e.createPanTargetBounds();else if(e.listener instanceof ic||e.listener instanceof Hc){var i=e.listener;if(i.isPressed){var s=i.getCurrentTarget();1===s.instances.length&&(t=s.instances[0].trail.parentToGlobalBounds(s.visibleBounds))}}}return t}repositionDuringDrag(){var t=this.getGlobalBoundsToViewDuringDrag();t&&this.keepBoundsInView(t,this._attachedPointers.some(t=>t instanceof Nu))}cancelPanningDuringDrag(t){if(t){var e=this._attachedPointers.indexOf(t.pointer);e>-1&&this._attachedPointers.splice(e,1)}else this._attachedPointers=[];this._draggingInDragBounds=!1}up(t){this.cancelPanningDuringDrag(t)}wheel(t){if(!this.middlePress){var e=new Mc(t,this._targetScale);this.repositionFromWheel(e,t)}}windowKeydown(t){if(this.cancelMiddlePress(),(!phet.joist.display._accessible||!phet.joist.display.pdomRootElement.contains(t.target))&&(this.handleZoomCommands(t),qn.isArrowKey(t))){var e=new kc($l,this.getCurrentScale(),this._targetScale);this.repositionFromKeys(e)}}keydown(t){var e=t.domEvent;this.cancelMiddlePress(),this.handleZoomCommands(e);var i=t.pointer.hasIntent(Lu.KEYBOARD_DRAG);if(qn.isArrowKey(e)&&!i){var s=new kc($l,this.getCurrentScale(),this._targetScale);this.repositionFromKeys(s)}qn.isMovementKey(e)&&i&&t.pointer.isAttached()&&(this._attachedPointers.includes(t.pointer)||this._attachedPointers.push(t.pointer))}handleZoomCommands(t){var e=qd.isZoomCommand(t,!0),i=qd.isZoomCommand(t,!1);if(e||i){t.preventDefault();var s=this.getNextDiscreteScale(e),n=new kc($l,s,this._targetScale);this.repositionFromKeys(n)}else qd.isZoomResetCommand(t)&&(t.preventDefault(),this.resetTransform())}handleGestureStartEvent(t){this.gestureStartAction.execute(t)}handleGestureChangeEvent(t){this.gestureChangeAction.execute(t)}handleMiddlePress(t){if(t>0){var e=this.middlePress.pointer.point.minus(this.middlePress.initialPoint),i=e.magnitude/100;i>0&&(e.setMagnitude(Math.min(i/t,150*this._targetScale)),this.setDestinationPosition(this.sourcePosition.plus(e)))}}translateScaleToTarget(t,e){var i=this._targetNode.globalToLocalPoint(t),s=this._targetNode.globalToParentPoint(t),n=wn.translation(-i.x,-i.y),r=wn.translation(s.x,s.y),a=this.limitScale(this.getCurrentScale()+e),o=r.timesMatrix(wn.scaling(a)).timesMatrix(n);this.matrixProperty.set(o),this.correctReposition()}setTranslationScaleToTarget(t,e){var i=this._targetNode.globalToLocalPoint(t),s=this._targetNode.globalToParentPoint(t),n=wn.translation(-i.x,-i.y),r=wn.translation(s.x,s.y),a=this.limitScale(e),o=r.timesMatrix(wn.scaling(a)).timesMatrix(n);this.matrixProperty.set(o),this.correctReposition()}translateDelta(t){var e=this._targetNode.globalToParentPoint(this._panBounds.center),i=e.plus(t);this.translateToTarget(i,e)}translateToTarget(t,e){var i=this._targetNode.globalToParentPoint(t),s=this._targetNode.globalToParentPoint(e).minus(i);this.matrixProperty.set(wn.translationFromVector(s).timesMatrix(this._targetNode.getMatrix())),this.correctReposition()}repositionFromKeys(t){var e=t.scale;e!==this.getCurrentScale()?(this.setDestinationScale(e),this.scaleGestureTargetPosition=t.computeScaleTargetFromKeyPress()):t.translationVector.equals(Is.ZERO)||this.setDestinationPosition(this.sourcePosition.plus(t.translationVector)),this.correctReposition()}repositionFromWheel(t,e){if(e.domEvent.preventDefault(),t.isCtrlKeyDown){var i=this.limitScale(this.getCurrentScale()+t.scaleDelta);this.scaleGestureTargetPosition=t.targetPoint,this.setDestinationScale(i)}else this.setDestinationPosition(this.sourcePosition.plus(t.translationVector));this.correctReposition()}correctReposition(){super.correctReposition(),this._panBounds.isFinite()&&(this._transformedPanBounds=this._panBounds.transformed(this._targetNode.matrix.inverted()),this.sourcePosition=this._transformedPanBounds.center,this.sourceScale=this.getCurrentScale())}addPress(t){super.addPress(t),this.stopInProgressAnimation()}removePress(t){super.removePress(t),this.middlePress&&(t.pointer.cursor="all-scroll"),0===this._presses.length&&this.stopInProgressAnimation()}interrupt(){this.cancelPanningDuringDrag(),this.cancelMiddlePress(),super.interrupt()}cancel(){this.interrupt()}hasDragIntent(t){return t.hasIntent(Lu.KEYBOARD_DRAG)||t.hasIntent(Lu.DRAG)}panToNode(t){this.keepBoundsInView(t.globalBounds,!0)}keepBoundsInView(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this._targetNode.globalToLocalBounds(t),s=new Is(0,0),n=0,r=0,a=0,o=0;e?(n=this._transformedPanBounds.centerX-i.centerX,r=this._transformedPanBounds.centerX-i.centerX,a=this._transformedPanBounds.centerY-i.centerY,o=this._transformedPanBounds.centerY-i.centerY):i.width0&&(s.y=-a),r<0&&(s.x=-r),n>0&&(s.x=-n),this.setDestinationPosition(this.sourcePosition.plus(s))}keepTrailInView(t){if(this._panBounds.isFinite()&&t.lastNode().bounds.isFinite()){var e=t.localToGlobalBounds(t.lastNode().localBounds);this._panBounds.containsBounds(e)||this.keepBoundsInView(e,!0)}}animateToTargets(t){var e=!this.destinationPosition.equalsEpsilon(this.sourcePosition,.1),i=!Vs.equalsEpsilon(this.sourceScale,this.destinationScale,.001);if(0===this._presses.length||null!==this.middlePress){if(e){var s=this.destinationPosition.minus(this.sourcePosition),n=s;0!==s.magnitude&&(n=s.normalized());var r=this.getTranslationSpeed(s.magnitude);Dc.setXY(r,r);var a=Dc.multiplyScalar(t),o=n.componentTimes(a);o.magnitude>s.magnitude&&o.set(s),this.translateDelta(o)}if(i){var h=this.destinationScale-this.sourceScale,l=h*t*6;Math.abs(l)>Math.abs(h)&&(l=h),this.translateScaleToTarget(this.scaleGestureTargetPosition,l),this.setDestinationPosition(this.sourcePosition)}else this.destinationScale!==this.sourceScale&&(this.setTranslationScaleToTarget(this.scaleGestureTargetPosition,this.destinationScale),this.setDestinationPosition(this.sourcePosition))}}stopInProgressAnimation(){this.boundsFinite&&(this.setDestinationScale(this.sourceScale),this.setDestinationPosition(this.sourcePosition))}initializePositions(){this.boundsFinite=this._transformedPanBounds.isFinite(),this.boundsFinite?(this.sourcePosition=this._transformedPanBounds.center,this.setDestinationPosition(this.sourcePosition)):(this.sourcePosition=null,this.destinationPosition=null)}setPanBounds(t){super.setPanBounds(t),this.initializePositions(),this._dragBounds=t.erodedXY(.1*t.width,.1*t.height)}setTargetBounds(t){super.setTargetBounds(t),this.initializePositions()}setDestinationPosition(t){Ic.setMinMax(this.sourcePosition.x-this._transformedPanBounds.left-this._panBounds.left,this.sourcePosition.y-this._transformedPanBounds.top-this._panBounds.top,this.sourcePosition.x+this._panBounds.right-this._transformedPanBounds.right,this.sourcePosition.y+this._panBounds.bottom-this._transformedPanBounds.bottom),this.destinationPosition=Ic.closestPointTo(t)}setDestinationScale(t){this.destinationScale=this.limitScale(t)}getTranslationSpeed(t){var e=t*this.getCurrentScale(),i=e*(1/(Math.pow(e,2)-Math.pow(5,2))+5);return Math.min(Math.abs(i),1e3*this.getCurrentScale())}resetTransform(){super.resetTransform(),this.stopInProgressAnimation()}getNextDiscreteScale(t){for(var e,i=this.getCurrentScale(),s=Number.POSITIVE_INFINITY,n=0;n0?-.5:.5,this.targetPoint=t.pointer.point;var s=.5*i.deltaX,n=.5*i.deltaY;i.deltaMode===window.WheelEvent.DOM_DELTA_LINE&&(s*=25,n*=25),this.translationVector=Ec.setXY(s*e,n*e)}}class Oc{constructor(t,e){this.pointer=t,this.trail=e,this.initialPoint=t.point.copy()}}var Rc=(t,e)=>{for(var i=[],s=0;s<8;s++)i[s]=(e-t)/8*(s*s);for(var n=i[7],r=0;r0||e.shiftDragVelocity>0,this.moveOnHoldDelayCounter=0,this.moveOnHoldIntervalCounter=0,this.delayComplete=!1,this.dragStartAction=new Kl(t=>{var e=qn.getEventCode(t.domEvent);if(!this.movementKeysDown&&qn.isMovementKey(t.domEvent)&&(this._pointer=t.pointer,t.pointer.addInputListener(this._pointerListener,!0)),this.keyState.push({keyDown:!0,key:e,timeDown:0}),this._start&&this.movementKeysDown&&this._start(t),!this.useDragVelocity){var i=this.shiftKeyDown()?this._shiftDragDelta:this._dragDelta;this.updatePosition(i)}},{parameters:[{name:"event",phetioType:Bu.SceneryEventIO}],tandem:e.tandem.createTandem("dragStartAction"),phetioDocumentation:"Emits whenever a keyboard drag starts.",phetioReadOnly:e.phetioReadOnly,phetioEventType:ct.USER}),this.dragEmitter=new xe({tandem:e.tandem.createTandem("dragEmitter"),phetioHighFrequency:!0,phetioDocumentation:"Emits whenever a keyboard drag occurs.",phetioReadOnly:e.phetioReadOnly,phetioEventType:ct.USER}),this.dragEndAction=new Kl(t=>{this.movementKeysDown||(this._pointer.removeInputListener(this._pointerListener),this._pointer=null),this._end&&this._end(t)},{parameters:[{name:"event",phetioType:Bu.SceneryEventIO}],tandem:e.tandem.createTandem("dragEndAction"),phetioDocumentation:"Emits whenever a keyboard drag ends.",phetioReadOnly:e.phetioReadOnly,phetioEventType:ct.USER});var i=this.step.bind(this);ve.addListener(i),this.enabledProperty.lazyLink(this.onEnabledPropertyChange.bind(this)),this._pointerListener={listener:this,interrupt:this.interrupt.bind(this)},this._pointer=null,this._disposeKeyboardDragListener=()=>{ve.removeListener(i)}}getDragBounds(){return this._dragBoundsProperty.value}get dragBounds(){return this.getDragBounds()}setTransform(t){this._transform=t}set transform(t){this.setTransform(t)}get transform(){return this.getTransform()}getTransform(){return this._transform}get dragVelocity(){return this._dragVelocity}set dragVelocity(t){this._dragVelocity=t}get shiftDragVelocity(){return this._shiftDragVelocity}set shiftDragVelocity(t){this._shiftDragVelocity=t}get dragDelta(){return this._dragDelta}set dragDelta(t){this._dragDelta=t}get shiftDragDelta(){return this._shiftDragDelta}set shiftDragDelta(t){this._shiftDragDelta=t}get moveOnHoldDelay(){return this._moveOnHoldDelay}set moveOnHoldDelay(t){this._moveOnHoldDelay=t}get moveOnHoldInterval(){return this._moveOnHoldInterval}set moveOnHoldInterval(t){this._moveOnHoldInterval=t}get hotkeyHoldInterval(){return this._hotkeyHoldInterval}set hotkeyHoldInterval(t){this._hotkeyHoldInterval=t}get isPressed(){return!!this._pointer}getCurrentTarget(){return this._pointer.trail.lastNode()}onEnabledPropertyChange(t){!t&&this.interrupt()}keydown(t){var e=t.domEvent,i=qn.getEventCode(e);e.metaKey||(qn.isMovementKey(e)&&e.preventDefault(),t.pointer.reserveForKeyboardDrag(),this.keyInListDown([i])||(Yi.safari&&qn.isArrowKey(e)&&this.keyInListDown([qn.KEY_RIGHT_ARROW,qn.KEY_LEFT_ARROW,qn.KEY_UP_ARROW,qn.KEY_DOWN_ARROW])?this.interrupt():this.canDrag()&&this.dragStartAction.execute(t)))}keyup(t){var e=t.domEvent,i=qn.getEventCode(e),s=this.movementKeysDown;i===qn.KEY_TAB&&e.shiftKey&&this.keyState.push({keyDown:!0,key:qn.KEY_SHIFT_LEFT,timeDown:0});for(var n=0;n0){for(var i=0;i=this._moveOnHoldDelay&&!this.delayComplete&&(n=!0,this.delayComplete=!0),this.delayComplete&&this.moveOnHoldIntervalCounter>=this._moveOnHoldInterval&&(n=!0),s=n?this.shiftKeyDown()?this._shiftDragDelta:this._dragDelta:0}s>0&&this.updatePosition(s)}}canDrag(){return this.enabledProperty.value}updateHotkeys(){for(var t=0;te[a+1].timeDown&&(r=!0);r&&(this.currentHotkey=this._hotkeys[t],this.hotkeyHoldIntervalCounter>=this._hotkeyHoldInterval&&(this.hotkeyHoldIntervalCounter=0,this._hotkeys[t].callback()))}this.currentHotkey&&(this.keyInListDown(this.currentHotkey.keys)?this.hotkeyDisablingDragging=!0:(this.hotkeyDisablingDragging=!1,this.currentHotkey=null))}updatePosition(t){if(this.updateHotkeys(),!this.hotkeyDisablingDragging){var e=0,i=0;this.leftMovementKeysDown()&&(e=-t),this.rightMovementKeysDown()&&(e=t),this.upMovementKeysDown()&&(i=-t),this.downMovementKeysDown()&&(i=t);var s=new Is(e,i);if(!s.equals(Is.ZERO)){if(this._transform&&(s=this._transform.inverseDelta2(s)),this._positionProperty){var n=this._positionProperty.get().plus(s),r=this._dragBoundsProperty.value;r&&(n=r.closestPointTo(n)),n.equals(this._positionProperty.get())||this._positionProperty.set(n)}this._drag&&this._drag(s),this.dragEmitter.emit()}}this.moveOnHoldIntervalCounter=0}keyInListDown(t){for(var e=!1,i=0;ie.key===t[s]);if(!n||!n.keyDown)return i=!1,"break"},n=0;nclass extends t{constructor(){super(...arguments),this.spriteInstance=null}press(t,e,i){if(this.isPressed)return!1;if(this.spriteInstance=null,t.currentTarget instanceof gl){var s=t.currentTarget;this.spriteInstance=s.getSpriteInstanceFromPoint(s.globalToLocalPoint(t.pointer.point))}return!!this.spriteInstance&&super.press(t,e,i)}};bs.register("SpriteListenable",Yc);class zc{constructor(t){this._pointer=null,this.downPoint=null,this.downEvent=null,this.enabled=!1,this.lastPoint=null,this.currentPoint=null,this.velocity=null,this.swipeDistance=null,this.firstUp=!1,this.timeSinceLastDown=0,this.downPointers=[],this.holdingTime=0,this.focusedNode=null,this.handleEventListener={down:t=>{t.handle(),t.abort(),this.handleDown(t)}},t.pointerAddedEmitter.addListener(t=>{this.enabled&&t.addInputListener(this.handleEventListener,!0)}),this._attachedPointerListener={up:t=>{this.focusedNode&&this.focusedNode.swipeEnd&&this.focusedNode.swipeEnd.bind(this.focusedNode)(t,this),this.focusedNode=null,this._pointer.removeInputListener(this._attachedPointerListener),this._pointer=null},move:t=>{this.focusedNode&&this.focusedNode.swipeMove&&this.focusedNode.swipeMove.bind(this.focusedNode)(t,this)},interrupt:t=>{this.focusedNode=null,this._pointer.removeInputListener(this._attachedPointerListener),this._pointer=null},cancel:t=>{this.focusedNode=null,this._pointer.removeInputListener(this._attachedPointerListener),this._pointer=null}},this._pointerListener={up:t=>{this.endSwipe(),this._pointer=null,this.swipeDistance=t.pointer.point.minus(this.downPoint);var e=this.swipeDistance.y,i=this.swipeDistance.x;if(Math.abs(i)>100&&Math.abs(e)<100)if(i>0){if(Dd.pdomFocusedNode&&"Reset All"===Dd.pdomFocusedNode.innerContent)return;go.getNextFocusable(document.body).focus()}else go.getPreviousFocusable(document.body).focus();else if(this.firstUp){if(this.timeSinceLastDown<.6){this.firstUp=!1,this.timeSinceLastDown=0;var s=document.getElementsByClassName("a11y-pdom-root")[0];s&&s.contains(document.activeElement)&&document.activeElement.click()}}else this.firstUp=!0},move:t=>{this.lastPoint=this.currentPoint,this.currentPoint=t.pointer.point},interrupt:()=>{this.interrupt()},cancel:()=>{this.interrupt()}},ve.addListener(this.step.bind(this))}handleDown(t){t.pointer.addIntent(Lu.DRAG),this.downPointers.push(t.pointer),this.downPointers.length>1&&(this.downPointers.forEach(t=>t.removeIntent(Lu.DRAG)),t.pointer.removeIntent(Lu.DRAG)),t.pointer.removeInputListener(this.handleEventListener),null===this._pointer&&"touch"===t.pointer.type&&(this._pointer=t.pointer,t.pointer.addInputListener(this._pointerListener,!0),t.abort(),this.downEvent=t,this.downPoint=t.pointer.point,this.currentPoint=this.downPoint.copy(),this.previousPoint=this.currentPoint.copy())}up(t){var e=this.downPointers.indexOf(t.pointer);e>-1&&this.downPointers.splice(e,1)}step(t){if(this.firstUp&&(this.timeSinceLastDown+=t,this.timeSinceLastDown>.6&&(this.firstUp=!1,this.timeSinceLastDown=0)),this._pointer&&!this._pointer.listeners.includes(this._attachedPointerListener))if(this.holdingTime>.75){var e=Dd.pdomFocusedNode;e&&(this._pointer.removeInputListener(this._pointerListener),this.holdingTime=0,this.focusedNode=e,this._pointer.addInputListener(this._attachedPointerListener,!0),this.focusedNode.swipeStart&&this.focusedNode.swipeStart(this.downEvent,this),this.downEvent=null)}else this.holdingTime+=t;null!==this.lastPoint&&null!==this.currentPoint&&(this.velocity=this.lastPoint.minus(this.currentPoint).dividedScalar(t))}endSwipe(){this.holdingTime=0,this._pointer&&this._pointer.listeners.includes(this._pointerListener)&&this._pointer.removeInputListener(this._pointerListener)}detachPointerListener(){this._pointer.detach(this._attachedPointerListener)}interrupt(){this.endSwipe(),this._pointer=null,this.downEvent=null}}bs.register("SwipeListener",zc);var Wc=["left","right","center","origin"],Uc=["top","bottom","center","origin"];class Gc extends it{constructor(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.POSITIVE_INFINITY;super(),this.horizontal=t,this.vertical=e,this.padRatio=i}static getAllowedAligns(t){return[...t===Li.HORIZONTAL?Wc:Uc,null]}static alignToInternal(t,e){return t===Li.HORIZONTAL?Gc.horizontalAlignToInternal(e):Gc.verticalAlignToInternal(e)}static horizontalAlignToInternal(t){return null===t?null:Xc[t]}static verticalAlignToInternal(t){return null===t?null:jc[t]}static internalToAlign(t,e){return null===e?null:t===Li.HORIZONTAL?e.horizontal:e.vertical}}_defineProperty(Gc,"START",new Gc("left","top",0)),_defineProperty(Gc,"END",new Gc("right","bottom",1)),_defineProperty(Gc,"CENTER",new Gc("center","center",.5)),_defineProperty(Gc,"ORIGIN",new Gc("origin","origin")),_defineProperty(Gc,"enumeration",new at(Gc,{phetioDocumentation:"Alignment for layout containers"}));var Xc={left:Gc.START,right:Gc.END,center:Gc.CENTER,origin:Gc.ORIGIN},jc={top:Gc.START,bottom:Gc.END,center:Gc.CENTER,origin:Gc.ORIGIN};bs.register("LayoutAlign",Gc);var qc=["left","right","center","spaceBetween","spaceAround","spaceEvenly"],Kc=["top","bottom","center","spaceBetween","spaceAround","spaceEvenly"];class Zc extends it{constructor(t,e,i){super(),this.spacingFunctionFactory=t,this.horizontal=e,this.vertical=i}static getAllowedJustificationValues(t){return t===Li.HORIZONTAL?qc:Kc}static justifyToInternal(t,e){return t===Li.HORIZONTAL?Qc[e]:Jc[e]}static internalToJustify(t,e){return t===Li.HORIZONTAL?e.horizontal:e.vertical}}_defineProperty(Zc,"START",new Zc(()=>()=>0,"left","top")),_defineProperty(Zc,"END",new Zc(t=>e=>0===e?t:0,"right","bottom")),_defineProperty(Zc,"CENTER",new Zc(t=>e=>0===e?t/2:0,"center","center")),_defineProperty(Zc,"SPACE_BETWEEN",new Zc((t,e)=>i=>0!==i?t/(e-1):0,"spaceBetween","spaceBetween")),_defineProperty(Zc,"SPACE_AROUND",new Zc((t,e)=>i=>(0!==i?2:1)*t/(2*e),"spaceAround","spaceAround")),_defineProperty(Zc,"SPACE_EVENLY",new Zc((t,e)=>i=>t/(e+1),"spaceEvenly","spaceEvenly")),_defineProperty(Zc,"enumeration",new at(Zc,{phetioDocumentation:"Justify for layout containers"}));var Qc={left:Zc.START,right:Zc.END,center:Zc.CENTER,spaceBetween:Zc.SPACE_BETWEEN,spaceAround:Zc.SPACE_AROUND,spaceEvenly:Zc.SPACE_EVENLY},Jc={top:Zc.START,bottom:Zc.END,center:Zc.CENTER,spaceBetween:Zc.SPACE_BETWEEN,spaceAround:Zc.SPACE_AROUND,spaceEvenly:Zc.SPACE_EVENLY};bs.register("LayoutJustification",Zc);class $c extends cl{constructor(t){super(w()({layoutOptions:{stretch:!0},stroke:"rgb(100,100,100)"},t))}}bs.register("Divider",$c);class tm extends(Ih($c)){constructor(t){super(),this.localPreferredHeightProperty.link(t=>{null!==t&&(this.y2=t)}),this.mutate(t)}}bs.register("HDivider",tm);class em extends(Sh($c)){constructor(t){super(),this.localPreferredWidthProperty.link(t=>{null!==t&&(this.x2=t)}),this.mutate(t)}}bs.register("VDivider",em);class im{constructor(t){this.initialize(t)}initialize(t){this.trail=t}checkPreconditions(){}get node(){return this.trail.lastNode()}get bounds(){return this.trail.parentToGlobalBounds(this.node.bounds)}get visibleBounds(){return this.trail.parentToGlobalBounds(this.node.visibleBounds)}get width(){return this.bounds.width}get height(){return this.bounds.height}get x(){return this.trail.getParentTransform().transformX(this.node.x)}set x(t){this.node.x=this.trail.getParentTransform().inverseX(t)}get y(){return this.trail.getParentTransform().transformY(this.node.y)}set y(t){this.node.y=this.trail.getParentTransform().inverseY(t)}get translation(){return this.trail.getParentTransform().transformPosition2(this.node.translation)}set translation(t){this.node.translation=this.trail.getParentTransform().inversePosition2(t)}get left(){return this.trail.getParentTransform().transformX(this.node.left)}set left(t){this.node.left=this.trail.getParentTransform().inverseX(t)}get right(){return this.trail.getParentTransform().transformX(this.node.right)}set right(t){this.node.right=this.trail.getParentTransform().inverseX(t)}get centerX(){return this.trail.getParentTransform().transformX(this.node.centerX)}set centerX(t){this.node.centerX=this.trail.getParentTransform().inverseX(t)}get top(){return this.trail.getParentTransform().transformY(this.node.top)}set top(t){this.node.top=this.trail.getParentTransform().inverseY(t)}get bottom(){return this.trail.getParentTransform().transformY(this.node.bottom)}set bottom(t){this.node.bottom=this.trail.getParentTransform().inverseY(t)}get centerY(){return this.trail.getParentTransform().transformY(this.node.centerY)}set centerY(t){this.node.centerY=this.trail.getParentTransform().inverseY(t)}get leftTop(){return this.trail.getParentTransform().transformPosition2(this.node.leftTop)}set leftTop(t){this.node.leftTop=this.trail.getParentTransform().inversePosition2(t)}get centerTop(){return this.trail.getParentTransform().transformPosition2(this.node.centerTop)}set centerTop(t){this.node.centerTop=this.trail.getParentTransform().inversePosition2(t)}get rightTop(){return this.trail.getParentTransform().transformPosition2(this.node.rightTop)}set rightTop(t){this.node.rightTop=this.trail.getParentTransform().inversePosition2(t)}get leftCenter(){return this.trail.getParentTransform().transformPosition2(this.node.leftCenter)}set leftCenter(t){this.node.leftCenter=this.trail.getParentTransform().inversePosition2(t)}get center(){return this.trail.getParentTransform().transformPosition2(this.node.center)}set center(t){this.node.center=this.trail.getParentTransform().inversePosition2(t)}get rightCenter(){return this.trail.getParentTransform().transformPosition2(this.node.rightCenter)}set rightCenter(t){this.node.rightCenter=this.trail.getParentTransform().inversePosition2(t)}get leftBottom(){return this.trail.getParentTransform().transformPosition2(this.node.leftBottom)}set leftBottom(t){this.node.leftBottom=this.trail.getParentTransform().inversePosition2(t)}get centerBottom(){return this.trail.getParentTransform().transformPosition2(this.node.centerBottom)}set centerBottom(t){this.node.centerBottom=this.trail.getParentTransform().inversePosition2(t)}get rightBottom(){return this.trail.getParentTransform().transformPosition2(this.node.rightBottom)}set rightBottom(t){this.node.rightBottom=this.trail.getParentTransform().inversePosition2(t)}get widthSizable(){return this.node.widthSizable}get heightSizable(){return this.node.heightSizable}get preferredWidth(){var t=this.node.preferredWidth;return null===t?null:Math.abs(this.trail.getParentTransform().transformDeltaX(t))}set preferredWidth(t){this.node.preferredWidth=null===t?null:Math.abs(this.trail.getParentTransform().inverseDeltaX(t))}get preferredHeight(){var t=this.node.preferredHeight;return null===t?null:Math.abs(this.trail.getParentTransform().transformDeltaY(t))}set preferredHeight(t){this.node.preferredHeight=null===t?null:Math.abs(this.trail.getParentTransform().inverseDeltaY(t))}get minimumWidth(){var t=xh(this.node)?this.node.minimumWidth||0:this.node.width;return Math.abs(this.trail.getParentTransform().transformDeltaX(t))}get minimumHeight(){var t=Ch(this.node)?this.node.minimumHeight||0:this.node.height;return Math.abs(this.trail.getParentTransform().transformDeltaY(t))}getMinimum(t){return t===Li.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maxWidth(){return null===this.node.maxWidth?null:Math.abs(this.trail.getParentTransform().transformDeltaX(this.node.maxWidth))}set maxWidth(t){this.node.maxWidth=null===t?null:Math.abs(this.trail.getParentTransform().inverseDeltaX(t))}get maxHeight(){return null===this.node.maxHeight?null:Math.abs(this.trail.getParentTransform().transformDeltaY(this.node.maxHeight))}set maxHeight(t){this.node.maxHeight=null===t?null:Math.abs(this.trail.getParentTransform().inverseDeltaY(t))}getMax(t){return t===Li.HORIZONTAL?this.maxWidth:this.maxHeight}get visible(){return this.node.visible}set visible(t){this.node.visible=t}dispose(){this.trail=null,this.freeToPool()}freeToPool(){im.pool.freeToPool(this)}}_defineProperty(im,"pool",new zi(im,{maxSize:1e3})),bs.register("LayoutProxy",im);class sm extends qe{constructor(t,e){var i=new Fh(t,e);super([i],t=>1===t.length?im.pool.create(t[0].copy().removeAncestor()):null,{tandem:Ct.OPT_OUT}),this.trailsBetweenProperty=i,this.lazyLink((t,e)=>{e&&e.dispose()})}dispose(){this.trailsBetweenProperty.dispose(),super.dispose()}}bs.register("LayoutProxyProperty",sm);class nm extends sm{constructor(t,e,i){super(t,e),_defineProperty(this,"transformTracker",null),this.link(e=>{this.transformTracker&&(this.transformTracker.dispose(),this.transformTracker=null),e&&(this.transformTracker=new Bl(e.trail.copy().addAncestor(t)),this.transformTracker.addListener(i))})}dispose(){this.transformTracker&&this.transformTracker.dispose(),super.dispose()}}bs.register("TrackingLayoutProxyProperty",nm);class rm{constructor(t){_defineProperty(this,"_layoutLockCount",0),_defineProperty(this,"_layoutAttemptDuringLock",!1),_defineProperty(this,"_enabled",!0),_defineProperty(this,"_listenedNodes",new Set),_defineProperty(this,"finishedLayoutEmitter",new c),this.ancestorNode=t,this._updateLayoutListener=this.updateLayoutAutomatically.bind(this)}addNode(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&(t._activeParentLayoutConstraint=this),t.boundsProperty.lazyLink(this._updateLayoutListener),t.visibleProperty.lazyLink(this._updateLayoutListener),Th(t)&&(t.minimumWidthProperty.lazyLink(this._updateLayoutListener),t.isWidthResizableProperty.lazyLink(this._updateLayoutListener)),Dh(t)&&(t.minimumHeightProperty.lazyLink(this._updateLayoutListener),t.isHeightResizableProperty.lazyLink(this._updateLayoutListener)),this._listenedNodes.add(t)}removeNode(t){t._activeParentLayoutConstraint===this&&(t._activeParentLayoutConstraint=null),t.boundsProperty.unlink(this._updateLayoutListener),t.visibleProperty.unlink(this._updateLayoutListener),Th(t)&&(t.minimumWidthProperty.unlink(this._updateLayoutListener),t.isWidthResizableProperty.unlink(this._updateLayoutListener)),Dh(t)&&(t.minimumHeightProperty.unlink(this._updateLayoutListener),t.isHeightResizableProperty.unlink(this._updateLayoutListener)),this._listenedNodes.delete(t)}layout(){}get isLocked(){return this._layoutLockCount>0}lock(){this._layoutLockCount++}unlock(){this._layoutLockCount--}validateLocalPreferredWidth(t){0}validateLocalPreferredHeight(t){0}validateLocalPreferredSize(t){0}updateLayout(){if(this.isLocked)this._layoutAttemptDuringLock=!0;else{this.lock();do{this._layoutAttemptDuringLock=!1,this.layout()}while(this._layoutAttemptDuringLock);this.unlock()}}updateLayoutAutomatically(){this._enabled&&this.updateLayout()}createLayoutProxy(t){var e=t.getTrails(t=>t===this.ancestorNode);return 1===e.length?im.pool.create(e[0].removeAncestor()):null}get enabled(){return this._enabled}set enabled(t){this._enabled!==t&&(this._enabled=t,this.updateLayoutAutomatically())}dispose(){for(var t=[...this._listenedNodes.keys()],e=0;et.updateLayoutAutomatically()),this.layoutProxyProperty.link(e=>{this._proxy=e,t.updateLayoutAutomatically()})),this._constraint=t,this._node=e,this.layoutOptionsListener=this.onLayoutOptionsChange.bind(this),this.node.layoutOptionsChangedEmitter.addListener(this.layoutOptionsListener)}onLayoutOptionsChange(){}get node(){return this._node}isConnected(){return null!==this._proxy}get proxy(){return this._proxy}isSizable(t){return t===Li.HORIZONTAL?this.proxy.widthSizable:this.proxy.heightSizable}dispose(){this.layoutProxyProperty&&this.layoutProxyProperty.dispose(),this.node.layoutOptionsChangedEmitter.removeListener(this.layoutOptionsListener)}}bs.register("LayoutCell",am);class om extends am{constructor(t,e,i){super(t,e,i),_defineProperty(this,"preferredSizeSet",new Mi(!1,!1)),_defineProperty(this,"lastAvailableBounds",mn.NOTHING.copy()),_defineProperty(this,"lastUsedBounds",mn.NOTHING.copy()),this._marginConstraint=t}reposition(t,e,i,s,n,r){var a=s&&this.isSizable(t)?e:this.getMinimumSize(t);this.attemptPreferredSize(t,a),r===Gc.ORIGIN?this.positionOrigin(t,i+n):this.positionStart(t,i+(e-this.getCellBounds()[t.size])*r.padRatio);var o=this.getCellBounds();return this.lastAvailableBounds[t.minCoordinate]=i,this.lastAvailableBounds[t.maxCoordinate]=i+e,this.lastUsedBounds.set(o),o}get effectiveLeftMargin(){return null!==this._leftMargin?this._leftMargin:this._marginConstraint._leftMargin}get effectiveRightMargin(){return null!==this._rightMargin?this._rightMargin:this._marginConstraint._rightMargin}get effectiveTopMargin(){return null!==this._topMargin?this._topMargin:this._marginConstraint._topMargin}get effectiveBottomMargin(){return null!==this._bottomMargin?this._bottomMargin:this._marginConstraint._bottomMargin}getEffectiveMinMargin(t){return t===Li.HORIZONTAL?this.effectiveLeftMargin:this.effectiveTopMargin}getEffectiveMaxMargin(t){return t===Li.HORIZONTAL?this.effectiveRightMargin:this.effectiveBottomMargin}get effectiveMinContentWidth(){return null!==this._minContentWidth?this._minContentWidth:this._marginConstraint._minContentWidth}get effectiveMinContentHeight(){return null!==this._minContentHeight?this._minContentHeight:this._marginConstraint._minContentHeight}getEffectiveMinContent(t){return t===Li.HORIZONTAL?this.effectiveMinContentWidth:this.effectiveMinContentHeight}get effectiveMaxContentWidth(){return null!==this._maxContentWidth?this._maxContentWidth:this._marginConstraint._maxContentWidth}get effectiveMaxContentHeight(){return null!==this._maxContentHeight?this._maxContentHeight:this._marginConstraint._maxContentHeight}getEffectiveMaxContent(t){return t===Li.HORIZONTAL?this.effectiveMaxContentWidth:this.effectiveMaxContentHeight}getMinimumSize(t){return this.getEffectiveMinMargin(t)+Math.max(this.proxy.getMinimum(t),this.getEffectiveMinContent(t)||0)+this.getEffectiveMaxMargin(t)}getMaximumSize(t){return this.getEffectiveMinMargin(t)+(this.getEffectiveMaxContent(t)||Number.POSITIVE_INFINITY)+this.getEffectiveMaxMargin(t)}attemptPreferredSize(t,e){if(this.proxy[t.sizable]){var i=this.getMinimumSize(t),s=this.getMaximumSize(t),n=(e=Vs.clamp(e,i,s))-this.getEffectiveMinMargin(t)-this.getEffectiveMaxMargin(t),r=this.proxy.getMax(t);null!==r&&(n=Math.min(r,n)),this._marginConstraint.setProxyPreferredSize(t,this.proxy,n),this.preferredSizeSet.set(t,!0)}}unsetPreferredSize(t){this.proxy[t.sizable]&&this._marginConstraint.setProxyPreferredSize(t,this.proxy,null)}positionStart(t,e){var i=this.getEffectiveMinMargin(t)+e;this._marginConstraint.setProxyMinSide(t,this.proxy,i)}positionOrigin(t,e){this._marginConstraint.setProxyOrigin(t,this.proxy,e)}getOriginBounds(){return this.getCellBounds().shiftedXY(-this.proxy.x,-this.proxy.y)}getCellBounds(){return this.proxy.bounds.withOffsets(this.effectiveLeftMargin,this.effectiveTopMargin,this.effectiveRightMargin,this.effectiveBottomMargin)}dispose(){Li.enumeration.values.forEach(t=>{this.preferredSizeSet.get(t)&&this.unsetPreferredSize(t)}),super.dispose()}static createHelperNode(t,e,i){var s=new uh,n=aa.union(t.map(t=>aa.bounds(t.lastAvailableBounds))),r=aa.union(t.map(t=>aa.bounds(t.lastUsedBounds))),a=aa.union(t.map(t=>aa.bounds(t.proxy.bounds))),o=aa.bounds(e).shapeDifference(n),h=n.shapeDifference(r),l=r.shapeDifference(a),d=(t,e,i)=>{var s=new rl(t,{font:new nn({size:6,family:"monospace"}),fill:e}),n=pl.bounds(s.bounds,{fill:i,children:[s]});return new Co(n,4,Math.floor(n.left),Math.ceil(n.top+1),Math.floor(n.width),Math.floor(n.height-2),wn.rotation2(-Math.PI/4))};return s.addChild(new sl(o,{fill:d("spacing","#000","#fff"),opacity:.6})),s.addChild(new sl(h,{fill:d("empty","#aaa","#000"),opacity:.6})),s.addChild(new sl(l,{fill:d("margin","#600","#f00"),opacity:.6})),s.addChild(pl.bounds(e,{stroke:"white",lineDash:[2,2],lineDashOffset:2,lineWidth:.4})),s.addChild(pl.bounds(e,{stroke:"black",lineDash:[2,2],lineWidth:.4})),t.forEach(t=>{s.addChild(pl.bounds(t.getCellBounds(),{stroke:"rgba(0,255,0,1)",lineWidth:.4}))}),t.forEach(t=>{s.addChild(pl.bounds(t.proxy.bounds,{stroke:"rgba(255,0,0,1)",lineWidth:.4}))}),t.forEach(t=>{var e=t.getCellBounds(),n=new ic;s.addChild(pl.bounds(e,{inputListeners:[n]}));var r=i(t);t.effectiveLeftMargin&&(r+="leftMargin: ".concat(t.effectiveLeftMargin,"\n")),t.effectiveRightMargin&&(r+="rightMargin: ".concat(t.effectiveRightMargin,"\n")),t.effectiveTopMargin&&(r+="topMargin: ".concat(t.effectiveTopMargin,"\n")),t.effectiveBottomMargin&&(r+="bottomMargin: ".concat(t.effectiveBottomMargin,"\n")),t.effectiveMinContentWidth&&(r+="minContentWidth: ".concat(t.effectiveMinContentWidth,"\n")),t.effectiveMinContentHeight&&(r+="minContentHeight: ".concat(t.effectiveMinContentHeight,"\n")),t.effectiveMaxContentWidth&&(r+="maxContentWidth: ".concat(t.effectiveMaxContentWidth,"\n")),t.effectiveMaxContentHeight&&(r+="maxContentHeight: ".concat(t.effectiveMaxContentHeight,"\n")),r+="layoutOptions: ".concat(JSON.stringify(t.node.layoutOptions,null,2).replace(/ /g," "),"\n");var a=new ip(r.trim().replace(/\n/g,"
    "),{font:new nn({size:12})}),o=pl.bounds(a.bounds.dilated(3),{fill:"rgba(255,255,255,0.8)",children:[a],leftTop:e.leftTop});s.addChild(o),n.isOverProperty.link(t=>{o.visible=t})}),s}}bs.register("MarginLayoutCell",om);class hm extends me{constructor(t,e){var i=w()({valueType:Is,validBounds:null,validators:[],phetioValueType:Is.Vector2IO},e);i.validBounds&&i.validators.push({validationMessage:"Vector2 is not within validBounds",isValidValue:t=>i.validBounds.containsPoint(t)}),super(t,i),this.validBounds=i.validBounds}}De.register("Vector2Property",hm);var lm=hm,dm=["resize","layoutOrigin"];class um extends(Oh(uh)){constructor(t){super(),_defineProperty(this,"layoutOriginProperty",new lm(Is.ZERO)),this.mutate(t)}linkLayoutBounds(){this._constraint.layoutBoundsProperty.link(t=>{this.localBounds=t})}setExcludeInvisibleChildrenFromBounds(t){super.setExcludeInvisibleChildrenFromBounds(t),this._constraint.excludeInvisible=t}setChildren(t){if(this.constraint.isLocked)return super.setChildren(t);var e=this.getChildren();return this.constraint.lock(),super.setChildren(t),this.constraint.unlock(),_.isEqual(e,t)||this.constraint.updateLayoutAutomatically(),this}updateLayout(){this._constraint.updateLayout()}get resize(){return this._constraint.enabled}set resize(t){this._constraint.enabled=t}get layoutOrigin(){return this.layoutOriginProperty.value}set layoutOrigin(t){this.layoutOriginProperty.value=t}get constraint(){return this._constraint}dispose(){this._constraint.dispose(),super.dispose()}}bs.register("LayoutNode",um);class cm{initializeLayoutLine(){this.min=0,this.max=Number.POSITIVE_INFINITY,this.minOrigin=Number.POSITIVE_INFINITY,this.maxOrigin=Number.NEGATIVE_INFINITY,this.size=0,this.position=0}hasOrigin(){return isFinite(this.minOrigin)&&isFinite(this.maxOrigin)}}bs.register("LayoutLine",cm);class mm extends rm{constructor(t,e){var i=w()({preferredWidthProperty:new ae(null),preferredHeightProperty:new ae(null),minimumWidthProperty:new ae(null),minimumHeightProperty:new ae(null),layoutOriginProperty:new ae(Is.ZERO)},e);super(t),_defineProperty(this,"_excludeInvisible",!0),this.layoutBoundsProperty=new me(mn.NOTHING,{useDeepEquality:!0,tandem:Ct.OPT_OUT}),this.preferredWidthProperty=i.preferredWidthProperty,this.preferredHeightProperty=i.preferredHeightProperty,this.minimumWidthProperty=i.minimumWidthProperty,this.minimumHeightProperty=i.minimumHeightProperty,this.layoutOriginProperty=i.layoutOriginProperty,this.preferredWidthProperty.lazyLink(this._updateLayoutListener),this.preferredHeightProperty.lazyLink(this._updateLayoutListener),this.layoutOriginProperty.lazyLink(this._updateLayoutListener)}get excludeInvisible(){return this._excludeInvisible}set excludeInvisible(t){this._excludeInvisible!==t&&(this._excludeInvisible=t,this.updateLayoutAutomatically())}setProxyPreferredSize(t,e,i){e[t.preferredSize]=i}setProxyMinSide(t,e,i){Math.abs(e[t.minSide]-i)>1e-9&&(e[t.minSide]=i)}setProxyOrigin(t,e,i){Math.abs(e[t.coordinate]-i)>1e-9&&(e[t.coordinate]=i)}dispose(){this.preferredWidthProperty.unlink(this._updateLayoutListener),this.preferredHeightProperty.unlink(this._updateLayoutListener),this.layoutOriginProperty.unlink(this._updateLayoutListener),super.dispose()}}bs.register("NodeLayoutConstraint",mm);var pm=["orientation","align","stretch","grow","margin","xMargin","yMargin","leftMargin","rightMargin","topMargin","bottomMargin","minContentWidth","minContentHeight","maxContentWidth","maxContentHeight"],gm=Ei(t=>class extends t{constructor(){super(...arguments),_defineProperty(this,"_orientation",Li.HORIZONTAL),_defineProperty(this,"_align",null),_defineProperty(this,"_stretch",null),_defineProperty(this,"_leftMargin",null),_defineProperty(this,"_rightMargin",null),_defineProperty(this,"_topMargin",null),_defineProperty(this,"_bottomMargin",null),_defineProperty(this,"_grow",null),_defineProperty(this,"_minContentWidth",null),_defineProperty(this,"_minContentHeight",null),_defineProperty(this,"_maxContentWidth",null),_defineProperty(this,"_maxContentHeight",null),_defineProperty(this,"changedEmitter",new c),_defineProperty(this,"orientationChangedEmitter",new c)}mutateConfigurable(t){Y(t,["margin"],["xMargin","yMargin"]),Y(t,["xMargin"],["leftMargin","rightMargin"]),Y(t,["yMargin"],["topMargin","bottomMargin"]),Di(this,pm,t)}setConfigToBaseDefault(){this._align=Gc.CENTER,this._stretch=!1,this._leftMargin=0,this._rightMargin=0,this._topMargin=0,this._bottomMargin=0,this._grow=0,this._minContentWidth=null,this._minContentHeight=null,this._maxContentWidth=null,this._maxContentHeight=null,this.changedEmitter.emit()}setConfigToInherit(){this._align=null,this._stretch=null,this._leftMargin=null,this._rightMargin=null,this._topMargin=null,this._bottomMargin=null,this._grow=null,this._minContentWidth=null,this._minContentHeight=null,this._maxContentWidth=null,this._maxContentHeight=null,this.changedEmitter.emit()}get orientation(){return this._orientation===Li.HORIZONTAL?"horizontal":"vertical"}set orientation(t){var e="horizontal"===t?Li.HORIZONTAL:Li.VERTICAL;this._orientation!==e&&(this._orientation=e,this.orientationChangedEmitter.emit(),this.changedEmitter.emit())}get align(){var t=Gc.internalToAlign(this._orientation,this._align);return t}set align(t){var e=Gc.alignToInternal(this._orientation.opposite,t);this._align!==e&&(this._align=e,this.changedEmitter.emit())}get stretch(){return this._stretch}set stretch(t){this._stretch!==t&&(this._stretch=t,this.changedEmitter.emit())}get leftMargin(){return this._leftMargin}set leftMargin(t){this._leftMargin!==t&&(this._leftMargin=t,this.changedEmitter.emit())}get rightMargin(){return this._rightMargin}set rightMargin(t){this._rightMargin!==t&&(this._rightMargin=t,this.changedEmitter.emit())}get topMargin(){return this._topMargin}set topMargin(t){this._topMargin!==t&&(this._topMargin=t,this.changedEmitter.emit())}get bottomMargin(){return this._bottomMargin}set bottomMargin(t){this._bottomMargin!==t&&(this._bottomMargin=t,this.changedEmitter.emit())}get grow(){return this._grow}set grow(t){this._grow!==t&&(this._grow=t,this.changedEmitter.emit())}get xMargin(){return this._leftMargin}set xMargin(t){this._leftMargin===t&&this._rightMargin===t||(this._leftMargin=t,this._rightMargin=t,this.changedEmitter.emit())}get yMargin(){return this._topMargin}set yMargin(t){this._topMargin===t&&this._bottomMargin===t||(this._topMargin=t,this._bottomMargin=t,this.changedEmitter.emit())}get margin(){return this._topMargin}set margin(t){this._leftMargin===t&&this._rightMargin===t&&this._topMargin===t&&this._bottomMargin===t||(this._leftMargin=t,this._rightMargin=t,this._topMargin=t,this._bottomMargin=t,this.changedEmitter.emit())}get minContentWidth(){return this._minContentWidth}set minContentWidth(t){this._minContentWidth!==t&&(this._minContentWidth=t,this.changedEmitter.emit())}get minContentHeight(){return this._minContentHeight}set minContentHeight(t){this._minContentHeight!==t&&(this._minContentHeight=t,this.changedEmitter.emit())}get maxContentWidth(){return this._maxContentWidth}set maxContentWidth(t){this._maxContentWidth!==t&&(this._maxContentWidth=t,this.changedEmitter.emit())}get maxContentHeight(){return this._maxContentHeight}set maxContentHeight(t){this._maxContentHeight!==t&&(this._maxContentHeight=t,this.changedEmitter.emit())}});bs.register("FlowConfigurable",gm);var vm=gm;class fm extends(vm(om)){constructor(t,e,i){super(t,e,i),_defineProperty(this,"size",0),this.flowConstraint=t,this.orientation=t.orientation,this.onLayoutOptionsChange()}get effectiveAlign(){return null!==this._align?this._align:this.flowConstraint._align}get effectiveStretch(){return null!==this._stretch?this._stretch:this.flowConstraint._stretch}get effectiveGrow(){return null!==this._grow?this._grow:this.flowConstraint._grow}onLayoutOptionsChange(){this.node.layoutOptions&&this.setOptions(this.node.layoutOptions),super.onLayoutOptionsChange()}setOptions(t){this.setConfigToInherit(),this.mutateConfigurable(t)}}bs.register("FlowCell",fm);class ym extends cm{constructor(t,e){super(),this.initialize(t,e)}initialize(t,e){this.orientation=t,this.cells=e,this.initializeLayoutLine()}getMinimumSize(t){return(this.cells.length-1)*t+_.sum(this.cells.map(t=>t.getMinimumSize(this.orientation)))}freeToPool(){ym.pool.freeToPool(this)}}_defineProperty(ym,"pool",new zi(ym,{defaultArguments:[Li.HORIZONTAL,[]]})),bs.register("FlowLine",ym);var bm=[...pm,"spacing","lineSpacing","justify","justifyLines","wrap","excludeInvisible"];class _m extends(vm(mm)){constructor(t,e){super(t,e),_defineProperty(this,"cells",[]),_defineProperty(this,"_justify",Zc.SPACE_BETWEEN),_defineProperty(this,"_justifyLines",null),_defineProperty(this,"_wrap",!1),_defineProperty(this,"_spacing",0),_defineProperty(this,"_lineSpacing",0),_defineProperty(this,"displayedCells",[]),this.setConfigToBaseDefault(),this.mutateConfigurable(e),Di(this,bm,e),this.changedEmitter.addListener(this._updateLayoutListener),this.orientationChangedEmitter.addListener(()=>this.cells.forEach(t=>{t.orientation=this.orientation}))}layout(){super.layout();for(var t=this._orientation,e=this._orientation.opposite,i=0;ii;r--){var a=this.cells[r];a.node instanceof $c?(a.node.visible=n,n=!1):a.node.visible&&(n=!0)}var o=this.cells.filter(t=>t.isConnected()&&t.proxy.bounds.isValid()&&(!this.excludeInvisible||t.node.visible));if(this.displayedCells=o,!o.length)return this.layoutBoundsProperty.value=mn.NOTHING,this.minimumWidthProperty.value=null,void(this.minimumHeightProperty.value=null);var h=this.getPreferredProperty(t).value,l=this.getPreferredProperty(e).value,d=Math.max(...o.map(e=>e.getMinimumSize(t)||0));d>(h||Number.POSITIVE_INFINITY)&&(h=d);var u=[];if(this.wrap){for(var c=[],m=h||Number.POSITIVE_INFINITY;o.length;){var p=o.shift(),g=p.getMinimumSize(t);0===c.length?(c.push(p),m-=g):this.spacing+g<=m+1e-7?(c.push(p),m-=this.spacing+g):(u.push(ym.pool.create(t,c)),m=h||Number.POSITIVE_INFINITY,c=[p],m-=g)}c.length&&u.push(ym.pool.create(t,c))}else u.push(ym.pool.create(t,o));u.forEach(t=>{t.cells.forEach(i=>{if(t.min=Math.max(t.min,i.getMinimumSize(e)),t.max=Math.min(t.max,i.getMaximumSize(e)),i.effectiveAlign===Gc.ORIGIN){var s=i.getOriginBounds();t.minOrigin=Math.min(s[e.minCoordinate],t.minOrigin),t.maxOrigin=Math.max(s[e.maxCoordinate],t.maxOrigin)}}),isFinite(t.minOrigin)&&isFinite(t.maxOrigin)?t.size=Math.max(t.min,t.maxOrigin-t.minOrigin):t.size=t.min});var v=Math.max(...u.map(t=>t.getMinimumSize(this.spacing))),f=_.sum(u.map(t=>t.size))+(u.length-1)*this.lineSpacing,y=this.wrap?d:v,b=Math.max(v,h||0),P=Math.max(f,l||0),w=this.layoutOriginProperty.value[t.coordinate],x=this.layoutOriginProperty.value[t.opposite.coordinate];u.forEach(e=>{var i,s=_.sum(e.cells.map(e=>e.getMinimumSize(t))),n=this.spacing*(e.cells.length-1),r=b-s-n;e.cells.forEach(e=>{e.size=e.getMinimumSize(t)});for(var a=function(){var e=_.sum(i.map(t=>t.effectiveGrow)),s=Math.min(Math.min(...i.map(e=>(e.getMaximumSize(t)-e.size)/e.effectiveGrow)),r/e);i.forEach(t=>{t.size+=s*t.effectiveGrow}),r-=s*e};r>1e-7&&(i=e.cells.filter(e=>0!==e.effectiveGrow&&e.sizee.attemptPreferredSize(t,e.size));var o=this._justify.spacingFunctionFactory(r,e.cells.length),h=w;e.cells.forEach((e,i)=>{h+=o(i),i>0&&(h+=this.spacing),e.positionStart(t,h),e.lastAvailableBounds[t.minCoordinate]=h,e.lastAvailableBounds[t.maxCoordinate]=h+e.size,h+=e.size})});var T=P-f,S=(u[0].hasOrigin()?u[0].minOrigin:0)+x,A=S;if(null===this._justifyLines)u.forEach(t=>{t.size+=T/u.length}),u.forEach(t=>{t.position=A,A+=t.size+this.lineSpacing});else{var E=this._justifyLines.spacingFunctionFactory(T,u.length);u.forEach((t,e)=>{A+=E(e),t.position=A,A+=t.size+this.lineSpacing})}u.forEach(t=>t.cells.forEach(i=>{i.reposition(e,t.size,t.position,i.effectiveStretch,-t.minOrigin,i.effectiveAlign)}));var C=w,D=w+b,I=S,L=S+P;this.layoutBoundsProperty.value=mn.oriented(t,C,I,D,L),this.minimumWidthProperty.value=t===Li.HORIZONTAL?y:f,this.minimumHeightProperty.value=t===Li.HORIZONTAL?f:y,this.finishedLayoutEmitter.emit(),u.forEach(t=>t.freeToPool())}get justify(){var t=Zc.internalToJustify(this._orientation,this._justify);return t}set justify(t){var e=Zc.justifyToInternal(this._orientation,t);this._justify!==e&&(this._justify=e,this.updateLayoutAutomatically())}get justifyLines(){if(null===this._justifyLines)return null;var t=Zc.internalToJustify(this._orientation,this._justifyLines);return t}set justifyLines(t){var e=null===t?null:Zc.justifyToInternal(this._orientation.opposite,t);this._justifyLines!==e&&(this._justifyLines=e,this.updateLayoutAutomatically())}get wrap(){return this._wrap}set wrap(t){this._wrap!==t&&(this._wrap=t,this.updateLayoutAutomatically())}get spacing(){return this._spacing}set spacing(t){this._spacing!==t&&(this._spacing=t,this.updateLayoutAutomatically())}get lineSpacing(){return this._lineSpacing}set lineSpacing(t){this._lineSpacing!==t&&(this._lineSpacing=t,this.updateLayoutAutomatically())}insertCell(t,e){e.orientation=this.orientation,this.cells.splice(t,0,e),this.addNode(e.node),e.changedEmitter.addListener(this._updateLayoutListener),this.updateLayoutAutomatically()}removeCell(t){tt(this.cells,t),this.removeNode(t.node),t.changedEmitter.removeListener(this._updateLayoutListener),this.updateLayoutAutomatically()}reorderCells(t,e,i){this.cells.splice(e,i-e+1,...t),this.updateLayoutAutomatically()}getPreferredProperty(t){return t===Li.HORIZONTAL?this.preferredWidthProperty:this.preferredHeightProperty}dispose(){this.lock(),this.cells.forEach(t=>this.removeCell(t)),this.displayedCells=[],super.dispose(),this.unlock()}static create(t,e){return new _m(t,e)}}bs.register("FlowConstraint",_m);var Pm=[...dm,...bm.filter(t=>"excludeInvisible"!==t)],wm={orientation:"horizontal",spacing:0,align:"center",stretch:!1};class xm extends um{constructor(t){var e=w()({excludeInvisibleChildrenFromBounds:!0,resize:!0,disabledOpacity:Ps.DISABLED_OPACITY},t);super(),_defineProperty(this,"_cellMap",new Map),this._constraint=new _m(this,{preferredWidthProperty:this.localPreferredWidthProperty,preferredHeightProperty:this.localPreferredHeightProperty,minimumWidthProperty:this.localMinimumWidthProperty,minimumHeightProperty:this.localMinimumHeightProperty,layoutOriginProperty:this.layoutOriginProperty,orientation:wm.orientation,spacing:wm.spacing,align:wm.align,stretch:wm.stretch,excludeInvisible:!1}),this.onChildInserted=this.onFlowBoxChildInserted.bind(this),this.onChildRemoved=this.onFlowBoxChildRemoved.bind(this),this.onChildrenReordered=this.onFlowBoxChildrenReordered.bind(this),this.onChildrenChanged=this.onFlowBoxChildrenChanged.bind(this),this.childInsertedEmitter.addListener(this.onChildInserted),this.childRemovedEmitter.addListener(this.onChildRemoved),this.childrenReorderedEmitter.addListener(this.onChildrenReordered),this.childrenChangedEmitter.addListener(this.onChildrenChanged);var i=_.omit(e,oh),s=_.pick(e,oh);this._constraint.lock(),this.mutate(i),this._constraint.unlock(),this._constraint.updateLayout(),this.mutate(s),this.linkLayoutBounds()}onFlowBoxChildInserted(t,e){var i=new fm(this._constraint,t,this._constraint.createLayoutProxy(t));this._cellMap.set(t,i),this._constraint.insertCell(e,i)}onFlowBoxChildRemoved(t){var e=this._cellMap.get(t);this._cellMap.delete(t),this._constraint.removeCell(e),e.dispose()}onFlowBoxChildrenReordered(t,e){this._constraint.reorderCells(this._children.slice(t,e+1).map(t=>this._cellMap.get(t)),t,e)}onFlowBoxChildrenChanged(){this._constraint.updateLayoutAutomatically()}getCell(t){var e=this._cellMap.get(t);return e}get orientation(){return this._constraint.orientation}set orientation(t){this._constraint.orientation=t}get spacing(){return this._constraint.spacing}set spacing(t){this._constraint.spacing=t}get lineSpacing(){return this._constraint.lineSpacing}set lineSpacing(t){this._constraint.lineSpacing=t}get justify(){return this._constraint.justify}set justify(t){this._constraint.justify=t}get justifyLines(){return this._constraint.justifyLines}set justifyLines(t){this._constraint.justifyLines=t}get wrap(){return this._constraint.wrap}set wrap(t){this._constraint.wrap=t}get align(){return this._constraint.align}set align(t){this._constraint.align=t}get stretch(){return this._constraint.stretch}set stretch(t){this._constraint.stretch=t}get grow(){return this._constraint.grow}set grow(t){this._constraint.grow=t}get margin(){return this._constraint.margin}set margin(t){this._constraint.margin=t}get xMargin(){return this._constraint.xMargin}set xMargin(t){this._constraint.xMargin=t}get yMargin(){return this._constraint.yMargin}set yMargin(t){this._constraint.yMargin=t}get leftMargin(){return this._constraint.leftMargin}set leftMargin(t){this._constraint.leftMargin=t}get rightMargin(){return this._constraint.rightMargin}set rightMargin(t){this._constraint.rightMargin=t}get topMargin(){return this._constraint.topMargin}set topMargin(t){this._constraint.topMargin=t}get bottomMargin(){return this._constraint.bottomMargin}set bottomMargin(t){this._constraint.bottomMargin=t}get minContentWidth(){return this._constraint.minContentWidth}set minContentWidth(t){this._constraint.minContentWidth=t}get minContentHeight(){return this._constraint.minContentHeight}set minContentHeight(t){this._constraint.minContentHeight=t}get maxContentWidth(){return this._constraint.maxContentWidth}set maxContentWidth(t){this._constraint.maxContentWidth=t}get maxContentHeight(){return this._constraint.maxContentHeight}set maxContentHeight(t){this._constraint.maxContentHeight=t}dispose(){for(var t of(this._constraint.lock(),this.childInsertedEmitter.removeListener(this.onChildInserted),this.childRemovedEmitter.removeListener(this.onChildRemoved),this.childrenReorderedEmitter.removeListener(this.onChildrenReordered),this.childrenChangedEmitter.removeListener(this.onChildrenChanged),this._cellMap.values()))t.dispose();super.dispose()}setOrientation(t){return this.orientation=t,this}getOrientation(){return this.orientation}setSpacing(t){return this.spacing=t,this}getSpacing(){return this.spacing}setAlign(t){return this.align=t,this}getAlign(){return this.align}setResize(t){return this.resize=t,this}isResize(){return this.resize}getHelperNode(){return om.createHelperNode(this.constraint.displayedCells,this.constraint.layoutBoundsProperty.value,t=>{var e="",i="horizontal"===t.orientation?Li.HORIZONTAL:Li.VERTICAL;return e+="align: ".concat(Gc.internalToAlign(i,t.effectiveAlign),"\n"),e+="stretch: ".concat(t.effectiveStretch,"\n"),e+="grow: ".concat(t.effectiveGrow,"\n")})}}_defineProperty(xm,"DEFAULT_FLOW_BOX_OPTIONS",wm),xm.prototype._mutatorKeys=[...kh,...Pm,...uh.prototype._mutatorKeys],bs.register("FlowBox",xm);var Tm=["xAlign","yAlign","stretch","xStretch","yStretch","grow","xGrow","yGrow","margin","xMargin","yMargin","leftMargin","rightMargin","topMargin","bottomMargin","minContentWidth","minContentHeight","maxContentWidth","maxContentHeight"],Sm=Ei(t=>class extends t{constructor(){super(...arguments),_defineProperty(this,"_xAlign",null),_defineProperty(this,"_yAlign",null),_defineProperty(this,"_xStretch",null),_defineProperty(this,"_yStretch",null),_defineProperty(this,"_leftMargin",null),_defineProperty(this,"_rightMargin",null),_defineProperty(this,"_topMargin",null),_defineProperty(this,"_bottomMargin",null),_defineProperty(this,"_xGrow",null),_defineProperty(this,"_yGrow",null),_defineProperty(this,"_minContentWidth",null),_defineProperty(this,"_minContentHeight",null),_defineProperty(this,"_maxContentWidth",null),_defineProperty(this,"_maxContentHeight",null),_defineProperty(this,"changedEmitter",new c)}mutateConfigurable(t){Y(t,["stretch"],["xStretch","yStretch"]),Y(t,["grow"],["xGrow","yGrow"]),Y(t,["margin"],["xMargin","yMargin"]),Y(t,["xMargin"],["leftMargin","rightMargin"]),Y(t,["yMargin"],["topMargin","bottomMargin"]),Di(this,Tm,t)}setConfigToBaseDefault(){this._xAlign=Gc.CENTER,this._yAlign=Gc.CENTER,this._xStretch=!1,this._yStretch=!1,this._leftMargin=0,this._rightMargin=0,this._topMargin=0,this._bottomMargin=0,this._xGrow=0,this._yGrow=0,this._minContentWidth=null,this._minContentHeight=null,this._maxContentWidth=null,this._maxContentHeight=null,this.changedEmitter.emit()}setConfigToInherit(){this._xAlign=null,this._yAlign=null,this._xStretch=null,this._yStretch=null,this._leftMargin=null,this._rightMargin=null,this._topMargin=null,this._bottomMargin=null,this._xGrow=null,this._yGrow=null,this._minContentWidth=null,this._minContentHeight=null,this._maxContentWidth=null,this._maxContentHeight=null,this.changedEmitter.emit()}get xAlign(){var t=null===this._xAlign?null:this._xAlign.horizontal;return t}set xAlign(t){var e=Gc.horizontalAlignToInternal(t);this._xAlign!==e&&(this._xAlign=e,this.changedEmitter.emit())}get yAlign(){var t=null===this._yAlign?null:this._yAlign.vertical;return t}set yAlign(t){var e=Gc.verticalAlignToInternal(t);this._yAlign!==e&&(this._yAlign=e,this.changedEmitter.emit())}get leftMargin(){return this._leftMargin}set leftMargin(t){this._leftMargin!==t&&(this._leftMargin=t,this.changedEmitter.emit())}get rightMargin(){return this._rightMargin}set rightMargin(t){this._rightMargin!==t&&(this._rightMargin=t,this.changedEmitter.emit())}get topMargin(){return this._topMargin}set topMargin(t){this._topMargin!==t&&(this._topMargin=t,this.changedEmitter.emit())}get bottomMargin(){return this._bottomMargin}set bottomMargin(t){this._bottomMargin!==t&&(this._bottomMargin=t,this.changedEmitter.emit())}get grow(){return this._xGrow}set grow(t){this._xGrow===t&&this._yGrow===t||(this._xGrow=t,this._yGrow=t,this.changedEmitter.emit())}get xGrow(){return this._xGrow}set xGrow(t){this._xGrow!==t&&(this._xGrow=t,this.changedEmitter.emit())}get yGrow(){return this._yGrow}set yGrow(t){this._yGrow!==t&&(this._yGrow=t,this.changedEmitter.emit())}get stretch(){return this._xStretch}set stretch(t){this._xStretch===t&&this._yStretch===t||(this._xStretch=t,this._yStretch=t,this.changedEmitter.emit())}get xStretch(){return this._xStretch}set xStretch(t){this._xStretch!==t&&(this._xStretch=t,this.changedEmitter.emit())}get yStretch(){return this._yStretch}set yStretch(t){this._yStretch!==t&&(this._yStretch=t,this.changedEmitter.emit())}get xMargin(){return this._leftMargin}set xMargin(t){this._leftMargin===t&&this._rightMargin===t||(this._leftMargin=t,this._rightMargin=t,this.changedEmitter.emit())}get yMargin(){return this._topMargin}set yMargin(t){this._topMargin===t&&this._bottomMargin===t||(this._topMargin=t,this._bottomMargin=t,this.changedEmitter.emit())}get margin(){return this._topMargin}set margin(t){this._leftMargin===t&&this._rightMargin===t&&this._topMargin===t&&this._bottomMargin===t||(this._leftMargin=t,this._rightMargin=t,this._topMargin=t,this._bottomMargin=t,this.changedEmitter.emit())}get minContentWidth(){return this._minContentWidth}set minContentWidth(t){this._minContentWidth!==t&&(this._minContentWidth=t,this.changedEmitter.emit())}get minContentHeight(){return this._minContentHeight}set minContentHeight(t){this._minContentHeight!==t&&(this._minContentHeight=t,this.changedEmitter.emit())}get maxContentWidth(){return this._maxContentWidth}set maxContentWidth(t){this._maxContentWidth!==t&&(this._maxContentWidth=t,this.changedEmitter.emit())}get maxContentHeight(){return this._maxContentHeight}set maxContentHeight(t){this._maxContentHeight!==t&&(this._maxContentHeight=t,this.changedEmitter.emit())}});bs.register("GridConfigurable",Sm);var Am=Sm;class Em extends(Am(om)){constructor(t,e,i){super(t,e,i),this.gridConstraint=t,this.setOptions(e.layoutOptions),this.onLayoutOptionsChange()}get effectiveXAlign(){return null!==this._xAlign?this._xAlign:this.gridConstraint._xAlign}get effectiveYAlign(){return null!==this._yAlign?this._yAlign:this.gridConstraint._yAlign}getEffectiveAlign(t){return t===Li.HORIZONTAL?this.effectiveXAlign:this.effectiveYAlign}get effectiveXGrow(){return null!==this._xGrow?this._xGrow:this.gridConstraint._xGrow}get effectiveYGrow(){return null!==this._yGrow?this._yGrow:this.gridConstraint._yGrow}getEffectiveGrow(t){return t===Li.HORIZONTAL?this.effectiveXGrow:this.effectiveYGrow}get effectiveXStretch(){return null!==this._xStretch?this._xStretch:this.gridConstraint._xStretch}get effectiveYStretch(){return null!==this._yStretch?this._yStretch:this.gridConstraint._yStretch}getEffectiveStretch(t){return t===Li.HORIZONTAL?this.effectiveXStretch:this.effectiveYStretch}onLayoutOptionsChange(){this.setOptions(this.node.layoutOptions),super.onLayoutOptionsChange()}setOptions(t){var e=w()({column:0,row:0,width:1,height:1},t);this.setConfigToInherit(),this.position=new Mi(e.column,e.row),this.size=new Mi(e.width,e.height),this.mutateConfigurable(e)}containsIndex(t,e){var i=this.position.get(t),s=this.size.get(t);return e>=i&&et.isConnected()&&t.proxy.bounds.isValid()&&(!this.excludeInvisible||t.node.visible));if(this.displayedCells=t,!t.length)return this.layoutBoundsProperty.value=mn.NOTHING,this.minimumWidthProperty.value=null,this.minimumHeightProperty.value=null,void this.displayedLines.forEach(t=>t.clear());var e=new Mi(0,0),i=new Mi(this.preferredWidthProperty.value,this.preferredHeightProperty.value),s=new mn(0,0,0,0);[Li.HORIZONTAL,Li.VERTICAL].forEach(n=>{var r=this._spacing.get(n),a=this.displayedLines.get(n);a.forEach(t=>t.freeToPool()),a.clear();var o=_.sortedUniq(_.sortBy(_.flatten(t.map(t=>t.getIndices(n))))).map(e=>{var i=_.filter(t,t=>t.containsIndex(n,e)),s=Math.max(...i.map(t=>t.getEffectiveGrow(n))),r=Cm.pool.create(e,i,s);return a.set(e,r),r}),h=o.slice(0,-1).map(t=>"number"==typeof r?r:r[t.index]);t.forEach(t=>{if(1===t.size.get(n)){var e=a.get(t.position.get(n));if(e.min=Math.max(e.min,t.getMinimumSize(n)),e.max=Math.min(e.max,t.getMaximumSize(n)),t.getEffectiveAlign(n)===Gc.ORIGIN){var i=t.getOriginBounds();e.minOrigin=Math.min(i[n.minCoordinate],e.minOrigin),e.maxOrigin=Math.max(i[n.maxCoordinate],e.maxOrigin)}}}),t.forEach(t=>{if(t.size.get(n)>1){var e=t.getIndices(n).map(t=>a.get(t)),i=_.sum(e.map(t=>t.min)),s=t.getMinimumSize(n);if(s>i){var r=(s-i)/e.length;e.forEach(t=>{t.min+=r})}}}),o.forEach(t=>{t.hasOrigin()?t.size=Math.max(t.min,t.maxOrigin-t.minOrigin):t.size=t.min});var l=_.sum(o.map(t=>t.size))+_.sum(h);e.set(n,l);for(var d,u=Math.max(l,i.get(n)||0),c=u-l,m=function(){var t=_.sum(d.map(t=>t.grow)),e=Math.min(Math.min(...d.map(t=>(t.max-t.size)/t.grow)),c/t);d.forEach(t=>{t.size+=e*t.grow}),c-=e*t};c>1e-7&&(d=o.filter(t=>t.grow>0&&t.size{var i=_.sum(o.slice(0,e).map(t=>t.size)),s=_.sum(h.slice(0,e));t.position=p+i+s}),t.forEach(t=>{var e=t.position.get(n),i=t.size.get(n),r=e+i-1,l=t.getIndices(n).map(t=>a.get(t)),d=a.get(e),u=0;e!==r&&o.slice(0,-1).forEach((t,i)=>{t.index>=e&&t.indext.size))+u,m=d.position,p=t.reposition(n,c,m,t.getEffectiveStretch(n),-d.minOrigin,t.getEffectiveAlign(n));s[n.minCoordinate]=Math.min(s[n.minCoordinate],p[n.minCoordinate]),s[n.maxCoordinate]=Math.max(s[n.maxCoordinate],p[n.maxCoordinate])})}),this.layoutBoundsProperty.value=s,this.minimumWidthProperty.value=e.horizontal,this.minimumHeightProperty.value=e.vertical,this.finishedLayoutEmitter.emit()}get spacing(){return this.xSpacing}set spacing(t){this._spacing.get(Li.HORIZONTAL)===t&&this._spacing.get(Li.VERTICAL)===t||(this._spacing.set(Li.HORIZONTAL,t),this._spacing.set(Li.VERTICAL,t),this.updateLayoutAutomatically())}get xSpacing(){return this._spacing.get(Li.HORIZONTAL)}set xSpacing(t){this._spacing.get(Li.HORIZONTAL)!==t&&(this._spacing.set(Li.HORIZONTAL,t),this.updateLayoutAutomatically())}get ySpacing(){return this._spacing.get(Li.VERTICAL)}set ySpacing(t){this._spacing.get(Li.VERTICAL)!==t&&(this._spacing.set(Li.VERTICAL,t),this.updateLayoutAutomatically())}addCell(t){this.cells.add(t),this.addNode(t.node),t.changedEmitter.addListener(this._updateLayoutListener),this.updateLayoutAutomatically()}removeCell(t){this.cells.delete(t),this.removeNode(t.node),t.changedEmitter.removeListener(this._updateLayoutListener),this.updateLayoutAutomatically()}dispose(){this.lock(),[...this.cells].forEach(t=>this.removeCell(t)),this.displayedLines.forEach(t=>t.clear()),this.displayedCells=[],super.dispose(),this.unlock()}getIndices(t){var e=[];return this.cells.forEach(i=>{e.push(...i.getIndices(t))}),_.sortedUniq(_.sortBy(e))}getCell(t,e){return _.find([...this.cells],i=>i.containsRow(t)&&i.containsColumn(e))||null}getCellFromNode(t){return _.find([...this.cells],e=>e.node===t)||null}getCells(t,e){return _.filter([...this.cells],i=>i.containsIndex(t,e))}static create(t,e){return new Im(t,e)}}bs.register("GridConstraint",Im);var Lm=[...dm,...Dm.filter(t=>"excludeInvisible"!==t),"rows","columns","autoRows","autoColumns"];class km extends um{constructor(t){var e=w()({excludeInvisibleChildrenFromBounds:!0,resize:!0},t);super(),_defineProperty(this,"_cellMap",new Map),_defineProperty(this,"_autoRows",null),_defineProperty(this,"_autoColumns",null),_defineProperty(this,"_autoLockCount",0),this._constraint=new Im(this,{preferredWidthProperty:this.localPreferredWidthProperty,preferredHeightProperty:this.localPreferredHeightProperty,minimumWidthProperty:this.localMinimumWidthProperty,minimumHeightProperty:this.localMinimumHeightProperty,layoutOriginProperty:this.layoutOriginProperty,excludeInvisible:!1}),this.onChildInserted=this.onGridBoxChildInserted.bind(this),this.onChildRemoved=this.onGridBoxChildRemoved.bind(this),this.onChildVisibilityToggled=this.updateAllAutoLines.bind(this),this.childInsertedEmitter.addListener(this.onChildInserted),this.childRemovedEmitter.addListener(this.onChildRemoved);var i=_.omit(e,oh),s=_.pick(e,oh);this._constraint.lock(),this.mutate(i),this._constraint.unlock(),this._constraint.updateLayout(),this.mutate(s),this.linkLayoutBounds()}setLines(t,e){for(var i=[],s=0;st.node)}getNodesInColumn(t){return this.constraint.getCells(Li.HORIZONTAL,t).map(t=>t.node)}addRow(t){return this.rows=[...this.rows,t],this}addColumn(t){return this.columns=[...this.columns,t],this}insertRow(t,e){return this.rows=[...this.rows.slice(0,t),e,...this.rows.slice(t)],this}insertColumn(t,e){return this.columns=[...this.columns.slice(0,t),e,...this.columns.slice(t)],this}removeRow(t){return this.rows=[...this.rows.slice(0,t),...this.rows.slice(t+1)],this}removeColumn(t){return this.columns=[...this.columns.slice(0,t),...this.columns.slice(t+1)],this}set autoRows(t){this._autoRows!==t&&(this._autoRows=t,this.updateAutoRows())}get autoRows(){return this._autoRows}set autoColumns(t){this._autoColumns!==t&&(this._autoColumns=t,this.updateAutoColumns())}get autoColumns(){return this._autoColumns}updateAutoLines(t,e){if(null!==e&&0===this._autoLockCount){var i=0;this.constraint.lock(),this.children.filter(t=>t.bounds.isValid()&&(!this._constraint.excludeInvisible||t.visible)).forEach((s,n)=>{var r=n%e,a=Math.floor(n/e);s.layoutOptions&&s.layoutOptions[t.line]===r&&s.layoutOptions[t.opposite.line]===a&&1===s.layoutOptions.width&&1===s.layoutOptions.height||(i++,s.mutateLayoutOptions({[t.line]:n%e,[t.opposite.line]:Math.floor(n/e),width:1,height:1}))}),this.constraint.unlock(),i>0&&this.constraint.updateLayoutAutomatically()}}updateAutoRows(){this.updateAutoLines(Li.VERTICAL,this.autoRows)}updateAutoColumns(){this.updateAutoLines(Li.HORIZONTAL,this.autoColumns)}updateAllAutoLines(){this.updateAutoRows(),this.updateAutoColumns()}setChildren(t){var e=this.getChildren();return this._autoLockCount++,super.setChildren(t),this._autoLockCount--,_.isEqual(e,t)||this.updateAllAutoLines(),this}onGridBoxChildInserted(t,e){t.visibleProperty.lazyLink(this.onChildVisibilityToggled);var i=new Em(this._constraint,t,this._constraint.createLayoutProxy(t));this._cellMap.set(t,i),this._constraint.addCell(i),this.updateAllAutoLines()}onGridBoxChildRemoved(t){var e=this._cellMap.get(t);this._cellMap.delete(t),this._constraint.removeCell(e),e.dispose(),this.updateAllAutoLines(),t.visibleProperty.unlink(this.onChildVisibilityToggled)}mutate(t){return Y(t,["rows"],["columns"],["children","autoRows","autoColumns"]),super.mutate(t)}get spacing(){return this._constraint.spacing}set spacing(t){this._constraint.spacing=t}get xSpacing(){return this._constraint.xSpacing}set xSpacing(t){this._constraint.xSpacing=t}get ySpacing(){return this._constraint.ySpacing}set ySpacing(t){this._constraint.ySpacing=t}get xAlign(){return this._constraint.xAlign}set xAlign(t){this._constraint.xAlign=t}get yAlign(){return this._constraint.yAlign}set yAlign(t){this._constraint.yAlign=t}get grow(){return this._constraint.grow}set grow(t){this._constraint.grow=t}get xGrow(){return this._constraint.xGrow}set xGrow(t){this._constraint.xGrow=t}get yGrow(){return this._constraint.yGrow}set yGrow(t){this._constraint.yGrow=t}get stretch(){return this._constraint.stretch}set stretch(t){this._constraint.stretch=t}get xStretch(){return this._constraint.xStretch}set xStretch(t){this._constraint.xStretch=t}get yStretch(){return this._constraint.yStretch}set yStretch(t){this._constraint.yStretch=t}get margin(){return this._constraint.margin}set margin(t){this._constraint.margin=t}get xMargin(){return this._constraint.xMargin}set xMargin(t){this._constraint.xMargin=t}get yMargin(){return this._constraint.yMargin}set yMargin(t){this._constraint.yMargin=t}get leftMargin(){return this._constraint.leftMargin}set leftMargin(t){this._constraint.leftMargin=t}get rightMargin(){return this._constraint.rightMargin}set rightMargin(t){this._constraint.rightMargin=t}get topMargin(){return this._constraint.topMargin}set topMargin(t){this._constraint.topMargin=t}get bottomMargin(){return this._constraint.bottomMargin}set bottomMargin(t){this._constraint.bottomMargin=t}get minContentWidth(){return this._constraint.minContentWidth}set minContentWidth(t){this._constraint.minContentWidth=t}get minContentHeight(){return this._constraint.minContentHeight}set minContentHeight(t){this._constraint.minContentHeight=t}get maxContentWidth(){return this._constraint.maxContentWidth}set maxContentWidth(t){this._constraint.maxContentWidth=t}get maxContentHeight(){return this._constraint.maxContentHeight}set maxContentHeight(t){this._constraint.maxContentHeight=t}setExcludeInvisibleChildrenFromBounds(t){super.setExcludeInvisibleChildrenFromBounds(t),this.updateAllAutoLines()}dispose(){for(var t of(this._constraint.lock(),this.childInsertedEmitter.removeListener(this.onChildInserted),this.childRemovedEmitter.removeListener(this.onChildRemoved),this._cellMap.values()))t.dispose(),t.node.visibleProperty.unlink(this.onChildVisibilityToggled);super.dispose()}getHelperNode(){return om.createHelperNode(this.constraint.displayedCells,this.constraint.layoutBoundsProperty.value,t=>{var e="";return e+="row: ".concat(t.position.vertical,"\n"),e+="column: ".concat(t.position.horizontal,"\n"),t.size.horizontal>1&&(e+="width: ".concat(t.size.horizontal,"\n")),t.size.vertical>1&&(e+="height: ".concat(t.size.vertical,"\n")),e+="xAlign: ".concat(Gc.internalToAlign(Li.HORIZONTAL,t.effectiveXAlign),"\n"),e+="yAlign: ".concat(Gc.internalToAlign(Li.VERTICAL,t.effectiveYAlign),"\n"),e+="xStretch: ".concat(t.effectiveXStretch,"\n"),e+="yStretch: ".concat(t.effectiveYStretch,"\n"),e+="xGrow: ".concat(t.effectiveXGrow,"\n"),e+="yGrow: ".concat(t.effectiveYGrow,"\n")})}}km.prototype._mutatorKeys=[...kh,...Lm,...uh.prototype._mutatorKeys],bs.register("GridBox",km);bs.register("GridBackgroundNode",class extends uh{constructor(t,e){var i=w()({createCellBackground:t=>pl.bounds(t.lastAvailableBounds,{fill:"white",stroke:"black"})},e);super(),this.constraint=t,this.createCellBackground=i.createCellBackground,this.layoutListener=this.update.bind(this),this.constraint.finishedLayoutEmitter.addListener(this.layoutListener),this.update(),this.mutate(i)}update(){this.children=this.constraint.displayedCells.map(this.createCellBackground).filter(_.identity)}dispose(){this.constraint.finishedLayoutEmitter.removeListener(this.layoutListener),super.dispose()}});class Mm extends rm{constructor(t,e,i){super(t),this.lock(),this.nodes=e,this.cells=e.map(t=>new am(this,t,null)),this.layoutCallback=i,this.nodes.forEach(t=>this.addNode(t,!1)),this.unlock(),this.updateLayout()}layout(){if(super.layout(),!_.some(this.cells,t=>!t.isConnected())){var t=this.cells.map(t=>t.proxy);this.layoutCallback.apply(null,t),this.finishedLayoutEmitter.emit()}}dispose(){this.cells.forEach(t=>t.dispose()),super.dispose()}static create(t,e,i){return new Mm(t,e,i)}}bs.register("ManualConstraint",Mm);class Om extends rm{constructor(t,e,i){super(t),this.lock(),this.nodes=e,this.cells=e.map(t=>new am(this,t,null)),this.layoutCallback=i,this.nodes.forEach(t=>this.addNode(t,!1)),this.unlock(),this.updateLayout()}layout(){super.layout();var t=this.cells.map(t=>t.isConnected()?t.proxy:null);this.layoutCallback.apply(null,t),this.finishedLayoutEmitter.emit()}dispose(){this.cells.forEach(t=>t.dispose()),super.dispose()}static create(t,e,i){return new Om(t,e,i)}}bs.register("RelaxedManualConstraint",Om);var Rm=Oh(uh);class Nm extends Rm{constructor(t,e){var i=w()({children:[t]},e);super({sizable:!1}),_defineProperty(this,"_xSet",!1),_defineProperty(this,"_ySet",!1),_defineProperty(this,"_contentBoundsListener",_.noop),this._content=t,this._alignBounds=null,this._xAlign="center",this._yAlign="center",this._leftMargin=0,this._rightMargin=0,this._topMargin=0,this._bottomMargin=0,this._group=null,this._contentBoundsListener=this.invalidateAlignment.bind(this),this.localBounds=new mn(0,0,0,0),this.constraint=new Bm(this,t),this._content.boundsProperty.link(this._contentBoundsListener),this.mutate(i),Je.multilink([this.localPreferredWidthProperty,this.localPreferredHeightProperty],(t,e)=>{if(null!==t||null!==e){var i=this._alignBounds||new mn(0,0,0,0);t&&(i.minX=0,i.maxX=t,this._xSet=!0),e&&(i.minY=0,i.maxY=e,this._ySet=!0),this._alignBounds=i,this.constraint.updateLayout()}})}invalidateAlignment(){this._group&&this._group.onAlignBoxResized(this),this.constraint.updateLayout()}setAlignBounds(t){return this._xSet=!0,this._ySet=!0,this._alignBounds===t||t&&this._alignBounds&&t.equals(this._alignBounds)||(this._alignBounds=t,this.constraint.updateLayout()),this}set alignBounds(t){this.setAlignBounds(t)}get alignBounds(){return this.getAlignBounds()}getAlignBounds(){return this._alignBounds}setGroup(t){return this._group!==t&&(this._group&&this._group.removeAlignBox(this),this._group=t,this._group&&this._group.addAlignBox(this)),this}set group(t){this.setGroup(t)}get group(){return this.getGroup()}getGroup(){return this._group}setXAlign(t){return this._xAlign!==t&&(this._xAlign=t,this.invalidateAlignment()),this}set xAlign(t){this.setXAlign(t)}get xAlign(){return this.getXAlign()}getXAlign(){return this._xAlign}setYAlign(t){return this._yAlign!==t&&(this._yAlign=t,this.invalidateAlignment()),this}set yAlign(t){this.setYAlign(t)}get yAlign(){return this.getYAlign()}getYAlign(){return this._yAlign}setMargin(t){return this._leftMargin===t&&this._rightMargin===t&&this._topMargin===t&&this._bottomMargin===t||(this._leftMargin=this._rightMargin=this._topMargin=this._bottomMargin=t,this.invalidateAlignment()),this}set margin(t){this.setMargin(t)}get margin(){return this.getMargin()}getMargin(){return this._leftMargin}setXMargin(t){return this._leftMargin===t&&this._rightMargin===t||(this._leftMargin=this._rightMargin=t,this.invalidateAlignment()),this}set xMargin(t){this.setXMargin(t)}get xMargin(){return this.getXMargin()}getXMargin(){return this._leftMargin}setYMargin(t){return this._topMargin===t&&this._bottomMargin===t||(this._topMargin=this._bottomMargin=t,this.invalidateAlignment()),this}set yMargin(t){this.setYMargin(t)}get yMargin(){return this.getYMargin()}getYMargin(){return this._topMargin}setLeftMargin(t){return this._leftMargin!==t&&(this._leftMargin=t,this.invalidateAlignment()),this}set leftMargin(t){this.setLeftMargin(t)}get leftMargin(){return this.getLeftMargin()}getLeftMargin(){return this._leftMargin}setRightMargin(t){return this._rightMargin!==t&&(this._rightMargin=t,this.invalidateAlignment()),this}set rightMargin(t){this.setRightMargin(t)}get rightMargin(){return this.getRightMargin()}getRightMargin(){return this._rightMargin}setTopMargin(t){return this._topMargin!==t&&(this._topMargin=t,this.invalidateAlignment()),this}set topMargin(t){this.setTopMargin(t)}get topMargin(){return this.getTopMargin()}getTopMargin(){return this._topMargin}setBottomMargin(t){return this._bottomMargin!==t&&(this._bottomMargin=t,this.invalidateAlignment()),this}set bottomMargin(t){this.setBottomMargin(t)}get bottomMargin(){return this.getBottomMargin()}getBottomMargin(){return this._bottomMargin}getContentBounds(){var t=this._content.bounds;return new mn(t.left-this._leftMargin,t.top-this._topMargin,t.right+this._rightMargin,t.bottom+this._bottomMargin)}setAdjustedLocalBounds(t){if(this._xSet&&this._ySet)this.localBounds=t;else if(this._xSet){var e=this.getContentBounds();this.localBounds=new mn(t.minX,e.minY,t.maxX,e.maxY)}else if(this._ySet){var i=this.getContentBounds();this.localBounds=new mn(i.minX,t.minY,i.maxX,t.maxY)}else this.localBounds=this.getContentBounds()}dispose(){this._content.boundsProperty.unlink(this._contentBoundsListener),this.group=null,this.constraint.dispose(),super.dispose()}}class Bm extends rm{constructor(t,e){super(t),this.alignBox=t,this.content=e,this.addNode(e),t.isWidthResizableProperty.lazyLink(this._updateLayoutListener),t.isHeightResizableProperty.lazyLink(this._updateLayoutListener)}updateProperty(t,e){var i=this.content[t],s=this.alignBox.localBounds[t]+e;Math.abs(i-s)>1e-5&&(this.content[t]=s)}layout(){super.layout();var t=this.alignBox,e=this.content;if(e.bounds.isValid()){var i=t.leftMargin+t.rightMargin,s=t.topMargin+t.bottomMargin;if(null!==t.alignBounds)t.setAdjustedLocalBounds(t.alignBounds);else{var n=e.width+i,r=e.height+s;t.setAdjustedLocalBounds(new mn(0,0,n,r))}var a=isFinite(e.width)?(xh(e)?e.minimumWidth||0:e.width)+i:null,o=isFinite(e.height)?(Ch(e)?e.minimumHeight||0:e.height)+s:null;e.localBounds.isEmpty()||("center"===t.xAlign?this.updateProperty("centerX",(t.leftMargin-t.rightMargin)/2):"left"===t.xAlign?this.updateProperty("left",t.leftMargin):"right"===t.xAlign?this.updateProperty("right",-t.rightMargin):"stretch"===t.xAlign&&(e.preferredWidth=t.localWidth-t.leftMargin-t.rightMargin,this.updateProperty("left",t.leftMargin)),"center"===t.yAlign?this.updateProperty("centerY",(t.topMargin-t.bottomMargin)/2):"top"===t.yAlign?this.updateProperty("top",t.topMargin):"bottom"===t.yAlign?this.updateProperty("bottom",-t.bottomMargin):"stretch"===t.yAlign&&(e.preferredHeight=t.localHeight-t.topMargin-t.bottomMargin,this.updateProperty("top",t.topMargin))),t.localMinimumWidth=t.widthSizable?a:t.localWidth,t.localMinimumHeight=t.heightSizable?o:t.localHeight}}}Nm.prototype._mutatorKeys=["alignBounds","xAlign","yAlign","margin","xMargin","yMargin","leftMargin","rightMargin","topMargin","bottomMargin","group"].concat(Rm.prototype._mutatorKeys),bs.register("AlignBox",Nm);var Fm=1,Vm={matchHorizontal:!0,matchVertical:!0};class Hm{constructor(t){var e=x()({},Vm,t);this._alignBoxes=[],this._matchHorizontal=e.matchHorizontal,this._matchVertical=e.matchVertical,this._resizeLock=!1,this._maxWidthProperty=new Re(0),this._maxHeightProperty=new Re(0),this.id=Fm++}getMaxWidth(){return this._maxWidthProperty.value}get maxWidth(){return this.getMaxWidth()}getMaxWidthProperty(){return this._maxWidthProperty}get maxWidthProperty(){return this.getMaxWidthProperty()}getMaxHeight(){return this._maxHeightProperty.value}get maxHeight(){return this.getMaxHeight()}getMaxHeightProperty(){return this._maxHeightProperty}get maxHeightProperty(){return this.getMaxHeightProperty()}createBox(t,e){return new Nm(t,T({group:this},e))}setMatchHorizontal(t){return this._matchHorizontal!==t&&(this._matchHorizontal=t,this.updateLayout()),this}set matchHorizontal(t){this.setMatchHorizontal(t)}get matchHorizontal(){return this.getMatchHorizontal()}getMatchHorizontal(){return this._matchHorizontal}setMatchVertical(t){return this._matchVertical!==t&&(this._matchVertical=t,this.updateLayout()),this}set matchVertical(t){this.setMatchVertical(t)}get matchVertical(){return this.getMatchVertical()}getMatchVertical(){return this._matchVertical}dispose(){for(var t=this._alignBoxes.length-1;t>=0;t--)this._alignBoxes[t].dispose()}updateLayout(){if(!this._resizeLock){this._resizeLock=!0;for(var t=0,e=0,i=0;i0&&e>0)for(var n=0;n{this.alignBounds=t},this.alignBoundsProperty=e,this.alignBoundsProperty.lazyLink(this._alignBoundsPropertyListener)}dispose(){this.alignBoundsProperty.unlink(this._alignBoundsPropertyListener),super.dispose()}});var Ym={vertical:"top",horizontal:"left"},zm={vertical:"height",horizontal:"width"},Wm={vertical:{left:"left",center:"centerX",right:"right",origin:"x"},horizontal:{top:"top",center:"centerY",bottom:"bottom",origin:"y"}};class Um extends uh{constructor(t){var e=w()({excludeInvisibleChildrenFromBounds:!0,disabledOpacity:Ps.DISABLED_OPACITY},t);super(),_defineProperty(this,"_orientation","vertical"),_defineProperty(this,"_spacing",0),_defineProperty(this,"_align","center"),_defineProperty(this,"_resize",!0),_defineProperty(this,"_updateLayoutLocked",!1),_defineProperty(this,"_layoutMutating",!1),this._updateLayoutListener=this.updateLayoutAutomatically.bind(this),this.childInsertedEmitter.addListener(this.onLayoutBoxChildInserted.bind(this)),this.childRemovedEmitter.addListener(this.onLayoutBoxChildRemoved.bind(this)),this.childrenChangedEmitter.addListener(this.onLayoutBoxChildrenChanged.bind(this)),this._layoutMutating=!0,this.mutate(e),this._layoutMutating=!1}getAlignmentBounds(){for(var t=Number.NEGATIVE_INFINITY,e=Number.NEGATIVE_INFINITY,i=0;i!t.visible)&&this.updateLayoutAutomatically()}setOrientation(t){return this._orientation!==t&&(this._orientation=t,this.updateLayout()),this}set orientation(t){this.setOrientation(t)}get orientation(){return this.getOrientation()}getOrientation(){return this._orientation}setSpacing(t){return this._spacing!==t&&(this._spacing=t,this.updateLayout()),this}set spacing(t){this.setSpacing(t)}get spacing(){return this.getSpacing()}getSpacing(){return this._spacing}setAlign(t){return this._align!==t&&(this._align=t,this.updateLayout()),this}set align(t){this.setAlign(t)}get align(){return this.getAlign()}getAlign(){return this._align}setResize(t){if(this._resize!==t){this._resize=t;for(var e=0;e"element"===t.type.toLowerCase(),Xm=t=>"text"===t.type.toLowerCase(),jm=new nn({size:20}),qm=["b","strong","i","em","sub","sup","u","s"],Km="COMPLETE",Zm="INCOMPLETE",Qm="NONE",Jm=(t,e)=>{if(!e)return null;var i=_.find(e.attributes,e=>e.key===t);return i&&i.value||null},$m=new rl(""),tp={"font-family":"family","font-size":"size","font-stretch":"stretch","font-style":"style","font-variant":"variant","font-weight":"weight","line-height":"lineHeight"},ep=Object.keys(tp);["color"].concat(ep);class ip extends uh{constructor(t,e){var i=w()({fill:"#000000",tandem:Ct.OPTIONAL,phetioType:ip.RichTextIO},e);"string"==typeof t||"number"==typeof t?i.text=t:i.textProperty=t,super(),this._textProperty=new ti("",!0,this.onTextPropertyChange.bind(this)),this._font=jm,this._boundsMethod="hybrid",this._fill="#000000",this._stroke=null,this._lineWidth=1,this._subScale=.75,this._subXSpacing=0,this._subYOffset=0,this._supScale=.75,this._supXSpacing=0,this._supYOffset=0,this._capHeightScale=.75,this._underlineLineWidth=1,this._underlineHeightScale=.15,this._strikethroughLineWidth=1,this._strikethroughHeightScale=.3,this._linkFill="rgb(27,0,241)",this._linkEventsHandled=!1,this._links={},this._align="left",this._leading=0,this._lineWrap=null,this._linkItems=[],this._hasAddedLeafToLine=!1,this.lineContainer=new uh({}),this.addChild(this.lineContainer),this.rebuildRichText(),this.mutate(i)}onTextPropertyChange(){this.rebuildRichText()}setTextProperty(t){return this._textProperty.setTargetProperty(this,"textProperty",t)}set textProperty(t){this.setTextProperty(t)}get textProperty(){return this.getTextProperty()}getTextProperty(){return this._textProperty}initializePhetioObject(t,e){var i=w()({},e),s=this.isPhetioInstrumented();super.initializePhetioObject(t,i),Ct.PHET_IO_ENABLED&&!s&&this.isPhetioInstrumented()&&this._textProperty.initializePhetio(this,"textProperty",()=>new $e(this.text,T({phetioReadOnly:this.phetioReadOnly,tandem:this.tandem.createTandem("textProperty"),phetioDocumentation:"Property for the displayed text"},i.textPropertyOptions)))}rebuildRichText(){if(this.freeChildrenToPool(),""!==this.text){var t=this.text.replace(/\u202a/g,'').replace(/\u202b/g,'').replace(/\u202c/g,""),e=himalaya.parse(t);this._linkItems.length=0;var i=null===this._lineWrap?Number.POSITIVE_INFINITY:this._lineWrap,s=np.pool.create(!0);for(this._hasAddedLeafToLine=!1;e.length;){var n=e[0],r=s.bounds.isValid()?s.width:0,a=this.appendElement(s,n,this._font,this._fill,!0,i-r);a!==Qm&&(s.bounds.isValid()?this.appendLine(s):this.appendLine(new _l($m.setText("X").setFont(this._font).height)),s=np.pool.create(!0),this._hasAddedLeafToLine=!1),a!==Zm&&e.splice(0,1)}for(s.bounds.isValid()&&this.appendLine(s),0===this.lineContainer.getChildrenCount()&&this.appendEmptyLeaf(),this.alignLines();this._linkItems.length;)(()=>{var t,e=this._linkItems[0].element,i=this._linkItems[0].href,s=[];for(t=this._linkItems.length-1;t>=0;t--){var n=this._linkItems[t];n.element===e&&(s.push(n.node),this._linkItems.splice(t,1))}var r=ap.pool.create(e.innerContent,i);for(this.lineContainer.addChild(r),t=0;t1){var c=[],m=!1;for(c.unshift(u.pop());u.length;){if((a=rp.pool.create(u.join(" "),n,i,this._boundsMethod,s,this._stroke,this._lineWidth)).fitsIn(r-d,this._hasAddedLeafToLine,n)||!(this._hasAddedLeafToLine||u.length>1)){m=!0;break}c.unshift(u.pop())}if(!m)return Zm;l=Zm,e.content=c.join(" ")}}this._hasAddedLeafToLine=!0}else if(Gm(e)){if("br"===e.tagName)return Km;if("span"===e.tagName){var p=Jm("dir",e);p&&(n="ltr"===p)}a=np.pool.create(n);var g=Jm("style",e);if(g){var v=(o=g.split(";"),h={},o.forEach(t=>{if(t.length>0){var e=t.split(":");h[e[0].trim()]=e[1].trim()}}),h);v.color&&(s=new Us(v.color));for(var f={},y=0;yt.node!==a),a.clean()));return l}setText(t){return t="".concat(t),this._textProperty.set(t),this}set text(t){this.setText(t)}get text(){return this.getText()}getText(){return this._textProperty.value}setBoundsMethod(t){return t!==this._boundsMethod&&(this._boundsMethod=t,this.rebuildRichText()),this}set boundsMethod(t){this.setBoundsMethod(t)}get boundsMethod(){return this.getBoundsMethod()}getBoundsMethod(){return this._boundsMethod}setFont(t){return this._font!==t&&(this._font=t,this.rebuildRichText()),this}set font(t){this.setFont(t)}get font(){return this.getFont()}getFont(){return this._font}setFill(t){return this._fill!==t&&(this._fill=t,this.rebuildRichText()),this}set fill(t){this.setFill(t)}get fill(){return this.getFill()}getFill(){return this._fill}setStroke(t){return this._stroke!==t&&(this._stroke=t,this.rebuildRichText()),this}set stroke(t){this.setStroke(t)}get stroke(){return this.getStroke()}getStroke(){return this._stroke}setLineWidth(t){return this._lineWidth!==t&&(this._lineWidth=t,this.rebuildRichText()),this}set lineWidth(t){this.setLineWidth(t)}get lineWidth(){return this.getLineWidth()}getLineWidth(){return this._lineWidth}setSubScale(t){return this._subScale!==t&&(this._subScale=t,this.rebuildRichText()),this}set subScale(t){this.setSubScale(t)}get subScale(){return this.getSubScale()}getSubScale(){return this._subScale}setSubXSpacing(t){return this._subXSpacing!==t&&(this._subXSpacing=t,this.rebuildRichText()),this}set subXSpacing(t){this.setSubXSpacing(t)}get subXSpacing(){return this.getSubXSpacing()}getSubXSpacing(){return this._subXSpacing}setSubYOffset(t){return this._subYOffset!==t&&(this._subYOffset=t,this.rebuildRichText()),this}set subYOffset(t){this.setSubYOffset(t)}get subYOffset(){return this.getSubYOffset()}getSubYOffset(){return this._subYOffset}setSupScale(t){return this._supScale!==t&&(this._supScale=t,this.rebuildRichText()),this}set supScale(t){this.setSupScale(t)}get supScale(){return this.getSupScale()}getSupScale(){return this._supScale}setSupXSpacing(t){return this._supXSpacing!==t&&(this._supXSpacing=t,this.rebuildRichText()),this}set supXSpacing(t){this.setSupXSpacing(t)}get supXSpacing(){return this.getSupXSpacing()}getSupXSpacing(){return this._supXSpacing}setSupYOffset(t){return this._supYOffset!==t&&(this._supYOffset=t,this.rebuildRichText()),this}set supYOffset(t){this.setSupYOffset(t)}get supYOffset(){return this.getSupYOffset()}getSupYOffset(){return this._supYOffset}setCapHeightScale(t){return this._capHeightScale!==t&&(this._capHeightScale=t,this.rebuildRichText()),this}set capHeightScale(t){this.setCapHeightScale(t)}get capHeightScale(){return this.getCapHeightScale()}getCapHeightScale(){return this._capHeightScale}setUnderlineLineWidth(t){return this._underlineLineWidth!==t&&(this._underlineLineWidth=t,this.rebuildRichText()),this}set underlineLineWidth(t){this.setUnderlineLineWidth(t)}get underlineLineWidth(){return this.getUnderlineLineWidth()}getUnderlineLineWidth(){return this._underlineLineWidth}setUnderlineHeightScale(t){return this._underlineHeightScale!==t&&(this._underlineHeightScale=t,this.rebuildRichText()),this}set underlineHeightScale(t){this.setUnderlineHeightScale(t)}get underlineHeightScale(){return this.getUnderlineHeightScale()}getUnderlineHeightScale(){return this._underlineHeightScale}setStrikethroughLineWidth(t){return this._strikethroughLineWidth!==t&&(this._strikethroughLineWidth=t,this.rebuildRichText()),this}set strikethroughLineWidth(t){this.setStrikethroughLineWidth(t)}get strikethroughLineWidth(){return this.getStrikethroughLineWidth()}getStrikethroughLineWidth(){return this._strikethroughLineWidth}setStrikethroughHeightScale(t){return this._strikethroughHeightScale!==t&&(this._strikethroughHeightScale=t,this.rebuildRichText()),this}set strikethroughHeightScale(t){this.setStrikethroughHeightScale(t)}get strikethroughHeightScale(){return this.getStrikethroughHeightScale()}getStrikethroughHeightScale(){return this._strikethroughHeightScale}setLinkFill(t){return this._linkFill!==t&&(this._linkFill=t,this.rebuildRichText()),this}set linkFill(t){this.setLinkFill(t)}get linkFill(){return this.getLinkFill()}getLinkFill(){return this._linkFill}setLinkEventsHandled(t){return this._linkEventsHandled!==t&&(this._linkEventsHandled=t,this.rebuildRichText()),this}set linkEventsHandled(t){this.setLinkEventsHandled(t)}get linkEventsHandled(){return this.getLinkEventsHandled()}getLinkEventsHandled(){return this._linkEventsHandled}setLinks(t){return this._links!==t&&(this._links=t,this.rebuildRichText()),this}set links(t){this.setLinks(t)}get links(){return this.getLinks()}getLinks(){return this._links}setAlign(t){return this._align!==t&&(this._align=t,this.rebuildRichText()),this}set align(t){this.setAlign(t)}get align(){return this.getAlign()}getAlign(){return this._align}setLeading(t){return this._leading!==t&&(this._leading=t,this.rebuildRichText()),this}set leading(t){this.setLeading(t)}get leading(){return this.getLeading()}getLeading(){return this._leading}setLineWrap(t){return this._lineWrap!==t&&(this._lineWrap=t,this.rebuildRichText()),this}set lineWrap(t){this.setLineWrap(t)}get lineWrap(){return this.getLineWrap()}getLineWrap(){return this._lineWrap}mutate(t){return super.mutate(t)}static stringWithFont(t,e){return"".concat("".concat(t,"")}static himalayaElementToString(t,e){if(Xm(t))return ip.contentToString(t.content,e);if(Gm(t)){var i=Jm("dir",t);return"span"===t.tagName&&i&&(e="ltr"===i),t.children.map(t=>ip.himalayaElementToString(t,e)).join("")}return""}static himalayaElementToAccessibleString(t,e){if(Xm(t))return ip.contentToString(t.content,e);if(Gm(t)){var i=Jm("dir",t);"span"===t.tagName&&i&&(e="ltr"===i);var s=t.children.map(t=>ip.himalayaElementToAccessibleString(t,e)).join("");return _.includes(qm,t.tagName)?"<".concat(t.tagName,">").concat(s,""):s}return""}static contentToString(t,e){var i=he.decode(t);return e?"‪".concat(i,"‬"):"‫".concat(i,"‬")}}ip.prototype._mutatorKeys=["boundsMethod","font","fill","stroke","lineWidth","subScale","subXSpacing","subYOffset","supScale","supXSpacing","supYOffset","capHeightScale","underlineLineWidth","underlineHeightScale","strikethroughLineWidth","strikethroughHeightScale","linkFill","linkEventsHandled","links","align","leading","lineWrap","textProperty","text"].concat(uh.prototype._mutatorKeys),bs.register("RichText",ip);var sp=Ei(t=>class extends t{get isCleanable(){return!0}clean(){for(var t=this._children.length-1;t>=0;t--){var e=this._children[t];e.isCleanable&&(this.removeChild(e),e.clean())}this.matrix=wn.IDENTITY,this.freeToPool()}});class np extends(sp(uh)){constructor(t){super(),this.initialize(t)}initialize(t){return this.isLTR=t,this.leftSpacing=0,this.rightSpacing=0,this}addElement(t){var e=this.children.length>0,i=t.width>0,s=t.getScaleVector().x,n=t.leftSpacing*s,r=t.rightSpacing*s;return!(!e&&!i)&&(e?i?(this.isLTR?(t.left=this.localRight+this.rightSpacing+n,this.rightSpacing=r):(t.right=this.localLeft-this.leftSpacing-r,this.leftSpacing=n),this.addChild(t),!0):(this.isLTR?this.rightSpacing+=n+r:this.leftSpacing+=n+r,!1):(this.isLTR?(t.left=0,this.leftSpacing=n,this.rightSpacing=r):(t.right=0,this.leftSpacing=n,this.rightSpacing=r),this.addChild(t),!0))}addExtraBeforeSpacing(t){this.isLTR?this.leftSpacing+=t:this.rightSpacing+=t}freeToPool(){np.pool.freeToPool(this)}}_defineProperty(np,"pool",new zi(np));class rp extends(sp(rl)){constructor(t,e,i,s,n,r,a){super(""),this.initialize(t,e,i,s,n,r,a)}initialize(t,e,i,s,n,r,a){for(var o="";t.startsWith(" ");)o+=" ",t=t.slice(1);for(var h="";t.endsWith(" ");)h=" ",t=t.slice(0,t.length-1);this.text=ip.contentToString(t,e),this.boundsMethod=s,this.font=i,this.fill=n,this.stroke=r,this.lineWidth=a;var l=o.length?$m.setText(o).setFont(i).width:0,d=h.length?$m.setText(h).setFont(i).width:0;return this.leftSpacing=e?l:d,this.rightSpacing=e?d:l,this}clean(){super.clean(),this.fill=null,this.stroke=null}fitsIn(t,e,i){return this.width+(e?i?this.leftSpacing:this.rightSpacing:0)<=t}freeToPool(){rp.pool.freeToPool(this)}}_defineProperty(rp,"pool",new zi(rp));class ap extends(Td(sp(uh))){constructor(t,e){super(),this.fireListener=null,this.accessibleInputListener=null,this.initialize(t,e,!1),this.mutate({cursor:"pointer",tagName:"a"})}initialize(t,e){return(!(arguments.length>2&&void 0!==arguments[2])||arguments[2])&&super.initialize(),this.innerContent=t,this.voicingNameResponse=t,"function"==typeof e?(this.fireListener=new sc({fire:e,tandem:Ct.OPT_OUT}),this.addInputListener(this.fireListener),this.setPDOMAttribute("href","#"),this.setPDOMAttribute("target","_self"),this.accessibleInputListener={click:t=>{t.domEvent&&t.domEvent.preventDefault(),e()}},this.addInputListener(this.accessibleInputListener)):(this.fireListener=new sc({fire:t=>{t.isFromPDOM()&&t.domEvent.preventDefault(),self._linkEventsHandled&&t.handle(),_r(e)},tandem:Ct.OPT_OUT}),this.addInputListener(this.fireListener),this.setPDOMAttribute("href",e),this.setPDOMAttribute("target","_blank")),this}clean(){super.clean(),this.fireListener&&this.removeInputListener(this.fireListener),this.fireListener=null,this.accessibleInputListener&&(this.removeInputListener(this.accessibleInputListener),this.accessibleInputListener=null)}freeToPool(){ap.pool.freeToPool(this)}}_defineProperty(ap,"pool",new zi(ap)),ip.RichTextIO=new j("RichTextIO",{valueType:ip,supertype:uh.NodeIO,documentation:"The tandem IO Type for the scenery RichText node"});class op extends(Xd(rl)){constructor(t,e){var i=w()({readingBlockNameResponse:t,tagName:"p",innerContent:t},e);super(t),this.focusHighlight=new Yd(this),this.mutate(i)}}bs.register("VoicingText",op);class hp extends(Xd(ip)){constructor(t,e){var i=w()({readingBlockNameResponse:t,innerContent:t,readingBlockTagName:"button"},e);super(t),this.focusHighlight=new Yd(this),this.mutate(i)}}bs.register("VoicingRichText",hp);var lp=t=>{if(t instanceof Is)return{type:"Vector2",x:t.x,y:t.y};if(t instanceof wn)return{type:"Matrix3",m00:t.m00(),m01:t.m01(),m02:t.m02(),m10:t.m10(),m11:t.m11(),m12:t.m12(),m20:t.m20(),m21:t.m21(),m22:t.m22()};if(t instanceof mn){var e=t;return{type:"Bounds2",maxX:e.maxX,maxY:e.maxY,minX:e.minX,minY:e.minY}}if(t instanceof aa)return{type:"Shape",path:t.getSVGPath()};if(Array.isArray(t))return{type:"Array",value:t.map(lp)};if(t instanceof Us)return{type:"Color",red:t.red,green:t.green,blue:t.blue,alpha:t.alpha};if(t instanceof ce)return{type:"Property",value:lp(t.value)};if(xo&&t instanceof xo){var i={};return t.transformMatrix&&(i.transformMatrix=lp(t.transformMatrix)),To&&(t instanceof Ao||t instanceof So)&&(i.stops=t.stops.map(t=>({ratio:t.ratio,stop:lp(t.color)})),i.start=lp(t.start),i.end=lp(t.end),So&&t instanceof So?i.type="LinearGradient":Ao&&t instanceof Ao&&(i.type="RadialGradient",i.startRadius=t.startRadius,i.endRadius=t.endRadius)),Eo&&t instanceof Eo&&(i.type="Pattern",i.url=t.image.src),i}if(t instanceof uh){var s=t,n={},r={};["visible","opacity","disabledOpacity","pickable","inputEnabled","cursor","transformBounds","renderer","usesOpacity","layerSplit","cssTransform","excludeInvisible","webglScale","preventFit"].forEach(t=>{s[t]!==uh.DEFAULT_NODE_OPTIONS[t]&&(n[t]=s[t])}),["tagName","innerContent","accessibleName","helpText"].forEach(t=>{null!==s[t]&&(n[t]=s[t])}),["maxWidth","maxHeight","clipArea","mouseArea","touchArea"].forEach(t=>{s[t]!==uh.DEFAULT_NODE_OPTIONS[t]&&(r[t]=lp(s[t]))}),s.matrix.isIdentity()||(r.matrix=lp(s.matrix)),s._localBoundsOverridden&&(r.localBounds=lp(s.localBounds)),r.children=s.children.map(t=>t.id),r.hasInputListeners=s.inputListeners.length>0;var a={id:s.id,type:"Node",types:nt(s.constructor).map(t=>t.name).filter(t=>t&&"Object"!==t&&"Node"!==t),name:s.constructor.name,options:n,setup:r};if(sl&&s instanceof sl&&(a.type="Path",r.path=lp(s.shape),s.boundsMethod!==sl.DEFAULT_PATH_OPTIONS.boundsMethod&&(n.boundsMethod=s.boundsMethod)),dl&&s instanceof dl&&(a.type="Circle",n.radius=s.radius),cl&&s instanceof cl&&(a.type="Line",n.x1=s.x1,n.y1=s.y1,n.x2=s.x2,n.y2=s.y2),pl&&s instanceof pl&&(a.type="Rectangle",n.rectX=s.rectX,n.rectY=s.rectY,n.rectWidth=s.rectWidth,n.rectHeight=s.rectHeight,n.cornerXRadius=s.cornerXRadius,n.cornerYRadius=s.cornerYRadius),rl&&s instanceof rl&&(a.type="Text","hybrid"!==s.boundsMethod&&(n.boundsMethod=s.boundsMethod),n.text=s.text,n.font=s.font),el&&s instanceof el&&(a.type="Image",["imageOpacity","initialWidth","initialHeight","mipmapBias","mipmapInitialLevel","mipmapMaxLevel"].forEach(t=>{s[t]!==el.DEFAULT_IMAGE_OPTIONS[t]&&(n[t]=s[t])}),r.width=s.imageWidth,r.height=s.imageHeight,s._mipmapData?(r.imageType="mipmapData",r.mipmapData=s._mipmapData.map(t=>({url:t.url,width:t.width,height:t.height}))):(s._mipmap&&(r.generateMipmaps=!0),s._image instanceof HTMLImageElement?(r.imageType="image",r.src=s._image.src):s._image instanceof HTMLCanvasElement&&(r.imageType="canvas",r.src=s._image.toDataURL()))),ll&&s instanceof ll||vl&&s instanceof vl){a.type=ll&&s instanceof ll?"CanvasNode":"WebGLNode",r.canvasBounds=lp(s.canvasBounds);var o=document.createElement("canvas");o.width=Math.ceil(1*s.canvasBounds.width),o.height=Math.ceil(1*s.canvasBounds.height);var h=o.getContext("2d"),l=new rr(o,h),d=wn.scale(1);l.context.setTransform(1,0,0,1,-s.canvasBounds.left,-s.canvasBounds.top),s.renderToCanvasSelf(l,d),r.url=o.toDataURL(),r.scale=1,r.offset=lp(s.canvasBounds.leftTop)}return ul&&s instanceof ul&&(a.type="DOM",a.element=(new window.XMLSerializer).serializeToString(s.element),s.element instanceof window.HTMLCanvasElement&&(a.dataURL=s.element.toDataURL()),n.preventTransform=s.preventTransform),(sl&&s instanceof sl||rl&&s instanceof rl)&&(["fillPickable","strokePickable","lineWidth","lineCap","lineJoin","lineDashOffset","miterLimit"].forEach(t=>{s[t]!==Wh[t]&&(n[t]=s[t])}),s.fill!==Wh.fill&&(r.fill=lp(s.fill)),s.stroke!==Wh.stroke&&(r.stroke=lp(s.stroke)),s.lineDash.length&&(r.lineDash=lp(s.lineDash))),a}return t instanceof $v?{type:"Display",width:t.width,height:t.height,backgroundColor:lp(t.backgroundColor),tree:{type:"Subtree",rootNodeId:t.rootNode.id,nodes:dp(t.rootNode)}}:{type:"value",value:t}},dp=t=>t.getSubtreeNodes().map(lp);bs.register("scenerySerialize",lp);var up=t=>{if("Vector2"===t.type)return new Is(t.x,t.y);if("Matrix3"===t.type)return(new wn).rowMajor(t.m00,t.m01,t.m02,t.m10,t.m11,t.m12,t.m20,t.m21,t.m22);if("Bounds2"===t.type)return new mn(t.minX,t.minY,t.maxX,t.maxY);if("Shape"===t.type)return new aa(t.path);if("Array"===t.type)return t.value.map(up);if("Color"===t.type)return new Us(t.red,t.green,t.blue,t.alpha);if("Property"===t.type)return new me(up(t.value));if("Pattern"===t.type||"LinearGradient"===t.type||"RadialGradient"===t.type){var e;if("Pattern"===t.type){var i=new window.Image;i.src=t.url,e=new Eo(i)}else{var s=up(t.start),n=up(t.end);"LinearGradient"===t.type?e=new So(s.x,s.y,n.x,n.y):"RadialGradient"===t.type&&(e=new Ao(s.x,s.y,t.startRadius,n.x,n.y,t.endRadius)),t.stops.forEach(t=>{e.addColorStop(t.ratio,up(t.stop))})}return t.transformMatrix&&e.setTransformMatrix(up(t.transformMatrix)),e}if(_.includes(["Node","Path","Circle","Line","Rectangle","Text","Image","CanvasNode","WebGLNode","DOM"],t.type)){var r,a=t.setup;if("Node"===t.type)r=new uh;else if("Path"===t.type)r=new sl(up(a.path));else if("Circle"===t.type)r=new dl({});else if("Line"===t.type)r=new cl({});else if("Rectangle"===t.type)r=new pl({});else if("Text"===t.type)r=new rl("");else if("Image"===t.type){if("image"===a.imageType||"canvas"===a.imageType)r=new el(a.src),a.generateMipmaps&&(r.mipmap=!0);else if("mipmapData"===a.imageType){var o=a.mipmapData.map(t=>{var e={width:t.width,height:t.height,url:t.url};e.img=new window.Image,e.img.src=t.url,e.canvas=document.createElement("canvas"),e.canvas.width=t.width,e.canvas.height=t.height;var i=e.canvas.getContext("2d");return e.updateCanvas=function(){e.img.complete&&(void 0===e.img.naturalWidth||e.img.naturalWidth>0)&&(i.drawImage(e.img,0,0),delete e.updateCanvas)},e});r=new el(o)}r.initialWidth=a.width,r.initialHeight=a.height}else if("CanvasNode"===t.type||"WebGLNode"===t.type)r=new uh({children:[new el(a.url,{translation:up(a.offset),scale:1/a.scale})]});else if("DOM"===t.type){var h=document.createElement("div");h.innerHTML=t.element;var l=h.childNodes[0];if(h.removeChild(l),t.dataURL){var d=new window.Image;d.onload=()=>{l.getContext("2d").drawImage(d,0,0)},d.src=t.dataURL}r=new ul(l)}return a.clipArea&&(r.clipArea=up(a.clipArea)),a.mouseArea&&(r.mouseArea=up(a.mouseArea)),a.touchArea&&(r.touchArea=up(a.touchArea)),a.matrix&&(r.matrix=up(a.matrix)),a.localBounds&&(r.localBounds=up(a.localBounds)),a.fill&&(r.fill=up(a.fill)),a.stroke&&(r.stroke=up(a.stroke)),a.lineDash&&(r.lineDash=up(a.lineDash)),r.mutate(t.options),r._serialization=t,r}if("Subtree"===t.type){var u={},c=t.nodes.map(up);return c.forEach(t=>{u[t._serialization.id]=t}),c.forEach(t=>{t._serialization.setup.children.forEach(e=>{t.addChild(u[e])})}),u[t.rootNodeId]}return"value"===t.type?t.value:null};bs.register("sceneryDeserialize",up);var cp=up,mp=t=>cp(lp(t));bs.register("sceneryCopy",mp);var pp=1;class gp{initialize(t){return this.id=this.id||pp++,this.clean(),this.renderer=t,this.dirty=!0,this.isDisposed=!1,this.linksDirty=!1,this.visibleProperty=new ae(!0),this.fittableProperty=new ae(!0),this}clean(){this.parentDrawable=null,this.backbone=null,this.pendingParentDrawable=null,this.pendingBackbone=null,this.pendingAddition=!1,this.pendingRemoval=!1,this.previousDrawable=null,this.nextDrawable=null,this.oldPreviousDrawable=null,this.oldNextDrawable=null,this.visibleProperty&&this.visibleProperty.removeAllListeners(),this.fittableProperty&&this.fittableProperty.removeAllListeners()}update(){var t=!1;return this.dirty&&!this.isDisposed&&(this.dirty=!1,t=!0),t}setVisible(t){this.visibleProperty.value=t}set visible(t){this.setVisible(t)}isVisible(){return this.visibleProperty.value}get visible(){return this.isVisible()}setFittable(t){this.fittableProperty.value=t}set fittable(t){this.setFittable(t)}isFittable(){return this.fittableProperty.value}get fittable(){return this.isFittable()}setBlockBackbone(t){this.parentDrawable=t,this.backbone=t,this.pendingParentDrawable=t,this.pendingBackbone=t,this.pendingAddition=!1,this.pendingRemoval=!1}notePendingAddition(t,e,i){this.pendingParentDrawable=e,this.pendingBackbone=i,this.pendingAddition=!0,this.pendingRemoval||t.markDrawableChangedBlock(this)}notePendingRemoval(t){this.pendingRemoval=!0,this.pendingAddition||t.markDrawableChangedBlock(this)}notePendingMove(t,e){this.pendingParentDrawable=e,this.pendingRemoval&&this.pendingAddition||t.markDrawableChangedBlock(this),this.pendingAddition=!0,this.pendingRemoval=!0}updateBlock(){var t=!1;return(this.pendingRemoval||this.pendingAddition)&&((t=!this.pendingRemoval||!this.pendingAddition||this.parentDrawable!==this.pendingParentDrawable||this.backbone!==this.pendingBackbone)?(this.pendingRemoval&&(this.parentDrawable.removeDrawable(this),this.pendingAddition||(this.pendingParentDrawable=null,this.pendingBackbone=null)),this.parentDrawable=this.pendingParentDrawable,this.backbone=this.pendingBackbone,this.pendingAddition&&this.parentDrawable.addDrawable(this)):this.pendingAddition&&on.isCanvas(this.renderer)&&this.parentDrawable.onPotentiallyMovedDrawable(this),this.pendingAddition=!1,this.pendingRemoval=!1),t}updateLinks(){this.oldNextDrawable=this.nextDrawable,this.oldPreviousDrawable=this.previousDrawable,this.linksDirty=!1}markDirty(){this.dirty||(this.dirty=!0,this.parentDrawable&&this.parentDrawable.markDirtyDrawable(this))}markLinksDirty(t){this.linksDirty||(this.linksDirty=!0,t.markDrawableForLinksUpdate(this))}markForDisposal(t){gp.disconnectBefore(this,t),gp.disconnectAfter(this,t),t.markDrawableForDisposal(this)}disposeImmediately(t){gp.disconnectBefore(this,t),gp.disconnectAfter(this,t),this.dispose()}dispose(){this.clean(),this.isDisposed=!0,this.freeToPool()}audit(t,e,i){0}toString(){return"".concat(this.constructor.name,"#").concat(this.id)}toDetailedString(){return this.toString()}static connectDrawables(t,e,i){t.nextDrawable!==e&&(t.nextDrawable&&(t.nextDrawable.markLinksDirty(i),t.nextDrawable.previousDrawable=null),e.previousDrawable&&(e.previousDrawable.markLinksDirty(i),e.previousDrawable.nextDrawable=null),t.nextDrawable=e,e.previousDrawable=t,t.markLinksDirty(i),e.markLinksDirty(i))}static disconnectBefore(t,e){t.previousDrawable&&(t.markLinksDirty(e),t.previousDrawable.markLinksDirty(e),t.previousDrawable.nextDrawable=null,t.previousDrawable=null)}static disconnectAfter(t,e){t.nextDrawable&&(t.markLinksDirty(e),t.nextDrawable.markLinksDirty(e),t.nextDrawable.previousDrawable=null,t.nextDrawable=null)}static listToArray(t,e){for(var i=[],s=t;i.push(s),s!==e;s=s.nextDrawable);return i}static oldListToArray(t,e){for(var i=[],s=t;i.push(s),s!==e;s=s.oldNextDrawable);return i}}bs.register("Drawable",gp);var vp=gp;class fp extends vp{constructor(t,e){super(),this.initialize(t,e)}initialize(t,e){return super.initialize(t),this.drawableVisibilityListener=this.drawableVisibilityListener||this.updateSelfVisibility.bind(this),this.instance=e,this.node=e.trail.lastNode(),this.node.attachDrawable(this),this.instance.selfVisibleEmitter.addListener(this.drawableVisibilityListener),this.updateSelfVisibility(),this}dispose(){this.instance.selfVisibleEmitter.removeListener(this.drawableVisibilityListener),this.node.detachDrawable(this),this.instance=null,this.node=null,super.dispose()}updateSelfVisibility(){this.visible=this.instance.selfVisible}toDetailedString(){return"".concat(this.toString()," (").concat(this.instance.trail.toPathString(),")")}}bs.register("SelfDrawable",fp);var yp=fp,bp=Ei(t=>class extends t{initialize(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;nclass extends t{initialize(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;nclass extends(wp(t)){initialize(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;nclass extends t{initialize(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;nclass extends(_p(t)){initialize(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;nclass extends(wp(t)){initialize(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;nclass extends(wp(t)){initialize(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;nclass extends(wp(t)){initialize(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;nclass extends(wp(t)){initialize(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;n=0&&-1===i&&t.removeAttribute("transform"),this.mipmapLevel=i,this.node._mipmap&&this.node.hasMipmaps()){var s=this.node.getMipmapURL(i),n=this.node.getMipmapCanvas(i);t.setAttribute("width","".concat(n.width,"px")),t.setAttribute("height","".concat(n.height,"px")),t.setAttribute("transform","scale(".concat(Math.pow(2,i).toFixed(20),")")),t.setAttributeNS(un,"xlink:href",s)}else t.setAttribute("width","".concat(this.node.getImageWidth(),"px")),t.setAttribute("height","".concat(this.node.getImageHeight(),"px")),t.setAttributeNS(un,"xlink:href",this.node.getImageURL())}updateMipmapStatus(t){this.usingMipmap!==t&&(this.usingMipmap=t,t?(this.instance.relativeTransform.addListener(this._mipmapTransformListener),this.instance.relativeTransform.addPrecompute()):(this.instance.relativeTransform.removeListener(this._mipmapTransformListener),this.instance.relativeTransform.removePrecompute()),this.markDirtyMipmap())}onMipmap(){this.markDirtyMipmap(),this.updateMipmapStatus(this.node._mipmap)}onMipmapTransform(){this.markDirtyMipmap()}dispose(){this.updateMipmapStatus(!1),this.node.mipmapEmitter.removeListener(this._mipmapListener),super.dispose()}}bs.register("ImageSVGDrawable",ag),Ui.mixInto(ag);var og=ag;class hg extends(Op(Ip)){initialize(t,e){super.initialize(t,e),this.vertexArray=this.vertexArray||new Float32Array(30),this.upperLeft=new Is(0,0),this.lowerLeft=new Is(0,0),this.upperRight=new Is(0,0),this.lowerRight=new Is(0,0),this.xyDirty=!0,this.uvDirty=!0,this.updatedOnce=!1,this.sprite=null}onAddToBlock(t){this.webglBlock=t,this.markDirty(),this.reserveSprite()}onRemoveFromBlock(t){this.unreserveSprite()}reserveSprite(){if(this.sprite){if(this.sprite.image===this.node._image)return;this.unreserveSprite()}var t=this.node.getImageWidth(),e=this.node.getImageHeight();this.sprite=t>0&&e>0?this.webglBlock.addSpriteSheetImage(this.node._image,t,e):null,this.xyDirty=!0,this.uvDirty=!0}unreserveSprite(){this.sprite&&this.webglBlock.removeSpriteSheetImage(this.sprite),this.sprite=null}markTransformDirty(){this.xyDirty=!0,super.markTransformDirty()}markPaintDirty(){this.xyDirty=!0,this.uvDirty=!0,this.markDirty()}update(){if(!super.update())return!1;if(this.reserveSprite(),!this.dirtyImageOpacity&&this.updatedOnce||(this.vertexArray[4]=this.node._imageOpacity,this.vertexArray[9]=this.node._imageOpacity,this.vertexArray[14]=this.node._imageOpacity,this.vertexArray[19]=this.node._imageOpacity,this.vertexArray[24]=this.node._imageOpacity,this.vertexArray[29]=this.node._imageOpacity),this.updatedOnce=!0,!this.sprite)return!1;if(this.uvDirty){this.uvDirty=!1;var t=this.sprite.uvBounds;this.vertexArray[2]=t.minX,this.vertexArray[3]=t.minY,this.vertexArray[7]=t.minX,this.vertexArray[8]=t.maxY,this.vertexArray[12]=t.maxX,this.vertexArray[13]=t.minY,this.vertexArray[17]=t.maxX,this.vertexArray[18]=t.minY,this.vertexArray[22]=t.minX,this.vertexArray[23]=t.maxY,this.vertexArray[27]=t.maxX,this.vertexArray[28]=t.maxY}if(this.xyDirty){this.xyDirty=!1;var e=this.node.getImageWidth(),i=this.node.getImageHeight(),s=this.instance.relativeTransform.matrix;s.multiplyVector2(this.upperLeft.setXY(0,0)),s.multiplyVector2(this.lowerLeft.setXY(0,i)),s.multiplyVector2(this.upperRight.setXY(e,0)),s.multiplyVector2(this.lowerRight.setXY(e,i)),this.vertexArray[0]=this.upperLeft.x,this.vertexArray[1]=this.upperLeft.y,this.vertexArray[5]=this.lowerLeft.x,this.vertexArray[6]=this.lowerLeft.y,this.vertexArray[10]=this.upperRight.x,this.vertexArray[11]=this.upperRight.y,this.vertexArray[15]=this.upperRight.x,this.vertexArray[16]=this.upperRight.y,this.vertexArray[20]=this.lowerLeft.x,this.vertexArray[21]=this.lowerLeft.y,this.vertexArray[25]=this.lowerRight.x,this.vertexArray[26]=this.lowerRight.y}return!0}}hg.prototype.webglRenderer=on.webglTexturedTriangles,bs.register("ImageWebGLDrawable",hg),Ui.mixInto(hg);var lg=hg;class dg extends(Np(Tp)){paintCanvas(t,e,i){var s=t.context;s.beginPath(),s.moveTo(e.x1,e.y1),s.lineTo(e.x2,e.y2),e.hasPaintableStroke()&&(e.beforeCanvasStroke(t),s.stroke(),e.afterCanvasStroke(t))}}bs.register("LineCanvasDrawable",dg),Ui.mixInto(dg);var ug=dg;class cg extends(Fp(Cp)){initialize(t,e){super.initialize(t,e,!0,!0),this.svgElement=this.svgElement||document.createElementNS(ln,"line")}updateSVGSelf(){var t=this.svgElement;this.dirtyX1&&t.setAttribute("x1",this.node.x1),this.dirtyY1&&t.setAttribute("y1",this.node.y1),this.dirtyX2&&t.setAttribute("x2",this.node.x2),this.dirtyY2&&t.setAttribute("y2",this.node.y2),this.updateFillStrokeStyle(t)}}bs.register("LineSVGDrawable",cg),Ui.mixInto(cg);var mg=cg;class pg extends(_p(Tp)){paintCanvas(t,e,i){var s=t.context;e.hasShape()&&(s.beginPath(),e._shape.writeToContext(s),e.hasFill()&&(e.beforeCanvasFill(t),s.fill(),e.afterCanvasFill(t)),e.hasPaintableStroke()&&(e.beforeCanvasStroke(t),s.stroke(),e.afterCanvasStroke(t)))}markDirtyShape(){this.markPaintDirty()}}bs.register("PathCanvasDrawable",pg),Ui.mixInto(pg);var gg=pg;class vg extends(Hp(Cp)){initialize(t,e){super.initialize(t,e,!0,!0),this.svgElement=this.svgElement||document.createElementNS(ln,"path")}updateSVGSelf(){var t=this.svgElement;if(this.dirtyShape){var e=this.node.hasShape()?this.node._shape.getSVGPath():"";e||(e="M0 0"),t.setAttribute("d",e)}this.updateFillStrokeStyle(t)}}bs.register("PathSVGDrawable",vg),Ui.mixInto(vg);var fg=vg;class yg extends(_p(Tp)){writeRectangularPath(t,e){t.beginPath(),t.moveTo(e._rectX,e._rectY),t.lineTo(e._rectX+e._rectWidth,e._rectY),t.lineTo(e._rectX+e._rectWidth,e._rectY+e._rectHeight),t.lineTo(e._rectX,e._rectY+e._rectHeight),t.closePath()}paintCanvas(t,e,i){var s=t.context;if(e.isRounded()){s.beginPath();var n=e.getMaximumArcSize(),r=Math.min(e._cornerXRadius,n),a=Math.min(e._cornerYRadius,n),o=e._rectX+r,h=e._rectX+e._rectWidth-r,l=e._rectY+a,d=e._rectY+e._rectHeight-a;r===a?(s.arc(h,l,r,-Math.PI/2,0,!1),s.arc(h,d,r,0,Math.PI/2,!1),s.arc(o,d,r,Math.PI/2,Math.PI,!1),s.arc(o,l,r,Math.PI,3*Math.PI/2,!1)):(s.ellipse(h,l,r,a,0,-Math.PI/2,0,!1),s.ellipse(h,d,r,a,0,0,Math.PI/2,!1),s.ellipse(o,d,r,a,0,Math.PI/2,Math.PI,!1),s.ellipse(o,l,r,a,0,Math.PI,3*Math.PI/2,!1)),s.closePath(),e.hasFill()&&(e.beforeCanvasFill(t),s.fill(),e.afterCanvasFill(t)),e.hasPaintableStroke()&&(e.beforeCanvasStroke(t),s.stroke(),e.afterCanvasStroke(t))}else e.hasFill()&&(e.getFillValue().transformMatrix?(this.writeRectangularPath(s,e),e.beforeCanvasFill(t),s.fill(),e.afterCanvasFill(t)):(e.beforeCanvasFill(t),s.fillRect(e._rectX,e._rectY,e._rectWidth,e._rectHeight),e.afterCanvasFill(t))),e.hasPaintableStroke()&&(e.getStrokeValue().transformMatrix?(this.writeRectangularPath(s,e),e.beforeCanvasStroke(t),s.stroke(),e.afterCanvasStroke(t)):(e.beforeCanvasStroke(t),s.strokeRect(e._rectX,e._rectY,e._rectWidth,e._rectHeight),e.afterCanvasStroke(t)))}markDirtyRectangle(){this.markPaintDirty()}markDirtyX(){this.markDirtyRectangle()}markDirtyY(){this.markDirtyRectangle()}markDirtyWidth(){this.markDirtyRectangle()}markDirtyHeight(){this.markDirtyRectangle()}markDirtyCornerXRadius(){this.markDirtyRectangle()}markDirtyCornerYRadius(){this.markDirtyRectangle()}}bs.register("RectangleCanvasDrawable",yg),Ui.mixInto(yg);var bg=yg,_g=wn.pool.fetch();class Pg extends(zp(Ap)){constructor(t,e){super(t,e),Rn.prepareForTransform(this.domElement)}initialize(t,e){if(super.initialize(t,e),!this.fillElement||!this.strokeElement){var i=document.createElement("div");this.fillElement=i,i.style.display="block",i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.pointerEvents="none";var s=document.createElement("div");this.strokeElement=s,s.style.display="block",s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.pointerEvents="none",i.appendChild(s)}this.domElement=this.fillElement}updateDOM(){var t=this.node,e=this.fillElement,i=this.strokeElement;if(this.paintDirty){var s=Math.min(t._cornerXRadius,t._cornerYRadius),n=this.dirtyCornerXRadius||this.dirtyCornerYRadius;if(this.dirtyWidth&&(e.style.width="".concat(t._rectWidth,"px")),this.dirtyHeight&&(e.style.height="".concat(t._rectHeight,"px")),n&&(e.style[Js.borderRadius]="".concat(s,"px")),this.dirtyFill&&(e.style.backgroundColor=t.getCSSFill()),this.dirtyStroke&&(t.hasStroke()?i.style.borderStyle="solid":i.style.borderStyle="none"),t.hasStroke()){var r=!this.hadStroke;(r||this.dirtyWidth||this.dirtyLineWidth)&&(i.style.width="".concat(t._rectWidth-t.getLineWidth(),"px")),(r||this.dirtyHeight||this.dirtyLineWidth)&&(i.style.height="".concat(t._rectHeight-t.getLineWidth(),"px")),(r||this.dirtyLineWidth)&&(i.style.left="".concat(-t.getLineWidth()/2,"px"),i.style.top="".concat(-t.getLineWidth()/2,"px"),i.style.borderWidth="".concat(t.getLineWidth(),"px")),(r||this.dirtyStroke)&&(i.style.borderColor=t.getSimpleCSSStroke()),(r||n||this.dirtyLineWidth||this.dirtyLineOptions)&&(i.style[Js.borderRadius]=t.isRounded()||"round"===t.getLineJoin()?"".concat(s+t.getLineWidth()/2,"px"):"0")}}if(this.transformDirty||this.dirtyX||this.dirtyY){_g.set(this.getTransformMatrix());var a=wn.translation(t._rectX,t._rectY);_g.multiplyMatrix(a),a.freeToPool(),Rn.applyPreparedTransform(_g,this.fillElement)}this.setToCleanState(),this.cleanPaintableState(),this.transformDirty=!1}dispose(){super.dispose()}}bs.register("RectangleDOMDrawable",Pg),Ui.mixInto(Pg);var wg=Pg;class xg extends(zp(Cp)){initialize(t,e){super.initialize(t,e,!0,!0),this.lastArcW=-1,this.lastArcH=-1,this.svgElement=this.svgElement||document.createElementNS(ln,"rect")}updateSVGSelf(){var t=this.svgElement;if(this.dirtyX&&t.setAttribute("x",this.node._rectX),this.dirtyY&&t.setAttribute("y",this.node._rectY),this.dirtyWidth&&t.setAttribute("width",this.node._rectWidth),this.dirtyHeight&&t.setAttribute("height",this.node._rectHeight),this.dirtyCornerXRadius||this.dirtyCornerYRadius||this.dirtyWidth||this.dirtyHeight){var e=0,i=0;if(this.node.isRounded()){var s=this.node.getMaximumArcSize();e=Math.min(this.node._cornerXRadius,s),i=Math.min(this.node._cornerYRadius,s)}e!==this.lastArcW&&(this.lastArcW=e,t.setAttribute("rx",e)),i!==this.lastArcH&&(this.lastArcH=i,t.setAttribute("ry",i))}this.updateFillStrokeStyle(t)}}bs.register("RectangleSVGDrawable",xg),Ui.mixInto(xg);var Tg=xg,Sg=new Us("transparent");class Ag extends(zp(Ip)){initialize(t,e){super.initialize(t,e),this.vertexArray||(this.vertexArray=new Float32Array(36)),this.upperLeft=new Is(0,0),this.lowerLeft=new Is(0,0),this.upperRight=new Is(0,0),this.lowerRight=new Is(0,0),this.transformDirty=!0,this.includeVertices=!0}onAddToBlock(t){this.webglBlock=t,this.markDirty()}onRemoveFromBlock(t){}markTransformDirty(){this.transformDirty=!0,super.markTransformDirty()}update(){if(!super.update())return!1;if(this.dirtyFill&&(this.includeVertices=this.node.hasFill(),this.includeVertices))for(var t=this.node.fill instanceof ce?this.node.fill.value:this.node.fill,e=Sg.set(t),i=e.red/255,s=e.green/255,n=e.blue/255,r=e.alpha,a=0;a<6;a++){var o=6*a;this.vertexArray[2+o]=i,this.vertexArray[3+o]=s,this.vertexArray[4+o]=n,this.vertexArray[5+o]=r}if(this.transformDirty||this.dirtyX||this.dirtyY||this.dirtyWidth||this.dirtyHeight){this.transformDirty=!1;var h=this.node._rectX,l=this.node._rectY,d=this.node._rectWidth,u=this.node._rectHeight,c=this.instance.relativeTransform.matrix;c.multiplyVector2(this.upperLeft.setXY(h,l)),c.multiplyVector2(this.lowerLeft.setXY(h,l+u)),c.multiplyVector2(this.upperRight.setXY(h+d,l)),c.multiplyVector2(this.lowerRight.setXY(h+d,l+u)),this.vertexArray[0]=this.upperLeft.x,this.vertexArray[1]=this.upperLeft.y,this.vertexArray[6]=this.lowerLeft.x,this.vertexArray[7]=this.lowerLeft.y,this.vertexArray[12]=this.upperRight.x,this.vertexArray[13]=this.upperRight.y,this.vertexArray[18]=this.upperRight.x,this.vertexArray[19]=this.upperRight.y,this.vertexArray[24]=this.lowerLeft.x,this.vertexArray[25]=this.lowerLeft.y,this.vertexArray[30]=this.lowerRight.x,this.vertexArray[31]=this.lowerRight.y}return this.setToCleanState(),this.cleanPaintableState(),!0}}Ag.prototype.webglRenderer=on.webglVertexColorPolygons,bs.register("RectangleWebGLDrawable",Ag),Ui.mixInto(Ag);var Eg=Ag;class Cg extends Tp{paintCanvas(t,e,i){for(var s=Jh.getApproximateMatrixScale(i)*(window.devicePixelRatio||1),n=e._spriteInstances.length,r=0;r{t.imageProperty.lazyLink(this.spriteChangeListener),this.addSpriteImage(t.imageProperty.value)}),this.hasDrawn=!1}addSpriteImage(t){this.spriteImageUVMap[t.id]=this.spriteSheet.addImage(t.image,t.image.width,t.image.height).uvBounds}removeSpriteImage(t){this.spriteSheet.removeImage(t.image),delete this.spriteImageUVMap[t.id]}onSpriteChange(t,e){this.removeSpriteImage(e),this.addSpriteImage(t)}setup(){var t=this.webGLBlock.gl;this.spriteSheet.initializeContext(t),this.shaderProgram=new ja(t,["attribute vec2 aVertex;","attribute vec2 aTextureCoord;","attribute float aAlpha;","varying vec2 vTextureCoord;","varying float vAlpha;","uniform mat3 uProjectionMatrix;","uniform mat3 uTransformMatrix;","void main() {"," vTextureCoord = aTextureCoord;"," vAlpha = aAlpha;"," vec3 ndc = uProjectionMatrix * ( uTransformMatrix * vec3( aVertex, 1.0 ) );"," gl_Position = vec4( ndc.xy, 0.0, 1.0 );","}"].join("\n"),["precision mediump float;","varying vec2 vTextureCoord;","varying float vAlpha;","uniform sampler2D uTexture;","void main() {"," vec4 color = texture2D( uTexture, vTextureCoord, -0.7 );"," color.a *= vAlpha;"," gl_FragColor = color;","}"].join("\n"),{attributes:["aVertex","aTextureCoord","aAlpha"],uniforms:["uTexture","uProjectionMatrix","uTransformMatrix"]}),this.vertexBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.DYNAMIC_DRAW)}onWebGLContextChange(){this.setup()}onAddToBlock(t){this.webGLBlock=t,this.setup(),t.glChangedEmitter.addListener(this.contextChangeListener)}onRemoveFromBlock(t){t.glChangedEmitter.removeListener(this.contextChangeListener)}draw(){var t=this.node._spriteInstances.length;if(0===t)return 0;this.spriteSheet.updateTexture(),this.shaderProgram.use();for(var e=0,i=!1;30*t>this.vertexArray.length;)this.vertexArray=new Float32Array(2*this.vertexArray.length),i=!0;for(var s=0;sthis.markDirty(),0),this.hasDrawn=!0,1}dispose(){this.node._sprites.forEach(t=>{t.imageProperty.unlink(this.spriteChangeListener)}),this.webGLBlock&&(this.webGLBlock=null),super.dispose()}markPaintDirty(){this.markDirty()}}Og.prototype.webglRenderer=on.webglCustom,bs.register("SpritesWebGLDrawable",Og),Ui.mixInto(Og);var Rg=Og;class Ng extends(_p(Tp)){paintCanvas(t,e,i){var s=t.context;(e.hasFill()||e.hasPaintableStroke())&&(t.setFont(e._font.getFont()),t.setDirection("ltr")),e.hasFill()&&(e.beforeCanvasFill(t),s.fillText(e.renderedText,0,0),e.afterCanvasFill(t)),e.hasPaintableStroke()&&(e.beforeCanvasStroke(t),s.strokeText(e.renderedText,0,0),e.afterCanvasStroke(t))}markDirtyText(){this.markPaintDirty()}markDirtyFont(){this.markPaintDirty()}markDirtyBounds(){this.markPaintDirty()}}bs.register("TextCanvasDrawable",Ng),Ui.mixInto(Ng);var Bg=Ng,Fg=wn.pool.fetch();class Vg extends(Up(Ap)){constructor(t,e){super(t,e),Rn.prepareForTransform(this.domElement)}initialize(t,e){super.initialize(t,e),this.domElement||(this.domElement=document.createElement("div"),this.domElement.style.display="block",this.domElement.style.position="absolute",this.domElement.style.pointerEvents="none",this.domElement.style.left="0",this.domElement.style.top="0",this.domElement.setAttribute("dir","ltr"))}updateDOM(){var t=this.node,e=this.domElement;if(this.paintDirty&&(this.dirtyFont&&(e.style.font=t.getFont()),this.dirtyStroke&&(e.style.color=t.getCSSFill()),this.dirtyBounds&&(e.style.width="".concat(t.getSelfBounds().width,"px"),e.style.height="".concat(t.getSelfBounds().height,"px")),this.dirtyText&&(e.textContent=t.renderedText)),this.transformDirty||this.dirtyText||this.dirtyFont||this.dirtyBounds){var i=t.getSelfBounds().minY;Fg.set(this.getTransformMatrix());var s=wn.translation(0,i);Fg.multiplyMatrix(s),s.freeToPool(),Rn.applyPreparedTransform(Fg,e)}this.setToCleanState(),this.cleanPaintableState(),this.transformDirty=!1}dispose(){super.dispose()}}bs.register("TextDOMDrawable",Vg),Ui.mixInto(Vg);var Hg=Vg,Yg=!Yi.edge;class zg extends(Up(Cp)){initialize(t,e){if(super.initialize(t,e,!0,!0),this.hasLength=!1,!this.svgElement){var i=document.createElementNS(ln,"text");this.svgElement=i,i.appendChild(document.createTextNode("")),i.setAttribute("dominant-baseline","alphabetic"),i.setAttribute("text-rendering","geometricPrecision"),i.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),i.setAttribute("direction","ltr")}}updateSVGSelf(){var t=this.svgElement;(this.dirtyFont&&(t.setAttribute("font-family",this.node._font.getFamily()),t.setAttribute("font-size",this.node._font.getSize()),t.setAttribute("font-style",this.node._font.getStyle()),t.setAttribute("font-weight",this.node._font.getWeight()),t.setAttribute("font-stretch",this.node._font.getStretch())),this.dirtyText&&(t.lastChild.nodeValue=Rn.safariEmbeddingMarkWorkaround(this.node.renderedText)),this.dirtyBounds&&Yg)&&("accurate"!==this.node._boundsMethod&&isFinite(this.node.selfBounds.width)?(this.hasLength||(this.hasLength=!0,t.setAttribute("lengthAdjust","spacingAndGlyphs")),t.setAttribute("textLength",this.node.selfBounds.width)):this.hasLength&&(this.hasLength=!1,t.removeAttribute("lengthAdjust"),t.removeAttribute("textLength")));this.updateFillStrokeStyle(t)}}bs.register("TextSVGDrawable",zg),Ui.mixInto(zg);var Wg=zg;class Ug extends Ip{initialize(t,e){super.initialize(t,e),this.contextChangeListener=this.contextChangeListener||this.onWebGLContextChange.bind(this),this.painter=null}createPainter(){return new(0,this.node.painterType)(this.webGLBlock.gl,this.node)}onWebGLContextChange(){this.painter=this.createPainter()}onAddToBlock(t){this.webGLBlock=t,this.painter=this.createPainter(),t.glChangedEmitter.addListener(this.contextChangeListener)}onRemoveFromBlock(t){t.glChangedEmitter.removeListener(this.contextChangeListener)}draw(){var t=this.instance.relativeTransform.matrix,e=this.painter.paint(t,this.webGLBlock.projectionMatrix);return e}dispose(){this.painter.dispose(),this.painter=null,this.webGLBlock&&(this.webGLBlock=null),super.dispose()}markPaintDirty(){this.markDirty()}get shaderAttributes(){return this.node.shaderAttributes}}Ug.prototype.webglRenderer=on.webglCustom,bs.register("WebGLNodeDrawable",Ug),Ui.mixInto(Ug);var Gg=Ug;class Xg extends vp{constructor(t,e){super(),this.initialize(t,e)}initialize(t,e){super.initialize(t),this.instance=e}stitch(t,e,i,s){}}bs.register("InlineCanvasCacheDrawable",Xg);var jg=Xg;class qg extends vp{constructor(t,e,i,s){super(),this.initialize(t,e,i,s)}initialize(t,e,i,s){super.initialize(e),this.instance=i,this.sharedInstance=s}}bs.register("SharedCanvasCacheDrawable",qg);var Kg=qg;class Zg{constructor(t){this.instance=t}initialize(t,e){return this.display=t,this.trail=e,this.node=e&&e.lastNode(),this.transformDirty=!0,this.nodeTransformListener=this.nodeTransformListener||this.onNodeTransformDirty.bind(this),this.matrix=this.matrix||wn.identity(),this.relativeSelfDirty=!0,this.relativeChildrenListenersCount=0,this.relativePrecomputeCount=0,this.relativeChildrenPrecomputeCount=0,this.relativeFrameId=-1,this.relativeChildDirtyFrame=t?t._frameId:0,this.relativeTransformListeners=ri(this.relativeTransformListeners),this}get parent(){return this.instance.parent?this.instance.parent.relativeTransform:null}addInstance(t){t.stateless||(t.relativeTransform.hasAncestorListenerNeed()&&this.incrementTransformListenerChildren(),t.relativeTransform.hasAncestorComputeNeed()&&this.incrementTransformPrecomputeChildren()),t.relativeTransform.forceMarkTransformDirty()}removeInstance(t){t.relativeTransform.hasAncestorListenerNeed()&&this.decrementTransformListenerChildren(),t.relativeTransform.hasAncestorComputeNeed()&&this.decrementTransformPrecomputeChildren()}attachNodeListeners(){this.node.transformEmitter.addListener(this.nodeTransformListener)}detachNodeListeners(){this.node.transformEmitter.removeListener(this.nodeTransformListener)}hasDescendantListenerNeed(){return this.instance.isTransformed?this.relativeChildrenListenersCount>0:this.relativeChildrenListenersCount>0||this.relativeTransformListeners.length>0}hasAncestorListenerNeed(){return this.instance.isTransformed?this.relativeTransformListeners.length>0:this.relativeChildrenListenersCount>0||this.relativeTransformListeners.length>0}hasSelfListenerNeed(){return this.relativeTransformListeners.length>0}incrementTransformListenerChildren(){var t=this.hasAncestorListenerNeed();this.relativeChildrenListenersCount++,t!==this.hasAncestorListenerNeed()&&this.parent&&this.parent.incrementTransformListenerChildren()}decrementTransformListenerChildren(){var t=this.hasAncestorListenerNeed();this.relativeChildrenListenersCount--,t!==this.hasAncestorListenerNeed()&&this.parent&&this.parent.decrementTransformListenerChildren()}addListener(t){var e=this.hasAncestorListenerNeed();this.relativeTransformListeners.push(t),e!==this.hasAncestorListenerNeed()&&(this.parent&&this.parent.incrementTransformListenerChildren(),this.hasAncestorComputeNeed()||this.forceMarkTransformDirty())}removeListener(t){var e=this.hasAncestorListenerNeed();this.relativeTransformListeners.splice(_.indexOf(this.relativeTransformListeners,t),1),e!==this.hasAncestorListenerNeed()&&this.parent&&this.parent.decrementTransformListenerChildren()}hasDescendantComputeNeed(){return this.instance.isTransformed?this.relativeChildrenPrecomputeCount>0:this.relativeChildrenPrecomputeCount>0||this.relativePrecomputeCount>0}hasAncestorComputeNeed(){return this.instance.isTransformed?this.relativePrecomputeCount>0:this.relativeChildrenPrecomputeCount>0||this.relativePrecomputeCount>0}hasSelfComputeNeed(){return this.relativePrecomputeCount>0}incrementTransformPrecomputeChildren(){var t=this.hasAncestorComputeNeed();this.relativeChildrenPrecomputeCount++,t!==this.hasAncestorComputeNeed()&&this.parent&&this.parent.incrementTransformPrecomputeChildren()}decrementTransformPrecomputeChildren(){var t=this.hasAncestorComputeNeed();this.relativeChildrenPrecomputeCount--,t!==this.hasAncestorComputeNeed()&&this.parent&&this.parent.decrementTransformPrecomputeChildren()}addPrecompute(){var t=this.hasAncestorComputeNeed();this.relativePrecomputeCount++,t!==this.hasAncestorComputeNeed()&&(this.parent&&this.parent.incrementTransformPrecomputeChildren(),this.hasAncestorListenerNeed()||this.forceMarkTransformDirty())}removePrecompute(){var t=this.hasAncestorComputeNeed();this.relativePrecomputeCount--,t!==this.hasAncestorComputeNeed()&&this.parent&&this.parent.decrementTransformPrecomputeChildren()}onNodeTransformDirty(){this.transformDirty||this.forceMarkTransformDirty()}forceMarkTransformDirty(){this.transformDirty=!0,this.relativeSelfDirty=!0;for(var t=this.display._frameId,e=this.instance.parent;e&&e.relativeTransform.relativeChildDirtyFrame!==t;){var i=e.parent,s=e.isTransformed;if(e.relativeTransform.relativeChildDirtyFrame=t,null===i){this.display.markTransformRootDirty(e,s);break}if(s){this.display.markTransformRootDirty(e,!0);break}e=i}}computeRelativeTransform(){var t=this.node.getMatrix();this.instance.parent&&!this.instance.parent.isTransformed?(this.matrix.set(this.parent.matrix),this.matrix.multiplyMatrix(t)):this.matrix.set(t),this.relativeFrameId=this.display._frameId,this.relativeSelfDirty=!1}isValidationNotNeeded(){return this.hasAncestorComputeNeed()||this.relativeFrameId===this.display._frameId}validate(){if(!this.isValidationNotNeeded()&&(this.instance.parent&&!this.instance.parent.isTransformed&&this.parent.validate(),this.relativeSelfDirty)){this.computeRelativeTransform();for(var t=this.instance.children.length,e=0;e0&&this.incrementSubtreeUnfittableCount()}onRemove(t){this.ancestorsFittable||t.markSubtreeFittable(),t.subtreeUnfittableCount>0&&this.decrementSubtreeUnfittableCount()}audit(){}}bs.register("Fittability",tv);var ev=tv,iv=1;class sv{constructor(t,e,i){this.id="group".concat(iv++),this.initialize(t,e,i)}initialize(t,e,i){this.block=t,this.instance=e,this.node=e.trail.lastNode(),this.parent=i,this.children=ri(this.children),this.hasSelfDrawable=!1,this.selfDrawable=null,this.dirty=!0,this.willApplyTransforms=this.block.transformRootInstance.trail.nodes.length=0;g--){var v=p[g].lookupSVGGroup(this.block);if(v){if(this.children[m]!==v){t.insertBefore(v.svgGroup,m+1>=this.children.length?null:this.children[m+1].svgGroup);var f=_.indexOf(this.children,v);this.children.splice(f,1),this.children.splice(m,0,v)}m--}}}}}isReleasable(){return!this.hasSelfDrawable&&!this.children.length&&this.parent}dispose(){this.hasFilter&&(this.svgGroup.removeAttribute("filter"),this.hasFilter=!1,this.block.defs.removeChild(this.filterElement)),this.willApplyTransforms&&this.node.transformEmitter.removeListener(this.transformDirtyListener),this.node.visibleProperty.unlink(this.visibilityDirtyListener),this.willApplyFilters&&this.node.filterChangeEmitter.removeListener(this.filterChangeListener),this.node.clipAreaProperty.unlink(this.clipDirtyListener),this.node.childrenChangedEmitter.removeListener(this.orderDirtyListener),this.instance.active&&this.instance.removeSVGGroup(this),this.clipDefinition&&(this.svgGroup.removeAttribute("clip-path"),this.block.defs.removeChild(this.clipDefinition),this.clipDefinition=null,this.clipPath=null),this.parent=null,this.block=null,this.instance=null,this.node=null,ri(this.children),this.selfDrawable=null,this.freeToPool()}toString(){return"SVGGroup:".concat(this.block.toString(),"_").concat(this.instance.toString())}static addDrawable(t,e){sv.ensureGroupsToInstance(t,e.instance).addSelfDrawable(e)}static removeDrawable(t,e){e.instance.lookupSVGGroup(t).removeSelfDrawable(e),sv.releaseGroupsToInstance(t,e.instance)}static ensureGroupsToInstance(t,e){var i=e.lookupSVGGroup(t);if(!i){var s=sv.ensureGroupsToInstance(t,e.parent);i=sv.createFromPool(t,e,s),s.addChildGroup(i)}return i}static releaseGroupsToInstance(t,e){var i=e.lookupSVGGroup(t);if(i.isReleasable()){var s=i.parent;s.removeChildGroup(i),sv.releaseGroupsToInstance(t,s.instance),i.dispose()}}}bs.register("SVGGroup",sv),Ui.mixInto(sv);var nv=sv;class rv extends vp{initialize(t,e){super.initialize(e),this.display=t,this.drawableCount=0,this.used=!0,this.firstDrawable=null,this.lastDrawable=null,this.pendingFirstDrawable=null,this.pendingLastDrawable=null,this.previousBlock=null,this.nextBlock=null,this.zIndex=0}dispose(){this.display=null,this.firstDrawable=null,this.lastDrawable=null,this.pendingFirstDrawable=null,this.pendingLastDrawable=null,this.previousBlock=null,this.nextBlock=null,super.dispose()}addDrawable(t){this.drawableCount++,this.markDirtyDrawable(t)}removeDrawable(t){this.drawableCount--,this.markDirty()}onIntervalChange(t,e){}updateInterval(){this.pendingFirstDrawable===this.firstDrawable&&this.pendingLastDrawable===this.lastDrawable||(this.onIntervalChange(this.pendingFirstDrawable,this.pendingLastDrawable),this.firstDrawable=this.pendingFirstDrawable,this.lastDrawable=this.pendingLastDrawable)}notifyInterval(t,e){this.pendingFirstDrawable=t,this.pendingLastDrawable=e,this.updateInterval()}audit(t,e,i){}}bs.register("Block",rv);var av=rv,ov=mn.NOTHING.copy();class hv extends av{initialize(t,e,i,s){return super.initialize(t,e),this.transformRootInstance=i,this.canBeFullDisplay=i.isDisplayRoot,this.preferredFit=s,this.fit=s,this.dirtyFit=!0,this.commonFitInstance=null,this.fitBounds=mn.NOTHING.copy(),this.oldFitBounds=mn.NOTHING.copy(),this.unfittableDrawableCount=0,this.dirtyFitListener=this.dirtyFitListener||this.markDirtyFit.bind(this),this.fittableListener=this.fittableListener||this.onFittabilityChange.bind(this),this.display.sizeProperty.lazyLink(this.dirtyFitListener),this}setFit(t){this.canBeFullDisplay||t!==hv.FULL_DISPLAY||(t=hv.COMMON_ANCESTOR),this.fit!==t&&(this.fit=t,this.markDirtyFit(),this.oldFitBounds.set(mn.NOTHING),t===hv.COMMON_ANCESTOR&&this.removeCommonFitInstance())}markDirtyFit(){this.dirtyFit=!0,this.markDirty()}updateFit(){if(this.dirtyFit||this.fit!==hv.FULL_DISPLAY)if(this.dirtyFit=!1,this.fit===hv.COMMON_ANCESTOR&&null===this.commonFitInstance&&this.addCommonFitInstance(this.computeCommonAncestorInstance()),this.fit===hv.COMMON_ANCESTOR&&this.commonFitInstance.fittability.subtreeUnfittableCount>0&&this.canBeFullDisplay&&(this.oldFitBounds.set(mn.NOTHING),this.fit=hv.FULL_DISPLAY),this.fit===hv.FULL_DISPLAY)this.fitBounds.set(mn.NOTHING),this.setSizeFullDisplay();else{if(this.fit!==hv.COMMON_ANCESTOR)throw new Error("unknown fit");this.fitBounds.set(this.commonFitInstance.node.getLocalBounds());for(var t=this.commonFitInstance;t!==this.transformRootInstance;)this.fitBounds.transform(t.node.getMatrix()),t=t.parent;this.fitBounds.roundOut(),this.fitBounds.dilate(4),this.transformRootInstance.isDisplayRoot&&(ov.setMinMax(0,0,this.display.width,this.display.height),this.fitBounds.constrainBounds(ov)),this.fitBounds.isValid()||this.fitBounds.setMinMax(0,0,0,0),this.fitBounds.equals(this.oldFitBounds)||(this.oldFitBounds.set(this.fitBounds),this.setSizeFitBounds())}}setSizeFullDisplay(){}setSizeFitBounds(){}addCommonFitInstance(t){t&&(this.commonFitInstance=t,this.commonFitInstance.fittability.subtreeFittabilityChangeEmitter.addListener(this.dirtyFitListener))}removeCommonFitInstance(){this.commonFitInstance&&(this.commonFitInstance.fittability.subtreeFittabilityChangeEmitter.removeListener(this.dirtyFitListener),this.commonFitInstance=null)}dispose(){this.display.sizeProperty.unlink(this.dirtyFitListener),this.removeCommonFitInstance(),this.transformRootInstance=null,super.dispose()}addDrawable(t){super.addDrawable(t),t.fittableProperty.lazyLink(this.fittableListener),t.fittable||this.incrementUnfittable()}removeDrawable(t){super.removeDrawable(t),t.fittableProperty.unlink(this.fittableListener),t.fittable||this.decrementUnfittable()}onFittabilityChange(t){t?this.decrementUnfittable():this.incrementUnfittable()}incrementUnfittable(){this.unfittableDrawableCount++,1===this.unfittableDrawableCount&&this.checkFitConstraints()}decrementUnfittable(){this.unfittableDrawableCount--,0===this.unfittableDrawableCount&&this.checkFitConstraints()}checkFitConstraints(){this.unfittableDrawableCount>0&&this.canBeFullDisplay?this.setFit(hv.FULL_DISPLAY):this.setFit(this.preferredFit)}computeCommonAncestorInstance(){for(var t=this.firstDrawable.instance,e=this.lastDrawable.instance,i=Math.min(t.trail.length,e.trail.length);t.trail.length>i;)t=t.parent;for(;e.trail.length>i;)e=e.parent;for(;t!==e;)t=t.parent,e=e.parent;return t}onIntervalChange(t,e){super.onIntervalChange(t,e),this.fit===hv.COMMON_ANCESTOR&&(this.removeCommonFitInstance(),this.markDirtyFit())}}bs.register("FittedBlock",hv),hv.FULL_DISPLAY=1,hv.COMMON_ANCESTOR=2,hv.fitString={1:"fullDisplay",2:"commonAncestor"};var lv=hv,dv=new wn,uv=new wn;class cv extends lv{constructor(t,e,i,s){super(),this.initialize(t,e,i,s)}initialize(t,e,i,s){super.initialize(t,e,i,lv.COMMON_ANCESTOR),this.filterRootInstance=s,this.dirtyDrawables=ri(this.dirtyDrawables),this.domElement||(this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.left="0",this.canvas.style.top="0",this.canvas.style.pointerEvents="none",this.canvasId=this.canvas.id="scenery-canvas".concat(this.id),this.context=this.canvas.getContext("2d"),this.context.save(),this.context.miterLimit=20,this.context.miterLimit=10,this.wrapper=new rr(this.canvas,this.context),this.domElement=this.canvas,this.wrapperStack=[this.wrapper]),this.wrapperStackIndex=0,this.filterListenerCountMap=this.filterListenerCountMap||{},Rn.prepareForTransform(this.canvas),Rn.unsetTransform(this.canvas),this.canvasDrawOffset=new Is(0,0),this.currentDrawable=null,this.clipDirty=!0,this.clipCount=0,this.backingScale=e&on.bitmaskCanvasLowResolution?1:Rn.backingScale(this.context),this.clipDirtyListener=this.markDirty.bind(this),this.opacityDirtyListener=this.markDirty.bind(this)}setSizeFullDisplay(){var t=this.display.getSize();this.canvas.width=t.width*this.backingScale,this.canvas.height=t.height*this.backingScale,this.canvas.style.width="".concat(t.width,"px"),this.canvas.style.height="".concat(t.height,"px"),this.wrapper.resetStyles(),this.canvasDrawOffset.setXY(0,0),Rn.unsetTransform(this.canvas)}setSizeFitBounds(){var t=this.fitBounds.minX,e=this.fitBounds.minY;this.canvasDrawOffset.setXY(-t,-e),Rn.setTransform("matrix(1,0,0,1,".concat(t,",").concat(e,")"),this.canvas),this.canvas.width=this.fitBounds.width*this.backingScale,this.canvas.height=this.fitBounds.height*this.backingScale,this.canvas.style.width="".concat(this.fitBounds.width,"px"),this.canvas.style.height="".concat(this.fitBounds.height,"px"),this.wrapper.resetStyles()}update(){if(!super.update())return!1;for(;this.dirtyDrawables.length;)this.dirtyDrawables.pop().update();this.updateFit(),this.context.restore(),this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.save(),this.wrapper.resetStyles(),this.currentDrawable=null;for(var t=this.firstDrawable;null!==t&&(this.renderDrawable(t),t!==this.lastDrawable);t=t.nextDrawable);return this.currentDrawable&&this.walkDown(this.currentDrawable.instance.trail,0),!0}applyClip(t){this.clipDirty=!1;var e=this.wrapperStack[this.wrapperStackIndex],i=e.context;if(i.restore(),i.save(),e.resetStyles(),this.clipCount){var s=t.instance.trail;dv.rowMajor(this.backingScale,0,this.canvasDrawOffset.x*this.backingScale,0,this.backingScale,this.canvasDrawOffset.y*this.backingScale,0,0,1),uv.set(this.transformRootInstance.trail.getMatrix()).invert(),uv.multiplyMatrix(dv).canvasSetTransform(i);for(var n=0;n=e;s--){var n=t.nodes[s];if(n.hasClipArea()&&(this.clipCount--,this.clipDirty=!0),s>i){if(n._filters.length){var r=this.wrapperStack[this.wrapperStackIndex],a=this.wrapperStack[this.wrapperStackIndex-1];this.popWrapper(),a.context.setTransform(1,0,0,1,0,0);for(var o=n._filters,h=Js.canvasFilter,l=0;li&&(1!==n.getEffectiveOpacity()&&this.pushWrapper(),n._filters.length&&this.pushWrapper()),n.hasClipArea()&&(this.clipCount++,this.clipDirty=!0)}}renderDrawable(t){if(t.visible&&0!==this.canvas.width&&0!==this.canvas.height){var e=this.currentDrawable?t.instance.getBranchIndexTo(this.currentDrawable.instance):0;this.currentDrawable&&this.walkDown(this.currentDrawable.instance.trail,e),this.walkUp(t.instance.trail,e);var i=this.wrapperStack[this.wrapperStackIndex],s=i.context;this.clipDirty&&this.applyClip(t);var n=t.instance.relativeTransform.matrix;s.setTransform(this.backingScale,0,0,this.backingScale,this.canvasDrawOffset.x*this.backingScale,this.canvasDrawOffset.y*this.backingScale),t.instance!==this.transformRootInstance&&n.canvasAppendTransform(s),t.paintCanvas(i,t.instance.node,t.instance.relativeTransform.matrix),this.currentDrawable=t}}dispose(){this.transformRootInstance=null,ri(this.dirtyDrawables),this.canvas.width=0,this.canvas.height=0,super.dispose()}markDirtyDrawable(t){this.dirtyDrawables.push(t),this.markDirty()}addDrawable(t){super.addDrawable(t);for(var e=t.instance;e&&e!==this.filterRootInstance;e=e.parent){var i=e.node;this.filterListenerCountMap[i.id]?this.filterListenerCountMap[i.id]++:(this.filterListenerCountMap[i.id]=1,i.filterChangeEmitter.addListener(this.opacityDirtyListener),i.clipAreaProperty.lazyLink(this.clipDirtyListener))}}removeDrawable(t){for(var e=t.instance;e&&e!==this.filterRootInstance;e=e.parent){var i=e.node;this.filterListenerCountMap[i.id]--,0===this.filterListenerCountMap[i.id]&&(delete this.filterListenerCountMap[i.id],i.clipAreaProperty.unlink(this.clipDirtyListener),i.filterChangeEmitter.removeListener(this.opacityDirtyListener))}super.removeDrawable(t)}onIntervalChange(t,e){super.onIntervalChange(t,e),this.markDirty()}onPotentiallyMovedDrawable(t){t.markDirty()}toString(){return"CanvasBlock#".concat(this.id,"-").concat(lv.fitString[this.fit])}}bs.register("CanvasBlock",cv),Ui.mixInto(cv);var mv=cv;class pv extends av{constructor(t,e){super(),this.initialize(t,e)}initialize(t,e){return super.initialize(t,e.renderer),this.domDrawable=e,this.domElement=e.domElement,this}update(){return!!super.update()&&(this.domDrawable.update(),!0)}dispose(){this.domDrawable=null,this.domElement=null,super.dispose()}markDirtyDrawable(t){this.markDirty()}addDrawable(t){super.addDrawable(t)}removeDrawable(t){super.removeDrawable(t)}}bs.register("DOMBlock",pv),Ui.mixInto(pv);var gv=pv;class vv extends lv{constructor(t,e,i,s){super(),this.initialize(t,e,i,s)}initialize(t,e,i,s){super.initialize(t,e,i,lv.COMMON_ANCESTOR),this.filterRootInstance=s,this.dirtyGradients=ri(this.dirtyGradients),this.dirtyGroups=ri(this.dirtyGroups),this.dirtyDrawables=ri(this.dirtyDrawables),this.paintCountMap=this.paintCountMap||new pr(this.onAddPaint.bind(this),this.onRemovePaint.bind(this)),this.areReferencesReduced=!0,this.domElement||(this.svg=document.createElementNS(ln,"svg"),this.svg.style.position="absolute",this.svg.style.left="0",this.svg.style.top="0",this.svg.setAttribute("focusable",!1),this.svg.style["pointer-events"]="none",this.defs=document.createElementNS(ln,"defs"),this.svg.appendChild(this.defs),this.baseTransformGroup=document.createElementNS(ln,"g"),this.svg.appendChild(this.baseTransformGroup),this.domElement=this.svg),Rn.prepareForTransform(this.svg),Rn.unsetTransform(this.svg),this.baseTransformGroup.setAttribute("transform","");var n=i.trail.nodes.length>s.trail.nodes.length?s:i;return this.rootGroup=nv.createFromPool(this,n,null),this.baseTransformGroup.appendChild(this.rootGroup.svgGroup),this}onAddPaint(t){var e=t.createSVGPaint(this);return e.definition.setAttribute("id","".concat(t.id,"-").concat(this.id)),this.defs.appendChild(e.definition),e}onRemovePaint(t,e){this.defs.removeChild(e.definition),e.dispose()}incrementPaint(t){this.paintCountMap.increment(t)}decrementPaint(t){this.paintCountMap.decrement(t)}markDirtyGradient(t){this.dirtyGradients.push(t),this.markDirty()}markDirtyGroup(t){this.dirtyGroups.push(t),this.markDirty(),this.areReferencesReduced&&this.display.markForReducedReferences(this),this.areReferencesReduced=!1}markDirtyDrawable(t){this.dirtyDrawables.push(t),this.markDirty(),this.areReferencesReduced&&this.display.markForReducedReferences(this),this.areReferencesReduced=!1}setSizeFullDisplay(){this.baseTransformGroup.removeAttribute("transform"),Rn.unsetTransform(this.svg);var t=this.display.getSize();this.svg.setAttribute("width",t.width),this.svg.setAttribute("height",t.height)}setSizeFitBounds(){var t=this.fitBounds.minX,e=this.fitBounds.minY;this.baseTransformGroup.setAttribute("transform","translate(".concat(-t,",").concat(-e,")")),Rn.setTransform("matrix(1,0,0,1,".concat(t,",").concat(e,")"),this.svg),this.svg.setAttribute("width",this.fitBounds.width),this.svg.setAttribute("height",this.fitBounds.height)}update(){if(!super.update())return!1;for(;this.dirtyGroups.length;){var t=this.dirtyGroups.pop();t.block===this&&t.update()}for(;this.dirtyGradients.length;)this.dirtyGradients.pop().update();for(;this.dirtyDrawables.length;){var e=this.dirtyDrawables.pop();e.parentDrawable===this&&e.update()}return this.areReferencesReduced=!0,this.updateFit(),!0}reduceReferences(){if(!this.areReferencesReduced){for(var t=0,e=0;te;)this.dirtyGroups.pop();for(t=0,e=0;te;)this.dirtyDrawables.pop();this.areReferencesReduced=!0}}dispose(){for(this.svg.setAttribute("width","0"),this.svg.setAttribute("height","0"),this.filterRootInstance=null,ri(this.dirtyGradients),ri(this.dirtyGroups),ri(this.dirtyDrawables),this.paintCountMap.clear(),this.baseTransformGroup.removeChild(this.rootGroup.svgGroup),this.rootGroup.dispose(),this.rootGroup=null;this.defs.childNodes.length;)this.defs.removeChild(this.defs.childNodes[0]);super.dispose()}addDrawable(t){super.addDrawable(t),nv.addDrawable(this,t),t.updateSVGBlock(this)}removeDrawable(t){nv.removeDrawable(this,t),super.removeDrawable(t)}onIntervalChange(t,e){super.onIntervalChange(t,e)}toString(){return"SVGBlock#".concat(this.id,"-").concat(lv.fitString[this.fit])}}bs.register("SVGBlock",vv),Ui.mixInto(vv);var fv=vv;class yv extends lv{constructor(t,e,i,s){super(),this.initialize(t,e,i,s)}initialize(t,e,i,s){return super.initialize(t,e,i,lv.FULL_DISPLAY),this.filterRootInstance=s,this.preserveDrawingBuffer=t._preserveDrawingBuffer,this.dirtyDrawables=ri(this.dirtyDrawables),this.spriteSheets=this.spriteSheets||[],this.projectionMatrix=this.projectionMatrix||new wn,this.projectionMatrixArray=new Float32Array(9),this.customProcessor=this.customProcessor||new _v,this.vertexColorPolygonsProcessor=this.vertexColorPolygonsProcessor||new Pv(this.projectionMatrixArray),this.texturedTrianglesProcessor=this.texturedTrianglesProcessor||new wv(this.projectionMatrixArray),this.glChangedEmitter=new c,this.isContextLost=!1,this.contextLostListener=this.onContextLoss.bind(this),this.contextRestoreListener=this.onContextRestoration.bind(this),this.domElement||(this.domElement=document.createElement("div"),this.domElement.className="webgl-container",this.domElement.style.position="absolute",this.domElement.style.left="0",this.domElement.style.top="0",this.rebuildCanvas()),this.gl.clear(this.gl.COLOR_BUFFER_BIT),Rn.prepareForTransform(this.canvas),Rn.unsetTransform(this.canvas),this}rebuildCanvas(){var t=document.createElement("canvas"),e=this.getContextFromCanvas(t);e&&(this.canvas&&(this.domElement.removeChild(this.canvas),this.canvas.removeEventListener("webglcontextlost",this.contextLostListener,!1),this.canvas.removeEventListener("webglcontextrestored",this.contextRestoreListener,!1)),this.canvas=t,this.canvas.style.pointerEvents="none",this.canvasId=this.canvas.id="scenery-webgl".concat(this.id),this.canvas.addEventListener("webglcontextlost",this.contextLostListener,!1),this.canvas.addEventListener("webglcontextrestored",this.contextRestoreListener,!1),this.domElement.appendChild(this.canvas),this.setupContext(e))}setupContext(t){this.isContextLost=!1,this.gl=t,this.backingScale=Rn.backingScale(this.gl),this.display._allowBackingScaleAntialiasing&&0===t.getParameter(t.SAMPLES)&&(this.backingScale*=2),this.originalBackingScale=this.backingScale,Rn.applyWebGLContextDefaults(this.gl),this.markDirty(),this.dirtyFit=!0,this.customProcessor.initializeContext(this.gl),this.vertexColorPolygonsProcessor.initializeContext(this.gl),this.texturedTrianglesProcessor.initializeContext(this.gl);for(var e=0;e=0;)this.dirtyDrawables.splice(e,1);t.onRemoveFromBlock(this),super.removeDrawable(t)}addSpriteSheetImage(t,e,i){for(var s=null,n=this.spriteSheets.length,r=0;rthis.vertexArray.length;){var i=new Float32Array(2*this.vertexArray.length);i.set(this.vertexArray),this.vertexArray=i}this.vertexArray.set(e,this.vertexArrayIndex),this.vertexArrayIndex+=e.length,this.drawCount++}}deactivate(){return this.drawCount&&this.draw(),this.shaderProgram.unuse(),this.drawCount}draw(){var t=this.gl;t.uniformMatrix3fv(this.shaderProgram.uniformLocations.uProjectionMatrix,!1,this.projectionMatrixArray),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray.length>this.lastArrayLength?t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.DYNAMIC_DRAW):t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray.subarray(0,this.vertexArrayIndex));var e=Float32Array.BYTES_PER_ELEMENT,i=6*e;t.vertexAttribPointer(this.shaderProgram.attributeLocations.aVertex,2,t.FLOAT,!1,i,0*e),t.vertexAttribPointer(this.shaderProgram.attributeLocations.aColor,4,t.FLOAT,!1,i,2*e),t.drawArrays(t.TRIANGLES,0,this.vertexArrayIndex/6),this.vertexArrayIndex=0}}class wv extends bv{constructor(t){super(),this.projectionMatrixArray=t,this.lastArrayLength=128,this.vertexArray=new Float32Array(this.lastArrayLength)}initializeContext(t){this.gl=t,this.shaderProgram=new ja(t,["attribute vec2 aVertex;","attribute vec2 aTextureCoord;","attribute float aAlpha;","varying vec2 vTextureCoord;","varying float vAlpha;","uniform mat3 uProjectionMatrix;","void main() {"," vTextureCoord = aTextureCoord;"," vAlpha = aAlpha;"," vec3 ndc = uProjectionMatrix * vec3( aVertex, 1.0 );"," gl_Position = vec4( ndc.xy, 0.0, 1.0 );","}"].join("\n"),["precision mediump float;","varying vec2 vTextureCoord;","varying float vAlpha;","uniform sampler2D uTexture;","void main() {"," vec4 color = texture2D( uTexture, vTextureCoord, -0.7 );"," color.a *= vAlpha;"," gl_FragColor = color;","}"].join("\n"),{attributes:["aVertex","aTextureCoord","aAlpha"],uniforms:["uTexture","uProjectionMatrix"]}),this.vertexBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.DYNAMIC_DRAW)}activate(){this.shaderProgram.use(),this.currentSpriteSheet=null,this.vertexArrayIndex=0,this.drawCount=0}processDrawable(t){if(t.sprite){this.currentSpriteSheet&&t.sprite.spriteSheet!==this.currentSpriteSheet&&this.draw(),this.currentSpriteSheet=t.sprite.spriteSheet;for(var e=t.vertexArray;e.length+this.vertexArrayIndex>this.vertexArray.length;){var i=new Float32Array(2*this.vertexArray.length);i.set(this.vertexArray),this.vertexArray=i}this.vertexArray.set(e,this.vertexArrayIndex),this.vertexArrayIndex+=e.length}}deactivate(){return this.currentSpriteSheet&&this.draw(),this.shaderProgram.unuse(),this.drawCount}draw(){var t=this.gl;t.uniformMatrix3fv(this.shaderProgram.uniformLocations.uProjectionMatrix,!1,this.projectionMatrixArray),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray.length>this.lastArrayLength?t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.DYNAMIC_DRAW):t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray.subarray(0,this.vertexArrayIndex));var e=Float32Array.BYTES_PER_ELEMENT,i=5*e;t.vertexAttribPointer(this.shaderProgram.attributeLocations.aVertex,2,t.FLOAT,!1,i,0*e),t.vertexAttribPointer(this.shaderProgram.attributeLocations.aTextureCoord,2,t.FLOAT,!1,i,2*e),t.vertexAttribPointer(this.shaderProgram.attributeLocations.aAlpha,1,t.FLOAT,!1,i,4*e),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.currentSpriteSheet.texture),t.uniform1i(this.shaderProgram.uniformLocations.uTexture,0),t.drawArrays(t.TRIANGLES,0,this.vertexArrayIndex/5),t.bindTexture(t.TEXTURE_2D,null),this.drawCount++,this.currentSpriteSheet=null,this.vertexArrayIndex=0}}Ui.mixInto(yv);var xv=yv;class Tv{initialize(t,e,i,s,n,r,a){this.backbone=t,this.firstDrawable=e,this.lastDrawable=i,this.touchedBlocks=ri(this.touchedBlocks)}clean(){this.backbone=null,this.firstDrawable=null,this.lastDrawable=null}recordBackboneBoundaries(){this.backbone.previousFirstDrawable=this.firstDrawable,this.backbone.previousLastDrawable=this.lastDrawable}notePendingAddition(t,e){t.notePendingAddition(this.backbone.display,e,this.backbone)}notePendingMove(t,e){t.notePendingMove(this.backbone.display,e)}notePendingRemoval(t){t.notePendingRemoval(this.backbone.display)}markBlockForDisposal(t){t.domElement.parentNode===this.backbone.domElement&&this.backbone.domElement.removeChild(t.domElement),t.markForDisposal(this.backbone.display)}removeAllBlocks(){for(;this.backbone.blocks.length;){var t=this.backbone.blocks[0];this.removeBlock(t),this.markBlockForDisposal(t)}}notifyInterval(t,e,i){t.notifyInterval(e,i),this.backbone.markDirtyDrawable(t)}markBeforeBlock(t,e){t.pendingFirstDrawable=e,this.touchedBlocks.push(t)}markAfterBlock(t,e){t.pendingLastDrawable=e,this.touchedBlocks.push(t)}updateBlockIntervals(){for(;this.touchedBlocks.length;){var t=this.touchedBlocks.pop();t.used&&(t.updateInterval(),this.backbone.markDirtyDrawable(t))}}createBlock(t,e){var i,s=this.backbone;if(on.isCanvas(t))i=mv.createFromPool(s.display,t,s.transformRootInstance,s.backboneInstance);else if(on.isSVG(t))i=fv.createFromPool(s.display,t,s.transformRootInstance,s.backboneInstance);else if(on.isDOM(t))i=gv.createFromPool(s.display,e);else{if(!on.isWebGL(t))throw new Error("unsupported renderer for createBlock: ".concat(t));i=xv.createFromPool(s.display,t,s.transformRootInstance,s.backboneInstance)}return i.setBlockBackbone(s),s.domElement.appendChild(i.domElement),s.isDisplayRoot&&i.domElement.setAttribute("aria-hidden",!0),s.markDirtyDrawable(i),i}appendBlock(t){this.backbone.blocks.push(t)}removeBlock(t){var e=_.indexOf(this.backbone.blocks,t);this.backbone.blocks.splice(e,1)}useNoBlocks(){ri(this.backbone.blocks)}reindex(){this.backbone.reindexBlocks()}auditStitch(){}static debugIntervals(t){}static debugDrawables(t,e,i,s,n){}}bs.register("Stitcher",Tv);var Sv=Tv;function Av(t,e){return t.renderer!==e.renderer||on.isDOM(t.renderer)||on.isDOM(e.renderer)}function Ev(t){return null!==t.previousDrawable&&!Av(t.previousDrawable,t)}function Cv(t){return null!==t.nextDrawable&&!Av(t,t.nextDrawable)}function Dv(t,e,i){return t.drawableBefore?t.drawableBefore.oldNextDrawable!==t.drawableAfter:t.drawableAfter?t.drawableAfter.oldPreviousDrawable!==t.drawableBefore:null!==e}function Iv(t,e,i){var s=t.drawableBefore?t.drawableBefore.parentDrawable:null,n=t.drawableAfter?t.drawableAfter.parentDrawable:null;return(!s||!n||s!==n)&&(s?s.nextBlock!==n:n?n.previousBlock!==s:null!==e)}class Lv extends Sv{stitch(t,e,i,s,n,r,a){var o;if(this.initialize(t,e,i,s,n,r,a),this.blockOrderChanged=!1,this.reusableBlocks=ri(this.reusableBlocks),this.blockWasAdded=!1,this.recordBackboneBoundaries(),t.blocks.length){var h=t.blocks[0];t.blocks[t.blocks.length-1];for(o=r;null!==o;o=o.nextChangeInterval){if(Dv(o,s))for(var l=o.drawableBefore?o.drawableBefore.oldNextDrawable:s,d=o.drawableAfter?o.drawableAfter.oldPreviousDrawable:n,u=l;this.notePendingRemoval(u),u!==d;u=u.oldNextDrawable);if(Iv(o,h))for(var c=null===o.drawableBefore?t.blocks[0]:o.drawableBefore.parentDrawable.nextBlock,m=null===o.drawableAfter?t.blocks[t.blocks.length-1]:o.drawableAfter.parentDrawable.previousBlock,p=c;this.unuseBlock(p),p!==m;p=p.nextBlock);}}if(e)for(o=r;null!==o;o=o.nextChangeInterval)this.processInterval(t,o,e,i);this.removeUnusedBlocks(),this.updateBlockIntervals(),null===e?this.useNoBlocks():this.blockOrderChanged&&(this.processBlockLinkedList(t,e.pendingParentDrawable,i.pendingParentDrawable),this.reindex()),this.clean(),ri(this.reusableBlocks)}processInterval(t,e,i,s){if(function(t,e,i){return t.drawableBefore?t.drawableBefore.nextDrawable!==t.drawableAfter:t.drawableAfter?t.drawableAfter.previousDrawable!==t.drawableBefore:null!==e}(e,i))for(var n=e.drawableBefore?e.drawableBefore.nextDrawable:i,r=null,a=null,o=!0;;){var h=n.nextDrawable,l=h===e.drawableAfter;if(r||(r=n),null===a&&n.parentDrawable&&!n.parentDrawable.used&&n.backbone===t&&n.parentDrawable.parentDrawable===t&&(a=n.parentDrawable),(l||Av(n,h))&&(o&&this.processEdgeCases(e,Ev(r),Cv(n)),this.processSubBlock(e,r,n,a,o,l),r=null,a=null,o=!1),l)break;n=h}else{if(e.drawableBefore&&e.drawableAfter){var d=!Av(e.drawableBefore,e.drawableAfter);this.processEdgeCases(e,d,d)}e.drawableBefore&&!Cv(e.drawableBefore)?this.linkAfterDrawable(e.drawableBefore):e.drawableAfter&&!Ev(e.drawableAfter)&&this.linkBeforeDrawable(e.drawableAfter)}}processSubBlock(t,e,i,s,n,r){var a=Ev(e),o=Cv(i);a&&(s=e.previousDrawable.pendingParentDrawable),o&&(s=i.nextDrawable.pendingParentDrawable),s=this.ensureUsedBlock(s,e);for(var h=e;this.notePendingAddition(h,s),h!==i;h=h.nextDrawable);a||this.linkBeforeDrawable(e),r&&!o&&this.linkAfterDrawable(i)}processEdgeCases(t,e,i){if(null!==t.drawableBefore&&null!==t.drawableAfter){var s,n=t.drawableBefore.pendingParentDrawable,r=t.drawableAfter.pendingParentDrawable,a=t.nextChangeInterval&&t.nextChangeInterval.drawableAfter?t.nextChangeInterval.drawableAfter.pendingParentDrawable:null;n===r&&(this.blockWasAdded=!0),e&&i?s=n:this.blockWasAdded||n===r?(s=this.createBlock(t.drawableAfter.renderer,t.drawableAfter),this.blockOrderChanged=!0):s=r,r===s?this.blockWasAdded=!0:this.changeExternals(t,s),a!==r&&(this.blockWasAdded||this.unuseBlock(r),this.blockWasAdded=!1)}}changeExternals(t,e){var i=function(t){var e=t.drawableAfter;if(e){for(var i=e.renderer,s=t.nextChangeInterval?t.nextChangeInterval.drawableBefore.nextDrawable:null,n=e;;){var r=n.nextDrawable;if(r===s||r.renderer!==i)break;n=r}return n}return null}(t);this.notePendingMoves(e,t.drawableAfter,i),t.nextChangeInterval&&t.nextChangeInterval.drawableBefore===i||this.linkAfterDrawable(i)}notePendingMoves(t,e,i){for(var s=e;this.notePendingMove(s,t),s!==i;s=s.nextDrawable);}ensureUsedBlock(t,e){return t?t.used||this.useBlock(t):t=this.getBlockForRenderer(e.renderer,e),t}getBlockForRenderer(t,e){var i;if(!on.isDOM(t))for(var s=this.reusableBlocks.length-1;s>=0;s--){var n=this.reusableBlocks[s];if(n.renderer===t){this.useBlockAtIndex(n,s),i=n;break}}return i||(i=this.createBlock(t,e)),this.blockOrderChanged=!0,i}unuseBlock(t){t.used&&(t.used=!1,this.reusableBlocks.push(t))}useBlock(t){this.useBlockAtIndex(t,_.indexOf(this.reusableBlocks,t))}useBlockAtIndex(t,e){this.reusableBlocks.splice(e,1),t.used=!0}removeUnusedBlocks(){for(;this.reusableBlocks.length;){var t=this.reusableBlocks.pop();this.markBlockForDisposal(t),this.blockOrderChanged=!0}}linkBeforeDrawable(t){var e=t.previousDrawable;this.linkBlocks(e?e.pendingParentDrawable:null,t.pendingParentDrawable,e,t)}linkAfterDrawable(t){var e=t.nextDrawable;this.linkBlocks(t.pendingParentDrawable,e?e.pendingParentDrawable:null,t,e)}linkBlocks(t,e,i,s){t&&(t.nextBlock!==e&&(this.blockOrderChanged=!0,t.nextBlock&&(t.nextBlock.previousBlock=null),t.nextBlock=e),this.markAfterBlock(t,i)),e&&(e.previousBlock!==t&&(this.blockOrderChanged=!0,e.previousBlock&&(e.previousBlock.nextBlock=null),e.previousBlock=t),this.markBeforeBlock(e,s))}processBlockLinkedList(t,e,i){for(;t.blocks.length;)t.blocks.pop();if(e)for(var s=e;t.blocks.push(s),s!==i;s=s.nextBlock);}}bs.register("GreedyStitcher",Lv);var kv=Lv;class Mv extends Sv{stitch(t,e,i,s,n,r,a){this.initialize(t,e,i,s,n,r,a);for(var o=t.previousFirstDrawable;null!==o&&(this.notePendingRemoval(o),o!==t.previousLastDrawable);o=o.oldNextDrawable);this.recordBackboneBoundaries(),this.removeAllBlocks();for(var h=null,l=0,d=null,u=e;null!==u&&(h&&u.renderer===l||(h&&this.notifyInterval(h,d,u.previousDrawable),l=u.renderer,h=this.createBlock(l,u),on.isDOM(l)&&(l=0),this.appendBlock(h),d=u),this.notePendingAddition(u,h),u!==i);u=u.nextDrawable);h&&this.notifyInterval(h,d,i),this.reindex(),this.clean()}}bs.register("RebuildStitcher",Mv);class Ov extends vp{constructor(t,e,i,s,n){super(),this.initialize(t,e,i,s,n)}initialize(t,e,i,s,n){if(super.initialize(s),this.display=t,this.backboneInstance=e,this.transformRootInstance=i,this.filterRootAncestorInstance=e.parent?e.parent.getFilterRootInstance():e,this.transformRootAncestorInstance=e.parent?e.parent.getTransformRootInstance():e,this.willApplyTransform=this.transformRootAncestorInstance!==this.transformRootInstance,this.willApplyFilters=this.filterRootAncestorInstance!==this.backboneInstance,this.transformListener=this.transformListener||this.markTransformDirty.bind(this),this.willApplyTransform&&(this.backboneInstance.relativeTransform.addListener(this.transformListener),this.backboneInstance.relativeTransform.addPrecompute()),this.backboneVisibilityListener=this.backboneVisibilityListener||this.updateBackboneVisibility.bind(this),this.backboneInstance.relativeVisibleEmitter.addListener(this.backboneVisibilityListener),this.updateBackboneVisibility(),this.visibilityDirty=!0,this.renderer=s,this.domElement=n?t.domElement:Ov.createDivBackbone(),this.isDisplayRoot=n,this.dirtyDrawables=ri(this.dirtyDrawables),Rn.prepareForTransform(this.domElement),this.watchedFilterNodes=ri(this.watchedFilterNodes),this.filterDirty=!0,this.clipDirty=!0,this.filterDirtyListener=this.filterDirtyListener||this.onFilterDirty.bind(this),this.clipDirtyListener=this.clipDirtyListener||this.onClipDirty.bind(this),this.willApplyFilters)for(var r=this.backboneInstance;r!==this.filterRootAncestorInstance;r=r.parent){var a=r.node;this.watchedFilterNodes.push(a),a.filterChangeEmitter.addListener(this.filterDirtyListener),a.clipAreaProperty.lazyLink(this.clipDirtyListener)}this.lastZIndex=0,this.blocks=this.blocks||[],this.previousFirstDrawable=null,this.previousLastDrawable=null,this.removedDrawables=!1,this.stitcher=this.stitcher||new kv}dispose(){for(;this.watchedFilterNodes.length;){var t=this.watchedFilterNodes.pop();t.filterChangeEmitter.removeListener(this.filterDirtyListener),t.clipAreaProperty.unlink(this.clipDirtyListener)}if(this.backboneInstance.relativeVisibleEmitter.removeListener(this.backboneVisibilityListener),!this.removedDrawables)for(var e=this.previousFirstDrawable;null!==e&&(e.parentDrawable.removeDrawable(e),e!==this.previousLastDrawable);e=e.nextDrawable);this.markBlocksForDisposal(),this.willApplyTransform&&(this.backboneInstance.relativeTransform.removeListener(this.transformListener),this.backboneInstance.relativeTransform.removePrecompute()),this.backboneInstance=null,this.transformRootInstance=null,this.filterRootAncestorInstance=null,this.transformRootAncestorInstance=null,ri(this.dirtyDrawables),ri(this.watchedFilterNodes),this.previousFirstDrawable=null,this.previousLastDrawable=null,super.dispose()}markBlocksForDisposal(){for(;this.blocks.length;){var t=this.blocks.pop();t.domElement.parentNode===this.domElement&&this.domElement.removeChild(t.domElement),t.markForDisposal(this.display)}}updateBackboneVisibility(){this.visible=this.backboneInstance.relativeVisible,this.visibilityDirty||(this.visibilityDirty=!0,this.markDirty())}markForDisposal(t){for(var e=this.previousFirstDrawable;null!==e&&(e.notePendingRemoval(this.display),e!==this.previousLastDrawable);e=e.oldNextDrawable);this.removedDrawables=!0,super.markForDisposal(t)}markDirtyDrawable(t){this.dirtyDrawables.push(t),this.markDirty()}markTransformDirty(){Rn.applyPreparedTransform(this.backboneInstance.relativeTransform.matrix,this.domElement)}onFilterDirty(){this.filterDirty||(this.filterDirty=!0,this.markDirty())}onClipDirty(){this.clipDirty||(this.clipDirty=!0,this.markDirty())}update(){if(!super.update())return!1;for(;this.dirtyDrawables.length;)this.dirtyDrawables.pop().update();if(this.filterDirty){this.filterDirty=!1;for(var t="",e=this.watchedFilterNodes.length,i=0;it?Math.ceil((t+this.blocks[e+1].zIndex)/2):t+20;i.domElement.style.zIndex=i.zIndex=s}t=i.zIndex}this.lastZIndex=t+1}stitch(t,e,i,s){if(null!==i&&null!==s){0;for(var n=null,r=i,a=!1;r;)a=r.constrict()||a,r.isEmpty()?n&&(n.nextChangeInterval=r.nextChangeInterval):(n||(i=r),n=r),r=r.nextChangeInterval;if(n)(s=n).nextChangeInterval=null,this.stitcher.stitch(this,t,e,this.previousFirstDrawable,this.previousLastDrawable,i,s)}}audit(t,e,i){}static createDivBackbone(){var t=document.createElement("div");return t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.width="0",t.style.height="0",t}static repurposeBackboneContainer(t){return"relative"===t.style.position&&"absolute"===t.style.position||(t.style.position="relative"),t.style.left="0",t.style.top="0",t}}bs.register("BackboneDrawable",Ov),Ui.mixInto(Ov);var Rv=Ov;class Nv{constructor(t,e,i){this.display=t,this.rootNode=e;var s=document.createElementNS(ln,"svg");s.style.position="absolute",s.setAttribute("class",i),s.style.top="0",s.style.left="0",s.style["pointer-events"]="none",this.svg=s,t.sizeProperty.link(t=>{var e,i;e=t.width,i=t.height,s.setAttribute("width",""+e),s.setAttribute("height",""+i),s.style.clip="rect(0px,".concat(e,"px,").concat(i,"px,0px)")}),this.domElement=s}addShape(t,e,i){var s=document.createElementNS(ln,"path"),n=t.getSVGPath();n||(n="M0 0"),n?s.setAttribute("d",n):s.hasAttribute("d")&&s.removeAttribute("d"),s.setAttribute("style","fill: none; stroke: ".concat(e,"; stroke-dasharray: 5, 3; stroke-dashoffset: ").concat(i?5:0,"; stroke-width: 3;")),this.svg.appendChild(s)}update(){for(;this.svg.childNodes.length;)this.svg.removeChild(this.svg.childNodes[this.svg.childNodes.length-1]);this.addShapes()}dispose(){}}bs.register("ShapeBasedOverlay",Nv);class Bv extends Nv{constructor(t,e){super(t,e,"canvasNodeBoundsOverlay")}addShapes(){new Nh(this.rootNode).eachTrailUnder(t=>{var e=t.lastNode();if(!e.isVisible())return!0;if(e instanceof ll&&t.isVisible()){var i=t.getTransform();this.addShape(i.transformShape(aa.bounds(e.selfBounds)),"rgba(0,255,0,0.8)",!0)}return!1})}}bs.register("CanvasNodeBoundsOverlay",Bv);class Fv extends Nv{constructor(t,e){super(t,e,"canvasNodeBoundsOverlay")}addShapes(){var t=this;function e(e,s){e.willApplyTransform&&(s=s.timesMatrix(e.backboneInstance.relativeTransform.matrix)),e.blocks.forEach(e=>{!function(e,s){e instanceof lv&&!e.fitBounds.isEmpty()&&t.addShape(aa.bounds(e.fitBounds).transformed(s),"rgba(255,0,0,0.8)",!0);if(e.firstDrawable&&e.lastDrawable){for(var n=e.firstDrawable;n!==e.lastDrawable;n=n.nextDrawable)i(n,s);i(e.lastDrawable,s)}}(e,s)})}function i(t,i){t instanceof Rv&&e(t,i)}e(this.display.rootBackbone,wn.IDENTITY)}}bs.register("FittedBlockBoundsOverlay",Fv);var Vv=Bd.OUTER_FOCUS_COLOR,Hv=Bd.INNER_FOCUS_COLOR,Yv=Bd.INNER_LIGHT_GROUP_FOCUS_COLOR,zv=Bd.OUTER_LIGHT_GROUP_FOCUS_COLOR;class Wv{constructor(t,e,i){_defineProperty(this,"trail",null),_defineProperty(this,"node",null),_defineProperty(this,"activeHighlight",null),_defineProperty(this,"mode",null),_defineProperty(this,"groupMode",null),_defineProperty(this,"groupHighlightNode",null),_defineProperty(this,"transformTracker",null),_defineProperty(this,"groupTransformTracker",null),_defineProperty(this,"nodeModeHighlight",null),_defineProperty(this,"nodeModeHighlightLayered",!1),_defineProperty(this,"transformDirty",!0),_defineProperty(this,"highlightNode",new uh),_defineProperty(this,"readingBlockHighlightNode",new uh),_defineProperty(this,"addedReadingBlockHighlight",null),_defineProperty(this,"activeReadingBlockNode",null),_defineProperty(this,"readingBlockTrail",null),_defineProperty(this,"readingBlockTransformDirty",!0),_defineProperty(this,"readingBlockTransformTracker",null);var s=w()({pdomFocusHighlightsVisibleProperty:new pe(!0),interactiveHighlightsVisibleProperty:new pe(!1),readingBlockHighlightsVisibleProperty:new pe(!1)},i);this.display=t,this.focusRootNode=e,this.focusRootNode.addChild(this.highlightNode),this.focusRootNode.addChild(this.readingBlockHighlightNode),this.pdomFocusHighlightsVisibleProperty=s.pdomFocusHighlightsVisibleProperty,this.interactiveHighlightsVisibleProperty=s.interactiveHighlightsVisibleProperty,this.readingBlockHighlightsVisibleProperty=s.readingBlockHighlightsVisibleProperty,this.focusDisplay=new $v(this.focusRootNode,{allowWebGL:t.isWebGLAllowed(),allowCSSHacks:!1,accessibility:!1,interactive:!1}),this.domElement=this.focusDisplay.domElement,this.domElement.style.pointerEvents="none",this.shapeFocusHighlightPath=new Bd(null),this.boundsFocusHighlightPath=new Vd(null,{useLocalBounds:!0}),this.highlightNode.addChild(this.shapeFocusHighlightPath),this.highlightNode.addChild(this.boundsFocusHighlightPath),this.groupFocusHighlightPath=new Vd(null,{useLocalBounds:!0,useGroupDilation:!0,outerLineWidth:Bd.GROUP_OUTER_LINE_WIDTH,innerLineWidth:Bd.GROUP_INNER_LINE_WIDTH,innerStroke:Bd.OUTER_FOCUS_COLOR}),this.groupFocusHighlightParent=new uh({children:[this.groupFocusHighlightPath]}),this.focusRootNode.addChild(this.groupFocusHighlightParent),this.readingBlockHighlightPath=new iu(null),this.readingBlockHighlightNode.addChild(this.readingBlockHighlightPath),this.boundsListener=this.onBoundsChange.bind(this),this.transformListener=this.onTransformChange.bind(this),this.domFocusListener=this.onFocusChange.bind(this),this.readingBlockTransformListener=this.onReadingBlockTransformChange.bind(this),this.focusHighlightListener=this.onFocusHighlightChange.bind(this),this.interactiveHighlightListener=this.onInteractiveHighlightChange.bind(this),this.focusHighlightsVisibleListener=this.onFocusHighlightsVisibleChange.bind(this),this.voicingHighlightsVisibleListener=this.onVoicingHighlightsVisibleChange.bind(this),this.pointerFocusListener=this.onPointerFocusChange.bind(this),this.lockedPointerFocusListener=this.onLockedPointerFocusChange.bind(this),this.readingBlockFocusListener=this.onReadingBlockFocusChange.bind(this),this.readingBlockHighlightChangeListener=this.onReadingBlockHighlightChange.bind(this),Dd.pdomFocusProperty.link(this.domFocusListener),t.focusManager.pointerFocusProperty.link(this.pointerFocusListener),t.focusManager.readingBlockFocusProperty.link(this.readingBlockFocusListener),t.focusManager.lockedPointerFocusProperty.link(this.lockedPointerFocusListener),this.pdomFocusHighlightsVisibleProperty.link(this.focusHighlightsVisibleListener),this.interactiveHighlightsVisibleProperty.link(this.voicingHighlightsVisibleListener)}dispose(){this.hasHighlight()&&this.deactivateHighlight(),Dd.pdomFocusProperty.unlink(this.domFocusListener),this.pdomFocusHighlightsVisibleProperty.unlink(this.focusHighlightsVisibleListener),this.interactiveHighlightsVisibleProperty.unlink(this.voicingHighlightsVisibleListener),this.display.focusManager.pointerFocusProperty.unlink(this.pointerFocusListener),this.display.focusManager.readingBlockFocusProperty.unlink(this.readingBlockFocusListener),this.focusDisplay.dispose()}hasHighlight(){return!!this.trail}hasReadingBlockHighlight(){return!!this.readingBlockTrail}activateHighlight(t,e,i,s,n){this.trail=t,this.node=e;var r=i;this.activeHighlight=r;var a=t;if("invisible"===r)this.mode="invisible";else if(r instanceof aa)this.mode="shape",this.shapeFocusHighlightPath.visible=!0,this.shapeFocusHighlightPath.setShape(r);else if(r instanceof uh){if(this.mode="node",r instanceof Bd)r.transformSourceNode&&(a=r.getUniqueHighlightTrail(this.trail));this.nodeModeHighlight=r,s?(this.nodeModeHighlightLayered=!0,this.nodeModeHighlight.visible=n.get()):(this.nodeModeHighlight.visible=!0,this.highlightNode.addChild(this.nodeModeHighlight))}else this.mode="bounds",this.boundsFocusHighlightPath.setShapeFromNode(this.node),this.boundsFocusHighlightPath.visible=!0,this.node.localBoundsProperty.lazyLink(this.boundsListener),this.onBoundsChange();this.transformTracker=new Bl(a,{isStatic:!0}),this.transformTracker.addListener(this.transformListener),this.activateGroupHighlights(),this.updateHighlightColors(),this.transformDirty=!0}activateFocusHighlight(t,e){this.activateHighlight(t,e,e.focusHighlight,e.focusHighlightLayerable,this.pdomFocusHighlightsVisibleProperty),e.focusHighlightChangedEmitter.addListener(this.focusHighlightListener)}activateInteractiveHighlight(t,e){this.activateHighlight(t,e,e.interactiveHighlight||e.focusHighlight,e.interactiveHighlightLayerable,this.interactiveHighlightsVisibleProperty),e.interactiveHighlightChangedEmitter.addListener(this.interactiveHighlightListener)}activateReadingBlockHighlight(t){this.readingBlockTrail=t;var e=t.lastNode();this.activeReadingBlockNode=e;var i=this.activeReadingBlockNode.readingBlockActiveHighlight;this.addedReadingBlockHighlight=i,"invisible"===i||(i instanceof aa?(this.readingBlockHighlightPath.setShape(i),this.readingBlockHighlightPath.visible=!0):i instanceof uh?this.readingBlockHighlightNode.addChild(i):(this.readingBlockHighlightPath.setShapeFromNode(this.activeReadingBlockNode),this.readingBlockHighlightPath.visible=!0)),this.readingBlockTransformTracker=new Bl(this.readingBlockTrail,{isStatic:!0}),this.readingBlockTransformTracker.addListener(this.readingBlockTransformListener),this.activeReadingBlockNode.readingBlockActiveHighlightChangedEmitter.addListener(this.readingBlockHighlightChangeListener),this.readingBlockTransformDirty=!0}deactivateReadingBlockHighlight(){this.readingBlockHighlightPath.visible=!1,this.addedReadingBlockHighlight instanceof uh&&this.readingBlockHighlightNode.removeChild(this.addedReadingBlockHighlight);var t=this.readingBlockTransformTracker;t.removeListener(this.readingBlockTransformListener),t.dispose(),this.readingBlockTransformTracker=null,this.activeReadingBlockNode.readingBlockActiveHighlightChangedEmitter.removeListener(this.readingBlockHighlightChangeListener),this.activeReadingBlockNode=null,this.readingBlockTrail=null,this.addedReadingBlockHighlight=null}deactivateHighlight(){var t=this.node;if("shape"===this.mode)this.shapeFocusHighlightPath.visible=!1;else if("node"===this.mode){var e=this.nodeModeHighlight;this.nodeModeHighlightLayered?this.nodeModeHighlightLayered=!1:this.highlightNode.removeChild(e),e.visible=!1,this.nodeModeHighlight=null}else"bounds"===this.mode&&(this.boundsFocusHighlightPath.visible=!1,t.localBoundsProperty.unlink(this.boundsListener));t.focusHighlightChangedEmitter.hasListener(this.focusHighlightListener)&&t.focusHighlightChangedEmitter.removeListener(this.focusHighlightListener);var i=t;i.isInteractiveHighlighting&&i.interactiveHighlightChangedEmitter.hasListener(this.interactiveHighlightListener)&&i.interactiveHighlightChangedEmitter.removeListener(this.interactiveHighlightListener),this.deactivateGroupHighlights(),this.trail=null,this.node=null,this.mode=null,this.activeHighlight=null,this.transformTracker.removeListener(this.transformListener),this.transformTracker.dispose(),this.transformTracker=null}activateGroupHighlights(){for(var t=this.trail,e=0;e{var e=t.lastNode();if(!e.isVisible()||!1===e.pickable)return!0;if(e.inputListeners.length&&t.isVisible()){var i=Uv.getLocalMouseShape(e),s=Uv.getLocalTouchShape(e),n=t.getMatrix();i.bounds.isEmpty()||this.addShape(i.transformed(n),"rgba(0,0,255,0.8)",!0),s.bounds.isEmpty()||this.addShape(s.transformed(n),"rgba(255,0,0,0.8)",!1)}return!1})}static getLocalMouseShape(t){var e=aa.union([t.mouseArea?t.mouseArea instanceof aa?t.mouseArea:aa.bounds(t.mouseArea):t.getSelfShape(),...t.children.filter(e=>t.visible&&!1!==t.pickable).map(t=>Uv.getLocalMouseShape(t).transformed(t.matrix))]);return t.hasClipArea()&&(e=e.shapeIntersection(t.clipArea)),e}static getLocalTouchShape(t){var e=aa.union([t.touchArea?t.touchArea instanceof aa?t.touchArea:aa.bounds(t.touchArea):t.getSelfShape(),...t.children.filter(e=>t.visible&&!1!==t.pickable).map(t=>Uv.getLocalTouchShape(t).transformed(t.matrix))]);return t.hasClipArea()&&(e=e.shapeIntersection(t.clipArea)),e}}bs.register("HitAreaOverlay",Uv);class Gv extends Nv{constructor(t,e){super(t,e,"mouseTouchAreaOverlay")}addShapes(){new Nh(this.rootNode).eachTrailUnder(t=>{var e=t.lastNode();if(!e.isVisible())return!0;if((e.mouseArea||e.touchArea)&&t.isVisible()){var i=t.getTransform();e.mouseArea&&this.addShape(i.transformShape(e.mouseArea instanceof mn?aa.bounds(e.mouseArea):e.mouseArea),"rgba(0,0,255,0.8)",!0),e.touchArea&&this.addShape(i.transformShape(e.touchArea instanceof mn?aa.bounds(e.touchArea):e.touchArea),"rgba(255,0,0,0.8)",!1)}return!1})}}bs.register("PointerAreaOverlay",Gv);class Xv{constructor(t,e){this.display=t,this.rootNode=e,this.pointerSVGContainer=document.createElement("div"),this.pointerSVGContainer.style.position="absolute",this.pointerSVGContainer.style.top="0",this.pointerSVGContainer.style.left="0",this.pointerSVGContainer.style["pointer-events"]="none";t.sizeProperty.lazyLink(t=>{this.pointerSVGContainer.setAttribute("width",""+t.width),this.pointerSVGContainer.setAttribute("height",""+t.height),this.pointerSVGContainer.style.clip="rect(0px,".concat(t.width,"px,").concat(t.height,"px,0px)")});var i=wn.IDENTITY.copy();this.pointerAdded=t=>{var e=document.createElementNS(ln,"svg");e.style.position="absolute",e.style.top="0",e.style.left="0",e.style["pointer-events"]="none",Rn.prepareForTransform(e),e.setAttribute("width","21"),e.setAttribute("height","21");var s=document.createElementNS(ln,"circle");s.setAttribute("cx","10.5"),s.setAttribute("cy","10.5"),s.setAttribute("r","10"),s.setAttribute("style","fill:black;"),s.setAttribute("style","stroke:white;"),s.setAttribute("opacity","0.4");var n=t=>Rn.applyPreparedTransform(i.setToTranslation(t.x-10.5,t.y-10.5),e),r=()=>{t.isTouchLike()&&(this.pointerSVGContainer.removeChild(e),t.removeInputListener(a))},a={move:()=>{t.point&&n(t.point)},up:r,cancel:r,focus:()=>{t instanceof Nu&&t.point&&(n(t.point),this.pointerSVGContainer.appendChild(e))},blur:()=>{this.pointerSVGContainer.contains(e)&&this.pointerSVGContainer.removeChild(e)}};t.addInputListener(a),a.move(),e.appendChild(s),this.pointerSVGContainer.appendChild(e)},t._input.pointerAddedEmitter.addListener(this.pointerAdded),t._input&&t._input.mouse&&this.pointerAdded(t._input.mouse),this.domElement=this.pointerSVGContainer}dispose(){this.display._input.pointerAddedEmitter.removeListener(this.pointerAdded)}update(){}}bs.register("PointerOverlay",Xv);var jv=1,qv=on.createOrderBitmask(on.bitmaskSVG,on.bitmaskCanvas,on.bitmaskDOM,on.bitmaskWebGL);class Kv{constructor(t,e,i,s){this.active=!1,this.initialize(t,e,i,s)}initialize(t,e,i,s){return e.setImmutable(),this.id=this.id||jv++,this.isWebGLSupported=t.isWebGLAllowed()&&Rn.isWebGLSupported,this.relativeTransform=this.relativeTransform||new Qg(this),this.fittability=this.fittability||new ev(this),this.visible=!0,this.relativeVisible=!0,this.selfVisible=!0,this.visibilityDirty=!0,this.childVisibilityDirty=!0,this.voicingVisible=!0,this.branchIndexMap=this.branchIndexMap||{},this.branchIndexReferences=ri(this.branchIndexReferences),this.addRemoveCounter=0,this.stitchChangeFrame=t._frameId,this.stitchChangeBefore=0,this.stitchChangeAfter=0,this.stitchChangeOnChildren=0,this.stitchChangeIncluded=!1,this.childInsertedListener=this.childInsertedListener||this.onChildInserted.bind(this),this.childRemovedListener=this.childRemovedListener||this.onChildRemoved.bind(this),this.childrenReorderedListener=this.childrenReorderedListener||this.onChildrenReordered.bind(this),this.visibilityListener=this.visibilityListener||this.onVisibilityChange.bind(this),this.markRenderStateDirtyListener=this.markRenderStateDirtyListener||this.markRenderStateDirty.bind(this),this.visibleEmitter=new c,this.relativeVisibleEmitter=new c,this.selfVisibleEmitter=new c,this.canVoiceEmitter=new c,this.cleanInstance(t,e),this.node.addInstance(this),this.externalReferenceCount=0,this.stateless=!0,this.isDisplayRoot=i,this.isSharedCanvasCacheRoot=s,this.preferredRenderers=0,this.isUnderCanvasCache=s,this.isBackbone=!1,this.isTransformed=!1,this.isVisibilityApplied=!1,this.isInstanceCanvasCache=!1,this.isSharedCanvasCachePlaceholder=!1,this.isSharedCanvasCacheSelf=s,this.selfRenderer=0,this.groupRenderer=0,this.sharedCacheRenderer=0,this.renderStateDirtyFrame=t._frameId,this.skipPruningFrame=t._frameId,this.active=!0,this}cleanInstance(t,e){this.display=t,this.trail=e,this.node=e?e.lastNode():null,this.parent=null,this.oldParent=null,this.children=ri(this.children),this.sharedCacheInstance=null,this.relativeTransform.initialize(t,e),this.fittability.initialize(t,e),this.instanceRemovalCheckList=ri(this.instanceRemovalCheckList),this.selfDrawable=null,this.groupDrawable=null,this.sharedCacheDrawable=null,this.firstDrawable=null,this.lastDrawable=null,this.firstInnerDrawable=null,this.lastInnerDrawable=null,this.svgGroups=ri(this.svgGroups),this.cleanSyncTreeResults()}cleanSyncTreeResults(){this.beforeStableIndex=this.children.length,this.afterStableIndex=-1,this.firstChangeInterval=null,this.lastChangeInterval=null,this.incompatibleStateChange=!1,this.groupChanged=!1,this.cascadingStateChange=!1,this.anyStateChange=!1}updateRenderingState(){var t=this.isBackbone,e=this.isTransformed,i=this.isVisibilityApplied,s=this.isInstanceCanvasCache,n=this.isSharedCanvasCacheSelf,r=this.isSharedCanvasCachePlaceholder,a=this.isUnderCanvasCache,o=this.selfRenderer,h=this.groupRenderer,l=this.sharedCacheRenderer,d=this.preferredRenderers;this.isBackbone=!1,this.isTransformed=!1,this.isVisibilityApplied=!1,this.isInstanceCanvasCache=!1,this.isSharedCanvasCacheSelf=!1,this.isSharedCanvasCachePlaceholder=!1,this.selfRenderer=0,this.groupRenderer=0,this.sharedCacheRenderer=0;var u=this.node._hints;this.isUnderCanvasCache=this.isSharedCanvasCacheRoot||!!this.parent&&(this.parent.isUnderCanvasCache||this.parent.isInstanceCanvasCache||this.parent.isSharedCanvasCacheSelf),this.preferredRenderers=this.parent?this.parent.preferredRenderers:qv,u.renderer&&(this.preferredRenderers=on.pushOrderBitmask(this.preferredRenderers,u.renderer));var c=this.node.hasClipArea(),m=1!==this.node.effectiveOpacity||u.usesOpacity||this.node._filters.length>0,p=!1,g=!1;if(m)for(var v=0;v=0;e--){var i=this.children[e].lastDrawable;if(null!==i)return i}return null}findNextDrawable(t){for(var e=this.children.length,i=t+1;ithis.afterStableIndex?this.afterStableIndex=e+1:this.afterStableIndex++,this.fittability.onInsert(t.fittability),this.relativeTransform.addInstance(t),this.markChildVisibilityDirty()}removeInstance(t){this.removeInstanceWithIndex(t,_.indexOf(this.children,t))}removeInstanceWithIndex(t,e){var i=this.display._frameId;t.stitchChangeFrame=i,this.stitchChangeOnChildren=i,e-1>=0&&(this.children[e-1].stitchChangeAfter=i),e+1=this.afterStableIndex?this.afterStableIndex=e:this.afterStableIndex--,this.fittability.onRemove(t.fittability),this.relativeTransform.removeInstance(t)}replaceInstanceWithIndex(t,e,i){this.removeInstanceWithIndex(t,i),this.insertInstance(e,i)}reorderInstances(t,e){var i=this.display._frameId;this.children.splice(t,e-t+1);for(var s=t;s<=e;s++){var n=this.findChildInstanceOnNode(this.node._children[s]);this.children.splice(s,0,n),n.stitchChangeFrame=i,s>t&&(n.stitchChangeAfter=i),s{e instanceof gv&&e.domDrawable instanceof Rv?i|=t(e.domDrawable):i|=e.renderer}),i}(this._rootBackbone)&on.bitmaskRendererArea}markTransformRootDirty(t,e){e?this._dirtyTransformRoots.push(t):this._dirtyTransformRootsWithoutPass.push(t)}updateDirtyTransformRoots(){for(;this._dirtyTransformRoots.length;)this._dirtyTransformRoots.pop().relativeTransform.updateTransformListenersAndCompute(!1,!1,this._frameId,!0);for(;this._dirtyTransformRootsWithoutPass.length;)this._dirtyTransformRootsWithoutPass.pop().relativeTransform.updateTransformListenersAndCompute(!1,!1,this._frameId,!1)}markDrawableChangedBlock(t){this._drawablesToChangeBlock.push(t)}markForReducedReferences(t){this._reduceReferencesNeeded.push(t)}markInstanceRootForDisposal(t){this._instanceRootsToDispose.push(t)}markDrawableForDisposal(t){this._drawablesToDispose.push(t)}markDrawableForLinksUpdate(t){this._drawablesToUpdateLinks.push(t)}markChangeIntervalToDispose(t){this._changeIntervalsToDispose.push(t)}updateBackgroundColor(){var t=null===this._backgroundColor?"":this._backgroundColor.toCSS?this._backgroundColor.toCSS():this._backgroundColor;t!==this._currentBackgroundCSS&&(this._currentBackgroundCSS=t,this._domElement.style.backgroundColor=t)}updateCursor(){if(this._input&&this._input.mouse&&this._input.mouse.point){if(this._input.mouse.cursor)return void this.setSceneCursor(this._input.mouse.cursor);var t=this._rootNode.trailUnderPointer(this._input.mouse);if(t)for(var e=t.getCursorCheckIndex();e>=0;e--){var i=t.nodes[e],s=i.getEffectiveCursor();if(s)return void this.setSceneCursor(s)}}this.setSceneCursor(this._defaultCursor)}setElementCursor(t){this._domElement.style.cursor=t,this._assumeFullWindow&&(document.body.style.cursor=t)}setSceneCursor(t){if(t!==this._lastCursor){this._lastCursor=t;var e=Qv[t];if(e)for(var i=e.length-1;i>=0;i--)this.setElementCursor(e[i]);else this.setElementCursor(t)}}applyCSSHacks(){this._allowSceneOverflow||(this._domElement.style.overflow="hidden"),this._domElement.style.msTouchAction="none",Js.setStyle(this._domElement,Js.fontSmoothing,"antialiased"),this._allowCSSHacks&&(document.onselectstart=()=>!1,document.body.style.msContentZooming="none",Js.setStyle(this._domElement,Js.userDrag,"none"),Js.setStyle(this._domElement,Js.userSelect,"none"),Js.setStyle(this._domElement,Js.touchAction,"none"),Js.setStyle(this._domElement,Js.touchCallout,"none"),Js.setStyle(this._domElement,Js.tapHighlightColor,"rgba(0,0,0,0)"))}canvasDataURL(t){this.canvasSnapshot(e=>{t(e.toDataURL())})}canvasSnapshot(t){var e=document.createElement("canvas");e.width=this.size.width,e.height=this.size.height;var i=e.getContext("2d");this._rootNode.renderToCanvas(e,i,()=>{t(e,i.getImageData(0,0,e.width,e.height))},this.domElement.style.backgroundColor)}setPointerDisplayVisible(t){t!==!!this._pointerOverlay&&(t?(this._pointerOverlay=new Xv(this,this._rootNode),this.addOverlay(this._pointerOverlay)):(this.removeOverlay(this._pointerOverlay),this._pointerOverlay.dispose(),this._pointerOverlay=null))}setPointerAreaDisplayVisible(t){t!==!!this._pointerAreaOverlay&&(t?(this._pointerAreaOverlay=new Gv(this,this._rootNode),this.addOverlay(this._pointerAreaOverlay)):(this.removeOverlay(this._pointerAreaOverlay),this._pointerAreaOverlay.dispose(),this._pointerAreaOverlay=null))}setHitAreaDisplayVisible(t){t!==!!this._hitAreaOverlay&&(t?(this._hitAreaOverlay=new Uv(this,this._rootNode),this.addOverlay(this._hitAreaOverlay)):(this.removeOverlay(this._hitAreaOverlay),this._hitAreaOverlay.dispose(),this._hitAreaOverlay=null))}setCanvasNodeBoundsVisible(t){t!==!!this._canvasAreaBoundsOverlay&&(t?(this._canvasAreaBoundsOverlay=new Bv(this,this._rootNode),this.addOverlay(this._canvasAreaBoundsOverlay)):(this.removeOverlay(this._canvasAreaBoundsOverlay),this._canvasAreaBoundsOverlay.dispose(),this._canvasAreaBoundsOverlay=null))}setFittedBlockBoundsVisible(t){t!==!!this._fittedBlockBoundsOverlay&&(t?(this._fittedBlockBoundsOverlay=new Fv(this,this._rootNode),this.addOverlay(this._fittedBlockBoundsOverlay)):(this.removeOverlay(this._fittedBlockBoundsOverlay),this._fittedBlockBoundsOverlay.dispose(),this._fittedBlockBoundsOverlay=null))}resizeOnWindowResize(){var t=()=>{this.setWidthHeight(window.innerWidth,window.innerHeight)};window.addEventListener("resize",t),t()}updateOnRequestAnimationFrame(t){var e=0,i=0,s=this;!function n(){s._requestAnimationFrameID=window.requestAnimationFrame(n,s._domElement);var r=Date.now();0!==e&&(i=(r-e)/1e3),e=r,ve.emit(i),t&&t(i),s.updateDisplay()}()}cancelUpdateOnRequestAnimationFrame(){window.cancelAnimationFrame(this._requestAnimationFrameID)}initializeEvents(t){var e=new zu(this,!this._listenToOnlyElement,this._batchDOMEvents,this._assumeFullWindow,this._passiveEvents,t);this._input=e,e.connectListeners()}detachEvents(){this._input.disconnectListeners(),this._input=null}addInputListener(t){return _.includes(this._inputListeners,t)||this._inputListeners.push(t),this}removeInputListener(t){return this._inputListeners.splice(_.indexOf(this._inputListeners,t),1),this}hasInputListener(t){for(var e=0;e{var i=e.gl;i&&Rn.loseContext(i);for(var s=e.firstDrawable;null!==s&&(t(s),s!==e.lastDrawable);s=s.nextDrawable);})}(this._rootBackbone)}inspect(){localStorage.scenerySnapshot=JSON.stringify(lp(this))}getDebugHTML(){var t="font-weight: bold; font-size: 120%; margin-top: 5px;",e=0,i="";i+='
    Display (').concat(this.id,") Summary
    "),i+="".concat(this.size.toString()," frame:").concat(this._frameId," input:").concat(!!this._input," cursor:").concat(this._lastCursor,"
    "),i+="Nodes: ".concat(function t(e){for(var i=1,s=0;s"),i+=this._baseInstance?"Instances: ".concat(function t(e){for(var i=1,s=0;s"):"",i+=this._rootBackbone?"Drawables: ".concat(function t(e){var i=1;if(e.blocks)_.each(e.blocks,e=>{i+=t(e)});else if(e.firstDrawable&&e.lastDrawable){for(var s=e.firstDrawable;s!==e.lastDrawable;s=s.nextDrawable)i+=t(s);i+=t(e.lastDrawable)}return i}(this._rootBackbone),"
    "):"";var s={};function n(t){var e=t.constructor.name;s[e]?s[e]++:s[e]=1}for(var r in i+=this._baseInstance?"Retained Drawables: ".concat(function t(e){var i=0;e.selfDrawable&&(n(e.selfDrawable),i++),e.groupDrawable&&(n(e.groupDrawable),i++),e.sharedCacheDrawable&&(n(e.sharedCacheDrawable),i++);for(var s=0;s"):"",s)i+="    ".concat(r,": ").concat(s[r],"
    ");function a(t){if(!t.firstDrawable||!t.lastDrawable)return"";var i=t.domDrawable&&t.domDrawable.blocks,s='
    ');if(s+=t.toString(),i||(s+=" (".concat(t.drawableCount," drawables)")),s+="
    ",e+=1,i)for(var n=0;nBlock Summary');for(var o=0;o")}var s=t.node;e+=t.id,e+=" ".concat(s.constructor.name?s.constructor.name:"?"),e+=' ').concat(s.id,""),e+=s.getDebugHTMLExtras(),s.visible||i("invis"),t.visible||i("I-invis"),t.relativeVisible||i("I-rel-invis"),t.selfVisible||i("I-self-invis"),t.fittability.ancestorsFittable||i("nofit-ancestor"),t.fittability.selfFittable||i("nofit-self"),!0===s.pickable&&i("pickable"),!1===s.pickable&&i("unpickable"),t.trail.isPickable()&&i('hits'),s.getEffectiveCursor()&&i("effectiveCursor:".concat(s.getEffectiveCursor())),s.clipArea&&i("clipArea"),s.mouseArea&&i("mouseArea"),s.touchArea&&i("touchArea"),s.getInputListeners().length&&i("inputListeners"),s.getRenderer()&&i("renderer:".concat(s.getRenderer())),s.isLayerSplit()&&i("layerSplit"),s.opacity<1&&i("opacity:".concat(s.opacity)),s.disabledOpacity<1&&i("disabledOpacity:".concat(s.disabledOpacity)),s._boundsEventCount>0&&i('boundsListen:'.concat(s._boundsEventCount,":").concat(s._boundsEventSelfCount,""));var n="";switch(s.transform.getMatrix().type){case Pn.IDENTITY:n="";break;case Pn.TRANSLATION_2D:n="translated";break;case Pn.SCALING:n="scale";break;case Pn.AFFINE:n="affine";break;case Pn.OTHER:n="other";break;default:throw new Error("invalid matrix type: ".concat(s.transform.getMatrix().type))}return n&&(e+=' ').concat(n,"")),e+=' [Trail '.concat(t.trail.indices.join("."),"]"),e+=' '.concat(s._rendererSummary.bitmask.toString(16)).concat(s._rendererBitmask!==on.bitmaskNodeDefault?" (".concat(s._rendererBitmask.toString(16),")"):"","")}function l(t){var e=t.toString();return t.visible&&(e="".concat(e,"")),t.dirty&&(e+=t.dirty?' [x]':""),t.fittable||(e+=t.dirty?' [no-fit]':""),e}function d(t){var s='
    ');function n(t,e){s+=' '.concat(t,":").concat(l(e),"")}s+=h(t),t.selfDrawable&&n("self",t.selfDrawable),t.groupDrawable&&n("group",t.groupDrawable),t.sharedCacheDrawable&&n("sharedCache",t.sharedCacheDrawable),i+=s+="
    ",e+=1,_.each(t.children,t=>{d(t)}),e-=1}return this._baseInstance&&(i+='
    Root Instance Tree
    '),d(this._baseInstance)),_.each(this._sharedCanvasInstances,e=>{i+='
    Shared Canvas Instance Tree
    '),d(e)}),this._rootBackbone&&(i+='
    Root Drawable Tree
    ',function t(s){var n='
    ');if(n+=l(s),s.instance?(n+=' ('.concat(s.instance.trail.toPathString(),")"),n+="   ".concat(h(s.instance))):s.backboneInstance&&(n+=' ('.concat(s.backboneInstance.trail.toPathString(),")"),n+="   ".concat(h(s.backboneInstance))),i+=n+="
    ",s.blocks)e+=1,_.each(s.blocks,e=>{t(e)}),e-=1;else if(s.firstDrawable&&s.lastDrawable){e+=1;for(var r=s.firstDrawable;r!==s.lastDrawable;r=r.nextDrawable)t(r);t(s.lastDrawable),e-=1}}(this._rootBackbone)),i}getDebugURI(){return"data:text/html;charset=utf-8,".concat(encodeURIComponent("".concat('Scenery Debug Snapshot').concat(this.getDebugHTML(),"")+""))}popupDebug(){window.open(this.getDebugURI())}iframeDebug(){var t=document.createElement("iframe");t.width=""+window.innerWidth,t.height=""+window.innerHeight,t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.zIndex="10000",document.body.appendChild(t),t.contentWindow.document.open(),t.contentWindow.document.write(this.getDebugHTML()),t.contentWindow.document.close(),t.contentWindow.document.body.style.background="white";var e=document.createElement("button");e.style.position="absolute",e.style.top="0",e.style.right="0",e.style.zIndex="10001",document.body.appendChild(e),e.textContent="close",["pointerdown","click","touchdown"].forEach(i=>{e.addEventListener(i,()=>{document.body.removeChild(t),document.body.removeChild(e)},!0)})}getPDOMDebugHTML(){var t="",e="font-weight: bold; font-size: 120%; margin-top: 5px;",i="    ";t+='
    Accessible Instances

    '),function e(s,n){t+="".concat(n+vi("".concat(s.isRootInstance?"":s.node.tagName," ").concat(s.toString())),"
    "),s.children.forEach(t=>{e(t,n+i)})}(this._rootPDOMInstance,""),t+='
    Parallel DOM

    ');for(var s=this._rootPDOMInstance.peer.primarySibling.outerHTML,n=(s=s.replace(/>\n<")).split("\n"),r="",a=0;a"),h||(r+=i)}return t}foreignObjectRasterization(t){var e={},i=0;function s(t){t.id||(t.id="unknown-canvas-".concat(i++)),e[t.id]=t.toDataURL()}!function t(e){if(e instanceof Rv)_.each(e.blocks,e=>{t(e)});else if(e instanceof av&&e.firstDrawable&&e.lastDrawable){for(var i=e.firstDrawable;i!==e.lastDrawable;i=i.nextDrawable)t(i);t(e.lastDrawable),(e instanceof mv||e instanceof xv)&&e.canvas&&e.canvas instanceof window.HTMLCanvasElement&&s(e.canvas)}eg&&e instanceof eg&&(e.domElement instanceof window.HTMLCanvasElement&&s(e.domElement),Array.prototype.forEach.call(e.domElement.getElementsByTagName("canvas"),t=>{s(t)}))}(this._rootBackbone);var n=document.implementation.createHTMLDocument("");n.documentElement.innerHTML=this.domElement.outerHTML,n.documentElement.setAttribute("xmlns",n.documentElement.namespaceURI),n.documentElement.appendChild(document.createElement("style")).innerHTML=".".concat(no.ROOT_CLASS_NAME," { display:none; } ");var r=n.documentElement.getElementsByTagName("canvas");r=Array.prototype.slice.call(r);for(var a=0;a{$v.elementToSVGDataURL(n.documentElement,u,c,t)},p=0,g=!1,v=Array.prototype.slice.call(n.documentElement.getElementsByTagName("image")),f=function(t){var e,i,s=v[t],n=s.getAttribute("xlink:href");"data:"!==n.slice(0,5)&&(p++,g=!0,e=new window.Image,i=s,e.onload=()=>{var t=document.createElement("canvas");t.width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0),i.setAttribute("xlink:href",t.toDataURL()),0==--p&&m()},e.onerror=()=>{0==--p&&m()},e.src=n)},y=0;y{t&&window.open(t)})}getTrailFromPDOMIndicesString(t){if(!this._rootPDOMInstance)return null;for(var e=this._rootPDOMInstance,i=t.split(go.PDOM_UNIQUE_ID_SEPARATOR),s=0;s')+''+'
    '.concat(a,"
    ")+"
    ",h=new window.Image;h.onload=()=>{r.drawImage(h,0,0),s(n.toDataURL())},h.onerror=()=>{s(null)};var l=new window.TextEncoderLite("utf-8").encode(o),d=window.fromByteArray(l);h.src="data:image/svg+xml;base64,".concat(d)}static assertSubtreeDisposed(t){}static addInputListener(t){_.includes($v.inputListeners,t)||$v.inputListeners.push(t)}static removeInputListener(t){$v.inputListeners.splice(_.indexOf($v.inputListeners,t),1)}static interruptInput(){for(var t=$v.inputListeners.slice(0),e=0;e{var e={};return t.parents[0]?e.index=t.parents[0].indexOfChild(t):e.index=null,e},applyState:(t,e)=>{var i=t.parents[0];if(i&&e.index){var s=i.children;s[i.indexOfChild(t)]=s[e.index],s[e.index]=t,i.setChildren(s)}},stateSchema:{index:Kt(Ee)},methods:{linkIndex:{returnType:Ee,parameterTypes:[Xt(Qt,[Ee])],documentation:"Following the PropertyIO.link pattern, subscribe for notifications when the index in the parent changes, and receive a callback with the current value. The return value is a numeric ID for use with clearLinkIndex.",implementation:function(t){var e=()=>{var e=this.parents[0].indexOfChild(this);t(e)};this.parents[0].childrenChangedEmitter.addListener(e),e();var i=ef;return tf[i]=e,ef++,i}},clearLinkIndex:{returnType:Qt,parameterTypes:[Ee],documentation:"Unlink a listener that has been added using linkIndex, by its numerical ID (like setTimeout/clearTimeout)",implementation:function(t){var e=tf[t];this.parents[0].childrenChangedEmitter.removeListener(e),delete tf[t]}},moveForward:{returnType:Qt,parameterTypes:[],implementation:function(){return this.moveForward()},documentation:"Move this node one index forward in each of its parents. If the node is already at the front, this is a no-op."},moveBackward:{returnType:Qt,parameterTypes:[],implementation:function(){return this.moveBackward()},documentation:"Move this node one index backward in each of its parents. If the node is already at the back, this is a no-op."}}});bs.register("IndexedNodeIO",sf);class nf extends Ue{constructor(t,e,i){i=b({nodeTandem:Ct.REQUIRED},i),super([new pe(!0,{tandem:i.nodeTandem.createTandem("visibleProperty")}),...t],(function(t){for(var i=arguments.length,s=new Array(i>1?i-1:0),n=1;n{i.predicate()&&(go.setTextContent(t,e),ve.setTimeout(()=>{Yi.safari?t.hidden=!0:t.textContent="",this.readyToAnnounce=!0},hf.ARIA_LIVE_DELAY))},0)}}_defineProperty(hf,"ARIA_LIVE_DELAY",200),_defineProperty(hf,"AriaLive",af),qi.register("AriaLiveAnnouncer",hf);var lf=hf;class df extends ls{constructor(t){C("Please use AccessibleValueHander.a11yCreateContextResponseAlert(), see https://github.com/phetsims/sun/issues/685"),super(w()({alertStableDelay:1e3},t))}}qi.register("ValueChangeUtterance",df)})()})()}(); \ No newline at end of file diff --git a/js/SpeechSynthesisAnnouncer.ts b/js/SpeechSynthesisAnnouncer.ts index 6735f8a..4564c34 100644 --- a/js/SpeechSynthesisAnnouncer.ts +++ b/js/SpeechSynthesisAnnouncer.ts @@ -730,29 +730,12 @@ class SpeechSynthesisUtteranceWrapper { } } -type HimalayaElement = { - type: string; - tagName: string; -}; -/** - * @param element - returned from himalaya parser, see documentation for details. - */ -const isNotBrTag = ( element: HimalayaElement ): boolean => !( element.type.toLowerCase() === 'element' && element.tagName.toLowerCase() === 'br' ); - /** * Remove
    or
    tags from a string * @param string - plain text or html string */ function removeBrTags( string: string ): string { - - // @ts-ignore - factor out usages of global to a single spot for one ts-ignore - const parser = himalaya; - - if ( parser ) { - const parsedAndFiltered = parser.parse( string ).filter( isNotBrTag ); - return parser.stringify( parsedAndFiltered ); - } - return string; + return string.split( '
    ' ).join( ' ' ).split( '
    ' ).join( ' ' ); } const SpeechSynthesisVoiceIO = new IOType( 'SpeechSynthesisVoiceIO', { diff --git a/package.json b/package.json index e5ebb89..123d850 100644 --- a/package.json +++ b/package.json @@ -18,15 +18,11 @@ "phet.utteranceQueue": "UTTERANCE_QUEUE/main", "phet.phetCore": "PHET_CORE/main", "phet.axon": "AXON/main" - }, - "preload": [ - "../sherpa/lib/himalaya-1.1.0.js" - ] + } }, "eslintConfig": { "extends": "../chipper/eslint/sim_eslintrc.js", "globals": { - "himalaya": "readonly", "SpeechSynthesis": "readonly", "SpeechSynthesisVoice": "readonly", "SpeechSynthesisUtterance": "readonly" diff --git a/utterance-queue-tests.html b/utterance-queue-tests.html index a2a26c1..ce21e98 100644 --- a/utterance-queue-tests.html +++ b/utterance-queue-tests.html @@ -41,15 +41,11 @@ "phet.utteranceQueue": "UTTERANCE_QUEUE/main", "phet.phetCore": "PHET_CORE/main", "phet.axon": "AXON/main" - }, - "preload": [ - "../sherpa/lib/himalaya-1.1.0.js" - ] + } }, "eslintConfig": { "extends": "../chipper/eslint/sim_eslintrc.js", "globals": { - "himalaya": "readonly", "SpeechSynthesis": "readonly", "SpeechSynthesisVoice": "readonly", "SpeechSynthesisUtterance": "readonly"