@vervedoc/docx-editor-view 1.0.4

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.
@@ -0,0 +1,113 @@
1
+ (function(X,Ht){typeof exports=="object"&&typeof module<"u"?Ht(exports):typeof define=="function"&&define.amd?define(["exports"],Ht):(X=typeof globalThis<"u"?globalThis:X||self,Ht(X.DocxEditorView={}))})(this,function(X){"use strict";var rl=Object.defineProperty;var ll=(X,Ht,ue)=>Ht in X?rl(X,Ht,{enumerable:!0,configurable:!0,writable:!0,value:ue}):X[Ht]=ue;var m=(X,Ht,ue)=>ll(X,typeof Ht!="symbol"?Ht+"":Ht,ue);var Ht=(l=>(l.EDIT="edit",l.READONLY="readonly",l.FORM="form",l))(Ht||{}),ue=(l=>(l.CONTAIN="contain",l.COVER="cover",l))(ue||{}),Ie=(l=>(l.REPEAT="repeat",l.NO_REPEAT="no-repeat",l.REPEAT_X="repeat-x",l.REPEAT_Y="repeat-y",l))(Ie||{}),Me=(l=>(l.IFRAME="iframe",l.VIDEO="video",l.AUDIO="audio",l.CHART="chart",l))(Me||{}),ve=(l=>(l.HALF="half",l.ONE_THIRD="one-third",l.QUARTER="quarter",l))(ve||{}),Vt=(l=>(l.ARABIC="arabic",l.CHINESE="chinese",l))(Vt||{}),Q=(l=>(l.INLINE="inline",l.BLOCK="block",l.SURROUND="surround",l.FLOAT_TOP="float-top",l.FLOAT_BOTTOM="float-bottom",l))(Q||{}),ie=(l=>(l.BEFORE="before",l.AFTER="after",l.OUTER_BEFORE="outer-before",l.OUTER_AFTER="outer-after",l))(ie||{}),Xi=(l=>(l.ROW="row",l.COLUMN="column",l))(Xi||{}),lt=(l=>(l.TEXT="text",l.SELECT="select",l.CHECKBOX="checkbox",l.RADIO="radio",l.DATE="date",l.NUMBER="number",l))(lt||{}),b=(l=>(l.PREFIX="prefix",l.POSTFIX="postfix",l.PRE_TEXT="preText",l.POST_TEXT="postText",l.PLACEHOLDER="placeholder",l.VALUE="value",l.CHECKBOX="checkbox",l.RADIO="radio",l))(b||{}),$i=(l=>(l.ROW_START="rowStart",l.VALUE_START="valueStart",l))($i||{}),_e=(l=>(l.ACTIVE="active",l.INACTIVE="inactive",l))(_e||{}),ke=(l=>(l.COMPONENT="component",l.MENU="menu",l.MAIN="main",l.FOOTER="footer",l.CONTEXTMENU="contextmenu",l.POPUP="popup",l.CATALOG="catalog",l.COMMENT="comment",l))(ke||{}),Ee=(l=>(l.PAGE="page",l.TABLE="table",l))(Ee||{}),at=(l=>(l.EDIT="edit",l.CLEAN="clean",l.READONLY="readonly",l.FORM="form",l.PRINT="print",l.DESIGN="design",l))(at||{}),st=(l=>(l.HEADER="header",l.MAIN="main",l.FOOTER="footer",l))(st||{}),Le=(l=>(l.PAGING="paging",l.CONTINUITY="continuity",l))(Le||{}),Ne=(l=>(l.VERTICAL="vertical",l.HORIZONTAL="horizontal",l))(Ne||{}),ui=(l=>(l.BREAK_ALL="break-all",l.BREAK_WORD="break-word",l))(ui||{}),gi=(l=>(l.SPEED="speed",l.COMPATIBILITY="compatibility",l))(gi||{}),R=(l=>(l.TEXT="text",l.IMAGE="image",l.TABLE="table",l.HYPERLINK="hyperlink",l.SUPERSCRIPT="superscript",l.SUBSCRIPT="subscript",l.SEPARATOR="separator",l.PAGE_BREAK="pageBreak",l.CONTROL="control",l.AREA="area",l.CHECKBOX="checkbox",l.RADIO="radio",l.LATEX="latex",l.TAB="tab",l.DATE="date",l.BLOCK="block",l.TITLE="title",l.LIST="list",l.PLACEHOLDER="placeholder",l.FOOTNOTE_MARK="footnoteMark",l.FOOTNOTE_CONTENT="footnoteContent",l.FOOTNOTE_SEPARATOR="footnoteSeparator",l.COLUMN_BREAK="columnBreak",l.REVISION_INSERT="revisionInsert",l.REVISION_DELETE="revisionDelete",l))(R||{}),Ui=(l=>(l[l.LEFT=0]="LEFT",l[l.CENTER=1]="CENTER",l[l.RIGHT=2]="RIGHT",l))(Ui||{}),wt=(l=>(l.Delete="Delete",l.Backspace="Backspace",l.Enter="Enter",l.Left="ArrowLeft",l.Right="ArrowRight",l.Up="ArrowUp",l.Down="ArrowDown",l.ESC="Escape",l.TAB="Tab",l.META="Meta",l.LEFT_BRACKET="[",l.RIGHT_BRACKET="]",l.COMMA=",",l.PERIOD=".",l.LEFT_ANGLE_BRACKET="<",l.RIGHT_ANGLE_BRACKET=">",l.EQUAL="=",l.MINUS="-",l.PLUS="+",l.BACKSLASH="\\",l.A="a",l.B="b",l.C="c",l.D="d",l.E="e",l.F="f",l.G="g",l.H="h",l.I="i",l.J="j",l.K="k",l.L="l",l.M="m",l.N="n",l.O="o",l.P="p",l.Q="q",l.R="r",l.S="s",l.T="t",l.U="u",l.V="v",l.W="w",l.X="x",l.Y="y",l.Z="z",l.A_UPPERCASE="A",l.B_UPPERCASE="B",l.C_UPPERCASE="C",l.D_UPPERCASE="D",l.E_UPPERCASE="E",l.F_UPPERCASE="F",l.G_UPPERCASE="G",l.H_UPPERCASE="H",l.I_UPPERCASE="I",l.J_UPPERCASE="J",l.K_UPPERCASE="K",l.L_UPPERCASE="L",l.M_UPPERCASE="M",l.N_UPPERCASE="N",l.O_UPPERCASE="O",l.P_UPPERCASE="P",l.Q_UPPERCASE="Q",l.R_UPPERCASE="R",l.S_UPPERCASE="S",l.T_UPPERCASE="T",l.U_UPPERCASE="U",l.V_UPPERCASE="V",l.W_UPPERCASE="W",l.X_UPPERCASE="X",l.Y_UPPERCASE="Y",l.Z_UPPERCASE="Z",l.ZERO="0",l.ONE="1",l.TWO="2",l.THREE="3",l.FOUR="4",l.FIVE="5",l.SIX="6",l.SEVEN="7",l.EIGHT="8",l.NINE="9",l))(wt||{}),pi=(l=>(l.PAGE="page",l.CONTINUITY="continuity",l))(pi||{}),ge=(l=>(l.UL="ul",l.OL="ol",l))(ge||{}),K=(l=>(l.DISC="disc",l.CIRCLE="circle",l.SQUARE="square",l.CHECKBOX="checkbox",l.DIAMOND="diamond",l.DASH="dash",l.CHECK="check",l.TRIANGLE="triangle",l.STAR="star",l.ARROW="arrow",l.DIAMOND_SOLID="diamond-solid",l.ANGLE="angle",l.HOLLOW_CIRCLE="hollow-circle",l.HOLLOW_SQUARE="hollow-square",l.HEART_HOLLOW="heart-hollow",l.HASH="hash",l.TRIANGLE_SOLID="triangle-solid",l.STAR_SOLID="star-solid",l.HEART_SOLID="heart-solid",l.FLOWER="flower",l.ASTERISK="asterisk",l.HOLLOW_DIAMOND="hollow-diamond",l.HOLLOW_TRIANGLE="hollow-triangle",l))(K||{}),Qt=(l=>(l.DECIMAL="decimal",l.DECIMAL_DOT="decimal-dot",l.DECIMAL_PAREN="decimal-paren",l.DECIMAL_CIRCLE="decimal-circle",l.DECIMAL_BRACKET="decimal-bracket",l.CHINESE="chinese",l.CHINESE_BRACKET="chinese-bracket",l.UPPER_ALPHA="upper-alpha",l.LOWER_ALPHA_DOT="lower-alpha-dot",l))(Qt||{}),It=(l=>(l.DISC="disc",l.CIRCLE="circle",l.SQUARE="square",l.CHECKBOX="checkbox",l.DIAMOND="diamond",l.DASH="dash",l.CHECK="check",l.DECIMAL="decimal",l.DECIMAL_DOT="decimal-dot",l.DECIMAL_PAREN="decimal-paren",l.DECIMAL_CIRCLE="decimal-circle",l.DECIMAL_BRACKET="decimal-bracket",l.CHINESE="chinese",l.CHINESE_BRACKET="chinese-bracket",l.UPPER_ALPHA="upper-alpha",l.LOWER_ALPHA_DOT="lower-alpha-dot",l))(It||{}),St=(l=>(l.UP="top",l.DOWN="down",l.LEFT="left",l.RIGHT="right",l))(St||{}),gt=(l=>(l.LEFT="left",l.CENTER="center",l.RIGHT="right",l.ALIGNMENT="alignment",l.JUSTIFY="justify",l))(gt||{}),We=(l=>(l.SOLID="solid",l.DOUBLE="double",l.DASHED="dashed",l.DOTTED="dotted",l.WAVY="wavy",l))(We||{}),ze=(l=>(l.SOLID="solid",l.DASHED="dashed",l.DOTTED="dotted",l))(ze||{}),Rt=(l=>(l.FIRST="first",l.SECOND="second",l.THIRD="third",l.FOURTH="fourth",l.FIFTH="fifth",l.SIXTH="sixth",l))(Rt||{}),Wt=(l=>(l.TOP="top",l.MIDDLE="middle",l.BOTTOM="bottom",l))(Wt||{}),fi=(l=>(l.TEXT="text",l.IMAGE="image",l))(fi||{}),Kt=(l=>(l.ALL="all",l.EMPTY="empty",l.EXTERNAL="external",l.INTERNAL="internal",l.DASH="dash",l))(Kt||{}),ne=(l=>(l.TOP="top",l.RIGHT="right",l.BOTTOM="bottom",l.LEFT="left",l))(ne||{}),mi=(l=>(l.FORWARD="forward",l.BACK="back",l))(mi||{}),pe=(l=>(l.ROW="row",l.COL="col",l))(pe||{});const Oo="1.0.0",Bo={version:Oo},Ho="1.0.0",Mo=String(Bo.version),Xe="editor-component",J="ce",Di=`${J}-clipboard`,Ci={print:{imagePreviewerDisabled:!1},readonly:{imagePreviewerDisabled:!1},form:{controlDeletableDisabled:!1}},Y="​",Vi=" ",Gi="&nbsp;",_o=["·","、",":",":",",",",",".","。",";",";","?","?","!","!"],Ki={[ve.HALF]:1/2,[ve.ONE_THIRD]:1/3,[ve.QUARTER]:1/4},ko={ENGLISH:"A-Za-z"},No="日",fe=["bold","color","highlight","font","size","characterScale","italic","underline","strikeout","textDecoration"],Te=["rowFlex","rowMargin","paragraphColor","paragraphIndentLeft","paragraphFirstLineIndent","paragraphSpacingBefore","paragraphSpacingAfter"],Wo=["type","font","size","characterScale","bold","color","italic","highlight","paragraphColor","underline","strikeout","rowFlex","url","areaId","hyperlinkId","dateId","dateFormat","groupIds","rowMargin","textDecoration","dashArray","separatorType","separatorLineWidth","revisionId","revisionType","revisionAuthor","revisionDate"],zo=["type","font","size","characterScale","bold","color","italic","highlight","paragraphColor","underline","strikeout","rowFlex","rowMargin","dashArray","separatorType","separatorLineWidth","trList","tableToolDisabled","borderType","borderColor","borderWidth","borderExternalWidth","width","height","url","colgroup","valueList","control","checkbox","radio","dateFormat","block","level","title","listType","listStyle","listWrap","groupIds","conceptId","imgDisplay","imgFloatPosition","imgToolDisabled","textDecoration","extension","externalId","areaId","area","paragraphIndentLeft","paragraphFirstLineIndent","paragraphSpacingBefore","paragraphSpacingAfter","revisionId","revisionType","revisionAuthor","revisionDate"],Xo=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","borderStyle","slashTypes","disabled","deletable"],qe=["tdId","trId","tableId"],Ii=["level","titleId","title"],Yi=["listId","listType","listStyle"],Ei=["control","controlId","controlComponent"],oe=["font","size","bold","highlight","italic","strikeout"],Li=["areaId","area"],ji=[...qe,...Ii,...Yi,...Li],Jt=[R.TEXT,R.HYPERLINK,R.SUBSCRIPT,R.SUPERSCRIPT,R.CONTROL,R.DATE,R.PLACEHOLDER],$o=[R.IMAGE,R.LATEX],Uo=[R.BLOCK,R.PAGE_BREAK,R.SEPARATOR,R.TABLE],Vo=["HR","TABLE","UL","OL"],Go=[R.TITLE,R.LIST],Ko=12,Yo={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF",dragFloatImageDisabled:!1},jo={PAGE_SCALE:"pageScale"},$e={PAGE_NO:"{pageNo}",PAGE_COUNT:"{pageCount}"},Zo={bottom:60,size:12,font:"Microsoft YaHei",color:"#000000",rowFlex:gt.CENTER,format:$e.PAGE_NO,numberType:Vt.ARABIC,disabled:!1,startPageNo:1,fromPageNo:0,maxPageNo:null},qo=[{value:"{pageNo}",label:"1, 2, 3 ...",numberType:Vt.ARABIC},{value:"- {pageNo} -",label:"- 1 -, - 2 -, - 3 - ...",numberType:Vt.ARABIC},{value:"— {pageNo} —",label:"— 1 —, — 2 —, — 3 — ...",numberType:Vt.ARABIC},{value:"第 {pageNo} 页",label:"第 1 页",numberType:Vt.ARABIC},{value:"第 {pageNo} 页 共 {pageCount} 页",label:"第 1 页 共 X 页",numberType:Vt.ARABIC},{value:"{pageNo} / {pageCount}",label:"1 / X",numberType:Vt.ARABIC},{value:"{pageNo} of {pageCount}",label:"1 of X",numberType:Vt.ARABIC},{value:"第{pageNo}页",label:"第一页",numberType:Vt.CHINESE},{value:"第{pageNo}页 共 {pageCount} 页",label:"第一页 共 X 页",numberType:Vt.CHINESE},{value:"{pageNo}",label:"I, II, III ...",numberType:"roman-upper"},{value:"{pageNo}",label:"i, ii, iii ...",numberType:"roman-lower"},{value:"{pageNo}",label:"①, ②, ③ ...",numberType:"circled-number"},{value:"{pageNo}",label:"一, 二, 三 ...",numberType:"chinese-number"},{value:"{pageNo}",label:"壹, 贰, 叁 ...",numberType:"chinese-formal-number"},{value:"{pageNo}",label:"A, B, C ...",numberType:"alphabet-upper"},{value:"{pageNo}",label:"a, b, c ...",numberType:"alphabet-lower"}],Qe=[{label:"宋体",value:"SimSun, serif"},{label:"楷体",value:"KaiTi, serif"},{label:"仿宋",value:"FangSong, serif"},{label:"黑体",value:"SimHei, sans-serif"},{label:"微软雅黑",value:"Microsoft YaHei, sans-serif"},{label:"微软正黑体",value:"Microsoft JhengHei, sans-serif"},{label:"华文新魏",value:"STXinwei, serif"},{label:"思源黑体",value:"Source Han Sans CN, sans-serif"},{label:"思源宋体",value:"Source Han Serif CN, serif"},{label:"Arial",value:"Arial, sans-serif"},{label:"Times New Roman",value:"Times New Roman, serif"},{label:"Segoe UI",value:"Segoe UI, sans-serif"},{label:"Courier New",value:"Courier New, monospace"}],Je=[{label:"初号",value:42},{label:"小初",value:36},{label:"一号",value:26},{label:"小一",value:24},{label:"二号",value:22},{label:"小二",value:18},{label:"三号",value:16},{label:"小三",value:15},{label:"四号",value:14},{label:"小四",value:12},{label:"五号",value:10.5},{label:"小五",value:9},{label:"六号",value:7.5},{label:"小六",value:6.5},{label:"七号",value:5.5},{label:"八号",value:5},{label:"5",value:5},{label:"5.5",value:5.5},{label:"6",value:6},{label:"6.5",value:6.5},{label:"7",value:7},{label:"7.5",value:7.5},{label:"8",value:8},{label:"9",value:9},{label:"10",value:10},{label:"10.5",value:10.5},{label:"11",value:11},{label:"12",value:12},{label:"14",value:14},{label:"16",value:16},{label:"18",value:18},{label:"20",value:20},{label:"22",value:22},{label:"24",value:24},{label:"26",value:26},{label:"28",value:28},{label:"36",value:36},{label:"48",value:48},{label:"72",value:72}],wi=/[0-9.]/,Qo=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,Jo=/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,ts=new RegExp(`${Jo.source}|${Qo.source}`,"g"),es=/[、,。?!;:……「」“”‘’*()【】〔〕〖〗〘〙〚〛《》———﹝﹞–—\\/·.,!?;:`~<>()[\]{}'"|]/,vi=new RegExp(`^[${Y}
2
+ ]`),is={data:"",type:fi.TEXT,width:0,height:0,color:"#AEB5C0",opacity:.3,size:200,font:"Microsoft YaHei",repeat:!1,gap:[10,10],numberType:Vt.ARABIC},ns={defaultFirstSize:21,defaultSecondSize:19,defaultThirdSize:16,defaultFourthSize:14,defaultFifthSize:12,defaultSixthSize:10},os={[Rt.FIRST]:"defaultFirstSize",[Rt.SECOND]:"defaultSecondSize",[Rt.THIRD]:"defaultThirdSize",[Rt.FOURTH]:"defaultFourthSize",[Rt.FIFTH]:"defaultFifthSize",[Rt.SIXTH]:"defaultSixthSize"},ss={[Rt.FIRST]:1,[Rt.SECOND]:2,[Rt.THIRD]:3,[Rt.FOURTH]:4,[Rt.FIFTH]:5,[Rt.SIXTH]:6},rs={H1:Rt.FIRST,H2:Rt.SECOND,H3:Rt.THIRD,H4:Rt.FOURTH,H5:Rt.FIFTH,H6:Rt.SIXTH},ls={[K.DISC]:"•",[K.CIRCLE]:"◦",[K.SQUARE]:"▫︎",[K.CHECKBOX]:"☑️",[K.DIAMOND]:"◆",[K.DASH]:"—",[K.CHECK]:"✓",[K.TRIANGLE]:"▶",[K.STAR]:"★",[K.ARROW]:"▸",[K.DIAMOND_SOLID]:"♦",[K.ANGLE]:">",[K.HOLLOW_CIRCLE]:"○",[K.HOLLOW_SQUARE]:"□",[K.HEART_HOLLOW]:"♡",[K.HASH]:"#",[K.TRIANGLE_SOLID]:"▲",[K.STAR_SOLID]:"☆",[K.HEART_SOLID]:"♥",[K.FLOWER]:"✿",[K.ASTERISK]:"*",[K.HOLLOW_DIAMOND]:"◇",[K.HOLLOW_TRIANGLE]:"▷"},as={[ge.OL]:"ol",[ge.UL]:"ul"},cs={[It.DISC]:"disc",[It.CIRCLE]:"circle",[It.SQUARE]:"square",[It.DECIMAL]:"decimal",[It.DECIMAL_DOT]:"decimal",[It.DECIMAL_PAREN]:"decimal",[It.DECIMAL_CIRCLE]:"decimal",[It.DECIMAL_BRACKET]:"decimal",[It.CHINESE]:"decimal",[It.CHINESE_BRACKET]:"decimal",[It.UPPER_ALPHA]:"upper-alpha",[It.LOWER_ALPHA_DOT]:"lower-alpha",[It.CHECKBOX]:"checkbox",[It.DIAMOND]:"disc",[It.DASH]:"disc",[It.CHECK]:"disc"},Zi={data:"",color:"#DCDFE6",opacity:1,size:16,font:"Microsoft YaHei"},hs={color:"#FFFFFF",image:"",size:ue.COVER,repeat:Ie.NO_REPEAT,applyPageNumbers:[]},ds={top:0,left:5},us={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",strokeStyle:"#ffffff",verticalAlign:Wt.BOTTOM},gs={placeholderColor:"#9c9b9b",bracketColor:"#000000",prefix:"{",postfix:"}",borderWidth:1,borderColor:"#000000",activeBackgroundColor:"",disabledBackgroundColor:"",existValueBackgroundColor:"",noValueBackgroundColor:""},ps={bottom:30,inactiveAlpha:1,maxHeightRadio:ve.HALF,disabled:!1,editable:!0},fs={opacity:.35,backgroundColor:"#F8C4C4",activeOpacity:.35,activeBackgroundColor:"#F8C4C4",disabled:!1,deletable:!0},ms={top:30,inactiveAlpha:1,maxHeightRadio:ve.HALF,disabled:!1,editable:!0},Ds={disabled:!0,color:"#CCCCCC",lineWidth:1.5},Cs={color:"#000000",lineWidth:1,padding:[0,5,0,5],disabled:!0},Is={font:"Microsoft YaHei",fontSize:12,lineDash:[3,1],disabled:!0},Es={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",strokeStyle:"#000000",verticalAlign:Wt.BOTTOM},Ls={lineWidth:1,strokeStyle:"#000000"},ws={tdPadding:[0,0,0,0],defaultTrHeight:6,defaultTrMinHeight:6,defaultColMinWidth:40,defaultBorderColor:"#000000"},vs={size:12,font:"Microsoft YaHei",color:"#000000",disabled:!0,right:20,type:pi.CONTINUITY},Ts={tipDisabled:!0};function qi(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var bs=function l(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;var i,n,r;if(Array.isArray(t)){if(i=t.length,i!=e.length)return!1;for(n=i;n--!==0;)if(!l(t[n],e[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if(r=Object.keys(t),i=r.length,i!==Object.keys(e).length)return!1;for(n=i;n--!==0;)if(!Object.prototype.hasOwnProperty.call(e,r[n]))return!1;for(n=i;n--!==0;){var o=r[n];if(!l(t[o],e[o]))return!1}return!0}return t!==t&&e!==e};const Qi=qi(bs);var xs=ys;function be(l){return l instanceof Buffer?Buffer.from(l):new l.constructor(l.buffer.slice(),l.byteOffset,l.length)}function ys(l){if(l=l||{},l.circles)return Rs(l);const t=new Map;if(t.set(Date,o=>new Date(o)),t.set(Map,(o,a)=>new Map(i(Array.from(o),a))),t.set(Set,(o,a)=>new Set(i(Array.from(o),a))),l.constructorHandlers)for(const o of l.constructorHandlers)t.set(o[0],o[1]);let e=null;return l.proto?r:n;function i(o,a){const s=Object.keys(o),c=new Array(s.length);for(let h=0;h<s.length;h++){const d=s[h],u=o[d];typeof u!="object"||u===null?c[d]=u:u.constructor!==Object&&(e=t.get(u.constructor))?c[d]=e(u,a):ArrayBuffer.isView(u)?c[d]=be(u):c[d]=a(u)}return c}function n(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return i(o,n);if(o.constructor!==Object&&(e=t.get(o.constructor)))return e(o,n);const a={};for(const s in o){if(Object.hasOwnProperty.call(o,s)===!1)continue;const c=o[s];typeof c!="object"||c===null?a[s]=c:c.constructor!==Object&&(e=t.get(c.constructor))?a[s]=e(c,n):ArrayBuffer.isView(c)?a[s]=be(c):a[s]=n(c)}return a}function r(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return i(o,r);if(o.constructor!==Object&&(e=t.get(o.constructor)))return e(o,r);const a={};for(const s in o){const c=o[s];typeof c!="object"||c===null?a[s]=c:c.constructor!==Object&&(e=t.get(c.constructor))?a[s]=e(c,r):ArrayBuffer.isView(c)?a[s]=be(c):a[s]=r(c)}return a}}function Rs(l){const t=[],e=[],i=new Map;if(i.set(Date,s=>new Date(s)),i.set(Map,(s,c)=>new Map(r(Array.from(s),c))),i.set(Set,(s,c)=>new Set(r(Array.from(s),c))),l.constructorHandlers)for(const s of l.constructorHandlers)i.set(s[0],s[1]);let n=null;return l.proto?a:o;function r(s,c){const h=Object.keys(s),d=new Array(h.length);for(let u=0;u<h.length;u++){const g=h[u],p=s[g];if(typeof p!="object"||p===null)d[g]=p;else if(p.constructor!==Object&&(n=i.get(p.constructor)))d[g]=n(p,c);else if(ArrayBuffer.isView(p))d[g]=be(p);else{const f=t.indexOf(p);f!==-1?d[g]=e[f]:d[g]=c(p)}}return d}function o(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return r(s,o);if(s.constructor!==Object&&(n=i.get(s.constructor)))return n(s,o);const c={};t.push(s),e.push(c);for(const h in s){if(Object.hasOwnProperty.call(s,h)===!1)continue;const d=s[h];if(typeof d!="object"||d===null)c[h]=d;else if(d.constructor!==Object&&(n=i.get(d.constructor)))c[h]=n(d,o);else if(ArrayBuffer.isView(d))c[h]=be(d);else{const u=t.indexOf(d);u!==-1?c[h]=e[u]:c[h]=o(d)}}return t.pop(),e.pop(),c}function a(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return r(s,a);if(s.constructor!==Object&&(n=i.get(s.constructor)))return n(s,a);const c={};t.push(s),e.push(c);for(const h in s){const d=s[h];if(typeof d!="object"||d===null)c[h]=d;else if(d.constructor!==Object&&(n=i.get(d.constructor)))c[h]=n(d,a);else if(ArrayBuffer.isView(d))c[h]=be(d);else{const u=t.indexOf(d);u!==-1?c[h]=e[u]:c[h]=a(d)}}return t.pop(),e.pop(),c}}const Fs=qi(xs);var Ps=As;function As(l,t){var e={};typeof t=="string"&&(t=[].slice.call(arguments,1));for(var i=t.length,n=0;n<i;n++){var r=t[n];r in l&&(e[r]=l[r])}return e}var Ss=Os;function Os(l,t){var e={};typeof t=="string"&&(t=[].slice.call(arguments,1));for(var i in l)(!l.hasOwnProperty||l.hasOwnProperty(i))&&t.indexOf(i)===-1&&(e[i]=l[i]);return e}var Bs=Hs;function Hs(l,t,e){var i=null,n=null,r=function(){i&&(clearTimeout(i),n=null,i=null)},o=function(){var s=n;r(),s&&s()},a=function(){if(!t)return l.apply(this,arguments);var s=this,c=arguments,h=e&&!i;if(r(),n=function(){l.apply(s,c)},i=setTimeout(function(){if(i=null,!h){var d=n;return n=null,d()}},t),h)return n()};return a.cancel=r,a.flush=o,a}var Ms=_s;function _s(l,t,e){var i=null,n=null,r=e&&e.leading,o=e&&e.trailing;r==null&&(r=!0),o==null&&(o=!r),r==!0&&(o=!1);var a=function(){i&&(clearTimeout(i),i=null)},s=function(){var h=n;a(),h&&h()},c=function(){var h=r&&!i,d=this,u=arguments;if(n=function(){return l.apply(d,u)},i||(i=setTimeout(function(){if(i=null,o)return n()},t)),h)return h=!1,n()};return c.cancel=a,c.flush=s,c}let ks="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",pt=(l=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(l|=0));for(;l--;)t+=ks[e[l]&63];return t};const Ns=Fs();function Ti(l,t){if(!l||typeof l!="object")return l;let e={};return Array.isArray(l)?e=l.map(i=>Ti(i,t)):Object.keys(l).forEach(i=>{if(!t.includes(i))return e[i]=Ti(l[i],t)}),e}function bt(l){return typeof structuredClone=="function"?structuredClone(l):Ns(l)}function bi(l){return l&&l.nodeType===1&&l.tagName.toLowerCase()==="body"}function ti(l,t,e){if(l&&!bi(l))for(l=l;l;){if(!t||t(l)||bi(l))return t&&!t(l)&&bi(l)?null:l;l=l.parentNode}return null}function Yt(l){const t=[];if(Intl.Segmenter){const e=new Intl.Segmenter().segment(l);for(const{segment:i}of e)t.push(i)}else{const e=new Map;for(const n of l.matchAll(ts))e.set(n.index,n[0]);let i=0;for(;i<l.length;){const n=e.get(i);n?(t.push(n),i+=n.length):(t.push(l[i]),i++)}}return t}function Ws(l,t){const e=document.createElement("a");e.href=l,e.download=t,e.click()}function zs(l,t){return Xs(3,l,t)}function Xs(l,t,e){let i=0,n=0;const r=function(o){i=new Date().getTime()-n<300?i+1:0,n=new Date().getTime(),i>=l-1&&(e(o),i=0)};return t.addEventListener("click",r),()=>{t.removeEventListener("click",r)}}function $s(l){return Array.isArray(l)}function Us(l){return Object.prototype.toString.call(l)==="[object Number]"}function Vs(l){return Object.prototype.toString.call(l)==="[object String]"}function Ji(l){queueMicrotask(()=>{l()})}function Gs(l){const t=["零","一","二","三","四","五","六","七","八","九"],e=["","十","百","千","万","十","百","千","亿","十","百","千","万","十","百","千","亿"];if(!l||isNaN(l))return"零";const i=l.toString().split("");let n="";for(let r=0;r<i.length;r++){const o=i.length-1-r;n=`${e[r]}${n}`,n=`${t[Number(i[o])]}${n}`}return n=n.replace(/零(千|百|十)/g,"零").replace(/十零/g,"十"),n=n.replace(/零+/g,"零"),n=n.replace(/零亿/g,"亿").replace(/零万/g,"万"),n=n.replace(/亿万/g,"亿"),n=n.replace(/零+$/,""),n=n.replace(/^一十/g,"十"),n}function Ue(l,t,e){for(let i=0;i<l.length;i++){const n=l[i],r=t[n];r!==void 0?e[n]=r:delete e[n]}}function Gt(l,t){return Ps(l,t)}function te(l,t){return Ss(l,t)}function Ks(l){const t=new TextEncoder().encode(l),e=Array.from(t,i=>String.fromCharCode(i));return window.btoa(e.join(""))}function Ys(l){let t=l.parentElement;for(;t;){const e=window.getComputedStyle(t).getPropertyValue("overflow-y");if(t.scrollHeight>t.clientHeight&&(e==="auto"||e==="scroll"))return t;t=t.parentElement}return document.documentElement}function js(l,t){const e=l.x,i=l.x+l.width,n=l.y,r=l.y+l.height,o=t.x,a=t.x+t.width,s=t.y,c=t.y+t.height;return!(e>a||i<o||n>c||r<s)}function tn(l){return l==null}function ei(l){return l.replace(/\r\n|\r/g,`
3
+ `)}const Zs=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),qs=typeof navigator<"u"&&/iPad|iPhone/.test(navigator.userAgent),Qs=typeof navigator<"u"&&/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);function xi(l){return Zs?l.metaKey:l.ctrlKey}function Js(l={}){var t,e,i;const n={...ws,...l.table},r={...ms,...l.header},o={...ps,...l.footer},a={...Zo,...l.pageNumber},s={...is,...l.watermark},c={...gs,...l.control},h={...us,...l.checkbox},d={...Es,...l.radio},u={...Yo,...l.cursor},g={...ns,...l.title},p={...Zi,...l.placeholder},f={...fs,...l.group},D={...Is,...l.pageBreak},C={...Ts,...l.zone},I={...hs,...l.background},E={...Ds,...l.lineBreak},w={...Ls,...l.separator},v={...vs,...l.lineNumber},L={...Cs,...l.pageBorder},T={...ds,...l.badge},x={print:{...Ci.print,...(t=l.modeRule)==null?void 0:t.print},readonly:{...Ci.readonly,...(e=l.modeRule)==null?void 0:e.readonly},form:{...Ci.form,...(i=l.modeRule)==null?void 0:i.form}},B={enabled:!0,...l.floatingBar};return{mode:at.EDIT,locale:"zhCN",defaultType:"TEXT",defaultColor:"#000000",defaultFont:"SimSun, serif",defaultSize:14,minSize:5,maxSize:72,defaultRowMargin:1,defaultLineHeight:1,defaultBasicRowMarginHeight:8,defaultTabWidth:32,width:794,height:1123,scale:1,pageGap:20,underlineColor:"#000000",strikeoutColor:"#FF0000",rangeAlpha:.6,rangeColor:"#AECBFA",rangeMinWidth:5,searchMatchAlpha:.6,searchMatchColor:"#FFFF00",searchNavigateMatchColor:"#AAD280",highlightAlpha:.6,highlightMarginHeight:8,resizerColor:"#4182D9",resizerSize:5,marginIndicatorSize:35,marginIndicatorColor:"#BABABA",marginIndicatorDisabled:!1,margins:[96,120,96,120],pageMode:Le.PAGING,renderMode:gi.SPEED,defaultHyperlinkColor:"#0000FF",paperDirection:Ne.VERTICAL,inactiveAlpha:.6,historyMaxRecordCount:100,wordBreak:ui.BREAK_WORD,printPixelRatio:3,maskMargin:[0,0,0,0],letterClass:[ko.ENGLISH],shortcutDisableKeys:[],scrollContainerSelector:"",pageOuterSelectionDisable:!1,...l,table:n,header:r,footer:o,pageNumber:a,watermark:s,control:c,checkbox:h,radio:d,cursor:u,title:g,placeholder:p,group:f,pageBreak:D,zone:C,background:I,lineBreak:E,separator:w,lineNumber:v,pageBorder:L,badge:T,modeRule:x,floatingBar:B,trackChanges:l.trackChanges??!1,revisionInsertColor:l.revisionInsertColor??"#1a73e8",revisionDeleteColor:l.revisionDeleteColor??"#f56c6c",annotationColor:l.annotationColor??"#409eff",revisionColor:l.revisionColor??"#e60000",revisionDisplayMode:l.revisionDisplayMode??"all",showCommentBalloons:l.showCommentBalloons??!0,showRevisionBalloons:l.showRevisionBalloons??!0}}const tr=["allow-scripts","allow-same-origin"];function en(l){const t=[];for(let e=0;e<l.length;e++){const i=l[e],n=Yt(i.value);for(let r=0;r<n.length;r++)t.push({...i,value:n[r]})}return t}function er(l){return l||pt()}function zt(l,t){var e;const{isHandleFirstElement:i=!0,isForceCompensation:n=!1,editorOptions:r,laTexToSVG:o}=t,a=l[0];(n||i&&(a==null?void 0:a.type)!==R.LIST&&(a!=null&&a.type&&a.type!==R.TEXT||!vi.test(a==null?void 0:a.value)))&&l.unshift({value:Y,rowFlex:a==null?void 0:a.rowFlex,listId:a==null?void 0:a.listId,listType:a==null?void 0:a.listType,listStyle:a==null?void 0:a.listStyle,listLevel:a==null?void 0:a.listLevel,listIndent:a==null?void 0:a.listIndent,listHanging:a==null?void 0:a.listHanging,paragraphIndentLeft:a==null?void 0:a.paragraphIndentLeft,paragraphSpacingBefore:a==null?void 0:a.paragraphSpacingBefore,paragraphSpacingAfter:a==null?void 0:a.paragraphSpacingAfter,paragraphFirstLineIndent:a==null?void 0:a.paragraphFirstLineIndent});let s=0;for(;s<l.length;){let c=l[s];if(c.type===R.TITLE){l.splice(s,1);const h=c.valueList||[];if(zt(h,{...t,isHandleFirstElement:!1,isForceCompensation:!1}),h.length){const d=er(c.titleId),u=r.title;for(let g=0;g<h.length;g++){const p=h[g];p.title=c.title,c.level&&(p.titleId=d,p.level=c.level),sr(p)&&(p.size||(p.size=u[os[p.level]]),p.bold===void 0&&(p.bold=!0)),l.splice(s,0,p),s++}}s--}else if(c.type===R.LIST){l.splice(s,1);const h=c.valueList||[];if(zt(h,{...t,isHandleFirstElement:!0,isForceCompensation:!1}),h.length){const d=pt();for(let u=0;u<h.length;u++){const g=h[u];g.listId=d,g.listType=c.listType,g.listStyle=c.listStyle,l.splice(s,0,g),s++}}s--}else if(c.type===R.AREA){l.splice(s,1);const h=(c==null?void 0:c.valueList)||[];if(zt(h,{...t,isHandleFirstElement:!0,isForceCompensation:!0}),h.length){const d=pt();for(let u=0;u<h.length;u++){const g=h[u];if(g.areaId=c.areaId||d,g.area=c.area,g.areaIndex=u,g.type===R.TABLE){const p=g.trList;for(let f=0;f<p.length;f++){const D=p[f];for(let C=0;C<D.tdList.length;C++){const I=D.tdList[C].value;for(let E=0;E<I.length;E++){const w=I[E];w.areaId=c.areaId||d,w.area=c.area}}}}l.splice(s,0,g),s++}}s--}else if(c.type===R.TABLE){const h=c.id||pt();if(c.id=h,c.trList){const{defaultTrMinHeight:d}=r.table;for(let u=0;u<c.trList.length;u++){const g=c.trList[u],p=g.id||pt();g.id=p,(!g.minHeight||g.minHeight<d)&&(g.minHeight=d),g.height<g.minHeight&&(g.height=g.minHeight);for(let f=0;f<g.tdList.length;f++){const D=g.tdList[f],C=D.id||pt();D.id=C,zt(D.value,{...t,isHandleFirstElement:!0,isForceCompensation:!0});for(let I=0;I<D.value.length;I++){const E=D.value[I];E.tdId=C,E.trId=p,E.tableId=h}}}}}else if(c.type===R.HYPERLINK){l.splice(s,1);const h=en(c.valueList||[]);if(h.length){const d=pt();for(let u=0;u<h.length;u++){const g=h[u];g.type=c.type,g.url=c.url,g.hyperlinkId=d,l.splice(s,0,g),s++}}s--}else if(c.type===R.DATE){l.splice(s,1);const h=en(c.valueList||[]);if(h.length){const d=pt();for(let u=0;u<h.length;u++){const g=h[u];g.type=c.type,g.dateFormat=c.dateFormat,g.dateId=d,l.splice(s,0,g),s++}}s--}else if(c.type===R.CONTROL){if(!c.control){s++;continue}const{prefix:h,postfix:d,preText:u,postText:g,value:p,placeholder:f,code:D,type:C,valueSets:I}=c.control,{editorOptions:{control:E,checkbox:w,radio:v}}=t,L=c.controlId||pt();l.splice(s,1);const T=Gt(c,[...ji,...Te]),x=Gt(c.control,oe),B={...x,color:r.control.bracketColor},F=Yt(h||E.prefix);for(let P=0;P<F.length;P++){const S=F[P];l.splice(s,0,{...T,...B,controlId:L,value:S,type:c.type,control:c.control,controlComponent:b.PREFIX}),s++}if(u){const P=Yt(u);for(let S=0;S<P.length;S++){const _=P[S];l.splice(s,0,{...T,...x,controlId:L,value:_,type:c.type,control:c.control,controlComponent:b.PRE_TEXT}),s++}}if(p&&p.length||C===lt.CHECKBOX||C===lt.RADIO||C===lt.SELECT&&D&&(!p||!p.length)){let P=p?bt(p):[];if(C===lt.CHECKBOX){const S=D?D.split(","):[];if(Array.isArray(I)&&I.length){const _=P.reduce((y,N)=>y.concat(N.value.split("").map(k=>({...N,value:k}))),[]);let A=0;for(let y=0;y<I.length;y++){const N=I[y];l.splice(s,0,{...T,...x,controlId:L,value:"",type:c.type,control:c.control,controlComponent:b.CHECKBOX,checkbox:{code:N.code,value:S.includes(N.code)}}),s++;const k=Yt(N.value);for(let z=0;z<k.length;z++){const O=k[z],W=z===k.length-1;l.splice(s,0,{...T,...x,..._[A],controlId:L,value:O===`
4
+ `?Y:O,letterSpacing:W?w.gap:0,control:c.control,controlComponent:b.VALUE}),A++,s++}}}}else if(C===lt.RADIO){if(Array.isArray(I)&&I.length){const S=P.reduce((A,y)=>A.concat(y.value.split("").map(N=>({...y,value:N}))),[]);let _=0;for(let A=0;A<I.length;A++){const y=I[A];l.splice(s,0,{...T,...x,controlId:L,value:"",type:c.type,control:c.control,controlComponent:b.RADIO,radio:{code:y.code,value:D===y.code}}),s++;const N=Yt(y.value);for(let k=0;k<N.length;k++){const z=N[k],O=k===N.length-1;l.splice(s,0,{...T,...x,...S[_],controlId:L,value:z===`
5
+ `?Y:z,letterSpacing:O?v.gap:0,control:c.control,controlComponent:b.VALUE}),_++,s++}}}}else{if((!p||!p.length)&&Array.isArray(I)&&I.length){const S=I.find(_=>_.code===D);S&&(P=[{value:S.value}])}zt(P,{...t,isHandleFirstElement:!1,isForceCompensation:!1});for(let S=0;S<P.length;S++){const _=P[S],A=_.value;l.splice(s,0,{...T,...x,..._,controlId:L,value:A===`
6
+ `?Y:A,type:_.type||R.TEXT,control:c.control,controlComponent:b.VALUE}),s++}}}else if(f){const P={...x,color:r.control.placeholderColor},S=Yt(f);for(let _=0;_<S.length;_++){const A=S[_];l.splice(s,0,{...T,...P,controlId:L,value:A===`
7
+ `?Y:A,type:c.type,control:c.control,controlComponent:b.PLACEHOLDER}),s++}}if(g){const P=Yt(g);for(let S=0;S<P.length;S++){const _=P[S];l.splice(s,0,{...T,...x,controlId:L,value:_,type:c.type,control:c.control,controlComponent:b.POST_TEXT}),s++}}const M=Yt(d||E.postfix);for(let P=0;P<M.length;P++){const S=M[P];l.splice(s,0,{...T,...B,controlId:L,value:S,type:c.type,control:c.control,controlComponent:b.POSTFIX}),s++}s--}else if((!c.type||Jt.includes(c.type)&&c.type!==R.PLACEHOLDER)&&((e=c.value)==null?void 0:e.length)>1){l.splice(s,1);const h=Yt(c.value);for(let d=0;d<h.length;d++)l.splice(s+d,0,{...c,value:h[d]});c=l[s]}if((c.value===`
8
+ `||c.value==`\r
9
+ `)&&(c.value=Y),(c.type===R.IMAGE||c.type===R.BLOCK)&&(c.id=c.id||pt()),c.type===R.LATEX&&o){const{svg:h,width:d,height:u}=o(c.value);c.width=c.width||d,c.height=c.height||u,c.laTexSVG=h,c.id=c.id||pt()}s++}}function ir(l,t){const e=Object.keys(l),i=Object.keys(t);if(e.length!==i.length)return!1;for(let n=0;n<e.length;n++){const r=e[n];if(r!=="value"&&!(r==="groupIds"&&Array.isArray(l[r])&&Array.isArray(t[r])&&Qi(l[r],t[r]))&&l[r]!==t[r])return!1}return!0}function ii(l,t={}){const{extraPickAttrs:e}=t,i=[...zo];e&&i.push(...e);const n={value:l.value===Y?`
10
+ `:l.value};return i.forEach(r=>{const o=l[r];o!==void 0&&(n[r]=o)}),n}function Et(l,t={}){const{extraPickAttrs:e,isClassifyArea:i=!1,isClone:n=!0}=t,r=n?bt(l):l,o=[];let a=0;for(;a<r.length;){let s=r[a];if(a===0&&s.value===Y&&!s.listId&&(!s.type||s.type===R.TEXT)){const h=r[a+1];h&&Te.forEach(d=>{s[d]!==void 0&&h[d]===void 0&&(h[d]=s[d])}),a++;continue}if(s.areaId){const h=s.areaId,d=s.area,u=[];for(;a<r.length;){const p=r[a];if(h!==p.areaId){a--;break}delete p.area,delete p.areaId,u.push(p),a++}const g=Et(u,t);if(i){const p={type:R.AREA,value:"",areaId:h,area:d};p.valueList=g,s=p}else{o.splice(a,0,...g);continue}}else if(s.titleId&&s.level){const h=s.titleId;if(h){const d=s.level,u={type:R.TITLE,title:s.title,titleId:h,value:"",level:d},g=[];for(;a<r.length;){const p=r[a];if(h!==p.titleId){a--;break}delete p.level,delete p.title,g.push(p),a++}u.valueList=Et(g,t),s=u}}else if(s.listId&&s.listType){const h=s.listId;if(h){const d=s.listType,u=s.listStyle,g={type:R.LIST,value:"",listId:h,listType:d,listStyle:u},p=[];for(;a<r.length;){const f=r[a];if(h!==f.listId){a--;break}delete f.listType,delete f.listStyle,p.push(f),a++}g.valueList=Et(p,t),s=g}}else if(s.type===R.TABLE){if(s.pagingId){let h=a+1,d=0;for(;h<r.length;){const u=r[h];if(u.pagingId===s.pagingId)s.height+=u.height,s.trList.push(...u.trList),h++,d++;else break}a+=d}if(s.trList)for(let h=0;h<s.trList.length;h++){const d=s.trList[h];delete d.id;for(let u=0;u<d.tdList.length;u++){const g=d.tdList[u],p={colspan:g.colspan,rowspan:g.rowspan,value:Et(g.value,{...t,isClassifyArea:!1})};Xo.forEach(f=>{const D=g[f];D!==void 0&&(p[f]=D)}),d.tdList[u]=p}}}else if(s.type===R.HYPERLINK){const h=s.hyperlinkId;if(h){const d={type:R.HYPERLINK,value:"",url:s.url},u=[];for(;a<r.length;){const g=r[a];if(h!==g.hyperlinkId){a--;break}delete g.type,delete g.url,u.push(g),a++}d.valueList=Et(u,t),s=d}}else if(s.type===R.DATE){const h=s.dateId;if(h){const d={type:R.DATE,value:"",dateFormat:s.dateFormat},u=[];for(;a<r.length;){const g=r[a];if(h!==g.dateId){a--;break}delete g.type,delete g.dateFormat,u.push(g),a++}d.valueList=Et(u,t),s=d}}else if(s.controlId){const h=s.controlId;if(s.controlComponent===b.PREFIX){const d=[];let u=!1,g=a;for(;g<r.length;){const p=r[g];if(h!==p.controlId)break;p.controlComponent===b.VALUE&&(delete p.control,delete p.controlId,d.push(p)),p.controlComponent===b.POSTFIX&&(u=!0),g++}if(u){const p=Gt(s,oe),f={...s.control,...p},D={...Gt(s,Te),type:R.CONTROL,value:"",control:f,controlId:h};D.control.value=Et(d,t),s=ii(D,{extraPickAttrs:e}),a+=g-a-1}}if(s.controlComponent&&(delete s.control,delete s.controlId,s.controlComponent!==b.VALUE&&s.controlComponent!==b.PRE_TEXT&&s.controlComponent!==b.POST_TEXT)){a++;continue}}const c=ii(s,{extraPickAttrs:e});if(!s.type||s.type===R.TEXT||s.type===R.SUBSCRIPT||s.type===R.SUPERSCRIPT)for(;a<r.length;){const h=r[a+1];if(a++,h&&ir(c,ii(h,{extraPickAttrs:e}))){const d=h.value===Y?`
11
+ `:h.value;c.value+=d}else break}else a++;o.push(c)}return o}function nr(l){switch(window.getComputedStyle(l).textAlign){case"left":case"start":return gt.LEFT;case"center":return gt.CENTER;case"right":case"end":return gt.RIGHT;case"justify":return gt.ALIGNMENT;case"justify-all":return gt.JUSTIFY;default:return gt.LEFT}}function nn(l){return l===gt.ALIGNMENT?"justify":l}function or(l){switch(l){case gt.LEFT:return"flex-start";case gt.CENTER:return"center";case gt.RIGHT:return"flex-end";case gt.ALIGNMENT:case gt.JUSTIFY:return"space-between";default:return"flex-start"}}function sr(l){return!l.type||Jt.includes(l.type)}function rr(l,t){const e=l[t];if(!e)return null;const i=l[t+1];return!e.listId&&e.value===Y&&i&&i.value!==Y&&e.areaId===i.areaId?i:e}function Xt(l,t,e,i){var n,r,o;let a=rr(l,e);if(!a)return;const{isBreakWhenWrap:s=!1,editorOptions:c}=i||{},{mode:h}=c||{};h!==at.DESIGN&&(n=a.title)!=null&&n.disabled&&(a=te(a,Ii));let d=!1;for(let u=0;u<t.length;u++){const g=t[u];if(s&&!a.listId&&vi.test(g.value)&&(d=!0),d||!a.listId&&g.type===R.LIST){const f=[...qe,...Te,...Li];Ue(f,a,g),(r=g.valueList)==null||r.forEach(D=>{Ue(f,a,D)});continue}(o=g.valueList)!=null&&o.length&&Xt(l,g.valueList,e,i);const p=[...ji];xe(g)||p.push(...Te),Ue(p,a,g)}}function lr(l,t){let e="span";l.type===R.SUPERSCRIPT?e="sup":l.type===R.SUBSCRIPT&&(e="sub");const i=document.createElement(e);return i.style.fontFamily=l.font||t.defaultFont,l.rowFlex&&(i.style.textAlign=nn(l.rowFlex)),l.color&&(i.style.color=l.color),l.bold&&(i.style.fontWeight="600"),l.italic&&(i.style.fontStyle="italic"),i.style.fontSize=`${l.size||t.defaultSize}px`,l.highlight&&(i.style.backgroundColor=l.highlight),l.underline&&(i.style.textDecoration="underline"),l.strikeout&&(i.style.textDecoration+=" line-through"),i.innerText=l.value.replace(new RegExp(`${Y}`,"g"),`
12
+ `),i}function on(l){let t=0;const e=new Map;for(let i=0;i<l.length;i++){const n=l[i];if(i===0){if(n.checkbox)continue;n.value=n.value.replace(vi,"")}if(n.listWrap){const r=e.get(t)||[];r.push(n),e.set(t,r)}else{const r=n.value.split(`
13
+ `);for(let o=0;o<r.length;o++){o>0&&(t+=1);const a=r[o],s=e.get(t)||[];s.push({...n,value:a}),e.set(t,s)}}}return e}function ar(l){var t;const e=[];if(!l.length)return e;let i=((t=l[0])==null?void 0:t.rowFlex)||null;e.push({rowFlex:i,data:[l[0]]});for(let n=1;n<l.length;n++){const r=l[n],o=r.rowFlex||null;i===o&&!xe(r)&&!xe(l[n-1])?e[e.length-1].data.push(r):(e.push({rowFlex:o,data:[r]}),i=o)}for(let n=0;n<e.length;n++){const r=e[n];r.data=Et(r.data)}return e}function sn(l,t){const e=Js(t);function i(o){var a,s,c,h,d,u,g,p,f,D,C,I;const E=document.createElement("div");for(let w=0;w<o.length;w++){const v=o[w];if(v.type===R.TABLE){const L=document.createElement("table");L.setAttribute("cellSpacing","0"),L.setAttribute("cellpadding","0"),L.setAttribute("border","0");const T="1px solid #000000";!v.borderType||v.borderType===Kt.ALL?(L.style.borderTop=T,L.style.borderLeft=T):v.borderType===Kt.EXTERNAL&&(L.style.border=T),L.style.width=`${v.width}px`;const x=document.createElement("colgroup");for(let F=0;F<v.colgroup.length;F++){const M=v.colgroup[F],P=document.createElement("col");P.setAttribute("width",`${M.width}`),x.append(P)}L.append(x);const B=v.trList;for(let F=0;F<B.length;F++){const M=document.createElement("tr"),P=B[F];M.style.height=`${P.height}px`;for(let S=0;S<P.tdList.length;S++){const _=document.createElement("td");(!v.borderType||v.borderType===Kt.ALL)&&(_.style.borderBottom=_.style.borderRight="1px solid");const A=P.tdList[S];_.colSpan=A.colspan,_.rowSpan=A.rowspan,_.style.verticalAlign=A.verticalAlign||"top",(a=A.borderTypes)!=null&&a.includes(ne.TOP)&&(_.style.borderTop=T),(s=A.borderTypes)!=null&&s.includes(ne.RIGHT)&&(_.style.borderRight=T),(c=A.borderTypes)!=null&&c.includes(ne.BOTTOM)&&(_.style.borderBottom=T),(h=A.borderTypes)!=null&&h.includes(ne.LEFT)&&(_.style.borderLeft=T);const y=sn(A.value,t);_.innerHTML=y.innerHTML,A.backgroundColor&&(_.style.backgroundColor=A.backgroundColor),M.append(_)}L.append(M)}E.append(L)}else if(v.type===R.HYPERLINK){const L=document.createElement("a");L.innerText=v.valueList.map(T=>T.value).join(""),v.url&&(L.href=v.url),E.append(L)}else if(v.type===R.TITLE){const L=document.createElement(`h${ss[v.level]}`),T=i(v.valueList);L.innerHTML=T.innerHTML,E.append(L)}else if(v.type===R.LIST){const L=document.createElement(as[v.listType]);v.listStyle&&(L.style.listStyleType=cs[v.listStyle]);const T=Et(v.valueList);on(T).forEach(x=>{const B=document.createElement("li"),F=i(x);B.innerHTML=F.innerHTML,L.append(B)}),E.append(L)}else if(v.type===R.IMAGE){const L=document.createElement("img");v.value&&(L.src=v.value,L.width=v.width,L.height=v.height),E.append(L)}else if(v.type===R.BLOCK){if(((d=v.block)==null?void 0:d.type)===Me.VIDEO){const L=(u=v.block.videoBlock)==null?void 0:u.src;if(L){const T=document.createElement("video");T.style.display="block",T.controls=!0,T.src=L,T.width=v.width||(t==null?void 0:t.width)||window.innerWidth,T.height=v.height,E.append(T)}}else if(((g=v.block)==null?void 0:g.type)===Me.IFRAME){const{src:L,srcdoc:T}=v.block.iframeBlock||{};if(L||T){const x=document.createElement("iframe");x.sandbox.add(...tr),x.style.display="block",x.style.border="none",L?x.src=L:T&&(x.srcdoc=T),x.width=`${v.width||(t==null?void 0:t.width)||window.innerWidth}`,x.height=`${v.height}`,E.append(x)}}}else if(v.type===R.SEPARATOR){const L=document.createElement("hr");E.append(L)}else if(v.type===R.CHECKBOX){const L=document.createElement("input");L.type="checkbox",(p=v.checkbox)!=null&&p.value&&L.setAttribute("checked","true"),E.append(L)}else if(v.type===R.RADIO){const L=document.createElement("input");L.type="radio",(f=v.radio)!=null&&f.value&&L.setAttribute("checked","true"),E.append(L)}else if(v.type===R.TAB){const L=document.createElement("span");L.innerHTML=`${Gi}${Gi}`,E.append(L)}else if(v.type===R.CONTROL){const L=document.createElement("span"),T=i(((D=v.control)==null?void 0:D.value)||[]);L.innerHTML=T.innerHTML,E.append(L)}else if(!v.type||v.type===R.LATEX||Jt.includes(v.type)){let L="";if(v.type===R.DATE?L=((C=v.valueList)==null?void 0:C.map(x=>x.value).join(""))||"":L=v.value,!L)continue;const T=lr(v,e);((I=o[w-1])==null?void 0:I.type)===R.TITLE&&(L=L.replace(/^\n/,"")),T.innerText=L.replace(new RegExp(`${Y}`,"g"),`
14
+ `),E.append(T)}}return E}const n=document.createElement("div"),r=ar(l);for(let o=0;o<r.length;o++){const a=r[o],s=!a.rowFlex||a.rowFlex===gt.LEFT,c=document.createElement("div");if(!s){const h=a.data[0];xe(h)?(c.style.display="flex",c.style.justifyContent=or(h.rowFlex)):c.style.textAlign=nn(a.rowFlex)}c.innerHTML=i(a.data).innerHTML,s?c.childNodes.forEach(h=>{n.append(h.cloneNode(!0))}):n.append(c)}return n}function cr(l){if(!l||l.nodeType!==3)return null;const t=l.parentNode,e=t.nodeName==="FONT"?t.parentNode:t,i=nr(e),n=l.textContent,r=window.getComputedStyle(e);if(!n||e.nodeName==="STYLE")return null;const o={value:n,color:r.color,bold:Number(r.fontWeight)>500,italic:r.fontStyle.includes("italic"),size:Math.floor(parseFloat(r.fontSize))};return e.nodeName==="SUB"||r.verticalAlign==="sub"?o.type=R.SUBSCRIPT:(e.nodeName==="SUP"||r.verticalAlign==="super")&&(o.type=R.SUPERSCRIPT),i!==gt.LEFT&&(o.rowFlex=i),r.backgroundColor!=="rgba(0, 0, 0, 0)"&&(o.highlight=r.backgroundColor),r.textDecorationLine.includes("underline")&&(o.underline=!0),r.textDecorationLine.includes("line-through")&&(o.strikeout=!0),o}function ni(l,t){const e=[];function i(o){if(o.nodeType===3){const a=cr(o);a&&e.push(a)}else if(o.nodeType===1){const a=o.childNodes;for(let s=0;s<a.length;s++){const c=a[s];if(c.nodeName==="BR")e.push({value:`
15
+ `});else if(c.nodeName==="A"){const h=c,d=h.innerText;d&&e.push({type:R.HYPERLINK,value:"",valueList:[{value:d}],url:h.href})}else if(/H[1-6]/.test(c.nodeName)){const h=ni(dr(c,"div").outerHTML,t);e.push({value:"",type:R.TITLE,level:rs[c.nodeName],valueList:h}),c.nextSibling&&!Vo.includes(c.nextSibling.nodeName)&&e.push({value:`
16
+ `})}else if(c.nodeName==="UL"||c.nodeName==="OL"){const h=c,d={value:"",type:R.LIST,valueList:[]};c.nodeName==="OL"?d.listType=ge.OL:(d.listType=ge.UL,d.listStyle=h.style.listStyleType),h.querySelectorAll("li").forEach(u=>{const g=ni(u.innerHTML,t);g.forEach(p=>{p.value===`
17
+ `&&(p.listWrap=!0)}),g.unshift({value:`
18
+ `}),d.valueList.push(...g)}),e.push(d)}else if(c.nodeName==="HR")e.push({value:`
19
+ `,type:R.SEPARATOR});else if(c.nodeName==="IMG"){const{src:h,width:d,height:u}=c;h&&d&&u&&e.push({width:d,height:u,value:h,type:R.IMAGE})}else if(c.nodeName==="VIDEO"){const{src:h,width:d,height:u}=c;h&&d&&u&&e.push({value:"",type:R.BLOCK,block:{type:Me.VIDEO,videoBlock:{src:h}},width:d,height:u})}else if(c.nodeName==="IFRAME"){const{src:h,srcdoc:d,width:u,height:g}=c;(h||d)&&u&&g&&e.push({value:"",type:R.BLOCK,block:{type:Me.IFRAME,iframeBlock:{src:h,srcdoc:d}},width:parseInt(u),height:parseInt(g)})}else if(c.nodeName==="TABLE"){const h=c,d={type:R.TABLE,value:`
20
+ `,colgroup:[],trList:[]};if(h.querySelectorAll("tr").forEach(u=>{const g=window.getComputedStyle(u).height.replace("px",""),p={height:Number(g),tdList:[]};u.querySelectorAll("th,td").forEach(f=>{const D=f,C=ni(D.innerHTML,t),I={colspan:D.colSpan,rowspan:D.rowSpan,value:C};D.style.backgroundColor&&(I.backgroundColor=D.style.backgroundColor),p.tdList.push(I)}),d.trList.push(p)}),d.trList.length){const u=d.trList[0].tdList.reduce((p,f)=>p+f.colspan,0),g=Math.ceil(t.innerWidth/u);for(let p=0;p<u;p++)d.colgroup.push({width:g});e.push(d)}}else c.nodeName==="INPUT"&&c.type===b.CHECKBOX?e.push({type:R.CHECKBOX,value:"",checkbox:{value:c.checked}}):c.nodeName==="INPUT"&&c.type===b.RADIO?e.push({type:R.RADIO,value:"",radio:{value:c.checked}}):(i(c),c.nodeType===1&&s!==a.length-1&&window.getComputedStyle(c).display==="block"&&e.push({value:`
21
+ `}))}}}const n=document.createElement("div");n.innerHTML=l,document.body.appendChild(n);const r=[];return n.childNodes.forEach(o=>{var a;o.nodeType!==1&&!((a=o.textContent)!=null&&a.trim())&&r.push(o)}),r.forEach(o=>o.remove()),i(n),n.remove(),e}function hr(l){function t(e){var i,n,r,o,a,s,c;let h="";for(let d=0;d<e.length;d++){const u=e[d];if(u.type===R.TABLE){h+=`
22
+ `;const g=u.trList;for(let p=0;p<g.length;p++){const f=g[p];for(let D=0;D<f.tdList.length;D++){const C=f.tdList[D],I=t(Et(C.value)),E=D===0,w=f.tdList.length-1===D;h+=`${E?"":" "}${I}${w?`
23
+ `:""}`}}}else if(u.type===R.TAB)h+=" ";else if(u.type===R.HYPERLINK)h+=u.valueList.map(g=>g.value).join("");else if(u.type===R.TITLE)h+=`${t(Et(u.valueList))}`;else if(u.type===R.LIST){const g=Et(u.valueList),p=on(g);let f="";u.listType===ge.UL&&(f=ls[u.listStyle]),p.forEach((D,C)=>{const I=p.size-1===C;h+=`
24
+ ${f||`${C+1}.`}${t(D)}${I?`
25
+ `:""}`})}else if(u.type===R.CHECKBOX)h+=(i=u.checkbox)!=null&&i.value?"☑":"□";else if(u.type===R.RADIO)h+=(n=u.radio)!=null&&n.value?"☉":"○";else if(!u.type||u.type===R.LATEX||Jt.includes(u.type)){let g="";if(u.type===R.CONTROL){const p=((o=(r=u.control.value)==null?void 0:r[0])==null?void 0:o.value)||"";g=p?`${((a=u.control)==null?void 0:a.preText)||""}${p}${((s=u.control)==null?void 0:s.postText)||""}`:""}else u.type===R.DATE?g=((c=u.valueList)==null?void 0:c.map(p=>p.value).join(""))||"":g=u.value;h+=g.replace(new RegExp(`${Y}`,"g"),`
26
+ `)}}return h}return t(Et(l))}function yi(l){return Ti(l,["metrics","style"])}function xe(l){return!!(l!=null&&l.type)&&(Uo.includes(l.type)||l.imgDisplay===Q.INLINE)}function dr(l,t){const e=document.createElement(t);for(let i=0;i<l.attributes.length;i++){const n=l.attributes[i];e.setAttribute(n.name,n.value)}return e.innerHTML=l.innerHTML,e}function rn(l){const t=[];for(let e=0;e<l.length;e++){const i=l[e];i.imgDisplay===Q.SURROUND&&t.push(i)}return t}function ur(l,t){var e;for(let i=l.length-1;i>=0;i--)((e=l[i].imgFloatPosition)==null?void 0:e.pageNo)===t&&l.splice(i,1)}function oi(l){return l.value===Y&&!l.listWrap}function Ve(l){return l.type===R.TABLE}function Ge(l){return l.type===R.IMAGE}function Ke(l,t,e=ie.BEFORE){var i,n,r,o,a,s,c,h,d,u,g,p;if(!((n=(i=l[t])==null?void 0:i.control)!=null&&n.hide)&&!((o=(r=l[t])==null?void 0:r.area)!=null&&o.hide))return t;let f=t;if(e===ie.BEFORE)for(f=t-1;f>0;){if(!((s=(a=l[f])==null?void 0:a.control)!=null&&s.hide)&&!((h=(c=l[f])==null?void 0:c.area)!=null&&h.hide))return f;f--}else for(f=t+1;f<l.length;){if(!((u=(d=l[f])==null?void 0:d.control)!=null&&u.hide)&&!((p=(g=l[f])==null?void 0:g.area)!=null&&p.hide))return f;f++}return f}const ln=Mo;class an{constructor(...t){}undo(...t){}redo(...t){}recovery(...t){}clear(...t){}popUndo(...t){}isStackEmpty(...t){return!0}isCanUndo(...t){return!1}isCanRedo(...t){return!1}execute(...t){}destroy(...t){}}class cn{constructor(...t){}destroy(...t){}}class hn{constructor(...t){}t(t,...e){return t}registerLangMap(...t){}destroy(...t){}}class dn{constructor(...t){}}class un{constructor(...t){}render(...t){}}class gn{constructor(...t){}render(...t){}renderDatePicker(...t){}clearDatePicker(...t){}destroy(...t){}}class pn{constructor(...t){}render(...t){}clear(...t){}destroy(...t){}}class fn{constructor(...t){}render(...t){}destroy(...t){}}function gr(l){if(!(typeof localStorage>"u"))try{localStorage.setItem(Di,JSON.stringify({text:l.text,elementList:l.elementList}))}catch{}}function Ri(){if(typeof localStorage>"u")return null;try{const l=localStorage.getItem(Di);if(!l)return null;const t=JSON.parse(l);if(typeof(t==null?void 0:t.text)=="string"&&Array.isArray(t==null?void 0:t.elementList))return t}catch{}return null}function mn(l){return Array.from(l.items).some(t=>t.kind==="file")}function Fi(){if(!(typeof localStorage>"u"))try{localStorage.removeItem(Di)}catch{}}function Dn(l){if(typeof document>"u"||typeof window>"u")return;const t=document.createElement("div");t.setAttribute("contenteditable","true"),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",t.style.opacity="0",t.innerHTML=l;const e=window.getSelection(),i=[];if(e)for(let o=0;o<e.rangeCount;o++)i.push(e.getRangeAt(o).cloneRange());const n=document.createRange(),r=document.createElement("span");r.innerText=`
27
+ `,t.append(r),document.body.append(t),n.selectNodeContents(t),e==null||e.removeAllRanges(),e==null||e.addRange(n);try{document.execCommand("copy")}finally{e==null||e.removeAllRanges(),i.forEach(o=>e==null?void 0:e.addRange(o)),t.remove()}}function pr(l,t,e){var r;if(!l&&!t&&!e.length||(gr({text:l,elementList:e}),typeof window>"u"))return;const i=(r=window.navigator)==null?void 0:r.clipboard,n=window.ClipboardItem;if(i!=null&&i.write&&n){const o=new Blob([l],{type:"text/plain"}),a=new Blob([t],{type:"text/html"}),s=new n({[o.type]:o,[a.type]:a});i.write([s]).catch(()=>Dn(t));return}Dn(t)}function Cn(l,t){if(typeof document>"u")return JSON.stringify(l);const e=sn(l,t);document.body.append(e);const i=e.innerText,n=e.innerHTML;return e.remove(),!i&&!n&&!l.length?"":(pr(i,n,Et(l)),i)}function Pi(l,t){const e=l.getDraw();if(e.isReadonly()||e.isDisabled()||e.getControl().getIsDisabledPasteControl())return;const i=e.getRange(),{startIndex:n}=i.getRange(),r=e.getElementList();if(~n&&!i.getIsSelectAll()){const o=r[n];if(o!=null&&o.titleId||o!=null&&o.listId){let a=0;for(;a<t.length;){const s=t[a];if(o.titleId&&/^\n/.test(s.value))break;if(Go.includes(s.type)){if(t.splice(a,1),s.valueList)for(let c=0;c<s.valueList.length;c++){const h=s.valueList[c];h.value===Y||h.value===`
28
+ `||(t.splice(a,0,h),a++)}a--}a++}}Xt(r,t,n,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function In(l,t){const e=l.getDraw();if(e.isReadonly()||e.isDisabled())return;const i=ni(t,{innerWidth:e.getOriginalInnerWidth()});Pi(l,i)}function Ai(l,t){const e=l.getDraw();if(e.isReadonly()||e.isDisabled())return;const i=e.getRange(),{startIndex:n}=i.getRange(),r=e.getElementList(),o=new FileReader;o.readAsDataURL(t),o.onload=()=>{const a=new Image,s=o.result;a.src=s,a.onload=()=>{const c={value:s,type:R.IMAGE,width:a.width,height:a.height};~n&&Xt(r,[c],n,{editorOptions:e.getOptions()}),e.insertElementList([c])}}}function fr(l,t){const e=l.getDraw();if(e.isReadonly()||e.isDisabled())return;const i=t.clipboardData;if(!i)return;const{paste:n}=e.getOverride();if(n){const o=n(t);if((o==null?void 0:o.preventDefault)!==!1)return}if(!mn(i)){const o=i.getData("text"),a=Ri();if(a&&ei(o)===ei(a.text)){Pi(l,a.elementList);return}}Fi();let r=!1;for(let o=0;o<i.items.length;o++)if(i.items[o].type==="text/html"){r=!0;break}for(let o=0;o<i.items.length;o++){const a=i.items[o];if(a.kind==="string"){if(a.type==="text/plain"&&!r){a.getAsString(s=>{l.input(s)});break}if(a.type==="text/html"&&r){a.getAsString(s=>{In(l,s)});break}}else if(a.kind==="file"&&a.type.includes("image")){const s=a.getAsFile();s&&Ai(l,s)}}}async function mr(l,t){const e=l.getDraw();if(e.isReadonly()||e.isDisabled())return;const{paste:i}=e.getOverride();if(i){const o=i();if((o==null?void 0:o.preventDefault)!==!1)return}const n=Ri();let r="";try{r=await navigator.clipboard.readText()}catch{r=(n==null?void 0:n.text)||""}if(n&&ei(r)===ei(n.text)){Pi(l,n.elementList);return}if(Fi(),t!=null&&t.isPlainText)r&&l.input(r);else{let o=[];try{o=await navigator.clipboard.read()}catch{r&&l.input(r);return}let a=!1;for(const s of o)if(s.types.includes("text/html")){a=!0;break}for(const s of o)if(s.types.includes("text/plain")&&!a){const h=await(await s.getType("text/plain")).text();h&&l.input(h)}else if(s.types.includes("text/html")&&a){const h=await(await s.getType("text/html")).text();h&&In(l,h)}else if(s.types.some(c=>c.startsWith("image/"))){const c=s.types.find(d=>d.startsWith("image/")),h=await s.getType(c);Ai(l,h)}}}class En{constructor(t,e){m(this,"draw");m(this,"container");m(this,"agentCursorDom");m(this,"canvasEvent");m(this,"eventBus");this.draw=t,this.container=t.getContainer(),this.canvasEvent=e,this.eventBus=t.getEventBus();const i=document.createElement("textarea");i.autocomplete="off",i.classList.add(`${J}-inputarea`),i.innerText="",this.container.append(i),this.agentCursorDom=i,i.onkeydown=n=>this._keyDown(n),i.oninput=this._input.bind(this),i.onpaste=n=>this._paste(n),i.addEventListener("compositionstart",this._compositionstart.bind(this)),i.addEventListener("compositionend",this._compositionend.bind(this))}getAgentCursorDom(){return this.agentCursorDom}_keyDown(t){this.canvasEvent.keydown(t)}_input(t){const e=t.data;e&&this.canvasEvent.input(e),this.eventBus.hasSubscribers("input")&&this.eventBus.emit("input",t)}_paste(t){this.draw.isReadonly()||!t.clipboardData||(fr(this.canvasEvent,t),t.preventDefault())}_compositionstart(){this.canvasEvent.compositionstart()}_compositionend(t){this.canvasEvent.compositionend(t)}}class Ln{constructor(t,e){m(this,"ANIMATION_CLASS",`${J}-cursor--animation`);m(this,"draw");m(this,"container");m(this,"options");m(this,"position");m(this,"cursorDom");m(this,"cursorAgent");m(this,"blinkTimeout");m(this,"hitLineStartIndex");this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${J}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new En(t,e),this.blinkTimeout=null}getCursorDom(){return this.cursorDom}getAgentDom(){return this.cursorAgent.getAgentCursorDom()}getAgentIsActive(){return this.getAgentDom()===document.activeElement}getAgentDomValue(){return this.getAgentDom().value}clearAgentDomValue(){this.getAgentDom().value=""}getHitLineStartIndex(){return this.hitLineStartIndex}_blinkStart(){this.cursorDom.classList.add(this.ANIMATION_CLASS)}_blinkStop(){this.cursorDom.classList.remove(this.ANIMATION_CLASS)}_setBlinkTimeout(){this._clearBlinkTimeout(),this.blinkTimeout=window.setTimeout(()=>{this._blinkStart()},500)}_clearBlinkTimeout(){this.blinkTimeout&&(this._blinkStop(),window.clearTimeout(this.blinkTimeout),this.blinkTimeout=null)}focus(){if(Qs&&this.draw.isReadonly())return;const t=this.cursorAgent.getAgentCursorDom();document.activeElement!==t&&(t.focus(),t.setSelectionRange(0,0))}drawCursor(t){let e=this.position.getCursorPosition();if(!e)return;const{scale:i,cursor:n}=this.options,{color:r,width:o,isShow:a=!0,isBlink:s=!0,isFocus:c=!0,hitLineStartIndex:h}={...n,...t},d=this.draw.getHeight(),u=this.draw.getPageGap();this.hitLineStartIndex=h,h&&(e=this.position.getPositionList()[h]);const{metrics:g,coordinate:{leftTop:p,rightTop:f},ascent:D,pageNo:C}=e,w=(this.draw.getZone().isMainActive()?C:this.draw.getPageNo())*(d+u),v=Ko*i,L=Math.min(g.height/4,v),T=g.height+L*2,x=this.cursorAgent.getAgentCursorDom();c&&setTimeout(()=>{this.focus()});const B=g.boundingBoxDescent<0?0:g.boundingBoxDescent,F=p[1]+D+B-(T-L)+w,M=h?p[0]:f[0];if(x.style.left=`${M}px`,x.style.top=`${F+T-v}px`,!a){this.recoveryCursor();return}const P=this.draw.isReadonly();this.cursorDom.style.width=`${o*i}px`,this.cursorDom.style.backgroundColor=r,this.cursorDom.style.left=`${M}px`,this.cursorDom.style.top=`${F}px`,this.cursorDom.style.display=P?"none":"block",this.cursorDom.style.height=`${T}px`,s?this._setBlinkTimeout():this._clearBlinkTimeout()}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:i}=t;if(!e||!i)return;const{pageNo:n,coordinate:{leftTop:r,leftBottom:o}}=e,a=n*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,s=i===St.UP,c=o[0],h=s?r[1]+a:o[1]+a,d=Ys(this.container),u={left:0,right:0,top:0,bottom:0};if(d===document.documentElement)u.right=window.innerWidth,u.bottom=window.innerHeight;else{const{left:p,right:f,top:D,bottom:C}=d.getBoundingClientRect();u.left=p,u.right=f,u.top=D,u.bottom=C}const{maskMargin:g}=this.options;if(u.top+=g[0],u.bottom-=g[2],!(c>=u.left&&c<=u.right&&h>=u.top&&h<=u.bottom)){const{scrollLeft:p,scrollTop:f}=d;s?d.scroll(p,f-(u.top-h)):d.scroll(p,f+h-u.bottom)}}}class Ye{constructor(t,e){m(this,"element");m(this,"control");this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getCode(){var t;return((t=this.element.control)==null?void 0:t.code)||null}getValue(){const t=this.control.getElementList(),{startIndex:e}=this.control.getRange(),i=t[e],n=[];let r=e;for(;r>0;){const a=t[r];if(a.controlId!==i.controlId||a.controlComponent===b.PREFIX||a.controlComponent===b.PRE_TEXT)break;a.controlComponent===b.VALUE&&n.unshift(a),r--}let o=e+1;for(;o<t.length;){const a=t[o];if(a.controlId!==i.controlId||a.controlComponent===b.POSTFIX||a.controlComponent===b.POST_TEXT)break;a.controlComponent===b.VALUE&&n.push(a),o++}return n}setValue(){return-1}setSelect(t,e={},i={}){if(!i.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:n}=this.element,r=e.elementList||this.control.getElementList(),{startIndex:o}=e.range||this.control.getRange(),a=r[o];let s=o;for(;s>0;){const h=r[s];if(h.controlId!==a.controlId||h.controlComponent===b.PREFIX||h.controlComponent===b.PRE_TEXT)break;if(h.controlComponent===b.CHECKBOX){const d=h.checkbox;d.value=t.includes(d.code)}s--}let c=o+1;for(;c<r.length;){const h=r[c];if(h.controlId!==a.controlId||h.controlComponent===b.POSTFIX||h.controlComponent===b.POST_TEXT)break;if(h.controlComponent===b.CHECKBOX){const d=h.checkbox;d.value=t.includes(d.code)}c++}n.code=t.join(","),this.control.repaintControl({curIndex:o,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:n}=e;return t.key===wt.Backspace||t.key===wt.Delete?this.control.removeControl(i):n}cut(){return-1}}class si extends Ye{setSelect(t,e={},i={}){if(!i.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:n}=this.element,r=e.elementList||this.control.getElementList(),{startIndex:o}=e.range||this.control.getRange(),a=r[o];let s=o;for(;s>0;){const h=r[s];if(h.controlId!==a.controlId||h.controlComponent===b.PREFIX||h.controlComponent===b.PRE_TEXT)break;if(h.controlComponent===b.RADIO){const d=h.radio;d.value=t.includes(d.code)}s--}let c=o+1;for(;c<r.length;){const h=r[c];if(h.controlId!==a.controlId||h.controlComponent===b.POSTFIX||h.controlComponent===b.POST_TEXT)break;if(h.controlComponent===b.RADIO){const d=h.radio;d.value=t.includes(d.code)}c++}n.code=t.join(","),this.control.repaintControl({curIndex:o,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}}function wn(l){const t=l.getDraw(),e=t.getPosition(),i=t.getRange();l.isAllowDrag=!0,l.cacheRange=bt(i.getRange()),l.cacheElementList=t.getElementList(),l.cachePositionList=e.getPositionList(),l.cachePositionContext=e.getPositionContext()}function vn(l,t){const{checkbox:e,control:i}=l;if(!i)t.getCheckboxParticle().setSelect(l);else{const n=i!=null&&i.code?i.code.split(","):[];if(e!=null&&e.value){const o=n.findIndex(a=>a===e.code);n.splice(o,1)}else e!=null&&e.code&&n.push(e.code);const r=t.getControl().getActiveControl();r instanceof Ye&&r.setSelect(n)}}function Tn(l,t){const{radio:e,control:i}=l;if(!i)t.getRadioParticle().setSelect(l);else{const n=e!=null&&e.code?[e.code]:[],r=t.getControl().getActiveControl();r instanceof si&&r.setSelect(n)}}function Dr(l,t){var _,A;const e=t.getDraw(),i=e.isReadonly(),n=e.getRange(),r=e.getPosition(),o=n.getRange();if(l.button===Ui.RIGHT&&(o.isCrossRowCol||!n.getIsCollapsed()))return;if(!t.isAllowDrag&&!i&&o.startIndex!==o.endIndex&&n.getIsPointInRange(l.offsetX,l.offsetY)){wn(t);return}const s=l.target.dataset.index;s&&e.setPageNo(Number(s)),t.isAllowSelection=!0;const c=bt(r.getPositionContext()),h=r.adjustPositionContext({x:l.offsetX,y:l.offsetY});if(!h)return;const{index:d,isDirectHit:u,isCheckbox:g,isRadio:p,isImage:f,isTable:D,tdValueIndex:C,hitLineStartIndex:I}=h;t.mouseDownStartPosition={...h,index:D?C:d,x:l.offsetX,y:l.offsetY};const E=e.getElementList(),w=r.getPositionList(),v=D?C:d,L=E[v],T=!!(u&&f),x=!!(u&&g),B=!!(u&&p);if(~d){let y=v,N=v;if(l.shiftKey){const{startIndex:k}=n.getRange();~k&&r.getPositionContext().tdId===c.tdId&&(v>k?y=k:N=k)}if(n.setRange(y,N),r.setCursorPosition(w[v]),x&&!i)vn(L,e);else if(B&&!i)Tn(L,e);else if(L.controlComponent===b.VALUE&&(((_=L.control)==null?void 0:_.type)===lt.CHECKBOX||((A=L.control)==null?void 0:A.type)===lt.RADIO)){let k=v;for(;k>0;){const z=E[k];if(z.controlComponent===b.CHECKBOX){vn(z,e);break}else if(z.controlComponent===b.RADIO){Tn(z,e);break}k--}}else e.render({curIndex:v,isCompute:!1,isSubmitHistory:!1,isSetCursor:!T&&!x&&!B});I&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:I})}const F=e.getPreviewer();if(F.clearResizer(),T){const y={dragDisable:i||!L.controlId&&e.getMode()===at.FORM};L.type===R.LATEX&&(y.mime="svg",y.srcKey="laTexSVG"),F.drawResizer(L,w[v],y),e.getCursor().drawCursor({isShow:!1}),wn(t),(L.imgDisplay===Q.SURROUND||L.imgDisplay===Q.FLOAT_TOP||L.imgDisplay===Q.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(L);const N=e.getEventBus();N.hasSubscribers("imageMousedown")&&N.emit("imageMousedown",{evt:l,element:L})}const M=e.getTableTool();M.dispose(),D&&!i&&e.getMode()!==at.FORM&&M.render();const P=e.getHyperlinkParticle();P.clearHyperlinkPopup(),L.type===R.HYPERLINK&&(xi(l)?P.openHyperlink(L):P.drawHyperlinkPopup(L,w[v]));const S=e.getDateParticle();S.clearDatePicker(),L.type===R.DATE&&!i&&S.renderDatePicker(L,w[v])}function ri(l){const t=pt();return Reflect.set(l,"dragId",t),t}function li(l,t){return t.findIndex(e=>e.dragId===l)}function bn(l,t,e){const i=e.getDraw();if(l.imgDisplay===Q.SURROUND||l.imgDisplay===Q.FLOAT_TOP||l.imgDisplay===Q.FLOAT_BOTTOM){const n=t.offsetX-e.mouseDownStartPosition.x,r=t.offsetY-e.mouseDownStartPosition.y,o=l.imgFloatPosition;l.imgFloatPosition={x:o.x+n,y:o.y+r,pageNo:i.getPageNo()}}i.getImageParticle().destroyFloatImage()}function Cr(l,t){var e,i,n,r,o,a;if(t.isAllowDrop){const s=t.getDraw();if(s.isReadonly()||s.isDisabled()){t.mousedown(l);return}const c=s.getPosition(),h=c.getPositionList(),d=c.getPositionContext(),u=s.getRange(),g=t.cacheRange,p=t.cacheElementList,f=t.cachePositionList,D=t.cachePositionContext,C=u.getRange(),I=g.startIndex===g.endIndex,E=I?g.startIndex-1:g.startIndex,w=g.endIndex;if(C.startIndex>=E&&C.endIndex<=w&&((e=t.cachePositionContext)==null?void 0:e.tdId)===d.tdId){s.clearSideEffect();let H=!1,ht=!1;if(I){const Pt=p[w];if(Pt.type===R.IMAGE||Pt.type===R.LATEX){if(bn(Pt,l,t),Pt.imgDisplay===Q.SURROUND||Pt.imgDisplay===Q.FLOAT_TOP||Pt.imgDisplay===Q.FLOAT_BOTTOM)s.getPreviewer().drawResizer(Pt),H=!0;else{const _t=f[w];s.getPreviewer().drawResizer(Pt,_t)}ht=Pt.imgDisplay===Q.SURROUND}}u.replaceRange({...g}),s.render({isCompute:ht,isSubmitHistory:H,isSetCursor:!1});return}const v=p.slice(E+1,w+1),L=v.find(H=>H.controlId);if(L){const H=p[E+1],ht=p[w];if(!((!H.controlId||H.controlComponent===b.PREFIX)&&(!ht.controlId||ht.controlComponent===b.POSTFIX)||H.controlId===ht.controlId&&H.controlComponent===b.PREFIX&&ht.controlComponent===b.POSTFIX||((i=H.control)==null?void 0:i.type)===lt.TEXT&&H.controlComponent===b.VALUE&&((n=ht.control)==null?void 0:n.type)===lt.TEXT&&ht.controlComponent===b.VALUE)){s.render({curIndex:C.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const T=s.getControl(),x=s.getElementList(),B=!L||!!x[C.startIndex].controlId||!T.getIsElementListContainFullControl(v),F=s.getOptions(),M=v.map(H=>{if(!H.type||H.type===R.TEXT){const ht={value:H.value},Pt=fe;return B||Pt.push(...Ei),Pt.forEach(_t=>{const re=H[_t];re!==void 0&&(ht[_t]=re)}),ht}else{let ht=bt(H);return B&&(ht=te(ht,Ei)),zt([ht],{isHandleFirstElement:!1,editorOptions:F}),ht}});Xt(x,M,C.startIndex,{editorOptions:s.getOptions()});const P=p[E],S=f[E],_=ri(p[E]),A=ri(p[w]),y=M.length;let N=C.startIndex,k=N+y;const z=T.getActiveControl();if(z&&p[N].controlComponent!==b.POSTFIX?(k=z.setValue(M),N=k-y):s.spliceElementList(x,N+1,0,M),!~k){s.render({isSetCursor:!1});return}const O=ri(x[N]),W=ri(x[k]),V=li(_,p),U=li(A,p),it=p[U];if(it.controlId&&it.controlComponent!==b.POSTFIX)u.replaceRange({...g,startIndex:V,endIndex:U}),(r=T.getActiveControl())==null||r.cut();else{let H=!0;if(D!=null&&D.isTable){const{tableId:ht,trIndex:Pt,tdIndex:_t}=D;H=!s.getOriginalElementList().some(me=>{var $,le,ae,ce;return me.id===ht&&((ce=(ae=(le=($=me==null?void 0:me.trList)==null?void 0:$[Pt])==null?void 0:le.tdList)==null?void 0:ae[_t])==null?void 0:ce.deletable)===!1})}H&&s.spliceElementList(p,V+1,U-V)}const Z=x[C.startIndex],tt=h[C.startIndex];let nt=d.index;nt&&(Z.tableId&&!P.tableId?S.index<nt&&(nt-=y):!Z.tableId&&P.tableId&&tt.index<nt&&(nt+=y),c.setPositionContext({...d,index:nt}));const Mt=li(O,x),j=li(W,x);u.setRange(I?j:Mt,j,C.tableId,C.startTdIndex,C.endTdIndex,C.startTrIndex,C.endTrIndex),s.clearSideEffect();let G=null;if(I){const ht=s.getElementList()[j];(ht.type===R.IMAGE||ht.type===R.LATEX)&&(bn(ht,l,t),G=ht)}if(s.render({isSetCursor:!1}),z?T.emitControlContentChange():P.controlId&&T.emitControlContentChange({context:{range:g,elementList:p},controlElement:P}),G)if(G.imgDisplay===Q.SURROUND||G.imgDisplay===Q.FLOAT_TOP||G.imgDisplay===Q.FLOAT_BOTTOM)s.getPreviewer().drawResizer(G);else{const ht=c.getPositionList()[j];s.getPreviewer().drawResizer(G,ht)}}else t.isAllowDrag&&((o=t.cacheRange)==null?void 0:o.startIndex)!==((a=t.cacheRange)==null?void 0:a.endIndex)&&t.mousedown(l)}function Ir(l,t){const e=t.getDraw();if(!e.getOptions().pageOuterSelectionDisable)return;const i=e.getPageContainer(),{x:n,y:r,width:o,height:a}=i.getBoundingClientRect();l.x>=n&&l.x<=n+o&&l.y>=r&&l.y<=r+a||t.setIsAllowSelection(!1)}function Er(l,t){var L;const e=t.getDraw();if(t.isAllowDrag){const T=l.offsetX,x=l.offsetY,{startIndex:B,endIndex:F}=t.cacheRange,M=t.cachePositionList;for(let S=B+1;S<=F;S++){const{coordinate:{leftTop:_,rightBottom:A}}=M[S];if(T>=_[0]&&T<=A[0]&&x>=_[1]&&x<=A[1])return}const P=(L=t.cacheRange)==null?void 0:L.startIndex;if(P){const S=t.cacheElementList[P];(S==null?void 0:S.type)===R.IMAGE&&(S.imgDisplay===Q.SURROUND||S.imgDisplay===Q.FLOAT_TOP||S.imgDisplay===Q.FLOAT_BOTTOM)&&(e.getPreviewer().clearResizer(),e.getImageParticle().dragFloatImage(l.movementX,l.movementY))}t.dragover(l),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const n=l.target.dataset.index;n&&e.setPageNo(Number(n));const r=e.getPosition(),o=r.getPositionByXY({x:l.offsetX,y:l.offsetY});if(!~o.index)return;const{index:a,isTable:s,tdValueIndex:c,tdIndex:h,trIndex:d,tableId:u,trId:g,tdId:p}=o,{index:f,isTable:D,tdIndex:C,trIndex:I,tableId:E}=t.mouseDownStartPosition,w=s?c:a,v=e.getRange();if(s&&D&&(h!==C||d!==I))v.setRange(w,w,u,C,h,I,d),r.setPositionContext({isTable:s,index:a,trIndex:d,tdIndex:h,tdId:p,trId:g,tableId:u});else{let T=~w?w:0;if((D||s)&&E!==u)return;let x=f;if(x>T&&([x,T]=[T,x]),x===T)return;const B=e.getElementList(),F=B[x+1],M=B[T];if((F==null?void 0:F.controlComponent)===b.PLACEHOLDER&&(M==null?void 0:M.controlComponent)===b.PLACEHOLDER&&F.controlId===M.controlId)return;v.setRange(x,T)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function Lr(l,t){var u,g;const e=t.getDraw();if(e.isReadonly())return;const i=e.getRange();if(!i.canInput())return;const r=e.getOptions().trackChanges,o=e.getControl(),a=e.getPosition();if(i.getIsCollapsed()){const p=i.getRange(),D=e.getElementList()[p.startIndex];if((u=D.control)!=null&&u.hide||(g=D.area)!=null&&g.hide){const C=o.removeControl(p.startIndex);if(C){p.startIndex=C,p.endIndex=C,i.replaceRange(p);const I=a.getPositionList();a.setCursorPosition(I[C])}}}const{startIndex:s,endIndex:c,isCrossRowCol:h}=i.getRange();let d;if(h){const p=e.getTableParticle().getRangeRowCol();if(!p)return;let f=!1;for(let D=0;D<p.length;D++){const C=p[D];for(let I=0;I<C.length;I++){const E=C[I];E.value.length>1&&(e.spliceElementList(E.value,1,E.value.length-1),f=!0)}}d=f?0:null}else if(o.getActiveControl()&&o.getIsRangeCanCaptureEvent())d=o.keydown(l),d&&o.emitControlContentChange();else{const p=a.getCursorPosition();if(!p)return;const{index:f}=p,D=i.getIsCollapsed(),C=e.getElementList();if(D&&f===0){const E=C[f];if(E.value===Y){E.listId&&e.getListParticle().unsetList(),l.preventDefault();return}}const I=C[s];if(D&&I.rowFlex&&I.value===Y){const E=i.getRangeRowElementList();if(E){const w=C[s-1];E.forEach(v=>{v.rowFlex=w==null?void 0:w.rowFlex})}}if(D)if(r){const E=C[f];if(E&&!E.revisionId){let w=null;for(let v=f+1;v<C.length;v++){const L=C[v];if(L&&L.revisionType==="delete"&&L.revisionAuthor==="当前用户"){w=L;break}if(L&&!L.revisionId)break}w?(E.revisionId=w.revisionId,E.revisionType="delete",E.revisionAuthor=w.revisionAuthor,E.revisionDate=w.revisionDate):(E.revisionId="rev_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),E.revisionType="delete",E.revisionAuthor="当前用户",E.revisionDate=new Date().toISOString())}d=f-1}else e.spliceElementList(C,f,1),d=f-1;else if(r){for(let E=s+1;E<=c;E++){const w=C[E];w&&!w.revisionId&&(w.revisionId="rev_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),w.revisionType="delete",w.revisionAuthor="当前用户",w.revisionDate=new Date().toISOString())}d=s}else e.spliceElementList(C,s+1,c-s),d=s}e.getGlobalEvent().setCanvasEventAbility(),d===null?(i.setRange(s,s),e.render({curIndex:s,isSubmitHistory:!1,isPartialRender:!0})):(i.setRange(d,d),e.render({curIndex:d,isPartialRender:!0}))}function wr(l,t){var u,g,p;const e=t.getDraw();if(e.isReadonly())return;const i=e.getRange();if(!i.canInput())return;const r=e.getOptions().trackChanges,{startIndex:o,endIndex:a,isCrossRowCol:s}=i.getRange(),c=e.getElementList(),h=e.getControl();if(i.getIsCollapsed()){const f=c[o+1];if((u=f==null?void 0:f.control)!=null&&u.hide||(g=f==null?void 0:f.area)!=null&&g.hide){const D=h.removeControl(o+1);if(D){const C=e.getPosition(),I=C.getPositionList();C.setCursorPosition(I[D])}}}let d;if(s){const f=e.getTableParticle().getRangeRowCol();if(!f)return;let D=!1;for(let C=0;C<f.length;C++){const I=f[C];for(let E=0;E<I.length;E++){const w=I[E];w.value.length>1&&(e.spliceElementList(w.value,1,w.value.length-1),D=!0)}}d=D?0:null}else if(h.getActiveControl()&&h.getIsRangeWithinControl())d=h.keydown(l),d&&h.emitControlContentChange();else if((p=c[a+1])!=null&&p.controlId)d=h.removeControl(a+1);else{const f=e.getPosition(),D=f.getCursorPosition();if(!D)return;const{index:C}=D,I=f.getPositionContext();if(I.isDirectHit&&I.isImage)e.spliceElementList(c,C,1),d=C-1;else if(i.getIsCollapsed()){if(!c[C+1])return;if(r){const w=c[C+1];if(w&&!w.revisionId){const v=c[C+2];v&&v.revisionType==="delete"&&v.revisionAuthor==="当前用户"?(w.revisionId=v.revisionId,w.revisionType="delete",w.revisionAuthor=v.revisionAuthor,w.revisionDate=v.revisionDate):(w.revisionId=`rev_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w.revisionType="delete",w.revisionAuthor="当前用户",w.revisionDate=new Date().toISOString())}d=C}else e.spliceElementList(c,C+1,1),d=C}else if(r){for(let w=o+1;w<=a;w++){const v=c[w];v&&!v.revisionId&&(v.revisionId=`rev_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,v.revisionType="delete",v.revisionAuthor="当前用户",v.revisionDate=new Date().toISOString())}d=o}else e.spliceElementList(c,o+1,a-o),d=o}e.getGlobalEvent().setCanvasEventAbility(),d===null?(i.setRange(o,o),e.render({curIndex:o,isSubmitHistory:!1,isPartialRender:!0})):(i.setRange(d,d),e.render({curIndex:d,isPartialRender:!0}))}function vr(l,t){var p,f,D;const e=t.getDraw();if(e.isReadonly())return;const i=e.getRange();if(!i.canInput())return;const{startIndex:n,endIndex:r}=i.getRange(),o=i.getIsCollapsed(),a=e.getElementList(),s=a[n],c=a[r];if(o&&c.listId&&c.value===Y&&((p=a[r+1])==null?void 0:p.listId)!==c.listId){e.getListParticle().unsetList();return}let h={value:Y};if(l.shiftKey&&s.listId&&(h.listWrap=!0),Xt(a,[h],n,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),l.shiftKey&&c.areaId&&c.areaId!==((f=a[r+1])==null?void 0:f.areaId)&&(h=te(h,Li)),!(c.titleId&&c.titleId!==((D=a[r+1])==null?void 0:D.titleId))){const C=i.getRangeAnchorStyle(a,r);if(C){const I=[...Te];C.controlComponent!==b.POSTFIX&&I.push(...fe),I.forEach(E=>{if(!l.shiftKey&&E==="characterScale")return;const w=C[E];w!==void 0&&(h[E]=w)})}}const d=e.getControl(),u=d.getActiveControl();let g;if(u&&d.getIsRangeWithinControl())g=d.setValue([h]),d.emitControlContentChange();else{const I=e.getPosition().getCursorPosition();if(!I)return;const{index:E}=I;o?e.spliceElementList(a,E+1,0,[h]):e.spliceElementList(a,n+1,r-n,[h]),g=E+1}~g&&(i.setRange(g,g),e.render({curIndex:g})),l.preventDefault()}function Tr(l,t){var w,v,L;const e=t.getDraw();if(e.isReadonly())return;const n=e.getPosition(),r=n.getCursorPosition();if(!r)return;const o=n.getPositionContext(),{index:a}=r;if(a<=0&&!o.isTable)return;const s=e.getRange(),{startIndex:c,endIndex:h}=s.getRange(),d=s.getIsCollapsed(),u=e.getElementList(),g=e.getControl();if(e.getMode()===at.FORM&&g.getActiveControl()&&(((w=u[a])==null?void 0:w.controlComponent)===b.PREFIX||((v=u[a])==null?void 0:v.controlComponent)===b.PRE_TEXT)){g.initNextControl({direction:St.UP});return}let p=1;if(xi(l)){const T=e.getLetterReg(),x=l.shiftKey&&!d&&c===(r==null?void 0:r.index)?h:c;if(T.test((L=u[x])==null?void 0:L.value)){let B=x-1;for(;B>0;){const F=u[B];if(!T.test(F.value))break;p++,B--}}}const f=c-p;let D=f,C=f;if(l.shiftKey&&r&&(c!==h?c===r.index?(D=c,C=h-p):(D=f,C=h):C=h),!l.shiftKey){const T=u[c];if(T.type===R.TABLE){const x=T.trList,B=x.length-1,F=x[B],M=F.tdList.length-1,P=F.tdList[M];n.setPositionContext({isTable:!0,index:c,trIndex:B,tdIndex:M,tdId:P.id,trId:F.id,tableId:T.id}),D=P.value.length-1,C=D,e.getTableTool().render()}else if(T.tableId&&c===0){const B=e.getOriginalElementList()[o.index].trList;t:for(let F=0;F<B.length;F++){const M=B[F];if(M.id!==T.trId)continue;const P=M.tdList;for(let S=0;S<P.length;S++)if(P[S].id===T.tdId){if(F===0&&S===0)n.setPositionContext({isTable:!1}),D=o.index-1,C=D,e.getTableTool().dispose();else{let A=F,y=S-1;y<0&&(A=F-1,y=B[A].tdList.length-1);const N=B[A],k=N.tdList[y];n.setPositionContext({isTable:!0,index:o.index,trIndex:A,tdIndex:y,tdId:k.id,trId:N.id,tableId:T.tableId}),D=k.value.length-1,C=D,e.getTableTool().render()}break t}}}}if(!~D||!~C)return;const I=e.getElementList();D=Ke(I,D),C=Ke(I,C),s.setRange(D,C);const E=D===C;e.render({curIndex:E?D:void 0,isSetCursor:E,isSubmitHistory:!1,isCompute:!1}),l.preventDefault()}function br(l,t){var L,T,x;const e=t.getDraw();if(e.isReadonly())return;const n=e.getPosition(),r=n.getCursorPosition();if(!r)return;const{index:o}=r,a=n.getPositionList(),s=n.getPositionContext();if(o>a.length-1&&!s.isTable)return;const c=e.getRange(),{startIndex:h,endIndex:d}=c.getRange(),u=c.getIsCollapsed();let g=e.getElementList();const p=e.getControl();if(e.getMode()===at.FORM&&p.getActiveControl()&&(((L=g[o+1])==null?void 0:L.controlComponent)===b.POSTFIX||((T=g[o+1])==null?void 0:T.controlComponent)===b.POST_TEXT)){p.initNextControl({direction:St.DOWN});return}let f=1;if(xi(l)){const B=e.getLetterReg(),F=l.shiftKey&&!u&&h===(r==null?void 0:r.index)?d:h;if(B.test((x=g[F+1])==null?void 0:x.value)){let M=F+2;for(;M<g.length;){const P=g[M];if(!B.test(P.value))break;f++,M++}}}const D=d+f;let C=D,I=D;if(l.shiftKey&&r&&(h!==d?h===r.index?(C=h,I=D):(C=h+f,I=d):C=h),!l.shiftKey){const B=g[d],F=g[d+1];if((F==null?void 0:F.type)===R.TABLE){const P=F.trList[0],S=P.tdList[0];n.setPositionContext({isTable:!0,index:d+1,trIndex:0,tdIndex:0,tdId:S.id,trId:P.id,tableId:F.id}),C=0,I=0,e.getTableTool().render()}else if(B.tableId&&!F){const P=e.getOriginalElementList()[s.index].trList;t:for(let S=0;S<P.length;S++){const _=P[S];if(_.id!==B.trId)continue;const A=_.tdList;for(let y=0;y<A.length;y++)if(A[y].id===B.tdId){if(S===P.length-1&&y===A.length-1)n.setPositionContext({isTable:!1}),C=s.index,I=C,g=e.getElementList(),e.getTableTool().dispose();else{let k=S,z=y+1;z>A.length-1&&(k=S+1,z=0);const O=P[k],W=O.tdList[z];n.setPositionContext({isTable:!0,index:s.index,trIndex:k,tdIndex:z,tdId:W.id,trId:O.id,tableId:B.tableId}),C=0,I=C,e.getTableTool().render()}break t}}}}const E=g.length-1;if(C>E||I>E)return;const w=e.getElementList();C=Ke(w,C,ie.AFTER),I=Ke(w,I,ie.AFTER),c.setRange(C,I);const v=C===I;e.render({curIndex:v?C:void 0,isSetCursor:v,isSubmitHistory:!1,isCompute:!1}),l.preventDefault()}function xr(l,t){const e=t.getDraw();if(e.isReadonly())return;l.preventDefault();const n=e.getControl();if(n.getActiveControl()&&n.getIsRangeWithinControl())n.initNextControl({direction:l.shiftKey?St.UP:St.DOWN});else{const o=e.getRange(),a=e.getElementList(),{startIndex:s,endIndex:c}=o.getRange(),h=o.getRangeAnchorStyle(a,c),u={...h?Gt(h,fe):null,type:R.TAB,value:""};Xt(a,[u],s,{editorOptions:e.getOptions()}),e.insertElementList([u])}}function Si(l){const{positionList:t,index:e,isUp:i,rowNo:n,cursorX:r}=l;let o=-1;const a=[];if(i){let s=e-1;for(;s>=0;){const c=t[s];if(s--,c.rowNo!==n){if(a[0]&&a[0].rowNo!==c.rowNo)break;a.unshift(c)}}}else{let s=e+1;for(;s<t.length;){const c=t[s];if(s++,c.rowNo!==n){if(a[0]&&a[0].rowNo!==c.rowNo)break;a.push(c)}}}for(let s=0;s<a.length;s++){const c=a[s],{coordinate:{leftTop:[h],rightTop:[d]}}=c;if(s===a.length-1&&(o=c.index),!(r<h||r>d)){o=c.index;break}}return o}function yr(l,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getPosition(),r=n.getCursorPosition();if(!r)return;const o=e.getRange(),{startIndex:a,endIndex:s}=o.getRange();let c=n.getPositionList();const h=l.key===wt.Up;let d=-1,u=-1;const g=n.getPositionContext();if(!l.shiftKey&&g.isTable&&(h&&r.rowIndex===0||!h&&r.rowIndex===e.getRowCount()-1)){const{index:f,trIndex:D,tdIndex:C,tableId:I}=g;if(h)if(D===0)n.setPositionContext({isTable:!1}),d=f-1,u=d,e.getTableTool().dispose();else{let E=-1,w=-1;const L=e.getOriginalElementList()[f].trList,T=L[D].tdList[C].colIndex;t:for(let F=D-1;F>=0;F--){const P=L[F].tdList;for(let S=0;S<P.length;S++){const _=P[S];if(_.colIndex===T||_.colIndex+_.colspan-1>=T&&_.colIndex<=T){E=F,w=S;break t}}}if(!~E||!~w)return;const x=L[E],B=x.tdList[w];n.setPositionContext({isTable:!0,index:f,trIndex:E,tdIndex:w,tdId:B.id,trId:x.id,tableId:I}),d=B.value.length-1,u=d,e.getTableTool().render()}else{const w=e.getOriginalElementList()[f].trList;if(D===w.length-1)n.setPositionContext({isTable:!1}),d=f,u=d,e.getTableTool().dispose();else{let v=-1,L=-1;const T=w[D].tdList[C].colIndex;t:for(let F=D+1;F<w.length;F++){const P=w[F].tdList;for(let S=0;S<P.length;S++){const _=P[S];if(_.colIndex===T||_.colIndex+_.colspan-1>=T&&_.colIndex<=T){v=F,L=S;break t}}}if(!~v||!~L)return;const x=w[v],B=x.tdList[L];n.setPositionContext({isTable:!0,index:f,trIndex:v,tdIndex:L,tdId:B.id,trId:x.id,tableId:I}),d=B.value.length-1,u=d,e.getTableTool().render()}}}else{let f=r;l.shiftKey&&(a===r.index?f=c[s]:f=c[a]);const{index:D,rowNo:C,rowIndex:I,coordinate:{rightTop:[E]}}=f;if(h&&I===0||!h&&I===e.getRowCount()-1)return;const w=Si({positionList:c,index:D,rowNo:C,isUp:h,cursorX:E});if(w<0)return;d=w,u=w,l.shiftKey&&(a!==s?a===r.index?d=a:u=s:h?u=s:d=a);const L=e.getElementList()[w];if(L.type===R.TABLE){const{scale:T}=e.getOptions(),x=e.getMargins(),B=L.trList;let F=-1,M=-1,P=-1;if(h)t:for(let S=B.length-1;S>=0;S--){const A=B[S].tdList;for(let y=0;y<A.length;y++){const N=A[y],k=N.x*T+x[3],z=N.width*T;if(E>=k&&E<=k+z){const O=N.positionList,W=O[O.length-1],V=Si({positionList:O,index:W.index+1,rowNo:W.rowNo-1,isUp:h,cursorX:E})||W.index;F=S,M=y,P=V;break t}}}else t:for(let S=0;S<B.length;S++){const A=B[S].tdList;for(let y=0;y<A.length;y++){const N=A[y],k=N.x*T+x[3],z=N.width*T;if(E>=k&&E<=k+z){const O=N.positionList,W=Si({positionList:O,index:-1,rowNo:-1,isUp:h,cursorX:E})||0;F=S,M=y,P=W;break t}}}if(~F&&~M&&~P){const S=B[F],_=S.tdList[M];n.setPositionContext({isTable:!0,index:w,trIndex:F,tdIndex:M,tdId:_.id,trId:S.id,tableId:L.id}),d=P,u=d,c=n.getPositionList(),e.getTableTool().render()}}}if(!~d||!~u)return;d>u&&([d,u]=[u,d]),o.setRange(d,u);const p=d===u;e.render({curIndex:p?d:void 0,isSetCursor:p,isSubmitHistory:!1,isCompute:!1}),e.getCursor().moveCursorToVisible({cursorPosition:c[h?d:u],direction:h?St.UP:St.DOWN})}function Rr(l,t){if(t.isComposing)return;const e=t.getDraw();if(l.key===wt.Backspace)Lr(l,t);else if(l.key===wt.Delete)wr(l,t);else if(l.key===wt.Enter)vr(l,t);else if(l.key===wt.Left)Tr(l,t);else if(l.key===wt.Right)br(l,t);else if(l.key===wt.Up||l.key===wt.Down)yr(l,t);else if(l.key===wt.ESC){t.clearPainterStyle();const i=e.getZone();i.isMainActive()||i.setZone(st.MAIN),l.preventDefault()}else l.key===wt.TAB&&xr(l,t)}let ai=null,ci=!1;function xn(l,t){var B,F;const e=t.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=e.getPosition().getCursorPosition();if(!l||!n)return;const r=t.isComposing;if(r&&((B=t.compositionInfo)==null?void 0:B.value)===l)return;const o=e.getRange();if(!o.canInput())return;const a=o.getDefaultStyle()||((F=t.compositionInfo)==null?void 0:F.defaultStyle)||null;yn(t),r||e.getCursor().clearAgentDomValue();const{TEXT:s,HYPERLINK:c,SUBSCRIPT:h,SUPERSCRIPT:d,DATE:u,TAB:g}=R,p=l.replaceAll(`
29
+ `,Y),{startIndex:f,endIndex:D}=o.getRange(),C=e.getElementList(),I=o.getRangeAnchorStyle(C,D);if(!I)return;const E=e.isDesignMode(),v=e.getOptions().trackChanges,L=Yt(p).map(M=>{var S,_;const P={value:M};if(v&&(P.revisionId=`rev_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,P.revisionType="insert",P.revisionAuthor="当前用户",P.revisionDate=new Date().toISOString()),E||!((S=I.title)!=null&&S.disabled)&&!((_=I.control)!=null&&_.disabled)){const A=C[D+1];(!I.type||I.type===s||I.type===c&&(A==null?void 0:A.type)===c||I.type===u&&(A==null?void 0:A.type)===u||I.type===h&&(A==null?void 0:A.type)===h||I.type===d&&(A==null?void 0:A.type)===d)&&Wo.forEach(y=>{if(y==="groupIds"&&!(A!=null&&A.groupIds))return;const N=I[y];N!==void 0&&(P[y]=N)}),(a||I.type===g)&&fe.forEach(y=>{const N=(a==null?void 0:a[y])||I[y];N!==void 0&&(P[y]=N)}),r&&(P.underline=!0)}return P}),T=e.getControl();let x;if(T.getActiveControl()&&T.getIsRangeWithinControl())x=T.setValue(L),r||T.emitControlContentChange();else{const M=f+1;f!==D&&e.spliceElementList(C,M,D-f),Xt(C,L,f,{editorOptions:e.getOptions()}),e.spliceElementList(C,M,0,L),x=f+L.length}~x&&(o.setRange(x,x),ai&&window.clearTimeout(ai),ci=!0,r?(e.render({curIndex:x,isSubmitHistory:!1,isPartialRender:!0}),ci=!1):ai=window.setTimeout(()=>{ci&&(e.render({curIndex:x,isSubmitHistory:!0,isPartialRender:!0}),ci=!1),ai=null},50)),r&&(t.compositionInfo={elementList:C,value:p,startIndex:x-L.length,endIndex:x,defaultStyle:a})}function yn(l){if(!l.compositionInfo)return;const{elementList:t,startIndex:e,endIndex:i}=l.compositionInfo;t.splice(e+1,i-e),l.getDraw().getRange().setRange(e,e),l.compositionInfo=null}function Fr(l){const t=l.getDraw(),e=t.getRange(),{startIndex:i,endIndex:n}=e.getRange();if(!~i&&!~n||t.isReadonly()||!e.canInput())return;const r=t.getElementList();let o=i,a=n;if(i===n){const u=t.getPosition().getPositionList(),g=u[i],p=g.rowNo,f=g.pageNo,D=[];for(let I=0;I<u.length;I++){const E=u[I];if(E.pageNo>f)break;E.pageNo===f&&E.rowNo===p&&D.push(I)}const C=D[0]-1;o=C<0?0:C,a=D[D.length-1]}const s=t.getOptions();Cn(r.slice(o+1,a+1),s);const c=t.getControl();let h;c.getActiveControl()&&c.getIsRangeWithinControl()?(h=c.cut(),c.emitControlContentChange()):(t.spliceElementList(r,o+1,a-o),h=o),e.setRange(h,h),t.render({curIndex:h})}function Pr(l,t){const e=l.getDraw(),{copy:i}=e.getOverride();if(i){const a=i();if((a==null?void 0:a.preventDefault)!==!1)return}const n=e.getRange();let r=null;if(n.getRange().isCrossRowCol){const a=n.getRangeTableElement();if(!a)return;const s=e.getTableParticle().getRangeRowCol();if(!s)return;const c={type:R.TABLE,value:"",colgroup:[],trList:[]},h=s[0],d=h[0].colIndex,u=h[h.length-1],g=u.colIndex+u.colspan-1;for(let p=d;p<=g;p++)c.colgroup.push(a.colgroup[p]);for(let p=0;p<s.length;p++){const f=s[p],D=a.trList[f[0].rowIndex],C={tdList:[],height:D.height,minHeight:D.minHeight};for(let I=0;I<f.length;I++)C.tdList.push(f[I]);c.trList.push(C)}r=Et([c])}else r=n.getIsCollapsed()?n.getRangeRowElementList():n.getSelectionElementList();t!=null&&t.isPlainText&&(r!=null&&r.length)&&(r=[{value:hr(r)}]),r!=null&&r.length&&Cn(r,e.getOptions())}function Ar(l,t){var r,o;const e=t.getDraw(),{drop:i}=e.getOverride();if(i){const a=i(l);if((a==null?void 0:a.preventDefault)!==!1)return}l.preventDefault();const n=(r=l.dataTransfer)==null?void 0:r.getData("text");if(n)t.input(n);else{const a=(o=l.dataTransfer)==null?void 0:o.files;if(!a)return;for(let s=0;s<a.length;s++){const c=a[s];c.type.startsWith("image")&&Ai(t,c)}}}function Sr(l,t){const i=t.getPosition().getPositionContext();if(!i.isTable)return;const n=t.getOriginalElementList(),{index:r}=i;let o=null;for(let s=r;s>=0;s--){const c=n[s];if(c&&c.type===R.TABLE){o=c;break}}if(!o)return;l.preventDefault(),l.stopPropagation();const a=t.__tableContextMenu;a&&a.show(l.clientX,l.clientY,o)}function Or(l){var u;if(!Intl.Segmenter)return null;const t=l.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const n=t.getRange().getRangeParagraphInfo();if(!n)return null;const r=((u=n==null?void 0:n.elementList)==null?void 0:u.map(g=>!g.type||g.type!==R.CONTROL&&Jt.includes(g.type)?g.value:Y).join(""))||"";if(!r)return null;const o=e.index,a=n.startIndex,c=new Intl.Segmenter(void 0,{granularity:"word"}).segment(r);let h=-1,d=-1;for(const{segment:g,index:p,isWordLike:f}of c){const D=p+a;if(f&&o>=D&&o<D+g.length){h=D-1,d=h+g.length;break}}return~h&&~d?{startIndex:h,endIndex:d}:null}function Br(l){const t=l.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const{value:i,index:n}=e,r=t.getLetterReg();let o=0,a=0;const s=wi.test(i);if(s||r.test(i)){const h=t.getElementList();let d=n-1;for(;d>0;){const g=h[d].value;if(s&&wi.test(g)||!s&&r.test(g))o++,d--;else break}let u=n+1;for(;u<h.length;){const g=h[u].value;if(s&&wi.test(g)||!s&&r.test(g))a++,u++;else break}}const c=n-o-1;return c<0?null:{startIndex:c,endIndex:n+a}}function Hr(l,t){const e=l.getDraw(),i=e.getPosition(),n=i.getPositionByXY({x:t.offsetX,y:t.offsetY});if(n.isImage&&n.isDirectHit){e.getPreviewer().render();return}if(e.getIsPagingMode()&&!~n.index&&n.zone){e.getZone().setZone(n.zone),e.clearSideEffect(),i.setPositionContext({isTable:!1}),e.getRange().setRange(0,0),e.render({curIndex:0,isSubmitHistory:!1});return}if((n.isCheckbox||n.isRadio)&&n.isDirectHit)return;const r=e.getRange(),o=Or(l)||Br(l);o&&(r.setRange(o.startIndex,o.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),r.setRangeStyle())}function Mr(l){var g,p;const t=l.getDraw(),i=t.getPosition().getCursorPosition();if(!i)return;const{index:n}=i,r=t.getElementList();let o=0,a=0,s=n-1;for(;s>0;){const f=r[s],D=r[s-1];if(oi(f)||f.listId!==(D==null?void 0:D.listId)||f.titleId!==(D==null?void 0:D.titleId))break;o++,s--}let c=n+1;for(;c<r.length;){const f=r[c],D=r[c+1];if(oi(f)||f.listId!==(D==null?void 0:D.listId)||f.titleId!==(D==null?void 0:D.titleId))break;a++,c++}const h=t.getRange();let d=n-o-1;if(((g=r[d])==null?void 0:g.value)!==Y&&(d-=1),d<0)return;let u=n+a+1;(((p=r[u])==null?void 0:p.value)===Y||u>r.length-1)&&(u-=1),h.setRange(d,u),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}const Rn={dblclick:Hr,handleTripleClick:Mr};function _r(l){l.isComposing=!0}function kr(l,t){l.isComposing=!1;const e=l.getDraw();if(t.data)l.compositionInfo&&xn(t.data,l);else{yn(l);const n=e.getRange(),{endIndex:r}=n.getRange();e.render({curIndex:r,isSubmitHistory:!1})}e.getCursor().clearAgentDomValue()}const Fn={compositionstart:_r,compositionend:kr};function Nr(l,t){var E;const e=t.getDraw();if(e.isReadonly())return;l.preventDefault();const n=e.getPageContainer();if(!ti(l.target,w=>w===n))return;const a=l.target.dataset.index;a&&e.setPageNo(Number(a));const s=e.getPosition(),c=s.adjustPositionContext({x:l.offsetX,y:l.offsetY});if(!c)return;const{isTable:h,tdValueIndex:d,index:u}=c,g=s.getPositionList(),p=h?d:u;~u&&(e.getRange().setRange(p,p),s.setCursorPosition(g[p]));const f=e.getCursor(),{cursor:{dragColor:D,dragWidth:C,dragFloatImageDisabled:I}}=e.getOptions();if(I){const w=(E=t.cacheElementList)==null?void 0:E[t.cacheRange.startIndex];if((w==null?void 0:w.type)===R.IMAGE&&(w.imgDisplay===Q.FLOAT_TOP||w.imgDisplay===Q.FLOAT_BOTTOM||w.imgDisplay===Q.SURROUND))return}f.drawCursor({width:C,color:D,isBlink:!1,isFocus:!1})}const Wr={dragover:Nr};class Pn{constructor(t){m(this,"isAllowSelection");m(this,"isComposing");m(this,"compositionInfo");m(this,"isAllowDrag");m(this,"isAllowDrop");m(this,"cacheRange");m(this,"cacheElementList");m(this,"cachePositionList");m(this,"cachePositionContext");m(this,"mouseDownStartPosition");m(this,"draw");m(this,"pageContainer");m(this,"pageList");m(this,"range");m(this,"position");m(this,"_clickHandler",null);m(this,"_mousedownHandler",null);m(this,"_mouseupHandler",null);m(this,"_mouseleaveHandler",null);m(this,"_mousemoveHandler",null);m(this,"_dblclickHandler",null);m(this,"_dragoverHandler",null);m(this,"_dropHandler",null);m(this,"_contextmenuHandler",null);m(this,"_threeClickCleanup",null);this.draw=t,this.pageContainer=t.getPageContainer(),this.pageList=t.getPageList(),this.range=this.draw.getRange(),this.position=this.draw.getPosition(),this.isAllowSelection=!1,this.isComposing=!1,this.compositionInfo=null,this.isAllowDrag=!1,this.isAllowDrop=!1,this.cacheRange=null,this.cacheElementList=null,this.cachePositionList=null,this.cachePositionContext=null,this.mouseDownStartPosition=null}getDraw(){return this.draw}register(){this._clickHandler=this.click.bind(this),this._mousedownHandler=this.mousedown.bind(this),this._mouseupHandler=this.mouseup.bind(this),this._mouseleaveHandler=this.mouseleave.bind(this),this._mousemoveHandler=this.mousemove.bind(this),this._dblclickHandler=this.dblclick.bind(this),this._dragoverHandler=this.dragover.bind(this),this._dropHandler=this.drop.bind(this),this._contextmenuHandler=this._contextmenu.bind(this),this.pageContainer.addEventListener("click",this._clickHandler),this.pageContainer.addEventListener("mousedown",this._mousedownHandler),this.pageContainer.addEventListener("mouseup",this._mouseupHandler),this.pageContainer.addEventListener("mouseleave",this._mouseleaveHandler),this.pageContainer.addEventListener("mousemove",this._mousemoveHandler),this.pageContainer.addEventListener("dblclick",this._dblclickHandler),this.pageContainer.addEventListener("dragover",this._dragoverHandler),this.pageContainer.addEventListener("drop",this._dropHandler),this.pageContainer.addEventListener("contextmenu",this._contextmenuHandler),this._threeClickCleanup=zs(this.pageContainer,this.handleTripleClick.bind(this))}removeEvent(){this._clickHandler&&this.pageContainer.removeEventListener("click",this._clickHandler),this._mousedownHandler&&this.pageContainer.removeEventListener("mousedown",this._mousedownHandler),this._mouseupHandler&&this.pageContainer.removeEventListener("mouseup",this._mouseupHandler),this._mouseleaveHandler&&this.pageContainer.removeEventListener("mouseleave",this._mouseleaveHandler),this._mousemoveHandler&&this.pageContainer.removeEventListener("mousemove",this._mousemoveHandler),this._dblclickHandler&&this.pageContainer.removeEventListener("dblclick",this._dblclickHandler),this._dragoverHandler&&this.pageContainer.removeEventListener("dragover",this._dragoverHandler),this._dropHandler&&this.pageContainer.removeEventListener("drop",this._dropHandler),this._contextmenuHandler&&this.pageContainer.removeEventListener("contextmenu",this._contextmenuHandler),this._threeClickCleanup&&this._threeClickCleanup(),this._clickHandler=null,this._mousedownHandler=null,this._mouseupHandler=null,this._mouseleaveHandler=null,this._mousemoveHandler=null,this._dblclickHandler=null,this._dragoverHandler=null,this._dropHandler=null,this._contextmenuHandler=null,this._threeClickCleanup=null}setIsAllowSelection(t){this.isAllowSelection=t,t||this.applyPainterStyle()}setIsAllowDrag(t){this.isAllowDrag=t,this.isAllowDrop=t}clearPainterStyle(){this.pageList.forEach(t=>{t.style.cursor="text"}),this.draw.setPainterStyle(null)}applyPainterStyle(){const t=this.draw.getPainterStyle();if(!t||this.draw.isReadonly()||this.draw.isDisabled())return;const i=this.range.getSelection();if(!i)return;const n=Object.keys(t);i.forEach(o=>{n.forEach(a=>{const s=a;o[s]=t[s]})}),this.draw.render({isSetCursor:!1});const r=this.draw.getPainterOptions();(!r||!r.isDblclick)&&this.clearPainterStyle()}selectAll(){const t=this.position.getPositionList();this.range.setRange(0,t.length-1),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}mousemove(t){Er(t,this)}mousedown(t){Dr(t,this)}click(){qs&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){Cr(t,this)}mouseleave(t){Ir(t,this)}keydown(t){Rr(t,this)}dblclick(t){Rn.dblclick(this,t)}handleTripleClick(){Rn.handleTripleClick(this)}input(t){xn(t,this)}cut(){Fr(this)}copy(t){Pr(this,t)}compositionstart(){Fn.compositionstart(this)}compositionend(t){Fn.compositionend(this,t)}drop(t){Ar(t,this)}dragover(t){Wr.dragover(t,this)}_contextmenu(t){Sr(t,this.draw)}}class An{constructor(t,e){m(this,"draw");m(this,"options");m(this,"cursor");m(this,"canvasEvent");m(this,"range");m(this,"previewer");m(this,"tableTool");m(this,"hyperlinkParticle");m(this,"control");m(this,"dateParticle");m(this,"imageParticle");m(this,"dprMediaQueryList");m(this,"clearSideEffect",t=>{if(!this.cursor)return;const e=(t==null?void 0:t.composedPath()[0])||t.target,i=this.draw.getPageList();if(ti(e,o=>i.includes(o)))return;if(ti(e,o=>!!o&&o.nodeType===1&&!!o.getAttribute(Xe))){this.watchCursorActive();return}this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker(),this.imageParticle.destroyFloatImage()});m(this,"setCanvasEventAbility",()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)});m(this,"setPageScale",t=>{if(this.options.shortcutDisableKeys.includes(jo.PAGE_SCALE)||!t.ctrlKey)return;t.preventDefault();const{scale:e}=this.options;if(t.deltaY<0){const i=Math.round(e*10+1)/10;i<=3&&this.draw.setPageScale(i)}else{const i=Math.round(e*10-1)/10;i>=.5&&this.draw.setPageScale(i)}});m(this,"_handleVisibilityChange",()=>{if(document.visibilityState==="visible"){const t=this.range.getRange(),e=!!~t.startIndex&&!!~t.endIndex&&t.startIndex===t.endIndex;this.range.replaceRange(t),this.draw.render({isSetCursor:e,isCompute:!1,isSubmitHistory:!1,curIndex:t.startIndex})}});m(this,"_handleDprChange",()=>{this.draw.setPageDevicePixel()});this.draw=t,this.options=t.getOptions(),this.canvasEvent=e,this.cursor=null,this.range=t.getRange(),this.previewer=t.getPreviewer(),this.tableTool=t.getTableTool(),this.hyperlinkParticle=t.getHyperlinkParticle(),this.dateParticle=t.getDateParticle(),this.imageParticle=t.getImageParticle(),this.control=t.getControl(),this.dprMediaQueryList=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)}register(){this.cursor=this.draw.getCursor(),this.addEvent()}addEvent(){window.addEventListener("blur",this.clearSideEffect),document.addEventListener("mousedown",this.clearSideEffect),document.addEventListener("mouseup",this.setCanvasEventAbility),document.addEventListener("wheel",this.setPageScale,{passive:!1}),document.addEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.addEventListener("change",this._handleDprChange)}removeEvent(){window.removeEventListener("blur",this.clearSideEffect),document.removeEventListener("mousedown",this.clearSideEffect),document.removeEventListener("mouseup",this.setCanvasEventAbility),document.removeEventListener("wheel",this.setPageScale),document.removeEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.removeEventListener("change",this._handleDprChange)}watchCursorActive(){this.range.getIsCollapsed()&&setTimeout(()=>{var t,e;(t=this.cursor)!=null&&t.getAgentIsActive()||(e=this.cursor)==null||e.drawCursor({isFocus:!1,isBlink:!1})})}}class Sn{constructor(t){m(this,"cursorPosition");m(this,"positionContext");m(this,"positionList");m(this,"floatPositionList");m(this,"draw");m(this,"eventBus");m(this,"options");this.positionList=[],this.floatPositionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.eventBus=t.getEventBus(),this.options=t.getOptions()}getFloatPositionList(){return this.floatPositionList}getTablePositionList(t){const{index:e,trIndex:i,tdIndex:n}=this.positionContext;return t[e].trList[i].tdList[n].positionList||[]}getPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalElementList()):this.getOriginalPositionList()}getMainPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalMainElementList()):this.positionList}getOriginalPositionList(){const t=this.draw.getZone();return t.isHeaderActive()?this.draw.getHeader().getPositionList():t.isFooterActive()?this.draw.getFooter().getPositionList():this.positionList}getOriginalMainPositionList(){return this.positionList}getSelectionPositionList(){const{startIndex:t,endIndex:e}=this.draw.getRange().getRange();return t===e?null:this.getPositionList().slice(t+1,e+1)}setPositionList(t){this.positionList=t}setFloatPositionList(t){this.floatPositionList=t}computePageRowPosition(t){const{positionList:e,rowList:i,pageNo:n,startX:r,startY:o,startRowIndex:a,startIndex:s,innerWidth:c,zone:h}=t,{scale:d,table:{tdPadding:u}}=this.options;let g=r,p=o,f=s;for(let D=0;D<i.length;D++){const C=i[D];if(C.isColumnContainer&&C.columnRowLists){const w=C.columnWidths||[],v=C.columnGap||0;let L=g;for(let T=0;T<C.columnRowLists.length;T++){const x=C.columnRowLists[T];if(x.length>0){this.computePageRowPosition({positionList:e,rowList:x,pageNo:n,startX:L,startY:p,startRowIndex:a+D,startIndex:f,innerWidth:w[T]||0,zone:h});for(const B of x)f+=B.elementList.length}L+=(w[T]||0)+v}p+=C.height;continue}if(!C.isSurround){const w=C.width+(C.offsetX||0);C.rowFlex===gt.CENTER?g+=(c-w)/2:C.rowFlex===gt.RIGHT&&(g+=c-w)}g+=C.offsetX||0,p+=C.offsetY||0;const I=g,E=p;for(let w=0;w<C.elementList.length;w++){const v=C.elementList[w],L=v.metrics,T=Ge(v)||v.type===R.LATEX?C.ascent-L.height:C.ascent;v.left&&(g+=v.left);const x={pageNo:n,index:f,value:v.value,rowIndex:a+D,rowNo:D,metrics:L,left:v.left||0,ascent:T,lineHeight:C.height,isFirstLetter:w===0,isLastLetter:w===C.elementList.length-1,coordinate:{leftTop:[g,p],leftBottom:[g,p+C.height],rightTop:[g+L.width,p],rightBottom:[g+L.width,p+C.height]}};if(v.imgDisplay===Q.SURROUND||v.imgDisplay===Q.FLOAT_TOP||v.imgDisplay===Q.FLOAT_BOTTOM){const B=e[e.length-1];B&&(x.metrics=B.metrics,x.coordinate=B.coordinate),v.imgFloatPosition||(v.imgFloatPosition={x:g,y:p,pageNo:n}),this.floatPositionList.push({pageNo:n,element:v,position:x,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:f,zone:h})}if(e.push(x),f++,g+=L.width,Ve(v)){const B=v.tdPadding||u;for(let F=0;F<v.trList.length;F++){const M=v.trList[F];for(let P=0;P<M.tdList.length;P++){const S=M.tdList[P],_=S.padding||B,A=_[1]+_[3],y=_[0]+_[2];S.positionList=[];const N=S.rowList,k=this.computePageRowPosition({positionList:S.positionList,rowList:N,pageNo:n,startRowIndex:0,startIndex:0,startX:(S.x+_[3])*d+I,startY:(S.y+_[0])*d+E,innerWidth:(S.width-A)*d,isTable:!0,index:f-1,tdIndex:P,trIndex:F,zone:h});if(S.verticalAlign===Wt.MIDDLE||S.verticalAlign===Wt.BOTTOM){const z=N.reduce((V,U)=>V+U.height,0),O=(S.height-y)*d-z,W=S.verticalAlign===Wt.MIDDLE?O/2:O;Math.floor(W)>0&&S.positionList.forEach(V=>{const{coordinate:{leftTop:U,leftBottom:it,rightBottom:Z,rightTop:tt}}=V;U[1]+=W,it[1]+=W,Z[1]+=W,tt[1]+=W})}g=k.x,p=k.y}}g=I,p=E}}g=r,p+=C.height}return{x:g,y:p,index:f}}computePositionList(){var c;this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),i=this.draw.getMargins(),n=i[3],o=this.draw.getHeader().getExtraHeight(),a=i[0]+o;let s=0;for(let h=0;h<e.length;h++){const d=e[h],u=(c=d[0])==null?void 0:c.startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:d,pageNo:h,startRowIndex:s,startIndex:u,startX:n,startY:a,innerWidth:t}),s+=d.length}}computeRowPosition(t){const{row:e,innerWidth:i}=t,n=[];return this.computePageRowPosition({positionList:n,innerWidth:i,rowList:[bt(e)],pageNo:0,startX:0,startY:0,startIndex:0,startRowIndex:0}),n}setCursorPosition(t){this.cursorPosition=t}getCursorPosition(){return this.cursorPosition}getPositionContext(){return this.positionContext}setPositionContext(t){this.eventBus.emit("positionContextChange",{value:t,oldValue:this.positionContext}),this.positionContext=t}getPositionByXY(t){var f,D,C,I;const{x:e,y:i,isTable:n}=t;let{elementList:r,positionList:o}=t;r||(r=this.draw.getOriginalElementList()),o||(o=this.getOriginalPositionList());const a=this.draw.getZone(),s=t.pageNo??this.draw.getPageNo(),c=a.isMainActive(),h=c?s:0;if(!n){const E=this.getFloatPositionByXY({...t,imgDisplays:[Q.FLOAT_TOP,Q.SURROUND]});if(E)return E}for(let E=0;E<o.length;E++){const{index:w,pageNo:v,left:L,isFirstLetter:T,coordinate:{leftTop:x,rightTop:B,leftBottom:F}}=o[E];if(h===v){if(v>h)break;if(x[0]-L<=e&&B[0]>=e&&x[1]<=i&&F[1]>=i){let M=E;const P=r[E];if(Ve(P))for(let _=0;_<P.trList.length;_++){const A=P.trList[_];for(let y=0;y<A.tdList.length;y++){const N=A.tdList[y],k=this.getPositionByXY({x:e,y:i,td:N,pageNo:s,tablePosition:o[E],isTable:!0,elementList:N.value,positionList:N.positionList});if(~k.index){const{index:z,hitLineStartIndex:O}=k,W=N.value[z];return{index:w,isCheckbox:k.isCheckbox||W.type===R.CHECKBOX||W.controlComponent===b.CHECKBOX,isRadio:W.type===R.RADIO||W.controlComponent===b.RADIO,isControl:!!W.controlId,isImage:k.isImage,isDirectHit:k.isDirectHit,isTable:!0,tdIndex:y,trIndex:_,tdValueIndex:z,tdId:N.id,trId:A.id,tableId:P.id,hitLineStartIndex:O}}}}if(Ge(P)||P.type===R.LATEX)return{index:M,isDirectHit:!0,isImage:!0};if(P.type===R.CHECKBOX||P.controlComponent===b.CHECKBOX)return{index:M,isDirectHit:!0,isCheckbox:!0};if(P.type===R.TAB&&P.listStyle===It.CHECKBOX){let _=M-1;for(;_>0;){const A=r[_];if(A.value===Y&&A.listStyle===It.CHECKBOX)break;_--}return{index:_,isDirectHit:!0,isCheckbox:!0}}if(P.type===R.RADIO||P.controlComponent===b.RADIO)return{index:M,isDirectHit:!0,isRadio:!0};let S;if(r[w].value!==Y){const _=B[0]-x[0];e<x[0]+_/2&&(M=E-1,T&&(S=E))}return{isDirectHit:!0,hitLineStartIndex:S,index:M,isControl:!!P.controlId}}}}if(!n){const E=this.getFloatPositionByXY({...t,imgDisplays:[Q.FLOAT_BOTTOM]});if(E)return E}let d=!1,u=-1,g;if(n){const{scale:E}=this.options,{td:w,tablePosition:v}=t;if(w&&v){const{leftTop:L}=v.coordinate,T=w.x*E+L[0],x=w.y*E+L[1],B=w.width*E,F=w.height*E;if(!(T<e&&e<T+B&&x<i&&i<x+F))return{index:u}}}const p=o.filter(E=>E.isLastLetter&&E.pageNo===h);for(let E=0;E<p.length;E++){const{index:w,rowNo:v,coordinate:{leftTop:L,leftBottom:T}}=p[E];if(i>L[1]&&i<=T[1]){const x=o.findIndex(P=>P.pageNo===h&&P.rowNo===v),B=r[x],F=o[x],M=B.listStyle===It.CHECKBOX?this.draw.getMargins()[3]:F.coordinate.leftTop[0];if(e<M)~x?F.value===Y?u=x:(u=x-1,g=x):u=w;else{if(B.listStyle===It.CHECKBOX&&e<L[0])return{index:x,isDirectHit:!0,isCheckbox:!0};u=w}d=!0;break}}if(!d){const w=this.draw.getHeader().getExtraHeight()+this.draw.getMargins()[0],v=this.draw.getFooter(),T=this.draw.getHeight()-(v.getExtraHeight()+this.draw.getMargins()[2]);if(c){if(i<w)return{index:-1,zone:st.HEADER};if(i>T)return{index:-1,zone:st.FOOTER}}else if(i<=T&&i>=w)return{index:-1,zone:st.MAIN};const x=this.draw.getMargins();if(i<=x[0])for(let B=0;B<o.length;B++){const F=o[B];if(F.pageNo!==h||F.rowNo!==0)continue;const{leftTop:M,rightTop:P}=F.coordinate;if(e<=x[3]||e>=M[0]&&e<=P[0]||((f=o[B+1])==null?void 0:f.rowNo)!==0)return{index:F.index}}else{const B=p[p.length-1];if(B){const F=B.rowNo;for(let M=0;M<o.length;M++){const P=o[M];if(P.pageNo!==h||P.rowNo!==F)continue;const{leftTop:S,rightTop:_}=P.coordinate;if(e<=x[3]||e>=S[0]&&e<=_[0]||((D=o[M+1])==null?void 0:D.rowNo)!==F)return{index:P.index}}}}return{index:((C=p[p.length-1])==null?void 0:C.index)||o.length-1}}return{hitLineStartIndex:g,index:u,isControl:!!((I=r[u])!=null&&I.controlId)}}getFloatPositionByXY(t){const{x:e,y:i}=t,n=t.pageNo??this.draw.getPageNo(),r=this.draw.getZone().getZone(),{scale:o}=this.options;for(let a=0;a<this.floatPositionList.length;a++){const{position:s,element:c,isTable:h,index:d,trIndex:u,tdIndex:g,tdValueIndex:p,zone:f,pageNo:D}=this.floatPositionList[a];if(n===D&&Ge(c)&&c.imgDisplay&&t.imgDisplays.includes(c.imgDisplay)&&(!f||f===r)){const C=c.imgFloatPosition,I=C.x*o,E=C.y*o,w=c.width*o,v=c.height*o;if(e>=I&&e<=I+w&&i>=E&&i<=E+v)return h?{index:d,isDirectHit:!0,isImage:!0,isTable:h,trIndex:u,tdIndex:g,tdValueIndex:p,tdId:c.tdId,trId:c.trId,tableId:c.tableId}:{index:s.index,isDirectHit:!0,isImage:!0}}}}adjustPositionContext(t){const e=this.getPositionByXY(t);if(!~e.index)return null;if(e.isControl&&this.draw.getMode()!==at.READONLY){const{index:f,isTable:D,trIndex:C,tdIndex:I,tdValueIndex:E}=e,w=this.draw.getControl(),{newIndex:v}=w.moveCursor({index:f,isTable:D,trIndex:C,tdIndex:I,tdValueIndex:E});D?e.tdValueIndex=v:e.index=v}const{index:i,isCheckbox:n,isRadio:r,isControl:o,isImage:a,isDirectHit:s,isTable:c,trIndex:h,tdIndex:d,tdId:u,trId:g,tableId:p}=e;return this.setPositionContext({isTable:c||!1,isCheckbox:n||!1,isRadio:r||!1,isControl:o||!1,isImage:a||!1,isDirectHit:s||!1,index:i,trIndex:h,tdIndex:d,tdId:u,trId:g,tableId:p}),e}setSurroundPosition(t){var h;const{pageNo:e,row:i,rowElement:n,rowElementRect:r,surroundElementList:o,availableWidth:a}=t;let s=r.x,c=0;if(o.length&&!xe(n)&&!((h=n.control)!=null&&h.minWidth))for(let d=0;d<o.length;d++){const u=o[d],g=u.imgFloatPosition;if(g.pageNo!==e)continue;const p={...g,width:u.width,height:u.height};if(js(r,p)){i.isSurround=!0;const f=p.width+p.x-r.x;if(n.left=f,i.width+=f,c+=f,s=p.x+p.width,i.width+n.metrics.width>a){n.left=0,i.width-=c;break}}}return{x:s,rowIncreaseWidth:c}}}var zr=Object.defineProperty,Xr=(l,t,e)=>t in l?zr(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,Oi=(l,t,e)=>Xr(l,typeof t!="symbol"?t+"":t,e),On=(l=>(l.CONTAIN="contain",l.COVER="cover",l))(On||{}),Bn=(l=>(l.REPEAT="repeat",l.NO_REPEAT="no-repeat",l.REPEAT_X="repeat-x",l.REPEAT_Y="repeat-y",l))(Bn||{}),ye=(l=>(l.HALF="half",l.ONE_THIRD="one-third",l.QUARTER="quarter",l))(ye||{}),jt=(l=>(l.ARABIC="arabic",l.CHINESE="chinese",l))(jt||{}),Tt=(l=>(l.PREFIX="prefix",l.POSTFIX="postfix",l.PRE_TEXT="preText",l.POST_TEXT="postText",l.PLACEHOLDER="placeholder",l.VALUE="value",l.CHECKBOX="checkbox",l.RADIO="radio",l))(Tt||{}),Hn=(l=>(l.PAGE="page",l.TABLE="table",l))(Hn||{}),At=(l=>(l.TEXT="text",l.IMAGE="image",l.TABLE="table",l.HYPERLINK="hyperlink",l.SUPERSCRIPT="superscript",l.SUBSCRIPT="subscript",l.SEPARATOR="separator",l.PAGE_BREAK="pageBreak",l.CONTROL="control",l.AREA="area",l.CHECKBOX="checkbox",l.RADIO="radio",l.LATEX="latex",l.TAB="tab",l.DATE="date",l.BLOCK="block",l.TITLE="title",l.LIST="list",l.PLACEHOLDER="placeholder",l.FOOTNOTE_MARK="footnoteMark",l.FOOTNOTE_CONTENT="footnoteContent",l.FOOTNOTE_SEPARATOR="footnoteSeparator",l.COLUMN_BREAK="columnBreak",l.REVISION_INSERT="revisionInsert",l.REVISION_DELETE="revisionDelete",l))(At||{}),Mn=(l=>(l.PAGE="page",l.CONTINUITY="continuity",l))(Mn||{}),Bi=(l=>(l.UL="ul",l.OL="ol",l))(Bi||{}),Lt=(l=>(l.DISC="disc",l.CIRCLE="circle",l.SQUARE="square",l.CHECKBOX="checkbox",l.DIAMOND="diamond",l.DASH="dash",l.CHECK="check",l.TRIANGLE="triangle",l.STAR="star",l.ARROW="arrow",l.DIAMOND_SOLID="diamond-solid",l.ANGLE="angle",l.HOLLOW_CIRCLE="hollow-circle",l.HOLLOW_SQUARE="hollow-square",l.HEART_HOLLOW="heart-hollow",l.HASH="hash",l.TRIANGLE_SOLID="triangle-solid",l.STAR_SOLID="star-solid",l.HEART_SOLID="heart-solid",l.FLOWER="flower",l.ASTERISK="asterisk",l.HOLLOW_DIAMOND="hollow-diamond",l.HOLLOW_TRIANGLE="hollow-triangle",l))(Lt||{}),Ot=(l=>(l.DISC="disc",l.CIRCLE="circle",l.SQUARE="square",l.CHECKBOX="checkbox",l.DIAMOND="diamond",l.DASH="dash",l.CHECK="check",l.DECIMAL="decimal",l.DECIMAL_DOT="decimal-dot",l.DECIMAL_PAREN="decimal-paren",l.DECIMAL_CIRCLE="decimal-circle",l.DECIMAL_BRACKET="decimal-bracket",l.CHINESE="chinese",l.CHINESE_BRACKET="chinese-bracket",l.UPPER_ALPHA="upper-alpha",l.LOWER_ALPHA_DOT="lower-alpha-dot",l))(Ot||{}),_n=(l=>(l.LEFT="left",l.CENTER="center",l.RIGHT="right",l.ALIGNMENT="alignment",l.JUSTIFY="justify",l))(_n||{}),Ft=(l=>(l.FIRST="first",l.SECOND="second",l.THIRD="third",l.FOURTH="fourth",l.FIFTH="fifth",l.SIXTH="sixth",l))(Ft||{}),Hi=(l=>(l.TOP="top",l.MIDDLE="middle",l.BOTTOM="bottom",l))(Hi||{}),kn=(l=>(l.TEXT="text",l.IMAGE="image",l))(kn||{});const je="​";ye.HALF+"",ye.ONE_THIRD+"",ye.QUARTER+"";const Nn=[At.TEXT,At.HYPERLINK,At.SUBSCRIPT,At.SUPERSCRIPT,At.CONTROL,At.DATE,At.PLACEHOLDER];At.IMAGE,At.LATEX,At.BLOCK,At.PAGE_BREAK,At.SEPARATOR,At.TABLE,At.TITLE,At.LIST,_n.CENTER,jt.ARABIC,jt.ARABIC,jt.ARABIC,jt.ARABIC,jt.ARABIC,jt.ARABIC,jt.ARABIC,jt.ARABIC,jt.CHINESE,jt.CHINESE,kn.TEXT,jt.ARABIC,Ft.FIRST+"",Ft.SECOND+"",Ft.THIRD+"",Ft.FOURTH+"",Ft.FIFTH+"",Ft.SIXTH+"",Ft.FIRST+"",Ft.SECOND+"",Ft.THIRD+"",Ft.FOURTH+"",Ft.FIFTH+"",Ft.SIXTH+"",Ft.FIRST,Ft.SECOND,Ft.THIRD,Ft.FOURTH,Ft.FIFTH,Ft.SIXTH,Lt.DISC+"",Lt.CIRCLE+"",Lt.SQUARE+"",Lt.CHECKBOX+"",Lt.DIAMOND+"",Lt.DASH+"",Lt.CHECK+"",Lt.TRIANGLE+"",Lt.STAR+"",Lt.ARROW+"",Lt.DIAMOND_SOLID+"",Lt.ANGLE+"",Lt.HOLLOW_CIRCLE+"",Lt.HOLLOW_SQUARE+"",Lt.HEART_HOLLOW+"",Lt.HASH+"",Lt.TRIANGLE_SOLID+"",Lt.STAR_SOLID+"",Lt.HEART_SOLID+"",Lt.FLOWER+"",Lt.ASTERISK+"",Lt.HOLLOW_DIAMOND+"",Lt.HOLLOW_TRIANGLE+"",Bi.OL+"",Bi.UL+"",Ot.DISC+"",Ot.CIRCLE+"",Ot.SQUARE+"",Ot.DECIMAL+"",Ot.DECIMAL_DOT+"",Ot.DECIMAL_PAREN+"",Ot.DECIMAL_CIRCLE+"",Ot.DECIMAL_BRACKET+"",Ot.CHINESE+"",Ot.CHINESE_BRACKET+"",Ot.UPPER_ALPHA+"",Ot.LOWER_ALPHA_DOT+"",Ot.CHECKBOX+"",Ot.DIAMOND+"",Ot.DASH+"",Ot.CHECK+"",On.COVER,Bn.NO_REPEAT,Hi.BOTTOM,ye.HALF,ye.HALF,Hi.BOTTOM,Mn.CONTINUITY;function $r(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Ur=Vr;function Re(l){return l instanceof Buffer?Buffer.from(l):new l.constructor(l.buffer.slice(),l.byteOffset,l.length)}function Vr(l){if(l=l||{},l.circles)return Gr(l);const t=new Map;if(t.set(Date,o=>new Date(o)),t.set(Map,(o,a)=>new Map(i(Array.from(o),a))),t.set(Set,(o,a)=>new Set(i(Array.from(o),a))),l.constructorHandlers)for(const o of l.constructorHandlers)t.set(o[0],o[1]);let e=null;return l.proto?r:n;function i(o,a){const s=Object.keys(o),c=new Array(s.length);for(let h=0;h<s.length;h++){const d=s[h],u=o[d];typeof u!="object"||u===null?c[d]=u:u.constructor!==Object&&(e=t.get(u.constructor))?c[d]=e(u,a):ArrayBuffer.isView(u)?c[d]=Re(u):c[d]=a(u)}return c}function n(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return i(o,n);if(o.constructor!==Object&&(e=t.get(o.constructor)))return e(o,n);const a={};for(const s in o){if(Object.hasOwnProperty.call(o,s)===!1)continue;const c=o[s];typeof c!="object"||c===null?a[s]=c:c.constructor!==Object&&(e=t.get(c.constructor))?a[s]=e(c,n):ArrayBuffer.isView(c)?a[s]=Re(c):a[s]=n(c)}return a}function r(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return i(o,r);if(o.constructor!==Object&&(e=t.get(o.constructor)))return e(o,r);const a={};for(const s in o){const c=o[s];typeof c!="object"||c===null?a[s]=c:c.constructor!==Object&&(e=t.get(c.constructor))?a[s]=e(c,r):ArrayBuffer.isView(c)?a[s]=Re(c):a[s]=r(c)}return a}}function Gr(l){const t=[],e=[],i=new Map;if(i.set(Date,s=>new Date(s)),i.set(Map,(s,c)=>new Map(r(Array.from(s),c))),i.set(Set,(s,c)=>new Set(r(Array.from(s),c))),l.constructorHandlers)for(const s of l.constructorHandlers)i.set(s[0],s[1]);let n=null;return l.proto?a:o;function r(s,c){const h=Object.keys(s),d=new Array(h.length);for(let u=0;u<h.length;u++){const g=h[u],p=s[g];if(typeof p!="object"||p===null)d[g]=p;else if(p.constructor!==Object&&(n=i.get(p.constructor)))d[g]=n(p,c);else if(ArrayBuffer.isView(p))d[g]=Re(p);else{const f=t.indexOf(p);f!==-1?d[g]=e[f]:d[g]=c(p)}}return d}function o(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return r(s,o);if(s.constructor!==Object&&(n=i.get(s.constructor)))return n(s,o);const c={};t.push(s),e.push(c);for(const h in s){if(Object.hasOwnProperty.call(s,h)===!1)continue;const d=s[h];if(typeof d!="object"||d===null)c[h]=d;else if(d.constructor!==Object&&(n=i.get(d.constructor)))c[h]=n(d,o);else if(ArrayBuffer.isView(d))c[h]=Re(d);else{const u=t.indexOf(d);u!==-1?c[h]=e[u]:c[h]=o(d)}}return t.pop(),e.pop(),c}function a(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return r(s,a);if(s.constructor!==Object&&(n=i.get(s.constructor)))return n(s,a);const c={};t.push(s),e.push(c);for(const h in s){const d=s[h];if(typeof d!="object"||d===null)c[h]=d;else if(d.constructor!==Object&&(n=i.get(d.constructor)))c[h]=n(d,a);else if(ArrayBuffer.isView(d))c[h]=Re(d);else{const u=t.indexOf(d);u!==-1?c[h]=e[u]:c[h]=a(d)}}return t.pop(),e.pop(),c}}$r(Ur)();function Kr(l,t){const e=l[t];if(!e)return null;const i=l[t+1];return!e.listId&&e.value===je&&i&&i.value!==je&&e.areaId===i.areaId?i:e}function Mi(l){return l.value===je&&!l.listWrap}const Yr=new RegExp(je,"g");class jr{constructor(t){Oi(this,"draw"),Oi(this,"range"),Oi(this,"defaultStyle"),this.draw=t,this.range={startIndex:-1,endIndex:-1},this.defaultStyle=null}get options(){return this.draw.getOptions()}get listener(){return this.draw.getListener()}get eventBus(){return this.draw.getEventBus()}get position(){return this.draw.getPosition()}get historyManager(){return this.draw.getHistoryManager()}getRange(){return this.range}getRangeClone(){return{...this.range}}clearRange(){this.setRange(-1,-1)}setDefaultStyle(t){t?this.defaultStyle={...this.defaultStyle,...t}:this.defaultStyle=null}getDefaultStyle(){return this.defaultStyle}getRangeAnchorStyle(t,e){const i=Kr(t,e);return i?{...i,...this.defaultStyle}:null}getIsRangeChange(t,e,i,n,r,o,a){return this.range.startIndex!==t||this.range.endIndex!==e||this.range.tableId!==i||this.range.startTdIndex!==n||this.range.endTdIndex!==r||this.range.startTrIndex!==o||this.range.endTrIndex!==a}getIsCollapsed(){const{startIndex:t,endIndex:e}=this.range;return t===e}getIsSelection(){const{startIndex:t,endIndex:e}=this.range;return!~t&&!~e?!1:t!==e}getSelection(){const{startIndex:t,endIndex:e}=this.range;return t===e?null:this.draw.getElementList().slice(t+1,e+1)}getSelectionElementList(){if(this.range.isCrossRowCol){const t=this.draw.getTableParticle().getRangeRowCol();if(!t)return null;const e=[];for(let i=0;i<t.length;i++){const n=t[i];for(let r=0;r<n.length;r++){const o=n[r];e.push(...o.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||Nn.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||Nn.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const i=this.position.getPositionList(),n=new Map;for(let r=t;r<e+1;r++){const{pageNo:o,rowNo:a}=i[r],s=n.get(o);s?s.has(a)||s.add(a):n.set(o,new Set([a]))}return n}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:i}=this.range;if(!~t&&!~e)return null;if(i)return this.getSelectionElementList();const n=this.getRangeRow();if(!n)return null;const r=this.position.getPositionList(),o=this.draw.getElementList(),a=[];for(let s=0;s<r.length;s++){const c=r[s],h=n.get(c.pageNo);h&&h.has(c.rowNo)&&a.push(o[s])}return a}getRangeParagraph(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const i=this.position.getPositionList(),n=this.draw.getElementList(),r=new Map;let o=t;for(;o>=0;){const{pageNo:c,rowNo:h}=i[o];let d=r.get(c);d||(d=[],r.set(c,d)),d.includes(h)||d.unshift(h);const u=n[o],g=n[o-1];if(Mi(u)||u.listId!==(g==null?void 0:g.listId)||u.titleId!==(g==null?void 0:g.titleId))break;o--}const a=t===e;if(!a){let c=t+1;for(;c<e;){const{pageNo:h,rowNo:d}=i[c];let u=r.get(h);u||(u=[],r.set(h,u)),u.includes(d)||u.push(d),c++}}let s=e;for(a&&n[t].value===je&&(s+=1);s<i.length;){const c=n[s],h=n[s+1];if(Mi(c)||c.listId!==(h==null?void 0:h.listId)||c.titleId!==(h==null?void 0:h.titleId))break;const{pageNo:d,rowNo:u}=i[s];let g=r.get(d);g||(g=[],r.set(d,g)),g.includes(u)||g.push(u),s++}return r}getRangeParagraphInfo(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;let i=-1;const n=[],r=this.getRangeParagraph();if(!r)return null;const o=this.draw.getElementList(),a=this.position.getPositionList();for(let s=0;s<a.length;s++){const c=a[s],h=r.get(c.pageNo);h&&h.includes(c.rowNo)&&(~i||(i=c.index),n.push(o[s]))}return n.length?{elementList:n,startIndex:i}:null}getRangeParagraphElementList(){var t;return((t=this.getRangeParagraphInfo())==null?void 0:t.elementList)||null}getRangeTableElement(){const t=this.position.getPositionContext();return t.isTable?this.draw.getOriginalElementList()[t.index]:null}getIsSelectAll(){const t=this.draw.getElementList(),{startIndex:e,endIndex:i}=this.range;return e===0&&t.length-1===i&&!this.position.getPositionContext().isTable}getIsPointInRange(t,e){const{startIndex:i,endIndex:n}=this.range,r=this.position.getPositionList();for(let o=i+1;o<=n&&r[o];o++){const{coordinate:{leftTop:a,rightBottom:s}}=r[o];if(t>=a[0]&&t<=s[0]&&e>=a[1]&&e<=s[1])return!0}return!1}getKeywordRangeList(t){const e=this.draw.getSearch().getMatchList(t,this.draw.getOriginalElementList()),i=new Map;for(const r of e){const o=i.get(r.groupId);if(o)o.endIndex+=1;else{const{type:a,groupId:s,tableId:c,index:h,tdIndex:d,trIndex:u}=r,g={startIndex:h,endIndex:h};a===Hn.TABLE&&(g.tableId=c,g.startTdIndex=d,g.endTdIndex=d,g.startTrIndex=u,g.endTrIndex=u),i.set(s,g)}}const n=[];return i.forEach(r=>{n.push(r)}),n}canInput(){var t;const{startIndex:e,endIndex:i}=this.getRange();if(!~e&&!~i)return!1;const n=this.draw.getElementList(),r=n[e];if(e===i)return(r.controlComponent!==Tt.PRE_TEXT||((t=n[e+1])==null?void 0:t.controlComponent)!==Tt.PRE_TEXT)&&r.controlComponent!==Tt.POST_TEXT;const o=n[i];return!r.controlId&&!o.controlId||(!r.controlId||r.controlComponent===Tt.POSTFIX)&&(!o.controlId||o.controlComponent===Tt.POSTFIX)||!!r.controlId&&o.controlId===r.controlId&&o.controlComponent!==Tt.PRE_TEXT&&o.controlComponent!==Tt.POST_TEXT&&o.controlComponent!==Tt.POSTFIX}setRange(t,e,i,n,r,o,a){this.getIsRangeChange(t,e,i,n,r,o,a)&&(this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=i,this.range.startTdIndex=n,this.range.endTdIndex=r,this.range.startTrIndex=o,this.range.endTrIndex=a,this.range.isCrossRowCol=n!==void 0||r!==void 0||o!==void 0||a!==void 0,this.setDefaultStyle(null)),this.range.zone=this.draw.getZone().getZone();const s=this.draw.getControl();if(~t&&~e){const c=this.draw.getElementList()[t];if(c!=null&&c.controlId){s.initControl();return}}s.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}shrinkRange(){const{startIndex:t,endIndex:e}=this.range;t===e||!~t&&!~e||this.replaceRange({...this.range,startIndex:e})}setRangeStyle(){var t;const e=this.listener.rangeStyleChange,i=this.eventBus.hasSubscribers("rangeStyleChange");if(!e&&!i)return;const{startIndex:n,endIndex:r,isCrossRowCol:o}=this.range;if(!~n&&!~r)return;let a;if(o){const V=this.draw.getOriginalElementList(),U=this.position.getPositionContext();a=V[U.index]}else{const V=~r?r:0,U=this.draw.getElementList();a=this.getRangeAnchorStyle(U,V)}if(!a)return;const s=!!((t=this.getSelectionElementList())!=null&&t.length),c=this.getSelection()||[a],h=a.type||At.TEXT,d=a.font||this.options.defaultFont,u=a.size||this.options.defaultSize,g=a.characterScale??100,p=!~c.findIndex(V=>!V.bold),f=!~c.findIndex(V=>!V.italic),D=!~c.findIndex(V=>{var U;return!V.underline&&!((U=V.control)!=null&&U.underline)}),C=!~c.findIndex(V=>!V.strikeout),I=a.color||null,E=a.highlight||null,w=a.paragraphColor||null;let v=0;{const V=this.draw.getElementList();for(let U=~r?r:0;U>=0;U--){const it=V[U];if(it.paragraphFirstLineIndent!==void 0){v=it.paragraphFirstLineIndent;break}if(U>0&&Mi(V[U-1]))break}}const L=a.rowFlex||null,T=a.rowMargin??this.options.defaultRowMargin,x=a.lineHeight??this.options.defaultLineHeight,B=a.dashArray||[],F=a.separatorType||null,M=a.separatorLineWidth??null,P=a.level||null,S=a.listType||null,_=a.listStyle||null,A=D&&a.textDecoration||null,y=!!this.draw.getPainterStyle(),N=this.historyManager.isCanUndo(),k=this.historyManager.isCanRedo(),z=a.groupIds||null;let O=a.extension??null;if(h===At.TABLE){const V={borderType:a.borderType??null,borderColor:a.borderColor??null,borderWidth:a.borderWidth??null,borderExternalWidth:a.borderExternalWidth??null};O&&typeof O=="object"&&!Array.isArray(O)?O={...O,table:V}:O={table:V}}const W={type:h,hasSelection:s,undo:N,redo:k,painter:y,font:d,size:u,characterScale:g,bold:p,italic:f,underline:D,strikeout:C,color:I,highlight:E,paragraphColor:w,rowFlex:L,rowMargin:T,lineHeight:x,dashArray:B,separatorType:F,separatorLineWidth:M,level:P,listType:S,listStyle:_,groupIds:z,textDecoration:A,paragraphFirstLineIndent:v,extension:O};e&&e(W),i&&this.eventBus.emit("rangeStyleChange",W)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.hasSubscribers("rangeStyleChange");if(!t&&!e)return;const i=this.options.defaultFont,n=this.options.defaultSize,r=this.options.defaultRowMargin,o=this.options.defaultLineHeight,a=!!this.draw.getPainterStyle(),s=this.historyManager.isCanUndo(),c=this.historyManager.isCanRedo(),h={type:null,hasSelection:!1,undo:s,redo:c,painter:a,font:i,size:n,characterScale:100,bold:!1,italic:!1,underline:!1,strikeout:!1,color:null,highlight:null,paragraphColor:null,rowFlex:null,rowMargin:r,lineHeight:o,dashArray:[],separatorType:null,separatorLineWidth:null,level:null,listType:null,listStyle:null,groupIds:null,textDecoration:null,paragraphFirstLineIndent:0,extension:null};t&&t(h),e&&this.eventBus.emit("rangeStyleChange",h)}shrinkBoundary(t={}){const e=t.elementList||this.draw.getElementList(),i=t.range||this.getRange(),{startIndex:n,endIndex:r}=i;if(!~n&&!~r)return;const o=e[n],a=e[r];if(n===r){if(o.controlComponent===Tt.PLACEHOLDER){let s=n-1;for(;s>0;){const c=e[s];if(c.controlId!==o.controlId||c.controlComponent===Tt.PREFIX||c.controlComponent===Tt.PRE_TEXT){i.startIndex=s,i.endIndex=s;break}s--}}}else{if(o.controlComponent===Tt.PLACEHOLDER||a.controlComponent===Tt.PLACEHOLDER){let s=r-1;for(;s>0;){const c=e[s];if(c.controlId!==a.controlId||c.controlComponent===Tt.PREFIX||c.controlComponent===Tt.PRE_TEXT){i.startIndex=s,i.endIndex=s;return}s--}}if(o.controlComponent===Tt.PREFIX){let s=n+1;for(;s<e.length;){const c=e[s];if(c.controlId!==o.controlId||c.controlComponent===Tt.VALUE){i.startIndex=s-1;break}else if(c.controlComponent===Tt.PLACEHOLDER){i.startIndex=s-1,i.endIndex=s-1;return}s++}}if(a.controlComponent!==Tt.VALUE){let s=r;for(;s>0;){const c=e[s];if(c.controlId!==o.controlId||c.controlComponent===Tt.VALUE){i.startIndex=s;break}else if(c.controlComponent===Tt.PLACEHOLDER){i.startIndex=s,i.endIndex=s;return}s--}}}}render(t,e,i,n,r){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,i,n,r),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(Yr,""):""}}var Zr={exports:{}};(function(l){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(s,c,h){this.fn=s,this.context=c,this.once=h||!1}function r(s,c,h,d,u){if(typeof h!="function")throw new TypeError("The listener must be a function");var g=new n(h,d||s,u),p=e?e+c:c;return s._events[p]?s._events[p].fn?s._events[p]=[s._events[p],g]:s._events[p].push(g):(s._events[p]=g,s._eventsCount++),s}function o(s,c){--s._eventsCount===0?s._events=new i:delete s._events[c]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var s=[],c,h;if(this._eventsCount===0)return s;for(h in c=this._events)t.call(c,h)&&s.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(c)):s},a.prototype.listeners=function(s){var c=e?e+s:s,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var d=0,u=h.length,g=new Array(u);d<u;d++)g[d]=h[d].fn;return g},a.prototype.listenerCount=function(s){var c=e?e+s:s,h=this._events[c];return h?h.fn?1:h.length:0},a.prototype.emit=function(s,c,h,d,u,g){var p=e?e+s:s;if(!this._events[p])return!1;var f=this._events[p],D=arguments.length,C,I;if(f.fn){switch(f.once&&this.removeListener(s,f.fn,void 0,!0),D){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,c),!0;case 3:return f.fn.call(f.context,c,h),!0;case 4:return f.fn.call(f.context,c,h,d),!0;case 5:return f.fn.call(f.context,c,h,d,u),!0;case 6:return f.fn.call(f.context,c,h,d,u,g),!0}for(I=1,C=new Array(D-1);I<D;I++)C[I-1]=arguments[I];f.fn.apply(f.context,C)}else{var E=f.length,w;for(I=0;I<E;I++)switch(f[I].once&&this.removeListener(s,f[I].fn,void 0,!0),D){case 1:f[I].fn.call(f[I].context);break;case 2:f[I].fn.call(f[I].context,c);break;case 3:f[I].fn.call(f[I].context,c,h);break;case 4:f[I].fn.call(f[I].context,c,h,d);break;default:if(!C)for(w=1,C=new Array(D-1);w<D;w++)C[w-1]=arguments[w];f[I].fn.apply(f[I].context,C)}}return!0},a.prototype.on=function(s,c,h){return r(this,s,c,h,!1)},a.prototype.once=function(s,c,h){return r(this,s,c,h,!0)},a.prototype.removeListener=function(s,c,h,d){var u=e?e+s:s;if(!this._events[u])return this;if(!c)return o(this,u),this;var g=this._events[u];if(g.fn)g.fn===c&&(!d||g.once)&&(!h||g.context===h)&&o(this,u);else{for(var p=0,f=[],D=g.length;p<D;p++)(g[p].fn!==c||d&&!g[p].once||h&&g[p].context!==h)&&f.push(g[p]);f.length?this._events[u]=f.length===1?f[0]:f:o(this,u)}return this},a.prototype.removeAllListeners=function(s){var c;return s?(c=e?e+s:s,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,l.exports=a})(Zr);class Wn{constructor(t){m(this,"draw");m(this,"options");m(this,"imageCache");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}_renderBackgroundColor(t,e,i,n){t.save(),t.fillStyle=e,t.fillRect(0,0,i,n),t.restore()}_drawImage(t,e,i,n){const{background:r,scale:o}=this.options;if(r.size===ue.CONTAIN){const a=e.width*o,s=e.height*o;if(!r.repeat||r.repeat===Ie.NO_REPEAT)t.drawImage(e,0,0,a,s);else{let c=0,h=0;const d=r.repeat===Ie.REPEAT||r.repeat===Ie.REPEAT_X?Math.ceil(i*o/a):1,u=r.repeat===Ie.REPEAT||r.repeat===Ie.REPEAT_Y?Math.ceil(n*o/s):1;for(let g=0;g<d;g++){for(let p=0;p<u;p++)t.drawImage(e,c,h,a,s),h+=s;h=0,c+=a}}}else t.drawImage(e,0,0,i*o,n*o)}_renderBackgroundImage(t,e,i){const{background:n}=this.options,r=this.imageCache.get(n.image);if(r)this._drawImage(t,r,e,i);else{const o=new Image;o.setAttribute("crossOrigin","Anonymous"),o.src=n.image,o.onload=()=>{this.imageCache.set(n.image,o),this._drawImage(t,o,e,i),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}}render(t,e){const{background:{image:i,color:n,applyPageNumbers:r}}=this.options;if(i&&(!(r!=null&&r.length)||r.includes(e))){const{width:o,height:a}=this.options;this._renderBackgroundImage(t,o,a)}else{const o=this.draw.getCanvasWidth(e),a=this.draw.getCanvasHeight(e);this._renderBackgroundColor(t,n,o,a)}}}const qr="solid",Qr=[0,0];function _i(l){return l.separatorType||qr}function zn(l,t){const e=Number(l.separatorLineWidth);return Number.isFinite(e)&&e>0?e:t}function Jr(l,t=_i(l)){return Array.isArray(l.dashArray)&&l.dashArray.length?l.dashArray:t==="dotted"?[1,1]:t==="dashed"?[6,3]:Qr}function Xn(l,t){const e=zn(l,t);switch(_i(l)){case"double":return e*3+2;case"triple":return e*5+4;case"wavy":return Math.max(e*4,8);case"shadow":return e+3;case"emboss":return e*2+3;default:return Math.max(e,1)}}class Ze{constructor(){m(this,"fillRect");m(this,"fillColor");m(this,"fillDecorationStyle");this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillDecorationStyle=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,i,n,r,o,a){const s=!this.fillRect.width;if(!s&&(this.fillColor!==o||this.fillDecorationStyle!==a)){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,i,n,r,o,a);return}s&&(this.fillRect.x=e,this.fillRect.y=i),r&&this.fillRect.height<r&&(this.fillRect.height=r),this.fillRect.width+=n,this.fillColor=o,this.fillDecorationStyle=a}}class $n extends Ze{constructor(e){super();m(this,"options");this.options=e.getOptions()}render(e){if(!this.fillRect.width)return;const{highlightAlpha:i}=this.options,{x:n,y:r,width:o,height:a}=this.fillRect;e.save(),e.globalAlpha=i,e.fillStyle=this.fillColor,e.fillRect(n,r,o,a),e.restore(),this.clearFillInfo()}}class Un extends Ze{render(t){if(!this.fillRect.width)return;const{x:e,y:i,width:n,height:r}=this.fillRect;t.save(),t.fillStyle=this.fillColor,t.fillRect(e,i,n,r),t.restore(),this.clearFillInfo()}}class Vn{constructor(t){m(this,"draw");m(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){if(this.options.marginIndicatorDisabled)return;const{marginIndicatorColor:i,pageMode:n}=this.options,r=this.draw.getWidth(),o=n===Le.CONTINUITY?this.draw.getCanvasHeight(e)/this.draw.getPagePixelRatio():this.draw.getHeight(),a=this.draw.getMargins(),s=this.draw.getMarginIndicatorSize();t.save(),t.translate(.5,.5),t.strokeStyle=i,t.beginPath();const c=[a[3],a[0]],h=[r-a[1],a[0]],d=[a[3],o-a[2]],u=[r-a[1],o-a[2]];t.moveTo(c[0]-s,c[1]),t.lineTo(...c),t.lineTo(c[0],c[1]-s),t.moveTo(h[0]+s,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]-s),t.moveTo(d[0]-s,d[1]),t.lineTo(...d),t.lineTo(d[0],d[1]+s),t.moveTo(u[0]+s,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]+s),t.stroke(),t.restore()}}class Gn{constructor(t){m(this,"draw");m(this,"options");m(this,"position");m(this,"searchKeyword");m(this,"searchNavigateIndex");m(this,"searchMatchList");this.draw=t,this.options=t.getOptions(),this.position=t.getPosition(),this.searchNavigateIndex=null,this.searchKeyword=null,this.searchMatchList=[]}getSearchKeyword(){return this.searchKeyword}setSearchKeyword(t){this.searchKeyword=t,this.searchNavigateIndex=null}searchNavigatePre(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex-1,e=!1;const i=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t>=0;){const n=this.searchMatchList[t];if(i!==n.groupId){e=!0,this.searchNavigateIndex=t-(this.searchKeyword.length-1);break}t--}if(!e){if(this.searchMatchList[this.searchMatchList.length-1].groupId===i)return null;this.searchNavigateIndex=this.searchMatchList.length-1-(this.searchKeyword.length-1)}}return this.searchNavigateIndex}searchNavigateNext(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex+1,e=!1;const i=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t<this.searchMatchList.length;){const n=this.searchMatchList[t];if(i!==n.groupId){e=!0,this.searchNavigateIndex=t;break}t++}if(!e){if(this.searchMatchList[0].groupId===i)return null;this.searchNavigateIndex=0}}return this.searchNavigateIndex}searchNavigateScrollIntoView(t){const{coordinate:{leftTop:e,leftBottom:i,rightTop:n},pageNo:r}=t,o=this.draw.getHeight(),a=this.draw.getPageGap(),s=r*(o+a),c=document.createElement("div");c.style.position="absolute";const h=50;c.style.width=`${n[0]-e[0]+h}px`,c.style.height=`${i[1]-e[1]+h}px`,c.style.left=`${e[0]}px`,c.style.top=`${e[1]+s}px`,this.draw.getContainer().append(c),c.scrollIntoView(!1),c.remove()}getSearchNavigateIndexList(){return this.searchNavigateIndex===null||!this.searchKeyword?[]:new Array(this.searchKeyword.length).fill(this.searchNavigateIndex).map((t,e)=>t+e)}getSearchMatchList(){return this.searchMatchList}getSearchNavigateInfo(){if(!this.searchKeyword||!this.searchMatchList.length)return null;const t=this.searchNavigateIndex!==null?this.searchNavigateIndex/this.searchKeyword.length+1:0;let e=0,i=null;for(let n=0;n<this.searchMatchList.length;n++){const r=this.searchMatchList[n];i!==r.groupId&&(i=r.groupId,e+=1)}return{index:t,count:e}}getMatchList(t,e){const i=t.toLocaleLowerCase(),n=[],r=[],o=e.length,a=[];for(let d=0;d<o;d++)e[d].type===R.TABLE&&a.push(d);let s=0,c=0;for(;c<o-1;){const d=a.length?a[s]:o,u=e.slice(c,d);u.length&&r.push({index:c,type:Ee.PAGE,elementList:u});const g=e[d];g&&r.push({index:d,type:Ee.TABLE,elementList:[g]}),c=d+1,s++}function h(d,u,g,p){if(!d)return;const f=g.map(I=>{var E,w;return!I.type||Jt.includes(I.type)&&I.controlComponent!==b.CHECKBOX&&!((E=I.control)!=null&&E.hide)&&!((w=I.area)!=null&&w.hide)?I.value:Y}).filter(Boolean).join("").toLocaleLowerCase(),D=[];let C=f.indexOf(d);for(;C!==-1;)D.push(C),C=f.indexOf(d,C+d.length);for(let I=0;I<D.length;I++){const E=D[I],w=pt();for(let v=0;v<d.length;v++){const L=E+v+((p==null?void 0:p.startIndex)||0);n.push({type:u,index:L,groupId:w,...p})}}}for(let d=0;d<r.length;d++){const u=r[d];if(u.type===Ee.TABLE){const g=u.elementList[0];for(let p=0;p<g.trList.length;p++){const f=g.trList[p];for(let D=0;D<f.tdList.length;D++){const C=f.tdList[D],I={tableId:g.id,tableIndex:u.index,trIndex:p,tdIndex:D,tdId:C.id};h(i,u.type,C.value,I)}}}else h(i,u.type,u.elementList,{startIndex:u.index})}return n}compute(t){this.searchMatchList=this.getMatchList(t,this.draw.getOriginalElementList())}render(t,e){var s,c;if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:i,searchMatchColor:n,searchNavigateMatchColor:r}=this.options,o=this.position.getOriginalPositionList(),a=this.draw.getOriginalElementList();t.save(),t.globalAlpha=i;for(let h=0;h<this.searchMatchList.length;h++){const d=this.searchMatchList[h];let u=null;if(d.type===Ee.TABLE){const{tableIndex:L,trIndex:T,tdIndex:x,index:B}=d;u=(c=(s=a[L])==null?void 0:s.trList[T].tdList[x])==null?void 0:c.positionList[B]}else u=o[d.index];if(!u)continue;const{coordinate:{leftTop:g,leftBottom:p,rightTop:f},pageNo:D}=u;if(D!==e)continue;if(this.getSearchNavigateIndexList().includes(h)){t.fillStyle=r;const L=this.searchMatchList[h-1];(!L||L.groupId!==d.groupId)&&this.searchNavigateScrollIntoView(u)}else t.fillStyle=n;const I=g[0],E=g[1],w=f[0]-g[0],v=p[1]-g[1];t.fillRect(I,E,w,v)}t.restore()}replace(t,e){var f,D,C,I;if(this.draw.isReadonly()||!t||new RegExp(`${Y}`,"g").test(t))return;let n=this.getSearchMatchList();const r=e==null?void 0:e.index;if(Us(r)){const E=[];n.forEach(w=>{const v=E[E.length-1];!v||v[0].groupId!==w.groupId?E.push([w]):v.push(w)}),n=E[r]}if(!(n!=null&&n.length))return;const o=this.draw.isDesignMode();let a=0,s=0,c="",h="",d=-1;const u=this.draw.getOriginalElementList();for(let E=0;E<n.length;E++){const w=n[E];if(w.type===Ee.TABLE){const{tableIndex:v,trIndex:L,tdIndex:T,index:x,tdId:B}=w;h&&B!==h&&(s=0),h=B;const F=v+a,M=u[F].trList[L].tdList[T].value,P=x+s,S=M[P];if(!o&&(((f=S==null?void 0:S.control)==null?void 0:f.deletable)===!1||((D=S==null?void 0:S.title)==null?void 0:D.deletable)===!1))continue;if(c===w.groupId){this.draw.spliceElementList(M,P,1),s--;continue}~d||(d=E);for(let _=0;_<t.length;_++){const A=t[_];_===0?S.value=A:(this.draw.spliceElementList(M,P+_,0,[{...S,value:A}]),s++)}}else{const v=w.index+a,L=u[v];if(!o&&(((C=L==null?void 0:L.control)==null?void 0:C.deletable)===!1||((I=L==null?void 0:L.title)==null?void 0:I.deletable)===!1)||L.type===R.CONTROL&&L.controlComponent!==b.VALUE)continue;if(~d||(d=E),c===w.groupId){this.draw.spliceElementList(u,v,1),a--;continue}for(let T=0;T<t.length;T++){const x=t[T];T===0?L.value=x:(this.draw.spliceElementList(u,v+T,0,[{...L,value:x}]),a++)}}c=w.groupId}if(!~d)return;const g=n[d],p=g.index+(t.length-1);if(g.type===Ee.TABLE){const{tableIndex:E,trIndex:w,tdIndex:v,index:L}=g,T=u[E].trList[w].tdList[v].value[L];this.position.setPositionContext({isTable:!0,index:E,trIndex:w,tdIndex:v,tdId:T.tdId,trId:T.trId,tableId:T.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(p,p),this.draw.render({curIndex:p})}}class Kn extends Ze{constructor(e){super();m(this,"options");this.options=e.getOptions()}render(e){if(!this.fillRect.width)return;const{scale:i,strikeoutColor:n}=this.options,{x:r,y:o,width:a}=this.fillRect;e.save(),e.lineWidth=i,e.strokeStyle=this.fillColor||n;const s=o+.5;e.beginPath(),e.moveTo(r,s),e.lineTo(r+a,s),e.stroke(),e.restore(),this.clearFillInfo()}}class Yn extends Ze{constructor(e){super();m(this,"options");this.options=e.getOptions()}_drawLine(e,i,n,r,o){const a=i+r;switch(e.beginPath(),o){case ze.DASHED:e.setLineDash([3,1]);break;case ze.DOTTED:e.setLineDash([1,1]);break}e.moveTo(i,n),e.lineTo(a,n),e.stroke()}_drawDouble(e,i,n,r){const a=i+r,s=n+3*this.options.scale;e.beginPath(),e.moveTo(i,n),e.lineTo(a,n),e.stroke(),e.beginPath(),e.moveTo(i,s),e.lineTo(a,s),e.stroke()}_drawWave(e,i,n,r){const{scale:o}=this.options,a=1.2*o,s=1/o,c=n+2*a;e.beginPath();for(let h=0;h<r;h++){const d=a*Math.sin(s*h);e.lineTo(i+h,c+d)}e.stroke()}render(e){if(!this.fillRect.width)return;const{underlineColor:i,scale:n}=this.options,{x:r,y:o,width:a}=this.fillRect;e.save(),e.strokeStyle=this.fillColor||i,e.lineWidth=n;const s=Math.floor(o+2*e.lineWidth)+.5;switch(this.fillDecorationStyle){case We.WAVY:this._drawWave(e,r,s,a);break;case We.DOUBLE:this._drawDouble(e,r,s,a);break;case We.DASHED:this._drawLine(e,r,s,a,ze.DASHED);break;case We.DOTTED:this._drawLine(e,r,s,a,ze.DOTTED);break;default:this._drawLine(e,r,s,a);break}e.restore(),this.clearFillInfo()}}class jn{constructor(t){m(this,"draw");m(this,"options");m(this,"imageCache");m(this,"container");m(this,"floatImageContainer");m(this,"floatImage");this.draw=t,this.options=t.getOptions(),this.container=t.getContainer(),this.imageCache=new Map,this.floatImageContainer=null,this.floatImage=null}getOriginalMainImageList(){const t=[],e=i=>{for(const n of i)if(n.type===R.TABLE){const r=n.trList;for(let o=0;o<r.length;o++){const a=r[o];for(let s=0;s<a.tdList.length;s++){const c=a.tdList[s];e(c.value)}}}else n.type===R.IMAGE&&t.push(n)};return e(this.draw.getOriginalMainElementList()),t}createFloatImage(t){const{scale:e}=this.options;let i=this.floatImageContainer,n=this.floatImage;i||(i=document.createElement("div"),i.classList.add(`${J}-float-image`),this.container.append(i),this.floatImageContainer=i),n||(n=document.createElement("img"),i.append(n),this.floatImage=n),i.style.display="none",n.style.width=`${t.width*e}px`,n.style.height=`${t.height*e}px`;const r=this.draw.getHeight(),o=this.draw.getPageGap(),a=this.draw.getPageNo()*(r+o),s=t.imgFloatPosition;i.style.left=`${s.x*e}px`,i.style.top=`${a+s.y*e}px`,n.setAttribute("crossOrigin","Anonymous"),n.src=t.value}dragFloatImage(t,e){if(!this.floatImageContainer)return;this.floatImageContainer.style.display="block";const i=parseFloat(this.floatImageContainer.style.left)+t,n=parseFloat(this.floatImageContainer.style.top)+e;this.floatImageContainer.style.left=`${i}px`,this.floatImageContainer.style.top=`${n}px`}destroyFloatImage(){this.floatImageContainer&&(this.floatImageContainer.style.display="none")}addImageObserver(t){this.draw.getImageObserver().add(t)}getFallbackImage(t,e){const n=(t-Math.ceil(t/8)*8)/2,r=(e-Math.ceil(e/8)*8)/2,o=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}" viewBox="0 0 ${t} ${e}">
30
+ <rect width="${t}" height="${e}" fill="url(#mosaic)" />
31
+ <defs>
32
+ <pattern id="mosaic" x="${n}" y="${r}" width="${8*2}" height="${8*2}" patternUnits="userSpaceOnUse">
33
+ <rect width="8" height="8" fill="#cccccc" />
34
+ <rect width="8" height="8" fill="#cccccc" transform="translate(8, 8)" />
35
+ </pattern>
36
+ </defs>
37
+ </svg>`,a=new Image;return a.src=`data:image/svg+xml;base64,${Ks(o)}`,a}render(t,e,i,n){const{scale:r}=this.options,o=e.width*r,a=e.height*r;if(this.imageCache.has(e.value)){const s=this.imageCache.get(e.value);t.drawImage(s,i,n,o,a)}else{const s=this.draw.getRenderCount(),c=new Promise(h=>{const d=new Image;d.setAttribute("crossOrigin","Anonymous"),d.src=e.value,d.onload=()=>{this.imageCache.set(e.value,d),h(e),s===this.draw.getRenderCount()&&(e.imgDisplay===Q.FLOAT_BOTTOM?this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}):t.drawImage(d,i,n,o,a))},d.onerror=()=>{const u=this.getFallbackImage(o,a);u.onload=()=>{t.drawImage(u,i,n,o,a),this.imageCache.set(e.value,u),h(e)},u.onerror=()=>{h(e)}}});this.addImageObserver(c)}}}class se{constructor(t){m(this,"draw");m(this,"options");m(this,"ctx");m(this,"curX");m(this,"curY");m(this,"text");m(this,"curStyle");m(this,"curColor");m(this,"curCharacterScale");m(this,"cacheMeasureText");this.draw=t,this.options=t.getOptions(),this.ctx=t.getCtx(),this.curX=-1,this.curY=-1,this.text="",this.curStyle="",this.curCharacterScale=100,this.cacheMeasureText=new Map}static getCharacterScaleRatio(t){const e=Math.round(t??100);return e>0?e/100:1}static fillScaledText(t,e,i,n,r){const o=se.getCharacterScaleRatio(r);if(o===1){t.fillText(e,i,n);return}t.save(),t.translate(i,n),t.scale(o,1),t.fillText(e,0,0),t.restore()}measureBasisWord(t,e){t.save(),t.font=e;const i=this.measureText(t,{value:No});return t.restore(),i}measureWord(t,e,i){const n=this.draw.getLetterReg();let r=0,o=e[i],a=i;for(;a<e.length;){const s=e[a];if(s.type&&s.type!==R.TEXT||!n.test(s.value)){o=s;break}r+=this.measureText(t,s).width,a++}return{width:r,endElement:o}}measurePunctuationWidth(t,e){return!e||!_o.includes(e.value)?0:this.measureText(t,e).width}measureText(t,e){if(e.width){const o=t.measureText(e.value);return{width:e.width,actualBoundingBoxAscent:o.actualBoundingBoxAscent,actualBoundingBoxDescent:o.actualBoundingBoxDescent,actualBoundingBoxLeft:o.actualBoundingBoxLeft,actualBoundingBoxRight:o.actualBoundingBoxRight,fontBoundingBoxAscent:o.fontBoundingBoxAscent,fontBoundingBoxDescent:o.fontBoundingBoxDescent}}const i=`${e.value}${t.font}`,n=this.cacheMeasureText.get(i);if(n)return n;const r=t.measureText(e.value);return this.cacheMeasureText.set(i,r),r}complete(){this._render(),this.text=""}record(t,e,i,n){if(this.ctx=t,this.options.renderMode===gi.COMPATIBILITY){this._setCurXY(i,n),this.text=e.value,this.curStyle=e.style,this.curColor=e.color,this.complete();return}this.text||this._setCurXY(i,n),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor||(e.characterScale??100)!==this.curCharacterScale)&&(this.complete(),this._setCurXY(i,n)),this.text+=e.value,this.curStyle=e.style,this.curColor=e.color,this.curCharacterScale=e.characterScale??100}_setCurXY(t,e){this.curX=t,this.curY=e}_render(){!this.text||!~this.curX||!~this.curX||(this.ctx.save(),this.ctx.font=this.curStyle,this.ctx.fillStyle=this.curColor||this.options.defaultColor,se.fillScaledText(this.ctx,this.text,this.curX,this.curY,this.curCharacterScale),this.ctx.restore())}}class we{constructor(t){m(this,"draw");m(this,"options");this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,i,n){const r=n===Vt.CHINESE?Gs(e):`${e}`;return t.replace(i,r)}render(t,e){const{scale:i,pageNumber:{size:n,font:r,color:o,rowFlex:a,numberType:s,format:c,startPageNo:h,fromPageNo:d}}=this.options;if(e<d)return;let u=c;const g=new RegExp($e.PAGE_NO);g.test(u)&&(u=we.formatNumberPlaceholder(u,e+h-d,g,s));const p=new RegExp($e.PAGE_COUNT);p.test(u)&&(u=we.formatNumberPlaceholder(u,this.draw.getPageCount()-d,p,s));const f=this.draw.getWidth(),D=this.draw.getHeight(),C=this.draw.getPageNumberBottom(),I=D-C;t.save(),t.fillStyle=o,t.font=`${n*i}px ${r}`;let E=0;const w=this.draw.getMargins(),{width:v}=t.measureText(u);a===gt.CENTER?E=(f-v)/2:a===gt.RIGHT?E=f-v-w[1]:E=w[3],t.fillText(u,E,I),t.restore()}}class Zn{constructor(t){m(this,"draw");m(this,"options");m(this,"scrollContainer");m(this,"_observer",Bs(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150));this.draw=t,this.options=t.getOptions(),this.scrollContainer=this.getScrollContainer(),setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}getScrollContainer(){return this.options.scrollContainerSelector&&document.querySelector(this.options.scrollContainerSelector)||document}_addEvent(){this.scrollContainer.addEventListener("scroll",this._observer)}removeEvent(){this.scrollContainer.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),i=this.scrollContainer===document?Math.max(document.documentElement.clientHeight,window.innerHeight):this.scrollContainer.clientHeight,n=Math.min(e.bottom,i)-Math.max(e.top,0);return{intersectionHeight:n>0?n:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let i=0,n=0;for(let r=0;r<t.length;r++){const o=t[r],{intersectionHeight:a}=this.getElementVisibleInfo(o);if(n&&!a)break;a&&e.push(r),a>n&&(n=a,i=r)}return{intersectionPageNo:i,visiblePageNoList:e}}}class qn{constructor(t){m(this,"step",5);m(this,"thresholdPoints",[70,40,10,20]);m(this,"selectionContainer");m(this,"rangeManager");m(this,"requestAnimationFrameId");m(this,"isMousedown");m(this,"isMoving");m(this,"clientWidth");m(this,"clientHeight");m(this,"containerRect");m(this,"_mousedown",()=>{if(this.isMousedown=!0,this.clientWidth=this.selectionContainer instanceof Document?document.documentElement.clientWidth:this.selectionContainer.clientWidth,this.clientHeight=this.selectionContainer instanceof Document?document.documentElement.clientHeight:this.selectionContainer.clientHeight,!(this.selectionContainer instanceof Document)){const t=this.selectionContainer.getBoundingClientRect();this.containerRect=t}});m(this,"_mouseup",()=>{this.isMousedown=!1,this._stopMove()});m(this,"_mousemove",t=>{if(!this.isMousedown||this.rangeManager.getIsCollapsed())return;let{x:e,y:i}=t;this.containerRect&&(e=e-this.containerRect.x,i=i-this.containerRect.y),i<this.thresholdPoints[0]?this._startMove(St.UP):this.clientHeight-i<=this.thresholdPoints[1]?this._startMove(St.DOWN):e<this.thresholdPoints[2]?this._startMove(St.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove(St.RIGHT):this._stopMove()});this.rangeManager=t.getRange();const{scrollContainerSelector:e}=t.getOptions();this.selectionContainer=e&&document.querySelector(e)||document,this.requestAnimationFrameId=null,this.isMousedown=!1,this.isMoving=!1,this.clientWidth=0,this.clientHeight=0,this.containerRect=null,this._addEvent()}_addEvent(){const t=this.selectionContainer;t.addEventListener("mousedown",this._mousedown),t.addEventListener("mousemove",this._mousemove),t.addEventListener("mouseup",this._mouseup),document.addEventListener("mouseleave",this._mouseup)}removeEvent(){const t=this.selectionContainer;t.removeEventListener("mousedown",this._mousedown),t.removeEventListener("mousemove",this._mousemove),t.removeEventListener("mouseup",this._mouseup),document.removeEventListener("mouseleave",this._mouseup)}_move(t){const e=this.selectionContainer instanceof Document?window:this.selectionContainer,i=this.selectionContainer instanceof Document?window.scrollX:e.scrollLeft,n=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===St.DOWN?e.scrollTo(i,n+this.step):t===St.UP?e.scrollTo(i,n-this.step):t===St.LEFT?e.scrollTo(i-this.step,n):e.scrollTo(i+this.step,n),this.requestAnimationFrameId=window.requestAnimationFrame(this._move.bind(this,t))}_startMove(t){this.isMoving||(this.isMoving=!0,this._move(t))}_stopMove(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=null,this.isMoving=!1)}}class Qn{constructor(t){m(this,"draw");m(this,"range");m(this,"options");this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){var i;const e=bt(t);for(let n=0;n<t.length;n++){const r=e[n];for(let o=r.tdList.length-1;o>=0;o--){const a=r.tdList[o],{rowspan:s,rowIndex:c,colIndex:h}=a,d=c+s-1;if(d!==o){const u=r.tdList.splice(o,1)[0];(i=e[d])==null||i.tdList.splice(h,0,u)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:i,tdIndex:n}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:r,startTdIndex:o,endTdIndex:a,startTrIndex:s,endTrIndex:c}=this.range.getRange(),u=this.draw.getOriginalElementList()[e].trList;if(!r)return[[u[i].tdList[n]]];let g=u[s].tdList[o],p=u[c].tdList[a];(g.x>p.x||g.y>p.y)&&([g,p]=[p,g]);const f=g.colIndex,D=p.colIndex+(p.colspan-1),C=g.rowIndex,I=p.rowIndex+(p.rowspan-1),E=[];for(let w=0;w<u.length;w++){const v=u[w],L=[];for(let T=0;T<v.tdList.length;T++){const x=v.tdList[T],B=x.colIndex,F=x.rowIndex;B>=f&&B<=D&&F>=C&&F<=I&&L.push(x)}L.length&&E.push(L)}return E.length?E:null}_drawSlash(t,e,i,n){var h,d;const{scale:r}=this.options;t.save();const o=e.width*r,a=e.height*r,s=Math.round(e.x*r+i),c=Math.round(e.y*r+n);t.beginPath(),(h=e.slashTypes)!=null&&h.includes(mi.FORWARD)&&(t.moveTo(s+o,c),t.lineTo(s,c+a)),(d=e.slashTypes)!=null&&d.includes(mi.BACK)&&(t.moveTo(s,c),t.lineTo(s+o,c+a)),t.stroke(),t.restore()}_drawBorder(t,e,i,n){var z;const{colgroup:r,trList:o,borderType:a,borderColor:s,borderWidth:c=.5,borderExternalWidth:h}=e;if(!r||!o)return;const{scale:d,table:{defaultBorderColor:u}}=this.options,g=r.length,p=o.length,f=s||u,D=c,C=h||D,I=a===Kt.DASH?"dashed":"solid",E=a===Kt.EMPTY,w=a===Kt.EXTERNAL,v=a===Kt.INTERNAL,L=!E&&!v,T=!E&&!w,x=O=>O==="double"?4:O==="solid"?3:O==="dashed"?2:O==="dotted"?1:0,B=O=>{const W=Number(O==null?void 0:O.width),V=Number.isFinite(W)?W:D,U=typeof(O==null?void 0:O.color)=="string"&&O.color?O.color:f,it=(O==null?void 0:O.style)==="dashed"||(O==null?void 0:O.style)==="dotted"||(O==null?void 0:O.style)==="double"?O.style:I;return{width:V,color:U,style:it}},F=(O,W)=>O?W?O.width!==W.width?O.width>W.width?O:W:O.style!==W.style?x(O.style)>=x(W.style)?O:W:O:O:W,M=new Map,P=(O,W)=>{const V=M.get(O);if(!V){M.set(O,W);return}const U=F(V,W);M.set(O,U)},S=(O,W,V,U)=>{const it=Math.min(O,W),Z=Math.max(O,W),tt=`H:${V}:${it}-${Z}`,nt=B(U);P(tt,{x1:it,y1:V,x2:Z,y2:V,...nt})},_=(O,W,V,U)=>{const it=Math.min(W,V),Z=Math.max(W,V),tt=`V:${O}:${it}-${Z}`,nt=B(U);P(tt,{x1:O,y1:it,x2:O,y2:Z,...nt})},A=O=>({width:O?C:D,color:f,style:I}),y=(O,W,V)=>{var it,Z;const U=(it=O.borderStyle)==null?void 0:it[W];return U||((Z=O.borderTypes)!=null&&Z.includes(W)?{width:D,color:f,style:I}:V)};t.save(),t.translate(.5,.5);for(let O=0;O<o.length;O++){const W=o[O];for(let V=0;V<W.tdList.length;V++){const U=W.tdList[V];(z=U.slashTypes)!=null&&z.length&&this._drawSlash(t,U,i,n);const it=Math.round(U.x*d+i),Z=Math.round(U.y*d+n),tt=Math.round((U.x+U.width)*d+i),nt=Math.round((U.y+U.height)*d+n),Mt=U.colIndex===0,j=U.colIndex+U.colspan===g,G=U.rowIndex===0,H=U.rowIndex+U.rowspan===p,ht=L&&G?A(!0):null,Pt=L&&H?A(!0):null,_t=L&&Mt?A(!0):null,re=L&&j?A(!0):null,me=T&&U.colIndex+U.colspan<g?A(!1):null,$=T&&U.rowIndex+U.rowspan<p?A(!1):null,le=y(U,ne.TOP,ht),ae=y(U,ne.BOTTOM,Pt||$),ce=y(U,ne.LEFT,_t),Oe=y(U,ne.RIGHT,re||me);le&&le.style!=="none"&&S(it,tt,Z,le),ae&&ae.style!=="none"&&S(it,tt,nt,ae),ce&&ce.style!=="none"&&_(it,Z,nt,ce),Oe&&Oe.style!=="none"&&_(tt,Z,nt,Oe)}}const N=O=>`${O.color}|${O.width}|${O.style}`,k=new Map;for(const O of M.values()){const W=N(O),V=k.get(W);V?V.push(O):k.set(W,[O])}for(const[O,W]of k){const[V,U,it]=O.split("|"),Z=Number(U);t.strokeStyle=V;const tt=(Number.isFinite(Z)?Z:D)*d;if(it==="double"){const nt=Math.max(.5*d,Math.round(tt/3*10)/10),Mt=Math.max(.5*d,Math.round(nt*1.2*10)/10),j=(nt+Mt)/2;t.setLineDash([]),t.lineWidth=nt,t.beginPath();for(const G of W){const H=G.y1===G.y2,ht=G.x1===G.x2;H?(t.moveTo(G.x1,G.y1-j),t.lineTo(G.x2,G.y2-j),t.moveTo(G.x1,G.y1+j),t.lineTo(G.x2,G.y2+j)):ht?(t.moveTo(G.x1-j,G.y1),t.lineTo(G.x2-j,G.y2),t.moveTo(G.x1+j,G.y1),t.lineTo(G.x2+j,G.y2)):(t.moveTo(G.x1,G.y1),t.lineTo(G.x2,G.y2))}t.stroke()}else{t.lineWidth=tt,it==="dashed"?t.setLineDash([3*d,3*d]):it==="dotted"?t.setLineDash([1*d,2*d]):t.setLineDash([]),t.beginPath();for(const nt of W)t.moveTo(nt.x1,nt.y1),t.lineTo(nt.x2,nt.y2);t.stroke()}}t.setLineDash([]),t.translate(-.5,-.5),t.restore()}_drawBackgroundColor(t,e,i,n){const{trList:r}=e;if(!r)return;const{scale:o}=this.options;for(let a=0;a<r.length;a++){const s=r[a];for(let c=0;c<s.tdList.length;c++){const h=s.tdList[c];if(!h.backgroundColor)continue;t.save();const d=h.width*o,u=h.height*o,g=Math.round(h.x*o+i),p=Math.round(h.y*o+n);t.fillStyle=h.backgroundColor,t.fillRect(g,p,d,u),t.restore()}}}getTableWidth(t){return t.colgroup.reduce((e,i)=>e+i.width,0)}getTableHeight(t){const e=t.trList;return e!=null&&e.length?this.getTdListByColIndex(e,0).reduce((i,n)=>i+n.height,0):0}getRowCountByColIndex(t,e){return this.getTdListByColIndex(t,e).reduce((i,n)=>i+n.rowspan,0)}getTdListByColIndex(t,e){const i=[];for(let n=0;n<t.length;n++){const r=t[n].tdList;for(let o=0;o<r.length;o++){const a=r[o],s=a.colIndex,c=s+a.colspan-1;e>=s&&e<=c&&i.push(a)}}return i}getTdListByRowIndex(t,e){const i=[];for(let n=0;n<t.length;n++){const r=t[n].tdList;for(let o=0;o<r.length;o++){const a=r[o],s=a.rowIndex,c=s+a.rowspan-1;e>=s&&e<=c&&i.push(a)}}return i}computeRowColInfo(t){const{colgroup:e,trList:i}=t;if(!e||!i)return;const n=e.length,r=i.length;if(!n||!r)return;const o=new Array(n).fill(0);let a=0;for(let u=0;u<n;u++)o[u]=a,a+=e[u].width;const s=new Array(r).fill(0);let c=0;for(let u=0;u<r;u++)s[u]=c,c+=i[u].height;const h=new Array(n).fill(0),d=(u,g)=>{if(u<0||u+g>n)return!1;for(let p=u;p<u+g;p++)if(h[p]>0)return!1;return!0};for(let u=0;u<r;u++){for(let p=0;p<n;p++)h[p]>0&&(h[p]-=1);const g=i[u];for(let p=0;p<g.tdList.length;p++){const f=g.tdList[p],D=Math.max(1,f.colspan||1),C=Math.max(1,f.rowspan||1);let I=0,E=!1;const w=Math.max(0,n-D);for(let F=0;F<=w;F++)if(d(F,D)){I=F,E=!0;break}E||(I=Math.max(0,Math.min(n-1,n-D)));for(let F=I;F<I+D&&F<n;F++)h[F]=Math.max(h[F],C);let v=0;for(let F=0;F<D;F++){const M=e[I+F];if(!M)break;v+=M.width}let L=0;for(let F=0;F<C;F++){const M=i[u+F];if(!M)break;L+=M.height}const T=g.tdList.length-1===p,x=u+C===r,B=T&&x&&I+D===n;f.isLastRowTd=T,f.isLastColTd=x,f.isLastTd=B,f.x=o[I],f.y=s[u],f.width=v,f.height=L,f.rowIndex=u,f.colIndex=I,f.trIndex=u,f.tdIndex=p}}}drawRange(t,e,i,n){const{scale:r,rangeAlpha:o,rangeColor:a}=this.options,{type:s,trList:c}=e;if(!c||s!==R.TABLE)return;const{isCrossRowCol:h,startTdIndex:d,endTdIndex:u,startTrIndex:g,endTrIndex:p}=this.range.getRange();if(!h)return;let f=c[g].tdList[d],D=c[p].tdList[u];(f.x>D.x||f.y>D.y)&&([f,D]=[D,f]);const C=f.colIndex,I=D.colIndex+(D.colspan-1),E=f.rowIndex,w=D.rowIndex+(D.rowspan-1);t.save();for(let v=0;v<c.length;v++){const L=c[v];for(let T=0;T<L.tdList.length;T++){const x=L.tdList[T],B=x.colIndex,F=x.rowIndex;if(B>=C&&B<=I&&F>=E&&F<=w){const M=x.x*r,P=x.y*r,S=x.width*r,_=x.height*r;t.globalAlpha=o,t.fillStyle=a,t.fillRect(M+i,P+n,S,_)}}}t.restore()}render(t,e,i,n){this._drawBackgroundColor(t,e,i,n),this._drawBorder(t,e,i,n)}}class Jn{constructor(t){m(this,"MIN_TD_WIDTH",20);m(this,"ROW_COL_OFFSET",18);m(this,"ROW_COL_QUICK_WIDTH",16);m(this,"ROW_COL_QUICK_OFFSET",5);m(this,"ROW_COL_QUICK_POSITION",this.ROW_COL_OFFSET+(this.ROW_COL_OFFSET-this.ROW_COL_QUICK_WIDTH)/2);m(this,"BORDER_VALUE",4);m(this,"TABLE_SELECT_OFFSET",20);m(this,"draw");m(this,"canvas");m(this,"options");m(this,"position");m(this,"range");m(this,"container");m(this,"toolRowContainer");m(this,"toolRowAddBtn");m(this,"toolColAddBtn");m(this,"toolTableSelectBtn");m(this,"toolColContainer");m(this,"toolBorderContainer");m(this,"anchorLine");m(this,"mousedownX");m(this,"mousedownY");this.draw=t,this.canvas=t.getPage(),this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.container=t.getContainer(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null,this.anchorLine=null,this.mousedownX=0,this.mousedownY=0}dispose(){var t,e,i,n,r,o;(t=this.toolRowContainer)==null||t.remove(),(e=this.toolRowAddBtn)==null||e.remove(),(i=this.toolColAddBtn)==null||i.remove(),(n=this.toolTableSelectBtn)==null||n.remove(),(r=this.toolColContainer)==null||r.remove(),(o=this.toolBorderContainer)==null||o.remove(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null}render(){const{isTable:t,index:e,trIndex:i,tdIndex:n}=this.position.getPositionContext();if(!t)return;this.dispose();const r=this.draw.getOriginalElementList(),o=this.position.getOriginalPositionList(),a=r[e];if(a.tableToolDisabled&&!this.draw.isDesignMode())return;const{scale:s}=this.options,c=o[e],{colgroup:h,trList:d}=a,{coordinate:{leftTop:u}}=c,g=this.draw.getHeight(),p=this.draw.getPageGap(),f=this.draw.getPageNo()*(g+p),D=u[0],C=u[1]+f,I=a.trList[i].tdList[n],E=I.rowIndex,w=I.colIndex,v=a.height*s,L=a.width*s,T=document.createElement("div");T.classList.add(`${J}-table-tool__select`),T.style.height=`${v*s}`,T.style.left=`${D}px`,T.style.top=`${C}px`,T.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*s}px, ${-this.TABLE_SELECT_OFFSET*s}px)`,T.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(T),this.toolTableSelectBtn=T;const x=d.map(A=>A.height),B=document.createElement("div");B.classList.add(`${J}-table-tool__row`),B.style.transform=`translateX(-${this.ROW_COL_OFFSET*s}px)`;for(let A=0;A<x.length;A++){const y=x[A]*s,N=document.createElement("div");N.classList.add(`${J}-table-tool__row__item`),A===E&&N.classList.add("active"),N.onclick=()=>{const z=this.draw.getTableParticle().getTdListByRowIndex(d,A),O=z[0],W=z[z.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:O.trIndex,tdIndex:O.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,O.tdIndex,W.tdIndex,O.trIndex,W.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(B,A)};const k=document.createElement("div");k.classList.add(`${J}-table-tool__anchor`),k.onmousedown=z=>{this._mousedown({evt:z,element:a,index:A,order:pe.ROW})},N.append(k),N.style.height=`${y}px`,B.append(N)}B.style.left=`${D}px`,B.style.top=`${C}px`,this.container.append(B),this.toolRowContainer=B;const F=document.createElement("div");F.classList.add(`${J}-table-tool__quick__add`),F.style.left=`${D+L/2}px`,F.style.top=`${C+v}px`,F.style.transform=`translate(-50%, ${this.ROW_COL_QUICK_OFFSET*s}px)`,F.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:d.length-1,tdIndex:0,tableId:a.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(F),this.toolRowAddBtn=F;const M=h.map(A=>A.width),P=document.createElement("div");P.classList.add(`${J}-table-tool__col`),P.style.transform=`translateY(-${this.ROW_COL_OFFSET*s}px)`;for(let A=0;A<M.length;A++){const y=M[A]*s,N=document.createElement("div");N.classList.add(`${J}-table-tool__col__item`),A===w&&N.classList.add("active"),N.onclick=()=>{const z=this.draw.getTableParticle().getTdListByColIndex(d,A),O=z[0],W=z[z.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:O.trIndex,tdIndex:O.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,O.tdIndex,W.tdIndex,O.trIndex,W.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(P,A)};const k=document.createElement("div");k.classList.add(`${J}-table-tool__anchor`),k.onmousedown=z=>{this._mousedown({evt:z,element:a,index:A,order:pe.COL})},N.append(k),N.style.width=`${y}px`,P.append(N)}P.style.left=`${D}px`,P.style.top=`${C}px`,this.container.append(P),this.toolColContainer=P;const S=document.createElement("div");S.classList.add(`${J}-table-tool__quick__add`),S.style.height=`${v*s}`,S.style.left=`${D+L}px`,S.style.top=`${C}px`,S.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*s}px, -${this.ROW_COL_QUICK_POSITION*s}px)`,S.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:d[0].tdList.length-1||0,tableId:a.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(S),this.toolColAddBtn=S;const _=document.createElement("div");_.classList.add(`${J}-table-tool__border`),_.style.height=`${v}px`,_.style.width=`${L}px`,_.style.left=`${D}px`,_.style.top=`${C}px`;for(let A=0;A<d.length;A++){const y=d[A];for(let N=0;N<y.tdList.length;N++){const k=y.tdList[N],z=document.createElement("div");z.classList.add(`${J}-table-tool__border__row`),z.style.width=`${k.width*s}px`,z.style.height=`${this.BORDER_VALUE}px`,z.style.top=`${(k.y+k.height)*s-this.BORDER_VALUE/2}px`,z.style.left=`${k.x*s}px`,z.onmousedown=W=>{this._mousedown({evt:W,element:a,index:k.rowIndex+k.rowspan-1,order:pe.ROW})},_.appendChild(z);const O=document.createElement("div");O.classList.add(`${J}-table-tool__border__col`),O.style.width=`${this.BORDER_VALUE}px`,O.style.height=`${k.height*s}px`,O.style.top=`${k.y*s}px`,O.style.left=`${(k.x+k.width)*s-this.BORDER_VALUE/2}px`,O.onmousedown=W=>{this._mousedown({evt:W,element:a,index:k.colIndex+k.colspan-1,order:pe.COL})},_.appendChild(O)}}this.container.append(_),this.toolBorderContainer=_}_setAnchorActive(t,e){const i=t.children;for(let n=0;n<i.length;n++){const r=i[n];n===e?r.classList.add("active"):r.classList.remove("active")}}_mousedown(t){const{evt:e,index:i,order:n,element:r}=t;this.canvas=this.draw.getPage();const{scale:o}=this.options,a=this.draw.getWidth(),s=this.draw.getHeight(),c=this.draw.getPageGap(),h=this.draw.getPageNo()*(s+c);this.mousedownX=e.x,this.mousedownY=e.y;const d=e.target,u=this.canvas.getBoundingClientRect(),g=window.getComputedStyle(d).cursor;document.body.style.cursor=g,this.canvas.style.cursor=g;let p=0,f=0;const D=document.createElement("div");D.classList.add(`${J}-table-anchor__line`),n===pe.ROW?(D.classList.add(`${J}-table-anchor__line__row`),D.style.width=`${a}px`,p=0,f=h+this.mousedownY-u.top):(D.classList.add(`${J}-table-anchor__line__col`),D.style.height=`${s}px`,p=this.mousedownX-u.left,f=h),D.style.left=`${p}px`,D.style.top=`${f}px`,this.container.append(D),this.anchorLine=D;let C=0,I=0;const E=w=>{const v=this._mousemove(w,n,p,f);v&&(C=v.dx,I=v.dy)};document.addEventListener("mousemove",E),document.addEventListener("mouseup",()=>{var v;let w=!1;if(n===pe.ROW){const L=r.trList,T=L[i]||L[i-1],{defaultTrMinHeight:x}=this.options.table;I<0&&T.height+I<x&&(I=x-T.height),I&&(T.height+=I,T.minHeight=T.height,w=!0)}else{const{colgroup:L}=r;if(L&&C){const T=this.draw.getInnerWidth(),x=L[i].width;C<0&&x+C<this.MIN_TD_WIDTH&&(C=this.MIN_TD_WIDTH-x);const B=(v=L[i+1])==null?void 0:v.width;C>0&&B&&B-C<this.MIN_TD_WIDTH&&(C=B-this.MIN_TD_WIDTH);const F=x+C;if(i===L.length-1){let M=0;for(let P=0;P<L.length;P++){const S=L[P];P===i+1&&(M-=C),P===i&&(M+=F),P!==i&&(M+=S.width)}if(M>T){const P=r.width;C=T-P}}C&&(L.length-1!==i&&(L[i+1].width-=C/o),L[i].width+=C/o,w=!0)}}w&&this.draw.render({isSetCursor:!1}),D.remove(),document.removeEventListener("mousemove",E),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,i,n){if(!this.anchorLine)return null;const r=t.x-this.mousedownX,o=t.y-this.mousedownY;return e===pe.ROW?this.anchorLine.style.top=`${n+o}px`:this.anchorLine.style.left=`${i+r}px`,t.preventDefault(),{dx:r,dy:o}}}class to{constructor(t){m(this,"draw");m(this,"options");m(this,"container");m(this,"hyperlinkPopupContainer");m(this,"hyperlinkDom");this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:i}=this._createHyperlinkPopupDom();this.hyperlinkDom=i,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${J}-hyperlink-popup`);const e=document.createElement("a");return e.target="_blank",e.rel="noopener",t.append(e),this.container.append(t),{hyperlinkPopupContainer:t,hyperlinkDom:e}}_isSafeUrl(t){try{const e=new URL(t,"https://placeholder.local");return e.protocol==="http:"||e.protocol==="https:"}catch{return t.startsWith("#")||t.startsWith("/")}}drawHyperlinkPopup(t,e){const{coordinate:{leftTop:[i,n]},lineHeight:r}=e,o=this.draw.getHeight(),a=this.draw.getPageGap(),s=this.draw.getPageNo()*(o+a);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${i}px`,this.hyperlinkPopupContainer.style.top=`${n+s+r}px`;const c=t.url||"#";this._isSafeUrl(c)?this.hyperlinkDom.href=c:this.hyperlinkDom.removeAttribute("href"),this.hyperlinkDom.title=c,this.hyperlinkDom.innerText=c}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=t.url;if(!e||!this._isSafeUrl(e)){console.warn(`[HyperlinkParticle] Blocked unsafe URL protocol: ${e}`);return}const i=window.open(e,"_blank","noopener");i&&(i.opener=null)}render(t,e,i,n){t.save(),t.font=e.style,e.color||(e.color=this.options.defaultHyperlinkColor),t.fillStyle=e.color,e.underline===void 0&&(e.underline=!0),se.fillScaledText(t,e.value,i,n,e.characterScale),t.restore()}}class eo{constructor(t,e){m(this,"draw");m(this,"position");m(this,"zone");m(this,"options");m(this,"elementList");m(this,"rowList");m(this,"positionList");this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth(),e=this.draw.getMargins(),i=rn(this.elementList);this.rowList=this.draw.computeRowList({startX:e[3],startY:this.getHeaderTop(),innerWidth:t,elementList:this.elementList,surroundElementList:i})}_computePositionList(){const t=this.getHeaderTop(),e=this.draw.getInnerWidth(),n=this.draw.getMargins()[3],r=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:n,startY:r,innerWidth:e,zone:st.HEADER})}getHeaderTop(){const{header:{top:t,disabled:e},scale:i}=this.options;return e?0:Math.floor(t*i)}getMaxHeight(){const{header:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*Ki[t])}getHeight(){const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),n=this.getHeaderTop()+e-t[0];return n<=0?0:n}render(t,e){t.save(),t.globalAlpha=this.zone.isHeaderActive()?1:this.options.header.inactiveAlpha;const i=this.draw.getInnerWidth(),n=this.getMaxHeight(),r=[];let o=0;for(let a=0;a<this.rowList.length;a++){const s=this.rowList[a];if(o+s.height>n)break;r.push(s),o+=s.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:r,pageNo:e,startIndex:0,innerWidth:i,zone:st.HEADER,isDrawLineBreak:!1}),t.restore()}}class io{getOffsetY(t){return-t.metrics.height/2}render(t,e,i,n){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),se.fillScaledText(t,e.value,i,n+this.getOffsetY(e),e.characterScale),t.restore()}}class no{getOffsetY(t){return t.metrics.height/2}render(t,e,i,n){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),se.fillScaledText(t,e.value,i,n+this.getOffsetY(e),e.characterScale),t.restore()}}class oo{constructor(t){m(this,"options");this.options=t.getOptions()}withAlpha(t,e){const i=Math.max(0,Math.min(1,e));if(t.startsWith("#")){const r=t.slice(1),o=r.length===3?r.split("").map(a=>a+a).join(""):r.length===6?r:"";if(o){const a=Number.parseInt(o.slice(0,2),16),s=Number.parseInt(o.slice(2,4),16),c=Number.parseInt(o.slice(4,6),16);return`rgba(${a}, ${s}, ${c}, ${i})`}}const n=t.match(/^rgba?\(([^)]+)\)$/i);if(n){const[r="0",o="0",a="0"]=n[1].split(",").map(s=>s.trim());return`rgba(${r}, ${o}, ${a}, ${i})`}return t}scaleDashArray(t,e,i){return t.some(n=>n>0)?t.map(n=>n<=0?0:Math.max(n*Math.max(e*Math.max(i,1),1),1)):[]}drawStraightLine(t,e,i,n,r,o,a=[]){t.save(),t.lineWidth=r,t.strokeStyle=o,t.lineCap=a.length?"round":"butt",t.setLineDash(a),t.beginPath(),t.moveTo(e,n),t.lineTo(i,n),t.stroke(),t.restore()}drawWavyLine(t,e,i,n,r,o){const a=Math.max(r,2),s=Math.max(r*6,12);t.save(),t.lineWidth=r,t.strokeStyle=o,t.lineCap="round",t.lineJoin="round",t.beginPath(),t.moveTo(e,n);let c=e;for(;c<i;){const h=Math.min(c+s/2,i),d=Math.min(c+s,i);t.quadraticCurveTo(c+s/4,n-a,h,n),h<i&&t.quadraticCurveTo(c+s*3/4,n+a,d,n),c=d}t.stroke(),t.restore()}render(t,e,i,n){t.save();const{scale:r,separator:{lineWidth:o,strokeStyle:a}}=this.options,s=i,c=i+(e.width||0)*r,h=_i(e),d=zn(e,o)*r,u=this.scaleDashArray(Jr(e,h),r,d),g=e.color||a,p=Xn(e,o)*r,f=Math.round(n+p/2);if(c<=s){t.restore();return}if(h==="double"){const D=Math.max(d+r,2);this.drawStraightLine(t,s,c,f-D/2,d,g,u),this.drawStraightLine(t,s,c,f+D/2,d,g,u)}else if(h==="triple"){const D=Math.max(d+r,2);this.drawStraightLine(t,s,c,f-D,d,g,u),this.drawStraightLine(t,s,c,f,d,g,u),this.drawStraightLine(t,s,c,f+D,d,g,u)}else if(h==="wavy")this.drawWavyLine(t,s,c,f,d,g);else if(h==="gradient"){const D=t.createLinearGradient(s,f,c,f);D.addColorStop(0,this.withAlpha(g,0)),D.addColorStop(.2,this.withAlpha(g,.4)),D.addColorStop(.5,this.withAlpha(g,1)),D.addColorStop(.8,this.withAlpha(g,.4)),D.addColorStop(1,this.withAlpha(g,0)),this.drawStraightLine(t,s,c,f,d,D,u)}else h==="shadow"?(this.drawStraightLine(t,s+r,c+r,f+r,d,this.withAlpha("#000000",.18),u),this.drawStraightLine(t,s,c,f,d,g,u)):h==="emboss"?(this.drawStraightLine(t,s,c,f-r,Math.max(d/2,1),this.withAlpha("#ffffff",.85),u),this.drawStraightLine(t,s,c,f,d,g,u),this.drawStraightLine(t,s,c,f+r,Math.max(d/2,1),this.withAlpha("#000000",.25),u)):this.drawStraightLine(t,s,c,f,d,g,u);t.restore()}}class so{constructor(t){m(this,"draw");m(this,"options");m(this,"i18n");this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,i,n){const{pageBreak:{font:r,fontSize:o,lineDash:a}}=this.draw.getOptions(),s=this.i18n.t("pageBreak.displayName"),{scale:c,defaultRowMargin:h}=this.options,d=o*c,u=e.width*c,g=this.draw.getDefaultBasicRowMarginHeight()*h;t.save(),t.font=`${d}px ${r}`;const p=t.measureText(s),f=(u-p.width)/2;t.setLineDash(a),t.translate(0,.5+g),t.beginPath(),t.moveTo(i,n),t.lineTo(i+f,n),t.moveTo(i+f+p.width,n),t.lineTo(i+u,n),t.stroke(),t.fillText(s,i+f,n+p.actualBoundingBoxAscent-d/2),t.restore()}}class ro{constructor(t){m(this,"draw");m(this,"options");m(this,"imageCache");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}renderText(t,e){const{watermark:{data:i,opacity:n,font:r,size:o,color:a,repeat:s,gap:c,numberType:h},scale:d}=this.options,u=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=n,t.font=`${o*d}px ${r}`;let p=i;const f=new RegExp($e.PAGE_NO);f.test(p)&&(p=we.formatNumberPlaceholder(p,e+1,f,h));const D=new RegExp($e.PAGE_COUNT);D.test(p)&&(p=we.formatNumberPlaceholder(p,this.draw.getPageCount(),D,h));const C=t.measureText(p);if(s){let I,E;typeof OffscreenCanvas<"u"?(I=new OffscreenCanvas(1,1),E=I.getContext("2d")):(I=document.createElement("canvas"),E=I.getContext("2d"));const w=C.width,v=C.actualBoundingBoxAscent+C.actualBoundingBoxDescent,L=Math.sqrt(Math.pow(w,2)+Math.pow(v,2)),T=L+2*c[0]*d,x=L+2*c[1]*d;I.width=T,I.height=x,E.translate(T/2,x/2),E.rotate(-45*Math.PI/180),E.translate(-T/2,-x/2),E.font=`${o*d}px ${r}`,E.fillStyle=a,E.fillText(p,(T-w)/2,(x-v)/2+C.actualBoundingBoxAscent);const B=t.createPattern(I,"repeat");B&&(t.fillStyle=B,t.fillRect(0,0,u,g))}else{const I=u/2,E=g/2;t.fillStyle=a,t.translate(I,E),t.rotate(-45*Math.PI/180),t.fillText(p,-C.width/2,C.actualBoundingBoxAscent-o*d/2)}t.restore()}renderImage(t){const{watermark:{width:e,height:i,data:n,opacity:r,repeat:o,gap:a},scale:s}=this.options;if(!this.imageCache.has(n)){const g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=n,g.onload=()=>{this.imageCache.set(n,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const c=this.draw.getWidth(),h=this.draw.getHeight(),d=e*s,u=i*s;if(t.save(),t.globalAlpha=r,o){let g,p;typeof OffscreenCanvas<"u"?(g=new OffscreenCanvas(1,1),p=g.getContext("2d")):(g=document.createElement("canvas"),p=g.getContext("2d"));const f=Math.sqrt(Math.pow(d,2)+Math.pow(u,2)),D=f+2*a[0]*s,C=f+2*a[1]*s;g.width=D,g.height=C,p.translate(D/2,C/2),p.rotate(-45*Math.PI/180),p.translate(-D/2,-C/2),p.drawImage(this.imageCache.get(n),(D-d)/2,(C-u)/2,d,u);const I=t.createPattern(g,"repeat");I&&(t.fillStyle=I,t.fillRect(0,0,c,h))}else{const g=c/2,p=h/2;t.translate(g,p),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(n),-d/2,-u/2,d,u)}t.restore()}render(t,e){this.options.watermark.type===fi.IMAGE?this.renderImage(t):this.renderText(t,e)}}class lo{constructor(t){m(this,"draw");m(this,"control");m(this,"options");m(this,"highlightList");m(this,"highlightMatchResult");this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){var p,f;const{control:{activeBackgroundColor:i,disabledBackgroundColor:n,existValueBackgroundColor:r,noValueBackgroundColor:o}}=this.options,a=t[e],s=this.draw.isPrintMode(),c=(p=this.control.getActiveControl())==null?void 0:p.getElement();let h=!1,d=!1,u=!1,g=!1;return a.highlight||(h=!s&&!!i&&!!c&&a.controlId===c.controlId&&!this.control.getIsRangeInPostfix()),h||(d=!s&&!!n&&!!((f=a.control)!=null&&f.disabled)),d||(u=!s&&!!r&&!!a.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),u||(g=!s&&!!o&&!!a.controlId&&!this.control.getIsExistValueByElementListIndex(t,e)),(h?i:"")||(d?n:"")||(u?r:"")||(g?o:"")}getHighlightMatchResult(){return this.highlightMatchResult}getHighlightList(){return this.highlightList}setHighlightList(t){this.highlightList=t}computeHighlightList(){const t=this.draw.getSearch(),e=(i,n)=>{let r=0;for(;r<i.length;){const o=i[r];if(r++,o.type===R.TABLE){const p=o.trList;for(let f=0;f<p.length;f++){const D=p[f];for(let C=0;C<D.tdList.length;C++){const I=D.tdList[C],E={tableId:o.id,tableIndex:r-1,trIndex:f,tdIndex:C,tdId:I.id};e(I.value,E)}}}const a=o==null?void 0:o.control;if(!a)continue;const s=this.highlightList.findIndex(p=>p.id===o.controlId||a.conceptId&&a.conceptId===p.conceptId);if(!~s)continue;const c=r;let h=r;for(;h<i.length&&i[h].controlId===o.controlId;)h++;r=h;const d=i.slice(c,h).map(p=>p.controlComponent===b.VALUE?p:{value:Y}),u=this.highlightList[s],{ruleList:g}=u;for(let p=0;p<g.length;p++){const f=g[p],D=t.getMatchList(f.keyword,d);this.highlightMatchResult.push(...D.map(C=>({...C,...f,...n,index:C.index+c})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){var a,s,c;if(!((a=this.highlightMatchResult)!=null&&a.length))return;const{searchMatchAlpha:i,searchMatchColor:n}=this.options,r=this.draw.getPosition().getOriginalPositionList(),o=this.draw.getOriginalElementList();t.save();for(let h=0;h<this.highlightMatchResult.length;h++){const d=this.highlightMatchResult[h];let u=null;if(d.tableId){const{tableIndex:v,trIndex:L,tdIndex:T,index:x}=d;u=(c=(s=o[v])==null?void 0:s.trList[L].tdList[T])==null?void 0:c.positionList[x]}else u=r[d.index];if(!u)continue;const{coordinate:{leftTop:g,leftBottom:p,rightTop:f},pageNo:D}=u;if(D!==e)continue;t.fillStyle=d.backgroundColor||n,t.globalAlpha=d.alpha||i;const C=g[0],I=g[1],E=f[0]-g[0],w=p[1]-g[1];t.fillRect(C,I,E,w)}t.restore()}}class ao{constructor(t){m(this,"borderRect");m(this,"options");this.borderRect=this.clearBorderInfo(),this.options=t.getOptions()}clearBorderInfo(){return this.borderRect={x:0,y:0,width:0,height:0},this.borderRect}recordBorderInfo(t,e,i,n){!this.borderRect.width&&(this.borderRect.x=t,this.borderRect.y=e,this.borderRect.height=n),this.borderRect.width+=i}render(t){if(!this.borderRect.width)return;const{scale:e,control:{borderWidth:i,borderColor:n}}=this.options,{x:r,y:o,width:a,height:s}=this.borderRect;t.save(),t.translate(0,1*e),t.lineWidth=i*e,t.strokeStyle=n,t.beginPath(),t.rect(r,o,a,s),t.stroke(),t.restore(),this.clearBorderInfo()}}class Fe{constructor(t,e){m(this,"element");m(this,"control");m(this,"isPopup");m(this,"selectDom");m(this,"options");m(this,"VALUE_DELIMITER",",");m(this,"DEFAULT_MULTI_SELECT_DELIMITER",",");const i=e.getDraw();this.options=i.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.selectDom=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getCodes(){var t,e;return(e=(t=this.element)==null?void 0:t.control)!=null&&e.code?this.element.control.code.split(","):[]}getText(t){var o,a;if(!((o=this.element)!=null&&o.control))return null;const e=this.element.control;if(!((a=e.valueSets)!=null&&a.length))return null;const i=(e==null?void 0:e.multiSelectDelimiter)||this.DEFAULT_MULTI_SELECT_DELIMITER,n=e.valueSets,r=[];return t.forEach(s=>{const c=n.find(h=>h.code===s);c&&!tn(c.value)&&r.push(c.value)}),r.join(i)||null}getValue(t={}){const e=t.elementList||this.control.getElementList(),{startIndex:i}=t.range||this.control.getRange(),n=e[i],r=[];let o=i;for(;o>0;){const s=e[o];if(s.controlId!==n.controlId||s.controlComponent===b.PREFIX||s.controlComponent===b.PRE_TEXT)break;s.controlComponent===b.VALUE&&r.unshift(s),o--}let a=i+1;for(;a<e.length;){const s=e[a];if(s.controlId!==n.controlId||s.controlComponent===b.POSTFIX||s.controlComponent===b.POST_TEXT)break;s.controlComponent===b.VALUE&&r.push(s),a++}return r}setValue(t,e={},i={}){var u,g;if(!((g=(u=this.element.control)==null?void 0:u.selectExclusiveOptions)!=null&&g.inputAble)||!i.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const n=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:o,endIndex:a}=r,s=this.control.getDraw();o!==a?s.spliceElementList(n,o+1,a-o):this.control.removePlaceholder(o,e);const c=n[o],h=c.type&&!Jt.includes(c.type)||c.controlComponent===b.PREFIX||c.controlComponent===b.PRE_TEXT?Gt(c,["control","controlId",...oe]):te(c,["type"]),d=r.startIndex+1;for(let p=0;p<t.length;p++){const f={...h,...t[p],controlComponent:b.VALUE};Xt(n,[f],o,{editorOptions:this.options}),s.spliceElementList(n,d+p,0,[f])}return d+t.length-1}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),i=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:r}=i,o=e[n],a=e[r];if(t.key===wt.Backspace)return n!==r?this.clearSelect():o.controlComponent===b.PREFIX||o.controlComponent===b.PRE_TEXT||a.controlComponent===b.POSTFIX||a.controlComponent===b.POST_TEXT||o.controlComponent===b.PLACEHOLDER?this.control.removeControl(n):this.clearSelect();if(t.key===wt.Delete){if(n!==r)return this.clearSelect();{const s=e[r+1];return(o.controlComponent===b.PREFIX||o.controlComponent===b.PRE_TEXT)&&s.controlComponent===b.PLACEHOLDER||s.controlComponent===b.POSTFIX||s.controlComponent===b.POST_TEXT||o.controlComponent===b.PLACEHOLDER?this.control.removeControl(n):this.clearSelect()}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();return t===e?t:this.clearSelect()}clearSelect(t={},e={}){const{isIgnoreDisabledRule:i=!1,isAddPlaceholder:n=!0}=e;if(!i&&this.control.getIsDisabledControl(t))return-1;const r=t.elementList||this.control.getElementList(),{startIndex:o}=t.range||this.control.getRange(),a=r[o];let s=-1,c=-1,h=o;for(;h>0;){const g=r[h];if(g.controlId!==a.controlId||g.controlComponent===b.PREFIX||g.controlComponent===b.PRE_TEXT){s=h;break}h--}let d=o+1;for(;d<r.length;){const g=r[d];if(g.controlId!==a.controlId||g.controlComponent===b.POSTFIX||g.controlComponent===b.POST_TEXT){c=d-1;break}d++}return!~s||!~c?-1:(this.control.getDraw().spliceElementList(r,s+1,c-s,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),n&&this.control.addPlaceholder(h,t),this.control.setControlProperties({code:null},{elementList:r,range:{startIndex:h,endIndex:h}}),h)}setSelect(t,e={},i={}){var w;if(!i.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const n=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange(),o=this.element.control,a=(t==null?void 0:t.split(this.VALUE_DELIMITER))||[],s=o.code,c=((w=o.code)==null?void 0:w.split(this.VALUE_DELIMITER))||[],h=o.isMultiSelect;if(!h&&t===s||h&&Qi(c,a)){this.control.repaintControl({curIndex:r.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const d=o.valueSets;if(!Array.isArray(d)||!d.length)return;const u=this.getText(a);if(!u){if(s){const v=this.clearSelect(e,{isIgnoreDeletedRule:i.isIgnoreDeletedRule});~v&&(this.control.repaintControl({curIndex:v}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],p=g?Gt(g,fe):Gt(n[r.startIndex],oe),f=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:i.isIgnoreDeletedRule});if(!~f)return;s||this.control.removePlaceholder(f,e);const D=te(n[f],fe),C=f+1,I=Yt(u),E=this.control.getDraw();for(let v=0;v<I.length;v++){const L={...p,...D,type:R.TEXT,value:I[v],controlComponent:b.VALUE};Xt(n,[L],f,{editorOptions:this.options}),E.spliceElementList(n,C+v,0,[L])}if(this.control.setControlProperties({code:t},{elementList:n,range:{startIndex:f,endIndex:f}}),!e.range){const v=C+I.length-1;this.control.repaintControl({curIndex:v}),this.control.emitControlContentChange({context:e}),h||this.destroy()}}_createSelectPopupDom(){const t=this.element.control,e=t.valueSets;if(!Array.isArray(e)||!e.length)return;const i=this.control.getPosition();if(!i)return;const n=document.createElement("div");n.classList.add(`${J}-select-control-popup`),n.setAttribute(Xe,ke.POPUP);const r=document.createElement("ul");for(let d=0;d<e.length;d++){const u=e[d],g=document.createElement("li");let p=this.getCodes();p.includes(u.code)&&g.classList.add("active"),g.onclick=()=>{const f=p.findIndex(D=>D===u.code);t.isMultiSelect?~f?p.splice(f,1):p.push(u.code):~f?p=[]:p=[u.code],this.setSelect(p.join(this.VALUE_DELIMITER))},g.append(document.createTextNode(u.value)),r.append(g)}n.append(r);const{coordinate:{leftTop:[o,a]},lineHeight:s}=i,c=this.control.getPreY();n.style.left=`${o}px`,n.style.top=`${a+c+s}px`,this.control.getContainer().append(n),this.selectDom=n}awake(){var i;if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const{startIndex:t}=this.control.getRange();((i=this.control.getElementList()[t+1])==null?void 0:i.controlId)===this.element.controlId&&(this._createSelectPopupDom(),this.isPopup=!0)}destroy(){var t;this.isPopup&&((t=this.selectDom)==null||t.remove(),this.isPopup=!1)}}class hi{constructor(t,e){m(this,"element");m(this,"control");m(this,"options");const i=e.getDraw();this.options=i.getOptions(),this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getValue(t={}){const e=t.elementList||this.control.getElementList(),{startIndex:i}=t.range||this.control.getRange(),n=e[i],r=[];let o=i;for(;o>0;){const s=e[o];if(s.controlId!==n.controlId||s.controlComponent===b.PREFIX||s.controlComponent===b.PRE_TEXT)break;s.controlComponent===b.VALUE&&r.unshift(s),o--}let a=i+1;for(;a<e.length;){const s=e[a];if(s.controlId!==n.controlId||s.controlComponent===b.POSTFIX||s.controlComponent===b.POST_TEXT)break;s.controlComponent===b.VALUE&&r.push(s),a++}return r}setValue(t,e={},i={}){if(!i.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const n=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:o,endIndex:a}=r,s=this.control.getDraw();o!==a?s.spliceElementList(n,o+1,a-o,[],{isIgnoreDeletedRule:i.isIgnoreDeletedRule}):this.control.removePlaceholder(o,e);const c=n[o],h=c.type&&!Jt.includes(c.type)||c.controlComponent===b.PREFIX||c.controlComponent===b.PRE_TEXT?Gt(c,["control","controlId",...oe]):te(c,["type"]),d=r.startIndex+1;for(let u=0;u<t.length;u++){const g={...h,...t[u],controlComponent:b.VALUE};Xt(n,[g],o,{editorOptions:this.options}),s.spliceElementList(n,d+u,0,[g])}return d+t.length-1}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const i=t.elementList||this.control.getElementList(),n=t.range||this.control.getRange(),{startIndex:r,endIndex:o}=n;return this.control.getDraw().spliceElementList(i,r+1,o-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),this.getValue(t).length||this.control.addPlaceholder(r,t),r}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),i=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:r}=i,o=e[n],a=e[r],s=this.control.getDraw();if(t.key===wt.Backspace)return n!==r?(s.spliceElementList(e,n+1,r-n),this.getValue().length||this.control.addPlaceholder(n),n):o.controlComponent===b.PREFIX||o.controlComponent===b.PRE_TEXT||a.controlComponent===b.POSTFIX||a.controlComponent===b.POST_TEXT||o.controlComponent===b.PLACEHOLDER?this.control.removeControl(n):(s.spliceElementList(e,n,1),this.getValue().length||this.control.addPlaceholder(n-1),n-1);if(t.key===wt.Delete){if(n!==r)return s.spliceElementList(e,n+1,r-n),this.getValue().length||this.control.addPlaceholder(n),n;{const c=e[r+1];return(o.controlComponent===b.PREFIX||o.controlComponent===b.PRE_TEXT)&&c.controlComponent===b.PLACEHOLDER||c.controlComponent===b.POSTFIX||c.controlComponent===b.POST_TEXT||o.controlComponent===b.PLACEHOLDER?this.control.removeControl(n):(s.spliceElementList(e,n+1,1),this.getValue().length||this.control.addPlaceholder(n),n)}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const i=this.control.getDraw(),n=this.control.getElementList();return i.spliceElementList(n,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}}class Pe{constructor(t,e){m(this,"draw");m(this,"element");m(this,"control");m(this,"isPopup");m(this,"datePicker");m(this,"options");const i=e.getDraw();this.draw=i,this.options=i.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValueRange(t={}){const e=t.elementList||this.control.getElementList(),{startIndex:i}=t.range||this.control.getRange(),n=e[i];let r=i;for(;r>0;){const a=e[r];if(a.controlId!==n.controlId||a.controlComponent===b.PREFIX||a.controlComponent===b.PRE_TEXT)break;r--}let o=i+1;for(;o<e.length;){const a=e[o];if(a.controlId!==n.controlId||a.controlComponent===b.POSTFIX||a.controlComponent===b.POST_TEXT)break;o++}return r===o?null:[r,o-1]}getValue(t={}){const e=t.elementList||this.control.getElementList(),i=this.getValueRange(t);if(!i)return[];const n=[],[r,o]=i;for(let a=r;a<=o;a++){const s=e[a];s.controlComponent===b.VALUE&&n.push(s)}return n}setValue(t,e={},i={}){if(!i.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const n=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:o,endIndex:a}=r,s=this.control.getDraw();o!==a?s.spliceElementList(n,o+1,a-o):this.control.removePlaceholder(o,e);const c=n[o],h=c.type&&!Jt.includes(c.type)||c.controlComponent===b.PREFIX||c.controlComponent===b.PRE_TEXT?Gt(c,["control","controlId",...oe]):te(c,["type"]),d=r.startIndex+1;for(let u=0;u<t.length;u++){const g={...h,...t[u],controlComponent:b.VALUE};Xt(n,[g],o,{editorOptions:this.options}),s.spliceElementList(n,d+u,0,[g])}return d+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:i=!1,isAddPlaceholder:n=!0}=e;if(!i&&this.control.getIsDisabledControl(t))return-1;const r=this.getValueRange(t);if(!r)return-1;const[o,a]=r;if(!~o||!~a)return-1;const s=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(s,o+1,a-o,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),n&&this.control.addPlaceholder(o,t),o}setSelect(t,e={},i={}){if(!i.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const n=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange(),o=this.getValue(e)[0],a=o?Gt(o,fe):Gt(n[r.startIndex],oe),s=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:i.isIgnoreDeletedRule});if(!~s)return;const c=te(n[s],fe),h=s+1,d=this.control.getDraw();for(let u=0;u<t.length;u++){const g={...a,...c,type:R.TEXT,value:t[u],controlComponent:b.VALUE};Xt(n,[g],s,{editorOptions:this.options}),d.spliceElementList(n,h+u,0,[g])}if(!e.range){const u=h+t.length-1;this.control.repaintControl({curIndex:u}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),i=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:r}=i,o=e[n],a=e[r],s=this.control.getDraw();if(t.key===wt.Backspace)return n!==r?(s.spliceElementList(e,n+1,r-n),this.getValue().length||this.control.addPlaceholder(n),n):o.controlComponent===b.PREFIX||o.controlComponent===b.PRE_TEXT||a.controlComponent===b.POSTFIX||a.controlComponent===b.POST_TEXT||o.controlComponent===b.PLACEHOLDER?this.control.removeControl(n):(s.spliceElementList(e,n,1),this.getValue().length||this.control.addPlaceholder(n-1),n-1);if(t.key===wt.Delete){if(n!==r)return s.spliceElementList(e,n+1,r-n),this.getValue().length||this.control.addPlaceholder(n),n;{const c=e[r+1];return(o.controlComponent===b.PREFIX||o.controlComponent===b.PRE_TEXT)&&c.controlComponent===b.PLACEHOLDER||c.controlComponent===b.POSTFIX||c.controlComponent===b.POST_TEXT||o.controlComponent===b.PLACEHOLDER?this.control.removeControl(n):(s.spliceElementList(e,n+1,1),this.getValue().length||this.control.addPlaceholder(n),n)}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const i=this.control.getDraw(),n=this.control.getElementList();return i.spliceElementList(n,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){var o,a;if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getPosition();if(!t)return;const e=this.draw.getElementList(),{startIndex:i}=this.control.getRange();if(((o=e[i+1])==null?void 0:o.controlId)!==this.element.controlId)return;this.datePicker=new fn(this.draw,{onSubmit:this._setDate.bind(this)});const n=this.getValue().map(s=>s.value).join("")||"",r=(a=this.element.control)==null?void 0:a.dateFormat;this.datePicker.render({value:n,position:t,dateFormat:r}),this.isPopup=!0}destroy(){var t;this.isPopup&&((t=this.datePicker)==null||t.destroy(),this.isPopup=!1)}_setDate(t){t?this.setSelect(t):this.clearSelect(),this.destroy()}}class ki extends hi{}class co{constructor(t){m(this,"controlBorder");m(this,"draw");m(this,"range");m(this,"listener");m(this,"eventBus");m(this,"controlSearch");m(this,"options");m(this,"controlOptions");m(this,"activeControl");m(this,"activeControlValue");m(this,"preElement");this.controlBorder=new ao(t),this.draw=t,this.range=t.getRange(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.controlSearch=new lo(this),this.options=t.getOptions(),this.controlOptions=this.options.control,this.activeControl=null,this.activeControlValue=[],this.preElement=null}setHighlightList(t){this.controlSearch.setHighlightList(t)}computeHighlightList(){this.controlSearch.getHighlightList().length&&this.controlSearch.computeHighlightList()}renderHighlightList(t,e){this.controlSearch.getHighlightMatchResult().length&&this.controlSearch.renderHighlightList(t,e)}getDraw(){return this.draw}filterAssistElement(t){return t.filter((e,i)=>{var n,r,o;if(e.type===R.TABLE){const a=e.trList;for(let s=0;s<a.length;s++){const c=a[s];for(let h=0;h<c.tdList.length;h++){const d=c.tdList[h];d.value=this.filterAssistElement(d.value)}}}if(!e.controlId)return!0;if((n=e.control)!=null&&n.minWidth){if(e.controlComponent===b.PREFIX||e.controlComponent===b.POSTFIX)return e.value="",!0}else{if((r=e.control)!=null&&r.preText&&e.controlComponent===b.PRE_TEXT){let a=!1,s=i+1;for(;s<t.length;){const c=t[s];if(e.controlId!==c.controlId)break;if(c.controlComponent===b.VALUE){a=!0;break}s++}return a}if((o=e.control)!=null&&o.postText&&e.controlComponent===b.POST_TEXT){let a=!1,s=i-1;for(;s<t.length;){const c=t[s];if(e.controlId!==c.controlId)break;if(c.controlComponent===b.VALUE){a=!0;break}s--}return a}}return e.controlComponent!==b.PREFIX&&e.controlComponent!==b.POSTFIX&&e.controlComponent!==b.PLACEHOLDER})}getIsRangeCanCaptureEvent(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const i=this.getElementList(),n=i[t];if(t===e&&n.controlComponent===b.POSTFIX)return!0;const r=i[e];return!!(n.controlId&&n.controlId===r.controlId&&r.controlComponent!==b.POSTFIX)}getIsRangeInPostfix(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();return t!==e?!1:this.getElementList()[t].controlComponent===b.POSTFIX}getIsRangeWithinControl(){const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const i=this.getElementList(),n=i[t],r=i[e];return!!(n!=null&&n.controlId&&n.controlId===r.controlId&&r.controlComponent!==b.POSTFIX)}getIsElementListContainFullControl(t){if(!t.some(n=>n.controlId))return!1;let e=0,i=0;for(let n=0;n<t.length;n++){const r=t[n];r.controlComponent===b.PREFIX?e++:r.controlComponent===b.POSTFIX&&i++}return!e||!i?!1:e===i}getIsDisabledControl(t={}){var n,r;if(this.draw.isDesignMode()||!this.activeControl)return!1;const{startIndex:e,endIndex:i}=t.range||this.range.getRange();return e===i&&~e&&~i&&(t.elementList||this.getElementList())[e].controlComponent===b.POSTFIX?!1:!!((r=(n=this.activeControl.getElement())==null?void 0:n.control)!=null&&r.disabled)}getIsDisabledPasteControl(t={}){var n,r;if(this.draw.isDesignMode()||!this.activeControl)return!1;const{startIndex:e,endIndex:i}=t.range||this.range.getRange();return e===i&&~e&&~i&&(t.elementList||this.getElementList())[e].controlComponent===b.POSTFIX?!1:!!((r=(n=this.activeControl.getElement())==null?void 0:n.control)!=null&&r.pasteDisabled)}getIsExistValueByElementListIndex(t,e){var n,r,o;const i=t[e];if(!i.controlId)return!1;if(((n=i.control)==null?void 0:n.type)===lt.CHECKBOX||((r=i.control)==null?void 0:r.type)===lt.RADIO)return!!((o=i.control)!=null&&o.code);if(i.controlComponent===b.VALUE)return!0;if(i.controlComponent===b.PLACEHOLDER)return!1;if(i.controlComponent===b.PREFIX||i.controlComponent===b.PRE_TEXT){let a=e+1;for(;a<t.length;){const s=t[a];if(s.controlId!==i.controlId)return!1;if(s.controlComponent===b.VALUE)return!0;if(s.controlComponent===b.PLACEHOLDER)return!1;a++}}if(i.controlComponent===b.POSTFIX||i.controlComponent===b.POST_TEXT){let a=e-1;for(;a>=0;){const s=t[a];if(s.controlId!==i.controlId)return!1;if(s.controlComponent===b.VALUE)return!0;if(s.controlComponent===b.PLACEHOLDER)return!1;a--}}return!1}getControlHighlight(t,e){return this.controlSearch.getControlHighlight(t,e)}getContainer(){return this.draw.getContainer()}getElementList(){return this.draw.getElementList()}getPosition(){const t=this.draw.getPosition().getPositionList(),{endIndex:e}=this.range.getRange();return t[e]||null}getPreY(){var n;const t=this.draw.getHeight(),e=this.draw.getPageGap();return(((n=this.getPosition())==null?void 0:n.pageNo)??this.draw.getPageNo())*(t+e)}getRange(){return this.range.getRange()}shrinkBoundary(t={}){this.range.shrinkBoundary(t)}getActiveControl(){return this.activeControl}getControlElementList(t={}){const e=t.elementList||this.getElementList(),{startIndex:i}=t.range||this.getRange(),n=e[i];if(!(n!=null&&n.controlId))return[];const r=[];let o=i;for(;o>0;){const s=e[o];if(s.controlId!==n.controlId)break;r.unshift(s),o--}let a=i+1;for(;a<e.length;){const s=e[a];if(s.controlId!==n.controlId)break;r.push(s),a++}return r}updateActiveControlValue(){this.activeControl&&(this.activeControlValue=this.getControlElementList())}emitControlChange(t){var a,s;if(!this.activeControl)return;const e=this.eventBus.hasSubscribers("controlChange");if(!this.listener.controlChange&&!e)return;let i;const n=this.activeControlValue,r=this.activeControl.getElement();n!=null&&n.length?i=Et(n)[0].control:(i=ii(bt(r)).control,i.value=[]);const o={state:t,control:i,controlId:r.controlId};(s=(a=this.listener).controlChange)==null||s.call(a,o),e&&this.eventBus.emit("controlChange",o)}initControl(){var o,a;const t=this.getElementList(),e=this.getRange(),i=t[e.startIndex];if(this.activeControl){(this.activeControl instanceof Fe||this.activeControl instanceof Pe)&&(i.controlComponent===b.POSTFIX?this.activeControl.destroy():this.activeControl.awake()),((o=this.preElement)==null?void 0:o.controlId)===i.controlId&&(i.controlComponent===b.POSTFIX?this.emitControlChange(_e.INACTIVE):((a=this.preElement)==null?void 0:a.controlComponent)===b.POSTFIX&&this.emitControlChange(_e.ACTIVE));const s=this.activeControl.getElement();if(i.controlId===s.controlId){this.updateActiveControlValue(),this.preElement=i;return}}if(this.destroyControl(),this.draw.isReadonly())return;const r=i.control;if(r.type===lt.TEXT)this.activeControl=new hi(i,this);else if(r.type===lt.SELECT){const s=new Fe(i,this);this.activeControl=s,s.awake()}else if(r.type===lt.CHECKBOX)this.activeControl=new Ye(i,this);else if(r.type===lt.RADIO)this.activeControl=new si(i,this);else if(r.type===lt.DATE){const s=new Pe(i,this);this.activeControl=s,s.awake()}else r.type===lt.NUMBER&&(this.activeControl=new ki(i,this));this.updateActiveControlValue(),this.preElement=i,i.controlComponent!==b.POSTFIX&&this.emitControlChange(_e.ACTIVE)}destroyControl(t={}){var i;if(!this.activeControl)return;const{isEmitEvent:e=!0}=t;(this.activeControl instanceof Fe||this.activeControl instanceof Pe)&&this.activeControl.destroy(),e&&((i=this.preElement)==null?void 0:i.controlComponent)!==b.POSTFIX&&this.emitControlChange(_e.INACTIVE),this.preElement=null,this.activeControl=null,this.activeControlValue=[]}repaintControl(t={}){const{curIndex:e,isCompute:i=!0,isSubmitHistory:n=!0,isSetCursor:r=!0}=t;e===void 0?(this.range.clearRange(),this.draw.render({isCompute:i,isSubmitHistory:n,isSetCursor:!1})):(this.range.setRange(e,e),this.draw.render({curIndex:e,isCompute:i,isSetCursor:r,isSubmitHistory:n}))}emitControlContentChange(t){var c,h,d,u,g,p;const e=this.eventBus.hasSubscribers("controlContentChange");if(!e&&!this.listener.controlContentChange)return;const i=(t==null?void 0:t.controlElement)||((c=this.activeControl)==null?void 0:c.getElement());if(!i)return;const n=((h=t==null?void 0:t.context)==null?void 0:h.elementList)||this.getElementList(),{startIndex:r}=((d=t==null?void 0:t.context)==null?void 0:d.range)||this.getRange();if(!((u=n[r])!=null&&u.controlId))return;const o=(t==null?void 0:t.controlValue)||this.getControlElementList(t==null?void 0:t.context);let a;if(o!=null&&o.length?a=Et(o)[0].control:(a=i.control,a.value=[]),!a)return;const s={control:a,controlId:i.controlId};(p=(g=this.listener).controlContentChange)==null||p.call(g,s),e&&this.eventBus.emit("controlContentChange",s)}reAwakeControl(){if(!this.activeControl)return;const t=this.getElementList(),e=this.getRange(),i=t[e.startIndex];this.activeControl.setElement(i),(this.activeControl instanceof Pe||this.activeControl instanceof Fe)&&this.activeControl.getIsPopup()&&(this.activeControl.destroy(),this.activeControl.awake())}moveCursor(t){var c,h;const{index:e,trIndex:i,tdIndex:n,tdValueIndex:r}=t;let o=this.draw.getOriginalElementList(),a;const s=t.isTable?r:e;if(t.isTable?(o=o[e].trList[i].tdList[n].value,a=o[r]):a=o[e],(c=a.control)!=null&&c.hide||(h=a.area)!=null&&h.hide){const d=Ke(o,s);return{newIndex:d,newElement:o[d]}}if(a.controlComponent===b.VALUE)return{newIndex:s,newElement:a};if(a.controlComponent===b.POSTFIX){let d=s+1;for(;d<o.length;){if(o[d].controlId!==a.controlId)return{newIndex:d-1,newElement:o[d-1]};d++}}else if(a.controlComponent===b.PREFIX||a.controlComponent===b.PRE_TEXT){let d=s+1;for(;d<o.length;){const u=o[d];if(u.controlId!==a.controlId||u.controlComponent!==b.PREFIX&&u.controlComponent!==b.PRE_TEXT)return{newIndex:d-1,newElement:o[d-1]};d++}}else if(a.controlComponent===b.PLACEHOLDER||a.controlComponent===b.POST_TEXT){let d=s-1;for(;d>0;){const u=o[d];if(u.controlId!==a.controlId||u.controlComponent===b.VALUE||u.controlComponent===b.PREFIX||u.controlComponent===b.PRE_TEXT)return{newIndex:d,newElement:o[d]};d--}}return{newIndex:s,newElement:a}}removeControl(t,e={}){var c,h;const i=e.elementList||this.getElementList(),n=i[t];if(!this.draw.isDesignMode()&&!((c=n==null?void 0:n.control)!=null&&c.hide)&&!((h=n==null?void 0:n.area)!=null&&h.hide)){const{deletable:d=!0}=n.control;if(!d)return null;const u=this.draw.getMode();if(u===at.FORM&&this.options.modeRule[u].controlDeletableDisabled)return null}let r=-1,o=-1,a=t;for(;a>0;){if(i[a].controlId!==n.controlId){r=a;break}a--}let s=t+1;for(;s<i.length;){if(i[s].controlId!==n.controlId){o=s-1;break}s++}return s===i.length&&(o=s-1),!~r&&!~o?t:(r=~r?r:0,this.draw.spliceElementList(i,r+1,o-r),r)}removePlaceholder(t,e={}){const i=e.elementList||this.getElementList(),n=i[t],r=i[t+1];if(n.controlComponent===b.PLACEHOLDER||r.controlComponent===b.PLACEHOLDER){let o=!1,a=t;for(;a<i.length;){const s=i[a];if(s.controlId!==n.controlId)break;s.controlComponent===b.PLACEHOLDER?(o||(o=!0,this.draw.getHistoryManager().popUndo(),this.draw.submitHistory(t)),i.splice(a,1)):a++}}}addPlaceholder(t,e={}){const i=e.elementList||this.getElementList(),n=i[t],r=n.control;if(!r.placeholder)return;const o=Yt(r.placeholder),a=Gt(n,oe);for(let s=0;s<o.length;s++){const c=o[s],h={...a,value:c===`
38
+ `?Y:c,controlId:n.controlId,type:R.CONTROL,control:n.control,controlComponent:b.PLACEHOLDER,color:this.controlOptions.placeholderColor};Xt(i,[h],t,{editorOptions:this.options}),this.draw.spliceElementList(i,t+s+1,0,[h])}}setValue(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.setValue(t)}setControlProperties(t,e={}){const i=e.elementList||this.getElementList(),{startIndex:n}=e.range||this.getRange(),r=i[n];let o=n;for(;o>0;){const s=i[o];if(s.controlId!==r.controlId)break;s.control={...s.control,...t},o--}let a=n+1;for(;a<i.length;){const s=i[a];if(s.controlId!==r.controlId)break;s.control={...s.control,...t},a++}}keydown(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.keydown(t)}cut(){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.cut()}getValueById(t){const{id:e,conceptId:i,areaId:n}=t,r=[];if(!e&&!i)return r;const o=(s,c)=>{let h=0;for(;h<s.length;){const d=s[h];if(h++,d.type===R.TABLE){const I=d.trList;for(let E=0;E<I.length;E++){const w=I[E];for(let v=0;v<w.tdList.length;v++){const L=w.tdList[v];o(L.value,c)}}}if(!d.control||e&&d.controlId!==e||i&&d.control.conceptId!==i||n&&d.areaId!==n)continue;const{type:u,code:g,valueSets:p}=d.control;let f=h,D="";const C=[];for(;f<s.length;){const I=s[f];if(I.controlId!==d.controlId)break;(u===lt.TEXT||u===lt.DATE||u===lt.NUMBER)&&I.controlComponent===b.VALUE&&(D+=I.value,C.push(te(I,Ei))),f++}if(u===lt.TEXT||u===lt.DATE||u===lt.NUMBER)r.push({...d.control,zone:c,value:D||null,innerText:D||null,elementList:Et(C)});else if(u===lt.SELECT||u===lt.CHECKBOX||u===lt.RADIO){const I=g==null?void 0:g.split(",").map(E=>{var w;return(w=p==null?void 0:p.find(v=>v.code===E))==null?void 0:w.value}).filter(Boolean).join("");r.push({...d.control,zone:c,value:g||null,innerText:I||null})}h=f}},a=[{zone:st.HEADER,elementList:this.draw.getHeaderElementList()},{zone:st.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:st.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:s,elementList:c}of a)o(c,s);return r}setValueListById(t){if(!t.length)return;let e=!1,i=!1;const n=o=>{let a=0;for(;a<o.length;){const s=o[a];if(a++,s.type===R.TABLE){const I=s.trList;for(let E=0;E<I.length;E++){const w=I[E];for(let v=0;v<w.tdList.length;v++){const L=w.tdList[v];n(L.value)}}}if(!s.control)continue;const c=t.find(I=>I.id&&s.controlId===I.id||I.conceptId&&s.control.conceptId===I.conceptId||I.areaId&&s.areaId===I.areaId);if(!c)continue;const{value:h,isSubmitHistory:d=!0}=c;e=!0,d&&(i=!0);const{type:u}=s.control;let g=a;for(;g<o.length&&o[g].controlId===s.controlId;)g++;const f={range:{startIndex:a-1,endIndex:g-2},elementList:o},D={isIgnoreDisabledRule:!0,isIgnoreDeletedRule:!0};if(u===lt.TEXT){const I=Array.isArray(h)?h:h?[{value:h}]:[];I.length&&zt(I,{isHandleFirstElement:!1,editorOptions:this.options});const E=new hi(s,this);this.activeControl=E,I.length?E.setValue(I,f,D):E.clearValue(f,D)}else if(u===lt.SELECT){if(Array.isArray(h))continue;const I=new Fe(s,this);this.activeControl=I,h?I.setSelect(h,f,D):I.clearSelect(f,D)}else if(u===lt.CHECKBOX){if(Array.isArray(h))continue;const I=new Ye(s,this);this.activeControl=I;const E=h?h.split(","):[];I.setSelect(E,f,D)}else if(u===lt.RADIO){if(Array.isArray(h))continue;const I=new si(s,this);this.activeControl=I;const E=h?[h]:[];I.setSelect(E,f,D)}else if(u===lt.DATE){const I=new Pe(s,this);this.activeControl=I,$s(h)?(h.length&&zt(h,{isHandleFirstElement:!1,editorOptions:this.options}),I.setValue(h,f,D)):Vs(h)?I.setSelect(h,f,D):I.clearSelect(f,D)}else if(u===lt.NUMBER){const I=Array.isArray(h)?h:h?[{value:h}]:[];I.length&&zt(I,{isHandleFirstElement:!1,editorOptions:this.options});const E=new ki(s,this);this.activeControl=E,I.length?E.setValue(I,f,D):E.clearValue(f,D)}this.emitControlContentChange({context:f}),this.activeControl=null;let C=a;for(;C<o.length&&o[C].controlId===s.controlId;)C++;a=C}};this.destroyControl({isEmitEvent:!1});const r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const o of r)n(o);e&&(i||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:i,isSetCursor:!1}))}setExtensionListById(t){if(!t.length)return;const e=n=>{let r=0;for(;r<n.length;){const o=n[r];if(r++,o.type===R.TABLE){const h=o.trList;for(let d=0;d<h.length;d++){const u=h[d];for(let g=0;g<u.tdList.length;g++){const p=u.tdList[g];e(p.value)}}}if(!o.control)continue;const a=t.find(h=>h.id&&o.controlId===h.id||h.conceptId&&o.control.conceptId===h.conceptId||h.areaId&&o.areaId===h.areaId);if(!a)continue;const{extension:s}=a;this.setControlProperties({extension:s},{elementList:n,range:{startIndex:r,endIndex:r}});let c=r;for(;c<n.length&&n[c].controlId===o.controlId;)c++;r=c}},i=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const n of i)e(n)}setPropertiesListById(t){if(!t.length)return;let e=!1,i=!1;const n=o=>{let a=0;for(;a<o.length;){const s=o[a];if(a++,s.type===R.TABLE){const g=s.trList;for(let p=0;p<g.length;p++){const f=g[p];for(let D=0;D<f.tdList.length;D++){const C=f.tdList[D];n(C.value)}}}if(!s.control)continue;const c=t.find(g=>g.id&&s.controlId===g.id||g.conceptId&&s.control.conceptId===g.conceptId||g.areaId&&s.areaId===g.areaId);if(!c)continue;const{properties:h,isSubmitHistory:d=!0}=c;e=!0,d&&(i=!0),this.setControlProperties({...s.control,...h,value:s.control.value},{elementList:o,range:{startIndex:a,endIndex:a}}),oe.forEach(g=>{const p=h[g];p&&Reflect.set(s,g,p)});let u=a;for(;u<o.length&&o[u].controlId===s.controlId;)u++;a=u}},r={header:this.draw.getHeaderElementList(),main:this.draw.getOriginalMainElementList(),footer:this.draw.getFooterElementList()};for(const o in r){const a=r[o];n(a)}if(e){for(const o in r){const a=o,s=Et(r[a],{isClassifyArea:!0,extraPickAttrs:["id"]});r[a]=s,zt(s,{editorOptions:this.options,isForceCompensation:!0})}this.draw.setEditorData(r),i||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:i,isSetCursor:!1})}}getList(){const t=[];function e(n){for(let r=0;r<n.length;r++){const o=n[r];if(o.type===R.TABLE){const a=o.trList;for(let s=0;s<a.length;s++){const c=a[s];for(let h=0;h<c.tdList.length;h++){const u=c.tdList[h].value;e(u)}}}if(o.controlId){const a=te(o,[...Ii,...Yi]);t.push(a)}}}const i=[this.draw.getHeader().getElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooter().getElementList()];for(const n of i)e(n);return Et(t,{extraPickAttrs:["controlId"]})}recordBorderInfo(t,e,i,n){this.controlBorder.recordBorderInfo(t,e,i,n)}drawBorder(t){this.controlBorder.render(t)}getPreControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const i=this.activeControl.getElement();function n(s,c){for(let h=c;h>0;h--){const d=s[h];if(d.type===R.TABLE){const g=d.trList||[];for(let p=g.length-1;p>=0;p--){const f=g[p],D=f.tdList;for(let C=D.length-1;C>=0;C--){const I=D[C],E=n(I.value,I.value.length-1);if(E)return{positionContext:{isTable:!0,index:h,trIndex:p,tdIndex:C,tdId:I.id,trId:f.id,tableId:d.id},nextIndex:E.nextIndex}}}}if(!d.controlId||d.controlId===i.controlId)continue;let u=h;for(;u>0;){const g=s[u];if(g.controlComponent===b.VALUE||g.controlComponent===b.PREFIX||g.controlComponent===b.PRE_TEXT)break;u--}return{positionContext:{isTable:!1},nextIndex:u}}return null}const{startIndex:r}=this.range.getRange(),o=this.getElementList(),a=n(o,r);if(a)return{positionContext:e.isTable?e:a.positionContext,nextIndex:a.nextIndex};if(i.tableId){const s=this.draw.getOriginalElementList(),{index:c,trIndex:h,tdIndex:d}=e,u=s[c].trList;for(let p=h;p>=0;p--){const f=u[p],D=f.tdList;for(let C=D.length-1;C>=0;C--){if(h===p&&C>=d)continue;const I=D[C],E=n(I.value,I.value.length-1);if(E)return{positionContext:{isTable:!0,index:e.index,trIndex:p,tdIndex:C,tdId:I.id,trId:f.id,tableId:i.tableId},nextIndex:E.nextIndex}}}const g=n(s,c-1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}getNextControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const i=this.activeControl.getElement();function n(s,c){var h,d;for(let u=c;u<s.length;u++){const g=s[u];if(g.type===R.TABLE){const p=g.trList||[];for(let f=0;f<p.length;f++){const D=p[f],C=D.tdList;for(let I=0;I<C.length;I++){const E=C[I],w=n(E.value,0);if(w)return{positionContext:{isTable:!0,index:u,trIndex:f,tdIndex:I,tdId:E.id,trId:D.id,tableId:g.id},nextIndex:w.nextIndex}}}}if(!(!g.controlId||g.controlId===i.controlId||((h=s[u+1])==null?void 0:h.controlComponent)===b.PREFIX||((d=s[u+1])==null?void 0:d.controlComponent)===b.PRE_TEXT))return{positionContext:{isTable:!1},nextIndex:u}}return null}const{endIndex:r}=this.range.getRange(),o=this.getElementList(),a=n(o,r);if(a)return{positionContext:e.isTable?e:a.positionContext,nextIndex:a.nextIndex};if(i.tableId){const s=this.draw.getOriginalElementList(),{index:c,trIndex:h,tdIndex:d}=e,u=s[c].trList;for(let p=h;p<u.length;p++){const f=u[p],D=f.tdList;for(let C=0;C<D.length;C++){if(h===p&&C<=d)continue;const I=D[C],E=n(I.value,0);if(E)return{positionContext:{isTable:!0,index:e.index,trIndex:p,tdIndex:C,tdId:I.id,trId:f.id,tableId:i.tableId},nextIndex:E.nextIndex}}}const g=n(s,c+1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}initNextControl(t={}){const{direction:e=St.DOWN}=t;let i=null;if(e===St.UP?i=this.getPreControlContext():i=this.getNextControlContext(),!i)return;const{nextIndex:n,positionContext:r}=i,o=this.draw.getPosition();o.setPositionContext(r),this.draw.getRange().replaceRange({startIndex:n,endIndex:n}),this.draw.render({curIndex:n,isCompute:!1,isSetCursor:!0,isSubmitHistory:!1});const a=o.getPositionList();this.draw.getCursor().moveCursorToVisible({cursorPosition:a[n],direction:e})}setMinWidthControlInfo(t){var h,d,u,g,p;const{row:e,rowElement:i,controlRealWidth:n,availableWidth:r}=t;if(!((h=i.control)!=null&&h.minWidth))return;const{scale:o}=this.options,a=i.control.minWidth*o;let s=null;if((d=i.control)!=null&&d.minWidth&&(((u=i.control)==null?void 0:u.rowFlex)===gt.CENTER||((g=i.control)==null?void 0:g.rowFlex)===gt.RIGHT)){let f=i.metrics.width,D=e.elementList.length-1;for(;D>=0;){const C=e.elementList[D];if(f+=C.metrics.width,((p=e.elementList[D-1])==null?void 0:p.controlComponent)===b.PREFIX){s=C;break}D--}s&&f<a&&(i.control.rowFlex===gt.CENTER?s.left=(a-f)/2:i.control.rowFlex===gt.RIGHT&&(s.left=a-f-i.metrics.width))}const c=a-n;if(c>0){const f=(s==null?void 0:s.left)||0,D=r-e.width-i.metrics.width,C=Math.min(D,c);i.left=C-f,e.width+=C-f}}}class ho{constructor(t){m(this,"draw");m(this,"options");this.draw=t,this.options=t.getOptions()}setSelect(t){const{checkbox:e}=t;e?e.value=!e.value:t.checkbox={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:i,index:n,row:r}=t;let{y:o}=t;const{checkbox:{gap:a,lineWidth:s,fillStyle:c,strokeStyle:h,verticalAlign:d},scale:u}=this.options,{metrics:g,checkbox:p}=r.elementList[n];if(d===Wt.TOP||d===Wt.MIDDLE){let E=n+1,w=null;for(;E<r.elementList.length&&(w=r.elementList[E],!(w.value!==Y&&w.value!==Vi));)E++;if(w){const{metrics:{boundingBoxAscent:v,boundingBoxDescent:L}}=w,T=v+L;T>g.height&&(d===Wt.TOP?o-=v-g.height:d===Wt.MIDDLE&&(o-=(T-g.height)/2))}}const f=Math.round(i+a*u),D=Math.round(o-g.height+s),C=g.width-a*2*u,I=g.height;e.save(),e.beginPath(),e.translate(.5,.5),p!=null&&p.value?(e.lineWidth=s,e.strokeStyle=c,e.rect(f,D,C,I),e.stroke(),e.beginPath(),e.fillStyle=c,e.fillRect(f,D,C,I),e.beginPath(),e.strokeStyle=h,e.lineWidth=s*2*u,e.moveTo(f+2*u,D+I/2),e.lineTo(f+C/2,D+I-3*u),e.lineTo(f+C-2*u,D+3*u),e.stroke()):(e.lineWidth=s,e.rect(f,D,C,I),e.stroke()),e.closePath(),e.restore()}}class uo{constructor(t){m(this,"draw");m(this,"options");this.draw=t,this.options=t.getOptions()}setSelect(t){const{radio:e}=t;e?e.value=!e.value:t.radio={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:i,index:n,row:r}=t;let{y:o}=t;const{radio:{gap:a,lineWidth:s,fillStyle:c,strokeStyle:h,verticalAlign:d},scale:u}=this.options,{metrics:g,radio:p}=r.elementList[n];if(d===Wt.TOP||d===Wt.MIDDLE){let E=n+1,w=null;for(;E<r.elementList.length&&(w=r.elementList[E],!(w.value!==Y&&w.value!==Vi));)E++;if(w){const{metrics:{boundingBoxAscent:v,boundingBoxDescent:L}}=w,T=v+L;T>g.height&&(d===Wt.TOP?o-=v-g.height:d===Wt.MIDDLE&&(o-=(T-g.height)/2))}}const f=Math.round(i+a*u),D=Math.round(o-g.height+s),C=g.width-a*2*u,I=g.height;e.save(),e.beginPath(),e.translate(.5,.5),e.strokeStyle=p!=null&&p.value?c:h,e.lineWidth=s,e.arc(f+C/2,D+I/2,C/2,0,Math.PI*2),e.stroke(),p!=null&&p.value&&(e.beginPath(),e.fillStyle=c,e.arc(f+C/2,D+I/2,C/3,0,Math.PI*2),e.fill()),e.closePath(),e.restore()}}class go{constructor(t){m(this,"container");m(this,"canvas");m(this,"draw");m(this,"options");m(this,"curElement");m(this,"curElementSrc");m(this,"previewerDrawOption");m(this,"curPosition");m(this,"eventBus");m(this,"imageList");m(this,"curShowElement");m(this,"imageCount");m(this,"imagePre");m(this,"imageNext");m(this,"resizerSelection");m(this,"resizerHandleList");m(this,"resizerImageContainer");m(this,"resizerImage");m(this,"resizerSize");m(this,"width");m(this,"height");m(this,"mousedownX");m(this,"mousedownY");m(this,"curHandleIndex");m(this,"previewerContainer");m(this,"previewerImage");m(this,"_keydown",()=>{this.resizerSelection.style.display==="block"&&(this.clearResizer(),document.removeEventListener("keydown",this._keydown))});this.container=t.getContainer(),this.canvas=t.getPage(),this.draw=t,this.options=t.getOptions(),this.curElement=null,this.curElementSrc="",this.previewerDrawOption={},this.curPosition=null,this.eventBus=t.getEventBus(),this.imageList=[],this.curShowElement=null,this.imageCount=null,this.imagePre=null,this.imageNext=null;const{resizerSelection:e,resizerHandleList:i,resizerImageContainer:n,resizerImage:r,resizerSize:o}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=i,this.resizerImageContainer=n,this.resizerImage=r,this.resizerSize=o,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.previewerContainer=null,this.previewerImage=null}_getElementPosition(t,e=null){const{scale:i}=this.options;let n=0,r=0;const o=this.draw.getHeight(),a=this.draw.getPageGap(),c=((e==null?void 0:e.pageNo)??this.draw.getPageNo())*(o+a);if(t.imgFloatPosition)n=t.imgFloatPosition.x*i,r=t.imgFloatPosition.y*i+c;else if(e){const{coordinate:{leftTop:[h,d]},ascent:u}=e;n=h,r=d+c+u}return{x:n,y:r}}_createResizerDom(){const{scale:t}=this.options,e=document.createElement("div");e.classList.add(`${J}-resizer-selection`),e.style.display="none",e.style.borderColor=this.options.resizerColor,e.style.borderWidth=`${t}px`;const i=[];for(let s=0;s<8;s++){const c=document.createElement("div");c.style.background=this.options.resizerColor,c.classList.add("resizer-handle"),c.classList.add(`handle-${s}`),c.setAttribute("data-index",String(s)),c.onmousedown=this._mousedown.bind(this),e.append(c),i.push(c)}this.container.append(e);const n=document.createElement("div");n.classList.add(`${J}-resizer-size-view`);const r=document.createElement("span");n.append(r),e.append(n);const o=document.createElement("div");o.classList.add(`${J}-resizer-image`),o.style.display="none";const a=document.createElement("img");return a.setAttribute("crossOrigin","Anonymous"),o.append(a),this.container.append(o),{resizerSelection:e,resizerHandleList:i,resizerImageContainer:o,resizerImage:a,resizerSize:r}}_mousedown(t){if(this.canvas=this.draw.getPage(),!this.curElement)return;const{scale:e}=this.options;this.mousedownX=t.x,this.mousedownY=t.y;const i=t.target;this.curHandleIndex=Number(i.dataset.index);const n=window.getComputedStyle(i).cursor;document.body.style.cursor=n,this.canvas.style.cursor=n,this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{x:r,y:o}=this._getElementPosition(this.curElement,this.curPosition);this.resizerImageContainer.style.left=`${r}px`,this.resizerImageContainer.style.top=`${o}px`,this.resizerImage.style.width=`${this.curElement.width*e}px`,this.resizerImage.style.height=`${this.curElement.height*e}px`;const a=this._mousemove.bind(this);document.addEventListener("mousemove",a),document.addEventListener("mouseup",()=>{var s;this.curElement&&!this.previewerDrawOption.dragDisable&&(this.curElement.width=this.width,this.curElement.height=this.height,this.draw.render({isSetCursor:!0,curIndex:(s=this.curPosition)==null?void 0:s.index})),this.resizerImageContainer.style.display="none",document.removeEventListener("mousemove",a),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.curElement||this.previewerDrawOption.dragDisable)return;const{scale:e}=this.options;let i=0,n=0;switch(this.curHandleIndex){case 0:{const c=this.mousedownX-t.x,h=this.mousedownY-t.y;i=Math.cbrt(c**3+h**3),n=this.curElement.height*i/this.curElement.width}break;case 1:n=this.mousedownY-t.y;break;case 2:{const c=t.x-this.mousedownX,h=this.mousedownY-t.y;i=Math.cbrt(c**3+h**3),n=this.curElement.height*i/this.curElement.width}break;case 4:{const c=t.x-this.mousedownX,h=t.y-this.mousedownY;i=Math.cbrt(c**3+h**3),n=this.curElement.height*i/this.curElement.width}break;case 3:i=t.x-this.mousedownX;break;case 5:n=t.y-this.mousedownY;break;case 6:{const c=this.mousedownX-t.x,h=t.y-this.mousedownY;i=Math.cbrt(c**3+h**3),n=this.curElement.height*i/this.curElement.width}break;case 7:i=this.mousedownX-t.x;break}const r=this.curElement.width+i/e,o=this.curElement.height+n/e;if(r<=0||o<=0)return;this.width=r,this.height=o;const a=r*e,s=o*e;this.resizerImage.style.width=`${a}px`,this.resizerImage.style.height=`${s}px`,this._updateResizerRect(a,s),this._updateResizerSizeView(a,s),t.preventDefault(),this.eventBus.hasSubscribers("imageSizeChange")&&this.eventBus.emit("imageSizeChange",{element:this.curElement})}_drawPreviewer(){const t=document.createElement("div");t.classList.add(`${J}-image-previewer`);const e=document.createElement("i");e.classList.add("image-close"),e.onclick=()=>{this._clearPreviewer()},t.append(e);const i=document.createElement("div");i.classList.add(`${J}-image-container`);const n=document.createElement("img");n.setAttribute("crossOrigin","Anonymous"),n.src=this.curElementSrc,n.draggable=!1,i.append(n),this.previewerImage=n,t.append(i);let r=0,o=0,a=1,s=0;const c=document.createElement("div");c.classList.add(`${J}-image-menu`);const h=document.createElement("div");h.classList.add("image-navigate");const d=document.createElement("i");d.classList.add("image-pre"),d.onclick=()=>{const L=this.imageList.findIndex(T=>{var x;return T.id===((x=this.curShowElement)==null?void 0:x.id)});L<=0||(this.curShowElement=this.imageList[L-1],n.src=this.curShowElement.value,this._updateImageNavigate())},h.append(d),this.imagePre=d;const u=document.createElement("span");u.classList.add("image-count"),this.imageCount=u,h.append(u);const g=document.createElement("i");g.classList.add("image-next"),g.onclick=()=>{const L=this.imageList.findIndex(T=>{var x;return T.id===((x=this.curShowElement)==null?void 0:x.id)});L>=this.imageList.length-1||(this.curShowElement=this.imageList[L+1],n.src=this.curShowElement.value,this._updateImageNavigate())},this.imageNext=g,h.append(g),c.append(h);const p=document.createElement("i");p.classList.add("zoom-in"),p.onclick=()=>{a+=.1,this._setPreviewerTransform(a,s,r,o)},c.append(p);const f=document.createElement("i");f.onclick=()=>{a-.1<=.1||(a-=.1,this._setPreviewerTransform(a,s,r,o))},f.classList.add("zoom-out"),c.append(f);const D=document.createElement("i");D.classList.add("rotate"),D.onclick=()=>{s+=1,this._setPreviewerTransform(a,s,r,o)},c.append(D);const C=document.createElement("i");C.classList.add("original-size"),C.onclick=()=>{r=0,o=0,a=1,s=0,this._setPreviewerTransform(a,s,r,o)},c.append(C);const I=document.createElement("i");I.classList.add("image-download"),I.onclick=()=>{var T;const{mime:L}=this.previewerDrawOption;Ws(n.src,`${(T=this.curElement)==null?void 0:T.id}.${L||"png"}`)},c.append(I),t.append(c),this.previewerContainer=t,document.body.append(t);let E=0,w=0,v=!1;n.onmousedown=L=>{v=!0,E=L.x,w=L.y,t.style.cursor="move"},t.onmousemove=L=>{v&&(r+=L.x-E,o+=L.y-w,E=L.x,w=L.y,this._setPreviewerTransform(a,s,r,o))},t.onmouseup=()=>{v=!1,t.style.cursor="auto"},t.onwheel=L=>{if(L.preventDefault(),L.stopPropagation(),L.deltaY<0)a+=.1;else{if(a-.1<=.1)return;a-=.1}this._setPreviewerTransform(a,s,r,o)},this._updateImageNavigate()}_updateImageNavigate(){const t=this.imageList.findIndex(e=>{var i;return e.id===((i=this.curShowElement)==null?void 0:i.id)});this.imageCount.innerText=`${t+1} / ${this.imageList.length}`,t<=0?this.imagePre.classList.add("disabled"):this.imagePre.classList.remove("disabled"),t>=this.imageList.length-1?this.imageNext.classList.add("disabled"):this.imageNext.classList.remove("disabled")}_setPreviewerTransform(t,e,i,n){this.previewerImage&&(this.previewerImage.style.left=`${i}px`,this.previewerImage.style.top=`${n}px`,this.previewerImage.style.transform=`scale(${t}) rotate(${e*90}deg)`)}_clearPreviewer(){var t;(t=this.previewerContainer)==null||t.remove(),this.previewerContainer=null,document.body.style.overflow="auto"}_updateResizerRect(t,e){const{resizerSize:i,scale:n}=this.options,r=this.draw.isReadonly();this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let o=0;o<8;o++){const a=o===0||o===6||o===7?-i:o===1||o===5?t/2:t-i,s=o===0||o===1||o===2?-i:o===3||o===7?e/2-i:e-i;this.resizerHandleList[o].style.transform=`scale(${n})`,this.resizerHandleList[o].style.left=`${a}px`,this.resizerHandleList[o].style.top=`${s}px`,this.resizerHandleList[o].style.display=r?"none":"block"}}_updateResizerSizeView(t,e){this.resizerSize.innerText=`${Math.round(t)} × ${Math.round(e)}`}render(){var e,i;const t=this.draw.getMode();!this.curElement||this.curElement.imgToolDisabled&&!this.draw.isDesignMode()||t===at.PRINT&&((e=this.options.modeRule[at.PRINT])!=null&&e.imagePreviewerDisabled)||t===at.READONLY&&((i=this.options.modeRule[at.READONLY])!=null&&i.imagePreviewerDisabled)||(this.imageList=this.draw.getImageParticle().getOriginalMainImageList(),this.curShowElement=this.curElement,this._drawPreviewer(),document.body.style.overflow="hidden")}drawResizer(t,e=null,i={}){var r,o;const n=this.draw.getMode();t.imgToolDisabled&&!this.draw.isDesignMode()||n===at.PRINT&&((r=this.options.modeRule[at.PRINT])!=null&&r.imagePreviewerDisabled)||n===at.READONLY&&((o=this.options.modeRule[at.READONLY])!=null&&o.imagePreviewerDisabled)||(this.previewerDrawOption=i,this.curElementSrc=t[i.srcKey||"value"]||"",this.updateResizer(t,e),document.addEventListener("keydown",this._keydown))}updateResizer(t,e=null){const{scale:i}=this.options,n=t.width*i,r=t.height*i;this._updateResizerSizeView(n,r);const{x:o,y:a}=this._getElementPosition(t,e);this.resizerSelection.style.left=`${o}px`,this.resizerSelection.style.top=`${a}px`,this.resizerSelection.style.borderWidth=`${i}px`,this._updateResizerRect(n,r),this.resizerSelection.style.display="block",this.curElement=t,this.curPosition=e,this.width=n,this.height=r}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}class po{constructor(){m(this,"promiseList");this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class fo{constructor(t,e){m(this,"draw");m(this,"zone");m(this,"i18n");m(this,"container");m(this,"pageContainer");m(this,"isDisableMouseMove");m(this,"tipContainer");m(this,"tipContent");m(this,"currentMoveZone");this.draw=t,this.zone=e,this.i18n=t.getI18n(),this.container=t.getContainer(),this.pageContainer=t.getPageContainer();const{tipContainer:i,tipContent:n}=this._drawZoneTip();this.tipContainer=i,this.tipContent=n,this.isDisableMouseMove=!0,this.currentMoveZone=st.MAIN;const r=[],{header:o,footer:a}=t.getOptions();o.disabled||r.push(st.HEADER),a.disabled||r.push(st.FOOTER),r.length&&this._watchMouseMoveZoneChange(r)}_watchMouseMoveZoneChange(t){this.pageContainer.addEventListener("mousemove",Ms(e=>{if(!(this.isDisableMouseMove||!this.draw.getIsPagingMode())&&e.offsetY)if(e.target instanceof HTMLCanvasElement){const i=this.zone.getZoneByY(e.offsetY);if(!t.includes(i)){this._updateZoneTip(!1);return}this.currentMoveZone=i,this._updateZoneTip(this.zone.getZone()===st.MAIN&&(i===st.HEADER||i===st.FOOTER),e.x,e.y)}else this._updateZoneTip(!1)},250)),this.pageContainer.addEventListener("mouseenter",()=>{this.isDisableMouseMove=!1}),this.pageContainer.addEventListener("mouseleave",()=>{this.isDisableMouseMove=!0,this._updateZoneTip(!1)})}_drawZoneTip(){const t=document.createElement("div");t.classList.add(`${J}-zone-tip`);const e=document.createElement("span");return t.append(e),this.container.append(t),{tipContainer:t,tipContent:e}}_updateZoneTip(t,e,i){t?(this.tipContainer.classList.add("show"),this.tipContainer.style.left=`${e}px`,this.tipContainer.style.top=`${i}px`,this.tipContent.innerText=this.i18n.t(`zone.${this.currentMoveZone===st.HEADER?"headerTip":"footerTip"}`)):this.tipContainer.classList.remove("show")}}class mo{constructor(t){m(this,"INDICATOR_PADDING",2);m(this,"draw");m(this,"options");m(this,"i18n");m(this,"container");m(this,"currentZone");m(this,"indicatorContainer");m(this,"pageNumberMenu");this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=st.MAIN,this.indicatorContainer=null,this.pageNumberMenu=null,this.options.zone.tipDisabled||new fo(t,this)}isHeaderActive(){return this.getZone()===st.HEADER}isMainActive(){return this.getZone()===st.MAIN}isFooterActive(){return this.getZone()===st.FOOTER}getZone(){return this.currentZone}setZone(t){const{header:e,footer:i}=this.options;!e.editable&&t===st.HEADER||!i.editable&&t===st.FOOTER||this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),Ji(()=>{const n=this.draw.getListener();n.zoneChange&&n.zoneChange(t);const r=this.draw.getEventBus();r.hasSubscribers("zoneChange")&&r.emit("zoneChange",t)}))}getZoneByY(t){const i=this.draw.getHeader().getExtraHeight()+this.draw.getMargins()[0],n=this.draw.getFooter(),o=this.draw.getHeight()-(n.getExtraHeight()+this.draw.getMargins()[2]);return t<i?st.HEADER:t>o?st.FOOTER:st.MAIN}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),i=this.draw.getPageList(),n=this.draw.getMargins(),r=this.draw.getInnerWidth(),o=this.draw.getHeight(),a=this.draw.getPageGap(),s=o+a;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${J}-zone-indicator`);const c=this.draw.getHeader(),h=this.draw.getFooter(),d=e?c.getHeight():h.getHeight(),u=e?c.getHeaderTop():o-h.getFooterBottom()-d;for(let g=0;g<i.length;g++){const p=s*g+u,f=n[3]-this.INDICATOR_PADDING,D=n[3]+r+this.INDICATOR_PADDING,C=e?p-this.INDICATOR_PADDING:p+d+this.INDICATOR_PADDING,I=e?p+d+this.INDICATOR_PADDING:p-this.INDICATOR_PADDING,E=document.createElement("div");E.classList.add(`${J}-zone-toolbar`),E.style.top=`${I}px`,E.style.left=`${n[3]}px`,E.style.width=`${r}px`,E.style.transform=`scale(${t})`,E.style.transformOrigin="0 0";const w=document.createElement("div");w.classList.add(`${J}-zone-toolbar-label`);const v=this._getZoneName(e);w.innerText=`${v} - 第 ${g+1} 节-`,E.append(w);const L=document.createElement("div");L.classList.add(`${J}-zone-toolbar-btn`),L.innerHTML='<svg viewBox="0 0 1024 1024" width="14" height="14"><path d="M896 896H128V128h576v64H192v640h640V448h64v448z" fill="#0078d4"></path><path d="M640 192h192v64H640zM704 128h64v192h-64z" fill="#0078d4"></path><path d="M352 448h320v64H352zM352 576h256v64H352zM352 320h192v64H352z" fill="#0078d4"></path></svg><span>插入页码</span><svg viewBox="0 0 1024 1024" width="12" height="12"><path d="M512 714.667l-298.667-298.667h597.333z" fill="currentColor"></path></svg>',L.onclick=M=>{M.stopPropagation(),this._showPageNumberMenu(L)},E.append(L),this.indicatorContainer.append(E);const T=document.createElement("span");T.classList.add(`${J}-zone-indicator-border__top`),T.style.top=`${C}px`,T.style.width=`${r}px`,T.style.marginLeft=`${n[3]}px`,this.indicatorContainer.append(T);const x=document.createElement("span");x.classList.add(`${J}-zone-indicator-border__left`),x.style.top=`${p}px`,x.style.height=`${d}px`,x.style.left=`${f}px`,this.indicatorContainer.append(x);const B=document.createElement("span");B.classList.add(`${J}-zone-indicator-border__bottom`),B.style.top=`${I}px`,this.indicatorContainer.append(B);const F=document.createElement("span");F.classList.add(`${J}-zone-indicator-border__right`),F.style.top=`${p}px`,F.style.height=`${d}px`,F.style.left=`${D}px`,this.indicatorContainer.append(F)}this.container.append(this.indicatorContainer)}_showPageNumberMenu(t){this._hidePageNumberMenu();const e=t.getBoundingClientRect(),i=document.createElement("div");i.classList.add(`${J}-zone-pagenumber-menu`),i.style.top=`${e.bottom+2}px`,i.style.left=`${e.left}px`,qo.forEach(o=>{const a=document.createElement("div");a.classList.add(`${J}-zone-pagenumber-menu-item`),a.innerText=o.label,a.onclick=s=>{s.stopPropagation(),this._insertPageNumber(o.value,o.numberType),this._hidePageNumberMenu()},i.append(a)}),document.body.append(i),this.pageNumberMenu=i;const n=()=>this._hidePageNumberMenu();window.addEventListener("scroll",n,!0),i._scrollHandler=n;const r=o=>{i.contains(o.target)||this._hidePageNumberMenu()};setTimeout(()=>{document.addEventListener("click",r)},0),i._closeHandler=r}_hidePageNumberMenu(){if(this.pageNumberMenu){const t=this.pageNumberMenu._scrollHandler;t&&window.removeEventListener("scroll",t,!0);const e=this.pageNumberMenu._closeHandler;e&&document.removeEventListener("click",e),this.pageNumberMenu.remove(),this.pageNumberMenu=null}}_insertPageNumber(t,e){const i=this.draw.getOptions();i.pageNumber=i.pageNumber||{};const n=i.pageNumber;n.format=t,e&&(n.numberType=e),this.draw.render({isSubmitHistory:!0,isSetCursor:!1})}_getZoneName(t){const e=`frame.${t?"header":"footer"}`,i=this.i18n.t(e);return i&&i!==e?i:t?"页眉":"页脚"}_clearZoneIndicator(){var t;(t=this.indicatorContainer)==null||t.remove(),this.indicatorContainer=null,this._hidePageNumberMenu()}}class Do{constructor(t,e){m(this,"draw");m(this,"position");m(this,"zone");m(this,"options");m(this,"elementList");m(this,"rowList");m(this,"positionList");this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(){const t=this.getFooterBottom(),e=this.draw.getInnerWidth(),n=this.draw.getMargins()[3],r=this.draw.getHeight(),o=this.getHeight(),a=r-t-o;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:n,startY:a,innerWidth:e,zone:st.FOOTER})}getFooterBottom(){const{footer:{bottom:t,disabled:e},scale:i}=this.options;return e?0:Math.floor(t*i)}getMaxHeight(){const{footer:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*Ki[t])}getHeight(){const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),n=this.getFooterBottom()+e-t[2];return n<=0?0:n}render(t,e){t.save(),t.globalAlpha=this.zone.isFooterActive()?1:this.options.footer.inactiveAlpha;const i=this.draw.getInnerWidth(),n=this.getMaxHeight(),r=[];let o=0;for(let a=0;a<this.rowList.length;a++){const s=this.rowList[a];if(o+s.height>n)break;r.push(s),o+=s.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:r,pageNo:e,startIndex:0,innerWidth:i,zone:st.FOOTER,isDrawLineBreak:!1}),t.restore()}}class tl{drawSymbol(t,e,i,n,r,o){t.save(),t.fillStyle=o,t.strokeStyle=o,t.lineWidth=Math.max(1.5,r*.08);const a=r*.6,s=n;switch(e){case K.DISC:this.drawDisc(t,i,s,a);break;case K.CIRCLE:this.drawCircle(t,i,s,a);break;case K.SQUARE:this.drawSquare(t,i,s,a,!0);break;case K.DIAMOND:case K.DIAMOND_SOLID:this.drawDiamond(t,i,s,a,!0);break;case K.DASH:this.drawDash(t,i,s,a);break;case K.CHECK:this.drawCheck(t,i,s,a);break;case K.TRIANGLE:case K.TRIANGLE_SOLID:this.drawTriangle(t,i,s,a,!0);break;case K.STAR:case K.STAR_SOLID:this.drawStar(t,i,s,a,!0);break;case K.ARROW:this.drawArrow(t,i,s,a);break;case K.ANGLE:this.drawAngle(t,i,s,a);break;case K.HOLLOW_CIRCLE:this.drawCircle(t,i,s,a);break;case K.HOLLOW_SQUARE:this.drawSquare(t,i,s,a,!1);break;case K.HEART_HOLLOW:this.drawHeart(t,i,s,a,!1);break;case K.HASH:this.drawHash(t,i,s,a);break;case K.HEART_SOLID:this.drawHeart(t,i,s,a,!0);break;case K.FLOWER:this.drawFlower(t,i,s,a);break;case K.ASTERISK:this.drawAsterisk(t,i,s,a);break;case K.HOLLOW_DIAMOND:this.drawDiamond(t,i,s,a,!1);break;case K.HOLLOW_TRIANGLE:this.drawTriangle(t,i,s,a,!1);break;default:this.drawDisc(t,i,s,a)}t.restore()}drawDisc(t,e,i,n){t.beginPath(),t.arc(e,i,n*.5,0,Math.PI*2),t.fill()}drawCircle(t,e,i,n){t.beginPath(),t.arc(e,i,n*.5,0,Math.PI*2),t.stroke()}drawSquare(t,e,i,n,r){const o=n*.5;t.beginPath(),t.rect(e-o,i-o,n,n),r?t.fill():t.stroke()}drawDiamond(t,e,i,n,r){const o=n*.6;t.beginPath(),t.moveTo(e,i-o),t.lineTo(e+o,i),t.lineTo(e,i+o),t.lineTo(e-o,i),t.closePath(),r?t.fill():t.stroke()}drawDash(t,e,i,n){const r=n*.6;t.beginPath(),t.moveTo(e-r,i),t.lineTo(e+r,i),t.stroke()}drawCheck(t,e,i,n){const r=n*.04;t.beginPath(),t.moveTo(e-n*.3,i),t.lineTo(e-n*.1,i+n*.25),t.lineTo(e+n*.35,i-n*.25),t.lineWidth=Math.max(1.5,r*4),t.stroke()}drawTriangle(t,e,i,n,r){const o=n*.55;t.beginPath(),t.moveTo(e-o,i-o*.6),t.lineTo(e+o,i),t.lineTo(e-o,i+o*.6),t.closePath(),r?t.fill():t.stroke()}drawStar(t,e,i,n,r){const o=n*.55,a=o*.4,s=5,c=Math.PI/s;t.beginPath();for(let h=0;h<2*s;h++){const d=h%2===0?o:a,u=h*c-Math.PI/2,g=e+d*Math.cos(u),p=i+d*Math.sin(u);h===0?t.moveTo(g,p):t.lineTo(g,p)}t.closePath(),r?t.fill():t.stroke()}drawArrow(t,e,i,n){const r=n*.5;t.beginPath(),t.moveTo(e-r*.3,i-r),t.lineTo(e+r,i),t.lineTo(e-r*.3,i+r),t.lineTo(e-r*.3,i),t.closePath(),t.fill()}drawAngle(t,e,i,n){const r=n*.5;t.beginPath(),t.moveTo(e-r,i-r*.8),t.lineTo(e+r*.3,i),t.lineTo(e-r,i+r*.8),t.lineWidth=Math.max(1.5,n*.08),t.stroke()}drawHeart(t,e,i,n,r){const o=n*.025;t.beginPath(),t.moveTo(e,i+o*4),t.bezierCurveTo(e-o*5,i+o*1,e-o*6,i-o*4,e,i-o*2),t.bezierCurveTo(e+o*6,i-o*4,e+o*5,i+o*1,e,i+o*4),t.closePath(),r?t.fill():t.stroke()}drawHash(t,e,i,n){const r=n*.5,o=n*.2;t.beginPath(),t.moveTo(e-r*.5,i-r),t.lineTo(e+r*.5,i+r),t.moveTo(e+r*.5,i-r),t.lineTo(e-r*.5,i+r),t.moveTo(e-r,i-o),t.lineTo(e+r,i-o),t.moveTo(e-r,i+o),t.lineTo(e+r,i+o),t.lineWidth=Math.max(1,n*.06),t.stroke()}drawFlower(t,e,i,n){const r=n*.25,o=n*.2,a=5;for(let s=0;s<a;s++){const c=s*2*Math.PI/a-Math.PI/2,h=e+o*Math.cos(c),d=i+o*Math.sin(c);t.beginPath(),t.arc(h,d,r,0,Math.PI*2),t.fill()}t.beginPath(),t.arc(e,i,r*.6,0,Math.PI*2),t.fill()}drawAsterisk(t,e,i,n){const r=n*.5,o=4;t.beginPath();for(let a=0;a<o;a++){const s=a*Math.PI/o,c=r*Math.cos(s),h=r*Math.sin(s);t.moveTo(e-c,i-h),t.lineTo(e+c,i+h)}t.lineWidth=Math.max(1.5,n*.08),t.stroke()}getSymbolWidth(t,e){const i=e*.6;switch(t){case K.DISC:case K.CIRCLE:case K.HOLLOW_CIRCLE:return i;case K.SQUARE:case K.HOLLOW_SQUARE:return i;case K.DIAMOND:case K.DIAMOND_SOLID:case K.HOLLOW_DIAMOND:return i*1.2;case K.DASH:return i*1.2;case K.CHECK:return i*.7;case K.TRIANGLE:case K.TRIANGLE_SOLID:case K.HOLLOW_TRIANGLE:return i*1.1;case K.STAR:case K.STAR_SOLID:return i*1.1;case K.ARROW:return i*1.5;case K.ANGLE:return i*1.3;case K.HEART_HOLLOW:case K.HEART_SOLID:return i*1.2;case K.HASH:return i;case K.FLOWER:return i*.9;case K.ASTERISK:return i;default:return i}}}class Co{constructor(t){m(this,"draw");m(this,"range");m(this,"options");m(this,"symbolDrawer");m(this,"MEASURE_BASE_TEXT","0");m(this,"LIST_GAP",10);this.draw=t,this.range=t.getRange(),this.options=t.getOptions(),this.symbolDrawer=new tl}setList(t,e){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:r}=this.range.getRange();if(!~n&&!~r)return;const o=this.range.getRangeParagraphElementList();if(!o||!o.length)return;if(o.find(d=>d.listType===t&&d.listStyle===e)||!t){this.unsetList();return}const s=pt();o.forEach(d=>{d.listId=s,d.listType=t,d.listStyle=e});const c=n===r,h=c?r:n;this.draw.render({curIndex:h,isSetCursor:c})}unsetList(){var c;if(this.draw.isReadonly())return;const{startIndex:e,endIndex:i}=this.range.getRange();if(!~e&&!~i)return;const n=(c=this.range.getRangeParagraphElementList())==null?void 0:c.filter(h=>h.listId);if(!n||!n.length)return;const r=this.draw.getElementList(),o=r[i];if(o.listId){let h=i+1;for(;h<r.length;){const d=r[h];if(oi(d))break;if(d.listId!==o.listId){this.draw.spliceElementList(r,h,0,[{value:Y}]);break}h++}}n.forEach(h=>{delete h.listId,delete h.listType,delete h.listStyle,delete h.listWrap});const a=e===i,s=a?i:e;this.draw.render({curIndex:s,isSetCursor:a})}computeListStyle(t,e){const i=new Map;let n=0,r=e[n].listId,o=[];const a=e.length;for(;n<a;){const s=e[n];if(r&&r===s.listId)o.push(s);else if(s.listId&&s.listId!==r){if(o.length){const c=this.getListStyleWidth(t,o);i.set(r,c)}r=s.listId,o=r?[s]:[]}n++}if(o.length){const s=this.getListStyleWidth(t,o);i.set(r,s)}return i}getListStyleWidth(t,e){const{scale:i,checkbox:n,defaultSize:r,defaultFont:o}=this.options,a=e[0];let s=a;for(let f=1;f<e.length;f++){const D=e[f];if(D.value!==Y&&D.value!==" "){s=D;break}}const c=s.actualSize||s.size||r,h=s.font||o,d=c*i;if(a.listStyle&&a.listStyle!==It.DECIMAL){if(a.listStyle===It.CHECKBOX)return(n.width+this.LIST_GAP)*i;if(a.listType===ge.UL){const C=this.symbolDrawer.getSymbolWidth(a.listStyle,d);return Math.ceil(C+this.LIST_GAP*i)}t.save(),t.font=`${d}px ${h}`;const f=this.getOlValue(a.listStyle,1),D=t.measureText(f);return t.restore(),Math.ceil((D.width+this.LIST_GAP)*i)}const u=e.reduce((f,D)=>(D.value===Y&&(f+=1),f),0);if(!u)return 0;const g=`${this.MEASURE_BASE_TEXT.repeat(String(u).length)}${wt.PERIOD}`;t.save(),t.font=`${d}px ${h}`;const p=t.measureText(g);return t.restore(),Math.ceil((p.width+this.LIST_GAP)*i)}drawListStyle(t,e,i){var x;const{elementList:n,offsetX:r,listIndex:o,ascent:a,height:s}=e,c=n[0];if(c.value!==Y||c.listWrap)return;let h=0;const{defaultTabWidth:d,scale:u,defaultFont:g,defaultSize:p}=this.options;for(let B=1;B<n.length;B++){const F=n[B];if((F==null?void 0:F.type)!==R.TAB)break;h+=d*u}const{coordinate:{leftTop:[f,D]}}=i,C=f-r+h-(c.listHanging||0)*this.options.scale;if(c.listStyle===It.CHECKBOX){const{width:B,height:F,gap:M}=this.options.checkbox,P={...c,checkbox:{value:!!((x=c.checkbox)!=null&&x.value)},metrics:{...c.metrics,width:(B+M*2)*u,height:F*u}};this.draw.getCheckboxParticle().render({ctx:t,x:C-M*u,y:D+a,index:0,row:{...e,elementList:[P,...e.elementList]}});return}let I=c;for(let B=1;B<n.length;B++){const F=n[B];if(F.value!==Y&&F.value!==" "){I=F;break}}const w=(I.actualSize||I.size||p)*u,v=I.color||this.options.defaultColor,L=D+a,T=D+s/2;if(c.listType===ge.UL){const B=c.listStyle||K.DISC,F=this.symbolDrawer.getSymbolWidth(B,w),M=C+F/2;this.symbolDrawer.drawSymbol(t,B,M,T,w,v)}else{const B=I.font||g,F=this.getOlValue(c.listStyle,o+1);if(!F)return;t.save(),t.font=`${I.italic?"italic ":""}${I.bold?"bold ":""}${w}px ${B}`,t.fillStyle=v,t.fillText(F,C,L),t.restore()}}getOlValue(t,e){switch(t){case Qt.CHINESE:return`${this.chineseFromNumber(e)}、`;case Qt.CHINESE_BRACKET:return`(${this.chineseFromNumber(e)})`;case Qt.DECIMAL_DOT:case Qt.DECIMAL:return`${e}${wt.PERIOD}`;case Qt.DECIMAL_PAREN:return`(${e})`;case Qt.DECIMAL_BRACKET:return`${e})`;case Qt.DECIMAL_CIRCLE:return this.circleFromNumber(e);case Qt.UPPER_ALPHA:return this.alphaFromNumber(e,!0);case Qt.LOWER_ALPHA_DOT:return`${this.alphaFromNumber(e,!1)}${wt.PERIOD}`;default:return`${e}${wt.PERIOD}`}}chineseFromNumber(t){const e=["零","一","二","三","四","五","六","七","八","九"],i=["","十","百","千"];if(t===0)return e[0];if(t<10)return e[t];if(t===10)return"十";if(t<20)return`十${e[t%10]}`;let n="",r=0;for(;t>0;){const o=t%10;o!==0?n=e[o]+i[r]+n:n!==""&&!n.startsWith(e[0])&&(n=e[0]+n),t=Math.floor(t/10),r++}return n.replace(/零+$/,"")}circleFromNumber(t){return["①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩","⑪","⑫","⑬","⑭","⑮","⑯","⑰","⑱","⑲","⑳"][t-1]||String(t)}alphaFromNumber(t,e){let i="";const n=e?65:97;for(;t>0;)t--,i=String.fromCharCode(n+t%26)+i,t=Math.floor(t/26);return i}}const Se=class Se{constructor(t){m(this,"options");this.options=t.getOptions()}render(t,e,i,n){const{scale:r,lineBreak:{color:o,lineWidth:a}}=this.options;t.save(),t.beginPath();const s=n-Se.HEIGHT*r/2,c=i+e.metrics.width;t.translate(c,s),t.scale(r,r),t.strokeStyle=o,t.lineWidth=a,t.lineCap="round",t.lineJoin="round",t.beginPath(),t.moveTo(8,0),t.lineTo(12,0),t.lineTo(12,6),t.lineTo(3,6),t.moveTo(3,6),t.lineTo(6,3),t.moveTo(3,6),t.lineTo(6,9),t.stroke(),t.closePath(),t.restore()}};m(Se,"WIDTH",12),m(Se,"HEIGHT",9),m(Se,"GAP",3);let Ae=Se;class Ni{constructor(t){m(this,"draw");m(this,"position");m(this,"options");m(this,"elementList");m(this,"rowList");m(this,"positionList");this.draw=t,this.position=t.getPosition(),this.options=t.getOptions(),this.elementList=[],this.rowList=[],this.positionList=[]}_recovery(){this.elementList=[],this.rowList=[],this.positionList=[]}_compute(t){this._computeRowList(),this._computePositionList(t)}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(t){const{lineBreak:e,scale:i}=this.options,n=this.draw.getHeader().getExtraHeight(),r=this.draw.getInnerWidth(),o=this.draw.getMargins();let a=o[3];e.disabled||(a+=(Ae.WIDTH+Ae.GAP)*i);const s=(t==null?void 0:t.startY)||o[0]+n;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:a,startY:s,innerWidth:r})}render(t,e){const{placeholder:i=this.options.placeholder}=e||{},{data:n,font:r,size:o,color:a,opacity:s}=i;this._recovery(),this.elementList=[{value:n,font:r,size:o,color:a}],zt(this.elementList,{editorOptions:this.options,isForceCompensation:!0}),this._compute(e);const c=this.draw.getInnerWidth();t.save(),t.globalAlpha=s,this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:this.rowList,pageNo:0,startIndex:0,innerWidth:c,isDrawLineBreak:!1}),t.restore()}}class Io{constructor(t){m(this,"draw");m(this,"options");m(this,"range");m(this,"fillRectMap");m(this,"groupIndexMap");this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map,this.groupIndexMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==st.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=pt();return t.forEach(i=>{Array.isArray(i.groupIds)||(i.groupIds=[]),i.groupIds.push(e)}),this.draw.render({isSetCursor:!1,isCompute:!1}),e}getElementListByGroupId(t,e){var n,r;const i=[];for(let o=0;o<t.length;o++){const a=t[o];if(a.type===R.TABLE){const s=a.trList;for(let c=0;c<s.length;c++){const h=s[c];for(let d=0;d<h.tdList.length;d++){const u=h.tdList[d],g=this.getElementListByGroupId(u.value,e);if(g.length)return i.push(...g),i}}}if((n=a==null?void 0:a.groupIds)!=null&&n.includes(e)){i.push(a);const s=t[o+1];if(!((r=s==null?void 0:s.groupIds)!=null&&r.includes(e)))break}}return i}deleteGroup(t){if(this.draw.isReadonly())return;const e=this.draw.getOriginalMainElementList(),i=this.getElementListByGroupId(e,t);if(i.length){for(let n=0;n<i.length;n++){const r=i[n],o=r.groupIds,a=o.findIndex(s=>s===t);o.splice(a,1),o.length||delete r.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){var r;let i=-1,n=-1;for(let o=0;o<t.length;o++){const a=t[o];if(a.type===R.TABLE){const s=a.trList;for(let c=0;c<s.length;c++){const h=s[c];for(let d=0;d<h.tdList.length;d++){const u=h.tdList[d],g=this.getContextByGroupId(u.value,e);if(g)return{...g,isTable:!0,index:o,trIndex:c,tdIndex:d,tdId:u.id,trId:h.id,tableId:a.tableId}}}}(r=a.groupIds)!=null&&r.includes(e)&&(i===-1&&(i=o),n=o)}return i!==-1?{isTable:!1,startIndex:i,endIndex:n}:null}clearFillInfo(){this.fillRectMap.clear(),this.groupIndexMap.clear()}recordFillInfo(t,e,i,n,r){const o=t.groupIds;if(o)for(const a of o){const s=this.fillRectMap.get(a);if(!s)this.fillRectMap.set(a,{lineRanges:[{x:e,y:i,width:n,height:r}]}),this.groupIndexMap.has(a)||this.groupIndexMap.set(a,this.groupIndexMap.size+1);else{const c=s.lineRanges[s.lineRanges.length-1];c&&Math.abs(c.y-i)<1?c.width+=n:s.lineRanges.push({x:e,y:i,width:n,height:r})}}}render(t){var c;if(!this.fillRectMap.size)return;const e=this.range.getRange(),n=(c=this.draw.getElementList()[e.endIndex])==null?void 0:c.groupIds,{group:{backgroundColor:r,opacity:o,activeOpacity:a,activeBackgroundColor:s}}=this.options;t.save(),this.fillRectMap.forEach((h,d)=>{const{lineRanges:u}=h;(n==null?void 0:n.includes(d))?(t.globalAlpha=a,t.fillStyle=s):(t.globalAlpha=o,t.fillStyle=r);for(const p of u)t.fillRect(p.x,p.y,p.width,p.height)}),t.restore(),this.clearFillInfo()}getCommentIndex(t){return this.groupIndexMap.get(t)||0}getAllGroupIds(){const t=Array.from(this.groupIndexMap.entries());return t.sort((e,i)=>e[1]-i[1]),t.map(e=>e[0])}}class Eo{constructor(t){m(this,"draw");m(this,"eventBus");m(this,"pageContainer");m(this,"_mousemoveHandler");m(this,"_mouseenterHandler");m(this,"_mouseleaveHandler");m(this,"_mousedownHandler");m(this,"_mouseupHandler");m(this,"_clickHandler");this.draw=t,this.eventBus=this.draw.getEventBus(),this.pageContainer=this.draw.getPageContainer(),this._mousemoveHandler=this._mousemove.bind(this),this._mouseenterHandler=this._mouseenter.bind(this),this._mouseleaveHandler=this._mouseleave.bind(this),this._mousedownHandler=this._mousedown.bind(this),this._mouseupHandler=this._mouseup.bind(this),this._clickHandler=this._click.bind(this),this.pageContainer.addEventListener("mousemove",this._mousemoveHandler),this.pageContainer.addEventListener("mouseenter",this._mouseenterHandler),this.pageContainer.addEventListener("mouseleave",this._mouseleaveHandler),this.pageContainer.addEventListener("mousedown",this._mousedownHandler),this.pageContainer.addEventListener("mouseup",this._mouseupHandler),this.pageContainer.addEventListener("click",this._clickHandler)}removeEvent(){this.pageContainer.removeEventListener("mousemove",this._mousemoveHandler),this.pageContainer.removeEventListener("mouseenter",this._mouseenterHandler),this.pageContainer.removeEventListener("mouseleave",this._mouseleaveHandler),this.pageContainer.removeEventListener("mousedown",this._mousedownHandler),this.pageContainer.removeEventListener("mouseup",this._mouseupHandler),this.pageContainer.removeEventListener("click",this._clickHandler)}_mousemove(t){this.eventBus.hasSubscribers("mousemove")&&this.eventBus.emit("mousemove",t)}_mouseenter(t){this.eventBus.hasSubscribers("mouseenter")&&this.eventBus.emit("mouseenter",t)}_mouseleave(t){this.eventBus.hasSubscribers("mouseleave")&&this.eventBus.emit("mouseleave",t)}_mousedown(t){this.eventBus.hasSubscribers("mousedown")&&this.eventBus.emit("mousedown",t)}_mouseup(t){this.eventBus.hasSubscribers("mouseup")&&this.eventBus.emit("mouseup",t)}_click(t){this.eventBus.hasSubscribers("click")&&this.eventBus.emit("click",t)}}class Lo{constructor(t){m(this,"draw");m(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:i,lineNumber:{color:n,size:r,font:o,right:a,type:s}}=this.options,c=this.draw.getTextParticle(),h=this.draw.getMargins(),d=this.draw.getPosition().getOriginalMainPositionList(),g=this.draw.getPageRowList()[e];t.save(),t.fillStyle=n,t.font=`${r*i}px ${o}`;for(let p=0;p<g.length;p++){const f=g[p],{coordinate:{leftBottom:D}}=d[f.startIndex],C=s===pi.PAGE?p+1:f.rowIndex+1,I=c.measureText(t,{value:`${C}`}),E=h[3]-(I.width+a)*i,w=D[1]-I.actualBoundingBoxAscent*i;t.fillText(`${C}`,E,w)}t.restore()}}class wo{constructor(t){m(this,"draw");m(this,"header");m(this,"footer");m(this,"options");this.draw=t,this.header=t.getHeader(),this.footer=t.getFooter(),this.options=t.getOptions()}render(t){const{scale:e,pageBorder:{color:i,lineWidth:n,padding:r}}=this.options;t.save(),t.translate(.5,.5),t.strokeStyle=i,t.lineWidth=n*e;const o=this.draw.getMargins(),a=o[3]-r[3]*e,s=o[0]+this.header.getExtraHeight()-r[0]*e,c=this.draw.getInnerWidth()+(r[1]+r[3])*e,h=this.draw.getHeight()-s-this.footer.getExtraHeight()-o[2]+r[2]*e;t.rect(a,s,c,h),t.stroke(),t.restore()}}class vo{constructor(t){m(this,"draw");m(this,"range");m(this,"position");m(this,"tableTool");m(this,"tableParticle");m(this,"options");this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.tableTool=t.getTableTool(),this.tableParticle=t.getTableParticle(),this.options=t.getOptions()}insertTable(t,e){var w;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return;const{defaultTrHeight:r,defaultTrMinHeight:o,tdPadding:a,defaultBorderColor:s}=this.options.table,c=this.draw.getElementList();let h=0;if((w=c[i])!=null&&w.listId){const v=this.position.getPositionList(),{rowIndex:L}=v[i],x=this.draw.getRowList()[L];h=(x==null?void 0:x.offsetX)||0}const d=this.draw.getContextInnerWidth()-h,u=a[0]+a[2],g=Number.isFinite(Number(r))&&Number(r)>0?Number(r):0,p=Math.max(o,g,Math.ceil(this.options.defaultSize*1.4+u)),f=[],D=d/e;for(let v=0;v<e;v++)f.push({width:D});const C=[];for(let v=0;v<t;v++){const L=[],T={height:p,tdList:L};for(let x=0;x<e;x++)L.push({colspan:1,rowspan:1,value:[]});C.push(T)}const I={type:R.TABLE,value:"",colgroup:f,trList:C,borderType:Kt.ALL,borderColor:s,borderWidth:.5};zt([I],{editorOptions:this.options}),Xt(c,[I],i,{editorOptions:this.options});const E=i+1;this.draw.spliceElementList(c,E,i===n?0:n-i,[I]),this.range.setRange(E,E),this.draw.render({curIndex:E,isSetCursor:!1})}insertTableTopRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:i,tableId:n}=t,o=this.draw.getOriginalElementList()[e],a=o.trList,s=a[i];if(s.tdList.length<o.colgroup.length){const d=s.tdList[0].rowIndex;for(let u=0;u<i;u++){const g=a[u];for(let p=0;p<g.tdList.length;p++){const f=g.tdList[p];f.rowspan>1&&f.rowIndex+f.rowspan>=d+1&&(f.rowspan+=1)}}}const c=pt(),h={height:s.height,id:c,tdList:[]};for(let d=0;d<s.tdList.length;d++){const u=s.tdList[d],g=pt();h.tdList.push({id:g,rowspan:1,colspan:u.colspan,value:[{value:Y,size:16,tableId:n,trId:c,tdId:g}]})}a.splice(i,0,h),this.position.setPositionContext({isTable:!0,index:e,trIndex:i,tdIndex:0,tdId:h.tdList[0].id,trId:h.id,tableId:n}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableBottomRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:i,tableId:n}=t,o=this.draw.getOriginalElementList()[e],a=o.trList,s=a[i],c=a.length-1===i?s:a[i+1];if(c.tdList.length<o.colgroup.length){const u=c.tdList[0].rowIndex;for(let g=0;g<i+1;g++){const p=a[g];for(let f=0;f<p.tdList.length;f++){const D=p.tdList[f];D.rowspan>1&&D.rowIndex+D.rowspan>=u+1&&(D.rowspan+=1)}}}const h=pt(),d={height:c.height,id:h,tdList:[]};for(let u=0;u<c.tdList.length;u++){const g=c.tdList[u],p=pt();d.tdList.push({id:p,rowspan:1,colspan:g.colspan,value:[{value:Y,size:16,tableId:n,trId:h,tdId:p}]})}a.splice(i+1,0,d),this.position.setPositionContext({isTable:!0,index:e,trIndex:i+1,tdIndex:0,tdId:d.tdList[0].id,trId:d.id,tableId:o.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}adjustColWidth(t){if(t.type!==R.TABLE)return;const{defaultColMinWidth:e}=this.options.table,i=t.colgroup,n=i.reduce((o,a)=>o+a.width,0),r=this.draw.getOriginalInnerWidth();if(n>r){const o=i.filter(s=>s.width>e),a=(n-r)/o.length;for(let s=0;s<i.length;s++){const c=i[s];c.width-a>=e&&(c.width-=a)}}}insertTableLeftCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:i,tableId:n}=t,o=this.draw.getOriginalElementList()[e],a=o.trList,s=i;for(let d=0;d<a.length;d++){const u=a[d],g=pt();u.tdList.splice(s,0,{id:g,rowspan:1,colspan:1,value:[{value:Y,size:16,tableId:n,trId:u.id,tdId:g}]})}const{defaultColMinWidth:c}=this.options.table;o.colgroup.splice(s,0,{width:c}),this.adjustColWidth(o),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:s,tdId:a[0].tdList[s].id,trId:a[0].id,tableId:n}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableRightCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:i,tableId:n}=t,o=this.draw.getOriginalElementList()[e],a=o.trList,s=i+1;for(let d=0;d<a.length;d++){const u=a[d],g=pt();u.tdList.splice(s,0,{id:g,rowspan:1,colspan:1,value:[{value:Y,size:16,tableId:n,trId:u.id,tdId:g}]})}const{defaultColMinWidth:c}=this.options.table;o.colgroup.splice(s,0,{width:c}),this.adjustColWidth(o),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:s,tdId:a[0].tdList[s].id,trId:a[0].id,tableId:o.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}deleteTableRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:i,tdIndex:n}=t,o=this.draw.getOriginalElementList()[e],a=o.trList,s=a[i],c=s.tdList[n].rowIndex;if(a.length<=1&&o.pagingIndex===0){this.deleteTable();return}for(let h=0;h<c;h++){const u=a[h].tdList;for(let g=0;g<u.length;g++){const p=u[g];p.rowIndex+p.rowspan>c&&p.rowspan--}}for(let h=0;h<s.tdList.length;h++){const d=s.tdList[h];if(d.rowspan>1){const u=pt(),g=a[i+1];g.tdList.splice(h,0,{id:u,rowspan:d.rowspan-1,colspan:d.colspan,value:[{value:Y,size:16,tableId:o.id,trId:g.id,tdId:u}]})}}a.splice(i,1),this.position.setPositionContext({isTable:!1}),this.range.clearRange(),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTableCol(){var d;const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:i,trIndex:n}=t,o=this.draw.getOriginalElementList()[e],a=o.trList,c=a[n].tdList[i].colIndex;if(!a.find(u=>u.tdList.length>1)){this.deleteTable();return}for(let u=0;u<a.length;u++){const g=a[u];for(let p=0;p<g.tdList.length;p++){const f=g.tdList[p];f.colIndex<=c&&f.colIndex+f.colspan>c&&(f.colspan>1?f.colspan--:g.tdList.splice(p,1))}}(d=o.colgroup)==null||d.splice(c,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTable(){const t=this.position.getPositionContext();if(!t.isTable)return;const e=this.draw.getOriginalElementList(),i=e[t.index];let n=1,r=t.index;if(i.pagingId){r=t.index-i.pagingIndex;for(let a=r+1;a<e.length&&e[a].pagingId===i.pagingId;a++)n++}e.splice(r,n);const o=r-1;this.position.setPositionContext({isTable:!1,index:o}),this.range.setRange(o,o),this.draw.render({curIndex:o}),this.tableTool.dispose()}mergeTableCell(){var _;const t=this.position.getPositionContext();if(!t.isTable)return;const{isCrossRowCol:e,startTdIndex:i,endTdIndex:n,startTrIndex:r,endTrIndex:o}=this.range.getRange();if(!e)return;const{index:a}=t,c=this.draw.getOriginalElementList()[a],h=c.trList;let d=h[r].tdList[i],u=h[o].tdList[n];(d.x>u.x||d.y>u.y)&&([d,u]=[u,d]);const g=d.colIndex,p=u.colIndex+(u.colspan-1),f=d.rowIndex,D=u.rowIndex+(u.rowspan-1),C=[];for(let A=0;A<h.length;A++){const y=h[A],N=[];for(let k=0;k<y.tdList.length;k++){const z=y.tdList[k],O=z.colIndex,W=z.rowIndex;O>=g&&O<=p&&W>=f&&W<=D&&N.push(z)}N.length&&C.push(N)}if(!C.length)return;const I=C[C.length-1],E=C[0][0],w=I[I.length-1],v=E.x,L=E.y,T=w.x+w.width,x=w.y+w.height;for(let A=0;A<C.length;A++){const y=C[A];for(let N=0;N<y.length;N++){const k=y[N],z=k.x,O=k.y,W=z+k.width,V=O+k.height;if(v>z||L>O||T<W||x<V)return}}const B=[],F=C[0][0],M=A=>!!A&&A.value===Y&&!A.type,P=F.value.find(A=>!M(A))||F.value[0]||{value:Y,tableId:c.id,trId:(_=h[F.trIndex])==null?void 0:_.id,tdId:F.id};for(let A=0;A<C.length;A++){const y=C[A];for(let N=0;N<y.length;N++){const k=y[N];if(!(A===0&&N===0)){B.push(k.id);let O=0;for(;M(k.value[O]);)O++;F.value.length>0&&F.value.every(M)&&O<k.value.length&&(F.value.length=0);for(let V=O;V<k.value.length;V++){const U=k.value[V];M(U)||(Ue(qe,P,U),F.value.push(U))}}A===0&&N!==0&&(F.colspan+=k.colspan),A!==0&&F.colIndex===k.colIndex&&(F.rowspan+=k.rowspan)}}if(!F.value.length||!M(F.value[0])){const A={value:Y};Ue(qe,P,A),F.value.unshift(A)}else for(;1<F.value.length;){if(M(F.value[1])){F.value.splice(1,1);continue}break}for(let A=0;A<h.length;A++){const y=h[A];let N=0;for(;N<y.tdList.length;){const k=y.tdList[N];B.includes(k.id)&&(y.tdList.splice(N,1),N--),N++}}this.position.setPositionContext({...t,trIndex:F.trIndex,tdIndex:F.tdIndex});const S=F.value.length-1;this.range.setRange(S,S),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:i,trIndex:n}=t,o=this.draw.getOriginalElementList()[e],a=o.trList,s=a[n],c=s.tdList[i];if(c.rowspan===1&&c.colspan===1)return;const h=c.colspan;if(c.colspan>1){for(let u=1;u<c.colspan;u++){const g=pt();s.tdList.splice(i+u,0,{id:g,rowspan:1,colspan:1,value:[{value:Y,size:16,tableId:o.id,trId:s.id,tdId:g}]})}c.colspan=1}if(c.rowspan>1){for(let u=1;u<c.rowspan;u++){const g=a[n+u];for(let p=0;p<h;p++){const f=pt();g.tdList.splice(c.colIndex,0,{id:f,rowspan:1,colspan:1,value:[{value:Y,size:16,tableId:o.id,trId:g.id,tdId:f}]})}}c.rowspan=1}const d=c.value.length-1;this.range.setRange(d,d),this.draw.render(),this.tableTool.render()}splitVerticalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:i,tdIndex:n,trIndex:r}=t,a=this.draw.getOriginalElementList()[i],s=a.trList,c=s[r],h=c.tdList[n];a.colgroup.splice(n+1,0,{width:this.options.table.defaultColMinWidth});for(let d=0;d<s.length;d++){const u=s[d];let g=0;for(;g<u.tdList.length;){const p=u.tdList[g];if(p.rowIndex!==h.rowIndex)p.colIndex<=h.colIndex&&p.colIndex+p.colspan>h.colIndex&&p.colspan++;else if(p.id===h.id){const f=pt();c.tdList.splice(g+h.colspan,0,{id:f,rowspan:h.rowspan,colspan:1,value:[{value:Y,size:16,tableId:a.id,trId:u.id,tdId:f}]}),g++}g++}}this.draw.render(),this.tableTool.render()}splitHorizontalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:i,tdIndex:n,trIndex:r}=t,a=this.draw.getOriginalElementList()[i],s=a.trList,h=s[r].tdList[n];let d=-1,u=0;for(;u<s.length;){if(u===d){u++;continue}const g=s[u];let p=0;for(;p<g.tdList.length;){const f=g.tdList[p];if(f.id===h.id){const D=pt(),C=pt();s.splice(u+h.rowspan,0,{id:D,height:this.options.table.defaultTrMinHeight,tdList:[{id:C,rowspan:1,colspan:h.colspan,value:[{value:Y,size:16,tableId:a.id,trId:D,tdId:C}]}]}),d=u+h.rowspan}else f.rowIndex>=h.rowIndex&&f.rowIndex<h.rowIndex+h.rowspan&&f.rowIndex+f.rowspan>=h.rowIndex+h.rowspan&&f.rowspan++;p++}u++}this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let n=0;n<e.length;n++){const r=e[n];for(let o=0;o<r.length;o++){const a=r[o];!a||a.verticalAlign===t||!a.verticalAlign&&t===Wt.TOP||(a.verticalAlign=t)}}const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i})}tableBorderType(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i}=e,r=this.draw.getOriginalElementList()[i];if(!r.borderType&&t===Kt.ALL||r.borderType===t)return;if(r.borderType=t,t===Kt.EMPTY){const a=r.trList;if(a)for(let s=0;s<a.length;s++){const c=a[s];for(let h=0;h<c.tdList.length;h++){const d=c.tdList[h];d.borderTypes&&delete d.borderTypes,d.borderStyle&&delete d.borderStyle}}}const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o})}tableBorderColor(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i}=e,r=this.draw.getOriginalElementList()[i];if(!r.borderColor&&t===this.options.table.defaultBorderColor||r.borderColor===t)return;r.borderColor=t;const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o,isCompute:!1})}tableBorderWidth(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i}=e,r=this.draw.getOriginalElementList()[i],o=Number(t);if(!Number.isFinite(o))return;if(o<=0){if(r.borderWidth===void 0)return;delete r.borderWidth}else{if(r.borderWidth===o)return;r.borderWidth=o,r.borderExternalWidth!==void 0&&r.borderExternalWidth<=0&&delete r.borderExternalWidth,r.borderExternalWidth!==void 0&&r.borderExternalWidth===o&&delete r.borderExternalWidth}const{endIndex:a}=this.range.getRange();this.draw.render({curIndex:a,isCompute:!1})}tableBorderExternalWidth(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i}=e,r=this.draw.getOriginalElementList()[i],o=Number(t);if(!Number.isFinite(o))return;const a=r.borderWidth??1;if(o<=0||o===a){if(r.borderExternalWidth===void 0)return;delete r.borderExternalWidth}else{if(r.borderExternalWidth===o)return;r.borderExternalWidth=o}const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s,isCompute:!1})}tableTdBorderType(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i}=e,r=this.draw.getOriginalElementList()[i],o=this.tableParticle.getRangeRowCol();if(!o)return;const a=o.flat(),s=a.some(h=>{var d;return!((d=h.borderTypes)!=null&&d.includes(t))});a.forEach(h=>{h.borderTypes||(h.borderTypes=[]);const d=h.borderTypes.findIndex(u=>u===t);s?(~d||h.borderTypes.push(t),h.borderStyle||(h.borderStyle={}),h.borderStyle[t]={width:r.borderWidth??.5,color:r.borderColor||this.options.table.defaultBorderColor,style:r.borderType===Kt.DASH?"dashed":"solid"}):(~d&&h.borderTypes.splice(d,1),h.borderStyle&&h.borderStyle[t]&&(delete h.borderStyle[t],Object.keys(h.borderStyle).length||delete h.borderStyle)),h.borderTypes.length||delete h.borderTypes});const{endIndex:c}=this.range.getRange();this.draw.render({curIndex:c})}tableTdSlashType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const i=e.flat(),n=i.some(o=>{var a;return!((a=o.slashTypes)!=null&&a.includes(t))});i.forEach(o=>{o.slashTypes||(o.slashTypes=[]);const a=o.slashTypes.findIndex(s=>s===t);n?~a||o.slashTypes.push(t):~a&&o.slashTypes.splice(a,1),o.slashTypes.length||delete o.slashTypes});const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdBackgroundColor(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let n=0;n<e.length;n++){const r=e[n];for(let o=0;o<r.length;o++){const a=r[o];a.backgroundColor=t}}const{endIndex:i}=this.range.getRange();this.range.setRange(i,i),this.draw.render({isCompute:!1})}tableSelectAll(){const t=this.position.getPositionContext(),{index:e,tableId:i,isTable:n}=t;if(!n||!i)return;const{startIndex:r,endIndex:o}=this.range.getRange(),s=this.draw.getOriginalElementList()[e].trList,c=s.length-1,h=s[c].tdList.length-1;this.range.replaceRange({startIndex:r,endIndex:o,tableId:i,startTdIndex:0,endTdIndex:h,startTrIndex:0,endTrIndex:c}),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}class To{constructor(t){m(this,"draw");m(this,"zone");m(this,"range");m(this,"position");m(this,"areaInfoMap",new Map);this.draw=t,this.zone=t.getZone(),this.range=t.getRange(),this.position=t.getPosition()}getAreaInfo(){return this.areaInfoMap}getActiveAreaId(){if(!this.areaInfoMap.size)return null;const{startIndex:t}=this.range.getRange(),i=this.draw.getElementList()[t];return(i==null?void 0:i.areaId)||null}getActiveAreaInfo(){const t=this.getActiveAreaId();return t&&this.areaInfoMap.get(t)||null}isReadonly(){const t=this.getActiveAreaInfo();if(!(t!=null&&t.area))return!1;switch(t.area.mode){case Ht.EDIT:return!1;case Ht.READONLY:return!0;case Ht.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){this.zone.getZone()!==st.MAIN&&this.zone.setZone(st.MAIN),this.draw.getPosition().setPositionContext({isTable:!1});const{id:e,value:i,area:n,position:r}=t;if(r===ie.BEFORE)this.range.setRange(0,0);else{const s=this.draw.getOriginalMainElementList().length-1;this.range.setRange(s,s)}const o=e||pt();return this.draw.insertElementList([{type:R.AREA,value:"",areaId:o,valueList:i,area:bt(n)}]),o}render(t,e){if(!this.areaInfoMap.size)return;t.save();const i=this.draw.getMargins(),n=this.draw.getInnerWidth();for(const r of this.areaInfoMap){const{area:o,positionList:a}=r[1];if(o!=null&&o.hide||!(o!=null&&o.backgroundColor)&&!(o!=null&&o.borderColor)&&!(o!=null&&o.placeholder))continue;const s=a.filter(p=>p.pageNo===e);if(!s.length)continue;t.translate(.5,.5);const c=s[0],h=s[s.length-1],d=i[3],u=Math.ceil(c.coordinate.leftTop[1]),g=Math.ceil(h.coordinate.rightBottom[1]-u);o.backgroundColor&&(t.fillStyle=o.backgroundColor,t.fillRect(d,u,n,g)),o.borderColor&&(t.strokeStyle=o.borderColor,t.strokeRect(d,u,n,g)),o.placeholder&&a.length<=1&&new Ni(this.draw).render(t,{placeholder:{...Zi,...o.placeholder},startY:c.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let i=0;i<t.length;i++){const n=t[i],r=n.areaId;if(r){const o=this.areaInfoMap.get(r);o?(o.elementList.push(n),o.positionList.push(e[i])):this.areaInfoMap.set(r,{id:r,area:n.area,elementList:[n],positionList:[e[i]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const i=this.areaInfoMap.get(e);return i?{area:i.area,id:i.id,startPageNo:i.positionList[0].pageNo,endPageNo:i.positionList[i.positionList.length-1].pageNo,value:Et(i.elementList)}:null}getContextByAreaId(t,e){var n,r,o;const i=this.draw.getOriginalMainElementList();for(let a=0;a<i.length;a++){const s=i[a];if((e==null?void 0:e.position)===ie.OUTER_BEFORE){if(((n=i[a+1])==null?void 0:n.areaId)!==t)continue}else if((e==null?void 0:e.position)===ie.AFTER){if(!(s.areaId===t&&((r=i[a+1])==null?void 0:r.areaId)!==t))continue}else if((e==null?void 0:e.position)===ie.OUTER_AFTER){if(!(s.areaId!==t&&((o=i[a-1])==null?void 0:o.areaId)===t))continue}else if(s.areaId!==t)continue;const c=this.position.getOriginalMainPositionList();return{range:{startIndex:a,endIndex:a},elementPosition:c[a]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const i=this.areaInfoMap.get(e);if(!i)return;i.area||(i.area={});let n=!1;const r=["top","hide"];Object.entries(t.properties).forEach(([o,a])=>{if(tn(a))return;const s=o;i.area[s]=a,r.includes(s)&&(n=!0)}),this.draw.render({isCompute:n,isSetCursor:!1})}}class bo{constructor(t){m(this,"draw");m(this,"options");m(this,"imageCache");m(this,"mainBadge");m(this,"areaBadgeMap");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,i,n,r,o){if(this.imageCache.has(o)){const a=this.imageCache.get(o);t.drawImage(a,e,i,n,r)}else{const a=new Image;a.setAttribute("crossOrigin","Anonymous"),a.src=o,a.onload=()=>{this.imageCache.set(o,a),t.drawImage(a,e,i,n,r)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:i,badge:n}=this.options,{left:r,top:o,width:a,height:s,value:c}=this.mainBadge,h=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),d=(r||n.left)*i,u=(o||n.top)*i+h;this._drawImage(t,d,u,a*i,s*i,c)}if(this.areaBadgeMap.size){const i=this.draw.getArea().getAreaInfo();if(i.size){const{scale:n,badge:r}=this.options;for(const o of i){const{positionList:a}=o[1],s=a[0];if(s.pageNo!==e)continue;const c=this.areaBadgeMap.get(o[0]);if(!c)continue;const{left:h,top:d,width:u,height:g,value:p}=c,f=(h||r.left)*n,D=(d||r.top)*n+s.coordinate.leftTop[1];this._drawImage(t,f,D,u*n,g*n,p)}}}}}class el{constructor(t,e,i,n,r,o){m(this,"container");m(this,"pageContainer");m(this,"pageList");m(this,"ctxList");m(this,"pageNo");m(this,"renderCount");m(this,"pagePixelRatio");m(this,"mode");m(this,"options");m(this,"position");m(this,"zone");m(this,"elementList");m(this,"listener");m(this,"eventBus");m(this,"override");m(this,"i18n");m(this,"canvasEvent");m(this,"globalEvent");m(this,"cursor");m(this,"range");m(this,"margin");m(this,"background");m(this,"badge");m(this,"search");m(this,"group");m(this,"area");m(this,"underline");m(this,"strikeout");m(this,"highlight");m(this,"paragraphColor");m(this,"historyManager");m(this,"previewer");m(this,"imageParticle");m(this,"laTexParticle");m(this,"textParticle");m(this,"tableParticle");m(this,"tableTool");m(this,"tableOperate");m(this,"pageNumber");m(this,"lineNumber");m(this,"waterMark");m(this,"placeholder");m(this,"header");m(this,"footer");m(this,"hyperlinkParticle");m(this,"dateParticle");m(this,"separatorParticle");m(this,"pageBreakParticle");m(this,"superscriptParticle");m(this,"subscriptParticle");m(this,"checkboxParticle");m(this,"radioParticle");m(this,"blockParticle");m(this,"listParticle");m(this,"lineBreakParticle");m(this,"control");m(this,"pageBorder");m(this,"revisionOverlay");m(this,"commentOverlay");m(this,"workerManager");m(this,"scrollObserver");m(this,"selectionObserver");m(this,"imageObserver");m(this,"mouseObserver");m(this,"LETTER_REG");m(this,"WORD_LIKE_REG");m(this,"rowList");m(this,"pageRowList");m(this,"painterStyle");m(this,"painterOptions");m(this,"visiblePageNoList");m(this,"intersectionPageNo");m(this,"lazyRenderIntersectionObserver");m(this,"printModeData");m(this,"_register",null);m(this,"HEADER_DEFAULT_SIZE",10);this._normalizeHeaderElementList(i.header),this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.renderCount=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=i.main,this.listener=n,this.eventBus=r,this.override=o,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new hn(e.locale),this.historyManager=new an(this),this.position=new Sn(this),this.zone=new mo(this),this.range=new jr(this),this.margin=new Vn(this),this.background=new Wn(this),this.badge=new bo(this),this.search=new Gn(this),this.group=new Io(this),this.area=new To(this),this.underline=new Yn(this),this.strikeout=new Kn(this),this.highlight=new $n(this),this.paragraphColor=new Un,this.previewer=new go(this),this.imageParticle=new jn(this),this.laTexParticle=new un(this),this.textParticle=new se(this),this.tableParticle=new Qn(this),this.tableTool=new Jn(this),this.tableOperate=new vo(this),this.pageNumber=new we(this),this.lineNumber=new Lo(this),this.waterMark=new ro(this),this.placeholder=new Ni(this),this.header=new eo(this,i.header),this.footer=new Do(this,i.footer),this.hyperlinkParticle=new to(this),this.dateParticle=new gn(this),this.separatorParticle=new oo(this),this.pageBreakParticle=new so(this),this.superscriptParticle=new io,this.subscriptParticle=new no,this.checkboxParticle=new ho(this),this.radioParticle=new uo(this),this.blockParticle=new pn(this),this.listParticle=new Co(this),this.lineBreakParticle=new Ae(this),this.control=new co(this),this.pageBorder=new wo(this),this.revisionOverlay=null,this.scrollObserver=new Zn(this),this.selectionObserver=new qn(this),this.imageObserver=new po,this.mouseObserver=new Eo(this),this.canvasEvent=new Pn(this),this.cursor=new Ln(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new An(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new cn(this),new dn(this);const{letterClass:a}=e;this.LETTER_REG=new RegExp(`[${a.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${a.map(s=>`[^${s}][${s}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.mode===at.PRINT&&this.setPrintData(),this.render({isInit:!0,isSetCursor:!1,isFirstRender:!0})}setPrintData(){this.printModeData={header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()};const t=bt(this.printModeData);["header","main","footer"].forEach(i=>{t[i]=this.control.filterAssistElement(t[i])}),this.setEditorData(t)}clearPrintData(){this.printModeData&&(this.setEditorData(this.printModeData),this.printModeData=null)}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}setRegister(t){this._register=t}getRegister(){return this._register}setMode(t){this.mode!==t&&(t===at.PRINT&&this.setPrintData(),this.mode===at.PRINT&&this.clearPrintData(),this.clearSideEffect(),this.range.clearRange(),this.mode=t,this.options.mode=t,this.render({isSetCursor:!1,isSubmitHistory:!1}))}isReadonly(){var t,e;if((e=(t=this.area.getActiveAreaInfo())==null?void 0:t.area)!=null&&e.mode)return this.area.isReadonly();switch(this.mode){case at.DESIGN:return!1;case at.READONLY:case at.PRINT:return!0;case at.FORM:return!this.control.getIsRangeWithinControl();default:return!1}}isDisabled(){var r,o,a,s,c;if(this.mode===at.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),i=this.getElementList();if((r=this.getTd())!=null&&r.disabled)return!0;if(t===e){const h=i[t],d=i[t+1];return!!((o=h==null?void 0:h.title)!=null&&o.disabled&&((a=d==null?void 0:d.title)!=null&&a.disabled)&&h.titleId===d.titleId||(s=h==null?void 0:h.control)!=null&&s.disabled&&((c=d==null?void 0:d.control)!=null&&c.disabled)&&h.controlId===d.controlId)}return i.slice(t+1,e+1).some(h=>{var d,u;return((d=h.title)==null?void 0:d.disabled)||((u=h.control)==null?void 0:u.disabled)})}isDesignMode(){return this.mode===at.DESIGN}isPrintMode(){return this.mode===at.PRINT}getOriginalWidth(){const{paperDirection:t,width:e,height:i}=this.options;return t===Ne.VERTICAL?e:i}getOriginalHeight(){const{paperDirection:t,width:e,height:i}=this.options;return t===Ne.VERTICAL?i:e}getWidth(){return Math.floor(this.getOriginalWidth()*this.options.scale)}getHeight(){return Math.floor(this.getOriginalHeight()*this.options.scale)}getMainHeight(){return this.getHeight()-this.getMainOuterHeight()}getMainOuterHeight(){const t=this.getMargins(),e=this.header.getExtraHeight(),i=this.footer.getExtraHeight();return t[0]+t[2]+e+i}getCanvasWidth(t=-1){return this.getPage(t).width}getCanvasHeight(t=-1){return this.getPage(t).height}getInnerWidth(){const t=this.getWidth(),e=this.getMargins();return t-e[1]-e[3]}getOriginalInnerWidth(){const t=this.getOriginalWidth(),e=this.getOriginalMargins();return t-e[1]-e[3]}getContextInnerWidth(){const t=this.position.getPositionContext();if(t.isTable){const{index:e,trIndex:i,tdIndex:n}=t,o=this.getOriginalElementList()[e].trList[i].tdList[n],a=this.getTdPadding();return o.width-a[1]-a[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===Ne.VERTICAL?t:[t[1],t[2],t[3],t[0]]}getPageGap(){return this.options.pageGap*this.options.scale}getOriginalPageGap(){return this.options.pageGap}getPageNumberBottom(){const{pageNumber:{bottom:t},scale:e}=this.options;return t*e}getMarginIndicatorSize(){return this.options.marginIndicatorSize*this.options.scale}getDefaultBasicRowMarginHeight(){return this.options.defaultBasicRowMarginHeight*this.options.scale}getHighlightMarginHeight(){return this.options.highlightMarginHeight*this.options.scale}getTdPadding(){var n,r,o;const{table:{tdPadding:t},scale:e}=this.options,i=this.position.getPositionContext();if(i.isTable){const{index:a,trIndex:s,tdIndex:c}=i,d=this.getOriginalElementList()[a],u=(o=(r=(n=d.trList)==null?void 0:n[s])==null?void 0:r.tdList)==null?void 0:o[c];return((u==null?void 0:u.padding)||d.tdPadding||t).map(p=>p*e)}return t.map(a=>a*e)}getContainer(){return this.container}getPageContainer(){return this.pageContainer}getVisiblePageNoList(){return this.visiblePageNoList}setVisiblePageNoList(t){this.visiblePageNoList=t,this.listener.visiblePageNoListChange&&this.listener.visiblePageNoListChange(this.visiblePageNoList),this.eventBus.hasSubscribers("visiblePageNoListChange")&&this.eventBus.emit("visiblePageNoListChange",this.visiblePageNoList)}getIntersectionPageNo(){return this.intersectionPageNo}setIntersectionPageNo(t){this.intersectionPageNo=t,this.listener.intersectionPageNoChange&&this.listener.intersectionPageNoChange(this.intersectionPageNo),this.eventBus.hasSubscribers("intersectionPageNoChange")&&this.eventBus.emit("intersectionPageNoChange",this.intersectionPageNo)}getPageNo(){return this.pageNo}setPageNo(t){this.pageNo=t}getRenderCount(){return this.renderCount}getPage(t=-1){return this.pageList[~t?t:this.pageNo]}getPageList(){return this.pageList}getPageCount(){return this.pageList.length}getTableRowList(t){const e=this.position.getPositionContext(),{index:i,trIndex:n,tdIndex:r}=e;return t[i].trList[n].tdList[r].rowList}getOriginalRowList(){const t=this.getZone();return t.isHeaderActive()?this.header.getRowList():t.isFooterActive()?this.footer.getRowList():this.rowList}getRowList(){return this.position.getPositionContext().isTable?this.getTableRowList(this.getOriginalElementList()):this.getOriginalRowList()}getPageRowList(){return this.pageRowList}getCtx(){return this.ctxList[this.pageNo]}getOptions(){return this.options}getSearch(){return this.search}getGroup(){return this.group}getArea(){return this.area}getBadge(){return this.badge}getHistoryManager(){return this.historyManager}setHistoryManager(t){this.historyManager=t}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getLineBreakParticle(){return this.lineBreakParticle}getTextParticle(){return this.textParticle}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){var o;const e=this.position.getPositionContext(),{index:i,trIndex:n,tdIndex:r}=e;return((o=t[i].trList)==null?void 0:o[n].tdList[r].value)||[]}getElementList(){const t=this.position.getPositionContext(),e=this.getOriginalElementList();return t.isTable?this.getTableElementList(e):e}getMainElementList(){return this.position.getPositionContext().isTable?this.getTableElementList(this.elementList):this.elementList}getOriginalElementList(){const t=this.getZone();return t.isHeaderActive()?this.getHeaderElementList():t.isFooterActive()?this.getFooterElementList():this.elementList}getOriginalMainElementList(){return this.elementList}getFooterElementList(){return this.footer.getElementList()}getTd(){const t=this.position.getPositionContext(),{index:e,trIndex:i,tdIndex:n,isTable:r}=t;return r?this.getOriginalElementList()[e].trList[i].tdList[n]:null}insertElementList(t,e={}){if(!t.length||!this.range.canInput())return;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return;const{isSubmitHistory:r=!0}=e;zt(t,{isHandleFirstElement:!1,editorOptions:this.options});let o=-1,a=this.control.getActiveControl();if(!a&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),a=this.control.getActiveControl()),a&&this.control.getIsRangeWithinControl())o=a.setValue(t,void 0,{isIgnoreDisabledRule:!0}),this.control.emitControlContentChange();else{const s=this.getElementList(),c=i===n,h=i+1;c||this.spliceElementList(s,h,n-i),this.spliceElementList(s,h,0,t),o=i+t.length;const d=s[h-1];t[0].listId&&d&&!d.listId&&(d==null?void 0:d.value)===Y&&(!d.type||d.type===R.TEXT)&&(s.splice(i,1),o-=1)}~o&&(this.range.setRange(o,o),this.render({curIndex:o,isSubmitHistory:r}))}appendElementList(t,e={}){if(!t.length)return;zt(t,{isHandleFirstElement:!1,editorOptions:this.options});let i;const{isPrepend:n,isSubmitHistory:r=!0}=e;n?(this.elementList.splice(1,0,...t),i=t.length):(this.elementList.push(...t),i=this.elementList.length-1),this.range.setRange(i,i),this.render({curIndex:i,isSubmitHistory:r})}spliceElementList(t,e,i,n,r){var c,h,d,u,g,p,f,D;const{isIgnoreDeletedRule:o=!1}=r||{},{group:a,modeRule:s}=this.options;if(i>0){const C=e+i,I=t[C],E=I==null?void 0:I.listId;if(E&&((c=t[e-1])==null?void 0:c.listId)!==E){let w=C;for(;w<t.length;){const v=t[w];if(v.listId!==E||v.value===Y)break;delete v.listId,delete v.listType,delete v.listStyle,w++}}if(!o&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const w=(h=this.getTd())==null?void 0:h.deletable;let v=C-1;for(;v>=e;){const L=t[v];((d=L==null?void 0:L.control)!=null&&d.hide||(u=L==null?void 0:L.area)!=null&&u.hide||w!==!1&&((g=L==null?void 0:L.control)==null?void 0:g.deletable)!==!1&&(!L.controlId||this.mode!==at.FORM||!s[this.mode].controlDeletableDisabled)&&((p=L==null?void 0:L.title)==null?void 0:p.deletable)!==!1&&(a.deletable!==!1||!((f=L.groupIds)!=null&&f.length))&&(((D=L==null?void 0:L.area)==null?void 0:D.deletable)!==!1||(L==null?void 0:L.areaIndex)!==0))&&t.splice(v,1),v--}}else t.splice(e,i)}if(n!=null&&n.length)for(let C=0;C<n.length;C++)t.splice(e+C,0,n[C])}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}initRevisionOverlay(t){this.revisionOverlay||(this.revisionOverlay={update:()=>{}}),this.revisionOverlay.update()}setRevisionOverlay(t){this.revisionOverlay=t}setCommentOverlay(t){this.commentOverlay=t}destroyRevisionOverlay(){this.revisionOverlay&&(this.revisionOverlay.destroy(),this.revisionOverlay=null,this.commentOverlay=null)}getRevisionOverlay(){return this.revisionOverlay}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}getLaTexParticle(){return this.laTexParticle}setLaTexParticle(t){this.laTexParticle=t}getBlockParticle(){return this.blockParticle}setBlockParticle(t){this.blockParticle=t}getTableTool(){return this.tableTool}getTableOperate(){return this.tableOperate}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getDateParticle(){return this.dateParticle}setDateParticle(t){this.dateParticle=t}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getControl(){return this.control}setControl(t){this.control=t}getWorkerManager(){return this.workerManager}setWorkerManager(t){this.workerManager=t}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:i}=t;e&&this.setPagePixelRatio(e);const n=this.mode,r=!!i&&n!==i;r&&this.setMode(i),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const o=this.pageList.map(a=>a.toDataURL());return e&&this.setPagePixelRatio(null),r&&this.setMode(n),o}getPainterStyle(){return this.painterStyle&&Object.keys(this.painterStyle).length?this.painterStyle:null}getPainterOptions(){return this.painterOptions}setPainterStyle(t,e){this.painterStyle=t,this.painterOptions=e||null,this.getPainterStyle()&&this.pageList.forEach(i=>i.style.cursor="copy")}setDefaultRange(){this.elementList.length&&setTimeout(()=>{const t=this.elementList.length-1;this.range.setRange(t,t),this.range.setRangeStyle()})}getIsPagingMode(){return this.options.pageMode===Le.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===Le.PAGING){const{height:n}=this.options,r=this.getPagePixelRatio(),o=this.pageList[0];o.style.height=`${n}px`,o.height=n*r,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(st.MAIN);const{startIndex:e}=this.range.getRange(),i=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),i||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.hasSubscribers("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const i=this.getWidth(),n=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((o,a)=>{o.width=i*e,o.height=n*e,o.style.width=`${i}px`,o.style.height=`${n}px`,o.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[a])});const r=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!r,curIndex:r==null?void 0:r.index}),this.listener.pageScaleChange&&this.listener.pageScaleChange(t),this.eventBus.hasSubscribers("pageScaleChange")&&this.eventBus.emit("pageScaleChange",t)}getPagePixelRatio(){return this.pagePixelRatio||window.devicePixelRatio}setPagePixelRatio(t){!this.pagePixelRatio&&t===window.devicePixelRatio||t===this.pagePixelRatio||(this.pagePixelRatio=t,this.setPageDevicePixel())}setPageDevicePixel(){const t=this.getPagePixelRatio(),e=this.getWidth(),i=this.getHeight();this.pageList.forEach((n,r)=>{n.width=e*t,n.height=i*t,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const i=this.getPagePixelRatio(),n=this.getWidth(),r=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((o,a)=>{o.width=n*i,o.height=r*i,o.style.width=`${n}px`,o.style.height=`${r}px`,this._initPageContext(this.ctxList[a])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const i=this.getWidth(),n=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((r,o)=>{r.width=i*e,r.height=n*e,r.style.width=`${i}px`,r.style.height=`${n}px`,this._initPageContext(this.ctxList[o])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getOriginValue(t={}){const{pageNo:e}=t;let i=this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(i=this.pageRowList[e].flatMap(r=>r.elementList)),{header:this.getHeaderElementList(),main:i,footer:this.getFooterElementList()}}getValue(t={}){const e=this.getOriginValue(t),{extraPickAttrs:i}=t,n={header:Et(e.header,{extraPickAttrs:i}),main:Et(e.main,{extraPickAttrs:i,isClassifyArea:!0}),footer:Et(e.footer,{extraPickAttrs:i})};return{dataVersion:Ho,schemaVersion:ln,data:n,options:bt(this.options)}}setValue(t,e){const{header:i,main:n,footer:r}=bt(t);if(!i&&!n&&!r)return;const{isSetCursor:o=!1}=e||{};[i,n,r].forEach(c=>{c&&zt(c,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:i,main:n,footer:r}),this.historyManager.recovery();const s=o?n!=null&&n.length?n.length-1:0:void 0;s!==void 0&&this.range.setRange(s,s),this.render({curIndex:s,isSetCursor:o,isFirstRender:!0})}setEditorData(t){const{header:e,main:i,footer:n}=t;e&&(this._normalizeHeaderElementList(e),this.header.setElementList(e)),i&&(this.elementList=i),n&&this.footer.setElementList(n)}_normalizeHeaderElementList(t){const e=t==null?void 0:t[0];e&&e.value===Y&&e.size===void 0&&(e.size=this.HEADER_DEFAULT_SIZE)}_wrapContainer(t){const e=document.createElement("div");return t.append(e),e}_formatContainer(){this.container.style.position="relative",this.container.style.width=`${this.getWidth()}px`,this.container.setAttribute(Xe,ke.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${J}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),i=this.getHeight(),n=document.createElement("canvas");n.style.width=`${e}px`,n.style.height=`${i}px`,n.style.display="block",n.style.backgroundColor="#ffffff",n.style.marginBottom=`${this.getPageGap()}px`,n.setAttribute("data-index",String(t)),this.pageContainer.append(n);const r=this.getPagePixelRatio();n.width=e*r,n.height=i*r,n.style.cursor="text";const o=n.getContext("2d");this._initPageContext(o),this.pageList.push(n),this.ctxList.push(o)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}getElementFont(t,e=1){const{defaultSize:i,defaultFont:n}=this.options,o=(s=>{const c=(s||"").trim();return c&&(/^fangsong/i.test(c)||/仿宋/i.test(c)?'FangSong,"FangSong_GB2312","仿宋",SimSun,"宋体",serif':/^kaiti/i.test(c)||/楷体/i.test(c)?'KaiTi,"KaiTi_GB2312","楷体",SimSun,"宋体",serif':/^simsun/i.test(c)||/宋体/i.test(c)?'SimSun,"宋体",serif':/^simhei/i.test(c)||/黑体/i.test(c)?'SimHei,"黑体",sans-serif':/microsoft yahei|微软雅黑/i.test(c)?'Microsoft YaHei,"微软雅黑","Microsoft YaHei UI","微软雅黑 UI",sans-serif':/microsoft jhenghei|微軟正黑體/i.test(c)?'Microsoft JhengHei,"微軟正黑體",sans-serif':/^stxinwei/i.test(c)||/华文新魏/i.test(c)?'"STXinwei","华文新魏",serif':c)})(t.font||n),a=t.actualSize||t.size||i;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${a*e}px ${o}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){const{defaultBasicRowMarginHeight:e,defaultRowMargin:i,scale:n}=this.options;return e*(t.rowMargin??i)*n}isPageBreakElement(t){return(t==null?void 0:t.type)===R.PAGE_BREAK}shouldForceWrapRow(t,e){var i,n,r;return t.type===R.SEPARATOR||this.isPageBreakElement(t)||Ve(t)||this.isPageBreakElement(e)||e&&Ve(e)||(e==null?void 0:e.type)===R.BLOCK||t.type===R.BLOCK||(e==null?void 0:e.listId)!==t.listId||(e==null?void 0:e.areaId)!==t.areaId&&!((i=t.area)!=null&&i.hide)||((n=t.control)==null?void 0:n.flexDirection)===Xi.COLUMN&&(t.controlComponent===b.CHECKBOX||t.controlComponent===b.RADIO)&&(e==null?void 0:e.controlComponent)===b.VALUE||t.value===Y&&!((r=t.area)!=null&&r.hide)}normalizeSpecialRow(t){t.isPageBreak&&(t.height=0,t.ascent=0)}shouldDrawLineBreakForRow(t,e,i,n){return i&&!n&&this.mode!==at.CLEAN&&!t.isWidthNotEnough&&!t.isPageBreak&&e===t.elementList.length-1}computeRowList(t){var _,A,y,N,k,z,O,W,V,U,it,Z,tt,nt,Mt;const{innerWidth:e,elementList:i,isPagingMode:n=!1,isFromTable:r=!1,startX:o=0,startY:a=0,pageHeight:s=0,mainOuterHeight:c=0,surroundElementList:h=[]}=t,{defaultSize:d,defaultRowMargin:u,scale:g,table:{tdPadding:p,defaultTrMinHeight:f},defaultTabWidth:D}=this.options,C=this.getDefaultBasicRowMarginHeight();let I;typeof OffscreenCanvas<"u"?I=new OffscreenCanvas(1,1).getContext("2d"):I=document.createElement("canvas").getContext("2d");const E=this.listParticle.computeListStyle(I,i),w=[];i.length&&w.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:((_=i==null?void 0:i[0])==null?void 0:_.rowFlex)||((A=i==null?void 0:i[1])==null?void 0:A.rowFlex)});let v=o,L=a,T=0,x,B=0,F=0,M=0,P=!0,S=0;for(let j=0;j<i.length;j++){const G=w[w.length-1],H=i[j];if(H.columnId&&H.columnCount&&H.columnCount>=2){const rt=H.columnId,q=H.columnCount,ft=(H.columnGap||0)*g,xt=H.columnSeparator||!1,$t=H.columnWidths||[],De=[];let He=j+1;for(;He<i.length;){const et=i[He];if(!et.columnId||et.columnId!==rt)break;De.push(et),He++}const he=[[]];for(const et of De)et.type===R.COLUMN_BREAK?he.length<q&&he.push([]):he[he.length-1].push(et);const dt=[];if($t.length>=q)for(let et=0;et<q;et++)dt.push($t[et]*g);else{const et=ft*(q-1),ut=(e-et)/q;for(let mt=0;mt<q;mt++)dt.push(ut)}const Dt=[];let ct=0;for(let et=0;et<q;et++){const ut=he[et]||[];if(ut.length===0){Dt.push([]);continue}const mt=this.computeRowList({innerWidth:dt[et],elementList:ut,isFromTable:r,isPagingMode:n,columnContext:{columnId:rt,columnIndex:et,totalColumns:q}});Dt.push(mt);const Ct=mt.reduce((yt,vt)=>yt+vt.height,0);Ct>ct&&(ct=Ct)}const ot={width:e,height:ct,ascent:0,startIndex:j,elementList:[],rowIndex:G.rowIndex+(G.elementList.length>0?1:0),isColumnContainer:!0,columnRowLists:Dt,columnWidths:dt,columnGap:ft,columnSeparator:xt};G.elementList.length<=1?w[w.length-1]=ot:w.push(ot),j=He,j<i.length&&w.push({width:0,height:0,ascent:0,elementList:[],startIndex:j,rowIndex:ot.rowIndex+1});continue}H.paragraphFirstLineIndent!==void 0&&(F=H.paragraphFirstLineIndent),H.paragraphIndentLeft!==void 0&&(M=H.paragraphIndentLeft);const ht=(H.paragraphSpacingBefore||0)*g,Pt=(H.paragraphSpacingAfter||0)*g,_t=C*(H.rowMargin??u),re=_t+ht,me=_t+Pt,$={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},le=H.listId&&E.get(H.listId)||0,ae=H.listId?((H.listIndent??(H.listLevel||0)*D)||0)*g:0,ce=M*g;if(G.offsetX===void 0&&(le||ce||F)){const rt=!!H.listId,q=rt?0:Math.max(0,P?F:0);G.offsetX=le+ae+ce+(P?q:0),P&&!rt&&(P=!1)}H.listId&&(G.isList=!0,G.listIndex===void 0&&(G.listIndex=B));const Oe=G.offsetX||0,Bt=e-Oe,xo=G.elementList.length===1;if(v+=xo?Oe:0,L+=xo&&G.offsetY||0,((y=H.control)!=null&&y.hide||(N=H.area)!=null&&N.hide)&&!this.isDesignMode())$.height=((k=G.elementList[G.elementList.length-1])==null?void 0:k.metrics.height)||this.options.defaultSize*g;else if(H.revisionType==="delete")$.width=0,$.height=0,$.boundingBoxAscent=0,$.boundingBoxDescent=0;else if(Ge(H)||H.type===R.LATEX){if(H.imgDisplay===Q.SURROUND||H.imgDisplay===Q.FLOAT_TOP||H.imgDisplay===Q.FLOAT_BOTTOM)$.width=0,$.height=0,$.boundingBoxDescent=0;else{const rt=H.width*g,q=H.height*g;if(rt>Bt){const ft=q*Bt/rt;H.width=Bt/g,H.height=ft/g,$.width=Bt,$.height=ft,$.boundingBoxDescent=ft}else $.width=rt,$.height=q,$.boundingBoxDescent=q}$.boundingBoxAscent=0}else if(Ve(H)){const rt=H.tdPadding||p;if(H.pagingId){let dt=j+1,Dt=0;for(;dt<i.length;){const ct=i[dt];if(ct.pagingId===H.pagingId){const ot=ct.trList.filter(et=>!et.pagingRepeat);H.trList.push(...ot),H.height+=ct.height,dt++,Dt++}else break}Dt&&i.splice(j+1,Dt)}H.pagingIndex=H.pagingIndex??0;const q=H.trList,ft=dt=>{let Dt=d,ct=(rt[0]||0)+(rt[2]||0);for(let ot=0;ot<dt.tdList.length;ot++){const et=dt.tdList[ot],ut=et.padding||rt,mt=(ut[0]||0)+(ut[2]||0);mt>ct&&(ct=mt);const Ct=et.value||[];for(let yt=0;yt<Ct.length;yt++){const vt=Ct[yt];if(!vt||vt.value===Y||vt.value===`
39
+ `)continue;const Ut=vt.actualSize||vt.size||d;Ut>Dt&&(Dt=Ut)}}return Math.ceil(Dt*1.4+ct)};for(let dt=0;dt<q.length;dt++){const Dt=q[dt],{defaultTrHeight:ct}=this.options.table,ot=Number(ct),et=Number.isFinite(ot)&&ot>0,ut=Math.max(f,et?ot:0,ft(Dt)),mt=Number(Dt.height),Ct=Number.isFinite(mt)&&mt>0,yt=Dt.minHeight??(Ct?mt:ut);Dt.height=Math.max(f,yt),Dt.minHeight=Dt.height}this.tableParticle.computeRowColInfo(H);for(let dt=0;dt<q.length;dt++){const Dt=q[dt];for(let ct=0;ct<Dt.tdList.length;ct++){const ot=Dt.tdList[ct],et=ot.padding||rt,ut=et[1]+et[3],mt=et[0]+et[2],Ct=this.computeRowList({innerWidth:(ot.width-ut)*g,elementList:ot.value,isFromTable:!0,isPagingMode:n}),yt=Ct.reduce((Nt,de)=>Nt+de.height,0);ot.rowList=Ct;const vt=yt/g+mt;if(ot.height<vt){const Nt=vt-ot.height,de=q[dt+ot.rowspan-1];de.height+=Nt,de.tdList.forEach(qt=>{qt.height+=Nt,qt.realHeight?qt.realHeight+=Nt:qt.realHeight=qt.height})}let Ut=0,ee=0,Ce=0;for(;Ce<ot.rowspan;){const Nt=q[Ce+dt]||q[dt];Ut+=Nt.minHeight,ee+=Nt.height,Ce++}ot.realMinHeight=Ut,ot.realHeight=ee,ot.mainHeight=vt}}const xt=this.tableParticle.getTrListGroupByCol(q);for(let dt=0;dt<xt.length;dt++){const Dt=xt[dt];let ct=-1;for(let ot=0;ot<Dt.tdList.length;ot++){const et=Dt.tdList[ot],ut=et.realHeight,mt=et.mainHeight,Ct=et.realMinHeight,yt=mt<Ct?ut-Ct:ut-mt;(!~ct||yt<ct)&&(ct=yt)}if(ct>0){const ot=q[dt];ot.height-=ct,ot.tdList.forEach(et=>{et.height-=ct,et.realHeight-=ct})}}this.tableParticle.computeRowColInfo(H);const $t=this.tableParticle.getTableHeight(H),De=this.tableParticle.getTableWidth(H);H.width=De,H.height=$t;const He=De*g,he=$t*g;if($.width=He,$.height=he,$.boundingBoxDescent=he,$.boundingBoxAscent=-_t,((z=i[j+1])==null?void 0:z.type)===R.TABLE&&($.boundingBoxAscent-=_t),n){const dt=this.getHeight(),Dt=this.getMainOuterHeight();let ct=Dt;for(let ut=0;ut<w.length;ut++){const mt=w[ut],Ct=mt.offsetY||0;mt.height+ct+Ct>dt||(O=w[ut-1])!=null&&O.isPageBreak?ct=Dt+mt.height+Ct:ct+=mt.height+Ct}const ot=_t*2*g,et=H.trList[0].height*g;if((ct+et+ot>dt||H.pagingIndex!==0&&H.trList[0].pagingRepeat)&&(ct=Dt),ct+ot+he>dt){const ut=H.trList;let mt=0,Ct=0,yt=0;if(ut.length>1)for(let vt=0;vt<ut.length;vt++){const Ut=ut[vt],ee=Ut.height*g;if(ct+ot+yt+ee>dt){const Ce=Ut.tdList.reduce((Nt,de)=>Nt+de.colspan,0);((W=H.colgroup)==null?void 0:W.length)!==Ce&&(Ct=0);break}else mt=vt+1,Ct=ut.length-mt,yt+=ee}if(Ct){const vt=ut.splice(mt,Ct),Ut=vt.reduce((qt,zi)=>qt+zi.height,0),ee=Ut*g,Ce=H.pagingId||pt();H.pagingId=Ce,H.height-=Ut,$.height-=ee,$.boundingBoxDescent-=ee;const Nt=bt(H);Nt.pagingId=Ce,Nt.pagingIndex=H.pagingIndex+1;const de=ut.filter(qt=>qt.pagingRepeat);if(de.length){const qt=bt(de);qt.forEach(zi=>zi.id=pt()),vt.unshift(...qt)}Nt.trList=vt,Nt.id=pt(),this.spliceElementList(i,j+1,0,[Nt])}}if(H.pagingId){const ut=this.position.getPositionContext();if(ut.isTable){let mt=-1,Ct=-1,yt=j;for(;yt<i.length;){const vt=i[yt];if(vt.pagingId!==H.pagingId)break;const Ut=vt.trList.findIndex(ee=>ee.id===ut.trId);if(~Ut){mt=yt,Ct=Ut;break}yt++}~mt&&(ut.index=mt,ut.trIndex=Ct,this.position.setPositionContext(ut))}}}}else if(H.type===R.SEPARATOR){const{separator:{lineWidth:rt}}=this.options;H.width=Bt/g,$.width=Bt,$.height=Xn(H,rt)*g,$.boundingBoxAscent=-_t,$.boundingBoxDescent=-_t+$.height}else if(H.type===R.PAGE_BREAK)this.options.pageBreak.disabled?(H.width=0,$.width=0,$.height=d*g,$.boundingBoxAscent=d*g,$.boundingBoxDescent=0):(H.width=Bt/g,$.width=Bt,$.height=d);else if(H.type===R.RADIO||H.controlComponent===b.RADIO){const{width:rt,height:q,gap:ft}=this.options.radio,xt=rt+ft*2;H.width=xt,$.width=xt*g,$.height=q*g}else if(H.type===R.CHECKBOX||H.controlComponent===b.CHECKBOX){const{width:rt,height:q,gap:ft}=this.options.checkbox,xt=rt+ft*2;H.width=xt,$.width=xt*g,$.height=q*g}else if(H.type===R.TAB)$.width=D*g,$.height=d*g,$.boundingBoxDescent=0,$.boundingBoxAscent=$.height;else if(H.type===R.BLOCK){if(!H.width)$.width=Bt;else{const rt=H.width*g;$.width=Math.min(rt,Bt)}$.height=H.height*g,$.boundingBoxDescent=$.height,$.boundingBoxAscent=0}else{const rt=H.size||d;(H.type===R.SUPERSCRIPT||H.type===R.SUBSCRIPT)&&(H.actualSize=Math.ceil(rt*.6)),$.height=(H.actualSize||rt)*g,I.font=this.getElementFont(H);const q=this.textParticle.measureText(I,H),ft=se.getCharacterScaleRatio(H.characterScale);$.width=q.width*g*ft,H.letterSpacing&&($.width+=H.letterSpacing*g),$.boundingBoxAscent=(H.value===Y?H.size||d:q.actualBoundingBoxAscent)*g,$.boundingBoxDescent=q.actualBoundingBoxDescent*g,H.type===R.SUPERSCRIPT?$.boundingBoxAscent+=$.height/2:H.type===R.SUBSCRIPT&&($.boundingBoxDescent+=$.height/2)}const yo=H.lineHeight??this.options.defaultLineHeight,Ro=Ge(H)||H.type===R.LATEX?$.height+re:$.boundingBoxAscent+re+($.boundingBoxAscent+$.boundingBoxDescent)*(yo-1)/2,Be=re+($.boundingBoxAscent+$.boundingBoxDescent)*yo+me,Zt=Object.assign(H,{metrics:$,left:0,style:this.getElementFont(H,g)});(V=Zt.control)!=null&&V.minWidth&&(Zt.controlComponent&&(S+=$.width),Zt.controlComponent===b.POSTFIX&&(this.control.setMinWidthControlInfo({row:G,rowElement:Zt,availableWidth:Bt,controlRealWidth:S}),S=0));const kt=i[j-1];let Fo=i[j+1],di=G.width+$.width;if(this.options.wordBreak===ui.BREAK_WORD&&(!(kt!=null&&kt.type)||(kt==null?void 0:kt.type)===R.TEXT)&&(!H.type||H.type===R.TEXT)){const rt=`${(kt==null?void 0:kt.value)||""}${H.value}`;if(this.WORD_LIKE_REG.test(rt)){const{width:ft,endElement:xt}=this.textParticle.measureWord(I,i,j),$t=ft*g;$t<=Bt&&(di+=$t,Fo=xt)}const q=this.textParticle.measurePunctuationWidth(I,Fo);di+=q*g}H.listId&&(H.listId!==x?B=0:oi(H)&&B++),x=H.listId;const Po=this.position.setSurroundPosition({pageNo:T,rowElement:Zt,row:G,rowElementRect:{x:v,y:L,height:Be,width:$.width},availableWidth:Bt,surroundElementList:h});v=Po.x,di+=Po.rowIncreaseWidth,v+=$.width;const Ao=j!==0&&this.shouldForceWrapRow(H,kt),So=di>Bt,Wi=Ao||So;if(Wi){const rt=()=>{var xt,$t,De;const ft=i[j];return(ft==null?void 0:ft.value)===Y?((xt=i[j+1])==null?void 0:xt.rowFlex)||(($t=i[j+2])==null?void 0:$t.rowFlex)||ft.rowFlex:(ft==null?void 0:ft.rowFlex)||((De=i[j+1])==null?void 0:De.rowFlex)},q={width:$.width,height:Be,startIndex:j,elementList:[Zt],ascent:Ro,rowIndex:G.rowIndex+1,rowFlex:rt(),isPageBreak:this.isPageBreakElement(H)};if(this.normalizeSpecialRow(q),Zt.controlComponent!==b.PREFIX&&((U=Zt.control)==null?void 0:U.indentation)===$i.VALUE_START){const ft=G.elementList.findIndex(xt=>xt.controlId===Zt.controlId&&xt.controlComponent!==b.PREFIX);if(~ft){const $t=this.position.computeRowPosition({row:G,innerWidth:this.getInnerWidth()})[ft];$t&&(q.offsetX=$t.coordinate.leftTop[0])}}H.listId&&(q.isList=!0,q.offsetX=(q.offsetX||0)+(E.get(H.listId)||0)+ae,q.listIndex=B),q.offsetY=!r&&((it=H.area)!=null&&it.top)&&H.areaId!==((Z=i[j-1])==null?void 0:Z.areaId)?H.area.top*g:0,w.push(q)}else G.width+=$.width,j===0&&(xe(i[1])||(tt=i[1])!=null&&tt.areaId)?(G.height=C,G.ascent=C):G.height<Be&&(G.height=Be,G.ascent=Ro),G.elementList.push(Zt);if((Wi||j===i.length-1)&&(G.isWidthNotEnough=So&&!Ao,!G.isSurround&&((kt==null?void 0:kt.rowFlex)===gt.JUSTIFY||(kt==null?void 0:kt.rowFlex)===gt.ALIGNMENT&&G.isWidthNotEnough))){const rt=((nt=G.elementList[0])==null?void 0:nt.value)===Y?G.elementList.slice(1):G.elementList,q=(Bt-G.width)/(rt.length-1);for(let ft=0;ft<rt.length-1;ft++){const xt=rt[ft];xt.metrics.width+=q}G.width=Bt}if(j!==0&&H.value===Y&&!((Mt=H.area)!=null&&Mt.hide)&&!H.listWrap&&(F=0,M=0,P=!0),Wi){v=o,L+=G.height,n&&!r&&s&&(L-a+c+Be>s||this.isPageBreakElement(H))&&(L=a,ur(h,T),T+=1),Zt.left=0;const rt=w[w.length-1];v=this.position.setSurroundPosition({pageNo:T,rowElement:Zt,row:rt,rowElementRect:{x:v,y:L,height:Be,width:$.width},availableWidth:Bt,surroundElementList:h}).x,v+=$.width}}return w}_computePageList(){var s;const t=[[]],{pageMode:e,pageNumber:{maxPageNo:i}}=this.options,n=this.getHeight(),r=this.getMainOuterHeight();let o=r,a=0;if(e===Le.CONTINUITY){t[0]=this.rowList,o+=this.rowList.reduce((u,g)=>u+g.height+(g.offsetY||0),0);const c=this.getPagePixelRatio(),h=this.pageList[0],d=Number(h.style.height.replace("px",""));if(o>d)h.style.height=`${o}px`,h.height=o*c;else{const u=o<n?n:o;h.style.height=`${u}px`,h.height=u*c}this._initPageContext(this.ctxList[0])}else for(let c=0;c<this.rowList.length;c++){const h=this.rowList[c],d=h.offsetY||0;if(h.height+d+o>n||(s=this.rowList[c-1])!=null&&s.isPageBreak){if(Number.isInteger(i)&&a>=i){this.elementList=this.elementList.slice(0,h.startIndex);break}o=r+h.height+d,t.push([h]),a++}else o+=h.height+d,t[a].push(h)}return t}_drawParagraphColor(t,e){const{rowList:i,positionList:n,innerWidth:r}=e,o=this.getMargins();for(let a=0;a<i.length;a++){const s=i[a],c=s.elementList[0],h=c==null?void 0:c.paragraphColor;if(!h)continue;const{coordinate:{leftTop:[,d]}}=n[s.startIndex],u=o[3];this.paragraphColor.recordFillInfo(t,u,d,r,s.height,h),this.paragraphColor.render(t)}}_drawHighlight(t,e){const{rowList:i,positionList:n,elementList:r}=e,o=this.getDefaultBasicRowMarginHeight(),a=this.getHighlightMarginHeight();for(let s=0;s<i.length;s++){const c=i[s];for(let h=0;h<c.elementList.length;h++){const d=c.elementList[h],u=c.elementList[h-1],g=d.highlight||this.control.getControlHighlight(r,c.startIndex+h);if(g){u&&u.highlight&&u.highlight!==d.highlight&&this.highlight.render(t);const{coordinate:{leftTop:[p,f]}}=n[c.startIndex+h],D=d.left||0;this.highlight.recordFillInfo(t,p-D,f+o-a,d.metrics.width+D,c.height-2*o+2*a,g)}else u!=null&&u.highlight&&this.highlight.render(t)}this.highlight.render(t)}}drawRow(t,e){var I,E,w,v,L,T,x,B,F;this._drawParagraphColor(t,e),this._drawHighlight(t,e);const{scale:i,table:{tdPadding:n},group:r,lineBreak:o}=this.options,{rowList:a,pageNo:s,elementList:c,positionList:h,startIndex:d,zone:u,isDrawLineBreak:g=!o.disabled}=e,p=this.mode===at.PRINT,{isCrossRowCol:f,tableId:D}=this.range.getRange();let C=d;for(let M=0;M<a.length;M++){const P=a[M];if(P.isColumnContainer&&P.columnRowLists){const{scale:A}=this.options,y=P.columnWidths||[],N=P.columnGap||0,k=P.columnSeparator||!1,z=h[P.startIndex],O=z?z.coordinate.leftTop[1]:0;let W=z?z.coordinate.leftTop[0]:0;for(let V=0;V<P.columnRowLists.length;V++){const U=P.columnRowLists[V];if(U.length>0){const it=[];this.position.computePageRowPosition({positionList:it,rowList:U,pageNo:s,startX:W,startY:O,startRowIndex:0,startIndex:0,innerWidth:y[V]||0});const Z=[];for(const tt of U)for(const nt of tt.elementList)Z.push(nt);this.drawRow(t,{elementList:Z,positionList:it,rowList:U,pageNo:s,startIndex:0,innerWidth:y[V]||0,zone:u})}if(k&&V<P.columnRowLists.length-1){const it=W+(y[V]||0)+N/2;t.save(),t.beginPath(),t.moveTo(it,O),t.lineTo(it,O+P.height),t.strokeStyle="#DCDFE6",t.lineWidth=.5*A,t.stroke(),t.restore()}W+=(y[V]||0)+N}continue}const S={x:0,y:0,width:0,height:0};let _=null;for(let A=0;A<P.elementList.length;A++){const y=P.elementList[A],N=y.metrics,{ascent:k,coordinate:{leftTop:[z,O]}}=h[P.startIndex+A],W=P.elementList[A-1];if(y.revisionType==="delete")this.textParticle.complete();else if(((I=y.control)!=null&&I.hide||(E=y.area)!=null&&E.hide)&&!this.isDesignMode())this.textParticle.complete();else if(y.type===R.IMAGE)this.textParticle.complete(),y.imgDisplay!==Q.SURROUND&&y.imgDisplay!==Q.FLOAT_TOP&&y.imgDisplay!==Q.FLOAT_BOTTOM&&this.imageParticle.render(t,y,z,O+k);else if(y.type===R.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,y,z,O+k);else if(y.type===R.TABLE)f&&(S.x=z,S.y=O,_=y),this.tableParticle.render(t,y,z,O);else if(y.type===R.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,y,z,O+k);else if(y.type===R.DATE){const Z=P.elementList[A+1];(!W||W.dateId!==y.dateId)&&this.textParticle.complete(),this.textParticle.record(t,y,z,O+k),(!Z||Z.dateId!==y.dateId)&&this.textParticle.complete()}else if(y.type===R.SUPERSCRIPT)this.textParticle.complete(),this.superscriptParticle.render(t,y,z,O+k);else if(y.type===R.SUBSCRIPT)this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,y,z,O+k);else if(y.type===R.SEPARATOR)this.separatorParticle.render(t,y,z,O);else if(this.isPageBreakElement(y))this.mode!==at.CLEAN&&!p&&this.options.pageBreak.disabled===!1&&this.pageBreakParticle.render(t,y,z,O);else if(y.type===R.CHECKBOX||y.controlComponent===b.CHECKBOX)this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:z,y:O+k,index:A,row:P});else if(y.type===R.RADIO||y.controlComponent===b.RADIO)this.textParticle.complete(),this.radioParticle.render({ctx:t,x:z,y:O+k,index:A,row:P});else if(y.type===R.TAB)this.textParticle.complete();else if(y.rowFlex===gt.ALIGNMENT||y.rowFlex===gt.JUSTIFY)this.textParticle.record(t,y,z,O+k),this.textParticle.complete();else if(y.type===R.BLOCK)this.textParticle.complete(),this.blockParticle.render(s,y,z,O+k);else if(y.type===R.PLACEHOLDER)this.textParticle.record(t,y,z,O+k),this.textParticle.complete();else{const Z=(y.characterScale??100)!==100;(y.left||Z)&&this.textParticle.complete(),this.textParticle.record(t,y,z,O+k),(y.width||y.letterSpacing||Z||es.test(y.value))&&this.textParticle.complete()}if(this.shouldDrawLineBreakForRow(P,A,g,p)&&this.lineBreakParticle.render(t,y,z,O+P.height/2),(w=y.control)!=null&&w.border){(v=W==null?void 0:W.control)!=null&&v.border&&W.controlId!==y.controlId&&this.control.drawBorder(t);const Z=this.getElementRowMargin(y);this.control.recordBorderInfo(z,O+Z,y.metrics.width,P.height-2*Z)}else(L=W==null?void 0:W.control)!=null&&L.border&&this.control.drawBorder(t);if(y.underline||(T=y.control)!=null&&T.underline){(W==null?void 0:W.type)===R.SUBSCRIPT&&y.type!==R.SUBSCRIPT&&this.underline.render(t);const Z=this.getElementRowMargin(y),tt=y.left||0;let nt=0;y.type===R.SUBSCRIPT&&(nt=this.subscriptParticle.getOffsetY(y));const Mt=(x=y.control)!=null&&x.underline?this.options.underlineColor:y.color;this.underline.recordFillInfo(t,z-tt,O+P.height-Z+nt,N.width+tt,0,Mt,(B=y.textDecoration)==null?void 0:B.style)}else(W!=null&&W.underline||(F=W==null?void 0:W.control)!=null&&F.underline)&&this.underline.render(t);if(y.strikeout){if(!y.type||Jt.includes(y.type)){W&&(W.type===R.SUBSCRIPT&&y.type!==R.SUBSCRIPT||W.type===R.SUPERSCRIPT&&y.type!==R.SUPERSCRIPT||this.getElementSize(W)!==this.getElementSize(y))&&this.strikeout.render(t);const Z=this.textParticle.measureBasisWord(t,this.getElementFont(y));let tt=O+k+Z.actualBoundingBoxDescent*i-N.height/2;y.type===R.SUBSCRIPT?tt+=this.subscriptParticle.getOffsetY(y):y.type===R.SUPERSCRIPT&&(tt+=this.superscriptParticle.getOffsetY(y)),this.strikeout.recordFillInfo(t,z,tt,N.width)}}else W!=null&&W.strikeout&&this.strikeout.render(t);if(y.revisionType==="insert"){const Z=this.options.revisionInsertColor||"#1a73e8",tt=this.getElementRowMargin(y),nt=y.left||0,Mt=O+P.height-tt;t.save(),t.strokeStyle=Z,t.lineWidth=this.options.scale;const j=Math.floor(Mt+2*t.lineWidth)+.5;t.beginPath(),t.moveTo(z-nt,j),t.lineTo(z-nt+N.width+nt,j),t.stroke(),t.restore()}const{zone:V,startIndex:U,endIndex:it}=this.range.getRange();if(V===u&&U!==it&&U<=C&&C<=it){const Z=this.position.getPositionContext();if(!Z.isTable&&!y.tdId||Z.tdId===y.tdId)if(U===C){const tt=c[U+1];tt&&tt.value===Y&&(S.x=z+N.width,S.y=O,S.height=P.height,S.width+=this.options.rangeMinWidth)}else{let tt=N.width;tt===0&&P.elementList.length===1&&(tt=this.options.rangeMinWidth),S.width||(S.x=z,S.y=O,S.height=P.height),S.width+=tt}}if(!r.disabled&&y.groupIds&&this.group.recordFillInfo(y,z,O,N.width,P.height),C++,y.type===R.TABLE){const Z=n[1]+n[3];for(let tt=0;tt<y.trList.length;tt++){const nt=y.trList[tt];for(let Mt=0;Mt<nt.tdList.length;Mt++){const j=nt.tdList[Mt];this.drawRow(t,{elementList:j.value,positionList:j.positionList,rowList:j.rowList,pageNo:s,startIndex:0,innerWidth:(j.width-Z)*i,zone:u,isDrawLineBreak:!1})}}}}if(P.isList&&this.listParticle.drawListStyle(t,P,h[P.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!p){if(S.width&&S.height){const{x:A,y,width:N,height:k}=S;this.range.render(t,A,y,N,k)}if(f&&_&&_.id===D){const{coordinate:{leftTop:[A,y]}}=h[P.startIndex];this.tableParticle.drawRange(t,_,A,y)}}}}_drawFloat(t,e){const{scale:i}=this.options,n=this.position.getFloatPositionList(),{imgDisplays:r,pageNo:o}=e;for(let a=0;a<n.length;a++){const s=n[a],c=s.element;if((o===s.pageNo||s.zone===st.HEADER||s.zone==st.FOOTER)&&c.imgDisplay&&r.includes(c.imgDisplay)&&c.type===R.IMAGE){const h=c.imgFloatPosition;this.imageParticle.render(t,c,h.x*i,h.y*i)}}}_clearPage(t){const e=this.ctxList[t],i=this.pageList[t];e.clearRect(0,0,Math.max(i.width,this.getWidth()),Math.max(i.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){var C,I;const{elementList:e,positionList:i,rowList:n,pageNo:r}=t,{inactiveAlpha:o,pageMode:a,header:s,footer:c,pageNumber:h,lineNumber:d,pageBorder:u}=this.options,g=this.mode===at.PRINT,p=this.getInnerWidth(),f=this.ctxList[r];f.globalAlpha=this.zone.isMainActive()?1:o,this._clearPage(r),this.background.render(f,r),g||this.area.render(f,r),a!==Le.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(f,r),g||this.margin.render(f,r),this._drawFloat(f,{pageNo:r,imgDisplays:[Q.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(f,r);const D=(C=n[0])==null?void 0:C.startIndex;this.drawRow(f,{elementList:e,positionList:i,rowList:n,pageNo:r,startIndex:D,innerWidth:p,zone:st.MAIN}),this.getIsPagingMode()&&(s.disabled||this.header.render(f,r),h.disabled||this.pageNumber.render(f,r),c.disabled||this.footer.render(f,r)),this._drawFloat(f,{pageNo:r,imgDisplays:[Q.FLOAT_TOP,Q.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(f,r),this.elementList.length<=1&&!((I=this.elementList[0])!=null&&I.listId)&&this.placeholder.render(f),d.disabled||this.lineNumber.render(f,r),u.disabled||this.pageBorder.render(f),this.badge.render(f,r)}_disconnectLazyRender(){var t;(t=this.lazyRenderIntersectionObserver)==null||t.disconnect()}_renderVisiblePages(t){const e=this.position.getOriginalMainPositionList(),i=this.getOriginalMainElementList(),n=this.pageRowList.length;let r=[];if(t!==void 0&&t>=0){const o=Math.max(0,t-1),a=Math.min(n-1,t+1);for(let s=o;s<=a;s++)r.push(s)}else r=[...this.visiblePageNoList],r.length===0&&(r=[0]);for(const o of r)o<n&&this.pageRowList[o]&&this._drawPage({elementList:i,positionList:e,rowList:this.pageRowList[o],pageNo:o})}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(i=>{i.forEach(n=>{if(n.isIntersecting){const r=Number(n.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[r],pageNo:r})}})}),this.pageList.forEach(i=>{this.lazyRenderIntersectionObserver.observe(i)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let i=0;i<this.pageRowList.length;i++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[i],pageNo:i})}render(t){this.renderCount++;const{header:e,footer:i}=this.options,{isSubmitHistory:n=!0,isSetCursor:r=!0,isCompute:o=!0,isLazy:a=!0,isInit:s=!1,isSourceHistory:c=!1,isFirstRender:h=!1,isPartialRender:d=!1,pageNo:u}=t||{};let{curIndex:g}=t||{};const p=this.getInnerWidth(),f=this.getIsPagingMode(),D=this.pageRowList.length;if(o){this.position.setFloatPositionList([]),f&&(e.disabled||this.header.compute(),i.disabled||this.footer.compute());const w=this.getMargins(),v=this.getHeight(),L=this.header.getExtraHeight(),T=this.getMainOuterHeight(),x=w[3],B=w[0]+L,F=rn(this.elementList);if(this.rowList=this.computeRowList({startX:x,startY:B,pageHeight:v,mainOuterHeight:T,isPagingMode:f,innerWidth:p,surroundElementList:F,elementList:this.elementList}),this.pageRowList=this._computePageList(),this.position.computePositionList(),this.area.compute(),this.mode!==at.PRINT){const M=this.search.getSearchKeyword();M&&this.search.compute(M),this.control.computeHighlightList()}}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let w=0;w<this.pageRowList.length;w++)this.pageList[w]||this._createPage(w);const C=this.pageRowList.length,I=this.pageList.length;if(I>C){const w=I-C;this.ctxList.splice(C,w),this.pageList.splice(C,w).forEach(v=>v.remove())}const E=D!==this.pageRowList.length;d&&f&&!E?this._renderVisiblePages(u??this.intersectionPageNo):a&&f?this._lazyRender():this._immediateRender(),r?g=this.setCursor(g):this.range.getIsSelection()&&this.cursor.focus(),(n&&!h||g!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(g),Ji(()=>{this.range.setRangeStyle(),o&&this.control.getActiveControl()&&this.control.reAwakeControl(),o&&!this.isReadonly()&&this.position.getPositionContext().isTable&&this.tableTool.render(),o&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),D!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.hasSubscribers("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(n||c)&&!s&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.hasSubscribers("contentChange")&&this.eventBus.emit("contentChange")),o&&this.revisionOverlay&&this.revisionOverlay.update(),o&&!n&&!c&&this.commentOverlay&&this.commentOverlay.render()})}setCursor(t){var r;const e=this.position.getPositionContext(),i=this.position.getPositionList();if(e.isTable){const{index:o,trIndex:a,tdIndex:s}=e,h=(r=this.getOriginalElementList()[o].trList)==null?void 0:r[a].tdList[s].positionList;t===void 0&&h&&(t=h.length-1);const d=h==null?void 0:h[t];this.position.setCursorPosition(d||null)}else this.position.setCursorPosition(t!==void 0?i[t]:null);let n=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const a=this.getElementList()[t];if($o.includes(a.type)){n=!1;const s=this.position.getCursorPosition();this.previewer.updateResizer(a,s)}}return this.cursor.drawCursor({isShow:n}),t}submitHistory(t){const e=this.position.getPositionContext(),i=yi(this.elementList),n=yi(this.header.getElementList()),r=yi(this.footer.getElementList()),o=bt(this.range.getRange()),a=this.pageNo,s=bt(e),c=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(c),this.setPageNo(a),this.position.setPositionContext(bt(s)),this.header.setElementList(bt(n)),this.footer.setElementList(bt(r)),this.elementList=bt(i),this.range.replaceRange(bt(o)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.container.remove(),this.canvasEvent.removeEvent(),this.globalEvent.removeEvent(),this.mouseObserver.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}}class il{constructor(t,e){m(this,"draw");m(this,"command");m(this,"range");m(this,"options");m(this,"container");m(this,"textToolbar",null);m(this,"imageToolbar",null);m(this,"lastMousePosition",{x:0,y:0});m(this,"currentImageElement",null);m(this,"_handleMouseUp",t=>{this.lastMousePosition={x:t.clientX,y:t.clientY},setTimeout(()=>{const e=this._getContext();e.isImageSelected&&e.imageElement?(this.currentImageElement=e.imageElement,this._hideTextToolbar(),this._showImageToolbar(),this._updateImageToolbarState()):e.hasSelection?(this.currentImageElement=null,this._hideImageToolbar(),this._showTextToolbar()):(this.currentImageElement=null,this._hideTextToolbar(),this._hideImageToolbar())},10)});m(this,"_handleClickOutside",t=>{const e=t.target,i=ti(e,r=>{var o;return(o=r==null?void 0:r.classList)==null?void 0:o.contains(`${J}-floating-toolbar`)}),n=this.container.contains(e);!i&&!n&&this.dispose()});m(this,"_handleContextMenu",t=>{t.preventDefault(),t.stopPropagation()});var i;this.draw=t,this.command=e,this.range=t.getRange(),this.options=t.getOptions(),this.container=t.getContainer(),((i=this.options.floatingBar)==null?void 0:i.enabled)!==!1&&(this._createToolbars(),this._addEvents())}_createToolbars(){this.textToolbar=document.createElement("div"),this.textToolbar.className=`${J}-floating-toolbar`,this.textToolbar.setAttribute(Xe,ke.COMPONENT),this.textToolbar.innerHTML=`
40
+ <select class="fb-select fb-fontfamily" title="字体">
41
+ ${this._createFontOptionsHtml()}
42
+ </select>
43
+ <select class="fb-select fb-fontsize" title="字号">
44
+ ${this._createSizeOptionsHtml()}
45
+ </select>
46
+ <div class="fb-divider"></div>
47
+ <button class="fb-btn" data-action="bold" title="加粗">
48
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"/></svg>
49
+ </button>
50
+ <button class="fb-btn" data-action="italic" title="斜体">
51
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"/></svg>
52
+ </button>
53
+ <button class="fb-btn" data-action="underline" title="下划线">
54
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"/></svg>
55
+ </button>
56
+ <div class="fb-divider"></div>
57
+ <div class="fb-color-picker" data-type="color">
58
+ <button class="fb-btn fb-color-btn" title="文字颜色">
59
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M11 2L5.5 16h2.25l1.12-3h6.25l1.12 3h2.25L13 2h-2zm-1.38 9L12 4.67 14.38 11H9.62z"/></svg>
60
+ <span class="fb-color-indicator" style="background:#000000"></span>
61
+ </button>
62
+ <input type="color" class="fb-color-input" value="#000000">
63
+ </div>
64
+ <div class="fb-color-picker" data-type="highlight">
65
+ <button class="fb-btn fb-color-btn" title="高亮颜色">
66
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M6 14l3 3v5h6v-5l3-3V9H6v5zm5-12h2v3h-2V2zM3.5 5.88l1.41-1.41 2.12 2.12L5.62 8 3.5 5.88zm13.46.71l2.12-2.12 1.41 1.41L18.38 8l-1.42-1.41z"/></svg>
67
+ <span class="fb-color-indicator" style="background:#ffff00"></span>
68
+ </button>
69
+ <input type="color" class="fb-color-input" value="#ffff00">
70
+ </div>
71
+ <div class="fb-divider"></div>
72
+ <button class="fb-btn" data-action="alignLeft" title="左对齐">
73
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"/></svg>
74
+ </button>
75
+ <button class="fb-btn" data-action="alignCenter" title="居中">
76
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"/></svg>
77
+ </button>
78
+ <button class="fb-btn" data-action="alignRight" title="右对齐">
79
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"/></svg>
80
+ </button>
81
+ `,this.container.appendChild(this.textToolbar),this.imageToolbar=document.createElement("div"),this.imageToolbar.className=`${J}-floating-toolbar ${J}-image-toolbar`,this.imageToolbar.setAttribute(Xe,ke.COMPONENT),this.imageToolbar.innerHTML=`
82
+ <span class="fb-label">环绕</span>
83
+ <button class="fb-btn" data-action="imgInline" data-display="INLINE" title="嵌入文字">
84
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M4 9h16v2H4V9zm0 4h10v2H4v-2z"/></svg>
85
+ </button>
86
+ <button class="fb-btn" data-action="imgSurround" data-display="SURROUND" title="文字环绕">
87
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M4 19h16v2H4v-2zm0-4h4v2H4v-2zm0-4h4v2H4v-2zm0-4h4v2H4V7zm0-4h16v2H4V3zm12 4h4v6h-4V7zm-2 10h8v2h-8v-2z"/></svg>
88
+ </button>
89
+ <button class="fb-btn" data-action="imgFloatTop" data-display="FLOAT_TOP" title="浮于文字上方">
90
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2zM7 17h10V7H7v10z"/></svg>
91
+ </button>
92
+ <button class="fb-btn" data-action="imgFloatBottom" data-display="FLOAT_BOTTOM" title="衬于文字下方">
93
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2z"/></svg>
94
+ </button>
95
+ <div class="fb-divider"></div>
96
+ <button class="fb-btn" data-action="rotateLeft" title="向左旋转">
97
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M7.11 8.53L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47zM6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47zm1.01 5.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32zM13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93z"/></svg>
98
+ </button>
99
+ <button class="fb-btn" data-action="rotateRight" title="向右旋转">
100
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M15.55 5.55L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45zM19.93 11c-.17-1.39-.72-2.73-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47h2.02zM13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03zm3.89-2.42l1.42 1.41c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.48z"/></svg>
101
+ </button>
102
+ <div class="fb-divider"></div>
103
+ <button class="fb-btn" data-action="replaceImage" title="替换图片">
104
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>
105
+ </button>
106
+ <button class="fb-btn" data-action="saveImage" title="保存图片">
107
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg>
108
+ </button>
109
+ <button class="fb-btn" data-action="deleteImage" title="删除">
110
+ <svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>
111
+ </button>
112
+ `,this.container.appendChild(this.imageToolbar),this._bindToolbarEvents()}_bindToolbarEvents(){if(this.textToolbar){const t=this.textToolbar.querySelector(".fb-fontfamily");t.value=this._resolveFontValue(this.options.defaultFont),t==null||t.addEventListener("change",()=>{this.command.executeFont(t.value)});const e=this.textToolbar.querySelector(".fb-fontsize");e.value=this._resolveSizeValue(this.options.defaultSize),e==null||e.addEventListener("change",()=>{this.command.executeSize(Number(e.value))}),this.textToolbar.querySelectorAll(".fb-btn:not(.fb-color-btn)").forEach(i=>{i.addEventListener("click",()=>{const n=i.getAttribute("data-action");this._executeTextAction(n)})}),this.textToolbar.querySelectorAll(".fb-color-picker").forEach(i=>{const n=i.getAttribute("data-type"),r=i.querySelector(".fb-color-btn"),o=i.querySelector(".fb-color-input"),a=i.querySelector(".fb-color-indicator");r==null||r.addEventListener("click",()=>{o==null||o.click()}),o==null||o.addEventListener("input",()=>{const s=o.value;s&&(n==="color"?this.command.executeColor(s):n==="highlight"&&this.command.executeHighlight(s),a&&(a.style.background=s))})})}this.imageToolbar&&this.imageToolbar.querySelectorAll(".fb-btn").forEach(t=>{t.addEventListener("click",()=>{const e=t.getAttribute("data-action");this._executeImageAction(e)})})}_createFontOptionsHtml(){var n;const t=(n=this.options.defaultFont)==null?void 0:n.trim();return(t&&Qe.some(r=>r.value===t||r.label===t)?[...Qe]:[...Qe,{label:t||"",value:t||""}].filter(r=>r.label&&r.value)).map(r=>`<option value="${r.value}" style="font-family:${r.value}">${r.label}</option>`).join("")}_createSizeOptionsHtml(){const t=this.options.defaultSize;return(Je.some(n=>n.value===t)?[...Je]:[...Je,{label:String(t),value:t}]).map(n=>`<option value="${n.value}">${n.label}</option>`).join("")}_resolveFontValue(t){const e=t.trim().toLowerCase(),i=Qe.find(n=>{const r=n.value.trim().toLowerCase(),o=n.label.trim().toLowerCase(),a=n.value.split(",").map(s=>s.replace(/['"]/g,"").trim().toLowerCase()).find(Boolean);return r===e||o===e||a===e});return(i==null?void 0:i.value)||t}_resolveSizeValue(t){const e=Number(t),i=Je.find(n=>n.value===e);return String((i==null?void 0:i.value)??e)}_executeTextAction(t){if(t)switch(t){case"bold":this.command.executeBold();break;case"italic":this.command.executeItalic();break;case"underline":this.command.executeUnderline();break;case"alignLeft":this.command.executeRowFlex(gt.LEFT);break;case"alignCenter":this.command.executeRowFlex(gt.CENTER);break;case"alignRight":this.command.executeRowFlex(gt.RIGHT);break}}_executeImageAction(t){if(!(!t||!this.currentImageElement))switch(t){case"imgInline":this.command.executeChangeImageDisplay(this.currentImageElement,Q.INLINE),this._updateImageToolbarState();break;case"imgSurround":this.command.executeChangeImageDisplay(this.currentImageElement,Q.SURROUND),this._updateImageToolbarState();break;case"imgFloatTop":this.command.executeChangeImageDisplay(this.currentImageElement,Q.FLOAT_TOP),this._updateImageToolbarState();break;case"imgFloatBottom":this.command.executeChangeImageDisplay(this.currentImageElement,Q.FLOAT_BOTTOM),this._updateImageToolbarState();break;case"rotateLeft":this._rotateImage(-90);break;case"rotateRight":this._rotateImage(90);break;case"replaceImage":this._replaceImage();break;case"saveImage":this.command.executeSaveAsImageElement();break;case"deleteImage":this.command.executeBackspace(),this.dispose();break}}_rotateImage(t){if(!this.currentImageElement)return;const e=this.currentImageElement.value,i=new Image;i.onload=()=>{const n=document.createElement("canvas"),r=n.getContext("2d");Math.abs(t)===90?(n.width=i.height,n.height=i.width):(n.width=i.width,n.height=i.height),r.translate(n.width/2,n.height/2),r.rotate(t*Math.PI/180),r.drawImage(i,-i.width/2,-i.height/2);const o=n.toDataURL();this.command.executeReplaceImageElement(o),setTimeout(()=>{const a=this._getContext();a.isImageSelected&&a.imageElement&&(this.currentImageElement=a.imageElement)},50)},i.src=e}_replaceImage(){const t=document.createElement("input");t.type="file",t.accept="image/*",t.onchange=e=>{var n;const i=(n=e.target.files)==null?void 0:n[0];if(i){const r=new FileReader;r.onload=o=>{var a;this.command.executeReplaceImageElement((a=o.target)==null?void 0:a.result)},r.readAsDataURL(i)}},t.click()}_updateImageToolbarState(){if(!this.imageToolbar||!this.currentImageElement)return;this.imageToolbar.querySelectorAll("[data-display]").forEach(e=>{var r;const i=e.getAttribute("data-display"),n=((r=this.currentImageElement)==null?void 0:r.imgDisplay)||Q.INLINE;i&&Q[i]===n?e.classList.add("active"):e.classList.remove("active")})}_addEvents(){const t=this.draw.getPageContainer();t.addEventListener("mouseup",this._handleMouseUp),document.addEventListener("mousedown",this._handleClickOutside),t.addEventListener("contextmenu",this._handleContextMenu)}_getContext(){const t=this.range.getRange(),e=t.startIndex!==t.endIndex&&t.startIndex>=0,i=this.draw.getElementList(),n=i[t.startIndex],r=i[t.endIndex],o=(n==null?void 0:n.type)===R.IMAGE||(r==null?void 0:r.type)===R.IMAGE,a=o?(n==null?void 0:n.type)===R.IMAGE?n:r:null;return{hasSelection:e,isImageSelected:o,imageElement:a}}_showTextToolbar(){this.textToolbar&&(this.textToolbar.classList.add("show"),this._positionToolbar(this.textToolbar))}_hideTextToolbar(){var t;(t=this.textToolbar)==null||t.classList.remove("show")}_showImageToolbar(){this.imageToolbar&&(this.imageToolbar.classList.add("show"),this._positionToolbar(this.imageToolbar))}_hideImageToolbar(){var t;(t=this.imageToolbar)==null||t.classList.remove("show"),this.currentImageElement=null}_positionToolbar(t){const e=t.getBoundingClientRect(),i=e.width||400,n=e.height||40;let r=this.lastMousePosition.x-i/2,o=this.lastMousePosition.y-n-10;r<10&&(r=10),r+i>window.innerWidth-10&&(r=window.innerWidth-i-10),o<10&&(o=this.lastMousePosition.y+20),t.style.left=`${r}px`,t.style.top=`${o}px`}removeEvent(){const t=this.draw.getPageContainer();t.removeEventListener("mouseup",this._handleMouseUp),document.removeEventListener("mousedown",this._handleClickOutside),t.removeEventListener("contextmenu",this._handleContextMenu)}dispose(){this._hideTextToolbar(),this._hideImageToolbar()}destroy(){var t,e;this.removeEvent(),(t=this.textToolbar)==null||t.remove(),(e=this.imageToolbar)==null||e.remove()}}class nl{constructor(t){m(this,"editor");this.editor=t}use(t,e){t(this.editor,e)}}class ol{constructor(){m(this,"paste");m(this,"copy");m(this,"drop")}}class sl{constructor(t){m(this,"shortcutList");m(this,"langMap");m(this,"chartRenderer",null);const{shortcut:e,i18n:i}=t;this.shortcutList=e.registerShortcutList.bind(e),this.langMap=i.registerLangMap.bind(i)}registerChartRenderer(t){this.chartRenderer=t}getChartRenderer(){return this.chartRenderer}hasChartRenderer(){return this.chartRenderer!==null}}X.AbstractRichText=Ze,X.Actuator=dn,X.Area=To,X.Background=Wn,X.Badge=bo,X.BlockParticle=pn,X.CanvasEvent=Pn,X.CheckboxControl=Ye,X.CheckboxParticle=ho,X.Control=co,X.ControlBorder=ao,X.ControlSearch=lo,X.Cursor=Ln,X.CursorAgent=En,X.DateControl=Pe,X.DateParticle=gn,X.DatePicker=fn,X.Draw=el,X.FloatingBar=il,X.Footer=Do,X.GlobalEvent=An,X.Group=Io,X.Header=eo,X.Highlight=$n,X.HistoryManager=an,X.HyperlinkParticle=to,X.I18n=hn,X.ImageObserver=po,X.ImageParticle=jn,X.LaTexParticle=un,X.LineBreakParticle=Ae,X.LineNumber=Lo,X.ListParticle=Co,X.Margin=Vn,X.MouseObserver=Eo,X.NumberControl=ki,X.Override=ol,X.PageBorder=wo,X.PageBreakParticle=so,X.PageNumber=we,X.ParagraphColor=Un,X.Placeholder=Ni,X.Plugin=nl,X.Position=Sn,X.Previewer=go,X.RadioControl=si,X.RadioParticle=uo,X.Register=sl,X.ScrollObserver=Zn,X.Search=Gn,X.SelectControl=Fe,X.SelectionObserver=qn,X.SeparatorParticle=oo,X.Strikeout=Kn,X.SubscriptParticle=no,X.SuperscriptParticle=io,X.TableOperate=vo,X.TableParticle=Qn,X.TableTool=Jn,X.TextControl=hi,X.TextParticle=se,X.Underline=Yn,X.Watermark=ro,X.WorkerManager=cn,X.Zone=mo,X.ZoneTip=fo,X.getClipboardData=Ri,X.getIsClipboardContainFile=mn,X.pasteByApi=mr,X.removeClipboardData=Fi,X.version=ln,Object.defineProperty(X,Symbol.toStringTag,{value:"Module"})});
113
+ //# sourceMappingURL=docx-editor-view.umd.cjs.map