{"version":3,"sources":["webpack:///./node_modules/@ckeditor/ckeditor5-engine/src/model/nodelist.js"],"names":["NodeList","nodes","Object","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_classCallCheck_js__WEBPACK_IMPORTED_MODULE_8__","this","_nodes","_insertNodes","Symbol","iterator","length","reduce","sum","node","offsetSize","index","indexOf","getNodeIndex","slice","maxOffset","CKEditorError","getNodeStartOffset","offset","_step","totalOffset","_iterator","_createForOfIteratorHelper","s","n","done","value","err","e","f","nodeList","_this$_nodes","_step2","_iterator2","Node","splice","apply","concat","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_4__","indexStart","howMany","arguments","undefined","map","toJSON"],"mappings":";;;;OAiBqBA,cAOpB,SAAAA,EAAaC,GAAQC,OAAAC,EAAA,KAAAD,CAAAE,KAAAJ,GAOpBI,KAAKC,UAEAJ,GACJG,KAAKE,aAAc,EAAGL,yCAWxB,WACC,OAAOG,KAAKC,OAAQE,OAAOC,gCAS5B,WACC,OAAOJ,KAAKC,OAAOI,8BASpB,WACC,OAAOL,KAAKC,OAAOK,OAAQ,SAAEC,EAAKC,GAAP,OAAiBD,EAAMC,EAAKC,YAAY,0BASpE,SAASC,GACR,OAAOV,KAAKC,OAAQS,IAAW,iCAShC,SAAcF,GACb,IAAME,EAAQV,KAAKC,OAAOU,QAASH,GAEnC,OAAiB,GAAVE,EAAc,KAAOA,oCAU7B,SAAoBF,GACnB,IAAME,EAAQV,KAAKY,aAAcJ,GAEjC,OAAiB,OAAVE,EAAiB,KAAOV,KAAKC,OAAOY,MAAO,EAAGH,GAAQJ,OAAQ,SAAEC,EAAKC,GAAP,OAAiBD,EAAMC,EAAKC,YAAY,gCAY9G,SAAeC,GACd,GAAKA,GAASV,KAAKC,OAAOI,OACzB,OAAOL,KAAKc,UAGb,IAAMN,EAAOR,KAAKC,OAAQS,GAE1B,IAAMF,EAML,MAAM,IAAIO,OAAe,qCAAsCf,MAGhE,OAAOA,KAAKgB,mBAAoBR,gCAYjC,SAAeS,GACd,IADuBC,EACnBC,EAAc,EADKC,EAAAC,EAGHrB,KAAKC,QAHF,IAGvB,IAAAmB,EAAAE,MAAAJ,EAAAE,EAAAG,KAAAC,MAAkC,KAAtBhB,EAAsBU,EAAAO,MACjC,GAAKR,GAAUE,GAAeF,EAASE,EAAcX,EAAKC,WACzD,OAAOT,KAAKY,aAAcJ,GAG3BW,GAAeX,EAAKC,YARE,MAAAiB,GAAAN,EAAAO,EAAAD,GAAA,QAAAN,EAAAQ,IAWvB,GAAKT,GAAeF,EAQnB,MAAM,IAAIF,OAAe,sCACxBf,MAECiB,SACAY,SAAU7B,OAKb,OAAOA,KAAKK,mCAUb,SAAcK,EAAOb,GAAQ,IAAAiC,EAAAC,EAAAC,EAAAX,EAERxB,GAFQ,IAE5B,IAAAmC,EAAAV,MAAAS,EAAAC,EAAAT,KAAAC,MAA4B,KAAhBhB,EAAgBuB,EAAAN,MAC3B,KAAQjB,aAAgByB,QAMvB,MAAM,IAAIlB,OAAe,sCAAuCf,OATtC,MAAA0B,GAAAM,EAAAL,EAAAD,GAAA,QAAAM,EAAAJ,KAa5BE,EAAA9B,KAAKC,QAAOiC,OAAZC,MAAAL,GAAoBpB,EAAO,GAA3B0B,OAAAtC,OAAAuC,EAAA,KAAAvC,CAAiCD,iCAWlC,SAAcyC,GAA0B,IAAdC,EAAcC,UAAAnC,OAAA,QAAAoC,IAAAD,UAAA,GAAAA,UAAA,GAAJ,EACnC,OAAOxC,KAAKC,OAAOiC,OAAQI,EAAYC,yBASxC,WACC,OAAOvC,KAAKC,OAAOyC,IAAK,SAAAlC,GAAI,OAAIA,EAAKmC,kBAzKpCxC,OAAOC","file":"js/chunk-2d20865d.5fd4c31b.js","sourcesContent":["/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module engine/model/nodelist\n */\n\nimport Node from './node';\nimport CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';\n\n/**\n * Provides an interface to operate on a list of {@link module:engine/model/node~Node nodes}. `NodeList` is used internally\n * in classes like {@link module:engine/model/element~Element Element}\n * or {@link module:engine/model/documentfragment~DocumentFragment DocumentFragment}.\n */\nexport default class NodeList {\n\t/**\n\t * Creates an empty node list.\n\t *\n\t * @protected\n\t * @param {Iterable.} nodes Nodes contained in this node list.\n\t */\n\tconstructor( nodes ) {\n\t\t/**\n\t\t * Nodes contained in this node list.\n\t\t *\n\t\t * @private\n\t\t * @member {Array.}\n\t\t */\n\t\tthis._nodes = [];\n\n\t\tif ( nodes ) {\n\t\t\tthis._insertNodes( 0, nodes );\n\t\t}\n\t}\n\n\t/**\n\t * Iterable interface.\n\t *\n\t * Iterates over all nodes contained inside this node list.\n\t *\n\t * @returns {Iterable.}\n\t */\n\t[ Symbol.iterator ]() {\n\t\treturn this._nodes[ Symbol.iterator ]();\n\t}\n\n\t/**\n\t * Number of nodes contained inside this node list.\n\t *\n\t * @readonly\n\t * @type {Number}\n\t */\n\tget length() {\n\t\treturn this._nodes.length;\n\t}\n\n\t/**\n\t * Sum of {@link module:engine/model/node~Node#offsetSize offset sizes} of all nodes contained inside this node list.\n\t *\n\t * @readonly\n\t * @type {Number}\n\t */\n\tget maxOffset() {\n\t\treturn this._nodes.reduce( ( sum, node ) => sum + node.offsetSize, 0 );\n\t}\n\n\t/**\n\t * Gets the node at the given index. Returns `null` if incorrect index was passed.\n\t *\n\t * @param {Number} index Index of node.\n\t * @returns {module:engine/model/node~Node|null} Node at given index.\n\t */\n\tgetNode( index ) {\n\t\treturn this._nodes[ index ] || null;\n\t}\n\n\t/**\n\t * Returns an index of the given node. Returns `null` if given node is not inside this node list.\n\t *\n\t * @param {module:engine/model/node~Node} node Child node to look for.\n\t * @returns {Number|null} Child node's index.\n\t */\n\tgetNodeIndex( node ) {\n\t\tconst index = this._nodes.indexOf( node );\n\n\t\treturn index == -1 ? null : index;\n\t}\n\n\t/**\n\t * Returns the starting offset of given node. Starting offset is equal to the sum of\n\t * {@link module:engine/model/node~Node#offsetSize offset sizes} of all nodes that are before this node in this node list.\n\t *\n\t * @param {module:engine/model/node~Node} node Node to look for.\n\t * @returns {Number|null} Node's starting offset.\n\t */\n\tgetNodeStartOffset( node ) {\n\t\tconst index = this.getNodeIndex( node );\n\n\t\treturn index === null ? null : this._nodes.slice( 0, index ).reduce( ( sum, node ) => sum + node.offsetSize, 0 );\n\t}\n\n\t/**\n\t * Converts index to offset in node list.\n\t *\n\t * Returns starting offset of a node that is at given index. Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError}\n\t * `model-nodelist-index-out-of-bounds` if given index is less than `0` or more than {@link #length}.\n\t *\n\t * @param {Number} index Node's index.\n\t * @returns {Number} Node's starting offset.\n\t */\n\tindexToOffset( index ) {\n\t\tif ( index == this._nodes.length ) {\n\t\t\treturn this.maxOffset;\n\t\t}\n\n\t\tconst node = this._nodes[ index ];\n\n\t\tif ( !node ) {\n\t\t\t/**\n\t\t\t * Given index cannot be found in the node list.\n\t\t\t *\n\t\t\t * @error model-nodelist-index-out-of-bounds\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'model-nodelist-index-out-of-bounds', this );\n\t\t}\n\n\t\treturn this.getNodeStartOffset( node );\n\t}\n\n\t/**\n\t * Converts offset in node list to index.\n\t *\n\t * Returns index of a node that occupies given offset. Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError}\n\t * `model-nodelist-offset-out-of-bounds` if given offset is less than `0` or more than {@link #maxOffset}.\n\t *\n\t * @param {Number} offset Offset to look for.\n\t * @returns {Number} Index of a node that occupies given offset.\n\t */\n\toffsetToIndex( offset ) {\n\t\tlet totalOffset = 0;\n\n\t\tfor ( const node of this._nodes ) {\n\t\t\tif ( offset >= totalOffset && offset < totalOffset + node.offsetSize ) {\n\t\t\t\treturn this.getNodeIndex( node );\n\t\t\t}\n\n\t\t\ttotalOffset += node.offsetSize;\n\t\t}\n\n\t\tif ( totalOffset != offset ) {\n\t\t\t/**\n\t\t\t * Given offset cannot be found in the node list.\n\t\t\t *\n\t\t\t * @error model-nodelist-offset-out-of-bounds\n\t\t\t * @param {Number} offset\n\t\t\t * @param {module:engine/model/nodelist~NodeList} nodeList Stringified node list.\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'model-nodelist-offset-out-of-bounds',\n\t\t\t\tthis,\n\t\t\t\t{\n\t\t\t\t\toffset,\n\t\t\t\t\tnodeList: this\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn this.length;\n\t}\n\n\t/**\n\t * Inserts given nodes at given index.\n\t *\n\t * @protected\n\t * @param {Number} index Index at which nodes should be inserted.\n\t * @param {Iterable.} nodes Nodes to be inserted.\n\t */\n\t_insertNodes( index, nodes ) {\n\t\t// Validation.\n\t\tfor ( const node of nodes ) {\n\t\t\tif ( !( node instanceof Node ) ) {\n\t\t\t\t/**\n\t\t\t\t * Trying to insert an object which is not a Node instance.\n\t\t\t\t *\n\t\t\t\t * @error model-nodelist-insertnodes-not-node\n\t\t\t\t */\n\t\t\t\tthrow new CKEditorError( 'model-nodelist-insertnodes-not-node', this );\n\t\t\t}\n\t\t}\n\n\t\tthis._nodes.splice( index, 0, ...nodes );\n\t}\n\n\t/**\n\t * Removes one or more nodes starting at the given index.\n\t *\n\t * @protected\n\t * @param {Number} indexStart Index of the first node to remove.\n\t * @param {Number} [howMany=1] Number of nodes to remove.\n\t * @returns {Array.} Array containing removed nodes.\n\t */\n\t_removeNodes( indexStart, howMany = 1 ) {\n\t\treturn this._nodes.splice( indexStart, howMany );\n\t}\n\n\t/**\n\t * Converts `NodeList` instance to an array containing nodes that were inserted in the node list. Nodes\n\t * are also converted to their plain object representation.\n\t *\n\t * @returns {Array.} `NodeList` instance converted to `Array`.\n\t */\n\ttoJSON() {\n\t\treturn this._nodes.map( node => node.toJSON() );\n\t}\n}\n"],"sourceRoot":""}