@zsviczian/excalidraw 0.18.0-39 → 0.18.0-40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11099,7 +11099,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
11099
11099
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11100
11100
 
11101
11101
  "use strict";
11102
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ diagram: () => (/* binding */ diagram)\n/* harmony export */ });\n/* harmony import */ var _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./mermaid-ad1dc92f.js */ \"../../node_modules/mermaid/dist/mermaid-ad1dc92f.js\");\n/* harmony import */ var dagre_d3_es_src_graphlib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! dagre-d3-es/src/graphlib/index.js */ \"../../node_modules/dagre-d3-es/src/graphlib/index.js\");\n/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! d3 */ \"../../node_modules/d3/src/index.js\");\n/* harmony import */ var dagre_d3_es_src_dagre_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! dagre-d3-es/src/dagre/index.js */ \"../../node_modules/dagre-d3-es/src/dagre/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uuid */ \"../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/v5.js\");\n/* harmony import */ var ts_dedent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ts-dedent */ \"../../node_modules/ts-dedent/esm/index.js\");\n/* harmony import */ var dayjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! dayjs */ \"../../node_modules/dayjs/dayjs.min.js\");\n/* harmony import */ var _braintree_sanitize_url__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @braintree/sanitize-url */ \"../../node_modules/mermaid/node_modules/@braintree/sanitize-url/dist/index.js\");\n/* harmony import */ var dompurify__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! dompurify */ \"../../node_modules/dompurify/dist/purify.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar parser = function() {\n var o = function(k, v, o2, l) {\n for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)\n ;\n return o2;\n }, $V0 = [6, 8, 10, 20, 22, 24, 26, 27, 28], $V1 = [1, 10], $V2 = [1, 11], $V3 = [1, 12], $V4 = [1, 13], $V5 = [1, 14], $V6 = [1, 15], $V7 = [1, 21], $V8 = [1, 22], $V9 = [1, 23], $Va = [1, 24], $Vb = [1, 25], $Vc = [6, 8, 10, 13, 15, 18, 19, 20, 22, 24, 26, 27, 28, 41, 42, 43, 44, 45], $Vd = [1, 34], $Ve = [27, 28, 46, 47], $Vf = [41, 42, 43, 44, 45], $Vg = [17, 34], $Vh = [1, 54], $Vi = [1, 53], $Vj = [17, 34, 36, 38];\n var parser2 = {\n trace: function trace() {\n },\n yy: {},\n symbols_: { \"error\": 2, \"start\": 3, \"ER_DIAGRAM\": 4, \"document\": 5, \"EOF\": 6, \"line\": 7, \"SPACE\": 8, \"statement\": 9, \"NEWLINE\": 10, \"entityName\": 11, \"relSpec\": 12, \":\": 13, \"role\": 14, \"BLOCK_START\": 15, \"attributes\": 16, \"BLOCK_STOP\": 17, \"SQS\": 18, \"SQE\": 19, \"title\": 20, \"title_value\": 21, \"acc_title\": 22, \"acc_title_value\": 23, \"acc_descr\": 24, \"acc_descr_value\": 25, \"acc_descr_multiline_value\": 26, \"ALPHANUM\": 27, \"ENTITY_NAME\": 28, \"attribute\": 29, \"attributeType\": 30, \"attributeName\": 31, \"attributeKeyTypeList\": 32, \"attributeComment\": 33, \"ATTRIBUTE_WORD\": 34, \"attributeKeyType\": 35, \"COMMA\": 36, \"ATTRIBUTE_KEY\": 37, \"COMMENT\": 38, \"cardinality\": 39, \"relType\": 40, \"ZERO_OR_ONE\": 41, \"ZERO_OR_MORE\": 42, \"ONE_OR_MORE\": 43, \"ONLY_ONE\": 44, \"MD_PARENT\": 45, \"NON_IDENTIFYING\": 46, \"IDENTIFYING\": 47, \"WORD\": 48, \"$accept\": 0, \"$end\": 1 },\n terminals_: { 2: \"error\", 4: \"ER_DIAGRAM\", 6: \"EOF\", 8: \"SPACE\", 10: \"NEWLINE\", 13: \":\", 15: \"BLOCK_START\", 17: \"BLOCK_STOP\", 18: \"SQS\", 19: \"SQE\", 20: \"title\", 21: \"title_value\", 22: \"acc_title\", 23: \"acc_title_value\", 24: \"acc_descr\", 25: \"acc_descr_value\", 26: \"acc_descr_multiline_value\", 27: \"ALPHANUM\", 28: \"ENTITY_NAME\", 34: \"ATTRIBUTE_WORD\", 36: \"COMMA\", 37: \"ATTRIBUTE_KEY\", 38: \"COMMENT\", 41: \"ZERO_OR_ONE\", 42: \"ZERO_OR_MORE\", 43: \"ONE_OR_MORE\", 44: \"ONLY_ONE\", 45: \"MD_PARENT\", 46: \"NON_IDENTIFYING\", 47: \"IDENTIFYING\", 48: \"WORD\" },\n productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 5], [9, 4], [9, 3], [9, 1], [9, 7], [9, 6], [9, 4], [9, 2], [9, 2], [9, 2], [9, 1], [11, 1], [11, 1], [16, 1], [16, 2], [29, 2], [29, 3], [29, 3], [29, 4], [30, 1], [31, 1], [32, 1], [32, 3], [35, 1], [33, 1], [12, 3], [39, 1], [39, 1], [39, 1], [39, 1], [39, 1], [40, 1], [40, 1], [14, 1], [14, 1], [14, 1]],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {\n var $0 = $$.length - 1;\n switch (yystate) {\n case 1:\n break;\n case 2:\n this.$ = [];\n break;\n case 3:\n $$[$0 - 1].push($$[$0]);\n this.$ = $$[$0 - 1];\n break;\n case 4:\n case 5:\n this.$ = $$[$0];\n break;\n case 6:\n case 7:\n this.$ = [];\n break;\n case 8:\n yy.addEntity($$[$0 - 4]);\n yy.addEntity($$[$0 - 2]);\n yy.addRelationship($$[$0 - 4], $$[$0], $$[$0 - 2], $$[$0 - 3]);\n break;\n case 9:\n yy.addEntity($$[$0 - 3]);\n yy.addAttributes($$[$0 - 3], $$[$0 - 1]);\n break;\n case 10:\n yy.addEntity($$[$0 - 2]);\n break;\n case 11:\n yy.addEntity($$[$0]);\n break;\n case 12:\n yy.addEntity($$[$0 - 6], $$[$0 - 4]);\n yy.addAttributes($$[$0 - 6], $$[$0 - 1]);\n break;\n case 13:\n yy.addEntity($$[$0 - 5], $$[$0 - 3]);\n break;\n case 14:\n yy.addEntity($$[$0 - 3], $$[$0 - 1]);\n break;\n case 15:\n case 16:\n this.$ = $$[$0].trim();\n yy.setAccTitle(this.$);\n break;\n case 17:\n case 18:\n this.$ = $$[$0].trim();\n yy.setAccDescription(this.$);\n break;\n case 19:\n case 43:\n this.$ = $$[$0];\n break;\n case 20:\n case 41:\n case 42:\n this.$ = $$[$0].replace(/\"/g, \"\");\n break;\n case 21:\n case 29:\n this.$ = [$$[$0]];\n break;\n case 22:\n $$[$0].push($$[$0 - 1]);\n this.$ = $$[$0];\n break;\n case 23:\n this.$ = { attributeType: $$[$0 - 1], attributeName: $$[$0] };\n break;\n case 24:\n this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeKeyTypeList: $$[$0] };\n break;\n case 25:\n this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeComment: $$[$0] };\n break;\n case 26:\n this.$ = { attributeType: $$[$0 - 3], attributeName: $$[$0 - 2], attributeKeyTypeList: $$[$0 - 1], attributeComment: $$[$0] };\n break;\n case 27:\n case 28:\n case 31:\n this.$ = $$[$0];\n break;\n case 30:\n $$[$0 - 2].push($$[$0]);\n this.$ = $$[$0 - 2];\n break;\n case 32:\n this.$ = $$[$0].replace(/\"/g, \"\");\n break;\n case 33:\n this.$ = { cardA: $$[$0], relType: $$[$0 - 1], cardB: $$[$0 - 2] };\n break;\n case 34:\n this.$ = yy.Cardinality.ZERO_OR_ONE;\n break;\n case 35:\n this.$ = yy.Cardinality.ZERO_OR_MORE;\n break;\n case 36:\n this.$ = yy.Cardinality.ONE_OR_MORE;\n break;\n case 37:\n this.$ = yy.Cardinality.ONLY_ONE;\n break;\n case 38:\n this.$ = yy.Cardinality.MD_PARENT;\n break;\n case 39:\n this.$ = yy.Identification.NON_IDENTIFYING;\n break;\n case 40:\n this.$ = yy.Identification.IDENTIFYING;\n break;\n }\n },\n table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 16, 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 11], { 12: 17, 39: 20, 15: [1, 18], 18: [1, 19], 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }), { 21: [1, 26] }, { 23: [1, 27] }, { 25: [1, 28] }, o($V0, [2, 18]), o($Vc, [2, 19]), o($Vc, [2, 20]), o($V0, [2, 4]), { 11: 29, 27: $V5, 28: $V6 }, { 16: 30, 17: [1, 31], 29: 32, 30: 33, 34: $Vd }, { 11: 35, 27: $V5, 28: $V6 }, { 40: 36, 46: [1, 37], 47: [1, 38] }, o($Ve, [2, 34]), o($Ve, [2, 35]), o($Ve, [2, 36]), o($Ve, [2, 37]), o($Ve, [2, 38]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 17]), { 13: [1, 39] }, { 17: [1, 40] }, o($V0, [2, 10]), { 16: 41, 17: [2, 21], 29: 32, 30: 33, 34: $Vd }, { 31: 42, 34: [1, 43] }, { 34: [2, 27] }, { 19: [1, 44] }, { 39: 45, 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }, o($Vf, [2, 39]), o($Vf, [2, 40]), { 14: 46, 27: [1, 49], 28: [1, 48], 48: [1, 47] }, o($V0, [2, 9]), { 17: [2, 22] }, o($Vg, [2, 23], { 32: 50, 33: 51, 35: 52, 37: $Vh, 38: $Vi }), o([17, 34, 37, 38], [2, 28]), o($V0, [2, 14], { 15: [1, 55] }), o([27, 28], [2, 33]), o($V0, [2, 8]), o($V0, [2, 41]), o($V0, [2, 42]), o($V0, [2, 43]), o($Vg, [2, 24], { 33: 56, 36: [1, 57], 38: $Vi }), o($Vg, [2, 25]), o($Vj, [2, 29]), o($Vg, [2, 32]), o($Vj, [2, 31]), { 16: 58, 17: [1, 59], 29: 32, 30: 33, 34: $Vd }, o($Vg, [2, 26]), { 35: 60, 37: $Vh }, { 17: [1, 61] }, o($V0, [2, 13]), o($Vj, [2, 30]), o($V0, [2, 12])],\n defaultActions: { 34: [2, 27], 41: [2, 22] },\n parseError: function parseError(str, hash) {\n if (hash.recoverable) {\n this.trace(str);\n } else {\n var error = new Error(str);\n error.hash = hash;\n throw error;\n }\n },\n parse: function parse(input) {\n var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = \"\", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;\n var args = lstack.slice.call(arguments, 1);\n var lexer2 = Object.create(this.lexer);\n var sharedState = { yy: {} };\n for (var k in this.yy) {\n if (Object.prototype.hasOwnProperty.call(this.yy, k)) {\n sharedState.yy[k] = this.yy[k];\n }\n }\n lexer2.setInput(input, sharedState.yy);\n sharedState.yy.lexer = lexer2;\n sharedState.yy.parser = this;\n if (typeof lexer2.yylloc == \"undefined\") {\n lexer2.yylloc = {};\n }\n var yyloc = lexer2.yylloc;\n lstack.push(yyloc);\n var ranges = lexer2.options && lexer2.options.ranges;\n if (typeof sharedState.yy.parseError === \"function\") {\n this.parseError = sharedState.yy.parseError;\n } else {\n this.parseError = Object.getPrototypeOf(this).parseError;\n }\n function lex() {\n var token;\n token = tstack.pop() || lexer2.lex() || EOF;\n if (typeof token !== \"number\") {\n if (token instanceof Array) {\n tstack = token;\n token = tstack.pop();\n }\n token = self.symbols_[token] || token;\n }\n return token;\n }\n var symbol, state, action, r, yyval = {}, p, len, newState, expected;\n while (true) {\n state = stack[stack.length - 1];\n if (this.defaultActions[state]) {\n action = this.defaultActions[state];\n } else {\n if (symbol === null || typeof symbol == \"undefined\") {\n symbol = lex();\n }\n action = table[state] && table[state][symbol];\n }\n if (typeof action === \"undefined\" || !action.length || !action[0]) {\n var errStr = \"\";\n expected = [];\n for (p in table[state]) {\n if (this.terminals_[p] && p > TERROR) {\n expected.push(\"'\" + this.terminals_[p] + \"'\");\n }\n }\n if (lexer2.showPosition) {\n errStr = \"Parse error on line \" + (yylineno + 1) + \":\\n\" + lexer2.showPosition() + \"\\nExpecting \" + expected.join(\", \") + \", got '\" + (this.terminals_[symbol] || symbol) + \"'\";\n } else {\n errStr = \"Parse error on line \" + (yylineno + 1) + \": Unexpected \" + (symbol == EOF ? \"end of input\" : \"'\" + (this.terminals_[symbol] || symbol) + \"'\");\n }\n this.parseError(errStr, {\n text: lexer2.match,\n token: this.terminals_[symbol] || symbol,\n line: lexer2.yylineno,\n loc: yyloc,\n expected\n });\n }\n if (action[0] instanceof Array && action.length > 1) {\n throw new Error(\"Parse Error: multiple actions possible at state: \" + state + \", token: \" + symbol);\n }\n switch (action[0]) {\n case 1:\n stack.push(symbol);\n vstack.push(lexer2.yytext);\n lstack.push(lexer2.yylloc);\n stack.push(action[1]);\n symbol = null;\n {\n yyleng = lexer2.yyleng;\n yytext = lexer2.yytext;\n yylineno = lexer2.yylineno;\n yyloc = lexer2.yylloc;\n }\n break;\n case 2:\n len = this.productions_[action[1]][1];\n yyval.$ = vstack[vstack.length - len];\n yyval._$ = {\n first_line: lstack[lstack.length - (len || 1)].first_line,\n last_line: lstack[lstack.length - 1].last_line,\n first_column: lstack[lstack.length - (len || 1)].first_column,\n last_column: lstack[lstack.length - 1].last_column\n };\n if (ranges) {\n yyval._$.range = [\n lstack[lstack.length - (len || 1)].range[0],\n lstack[lstack.length - 1].range[1]\n ];\n }\n r = this.performAction.apply(yyval, [\n yytext,\n yyleng,\n yylineno,\n sharedState.yy,\n action[1],\n vstack,\n lstack\n ].concat(args));\n if (typeof r !== \"undefined\") {\n return r;\n }\n if (len) {\n stack = stack.slice(0, -1 * len * 2);\n vstack = vstack.slice(0, -1 * len);\n lstack = lstack.slice(0, -1 * len);\n }\n stack.push(this.productions_[action[1]][0]);\n vstack.push(yyval.$);\n lstack.push(yyval._$);\n newState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n stack.push(newState);\n break;\n case 3:\n return true;\n }\n }\n return true;\n }\n };\n var lexer = function() {\n var lexer2 = {\n EOF: 1,\n parseError: function parseError(str, hash) {\n if (this.yy.parser) {\n this.yy.parser.parseError(str, hash);\n } else {\n throw new Error(str);\n }\n },\n // resets the lexer, sets new input\n setInput: function(input, yy) {\n this.yy = yy || this.yy || {};\n this._input = input;\n this._more = this._backtrack = this.done = false;\n this.yylineno = this.yyleng = 0;\n this.yytext = this.matched = this.match = \"\";\n this.conditionStack = [\"INITIAL\"];\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0\n };\n if (this.options.ranges) {\n this.yylloc.range = [0, 0];\n }\n this.offset = 0;\n return this;\n },\n // consumes and returns one char from the input\n input: function() {\n var ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n var lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n } else {\n this.yylloc.last_column++;\n }\n if (this.options.ranges) {\n this.yylloc.range[1]++;\n }\n this._input = this._input.slice(1);\n return ch;\n },\n // unshifts one char (or a string) into the input\n unput: function(ch) {\n var len = ch.length;\n var lines = ch.split(/(?:\\r\\n?|\\n)/g);\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.offset -= len;\n var oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n this.match = this.match.substr(0, this.match.length - 1);\n this.matched = this.matched.substr(0, this.matched.length - 1);\n if (lines.length - 1) {\n this.yylineno -= lines.length - 1;\n }\n var r = this.yylloc.range;\n this.yylloc = {\n first_line: this.yylloc.first_line,\n last_line: this.yylineno + 1,\n first_column: this.yylloc.first_column,\n last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len\n };\n if (this.options.ranges) {\n this.yylloc.range = [r[0], r[0] + this.yyleng - len];\n }\n this.yyleng = this.yytext.length;\n return this;\n },\n // When called from action, caches matched text and appends it on next action\n more: function() {\n this._more = true;\n return this;\n },\n // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\n reject: function() {\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n return this.parseError(\"Lexical error on line \" + (this.yylineno + 1) + \". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n\" + this.showPosition(), {\n text: \"\",\n token: null,\n line: this.yylineno\n });\n }\n return this;\n },\n // retain first n characters of the match\n less: function(n) {\n this.unput(this.match.slice(n));\n },\n // displays already matched input, i.e. for error messages\n pastInput: function() {\n var past = this.matched.substr(0, this.matched.length - this.match.length);\n return (past.length > 20 ? \"...\" : \"\") + past.substr(-20).replace(/\\n/g, \"\");\n },\n // displays upcoming input, i.e. for error messages\n upcomingInput: function() {\n var next = this.match;\n if (next.length < 20) {\n next += this._input.substr(0, 20 - next.length);\n }\n return (next.substr(0, 20) + (next.length > 20 ? \"...\" : \"\")).replace(/\\n/g, \"\");\n },\n // displays the character position where the lexing error occurred, i.e. for error messages\n showPosition: function() {\n var pre = this.pastInput();\n var c = new Array(pre.length + 1).join(\"-\");\n return pre + this.upcomingInput() + \"\\n\" + c + \"^\";\n },\n // test the lexed token: return FALSE when not a match, otherwise return token\n test_match: function(match, indexed_rule) {\n var token, lines, backup;\n if (this.options.backtrack_lexer) {\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(0),\n done: this.done\n };\n if (this.options.ranges) {\n backup.yylloc.range = this.yylloc.range.slice(0);\n }\n }\n lines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n if (lines) {\n this.yylineno += lines.length;\n }\n this.yylloc = {\n first_line: this.yylloc.last_line,\n last_line: this.yylineno + 1,\n first_column: this.yylloc.last_column,\n last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length : this.yylloc.last_column + match[0].length\n };\n this.yytext += match[0];\n this.match += match[0];\n this.matches = match;\n this.yyleng = this.yytext.length;\n if (this.options.ranges) {\n this.yylloc.range = [this.offset, this.offset += this.yyleng];\n }\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match[0].length);\n this.matched += match[0];\n token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n for (var k in backup) {\n this[k] = backup[k];\n }\n return false;\n }\n return false;\n },\n // return next match in input\n next: function() {\n if (this.done) {\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n var token, match, tempMatch, index;\n if (!this._more) {\n this.yytext = \"\";\n this.match = \"\";\n }\n var rules = this._currentRules();\n for (var i = 0; i < rules.length; i++) {\n tempMatch = this._input.match(this.rules[rules[i]]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n token = this.test_match(tempMatch, rules[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = false;\n continue;\n } else {\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n if (match) {\n token = this.test_match(match, rules[index]);\n if (token !== false) {\n return token;\n }\n return false;\n }\n if (this._input === \"\") {\n return this.EOF;\n } else {\n return this.parseError(\"Lexical error on line \" + (this.yylineno + 1) + \". Unrecognized text.\\n\" + this.showPosition(), {\n text: \"\",\n token: null,\n line: this.yylineno\n });\n }\n },\n // return next match that has a token\n lex: function lex() {\n var r = this.next();\n if (r) {\n return r;\n } else {\n return this.lex();\n }\n },\n // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\n begin: function begin(condition) {\n this.conditionStack.push(condition);\n },\n // pop the previously active lexer condition state off the condition stack\n popState: function popState() {\n var n = this.conditionStack.length - 1;\n if (n > 0) {\n return this.conditionStack.pop();\n } else {\n return this.conditionStack[0];\n }\n },\n // produce the lexer rule set which is active for the currently active lexer condition state\n _currentRules: function _currentRules() {\n if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n } else {\n return this.conditions[\"INITIAL\"].rules;\n }\n },\n // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\n topState: function topState(n) {\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n } else {\n return \"INITIAL\";\n }\n },\n // alias for begin(condition)\n pushState: function pushState(condition) {\n this.begin(condition);\n },\n // return the number of states currently on the stack\n stateStackSize: function stateStackSize() {\n return this.conditionStack.length;\n },\n options: { \"case-insensitive\": true },\n performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {\n switch ($avoiding_name_collisions) {\n case 0:\n this.begin(\"acc_title\");\n return 22;\n case 1:\n this.popState();\n return \"acc_title_value\";\n case 2:\n this.begin(\"acc_descr\");\n return 24;\n case 3:\n this.popState();\n return \"acc_descr_value\";\n case 4:\n this.begin(\"acc_descr_multiline\");\n break;\n case 5:\n this.popState();\n break;\n case 6:\n return \"acc_descr_multiline_value\";\n case 7:\n return 10;\n case 8:\n break;\n case 9:\n return 8;\n case 10:\n return 28;\n case 11:\n return 48;\n case 12:\n return 4;\n case 13:\n this.begin(\"block\");\n return 15;\n case 14:\n return 36;\n case 15:\n break;\n case 16:\n return 37;\n case 17:\n return 34;\n case 18:\n return 34;\n case 19:\n return 38;\n case 20:\n break;\n case 21:\n this.popState();\n return 17;\n case 22:\n return yy_.yytext[0];\n case 23:\n return 18;\n case 24:\n return 19;\n case 25:\n return 41;\n case 26:\n return 43;\n case 27:\n return 43;\n case 28:\n return 43;\n case 29:\n return 41;\n case 30:\n return 41;\n case 31:\n return 42;\n case 32:\n return 42;\n case 33:\n return 42;\n case 34:\n return 42;\n case 35:\n return 42;\n case 36:\n return 43;\n case 37:\n return 42;\n case 38:\n return 43;\n case 39:\n return 44;\n case 40:\n return 44;\n case 41:\n return 44;\n case 42:\n return 44;\n case 43:\n return 41;\n case 44:\n return 42;\n case 45:\n return 43;\n case 46:\n return 45;\n case 47:\n return 46;\n case 48:\n return 47;\n case 49:\n return 47;\n case 50:\n return 46;\n case 51:\n return 46;\n case 52:\n return 46;\n case 53:\n return 27;\n case 54:\n return yy_.yytext[0];\n case 55:\n return 6;\n }\n },\n rules: [/^(?:accTitle\\s*:\\s*)/i, /^(?:(?!\\n||)*[^\\n]*)/i, /^(?:accDescr\\s*:\\s*)/i, /^(?:(?!\\n||)*[^\\n]*)/i, /^(?:accDescr\\s*\\{\\s*)/i, /^(?:[\\}])/i, /^(?:[^\\}]*)/i, /^(?:[\\n]+)/i, /^(?:\\s+)/i, /^(?:[\\s]+)/i, /^(?:\"[^\"%\\r\\n\\v\\b\\\\]+\")/i, /^(?:\"[^\"]*\")/i, /^(?:erDiagram\\b)/i, /^(?:\\{)/i, /^(?:,)/i, /^(?:\\s+)/i, /^(?:\\b((?:PK)|(?:FK)|(?:UK))\\b)/i, /^(?:(.*?)[~](.*?)*[~])/i, /^(?:[\\*A-Za-z_][A-Za-z0-9\\-_\\[\\]\\(\\)]*)/i, /^(?:\"[^\"]*\")/i, /^(?:[\\n]+)/i, /^(?:\\})/i, /^(?:.)/i, /^(?:\\[)/i, /^(?:\\])/i, /^(?:one or zero\\b)/i, /^(?:one or more\\b)/i, /^(?:one or many\\b)/i, /^(?:1\\+)/i, /^(?:\\|o\\b)/i, /^(?:zero or one\\b)/i, /^(?:zero or more\\b)/i, /^(?:zero or many\\b)/i, /^(?:0\\+)/i, /^(?:\\}o\\b)/i, /^(?:many\\(0\\))/i, /^(?:many\\(1\\))/i, /^(?:many\\b)/i, /^(?:\\}\\|)/i, /^(?:one\\b)/i, /^(?:only one\\b)/i, /^(?:1\\b)/i, /^(?:\\|\\|)/i, /^(?:o\\|)/i, /^(?:o\\{)/i, /^(?:\\|\\{)/i, /^(?:\\s*u\\b)/i, /^(?:\\.\\.)/i, /^(?:--)/i, /^(?:to\\b)/i, /^(?:optionally to\\b)/i, /^(?:\\.-)/i, /^(?:-\\.)/i, /^(?:[A-Za-z_][A-Za-z0-9\\-_]*)/i, /^(?:.)/i, /^(?:$)/i],\n conditions: { \"acc_descr_multiline\": { \"rules\": [5, 6], \"inclusive\": false }, \"acc_descr\": { \"rules\": [3], \"inclusive\": false }, \"acc_title\": { \"rules\": [1], \"inclusive\": false }, \"block\": { \"rules\": [14, 15, 16, 17, 18, 19, 20, 21, 22], \"inclusive\": false }, \"INITIAL\": { \"rules\": [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55], \"inclusive\": true } }\n };\n return lexer2;\n }();\n parser2.lexer = lexer;\n function Parser() {\n this.yy = {};\n }\n Parser.prototype = parser2;\n parser2.Parser = Parser;\n return new Parser();\n}();\nparser.parser = parser;\nconst erParser = parser;\nlet entities = {};\nlet relationships = [];\nconst Cardinality = {\n ZERO_OR_ONE: \"ZERO_OR_ONE\",\n ZERO_OR_MORE: \"ZERO_OR_MORE\",\n ONE_OR_MORE: \"ONE_OR_MORE\",\n ONLY_ONE: \"ONLY_ONE\",\n MD_PARENT: \"MD_PARENT\"\n};\nconst Identification = {\n NON_IDENTIFYING: \"NON_IDENTIFYING\",\n IDENTIFYING: \"IDENTIFYING\"\n};\nconst addEntity = function(name, alias = void 0) {\n if (entities[name] === void 0) {\n entities[name] = { attributes: [], alias };\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.l.info(\"Added new entity :\", name);\n } else if (entities[name] && !entities[name].alias && alias) {\n entities[name].alias = alias;\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.l.info(`Add alias '${alias}' to entity '${name}'`);\n }\n return entities[name];\n};\nconst getEntities = () => entities;\nconst addAttributes = function(entityName, attribs) {\n let entity = addEntity(entityName);\n let i;\n for (i = attribs.length - 1; i >= 0; i--) {\n entity.attributes.push(attribs[i]);\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.l.debug(\"Added attribute \", attribs[i].attributeName);\n }\n};\nconst addRelationship = function(entA, rolA, entB, rSpec) {\n let rel = {\n entityA: entA,\n roleA: rolA,\n entityB: entB,\n relSpec: rSpec\n };\n relationships.push(rel);\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.l.debug(\"Added new relationship :\", rel);\n};\nconst getRelationships = () => relationships;\nconst clear = function() {\n entities = {};\n relationships = [];\n (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.v)();\n};\nconst erDb = {\n Cardinality,\n Identification,\n getConfig: () => (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().er,\n addEntity,\n addAttributes,\n getEntities,\n addRelationship,\n getRelationships,\n clear,\n setAccTitle: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.s,\n getAccTitle: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.g,\n setAccDescription: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.b,\n getAccDescription: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.a,\n setDiagramTitle: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.q,\n getDiagramTitle: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.t\n};\nconst ERMarkers = {\n ONLY_ONE_START: \"ONLY_ONE_START\",\n ONLY_ONE_END: \"ONLY_ONE_END\",\n ZERO_OR_ONE_START: \"ZERO_OR_ONE_START\",\n ZERO_OR_ONE_END: \"ZERO_OR_ONE_END\",\n ONE_OR_MORE_START: \"ONE_OR_MORE_START\",\n ONE_OR_MORE_END: \"ONE_OR_MORE_END\",\n ZERO_OR_MORE_START: \"ZERO_OR_MORE_START\",\n ZERO_OR_MORE_END: \"ZERO_OR_MORE_END\",\n MD_PARENT_END: \"MD_PARENT_END\",\n MD_PARENT_START: \"MD_PARENT_START\"\n};\nconst insertMarkers = function(elem, conf2) {\n let marker;\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.MD_PARENT_START).attr(\"refX\", 0).attr(\"refY\", 7).attr(\"markerWidth\", 190).attr(\"markerHeight\", 240).attr(\"orient\", \"auto\").append(\"path\").attr(\"d\", \"M 18,7 L9,13 L1,7 L9,1 Z\");\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.MD_PARENT_END).attr(\"refX\", 19).attr(\"refY\", 7).attr(\"markerWidth\", 20).attr(\"markerHeight\", 28).attr(\"orient\", \"auto\").append(\"path\").attr(\"d\", \"M 18,7 L9,13 L1,7 L9,1 Z\");\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ONLY_ONE_START).attr(\"refX\", 0).attr(\"refY\", 9).attr(\"markerWidth\", 18).attr(\"markerHeight\", 18).attr(\"orient\", \"auto\").append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M9,0 L9,18 M15,0 L15,18\");\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ONLY_ONE_END).attr(\"refX\", 18).attr(\"refY\", 9).attr(\"markerWidth\", 18).attr(\"markerHeight\", 18).attr(\"orient\", \"auto\").append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M3,0 L3,18 M9,0 L9,18\");\n marker = elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ZERO_OR_ONE_START).attr(\"refX\", 0).attr(\"refY\", 9).attr(\"markerWidth\", 30).attr(\"markerHeight\", 18).attr(\"orient\", \"auto\");\n marker.append(\"circle\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"white\").attr(\"cx\", 21).attr(\"cy\", 9).attr(\"r\", 6);\n marker.append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M9,0 L9,18\");\n marker = elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ZERO_OR_ONE_END).attr(\"refX\", 30).attr(\"refY\", 9).attr(\"markerWidth\", 30).attr(\"markerHeight\", 18).attr(\"orient\", \"auto\");\n marker.append(\"circle\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"white\").attr(\"cx\", 9).attr(\"cy\", 9).attr(\"r\", 6);\n marker.append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M21,0 L21,18\");\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ONE_OR_MORE_START).attr(\"refX\", 18).attr(\"refY\", 18).attr(\"markerWidth\", 45).attr(\"markerHeight\", 36).attr(\"orient\", \"auto\").append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27\");\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ONE_OR_MORE_END).attr(\"refX\", 27).attr(\"refY\", 18).attr(\"markerWidth\", 45).attr(\"markerHeight\", 36).attr(\"orient\", \"auto\").append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18\");\n marker = elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ZERO_OR_MORE_START).attr(\"refX\", 18).attr(\"refY\", 18).attr(\"markerWidth\", 57).attr(\"markerHeight\", 36).attr(\"orient\", \"auto\");\n marker.append(\"circle\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"white\").attr(\"cx\", 48).attr(\"cy\", 18).attr(\"r\", 6);\n marker.append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M0,18 Q18,0 36,18 Q18,36 0,18\");\n marker = elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ZERO_OR_MORE_END).attr(\"refX\", 39).attr(\"refY\", 18).attr(\"markerWidth\", 57).attr(\"markerHeight\", 36).attr(\"orient\", \"auto\");\n marker.append(\"circle\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"white\").attr(\"cx\", 9).attr(\"cy\", 18).attr(\"r\", 6);\n marker.append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M21,18 Q39,0 57,18 Q39,36 21,18\");\n return;\n};\nconst erMarkers = {\n ERMarkers,\n insertMarkers\n};\nconst BAD_ID_CHARS_REGEXP = /[^\\dA-Za-z](\\W)*/g;\nlet conf = {};\nlet entityNameIds = /* @__PURE__ */ new Map();\nconst setConf = function(cnf) {\n const keys = Object.keys(cnf);\n for (const key of keys) {\n conf[key] = cnf[key];\n }\n};\nconst drawAttributes = (groupNode, entityTextNode, attributes) => {\n const heightPadding = conf.entityPadding / 3;\n const widthPadding = conf.entityPadding / 3;\n const attrFontSize = conf.fontSize * 0.85;\n const labelBBox = entityTextNode.node().getBBox();\n const attributeNodes = [];\n let hasKeyType = false;\n let hasComment = false;\n let maxTypeWidth = 0;\n let maxNameWidth = 0;\n let maxKeyWidth = 0;\n let maxCommentWidth = 0;\n let cumulativeHeight = labelBBox.height + heightPadding * 2;\n let attrNum = 1;\n attributes.forEach((item) => {\n if (item.attributeKeyTypeList !== void 0 && item.attributeKeyTypeList.length > 0) {\n hasKeyType = true;\n }\n if (item.attributeComment !== void 0) {\n hasComment = true;\n }\n });\n attributes.forEach((item) => {\n const attrPrefix = `${entityTextNode.node().id}-attr-${attrNum}`;\n let nodeHeight = 0;\n const attributeType = (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.x)(item.attributeType);\n const typeNode = groupNode.append(\"text\").classed(\"er entityLabel\", true).attr(\"id\", `${attrPrefix}-type`).attr(\"x\", 0).attr(\"y\", 0).style(\"dominant-baseline\", \"middle\").style(\"text-anchor\", \"left\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", attrFontSize + \"px\").text(attributeType);\n const nameNode = groupNode.append(\"text\").classed(\"er entityLabel\", true).attr(\"id\", `${attrPrefix}-name`).attr(\"x\", 0).attr(\"y\", 0).style(\"dominant-baseline\", \"middle\").style(\"text-anchor\", \"left\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", attrFontSize + \"px\").text(item.attributeName);\n const attributeNode = {};\n attributeNode.tn = typeNode;\n attributeNode.nn = nameNode;\n const typeBBox = typeNode.node().getBBox();\n const nameBBox = nameNode.node().getBBox();\n maxTypeWidth = Math.max(maxTypeWidth, typeBBox.width);\n maxNameWidth = Math.max(maxNameWidth, nameBBox.width);\n nodeHeight = Math.max(typeBBox.height, nameBBox.height);\n if (hasKeyType) {\n const keyTypeNodeText = item.attributeKeyTypeList !== void 0 ? item.attributeKeyTypeList.join(\",\") : \"\";\n const keyTypeNode = groupNode.append(\"text\").classed(\"er entityLabel\", true).attr(\"id\", `${attrPrefix}-key`).attr(\"x\", 0).attr(\"y\", 0).style(\"dominant-baseline\", \"middle\").style(\"text-anchor\", \"left\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", attrFontSize + \"px\").text(keyTypeNodeText);\n attributeNode.kn = keyTypeNode;\n const keyTypeBBox = keyTypeNode.node().getBBox();\n maxKeyWidth = Math.max(maxKeyWidth, keyTypeBBox.width);\n nodeHeight = Math.max(nodeHeight, keyTypeBBox.height);\n }\n if (hasComment) {\n const commentNode = groupNode.append(\"text\").classed(\"er entityLabel\", true).attr(\"id\", `${attrPrefix}-comment`).attr(\"x\", 0).attr(\"y\", 0).style(\"dominant-baseline\", \"middle\").style(\"text-anchor\", \"left\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", attrFontSize + \"px\").text(item.attributeComment || \"\");\n attributeNode.cn = commentNode;\n const commentNodeBBox = commentNode.node().getBBox();\n maxCommentWidth = Math.max(maxCommentWidth, commentNodeBBox.width);\n nodeHeight = Math.max(nodeHeight, commentNodeBBox.height);\n }\n attributeNode.height = nodeHeight;\n attributeNodes.push(attributeNode);\n cumulativeHeight += nodeHeight + heightPadding * 2;\n attrNum += 1;\n });\n let widthPaddingFactor = 4;\n if (hasKeyType) {\n widthPaddingFactor += 2;\n }\n if (hasComment) {\n widthPaddingFactor += 2;\n }\n const maxWidth = maxTypeWidth + maxNameWidth + maxKeyWidth + maxCommentWidth;\n const bBox = {\n width: Math.max(\n conf.minEntityWidth,\n Math.max(\n labelBBox.width + conf.entityPadding * 2,\n maxWidth + widthPadding * widthPaddingFactor\n )\n ),\n height: attributes.length > 0 ? cumulativeHeight : Math.max(conf.minEntityHeight, labelBBox.height + conf.entityPadding * 2)\n };\n if (attributes.length > 0) {\n const spareColumnWidth = Math.max(\n 0,\n (bBox.width - maxWidth - widthPadding * widthPaddingFactor) / (widthPaddingFactor / 2)\n );\n entityTextNode.attr(\n \"transform\",\n \"translate(\" + bBox.width / 2 + \",\" + (heightPadding + labelBBox.height / 2) + \")\"\n );\n let heightOffset = labelBBox.height + heightPadding * 2;\n let attribStyle = \"attributeBoxOdd\";\n attributeNodes.forEach((attributeNode) => {\n const alignY = heightOffset + heightPadding + attributeNode.height / 2;\n attributeNode.tn.attr(\"transform\", \"translate(\" + widthPadding + \",\" + alignY + \")\");\n const typeRect = groupNode.insert(\"rect\", \"#\" + attributeNode.tn.node().id).classed(`er ${attribStyle}`, true).attr(\"x\", 0).attr(\"y\", heightOffset).attr(\"width\", maxTypeWidth + widthPadding * 2 + spareColumnWidth).attr(\"height\", attributeNode.height + heightPadding * 2);\n const nameXOffset = parseFloat(typeRect.attr(\"x\")) + parseFloat(typeRect.attr(\"width\"));\n attributeNode.nn.attr(\n \"transform\",\n \"translate(\" + (nameXOffset + widthPadding) + \",\" + alignY + \")\"\n );\n const nameRect = groupNode.insert(\"rect\", \"#\" + attributeNode.nn.node().id).classed(`er ${attribStyle}`, true).attr(\"x\", nameXOffset).attr(\"y\", heightOffset).attr(\"width\", maxNameWidth + widthPadding * 2 + spareColumnWidth).attr(\"height\", attributeNode.height + heightPadding * 2);\n let keyTypeAndCommentXOffset = parseFloat(nameRect.attr(\"x\")) + parseFloat(nameRect.attr(\"width\"));\n if (hasKeyType) {\n attributeNode.kn.attr(\n \"transform\",\n \"translate(\" + (keyTypeAndCommentXOffset + widthPadding) + \",\" + alignY + \")\"\n );\n const keyTypeRect = groupNode.insert(\"rect\", \"#\" + attributeNode.kn.node().id).classed(`er ${attribStyle}`, true).attr(\"x\", keyTypeAndCommentXOffset).attr(\"y\", heightOffset).attr(\"width\", maxKeyWidth + widthPadding * 2 + spareColumnWidth).attr(\"height\", attributeNode.height + heightPadding * 2);\n keyTypeAndCommentXOffset = parseFloat(keyTypeRect.attr(\"x\")) + parseFloat(keyTypeRect.attr(\"width\"));\n }\n if (hasComment) {\n attributeNode.cn.attr(\n \"transform\",\n \"translate(\" + (keyTypeAndCommentXOffset + widthPadding) + \",\" + alignY + \")\"\n );\n groupNode.insert(\"rect\", \"#\" + attributeNode.cn.node().id).classed(`er ${attribStyle}`, \"true\").attr(\"x\", keyTypeAndCommentXOffset).attr(\"y\", heightOffset).attr(\"width\", maxCommentWidth + widthPadding * 2 + spareColumnWidth).attr(\"height\", attributeNode.height + heightPadding * 2);\n }\n heightOffset += attributeNode.height + heightPadding * 2;\n attribStyle = attribStyle === \"attributeBoxOdd\" ? \"attributeBoxEven\" : \"attributeBoxOdd\";\n });\n } else {\n bBox.height = Math.max(conf.minEntityHeight, cumulativeHeight);\n entityTextNode.attr(\"transform\", \"translate(\" + bBox.width / 2 + \",\" + bBox.height / 2 + \")\");\n }\n return bBox;\n};\nconst drawEntities = function(svgNode, entities2, graph) {\n const keys = Object.keys(entities2);\n let firstOne;\n keys.forEach(function(entityName) {\n const entityId = generateId(entityName, \"entity\");\n entityNameIds.set(entityName, entityId);\n const groupNode = svgNode.append(\"g\").attr(\"id\", entityId);\n firstOne = firstOne === void 0 ? entityId : firstOne;\n const textId = \"text-\" + entityId;\n const textNode = groupNode.append(\"text\").classed(\"er entityLabel\", true).attr(\"id\", textId).attr(\"x\", 0).attr(\"y\", 0).style(\"dominant-baseline\", \"middle\").style(\"text-anchor\", \"middle\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", conf.fontSize + \"px\").text(entities2[entityName].alias ?? entityName);\n const { width: entityWidth, height: entityHeight } = drawAttributes(\n groupNode,\n textNode,\n entities2[entityName].attributes\n );\n const rectNode = groupNode.insert(\"rect\", \"#\" + textId).classed(\"er entityBox\", true).attr(\"x\", 0).attr(\"y\", 0).attr(\"width\", entityWidth).attr(\"height\", entityHeight);\n const rectBBox = rectNode.node().getBBox();\n graph.setNode(entityId, {\n width: rectBBox.width,\n height: rectBBox.height,\n shape: \"rect\",\n id: entityId\n });\n });\n return firstOne;\n};\nconst adjustEntities = function(svgNode, graph) {\n graph.nodes().forEach(function(v) {\n if (v !== void 0 && graph.node(v) !== void 0) {\n svgNode.select(\"#\" + v).attr(\n \"transform\",\n \"translate(\" + (graph.node(v).x - graph.node(v).width / 2) + \",\" + (graph.node(v).y - graph.node(v).height / 2) + \" )\"\n );\n }\n });\n};\nconst getEdgeName = function(rel) {\n return (rel.entityA + rel.roleA + rel.entityB).replace(/\\s/g, \"\");\n};\nconst addRelationships = function(relationships2, g) {\n relationships2.forEach(function(r) {\n g.setEdge(\n entityNameIds.get(r.entityA),\n entityNameIds.get(r.entityB),\n { relationship: r },\n getEdgeName(r)\n );\n });\n return relationships2;\n};\nlet relCnt = 0;\nconst drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) {\n relCnt++;\n const edge = g.edge(\n entityNameIds.get(rel.entityA),\n entityNameIds.get(rel.entityB),\n getEdgeName(rel)\n );\n const lineFunction = (0,d3__WEBPACK_IMPORTED_MODULE_1__.line)().x(function(d) {\n return d.x;\n }).y(function(d) {\n return d.y;\n }).curve(d3__WEBPACK_IMPORTED_MODULE_1__.curveBasis);\n const svgPath = svg.insert(\"path\", \"#\" + insert).classed(\"er relationshipLine\", true).attr(\"d\", lineFunction(edge.points)).style(\"stroke\", conf.stroke).style(\"fill\", \"none\");\n if (rel.relSpec.relType === diagObj.db.Identification.NON_IDENTIFYING) {\n svgPath.attr(\"stroke-dasharray\", \"8,8\");\n }\n let url = \"\";\n if (conf.arrowMarkerAbsolute) {\n url = window.location.protocol + \"//\" + window.location.host + window.location.pathname + window.location.search;\n url = url.replace(/\\(/g, \"\\\\(\");\n url = url.replace(/\\)/g, \"\\\\)\");\n }\n switch (rel.relSpec.cardA) {\n case diagObj.db.Cardinality.ZERO_OR_ONE:\n svgPath.attr(\"marker-end\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.ZERO_OR_ONE_END + \")\");\n break;\n case diagObj.db.Cardinality.ZERO_OR_MORE:\n svgPath.attr(\"marker-end\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.ZERO_OR_MORE_END + \")\");\n break;\n case diagObj.db.Cardinality.ONE_OR_MORE:\n svgPath.attr(\"marker-end\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.ONE_OR_MORE_END + \")\");\n break;\n case diagObj.db.Cardinality.ONLY_ONE:\n svgPath.attr(\"marker-end\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.ONLY_ONE_END + \")\");\n break;\n case diagObj.db.Cardinality.MD_PARENT:\n svgPath.attr(\"marker-end\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.MD_PARENT_END + \")\");\n break;\n }\n switch (rel.relSpec.cardB) {\n case diagObj.db.Cardinality.ZERO_OR_ONE:\n svgPath.attr(\n \"marker-start\",\n \"url(\" + url + \"#\" + erMarkers.ERMarkers.ZERO_OR_ONE_START + \")\"\n );\n break;\n case diagObj.db.Cardinality.ZERO_OR_MORE:\n svgPath.attr(\n \"marker-start\",\n \"url(\" + url + \"#\" + erMarkers.ERMarkers.ZERO_OR_MORE_START + \")\"\n );\n break;\n case diagObj.db.Cardinality.ONE_OR_MORE:\n svgPath.attr(\n \"marker-start\",\n \"url(\" + url + \"#\" + erMarkers.ERMarkers.ONE_OR_MORE_START + \")\"\n );\n break;\n case diagObj.db.Cardinality.ONLY_ONE:\n svgPath.attr(\"marker-start\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.ONLY_ONE_START + \")\");\n break;\n case diagObj.db.Cardinality.MD_PARENT:\n svgPath.attr(\"marker-start\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.MD_PARENT_START + \")\");\n break;\n }\n const len = svgPath.node().getTotalLength();\n const labelPoint = svgPath.node().getPointAtLength(len * 0.5);\n const labelId = \"rel\" + relCnt;\n const labelNode = svg.append(\"text\").classed(\"er relationshipLabel\", true).attr(\"id\", labelId).attr(\"x\", labelPoint.x).attr(\"y\", labelPoint.y).style(\"text-anchor\", \"middle\").style(\"dominant-baseline\", \"middle\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", conf.fontSize + \"px\").text(rel.roleA);\n const labelBBox = labelNode.node().getBBox();\n svg.insert(\"rect\", \"#\" + labelId).classed(\"er relationshipLabelBox\", true).attr(\"x\", labelPoint.x - labelBBox.width / 2).attr(\"y\", labelPoint.y - labelBBox.height / 2).attr(\"width\", labelBBox.width).attr(\"height\", labelBBox.height);\n};\nconst draw = function(text, id, _version, diagObj) {\n conf = (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().er;\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.l.info(\"Drawing ER diagram\");\n const securityLevel = (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().securityLevel;\n let sandboxElement;\n if (securityLevel === \"sandbox\") {\n sandboxElement = (0,d3__WEBPACK_IMPORTED_MODULE_1__.select)(\"#i\" + id);\n }\n const root = securityLevel === \"sandbox\" ? (0,d3__WEBPACK_IMPORTED_MODULE_1__.select)(sandboxElement.nodes()[0].contentDocument.body) : (0,d3__WEBPACK_IMPORTED_MODULE_1__.select)(\"body\");\n const svg = root.select(`[id='${id}']`);\n erMarkers.insertMarkers(svg, conf);\n let g;\n g = new dagre_d3_es_src_graphlib_index_js__WEBPACK_IMPORTED_MODULE_0__.Graph({\n multigraph: true,\n directed: true,\n compound: false\n }).setGraph({\n rankdir: conf.layoutDirection,\n marginx: 20,\n marginy: 20,\n nodesep: 100,\n edgesep: 100,\n ranksep: 100\n }).setDefaultEdgeLabel(function() {\n return {};\n });\n const firstEntity = drawEntities(svg, diagObj.db.getEntities(), g);\n const relationships2 = addRelationships(diagObj.db.getRelationships(), g);\n (0,dagre_d3_es_src_dagre_index_js__WEBPACK_IMPORTED_MODULE_2__.layout)(g);\n adjustEntities(svg, g);\n relationships2.forEach(function(rel) {\n drawRelationshipFromLayout(svg, rel, g, firstEntity, diagObj);\n });\n const padding = conf.diagramPadding;\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.u.insertTitle(svg, \"entityTitleText\", conf.titleTopMargin, diagObj.db.getDiagramTitle());\n const svgBounds = svg.node().getBBox();\n const width = svgBounds.width + padding * 2;\n const height = svgBounds.height + padding * 2;\n (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.i)(svg, height, width, conf.useMaxWidth);\n svg.attr(\"viewBox\", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`);\n};\nconst MERMAID_ERDIAGRAM_UUID = \"28e9f9db-3c8d-5aa5-9faf-44286ae5937c\";\nfunction generateId(str = \"\", prefix = \"\") {\n const simplifiedStr = str.replace(BAD_ID_CHARS_REGEXP, \"\");\n return `${strWithHyphen(prefix)}${strWithHyphen(simplifiedStr)}${(0,uuid__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(\n str,\n MERMAID_ERDIAGRAM_UUID\n )}`;\n}\nfunction strWithHyphen(str = \"\") {\n return str.length > 0 ? `${str}-` : \"\";\n}\nconst erRenderer = {\n setConf,\n draw\n};\nconst getStyles = (options) => `\n .entityBox {\n fill: ${options.mainBkg};\n stroke: ${options.nodeBorder};\n }\n\n .attributeBoxOdd {\n fill: ${options.attributeBackgroundColorOdd};\n stroke: ${options.nodeBorder};\n }\n\n .attributeBoxEven {\n fill: ${options.attributeBackgroundColorEven};\n stroke: ${options.nodeBorder};\n }\n\n .relationshipLabelBox {\n fill: ${options.tertiaryColor};\n opacity: 0.7;\n background-color: ${options.tertiaryColor};\n rect {\n opacity: 0.5;\n }\n }\n\n .relationshipLine {\n stroke: ${options.lineColor};\n }\n\n .entityTitleText {\n text-anchor: middle;\n font-size: 18px;\n fill: ${options.textColor};\n } \n #MD_PARENT_START {\n fill: #f5f5f5 !important;\n stroke: ${options.lineColor} !important;\n stroke-width: 1;\n }\n #MD_PARENT_END {\n fill: #f5f5f5 !important;\n stroke: ${options.lineColor} !important;\n stroke-width: 1;\n }\n \n`;\nconst erStyles = getStyles;\nconst diagram = {\n parser: erParser,\n db: erDb,\n renderer: erRenderer,\n styles: erStyles\n};\n\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/mermaid/dist/erDiagram-880f2ed8.js?");
11102
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ diagram: () => (/* binding */ diagram)\n/* harmony export */ });\n/* harmony import */ var _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./mermaid-ad1dc92f.js */ \"../../node_modules/mermaid/dist/mermaid-ad1dc92f.js\");\n/* harmony import */ var dagre_d3_es_src_graphlib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! dagre-d3-es/src/graphlib/index.js */ \"../../node_modules/dagre-d3-es/src/graphlib/index.js\");\n/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! d3 */ \"../../node_modules/d3/src/index.js\");\n/* harmony import */ var dagre_d3_es_src_dagre_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! dagre-d3-es/src/dagre/index.js */ \"../../node_modules/dagre-d3-es/src/dagre/index.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uuid */ \"../../node_modules/uuid/dist/esm-browser/v5.js\");\n/* harmony import */ var ts_dedent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ts-dedent */ \"../../node_modules/ts-dedent/esm/index.js\");\n/* harmony import */ var dayjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! dayjs */ \"../../node_modules/dayjs/dayjs.min.js\");\n/* harmony import */ var _braintree_sanitize_url__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @braintree/sanitize-url */ \"../../node_modules/mermaid/node_modules/@braintree/sanitize-url/dist/index.js\");\n/* harmony import */ var dompurify__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! dompurify */ \"../../node_modules/dompurify/dist/purify.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar parser = function() {\n var o = function(k, v, o2, l) {\n for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)\n ;\n return o2;\n }, $V0 = [6, 8, 10, 20, 22, 24, 26, 27, 28], $V1 = [1, 10], $V2 = [1, 11], $V3 = [1, 12], $V4 = [1, 13], $V5 = [1, 14], $V6 = [1, 15], $V7 = [1, 21], $V8 = [1, 22], $V9 = [1, 23], $Va = [1, 24], $Vb = [1, 25], $Vc = [6, 8, 10, 13, 15, 18, 19, 20, 22, 24, 26, 27, 28, 41, 42, 43, 44, 45], $Vd = [1, 34], $Ve = [27, 28, 46, 47], $Vf = [41, 42, 43, 44, 45], $Vg = [17, 34], $Vh = [1, 54], $Vi = [1, 53], $Vj = [17, 34, 36, 38];\n var parser2 = {\n trace: function trace() {\n },\n yy: {},\n symbols_: { \"error\": 2, \"start\": 3, \"ER_DIAGRAM\": 4, \"document\": 5, \"EOF\": 6, \"line\": 7, \"SPACE\": 8, \"statement\": 9, \"NEWLINE\": 10, \"entityName\": 11, \"relSpec\": 12, \":\": 13, \"role\": 14, \"BLOCK_START\": 15, \"attributes\": 16, \"BLOCK_STOP\": 17, \"SQS\": 18, \"SQE\": 19, \"title\": 20, \"title_value\": 21, \"acc_title\": 22, \"acc_title_value\": 23, \"acc_descr\": 24, \"acc_descr_value\": 25, \"acc_descr_multiline_value\": 26, \"ALPHANUM\": 27, \"ENTITY_NAME\": 28, \"attribute\": 29, \"attributeType\": 30, \"attributeName\": 31, \"attributeKeyTypeList\": 32, \"attributeComment\": 33, \"ATTRIBUTE_WORD\": 34, \"attributeKeyType\": 35, \"COMMA\": 36, \"ATTRIBUTE_KEY\": 37, \"COMMENT\": 38, \"cardinality\": 39, \"relType\": 40, \"ZERO_OR_ONE\": 41, \"ZERO_OR_MORE\": 42, \"ONE_OR_MORE\": 43, \"ONLY_ONE\": 44, \"MD_PARENT\": 45, \"NON_IDENTIFYING\": 46, \"IDENTIFYING\": 47, \"WORD\": 48, \"$accept\": 0, \"$end\": 1 },\n terminals_: { 2: \"error\", 4: \"ER_DIAGRAM\", 6: \"EOF\", 8: \"SPACE\", 10: \"NEWLINE\", 13: \":\", 15: \"BLOCK_START\", 17: \"BLOCK_STOP\", 18: \"SQS\", 19: \"SQE\", 20: \"title\", 21: \"title_value\", 22: \"acc_title\", 23: \"acc_title_value\", 24: \"acc_descr\", 25: \"acc_descr_value\", 26: \"acc_descr_multiline_value\", 27: \"ALPHANUM\", 28: \"ENTITY_NAME\", 34: \"ATTRIBUTE_WORD\", 36: \"COMMA\", 37: \"ATTRIBUTE_KEY\", 38: \"COMMENT\", 41: \"ZERO_OR_ONE\", 42: \"ZERO_OR_MORE\", 43: \"ONE_OR_MORE\", 44: \"ONLY_ONE\", 45: \"MD_PARENT\", 46: \"NON_IDENTIFYING\", 47: \"IDENTIFYING\", 48: \"WORD\" },\n productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 5], [9, 4], [9, 3], [9, 1], [9, 7], [9, 6], [9, 4], [9, 2], [9, 2], [9, 2], [9, 1], [11, 1], [11, 1], [16, 1], [16, 2], [29, 2], [29, 3], [29, 3], [29, 4], [30, 1], [31, 1], [32, 1], [32, 3], [35, 1], [33, 1], [12, 3], [39, 1], [39, 1], [39, 1], [39, 1], [39, 1], [40, 1], [40, 1], [14, 1], [14, 1], [14, 1]],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {\n var $0 = $$.length - 1;\n switch (yystate) {\n case 1:\n break;\n case 2:\n this.$ = [];\n break;\n case 3:\n $$[$0 - 1].push($$[$0]);\n this.$ = $$[$0 - 1];\n break;\n case 4:\n case 5:\n this.$ = $$[$0];\n break;\n case 6:\n case 7:\n this.$ = [];\n break;\n case 8:\n yy.addEntity($$[$0 - 4]);\n yy.addEntity($$[$0 - 2]);\n yy.addRelationship($$[$0 - 4], $$[$0], $$[$0 - 2], $$[$0 - 3]);\n break;\n case 9:\n yy.addEntity($$[$0 - 3]);\n yy.addAttributes($$[$0 - 3], $$[$0 - 1]);\n break;\n case 10:\n yy.addEntity($$[$0 - 2]);\n break;\n case 11:\n yy.addEntity($$[$0]);\n break;\n case 12:\n yy.addEntity($$[$0 - 6], $$[$0 - 4]);\n yy.addAttributes($$[$0 - 6], $$[$0 - 1]);\n break;\n case 13:\n yy.addEntity($$[$0 - 5], $$[$0 - 3]);\n break;\n case 14:\n yy.addEntity($$[$0 - 3], $$[$0 - 1]);\n break;\n case 15:\n case 16:\n this.$ = $$[$0].trim();\n yy.setAccTitle(this.$);\n break;\n case 17:\n case 18:\n this.$ = $$[$0].trim();\n yy.setAccDescription(this.$);\n break;\n case 19:\n case 43:\n this.$ = $$[$0];\n break;\n case 20:\n case 41:\n case 42:\n this.$ = $$[$0].replace(/\"/g, \"\");\n break;\n case 21:\n case 29:\n this.$ = [$$[$0]];\n break;\n case 22:\n $$[$0].push($$[$0 - 1]);\n this.$ = $$[$0];\n break;\n case 23:\n this.$ = { attributeType: $$[$0 - 1], attributeName: $$[$0] };\n break;\n case 24:\n this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeKeyTypeList: $$[$0] };\n break;\n case 25:\n this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeComment: $$[$0] };\n break;\n case 26:\n this.$ = { attributeType: $$[$0 - 3], attributeName: $$[$0 - 2], attributeKeyTypeList: $$[$0 - 1], attributeComment: $$[$0] };\n break;\n case 27:\n case 28:\n case 31:\n this.$ = $$[$0];\n break;\n case 30:\n $$[$0 - 2].push($$[$0]);\n this.$ = $$[$0 - 2];\n break;\n case 32:\n this.$ = $$[$0].replace(/\"/g, \"\");\n break;\n case 33:\n this.$ = { cardA: $$[$0], relType: $$[$0 - 1], cardB: $$[$0 - 2] };\n break;\n case 34:\n this.$ = yy.Cardinality.ZERO_OR_ONE;\n break;\n case 35:\n this.$ = yy.Cardinality.ZERO_OR_MORE;\n break;\n case 36:\n this.$ = yy.Cardinality.ONE_OR_MORE;\n break;\n case 37:\n this.$ = yy.Cardinality.ONLY_ONE;\n break;\n case 38:\n this.$ = yy.Cardinality.MD_PARENT;\n break;\n case 39:\n this.$ = yy.Identification.NON_IDENTIFYING;\n break;\n case 40:\n this.$ = yy.Identification.IDENTIFYING;\n break;\n }\n },\n table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 16, 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 11], { 12: 17, 39: 20, 15: [1, 18], 18: [1, 19], 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }), { 21: [1, 26] }, { 23: [1, 27] }, { 25: [1, 28] }, o($V0, [2, 18]), o($Vc, [2, 19]), o($Vc, [2, 20]), o($V0, [2, 4]), { 11: 29, 27: $V5, 28: $V6 }, { 16: 30, 17: [1, 31], 29: 32, 30: 33, 34: $Vd }, { 11: 35, 27: $V5, 28: $V6 }, { 40: 36, 46: [1, 37], 47: [1, 38] }, o($Ve, [2, 34]), o($Ve, [2, 35]), o($Ve, [2, 36]), o($Ve, [2, 37]), o($Ve, [2, 38]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 17]), { 13: [1, 39] }, { 17: [1, 40] }, o($V0, [2, 10]), { 16: 41, 17: [2, 21], 29: 32, 30: 33, 34: $Vd }, { 31: 42, 34: [1, 43] }, { 34: [2, 27] }, { 19: [1, 44] }, { 39: 45, 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }, o($Vf, [2, 39]), o($Vf, [2, 40]), { 14: 46, 27: [1, 49], 28: [1, 48], 48: [1, 47] }, o($V0, [2, 9]), { 17: [2, 22] }, o($Vg, [2, 23], { 32: 50, 33: 51, 35: 52, 37: $Vh, 38: $Vi }), o([17, 34, 37, 38], [2, 28]), o($V0, [2, 14], { 15: [1, 55] }), o([27, 28], [2, 33]), o($V0, [2, 8]), o($V0, [2, 41]), o($V0, [2, 42]), o($V0, [2, 43]), o($Vg, [2, 24], { 33: 56, 36: [1, 57], 38: $Vi }), o($Vg, [2, 25]), o($Vj, [2, 29]), o($Vg, [2, 32]), o($Vj, [2, 31]), { 16: 58, 17: [1, 59], 29: 32, 30: 33, 34: $Vd }, o($Vg, [2, 26]), { 35: 60, 37: $Vh }, { 17: [1, 61] }, o($V0, [2, 13]), o($Vj, [2, 30]), o($V0, [2, 12])],\n defaultActions: { 34: [2, 27], 41: [2, 22] },\n parseError: function parseError(str, hash) {\n if (hash.recoverable) {\n this.trace(str);\n } else {\n var error = new Error(str);\n error.hash = hash;\n throw error;\n }\n },\n parse: function parse(input) {\n var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = \"\", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;\n var args = lstack.slice.call(arguments, 1);\n var lexer2 = Object.create(this.lexer);\n var sharedState = { yy: {} };\n for (var k in this.yy) {\n if (Object.prototype.hasOwnProperty.call(this.yy, k)) {\n sharedState.yy[k] = this.yy[k];\n }\n }\n lexer2.setInput(input, sharedState.yy);\n sharedState.yy.lexer = lexer2;\n sharedState.yy.parser = this;\n if (typeof lexer2.yylloc == \"undefined\") {\n lexer2.yylloc = {};\n }\n var yyloc = lexer2.yylloc;\n lstack.push(yyloc);\n var ranges = lexer2.options && lexer2.options.ranges;\n if (typeof sharedState.yy.parseError === \"function\") {\n this.parseError = sharedState.yy.parseError;\n } else {\n this.parseError = Object.getPrototypeOf(this).parseError;\n }\n function lex() {\n var token;\n token = tstack.pop() || lexer2.lex() || EOF;\n if (typeof token !== \"number\") {\n if (token instanceof Array) {\n tstack = token;\n token = tstack.pop();\n }\n token = self.symbols_[token] || token;\n }\n return token;\n }\n var symbol, state, action, r, yyval = {}, p, len, newState, expected;\n while (true) {\n state = stack[stack.length - 1];\n if (this.defaultActions[state]) {\n action = this.defaultActions[state];\n } else {\n if (symbol === null || typeof symbol == \"undefined\") {\n symbol = lex();\n }\n action = table[state] && table[state][symbol];\n }\n if (typeof action === \"undefined\" || !action.length || !action[0]) {\n var errStr = \"\";\n expected = [];\n for (p in table[state]) {\n if (this.terminals_[p] && p > TERROR) {\n expected.push(\"'\" + this.terminals_[p] + \"'\");\n }\n }\n if (lexer2.showPosition) {\n errStr = \"Parse error on line \" + (yylineno + 1) + \":\\n\" + lexer2.showPosition() + \"\\nExpecting \" + expected.join(\", \") + \", got '\" + (this.terminals_[symbol] || symbol) + \"'\";\n } else {\n errStr = \"Parse error on line \" + (yylineno + 1) + \": Unexpected \" + (symbol == EOF ? \"end of input\" : \"'\" + (this.terminals_[symbol] || symbol) + \"'\");\n }\n this.parseError(errStr, {\n text: lexer2.match,\n token: this.terminals_[symbol] || symbol,\n line: lexer2.yylineno,\n loc: yyloc,\n expected\n });\n }\n if (action[0] instanceof Array && action.length > 1) {\n throw new Error(\"Parse Error: multiple actions possible at state: \" + state + \", token: \" + symbol);\n }\n switch (action[0]) {\n case 1:\n stack.push(symbol);\n vstack.push(lexer2.yytext);\n lstack.push(lexer2.yylloc);\n stack.push(action[1]);\n symbol = null;\n {\n yyleng = lexer2.yyleng;\n yytext = lexer2.yytext;\n yylineno = lexer2.yylineno;\n yyloc = lexer2.yylloc;\n }\n break;\n case 2:\n len = this.productions_[action[1]][1];\n yyval.$ = vstack[vstack.length - len];\n yyval._$ = {\n first_line: lstack[lstack.length - (len || 1)].first_line,\n last_line: lstack[lstack.length - 1].last_line,\n first_column: lstack[lstack.length - (len || 1)].first_column,\n last_column: lstack[lstack.length - 1].last_column\n };\n if (ranges) {\n yyval._$.range = [\n lstack[lstack.length - (len || 1)].range[0],\n lstack[lstack.length - 1].range[1]\n ];\n }\n r = this.performAction.apply(yyval, [\n yytext,\n yyleng,\n yylineno,\n sharedState.yy,\n action[1],\n vstack,\n lstack\n ].concat(args));\n if (typeof r !== \"undefined\") {\n return r;\n }\n if (len) {\n stack = stack.slice(0, -1 * len * 2);\n vstack = vstack.slice(0, -1 * len);\n lstack = lstack.slice(0, -1 * len);\n }\n stack.push(this.productions_[action[1]][0]);\n vstack.push(yyval.$);\n lstack.push(yyval._$);\n newState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n stack.push(newState);\n break;\n case 3:\n return true;\n }\n }\n return true;\n }\n };\n var lexer = function() {\n var lexer2 = {\n EOF: 1,\n parseError: function parseError(str, hash) {\n if (this.yy.parser) {\n this.yy.parser.parseError(str, hash);\n } else {\n throw new Error(str);\n }\n },\n // resets the lexer, sets new input\n setInput: function(input, yy) {\n this.yy = yy || this.yy || {};\n this._input = input;\n this._more = this._backtrack = this.done = false;\n this.yylineno = this.yyleng = 0;\n this.yytext = this.matched = this.match = \"\";\n this.conditionStack = [\"INITIAL\"];\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0\n };\n if (this.options.ranges) {\n this.yylloc.range = [0, 0];\n }\n this.offset = 0;\n return this;\n },\n // consumes and returns one char from the input\n input: function() {\n var ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n var lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n } else {\n this.yylloc.last_column++;\n }\n if (this.options.ranges) {\n this.yylloc.range[1]++;\n }\n this._input = this._input.slice(1);\n return ch;\n },\n // unshifts one char (or a string) into the input\n unput: function(ch) {\n var len = ch.length;\n var lines = ch.split(/(?:\\r\\n?|\\n)/g);\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.offset -= len;\n var oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n this.match = this.match.substr(0, this.match.length - 1);\n this.matched = this.matched.substr(0, this.matched.length - 1);\n if (lines.length - 1) {\n this.yylineno -= lines.length - 1;\n }\n var r = this.yylloc.range;\n this.yylloc = {\n first_line: this.yylloc.first_line,\n last_line: this.yylineno + 1,\n first_column: this.yylloc.first_column,\n last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len\n };\n if (this.options.ranges) {\n this.yylloc.range = [r[0], r[0] + this.yyleng - len];\n }\n this.yyleng = this.yytext.length;\n return this;\n },\n // When called from action, caches matched text and appends it on next action\n more: function() {\n this._more = true;\n return this;\n },\n // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\n reject: function() {\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n return this.parseError(\"Lexical error on line \" + (this.yylineno + 1) + \". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n\" + this.showPosition(), {\n text: \"\",\n token: null,\n line: this.yylineno\n });\n }\n return this;\n },\n // retain first n characters of the match\n less: function(n) {\n this.unput(this.match.slice(n));\n },\n // displays already matched input, i.e. for error messages\n pastInput: function() {\n var past = this.matched.substr(0, this.matched.length - this.match.length);\n return (past.length > 20 ? \"...\" : \"\") + past.substr(-20).replace(/\\n/g, \"\");\n },\n // displays upcoming input, i.e. for error messages\n upcomingInput: function() {\n var next = this.match;\n if (next.length < 20) {\n next += this._input.substr(0, 20 - next.length);\n }\n return (next.substr(0, 20) + (next.length > 20 ? \"...\" : \"\")).replace(/\\n/g, \"\");\n },\n // displays the character position where the lexing error occurred, i.e. for error messages\n showPosition: function() {\n var pre = this.pastInput();\n var c = new Array(pre.length + 1).join(\"-\");\n return pre + this.upcomingInput() + \"\\n\" + c + \"^\";\n },\n // test the lexed token: return FALSE when not a match, otherwise return token\n test_match: function(match, indexed_rule) {\n var token, lines, backup;\n if (this.options.backtrack_lexer) {\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(0),\n done: this.done\n };\n if (this.options.ranges) {\n backup.yylloc.range = this.yylloc.range.slice(0);\n }\n }\n lines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n if (lines) {\n this.yylineno += lines.length;\n }\n this.yylloc = {\n first_line: this.yylloc.last_line,\n last_line: this.yylineno + 1,\n first_column: this.yylloc.last_column,\n last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length : this.yylloc.last_column + match[0].length\n };\n this.yytext += match[0];\n this.match += match[0];\n this.matches = match;\n this.yyleng = this.yytext.length;\n if (this.options.ranges) {\n this.yylloc.range = [this.offset, this.offset += this.yyleng];\n }\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match[0].length);\n this.matched += match[0];\n token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n for (var k in backup) {\n this[k] = backup[k];\n }\n return false;\n }\n return false;\n },\n // return next match in input\n next: function() {\n if (this.done) {\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n var token, match, tempMatch, index;\n if (!this._more) {\n this.yytext = \"\";\n this.match = \"\";\n }\n var rules = this._currentRules();\n for (var i = 0; i < rules.length; i++) {\n tempMatch = this._input.match(this.rules[rules[i]]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n token = this.test_match(tempMatch, rules[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = false;\n continue;\n } else {\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n if (match) {\n token = this.test_match(match, rules[index]);\n if (token !== false) {\n return token;\n }\n return false;\n }\n if (this._input === \"\") {\n return this.EOF;\n } else {\n return this.parseError(\"Lexical error on line \" + (this.yylineno + 1) + \". Unrecognized text.\\n\" + this.showPosition(), {\n text: \"\",\n token: null,\n line: this.yylineno\n });\n }\n },\n // return next match that has a token\n lex: function lex() {\n var r = this.next();\n if (r) {\n return r;\n } else {\n return this.lex();\n }\n },\n // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\n begin: function begin(condition) {\n this.conditionStack.push(condition);\n },\n // pop the previously active lexer condition state off the condition stack\n popState: function popState() {\n var n = this.conditionStack.length - 1;\n if (n > 0) {\n return this.conditionStack.pop();\n } else {\n return this.conditionStack[0];\n }\n },\n // produce the lexer rule set which is active for the currently active lexer condition state\n _currentRules: function _currentRules() {\n if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n } else {\n return this.conditions[\"INITIAL\"].rules;\n }\n },\n // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\n topState: function topState(n) {\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n } else {\n return \"INITIAL\";\n }\n },\n // alias for begin(condition)\n pushState: function pushState(condition) {\n this.begin(condition);\n },\n // return the number of states currently on the stack\n stateStackSize: function stateStackSize() {\n return this.conditionStack.length;\n },\n options: { \"case-insensitive\": true },\n performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {\n switch ($avoiding_name_collisions) {\n case 0:\n this.begin(\"acc_title\");\n return 22;\n case 1:\n this.popState();\n return \"acc_title_value\";\n case 2:\n this.begin(\"acc_descr\");\n return 24;\n case 3:\n this.popState();\n return \"acc_descr_value\";\n case 4:\n this.begin(\"acc_descr_multiline\");\n break;\n case 5:\n this.popState();\n break;\n case 6:\n return \"acc_descr_multiline_value\";\n case 7:\n return 10;\n case 8:\n break;\n case 9:\n return 8;\n case 10:\n return 28;\n case 11:\n return 48;\n case 12:\n return 4;\n case 13:\n this.begin(\"block\");\n return 15;\n case 14:\n return 36;\n case 15:\n break;\n case 16:\n return 37;\n case 17:\n return 34;\n case 18:\n return 34;\n case 19:\n return 38;\n case 20:\n break;\n case 21:\n this.popState();\n return 17;\n case 22:\n return yy_.yytext[0];\n case 23:\n return 18;\n case 24:\n return 19;\n case 25:\n return 41;\n case 26:\n return 43;\n case 27:\n return 43;\n case 28:\n return 43;\n case 29:\n return 41;\n case 30:\n return 41;\n case 31:\n return 42;\n case 32:\n return 42;\n case 33:\n return 42;\n case 34:\n return 42;\n case 35:\n return 42;\n case 36:\n return 43;\n case 37:\n return 42;\n case 38:\n return 43;\n case 39:\n return 44;\n case 40:\n return 44;\n case 41:\n return 44;\n case 42:\n return 44;\n case 43:\n return 41;\n case 44:\n return 42;\n case 45:\n return 43;\n case 46:\n return 45;\n case 47:\n return 46;\n case 48:\n return 47;\n case 49:\n return 47;\n case 50:\n return 46;\n case 51:\n return 46;\n case 52:\n return 46;\n case 53:\n return 27;\n case 54:\n return yy_.yytext[0];\n case 55:\n return 6;\n }\n },\n rules: [/^(?:accTitle\\s*:\\s*)/i, /^(?:(?!\\n||)*[^\\n]*)/i, /^(?:accDescr\\s*:\\s*)/i, /^(?:(?!\\n||)*[^\\n]*)/i, /^(?:accDescr\\s*\\{\\s*)/i, /^(?:[\\}])/i, /^(?:[^\\}]*)/i, /^(?:[\\n]+)/i, /^(?:\\s+)/i, /^(?:[\\s]+)/i, /^(?:\"[^\"%\\r\\n\\v\\b\\\\]+\")/i, /^(?:\"[^\"]*\")/i, /^(?:erDiagram\\b)/i, /^(?:\\{)/i, /^(?:,)/i, /^(?:\\s+)/i, /^(?:\\b((?:PK)|(?:FK)|(?:UK))\\b)/i, /^(?:(.*?)[~](.*?)*[~])/i, /^(?:[\\*A-Za-z_][A-Za-z0-9\\-_\\[\\]\\(\\)]*)/i, /^(?:\"[^\"]*\")/i, /^(?:[\\n]+)/i, /^(?:\\})/i, /^(?:.)/i, /^(?:\\[)/i, /^(?:\\])/i, /^(?:one or zero\\b)/i, /^(?:one or more\\b)/i, /^(?:one or many\\b)/i, /^(?:1\\+)/i, /^(?:\\|o\\b)/i, /^(?:zero or one\\b)/i, /^(?:zero or more\\b)/i, /^(?:zero or many\\b)/i, /^(?:0\\+)/i, /^(?:\\}o\\b)/i, /^(?:many\\(0\\))/i, /^(?:many\\(1\\))/i, /^(?:many\\b)/i, /^(?:\\}\\|)/i, /^(?:one\\b)/i, /^(?:only one\\b)/i, /^(?:1\\b)/i, /^(?:\\|\\|)/i, /^(?:o\\|)/i, /^(?:o\\{)/i, /^(?:\\|\\{)/i, /^(?:\\s*u\\b)/i, /^(?:\\.\\.)/i, /^(?:--)/i, /^(?:to\\b)/i, /^(?:optionally to\\b)/i, /^(?:\\.-)/i, /^(?:-\\.)/i, /^(?:[A-Za-z_][A-Za-z0-9\\-_]*)/i, /^(?:.)/i, /^(?:$)/i],\n conditions: { \"acc_descr_multiline\": { \"rules\": [5, 6], \"inclusive\": false }, \"acc_descr\": { \"rules\": [3], \"inclusive\": false }, \"acc_title\": { \"rules\": [1], \"inclusive\": false }, \"block\": { \"rules\": [14, 15, 16, 17, 18, 19, 20, 21, 22], \"inclusive\": false }, \"INITIAL\": { \"rules\": [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55], \"inclusive\": true } }\n };\n return lexer2;\n }();\n parser2.lexer = lexer;\n function Parser() {\n this.yy = {};\n }\n Parser.prototype = parser2;\n parser2.Parser = Parser;\n return new Parser();\n}();\nparser.parser = parser;\nconst erParser = parser;\nlet entities = {};\nlet relationships = [];\nconst Cardinality = {\n ZERO_OR_ONE: \"ZERO_OR_ONE\",\n ZERO_OR_MORE: \"ZERO_OR_MORE\",\n ONE_OR_MORE: \"ONE_OR_MORE\",\n ONLY_ONE: \"ONLY_ONE\",\n MD_PARENT: \"MD_PARENT\"\n};\nconst Identification = {\n NON_IDENTIFYING: \"NON_IDENTIFYING\",\n IDENTIFYING: \"IDENTIFYING\"\n};\nconst addEntity = function(name, alias = void 0) {\n if (entities[name] === void 0) {\n entities[name] = { attributes: [], alias };\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.l.info(\"Added new entity :\", name);\n } else if (entities[name] && !entities[name].alias && alias) {\n entities[name].alias = alias;\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.l.info(`Add alias '${alias}' to entity '${name}'`);\n }\n return entities[name];\n};\nconst getEntities = () => entities;\nconst addAttributes = function(entityName, attribs) {\n let entity = addEntity(entityName);\n let i;\n for (i = attribs.length - 1; i >= 0; i--) {\n entity.attributes.push(attribs[i]);\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.l.debug(\"Added attribute \", attribs[i].attributeName);\n }\n};\nconst addRelationship = function(entA, rolA, entB, rSpec) {\n let rel = {\n entityA: entA,\n roleA: rolA,\n entityB: entB,\n relSpec: rSpec\n };\n relationships.push(rel);\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.l.debug(\"Added new relationship :\", rel);\n};\nconst getRelationships = () => relationships;\nconst clear = function() {\n entities = {};\n relationships = [];\n (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.v)();\n};\nconst erDb = {\n Cardinality,\n Identification,\n getConfig: () => (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().er,\n addEntity,\n addAttributes,\n getEntities,\n addRelationship,\n getRelationships,\n clear,\n setAccTitle: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.s,\n getAccTitle: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.g,\n setAccDescription: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.b,\n getAccDescription: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.a,\n setDiagramTitle: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.q,\n getDiagramTitle: _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.t\n};\nconst ERMarkers = {\n ONLY_ONE_START: \"ONLY_ONE_START\",\n ONLY_ONE_END: \"ONLY_ONE_END\",\n ZERO_OR_ONE_START: \"ZERO_OR_ONE_START\",\n ZERO_OR_ONE_END: \"ZERO_OR_ONE_END\",\n ONE_OR_MORE_START: \"ONE_OR_MORE_START\",\n ONE_OR_MORE_END: \"ONE_OR_MORE_END\",\n ZERO_OR_MORE_START: \"ZERO_OR_MORE_START\",\n ZERO_OR_MORE_END: \"ZERO_OR_MORE_END\",\n MD_PARENT_END: \"MD_PARENT_END\",\n MD_PARENT_START: \"MD_PARENT_START\"\n};\nconst insertMarkers = function(elem, conf2) {\n let marker;\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.MD_PARENT_START).attr(\"refX\", 0).attr(\"refY\", 7).attr(\"markerWidth\", 190).attr(\"markerHeight\", 240).attr(\"orient\", \"auto\").append(\"path\").attr(\"d\", \"M 18,7 L9,13 L1,7 L9,1 Z\");\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.MD_PARENT_END).attr(\"refX\", 19).attr(\"refY\", 7).attr(\"markerWidth\", 20).attr(\"markerHeight\", 28).attr(\"orient\", \"auto\").append(\"path\").attr(\"d\", \"M 18,7 L9,13 L1,7 L9,1 Z\");\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ONLY_ONE_START).attr(\"refX\", 0).attr(\"refY\", 9).attr(\"markerWidth\", 18).attr(\"markerHeight\", 18).attr(\"orient\", \"auto\").append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M9,0 L9,18 M15,0 L15,18\");\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ONLY_ONE_END).attr(\"refX\", 18).attr(\"refY\", 9).attr(\"markerWidth\", 18).attr(\"markerHeight\", 18).attr(\"orient\", \"auto\").append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M3,0 L3,18 M9,0 L9,18\");\n marker = elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ZERO_OR_ONE_START).attr(\"refX\", 0).attr(\"refY\", 9).attr(\"markerWidth\", 30).attr(\"markerHeight\", 18).attr(\"orient\", \"auto\");\n marker.append(\"circle\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"white\").attr(\"cx\", 21).attr(\"cy\", 9).attr(\"r\", 6);\n marker.append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M9,0 L9,18\");\n marker = elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ZERO_OR_ONE_END).attr(\"refX\", 30).attr(\"refY\", 9).attr(\"markerWidth\", 30).attr(\"markerHeight\", 18).attr(\"orient\", \"auto\");\n marker.append(\"circle\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"white\").attr(\"cx\", 9).attr(\"cy\", 9).attr(\"r\", 6);\n marker.append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M21,0 L21,18\");\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ONE_OR_MORE_START).attr(\"refX\", 18).attr(\"refY\", 18).attr(\"markerWidth\", 45).attr(\"markerHeight\", 36).attr(\"orient\", \"auto\").append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27\");\n elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ONE_OR_MORE_END).attr(\"refX\", 27).attr(\"refY\", 18).attr(\"markerWidth\", 45).attr(\"markerHeight\", 36).attr(\"orient\", \"auto\").append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18\");\n marker = elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ZERO_OR_MORE_START).attr(\"refX\", 18).attr(\"refY\", 18).attr(\"markerWidth\", 57).attr(\"markerHeight\", 36).attr(\"orient\", \"auto\");\n marker.append(\"circle\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"white\").attr(\"cx\", 48).attr(\"cy\", 18).attr(\"r\", 6);\n marker.append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M0,18 Q18,0 36,18 Q18,36 0,18\");\n marker = elem.append(\"defs\").append(\"marker\").attr(\"id\", ERMarkers.ZERO_OR_MORE_END).attr(\"refX\", 39).attr(\"refY\", 18).attr(\"markerWidth\", 57).attr(\"markerHeight\", 36).attr(\"orient\", \"auto\");\n marker.append(\"circle\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"white\").attr(\"cx\", 9).attr(\"cy\", 18).attr(\"r\", 6);\n marker.append(\"path\").attr(\"stroke\", conf2.stroke).attr(\"fill\", \"none\").attr(\"d\", \"M21,18 Q39,0 57,18 Q39,36 21,18\");\n return;\n};\nconst erMarkers = {\n ERMarkers,\n insertMarkers\n};\nconst BAD_ID_CHARS_REGEXP = /[^\\dA-Za-z](\\W)*/g;\nlet conf = {};\nlet entityNameIds = /* @__PURE__ */ new Map();\nconst setConf = function(cnf) {\n const keys = Object.keys(cnf);\n for (const key of keys) {\n conf[key] = cnf[key];\n }\n};\nconst drawAttributes = (groupNode, entityTextNode, attributes) => {\n const heightPadding = conf.entityPadding / 3;\n const widthPadding = conf.entityPadding / 3;\n const attrFontSize = conf.fontSize * 0.85;\n const labelBBox = entityTextNode.node().getBBox();\n const attributeNodes = [];\n let hasKeyType = false;\n let hasComment = false;\n let maxTypeWidth = 0;\n let maxNameWidth = 0;\n let maxKeyWidth = 0;\n let maxCommentWidth = 0;\n let cumulativeHeight = labelBBox.height + heightPadding * 2;\n let attrNum = 1;\n attributes.forEach((item) => {\n if (item.attributeKeyTypeList !== void 0 && item.attributeKeyTypeList.length > 0) {\n hasKeyType = true;\n }\n if (item.attributeComment !== void 0) {\n hasComment = true;\n }\n });\n attributes.forEach((item) => {\n const attrPrefix = `${entityTextNode.node().id}-attr-${attrNum}`;\n let nodeHeight = 0;\n const attributeType = (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.x)(item.attributeType);\n const typeNode = groupNode.append(\"text\").classed(\"er entityLabel\", true).attr(\"id\", `${attrPrefix}-type`).attr(\"x\", 0).attr(\"y\", 0).style(\"dominant-baseline\", \"middle\").style(\"text-anchor\", \"left\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", attrFontSize + \"px\").text(attributeType);\n const nameNode = groupNode.append(\"text\").classed(\"er entityLabel\", true).attr(\"id\", `${attrPrefix}-name`).attr(\"x\", 0).attr(\"y\", 0).style(\"dominant-baseline\", \"middle\").style(\"text-anchor\", \"left\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", attrFontSize + \"px\").text(item.attributeName);\n const attributeNode = {};\n attributeNode.tn = typeNode;\n attributeNode.nn = nameNode;\n const typeBBox = typeNode.node().getBBox();\n const nameBBox = nameNode.node().getBBox();\n maxTypeWidth = Math.max(maxTypeWidth, typeBBox.width);\n maxNameWidth = Math.max(maxNameWidth, nameBBox.width);\n nodeHeight = Math.max(typeBBox.height, nameBBox.height);\n if (hasKeyType) {\n const keyTypeNodeText = item.attributeKeyTypeList !== void 0 ? item.attributeKeyTypeList.join(\",\") : \"\";\n const keyTypeNode = groupNode.append(\"text\").classed(\"er entityLabel\", true).attr(\"id\", `${attrPrefix}-key`).attr(\"x\", 0).attr(\"y\", 0).style(\"dominant-baseline\", \"middle\").style(\"text-anchor\", \"left\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", attrFontSize + \"px\").text(keyTypeNodeText);\n attributeNode.kn = keyTypeNode;\n const keyTypeBBox = keyTypeNode.node().getBBox();\n maxKeyWidth = Math.max(maxKeyWidth, keyTypeBBox.width);\n nodeHeight = Math.max(nodeHeight, keyTypeBBox.height);\n }\n if (hasComment) {\n const commentNode = groupNode.append(\"text\").classed(\"er entityLabel\", true).attr(\"id\", `${attrPrefix}-comment`).attr(\"x\", 0).attr(\"y\", 0).style(\"dominant-baseline\", \"middle\").style(\"text-anchor\", \"left\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", attrFontSize + \"px\").text(item.attributeComment || \"\");\n attributeNode.cn = commentNode;\n const commentNodeBBox = commentNode.node().getBBox();\n maxCommentWidth = Math.max(maxCommentWidth, commentNodeBBox.width);\n nodeHeight = Math.max(nodeHeight, commentNodeBBox.height);\n }\n attributeNode.height = nodeHeight;\n attributeNodes.push(attributeNode);\n cumulativeHeight += nodeHeight + heightPadding * 2;\n attrNum += 1;\n });\n let widthPaddingFactor = 4;\n if (hasKeyType) {\n widthPaddingFactor += 2;\n }\n if (hasComment) {\n widthPaddingFactor += 2;\n }\n const maxWidth = maxTypeWidth + maxNameWidth + maxKeyWidth + maxCommentWidth;\n const bBox = {\n width: Math.max(\n conf.minEntityWidth,\n Math.max(\n labelBBox.width + conf.entityPadding * 2,\n maxWidth + widthPadding * widthPaddingFactor\n )\n ),\n height: attributes.length > 0 ? cumulativeHeight : Math.max(conf.minEntityHeight, labelBBox.height + conf.entityPadding * 2)\n };\n if (attributes.length > 0) {\n const spareColumnWidth = Math.max(\n 0,\n (bBox.width - maxWidth - widthPadding * widthPaddingFactor) / (widthPaddingFactor / 2)\n );\n entityTextNode.attr(\n \"transform\",\n \"translate(\" + bBox.width / 2 + \",\" + (heightPadding + labelBBox.height / 2) + \")\"\n );\n let heightOffset = labelBBox.height + heightPadding * 2;\n let attribStyle = \"attributeBoxOdd\";\n attributeNodes.forEach((attributeNode) => {\n const alignY = heightOffset + heightPadding + attributeNode.height / 2;\n attributeNode.tn.attr(\"transform\", \"translate(\" + widthPadding + \",\" + alignY + \")\");\n const typeRect = groupNode.insert(\"rect\", \"#\" + attributeNode.tn.node().id).classed(`er ${attribStyle}`, true).attr(\"x\", 0).attr(\"y\", heightOffset).attr(\"width\", maxTypeWidth + widthPadding * 2 + spareColumnWidth).attr(\"height\", attributeNode.height + heightPadding * 2);\n const nameXOffset = parseFloat(typeRect.attr(\"x\")) + parseFloat(typeRect.attr(\"width\"));\n attributeNode.nn.attr(\n \"transform\",\n \"translate(\" + (nameXOffset + widthPadding) + \",\" + alignY + \")\"\n );\n const nameRect = groupNode.insert(\"rect\", \"#\" + attributeNode.nn.node().id).classed(`er ${attribStyle}`, true).attr(\"x\", nameXOffset).attr(\"y\", heightOffset).attr(\"width\", maxNameWidth + widthPadding * 2 + spareColumnWidth).attr(\"height\", attributeNode.height + heightPadding * 2);\n let keyTypeAndCommentXOffset = parseFloat(nameRect.attr(\"x\")) + parseFloat(nameRect.attr(\"width\"));\n if (hasKeyType) {\n attributeNode.kn.attr(\n \"transform\",\n \"translate(\" + (keyTypeAndCommentXOffset + widthPadding) + \",\" + alignY + \")\"\n );\n const keyTypeRect = groupNode.insert(\"rect\", \"#\" + attributeNode.kn.node().id).classed(`er ${attribStyle}`, true).attr(\"x\", keyTypeAndCommentXOffset).attr(\"y\", heightOffset).attr(\"width\", maxKeyWidth + widthPadding * 2 + spareColumnWidth).attr(\"height\", attributeNode.height + heightPadding * 2);\n keyTypeAndCommentXOffset = parseFloat(keyTypeRect.attr(\"x\")) + parseFloat(keyTypeRect.attr(\"width\"));\n }\n if (hasComment) {\n attributeNode.cn.attr(\n \"transform\",\n \"translate(\" + (keyTypeAndCommentXOffset + widthPadding) + \",\" + alignY + \")\"\n );\n groupNode.insert(\"rect\", \"#\" + attributeNode.cn.node().id).classed(`er ${attribStyle}`, \"true\").attr(\"x\", keyTypeAndCommentXOffset).attr(\"y\", heightOffset).attr(\"width\", maxCommentWidth + widthPadding * 2 + spareColumnWidth).attr(\"height\", attributeNode.height + heightPadding * 2);\n }\n heightOffset += attributeNode.height + heightPadding * 2;\n attribStyle = attribStyle === \"attributeBoxOdd\" ? \"attributeBoxEven\" : \"attributeBoxOdd\";\n });\n } else {\n bBox.height = Math.max(conf.minEntityHeight, cumulativeHeight);\n entityTextNode.attr(\"transform\", \"translate(\" + bBox.width / 2 + \",\" + bBox.height / 2 + \")\");\n }\n return bBox;\n};\nconst drawEntities = function(svgNode, entities2, graph) {\n const keys = Object.keys(entities2);\n let firstOne;\n keys.forEach(function(entityName) {\n const entityId = generateId(entityName, \"entity\");\n entityNameIds.set(entityName, entityId);\n const groupNode = svgNode.append(\"g\").attr(\"id\", entityId);\n firstOne = firstOne === void 0 ? entityId : firstOne;\n const textId = \"text-\" + entityId;\n const textNode = groupNode.append(\"text\").classed(\"er entityLabel\", true).attr(\"id\", textId).attr(\"x\", 0).attr(\"y\", 0).style(\"dominant-baseline\", \"middle\").style(\"text-anchor\", \"middle\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", conf.fontSize + \"px\").text(entities2[entityName].alias ?? entityName);\n const { width: entityWidth, height: entityHeight } = drawAttributes(\n groupNode,\n textNode,\n entities2[entityName].attributes\n );\n const rectNode = groupNode.insert(\"rect\", \"#\" + textId).classed(\"er entityBox\", true).attr(\"x\", 0).attr(\"y\", 0).attr(\"width\", entityWidth).attr(\"height\", entityHeight);\n const rectBBox = rectNode.node().getBBox();\n graph.setNode(entityId, {\n width: rectBBox.width,\n height: rectBBox.height,\n shape: \"rect\",\n id: entityId\n });\n });\n return firstOne;\n};\nconst adjustEntities = function(svgNode, graph) {\n graph.nodes().forEach(function(v) {\n if (v !== void 0 && graph.node(v) !== void 0) {\n svgNode.select(\"#\" + v).attr(\n \"transform\",\n \"translate(\" + (graph.node(v).x - graph.node(v).width / 2) + \",\" + (graph.node(v).y - graph.node(v).height / 2) + \" )\"\n );\n }\n });\n};\nconst getEdgeName = function(rel) {\n return (rel.entityA + rel.roleA + rel.entityB).replace(/\\s/g, \"\");\n};\nconst addRelationships = function(relationships2, g) {\n relationships2.forEach(function(r) {\n g.setEdge(\n entityNameIds.get(r.entityA),\n entityNameIds.get(r.entityB),\n { relationship: r },\n getEdgeName(r)\n );\n });\n return relationships2;\n};\nlet relCnt = 0;\nconst drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) {\n relCnt++;\n const edge = g.edge(\n entityNameIds.get(rel.entityA),\n entityNameIds.get(rel.entityB),\n getEdgeName(rel)\n );\n const lineFunction = (0,d3__WEBPACK_IMPORTED_MODULE_1__.line)().x(function(d) {\n return d.x;\n }).y(function(d) {\n return d.y;\n }).curve(d3__WEBPACK_IMPORTED_MODULE_1__.curveBasis);\n const svgPath = svg.insert(\"path\", \"#\" + insert).classed(\"er relationshipLine\", true).attr(\"d\", lineFunction(edge.points)).style(\"stroke\", conf.stroke).style(\"fill\", \"none\");\n if (rel.relSpec.relType === diagObj.db.Identification.NON_IDENTIFYING) {\n svgPath.attr(\"stroke-dasharray\", \"8,8\");\n }\n let url = \"\";\n if (conf.arrowMarkerAbsolute) {\n url = window.location.protocol + \"//\" + window.location.host + window.location.pathname + window.location.search;\n url = url.replace(/\\(/g, \"\\\\(\");\n url = url.replace(/\\)/g, \"\\\\)\");\n }\n switch (rel.relSpec.cardA) {\n case diagObj.db.Cardinality.ZERO_OR_ONE:\n svgPath.attr(\"marker-end\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.ZERO_OR_ONE_END + \")\");\n break;\n case diagObj.db.Cardinality.ZERO_OR_MORE:\n svgPath.attr(\"marker-end\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.ZERO_OR_MORE_END + \")\");\n break;\n case diagObj.db.Cardinality.ONE_OR_MORE:\n svgPath.attr(\"marker-end\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.ONE_OR_MORE_END + \")\");\n break;\n case diagObj.db.Cardinality.ONLY_ONE:\n svgPath.attr(\"marker-end\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.ONLY_ONE_END + \")\");\n break;\n case diagObj.db.Cardinality.MD_PARENT:\n svgPath.attr(\"marker-end\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.MD_PARENT_END + \")\");\n break;\n }\n switch (rel.relSpec.cardB) {\n case diagObj.db.Cardinality.ZERO_OR_ONE:\n svgPath.attr(\n \"marker-start\",\n \"url(\" + url + \"#\" + erMarkers.ERMarkers.ZERO_OR_ONE_START + \")\"\n );\n break;\n case diagObj.db.Cardinality.ZERO_OR_MORE:\n svgPath.attr(\n \"marker-start\",\n \"url(\" + url + \"#\" + erMarkers.ERMarkers.ZERO_OR_MORE_START + \")\"\n );\n break;\n case diagObj.db.Cardinality.ONE_OR_MORE:\n svgPath.attr(\n \"marker-start\",\n \"url(\" + url + \"#\" + erMarkers.ERMarkers.ONE_OR_MORE_START + \")\"\n );\n break;\n case diagObj.db.Cardinality.ONLY_ONE:\n svgPath.attr(\"marker-start\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.ONLY_ONE_START + \")\");\n break;\n case diagObj.db.Cardinality.MD_PARENT:\n svgPath.attr(\"marker-start\", \"url(\" + url + \"#\" + erMarkers.ERMarkers.MD_PARENT_START + \")\");\n break;\n }\n const len = svgPath.node().getTotalLength();\n const labelPoint = svgPath.node().getPointAtLength(len * 0.5);\n const labelId = \"rel\" + relCnt;\n const labelNode = svg.append(\"text\").classed(\"er relationshipLabel\", true).attr(\"id\", labelId).attr(\"x\", labelPoint.x).attr(\"y\", labelPoint.y).style(\"text-anchor\", \"middle\").style(\"dominant-baseline\", \"middle\").style(\"font-family\", (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().fontFamily).style(\"font-size\", conf.fontSize + \"px\").text(rel.roleA);\n const labelBBox = labelNode.node().getBBox();\n svg.insert(\"rect\", \"#\" + labelId).classed(\"er relationshipLabelBox\", true).attr(\"x\", labelPoint.x - labelBBox.width / 2).attr(\"y\", labelPoint.y - labelBBox.height / 2).attr(\"width\", labelBBox.width).attr(\"height\", labelBBox.height);\n};\nconst draw = function(text, id, _version, diagObj) {\n conf = (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().er;\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.l.info(\"Drawing ER diagram\");\n const securityLevel = (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.c)().securityLevel;\n let sandboxElement;\n if (securityLevel === \"sandbox\") {\n sandboxElement = (0,d3__WEBPACK_IMPORTED_MODULE_1__.select)(\"#i\" + id);\n }\n const root = securityLevel === \"sandbox\" ? (0,d3__WEBPACK_IMPORTED_MODULE_1__.select)(sandboxElement.nodes()[0].contentDocument.body) : (0,d3__WEBPACK_IMPORTED_MODULE_1__.select)(\"body\");\n const svg = root.select(`[id='${id}']`);\n erMarkers.insertMarkers(svg, conf);\n let g;\n g = new dagre_d3_es_src_graphlib_index_js__WEBPACK_IMPORTED_MODULE_0__.Graph({\n multigraph: true,\n directed: true,\n compound: false\n }).setGraph({\n rankdir: conf.layoutDirection,\n marginx: 20,\n marginy: 20,\n nodesep: 100,\n edgesep: 100,\n ranksep: 100\n }).setDefaultEdgeLabel(function() {\n return {};\n });\n const firstEntity = drawEntities(svg, diagObj.db.getEntities(), g);\n const relationships2 = addRelationships(diagObj.db.getRelationships(), g);\n (0,dagre_d3_es_src_dagre_index_js__WEBPACK_IMPORTED_MODULE_2__.layout)(g);\n adjustEntities(svg, g);\n relationships2.forEach(function(rel) {\n drawRelationshipFromLayout(svg, rel, g, firstEntity, diagObj);\n });\n const padding = conf.diagramPadding;\n _mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.u.insertTitle(svg, \"entityTitleText\", conf.titleTopMargin, diagObj.db.getDiagramTitle());\n const svgBounds = svg.node().getBBox();\n const width = svgBounds.width + padding * 2;\n const height = svgBounds.height + padding * 2;\n (0,_mermaid_ad1dc92f_js__WEBPACK_IMPORTED_MODULE_7__.i)(svg, height, width, conf.useMaxWidth);\n svg.attr(\"viewBox\", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`);\n};\nconst MERMAID_ERDIAGRAM_UUID = \"28e9f9db-3c8d-5aa5-9faf-44286ae5937c\";\nfunction generateId(str = \"\", prefix = \"\") {\n const simplifiedStr = str.replace(BAD_ID_CHARS_REGEXP, \"\");\n return `${strWithHyphen(prefix)}${strWithHyphen(simplifiedStr)}${(0,uuid__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(\n str,\n MERMAID_ERDIAGRAM_UUID\n )}`;\n}\nfunction strWithHyphen(str = \"\") {\n return str.length > 0 ? `${str}-` : \"\";\n}\nconst erRenderer = {\n setConf,\n draw\n};\nconst getStyles = (options) => `\n .entityBox {\n fill: ${options.mainBkg};\n stroke: ${options.nodeBorder};\n }\n\n .attributeBoxOdd {\n fill: ${options.attributeBackgroundColorOdd};\n stroke: ${options.nodeBorder};\n }\n\n .attributeBoxEven {\n fill: ${options.attributeBackgroundColorEven};\n stroke: ${options.nodeBorder};\n }\n\n .relationshipLabelBox {\n fill: ${options.tertiaryColor};\n opacity: 0.7;\n background-color: ${options.tertiaryColor};\n rect {\n opacity: 0.5;\n }\n }\n\n .relationshipLine {\n stroke: ${options.lineColor};\n }\n\n .entityTitleText {\n text-anchor: middle;\n font-size: 18px;\n fill: ${options.textColor};\n } \n #MD_PARENT_START {\n fill: #f5f5f5 !important;\n stroke: ${options.lineColor} !important;\n stroke-width: 1;\n }\n #MD_PARENT_END {\n fill: #f5f5f5 !important;\n stroke: ${options.lineColor} !important;\n stroke-width: 1;\n }\n \n`;\nconst erStyles = getStyles;\nconst diagram = {\n parser: erParser,\n db: erDb,\n renderer: erRenderer,\n styles: erStyles\n};\n\n\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/mermaid/dist/erDiagram-880f2ed8.js?");
11103
11103
 
11104
11104
  /***/ }),
11105
11105
 
@@ -11378,83 +11378,6 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
11378
11378
 
11379
11379
  /***/ }),
11380
11380
 
11381
- /***/ "../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/parse.js":
11382
- /*!******************************************************************************!*\
11383
- !*** ../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/parse.js ***!
11384
- \******************************************************************************/
11385
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
11386
-
11387
- "use strict";
11388
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validate.js */ \"../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/validate.js\");\n\n\nfunction parse(uuid) {\n if (!(0,_validate_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (parse);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/parse.js?");
11389
-
11390
- /***/ }),
11391
-
11392
- /***/ "../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/regex.js":
11393
- /*!******************************************************************************!*\
11394
- !*** ../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/regex.js ***!
11395
- \******************************************************************************/
11396
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
11397
-
11398
- "use strict";
11399
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/regex.js?");
11400
-
11401
- /***/ }),
11402
-
11403
- /***/ "../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/sha1.js":
11404
- /*!*****************************************************************************!*\
11405
- !*** ../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/sha1.js ***!
11406
- \*****************************************************************************/
11407
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
11408
-
11409
- "use strict";
11410
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n// Adapted from Chris Veness' SHA1 code at\n// http://www.movable-type.co.uk/scripts/sha1.html\nfunction f(s, x, y, z) {\n switch (s) {\n case 0:\n return x & y ^ ~x & z;\n\n case 1:\n return x ^ y ^ z;\n\n case 2:\n return x & y ^ x & z ^ y & z;\n\n case 3:\n return x ^ y ^ z;\n }\n}\n\nfunction ROTL(x, n) {\n return x << n | x >>> 32 - n;\n}\n\nfunction sha1(bytes) {\n const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];\n const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];\n\n if (typeof bytes === 'string') {\n const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape\n\n bytes = [];\n\n for (let i = 0; i < msg.length; ++i) {\n bytes.push(msg.charCodeAt(i));\n }\n } else if (!Array.isArray(bytes)) {\n // Convert Array-like to Array\n bytes = Array.prototype.slice.call(bytes);\n }\n\n bytes.push(0x80);\n const l = bytes.length / 4 + 2;\n const N = Math.ceil(l / 16);\n const M = new Array(N);\n\n for (let i = 0; i < N; ++i) {\n const arr = new Uint32Array(16);\n\n for (let j = 0; j < 16; ++j) {\n arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];\n }\n\n M[i] = arr;\n }\n\n M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);\n M[N - 1][14] = Math.floor(M[N - 1][14]);\n M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;\n\n for (let i = 0; i < N; ++i) {\n const W = new Uint32Array(80);\n\n for (let t = 0; t < 16; ++t) {\n W[t] = M[i][t];\n }\n\n for (let t = 16; t < 80; ++t) {\n W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);\n }\n\n let a = H[0];\n let b = H[1];\n let c = H[2];\n let d = H[3];\n let e = H[4];\n\n for (let t = 0; t < 80; ++t) {\n const s = Math.floor(t / 20);\n const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;\n e = d;\n d = c;\n c = ROTL(b, 30) >>> 0;\n b = a;\n a = T;\n }\n\n H[0] = H[0] + a >>> 0;\n H[1] = H[1] + b >>> 0;\n H[2] = H[2] + c >>> 0;\n H[3] = H[3] + d >>> 0;\n H[4] = H[4] + e >>> 0;\n }\n\n return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (sha1);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/sha1.js?");
11411
-
11412
- /***/ }),
11413
-
11414
- /***/ "../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/stringify.js":
11415
- /*!**********************************************************************************!*\
11416
- !*** ../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/stringify.js ***!
11417
- \**********************************************************************************/
11418
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
11419
-
11420
- "use strict";
11421
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ unsafeStringify: () => (/* binding */ unsafeStringify)\n/* harmony export */ });\n/* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validate.js */ \"../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/validate.js\");\n\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nfunction unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!(0,_validate_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (stringify);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/stringify.js?");
11422
-
11423
- /***/ }),
11424
-
11425
- /***/ "../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/v35.js":
11426
- /*!****************************************************************************!*\
11427
- !*** ../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/v35.js ***!
11428
- \****************************************************************************/
11429
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
11430
-
11431
- "use strict";
11432
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DNS: () => (/* binding */ DNS),\n/* harmony export */ URL: () => (/* binding */ URL),\n/* harmony export */ \"default\": () => (/* binding */ v35)\n/* harmony export */ });\n/* harmony import */ var _stringify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringify.js */ \"../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/stringify.js\");\n/* harmony import */ var _parse_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./parse.js */ \"../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/parse.js\");\n\n\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nconst DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nconst URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nfunction v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = (0,_parse_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return (0,_stringify_js__WEBPACK_IMPORTED_MODULE_1__.unsafeStringify)(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/v35.js?");
11433
-
11434
- /***/ }),
11435
-
11436
- /***/ "../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/v5.js":
11437
- /*!***************************************************************************!*\
11438
- !*** ../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/v5.js ***!
11439
- \***************************************************************************/
11440
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
11441
-
11442
- "use strict";
11443
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _v35_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./v35.js */ \"../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/v35.js\");\n/* harmony import */ var _sha1_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sha1.js */ \"../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/sha1.js\");\n\n\nconst v5 = (0,_v35_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('v5', 0x50, _sha1_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (v5);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/v5.js?");
11444
-
11445
- /***/ }),
11446
-
11447
- /***/ "../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/validate.js":
11448
- /*!*********************************************************************************!*\
11449
- !*** ../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/validate.js ***!
11450
- \*********************************************************************************/
11451
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
11452
-
11453
- "use strict";
11454
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ \"../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/regex.js\");\n\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && _regex_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].test(uuid);\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (validate);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/mermaid/node_modules/uuid/dist/esm-browser/validate.js?");
11455
-
11456
- /***/ }),
11457
-
11458
11381
  /***/ "../../node_modules/micromark-core-commonmark/dev/lib/attention.js":
11459
11382
  /*!*************************************************************************!*\
11460
11383
  !*** ../../node_modules/micromark-core-commonmark/dev/lib/attention.js ***!
@@ -12853,6 +12776,83 @@ eval("\n\nif (false) {} else {\n module.exports = __webpack_require__(/*! ../cj
12853
12776
 
12854
12777
  /***/ }),
12855
12778
 
12779
+ /***/ "../../node_modules/uuid/dist/esm-browser/parse.js":
12780
+ /*!*********************************************************!*\
12781
+ !*** ../../node_modules/uuid/dist/esm-browser/parse.js ***!
12782
+ \*********************************************************/
12783
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12784
+
12785
+ "use strict";
12786
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validate.js */ \"../../node_modules/uuid/dist/esm-browser/validate.js\");\n\n\nfunction parse(uuid) {\n if (!(0,_validate_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (parse);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/uuid/dist/esm-browser/parse.js?");
12787
+
12788
+ /***/ }),
12789
+
12790
+ /***/ "../../node_modules/uuid/dist/esm-browser/regex.js":
12791
+ /*!*********************************************************!*\
12792
+ !*** ../../node_modules/uuid/dist/esm-browser/regex.js ***!
12793
+ \*********************************************************/
12794
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12795
+
12796
+ "use strict";
12797
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/uuid/dist/esm-browser/regex.js?");
12798
+
12799
+ /***/ }),
12800
+
12801
+ /***/ "../../node_modules/uuid/dist/esm-browser/sha1.js":
12802
+ /*!********************************************************!*\
12803
+ !*** ../../node_modules/uuid/dist/esm-browser/sha1.js ***!
12804
+ \********************************************************/
12805
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12806
+
12807
+ "use strict";
12808
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n// Adapted from Chris Veness' SHA1 code at\n// http://www.movable-type.co.uk/scripts/sha1.html\nfunction f(s, x, y, z) {\n switch (s) {\n case 0:\n return x & y ^ ~x & z;\n\n case 1:\n return x ^ y ^ z;\n\n case 2:\n return x & y ^ x & z ^ y & z;\n\n case 3:\n return x ^ y ^ z;\n }\n}\n\nfunction ROTL(x, n) {\n return x << n | x >>> 32 - n;\n}\n\nfunction sha1(bytes) {\n const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];\n const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];\n\n if (typeof bytes === 'string') {\n const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape\n\n bytes = [];\n\n for (let i = 0; i < msg.length; ++i) {\n bytes.push(msg.charCodeAt(i));\n }\n } else if (!Array.isArray(bytes)) {\n // Convert Array-like to Array\n bytes = Array.prototype.slice.call(bytes);\n }\n\n bytes.push(0x80);\n const l = bytes.length / 4 + 2;\n const N = Math.ceil(l / 16);\n const M = new Array(N);\n\n for (let i = 0; i < N; ++i) {\n const arr = new Uint32Array(16);\n\n for (let j = 0; j < 16; ++j) {\n arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];\n }\n\n M[i] = arr;\n }\n\n M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);\n M[N - 1][14] = Math.floor(M[N - 1][14]);\n M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;\n\n for (let i = 0; i < N; ++i) {\n const W = new Uint32Array(80);\n\n for (let t = 0; t < 16; ++t) {\n W[t] = M[i][t];\n }\n\n for (let t = 16; t < 80; ++t) {\n W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);\n }\n\n let a = H[0];\n let b = H[1];\n let c = H[2];\n let d = H[3];\n let e = H[4];\n\n for (let t = 0; t < 80; ++t) {\n const s = Math.floor(t / 20);\n const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;\n e = d;\n d = c;\n c = ROTL(b, 30) >>> 0;\n b = a;\n a = T;\n }\n\n H[0] = H[0] + a >>> 0;\n H[1] = H[1] + b >>> 0;\n H[2] = H[2] + c >>> 0;\n H[3] = H[3] + d >>> 0;\n H[4] = H[4] + e >>> 0;\n }\n\n return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (sha1);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/uuid/dist/esm-browser/sha1.js?");
12809
+
12810
+ /***/ }),
12811
+
12812
+ /***/ "../../node_modules/uuid/dist/esm-browser/stringify.js":
12813
+ /*!*************************************************************!*\
12814
+ !*** ../../node_modules/uuid/dist/esm-browser/stringify.js ***!
12815
+ \*************************************************************/
12816
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12817
+
12818
+ "use strict";
12819
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ unsafeStringify: () => (/* binding */ unsafeStringify)\n/* harmony export */ });\n/* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validate.js */ \"../../node_modules/uuid/dist/esm-browser/validate.js\");\n\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nfunction unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!(0,_validate_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (stringify);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/uuid/dist/esm-browser/stringify.js?");
12820
+
12821
+ /***/ }),
12822
+
12823
+ /***/ "../../node_modules/uuid/dist/esm-browser/v35.js":
12824
+ /*!*******************************************************!*\
12825
+ !*** ../../node_modules/uuid/dist/esm-browser/v35.js ***!
12826
+ \*******************************************************/
12827
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12828
+
12829
+ "use strict";
12830
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DNS: () => (/* binding */ DNS),\n/* harmony export */ URL: () => (/* binding */ URL),\n/* harmony export */ \"default\": () => (/* binding */ v35)\n/* harmony export */ });\n/* harmony import */ var _stringify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringify.js */ \"../../node_modules/uuid/dist/esm-browser/stringify.js\");\n/* harmony import */ var _parse_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./parse.js */ \"../../node_modules/uuid/dist/esm-browser/parse.js\");\n\n\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nconst DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nconst URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nfunction v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = (0,_parse_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return (0,_stringify_js__WEBPACK_IMPORTED_MODULE_1__.unsafeStringify)(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/uuid/dist/esm-browser/v35.js?");
12831
+
12832
+ /***/ }),
12833
+
12834
+ /***/ "../../node_modules/uuid/dist/esm-browser/v5.js":
12835
+ /*!******************************************************!*\
12836
+ !*** ../../node_modules/uuid/dist/esm-browser/v5.js ***!
12837
+ \******************************************************/
12838
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12839
+
12840
+ "use strict";
12841
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _v35_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./v35.js */ \"../../node_modules/uuid/dist/esm-browser/v35.js\");\n/* harmony import */ var _sha1_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sha1.js */ \"../../node_modules/uuid/dist/esm-browser/sha1.js\");\n\n\nconst v5 = (0,_v35_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])('v5', 0x50, _sha1_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (v5);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/uuid/dist/esm-browser/v5.js?");
12842
+
12843
+ /***/ }),
12844
+
12845
+ /***/ "../../node_modules/uuid/dist/esm-browser/validate.js":
12846
+ /*!************************************************************!*\
12847
+ !*** ../../node_modules/uuid/dist/esm-browser/validate.js ***!
12848
+ \************************************************************/
12849
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12850
+
12851
+ "use strict";
12852
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ \"../../node_modules/uuid/dist/esm-browser/regex.js\");\n\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && _regex_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].test(uuid);\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (validate);\n\n//# sourceURL=webpack://ExcalidrawLib/../../node_modules/uuid/dist/esm-browser/validate.js?");
12853
+
12854
+ /***/ }),
12855
+
12856
12856
  /***/ "../../node_modules/uvu/assert/index.mjs":
12857
12857
  /*!***********************************************!*\
12858
12858
  !*** ../../node_modules/uvu/assert/index.mjs ***!
@@ -12904,7 +12904,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
12904
12904
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12905
12905
 
12906
12906
  "use strict";
12907
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BinaryHeap: () => (/* binding */ BinaryHeap)\n/* harmony export */ });\nclass BinaryHeap {\n constructor(scoreFunction) {\n this.scoreFunction = scoreFunction;\n this.content = [];\n }\n\n sinkDown(idx) {\n const node = this.content[idx];\n\n while (idx > 0) {\n const parentN = (idx + 1 >> 1) - 1;\n const parent = this.content[parentN];\n\n if (this.scoreFunction(node) < this.scoreFunction(parent)) {\n this.content[parentN] = node;\n this.content[idx] = parent;\n idx = parentN; // TODO: Optimize\n } else {\n break;\n }\n }\n }\n\n bubbleUp(idx) {\n const length = this.content.length;\n const node = this.content[idx];\n const score = this.scoreFunction(node);\n\n while (true) {\n const child2N = idx + 1 << 1;\n const child1N = child2N - 1;\n let swap = null;\n let child1Score = 0;\n\n if (child1N < length) {\n const child1 = this.content[child1N];\n child1Score = this.scoreFunction(child1);\n\n if (child1Score < score) {\n swap = child1N;\n }\n }\n\n if (child2N < length) {\n const child2 = this.content[child2N];\n const child2Score = this.scoreFunction(child2);\n\n if (child2Score < (swap === null ? score : child1Score)) {\n swap = child2N;\n }\n }\n\n if (swap !== null) {\n this.content[idx] = this.content[swap];\n this.content[swap] = node;\n idx = swap; // TODO: Optimize\n } else {\n break;\n }\n }\n }\n\n push(node) {\n this.content.push(node);\n this.sinkDown(this.content.length - 1);\n }\n\n pop() {\n if (this.content.length === 0) {\n return null;\n }\n\n const result = this.content[0];\n const end = this.content.pop();\n\n if (this.content.length > 0) {\n this.content[0] = end;\n this.bubbleUp(0);\n }\n\n return result;\n }\n\n remove(node) {\n if (this.content.length === 0) {\n return;\n }\n\n const i = this.content.indexOf(node);\n const end = this.content.pop();\n\n if (i < this.content.length) {\n this.content[i] = end;\n\n if (this.scoreFunction(end) < this.scoreFunction(node)) {\n this.sinkDown(i);\n } else {\n this.bubbleUp(i);\n }\n }\n }\n\n size() {\n return this.content.length;\n }\n\n rescoreElement(node) {\n this.sinkDown(this.content.indexOf(node));\n }\n\n}\n\n//# sourceURL=webpack://ExcalidrawLib/../common/src/binary-heap.ts?");
12907
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BinaryHeap: () => (/* binding */ BinaryHeap)\n/* harmony export */ });\nclass BinaryHeap {\n constructor(scoreFunction) {\n this.scoreFunction = scoreFunction;\n this.content = [];\n }\n\n sinkDown(idx) {\n const node = this.content[idx];\n const nodeScore = this.scoreFunction(node);\n\n while (idx > 0) {\n const parentN = (idx + 1 >> 1) - 1;\n const parent = this.content[parentN];\n\n if (nodeScore < this.scoreFunction(parent)) {\n this.content[idx] = parent;\n idx = parentN; // TODO: Optimize\n } else {\n break;\n }\n }\n\n this.content[idx] = node;\n }\n\n bubbleUp(idx) {\n const length = this.content.length;\n const node = this.content[idx];\n const score = this.scoreFunction(node);\n\n while (true) {\n const child1N = (idx + 1 << 1) - 1;\n const child2N = child1N + 1;\n let smallestIdx = idx;\n let smallestScore = score; // Check left child\n\n if (child1N < length) {\n const child1Score = this.scoreFunction(this.content[child1N]);\n\n if (child1Score < smallestScore) {\n smallestIdx = child1N;\n smallestScore = child1Score;\n }\n } // Check right child\n\n\n if (child2N < length) {\n const child2Score = this.scoreFunction(this.content[child2N]);\n\n if (child2Score < smallestScore) {\n smallestIdx = child2N;\n }\n }\n\n if (smallestIdx === idx) {\n break;\n } // Move the smaller child up, continue finding position for node\n\n\n this.content[idx] = this.content[smallestIdx];\n idx = smallestIdx;\n } // Place node in its final position\n\n\n this.content[idx] = node;\n }\n\n push(node) {\n this.content.push(node);\n this.sinkDown(this.content.length - 1);\n }\n\n pop() {\n if (this.content.length === 0) {\n return null;\n }\n\n const result = this.content[0];\n const end = this.content.pop();\n\n if (this.content.length > 0) {\n this.content[0] = end;\n this.bubbleUp(0);\n }\n\n return result;\n }\n\n remove(node) {\n if (this.content.length === 0) {\n return;\n }\n\n const i = this.content.indexOf(node);\n const end = this.content.pop();\n\n if (i < this.content.length) {\n this.content[i] = end;\n\n if (this.scoreFunction(end) < this.scoreFunction(node)) {\n this.sinkDown(i);\n } else {\n this.bubbleUp(i);\n }\n }\n }\n\n size() {\n return this.content.length;\n }\n\n rescoreElement(node) {\n this.sinkDown(this.content.indexOf(node));\n }\n\n}\n\n//# sourceURL=webpack://ExcalidrawLib/../common/src/binary-heap.ts?");
12908
12908
 
12909
12909
  /***/ }),
12910
12910
 
@@ -13300,7 +13300,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
13300
13300
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
13301
13301
 
13302
13302
  "use strict";
13303
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AppStateDelta: () => (/* reexport safe */ _delta__WEBPACK_IMPORTED_MODULE_10__.AppStateDelta),\n/* harmony export */ BASE_PADDING: () => (/* reexport safe */ _elbowArrow__WEBPACK_IMPORTED_MODULE_15__.BASE_PADDING),\n/* harmony export */ BINDING_HIGHLIGHT_THICKNESS: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.BINDING_HIGHLIGHT_THICKNESS),\n/* harmony export */ BindableElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.BindableElement),\n/* harmony export */ BoundElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.BoundElement),\n/* harmony export */ CaptureUpdateAction: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.CaptureUpdateAction),\n/* harmony export */ DEFAULT_LINK_SIZE: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.DEFAULT_LINK_SIZE),\n/* harmony export */ DEFAULT_OMIT_SIDES: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.DEFAULT_OMIT_SIDES),\n/* harmony export */ Delta: () => (/* reexport safe */ _delta__WEBPACK_IMPORTED_MODULE_10__.Delta),\n/* harmony export */ DurableIncrement: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.DurableIncrement),\n/* harmony export */ ElementBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.ElementBounds),\n/* harmony export */ ElementsDelta: () => (/* reexport safe */ _delta__WEBPACK_IMPORTED_MODULE_10__.ElementsDelta),\n/* harmony export */ EphemeralIncrement: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.EphemeralIncrement),\n/* harmony export */ FIXED_BINDING_DISTANCE: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.FIXED_BINDING_DISTANCE),\n/* harmony export */ FlowChartCreator: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.FlowChartCreator),\n/* harmony export */ FlowChartNavigator: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.FlowChartNavigator),\n/* harmony export */ HEADING_DOWN: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.HEADING_DOWN),\n/* harmony export */ HEADING_LEFT: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.HEADING_LEFT),\n/* harmony export */ HEADING_RIGHT: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.HEADING_RIGHT),\n/* harmony export */ HEADING_UP: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.HEADING_UP),\n/* harmony export */ IMAGE_INVERT_FILTER: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.IMAGE_INVERT_FILTER),\n/* harmony export */ INVISIBLY_SMALL_ELEMENT_SIZE: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.INVISIBLY_SMALL_ELEMENT_SIZE),\n/* harmony export */ InvalidFractionalIndexError: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.InvalidFractionalIndexError),\n/* harmony export */ LinearElementEditor: () => (/* reexport safe */ _linearElementEditor__WEBPACK_IMPORTED_MODULE_24__.LinearElementEditor),\n/* harmony export */ MINIMAL_CROP_SIZE: () => (/* reexport safe */ _cropElement__WEBPACK_IMPORTED_MODULE_9__.MINIMAL_CROP_SIZE),\n/* harmony export */ OMIT_SIDES_FOR_FRAME: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.OMIT_SIDES_FOR_FRAME),\n/* harmony export */ OMIT_SIDES_FOR_MULTIPLE_ELEMENTS: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.OMIT_SIDES_FOR_MULTIPLE_ELEMENTS),\n/* harmony export */ Scene: () => (/* reexport safe */ _Scene__WEBPACK_IMPORTED_MODULE_31__.Scene),\n/* harmony export */ ShapeCache: () => (/* reexport safe */ _shape__WEBPACK_IMPORTED_MODULE_33__.ShapeCache),\n/* harmony export */ Store: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.Store),\n/* harmony export */ StoreChange: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.StoreChange),\n/* harmony export */ StoreDelta: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.StoreDelta),\n/* harmony export */ StoreIncrement: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.StoreIncrement),\n/* harmony export */ StoreSnapshot: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.StoreSnapshot),\n/* harmony export */ aabbForElement: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.aabbForElement),\n/* harmony export */ addElementsToFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.addElementsToFrame),\n/* harmony export */ addNewNodes: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.addNewNodes),\n/* harmony export */ addToGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.addToGroup),\n/* harmony export */ alignElements: () => (/* reexport safe */ _align__WEBPACK_IMPORTED_MODULE_3__.alignElements),\n/* harmony export */ avoidRectangularCorner: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.avoidRectangularCorner),\n/* harmony export */ bindElementsToFramesAfterDuplication: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.bindElementsToFramesAfterDuplication),\n/* harmony export */ bindLinearElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindLinearElement),\n/* harmony export */ bindOrUnbindLinearElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindOrUnbindLinearElement),\n/* harmony export */ bindOrUnbindLinearElements: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindOrUnbindLinearElements),\n/* harmony export */ bindPointToSnapToElementOutline: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindPointToSnapToElementOutline),\n/* harmony export */ bindingBorderTest: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindingBorderTest),\n/* harmony export */ bindingProperties: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindingProperties),\n/* harmony export */ bumpVersion: () => (/* reexport safe */ _mutateElement__WEBPACK_IMPORTED_MODULE_25__.bumpVersion),\n/* harmony export */ calculateFixedPointForElbowArrowBinding: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.calculateFixedPointForElbowArrowBinding),\n/* harmony export */ canApplyRoundnessTypeToElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.canApplyRoundnessTypeToElement),\n/* harmony export */ canBecomePolygon: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.canBecomePolygon),\n/* harmony export */ canChangeRoundness: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.canChangeRoundness),\n/* harmony export */ canCreateLinkFromElements: () => (/* reexport safe */ _elementLink__WEBPACK_IMPORTED_MODULE_16__.canCreateLinkFromElements),\n/* harmony export */ canHaveArrowheads: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.canHaveArrowheads),\n/* harmony export */ canResizeFromSides: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.canResizeFromSides),\n/* harmony export */ charWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.charWidth),\n/* harmony export */ clearElementsForDatabase: () => (/* binding */ clearElementsForDatabase),\n/* harmony export */ clearElementsForExport: () => (/* binding */ clearElementsForExport),\n/* harmony export */ clearElementsForLocalStorage: () => (/* binding */ clearElementsForLocalStorage),\n/* harmony export */ compareHeading: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.compareHeading),\n/* harmony export */ computeBoundTextPosition: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.computeBoundTextPosition),\n/* harmony export */ computeContainerDimensionForBoundText: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.computeContainerDimensionForBoundText),\n/* harmony export */ containsCJK: () => (/* reexport safe */ _textWrapping__WEBPACK_IMPORTED_MODULE_39__.containsCJK),\n/* harmony export */ createPlaceholderEmbeddableLabel: () => (/* reexport safe */ _embeddable__WEBPACK_IMPORTED_MODULE_17__.createPlaceholderEmbeddableLabel),\n/* harmony export */ createSrcDoc: () => (/* reexport safe */ _embeddable__WEBPACK_IMPORTED_MODULE_17__.createSrcDoc),\n/* harmony export */ cropElement: () => (/* reexport safe */ _cropElement__WEBPACK_IMPORTED_MODULE_9__.cropElement),\n/* harmony export */ deconstructDiamondElement: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_41__.deconstructDiamondElement),\n/* harmony export */ deconstructLinearOrFreeDrawElement: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_41__.deconstructLinearOrFreeDrawElement),\n/* harmony export */ deconstructRectanguloidElement: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_41__.deconstructRectanguloidElement),\n/* harmony export */ deepCopyElement: () => (/* reexport safe */ _duplicate__WEBPACK_IMPORTED_MODULE_14__.deepCopyElement),\n/* harmony export */ defaultGetElementLinkFromSelection: () => (/* reexport safe */ _elementLink__WEBPACK_IMPORTED_MODULE_16__.defaultGetElementLinkFromSelection),\n/* harmony export */ detectLineHeight: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.detectLineHeight),\n/* harmony export */ determineFocusDistance: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.determineFocusDistance),\n/* harmony export */ distanceToElement: () => (/* reexport safe */ _distance__WEBPACK_IMPORTED_MODULE_11__.distanceToElement),\n/* harmony export */ distributeElements: () => (/* reexport safe */ _distribute__WEBPACK_IMPORTED_MODULE_12__.distributeElements),\n/* harmony export */ doBoundsIntersect: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.doBoundsIntersect),\n/* harmony export */ dragNewElement: () => (/* reexport safe */ _dragElements__WEBPACK_IMPORTED_MODULE_13__.dragNewElement),\n/* harmony export */ dragSelectedElements: () => (/* reexport safe */ _dragElements__WEBPACK_IMPORTED_MODULE_13__.dragSelectedElements),\n/* harmony export */ duplicateElement: () => (/* reexport safe */ _duplicate__WEBPACK_IMPORTED_MODULE_14__.duplicateElement),\n/* harmony export */ duplicateElements: () => (/* reexport safe */ _duplicate__WEBPACK_IMPORTED_MODULE_14__.duplicateElements),\n/* harmony export */ editGroupForSelectedElement: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.editGroupForSelectedElement),\n/* harmony export */ elementCenterPoint: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.elementCenterPoint),\n/* harmony export */ elementOverlapsWithFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.elementOverlapsWithFrame),\n/* harmony export */ elementWithCanvasCache: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.elementWithCanvasCache),\n/* harmony export */ elementsAreInFrameBounds: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.elementsAreInFrameBounds),\n/* harmony export */ elementsAreInSameGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.elementsAreInSameGroup),\n/* harmony export */ embeddableURLValidator: () => (/* reexport safe */ _embeddable__WEBPACK_IMPORTED_MODULE_17__.embeddableURLValidator),\n/* harmony export */ excludeElementsInFramesFromSelection: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.excludeElementsInFramesFromSelection),\n/* harmony export */ filterElementsEligibleAsFrameChildren: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.filterElementsEligibleAsFrameChildren),\n/* harmony export */ fixBindingsAfterDeletion: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.fixBindingsAfterDeletion),\n/* harmony export */ fixDuplicatedBindingsAfterDuplication: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.fixDuplicatedBindingsAfterDuplication),\n/* harmony export */ flipHeading: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.flipHeading),\n/* harmony export */ frameAndChildrenSelectedTogether: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.frameAndChildrenSelectedTogether),\n/* harmony export */ generateFreeDrawShape: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.generateFreeDrawShape),\n/* harmony export */ generateLinearCollisionShape: () => (/* reexport safe */ _shape__WEBPACK_IMPORTED_MODULE_33__.generateLinearCollisionShape),\n/* harmony export */ generateRoughOptions: () => (/* reexport safe */ _shape__WEBPACK_IMPORTED_MODULE_33__.generateRoughOptions),\n/* harmony export */ getApproxMinLineHeight: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getApproxMinLineHeight),\n/* harmony export */ getApproxMinLineWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getApproxMinLineWidth),\n/* harmony export */ getArrowLocalFixedPoints: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getArrowLocalFixedPoints),\n/* harmony export */ getArrowheadAngle: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getArrowheadAngle),\n/* harmony export */ getArrowheadPoints: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getArrowheadPoints),\n/* harmony export */ getArrowheadSize: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getArrowheadSize),\n/* harmony export */ getBoundTextElement: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getBoundTextElement),\n/* harmony export */ getBoundTextElementId: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getBoundTextElementId),\n/* harmony export */ getBoundTextElementPosition: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getBoundTextElementPosition),\n/* harmony export */ getBoundTextMaxHeight: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getBoundTextMaxHeight),\n/* harmony export */ getBoundTextMaxWidth: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getBoundTextMaxWidth),\n/* harmony export */ getBoundsFromPoints: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getBoundsFromPoints),\n/* harmony export */ getCenterForBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getCenterForBounds),\n/* harmony export */ getClosestElementBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getClosestElementBounds),\n/* harmony export */ getCommonBoundingBox: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getCommonBoundingBox),\n/* harmony export */ getCommonBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getCommonBounds),\n/* harmony export */ getContainerCenter: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getContainerCenter),\n/* harmony export */ getContainerCoords: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getContainerCoords),\n/* harmony export */ getContainerElement: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getContainerElement),\n/* harmony export */ getContainingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getContainingFrame),\n/* harmony export */ getCornerRadius: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_41__.getCornerRadius),\n/* harmony export */ getCubicBezierCurveBound: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getCubicBezierCurveBound),\n/* harmony export */ getCursorForResizingElement: () => (/* reexport safe */ _resizeTest__WEBPACK_IMPORTED_MODULE_30__.getCursorForResizingElement),\n/* harmony export */ getDefaultFrameName: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getDefaultFrameName),\n/* harmony export */ getDefaultRoundnessTypeForElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.getDefaultRoundnessTypeForElement),\n/* harmony export */ getDiamondPoints: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getDiamondPoints),\n/* harmony export */ getDragOffsetXY: () => (/* reexport safe */ _dragElements__WEBPACK_IMPORTED_MODULE_13__.getDragOffsetXY),\n/* harmony export */ getDraggedElementsBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getDraggedElementsBounds),\n/* harmony export */ getElementAbsoluteCoords: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getElementAbsoluteCoords),\n/* harmony export */ getElementBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getElementBounds),\n/* harmony export */ getElementLineSegments: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getElementLineSegments),\n/* harmony export */ getElementPointsCoords: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getElementPointsCoords),\n/* harmony export */ getElementShape: () => (/* reexport safe */ _shape__WEBPACK_IMPORTED_MODULE_33__.getElementShape),\n/* harmony export */ getElementWithTransformHandleType: () => (/* reexport safe */ _resizeTest__WEBPACK_IMPORTED_MODULE_30__.getElementWithTransformHandleType),\n/* harmony export */ getElementsCompletelyInFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getElementsCompletelyInFrame),\n/* harmony export */ getElementsInGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getElementsInGroup),\n/* harmony export */ getElementsInNewFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getElementsInNewFrame),\n/* harmony export */ getElementsInResizingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getElementsInResizingFrame),\n/* harmony export */ getElementsIntersectingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getElementsIntersectingFrame),\n/* harmony export */ getElementsOverlappingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getElementsOverlappingFrame),\n/* harmony export */ getElementsWithinSelection: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.getElementsWithinSelection),\n/* harmony export */ getEmbedLink: () => (/* reexport safe */ _embeddable__WEBPACK_IMPORTED_MODULE_17__.getEmbedLink),\n/* harmony export */ getFlipAdjustedCropPosition: () => (/* reexport safe */ _cropElement__WEBPACK_IMPORTED_MODULE_9__.getFlipAdjustedCropPosition),\n/* harmony export */ getFrameChildren: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getFrameChildren),\n/* harmony export */ getFrameLikeElements: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getFrameLikeElements),\n/* harmony export */ getFrameLikeTitle: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getFrameLikeTitle),\n/* harmony export */ getFreeDrawPath2D: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.getFreeDrawPath2D),\n/* harmony export */ getFreeDrawSvgPath: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.getFreeDrawSvgPath),\n/* harmony export */ getFreedrawOutlineAsSegments: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.getFreedrawOutlineAsSegments),\n/* harmony export */ getFreedrawOutlinePoints: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.getFreedrawOutlinePoints),\n/* harmony export */ getGlobalFixedPointForBindableElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getGlobalFixedPointForBindableElement),\n/* harmony export */ getGlobalFixedPoints: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getGlobalFixedPoints),\n/* harmony export */ getHeadingForElbowArrowSnap: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getHeadingForElbowArrowSnap),\n/* harmony export */ getHoveredElementForBinding: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getHoveredElementForBinding),\n/* harmony export */ getInitializedImageElements: () => (/* reexport safe */ _image__WEBPACK_IMPORTED_MODULE_23__.getInitializedImageElements),\n/* harmony export */ getLineHeightInPx: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getLineHeightInPx),\n/* harmony export */ getLineWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getLineWidth),\n/* harmony export */ getLinearElementSubType: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.getLinearElementSubType),\n/* harmony export */ getLinkDirectionFromKey: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.getLinkDirectionFromKey),\n/* harmony export */ getLinkIdAndTypeFromSelection: () => (/* reexport safe */ _elementLink__WEBPACK_IMPORTED_MODULE_16__.getLinkIdAndTypeFromSelection),\n/* harmony export */ getLockedLinearCursorAlignSize: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.getLockedLinearCursorAlignSize),\n/* harmony export */ getMaxCharWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getMaxCharWidth),\n/* harmony export */ getMaximumGroups: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getMaximumGroups),\n/* harmony export */ getMinCharWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getMinCharWidth),\n/* harmony export */ getMinMaxXYFromCurvePathOps: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getMinMaxXYFromCurvePathOps),\n/* harmony export */ getMinTextElementWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getMinTextElementWidth),\n/* harmony export */ getNewGroupIdsForDuplication: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getNewGroupIdsForDuplication),\n/* harmony export */ getNextSingleWidthAndHeightFromPointer: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.getNextSingleWidthAndHeightFromPointer),\n/* harmony export */ getNonDeletedElements: () => (/* binding */ getNonDeletedElements),\n/* harmony export */ getNonDeletedGroupIds: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getNonDeletedGroupIds),\n/* harmony export */ getNormalizedDimensions: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.getNormalizedDimensions),\n/* harmony export */ getObservedAppState: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.getObservedAppState),\n/* harmony export */ getOmitSidesForDevice: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.getOmitSidesForDevice),\n/* harmony export */ getOriginalContainerHeightFromCache: () => (/* reexport safe */ _containerCache__WEBPACK_IMPORTED_MODULE_8__.getOriginalContainerHeightFromCache),\n/* harmony export */ getPerfectElementSize: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.getPerfectElementSize),\n/* harmony export */ getPredecessors: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.getPredecessors),\n/* harmony export */ getRectangleBoxAbsoluteCoords: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getRectangleBoxAbsoluteCoords),\n/* harmony export */ getRenderOpacity: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.getRenderOpacity),\n/* harmony export */ getResizeArrowDirection: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.getResizeArrowDirection),\n/* harmony export */ getResizeOffsetXY: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.getResizeOffsetXY),\n/* harmony export */ getResizedElementAbsoluteCoords: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getResizedElementAbsoluteCoords),\n/* harmony export */ getRootElements: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getRootElements),\n/* harmony export */ getSceneVersion: () => (/* binding */ getSceneVersion),\n/* harmony export */ getSelectedElements: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.getSelectedElements),\n/* harmony export */ getSelectedElementsByGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getSelectedElementsByGroup),\n/* harmony export */ getSelectedGroupForElement: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getSelectedGroupForElement),\n/* harmony export */ getSelectedGroupIdForElement: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getSelectedGroupIdForElement),\n/* harmony export */ getSelectedGroupIds: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getSelectedGroupIds),\n/* harmony export */ getSelectionStateForElements: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.getSelectionStateForElements),\n/* harmony export */ getSuggestedBindingsForArrows: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getSuggestedBindingsForArrows),\n/* harmony export */ getTargetElements: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.getTargetElements),\n/* harmony export */ getTargetFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getTargetFrame),\n/* harmony export */ getTextElementAngle: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getTextElementAngle),\n/* harmony export */ getTextFromElements: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getTextFromElements),\n/* harmony export */ getTextHeight: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getTextHeight),\n/* harmony export */ getTextWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getTextWidth),\n/* harmony export */ getTransformHandleTypeFromCoords: () => (/* reexport safe */ _resizeTest__WEBPACK_IMPORTED_MODULE_30__.getTransformHandleTypeFromCoords),\n/* harmony export */ getTransformHandles: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.getTransformHandles),\n/* harmony export */ getTransformHandlesFromCoords: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.getTransformHandlesFromCoords),\n/* harmony export */ getUncroppedImageElement: () => (/* reexport safe */ _cropElement__WEBPACK_IMPORTED_MODULE_9__.getUncroppedImageElement),\n/* harmony export */ getUncroppedWidthAndHeight: () => (/* reexport safe */ _cropElement__WEBPACK_IMPORTED_MODULE_9__.getUncroppedWidthAndHeight),\n/* harmony export */ getVisibleAndNonSelectedElements: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.getVisibleAndNonSelectedElements),\n/* harmony export */ getVisibleElements: () => (/* binding */ getVisibleElements),\n/* harmony export */ getVisibleSceneBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getVisibleSceneBounds),\n/* harmony export */ groupByFrameLikes: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.groupByFrameLikes),\n/* harmony export */ groupsAreAtLeastIntersectingTheFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.groupsAreAtLeastIntersectingTheFrame),\n/* harmony export */ groupsAreCompletelyOutOfFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.groupsAreCompletelyOutOfFrame),\n/* harmony export */ handleBindTextResize: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.handleBindTextResize),\n/* harmony export */ hasBackground: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.hasBackground),\n/* harmony export */ hasBoundTextElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.hasBoundTextElement),\n/* harmony export */ hasStrokeColor: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.hasStrokeColor),\n/* harmony export */ hasStrokeStyle: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.hasStrokeStyle),\n/* harmony export */ hasStrokeWidth: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.hasStrokeWidth),\n/* harmony export */ hashElementsVersion: () => (/* binding */ hashElementsVersion),\n/* harmony export */ hashString: () => (/* binding */ hashString),\n/* harmony export */ headingForPoint: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.headingForPoint),\n/* harmony export */ headingForPointFromElement: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.headingForPointFromElement),\n/* harmony export */ headingForPointIsHorizontal: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.headingForPointIsHorizontal),\n/* harmony export */ headingIsHorizontal: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.headingIsHorizontal),\n/* harmony export */ headingIsVertical: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.headingIsVertical),\n/* harmony export */ hitElementBoundText: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.hitElementBoundText),\n/* harmony export */ hitElementBoundingBox: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.hitElementBoundingBox),\n/* harmony export */ hitElementBoundingBoxOnly: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.hitElementBoundingBoxOnly),\n/* harmony export */ hitElementItself: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.hitElementItself),\n/* harmony export */ intersectElementWithLineSegment: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.intersectElementWithLineSegment),\n/* harmony export */ isArrowBoundToElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isArrowBoundToElement),\n/* harmony export */ isArrowElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isArrowElement),\n/* harmony export */ isBindableElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isBindableElement),\n/* harmony export */ isBindingElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isBindingElement),\n/* harmony export */ isBindingElementType: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isBindingElementType),\n/* harmony export */ isBindingEnabled: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.isBindingEnabled),\n/* harmony export */ isBoundToContainer: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isBoundToContainer),\n/* harmony export */ isBounds: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isBounds),\n/* harmony export */ isCursorInFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.isCursorInFrame),\n/* harmony export */ isCurvedArrow: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isCurvedArrow),\n/* harmony export */ isElbowArrow: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isElbowArrow),\n/* harmony export */ isElementCompletelyInViewport: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.isElementCompletelyInViewport),\n/* harmony export */ isElementContainingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.isElementContainingFrame),\n/* harmony export */ isElementInFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.isElementInFrame),\n/* harmony export */ isElementInGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.isElementInGroup),\n/* harmony export */ isElementInViewport: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.isElementInViewport),\n/* harmony export */ isElementIntersectingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.isElementIntersectingFrame),\n/* harmony export */ isElementLink: () => (/* reexport safe */ _elementLink__WEBPACK_IMPORTED_MODULE_16__.isElementLink),\n/* harmony export */ isEmbeddableElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isEmbeddableElement),\n/* harmony export */ isExcalidrawElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isExcalidrawElement),\n/* harmony export */ isFixedPointBinding: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFixedPointBinding),\n/* harmony export */ isFlowchartNodeElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFlowchartNodeElement),\n/* harmony export */ isFrameElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFrameElement),\n/* harmony export */ isFrameLikeElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFrameLikeElement),\n/* harmony export */ isFreeDrawElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFreeDrawElement),\n/* harmony export */ isFreeDrawElementType: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFreeDrawElementType),\n/* harmony export */ isHTMLSVGElement: () => (/* reexport safe */ _image__WEBPACK_IMPORTED_MODULE_23__.isHTMLSVGElement),\n/* harmony export */ isIframeElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isIframeElement),\n/* harmony export */ isIframeLikeElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isIframeLikeElement),\n/* harmony export */ isImageElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isImageElement),\n/* harmony export */ isInGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.isInGroup),\n/* harmony export */ isInitializedImageElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isInitializedImageElement),\n/* harmony export */ isInvisiblySmallElement: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.isInvisiblySmallElement),\n/* harmony export */ isLineElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isLineElement),\n/* harmony export */ isLinearElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isLinearElement),\n/* harmony export */ isLinearElementSimpleAndAlreadyBound: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.isLinearElementSimpleAndAlreadyBound),\n/* harmony export */ isLinearElementType: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isLinearElementType),\n/* harmony export */ isMagicFrameElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isMagicFrameElement),\n/* harmony export */ isMeasureTextSupported: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.isMeasureTextSupported),\n/* harmony export */ isNodeInFlowchart: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.isNodeInFlowchart),\n/* harmony export */ isNonDeletedElement: () => (/* binding */ isNonDeletedElement),\n/* harmony export */ isPathALoop: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_41__.isPathALoop),\n/* harmony export */ isPointInElement: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.isPointInElement),\n/* harmony export */ isRectangularElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isRectangularElement),\n/* harmony export */ isRectanguloidElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isRectanguloidElement),\n/* harmony export */ isSelectedViaGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.isSelectedViaGroup),\n/* harmony export */ isSharpArrow: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isSharpArrow),\n/* harmony export */ isSimpleArrow: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isSimpleArrow),\n/* harmony export */ isSomeElementSelected: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.isSomeElementSelected),\n/* harmony export */ isTextBindableContainer: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isTextBindableContainer),\n/* harmony export */ isTextElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isTextElement),\n/* harmony export */ isUsingAdaptiveRadius: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isUsingAdaptiveRadius),\n/* harmony export */ isUsingProportionalRadius: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isUsingProportionalRadius),\n/* harmony export */ isValidPolygon: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isValidPolygon),\n/* harmony export */ isValidTextContainer: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.isValidTextContainer),\n/* harmony export */ loadHTMLImageElement: () => (/* reexport safe */ _image__WEBPACK_IMPORTED_MODULE_23__.loadHTMLImageElement),\n/* harmony export */ makeNextSelectedElementIds: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.makeNextSelectedElementIds),\n/* harmony export */ maxBindingGap: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.maxBindingGap),\n/* harmony export */ maybeBindLinearElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.maybeBindLinearElement),\n/* harmony export */ maybeParseEmbedSrc: () => (/* reexport safe */ _embeddable__WEBPACK_IMPORTED_MODULE_17__.maybeParseEmbedSrc),\n/* harmony export */ maybeSuggestBindingsForLinearElementAtCoords: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.maybeSuggestBindingsForLinearElementAtCoords),\n/* harmony export */ measureFontSizeFromWidth: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.measureFontSizeFromWidth),\n/* harmony export */ measureText: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.measureText),\n/* harmony export */ moveAllLeft: () => (/* reexport safe */ _zindex__WEBPACK_IMPORTED_MODULE_42__.moveAllLeft),\n/* harmony export */ moveAllRight: () => (/* reexport safe */ _zindex__WEBPACK_IMPORTED_MODULE_42__.moveAllRight),\n/* harmony export */ moveOneLeft: () => (/* reexport safe */ _zindex__WEBPACK_IMPORTED_MODULE_42__.moveOneLeft),\n/* harmony export */ moveOneRight: () => (/* reexport safe */ _zindex__WEBPACK_IMPORTED_MODULE_42__.moveOneRight),\n/* harmony export */ mutateElement: () => (/* reexport safe */ _mutateElement__WEBPACK_IMPORTED_MODULE_25__.mutateElement),\n/* harmony export */ newArrowElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newArrowElement),\n/* harmony export */ newElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newElement),\n/* harmony export */ newElementWith: () => (/* reexport safe */ _mutateElement__WEBPACK_IMPORTED_MODULE_25__.newElementWith),\n/* harmony export */ newEmbeddableElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newEmbeddableElement),\n/* harmony export */ newFrameElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newFrameElement),\n/* harmony export */ newFreeDrawElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newFreeDrawElement),\n/* harmony export */ newIframeElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newIframeElement),\n/* harmony export */ newImageElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newImageElement),\n/* harmony export */ newLinearElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newLinearElement),\n/* harmony export */ newMagicFrameElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newMagicFrameElement),\n/* harmony export */ newTextElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newTextElement),\n/* harmony export */ normalizeElementOrder: () => (/* reexport safe */ _sortElements__WEBPACK_IMPORTED_MODULE_35__.normalizeElementOrder),\n/* harmony export */ normalizeFixedPoint: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.normalizeFixedPoint),\n/* harmony export */ normalizeSVG: () => (/* reexport safe */ _image__WEBPACK_IMPORTED_MODULE_23__.normalizeSVG),\n/* harmony export */ normalizeText: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.normalizeText),\n/* harmony export */ omitGroupsContainingFrameLikes: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.omitGroupsContainingFrameLikes),\n/* harmony export */ omitPartialGroups: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.omitPartialGroups),\n/* harmony export */ orderByFractionalIndex: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.orderByFractionalIndex),\n/* harmony export */ originalContainerCache: () => (/* reexport safe */ _containerCache__WEBPACK_IMPORTED_MODULE_8__.originalContainerCache),\n/* harmony export */ parseElementLinkFromURL: () => (/* reexport safe */ _elementLink__WEBPACK_IMPORTED_MODULE_16__.parseElementLinkFromURL),\n/* harmony export */ parseTokens: () => (/* reexport safe */ _textWrapping__WEBPACK_IMPORTED_MODULE_39__.parseTokens),\n/* harmony export */ pathsCache: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.pathsCache),\n/* harmony export */ pointInsideBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.pointInsideBounds),\n/* harmony export */ positionElementsOnGrid: () => (/* reexport safe */ _positionElementsOnGrid__WEBPACK_IMPORTED_MODULE_27__.positionElementsOnGrid),\n/* harmony export */ redrawTextBoundingBox: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.redrawTextBoundingBox),\n/* harmony export */ refreshTextDimensions: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.refreshTextDimensions),\n/* harmony export */ removeAllElementsFromFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.removeAllElementsFromFrame),\n/* harmony export */ removeElementsFromFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.removeElementsFromFrame),\n/* harmony export */ removeFromSelectedGroups: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.removeFromSelectedGroups),\n/* harmony export */ renderElement: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.renderElement),\n/* harmony export */ renderSelectionElement: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.renderSelectionElement),\n/* harmony export */ replaceAllElementsInFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.replaceAllElementsInFrame),\n/* harmony export */ rescalePointsInElement: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.rescalePointsInElement),\n/* harmony export */ resetOriginalContainerCache: () => (/* reexport safe */ _containerCache__WEBPACK_IMPORTED_MODULE_8__.resetOriginalContainerCache),\n/* harmony export */ resizeMultipleElements: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.resizeMultipleElements),\n/* harmony export */ resizeSingleElement: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.resizeSingleElement),\n/* harmony export */ resizeSingleTextElement: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.resizeSingleTextElement),\n/* harmony export */ resizeTest: () => (/* reexport safe */ _resizeTest__WEBPACK_IMPORTED_MODULE_30__.resizeTest),\n/* harmony export */ selectGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.selectGroup),\n/* harmony export */ selectGroupsForSelectedElements: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.selectGroupsForSelectedElements),\n/* harmony export */ selectGroupsFromGivenElements: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.selectGroupsFromGivenElements),\n/* harmony export */ setCustomTextMetricsProvider: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.setCustomTextMetricsProvider),\n/* harmony export */ shouldAllowVerticalAlign: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.shouldAllowVerticalAlign),\n/* harmony export */ shouldApplyFrameClip: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.shouldApplyFrameClip),\n/* harmony export */ shouldEnableBindingForPointerEvent: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.shouldEnableBindingForPointerEvent),\n/* harmony export */ shouldShowBoundingBox: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.shouldShowBoundingBox),\n/* harmony export */ shouldTestInside: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.shouldTestInside),\n/* harmony export */ showSelectedShapeActions: () => (/* reexport safe */ _showSelectedShapeActions__WEBPACK_IMPORTED_MODULE_34__.showSelectedShapeActions),\n/* harmony export */ snapToMid: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.snapToMid),\n/* harmony export */ suppportsHorizontalAlign: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.suppportsHorizontalAlign),\n/* harmony export */ syncInvalidIndices: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.syncInvalidIndices),\n/* harmony export */ syncInvalidIndicesImmutable: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.syncInvalidIndicesImmutable),\n/* harmony export */ syncMovedIndices: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.syncMovedIndices),\n/* harmony export */ toggleLinePolygonState: () => (/* reexport safe */ _shape__WEBPACK_IMPORTED_MODULE_33__.toggleLinePolygonState),\n/* harmony export */ toolIsArrow: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.toolIsArrow),\n/* harmony export */ transformElements: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.transformElements),\n/* harmony export */ updateBindings: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.updateBindings),\n/* harmony export */ updateBoundElements: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.updateBoundElements),\n/* harmony export */ updateElbowArrowPoints: () => (/* reexport safe */ _elbowArrow__WEBPACK_IMPORTED_MODULE_15__.updateElbowArrowPoints),\n/* harmony export */ updateFrameMembershipOfSelectedElements: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.updateFrameMembershipOfSelectedElements),\n/* harmony export */ updateImageCache: () => (/* reexport safe */ _image__WEBPACK_IMPORTED_MODULE_23__.updateImageCache),\n/* harmony export */ updateOriginalContainerCache: () => (/* reexport safe */ _containerCache__WEBPACK_IMPORTED_MODULE_8__.updateOriginalContainerCache),\n/* harmony export */ validateElbowPoints: () => (/* reexport safe */ _elbowArrow__WEBPACK_IMPORTED_MODULE_15__.validateElbowPoints),\n/* harmony export */ validateFractionalIndices: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.validateFractionalIndices),\n/* harmony export */ vectorToHeading: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.vectorToHeading),\n/* harmony export */ wrapText: () => (/* reexport safe */ _textWrapping__WEBPACK_IMPORTED_MODULE_39__.wrapText)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sizeHelpers */ \"../element/src/sizeHelpers.ts\");\n/* harmony import */ var _typeChecks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _align__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./align */ \"../element/src/align.ts\");\n/* harmony import */ var _binding__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./binding */ \"../element/src/binding.ts\");\n/* harmony import */ var _bounds__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _collision__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./collision */ \"../element/src/collision.ts\");\n/* harmony import */ var _comparisons__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./comparisons */ \"../element/src/comparisons.ts\");\n/* harmony import */ var _containerCache__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./containerCache */ \"../element/src/containerCache.ts\");\n/* harmony import */ var _cropElement__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./cropElement */ \"../element/src/cropElement.ts\");\n/* harmony import */ var _delta__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./delta */ \"../element/src/delta.ts\");\n/* harmony import */ var _distance__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./distance */ \"../element/src/distance.ts\");\n/* harmony import */ var _distribute__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./distribute */ \"../element/src/distribute.ts\");\n/* harmony import */ var _dragElements__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./dragElements */ \"../element/src/dragElements.ts\");\n/* harmony import */ var _duplicate__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./duplicate */ \"../element/src/duplicate.ts\");\n/* harmony import */ var _elbowArrow__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./elbowArrow */ \"../element/src/elbowArrow.ts\");\n/* harmony import */ var _elementLink__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./elementLink */ \"../element/src/elementLink.ts\");\n/* harmony import */ var _embeddable__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./embeddable */ \"../element/src/embeddable.ts\");\n/* harmony import */ var _flowchart__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./flowchart */ \"../element/src/flowchart.ts\");\n/* harmony import */ var _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./fractionalIndex */ \"../element/src/fractionalIndex.ts\");\n/* harmony import */ var _frame__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./frame */ \"../element/src/frame.ts\");\n/* harmony import */ var _groups__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./groups */ \"../element/src/groups.ts\");\n/* harmony import */ var _heading__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./heading */ \"../element/src/heading.ts\");\n/* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./image */ \"../element/src/image.ts\");\n/* harmony import */ var _linearElementEditor__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _mutateElement__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./mutateElement */ \"../element/src/mutateElement.ts\");\n/* harmony import */ var _newElement__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./newElement */ \"../element/src/newElement.ts\");\n/* harmony import */ var _positionElementsOnGrid__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./positionElementsOnGrid */ \"../element/src/positionElementsOnGrid.ts\");\n/* harmony import */ var _renderElement__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./renderElement */ \"../element/src/renderElement.ts\");\n/* harmony import */ var _resizeElements__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./resizeElements */ \"../element/src/resizeElements.ts\");\n/* harmony import */ var _resizeTest__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./resizeTest */ \"../element/src/resizeTest.ts\");\n/* harmony import */ var _Scene__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Scene */ \"../element/src/Scene.ts\");\n/* harmony import */ var _selection__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./selection */ \"../element/src/selection.ts\");\n/* harmony import */ var _shape__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./shape */ \"../element/src/shape.ts\");\n/* harmony import */ var _showSelectedShapeActions__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./showSelectedShapeActions */ \"../element/src/showSelectedShapeActions.ts\");\n/* harmony import */ var _sortElements__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./sortElements */ \"../element/src/sortElements.ts\");\n/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./store */ \"../element/src/store.ts\");\n/* harmony import */ var _textElement__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _textMeasurements__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _textWrapping__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./textWrapping */ \"../element/src/textWrapping.ts\");\n/* harmony import */ var _transformHandles__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./transformHandles */ \"../element/src/transformHandles.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./utils */ \"../element/src/utils.ts\");\n/* harmony import */ var _zindex__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./zindex */ \"../element/src/zindex.ts\");\n\n\n\n/**\r\n * @deprecated unsafe, use hashElementsVersion instead\r\n */\n\nconst getSceneVersion = elements => elements.reduce((acc, el) => acc + el.version, 0);\n/**\r\n * Hashes elements' versionNonce (using djb2 algo). Order of elements matters.\r\n */\n\nconst hashElementsVersion = elements => {\n let hash = 5381;\n\n for (const element of (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.toIterable)(elements)) {\n hash = (hash << 5) + hash + element.versionNonce;\n }\n\n return hash >>> 0; // Ensure unsigned 32-bit integer\n}; // string hash function (using djb2). Not cryptographically secure, use only\n// for versioning and such.\n\nconst hashString = s => {\n let hash = 5381;\n\n for (let i = 0; i < s.length; i++) {\n const char = s.charCodeAt(i);\n hash = (hash << 5) + hash + char;\n }\n\n return hash >>> 0; // Ensure unsigned 32-bit integer\n};\nconst getVisibleElements = elements => elements.filter(el => !el.isDeleted && !(0,_sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.isInvisiblySmallElement)(el));\nconst getNonDeletedElements = elements => elements.filter(element => !element.isDeleted);\nconst isNonDeletedElement = element => !element.isDeleted;\n\nconst _clearElements = elements => getNonDeletedElements(elements).map(element => (0,_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isLinearElementType)(element.type) ? Object.assign(Object.assign({}, element), {\n lastCommittedPoint: null\n}) : element);\n\nconst clearElementsForDatabase = elements => _clearElements(elements);\nconst clearElementsForExport = elements => _clearElements(elements);\nconst clearElementsForLocalStorage = elements => _clearElements(elements);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceURL=webpack://ExcalidrawLib/../element/src/index.ts?");
13303
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AppStateDelta: () => (/* reexport safe */ _delta__WEBPACK_IMPORTED_MODULE_10__.AppStateDelta),\n/* harmony export */ BASE_PADDING: () => (/* reexport safe */ _elbowArrow__WEBPACK_IMPORTED_MODULE_15__.BASE_PADDING),\n/* harmony export */ BINDING_HIGHLIGHT_THICKNESS: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.BINDING_HIGHLIGHT_THICKNESS),\n/* harmony export */ BindableElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.BindableElement),\n/* harmony export */ BoundElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.BoundElement),\n/* harmony export */ CaptureUpdateAction: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.CaptureUpdateAction),\n/* harmony export */ DEFAULT_LINK_SIZE: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.DEFAULT_LINK_SIZE),\n/* harmony export */ DEFAULT_OMIT_SIDES: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.DEFAULT_OMIT_SIDES),\n/* harmony export */ Delta: () => (/* reexport safe */ _delta__WEBPACK_IMPORTED_MODULE_10__.Delta),\n/* harmony export */ DurableIncrement: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.DurableIncrement),\n/* harmony export */ ElementBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.ElementBounds),\n/* harmony export */ ElementsDelta: () => (/* reexport safe */ _delta__WEBPACK_IMPORTED_MODULE_10__.ElementsDelta),\n/* harmony export */ EphemeralIncrement: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.EphemeralIncrement),\n/* harmony export */ FIXED_BINDING_DISTANCE: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.FIXED_BINDING_DISTANCE),\n/* harmony export */ FlowChartCreator: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.FlowChartCreator),\n/* harmony export */ FlowChartNavigator: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.FlowChartNavigator),\n/* harmony export */ HEADING_DOWN: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.HEADING_DOWN),\n/* harmony export */ HEADING_LEFT: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.HEADING_LEFT),\n/* harmony export */ HEADING_RIGHT: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.HEADING_RIGHT),\n/* harmony export */ HEADING_UP: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.HEADING_UP),\n/* harmony export */ IMAGE_INVERT_FILTER: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.IMAGE_INVERT_FILTER),\n/* harmony export */ INVISIBLY_SMALL_ELEMENT_SIZE: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.INVISIBLY_SMALL_ELEMENT_SIZE),\n/* harmony export */ InvalidFractionalIndexError: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.InvalidFractionalIndexError),\n/* harmony export */ LinearElementEditor: () => (/* reexport safe */ _linearElementEditor__WEBPACK_IMPORTED_MODULE_24__.LinearElementEditor),\n/* harmony export */ MINIMAL_CROP_SIZE: () => (/* reexport safe */ _cropElement__WEBPACK_IMPORTED_MODULE_9__.MINIMAL_CROP_SIZE),\n/* harmony export */ OMIT_SIDES_FOR_FRAME: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.OMIT_SIDES_FOR_FRAME),\n/* harmony export */ OMIT_SIDES_FOR_MULTIPLE_ELEMENTS: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.OMIT_SIDES_FOR_MULTIPLE_ELEMENTS),\n/* harmony export */ Scene: () => (/* reexport safe */ _Scene__WEBPACK_IMPORTED_MODULE_31__.Scene),\n/* harmony export */ ShapeCache: () => (/* reexport safe */ _shape__WEBPACK_IMPORTED_MODULE_33__.ShapeCache),\n/* harmony export */ Store: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.Store),\n/* harmony export */ StoreChange: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.StoreChange),\n/* harmony export */ StoreDelta: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.StoreDelta),\n/* harmony export */ StoreIncrement: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.StoreIncrement),\n/* harmony export */ StoreSnapshot: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.StoreSnapshot),\n/* harmony export */ aabbForElement: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.aabbForElement),\n/* harmony export */ addElementsToFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.addElementsToFrame),\n/* harmony export */ addNewNodes: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.addNewNodes),\n/* harmony export */ addToGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.addToGroup),\n/* harmony export */ alignElements: () => (/* reexport safe */ _align__WEBPACK_IMPORTED_MODULE_3__.alignElements),\n/* harmony export */ avoidRectangularCorner: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.avoidRectangularCorner),\n/* harmony export */ bindElementsToFramesAfterDuplication: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.bindElementsToFramesAfterDuplication),\n/* harmony export */ bindLinearElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindLinearElement),\n/* harmony export */ bindOrUnbindLinearElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindOrUnbindLinearElement),\n/* harmony export */ bindOrUnbindLinearElements: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindOrUnbindLinearElements),\n/* harmony export */ bindPointToSnapToElementOutline: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindPointToSnapToElementOutline),\n/* harmony export */ bindingBorderTest: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindingBorderTest),\n/* harmony export */ bindingProperties: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.bindingProperties),\n/* harmony export */ bumpVersion: () => (/* reexport safe */ _mutateElement__WEBPACK_IMPORTED_MODULE_25__.bumpVersion),\n/* harmony export */ calculateFixedPointForElbowArrowBinding: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.calculateFixedPointForElbowArrowBinding),\n/* harmony export */ canApplyRoundnessTypeToElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.canApplyRoundnessTypeToElement),\n/* harmony export */ canBecomePolygon: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.canBecomePolygon),\n/* harmony export */ canChangeRoundness: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.canChangeRoundness),\n/* harmony export */ canCreateLinkFromElements: () => (/* reexport safe */ _elementLink__WEBPACK_IMPORTED_MODULE_16__.canCreateLinkFromElements),\n/* harmony export */ canHaveArrowheads: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.canHaveArrowheads),\n/* harmony export */ canResizeFromSides: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.canResizeFromSides),\n/* harmony export */ charWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.charWidth),\n/* harmony export */ clearElementsForDatabase: () => (/* binding */ clearElementsForDatabase),\n/* harmony export */ clearElementsForExport: () => (/* binding */ clearElementsForExport),\n/* harmony export */ clearElementsForLocalStorage: () => (/* binding */ clearElementsForLocalStorage),\n/* harmony export */ compareHeading: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.compareHeading),\n/* harmony export */ computeBoundTextPosition: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.computeBoundTextPosition),\n/* harmony export */ computeContainerDimensionForBoundText: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.computeContainerDimensionForBoundText),\n/* harmony export */ containsCJK: () => (/* reexport safe */ _textWrapping__WEBPACK_IMPORTED_MODULE_39__.containsCJK),\n/* harmony export */ createPlaceholderEmbeddableLabel: () => (/* reexport safe */ _embeddable__WEBPACK_IMPORTED_MODULE_17__.createPlaceholderEmbeddableLabel),\n/* harmony export */ createSrcDoc: () => (/* reexport safe */ _embeddable__WEBPACK_IMPORTED_MODULE_17__.createSrcDoc),\n/* harmony export */ cropElement: () => (/* reexport safe */ _cropElement__WEBPACK_IMPORTED_MODULE_9__.cropElement),\n/* harmony export */ deconstructDiamondElement: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_41__.deconstructDiamondElement),\n/* harmony export */ deconstructLinearOrFreeDrawElement: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_41__.deconstructLinearOrFreeDrawElement),\n/* harmony export */ deconstructRectanguloidElement: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_41__.deconstructRectanguloidElement),\n/* harmony export */ deepCopyElement: () => (/* reexport safe */ _duplicate__WEBPACK_IMPORTED_MODULE_14__.deepCopyElement),\n/* harmony export */ defaultGetElementLinkFromSelection: () => (/* reexport safe */ _elementLink__WEBPACK_IMPORTED_MODULE_16__.defaultGetElementLinkFromSelection),\n/* harmony export */ detectLineHeight: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.detectLineHeight),\n/* harmony export */ determineFocusDistance: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.determineFocusDistance),\n/* harmony export */ distanceToElement: () => (/* reexport safe */ _distance__WEBPACK_IMPORTED_MODULE_11__.distanceToElement),\n/* harmony export */ distributeElements: () => (/* reexport safe */ _distribute__WEBPACK_IMPORTED_MODULE_12__.distributeElements),\n/* harmony export */ doBoundsIntersect: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.doBoundsIntersect),\n/* harmony export */ dragNewElement: () => (/* reexport safe */ _dragElements__WEBPACK_IMPORTED_MODULE_13__.dragNewElement),\n/* harmony export */ dragSelectedElements: () => (/* reexport safe */ _dragElements__WEBPACK_IMPORTED_MODULE_13__.dragSelectedElements),\n/* harmony export */ duplicateElement: () => (/* reexport safe */ _duplicate__WEBPACK_IMPORTED_MODULE_14__.duplicateElement),\n/* harmony export */ duplicateElements: () => (/* reexport safe */ _duplicate__WEBPACK_IMPORTED_MODULE_14__.duplicateElements),\n/* harmony export */ editGroupForSelectedElement: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.editGroupForSelectedElement),\n/* harmony export */ elementCenterPoint: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.elementCenterPoint),\n/* harmony export */ elementOverlapsWithFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.elementOverlapsWithFrame),\n/* harmony export */ elementWithCanvasCache: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.elementWithCanvasCache),\n/* harmony export */ elementsAreInFrameBounds: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.elementsAreInFrameBounds),\n/* harmony export */ elementsAreInSameGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.elementsAreInSameGroup),\n/* harmony export */ embeddableURLValidator: () => (/* reexport safe */ _embeddable__WEBPACK_IMPORTED_MODULE_17__.embeddableURLValidator),\n/* harmony export */ excludeElementsInFramesFromSelection: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.excludeElementsInFramesFromSelection),\n/* harmony export */ filterElementsEligibleAsFrameChildren: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.filterElementsEligibleAsFrameChildren),\n/* harmony export */ fixBindingsAfterDeletion: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.fixBindingsAfterDeletion),\n/* harmony export */ fixDuplicatedBindingsAfterDuplication: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.fixDuplicatedBindingsAfterDuplication),\n/* harmony export */ flipHeading: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.flipHeading),\n/* harmony export */ frameAndChildrenSelectedTogether: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.frameAndChildrenSelectedTogether),\n/* harmony export */ generateFreeDrawShape: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.generateFreeDrawShape),\n/* harmony export */ generateLinearCollisionShape: () => (/* reexport safe */ _shape__WEBPACK_IMPORTED_MODULE_33__.generateLinearCollisionShape),\n/* harmony export */ generateRoughOptions: () => (/* reexport safe */ _shape__WEBPACK_IMPORTED_MODULE_33__.generateRoughOptions),\n/* harmony export */ getApproxMinLineHeight: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getApproxMinLineHeight),\n/* harmony export */ getApproxMinLineWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getApproxMinLineWidth),\n/* harmony export */ getArrowLocalFixedPoints: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getArrowLocalFixedPoints),\n/* harmony export */ getArrowheadAngle: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getArrowheadAngle),\n/* harmony export */ getArrowheadPoints: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getArrowheadPoints),\n/* harmony export */ getArrowheadSize: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getArrowheadSize),\n/* harmony export */ getBoundTextElement: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getBoundTextElement),\n/* harmony export */ getBoundTextElementId: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getBoundTextElementId),\n/* harmony export */ getBoundTextElementPosition: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getBoundTextElementPosition),\n/* harmony export */ getBoundTextMaxHeight: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getBoundTextMaxHeight),\n/* harmony export */ getBoundTextMaxWidth: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getBoundTextMaxWidth),\n/* harmony export */ getBoundsFromPoints: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getBoundsFromPoints),\n/* harmony export */ getCenterForBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getCenterForBounds),\n/* harmony export */ getClosestElementBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getClosestElementBounds),\n/* harmony export */ getCommonBoundingBox: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getCommonBoundingBox),\n/* harmony export */ getCommonBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getCommonBounds),\n/* harmony export */ getContainerCenter: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getContainerCenter),\n/* harmony export */ getContainerCoords: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getContainerCoords),\n/* harmony export */ getContainerElement: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getContainerElement),\n/* harmony export */ getContainingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getContainingFrame),\n/* harmony export */ getCornerRadius: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_41__.getCornerRadius),\n/* harmony export */ getCubicBezierCurveBound: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getCubicBezierCurveBound),\n/* harmony export */ getCursorForResizingElement: () => (/* reexport safe */ _resizeTest__WEBPACK_IMPORTED_MODULE_30__.getCursorForResizingElement),\n/* harmony export */ getDefaultFrameName: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getDefaultFrameName),\n/* harmony export */ getDefaultRoundnessTypeForElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.getDefaultRoundnessTypeForElement),\n/* harmony export */ getDiamondPoints: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getDiamondPoints),\n/* harmony export */ getDragOffsetXY: () => (/* reexport safe */ _dragElements__WEBPACK_IMPORTED_MODULE_13__.getDragOffsetXY),\n/* harmony export */ getDraggedElementsBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getDraggedElementsBounds),\n/* harmony export */ getElementAbsoluteCoords: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getElementAbsoluteCoords),\n/* harmony export */ getElementBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getElementBounds),\n/* harmony export */ getElementLineSegments: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getElementLineSegments),\n/* harmony export */ getElementPointsCoords: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getElementPointsCoords),\n/* harmony export */ getElementShape: () => (/* reexport safe */ _shape__WEBPACK_IMPORTED_MODULE_33__.getElementShape),\n/* harmony export */ getElementWithTransformHandleType: () => (/* reexport safe */ _resizeTest__WEBPACK_IMPORTED_MODULE_30__.getElementWithTransformHandleType),\n/* harmony export */ getElementsCompletelyInFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getElementsCompletelyInFrame),\n/* harmony export */ getElementsInGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getElementsInGroup),\n/* harmony export */ getElementsInNewFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getElementsInNewFrame),\n/* harmony export */ getElementsInResizingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getElementsInResizingFrame),\n/* harmony export */ getElementsIntersectingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getElementsIntersectingFrame),\n/* harmony export */ getElementsOverlappingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getElementsOverlappingFrame),\n/* harmony export */ getElementsWithinSelection: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.getElementsWithinSelection),\n/* harmony export */ getEmbedLink: () => (/* reexport safe */ _embeddable__WEBPACK_IMPORTED_MODULE_17__.getEmbedLink),\n/* harmony export */ getFlipAdjustedCropPosition: () => (/* reexport safe */ _cropElement__WEBPACK_IMPORTED_MODULE_9__.getFlipAdjustedCropPosition),\n/* harmony export */ getFrameChildren: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getFrameChildren),\n/* harmony export */ getFrameLikeElements: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getFrameLikeElements),\n/* harmony export */ getFrameLikeTitle: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getFrameLikeTitle),\n/* harmony export */ getFreeDrawPath2D: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.getFreeDrawPath2D),\n/* harmony export */ getFreeDrawSvgPath: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.getFreeDrawSvgPath),\n/* harmony export */ getFreedrawOutlineAsSegments: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.getFreedrawOutlineAsSegments),\n/* harmony export */ getFreedrawOutlinePoints: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.getFreedrawOutlinePoints),\n/* harmony export */ getGlobalFixedPointForBindableElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getGlobalFixedPointForBindableElement),\n/* harmony export */ getGlobalFixedPoints: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getGlobalFixedPoints),\n/* harmony export */ getHeadingForElbowArrowSnap: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getHeadingForElbowArrowSnap),\n/* harmony export */ getHoveredElementForBinding: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getHoveredElementForBinding),\n/* harmony export */ getInitializedImageElements: () => (/* reexport safe */ _image__WEBPACK_IMPORTED_MODULE_23__.getInitializedImageElements),\n/* harmony export */ getLineHeightInPx: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getLineHeightInPx),\n/* harmony export */ getLineWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getLineWidth),\n/* harmony export */ getLinearElementSubType: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.getLinearElementSubType),\n/* harmony export */ getLinkDirectionFromKey: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.getLinkDirectionFromKey),\n/* harmony export */ getLinkIdAndTypeFromSelection: () => (/* reexport safe */ _elementLink__WEBPACK_IMPORTED_MODULE_16__.getLinkIdAndTypeFromSelection),\n/* harmony export */ getLockedLinearCursorAlignSize: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.getLockedLinearCursorAlignSize),\n/* harmony export */ getMaxCharWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getMaxCharWidth),\n/* harmony export */ getMaximumGroups: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getMaximumGroups),\n/* harmony export */ getMinCharWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getMinCharWidth),\n/* harmony export */ getMinMaxXYFromCurvePathOps: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getMinMaxXYFromCurvePathOps),\n/* harmony export */ getMinTextElementWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getMinTextElementWidth),\n/* harmony export */ getNewGroupIdsForDuplication: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getNewGroupIdsForDuplication),\n/* harmony export */ getNextSingleWidthAndHeightFromPointer: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.getNextSingleWidthAndHeightFromPointer),\n/* harmony export */ getNonDeletedElements: () => (/* binding */ getNonDeletedElements),\n/* harmony export */ getNonDeletedGroupIds: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getNonDeletedGroupIds),\n/* harmony export */ getNormalizedDimensions: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.getNormalizedDimensions),\n/* harmony export */ getObservedAppState: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_36__.getObservedAppState),\n/* harmony export */ getOmitSidesForDevice: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.getOmitSidesForDevice),\n/* harmony export */ getOriginalContainerHeightFromCache: () => (/* reexport safe */ _containerCache__WEBPACK_IMPORTED_MODULE_8__.getOriginalContainerHeightFromCache),\n/* harmony export */ getPerfectElementSize: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.getPerfectElementSize),\n/* harmony export */ getPredecessors: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.getPredecessors),\n/* harmony export */ getRectangleBoxAbsoluteCoords: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getRectangleBoxAbsoluteCoords),\n/* harmony export */ getRenderOpacity: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.getRenderOpacity),\n/* harmony export */ getResizeArrowDirection: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.getResizeArrowDirection),\n/* harmony export */ getResizeOffsetXY: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.getResizeOffsetXY),\n/* harmony export */ getResizedElementAbsoluteCoords: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getResizedElementAbsoluteCoords),\n/* harmony export */ getRootElements: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getRootElements),\n/* harmony export */ getSceneVersion: () => (/* binding */ getSceneVersion),\n/* harmony export */ getSelectedElements: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.getSelectedElements),\n/* harmony export */ getSelectedElementsByGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getSelectedElementsByGroup),\n/* harmony export */ getSelectedGroupForElement: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getSelectedGroupForElement),\n/* harmony export */ getSelectedGroupIdForElement: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getSelectedGroupIdForElement),\n/* harmony export */ getSelectedGroupIds: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.getSelectedGroupIds),\n/* harmony export */ getSelectionStateForElements: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.getSelectionStateForElements),\n/* harmony export */ getSuggestedBindingsForArrows: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.getSuggestedBindingsForArrows),\n/* harmony export */ getTargetElements: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.getTargetElements),\n/* harmony export */ getTargetFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.getTargetFrame),\n/* harmony export */ getTextElementAngle: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getTextElementAngle),\n/* harmony export */ getTextFromElements: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.getTextFromElements),\n/* harmony export */ getTextHeight: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getTextHeight),\n/* harmony export */ getTextWidth: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.getTextWidth),\n/* harmony export */ getTransformHandleTypeFromCoords: () => (/* reexport safe */ _resizeTest__WEBPACK_IMPORTED_MODULE_30__.getTransformHandleTypeFromCoords),\n/* harmony export */ getTransformHandles: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.getTransformHandles),\n/* harmony export */ getTransformHandlesFromCoords: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.getTransformHandlesFromCoords),\n/* harmony export */ getUncroppedImageElement: () => (/* reexport safe */ _cropElement__WEBPACK_IMPORTED_MODULE_9__.getUncroppedImageElement),\n/* harmony export */ getUncroppedWidthAndHeight: () => (/* reexport safe */ _cropElement__WEBPACK_IMPORTED_MODULE_9__.getUncroppedWidthAndHeight),\n/* harmony export */ getVisibleAndNonSelectedElements: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.getVisibleAndNonSelectedElements),\n/* harmony export */ getVisibleElements: () => (/* binding */ getVisibleElements),\n/* harmony export */ getVisibleSceneBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.getVisibleSceneBounds),\n/* harmony export */ groupByFrameLikes: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.groupByFrameLikes),\n/* harmony export */ groupsAreAtLeastIntersectingTheFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.groupsAreAtLeastIntersectingTheFrame),\n/* harmony export */ groupsAreCompletelyOutOfFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.groupsAreCompletelyOutOfFrame),\n/* harmony export */ handleBindTextResize: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.handleBindTextResize),\n/* harmony export */ hasBackground: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.hasBackground),\n/* harmony export */ hasBoundTextElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.hasBoundTextElement),\n/* harmony export */ hasStrokeColor: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.hasStrokeColor),\n/* harmony export */ hasStrokeStyle: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.hasStrokeStyle),\n/* harmony export */ hasStrokeWidth: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.hasStrokeWidth),\n/* harmony export */ hashElementsVersion: () => (/* binding */ hashElementsVersion),\n/* harmony export */ hashString: () => (/* binding */ hashString),\n/* harmony export */ headingForPoint: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.headingForPoint),\n/* harmony export */ headingForPointFromElement: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.headingForPointFromElement),\n/* harmony export */ headingForPointIsHorizontal: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.headingForPointIsHorizontal),\n/* harmony export */ headingIsHorizontal: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.headingIsHorizontal),\n/* harmony export */ headingIsVertical: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.headingIsVertical),\n/* harmony export */ hitElementBoundText: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.hitElementBoundText),\n/* harmony export */ hitElementBoundingBox: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.hitElementBoundingBox),\n/* harmony export */ hitElementBoundingBoxOnly: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.hitElementBoundingBoxOnly),\n/* harmony export */ hitElementItself: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.hitElementItself),\n/* harmony export */ intersectElementWithLineSegment: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.intersectElementWithLineSegment),\n/* harmony export */ isArrowBoundToElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isArrowBoundToElement),\n/* harmony export */ isArrowElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isArrowElement),\n/* harmony export */ isBindableElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isBindableElement),\n/* harmony export */ isBindingElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isBindingElement),\n/* harmony export */ isBindingElementType: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isBindingElementType),\n/* harmony export */ isBindingEnabled: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.isBindingEnabled),\n/* harmony export */ isBoundToContainer: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isBoundToContainer),\n/* harmony export */ isBounds: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isBounds),\n/* harmony export */ isCursorInFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.isCursorInFrame),\n/* harmony export */ isCurvedArrow: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isCurvedArrow),\n/* harmony export */ isElbowArrow: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isElbowArrow),\n/* harmony export */ isElementCompletelyInViewport: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.isElementCompletelyInViewport),\n/* harmony export */ isElementContainingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.isElementContainingFrame),\n/* harmony export */ isElementInFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.isElementInFrame),\n/* harmony export */ isElementInGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.isElementInGroup),\n/* harmony export */ isElementInViewport: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.isElementInViewport),\n/* harmony export */ isElementIntersectingFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.isElementIntersectingFrame),\n/* harmony export */ isElementLink: () => (/* reexport safe */ _elementLink__WEBPACK_IMPORTED_MODULE_16__.isElementLink),\n/* harmony export */ isEmbeddableElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isEmbeddableElement),\n/* harmony export */ isExcalidrawElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isExcalidrawElement),\n/* harmony export */ isFixedPointBinding: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFixedPointBinding),\n/* harmony export */ isFlowchartNodeElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFlowchartNodeElement),\n/* harmony export */ isFrameElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFrameElement),\n/* harmony export */ isFrameLikeElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFrameLikeElement),\n/* harmony export */ isFreeDrawElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFreeDrawElement),\n/* harmony export */ isFreeDrawElementType: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isFreeDrawElementType),\n/* harmony export */ isHTMLSVGElement: () => (/* reexport safe */ _image__WEBPACK_IMPORTED_MODULE_23__.isHTMLSVGElement),\n/* harmony export */ isIframeElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isIframeElement),\n/* harmony export */ isIframeLikeElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isIframeLikeElement),\n/* harmony export */ isImageElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isImageElement),\n/* harmony export */ isInGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.isInGroup),\n/* harmony export */ isInitializedImageElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isInitializedImageElement),\n/* harmony export */ isInvisiblySmallElement: () => (/* reexport safe */ _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.isInvisiblySmallElement),\n/* harmony export */ isLineElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isLineElement),\n/* harmony export */ isLinearElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isLinearElement),\n/* harmony export */ isLinearElementSimpleAndAlreadyBound: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.isLinearElementSimpleAndAlreadyBound),\n/* harmony export */ isLinearElementType: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isLinearElementType),\n/* harmony export */ isMagicFrameElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isMagicFrameElement),\n/* harmony export */ isMeasureTextSupported: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.isMeasureTextSupported),\n/* harmony export */ isNodeInFlowchart: () => (/* reexport safe */ _flowchart__WEBPACK_IMPORTED_MODULE_18__.isNodeInFlowchart),\n/* harmony export */ isNonDeletedElement: () => (/* binding */ isNonDeletedElement),\n/* harmony export */ isPathALoop: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_41__.isPathALoop),\n/* harmony export */ isPointInElement: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.isPointInElement),\n/* harmony export */ isRectangularElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isRectangularElement),\n/* harmony export */ isRectanguloidElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isRectanguloidElement),\n/* harmony export */ isSelectedViaGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.isSelectedViaGroup),\n/* harmony export */ isSharpArrow: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isSharpArrow),\n/* harmony export */ isSimpleArrow: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isSimpleArrow),\n/* harmony export */ isSomeElementSelected: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.isSomeElementSelected),\n/* harmony export */ isTextBindableContainer: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isTextBindableContainer),\n/* harmony export */ isTextElement: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isTextElement),\n/* harmony export */ isUsingAdaptiveRadius: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isUsingAdaptiveRadius),\n/* harmony export */ isUsingProportionalRadius: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isUsingProportionalRadius),\n/* harmony export */ isValidPolygon: () => (/* reexport safe */ _typeChecks__WEBPACK_IMPORTED_MODULE_2__.isValidPolygon),\n/* harmony export */ isValidTextContainer: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.isValidTextContainer),\n/* harmony export */ loadHTMLImageElement: () => (/* reexport safe */ _image__WEBPACK_IMPORTED_MODULE_23__.loadHTMLImageElement),\n/* harmony export */ makeNextSelectedElementIds: () => (/* reexport safe */ _selection__WEBPACK_IMPORTED_MODULE_32__.makeNextSelectedElementIds),\n/* harmony export */ maxBindingGap: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.maxBindingGap),\n/* harmony export */ maybeBindLinearElement: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.maybeBindLinearElement),\n/* harmony export */ maybeParseEmbedSrc: () => (/* reexport safe */ _embeddable__WEBPACK_IMPORTED_MODULE_17__.maybeParseEmbedSrc),\n/* harmony export */ maybeSuggestBindingsForLinearElementAtCoords: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.maybeSuggestBindingsForLinearElementAtCoords),\n/* harmony export */ measureFontSizeFromWidth: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.measureFontSizeFromWidth),\n/* harmony export */ measureText: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.measureText),\n/* harmony export */ moveAllLeft: () => (/* reexport safe */ _zindex__WEBPACK_IMPORTED_MODULE_42__.moveAllLeft),\n/* harmony export */ moveAllRight: () => (/* reexport safe */ _zindex__WEBPACK_IMPORTED_MODULE_42__.moveAllRight),\n/* harmony export */ moveOneLeft: () => (/* reexport safe */ _zindex__WEBPACK_IMPORTED_MODULE_42__.moveOneLeft),\n/* harmony export */ moveOneRight: () => (/* reexport safe */ _zindex__WEBPACK_IMPORTED_MODULE_42__.moveOneRight),\n/* harmony export */ mutateElement: () => (/* reexport safe */ _mutateElement__WEBPACK_IMPORTED_MODULE_25__.mutateElement),\n/* harmony export */ newArrowElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newArrowElement),\n/* harmony export */ newElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newElement),\n/* harmony export */ newElementWith: () => (/* reexport safe */ _mutateElement__WEBPACK_IMPORTED_MODULE_25__.newElementWith),\n/* harmony export */ newEmbeddableElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newEmbeddableElement),\n/* harmony export */ newFrameElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newFrameElement),\n/* harmony export */ newFreeDrawElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newFreeDrawElement),\n/* harmony export */ newIframeElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newIframeElement),\n/* harmony export */ newImageElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newImageElement),\n/* harmony export */ newLinearElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newLinearElement),\n/* harmony export */ newMagicFrameElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newMagicFrameElement),\n/* harmony export */ newTextElement: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.newTextElement),\n/* harmony export */ normalizeElementOrder: () => (/* reexport safe */ _sortElements__WEBPACK_IMPORTED_MODULE_35__.normalizeElementOrder),\n/* harmony export */ normalizeFixedPoint: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.normalizeFixedPoint),\n/* harmony export */ normalizeSVG: () => (/* reexport safe */ _image__WEBPACK_IMPORTED_MODULE_23__.normalizeSVG),\n/* harmony export */ normalizeText: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.normalizeText),\n/* harmony export */ omitGroupsContainingFrameLikes: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.omitGroupsContainingFrameLikes),\n/* harmony export */ omitPartialGroups: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.omitPartialGroups),\n/* harmony export */ orderByFractionalIndex: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.orderByFractionalIndex),\n/* harmony export */ originalContainerCache: () => (/* reexport safe */ _containerCache__WEBPACK_IMPORTED_MODULE_8__.originalContainerCache),\n/* harmony export */ parseElementLinkFromURL: () => (/* reexport safe */ _elementLink__WEBPACK_IMPORTED_MODULE_16__.parseElementLinkFromURL),\n/* harmony export */ parseTokens: () => (/* reexport safe */ _textWrapping__WEBPACK_IMPORTED_MODULE_39__.parseTokens),\n/* harmony export */ pathsCache: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.pathsCache),\n/* harmony export */ pointInsideBounds: () => (/* reexport safe */ _bounds__WEBPACK_IMPORTED_MODULE_5__.pointInsideBounds),\n/* harmony export */ positionElementsOnGrid: () => (/* reexport safe */ _positionElementsOnGrid__WEBPACK_IMPORTED_MODULE_27__.positionElementsOnGrid),\n/* harmony export */ redrawTextBoundingBox: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.redrawTextBoundingBox),\n/* harmony export */ refreshTextDimensions: () => (/* reexport safe */ _newElement__WEBPACK_IMPORTED_MODULE_26__.refreshTextDimensions),\n/* harmony export */ removeAllElementsFromFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.removeAllElementsFromFrame),\n/* harmony export */ removeElementsFromFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.removeElementsFromFrame),\n/* harmony export */ removeFromSelectedGroups: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.removeFromSelectedGroups),\n/* harmony export */ renderElement: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.renderElement),\n/* harmony export */ renderSelectionElement: () => (/* reexport safe */ _renderElement__WEBPACK_IMPORTED_MODULE_28__.renderSelectionElement),\n/* harmony export */ replaceAllElementsInFrame: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.replaceAllElementsInFrame),\n/* harmony export */ rescalePointsInElement: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.rescalePointsInElement),\n/* harmony export */ resetOriginalContainerCache: () => (/* reexport safe */ _containerCache__WEBPACK_IMPORTED_MODULE_8__.resetOriginalContainerCache),\n/* harmony export */ resizeMultipleElements: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.resizeMultipleElements),\n/* harmony export */ resizeSingleElement: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.resizeSingleElement),\n/* harmony export */ resizeSingleTextElement: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.resizeSingleTextElement),\n/* harmony export */ resizeTest: () => (/* reexport safe */ _resizeTest__WEBPACK_IMPORTED_MODULE_30__.resizeTest),\n/* harmony export */ selectGroup: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.selectGroup),\n/* harmony export */ selectGroupsForSelectedElements: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.selectGroupsForSelectedElements),\n/* harmony export */ selectGroupsFromGivenElements: () => (/* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_21__.selectGroupsFromGivenElements),\n/* harmony export */ setCustomTextMetricsProvider: () => (/* reexport safe */ _textMeasurements__WEBPACK_IMPORTED_MODULE_38__.setCustomTextMetricsProvider),\n/* harmony export */ shouldAllowVerticalAlign: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.shouldAllowVerticalAlign),\n/* harmony export */ shouldApplyFrameClip: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.shouldApplyFrameClip),\n/* harmony export */ shouldEnableBindingForPointerEvent: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.shouldEnableBindingForPointerEvent),\n/* harmony export */ shouldShowBoundingBox: () => (/* reexport safe */ _transformHandles__WEBPACK_IMPORTED_MODULE_40__.shouldShowBoundingBox),\n/* harmony export */ shouldTestInside: () => (/* reexport safe */ _collision__WEBPACK_IMPORTED_MODULE_6__.shouldTestInside),\n/* harmony export */ showSelectedShapeActions: () => (/* reexport safe */ _showSelectedShapeActions__WEBPACK_IMPORTED_MODULE_34__.showSelectedShapeActions),\n/* harmony export */ snapToMid: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.snapToMid),\n/* harmony export */ suppportsHorizontalAlign: () => (/* reexport safe */ _textElement__WEBPACK_IMPORTED_MODULE_37__.suppportsHorizontalAlign),\n/* harmony export */ syncInvalidIndices: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.syncInvalidIndices),\n/* harmony export */ syncInvalidIndicesImmutable: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.syncInvalidIndicesImmutable),\n/* harmony export */ syncMovedIndices: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.syncMovedIndices),\n/* harmony export */ toggleLinePolygonState: () => (/* reexport safe */ _shape__WEBPACK_IMPORTED_MODULE_33__.toggleLinePolygonState),\n/* harmony export */ toolIsArrow: () => (/* reexport safe */ _comparisons__WEBPACK_IMPORTED_MODULE_7__.toolIsArrow),\n/* harmony export */ transformElements: () => (/* reexport safe */ _resizeElements__WEBPACK_IMPORTED_MODULE_29__.transformElements),\n/* harmony export */ updateBindings: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.updateBindings),\n/* harmony export */ updateBoundElements: () => (/* reexport safe */ _binding__WEBPACK_IMPORTED_MODULE_4__.updateBoundElements),\n/* harmony export */ updateElbowArrowPoints: () => (/* reexport safe */ _elbowArrow__WEBPACK_IMPORTED_MODULE_15__.updateElbowArrowPoints),\n/* harmony export */ updateFrameMembershipOfSelectedElements: () => (/* reexport safe */ _frame__WEBPACK_IMPORTED_MODULE_20__.updateFrameMembershipOfSelectedElements),\n/* harmony export */ updateImageCache: () => (/* reexport safe */ _image__WEBPACK_IMPORTED_MODULE_23__.updateImageCache),\n/* harmony export */ updateOriginalContainerCache: () => (/* reexport safe */ _containerCache__WEBPACK_IMPORTED_MODULE_8__.updateOriginalContainerCache),\n/* harmony export */ validateElbowPoints: () => (/* reexport safe */ _elbowArrow__WEBPACK_IMPORTED_MODULE_15__.validateElbowPoints),\n/* harmony export */ validateFractionalIndices: () => (/* reexport safe */ _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__.validateFractionalIndices),\n/* harmony export */ vectorToHeading: () => (/* reexport safe */ _heading__WEBPACK_IMPORTED_MODULE_22__.vectorToHeading),\n/* harmony export */ wrapText: () => (/* reexport safe */ _textWrapping__WEBPACK_IMPORTED_MODULE_39__.wrapText)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _sizeHelpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sizeHelpers */ \"../element/src/sizeHelpers.ts\");\n/* harmony import */ var _typeChecks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./typeChecks */ \"../element/src/typeChecks.ts\");\n/* harmony import */ var _align__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./align */ \"../element/src/align.ts\");\n/* harmony import */ var _binding__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./binding */ \"../element/src/binding.ts\");\n/* harmony import */ var _bounds__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./bounds */ \"../element/src/bounds.ts\");\n/* harmony import */ var _collision__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./collision */ \"../element/src/collision.ts\");\n/* harmony import */ var _comparisons__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./comparisons */ \"../element/src/comparisons.ts\");\n/* harmony import */ var _containerCache__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./containerCache */ \"../element/src/containerCache.ts\");\n/* harmony import */ var _cropElement__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./cropElement */ \"../element/src/cropElement.ts\");\n/* harmony import */ var _delta__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./delta */ \"../element/src/delta.ts\");\n/* harmony import */ var _distance__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./distance */ \"../element/src/distance.ts\");\n/* harmony import */ var _distribute__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./distribute */ \"../element/src/distribute.ts\");\n/* harmony import */ var _dragElements__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./dragElements */ \"../element/src/dragElements.ts\");\n/* harmony import */ var _duplicate__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./duplicate */ \"../element/src/duplicate.ts\");\n/* harmony import */ var _elbowArrow__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./elbowArrow */ \"../element/src/elbowArrow.ts\");\n/* harmony import */ var _elementLink__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./elementLink */ \"../element/src/elementLink.ts\");\n/* harmony import */ var _embeddable__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./embeddable */ \"../element/src/embeddable.ts\");\n/* harmony import */ var _flowchart__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./flowchart */ \"../element/src/flowchart.ts\");\n/* harmony import */ var _fractionalIndex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./fractionalIndex */ \"../element/src/fractionalIndex.ts\");\n/* harmony import */ var _frame__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./frame */ \"../element/src/frame.ts\");\n/* harmony import */ var _groups__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./groups */ \"../element/src/groups.ts\");\n/* harmony import */ var _heading__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./heading */ \"../element/src/heading.ts\");\n/* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./image */ \"../element/src/image.ts\");\n/* harmony import */ var _linearElementEditor__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./linearElementEditor */ \"../element/src/linearElementEditor.ts\");\n/* harmony import */ var _mutateElement__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./mutateElement */ \"../element/src/mutateElement.ts\");\n/* harmony import */ var _newElement__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./newElement */ \"../element/src/newElement.ts\");\n/* harmony import */ var _positionElementsOnGrid__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./positionElementsOnGrid */ \"../element/src/positionElementsOnGrid.ts\");\n/* harmony import */ var _renderElement__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./renderElement */ \"../element/src/renderElement.ts\");\n/* harmony import */ var _resizeElements__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./resizeElements */ \"../element/src/resizeElements.ts\");\n/* harmony import */ var _resizeTest__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./resizeTest */ \"../element/src/resizeTest.ts\");\n/* harmony import */ var _Scene__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Scene */ \"../element/src/Scene.ts\");\n/* harmony import */ var _selection__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./selection */ \"../element/src/selection.ts\");\n/* harmony import */ var _shape__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./shape */ \"../element/src/shape.ts\");\n/* harmony import */ var _showSelectedShapeActions__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./showSelectedShapeActions */ \"../element/src/showSelectedShapeActions.ts\");\n/* harmony import */ var _sortElements__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./sortElements */ \"../element/src/sortElements.ts\");\n/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./store */ \"../element/src/store.ts\");\n/* harmony import */ var _textElement__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./textElement */ \"../element/src/textElement.ts\");\n/* harmony import */ var _textMeasurements__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./textMeasurements */ \"../element/src/textMeasurements.ts\");\n/* harmony import */ var _textWrapping__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./textWrapping */ \"../element/src/textWrapping.ts\");\n/* harmony import */ var _transformHandles__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./transformHandles */ \"../element/src/transformHandles.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./utils */ \"../element/src/utils.ts\");\n/* harmony import */ var _zindex__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./zindex */ \"../element/src/zindex.ts\");\n\n\n\n/**\r\n * @deprecated unsafe, use hashElementsVersion instead\r\n */\n\nconst getSceneVersion = elements => elements.reduce((acc, el) => acc + el.version, 0);\n/**\r\n * Hashes elements' versionNonce (using djb2 algo). Order of elements matters.\r\n */\n\nconst hashElementsVersion = elements => {\n let hash = 5381;\n\n for (const element of (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_0__.toIterable)(elements)) {\n hash = (hash << 5) + hash + element.versionNonce;\n }\n\n return hash >>> 0; // Ensure unsigned 32-bit integer\n}; // string hash function (using djb2). Not cryptographically secure, use only\n// for versioning and such.\n// note: hashes individual code units (not code points),\n// but for hashing purposes this is fine as it iterates through every code unit\n// (as such, no need to encode to byte string first)\n\nconst hashString = s => {\n let hash = 5381;\n\n for (let i = 0; i < s.length; i++) {\n const char = s.charCodeAt(i);\n hash = (hash << 5) + hash + char;\n }\n\n return hash >>> 0; // Ensure unsigned 32-bit integer\n};\nconst getVisibleElements = elements => elements.filter(el => !el.isDeleted && !(0,_sizeHelpers__WEBPACK_IMPORTED_MODULE_1__.isInvisiblySmallElement)(el));\nconst getNonDeletedElements = elements => elements.filter(element => !element.isDeleted);\nconst isNonDeletedElement = element => !element.isDeleted;\n\nconst _clearElements = elements => getNonDeletedElements(elements).map(element => (0,_typeChecks__WEBPACK_IMPORTED_MODULE_2__.isLinearElementType)(element.type) ? Object.assign(Object.assign({}, element), {\n lastCommittedPoint: null\n}) : element);\n\nconst clearElementsForDatabase = elements => _clearElements(elements);\nconst clearElementsForExport = elements => _clearElements(elements);\nconst clearElementsForLocalStorage = elements => _clearElements(elements);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//# sourceURL=webpack://ExcalidrawLib/../element/src/index.ts?");
13304
13304
 
13305
13305
  /***/ }),
13306
13306
 
@@ -13784,7 +13784,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
13784
13784
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
13785
13785
 
13786
13786
  "use strict";
13787
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ actionChangeViewBackgroundColor: () => (/* binding */ actionChangeViewBackgroundColor),\n/* harmony export */ actionClearCanvas: () => (/* binding */ actionClearCanvas),\n/* harmony export */ actionResetZoom: () => (/* binding */ actionResetZoom),\n/* harmony export */ actionToggleEraserTool: () => (/* binding */ actionToggleEraserTool),\n/* harmony export */ actionToggleHandTool: () => (/* binding */ actionToggleHandTool),\n/* harmony export */ actionToggleLaserPointer: () => (/* binding */ actionToggleLaserPointer),\n/* harmony export */ actionToggleLassoTool: () => (/* binding */ actionToggleLassoTool),\n/* harmony export */ actionToggleTheme: () => (/* binding */ actionToggleTheme),\n/* harmony export */ actionZoomIn: () => (/* binding */ actionZoomIn),\n/* harmony export */ actionZoomOut: () => (/* binding */ actionZoomOut),\n/* harmony export */ actionZoomToFit: () => (/* binding */ actionZoomToFit),\n/* harmony export */ actionZoomToFitSelection: () => (/* binding */ actionZoomToFitSelection),\n/* harmony export */ actionZoomToFitSelectionInViewport: () => (/* binding */ actionZoomToFitSelectionInViewport),\n/* harmony export */ zoomToFit: () => (/* binding */ zoomToFit),\n/* harmony export */ zoomToFitBounds: () => (/* binding */ zoomToFitBounds),\n/* harmony export */ zoomToFitElements: () => (/* binding */ zoomToFitElements)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _components_ColorPicker_ColorPicker__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../components/ColorPicker/ColorPicker */ \"./components/ColorPicker/ColorPicker.tsx\");\n/* harmony import */ var _components_ToolButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../components/ToolButton */ \"./components/ToolButton.tsx\");\n/* harmony import */ var _components_icons__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../components/icons */ \"./components/icons.tsx\");\n/* harmony import */ var _cursor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../cursor */ \"./cursor.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _scene_scroll__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../scene/scroll */ \"./scene/scroll.ts\");\n/* harmony import */ var _scene_zoom__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../scene/zoom */ \"./scene/zoom.ts\");\n/* harmony import */ var _register__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./register */ \"./actions/register.ts\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @excalidraw/element/selection */ \"../element/src/selection.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst actionChangeViewBackgroundColor = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"changeViewBackgroundColor\",\n label: \"labels.canvasBackground\",\n trackEvent: false,\n predicate: (elements, appState, props, app) => {\n return !!app.props.UIOptions.canvasActions.changeViewBackgroundColor && !appState.viewModeEnabled;\n },\n perform: (_, appState, value) => {\n return {\n appState: Object.assign(Object.assign({}, appState), value),\n captureUpdate: !!value.viewBackgroundColor ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.IMMEDIATELY : _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n },\n PanelComponent: ({\n elements,\n appState,\n updateData,\n appProps,\n data\n }) => {\n var _a, _b, _c, _d, _e; // FIXME move me to src/components/mainMenu/DefaultItems.tsx\n\n\n return React.createElement(_components_ColorPicker_ColorPicker__WEBPACK_IMPORTED_MODULE_4__.ColorPicker, {\n topPicks: //zsviczian\n (_c = (_b = (_a = appState.colorPalette) === null || _a === void 0 ? void 0 : _a.topPicks) === null || _b === void 0 ? void 0 : _b.canvasBackground) !== null && _c !== void 0 ? _c : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_CANVAS_BACKGROUND_PICKS,\n palette: //zsviczian\n (_e = (_d = appState.colorPalette) === null || _d === void 0 ? void 0 : _d.canvasBackground) !== null && _e !== void 0 ? _e : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE,\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.canvasBackground\"),\n type: \"canvasBackground\",\n color: appState.viewBackgroundColor,\n onChange: color => updateData({\n viewBackgroundColor: color\n }),\n \"data-testid\": \"canvas-background-picker\",\n elements: elements,\n appState: appState,\n updateData: updateData,\n compactMode: appState.stylesPanelMode === \"compact\"\n });\n }\n});\nconst actionClearCanvas = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"clearCanvas\",\n label: \"labels.clearCanvas\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.TrashIcon,\n trackEvent: {\n category: \"canvas\"\n },\n predicate: (elements, appState, props, app) => {\n var _a;\n\n return !!app.props.UIOptions.canvasActions.clearCanvas && !appState.viewModeEnabled && ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"elementLinkSelector\";\n },\n perform: (elements, appState, _, app) => {\n app.imageCache.clear();\n return {\n elements: elements.map(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.newElementWith)(element, {\n isDeleted: true\n })),\n appState: Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_3__.getDefaultAppState)()), {\n files: {},\n theme: appState.theme,\n penMode: appState.penMode,\n penDetected: appState.penDetected,\n exportBackground: appState.exportBackground,\n exportEmbedScene: appState.exportEmbedScene,\n gridSize: appState.gridSize,\n gridStep: appState.gridStep,\n gridModeEnabled: appState.gridModeEnabled,\n stats: appState.stats,\n pasteDialog: appState.pasteDialog,\n activeTool: appState.activeTool.type === \"image\" ? Object.assign(Object.assign({}, appState.activeTool), {\n type: app.defaultSelectionTool\n }) : appState.activeTool,\n colorPalette: appState.colorPalette,\n trayModeEnabled: appState.trayModeEnabled,\n allowPinchZoom: appState.allowPinchZoom,\n allowWheelZoom: appState.allowWheelZoom,\n pinnedScripts: appState.pinnedScripts,\n customPens: appState.customPens\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.IMMEDIATELY\n };\n }\n});\nconst actionZoomIn = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"zoomIn\",\n label: \"buttons.zoomIn\",\n viewMode: true,\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.ZoomInIcon,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (_elements, appState, _, app) => {\n return {\n appState: Object.assign(Object.assign(Object.assign({}, appState), (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_11__.getStateForZoom)({\n viewportX: appState.width / 2 + appState.offsetLeft,\n viewportY: appState.height / 2 + appState.offsetTop,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getNormalizedZoom)(appState.zoom.value + (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomStep)())\n }, appState)), {\n userToFollow: null\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n },\n PanelComponent: ({\n updateData,\n appState\n }) => React.createElement(_components_ToolButton__WEBPACK_IMPORTED_MODULE_5__.ToolButton, {\n type: \"button\",\n className: \"zoom-in-button zoom-button\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.ZoomInIcon,\n title: `${(0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.zoomIn\")} — ${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd++\")}`,\n \"aria-label\": (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.zoomIn\"),\n disabled: appState.zoom.value >= (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomMax)(),\n onClick: () => {\n updateData(null);\n }\n }),\n keyTest: event => (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.EQUAL || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.NUM_ADD) && (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] || event.shiftKey)\n});\nconst actionZoomOut = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"zoomOut\",\n label: \"buttons.zoomOut\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.ZoomOutIcon,\n viewMode: true,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (_elements, appState, _, app) => {\n return {\n appState: Object.assign(Object.assign(Object.assign({}, appState), (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_11__.getStateForZoom)({\n viewportX: appState.width / 2 + appState.offsetLeft,\n viewportY: appState.height / 2 + appState.offsetTop,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getNormalizedZoom)(appState.zoom.value - (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomStep)())\n }, appState)), {\n userToFollow: null\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n },\n PanelComponent: ({\n updateData,\n appState\n }) => React.createElement(_components_ToolButton__WEBPACK_IMPORTED_MODULE_5__.ToolButton, {\n type: \"button\",\n className: \"zoom-out-button zoom-button\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.ZoomOutIcon,\n title: `${(0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.zoomOut\")} — ${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+-\")}`,\n \"aria-label\": (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.zoomOut\"),\n disabled: appState.zoom.value <= (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomMin)(),\n onClick: () => {\n updateData(null);\n }\n }),\n keyTest: event => (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.MINUS || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.NUM_SUBTRACT) && (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] || event.shiftKey)\n});\nconst actionResetZoom = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"resetZoom\",\n label: \"buttons.resetZoom\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.ZoomResetIcon,\n viewMode: true,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (_elements, appState, _, app) => {\n return {\n appState: Object.assign(Object.assign(Object.assign({}, appState), (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_11__.getStateForZoom)({\n viewportX: appState.width / 2 + appState.offsetLeft,\n viewportY: appState.height / 2 + appState.offsetTop,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getNormalizedZoom)(1)\n }, appState)), {\n userToFollow: null\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n },\n PanelComponent: ({\n updateData,\n appState\n }) => // zsviczian <Tooltip label={t(\"buttons.resetZoom\")} style={{ display: \"none\" }}>\n React.createElement(_components_ToolButton__WEBPACK_IMPORTED_MODULE_5__.ToolButton, {\n type: \"button\",\n className: \"reset-zoom-button zoom-button\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.resetZoom\"),\n \"aria-label\": (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.resetZoom\"),\n onClick: () => {\n updateData(null);\n }\n }, (appState.zoom.value * 100).toFixed(0), \"%\") //</Tooltip>\n ,\n keyTest: event => (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.ZERO || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.NUM_ZERO) && (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] || event.shiftKey)\n});\n\nconst zoomValueToFitBoundsOnViewport = (bounds, viewportDimensions, viewportZoomFactor = 1, // default to 1 if not provided\nmaxZoom) => {\n if (typeof maxZoom === \"undefined\") {\n //zsviczian\n maxZoom = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getMaxZoom)();\n }\n\n const [x1, y1, x2, y2] = bounds;\n const commonBoundsWidth = x2 - x1;\n const zoomValueForWidth = viewportDimensions.width / commonBoundsWidth;\n const commonBoundsHeight = y2 - y1;\n const zoomValueForHeight = viewportDimensions.height / commonBoundsHeight;\n const smallestZoomValue = Math.min(zoomValueForWidth, zoomValueForHeight);\n const adjustedZoomValue = smallestZoomValue * (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)(viewportZoomFactor, 0.1, 1);\n return Math.min(adjustedZoomValue, maxZoom); //zsviczian\n};\n\nconst zoomToFitBounds = ({\n bounds,\n appState,\n canvasOffsets,\n fitToViewport = false,\n viewportZoomFactor = 1,\n minZoom = -Infinity,\n maxZoom = Infinity\n}) => {\n var _a, _b, _c, _d;\n\n viewportZoomFactor = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)(viewportZoomFactor, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomMin)(), (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomMax)());\n const [x1, y1, x2, y2] = bounds;\n const centerX = (x1 + x2) / 2;\n const centerY = (y1 + y2) / 2;\n const canvasOffsetLeft = (_a = canvasOffsets === null || canvasOffsets === void 0 ? void 0 : canvasOffsets.left) !== null && _a !== void 0 ? _a : 0;\n const canvasOffsetTop = (_b = canvasOffsets === null || canvasOffsets === void 0 ? void 0 : canvasOffsets.top) !== null && _b !== void 0 ? _b : 0;\n const canvasOffsetRight = (_c = canvasOffsets === null || canvasOffsets === void 0 ? void 0 : canvasOffsets.right) !== null && _c !== void 0 ? _c : 0;\n const canvasOffsetBottom = (_d = canvasOffsets === null || canvasOffsets === void 0 ? void 0 : canvasOffsets.bottom) !== null && _d !== void 0 ? _d : 0;\n const effectiveCanvasWidth = appState.width - canvasOffsetLeft - canvasOffsetRight;\n const effectiveCanvasHeight = appState.height - canvasOffsetTop - canvasOffsetBottom;\n let adjustedZoomValue;\n\n if (fitToViewport) {\n const commonBoundsWidth = x2 - x1;\n const commonBoundsHeight = y2 - y1;\n adjustedZoomValue = Math.min(effectiveCanvasWidth / commonBoundsWidth, effectiveCanvasHeight / commonBoundsHeight) * viewportZoomFactor;\n } else {\n adjustedZoomValue = zoomValueToFitBoundsOnViewport(bounds, {\n width: effectiveCanvasWidth,\n height: effectiveCanvasHeight\n }, viewportZoomFactor);\n }\n\n const newZoomValue = (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getNormalizedZoom)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.roundToStep)(adjustedZoomValue, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomStep)(), \"floor\"), minZoom, maxZoom));\n const centerScroll = (0,_scene_scroll__WEBPACK_IMPORTED_MODULE_10__.centerScrollOn)({\n scenePoint: {\n x: centerX,\n y: centerY\n },\n viewportDimensions: {\n width: appState.width,\n height: appState.height\n },\n offsets: canvasOffsets,\n zoom: {\n value: newZoomValue\n }\n });\n return {\n appState: Object.assign(Object.assign({}, appState), {\n scrollX: centerScroll.scrollX,\n scrollY: centerScroll.scrollY,\n zoom: {\n value: newZoomValue\n }\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n};\nconst zoomToFit = ({\n canvasOffsets,\n targetElements,\n appState,\n fitToViewport,\n viewportZoomFactor,\n minZoom,\n maxZoom\n}) => {\n const commonBounds = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getNonDeletedElements)(targetElements));\n return zoomToFitBounds({\n canvasOffsets,\n bounds: commonBounds,\n appState,\n fitToViewport,\n viewportZoomFactor,\n minZoom,\n maxZoom\n });\n}; // Note, this action differs from actionZoomToFitSelection in that it doesn't\n// zoom beyond 100%. In other words, if the content is smaller than viewport\n// size, it won't be zoomed in.\n\nconst actionZoomToFitSelectionInViewport = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"zoomToFitSelectionInViewport\",\n label: \"labels.zoomToFitViewport\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.zoomAreaIcon,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (elements, appState, _, app) => {\n const selectedElements = app.scene.getSelectedElements(appState);\n return zoomToFit({\n targetElements: selectedElements.length ? selectedElements : elements,\n appState: Object.assign(Object.assign({}, appState), {\n userToFollow: null\n }),\n fitToViewport: false,\n canvasOffsets: app.getEditorUIOffsets()\n });\n },\n // NOTE shift-2 should have been assigned actionZoomToFitSelection.\n // TBD on how proceed\n keyTest: event => event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.TWO && event.shiftKey && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD]\n});\nconst actionZoomToFitSelection = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"zoomToFitSelection\",\n label: \"helpDialog.zoomToSelection\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.zoomAreaIcon,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (elements, appState, _, app) => {\n const selectedElements = app.scene.getSelectedElements(appState);\n return zoomToFit({\n targetElements: selectedElements.length ? selectedElements : elements,\n appState: Object.assign(Object.assign({}, appState), {\n userToFollow: null\n }),\n fitToViewport: true,\n canvasOffsets: app.getEditorUIOffsets()\n });\n },\n // NOTE this action should use shift-2 per figma, alas\n keyTest: event => event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.THREE && event.shiftKey && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD]\n});\nconst actionZoomToFit = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"zoomToFit\",\n label: \"helpDialog.zoomToFit\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.zoomAreaIcon,\n viewMode: true,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (elements, appState, _, app) => zoomToFit({\n targetElements: elements,\n appState: Object.assign(Object.assign({}, appState), {\n userToFollow: null\n }),\n fitToViewport: false,\n canvasOffsets: app.getEditorUIOffsets()\n }),\n keyTest: event => event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.ONE && event.shiftKey && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD]\n});\nconst actionToggleTheme = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"toggleTheme\",\n label: (_, appState) => {\n return appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK ? \"buttons.lightMode\" : \"buttons.darkMode\";\n },\n keywords: [\"toggle\", \"dark\", \"light\", \"mode\", \"theme\"],\n icon: appState => appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT ? _components_icons__WEBPACK_IMPORTED_MODULE_6__.MoonIcon : _components_icons__WEBPACK_IMPORTED_MODULE_6__.SunIcon,\n viewMode: true,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (_, appState, value, app) => {\n //zsviczian\n if (app.props.onThemeChange) {\n //zsviczian\n app.props.onThemeChange(value || (appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT));\n }\n\n return {\n appState: Object.assign(Object.assign({}, appState), {\n theme: value || (appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT)\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n },\n keyTest: event => event.altKey && event.shiftKey && event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.D,\n predicate: (elements, appState, props, app) => {\n return !!app.props.UIOptions.canvasActions.toggleTheme;\n }\n});\nconst actionToggleEraserTool = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"toggleEraserTool\",\n label: \"toolBar.eraser\",\n trackEvent: {\n category: \"toolbar\"\n },\n perform: (elements, appState, _, app) => {\n let activeTool;\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_3__.isEraserActive)(appState)) {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, Object.assign(Object.assign({}, appState.activeTool.lastActiveTool || {\n type: app.defaultSelectionTool\n }), {\n lastActiveToolBeforeEraser: null\n }));\n } else {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, {\n type: \"eraser\",\n lastActiveToolBeforeEraser: appState.activeTool\n });\n }\n\n return {\n appState: Object.assign(Object.assign({}, appState), {\n selectedElementIds: {},\n selectedGroupIds: {},\n activeEmbeddable: null,\n activeTool\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.IMMEDIATELY\n };\n },\n keyTest: event => event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.E\n});\nconst actionToggleLassoTool = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"toggleLassoTool\",\n label: \"toolBar.lasso\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.LassoIcon,\n trackEvent: {\n category: \"toolbar\"\n },\n predicate: (elements, appState, props, app) => {\n return app.defaultSelectionTool !== \"lasso\";\n },\n perform: (elements, appState, _, app) => {\n let activeTool;\n\n if (appState.activeTool.type !== \"lasso\") {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, {\n type: \"lasso\",\n fromSelection: false\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_7__.setCursor)(app.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CURSOR_TYPE.CROSSHAIR);\n } else {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, {\n type: \"selection\"\n });\n }\n\n return {\n appState: Object.assign(Object.assign({}, appState), {\n selectedElementIds: {},\n selectedGroupIds: {},\n activeEmbeddable: null,\n activeTool\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.NEVER\n };\n }\n});\nconst actionToggleHandTool = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"toggleHandTool\",\n label: \"toolBar.hand\",\n trackEvent: {\n category: \"toolbar\"\n },\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.handIcon,\n viewMode: false,\n perform: (elements, appState, _, app) => {\n let activeTool;\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_3__.isHandToolActive)(appState)) {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, Object.assign(Object.assign({}, appState.activeTool.lastActiveTool || {\n type: \"selection\"\n }), {\n lastActiveToolBeforeEraser: null\n }));\n } else {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, {\n type: \"hand\",\n lastActiveToolBeforeEraser: appState.activeTool\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_7__.setCursor)(app.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CURSOR_TYPE.GRAB);\n }\n\n return {\n appState: Object.assign(Object.assign({}, appState), {\n selectedElementIds: {},\n selectedGroupIds: {},\n activeEmbeddable: null,\n activeTool\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.IMMEDIATELY\n };\n },\n keyTest: event => !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.H\n});\nconst actionToggleLaserPointer = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n //zsviczian - did I really add this? Delta compared to excalidraw.com\n name: \"toggleLaserPointerTool\",\n viewMode: true,\n trackEvent: {\n category: \"menu\"\n },\n\n perform(elements, appState, _, app) {\n let activeTool;\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_3__.isLaserPointerActive)(appState)) {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, Object.assign(Object.assign({}, appState.activeTool.lastActiveTool || {\n type: appState.viewModeEnabled ? \"hand\" : \"selection\"\n }), {\n lastActiveToolBeforeEraser: null\n }));\n (0,_cursor__WEBPACK_IMPORTED_MODULE_7__.setCursor)(app.interactiveCanvas, appState.viewModeEnabled ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CURSOR_TYPE.GRAB : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CURSOR_TYPE.POINTER);\n } else {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, {\n type: \"laser\",\n lastActiveToolBeforeEraser: appState.activeTool\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_7__.setCursor)(app.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CURSOR_TYPE.CROSSHAIR);\n }\n\n return {\n appState: Object.assign(Object.assign({}, appState), {\n selectedElementIds: {},\n selectedGroupIds: {},\n activeEmbeddable: null,\n activeTool\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.NEVER\n };\n },\n\n checked: appState => appState.activeTool.type === \"laser\",\n label: \"labels.laser\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.laserPointerToolIcon\n}); //zsviczian\n\nconst zoomToFitElements = (elements, appState, zoomToSelection, app, //zsviczian\nmaxZoom, //zsviczian\nmargin = 0) => {\n if (typeof maxZoom === \"undefined\") {\n //zsviczian\n maxZoom = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getMaxZoom)();\n }\n\n const nonDeletedElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getNonDeletedElements)(elements);\n const selectedElements = app.scene.getSelectedElements(appState);\n const commonBounds = zoomToSelection && selectedElements.length > 0 ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)((0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_14__.excludeElementsInFramesFromSelection)(selectedElements)) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)((0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_14__.excludeElementsInFramesFromSelection)(nonDeletedElements));\n const newZoom = {\n value: (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getNormalizedZoom)(zoomValueToFitBoundsOnViewport(commonBounds, {\n width: appState.width - appState.width * margin,\n height: appState.height - appState.height * margin\n }, 1, maxZoom))\n };\n const [x1, y1, x2, y2] = commonBounds;\n const centerX = (x1 + x2) / 2;\n const centerY = (y1 + y2) / 2;\n return {\n appState: Object.assign(Object.assign(Object.assign({}, appState), (0,_scene_scroll__WEBPACK_IMPORTED_MODULE_10__.centerScrollOn)({\n scenePoint: {\n x: centerX,\n y: centerY\n },\n viewportDimensions: {\n width: appState.width,\n height: appState.height\n },\n zoom: newZoom\n })), {\n zoom: newZoom\n }),\n commitToHistory: false\n };\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./actions/actionCanvas.tsx?");
13787
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ actionChangeViewBackgroundColor: () => (/* binding */ actionChangeViewBackgroundColor),\n/* harmony export */ actionClearCanvas: () => (/* binding */ actionClearCanvas),\n/* harmony export */ actionResetZoom: () => (/* binding */ actionResetZoom),\n/* harmony export */ actionToggleEraserTool: () => (/* binding */ actionToggleEraserTool),\n/* harmony export */ actionToggleHandTool: () => (/* binding */ actionToggleHandTool),\n/* harmony export */ actionToggleLaserPointer: () => (/* binding */ actionToggleLaserPointer),\n/* harmony export */ actionToggleLassoTool: () => (/* binding */ actionToggleLassoTool),\n/* harmony export */ actionToggleTheme: () => (/* binding */ actionToggleTheme),\n/* harmony export */ actionZoomIn: () => (/* binding */ actionZoomIn),\n/* harmony export */ actionZoomOut: () => (/* binding */ actionZoomOut),\n/* harmony export */ actionZoomToFit: () => (/* binding */ actionZoomToFit),\n/* harmony export */ actionZoomToFitSelection: () => (/* binding */ actionZoomToFitSelection),\n/* harmony export */ actionZoomToFitSelectionInViewport: () => (/* binding */ actionZoomToFitSelectionInViewport),\n/* harmony export */ zoomToFit: () => (/* binding */ zoomToFit),\n/* harmony export */ zoomToFitBounds: () => (/* binding */ zoomToFitBounds),\n/* harmony export */ zoomToFitElements: () => (/* binding */ zoomToFitElements)\n/* harmony export */ });\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _components_ColorPicker_ColorPicker__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../components/ColorPicker/ColorPicker */ \"./components/ColorPicker/ColorPicker.tsx\");\n/* harmony import */ var _components_ToolButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../components/ToolButton */ \"./components/ToolButton.tsx\");\n/* harmony import */ var _components_icons__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../components/icons */ \"./components/icons.tsx\");\n/* harmony import */ var _cursor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../cursor */ \"./cursor.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _scene_scroll__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../scene/scroll */ \"./scene/scroll.ts\");\n/* harmony import */ var _scene_zoom__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../scene/zoom */ \"./scene/zoom.ts\");\n/* harmony import */ var _register__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./register */ \"./actions/register.ts\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @excalidraw/element/selection */ \"../element/src/selection.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst actionChangeViewBackgroundColor = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"changeViewBackgroundColor\",\n label: \"labels.canvasBackground\",\n trackEvent: false,\n predicate: (elements, appState, props, app) => {\n return !!app.props.UIOptions.canvasActions.changeViewBackgroundColor && !appState.viewModeEnabled;\n },\n perform: (_, appState, value) => {\n return {\n appState: Object.assign(Object.assign({}, appState), value),\n captureUpdate: !!value.viewBackgroundColor ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.IMMEDIATELY : _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n },\n PanelComponent: ({\n elements,\n appState,\n updateData,\n appProps,\n data\n }) => {\n var _a, _b, _c, _d, _e; // FIXME move me to src/components/mainMenu/DefaultItems.tsx\n\n\n return React.createElement(_components_ColorPicker_ColorPicker__WEBPACK_IMPORTED_MODULE_4__.ColorPicker, {\n topPicks: //zsviczian\n (_c = (_b = (_a = appState.colorPalette) === null || _a === void 0 ? void 0 : _a.topPicks) === null || _b === void 0 ? void 0 : _b.canvasBackground) !== null && _c !== void 0 ? _c : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_CANVAS_BACKGROUND_PICKS,\n palette: //zsviczian\n (_e = (_d = appState.colorPalette) === null || _d === void 0 ? void 0 : _d.canvasBackground) !== null && _e !== void 0 ? _e : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE,\n label: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.canvasBackground\"),\n type: \"canvasBackground\",\n color: appState.viewBackgroundColor,\n onChange: color => updateData({\n viewBackgroundColor: color\n }),\n \"data-testid\": \"canvas-background-picker\",\n elements: elements,\n appState: appState,\n updateData: updateData,\n compactMode: false\n /*appState.stylesPanelMode === \"compact\" //zsviczian*/\n\n });\n }\n});\nconst actionClearCanvas = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"clearCanvas\",\n label: \"labels.clearCanvas\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.TrashIcon,\n trackEvent: {\n category: \"canvas\"\n },\n predicate: (elements, appState, props, app) => {\n var _a;\n\n return !!app.props.UIOptions.canvasActions.clearCanvas && !appState.viewModeEnabled && ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"elementLinkSelector\";\n },\n perform: (elements, appState, _, app) => {\n app.imageCache.clear();\n return {\n elements: elements.map(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.newElementWith)(element, {\n isDeleted: true\n })),\n appState: Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_3__.getDefaultAppState)()), {\n files: {},\n theme: appState.theme,\n penMode: appState.penMode,\n penDetected: appState.penDetected,\n exportBackground: appState.exportBackground,\n exportEmbedScene: appState.exportEmbedScene,\n gridSize: appState.gridSize,\n gridStep: appState.gridStep,\n gridModeEnabled: appState.gridModeEnabled,\n stats: appState.stats,\n pasteDialog: appState.pasteDialog,\n activeTool: appState.activeTool.type === \"image\" ? Object.assign(Object.assign({}, appState.activeTool), {\n type: app.defaultSelectionTool\n }) : appState.activeTool,\n colorPalette: appState.colorPalette,\n trayModeEnabled: appState.trayModeEnabled,\n allowPinchZoom: appState.allowPinchZoom,\n allowWheelZoom: appState.allowWheelZoom,\n pinnedScripts: appState.pinnedScripts,\n customPens: appState.customPens\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.IMMEDIATELY\n };\n }\n});\nconst actionZoomIn = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"zoomIn\",\n label: \"buttons.zoomIn\",\n viewMode: true,\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.ZoomInIcon,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (_elements, appState, _, app) => {\n return {\n appState: Object.assign(Object.assign(Object.assign({}, appState), (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_11__.getStateForZoom)({\n viewportX: appState.width / 2 + appState.offsetLeft,\n viewportY: appState.height / 2 + appState.offsetTop,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getNormalizedZoom)(appState.zoom.value + (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomStep)())\n }, appState)), {\n userToFollow: null\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n },\n PanelComponent: ({\n updateData,\n appState\n }) => React.createElement(_components_ToolButton__WEBPACK_IMPORTED_MODULE_5__.ToolButton, {\n type: \"button\",\n className: \"zoom-in-button zoom-button\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.ZoomInIcon,\n title: `${(0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.zoomIn\")} — ${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd++\")}`,\n \"aria-label\": (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.zoomIn\"),\n disabled: appState.zoom.value >= (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomMax)(),\n onClick: () => {\n updateData(null);\n }\n }),\n keyTest: event => (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.EQUAL || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.NUM_ADD) && (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] || event.shiftKey)\n});\nconst actionZoomOut = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"zoomOut\",\n label: \"buttons.zoomOut\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.ZoomOutIcon,\n viewMode: true,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (_elements, appState, _, app) => {\n return {\n appState: Object.assign(Object.assign(Object.assign({}, appState), (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_11__.getStateForZoom)({\n viewportX: appState.width / 2 + appState.offsetLeft,\n viewportY: appState.height / 2 + appState.offsetTop,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getNormalizedZoom)(appState.zoom.value - (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomStep)())\n }, appState)), {\n userToFollow: null\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n },\n PanelComponent: ({\n updateData,\n appState\n }) => React.createElement(_components_ToolButton__WEBPACK_IMPORTED_MODULE_5__.ToolButton, {\n type: \"button\",\n className: \"zoom-out-button zoom-button\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.ZoomOutIcon,\n title: `${(0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.zoomOut\")} — ${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.getShortcutKey)(\"CtrlOrCmd+-\")}`,\n \"aria-label\": (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.zoomOut\"),\n disabled: appState.zoom.value <= (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomMin)(),\n onClick: () => {\n updateData(null);\n }\n }),\n keyTest: event => (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.MINUS || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.NUM_SUBTRACT) && (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] || event.shiftKey)\n});\nconst actionResetZoom = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"resetZoom\",\n label: \"buttons.resetZoom\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.ZoomResetIcon,\n viewMode: true,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (_elements, appState, _, app) => {\n return {\n appState: Object.assign(Object.assign(Object.assign({}, appState), (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_11__.getStateForZoom)({\n viewportX: appState.width / 2 + appState.offsetLeft,\n viewportY: appState.height / 2 + appState.offsetTop,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getNormalizedZoom)(1)\n }, appState)), {\n userToFollow: null\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n },\n PanelComponent: ({\n updateData,\n appState\n }) => // zsviczian <Tooltip label={t(\"buttons.resetZoom\")} style={{ display: \"none\" }}>\n React.createElement(_components_ToolButton__WEBPACK_IMPORTED_MODULE_5__.ToolButton, {\n type: \"button\",\n className: \"reset-zoom-button zoom-button\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.resetZoom\"),\n \"aria-label\": (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.resetZoom\"),\n onClick: () => {\n updateData(null);\n }\n }, (appState.zoom.value * 100).toFixed(0), \"%\") //</Tooltip>\n ,\n keyTest: event => (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.ZERO || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.NUM_ZERO) && (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] || event.shiftKey)\n});\n\nconst zoomValueToFitBoundsOnViewport = (bounds, viewportDimensions, viewportZoomFactor = 1, // default to 1 if not provided\nmaxZoom) => {\n if (typeof maxZoom === \"undefined\") {\n //zsviczian\n maxZoom = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getMaxZoom)();\n }\n\n const [x1, y1, x2, y2] = bounds;\n const commonBoundsWidth = x2 - x1;\n const zoomValueForWidth = viewportDimensions.width / commonBoundsWidth;\n const commonBoundsHeight = y2 - y1;\n const zoomValueForHeight = viewportDimensions.height / commonBoundsHeight;\n const smallestZoomValue = Math.min(zoomValueForWidth, zoomValueForHeight);\n const adjustedZoomValue = smallestZoomValue * (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)(viewportZoomFactor, 0.1, 1);\n return Math.min(adjustedZoomValue, maxZoom); //zsviczian\n};\n\nconst zoomToFitBounds = ({\n bounds,\n appState,\n canvasOffsets,\n fitToViewport = false,\n viewportZoomFactor = 1,\n minZoom = -Infinity,\n maxZoom = Infinity\n}) => {\n var _a, _b, _c, _d;\n\n viewportZoomFactor = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)(viewportZoomFactor, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomMin)(), (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomMax)());\n const [x1, y1, x2, y2] = bounds;\n const centerX = (x1 + x2) / 2;\n const centerY = (y1 + y2) / 2;\n const canvasOffsetLeft = (_a = canvasOffsets === null || canvasOffsets === void 0 ? void 0 : canvasOffsets.left) !== null && _a !== void 0 ? _a : 0;\n const canvasOffsetTop = (_b = canvasOffsets === null || canvasOffsets === void 0 ? void 0 : canvasOffsets.top) !== null && _b !== void 0 ? _b : 0;\n const canvasOffsetRight = (_c = canvasOffsets === null || canvasOffsets === void 0 ? void 0 : canvasOffsets.right) !== null && _c !== void 0 ? _c : 0;\n const canvasOffsetBottom = (_d = canvasOffsets === null || canvasOffsets === void 0 ? void 0 : canvasOffsets.bottom) !== null && _d !== void 0 ? _d : 0;\n const effectiveCanvasWidth = appState.width - canvasOffsetLeft - canvasOffsetRight;\n const effectiveCanvasHeight = appState.height - canvasOffsetTop - canvasOffsetBottom;\n let adjustedZoomValue;\n\n if (fitToViewport) {\n const commonBoundsWidth = x2 - x1;\n const commonBoundsHeight = y2 - y1;\n adjustedZoomValue = Math.min(effectiveCanvasWidth / commonBoundsWidth, effectiveCanvasHeight / commonBoundsHeight) * viewportZoomFactor;\n } else {\n adjustedZoomValue = zoomValueToFitBoundsOnViewport(bounds, {\n width: effectiveCanvasWidth,\n height: effectiveCanvasHeight\n }, viewportZoomFactor);\n }\n\n const newZoomValue = (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getNormalizedZoom)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.clamp)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_0__.roundToStep)(adjustedZoomValue, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getZoomStep)(), \"floor\"), minZoom, maxZoom));\n const centerScroll = (0,_scene_scroll__WEBPACK_IMPORTED_MODULE_10__.centerScrollOn)({\n scenePoint: {\n x: centerX,\n y: centerY\n },\n viewportDimensions: {\n width: appState.width,\n height: appState.height\n },\n offsets: canvasOffsets,\n zoom: {\n value: newZoomValue\n }\n });\n return {\n appState: Object.assign(Object.assign({}, appState), {\n scrollX: centerScroll.scrollX,\n scrollY: centerScroll.scrollY,\n zoom: {\n value: newZoomValue\n }\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n};\nconst zoomToFit = ({\n canvasOffsets,\n targetElements,\n appState,\n fitToViewport,\n viewportZoomFactor,\n minZoom,\n maxZoom\n}) => {\n const commonBounds = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getNonDeletedElements)(targetElements));\n return zoomToFitBounds({\n canvasOffsets,\n bounds: commonBounds,\n appState,\n fitToViewport,\n viewportZoomFactor,\n minZoom,\n maxZoom\n });\n}; // Note, this action differs from actionZoomToFitSelection in that it doesn't\n// zoom beyond 100%. In other words, if the content is smaller than viewport\n// size, it won't be zoomed in.\n\nconst actionZoomToFitSelectionInViewport = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"zoomToFitSelectionInViewport\",\n label: \"labels.zoomToFitViewport\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.zoomAreaIcon,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (elements, appState, _, app) => {\n const selectedElements = app.scene.getSelectedElements(appState);\n return zoomToFit({\n targetElements: selectedElements.length ? selectedElements : elements,\n appState: Object.assign(Object.assign({}, appState), {\n userToFollow: null\n }),\n fitToViewport: false,\n canvasOffsets: app.getEditorUIOffsets()\n });\n },\n // NOTE shift-2 should have been assigned actionZoomToFitSelection.\n // TBD on how proceed\n keyTest: event => event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.TWO && event.shiftKey && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD]\n});\nconst actionZoomToFitSelection = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"zoomToFitSelection\",\n label: \"helpDialog.zoomToSelection\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.zoomAreaIcon,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (elements, appState, _, app) => {\n const selectedElements = app.scene.getSelectedElements(appState);\n return zoomToFit({\n targetElements: selectedElements.length ? selectedElements : elements,\n appState: Object.assign(Object.assign({}, appState), {\n userToFollow: null\n }),\n fitToViewport: true,\n canvasOffsets: app.getEditorUIOffsets()\n });\n },\n // NOTE this action should use shift-2 per figma, alas\n keyTest: event => event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.THREE && event.shiftKey && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD]\n});\nconst actionZoomToFit = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"zoomToFit\",\n label: \"helpDialog.zoomToFit\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.zoomAreaIcon,\n viewMode: true,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (elements, appState, _, app) => zoomToFit({\n targetElements: elements,\n appState: Object.assign(Object.assign({}, appState), {\n userToFollow: null\n }),\n fitToViewport: false,\n canvasOffsets: app.getEditorUIOffsets()\n }),\n keyTest: event => event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.ONE && event.shiftKey && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD]\n});\nconst actionToggleTheme = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"toggleTheme\",\n label: (_, appState) => {\n return appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK ? \"buttons.lightMode\" : \"buttons.darkMode\";\n },\n keywords: [\"toggle\", \"dark\", \"light\", \"mode\", \"theme\"],\n icon: appState => appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT ? _components_icons__WEBPACK_IMPORTED_MODULE_6__.MoonIcon : _components_icons__WEBPACK_IMPORTED_MODULE_6__.SunIcon,\n viewMode: true,\n trackEvent: {\n category: \"canvas\"\n },\n perform: (_, appState, value, app) => {\n //zsviczian\n if (app.props.onThemeChange) {\n //zsviczian\n app.props.onThemeChange(value || (appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT));\n }\n\n return {\n appState: Object.assign(Object.assign({}, appState), {\n theme: value || (appState.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.DARK : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.THEME.LIGHT)\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.EVENTUALLY\n };\n },\n keyTest: event => event.altKey && event.shiftKey && event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CODES.D,\n predicate: (elements, appState, props, app) => {\n return !!app.props.UIOptions.canvasActions.toggleTheme;\n }\n});\nconst actionToggleEraserTool = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"toggleEraserTool\",\n label: \"toolBar.eraser\",\n trackEvent: {\n category: \"toolbar\"\n },\n perform: (elements, appState, _, app) => {\n let activeTool;\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_3__.isEraserActive)(appState)) {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, Object.assign(Object.assign({}, appState.activeTool.lastActiveTool || {\n type: app.defaultSelectionTool\n }), {\n lastActiveToolBeforeEraser: null\n }));\n } else {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, {\n type: \"eraser\",\n lastActiveToolBeforeEraser: appState.activeTool\n });\n }\n\n return {\n appState: Object.assign(Object.assign({}, appState), {\n selectedElementIds: {},\n selectedGroupIds: {},\n activeEmbeddable: null,\n activeTool\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.IMMEDIATELY\n };\n },\n keyTest: event => event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.E\n});\nconst actionToggleLassoTool = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"toggleLassoTool\",\n label: \"toolBar.lasso\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.LassoIcon,\n trackEvent: {\n category: \"toolbar\"\n },\n predicate: (elements, appState, props, app) => {\n return app.defaultSelectionTool !== \"lasso\";\n },\n perform: (elements, appState, _, app) => {\n let activeTool;\n\n if (appState.activeTool.type !== \"lasso\") {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, {\n type: \"lasso\",\n fromSelection: false\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_7__.setCursor)(app.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CURSOR_TYPE.CROSSHAIR);\n } else {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, {\n type: \"selection\"\n });\n }\n\n return {\n appState: Object.assign(Object.assign({}, appState), {\n selectedElementIds: {},\n selectedGroupIds: {},\n activeEmbeddable: null,\n activeTool\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.NEVER\n };\n }\n});\nconst actionToggleHandTool = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n name: \"toggleHandTool\",\n label: \"toolBar.hand\",\n trackEvent: {\n category: \"toolbar\"\n },\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.handIcon,\n viewMode: false,\n perform: (elements, appState, _, app) => {\n let activeTool;\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_3__.isHandToolActive)(appState)) {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, Object.assign(Object.assign({}, appState.activeTool.lastActiveTool || {\n type: \"selection\"\n }), {\n lastActiveToolBeforeEraser: null\n }));\n } else {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, {\n type: \"hand\",\n lastActiveToolBeforeEraser: appState.activeTool\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_7__.setCursor)(app.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CURSOR_TYPE.GRAB);\n }\n\n return {\n appState: Object.assign(Object.assign({}, appState), {\n selectedElementIds: {},\n selectedGroupIds: {},\n activeEmbeddable: null,\n activeTool\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.IMMEDIATELY\n };\n },\n keyTest: event => !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.CTRL_OR_CMD] && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.KEYS.H\n});\nconst actionToggleLaserPointer = (0,_register__WEBPACK_IMPORTED_MODULE_12__.register)({\n //zsviczian - did I really add this? Delta compared to excalidraw.com\n name: \"toggleLaserPointerTool\",\n viewMode: true,\n trackEvent: {\n category: \"menu\"\n },\n\n perform(elements, appState, _, app) {\n let activeTool;\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_3__.isLaserPointerActive)(appState)) {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, Object.assign(Object.assign({}, appState.activeTool.lastActiveTool || {\n type: appState.viewModeEnabled ? \"hand\" : \"selection\"\n }), {\n lastActiveToolBeforeEraser: null\n }));\n (0,_cursor__WEBPACK_IMPORTED_MODULE_7__.setCursor)(app.interactiveCanvas, appState.viewModeEnabled ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CURSOR_TYPE.GRAB : _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CURSOR_TYPE.POINTER);\n } else {\n activeTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.updateActiveTool)(appState, {\n type: \"laser\",\n lastActiveToolBeforeEraser: appState.activeTool\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_7__.setCursor)(app.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.CURSOR_TYPE.CROSSHAIR);\n }\n\n return {\n appState: Object.assign(Object.assign({}, appState), {\n selectedElementIds: {},\n selectedGroupIds: {},\n activeEmbeddable: null,\n activeTool\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.CaptureUpdateAction.NEVER\n };\n },\n\n checked: appState => appState.activeTool.type === \"laser\",\n label: \"labels.laser\",\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_6__.laserPointerToolIcon\n}); //zsviczian\n\nconst zoomToFitElements = (elements, appState, zoomToSelection, app, //zsviczian\nmaxZoom, //zsviczian\nmargin = 0) => {\n if (typeof maxZoom === \"undefined\") {\n //zsviczian\n maxZoom = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_13__.getMaxZoom)();\n }\n\n const nonDeletedElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getNonDeletedElements)(elements);\n const selectedElements = app.scene.getSelectedElements(appState);\n const commonBounds = zoomToSelection && selectedElements.length > 0 ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)((0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_14__.excludeElementsInFramesFromSelection)(selectedElements)) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBounds)((0,_excalidraw_element_selection__WEBPACK_IMPORTED_MODULE_14__.excludeElementsInFramesFromSelection)(nonDeletedElements));\n const newZoom = {\n value: (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getNormalizedZoom)(zoomValueToFitBoundsOnViewport(commonBounds, {\n width: appState.width - appState.width * margin,\n height: appState.height - appState.height * margin\n }, 1, maxZoom))\n };\n const [x1, y1, x2, y2] = commonBounds;\n const centerX = (x1 + x2) / 2;\n const centerY = (y1 + y2) / 2;\n return {\n appState: Object.assign(Object.assign(Object.assign({}, appState), (0,_scene_scroll__WEBPACK_IMPORTED_MODULE_10__.centerScrollOn)({\n scenePoint: {\n x: centerX,\n y: centerY\n },\n viewportDimensions: {\n width: appState.width,\n height: appState.height\n },\n zoom: newZoom\n })), {\n zoom: newZoom\n }),\n commitToHistory: false\n };\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./actions/actionCanvas.tsx?");
13788
13788
 
13789
13789
  /***/ }),
13790
13790
 
@@ -14257,7 +14257,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extr
14257
14257
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14258
14258
 
14259
14259
  "use strict";
14260
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CompactShapeActions: () => (/* binding */ CompactShapeActions),\n/* harmony export */ ExitZenModeAction: () => (/* binding */ ExitZenModeAction),\n/* harmony export */ SelectedShapeActions: () => (/* binding */ SelectedShapeActions),\n/* harmony export */ ShapesSwitcher: () => (/* binding */ ShapesSwitcher),\n/* harmony export */ UndoRedoActions: () => (/* binding */ UndoRedoActions),\n/* harmony export */ ZoomActions: () => (/* binding */ ZoomActions),\n/* harmony export */ canChangeBackgroundColor: () => (/* binding */ canChangeBackgroundColor),\n/* harmony export */ canChangeStrokeColor: () => (/* binding */ canChangeStrokeColor)\n/* harmony export */ });\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @radix-ui/react-popover */ \"../../node_modules/@radix-ui/react-popover/dist/index.mjs\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_actionAlign__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../actions/actionAlign */ \"./actions/actionAlign.tsx\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _context_tunnels__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../context/tunnels */ \"./context/tunnels.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../actions/actionProperties */ \"./actions/actionProperties.tsx\");\n/* harmony import */ var _hooks_useTextEditorFocus__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../hooks/useTextEditorFocus */ \"./hooks/useTextEditorFocus.ts\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./shapes */ \"./components/shapes.tsx\");\n/* harmony import */ var _Actions_scss__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Actions.scss */ \"./components/Actions.scss\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./App */ \"./components/App.tsx\");\n/* harmony import */ var _Stack__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Stack */ \"./components/Stack.tsx\");\n/* harmony import */ var _ToolButton__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ToolButton */ \"./components/ToolButton.tsx\");\n/* harmony import */ var _dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./dropdownMenu/DropdownMenu */ \"./components/dropdownMenu/DropdownMenu.tsx\");\n/* harmony import */ var _PropertiesPopover__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PropertiesPopover */ \"./components/PropertiesPopover.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n //import { Tooltip } from \"./Tooltip\"; //zsivczian\n\n\n\n\n //zsviczian\n// Common CSS class combinations\n\nconst PROPERTIES_CLASSES = (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])([_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.CLASSES.SHAPE_ACTIONS_THEME_SCOPE, \"properties-content\"]);\nconst canChangeStrokeColor = (appState, targetElements) => {\n var _a;\n\n let commonSelectedType = ((_a = targetElements[0]) === null || _a === void 0 ? void 0 : _a.type) || null;\n\n for (const element of targetElements) {\n if (element.type !== commonSelectedType) {\n commonSelectedType = null;\n break;\n }\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasStrokeColor)(appState.activeTool.type) && commonSelectedType !== \"image\" && commonSelectedType !== \"frame\" && commonSelectedType !== \"magicframe\" || targetElements.some(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasStrokeColor)(element.type));\n};\nconst canChangeBackgroundColor = (appState, targetElements) => {\n return (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(element.type));\n};\nconst SelectedShapeActions = ({\n appState,\n elementsMap,\n renderAction,\n app\n}) => {\n var _a;\n\n const targetElements = (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getTargetElements)(elementsMap, appState);\n let isSingleElementBoundContainer = false;\n\n if (targetElements.length === 2 && ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasBoundTextElement)(targetElements[0]) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasBoundTextElement)(targetElements[1]))) {\n isSingleElementBoundContainer = true;\n }\n\n const isEditingTextOrNewElement = Boolean(appState.editingTextElement || appState.newElement);\n const device = (0,_App__WEBPACK_IMPORTED_MODULE_14__.useDevice)();\n const isRTL = document.documentElement.getAttribute(\"dir\") === \"rtl\";\n const showFillIcons = (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(appState.activeTool.type) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isTransparent)(appState.currentItemBackgroundColor) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(element.type) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isTransparent)(element.backgroundColor));\n const showLinkIcon = targetElements.length === 1 || isSingleElementBoundContainer;\n const showLineEditorAction = !((_a = appState.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && targetElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isLinearElement)(targetElements[0]) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isElbowArrow)(targetElements[0]);\n const showCropEditorAction = !appState.croppingElementId && targetElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isImageElement)(targetElements[0]);\n const showAlignActions = !isSingleElementBoundContainer && (0,_actions_actionAlign__WEBPACK_IMPORTED_MODULE_5__.alignActionsPredicate)(appState, app); // zsviczian\n\n const showToggleFrameRoleAction = targetElements.length > 0 && targetElements.every(el => el.type === \"frame\") || appState.activeTool.type === \"frame\";\n return React.createElement(\"div\", {\n className: \"selected-shape-actions\"\n }, React.createElement(\"div\", null, canChangeStrokeColor(appState, targetElements) && renderAction(\"changeStrokeColor\")), canChangeBackgroundColor(appState, targetElements) && React.createElement(\"div\", null, renderAction(\"changeBackgroundColor\")), showFillIcons && renderAction(\"changeFillStyle\"), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(element.type))) && renderAction(\"changeStrokeWidth\"), (appState.activeTool.type === \"freedraw\" || targetElements.some(element => element.type === \"freedraw\")) && renderAction(\"changeStrokeShape\"), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(element.type))) && React.createElement(React.Fragment, null, renderAction(\"changeStrokeStyle\"), renderAction(\"changeSloppiness\")), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(element.type))) && React.createElement(React.Fragment, null, renderAction(\"changeRoundness\")), ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.toolIsArrow)(appState.activeTool.type) || targetElements.some(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.toolIsArrow)(element.type))) && React.createElement(React.Fragment, null, renderAction(\"changeArrowType\")), (appState.activeTool.type === \"text\" || targetElements.some(_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isTextElement)) && React.createElement(React.Fragment, null, renderAction(\"changeFontFamily\"), renderAction(\"changeFontSize\"), (appState.activeTool.type === \"text\" || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.suppportsHorizontalAlign)(targetElements, elementsMap)) && renderAction(\"changeTextAlign\")), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.shouldAllowVerticalAlign)(targetElements, elementsMap) && renderAction(\"changeVerticalAlign\"), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.canHaveArrowheads)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.canHaveArrowheads)(element.type))) && React.createElement(React.Fragment, null, renderAction(\"changeArrowhead\")), showToggleFrameRoleAction && React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_FRAME\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, renderAction(\"toggleFrameRole\"))), renderAction(\"changeOpacity\"), React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.layers\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, renderAction(\"sendToBack\"), renderAction(\"sendBackward\"), renderAction(\"bringForward\"), renderAction(\"bringToFront\"))), showAlignActions && !isSingleElementBoundContainer && React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.align\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, isRTL ? React.createElement(React.Fragment, null, renderAction(\"alignRight\"), renderAction(\"alignHorizontallyCentered\"), renderAction(\"alignLeft\")) : React.createElement(React.Fragment, null, renderAction(\"alignLeft\"), renderAction(\"alignHorizontallyCentered\"), renderAction(\"alignRight\")), targetElements.length > 2 && renderAction(\"distributeHorizontally\"), React.createElement(\"div\", {\n style: {\n flexBasis: \"100%\",\n height: 0\n }\n }), React.createElement(\"div\", {\n style: {\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: \".5rem\",\n marginTop: \"-0.5rem\"\n }\n }, renderAction(\"alignTop\"), renderAction(\"alignVerticallyCentered\"), renderAction(\"alignBottom\"), targetElements.length > 2 && renderAction(\"distributeVertically\")))), !isEditingTextOrNewElement && targetElements.length > 0 && React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.actions\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, !device.editor.isMobile && renderAction(\"duplicateSelection\"), !device.editor.isMobile && renderAction(\"deleteSelectedElements\"), renderAction(\"group\"), renderAction(\"ungroup\"), showLinkIcon && renderAction(\"hyperlink\"), showCropEditorAction && renderAction(\"cropEditor\"), showLineEditorAction && renderAction(\"toggleLinearEditor\"))));\n};\nconst CompactShapeActions = ({\n appState,\n elementsMap,\n renderAction,\n app,\n setAppState\n}) => {\n var _a;\n\n const targetElements = (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getTargetElements)(elementsMap, appState);\n const {\n saveCaretPosition,\n restoreCaretPosition\n } = (0,_hooks_useTextEditorFocus__WEBPACK_IMPORTED_MODULE_11__.useTextEditorFocus)();\n const {\n container\n } = (0,_App__WEBPACK_IMPORTED_MODULE_14__.useExcalidrawContainer)();\n const isEditingTextOrNewElement = Boolean(appState.editingTextElement || appState.newElement);\n const showFillIcons = (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(appState.activeTool.type) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isTransparent)(appState.currentItemBackgroundColor) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(element.type) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isTransparent)(element.backgroundColor));\n const showLinkIcon = targetElements.length === 1;\n const showLineEditorAction = !((_a = appState.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && targetElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isLinearElement)(targetElements[0]) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isElbowArrow)(targetElements[0]);\n const showCropEditorAction = !appState.croppingElementId && targetElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isImageElement)(targetElements[0]);\n const showAlignActions = (0,_actions_actionAlign__WEBPACK_IMPORTED_MODULE_5__.alignActionsPredicate)(appState, app);\n let isSingleElementBoundContainer = false;\n\n if (targetElements.length === 2 && ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasBoundTextElement)(targetElements[0]) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasBoundTextElement)(targetElements[1]))) {\n isSingleElementBoundContainer = true;\n }\n\n const isRTL = document.documentElement.getAttribute(\"dir\") === \"rtl\";\n return React.createElement(\"div\", {\n className: \"compact-shape-actions\"\n }, canChangeStrokeColor(appState, targetElements) && React.createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"compact-action-item\")\n }, renderAction(\"changeStrokeColor\")), canChangeBackgroundColor(appState, targetElements) && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, renderAction(\"changeBackgroundColor\")), (showFillIcons || (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(element.type)) || (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(element.type)) || (0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(element.type))) && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Root, {\n open: appState.openPopup === \"compactStrokeStyles\",\n onOpenChange: open => {\n if (open) {\n setAppState({\n openPopup: \"compactStrokeStyles\"\n });\n } else {\n setAppState({\n openPopup: null\n });\n }\n }\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Trigger, {\n asChild: true\n }, React.createElement(\"button\", {\n type: \"button\",\n className: \"compact-action-button properties-trigger\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.stroke\"),\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n setAppState({\n openPopup: appState.openPopup === \"compactStrokeStyles\" ? null : \"compactStrokeStyles\"\n });\n }\n }, _icons__WEBPACK_IMPORTED_MODULE_19__.adjustmentsIcon)), appState.openPopup === \"compactStrokeStyles\" && React.createElement(_PropertiesPopover__WEBPACK_IMPORTED_MODULE_18__.PropertiesPopover, {\n className: PROPERTIES_CLASSES,\n container: container,\n style: {\n maxWidth: \"13rem\"\n },\n onClose: () => {}\n }, React.createElement(\"div\", {\n className: \"selected-shape-actions\"\n }, showFillIcons && renderAction(\"changeFillStyle\"), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(element.type))) && renderAction(\"changeStrokeWidth\"), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(element.type))) && React.createElement(React.Fragment, null, renderAction(\"changeStrokeStyle\"), renderAction(\"changeSloppiness\")), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(element.type))) && renderAction(\"changeRoundness\"), renderAction(\"changeOpacity\"))))), ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.toolIsArrow)(appState.activeTool.type) || targetElements.some(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.toolIsArrow)(element.type))) && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Root, {\n open: appState.openPopup === \"compactArrowProperties\",\n onOpenChange: open => {\n if (open) {\n setAppState({\n openPopup: \"compactArrowProperties\"\n });\n } else {\n setAppState({\n openPopup: null\n });\n }\n }\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Trigger, {\n asChild: true\n }, React.createElement(\"button\", {\n type: \"button\",\n className: \"compact-action-button properties-trigger\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.arrowtypes\"),\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n setAppState({\n openPopup: appState.openPopup === \"compactArrowProperties\" ? null : \"compactArrowProperties\"\n });\n }\n }, (() => {\n // Show an icon based on the current arrow type\n const arrowType = (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__.getFormValue)(targetElements, app, element => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isArrowElement)(element)) {\n return element.elbowed ? \"elbow\" : element.roundness ? \"round\" : \"sharp\";\n }\n\n return null;\n }, element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isArrowElement)(element), hasSelection => hasSelection ? null : appState.currentItemArrowType);\n\n if (arrowType === \"elbow\") {\n return _icons__WEBPACK_IMPORTED_MODULE_19__.elbowArrowIcon;\n }\n\n if (arrowType === \"round\") {\n return _icons__WEBPACK_IMPORTED_MODULE_19__.roundArrowIcon;\n }\n\n return _icons__WEBPACK_IMPORTED_MODULE_19__.sharpArrowIcon;\n })())), appState.openPopup === \"compactArrowProperties\" && React.createElement(_PropertiesPopover__WEBPACK_IMPORTED_MODULE_18__.PropertiesPopover, {\n container: container,\n className: \"properties-content\",\n style: {\n maxWidth: \"13rem\"\n },\n onClose: () => {}\n }, renderAction(\"changeArrowProperties\")))), showLineEditorAction && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, renderAction(\"toggleLinearEditor\")), (appState.activeTool.type === \"text\" || targetElements.some(_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isTextElement)) && React.createElement(React.Fragment, null, React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, renderAction(\"changeFontFamily\")), React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Root, {\n open: appState.openPopup === \"compactTextProperties\",\n onOpenChange: open => {\n if (open) {\n if (appState.editingTextElement) {\n saveCaretPosition();\n }\n\n setAppState({\n openPopup: \"compactTextProperties\"\n });\n } else {\n setAppState({\n openPopup: null\n });\n\n if (appState.editingTextElement) {\n restoreCaretPosition();\n }\n }\n }\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Trigger, {\n asChild: true\n }, React.createElement(\"button\", {\n type: \"button\",\n className: \"compact-action-button properties-trigger\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.textAlign\"),\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n\n if (appState.openPopup === \"compactTextProperties\") {\n setAppState({\n openPopup: null\n });\n } else {\n if (appState.editingTextElement) {\n saveCaretPosition();\n }\n\n setAppState({\n openPopup: \"compactTextProperties\"\n });\n }\n }\n }, _icons__WEBPACK_IMPORTED_MODULE_19__.TextSizeIcon)), appState.openPopup === \"compactTextProperties\" && React.createElement(_PropertiesPopover__WEBPACK_IMPORTED_MODULE_18__.PropertiesPopover, {\n className: PROPERTIES_CLASSES,\n container: container,\n style: {\n maxWidth: \"13rem\"\n },\n // Improve focus handling for text editing scenarios\n preventAutoFocusOnTouch: !!appState.editingTextElement,\n onClose: () => {\n // Refocus text editor when popover closes with caret restoration\n if (appState.editingTextElement) {\n restoreCaretPosition();\n }\n }\n }, React.createElement(\"div\", {\n className: \"selected-shape-actions\"\n }, (appState.activeTool.type === \"text\" || targetElements.some(_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isTextElement)) && renderAction(\"changeFontSize\"), (appState.activeTool.type === \"text\" || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.suppportsHorizontalAlign)(targetElements, elementsMap)) && renderAction(\"changeTextAlign\"), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.shouldAllowVerticalAlign)(targetElements, elementsMap) && renderAction(\"changeVerticalAlign\")))))), !isEditingTextOrNewElement && targetElements.length > 0 && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, renderAction(\"duplicateSelection\")), !isEditingTextOrNewElement && targetElements.length > 0 && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, renderAction(\"deleteSelectedElements\")), !isEditingTextOrNewElement && targetElements.length > 0 && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Root, {\n open: appState.openPopup === \"compactOtherProperties\",\n onOpenChange: open => {\n if (open) {\n setAppState({\n openPopup: \"compactOtherProperties\"\n });\n } else {\n setAppState({\n openPopup: null\n });\n }\n }\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Trigger, {\n asChild: true\n }, React.createElement(\"button\", {\n type: \"button\",\n className: \"compact-action-button properties-trigger\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.actions\"),\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n setAppState({\n openPopup: appState.openPopup === \"compactOtherProperties\" ? null : \"compactOtherProperties\"\n });\n }\n }, _icons__WEBPACK_IMPORTED_MODULE_19__.DotsHorizontalIcon)), appState.openPopup === \"compactOtherProperties\" && React.createElement(_PropertiesPopover__WEBPACK_IMPORTED_MODULE_18__.PropertiesPopover, {\n className: PROPERTIES_CLASSES,\n container: container,\n style: {\n maxWidth: \"12rem\",\n // center the popover content\n justifyContent: \"center\",\n alignItems: \"center\"\n },\n onClose: () => {}\n }, React.createElement(\"div\", {\n className: \"selected-shape-actions\"\n }, React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.layers\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, renderAction(\"sendToBack\"), renderAction(\"sendBackward\"), renderAction(\"bringForward\"), renderAction(\"bringToFront\"))), showAlignActions && !isSingleElementBoundContainer && React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.align\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, isRTL ? React.createElement(React.Fragment, null, renderAction(\"alignRight\"), renderAction(\"alignHorizontallyCentered\"), renderAction(\"alignLeft\")) : React.createElement(React.Fragment, null, renderAction(\"alignLeft\"), renderAction(\"alignHorizontallyCentered\"), renderAction(\"alignRight\")), targetElements.length > 2 && renderAction(\"distributeHorizontally\"), React.createElement(\"div\", {\n style: {\n flexBasis: \"100%\",\n height: 0\n }\n }), React.createElement(\"div\", {\n style: {\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: \".5rem\",\n marginTop: \"-0.5rem\"\n }\n }, renderAction(\"alignTop\"), renderAction(\"alignVerticallyCentered\"), renderAction(\"alignBottom\"), targetElements.length > 2 && renderAction(\"distributeVertically\")))), React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.actions\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, renderAction(\"group\"), renderAction(\"ungroup\"), showLinkIcon && renderAction(\"hyperlink\"), showCropEditorAction && renderAction(\"cropEditor\"))))))));\n};\nconst ShapesSwitcher = ({\n activeTool,\n appState,\n app,\n UIOptions\n}) => {\n const {\n renderMermaid\n } = (0,_App__WEBPACK_IMPORTED_MODULE_14__.useAppProps)(); //zsviczian\n\n const [isExtraToolsMenuOpen, setIsExtraToolsMenuOpen] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);\n const [isImageMenuOpen, setIsImageMenuOpen] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false); //zsviczian\n\n const frameToolSelected = activeTool.type === \"frame\";\n const laserToolSelected = activeTool.type === \"laser\";\n const lassoToolSelected = activeTool.type === \"lasso\" && app.defaultSelectionTool !== \"lasso\";\n const embeddableToolSelected = activeTool.type === \"embeddable\";\n const {\n TTDDialogTriggerTunnel\n } = (0,_context_tunnels__WEBPACK_IMPORTED_MODULE_7__.useTunnels)();\n return React.createElement(React.Fragment, null, (0,_shapes__WEBPACK_IMPORTED_MODULE_12__.getToolbarTools)(app).map(({\n value,\n icon,\n key,\n numericKey,\n fillable\n }, index) => {\n var _a;\n\n if (((_a = UIOptions.tools) === null || _a === void 0 ? void 0 : _a[value]) === false) {\n return null;\n }\n\n const label = (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(`toolBar.${value}`);\n const letter = key && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.capitalizeString)(typeof key === \"string\" ? key : key[0]);\n const shortcut = letter ? `${letter} ${(0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"helpDialog.or\")} ${numericKey}` : `${numericKey}`;\n return React.createElement(_ToolButton__WEBPACK_IMPORTED_MODULE_16__.ToolButton, {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"Shape\", {\n fillable\n }),\n key: value,\n type: \"radio\",\n icon: icon,\n checked: activeTool.type === value,\n name: \"editor-current-shape\",\n title: `${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.capitalizeString)(label)} — ${shortcut}`,\n keyBindingLabel: numericKey || letter,\n \"aria-label\": (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.capitalizeString)(label),\n \"aria-keyshortcuts\": shortcut,\n \"data-testid\": `toolbar-${value}`,\n onPointerDown: ({\n pointerType\n }) => {\n if (!appState.penDetected && pointerType === \"pen\") {\n app.togglePenMode(true);\n }\n\n if (value === \"selection\") {\n if (appState.activeTool.type === \"selection\") {\n app.setActiveTool({\n type: \"lasso\"\n });\n } else {\n app.setActiveTool({\n type: \"selection\"\n });\n }\n }\n },\n onChange: ({\n pointerType\n }) => {\n if (appState.activeTool.type !== value) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_6__.trackEvent)(\"toolbar\", value, \"ui\");\n }\n /*if (value === \"image\") {\r\n app.setActiveTool({\r\n type: value,\r\n });\r\n } else {*/\n //zsviczian moved Image action to dropdown menu\n\n\n app.setActiveTool({\n type: value\n }); //}\n }\n });\n }), React.createElement(\"div\", {\n className: \"App-toolbar__divider\"\n }), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"], {\n open: isImageMenuOpen\n }, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Trigger, {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"App-toolbar__extra-tools-trigger\"),\n onToggle: () => {\n if (!isImageMenuOpen) {\n setIsExtraToolsMenuOpen(false);\n }\n\n setIsImageMenuOpen(!isImageMenuOpen);\n },\n title: (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_IMG\")\n }, _icons__WEBPACK_IMPORTED_MODULE_19__.ImageIcon), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Content, {\n onClickOutside: () => setIsImageMenuOpen(false),\n onSelect: () => setIsImageMenuOpen(false),\n className: \"App-toolbar__extra-tools-dropdown\"\n }, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setActiveTool({\n type: \"image\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.ImageIcon,\n \"data-testid\": \"toolbar-image-import\"\n }, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_IMG_FROM_SYSTEM\")), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.runAction)(\"anyFile\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.InsertAnyFileIcon,\n \"data-testid\": \"toolbar-any-file\"\n }, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_IMG_ANY_FILE\")), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.runAction)(\"card\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.Card,\n \"data-testid\": \"toolbar-card\"\n }, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"INSERT_CARD\")), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.runAction)(\"LaTeX\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.LaTeXIcon,\n \"data-testid\": \"toolbar-latex\"\n }, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_IMG_LaTeX\")))), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"], {\n open: isExtraToolsMenuOpen\n }, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Trigger, {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"App-toolbar__extra-tools-trigger\", {\n \"App-toolbar__extra-tools-trigger--selected\": frameToolSelected || embeddableToolSelected || lassoToolSelected || // in collab we're already highlighting the laser button\n // outside toolbar, so let's not highlight extra-tools button\n // on top of it\n laserToolSelected && !app.props.isCollaborating\n }),\n onToggle: () => {\n if (!isExtraToolsMenuOpen) {\n setIsImageMenuOpen(false);\n }\n\n setIsExtraToolsMenuOpen(!isExtraToolsMenuOpen);\n },\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.extraTools\")\n }, frameToolSelected ? _icons__WEBPACK_IMPORTED_MODULE_19__.frameToolIcon : embeddableToolSelected ? _icons__WEBPACK_IMPORTED_MODULE_19__.EmbedIcon : laserToolSelected && !app.props.isCollaborating ? _icons__WEBPACK_IMPORTED_MODULE_19__.laserPointerToolIcon : lassoToolSelected ? _icons__WEBPACK_IMPORTED_MODULE_19__.LassoIcon : _icons__WEBPACK_IMPORTED_MODULE_19__.extraToolsIcon), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Content, {\n onClickOutside: () => setIsExtraToolsMenuOpen(false),\n onSelect: () => setIsExtraToolsMenuOpen(false),\n className: \"App-toolbar__extra-tools-dropdown\"\n }, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setActiveTool({\n type: \"frame\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.frameToolIcon,\n shortcut: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.KEYS.F.toLocaleUpperCase(),\n \"data-testid\": \"toolbar-frame\",\n selected: frameToolSelected\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.frame\")), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setActiveTool({\n type: \"embeddable\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.EmbedIcon,\n \"data-testid\": \"toolbar-embeddable\",\n selected: embeddableToolSelected\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.embeddable\")), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setActiveTool({\n type: \"laser\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.laserPointerToolIcon,\n \"data-testid\": \"toolbar-laser\",\n selected: laserToolSelected,\n shortcut: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.KEYS.K.toLocaleUpperCase()\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.laser\")), app.defaultSelectionTool !== \"lasso\" && React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setActiveTool({\n type: \"lasso\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.LassoIcon,\n \"data-testid\": \"toolbar-lasso\",\n selected: lassoToolSelected\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.lasso\")), React.createElement(\"div\", {\n style: {\n margin: \"6px 0\",\n fontSize: 14,\n fontWeight: 600\n }\n }, \"Generate\"), app.props.aiEnabled !== false && React.createElement(TTDDialogTriggerTunnel.Out, null), renderMermaid && //zsviczian\n React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setOpenDialog({\n name: \"ttd\",\n tab: \"mermaid\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.mermaidLogoIcon,\n \"data-testid\": \"toolbar-embeddable\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.mermaidToExcalidraw\")), app.props.aiEnabled !== false && app.plugins.diagramToCode && React.createElement(React.Fragment, null, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.onMagicframeToolSelect(),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.MagicIcon,\n \"data-testid\": \"toolbar-magicframe\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.magicframe\"), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item.Badge, null, \"AI\"))))));\n};\nconst ZoomActions = ({\n renderAction,\n zoom,\n trayMode = false //zsviczian\n\n}) => React.createElement(_Stack__WEBPACK_IMPORTED_MODULE_15__[\"default\"].Col, {\n gap: 1,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.CLASSES.ZOOM_ACTIONS, {\n \"tray-zoom\": trayMode\n })\n}, React.createElement(_Stack__WEBPACK_IMPORTED_MODULE_15__[\"default\"].Row, {\n align: \"center\"\n}, renderAction(\"zoomOut\"), renderAction(\"resetZoom\"), renderAction(\"zoomIn\")));\nconst UndoRedoActions = ({\n renderAction,\n className\n}) => React.createElement(\"div\", {\n className: `undo-redo-buttons ${className}`\n}, React.createElement(\"div\", {\n className: \"undo-button-container\"\n}, renderAction(\"undo\")\n/* //zsviczian */\n), React.createElement(\"div\", {\n className: \"redo-button-container\"\n}, renderAction(\"redo\")\n/* //zsviczian */\n));\nconst ExitZenModeAction = ({\n actionManager,\n showExitZenModeBtn\n}) => React.createElement(\"button\", {\n type: \"button\",\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"disable-zen-mode\", {\n \"disable-zen-mode--visible\": showExitZenModeBtn\n }),\n onClick: () => actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_4__.actionToggleZenMode)\n}, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.exitZenMode\"));\n\n//# sourceURL=webpack://ExcalidrawLib/./components/Actions.tsx?");
14260
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CompactShapeActions: () => (/* binding */ CompactShapeActions),\n/* harmony export */ ExitZenModeAction: () => (/* binding */ ExitZenModeAction),\n/* harmony export */ SelectedShapeActions: () => (/* binding */ SelectedShapeActions),\n/* harmony export */ ShapesSwitcher: () => (/* binding */ ShapesSwitcher),\n/* harmony export */ UndoRedoActions: () => (/* binding */ UndoRedoActions),\n/* harmony export */ ZoomActions: () => (/* binding */ ZoomActions),\n/* harmony export */ canChangeBackgroundColor: () => (/* binding */ canChangeBackgroundColor),\n/* harmony export */ canChangeStrokeColor: () => (/* binding */ canChangeStrokeColor)\n/* harmony export */ });\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @radix-ui/react-popover */ \"../../node_modules/@radix-ui/react-popover/dist/index.mjs\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_actionAlign__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../actions/actionAlign */ \"./actions/actionAlign.tsx\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _context_tunnels__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../context/tunnels */ \"./context/tunnels.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../actions/actionProperties */ \"./actions/actionProperties.tsx\");\n/* harmony import */ var _hooks_useTextEditorFocus__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../hooks/useTextEditorFocus */ \"./hooks/useTextEditorFocus.ts\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./shapes */ \"./components/shapes.tsx\");\n/* harmony import */ var _Actions_scss__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Actions.scss */ \"./components/Actions.scss\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./App */ \"./components/App.tsx\");\n/* harmony import */ var _Stack__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Stack */ \"./components/Stack.tsx\");\n/* harmony import */ var _ToolButton__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ToolButton */ \"./components/ToolButton.tsx\");\n/* harmony import */ var _dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./dropdownMenu/DropdownMenu */ \"./components/dropdownMenu/DropdownMenu.tsx\");\n/* harmony import */ var _PropertiesPopover__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PropertiesPopover */ \"./components/PropertiesPopover.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n //import { Tooltip } from \"./Tooltip\"; //zsivczian\n\n\n\n\n //zsviczian\n// Common CSS class combinations\n\nconst PROPERTIES_CLASSES = (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])([_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.CLASSES.SHAPE_ACTIONS_THEME_SCOPE, \"properties-content\"]);\nconst canChangeStrokeColor = (appState, targetElements) => {\n var _a;\n\n let commonSelectedType = ((_a = targetElements[0]) === null || _a === void 0 ? void 0 : _a.type) || null;\n\n for (const element of targetElements) {\n if (element.type !== commonSelectedType) {\n commonSelectedType = null;\n break;\n }\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasStrokeColor)(appState.activeTool.type) && commonSelectedType !== \"image\" && commonSelectedType !== \"frame\" && commonSelectedType !== \"magicframe\" || targetElements.some(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasStrokeColor)(element.type));\n};\nconst canChangeBackgroundColor = (appState, targetElements) => {\n return (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(element.type));\n};\nconst SelectedShapeActions = ({\n appState,\n elementsMap,\n renderAction,\n app\n}) => {\n var _a;\n\n const targetElements = (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getTargetElements)(elementsMap, appState);\n let isSingleElementBoundContainer = false;\n\n if (targetElements.length === 2 && ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasBoundTextElement)(targetElements[0]) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasBoundTextElement)(targetElements[1]))) {\n isSingleElementBoundContainer = true;\n }\n\n const isEditingTextOrNewElement = Boolean(appState.editingTextElement || appState.newElement);\n const device = (0,_App__WEBPACK_IMPORTED_MODULE_14__.useDevice)();\n const isRTL = document.documentElement.getAttribute(\"dir\") === \"rtl\";\n const showFillIcons = (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(appState.activeTool.type) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isTransparent)(appState.currentItemBackgroundColor) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(element.type) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isTransparent)(element.backgroundColor));\n const showLinkIcon = targetElements.length === 1 || isSingleElementBoundContainer;\n const showLineEditorAction = !((_a = appState.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && targetElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isLinearElement)(targetElements[0]) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isElbowArrow)(targetElements[0]);\n const showCropEditorAction = !appState.croppingElementId && targetElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isImageElement)(targetElements[0]);\n const showAlignActions = !isSingleElementBoundContainer && (0,_actions_actionAlign__WEBPACK_IMPORTED_MODULE_5__.alignActionsPredicate)(appState, app); // zsviczian\n\n const showToggleFrameRoleAction = targetElements.length > 0 && targetElements.every(el => el.type === \"frame\") || appState.activeTool.type === \"frame\";\n return React.createElement(\"div\", {\n className: \"selected-shape-actions\"\n }, React.createElement(\"div\", null, canChangeStrokeColor(appState, targetElements) && renderAction(\"changeStrokeColor\")), canChangeBackgroundColor(appState, targetElements) && React.createElement(\"div\", null, renderAction(\"changeBackgroundColor\")), showFillIcons && renderAction(\"changeFillStyle\"), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(element.type))) && renderAction(\"changeStrokeWidth\"), (appState.activeTool.type === \"freedraw\" || targetElements.some(element => element.type === \"freedraw\")) && renderAction(\"changeStrokeShape\"), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(element.type))) && React.createElement(React.Fragment, null, renderAction(\"changeStrokeStyle\"), renderAction(\"changeSloppiness\")), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(element.type))) && React.createElement(React.Fragment, null, renderAction(\"changeRoundness\")), ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.toolIsArrow)(appState.activeTool.type) || targetElements.some(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.toolIsArrow)(element.type))) && React.createElement(React.Fragment, null, renderAction(\"changeArrowType\")), (appState.activeTool.type === \"text\" || targetElements.some(_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isTextElement)) && React.createElement(React.Fragment, null, renderAction(\"changeFontFamily\"), renderAction(\"changeFontSize\"), (appState.activeTool.type === \"text\" || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.suppportsHorizontalAlign)(targetElements, elementsMap)) && renderAction(\"changeTextAlign\")), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.shouldAllowVerticalAlign)(targetElements, elementsMap) && renderAction(\"changeVerticalAlign\"), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.canHaveArrowheads)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.canHaveArrowheads)(element.type))) && React.createElement(React.Fragment, null, renderAction(\"changeArrowhead\")), showToggleFrameRoleAction && React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_FRAME\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, renderAction(\"toggleFrameRole\"))), renderAction(\"changeOpacity\"), React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.layers\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, renderAction(\"sendToBack\"), renderAction(\"sendBackward\"), renderAction(\"bringForward\"), renderAction(\"bringToFront\"))), showAlignActions && !isSingleElementBoundContainer && React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.align\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, isRTL ? React.createElement(React.Fragment, null, renderAction(\"alignRight\"), renderAction(\"alignHorizontallyCentered\"), renderAction(\"alignLeft\")) : React.createElement(React.Fragment, null, renderAction(\"alignLeft\"), renderAction(\"alignHorizontallyCentered\"), renderAction(\"alignRight\")), targetElements.length > 2 && renderAction(\"distributeHorizontally\"), React.createElement(\"div\", {\n style: {\n flexBasis: \"100%\",\n height: 0\n }\n }), React.createElement(\"div\", {\n style: {\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: \".5rem\",\n marginTop: \"-0.5rem\"\n }\n }, renderAction(\"alignTop\"), renderAction(\"alignVerticallyCentered\"), renderAction(\"alignBottom\"), targetElements.length > 2 && renderAction(\"distributeVertically\")))), !isEditingTextOrNewElement && targetElements.length > 0 && React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.actions\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, !device.editor.isMobile && renderAction(\"duplicateSelection\"), !device.editor.isMobile && renderAction(\"deleteSelectedElements\"), renderAction(\"group\"), renderAction(\"ungroup\"), showLinkIcon && renderAction(\"hyperlink\"), showCropEditorAction && renderAction(\"cropEditor\"), showLineEditorAction && renderAction(\"toggleLinearEditor\"))));\n};\nconst CompactShapeActions = ({\n appState,\n elementsMap,\n renderAction,\n app,\n setAppState\n}) => {\n var _a;\n\n const targetElements = (0,_scene__WEBPACK_IMPORTED_MODULE_9__.getTargetElements)(elementsMap, appState);\n const {\n saveCaretPosition,\n restoreCaretPosition\n } = (0,_hooks_useTextEditorFocus__WEBPACK_IMPORTED_MODULE_11__.useTextEditorFocus)();\n const {\n container\n } = (0,_App__WEBPACK_IMPORTED_MODULE_14__.useExcalidrawContainer)();\n const isEditingTextOrNewElement = Boolean(appState.editingTextElement || appState.newElement);\n const showFillIcons = (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(appState.activeTool.type) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isTransparent)(appState.currentItemBackgroundColor) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasBackground)(element.type) && !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isTransparent)(element.backgroundColor));\n const showLinkIcon = targetElements.length === 1;\n const showLineEditorAction = !((_a = appState.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && targetElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isLinearElement)(targetElements[0]) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isElbowArrow)(targetElements[0]);\n const showCropEditorAction = !appState.croppingElementId && targetElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isImageElement)(targetElements[0]);\n const showAlignActions = (0,_actions_actionAlign__WEBPACK_IMPORTED_MODULE_5__.alignActionsPredicate)(appState, app);\n let isSingleElementBoundContainer = false;\n\n if (targetElements.length === 2 && ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasBoundTextElement)(targetElements[0]) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.hasBoundTextElement)(targetElements[1]))) {\n isSingleElementBoundContainer = true;\n }\n\n const isRTL = document.documentElement.getAttribute(\"dir\") === \"rtl\"; // zsviczian\n\n const showToggleFrameRoleAction = targetElements.length > 0 && targetElements.every(el => el.type === \"frame\") || appState.activeTool.type === \"frame\";\n return React.createElement(\"div\", {\n className: \"compact-shape-actions\"\n }, canChangeStrokeColor(appState, targetElements) && React.createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"compact-action-item\")\n }, renderAction(\"changeStrokeColor\")), canChangeBackgroundColor(appState, targetElements) && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, renderAction(\"changeBackgroundColor\")), (showFillIcons || showToggleFrameRoleAction || //zsviczian\n (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(element.type)) || (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(element.type)) || (0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(element.type))) && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Root, {\n open: appState.openPopup === \"compactStrokeStyles\",\n onOpenChange: open => {\n if (open) {\n setAppState({\n openPopup: \"compactStrokeStyles\"\n });\n } else {\n setAppState({\n openPopup: null\n });\n }\n }\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Trigger, {\n asChild: true\n }, React.createElement(\"button\", {\n type: \"button\",\n className: \"compact-action-button properties-trigger\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.stroke\"),\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n setAppState({\n openPopup: appState.openPopup === \"compactStrokeStyles\" ? null : \"compactStrokeStyles\"\n });\n }\n }, _icons__WEBPACK_IMPORTED_MODULE_19__.adjustmentsIcon)), appState.openPopup === \"compactStrokeStyles\" && React.createElement(_PropertiesPopover__WEBPACK_IMPORTED_MODULE_18__.PropertiesPopover, {\n className: PROPERTIES_CLASSES,\n container: container,\n style: {\n maxWidth: \"13rem\"\n },\n onClose: () => {}\n }, React.createElement(\"div\", {\n className: \"selected-shape-actions\"\n }, showFillIcons && renderAction(\"changeFillStyle\"), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeWidth)(element.type))) && renderAction(\"changeStrokeWidth\"), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.hasStrokeStyle)(element.type))) && React.createElement(React.Fragment, null, renderAction(\"changeStrokeStyle\"), renderAction(\"changeSloppiness\")), ((0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(appState.activeTool.type) || targetElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_9__.canChangeRoundness)(element.type))) && renderAction(\"changeRoundness\"), showToggleFrameRoleAction && React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_FRAME\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, renderAction(\"toggleFrameRole\"))), renderAction(\"changeOpacity\"))))), ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.toolIsArrow)(appState.activeTool.type) || targetElements.some(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.toolIsArrow)(element.type))) && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Root, {\n open: appState.openPopup === \"compactArrowProperties\",\n onOpenChange: open => {\n if (open) {\n setAppState({\n openPopup: \"compactArrowProperties\"\n });\n } else {\n setAppState({\n openPopup: null\n });\n }\n }\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Trigger, {\n asChild: true\n }, React.createElement(\"button\", {\n type: \"button\",\n className: \"compact-action-button properties-trigger\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.arrowtypes\"),\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n setAppState({\n openPopup: appState.openPopup === \"compactArrowProperties\" ? null : \"compactArrowProperties\"\n });\n }\n }, (() => {\n // Show an icon based on the current arrow type\n const arrowType = (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_10__.getFormValue)(targetElements, app, element => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isArrowElement)(element)) {\n return element.elbowed ? \"elbow\" : element.roundness ? \"round\" : \"sharp\";\n }\n\n return null;\n }, element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isArrowElement)(element), hasSelection => hasSelection ? null : appState.currentItemArrowType);\n\n if (arrowType === \"elbow\") {\n return _icons__WEBPACK_IMPORTED_MODULE_19__.elbowArrowIcon;\n }\n\n if (arrowType === \"round\") {\n return _icons__WEBPACK_IMPORTED_MODULE_19__.roundArrowIcon;\n }\n\n return _icons__WEBPACK_IMPORTED_MODULE_19__.sharpArrowIcon;\n })())), appState.openPopup === \"compactArrowProperties\" && React.createElement(_PropertiesPopover__WEBPACK_IMPORTED_MODULE_18__.PropertiesPopover, {\n container: container,\n className: \"properties-content\",\n style: {\n maxWidth: \"13rem\"\n },\n onClose: () => {}\n }, renderAction(\"changeArrowProperties\")))), showLineEditorAction && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, renderAction(\"toggleLinearEditor\")), (appState.activeTool.type === \"text\" || targetElements.some(_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isTextElement)) && React.createElement(React.Fragment, null, React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, renderAction(\"changeFontFamily\")), React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Root, {\n open: appState.openPopup === \"compactTextProperties\",\n onOpenChange: open => {\n if (open) {\n if (appState.editingTextElement) {\n saveCaretPosition();\n }\n\n setAppState({\n openPopup: \"compactTextProperties\"\n });\n } else {\n setAppState({\n openPopup: null\n });\n\n if (appState.editingTextElement) {\n restoreCaretPosition();\n }\n }\n }\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Trigger, {\n asChild: true\n }, React.createElement(\"button\", {\n type: \"button\",\n className: \"compact-action-button properties-trigger\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.textAlign\"),\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n\n if (appState.openPopup === \"compactTextProperties\") {\n setAppState({\n openPopup: null\n });\n } else {\n if (appState.editingTextElement) {\n saveCaretPosition();\n }\n\n setAppState({\n openPopup: \"compactTextProperties\"\n });\n }\n }\n }, _icons__WEBPACK_IMPORTED_MODULE_19__.TextSizeIcon)), appState.openPopup === \"compactTextProperties\" && React.createElement(_PropertiesPopover__WEBPACK_IMPORTED_MODULE_18__.PropertiesPopover, {\n className: PROPERTIES_CLASSES,\n container: container,\n style: {\n maxWidth: \"13rem\"\n },\n // Improve focus handling for text editing scenarios\n preventAutoFocusOnTouch: !!appState.editingTextElement,\n onClose: () => {\n // Refocus text editor when popover closes with caret restoration\n if (appState.editingTextElement) {\n restoreCaretPosition();\n }\n }\n }, React.createElement(\"div\", {\n className: \"selected-shape-actions\"\n }, (appState.activeTool.type === \"text\" || targetElements.some(_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.isTextElement)) && renderAction(\"changeFontSize\"), (appState.activeTool.type === \"text\" || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.suppportsHorizontalAlign)(targetElements, elementsMap)) && renderAction(\"changeTextAlign\"), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.shouldAllowVerticalAlign)(targetElements, elementsMap) && renderAction(\"changeVerticalAlign\")))))), !isEditingTextOrNewElement && targetElements.length > 0 && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, renderAction(\"duplicateSelection\")), !isEditingTextOrNewElement && targetElements.length > 0 && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, renderAction(\"deleteSelectedElements\")), !isEditingTextOrNewElement && targetElements.length > 0 && React.createElement(\"div\", {\n className: \"compact-action-item\"\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Root, {\n open: appState.openPopup === \"compactOtherProperties\",\n onOpenChange: open => {\n if (open) {\n setAppState({\n openPopup: \"compactOtherProperties\"\n });\n } else {\n setAppState({\n openPopup: null\n });\n }\n }\n }, React.createElement(_radix_ui_react_popover__WEBPACK_IMPORTED_MODULE_21__.Trigger, {\n asChild: true\n }, React.createElement(\"button\", {\n type: \"button\",\n className: \"compact-action-button properties-trigger\",\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.actions\"),\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n setAppState({\n openPopup: appState.openPopup === \"compactOtherProperties\" ? null : \"compactOtherProperties\"\n });\n }\n }, _icons__WEBPACK_IMPORTED_MODULE_19__.DotsHorizontalIcon)), appState.openPopup === \"compactOtherProperties\" && React.createElement(_PropertiesPopover__WEBPACK_IMPORTED_MODULE_18__.PropertiesPopover, {\n className: PROPERTIES_CLASSES,\n container: container,\n style: {\n maxWidth: \"12rem\",\n // center the popover content\n justifyContent: \"center\",\n alignItems: \"center\"\n },\n onClose: () => {}\n }, React.createElement(\"div\", {\n className: \"selected-shape-actions\"\n }, React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.layers\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, renderAction(\"sendToBack\"), renderAction(\"sendBackward\"), renderAction(\"bringForward\"), renderAction(\"bringToFront\"))), showAlignActions && !isSingleElementBoundContainer && React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.align\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, isRTL ? React.createElement(React.Fragment, null, renderAction(\"alignRight\"), renderAction(\"alignHorizontallyCentered\"), renderAction(\"alignLeft\")) : React.createElement(React.Fragment, null, renderAction(\"alignLeft\"), renderAction(\"alignHorizontallyCentered\"), renderAction(\"alignRight\")), targetElements.length > 2 && renderAction(\"distributeHorizontally\"), React.createElement(\"div\", {\n style: {\n flexBasis: \"100%\",\n height: 0\n }\n }), React.createElement(\"div\", {\n style: {\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: \".5rem\",\n marginTop: \"-0.5rem\"\n }\n }, renderAction(\"alignTop\"), renderAction(\"alignVerticallyCentered\"), renderAction(\"alignBottom\"), targetElements.length > 2 && renderAction(\"distributeVertically\")))), React.createElement(\"fieldset\", null, React.createElement(\"legend\", null, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"labels.actions\")), React.createElement(\"div\", {\n className: \"buttonList\"\n }, renderAction(\"group\"), renderAction(\"ungroup\"), showLinkIcon && renderAction(\"hyperlink\"), showCropEditorAction && renderAction(\"cropEditor\"))))))));\n};\nconst ShapesSwitcher = ({\n activeTool,\n appState,\n app,\n UIOptions\n}) => {\n const {\n renderMermaid\n } = (0,_App__WEBPACK_IMPORTED_MODULE_14__.useAppProps)(); //zsviczian\n\n const [isExtraToolsMenuOpen, setIsExtraToolsMenuOpen] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);\n const [isImageMenuOpen, setIsImageMenuOpen] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false); //zsviczian\n\n const frameToolSelected = activeTool.type === \"frame\";\n const laserToolSelected = activeTool.type === \"laser\";\n const lassoToolSelected = activeTool.type === \"lasso\" && app.defaultSelectionTool !== \"lasso\";\n const embeddableToolSelected = activeTool.type === \"embeddable\";\n const {\n TTDDialogTriggerTunnel\n } = (0,_context_tunnels__WEBPACK_IMPORTED_MODULE_7__.useTunnels)();\n return React.createElement(React.Fragment, null, (0,_shapes__WEBPACK_IMPORTED_MODULE_12__.getToolbarTools)(app).map(({\n value,\n icon,\n key,\n numericKey,\n fillable\n }, index) => {\n var _a;\n\n if (((_a = UIOptions.tools) === null || _a === void 0 ? void 0 : _a[value]) === false) {\n return null;\n }\n\n const label = (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(`toolBar.${value}`);\n const letter = key && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.capitalizeString)(typeof key === \"string\" ? key : key[0]);\n const shortcut = letter ? `${letter} ${(0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"helpDialog.or\")} ${numericKey}` : `${numericKey}`;\n return React.createElement(_ToolButton__WEBPACK_IMPORTED_MODULE_16__.ToolButton, {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"Shape\", {\n fillable\n }),\n key: value,\n type: \"radio\",\n icon: icon,\n checked: activeTool.type === value,\n name: \"editor-current-shape\",\n title: `${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.capitalizeString)(label)} — ${shortcut}`,\n keyBindingLabel: numericKey || letter,\n \"aria-label\": (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.capitalizeString)(label),\n \"aria-keyshortcuts\": shortcut,\n \"data-testid\": `toolbar-${value}`,\n onPointerDown: ({\n pointerType\n }) => {\n if (!appState.penDetected && pointerType === \"pen\") {\n app.togglePenMode(true);\n }\n\n if (value === \"selection\") {\n if (appState.activeTool.type === \"selection\") {\n app.setActiveTool({\n type: \"lasso\"\n });\n } else {\n app.setActiveTool({\n type: \"selection\"\n });\n }\n }\n },\n onChange: ({\n pointerType\n }) => {\n if (appState.activeTool.type !== value) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_6__.trackEvent)(\"toolbar\", value, \"ui\");\n }\n /*if (value === \"image\") {\r\n app.setActiveTool({\r\n type: value,\r\n });\r\n } else {*/\n //zsviczian moved Image action to dropdown menu\n\n\n app.setActiveTool({\n type: value\n }); //}\n }\n });\n }), React.createElement(\"div\", {\n className: \"App-toolbar__divider\"\n }), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"], {\n open: isImageMenuOpen\n }, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Trigger, {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"App-toolbar__extra-tools-trigger\"),\n onToggle: () => {\n if (!isImageMenuOpen) {\n setIsExtraToolsMenuOpen(false);\n }\n\n setIsImageMenuOpen(!isImageMenuOpen);\n },\n title: (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_IMG\")\n }, _icons__WEBPACK_IMPORTED_MODULE_19__.ImageIcon), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Content, {\n onClickOutside: () => setIsImageMenuOpen(false),\n onSelect: () => setIsImageMenuOpen(false),\n className: \"App-toolbar__extra-tools-dropdown\"\n }, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setActiveTool({\n type: \"image\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.ImageIcon,\n \"data-testid\": \"toolbar-image-import\"\n }, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_IMG_FROM_SYSTEM\")), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.runAction)(\"anyFile\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.InsertAnyFileIcon,\n \"data-testid\": \"toolbar-any-file\"\n }, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_IMG_ANY_FILE\")), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.runAction)(\"card\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.Card,\n \"data-testid\": \"toolbar-card\"\n }, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"INSERT_CARD\")), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.runAction)(\"LaTeX\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.LaTeXIcon,\n \"data-testid\": \"toolbar-latex\"\n }, (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_20__.t2)(\"COMP_IMG_LaTeX\")))), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"], {\n open: isExtraToolsMenuOpen\n }, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Trigger, {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"App-toolbar__extra-tools-trigger\", {\n \"App-toolbar__extra-tools-trigger--selected\": frameToolSelected || embeddableToolSelected || lassoToolSelected || // in collab we're already highlighting the laser button\n // outside toolbar, so let's not highlight extra-tools button\n // on top of it\n laserToolSelected && !app.props.isCollaborating\n }),\n onToggle: () => {\n if (!isExtraToolsMenuOpen) {\n setIsImageMenuOpen(false);\n }\n\n setIsExtraToolsMenuOpen(!isExtraToolsMenuOpen);\n },\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.extraTools\")\n }, frameToolSelected ? _icons__WEBPACK_IMPORTED_MODULE_19__.frameToolIcon : embeddableToolSelected ? _icons__WEBPACK_IMPORTED_MODULE_19__.EmbedIcon : laserToolSelected && !app.props.isCollaborating ? _icons__WEBPACK_IMPORTED_MODULE_19__.laserPointerToolIcon : lassoToolSelected ? _icons__WEBPACK_IMPORTED_MODULE_19__.LassoIcon : _icons__WEBPACK_IMPORTED_MODULE_19__.extraToolsIcon), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Content, {\n onClickOutside: () => setIsExtraToolsMenuOpen(false),\n onSelect: () => setIsExtraToolsMenuOpen(false),\n className: \"App-toolbar__extra-tools-dropdown\"\n }, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setActiveTool({\n type: \"frame\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.frameToolIcon,\n shortcut: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.KEYS.F.toLocaleUpperCase(),\n \"data-testid\": \"toolbar-frame\",\n selected: frameToolSelected\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.frame\")), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setActiveTool({\n type: \"embeddable\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.EmbedIcon,\n \"data-testid\": \"toolbar-embeddable\",\n selected: embeddableToolSelected\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.embeddable\")), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setActiveTool({\n type: \"laser\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.laserPointerToolIcon,\n \"data-testid\": \"toolbar-laser\",\n selected: laserToolSelected,\n shortcut: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.KEYS.K.toLocaleUpperCase()\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.laser\")), app.defaultSelectionTool !== \"lasso\" && React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setActiveTool({\n type: \"lasso\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.LassoIcon,\n \"data-testid\": \"toolbar-lasso\",\n selected: lassoToolSelected\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.lasso\")), React.createElement(\"div\", {\n style: {\n margin: \"6px 0\",\n fontSize: 14,\n fontWeight: 600\n }\n }, \"Generate\"), app.props.aiEnabled !== false && React.createElement(TTDDialogTriggerTunnel.Out, null), renderMermaid && //zsviczian\n React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.setOpenDialog({\n name: \"ttd\",\n tab: \"mermaid\"\n }),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.mermaidLogoIcon,\n \"data-testid\": \"toolbar-embeddable\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.mermaidToExcalidraw\")), app.props.aiEnabled !== false && app.plugins.diagramToCode && React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item, {\n onSelect: () => app.onMagicframeToolSelect(),\n icon: _icons__WEBPACK_IMPORTED_MODULE_19__.MagicIcon,\n \"data-testid\": \"toolbar-magicframe\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"toolBar.magicframe\"), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_17__[\"default\"].Item.Badge, null, \"AI\")))));\n};\nconst ZoomActions = ({\n renderAction,\n zoom,\n trayMode = false //zsviczian\n\n}) => React.createElement(_Stack__WEBPACK_IMPORTED_MODULE_15__[\"default\"].Col, {\n gap: 1,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.CLASSES.ZOOM_ACTIONS, {\n \"tray-zoom\": trayMode\n })\n}, React.createElement(_Stack__WEBPACK_IMPORTED_MODULE_15__[\"default\"].Row, {\n align: \"center\"\n}, renderAction(\"zoomOut\"), renderAction(\"resetZoom\"), renderAction(\"zoomIn\")));\nconst UndoRedoActions = ({\n renderAction,\n className\n}) => React.createElement(\"div\", {\n className: `undo-redo-buttons ${className}`\n}, React.createElement(\"div\", {\n className: \"undo-button-container\"\n}, renderAction(\"undo\")\n/* //zsviczian */\n), React.createElement(\"div\", {\n className: \"redo-button-container\"\n}, renderAction(\"redo\")\n/* //zsviczian */\n));\nconst ExitZenModeAction = ({\n actionManager,\n showExitZenModeBtn\n}) => React.createElement(\"button\", {\n type: \"button\",\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"disable-zen-mode\", {\n \"disable-zen-mode--visible\": showExitZenModeBtn\n }),\n onClick: () => actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_4__.actionToggleZenMode)\n}, (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.t)(\"buttons.exitZenMode\"));\n\n//# sourceURL=webpack://ExcalidrawLib/./components/Actions.tsx?");
14261
14261
 
14262
14262
  /***/ }),
14263
14263
 
@@ -14279,7 +14279,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
14279
14279
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14280
14280
 
14281
14281
  "use strict";
14282
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExcalidrawContainerContext: () => (/* binding */ ExcalidrawContainerContext),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ useApp: () => (/* binding */ useApp),\n/* harmony export */ useAppProps: () => (/* binding */ useAppProps),\n/* harmony export */ useDevice: () => (/* binding */ useDevice),\n/* harmony export */ useExcalidrawActionManager: () => (/* binding */ useExcalidrawActionManager),\n/* harmony export */ useExcalidrawAppState: () => (/* binding */ useExcalidrawAppState),\n/* harmony export */ useExcalidrawContainer: () => (/* binding */ useExcalidrawContainer),\n/* harmony export */ useExcalidrawElements: () => (/* binding */ useExcalidrawElements),\n/* harmony export */ useExcalidrawSetAppState: () => (/* binding */ useExcalidrawSetAppState)\n/* harmony export */ });\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var lodash_throttle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash.throttle */ \"../../node_modules/lodash.throttle/index.js\");\n/* harmony import */ var lodash_throttle__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_throttle__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-dom */ \"react-dom\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! roughjs/bin/rough */ \"../../node_modules/roughjs/bin/rough.js\");\n/* harmony import */ var nanoid__WEBPACK_IMPORTED_MODULE_72__ = __webpack_require__(/*! nanoid */ \"./node_modules/nanoid/index.browser.js\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../actions/actionBoundText */ \"./actions/actionBoundText.tsx\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n/* harmony import */ var _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../actions/actionClipboard */ \"./actions/actionClipboard.tsx\");\n/* harmony import */ var _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../actions/actionElementLink */ \"./actions/actionElementLink.ts\");\n/* harmony import */ var _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../actions/actionElementLock */ \"./actions/actionElementLock.ts\");\n/* harmony import */ var _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../actions/actionFrame */ \"./actions/actionFrame.ts\");\n/* harmony import */ var _actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../actions/actionHistory */ \"./actions/actionHistory.tsx\");\n/* harmony import */ var _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../actions/actionTextAutoResize */ \"./actions/actionTextAutoResize.ts\");\n/* harmony import */ var _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../actions/actionToggleViewMode */ \"./actions/actionToggleViewMode.tsx\");\n/* harmony import */ var _actions_manager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../actions/manager */ \"./actions/manager.tsx\");\n/* harmony import */ var _actions_register__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../actions/register */ \"./actions/register.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _animation_frame_handler__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../animation-frame-handler */ \"./animation-frame-handler.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../data */ \"./data/index.ts\");\n/* harmony import */ var _data_library__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../data/library */ \"./data/library.ts\");\n/* harmony import */ var _data_restore__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../data/restore */ \"./data/restore.ts\");\n/* harmony import */ var _gesture__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../gesture */ \"./gesture.ts\");\n/* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ../history */ \"./history.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _scene_zoom__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ../scene/zoom */ \"./scene/zoom.ts\");\n/* harmony import */ var _data_blob__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ../data/blob */ \"./data/blob.ts\");\n/* harmony import */ var _data_filesystem__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ../data/filesystem */ \"./data/filesystem.ts\");\n/* harmony import */ var _components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ../components/hyperlink/Hyperlink */ \"./components/hyperlink/Hyperlink.tsx\");\n/* harmony import */ var _fonts__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ../fonts */ \"./fonts/index.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ../errors */ \"./errors.ts\");\n/* harmony import */ var _snapping__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ../snapping */ \"./snapping.ts\");\n/* harmony import */ var _data_transform__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ../data/transform */ \"./data/transform.ts\");\n/* harmony import */ var _scene_Renderer__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ../scene/Renderer */ \"./scene/Renderer.ts\");\n/* harmony import */ var _cursor__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ../cursor */ \"./cursor.ts\");\n/* harmony import */ var _components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ../components/ElementCanvasButtons */ \"./components/ElementCanvasButtons.tsx\");\n/* harmony import */ var _laser_trails__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ../laser-trails */ \"./laser-trails.ts\");\n/* harmony import */ var _reactUtils__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ../reactUtils */ \"./reactUtils.ts\");\n/* harmony import */ var _wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ../wysiwyg/textWysiwyg */ \"./wysiwyg/textWysiwyg.tsx\");\n/* harmony import */ var _scene_scrollbars__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ../scene/scrollbars */ \"./scene/scrollbars.ts\");\n/* harmony import */ var _mermaid__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ../mermaid */ \"./mermaid.ts\");\n/* harmony import */ var _lasso__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ../lasso */ \"./lasso/index.ts\");\n/* harmony import */ var _eraser__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(/*! ../eraser */ \"./eraser/index.ts\");\n/* harmony import */ var _ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(/*! ./ConvertElementTypePopup */ \"./components/ConvertElementTypePopup.tsx\");\n/* harmony import */ var _ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(/*! ./ActiveConfirmDialog */ \"./components/ActiveConfirmDialog.tsx\");\n/* harmony import */ var _BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(/*! ./BraveMeasureTextError */ \"./components/BraveMeasureTextError.tsx\");\n/* harmony import */ var _ContextMenu__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(/*! ./ContextMenu */ \"./components/ContextMenu.tsx\");\n/* harmony import */ var _EyeDropper__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(/*! ./EyeDropper */ \"./components/EyeDropper.tsx\");\n/* harmony import */ var _FollowMode_FollowMode__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(/*! ./FollowMode/FollowMode */ \"./components/FollowMode/FollowMode.tsx\");\n/* harmony import */ var _LayerUI__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(/*! ./LayerUI */ \"./components/LayerUI.tsx\");\n/* harmony import */ var _MagicButton__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(/*! ./MagicButton */ \"./components/MagicButton.tsx\");\n/* harmony import */ var _SVGLayer__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(/*! ./SVGLayer */ \"./components/SVGLayer.tsx\");\n/* harmony import */ var _SearchMenu__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(/*! ./SearchMenu */ \"./components/SearchMenu.tsx\");\n/* harmony import */ var _Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(/*! ./Sidebar/Sidebar */ \"./components/Sidebar/Sidebar.tsx\");\n/* harmony import */ var _canvases__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(/*! ./canvases */ \"./components/canvases/index.tsx\");\n/* harmony import */ var _canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(/*! ./canvases/NewElementCanvas */ \"./components/canvases/NewElementCanvas.tsx\");\n/* harmony import */ var _hyperlink_helpers__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(/*! ./hyperlink/helpers */ \"./components/hyperlink/helpers.ts\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _Toast__WEBPACK_IMPORTED_MODULE_66__ = __webpack_require__(/*! ./Toast */ \"./components/Toast.tsx\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_67__ = __webpack_require__(/*! ./shapes */ \"./components/shapes.tsx\");\n/* harmony import */ var _UnlockPopup__WEBPACK_IMPORTED_MODULE_68__ = __webpack_require__(/*! ./UnlockPopup */ \"./components/UnlockPopup.tsx\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_69__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _Tooltip__WEBPACK_IMPORTED_MODULE_70__ = __webpack_require__(/*! ./Tooltip */ \"./components/Tooltip.tsx\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_71__ = __webpack_require__(/*! ../actions/actionProperties */ \"./actions/actionProperties.tsx\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst AppContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst AppPropsContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst deviceContextInitialValue = {\n viewport: {\n isMobile: false,\n isLandscape: false\n },\n editor: {\n isMobile: false,\n canFitSidebar: false\n },\n isTouchScreen: false\n};\nconst DeviceContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(deviceContextInitialValue);\nDeviceContext.displayName = \"DeviceContext\";\nconst ExcalidrawContainerContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext({\n container: null,\n id: null\n});\nExcalidrawContainerContext.displayName = \"ExcalidrawContainerContext\";\nconst ExcalidrawElementsContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext([]);\nExcalidrawElementsContext.displayName = \"ExcalidrawElementsContext\";\nconst ExcalidrawAppStateContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_23__.getDefaultAppState)()), {\n width: 0,\n height: 0,\n offsetLeft: 0,\n offsetTop: 0\n}));\nExcalidrawAppStateContext.displayName = \"ExcalidrawAppStateContext\";\nconst ExcalidrawSetAppStateContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(() => {\n console.warn(\"Uninitialized ExcalidrawSetAppStateContext context!\");\n});\nExcalidrawSetAppStateContext.displayName = \"ExcalidrawSetAppStateContext\";\nconst ExcalidrawActionManagerContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nExcalidrawActionManagerContext.displayName = \"ExcalidrawActionManagerContext\";\nconst useApp = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppContext);\nconst useAppProps = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppPropsContext);\nconst useDevice = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(DeviceContext);\nconst useExcalidrawContainer = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawContainerContext);\nconst useExcalidrawElements = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawElementsContext);\nconst useExcalidrawAppState = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawAppStateContext);\nconst useExcalidrawSetAppState = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawSetAppStateContext);\nconst useExcalidrawActionManager = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawActionManagerContext);\nlet didTapTwice = false;\nlet tappedTwiceTimer = 0;\nlet firstTapPosition = null;\nlet isHoldingSpace = false;\nlet isPanning = false;\nlet isDraggingScrollBar = false;\nlet currentScrollBars = {\n horizontal: null,\n vertical: null\n};\nlet touchTimeout = 0;\nlet invalidateContextMenu = false;\n/**\r\n * Map of youtube embed video states\r\n */\n\nconst YOUTUBE_VIDEO_STATES = new Map();\nlet IS_PLAIN_PASTE = false;\nlet IS_PLAIN_PASTE_TIMER = 0;\nlet PLAIN_PASTE_TOAST_SHOWN = false;\nlet lastPointerUp = null;\nconst gesture = {\n pointers: new Map(),\n lastCenter: null,\n initialDistance: null,\n initialScale: null\n};\n\nclass App extends (react__WEBPACK_IMPORTED_MODULE_2___default().Component) {\n constructor(props) {\n super(props);\n this.interactiveCanvas = null;\n this.unmounted = false;\n this.device = deviceContextInitialValue;\n this.excalidrawContainerRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createRef();\n this.shouldRenderAllEmbeddables = false; //zsviczian\n\n this.files = {};\n this.imageCache = new Map();\n this.iFrameRefs = new Map();\n /**\r\n * Indicates whether the embeddable's url has been validated for rendering.\r\n * If value not set, indicates that the validation is pending.\r\n * Initially or on url change the flag is not reset so that we can guarantee\r\n * the validation came from a trusted source (the editor).\r\n **/\n\n this.embedsValidationStatus = new Map();\n /** embeds that have been inserted to DOM (as a perf optim, we don't want to\r\n * insert to DOM before user initially scrolls to them) */\n\n this.initializedEmbeds = new Set();\n\n this.handleToastClose = () => {\n this.setToast(null);\n };\n\n this.elementsPendingErasure = new Set();\n this.flowChartCreator = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.FlowChartCreator();\n this.flowChartNavigator = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.FlowChartNavigator();\n this.lastPointerDownEvent = null;\n this.lastPointerUpEvent = null;\n this.lastPointerMoveEvent = null;\n this.lastPointerMoveCoords = null;\n this.lastViewportPosition = {\n x: 0,\n y: 0\n };\n this.allowMobileMode = true; //zsviczian\n\n this.animationFrameHandler = new _animation_frame_handler__WEBPACK_IMPORTED_MODULE_22__.AnimationFrameHandler();\n this.laserTrails = new _laser_trails__WEBPACK_IMPORTED_MODULE_44__.LaserTrails(this.animationFrameHandler, this);\n this.eraserTrail = new _eraser__WEBPACK_IMPORTED_MODULE_50__.EraserTrail(this.animationFrameHandler, this);\n this.lassoTrail = new _lasso__WEBPACK_IMPORTED_MODULE_49__.LassoTrail(this.animationFrameHandler, this);\n this.onChangeEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onPointerDownEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onPointerUpEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onUserFollowEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onScrollChangeEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.missingPointerEventCleanupEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onRemoveEventListenersEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.defaultSelectionTool = \"selection\";\n\n this.updateEditorAtom = (atom, ...args) => {\n const result = _editor_jotai__WEBPACK_IMPORTED_MODULE_37__.editorJotaiStore.set(atom, ...args);\n this.triggerRender();\n return result;\n };\n /**\r\n * Returns gridSize taking into account `gridModeEnabled`.\r\n * If disabled, returns null.\r\n */\n\n\n this.getEffectiveGridSize = () => {\n return (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.isGridModeEnabled)(this) ? this.state.gridSize : null;\n };\n\n this.updateEmbedValidationStatus = (element, status) => {\n this.embedsValidationStatus.set(element.id, status);\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element);\n };\n\n this.updateEmbeddables = () => {\n const iframeLikes = new Set();\n let updated = false;\n this.scene.getNonDeletedElements().filter(element => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(element)) {\n iframeLikes.add(element.id);\n\n if (!this.embedsValidationStatus.has(element.id)) {\n updated = true;\n const validated = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(element.link, this.props.validateEmbeddable);\n this.updateEmbedValidationStatus(element, validated);\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(element)) {\n iframeLikes.add(element.id);\n }\n\n return false;\n });\n\n if (updated) {\n this.scene.triggerUpdate();\n } // GC\n\n\n this.iFrameRefs.forEach((ref, id) => {\n if (!iframeLikes.has(id)) {\n this.iFrameRefs.delete(id);\n }\n });\n };\n\n this.getFrameNameDOMId = frameElement => {\n return `${this.id}-frame-name-${frameElement.id}`;\n };\n\n this.frameNameBoundsCache = {\n get: frameElement => {\n let bounds = this.frameNameBoundsCache._cache.get(frameElement.id);\n\n if (!bounds || bounds.zoom !== this.state.zoom.value || bounds.versionNonce !== frameElement.versionNonce) {\n const frameNameDiv = document.getElementById(this.getFrameNameDOMId(frameElement));\n\n if (frameNameDiv) {\n const box = frameNameDiv.getBoundingClientRect();\n const boxSceneTopLeft = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: box.x,\n clientY: box.y\n }, this.state);\n const boxSceneBottomRight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: box.right,\n clientY: box.bottom\n }, this.state);\n bounds = {\n x: boxSceneTopLeft.x,\n y: boxSceneTopLeft.y,\n width: boxSceneBottomRight.x - boxSceneTopLeft.x,\n height: boxSceneBottomRight.y - boxSceneTopLeft.y,\n angle: 0,\n zoom: this.state.zoom.value,\n versionNonce: frameElement.versionNonce\n };\n\n this.frameNameBoundsCache._cache.set(frameElement.id, bounds);\n\n return bounds;\n }\n\n return null;\n }\n\n return bounds;\n },\n\n /**\r\n * @private\r\n */\n _cache: new Map()\n };\n\n this.resetEditingFrame = frame => {\n var _a;\n\n if (frame) {\n this.scene.mutateElement(frame, {\n name: ((_a = frame.name) === null || _a === void 0 ? void 0 : _a.trim()) || null\n });\n }\n\n this.setState({\n editingFrame: null\n });\n };\n\n this.renderFrameNames = () => {\n var _a;\n\n if (!this.state.frameRendering.enabled || !this.state.frameRendering.name) {\n if (this.state.editingFrame) {\n this.resetEditingFrame(null);\n }\n\n return null;\n }\n\n const isDarkTheme = this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK; //zsviczian\n\n const nonDeletedFramesLikes = this.state.frameRendering.markerName && this.state.frameRendering.markerEnabled ? this.scene.getNonDeletedFramesLikes() : this.scene.getNonDeletedFramesLikes().filter(f => f.frameRole !== \"marker\");\n const focusedSearchMatch = nonDeletedFramesLikes.length > 0 ? ((_a = this.state.searchMatches) === null || _a === void 0 ? void 0 : _a.focusedId) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(this.scene.getElement(this.state.searchMatches.focusedId)) ? this.state.searchMatches.matches.find(sm => sm.focus) : null : null;\n return nonDeletedFramesLikes.map(f => {\n var _a, _b;\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInViewport)(f, this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap())) {\n if (this.state.editingFrame === f.id) {\n this.resetEditingFrame(f);\n } // if frame not visible, don't render its name\n\n\n return null;\n }\n\n const {\n x: x1,\n y: y1\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.sceneCoordsToViewportCoords)({\n sceneX: f.x,\n sceneY: f.y\n }, this.state);\n const FRAME_NAME_EDIT_PADDING = 6;\n let frameNameJSX;\n const frameName = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getFrameLikeTitle)(f);\n\n if (f.id === this.state.editingFrame) {\n const frameNameInEdit = frameName;\n frameNameJSX = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"input\", {\n autoFocus: true,\n value: frameNameInEdit,\n onChange: e => {\n this.scene.mutateElement(f, {\n name: e.target.value\n });\n },\n onFocus: e => e.target.select(),\n onBlur: () => this.resetEditingFrame(f),\n onKeyDown: event => {\n // for some inexplicable reason, `onBlur` triggered on ESC\n // does not reset `state.editingFrame` despite being called,\n // and we need to reset it here as well\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) {\n this.resetEditingFrame(f);\n }\n },\n style: {\n background: this.state.viewBackgroundColor,\n filter: isDarkTheme ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME_FILTER : \"none\",\n zIndex: 2,\n border: \"none\",\n display: \"block\",\n padding: `${FRAME_NAME_EDIT_PADDING}px`,\n borderRadius: 4,\n boxShadow: \"inset 0 0 0 2px var(--color-on-primary-container)\",\n fontFamily: \"Assistant\",\n fontSize: `${_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameFontSize}px`,\n transform: `translate(-${FRAME_NAME_EDIT_PADDING}px, ${FRAME_NAME_EDIT_PADDING}px)`,\n color: \"var(--color-gray-80)\",\n overflow: \"hidden\",\n maxWidth: `${(0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.getExcalidrawContentEl)().clientWidth - x1 - FRAME_NAME_EDIT_PADDING //zsviczian was document.body\n }px`\n },\n size: frameNameInEdit.length + 1 || 1,\n dir: \"auto\",\n autoComplete: \"off\",\n autoCapitalize: \"off\",\n autoCorrect: \"off\"\n });\n } else {\n frameNameJSX = frameName;\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n id: this.getFrameNameDOMId(f),\n key: f.id,\n style: {\n position: \"absolute\",\n // Positioning from bottom so that we don't to either\n // calculate text height or adjust using transform (which)\n // messes up input position when editing the frame name.\n // This makes the positioning deterministic and we can calculate\n // the same position when rendering to canvas / svg.\n bottom: `${this.state.height + _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameOffsetY - y1 + this.state.offsetTop}px`,\n left: `${x1 - this.state.offsetLeft}px`,\n zIndex: 2,\n fontSize: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameFontSize,\n color: (_b = (_a = this.state.frameColor) === null || _a === void 0 ? void 0 : _a.nameColor) !== null && _b !== void 0 ? _b : isDarkTheme //zsviczian\n ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameColorDarkTheme : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameColorLightTheme,\n lineHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameLineHeight,\n width: \"max-content\",\n maxWidth: (focusedSearchMatch === null || focusedSearchMatch === void 0 ? void 0 : focusedSearchMatch.id) === f.id && (focusedSearchMatch === null || focusedSearchMatch === void 0 ? void 0 : focusedSearchMatch.focus) ? \"none\" : `${f.width * this.state.zoom.value}px`,\n overflow: f.id === this.state.editingFrame ? \"visible\" : \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n cursor: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE,\n pointerEvents: this.state.viewModeEnabled ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.enabled\n },\n onPointerDown: event => this.handleCanvasPointerDown(event),\n onWheel: event => this.handleWheel(event),\n onContextMenu: this.handleCanvasContextMenu,\n onDoubleClick: () => {\n this.setState({\n editingFrame: f.id\n });\n }\n }, frameNameJSX);\n });\n };\n\n this.focusContainer = () => {\n var _a;\n\n (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.focus();\n };\n\n this.getSceneElementsIncludingDeleted = () => {\n return this.scene.getElementsIncludingDeleted();\n };\n\n this.getSceneElementsMapIncludingDeleted = () => {\n return this.scene.getElementsMapIncludingDeleted();\n };\n\n this.getSceneElements = () => {\n return this.scene.getNonDeletedElements();\n };\n\n this.onInsertElements = elements => {\n this.addElementsFromPasteOrLibrary({\n elements,\n position: \"center\",\n files: null\n });\n };\n\n this.onExportImage = async (type, elements, opts) => {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"export\", type, \"ui\");\n const fileHandle = await (0,_data__WEBPACK_IMPORTED_MODULE_25__.exportCanvas)(type, elements, this.state, this.files, {\n exportBackground: this.state.exportBackground,\n name: this.getName(),\n viewBackgroundColor: this.state.viewBackgroundColor,\n exportingFrame: opts.exportingFrame\n }).catch(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.muteFSAbortError).catch(error => {\n console.error(error);\n this.setState({\n errorMessage: error.message\n });\n });\n\n if (this.state.exportEmbedScene && fileHandle && (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.isImageFileHandle)(fileHandle)) {\n this.setState({\n fileHandle\n });\n }\n };\n\n this.magicGenerations = new Map();\n\n this.updateMagicGeneration = ({\n frameElement,\n data\n }) => {\n if (data.status === \"pending\") {\n // We don't wanna persist pending state to storage. It should be in-app\n // state only.\n // Thus reset so that we prefer local cache (if there was some\n // generationData set previously)\n this.scene.mutateElement(frameElement, {\n customData: {\n generationData: undefined\n }\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n this.scene.mutateElement(frameElement, {\n customData: {\n generationData: data\n }\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n\n this.magicGenerations.set(frameElement.id, data);\n this.triggerRender();\n };\n\n this.plugins = {};\n\n this.onMagicframeToolSelect = () => {\n const selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds\n });\n\n if (selectedElements.length === 0) {\n this.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"tool-select (empty-selection)\", \"d2c\");\n } else {\n const selectedMagicFrame = selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isMagicFrameElement)(selectedElements[0]) && selectedElements[0]; // case: user selected elements containing frame-like(s) or are frame\n // members, we don't want to wrap into another magicframe\n // (unless the only selected element is a magic frame which we reuse)\n\n if (!selectedMagicFrame && selectedElements.some(el => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(el) || el.frameId)) {\n this.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe\n });\n return;\n }\n\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"tool-select (existing selection)\", \"d2c\");\n let frame;\n\n if (selectedMagicFrame) {\n // a single magicframe already selected -> use it\n frame = selectedMagicFrame;\n } else {\n // selected elements aren't wrapped in magic frame yet -> wrap now\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n const padding = 50;\n frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newMagicFrameElement)(Object.assign(Object.assign({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE), {\n x: minX - padding,\n y: minY - padding,\n width: maxX - minX + padding * 2,\n height: maxY - minY + padding * 2,\n opacity: 100,\n locked: false\n }));\n this.scene.insertElement(frame);\n\n for (const child of selectedElements) {\n this.scene.mutateElement(child, {\n frameId: frame.id\n });\n }\n\n this.setState({\n selectedElementIds: {\n [frame.id]: true\n }\n });\n }\n\n this.onMagicFrameGenerate(frame, \"upstream\");\n }\n };\n\n this.openEyeDropper = ({\n type\n }) => {\n this.updateEditorAtom(_EyeDropper__WEBPACK_IMPORTED_MODULE_55__.activeEyeDropperAtom, {\n swapPreviewOnAlt: true,\n colorPickerType: type === \"stroke\" ? \"elementStroke\" : \"elementBackground\",\n onSelect: (color, event) => {\n const shouldUpdateStrokeColor = type === \"background\" && event.altKey || type === \"stroke\" && !event.altKey;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (!selectedElements.length || this.state.activeTool.type !== \"selection\") {\n if (shouldUpdateStrokeColor) {\n this.syncActionResult({\n appState: Object.assign(Object.assign({}, this.state), {\n currentItemStrokeColor: color\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n } else {\n this.syncActionResult({\n appState: Object.assign(Object.assign({}, this.state), {\n currentItemBackgroundColor: color\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n } else {\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().map(el => {\n if (this.state.selectedElementIds[el.id]) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(el, {\n [shouldUpdateStrokeColor ? \"strokeColor\" : \"backgroundColor\"]: color\n });\n }\n\n return el;\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n },\n keepOpenOnAlt: false\n });\n };\n\n this.dismissLinearEditor = () => {\n setTimeout(() => {\n var _a;\n\n if ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n isEditing: false\n })\n });\n }\n });\n };\n\n this.syncActionResult = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(actionResult => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n\n if (this.unmounted || actionResult === false) {\n return;\n }\n\n this.store.scheduleAction(actionResult.captureUpdate);\n let didUpdate = false;\n let editingTextElement = null;\n\n if (actionResult.elements) {\n this.scene.replaceAllElements(actionResult.elements);\n didUpdate = true;\n }\n\n if (actionResult.files) {\n this.addMissingFiles(actionResult.files, actionResult.replaceFiles);\n this.addNewImagesToImageCache();\n }\n\n if (actionResult.appState || editingTextElement || this.state.contextMenu) {\n let viewModeEnabled = ((_a = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _a === void 0 ? void 0 : _a.viewModeEnabled) || false;\n let zenModeEnabled = ((_b = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _b === void 0 ? void 0 : _b.zenModeEnabled) || false;\n const theme = ((_c = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _c === void 0 ? void 0 : _c.theme) || this.props.theme || _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.LIGHT;\n const name = (_e = (_d = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : this.state.name;\n const errorMessage = (_g = (_f = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _f === void 0 ? void 0 : _f.errorMessage) !== null && _g !== void 0 ? _g : this.state.errorMessage;\n\n if (typeof this.props.viewModeEnabled !== \"undefined\") {\n viewModeEnabled = this.props.viewModeEnabled;\n }\n\n if (typeof this.props.zenModeEnabled !== \"undefined\") {\n zenModeEnabled = this.props.zenModeEnabled;\n }\n\n editingTextElement = ((_h = actionResult.appState) === null || _h === void 0 ? void 0 : _h.editingTextElement) || null; // make sure editingTextElement points to latest element reference\n\n if (actionResult.elements && editingTextElement) {\n actionResult.elements.forEach(element => {\n if ((editingTextElement === null || editingTextElement === void 0 ? void 0 : editingTextElement.id) === element.id && editingTextElement !== element && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isNonDeletedElement)(element) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element)) {\n editingTextElement = element;\n }\n });\n }\n\n if (editingTextElement === null || editingTextElement === void 0 ? void 0 : editingTextElement.isDeleted) {\n editingTextElement = null;\n }\n\n this.setState(prevAppState => {\n const actionAppState = actionResult.appState || {};\n return Object.assign(Object.assign(Object.assign({}, prevAppState), actionAppState), {\n // NOTE this will prevent opening context menu using an action\n // or programmatically from the host, so it will need to be\n // rewritten later\n contextMenu: null,\n editingTextElement,\n viewModeEnabled,\n zenModeEnabled,\n theme,\n name,\n errorMessage\n });\n });\n didUpdate = true;\n }\n\n if (!didUpdate) {\n this.scene.triggerUpdate();\n }\n }); // Lifecycle\n\n this.onBlur = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(() => {\n isHoldingSpace = false;\n this.setState({\n isBindingEnabled: true\n });\n });\n\n this.onUnload = () => {\n this.onBlur();\n };\n\n this.disableEvent = event => {\n event.preventDefault();\n };\n\n this.resetHistory = () => {\n this.history.clear();\n };\n\n this.resetStore = () => {\n this.store.clear();\n };\n /**\r\n * Resets scene & history.\r\n * ! Do not use to clear scene user action !\r\n */\n\n\n this.resetScene = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(opts => {\n this.scene.replaceAllElements([]);\n this.setState(state => Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_23__.getDefaultAppState)()), {\n isLoading: (opts === null || opts === void 0 ? void 0 : opts.resetLoadingState) ? false : state.isLoading,\n theme: this.state.theme\n }));\n this.resetStore();\n this.resetHistory();\n });\n\n this.initializeScene = async () => {\n var _a;\n\n if (\"launchQueue\" in window && \"LaunchParams\" in window) {\n window.launchQueue.setConsumer(async launchParams => {\n if (!launchParams.files.length) {\n return;\n }\n\n const fileHandle = launchParams.files[0];\n const blob = await fileHandle.getFile();\n this.loadFileToCanvas(new File([blob], blob.name || \"\", {\n type: blob.type\n }), fileHandle);\n });\n }\n\n if (this.props.theme) {\n this.setState({\n theme: this.props.theme\n });\n }\n\n if (!this.state.isLoading) {\n this.setState({\n isLoading: true\n });\n }\n\n let initialData = null;\n\n try {\n if (typeof this.props.initialData === \"function\") {\n initialData = (await this.props.initialData()) || null;\n } else {\n initialData = (await this.props.initialData) || null;\n }\n\n if (initialData === null || initialData === void 0 ? void 0 : initialData.libraryItems) {\n this.library.updateLibrary({\n libraryItems: initialData.libraryItems,\n merge: true\n }).catch(error => {\n console.error(error);\n });\n }\n } catch (error) {\n console.error(error);\n initialData = {\n appState: {\n errorMessage: error.message || \"Encountered an error during importing or restoring scene data\"\n }\n };\n }\n\n const scene = (0,_data_restore__WEBPACK_IMPORTED_MODULE_27__.restore)(initialData, null, null, {\n repairBindings: true,\n deleteInvisibleElements: true\n });\n const activeTool = scene.appState.activeTool;\n scene.appState = Object.assign(Object.assign({}, scene.appState), {\n theme: this.props.theme || scene.appState.theme,\n // we're falling back to current (pre-init) state when deciding\n // whether to open the library, to handle a case where we\n // update the state outside of initialData (e.g. when loading the app\n // with a library install link, which should auto-open the library)\n openSidebar: ((_a = scene.appState) === null || _a === void 0 ? void 0 : _a.openSidebar) || this.state.openSidebar,\n activeTool: activeTool.type === \"image\" || activeTool.type === \"lasso\" || activeTool.type === \"selection\" ? Object.assign(Object.assign({}, activeTool), {\n type: this.defaultSelectionTool\n }) : scene.appState.activeTool,\n isLoading: false,\n toast: this.state.toast\n });\n\n if (initialData === null || initialData === void 0 ? void 0 : initialData.scrollToContent) {\n scene.appState = Object.assign(Object.assign({}, scene.appState), (0,_scene__WEBPACK_IMPORTED_MODULE_31__.calculateScrollCenter)(scene.elements, Object.assign(Object.assign({}, scene.appState), {\n width: this.state.width,\n height: this.state.height,\n offsetTop: this.state.offsetTop,\n offsetLeft: this.state.offsetLeft\n })));\n }\n\n this.resetStore();\n this.resetHistory();\n this.syncActionResult(Object.assign(Object.assign({}, scene), {\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER\n })); // clear the shape and image cache so that any images in initialData\n // can be loaded fresh\n\n this.clearImageShapeCache(); // manually loading the font faces seems faster even in browsers that do fire the loadingdone event\n\n this.fonts.loadSceneFonts().then(fontFaces => {\n this.fonts.onLoaded(fontFaces);\n });\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(window.location.href)) {\n this.scrollToContent(window.location.href, {\n animate: false\n });\n }\n };\n\n this.isMobileBreakpoint = (width, height) => {\n return width !== 0 && this.allowMobileMode && ( //zsviczian changing tabs in Obsidian causes MobileMenu to be rendered\n width <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_MAX_MOBILE || height < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_MAX_HEIGHT_LANDSCAPE && width < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_MAX_WIDTH_LANDSCAPE);\n };\n\n this.isTabletBreakpoint = (editorWidth, editorHeight) => {\n const minSide = Math.min(editorWidth, editorHeight);\n const maxSide = Math.max(editorWidth, editorHeight);\n return editorWidth !== 0 && //zsviczian changing tabs in Obsidian causes MobileMenu to be rendered\n minSide >= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_MIN_TABLET && maxSide <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_MAX_TABLET;\n };\n\n this.refreshViewportBreakpoints = () => {\n const container = this.excalidrawContainerRef.current;\n\n if (!container) {\n return;\n }\n\n const {\n width: editorWidth,\n height: editorHeight\n } = container.getBoundingClientRect();\n const prevViewportState = this.device.viewport;\n const nextViewportState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(prevViewportState, {\n isLandscape: editorWidth > editorHeight,\n isMobile: this.isMobileBreakpoint(editorWidth, editorHeight)\n });\n\n if (prevViewportState !== nextViewportState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n viewport: nextViewportState\n });\n return true;\n }\n\n return false;\n };\n\n this.refreshEditorBreakpoints = () => {\n const container = this.excalidrawContainerRef.current;\n\n if (!container) {\n return;\n }\n\n const {\n width: editorWidth,\n height: editorHeight\n } = container.getBoundingClientRect();\n const sidebarBreakpoint = this.props.UIOptions.dockedSidebarBreakpoint != null ? this.props.UIOptions.dockedSidebarBreakpoint : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_RIGHT_SIDEBAR_MIN_WIDTH;\n const prevEditorState = this.device.editor;\n const nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(prevEditorState, {\n isMobile: this.isMobileBreakpoint(editorWidth, editorHeight),\n canFitSidebar: editorWidth > sidebarBreakpoint\n }); // also check if we need to update the app state\n\n this.setState({\n stylesPanelMode: // NOTE: we could also remove the isMobileOrTablet check here and\n // always switch to compact mode when the editor is narrow (e.g. < MQ_MIN_WIDTH_DESKTOP)\n // but not too narrow (> MQ_MAX_WIDTH_MOBILE)\n this.isTabletBreakpoint(editorWidth, editorHeight) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() ? \"compact\" : \"full\"\n });\n\n if (prevEditorState !== nextEditorState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n editor: nextEditorState\n });\n return true;\n }\n\n return false;\n };\n\n this.onResize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(() => {\n this.scene.getElementsIncludingDeleted().forEach(element => _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element));\n this.refreshViewportBreakpoints();\n this.updateDOMRect();\n\n if (!_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.supportsResizeObserver) {\n this.refreshEditorBreakpoints();\n }\n\n this.setState({});\n });\n /** generally invoked only if fullscreen was invoked programmatically */\n\n this.onFullscreenChange = () => {\n var _a;\n\n if ( // points to the iframe element we fullscreened\n !document.fullscreenElement && ((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.state) === \"active\") {\n this.setState({\n activeEmbeddable: null\n });\n }\n };\n\n this.renderInteractiveSceneCallback = ({\n atLeastOneVisibleElement,\n scrollBars,\n elementsMap\n }) => {\n if (!document.querySelector(\".excalidraw\")) {\n return;\n } //zsviczian - address issue when moving excalidraw to a new window/document\n\n\n if (scrollBars) {\n currentScrollBars = scrollBars;\n }\n\n const scrolledOutside = // hide when editing text\n this.state.editingTextElement ? false : !atLeastOneVisibleElement && elementsMap.size > 0;\n\n if (this.state.scrolledOutside !== scrolledOutside) {\n this.setState({\n scrolledOutside\n });\n }\n\n this.scheduleImageRefresh();\n };\n\n this.onScroll = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.debounce)(() => {\n const {\n offsetTop,\n offsetLeft\n } = this.getCanvasOffsets();\n this.setState(state => {\n if (state.offsetLeft === offsetLeft && state.offsetTop === offsetTop) {\n return null;\n }\n\n return {\n offsetTop,\n offsetLeft\n };\n });\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.SCROLL_TIMEOUT); // Copy/paste\n\n this.onCut = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n var _a;\n\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement);\n\n if (!isExcalidrawActive || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionCut, \"keyboard\", event);\n event.preventDefault();\n event.stopPropagation();\n });\n this.onCopy = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n var _a;\n\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement);\n\n if (!isExcalidrawActive || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionCopy, \"keyboard\", event);\n event.preventDefault();\n event.stopPropagation();\n });\n\n this.onTouchStart = event => {\n // fix for Apple Pencil Scribble (do not prevent for other devices)\n if (_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isIOS) {\n event.preventDefault();\n }\n\n if (!didTapTwice) {\n didTapTwice = true;\n\n if (event.touches.length === 1) {\n firstTapPosition = {\n x: event.touches[0].clientX,\n y: event.touches[0].clientY\n };\n }\n\n clearTimeout(tappedTwiceTimer);\n tappedTwiceTimer = window.setTimeout(App.resetTapTwice, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TAP_TWICE_TIMEOUT);\n return;\n } // insert text only if we tapped twice with a single finger at approximately the same position\n // event.touches.length === 1 will also prevent inserting text when user's zooming\n\n\n if (didTapTwice && event.touches.length === 1 && firstTapPosition) {\n const touch = event.touches[0];\n const distance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(touch.clientX, touch.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(firstTapPosition.x, firstTapPosition.y)); // only create text if the second tap is within the threshold of the first tap\n // this prevents accidental text creation during dragging/selection\n\n if (distance <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DOUBLE_TAP_POSITION_THRESHOLD) {\n // end lasso trail and deselect elements just in case\n this.lassoTrail.endPath();\n this.deselectElements(); // @ts-ignore\n\n this.handleCanvasDoubleClick({\n clientX: touch.clientX,\n clientY: touch.clientY\n });\n }\n\n didTapTwice = false;\n clearTimeout(tappedTwiceTimer);\n }\n\n if (event.touches.length === 2) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null\n });\n }\n };\n\n this.onTouchEnd = event => {\n this.resetContextMenuTimer();\n\n if (event.touches.length > 0) {\n this.setState({\n previousSelectedElementIds: {},\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n } else {\n gesture.pointers.clear();\n }\n };\n\n this.pasteFromClipboard = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(async event => {\n var _a;\n\n const isPlainPaste = !!IS_PLAIN_PASTE; // #686\n\n const target = document.activeElement;\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(target);\n\n if (event && !isExcalidrawActive) {\n return;\n }\n\n const elementUnderCursor = document.elementFromPoint(this.lastViewportPosition.x, this.lastViewportPosition.y);\n\n if (event && (!(elementUnderCursor instanceof HTMLCanvasElement) || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(target))) {\n return;\n } // must be called in the same frame (thus before any awaits) as the paste\n // event else some browsers (FF...) will clear the clipboardData\n // (something something security)\n\n\n const dataTransferList = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_24__.parseDataTransferEvent)(event);\n const filesList = dataTransferList.getFiles();\n const data = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_24__.parseClipboard)(dataTransferList, isPlainPaste);\n\n if (this.props.onPaste) {\n try {\n if ((await this.props.onPaste(data, event)) === false) {\n return;\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n await this.insertClipboardContent(data, filesList, isPlainPaste);\n this.setActiveTool({\n type: this.defaultSelectionTool\n }, true);\n event === null || event === void 0 ? void 0 : event.preventDefault();\n });\n\n this.addElementsFromPasteOrLibrary = opts => {\n var _a, _b;\n\n const elements = (0,_data_restore__WEBPACK_IMPORTED_MODULE_27__.restoreElements)(opts.elements, null, {\n deleteInvisibleElements: true\n });\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(elements);\n const elementsCenterX = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(minX, maxX) / 2;\n const elementsCenterY = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(minY, maxY) / 2;\n const clientX = typeof opts.position === \"object\" ? opts.position.clientX : opts.position === \"cursor\" ? this.lastViewportPosition.x : this.state.width / 2 + this.state.offsetLeft;\n const clientY = typeof opts.position === \"object\" ? opts.position.clientY : opts.position === \"cursor\" ? this.lastViewportPosition.y : this.state.height / 2 + this.state.offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX,\n clientY\n }, this.state);\n const dx = x - elementsCenterX;\n const dy = y - elementsCenterY;\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(dx, dy, this.getEffectiveGridSize());\n const {\n duplicatedElements\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.duplicateElements)({\n type: \"everything\",\n elements: elements.map(element => {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(element, {\n x: element.x + gridX - minX,\n y: element.y + gridY - minY\n });\n }),\n randomizeSeed: !opts.retainSeed\n });\n const prevElements = this.scene.getElementsIncludingDeleted();\n let nextElements = [...prevElements, ...duplicatedElements];\n const mappedNewSceneElements = (_b = (_a = this.props).onDuplicate) === null || _b === void 0 ? void 0 : _b.call(_a, nextElements, prevElements);\n nextElements = mappedNewSceneElements || nextElements;\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.syncMovedIndices)(nextElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(duplicatedElements));\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x,\n y\n });\n\n if (topLayerFrame) {\n const eligibleElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.filterElementsEligibleAsFrameChildren)(duplicatedElements, topLayerFrame);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(nextElements, eligibleElements, topLayerFrame, this.state);\n }\n\n this.scene.replaceAllElements(nextElements);\n duplicatedElements.forEach(newElement => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(newElement) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(newElement)) {\n const container = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(newElement, this.scene.getElementsMapIncludingDeleted());\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.redrawTextBoundingBox)(newElement, container, this.scene);\n }\n }); // paste event may not fire FontFace loadingdone event in Safari, hence loading font faces manually\n\n if (true) {\n //zsviczian - isSafari\n _fonts__WEBPACK_IMPORTED_MODULE_36__.Fonts.loadElementsFonts(duplicatedElements).then(fontFaces => {\n this.fonts.onLoaded(fontFaces);\n });\n }\n\n if (opts.files) {\n this.addMissingFiles(opts.files);\n }\n\n const nextElementsToSelect = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.excludeElementsInFramesFromSelection)(duplicatedElements);\n this.store.scheduleCapture();\n this.setState(Object.assign(Object.assign(Object.assign({}, this.state), {\n // keep sidebar (presumably the library) open if it's docked and\n // can fit.\n //\n // Note, we should close the sidebar only if we're dropping items\n // from library, not when pasting from clipboard. Alas.\n openSidebar: this.state.openSidebar && this.device.editor.canFitSidebar && _editor_jotai__WEBPACK_IMPORTED_MODULE_37__.editorJotaiStore.get(_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_61__.isSidebarDockedAtom) ? this.state.openSidebar : null\n }), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: null,\n selectedElementIds: nextElementsToSelect.reduce((acc, element) => {\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(element)) {\n acc[element.id] = true;\n }\n\n return acc;\n }, {})\n }, this.scene.getNonDeletedElements(), this.state, this)), () => {\n if (opts.files) {\n this.addNewImagesToImageCache();\n }\n });\n this.setActiveTool({\n type: this.defaultSelectionTool\n }, true);\n\n if (opts.fitToContent) {\n this.scrollToContent(duplicatedElements, {\n fitToContent: true,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n };\n\n this.setAppState = (state, callback) => {\n this.setState(state, callback);\n };\n\n this.removePointer = event => {\n if (touchTimeout) {\n this.resetContextMenuTimer();\n }\n\n gesture.pointers.delete(event.pointerId);\n };\n\n this.toggleLock = (source = \"ui\") => {\n if (!this.state.activeTool.locked) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"toolbar\", \"toggleLock\", `${source} (${this.device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n\n this.setState(prevState => {\n return {\n activeTool: Object.assign(Object.assign(Object.assign({}, prevState.activeTool), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, prevState.activeTool.locked ? {\n type: this.defaultSelectionTool\n } : prevState.activeTool)), {\n locked: !prevState.activeTool.locked\n })\n };\n });\n };\n\n this.updateFrameRendering = opts => {\n this.setState(prevState => {\n var _a, _b, _c, _d, _e, _f;\n\n const next = typeof opts === \"function\" ? opts(prevState.frameRendering) : opts;\n return {\n frameRendering: {\n enabled: (_a = next === null || next === void 0 ? void 0 : next.enabled) !== null && _a !== void 0 ? _a : prevState.frameRendering.enabled,\n clip: (_b = next === null || next === void 0 ? void 0 : next.clip) !== null && _b !== void 0 ? _b : prevState.frameRendering.clip,\n name: (_c = next === null || next === void 0 ? void 0 : next.name) !== null && _c !== void 0 ? _c : prevState.frameRendering.name,\n outline: (_d = next === null || next === void 0 ? void 0 : next.outline) !== null && _d !== void 0 ? _d : prevState.frameRendering.outline,\n //zsviczian\n markerName: (_e = next === null || next === void 0 ? void 0 : next.markerName) !== null && _e !== void 0 ? _e : prevState.frameRendering.markerName,\n markerEnabled: (_f = next === null || next === void 0 ? void 0 : next.markerEnabled) !== null && _f !== void 0 ? _f : prevState.frameRendering.markerEnabled\n }\n };\n });\n };\n\n this.togglePenMode = force => {\n this.setState(prevState => {\n return {\n penMode: force !== null && force !== void 0 ? force : !prevState.penMode,\n penDetected: true\n };\n });\n };\n\n this.onHandToolToggle = () => {\n //zsviczian added timeout because button won't select otherwise\n setTimeout(() => this.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.actionToggleHandTool));\n };\n /**\r\n * Zooms on canvas viewport center\r\n */\n\n\n this.zoomCanvas = (\n /**\r\n * Decimal fraction, auto-clamped between MIN_ZOOM and MAX_ZOOM.\r\n * 1 = 100% zoom, 2 = 200% zoom, 0.5 = 50% zoom\r\n */\n value) => {\n this.setState(Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_32__.getStateForZoom)({\n viewportX: this.state.width / 2 + this.state.offsetLeft,\n viewportY: this.state.height / 2 + this.state.offsetTop,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getNormalizedZoom)(value)\n }, this.state)));\n };\n\n this.cancelInProgressAnimation = null;\n\n this.scrollToContent = (\n /**\r\n * target to scroll to\r\n *\r\n * - string - id of element or group, or url containing elementLink\r\n * - ExcalidrawElement | ExcalidrawElement[] - element(s) objects\r\n */\n target = this.scene.getNonDeletedElements(), opts) => {\n var _a, _b, _c, _d;\n\n if (typeof target === \"string\") {\n let id;\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(target)) {\n id = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.parseElementLinkFromURL)(target);\n } else {\n id = target;\n }\n\n if (id) {\n const elements = this.scene.getElementsFromId(id);\n\n if (elements === null || elements === void 0 ? void 0 : elements.length) {\n this.scrollToContent(elements, {\n fitToContent: (_a = opts === null || opts === void 0 ? void 0 : opts.fitToContent) !== null && _a !== void 0 ? _a : true,\n animate: (_b = opts === null || opts === void 0 ? void 0 : opts.animate) !== null && _b !== void 0 ? _b : true\n });\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(target)) {\n this.setState({\n toast: {\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"elementLink.notFound\"),\n duration: 3000,\n closable: true\n }\n });\n }\n }\n\n return;\n }\n\n (_c = this.cancelInProgressAnimation) === null || _c === void 0 ? void 0 : _c.call(this); // convert provided target into ExcalidrawElement[] if necessary\n\n const targetElements = Array.isArray(target) ? target : [target];\n let zoom = this.state.zoom;\n let scrollX = this.state.scrollX;\n let scrollY = this.state.scrollY;\n\n if ((opts === null || opts === void 0 ? void 0 : opts.fitToContent) || (opts === null || opts === void 0 ? void 0 : opts.fitToViewport)) {\n const {\n appState\n } = (0,_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.zoomToFit)({\n canvasOffsets: opts.canvasOffsets,\n targetElements,\n appState: this.state,\n fitToViewport: !!(opts === null || opts === void 0 ? void 0 : opts.fitToViewport),\n viewportZoomFactor: opts === null || opts === void 0 ? void 0 : opts.viewportZoomFactor,\n minZoom: opts === null || opts === void 0 ? void 0 : opts.minZoom,\n maxZoom: opts === null || opts === void 0 ? void 0 : opts.maxZoom\n });\n zoom = appState.zoom;\n scrollX = appState.scrollX;\n scrollY = appState.scrollY;\n } else {\n // compute only the viewport location, without any zoom adjustment\n const scroll = (0,_scene__WEBPACK_IMPORTED_MODULE_31__.calculateScrollCenter)(targetElements, this.state);\n scrollX = scroll.scrollX;\n scrollY = scroll.scrollY;\n } // when animating, we use RequestAnimationFrame to prevent the animation\n // from slowing down other processes\n\n\n if (opts === null || opts === void 0 ? void 0 : opts.animate) {\n const origScrollX = this.state.scrollX;\n const origScrollY = this.state.scrollY;\n const origZoom = this.state.zoom.value;\n const cancel = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.easeToValuesRAF)({\n fromValues: {\n scrollX: origScrollX,\n scrollY: origScrollY,\n zoom: origZoom\n },\n toValues: {\n scrollX,\n scrollY,\n zoom: zoom.value\n },\n interpolateValue: (from, to, progress, key) => {\n // for zoom, use different easing\n if (key === \"zoom\") {\n return from * Math.pow(to / from, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.easeOut)(progress));\n } // handle using default\n\n\n return undefined;\n },\n onStep: ({\n scrollX,\n scrollY,\n zoom\n }) => {\n this.setState({\n scrollX,\n scrollY,\n zoom: {\n value: zoom\n }\n });\n },\n onStart: () => {\n this.setState({\n shouldCacheIgnoreZoom: true\n });\n },\n onEnd: () => {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n },\n onCancel: () => {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n },\n duration: (_d = opts === null || opts === void 0 ? void 0 : opts.duration) !== null && _d !== void 0 ? _d : 500\n });\n\n this.cancelInProgressAnimation = () => {\n cancel();\n this.cancelInProgressAnimation = null;\n };\n } else {\n this.setState({\n scrollX,\n scrollY,\n zoom\n });\n }\n };\n\n this.maybeUnfollowRemoteUser = () => {\n if (this.state.userToFollow) {\n this.setState({\n userToFollow: null\n });\n }\n };\n /** use when changing scrollX/scrollY/zoom based on user interaction */\n\n\n this.translateCanvas = state => {\n var _a;\n\n (_a = this.cancelInProgressAnimation) === null || _a === void 0 ? void 0 : _a.call(this);\n this.maybeUnfollowRemoteUser();\n this.setState(state);\n }; //zsviczian\n\n\n this.setForceRenderAllEmbeddables = force => {\n this.shouldRenderAllEmbeddables = force;\n\n if (force) {\n this.setState({});\n }\n }; //zsviczian\n\n\n this.zoomToFit = (target = this.scene.getNonDeletedElements(), maxZoom, //null will zoom to max based on viewport\n margin = 0.03) => {\n if (typeof maxZoom === \"undefined\") {\n //zsviczian\n maxZoom = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.getMaxZoom)();\n }\n\n if (!target) {\n target = this.scene.getNonDeletedElements();\n }\n\n if (target.length === 0) {\n maxZoom = 1;\n }\n\n this.setState((0,_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.zoomToFitElements)(target, this.state, false, this, maxZoom, margin).appState);\n }; //zsviczian\n\n\n this.getColorAtScenePoint = ({\n sceneX,\n sceneY\n }) => {\n if (!this.canvas) {\n console.error(\"Canvas not available\");\n return null;\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.sceneCoordsToViewportCoords)({\n sceneX,\n sceneY\n }, this.state);\n const context = this.canvas.getContext(\"2d\");\n\n if (!context) {\n console.error(\"2D context not available\");\n return null;\n } // Get pixel data directly from the given scene coordinates\n\n\n const pixelData = context.getImageData(x, y, 1, 1).data;\n const [r, g, b, a] = pixelData; // Check for transparency\n\n if (a === 0) {\n return this.state.theme === \"light\" ? \"rgba(255,255,255,1)\" : \"rgba(0,0,0,1)\";\n } // Return the color in rgba format\n\n\n return `rgba(${r}, ${g}, ${b}, ${a / 255})`;\n }; //zsviczian\n\n\n this.startLineEditor = (el, selectedPointsIndices = null) => {\n if (!el || !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(el)) {\n return;\n } // First select the element\n\n\n this.setState({\n selectedElementIds: {\n [el.id]: true\n }\n }, () => {\n // Then set up the editor\n const linearElementEditor = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(el, this.scene.getNonDeletedElementsMap());\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, linearElementEditor), {\n isEditing: true,\n selectedPointsIndices\n })\n });\n });\n }; //zsviczian\n\n\n this.updateContainerSize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(containers => {\n containers.forEach(element => {\n // Get absolute coordinates for the bottom-right corner\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getResizedElementAbsoluteCoords)(element, element.width, element.height, true); // Get rotated pointer position at bottom-right corner\n\n const [pointerX, pointerY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x2, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)((x1 + x2) / 2, (y1 + y2) / 2), element.angle);\n const {\n nextWidth,\n nextHeight\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getNextSingleWidthAndHeightFromPointer)(element, element, \"se\", pointerX, pointerY);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.resizeSingleElement)(nextWidth, nextHeight, element, element, this.scene.getElementsMapIncludingDeleted(), this.scene, \"se\", {\n shouldMaintainAspectRatio: true,\n shouldResizeFromCenter: false\n });\n });\n });\n\n this.setToast = toast => {\n this.setState({\n toast\n });\n };\n\n this.restoreFileFromShare = async () => {\n try {\n const webShareTargetCache = await caches.open(\"web-share-target\");\n const response = await webShareTargetCache.match(\"shared-file\");\n\n if (response) {\n const blob = await response.blob();\n const file = new File([blob], blob.name || \"\", {\n type: blob.type\n });\n this.loadFileToCanvas(file, null);\n await webShareTargetCache.delete(\"shared-file\");\n window.history.replaceState(null, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.APP_NAME, window.location.pathname);\n }\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n };\n /**\r\n * adds supplied files to existing files in the appState.\r\n * NOTE if file already exists in editor state, the file data is not updated\r\n * */\n\n\n this.addFiles = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(files => {\n const {\n addedFiles\n } = this.addMissingFiles(files, undefined, true); //zsviczian\n\n this.clearImageShapeCache(addedFiles);\n this.scene.triggerUpdate();\n this.addNewImagesToImageCache();\n }); //zsviczian https://github.com/zsviczian/excalibrain/issues/9\n\n this.setMobileModeAllowed = allow => {\n const {\n width: editorWidth,\n height: editorHeight\n } = this.excalidrawContainerRef.current.getBoundingClientRect();\n this.allowMobileMode = allow;\n const prevEditorState = this.device.editor;\n let nextEditorState;\n\n if (allow) {\n nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(prevEditorState, {\n isMobile: this.isMobileBreakpoint(editorWidth, editorHeight)\n });\n } else {\n nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(prevEditorState, {\n isMobile: false //must test this\n\n });\n }\n\n if (prevEditorState !== nextEditorState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n editor: nextEditorState\n });\n this.forceUpdate();\n }\n }; //zsviczian\n\n\n this.debounceClearHighlightSearchResults = false;\n\n this.selectElements = (elements, highlightSearchResult = false) => {\n //zsviczian\n if (highlightSearchResult) {\n this.debounceClearHighlightSearchResults = true;\n setTimeout(() => {\n this.debounceClearHighlightSearchResults = false;\n }, 500);\n }\n\n this.updateScene({\n appState: Object.assign(Object.assign({}, this.state), {\n editingGroupId: null,\n selectedElementIds: elements.reduce((map, element) => {\n map[element.id] = true;\n return map;\n }, {}),\n highlightSearchResult\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER,\n forceFlushSync: true\n });\n }; //zsviczian\n\n\n this.bringToFront = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_8__.actionBringToFront.perform(this.scene.getNonDeletedElements(), this.state));\n }; //zsviczian\n\n\n this.bringForward = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_8__.actionBringForward.perform(this.scene.getNonDeletedElements(), this.state, undefined, this));\n }; //zsviczian\n\n\n this.sendToBack = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_8__.actionSendToBack.perform(this.scene.getNonDeletedElements(), this.state));\n }; //zsviczian\n\n\n this.sendBackward = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_8__.actionSendBackward.perform(this.scene.getNonDeletedElements(), this.state, undefined, this));\n };\n\n this.addMissingFiles = (files, replace = false, force = false) => {\n var _a;\n\n const nextFiles = replace ? {} : Object.assign({}, this.files);\n const addedFiles = {};\n\n const _files = Array.isArray(files) ? files : Object.values(files);\n\n for (const fileData of _files) {\n if (!force && nextFiles[fileData.id]) {\n //zsviczian\n continue;\n }\n\n addedFiles[fileData.id] = fileData;\n nextFiles[fileData.id] = fileData;\n\n if (fileData.mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg) {\n try {\n const restoredDataURL = (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.getDataURL_sync)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.normalizeSVG)((0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.dataURLToString)(fileData.dataURL)), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg);\n\n if (fileData.dataURL !== restoredDataURL) {\n // bump version so persistence layer can update the store\n fileData.version = ((_a = fileData.version) !== null && _a !== void 0 ? _a : 1) + 1;\n fileData.dataURL = restoredDataURL;\n }\n } catch (error) {\n console.error(error);\n }\n }\n }\n\n this.files = nextFiles;\n return {\n addedFiles\n };\n };\n\n this.updateScene = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(sceneData => {\n const {\n elements,\n appState,\n collaborators,\n captureUpdate\n } = sceneData;\n\n if (captureUpdate) {\n const nextElements = elements ? elements : undefined;\n const observedAppState = appState ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getObservedAppState)(Object.assign(Object.assign({}, this.store.snapshot.appState), appState)) : undefined;\n this.store.scheduleMicroAction({\n action: captureUpdate,\n elements: nextElements,\n appState: observedAppState\n });\n } //zsviczian forceFlushSync is set to true in ExcalidrawView.updateScene.\n //without this e.g. text search did not select the elements\n\n\n if (sceneData.forceFlushSync === true) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n if (appState) {\n this.setState(appState);\n }\n });\n } else if (appState) {\n this.setState(appState);\n }\n\n if (elements) {\n this.scene.replaceAllElements(elements);\n }\n\n if (collaborators) {\n this.setState({\n collaborators\n });\n }\n });\n\n this.applyDeltas = (deltas, options) => {\n // squash all deltas together, starting with a fresh new delta instance\n const aggregatedDelta = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.StoreDelta.squash(...deltas); // create new instance of elements map & appState, so we don't accidentaly mutate existing ones\n\n const nextAppState = Object.assign({}, this.state);\n const nextElements = new Map(this.scene.getElementsMapIncludingDeleted());\n return _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.StoreDelta.applyTo(aggregatedDelta, nextElements, nextAppState, options);\n };\n\n this.mutateElement = (element, updates, informMutation = true) => {\n return this.scene.mutateElement(element, updates, {\n informMutation,\n isDragging: false\n });\n };\n\n this.triggerRender = (\n /** force always re-renders canvas even if no change */\n force) => {\n if (force === true) {\n this.scene.triggerUpdate();\n } else {\n this.setState({});\n }\n };\n /**\r\n * @returns whether the menu was toggled on or off\r\n */\n\n\n this.toggleSidebar = ({\n name,\n tab,\n force\n }) => {\n var _a, _b;\n\n let nextName;\n\n if (force === undefined) {\n nextName = ((_a = this.state.openSidebar) === null || _a === void 0 ? void 0 : _a.name) === name && ((_b = this.state.openSidebar) === null || _b === void 0 ? void 0 : _b.tab) === tab ? null : name;\n } else {\n nextName = force ? name : null;\n }\n\n const nextState = nextName ? {\n name: nextName\n } : null;\n\n if (nextState && tab) {\n nextState.tab = tab;\n }\n\n this.setState({\n openSidebar: nextState\n });\n return !!nextName;\n };\n\n this.updateCurrentCursorPosition = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n this.lastViewportPosition.x = event.clientX;\n this.lastViewportPosition.y = event.clientY;\n });\n\n this.getEditorUIOffsets = () => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;\n\n const toolbarBottom = ((_e = (_d = (_c = (_b = (_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.querySelector(\".App-toolbar\")) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect()) === null || _d === void 0 ? void 0 : _d.bottom) !== null && _e !== void 0 ? _e : 0) - this.state.offsetTop;\n const sidebarRect = (_h = (_g = (_f = this.excalidrawContainerRef) === null || _f === void 0 ? void 0 : _f.current) === null || _g === void 0 ? void 0 : _g.querySelector(\".sidebar\")) === null || _h === void 0 ? void 0 : _h.getBoundingClientRect();\n const propertiesPanelRect = (_l = (_k = (_j = this.excalidrawContainerRef) === null || _j === void 0 ? void 0 : _j.current) === null || _k === void 0 ? void 0 : _k.querySelector(\".App-menu__left\")) === null || _l === void 0 ? void 0 : _l.getBoundingClientRect();\n const PADDING = 16;\n\n const adjustRectValueForOffset = ( //zsviczian https://github.com/excalidraw/excalidraw/issues/8561\n value, fallback) => (value !== null && value !== void 0 ? value : fallback + this.state.offsetLeft) - this.state.offsetLeft;\n\n return (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.getLanguage)().rtl ? {\n top: toolbarBottom + PADDING,\n right: Math.max(this.state.width - adjustRectValueForOffset( //zsivczian\n propertiesPanelRect === null || propertiesPanelRect === void 0 ? void 0 : propertiesPanelRect.left, this.state.width), 0) + PADDING,\n bottom: PADDING,\n //zsivczian\n left: Math.max(adjustRectValueForOffset(sidebarRect === null || sidebarRect === void 0 ? void 0 : sidebarRect.right, 0), 0) + PADDING\n } : {\n top: toolbarBottom + PADDING,\n right: Math.max(this.state.width - adjustRectValueForOffset(sidebarRect === null || sidebarRect === void 0 ? void 0 : sidebarRect.left, this.state.width) + //zsivczian\n PADDING, 0),\n bottom: PADDING,\n //zsivczian\n left: Math.max(adjustRectValueForOffset(propertiesPanelRect === null || propertiesPanelRect === void 0 ? void 0 : propertiesPanelRect.right, 0), 0) + PADDING\n };\n }; // Input handling\n\n\n this.onKeyDown = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n\n if (this.state.activeTool.type === \"selection\" && this.state.resizingElement && (event.shiftKey || event.altKey)) {\n event.stopPropagation(); //zsviczian shift fires repeatedly causing slowdown when resizing sticky notes\n\n return;\n } // normalize `event.key` when CapsLock is pressed #2372\n\n\n if (\"Proxy\" in window && (!event.shiftKey && /^[A-Z]$/.test(event.key) || event.shiftKey && /^[a-z]$/.test(event.key))) {\n event = new Proxy(event, {\n get(ev, prop) {\n const value = ev[prop];\n\n if (typeof value === \"function\") {\n // fix for Proxies hijacking `this`\n return value.bind(ev);\n }\n\n return prop === \"key\" ? // CapsLock inverts capitalization based on ShiftKey, so invert\n // it back\n event.shiftKey ? ev.key.toUpperCase() : ev.key.toLowerCase() : value;\n }\n\n });\n }\n\n if (!(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isInputLike)(event.target)) {\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) && this.state.croppingElementId) {\n this.finishImageCropping();\n return;\n }\n\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(selectedElements[0]) && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) {\n this.startImageCropping(selectedElements[0]);\n return;\n } // Shape switching\n\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom, null);\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.TAB && (document.activeElement === ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) || ((_b = document.activeElement) === null || _b === void 0 ? void 0 : _b.classList.contains(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CLASSES.CONVERT_ELEMENT_TYPE_POPUP)))) {\n event.preventDefault();\n const conversionType = (0,_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.getConversionTypeFromElements)(selectedElements);\n\n if (((_c = _editor_jotai__WEBPACK_IMPORTED_MODULE_37__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom)) === null || _c === void 0 ? void 0 : _c.type) === \"panel\") {\n if ((0,_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypes)(this, {\n conversionType,\n direction: event.shiftKey ? \"left\" : \"right\"\n })) {\n this.store.scheduleCapture();\n }\n }\n\n if (conversionType) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom, {\n type: \"panel\"\n });\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE && this.flowChartCreator.isCreatingChart) {\n this.flowChartCreator.clear();\n this.triggerRender(true);\n return;\n }\n\n const arrowKeyPressed = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key);\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && arrowKeyPressed && !event.shiftKey) {\n event.preventDefault();\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFlowchartNodeElement)(selectedElements[0])) {\n this.flowChartCreator.createNodes(selectedElements[0], this.state, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLinkDirectionFromKey)(event.key), this.scene);\n }\n\n if (((_d = this.flowChartCreator.pendingNodes) === null || _d === void 0 ? void 0 : _d.length) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementCompletelyInViewport)(this.flowChartCreator.pendingNodes, this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(this.flowChartCreator.pendingNodes, {\n animate: true,\n duration: 300,\n fitToContent: true,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n\n return;\n }\n\n if (event.altKey) {\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && arrowKeyPressed) {\n event.preventDefault();\n const nextId = this.flowChartNavigator.exploreByDirection(selectedElements[0], this.scene.getNonDeletedElementsMap(), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLinkDirectionFromKey)(event.key));\n\n if (nextId) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [nextId]: true\n }, prevState)\n }));\n const nextNode = this.scene.getNonDeletedElementsMap().get(nextId);\n\n if (nextNode && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementCompletelyInViewport)([nextNode], this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(nextNode, {\n animate: true,\n duration: 300,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n }\n\n return;\n }\n }\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.P && !event.shiftKey && !event.altKey) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"commandPalette.shortcutHint\", {\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_20__.getShortcutFromShortcutName)(\"commandPalette\")\n })\n });\n event.preventDefault();\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.V) {\n IS_PLAIN_PASTE = event.shiftKey;\n clearTimeout(IS_PLAIN_PASTE_TIMER); // reset (100ms to be safe that we it runs after the ensuing\n // paste event). Though, technically unnecessary to reset since we\n // (re)set the flag before each paste event.\n\n IS_PLAIN_PASTE_TIMER = window.setTimeout(() => {\n IS_PLAIN_PASTE = false;\n }, 100);\n } // prevent browser zoom in input fields\n\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(event.target)) {\n if (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CODES.MINUS || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CODES.EQUAL) {\n event.preventDefault();\n return;\n }\n } // bail if\n\n\n if ( // inside an input\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(event.target) && // unless pressing escape (finalize action)\n event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE || // or unless using arrows (to move between buttons)\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isInputLike)(event.target)) {\n return;\n } //mfuria #329. open context menu with 'm' if not editing text and container focused\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.isPanWithRightMouseEnabled)() && event.key.toLowerCase() === 'm' && !this.state.editingTextElement && // don't trigger when typing in inputs\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isInputLike)(event.target) && ( // ensure focus is within excalidraw container\n (_f = (_e = this.excalidrawContainerRef) === null || _e === void 0 ? void 0 : _e.current) === null || _f === void 0 ? void 0 : _f.contains(document.activeElement))) {\n // open context menu at current cursor position\n const container = this.excalidrawContainerRef.current;\n const {\n top: offsetTop,\n left: offsetLeft\n } = container.getBoundingClientRect();\n const left = this.lastViewportPosition.x - offsetLeft;\n const top = this.lastViewportPosition.y - offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state);\n const element = this.getElementAtPosition(x, y, {\n preferSelected: true,\n includeLockedElements: true\n });\n const selectedElements = this.scene.getSelectedElements(this.state);\n const isHittingCommonBoundBox = this.isHittingCommonBoundingBoxOfSelectedElements({\n x,\n y\n }, selectedElements);\n const type = element || isHittingCommonBoundBox ? 'element' : 'canvas';\n this.setState({\n contextMenu: {\n top,\n left,\n items: this.getContextMenuItems(type)\n }\n });\n event.preventDefault();\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.QUESTION_MARK) {\n this.setState({\n openDialog: {\n name: \"help\"\n }\n });\n return;\n } else if (event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.E && event.shiftKey && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n event.preventDefault();\n this.setState({\n openDialog: {\n name: \"imageExport\"\n }\n });\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.PAGE_UP || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.PAGE_DOWN) {\n let offset = (event.shiftKey ? this.state.width : this.state.height) / this.state.zoom.value;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.PAGE_DOWN) {\n offset = -offset;\n }\n\n if (event.shiftKey) {\n this.translateCanvas(state => ({\n scrollX: state.scrollX + offset\n }));\n } else {\n this.translateCanvas(state => ({\n scrollY: state.scrollY + offset\n }));\n }\n }\n\n if (((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) === \"elementLinkSelector\") {\n return;\n }\n\n if (this.actionManager.handleKeyDown(event)) {\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.K && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isLaserPointerActive)(this.state)) {\n this.setActiveTool({\n type: \"selection\"\n });\n } else {\n this.setActiveTool({\n type: \"laser\"\n });\n }\n\n return;\n }\n\n if (this.state.viewModeEnabled) {\n //revert to hand in case a key is pressed (K is handled above)\n if (event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.K) {\n this.setActiveTool({\n type: \"selection\"\n });\n }\n\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && this.state.isBindingEnabled) {\n this.setState({\n isBindingEnabled: false\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key)) {\n let selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds,\n includeBoundTextElement: true,\n includeElementsInFrames: true\n });\n const elbowArrow = selectedElements.find(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow);\n const arrowIdsToRemove = new Set();\n selectedElements.filter(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow).filter(arrow => {\n const startElementNotInSelection = arrow.startBinding && !selectedElements.some(el => {\n var _a;\n\n return el.id === ((_a = arrow.startBinding) === null || _a === void 0 ? void 0 : _a.elementId);\n });\n const endElementNotInSelection = arrow.endBinding && !selectedElements.some(el => {\n var _a;\n\n return el.id === ((_a = arrow.endBinding) === null || _a === void 0 ? void 0 : _a.elementId);\n });\n return startElementNotInSelection || endElementNotInSelection;\n }).forEach(arrow => arrowIdsToRemove.add(arrow.id));\n selectedElements = selectedElements.filter(el => !arrowIdsToRemove.has(el.id));\n const step = this.getEffectiveGridSize() && (event.shiftKey ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ELEMENT_TRANSLATE_AMOUNT : this.getEffectiveGridSize()) || (event.shiftKey ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ELEMENT_SHIFT_TRANSLATE_AMOUNT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ELEMENT_TRANSLATE_AMOUNT);\n let offsetX = 0;\n let offsetY = 0;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_LEFT) {\n offsetX = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_RIGHT) {\n offsetX = step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_UP) {\n offsetY = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_DOWN) {\n offsetY = step;\n }\n\n selectedElements.forEach(element => {\n this.scene.mutateElement(element, {\n x: element.x + offsetX,\n y: element.y + offsetY\n }, {\n informMutation: false,\n isDragging: false\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(element, this.scene, {\n simultaneouslyUpdated: selectedElements\n });\n });\n this.setState({\n suggestedBindings: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSuggestedBindingsForArrows)(selectedElements.filter(element => element.id !== (elbowArrow === null || elbowArrow === void 0 ? void 0 : elbowArrow.id) || step !== 0), this.scene.getNonDeletedElementsMap(), this.state.zoom)\n });\n this.scene.triggerUpdate();\n event.preventDefault();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n const selectedElement = selectedElements[0];\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedElement)) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElement)) {\n if (!((_h = this.state.selectedLinearElement) === null || _h === void 0 ? void 0 : _h.isEditing) || this.state.selectedLinearElement.elementId !== selectedElement.id) {\n this.store.scheduleCapture();\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElement)) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n }\n }\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isValidTextContainer)(selectedElement)) {\n let container;\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement)) {\n container = selectedElement;\n }\n\n const midPoint = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerCenter)(selectedElement, this.state, this.scene.getNonDeletedElementsMap());\n const sceneX = midPoint.x;\n const sceneY = midPoint.y;\n this.startTextEditing({\n sceneX,\n sceneY,\n container\n });\n event.preventDefault();\n return;\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(selectedElement)) {\n this.setState({\n editingFrame: selectedElement.id\n });\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(selectedElement)) {\n //zsviczian\n this.setState({\n activeEmbeddable: {\n element: selectedElement,\n state: \"active\"\n }\n });\n }\n }\n } else if (!event.ctrlKey && !event.altKey && !event.metaKey && !this.state.newElement && !this.state.selectionElement && !this.state.selectedElementsAreBeingDragged) {\n const shape = (0,_shapes__WEBPACK_IMPORTED_MODULE_67__.findShapeByKey)(event.key, this);\n\n if (shape) {\n if (this.state.activeTool.type !== shape) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"toolbar\", shape, `keyboard (${this.device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n\n if (shape === \"arrow\" && this.state.activeTool.type === \"arrow\") {\n this.setState(prevState => ({\n currentItemArrowType: prevState.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.sharp ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.round : prevState.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.round ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.elbow : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.sharp\n }));\n }\n\n this.setActiveTool({\n type: shape\n });\n event.stopPropagation();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.Q) {\n this.toggleLock(\"keyboard\");\n event.stopPropagation();\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.SPACE && gesture.pointers.size === 0) {\n isHoldingSpace = true;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n event.preventDefault();\n }\n\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.G || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S) && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (this.state.activeTool.type === \"selection\" && !selectedElements.length) {\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.G && ((0,_scene__WEBPACK_IMPORTED_MODULE_31__.hasBackground)(this.state.activeTool.type) || selectedElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_31__.hasBackground)(element.type)))) {\n this.setState({\n openPopup: \"elementBackground\"\n });\n event.stopPropagation();\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S) {\n this.setState({\n openPopup: \"elementStroke\"\n });\n event.stopPropagation();\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && event.shiftKey && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.F) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (this.state.activeTool.type === \"selection\" && !selectedElements.length) {\n return;\n }\n\n if (this.state.activeTool.type === \"text\" || selectedElements.find(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(element, this.scene.getNonDeletedElementsMap()))) {\n event.preventDefault();\n this.setState({\n openPopup: \"fontFamily\"\n });\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.K && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if (this.state.activeTool.type === \"laser\") {\n this.setActiveTool({\n type: this.defaultSelectionTool\n });\n } else {\n this.setActiveTool({\n type: \"laser\"\n });\n }\n\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.BACKSPACE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.DELETE)) {\n this.updateEditorAtom(_ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_52__.activeConfirmDialogAtom, \"clearCanvas\");\n } // eye dropper\n // -----------------------------------------------------------------------\n\n\n const lowerCased = event.key.toLocaleLowerCase();\n const isPickingStroke = lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S && event.shiftKey;\n const isPickingBackground = event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.I || lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.G && event.shiftKey;\n\n if (isPickingStroke || isPickingBackground) {\n this.openEyeDropper({\n type: isPickingStroke ? \"stroke\" : \"background\"\n });\n } // -----------------------------------------------------------------------\n\n });\n this.onKeyUp = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d, _e;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.SPACE) {\n if (this.state.viewModeEnabled || ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if (this.state.activeTool.type === \"selection\" || this.state.activeTool.type === \"lasso\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n isHoldingSpace = false;\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !this.state.isBindingEnabled) {\n this.setState({\n isBindingEnabled: true\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.bindOrUnbindLinearElements)(this.scene.getSelectedElements(this.state).filter(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state), (_c = (_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.selectedPointsIndices) !== null && _c !== void 0 ? _c : [], this.scene, this.state.zoom);\n this.setState({\n suggestedBindings: []\n });\n }\n\n if (!event.altKey) {\n if (this.flowChartNavigator.isExploring) {\n this.flowChartNavigator.clear();\n this.syncActionResult({\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if (this.flowChartCreator.isCreatingChart) {\n if ((_d = this.flowChartCreator.pendingNodes) === null || _d === void 0 ? void 0 : _d.length) {\n this.scene.insertElements(this.flowChartCreator.pendingNodes);\n }\n\n const firstNode = (_e = this.flowChartCreator.pendingNodes) === null || _e === void 0 ? void 0 : _e[0];\n\n if (firstNode) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [firstNode.id]: true\n }, prevState)\n }));\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementCompletelyInViewport)([firstNode], this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(firstNode, {\n animate: true,\n duration: 300,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n }\n\n this.flowChartCreator.clear();\n this.syncActionResult({\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n }\n }); // We purposely widen the `tool` type so this helper can be called with\n // any tool without having to type check it\n\n this.isToolSupported = tool => {\n var _a;\n\n return ((_a = this.props.UIOptions.tools) === null || _a === void 0 ? void 0 : _a[tool]) !== false;\n };\n\n this.setActiveTool = (tool, keepSelection = false) => {\n if (!this.isToolSupported(tool.type)) {\n console.warn(`\"${tool.type}\" tool is disabled via \"UIOptions.canvasActions.tools.${tool.type}\"`);\n return;\n }\n\n const nextActiveTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, tool);\n\n if (nextActiveTool.type === \"hand\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if (!isHoldingSpace) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, Object.assign(Object.assign({}, this.state), {\n activeTool: nextActiveTool\n }));\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isToolIcon)(document.activeElement)) {\n this.focusContainer();\n }\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElementType)(nextActiveTool.type)) {\n this.setState({\n suggestedBindings: []\n });\n }\n\n if (nextActiveTool.type === \"image\") {\n this.onImageToolbarButtonClick();\n }\n\n setTimeout(() => {\n this.setState(prevState => {\n const commonResets = {\n snapLines: prevState.snapLines.length ? [] : prevState.snapLines,\n originSnapOffset: null,\n activeEmbeddable: null\n };\n\n if (nextActiveTool.type === \"freedraw\") {\n this.store.scheduleCapture();\n }\n\n if (nextActiveTool.type === \"lasso\") {\n return Object.assign(Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool\n }), keepSelection ? {} : {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n selectedGroupIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n }), commonResets);\n } else if (nextActiveTool.type !== \"selection\") {\n return Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool,\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextActiveTool.type === \"mermaid\" //zsviczian\n ? this.state.selectedElementIds : {}, prevState),\n selectedGroupIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n }), commonResets);\n }\n\n return Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool\n }), commonResets);\n });\n }); //zsviczian added timeout because button won't select otherwise\n };\n\n this.setOpenDialog = dialogType => {\n this.setState({\n openDialog: dialogType\n });\n };\n\n this.setCursor = cursor => {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, cursor);\n };\n\n this.resetCursor = () => {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n };\n /**\r\n * returns whether user is making a gesture with >= 2 fingers (points)\r\n * on o touch screen (not on a trackpad). Currently only relates to Darwin\r\n * (iOS/iPadOS,MacOS), but may work on other devices in the future if\r\n * GestureEvent is standardized.\r\n */\n\n\n this.isTouchScreenMultiTouchGesture = () => {\n // we don't want to deselect when using trackpad, and multi-point gestures\n // only work on touch screens, so checking for >= pointers means we're on a\n // touchscreen\n return gesture.pointers.size >= 2;\n };\n\n this.getName = () => {\n return this.state.name || this.props.name || `${(0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getDateTime)()}`;\n }; // fires only on Safari\n\n\n this.onGestureStart = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n //zsviczian - start\n // If an embeddable is active and the pinch starts over it, let it handle the gesture.\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.shouldDisableZoom)(this.state)) {\n gesture.initialScale = null;\n return;\n }\n\n event.preventDefault(); // we only want to deselect on touch screens because user may have selected\n // elements by mistake while zooming\n\n if (this.isTouchScreenMultiTouchGesture()) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null\n });\n }\n\n gesture.initialScale = this.state.zoom.value;\n }); // fires only on Safari\n\n this.onGestureChange = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n //zsviczian\n if (!gesture.initialScale) {\n return;\n }\n\n event.preventDefault(); // onGestureChange only has zoom factor but not the center.\n // If we're on iPad or iPhone, then we recognize multi-touch and will\n // zoom in at the right location in the touchmove handler\n // (handleCanvasPointerMove).\n //\n // On Macbook trackpad, we don't have those events so will zoom in at the\n // current location instead.\n //\n // As such, bail from this handler on touch devices.\n\n if (this.isTouchScreenMultiTouchGesture()) {\n return;\n }\n\n const initialScale = gesture.initialScale;\n\n if (initialScale) {\n this.setState(state => Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_32__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getNormalizedZoom)(initialScale * event.scale)\n }, state)));\n }\n }); // fires only on Safari\n\n this.onGestureEnd = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n event.preventDefault(); // reselect elements only on touch screens (see onGestureStart)\n\n if (this.isTouchScreenMultiTouchGesture()) {\n this.setState({\n previousSelectedElementIds: {},\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n }\n\n gesture.initialScale = null;\n });\n\n this.startTextEditing = ({\n sceneX,\n sceneY,\n insertAtParentCenter = true,\n container,\n autoEdit = true\n }) => {\n var _a;\n\n let shouldBindToContainer = false;\n let parentCenterPosition = insertAtParentCenter && this.getTextWysiwygSnappedToCenterPosition(sceneX, sceneY, this.state, container);\n\n if (container && parentCenterPosition) {\n const boundTextElementToContainer = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(container, this.scene.getNonDeletedElementsMap());\n\n if (!boundTextElementToContainer) {\n shouldBindToContainer = true;\n }\n }\n\n let existingTextElement = null;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElements[0])) {\n existingTextElement = selectedElements[0];\n } else if (container) {\n existingTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(selectedElements[0], this.scene.getNonDeletedElementsMap());\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n\n const fontFamily = (existingTextElement === null || existingTextElement === void 0 ? void 0 : existingTextElement.fontFamily) || this.state.currentItemFontFamily;\n const lineHeight = (existingTextElement === null || existingTextElement === void 0 ? void 0 : existingTextElement.lineHeight) || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getLineHeight)(fontFamily);\n const fontSize = (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_71__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value); //zsviczian\n\n if (!existingTextElement && shouldBindToContainer && container && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container)) {\n const fontString = {\n fontSize,\n fontFamily\n };\n const minWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getApproxMinLineWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFontString)(fontString), lineHeight);\n const minHeight = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getApproxMinLineHeight)(fontSize, lineHeight);\n const newHeight = Math.max(container.height, minHeight);\n const newWidth = Math.max(container.width, minWidth);\n this.scene.mutateElement(container, {\n height: newHeight,\n width: newWidth\n });\n sceneX = container.x + newWidth / 2;\n sceneY = container.y + newHeight / 2;\n\n if (parentCenterPosition) {\n parentCenterPosition = this.getTextWysiwygSnappedToCenterPosition(sceneX, sceneY, this.state, container);\n }\n }\n\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: sceneX,\n y: sceneY\n });\n const element = existingTextElement || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newTextElement)({\n x: parentCenterPosition ? parentCenterPosition.elementCenterX : sceneX,\n y: parentCenterPosition ? parentCenterPosition.elementCenterY : sceneY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n text: \"\",\n rawText: \"\",\n fontSize,\n fontFamily,\n textAlign: parentCenterPosition ? \"center\" : this.state.currentItemTextAlign,\n verticalAlign: parentCenterPosition ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.VERTICAL_ALIGN.MIDDLE : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_VERTICAL_ALIGN,\n containerId: shouldBindToContainer ? container === null || container === void 0 ? void 0 : container.id : undefined,\n groupIds: (_a = container === null || container === void 0 ? void 0 : container.groupIds) !== null && _a !== void 0 ? _a : [],\n lineHeight,\n angle: container ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container) ? 0 : container.angle : 0,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n\n if (!existingTextElement && shouldBindToContainer && container) {\n this.scene.mutateElement(container, {\n boundElements: (container.boundElements || []).concat({\n type: \"text\",\n id: element.id\n })\n });\n }\n\n this.setState({\n editingTextElement: element\n });\n\n if (!existingTextElement) {\n if (container && shouldBindToContainer) {\n const containerIndex = this.scene.getElementIndex(container.id);\n this.scene.insertElementAtIndex(element, containerIndex + 1);\n } else {\n this.scene.insertElement(element);\n }\n }\n\n if (autoEdit || existingTextElement || container) {\n this.handleTextWysiwyg(element, {\n isExistingElement: !!existingTextElement\n });\n } else {\n this.setState({\n newElement: element,\n multiElement: null\n });\n }\n };\n\n this.debounceDoubleClickTimestamp = 0; //zsviczian\n\n this.startImageCropping = image => {\n this.store.scheduleCapture();\n this.setState({\n croppingElementId: image.id\n });\n };\n\n this.finishImageCropping = () => {\n if (this.state.croppingElementId) {\n this.store.scheduleCapture();\n this.setState({\n croppingElementId: null\n });\n }\n };\n\n this.handleCanvasDoubleClick = event => {\n var _a, _b, _c, _d; // case: double-clicking with arrow/line tool selected would both create\n // text and enter multiElement mode\n\n\n if (this.state.multiElement) {\n return;\n }\n\n if ( //zsviczian - double click eraser\n this.state.penMode && (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.allowDoubleTapEraser)() && ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a.pointerType) === \"touch\" && this.state.activeTool.type !== \"selection\") {\n const now = Date.now();\n\n if (now - this.debounceDoubleClickTimestamp < 200) {\n //handleCanvasDoubleClick click fires twice in case of touch.\n //Once from the onTouchStart event handler, once from the double click event handler\n return;\n }\n\n this.debounceDoubleClickTimestamp = now;\n this.updateScene(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.actionToggleEraserTool.perform([], this.state, null, this));\n return;\n } // zsviczian - end\n // we should only be able to double click when mode is selection\n\n\n if (this.state.activeTool.type !== this.defaultSelectionTool) {\n return;\n }\n\n const selectedElements = this.scene.getSelectedElements(this.state);\n let {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0])) {\n const selectedLinearElement = selectedElements[0];\n\n if ((event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isSimpleArrow)(selectedLinearElement) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedLinearElement)) && (!((_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.isEditing) || this.state.selectedLinearElement.elementId !== selectedLinearElement.id)) {\n // Use the proper action to ensure immediate history capture\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n return;\n } else if (this.state.selectedLinearElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0])) {\n const hitCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(this.state.selectedLinearElement, {\n x: sceneX,\n y: sceneY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const midPoint = hitCoords ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, hitCoords, this.scene.getNonDeletedElementsMap()) : -1;\n\n if (midPoint && midPoint > -1) {\n this.store.scheduleCapture();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.deleteFixedSegment(selectedElements[0], this.scene, midPoint);\n const nextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: null\n }), {\n x: sceneX,\n y: sceneY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const nextIndex = nextCoords ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, nextCoords, this.scene.getNonDeletedElementsMap()) : null;\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n pointerDownState: Object.assign(Object.assign({}, this.state.selectedLinearElement.pointerDownState), {\n segmentMidpoint: {\n index: nextIndex,\n value: hitCoords,\n added: false\n }\n }),\n segmentMidPointHoveredCoords: nextCoords\n })\n });\n return;\n }\n } else if (((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.isEditing) && this.state.selectedLinearElement.elementId === selectedLinearElement.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedLinearElement)) {\n return;\n }\n }\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(selectedElements[0])) {\n this.startImageCropping(selectedElements[0]);\n return;\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n const selectedGroupIds = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectedGroupIds)(this.state);\n\n if (selectedGroupIds.length > 0) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n const selectedGroupId = hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectedGroupIdForElement)(hitElement, this.state.selectedGroupIds);\n\n if (selectedGroupId) {\n this.store.scheduleCapture();\n this.setState(prevState => Object.assign(Object.assign({}, prevState), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: selectedGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this)));\n return;\n }\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !this.state.viewModeEnabled) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement)) {\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"active\"\n }\n });\n return;\n } // shouldn't edit/create text when inside line editor (often false positive)\n\n\n if (!((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing)) {\n const container = this.getTextBindableContainerAtPosition(sceneX, sceneY);\n\n if (container) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hasBoundTextElement)(container) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isTransparent)(container.backgroundColor) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(sceneX, sceneY),\n element: container,\n elementsMap: this.scene.getNonDeletedElementsMap(),\n threshold: this.getElementHitThreshold(container)\n })) {\n const midPoint = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerCenter)(container, this.state, this.scene.getNonDeletedElementsMap());\n sceneX = midPoint.x;\n sceneY = midPoint.y;\n }\n } //zsviczian Disable double click text create, but allow double click edit\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.disableDoubleClickTextEditing)()) {\n let existingTextElement = null;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElements[0])) {\n existingTextElement = selectedElements[0];\n } else if (container) {\n existingTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(selectedElements[0], this.scene.getNonDeletedElementsMap());\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n\n if (!existingTextElement) {\n return;\n }\n }\n\n this.startTextEditing({\n sceneX,\n sceneY,\n insertAtParentCenter: !event.altKey,\n container\n });\n }\n }\n };\n\n this.getElementLinkAtPosition = (scenePointer, hitElementMightBeLocked) => {\n if (hitElementMightBeLocked && hitElementMightBeLocked.locked) {\n return undefined;\n }\n\n const elements = this.scene.getNonDeletedElements();\n let hitElementIndex = -1;\n\n for (let index = elements.length - 1; index >= 0; index--) {\n const element = elements[index];\n\n if (hitElementMightBeLocked && element.id === hitElementMightBeLocked.id) {\n hitElementIndex = index;\n }\n\n if (element.link && index >= hitElementIndex && (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_64__.isPointHittingLink)(element, this.scene.getNonDeletedElementsMap(), this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y), this.device.editor.isMobile)) {\n return element;\n }\n }\n };\n\n this.redirectToLink = (event, isTouchScreen) => {\n const draggedDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(this.lastPointerDownEvent.clientX, this.lastPointerDownEvent.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(this.lastPointerUpEvent.clientX, this.lastPointerUpEvent.clientY));\n\n if (!this.hitLinkElement || draggedDistance > _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DRAGGING_THRESHOLD) {\n return;\n }\n\n const lastPointerDownCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(this.lastPointerDownEvent, this.state);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const lastPointerDownHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_64__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerDownCoords.x, lastPointerDownCoords.y), this.device.editor.isMobile);\n const lastPointerUpCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(this.lastPointerUpEvent, this.state);\n const lastPointerUpHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_64__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerUpCoords.x, lastPointerUpCoords.y), this.device.editor.isMobile);\n\n if (lastPointerDownHittingLinkIcon && lastPointerUpHittingLinkIcon) {\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_35__.hideHyperlinkToolip)();\n let url = this.hitLinkElement.link;\n\n if (url) {\n url = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeLink)(url);\n let customEvent;\n\n if (this.props.onLinkOpen) {\n customEvent = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.wrapEvent)(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.EXCALIDRAW_LINK, event.nativeEvent);\n this.props.onLinkOpen(Object.assign(Object.assign({}, this.hitLinkElement), {\n link: url\n }), customEvent);\n }\n\n if (!(customEvent === null || customEvent === void 0 ? void 0 : customEvent.defaultPrevented)) {\n const target = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isLocalLink)(url) ? \"_self\" : \"_blank\";\n const newWindow = window.open(undefined, target); // https://mathiasbynens.github.io/rel-noopener/\n\n if (newWindow) {\n newWindow.opener = null;\n newWindow.location = url;\n }\n }\n }\n }\n };\n\n this.getTopLayerFrameAtSceneCoords = sceneCoords => {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const frames = this.scene.getNonDeletedFramesLikes().filter(frame => !frame.locked && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isCursorInFrame)(sceneCoords, frame, elementsMap) && frame.frameRole !== \"marker\");\n return frames.length ? frames[frames.length - 1] : null;\n };\n\n this.handleCanvasPointerMove = event => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n\n this.savePointer(event.clientX, event.clientY, this.state.cursorButton);\n this.lastPointerMoveEvent = event.nativeEvent;\n\n if (gesture.pointers.has(event.pointerId)) {\n gesture.pointers.set(event.pointerId, {\n x: event.clientX,\n y: event.clientY\n });\n }\n\n const initialScale = gesture.initialScale;\n\n if (gesture.pointers.size === 2 && gesture.lastCenter && initialScale && gesture.initialDistance) {\n const center = (0,_gesture__WEBPACK_IMPORTED_MODULE_28__.getCenter)(gesture.pointers);\n const deltaX = center.x - gesture.lastCenter.x;\n const deltaY = center.y - gesture.lastCenter.y;\n gesture.lastCenter = center;\n const distance = (0,_gesture__WEBPACK_IMPORTED_MODULE_28__.getDistance)(Array.from(gesture.pointers.values()));\n const scaleFactor = !this.state.allowPinchZoom && //zsviczian\n this.state.activeTool.type === \"freedraw\" && this.state.penMode ? 1 : distance / gesture.initialDistance;\n const nextZoom = scaleFactor ? (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getNormalizedZoom)(initialScale * scaleFactor) : this.state.zoom.value;\n this.setState(state => {\n const zoomState = (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_32__.getStateForZoom)({\n viewportX: center.x,\n viewportY: center.y,\n nextZoom\n }, state);\n this.translateCanvas({\n zoom: zoomState.zoom,\n // 2x multiplier is just a magic number that makes this work correctly\n // on touchscreen devices (note: if we get report that panning is slower/faster\n // than actual movement, consider swapping with devicePixelRatio)\n scrollX: zoomState.scrollX + 2 * (deltaX / nextZoom),\n scrollY: zoomState.scrollY + 2 * (deltaY / nextZoom),\n shouldCacheIgnoreZoom: true\n });\n });\n this.resetShouldCacheIgnoreZoomDebounced();\n } else {\n gesture.lastCenter = gesture.initialDistance = gesture.initialScale = null;\n }\n\n if (isHoldingSpace || isPanning || isDraggingScrollBar || (0,_appState__WEBPACK_IMPORTED_MODULE_23__.isHandToolActive)(this.state)) {\n return;\n }\n\n const isPointerOverScrollBars = (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_47__.isOverScrollBars)(currentScrollBars, event.clientX - this.state.offsetLeft, event.clientY - this.state.offsetTop);\n const isOverScrollBar = isPointerOverScrollBars.isOverEither;\n const isPenFreedraw = this.state.activeTool.type === \"freedraw\" && event.pointerType === \"pen\"; //zsviczian\n\n if (!this.state.newElement && !this.state.selectionElement && !this.state.selectedElementsAreBeingDragged && !this.state.multiElement) {\n if (isOverScrollBar) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n } else if (isPenFreedraw && this.interactiveCanvas && (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.hideFreedrawPenmodeCursor)()) {\n //zsviczian https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1659\n this.interactiveCanvas.style.cursor = \"none\";\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n }\n\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const {\n x: scenePointerX,\n y: scenePointerY\n } = scenePointer;\n\n if (!this.state.newElement && (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.isActiveToolNonLinearSnappable)(this.state.activeTool.type)) {\n const {\n originOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.getSnapLinesAtPointer)(this.scene.getNonDeletedElements(), this, {\n x: scenePointerX,\n y: scenePointerY\n }, event, this.scene.getNonDeletedElementsMap());\n this.setState(prevState => {\n const nextSnapLines = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.snapLines, snapLines);\n const nextOriginOffset = prevState.originSnapOffset ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.originSnapOffset, originOffset) : originOffset;\n\n if (prevState.snapLines === nextSnapLines && prevState.originSnapOffset === nextOriginOffset) {\n return null;\n }\n\n return {\n snapLines: nextSnapLines,\n originSnapOffset: nextOriginOffset\n };\n });\n } else if (!this.state.newElement && !this.state.selectedElementsAreBeingDragged && !this.state.selectionElement) {\n this.setState(prevState => {\n if (prevState.snapLines.length) {\n return {\n snapLines: []\n };\n }\n\n return null;\n });\n }\n\n if (((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && !this.state.selectedLinearElement.isDragging) {\n const editingLinearElement = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerMove(event, scenePointerX, scenePointerY, this);\n const linearElement = editingLinearElement ? this.scene.getElement(editingLinearElement.elementId) : null;\n\n if (editingLinearElement && editingLinearElement !== this.state.selectedLinearElement) {\n // Since we are reading from previous state which is not possible with\n // automatic batching in React 18 hence using flush sync to synchronously\n // update the state. Check https://github.com/excalidraw/excalidraw/pull/5508 for more details.\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n selectedLinearElement: editingLinearElement\n });\n });\n }\n\n if ((editingLinearElement === null || editingLinearElement === void 0 ? void 0 : editingLinearElement.lastUncommittedPoint) != null && linearElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElementType)(linearElement.type)) {\n this.maybeSuggestBindingAtCursor(scenePointer, editingLinearElement.elbowed);\n } else if (this.state.suggestedBindings.length) {\n this.setState({\n suggestedBindings: []\n });\n }\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElementType)(this.state.activeTool.type)) {\n // Hovering with a selected tool or creating new linear element via click\n // and point\n const {\n newElement\n } = this.state;\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(newElement, false)) {\n this.setState({\n suggestedBindings: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeSuggestBindingsForLinearElementAtCoords)(newElement, [scenePointer], this.scene, this.state.zoom, this.state.startBoundElement)\n });\n } else {\n this.maybeSuggestBindingAtCursor(scenePointer, false);\n }\n }\n\n if (this.state.multiElement) {\n const {\n multiElement\n } = this.state;\n const {\n x: rx,\n y: ry\n } = multiElement;\n const {\n points,\n lastCommittedPoint\n } = multiElement;\n const lastPoint = points[points.length - 1];\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n\n if (lastPoint === lastCommittedPoint) {\n // if we haven't yet created a temp point and we're beyond commit-zone\n // threshold, add a point\n if ((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry), lastPoint) >= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.LINE_CONFIRM_THRESHOLD) {\n this.scene.mutateElement(multiElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry)]\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER); // in this branch, we're inside the commit zone, and no uncommitted\n // point exists. Thus do nothing (don't add/remove points).\n }\n } else if (points.length > 2 && lastCommittedPoint && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry), lastCommittedPoint) < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.LINE_CONFIRM_THRESHOLD) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n this.scene.mutateElement(multiElement, {\n points: points.slice(0, -1)\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(scenePointerX, scenePointerY, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(multiElement) ? null : this.getEffectiveGridSize());\n const [lastCommittedX, lastCommittedY] = (_b = multiElement === null || multiElement === void 0 ? void 0 : multiElement.lastCommittedPoint) !== null && _b !== void 0 ? _b : [0, 0];\n let dxFromLastCommitted = gridX - rx - lastCommittedX;\n let dyFromLastCommitted = gridY - ry - lastCommittedY;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldRotateWithDiscreteAngle)(event)) {\n ({\n width: dxFromLastCommitted,\n height: dyFromLastCommitted\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLockedLinearCursorAlignSize)( // actual coordinate of the last committed point\n lastCommittedX + rx, lastCommittedY + ry, // cursor-grid coordinate\n gridX, gridY));\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isPathALoop)(points, this.state.zoom.value)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } // update last uncommitted point\n\n\n this.scene.mutateElement(multiElement, {\n points: [...points.slice(0, -1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastCommittedX + dxFromLastCommitted, lastCommittedY + dyFromLastCommitted)]\n }, {\n isDragging: true,\n informMutation: false\n }); // in this path, we're mutating multiElement to reflect\n // how it will be after adding pointer position as the next point\n // trigger update here so that new element canvas renders again to reflect this\n\n this.triggerRender(false);\n }\n\n return;\n }\n\n const hasDeselectedButton = Boolean(event.buttons);\n\n if (hasDeselectedButton || this.state.activeTool.type !== \"selection\" && this.state.activeTool.type !== \"lasso\" && this.state.activeTool.type !== \"text\" && this.state.activeTool.type !== \"eraser\") {\n return;\n }\n\n const elements = this.scene.getNonDeletedElements();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1 && !isOverScrollBar && !((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.isEditing)) {\n // for linear elements, we'd like to prioritize point dragging over edge resizing\n // therefore, we update and check hovered point index first\n if (this.state.selectedLinearElement) {\n this.handleHoverSelectedLinearElement(this.state.selectedLinearElement, scenePointerX, scenePointerY);\n }\n\n if ((!this.state.selectedLinearElement || this.state.selectedLinearElement.hoverPointIndex === -1) && ((_d = this.state.openDialog) === null || _d === void 0 ? void 0 : _d.name) !== \"elementLinkSelector\" && !(selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0]))) {\n const elementWithTransformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementWithTransformHandleType)(elements, this.state, scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.device);\n\n if (elementWithTransformHandleType && elementWithTransformHandleType.transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCursorForResizingElement)(elementWithTransformHandleType));\n return;\n }\n }\n } else if (selectedElements.length > 1 && !isOverScrollBar && ((_e = this.state.openDialog) === null || _e === void 0 ? void 0 : _e.name) !== \"elementLinkSelector\") {\n const transformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getTransformHandleTypeFromCoords)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements), scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.device);\n\n if (transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCursorForResizingElement)({\n transformHandleType\n }));\n return;\n }\n }\n\n const hitElementMightBeLocked = this.getElementAtPosition(scenePointerX, scenePointerY, {\n preferSelected: true,\n includeLockedElements: true\n });\n let hitElement = null;\n\n if (hitElementMightBeLocked && hitElementMightBeLocked.locked) {\n hitElement = null;\n } else {\n hitElement = hitElementMightBeLocked;\n }\n\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElementMightBeLocked);\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state)) {\n return;\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_35__.showHyperlinkTooltip)(this.hitLinkElement, this.state, this.scene.getNonDeletedElementsMap());\n\n if (this.props.onLinkHover) {\n this.props.onLinkHover(this.hitLinkElement, event);\n } //zsviczian\n\n } else {\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_35__.hideHyperlinkToolip)();\n\n if (hitElement && (hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(hitElement)) && this.state.selectedElementIds[hitElement.id] && !this.state.contextMenu && !this.state.showHyperlinkPopup) {\n this.setState({\n showHyperlinkPopup: \"info\"\n });\n } else if (this.state.activeTool.type === \"text\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(hitElement) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.TEXT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.CROSSHAIR);\n } else if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if (((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n } else if (isOverScrollBar) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n } else if ( // if using cmd/ctrl, we're not dragging\n !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if ((hitElement || this.isHittingCommonBoundingBoxOfSelectedElements(scenePointer, selectedElements)) && !(hitElement === null || hitElement === void 0 ? void 0 : hitElement.locked)) {\n if (hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, event, scenePointerX, scenePointerY)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"hover\"\n }\n });\n } else if (!hitElement || // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(hitElement) || !(hitElement.startBinding || hitElement.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || selectedElements.length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\n\n if (((_g = this.state.activeEmbeddable) === null || _g === void 0 ? void 0 : _g.state) === \"hover\") {\n this.setState({\n activeEmbeddable: null\n });\n }\n }\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n }\n\n if (this.state.selectedLinearElement) {\n this.handleHoverSelectedLinearElement(this.state.selectedLinearElement, scenePointerX, scenePointerY);\n }\n }\n\n if (((_h = this.state.openDialog) === null || _h === void 0 ? void 0 : _h.name) === \"elementLinkSelector\" && hitElement) {\n this.setState(prevState => {\n return {\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.hoveredElementIds, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this).selectedElementIds)\n };\n });\n } else if (((_j = this.state.openDialog) === null || _j === void 0 ? void 0 : _j.name) === \"elementLinkSelector\" && !hitElement) {\n this.setState(prevState => ({\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.hoveredElementIds, {})\n }));\n }\n };\n\n this.handleEraser = (event, scenePointer) => {\n const elementsToErase = this.eraserTrail.addPointToPath(scenePointer.x, scenePointer.y, event.altKey);\n this.elementsPendingErasure = new Set(elementsToErase);\n this.triggerRender();\n }; // set touch moving for mobile context menu\n\n\n this.handleTouchMove = event => {\n this.resetContextMenuTimer(); //zsviczian\n };\n\n this.handleCanvasPointerDown = event => {\n var _a, _b, _c, _d, _e; //mfuria #329. Right-click pan support when enabled via host plugin setting\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.isPanWithRightMouseEnabled)() && event.pointerType === \"mouse\" && event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.SECONDARY && !this.state.editingTextElement) {\n // prevent native context menu\n const onContextMenu = e => {\n e.preventDefault();\n };\n\n window.addEventListener('contextmenu', onContextMenu, {\n once: true\n }); // Start right-click panning\n\n this.startRightClickPanning(event);\n return;\n } //zsviczian - begin\n\n\n const isInsideEmbeddableContainer = !!((_b = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest) === null || _b === void 0 ? void 0 : _b.call(_a, \".excalidraw__embeddable-container\"));\n\n if (!isInsideEmbeddableContainer) {\n this.focusContainer();\n } //zsviczian - end\n\n\n const target = event.target; // capture subsequent pointer events to the canvas\n // this makes other elements non-interactive until pointer up\n\n if (target.setPointerCapture) {\n target.setPointerCapture(event.pointerId);\n }\n\n this.maybeCleanupAfterMissingPointerUp(event.nativeEvent);\n this.maybeUnfollowRemoteUser();\n\n if (this.state.searchMatches) {\n this.setState(state => {\n return {\n searchMatches: state.searchMatches && {\n focusedId: null,\n matches: state.searchMatches.matches.map(searchMatch => Object.assign(Object.assign({}, searchMatch), {\n focus: false\n }))\n }\n };\n });\n this.updateEditorAtom(_SearchMenu__WEBPACK_IMPORTED_MODULE_60__.searchItemInFocusAtom, null);\n }\n\n if (_editor_jotai__WEBPACK_IMPORTED_MODULE_37__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom)) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom, null);\n } // since contextMenu options are potentially evaluated on each render,\n // and an contextMenu action may depend on selection state, we must\n // close the contextMenu before we update the selection on pointerDown\n // (e.g. resetting selection)\n\n\n if (this.state.contextMenu) {\n this.setState({\n contextMenu: null\n });\n }\n\n if (this.state.snapLines) {\n this.setAppState({\n snapLines: []\n });\n }\n\n this.updateGestureOnPointerDown(event); // if dragging element is freedraw and another pointerdown event occurs\n // a second finger is on the screen\n // discard the freedraw element if it is very short because it is likely\n // just a spike, otherwise finalize the freedraw element when the second\n // finger is lifted\n\n if (event.pointerType === \"touch\" && this.state.newElement && this.state.newElement.type === \"freedraw\") {\n const element = this.state.newElement;\n this.updateScene(Object.assign(Object.assign({}, element.points.length < 10 ? {\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== element.id)\n } : {}), {\n appState: {\n newElement: null,\n editingTextElement: null,\n startBoundElement: null,\n suggestedBindings: [],\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.keys(this.state.selectedElementIds).filter(key => key !== element.id).reduce((obj, key) => {\n obj[key] = this.state.selectedElementIds[key];\n return obj;\n }, {}), this.state)\n },\n captureUpdate: ((_c = this.state.openDialog) === null || _c === void 0 ? void 0 : _c.name) === \"elementLinkSelector\" ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.EVENTUALLY : _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER\n }));\n return;\n } // remove any active selection when we start to interact with canvas\n // (mainly, we care about removing selection outside the component which\n // would prevent our copy handling otherwise)\n\n\n const selection = document.getSelection();\n\n if (selection === null || selection === void 0 ? void 0 : selection.anchorNode) {\n selection.removeAllRanges();\n }\n\n this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(event); //fires only once, if pen is detected, penMode is enabled\n //the user can disable this by toggling the penMode button\n\n if (!this.state.penDetected && event.pointerType === \"pen\") {\n this.setState(prevState => {\n return {\n penMode: true,\n penDetected: true\n };\n });\n }\n\n if (!this.device.isTouchScreen && [\"pen\", \"touch\"].includes(event.pointerType)) {\n this.device = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(this.device, {\n isTouchScreen: true\n });\n }\n\n if (isPanning) {\n return;\n }\n\n this.lastPointerDownEvent = event; // we must exit before we set `cursorButton` state and `savePointer`\n // else it will send pointer state & laser pointer events in collab when\n // panning\n\n /*if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {\r\n return;\r\n }*/\n //zsviczian this broke on pointer down in onPointerUpdate\n\n this.setState({\n lastPointerDownWith: event.pointerType,\n cursorButton: \"down\"\n });\n this.savePointer(event.clientX, event.clientY, \"down\");\n\n if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {\n return;\n } //zsviczian moved it here, because else pointer down in onPointerUpdate did not work\n\n\n if (event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.ERASER && this.state.activeTool.type !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.eraser) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.eraser,\n lastActiveToolBeforeEraser: this.state.activeTool\n })\n }, () => {\n this.handleCanvasPointerDown(event);\n\n const onPointerUp = () => {\n unsubPointerUp();\n unsubCleanup === null || unsubCleanup === void 0 ? void 0 : unsubCleanup();\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, Object.assign(Object.assign({}, this.state.activeTool.lastActiveTool || {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.selection\n }), {\n lastActiveToolBeforeEraser: null\n }))\n });\n }\n };\n\n const unsubPointerUp = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp, {\n once: true\n });\n let unsubCleanup; // subscribe inside rAF lest it'd be triggered on the same pointerdown\n // if we start erasing while coming from blurred document since\n // we cleanup pointer events on focus\n\n requestAnimationFrame(() => {\n unsubCleanup = this.missingPointerEventCleanupEmitter.once(onPointerUp);\n });\n });\n return;\n } // only handle left mouse button or touch\n\n\n if (event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.MAIN && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.TOUCH && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.ERASER) {\n return;\n } // don't select while panning\n\n\n if (gesture.pointers.size > 1) {\n return;\n } // State for the duration of a pointer interaction, which starts with a\n // pointerDown event, ends with a pointerUp event (or another pointerDown)\n\n\n const pointerDownState = this.initialPointerDownState(event);\n this.setState({\n selectedElementsAreBeingDragged: false\n });\n\n if (this.handleDraggingScrollBar(event, pointerDownState)) {\n return;\n }\n\n this.clearSelectionIfNotUsingSelection();\n this.updateBindingEnabledOnPointerMove(event);\n\n if (this.handleSelectionOnPointerDown(event, pointerDownState)) {\n return;\n }\n\n const allowOnPointerDown = !this.state.penMode || event.pointerType !== \"touch\" || this.state.activeTool.type === \"selection\" || this.state.activeTool.type === \"lasso\" || this.state.activeTool.type === \"text\" || this.state.activeTool.type === \"image\";\n\n if (!allowOnPointerDown) {\n return;\n }\n\n if (this.state.activeTool.type === \"lasso\") {\n const hitSelectedElement = pointerDownState.hit.element && this.isASelectedElement(pointerDownState.hit.element);\n\n if (!pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements && !pointerDownState.resize.handleType && !hitSelectedElement) {\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey); // block dragging after lasso selection on PCs until the next pointer down\n // (on mobile or tablet, we want to allow user to drag immediately)\n\n pointerDownState.drag.blockDragging = !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)();\n } // only for mobile or tablet, if we hit an element, select it immediately like normal selection\n\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() && pointerDownState.hit.element && !hitSelectedElement) {\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [pointerDownState.hit.element.id]: true\n });\n const previouslySelectedElements = [];\n Object.keys(prevState.selectedElementIds).forEach(id => {\n const element = this.scene.getElement(id);\n element && previouslySelectedElements.push(element);\n });\n const hitElement = pointerDownState.hit.element; // if hitElement is frame-like, deselect all of its elements\n // if they are selected\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getFrameChildren)(previouslySelectedElements, hitElement.id).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n } else if (hitElement.frameId) {\n // if hitElement is in a frame and its frame has been selected\n // disable selection for the given element\n if (nextSelectedElementIds[hitElement.frameId]) {\n delete nextSelectedElementIds[hitElement.id];\n }\n } else {\n // hitElement is neither a frame nor an element in a frame\n // but since hitElement could be in a group with some frames\n // this means selecting hitElement will have the frames selected as well\n // because we want to keep the invariant:\n // - frames and their elements are not selected at the same time\n // we deselect elements in those frames that were previously selected\n const groupIds = hitElement.groupIds;\n const framesInGroups = new Set(groupIds.flatMap(gid => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element)).map(frame => frame.id));\n\n if (framesInGroups.size > 0) {\n previouslySelectedElements.forEach(element => {\n if (element.frameId && framesInGroups.has(element.frameId)) {\n // deselect element and groups containing the element\n delete nextSelectedElementIds[element.id];\n element.groupIds.flatMap(gid => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n }\n });\n }\n }\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n pointerDownState.hit.wasAddedToSelection = true;\n }\n } else if (this.state.activeTool.type === \"text\") {\n this.handleTextOnPointerDown(event, pointerDownState);\n } else if (this.state.activeTool.type === \"arrow\" || this.state.activeTool.type === \"line\") {\n this.handleLinearElementOnPointerDown(event, this.state.activeTool.type, pointerDownState);\n } else if (this.state.activeTool.type === \"freedraw\") {\n this.handleFreeDrawElementOnPointerDown(event, this.state.activeTool.type, pointerDownState);\n } else if (this.state.activeTool.type === \"custom\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n } else if (this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe) {\n this.createFrameElementOnPointerDown(pointerDownState, this.state.activeTool.type);\n } else if (this.state.activeTool.type === \"laser\") {\n this.laserTrails.startPath(pointerDownState.lastCoords.x, pointerDownState.lastCoords.y);\n } else if (this.state.activeTool.type !== \"eraser\" && this.state.activeTool.type !== \"hand\" && this.state.activeTool.type !== \"mermaid\" && //zsviczian\n this.state.activeTool.type !== \"image\") {\n this.createGenericElementOnPointerDown(this.state.activeTool.type, pointerDownState);\n }\n\n (_e = (_d = this.props) === null || _d === void 0 ? void 0 : _d.onPointerDown) === null || _e === void 0 ? void 0 : _e.call(_d, this.state.activeTool, pointerDownState);\n this.onPointerDownEmitter.trigger(this.state.activeTool, pointerDownState, event);\n\n if (this.state.activeTool.type === \"eraser\") {\n this.eraserTrail.startPath(pointerDownState.lastCoords.x, pointerDownState.lastCoords.y);\n }\n\n const onPointerMove = this.onPointerMoveFromPointerDownHandler(pointerDownState);\n const onPointerUp = this.onPointerUpFromPointerDownHandler(pointerDownState);\n const onKeyDown = this.onKeyDownFromPointerDownHandler(pointerDownState);\n const onKeyUp = this.onKeyUpFromPointerDownHandler(pointerDownState);\n this.missingPointerEventCleanupEmitter.once(_event => onPointerUp(_event || event.nativeEvent));\n\n if (!this.state.viewModeEnabled || this.state.activeTool.type === \"laser\") {\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, onKeyDown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYUP, onKeyUp);\n pointerDownState.eventListeners.onMove = onPointerMove;\n pointerDownState.eventListeners.onUp = onPointerUp;\n pointerDownState.eventListeners.onKeyUp = onKeyUp;\n pointerDownState.eventListeners.onKeyDown = onKeyDown;\n }\n };\n\n this.handleCanvasPointerUp = event => {\n var _a, _b;\n\n this.removePointer(event);\n this.lastPointerUpEvent = event;\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: event.clientX,\n clientY: event.clientY\n }, this.state);\n const clicklength = event.timeStamp - ((_b = (_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a.timeStamp) !== null && _b !== void 0 ? _b : 0);\n\n if (this.device.editor.isMobile && clicklength < 300) {\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, event, scenePointer.x, scenePointer.y)) {\n this.handleEmbeddableCenterClick(hitElement);\n return;\n }\n }\n\n if (this.device.isTouchScreen) {\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y, {\n includeLockedElements: true\n });\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElement);\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n if (clicklength < 300 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(this.hitLinkElement) && !(0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_64__.isPointHittingLinkIcon)(this.hitLinkElement, this.scene.getNonDeletedElementsMap(), this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y))) {\n this.handleEmbeddableCenterClick(this.hitLinkElement);\n } else {\n this.redirectToLink(event, this.device.isTouchScreen);\n }\n } else if (this.state.viewModeEnabled) {\n this.setState({\n activeEmbeddable: null,\n selectedElementIds: {}\n });\n }\n };\n\n this.maybeOpenContextMenuAfterPointerDownOnTouchDevices = event => {\n // deal with opening context menu on touch devices\n if (event.pointerType === \"touch\") {\n invalidateContextMenu = false;\n\n if (touchTimeout) {\n // If there's already a touchTimeout, this means that there's another\n // touch down and we are doing another touch, so we shouldn't open the\n // context menu.\n invalidateContextMenu = true;\n } else {\n // open the context menu with the first touch's clientX and clientY\n // if the touch is not moving\n touchTimeout = window.setTimeout(() => {\n touchTimeout = 0;\n\n if (!invalidateContextMenu) {\n this.handleCanvasContextMenu(event);\n }\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOUCH_CTX_MENU_TIMEOUT);\n }\n }\n };\n\n this.resetContextMenuTimer = () => {\n clearTimeout(touchTimeout);\n touchTimeout = 0;\n invalidateContextMenu = false;\n };\n /**\r\n * pointerup may not fire in certian cases (user tabs away...), so in order\r\n * to properly cleanup pointerdown state, we need to fire any hanging\r\n * pointerup handlers manually\r\n */\n\n\n this.maybeCleanupAfterMissingPointerUp = event => {\n lastPointerUp === null || lastPointerUp === void 0 ? void 0 : lastPointerUp();\n this.missingPointerEventCleanupEmitter.trigger(event).clear();\n }; // Returns whether the event is a panning\n\n\n this.handleCanvasPanUsingWheelOrSpaceDrag = event => {\n if (!(gesture.pointers.size <= 1 && (event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.WHEEL || event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.MAIN && isHoldingSpace || (0,_appState__WEBPACK_IMPORTED_MODULE_23__.isHandToolActive)(this.state) || //zsviczian\n (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.isTouchInPenMode)(this.state, event) || //!isLaserPointerActive added by zsviczian (but don't remember why....)\n this.state.viewModeEnabled && !(0,_appState__WEBPACK_IMPORTED_MODULE_23__.isLaserPointerActive)(this.state)))) {\n return false;\n }\n\n isPanning = true; // due to event.preventDefault below, container wouldn't get focus\n // automatically\n\n this.focusContainer(); // preventing defualt while text editing messes with cursor/focus\n\n if (!this.state.editingTextElement) {\n // necessary to prevent browser from scrolling the page if excalidraw\n // not full-page #4489\n //\n // as such, the above is broken when panning canvas while in wysiwyg\n event.preventDefault();\n }\n\n let nextPastePrevented = false;\n const isLinux = typeof window === undefined ? false : /Linux/.test(window.navigator.platform);\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRABBING);\n let {\n clientX: lastX,\n clientY: lastY\n } = event;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdatesThrottled)(event => {\n const deltaX = lastX - event.clientX;\n const deltaY = lastY - event.clientY;\n lastX = event.clientX;\n lastY = event.clientY;\n /*\r\n * Prevent paste event if we move while middle clicking on Linux.\r\n * See issue #1383.\r\n */\n\n if (isLinux && !nextPastePrevented && (Math.abs(deltaX) > 1 || Math.abs(deltaY) > 1)) {\n nextPastePrevented = true;\n /* Prevent the next paste event */\n\n const preventNextPaste = event => {\n document.body.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, preventNextPaste);\n event.stopPropagation();\n };\n /*\r\n * Reenable next paste in case of disabled middle click paste for\r\n * any reason:\r\n * - right click paste\r\n * - empty clipboard\r\n */\n\n\n const enableNextPaste = () => {\n setTimeout(() => {\n document.body.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, preventNextPaste);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, enableNextPaste);\n }, 100);\n };\n\n document.body.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, preventNextPaste);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, enableNextPaste);\n }\n\n this.translateCanvas({\n scrollX: this.state.scrollX - deltaX / this.state.zoom.value,\n scrollY: this.state.scrollY - deltaY / this.state.zoom.value\n });\n });\n const teardown = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(lastPointerUp = () => {\n lastPointerUp = null;\n isPanning = false;\n\n if (!isHoldingSpace) {\n if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n }\n\n this.setState({\n cursorButton: \"up\"\n });\n this.savePointer(event.clientX, event.clientY, \"up\");\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n onPointerMove.flush();\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove, {\n passive: true\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n return true;\n };\n\n this.clearSelectionIfNotUsingSelection = () => {\n if (this.state.activeTool.type !== \"selection\" && this.state.activeTool.type !== \"lasso\") {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n };\n /**\r\n * @returns whether the pointer event has been completely handled\r\n */\n\n\n this.handleSelectionOnPointerDown = (event, pointerDownState) => {\n var _a, _b, _c, _d, _e;\n\n if (this.state.activeTool.type === \"selection\" || this.state.activeTool.type === \"lasso\") {\n const elements = this.scene.getNonDeletedElements();\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1 && !((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0]) && !((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedElements[0]) && _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointIndexUnderCursor(selectedElements[0], elementsMap, this.state.zoom, pointerDownState.origin.x, pointerDownState.origin.y) !== -1) && !(this.state.selectedLinearElement && this.state.selectedLinearElement.hoverPointIndex !== -1)) {\n const elementWithTransformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementWithTransformHandleType)(elements, this.state, pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.device);\n\n if (elementWithTransformHandleType != null) {\n if (elementWithTransformHandleType.transformHandleType === \"rotation\") {\n this.setState({\n resizingElement: elementWithTransformHandleType.element\n });\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n } else if (this.state.croppingElementId) {\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n } else {\n this.setState({\n resizingElement: elementWithTransformHandleType.element\n });\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n }\n }\n } else if (selectedElements.length > 1) {\n pointerDownState.resize.handleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getTransformHandleTypeFromCoords)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements), pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.device);\n }\n\n if (pointerDownState.resize.handleType) {\n pointerDownState.resize.isResizing = true;\n pointerDownState.resize.offset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.tupleToCoors)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getResizeOffsetXY)(pointerDownState.resize.handleType, selectedElements, elementsMap, pointerDownState.origin.x, pointerDownState.origin.y));\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0]) && selectedElements[0].points.length === 2) {\n pointerDownState.resize.arrowDirection = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getResizeArrowDirection)(pointerDownState.resize.handleType, selectedElements[0]);\n }\n } else {\n if (this.state.selectedLinearElement) {\n const linearElementEditor = this.state.selectedLinearElement;\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerDown(event, this, this.store, pointerDownState.origin, linearElementEditor, this.scene);\n\n if (ret.hitElement) {\n pointerDownState.hit.element = ret.hitElement;\n }\n\n if (ret.linearElementEditor) {\n this.setState({\n selectedLinearElement: ret.linearElementEditor\n });\n }\n\n if (ret.didAddPoint) {\n return true;\n }\n }\n\n const allHitElements = this.getElementsAtPosition(pointerDownState.origin.x, pointerDownState.origin.y, {\n includeLockedElements: true\n });\n const unlockedHitElements = allHitElements.filter(e => !e.locked); // Cannot set preferSelected in getElementAtPosition as we do in pointer move; consider:\n // A & B: both unlocked, A selected, B on top, A & B overlaps in some way\n // we want to select B when clicking on the overlapping area\n\n const hitElementMightBeLocked = this.getElementAtPosition(pointerDownState.origin.x, pointerDownState.origin.y, {\n allHitElements\n });\n\n if (!hitElementMightBeLocked || hitElementMightBeLocked.id !== this.state.activeLockedId) {\n this.setState({\n activeLockedId: null\n });\n }\n\n const isUnlockedHitElSelected = unlockedHitElements.some(el => this.state.selectedElementIds[el.id]); //zsviczian\n // Prioritize unlocked elements over locked ones\n\n if (!isUnlockedHitElSelected && unlockedHitElements.length > 0) {\n //zsviczian https://github.com/excalidraw/excalidraw/pull/9582\n // If there are unlocked elements, use the topmost one\n pointerDownState.hit.element = unlockedHitElements[unlockedHitElements.length - 1];\n } else if (hitElementMightBeLocked && hitElementMightBeLocked.locked && !isUnlockedHitElSelected //zsviczian\n ) {\n pointerDownState.hit.element = null;\n } else {\n // hitElement may already be set above, so check first\n pointerDownState.hit.element = (_b = pointerDownState.hit.element) !== null && _b !== void 0 ? _b : this.getElementAtPosition(pointerDownState.origin.x, pointerDownState.origin.y);\n }\n\n this.hitLinkElement = this.getElementLinkAtPosition(pointerDownState.origin, hitElementMightBeLocked);\n\n if (this.hitLinkElement) {\n return true;\n }\n\n if (this.state.croppingElementId && ((_c = pointerDownState.hit.element) === null || _c === void 0 ? void 0 : _c.id) !== this.state.croppingElementId) {\n this.finishImageCropping();\n }\n\n if (pointerDownState.hit.element) {\n // Early return if pointer is hitting link icon\n const hitLinkElement = this.getElementLinkAtPosition({\n x: pointerDownState.origin.x,\n y: pointerDownState.origin.y\n }, pointerDownState.hit.element);\n\n if (hitLinkElement) {\n return false;\n }\n } // For overlapped elements one position may hit\n // multiple elements\n\n\n pointerDownState.hit.allHitElements = unlockedHitElements;\n const hitElement = pointerDownState.hit.element;\n const someHitElementIsSelected = pointerDownState.hit.allHitElements.some(element => this.isASelectedElement(element));\n\n if ((hitElement === null || !someHitElementIsSelected) && !event.shiftKey && !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) {\n this.clearSelection(hitElement);\n }\n\n if ((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [this.state.selectedLinearElement.elementId]: true\n }, this.state)\n }); // If we click on something\n } else if (hitElement != null) {\n // == deep selection ==\n // on CMD/CTRL, drill down to hit element regardless of groups etc.\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if (event.altKey) {\n // ctrl + alt means we're lasso selecting - start lasso trail and switch to lasso tool\n // Close any open dialogs that might interfere with lasso selection\n if (((_e = this.state.openDialog) === null || _e === void 0 ? void 0 : _e.name) === \"elementLinkSelector\") {\n this.setOpenDialog(null);\n }\n\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n this.setActiveTool({\n type: \"lasso\",\n fromSelection: true\n });\n return false;\n }\n\n if (!this.state.selectedElementIds[hitElement.id]) {\n pointerDownState.hit.wasAddedToSelection = true;\n }\n\n this.setState(prevState => Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.editGroupForSelectedElement)(prevState, hitElement)), {\n previousSelectedElementIds: this.state.selectedElementIds\n })); // mark as not completely handled so as to allow dragging etc.\n\n return false;\n } // deselect if item is selected\n // if shift is not clicked, this will always return true\n // otherwise, it will trigger selection based on current\n // state of the box\n\n\n if (!this.state.selectedElementIds[hitElement.id]) {\n // if we are currently editing a group, exiting editing mode and deselect the group.\n if (this.state.editingGroupId && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInGroup)(hitElement, this.state.editingGroupId)) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n } // Add hit element to selection. At this point if we're not holding\n // SHIFT the previously selected element(s) were deselected above\n // (make sure you use setState updater to use latest state)\n // With shift-selection, we want to make sure that frames and their containing\n // elements are not selected at the same time.\n\n\n if (!someHitElementIsSelected && !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) {\n this.setState(prevState => {\n var _a;\n\n let nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [hitElement.id]: true\n });\n const previouslySelectedElements = [];\n Object.keys(prevState.selectedElementIds).forEach(id => {\n const element = this.scene.getElement(id);\n element && previouslySelectedElements.push(element);\n }); // if hitElement is frame-like, deselect all of its elements\n // if they are selected\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getFrameChildren)(previouslySelectedElements, hitElement.id).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n } else if (hitElement.frameId) {\n // if hitElement is in a frame and its frame has been selected\n // disable selection for the given element\n if (nextSelectedElementIds[hitElement.frameId]) {\n delete nextSelectedElementIds[hitElement.id];\n }\n } else {\n // hitElement is neither a frame nor an element in a frame\n // but since hitElement could be in a group with some frames\n // this means selecting hitElement will have the frames selected as well\n // because we want to keep the invariant:\n // - frames and their elements are not selected at the same time\n // we deselect elements in those frames that were previously selected\n const groupIds = hitElement.groupIds;\n const framesInGroups = new Set(groupIds.flatMap(gid => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element)).map(frame => frame.id));\n\n if (framesInGroups.size > 0) {\n previouslySelectedElements.forEach(element => {\n if (element.frameId && framesInGroups.has(element.frameId)) {\n // deselect element and groups containing the element\n delete nextSelectedElementIds[element.id];\n element.groupIds.flatMap(gid => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n }\n });\n }\n } // Finally, in shape selection mode, we'd like to\n // keep only one shape or group selected at a time.\n // This means, if the hitElement is a different shape or group\n // than the previously selected ones, we deselect the previous ones\n // and select the hitElement\n\n\n if (((_a = prevState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n if (!hitElement.groupIds.some(gid => prevState.selectedGroupIds[gid])) {\n nextSelectedElementIds = {\n [hitElement.id]: true\n };\n }\n }\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n pointerDownState.hit.wasAddedToSelection = true;\n }\n }\n }\n\n this.setState({\n previousSelectedElementIds: this.state.selectedElementIds\n });\n }\n }\n\n return false;\n };\n\n this.handleTextOnPointerDown = (event, pointerDownState) => {\n // if we're currently still editing text, clicking outside\n // should only finalize it, not create another (irrespective\n // of state.activeTool.locked)\n if (this.state.editingTextElement) {\n return;\n }\n\n let sceneX = pointerDownState.origin.x;\n let sceneY = pointerDownState.origin.y;\n const element = this.getElementAtPosition(sceneX, sceneY, {\n includeBoundTextElement: true\n }); // FIXME\n\n let container = this.getTextBindableContainerAtPosition(sceneX, sceneY);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hasBoundTextElement)(element)) {\n container = element;\n sceneX = element.x + element.width / 2;\n sceneY = element.y + element.height / 2;\n }\n\n this.startTextEditing({\n sceneX,\n sceneY,\n insertAtParentCenter: !event.altKey,\n container,\n autoEdit: false\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n\n if (!this.state.activeTool.locked) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.defaultSelectionTool\n })\n });\n }\n };\n\n this.handleFreeDrawElementOnPointerDown = (event, elementType, pointerDownState) => {\n // Begin a mark capture. This does not have to update state yet.\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, null);\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n const strokeOptions = this.state.currentStrokeOptions; //zsviczian\n\n const simulatePressure = (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure //zsviczian\n ) ? false : event.pressure === 0.5;\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newFreeDrawElement)(Object.assign(Object.assign({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: null,\n simulatePressure,\n locked: false\n }, strokeOptions //zsviczian\n ? {\n customData: {\n strokeOptions\n }\n } : {}), {\n frameId: topLayerFrame ? topLayerFrame.id : null,\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0)],\n pressures: simulatePressure ? [] : [(strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure) ? 1 : event.pressure]\n })); //zsviczian\n\n if (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.highlighter) {\n this.scene.insertElement(element, 0);\n } else {\n this.scene.insertElement(element);\n }\n\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete nextSelectedElementIds[element.id];\n return {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextSelectedElementIds, prevState)\n };\n });\n const boundElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)(pointerDownState.origin, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom);\n this.setState({\n newElement: element,\n startBoundElement: boundElement,\n suggestedBindings: []\n });\n };\n\n this.insertIframeElement = ({\n sceneX,\n sceneY,\n width,\n height\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newIframeElement)({\n type: \"iframe\",\n x: gridX,\n y: gridY,\n strokeColor: \"transparent\",\n backgroundColor: \"transparent\",\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: this.getCurrentItemRoundness(\"iframe\"),\n opacity: this.state.currentItemOpacity,\n locked: false,\n width,\n height\n });\n this.scene.insertElement(element);\n return element;\n }; //create rectangle element with youtube top left on nearest grid point width / hight 640/360\n\n\n this.insertEmbeddableElement = ({\n sceneX,\n sceneY,\n link\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const embedLink = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)(link);\n\n if (!embedLink) {\n return;\n }\n\n if (embedLink.error instanceof URIError) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"toast.unrecognizedLinkFormat\"),\n closable: true\n });\n }\n\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newEmbeddableElement)({\n type: \"embeddable\",\n x: gridX,\n y: gridY,\n strokeColor: \"transparent\",\n backgroundColor: \"transparent\",\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: this.getCurrentItemRoundness(\"embeddable\"),\n opacity: this.state.currentItemOpacity,\n locked: false,\n width: embedLink.intrinsicSize.w,\n height: embedLink.intrinsicSize.h,\n link\n });\n this.scene.insertElement(element);\n return element;\n };\n\n this.newImagePlaceholder = ({\n sceneX,\n sceneY,\n addToFrameUnderCursor = true\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const topLayerFrame = addToFrameUnderCursor ? this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n }) : null;\n const placeholderSize = 100 / this.state.zoom.value;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newImageElement)({\n type: \"image\",\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: null,\n opacity: this.state.currentItemOpacity,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null,\n x: gridX - placeholderSize / 2,\n y: gridY - placeholderSize / 2,\n width: placeholderSize,\n height: placeholderSize\n });\n };\n\n this.handleLinearElementOnPointerDown = (event, elementType, pointerDownState) => {\n if (this.state.multiElement) {\n const {\n multiElement\n } = this.state; // finalize if completing a loop\n\n if (multiElement.type === \"line\" && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isPathALoop)(multiElement.points, this.state.zoom.value)) {\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n return;\n } // Elbow arrows cannot be created by putting down points\n // only the start and end points can be defined\n\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(multiElement) && multiElement.points.length > 1) {\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n return;\n }\n\n const {\n x: rx,\n y: ry,\n lastCommittedPoint\n } = multiElement; // clicking inside commit zone → finalize arrow\n\n if (multiElement.points.length > 1 && lastCommittedPoint && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x - rx, pointerDownState.origin.y - ry), lastCommittedPoint) < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.LINE_CONFIRM_THRESHOLD) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n return;\n }\n\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [multiElement.id]: true\n }), prevState)\n })); // clicking outside commit zone → update reference for last committed\n // point\n\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } else {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n /* If arrow is pre-arrowheads, it will have undefined for both start and end arrowheads.\r\n If so, we want it to be null for start and \"arrow\" for end. If the linear item is not\r\n an arrow, we want it to be null for both. Otherwise, we want it to use the\r\n values from appState. */\n\n const {\n currentItemStartArrowhead,\n currentItemEndArrowhead\n } = this.state;\n const [startArrowhead, endArrowhead] = elementType === \"arrow\" ? [currentItemStartArrowhead, currentItemEndArrowhead] : [null, null];\n const element = elementType === \"arrow\" ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newArrowElement)({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.round ? {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : // note, roundness doesn't have any effect for elbow arrows,\n // but it's best to set it to null as well\n null,\n startArrowhead,\n endArrowhead,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null,\n elbowed: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.elbow,\n fixedSegments: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.elbow ? [] : null\n }) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newLinearElement)({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.state.currentItemRoundness === \"round\" ? {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete nextSelectedElementIds[element.id];\n return {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextSelectedElementIds, prevState)\n };\n });\n this.scene.mutateElement(element, {\n points: [...element.points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0)]\n });\n const boundElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)(pointerDownState.origin, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element));\n this.scene.insertElement(element);\n this.setState({\n newElement: element,\n startBoundElement: boundElement,\n suggestedBindings: []\n });\n }\n };\n\n this.createGenericElementOnPointerDown = (elementType, pointerDownState) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n const baseElementAttributes = {\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.getCurrentItemRoundness(elementType),\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n };\n let element;\n\n if (elementType === \"embeddable\") {\n element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newEmbeddableElement)(Object.assign({\n type: \"embeddable\"\n }, baseElementAttributes));\n } else {\n element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElement)(Object.assign({\n type: elementType\n }, baseElementAttributes));\n }\n\n if (element.type === \"selection\") {\n this.setState({\n selectionElement: element\n });\n } else {\n this.scene.insertElement(element);\n this.setState({\n multiElement: null,\n newElement: element\n });\n }\n };\n\n this.createFrameElementOnPointerDown = (pointerDownState, type) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const constructorOpts = Object.assign(Object.assign(Object.assign({\n x: gridX,\n y: gridY,\n opacity: this.state.currentItemOpacity,\n locked: false\n }, type === \"frame\" && this.state.currentItemFrameRole ? {\n frameRole: this.state.currentItemFrameRole\n } : {}), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE), this.state.frameColor ? {\n //zsviczian\n customData: {\n frameColor: this.state.frameColor\n }\n } : {});\n const frame = type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newMagicFrameElement)(constructorOpts) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newFrameElement)(constructorOpts, this.scene.getNonDeletedElements()); //zsviczian\n\n this.scene.insertElement(frame);\n this.setState({\n multiElement: null,\n newElement: frame\n });\n };\n\n this.restoreReadyToEraseElements = () => {\n this.elementsPendingErasure = new Set();\n this.triggerRender();\n };\n\n this.eraseElements = () => {\n let didChange = false;\n const elements = this.scene.getElementsIncludingDeleted().map(ele => {\n if (this.elementsPendingErasure.has(ele.id) || ele.frameId && this.elementsPendingErasure.has(ele.frameId) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(ele) && this.elementsPendingErasure.has(ele.containerId)) {\n didChange = true;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(ele, {\n isDeleted: true\n });\n }\n\n return ele;\n });\n this.elementsPendingErasure = new Set();\n\n if (didChange) {\n this.store.scheduleCapture();\n this.scene.replaceAllElements(elements);\n }\n };\n\n this.initializeImage = async (placeholderImageElement, imageFile) => {\n var _a, _b, _c; // at this point this should be guaranteed image file, but we do this check\n // to satisfy TS down the line\n\n\n if (!(0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.isSupportedImageFile)(imageFile)) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.unsupportedFileType\"));\n }\n\n const mimeType = imageFile.type;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, \"wait\");\n\n if (mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg) {\n try {\n imageFile = (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.SVGStringToFile)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.normalizeSVG)(await imageFile.text()), imageFile.name);\n } catch (error) {\n console.warn(error);\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.svgImageInsertError\"));\n }\n } // generate image id (by default the file digest) before any\n // resizing/compression takes place to keep it more portable\n\n\n const fileId = await (((_b = (_a = this.props).generateIdForFile) === null || _b === void 0 ? void 0 : _b.call(_a, imageFile)) || (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.generateIdFromFile)(imageFile));\n\n if (!fileId) {\n console.warn(\"Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one.\");\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.imageInsertError\"));\n }\n\n const existingFileData = this.files[fileId];\n\n if (!(existingFileData === null || existingFileData === void 0 ? void 0 : existingFileData.dataURL)) {\n try {\n imageFile = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.resizeImageFile)(imageFile, {\n maxWidthOrHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT\n });\n } catch (error) {\n console.error(\"Error trying to resizing image file on insertion\", error);\n }\n\n if (imageFile.size > _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MAX_ALLOWED_FILE_BYTES) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.fileTooBig\", {\n maxSize: `${Math.trunc(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MAX_ALLOWED_FILE_BYTES / 1024 / 1024)}MB`\n }));\n }\n }\n\n const dataURL = ((_c = this.files[fileId]) === null || _c === void 0 ? void 0 : _c.dataURL) || (await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.getDataURL)(imageFile));\n return new Promise(async (resolve, reject) => {\n var _a, _b;\n\n try {\n let initializedImageElement = this.getLatestInitializedImageElement(placeholderImageElement, fileId);\n this.addMissingFiles([{\n mimeType,\n id: fileId,\n dataURL,\n created: Date.now(),\n lastRetrieved: Date.now(),\n //@ts-ignore\n name: (imageFile === null || imageFile === void 0 ? void 0 : imageFile.name) && imageFile.name !== \"image.png\" ? imageFile.name : undefined // zsviczian\n\n }]);\n\n if (!this.imageCache.get(fileId)) {\n this.addNewImagesToImageCache();\n const {\n erroredFiles\n } = await this.updateImageCache([initializedImageElement]);\n\n if (erroredFiles.size) {\n throw new Error(\"Image cache update resulted with an error.\");\n }\n }\n\n const imageHTML = await ((_a = this.imageCache.get(fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (imageHTML && ((_b = this.state.newElement) === null || _b === void 0 ? void 0 : _b.id) !== initializedImageElement.id) {\n initializedImageElement = this.getLatestInitializedImageElement(placeholderImageElement, fileId);\n const naturalDimensions = this.getImageNaturalDimensions(initializedImageElement, imageHTML); // no need to create a new instance anymore, just assign the natural dimensions\n\n Object.assign(initializedImageElement, naturalDimensions);\n }\n\n resolve(initializedImageElement);\n } catch (error) {\n console.error(error);\n reject(new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.imageInsertError\")));\n }\n });\n };\n /**\r\n * use during async image initialization,\r\n * when the placeholder image could have been modified in the meantime,\r\n * and when you don't want to loose those modifications\r\n */\n\n\n this.getLatestInitializedImageElement = (imagePlaceholder, fileId) => {\n var _a;\n\n const latestImageElement = (_a = this.scene.getElement(imagePlaceholder.id)) !== null && _a !== void 0 ? _a : imagePlaceholder;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(latestImageElement, {\n fileId\n });\n };\n\n this.onImageToolbarButtonClick = async () => {\n try {\n const clientX = this.state.width / 2 + this.state.offsetLeft;\n const clientY = this.state.height / 2 + this.state.offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX,\n clientY\n }, this.state);\n const imageFiles = await (0,_data_filesystem__WEBPACK_IMPORTED_MODULE_34__.fileOpen)({\n description: \"Image\",\n extensions: Object.keys(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.IMAGE_MIME_TYPES),\n multiple: true\n });\n this.insertImages(imageFiles, x, y);\n } catch (error) {\n if (error.name !== \"AbortError\") {\n console.error(error);\n } else {\n console.warn(error);\n }\n\n this.setState({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.defaultSelectionTool\n })\n }, () => {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n });\n }\n };\n\n this.getImageNaturalDimensions = (imageElement, imageHTML) => {\n const minHeight = Math.max(this.state.height - 120, 160); // max 65% of canvas height, clamped to <300px, vh - 120px>\n\n const maxHeight = Math.min(minHeight, Math.floor(this.state.height * 0.5) / this.state.zoom.value);\n const height = Math.min(imageHTML.naturalHeight, maxHeight);\n const width = height * (imageHTML.naturalWidth / imageHTML.naturalHeight); // add current imageElement width/height to account for previous centering\n // of the placeholder image\n\n const x = imageElement.x + imageElement.width / 2 - width / 2;\n const y = imageElement.y + imageElement.height / 2 - height / 2;\n return {\n x,\n y,\n width,\n height,\n crop: null\n };\n };\n /** updates image cache, refreshing updated elements and/or setting status\r\n to error for images that fail during <img> element creation */\n\n\n this.updateImageCache = async (elements, files = this.files) => {\n const {\n updatedFiles,\n erroredFiles\n } = await (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateImageCache)({\n imageCache: this.imageCache,\n fileIds: elements.map(element => element.fileId),\n files\n });\n\n if (erroredFiles.size) {\n this.store.scheduleAction(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER);\n this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(element => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(element) && erroredFiles.has(element.fileId)) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(element, {\n status: \"error\"\n });\n }\n\n return element;\n }));\n }\n\n return {\n updatedFiles,\n erroredFiles\n };\n };\n /** adds new images to imageCache and re-renders if needed */\n\n\n this.addNewImagesToImageCache = async (imageElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getInitializedImageElements)(this.scene.getNonDeletedElements()), files = this.files) => {\n const uncachedImageElements = imageElements.filter(element => !element.isDeleted && !this.imageCache.has(element.fileId));\n\n if (uncachedImageElements.length) {\n const {\n updatedFiles\n } = await this.updateImageCache(uncachedImageElements, files);\n\n if (updatedFiles.size) {\n for (const element of uncachedImageElements) {\n if (updatedFiles.has(element.fileId)) {\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element);\n }\n }\n }\n\n if (updatedFiles.size) {\n this.scene.triggerUpdate();\n }\n }\n };\n /** generally you should use `addNewImagesToImageCache()` directly if you need\r\n * to render new images. This is just a failsafe */\n\n\n this.scheduleImageRefresh = lodash_throttle__WEBPACK_IMPORTED_MODULE_1___default()(() => {\n this.addNewImagesToImageCache();\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.IMAGE_RENDER_TIMEOUT);\n\n this.updateBindingEnabledOnPointerMove = event => {\n const shouldEnableBinding = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.shouldEnableBindingForPointerEvent)(event);\n\n if (this.state.isBindingEnabled !== shouldEnableBinding) {\n this.setState({\n isBindingEnabled: shouldEnableBinding\n });\n }\n };\n\n this.maybeSuggestBindingAtCursor = (pointerCoords, considerAll) => {\n const hoveredBindableElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)(pointerCoords, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom, false, considerAll);\n this.setState({\n suggestedBindings: hoveredBindableElement != null ? [hoveredBindableElement] : []\n });\n };\n\n this.handleInteractiveCanvasRef = canvas => {\n var _a, _b; // canvas is null when unmounting\n\n\n if (canvas !== null) {\n this.interactiveCanvas = canvas; // -----------------------------------------------------------------------\n // NOTE wheel, touchstart, touchend events must be registered outside\n // of react because react binds them them passively (so we can't prevent\n // default on them)\n\n this.interactiveCanvas.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_START, this.onTouchStart, {\n passive: false\n });\n this.interactiveCanvas.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_END, this.onTouchEnd); // -----------------------------------------------------------------------\n } else {\n (_a = this.interactiveCanvas) === null || _a === void 0 ? void 0 : _a.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_START, this.onTouchStart);\n (_b = this.interactiveCanvas) === null || _b === void 0 ? void 0 : _b.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_END, this.onTouchEnd);\n }\n };\n\n this.insertImages = async (imageFiles, sceneX, sceneY) => {\n const gridPadding = 50 / this.state.zoom.value; // Create, position, and insert placeholders\n\n const placeholders = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.positionElementsOnGrid)(imageFiles.map(() => this.newImagePlaceholder({\n sceneX,\n sceneY\n })), sceneX, sceneY, gridPadding);\n placeholders.forEach(el => this.scene.insertElement(el)); // Create, position, insert and select initialized (replacing placeholders)\n\n const initialized = await Promise.all(placeholders.map(async (placeholder, i) => {\n try {\n return await this.initializeImage(placeholder, await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.normalizeFile)(imageFiles[i]));\n } catch (error) {\n this.setState({\n errorMessage: error.message || (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.imageInsertError\")\n });\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(placeholder, {\n isDeleted: true\n });\n }\n }));\n const initializedMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(initialized);\n const positioned = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.positionElementsOnGrid)(initialized.filter(el => !el.isDeleted), sceneX, sceneY, gridPadding);\n const positionedMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(positioned);\n const nextElements = this.scene.getElementsIncludingDeleted().map(el => {\n var _a, _b;\n\n return (_b = (_a = positionedMap.get(el.id)) !== null && _a !== void 0 ? _a : initializedMap.get(el.id)) !== null && _b !== void 0 ? _b : el;\n });\n this.updateScene({\n appState: {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.fromEntries(positioned.map(el => [el.id, true])), this.state)\n },\n elements: nextElements,\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n this.setState({}, () => {\n // actionFinalize after all state values have been updated\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n });\n };\n\n this.handleAppOnDrop = async event => {\n var _a;\n\n if (this.props.onDrop) {\n //zsviczian\n try {\n if ((await this.props.onDrop(event)) === false) {\n return;\n }\n } catch (e) {\n console.error(e);\n }\n }\n\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const dataTransferList = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_24__.parseDataTransferEvent)(event); // must be retrieved first, in the same frame\n\n const fileItems = dataTransferList.getFiles();\n\n if (fileItems.length === 1) {\n const {\n file,\n fileHandle\n } = fileItems[0];\n\n if (file && (file.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.png || file.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg)) {\n try {\n const scene = await (0,_data__WEBPACK_IMPORTED_MODULE_25__.loadFromBlob)(file, this.state, this.scene.getElementsIncludingDeleted(), fileHandle);\n this.syncActionResult(Object.assign(Object.assign({}, scene), {\n appState: Object.assign(Object.assign({}, scene.appState || this.state), {\n isLoading: false\n }),\n replaceFiles: true,\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n }));\n return;\n } catch (error) {\n if (error.name !== \"EncodingError\") {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"alerts.couldNotLoadInvalidFile\"));\n } // if EncodingError, fall through to insert as regular image\n\n }\n }\n }\n\n const imageFiles = fileItems.map(data => data.file).filter(file => (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.isSupportedImageFile)(file));\n\n if (imageFiles.length > 0 && this.isToolSupported(\"image\")) {\n return this.insertImages(imageFiles, sceneX, sceneY);\n }\n\n const excalidrawLibrary_ids = dataTransferList.getData(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidrawlibIds);\n const excalidrawLibrary_data = dataTransferList.getData(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidrawlib);\n\n if (excalidrawLibrary_ids || excalidrawLibrary_data) {\n try {\n let libraryItems = null;\n\n if (excalidrawLibrary_ids) {\n const {\n itemIds\n } = JSON.parse(excalidrawLibrary_ids);\n const allLibraryItems = await this.library.getLatestLibrary();\n libraryItems = allLibraryItems.filter(item => itemIds.includes(item.id)); // legacy library dataTransfer format\n } else if (excalidrawLibrary_data) {\n libraryItems = (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.parseLibraryJSON)(excalidrawLibrary_data);\n }\n\n if (libraryItems === null || libraryItems === void 0 ? void 0 : libraryItems.length) {\n libraryItems = libraryItems.map(item => Object.assign(Object.assign({}, item), {\n // #6465\n elements: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.duplicateElements)({\n type: \"everything\",\n elements: item.elements,\n randomizeSeed: true\n }).duplicatedElements\n }));\n this.addElementsFromPasteOrLibrary({\n elements: (0,_data_library__WEBPACK_IMPORTED_MODULE_26__.distributeLibraryItemsOnSquareGrid)(libraryItems),\n position: event,\n files: null\n });\n }\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n\n return;\n }\n\n if (fileItems.length > 0) {\n const {\n file,\n fileHandle\n } = fileItems[0];\n\n if (file) {\n // Attempt to parse an excalidraw/excalidrawlib file\n await this.loadFileToCanvas(file, fileHandle);\n }\n }\n\n const textItem = dataTransferList.findByType(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.text);\n\n if (textItem) {\n const text = textItem.value;\n\n if (text && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(text, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(text) || ((_a = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)(text)) === null || _a === void 0 ? void 0 : _a.type) === \"video\")) {\n const embeddable = this.insertEmbeddableElement({\n sceneX,\n sceneY,\n link: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeLink)(text)\n });\n\n if (embeddable) {\n this.store.scheduleCapture();\n this.setState({\n selectedElementIds: {\n [embeddable.id]: true\n }\n });\n }\n }\n }\n };\n\n this.loadFileToCanvas = async (file, fileHandle) => {\n file = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.normalizeFile)(file);\n\n try {\n const elements = this.scene.getElementsIncludingDeleted();\n let ret;\n\n try {\n ret = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.loadSceneOrLibraryFromBlob)(file, this.state, elements, fileHandle);\n } catch (error) {\n const imageSceneDataError = error instanceof _errors__WEBPACK_IMPORTED_MODULE_38__.ImageSceneDataError;\n\n if (imageSceneDataError && error.code === \"IMAGE_NOT_CONTAINS_SCENE_DATA\" && !this.isToolSupported(\"image\")) {\n this.setState({\n isLoading: false,\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.imageToolNotSupported\")\n });\n return;\n }\n\n const errorMessage = imageSceneDataError ? (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"alerts.cannotRestoreFromImage\") : (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"alerts.couldNotLoadInvalidFile\");\n this.setState({\n isLoading: false,\n errorMessage\n });\n }\n\n if (!ret) {\n return;\n }\n\n if (ret.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidraw) {\n // restore the fractional indices by mutating elements\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.syncInvalidIndices)(elements.concat(ret.data.elements)); // don't capture and only update the store snapshot for old elements,\n // otherwise we would end up with duplicated fractional indices on undo\n\n this.store.scheduleMicroAction({\n action: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER,\n elements,\n appState: undefined\n });\n this.setState({\n isLoading: true\n });\n this.syncActionResult(Object.assign(Object.assign({}, ret.data), {\n appState: Object.assign(Object.assign({}, ret.data.appState || this.state), {\n isLoading: false\n }),\n replaceFiles: true,\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n }));\n } else if (ret.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidrawlib) {\n await this.library.updateLibrary({\n libraryItems: file,\n merge: true,\n openLibraryMenu: true\n }).catch(error => {\n console.error(error);\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.importLibraryError\")\n });\n });\n }\n } catch (error) {\n this.setState({\n isLoading: false,\n errorMessage: error.message\n });\n }\n };\n\n this.handleCanvasContextMenu = event => {\n event.preventDefault(); //mfuria #329. if right-click pan is enabled, we suppress opening our custom menu too.\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.isPanWithRightMouseEnabled)()) {\n return;\n }\n\n if ((\"pointerType\" in event.nativeEvent && event.nativeEvent.pointerType === \"touch\" || \"pointerType\" in event.nativeEvent && event.nativeEvent.pointerType === \"pen\" && // always allow if user uses a pen secondary button\n event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.SECONDARY) && this.state.activeTool.type !== this.defaultSelectionTool) {\n return;\n }\n\n if (this.state.isResizing) {\n return; //zsviczian - avoid context menu during resizing on Mobiles\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const element = this.getElementAtPosition(x, y, {\n preferSelected: true,\n includeLockedElements: true\n });\n const selectedElements = this.scene.getSelectedElements(this.state);\n const isHittingCommonBoundBox = this.isHittingCommonBoundingBoxOfSelectedElements({\n x,\n y\n }, selectedElements);\n const type = element || isHittingCommonBoundBox ? \"element\" : \"canvas\";\n const container = this.excalidrawContainerRef.current;\n const {\n top: offsetTop,\n left: offsetLeft\n } = container.getBoundingClientRect();\n const left = event.clientX - offsetLeft;\n const top = event.clientY - offsetTop;\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"contextMenu\", \"openContextMenu\", type);\n this.setState(Object.assign(Object.assign({}, element && !this.state.selectedElementIds[element.id] ? Object.assign(Object.assign(Object.assign({}, this.state), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: this.state.editingGroupId,\n selectedElementIds: {\n [element.id]: true\n }\n }, this.scene.getNonDeletedElements(), this.state, this)), {\n selectedLinearElement: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(element) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(element, this.scene.getNonDeletedElementsMap()) : null\n }) : this.state), {\n showHyperlinkPopup: false\n }), () => {\n this.setState({\n contextMenu: {\n top,\n left,\n items: this.getContextMenuItems(type)\n }\n });\n });\n };\n\n this.maybeDragNewGenericElement = (pointerDownState, event, informMutation = true) => {\n var _a, _b, _c, _d, _e;\n\n const selectionElement = this.state.selectionElement;\n const pointerCoords = pointerDownState.lastCoords;\n\n if (selectionElement && this.state.activeTool.type !== \"eraser\") {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.dragNewElement)({\n newElement: selectionElement,\n elementType: this.state.activeTool.type,\n originX: pointerDownState.origin.x,\n originY: pointerDownState.origin.y,\n x: pointerCoords.x,\n y: pointerCoords.y,\n width: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.origin.x, pointerCoords.x),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.origin.y, pointerCoords.y),\n shouldMaintainAspectRatio: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event),\n shouldResizeFromCenter: false,\n scene: this.scene,\n zoom: this.state.zoom.value,\n informMutation: false\n });\n return;\n }\n\n const newElement = this.state.newElement;\n\n if (!newElement) {\n return;\n }\n\n let [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(newElement) && ((_a = this.imageCache.get(newElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n const aspectRatio = image && !(image instanceof Promise) ? image.width / image.height : null;\n this.maybeCacheReferenceSnapPoints(event, [newElement]);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.snapNewElement)(newElement, this, event, {\n x: pointerDownState.originInGrid.x + ((_c = (_b = this.state.originSnapOffset) === null || _b === void 0 ? void 0 : _b.x) !== null && _c !== void 0 ? _c : 0),\n y: pointerDownState.originInGrid.y + ((_e = (_d = this.state.originSnapOffset) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 0)\n }, {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n }, this.scene.getNonDeletedElementsMap());\n gridX += snapOffset.x;\n gridY += snapOffset.y;\n this.setState({\n snapLines\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.dragNewElement)({\n newElement,\n elementType: this.state.activeTool.type,\n originX: pointerDownState.originInGrid.x,\n originY: pointerDownState.originInGrid.y,\n x: gridX,\n y: gridY,\n width: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.originInGrid.x, gridX),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.originInGrid.y, gridY),\n shouldMaintainAspectRatio: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(newElement) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event),\n shouldResizeFromCenter: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldResizeFromCenter)(event),\n zoom: this.state.zoom.value,\n scene: this.scene,\n widthAspectRatio: aspectRatio,\n originOffset: this.state.originSnapOffset,\n informMutation\n });\n this.setState({\n newElement\n }); // highlight elements that are to be added to frames on frames creation\n\n if (this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe) {\n this.setState({\n elementsToHighlight: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInResizingFrame)(this.scene.getNonDeletedElements(), newElement, this.state, this.scene.getNonDeletedElementsMap())\n });\n }\n };\n\n this.maybeHandleCrop = (pointerDownState, event) => {\n var _a; // to crop, we must already be in the cropping mode, where croppingElement has been set\n\n\n if (!this.state.croppingElementId) {\n return false;\n }\n\n const transformHandleType = pointerDownState.resize.handleType;\n const pointerCoords = pointerDownState.lastCoords;\n const [x, y] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const croppingElement = this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);\n\n if (transformHandleType && croppingElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingElement)) {\n const croppingAtStateStart = pointerDownState.originalElements.get(croppingElement.id);\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(croppingElement) && ((_a = this.imageCache.get(croppingElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (croppingAtStateStart && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingAtStateStart) && image && !(image instanceof Promise)) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const dragOffset = {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n };\n this.maybeCacheReferenceSnapPoints(event, [croppingElement]);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.snapResizingElements)([croppingElement], [croppingAtStateStart], this, event, dragOffset, transformHandleType);\n this.scene.mutateElement(croppingElement, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.cropElement)(croppingElement, this.scene.getNonDeletedElementsMap(), transformHandleType, image.naturalWidth, image.naturalHeight, x + snapOffset.x, y + snapOffset.y, event.shiftKey ? croppingAtStateStart.width / croppingAtStateStart.height : undefined));\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(croppingElement, this.scene, {\n newSize: {\n width: croppingElement.width,\n height: croppingElement.height\n }\n });\n this.setState({\n isCropping: transformHandleType && transformHandleType !== \"rotation\",\n snapLines\n });\n }\n\n return true;\n }\n\n return false;\n };\n\n this.maybeHandleResize = (pointerDownState, event) => {\n const selectedElements = this.scene.getSelectedElements(this.state);\n const selectedFrames = selectedElements.filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element));\n const transformHandleType = pointerDownState.resize.handleType;\n\n if ( // Frames cannot be rotated.\n selectedFrames.length > 0 && transformHandleType === \"rotation\" || // Elbow arrows cannot be transformed (resized or rotated).\n selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0]) || // Do not resize when in crop mode\n this.state.croppingElementId) {\n return false;\n }\n\n this.setState({\n // TODO: rename this state field to \"isScaling\" to distinguish\n // it from the generic \"isResizing\" which includes scaling and\n // rotating\n isResizing: transformHandleType && transformHandleType !== \"rotation\",\n isRotating: transformHandleType === \"rotation\",\n activeEmbeddable: null\n });\n const pointerCoords = pointerDownState.lastCoords;\n let [resizeX, resizeY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const frameElementsOffsetsMap = new Map();\n selectedFrames.forEach(frame => {\n const elementsInFrame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getFrameChildren)(this.scene.getNonDeletedElements(), frame.id);\n elementsInFrame.forEach(element => {\n frameElementsOffsetsMap.set(frame.id + element.id, {\n x: element.x - frame.x,\n y: element.y - frame.y\n });\n });\n }); // check needed for avoiding flickering when a key gets pressed\n // during dragging\n\n if (!this.state.selectedElementsAreBeingDragged) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const dragOffset = {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n };\n const originalElements = [...pointerDownState.originalElements.values()];\n this.maybeCacheReferenceSnapPoints(event, selectedElements);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.snapResizingElements)(selectedElements, (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getSelectedElements)(originalElements, this.state), this, event, dragOffset, transformHandleType);\n resizeX += snapOffset.x;\n resizeY += snapOffset.y;\n this.setState({\n snapLines\n });\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.transformElements)(pointerDownState.originalElements, transformHandleType, selectedElements, this.scene, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldRotateWithDiscreteAngle)(event), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldResizeFromCenter)(event), selectedElements.some(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(element)) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event), resizeX, resizeY, pointerDownState.resize.center.x, pointerDownState.resize.center.y)) {\n const suggestedBindings = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSuggestedBindingsForArrows)(selectedElements, this.scene.getNonDeletedElementsMap(), this.state.zoom);\n const elementsToHighlight = new Set();\n selectedFrames.forEach(frame => {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInResizingFrame)(this.scene.getNonDeletedElements(), frame, this.state, this.scene.getNonDeletedElementsMap()).forEach(element => elementsToHighlight.add(element));\n });\n this.setState({\n elementsToHighlight: [...elementsToHighlight],\n suggestedBindings\n });\n return true;\n }\n\n return false;\n };\n\n this.getContextMenuItems = type => {\n const options = [];\n options.push(_actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsSvg); // canvas contextMenu\n // -------------------------------------------------------------------------\n\n if (type === \"canvas\") {\n if (this.state.viewModeEnabled) {\n return [...options, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleStats, _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.actionToggleLaserPointer];\n }\n\n return [_actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsSvg, _actions__WEBPACK_IMPORTED_MODULE_8__.copyText, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSelectAll, _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_13__.actionUnlockAllElements, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleObjectsSnapMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleStats];\n } // element contextMenu\n // -------------------------------------------------------------------------\n\n\n options.push(_actions__WEBPACK_IMPORTED_MODULE_8__.copyText);\n\n if (this.state.viewModeEnabled) {\n return [_actions__WEBPACK_IMPORTED_MODULE_8__.actionCopy, ...options];\n }\n\n return [_ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCut, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopy, _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionSelectAllElementsInFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionRemoveAllElementsFromFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionWrapSelectionInFrame, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleCropEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, ...options, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyStyles, _actions__WEBPACK_IMPORTED_MODULE_8__.actionPasteStyles, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionGroup, _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_16__.actionTextAutoResize, _actions__WEBPACK_IMPORTED_MODULE_8__.actionUnbindText, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBindText, _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_9__.actionWrapTextInContainer, _actions__WEBPACK_IMPORTED_MODULE_8__.actionUngroup, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionAddToLibrary, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSendBackward, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBringForward, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSendToBack, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBringToFront, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionFlipHorizontal, _actions__WEBPACK_IMPORTED_MODULE_8__.actionFlipVertical, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionLink, _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_12__.actionCopyElementLink, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionDuplicateSelection, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleElementLock, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionDeleteSelected];\n };\n\n this.handleWheel = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d; // if not scrolling on canvas/wysiwyg, ignore\n //zsviczian - begin\n\n\n const path = (_b = (_a = event).composedPath) === null || _b === void 0 ? void 0 : _b.call(_a);\n const isOnExcalidrawCanvas = (path === null || path === void 0 ? void 0 : path.some(n => {\n var _a;\n\n return n instanceof HTMLCanvasElement && ((_a = n.classList) === null || _a === void 0 ? void 0 : _a.contains(\"excalidraw__canvas\"));\n })) || ((_d = (_c = event.target) === null || _c === void 0 ? void 0 : _c.closest) === null || _d === void 0 ? void 0 : _d.call(_c, \"canvas.excalidraw__canvas\")) != null; //zsviczian - end\n\n if (!(isOnExcalidrawCanvas || //zsviczian\n event.target instanceof HTMLTextAreaElement || event.target instanceof HTMLIFrameElement)) {\n // prevent zooming the browser (but allow scrolling DOM)\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n event.preventDefault();\n }\n\n return;\n }\n\n event.preventDefault();\n\n if (isPanning) {\n return;\n }\n\n const {\n deltaX,\n deltaY\n } = event; // note that event.ctrlKey is necessary to handle pinch zooming\n\n if ( //zsviczian\n (event.metaKey || event.ctrlKey) && !this.state.allowWheelZoom || !(event.metaKey || event.ctrlKey) && this.state.allowWheelZoom) {\n const sign = Math.sign(deltaY);\n const MAX_STEP = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.getZoomStep)() * 100;\n const absDelta = Math.abs(deltaY);\n let delta = deltaY;\n\n if (absDelta > MAX_STEP) {\n delta = MAX_STEP * sign;\n }\n\n let newZoom = this.state.zoom.value - delta / 100; // increase zoom steps the more zoomed-in we are (applies to >100% only)\n\n newZoom += Math.log10(Math.max(1, this.state.zoom.value)) * -sign * // reduced amplification for small deltas (small movements on a trackpad)\n Math.min(1, absDelta / 20);\n this.translateCanvas(state => Object.assign(Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_32__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getNormalizedZoom)(newZoom)\n }, state)), {\n shouldCacheIgnoreZoom: true\n }));\n this.resetShouldCacheIgnoreZoomDebounced();\n return;\n } // scroll horizontally when shift pressed\n\n\n if (event.shiftKey) {\n this.translateCanvas(({\n zoom,\n scrollX\n }) => ({\n // on Mac, shift+wheel tends to result in deltaX\n scrollX: scrollX - (deltaY || deltaX) / zoom.value\n }));\n return;\n }\n\n this.translateCanvas(({\n zoom,\n scrollX,\n scrollY\n }) => ({\n scrollX: scrollX - deltaX / zoom.value,\n scrollY: scrollY - deltaY / zoom.value\n }));\n });\n\n this.savePointer = (x, y, button) => {\n var _a, _b;\n\n if (!x || !y) {\n return;\n }\n\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: x,\n clientY: y\n }, this.state);\n\n if (isNaN(sceneX) || isNaN(sceneY)) {// sometimes the pointer goes off screen\n }\n\n const pointer = {\n x: sceneX,\n y: sceneY,\n tool: this.state.activeTool.type === \"laser\" ? \"laser\" : \"pointer\"\n };\n (_b = (_a = this.props).onPointerUpdate) === null || _b === void 0 ? void 0 : _b.call(_a, {\n pointer,\n button,\n pointersMap: gesture.pointers\n });\n };\n\n this.resetShouldCacheIgnoreZoomDebounced = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.debounce)(() => {\n if (!this.unmounted) {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n }\n }, 300);\n\n this.updateDOMRect = cb => {\n var _a;\n\n if ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) {\n const excalidrawContainer = this.excalidrawContainerRef.current;\n const {\n width,\n height,\n left: offsetLeft,\n top: offsetTop\n } = excalidrawContainer.getBoundingClientRect();\n const {\n width: currentWidth,\n height: currentHeight,\n offsetTop: currentOffsetTop,\n offsetLeft: currentOffsetLeft\n } = this.state;\n\n if (width === currentWidth && height === currentHeight && offsetLeft === currentOffsetLeft && offsetTop === currentOffsetTop) {\n if (cb) {\n cb();\n }\n\n return;\n } //zsviczian\n\n\n if (width === 0 || height === 0) {\n if (cb) {\n cb();\n }\n\n return;\n }\n\n this.setState({\n width,\n height,\n offsetLeft,\n offsetTop\n }, () => {\n cb && cb();\n });\n }\n };\n\n this.refresh = () => {\n this.setState(Object.assign({}, this.getCanvasOffsets()));\n };\n\n const defaultAppState = (0,_appState__WEBPACK_IMPORTED_MODULE_23__.getDefaultAppState)();\n this.defaultSelectionTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() ? \"lasso\" : \"selection\";\n const {\n excalidrawAPI,\n viewModeEnabled = false,\n zenModeEnabled = false,\n gridModeEnabled = false,\n objectsSnapModeEnabled = false,\n theme = defaultAppState.theme,\n initState,\n //zsviczian\n name = `${(0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getDateTime)()}`\n } = props;\n this.state = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaultAppState), {\n theme,\n isLoading: true\n }), this.getCanvasOffsets()), {\n viewModeEnabled,\n zenModeEnabled,\n objectsSnapModeEnabled,\n gridModeEnabled: gridModeEnabled !== null && gridModeEnabled !== void 0 ? gridModeEnabled : defaultAppState.gridModeEnabled,\n name,\n width: window.innerWidth,\n height: window.innerHeight\n }), initState !== null && initState !== void 0 ? initState : {});\n this.id = (0,nanoid__WEBPACK_IMPORTED_MODULE_72__.nanoid)();\n (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.initializeObsidianUtils)();\n this.library = new _data_library__WEBPACK_IMPORTED_MODULE_26__[\"default\"](this);\n this.actionManager = new _actions_manager__WEBPACK_IMPORTED_MODULE_18__.ActionManager(this.syncActionResult, () => this.state, () => this.scene.getElementsIncludingDeleted(), this);\n this.scene = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Scene();\n this.canvas = document.createElement(\"canvas\");\n this.rc = roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_4__[\"default\"].canvas(this.canvas);\n this.renderer = new _scene_Renderer__WEBPACK_IMPORTED_MODULE_41__.Renderer(this.scene);\n this.visibleElements = [];\n this.store = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Store(this);\n this.history = new _history__WEBPACK_IMPORTED_MODULE_29__.History(this.store);\n\n if (excalidrawAPI) {\n const api = {\n updateScene: this.updateScene,\n applyDeltas: this.applyDeltas,\n mutateElement: this.mutateElement,\n updateLibrary: this.library.updateLibrary,\n addFiles: this.addFiles,\n resetScene: this.resetScene,\n getSceneElementsIncludingDeleted: this.getSceneElementsIncludingDeleted,\n getSceneElementsMapIncludingDeleted: this.getSceneElementsMapIncludingDeleted,\n history: {\n clear: this.resetHistory\n },\n scrollToContent: this.scrollToContent,\n setForceRenderAllEmbeddables: this.setForceRenderAllEmbeddables,\n zoomToFit: this.zoomToFit,\n getColorAtScenePoint: this.getColorAtScenePoint,\n startLineEditor: this.startLineEditor,\n getSceneElements: this.getSceneElements,\n getAppState: () => this.state,\n getFiles: () => this.files,\n getName: this.getName,\n registerAction: action => {\n this.actionManager.registerAction(action);\n },\n refresh: this.refresh,\n setToast: this.setToast,\n updateContainerSize: this.updateContainerSize,\n id: this.id,\n selectElements: this.selectElements,\n sendBackward: this.sendBackward,\n bringForward: this.bringForward,\n sendToBack: this.sendToBack,\n bringToFront: this.bringToFront,\n setMobileModeAllowed: this.setMobileModeAllowed,\n setActiveTool: this.setActiveTool,\n setCursor: this.setCursor,\n resetCursor: this.resetCursor,\n updateFrameRendering: this.updateFrameRendering,\n toggleSidebar: this.toggleSidebar,\n getHTMLIFrameElement: id => this.getHTMLIFrameElement(id),\n onChange: cb => this.onChangeEmitter.on(cb),\n onIncrement: cb => this.store.onStoreIncrementEmitter.on(cb),\n onPointerDown: cb => this.onPointerDownEmitter.on(cb),\n onPointerUp: cb => this.onPointerUpEmitter.on(cb),\n onScrollChange: cb => this.onScrollChangeEmitter.on(cb),\n onUserFollow: cb => this.onUserFollowEmitter.on(cb)\n };\n\n if (typeof excalidrawAPI === \"function\") {\n excalidrawAPI(api);\n } else {\n console.error(\"excalidrawAPI should be a function!\");\n }\n }\n\n this.excalidrawContainerValue = {\n container: this.excalidrawContainerRef.current,\n id: this.id\n };\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_36__.Fonts(this.scene);\n this.history = new _history__WEBPACK_IMPORTED_MODULE_29__.History(this.store);\n this.actionManager.registerAll(_actions_register__WEBPACK_IMPORTED_MODULE_19__.actions);\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__.createUndoAction)(this.history));\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__.createRedoAction)(this.history));\n }\n\n onWindowMessage(event) {\n if (event.origin !== \"https://player.vimeo.com\" && event.origin !== \"https://www.youtube.com\") {\n return;\n }\n\n let data = null;\n\n try {\n data = JSON.parse(event.data);\n } catch (e) {}\n\n if (!data) {\n return;\n }\n\n switch (event.origin) {\n case \"https://player.vimeo.com\":\n //Allowing for multiple instances of Excalidraw running in the window\n if (data.method === \"paused\") {\n let source = null;\n const iframes = document.body.querySelectorAll(\"iframe.excalidraw__embeddable\");\n\n if (!iframes) {\n break;\n }\n\n for (const iframe of iframes) {\n if (iframe.contentWindow === event.source) {\n source = iframe.contentWindow;\n }\n }\n\n source === null || source === void 0 ? void 0 : source.postMessage(JSON.stringify({\n method: data.value ? \"play\" : \"pause\",\n value: true\n }), \"*\");\n }\n\n break;\n\n case \"https://www.youtube.com\":\n if (data.event === \"infoDelivery\" && data.info && data.id && typeof data.info.playerState === \"number\") {\n const id = data.id;\n const playerState = data.info.playerState;\n\n if (Object.values(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES).includes(playerState)) {\n YOUTUBE_VIDEO_STATES.set(id, playerState);\n }\n }\n\n break;\n }\n }\n\n cacheEmbeddableRef(element, ref) {\n if (ref) {\n this.iFrameRefs.set(element.id, ref);\n }\n }\n\n getHTMLIFrameElement(element) {\n //zsviczian\n if (typeof element === \"string\") {\n return this.iFrameRefs.get(element);\n }\n\n return this.iFrameRefs.get(element.id);\n }\n\n handleEmbeddableCenterClick(element) {\n var _a, _b, _c, _d;\n\n if (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.element) === element && ((_b = this.state.activeEmbeddable) === null || _b === void 0 ? void 0 : _b.state) === \"active\") {\n return;\n } // The delay serves two purposes\n // 1. To prevent first click propagating to iframe on mobile,\n // else the click will immediately start and stop the video\n // 2. If the user double clicks the frame center to activate it\n // without the delay youtube will immediately open the video\n // in fullscreen mode\n\n\n setTimeout(() => {\n this.setState({\n activeEmbeddable: {\n element,\n state: \"active\"\n },\n selectedElementIds: {\n [element.id]: true\n },\n newElement: null,\n selectionElement: null\n });\n }, 100);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(element)) {\n return;\n }\n\n const iframe = this.getHTMLIFrameElement(element);\n\n if (!(iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow)) {\n return;\n }\n\n if (iframe.src.includes(\"youtube\")) {\n const state = YOUTUBE_VIDEO_STATES.get(element.id);\n\n if (!state) {\n YOUTUBE_VIDEO_STATES.set(element.id, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES.UNSTARTED);\n iframe.contentWindow.postMessage(JSON.stringify({\n event: \"listening\",\n id: element.id\n }), \"*\");\n }\n\n switch (state) {\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES.PLAYING:\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES.BUFFERING:\n (_c = iframe.contentWindow) === null || _c === void 0 ? void 0 : _c.postMessage(JSON.stringify({\n event: \"command\",\n func: \"pauseVideo\",\n args: \"\"\n }), \"*\");\n break;\n\n default:\n (_d = iframe.contentWindow) === null || _d === void 0 ? void 0 : _d.postMessage(JSON.stringify({\n event: \"command\",\n func: \"playVideo\",\n args: \"\"\n }), \"*\");\n }\n }\n\n if (iframe.src.includes(\"player.vimeo.com\")) {\n iframe.contentWindow.postMessage(JSON.stringify({\n method: \"paused\" //video play/pause in onWindowMessage handler\n\n }), \"*\");\n }\n }\n\n isIframeLikeElementCenter(el, event, sceneX, sceneY) {\n var _a, _b;\n\n return el && !event.altKey && !event.shiftKey && !event.metaKey && !event.ctrlKey && (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.element) !== el || ((_b = this.state.activeEmbeddable) === null || _b === void 0 ? void 0 : _b.state) === \"hover\" || !this.state.activeEmbeddable) && sceneX >= el.x + el.width / 3 && sceneX <= el.x + 2 * el.width / 3 && sceneY >= el.y + el.height / 3 && sceneY <= el.y + 2 * el.height / 3;\n }\n\n renderEmbeddables() {\n const scale = this.state.zoom.value;\n const normalizedWidth = this.state.width;\n const normalizedHeight = this.state.height;\n const embeddableElements = this.scene.getNonDeletedElements().filter(el => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(el) && this.embedsValidationStatus.get(el.id) === true || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(el));\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement((react__WEBPACK_IMPORTED_MODULE_2___default().Fragment), null, embeddableElements.map(el => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.sceneCoordsToViewportCoords)({\n sceneX: el.x,\n sceneY: el.y\n }, this.state); //zsviczian - shouldRenderAllEmbeddables\n\n const isVisible = this.shouldRenderAllEmbeddables || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInViewport)(el, normalizedWidth, normalizedHeight, this.state, this.scene.getNonDeletedElementsMap());\n const hasBeenInitialized = this.initializedEmbeds.has(el.id);\n\n if (isVisible && !hasBeenInitialized) {\n this.initializedEmbeds.add(el.id);\n }\n\n const shouldRender = isVisible || hasBeenInitialized;\n\n if (!shouldRender) {\n return null;\n }\n\n let src;\n const embedLink = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.toValidURL)(el.link || \"\")); //zsviczian\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(el)) {\n src = null;\n const data = ((_b = (_a = el.customData) === null || _a === void 0 ? void 0 : _a.generationData) !== null && _b !== void 0 ? _b : this.magicGenerations.get(el.id)) || {\n status: \"error\",\n message: \"No generation data\",\n code: \"ERR_NO_GENERATION_DATA\"\n };\n\n if (data.status === \"done\") {\n const html = data.html;\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return html;\n }\n };\n } else if (data.status === \"pending\") {\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.createSrcDoc)(`\n <style>\n html, body {\n width: 100%;\n height: 100%;\n color: ${this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK ? \"white\" : \"black\"};\n }\n body {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 1rem;\n }\n\n .Spinner {\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: auto;\n margin-right: auto;\n }\n\n .Spinner svg {\n animation: rotate 1.6s linear infinite;\n transform-origin: center center;\n width: 40px;\n height: 40px;\n }\n\n .Spinner circle {\n stroke: currentColor;\n animation: dash 1.6s linear 0s infinite;\n stroke-linecap: round;\n }\n\n @keyframes rotate {\n 100% {\n transform: rotate(360deg);\n }\n }\n\n @keyframes dash {\n 0% {\n stroke-dasharray: 1, 300;\n stroke-dashoffset: 0;\n }\n 50% {\n stroke-dasharray: 150, 300;\n stroke-dashoffset: -200;\n }\n 100% {\n stroke-dasharray: 1, 300;\n stroke-dashoffset: -280;\n }\n }\n </style>\n <div class=\"Spinner\">\n <svg\n viewBox=\"0 0 100 100\"\n >\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"46\"\n stroke-width=\"8\"\n fill=\"none\"\n stroke-miter-limit=\"10\"\n />\n </svg>\n </div>\n <div>Generating...</div>\n `);\n }\n };\n } else {\n let message;\n\n if (data.code === \"ERR_GENERATION_INTERRUPTED\") {\n message = \"Generation was interrupted...\";\n } else {\n message = data.message || \"Generation failed\";\n }\n\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.createSrcDoc)(`\n <style>\n html, body {\n height: 100%;\n }\n body {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n color: ${_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.COLOR_PALETTE.red[3]};\n }\n h1, h3 {\n margin-top: 0;\n margin-bottom: 0.5rem;\n }\n </style>\n <h1>Error!</h1>\n <h3>${message}</h3>\n `);\n }\n };\n }\n } else {\n src = embedLink; //zsviczian getEmbedLink(toValidURL(el.link || \"\"));\n }\n\n const isActive = ((_c = this.state.activeEmbeddable) === null || _c === void 0 ? void 0 : _c.element) === el && ((_d = this.state.activeEmbeddable) === null || _d === void 0 ? void 0 : _d.state) === \"active\";\n const isHovered = ((_e = this.state.activeEmbeddable) === null || _e === void 0 ? void 0 : _e.element) === el && ((_f = this.state.activeEmbeddable) === null || _f === void 0 ? void 0 : _f.state) === \"hover\";\n const isWebview = //zsviczian\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(el) && this.props.renderWebview && (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) !== \"document\" && !((_h = (_g = embedLink === null || embedLink === void 0 ? void 0 : embedLink.link) === null || _g === void 0 ? void 0 : _g.startsWith) === null || _h === void 0 ? void 0 : _h.call(_g, \"https://player.vimeo.com\")); // Modify the scale based on el.scale property\n\n const [xScale, yScale] = (_j = el.scale) !== null && _j !== void 0 ? _j : [1, 1]; //zsviczian\n\n const scaledTransform = `scale(${scale * xScale}, ${scale * yScale})`;\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n key: el.id,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"excalidraw__embeddable-container\", {\n \"is-hovered\": isHovered\n }),\n style: {\n transform: isVisible ? `translate(${x - this.state.offsetLeft}px, ${y - this.state.offsetTop}px) ${scaledTransform}` : \"none\",\n display: isVisible ? \"block\" : \"none\",\n opacity: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getRenderOpacity)(el, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainingFrame)(el, this.scene.getNonDeletedElementsMap()), this.elementsPendingErasure, null, ((_k = this.state.openDialog) === null || _k === void 0 ? void 0 : _k.name) === \"elementLinkSelector\" ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_REDUCED_GLOBAL_ALPHA : 1),\n [\"--embeddable-radius\"]: `${(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCornerRadius)(Math.min(el.width, el.height), el) / xScale //zsviczian\n }px`\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n //this is a hack that addresses isse with embedded excalidraw.com embeddable\n //https://github.com/excalidraw/excalidraw/pull/6691#issuecomment-1607383938\n\n /*ref={(ref) => {\r\n if (!this.excalidrawContainerRef.current) {\r\n return;\r\n }\r\n const container = this.excalidrawContainerRef.current;\r\n const sh = container.scrollHeight;\r\n const ch = container.clientHeight;\r\n if (sh !== ch) {\r\n container.style.height = `${sh}px`;\r\n setTimeout(() => {\r\n container.style.height = `100%`;\r\n });\r\n }\r\n }}*/\n className: \"excalidraw__embeddable-container__inner\",\n style: {\n width: isVisible ? `${el.width / xScale}px` : 0,\n height: isVisible ? `${el.height / yScale}px` : 0,\n transform: isVisible ? `rotate(${el.angle}rad)` : \"none\",\n pointerEvents: isActive ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.enabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.disabled\n }\n }, isHovered && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw__embeddable-hint\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"buttons.embeddableInteractionButton\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw__embeddable__outer\",\n style: {\n padding: `${el.strokeWidth / (4 * el.scale[0])}px` //zsviczian MDEmbeddable round border cutoff issue\n\n }\n }, (_o = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(el) ? (_m = (_l = this.props).renderEmbeddable) === null || _m === void 0 ? void 0 : _m.call(_l, el, this.state) //zsviczian\n : null) !== null && _o !== void 0 ? _o : isWebview ?\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"webview\", {\n ref: ref => this.cacheEmbeddableRef(el, ref),\n className: \"excalidraw__embeddable\",\n src: (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) === \"generic\" || (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) === \"video\" ? embedLink.link : \"\",\n title: \"Excalidraw Embedded Content\",\n allowFullScreen: true\n }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"iframe\", {\n ref: ref => this.cacheEmbeddableRef(el, ref),\n className: \"excalidraw__embeddable\",\n srcDoc: (src === null || src === void 0 ? void 0 : src.type) === \"document\" ? src.srcdoc(this.state.theme) : undefined,\n src: (src === null || src === void 0 ? void 0 : src.type) !== \"document\" ? (_p = src === null || src === void 0 ? void 0 : src.link) !== null && _p !== void 0 ? _p : \"\" : undefined,\n // https://stackoverflow.com/q/18470015\n // scrolling=\"no\" //zsviczian\n referrerPolicy: \"no-referrer-when-downgrade\",\n title: \"Excalidraw Embedded Content\",\n allow: \"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\",\n allowFullScreen: true,\n sandbox: `${((_q = src === null || src === void 0 ? void 0 : src.sandbox) === null || _q === void 0 ? void 0 : _q.allowSameOrigin) ? \"allow-same-origin\" : \"\"} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`\n }))));\n }));\n }\n\n toggleOverscrollBehavior(event) {\n // when pointer inside editor, disable overscroll behavior to prevent\n // panning to trigger history back/forward on MacOS Chrome\n document.documentElement.style.overscrollBehaviorX = event.type === \"pointerenter\" ? \"none\" : \"auto\";\n }\n\n render() {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const selectedElements = this.scene.getSelectedElements(this.state);\n const {\n renderTopRightUI,\n renderCustomStats\n } = this.props;\n const sceneNonce = this.scene.getSceneNonce();\n const {\n elementsMap,\n visibleElements\n } = this.renderer.getRenderableElements({\n sceneNonce,\n zoom: this.state.zoom,\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n height: this.state.height,\n width: this.state.width,\n editingTextElement: this.state.editingTextElement,\n newElementId: (_a = this.state.newElement) === null || _a === void 0 ? void 0 : _a.id\n });\n this.visibleElements = visibleElements;\n const allElementsMap = this.scene.getNonDeletedElementsMap();\n const shouldBlockPointerEvents = // default back to `--ui-pointerEvents` flow if setPointerCapture\n // not supported\n \"setPointerCapture\" in HTMLElement.prototype ? false : this.state.selectionElement || this.state.newElement || this.state.selectedElementsAreBeingDragged || this.state.resizingElement || this.state.activeTool.type === \"laser\" && // technically we can just test on this once we make it more safe\n this.state.cursorButton === \"down\";\n const firstSelectedElement = selectedElements[0]; //zsviczian\n\n const isHighlighter = (_d = (_c = (_b = this.state.newElement) === null || _b === void 0 ? void 0 : _b.customData) === null || _c === void 0 ? void 0 : _c.strokeOptions) === null || _d === void 0 ? void 0 : _d.highlighter;\n const showShapeSwitchPanel = ((_e = _editor_jotai__WEBPACK_IMPORTED_MODULE_37__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom)) === null || _e === void 0 ? void 0 : _e.type) === \"panel\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"excalidraw excalidraw-container\", {\n \"excalidraw--view-mode\": this.state.viewModeEnabled || ((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\",\n \"excalidraw--mobile\": this.device.editor.isMobile || !(this.state.viewModeEnabled || this.state.zenModeEnabled) && this.state.trayModeEnabled //zsviczian\n\n }),\n style: Object.assign(Object.assign({\n //zsviczian\n [\"--ui-pointerEvents\"]: shouldBlockPointerEvents ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.enabled\n }, this.state.dynamicStyle || {}), {\n [\"--right-sidebar-width\"]: \"302px\"\n }),\n ref: this.excalidrawContainerRef,\n onDrop: this.handleAppOnDrop,\n tabIndex: 0,\n onKeyDown: this.props.handleKeyboardGlobally ? undefined : this.onKeyDown,\n onPointerEnter: this.toggleOverscrollBehavior,\n onPointerLeave: this.toggleOverscrollBehavior\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(AppContext.Provider, {\n value: this\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(AppPropsContext.Provider, {\n value: this.props\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawContainerContext.Provider, {\n value: this.excalidrawContainerValue\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(DeviceContext.Provider, {\n value: this.device\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawSetAppStateContext.Provider, {\n value: this.setAppState\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawAppStateContext.Provider, {\n value: this.state\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawElementsContext.Provider, {\n value: this.scene.getNonDeletedElements()\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawActionManagerContext.Provider, {\n value: this.actionManager\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_LayerUI__WEBPACK_IMPORTED_MODULE_57__[\"default\"], {\n canvas: this.canvas,\n appState: this.state,\n files: this.files,\n setAppState: this.setAppState,\n actionManager: this.actionManager,\n elements: this.scene.getNonDeletedElements(),\n onLockToggle: this.toggleLock,\n onPenModeToggle: this.togglePenMode,\n onHandToolToggle: this.onHandToolToggle,\n langCode: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.getLanguage)().code,\n renderTopRightUI: renderTopRightUI,\n renderCustomStats: renderCustomStats,\n showExitZenModeBtn: typeof ((_g = this.props) === null || _g === void 0 ? void 0 : _g.zenModeEnabled) === \"undefined\" && this.state.zenModeEnabled,\n UIOptions: this.props.UIOptions,\n onExportImage: this.onExportImage,\n renderWelcomeScreen: !this.state.isLoading && this.state.showWelcomeScreen && this.state.activeTool.type === this.defaultSelectionTool && !this.state.zenModeEnabled && !this.scene.getElementsIncludingDeleted().length,\n app: this,\n isCollaborating: this.props.isCollaborating,\n generateLinkForSelection: this.props.generateLinkForSelection\n }, this.props.children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-textEditorContainer\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-contextMenuContainer\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-eye-dropper-container\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_SVGLayer__WEBPACK_IMPORTED_MODULE_59__.SVGLayer, {\n trails: [this.laserTrails, this.lassoTrail, this.eraserTrail]\n }), selectedElements.length === 1 && ((_h = this.state.openDialog) === null || _h === void 0 ? void 0 : _h.name) !== \"elementLinkSelector\" && this.state.showHyperlinkPopup && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_35__.Hyperlink, {\n key: firstSelectedElement.id,\n element: firstSelectedElement,\n scene: this.scene,\n setAppState: this.setAppState,\n onLinkOpen: this.props.onLinkOpen,\n setToast: this.setToast,\n updateEmbedValidationStatus: this.updateEmbedValidationStatus\n }), this.props.aiEnabled !== false && selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isMagicFrameElement)(firstSelectedElement) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_43__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_58__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"labels.convertToCode\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_65__.MagicIcon,\n checked: false,\n onChange: () => this.onMagicFrameGenerate(firstSelectedElement, \"button\")\n })), selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(firstSelectedElement) && ((_k = (_j = firstSelectedElement.customData) === null || _j === void 0 ? void 0 : _j.generationData) === null || _k === void 0 ? void 0 : _k.status) === \"done\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_43__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_58__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"labels.copySource\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_65__.copyIcon,\n checked: false,\n onChange: () => this.onIframeSrcCopy(firstSelectedElement)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_58__.ElementCanvasButton, {\n title: \"Enter fullscreen\",\n icon: _icons__WEBPACK_IMPORTED_MODULE_65__.fullscreenIcon,\n checked: false,\n onChange: () => {\n const iframe = this.getHTMLIFrameElement(firstSelectedElement);\n\n if (iframe) {\n try {\n iframe.requestFullscreen();\n this.setState({\n activeEmbeddable: {\n element: firstSelectedElement,\n state: \"active\"\n },\n selectedElementIds: {\n [firstSelectedElement.id]: true\n },\n newElement: null,\n selectionElement: null\n });\n } catch (err) {\n console.warn(err);\n this.setState({\n errorMessage: \"Couldn't enter fullscreen\"\n });\n }\n }\n }\n })), this.state.toast !== null && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_Toast__WEBPACK_IMPORTED_MODULE_66__.Toast, {\n message: this.state.toast.message,\n onClose: this.handleToastClose,\n duration: this.state.toast.duration,\n closable: this.state.toast.closable\n }), this.state.contextMenu && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ContextMenu__WEBPACK_IMPORTED_MODULE_54__.ContextMenu, {\n items: this.state.contextMenu.items,\n top: this.state.contextMenu.top,\n left: this.state.contextMenu.left,\n actionManager: this.actionManager,\n onClose: callback => {\n this.setState({\n contextMenu: null\n }, () => {\n this.focusContainer();\n callback === null || callback === void 0 ? void 0 : callback();\n });\n }\n }), this.state.newElement && isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_63__[\"default\"], {\n appState: this.state,\n scale: window.devicePixelRatio,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: false,\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: null,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_62__.StaticCanvas, {\n canvas: this.canvas,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n visibleElements: visibleElements,\n sceneNonce: sceneNonce,\n selectionNonce: (_l = this.state.selectionElement) === null || _l === void 0 ? void 0 : _l.versionNonce,\n scale: window.devicePixelRatio,\n appState: this.state,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.isGridModeEnabled)(this),\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: this.flowChartCreator.pendingNodes,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), this.state.newElement && !isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_63__[\"default\"], {\n appState: this.state,\n scale: window.devicePixelRatio,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: false,\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: null,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_62__.InteractiveCanvas, {\n containerRef: this.excalidrawContainerRef,\n canvas: this.interactiveCanvas,\n elementsMap: elementsMap,\n visibleElements: visibleElements,\n allElementsMap: allElementsMap,\n selectedElements: selectedElements,\n sceneNonce: sceneNonce,\n selectionNonce: (_m = this.state.selectionElement) === null || _m === void 0 ? void 0 : _m.versionNonce,\n scale: window.devicePixelRatio,\n appState: this.state,\n renderScrollbars: this.props.renderScrollbars === true,\n device: this.device,\n renderInteractiveSceneCallback: this.renderInteractiveSceneCallback,\n handleCanvasRef: this.handleInteractiveCanvasRef,\n onContextMenu: this.handleCanvasContextMenu,\n onPointerMove: this.handleCanvasPointerMove,\n onPointerUp: this.handleCanvasPointerUp,\n onPointerCancel: this.removePointer,\n onTouchMove: this.handleTouchMove,\n onPointerDown: this.handleCanvasPointerDown,\n onDoubleClick: this.handleCanvasDoubleClick\n }), this.state.userToFollow && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_FollowMode_FollowMode__WEBPACK_IMPORTED_MODULE_56__[\"default\"], {\n width: this.state.width,\n height: this.state.height,\n userToFollow: this.state.userToFollow,\n onDisconnect: this.maybeUnfollowRemoteUser\n }), this.renderFrameNames(), ((_o = this.state.activeEmbeddable) === null || _o === void 0 ? void 0 : _o.state) === \"active\" && ( //zsviczian\n (_q = (_p = this.props).renderEmbeddableMenu) === null || _q === void 0 ? void 0 : _q.call(_p, this.state)), this.state.activeLockedId && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_UnlockPopup__WEBPACK_IMPORTED_MODULE_68__[\"default\"], {\n app: this,\n activeLockedId: this.state.activeLockedId\n }), showShapeSwitchPanel && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__[\"default\"], {\n app: this\n })), this.renderEmbeddables()))))))));\n }\n\n setPlugins(plugins) {\n Object.assign(this.plugins, plugins);\n }\n\n async onMagicFrameGenerate(magicFrame, source) {\n var _a;\n\n const generateDiagramToCode = (_a = this.plugins.diagramToCode) === null || _a === void 0 ? void 0 : _a.generate;\n\n if (!generateDiagramToCode) {\n this.setState({\n errorMessage: \"No diagram to code plugin found\"\n });\n return;\n }\n\n const magicFrameChildren = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsOverlappingFrame)(this.scene.getNonDeletedElements(), magicFrame).filter(el => !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isMagicFrameElement)(el));\n\n if (!magicFrameChildren.length) {\n if (source === \"button\") {\n this.setState({\n errorMessage: \"Cannot generate from an empty frame\"\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"generate (no-children)\", \"d2c\");\n } else {\n this.setActiveTool({\n type: \"magicframe\"\n });\n }\n\n return;\n }\n\n const frameElement = this.insertIframeElement({\n sceneX: magicFrame.x + magicFrame.width + 30,\n sceneY: magicFrame.y,\n width: magicFrame.width,\n height: magicFrame.height\n });\n\n if (!frameElement) {\n return;\n }\n\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"pending\"\n }\n });\n this.setState({\n selectedElementIds: {\n [frameElement.id]: true\n }\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"generate (start)\", \"d2c\");\n\n try {\n const {\n html\n } = await generateDiagramToCode({\n frame: magicFrame,\n children: magicFrameChildren\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"generate (success)\", \"d2c\");\n\n if (!html.trim()) {\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"error\",\n code: \"ERR_OAI\",\n message: \"Nothing genereated :(\"\n }\n });\n return;\n }\n\n const parsedHtml = html.includes(\"<!DOCTYPE html>\") && html.includes(\"</html>\") ? html.slice(html.indexOf(\"<!DOCTYPE html>\"), html.indexOf(\"</html>\") + \"</html>\".length) : html;\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"done\",\n html: parsedHtml\n }\n });\n } catch (error) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"generate (failed)\", \"d2c\");\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"error\",\n code: \"ERR_OAI\",\n message: error.message || \"Unknown error during generation\"\n }\n });\n }\n }\n\n onIframeSrcCopy(element) {\n var _a, _b;\n\n if (((_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.generationData) === null || _b === void 0 ? void 0 : _b.status) === \"done\") {\n (0,_clipboard__WEBPACK_IMPORTED_MODULE_24__.copyTextToSystemClipboard)(element.customData.generationData.html);\n this.setToast({\n message: \"copied to clipboard\",\n closable: false,\n duration: 1500\n });\n }\n }\n\n clearImageShapeCache(filesMap) {\n const files = filesMap !== null && filesMap !== void 0 ? filesMap : this.files;\n this.scene.getNonDeletedElements().forEach(element => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(element) && files[element.fileId]) {\n this.imageCache.delete(element.fileId);\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element);\n }\n });\n }\n\n async componentDidMount() {\n var _a;\n\n this.unmounted = false;\n this.excalidrawContainerValue.container = this.excalidrawContainerRef.current; //zsviczian disabling this code\n\n /*\r\n if (false && (isTestEnv() || isDevEnv())) {\r\n const setState = this.setState.bind(this);\r\n Object.defineProperties(window.h, {\r\n state: {\r\n configurable: true,\r\n get: () => {\r\n return this.state;\r\n },\r\n },\r\n setState: {\r\n configurable: true,\r\n value: (...args: Parameters<typeof setState>) => {\r\n return this.setState(...args);\r\n },\r\n },\r\n app: {\r\n configurable: true,\r\n value: this,\r\n },\r\n history: {\r\n configurable: true,\r\n value: this.history,\r\n },\r\n store: {\r\n configurable: true,\r\n value: this.store,\r\n },\r\n fonts: {\r\n configurable: true,\r\n value: this.fonts,\r\n },\r\n });\r\n }*/\n\n this.store.onDurableIncrementEmitter.on(increment => {\n this.history.record(increment.delta);\n });\n const {\n onIncrement\n } = this.props; // per. optimmisation, only subscribe if there is the `onIncrement` prop registered, to avoid unnecessary computation\n\n if (onIncrement) {\n this.store.onStoreIncrementEmitter.on(increment => {\n onIncrement(increment);\n });\n }\n\n this.scene.onUpdate(this.triggerRender);\n this.addEventListeners();\n\n if (this.props.autoFocus && this.excalidrawContainerRef.current) {\n this.focusContainer();\n }\n\n if ( // bounding rects don't work in tests so updating\n // the state on init would result in making the test enviro run\n // in mobile breakpoint (0 width/height), making everything fail\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isTestEnv)()) {\n this.refreshViewportBreakpoints();\n this.refreshEditorBreakpoints();\n }\n\n if (_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.supportsResizeObserver && this.excalidrawContainerRef.current) {\n this.resizeObserver = new ResizeObserver(() => {\n this.refreshEditorBreakpoints();\n this.updateDOMRect();\n });\n (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.excalidrawContainerRef.current);\n }\n\n const searchParams = new URLSearchParams(window.location.search.slice(1));\n\n if (searchParams.has(\"web-share-target\")) {\n // Obtain a file that was shared via the Web Share Target API.\n this.restoreFileFromShare();\n } else {\n this.updateDOMRect(this.initializeScene);\n } // note that this check seems to always pass in localhost\n\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isBrave)() && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isMeasureTextSupported)()) {\n this.setState({\n errorMessage: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_53__[\"default\"], null)\n });\n }\n }\n\n componentWillUnmount() {\n var _a, _b;\n\n (_a = window.launchQueue) === null || _a === void 0 ? void 0 : _a.setConsumer(() => {});\n this.renderer.destroy();\n this.scene.destroy();\n this.scene = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Scene();\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_36__.Fonts(this.scene);\n this.renderer = new _scene_Renderer__WEBPACK_IMPORTED_MODULE_41__.Renderer(this.scene);\n this.files = {};\n this.imageCache.clear();\n (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();\n this.unmounted = true;\n this.removeEventListeners();\n this.library.destroy();\n this.laserTrails.stop();\n this.eraserTrail.stop();\n this.onChangeEmitter.clear();\n this.store.onStoreIncrementEmitter.clear();\n this.store.onDurableIncrementEmitter.clear();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.destroy();\n _snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.destroy();\n clearTimeout(touchTimeout);\n _scene__WEBPACK_IMPORTED_MODULE_31__.isSomeElementSelected.clearCache();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements.clearCache();\n touchTimeout = 0;\n document.documentElement.style.overscrollBehaviorX = \"\";\n document.body.removeChild((0,_Tooltip__WEBPACK_IMPORTED_MODULE_70__.getTooltipDiv)()); //clearRenderCache(); //zsviczian\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.clearEraserCanvasCache)(); //zsviczian\n\n this.interactiveCanvas = null; //zsviczian\n\n this.iFrameRefs.clear(); //zsviczian\n //@ts-ignore\n\n this.iFrameRefs = null; //zsviczian\n\n this.embedsValidationStatus.clear(); //zsviczian\n //@ts-ignore\n\n this.embedsValidationStatus = null; //zsviczian\n\n this.initializedEmbeds.clear(); //zsviczian\n //@ts-ignore\n\n this.initializedEmbeds = null; //zsviczian\n\n this.elementsPendingErasure.clear(); //zsviczian\n //@ts-ignore\n\n this.elementsPendingErasure = null; //zsviczian\n\n this.lastPointerDownEvent = null; //zsviczian\n\n this.lastPointerUpEvent = null; //zsviczian\n\n this.lastPointerMoveEvent = null; //zsviczian\n //@ts-ignore\n\n this.actionManager.app = null; //zsviczian\n\n this.actionManager.actions = {}; //zsviczian\n\n this.history.clear(); //zsviczian\n\n this.store.clear(); //zsviczian\n //@ts-ignore\n\n this.store = null; //zsviczian\n //@ts-ignore\n\n this.library = null; //zsviczian\n //@ts-ignore\n\n this.canvas = null; //zsviczian\n //@ts-ignore\n\n this.rc = null; //zsviczian\n //@ts-ignore\n\n this.excalidrawContainerRef.current = undefined; //zsviczian\n\n this.nearestScrollableContainer = undefined; //zsviczian\n\n this.excalidrawContainerValue = {\n container: null,\n id: \"unknown\"\n }; //zsviczian\n //@ts-ignore\n // this.laserTrails.terminate(); //zsviczian\n // this.eraserTrail.terminate(); //zsviczian\n\n /*\r\n Object.keys(this).forEach((key) => {\r\n //@ts-ignore\r\n delete this[key];\r\n });*/\n }\n\n removeEventListeners() {\n this.onRemoveEventListenersEmitter.trigger();\n }\n\n addEventListeners() {\n // remove first as we can add event listeners multiple times\n this.removeEventListeners(); // -------------------------------------------------------------------------\n // view+edit mode listeners\n // -------------------------------------------------------------------------\n\n if (this.props.handleKeyboardGlobally) {\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, this.onKeyDown, false));\n }\n\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.WHEEL, this.handleWheel, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.MESSAGE, this.onWindowMessage, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, this.removePointer, {\n passive: false\n }), // #3553\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.COPY, this.onCopy, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYUP, this.onKeyUp, {\n passive: true\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, \"focus\", () => this.triggerRender(true), {\n passive: true\n }), //zsviczian\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, this.updateCurrentCursorPosition, {\n passive: false\n }), // rerender text elements on font load to fix #637 && #1553\n // zsviczian In Obsidian this is not needed as I manage font load separately\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document.fonts, \"loadingdone\", event => {\n const fontFaces = event.fontfaces;\n this.fonts.onLoaded(fontFaces);\n }, {\n passive: false\n }), // Safari-only desktop pinch zoom\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_START, this.onGestureStart, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_CHANGE, this.onGestureChange, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_END, this.onGestureEnd, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.FOCUS, () => {\n this.maybeCleanupAfterMissingPointerUp(null); // browsers (chrome?) tend to free up memory a lot, which results\n // in canvas context being cleared. Thus re-render on focus.\n\n this.triggerRender(true);\n }, {\n passive: false\n }));\n\n if (this.state.viewModeEnabled) {\n return;\n } // -------------------------------------------------------------------------\n // edit-mode listeners only\n // -------------------------------------------------------------------------\n\n\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.FULLSCREENCHANGE, this.onFullscreenChange, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, this.pasteFromClipboard, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.CUT, this.onCut, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.RESIZE, this.onResize, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.UNLOAD, this.onUnload, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, this.onBlur, false),\n /*addEventListener( //zsviczian (duplicate)\r\n this.excalidrawContainerRef.current,\r\n EVENT.WHEEL,\r\n this.handleWheel,\r\n { passive: false },\r\n ),*/\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.DRAG_OVER, this.disableEvent, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.DROP, this.disableEvent, false));\n\n if (this.props.detectScroll) {\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getNearestScrollableContainer)(this.excalidrawContainerRef.current), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.SCROLL, this.onScroll, {\n passive: false\n }));\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;\n\n this.updateEmbeddables();\n const elements = this.scene.getElementsIncludingDeleted();\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n\n if (!this.state.showWelcomeScreen && !elements.length) {\n this.setState({\n showWelcomeScreen: true\n });\n }\n\n if (prevProps.UIOptions.dockedSidebarBreakpoint !== this.props.UIOptions.dockedSidebarBreakpoint) {\n this.refreshEditorBreakpoints();\n }\n\n const hasFollowedPersonLeft = prevState.userToFollow && !this.state.collaborators.has(prevState.userToFollow.socketId);\n\n if (hasFollowedPersonLeft) {\n this.maybeUnfollowRemoteUser();\n }\n\n if (prevState.zoom.value !== this.state.zoom.value || prevState.scrollX !== this.state.scrollX || prevState.scrollY !== this.state.scrollY) {\n (_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.onScrollChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.state.scrollX, this.state.scrollY, this.state.zoom);\n this.onScrollChangeEmitter.trigger(this.state.scrollX, this.state.scrollY, this.state.zoom);\n }\n\n if (prevState.userToFollow !== this.state.userToFollow) {\n if (prevState.userToFollow) {\n this.onUserFollowEmitter.trigger({\n userToFollow: prevState.userToFollow,\n action: \"UNFOLLOW\"\n });\n }\n\n if (this.state.userToFollow) {\n this.onUserFollowEmitter.trigger({\n userToFollow: this.state.userToFollow,\n action: \"FOLLOW\"\n });\n }\n } // zsviczian\n\n\n if (this.state.highlightSearchResult && !this.debounceClearHighlightSearchResults && prevState.selectedElementIds !== this.state.selectedElementIds) {\n this.setState({\n highlightSearchResult: false\n });\n }\n\n if (Object.keys(this.state.selectedElementIds).length && (0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: \"selection\"\n })\n });\n }\n\n if (this.state.activeTool.type === \"eraser\" && prevState.theme !== this.state.theme) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setEraserCursor)(this.interactiveCanvas, this.state.theme);\n } // Hide hyperlink popup if shown when element type is not selection\n\n\n if (prevState.activeTool.type === \"selection\" && this.state.activeTool.type !== \"selection\" && this.state.showHyperlinkPopup) {\n this.setState({\n showHyperlinkPopup: false\n });\n }\n\n if (prevProps.langCode !== this.props.langCode) {\n this.updateLanguage();\n }\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(prevState) && !(0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state)) {\n this.eraserTrail.endPath();\n }\n\n if (prevProps.viewModeEnabled !== this.props.viewModeEnabled) {\n this.setState({\n viewModeEnabled: !!this.props.viewModeEnabled\n });\n }\n\n if (prevState.viewModeEnabled !== this.state.viewModeEnabled) {\n this.addEventListeners();\n this.deselectElements();\n } // cleanup\n\n\n if ((((_c = prevState.openDialog) === null || _c === void 0 ? void 0 : _c.name) === \"elementLinkSelector\" || ((_d = this.state.openDialog) === null || _d === void 0 ? void 0 : _d.name) === \"elementLinkSelector\") && ((_e = prevState.openDialog) === null || _e === void 0 ? void 0 : _e.name) !== ((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name)) {\n this.deselectElements();\n this.setState({\n hoveredElementIds: {}\n });\n }\n\n if (prevProps.zenModeEnabled !== this.props.zenModeEnabled) {\n this.setState({\n zenModeEnabled: !!this.props.zenModeEnabled\n });\n }\n\n if (prevProps.theme !== this.props.theme && this.props.theme) {\n this.setState({\n theme: this.props.theme\n });\n }\n\n (_g = this.excalidrawContainerRef.current) === null || _g === void 0 ? void 0 : _g.classList.toggle(\"theme--dark\", this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK);\n\n if (((_h = this.state.selectedLinearElement) === null || _h === void 0 ? void 0 : _h.isEditing) && !this.state.selectedElementIds[this.state.selectedLinearElement.elementId]) {\n // defer so that the scheduleCapture flag isn't reset via current update\n setTimeout(() => {\n var _a; // execute only if the condition still holds when the deferred callback\n // executes (it can be scheduled multiple times depending on how\n // many times the component renders)\n\n\n ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n });\n } // failsafe in case the state is being updated in incorrect order resulting\n // in the editingTextElement being now a deleted element\n\n\n if ((_j = this.state.editingTextElement) === null || _j === void 0 ? void 0 : _j.isDeleted) {\n this.setState({\n editingTextElement: null\n });\n }\n\n if (this.state.selectedLinearElement && !this.state.selectedElementIds[this.state.selectedLinearElement.elementId]) {\n // To make sure `selectedLinearElement` is in sync with `selectedElementIds`, however this shouldn't be needed once\n // we have a single API to update `selectedElementIds`\n this.setState({\n selectedLinearElement: null\n });\n }\n\n this.store.commit(elementsMap, this.state); // Do not notify consumers if we're still loading the scene. Among other\n // potential issues, this fixes a case where the tab isn't focused during\n // init, which would trigger onChange with empty elements, which would then\n // override whatever is in localStorage currently.\n\n if (!this.state.isLoading) {\n (_l = (_k = this.props).onChange) === null || _l === void 0 ? void 0 : _l.call(_k, elements, this.state, this.files);\n this.onChangeEmitter.trigger(elements, this.state, this.files);\n }\n }\n\n static resetTapTwice() {\n didTapTwice = false;\n firstTapPosition = null;\n } // TODO: Cover with tests\n\n\n async insertClipboardContent(data, dataTransferFiles, isPlainPaste) {\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state); // ------------------- Error -------------------\n\n if (data.errorMessage) {\n this.setState({\n errorMessage: data.errorMessage\n });\n return;\n } // ------------------- Mixed content with no files -------------------\n\n\n if (dataTransferFiles.length === 0 && !isPlainPaste && data.mixedContent) {\n await this.addElementsFromMixedContentPaste(data.mixedContent, {\n isPlainPaste,\n sceneX,\n sceneY\n });\n return;\n } // ------------------- Spreadsheet -------------------\n\n\n if (data.spreadsheet && !isPlainPaste) {\n this.setState({\n pasteDialog: {\n data: data.spreadsheet,\n shown: true\n }\n });\n return;\n } // ------------------- Images or SVG code -------------------\n\n\n const imageFiles = dataTransferFiles.map(data => data.file);\n\n if (imageFiles.length === 0 && data.text && !isPlainPaste) {\n const trimmedText = data.text.trim();\n\n if (trimmedText.startsWith(\"<svg\") && trimmedText.endsWith(\"</svg>\")) {\n // ignore SVG validation/normalization which will be done during image\n // initialization\n imageFiles.push((0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.SVGStringToFile)(trimmedText));\n }\n }\n\n if (imageFiles.length > 0) {\n if (this.isToolSupported(\"image\")) {\n await this.insertImages(imageFiles, sceneX, sceneY);\n } else {\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.imageToolNotSupported\")\n });\n }\n\n return;\n } // ------------------- Elements -------------------\n\n\n if (data.elements) {\n const elements = data.programmaticAPI ? (0,_data_transform__WEBPACK_IMPORTED_MODULE_40__.convertToExcalidrawElements)(data.elements) : data.elements; // TODO: remove formatting from elements if isPlainPaste\n\n this.addElementsFromPasteOrLibrary({\n elements,\n files: data.files || null,\n position: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() ? \"center\" : \"cursor\",\n retainSeed: isPlainPaste\n });\n return;\n } // ------------------- Only textual stuff remaining -------------------\n\n\n if (!data.text) {\n return;\n } // ------------------- Successful Mermaid -------------------\n\n\n if (!isPlainPaste && (0,_mermaid__WEBPACK_IMPORTED_MODULE_48__.isMaybeMermaidDefinition)(data.text)) {\n const api = await Promise.resolve(/*! import() */).then(__webpack_require__.bind(__webpack_require__, /*! @zsviczian/mermaid-to-excalidraw */ \"../../node_modules/@zsviczian/mermaid-to-excalidraw/dist/index.js\"));\n\n try {\n const {\n elements: skeletonElements,\n files\n } = await api.parseMermaidToExcalidraw(data.text);\n const elements = (0,_data_transform__WEBPACK_IMPORTED_MODULE_40__.convertToExcalidrawElements)(skeletonElements, {\n regenerateIds: true\n });\n this.addElementsFromPasteOrLibrary({\n elements,\n files,\n position: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() ? \"center\" : \"cursor\"\n });\n return;\n } catch (err) {\n console.warn(`parsing pasted text as mermaid definition failed: ${err.message}`);\n }\n } // ------------------- Pure embeddable URLs -------------------\n\n\n const nonEmptyLines = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeEOL)(data.text).split(/\\n+/).map(s => s.trim()).filter(Boolean);\n const embbeddableUrls = nonEmptyLines.map(str => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeParseEmbedSrc)(str)).filter(string => {\n var _a;\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(string, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(string) || ((_a = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)(string)) === null || _a === void 0 ? void 0 : _a.type) === \"video\");\n });\n\n if (!isPlainPaste && embbeddableUrls.length > 0 && embbeddableUrls.length === nonEmptyLines.length) {\n const embeddables = [];\n\n for (const url of embbeddableUrls) {\n const prevEmbeddable = embeddables[embeddables.length - 1];\n const embeddable = this.insertEmbeddableElement({\n sceneX: prevEmbeddable ? prevEmbeddable.x + prevEmbeddable.width + 20 : sceneX,\n sceneY,\n link: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeLink)(url)\n });\n\n if (embeddable) {\n embeddables.push(embeddable);\n }\n }\n\n if (embeddables.length) {\n this.store.scheduleCapture();\n this.setState({\n selectedElementIds: Object.fromEntries(embeddables.map(embeddable => [embeddable.id, true]))\n });\n }\n\n return;\n } // ------------------- Text -------------------\n\n\n this.addTextFromPaste(data.text, isPlainPaste);\n } // TODO rewrite this to paste both text & images at the same time if\n // pasted data contains both\n\n\n async addElementsFromMixedContentPaste(mixedContent, {\n isPlainPaste,\n sceneX,\n sceneY\n }) {\n if (!isPlainPaste && mixedContent.some(node => node.type === \"imageUrl\") && this.isToolSupported(\"image\")) {\n const imageURLs = mixedContent.filter(node => node.type === \"imageUrl\").map(node => node.value);\n const responses = await Promise.all(imageURLs.map(async url => {\n try {\n return {\n file: await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.ImageURLToFile)(url)\n };\n } catch (error) {\n let errorMessage = error.message;\n\n if (error.cause === \"FETCH_ERROR\") {\n errorMessage = (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.failedToFetchImage\");\n } else if (error.cause === \"UNSUPPORTED\") {\n errorMessage = (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.unsupportedFileType\");\n }\n\n return {\n errorMessage\n };\n }\n }));\n const imageFiles = responses.filter(response => !!response.file).map(response => response.file);\n await this.insertImages(imageFiles, sceneX, sceneY);\n const error = responses.find(response => !!response.errorMessage);\n\n if (error && error.errorMessage) {\n this.setState({\n errorMessage: error.errorMessage\n });\n }\n } else {\n const textNodes = mixedContent.filter(node => node.type === \"text\");\n\n if (textNodes.length) {\n this.addTextFromPaste(textNodes.map(node => node.value).join(\"\\n\\n\"), isPlainPaste);\n }\n }\n }\n\n addTextFromPaste(text, isPlainPaste = false) {\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state);\n const textElementProps = {\n x,\n y,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roundness: null,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n text,\n rawText: text,\n fontSize: (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_71__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value),\n fontFamily: this.state.currentItemFontFamily,\n textAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_TEXT_ALIGN,\n verticalAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_VERTICAL_ALIGN,\n locked: false\n };\n const fontString = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFontString)({\n fontSize: textElementProps.fontSize,\n fontFamily: textElementProps.fontFamily\n });\n const lineHeight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getLineHeight)(textElementProps.fontFamily);\n const [x1,, x2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getVisibleSceneBounds)(this.state); // long texts should not go beyond 800 pixels in width nor should it go below 200 px\n\n const maxTextWidth = Math.max(Math.min((x2 - x1) * 0.5, 800), 200);\n const LINE_GAP = 10;\n let currentY = y;\n const lines = isPlainPaste ? [text] : text.split(\"\\n\");\n const textElements = lines.reduce((acc, line, idx) => {\n var _a;\n\n const originalText = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.normalizeText)(line).trim();\n\n if (originalText.length) {\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x,\n y: currentY\n });\n let metrics = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.measureText)(originalText, fontString, lineHeight);\n const isTextUnwrapped = metrics.width > maxTextWidth;\n const text = isTextUnwrapped ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.wrapText)(originalText, fontString, maxTextWidth) : originalText;\n metrics = isTextUnwrapped ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.measureText)(text, fontString, lineHeight) : metrics;\n const startX = x - metrics.width / 2;\n const startY = currentY - metrics.height / 2;\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newTextElement)(Object.assign(Object.assign({}, textElementProps), {\n x: startX,\n y: startY,\n text,\n rawText: originalText,\n //zsviczian\n originalText,\n lineHeight,\n autoResize: !isTextUnwrapped,\n frameId: topLayerFrame ? topLayerFrame.id : null\n }));\n acc.push(element);\n currentY += element.height + LINE_GAP;\n } else {\n const prevLine = (_a = lines[idx - 1]) === null || _a === void 0 ? void 0 : _a.trim(); // add paragraph only if previous line was not empty, IOW don't add\n // more than one empty line\n\n if (prevLine) {\n currentY += (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLineHeightInPx)(textElementProps.fontSize, lineHeight) + LINE_GAP;\n }\n }\n\n return acc;\n }, []);\n\n if (textElements.length === 0) {\n return;\n }\n\n this.scene.insertElements(textElements);\n this.store.scheduleCapture();\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.fromEntries(textElements.map(el => [el.id, true])), this.state)\n });\n\n if (!isPlainPaste && textElements.length > 1 && PLAIN_PASTE_TOAST_SHOWN === false && !this.device.editor.isMobile) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"toast.pasteAsSingleElement\", {\n shortcut: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getShortcutKey)(\"CtrlOrCmd+Shift+V\")\n }),\n duration: 5000\n });\n PLAIN_PASTE_TOAST_SHOWN = true;\n }\n }\n\n handleTextWysiwyg(element, {\n isExistingElement = false\n }) {\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n\n const updateElement = (nextOriginalText, isDeleted, rawText, //zsviczian\n link) => {\n this.scene.replaceAllElements([// Not sure why we include deleted elements as well hence using deleted elements map\n ...this.scene.getElementsIncludingDeleted().map(_element => {\n if (_element.id === element.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(_element)) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(_element, Object.assign({\n originalText: nextOriginalText,\n rawText: rawText !== null && rawText !== void 0 ? rawText : nextOriginalText,\n //zsviczian\n link,\n isDeleted: isDeleted !== null && isDeleted !== void 0 ? isDeleted : _element.isDeleted\n }, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(_element, elementsMap), elementsMap, nextOriginalText)));\n }\n\n return _element;\n })]);\n }; //zsviczian\n\n\n if (this.props.onBeforeTextEdit) {\n const text = this.props.onBeforeTextEdit(element, isExistingElement);\n\n if (text && text !== element.originalText) {\n this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(_element => {\n if (_element.id === element.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(_element)) {\n //changing the value of element so this gets edited by textWysiwyg\n element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(_element, Object.assign({\n originalText: text,\n rawText: text,\n isDeleted: false\n }, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(_element, elementsMap), elementsMap, text)));\n return element;\n }\n\n return _element;\n })]);\n }\n }\n\n (0,_wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_46__.textWysiwyg)({\n id: element.id,\n canvas: this.canvas,\n getViewportCoords: (x, y) => {\n const {\n x: viewportX,\n y: viewportY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.sceneCoordsToViewportCoords)({\n sceneX: x,\n sceneY: y\n }, this.state);\n return [viewportX - this.state.offsetLeft, viewportY - this.state.offsetTop];\n },\n onChange: (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(nextOriginalText => {\n updateElement(nextOriginalText, false);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isNonDeletedElement)(element)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(element, this.scene);\n }\n }),\n onSubmit: (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(({\n viaKeyboard,\n nextOriginalText\n }) => {\n var _a;\n\n const isDeleted = !nextOriginalText.trim(); //zsviczian insert start\n\n const rawText = nextOriginalText; //should this be originalText??\n\n let link = undefined;\n\n if (this.props.onBeforeTextSubmit) {\n const _element = this.scene.getElementsIncludingDeleted().find(el => el.id === element.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(el));\n\n if (_element) {\n const dismensionsData = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(_element, elementsMap), elementsMap, nextOriginalText);\n const {\n updatedNextOriginalText,\n nextLink\n } = this.props.onBeforeTextSubmit(element, (_a = dismensionsData === null || dismensionsData === void 0 ? void 0 : dismensionsData.text) !== null && _a !== void 0 ? _a : nextOriginalText, //should never be undefined\n nextOriginalText, isDeleted);\n nextOriginalText = updatedNextOriginalText !== null && updatedNextOriginalText !== void 0 ? updatedNextOriginalText : nextOriginalText;\n link = nextLink;\n }\n } //zsviczian insert end\n\n\n updateElement(nextOriginalText, isDeleted, rawText, link); //zsviczian (added rawText, link, text)\n // select the created text element only if submitting via keyboard\n // (when submitting via click it should act as signal to deselect)\n\n if (!isDeleted && viaKeyboard) {\n const elementIdToSelect = element.containerId ? element.containerId : element.id; // needed to ensure state is updated before \"finalize\" action\n // that's invoked on keyboard-submit as well\n // TODO either move this into finalize as well, or handle all state\n // updates in one place, skipping finalize action\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [elementIdToSelect]: true\n }), prevState)\n }));\n });\n }\n\n if (isDeleted) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.fixBindingsAfterDeletion)(this.scene.getNonDeletedElements(), [element]);\n }\n\n if (!isDeleted || isExistingElement) {\n this.store.scheduleCapture();\n }\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n newElement: null,\n editingTextElement: null\n });\n });\n\n if (this.state.activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n\n this.focusContainer();\n }),\n element,\n excalidrawContainer: this.excalidrawContainerRef.current,\n app: this,\n // when text is selected, it's hard (at least on iOS) to re-position the\n // caret (i.e. deselect). There's not much use for always selecting\n // the text on edit anyway (and users can select-all from contextmenu\n // if needed)\n autoSelect: !this.device.isTouchScreen\n }); // deselect all other elements when inserting text\n\n this.deselectElements(); // do an initial update to re-initialize element position since we were\n // modifying element's x/y for sake of editor (case: syncing to remote)\n\n updateElement(element.originalText, false);\n }\n\n deselectElements() {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n getTextElementAtPosition(x, y) {\n const element = this.getElementAtPosition(x, y, {\n includeBoundTextElement: true\n });\n\n if (element && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element) && !element.isDeleted) {\n return element;\n }\n\n return null;\n } // NOTE: Hot path for hit testing, so avoid unnecessary computations\n\n\n getElementAtPosition(x, y, opts) {\n let allHitElements = [];\n\n if (opts && \"allHitElements\" in opts) {\n allHitElements = (opts === null || opts === void 0 ? void 0 : opts.allHitElements) || [];\n } else {\n allHitElements = this.getElementsAtPosition(x, y, {\n includeBoundTextElement: opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement,\n includeLockedElements: opts === null || opts === void 0 ? void 0 : opts.includeLockedElements\n });\n }\n\n if (allHitElements.length > 1) {\n if (opts === null || opts === void 0 ? void 0 : opts.preferSelected) {\n for (let index = allHitElements.length - 1; index > -1; index--) {\n if (this.state.selectedElementIds[allHitElements[index].id]) {\n return allHitElements[index];\n }\n }\n }\n\n const elementWithHighestZIndex = allHitElements[allHitElements.length - 1]; // If we're hitting element with highest z-index only on its bounding box\n // while also hitting other element figure, the latter should be considered.\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element: elementWithHighestZIndex,\n // when overlapping, we would like to be more precise\n // this also avoids the need to update past tests\n threshold: this.getElementHitThreshold(elementWithHighestZIndex) / 2,\n elementsMap: this.scene.getNonDeletedElementsMap(),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(elementWithHighestZIndex) ? this.frameNameBoundsCache.get(elementWithHighestZIndex) : null\n }) ? elementWithHighestZIndex : allHitElements[allHitElements.length - 2];\n }\n\n if (allHitElements.length === 1) {\n return allHitElements[0];\n }\n\n return null;\n } // NOTE: Hot path for hit testing, so avoid unnecessary computations\n\n\n getElementsAtPosition(x, y, opts) {\n const iframeLikes = [];\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const elements = ((opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement) && (opts === null || opts === void 0 ? void 0 : opts.includeLockedElements) ? this.scene.getNonDeletedElements() : this.scene.getNonDeletedElements().filter(element => ((opts === null || opts === void 0 ? void 0 : opts.includeLockedElements) || !element.locked) && ((opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement) || !((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element) && element.containerId)))).filter(el => this.hitElement(x, y, el)).filter(element => {\n // hitting a frame's element from outside the frame is not considered a hit\n const containingFrame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainingFrame)(element, elementsMap);\n return containingFrame && this.state.frameRendering.enabled && this.state.frameRendering.clip ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isCursorInFrame)({\n x,\n y\n }, containingFrame, elementsMap) : true;\n }).filter(el => {\n // The parameter elements comes ordered from lower z-index to higher.\n // We want to preserve that order on the returned array.\n // Exception being embeddables which should be on top of everything else in\n // terms of hit testing.\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(el)) {\n iframeLikes.push(el);\n return false;\n }\n\n return true;\n }).concat(iframeLikes);\n return elements;\n }\n\n getElementHitThreshold(element) {\n return Math.max(element.strokeWidth / 2 + 0.1, // NOTE: Here be dragons. Do not go under the 0.63 multiplier unless you're\n // willing to test extensively. The hit testing starts to become unreliable\n // due to FP imprecision under 0.63 in high zoom levels.\n 0.85 * (_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_COLLISION_THRESHOLD / this.state.zoom.value));\n }\n\n hitElement(x, y, element, considerBoundingBox = true) {\n // if the element is selected, then hit test is done against its bounding box\n if (considerBoundingBox && this.state.selectedElementIds[element.id] && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.shouldShowBoundingBox)([element], this.state)) {\n // if hitting the bounding box, return early\n // but if not, we should check for other cases as well (e.g. frame name)\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundingBox)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), element, this.scene.getNonDeletedElementsMap(), this.getElementHitThreshold(element))) {\n return true;\n }\n } // take bound text element into consideration for hit collision as well\n\n\n const hitBoundTextOfElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundText)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), element, this.scene.getNonDeletedElementsMap());\n\n if (hitBoundTextOfElement) {\n return true;\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element,\n threshold: this.getElementHitThreshold(element),\n elementsMap: this.scene.getNonDeletedElementsMap(),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element) ? this.frameNameBoundsCache.get(element) : null\n });\n }\n\n getTextBindableContainerAtPosition(x, y) {\n const elements = this.scene.getNonDeletedElements();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextBindableContainer)(selectedElements[0], false) ? selectedElements[0] : null;\n }\n\n let hitElement = null; // We need to do hit testing from front (end of the array) to back (beginning of the array)\n\n for (let index = elements.length - 1; index >= 0; --index) {\n if (elements[index].isDeleted) {\n continue;\n }\n\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementAbsoluteCoords)(elements[index], this.scene.getNonDeletedElementsMap());\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(elements[index]) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element: elements[index],\n elementsMap: this.scene.getNonDeletedElementsMap(),\n threshold: this.getElementHitThreshold(elements[index])\n })) {\n hitElement = elements[index];\n break;\n } else if (x1 < x && x < x2 && y1 < y && y < y2) {\n hitElement = elements[index];\n break;\n }\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextBindableContainer)(hitElement, false) ? hitElement : null;\n }\n\n handleHoverSelectedLinearElement(linearElementEditor, scenePointerX, scenePointerY) {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(linearElementEditor.elementId, elementsMap);\n\n if (!element) {\n return;\n }\n\n if (this.state.selectedLinearElement) {\n let hoverPointIndex = -1;\n let segmentMidPointHoveredCoords = null;\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY),\n element,\n elementsMap,\n threshold: this.getElementHitThreshold(element)\n })) {\n hoverPointIndex = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointIndexUnderCursor(element, elementsMap, this.state.zoom, scenePointerX, scenePointerY);\n segmentMidPointHoveredCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(linearElementEditor, {\n x: scenePointerX,\n y: scenePointerY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const isHoveringAPointHandle = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) ? hoverPointIndex === 0 || hoverPointIndex === element.points.length - 1 : hoverPointIndex >= 0;\n\n if (isHoveringAPointHandle || segmentMidPointHoveredCoords) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || Object.keys(this.state.selectedElementIds).length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\n }\n }\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || Object.keys(this.state.selectedElementIds).length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\n }\n }\n\n if (this.state.selectedLinearElement.hoverPointIndex !== hoverPointIndex) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n hoverPointIndex\n })\n });\n }\n\n if (!_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords, segmentMidPointHoveredCoords)) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords\n })\n });\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n }\n } //mfuria #329. start right-click panning\n\n\n startRightClickPanning(event) {\n // Set up right-click panning similar to hand tool\n isPanning = true;\n this.focusContainer();\n\n if (!this.state.editingTextElement) {\n event.preventDefault();\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRABBING);\n let {\n clientX: lastX,\n clientY: lastY\n } = event;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdatesThrottled)(event => {\n const deltaX = lastX - event.clientX;\n const deltaY = lastY - event.clientY;\n lastX = event.clientX;\n lastY = event.clientY;\n this.translateCanvas({\n scrollX: this.state.scrollX - deltaX / this.state.zoom.value,\n scrollY: this.state.scrollY - deltaY / this.state.zoom.value\n });\n });\n const teardown = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(() => {\n isPanning = false;\n\n if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n\n this.setState({\n cursorButton: \"up\"\n });\n this.savePointer(event.clientX, event.clientY, \"up\");\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n onPointerMove.flush();\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove, {\n passive: true\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n }\n\n updateGestureOnPointerDown(event) {\n gesture.pointers.set(event.pointerId, {\n x: event.clientX,\n y: event.clientY\n });\n\n if (gesture.pointers.size === 2) {\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.shouldDisableZoom)(this.state)) {\n //zsviczian\n gesture.initialDistance = null;\n } else {\n gesture.lastCenter = (0,_gesture__WEBPACK_IMPORTED_MODULE_28__.getCenter)(gesture.pointers);\n gesture.initialScale = this.state.zoom.value;\n gesture.initialDistance = (0,_gesture__WEBPACK_IMPORTED_MODULE_28__.getDistance)(Array.from(gesture.pointers.values()));\n }\n }\n }\n\n initialPointerDownState(event) {\n const origin = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const selectedElements = this.scene.getSelectedElements(this.state);\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n const isElbowArrowOnly = selectedElements.findIndex(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow) === 0;\n return {\n origin,\n withCmdOrCtrl: event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD],\n originInGrid: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.tupleToCoors)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(origin.x, origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] || isElbowArrowOnly ? null : this.getEffectiveGridSize())),\n scrollbars: (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_47__.isOverScrollBars)(currentScrollBars, event.clientX - this.state.offsetLeft, event.clientY - this.state.offsetTop),\n // we need to duplicate because we'll be updating this state\n lastCoords: Object.assign({}, origin),\n originalElements: this.scene.getNonDeletedElements().reduce((acc, element) => {\n acc.set(element.id, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.deepCopyElement)(element));\n return acc;\n }, new Map()),\n resize: {\n handleType: false,\n isResizing: false,\n offset: {\n x: 0,\n y: 0\n },\n arrowDirection: \"origin\",\n center: {\n x: (maxX + minX) / 2,\n y: (maxY + minY) / 2\n }\n },\n hit: {\n element: null,\n allHitElements: [],\n wasAddedToSelection: false,\n hasBeenDuplicated: false,\n hasHitCommonBoundingBoxOfSelectedElements: this.isHittingCommonBoundingBoxOfSelectedElements(origin, selectedElements)\n },\n drag: {\n hasOccurred: false,\n offset: null,\n origin: Object.assign({}, origin),\n blockDragging: false\n },\n eventListeners: {\n onMove: null,\n onUp: null,\n onKeyUp: null,\n onKeyDown: null\n },\n boxSelection: {\n hasOccurred: false\n }\n };\n } // Returns whether the event is a dragging a scrollbar\n\n\n handleDraggingScrollBar(event, pointerDownState) {\n if (!(pointerDownState.scrollbars.isOverEither && !this.state.multiElement)) {\n return false;\n }\n\n isDraggingScrollBar = true;\n pointerDownState.lastCoords.x = event.clientX;\n pointerDownState.lastCoords.y = event.clientY;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdatesThrottled)(event => {\n const target = event.target;\n\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n this.handlePointerMoveOverScrollbars(event, pointerDownState);\n });\n const onPointerUp = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(() => {\n lastPointerUp = null;\n isDraggingScrollBar = false;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n this.setState({\n cursorButton: \"up\"\n });\n this.savePointer(event.clientX, event.clientY, \"up\");\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp);\n onPointerMove.flush();\n });\n lastPointerUp = onPointerUp;\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp);\n return true;\n }\n\n isASelectedElement(hitElement) {\n return hitElement != null && this.state.selectedElementIds[hitElement.id];\n }\n\n isHittingCommonBoundingBoxOfSelectedElements(point, selectedElements) {\n if (selectedElements.length < 2) {\n return false;\n } // How many pixels off the shape boundary we still consider a hit\n\n\n const threshold = Math.max(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_COLLISION_THRESHOLD / this.state.zoom.value, 1);\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n return point.x > x1 - threshold && point.x < x2 + threshold && point.y > y1 - threshold && point.y < y2 + threshold;\n }\n\n getCurrentItemRoundness(elementType) {\n return this.state.currentItemRoundness === \"round\" ? {\n type: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isUsingAdaptiveRadius)(elementType) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.ADAPTIVE_RADIUS : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null;\n }\n\n maybeCacheReferenceSnapPoints(event, selectedElements, recomputeAnyways = false) {\n if ((0,_snapping__WEBPACK_IMPORTED_MODULE_39__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.getReferenceSnapPoints())) {\n _snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.setReferenceSnapPoints((0,_snapping__WEBPACK_IMPORTED_MODULE_39__.getReferenceSnapPoints)(this.scene.getNonDeletedElements(), selectedElements, this.state, this.scene.getNonDeletedElementsMap()));\n }\n }\n\n maybeCacheVisibleGaps(event, selectedElements, recomputeAnyways = false) {\n if ((0,_snapping__WEBPACK_IMPORTED_MODULE_39__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.getVisibleGaps())) {\n _snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.setVisibleGaps((0,_snapping__WEBPACK_IMPORTED_MODULE_39__.getVisibleGaps)(this.scene.getNonDeletedElements(), selectedElements, this.state, this.scene.getNonDeletedElementsMap()));\n }\n }\n\n onKeyDownFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n if (this.maybeHandleResize(pointerDownState, event)) {\n return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\n });\n }\n\n onKeyUpFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n // Prevents focus from escaping excalidraw tab\n event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ALT && event.preventDefault();\n\n if (this.maybeHandleResize(pointerDownState, event)) {\n return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\n });\n }\n\n onPointerMoveFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdatesThrottled)(event => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j; //To avoid pointerMove canceling the selection of locked elements on mobile //zsviczian\n\n\n if (Boolean(this.state.contextMenu) || ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n return;\n }\n\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (this.state.activeLockedId) {\n this.setState({\n activeLockedId: null\n });\n }\n\n if (this.state.selectedLinearElement && this.state.selectedLinearElement.elbowed && this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n let index = this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;\n\n if (index < 0) {\n const nextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: null\n }), {\n x: gridX,\n y: gridY\n }, this.state, this.scene.getNonDeletedElementsMap());\n index = nextCoords ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, nextCoords, this.scene.getNonDeletedElementsMap()) : -1;\n }\n\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.moveFixedSegment(this.state.selectedLinearElement, index, gridX, gridY, this.scene);\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: ret.segmentMidPointHoveredCoords,\n pointerDownState: ret.pointerDownState\n })\n });\n return;\n }\n\n const lastPointerCoords = (_b = this.lastPointerMoveCoords) !== null && _b !== void 0 ? _b : pointerDownState.origin;\n this.lastPointerMoveCoords = pointerCoords; // We need to initialize dragOffsetXY only after we've updated\n // `state.selectedElementIds` on pointerDown. Doing it here in pointerMove\n // event handler should hopefully ensure we're already working with\n // the updated state.\n\n if (pointerDownState.drag.offset === null) {\n pointerDownState.drag.offset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.tupleToCoors)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getDragOffsetXY)(this.scene.getSelectedElements(this.state), pointerDownState.origin.x, pointerDownState.origin.y));\n }\n\n const target = event.target;\n\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n if (this.handlePointerMoveOverScrollbars(event, pointerDownState)) {\n return;\n }\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state)) {\n this.handleEraser(event, pointerCoords);\n return;\n }\n\n if (this.state.activeTool.type === \"laser\") {\n this.laserTrails.addPointToPath(pointerCoords.x, pointerCoords.y);\n }\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize()); // for arrows/lines, don't start dragging until a given threshold\n // to ensure we don't create a 2-point arrow by mistake when\n // user clicks mouse in a way that it moves a tiny bit (thus\n // triggering pointermove)\n\n if (!pointerDownState.drag.hasOccurred && (this.state.activeTool.type === \"arrow\" || this.state.activeTool.type === \"line\")) {\n if ((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerCoords.x, pointerCoords.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y)) * this.state.zoom.value < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MINIMUM_ARROW_SIZE) {\n return;\n }\n }\n\n if (pointerDownState.resize.isResizing) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n\n if (this.maybeHandleCrop(pointerDownState, event)) {\n return true;\n }\n\n if (this.maybeHandleResize(pointerDownState, event)) {\n return true;\n }\n }\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if (this.state.selectedLinearElement) {\n const linearElementEditor = this.state.selectedLinearElement;\n\n if (_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.shouldAddMidpoint(this.state.selectedLinearElement, pointerCoords, this.state, elementsMap)) {\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.addMidpoint(this.state.selectedLinearElement, pointerCoords, this, !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD], this.scene);\n\n if (!ret) {\n return;\n } // Since we are reading from previous state which is not possible with\n // automatic batching in React 18 hence using flush sync to synchronously\n // update the state. Check https://github.com/excalidraw/excalidraw/pull/5508 for more details.\n\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n if (this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n pointerDownState: ret.pointerDownState,\n selectedPointsIndices: ret.selectedPointsIndices,\n segmentMidPointHoveredCoords: null\n })\n });\n }\n });\n return;\n } else if (linearElementEditor.pointerDownState.segmentMidpoint.value !== null && !linearElementEditor.pointerDownState.segmentMidpoint.added) {\n return;\n }\n\n const newState = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointDragging(event, this, pointerCoords.x, pointerCoords.y, linearElementEditor);\n\n if (newState) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n pointerDownState.drag.hasOccurred = true;\n this.setState(newState);\n return;\n }\n }\n\n const hasHitASelectedElement = pointerDownState.hit.allHitElements.some(element => this.isASelectedElement(element));\n const isSelectingPointsInLineEditor = ((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.isEditing) && event.shiftKey && this.state.selectedLinearElement.elementId === ((_d = pointerDownState.hit.element) === null || _d === void 0 ? void 0 : _d.id);\n\n if ((hasHitASelectedElement || pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) && !isSelectingPointsInLineEditor && !pointerDownState.drag.blockDragging) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length > 0 && selectedElements.every(element => element.locked)) {\n return;\n }\n\n const selectedElementsHasAFrame = selectedElements.find(e => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(e));\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords(pointerCoords);\n const frameToHighlight = topLayerFrame && !selectedElementsHasAFrame ? topLayerFrame : null; // Only update the state if there is a difference\n\n if (this.state.frameToHighlight !== frameToHighlight) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n frameToHighlight\n });\n });\n } // Marking that click was used for dragging to check\n // if elements should be deselected on pointerup\n\n\n pointerDownState.drag.hasOccurred = true; // prevent immediate dragging during lasso selection to avoid element displacement\n // only allow dragging if we're not in the middle of lasso selection\n // (on mobile, allow dragging if we hit an element)\n\n if (this.state.activeTool.type === \"lasso\" && this.lassoTrail.hasCurrentTrail && !((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() && pointerDownState.hit.element) && !this.state.activeTool.fromSelection) {\n return;\n } // Clear lasso trail when starting to drag selected elements with lasso tool\n // Only clear if we're actually dragging (not during lasso selection)\n\n\n if (this.state.activeTool.type === \"lasso\" && selectedElements.length > 0 && pointerDownState.drag.hasOccurred && !this.state.activeTool.fromSelection) {\n this.lassoTrail.endPath();\n } // prevent dragging even if we're no longer holding cmd/ctrl otherwise\n // it would have weird results (stuff jumping all over the screen)\n // Checking for editingTextElement to avoid jump while editing on mobile #6503\n\n\n if (selectedElements.length > 0 && !pointerDownState.withCmdOrCtrl && !this.state.editingTextElement && ((_e = this.state.activeEmbeddable) === null || _e === void 0 ? void 0 : _e.state) !== \"active\") {\n const dragOffset = {\n x: pointerCoords.x - pointerDownState.drag.origin.x,\n y: pointerCoords.y - pointerDownState.drag.origin.y\n };\n const originalElements = [...pointerDownState.originalElements.values()]; // We only drag in one direction if shift is pressed\n\n const lockDirection = event.shiftKey;\n\n if (lockDirection) {\n const distanceX = Math.abs(dragOffset.x);\n const distanceY = Math.abs(dragOffset.y);\n const lockX = lockDirection && distanceX < distanceY;\n const lockY = lockDirection && distanceX > distanceY;\n\n if (lockX) {\n dragOffset.x = 0;\n }\n\n if (lockY) {\n dragOffset.y = 0;\n }\n } // #region move crop region\n\n\n if (this.state.croppingElementId) {\n const croppingElement = this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);\n\n if (croppingElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingElement) && croppingElement.crop !== null && pointerDownState.hit.element === croppingElement) {\n const crop = croppingElement.crop;\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(croppingElement) && ((_f = this.imageCache.get(croppingElement.fileId)) === null || _f === void 0 ? void 0 : _f.image);\n\n if (image && !(image instanceof Promise)) {\n const instantDragOffset = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vector)(pointerCoords.x - lastPointerCoords.x, pointerCoords.y - lastPointerCoords.y), Math.max(this.state.zoom.value, 2));\n const [x1, y1, x2, y2, cx, cy] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementAbsoluteCoords)(croppingElement, elementsMap);\n const topLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x1, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const topRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x2, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const bottomLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x1, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const topEdge = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorSubtract)(topRight, topLeft));\n const leftEdge = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorSubtract)(bottomLeft, topLeft)); // project instantDrafOffset onto leftEdge and topEdge to decompose\n\n const offsetVector = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorDot)(instantDragOffset, topEdge), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorDot)(instantDragOffset, leftEdge));\n const nextCrop = Object.assign(Object.assign({}, crop), {\n x: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.clamp)(crop.x - offsetVector[0] * Math.sign(croppingElement.scale[0]), 0, image.naturalWidth - crop.width),\n y: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.clamp)(crop.y - offsetVector[1] * Math.sign(croppingElement.scale[1]), 0, image.naturalHeight - crop.height)\n });\n this.scene.mutateElement(croppingElement, {\n crop: nextCrop\n });\n return;\n }\n }\n } // Snap cache *must* be synchronously popuplated before initial drag,\n // otherwise the first drag even will not snap, causing a jump before\n // it snaps to its position if previously snapped already.\n\n\n this.maybeCacheVisibleGaps(event, selectedElements);\n this.maybeCacheReferenceSnapPoints(event, selectedElements);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.snapDraggedElements)(originalElements, dragOffset, this, event, this.scene.getNonDeletedElementsMap());\n this.setState({\n snapLines\n }); // when we're editing the name of a frame, we want the user to be\n // able to select and interact with the text input\n\n if (!this.state.editingFrame) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.dragSelectedElements)(pointerDownState, selectedElements, dragOffset, this.scene, snapOffset, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n }\n\n this.setState({\n selectedElementsAreBeingDragged: true,\n // element is being dragged and selectionElement that was created on pointer down\n // should be removed\n selectionElement: null\n });\n\n if (selectedElements.length !== 1 || !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0])) {\n this.setState({\n suggestedBindings: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSuggestedBindingsForArrows)(selectedElements, this.scene.getNonDeletedElementsMap(), this.state.zoom)\n });\n } // We duplicate the selected element if alt is pressed on pointer move\n\n\n if (event.altKey && !pointerDownState.hit.hasBeenDuplicated) {\n // Move the currently selected elements to the top of the z index stack, and\n // put the duplicates where the selected elements used to be.\n // (the origin point where the dragging started)\n pointerDownState.hit.hasBeenDuplicated = true;\n const elements = this.scene.getElementsIncludingDeleted();\n const hitElement = pointerDownState.hit.element;\n const selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds,\n includeBoundTextElement: true,\n includeElementsInFrames: true\n });\n\n if (hitElement && // hit element may not end up being selected\n // if we're alt-dragging a common bounding box\n // over the hit element\n pointerDownState.hit.wasAddedToSelection && !selectedElements.find(el => el.id === hitElement.id)) {\n selectedElements.push(hitElement);\n }\n\n const idsOfElementsToDuplicate = new Map(selectedElements.map(el => [el.id, el]));\n const {\n duplicatedElements,\n duplicateElementsMap,\n elementsWithDuplicates,\n origIdToDuplicateId\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.duplicateElements)({\n type: \"in-place\",\n elements,\n appState: this.state,\n randomizeSeed: true,\n idsOfElementsToDuplicate,\n overrides: ({\n duplicateElement,\n origElement\n }) => {\n var _a;\n\n return {\n // reset to the original element's frameId (unless we've\n // duplicated alongside a frame in which case we need to\n // keep the duplicate frame's id) so that the element\n // frame membership is refreshed on pointerup\n // NOTE this is a hacky solution and should be done\n // differently\n frameId: (_a = duplicateElement.frameId) !== null && _a !== void 0 ? _a : origElement.frameId,\n seed: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.randomInteger)()\n };\n }\n });\n duplicatedElements.forEach(element => {\n pointerDownState.originalElements.set(element.id, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.deepCopyElement)(element));\n });\n const mappedClonedElements = elementsWithDuplicates.map(el => {\n if (idsOfElementsToDuplicate.has(el.id)) {\n const origEl = pointerDownState.originalElements.get(el.id);\n\n if (origEl) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(el, {\n x: origEl.x,\n y: origEl.y\n });\n }\n }\n\n return el;\n });\n const mappedNewSceneElements = (_h = (_g = this.props).onDuplicate) === null || _h === void 0 ? void 0 : _h.call(_g, mappedClonedElements, elements);\n const elementsWithIndices = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.syncMovedIndices)(mappedNewSceneElements || mappedClonedElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(duplicatedElements)); // we need to update synchronously so as to keep pointerDownState,\n // appState, and scene elements in sync\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n // swap hit element with the duplicated one\n if (pointerDownState.hit.element) {\n const cloneId = origIdToDuplicateId.get(pointerDownState.hit.element.id);\n const clonedElement = cloneId && duplicateElementsMap.get(cloneId);\n pointerDownState.hit.element = clonedElement || null;\n } // swap hit elements with the duplicated ones\n\n\n pointerDownState.hit.allHitElements = pointerDownState.hit.allHitElements.reduce((acc, origHitElement) => {\n const cloneId = origIdToDuplicateId.get(origHitElement.id);\n const clonedElement = cloneId && duplicateElementsMap.get(cloneId);\n\n if (clonedElement) {\n acc.push(clonedElement);\n }\n\n return acc;\n }, []); // update drag origin to the position at which we started\n // the duplication so that the drag offset is correct\n\n pointerDownState.drag.origin = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state); // switch selected elements to the duplicated ones\n\n this.setState(prevState => Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectionStateForElements)(duplicatedElements, this.scene.getNonDeletedElements(), prevState)));\n this.scene.replaceAllElements(elementsWithIndices);\n this.maybeCacheVisibleGaps(event, selectedElements, true);\n this.maybeCacheReferenceSnapPoints(event, selectedElements, true);\n });\n }\n\n return;\n }\n }\n\n if (this.state.selectionElement) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n\n if (event.altKey) {\n this.setActiveTool({\n type: \"lasso\",\n fromSelection: true\n }, event.shiftKey);\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n this.setAppState({\n selectionElement: null\n });\n return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\n } else if (this.state.activeTool.type === \"lasso\") {\n if (!event.altKey && this.state.activeTool.fromSelection) {\n this.setActiveTool({\n type: \"selection\"\n });\n this.createGenericElementOnPointerDown(\"selection\", pointerDownState);\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n this.maybeDragNewGenericElement(pointerDownState, event);\n this.lassoTrail.endPath();\n } else {\n this.lassoTrail.addPointToPath(pointerCoords.x, pointerCoords.y, event.shiftKey);\n }\n } else {\n // It is very important to read this.state within each move event,\n // otherwise we would read a stale one!\n const newElement = this.state.newElement;\n\n if (!newElement) {\n return;\n }\n\n if (newElement.type === \"freedraw\") {\n const points = newElement.points;\n const dx = pointerCoords.x - newElement.x;\n const dy = pointerCoords.y - newElement.y;\n const lastPoint = points.length > 0 && points[points.length - 1];\n const discardPoint = lastPoint && lastPoint[0] === dx && lastPoint[1] === dy;\n\n if (!discardPoint) {\n const strokeOptions = this.state.currentStrokeOptions; //zsviczian\n\n const pressures = newElement.simulatePressure ? newElement.pressures : [//zsviczian\n ...newElement.pressures, (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure) ? 1 : event.pressure];\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)],\n pressures\n }, {\n informMutation: false,\n isDragging: false\n });\n this.setState({\n newElement\n });\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newElement)) {\n pointerDownState.drag.hasOccurred = true;\n const points = newElement.points;\n let dx = gridX - newElement.x;\n let dy = gridY - newElement.y;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldRotateWithDiscreteAngle)(event) && points.length === 2) {\n ({\n width: dx,\n height: dy\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLockedLinearCursorAlignSize)(newElement.x, newElement.y, pointerCoords.x, pointerCoords.y));\n }\n\n if (points.length === 1) {\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n informMutation: false,\n isDragging: false\n });\n } else if (points.length === 2 || points.length > 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(newElement)) {\n this.scene.mutateElement(newElement, {\n points: [...points.slice(0, -1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n isDragging: true,\n informMutation: false\n });\n }\n\n this.setState({\n newElement\n });\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(newElement, false)) {\n // When creating a linear element by dragging\n this.setState({\n suggestedBindings: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeSuggestBindingsForLinearElementAtCoords)(newElement, [pointerCoords], this.scene, this.state.zoom, this.state.startBoundElement)\n });\n }\n } else {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n this.maybeDragNewGenericElement(pointerDownState, event, false);\n }\n }\n\n if (this.state.activeTool.type === \"selection\") {\n pointerDownState.boxSelection.hasOccurred = true;\n const elements = this.scene.getNonDeletedElements(); // box-select line editor points\n\n if ((_j = this.state.selectedLinearElement) === null || _j === void 0 ? void 0 : _j.isEditing) {\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handleBoxSelection(event, this.state, this.setState.bind(this), this.scene.getNonDeletedElementsMap()); // regular box-select\n } else {\n let shouldReuseSelection = true;\n\n if (!event.shiftKey && (0,_scene__WEBPACK_IMPORTED_MODULE_31__.isSomeElementSelected)(elements, this.state)) {\n if (pointerDownState.withCmdOrCtrl && pointerDownState.hit.element) {\n this.setState(prevState => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)(Object.assign(Object.assign({}, prevState), {\n selectedElementIds: {\n [pointerDownState.hit.element.id]: true\n }\n }), this.scene.getNonDeletedElements(), prevState, this));\n } else {\n shouldReuseSelection = false;\n }\n }\n\n const elementsWithinSelection = this.state.selectionElement ? (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getElementsWithinSelection)(elements, this.state.selectionElement, this.scene.getNonDeletedElementsMap(), false) : [];\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign(Object.assign({}, shouldReuseSelection && prevState.selectedElementIds), elementsWithinSelection.reduce((acc, element) => {\n acc[element.id] = true;\n return acc;\n }, {}));\n\n if (pointerDownState.hit.element) {\n // if using ctrl/cmd, select the hitElement only if we\n // haven't box-selected anything else\n if (!elementsWithinSelection.length) {\n nextSelectedElementIds[pointerDownState.hit.element.id] = true;\n } else {\n delete nextSelectedElementIds[pointerDownState.hit.element.id];\n }\n }\n\n prevState = !shouldReuseSelection ? Object.assign(Object.assign({}, prevState), {\n selectedGroupIds: {},\n editingGroupId: null\n }) : prevState;\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n // select linear element only when we haven't box-selected anything else\n selectedLinearElement: elementsWithinSelection.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(elementsWithinSelection[0]) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(elementsWithinSelection[0], this.scene.getNonDeletedElementsMap()) : null,\n showHyperlinkPopup: elementsWithinSelection.length === 1 && (elementsWithinSelection[0].link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(elementsWithinSelection[0])) ? \"info\" : false\n });\n });\n }\n }\n });\n } // Returns whether the pointer move happened over either scrollbar\n\n\n handlePointerMoveOverScrollbars(event, pointerDownState) {\n var _a, _b;\n\n if (pointerDownState.scrollbars.isOverHorizontal) {\n const x = event.clientX;\n const dx = x - pointerDownState.lastCoords.x;\n this.translateCanvas({\n scrollX: this.state.scrollX - dx * (((_a = currentScrollBars.horizontal) === null || _a === void 0 ? void 0 : _a.deltaMultiplier) || 1) / this.state.zoom.value\n });\n pointerDownState.lastCoords.x = x;\n return true;\n }\n\n if (pointerDownState.scrollbars.isOverVertical) {\n const y = event.clientY;\n const dy = y - pointerDownState.lastCoords.y;\n this.translateCanvas({\n scrollY: this.state.scrollY - dy * (((_b = currentScrollBars.vertical) === null || _b === void 0 ? void 0 : _b.deltaMultiplier) || 1) / this.state.zoom.value\n });\n pointerDownState.lastCoords.y = y;\n return true;\n }\n\n return false;\n }\n\n onPointerUpFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(childEvent => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;\n\n this.removePointer(childEvent);\n pointerDownState.drag.blockDragging = false;\n\n if (pointerDownState.eventListeners.onMove) {\n pointerDownState.eventListeners.onMove.flush();\n }\n\n const {\n newElement,\n resizingElement,\n croppingElementId,\n multiElement,\n activeTool,\n isResizing,\n isRotating,\n isCropping\n } = this.state;\n this.setState(prevState => ({\n isResizing: false,\n isRotating: false,\n isCropping: false,\n resizingElement: null,\n selectionElement: null,\n frameToHighlight: null,\n elementsToHighlight: null,\n cursorButton: \"up\",\n snapLines: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.snapLines, []),\n originSnapOffset: null\n })); // just in case, tool changes mid drag, always clean up\n\n this.lassoTrail.endPath();\n this.lastPointerMoveCoords = null;\n _snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.setReferenceSnapPoints(null);\n _snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.setVisibleGaps(null);\n this.savePointer(childEvent.clientX, childEvent.clientY, \"up\"); // if current elements are still selected\n // and the pointer is just over a locked element\n // do not allow activeLockedId to be set\n\n const hitElements = pointerDownState.hit.allHitElements;\n const sceneCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: childEvent.clientX,\n clientY: childEvent.clientY\n }, this.state);\n\n if (this.state.activeTool.type === \"selection\" && !pointerDownState.boxSelection.hasOccurred && !pointerDownState.resize.isResizing && !hitElements.some(el => this.state.selectedElementIds[el.id])) {\n const hitLockedElement = this.getElementAtPosition(sceneCoords.x, sceneCoords.y, {\n includeLockedElements: true\n });\n this.store.scheduleCapture();\n\n if (hitLockedElement === null || hitLockedElement === void 0 ? void 0 : hitLockedElement.locked) {\n this.setState({\n activeLockedId: hitLockedElement.groupIds.length > 0 ? hitLockedElement.groupIds.at(-1) || \"\" : hitLockedElement.id\n });\n } else {\n this.setState({\n activeLockedId: null\n });\n }\n } else {\n this.setState({\n activeLockedId: null\n });\n }\n\n this.setState({\n selectedElementsAreBeingDragged: false\n });\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if (pointerDownState.drag.hasOccurred && ((_b = (_a = pointerDownState.hit) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.id)) {\n const element = elementsMap.get(pointerDownState.hit.element.id);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindableElement)(element)) {\n // Renormalize elbow arrows when they are changed via indirect move\n (_c = element.boundElements) === null || _c === void 0 ? void 0 : _c.filter(e => e.type === \"arrow\").map(e => elementsMap.get(e.id)).filter(e => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(e)).forEach(e => {\n !!e && this.scene.mutateElement(e, {});\n });\n }\n } // Handle end of dragging a point of a linear element, might close a loop\n // and sets binding element\n\n\n if ((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing) {\n if (!pointerDownState.boxSelection.hasOccurred && ((_f = (_e = pointerDownState.hit) === null || _e === void 0 ? void 0 : _e.element) === null || _f === void 0 ? void 0 : _f.id) !== this.state.selectedLinearElement.elementId) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n } else {\n const editingLinearElement = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerUp(childEvent, this.state.selectedLinearElement, this.state, this.scene);\n\n if (editingLinearElement !== this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: editingLinearElement,\n suggestedBindings: []\n });\n }\n }\n } else if (this.state.selectedLinearElement) {\n // Normalize elbow arrow points, remove close parallel segments\n if (this.state.selectedLinearElement.elbowed) {\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(this.state.selectedLinearElement.elementId, this.scene.getNonDeletedElementsMap());\n\n if (element) {\n this.scene.mutateElement(element, {});\n }\n }\n\n if (((_h = (_g = pointerDownState.hit) === null || _g === void 0 ? void 0 : _g.element) === null || _h === void 0 ? void 0 : _h.id) !== this.state.selectedLinearElement.elementId) {\n const selectedELements = this.scene.getSelectedElements(this.state); // set selectedLinearElement to null if there is more than one element selected since we don't want to show linear element handles\n\n if (selectedELements.length > 1) {\n this.setState({\n selectedLinearElement: null\n });\n }\n } else if (this.state.selectedLinearElement.isDragging) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: childEvent,\n sceneCoords\n });\n }\n }\n\n this.missingPointerEventCleanupEmitter.clear();\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, pointerDownState.eventListeners.onMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, pointerDownState.eventListeners.onUp);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, pointerDownState.eventListeners.onKeyDown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYUP, pointerDownState.eventListeners.onKeyUp);\n (_k = (_j = this.props) === null || _j === void 0 ? void 0 : _j.onPointerUp) === null || _k === void 0 ? void 0 : _k.call(_j, activeTool, pointerDownState);\n this.onPointerUpEmitter.trigger(this.state.activeTool, pointerDownState, childEvent);\n\n if ((newElement === null || newElement === void 0 ? void 0 : newElement.type) === \"freedraw\") {\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(childEvent, this.state);\n const points = newElement.points;\n let dx = pointerCoords.x - newElement.x;\n let dy = pointerCoords.y - newElement.y; // Allows dots to avoid being flagged as infinitely small\n\n if (dx === points[0][0] && dy === points[0][1]) {\n dy += 0.0001;\n dx += 0.0001;\n }\n\n const pressures = newElement.simulatePressure ? [] : [...newElement.pressures, childEvent.pressure];\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)],\n pressures,\n lastCommittedPoint: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newElement)) {\n if (newElement.points.length > 1) {\n this.store.scheduleCapture();\n }\n\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(childEvent, this.state);\n const dragDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerCoords.x, pointerCoords.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y)) * this.state.zoom.value;\n\n if ((!pointerDownState.drag.hasOccurred || dragDistance < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MINIMUM_ARROW_SIZE) && newElement && !multiElement) {\n if (this.device.isTouchScreen && newElement.points.length > 1) {\n //zsviczian\n const FIXED_DELTA_X = Math.min(this.state.width * 0.7 / this.state.zoom.value, 100);\n this.scene.mutateElement(newElement, {\n x: newElement.x - FIXED_DELTA_X / 2,\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(FIXED_DELTA_X, 0)]\n }, {\n informMutation: false,\n isDragging: false\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n } else {\n const dx = pointerCoords.x - newElement.x;\n const dy = pointerCoords.y - newElement.y;\n this.scene.mutateElement(newElement, {\n points: [...newElement.points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n informMutation: false,\n isDragging: false\n });\n this.setState({\n multiElement: newElement,\n newElement\n });\n }\n } else if (pointerDownState.drag.hasOccurred && !multiElement) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(newElement, false)) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: childEvent,\n sceneCoords\n });\n }\n\n this.setState({\n suggestedBindings: [],\n startBoundElement: null\n });\n\n if (!activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n this.setState(prevState => ({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.defaultSelectionTool\n }),\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n selectedLinearElement: new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(newElement, this.scene.getNonDeletedElementsMap())\n }));\n } else {\n this.setState(prevState => ({\n newElement: null\n }));\n } // so that the scene gets rendered again to display the newly drawn linear as well\n\n\n this.scene.triggerUpdate();\n }\n\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(newElement)) {\n const minWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getMinTextElementWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFontString)({\n fontSize: newElement.fontSize,\n fontFamily: newElement.fontFamily\n }), newElement.lineHeight);\n\n if (newElement.width < minWidth) {\n this.scene.mutateElement(newElement, {\n autoResize: true\n });\n }\n\n this.resetCursor();\n this.handleTextWysiwyg(newElement, {\n isExistingElement: true\n });\n }\n\n if (activeTool.type !== \"selection\" && newElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInvisiblySmallElement)(newElement)) {\n // remove invisible element which was added in onPointerDown\n // update the store snapshot, so that invisible elements are not captured by the store\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== newElement.id),\n appState: {\n newElement: null\n },\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER\n });\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(newElement)) {\n const elementsInsideFrame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInNewFrame)(this.scene.getElementsIncludingDeleted(), newElement, this.scene.getNonDeletedElementsMap());\n this.scene.replaceAllElements((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(this.scene.getElementsMapIncludingDeleted(), elementsInsideFrame, newElement, this.state));\n }\n\n if (newElement) {\n this.scene.mutateElement(newElement, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getNormalizedDimensions)(newElement), {\n informMutation: false,\n isDragging: false\n }); // the above does not guarantee the scene to be rendered again, hence the trigger below\n\n this.scene.triggerUpdate();\n }\n\n if (pointerDownState.drag.hasOccurred) {\n const sceneCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(childEvent, this.state); // when editing the points of a linear element, we check if the\n // linear element still is in the frame afterwards\n // if not, the linear element will be removed from its frame (if any)\n\n if (this.state.selectedLinearElement && this.state.selectedLinearElement.isDragging) {\n const linearElement = this.scene.getElement(this.state.selectedLinearElement.elementId);\n\n if (linearElement === null || linearElement === void 0 ? void 0 : linearElement.frameId) {\n const frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainingFrame)(linearElement, elementsMap);\n\n if (frame && linearElement) {\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.elementOverlapsWithFrame)(linearElement, frame, this.scene.getNonDeletedElementsMap())) {\n // remove the linear element from all groups\n // before removing it from the frame as well\n this.scene.mutateElement(linearElement, {\n groupIds: []\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.removeElementsFromFrame)([linearElement], this.scene.getNonDeletedElementsMap());\n this.scene.triggerUpdate();\n }\n }\n }\n } else {\n // update the relationships between selected elements and frames\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords(sceneCoords);\n const selectedElements = this.scene.getSelectedElements(this.state);\n let nextElements = this.scene.getElementsMapIncludingDeleted();\n\n const updateGroupIdsAfterEditingGroup = elements => {\n if (elements.length > 0) {\n for (const element of elements) {\n const index = element.groupIds.indexOf(this.state.editingGroupId);\n this.scene.mutateElement(element, {\n groupIds: element.groupIds.slice(0, index)\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n\n nextElements.forEach(element => {\n if (element.groupIds.length && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(nextElements, element.groupIds[element.groupIds.length - 1]).length < 2) {\n this.scene.mutateElement(element, {\n groupIds: []\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n });\n this.setState({\n editingGroupId: null\n });\n }\n };\n\n if (topLayerFrame && !this.state.selectedElementIds[topLayerFrame.id]) {\n const elementsToAdd = selectedElements.filter(element => element.frameId !== topLayerFrame.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInFrame)(element, nextElements, this.state));\n\n if (this.state.editingGroupId) {\n updateGroupIdsAfterEditingGroup(elementsToAdd);\n }\n\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(nextElements, elementsToAdd, topLayerFrame, this.state);\n } else if (!topLayerFrame) {\n if (this.state.editingGroupId) {\n const elementsToRemove = selectedElements.filter(element => element.frameId && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInFrame)(element, nextElements, this.state));\n updateGroupIdsAfterEditingGroup(elementsToRemove);\n }\n }\n\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateFrameMembershipOfSelectedElements)(nextElements, this.state, this);\n this.scene.replaceAllElements(nextElements);\n }\n }\n\n if (resizingElement) {\n this.store.scheduleCapture();\n }\n\n if (resizingElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInvisiblySmallElement)(resizingElement)) {\n // update the store snapshot, so that invisible elements are not captured by the store\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== resizingElement.id),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER\n });\n } // handle frame membership for resizing frames and/or selected elements\n\n\n if (pointerDownState.resize.isResizing) {\n let nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateFrameMembershipOfSelectedElements)(this.scene.getElementsIncludingDeleted(), this.state, this);\n const selectedFrames = this.scene.getSelectedElements(this.state).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element));\n\n for (const frame of selectedFrames) {\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.replaceAllElementsInFrame)(nextElements, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInResizingFrame)(this.scene.getElementsIncludingDeleted(), frame, this.state, elementsMap), frame, this);\n }\n\n this.scene.replaceAllElements(nextElements);\n } // Code below handles selection when element(s) weren't\n // drag or added to selection on pointer down phase.\n\n\n const hitElement = pointerDownState.hit.element;\n\n if (((_l = this.state.selectedLinearElement) === null || _l === void 0 ? void 0 : _l.elementId) !== (hitElement === null || hitElement === void 0 ? void 0 : hitElement.id) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(hitElement)) {\n const selectedElements = this.scene.getSelectedElements(this.state); // set selectedLinearElement when no other element selected except\n // the one we've hit\n\n if (selectedElements.length === 1) {\n this.setState({\n selectedLinearElement: new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(hitElement, this.scene.getNonDeletedElementsMap())\n });\n }\n } // click outside the cropping region to exit\n\n\n if ( // not in the cropping mode at all\n !croppingElementId || // in the cropping mode\n croppingElementId && ( // not cropping and no hit element\n !hitElement && !isCropping || // hitting something else\n hitElement && hitElement.id !== croppingElementId)) {\n this.finishImageCropping();\n }\n\n const pointerStart = this.lastPointerDownEvent;\n const pointerEnd = this.lastPointerUpEvent || this.lastPointerMoveEvent;\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state) && pointerStart && pointerEnd) {\n this.eraserTrail.endPath();\n const draggedDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerStart.clientX, pointerStart.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerEnd.clientX, pointerEnd.clientY));\n\n if (draggedDistance === 0) {\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: pointerEnd.clientX,\n clientY: pointerEnd.clientY\n }, this.state);\n const hitElements = this.getElementsAtPosition(scenePointer.x, scenePointer.y);\n hitElements.forEach(hitElement => this.elementsPendingErasure.add(hitElement.id));\n }\n\n this.eraseElements();\n return;\n } else if (this.elementsPendingErasure.size) {\n this.restoreReadyToEraseElements();\n }\n\n if (hitElement && !pointerDownState.drag.hasOccurred && !pointerDownState.hit.wasAddedToSelection && ( // if we're editing a line, pointerup shouldn't switch selection if\n // box selected\n !((_m = this.state.selectedLinearElement) === null || _m === void 0 ? void 0 : _m.isEditing) || !pointerDownState.boxSelection.hasOccurred) && // hitElement can be set when alt + ctrl to toggle lasso and we will\n // just respect the selected elements from lasso instead\n this.state.activeTool.type !== \"lasso\") {\n // when inside line editor, shift selects points instead\n if (childEvent.shiftKey && !((_o = this.state.selectedLinearElement) === null || _o === void 0 ? void 0 : _o.isEditing)) {\n if (this.state.selectedElementIds[hitElement.id]) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isSelectedViaGroup)(this.state, hitElement)) {\n this.setState(_prevState => {\n const nextSelectedElementIds = Object.assign({}, _prevState.selectedElementIds); // We want to unselect all groups hitElement is part of\n // as well as all elements that are part of the groups\n // hitElement is part of\n\n for (const groupedElement of hitElement.groupIds.flatMap(groupId => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), groupId))) {\n delete nextSelectedElementIds[groupedElement.id];\n }\n\n return {\n selectedGroupIds: Object.assign(Object.assign({}, _prevState.selectedElementIds), hitElement.groupIds.map(gId => ({\n [gId]: false\n })).reduce((prev, acc) => Object.assign(Object.assign({}, prev), acc), {})),\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextSelectedElementIds, _prevState)\n };\n }); // if not dragging a linear element point (outside editor)\n } else if (!((_p = this.state.selectedLinearElement) === null || _p === void 0 ? void 0 : _p.isDragging)) {\n // remove element from selection while\n // keeping prev elements selected\n this.setState(prevState => {\n const newSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete newSelectedElementIds[hitElement.id];\n const newSelectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getSelectedElements)(this.scene.getNonDeletedElements(), {\n selectedElementIds: newSelectedElementIds\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: newSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n // set selectedLinearElement only if thats the only element selected\n selectedLinearElement: newSelectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newSelectedElements[0]) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(newSelectedElements[0], this.scene.getNonDeletedElementsMap()) : prevState.selectedLinearElement\n });\n });\n }\n } else if (hitElement.frameId && this.state.selectedElementIds[hitElement.frameId]) {\n // when hitElement is part of a selected frame, deselect the frame\n // to avoid frame and containing elements selected simultaneously\n this.setState(prevState => {\n var _a, _b;\n\n const nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [hitElement.id]: true\n }); // deselect the frame\n\n delete nextSelectedElementIds[hitElement.frameId]; // deselect groups containing the frame\n\n ((_b = (_a = this.scene.getElement(hitElement.frameId)) === null || _a === void 0 ? void 0 : _a.groupIds) !== null && _b !== void 0 ? _b : []).flatMap(gid => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n } else {\n // add element to selection while keeping prev elements selected\n this.setState(_prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, _prevState.selectedElementIds), {\n [hitElement.id]: true\n }), _prevState)\n }));\n }\n } else {\n this.setState(prevState => {\n var _a;\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n selectedLinearElement: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(hitElement) && // Don't set `selectedLinearElement` if its same as the hitElement, this is mainly to prevent resetting the `hoverPointIndex` to -1.\n // Future we should update the API to take care of setting the correct `hoverPointIndex` when initialized\n ((_a = prevState.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.elementId) !== hitElement.id ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(hitElement, this.scene.getNonDeletedElementsMap()) : prevState.selectedLinearElement\n });\n });\n }\n }\n\n if ( // do not clear selection if lasso is active\n this.state.activeTool.type !== \"lasso\" && // not elbow midpoint dragged\n !(hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(hitElement)) && // not dragged\n !pointerDownState.drag.hasOccurred && // not resized\n !this.state.isResizing && ( // only hitting the bounding box of the previous hit element\n hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundingBoxOnly)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y),\n element: hitElement,\n elementsMap,\n threshold: this.getElementHitThreshold(hitElement),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement) ? this.frameNameBoundsCache.get(hitElement) : null\n }, elementsMap) || !hitElement && pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements)) {\n if ((_q = this.state.selectedLinearElement) === null || _q === void 0 ? void 0 : _q.isEditing) {\n // Exit editing mode but keep the element selected\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n } else {\n // Deselect selected elements\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n } // reset cursor\n\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n return;\n }\n\n if (!activeTool.locked && activeTool.type !== \"freedraw\" && newElement) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n showHyperlinkPopup: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(newElement) && !newElement.link ? \"editor\" : prevState.showHyperlinkPopup\n }));\n }\n\n if (activeTool.type !== \"selection\" || (0,_scene__WEBPACK_IMPORTED_MODULE_31__.isSomeElementSelected)(this.scene.getNonDeletedElements(), this.state) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isShallowEqual)(this.state.previousSelectedElementIds, this.state.selectedElementIds)) {\n this.store.scheduleCapture();\n }\n\n if (pointerDownState.drag.hasOccurred && !this.state.selectedLinearElement || isResizing || isRotating || isCropping) {\n // We only allow binding via linear elements, specifically via dragging\n // the endpoints (\"start\" or \"end\").\n const linearElements = this.scene.getSelectedElements(this.state).filter(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.bindOrUnbindLinearElements)(linearElements, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state), (_s = (_r = this.state.selectedLinearElement) === null || _r === void 0 ? void 0 : _r.selectedPointsIndices) !== null && _s !== void 0 ? _s : [], this.scene, this.state.zoom);\n }\n\n if (activeTool.type === \"laser\") {\n this.laserTrails.endPath();\n return;\n }\n\n if (!activeTool.locked && activeTool.type !== \"freedraw\" && (activeTool.type !== \"lasso\" || // if lasso is turned on but from selection => reset to selection\n activeTool.type === \"lasso\" && activeTool.fromSelection)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n this.setState({\n newElement: null,\n suggestedBindings: [],\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.defaultSelectionTool\n })\n });\n } else {\n this.setState({\n newElement: null,\n suggestedBindings: []\n });\n }\n\n if (hitElement && this.lastPointerUpEvent && this.lastPointerDownEvent && this.lastPointerUpEvent.timeStamp - this.lastPointerDownEvent.timeStamp < 300 && gesture.pointers.size <= 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, this.lastPointerUpEvent, pointerDownState.origin.x, pointerDownState.origin.y)) {\n this.handleEmbeddableCenterClick(hitElement);\n }\n });\n } //zsviczian - published on API\n\n\n setSelection(elements) {\n const selectedElementIds = {};\n const selectedGroupIds = {};\n elements.forEach(ele => {\n if (ele.groupIds.length) {\n selectedElementIds[ele.id] = true;\n ele.groupIds.forEach(id => {\n selectedGroupIds[id] = true;\n });\n } // exclude bound text elements as we don't mark them as selected when\n // container is selected unless in group\n else if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(ele)) {\n selectedElementIds[ele.id] = true;\n }\n });\n this.setState({\n previousSelectedElementIds: this.state.selectedElementIds,\n selectedElementIds,\n selectedGroupIds\n });\n }\n\n clearSelection(hitElement) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n activeEmbeddable: null,\n selectedGroupIds: {},\n // Continue editing the same group if the user selected a different\n // element from it\n editingGroupId: prevState.editingGroupId && hitElement != null && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInGroup)(hitElement, prevState.editingGroupId) ? prevState.editingGroupId : null\n }));\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null,\n previousSelectedElementIds: this.state.selectedElementIds\n });\n }\n\n getTextWysiwygSnappedToCenterPosition(x, y, appState, container) {\n if (container) {\n let elementCenterX = container.x + container.width / 2;\n let elementCenterY = container.y + container.height / 2;\n const elementCenter = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerCenter)(container, appState, this.scene.getNonDeletedElementsMap());\n\n if (elementCenter) {\n elementCenterX = elementCenter.x;\n elementCenterY = elementCenter.y;\n }\n\n const distanceToCenter = Math.hypot(x - elementCenterX, y - elementCenterY);\n const isSnappedToCenter = distanceToCenter < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TEXT_TO_CENTER_SNAP_THRESHOLD;\n\n if (isSnappedToCenter) {\n const {\n x: viewportX,\n y: viewportY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.sceneCoordsToViewportCoords)({\n sceneX: elementCenterX,\n sceneY: elementCenterY\n }, appState);\n return {\n viewportX,\n viewportY,\n elementCenterX,\n elementCenterY\n };\n }\n }\n }\n\n getCanvasOffsets() {\n var _a;\n\n if ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) {\n const excalidrawContainer = this.excalidrawContainerRef.current;\n const {\n left,\n top\n } = excalidrawContainer.getBoundingClientRect();\n return {\n offsetLeft: left,\n offsetTop: top\n };\n }\n\n return {\n offsetLeft: 0,\n offsetTop: 0\n };\n }\n\n async updateLanguage() {\n const currentLang = _i18n__WEBPACK_IMPORTED_MODULE_30__.languages.find(lang => lang.code === this.props.langCode) || _i18n__WEBPACK_IMPORTED_MODULE_30__.defaultLang;\n await (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.setLanguage)(currentLang);\n this.setAppState({});\n }\n\n} // -----------------------------------------------------------------------------\n// TEST HOOKS\n// -----------------------------------------------------------------------------\n\n/* //zsviczian - I get a type error on h, but anyway I don't need this test hook\r\ndeclare global {\r\n interface Window {\r\n h: {\r\n scene: Scene;\r\n elements: readonly ExcalidrawElement[];\r\n state: AppState;\r\n setState: React.Component<any, AppState>[\"setState\"];\r\n app: InstanceType<typeof App>;\r\n history: History;\r\n store: Store;\r\n };\r\n }\r\n}\r\n\r\nexport const createTestHook = () => {\r\n if (isTestEnv() || isDevEnv()) {\r\n window.h = window.h || ({} as Window[\"h\"]);\r\n\r\n Object.defineProperties(window.h, {\r\n elements: {\r\n configurable: true,\r\n get() {\r\n return this.app?.scene.getElementsIncludingDeleted();\r\n },\r\n set(elements: ExcalidrawElement[]) {\r\n return this.app?.scene.replaceAllElements(\r\n syncInvalidIndices(elements),\r\n );\r\n },\r\n },\r\n scene: {\r\n configurable: true,\r\n get() {\r\n return this.app?.scene;\r\n },\r\n },\r\n });\r\n }\r\n};\r\n\r\ncreateTestHook();*/\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (App);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/App.tsx?");
14282
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExcalidrawContainerContext: () => (/* binding */ ExcalidrawContainerContext),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ useApp: () => (/* binding */ useApp),\n/* harmony export */ useAppProps: () => (/* binding */ useAppProps),\n/* harmony export */ useDevice: () => (/* binding */ useDevice),\n/* harmony export */ useExcalidrawActionManager: () => (/* binding */ useExcalidrawActionManager),\n/* harmony export */ useExcalidrawAppState: () => (/* binding */ useExcalidrawAppState),\n/* harmony export */ useExcalidrawContainer: () => (/* binding */ useExcalidrawContainer),\n/* harmony export */ useExcalidrawElements: () => (/* binding */ useExcalidrawElements),\n/* harmony export */ useExcalidrawSetAppState: () => (/* binding */ useExcalidrawSetAppState)\n/* harmony export */ });\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var lodash_throttle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash.throttle */ \"../../node_modules/lodash.throttle/index.js\");\n/* harmony import */ var lodash_throttle__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_throttle__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-dom */ \"react-dom\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! roughjs/bin/rough */ \"../../node_modules/roughjs/bin/rough.js\");\n/* harmony import */ var nanoid__WEBPACK_IMPORTED_MODULE_72__ = __webpack_require__(/*! nanoid */ \"./node_modules/nanoid/index.browser.js\");\n/* harmony import */ var _excalidraw_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @excalidraw/math */ \"../math/src/index.ts\");\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../actions/actionBoundText */ \"./actions/actionBoundText.tsx\");\n/* harmony import */ var _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../actions/actionCanvas */ \"./actions/actionCanvas.tsx\");\n/* harmony import */ var _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../actions/actionClipboard */ \"./actions/actionClipboard.tsx\");\n/* harmony import */ var _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../actions/actionElementLink */ \"./actions/actionElementLink.ts\");\n/* harmony import */ var _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../actions/actionElementLock */ \"./actions/actionElementLock.ts\");\n/* harmony import */ var _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../actions/actionFrame */ \"./actions/actionFrame.ts\");\n/* harmony import */ var _actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../actions/actionHistory */ \"./actions/actionHistory.tsx\");\n/* harmony import */ var _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../actions/actionTextAutoResize */ \"./actions/actionTextAutoResize.ts\");\n/* harmony import */ var _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../actions/actionToggleViewMode */ \"./actions/actionToggleViewMode.tsx\");\n/* harmony import */ var _actions_manager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../actions/manager */ \"./actions/manager.tsx\");\n/* harmony import */ var _actions_register__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../actions/register */ \"./actions/register.ts\");\n/* harmony import */ var _actions_shortcuts__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../actions/shortcuts */ \"./actions/shortcuts.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _animation_frame_handler__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../animation-frame-handler */ \"./animation-frame-handler.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _clipboard__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../clipboard */ \"./clipboard.ts\");\n/* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../data */ \"./data/index.ts\");\n/* harmony import */ var _data_library__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../data/library */ \"./data/library.ts\");\n/* harmony import */ var _data_restore__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../data/restore */ \"./data/restore.ts\");\n/* harmony import */ var _gesture__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../gesture */ \"./gesture.ts\");\n/* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ../history */ \"./history.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _scene_zoom__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ../scene/zoom */ \"./scene/zoom.ts\");\n/* harmony import */ var _data_blob__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ../data/blob */ \"./data/blob.ts\");\n/* harmony import */ var _data_filesystem__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ../data/filesystem */ \"./data/filesystem.ts\");\n/* harmony import */ var _components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ../components/hyperlink/Hyperlink */ \"./components/hyperlink/Hyperlink.tsx\");\n/* harmony import */ var _fonts__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ../fonts */ \"./fonts/index.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ../errors */ \"./errors.ts\");\n/* harmony import */ var _snapping__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ../snapping */ \"./snapping.ts\");\n/* harmony import */ var _data_transform__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ../data/transform */ \"./data/transform.ts\");\n/* harmony import */ var _scene_Renderer__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ../scene/Renderer */ \"./scene/Renderer.ts\");\n/* harmony import */ var _cursor__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ../cursor */ \"./cursor.ts\");\n/* harmony import */ var _components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ../components/ElementCanvasButtons */ \"./components/ElementCanvasButtons.tsx\");\n/* harmony import */ var _laser_trails__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ../laser-trails */ \"./laser-trails.ts\");\n/* harmony import */ var _reactUtils__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ../reactUtils */ \"./reactUtils.ts\");\n/* harmony import */ var _wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ../wysiwyg/textWysiwyg */ \"./wysiwyg/textWysiwyg.tsx\");\n/* harmony import */ var _scene_scrollbars__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ../scene/scrollbars */ \"./scene/scrollbars.ts\");\n/* harmony import */ var _mermaid__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ../mermaid */ \"./mermaid.ts\");\n/* harmony import */ var _lasso__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ../lasso */ \"./lasso/index.ts\");\n/* harmony import */ var _eraser__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(/*! ../eraser */ \"./eraser/index.ts\");\n/* harmony import */ var _ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(/*! ./ConvertElementTypePopup */ \"./components/ConvertElementTypePopup.tsx\");\n/* harmony import */ var _ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(/*! ./ActiveConfirmDialog */ \"./components/ActiveConfirmDialog.tsx\");\n/* harmony import */ var _BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(/*! ./BraveMeasureTextError */ \"./components/BraveMeasureTextError.tsx\");\n/* harmony import */ var _ContextMenu__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(/*! ./ContextMenu */ \"./components/ContextMenu.tsx\");\n/* harmony import */ var _EyeDropper__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(/*! ./EyeDropper */ \"./components/EyeDropper.tsx\");\n/* harmony import */ var _FollowMode_FollowMode__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(/*! ./FollowMode/FollowMode */ \"./components/FollowMode/FollowMode.tsx\");\n/* harmony import */ var _LayerUI__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(/*! ./LayerUI */ \"./components/LayerUI.tsx\");\n/* harmony import */ var _MagicButton__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(/*! ./MagicButton */ \"./components/MagicButton.tsx\");\n/* harmony import */ var _SVGLayer__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(/*! ./SVGLayer */ \"./components/SVGLayer.tsx\");\n/* harmony import */ var _SearchMenu__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(/*! ./SearchMenu */ \"./components/SearchMenu.tsx\");\n/* harmony import */ var _Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(/*! ./Sidebar/Sidebar */ \"./components/Sidebar/Sidebar.tsx\");\n/* harmony import */ var _canvases__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(/*! ./canvases */ \"./components/canvases/index.tsx\");\n/* harmony import */ var _canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(/*! ./canvases/NewElementCanvas */ \"./components/canvases/NewElementCanvas.tsx\");\n/* harmony import */ var _hyperlink_helpers__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(/*! ./hyperlink/helpers */ \"./components/hyperlink/helpers.ts\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _Toast__WEBPACK_IMPORTED_MODULE_66__ = __webpack_require__(/*! ./Toast */ \"./components/Toast.tsx\");\n/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_67__ = __webpack_require__(/*! ./shapes */ \"./components/shapes.tsx\");\n/* harmony import */ var _UnlockPopup__WEBPACK_IMPORTED_MODULE_68__ = __webpack_require__(/*! ./UnlockPopup */ \"./components/UnlockPopup.tsx\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_69__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _Tooltip__WEBPACK_IMPORTED_MODULE_70__ = __webpack_require__(/*! ./Tooltip */ \"./components/Tooltip.tsx\");\n/* harmony import */ var _actions_actionProperties__WEBPACK_IMPORTED_MODULE_71__ = __webpack_require__(/*! ../actions/actionProperties */ \"./actions/actionProperties.tsx\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst AppContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst AppPropsContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nconst deviceContextInitialValue = {\n viewport: {\n isMobile: false,\n isLandscape: false\n },\n editor: {\n isMobile: false,\n canFitSidebar: false\n },\n isTouchScreen: false\n};\nconst DeviceContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(deviceContextInitialValue);\nDeviceContext.displayName = \"DeviceContext\";\nconst ExcalidrawContainerContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext({\n container: null,\n id: null\n});\nExcalidrawContainerContext.displayName = \"ExcalidrawContainerContext\";\nconst ExcalidrawElementsContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext([]);\nExcalidrawElementsContext.displayName = \"ExcalidrawElementsContext\";\nconst ExcalidrawAppStateContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_23__.getDefaultAppState)()), {\n width: 0,\n height: 0,\n offsetLeft: 0,\n offsetTop: 0\n}));\nExcalidrawAppStateContext.displayName = \"ExcalidrawAppStateContext\";\nconst ExcalidrawSetAppStateContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(() => {\n console.warn(\"Uninitialized ExcalidrawSetAppStateContext context!\");\n});\nExcalidrawSetAppStateContext.displayName = \"ExcalidrawSetAppStateContext\";\nconst ExcalidrawActionManagerContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createContext(null);\nExcalidrawActionManagerContext.displayName = \"ExcalidrawActionManagerContext\";\nconst useApp = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppContext);\nconst useAppProps = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(AppPropsContext);\nconst useDevice = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(DeviceContext);\nconst useExcalidrawContainer = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawContainerContext);\nconst useExcalidrawElements = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawElementsContext);\nconst useExcalidrawAppState = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawAppStateContext);\nconst useExcalidrawSetAppState = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawSetAppStateContext);\nconst useExcalidrawActionManager = () => (0,react__WEBPACK_IMPORTED_MODULE_2__.useContext)(ExcalidrawActionManagerContext);\nlet didTapTwice = false;\nlet tappedTwiceTimer = 0;\nlet firstTapPosition = null;\nlet isHoldingSpace = false;\nlet isPanning = false;\nlet isDraggingScrollBar = false;\nlet currentScrollBars = {\n horizontal: null,\n vertical: null\n};\nlet touchTimeout = 0;\nlet invalidateContextMenu = false;\n/**\r\n * Map of youtube embed video states\r\n */\n\nconst YOUTUBE_VIDEO_STATES = new Map();\nlet IS_PLAIN_PASTE = false;\nlet IS_PLAIN_PASTE_TIMER = 0;\nlet PLAIN_PASTE_TOAST_SHOWN = false;\nlet lastPointerUp = null;\nconst gesture = {\n pointers: new Map(),\n lastCenter: null,\n initialDistance: null,\n initialScale: null\n};\n\nclass App extends (react__WEBPACK_IMPORTED_MODULE_2___default().Component) {\n constructor(props) {\n super(props);\n this.interactiveCanvas = null;\n this.unmounted = false;\n this.device = deviceContextInitialValue;\n this.excalidrawContainerRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createRef();\n this.shouldRenderAllEmbeddables = false; //zsviczian\n\n this.files = {};\n this.imageCache = new Map();\n this.iFrameRefs = new Map();\n /**\r\n * Indicates whether the embeddable's url has been validated for rendering.\r\n * If value not set, indicates that the validation is pending.\r\n * Initially or on url change the flag is not reset so that we can guarantee\r\n * the validation came from a trusted source (the editor).\r\n **/\n\n this.embedsValidationStatus = new Map();\n /** embeds that have been inserted to DOM (as a perf optim, we don't want to\r\n * insert to DOM before user initially scrolls to them) */\n\n this.initializedEmbeds = new Set();\n\n this.handleToastClose = () => {\n this.setToast(null);\n };\n\n this.elementsPendingErasure = new Set();\n this.flowChartCreator = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.FlowChartCreator();\n this.flowChartNavigator = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.FlowChartNavigator();\n this.lastPointerDownEvent = null;\n this.lastPointerUpEvent = null;\n this.lastPointerMoveEvent = null;\n this.lastPointerMoveCoords = null;\n this.lastViewportPosition = {\n x: 0,\n y: 0\n };\n this.allowMobileMode = true; //zsviczian\n\n this.animationFrameHandler = new _animation_frame_handler__WEBPACK_IMPORTED_MODULE_22__.AnimationFrameHandler();\n this.laserTrails = new _laser_trails__WEBPACK_IMPORTED_MODULE_44__.LaserTrails(this.animationFrameHandler, this);\n this.eraserTrail = new _eraser__WEBPACK_IMPORTED_MODULE_50__.EraserTrail(this.animationFrameHandler, this);\n this.lassoTrail = new _lasso__WEBPACK_IMPORTED_MODULE_49__.LassoTrail(this.animationFrameHandler, this);\n this.onChangeEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onPointerDownEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onPointerUpEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onUserFollowEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onScrollChangeEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.missingPointerEventCleanupEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.onRemoveEventListenersEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.Emitter();\n this.defaultSelectionTool = \"selection\";\n\n this.updateEditorAtom = (atom, ...args) => {\n const result = _editor_jotai__WEBPACK_IMPORTED_MODULE_37__.editorJotaiStore.set(atom, ...args);\n this.triggerRender();\n return result;\n };\n /**\r\n * Returns gridSize taking into account `gridModeEnabled`.\r\n * If disabled, returns null.\r\n */\n\n\n this.getEffectiveGridSize = () => {\n return (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.isGridModeEnabled)(this) ? this.state.gridSize : null;\n };\n\n this.updateEmbedValidationStatus = (element, status) => {\n this.embedsValidationStatus.set(element.id, status);\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element);\n };\n\n this.updateEmbeddables = () => {\n const iframeLikes = new Set();\n let updated = false;\n this.scene.getNonDeletedElements().filter(element => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(element)) {\n iframeLikes.add(element.id);\n\n if (!this.embedsValidationStatus.has(element.id)) {\n updated = true;\n const validated = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(element.link, this.props.validateEmbeddable);\n this.updateEmbedValidationStatus(element, validated);\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(element)) {\n iframeLikes.add(element.id);\n }\n\n return false;\n });\n\n if (updated) {\n this.scene.triggerUpdate();\n } // GC\n\n\n this.iFrameRefs.forEach((ref, id) => {\n if (!iframeLikes.has(id)) {\n this.iFrameRefs.delete(id);\n }\n });\n };\n\n this.getFrameNameDOMId = frameElement => {\n return `${this.id}-frame-name-${frameElement.id}`;\n };\n\n this.frameNameBoundsCache = {\n get: frameElement => {\n let bounds = this.frameNameBoundsCache._cache.get(frameElement.id);\n\n if (!bounds || bounds.zoom !== this.state.zoom.value || bounds.versionNonce !== frameElement.versionNonce) {\n const frameNameDiv = document.getElementById(this.getFrameNameDOMId(frameElement));\n\n if (frameNameDiv) {\n const box = frameNameDiv.getBoundingClientRect();\n const boxSceneTopLeft = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: box.x,\n clientY: box.y\n }, this.state);\n const boxSceneBottomRight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: box.right,\n clientY: box.bottom\n }, this.state);\n bounds = {\n x: boxSceneTopLeft.x,\n y: boxSceneTopLeft.y,\n width: boxSceneBottomRight.x - boxSceneTopLeft.x,\n height: boxSceneBottomRight.y - boxSceneTopLeft.y,\n angle: 0,\n zoom: this.state.zoom.value,\n versionNonce: frameElement.versionNonce\n };\n\n this.frameNameBoundsCache._cache.set(frameElement.id, bounds);\n\n return bounds;\n }\n\n return null;\n }\n\n return bounds;\n },\n\n /**\r\n * @private\r\n */\n _cache: new Map()\n };\n\n this.resetEditingFrame = frame => {\n var _a;\n\n if (frame) {\n this.scene.mutateElement(frame, {\n name: ((_a = frame.name) === null || _a === void 0 ? void 0 : _a.trim()) || null\n });\n }\n\n this.setState({\n editingFrame: null\n });\n };\n\n this.renderFrameNames = () => {\n var _a;\n\n if (!this.state.frameRendering.enabled || !this.state.frameRendering.name) {\n if (this.state.editingFrame) {\n this.resetEditingFrame(null);\n }\n\n return null;\n }\n\n const isDarkTheme = this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK; //zsviczian\n\n const nonDeletedFramesLikes = this.state.frameRendering.markerName && this.state.frameRendering.markerEnabled ? this.scene.getNonDeletedFramesLikes() : this.scene.getNonDeletedFramesLikes().filter(f => f.frameRole !== \"marker\");\n const focusedSearchMatch = nonDeletedFramesLikes.length > 0 ? ((_a = this.state.searchMatches) === null || _a === void 0 ? void 0 : _a.focusedId) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(this.scene.getElement(this.state.searchMatches.focusedId)) ? this.state.searchMatches.matches.find(sm => sm.focus) : null : null;\n return nonDeletedFramesLikes.map(f => {\n var _a, _b;\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInViewport)(f, this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap())) {\n if (this.state.editingFrame === f.id) {\n this.resetEditingFrame(f);\n } // if frame not visible, don't render its name\n\n\n return null;\n }\n\n const {\n x: x1,\n y: y1\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.sceneCoordsToViewportCoords)({\n sceneX: f.x,\n sceneY: f.y\n }, this.state);\n const FRAME_NAME_EDIT_PADDING = 6;\n let frameNameJSX;\n const frameName = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getFrameLikeTitle)(f);\n\n if (f.id === this.state.editingFrame) {\n const frameNameInEdit = frameName;\n frameNameJSX = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"input\", {\n autoFocus: true,\n value: frameNameInEdit,\n onChange: e => {\n this.scene.mutateElement(f, {\n name: e.target.value\n });\n },\n onFocus: e => e.target.select(),\n onBlur: () => this.resetEditingFrame(f),\n onKeyDown: event => {\n // for some inexplicable reason, `onBlur` triggered on ESC\n // does not reset `state.editingFrame` despite being called,\n // and we need to reset it here as well\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) {\n this.resetEditingFrame(f);\n }\n },\n style: {\n background: this.state.viewBackgroundColor,\n filter: isDarkTheme ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME_FILTER : \"none\",\n zIndex: 2,\n border: \"none\",\n display: \"block\",\n padding: `${FRAME_NAME_EDIT_PADDING}px`,\n borderRadius: 4,\n boxShadow: \"inset 0 0 0 2px var(--color-on-primary-container)\",\n fontFamily: \"Assistant\",\n fontSize: `${_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameFontSize}px`,\n transform: `translate(-${FRAME_NAME_EDIT_PADDING}px, ${FRAME_NAME_EDIT_PADDING}px)`,\n color: \"var(--color-gray-80)\",\n overflow: \"hidden\",\n maxWidth: `${(0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.getExcalidrawContentEl)().clientWidth - x1 - FRAME_NAME_EDIT_PADDING //zsviczian was document.body\n }px`\n },\n size: frameNameInEdit.length + 1 || 1,\n dir: \"auto\",\n autoComplete: \"off\",\n autoCapitalize: \"off\",\n autoCorrect: \"off\"\n });\n } else {\n frameNameJSX = frameName;\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n id: this.getFrameNameDOMId(f),\n key: f.id,\n style: {\n position: \"absolute\",\n // Positioning from bottom so that we don't to either\n // calculate text height or adjust using transform (which)\n // messes up input position when editing the frame name.\n // This makes the positioning deterministic and we can calculate\n // the same position when rendering to canvas / svg.\n bottom: `${this.state.height + _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameOffsetY - y1 + this.state.offsetTop}px`,\n left: `${x1 - this.state.offsetLeft}px`,\n zIndex: 2,\n fontSize: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameFontSize,\n color: (_b = (_a = this.state.frameColor) === null || _a === void 0 ? void 0 : _a.nameColor) !== null && _b !== void 0 ? _b : isDarkTheme //zsviczian\n ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameColorDarkTheme : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameColorLightTheme,\n lineHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE.nameLineHeight,\n width: \"max-content\",\n maxWidth: (focusedSearchMatch === null || focusedSearchMatch === void 0 ? void 0 : focusedSearchMatch.id) === f.id && (focusedSearchMatch === null || focusedSearchMatch === void 0 ? void 0 : focusedSearchMatch.focus) ? \"none\" : `${f.width * this.state.zoom.value}px`,\n overflow: f.id === this.state.editingFrame ? \"visible\" : \"hidden\",\n whiteSpace: \"nowrap\",\n textOverflow: \"ellipsis\",\n cursor: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE,\n pointerEvents: this.state.viewModeEnabled ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.enabled\n },\n onPointerDown: event => this.handleCanvasPointerDown(event),\n onWheel: event => this.handleWheel(event),\n onContextMenu: this.handleCanvasContextMenu,\n onDoubleClick: () => {\n this.setState({\n editingFrame: f.id\n });\n }\n }, frameNameJSX);\n });\n };\n\n this.focusContainer = () => {\n var _a;\n\n (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.focus();\n };\n\n this.getSceneElementsIncludingDeleted = () => {\n return this.scene.getElementsIncludingDeleted();\n };\n\n this.getSceneElementsMapIncludingDeleted = () => {\n return this.scene.getElementsMapIncludingDeleted();\n };\n\n this.getSceneElements = () => {\n return this.scene.getNonDeletedElements();\n };\n\n this.onInsertElements = elements => {\n this.addElementsFromPasteOrLibrary({\n elements,\n position: \"center\",\n files: null\n });\n };\n\n this.onExportImage = async (type, elements, opts) => {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"export\", type, \"ui\");\n const fileHandle = await (0,_data__WEBPACK_IMPORTED_MODULE_25__.exportCanvas)(type, elements, this.state, this.files, {\n exportBackground: this.state.exportBackground,\n name: this.getName(),\n viewBackgroundColor: this.state.viewBackgroundColor,\n exportingFrame: opts.exportingFrame\n }).catch(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.muteFSAbortError).catch(error => {\n console.error(error);\n this.setState({\n errorMessage: error.message\n });\n });\n\n if (this.state.exportEmbedScene && fileHandle && (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.isImageFileHandle)(fileHandle)) {\n this.setState({\n fileHandle\n });\n }\n };\n\n this.magicGenerations = new Map();\n\n this.updateMagicGeneration = ({\n frameElement,\n data\n }) => {\n if (data.status === \"pending\") {\n // We don't wanna persist pending state to storage. It should be in-app\n // state only.\n // Thus reset so that we prefer local cache (if there was some\n // generationData set previously)\n this.scene.mutateElement(frameElement, {\n customData: {\n generationData: undefined\n }\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n this.scene.mutateElement(frameElement, {\n customData: {\n generationData: data\n }\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n\n this.magicGenerations.set(frameElement.id, data);\n this.triggerRender();\n };\n\n this.plugins = {};\n\n this.onMagicframeToolSelect = () => {\n const selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds\n });\n\n if (selectedElements.length === 0) {\n this.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"tool-select (empty-selection)\", \"d2c\");\n } else {\n const selectedMagicFrame = selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isMagicFrameElement)(selectedElements[0]) && selectedElements[0]; // case: user selected elements containing frame-like(s) or are frame\n // members, we don't want to wrap into another magicframe\n // (unless the only selected element is a magic frame which we reuse)\n\n if (!selectedMagicFrame && selectedElements.some(el => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(el) || el.frameId)) {\n this.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe\n });\n return;\n }\n\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"tool-select (existing selection)\", \"d2c\");\n let frame;\n\n if (selectedMagicFrame) {\n // a single magicframe already selected -> use it\n frame = selectedMagicFrame;\n } else {\n // selected elements aren't wrapped in magic frame yet -> wrap now\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n const padding = 50;\n frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newMagicFrameElement)(Object.assign(Object.assign({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE), {\n x: minX - padding,\n y: minY - padding,\n width: maxX - minX + padding * 2,\n height: maxY - minY + padding * 2,\n opacity: 100,\n locked: false\n }));\n this.scene.insertElement(frame);\n\n for (const child of selectedElements) {\n this.scene.mutateElement(child, {\n frameId: frame.id\n });\n }\n\n this.setState({\n selectedElementIds: {\n [frame.id]: true\n }\n });\n }\n\n this.onMagicFrameGenerate(frame, \"upstream\");\n }\n };\n\n this.openEyeDropper = ({\n type\n }) => {\n this.updateEditorAtom(_EyeDropper__WEBPACK_IMPORTED_MODULE_55__.activeEyeDropperAtom, {\n swapPreviewOnAlt: true,\n colorPickerType: type === \"stroke\" ? \"elementStroke\" : \"elementBackground\",\n onSelect: (color, event) => {\n const shouldUpdateStrokeColor = type === \"background\" && event.altKey || type === \"stroke\" && !event.altKey;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (!selectedElements.length || this.state.activeTool.type !== \"selection\") {\n if (shouldUpdateStrokeColor) {\n this.syncActionResult({\n appState: Object.assign(Object.assign({}, this.state), {\n currentItemStrokeColor: color\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n } else {\n this.syncActionResult({\n appState: Object.assign(Object.assign({}, this.state), {\n currentItemBackgroundColor: color\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n } else {\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().map(el => {\n if (this.state.selectedElementIds[el.id]) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(el, {\n [shouldUpdateStrokeColor ? \"strokeColor\" : \"backgroundColor\"]: color\n });\n }\n\n return el;\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n },\n keepOpenOnAlt: false\n });\n };\n\n this.dismissLinearEditor = () => {\n setTimeout(() => {\n var _a;\n\n if ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n isEditing: false\n })\n });\n }\n });\n };\n\n this.syncActionResult = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(actionResult => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n\n if (this.unmounted || actionResult === false) {\n return;\n }\n\n this.store.scheduleAction(actionResult.captureUpdate);\n let didUpdate = false;\n let editingTextElement = null;\n\n if (actionResult.elements) {\n this.scene.replaceAllElements(actionResult.elements);\n didUpdate = true;\n }\n\n if (actionResult.files) {\n this.addMissingFiles(actionResult.files, actionResult.replaceFiles);\n this.addNewImagesToImageCache();\n }\n\n if (actionResult.appState || editingTextElement || this.state.contextMenu) {\n let viewModeEnabled = ((_a = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _a === void 0 ? void 0 : _a.viewModeEnabled) || false;\n let zenModeEnabled = ((_b = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _b === void 0 ? void 0 : _b.zenModeEnabled) || false;\n const theme = ((_c = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _c === void 0 ? void 0 : _c.theme) || this.props.theme || _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.LIGHT;\n const name = (_e = (_d = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : this.state.name;\n const errorMessage = (_g = (_f = actionResult === null || actionResult === void 0 ? void 0 : actionResult.appState) === null || _f === void 0 ? void 0 : _f.errorMessage) !== null && _g !== void 0 ? _g : this.state.errorMessage;\n\n if (typeof this.props.viewModeEnabled !== \"undefined\") {\n viewModeEnabled = this.props.viewModeEnabled;\n }\n\n if (typeof this.props.zenModeEnabled !== \"undefined\") {\n zenModeEnabled = this.props.zenModeEnabled;\n }\n\n editingTextElement = ((_h = actionResult.appState) === null || _h === void 0 ? void 0 : _h.editingTextElement) || null; // make sure editingTextElement points to latest element reference\n\n if (actionResult.elements && editingTextElement) {\n actionResult.elements.forEach(element => {\n if ((editingTextElement === null || editingTextElement === void 0 ? void 0 : editingTextElement.id) === element.id && editingTextElement !== element && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isNonDeletedElement)(element) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element)) {\n editingTextElement = element;\n }\n });\n }\n\n if (editingTextElement === null || editingTextElement === void 0 ? void 0 : editingTextElement.isDeleted) {\n editingTextElement = null;\n }\n\n this.setState(prevAppState => {\n const actionAppState = actionResult.appState || {};\n return Object.assign(Object.assign(Object.assign({}, prevAppState), actionAppState), {\n // NOTE this will prevent opening context menu using an action\n // or programmatically from the host, so it will need to be\n // rewritten later\n contextMenu: null,\n editingTextElement,\n viewModeEnabled,\n zenModeEnabled,\n theme,\n name,\n errorMessage\n });\n });\n didUpdate = true;\n }\n\n if (!didUpdate) {\n this.scene.triggerUpdate();\n }\n }); // Lifecycle\n\n this.onBlur = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(() => {\n isHoldingSpace = false;\n this.setState({\n isBindingEnabled: true\n });\n });\n\n this.onUnload = () => {\n this.onBlur();\n };\n\n this.disableEvent = event => {\n event.preventDefault();\n };\n\n this.resetHistory = () => {\n this.history.clear();\n };\n\n this.resetStore = () => {\n this.store.clear();\n };\n /**\r\n * Resets scene & history.\r\n * ! Do not use to clear scene user action !\r\n */\n\n\n this.resetScene = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(opts => {\n this.scene.replaceAllElements([]);\n this.setState(state => Object.assign(Object.assign({}, (0,_appState__WEBPACK_IMPORTED_MODULE_23__.getDefaultAppState)()), {\n isLoading: (opts === null || opts === void 0 ? void 0 : opts.resetLoadingState) ? false : state.isLoading,\n theme: this.state.theme\n }));\n this.resetStore();\n this.resetHistory();\n });\n\n this.initializeScene = async () => {\n var _a;\n\n if (\"launchQueue\" in window && \"LaunchParams\" in window) {\n window.launchQueue.setConsumer(async launchParams => {\n if (!launchParams.files.length) {\n return;\n }\n\n const fileHandle = launchParams.files[0];\n const blob = await fileHandle.getFile();\n this.loadFileToCanvas(new File([blob], blob.name || \"\", {\n type: blob.type\n }), fileHandle);\n });\n }\n\n if (this.props.theme) {\n this.setState({\n theme: this.props.theme\n });\n }\n\n if (!this.state.isLoading) {\n this.setState({\n isLoading: true\n });\n }\n\n let initialData = null;\n\n try {\n if (typeof this.props.initialData === \"function\") {\n initialData = (await this.props.initialData()) || null;\n } else {\n initialData = (await this.props.initialData) || null;\n }\n\n if (initialData === null || initialData === void 0 ? void 0 : initialData.libraryItems) {\n this.library.updateLibrary({\n libraryItems: initialData.libraryItems,\n merge: true\n }).catch(error => {\n console.error(error);\n });\n }\n } catch (error) {\n console.error(error);\n initialData = {\n appState: {\n errorMessage: error.message || \"Encountered an error during importing or restoring scene data\"\n }\n };\n }\n\n const scene = (0,_data_restore__WEBPACK_IMPORTED_MODULE_27__.restore)(initialData, null, null, {\n repairBindings: true,\n deleteInvisibleElements: true\n });\n const activeTool = scene.appState.activeTool;\n scene.appState = Object.assign(Object.assign({}, scene.appState), {\n theme: this.props.theme || scene.appState.theme,\n // we're falling back to current (pre-init) state when deciding\n // whether to open the library, to handle a case where we\n // update the state outside of initialData (e.g. when loading the app\n // with a library install link, which should auto-open the library)\n openSidebar: ((_a = scene.appState) === null || _a === void 0 ? void 0 : _a.openSidebar) || this.state.openSidebar,\n activeTool: activeTool.type === \"image\" || activeTool.type === \"lasso\" || activeTool.type === \"selection\" ? Object.assign(Object.assign({}, activeTool), {\n type: this.defaultSelectionTool\n }) : scene.appState.activeTool,\n isLoading: false,\n toast: this.state.toast\n });\n\n if (initialData === null || initialData === void 0 ? void 0 : initialData.scrollToContent) {\n scene.appState = Object.assign(Object.assign({}, scene.appState), (0,_scene__WEBPACK_IMPORTED_MODULE_31__.calculateScrollCenter)(scene.elements, Object.assign(Object.assign({}, scene.appState), {\n width: this.state.width,\n height: this.state.height,\n offsetTop: this.state.offsetTop,\n offsetLeft: this.state.offsetLeft\n })));\n }\n\n this.resetStore();\n this.resetHistory();\n this.syncActionResult(Object.assign(Object.assign({}, scene), {\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER\n })); // clear the shape and image cache so that any images in initialData\n // can be loaded fresh\n\n this.clearImageShapeCache(); // manually loading the font faces seems faster even in browsers that do fire the loadingdone event\n\n this.fonts.loadSceneFonts().then(fontFaces => {\n this.fonts.onLoaded(fontFaces);\n });\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(window.location.href)) {\n this.scrollToContent(window.location.href, {\n animate: false\n });\n }\n };\n\n this.isMobileBreakpoint = (width, height) => {\n return width !== 0 && this.allowMobileMode && ( //zsviczian changing tabs in Obsidian causes MobileMenu to be rendered\n width <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_MAX_MOBILE || height < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_MAX_HEIGHT_LANDSCAPE && width < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_MAX_WIDTH_LANDSCAPE);\n };\n\n this.isTabletBreakpoint = (editorWidth, editorHeight) => {\n const minSide = Math.min(editorWidth, editorHeight);\n const maxSide = Math.max(editorWidth, editorHeight);\n return editorWidth !== 0 && //zsviczian changing tabs in Obsidian causes MobileMenu to be rendered\n minSide >= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_MIN_TABLET && maxSide <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_MAX_TABLET;\n };\n\n this.refreshViewportBreakpoints = () => {\n const container = this.excalidrawContainerRef.current;\n\n if (!container) {\n return;\n }\n\n const {\n width: editorWidth,\n height: editorHeight\n } = container.getBoundingClientRect();\n const prevViewportState = this.device.viewport;\n const nextViewportState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(prevViewportState, {\n isLandscape: editorWidth > editorHeight,\n isMobile: this.isMobileBreakpoint(editorWidth, editorHeight)\n });\n\n if (prevViewportState !== nextViewportState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n viewport: nextViewportState\n });\n return true;\n }\n\n return false;\n };\n\n this.refreshEditorBreakpoints = () => {\n const container = this.excalidrawContainerRef.current;\n\n if (!container) {\n return;\n }\n\n const {\n width: editorWidth,\n height: editorHeight\n } = container.getBoundingClientRect();\n const sidebarBreakpoint = this.props.UIOptions.dockedSidebarBreakpoint != null ? this.props.UIOptions.dockedSidebarBreakpoint : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MQ_RIGHT_SIDEBAR_MIN_WIDTH;\n const prevEditorState = this.device.editor;\n const nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(prevEditorState, {\n isMobile: this.isMobileBreakpoint(editorWidth, editorHeight),\n canFitSidebar: editorWidth > sidebarBreakpoint\n }); // also check if we need to update the app state\n\n this.setState({\n stylesPanelMode: // NOTE: we could also remove the isMobileOrTablet check here and\n // always switch to compact mode when the editor is narrow (e.g. < MQ_MIN_WIDTH_DESKTOP)\n // but not too narrow (> MQ_MAX_WIDTH_MOBILE)\n this.isTabletBreakpoint(editorWidth, editorHeight) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() && !this.state.trayModeEnabled //zsviczian\n ? \"compact\" : \"full\"\n });\n\n if (prevEditorState !== nextEditorState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n editor: nextEditorState\n });\n return true;\n }\n\n return false;\n };\n\n this.onResize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(() => {\n this.scene.getElementsIncludingDeleted().forEach(element => _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element));\n this.refreshViewportBreakpoints();\n this.updateDOMRect();\n\n if (!_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.supportsResizeObserver) {\n this.refreshEditorBreakpoints();\n }\n\n this.setState({});\n });\n /** generally invoked only if fullscreen was invoked programmatically */\n\n this.onFullscreenChange = () => {\n var _a;\n\n if ( // points to the iframe element we fullscreened\n !document.fullscreenElement && ((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.state) === \"active\") {\n this.setState({\n activeEmbeddable: null\n });\n }\n };\n\n this.renderInteractiveSceneCallback = ({\n atLeastOneVisibleElement,\n scrollBars,\n elementsMap\n }) => {\n if (!document.querySelector(\".excalidraw\")) {\n return;\n } //zsviczian - address issue when moving excalidraw to a new window/document\n\n\n if (scrollBars) {\n currentScrollBars = scrollBars;\n }\n\n const scrolledOutside = // hide when editing text\n this.state.editingTextElement ? false : !atLeastOneVisibleElement && elementsMap.size > 0;\n\n if (this.state.scrolledOutside !== scrolledOutside) {\n this.setState({\n scrolledOutside\n });\n }\n\n this.scheduleImageRefresh();\n };\n\n this.onScroll = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.debounce)(() => {\n const {\n offsetTop,\n offsetLeft\n } = this.getCanvasOffsets();\n this.setState(state => {\n if (state.offsetLeft === offsetLeft && state.offsetTop === offsetTop) {\n return null;\n }\n\n return {\n offsetTop,\n offsetLeft\n };\n });\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.SCROLL_TIMEOUT); // Copy/paste\n\n this.onCut = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n var _a;\n\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement);\n\n if (!isExcalidrawActive || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionCut, \"keyboard\", event);\n event.preventDefault();\n event.stopPropagation();\n });\n this.onCopy = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n var _a;\n\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement);\n\n if (!isExcalidrawActive || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(event.target)) {\n return;\n }\n\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionCopy, \"keyboard\", event);\n event.preventDefault();\n event.stopPropagation();\n });\n\n this.onTouchStart = event => {\n // fix for Apple Pencil Scribble (do not prevent for other devices)\n if (_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isIOS) {\n event.preventDefault();\n }\n\n if (!didTapTwice) {\n didTapTwice = true;\n\n if (event.touches.length === 1) {\n firstTapPosition = {\n x: event.touches[0].clientX,\n y: event.touches[0].clientY\n };\n }\n\n clearTimeout(tappedTwiceTimer);\n tappedTwiceTimer = window.setTimeout(App.resetTapTwice, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TAP_TWICE_TIMEOUT);\n return;\n } // insert text only if we tapped twice with a single finger at approximately the same position\n // event.touches.length === 1 will also prevent inserting text when user's zooming\n\n\n if (didTapTwice && event.touches.length === 1 && firstTapPosition) {\n const touch = event.touches[0];\n const distance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(touch.clientX, touch.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(firstTapPosition.x, firstTapPosition.y)); // only create text if the second tap is within the threshold of the first tap\n // this prevents accidental text creation during dragging/selection\n\n if (distance <= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DOUBLE_TAP_POSITION_THRESHOLD) {\n // end lasso trail and deselect elements just in case\n this.lassoTrail.endPath();\n this.deselectElements(); // @ts-ignore\n\n this.handleCanvasDoubleClick({\n clientX: touch.clientX,\n clientY: touch.clientY\n });\n }\n\n didTapTwice = false;\n clearTimeout(tappedTwiceTimer);\n }\n\n if (event.touches.length === 2) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null\n });\n }\n };\n\n this.onTouchEnd = event => {\n this.resetContextMenuTimer();\n\n if (event.touches.length > 0) {\n this.setState({\n previousSelectedElementIds: {},\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n } else {\n gesture.pointers.clear();\n }\n };\n\n this.pasteFromClipboard = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(async event => {\n var _a;\n\n const isPlainPaste = !!IS_PLAIN_PASTE; // #686\n\n const target = document.activeElement;\n const isExcalidrawActive = (_a = this.excalidrawContainerRef.current) === null || _a === void 0 ? void 0 : _a.contains(target);\n\n if (event && !isExcalidrawActive) {\n return;\n }\n\n const elementUnderCursor = document.elementFromPoint(this.lastViewportPosition.x, this.lastViewportPosition.y);\n\n if (event && (!(elementUnderCursor instanceof HTMLCanvasElement) || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(target))) {\n return;\n } // must be called in the same frame (thus before any awaits) as the paste\n // event else some browsers (FF...) will clear the clipboardData\n // (something something security)\n\n\n const dataTransferList = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_24__.parseDataTransferEvent)(event);\n const filesList = dataTransferList.getFiles();\n const data = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_24__.parseClipboard)(dataTransferList, isPlainPaste);\n\n if (this.props.onPaste) {\n try {\n if ((await this.props.onPaste(data, event)) === false) {\n return;\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n await this.insertClipboardContent(data, filesList, isPlainPaste);\n this.setActiveTool({\n type: this.defaultSelectionTool\n }, true);\n event === null || event === void 0 ? void 0 : event.preventDefault();\n });\n\n this.addElementsFromPasteOrLibrary = opts => {\n var _a, _b;\n\n const elements = (0,_data_restore__WEBPACK_IMPORTED_MODULE_27__.restoreElements)(opts.elements, null, {\n deleteInvisibleElements: true\n });\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(elements);\n const elementsCenterX = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(minX, maxX) / 2;\n const elementsCenterY = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(minY, maxY) / 2;\n const clientX = typeof opts.position === \"object\" ? opts.position.clientX : opts.position === \"cursor\" ? this.lastViewportPosition.x : this.state.width / 2 + this.state.offsetLeft;\n const clientY = typeof opts.position === \"object\" ? opts.position.clientY : opts.position === \"cursor\" ? this.lastViewportPosition.y : this.state.height / 2 + this.state.offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX,\n clientY\n }, this.state);\n const dx = x - elementsCenterX;\n const dy = y - elementsCenterY;\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(dx, dy, this.getEffectiveGridSize());\n const {\n duplicatedElements\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.duplicateElements)({\n type: \"everything\",\n elements: elements.map(element => {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(element, {\n x: element.x + gridX - minX,\n y: element.y + gridY - minY\n });\n }),\n randomizeSeed: !opts.retainSeed\n });\n const prevElements = this.scene.getElementsIncludingDeleted();\n let nextElements = [...prevElements, ...duplicatedElements];\n const mappedNewSceneElements = (_b = (_a = this.props).onDuplicate) === null || _b === void 0 ? void 0 : _b.call(_a, nextElements, prevElements);\n nextElements = mappedNewSceneElements || nextElements;\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.syncMovedIndices)(nextElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(duplicatedElements));\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x,\n y\n });\n\n if (topLayerFrame) {\n const eligibleElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.filterElementsEligibleAsFrameChildren)(duplicatedElements, topLayerFrame);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(nextElements, eligibleElements, topLayerFrame, this.state);\n }\n\n this.scene.replaceAllElements(nextElements);\n duplicatedElements.forEach(newElement => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(newElement) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(newElement)) {\n const container = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(newElement, this.scene.getElementsMapIncludingDeleted());\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.redrawTextBoundingBox)(newElement, container, this.scene);\n }\n }); // paste event may not fire FontFace loadingdone event in Safari, hence loading font faces manually\n\n if (true) {\n //zsviczian - isSafari\n _fonts__WEBPACK_IMPORTED_MODULE_36__.Fonts.loadElementsFonts(duplicatedElements).then(fontFaces => {\n this.fonts.onLoaded(fontFaces);\n });\n }\n\n if (opts.files) {\n this.addMissingFiles(opts.files);\n }\n\n const nextElementsToSelect = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.excludeElementsInFramesFromSelection)(duplicatedElements);\n this.store.scheduleCapture();\n this.setState(Object.assign(Object.assign(Object.assign({}, this.state), {\n // keep sidebar (presumably the library) open if it's docked and\n // can fit.\n //\n // Note, we should close the sidebar only if we're dropping items\n // from library, not when pasting from clipboard. Alas.\n openSidebar: this.state.openSidebar && this.device.editor.canFitSidebar && _editor_jotai__WEBPACK_IMPORTED_MODULE_37__.editorJotaiStore.get(_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_61__.isSidebarDockedAtom) ? this.state.openSidebar : null\n }), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: null,\n selectedElementIds: nextElementsToSelect.reduce((acc, element) => {\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(element)) {\n acc[element.id] = true;\n }\n\n return acc;\n }, {})\n }, this.scene.getNonDeletedElements(), this.state, this)), () => {\n if (opts.files) {\n this.addNewImagesToImageCache();\n }\n });\n this.setActiveTool({\n type: this.defaultSelectionTool\n }, true);\n\n if (opts.fitToContent) {\n this.scrollToContent(duplicatedElements, {\n fitToContent: true,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n };\n\n this.setAppState = (state, callback) => {\n this.setState(state, callback);\n };\n\n this.removePointer = event => {\n if (touchTimeout) {\n this.resetContextMenuTimer();\n }\n\n gesture.pointers.delete(event.pointerId);\n };\n\n this.toggleLock = (source = \"ui\") => {\n if (!this.state.activeTool.locked) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"toolbar\", \"toggleLock\", `${source} (${this.device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n\n this.setState(prevState => {\n return {\n activeTool: Object.assign(Object.assign(Object.assign({}, prevState.activeTool), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, prevState.activeTool.locked ? {\n type: this.defaultSelectionTool\n } : prevState.activeTool)), {\n locked: !prevState.activeTool.locked\n })\n };\n });\n };\n\n this.updateFrameRendering = opts => {\n this.setState(prevState => {\n var _a, _b, _c, _d, _e, _f;\n\n const next = typeof opts === \"function\" ? opts(prevState.frameRendering) : opts;\n return {\n frameRendering: {\n enabled: (_a = next === null || next === void 0 ? void 0 : next.enabled) !== null && _a !== void 0 ? _a : prevState.frameRendering.enabled,\n clip: (_b = next === null || next === void 0 ? void 0 : next.clip) !== null && _b !== void 0 ? _b : prevState.frameRendering.clip,\n name: (_c = next === null || next === void 0 ? void 0 : next.name) !== null && _c !== void 0 ? _c : prevState.frameRendering.name,\n outline: (_d = next === null || next === void 0 ? void 0 : next.outline) !== null && _d !== void 0 ? _d : prevState.frameRendering.outline,\n //zsviczian\n markerName: (_e = next === null || next === void 0 ? void 0 : next.markerName) !== null && _e !== void 0 ? _e : prevState.frameRendering.markerName,\n markerEnabled: (_f = next === null || next === void 0 ? void 0 : next.markerEnabled) !== null && _f !== void 0 ? _f : prevState.frameRendering.markerEnabled\n }\n };\n });\n };\n\n this.togglePenMode = force => {\n this.setState(prevState => {\n return {\n penMode: force !== null && force !== void 0 ? force : !prevState.penMode,\n penDetected: true\n };\n });\n };\n\n this.onHandToolToggle = () => {\n //zsviczian added timeout because button won't select otherwise\n setTimeout(() => this.actionManager.executeAction(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.actionToggleHandTool));\n };\n /**\r\n * Zooms on canvas viewport center\r\n */\n\n\n this.zoomCanvas = (\n /**\r\n * Decimal fraction, auto-clamped between MIN_ZOOM and MAX_ZOOM.\r\n * 1 = 100% zoom, 2 = 200% zoom, 0.5 = 50% zoom\r\n */\n value) => {\n this.setState(Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_32__.getStateForZoom)({\n viewportX: this.state.width / 2 + this.state.offsetLeft,\n viewportY: this.state.height / 2 + this.state.offsetTop,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getNormalizedZoom)(value)\n }, this.state)));\n };\n\n this.cancelInProgressAnimation = null;\n\n this.scrollToContent = (\n /**\r\n * target to scroll to\r\n *\r\n * - string - id of element or group, or url containing elementLink\r\n * - ExcalidrawElement | ExcalidrawElement[] - element(s) objects\r\n */\n target = this.scene.getNonDeletedElements(), opts) => {\n var _a, _b, _c, _d;\n\n if (typeof target === \"string\") {\n let id;\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(target)) {\n id = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.parseElementLinkFromURL)(target);\n } else {\n id = target;\n }\n\n if (id) {\n const elements = this.scene.getElementsFromId(id);\n\n if (elements === null || elements === void 0 ? void 0 : elements.length) {\n this.scrollToContent(elements, {\n fitToContent: (_a = opts === null || opts === void 0 ? void 0 : opts.fitToContent) !== null && _a !== void 0 ? _a : true,\n animate: (_b = opts === null || opts === void 0 ? void 0 : opts.animate) !== null && _b !== void 0 ? _b : true\n });\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementLink)(target)) {\n this.setState({\n toast: {\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"elementLink.notFound\"),\n duration: 3000,\n closable: true\n }\n });\n }\n }\n\n return;\n }\n\n (_c = this.cancelInProgressAnimation) === null || _c === void 0 ? void 0 : _c.call(this); // convert provided target into ExcalidrawElement[] if necessary\n\n const targetElements = Array.isArray(target) ? target : [target];\n let zoom = this.state.zoom;\n let scrollX = this.state.scrollX;\n let scrollY = this.state.scrollY;\n\n if ((opts === null || opts === void 0 ? void 0 : opts.fitToContent) || (opts === null || opts === void 0 ? void 0 : opts.fitToViewport)) {\n const {\n appState\n } = (0,_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.zoomToFit)({\n canvasOffsets: opts.canvasOffsets,\n targetElements,\n appState: this.state,\n fitToViewport: !!(opts === null || opts === void 0 ? void 0 : opts.fitToViewport),\n viewportZoomFactor: opts === null || opts === void 0 ? void 0 : opts.viewportZoomFactor,\n minZoom: opts === null || opts === void 0 ? void 0 : opts.minZoom,\n maxZoom: opts === null || opts === void 0 ? void 0 : opts.maxZoom\n });\n zoom = appState.zoom;\n scrollX = appState.scrollX;\n scrollY = appState.scrollY;\n } else {\n // compute only the viewport location, without any zoom adjustment\n const scroll = (0,_scene__WEBPACK_IMPORTED_MODULE_31__.calculateScrollCenter)(targetElements, this.state);\n scrollX = scroll.scrollX;\n scrollY = scroll.scrollY;\n } // when animating, we use RequestAnimationFrame to prevent the animation\n // from slowing down other processes\n\n\n if (opts === null || opts === void 0 ? void 0 : opts.animate) {\n const origScrollX = this.state.scrollX;\n const origScrollY = this.state.scrollY;\n const origZoom = this.state.zoom.value;\n const cancel = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.easeToValuesRAF)({\n fromValues: {\n scrollX: origScrollX,\n scrollY: origScrollY,\n zoom: origZoom\n },\n toValues: {\n scrollX,\n scrollY,\n zoom: zoom.value\n },\n interpolateValue: (from, to, progress, key) => {\n // for zoom, use different easing\n if (key === \"zoom\") {\n return from * Math.pow(to / from, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.easeOut)(progress));\n } // handle using default\n\n\n return undefined;\n },\n onStep: ({\n scrollX,\n scrollY,\n zoom\n }) => {\n this.setState({\n scrollX,\n scrollY,\n zoom: {\n value: zoom\n }\n });\n },\n onStart: () => {\n this.setState({\n shouldCacheIgnoreZoom: true\n });\n },\n onEnd: () => {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n },\n onCancel: () => {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n },\n duration: (_d = opts === null || opts === void 0 ? void 0 : opts.duration) !== null && _d !== void 0 ? _d : 500\n });\n\n this.cancelInProgressAnimation = () => {\n cancel();\n this.cancelInProgressAnimation = null;\n };\n } else {\n this.setState({\n scrollX,\n scrollY,\n zoom\n });\n }\n };\n\n this.maybeUnfollowRemoteUser = () => {\n if (this.state.userToFollow) {\n this.setState({\n userToFollow: null\n });\n }\n };\n /** use when changing scrollX/scrollY/zoom based on user interaction */\n\n\n this.translateCanvas = state => {\n var _a;\n\n (_a = this.cancelInProgressAnimation) === null || _a === void 0 ? void 0 : _a.call(this);\n this.maybeUnfollowRemoteUser();\n this.setState(state);\n }; //zsviczian\n\n\n this.setForceRenderAllEmbeddables = force => {\n this.shouldRenderAllEmbeddables = force;\n\n if (force) {\n this.setState({});\n }\n }; //zsviczian\n\n\n this.zoomToFit = (target = this.scene.getNonDeletedElements(), maxZoom, //null will zoom to max based on viewport\n margin = 0.03) => {\n if (typeof maxZoom === \"undefined\") {\n //zsviczian\n maxZoom = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.getMaxZoom)();\n }\n\n if (!target) {\n target = this.scene.getNonDeletedElements();\n }\n\n if (target.length === 0) {\n maxZoom = 1;\n }\n\n this.setState((0,_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.zoomToFitElements)(target, this.state, false, this, maxZoom, margin).appState);\n }; //zsviczian\n\n\n this.getColorAtScenePoint = ({\n sceneX,\n sceneY\n }) => {\n if (!this.canvas) {\n console.error(\"Canvas not available\");\n return null;\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.sceneCoordsToViewportCoords)({\n sceneX,\n sceneY\n }, this.state);\n const context = this.canvas.getContext(\"2d\");\n\n if (!context) {\n console.error(\"2D context not available\");\n return null;\n } // Get pixel data directly from the given scene coordinates\n\n\n const pixelData = context.getImageData(x, y, 1, 1).data;\n const [r, g, b, a] = pixelData; // Check for transparency\n\n if (a === 0) {\n return this.state.theme === \"light\" ? \"rgba(255,255,255,1)\" : \"rgba(0,0,0,1)\";\n } // Return the color in rgba format\n\n\n return `rgba(${r}, ${g}, ${b}, ${a / 255})`;\n }; //zsviczian\n\n\n this.startLineEditor = (el, selectedPointsIndices = null) => {\n if (!el || !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(el)) {\n return;\n } // First select the element\n\n\n this.setState({\n selectedElementIds: {\n [el.id]: true\n }\n }, () => {\n // Then set up the editor\n const linearElementEditor = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(el, this.scene.getNonDeletedElementsMap());\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, linearElementEditor), {\n isEditing: true,\n selectedPointsIndices\n })\n });\n });\n }; //zsviczian\n\n\n this.updateContainerSize = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(containers => {\n containers.forEach(element => {\n // Get absolute coordinates for the bottom-right corner\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getResizedElementAbsoluteCoords)(element, element.width, element.height, true); // Get rotated pointer position at bottom-right corner\n\n const [pointerX, pointerY] = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x2, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)((x1 + x2) / 2, (y1 + y2) / 2), element.angle);\n const {\n nextWidth,\n nextHeight\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getNextSingleWidthAndHeightFromPointer)(element, element, \"se\", pointerX, pointerY);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.resizeSingleElement)(nextWidth, nextHeight, element, element, this.scene.getElementsMapIncludingDeleted(), this.scene, \"se\", {\n shouldMaintainAspectRatio: true,\n shouldResizeFromCenter: false\n });\n });\n });\n\n this.setToast = toast => {\n this.setState({\n toast\n });\n };\n\n this.restoreFileFromShare = async () => {\n try {\n const webShareTargetCache = await caches.open(\"web-share-target\");\n const response = await webShareTargetCache.match(\"shared-file\");\n\n if (response) {\n const blob = await response.blob();\n const file = new File([blob], blob.name || \"\", {\n type: blob.type\n });\n this.loadFileToCanvas(file, null);\n await webShareTargetCache.delete(\"shared-file\");\n window.history.replaceState(null, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.APP_NAME, window.location.pathname);\n }\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n };\n /**\r\n * adds supplied files to existing files in the appState.\r\n * NOTE if file already exists in editor state, the file data is not updated\r\n * */\n\n\n this.addFiles = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(files => {\n const {\n addedFiles\n } = this.addMissingFiles(files, undefined, true); //zsviczian\n\n this.clearImageShapeCache(addedFiles);\n this.scene.triggerUpdate();\n this.addNewImagesToImageCache();\n }); //zsviczian https://github.com/zsviczian/excalibrain/issues/9\n\n this.setMobileModeAllowed = allow => {\n const {\n width: editorWidth,\n height: editorHeight\n } = this.excalidrawContainerRef.current.getBoundingClientRect();\n this.allowMobileMode = allow;\n const prevEditorState = this.device.editor;\n let nextEditorState;\n\n if (allow) {\n nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(prevEditorState, {\n isMobile: this.isMobileBreakpoint(editorWidth, editorHeight)\n });\n } else {\n nextEditorState = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(prevEditorState, {\n isMobile: false //must test this\n\n });\n }\n\n if (prevEditorState !== nextEditorState) {\n this.device = Object.assign(Object.assign({}, this.device), {\n editor: nextEditorState\n });\n this.forceUpdate();\n }\n }; //zsviczian\n\n\n this.debounceClearHighlightSearchResults = false;\n\n this.selectElements = (elements, highlightSearchResult = false) => {\n //zsviczian\n if (highlightSearchResult) {\n this.debounceClearHighlightSearchResults = true;\n setTimeout(() => {\n this.debounceClearHighlightSearchResults = false;\n }, 500);\n }\n\n this.updateScene({\n appState: Object.assign(Object.assign({}, this.state), {\n editingGroupId: null,\n selectedElementIds: elements.reduce((map, element) => {\n map[element.id] = true;\n return map;\n }, {}),\n highlightSearchResult\n }),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER,\n forceFlushSync: true\n });\n }; //zsviczian\n\n\n this.bringToFront = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_8__.actionBringToFront.perform(this.scene.getNonDeletedElements(), this.state));\n }; //zsviczian\n\n\n this.bringForward = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_8__.actionBringForward.perform(this.scene.getNonDeletedElements(), this.state, undefined, this));\n }; //zsviczian\n\n\n this.sendToBack = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_8__.actionSendToBack.perform(this.scene.getNonDeletedElements(), this.state));\n }; //zsviczian\n\n\n this.sendBackward = elements => {\n this.selectElements(elements);\n this.updateScene(_actions__WEBPACK_IMPORTED_MODULE_8__.actionSendBackward.perform(this.scene.getNonDeletedElements(), this.state, undefined, this));\n };\n\n this.addMissingFiles = (files, replace = false, force = false) => {\n var _a;\n\n const nextFiles = replace ? {} : Object.assign({}, this.files);\n const addedFiles = {};\n\n const _files = Array.isArray(files) ? files : Object.values(files);\n\n for (const fileData of _files) {\n if (!force && nextFiles[fileData.id]) {\n //zsviczian\n continue;\n }\n\n addedFiles[fileData.id] = fileData;\n nextFiles[fileData.id] = fileData;\n\n if (fileData.mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg) {\n try {\n const restoredDataURL = (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.getDataURL_sync)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.normalizeSVG)((0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.dataURLToString)(fileData.dataURL)), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg);\n\n if (fileData.dataURL !== restoredDataURL) {\n // bump version so persistence layer can update the store\n fileData.version = ((_a = fileData.version) !== null && _a !== void 0 ? _a : 1) + 1;\n fileData.dataURL = restoredDataURL;\n }\n } catch (error) {\n console.error(error);\n }\n }\n }\n\n this.files = nextFiles;\n return {\n addedFiles\n };\n };\n\n this.updateScene = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(sceneData => {\n const {\n elements,\n appState,\n collaborators,\n captureUpdate\n } = sceneData;\n\n if (captureUpdate) {\n const nextElements = elements ? elements : undefined;\n const observedAppState = appState ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getObservedAppState)(Object.assign(Object.assign({}, this.store.snapshot.appState), appState)) : undefined;\n this.store.scheduleMicroAction({\n action: captureUpdate,\n elements: nextElements,\n appState: observedAppState\n });\n } //zsviczian forceFlushSync is set to true in ExcalidrawView.updateScene.\n //without this e.g. text search did not select the elements\n\n\n if (sceneData.forceFlushSync === true) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n if (appState) {\n this.setState(appState);\n }\n });\n } else if (appState) {\n this.setState(appState);\n }\n\n if (elements) {\n this.scene.replaceAllElements(elements);\n }\n\n if (collaborators) {\n this.setState({\n collaborators\n });\n }\n });\n\n this.applyDeltas = (deltas, options) => {\n // squash all deltas together, starting with a fresh new delta instance\n const aggregatedDelta = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.StoreDelta.squash(...deltas); // create new instance of elements map & appState, so we don't accidentaly mutate existing ones\n\n const nextAppState = Object.assign({}, this.state);\n const nextElements = new Map(this.scene.getElementsMapIncludingDeleted());\n return _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.StoreDelta.applyTo(aggregatedDelta, nextElements, nextAppState, options);\n };\n\n this.mutateElement = (element, updates, informMutation = true) => {\n return this.scene.mutateElement(element, updates, {\n informMutation,\n isDragging: false\n });\n };\n\n this.triggerRender = (\n /** force always re-renders canvas even if no change */\n force) => {\n if (force === true) {\n this.scene.triggerUpdate();\n } else {\n this.setState({});\n }\n };\n /**\r\n * @returns whether the menu was toggled on or off\r\n */\n\n\n this.toggleSidebar = ({\n name,\n tab,\n force\n }) => {\n var _a, _b;\n\n let nextName;\n\n if (force === undefined) {\n nextName = ((_a = this.state.openSidebar) === null || _a === void 0 ? void 0 : _a.name) === name && ((_b = this.state.openSidebar) === null || _b === void 0 ? void 0 : _b.tab) === tab ? null : name;\n } else {\n nextName = force ? name : null;\n }\n\n const nextState = nextName ? {\n name: nextName\n } : null;\n\n if (nextState && tab) {\n nextState.tab = tab;\n }\n\n this.setState({\n openSidebar: nextState\n });\n return !!nextName;\n };\n\n this.updateCurrentCursorPosition = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n this.lastViewportPosition.x = event.clientX;\n this.lastViewportPosition.y = event.clientY;\n });\n\n this.getEditorUIOffsets = () => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;\n\n const toolbarBottom = ((_e = (_d = (_c = (_b = (_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.querySelector(\".App-toolbar\")) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect()) === null || _d === void 0 ? void 0 : _d.bottom) !== null && _e !== void 0 ? _e : 0) - this.state.offsetTop;\n const sidebarRect = (_h = (_g = (_f = this.excalidrawContainerRef) === null || _f === void 0 ? void 0 : _f.current) === null || _g === void 0 ? void 0 : _g.querySelector(\".sidebar\")) === null || _h === void 0 ? void 0 : _h.getBoundingClientRect();\n const propertiesPanelRect = (_l = (_k = (_j = this.excalidrawContainerRef) === null || _j === void 0 ? void 0 : _j.current) === null || _k === void 0 ? void 0 : _k.querySelector(\".App-menu__left\")) === null || _l === void 0 ? void 0 : _l.getBoundingClientRect();\n const PADDING = 16;\n\n const adjustRectValueForOffset = ( //zsviczian https://github.com/excalidraw/excalidraw/issues/8561\n value, fallback) => (value !== null && value !== void 0 ? value : fallback + this.state.offsetLeft) - this.state.offsetLeft;\n\n return (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.getLanguage)().rtl ? {\n top: toolbarBottom + PADDING,\n right: Math.max(this.state.width - adjustRectValueForOffset( //zsivczian\n propertiesPanelRect === null || propertiesPanelRect === void 0 ? void 0 : propertiesPanelRect.left, this.state.width), 0) + PADDING,\n bottom: PADDING,\n //zsivczian\n left: Math.max(adjustRectValueForOffset(sidebarRect === null || sidebarRect === void 0 ? void 0 : sidebarRect.right, 0), 0) + PADDING\n } : {\n top: toolbarBottom + PADDING,\n right: Math.max(this.state.width - adjustRectValueForOffset(sidebarRect === null || sidebarRect === void 0 ? void 0 : sidebarRect.left, this.state.width) + //zsivczian\n PADDING, 0),\n bottom: PADDING,\n //zsivczian\n left: Math.max(adjustRectValueForOffset(propertiesPanelRect === null || propertiesPanelRect === void 0 ? void 0 : propertiesPanelRect.right, 0), 0) + PADDING\n };\n }; // Input handling\n\n\n this.onKeyDown = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n\n if (this.state.activeTool.type === \"selection\" && this.state.resizingElement && (event.shiftKey || event.altKey)) {\n event.stopPropagation(); //zsviczian shift fires repeatedly causing slowdown when resizing sticky notes\n\n return;\n } // normalize `event.key` when CapsLock is pressed #2372\n\n\n if (\"Proxy\" in window && (!event.shiftKey && /^[A-Z]$/.test(event.key) || event.shiftKey && /^[a-z]$/.test(event.key))) {\n event = new Proxy(event, {\n get(ev, prop) {\n const value = ev[prop];\n\n if (typeof value === \"function\") {\n // fix for Proxies hijacking `this`\n return value.bind(ev);\n }\n\n return prop === \"key\" ? // CapsLock inverts capitalization based on ShiftKey, so invert\n // it back\n event.shiftKey ? ev.key.toUpperCase() : ev.key.toLowerCase() : value;\n }\n\n });\n }\n\n if (!(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isInputLike)(event.target)) {\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) && this.state.croppingElementId) {\n this.finishImageCropping();\n return;\n }\n\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(selectedElements[0]) && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) {\n this.startImageCropping(selectedElements[0]);\n return;\n } // Shape switching\n\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom, null);\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.TAB && (document.activeElement === ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) || ((_b = document.activeElement) === null || _b === void 0 ? void 0 : _b.classList.contains(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CLASSES.CONVERT_ELEMENT_TYPE_POPUP)))) {\n event.preventDefault();\n const conversionType = (0,_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.getConversionTypeFromElements)(selectedElements);\n\n if (((_c = _editor_jotai__WEBPACK_IMPORTED_MODULE_37__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom)) === null || _c === void 0 ? void 0 : _c.type) === \"panel\") {\n if ((0,_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypes)(this, {\n conversionType,\n direction: event.shiftKey ? \"left\" : \"right\"\n })) {\n this.store.scheduleCapture();\n }\n }\n\n if (conversionType) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom, {\n type: \"panel\"\n });\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE && this.flowChartCreator.isCreatingChart) {\n this.flowChartCreator.clear();\n this.triggerRender(true);\n return;\n }\n\n const arrowKeyPressed = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key);\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && arrowKeyPressed && !event.shiftKey) {\n event.preventDefault();\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFlowchartNodeElement)(selectedElements[0])) {\n this.flowChartCreator.createNodes(selectedElements[0], this.state, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLinkDirectionFromKey)(event.key), this.scene);\n }\n\n if (((_d = this.flowChartCreator.pendingNodes) === null || _d === void 0 ? void 0 : _d.length) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementCompletelyInViewport)(this.flowChartCreator.pendingNodes, this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(this.flowChartCreator.pendingNodes, {\n animate: true,\n duration: 300,\n fitToContent: true,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n\n return;\n }\n\n if (event.altKey) {\n const selectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getSelectedElements)(this.scene.getNonDeletedElementsMap(), this.state);\n\n if (selectedElements.length === 1 && arrowKeyPressed) {\n event.preventDefault();\n const nextId = this.flowChartNavigator.exploreByDirection(selectedElements[0], this.scene.getNonDeletedElementsMap(), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLinkDirectionFromKey)(event.key));\n\n if (nextId) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [nextId]: true\n }, prevState)\n }));\n const nextNode = this.scene.getNonDeletedElementsMap().get(nextId);\n\n if (nextNode && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementCompletelyInViewport)([nextNode], this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(nextNode, {\n animate: true,\n duration: 300,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n }\n\n return;\n }\n }\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.P && !event.shiftKey && !event.altKey) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"commandPalette.shortcutHint\", {\n shortcut: (0,_actions_shortcuts__WEBPACK_IMPORTED_MODULE_20__.getShortcutFromShortcutName)(\"commandPalette\")\n })\n });\n event.preventDefault();\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.V) {\n IS_PLAIN_PASTE = event.shiftKey;\n clearTimeout(IS_PLAIN_PASTE_TIMER); // reset (100ms to be safe that we it runs after the ensuing\n // paste event). Though, technically unnecessary to reset since we\n // (re)set the flag before each paste event.\n\n IS_PLAIN_PASTE_TIMER = window.setTimeout(() => {\n IS_PLAIN_PASTE = false;\n }, 100);\n } // prevent browser zoom in input fields\n\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(event.target)) {\n if (event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CODES.MINUS || event.code === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CODES.EQUAL) {\n event.preventDefault();\n return;\n }\n } // bail if\n\n\n if ( // inside an input\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isWritableElement)(event.target) && // unless pressing escape (finalize action)\n event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ESCAPE || // or unless using arrows (to move between buttons)\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isInputLike)(event.target)) {\n return;\n } //mfuria #329. open context menu with 'm' if not editing text and container focused\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.isPanWithRightMouseEnabled)() && event.key.toLowerCase() === 'm' && !this.state.editingTextElement && // don't trigger when typing in inputs\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isInputLike)(event.target) && ( // ensure focus is within excalidraw container\n (_f = (_e = this.excalidrawContainerRef) === null || _e === void 0 ? void 0 : _e.current) === null || _f === void 0 ? void 0 : _f.contains(document.activeElement))) {\n // open context menu at current cursor position\n const container = this.excalidrawContainerRef.current;\n const {\n top: offsetTop,\n left: offsetLeft\n } = container.getBoundingClientRect();\n const left = this.lastViewportPosition.x - offsetLeft;\n const top = this.lastViewportPosition.y - offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state);\n const element = this.getElementAtPosition(x, y, {\n preferSelected: true,\n includeLockedElements: true\n });\n const selectedElements = this.scene.getSelectedElements(this.state);\n const isHittingCommonBoundBox = this.isHittingCommonBoundingBoxOfSelectedElements({\n x,\n y\n }, selectedElements);\n const type = element || isHittingCommonBoundBox ? 'element' : 'canvas';\n this.setState({\n contextMenu: {\n top,\n left,\n items: this.getContextMenuItems(type)\n }\n });\n event.preventDefault();\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.QUESTION_MARK) {\n this.setState({\n openDialog: {\n name: \"help\"\n }\n });\n return;\n } else if (event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.E && event.shiftKey && event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n event.preventDefault();\n this.setState({\n openDialog: {\n name: \"imageExport\"\n }\n });\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.PAGE_UP || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.PAGE_DOWN) {\n let offset = (event.shiftKey ? this.state.width : this.state.height) / this.state.zoom.value;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.PAGE_DOWN) {\n offset = -offset;\n }\n\n if (event.shiftKey) {\n this.translateCanvas(state => ({\n scrollX: state.scrollX + offset\n }));\n } else {\n this.translateCanvas(state => ({\n scrollY: state.scrollY + offset\n }));\n }\n }\n\n if (((_g = this.state.openDialog) === null || _g === void 0 ? void 0 : _g.name) === \"elementLinkSelector\") {\n return;\n }\n\n if (this.actionManager.handleKeyDown(event)) {\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.K && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isLaserPointerActive)(this.state)) {\n this.setActiveTool({\n type: \"selection\"\n });\n } else {\n this.setActiveTool({\n type: \"laser\"\n });\n }\n\n return;\n }\n\n if (this.state.viewModeEnabled) {\n //revert to hand in case a key is pressed (K is handled above)\n if (event.key !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.K) {\n this.setActiveTool({\n type: \"selection\"\n });\n }\n\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && this.state.isBindingEnabled) {\n this.setState({\n isBindingEnabled: false\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key)) {\n let selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds,\n includeBoundTextElement: true,\n includeElementsInFrames: true\n });\n const elbowArrow = selectedElements.find(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow);\n const arrowIdsToRemove = new Set();\n selectedElements.filter(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow).filter(arrow => {\n const startElementNotInSelection = arrow.startBinding && !selectedElements.some(el => {\n var _a;\n\n return el.id === ((_a = arrow.startBinding) === null || _a === void 0 ? void 0 : _a.elementId);\n });\n const endElementNotInSelection = arrow.endBinding && !selectedElements.some(el => {\n var _a;\n\n return el.id === ((_a = arrow.endBinding) === null || _a === void 0 ? void 0 : _a.elementId);\n });\n return startElementNotInSelection || endElementNotInSelection;\n }).forEach(arrow => arrowIdsToRemove.add(arrow.id));\n selectedElements = selectedElements.filter(el => !arrowIdsToRemove.has(el.id));\n const step = this.getEffectiveGridSize() && (event.shiftKey ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ELEMENT_TRANSLATE_AMOUNT : this.getEffectiveGridSize()) || (event.shiftKey ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ELEMENT_SHIFT_TRANSLATE_AMOUNT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ELEMENT_TRANSLATE_AMOUNT);\n let offsetX = 0;\n let offsetY = 0;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_LEFT) {\n offsetX = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_RIGHT) {\n offsetX = step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_UP) {\n offsetY = -step;\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ARROW_DOWN) {\n offsetY = step;\n }\n\n selectedElements.forEach(element => {\n this.scene.mutateElement(element, {\n x: element.x + offsetX,\n y: element.y + offsetY\n }, {\n informMutation: false,\n isDragging: false\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(element, this.scene, {\n simultaneouslyUpdated: selectedElements\n });\n });\n this.setState({\n suggestedBindings: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSuggestedBindingsForArrows)(selectedElements.filter(element => element.id !== (elbowArrow === null || elbowArrow === void 0 ? void 0 : elbowArrow.id) || step !== 0), this.scene.getNonDeletedElementsMap(), this.state.zoom)\n });\n this.scene.triggerUpdate();\n event.preventDefault();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ENTER) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n const selectedElement = selectedElements[0];\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedElement)) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElement)) {\n if (!((_h = this.state.selectedLinearElement) === null || _h === void 0 ? void 0 : _h.isEditing) || this.state.selectedLinearElement.elementId !== selectedElement.id) {\n this.store.scheduleCapture();\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElement)) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n }\n }\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isValidTextContainer)(selectedElement)) {\n let container;\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElement)) {\n container = selectedElement;\n }\n\n const midPoint = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerCenter)(selectedElement, this.state, this.scene.getNonDeletedElementsMap());\n const sceneX = midPoint.x;\n const sceneY = midPoint.y;\n this.startTextEditing({\n sceneX,\n sceneY,\n container\n });\n event.preventDefault();\n return;\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(selectedElement)) {\n this.setState({\n editingFrame: selectedElement.id\n });\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(selectedElement)) {\n //zsviczian\n this.setState({\n activeEmbeddable: {\n element: selectedElement,\n state: \"active\"\n }\n });\n }\n }\n } else if (!event.ctrlKey && !event.altKey && !event.metaKey && !this.state.newElement && !this.state.selectionElement && !this.state.selectedElementsAreBeingDragged) {\n const shape = (0,_shapes__WEBPACK_IMPORTED_MODULE_67__.findShapeByKey)(event.key, this);\n\n if (shape) {\n if (this.state.activeTool.type !== shape) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"toolbar\", shape, `keyboard (${this.device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n\n if (shape === \"arrow\" && this.state.activeTool.type === \"arrow\") {\n this.setState(prevState => ({\n currentItemArrowType: prevState.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.sharp ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.round : prevState.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.round ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.elbow : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.sharp\n }));\n }\n\n this.setActiveTool({\n type: shape\n });\n event.stopPropagation();\n } else if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.Q) {\n this.toggleLock(\"keyboard\");\n event.stopPropagation();\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.SPACE && gesture.pointers.size === 0) {\n isHoldingSpace = true;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n event.preventDefault();\n }\n\n if ((event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.G || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S) && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (this.state.activeTool.type === \"selection\" && !selectedElements.length) {\n return;\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.G && ((0,_scene__WEBPACK_IMPORTED_MODULE_31__.hasBackground)(this.state.activeTool.type) || selectedElements.some(element => (0,_scene__WEBPACK_IMPORTED_MODULE_31__.hasBackground)(element.type)))) {\n this.setState({\n openPopup: \"elementBackground\"\n });\n event.stopPropagation();\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S) {\n this.setState({\n openPopup: \"elementStroke\"\n });\n event.stopPropagation();\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && event.shiftKey && event.key.toLowerCase() === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.F) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (this.state.activeTool.type === \"selection\" && !selectedElements.length) {\n return;\n }\n\n if (this.state.activeTool.type === \"text\" || selectedElements.find(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(element, this.scene.getNonDeletedElementsMap()))) {\n event.preventDefault();\n this.setState({\n openPopup: \"fontFamily\"\n });\n }\n }\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.K && !event.altKey && !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if (this.state.activeTool.type === \"laser\") {\n this.setActiveTool({\n type: this.defaultSelectionTool\n });\n } else {\n this.setActiveTool({\n type: \"laser\"\n });\n }\n\n return;\n }\n\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.BACKSPACE || event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.DELETE)) {\n this.updateEditorAtom(_ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_52__.activeConfirmDialogAtom, \"clearCanvas\");\n } // eye dropper\n // -----------------------------------------------------------------------\n\n\n const lowerCased = event.key.toLocaleLowerCase();\n const isPickingStroke = lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.S && event.shiftKey;\n const isPickingBackground = event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.I || lowerCased === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.G && event.shiftKey;\n\n if (isPickingStroke || isPickingBackground) {\n this.openEyeDropper({\n type: isPickingStroke ? \"stroke\" : \"background\"\n });\n } // -----------------------------------------------------------------------\n\n });\n this.onKeyUp = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d, _e;\n\n if (event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.SPACE) {\n if (this.state.viewModeEnabled || ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if (this.state.activeTool.type === \"selection\" || this.state.activeTool.type === \"lasso\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n isHoldingSpace = false;\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !this.state.isBindingEnabled) {\n this.setState({\n isBindingEnabled: true\n });\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isArrowKey)(event.key)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.bindOrUnbindLinearElements)(this.scene.getSelectedElements(this.state).filter(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state), (_c = (_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.selectedPointsIndices) !== null && _c !== void 0 ? _c : [], this.scene, this.state.zoom);\n this.setState({\n suggestedBindings: []\n });\n }\n\n if (!event.altKey) {\n if (this.flowChartNavigator.isExploring) {\n this.flowChartNavigator.clear();\n this.syncActionResult({\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n }\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if (this.flowChartCreator.isCreatingChart) {\n if ((_d = this.flowChartCreator.pendingNodes) === null || _d === void 0 ? void 0 : _d.length) {\n this.scene.insertElements(this.flowChartCreator.pendingNodes);\n }\n\n const firstNode = (_e = this.flowChartCreator.pendingNodes) === null || _e === void 0 ? void 0 : _e[0];\n\n if (firstNode) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [firstNode.id]: true\n }, prevState)\n }));\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementCompletelyInViewport)([firstNode], this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, {\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n zoom: this.state.zoom\n }, this.scene.getNonDeletedElementsMap(), this.getEditorUIOffsets())) {\n this.scrollToContent(firstNode, {\n animate: true,\n duration: 300,\n canvasOffsets: this.getEditorUIOffsets()\n });\n }\n }\n\n this.flowChartCreator.clear();\n this.syncActionResult({\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n }\n }\n }); // We purposely widen the `tool` type so this helper can be called with\n // any tool without having to type check it\n\n this.isToolSupported = tool => {\n var _a;\n\n return ((_a = this.props.UIOptions.tools) === null || _a === void 0 ? void 0 : _a[tool]) !== false;\n };\n\n this.setActiveTool = (tool, keepSelection = false) => {\n if (!this.isToolSupported(tool.type)) {\n console.warn(`\"${tool.type}\" tool is disabled via \"UIOptions.canvasActions.tools.${tool.type}\"`);\n return;\n }\n\n const nextActiveTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, tool);\n\n if (nextActiveTool.type === \"hand\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if (!isHoldingSpace) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, Object.assign(Object.assign({}, this.state), {\n activeTool: nextActiveTool\n }));\n }\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isToolIcon)(document.activeElement)) {\n this.focusContainer();\n }\n\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElementType)(nextActiveTool.type)) {\n this.setState({\n suggestedBindings: []\n });\n }\n\n if (nextActiveTool.type === \"image\") {\n this.onImageToolbarButtonClick();\n }\n\n setTimeout(() => {\n this.setState(prevState => {\n const commonResets = {\n snapLines: prevState.snapLines.length ? [] : prevState.snapLines,\n originSnapOffset: null,\n activeEmbeddable: null\n };\n\n if (nextActiveTool.type === \"freedraw\") {\n this.store.scheduleCapture();\n }\n\n if (nextActiveTool.type === \"lasso\") {\n return Object.assign(Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool\n }), keepSelection ? {} : {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n selectedGroupIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n }), commonResets);\n } else if (nextActiveTool.type !== \"selection\") {\n return Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool,\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextActiveTool.type === \"mermaid\" //zsviczian\n ? this.state.selectedElementIds : {}, prevState),\n selectedGroupIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n editingGroupId: null,\n multiElement: null\n }), commonResets);\n }\n\n return Object.assign(Object.assign(Object.assign({}, prevState), {\n activeTool: nextActiveTool\n }), commonResets);\n });\n }); //zsviczian added timeout because button won't select otherwise\n };\n\n this.setOpenDialog = dialogType => {\n this.setState({\n openDialog: dialogType\n });\n };\n\n this.setCursor = cursor => {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, cursor);\n };\n\n this.resetCursor = () => {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n };\n /**\r\n * returns whether user is making a gesture with >= 2 fingers (points)\r\n * on o touch screen (not on a trackpad). Currently only relates to Darwin\r\n * (iOS/iPadOS,MacOS), but may work on other devices in the future if\r\n * GestureEvent is standardized.\r\n */\n\n\n this.isTouchScreenMultiTouchGesture = () => {\n // we don't want to deselect when using trackpad, and multi-point gestures\n // only work on touch screens, so checking for >= pointers means we're on a\n // touchscreen\n return gesture.pointers.size >= 2;\n };\n\n this.getName = () => {\n return this.state.name || this.props.name || `${(0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getDateTime)()}`;\n }; // fires only on Safari\n\n\n this.onGestureStart = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n //zsviczian - start\n // If an embeddable is active and the pinch starts over it, let it handle the gesture.\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.shouldDisableZoom)(this.state)) {\n gesture.initialScale = null;\n return;\n }\n\n event.preventDefault(); // we only want to deselect on touch screens because user may have selected\n // elements by mistake while zooming\n\n if (this.isTouchScreenMultiTouchGesture()) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null\n });\n }\n\n gesture.initialScale = this.state.zoom.value;\n }); // fires only on Safari\n\n this.onGestureChange = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n //zsviczian\n if (!gesture.initialScale) {\n return;\n }\n\n event.preventDefault(); // onGestureChange only has zoom factor but not the center.\n // If we're on iPad or iPhone, then we recognize multi-touch and will\n // zoom in at the right location in the touchmove handler\n // (handleCanvasPointerMove).\n //\n // On Macbook trackpad, we don't have those events so will zoom in at the\n // current location instead.\n //\n // As such, bail from this handler on touch devices.\n\n if (this.isTouchScreenMultiTouchGesture()) {\n return;\n }\n\n const initialScale = gesture.initialScale;\n\n if (initialScale) {\n this.setState(state => Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_32__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getNormalizedZoom)(initialScale * event.scale)\n }, state)));\n }\n }); // fires only on Safari\n\n this.onGestureEnd = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n event.preventDefault(); // reselect elements only on touch screens (see onGestureStart)\n\n if (this.isTouchScreenMultiTouchGesture()) {\n this.setState({\n previousSelectedElementIds: {},\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(this.state.previousSelectedElementIds, this.state)\n });\n }\n\n gesture.initialScale = null;\n });\n\n this.startTextEditing = ({\n sceneX,\n sceneY,\n insertAtParentCenter = true,\n container,\n autoEdit = true\n }) => {\n var _a;\n\n let shouldBindToContainer = false;\n let parentCenterPosition = insertAtParentCenter && this.getTextWysiwygSnappedToCenterPosition(sceneX, sceneY, this.state, container);\n\n if (container && parentCenterPosition) {\n const boundTextElementToContainer = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(container, this.scene.getNonDeletedElementsMap());\n\n if (!boundTextElementToContainer) {\n shouldBindToContainer = true;\n }\n }\n\n let existingTextElement = null;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElements[0])) {\n existingTextElement = selectedElements[0];\n } else if (container) {\n existingTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(selectedElements[0], this.scene.getNonDeletedElementsMap());\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n\n const fontFamily = (existingTextElement === null || existingTextElement === void 0 ? void 0 : existingTextElement.fontFamily) || this.state.currentItemFontFamily;\n const lineHeight = (existingTextElement === null || existingTextElement === void 0 ? void 0 : existingTextElement.lineHeight) || (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getLineHeight)(fontFamily);\n const fontSize = (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_71__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value); //zsviczian\n\n if (!existingTextElement && shouldBindToContainer && container && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container)) {\n const fontString = {\n fontSize,\n fontFamily\n };\n const minWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getApproxMinLineWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFontString)(fontString), lineHeight);\n const minHeight = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getApproxMinLineHeight)(fontSize, lineHeight);\n const newHeight = Math.max(container.height, minHeight);\n const newWidth = Math.max(container.width, minWidth);\n this.scene.mutateElement(container, {\n height: newHeight,\n width: newWidth\n });\n sceneX = container.x + newWidth / 2;\n sceneY = container.y + newHeight / 2;\n\n if (parentCenterPosition) {\n parentCenterPosition = this.getTextWysiwygSnappedToCenterPosition(sceneX, sceneY, this.state, container);\n }\n }\n\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: sceneX,\n y: sceneY\n });\n const element = existingTextElement || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newTextElement)({\n x: parentCenterPosition ? parentCenterPosition.elementCenterX : sceneX,\n y: parentCenterPosition ? parentCenterPosition.elementCenterY : sceneY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n text: \"\",\n rawText: \"\",\n fontSize,\n fontFamily,\n textAlign: parentCenterPosition ? \"center\" : this.state.currentItemTextAlign,\n verticalAlign: parentCenterPosition ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.VERTICAL_ALIGN.MIDDLE : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_VERTICAL_ALIGN,\n containerId: shouldBindToContainer ? container === null || container === void 0 ? void 0 : container.id : undefined,\n groupIds: (_a = container === null || container === void 0 ? void 0 : container.groupIds) !== null && _a !== void 0 ? _a : [],\n lineHeight,\n angle: container ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(container) ? 0 : container.angle : 0,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n\n if (!existingTextElement && shouldBindToContainer && container) {\n this.scene.mutateElement(container, {\n boundElements: (container.boundElements || []).concat({\n type: \"text\",\n id: element.id\n })\n });\n }\n\n this.setState({\n editingTextElement: element\n });\n\n if (!existingTextElement) {\n if (container && shouldBindToContainer) {\n const containerIndex = this.scene.getElementIndex(container.id);\n this.scene.insertElementAtIndex(element, containerIndex + 1);\n } else {\n this.scene.insertElement(element);\n }\n }\n\n if (autoEdit || existingTextElement || container) {\n this.handleTextWysiwyg(element, {\n isExistingElement: !!existingTextElement\n });\n } else {\n this.setState({\n newElement: element,\n multiElement: null\n });\n }\n };\n\n this.debounceDoubleClickTimestamp = 0; //zsviczian\n\n this.startImageCropping = image => {\n this.store.scheduleCapture();\n this.setState({\n croppingElementId: image.id\n });\n };\n\n this.finishImageCropping = () => {\n if (this.state.croppingElementId) {\n this.store.scheduleCapture();\n this.setState({\n croppingElementId: null\n });\n }\n };\n\n this.handleCanvasDoubleClick = event => {\n var _a, _b, _c, _d; // case: double-clicking with arrow/line tool selected would both create\n // text and enter multiElement mode\n\n\n if (this.state.multiElement) {\n return;\n }\n\n if ( //zsviczian - double click eraser\n this.state.penMode && (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.allowDoubleTapEraser)() && ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a.pointerType) === \"touch\" && this.state.activeTool.type !== \"selection\") {\n const now = Date.now();\n\n if (now - this.debounceDoubleClickTimestamp < 200) {\n //handleCanvasDoubleClick click fires twice in case of touch.\n //Once from the onTouchStart event handler, once from the double click event handler\n return;\n }\n\n this.debounceDoubleClickTimestamp = now;\n this.updateScene(_actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.actionToggleEraserTool.perform([], this.state, null, this));\n return;\n } // zsviczian - end\n // we should only be able to double click when mode is selection\n\n\n if (this.state.activeTool.type !== this.defaultSelectionTool) {\n return;\n }\n\n const selectedElements = this.scene.getSelectedElements(this.state);\n let {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0])) {\n const selectedLinearElement = selectedElements[0];\n\n if ((event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isSimpleArrow)(selectedLinearElement) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedLinearElement)) && (!((_b = this.state.selectedLinearElement) === null || _b === void 0 ? void 0 : _b.isEditing) || this.state.selectedLinearElement.elementId !== selectedLinearElement.id)) {\n // Use the proper action to ensure immediate history capture\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n return;\n } else if (this.state.selectedLinearElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0])) {\n const hitCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(this.state.selectedLinearElement, {\n x: sceneX,\n y: sceneY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const midPoint = hitCoords ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, hitCoords, this.scene.getNonDeletedElementsMap()) : -1;\n\n if (midPoint && midPoint > -1) {\n this.store.scheduleCapture();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.deleteFixedSegment(selectedElements[0], this.scene, midPoint);\n const nextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: null\n }), {\n x: sceneX,\n y: sceneY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const nextIndex = nextCoords ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, nextCoords, this.scene.getNonDeletedElementsMap()) : null;\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n pointerDownState: Object.assign(Object.assign({}, this.state.selectedLinearElement.pointerDownState), {\n segmentMidpoint: {\n index: nextIndex,\n value: hitCoords,\n added: false\n }\n }),\n segmentMidPointHoveredCoords: nextCoords\n })\n });\n return;\n }\n } else if (((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.isEditing) && this.state.selectedLinearElement.elementId === selectedLinearElement.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedLinearElement)) {\n return;\n }\n }\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(selectedElements[0])) {\n this.startImageCropping(selectedElements[0]);\n return;\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n const selectedGroupIds = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectedGroupIds)(this.state);\n\n if (selectedGroupIds.length > 0) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n const selectedGroupId = hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectedGroupIdForElement)(hitElement, this.state.selectedGroupIds);\n\n if (selectedGroupId) {\n this.store.scheduleCapture();\n this.setState(prevState => Object.assign(Object.assign({}, prevState), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: selectedGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this)));\n return;\n }\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n\n if (!event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] && !this.state.viewModeEnabled) {\n const hitElement = this.getElementAtPosition(sceneX, sceneY);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement)) {\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"active\"\n }\n });\n return;\n } // shouldn't edit/create text when inside line editor (often false positive)\n\n\n if (!((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing)) {\n const container = this.getTextBindableContainerAtPosition(sceneX, sceneY);\n\n if (container) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hasBoundTextElement)(container) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isTransparent)(container.backgroundColor) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(sceneX, sceneY),\n element: container,\n elementsMap: this.scene.getNonDeletedElementsMap(),\n threshold: this.getElementHitThreshold(container)\n })) {\n const midPoint = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerCenter)(container, this.state, this.scene.getNonDeletedElementsMap());\n sceneX = midPoint.x;\n sceneY = midPoint.y;\n }\n } //zsviczian Disable double click text create, but allow double click edit\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.disableDoubleClickTextEditing)()) {\n let existingTextElement = null;\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(selectedElements[0])) {\n existingTextElement = selectedElements[0];\n } else if (container) {\n existingTextElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getBoundTextElement)(selectedElements[0], this.scene.getNonDeletedElementsMap());\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n } else {\n existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);\n }\n\n if (!existingTextElement) {\n return;\n }\n }\n\n this.startTextEditing({\n sceneX,\n sceneY,\n insertAtParentCenter: !event.altKey,\n container\n });\n }\n }\n };\n\n this.getElementLinkAtPosition = (scenePointer, hitElementMightBeLocked) => {\n if (hitElementMightBeLocked && hitElementMightBeLocked.locked) {\n return undefined;\n }\n\n const elements = this.scene.getNonDeletedElements();\n let hitElementIndex = -1;\n\n for (let index = elements.length - 1; index >= 0; index--) {\n const element = elements[index];\n\n if (hitElementMightBeLocked && element.id === hitElementMightBeLocked.id) {\n hitElementIndex = index;\n }\n\n if (element.link && index >= hitElementIndex && (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_64__.isPointHittingLink)(element, this.scene.getNonDeletedElementsMap(), this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y), this.device.editor.isMobile)) {\n return element;\n }\n }\n };\n\n this.redirectToLink = (event, isTouchScreen) => {\n const draggedDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(this.lastPointerDownEvent.clientX, this.lastPointerDownEvent.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(this.lastPointerUpEvent.clientX, this.lastPointerUpEvent.clientY));\n\n if (!this.hitLinkElement || draggedDistance > _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DRAGGING_THRESHOLD) {\n return;\n }\n\n const lastPointerDownCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(this.lastPointerDownEvent, this.state);\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const lastPointerDownHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_64__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerDownCoords.x, lastPointerDownCoords.y), this.device.editor.isMobile);\n const lastPointerUpCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(this.lastPointerUpEvent, this.state);\n const lastPointerUpHittingLinkIcon = (0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_64__.isPointHittingLink)(this.hitLinkElement, elementsMap, this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastPointerUpCoords.x, lastPointerUpCoords.y), this.device.editor.isMobile);\n\n if (lastPointerDownHittingLinkIcon && lastPointerUpHittingLinkIcon) {\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_35__.hideHyperlinkToolip)();\n let url = this.hitLinkElement.link;\n\n if (url) {\n url = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeLink)(url);\n let customEvent;\n\n if (this.props.onLinkOpen) {\n customEvent = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.wrapEvent)(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.EXCALIDRAW_LINK, event.nativeEvent);\n this.props.onLinkOpen(Object.assign(Object.assign({}, this.hitLinkElement), {\n link: url\n }), customEvent);\n }\n\n if (!(customEvent === null || customEvent === void 0 ? void 0 : customEvent.defaultPrevented)) {\n const target = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isLocalLink)(url) ? \"_self\" : \"_blank\";\n const newWindow = window.open(undefined, target); // https://mathiasbynens.github.io/rel-noopener/\n\n if (newWindow) {\n newWindow.opener = null;\n newWindow.location = url;\n }\n }\n }\n }\n };\n\n this.getTopLayerFrameAtSceneCoords = sceneCoords => {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const frames = this.scene.getNonDeletedFramesLikes().filter(frame => !frame.locked && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isCursorInFrame)(sceneCoords, frame, elementsMap) && frame.frameRole !== \"marker\");\n return frames.length ? frames[frames.length - 1] : null;\n };\n\n this.handleCanvasPointerMove = event => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n\n this.savePointer(event.clientX, event.clientY, this.state.cursorButton);\n this.lastPointerMoveEvent = event.nativeEvent;\n\n if (gesture.pointers.has(event.pointerId)) {\n gesture.pointers.set(event.pointerId, {\n x: event.clientX,\n y: event.clientY\n });\n }\n\n const initialScale = gesture.initialScale;\n\n if (gesture.pointers.size === 2 && gesture.lastCenter && initialScale && gesture.initialDistance) {\n const center = (0,_gesture__WEBPACK_IMPORTED_MODULE_28__.getCenter)(gesture.pointers);\n const deltaX = center.x - gesture.lastCenter.x;\n const deltaY = center.y - gesture.lastCenter.y;\n gesture.lastCenter = center;\n const distance = (0,_gesture__WEBPACK_IMPORTED_MODULE_28__.getDistance)(Array.from(gesture.pointers.values()));\n const scaleFactor = !this.state.allowPinchZoom && //zsviczian\n this.state.activeTool.type === \"freedraw\" && this.state.penMode ? 1 : distance / gesture.initialDistance;\n const nextZoom = scaleFactor ? (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getNormalizedZoom)(initialScale * scaleFactor) : this.state.zoom.value;\n this.setState(state => {\n const zoomState = (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_32__.getStateForZoom)({\n viewportX: center.x,\n viewportY: center.y,\n nextZoom\n }, state);\n this.translateCanvas({\n zoom: zoomState.zoom,\n // 2x multiplier is just a magic number that makes this work correctly\n // on touchscreen devices (note: if we get report that panning is slower/faster\n // than actual movement, consider swapping with devicePixelRatio)\n scrollX: zoomState.scrollX + 2 * (deltaX / nextZoom),\n scrollY: zoomState.scrollY + 2 * (deltaY / nextZoom),\n shouldCacheIgnoreZoom: true\n });\n });\n this.resetShouldCacheIgnoreZoomDebounced();\n } else {\n gesture.lastCenter = gesture.initialDistance = gesture.initialScale = null;\n }\n\n if (isHoldingSpace || isPanning || isDraggingScrollBar || (0,_appState__WEBPACK_IMPORTED_MODULE_23__.isHandToolActive)(this.state)) {\n return;\n }\n\n const isPointerOverScrollBars = (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_47__.isOverScrollBars)(currentScrollBars, event.clientX - this.state.offsetLeft, event.clientY - this.state.offsetTop);\n const isOverScrollBar = isPointerOverScrollBars.isOverEither;\n const isPenFreedraw = this.state.activeTool.type === \"freedraw\" && event.pointerType === \"pen\"; //zsviczian\n\n if (!this.state.newElement && !this.state.selectionElement && !this.state.selectedElementsAreBeingDragged && !this.state.multiElement) {\n if (isOverScrollBar) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n } else if (isPenFreedraw && this.interactiveCanvas && (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.hideFreedrawPenmodeCursor)()) {\n //zsviczian https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1659\n this.interactiveCanvas.style.cursor = \"none\";\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n }\n\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const {\n x: scenePointerX,\n y: scenePointerY\n } = scenePointer;\n\n if (!this.state.newElement && (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.isActiveToolNonLinearSnappable)(this.state.activeTool.type)) {\n const {\n originOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.getSnapLinesAtPointer)(this.scene.getNonDeletedElements(), this, {\n x: scenePointerX,\n y: scenePointerY\n }, event, this.scene.getNonDeletedElementsMap());\n this.setState(prevState => {\n const nextSnapLines = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.snapLines, snapLines);\n const nextOriginOffset = prevState.originSnapOffset ? (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.originSnapOffset, originOffset) : originOffset;\n\n if (prevState.snapLines === nextSnapLines && prevState.originSnapOffset === nextOriginOffset) {\n return null;\n }\n\n return {\n snapLines: nextSnapLines,\n originSnapOffset: nextOriginOffset\n };\n });\n } else if (!this.state.newElement && !this.state.selectedElementsAreBeingDragged && !this.state.selectionElement) {\n this.setState(prevState => {\n if (prevState.snapLines.length) {\n return {\n snapLines: []\n };\n }\n\n return null;\n });\n }\n\n if (((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && !this.state.selectedLinearElement.isDragging) {\n const editingLinearElement = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerMove(event, scenePointerX, scenePointerY, this);\n const linearElement = editingLinearElement ? this.scene.getElement(editingLinearElement.elementId) : null;\n\n if (editingLinearElement && editingLinearElement !== this.state.selectedLinearElement) {\n // Since we are reading from previous state which is not possible with\n // automatic batching in React 18 hence using flush sync to synchronously\n // update the state. Check https://github.com/excalidraw/excalidraw/pull/5508 for more details.\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n selectedLinearElement: editingLinearElement\n });\n });\n }\n\n if ((editingLinearElement === null || editingLinearElement === void 0 ? void 0 : editingLinearElement.lastUncommittedPoint) != null && linearElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElementType)(linearElement.type)) {\n this.maybeSuggestBindingAtCursor(scenePointer, editingLinearElement.elbowed);\n } else if (this.state.suggestedBindings.length) {\n this.setState({\n suggestedBindings: []\n });\n }\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElementType)(this.state.activeTool.type)) {\n // Hovering with a selected tool or creating new linear element via click\n // and point\n const {\n newElement\n } = this.state;\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(newElement, false)) {\n this.setState({\n suggestedBindings: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeSuggestBindingsForLinearElementAtCoords)(newElement, [scenePointer], this.scene, this.state.zoom, this.state.startBoundElement)\n });\n } else {\n this.maybeSuggestBindingAtCursor(scenePointer, false);\n }\n }\n\n if (this.state.multiElement) {\n const {\n multiElement\n } = this.state;\n const {\n x: rx,\n y: ry\n } = multiElement;\n const {\n points,\n lastCommittedPoint\n } = multiElement;\n const lastPoint = points[points.length - 1];\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n\n if (lastPoint === lastCommittedPoint) {\n // if we haven't yet created a temp point and we're beyond commit-zone\n // threshold, add a point\n if ((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry), lastPoint) >= _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.LINE_CONFIRM_THRESHOLD) {\n this.scene.mutateElement(multiElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry)]\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER); // in this branch, we're inside the commit zone, and no uncommitted\n // point exists. Thus do nothing (don't add/remove points).\n }\n } else if (points.length > 2 && lastCommittedPoint && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX - rx, scenePointerY - ry), lastCommittedPoint) < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.LINE_CONFIRM_THRESHOLD) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n this.scene.mutateElement(multiElement, {\n points: points.slice(0, -1)\n }, {\n informMutation: false,\n isDragging: false\n });\n } else {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(scenePointerX, scenePointerY, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(multiElement) ? null : this.getEffectiveGridSize());\n const [lastCommittedX, lastCommittedY] = (_b = multiElement === null || multiElement === void 0 ? void 0 : multiElement.lastCommittedPoint) !== null && _b !== void 0 ? _b : [0, 0];\n let dxFromLastCommitted = gridX - rx - lastCommittedX;\n let dyFromLastCommitted = gridY - ry - lastCommittedY;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldRotateWithDiscreteAngle)(event)) {\n ({\n width: dxFromLastCommitted,\n height: dyFromLastCommitted\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLockedLinearCursorAlignSize)( // actual coordinate of the last committed point\n lastCommittedX + rx, lastCommittedY + ry, // cursor-grid coordinate\n gridX, gridY));\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isPathALoop)(points, this.state.zoom.value)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } // update last uncommitted point\n\n\n this.scene.mutateElement(multiElement, {\n points: [...points.slice(0, -1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(lastCommittedX + dxFromLastCommitted, lastCommittedY + dyFromLastCommitted)]\n }, {\n isDragging: true,\n informMutation: false\n }); // in this path, we're mutating multiElement to reflect\n // how it will be after adding pointer position as the next point\n // trigger update here so that new element canvas renders again to reflect this\n\n this.triggerRender(false);\n }\n\n return;\n }\n\n const hasDeselectedButton = Boolean(event.buttons);\n\n if (hasDeselectedButton || this.state.activeTool.type !== \"selection\" && this.state.activeTool.type !== \"lasso\" && this.state.activeTool.type !== \"text\" && this.state.activeTool.type !== \"eraser\") {\n return;\n }\n\n const elements = this.scene.getNonDeletedElements();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1 && !isOverScrollBar && !((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.isEditing)) {\n // for linear elements, we'd like to prioritize point dragging over edge resizing\n // therefore, we update and check hovered point index first\n if (this.state.selectedLinearElement) {\n this.handleHoverSelectedLinearElement(this.state.selectedLinearElement, scenePointerX, scenePointerY);\n }\n\n if ((!this.state.selectedLinearElement || this.state.selectedLinearElement.hoverPointIndex === -1) && ((_d = this.state.openDialog) === null || _d === void 0 ? void 0 : _d.name) !== \"elementLinkSelector\" && !(selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0]))) {\n const elementWithTransformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementWithTransformHandleType)(elements, this.state, scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.device);\n\n if (elementWithTransformHandleType && elementWithTransformHandleType.transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCursorForResizingElement)(elementWithTransformHandleType));\n return;\n }\n }\n } else if (selectedElements.length > 1 && !isOverScrollBar && ((_e = this.state.openDialog) === null || _e === void 0 ? void 0 : _e.name) !== \"elementLinkSelector\") {\n const transformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getTransformHandleTypeFromCoords)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements), scenePointerX, scenePointerY, this.state.zoom, event.pointerType, this.device);\n\n if (transformHandleType) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCursorForResizingElement)({\n transformHandleType\n }));\n return;\n }\n }\n\n const hitElementMightBeLocked = this.getElementAtPosition(scenePointerX, scenePointerY, {\n preferSelected: true,\n includeLockedElements: true\n });\n let hitElement = null;\n\n if (hitElementMightBeLocked && hitElementMightBeLocked.locked) {\n hitElement = null;\n } else {\n hitElement = hitElementMightBeLocked;\n }\n\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElementMightBeLocked);\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state)) {\n return;\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_35__.showHyperlinkTooltip)(this.hitLinkElement, this.state, this.scene.getNonDeletedElementsMap());\n\n if (this.props.onLinkHover) {\n this.props.onLinkHover(this.hitLinkElement, event);\n } //zsviczian\n\n } else {\n (0,_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_35__.hideHyperlinkToolip)();\n\n if (hitElement && (hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(hitElement)) && this.state.selectedElementIds[hitElement.id] && !this.state.contextMenu && !this.state.showHyperlinkPopup) {\n this.setState({\n showHyperlinkPopup: \"info\"\n });\n } else if (this.state.activeTool.type === \"text\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(hitElement) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.TEXT : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.CROSSHAIR);\n } else if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else if (((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n } else if (isOverScrollBar) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n } else if ( // if using cmd/ctrl, we're not dragging\n !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if ((hitElement || this.isHittingCommonBoundingBoxOfSelectedElements(scenePointer, selectedElements)) && !(hitElement === null || hitElement === void 0 ? void 0 : hitElement.locked)) {\n if (hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, event, scenePointerX, scenePointerY)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n this.setState({\n activeEmbeddable: {\n element: hitElement,\n state: \"hover\"\n }\n });\n } else if (!hitElement || // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(hitElement) || !(hitElement.startBinding || hitElement.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || selectedElements.length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\n\n if (((_g = this.state.activeEmbeddable) === null || _g === void 0 ? void 0 : _g.state) === \"hover\") {\n this.setState({\n activeEmbeddable: null\n });\n }\n }\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n }\n\n if (this.state.selectedLinearElement) {\n this.handleHoverSelectedLinearElement(this.state.selectedLinearElement, scenePointerX, scenePointerY);\n }\n }\n\n if (((_h = this.state.openDialog) === null || _h === void 0 ? void 0 : _h.name) === \"elementLinkSelector\" && hitElement) {\n this.setState(prevState => {\n return {\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.hoveredElementIds, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this).selectedElementIds)\n };\n });\n } else if (((_j = this.state.openDialog) === null || _j === void 0 ? void 0 : _j.name) === \"elementLinkSelector\" && !hitElement) {\n this.setState(prevState => ({\n hoveredElementIds: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.hoveredElementIds, {})\n }));\n }\n };\n\n this.handleEraser = (event, scenePointer) => {\n const elementsToErase = this.eraserTrail.addPointToPath(scenePointer.x, scenePointer.y, event.altKey);\n this.elementsPendingErasure = new Set(elementsToErase);\n this.triggerRender();\n }; // set touch moving for mobile context menu\n\n\n this.handleTouchMove = event => {\n this.resetContextMenuTimer(); //zsviczian\n };\n\n this.handleCanvasPointerDown = event => {\n var _a, _b, _c, _d, _e; //mfuria #329. Right-click pan support when enabled via host plugin setting\n\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.isPanWithRightMouseEnabled)() && event.pointerType === \"mouse\" && event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.SECONDARY && !this.state.editingTextElement) {\n // prevent native context menu\n const onContextMenu = e => {\n e.preventDefault();\n };\n\n window.addEventListener('contextmenu', onContextMenu, {\n once: true\n }); // Start right-click panning\n\n this.startRightClickPanning(event);\n return;\n } //zsviczian - begin\n\n\n const isInsideEmbeddableContainer = !!((_b = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest) === null || _b === void 0 ? void 0 : _b.call(_a, \".excalidraw__embeddable-container\"));\n\n if (!isInsideEmbeddableContainer) {\n this.focusContainer();\n } //zsviczian - end\n\n\n const target = event.target; // capture subsequent pointer events to the canvas\n // this makes other elements non-interactive until pointer up\n\n if (target.setPointerCapture) {\n target.setPointerCapture(event.pointerId);\n }\n\n this.maybeCleanupAfterMissingPointerUp(event.nativeEvent);\n this.maybeUnfollowRemoteUser();\n\n if (this.state.searchMatches) {\n this.setState(state => {\n return {\n searchMatches: state.searchMatches && {\n focusedId: null,\n matches: state.searchMatches.matches.map(searchMatch => Object.assign(Object.assign({}, searchMatch), {\n focus: false\n }))\n }\n };\n });\n this.updateEditorAtom(_SearchMenu__WEBPACK_IMPORTED_MODULE_60__.searchItemInFocusAtom, null);\n }\n\n if (_editor_jotai__WEBPACK_IMPORTED_MODULE_37__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom)) {\n this.updateEditorAtom(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom, null);\n } // since contextMenu options are potentially evaluated on each render,\n // and an contextMenu action may depend on selection state, we must\n // close the contextMenu before we update the selection on pointerDown\n // (e.g. resetting selection)\n\n\n if (this.state.contextMenu) {\n this.setState({\n contextMenu: null\n });\n }\n\n if (this.state.snapLines) {\n this.setAppState({\n snapLines: []\n });\n }\n\n this.updateGestureOnPointerDown(event); // if dragging element is freedraw and another pointerdown event occurs\n // a second finger is on the screen\n // discard the freedraw element if it is very short because it is likely\n // just a spike, otherwise finalize the freedraw element when the second\n // finger is lifted\n\n if (event.pointerType === \"touch\" && this.state.newElement && this.state.newElement.type === \"freedraw\") {\n const element = this.state.newElement;\n this.updateScene(Object.assign(Object.assign({}, element.points.length < 10 ? {\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== element.id)\n } : {}), {\n appState: {\n newElement: null,\n editingTextElement: null,\n startBoundElement: null,\n suggestedBindings: [],\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.keys(this.state.selectedElementIds).filter(key => key !== element.id).reduce((obj, key) => {\n obj[key] = this.state.selectedElementIds[key];\n return obj;\n }, {}), this.state)\n },\n captureUpdate: ((_c = this.state.openDialog) === null || _c === void 0 ? void 0 : _c.name) === \"elementLinkSelector\" ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.EVENTUALLY : _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER\n }));\n return;\n } // remove any active selection when we start to interact with canvas\n // (mainly, we care about removing selection outside the component which\n // would prevent our copy handling otherwise)\n\n\n const selection = document.getSelection();\n\n if (selection === null || selection === void 0 ? void 0 : selection.anchorNode) {\n selection.removeAllRanges();\n }\n\n this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(event); //fires only once, if pen is detected, penMode is enabled\n //the user can disable this by toggling the penMode button\n\n if (!this.state.penDetected && event.pointerType === \"pen\") {\n this.setState(prevState => {\n return {\n penMode: true,\n penDetected: true\n };\n });\n }\n\n if (!this.device.isTouchScreen && [\"pen\", \"touch\"].includes(event.pointerType)) {\n this.device = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateObject)(this.device, {\n isTouchScreen: true\n });\n }\n\n if (isPanning) {\n return;\n }\n\n this.lastPointerDownEvent = event; // we must exit before we set `cursorButton` state and `savePointer`\n // else it will send pointer state & laser pointer events in collab when\n // panning\n\n /*if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {\r\n return;\r\n }*/\n //zsviczian this broke on pointer down in onPointerUpdate\n\n this.setState({\n lastPointerDownWith: event.pointerType,\n cursorButton: \"down\"\n });\n this.savePointer(event.clientX, event.clientY, \"down\");\n\n if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {\n return;\n } //zsviczian moved it here, because else pointer down in onPointerUpdate did not work\n\n\n if (event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.ERASER && this.state.activeTool.type !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.eraser) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.eraser,\n lastActiveToolBeforeEraser: this.state.activeTool\n })\n }, () => {\n this.handleCanvasPointerDown(event);\n\n const onPointerUp = () => {\n unsubPointerUp();\n unsubCleanup === null || unsubCleanup === void 0 ? void 0 : unsubCleanup();\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, Object.assign(Object.assign({}, this.state.activeTool.lastActiveTool || {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.selection\n }), {\n lastActiveToolBeforeEraser: null\n }))\n });\n }\n };\n\n const unsubPointerUp = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp, {\n once: true\n });\n let unsubCleanup; // subscribe inside rAF lest it'd be triggered on the same pointerdown\n // if we start erasing while coming from blurred document since\n // we cleanup pointer events on focus\n\n requestAnimationFrame(() => {\n unsubCleanup = this.missingPointerEventCleanupEmitter.once(onPointerUp);\n });\n });\n return;\n } // only handle left mouse button or touch\n\n\n if (event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.MAIN && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.TOUCH && event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.ERASER) {\n return;\n } // don't select while panning\n\n\n if (gesture.pointers.size > 1) {\n return;\n } // State for the duration of a pointer interaction, which starts with a\n // pointerDown event, ends with a pointerUp event (or another pointerDown)\n\n\n const pointerDownState = this.initialPointerDownState(event);\n this.setState({\n selectedElementsAreBeingDragged: false\n });\n\n if (this.handleDraggingScrollBar(event, pointerDownState)) {\n return;\n }\n\n this.clearSelectionIfNotUsingSelection();\n this.updateBindingEnabledOnPointerMove(event);\n\n if (this.handleSelectionOnPointerDown(event, pointerDownState)) {\n return;\n }\n\n const allowOnPointerDown = !this.state.penMode || event.pointerType !== \"touch\" || this.state.activeTool.type === \"selection\" || this.state.activeTool.type === \"lasso\" || this.state.activeTool.type === \"text\" || this.state.activeTool.type === \"image\";\n\n if (!allowOnPointerDown) {\n return;\n }\n\n if (this.state.activeTool.type === \"lasso\") {\n const hitSelectedElement = pointerDownState.hit.element && this.isASelectedElement(pointerDownState.hit.element);\n\n if (!pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements && !pointerDownState.resize.handleType && !hitSelectedElement) {\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey); // block dragging after lasso selection on PCs until the next pointer down\n // (on mobile or tablet, we want to allow user to drag immediately)\n\n pointerDownState.drag.blockDragging = !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)();\n } // only for mobile or tablet, if we hit an element, select it immediately like normal selection\n\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() && pointerDownState.hit.element && !hitSelectedElement) {\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [pointerDownState.hit.element.id]: true\n });\n const previouslySelectedElements = [];\n Object.keys(prevState.selectedElementIds).forEach(id => {\n const element = this.scene.getElement(id);\n element && previouslySelectedElements.push(element);\n });\n const hitElement = pointerDownState.hit.element; // if hitElement is frame-like, deselect all of its elements\n // if they are selected\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getFrameChildren)(previouslySelectedElements, hitElement.id).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n } else if (hitElement.frameId) {\n // if hitElement is in a frame and its frame has been selected\n // disable selection for the given element\n if (nextSelectedElementIds[hitElement.frameId]) {\n delete nextSelectedElementIds[hitElement.id];\n }\n } else {\n // hitElement is neither a frame nor an element in a frame\n // but since hitElement could be in a group with some frames\n // this means selecting hitElement will have the frames selected as well\n // because we want to keep the invariant:\n // - frames and their elements are not selected at the same time\n // we deselect elements in those frames that were previously selected\n const groupIds = hitElement.groupIds;\n const framesInGroups = new Set(groupIds.flatMap(gid => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element)).map(frame => frame.id));\n\n if (framesInGroups.size > 0) {\n previouslySelectedElements.forEach(element => {\n if (element.frameId && framesInGroups.has(element.frameId)) {\n // deselect element and groups containing the element\n delete nextSelectedElementIds[element.id];\n element.groupIds.flatMap(gid => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n }\n });\n }\n }\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n pointerDownState.hit.wasAddedToSelection = true;\n }\n } else if (this.state.activeTool.type === \"text\") {\n this.handleTextOnPointerDown(event, pointerDownState);\n } else if (this.state.activeTool.type === \"arrow\" || this.state.activeTool.type === \"line\") {\n this.handleLinearElementOnPointerDown(event, this.state.activeTool.type, pointerDownState);\n } else if (this.state.activeTool.type === \"freedraw\") {\n this.handleFreeDrawElementOnPointerDown(event, this.state.activeTool.type, pointerDownState);\n } else if (this.state.activeTool.type === \"custom\") {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n } else if (this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe) {\n this.createFrameElementOnPointerDown(pointerDownState, this.state.activeTool.type);\n } else if (this.state.activeTool.type === \"laser\") {\n this.laserTrails.startPath(pointerDownState.lastCoords.x, pointerDownState.lastCoords.y);\n } else if (this.state.activeTool.type !== \"eraser\" && this.state.activeTool.type !== \"hand\" && this.state.activeTool.type !== \"mermaid\" && //zsviczian\n this.state.activeTool.type !== \"image\") {\n this.createGenericElementOnPointerDown(this.state.activeTool.type, pointerDownState);\n }\n\n (_e = (_d = this.props) === null || _d === void 0 ? void 0 : _d.onPointerDown) === null || _e === void 0 ? void 0 : _e.call(_d, this.state.activeTool, pointerDownState);\n this.onPointerDownEmitter.trigger(this.state.activeTool, pointerDownState, event);\n\n if (this.state.activeTool.type === \"eraser\") {\n this.eraserTrail.startPath(pointerDownState.lastCoords.x, pointerDownState.lastCoords.y);\n }\n\n const onPointerMove = this.onPointerMoveFromPointerDownHandler(pointerDownState);\n const onPointerUp = this.onPointerUpFromPointerDownHandler(pointerDownState);\n const onKeyDown = this.onKeyDownFromPointerDownHandler(pointerDownState);\n const onKeyUp = this.onKeyUpFromPointerDownHandler(pointerDownState);\n this.missingPointerEventCleanupEmitter.once(_event => onPointerUp(_event || event.nativeEvent));\n\n if (!this.state.viewModeEnabled || this.state.activeTool.type === \"laser\") {\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, onKeyDown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYUP, onKeyUp);\n pointerDownState.eventListeners.onMove = onPointerMove;\n pointerDownState.eventListeners.onUp = onPointerUp;\n pointerDownState.eventListeners.onKeyUp = onKeyUp;\n pointerDownState.eventListeners.onKeyDown = onKeyDown;\n }\n };\n\n this.handleCanvasPointerUp = event => {\n var _a, _b;\n\n this.removePointer(event);\n this.lastPointerUpEvent = event;\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: event.clientX,\n clientY: event.clientY\n }, this.state);\n const clicklength = event.timeStamp - ((_b = (_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a.timeStamp) !== null && _b !== void 0 ? _b : 0);\n\n if (this.device.editor.isMobile && clicklength < 300) {\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, event, scenePointer.x, scenePointer.y)) {\n this.handleEmbeddableCenterClick(hitElement);\n return;\n }\n }\n\n if (this.device.isTouchScreen) {\n const hitElement = this.getElementAtPosition(scenePointer.x, scenePointer.y, {\n includeLockedElements: true\n });\n this.hitLinkElement = this.getElementLinkAtPosition(scenePointer, hitElement);\n }\n\n if (this.hitLinkElement && !this.state.selectedElementIds[this.hitLinkElement.id]) {\n if (clicklength < 300 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(this.hitLinkElement) && !(0,_hyperlink_helpers__WEBPACK_IMPORTED_MODULE_64__.isPointHittingLinkIcon)(this.hitLinkElement, this.scene.getNonDeletedElementsMap(), this.state, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointer.x, scenePointer.y))) {\n this.handleEmbeddableCenterClick(this.hitLinkElement);\n } else {\n this.redirectToLink(event, this.device.isTouchScreen);\n }\n } else if (this.state.viewModeEnabled) {\n this.setState({\n activeEmbeddable: null,\n selectedElementIds: {}\n });\n }\n };\n\n this.maybeOpenContextMenuAfterPointerDownOnTouchDevices = event => {\n // deal with opening context menu on touch devices\n if (event.pointerType === \"touch\") {\n invalidateContextMenu = false;\n\n if (touchTimeout) {\n // If there's already a touchTimeout, this means that there's another\n // touch down and we are doing another touch, so we shouldn't open the\n // context menu.\n invalidateContextMenu = true;\n } else {\n // open the context menu with the first touch's clientX and clientY\n // if the touch is not moving\n touchTimeout = window.setTimeout(() => {\n touchTimeout = 0;\n\n if (!invalidateContextMenu) {\n this.handleCanvasContextMenu(event);\n }\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOUCH_CTX_MENU_TIMEOUT);\n }\n }\n };\n\n this.resetContextMenuTimer = () => {\n clearTimeout(touchTimeout);\n touchTimeout = 0;\n invalidateContextMenu = false;\n };\n /**\r\n * pointerup may not fire in certian cases (user tabs away...), so in order\r\n * to properly cleanup pointerdown state, we need to fire any hanging\r\n * pointerup handlers manually\r\n */\n\n\n this.maybeCleanupAfterMissingPointerUp = event => {\n lastPointerUp === null || lastPointerUp === void 0 ? void 0 : lastPointerUp();\n this.missingPointerEventCleanupEmitter.trigger(event).clear();\n }; // Returns whether the event is a panning\n\n\n this.handleCanvasPanUsingWheelOrSpaceDrag = event => {\n if (!(gesture.pointers.size <= 1 && (event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.WHEEL || event.button === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.MAIN && isHoldingSpace || (0,_appState__WEBPACK_IMPORTED_MODULE_23__.isHandToolActive)(this.state) || //zsviczian\n (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.isTouchInPenMode)(this.state, event) || //!isLaserPointerActive added by zsviczian (but don't remember why....)\n this.state.viewModeEnabled && !(0,_appState__WEBPACK_IMPORTED_MODULE_23__.isLaserPointerActive)(this.state)))) {\n return false;\n }\n\n isPanning = true; // due to event.preventDefault below, container wouldn't get focus\n // automatically\n\n this.focusContainer(); // preventing defualt while text editing messes with cursor/focus\n\n if (!this.state.editingTextElement) {\n // necessary to prevent browser from scrolling the page if excalidraw\n // not full-page #4489\n //\n // as such, the above is broken when panning canvas while in wysiwyg\n event.preventDefault();\n }\n\n let nextPastePrevented = false;\n const isLinux = typeof window === undefined ? false : /Linux/.test(window.navigator.platform);\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRABBING);\n let {\n clientX: lastX,\n clientY: lastY\n } = event;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdatesThrottled)(event => {\n const deltaX = lastX - event.clientX;\n const deltaY = lastY - event.clientY;\n lastX = event.clientX;\n lastY = event.clientY;\n /*\r\n * Prevent paste event if we move while middle clicking on Linux.\r\n * See issue #1383.\r\n */\n\n if (isLinux && !nextPastePrevented && (Math.abs(deltaX) > 1 || Math.abs(deltaY) > 1)) {\n nextPastePrevented = true;\n /* Prevent the next paste event */\n\n const preventNextPaste = event => {\n document.body.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, preventNextPaste);\n event.stopPropagation();\n };\n /*\r\n * Reenable next paste in case of disabled middle click paste for\r\n * any reason:\r\n * - right click paste\r\n * - empty clipboard\r\n */\n\n\n const enableNextPaste = () => {\n setTimeout(() => {\n document.body.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, preventNextPaste);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, enableNextPaste);\n }, 100);\n };\n\n document.body.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, preventNextPaste);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, enableNextPaste);\n }\n\n this.translateCanvas({\n scrollX: this.state.scrollX - deltaX / this.state.zoom.value,\n scrollY: this.state.scrollY - deltaY / this.state.zoom.value\n });\n });\n const teardown = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(lastPointerUp = () => {\n lastPointerUp = null;\n isPanning = false;\n\n if (!isHoldingSpace) {\n if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n }\n\n this.setState({\n cursorButton: \"up\"\n });\n this.savePointer(event.clientX, event.clientY, \"up\");\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n onPointerMove.flush();\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove, {\n passive: true\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n return true;\n };\n\n this.clearSelectionIfNotUsingSelection = () => {\n if (this.state.activeTool.type !== \"selection\" && this.state.activeTool.type !== \"lasso\") {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n };\n /**\r\n * @returns whether the pointer event has been completely handled\r\n */\n\n\n this.handleSelectionOnPointerDown = (event, pointerDownState) => {\n var _a, _b, _c, _d, _e;\n\n if (this.state.activeTool.type === \"selection\" || this.state.activeTool.type === \"lasso\") {\n const elements = this.scene.getNonDeletedElements();\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1 && !((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0]) && !((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLineElement)(selectedElements[0]) && _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointIndexUnderCursor(selectedElements[0], elementsMap, this.state.zoom, pointerDownState.origin.x, pointerDownState.origin.y) !== -1) && !(this.state.selectedLinearElement && this.state.selectedLinearElement.hoverPointIndex !== -1)) {\n const elementWithTransformHandleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementWithTransformHandleType)(elements, this.state, pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.scene.getNonDeletedElementsMap(), this.device);\n\n if (elementWithTransformHandleType != null) {\n if (elementWithTransformHandleType.transformHandleType === \"rotation\") {\n this.setState({\n resizingElement: elementWithTransformHandleType.element\n });\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n } else if (this.state.croppingElementId) {\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n } else {\n this.setState({\n resizingElement: elementWithTransformHandleType.element\n });\n pointerDownState.resize.handleType = elementWithTransformHandleType.transformHandleType;\n }\n }\n } else if (selectedElements.length > 1) {\n pointerDownState.resize.handleType = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getTransformHandleTypeFromCoords)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements), pointerDownState.origin.x, pointerDownState.origin.y, this.state.zoom, event.pointerType, this.device);\n }\n\n if (pointerDownState.resize.handleType) {\n pointerDownState.resize.isResizing = true;\n pointerDownState.resize.offset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.tupleToCoors)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getResizeOffsetXY)(pointerDownState.resize.handleType, selectedElements, elementsMap, pointerDownState.origin.x, pointerDownState.origin.y));\n\n if (selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(selectedElements[0]) && selectedElements[0].points.length === 2) {\n pointerDownState.resize.arrowDirection = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getResizeArrowDirection)(pointerDownState.resize.handleType, selectedElements[0]);\n }\n } else {\n if (this.state.selectedLinearElement) {\n const linearElementEditor = this.state.selectedLinearElement;\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerDown(event, this, this.store, pointerDownState.origin, linearElementEditor, this.scene);\n\n if (ret.hitElement) {\n pointerDownState.hit.element = ret.hitElement;\n }\n\n if (ret.linearElementEditor) {\n this.setState({\n selectedLinearElement: ret.linearElementEditor\n });\n }\n\n if (ret.didAddPoint) {\n return true;\n }\n }\n\n const allHitElements = this.getElementsAtPosition(pointerDownState.origin.x, pointerDownState.origin.y, {\n includeLockedElements: true\n });\n const unlockedHitElements = allHitElements.filter(e => !e.locked); // Cannot set preferSelected in getElementAtPosition as we do in pointer move; consider:\n // A & B: both unlocked, A selected, B on top, A & B overlaps in some way\n // we want to select B when clicking on the overlapping area\n\n const hitElementMightBeLocked = this.getElementAtPosition(pointerDownState.origin.x, pointerDownState.origin.y, {\n allHitElements\n });\n\n if (!hitElementMightBeLocked || hitElementMightBeLocked.id !== this.state.activeLockedId) {\n this.setState({\n activeLockedId: null\n });\n }\n\n const isUnlockedHitElSelected = unlockedHitElements.some(el => this.state.selectedElementIds[el.id]); //zsviczian\n // Prioritize unlocked elements over locked ones\n\n if (!isUnlockedHitElSelected && unlockedHitElements.length > 0) {\n //zsviczian https://github.com/excalidraw/excalidraw/pull/9582\n // If there are unlocked elements, use the topmost one\n pointerDownState.hit.element = unlockedHitElements[unlockedHitElements.length - 1];\n } else if (hitElementMightBeLocked && hitElementMightBeLocked.locked && !isUnlockedHitElSelected //zsviczian\n ) {\n pointerDownState.hit.element = null;\n } else {\n // hitElement may already be set above, so check first\n pointerDownState.hit.element = (_b = pointerDownState.hit.element) !== null && _b !== void 0 ? _b : this.getElementAtPosition(pointerDownState.origin.x, pointerDownState.origin.y);\n }\n\n this.hitLinkElement = this.getElementLinkAtPosition(pointerDownState.origin, hitElementMightBeLocked);\n\n if (this.hitLinkElement) {\n return true;\n }\n\n if (this.state.croppingElementId && ((_c = pointerDownState.hit.element) === null || _c === void 0 ? void 0 : _c.id) !== this.state.croppingElementId) {\n this.finishImageCropping();\n }\n\n if (pointerDownState.hit.element) {\n // Early return if pointer is hitting link icon\n const hitLinkElement = this.getElementLinkAtPosition({\n x: pointerDownState.origin.x,\n y: pointerDownState.origin.y\n }, pointerDownState.hit.element);\n\n if (hitLinkElement) {\n return false;\n }\n } // For overlapped elements one position may hit\n // multiple elements\n\n\n pointerDownState.hit.allHitElements = unlockedHitElements;\n const hitElement = pointerDownState.hit.element;\n const someHitElementIsSelected = pointerDownState.hit.allHitElements.some(element => this.isASelectedElement(element));\n\n if ((hitElement === null || !someHitElementIsSelected) && !event.shiftKey && !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) {\n this.clearSelection(hitElement);\n }\n\n if ((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({\n [this.state.selectedLinearElement.elementId]: true\n }, this.state)\n }); // If we click on something\n } else if (hitElement != null) {\n // == deep selection ==\n // on CMD/CTRL, drill down to hit element regardless of groups etc.\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n if (event.altKey) {\n // ctrl + alt means we're lasso selecting - start lasso trail and switch to lasso tool\n // Close any open dialogs that might interfere with lasso selection\n if (((_e = this.state.openDialog) === null || _e === void 0 ? void 0 : _e.name) === \"elementLinkSelector\") {\n this.setOpenDialog(null);\n }\n\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n this.setActiveTool({\n type: \"lasso\",\n fromSelection: true\n });\n return false;\n }\n\n if (!this.state.selectedElementIds[hitElement.id]) {\n pointerDownState.hit.wasAddedToSelection = true;\n }\n\n this.setState(prevState => Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.editGroupForSelectedElement)(prevState, hitElement)), {\n previousSelectedElementIds: this.state.selectedElementIds\n })); // mark as not completely handled so as to allow dragging etc.\n\n return false;\n } // deselect if item is selected\n // if shift is not clicked, this will always return true\n // otherwise, it will trigger selection based on current\n // state of the box\n\n\n if (!this.state.selectedElementIds[hitElement.id]) {\n // if we are currently editing a group, exiting editing mode and deselect the group.\n if (this.state.editingGroupId && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInGroup)(hitElement, this.state.editingGroupId)) {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n } // Add hit element to selection. At this point if we're not holding\n // SHIFT the previously selected element(s) were deselected above\n // (make sure you use setState updater to use latest state)\n // With shift-selection, we want to make sure that frames and their containing\n // elements are not selected at the same time.\n\n\n if (!someHitElementIsSelected && !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) {\n this.setState(prevState => {\n var _a;\n\n let nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [hitElement.id]: true\n });\n const previouslySelectedElements = [];\n Object.keys(prevState.selectedElementIds).forEach(id => {\n const element = this.scene.getElement(id);\n element && previouslySelectedElements.push(element);\n }); // if hitElement is frame-like, deselect all of its elements\n // if they are selected\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getFrameChildren)(previouslySelectedElements, hitElement.id).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n } else if (hitElement.frameId) {\n // if hitElement is in a frame and its frame has been selected\n // disable selection for the given element\n if (nextSelectedElementIds[hitElement.frameId]) {\n delete nextSelectedElementIds[hitElement.id];\n }\n } else {\n // hitElement is neither a frame nor an element in a frame\n // but since hitElement could be in a group with some frames\n // this means selecting hitElement will have the frames selected as well\n // because we want to keep the invariant:\n // - frames and their elements are not selected at the same time\n // we deselect elements in those frames that were previously selected\n const groupIds = hitElement.groupIds;\n const framesInGroups = new Set(groupIds.flatMap(gid => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element)).map(frame => frame.id));\n\n if (framesInGroups.size > 0) {\n previouslySelectedElements.forEach(element => {\n if (element.frameId && framesInGroups.has(element.frameId)) {\n // deselect element and groups containing the element\n delete nextSelectedElementIds[element.id];\n element.groupIds.flatMap(gid => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n }\n });\n }\n } // Finally, in shape selection mode, we'd like to\n // keep only one shape or group selected at a time.\n // This means, if the hitElement is a different shape or group\n // than the previously selected ones, we deselect the previous ones\n // and select the hitElement\n\n\n if (((_a = prevState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n if (!hitElement.groupIds.some(gid => prevState.selectedGroupIds[gid])) {\n nextSelectedElementIds = {\n [hitElement.id]: true\n };\n }\n }\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n pointerDownState.hit.wasAddedToSelection = true;\n }\n }\n }\n\n this.setState({\n previousSelectedElementIds: this.state.selectedElementIds\n });\n }\n }\n\n return false;\n };\n\n this.handleTextOnPointerDown = (event, pointerDownState) => {\n // if we're currently still editing text, clicking outside\n // should only finalize it, not create another (irrespective\n // of state.activeTool.locked)\n if (this.state.editingTextElement) {\n return;\n }\n\n let sceneX = pointerDownState.origin.x;\n let sceneY = pointerDownState.origin.y;\n const element = this.getElementAtPosition(sceneX, sceneY, {\n includeBoundTextElement: true\n }); // FIXME\n\n let container = this.getTextBindableContainerAtPosition(sceneX, sceneY);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hasBoundTextElement)(element)) {\n container = element;\n sceneX = element.x + element.width / 2;\n sceneY = element.y + element.height / 2;\n }\n\n this.startTextEditing({\n sceneX,\n sceneY,\n insertAtParentCenter: !event.altKey,\n container,\n autoEdit: false\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n\n if (!this.state.activeTool.locked) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.defaultSelectionTool\n })\n });\n }\n };\n\n this.handleFreeDrawElementOnPointerDown = (event, elementType, pointerDownState) => {\n // Begin a mark capture. This does not have to update state yet.\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, null);\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n const strokeOptions = this.state.currentStrokeOptions; //zsviczian\n\n const simulatePressure = (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure //zsviczian\n ) ? false : event.pressure === 0.5;\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newFreeDrawElement)(Object.assign(Object.assign({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: null,\n simulatePressure,\n locked: false\n }, strokeOptions //zsviczian\n ? {\n customData: {\n strokeOptions\n }\n } : {}), {\n frameId: topLayerFrame ? topLayerFrame.id : null,\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0)],\n pressures: simulatePressure ? [] : [(strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure) ? 1 : event.pressure]\n })); //zsviczian\n\n if (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.highlighter) {\n this.scene.insertElement(element, 0);\n } else {\n this.scene.insertElement(element);\n }\n\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete nextSelectedElementIds[element.id];\n return {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextSelectedElementIds, prevState)\n };\n });\n const boundElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)(pointerDownState.origin, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom);\n this.setState({\n newElement: element,\n startBoundElement: boundElement,\n suggestedBindings: []\n });\n };\n\n this.insertIframeElement = ({\n sceneX,\n sceneY,\n width,\n height\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newIframeElement)({\n type: \"iframe\",\n x: gridX,\n y: gridY,\n strokeColor: \"transparent\",\n backgroundColor: \"transparent\",\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: this.getCurrentItemRoundness(\"iframe\"),\n opacity: this.state.currentItemOpacity,\n locked: false,\n width,\n height\n });\n this.scene.insertElement(element);\n return element;\n }; //create rectangle element with youtube top left on nearest grid point width / hight 640/360\n\n\n this.insertEmbeddableElement = ({\n sceneX,\n sceneY,\n link\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const embedLink = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)(link);\n\n if (!embedLink) {\n return;\n }\n\n if (embedLink.error instanceof URIError) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"toast.unrecognizedLinkFormat\"),\n closable: true\n });\n }\n\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newEmbeddableElement)({\n type: \"embeddable\",\n x: gridX,\n y: gridY,\n strokeColor: \"transparent\",\n backgroundColor: \"transparent\",\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: this.getCurrentItemRoundness(\"embeddable\"),\n opacity: this.state.currentItemOpacity,\n locked: false,\n width: embedLink.intrinsicSize.w,\n height: embedLink.intrinsicSize.h,\n link\n });\n this.scene.insertElement(element);\n return element;\n };\n\n this.newImagePlaceholder = ({\n sceneX,\n sceneY,\n addToFrameUnderCursor = true\n }) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(sceneX, sceneY, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const topLayerFrame = addToFrameUnderCursor ? this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n }) : null;\n const placeholderSize = 100 / this.state.zoom.value;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newImageElement)({\n type: \"image\",\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n roundness: null,\n opacity: this.state.currentItemOpacity,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null,\n x: gridX - placeholderSize / 2,\n y: gridY - placeholderSize / 2,\n width: placeholderSize,\n height: placeholderSize\n });\n };\n\n this.handleLinearElementOnPointerDown = (event, elementType, pointerDownState) => {\n if (this.state.multiElement) {\n const {\n multiElement\n } = this.state; // finalize if completing a loop\n\n if (multiElement.type === \"line\" && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isPathALoop)(multiElement.points, this.state.zoom.value)) {\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n return;\n } // Elbow arrows cannot be created by putting down points\n // only the start and end points can be defined\n\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(multiElement) && multiElement.points.length > 1) {\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n return;\n }\n\n const {\n x: rx,\n y: ry,\n lastCommittedPoint\n } = multiElement; // clicking inside commit zone → finalize arrow\n\n if (multiElement.points.length > 1 && lastCommittedPoint && (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x - rx, pointerDownState.origin.y - ry), lastCommittedPoint) < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.LINE_CONFIRM_THRESHOLD) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n return;\n }\n\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [multiElement.id]: true\n }), prevState)\n })); // clicking outside commit zone → update reference for last committed\n // point\n\n this.scene.mutateElement(multiElement, {\n lastCommittedPoint: multiElement.points[multiElement.points.length - 1]\n });\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } else {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n /* If arrow is pre-arrowheads, it will have undefined for both start and end arrowheads.\r\n If so, we want it to be null for start and \"arrow\" for end. If the linear item is not\r\n an arrow, we want it to be null for both. Otherwise, we want it to use the\r\n values from appState. */\n\n const {\n currentItemStartArrowhead,\n currentItemEndArrowhead\n } = this.state;\n const [startArrowhead, endArrowhead] = elementType === \"arrow\" ? [currentItemStartArrowhead, currentItemEndArrowhead] : [null, null];\n const element = elementType === \"arrow\" ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newArrowElement)({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.round ? {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : // note, roundness doesn't have any effect for elbow arrows,\n // but it's best to set it to null as well\n null,\n startArrowhead,\n endArrowhead,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null,\n elbowed: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.elbow,\n fixedSegments: this.state.currentItemArrowType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ARROW_TYPE.elbow ? [] : null\n }) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newLinearElement)({\n type: elementType,\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.state.currentItemRoundness === \"round\" ? {\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null,\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n });\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete nextSelectedElementIds[element.id];\n return {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextSelectedElementIds, prevState)\n };\n });\n this.scene.mutateElement(element, {\n points: [...element.points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0)]\n });\n const boundElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)(pointerDownState.origin, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element));\n this.scene.insertElement(element);\n this.setState({\n newElement: element,\n startBoundElement: boundElement,\n suggestedBindings: []\n });\n }\n };\n\n this.createGenericElementOnPointerDown = (elementType, pointerDownState) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x: gridX,\n y: gridY\n });\n const baseElementAttributes = {\n x: gridX,\n y: gridY,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n roundness: this.getCurrentItemRoundness(elementType),\n locked: false,\n frameId: topLayerFrame ? topLayerFrame.id : null\n };\n let element;\n\n if (elementType === \"embeddable\") {\n element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newEmbeddableElement)(Object.assign({\n type: \"embeddable\"\n }, baseElementAttributes));\n } else {\n element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElement)(Object.assign({\n type: elementType\n }, baseElementAttributes));\n }\n\n if (element.type === \"selection\") {\n this.setState({\n selectionElement: element\n });\n } else {\n this.scene.insertElement(element);\n this.setState({\n multiElement: null,\n newElement: element\n });\n }\n };\n\n this.createFrameElementOnPointerDown = (pointerDownState, type) => {\n var _a;\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerDownState.origin.x, pointerDownState.origin.y, ((_a = this.lastPointerDownEvent) === null || _a === void 0 ? void 0 : _a[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) ? null : this.getEffectiveGridSize());\n const constructorOpts = Object.assign(Object.assign(Object.assign({\n x: gridX,\n y: gridY,\n opacity: this.state.currentItemOpacity,\n locked: false\n }, type === \"frame\" && this.state.currentItemFrameRole ? {\n frameRole: this.state.currentItemFrameRole\n } : {}), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.FRAME_STYLE), this.state.frameColor ? {\n //zsviczian\n customData: {\n frameColor: this.state.frameColor\n }\n } : {});\n const frame = type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newMagicFrameElement)(constructorOpts) : (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newFrameElement)(constructorOpts, this.scene.getNonDeletedElements()); //zsviczian\n\n this.scene.insertElement(frame);\n this.setState({\n multiElement: null,\n newElement: frame\n });\n };\n\n this.restoreReadyToEraseElements = () => {\n this.elementsPendingErasure = new Set();\n this.triggerRender();\n };\n\n this.eraseElements = () => {\n let didChange = false;\n const elements = this.scene.getElementsIncludingDeleted().map(ele => {\n if (this.elementsPendingErasure.has(ele.id) || ele.frameId && this.elementsPendingErasure.has(ele.frameId) || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(ele) && this.elementsPendingErasure.has(ele.containerId)) {\n didChange = true;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(ele, {\n isDeleted: true\n });\n }\n\n return ele;\n });\n this.elementsPendingErasure = new Set();\n\n if (didChange) {\n this.store.scheduleCapture();\n this.scene.replaceAllElements(elements);\n }\n };\n\n this.initializeImage = async (placeholderImageElement, imageFile) => {\n var _a, _b, _c; // at this point this should be guaranteed image file, but we do this check\n // to satisfy TS down the line\n\n\n if (!(0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.isSupportedImageFile)(imageFile)) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.unsupportedFileType\"));\n }\n\n const mimeType = imageFile.type;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, \"wait\");\n\n if (mimeType === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg) {\n try {\n imageFile = (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.SVGStringToFile)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.normalizeSVG)(await imageFile.text()), imageFile.name);\n } catch (error) {\n console.warn(error);\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.svgImageInsertError\"));\n }\n } // generate image id (by default the file digest) before any\n // resizing/compression takes place to keep it more portable\n\n\n const fileId = await (((_b = (_a = this.props).generateIdForFile) === null || _b === void 0 ? void 0 : _b.call(_a, imageFile)) || (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.generateIdFromFile)(imageFile));\n\n if (!fileId) {\n console.warn(\"Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one.\");\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.imageInsertError\"));\n }\n\n const existingFileData = this.files[fileId];\n\n if (!(existingFileData === null || existingFileData === void 0 ? void 0 : existingFileData.dataURL)) {\n try {\n imageFile = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.resizeImageFile)(imageFile, {\n maxWidthOrHeight: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT\n });\n } catch (error) {\n console.error(\"Error trying to resizing image file on insertion\", error);\n }\n\n if (imageFile.size > _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MAX_ALLOWED_FILE_BYTES) {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.fileTooBig\", {\n maxSize: `${Math.trunc(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MAX_ALLOWED_FILE_BYTES / 1024 / 1024)}MB`\n }));\n }\n }\n\n const dataURL = ((_c = this.files[fileId]) === null || _c === void 0 ? void 0 : _c.dataURL) || (await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.getDataURL)(imageFile));\n return new Promise(async (resolve, reject) => {\n var _a, _b;\n\n try {\n let initializedImageElement = this.getLatestInitializedImageElement(placeholderImageElement, fileId);\n this.addMissingFiles([{\n mimeType,\n id: fileId,\n dataURL,\n created: Date.now(),\n lastRetrieved: Date.now(),\n //@ts-ignore\n name: (imageFile === null || imageFile === void 0 ? void 0 : imageFile.name) && imageFile.name !== \"image.png\" ? imageFile.name : undefined // zsviczian\n\n }]);\n\n if (!this.imageCache.get(fileId)) {\n this.addNewImagesToImageCache();\n const {\n erroredFiles\n } = await this.updateImageCache([initializedImageElement]);\n\n if (erroredFiles.size) {\n throw new Error(\"Image cache update resulted with an error.\");\n }\n }\n\n const imageHTML = await ((_a = this.imageCache.get(fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (imageHTML && ((_b = this.state.newElement) === null || _b === void 0 ? void 0 : _b.id) !== initializedImageElement.id) {\n initializedImageElement = this.getLatestInitializedImageElement(placeholderImageElement, fileId);\n const naturalDimensions = this.getImageNaturalDimensions(initializedImageElement, imageHTML); // no need to create a new instance anymore, just assign the natural dimensions\n\n Object.assign(initializedImageElement, naturalDimensions);\n }\n\n resolve(initializedImageElement);\n } catch (error) {\n console.error(error);\n reject(new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.imageInsertError\")));\n }\n });\n };\n /**\r\n * use during async image initialization,\r\n * when the placeholder image could have been modified in the meantime,\r\n * and when you don't want to loose those modifications\r\n */\n\n\n this.getLatestInitializedImageElement = (imagePlaceholder, fileId) => {\n var _a;\n\n const latestImageElement = (_a = this.scene.getElement(imagePlaceholder.id)) !== null && _a !== void 0 ? _a : imagePlaceholder;\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(latestImageElement, {\n fileId\n });\n };\n\n this.onImageToolbarButtonClick = async () => {\n try {\n const clientX = this.state.width / 2 + this.state.offsetLeft;\n const clientY = this.state.height / 2 + this.state.offsetTop;\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX,\n clientY\n }, this.state);\n const imageFiles = await (0,_data_filesystem__WEBPACK_IMPORTED_MODULE_34__.fileOpen)({\n description: \"Image\",\n extensions: Object.keys(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.IMAGE_MIME_TYPES),\n multiple: true\n });\n this.insertImages(imageFiles, x, y);\n } catch (error) {\n if (error.name !== \"AbortError\") {\n console.error(error);\n } else {\n console.warn(error);\n }\n\n this.setState({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.defaultSelectionTool\n })\n }, () => {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n });\n }\n };\n\n this.getImageNaturalDimensions = (imageElement, imageHTML) => {\n const minHeight = Math.max(this.state.height - 120, 160); // max 65% of canvas height, clamped to <300px, vh - 120px>\n\n const maxHeight = Math.min(minHeight, Math.floor(this.state.height * 0.5) / this.state.zoom.value);\n const height = Math.min(imageHTML.naturalHeight, maxHeight);\n const width = height * (imageHTML.naturalWidth / imageHTML.naturalHeight); // add current imageElement width/height to account for previous centering\n // of the placeholder image\n\n const x = imageElement.x + imageElement.width / 2 - width / 2;\n const y = imageElement.y + imageElement.height / 2 - height / 2;\n return {\n x,\n y,\n width,\n height,\n crop: null\n };\n };\n /** updates image cache, refreshing updated elements and/or setting status\r\n to error for images that fail during <img> element creation */\n\n\n this.updateImageCache = async (elements, files = this.files) => {\n const {\n updatedFiles,\n erroredFiles\n } = await (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateImageCache)({\n imageCache: this.imageCache,\n fileIds: elements.map(element => element.fileId),\n files\n });\n\n if (erroredFiles.size) {\n this.store.scheduleAction(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER);\n this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(element => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(element) && erroredFiles.has(element.fileId)) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(element, {\n status: \"error\"\n });\n }\n\n return element;\n }));\n }\n\n return {\n updatedFiles,\n erroredFiles\n };\n };\n /** adds new images to imageCache and re-renders if needed */\n\n\n this.addNewImagesToImageCache = async (imageElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getInitializedImageElements)(this.scene.getNonDeletedElements()), files = this.files) => {\n const uncachedImageElements = imageElements.filter(element => !element.isDeleted && !this.imageCache.has(element.fileId));\n\n if (uncachedImageElements.length) {\n const {\n updatedFiles\n } = await this.updateImageCache(uncachedImageElements, files);\n\n if (updatedFiles.size) {\n for (const element of uncachedImageElements) {\n if (updatedFiles.has(element.fileId)) {\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element);\n }\n }\n }\n\n if (updatedFiles.size) {\n this.scene.triggerUpdate();\n }\n }\n };\n /** generally you should use `addNewImagesToImageCache()` directly if you need\r\n * to render new images. This is just a failsafe */\n\n\n this.scheduleImageRefresh = lodash_throttle__WEBPACK_IMPORTED_MODULE_1___default()(() => {\n this.addNewImagesToImageCache();\n }, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.IMAGE_RENDER_TIMEOUT);\n\n this.updateBindingEnabledOnPointerMove = event => {\n const shouldEnableBinding = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.shouldEnableBindingForPointerEvent)(event);\n\n if (this.state.isBindingEnabled !== shouldEnableBinding) {\n this.setState({\n isBindingEnabled: shouldEnableBinding\n });\n }\n };\n\n this.maybeSuggestBindingAtCursor = (pointerCoords, considerAll) => {\n const hoveredBindableElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getHoveredElementForBinding)(pointerCoords, this.scene.getNonDeletedElements(), this.scene.getNonDeletedElementsMap(), this.state.zoom, false, considerAll);\n this.setState({\n suggestedBindings: hoveredBindableElement != null ? [hoveredBindableElement] : []\n });\n };\n\n this.handleInteractiveCanvasRef = canvas => {\n var _a, _b; // canvas is null when unmounting\n\n\n if (canvas !== null) {\n this.interactiveCanvas = canvas; // -----------------------------------------------------------------------\n // NOTE wheel, touchstart, touchend events must be registered outside\n // of react because react binds them them passively (so we can't prevent\n // default on them)\n\n this.interactiveCanvas.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_START, this.onTouchStart, {\n passive: false\n });\n this.interactiveCanvas.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_END, this.onTouchEnd); // -----------------------------------------------------------------------\n } else {\n (_a = this.interactiveCanvas) === null || _a === void 0 ? void 0 : _a.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_START, this.onTouchStart);\n (_b = this.interactiveCanvas) === null || _b === void 0 ? void 0 : _b.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.TOUCH_END, this.onTouchEnd);\n }\n };\n\n this.insertImages = async (imageFiles, sceneX, sceneY) => {\n const gridPadding = 50 / this.state.zoom.value; // Create, position, and insert placeholders\n\n const placeholders = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.positionElementsOnGrid)(imageFiles.map(() => this.newImagePlaceholder({\n sceneX,\n sceneY\n })), sceneX, sceneY, gridPadding);\n placeholders.forEach(el => this.scene.insertElement(el)); // Create, position, insert and select initialized (replacing placeholders)\n\n const initialized = await Promise.all(placeholders.map(async (placeholder, i) => {\n try {\n return await this.initializeImage(placeholder, await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.normalizeFile)(imageFiles[i]));\n } catch (error) {\n this.setState({\n errorMessage: error.message || (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.imageInsertError\")\n });\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(placeholder, {\n isDeleted: true\n });\n }\n }));\n const initializedMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(initialized);\n const positioned = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.positionElementsOnGrid)(initialized.filter(el => !el.isDeleted), sceneX, sceneY, gridPadding);\n const positionedMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(positioned);\n const nextElements = this.scene.getElementsIncludingDeleted().map(el => {\n var _a, _b;\n\n return (_b = (_a = positionedMap.get(el.id)) !== null && _a !== void 0 ? _a : initializedMap.get(el.id)) !== null && _b !== void 0 ? _b : el;\n });\n this.updateScene({\n appState: {\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.fromEntries(positioned.map(el => [el.id, true])), this.state)\n },\n elements: nextElements,\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n });\n this.setState({}, () => {\n // actionFinalize after all state values have been updated\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n });\n };\n\n this.handleAppOnDrop = async event => {\n var _a;\n\n if (this.props.onDrop) {\n //zsviczian\n try {\n if ((await this.props.onDrop(event)) === false) {\n return;\n }\n } catch (e) {\n console.error(e);\n }\n }\n\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const dataTransferList = await (0,_clipboard__WEBPACK_IMPORTED_MODULE_24__.parseDataTransferEvent)(event); // must be retrieved first, in the same frame\n\n const fileItems = dataTransferList.getFiles();\n\n if (fileItems.length === 1) {\n const {\n file,\n fileHandle\n } = fileItems[0];\n\n if (file && (file.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.png || file.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.svg)) {\n try {\n const scene = await (0,_data__WEBPACK_IMPORTED_MODULE_25__.loadFromBlob)(file, this.state, this.scene.getElementsIncludingDeleted(), fileHandle);\n this.syncActionResult(Object.assign(Object.assign({}, scene), {\n appState: Object.assign(Object.assign({}, scene.appState || this.state), {\n isLoading: false\n }),\n replaceFiles: true,\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n }));\n return;\n } catch (error) {\n if (error.name !== \"EncodingError\") {\n throw new Error((0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"alerts.couldNotLoadInvalidFile\"));\n } // if EncodingError, fall through to insert as regular image\n\n }\n }\n }\n\n const imageFiles = fileItems.map(data => data.file).filter(file => (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.isSupportedImageFile)(file));\n\n if (imageFiles.length > 0 && this.isToolSupported(\"image\")) {\n return this.insertImages(imageFiles, sceneX, sceneY);\n }\n\n const excalidrawLibrary_ids = dataTransferList.getData(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidrawlibIds);\n const excalidrawLibrary_data = dataTransferList.getData(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidrawlib);\n\n if (excalidrawLibrary_ids || excalidrawLibrary_data) {\n try {\n let libraryItems = null;\n\n if (excalidrawLibrary_ids) {\n const {\n itemIds\n } = JSON.parse(excalidrawLibrary_ids);\n const allLibraryItems = await this.library.getLatestLibrary();\n libraryItems = allLibraryItems.filter(item => itemIds.includes(item.id)); // legacy library dataTransfer format\n } else if (excalidrawLibrary_data) {\n libraryItems = (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.parseLibraryJSON)(excalidrawLibrary_data);\n }\n\n if (libraryItems === null || libraryItems === void 0 ? void 0 : libraryItems.length) {\n libraryItems = libraryItems.map(item => Object.assign(Object.assign({}, item), {\n // #6465\n elements: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.duplicateElements)({\n type: \"everything\",\n elements: item.elements,\n randomizeSeed: true\n }).duplicatedElements\n }));\n this.addElementsFromPasteOrLibrary({\n elements: (0,_data_library__WEBPACK_IMPORTED_MODULE_26__.distributeLibraryItemsOnSquareGrid)(libraryItems),\n position: event,\n files: null\n });\n }\n } catch (error) {\n this.setState({\n errorMessage: error.message\n });\n }\n\n return;\n }\n\n if (fileItems.length > 0) {\n const {\n file,\n fileHandle\n } = fileItems[0];\n\n if (file) {\n // Attempt to parse an excalidraw/excalidrawlib file\n await this.loadFileToCanvas(file, fileHandle);\n }\n }\n\n const textItem = dataTransferList.findByType(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.text);\n\n if (textItem) {\n const text = textItem.value;\n\n if (text && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(text, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(text) || ((_a = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)(text)) === null || _a === void 0 ? void 0 : _a.type) === \"video\")) {\n const embeddable = this.insertEmbeddableElement({\n sceneX,\n sceneY,\n link: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeLink)(text)\n });\n\n if (embeddable) {\n this.store.scheduleCapture();\n this.setState({\n selectedElementIds: {\n [embeddable.id]: true\n }\n });\n }\n }\n }\n };\n\n this.loadFileToCanvas = async (file, fileHandle) => {\n file = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.normalizeFile)(file);\n\n try {\n const elements = this.scene.getElementsIncludingDeleted();\n let ret;\n\n try {\n ret = await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.loadSceneOrLibraryFromBlob)(file, this.state, elements, fileHandle);\n } catch (error) {\n const imageSceneDataError = error instanceof _errors__WEBPACK_IMPORTED_MODULE_38__.ImageSceneDataError;\n\n if (imageSceneDataError && error.code === \"IMAGE_NOT_CONTAINS_SCENE_DATA\" && !this.isToolSupported(\"image\")) {\n this.setState({\n isLoading: false,\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.imageToolNotSupported\")\n });\n return;\n }\n\n const errorMessage = imageSceneDataError ? (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"alerts.cannotRestoreFromImage\") : (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"alerts.couldNotLoadInvalidFile\");\n this.setState({\n isLoading: false,\n errorMessage\n });\n }\n\n if (!ret) {\n return;\n }\n\n if (ret.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidraw) {\n // restore the fractional indices by mutating elements\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.syncInvalidIndices)(elements.concat(ret.data.elements)); // don't capture and only update the store snapshot for old elements,\n // otherwise we would end up with duplicated fractional indices on undo\n\n this.store.scheduleMicroAction({\n action: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER,\n elements,\n appState: undefined\n });\n this.setState({\n isLoading: true\n });\n this.syncActionResult(Object.assign(Object.assign({}, ret.data), {\n appState: Object.assign(Object.assign({}, ret.data.appState || this.state), {\n isLoading: false\n }),\n replaceFiles: true,\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.IMMEDIATELY\n }));\n } else if (ret.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MIME_TYPES.excalidrawlib) {\n await this.library.updateLibrary({\n libraryItems: file,\n merge: true,\n openLibraryMenu: true\n }).catch(error => {\n console.error(error);\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.importLibraryError\")\n });\n });\n }\n } catch (error) {\n this.setState({\n isLoading: false,\n errorMessage: error.message\n });\n }\n };\n\n this.handleCanvasContextMenu = event => {\n event.preventDefault(); //mfuria #329. if right-click pan is enabled, we suppress opening our custom menu too.\n\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.isPanWithRightMouseEnabled)()) {\n return;\n }\n\n if ((\"pointerType\" in event.nativeEvent && event.nativeEvent.pointerType === \"touch\" || \"pointerType\" in event.nativeEvent && event.nativeEvent.pointerType === \"pen\" && // always allow if user uses a pen secondary button\n event.button !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_BUTTON.SECONDARY) && this.state.activeTool.type !== this.defaultSelectionTool) {\n return;\n }\n\n if (this.state.isResizing) {\n return; //zsviczian - avoid context menu during resizing on Mobiles\n }\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const element = this.getElementAtPosition(x, y, {\n preferSelected: true,\n includeLockedElements: true\n });\n const selectedElements = this.scene.getSelectedElements(this.state);\n const isHittingCommonBoundBox = this.isHittingCommonBoundingBoxOfSelectedElements({\n x,\n y\n }, selectedElements);\n const type = element || isHittingCommonBoundBox ? \"element\" : \"canvas\";\n const container = this.excalidrawContainerRef.current;\n const {\n top: offsetTop,\n left: offsetLeft\n } = container.getBoundingClientRect();\n const left = event.clientX - offsetLeft;\n const top = event.clientY - offsetTop;\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"contextMenu\", \"openContextMenu\", type);\n this.setState(Object.assign(Object.assign({}, element && !this.state.selectedElementIds[element.id] ? Object.assign(Object.assign(Object.assign({}, this.state), (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: this.state.editingGroupId,\n selectedElementIds: {\n [element.id]: true\n }\n }, this.scene.getNonDeletedElements(), this.state, this)), {\n selectedLinearElement: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(element) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(element, this.scene.getNonDeletedElementsMap()) : null\n }) : this.state), {\n showHyperlinkPopup: false\n }), () => {\n this.setState({\n contextMenu: {\n top,\n left,\n items: this.getContextMenuItems(type)\n }\n });\n });\n };\n\n this.maybeDragNewGenericElement = (pointerDownState, event, informMutation = true) => {\n var _a, _b, _c, _d, _e;\n\n const selectionElement = this.state.selectionElement;\n const pointerCoords = pointerDownState.lastCoords;\n\n if (selectionElement && this.state.activeTool.type !== \"eraser\") {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.dragNewElement)({\n newElement: selectionElement,\n elementType: this.state.activeTool.type,\n originX: pointerDownState.origin.x,\n originY: pointerDownState.origin.y,\n x: pointerCoords.x,\n y: pointerCoords.y,\n width: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.origin.x, pointerCoords.x),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.origin.y, pointerCoords.y),\n shouldMaintainAspectRatio: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event),\n shouldResizeFromCenter: false,\n scene: this.scene,\n zoom: this.state.zoom.value,\n informMutation: false\n });\n return;\n }\n\n const newElement = this.state.newElement;\n\n if (!newElement) {\n return;\n }\n\n let [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(newElement) && ((_a = this.imageCache.get(newElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n const aspectRatio = image && !(image instanceof Promise) ? image.width / image.height : null;\n this.maybeCacheReferenceSnapPoints(event, [newElement]);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.snapNewElement)(newElement, this, event, {\n x: pointerDownState.originInGrid.x + ((_c = (_b = this.state.originSnapOffset) === null || _b === void 0 ? void 0 : _b.x) !== null && _c !== void 0 ? _c : 0),\n y: pointerDownState.originInGrid.y + ((_e = (_d = this.state.originSnapOffset) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 0)\n }, {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n }, this.scene.getNonDeletedElementsMap());\n gridX += snapOffset.x;\n gridY += snapOffset.y;\n this.setState({\n snapLines\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.dragNewElement)({\n newElement,\n elementType: this.state.activeTool.type,\n originX: pointerDownState.originInGrid.x,\n originY: pointerDownState.originInGrid.y,\n x: gridX,\n y: gridY,\n width: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.originInGrid.x, gridX),\n height: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.distance)(pointerDownState.originInGrid.y, gridY),\n shouldMaintainAspectRatio: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(newElement) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event),\n shouldResizeFromCenter: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldResizeFromCenter)(event),\n zoom: this.state.zoom.value,\n scene: this.scene,\n widthAspectRatio: aspectRatio,\n originOffset: this.state.originSnapOffset,\n informMutation\n });\n this.setState({\n newElement\n }); // highlight elements that are to be added to frames on frames creation\n\n if (this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.frame || this.state.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TOOL_TYPE.magicframe) {\n this.setState({\n elementsToHighlight: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInResizingFrame)(this.scene.getNonDeletedElements(), newElement, this.state, this.scene.getNonDeletedElementsMap())\n });\n }\n };\n\n this.maybeHandleCrop = (pointerDownState, event) => {\n var _a; // to crop, we must already be in the cropping mode, where croppingElement has been set\n\n\n if (!this.state.croppingElementId) {\n return false;\n }\n\n const transformHandleType = pointerDownState.resize.handleType;\n const pointerCoords = pointerDownState.lastCoords;\n const [x, y] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const croppingElement = this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);\n\n if (transformHandleType && croppingElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingElement)) {\n const croppingAtStateStart = pointerDownState.originalElements.get(croppingElement.id);\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(croppingElement) && ((_a = this.imageCache.get(croppingElement.fileId)) === null || _a === void 0 ? void 0 : _a.image);\n\n if (croppingAtStateStart && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingAtStateStart) && image && !(image instanceof Promise)) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const dragOffset = {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n };\n this.maybeCacheReferenceSnapPoints(event, [croppingElement]);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.snapResizingElements)([croppingElement], [croppingAtStateStart], this, event, dragOffset, transformHandleType);\n this.scene.mutateElement(croppingElement, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.cropElement)(croppingElement, this.scene.getNonDeletedElementsMap(), transformHandleType, image.naturalWidth, image.naturalHeight, x + snapOffset.x, y + snapOffset.y, event.shiftKey ? croppingAtStateStart.width / croppingAtStateStart.height : undefined));\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(croppingElement, this.scene, {\n newSize: {\n width: croppingElement.width,\n height: croppingElement.height\n }\n });\n this.setState({\n isCropping: transformHandleType && transformHandleType !== \"rotation\",\n snapLines\n });\n }\n\n return true;\n }\n\n return false;\n };\n\n this.maybeHandleResize = (pointerDownState, event) => {\n const selectedElements = this.scene.getSelectedElements(this.state);\n const selectedFrames = selectedElements.filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element));\n const transformHandleType = pointerDownState.resize.handleType;\n\n if ( // Frames cannot be rotated.\n selectedFrames.length > 0 && transformHandleType === \"rotation\" || // Elbow arrows cannot be transformed (resized or rotated).\n selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0]) || // Do not resize when in crop mode\n this.state.croppingElementId) {\n return false;\n }\n\n this.setState({\n // TODO: rename this state field to \"isScaling\" to distinguish\n // it from the generic \"isResizing\" which includes scaling and\n // rotating\n isResizing: transformHandleType && transformHandleType !== \"rotation\",\n isRotating: transformHandleType === \"rotation\",\n activeEmbeddable: null\n });\n const pointerCoords = pointerDownState.lastCoords;\n let [resizeX, resizeY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x - pointerDownState.resize.offset.x, pointerCoords.y - pointerDownState.resize.offset.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const frameElementsOffsetsMap = new Map();\n selectedFrames.forEach(frame => {\n const elementsInFrame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getFrameChildren)(this.scene.getNonDeletedElements(), frame.id);\n elementsInFrame.forEach(element => {\n frameElementsOffsetsMap.set(frame.id + element.id, {\n x: element.x - frame.x,\n y: element.y - frame.y\n });\n });\n }); // check needed for avoiding flickering when a key gets pressed\n // during dragging\n\n if (!this.state.selectedElementsAreBeingDragged) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n const dragOffset = {\n x: gridX - pointerDownState.originInGrid.x,\n y: gridY - pointerDownState.originInGrid.y\n };\n const originalElements = [...pointerDownState.originalElements.values()];\n this.maybeCacheReferenceSnapPoints(event, selectedElements);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.snapResizingElements)(selectedElements, (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getSelectedElements)(originalElements, this.state), this, event, dragOffset, transformHandleType);\n resizeX += snapOffset.x;\n resizeY += snapOffset.y;\n this.setState({\n snapLines\n });\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.transformElements)(pointerDownState.originalElements, transformHandleType, selectedElements, this.scene, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldRotateWithDiscreteAngle)(event), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldResizeFromCenter)(event), selectedElements.some(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(element)) ? !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event) : (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldMaintainAspectRatio)(event), resizeX, resizeY, pointerDownState.resize.center.x, pointerDownState.resize.center.y)) {\n const suggestedBindings = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSuggestedBindingsForArrows)(selectedElements, this.scene.getNonDeletedElementsMap(), this.state.zoom);\n const elementsToHighlight = new Set();\n selectedFrames.forEach(frame => {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInResizingFrame)(this.scene.getNonDeletedElements(), frame, this.state, this.scene.getNonDeletedElementsMap()).forEach(element => elementsToHighlight.add(element));\n });\n this.setState({\n elementsToHighlight: [...elementsToHighlight],\n suggestedBindings\n });\n return true;\n }\n\n return false;\n };\n\n this.getContextMenuItems = type => {\n const options = [];\n options.push(_actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsSvg); // canvas contextMenu\n // -------------------------------------------------------------------------\n\n if (type === \"canvas\") {\n if (this.state.viewModeEnabled) {\n return [...options, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleStats, _actions_actionCanvas__WEBPACK_IMPORTED_MODULE_10__.actionToggleLaserPointer];\n }\n\n return [_actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsPng, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyAsSvg, _actions__WEBPACK_IMPORTED_MODULE_8__.copyText, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSelectAll, _actions_actionElementLock__WEBPACK_IMPORTED_MODULE_13__.actionUnlockAllElements, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleGridMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleObjectsSnapMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleZenMode, _actions_actionToggleViewMode__WEBPACK_IMPORTED_MODULE_17__.actionToggleViewMode, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleStats];\n } // element contextMenu\n // -------------------------------------------------------------------------\n\n\n options.push(_actions__WEBPACK_IMPORTED_MODULE_8__.copyText);\n\n if (this.state.viewModeEnabled) {\n return [_actions__WEBPACK_IMPORTED_MODULE_8__.actionCopy, ...options];\n }\n\n return [_ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCut, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopy, _actions_actionClipboard__WEBPACK_IMPORTED_MODULE_11__.actionPaste, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionSelectAllElementsInFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionRemoveAllElementsFromFrame, _actions_actionFrame__WEBPACK_IMPORTED_MODULE_14__.actionWrapSelectionInFrame, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleCropEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, ...options, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionCopyStyles, _actions__WEBPACK_IMPORTED_MODULE_8__.actionPasteStyles, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionGroup, _actions_actionTextAutoResize__WEBPACK_IMPORTED_MODULE_16__.actionTextAutoResize, _actions__WEBPACK_IMPORTED_MODULE_8__.actionUnbindText, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBindText, _actions_actionBoundText__WEBPACK_IMPORTED_MODULE_9__.actionWrapTextInContainer, _actions__WEBPACK_IMPORTED_MODULE_8__.actionUngroup, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionAddToLibrary, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSendBackward, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBringForward, _actions__WEBPACK_IMPORTED_MODULE_8__.actionSendToBack, _actions__WEBPACK_IMPORTED_MODULE_8__.actionBringToFront, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionFlipHorizontal, _actions__WEBPACK_IMPORTED_MODULE_8__.actionFlipVertical, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionLink, _actions_actionElementLink__WEBPACK_IMPORTED_MODULE_12__.actionCopyElementLink, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionDuplicateSelection, _actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleElementLock, _ContextMenu__WEBPACK_IMPORTED_MODULE_54__.CONTEXT_MENU_SEPARATOR, _actions__WEBPACK_IMPORTED_MODULE_8__.actionDeleteSelected];\n };\n\n this.handleWheel = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n var _a, _b, _c, _d; // if not scrolling on canvas/wysiwyg, ignore\n //zsviczian - begin\n\n\n const path = (_b = (_a = event).composedPath) === null || _b === void 0 ? void 0 : _b.call(_a);\n const isOnExcalidrawCanvas = (path === null || path === void 0 ? void 0 : path.some(n => {\n var _a;\n\n return n instanceof HTMLCanvasElement && ((_a = n.classList) === null || _a === void 0 ? void 0 : _a.contains(\"excalidraw__canvas\"));\n })) || ((_d = (_c = event.target) === null || _c === void 0 ? void 0 : _c.closest) === null || _d === void 0 ? void 0 : _d.call(_c, \"canvas.excalidraw__canvas\")) != null; //zsviczian - end\n\n if (!(isOnExcalidrawCanvas || //zsviczian\n event.target instanceof HTMLTextAreaElement || event.target instanceof HTMLIFrameElement)) {\n // prevent zooming the browser (but allow scrolling DOM)\n if (event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD]) {\n event.preventDefault();\n }\n\n return;\n }\n\n event.preventDefault();\n\n if (isPanning) {\n return;\n }\n\n const {\n deltaX,\n deltaY\n } = event; // note that event.ctrlKey is necessary to handle pinch zooming\n\n if ( //zsviczian\n (event.metaKey || event.ctrlKey) && !this.state.allowWheelZoom || !(event.metaKey || event.ctrlKey) && this.state.allowWheelZoom) {\n const sign = Math.sign(deltaY);\n const MAX_STEP = (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.getZoomStep)() * 100;\n const absDelta = Math.abs(deltaY);\n let delta = deltaY;\n\n if (absDelta > MAX_STEP) {\n delta = MAX_STEP * sign;\n }\n\n let newZoom = this.state.zoom.value - delta / 100; // increase zoom steps the more zoomed-in we are (applies to >100% only)\n\n newZoom += Math.log10(Math.max(1, this.state.zoom.value)) * -sign * // reduced amplification for small deltas (small movements on a trackpad)\n Math.min(1, absDelta / 20);\n this.translateCanvas(state => Object.assign(Object.assign({}, (0,_scene_zoom__WEBPACK_IMPORTED_MODULE_32__.getStateForZoom)({\n viewportX: this.lastViewportPosition.x,\n viewportY: this.lastViewportPosition.y,\n nextZoom: (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getNormalizedZoom)(newZoom)\n }, state)), {\n shouldCacheIgnoreZoom: true\n }));\n this.resetShouldCacheIgnoreZoomDebounced();\n return;\n } // scroll horizontally when shift pressed\n\n\n if (event.shiftKey) {\n this.translateCanvas(({\n zoom,\n scrollX\n }) => ({\n // on Mac, shift+wheel tends to result in deltaX\n scrollX: scrollX - (deltaY || deltaX) / zoom.value\n }));\n return;\n }\n\n this.translateCanvas(({\n zoom,\n scrollX,\n scrollY\n }) => ({\n scrollX: scrollX - deltaX / zoom.value,\n scrollY: scrollY - deltaY / zoom.value\n }));\n });\n\n this.savePointer = (x, y, button) => {\n var _a, _b;\n\n if (!x || !y) {\n return;\n }\n\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: x,\n clientY: y\n }, this.state);\n\n if (isNaN(sceneX) || isNaN(sceneY)) {// sometimes the pointer goes off screen\n }\n\n const pointer = {\n x: sceneX,\n y: sceneY,\n tool: this.state.activeTool.type === \"laser\" ? \"laser\" : \"pointer\"\n };\n (_b = (_a = this.props).onPointerUpdate) === null || _b === void 0 ? void 0 : _b.call(_a, {\n pointer,\n button,\n pointersMap: gesture.pointers\n });\n };\n\n this.resetShouldCacheIgnoreZoomDebounced = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.debounce)(() => {\n if (!this.unmounted) {\n this.setState({\n shouldCacheIgnoreZoom: false\n });\n }\n }, 300);\n\n this.updateDOMRect = cb => {\n var _a;\n\n if ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) {\n const excalidrawContainer = this.excalidrawContainerRef.current;\n const {\n width,\n height,\n left: offsetLeft,\n top: offsetTop\n } = excalidrawContainer.getBoundingClientRect();\n const {\n width: currentWidth,\n height: currentHeight,\n offsetTop: currentOffsetTop,\n offsetLeft: currentOffsetLeft\n } = this.state;\n\n if (width === currentWidth && height === currentHeight && offsetLeft === currentOffsetLeft && offsetTop === currentOffsetTop) {\n if (cb) {\n cb();\n }\n\n return;\n } //zsviczian\n\n\n if (width === 0 || height === 0) {\n if (cb) {\n cb();\n }\n\n return;\n }\n\n this.setState({\n width,\n height,\n offsetLeft,\n offsetTop\n }, () => {\n cb && cb();\n });\n }\n };\n\n this.refresh = () => {\n this.setState(Object.assign({}, this.getCanvasOffsets()));\n };\n\n const defaultAppState = (0,_appState__WEBPACK_IMPORTED_MODULE_23__.getDefaultAppState)();\n this.defaultSelectionTool = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() ? \"lasso\" : \"selection\";\n const {\n excalidrawAPI,\n viewModeEnabled = false,\n zenModeEnabled = false,\n gridModeEnabled = false,\n objectsSnapModeEnabled = false,\n theme = defaultAppState.theme,\n initState,\n //zsviczian\n name = `${(0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"labels.untitled\")}-${(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getDateTime)()}`\n } = props;\n this.state = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaultAppState), {\n theme,\n isLoading: true\n }), this.getCanvasOffsets()), {\n viewModeEnabled,\n zenModeEnabled,\n objectsSnapModeEnabled,\n gridModeEnabled: gridModeEnabled !== null && gridModeEnabled !== void 0 ? gridModeEnabled : defaultAppState.gridModeEnabled,\n name,\n width: window.innerWidth,\n height: window.innerHeight\n }), initState !== null && initState !== void 0 ? initState : {});\n this.id = (0,nanoid__WEBPACK_IMPORTED_MODULE_72__.nanoid)();\n (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.initializeObsidianUtils)();\n this.library = new _data_library__WEBPACK_IMPORTED_MODULE_26__[\"default\"](this);\n this.actionManager = new _actions_manager__WEBPACK_IMPORTED_MODULE_18__.ActionManager(this.syncActionResult, () => this.state, () => this.scene.getElementsIncludingDeleted(), this);\n this.scene = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Scene();\n this.canvas = document.createElement(\"canvas\");\n this.rc = roughjs_bin_rough__WEBPACK_IMPORTED_MODULE_4__[\"default\"].canvas(this.canvas);\n this.renderer = new _scene_Renderer__WEBPACK_IMPORTED_MODULE_41__.Renderer(this.scene);\n this.visibleElements = [];\n this.store = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Store(this);\n this.history = new _history__WEBPACK_IMPORTED_MODULE_29__.History(this.store);\n\n if (excalidrawAPI) {\n const api = {\n updateScene: this.updateScene,\n applyDeltas: this.applyDeltas,\n mutateElement: this.mutateElement,\n updateLibrary: this.library.updateLibrary,\n addFiles: this.addFiles,\n resetScene: this.resetScene,\n getSceneElementsIncludingDeleted: this.getSceneElementsIncludingDeleted,\n getSceneElementsMapIncludingDeleted: this.getSceneElementsMapIncludingDeleted,\n history: {\n clear: this.resetHistory\n },\n scrollToContent: this.scrollToContent,\n setForceRenderAllEmbeddables: this.setForceRenderAllEmbeddables,\n zoomToFit: this.zoomToFit,\n refreshEditorBreakpoints: this.refreshEditorBreakpoints,\n getColorAtScenePoint: this.getColorAtScenePoint,\n startLineEditor: this.startLineEditor,\n getSceneElements: this.getSceneElements,\n getAppState: () => this.state,\n getFiles: () => this.files,\n getName: this.getName,\n registerAction: action => {\n this.actionManager.registerAction(action);\n },\n refresh: this.refresh,\n setToast: this.setToast,\n updateContainerSize: this.updateContainerSize,\n id: this.id,\n selectElements: this.selectElements,\n sendBackward: this.sendBackward,\n bringForward: this.bringForward,\n sendToBack: this.sendToBack,\n bringToFront: this.bringToFront,\n setMobileModeAllowed: this.setMobileModeAllowed,\n setActiveTool: this.setActiveTool,\n setCursor: this.setCursor,\n resetCursor: this.resetCursor,\n updateFrameRendering: this.updateFrameRendering,\n toggleSidebar: this.toggleSidebar,\n getHTMLIFrameElement: id => this.getHTMLIFrameElement(id),\n onChange: cb => this.onChangeEmitter.on(cb),\n onIncrement: cb => this.store.onStoreIncrementEmitter.on(cb),\n onPointerDown: cb => this.onPointerDownEmitter.on(cb),\n onPointerUp: cb => this.onPointerUpEmitter.on(cb),\n onScrollChange: cb => this.onScrollChangeEmitter.on(cb),\n onUserFollow: cb => this.onUserFollowEmitter.on(cb)\n };\n\n if (typeof excalidrawAPI === \"function\") {\n excalidrawAPI(api);\n } else {\n console.error(\"excalidrawAPI should be a function!\");\n }\n }\n\n this.excalidrawContainerValue = {\n container: this.excalidrawContainerRef.current,\n id: this.id\n };\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_36__.Fonts(this.scene);\n this.history = new _history__WEBPACK_IMPORTED_MODULE_29__.History(this.store);\n this.actionManager.registerAll(_actions_register__WEBPACK_IMPORTED_MODULE_19__.actions);\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__.createUndoAction)(this.history));\n this.actionManager.registerAction((0,_actions_actionHistory__WEBPACK_IMPORTED_MODULE_15__.createRedoAction)(this.history));\n }\n\n onWindowMessage(event) {\n if (event.origin !== \"https://player.vimeo.com\" && event.origin !== \"https://www.youtube.com\") {\n return;\n }\n\n let data = null;\n\n try {\n data = JSON.parse(event.data);\n } catch (e) {}\n\n if (!data) {\n return;\n }\n\n switch (event.origin) {\n case \"https://player.vimeo.com\":\n //Allowing for multiple instances of Excalidraw running in the window\n if (data.method === \"paused\") {\n let source = null;\n const iframes = document.body.querySelectorAll(\"iframe.excalidraw__embeddable\");\n\n if (!iframes) {\n break;\n }\n\n for (const iframe of iframes) {\n if (iframe.contentWindow === event.source) {\n source = iframe.contentWindow;\n }\n }\n\n source === null || source === void 0 ? void 0 : source.postMessage(JSON.stringify({\n method: data.value ? \"play\" : \"pause\",\n value: true\n }), \"*\");\n }\n\n break;\n\n case \"https://www.youtube.com\":\n if (data.event === \"infoDelivery\" && data.info && data.id && typeof data.info.playerState === \"number\") {\n const id = data.id;\n const playerState = data.info.playerState;\n\n if (Object.values(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES).includes(playerState)) {\n YOUTUBE_VIDEO_STATES.set(id, playerState);\n }\n }\n\n break;\n }\n }\n\n cacheEmbeddableRef(element, ref) {\n if (ref) {\n this.iFrameRefs.set(element.id, ref);\n }\n }\n\n getHTMLIFrameElement(element) {\n //zsviczian\n if (typeof element === \"string\") {\n return this.iFrameRefs.get(element);\n }\n\n return this.iFrameRefs.get(element.id);\n }\n\n handleEmbeddableCenterClick(element) {\n var _a, _b, _c, _d;\n\n if (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.element) === element && ((_b = this.state.activeEmbeddable) === null || _b === void 0 ? void 0 : _b.state) === \"active\") {\n return;\n } // The delay serves two purposes\n // 1. To prevent first click propagating to iframe on mobile,\n // else the click will immediately start and stop the video\n // 2. If the user double clicks the frame center to activate it\n // without the delay youtube will immediately open the video\n // in fullscreen mode\n\n\n setTimeout(() => {\n this.setState({\n activeEmbeddable: {\n element,\n state: \"active\"\n },\n selectedElementIds: {\n [element.id]: true\n },\n newElement: null,\n selectionElement: null\n });\n }, 100);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(element)) {\n return;\n }\n\n const iframe = this.getHTMLIFrameElement(element);\n\n if (!(iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow)) {\n return;\n }\n\n if (iframe.src.includes(\"youtube\")) {\n const state = YOUTUBE_VIDEO_STATES.get(element.id);\n\n if (!state) {\n YOUTUBE_VIDEO_STATES.set(element.id, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES.UNSTARTED);\n iframe.contentWindow.postMessage(JSON.stringify({\n event: \"listening\",\n id: element.id\n }), \"*\");\n }\n\n switch (state) {\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES.PLAYING:\n case _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.YOUTUBE_STATES.BUFFERING:\n (_c = iframe.contentWindow) === null || _c === void 0 ? void 0 : _c.postMessage(JSON.stringify({\n event: \"command\",\n func: \"pauseVideo\",\n args: \"\"\n }), \"*\");\n break;\n\n default:\n (_d = iframe.contentWindow) === null || _d === void 0 ? void 0 : _d.postMessage(JSON.stringify({\n event: \"command\",\n func: \"playVideo\",\n args: \"\"\n }), \"*\");\n }\n }\n\n if (iframe.src.includes(\"player.vimeo.com\")) {\n iframe.contentWindow.postMessage(JSON.stringify({\n method: \"paused\" //video play/pause in onWindowMessage handler\n\n }), \"*\");\n }\n }\n\n isIframeLikeElementCenter(el, event, sceneX, sceneY) {\n var _a, _b;\n\n return el && !event.altKey && !event.shiftKey && !event.metaKey && !event.ctrlKey && (((_a = this.state.activeEmbeddable) === null || _a === void 0 ? void 0 : _a.element) !== el || ((_b = this.state.activeEmbeddable) === null || _b === void 0 ? void 0 : _b.state) === \"hover\" || !this.state.activeEmbeddable) && sceneX >= el.x + el.width / 3 && sceneX <= el.x + 2 * el.width / 3 && sceneY >= el.y + el.height / 3 && sceneY <= el.y + 2 * el.height / 3;\n }\n\n renderEmbeddables() {\n const scale = this.state.zoom.value;\n const normalizedWidth = this.state.width;\n const normalizedHeight = this.state.height;\n const embeddableElements = this.scene.getNonDeletedElements().filter(el => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(el) && this.embedsValidationStatus.get(el.id) === true || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(el));\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement((react__WEBPACK_IMPORTED_MODULE_2___default().Fragment), null, embeddableElements.map(el => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.sceneCoordsToViewportCoords)({\n sceneX: el.x,\n sceneY: el.y\n }, this.state); //zsviczian - shouldRenderAllEmbeddables\n\n const isVisible = this.shouldRenderAllEmbeddables || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInViewport)(el, normalizedWidth, normalizedHeight, this.state, this.scene.getNonDeletedElementsMap());\n const hasBeenInitialized = this.initializedEmbeds.has(el.id);\n\n if (isVisible && !hasBeenInitialized) {\n this.initializedEmbeds.add(el.id);\n }\n\n const shouldRender = isVisible || hasBeenInitialized;\n\n if (!shouldRender) {\n return null;\n }\n\n let src;\n const embedLink = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.toValidURL)(el.link || \"\")); //zsviczian\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(el)) {\n src = null;\n const data = ((_b = (_a = el.customData) === null || _a === void 0 ? void 0 : _a.generationData) !== null && _b !== void 0 ? _b : this.magicGenerations.get(el.id)) || {\n status: \"error\",\n message: \"No generation data\",\n code: \"ERR_NO_GENERATION_DATA\"\n };\n\n if (data.status === \"done\") {\n const html = data.html;\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return html;\n }\n };\n } else if (data.status === \"pending\") {\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.createSrcDoc)(`\n <style>\n html, body {\n width: 100%;\n height: 100%;\n color: ${this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK ? \"white\" : \"black\"};\n }\n body {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 1rem;\n }\n\n .Spinner {\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: auto;\n margin-right: auto;\n }\n\n .Spinner svg {\n animation: rotate 1.6s linear infinite;\n transform-origin: center center;\n width: 40px;\n height: 40px;\n }\n\n .Spinner circle {\n stroke: currentColor;\n animation: dash 1.6s linear 0s infinite;\n stroke-linecap: round;\n }\n\n @keyframes rotate {\n 100% {\n transform: rotate(360deg);\n }\n }\n\n @keyframes dash {\n 0% {\n stroke-dasharray: 1, 300;\n stroke-dashoffset: 0;\n }\n 50% {\n stroke-dasharray: 150, 300;\n stroke-dashoffset: -200;\n }\n 100% {\n stroke-dasharray: 1, 300;\n stroke-dashoffset: -280;\n }\n }\n </style>\n <div class=\"Spinner\">\n <svg\n viewBox=\"0 0 100 100\"\n >\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"46\"\n stroke-width=\"8\"\n fill=\"none\"\n stroke-miter-limit=\"10\"\n />\n </svg>\n </div>\n <div>Generating...</div>\n `);\n }\n };\n } else {\n let message;\n\n if (data.code === \"ERR_GENERATION_INTERRUPTED\") {\n message = \"Generation was interrupted...\";\n } else {\n message = data.message || \"Generation failed\";\n }\n\n src = {\n intrinsicSize: {\n w: el.width,\n h: el.height\n },\n type: \"document\",\n srcdoc: () => {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.createSrcDoc)(`\n <style>\n html, body {\n height: 100%;\n }\n body {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n color: ${_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.COLOR_PALETTE.red[3]};\n }\n h1, h3 {\n margin-top: 0;\n margin-bottom: 0.5rem;\n }\n </style>\n <h1>Error!</h1>\n <h3>${message}</h3>\n `);\n }\n };\n }\n } else {\n src = embedLink; //zsviczian getEmbedLink(toValidURL(el.link || \"\"));\n }\n\n const isActive = ((_c = this.state.activeEmbeddable) === null || _c === void 0 ? void 0 : _c.element) === el && ((_d = this.state.activeEmbeddable) === null || _d === void 0 ? void 0 : _d.state) === \"active\";\n const isHovered = ((_e = this.state.activeEmbeddable) === null || _e === void 0 ? void 0 : _e.element) === el && ((_f = this.state.activeEmbeddable) === null || _f === void 0 ? void 0 : _f.state) === \"hover\";\n const isWebview = //zsviczian\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(el) && this.props.renderWebview && (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) !== \"document\" && !((_h = (_g = embedLink === null || embedLink === void 0 ? void 0 : embedLink.link) === null || _g === void 0 ? void 0 : _g.startsWith) === null || _h === void 0 ? void 0 : _h.call(_g, \"https://player.vimeo.com\")); // Modify the scale based on el.scale property\n\n const [xScale, yScale] = (_j = el.scale) !== null && _j !== void 0 ? _j : [1, 1]; //zsviczian\n\n const scaledTransform = `scale(${scale * xScale}, ${scale * yScale})`;\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n key: el.id,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"excalidraw__embeddable-container\", {\n \"is-hovered\": isHovered\n }),\n style: {\n transform: isVisible ? `translate(${x - this.state.offsetLeft}px, ${y - this.state.offsetTop}px) ${scaledTransform}` : \"none\",\n display: isVisible ? \"block\" : \"none\",\n opacity: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getRenderOpacity)(el, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainingFrame)(el, this.scene.getNonDeletedElementsMap()), this.elementsPendingErasure, null, ((_k = this.state.openDialog) === null || _k === void 0 ? void 0 : _k.name) === \"elementLinkSelector\" ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_REDUCED_GLOBAL_ALPHA : 1),\n [\"--embeddable-radius\"]: `${(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCornerRadius)(Math.min(el.width, el.height), el) / xScale //zsviczian\n }px`\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n //this is a hack that addresses isse with embedded excalidraw.com embeddable\n //https://github.com/excalidraw/excalidraw/pull/6691#issuecomment-1607383938\n\n /*ref={(ref) => {\r\n if (!this.excalidrawContainerRef.current) {\r\n return;\r\n }\r\n const container = this.excalidrawContainerRef.current;\r\n const sh = container.scrollHeight;\r\n const ch = container.clientHeight;\r\n if (sh !== ch) {\r\n container.style.height = `${sh}px`;\r\n setTimeout(() => {\r\n container.style.height = `100%`;\r\n });\r\n }\r\n }}*/\n className: \"excalidraw__embeddable-container__inner\",\n style: {\n width: isVisible ? `${el.width / xScale}px` : 0,\n height: isVisible ? `${el.height / yScale}px` : 0,\n transform: isVisible ? `rotate(${el.angle}rad)` : \"none\",\n pointerEvents: isActive ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.enabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.disabled\n }\n }, isHovered && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw__embeddable-hint\"\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"buttons.embeddableInteractionButton\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw__embeddable__outer\",\n style: {\n padding: `${el.strokeWidth / (4 * el.scale[0])}px` //zsviczian MDEmbeddable round border cutoff issue\n\n }\n }, (_o = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(el) ? (_m = (_l = this.props).renderEmbeddable) === null || _m === void 0 ? void 0 : _m.call(_l, el, this.state) //zsviczian\n : null) !== null && _o !== void 0 ? _o : isWebview ?\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"webview\", {\n ref: ref => this.cacheEmbeddableRef(el, ref),\n className: \"excalidraw__embeddable\",\n src: (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) === \"generic\" || (embedLink === null || embedLink === void 0 ? void 0 : embedLink.type) === \"video\" ? embedLink.link : \"\",\n title: \"Excalidraw Embedded Content\",\n allowFullScreen: true\n }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"iframe\", {\n ref: ref => this.cacheEmbeddableRef(el, ref),\n className: \"excalidraw__embeddable\",\n srcDoc: (src === null || src === void 0 ? void 0 : src.type) === \"document\" ? src.srcdoc(this.state.theme) : undefined,\n src: (src === null || src === void 0 ? void 0 : src.type) !== \"document\" ? (_p = src === null || src === void 0 ? void 0 : src.link) !== null && _p !== void 0 ? _p : \"\" : undefined,\n // https://stackoverflow.com/q/18470015\n // scrolling=\"no\" //zsviczian\n referrerPolicy: \"no-referrer-when-downgrade\",\n title: \"Excalidraw Embedded Content\",\n allow: \"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\",\n allowFullScreen: true,\n sandbox: `${((_q = src === null || src === void 0 ? void 0 : src.sandbox) === null || _q === void 0 ? void 0 : _q.allowSameOrigin) ? \"allow-same-origin\" : \"\"} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`\n }))));\n }));\n }\n\n toggleOverscrollBehavior(event) {\n // when pointer inside editor, disable overscroll behavior to prevent\n // panning to trigger history back/forward on MacOS Chrome\n document.documentElement.style.overscrollBehaviorX = event.type === \"pointerenter\" ? \"none\" : \"auto\";\n }\n\n render() {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;\n\n const selectedElements = this.scene.getSelectedElements(this.state);\n const {\n renderTopRightUI,\n renderCustomStats\n } = this.props;\n const sceneNonce = this.scene.getSceneNonce();\n const {\n elementsMap,\n visibleElements\n } = this.renderer.getRenderableElements({\n sceneNonce,\n zoom: this.state.zoom,\n offsetLeft: this.state.offsetLeft,\n offsetTop: this.state.offsetTop,\n scrollX: this.state.scrollX,\n scrollY: this.state.scrollY,\n height: this.state.height,\n width: this.state.width,\n editingTextElement: this.state.editingTextElement,\n newElementId: (_a = this.state.newElement) === null || _a === void 0 ? void 0 : _a.id\n });\n this.visibleElements = visibleElements;\n const allElementsMap = this.scene.getNonDeletedElementsMap();\n const shouldBlockPointerEvents = // default back to `--ui-pointerEvents` flow if setPointerCapture\n // not supported\n \"setPointerCapture\" in HTMLElement.prototype ? false : this.state.selectionElement || this.state.newElement || this.state.selectedElementsAreBeingDragged || this.state.resizingElement || this.state.activeTool.type === \"laser\" && // technically we can just test on this once we make it more safe\n this.state.cursorButton === \"down\";\n const firstSelectedElement = selectedElements[0]; //zsviczian\n\n const isHighlighter = (_d = (_c = (_b = this.state.newElement) === null || _b === void 0 ? void 0 : _b.customData) === null || _c === void 0 ? void 0 : _c.strokeOptions) === null || _d === void 0 ? void 0 : _d.highlighter;\n const showShapeSwitchPanel = ((_e = _editor_jotai__WEBPACK_IMPORTED_MODULE_37__.editorJotaiStore.get(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__.convertElementTypePopupAtom)) === null || _e === void 0 ? void 0 : _e.type) === \"panel\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"excalidraw excalidraw-container\", {\n \"excalidraw--view-mode\": this.state.viewModeEnabled || ((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name) === \"elementLinkSelector\",\n \"excalidraw--mobile\": this.device.editor.isMobile || !(this.state.viewModeEnabled || this.state.zenModeEnabled) && this.state.trayModeEnabled //zsviczian\n\n }),\n style: Object.assign(Object.assign({\n //zsviczian\n [\"--ui-pointerEvents\"]: shouldBlockPointerEvents ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.disabled : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.POINTER_EVENTS.enabled\n }, this.state.dynamicStyle || {}), {\n [\"--right-sidebar-width\"]: \"302px\"\n }),\n ref: this.excalidrawContainerRef,\n onDrop: this.handleAppOnDrop,\n tabIndex: 0,\n onKeyDown: this.props.handleKeyboardGlobally ? undefined : this.onKeyDown,\n onPointerEnter: this.toggleOverscrollBehavior,\n onPointerLeave: this.toggleOverscrollBehavior\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(AppContext.Provider, {\n value: this\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(AppPropsContext.Provider, {\n value: this.props\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawContainerContext.Provider, {\n value: this.excalidrawContainerValue\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(DeviceContext.Provider, {\n value: this.device\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawSetAppStateContext.Provider, {\n value: this.setAppState\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawAppStateContext.Provider, {\n value: this.state\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawElementsContext.Provider, {\n value: this.scene.getNonDeletedElements()\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(ExcalidrawActionManagerContext.Provider, {\n value: this.actionManager\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_LayerUI__WEBPACK_IMPORTED_MODULE_57__[\"default\"], {\n canvas: this.canvas,\n appState: this.state,\n files: this.files,\n setAppState: this.setAppState,\n actionManager: this.actionManager,\n elements: this.scene.getNonDeletedElements(),\n onLockToggle: this.toggleLock,\n onPenModeToggle: this.togglePenMode,\n onHandToolToggle: this.onHandToolToggle,\n langCode: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.getLanguage)().code,\n renderTopRightUI: renderTopRightUI,\n renderCustomStats: renderCustomStats,\n showExitZenModeBtn: typeof ((_g = this.props) === null || _g === void 0 ? void 0 : _g.zenModeEnabled) === \"undefined\" && this.state.zenModeEnabled,\n UIOptions: this.props.UIOptions,\n onExportImage: this.onExportImage,\n renderWelcomeScreen: !this.state.isLoading && this.state.showWelcomeScreen && this.state.activeTool.type === this.defaultSelectionTool && !this.state.zenModeEnabled && !this.scene.getElementsIncludingDeleted().length,\n app: this,\n isCollaborating: this.props.isCollaborating,\n generateLinkForSelection: this.props.generateLinkForSelection\n }, this.props.children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-textEditorContainer\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-contextMenuContainer\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(\"div\", {\n className: \"excalidraw-eye-dropper-container\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_SVGLayer__WEBPACK_IMPORTED_MODULE_59__.SVGLayer, {\n trails: [this.laserTrails, this.lassoTrail, this.eraserTrail]\n }), selectedElements.length === 1 && ((_h = this.state.openDialog) === null || _h === void 0 ? void 0 : _h.name) !== \"elementLinkSelector\" && this.state.showHyperlinkPopup && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_hyperlink_Hyperlink__WEBPACK_IMPORTED_MODULE_35__.Hyperlink, {\n key: firstSelectedElement.id,\n element: firstSelectedElement,\n scene: this.scene,\n setAppState: this.setAppState,\n onLinkOpen: this.props.onLinkOpen,\n setToast: this.setToast,\n updateEmbedValidationStatus: this.updateEmbedValidationStatus\n }), this.props.aiEnabled !== false && selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isMagicFrameElement)(firstSelectedElement) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_43__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_58__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"labels.convertToCode\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_65__.MagicIcon,\n checked: false,\n onChange: () => this.onMagicFrameGenerate(firstSelectedElement, \"button\")\n })), selectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(firstSelectedElement) && ((_k = (_j = firstSelectedElement.customData) === null || _j === void 0 ? void 0 : _j.generationData) === null || _k === void 0 ? void 0 : _k.status) === \"done\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_components_ElementCanvasButtons__WEBPACK_IMPORTED_MODULE_43__.ElementCanvasButtons, {\n element: firstSelectedElement,\n elementsMap: elementsMap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_58__.ElementCanvasButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"labels.copySource\"),\n icon: _icons__WEBPACK_IMPORTED_MODULE_65__.copyIcon,\n checked: false,\n onChange: () => this.onIframeSrcCopy(firstSelectedElement)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_MagicButton__WEBPACK_IMPORTED_MODULE_58__.ElementCanvasButton, {\n title: \"Enter fullscreen\",\n icon: _icons__WEBPACK_IMPORTED_MODULE_65__.fullscreenIcon,\n checked: false,\n onChange: () => {\n const iframe = this.getHTMLIFrameElement(firstSelectedElement);\n\n if (iframe) {\n try {\n iframe.requestFullscreen();\n this.setState({\n activeEmbeddable: {\n element: firstSelectedElement,\n state: \"active\"\n },\n selectedElementIds: {\n [firstSelectedElement.id]: true\n },\n newElement: null,\n selectionElement: null\n });\n } catch (err) {\n console.warn(err);\n this.setState({\n errorMessage: \"Couldn't enter fullscreen\"\n });\n }\n }\n }\n })), this.state.toast !== null && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_Toast__WEBPACK_IMPORTED_MODULE_66__.Toast, {\n message: this.state.toast.message,\n onClose: this.handleToastClose,\n duration: this.state.toast.duration,\n closable: this.state.toast.closable\n }), this.state.contextMenu && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ContextMenu__WEBPACK_IMPORTED_MODULE_54__.ContextMenu, {\n items: this.state.contextMenu.items,\n top: this.state.contextMenu.top,\n left: this.state.contextMenu.left,\n actionManager: this.actionManager,\n onClose: callback => {\n this.setState({\n contextMenu: null\n }, () => {\n this.focusContainer();\n callback === null || callback === void 0 ? void 0 : callback();\n });\n }\n }), this.state.newElement && isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_63__[\"default\"], {\n appState: this.state,\n scale: window.devicePixelRatio,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: false,\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: null,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_62__.StaticCanvas, {\n canvas: this.canvas,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n visibleElements: visibleElements,\n sceneNonce: sceneNonce,\n selectionNonce: (_l = this.state.selectionElement) === null || _l === void 0 ? void 0 : _l.versionNonce,\n scale: window.devicePixelRatio,\n appState: this.state,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.isGridModeEnabled)(this),\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: this.flowChartCreator.pendingNodes,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), this.state.newElement && !isHighlighter &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases_NewElementCanvas__WEBPACK_IMPORTED_MODULE_63__[\"default\"], {\n appState: this.state,\n scale: window.devicePixelRatio,\n rc: this.rc,\n elementsMap: elementsMap,\n allElementsMap: allElementsMap,\n renderConfig: {\n imageCache: this.imageCache,\n isExporting: false,\n renderGrid: false,\n canvasBackgroundColor: this.state.viewBackgroundColor,\n embedsValidationStatus: this.embedsValidationStatus,\n elementsPendingErasure: this.elementsPendingErasure,\n pendingFlowchartNodes: null,\n isHighlighterPenDrawing: isHighlighter //zsviczian\n\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_canvases__WEBPACK_IMPORTED_MODULE_62__.InteractiveCanvas, {\n containerRef: this.excalidrawContainerRef,\n canvas: this.interactiveCanvas,\n elementsMap: elementsMap,\n visibleElements: visibleElements,\n allElementsMap: allElementsMap,\n selectedElements: selectedElements,\n sceneNonce: sceneNonce,\n selectionNonce: (_m = this.state.selectionElement) === null || _m === void 0 ? void 0 : _m.versionNonce,\n scale: window.devicePixelRatio,\n appState: this.state,\n renderScrollbars: this.props.renderScrollbars === true,\n device: this.device,\n renderInteractiveSceneCallback: this.renderInteractiveSceneCallback,\n handleCanvasRef: this.handleInteractiveCanvasRef,\n onContextMenu: this.handleCanvasContextMenu,\n onPointerMove: this.handleCanvasPointerMove,\n onPointerUp: this.handleCanvasPointerUp,\n onPointerCancel: this.removePointer,\n onTouchMove: this.handleTouchMove,\n onPointerDown: this.handleCanvasPointerDown,\n onDoubleClick: this.handleCanvasDoubleClick\n }), this.state.userToFollow && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_FollowMode_FollowMode__WEBPACK_IMPORTED_MODULE_56__[\"default\"], {\n width: this.state.width,\n height: this.state.height,\n userToFollow: this.state.userToFollow,\n onDisconnect: this.maybeUnfollowRemoteUser\n }), this.renderFrameNames(), ((_o = this.state.activeEmbeddable) === null || _o === void 0 ? void 0 : _o.state) === \"active\" && ( //zsviczian\n (_q = (_p = this.props).renderEmbeddableMenu) === null || _q === void 0 ? void 0 : _q.call(_p, this.state)), this.state.activeLockedId && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_UnlockPopup__WEBPACK_IMPORTED_MODULE_68__[\"default\"], {\n app: this,\n activeLockedId: this.state.activeLockedId\n }), showShapeSwitchPanel && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_ConvertElementTypePopup__WEBPACK_IMPORTED_MODULE_51__[\"default\"], {\n app: this\n })), this.renderEmbeddables()))))))));\n }\n\n setPlugins(plugins) {\n Object.assign(this.plugins, plugins);\n }\n\n async onMagicFrameGenerate(magicFrame, source) {\n var _a;\n\n const generateDiagramToCode = (_a = this.plugins.diagramToCode) === null || _a === void 0 ? void 0 : _a.generate;\n\n if (!generateDiagramToCode) {\n this.setState({\n errorMessage: \"No diagram to code plugin found\"\n });\n return;\n }\n\n const magicFrameChildren = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsOverlappingFrame)(this.scene.getNonDeletedElements(), magicFrame).filter(el => !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isMagicFrameElement)(el));\n\n if (!magicFrameChildren.length) {\n if (source === \"button\") {\n this.setState({\n errorMessage: \"Cannot generate from an empty frame\"\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"generate (no-children)\", \"d2c\");\n } else {\n this.setActiveTool({\n type: \"magicframe\"\n });\n }\n\n return;\n }\n\n const frameElement = this.insertIframeElement({\n sceneX: magicFrame.x + magicFrame.width + 30,\n sceneY: magicFrame.y,\n width: magicFrame.width,\n height: magicFrame.height\n });\n\n if (!frameElement) {\n return;\n }\n\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"pending\"\n }\n });\n this.setState({\n selectedElementIds: {\n [frameElement.id]: true\n }\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"generate (start)\", \"d2c\");\n\n try {\n const {\n html\n } = await generateDiagramToCode({\n frame: magicFrame,\n children: magicFrameChildren\n });\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"generate (success)\", \"d2c\");\n\n if (!html.trim()) {\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"error\",\n code: \"ERR_OAI\",\n message: \"Nothing genereated :(\"\n }\n });\n return;\n }\n\n const parsedHtml = html.includes(\"<!DOCTYPE html>\") && html.includes(\"</html>\") ? html.slice(html.indexOf(\"<!DOCTYPE html>\"), html.indexOf(\"</html>\") + \"</html>\".length) : html;\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"done\",\n html: parsedHtml\n }\n });\n } catch (error) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_21__.trackEvent)(\"ai\", \"generate (failed)\", \"d2c\");\n this.updateMagicGeneration({\n frameElement,\n data: {\n status: \"error\",\n code: \"ERR_OAI\",\n message: error.message || \"Unknown error during generation\"\n }\n });\n }\n }\n\n onIframeSrcCopy(element) {\n var _a, _b;\n\n if (((_b = (_a = element.customData) === null || _a === void 0 ? void 0 : _a.generationData) === null || _b === void 0 ? void 0 : _b.status) === \"done\") {\n (0,_clipboard__WEBPACK_IMPORTED_MODULE_24__.copyTextToSystemClipboard)(element.customData.generationData.html);\n this.setToast({\n message: \"copied to clipboard\",\n closable: false,\n duration: 1500\n });\n }\n }\n\n clearImageShapeCache(filesMap) {\n const files = filesMap !== null && filesMap !== void 0 ? filesMap : this.files;\n this.scene.getNonDeletedElements().forEach(element => {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(element) && files[element.fileId]) {\n this.imageCache.delete(element.fileId);\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.delete(element);\n }\n });\n }\n\n async componentDidMount() {\n var _a;\n\n this.unmounted = false;\n this.excalidrawContainerValue.container = this.excalidrawContainerRef.current; //zsviczian disabling this code\n\n /*\r\n if (false && (isTestEnv() || isDevEnv())) {\r\n const setState = this.setState.bind(this);\r\n Object.defineProperties(window.h, {\r\n state: {\r\n configurable: true,\r\n get: () => {\r\n return this.state;\r\n },\r\n },\r\n setState: {\r\n configurable: true,\r\n value: (...args: Parameters<typeof setState>) => {\r\n return this.setState(...args);\r\n },\r\n },\r\n app: {\r\n configurable: true,\r\n value: this,\r\n },\r\n history: {\r\n configurable: true,\r\n value: this.history,\r\n },\r\n store: {\r\n configurable: true,\r\n value: this.store,\r\n },\r\n fonts: {\r\n configurable: true,\r\n value: this.fonts,\r\n },\r\n });\r\n }*/\n\n this.store.onDurableIncrementEmitter.on(increment => {\n this.history.record(increment.delta);\n });\n const {\n onIncrement\n } = this.props; // per. optimmisation, only subscribe if there is the `onIncrement` prop registered, to avoid unnecessary computation\n\n if (onIncrement) {\n this.store.onStoreIncrementEmitter.on(increment => {\n onIncrement(increment);\n });\n }\n\n this.scene.onUpdate(this.triggerRender);\n this.addEventListeners();\n\n if (this.props.autoFocus && this.excalidrawContainerRef.current) {\n this.focusContainer();\n }\n\n if ( // bounding rects don't work in tests so updating\n // the state on init would result in making the test enviro run\n // in mobile breakpoint (0 width/height), making everything fail\n !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isTestEnv)()) {\n this.refreshViewportBreakpoints();\n this.refreshEditorBreakpoints();\n }\n\n if (_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.supportsResizeObserver && this.excalidrawContainerRef.current) {\n this.resizeObserver = new ResizeObserver(() => {\n this.refreshEditorBreakpoints();\n this.updateDOMRect();\n });\n (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.excalidrawContainerRef.current);\n }\n\n const searchParams = new URLSearchParams(window.location.search.slice(1));\n\n if (searchParams.has(\"web-share-target\")) {\n // Obtain a file that was shared via the Web Share Target API.\n this.restoreFileFromShare();\n } else {\n this.updateDOMRect(this.initializeScene);\n } // note that this check seems to always pass in localhost\n\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isBrave)() && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isMeasureTextSupported)()) {\n this.setState({\n errorMessage: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_BraveMeasureTextError__WEBPACK_IMPORTED_MODULE_53__[\"default\"], null)\n });\n }\n }\n\n componentWillUnmount() {\n var _a, _b;\n\n (_a = window.launchQueue) === null || _a === void 0 ? void 0 : _a.setConsumer(() => {});\n this.renderer.destroy();\n this.scene.destroy();\n this.scene = new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.Scene();\n this.fonts = new _fonts__WEBPACK_IMPORTED_MODULE_36__.Fonts(this.scene);\n this.renderer = new _scene_Renderer__WEBPACK_IMPORTED_MODULE_41__.Renderer(this.scene);\n this.files = {};\n this.imageCache.clear();\n (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();\n this.unmounted = true;\n this.removeEventListeners();\n this.library.destroy();\n this.laserTrails.stop();\n this.eraserTrail.stop();\n this.onChangeEmitter.clear();\n this.store.onStoreIncrementEmitter.clear();\n this.store.onDurableIncrementEmitter.clear();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.ShapeCache.destroy();\n _snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.destroy();\n clearTimeout(touchTimeout);\n _scene__WEBPACK_IMPORTED_MODULE_31__.isSomeElementSelected.clearCache();\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements.clearCache();\n touchTimeout = 0;\n document.documentElement.style.overscrollBehaviorX = \"\";\n document.body.removeChild((0,_Tooltip__WEBPACK_IMPORTED_MODULE_70__.getTooltipDiv)()); //clearRenderCache(); //zsviczian\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.clearEraserCanvasCache)(); //zsviczian\n\n this.interactiveCanvas = null; //zsviczian\n\n this.iFrameRefs.clear(); //zsviczian\n //@ts-ignore\n\n this.iFrameRefs = null; //zsviczian\n\n this.embedsValidationStatus.clear(); //zsviczian\n //@ts-ignore\n\n this.embedsValidationStatus = null; //zsviczian\n\n this.initializedEmbeds.clear(); //zsviczian\n //@ts-ignore\n\n this.initializedEmbeds = null; //zsviczian\n\n this.elementsPendingErasure.clear(); //zsviczian\n //@ts-ignore\n\n this.elementsPendingErasure = null; //zsviczian\n\n this.lastPointerDownEvent = null; //zsviczian\n\n this.lastPointerUpEvent = null; //zsviczian\n\n this.lastPointerMoveEvent = null; //zsviczian\n //@ts-ignore\n\n this.actionManager.app = null; //zsviczian\n\n this.actionManager.actions = {}; //zsviczian\n\n this.history.clear(); //zsviczian\n\n this.store.clear(); //zsviczian\n //@ts-ignore\n\n this.store = null; //zsviczian\n //@ts-ignore\n\n this.library = null; //zsviczian\n //@ts-ignore\n\n this.canvas = null; //zsviczian\n //@ts-ignore\n\n this.rc = null; //zsviczian\n //@ts-ignore\n\n this.excalidrawContainerRef.current = undefined; //zsviczian\n\n this.nearestScrollableContainer = undefined; //zsviczian\n\n this.excalidrawContainerValue = {\n container: null,\n id: \"unknown\"\n }; //zsviczian\n //@ts-ignore\n // this.laserTrails.terminate(); //zsviczian\n // this.eraserTrail.terminate(); //zsviczian\n\n /*\r\n Object.keys(this).forEach((key) => {\r\n //@ts-ignore\r\n delete this[key];\r\n });*/\n }\n\n removeEventListeners() {\n this.onRemoveEventListenersEmitter.trigger();\n }\n\n addEventListeners() {\n // remove first as we can add event listeners multiple times\n this.removeEventListeners(); // -------------------------------------------------------------------------\n // view+edit mode listeners\n // -------------------------------------------------------------------------\n\n if (this.props.handleKeyboardGlobally) {\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, this.onKeyDown, false));\n }\n\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.WHEEL, this.handleWheel, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.MESSAGE, this.onWindowMessage, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, this.removePointer, {\n passive: false\n }), // #3553\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.COPY, this.onCopy, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYUP, this.onKeyUp, {\n passive: true\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, \"focus\", () => this.triggerRender(true), {\n passive: true\n }), //zsviczian\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, this.updateCurrentCursorPosition, {\n passive: false\n }), // rerender text elements on font load to fix #637 && #1553\n // zsviczian In Obsidian this is not needed as I manage font load separately\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document.fonts, \"loadingdone\", event => {\n const fontFaces = event.fontfaces;\n this.fonts.onLoaded(fontFaces);\n }, {\n passive: false\n }), // Safari-only desktop pinch zoom\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_START, this.onGestureStart, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_CHANGE, this.onGestureChange, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.GESTURE_END, this.onGestureEnd, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.FOCUS, () => {\n this.maybeCleanupAfterMissingPointerUp(null); // browsers (chrome?) tend to free up memory a lot, which results\n // in canvas context being cleared. Thus re-render on focus.\n\n this.triggerRender(true);\n }, {\n passive: false\n }));\n\n if (this.state.viewModeEnabled) {\n return;\n } // -------------------------------------------------------------------------\n // edit-mode listeners only\n // -------------------------------------------------------------------------\n\n\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.FULLSCREENCHANGE, this.onFullscreenChange, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.PASTE, this.pasteFromClipboard, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(document, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.CUT, this.onCut, {\n passive: false\n }), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.RESIZE, this.onResize, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.UNLOAD, this.onUnload, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(window, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, this.onBlur, false),\n /*addEventListener( //zsviczian (duplicate)\r\n this.excalidrawContainerRef.current,\r\n EVENT.WHEEL,\r\n this.handleWheel,\r\n { passive: false },\r\n ),*/\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.DRAG_OVER, this.disableEvent, false), (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)(this.excalidrawContainerRef.current, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.DROP, this.disableEvent, false));\n\n if (this.props.detectScroll) {\n this.onRemoveEventListenersEmitter.once((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.addEventListener)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getNearestScrollableContainer)(this.excalidrawContainerRef.current), _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.SCROLL, this.onScroll, {\n passive: false\n }));\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;\n\n this.updateEmbeddables();\n const elements = this.scene.getElementsIncludingDeleted();\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n\n if (!this.state.showWelcomeScreen && !elements.length) {\n this.setState({\n showWelcomeScreen: true\n });\n }\n\n if (prevProps.UIOptions.dockedSidebarBreakpoint !== this.props.UIOptions.dockedSidebarBreakpoint) {\n this.refreshEditorBreakpoints();\n }\n\n const hasFollowedPersonLeft = prevState.userToFollow && !this.state.collaborators.has(prevState.userToFollow.socketId);\n\n if (hasFollowedPersonLeft) {\n this.maybeUnfollowRemoteUser();\n }\n\n if (prevState.zoom.value !== this.state.zoom.value || prevState.scrollX !== this.state.scrollX || prevState.scrollY !== this.state.scrollY) {\n (_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.onScrollChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.state.scrollX, this.state.scrollY, this.state.zoom);\n this.onScrollChangeEmitter.trigger(this.state.scrollX, this.state.scrollY, this.state.zoom);\n }\n\n if (prevState.userToFollow !== this.state.userToFollow) {\n if (prevState.userToFollow) {\n this.onUserFollowEmitter.trigger({\n userToFollow: prevState.userToFollow,\n action: \"UNFOLLOW\"\n });\n }\n\n if (this.state.userToFollow) {\n this.onUserFollowEmitter.trigger({\n userToFollow: this.state.userToFollow,\n action: \"FOLLOW\"\n });\n }\n } // zsviczian\n\n\n if (this.state.highlightSearchResult && !this.debounceClearHighlightSearchResults && prevState.selectedElementIds !== this.state.selectedElementIds) {\n this.setState({\n highlightSearchResult: false\n });\n }\n\n if (Object.keys(this.state.selectedElementIds).length && (0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state)) {\n this.setState({\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: \"selection\"\n })\n });\n }\n\n if (this.state.activeTool.type === \"eraser\" && prevState.theme !== this.state.theme) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setEraserCursor)(this.interactiveCanvas, this.state.theme);\n } // Hide hyperlink popup if shown when element type is not selection\n\n\n if (prevState.activeTool.type === \"selection\" && this.state.activeTool.type !== \"selection\" && this.state.showHyperlinkPopup) {\n this.setState({\n showHyperlinkPopup: false\n });\n }\n\n if (prevProps.langCode !== this.props.langCode) {\n this.updateLanguage();\n }\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(prevState) && !(0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state)) {\n this.eraserTrail.endPath();\n }\n\n if (prevProps.viewModeEnabled !== this.props.viewModeEnabled) {\n this.setState({\n viewModeEnabled: !!this.props.viewModeEnabled\n });\n }\n\n if (prevState.viewModeEnabled !== this.state.viewModeEnabled) {\n this.addEventListeners();\n this.deselectElements();\n } // cleanup\n\n\n if ((((_c = prevState.openDialog) === null || _c === void 0 ? void 0 : _c.name) === \"elementLinkSelector\" || ((_d = this.state.openDialog) === null || _d === void 0 ? void 0 : _d.name) === \"elementLinkSelector\") && ((_e = prevState.openDialog) === null || _e === void 0 ? void 0 : _e.name) !== ((_f = this.state.openDialog) === null || _f === void 0 ? void 0 : _f.name)) {\n this.deselectElements();\n this.setState({\n hoveredElementIds: {}\n });\n }\n\n if (prevProps.zenModeEnabled !== this.props.zenModeEnabled) {\n this.setState({\n zenModeEnabled: !!this.props.zenModeEnabled\n });\n }\n\n if (prevProps.theme !== this.props.theme && this.props.theme) {\n this.setState({\n theme: this.props.theme\n });\n }\n\n (_g = this.excalidrawContainerRef.current) === null || _g === void 0 ? void 0 : _g.classList.toggle(\"theme--dark\", this.state.theme === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.THEME.DARK);\n\n if (((_h = this.state.selectedLinearElement) === null || _h === void 0 ? void 0 : _h.isEditing) && !this.state.selectedElementIds[this.state.selectedLinearElement.elementId]) {\n // defer so that the scheduleCapture flag isn't reset via current update\n setTimeout(() => {\n var _a; // execute only if the condition still holds when the deferred callback\n // executes (it can be scheduled multiple times depending on how\n // many times the component renders)\n\n\n ((_a = this.state.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.isEditing) && this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n });\n } // failsafe in case the state is being updated in incorrect order resulting\n // in the editingTextElement being now a deleted element\n\n\n if ((_j = this.state.editingTextElement) === null || _j === void 0 ? void 0 : _j.isDeleted) {\n this.setState({\n editingTextElement: null\n });\n }\n\n if (this.state.selectedLinearElement && !this.state.selectedElementIds[this.state.selectedLinearElement.elementId]) {\n // To make sure `selectedLinearElement` is in sync with `selectedElementIds`, however this shouldn't be needed once\n // we have a single API to update `selectedElementIds`\n this.setState({\n selectedLinearElement: null\n });\n }\n\n this.store.commit(elementsMap, this.state); // Do not notify consumers if we're still loading the scene. Among other\n // potential issues, this fixes a case where the tab isn't focused during\n // init, which would trigger onChange with empty elements, which would then\n // override whatever is in localStorage currently.\n\n if (!this.state.isLoading) {\n (_l = (_k = this.props).onChange) === null || _l === void 0 ? void 0 : _l.call(_k, elements, this.state, this.files);\n this.onChangeEmitter.trigger(elements, this.state, this.files);\n }\n }\n\n static resetTapTwice() {\n didTapTwice = false;\n firstTapPosition = null;\n } // TODO: Cover with tests\n\n\n async insertClipboardContent(data, dataTransferFiles, isPlainPaste) {\n const {\n x: sceneX,\n y: sceneY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state); // ------------------- Error -------------------\n\n if (data.errorMessage) {\n this.setState({\n errorMessage: data.errorMessage\n });\n return;\n } // ------------------- Mixed content with no files -------------------\n\n\n if (dataTransferFiles.length === 0 && !isPlainPaste && data.mixedContent) {\n await this.addElementsFromMixedContentPaste(data.mixedContent, {\n isPlainPaste,\n sceneX,\n sceneY\n });\n return;\n } // ------------------- Spreadsheet -------------------\n\n\n if (data.spreadsheet && !isPlainPaste) {\n this.setState({\n pasteDialog: {\n data: data.spreadsheet,\n shown: true\n }\n });\n return;\n } // ------------------- Images or SVG code -------------------\n\n\n const imageFiles = dataTransferFiles.map(data => data.file);\n\n if (imageFiles.length === 0 && data.text && !isPlainPaste) {\n const trimmedText = data.text.trim();\n\n if (trimmedText.startsWith(\"<svg\") && trimmedText.endsWith(\"</svg>\")) {\n // ignore SVG validation/normalization which will be done during image\n // initialization\n imageFiles.push((0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.SVGStringToFile)(trimmedText));\n }\n }\n\n if (imageFiles.length > 0) {\n if (this.isToolSupported(\"image\")) {\n await this.insertImages(imageFiles, sceneX, sceneY);\n } else {\n this.setState({\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.imageToolNotSupported\")\n });\n }\n\n return;\n } // ------------------- Elements -------------------\n\n\n if (data.elements) {\n const elements = data.programmaticAPI ? (0,_data_transform__WEBPACK_IMPORTED_MODULE_40__.convertToExcalidrawElements)(data.elements) : data.elements; // TODO: remove formatting from elements if isPlainPaste\n\n this.addElementsFromPasteOrLibrary({\n elements,\n files: data.files || null,\n position: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() ? \"center\" : \"cursor\",\n retainSeed: isPlainPaste\n });\n return;\n } // ------------------- Only textual stuff remaining -------------------\n\n\n if (!data.text) {\n return;\n } // ------------------- Successful Mermaid -------------------\n\n\n if (!isPlainPaste && (0,_mermaid__WEBPACK_IMPORTED_MODULE_48__.isMaybeMermaidDefinition)(data.text)) {\n const api = await Promise.resolve(/*! import() */).then(__webpack_require__.bind(__webpack_require__, /*! @zsviczian/mermaid-to-excalidraw */ \"../../node_modules/@zsviczian/mermaid-to-excalidraw/dist/index.js\"));\n\n try {\n const {\n elements: skeletonElements,\n files\n } = await api.parseMermaidToExcalidraw(data.text);\n const elements = (0,_data_transform__WEBPACK_IMPORTED_MODULE_40__.convertToExcalidrawElements)(skeletonElements, {\n regenerateIds: true\n });\n this.addElementsFromPasteOrLibrary({\n elements,\n files,\n position: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() ? \"center\" : \"cursor\"\n });\n return;\n } catch (err) {\n console.warn(`parsing pasted text as mermaid definition failed: ${err.message}`);\n }\n } // ------------------- Pure embeddable URLs -------------------\n\n\n const nonEmptyLines = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeEOL)(data.text).split(/\\n+/).map(s => s.trim()).filter(Boolean);\n const embbeddableUrls = nonEmptyLines.map(str => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeParseEmbedSrc)(str)).filter(string => {\n var _a;\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.embeddableURLValidator)(string, this.props.validateEmbeddable) && (/^(http|https):\\/\\/[^\\s/$.?#].[^\\s]*$/.test(string) || ((_a = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getEmbedLink)(string)) === null || _a === void 0 ? void 0 : _a.type) === \"video\");\n });\n\n if (!isPlainPaste && embbeddableUrls.length > 0 && embbeddableUrls.length === nonEmptyLines.length) {\n const embeddables = [];\n\n for (const url of embbeddableUrls) {\n const prevEmbeddable = embeddables[embeddables.length - 1];\n const embeddable = this.insertEmbeddableElement({\n sceneX: prevEmbeddable ? prevEmbeddable.x + prevEmbeddable.width + 20 : sceneX,\n sceneY,\n link: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.normalizeLink)(url)\n });\n\n if (embeddable) {\n embeddables.push(embeddable);\n }\n }\n\n if (embeddables.length) {\n this.store.scheduleCapture();\n this.setState({\n selectedElementIds: Object.fromEntries(embeddables.map(embeddable => [embeddable.id, true]))\n });\n }\n\n return;\n } // ------------------- Text -------------------\n\n\n this.addTextFromPaste(data.text, isPlainPaste);\n } // TODO rewrite this to paste both text & images at the same time if\n // pasted data contains both\n\n\n async addElementsFromMixedContentPaste(mixedContent, {\n isPlainPaste,\n sceneX,\n sceneY\n }) {\n if (!isPlainPaste && mixedContent.some(node => node.type === \"imageUrl\") && this.isToolSupported(\"image\")) {\n const imageURLs = mixedContent.filter(node => node.type === \"imageUrl\").map(node => node.value);\n const responses = await Promise.all(imageURLs.map(async url => {\n try {\n return {\n file: await (0,_data_blob__WEBPACK_IMPORTED_MODULE_33__.ImageURLToFile)(url)\n };\n } catch (error) {\n let errorMessage = error.message;\n\n if (error.cause === \"FETCH_ERROR\") {\n errorMessage = (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.failedToFetchImage\");\n } else if (error.cause === \"UNSUPPORTED\") {\n errorMessage = (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"errors.unsupportedFileType\");\n }\n\n return {\n errorMessage\n };\n }\n }));\n const imageFiles = responses.filter(response => !!response.file).map(response => response.file);\n await this.insertImages(imageFiles, sceneX, sceneY);\n const error = responses.find(response => !!response.errorMessage);\n\n if (error && error.errorMessage) {\n this.setState({\n errorMessage: error.errorMessage\n });\n }\n } else {\n const textNodes = mixedContent.filter(node => node.type === \"text\");\n\n if (textNodes.length) {\n this.addTextFromPaste(textNodes.map(node => node.value).join(\"\\n\\n\"), isPlainPaste);\n }\n }\n }\n\n addTextFromPaste(text, isPlainPaste = false) {\n const {\n x,\n y\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: this.lastViewportPosition.x,\n clientY: this.lastViewportPosition.y\n }, this.state);\n const textElementProps = {\n x,\n y,\n strokeColor: this.state.currentItemStrokeColor,\n backgroundColor: this.state.currentItemBackgroundColor,\n fillStyle: this.state.currentItemFillStyle,\n strokeWidth: this.state.currentItemStrokeWidth,\n strokeStyle: this.state.currentItemStrokeStyle,\n roundness: null,\n roughness: this.state.currentItemRoughness,\n opacity: this.state.currentItemOpacity,\n text,\n rawText: text,\n fontSize: (0,_actions_actionProperties__WEBPACK_IMPORTED_MODULE_71__.getFontSize)(this.state.currentItemFontSize, this.state.zoom.value),\n fontFamily: this.state.currentItemFontFamily,\n textAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_TEXT_ALIGN,\n verticalAlign: _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_VERTICAL_ALIGN,\n locked: false\n };\n const fontString = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFontString)({\n fontSize: textElementProps.fontSize,\n fontFamily: textElementProps.fontFamily\n });\n const lineHeight = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getLineHeight)(textElementProps.fontFamily);\n const [x1,, x2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getVisibleSceneBounds)(this.state); // long texts should not go beyond 800 pixels in width nor should it go below 200 px\n\n const maxTextWidth = Math.max(Math.min((x2 - x1) * 0.5, 800), 200);\n const LINE_GAP = 10;\n let currentY = y;\n const lines = isPlainPaste ? [text] : text.split(\"\\n\");\n const textElements = lines.reduce((acc, line, idx) => {\n var _a;\n\n const originalText = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.normalizeText)(line).trim();\n\n if (originalText.length) {\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords({\n x,\n y: currentY\n });\n let metrics = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.measureText)(originalText, fontString, lineHeight);\n const isTextUnwrapped = metrics.width > maxTextWidth;\n const text = isTextUnwrapped ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.wrapText)(originalText, fontString, maxTextWidth) : originalText;\n metrics = isTextUnwrapped ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.measureText)(text, fontString, lineHeight) : metrics;\n const startX = x - metrics.width / 2;\n const startY = currentY - metrics.height / 2;\n const element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newTextElement)(Object.assign(Object.assign({}, textElementProps), {\n x: startX,\n y: startY,\n text,\n rawText: originalText,\n //zsviczian\n originalText,\n lineHeight,\n autoResize: !isTextUnwrapped,\n frameId: topLayerFrame ? topLayerFrame.id : null\n }));\n acc.push(element);\n currentY += element.height + LINE_GAP;\n } else {\n const prevLine = (_a = lines[idx - 1]) === null || _a === void 0 ? void 0 : _a.trim(); // add paragraph only if previous line was not empty, IOW don't add\n // more than one empty line\n\n if (prevLine) {\n currentY += (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLineHeightInPx)(textElementProps.fontSize, lineHeight) + LINE_GAP;\n }\n }\n\n return acc;\n }, []);\n\n if (textElements.length === 0) {\n return;\n }\n\n this.scene.insertElements(textElements);\n this.store.scheduleCapture();\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.fromEntries(textElements.map(el => [el.id, true])), this.state)\n });\n\n if (!isPlainPaste && textElements.length > 1 && PLAIN_PASTE_TOAST_SHOWN === false && !this.device.editor.isMobile) {\n this.setToast({\n message: (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.t)(\"toast.pasteAsSingleElement\", {\n shortcut: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getShortcutKey)(\"CtrlOrCmd+Shift+V\")\n }),\n duration: 5000\n });\n PLAIN_PASTE_TOAST_SHOWN = true;\n }\n }\n\n handleTextWysiwyg(element, {\n isExistingElement = false\n }) {\n const elementsMap = this.scene.getElementsMapIncludingDeleted();\n\n const updateElement = (nextOriginalText, isDeleted, rawText, //zsviczian\n link) => {\n this.scene.replaceAllElements([// Not sure why we include deleted elements as well hence using deleted elements map\n ...this.scene.getElementsIncludingDeleted().map(_element => {\n if (_element.id === element.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(_element)) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(_element, Object.assign({\n originalText: nextOriginalText,\n rawText: rawText !== null && rawText !== void 0 ? rawText : nextOriginalText,\n //zsviczian\n link,\n isDeleted: isDeleted !== null && isDeleted !== void 0 ? isDeleted : _element.isDeleted\n }, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(_element, elementsMap), elementsMap, nextOriginalText)));\n }\n\n return _element;\n })]);\n }; //zsviczian\n\n\n if (this.props.onBeforeTextEdit) {\n const text = this.props.onBeforeTextEdit(element, isExistingElement);\n\n if (text && text !== element.originalText) {\n this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(_element => {\n if (_element.id === element.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(_element)) {\n //changing the value of element so this gets edited by textWysiwyg\n element = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(_element, Object.assign({\n originalText: text,\n rawText: text,\n isDeleted: false\n }, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(_element, elementsMap), elementsMap, text)));\n return element;\n }\n\n return _element;\n })]);\n }\n }\n\n (0,_wysiwyg_textWysiwyg__WEBPACK_IMPORTED_MODULE_46__.textWysiwyg)({\n id: element.id,\n canvas: this.canvas,\n getViewportCoords: (x, y) => {\n const {\n x: viewportX,\n y: viewportY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.sceneCoordsToViewportCoords)({\n sceneX: x,\n sceneY: y\n }, this.state);\n return [viewportX - this.state.offsetLeft, viewportY - this.state.offsetTop];\n },\n onChange: (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(nextOriginalText => {\n updateElement(nextOriginalText, false);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isNonDeletedElement)(element)) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateBoundElements)(element, this.scene);\n }\n }),\n onSubmit: (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(({\n viaKeyboard,\n nextOriginalText\n }) => {\n var _a;\n\n const isDeleted = !nextOriginalText.trim(); //zsviczian insert start\n\n const rawText = nextOriginalText; //should this be originalText??\n\n let link = undefined;\n\n if (this.props.onBeforeTextSubmit) {\n const _element = this.scene.getElementsIncludingDeleted().find(el => el.id === element.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(el));\n\n if (_element) {\n const dismensionsData = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.refreshTextDimensions)(_element, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerElement)(_element, elementsMap), elementsMap, nextOriginalText);\n const {\n updatedNextOriginalText,\n nextLink\n } = this.props.onBeforeTextSubmit(element, (_a = dismensionsData === null || dismensionsData === void 0 ? void 0 : dismensionsData.text) !== null && _a !== void 0 ? _a : nextOriginalText, //should never be undefined\n nextOriginalText, isDeleted);\n nextOriginalText = updatedNextOriginalText !== null && updatedNextOriginalText !== void 0 ? updatedNextOriginalText : nextOriginalText;\n link = nextLink;\n }\n } //zsviczian insert end\n\n\n updateElement(nextOriginalText, isDeleted, rawText, link); //zsviczian (added rawText, link, text)\n // select the created text element only if submitting via keyboard\n // (when submitting via click it should act as signal to deselect)\n\n if (!isDeleted && viaKeyboard) {\n const elementIdToSelect = element.containerId ? element.containerId : element.id; // needed to ensure state is updated before \"finalize\" action\n // that's invoked on keyboard-submit as well\n // TODO either move this into finalize as well, or handle all state\n // updates in one place, skipping finalize action\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [elementIdToSelect]: true\n }), prevState)\n }));\n });\n }\n\n if (isDeleted) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.fixBindingsAfterDeletion)(this.scene.getNonDeletedElements(), [element]);\n }\n\n if (!isDeleted || isExistingElement) {\n this.store.scheduleCapture();\n }\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n newElement: null,\n editingTextElement: null\n });\n });\n\n if (this.state.activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n\n this.focusContainer();\n }),\n element,\n excalidrawContainer: this.excalidrawContainerRef.current,\n app: this,\n // when text is selected, it's hard (at least on iOS) to re-position the\n // caret (i.e. deselect). There's not much use for always selecting\n // the text on edit anyway (and users can select-all from contextmenu\n // if needed)\n autoSelect: !this.device.isTouchScreen\n }); // deselect all other elements when inserting text\n\n this.deselectElements(); // do an initial update to re-initialize element position since we were\n // modifying element's x/y for sake of editor (case: syncing to remote)\n\n updateElement(element.originalText, false);\n }\n\n deselectElements() {\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n }\n\n getTextElementAtPosition(x, y) {\n const element = this.getElementAtPosition(x, y, {\n includeBoundTextElement: true\n });\n\n if (element && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element) && !element.isDeleted) {\n return element;\n }\n\n return null;\n } // NOTE: Hot path for hit testing, so avoid unnecessary computations\n\n\n getElementAtPosition(x, y, opts) {\n let allHitElements = [];\n\n if (opts && \"allHitElements\" in opts) {\n allHitElements = (opts === null || opts === void 0 ? void 0 : opts.allHitElements) || [];\n } else {\n allHitElements = this.getElementsAtPosition(x, y, {\n includeBoundTextElement: opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement,\n includeLockedElements: opts === null || opts === void 0 ? void 0 : opts.includeLockedElements\n });\n }\n\n if (allHitElements.length > 1) {\n if (opts === null || opts === void 0 ? void 0 : opts.preferSelected) {\n for (let index = allHitElements.length - 1; index > -1; index--) {\n if (this.state.selectedElementIds[allHitElements[index].id]) {\n return allHitElements[index];\n }\n }\n }\n\n const elementWithHighestZIndex = allHitElements[allHitElements.length - 1]; // If we're hitting element with highest z-index only on its bounding box\n // while also hitting other element figure, the latter should be considered.\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element: elementWithHighestZIndex,\n // when overlapping, we would like to be more precise\n // this also avoids the need to update past tests\n threshold: this.getElementHitThreshold(elementWithHighestZIndex) / 2,\n elementsMap: this.scene.getNonDeletedElementsMap(),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(elementWithHighestZIndex) ? this.frameNameBoundsCache.get(elementWithHighestZIndex) : null\n }) ? elementWithHighestZIndex : allHitElements[allHitElements.length - 2];\n }\n\n if (allHitElements.length === 1) {\n return allHitElements[0];\n }\n\n return null;\n } // NOTE: Hot path for hit testing, so avoid unnecessary computations\n\n\n getElementsAtPosition(x, y, opts) {\n const iframeLikes = [];\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const elements = ((opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement) && (opts === null || opts === void 0 ? void 0 : opts.includeLockedElements) ? this.scene.getNonDeletedElements() : this.scene.getNonDeletedElements().filter(element => ((opts === null || opts === void 0 ? void 0 : opts.includeLockedElements) || !element.locked) && ((opts === null || opts === void 0 ? void 0 : opts.includeBoundTextElement) || !((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(element) && element.containerId)))).filter(el => this.hitElement(x, y, el)).filter(element => {\n // hitting a frame's element from outside the frame is not considered a hit\n const containingFrame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainingFrame)(element, elementsMap);\n return containingFrame && this.state.frameRendering.enabled && this.state.frameRendering.clip ? (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isCursorInFrame)({\n x,\n y\n }, containingFrame, elementsMap) : true;\n }).filter(el => {\n // The parameter elements comes ordered from lower z-index to higher.\n // We want to preserve that order on the returned array.\n // Exception being embeddables which should be on top of everything else in\n // terms of hit testing.\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeElement)(el)) {\n iframeLikes.push(el);\n return false;\n }\n\n return true;\n }).concat(iframeLikes);\n return elements;\n }\n\n getElementHitThreshold(element) {\n return Math.max(element.strokeWidth / 2 + 0.1, // NOTE: Here be dragons. Do not go under the 0.63 multiplier unless you're\n // willing to test extensively. The hit testing starts to become unreliable\n // due to FP imprecision under 0.63 in high zoom levels.\n 0.85 * (_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_COLLISION_THRESHOLD / this.state.zoom.value));\n }\n\n hitElement(x, y, element, considerBoundingBox = true) {\n // if the element is selected, then hit test is done against its bounding box\n if (considerBoundingBox && this.state.selectedElementIds[element.id] && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.shouldShowBoundingBox)([element], this.state)) {\n // if hitting the bounding box, return early\n // but if not, we should check for other cases as well (e.g. frame name)\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundingBox)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), element, this.scene.getNonDeletedElementsMap(), this.getElementHitThreshold(element))) {\n return true;\n }\n } // take bound text element into consideration for hit collision as well\n\n\n const hitBoundTextOfElement = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundText)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y), element, this.scene.getNonDeletedElementsMap());\n\n if (hitBoundTextOfElement) {\n return true;\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element,\n threshold: this.getElementHitThreshold(element),\n elementsMap: this.scene.getNonDeletedElementsMap(),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element) ? this.frameNameBoundsCache.get(element) : null\n });\n }\n\n getTextBindableContainerAtPosition(x, y) {\n const elements = this.scene.getNonDeletedElements();\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length === 1) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextBindableContainer)(selectedElements[0], false) ? selectedElements[0] : null;\n }\n\n let hitElement = null; // We need to do hit testing from front (end of the array) to back (beginning of the array)\n\n for (let index = elements.length - 1; index >= 0; --index) {\n if (elements[index].isDeleted) {\n continue;\n }\n\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementAbsoluteCoords)(elements[index], this.scene.getNonDeletedElementsMap());\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isArrowElement)(elements[index]) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x, y),\n element: elements[index],\n elementsMap: this.scene.getNonDeletedElementsMap(),\n threshold: this.getElementHitThreshold(elements[index])\n })) {\n hitElement = elements[index];\n break;\n } else if (x1 < x && x < x2 && y1 < y && y < y2) {\n hitElement = elements[index];\n break;\n }\n }\n\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextBindableContainer)(hitElement, false) ? hitElement : null;\n }\n\n handleHoverSelectedLinearElement(linearElementEditor, scenePointerX, scenePointerY) {\n const elementsMap = this.scene.getNonDeletedElementsMap();\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(linearElementEditor.elementId, elementsMap);\n\n if (!element) {\n return;\n }\n\n if (this.state.selectedLinearElement) {\n let hoverPointIndex = -1;\n let segmentMidPointHoveredCoords = null;\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementItself)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(scenePointerX, scenePointerY),\n element,\n elementsMap,\n threshold: this.getElementHitThreshold(element)\n })) {\n hoverPointIndex = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getPointIndexUnderCursor(element, elementsMap, this.state.zoom, scenePointerX, scenePointerY);\n segmentMidPointHoveredCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(linearElementEditor, {\n x: scenePointerX,\n y: scenePointerY\n }, this.state, this.scene.getNonDeletedElementsMap());\n const isHoveringAPointHandle = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) ? hoverPointIndex === 0 || hoverPointIndex === element.points.length - 1 : hoverPointIndex >= 0;\n\n if (isHoveringAPointHandle || segmentMidPointHoveredCoords) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.POINTER);\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || Object.keys(this.state.selectedElementIds).length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\n }\n }\n } else if (this.hitElement(scenePointerX, scenePointerY, element)) {\n if ( // Ebow arrows can only be moved when unconnected\n !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(element) || !(element.startBinding || element.endBinding)) {\n if (this.state.activeTool.type !== \"lasso\" || Object.keys(this.state.selectedElementIds).length > 0) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.MOVE);\n }\n }\n }\n\n if (this.state.selectedLinearElement.hoverPointIndex !== hoverPointIndex) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n hoverPointIndex\n })\n });\n }\n\n if (!_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords, segmentMidPointHoveredCoords)) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords\n })\n });\n }\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n }\n } //mfuria #329. start right-click panning\n\n\n startRightClickPanning(event) {\n // Set up right-click panning similar to hand tool\n isPanning = true;\n this.focusContainer();\n\n if (!this.state.editingTextElement) {\n event.preventDefault();\n }\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRABBING);\n let {\n clientX: lastX,\n clientY: lastY\n } = event;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdatesThrottled)(event => {\n const deltaX = lastX - event.clientX;\n const deltaY = lastY - event.clientY;\n lastX = event.clientX;\n lastY = event.clientY;\n this.translateCanvas({\n scrollX: this.state.scrollX - deltaX / this.state.zoom.value,\n scrollY: this.state.scrollY - deltaY / this.state.zoom.value\n });\n });\n const teardown = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(() => {\n isPanning = false;\n\n if (this.state.viewModeEnabled) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.GRAB);\n } else {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n }\n\n this.setState({\n cursorButton: \"up\"\n });\n this.savePointer(event.clientX, event.clientY, \"up\");\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n onPointerMove.flush();\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.BLUR, teardown);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove, {\n passive: true\n });\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, teardown);\n }\n\n updateGestureOnPointerDown(event) {\n gesture.pointers.set(event.pointerId, {\n x: event.clientX,\n y: event.clientY\n });\n\n if (gesture.pointers.size === 2) {\n if ((0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_69__.shouldDisableZoom)(this.state)) {\n //zsviczian\n gesture.initialDistance = null;\n } else {\n gesture.lastCenter = (0,_gesture__WEBPACK_IMPORTED_MODULE_28__.getCenter)(gesture.pointers);\n gesture.initialScale = this.state.zoom.value;\n gesture.initialDistance = (0,_gesture__WEBPACK_IMPORTED_MODULE_28__.getDistance)(Array.from(gesture.pointers.values()));\n }\n }\n }\n\n initialPointerDownState(event) {\n const origin = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n const selectedElements = this.scene.getSelectedElements(this.state);\n const [minX, minY, maxX, maxY] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n const isElbowArrowOnly = selectedElements.findIndex(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow) === 0;\n return {\n origin,\n withCmdOrCtrl: event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD],\n originInGrid: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.tupleToCoors)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(origin.x, origin.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] || isElbowArrowOnly ? null : this.getEffectiveGridSize())),\n scrollbars: (0,_scene_scrollbars__WEBPACK_IMPORTED_MODULE_47__.isOverScrollBars)(currentScrollBars, event.clientX - this.state.offsetLeft, event.clientY - this.state.offsetTop),\n // we need to duplicate because we'll be updating this state\n lastCoords: Object.assign({}, origin),\n originalElements: this.scene.getNonDeletedElements().reduce((acc, element) => {\n acc.set(element.id, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.deepCopyElement)(element));\n return acc;\n }, new Map()),\n resize: {\n handleType: false,\n isResizing: false,\n offset: {\n x: 0,\n y: 0\n },\n arrowDirection: \"origin\",\n center: {\n x: (maxX + minX) / 2,\n y: (maxY + minY) / 2\n }\n },\n hit: {\n element: null,\n allHitElements: [],\n wasAddedToSelection: false,\n hasBeenDuplicated: false,\n hasHitCommonBoundingBoxOfSelectedElements: this.isHittingCommonBoundingBoxOfSelectedElements(origin, selectedElements)\n },\n drag: {\n hasOccurred: false,\n offset: null,\n origin: Object.assign({}, origin),\n blockDragging: false\n },\n eventListeners: {\n onMove: null,\n onUp: null,\n onKeyUp: null,\n onKeyDown: null\n },\n boxSelection: {\n hasOccurred: false\n }\n };\n } // Returns whether the event is a dragging a scrollbar\n\n\n handleDraggingScrollBar(event, pointerDownState) {\n if (!(pointerDownState.scrollbars.isOverEither && !this.state.multiElement)) {\n return false;\n }\n\n isDraggingScrollBar = true;\n pointerDownState.lastCoords.x = event.clientX;\n pointerDownState.lastCoords.y = event.clientY;\n const onPointerMove = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdatesThrottled)(event => {\n const target = event.target;\n\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n this.handlePointerMoveOverScrollbars(event, pointerDownState);\n });\n const onPointerUp = (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(() => {\n lastPointerUp = null;\n isDraggingScrollBar = false;\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursorForShape)(this.interactiveCanvas, this.state);\n this.setState({\n cursorButton: \"up\"\n });\n this.savePointer(event.clientX, event.clientY, \"up\");\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp);\n onPointerMove.flush();\n });\n lastPointerUp = onPointerUp;\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, onPointerMove);\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, onPointerUp);\n return true;\n }\n\n isASelectedElement(hitElement) {\n return hitElement != null && this.state.selectedElementIds[hitElement.id];\n }\n\n isHittingCommonBoundingBoxOfSelectedElements(point, selectedElements) {\n if (selectedElements.length < 2) {\n return false;\n } // How many pixels off the shape boundary we still consider a hit\n\n\n const threshold = Math.max(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.DEFAULT_COLLISION_THRESHOLD / this.state.zoom.value, 1);\n const [x1, y1, x2, y2] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getCommonBounds)(selectedElements);\n return point.x > x1 - threshold && point.x < x2 + threshold && point.y > y1 - threshold && point.y < y2 + threshold;\n }\n\n getCurrentItemRoundness(elementType) {\n return this.state.currentItemRoundness === \"round\" ? {\n type: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isUsingAdaptiveRadius)(elementType) ? _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.ADAPTIVE_RADIUS : _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.ROUNDNESS.PROPORTIONAL_RADIUS\n } : null;\n }\n\n maybeCacheReferenceSnapPoints(event, selectedElements, recomputeAnyways = false) {\n if ((0,_snapping__WEBPACK_IMPORTED_MODULE_39__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.getReferenceSnapPoints())) {\n _snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.setReferenceSnapPoints((0,_snapping__WEBPACK_IMPORTED_MODULE_39__.getReferenceSnapPoints)(this.scene.getNonDeletedElements(), selectedElements, this.state, this.scene.getNonDeletedElementsMap()));\n }\n }\n\n maybeCacheVisibleGaps(event, selectedElements, recomputeAnyways = false) {\n if ((0,_snapping__WEBPACK_IMPORTED_MODULE_39__.isSnappingEnabled)({\n event,\n app: this,\n selectedElements\n }) && (recomputeAnyways || !_snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.getVisibleGaps())) {\n _snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.setVisibleGaps((0,_snapping__WEBPACK_IMPORTED_MODULE_39__.getVisibleGaps)(this.scene.getNonDeletedElements(), selectedElements, this.state, this.scene.getNonDeletedElementsMap()));\n }\n }\n\n onKeyDownFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n if (this.maybeHandleResize(pointerDownState, event)) {\n return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\n });\n }\n\n onKeyUpFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(event => {\n // Prevents focus from escaping excalidraw tab\n event.key === _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.ALT && event.preventDefault();\n\n if (this.maybeHandleResize(pointerDownState, event)) {\n return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\n });\n }\n\n onPointerMoveFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdatesThrottled)(event => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j; //To avoid pointerMove canceling the selection of locked elements on mobile //zsviczian\n\n\n if (Boolean(this.state.contextMenu) || ((_a = this.state.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n return;\n }\n\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state);\n\n if (this.state.activeLockedId) {\n this.setState({\n activeLockedId: null\n });\n }\n\n if (this.state.selectedLinearElement && this.state.selectedLinearElement.elbowed && this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index) {\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n let index = this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;\n\n if (index < 0) {\n const nextCoords = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidpointHitCoords(Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: null\n }), {\n x: gridX,\n y: gridY\n }, this.state, this.scene.getNonDeletedElementsMap());\n index = nextCoords ? _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getSegmentMidPointIndex(this.state.selectedLinearElement, this.state, nextCoords, this.scene.getNonDeletedElementsMap()) : -1;\n }\n\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.moveFixedSegment(this.state.selectedLinearElement, index, gridX, gridY, this.scene);\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n segmentMidPointHoveredCoords: ret.segmentMidPointHoveredCoords,\n pointerDownState: ret.pointerDownState\n })\n });\n return;\n }\n\n const lastPointerCoords = (_b = this.lastPointerMoveCoords) !== null && _b !== void 0 ? _b : pointerDownState.origin;\n this.lastPointerMoveCoords = pointerCoords; // We need to initialize dragOffsetXY only after we've updated\n // `state.selectedElementIds` on pointerDown. Doing it here in pointerMove\n // event handler should hopefully ensure we're already working with\n // the updated state.\n\n if (pointerDownState.drag.offset === null) {\n pointerDownState.drag.offset = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.tupleToCoors)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getDragOffsetXY)(this.scene.getSelectedElements(this.state), pointerDownState.origin.x, pointerDownState.origin.y));\n }\n\n const target = event.target;\n\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n if (this.handlePointerMoveOverScrollbars(event, pointerDownState)) {\n return;\n }\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state)) {\n this.handleEraser(event, pointerCoords);\n return;\n }\n\n if (this.state.activeTool.type === \"laser\") {\n this.laserTrails.addPointToPath(pointerCoords.x, pointerCoords.y);\n }\n\n const [gridX, gridY] = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getGridPoint)(pointerCoords.x, pointerCoords.y, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize()); // for arrows/lines, don't start dragging until a given threshold\n // to ensure we don't create a 2-point arrow by mistake when\n // user clicks mouse in a way that it moves a tiny bit (thus\n // triggering pointermove)\n\n if (!pointerDownState.drag.hasOccurred && (this.state.activeTool.type === \"arrow\" || this.state.activeTool.type === \"line\")) {\n if ((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerCoords.x, pointerCoords.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y)) * this.state.zoom.value < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MINIMUM_ARROW_SIZE) {\n return;\n }\n }\n\n if (pointerDownState.resize.isResizing) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n\n if (this.maybeHandleCrop(pointerDownState, event)) {\n return true;\n }\n\n if (this.maybeHandleResize(pointerDownState, event)) {\n return true;\n }\n }\n\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if (this.state.selectedLinearElement) {\n const linearElementEditor = this.state.selectedLinearElement;\n\n if (_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.shouldAddMidpoint(this.state.selectedLinearElement, pointerCoords, this.state, elementsMap)) {\n const ret = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.addMidpoint(this.state.selectedLinearElement, pointerCoords, this, !event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD], this.scene);\n\n if (!ret) {\n return;\n } // Since we are reading from previous state which is not possible with\n // automatic batching in React 18 hence using flush sync to synchronously\n // update the state. Check https://github.com/excalidraw/excalidraw/pull/5508 for more details.\n\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n if (this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: Object.assign(Object.assign({}, this.state.selectedLinearElement), {\n pointerDownState: ret.pointerDownState,\n selectedPointsIndices: ret.selectedPointsIndices,\n segmentMidPointHoveredCoords: null\n })\n });\n }\n });\n return;\n } else if (linearElementEditor.pointerDownState.segmentMidpoint.value !== null && !linearElementEditor.pointerDownState.segmentMidpoint.added) {\n return;\n }\n\n const newState = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointDragging(event, this, pointerCoords.x, pointerCoords.y, linearElementEditor);\n\n if (newState) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n pointerDownState.drag.hasOccurred = true;\n this.setState(newState);\n return;\n }\n }\n\n const hasHitASelectedElement = pointerDownState.hit.allHitElements.some(element => this.isASelectedElement(element));\n const isSelectingPointsInLineEditor = ((_c = this.state.selectedLinearElement) === null || _c === void 0 ? void 0 : _c.isEditing) && event.shiftKey && this.state.selectedLinearElement.elementId === ((_d = pointerDownState.hit.element) === null || _d === void 0 ? void 0 : _d.id);\n\n if ((hasHitASelectedElement || pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements) && !isSelectingPointsInLineEditor && !pointerDownState.drag.blockDragging) {\n const selectedElements = this.scene.getSelectedElements(this.state);\n\n if (selectedElements.length > 0 && selectedElements.every(element => element.locked)) {\n return;\n }\n\n const selectedElementsHasAFrame = selectedElements.find(e => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(e));\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords(pointerCoords);\n const frameToHighlight = topLayerFrame && !selectedElementsHasAFrame ? topLayerFrame : null; // Only update the state if there is a difference\n\n if (this.state.frameToHighlight !== frameToHighlight) {\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n this.setState({\n frameToHighlight\n });\n });\n } // Marking that click was used for dragging to check\n // if elements should be deselected on pointerup\n\n\n pointerDownState.drag.hasOccurred = true; // prevent immediate dragging during lasso selection to avoid element displacement\n // only allow dragging if we're not in the middle of lasso selection\n // (on mobile, allow dragging if we hit an element)\n\n if (this.state.activeTool.type === \"lasso\" && this.lassoTrail.hasCurrentTrail && !((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isMobileOrTablet)() && pointerDownState.hit.element) && !this.state.activeTool.fromSelection) {\n return;\n } // Clear lasso trail when starting to drag selected elements with lasso tool\n // Only clear if we're actually dragging (not during lasso selection)\n\n\n if (this.state.activeTool.type === \"lasso\" && selectedElements.length > 0 && pointerDownState.drag.hasOccurred && !this.state.activeTool.fromSelection) {\n this.lassoTrail.endPath();\n } // prevent dragging even if we're no longer holding cmd/ctrl otherwise\n // it would have weird results (stuff jumping all over the screen)\n // Checking for editingTextElement to avoid jump while editing on mobile #6503\n\n\n if (selectedElements.length > 0 && !pointerDownState.withCmdOrCtrl && !this.state.editingTextElement && ((_e = this.state.activeEmbeddable) === null || _e === void 0 ? void 0 : _e.state) !== \"active\") {\n const dragOffset = {\n x: pointerCoords.x - pointerDownState.drag.origin.x,\n y: pointerCoords.y - pointerDownState.drag.origin.y\n };\n const originalElements = [...pointerDownState.originalElements.values()]; // We only drag in one direction if shift is pressed\n\n const lockDirection = event.shiftKey;\n\n if (lockDirection) {\n const distanceX = Math.abs(dragOffset.x);\n const distanceY = Math.abs(dragOffset.y);\n const lockX = lockDirection && distanceX < distanceY;\n const lockY = lockDirection && distanceX > distanceY;\n\n if (lockX) {\n dragOffset.x = 0;\n }\n\n if (lockY) {\n dragOffset.y = 0;\n }\n } // #region move crop region\n\n\n if (this.state.croppingElementId) {\n const croppingElement = this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);\n\n if (croppingElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isImageElement)(croppingElement) && croppingElement.crop !== null && pointerDownState.hit.element === croppingElement) {\n const crop = croppingElement.crop;\n const image = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInitializedImageElement)(croppingElement) && ((_f = this.imageCache.get(croppingElement.fileId)) === null || _f === void 0 ? void 0 : _f.image);\n\n if (image && !(image instanceof Promise)) {\n const instantDragOffset = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorScale)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vector)(pointerCoords.x - lastPointerCoords.x, pointerCoords.y - lastPointerCoords.y), Math.max(this.state.zoom.value, 2));\n const [x1, y1, x2, y2, cx, cy] = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementAbsoluteCoords)(croppingElement, elementsMap);\n const topLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x1, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const topRight = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x2, y1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const bottomLeft = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorFromPoint)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointRotateRads)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(x1, y2), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(cx, cy), croppingElement.angle));\n const topEdge = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorSubtract)(topRight, topLeft));\n const leftEdge = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorNormalize)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorSubtract)(bottomLeft, topLeft)); // project instantDrafOffset onto leftEdge and topEdge to decompose\n\n const offsetVector = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vector)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorDot)(instantDragOffset, topEdge), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.vectorDot)(instantDragOffset, leftEdge));\n const nextCrop = Object.assign(Object.assign({}, crop), {\n x: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.clamp)(crop.x - offsetVector[0] * Math.sign(croppingElement.scale[0]), 0, image.naturalWidth - crop.width),\n y: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.clamp)(crop.y - offsetVector[1] * Math.sign(croppingElement.scale[1]), 0, image.naturalHeight - crop.height)\n });\n this.scene.mutateElement(croppingElement, {\n crop: nextCrop\n });\n return;\n }\n }\n } // Snap cache *must* be synchronously popuplated before initial drag,\n // otherwise the first drag even will not snap, causing a jump before\n // it snaps to its position if previously snapped already.\n\n\n this.maybeCacheVisibleGaps(event, selectedElements);\n this.maybeCacheReferenceSnapPoints(event, selectedElements);\n const {\n snapOffset,\n snapLines\n } = (0,_snapping__WEBPACK_IMPORTED_MODULE_39__.snapDraggedElements)(originalElements, dragOffset, this, event, this.scene.getNonDeletedElementsMap());\n this.setState({\n snapLines\n }); // when we're editing the name of a frame, we want the user to be\n // able to select and interact with the text input\n\n if (!this.state.editingFrame) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.dragSelectedElements)(pointerDownState, selectedElements, dragOffset, this.scene, snapOffset, event[_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize());\n }\n\n this.setState({\n selectedElementsAreBeingDragged: true,\n // element is being dragged and selectionElement that was created on pointer down\n // should be removed\n selectionElement: null\n });\n\n if (selectedElements.length !== 1 || !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(selectedElements[0])) {\n this.setState({\n suggestedBindings: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSuggestedBindingsForArrows)(selectedElements, this.scene.getNonDeletedElementsMap(), this.state.zoom)\n });\n } // We duplicate the selected element if alt is pressed on pointer move\n\n\n if (event.altKey && !pointerDownState.hit.hasBeenDuplicated) {\n // Move the currently selected elements to the top of the z index stack, and\n // put the duplicates where the selected elements used to be.\n // (the origin point where the dragging started)\n pointerDownState.hit.hasBeenDuplicated = true;\n const elements = this.scene.getElementsIncludingDeleted();\n const hitElement = pointerDownState.hit.element;\n const selectedElements = this.scene.getSelectedElements({\n selectedElementIds: this.state.selectedElementIds,\n includeBoundTextElement: true,\n includeElementsInFrames: true\n });\n\n if (hitElement && // hit element may not end up being selected\n // if we're alt-dragging a common bounding box\n // over the hit element\n pointerDownState.hit.wasAddedToSelection && !selectedElements.find(el => el.id === hitElement.id)) {\n selectedElements.push(hitElement);\n }\n\n const idsOfElementsToDuplicate = new Map(selectedElements.map(el => [el.id, el]));\n const {\n duplicatedElements,\n duplicateElementsMap,\n elementsWithDuplicates,\n origIdToDuplicateId\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.duplicateElements)({\n type: \"in-place\",\n elements,\n appState: this.state,\n randomizeSeed: true,\n idsOfElementsToDuplicate,\n overrides: ({\n duplicateElement,\n origElement\n }) => {\n var _a;\n\n return {\n // reset to the original element's frameId (unless we've\n // duplicated alongside a frame in which case we need to\n // keep the duplicate frame's id) so that the element\n // frame membership is refreshed on pointerup\n // NOTE this is a hacky solution and should be done\n // differently\n frameId: (_a = duplicateElement.frameId) !== null && _a !== void 0 ? _a : origElement.frameId,\n seed: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.randomInteger)()\n };\n }\n });\n duplicatedElements.forEach(element => {\n pointerDownState.originalElements.set(element.id, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.deepCopyElement)(element));\n });\n const mappedClonedElements = elementsWithDuplicates.map(el => {\n if (idsOfElementsToDuplicate.has(el.id)) {\n const origEl = pointerDownState.originalElements.get(el.id);\n\n if (origEl) {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.newElementWith)(el, {\n x: origEl.x,\n y: origEl.y\n });\n }\n }\n\n return el;\n });\n const mappedNewSceneElements = (_h = (_g = this.props).onDuplicate) === null || _h === void 0 ? void 0 : _h.call(_g, mappedClonedElements, elements);\n const elementsWithIndices = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.syncMovedIndices)(mappedNewSceneElements || mappedClonedElements, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.arrayToMap)(duplicatedElements)); // we need to update synchronously so as to keep pointerDownState,\n // appState, and scene elements in sync\n\n (0,react_dom__WEBPACK_IMPORTED_MODULE_3__.flushSync)(() => {\n // swap hit element with the duplicated one\n if (pointerDownState.hit.element) {\n const cloneId = origIdToDuplicateId.get(pointerDownState.hit.element.id);\n const clonedElement = cloneId && duplicateElementsMap.get(cloneId);\n pointerDownState.hit.element = clonedElement || null;\n } // swap hit elements with the duplicated ones\n\n\n pointerDownState.hit.allHitElements = pointerDownState.hit.allHitElements.reduce((acc, origHitElement) => {\n const cloneId = origIdToDuplicateId.get(origHitElement.id);\n const clonedElement = cloneId && duplicateElementsMap.get(cloneId);\n\n if (clonedElement) {\n acc.push(clonedElement);\n }\n\n return acc;\n }, []); // update drag origin to the position at which we started\n // the duplication so that the drag offset is correct\n\n pointerDownState.drag.origin = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(event, this.state); // switch selected elements to the duplicated ones\n\n this.setState(prevState => Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getSelectionStateForElements)(duplicatedElements, this.scene.getNonDeletedElements(), prevState)));\n this.scene.replaceAllElements(elementsWithIndices);\n this.maybeCacheVisibleGaps(event, selectedElements, true);\n this.maybeCacheReferenceSnapPoints(event, selectedElements, true);\n });\n }\n\n return;\n }\n }\n\n if (this.state.selectionElement) {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n\n if (event.altKey) {\n this.setActiveTool({\n type: \"lasso\",\n fromSelection: true\n }, event.shiftKey);\n this.lassoTrail.startPath(pointerDownState.origin.x, pointerDownState.origin.y, event.shiftKey);\n this.setAppState({\n selectionElement: null\n });\n return;\n }\n\n this.maybeDragNewGenericElement(pointerDownState, event);\n } else if (this.state.activeTool.type === \"lasso\") {\n if (!event.altKey && this.state.activeTool.fromSelection) {\n this.setActiveTool({\n type: \"selection\"\n });\n this.createGenericElementOnPointerDown(\"selection\", pointerDownState);\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n this.maybeDragNewGenericElement(pointerDownState, event);\n this.lassoTrail.endPath();\n } else {\n this.lassoTrail.addPointToPath(pointerCoords.x, pointerCoords.y, event.shiftKey);\n }\n } else {\n // It is very important to read this.state within each move event,\n // otherwise we would read a stale one!\n const newElement = this.state.newElement;\n\n if (!newElement) {\n return;\n }\n\n if (newElement.type === \"freedraw\") {\n const points = newElement.points;\n const dx = pointerCoords.x - newElement.x;\n const dy = pointerCoords.y - newElement.y;\n const lastPoint = points.length > 0 && points[points.length - 1];\n const discardPoint = lastPoint && lastPoint[0] === dx && lastPoint[1] === dy;\n\n if (!discardPoint) {\n const strokeOptions = this.state.currentStrokeOptions; //zsviczian\n\n const pressures = newElement.simulatePressure ? newElement.pressures : [//zsviczian\n ...newElement.pressures, (strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.constantPressure) ? 1 : event.pressure];\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)],\n pressures\n }, {\n informMutation: false,\n isDragging: false\n });\n this.setState({\n newElement\n });\n }\n } else if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newElement)) {\n pointerDownState.drag.hasOccurred = true;\n const points = newElement.points;\n let dx = gridX - newElement.x;\n let dy = gridY - newElement.y;\n\n if ((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.shouldRotateWithDiscreteAngle)(event) && points.length === 2) {\n ({\n width: dx,\n height: dy\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getLockedLinearCursorAlignSize)(newElement.x, newElement.y, pointerCoords.x, pointerCoords.y));\n }\n\n if (points.length === 1) {\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n informMutation: false,\n isDragging: false\n });\n } else if (points.length === 2 || points.length > 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(newElement)) {\n this.scene.mutateElement(newElement, {\n points: [...points.slice(0, -1), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n isDragging: true,\n informMutation: false\n });\n }\n\n this.setState({\n newElement\n });\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(newElement, false)) {\n // When creating a linear element by dragging\n this.setState({\n suggestedBindings: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.maybeSuggestBindingsForLinearElementAtCoords)(newElement, [pointerCoords], this.scene, this.state.zoom, this.state.startBoundElement)\n });\n }\n } else {\n pointerDownState.lastCoords.x = pointerCoords.x;\n pointerDownState.lastCoords.y = pointerCoords.y;\n this.maybeDragNewGenericElement(pointerDownState, event, false);\n }\n }\n\n if (this.state.activeTool.type === \"selection\") {\n pointerDownState.boxSelection.hasOccurred = true;\n const elements = this.scene.getNonDeletedElements(); // box-select line editor points\n\n if ((_j = this.state.selectedLinearElement) === null || _j === void 0 ? void 0 : _j.isEditing) {\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handleBoxSelection(event, this.state, this.setState.bind(this), this.scene.getNonDeletedElementsMap()); // regular box-select\n } else {\n let shouldReuseSelection = true;\n\n if (!event.shiftKey && (0,_scene__WEBPACK_IMPORTED_MODULE_31__.isSomeElementSelected)(elements, this.state)) {\n if (pointerDownState.withCmdOrCtrl && pointerDownState.hit.element) {\n this.setState(prevState => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)(Object.assign(Object.assign({}, prevState), {\n selectedElementIds: {\n [pointerDownState.hit.element.id]: true\n }\n }), this.scene.getNonDeletedElements(), prevState, this));\n } else {\n shouldReuseSelection = false;\n }\n }\n\n const elementsWithinSelection = this.state.selectionElement ? (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getElementsWithinSelection)(elements, this.state.selectionElement, this.scene.getNonDeletedElementsMap(), false) : [];\n this.setState(prevState => {\n const nextSelectedElementIds = Object.assign(Object.assign({}, shouldReuseSelection && prevState.selectedElementIds), elementsWithinSelection.reduce((acc, element) => {\n acc[element.id] = true;\n return acc;\n }, {}));\n\n if (pointerDownState.hit.element) {\n // if using ctrl/cmd, select the hitElement only if we\n // haven't box-selected anything else\n if (!elementsWithinSelection.length) {\n nextSelectedElementIds[pointerDownState.hit.element.id] = true;\n } else {\n delete nextSelectedElementIds[pointerDownState.hit.element.id];\n }\n }\n\n prevState = !shouldReuseSelection ? Object.assign(Object.assign({}, prevState), {\n selectedGroupIds: {},\n editingGroupId: null\n }) : prevState;\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n // select linear element only when we haven't box-selected anything else\n selectedLinearElement: elementsWithinSelection.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(elementsWithinSelection[0]) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(elementsWithinSelection[0], this.scene.getNonDeletedElementsMap()) : null,\n showHyperlinkPopup: elementsWithinSelection.length === 1 && (elementsWithinSelection[0].link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(elementsWithinSelection[0])) ? \"info\" : false\n });\n });\n }\n }\n });\n } // Returns whether the pointer move happened over either scrollbar\n\n\n handlePointerMoveOverScrollbars(event, pointerDownState) {\n var _a, _b;\n\n if (pointerDownState.scrollbars.isOverHorizontal) {\n const x = event.clientX;\n const dx = x - pointerDownState.lastCoords.x;\n this.translateCanvas({\n scrollX: this.state.scrollX - dx * (((_a = currentScrollBars.horizontal) === null || _a === void 0 ? void 0 : _a.deltaMultiplier) || 1) / this.state.zoom.value\n });\n pointerDownState.lastCoords.x = x;\n return true;\n }\n\n if (pointerDownState.scrollbars.isOverVertical) {\n const y = event.clientY;\n const dy = y - pointerDownState.lastCoords.y;\n this.translateCanvas({\n scrollY: this.state.scrollY - dy * (((_b = currentScrollBars.vertical) === null || _b === void 0 ? void 0 : _b.deltaMultiplier) || 1) / this.state.zoom.value\n });\n pointerDownState.lastCoords.y = y;\n return true;\n }\n\n return false;\n }\n\n onPointerUpFromPointerDownHandler(pointerDownState) {\n return (0,_reactUtils__WEBPACK_IMPORTED_MODULE_45__.withBatchedUpdates)(childEvent => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;\n\n this.removePointer(childEvent);\n pointerDownState.drag.blockDragging = false;\n\n if (pointerDownState.eventListeners.onMove) {\n pointerDownState.eventListeners.onMove.flush();\n }\n\n const {\n newElement,\n resizingElement,\n croppingElementId,\n multiElement,\n activeTool,\n isResizing,\n isRotating,\n isCropping\n } = this.state;\n this.setState(prevState => ({\n isResizing: false,\n isRotating: false,\n isCropping: false,\n resizingElement: null,\n selectionElement: null,\n frameToHighlight: null,\n elementsToHighlight: null,\n cursorButton: \"up\",\n snapLines: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateStable)(prevState.snapLines, []),\n originSnapOffset: null\n })); // just in case, tool changes mid drag, always clean up\n\n this.lassoTrail.endPath();\n this.lastPointerMoveCoords = null;\n _snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.setReferenceSnapPoints(null);\n _snapping__WEBPACK_IMPORTED_MODULE_39__.SnapCache.setVisibleGaps(null);\n this.savePointer(childEvent.clientX, childEvent.clientY, \"up\"); // if current elements are still selected\n // and the pointer is just over a locked element\n // do not allow activeLockedId to be set\n\n const hitElements = pointerDownState.hit.allHitElements;\n const sceneCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: childEvent.clientX,\n clientY: childEvent.clientY\n }, this.state);\n\n if (this.state.activeTool.type === \"selection\" && !pointerDownState.boxSelection.hasOccurred && !pointerDownState.resize.isResizing && !hitElements.some(el => this.state.selectedElementIds[el.id])) {\n const hitLockedElement = this.getElementAtPosition(sceneCoords.x, sceneCoords.y, {\n includeLockedElements: true\n });\n this.store.scheduleCapture();\n\n if (hitLockedElement === null || hitLockedElement === void 0 ? void 0 : hitLockedElement.locked) {\n this.setState({\n activeLockedId: hitLockedElement.groupIds.length > 0 ? hitLockedElement.groupIds.at(-1) || \"\" : hitLockedElement.id\n });\n } else {\n this.setState({\n activeLockedId: null\n });\n }\n } else {\n this.setState({\n activeLockedId: null\n });\n }\n\n this.setState({\n selectedElementsAreBeingDragged: false\n });\n const elementsMap = this.scene.getNonDeletedElementsMap();\n\n if (pointerDownState.drag.hasOccurred && ((_b = (_a = pointerDownState.hit) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.id)) {\n const element = elementsMap.get(pointerDownState.hit.element.id);\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindableElement)(element)) {\n // Renormalize elbow arrows when they are changed via indirect move\n (_c = element.boundElements) === null || _c === void 0 ? void 0 : _c.filter(e => e.type === \"arrow\").map(e => elementsMap.get(e.id)).filter(e => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(e)).forEach(e => {\n !!e && this.scene.mutateElement(e, {});\n });\n }\n } // Handle end of dragging a point of a linear element, might close a loop\n // and sets binding element\n\n\n if ((_d = this.state.selectedLinearElement) === null || _d === void 0 ? void 0 : _d.isEditing) {\n if (!pointerDownState.boxSelection.hasOccurred && ((_f = (_e = pointerDownState.hit) === null || _e === void 0 ? void 0 : _e.element) === null || _f === void 0 ? void 0 : _f.id) !== this.state.selectedLinearElement.elementId) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n } else {\n const editingLinearElement = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.handlePointerUp(childEvent, this.state.selectedLinearElement, this.state, this.scene);\n\n if (editingLinearElement !== this.state.selectedLinearElement) {\n this.setState({\n selectedLinearElement: editingLinearElement,\n suggestedBindings: []\n });\n }\n }\n } else if (this.state.selectedLinearElement) {\n // Normalize elbow arrow points, remove close parallel segments\n if (this.state.selectedLinearElement.elbowed) {\n const element = _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor.getElement(this.state.selectedLinearElement.elementId, this.scene.getNonDeletedElementsMap());\n\n if (element) {\n this.scene.mutateElement(element, {});\n }\n }\n\n if (((_h = (_g = pointerDownState.hit) === null || _g === void 0 ? void 0 : _g.element) === null || _h === void 0 ? void 0 : _h.id) !== this.state.selectedLinearElement.elementId) {\n const selectedELements = this.scene.getSelectedElements(this.state); // set selectedLinearElement to null if there is more than one element selected since we don't want to show linear element handles\n\n if (selectedELements.length > 1) {\n this.setState({\n selectedLinearElement: null\n });\n }\n } else if (this.state.selectedLinearElement.isDragging) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: childEvent,\n sceneCoords\n });\n }\n }\n\n this.missingPointerEventCleanupEmitter.clear();\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_MOVE, pointerDownState.eventListeners.onMove);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.POINTER_UP, pointerDownState.eventListeners.onUp);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYDOWN, pointerDownState.eventListeners.onKeyDown);\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.EVENT.KEYUP, pointerDownState.eventListeners.onKeyUp);\n (_k = (_j = this.props) === null || _j === void 0 ? void 0 : _j.onPointerUp) === null || _k === void 0 ? void 0 : _k.call(_j, activeTool, pointerDownState);\n this.onPointerUpEmitter.trigger(this.state.activeTool, pointerDownState, childEvent);\n\n if ((newElement === null || newElement === void 0 ? void 0 : newElement.type) === \"freedraw\") {\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(childEvent, this.state);\n const points = newElement.points;\n let dx = pointerCoords.x - newElement.x;\n let dy = pointerCoords.y - newElement.y; // Allows dots to avoid being flagged as infinitely small\n\n if (dx === points[0][0] && dy === points[0][1]) {\n dy += 0.0001;\n dx += 0.0001;\n }\n\n const pressures = newElement.simulatePressure ? [] : [...newElement.pressures, childEvent.pressure];\n this.scene.mutateElement(newElement, {\n points: [...points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)],\n pressures,\n lastCommittedPoint: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newElement)) {\n if (newElement.points.length > 1) {\n this.store.scheduleCapture();\n }\n\n const pointerCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(childEvent, this.state);\n const dragDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerCoords.x, pointerCoords.y), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y)) * this.state.zoom.value;\n\n if ((!pointerDownState.drag.hasOccurred || dragDistance < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.MINIMUM_ARROW_SIZE) && newElement && !multiElement) {\n if (this.device.isTouchScreen && newElement.points.length > 1) {\n //zsviczian\n const FIXED_DELTA_X = Math.min(this.state.width * 0.7 / this.state.zoom.value, 100);\n this.scene.mutateElement(newElement, {\n x: newElement.x - FIXED_DELTA_X / 2,\n points: [(0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(0, 0), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(FIXED_DELTA_X, 0)]\n }, {\n informMutation: false,\n isDragging: false\n });\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize);\n } else {\n const dx = pointerCoords.x - newElement.x;\n const dy = pointerCoords.y - newElement.y;\n this.scene.mutateElement(newElement, {\n points: [...newElement.points, (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(dx, dy)]\n }, {\n informMutation: false,\n isDragging: false\n });\n this.setState({\n multiElement: newElement,\n newElement\n });\n }\n } else if (pointerDownState.drag.hasOccurred && !multiElement) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingElement)(newElement, false)) {\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionFinalize, \"ui\", {\n event: childEvent,\n sceneCoords\n });\n }\n\n this.setState({\n suggestedBindings: [],\n startBoundElement: null\n });\n\n if (!activeTool.locked) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n this.setState(prevState => ({\n newElement: null,\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.defaultSelectionTool\n }),\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n selectedLinearElement: new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(newElement, this.scene.getNonDeletedElementsMap())\n }));\n } else {\n this.setState(prevState => ({\n newElement: null\n }));\n } // so that the scene gets rendered again to display the newly drawn linear as well\n\n\n this.scene.triggerUpdate();\n }\n\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isTextElement)(newElement)) {\n const minWidth = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getMinTextElementWidth)((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.getFontString)({\n fontSize: newElement.fontSize,\n fontFamily: newElement.fontFamily\n }), newElement.lineHeight);\n\n if (newElement.width < minWidth) {\n this.scene.mutateElement(newElement, {\n autoResize: true\n });\n }\n\n this.resetCursor();\n this.handleTextWysiwyg(newElement, {\n isExistingElement: true\n });\n }\n\n if (activeTool.type !== \"selection\" && newElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInvisiblySmallElement)(newElement)) {\n // remove invisible element which was added in onPointerDown\n // update the store snapshot, so that invisible elements are not captured by the store\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== newElement.id),\n appState: {\n newElement: null\n },\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER\n });\n return;\n }\n\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(newElement)) {\n const elementsInsideFrame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInNewFrame)(this.scene.getElementsIncludingDeleted(), newElement, this.scene.getNonDeletedElementsMap());\n this.scene.replaceAllElements((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(this.scene.getElementsMapIncludingDeleted(), elementsInsideFrame, newElement, this.state));\n }\n\n if (newElement) {\n this.scene.mutateElement(newElement, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getNormalizedDimensions)(newElement), {\n informMutation: false,\n isDragging: false\n }); // the above does not guarantee the scene to be rendered again, hence the trigger below\n\n this.scene.triggerUpdate();\n }\n\n if (pointerDownState.drag.hasOccurred) {\n const sceneCoords = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)(childEvent, this.state); // when editing the points of a linear element, we check if the\n // linear element still is in the frame afterwards\n // if not, the linear element will be removed from its frame (if any)\n\n if (this.state.selectedLinearElement && this.state.selectedLinearElement.isDragging) {\n const linearElement = this.scene.getElement(this.state.selectedLinearElement.elementId);\n\n if (linearElement === null || linearElement === void 0 ? void 0 : linearElement.frameId) {\n const frame = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainingFrame)(linearElement, elementsMap);\n\n if (frame && linearElement) {\n if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.elementOverlapsWithFrame)(linearElement, frame, this.scene.getNonDeletedElementsMap())) {\n // remove the linear element from all groups\n // before removing it from the frame as well\n this.scene.mutateElement(linearElement, {\n groupIds: []\n });\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.removeElementsFromFrame)([linearElement], this.scene.getNonDeletedElementsMap());\n this.scene.triggerUpdate();\n }\n }\n }\n } else {\n // update the relationships between selected elements and frames\n const topLayerFrame = this.getTopLayerFrameAtSceneCoords(sceneCoords);\n const selectedElements = this.scene.getSelectedElements(this.state);\n let nextElements = this.scene.getElementsMapIncludingDeleted();\n\n const updateGroupIdsAfterEditingGroup = elements => {\n if (elements.length > 0) {\n for (const element of elements) {\n const index = element.groupIds.indexOf(this.state.editingGroupId);\n this.scene.mutateElement(element, {\n groupIds: element.groupIds.slice(0, index)\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n\n nextElements.forEach(element => {\n if (element.groupIds.length && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(nextElements, element.groupIds[element.groupIds.length - 1]).length < 2) {\n this.scene.mutateElement(element, {\n groupIds: []\n }, {\n informMutation: false,\n isDragging: false\n });\n }\n });\n this.setState({\n editingGroupId: null\n });\n }\n };\n\n if (topLayerFrame && !this.state.selectedElementIds[topLayerFrame.id]) {\n const elementsToAdd = selectedElements.filter(element => element.frameId !== topLayerFrame.id && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInFrame)(element, nextElements, this.state));\n\n if (this.state.editingGroupId) {\n updateGroupIdsAfterEditingGroup(elementsToAdd);\n }\n\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.addElementsToFrame)(nextElements, elementsToAdd, topLayerFrame, this.state);\n } else if (!topLayerFrame) {\n if (this.state.editingGroupId) {\n const elementsToRemove = selectedElements.filter(element => element.frameId && !(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInFrame)(element, nextElements, this.state));\n updateGroupIdsAfterEditingGroup(elementsToRemove);\n }\n }\n\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateFrameMembershipOfSelectedElements)(nextElements, this.state, this);\n this.scene.replaceAllElements(nextElements);\n }\n }\n\n if (resizingElement) {\n this.store.scheduleCapture();\n }\n\n if (resizingElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isInvisiblySmallElement)(resizingElement)) {\n // update the store snapshot, so that invisible elements are not captured by the store\n this.updateScene({\n elements: this.scene.getElementsIncludingDeleted().filter(el => el.id !== resizingElement.id),\n captureUpdate: _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.CaptureUpdateAction.NEVER\n });\n } // handle frame membership for resizing frames and/or selected elements\n\n\n if (pointerDownState.resize.isResizing) {\n let nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.updateFrameMembershipOfSelectedElements)(this.scene.getElementsIncludingDeleted(), this.state, this);\n const selectedFrames = this.scene.getSelectedElements(this.state).filter(element => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(element));\n\n for (const frame of selectedFrames) {\n nextElements = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.replaceAllElementsInFrame)(nextElements, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInResizingFrame)(this.scene.getElementsIncludingDeleted(), frame, this.state, elementsMap), frame, this);\n }\n\n this.scene.replaceAllElements(nextElements);\n } // Code below handles selection when element(s) weren't\n // drag or added to selection on pointer down phase.\n\n\n const hitElement = pointerDownState.hit.element;\n\n if (((_l = this.state.selectedLinearElement) === null || _l === void 0 ? void 0 : _l.elementId) !== (hitElement === null || hitElement === void 0 ? void 0 : hitElement.id) && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(hitElement)) {\n const selectedElements = this.scene.getSelectedElements(this.state); // set selectedLinearElement when no other element selected except\n // the one we've hit\n\n if (selectedElements.length === 1) {\n this.setState({\n selectedLinearElement: new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(hitElement, this.scene.getNonDeletedElementsMap())\n });\n }\n } // click outside the cropping region to exit\n\n\n if ( // not in the cropping mode at all\n !croppingElementId || // in the cropping mode\n croppingElementId && ( // not cropping and no hit element\n !hitElement && !isCropping || // hitting something else\n hitElement && hitElement.id !== croppingElementId)) {\n this.finishImageCropping();\n }\n\n const pointerStart = this.lastPointerDownEvent;\n const pointerEnd = this.lastPointerUpEvent || this.lastPointerMoveEvent;\n\n if ((0,_appState__WEBPACK_IMPORTED_MODULE_23__.isEraserActive)(this.state) && pointerStart && pointerEnd) {\n this.eraserTrail.endPath();\n const draggedDistance = (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointDistance)((0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerStart.clientX, pointerStart.clientY), (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerEnd.clientX, pointerEnd.clientY));\n\n if (draggedDistance === 0) {\n const scenePointer = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.viewportCoordsToSceneCoords)({\n clientX: pointerEnd.clientX,\n clientY: pointerEnd.clientY\n }, this.state);\n const hitElements = this.getElementsAtPosition(scenePointer.x, scenePointer.y);\n hitElements.forEach(hitElement => this.elementsPendingErasure.add(hitElement.id));\n }\n\n this.eraseElements();\n return;\n } else if (this.elementsPendingErasure.size) {\n this.restoreReadyToEraseElements();\n }\n\n if (hitElement && !pointerDownState.drag.hasOccurred && !pointerDownState.hit.wasAddedToSelection && ( // if we're editing a line, pointerup shouldn't switch selection if\n // box selected\n !((_m = this.state.selectedLinearElement) === null || _m === void 0 ? void 0 : _m.isEditing) || !pointerDownState.boxSelection.hasOccurred) && // hitElement can be set when alt + ctrl to toggle lasso and we will\n // just respect the selected elements from lasso instead\n this.state.activeTool.type !== \"lasso\") {\n // when inside line editor, shift selects points instead\n if (childEvent.shiftKey && !((_o = this.state.selectedLinearElement) === null || _o === void 0 ? void 0 : _o.isEditing)) {\n if (this.state.selectedElementIds[hitElement.id]) {\n if ((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isSelectedViaGroup)(this.state, hitElement)) {\n this.setState(_prevState => {\n const nextSelectedElementIds = Object.assign({}, _prevState.selectedElementIds); // We want to unselect all groups hitElement is part of\n // as well as all elements that are part of the groups\n // hitElement is part of\n\n for (const groupedElement of hitElement.groupIds.flatMap(groupId => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), groupId))) {\n delete nextSelectedElementIds[groupedElement.id];\n }\n\n return {\n selectedGroupIds: Object.assign(Object.assign({}, _prevState.selectedElementIds), hitElement.groupIds.map(gId => ({\n [gId]: false\n })).reduce((prev, acc) => Object.assign(Object.assign({}, prev), acc), {})),\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(nextSelectedElementIds, _prevState)\n };\n }); // if not dragging a linear element point (outside editor)\n } else if (!((_p = this.state.selectedLinearElement) === null || _p === void 0 ? void 0 : _p.isDragging)) {\n // remove element from selection while\n // keeping prev elements selected\n this.setState(prevState => {\n const newSelectedElementIds = Object.assign({}, prevState.selectedElementIds);\n delete newSelectedElementIds[hitElement.id];\n const newSelectedElements = (0,_scene__WEBPACK_IMPORTED_MODULE_31__.getSelectedElements)(this.scene.getNonDeletedElements(), {\n selectedElementIds: newSelectedElementIds\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: newSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n // set selectedLinearElement only if thats the only element selected\n selectedLinearElement: newSelectedElements.length === 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(newSelectedElements[0]) ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(newSelectedElements[0], this.scene.getNonDeletedElementsMap()) : prevState.selectedLinearElement\n });\n });\n }\n } else if (hitElement.frameId && this.state.selectedElementIds[hitElement.frameId]) {\n // when hitElement is part of a selected frame, deselect the frame\n // to avoid frame and containing elements selected simultaneously\n this.setState(prevState => {\n var _a, _b;\n\n const nextSelectedElementIds = Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [hitElement.id]: true\n }); // deselect the frame\n\n delete nextSelectedElementIds[hitElement.frameId]; // deselect groups containing the frame\n\n ((_b = (_a = this.scene.getElement(hitElement.frameId)) === null || _a === void 0 ? void 0 : _a.groupIds) !== null && _b !== void 0 ? _b : []).flatMap(gid => (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getElementsInGroup)(this.scene.getNonDeletedElements(), gid)).forEach(element => {\n delete nextSelectedElementIds[element.id];\n });\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: nextSelectedElementIds\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n showHyperlinkPopup: hitElement.link || (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(hitElement) ? \"info\" : false\n });\n });\n } else {\n // add element to selection while keeping prev elements selected\n this.setState(_prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, _prevState.selectedElementIds), {\n [hitElement.id]: true\n }), _prevState)\n }));\n }\n } else {\n this.setState(prevState => {\n var _a;\n\n return Object.assign(Object.assign({}, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.selectGroupsForSelectedElements)({\n editingGroupId: prevState.editingGroupId,\n selectedElementIds: {\n [hitElement.id]: true\n }\n }, this.scene.getNonDeletedElements(), prevState, this)), {\n selectedLinearElement: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement)(hitElement) && // Don't set `selectedLinearElement` if its same as the hitElement, this is mainly to prevent resetting the `hoverPointIndex` to -1.\n // Future we should update the API to take care of setting the correct `hoverPointIndex` when initialized\n ((_a = prevState.selectedLinearElement) === null || _a === void 0 ? void 0 : _a.elementId) !== hitElement.id ? new _excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.LinearElementEditor(hitElement, this.scene.getNonDeletedElementsMap()) : prevState.selectedLinearElement\n });\n });\n }\n }\n\n if ( // do not clear selection if lasso is active\n this.state.activeTool.type !== \"lasso\" && // not elbow midpoint dragged\n !(hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElbowArrow)(hitElement)) && // not dragged\n !pointerDownState.drag.hasOccurred && // not resized\n !this.state.isResizing && ( // only hitting the bounding box of the previous hit element\n hitElement && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.hitElementBoundingBoxOnly)({\n point: (0,_excalidraw_math__WEBPACK_IMPORTED_MODULE_5__.pointFrom)(pointerDownState.origin.x, pointerDownState.origin.y),\n element: hitElement,\n elementsMap,\n threshold: this.getElementHitThreshold(hitElement),\n frameNameBound: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isFrameLikeElement)(hitElement) ? this.frameNameBoundsCache.get(hitElement) : null\n }, elementsMap) || !hitElement && pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements)) {\n if ((_q = this.state.selectedLinearElement) === null || _q === void 0 ? void 0 : _q.isEditing) {\n // Exit editing mode but keep the element selected\n this.actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_8__.actionToggleLinearEditor);\n } else {\n // Deselect selected elements\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n selectedGroupIds: {},\n editingGroupId: null,\n activeEmbeddable: null\n });\n } // reset cursor\n\n\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.setCursor)(this.interactiveCanvas, _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.CURSOR_TYPE.AUTO);\n return;\n }\n\n if (!activeTool.locked && activeTool.type !== \"freedraw\" && newElement) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)(Object.assign(Object.assign({}, prevState.selectedElementIds), {\n [newElement.id]: true\n }), prevState),\n showHyperlinkPopup: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isEmbeddableElement)(newElement) && !newElement.link ? \"editor\" : prevState.showHyperlinkPopup\n }));\n }\n\n if (activeTool.type !== \"selection\" || (0,_scene__WEBPACK_IMPORTED_MODULE_31__.isSomeElementSelected)(this.scene.getNonDeletedElements(), this.state) || !(0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.isShallowEqual)(this.state.previousSelectedElementIds, this.state.selectedElementIds)) {\n this.store.scheduleCapture();\n }\n\n if (pointerDownState.drag.hasOccurred && !this.state.selectedLinearElement || isResizing || isRotating || isCropping) {\n // We only allow binding via linear elements, specifically via dragging\n // the endpoints (\"start\" or \"end\").\n const linearElements = this.scene.getSelectedElements(this.state).filter(_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isLinearElement);\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.bindOrUnbindLinearElements)(linearElements, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBindingEnabled)(this.state), (_s = (_r = this.state.selectedLinearElement) === null || _r === void 0 ? void 0 : _r.selectedPointsIndices) !== null && _s !== void 0 ? _s : [], this.scene, this.state.zoom);\n }\n\n if (activeTool.type === \"laser\") {\n this.laserTrails.endPath();\n return;\n }\n\n if (!activeTool.locked && activeTool.type !== \"freedraw\" && (activeTool.type !== \"lasso\" || // if lasso is turned on but from selection => reset to selection\n activeTool.type === \"lasso\" && activeTool.fromSelection)) {\n (0,_cursor__WEBPACK_IMPORTED_MODULE_42__.resetCursor)(this.interactiveCanvas);\n this.setState({\n newElement: null,\n suggestedBindings: [],\n activeTool: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.updateActiveTool)(this.state, {\n type: this.defaultSelectionTool\n })\n });\n } else {\n this.setState({\n newElement: null,\n suggestedBindings: []\n });\n }\n\n if (hitElement && this.lastPointerUpEvent && this.lastPointerDownEvent && this.lastPointerUpEvent.timeStamp - this.lastPointerDownEvent.timeStamp < 300 && gesture.pointers.size <= 1 && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isIframeLikeElement)(hitElement) && this.isIframeLikeElementCenter(hitElement, this.lastPointerUpEvent, pointerDownState.origin.x, pointerDownState.origin.y)) {\n this.handleEmbeddableCenterClick(hitElement);\n }\n });\n } //zsviczian - published on API\n\n\n setSelection(elements) {\n const selectedElementIds = {};\n const selectedGroupIds = {};\n elements.forEach(ele => {\n if (ele.groupIds.length) {\n selectedElementIds[ele.id] = true;\n ele.groupIds.forEach(id => {\n selectedGroupIds[id] = true;\n });\n } // exclude bound text elements as we don't mark them as selected when\n // container is selected unless in group\n else if (!(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isBoundToContainer)(ele)) {\n selectedElementIds[ele.id] = true;\n }\n });\n this.setState({\n previousSelectedElementIds: this.state.selectedElementIds,\n selectedElementIds,\n selectedGroupIds\n });\n }\n\n clearSelection(hitElement) {\n this.setState(prevState => ({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, prevState),\n activeEmbeddable: null,\n selectedGroupIds: {},\n // Continue editing the same group if the user selected a different\n // element from it\n editingGroupId: prevState.editingGroupId && hitElement != null && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.isElementInGroup)(hitElement, prevState.editingGroupId) ? prevState.editingGroupId : null\n }));\n this.setState({\n selectedElementIds: (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.makeNextSelectedElementIds)({}, this.state),\n activeEmbeddable: null,\n previousSelectedElementIds: this.state.selectedElementIds\n });\n }\n\n getTextWysiwygSnappedToCenterPosition(x, y, appState, container) {\n if (container) {\n let elementCenterX = container.x + container.width / 2;\n let elementCenterY = container.y + container.height / 2;\n const elementCenter = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_7__.getContainerCenter)(container, appState, this.scene.getNonDeletedElementsMap());\n\n if (elementCenter) {\n elementCenterX = elementCenter.x;\n elementCenterY = elementCenter.y;\n }\n\n const distanceToCenter = Math.hypot(x - elementCenterX, y - elementCenterY);\n const isSnappedToCenter = distanceToCenter < _excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.TEXT_TO_CENTER_SNAP_THRESHOLD;\n\n if (isSnappedToCenter) {\n const {\n x: viewportX,\n y: viewportY\n } = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_6__.sceneCoordsToViewportCoords)({\n sceneX: elementCenterX,\n sceneY: elementCenterY\n }, appState);\n return {\n viewportX,\n viewportY,\n elementCenterX,\n elementCenterY\n };\n }\n }\n }\n\n getCanvasOffsets() {\n var _a;\n\n if ((_a = this.excalidrawContainerRef) === null || _a === void 0 ? void 0 : _a.current) {\n const excalidrawContainer = this.excalidrawContainerRef.current;\n const {\n left,\n top\n } = excalidrawContainer.getBoundingClientRect();\n return {\n offsetLeft: left,\n offsetTop: top\n };\n }\n\n return {\n offsetLeft: 0,\n offsetTop: 0\n };\n }\n\n async updateLanguage() {\n const currentLang = _i18n__WEBPACK_IMPORTED_MODULE_30__.languages.find(lang => lang.code === this.props.langCode) || _i18n__WEBPACK_IMPORTED_MODULE_30__.defaultLang;\n await (0,_i18n__WEBPACK_IMPORTED_MODULE_30__.setLanguage)(currentLang);\n this.setAppState({});\n }\n\n} // -----------------------------------------------------------------------------\n// TEST HOOKS\n// -----------------------------------------------------------------------------\n\n/* //zsviczian - I get a type error on h, but anyway I don't need this test hook\r\ndeclare global {\r\n interface Window {\r\n h: {\r\n scene: Scene;\r\n elements: readonly ExcalidrawElement[];\r\n state: AppState;\r\n setState: React.Component<any, AppState>[\"setState\"];\r\n app: InstanceType<typeof App>;\r\n history: History;\r\n store: Store;\r\n };\r\n }\r\n}\r\n\r\nexport const createTestHook = () => {\r\n if (isTestEnv() || isDevEnv()) {\r\n window.h = window.h || ({} as Window[\"h\"]);\r\n\r\n Object.defineProperties(window.h, {\r\n elements: {\r\n configurable: true,\r\n get() {\r\n return this.app?.scene.getElementsIncludingDeleted();\r\n },\r\n set(elements: ExcalidrawElement[]) {\r\n return this.app?.scene.replaceAllElements(\r\n syncInvalidIndices(elements),\r\n );\r\n },\r\n },\r\n scene: {\r\n configurable: true,\r\n get() {\r\n return this.app?.scene;\r\n },\r\n },\r\n });\r\n }\r\n};\r\n\r\ncreateTestHook();*/\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (App);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/App.tsx?");
14283
14283
 
14284
14284
  /***/ }),
14285
14285
 
@@ -14884,7 +14884,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extr
14884
14884
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
14885
14885
 
14886
14886
  "use strict";
14887
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FixedSideContainer: () => (/* binding */ FixedSideContainer)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var _FixedSideContainer_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FixedSideContainer.scss */ \"./components/FixedSideContainer.scss\");\n\n\n\nconst FixedSideContainer = ({\n children,\n side,\n className\n}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(\"FixedSideContainer\", `FixedSideContainer_side_${side}`, className)\n}, children);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/FixedSideContainer.tsx?");
14887
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ FixedSideContainer: () => (/* binding */ FixedSideContainer)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var _FixedSideContainer_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FixedSideContainer.scss */ \"./components/FixedSideContainer.scss\");\n\n\n\nconst FixedSideContainer = ({\n children,\n side,\n className,\n sidepanelOpen = false //zsviczian\n\n}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n style: sidepanelOpen ? {\n right: \"var(--right-sidebar-width)\"\n } : undefined,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(\"FixedSideContainer\", `FixedSideContainer_side_${side}`, className)\n}, children);\n\n//# sourceURL=webpack://ExcalidrawLib/./components/FixedSideContainer.tsx?");
14888
14888
 
14889
14889
  /***/ }),
14890
14890
 
@@ -15159,7 +15159,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extr
15159
15159
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
15160
15160
 
15161
15161
  "use strict";
15162
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _context_tunnels__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../context/tunnels */ \"./context/tunnels.ts\");\n/* harmony import */ var _context_ui_appState__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../context/ui-appState */ \"./context/ui-appState.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _Actions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Actions */ \"./components/Actions.tsx\");\n/* harmony import */ var _LoadingMessage__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./LoadingMessage */ \"./components/LoadingMessage.tsx\");\n/* harmony import */ var _LockButton__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./LockButton */ \"./components/LockButton.tsx\");\n/* harmony import */ var _MobileMenu__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./MobileMenu */ \"./components/MobileMenu.tsx\");\n/* harmony import */ var _PasteChartDialog__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./PasteChartDialog */ \"./components/PasteChartDialog.tsx\");\n/* harmony import */ var _Section__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Section */ \"./components/Section.tsx\");\n/* harmony import */ var _Stack__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Stack */ \"./components/Stack.tsx\");\n/* harmony import */ var _UserList__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./UserList */ \"./components/UserList.tsx\");\n/* harmony import */ var _PenModeButton__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./PenModeButton */ \"./components/PenModeButton.tsx\");\n/* harmony import */ var _footer_Footer__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./footer/Footer */ \"./components/footer/Footer.tsx\");\n/* harmony import */ var _Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Sidebar/Sidebar */ \"./components/Sidebar/Sidebar.tsx\");\n/* harmony import */ var _main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./main-menu/MainMenu */ \"./components/main-menu/MainMenu.tsx\");\n/* harmony import */ var _ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ActiveConfirmDialog */ \"./components/ActiveConfirmDialog.tsx\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./App */ \"./components/App.tsx\");\n/* harmony import */ var _OverwriteConfirm_OverwriteConfirm__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./OverwriteConfirm/OverwriteConfirm */ \"./components/OverwriteConfirm/OverwriteConfirm.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _DefaultSidebar__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./DefaultSidebar */ \"./components/DefaultSidebar.tsx\");\n/* harmony import */ var _TTDDialog_TTDDialog__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./TTDDialog/TTDDialog */ \"./components/TTDDialog/TTDDialog.tsx\");\n/* harmony import */ var _Stats__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Stats */ \"./components/Stats/index.tsx\");\n/* harmony import */ var _ElementLinkDialog__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./ElementLinkDialog */ \"./components/ElementLinkDialog.tsx\");\n/* harmony import */ var _ErrorDialog__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./ErrorDialog */ \"./components/ErrorDialog.tsx\");\n/* harmony import */ var _EyeDropper__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./EyeDropper */ \"./components/EyeDropper.tsx\");\n/* harmony import */ var _FixedSideContainer__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./FixedSideContainer */ \"./components/FixedSideContainer.tsx\");\n/* harmony import */ var _HandButton__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./HandButton */ \"./components/HandButton.tsx\");\n/* harmony import */ var _HelpDialog__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./HelpDialog */ \"./components/HelpDialog.tsx\");\n/* harmony import */ var _HintViewer__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./HintViewer */ \"./components/HintViewer.tsx\");\n/* harmony import */ var _ImageExportDialog__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./ImageExportDialog */ \"./components/ImageExportDialog.tsx\");\n/* harmony import */ var _Island__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./Island */ \"./components/Island.tsx\");\n/* harmony import */ var _JSONExportDialog__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./JSONExportDialog */ \"./components/JSONExportDialog.tsx\");\n/* harmony import */ var _LaserPointerButton__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./LaserPointerButton */ \"./components/LaserPointerButton.tsx\");\n/* harmony import */ var _LayerUI_scss__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./LayerUI.scss */ \"./components/LayerUI.scss\");\n/* harmony import */ var _Toolbar_scss__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ./Toolbar.scss */ \"./components/Toolbar.scss\");\nvar __rest = undefined && undefined.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst DefaultMainMenu = ({\n UIOptions\n}) => {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"], {\n __fallback: true\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.LoadScene, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.SaveToActiveFile, null), UIOptions.canvasActions.export && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.Export, null), UIOptions.canvasActions.saveAsImage && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.SaveAsImage, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.SearchMenu, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.Help, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.ClearCanvas, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].Separator, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].Group, {\n title: \"Excalidraw links\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.Socials, null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].Separator, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.ToggleTheme, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.ChangeCanvasBackground, null));\n};\n\nconst DefaultOverwriteConfirmDialog = () => {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_OverwriteConfirm_OverwriteConfirm__WEBPACK_IMPORTED_MODULE_26__.OverwriteConfirmDialog, {\n __fallback: true\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_OverwriteConfirm_OverwriteConfirm__WEBPACK_IMPORTED_MODULE_26__.OverwriteConfirmDialog.Actions.SaveToDisk, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_OverwriteConfirm_OverwriteConfirm__WEBPACK_IMPORTED_MODULE_26__.OverwriteConfirmDialog.Actions.ExportToImage, null));\n};\n\nconst LayerUI = ({\n actionManager,\n appState,\n files,\n setAppState,\n elements,\n canvas,\n onLockToggle,\n onHandToolToggle,\n onPenModeToggle,\n showExitZenModeBtn,\n renderTopRightUI,\n renderCustomStats,\n UIOptions,\n onExportImage,\n renderWelcomeScreen,\n children,\n app,\n isCollaborating,\n generateLinkForSelection\n}) => {\n var _a, _b, _c;\n\n const device = (0,_App__WEBPACK_IMPORTED_MODULE_25__.useDevice)();\n const tunnels = (0,_context_tunnels__WEBPACK_IMPORTED_MODULE_7__.useInitializeTunnels)();\n const spacing = appState.stylesPanelMode === \"compact\" ? {\n menuTopGap: 4,\n toolbarColGap: 4,\n toolbarRowGap: 1,\n toolbarInnerRowGap: 0.5,\n islandPadding: 1,\n collabMarginLeft: 8\n } : {\n menuTopGap: 6,\n toolbarColGap: 4,\n toolbarRowGap: 1,\n toolbarInnerRowGap: 1,\n islandPadding: 1,\n collabMarginLeft: 8\n };\n const TunnelsJotaiProvider = tunnels.tunnelsJotai.Provider;\n const [eyeDropperState, setEyeDropperState] = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_9__.useAtom)(_EyeDropper__WEBPACK_IMPORTED_MODULE_33__.activeEyeDropperAtom);\n\n const renderJSONExportDialog = () => {\n if (!UIOptions.canvasActions.export) {\n return null;\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_JSONExportDialog__WEBPACK_IMPORTED_MODULE_40__.JSONExportDialog, {\n elements: elements,\n appState: appState,\n files: files,\n actionManager: actionManager,\n exportOpts: UIOptions.canvasActions.export,\n canvas: canvas,\n setAppState: setAppState\n });\n };\n\n const renderImageExportDialog = () => {\n var _a;\n\n if (!UIOptions.canvasActions.saveAsImage || ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"imageExport\") {\n return null;\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_ImageExportDialog__WEBPACK_IMPORTED_MODULE_38__.ImageExportDialog, {\n elements: elements,\n appState: appState,\n files: files,\n actionManager: actionManager,\n onExportImage: onExportImage,\n onCloseRequest: () => setAppState({\n openDialog: null\n }),\n name: app.getName()\n });\n };\n\n const renderCanvasActions = () => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n style: {\n position: \"relative\"\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.MainMenuTunnel.Out, null), renderWelcomeScreen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.WelcomeScreenMenuHintTunnel.Out, null));\n\n const renderSelectedShapeActions = () => {\n const isCompactMode = appState.stylesPanelMode === \"compact\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Section__WEBPACK_IMPORTED_MODULE_17__.Section, {\n heading: \"selectedShapeActions\",\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"selected-shape-actions zen-mode-transition\", {\n \"transition-left\": appState.zenModeEnabled\n })\n }, isCompactMode ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_39__.Island, {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"compact-shape-actions-island\"),\n padding: 0,\n style: {\n // we want to make sure this doesn't overflow so subtracting the\n // approximate height of hamburgerMenu + footer\n maxHeight: `${appState.height - 166}px`\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_12__.CompactShapeActions, {\n appState: appState,\n elementsMap: app.scene.getNonDeletedElementsMap(),\n renderAction: actionManager.renderAction,\n app: app,\n setAppState: setAppState\n })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_39__.Island, {\n className: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.CLASSES.SHAPE_ACTIONS_MENU,\n padding: 2,\n style: {\n // we want to make sure this doesn't overflow so subtracting the\n // approximate height of hamburgerMenu + footer\n maxHeight: `${appState.height - 166}px`\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_12__.SelectedShapeActions, {\n appState: appState,\n elementsMap: app.scene.getNonDeletedElementsMap(),\n renderAction: actionManager.renderAction,\n app: app\n })));\n };\n\n const renderFixedSideContainer = () => {\n var _a, _b, _c, _d, _e;\n\n const shouldRenderSelectedShapeActions = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.showSelectedShapeActions)(appState, elements);\n\n if (appState.viewModeEnabled) {\n return null;\n } //zsviczian\n\n\n const shouldShowStats = appState.stats.open && !appState.zenModeEnabled && !appState.viewModeEnabled && ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"elementLinkSelector\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_FixedSideContainer__WEBPACK_IMPORTED_MODULE_34__.FixedSideContainer, {\n side: \"top\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"App-menu App-menu_top\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_18__[\"default\"].Col, {\n gap: spacing.menuTopGap,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"App-menu_top__left\")\n }, renderCanvasActions(), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"selected-shape-actions-container\", {\n \"selected-shape-actions-container--compact\": appState.stylesPanelMode === \"compact\"\n })\n }, shouldRenderSelectedShapeActions && renderSelectedShapeActions())), !appState.viewModeEnabled && ((_b = appState.openDialog) === null || _b === void 0 ? void 0 : _b.name) !== \"elementLinkSelector\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Section__WEBPACK_IMPORTED_MODULE_17__.Section, {\n heading: \"shapes\",\n className: \"shapes-section\"\n }, heading => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n style: {\n position: \"relative\"\n }\n }, renderWelcomeScreen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.WelcomeScreenToolbarHintTunnel.Out, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_18__[\"default\"].Col, {\n gap: spacing.toolbarColGap,\n align: \"start\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_18__[\"default\"].Row, {\n gap: spacing.toolbarRowGap,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"App-toolbar-container\", {\n \"zen-mode\": appState.zenModeEnabled\n })\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_39__.Island, {\n padding: spacing.islandPadding,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"App-toolbar\", {\n \"zen-mode\": appState.zenModeEnabled,\n \"App-toolbar--compact\": appState.stylesPanelMode === \"compact\"\n })\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_HintViewer__WEBPACK_IMPORTED_MODULE_37__.HintViewer, {\n appState: appState,\n isMobile: device.editor.isMobile || !(appState.viewModeEnabled || appState.zenModeEnabled) && appState.trayModeEnabled,\n device: device,\n app: app\n }), heading, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_18__[\"default\"].Row, {\n gap: spacing.toolbarInnerRowGap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_PenModeButton__WEBPACK_IMPORTED_MODULE_20__.PenModeButton, {\n zenModeEnabled: appState.zenModeEnabled,\n checked: appState.penMode,\n onChange: () => onPenModeToggle(null),\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"toolBar.penMode\"),\n penDetected: appState.penDetected\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_LockButton__WEBPACK_IMPORTED_MODULE_14__.LockButton, {\n checked: appState.activeTool.locked,\n onChange: onLockToggle,\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"toolBar.lock\")\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"App-toolbar__divider\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_HandButton__WEBPACK_IMPORTED_MODULE_35__.HandButton, {\n checked: (0,_appState__WEBPACK_IMPORTED_MODULE_6__.isHandToolActive)(appState),\n onChange: () => onHandToolToggle(),\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"toolBar.hand\"),\n isMobile: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_12__.ShapesSwitcher, {\n appState: appState,\n activeTool: appState.activeTool,\n UIOptions: UIOptions,\n app: app\n }))), isCollaborating && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_39__.Island, {\n style: {\n marginLeft: spacing.collabMarginLeft,\n alignSelf: \"center\",\n height: \"fit-content\"\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_LaserPointerButton__WEBPACK_IMPORTED_MODULE_41__.LaserPointerButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"toolBar.laser\"),\n checked: appState.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.TOOL_TYPE.laser,\n onChange: () => app.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.TOOL_TYPE.laser\n }),\n isMobile: true\n })))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"layer-ui__wrapper__top-right zen-mode-transition\", {\n \"transition-right\": appState.zenModeEnabled,\n \"layer-ui__wrapper__top-right--compact\": appState.stylesPanelMode === \"compact\"\n })\n }, appState.collaborators.size > 0 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_UserList__WEBPACK_IMPORTED_MODULE_19__.UserList, {\n collaborators: appState.collaborators,\n userToFollow: ((_c = appState.userToFollow) === null || _c === void 0 ? void 0 : _c.socketId) || null\n }), !appState.viewModeEnabled && ( //zsviczian\n renderTopRightUI === null || renderTopRightUI === void 0 ? void 0 : renderTopRightUI(device.editor.isMobile, appState)), !appState.viewModeEnabled && ((_d = appState.openDialog) === null || _d === void 0 ? void 0 : _d.name) !== \"elementLinkSelector\" && ( // hide button when sidebar docked\n !isSidebarDocked || ((_e = appState.openSidebar) === null || _e === void 0 ? void 0 : _e.name) !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_SIDEBAR.name) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.DefaultSidebarTriggerTunnel.Out, null), shouldShowStats && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Stats__WEBPACK_IMPORTED_MODULE_30__.Stats, {\n app: app,\n onClose: () => {\n actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_4__.actionToggleStats);\n },\n renderCustomStats: renderCustomStats\n }))));\n };\n\n const isTrayModeOrMobile = device.editor.isMobile || !(appState.viewModeEnabled || appState.zenModeEnabled) && appState.trayModeEnabled; //zsviczian\n\n const renderSidebars = () => {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_DefaultSidebar__WEBPACK_IMPORTED_MODULE_28__.DefaultSidebar, {\n __fallback: true,\n onDock: docked => {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_5__.trackEvent)(\"sidebar\", `toggleDock (${docked ? \"dock\" : \"undock\"})`, `(${device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n });\n };\n\n const isSidebarDocked = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_9__.useAtomValue)(_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_22__.isSidebarDockedAtom);\n const layerUIJSX = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), null, children, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(DefaultMainMenu, {\n UIOptions: UIOptions\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_DefaultSidebar__WEBPACK_IMPORTED_MODULE_28__.DefaultSidebar.Trigger, {\n __fallback: true,\n icon: _icons__WEBPACK_IMPORTED_MODULE_27__.LibraryIcon,\n title: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.capitalizeString)((0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"toolBar.library\")),\n onToggle: open => {\n if (open) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_5__.trackEvent)(\"sidebar\", `${_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_SIDEBAR.name} (open)`, `button (${device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n },\n tab: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_SIDEBAR.defaultTab\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(DefaultOverwriteConfirmDialog, null), ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"ttd\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_TTDDialog_TTDDialog__WEBPACK_IMPORTED_MODULE_29__.TTDDialog, {\n __fallback: true\n }), appState.isLoading && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_LoadingMessage__WEBPACK_IMPORTED_MODULE_13__.LoadingMessage, {\n delay: 250\n }), appState.errorMessage && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_ErrorDialog__WEBPACK_IMPORTED_MODULE_32__.ErrorDialog, {\n onClose: () => setAppState({\n errorMessage: null\n })\n }, appState.errorMessage), eyeDropperState &&\n /*#__PURE__*/\n //!device.editor.isMobile && //zsviczian\n react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_EyeDropper__WEBPACK_IMPORTED_MODULE_33__.EyeDropper, {\n colorPickerType: eyeDropperState.colorPickerType,\n onCancel: () => {\n setEyeDropperState(null);\n },\n onChange: (colorPickerType, color, selectedElements, {\n altKey\n }) => {\n if (colorPickerType !== \"elementBackground\" && colorPickerType !== \"elementStroke\") {\n return;\n }\n\n if (selectedElements.length) {\n for (const element of selectedElements) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.mutateElement)(element, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.arrayToMap)(elements), {\n [altKey && eyeDropperState.swapPreviewOnAlt ? colorPickerType === \"elementBackground\" ? \"strokeColor\" : \"backgroundColor\" : colorPickerType === \"elementBackground\" ? \"backgroundColor\" : \"strokeColor\"]: color\n });\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.ShapeCache.delete(element);\n }\n\n app.scene.triggerUpdate();\n } else if (colorPickerType === \"elementBackground\") {\n setAppState({\n currentItemBackgroundColor: color\n });\n } else {\n setAppState({\n currentItemStrokeColor: color\n });\n }\n },\n onSelect: (color, event) => {\n var _a;\n\n setEyeDropperState(state => {\n return (state === null || state === void 0 ? void 0 : state.keepOpenOnAlt) && event.altKey ? state : null;\n });\n (_a = eyeDropperState === null || eyeDropperState === void 0 ? void 0 : eyeDropperState.onSelect) === null || _a === void 0 ? void 0 : _a.call(eyeDropperState, color, event);\n }\n }), ((_b = appState.openDialog) === null || _b === void 0 ? void 0 : _b.name) === \"help\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_HelpDialog__WEBPACK_IMPORTED_MODULE_36__.HelpDialog, {\n onClose: () => {\n setAppState({\n openDialog: null\n });\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_24__.ActiveConfirmDialog, null), ((_c = appState.openDialog) === null || _c === void 0 ? void 0 : _c.name) === \"elementLinkSelector\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_ElementLinkDialog__WEBPACK_IMPORTED_MODULE_31__[\"default\"], {\n sourceElementId: appState.openDialog.sourceElementId,\n onClose: () => {\n setAppState({\n openDialog: null\n });\n },\n scene: app.scene,\n appState: appState,\n generateLinkForSelection: generateLinkForSelection\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.OverwriteConfirmDialogTunnel.Out, null), renderImageExportDialog(), renderJSONExportDialog(), appState.pasteDialog.shown && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_PasteChartDialog__WEBPACK_IMPORTED_MODULE_16__.PasteChartDialog, {\n setAppState: setAppState,\n appState: appState,\n onClose: () => setAppState({\n pasteDialog: {\n shown: false,\n data: null\n }\n })\n }), isTrayModeOrMobile &&\n /*#__PURE__*/\n //zsviczian Added isTrayMode condition\n react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_MobileMenu__WEBPACK_IMPORTED_MODULE_15__.MobileMenu, {\n app: app,\n appState: appState,\n elements: elements,\n actionManager: actionManager,\n renderJSONExportDialog: renderJSONExportDialog,\n renderImageExportDialog: renderImageExportDialog,\n setAppState: setAppState,\n onLockToggle: onLockToggle,\n onHandToolToggle: onHandToolToggle,\n onPenModeToggle: onPenModeToggle,\n renderTopRightUI: renderTopRightUI,\n renderCustomStats: renderCustomStats,\n renderSidebars: renderSidebars,\n device: device,\n renderWelcomeScreen: renderWelcomeScreen,\n UIOptions: UIOptions\n }), !isTrayModeOrMobile &&\n /*#__PURE__*/\n //zsviczian changed from !device.editor.isMobile\n react__WEBPACK_IMPORTED_MODULE_1___default().createElement((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"layer-ui__wrapper\",\n style: appState.openSidebar && isSidebarDocked && device.editor.canFitSidebar ? {\n width: `calc(100% - var(--right-sidebar-width))`\n } : {}\n }, renderWelcomeScreen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.WelcomeScreenCenterTunnel.Out, null), renderFixedSideContainer(), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_footer_Footer__WEBPACK_IMPORTED_MODULE_21__[\"default\"], {\n appState: appState,\n actionManager: actionManager,\n showExitZenModeBtn: showExitZenModeBtn,\n renderWelcomeScreen: renderWelcomeScreen\n }), appState.scrolledOutside && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"button\", {\n type: \"button\",\n className: \"scroll-back-to-content\",\n onClick: () => {\n setAppState(appState => Object.assign({}, (0,_scene__WEBPACK_IMPORTED_MODULE_11__.calculateScrollCenter)(elements, appState)));\n }\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"buttons.scrollBackToContent\"))), renderSidebars()));\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_context_ui_appState__WEBPACK_IMPORTED_MODULE_8__.UIAppStateContext.Provider, {\n value: appState\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(TunnelsJotaiProvider, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_context_tunnels__WEBPACK_IMPORTED_MODULE_7__.TunnelsContext.Provider, {\n value: tunnels\n }, layerUIJSX)));\n};\n\nconst stripIrrelevantAppStateProps = appState => {\n const {\n suggestedBindings,\n startBoundElement,\n cursorButton,\n scrollX,\n scrollY\n } = appState,\n ret = __rest(appState, [\"suggestedBindings\", \"startBoundElement\", \"cursorButton\", \"scrollX\", \"scrollY\"]);\n\n return ret;\n};\n\nconst areEqual = (prevProps, nextProps) => {\n // short-circuit early\n if (prevProps.children !== nextProps.children) {\n return false;\n }\n\n const {\n canvas: _pC,\n appState: prevAppState\n } = prevProps,\n prev = __rest(prevProps, [\"canvas\", \"appState\"]);\n\n const {\n canvas: _nC,\n appState: nextAppState\n } = nextProps,\n next = __rest(nextProps, [\"canvas\", \"appState\"]);\n\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isShallowEqual)( // asserting AppState because we're being passed the whole AppState\n // but resolve to only the UI-relevant props\n stripIrrelevantAppStateProps(prevAppState), stripIrrelevantAppStateProps(nextAppState), {\n selectedElementIds: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isShallowEqual,\n selectedGroupIds: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isShallowEqual\n }) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isShallowEqual)(prev, next);\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().memo(LayerUI, areEqual));\n\n//# sourceURL=webpack://ExcalidrawLib/./components/LayerUI.tsx?");
15162
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../analytics */ \"./analytics.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _context_tunnels__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../context/tunnels */ \"./context/tunnels.ts\");\n/* harmony import */ var _context_ui_appState__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../context/ui-appState */ \"./context/ui-appState.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _Actions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Actions */ \"./components/Actions.tsx\");\n/* harmony import */ var _LoadingMessage__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./LoadingMessage */ \"./components/LoadingMessage.tsx\");\n/* harmony import */ var _LockButton__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./LockButton */ \"./components/LockButton.tsx\");\n/* harmony import */ var _MobileMenu__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./MobileMenu */ \"./components/MobileMenu.tsx\");\n/* harmony import */ var _PasteChartDialog__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./PasteChartDialog */ \"./components/PasteChartDialog.tsx\");\n/* harmony import */ var _Section__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Section */ \"./components/Section.tsx\");\n/* harmony import */ var _Stack__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Stack */ \"./components/Stack.tsx\");\n/* harmony import */ var _UserList__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./UserList */ \"./components/UserList.tsx\");\n/* harmony import */ var _PenModeButton__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./PenModeButton */ \"./components/PenModeButton.tsx\");\n/* harmony import */ var _footer_Footer__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./footer/Footer */ \"./components/footer/Footer.tsx\");\n/* harmony import */ var _Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Sidebar/Sidebar */ \"./components/Sidebar/Sidebar.tsx\");\n/* harmony import */ var _main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./main-menu/MainMenu */ \"./components/main-menu/MainMenu.tsx\");\n/* harmony import */ var _ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ActiveConfirmDialog */ \"./components/ActiveConfirmDialog.tsx\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./App */ \"./components/App.tsx\");\n/* harmony import */ var _OverwriteConfirm_OverwriteConfirm__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./OverwriteConfirm/OverwriteConfirm */ \"./components/OverwriteConfirm/OverwriteConfirm.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./icons */ \"./components/icons.tsx\");\n/* harmony import */ var _DefaultSidebar__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./DefaultSidebar */ \"./components/DefaultSidebar.tsx\");\n/* harmony import */ var _TTDDialog_TTDDialog__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./TTDDialog/TTDDialog */ \"./components/TTDDialog/TTDDialog.tsx\");\n/* harmony import */ var _Stats__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Stats */ \"./components/Stats/index.tsx\");\n/* harmony import */ var _ElementLinkDialog__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./ElementLinkDialog */ \"./components/ElementLinkDialog.tsx\");\n/* harmony import */ var _ErrorDialog__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./ErrorDialog */ \"./components/ErrorDialog.tsx\");\n/* harmony import */ var _EyeDropper__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./EyeDropper */ \"./components/EyeDropper.tsx\");\n/* harmony import */ var _FixedSideContainer__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./FixedSideContainer */ \"./components/FixedSideContainer.tsx\");\n/* harmony import */ var _HandButton__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./HandButton */ \"./components/HandButton.tsx\");\n/* harmony import */ var _HelpDialog__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./HelpDialog */ \"./components/HelpDialog.tsx\");\n/* harmony import */ var _HintViewer__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./HintViewer */ \"./components/HintViewer.tsx\");\n/* harmony import */ var _ImageExportDialog__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./ImageExportDialog */ \"./components/ImageExportDialog.tsx\");\n/* harmony import */ var _Island__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./Island */ \"./components/Island.tsx\");\n/* harmony import */ var _JSONExportDialog__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./JSONExportDialog */ \"./components/JSONExportDialog.tsx\");\n/* harmony import */ var _LaserPointerButton__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./LaserPointerButton */ \"./components/LaserPointerButton.tsx\");\n/* harmony import */ var _LayerUI_scss__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./LayerUI.scss */ \"./components/LayerUI.scss\");\n/* harmony import */ var _Toolbar_scss__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ./Toolbar.scss */ \"./components/Toolbar.scss\");\nvar __rest = undefined && undefined.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst DefaultMainMenu = ({\n UIOptions\n}) => {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"], {\n __fallback: true\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.LoadScene, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.SaveToActiveFile, null), UIOptions.canvasActions.export && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.Export, null), UIOptions.canvasActions.saveAsImage && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.SaveAsImage, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.SearchMenu, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.Help, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.ClearCanvas, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].Separator, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].Group, {\n title: \"Excalidraw links\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.Socials, null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].Separator, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.ToggleTheme, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_main_menu_MainMenu__WEBPACK_IMPORTED_MODULE_23__[\"default\"].DefaultItems.ChangeCanvasBackground, null));\n};\n\nconst DefaultOverwriteConfirmDialog = () => {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_OverwriteConfirm_OverwriteConfirm__WEBPACK_IMPORTED_MODULE_26__.OverwriteConfirmDialog, {\n __fallback: true\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_OverwriteConfirm_OverwriteConfirm__WEBPACK_IMPORTED_MODULE_26__.OverwriteConfirmDialog.Actions.SaveToDisk, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_OverwriteConfirm_OverwriteConfirm__WEBPACK_IMPORTED_MODULE_26__.OverwriteConfirmDialog.Actions.ExportToImage, null));\n};\n\nconst LayerUI = ({\n actionManager,\n appState,\n files,\n setAppState,\n elements,\n canvas,\n onLockToggle,\n onHandToolToggle,\n onPenModeToggle,\n showExitZenModeBtn,\n renderTopRightUI,\n renderCustomStats,\n UIOptions,\n onExportImage,\n renderWelcomeScreen,\n children,\n app,\n isCollaborating,\n generateLinkForSelection\n}) => {\n var _a, _b, _c;\n\n const device = (0,_App__WEBPACK_IMPORTED_MODULE_25__.useDevice)();\n const tunnels = (0,_context_tunnels__WEBPACK_IMPORTED_MODULE_7__.useInitializeTunnels)();\n const spacing = appState.stylesPanelMode === \"compact\" ? {\n menuTopGap: 4,\n toolbarColGap: 4,\n toolbarRowGap: 1,\n toolbarInnerRowGap: 0.5,\n islandPadding: 1,\n collabMarginLeft: 8\n } : {\n menuTopGap: 6,\n toolbarColGap: 4,\n toolbarRowGap: 1,\n toolbarInnerRowGap: 1,\n islandPadding: 1,\n collabMarginLeft: 8\n };\n const TunnelsJotaiProvider = tunnels.tunnelsJotai.Provider;\n const [eyeDropperState, setEyeDropperState] = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_9__.useAtom)(_EyeDropper__WEBPACK_IMPORTED_MODULE_33__.activeEyeDropperAtom);\n\n const renderJSONExportDialog = () => {\n if (!UIOptions.canvasActions.export) {\n return null;\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_JSONExportDialog__WEBPACK_IMPORTED_MODULE_40__.JSONExportDialog, {\n elements: elements,\n appState: appState,\n files: files,\n actionManager: actionManager,\n exportOpts: UIOptions.canvasActions.export,\n canvas: canvas,\n setAppState: setAppState\n });\n };\n\n const renderImageExportDialog = () => {\n var _a;\n\n if (!UIOptions.canvasActions.saveAsImage || ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"imageExport\") {\n return null;\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_ImageExportDialog__WEBPACK_IMPORTED_MODULE_38__.ImageExportDialog, {\n elements: elements,\n appState: appState,\n files: files,\n actionManager: actionManager,\n onExportImage: onExportImage,\n onCloseRequest: () => setAppState({\n openDialog: null\n }),\n name: app.getName()\n });\n };\n\n const renderCanvasActions = () => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n style: {\n position: \"relative\"\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.MainMenuTunnel.Out, null), renderWelcomeScreen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.WelcomeScreenMenuHintTunnel.Out, null));\n\n const renderSelectedShapeActions = () => {\n const isCompactMode = appState.stylesPanelMode === \"compact\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Section__WEBPACK_IMPORTED_MODULE_17__.Section, {\n heading: \"selectedShapeActions\",\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"selected-shape-actions zen-mode-transition\", {\n \"transition-left\": appState.zenModeEnabled\n })\n }, isCompactMode ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_39__.Island, {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"compact-shape-actions-island\"),\n padding: 0,\n style: {\n // we want to make sure this doesn't overflow so subtracting the\n // approximate height of hamburgerMenu + footer\n maxHeight: `${appState.height - 166}px`\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_12__.CompactShapeActions, {\n appState: appState,\n elementsMap: app.scene.getNonDeletedElementsMap(),\n renderAction: actionManager.renderAction,\n app: app,\n setAppState: setAppState\n })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_39__.Island, {\n className: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.CLASSES.SHAPE_ACTIONS_MENU,\n padding: 2,\n style: {\n // we want to make sure this doesn't overflow so subtracting the\n // approximate height of hamburgerMenu + footer\n maxHeight: `${appState.height - 166}px`\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_12__.SelectedShapeActions, {\n appState: appState,\n elementsMap: app.scene.getNonDeletedElementsMap(),\n renderAction: actionManager.renderAction,\n app: app\n })));\n };\n\n const renderFixedSideContainer = () => {\n var _a, _b, _c, _d, _e;\n\n const shouldRenderSelectedShapeActions = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.showSelectedShapeActions)(appState, elements);\n\n if (appState.viewModeEnabled) {\n return null;\n } //zsviczian\n\n\n const shouldShowStats = appState.stats.open && !appState.zenModeEnabled && !appState.viewModeEnabled && ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"elementLinkSelector\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_FixedSideContainer__WEBPACK_IMPORTED_MODULE_34__.FixedSideContainer, {\n side: \"top\",\n sidepanelOpen: !!appState.openSidebar\n /*zsviczian*/\n\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"App-menu App-menu_top\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_18__[\"default\"].Col, {\n gap: spacing.menuTopGap,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"App-menu_top__left\")\n }, renderCanvasActions(), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"selected-shape-actions-container\", {\n \"selected-shape-actions-container--compact\": appState.stylesPanelMode === \"compact\"\n })\n }, shouldRenderSelectedShapeActions && renderSelectedShapeActions())), !appState.viewModeEnabled && ((_b = appState.openDialog) === null || _b === void 0 ? void 0 : _b.name) !== \"elementLinkSelector\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Section__WEBPACK_IMPORTED_MODULE_17__.Section, {\n heading: \"shapes\",\n className: \"shapes-section\"\n }, heading => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n style: {\n position: \"relative\"\n }\n }, renderWelcomeScreen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.WelcomeScreenToolbarHintTunnel.Out, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_18__[\"default\"].Col, {\n gap: spacing.toolbarColGap,\n align: \"start\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_18__[\"default\"].Row, {\n gap: spacing.toolbarRowGap,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"App-toolbar-container\", {\n \"zen-mode\": appState.zenModeEnabled\n })\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_39__.Island, {\n padding: spacing.islandPadding,\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"App-toolbar\", {\n \"zen-mode\": appState.zenModeEnabled,\n \"App-toolbar--compact\": appState.stylesPanelMode === \"compact\"\n })\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_HintViewer__WEBPACK_IMPORTED_MODULE_37__.HintViewer, {\n appState: appState,\n isMobile: device.editor.isMobile || !(appState.viewModeEnabled || appState.zenModeEnabled) && appState.trayModeEnabled,\n device: device,\n app: app\n }), heading, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_18__[\"default\"].Row, {\n gap: spacing.toolbarInnerRowGap\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_PenModeButton__WEBPACK_IMPORTED_MODULE_20__.PenModeButton, {\n zenModeEnabled: appState.zenModeEnabled,\n checked: appState.penMode,\n onChange: () => onPenModeToggle(null),\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"toolBar.penMode\"),\n penDetected: appState.penDetected\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_LockButton__WEBPACK_IMPORTED_MODULE_14__.LockButton, {\n checked: appState.activeTool.locked,\n onChange: onLockToggle,\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"toolBar.lock\")\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"App-toolbar__divider\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_HandButton__WEBPACK_IMPORTED_MODULE_35__.HandButton, {\n checked: (0,_appState__WEBPACK_IMPORTED_MODULE_6__.isHandToolActive)(appState),\n onChange: () => onHandToolToggle(),\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"toolBar.hand\"),\n isMobile: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_12__.ShapesSwitcher, {\n appState: appState,\n activeTool: appState.activeTool,\n UIOptions: UIOptions,\n app: app\n }))), isCollaborating && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_39__.Island, {\n style: {\n marginLeft: spacing.collabMarginLeft,\n alignSelf: \"center\",\n height: \"fit-content\"\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_LaserPointerButton__WEBPACK_IMPORTED_MODULE_41__.LaserPointerButton, {\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"toolBar.laser\"),\n checked: appState.activeTool.type === _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.TOOL_TYPE.laser,\n onChange: () => app.setActiveTool({\n type: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.TOOL_TYPE.laser\n }),\n isMobile: true\n })))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(\"mobile-misc-tools-container zen-mode-transition\", //zsviczian\n {\n \"transition-right\": appState.zenModeEnabled,\n \"layer-ui__wrapper__top-right--compact\": appState.stylesPanelMode === \"compact\"\n })\n }, appState.collaborators.size > 0 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_UserList__WEBPACK_IMPORTED_MODULE_19__.UserList, {\n collaborators: appState.collaborators,\n userToFollow: ((_c = appState.userToFollow) === null || _c === void 0 ? void 0 : _c.socketId) || null\n }), !appState.viewModeEnabled && ( //zsviczian\n renderTopRightUI === null || renderTopRightUI === void 0 ? void 0 : renderTopRightUI(device.editor.isMobile, appState)), !appState.viewModeEnabled && ((_d = appState.openDialog) === null || _d === void 0 ? void 0 : _d.name) !== \"elementLinkSelector\" && ( // hide button when sidebar docked\n !isSidebarDocked || ((_e = appState.openSidebar) === null || _e === void 0 ? void 0 : _e.name) !== _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_SIDEBAR.name) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.DefaultSidebarTriggerTunnel.Out, null), shouldShowStats && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_Stats__WEBPACK_IMPORTED_MODULE_30__.Stats, {\n app: app,\n onClose: () => {\n actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_4__.actionToggleStats);\n },\n renderCustomStats: renderCustomStats\n }))));\n };\n\n const isTrayModeOrMobile = device.editor.isMobile || !(appState.viewModeEnabled || appState.zenModeEnabled) && appState.trayModeEnabled; //zsviczian\n\n const renderSidebars = () => {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_DefaultSidebar__WEBPACK_IMPORTED_MODULE_28__.DefaultSidebar, {\n __fallback: true,\n onDock: docked => {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_5__.trackEvent)(\"sidebar\", `toggleDock (${docked ? \"dock\" : \"undock\"})`, `(${device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n });\n };\n\n const isSidebarDocked = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_9__.useAtomValue)(_Sidebar_Sidebar__WEBPACK_IMPORTED_MODULE_22__.isSidebarDockedAtom);\n const layerUIJSX = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), null, children, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(DefaultMainMenu, {\n UIOptions: UIOptions\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_DefaultSidebar__WEBPACK_IMPORTED_MODULE_28__.DefaultSidebar.Trigger, {\n __fallback: true,\n icon: _icons__WEBPACK_IMPORTED_MODULE_27__.LibraryIcon,\n title: (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.capitalizeString)((0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"toolBar.library\")),\n onToggle: open => {\n if (open) {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_5__.trackEvent)(\"sidebar\", `${_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_SIDEBAR.name} (open)`, `button (${device.editor.isMobile ? \"mobile\" : \"desktop\"})`);\n }\n },\n tab: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_SIDEBAR.defaultTab\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(DefaultOverwriteConfirmDialog, null), ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"ttd\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_TTDDialog_TTDDialog__WEBPACK_IMPORTED_MODULE_29__.TTDDialog, {\n __fallback: true\n }), appState.isLoading && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_LoadingMessage__WEBPACK_IMPORTED_MODULE_13__.LoadingMessage, {\n delay: 250\n }), appState.errorMessage && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_ErrorDialog__WEBPACK_IMPORTED_MODULE_32__.ErrorDialog, {\n onClose: () => setAppState({\n errorMessage: null\n })\n }, appState.errorMessage), eyeDropperState &&\n /*#__PURE__*/\n //!device.editor.isMobile && //zsviczian\n react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_EyeDropper__WEBPACK_IMPORTED_MODULE_33__.EyeDropper, {\n colorPickerType: eyeDropperState.colorPickerType,\n onCancel: () => {\n setEyeDropperState(null);\n },\n onChange: (colorPickerType, color, selectedElements, {\n altKey\n }) => {\n if (colorPickerType !== \"elementBackground\" && colorPickerType !== \"elementStroke\") {\n return;\n }\n\n if (selectedElements.length) {\n for (const element of selectedElements) {\n (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.mutateElement)(element, (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.arrayToMap)(elements), {\n [altKey && eyeDropperState.swapPreviewOnAlt ? colorPickerType === \"elementBackground\" ? \"strokeColor\" : \"backgroundColor\" : colorPickerType === \"elementBackground\" ? \"backgroundColor\" : \"strokeColor\"]: color\n });\n _excalidraw_element__WEBPACK_IMPORTED_MODULE_3__.ShapeCache.delete(element);\n }\n\n app.scene.triggerUpdate();\n } else if (colorPickerType === \"elementBackground\") {\n setAppState({\n currentItemBackgroundColor: color\n });\n } else {\n setAppState({\n currentItemStrokeColor: color\n });\n }\n },\n onSelect: (color, event) => {\n var _a;\n\n setEyeDropperState(state => {\n return (state === null || state === void 0 ? void 0 : state.keepOpenOnAlt) && event.altKey ? state : null;\n });\n (_a = eyeDropperState === null || eyeDropperState === void 0 ? void 0 : eyeDropperState.onSelect) === null || _a === void 0 ? void 0 : _a.call(eyeDropperState, color, event);\n }\n }), ((_b = appState.openDialog) === null || _b === void 0 ? void 0 : _b.name) === \"help\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_HelpDialog__WEBPACK_IMPORTED_MODULE_36__.HelpDialog, {\n onClose: () => {\n setAppState({\n openDialog: null\n });\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_ActiveConfirmDialog__WEBPACK_IMPORTED_MODULE_24__.ActiveConfirmDialog, null), ((_c = appState.openDialog) === null || _c === void 0 ? void 0 : _c.name) === \"elementLinkSelector\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_ElementLinkDialog__WEBPACK_IMPORTED_MODULE_31__[\"default\"], {\n sourceElementId: appState.openDialog.sourceElementId,\n onClose: () => {\n setAppState({\n openDialog: null\n });\n },\n scene: app.scene,\n appState: appState,\n generateLinkForSelection: generateLinkForSelection\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.OverwriteConfirmDialogTunnel.Out, null), renderImageExportDialog(), renderJSONExportDialog(), appState.pasteDialog.shown && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_PasteChartDialog__WEBPACK_IMPORTED_MODULE_16__.PasteChartDialog, {\n setAppState: setAppState,\n appState: appState,\n onClose: () => setAppState({\n pasteDialog: {\n shown: false,\n data: null\n }\n })\n }), isTrayModeOrMobile &&\n /*#__PURE__*/\n //zsviczian Added isTrayMode condition\n react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_MobileMenu__WEBPACK_IMPORTED_MODULE_15__.MobileMenu, {\n app: app,\n appState: appState,\n elements: elements,\n actionManager: actionManager,\n renderJSONExportDialog: renderJSONExportDialog,\n renderImageExportDialog: renderImageExportDialog,\n setAppState: setAppState,\n onLockToggle: onLockToggle,\n onHandToolToggle: onHandToolToggle,\n onPenModeToggle: onPenModeToggle,\n renderTopRightUI: renderTopRightUI,\n renderCustomStats: renderCustomStats,\n renderSidebars: renderSidebars,\n device: device,\n renderWelcomeScreen: renderWelcomeScreen,\n UIOptions: UIOptions\n }), !isTrayModeOrMobile &&\n /*#__PURE__*/\n //zsviczian changed from !device.editor.isMobile\n react__WEBPACK_IMPORTED_MODULE_1___default().createElement((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"layer-ui__wrapper\",\n style: appState.openSidebar && isSidebarDocked && device.editor.canFitSidebar ? {\n width: `calc(100% - var(--right-sidebar-width))`\n } : {}\n }, renderWelcomeScreen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(tunnels.WelcomeScreenCenterTunnel.Out, null), renderFixedSideContainer(), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_footer_Footer__WEBPACK_IMPORTED_MODULE_21__[\"default\"], {\n appState: appState,\n actionManager: actionManager,\n showExitZenModeBtn: showExitZenModeBtn,\n renderWelcomeScreen: renderWelcomeScreen\n }), appState.scrolledOutside && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"button\", {\n type: \"button\",\n className: \"scroll-back-to-content\",\n onClick: () => {\n setAppState(appState => Object.assign({}, (0,_scene__WEBPACK_IMPORTED_MODULE_11__.calculateScrollCenter)(elements, appState)));\n }\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_10__.t)(\"buttons.scrollBackToContent\"))), renderSidebars()));\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_context_ui_appState__WEBPACK_IMPORTED_MODULE_8__.UIAppStateContext.Provider, {\n value: appState\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(TunnelsJotaiProvider, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_context_tunnels__WEBPACK_IMPORTED_MODULE_7__.TunnelsContext.Provider, {\n value: tunnels\n }, layerUIJSX)));\n};\n\nconst stripIrrelevantAppStateProps = appState => {\n const {\n suggestedBindings,\n startBoundElement,\n cursorButton,\n scrollX,\n scrollY\n } = appState,\n ret = __rest(appState, [\"suggestedBindings\", \"startBoundElement\", \"cursorButton\", \"scrollX\", \"scrollY\"]);\n\n return ret;\n};\n\nconst areEqual = (prevProps, nextProps) => {\n // short-circuit early\n if (prevProps.children !== nextProps.children) {\n return false;\n }\n\n const {\n canvas: _pC,\n appState: prevAppState\n } = prevProps,\n prev = __rest(prevProps, [\"canvas\", \"appState\"]);\n\n const {\n canvas: _nC,\n appState: nextAppState\n } = nextProps,\n next = __rest(nextProps, [\"canvas\", \"appState\"]);\n\n return (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isShallowEqual)( // asserting AppState because we're being passed the whole AppState\n // but resolve to only the UI-relevant props\n stripIrrelevantAppStateProps(prevAppState), stripIrrelevantAppStateProps(nextAppState), {\n selectedElementIds: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isShallowEqual,\n selectedGroupIds: _excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isShallowEqual\n }) && (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_2__.isShallowEqual)(prev, next);\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().memo(LayerUI, areEqual));\n\n//# sourceURL=webpack://ExcalidrawLib/./components/LayerUI.tsx?");
15163
15163
 
15164
15164
  /***/ }),
15165
15165
 
@@ -15313,7 +15313,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
15313
15313
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
15314
15314
 
15315
15315
  "use strict";
15316
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MobileMenu: () => (/* binding */ MobileMenu)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _context_tunnels__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../context/tunnels */ \"./context/tunnels.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../scene/scrollbars */ \"./scene/scrollbars.ts\");\n/* harmony import */ var _Actions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Actions */ \"./components/Actions.tsx\");\n/* harmony import */ var _FixedSideContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./FixedSideContainer */ \"./components/FixedSideContainer.tsx\");\n/* harmony import */ var _HandButton__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./HandButton */ \"./components/HandButton.tsx\");\n/* harmony import */ var _HintViewer__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./HintViewer */ \"./components/HintViewer.tsx\");\n/* harmony import */ var _Island__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Island */ \"./components/Island.tsx\");\n/* harmony import */ var _LockButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./LockButton */ \"./components/LockButton.tsx\");\n/* harmony import */ var _PenModeButton__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./PenModeButton */ \"./components/PenModeButton.tsx\");\n/* harmony import */ var _Section__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Section */ \"./components/Section.tsx\");\n/* harmony import */ var _Stack__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Stack */ \"./components/Stack.tsx\");\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var _Stats__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Stats */ \"./components/Stats/index.tsx\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst MobileMenu = ({\n appState,\n elements,\n actionManager,\n setAppState,\n onLockToggle,\n onHandToolToggle,\n onPenModeToggle,\n renderTopRightUI,\n renderCustomStats,\n renderSidebars,\n device,\n renderWelcomeScreen,\n UIOptions,\n app\n}) => {\n var _a, _b;\n\n const {\n WelcomeScreenCenterTunnel,\n MainMenuTunnel,\n DefaultSidebarTriggerTunnel\n } = (0,_context_tunnels__WEBPACK_IMPORTED_MODULE_3__.useTunnels)();\n\n const renderToolbar = () => {\n const shouldShowStats = //zsviczian\n appState.stats.open && !appState.zenModeEnabled && !appState.viewModeEnabled;\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_FixedSideContainer__WEBPACK_IMPORTED_MODULE_8__.FixedSideContainer, {\n side: \"top\",\n className: \"App-top-bar\"\n }, renderWelcomeScreen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(WelcomeScreenCenterTunnel.Out, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Section__WEBPACK_IMPORTED_MODULE_14__.Section, {\n heading: \"shapes\"\n }, heading => {\n var _a;\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_15__[\"default\"].Col, {\n gap: 4,\n align: \"center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_15__[\"default\"].Row, {\n gap: 1,\n className: \"App-toolbar-container\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_11__.Island, {\n padding: 1,\n className: `App-toolbar${device.editor.isMobile ? \" App-toolbar--mobile\" : \"\" //zsviczian\n }`\n }, heading, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_15__[\"default\"].Row, {\n gap: 1\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_7__.ShapesSwitcher, {\n appState: appState,\n activeTool: appState.activeTool,\n UIOptions: UIOptions,\n app: app\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"mobile-misc-tools-container\"\n }, !appState.viewModeEnabled && ( //zsviczian\n renderTopRightUI === null || renderTopRightUI === void 0 ? void 0 : renderTopRightUI(true, appState)), !appState.viewModeEnabled && ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"elementLinkSelector\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(DefaultSidebarTriggerTunnel.Out, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_PenModeButton__WEBPACK_IMPORTED_MODULE_13__.PenModeButton, {\n checked: appState.penMode,\n onChange: () => onPenModeToggle(null),\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.penMode\"),\n isMobile: true,\n penDetected: appState.penDetected\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_LockButton__WEBPACK_IMPORTED_MODULE_12__.LockButton, {\n checked: appState.activeTool.locked,\n onChange: onLockToggle,\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.lock\"),\n isMobile: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_HandButton__WEBPACK_IMPORTED_MODULE_9__.HandButton, {\n checked: (0,_appState__WEBPACK_IMPORTED_MODULE_2__.isHandToolActive)(appState),\n onChange: () => onHandToolToggle(),\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.hand\"),\n isMobile: true\n }))));\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_HintViewer__WEBPACK_IMPORTED_MODULE_10__.HintViewer, {\n appState: appState,\n isMobile: true,\n device: device,\n app: app\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_16__[\"default\"])(\"layer-ui__wrapper__top-right zen-mode-transition\", {\n \"transition-right\": appState.zenModeEnabled\n }),\n style: {\n marginRight: \"4rem\"\n }\n }, shouldShowStats &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Stats__WEBPACK_IMPORTED_MODULE_17__.Stats, {\n app: app,\n onClose: () => {\n actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_18__.actionToggleStats);\n },\n renderCustomStats: renderCustomStats\n })));\n };\n\n const renderAppToolbar = () => {\n var _a;\n\n if (appState.viewModeEnabled) {\n return; //zsviczian\n }\n\n if (((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n return (\n /*#__PURE__*/\n //zsviczian (see original below)\n react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"App-toolbar-content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(MainMenuTunnel.Out, null))\n );\n }\n /*\r\n if (\r\n appState.viewModeEnabled ||\r\n appState.openDialog?.name === \"elementLinkSelector\"\r\n ) {\r\n return (\r\n <div className=\"App-toolbar-content\">\r\n <MainMenuTunnel.Out />\r\n </div>\r\n );\r\n }\r\n */\n //zsviczian fix mobile menu button positions\n\n\n const showEditMenu = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.showSelectedShapeActions)(appState, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getNonDeletedElements)(elements));\n const showElAction = (0,_scene__WEBPACK_IMPORTED_MODULE_5__.isSomeElementSelected)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getNonDeletedElements)(elements), appState);\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"App-toolbar-content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(MainMenuTunnel.Out, null), showEditMenu ? //zsviczian\n actionManager.renderAction(\"toggleEditMenu\") : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"ToolIcon__icon\",\n \"aria-hidden\": \"true\"\n }), showElAction || appState.multiElement ? //zsviczian\n actionManager.renderAction(appState.multiElement ? \"finalize\" : \"duplicateSelection\") : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"ToolIcon__icon\",\n \"aria-hidden\": \"true\"\n }), showElAction ? //zsviczian\n actionManager.renderAction(\"deleteSelectedElements\") : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"ToolIcon__icon\",\n \"aria-hidden\": \"true\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", null, actionManager.renderAction(\"undo\"), actionManager.renderAction(\"redo\")));\n };\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, renderSidebars(), !appState.viewModeEnabled && ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"elementLinkSelector\" && renderToolbar(), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"App-bottom-bar\",\n style: {\n marginBottom: _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_WIDTH + _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_MARGIN,\n marginLeft: _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_WIDTH + _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_MARGIN * 2,\n marginRight: _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_WIDTH + _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_MARGIN * 2\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_11__.Island, {\n padding: 0\n }, appState.openMenu === \"shape\" && !appState.viewModeEnabled && ((_b = appState.openDialog) === null || _b === void 0 ? void 0 : _b.name) !== \"elementLinkSelector\" && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.showSelectedShapeActions)(appState, elements) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Section__WEBPACK_IMPORTED_MODULE_14__.Section, {\n className: \"App-mobile-menu\",\n heading: \"selectedShapeActions\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_7__.SelectedShapeActions, {\n appState: appState,\n elementsMap: app.scene.getNonDeletedElementsMap(),\n renderAction: actionManager.renderAction,\n app: app\n })) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"footer\", {\n className: \"App-toolbar\"\n }, renderAppToolbar(), appState.scrolledOutside && !appState.openMenu && !appState.openSidebar && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"button\", {\n type: \"button\",\n className: \"scroll-back-to-content\",\n onClick: () => {\n setAppState(appState => Object.assign({}, (0,_scene__WEBPACK_IMPORTED_MODULE_5__.calculateScrollCenter)(elements, appState)));\n }\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.scrollBackToContent\")))), appState.trayModeEnabled ?\n /*#__PURE__*/\n //zsviczian display zoom menu in tray mode\n react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_11__.Island, {\n padding: 1,\n style: {\n marginLeft: `4px`\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_7__.ZoomActions, {\n renderAction: actionManager.renderAction,\n zoom: appState.zoom,\n trayMode: true\n })) : \"\"));\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./components/MobileMenu.tsx?");
15316
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MobileMenu: () => (/* binding */ MobileMenu)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _appState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../appState */ \"./appState.ts\");\n/* harmony import */ var _context_tunnels__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../context/tunnels */ \"./context/tunnels.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ \"./scene/index.ts\");\n/* harmony import */ var _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../scene/scrollbars */ \"./scene/scrollbars.ts\");\n/* harmony import */ var _Actions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Actions */ \"./components/Actions.tsx\");\n/* harmony import */ var _FixedSideContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./FixedSideContainer */ \"./components/FixedSideContainer.tsx\");\n/* harmony import */ var _HandButton__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./HandButton */ \"./components/HandButton.tsx\");\n/* harmony import */ var _HintViewer__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./HintViewer */ \"./components/HintViewer.tsx\");\n/* harmony import */ var _Island__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Island */ \"./components/Island.tsx\");\n/* harmony import */ var _LockButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./LockButton */ \"./components/LockButton.tsx\");\n/* harmony import */ var _PenModeButton__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./PenModeButton */ \"./components/PenModeButton.tsx\");\n/* harmony import */ var _Section__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Section */ \"./components/Section.tsx\");\n/* harmony import */ var _Stack__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Stack */ \"./components/Stack.tsx\");\n/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! clsx */ \"../../node_modules/clsx/dist/clsx.m.js\");\n/* harmony import */ var _Stats__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Stats */ \"./components/Stats/index.tsx\");\n/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../actions */ \"./actions/index.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst MobileMenu = ({\n appState,\n elements,\n actionManager,\n setAppState,\n onLockToggle,\n onHandToolToggle,\n onPenModeToggle,\n renderTopRightUI,\n renderCustomStats,\n renderSidebars,\n device,\n renderWelcomeScreen,\n UIOptions,\n app\n}) => {\n var _a, _b;\n\n const {\n WelcomeScreenCenterTunnel,\n MainMenuTunnel,\n DefaultSidebarTriggerTunnel\n } = (0,_context_tunnels__WEBPACK_IMPORTED_MODULE_3__.useTunnels)();\n\n const renderToolbar = () => {\n const shouldShowStats = //zsviczian\n appState.stats.open && !appState.zenModeEnabled && !appState.viewModeEnabled;\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_FixedSideContainer__WEBPACK_IMPORTED_MODULE_8__.FixedSideContainer, {\n side: \"top\",\n className: \"App-top-bar\",\n sidepanelOpen: !!appState.openSidebar\n /*zsviczian*/\n\n }, renderWelcomeScreen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(WelcomeScreenCenterTunnel.Out, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Section__WEBPACK_IMPORTED_MODULE_14__.Section, {\n heading: \"shapes\"\n }, heading => {\n var _a;\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_15__[\"default\"].Col, {\n gap: 4,\n align: \"center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_15__[\"default\"].Row, {\n gap: 1,\n className: \"App-toolbar-container\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_11__.Island, {\n padding: 1,\n className: `App-toolbar${device.editor.isMobile ? \" App-toolbar--mobile\" : \"\" //zsviczian\n }`\n }, heading, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Stack__WEBPACK_IMPORTED_MODULE_15__[\"default\"].Row, {\n gap: 1\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_7__.ShapesSwitcher, {\n appState: appState,\n activeTool: appState.activeTool,\n UIOptions: UIOptions,\n app: app\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"mobile-misc-tools-container\"\n }, !appState.viewModeEnabled && ( //zsviczian\n renderTopRightUI === null || renderTopRightUI === void 0 ? void 0 : renderTopRightUI(true, appState)), !appState.viewModeEnabled && ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"elementLinkSelector\" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(DefaultSidebarTriggerTunnel.Out, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_PenModeButton__WEBPACK_IMPORTED_MODULE_13__.PenModeButton, {\n checked: appState.penMode,\n onChange: () => onPenModeToggle(null),\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.penMode\"),\n isMobile: true,\n penDetected: appState.penDetected\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_LockButton__WEBPACK_IMPORTED_MODULE_12__.LockButton, {\n checked: appState.activeTool.locked,\n onChange: onLockToggle,\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.lock\"),\n isMobile: true\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_HandButton__WEBPACK_IMPORTED_MODULE_9__.HandButton, {\n checked: (0,_appState__WEBPACK_IMPORTED_MODULE_2__.isHandToolActive)(appState),\n onChange: () => onHandToolToggle(),\n title: (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"toolBar.hand\"),\n isMobile: true\n }))));\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_HintViewer__WEBPACK_IMPORTED_MODULE_10__.HintViewer, {\n appState: appState,\n isMobile: true,\n device: device,\n app: app\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: (0,clsx__WEBPACK_IMPORTED_MODULE_16__[\"default\"])(\"layer-ui__wrapper__top-right zen-mode-transition\", {\n \"transition-right\": appState.zenModeEnabled\n }),\n style: {\n marginRight: \"4rem\"\n }\n }, shouldShowStats &&\n /*#__PURE__*/\n //zsviczian\n react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Stats__WEBPACK_IMPORTED_MODULE_17__.Stats, {\n app: app,\n onClose: () => {\n actionManager.executeAction(_actions__WEBPACK_IMPORTED_MODULE_18__.actionToggleStats);\n },\n renderCustomStats: renderCustomStats\n })));\n };\n\n const renderAppToolbar = () => {\n var _a;\n\n if (appState.viewModeEnabled) {\n return; //zsviczian\n }\n\n if (((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) === \"elementLinkSelector\") {\n return (\n /*#__PURE__*/\n //zsviczian (see original below)\n react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"App-toolbar-content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(MainMenuTunnel.Out, null))\n );\n }\n /*\r\n if (\r\n appState.viewModeEnabled ||\r\n appState.openDialog?.name === \"elementLinkSelector\"\r\n ) {\r\n return (\r\n <div className=\"App-toolbar-content\">\r\n <MainMenuTunnel.Out />\r\n </div>\r\n );\r\n }\r\n */\n //zsviczian fix mobile menu button positions\n\n\n const showEditMenu = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.showSelectedShapeActions)(appState, (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getNonDeletedElements)(elements));\n const showElAction = (0,_scene__WEBPACK_IMPORTED_MODULE_5__.isSomeElementSelected)((0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.getNonDeletedElements)(elements), appState);\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"App-toolbar-content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(MainMenuTunnel.Out, null), showEditMenu ? //zsviczian\n actionManager.renderAction(\"toggleEditMenu\") : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"ToolIcon__icon\",\n \"aria-hidden\": \"true\"\n }), showElAction || appState.multiElement ? //zsviczian\n actionManager.renderAction(appState.multiElement ? \"finalize\" : \"duplicateSelection\") : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"ToolIcon__icon\",\n \"aria-hidden\": \"true\"\n }), showElAction ? //zsviczian\n actionManager.renderAction(\"deleteSelectedElements\") : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"ToolIcon__icon\",\n \"aria-hidden\": \"true\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", null, actionManager.renderAction(\"undo\"), actionManager.renderAction(\"redo\")));\n };\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, renderSidebars(), !appState.viewModeEnabled && ((_a = appState.openDialog) === null || _a === void 0 ? void 0 : _a.name) !== \"elementLinkSelector\" && renderToolbar(), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", {\n className: \"App-bottom-bar\",\n style: {\n marginBottom: _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_WIDTH + _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_MARGIN,\n marginLeft: _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_WIDTH + _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_MARGIN * 2,\n marginRight: _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_WIDTH + _scene_scrollbars__WEBPACK_IMPORTED_MODULE_6__.SCROLLBAR_MARGIN * 2\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_11__.Island, {\n padding: 0\n }, appState.openMenu === \"shape\" && !appState.viewModeEnabled && ((_b = appState.openDialog) === null || _b === void 0 ? void 0 : _b.name) !== \"elementLinkSelector\" && (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_1__.showSelectedShapeActions)(appState, elements) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Section__WEBPACK_IMPORTED_MODULE_14__.Section, {\n className: \"App-mobile-menu\",\n heading: \"selectedShapeActions\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_7__.SelectedShapeActions, {\n appState: appState,\n elementsMap: app.scene.getNonDeletedElementsMap(),\n renderAction: actionManager.renderAction,\n app: app\n })) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"footer\", {\n className: \"App-toolbar\"\n }, renderAppToolbar(), appState.scrolledOutside && !appState.openMenu && !appState.openSidebar && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"button\", {\n type: \"button\",\n className: \"scroll-back-to-content\",\n onClick: () => {\n setAppState(appState => Object.assign({}, (0,_scene__WEBPACK_IMPORTED_MODULE_5__.calculateScrollCenter)(elements, appState)));\n }\n }, (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.t)(\"buttons.scrollBackToContent\")))), appState.trayModeEnabled ?\n /*#__PURE__*/\n //zsviczian display zoom menu in tray mode\n react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Island__WEBPACK_IMPORTED_MODULE_11__.Island, {\n padding: 1,\n style: {\n marginLeft: `4px`\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_Actions__WEBPACK_IMPORTED_MODULE_7__.ZoomActions, {\n renderAction: actionManager.renderAction,\n zoom: appState.zoom,\n trayMode: true\n })) : \"\"));\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./components/MobileMenu.tsx?");
15317
15317
 
15318
15318
  /***/ }),
15319
15319
 
@@ -16160,7 +16160,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
16160
16160
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
16161
16161
 
16162
16162
  "use strict";
16163
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TTDDialogTrigger: () => (/* binding */ TTDDialogTrigger)\n/* harmony export */ });\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../analytics */ \"./analytics.ts\");\n/* harmony import */ var _context_tunnels__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../context/tunnels */ \"./context/tunnels.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../i18n */ \"./i18n.ts\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../App */ \"./components/App.tsx\");\n/* harmony import */ var _dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../dropdownMenu/DropdownMenu */ \"./components/dropdownMenu/DropdownMenu.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../icons */ \"./components/icons.tsx\");\n\n\n\n\n\n\nconst TTDDialogTrigger = ({\n children,\n icon\n}) => {\n const {\n TTDDialogTriggerTunnel\n } = (0,_context_tunnels__WEBPACK_IMPORTED_MODULE_1__.useTunnels)();\n const setAppState = (0,_App__WEBPACK_IMPORTED_MODULE_3__.useExcalidrawSetAppState)();\n return React.createElement(TTDDialogTriggerTunnel.In, null, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_4__[\"default\"].Item, {\n onSelect: () => {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_0__.trackEvent)(\"ai\", \"dialog open\", \"ttd\");\n setAppState({\n openDialog: {\n name: \"ttd\",\n tab: \"text-to-diagram\"\n }\n });\n },\n icon: icon !== null && icon !== void 0 ? icon : _icons__WEBPACK_IMPORTED_MODULE_5__.brainIcon\n }, children !== null && children !== void 0 ? children : (0,_i18n__WEBPACK_IMPORTED_MODULE_2__.t)(\"labels.textToDiagram\"), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_4__[\"default\"].Item.Badge, null, \"AI\")));\n};\nTTDDialogTrigger.displayName = \"TTDDialogTrigger\";\n\n//# sourceURL=webpack://ExcalidrawLib/./components/TTDDialog/TTDDialogTrigger.tsx?");
16163
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TTDDialogTrigger: () => (/* binding */ TTDDialogTrigger)\n/* harmony export */ });\n/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../analytics */ \"./analytics.ts\");\n/* harmony import */ var _context_tunnels__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../context/tunnels */ \"./context/tunnels.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../i18n */ \"./i18n.ts\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../App */ \"./components/App.tsx\");\n/* harmony import */ var _dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../dropdownMenu/DropdownMenu */ \"./components/dropdownMenu/DropdownMenu.tsx\");\n/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../icons */ \"./components/icons.tsx\");\n\n\n\n\n\n\nconst TTDDialogTrigger = ({\n children,\n icon\n}) => {\n const {\n t\n } = (0,_i18n__WEBPACK_IMPORTED_MODULE_2__.useI18n)();\n const {\n TTDDialogTriggerTunnel\n } = (0,_context_tunnels__WEBPACK_IMPORTED_MODULE_1__.useTunnels)();\n const setAppState = (0,_App__WEBPACK_IMPORTED_MODULE_3__.useExcalidrawSetAppState)();\n return React.createElement(TTDDialogTriggerTunnel.In, null, React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_4__[\"default\"].Item, {\n onSelect: () => {\n (0,_analytics__WEBPACK_IMPORTED_MODULE_0__.trackEvent)(\"ai\", \"dialog open\", \"ttd\");\n setAppState({\n openDialog: {\n name: \"ttd\",\n tab: \"text-to-diagram\"\n }\n });\n },\n icon: icon !== null && icon !== void 0 ? icon : _icons__WEBPACK_IMPORTED_MODULE_5__.brainIcon\n }, children !== null && children !== void 0 ? children : t(\"labels.textToDiagram\"), React.createElement(_dropdownMenu_DropdownMenu__WEBPACK_IMPORTED_MODULE_4__[\"default\"].Item.Badge, null, \"AI\")));\n};\nTTDDialogTrigger.displayName = \"TTDDialogTrigger\";\n\n//# sourceURL=webpack://ExcalidrawLib/./components/TTDDialog/TTDDialogTrigger.tsx?");
16164
16164
 
16165
16165
  /***/ }),
16166
16166
 
@@ -16875,7 +16875,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
16875
16875
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
16876
16876
 
16877
16877
  "use strict";
16878
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ distributeLibraryItemsOnSquareGrid: () => (/* binding */ distributeLibraryItemsOnSquareGrid),\n/* harmony export */ getLibraryItemsHash: () => (/* binding */ getLibraryItemsHash),\n/* harmony export */ libraryItemsAtom: () => (/* binding */ libraryItemsAtom),\n/* harmony export */ mergeLibraryItems: () => (/* binding */ mergeLibraryItems),\n/* harmony export */ parseLibraryTokensFromUrl: () => (/* binding */ parseLibraryTokensFromUrl),\n/* harmony export */ useHandleLibrary: () => (/* binding */ useHandleLibrary),\n/* harmony export */ validateLibraryUrl: () => (/* binding */ validateLibraryUrl)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors */ \"./errors.ts\");\n/* harmony import */ var _hooks_useLibraryItemSvg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../hooks/useLibraryItemSvg */ \"./hooks/useLibraryItemSvg.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _blob__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./blob */ \"./data/blob.ts\");\n/* harmony import */ var _restore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./restore */ \"./data/restore.ts\");\nvar _a;\n\n\n\n\n\n\n\n\n\n\n\n/**\r\n * format: hostname or hostname/pathname\r\n *\r\n * Both hostname and pathname are matched partially,\r\n * hostname from the end, pathname from the start, with subdomain/path\r\n * boundaries\r\n **/\n\nconst ALLOWED_LIBRARY_URLS = [\"excalidraw.com\", // when installing from github PRs\n\"raw.githubusercontent.com/excalidraw/excalidraw-libraries\"];\nconst onLibraryUpdateEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.Emitter();\nconst libraryItemsAtom = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_3__.atom)({\n status: \"loaded\",\n isInitialized: false,\n libraryItems: []\n});\n\nconst cloneLibraryItems = libraryItems => (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.cloneJSON)(libraryItems);\n/**\r\n * checks if library item does not exist already in current library\r\n */\n\n\nconst isUniqueItem = (existingLibraryItems, targetLibraryItem) => {\n return !existingLibraryItems.find(libraryItem => {\n if (libraryItem.elements.length !== targetLibraryItem.elements.length) {\n return false;\n } // detect z-index difference by checking the excalidraw elements\n // are in order\n\n\n return libraryItem.elements.every((libItemExcalidrawItem, idx) => {\n return libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce;\n });\n });\n};\n/** Merges otherItems into localItems. Unique items in otherItems array are\r\n sorted first. */\n\n\nconst mergeLibraryItems = (localItems, otherItems) => {\n const newItems = [];\n\n for (const item of otherItems) {\n if (isUniqueItem(localItems, item)) {\n newItems.push(item);\n }\n }\n\n return [...newItems, ...localItems];\n};\n/**\r\n * Returns { deletedItems, addedItems } maps of all added and deleted items\r\n * since last onLibraryChange event.\r\n *\r\n * Host apps are recommended to diff with the latest state they have.\r\n */\n\nconst createLibraryUpdate = (prevLibraryItems, nextLibraryItems) => {\n const nextItemsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(nextLibraryItems);\n const update = {\n deletedItems: new Map(),\n addedItems: new Map()\n };\n\n for (const item of prevLibraryItems) {\n if (!nextItemsMap.has(item.id)) {\n update.deletedItems.set(item.id, item);\n }\n }\n\n const prevItemsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(prevLibraryItems);\n\n for (const item of nextLibraryItems) {\n if (!prevItemsMap.has(item.id)) {\n update.addedItems.set(item.id, item);\n }\n }\n\n return update;\n};\n\nclass Library {\n constructor(app) {\n /** latest libraryItems */\n this.currLibraryItems = [];\n /** snapshot of library items since last onLibraryChange call */\n\n this.prevLibraryItems = cloneLibraryItems(this.currLibraryItems);\n this.updateQueue = [];\n\n this.getLastUpdateTask = () => {\n return this.updateQueue[this.updateQueue.length - 1];\n };\n\n this.notifyListeners = () => {\n var _b, _c;\n\n if (this.updateQueue.length > 0) {\n _editor_jotai__WEBPACK_IMPORTED_MODULE_3__.editorJotaiStore.set(libraryItemsAtom, s => ({\n status: \"loading\",\n libraryItems: this.currLibraryItems,\n isInitialized: s.isInitialized\n }));\n } else {\n _editor_jotai__WEBPACK_IMPORTED_MODULE_3__.editorJotaiStore.set(libraryItemsAtom, {\n status: \"loaded\",\n libraryItems: this.currLibraryItems,\n isInitialized: true\n });\n\n try {\n const prevLibraryItems = this.prevLibraryItems;\n this.prevLibraryItems = cloneLibraryItems(this.currLibraryItems);\n const nextLibraryItems = cloneLibraryItems(this.currLibraryItems);\n (_c = (_b = this.app.props).onLibraryChange) === null || _c === void 0 ? void 0 : _c.call(_b, nextLibraryItems); // for internal use in `useHandleLibrary` hook\n\n onLibraryUpdateEmitter.trigger(createLibraryUpdate(prevLibraryItems, nextLibraryItems), nextLibraryItems);\n } catch (error) {\n console.error(error);\n }\n }\n };\n /** call on excalidraw instance unmount */\n\n\n this.destroy = () => {\n this.updateQueue = [];\n this.currLibraryItems = [];\n _editor_jotai__WEBPACK_IMPORTED_MODULE_3__.editorJotaiStore.set(_hooks_useLibraryItemSvg__WEBPACK_IMPORTED_MODULE_5__.libraryItemSvgsCache, new Map()); // TODO uncomment after/if we make jotai store scoped to each excal instance\n // jotaiStore.set(libraryItemsAtom, {\n // status: \"loading\",\n // isInitialized: false,\n // libraryItems: [],\n // });\n };\n\n this.resetLibrary = () => {\n return this.setLibrary([]);\n };\n /**\r\n * @returns latest cloned libraryItems. Awaits all in-progress updates first.\r\n */\n\n\n this.getLatestLibrary = () => {\n return new Promise(async resolve => {\n try {\n const libraryItems = await (this.getLastUpdateTask() || this.currLibraryItems);\n\n if (this.updateQueue.length > 0) {\n resolve(this.getLatestLibrary());\n } else {\n resolve(cloneLibraryItems(libraryItems));\n }\n } catch (error) {\n return resolve(this.currLibraryItems);\n }\n });\n }; // NOTE this is a high-level public API (exposed on ExcalidrawAPI) with\n // a slight overhead (always restoring library items). For internal use\n // where merging isn't needed, use `library.setLibrary()` directly.\n\n\n this.updateLibrary = async ({\n libraryItems,\n prompt = false,\n merge = false,\n openLibraryMenu = false,\n defaultStatus = \"unpublished\"\n }) => {\n if (openLibraryMenu) {\n this.app.setState({\n openSidebar: {\n name: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SIDEBAR.name,\n tab: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.LIBRARY_SIDEBAR_TAB\n }\n });\n }\n\n return this.setLibrary(() => {\n return new Promise(async (resolve, reject) => {\n try {\n const source = await (typeof libraryItems === \"function\" && !(libraryItems instanceof Blob) ? libraryItems(this.currLibraryItems) : libraryItems);\n let nextItems;\n\n if (source instanceof Blob) {\n nextItems = await (0,_blob__WEBPACK_IMPORTED_MODULE_7__.loadLibraryFromBlob)(source, defaultStatus);\n } else {\n nextItems = (0,_restore__WEBPACK_IMPORTED_MODULE_8__.restoreLibraryItems)(source, defaultStatus);\n }\n\n if (!prompt || window.confirm((0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"alerts.confirmAddLibrary\", {\n numShapes: nextItems.length\n }))) {\n if (prompt) {\n // focus container if we've prompted. We focus conditionally\n // lest `props.autoFocus` is disabled (in which case we should\n // focus only on user action such as prompt confirm)\n this.app.focusContainer();\n }\n\n if (merge) {\n resolve(mergeLibraryItems(this.currLibraryItems, nextItems));\n } else {\n resolve(nextItems);\n }\n } else {\n reject(new _errors__WEBPACK_IMPORTED_MODULE_4__.AbortError());\n }\n } catch (error) {\n reject(error);\n }\n });\n });\n };\n\n this.setLibrary = (\n /**\r\n * LibraryItems that will replace current items. Can be a function which\r\n * will be invoked after all previous tasks are resolved\r\n * (this is the prefered way to update the library to avoid race conditions,\r\n * but you'll want to manually merge the library items in the callback\r\n * - which is what we're doing in Library.importLibrary()).\r\n *\r\n * If supplied promise is rejected with AbortError, we swallow it and\r\n * do not update the library.\r\n */\n libraryItems) => {\n const task = new Promise(async (resolve, reject) => {\n try {\n await this.getLastUpdateTask();\n\n if (typeof libraryItems === \"function\") {\n libraryItems = libraryItems(this.currLibraryItems);\n }\n\n this.currLibraryItems = cloneLibraryItems(await libraryItems);\n resolve(this.currLibraryItems);\n } catch (error) {\n reject(error);\n }\n }).catch(error => {\n if (error.name === \"AbortError\") {\n console.warn(\"Library update aborted by user\");\n return this.currLibraryItems;\n }\n\n throw error;\n }).finally(() => {\n this.updateQueue = this.updateQueue.filter(_task => _task !== task);\n this.notifyListeners();\n });\n this.updateQueue.push(task);\n this.notifyListeners();\n return task;\n };\n\n this.app = app;\n }\n\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Library);\nconst distributeLibraryItemsOnSquareGrid = libraryItems => {\n const PADDING = 50;\n const ITEMS_PER_ROW = Math.ceil(Math.sqrt(libraryItems.length));\n const resElements = [];\n\n const getMaxHeightPerRow = row => {\n const maxHeight = libraryItems.slice(row * ITEMS_PER_ROW, row * ITEMS_PER_ROW + ITEMS_PER_ROW).reduce((acc, item) => {\n const {\n height\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBoundingBox)(item.elements);\n return Math.max(acc, height);\n }, 0);\n return maxHeight;\n };\n\n const getMaxWidthPerCol = targetCol => {\n let index = 0;\n let currCol = 0;\n let maxWidth = 0;\n\n for (const item of libraryItems) {\n if (index % ITEMS_PER_ROW === 0) {\n currCol = 0;\n }\n\n if (currCol === targetCol) {\n const {\n width\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBoundingBox)(item.elements);\n maxWidth = Math.max(maxWidth, width);\n }\n\n index++;\n currCol++;\n }\n\n return maxWidth;\n };\n\n let colOffsetX = 0;\n let rowOffsetY = 0;\n let maxHeightCurrRow = 0;\n let maxWidthCurrCol = 0;\n let index = 0;\n let col = 0;\n let row = 0;\n\n for (const item of libraryItems) {\n if (index && index % ITEMS_PER_ROW === 0) {\n rowOffsetY += maxHeightCurrRow + PADDING;\n colOffsetX = 0;\n col = 0;\n row++;\n }\n\n if (col === 0) {\n maxHeightCurrRow = getMaxHeightPerRow(row);\n }\n\n maxWidthCurrCol = getMaxWidthPerCol(col);\n const {\n minX,\n minY,\n width,\n height\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBoundingBox)(item.elements);\n const offsetCenterX = (maxWidthCurrCol - width) / 2;\n const offsetCenterY = (maxHeightCurrRow - height) / 2;\n resElements.push( // eslint-disable-next-line no-loop-func\n ...item.elements.map(element => Object.assign(Object.assign({}, element), {\n x: element.x + // offset for column\n colOffsetX + // offset to center in given square grid\n offsetCenterX - // subtract minX so that given item starts at 0 coord\n minX,\n y: element.y + // offset for row\n rowOffsetY + // offset to center in given square grid\n offsetCenterY - // subtract minY so that given item starts at 0 coord\n minY\n })));\n colOffsetX += maxWidthCurrCol + PADDING;\n index++;\n col++;\n }\n\n return resElements;\n};\nconst validateLibraryUrl = (libraryUrl,\n/**\r\n * @returns `true` if the URL is valid, throws otherwise.\r\n */\nvalidator = ALLOWED_LIBRARY_URLS) => {\n if (typeof validator === \"function\" ? validator(libraryUrl) : validator.some(allowedUrlDef => {\n const allowedUrl = new URL(`https://${allowedUrlDef.replace(/^https?:\\/\\//, \"\")}`);\n const {\n hostname,\n pathname\n } = new URL(libraryUrl);\n return new RegExp(`(^|\\\\.)${allowedUrl.hostname}$`).test(hostname) && new RegExp(`^${allowedUrl.pathname.replace(/\\/+$/, \"\")}(/+|$)`).test(pathname);\n })) {\n return true;\n }\n\n throw new Error(`Invalid or disallowed library URL: \"${libraryUrl}\"`);\n};\nconst parseLibraryTokensFromUrl = () => {\n const libraryUrl = // current\n new URLSearchParams(window.location.hash.slice(1)).get(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_HASH_KEYS.addLibrary) || // legacy, kept for compat reasons\n new URLSearchParams(window.location.search).get(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_QUERY_KEYS.addLibrary);\n const idToken = libraryUrl ? new URLSearchParams(window.location.hash.slice(1)).get(\"token\") : null;\n return libraryUrl ? {\n libraryUrl,\n idToken\n } : null;\n};\n\nclass AdapterTransaction {\n static async getLibraryItems(adapter, source, _queue = true) {\n const task = () => new Promise(async (resolve, reject) => {\n try {\n const data = await adapter.load({\n source\n });\n resolve((0,_restore__WEBPACK_IMPORTED_MODULE_8__.restoreLibraryItems)((data === null || data === void 0 ? void 0 : data.libraryItems) || [], \"published\"));\n } catch (error) {\n reject(error);\n }\n });\n\n if (_queue) {\n return AdapterTransaction.queue.push(task);\n }\n\n return task();\n }\n\n constructor(adapter) {\n this.adapter = adapter;\n }\n\n getLibraryItems(source) {\n return AdapterTransaction.getLibraryItems(this.adapter, source, false);\n }\n\n}\n\n_a = AdapterTransaction;\nAdapterTransaction.queue = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.Queue();\n\nAdapterTransaction.run = async (adapter, fn) => {\n const transaction = new AdapterTransaction(adapter);\n return AdapterTransaction.queue.push(() => fn(transaction));\n};\n\nlet lastSavedLibraryItemsHash = 0;\nlet librarySaveCounter = 0;\nconst getLibraryItemsHash = items => {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.hashString)(items.map(item => {\n return `${item.id}:${(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.hashElementsVersion)(item.elements)}`;\n }).sort().join());\n};\n\nconst persistLibraryUpdate = async (adapter, update) => {\n try {\n librarySaveCounter++;\n return await AdapterTransaction.run(adapter, async transaction => {\n const nextLibraryItemsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(await transaction.getLibraryItems(\"save\"));\n\n for (const [id] of update.deletedItems) {\n nextLibraryItemsMap.delete(id);\n }\n\n const addedItems = []; // we want to merge current library items with the ones stored in the\n // DB so that we don't lose any elements that for some reason aren't\n // in the current editor library, which could happen when:\n //\n // 1. we haven't received an update deleting some elements\n // (in which case it's still better to keep them in the DB lest\n // it was due to a different reason)\n // 2. we keep a single DB for all active editors, but the editors'\n // libraries aren't synced or there's a race conditions during\n // syncing\n // 3. some other race condition, e.g. during init where emit updates\n // for partial updates (e.g. you install a 3rd party library and\n // init from DB only after — we emit events for both updates)\n\n for (const [id, item] of update.addedItems) {\n if (nextLibraryItemsMap.has(id)) {\n // replace item with latest version\n // TODO we could prefer the newer item instead\n nextLibraryItemsMap.set(id, item);\n } else {\n // we want to prepend the new items with the ones that are already\n // in DB to preserve the ordering we do in editor (newly added\n // items are added to the beginning)\n addedItems.push(item);\n }\n }\n\n const nextLibraryItems = addedItems.concat(Array.from(nextLibraryItemsMap.values()));\n const version = getLibraryItemsHash(nextLibraryItems);\n\n if (version !== lastSavedLibraryItemsHash) {\n await adapter.save({\n libraryItems: nextLibraryItems\n });\n }\n\n lastSavedLibraryItemsHash = version;\n return nextLibraryItems;\n });\n } finally {\n librarySaveCounter--;\n }\n};\n\nconst useHandleLibrary = opts => {\n const {\n excalidrawAPI\n } = opts;\n const optsRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(opts);\n optsRef.current = opts;\n const isLibraryLoadedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n if (!excalidrawAPI) {\n return;\n } // reset on editor remount (excalidrawAPI changed)\n\n\n isLibraryLoadedRef.current = false;\n\n const importLibraryFromURL = async ({\n libraryUrl,\n idToken\n }) => {\n const libraryPromise = new Promise(async (resolve, reject) => {\n try {\n libraryUrl = decodeURIComponent(libraryUrl);\n libraryUrl = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.toValidURL)(libraryUrl);\n validateLibraryUrl(libraryUrl, optsRef.current.validateLibraryUrl);\n const request = await fetch(libraryUrl);\n const blob = await request.blob();\n resolve(blob);\n } catch (error) {\n reject(error);\n }\n });\n const shouldPrompt = idToken !== excalidrawAPI.id; // wait for the tab to be focused before continuing in case we'll prompt\n // for confirmation\n\n await (shouldPrompt && document.hidden ? new Promise(resolve => {\n window.addEventListener(\"focus\", () => resolve(), {\n once: true\n });\n }) : null);\n\n try {\n await excalidrawAPI.updateLibrary({\n libraryItems: libraryPromise,\n prompt: shouldPrompt,\n merge: true,\n defaultStatus: \"published\",\n openLibraryMenu: true\n });\n } catch (error) {\n excalidrawAPI.updateScene({\n appState: {\n errorMessage: error.message\n }\n });\n throw error;\n } finally {\n if (window.location.hash.includes(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_HASH_KEYS.addLibrary)) {\n const hash = new URLSearchParams(window.location.hash.slice(1));\n hash.delete(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_HASH_KEYS.addLibrary);\n window.history.replaceState({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.APP_NAME, `#${hash.toString()}`);\n } else if (window.location.search.includes(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_QUERY_KEYS.addLibrary)) {\n const query = new URLSearchParams(window.location.search);\n query.delete(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_QUERY_KEYS.addLibrary);\n window.history.replaceState({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.APP_NAME, `?${query.toString()}`);\n }\n }\n };\n\n const onHashChange = event => {\n event.preventDefault();\n const libraryUrlTokens = parseLibraryTokensFromUrl();\n\n if (libraryUrlTokens) {\n event.stopImmediatePropagation(); // If hash changed and it contains library url, import it and replace\n // the url to its previous state (important in case of collaboration\n // and similar).\n // Using history API won't trigger another hashchange.\n\n window.history.replaceState({}, \"\", event.oldURL);\n importLibraryFromURL(libraryUrlTokens);\n }\n }; // -------------------------------------------------------------------------\n // ---------------------------------- init ---------------------------------\n // -------------------------------------------------------------------------\n\n\n const libraryUrlTokens = parseLibraryTokensFromUrl();\n\n if (libraryUrlTokens) {\n importLibraryFromURL(libraryUrlTokens);\n } // ------ (A) init load (legacy) -------------------------------------------\n\n\n if (\"getInitialLibraryItems\" in optsRef.current && optsRef.current.getInitialLibraryItems) {\n console.warn(\"useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead.\");\n Promise.resolve(optsRef.current.getInitialLibraryItems()).then(libraryItems => {\n excalidrawAPI.updateLibrary({\n libraryItems,\n // merge with current library items because we may have already\n // populated it (e.g. by installing 3rd party library which can\n // happen before the DB data is loaded)\n merge: true\n });\n }).catch(error => {\n console.error(`UseHandeLibrary getInitialLibraryItems failed: ${error === null || error === void 0 ? void 0 : error.message}`);\n });\n } // -------------------------------------------------------------------------\n // --------------------------------------------------------- init load -----\n // -------------------------------------------------------------------------\n // ------ (B) data source adapter ------------------------------------------\n\n\n if (\"adapter\" in optsRef.current && optsRef.current.adapter) {\n const adapter = optsRef.current.adapter;\n const migrationAdapter = optsRef.current.migrationAdapter;\n const initDataPromise = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.resolvablePromise)(); // migrate from old data source if needed\n // (note, if `migrate` function is defined, we always migrate even\n // if the data has already been migrated. In that case it'll be a no-op,\n // though with several unnecessary steps — we will still load latest\n // DB data during the `persistLibraryChange()` step)\n // -----------------------------------------------------------------------\n\n if (migrationAdapter) {\n initDataPromise.resolve((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.promiseTry)(migrationAdapter.load).then(async libraryData => {\n let restoredData = null;\n\n try {\n // if no library data to migrate, assume no migration needed\n // and skip persisting to new data store, as well as well\n // clearing the old store via `migrationAdapter.clear()`\n if (!libraryData) {\n return AdapterTransaction.getLibraryItems(adapter, \"load\");\n }\n\n restoredData = (0,_restore__WEBPACK_IMPORTED_MODULE_8__.restoreLibraryItems)(libraryData.libraryItems || [], \"published\"); // we don't queue this operation because it's running inside\n // a promise that's running inside Library update queue itself\n\n const nextItems = await persistLibraryUpdate(adapter, createLibraryUpdate([], restoredData));\n\n try {\n await migrationAdapter.clear();\n } catch (error) {\n console.error(`couldn't delete legacy library data: ${error.message}`);\n } // migration suceeded, load migrated data\n\n\n return nextItems;\n } catch (error) {\n console.error(`couldn't migrate legacy library data: ${error.message}`); // migration failed, load data from previous store, if any\n\n return restoredData;\n }\n }) // errors caught during `migrationAdapter.load()`\n .catch(error => {\n console.error(`error during library migration: ${error.message}`); // as a default, load latest library from current data source\n\n return AdapterTransaction.getLibraryItems(adapter, \"load\");\n }));\n } else {\n initDataPromise.resolve((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.promiseTry)(AdapterTransaction.getLibraryItems, adapter, \"load\"));\n } // load initial (or migrated) library\n\n\n excalidrawAPI.updateLibrary({\n libraryItems: initDataPromise.then(libraryItems => {\n const _libraryItems = libraryItems || [];\n\n lastSavedLibraryItemsHash = getLibraryItemsHash(_libraryItems);\n return _libraryItems;\n }),\n // merge with current library items because we may have already\n // populated it (e.g. by installing 3rd party library which can\n // happen before the DB data is loaded)\n merge: true\n }).finally(() => {\n isLibraryLoadedRef.current = true;\n });\n } // ---------------------------------------------- data source datapter -----\n\n\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.EVENT.HASHCHANGE, onHashChange);\n return () => {\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.EVENT.HASHCHANGE, onHashChange);\n };\n }, [// important this useEffect only depends on excalidrawAPI so it only reruns\n // on editor remounts (the excalidrawAPI changes)\n excalidrawAPI]); // This effect is run without excalidrawAPI dependency so that host apps\n // can run this hook outside of an active editor instance and the library\n // update queue/loop survives editor remounts\n //\n // This effect is still only meant to be run if host apps supply an persitence\n // adapter. If we don't have access to it, it the update listener doesn't\n // do anything.\n\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n // on update, merge with current library items and persist\n // -----------------------------------------------------------------------\n const unsubOnLibraryUpdate = onLibraryUpdateEmitter.on(async (update, nextLibraryItems) => {\n const isLoaded = isLibraryLoadedRef.current; // we want to operate with the latest adapter, but we don't want this\n // effect to rerun on every adapter change in case host apps' adapter\n // isn't stable\n\n const adapter = \"adapter\" in optsRef.current && optsRef.current.adapter || null;\n\n try {\n if (adapter) {\n if ( // if nextLibraryItems hash identical to previously saved hash,\n // exit early, even if actual upstream state ends up being\n // different (e.g. has more data than we have locally), as it'd\n // be low-impact scenario.\n lastSavedLibraryItemsHash !== getLibraryItemsHash(nextLibraryItems)) {\n await persistLibraryUpdate(adapter, update);\n }\n }\n } catch (error) {\n console.error(`couldn't persist library update: ${error.message}`, update); // currently we only show error if an editor is loaded\n\n if (isLoaded && optsRef.current.excalidrawAPI) {\n optsRef.current.excalidrawAPI.updateScene({\n appState: {\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"errors.saveLibraryError\")\n }\n });\n }\n }\n });\n\n const onUnload = event => {\n if (librarySaveCounter) {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.preventUnload)(event);\n }\n };\n\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.EVENT.BEFORE_UNLOAD, onUnload);\n return () => {\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.EVENT.BEFORE_UNLOAD, onUnload);\n unsubOnLibraryUpdate();\n lastSavedLibraryItemsHash = 0;\n librarySaveCounter = 0;\n };\n }, [// this effect must not have any deps so it doesn't rerun\n ]);\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./data/library.ts?");
16878
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ distributeLibraryItemsOnSquareGrid: () => (/* binding */ distributeLibraryItemsOnSquareGrid),\n/* harmony export */ getLibraryItemsHash: () => (/* binding */ getLibraryItemsHash),\n/* harmony export */ libraryItemsAtom: () => (/* binding */ libraryItemsAtom),\n/* harmony export */ mergeLibraryItems: () => (/* binding */ mergeLibraryItems),\n/* harmony export */ parseLibraryTokensFromUrl: () => (/* binding */ parseLibraryTokensFromUrl),\n/* harmony export */ useHandleLibrary: () => (/* binding */ useHandleLibrary),\n/* harmony export */ validateLibraryUrl: () => (/* binding */ validateLibraryUrl)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @excalidraw/common */ \"../common/src/index.ts\");\n/* harmony import */ var _excalidraw_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @excalidraw/element */ \"../element/src/index.ts\");\n/* harmony import */ var _editor_jotai__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../editor-jotai */ \"./editor-jotai.ts\");\n/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors */ \"./errors.ts\");\n/* harmony import */ var _hooks_useLibraryItemSvg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../hooks/useLibraryItemSvg */ \"./hooks/useLibraryItemSvg.ts\");\n/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../i18n */ \"./i18n.ts\");\n/* harmony import */ var _blob__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./blob */ \"./data/blob.ts\");\n/* harmony import */ var _restore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./restore */ \"./data/restore.ts\");\nvar _a;\n\n\n\n\n\n\n\n\n\n\n\n/**\r\n * format: hostname or hostname/pathname\r\n *\r\n * Both hostname and pathname are matched partially,\r\n * hostname from the end, pathname from the start, with subdomain/path\r\n * boundaries\r\n **/\n\nconst ALLOWED_LIBRARY_URLS = [\"excalidraw.com\", // when installing from github PRs\n\"raw.githubusercontent.com/excalidraw/excalidraw-libraries\"];\nconst onLibraryUpdateEmitter = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.Emitter();\nconst libraryItemsAtom = (0,_editor_jotai__WEBPACK_IMPORTED_MODULE_3__.atom)({\n status: \"loaded\",\n isInitialized: false,\n libraryItems: []\n});\n\nconst cloneLibraryItems = libraryItems => (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.cloneJSON)(libraryItems);\n/**\r\n * checks if library item does not exist already in current library\r\n */\n\n\nconst isUniqueItem = (existingLibraryItems, targetLibraryItem) => {\n return !existingLibraryItems.find(libraryItem => {\n if (libraryItem.elements.length !== targetLibraryItem.elements.length) {\n return false;\n } // detect z-index difference by checking the excalidraw elements\n // are in order\n\n\n return libraryItem.elements.every((libItemExcalidrawItem, idx) => {\n return libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce;\n });\n });\n};\n/** Merges otherItems into localItems. Unique items in otherItems array are\r\n sorted first. */\n\n\nconst mergeLibraryItems = (localItems, otherItems) => {\n const newItems = [];\n\n for (const item of otherItems) {\n if (isUniqueItem(localItems, item)) {\n newItems.push(item);\n }\n }\n\n return [...newItems, ...localItems];\n};\n/**\r\n * Returns { deletedItems, addedItems } maps of all added and deleted items\r\n * since last onLibraryChange event.\r\n *\r\n * Host apps are recommended to diff with the latest state they have.\r\n */\n\nconst createLibraryUpdate = (prevLibraryItems, nextLibraryItems) => {\n const nextItemsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(nextLibraryItems);\n const update = {\n deletedItems: new Map(),\n addedItems: new Map(),\n updatedItems: new Map()\n };\n\n for (const item of prevLibraryItems) {\n if (!nextItemsMap.has(item.id)) {\n update.deletedItems.set(item.id, item);\n }\n }\n\n const prevItemsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(prevLibraryItems);\n\n for (const item of nextLibraryItems) {\n const prevItem = prevItemsMap.get(item.id);\n\n if (!prevItem) {\n update.addedItems.set(item.id, item);\n } else if (getLibraryItemHash(prevItem) !== getLibraryItemHash(item)) {\n update.updatedItems.set(item.id, item);\n }\n }\n\n return update;\n};\n\nclass Library {\n constructor(app) {\n /** latest libraryItems */\n this.currLibraryItems = [];\n /** snapshot of library items since last onLibraryChange call */\n\n this.prevLibraryItems = cloneLibraryItems(this.currLibraryItems);\n this.updateQueue = [];\n\n this.getLastUpdateTask = () => {\n return this.updateQueue[this.updateQueue.length - 1];\n };\n\n this.notifyListeners = () => {\n var _b, _c;\n\n if (this.updateQueue.length > 0) {\n _editor_jotai__WEBPACK_IMPORTED_MODULE_3__.editorJotaiStore.set(libraryItemsAtom, s => ({\n status: \"loading\",\n libraryItems: this.currLibraryItems,\n isInitialized: s.isInitialized\n }));\n } else {\n _editor_jotai__WEBPACK_IMPORTED_MODULE_3__.editorJotaiStore.set(libraryItemsAtom, {\n status: \"loaded\",\n libraryItems: this.currLibraryItems,\n isInitialized: true\n });\n\n try {\n const prevLibraryItems = this.prevLibraryItems;\n this.prevLibraryItems = cloneLibraryItems(this.currLibraryItems);\n const nextLibraryItems = cloneLibraryItems(this.currLibraryItems);\n (_c = (_b = this.app.props).onLibraryChange) === null || _c === void 0 ? void 0 : _c.call(_b, nextLibraryItems); // for internal use in `useHandleLibrary` hook\n\n onLibraryUpdateEmitter.trigger(createLibraryUpdate(prevLibraryItems, nextLibraryItems), nextLibraryItems);\n } catch (error) {\n console.error(error);\n }\n }\n };\n /** call on excalidraw instance unmount */\n\n\n this.destroy = () => {\n this.updateQueue = [];\n this.currLibraryItems = [];\n _editor_jotai__WEBPACK_IMPORTED_MODULE_3__.editorJotaiStore.set(_hooks_useLibraryItemSvg__WEBPACK_IMPORTED_MODULE_5__.libraryItemSvgsCache, new Map()); // TODO uncomment after/if we make jotai store scoped to each excal instance\n // jotaiStore.set(libraryItemsAtom, {\n // status: \"loading\",\n // isInitialized: false,\n // libraryItems: [],\n // });\n };\n\n this.resetLibrary = () => {\n return this.setLibrary([]);\n };\n /**\r\n * @returns latest cloned libraryItems. Awaits all in-progress updates first.\r\n */\n\n\n this.getLatestLibrary = () => {\n return new Promise(async resolve => {\n try {\n const libraryItems = await (this.getLastUpdateTask() || this.currLibraryItems);\n\n if (this.updateQueue.length > 0) {\n resolve(this.getLatestLibrary());\n } else {\n resolve(cloneLibraryItems(libraryItems));\n }\n } catch (error) {\n return resolve(this.currLibraryItems);\n }\n });\n }; // NOTE this is a high-level public API (exposed on ExcalidrawAPI) with\n // a slight overhead (always restoring library items). For internal use\n // where merging isn't needed, use `library.setLibrary()` directly.\n\n\n this.updateLibrary = async ({\n libraryItems,\n prompt = false,\n merge = false,\n openLibraryMenu = false,\n defaultStatus = \"unpublished\"\n }) => {\n if (openLibraryMenu) {\n this.app.setState({\n openSidebar: {\n name: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_SIDEBAR.name,\n tab: _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.LIBRARY_SIDEBAR_TAB\n }\n });\n }\n\n return this.setLibrary(() => {\n return new Promise(async (resolve, reject) => {\n try {\n const source = await (typeof libraryItems === \"function\" && !(libraryItems instanceof Blob) ? libraryItems(this.currLibraryItems) : libraryItems);\n let nextItems;\n\n if (source instanceof Blob) {\n nextItems = await (0,_blob__WEBPACK_IMPORTED_MODULE_7__.loadLibraryFromBlob)(source, defaultStatus);\n } else {\n nextItems = (0,_restore__WEBPACK_IMPORTED_MODULE_8__.restoreLibraryItems)(source, defaultStatus);\n }\n\n if (!prompt || window.confirm((0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"alerts.confirmAddLibrary\", {\n numShapes: nextItems.length\n }))) {\n if (prompt) {\n // focus container if we've prompted. We focus conditionally\n // lest `props.autoFocus` is disabled (in which case we should\n // focus only on user action such as prompt confirm)\n this.app.focusContainer();\n }\n\n if (merge) {\n resolve(mergeLibraryItems(this.currLibraryItems, nextItems));\n } else {\n resolve(nextItems);\n }\n } else {\n reject(new _errors__WEBPACK_IMPORTED_MODULE_4__.AbortError());\n }\n } catch (error) {\n reject(error);\n }\n });\n });\n };\n\n this.setLibrary = (\n /**\r\n * LibraryItems that will replace current items. Can be a function which\r\n * will be invoked after all previous tasks are resolved\r\n * (this is the prefered way to update the library to avoid race conditions,\r\n * but you'll want to manually merge the library items in the callback\r\n * - which is what we're doing in Library.importLibrary()).\r\n *\r\n * If supplied promise is rejected with AbortError, we swallow it and\r\n * do not update the library.\r\n */\n libraryItems) => {\n const task = new Promise(async (resolve, reject) => {\n try {\n await this.getLastUpdateTask();\n\n if (typeof libraryItems === \"function\") {\n libraryItems = libraryItems(this.currLibraryItems);\n }\n\n this.currLibraryItems = cloneLibraryItems(await libraryItems);\n resolve(this.currLibraryItems);\n } catch (error) {\n reject(error);\n }\n }).catch(error => {\n if (error.name === \"AbortError\") {\n console.warn(\"Library update aborted by user\");\n return this.currLibraryItems;\n }\n\n throw error;\n }).finally(() => {\n this.updateQueue = this.updateQueue.filter(_task => _task !== task);\n this.notifyListeners();\n });\n this.updateQueue.push(task);\n this.notifyListeners();\n return task;\n };\n\n this.app = app;\n }\n\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Library);\nconst distributeLibraryItemsOnSquareGrid = libraryItems => {\n const PADDING = 50;\n const ITEMS_PER_ROW = Math.ceil(Math.sqrt(libraryItems.length));\n const resElements = [];\n\n const getMaxHeightPerRow = row => {\n const maxHeight = libraryItems.slice(row * ITEMS_PER_ROW, row * ITEMS_PER_ROW + ITEMS_PER_ROW).reduce((acc, item) => {\n const {\n height\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBoundingBox)(item.elements);\n return Math.max(acc, height);\n }, 0);\n return maxHeight;\n };\n\n const getMaxWidthPerCol = targetCol => {\n let index = 0;\n let currCol = 0;\n let maxWidth = 0;\n\n for (const item of libraryItems) {\n if (index % ITEMS_PER_ROW === 0) {\n currCol = 0;\n }\n\n if (currCol === targetCol) {\n const {\n width\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBoundingBox)(item.elements);\n maxWidth = Math.max(maxWidth, width);\n }\n\n index++;\n currCol++;\n }\n\n return maxWidth;\n };\n\n let colOffsetX = 0;\n let rowOffsetY = 0;\n let maxHeightCurrRow = 0;\n let maxWidthCurrCol = 0;\n let index = 0;\n let col = 0;\n let row = 0;\n\n for (const item of libraryItems) {\n if (index && index % ITEMS_PER_ROW === 0) {\n rowOffsetY += maxHeightCurrRow + PADDING;\n colOffsetX = 0;\n col = 0;\n row++;\n }\n\n if (col === 0) {\n maxHeightCurrRow = getMaxHeightPerRow(row);\n }\n\n maxWidthCurrCol = getMaxWidthPerCol(col);\n const {\n minX,\n minY,\n width,\n height\n } = (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.getCommonBoundingBox)(item.elements);\n const offsetCenterX = (maxWidthCurrCol - width) / 2;\n const offsetCenterY = (maxHeightCurrRow - height) / 2;\n resElements.push( // eslint-disable-next-line no-loop-func\n ...item.elements.map(element => Object.assign(Object.assign({}, element), {\n x: element.x + // offset for column\n colOffsetX + // offset to center in given square grid\n offsetCenterX - // subtract minX so that given item starts at 0 coord\n minX,\n y: element.y + // offset for row\n rowOffsetY + // offset to center in given square grid\n offsetCenterY - // subtract minY so that given item starts at 0 coord\n minY\n })));\n colOffsetX += maxWidthCurrCol + PADDING;\n index++;\n col++;\n }\n\n return resElements;\n};\nconst validateLibraryUrl = (libraryUrl,\n/**\r\n * @returns `true` if the URL is valid, throws otherwise.\r\n */\nvalidator = ALLOWED_LIBRARY_URLS) => {\n if (typeof validator === \"function\" ? validator(libraryUrl) : validator.some(allowedUrlDef => {\n const allowedUrl = new URL(`https://${allowedUrlDef.replace(/^https?:\\/\\//, \"\")}`);\n const {\n hostname,\n pathname\n } = new URL(libraryUrl);\n return new RegExp(`(^|\\\\.)${allowedUrl.hostname}$`).test(hostname) && new RegExp(`^${allowedUrl.pathname.replace(/\\/+$/, \"\")}(/+|$)`).test(pathname);\n })) {\n return true;\n }\n\n throw new Error(`Invalid or disallowed library URL: \"${libraryUrl}\"`);\n};\nconst parseLibraryTokensFromUrl = () => {\n const libraryUrl = // current\n new URLSearchParams(window.location.hash.slice(1)).get(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_HASH_KEYS.addLibrary) || // legacy, kept for compat reasons\n new URLSearchParams(window.location.search).get(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_QUERY_KEYS.addLibrary);\n const idToken = libraryUrl ? new URLSearchParams(window.location.hash.slice(1)).get(\"token\") : null;\n return libraryUrl ? {\n libraryUrl,\n idToken\n } : null;\n};\n\nclass AdapterTransaction {\n static async getLibraryItems(adapter, source, _queue = true) {\n const task = () => new Promise(async (resolve, reject) => {\n try {\n const data = await adapter.load({\n source\n });\n resolve((0,_restore__WEBPACK_IMPORTED_MODULE_8__.restoreLibraryItems)((data === null || data === void 0 ? void 0 : data.libraryItems) || [], \"published\"));\n } catch (error) {\n reject(error);\n }\n });\n\n if (_queue) {\n return AdapterTransaction.queue.push(task);\n }\n\n return task();\n }\n\n constructor(adapter) {\n this.adapter = adapter;\n }\n\n getLibraryItems(source) {\n return AdapterTransaction.getLibraryItems(this.adapter, source, false);\n }\n\n}\n\n_a = AdapterTransaction;\nAdapterTransaction.queue = new _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.Queue();\n\nAdapterTransaction.run = async (adapter, fn) => {\n const transaction = new AdapterTransaction(adapter);\n return AdapterTransaction.queue.push(() => fn(transaction));\n};\n\nlet lastSavedLibraryItemsHash = 0;\nlet librarySaveCounter = 0;\n\nconst getLibraryItemHash = item => {\n return `${item.id}:${item.name || \"\"}:${(0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.hashElementsVersion)(item.elements)}`;\n};\n\nconst getLibraryItemsHash = items => {\n return (0,_excalidraw_element__WEBPACK_IMPORTED_MODULE_2__.hashString)(items.map(item => getLibraryItemHash(item)).sort().join());\n};\n\nconst persistLibraryUpdate = async (adapter, update) => {\n try {\n librarySaveCounter++;\n return await AdapterTransaction.run(adapter, async transaction => {\n const nextLibraryItemsMap = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.arrayToMap)(await transaction.getLibraryItems(\"save\"));\n\n for (const [id] of update.deletedItems) {\n nextLibraryItemsMap.delete(id);\n }\n\n const addedItems = []; // we want to merge current library items with the ones stored in the\n // DB so that we don't lose any elements that for some reason aren't\n // in the current editor library, which could happen when:\n //\n // 1. we haven't received an update deleting some elements\n // (in which case it's still better to keep them in the DB lest\n // it was due to a different reason)\n // 2. we keep a single DB for all active editors, but the editors'\n // libraries aren't synced or there's a race conditions during\n // syncing\n // 3. some other race condition, e.g. during init where emit updates\n // for partial updates (e.g. you install a 3rd party library and\n // init from DB only after — we emit events for both updates)\n\n for (const [id, item] of update.addedItems) {\n if (nextLibraryItemsMap.has(id)) {\n // replace item with latest version\n // TODO we could prefer the newer item instead\n nextLibraryItemsMap.set(id, item);\n } else {\n // we want to prepend the new items with the ones that are already\n // in DB to preserve the ordering we do in editor (newly added\n // items are added to the beginning)\n addedItems.push(item);\n }\n } // replace existing items with their updated versions\n\n\n if (update.updatedItems) {\n for (const [id, item] of update.updatedItems) {\n nextLibraryItemsMap.set(id, item);\n }\n }\n\n const nextLibraryItems = addedItems.concat(Array.from(nextLibraryItemsMap.values()));\n const version = getLibraryItemsHash(nextLibraryItems);\n\n if (version !== lastSavedLibraryItemsHash) {\n await adapter.save({\n libraryItems: nextLibraryItems\n });\n }\n\n lastSavedLibraryItemsHash = version;\n return nextLibraryItems;\n });\n } finally {\n librarySaveCounter--;\n }\n};\n\nconst useHandleLibrary = opts => {\n const {\n excalidrawAPI\n } = opts;\n const optsRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(opts);\n optsRef.current = opts;\n const isLibraryLoadedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n if (!excalidrawAPI) {\n return;\n } // reset on editor remount (excalidrawAPI changed)\n\n\n isLibraryLoadedRef.current = false;\n\n const importLibraryFromURL = async ({\n libraryUrl,\n idToken\n }) => {\n const libraryPromise = new Promise(async (resolve, reject) => {\n try {\n libraryUrl = decodeURIComponent(libraryUrl);\n libraryUrl = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.toValidURL)(libraryUrl);\n validateLibraryUrl(libraryUrl, optsRef.current.validateLibraryUrl);\n const request = await fetch(libraryUrl);\n const blob = await request.blob();\n resolve(blob);\n } catch (error) {\n reject(error);\n }\n });\n const shouldPrompt = idToken !== excalidrawAPI.id; // wait for the tab to be focused before continuing in case we'll prompt\n // for confirmation\n\n await (shouldPrompt && document.hidden ? new Promise(resolve => {\n window.addEventListener(\"focus\", () => resolve(), {\n once: true\n });\n }) : null);\n\n try {\n await excalidrawAPI.updateLibrary({\n libraryItems: libraryPromise,\n prompt: shouldPrompt,\n merge: true,\n defaultStatus: \"published\",\n openLibraryMenu: true\n });\n } catch (error) {\n excalidrawAPI.updateScene({\n appState: {\n errorMessage: error.message\n }\n });\n throw error;\n } finally {\n if (window.location.hash.includes(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_HASH_KEYS.addLibrary)) {\n const hash = new URLSearchParams(window.location.hash.slice(1));\n hash.delete(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_HASH_KEYS.addLibrary);\n window.history.replaceState({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.APP_NAME, `#${hash.toString()}`);\n } else if (window.location.search.includes(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_QUERY_KEYS.addLibrary)) {\n const query = new URLSearchParams(window.location.search);\n query.delete(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.URL_QUERY_KEYS.addLibrary);\n window.history.replaceState({}, _excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.APP_NAME, `?${query.toString()}`);\n }\n }\n };\n\n const onHashChange = event => {\n event.preventDefault();\n const libraryUrlTokens = parseLibraryTokensFromUrl();\n\n if (libraryUrlTokens) {\n event.stopImmediatePropagation(); // If hash changed and it contains library url, import it and replace\n // the url to its previous state (important in case of collaboration\n // and similar).\n // Using history API won't trigger another hashchange.\n\n window.history.replaceState({}, \"\", event.oldURL);\n importLibraryFromURL(libraryUrlTokens);\n }\n }; // -------------------------------------------------------------------------\n // ---------------------------------- init ---------------------------------\n // -------------------------------------------------------------------------\n\n\n const libraryUrlTokens = parseLibraryTokensFromUrl();\n\n if (libraryUrlTokens) {\n importLibraryFromURL(libraryUrlTokens);\n } // ------ (A) init load (legacy) -------------------------------------------\n\n\n if (\"getInitialLibraryItems\" in optsRef.current && optsRef.current.getInitialLibraryItems) {\n console.warn(\"useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead.\");\n Promise.resolve(optsRef.current.getInitialLibraryItems()).then(libraryItems => {\n excalidrawAPI.updateLibrary({\n libraryItems,\n // merge with current library items because we may have already\n // populated it (e.g. by installing 3rd party library which can\n // happen before the DB data is loaded)\n merge: true\n });\n }).catch(error => {\n console.error(`UseHandeLibrary getInitialLibraryItems failed: ${error === null || error === void 0 ? void 0 : error.message}`);\n });\n } // -------------------------------------------------------------------------\n // --------------------------------------------------------- init load -----\n // -------------------------------------------------------------------------\n // ------ (B) data source adapter ------------------------------------------\n\n\n if (\"adapter\" in optsRef.current && optsRef.current.adapter) {\n const adapter = optsRef.current.adapter;\n const migrationAdapter = optsRef.current.migrationAdapter;\n const initDataPromise = (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.resolvablePromise)(); // migrate from old data source if needed\n // (note, if `migrate` function is defined, we always migrate even\n // if the data has already been migrated. In that case it'll be a no-op,\n // though with several unnecessary steps — we will still load latest\n // DB data during the `persistLibraryChange()` step)\n // -----------------------------------------------------------------------\n\n if (migrationAdapter) {\n initDataPromise.resolve((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.promiseTry)(migrationAdapter.load).then(async libraryData => {\n let restoredData = null;\n\n try {\n // if no library data to migrate, assume no migration needed\n // and skip persisting to new data store, as well as well\n // clearing the old store via `migrationAdapter.clear()`\n if (!libraryData) {\n return AdapterTransaction.getLibraryItems(adapter, \"load\");\n }\n\n restoredData = (0,_restore__WEBPACK_IMPORTED_MODULE_8__.restoreLibraryItems)(libraryData.libraryItems || [], \"published\"); // we don't queue this operation because it's running inside\n // a promise that's running inside Library update queue itself\n\n const nextItems = await persistLibraryUpdate(adapter, createLibraryUpdate([], restoredData));\n\n try {\n await migrationAdapter.clear();\n } catch (error) {\n console.error(`couldn't delete legacy library data: ${error.message}`);\n } // migration suceeded, load migrated data\n\n\n return nextItems;\n } catch (error) {\n console.error(`couldn't migrate legacy library data: ${error.message}`); // migration failed, load data from previous store, if any\n\n return restoredData;\n }\n }) // errors caught during `migrationAdapter.load()`\n .catch(error => {\n console.error(`error during library migration: ${error.message}`); // as a default, load latest library from current data source\n\n return AdapterTransaction.getLibraryItems(adapter, \"load\");\n }));\n } else {\n initDataPromise.resolve((0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.promiseTry)(AdapterTransaction.getLibraryItems, adapter, \"load\"));\n } // load initial (or migrated) library\n\n\n excalidrawAPI.updateLibrary({\n libraryItems: initDataPromise.then(libraryItems => {\n const _libraryItems = libraryItems || [];\n\n lastSavedLibraryItemsHash = getLibraryItemsHash(_libraryItems);\n return _libraryItems;\n }),\n // merge with current library items because we may have already\n // populated it (e.g. by installing 3rd party library which can\n // happen before the DB data is loaded)\n merge: true\n }).finally(() => {\n isLibraryLoadedRef.current = true;\n });\n } // ---------------------------------------------- data source datapter -----\n\n\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.EVENT.HASHCHANGE, onHashChange);\n return () => {\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.EVENT.HASHCHANGE, onHashChange);\n };\n }, [// important this useEffect only depends on excalidrawAPI so it only reruns\n // on editor remounts (the excalidrawAPI changes)\n excalidrawAPI]); // This effect is run without excalidrawAPI dependency so that host apps\n // can run this hook outside of an active editor instance and the library\n // update queue/loop survives editor remounts\n //\n // This effect is still only meant to be run if host apps supply an persitence\n // adapter. If we don't have access to it, it the update listener doesn't\n // do anything.\n\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {\n // on update, merge with current library items and persist\n // -----------------------------------------------------------------------\n const unsubOnLibraryUpdate = onLibraryUpdateEmitter.on(async (update, nextLibraryItems) => {\n const isLoaded = isLibraryLoadedRef.current; // we want to operate with the latest adapter, but we don't want this\n // effect to rerun on every adapter change in case host apps' adapter\n // isn't stable\n\n const adapter = \"adapter\" in optsRef.current && optsRef.current.adapter || null;\n\n try {\n if (adapter) {\n if ( // if nextLibraryItems hash identical to previously saved hash,\n // exit early, even if actual upstream state ends up being\n // different (e.g. has more data than we have locally), as it'd\n // be low-impact scenario.\n lastSavedLibraryItemsHash !== getLibraryItemsHash(nextLibraryItems)) {\n await persistLibraryUpdate(adapter, update);\n }\n }\n } catch (error) {\n console.error(`couldn't persist library update: ${error.message}`, update); // currently we only show error if an editor is loaded\n\n if (isLoaded && optsRef.current.excalidrawAPI) {\n optsRef.current.excalidrawAPI.updateScene({\n appState: {\n errorMessage: (0,_i18n__WEBPACK_IMPORTED_MODULE_6__.t)(\"errors.saveLibraryError\")\n }\n });\n }\n }\n });\n\n const onUnload = event => {\n if (librarySaveCounter) {\n (0,_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.preventUnload)(event);\n }\n };\n\n window.addEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.EVENT.BEFORE_UNLOAD, onUnload);\n return () => {\n window.removeEventListener(_excalidraw_common__WEBPACK_IMPORTED_MODULE_1__.EVENT.BEFORE_UNLOAD, onUnload);\n unsubOnLibraryUpdate();\n lastSavedLibraryItemsHash = 0;\n librarySaveCounter = 0;\n };\n }, [// this effect must not have any deps so it doesn't rerun\n ]);\n};\n\n//# sourceURL=webpack://ExcalidrawLib/./data/library.ts?");
16879
16879
 
16880
16880
  /***/ }),
16881
16881
 
@@ -19976,7 +19976,7 @@ eval("module.exports = /*#__PURE__*/JSON.parse('{\"labels\":{\"paste\":\"Επι
19976
19976
  /***/ ((module) => {
19977
19977
 
19978
19978
  "use strict";
19979
- eval("module.exports = /*#__PURE__*/JSON.parse('{\"labels\":{\"laser\":\"Toggle laser pointer\",\"paste\":\"Paste\",\"pasteAsPlaintext\":\"Paste as plaintext\",\"pasteCharts\":\"Paste charts\",\"selectAll\":\"Select all\",\"multiSelect\":\"Add element to selection\",\"moveCanvas\":\"Move canvas\",\"cut\":\"Cut\",\"copy\":\"Copy\",\"copyAsPng\":\"Copy to clipboard as PNG\",\"copyAsSvg\":\"Copy to clipboard as SVG\",\"copyText\":\"Copy to clipboard as text\",\"copySource\":\"Copy source to clipboard\",\"convertToCode\":\"Convert to code\",\"bringForward\":\"Bring forward\",\"sendToBack\":\"Send to back\",\"bringToFront\":\"Bring to front\",\"sendBackward\":\"Send backward\",\"delete\":\"Delete\",\"copyStyles\":\"Copy styles\",\"pasteStyles\":\"Paste styles\",\"stroke\":\"Stroke\",\"changeStroke\":\"Change stroke color\",\"background\":\"Background\",\"changeBackground\":\"Change background color\",\"fill\":\"Fill\",\"strokeWidth\":\"Stroke width\",\"strokeStyle\":\"Stroke style\",\"strokeStyle_solid\":\"Solid\",\"strokeStyle_dashed\":\"Dashed\",\"strokeStyle_dotted\":\"Dotted\",\"sloppiness\":\"Sloppiness\",\"opacity\":\"Opacity\",\"textAlign\":\"Text align\",\"edges\":\"Edges\",\"sharp\":\"Sharp\",\"round\":\"Round\",\"arrowheads\":\"Arrowheads\",\"arrowhead_none\":\"None\",\"arrowhead_arrow\":\"Arrow\",\"arrowhead_bar\":\"Bar\",\"arrowhead_dot\":\"Dot\",\"arrowhead_circle\":\"Circle\",\"arrowhead_circle_outline\":\"Circle (outline)\",\"arrowhead_triangle\":\"Triangle\",\"arrowhead_triangle_outline\":\"Triangle (outline)\",\"arrowhead_diamond\":\"Diamond\",\"arrowhead_diamond_outline\":\"Diamond (outline)\",\"arrowhead_crowfoot_many\":\"Crow\\'s foot (many)\",\"arrowhead_crowfoot_one\":\"Crow\\'s foot (one)\",\"arrowhead_crowfoot_one_or_many\":\"Crow\\'s foot (one or many)\",\"more_options\":\"More options\",\"arrowtypes\":\"Arrow type\",\"arrowtype_sharp\":\"Sharp arrow\",\"arrowtype_round\":\"Curved arrow\",\"arrowtype_elbowed\":\"Elbow arrow\",\"fontSize\":\"Font size\",\"fontFamily\":\"Font family\",\"addWatermark\":\"Add \\\\\"Made with Excalidraw\\\\\"\",\"handDrawn\":\"Hand-drawn\",\"normal\":\"Normal\",\"code\":\"Code\",\"localFont\":\"Local Font\",\"small\":\"Small\",\"medium\":\"Medium\",\"large\":\"Large\",\"veryLarge\":\"Very large\",\"solid\":\"Solid\",\"hachure\":\"Hachure\",\"zigzag\":\"Zigzag\",\"crossHatch\":\"Cross-hatch\",\"extraThin\":\"Extra thin\",\"thin\":\"Thin\",\"bold\":\"Bold\",\"left\":\"Left\",\"center\":\"Center\",\"right\":\"Right\",\"extraBold\":\"Extra bold\",\"architect\":\"Architect\",\"artist\":\"Artist\",\"cartoonist\":\"Cartoonist\",\"fileTitle\":\"File name\",\"colorPicker\":\"Color picker\",\"canvasColors\":\"Used on canvas\",\"canvasBackground\":\"Canvas background\",\"drawingCanvas\":\"Drawing canvas\",\"clearCanvas\":\"Clear canvas\",\"layers\":\"Layers\",\"actions\":\"Actions\",\"language\":\"Language\",\"liveCollaboration\":\"Live collaboration...\",\"duplicateSelection\":\"Duplicate\",\"untitled\":\"Untitled\",\"name\":\"Name\",\"yourName\":\"Your name\",\"madeWithExcalidraw\":\"Made with Excalidraw\",\"group\":\"Group selection\",\"ungroup\":\"Ungroup selection\",\"collaborators\":\"Collaborators\",\"toggleGrid\":\"Toggle grid\",\"addToLibrary\":\"Add to library\",\"removeFromLibrary\":\"Remove from library\",\"libraryLoadingMessage\":\"Loading library…\",\"libraries\":\"Browse libraries\",\"loadingScene\":\"Loading scene…\",\"loadScene\":\"Load scene from file\",\"align\":\"Align\",\"alignTop\":\"Align top\",\"alignBottom\":\"Align bottom\",\"alignLeft\":\"Align left\",\"alignRight\":\"Align right\",\"centerVertically\":\"Center vertically\",\"centerHorizontally\":\"Center horizontally\",\"distributeHorizontally\":\"Distribute horizontally\",\"distributeVertically\":\"Distribute vertically\",\"flipHorizontal\":\"Flip horizontal\",\"flipVertical\":\"Flip vertical\",\"viewMode\":\"View mode\",\"share\":\"Share\",\"showStroke\":\"Show stroke color picker\",\"showBackground\":\"Show background color picker\",\"showFonts\":\"Show font picker\",\"toggleTheme\":\"Toggle light/dark theme\",\"theme\":\"Theme\",\"personalLib\":\"Personal Library\",\"excalidrawLib\":\"Excalidraw Library\",\"decreaseFontSize\":\"Decrease font size\",\"increaseFontSize\":\"Increase font size\",\"unbindText\":\"Unbind text\",\"bindText\":\"Bind text to the container\",\"createContainerFromText\":\"Wrap text in a container\",\"link\":{\"edit\":\"Edit link\",\"editEmbed\":\"Edit embeddable link\",\"create\":\"Add link\",\"label\":\"Link\",\"labelEmbed\":\"Link & embed\",\"empty\":\"No link is set\",\"hint\":\"Type or paste your link here\",\"goToElement\":\"Go to target element\"},\"lineEditor\":{\"edit\":\"Edit line\",\"editArrow\":\"Edit arrow\"},\"polygon\":{\"breakPolygon\":\"Break polygon\",\"convertToPolygon\":\"Convert to polygon\"},\"elementLock\":{\"lock\":\"Lock\",\"unlock\":\"Unlock\",\"lockAll\":\"Lock all\",\"unlockAll\":\"Unlock all\"},\"statusPublished\":\"Published\",\"sidebarLock\":\"Keep sidebar open\",\"selectAllElementsInFrame\":\"Select all elements in frame\",\"removeAllElementsFromFrame\":\"Remove all elements from frame\",\"eyeDropper\":\"Pick color from canvas\",\"textToDiagram\":\"Text to diagram\",\"prompt\":\"Prompt\",\"followUs\":\"Follow us\",\"discordChat\":\"Discord chat\",\"zoomToFitViewport\":\"Zoom to fit in viewport\",\"zoomToFitSelection\":\"Zoom to fit selection\",\"zoomToFit\":\"Zoom to fit all elements\",\"installPWA\":\"Install Excalidraw locally (PWA)\",\"autoResize\":\"Enable text auto-resizing\",\"imageCropping\":\"Image cropping\",\"unCroppedDimension\":\"Uncropped dimension\",\"copyElementLink\":\"Copy link to object\",\"linkToElement\":\"Link to object\",\"wrapSelectionInFrame\":\"Wrap selection in frame\",\"tab\":\"Tab\",\"shapeSwitch\":\"Switch shape\",\"toggleFrameRole\":\"Toggle frame role\"},\"elementLink\":{\"title\":\"Link to object\",\"desc\":\"Click on a shape on canvas or paste a link.\",\"notFound\":\"Linked object wasn\\'t found on canvas.\"},\"library\":{\"noItems\":\"No items added yet...\",\"hint_emptyLibrary\":\"Select an item on canvas to add it here, or install a library from the public repository, below.\",\"hint_emptyPrivateLibrary\":\"Select an item on canvas to add it here.\",\"search\":{\"inputPlaceholder\":\"Search library\",\"heading\":\"Library matches\",\"noResults\":\"No matching items found...\",\"clearSearch\":\"Clear search\"}},\"search\":{\"title\":\"Find on canvas\",\"noMatch\":\"No matches found...\",\"singleResult\":\"result\",\"multipleResults\":\"results\",\"placeholder\":\"Find text on canvas...\",\"frames\":\"Frames\",\"texts\":\"Texts\"},\"buttons\":{\"clearReset\":\"Reset the canvas\",\"exportJSON\":\"Export to file\",\"exportImage\":\"Export image...\",\"export\":\"Save to...\",\"copyToClipboard\":\"Copy to clipboard\",\"copyLink\":\"Copy link\",\"save\":\"Save to current file\",\"saveAs\":\"Save as\",\"load\":\"Open\",\"getShareableLink\":\"Get shareable link\",\"close\":\"Close\",\"selectLanguage\":\"Select language\",\"scrollBackToContent\":\"Scroll back to content\",\"zoomIn\":\"Zoom in\",\"zoomOut\":\"Zoom out\",\"resetZoom\":\"Reset zoom\",\"menu\":\"Menu\",\"done\":\"Done\",\"edit\":\"Edit\",\"undo\":\"Undo\",\"redo\":\"Redo\",\"resetLibrary\":\"Reset library\",\"createNewRoom\":\"Create new room\",\"fullScreen\":\"Full screen\",\"darkMode\":\"Dark mode\",\"lightMode\":\"Light mode\",\"systemMode\":\"System mode\",\"zenMode\":\"Zen mode\",\"objectsSnapMode\":\"Snap to objects\",\"exitZenMode\":\"Exit zen mode\",\"cancel\":\"Cancel\",\"saveLibNames\":\"Save name(s) and exit\",\"clear\":\"Clear\",\"remove\":\"Remove\",\"embed\":\"Toggle embedding\",\"publishLibrary\":\"Rename or publish\",\"submit\":\"Submit\",\"confirm\":\"Confirm\",\"embeddableInteractionButton\":\"Click to interact\"},\"alerts\":{\"clearReset\":\"This will clear the whole canvas. Are you sure?\",\"couldNotCreateShareableLink\":\"Couldn\\'t create shareable link.\",\"couldNotCreateShareableLinkTooBig\":\"Couldn\\'t create shareable link: the scene is too big\",\"couldNotLoadInvalidFile\":\"Couldn\\'t load invalid file\",\"importBackendFailed\":\"Importing from backend failed.\",\"cannotExportEmptyCanvas\":\"Cannot export empty canvas.\",\"couldNotCopyToClipboard\":\"Couldn\\'t copy to clipboard.\",\"decryptFailed\":\"Couldn\\'t decrypt data.\",\"uploadedSecurly\":\"The upload has been secured with end-to-end encryption, which means that Excalidraw server and third parties can\\'t read the content.\",\"loadSceneOverridePrompt\":\"Loading external drawing will replace your existing content. Do you wish to continue?\",\"collabStopOverridePrompt\":\"Stopping the session will overwrite your previous, locally stored drawing. Are you sure?\\\\n\\\\n(If you want to keep your local drawing, simply close the browser tab instead.)\",\"errorAddingToLibrary\":\"Couldn\\'t add item to the library\",\"errorRemovingFromLibrary\":\"Couldn\\'t remove item from the library\",\"confirmAddLibrary\":\"This will add {{numShapes}} shape(s) to your library. Are you sure?\",\"imageDoesNotContainScene\":\"This image does not seem to contain any scene data. Have you enabled scene embedding during export?\",\"cannotRestoreFromImage\":\"Scene couldn\\'t be restored from this image file\",\"invalidSceneUrl\":\"Couldn\\'t import scene from the supplied URL. It\\'s either malformed, or doesn\\'t contain valid Excalidraw JSON data.\",\"resetLibrary\":\"This will clear your library. Are you sure?\",\"removeItemsFromsLibrary\":\"Delete {{count}} item(s) from library?\",\"invalidEncryptionKey\":\"Encryption key must be of 22 characters. Live collaboration is disabled.\",\"collabOfflineWarning\":\"No internet connection available.\\\\nYour changes will not be saved!\"},\"errors\":{\"unsupportedFileType\":\"Unsupported file type.\",\"imageInsertError\":\"Couldn\\'t insert image. Try again later...\",\"fileTooBig\":\"File is too big. Maximum allowed size is {{maxSize}}.\",\"svgImageInsertError\":\"Couldn\\'t insert SVG image. The SVG markup looks invalid.\",\"failedToFetchImage\":\"Failed to fetch image.\",\"cannotResolveCollabServer\":\"Couldn\\'t connect to the collab server. Please reload the page and try again.\",\"importLibraryError\":\"Couldn\\'t load library\",\"saveLibraryError\":\"Couldn\\'t save library to storage. Please save your library to a file locally to make sure you don\\'t lose changes.\",\"collabSaveFailed\":\"Couldn\\'t save to the backend database. If problems persist, you should save your file locally to ensure you don\\'t lose your work.\",\"collabSaveFailed_sizeExceeded\":\"Couldn\\'t save to the backend database, the canvas seems to be too big. You should save the file locally to ensure you don\\'t lose your work.\",\"imageToolNotSupported\":\"Images are disabled.\",\"brave_measure_text_error\":{\"line1\":\"Looks like you are using Brave browser with the <bold>Aggressively Block Fingerprinting</bold> setting enabled.\",\"line2\":\"This could result in breaking the <bold>Text Elements</bold> in your drawings.\",\"line3\":\"We strongly recommend disabling this setting. You can follow <link>these steps</link> on how to do so.\",\"line4\":\"If disabling this setting doesn\\'t fix the display of text elements, please open an <issueLink>issue</issueLink> on our GitHub, or write us on <discordLink>Discord</discordLink>\"},\"libraryElementTypeError\":{\"embeddable\":\"Embeddable elements cannot be added to the library.\",\"iframe\":\"IFrame elements cannot be added to the library.\",\"image\":\"Support for adding images to the library coming soon!\"},\"asyncPasteFailedOnRead\":\"Couldn\\'t paste (couldn\\'t read from system clipboard).\",\"asyncPasteFailedOnParse\":\"Couldn\\'t paste.\",\"copyToSystemClipboardFailed\":\"Couldn\\'t copy to clipboard.\"},\"toolBar\":{\"selection\":\"Selection\",\"lasso\":\"Lasso selection\",\"image\":\"Insert image\",\"rectangle\":\"Rectangle\",\"diamond\":\"Diamond\",\"ellipse\":\"Ellipse\",\"arrow\":\"Arrow\",\"line\":\"Line\",\"freedraw\":\"Draw\",\"text\":\"Text\",\"library\":\"Library\",\"lock\":\"Keep selected tool active after drawing\",\"penMode\":\"Pen mode - prevent touch\",\"link\":\"Add / Update link for a selected shape\",\"eraser\":\"Eraser\",\"frame\":\"Frame tool\",\"magicframe\":\"Wireframe to code\",\"embeddable\":\"Web Embed\",\"laser\":\"Laser pointer\",\"hand\":\"Hand (panning tool)\",\"extraTools\":\"More tools\",\"mermaidToExcalidraw\":\"Mermaid to Excalidraw\",\"convertElementType\":\"Toggle shape type\"},\"element\":{\"rectangle\":\"Rectangle\",\"diamond\":\"Diamond\",\"ellipse\":\"Ellipse\",\"arrow\":\"Arrow\",\"line\":\"Line\",\"freedraw\":\"Freedraw\",\"text\":\"Text\",\"image\":\"Image\",\"group\":\"Group\",\"frame\":\"Frame\",\"magicframe\":\"Wireframe to code\",\"embeddable\":\"Web Embed\",\"selection\":\"Selection\",\"iframe\":\"IFrame\"},\"headings\":{\"canvasActions\":\"Canvas actions\",\"selectedShapeActions\":\"Selected shape actions\",\"shapes\":\"Shapes\"},\"hints\":{\"dismissSearch\":\"Escape to dismiss search\",\"canvasPanning\":\"To move canvas, hold mouse wheel or spacebar while dragging, or use the hand tool\",\"linearElement\":\"Click to start multiple points, drag for single line\",\"arrowTool\":\"Click to start multiple points, drag for single line. Press {{arrowShortcut}} again to change arrow type.\",\"freeDraw\":\"Click and drag, release when you\\'re finished\",\"text\":\"Tip: you can also add text by double-clicking anywhere with the selection tool\",\"embeddable\":\"Click-drag to create a website embed\",\"text_selected\":\"Double-click or press ENTER to edit text\",\"text_editing\":\"Press Escape or CtrlOrCmd+ENTER to finish editing\",\"linearElementMulti\":\"Click on last point or press Escape or Enter to finish\",\"lockAngle\":\"You can constrain angle by holding SHIFT\",\"resize\":\"You can constrain proportions by holding SHIFT while resizing,\\\\nhold ALT to resize from the center\",\"resizeImage\":\"You can resize freely by holding SHIFT,\\\\nhold ALT to resize from the center\",\"rotate\":\"You can constrain angles by holding SHIFT while rotating\",\"lineEditor_info\":\"Hold CtrlOrCmd and Double-click or press CtrlOrCmd + Enter to edit points\",\"lineEditor_line_info\":\"Double-click or press Enter to edit points\",\"lineEditor_pointSelected\":\"Press Delete to remove point(s),\\\\nCtrlOrCmd+D to duplicate, or drag to move\",\"lineEditor_nothingSelected\":\"Select a point to edit (hold SHIFT to select multiple),\\\\nor hold Alt and click to add new points\",\"publishLibrary\":\"Publish your own library\",\"bindTextToElement\":\"Press enter to add text\",\"createFlowchart\":\"Hold CtrlOrCmd and Arrow key to create a flowchart\",\"deepBoxSelect\":\"Hold CtrlOrCmd to deep select, and to prevent dragging\",\"eraserRevert\":\"Hold Alt to revert the elements marked for deletion\",\"firefox_clipboard_write\":\"This feature can likely be enabled by setting the \\\\\"dom.events.asyncClipboard.clipboardItem\\\\\" flag to \\\\\"true\\\\\". To change the browser flags in Firefox, visit the \\\\\"about:config\\\\\" page.\",\"disableSnapping\":\"Hold CtrlOrCmd to disable snapping\",\"enterCropEditor\":\"Double click the image or press ENTER to crop the image\",\"leaveCropEditor\":\"Click outside the image or press ENTER or ESCAPE to finish cropping\"},\"canvasError\":{\"cannotShowPreview\":\"Cannot show preview\",\"canvasTooBig\":\"The canvas may be too big.\",\"canvasTooBigTip\":\"Tip: try moving the farthest elements a bit closer together.\"},\"errorSplash\":{\"headingMain\":\"Encountered an error. Try <button>reloading the page</button>.\",\"clearCanvasMessage\":\"If reloading doesn\\'t work, try <button>clearing the canvas</button>.\",\"clearCanvasCaveat\":\" This will result in loss of work \",\"trackedToSentry\":\"The error with identifier {{eventId}} was tracked on our system.\",\"openIssueMessage\":\"We were very cautious not to include your scene information on the error. If your scene is not private, please consider following up on our <button>bug tracker</button>. Please include information below by copying and pasting into the GitHub issue.\",\"sceneContent\":\"Scene content:\"},\"shareDialog\":{\"or\":\"Or\"},\"roomDialog\":{\"desc_intro\":\"Invite people to collaborate on your drawing.\",\"desc_privacy\":\"Don\\'t worry, the session is end-to-end encrypted, and fully private. Not even our server can see what you draw.\",\"button_startSession\":\"Start session\",\"button_stopSession\":\"Stop session\",\"desc_inProgressIntro\":\"Live-collaboration session is now in progress.\",\"desc_shareLink\":\"Share this link with anyone you want to collaborate with:\",\"desc_exitSession\":\"Stopping the session will disconnect you from the room, but you\\'ll be able to continue working with the scene, locally. Note that this won\\'t affect other people, and they\\'ll still be able to collaborate on their version.\",\"shareTitle\":\"Join a live collaboration session on Excalidraw\"},\"errorDialog\":{\"title\":\"Error\"},\"exportDialog\":{\"disk_title\":\"Save to disk\",\"disk_details\":\"Export the scene data to a file from which you can import later.\",\"disk_button\":\"Save to file\",\"link_title\":\"Shareable link\",\"link_details\":\"Export as a read-only link.\",\"link_button\":\"Export to Link\",\"excalidrawplus_description\":\"Save the scene to your Excalidraw+ workspace.\",\"excalidrawplus_button\":\"Export\",\"excalidrawplus_exportError\":\"Couldn\\'t export to Excalidraw+ at this moment...\"},\"helpDialog\":{\"blog\":\"Read our blog\",\"click\":\"click\",\"deepSelect\":\"Deep select\",\"deepBoxSelect\":\"Deep select within box, and prevent dragging\",\"createFlowchart\":\"Create a flowchart from a generic element\",\"navigateFlowchart\":\"Navigate a flowchart\",\"curvedArrow\":\"Curved arrow\",\"curvedLine\":\"Curved line\",\"documentation\":\"Documentation\",\"doubleClick\":\"double-click\",\"drag\":\"drag\",\"editor\":\"Editor\",\"editLineArrowPoints\":\"Edit line/arrow points\",\"editText\":\"Edit text / add label\",\"github\":\"Found an issue? Submit\",\"howto\":\"Follow our guides\",\"or\":\"or\",\"preventBinding\":\"Prevent arrow binding\",\"tools\":\"Tools\",\"shortcuts\":\"Keyboard shortcuts\",\"textFinish\":\"Finish editing (text editor)\",\"textNewLine\":\"Add new line (text editor)\",\"title\":\"Help\",\"view\":\"View\",\"zoomToFit\":\"Zoom to fit all elements\",\"zoomToSelection\":\"Zoom to selection\",\"toggleElementLock\":\"Lock/unlock selection\",\"movePageUpDown\":\"Move page up/down\",\"movePageLeftRight\":\"Move page left/right\",\"cropStart\":\"Crop image\",\"cropFinish\":\"Finish image cropping\"},\"clearCanvasDialog\":{\"title\":\"Clear canvas\"},\"publishDialog\":{\"title\":\"Publish library\",\"itemName\":\"Item name\",\"authorName\":\"Author name\",\"githubUsername\":\"GitHub username\",\"twitterUsername\":\"Twitter username\",\"libraryName\":\"Library name\",\"libraryDesc\":\"Library description\",\"website\":\"Website\",\"placeholder\":{\"authorName\":\"Your name or username\",\"libraryName\":\"Name of your library\",\"libraryDesc\":\"Description of your library to help people understand its usage\",\"githubHandle\":\"GitHub handle (optional), so you can edit the library once submitted for review\",\"twitterHandle\":\"Twitter username (optional), so we know who to credit when promoting over Twitter\",\"website\":\"Link to your personal website or elsewhere (optional)\"},\"errors\":{\"required\":\"Required\",\"website\":\"Enter a valid URL\"},\"noteDescription\":\"Submit your library to be included in the <link>public library repository</link> for other people to use in their drawings.\",\"noteGuidelines\":\"The library needs to be manually approved first. Please read the <link>guidelines</link> before submitting. You will need a GitHub account to communicate and make changes if requested, but it is not strictly required.\",\"noteLicense\":\"By submitting, you agree the library will be published under the <link>MIT License</link>, which in short means anyone can use them without restrictions.\",\"noteItems\":\"Each library item must have its own name so it\\'s filterable. The following library items will be included:\",\"atleastOneLibItem\":\"Please select at least one library item to get started\",\"republishWarning\":\"Note: some of the selected items are marked as already published/submitted. You should only resubmit items when updating an existing library or submission.\"},\"publishSuccessDialog\":{\"title\":\"Library submitted\",\"content\":\"Thank you {{authorName}}. Your library has been submitted for review. You can track the status <link>here</link>\"},\"confirmDialog\":{\"resetLibrary\":\"Reset library\",\"removeItemsFromLib\":\"Remove selected items from library\"},\"imageExportDialog\":{\"header\":\"Export image\",\"label\":{\"withBackground\":\"Background\",\"onlySelected\":\"Only selected\",\"darkMode\":\"Dark mode\",\"embedScene\":\"Embed scene\",\"scale\":\"Scale\",\"padding\":\"Padding\"},\"tooltip\":{\"embedScene\":\"Scene data will be saved into the exported PNG/SVG file so that the scene can be restored from it.\\\\nWill increase exported file size.\"},\"title\":{\"exportToPng\":\"Export to PNG\",\"exportToSvg\":\"Export to SVG\",\"copyPngToClipboard\":\"Copy PNG to clipboard\"},\"button\":{\"exportToPng\":\"PNG\",\"exportToSvg\":\"SVG\",\"copyPngToClipboard\":\"Copy to clipboard\"}},\"encrypted\":{\"tooltip\":\"Your drawings are end-to-end encrypted so Excalidraw\\'s servers will never see them.\",\"link\":\"Blog post on end-to-end encryption in Excalidraw\"},\"stats\":{\"angle\":\"Angle\",\"shapes\":\"Shapes\",\"height\":\"Height\",\"scene\":\"Scene\",\"selected\":\"Selected\",\"storage\":\"Storage\",\"fullTitle\":\"Canvas & Shape properties\",\"title\":\"Properties\",\"generalStats\":\"General\",\"elementProperties\":\"Shape properties\",\"total\":\"Total\",\"version\":\"Version\",\"versionCopy\":\"Click to copy\",\"versionNotAvailable\":\"Version not available\",\"width\":\"Width\"},\"toast\":{\"addedToLibrary\":\"Added to library\",\"copyStyles\":\"Copied styles.\",\"copyToClipboard\":\"Copied to clipboard.\",\"copyToClipboardAsPng\":\"Copied {{exportSelection}} to clipboard as PNG\\\\n({{exportColorScheme}})\",\"copyToClipboardAsSvg\":\"Copied {{exportSelection}} to clipboard as SVG\\\\n({{exportColorScheme}})\",\"fileSaved\":\"File saved.\",\"fileSavedToFilename\":\"Saved to {filename}\",\"canvas\":\"canvas\",\"selection\":\"selection\",\"pasteAsSingleElement\":\"Use {{shortcut}} to paste as a single element,\\\\nor paste into an existing text editor\",\"unableToEmbed\":\"Embedding this url is currently not allowed. Raise an issue on GitHub to request the url whitelisted\",\"unrecognizedLinkFormat\":\"The link you embedded does not match the expected format. Please try to paste the \\'embed\\' string provided by the source site\",\"elementLinkCopied\":\"Link copied to clipboard\"},\"colors\":{\"transparent\":\"Transparent\",\"black\":\"Black\",\"white\":\"White\",\"red\":\"Red\",\"pink\":\"Pink\",\"grape\":\"Grape\",\"violet\":\"Violet\",\"gray\":\"Gray\",\"blue\":\"Blue\",\"cyan\":\"Cyan\",\"teal\":\"Teal\",\"green\":\"Green\",\"yellow\":\"Yellow\",\"orange\":\"Orange\",\"bronze\":\"Bronze\"},\"welcomeScreen\":{\"app\":{\"center_heading\":\"All your data is saved locally in your browser.\",\"center_heading_plus\":\"Did you want to go to the Excalidraw+ instead?\",\"menuHint\":\"Export, preferences, languages, ...\"},\"defaults\":{\"menuHint\":\"Export, preferences, and more...\",\"center_heading\":\"Diagrams. Made. Simple.\",\"toolbarHint\":\"Pick a tool & Start drawing!\",\"helpHint\":\"Shortcuts & help\"}},\"colorPicker\":{\"color\":\"Color\",\"mostUsedCustomColors\":\"Most used custom colors\",\"colors\":\"Colors\",\"shades\":\"Shades\",\"hexCode\":\"Hex code\",\"noShades\":\"No shades available for this color\"},\"overwriteConfirm\":{\"action\":{\"exportToImage\":{\"title\":\"Export as image\",\"button\":\"Export as image\",\"description\":\"Export the scene data as an image from which you can import later.\"},\"saveToDisk\":{\"title\":\"Save to disk\",\"button\":\"Save to disk\",\"description\":\"Export the scene data to a file from which you can import later.\"},\"excalidrawPlus\":{\"title\":\"Excalidraw+\",\"button\":\"Export to Excalidraw+\",\"description\":\"Save the scene to your Excalidraw+ workspace.\"}},\"modal\":{\"loadFromFile\":{\"title\":\"Load from file\",\"button\":\"Load from file\",\"description\":\"Loading from a file will <bold>replace your existing content</bold>.<br></br>You can back up your drawing first using one of the options below.\"},\"shareableLink\":{\"title\":\"Load from link\",\"button\":\"Replace my content\",\"description\":\"Loading external drawing will <bold>replace your existing content</bold>.<br></br>You can back up your drawing first by using one of the options below.\"}}},\"mermaid\":{\"title\":\"Mermaid to Excalidraw\",\"button\":\"Insert\",\"description\":\"Currently only <flowchartLink>Flowchart</flowchartLink>,<sequenceLink> Sequence, </sequenceLink> and <classLink>Class </classLink>Diagrams are supported. The other types will be rendered as image in Excalidraw.\",\"syntax\":\"Mermaid Syntax\",\"preview\":\"Preview\"},\"quickSearch\":{\"placeholder\":\"Quick search\"},\"fontList\":{\"badge\":{\"old\":\"old\"},\"sceneFonts\":\"In this scene\",\"availableFonts\":\"Available fonts\",\"empty\":\"No fonts found\"},\"userList\":{\"empty\":\"No users found\",\"hint\":{\"text\":\"Click on user to follow\",\"followStatus\":\"You\\'re currently following this user\",\"inCall\":\"User is in a voice call\",\"micMuted\":\"User\\'s microphone is muted\",\"isSpeaking\":\"User is speaking\"}},\"commandPalette\":{\"title\":\"Command palette\",\"shortcuts\":{\"select\":\"Select\",\"confirm\":\"Confirm\",\"close\":\"Close\"},\"recents\":\"Recently used\",\"search\":{\"placeholder\":\"Search menus, commands, and discover hidden gems\",\"noMatch\":\"No matching commands...\"},\"itemNotAvailable\":\"Command is not available...\",\"shortcutHint\":\"For Command palette, use {{shortcut}}\"}}');\n\n//# sourceURL=webpack://ExcalidrawLib/./locales/en.json?");
19979
+ eval("module.exports = /*#__PURE__*/JSON.parse('{\"labels\":{\"laser\":\"Toggle laser pointer\",\"paste\":\"Paste\",\"pasteAsPlaintext\":\"Paste as plaintext\",\"pasteCharts\":\"Paste charts\",\"selectAll\":\"Select all\",\"multiSelect\":\"Add element to selection\",\"moveCanvas\":\"Move canvas\",\"cut\":\"Cut\",\"copy\":\"Copy\",\"copyAsPng\":\"Copy to clipboard as PNG\",\"copyAsSvg\":\"Copy to clipboard as SVG\",\"copyText\":\"Copy to clipboard as text\",\"copySource\":\"Copy source to clipboard\",\"convertToCode\":\"Convert to code\",\"bringForward\":\"Bring forward\",\"sendToBack\":\"Send to back\",\"bringToFront\":\"Bring to front\",\"sendBackward\":\"Send backward\",\"delete\":\"Delete\",\"copyStyles\":\"Copy styles\",\"pasteStyles\":\"Paste styles\",\"stroke\":\"Stroke\",\"changeStroke\":\"Change stroke color\",\"background\":\"Background\",\"changeBackground\":\"Change background color\",\"fill\":\"Fill\",\"strokeWidth\":\"Stroke width\",\"strokeStyle\":\"Stroke style\",\"strokeStyle_solid\":\"Solid\",\"strokeStyle_dashed\":\"Dashed\",\"strokeStyle_dotted\":\"Dotted\",\"sloppiness\":\"Sloppiness\",\"opacity\":\"Opacity\",\"textAlign\":\"Text align\",\"edges\":\"Edges\",\"sharp\":\"Sharp\",\"round\":\"Round\",\"arrowheads\":\"Arrowheads\",\"arrowhead_none\":\"None\",\"arrowhead_arrow\":\"Arrow\",\"arrowhead_bar\":\"Bar\",\"arrowhead_dot\":\"Dot\",\"arrowhead_circle\":\"Circle\",\"arrowhead_circle_outline\":\"Circle (outline)\",\"arrowhead_triangle\":\"Triangle\",\"arrowhead_triangle_outline\":\"Triangle (outline)\",\"arrowhead_diamond\":\"Diamond\",\"arrowhead_diamond_outline\":\"Diamond (outline)\",\"arrowhead_crowfoot_many\":\"Crow\\'s foot (many)\",\"arrowhead_crowfoot_one\":\"Crow\\'s foot (one)\",\"arrowhead_crowfoot_one_or_many\":\"Crow\\'s foot (one or many)\",\"more_options\":\"More options\",\"arrowtypes\":\"Arrow type\",\"arrowtype_sharp\":\"Sharp arrow\",\"arrowtype_round\":\"Curved arrow\",\"arrowtype_elbowed\":\"Elbow arrow\",\"fontSize\":\"Font size\",\"fontFamily\":\"Font family\",\"addWatermark\":\"Add \\\\\"Made with Excalidraw\\\\\"\",\"handDrawn\":\"Hand-drawn\",\"normal\":\"Normal\",\"code\":\"Code\",\"localFont\":\"Local Font\",\"small\":\"Small\",\"medium\":\"Medium\",\"large\":\"Large\",\"veryLarge\":\"Very large\",\"solid\":\"Solid\",\"hachure\":\"Hachure\",\"zigzag\":\"Zigzag\",\"crossHatch\":\"Cross-hatch\",\"extraThin\":\"Extra thin\",\"thin\":\"Thin\",\"bold\":\"Bold\",\"left\":\"Left\",\"center\":\"Center\",\"right\":\"Right\",\"extraBold\":\"Extra bold\",\"architect\":\"Architect\",\"artist\":\"Artist\",\"cartoonist\":\"Cartoonist\",\"fileTitle\":\"File name\",\"colorPicker\":\"Color picker\",\"canvasColors\":\"Used on canvas\",\"canvasBackground\":\"Canvas background\",\"drawingCanvas\":\"Drawing canvas\",\"clearCanvas\":\"Clear canvas\",\"layers\":\"Layers\",\"actions\":\"Actions\",\"language\":\"Language\",\"liveCollaboration\":\"Live collaboration...\",\"duplicateSelection\":\"Duplicate\",\"untitled\":\"Untitled\",\"name\":\"Name\",\"yourName\":\"Your name\",\"madeWithExcalidraw\":\"Made with Excalidraw\",\"group\":\"Group selection\",\"ungroup\":\"Ungroup selection\",\"collaborators\":\"Collaborators\",\"toggleGrid\":\"Toggle grid\",\"addToLibrary\":\"Add to library\",\"removeFromLibrary\":\"Remove from library\",\"libraryLoadingMessage\":\"Loading library…\",\"libraries\":\"Browse libraries\",\"loadingScene\":\"Loading scene…\",\"loadScene\":\"Load scene from file\",\"align\":\"Align\",\"alignTop\":\"Align top\",\"alignBottom\":\"Align bottom\",\"alignLeft\":\"Align left\",\"alignRight\":\"Align right\",\"centerVertically\":\"Center vertically\",\"centerHorizontally\":\"Center horizontally\",\"distributeHorizontally\":\"Distribute horizontally\",\"distributeVertically\":\"Distribute vertically\",\"flipHorizontal\":\"Flip horizontal\",\"flipVertical\":\"Flip vertical\",\"viewMode\":\"View mode\",\"share\":\"Share\",\"showStroke\":\"Show stroke color picker\",\"showBackground\":\"Show background color picker\",\"showFonts\":\"Show font picker\",\"toggleTheme\":\"Toggle light/dark theme\",\"theme\":\"Theme\",\"personalLib\":\"Personal Library\",\"excalidrawLib\":\"Excalidraw Library\",\"decreaseFontSize\":\"Decrease font size\",\"increaseFontSize\":\"Increase font size\",\"unbindText\":\"Unbind text\",\"bindText\":\"Bind text to the container\",\"createContainerFromText\":\"Wrap text in a container\",\"link\":{\"edit\":\"Edit link\",\"editEmbed\":\"Edit embeddable link\",\"create\":\"Add link\",\"label\":\"Link\",\"labelEmbed\":\"Link & embed\",\"empty\":\"No link is set\",\"hint\":\"Type or paste your link here\",\"goToElement\":\"Go to target element\"},\"lineEditor\":{\"edit\":\"Edit line\",\"editArrow\":\"Edit arrow\"},\"polygon\":{\"breakPolygon\":\"Break polygon\",\"convertToPolygon\":\"Convert to polygon\"},\"elementLock\":{\"lock\":\"Lock\",\"unlock\":\"Unlock\",\"lockAll\":\"Lock all\",\"unlockAll\":\"Unlock all\"},\"statusPublished\":\"Published\",\"sidebarLock\":\"Keep sidebar open\",\"selectAllElementsInFrame\":\"Select all elements in frame\",\"removeAllElementsFromFrame\":\"Remove all elements from frame\",\"eyeDropper\":\"Pick color from canvas\",\"textToDiagram\":\"Text to diagram\",\"prompt\":\"Prompt\",\"followUs\":\"Follow us\",\"discordChat\":\"Discord chat\",\"zoomToFitViewport\":\"Zoom to fit in viewport\",\"zoomToFitSelection\":\"Zoom to fit selection\",\"zoomToFit\":\"Zoom to fit all elements\",\"installPWA\":\"Install Excalidraw locally (PWA)\",\"autoResize\":\"Enable text auto-resizing\",\"imageCropping\":\"Image cropping\",\"unCroppedDimension\":\"Uncropped dimension\",\"copyElementLink\":\"Copy link to object\",\"linkToElement\":\"Link to object\",\"wrapSelectionInFrame\":\"Wrap selection in frame\",\"tab\":\"Tab\",\"shapeSwitch\":\"Switch shape\",\"toggleFrameRole\":\"Toggle frame role\"},\"elementLink\":{\"title\":\"Link to object\",\"desc\":\"Click on a shape on canvas or paste a link.\",\"notFound\":\"Linked object wasn\\'t found on canvas.\"},\"library\":{\"noItems\":\"No items added yet...\",\"hint_emptyLibrary\":\"Select an item on canvas to add it here, or install a library from the public repository, below.\",\"hint_emptyPrivateLibrary\":\"Select an item on canvas to add it here.\",\"search\":{\"inputPlaceholder\":\"Search library\",\"heading\":\"Library matches\",\"noResults\":\"No matching items found...\",\"clearSearch\":\"Clear search\"}},\"search\":{\"title\":\"Find on canvas\",\"noMatch\":\"No matches found...\",\"singleResult\":\"result\",\"multipleResults\":\"results\",\"placeholder\":\"Find text on canvas...\",\"frames\":\"Frames\",\"texts\":\"Texts\"},\"buttons\":{\"clearReset\":\"Reset the canvas\",\"exportJSON\":\"Export to file\",\"exportImage\":\"Export image...\",\"export\":\"Save to...\",\"copyToClipboard\":\"Copy to clipboard\",\"copyLink\":\"Copy link\",\"save\":\"Save to current file\",\"saveAs\":\"Save as\",\"load\":\"Open\",\"getShareableLink\":\"Get shareable link\",\"close\":\"Close\",\"selectLanguage\":\"Select language\",\"scrollBackToContent\":\"Scroll back to content\",\"zoomIn\":\"Zoom in\",\"zoomOut\":\"Zoom out\",\"resetZoom\":\"Reset zoom\",\"menu\":\"Menu\",\"done\":\"Done\",\"edit\":\"Edit\",\"undo\":\"Undo\",\"redo\":\"Redo\",\"resetLibrary\":\"Reset library\",\"createNewRoom\":\"Create new room\",\"fullScreen\":\"Full screen\",\"darkMode\":\"Dark mode\",\"lightMode\":\"Light mode\",\"systemMode\":\"System mode\",\"zenMode\":\"Zen mode\",\"objectsSnapMode\":\"Snap to objects\",\"exitZenMode\":\"Exit zen mode\",\"cancel\":\"Cancel\",\"saveLibNames\":\"Save name(s) and exit\",\"clear\":\"Clear\",\"remove\":\"Remove\",\"embed\":\"Toggle embedding\",\"publishLibrary\":\"Rename or publish\",\"submit\":\"Submit\",\"confirm\":\"Confirm\",\"embeddableInteractionButton\":\"Click to interact\"},\"alerts\":{\"clearReset\":\"This will clear the whole canvas. Are you sure?\",\"couldNotCreateShareableLink\":\"Couldn\\'t create shareable link.\",\"couldNotCreateShareableLinkTooBig\":\"Couldn\\'t create shareable link: the scene is too big\",\"couldNotLoadInvalidFile\":\"Couldn\\'t load invalid file\",\"importBackendFailed\":\"Importing from backend failed.\",\"cannotExportEmptyCanvas\":\"Cannot export empty canvas.\",\"couldNotCopyToClipboard\":\"Couldn\\'t copy to clipboard.\",\"decryptFailed\":\"Couldn\\'t decrypt data.\",\"uploadedSecurly\":\"The upload has been secured with end-to-end encryption, which means that Excalidraw server and third parties can\\'t read the content.\",\"loadSceneOverridePrompt\":\"Loading external drawing will replace your existing content. Do you wish to continue?\",\"collabStopOverridePrompt\":\"Stopping the session will overwrite your previous, locally stored drawing. Are you sure?\\\\n\\\\n(If you want to keep your local drawing, simply close the browser tab instead.)\",\"errorAddingToLibrary\":\"Couldn\\'t add item to the library\",\"errorRemovingFromLibrary\":\"Couldn\\'t remove item from the library\",\"confirmAddLibrary\":\"This will add {{numShapes}} shape(s) to your library. Are you sure?\",\"imageDoesNotContainScene\":\"This image does not seem to contain any scene data. Have you enabled scene embedding during export?\",\"cannotRestoreFromImage\":\"Scene couldn\\'t be restored from this image file\",\"invalidSceneUrl\":\"Couldn\\'t import scene from the supplied URL. It\\'s either malformed, or doesn\\'t contain valid Excalidraw JSON data.\",\"resetLibrary\":\"This will clear your library. Are you sure?\",\"removeItemsFromsLibrary\":\"Delete {{count}} item(s) from library?\",\"invalidEncryptionKey\":\"Encryption key must be of 22 characters. Live collaboration is disabled.\",\"collabOfflineWarning\":\"No internet connection available.\\\\nYour changes will not be saved!\",\"localStorageQuotaExceeded\":\"Browser storage quota exceeded. Changes will not be saved.\"},\"errors\":{\"unsupportedFileType\":\"Unsupported file type.\",\"imageInsertError\":\"Couldn\\'t insert image. Try again later...\",\"fileTooBig\":\"File is too big. Maximum allowed size is {{maxSize}}.\",\"svgImageInsertError\":\"Couldn\\'t insert SVG image. The SVG markup looks invalid.\",\"failedToFetchImage\":\"Failed to fetch image.\",\"cannotResolveCollabServer\":\"Couldn\\'t connect to the collab server. Please reload the page and try again.\",\"importLibraryError\":\"Couldn\\'t load library\",\"saveLibraryError\":\"Couldn\\'t save library to storage. Please save your library to a file locally to make sure you don\\'t lose changes.\",\"collabSaveFailed\":\"Couldn\\'t save to the backend database. If problems persist, you should save your file locally to ensure you don\\'t lose your work.\",\"collabSaveFailed_sizeExceeded\":\"Couldn\\'t save to the backend database, the canvas seems to be too big. You should save the file locally to ensure you don\\'t lose your work.\",\"imageToolNotSupported\":\"Images are disabled.\",\"brave_measure_text_error\":{\"line1\":\"Looks like you are using Brave browser with the <bold>Aggressively Block Fingerprinting</bold> setting enabled.\",\"line2\":\"This could result in breaking the <bold>Text Elements</bold> in your drawings.\",\"line3\":\"We strongly recommend disabling this setting. You can follow <link>these steps</link> on how to do so.\",\"line4\":\"If disabling this setting doesn\\'t fix the display of text elements, please open an <issueLink>issue</issueLink> on our GitHub, or write us on <discordLink>Discord</discordLink>\"},\"libraryElementTypeError\":{\"embeddable\":\"Embeddable elements cannot be added to the library.\",\"iframe\":\"IFrame elements cannot be added to the library.\",\"image\":\"Support for adding images to the library coming soon!\"},\"asyncPasteFailedOnRead\":\"Couldn\\'t paste (couldn\\'t read from system clipboard).\",\"asyncPasteFailedOnParse\":\"Couldn\\'t paste.\",\"copyToSystemClipboardFailed\":\"Couldn\\'t copy to clipboard.\"},\"toolBar\":{\"selection\":\"Selection\",\"lasso\":\"Lasso selection\",\"image\":\"Insert image\",\"rectangle\":\"Rectangle\",\"diamond\":\"Diamond\",\"ellipse\":\"Ellipse\",\"arrow\":\"Arrow\",\"line\":\"Line\",\"freedraw\":\"Draw\",\"text\":\"Text\",\"library\":\"Library\",\"lock\":\"Keep selected tool active after drawing\",\"penMode\":\"Pen mode - prevent touch\",\"link\":\"Add / Update link for a selected shape\",\"eraser\":\"Eraser\",\"frame\":\"Frame tool\",\"magicframe\":\"Wireframe to code\",\"embeddable\":\"Web Embed\",\"laser\":\"Laser pointer\",\"hand\":\"Hand (panning tool)\",\"extraTools\":\"More tools\",\"mermaidToExcalidraw\":\"Mermaid to Excalidraw\",\"convertElementType\":\"Toggle shape type\"},\"element\":{\"rectangle\":\"Rectangle\",\"diamond\":\"Diamond\",\"ellipse\":\"Ellipse\",\"arrow\":\"Arrow\",\"line\":\"Line\",\"freedraw\":\"Freedraw\",\"text\":\"Text\",\"image\":\"Image\",\"group\":\"Group\",\"frame\":\"Frame\",\"magicframe\":\"Wireframe to code\",\"embeddable\":\"Web Embed\",\"selection\":\"Selection\",\"iframe\":\"IFrame\"},\"headings\":{\"canvasActions\":\"Canvas actions\",\"selectedShapeActions\":\"Selected shape actions\",\"shapes\":\"Shapes\"},\"hints\":{\"dismissSearch\":\"Escape to dismiss search\",\"canvasPanning\":\"To move canvas, hold mouse wheel or spacebar while dragging, or use the hand tool\",\"linearElement\":\"Click to start multiple points, drag for single line\",\"arrowTool\":\"Click to start multiple points, drag for single line. Press {{arrowShortcut}} again to change arrow type.\",\"freeDraw\":\"Click and drag, release when you\\'re finished\",\"text\":\"Tip: you can also add text by double-clicking anywhere with the selection tool\",\"embeddable\":\"Click-drag to create a website embed\",\"text_selected\":\"Double-click or press ENTER to edit text\",\"text_editing\":\"Press Escape or CtrlOrCmd+ENTER to finish editing\",\"linearElementMulti\":\"Click on last point or press Escape or Enter to finish\",\"lockAngle\":\"You can constrain angle by holding SHIFT\",\"resize\":\"You can constrain proportions by holding SHIFT while resizing,\\\\nhold ALT to resize from the center\",\"resizeImage\":\"You can resize freely by holding SHIFT,\\\\nhold ALT to resize from the center\",\"rotate\":\"You can constrain angles by holding SHIFT while rotating\",\"lineEditor_info\":\"Hold CtrlOrCmd and Double-click or press CtrlOrCmd + Enter to edit points\",\"lineEditor_line_info\":\"Double-click or press Enter to edit points\",\"lineEditor_pointSelected\":\"Press Delete to remove point(s),\\\\nCtrlOrCmd+D to duplicate, or drag to move\",\"lineEditor_nothingSelected\":\"Select a point to edit (hold SHIFT to select multiple),\\\\nor hold Alt and click to add new points\",\"publishLibrary\":\"Publish your own library\",\"bindTextToElement\":\"Press enter to add text\",\"createFlowchart\":\"Hold CtrlOrCmd and Arrow key to create a flowchart\",\"deepBoxSelect\":\"Hold CtrlOrCmd to deep select, and to prevent dragging\",\"eraserRevert\":\"Hold Alt to revert the elements marked for deletion\",\"firefox_clipboard_write\":\"This feature can likely be enabled by setting the \\\\\"dom.events.asyncClipboard.clipboardItem\\\\\" flag to \\\\\"true\\\\\". To change the browser flags in Firefox, visit the \\\\\"about:config\\\\\" page.\",\"disableSnapping\":\"Hold CtrlOrCmd to disable snapping\",\"enterCropEditor\":\"Double click the image or press ENTER to crop the image\",\"leaveCropEditor\":\"Click outside the image or press ENTER or ESCAPE to finish cropping\"},\"canvasError\":{\"cannotShowPreview\":\"Cannot show preview\",\"canvasTooBig\":\"The canvas may be too big.\",\"canvasTooBigTip\":\"Tip: try moving the farthest elements a bit closer together.\"},\"errorSplash\":{\"headingMain\":\"Encountered an error. Try <button>reloading the page</button>.\",\"clearCanvasMessage\":\"If reloading doesn\\'t work, try <button>clearing the canvas</button>.\",\"clearCanvasCaveat\":\" This will result in loss of work \",\"trackedToSentry\":\"The error with identifier {{eventId}} was tracked on our system.\",\"openIssueMessage\":\"We were very cautious not to include your scene information on the error. If your scene is not private, please consider following up on our <button>bug tracker</button>. Please include information below by copying and pasting into the GitHub issue.\",\"sceneContent\":\"Scene content:\"},\"shareDialog\":{\"or\":\"Or\"},\"roomDialog\":{\"desc_intro\":\"Invite people to collaborate on your drawing.\",\"desc_privacy\":\"Don\\'t worry, the session is end-to-end encrypted, and fully private. Not even our server can see what you draw.\",\"button_startSession\":\"Start session\",\"button_stopSession\":\"Stop session\",\"desc_inProgressIntro\":\"Live-collaboration session is now in progress.\",\"desc_shareLink\":\"Share this link with anyone you want to collaborate with:\",\"desc_exitSession\":\"Stopping the session will disconnect you from the room, but you\\'ll be able to continue working with the scene, locally. Note that this won\\'t affect other people, and they\\'ll still be able to collaborate on their version.\",\"shareTitle\":\"Join a live collaboration session on Excalidraw\"},\"errorDialog\":{\"title\":\"Error\"},\"exportDialog\":{\"disk_title\":\"Save to disk\",\"disk_details\":\"Export the scene data to a file from which you can import later.\",\"disk_button\":\"Save to file\",\"link_title\":\"Shareable link\",\"link_details\":\"Export as a read-only link.\",\"link_button\":\"Export to Link\",\"excalidrawplus_description\":\"Save the scene to your Excalidraw+ workspace.\",\"excalidrawplus_button\":\"Export\",\"excalidrawplus_exportError\":\"Couldn\\'t export to Excalidraw+ at this moment...\"},\"helpDialog\":{\"blog\":\"Read our blog\",\"click\":\"click\",\"deepSelect\":\"Deep select\",\"deepBoxSelect\":\"Deep select within box, and prevent dragging\",\"createFlowchart\":\"Create a flowchart from a generic element\",\"navigateFlowchart\":\"Navigate a flowchart\",\"curvedArrow\":\"Curved arrow\",\"curvedLine\":\"Curved line\",\"documentation\":\"Documentation\",\"doubleClick\":\"double-click\",\"drag\":\"drag\",\"editor\":\"Editor\",\"editLineArrowPoints\":\"Edit line/arrow points\",\"editText\":\"Edit text / add label\",\"github\":\"Found an issue? Submit\",\"howto\":\"Follow our guides\",\"or\":\"or\",\"preventBinding\":\"Prevent arrow binding\",\"tools\":\"Tools\",\"shortcuts\":\"Keyboard shortcuts\",\"textFinish\":\"Finish editing (text editor)\",\"textNewLine\":\"Add new line (text editor)\",\"title\":\"Help\",\"view\":\"View\",\"zoomToFit\":\"Zoom to fit all elements\",\"zoomToSelection\":\"Zoom to selection\",\"toggleElementLock\":\"Lock/unlock selection\",\"movePageUpDown\":\"Move page up/down\",\"movePageLeftRight\":\"Move page left/right\",\"cropStart\":\"Crop image\",\"cropFinish\":\"Finish image cropping\"},\"clearCanvasDialog\":{\"title\":\"Clear canvas\"},\"publishDialog\":{\"title\":\"Publish library\",\"itemName\":\"Item name\",\"authorName\":\"Author name\",\"githubUsername\":\"GitHub username\",\"twitterUsername\":\"Twitter username\",\"libraryName\":\"Library name\",\"libraryDesc\":\"Library description\",\"website\":\"Website\",\"placeholder\":{\"authorName\":\"Your name or username\",\"libraryName\":\"Name of your library\",\"libraryDesc\":\"Description of your library to help people understand its usage\",\"githubHandle\":\"GitHub handle (optional), so you can edit the library once submitted for review\",\"twitterHandle\":\"Twitter username (optional), so we know who to credit when promoting over Twitter\",\"website\":\"Link to your personal website or elsewhere (optional)\"},\"errors\":{\"required\":\"Required\",\"website\":\"Enter a valid URL\"},\"noteDescription\":\"Submit your library to be included in the <link>public library repository</link> for other people to use in their drawings.\",\"noteGuidelines\":\"The library needs to be manually approved first. Please read the <link>guidelines</link> before submitting. You will need a GitHub account to communicate and make changes if requested, but it is not strictly required.\",\"noteLicense\":\"By submitting, you agree the library will be published under the <link>MIT License</link>, which in short means anyone can use them without restrictions.\",\"noteItems\":\"Each library item must have its own name so it\\'s filterable. The following library items will be included:\",\"atleastOneLibItem\":\"Please select at least one library item to get started\",\"republishWarning\":\"Note: some of the selected items are marked as already published/submitted. You should only resubmit items when updating an existing library or submission.\"},\"publishSuccessDialog\":{\"title\":\"Library submitted\",\"content\":\"Thank you {{authorName}}. Your library has been submitted for review. You can track the status <link>here</link>\"},\"confirmDialog\":{\"resetLibrary\":\"Reset library\",\"removeItemsFromLib\":\"Remove selected items from library\"},\"imageExportDialog\":{\"header\":\"Export image\",\"label\":{\"withBackground\":\"Background\",\"onlySelected\":\"Only selected\",\"darkMode\":\"Dark mode\",\"embedScene\":\"Embed scene\",\"scale\":\"Scale\",\"padding\":\"Padding\"},\"tooltip\":{\"embedScene\":\"Scene data will be saved into the exported PNG/SVG file so that the scene can be restored from it.\\\\nWill increase exported file size.\"},\"title\":{\"exportToPng\":\"Export to PNG\",\"exportToSvg\":\"Export to SVG\",\"copyPngToClipboard\":\"Copy PNG to clipboard\"},\"button\":{\"exportToPng\":\"PNG\",\"exportToSvg\":\"SVG\",\"copyPngToClipboard\":\"Copy to clipboard\"}},\"encrypted\":{\"tooltip\":\"Your drawings are end-to-end encrypted so Excalidraw\\'s servers will never see them.\",\"link\":\"Blog post on end-to-end encryption in Excalidraw\"},\"stats\":{\"angle\":\"Angle\",\"shapes\":\"Shapes\",\"height\":\"Height\",\"scene\":\"Scene\",\"selected\":\"Selected\",\"storage\":\"Storage\",\"fullTitle\":\"Canvas & Shape properties\",\"title\":\"Properties\",\"generalStats\":\"General\",\"elementProperties\":\"Shape properties\",\"total\":\"Total\",\"version\":\"Version\",\"versionCopy\":\"Click to copy\",\"versionNotAvailable\":\"Version not available\",\"width\":\"Width\"},\"toast\":{\"addedToLibrary\":\"Added to library\",\"copyStyles\":\"Copied styles.\",\"copyToClipboard\":\"Copied to clipboard.\",\"copyToClipboardAsPng\":\"Copied {{exportSelection}} to clipboard as PNG\\\\n({{exportColorScheme}})\",\"copyToClipboardAsSvg\":\"Copied {{exportSelection}} to clipboard as SVG\\\\n({{exportColorScheme}})\",\"fileSaved\":\"File saved.\",\"fileSavedToFilename\":\"Saved to {filename}\",\"canvas\":\"canvas\",\"selection\":\"selection\",\"pasteAsSingleElement\":\"Use {{shortcut}} to paste as a single element,\\\\nor paste into an existing text editor\",\"unableToEmbed\":\"Embedding this url is currently not allowed. Raise an issue on GitHub to request the url whitelisted\",\"unrecognizedLinkFormat\":\"The link you embedded does not match the expected format. Please try to paste the \\'embed\\' string provided by the source site\",\"elementLinkCopied\":\"Link copied to clipboard\"},\"colors\":{\"transparent\":\"Transparent\",\"black\":\"Black\",\"white\":\"White\",\"red\":\"Red\",\"pink\":\"Pink\",\"grape\":\"Grape\",\"violet\":\"Violet\",\"gray\":\"Gray\",\"blue\":\"Blue\",\"cyan\":\"Cyan\",\"teal\":\"Teal\",\"green\":\"Green\",\"yellow\":\"Yellow\",\"orange\":\"Orange\",\"bronze\":\"Bronze\"},\"welcomeScreen\":{\"app\":{\"center_heading\":\"All your data is saved locally in your browser.\",\"center_heading_plus\":\"Did you want to go to the Excalidraw+ instead?\",\"menuHint\":\"Export, preferences, languages, ...\"},\"defaults\":{\"menuHint\":\"Export, preferences, and more...\",\"center_heading\":\"Diagrams. Made. Simple.\",\"toolbarHint\":\"Pick a tool & Start drawing!\",\"helpHint\":\"Shortcuts & help\"}},\"colorPicker\":{\"color\":\"Color\",\"mostUsedCustomColors\":\"Most used custom colors\",\"colors\":\"Colors\",\"shades\":\"Shades\",\"hexCode\":\"Hex code\",\"noShades\":\"No shades available for this color\"},\"overwriteConfirm\":{\"action\":{\"exportToImage\":{\"title\":\"Export as image\",\"button\":\"Export as image\",\"description\":\"Export the scene data as an image from which you can import later.\"},\"saveToDisk\":{\"title\":\"Save to disk\",\"button\":\"Save to disk\",\"description\":\"Export the scene data to a file from which you can import later.\"},\"excalidrawPlus\":{\"title\":\"Excalidraw+\",\"button\":\"Export to Excalidraw+\",\"description\":\"Save the scene to your Excalidraw+ workspace.\"}},\"modal\":{\"loadFromFile\":{\"title\":\"Load from file\",\"button\":\"Load from file\",\"description\":\"Loading from a file will <bold>replace your existing content</bold>.<br></br>You can back up your drawing first using one of the options below.\"},\"shareableLink\":{\"title\":\"Load from link\",\"button\":\"Replace my content\",\"description\":\"Loading external drawing will <bold>replace your existing content</bold>.<br></br>You can back up your drawing first by using one of the options below.\"}}},\"mermaid\":{\"title\":\"Mermaid to Excalidraw\",\"button\":\"Insert\",\"description\":\"Currently only <flowchartLink>Flowchart</flowchartLink>,<sequenceLink> Sequence, </sequenceLink> and <classLink>Class </classLink>Diagrams are supported. The other types will be rendered as image in Excalidraw.\",\"syntax\":\"Mermaid Syntax\",\"preview\":\"Preview\"},\"quickSearch\":{\"placeholder\":\"Quick search\"},\"fontList\":{\"badge\":{\"old\":\"old\"},\"sceneFonts\":\"In this scene\",\"availableFonts\":\"Available fonts\",\"empty\":\"No fonts found\"},\"userList\":{\"empty\":\"No users found\",\"hint\":{\"text\":\"Click on user to follow\",\"followStatus\":\"You\\'re currently following this user\",\"inCall\":\"User is in a voice call\",\"micMuted\":\"User\\'s microphone is muted\",\"isSpeaking\":\"User is speaking\"}},\"commandPalette\":{\"title\":\"Command palette\",\"shortcuts\":{\"select\":\"Select\",\"confirm\":\"Confirm\",\"close\":\"Close\"},\"recents\":\"Recently used\",\"search\":{\"placeholder\":\"Search menus, commands, and discover hidden gems\",\"noMatch\":\"No matching commands...\"},\"itemNotAvailable\":\"Command is not available...\",\"shortcutHint\":\"For Command palette, use {{shortcut}}\"}}');\n\n//# sourceURL=webpack://ExcalidrawLib/./locales/en.json?");
19980
19980
 
19981
19981
  /***/ }),
19982
19982