{"code":"(window.webpackJsonpGUI=window.webpackJsonpGUI||[]).push([[27],{1583:function(t,e,n){\"use strict\";n.r(e),n.d(e,\"resources\",(function(){return r}));const r={\"userscript.js\":async function(t){let{addon:e}=t;const n={none:0,hundredth:.01,tenth:.1,one:1,ten:10},r=new WeakMap,s=t=>t.includes(\".\")?t.toString().split(\".\")[1].length:0,i=(t,e)=>{const n=\"-\"===t[0];let r=n?t.substring(1):t;for(let t=0;t{if(e.self.disabled)return;if(![\"ArrowUp\",\"ArrowDown\"].includes(t.key))return;if(!((a=t.target).classList.contains(\"blocklyHtmlInput\")||a.matches(\".mediaRecorderPopupContent input[type=number]\")||a.className.includes(\"input_input-form_\")&&(a.matches(\"[class*=sprite-info_sprite-info_] [class*=input_input-small_]\")||a.matches(\"[class*=paint-editor_editor-container-top_] input[type=number]\"))))return;var a;if(!t.target.value)return;if(!(t=>{if(t.length>30)return!1;try{BigInt(t.replace(\".\",\"\"))}catch(t){return!1}return!0})(t.target.value))return;t.preventDefault();let l=\"ArrowUp\"===t.key?1:-1;if(e.settings.get(\"useCustom\")){let n=t.shiftKey?e.settings.get(\"shiftCustom\"):t.altKey?e.settings.get(\"altCustom\"):e.settings.get(\"regularCustom\");\"\"===n&&(n=0);let r=parseFloat(n);if(r<0&&(r*=-1),Number.isNaN(r))return;if(!(0===r||r<1e8&&r>99e-8))return;l*=r}else l*=t.shiftKey?n[e.settings.get(\"shift\")]:t.altKey?n[e.settings.get(\"alt\")]:n[e.settings.get(\"regular\")];const o=Math.max(s(t.target.value),s(l.toString())),u=((t,e)=>{const n=\"-\"===t[0];let r=n?t.substring(1):t;for(let t=0;tt.target.dispatchEvent(new Event(\"blur\",{bubbles:!0})),i=document.timeline.currentTime;r.has(t.target)||r.set(t.target,{time:null,steps:-1}),r.get(t.target).time=i;(r.get(t.target).steps+=1)===n?(s(),r.delete(t.target)):setTimeout((()=>{var e;(null===(e=r.get(t.target))||void 0===e?void 0:e.time)===i&&(s(),r.delete(t.target))}),e)}else t.target.value=u.toString()}))}}}}]);","name":"js/pentapod/addon-entry-editor-number-arrow-keys.ce5b48ccd93c79b94f4b.js","input":"(window[\"webpackJsonpGUI\"] = window[\"webpackJsonpGUI\"] || []).push([[27],{\n\n/***/ 1583:\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n// ESM COMPAT FLAG\n__webpack_require__.r(__webpack_exports__);\n\n// EXPORTS\n__webpack_require__.d(__webpack_exports__, \"resources\", function() { return /* binding */ resources; });\n\n// CONCATENATED MODULE: ./src/addons/addons/editor-number-arrow-keys/userscript.js\n/* harmony default export */ var userscript = (async function (_ref) {\n let {\n addon\n } = _ref;\n const settings = {\n none: 0,\n hundredth: 0.01,\n tenth: 0.1,\n one: 1,\n ten: 10\n };\n const inputMap = new WeakMap();\n const amountOfDecimals = numStr => {\n if (!numStr.includes(\".\")) return 0;\n return numStr.toString().split(\".\")[1].length;\n };\n const shiftDecimalPointToRight = (num, times) => {\n const isNumberNegative = num[0] === \"-\";\n let numStr = isNumberNegative ? num.substring(1) : num;\n for (let i = 0; i < times; i++) {\n if (numStr.indexOf(\".\") === -1) numStr += 0;else if (numStr.indexOf(\".\") === numStr.length - 2) numStr = numStr.replace(\".\", \"\");else {\n const index = numStr.indexOf(\".\");\n const numArrFiltered = Array.from(numStr.replace(\".\", \"\"));\n numArrFiltered.splice(index + 1, 0, \".\");\n numStr = numArrFiltered.join(\"\");\n }\n }\n return BigInt(numStr) * (isNumberNegative ? -1n : 1n);\n };\n const shiftDecimalPointToLeft = (num, times) => {\n const isNumberNegative = num[0] === \"-\";\n let numStr = isNumberNegative ? num.substring(1) : num;\n for (let i = 0; i < times; i++) {\n if (numStr.indexOf(\".\") === 0) numStr = \".0\" + numStr.substring(1);else if (numStr.indexOf(\".\") === -1) {\n const numArr = Array.from(numStr);\n numArr.splice(numArr.length - 1, 0, \".\");\n numStr = numArr.join(\"\");\n } else {\n const index = numStr.indexOf(\".\");\n const numArrFiltered = Array.from(numStr.replace(\".\", \"\"));\n numArrFiltered.splice(index - 1, 0, \".\");\n numStr = numArrFiltered.join(\"\");\n }\n }\n\n // Adds zero before the decimal point if necessary (.1 → 0.1)\n if (numStr[0] === \".\") {\n numStr = \"0\" + numStr;\n }\n\n // Removes trailing zeros (2.250 → 2.25)\n if (numStr.includes(\".\")) {\n numStr = numStr.replace(/0*$/, \"\");\n }\n\n // Removes the decimal point if it's the last character (2. → 2)\n if (numStr.endsWith(\".\")) {\n numStr = numStr.slice(0, -1);\n }\n return numStr ? (isNumberNegative ? \"-\" : \"\") + numStr : 0;\n };\n const isValidNumber = numStr => {\n if (numStr.length > 30) return false;\n try {\n BigInt(numStr.replace(\".\", \"\"));\n } catch (_unused) {\n return false; // Even though an error would occur later anyway, we still catch now to abort before e.preventDefault().\n }\n return true;\n };\n const isSupportedElement = el => {\n if (el.classList.contains(\"blocklyHtmlInput\")) return true;else if (el.matches(\".mediaRecorderPopupContent input[type=number]\")) {\n // Number inputs in `mediarecorder` addon modal\n return true;\n } else if (el.className.includes(\"input_input-form_\")) {\n if (el.matches(\"[class*=sprite-info_sprite-info_] [class*=input_input-small_]\")) {\n // Sprite X/Y coordinates, size and direction (excludes sprite name)\n return true;\n } else if (el.matches(\"[class*=paint-editor_editor-container-top_] input[type=number]\")) {\n // Number inputs in costume editor (note that browsers already provide up/down clickable buttons for these)\n return true;\n } else return false;\n }\n return false;\n };\n document.body.addEventListener(\"keydown\", e => {\n if (addon.self.disabled) return;\n if (![\"ArrowUp\", \"ArrowDown\"].includes(e.key)) return;\n if (!isSupportedElement(e.target)) return;\n if (!e.target.value) return;\n if (!isValidNumber(e.target.value)) return;\n e.preventDefault();\n // If this is a text input, this will prevent the cursor from moving to the beginning/end of the input.\n // If this is a number input, it will prevent the default browser behavior when pressing up/down in a\n // number input (increase or decrease by 1). If we didn't prevent, the user would be increasing twice.\n\n let changeBy = e.key === \"ArrowUp\" ? 1 : -1;\n if (addon.settings.get(\"useCustom\")) {\n let settingValue = e.shiftKey ? addon.settings.get(\"shiftCustom\") : e.altKey ? addon.settings.get(\"altCustom\") : addon.settings.get(\"regularCustom\");\n if (settingValue === \"\") settingValue = 0;\n let valueAsFloat = parseFloat(settingValue);\n if (valueAsFloat < 0) valueAsFloat *= -1; // If user typed a negative number, we make it positive\n if (Number.isNaN(valueAsFloat)) {\n return;\n } else if (valueAsFloat === 0 || valueAsFloat < 100000000 && valueAsFloat > 0.00000099) {\n // This will exclude valid floats such as `1e20` that are less than 9 characters\n changeBy *= valueAsFloat;\n } else {\n return;\n }\n } else {\n changeBy *= e.shiftKey ? settings[addon.settings.get(\"shift\")] : e.altKey ? settings[addon.settings.get(\"alt\")] : settings[addon.settings.get(\"regular\")];\n }\n const decimalCount = Math.max(amountOfDecimals(e.target.value), amountOfDecimals(changeBy.toString()));\n const newValueAsBigInt = shiftDecimalPointToRight(e.target.value, decimalCount) + shiftDecimalPointToRight(changeBy.toString(), decimalCount);\n const newValue = shiftDecimalPointToLeft(newValueAsBigInt.toString(), decimalCount);\n if (e.target.className.includes(\"input_input-form_\")) {\n Object.getOwnPropertyDescriptor(e.target.constructor.prototype, \"value\").set.call(e.target, newValue.toString());\n e.target.dispatchEvent(new Event(\"input\", {\n bubbles: true\n }));\n\n // The user probably wants to visualize how the sprite changes size, coordinates, direction, etc.\n // without having to press Enter. But updating in realtime could be bad for performance.\n const FLUSH_AFTER_MS = 300; // Number of ms to wait until the input change takes effect.\n // Force flush after incrementing/decrementing 5 times in a row, even if it's not been 300ms:\n const FLUSH_AFTER_N_STEPS = 5;\n\n // https://github.com/scratchfoundation/scratch-gui/blob/develop/src/components/forms/buffered-input-hoc.jsx\n // This function calls handleFlush() on the buffered input when called.\n const flushInput = () => e.target.dispatchEvent(new Event(\"blur\", {\n bubbles: true\n }));\n const currentTime = document.timeline.currentTime; // Similar to Date.now() but can't be changed by user unexpectedly\n if (!inputMap.has(e.target)) inputMap.set(e.target, {\n time: null,\n steps: -1\n });\n inputMap.get(e.target).time = currentTime;\n const newNumOfSteps = inputMap.get(e.target).steps += 1;\n if (newNumOfSteps === FLUSH_AFTER_N_STEPS) {\n flushInput();\n inputMap.delete(e.target);\n } else {\n setTimeout(() => {\n var _inputMap$get;\n if (((_inputMap$get = inputMap.get(e.target)) === null || _inputMap$get === void 0 ? void 0 : _inputMap$get.time) === currentTime) {\n flushInput();\n inputMap.delete(e.target);\n }\n }, FLUSH_AFTER_MS);\n }\n } else {\n // Normal Blockly input\n e.target.value = newValue.toString();\n }\n });\n});\n// CONCATENATED MODULE: ./src/addons/addons/editor-number-arrow-keys/_runtime_entry.js\n/* generated by pull.js */\n\nconst resources = {\n \"userscript.js\": userscript\n};\n\n/***/ })\n\n}]);","inputSourceMap":null}