@agile_jy/word-editor 0.0.1-beta.20 → 0.0.1-beta.21
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.
- package/dist/canvas-editor.es.js +41 -47
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +3 -3
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +1 -3
- package/dist/src/editor/core/command/CommandAdapt.d.ts +5 -1
- package/dist/src/editor/utils/docxHtml.d.ts +5 -0
- package/dist/src/plugins/docx/importDocx.d.ts +2 -4
- package/dist/src/plugins/docx/index.d.ts +5 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="canvas-editor-style",e.appendChild(document.createTextNode('.ce-select-control-popup{max-width:160px;min-width:69px;max-height:225px;position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;overflow-y:auto}.ce-select-control-popup ul{list-style:none;padding:3px 0;margin:0;box-sizing:border-box}.ce-select-control-popup ul li{font-size:13px;padding:0 20px;position:relative;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#666;height:36px;line-height:36px;box-sizing:border-box;cursor:pointer}.ce-select-control-popup ul li:hover{background-color:#eef2fd}.ce-select-control-popup ul li.active{color:var(--COLOR-HOVER, #5175f4);font-weight:700}.ce-calculator{position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;padding:8px;width:200px}.ce-calculator-display{width:100%;height:40px;line-height:40px;text-align:right;padding:0 10px;margin-bottom:8px;border:1px solid #e4e7ed;border-radius:4px;background-color:#f5f7fa;font-size:16px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis}.ce-calculator-buttons{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ce-calculator-button{width:100%;height:36px;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;font-size:14px;cursor:pointer;transition:all .2s;box-sizing:border-box}.ce-calculator-button:hover{background-color:#eef2fd;border-color:#c6d1ff}.ce-calculator-button:active{background-color:#e1e8ff}.ce-calculator-button.operator{background-color:#f5f7fa}.ce-calculator-button.operator:hover{background-color:#eef2fd}.ce-calculator-button.equal{background-color:var(--COLOR-HOVER, #5175f4);color:#fff;border-color:var(--COLOR-HOVER, #5175f4)}.ce-calculator-button.equal:hover{background-color:var(--COLOR-HOVER, #6a84ff);border-color:var(--COLOR-HOVER, #6a84ff)}.ce-calculator-button.utility{background-color:#f0f2f5}.ce-calculator-button.utility:hover{background-color:#e6e8eb}.ce-date-container{display:none;width:300px;overflow:hidden;left:0;right:0;position:absolute;z-index:1;color:#606266;background:#ffffff;border-radius:4px;padding:10px;user-select:none;border:1px solid #e4e7ed;box-shadow:0 2px 12px #0000001a}.ce-date-container.active{display:block}.ce-date-wrap{display:none}.ce-date-wrap.active{display:block}.ce-date-title{display:flex;justify-content:center;align-items:center;text-align:center;color:#606266;font-size:16px}.ce-date-title>span{display:inline-block}.ce-date-title>span:not(.ce-date-title__now){font-family:cursive;cursor:pointer}.ce-date-title>span:not(.ce-date-title__now):hover{color:#5175f4}.ce-date-title .ce-date-title__pre-year,.ce-date-title .ce-date-title__pre-month{width:15%}.ce-date-title .ce-date-title__now{width:40%}.ce-date-title .ce-date-title__next-year,.ce-date-title .ce-date-title__next-month{width:15%}.ce-date-week{width:100%;display:flex;justify-content:center;margin-top:15px;padding-bottom:5px;border-bottom:1px solid #e4e7ed}.ce-date-week>span{list-style:none;width:calc(100%/7);text-align:center;color:#606266;font-size:14px}.ce-date-day{width:100%;display:flex;flex-wrap:wrap;align-items:center;margin-top:5px}.ce-date-day>div{width:calc(100%/7);height:40px;text-align:center;color:#606266;font-size:14px;cursor:pointer;line-height:40px;border-radius:4px}.ce-date-day>div:hover{color:#5175f4;opacity:.8}.ce-date-day>div.active{color:#5175f4;font-weight:700}.ce-date-day>div.disable{color:#c0c4cc}.ce-date-day>div.select{color:#fff;background-color:#5175f4}.ce-time-wrap{display:none;padding:10px;height:286px}.ce-time-wrap ::-webkit-scrollbar{width:0}.ce-time-wrap.active{display:flex}.ce-time-wrap li{list-style:none}.ce-time-wrap>li{width:33.3%;height:100%;text-align:center}.ce-time-wrap>li>span{transform:translateY(-5px);display:inline-block}.ce-time-wrap>li>ol{height:calc(100% - 20px);overflow-y:auto;border:1px solid #e2e2e2;position:relative}.ce-time-wrap>li:first-child>ol{border-right:0}.ce-time-wrap>li:last-child>ol{border-left:0}.ce-time-wrap>li>ol>li{line-height:30px;cursor:pointer;transition:all .3s}.ce-time-wrap>li>ol>li:hover{background-color:#eaeaea}.ce-time-wrap>li>ol>li.active{color:#fff;background:#5175F4}.ce-date-menu{width:100%;height:28px;display:flex;justify-content:flex-end;align-items:center;padding-top:10px;position:relative;border-top:1px solid #e4e7ed}.ce-date-menu button{display:inline-block;line-height:1;white-space:nowrap;cursor:pointer;background:#fff;border:1px solid #dcdfe6;color:#606266;appearance:none;text-align:center;box-sizing:border-box;outline:none;transition:.1s;font-weight:500;user-select:none;padding:7px 15px;font-size:12px;border-radius:3px;margin:0 0 0 10px}.ce-date-menu button:hover{color:#5175f4;border-color:#5175f4}.ce-date-menu button.ce-date-menu__time{border:1px solid transparent;position:absolute;left:0;margin-left:0}.ce-date-menu button.ce-date-menu__time:hover{color:#5175f4}.ce-block-item{position:absolute;z-index:0;background-color:#fff;border:1px solid rgb(235 236 240)}.ce-block-item .ce-resizer-selection{width:100%;height:100%}.ce-block-item .ce-resizer-mask{position:absolute;top:0;bottom:0;left:0;right:0;z-index:1;background-color:transparent}.ce-table-tool__row{position:absolute;width:12px;border-radius:6.5px;overflow:hidden;background-color:#e2e6ed}.ce-table-tool__row .ce-table-tool__row__item{width:100%;position:relative;cursor:pointer;transition:all .3s}.ce-table-tool__row .ce-table-tool__row__item:after{content:"";position:absolute;bottom:0;left:2px;width:8px;height:1px;background-color:#c0c6cf}.ce-table-tool__row .ce-table-tool__row__item:hover{background-color:#dadce0}.ce-table-tool__row .ce-table-tool__row__item:last-child:after{display:none}.ce-table-tool__quick__add{width:16px;height:16px;position:absolute;border-radius:50%;background-color:#e2e6ed;cursor:pointer}.ce-table-tool__quick__add:after{content:"+";color:#fff;position:absolute;top:50%;left:50%;transform:translate(-50%,-55%)}.ce-table-tool__select{width:16px;height:18px;position:absolute;border-radius:3px;cursor:pointer}.ce-table-tool__select:hover{background-color:#e2e6ed}.ce-table-tool__select:after{content:":::";color:#aaaaab;position:absolute;top:50%;left:50%;transform:translate(-75%,-50%) rotate(-90deg)}.ce-table-tool__col{position:absolute;height:12px;border-radius:6.5px;overflow:hidden;background-color:#e2e6ed;display:flex}.ce-table-tool__col .ce-table-tool__col__item{height:100%;position:relative;cursor:pointer;transition:all .3s}.ce-table-tool__col .ce-table-tool__col__item:after{content:"";position:absolute;top:2px;left:-1px;width:1px;height:8px;z-index:1;background-color:#c0c6cf}.ce-table-tool__col .ce-table-tool__col__item:hover{background-color:#dadce0}.ce-table-tool__col .ce-table-tool__col__item:first-child:after{display:none}.ce-table-tool__row .ce-table-tool__row__item.active,.ce-table-tool__col .ce-table-tool__col__item.active{background-color:#c4d7fa}.ce-table-tool__col .ce-table-tool__anchor{right:-5px;width:10px;height:12px;z-index:9;position:absolute;cursor:col-resize}.ce-table-tool__row .ce-table-tool__anchor{bottom:-5px;left:0;width:12px;height:10px;z-index:9;position:absolute;cursor:row-resize}.ce-table-anchor__line{z-index:9;position:absolute;border:1px dotted #000000}.ce-table-tool__border{position:absolute;z-index:1;background:transparent;pointer-events:none}.ce-table-tool__border__row{position:absolute;cursor:row-resize;pointer-events:auto}.ce-table-tool__border__col{position:absolute;cursor:col-resize;pointer-events:auto}.ce-resizer-selection{position:absolute;border:1px solid;pointer-events:none}.ce-resizer-selection .resizer-handle{position:absolute;z-index:9;width:10px;height:10px;box-shadow:0 1px 4px #0000004d;border-radius:5px;border:2px solid #ffffff;box-sizing:border-box;pointer-events:initial}.ce-resizer-selection .handle-0{cursor:nw-resize}.ce-resizer-selection .handle-1{cursor:n-resize}.ce-resizer-selection .handle-2{cursor:ne-resize}.ce-resizer-selection .handle-3{cursor:e-resize}.ce-resizer-selection .handle-4{cursor:se-resize}.ce-resizer-selection .handle-5{cursor:s-resize}.ce-resizer-selection .handle-6{cursor:sw-resize}.ce-resizer-selection .handle-7{cursor:w-resize}.ce-resizer-size-view{display:flex;align-items:center;height:20px;white-space:nowrap;position:absolute;z-index:9;top:-30px;left:0;opacity:.9;background-color:#000;padding:0 5px;border-radius:4px}.ce-resizer-size-view span{color:#fff;font-size:12px}.ce-resizer-image{position:absolute;opacity:.5}.ce-image-previewer{position:fixed;left:0;top:0;z-index:1000;width:100%;height:100%;overflow:hidden;background:#f2f4f7;display:flex;align-items:center;justify-content:center;animation:previewerAnimation .3s}@keyframes previewerAnimation{0%{opacity:.1}to{opacity:1}}.ce-image-previewer .image-close{width:24px;height:24px;display:inline-block;position:absolute;right:50px;top:30px;z-index:99;cursor:pointer;background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIzLjk3IDdsMS40MTUgMS40MTQtNy43NzkgNy43NzggNy43NzkgNy43NzktMS40MTQgMS40MTQtNy43NzktNy43NzktNy43NzggNy43NzlMNyAyMy45N2w3Ljc3OC03Ljc3OUw3IDguNDE0IDguNDE0IDdsNy43NzggNy43NzhMMjMuOTcxIDd6IiBmaWxsPSIjM0Q0NzU3IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=) no-repeat;background-size:100% 100%;transition:all .3s;border-radius:50%}.ce-image-previewer .image-close:hover{background-color:#e2e6ed}.ce-image-previewer .ce-image-container{position:relative}.ce-image-previewer .ce-image-container img{cursor:move;position:relative}.ce-image-previewer .ce-image-menu{height:50px;position:absolute;bottom:50px;z-index:99;display:flex;align-items:center;justify-content:center}.ce-image-previewer .ce-image-menu i{width:32px;height:32px;margin:0 8px;cursor:pointer;display:inline-block;background-repeat:no-repeat;background-size:100% 100%;transition:all .3s;border-radius:50%}.ce-image-previewer .ce-image-menu i:hover{background-color:#e2e6ed}.ce-image-previewer .ce-image-menu i.zoom-in{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE0IDE0di00aDJ2NGg0djJoLTR2NGgtMnYtNGgtNHYtMmg0em04Ljc0OSAxMC4xNjNBMTEuOTUyIDExLjk1MiAwIDAxMTUgMjdDOC4zNzMgMjcgMyAyMS42MjcgMyAxNVM4LjM3MyAzIDE1IDNzMTIgNS4zNzMgMTIgMTJjMCAyLjk1NC0xLjA2NyA1LjY1OC0yLjgzNyA3Ljc0OWw0LjkwOCA0LjkwOC0xLjQxNCAxLjQxNC00LjkwOC00LjkwOHpNMTUgMjVjNS41MjMgMCAxMC00LjQ3NyAxMC0xMFMyMC41MjMgNSAxNSA1IDUgOS40NzcgNSAxNXM0LjQ3NyAxMCAxMCAxMHoiIGZpbGw9IiMzRDQ3NTciLz48L3N2Zz4=)}.ce-image-previewer .ce-image-menu i.zoom-out{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIyLjc0OSAyNC4xNjNBMTEuOTUyIDExLjk1MiAwIDAxMTUgMjdDOC4zNzMgMjcgMyAyMS42MjcgMyAxNVM4LjM3MyAzIDE1IDNzMTIgNS4zNzMgMTIgMTJjMCAyLjk1NC0xLjA2NyA1LjY1OC0yLjgzNyA3Ljc0OWw0LjkwOCA0LjkwOC0xLjQxNCAxLjQxNC00LjkwOC00LjkwOHpNMTUgMjVjNS41MjMgMCAxMC00LjQ3NyAxMC0xMFMyMC41MjMgNSAxNSA1IDUgOS40NzcgNSAxNXM0LjQ3NyAxMCAxMCAxMHptLTUtMTFoMTB2MkgxMHYtMnoiIGZpbGw9IiMzRDQ3NTciLz48L3N2Zz4=)}.ce-image-previewer .ce-image-menu i.rotate{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMTYgNGM2LjYyNyAwIDEyIDUuMzczIDEyIDEyYTExLjk3IDExLjk3IDAgMDEtNCA4Ljk0NFYyM2gtLjg2QTkuOTY4IDkuOTY4IDAgMDAyNiAxNmMwLTUuNTIzLTQuNDc3LTEwLTEwLTEwUzYgMTAuNDc3IDYgMTZjMCA1LjE4NSAzLjk0NyA5LjQ0OSA5IDkuOTV2Mi4wMDlDOC44NCAyNy40NTEgNCAyMi4yOTEgNCAxNiA0IDkuMzczIDkuMzczIDQgMTYgNHoiIGZpbGwtcnVsZT0ibm9uemVybyIvPjxwYXRoIGQ9Ik0xOS44NzkgMjcuMzI4bDEuNzY3LTYuNzE3IDQuOTUgNC45NXoiLz48L2c+PC9zdmc+)}.ce-image-previewer .ce-image-menu i.original-size{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgNGgyNHYyNEg0VjR6bTIgMnYyMGgyMFY2SDZ6bTQgNWgydjEwaC0yVjExem01IDJoMnYyaC0ydi0yem0wIDRoMnYyaC0ydi0yem01LTZoMnYxMGgtMlYxMXoiIGZpbGw9IiMzRDQ3NTciLz48L3N2Zz4=)}.ce-image-previewer .ce-image-menu i.image-download{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAxNXYzLjVoMTVWMTVIMjF2NUgzdi01aDEuNXptOC4yMzItMTEuMjI2djkuMTk2bDQuMDUtNC4wNSAxLjA2IDEuMDYtNS44MzQgNS44MzQtNS44MzMtNS44MzMgMS4wNi0xLjA2IDMuOTk4IDMuOTk2VjMuNzc0aDEuNXoiIGZpbGw9IiMzRDQ3NTciLz48L3N2Zz4=)}.ce-image-previewer .ce-image-menu .image-navigate{display:flex;align-items:center;justify-content:center}.ce-image-previewer .ce-image-menu i.image-pre{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyLjUgNC4wNjNMNi44NzUgMTBsNS42MjUgNS45MzgiIHN0cm9rZT0iIzNENDc1NyIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==)}.ce-image-previewer .ce-image-menu i.image-next{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcuNSA0LjA2M0wxMy4xMjUgMTAgNy41IDE1LjkzOCIgc3Ryb2tlPSIjM0Q0NzU3IiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+)}.ce-image-previewer .ce-image-menu .image-count{color:#000;font-size:20px}.ce-image-previewer .ce-image-menu i.disabled{cursor:not-allowed;opacity:.5}.ce-contextmenu-container{z-index:9;position:fixed;display:none;padding:4px;overflow-x:hidden;overflow-y:auto;background:#fff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px}.ce-contextmenu-content{display:flex;flex-direction:column}.ce-contextmenu-content .ce-contextmenu-sub-item:after{position:absolute;content:"";width:16px;height:16px;right:12px;background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMCAwaDE2djE2SDB6Ii8+PGcgZmlsbD0iIzc2N0M4NSI+PHBhdGggZD0iTTcgMTIuMjQzbC0uNzA3LS43MDcgNC4yNDMtNC4yNDMuNzA3LjcwN3oiLz48cGF0aCBkPSJNNi4yOTMgNC40NjRMNyAzLjc1NyAxMS4yNDMgOGwtLjcwNy43MDd6Ii8+PC9nPjwvZz48L3N2Zz4=)}.ce-contextmenu-content .ce-contextmenu-item{min-width:140px;padding:0 32px 0 16px;height:30px;display:flex;align-items:center;white-space:nowrap;box-sizing:border-box;cursor:pointer}.ce-contextmenu-content .ce-contextmenu-item.hover{background:rgba(25,55,88,.04)}.ce-contextmenu-content .ce-contextmenu-item span{max-width:300px;font-size:12px;color:#3d4757;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.ce-contextmenu-content .ce-contextmenu-item span.ce-shortcut{color:#767c85;height:30px;flex:1;text-align:right;line-height:30px;margin-left:20px}.ce-contextmenu-content .ce-contextmenu-item i{width:16px;height:16px;vertical-align:middle;display:inline-block;background-repeat:no-repeat;background-size:100% 100%;flex-shrink:0;margin-right:8px}.ce-contextmenu-divider{background-color:#e2e6ed;margin:4px 16px;height:1px}.ce-contextmenu-print{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjM0Q0NzU3IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0xMiA0aC0xVjJINXYySDRWMmExIDEgMCAwMTEtMWg2YTEgMSAwIDAxMSAxdjJ6bTAgNXY0YTEgMSAwIDAxLTEgMUg1YTEgMSAwIDAxLTEtMVY5aDF2NGg2VjloMXoiLz48cGF0aCBkPSJNMTIgMTJ2LTFoMlY1SDJ2NmgydjFIMmExIDEgMCAwMS0xLTFWNWExIDEgMCAwMTEtMWgxMmExIDEgMCAwMTEgMXY2YTEgMSAwIDAxLTEgMWgtMnoiLz48cGF0aCBkPSJNMyA4aDEwdjFIM3ptOC0yaDJ2MWgtMnoiLz48L2c+PC9zdmc+)}.ce-contextmenu-image{background-image:url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSLlm77lsYJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4PSIwIiB5PSIwIiB2aWV3Qm94PSIwIDAgMTYgMTYiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxzdHlsZT4uc3Qwe2ZpbGw6IzNkNDc1N308L3N0eWxlPjxnIGlkPSJfeDMwXzAt5YWs5YWxX3gyRl8wMuW3peWFt+agj194MkZf5o+S5YWl5Zu+54mHLTE2cHgtIj48ZyBpZD0iR3JvdXAtMTkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEgMSkiPjxwYXRoIGlkPSJDb21iaW5lZC1TaGFwZSIgY2xhc3M9InN0MCIgZD0iTTEgMGgxMmMuNiAwIDEgLjQgMSAxdjExYzAgLjYtLjQgMS0xIDFIMWMtLjYgMC0xLS40LTEtMVYxYzAtLjYuNC0xIDEtMXptMCAxdjExaDEyVjFIMXoiLz48Y2lyY2xlIGlkPSLmpK3lnIblvaIiIGNsYXNzPSJzdDAiIGN4PSIxMCIgY3k9IjQiIHI9IjEiLz48cGF0aCBpZD0iUGF0aCIgY2xhc3M9InN0MCIgZD0iTTguNSAxMS4ybC00LTQuMUwxIDEwLjdWOS4yYzEuNy0xLjYgMi43LTIuNSAzLTIuOC40LS41LjctLjQgMSAwTDguNSAxMCAxMSA3LjNjLjQtLjUuNi0uNSAxLS4xbDIgMi44djEuNWwtMi41LTMuNC0zIDMuMXoiLz48L2c+PC9nPjwvc3ZnPg==)}.ce-contextmenu-image-change{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyIDQpIiBmaWxsPSIjM0Q0NzU3Ij48Y2lyY2xlIGZpbGwtcnVsZT0ibm9uemVybyIgY3g9IjMiIGN5PSIxIiByPSIxIi8+PHBhdGggZD0iTTcuNDczIDguMjIzTDMuNDcgNC4xMDcgMCA3LjY2N3YtMS41QzEuNzE1IDQuNiAyLjcwNyAzLjY2NCAyLjk3NSAzLjM1OGMuNDAyLS40NTcuNjUxLS4zOSAxLjA0MiAwTDcuNDczIDcgOS45NiA0LjM0OWMuNDE0LS40NjIuNjItLjQ2MiAxLjAxMS0uMDcxTDEzIDcuMDZ2MS41bC0yLjUxLTMuNDEtMy4wMTcgMy4wNzJ6Ii8+PC9nPjxwYXRoIGQ9Ik02IDEuNUgxLjV2MTJoMTN2LTRWMTNhLjUuNSAwIDAxLS41LjVIMmEuNS41IDAgMDEtLjUtLjVWMmEuNS41IDAgMDEuNS0uNWg0em04LjUgOFY2bC0uNS41aDFsLS41LS41djMuNXpNNiAxLjVoNEw5LjUgMXYxbC41LS41SDZ6IiBzdHJva2U9IiMzRDQ3NTciLz48cGF0aCBkPSJNMTMuMDg1IDEuMzE2bC0zLjgxNCA0YTEgMSAwIDAwMS40NTggMS4zNjhsMy44MTUtNGExIDEgMCAxMC0xLjQ1OS0xLjM2OHoiIGZpbGw9IiMzRDQ3NTciIGZpbGwtcnVsZT0ibm9uemVybyIvPjwvZz48L3N2Zz4=)}.ce-contextmenu-insert-row-col{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBzdHJva2U9IiMzRDQ3NTciIGQ9Ik04LjUgNS41aDZ2NGgtNnoiLz48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNNCA3djFoMlY3em0tMyAuNUw0IDV2NXpNMSAxaDEydjFIMXptMCAxMmgxMnYxSDF6Ii8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-insert-top-row{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNOCA1SDd2M2gxem0tLjUtM0wxMCA1SDV6Ii8+PHJlY3Qgc3Ryb2tlPSIjM0Q0NzU3IiB4PSIxLjUiIHk9IjEwLjUiIHdpZHRoPSIxMiIgaGVpZ2h0PSIzIiByeD0iMSIvPjwvZz48L3N2Zz4=)}.ce-contextmenu-insert-bottom-row{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNNyAxMWgxVjhIN3ptLjUgM0w1IDExaDV6Ii8+PHJlY3Qgc3Ryb2tlPSIjM0Q0NzU3IiB4PSIxLjUiIHk9IjIuNSIgd2lkdGg9IjEyIiBoZWlnaHQ9IjMiIHJ4PSIxIi8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-insert-left-col{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNMTEgN3YxaDNWN3ptLTMgLjVMMTEgNXY1eiIvPjxyZWN0IHN0cm9rZT0iIzNENDc1NyIgdHJhbnNmb3JtPSJyb3RhdGUoOTAgNCA3LjUpIiB4PSItMiIgeT0iNiIgd2lkdGg9IjEyIiBoZWlnaHQ9IjMiIHJ4PSIxIi8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-insert-right-col{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNNSA4VjdIMnYxem0zLS41TDUgMTBWNXoiLz48cmVjdCBzdHJva2U9IiMzRDQ3NTciIHRyYW5zZm9ybT0icm90YXRlKDkwIDEyIDcuNSkiIHg9IjYiIHk9IjYiIHdpZHRoPSIxMiIgaGVpZ2h0PSIzIiByeD0iMSIvPjwvZz48L3N2Zz4=)}.ce-contextmenu-delete-row-col{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBzdHJva2U9IiM5MjlBQTgiIGQ9Ik04LjUgNi41aDZ2MmgtNnoiLz48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNMiAxMmgxMXYxSDJ6TTIgMmgxMXYxSDJ6bS42MyAzTDcgOS4zNWwtLjYzNS42NUwyIDUuNjN6Ii8+PHBhdGggZmlsbD0iIzNENDc1NyIgZD0iTTIgOS4zNjNMNi4zNTUgNSA3IDUuNzA3IDIuNjk1IDEweiIvPjwvZz48L3N2Zz4=)}.ce-contextmenu-delete-row{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBzdHJva2U9IiM5MjlBQTgiIGQ9Ik04LjUgNS41aDZ2NGgtNnoiLz48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNMSAxM2gxMnYxSDF6TTEgMWgxMnYxSDF6bTAgNGgxdjFIMXptMSAxaDF2MUgyem0xIDFoMXYxSDN6bTEtMWgxdjFINHptMS0xaDF2MUg1ek00IDhoMXYxSDR6TTIgOGgxdjFIMnptMyAxaDF2MUg1ek0xIDloMXYxSDF6Ii8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-delete-col{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBzdHJva2U9IiM5MjlBQTgiIGQ9Ik01LjUgNy41di02aDR2NnoiLz48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNMTMgMTVWM2gxdjEyek0xIDE1VjNoMXYxMnptNCAwdi0xaDF2MXptMS0xdi0xaDF2MXptMS0xdi0xaDF2MXptLTEtMXYtMWgxdjF6bS0xLTF2LTFoMXYxem0zIDF2LTFoMXYxem0wIDJ2LTFoMXYxem0xLTN2LTFoMXYxem0wIDR2LTFoMXYxeiIvPjwvZz48L3N2Zz4=)}.ce-contextmenu-delete-table{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMTQgMTNoLTF2LTNIMnYzSDF2LTNhMSAxIDAgMDExLTFoMTFhMSAxIDAgMDExIDF2M3oiIGZpbGwtcnVsZT0ibm9uemVybyIvPjxwYXRoIGQ9Ik01LjYyNSAyTDEwIDYuMzc1IDkuMzc1IDcgNSAyLjYyNXoiLz48cGF0aCBkPSJNNSA2LjM3NUw5LjM3NSAybC42MjUuNjI1TDUuNjI1IDd6Ii8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-merge-cell{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNiAxdjFIMnYxMWg0djFIMmExIDEgMCAwMS0xLTFWMmExIDEgMCAwMTEtMWg0em0zIDBoNGExIDEgMCAwMTEgMXYxMWExIDEgMCAwMS0xIDFIOXYtMWg0VjJIOVYxeiIvPjxwYXRoIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTYgMWgxdjRINnptMiAwaDF2NEg4eiIvPjxwYXRoIGQ9Ik04IDcuNUwxMCA2djN6bS0xIDBMNSA2djN6Ii8+PHBhdGggZD0iTTkgN2gzdjFIOXpNMyA3aDN2MUgzeiIvPjxwYXRoIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTggMTBoMXY0SDh6bS0yIDBoMXY0SDZ6Ii8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-merge-cancel-cell{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNiAxdjFIMnYxMWg0djFIMmExIDEgMCAwMS0xLTFWMmExIDEgMCAwMTEtMWg0em0zIDBoNGExIDEgMCAwMTEgMXYxMWExIDEgMCAwMS0xIDFIOXYtMWg0VjJIOVYxeiIvPjxwYXRoIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTYgMWgxdjRINnptMiAwaDF2NEg4eiIvPjxwYXRoIGQ9Ik0zIDcuNUw1IDZ2M3ptOSAwTDEwIDZ2M3oiLz48cGF0aCBkPSJNNCA3aDN2MUg0em00IDBoM3YxSDh6Ii8+PHBhdGggZmlsbC1ydWxlPSJub256ZXJvIiBkPSJNOCAxMGgxdjRIOHptLTIgMGgxdjRINnoiLz48L2c+PC9zdmc+)}.ce-contextmenu-vertical-align{background-image:url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHdpZHRoPSIxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMiAxM2gxMnYxSDJ6bTAtM2g4djFIMnptMC0zaDEydjFIMnptMC02aDEydjFIMnptMCAzaDh2MUgyeiIgZmlsbD0iIzNkNDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}.ce-contextmenu-vertical-align-top{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTggOEg3djZoMXptLS41LTNMMTAgOEg1ek0yIDNoMTF2MUgyeiIgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}.ce-contextmenu-vertical-align-middle{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAxMkg3djNoMXptLS41LTNsMi41IDNINXpNNyAzaDFWMEg3em0uNSAzTDUgM2g1ek0yIDdoMTF2MUgyeiIgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}.ce-contextmenu-vertical-align-bottom{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgOWgxVjNIN3ptLjUgM0w1IDloNXpNMiAxM2gxMXYxSDJ6IiBmaWxsPSIjM0Q0NzU3IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=)}.ce-contextmenu-border-all{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iIzNENDc1NyIvPjxwYXRoIGZpbGw9IiMzRDQ3NTciIGQ9Ik0zIDhoMTF2MUgzeiIvPjxwYXRoIGZpbGw9IiMzRDQ3NTciIGQ9Ik05IDN2MTFIOFYzeiIvPjwvc3ZnPg==)}.ce-contextmenu-border-empty{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMyAzaC0xVjJoMWExIDEgMCAwMTEgMXYxaC0xVjN6bS0zLTF2MUg4LjV2MmgtMVYzSDZWMmg0ek00IDJ2MUgzdjFIMlYzYTEgMSAwIDAxMS0xaDF6TTIgNmgxdjEuNWgydjFIM1YxMEgyVjZ6bTAgNmgxdjFoMXYxSDNhMSAxIDAgMDEtMS0xdi0xem00IDJ2LTFoMS41di0yaDF2MkgxMHYxSDZ6bTYgMHYtMWgxdi0xaDF2MWExIDEgMCAwMS0xIDFoLTF6bTItNGgtMVY4LjVoLTJ2LTFoMlY2aDF2NHpNOC41IDcuNXYtMWgtMXYxaC0xdjFoMXYxaDF2LTFoMXYtMWgtMXoiIGZpbGw9IiNBQUFDQjAiLz48L3N2Zz4=)}.ce-contextmenu-border-dash{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMyAzaC0xVjJoMWExIDEgMCAwMTEgMXYxaC0xVjN6bS0zLTF2MUg4LjV2MmgtMVYzSDZWMmg0ek00IDJ2MUgzdjFIMlYzYTEgMSAwIDAxMS0xaDF6TTIgNmgxdjEuNWgydjFIM1YxMEgyVjZ6bTAgNmgxdjFoMXYxSDNhMSAxIDAgMDEtMS0xdi0xem00IDJ2LTFoMS41di0yaDF2MkgxMHYxSDZ6bTYgMHYtMWgxdi0xaDF2MWExIDEgMCAwMS0xIDFoLTF6bTItNGgtMVY4LjVoLTJ2LTFoMlY2aDF2NHpNOC41IDcuNXYtMWgtMXYxaC0xdjFoMXYxaDF2LTFoMXYtMWgtMXoiIGZpbGw9IiMwMDAwMDAiLz48L3N2Zz4=)}.ce-contextmenu-border-external{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iIzNENDc1NyIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOSA1VjNIOHYyaDF6bTAgOXYtMkg4djJoMXpNNSA4SDN2MWgyVjh6bTkgMGgtMnYxaDJWOHpNOSA3djFoMXYxSDl2MUg4VjlIN1Y4aDFWN2gxeiIgZmlsbD0iI0FBQUNCMCIvPjwvc3ZnPg==)}.ce-contextmenu-border-internal{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOSA1VjNIOHYyaDF6bTAgOXYtMkg4djJoMXpNNSA4SDN2MWgyVjh6bTkgMGgtMnYxaDJWOHpNOSA3djFoMXYxSDl2MUg4VjlIN1Y4aDFWN2gxeiIgZmlsbD0iIzNENDc1NyIvPjwvc3ZnPg==)}.ce-contextmenu-border-td{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgZD0iTTguNSAyLjUgdjYgaC02Ii8+PC9zdmc+)}.ce-contextmenu-border-td-top{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgc3Ryb2tlLXdpZHRoPSIyIiBkPSJNMi41IDMgaDEyIi8+PC9zdmc+)}.ce-contextmenu-border-td-left{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgc3Ryb2tlLXdpZHRoPSIyIiBkPSJNMyAzIHYxMSIvPjwvc3ZnPg==)}.ce-contextmenu-border-td-bottom{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgc3Ryb2tlLXdpZHRoPSIyIiBkPSJNMi41IDE0IGgxMiIvPjwvc3ZnPg==)}.ce-contextmenu-border-td-right{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgc3Ryb2tlLXdpZHRoPSIyIiBkPSJNMTQgMyB2MTEiLz48L3N2Zz4=)}.ce-contextmenu-border-td-forward{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIgLz48cGF0aCBzdHJva2U9IiMzRDQ3NTciIGQ9Ik0xNCAzIGwtMTEgMTEiIC8+PC9zdmc+)}.ce-contextmenu-border-td-back{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIgLz48cGF0aCBzdHJva2U9IiMzRDQ3NTciIGQ9Ik0zIDMgbDExIDExIiAvPjwvc3ZnPg==)}.ce-hyperlink-popup{background:#fff;box-shadow:0 2px 12px #626b8433;border-radius:2px;color:#3d4757;padding:12px 16px;position:absolute;z-index:1;text-align:center;display:none}.ce-hyperlink-popup a{min-width:100px;max-width:300px;font-size:12px;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;color:#00f}.ce-zone-indicator>div{padding:3px 6px;color:#000;font-size:12px;background:rgb(218 231 252);position:absolute;transform-origin:0 0}.ce-zone-indicator-border__top,.ce-zone-indicator-border__bottom,.ce-zone-indicator-border__left,.ce-zone-indicator-border__right{display:block;position:absolute;z-index:0}.ce-zone-indicator-border__top{border-top:2px dashed rgb(238,238,238)}.ce-zone-indicator-border__bottom{border-top:2px dashed rgb(238,238,238);width:100%}.ce-zone-indicator-border__left{border-left:2px dashed rgb(238,238,238)}.ce-zone-indicator-border__right{border-right:2px dashed rgb(238,238,238)}.ce-zone-tip{display:none;align-items:center;height:30px;white-space:nowrap;position:fixed;opacity:.9;background-color:#000;padding:0 5px;border-radius:4px;z-index:9;transition:all .3s;outline:none;user-select:none;pointer-events:none;transform:translate(10px,10px)}.ce-zone-tip.show{display:flex}.ce-zone-tip span{color:#fff;font-size:12px}.ce-inputarea{width:100px;height:30px;min-width:0;min-height:0;margin:0;padding:0;left:0;top:0;letter-spacing:0;font-size:12px;position:absolute;z-index:-1;outline:none;resize:none;border:none;overflow:hidden;color:transparent;user-select:none;caret-color:transparent;background-color:transparent}.ce-cursor{width:1px;height:20px;left:0;right:0;position:absolute;outline:none;background-color:#000;pointer-events:none}.ce-cursor.ce-cursor--animation{animation-duration:1s;animation-iteration-count:infinite;animation-name:cursorAnimation}@keyframes cursorAnimation{0%{opacity:1}13%{opacity:0}50%{opacity:0}63%{opacity:1}to{opacity:1}}.ce-float-image{position:absolute;opacity:.5;pointer-events:none}.dialog-mask{position:fixed;left:0;top:0;width:100%;height:100%;opacity:.5;background:#000000;z-index:99}.dialog-container{position:fixed;top:0;right:0;bottom:0;left:0;overflow:auto;z-index:999;margin:0;display:flex;justify-content:center;align-items:center}.dialog{position:absolute;padding:0 30px 30px;background:#ffffff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px}.dialog-title{position:relative;border-bottom:1px solid #e2e6ed;margin-bottom:30px;height:60px;display:flex;align-items:center;justify-content:space-between}.dialog-title i{width:16px;height:16px;cursor:pointer;display:inline-block;background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOC45IDguMTkybDQuMjQyIDQuMjQzLS43MDcuNzA3TDguMTkyIDguOSAzLjk1IDEzLjE0MmwtLjcwNy0uNzA3IDQuMjQyLTQuMjQzTDMuMjQzIDMuOTVsLjcwNy0uNzA3IDQuMjQyIDQuMjQyIDQuMjQzLTQuMjQyLjcwNy43MDdMOC45IDguMTkyeiIgZmlsbD0iIzZBNkE2QSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}.dialog-option__item{margin-bottom:18px;display:flex;align-items:center;justify-content:space-between}.dialog-option__item span{margin-right:12px;font-size:14px;color:#3d4757;position:relative}.dialog-option__item input,.dialog-option__item select{width:276px;height:28px;border-radius:2px;border:1px solid #d3d3d3;min-height:28px;padding:5px;box-sizing:border-box;outline:none;appearance:none;user-select:none;font-family:inherit}.dialog-option__item textarea{width:276px;height:58px;border-radius:2px;border:1px solid #d3d3d3;min-height:58px;padding:5px;box-sizing:border-box;outline:none;appearance:none;user-select:none;font-family:inherit}.dialog-option__item input:focus,.dialog-option__item textarea:focus{border-color:#4991f2}.dialog-option__item--require:before{content:"*";color:#f56c6c;margin-right:4px;position:absolute;left:-8px}.dialog-menu{display:flex;align-items:center;justify-content:flex-end}.dialog-menu button{position:relative;display:inline-block;border:1px solid #e2e6ed;border-radius:2px;background:#ffffff;line-height:22px;padding:0 16px;white-space:nowrap;cursor:pointer}.dialog-menu button:hover{background:rgba(25,55,88,.04)}.dialog-menu__cancel{margin-right:16px}.dialog-menu button[type=submit]{color:#fff;background:#4991f2;border-color:#4991f2}.dialog-menu button[type=submit]:hover{background:#5b9cf3;border-color:#5b9cf3}.searchable-select{position:relative;width:276px;height:30px;box-sizing:border-box}.searchable-select__input-wrapper{position:relative;display:flex;align-items:center;width:100%;height:100%;border:1px solid #d3d3d3}.searchable-select__input-wrapper .searchable-select__input{border:none}.searchable-select__input-wrapper .searchable-select__arrow{margin-right:0;margin-top:-12px}.searchable-select__input{width:100%;height:30px;border-radius:2px;border:1px solid #d3d3d3;padding:5px 30px 5px 5px;box-sizing:border-box;outline:none;font-family:inherit;font-size:14px;cursor:pointer;background-color:#fff}.searchable-select__input:focus{border-color:#4991f2}.searchable-select__arrow{position:absolute;right:8px;top:50%;transform:translateY(-50%);font-size:10px;color:#666;cursor:pointer;user-select:none;line-height:1;z-index:1}.searchable-select__dropdown{position:absolute;top:calc(100% + 4px);left:0;width:100%;background:#ffffff;border:1px solid #d3d3d3;border-radius:2px;box-shadow:0 2px 8px #00000026;max-height:200px;overflow-y:auto;z-index:1000}.searchable-select__option{padding:8px 12px;cursor:pointer;font-size:14px;color:#3d4757;transition:background-color .2s;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.searchable-select__option:hover{background-color:#f5f7fa}.searchable-select__option--selected{background-color:#ecf5ff;color:#4991f2;font-weight:500}.searchable-select__option--empty{color:#999;cursor:not-allowed;text-align:center;padding:12px}.searchable-select__option--empty:hover{background-color:transparent}.searchable-select__dropdown::-webkit-scrollbar{width:6px}.searchable-select__dropdown::-webkit-scrollbar-thumb{background-color:#c0c4cc;border-radius:3px}.searchable-select__dropdown::-webkit-scrollbar-thumb:hover{background-color:#909399}.searchable-select__dropdown::-webkit-scrollbar-track{background-color:#f5f7fa}')),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
|
|
2
|
-
(function(c,Ie){typeof exports=="object"&&typeof module!="undefined"?Ie(exports):typeof define=="function"&&define.amd?define(["exports"],Ie):(c=typeof globalThis!="undefined"?globalThis:c||self,Ie(c["canvas-editor"]={}))})(this,function(c){"use strict";var Ie="";const xe="0.0.1-beta.
|
|
2
|
+
(function(c,Ie){typeof exports=="object"&&typeof module!="undefined"?Ie(exports):typeof define=="function"&&define.amd?define(["exports"],Ie):(c=typeof globalThis!="undefined"?globalThis:c||self,Ie(c["canvas-editor"]={}))})(this,function(c){"use strict";var Ie="";const xe="0.0.1-beta.21";c.MaxHeightRatio=void 0,function(o){o.HALF="half",o.ONE_THIRD="one-third",o.QUARTER="quarter"}(c.MaxHeightRatio||(c.MaxHeightRatio={})),c.NumberType=void 0,function(o){o.ARABIC="arabic",o.CHINESE="chinese"}(c.NumberType||(c.NumberType={})),c.ImageDisplay=void 0,function(o){o.INLINE="inline",o.BLOCK="block",o.SURROUND="surround",o.FLOAT_TOP="float-top",o.FLOAT_BOTTOM="float-bottom"}(c.ImageDisplay||(c.ImageDisplay={})),c.LocationPosition=void 0,function(o){o.BEFORE="before",o.AFTER="after",o.OUTER_BEFORE="outer-before",o.OUTER_AFTER="outer-after"}(c.LocationPosition||(c.LocationPosition={})),c.FlexDirection=void 0,function(o){o.ROW="row",o.COLUMN="column"}(c.FlexDirection||(c.FlexDirection={}));const w="\u200B",Zt=`
|
|
3
3
|
`,Je=" ",Fn=" ",_i=["\xB7","\u3001",":","\uFF1A",",","\uFF0C",".","\u3002",";","\uFF1B","?","\uFF1F","!","\uFF01"],Wn={[c.MaxHeightRatio.HALF]:1/2,[c.MaxHeightRatio.ONE_THIRD]:1/3,[c.MaxHeightRatio.QUARTER]:1/4},Vn={ENGLISH:"A-Za-z",SPANISH:"A-Za-z\xC1\xC9\xCD\xD3\xDA\xE1\xE9\xED\xF3\xFA\xD1\xF1\xDC\xFC",FRENCH:"A-Za-z\xC0\xC2\xC7\xE0\xE2\xE7\xC9\xE9\xC8\xE8\xCA\xEA\xCB\xEB\xCE\xEE\xCF\xEF\xD4\xF4\xD9\xF9\xDB\xFB\u0178\xFF",GERMAN:"A-Za-z\xC4\xE4\xD6\xF6\xDC\xFC\xDF",RUSSIAN:"\u0410-\u042F\u0430-\u044F\u0401\u0451",PORTUGUESE:"A-Za-z\xC1\xC9\xCD\xD3\xDA\xE1\xE9\xED\xF3\xFA\xC3\xD5\xE3\xF5\xC7\xE7",ITALIAN:"A-Za-z\xC0\xE0\xC8\xE8\xC9\xE9\xCC\xEC\xCD\xED\xCE\xEE\xD3\xF3\xD2\xF2\xD9\xF9",DUTCH:"A-Za-z\xC0\xE0\xC1\xE1\xC2\xE2\xC4\xE4\xC8\xE8\xC9\xE9\xCA\xEA\xCB\xEB\xCC\xEC\xCD\xED\xCE\xEE\xCF\xEF\xD3\xF3\xD2\xF2\xD4\xF4\xD6\xF6\xD9\xF9\xDB\xFB\xDC\xFC",SWEDISH:"A-Za-z\xC5\xE5\xC4\xE4\xD6\xF6",GREEK:"\u0391\u03B1\u0392\u03B2\u0393\u03B3\u0394\u03B4\u0395\u03B5\u0396\u03B6\u0397\u03B7\u0398\u03B8\u0399\u03B9\u039A\u03BA\u039B\u03BB\u039C\u03BC\u039D\u03BD\u039E\u03BE\u039F\u03BF\u03A0\u03C0\u03A1\u03C1\u03A3\u03C3\u03C2\u03A4\u03C4\u03A5\u03C5\u03A6\u03C6\u03A7\u03C7\u03A8\u03C8\u03A9\u03C9"},zi="\u4E2D";c.RowFlex=void 0,function(o){o.LEFT="left",o.CENTER="center",o.RIGHT="right",o.ALIGNMENT="alignment",o.JUSTIFY="justify"}(c.RowFlex||(c.RowFlex={}));const ve=/[0-9.]/,$i=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,ji=/[#*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,qi=new RegExp(`${ji.source}|${$i.source}`,"g"),to=/[、,。?!;:……「」“”‘’*()【】〔〕〖〗〘〙〚〛《》———﹝﹞–—\\/·.,!?;:`~<>()[\]{}'"|]/,Ae=new RegExp(`^[${w}
|
|
4
4
|
]`),eo=/[^0-9\+\-\.eE,]/,no=/\s/;function io(o,t){let e;return function(...n){e&&window.clearTimeout(e),e=window.setTimeout(()=>{o.apply(this,n)},t)}}function oo(o,t){let e=0,n;return function(...i){const r=Date.now();r-e>=t?(window.clearTimeout(n),o.apply(this,i),e=r):(window.clearTimeout(n),n=window.setTimeout(()=>{o.apply(this,i),e=r},t))}}function Be(o,t){if(!o||typeof o!="object")return o;let e={};return Array.isArray(o)?e=o.map(n=>Be(n,t)):Object.keys(o).forEach(n=>{t.includes(n)||(e[n]=Be(o[n],t))}),e}function et(o){if(typeof structuredClone=="function")return structuredClone(o);if(!o||typeof o!="object")return o;let t={};return Array.isArray(o)?t=o.map(e=>et(e)):Object.keys(o).forEach(e=>{t[e]=et(o[e])}),t}function ke(o){return o&&o.nodeType===1&&o.tagName.toLowerCase()==="body"}function Xe(o,t,e){if(o&&!ke(o))for(o=e?o:o.parentNode;o;){if(!t||t(o)||ke(o))return t&&!t(o)&&ke(o)?null:o;o=o.parentNode}return null}function q(){function o(){return((1+Math.random())*65536|0).toString(16).substring(1)}return o()+o()+"-"+o()+"-"+o()+"-"+o()+"-"+o()+o()+o()}function Ft(o){const t=[];if(Intl.Segmenter){const n=new Intl.Segmenter().segment(o);for(const{segment:i}of n)t.push(i)}else{const e=new Map;for(const i of o.matchAll(qi))e.set(i.index,i[0]);let n=0;for(;n<o.length;){const i=e.get(n);i?(t.push(i),n+=i.length):(t.push(o[n]),n++)}}return t}function Yn(o,t){const e=document.createElement("a");e.href=o,e.download=t,e.click()}function so(o,t){ro(3,o,t)}function ro(o,t,e){let n=0,i=0;const r=function(s){n=new Date().getTime()-i<300?n+1:0,i=new Date().getTime(),n>=o-1&&(e(s),n=0)};t.addEventListener("click",r)}function Ne(o){return Object.prototype.toString.call(o)==="[object Object]"}function _e(o){return Array.isArray(o)}function ze(o){return Object.prototype.toString.call(o)==="[object Number]"}function lo(o){return Object.prototype.toString.call(o)==="[object String]"}function Zn(o,t){if(Ne(o)&&Ne(t)){const e=t;for(const[n,i]of Object.entries(o))e[n]?e[n]=Zn(i,e[n]):e[n]=i}else _e(o)&&_e(t)&&t.push(...o);return t}function $e(o){setTimeout(()=>{o()},0)}function ao(o){const t=["\u96F6","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D","\u4E03","\u516B","\u4E5D"],e=["","\u5341","\u767E","\u5343","\u4E07","\u5341","\u767E","\u5343","\u4EBF","\u5341","\u767E","\u5343","\u4E07","\u5341","\u767E","\u5343","\u4EBF"];if(!o||isNaN(o))return"\u96F6";const n=o.toString().split("");let i="";for(let r=0;r<n.length;r++){const s=n.length-1-r;i=`${e[r]}${i}`,i=`${t[Number(n[s])]}${i}`}return i=i.replace(/零(千|百|十)/g,"\u96F6").replace(/十零/g,"\u5341"),i=i.replace(/零+/g,"\u96F6"),i=i.replace(/零亿/g,"\u4EBF").replace(/零万/g,"\u4E07"),i=i.replace(/亿万/g,"\u4EBF"),i=i.replace(/零+$/,""),i=i.replace(/^一十/g,"\u5341"),i}function jt(o,t,e){for(let n=0;n<o.length;n++){const i=o[n],r=t[i];r!==void 0?e[i]=r:delete e[i]}}function Un(o,t){if(!(!t.length||!o.length))for(let e=o.length-1;e>=0;e--)t.includes(o[e])&&o.splice(e,1)}function Wt(o,t){const e={};for(const n in o)t.includes(n)&&(e[n]=o[n]);return e}function wt(o,t){const e={};for(const n in o)t.includes(n)||(e[n]=o[n]);return e}function Ro(o){const e=new TextEncoder().encode(o),n=Array.from(e,r=>String.fromCharCode(r));return window.btoa(n.join(""))}function co(o){let t=o.parentElement;for(;t;){const n=window.getComputedStyle(t).getPropertyValue("overflow-y");if(t.scrollHeight>t.clientHeight&&(n==="auto"||n==="scroll"))return t;t=t.parentElement}return document.documentElement}function En(o,t){return o.length!==t.length?!1:!o.some(e=>!t.includes(e))}function uo(o,t){if(!Ne(o)||!Ne(t))return!1;const e=Object.keys(o),n=Object.keys(t);return e.length!==n.length?!1:!e.some(i=>t[i]!==o[i])}function ho(o,t){const e=o.x,n=o.x+o.width,i=o.y,r=o.y+o.height,s=t.x,l=t.x+t.width,a=t.y,R=t.y+t.height;return!(e>l||n<s||i>R||r<a)}function Cn(o){return o==null}function pe(o){return o.replace(/\r\n|\r/g,`
|
|
5
5
|
`)}function Qn(o,t,e=0){const n=Math.max(0,Math.floor(e));if(n>=o.length)return typeof t=="string"&&t===""?{index:o.length,length:0}:{index:-1,length:0};if(typeof t=="string"){if(t==="")return{index:n,length:0};const a=o.indexOf(t,n);return a===-1?{index:-1,length:0}:{index:a,length:t.length}}const i=t.flags,r=i.includes("g")?i:i+"g",s=new RegExp(t.source,r);s.lastIndex=n;const l=s.exec(o);return l?{index:l.index,length:l[0].length}:{index:-1,length:0}}function bn(o,t){if(!t){o.scrollTop=0;return}const e=[];let n=t.offsetParent;for(;n&&o!==n&&o.contains(n);)e.push(n),n=n.offsetParent;const i=t.offsetTop+e.reduce((a,R)=>a+R.offsetTop,0),r=i+t.offsetHeight,s=o.scrollTop,l=s+o.clientHeight;i<s?o.scrollTop=i:r>l&&(o.scrollTop=r-o.clientHeight)}const go=12,Lo={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF",dragFloatImageDisabled:!1},Ht="editor-component",x="ce",Fe=`${x}-clipboard`,je={print:{imagePreviewerDisabled:!1,backgroundDisabled:!1},readonly:{imagePreviewerDisabled:!1},form:{controlDeletableDisabled:!1}};var Pt;(function(o){o.UP="top",o.DOWN="down",o.LEFT="left",o.RIGHT="right"})(Pt||(Pt={}));const qt=typeof navigator!="undefined"&&/Mac OS X/.test(navigator.userAgent),To=typeof navigator!="undefined"&&/iPad|iPhone/.test(navigator.userAgent),Po=/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),Oo=typeof navigator!="undefined"&&/Firefox/.test(navigator.userAgent);c.ElementType=void 0,function(o){o.TEXT="text",o.IMAGE="image",o.TABLE="table",o.HYPERLINK="hyperlink",o.SUPERSCRIPT="superscript",o.SUBSCRIPT="subscript",o.SEPARATOR="separator",o.PAGE_BREAK="pageBreak",o.CONTROL="control",o.AREA="area",o.CHECKBOX="checkbox",o.RADIO="radio",o.LATEX="latex",o.TAB="tab",o.DATE="date",o.BLOCK="block",o.TITLE="title",o.LIST="list",o.LABEL="label"}(c.ElementType||(c.ElementType={}));const Ct=["bold","color","highlight","font","size","italic","underline","strikeout","textDecoration"],te=["rowFlex","rowMargin","textIndent","marginLeft","marginRight","marginTop","minHeight","whiteSpace"],Mo=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","url","areaId","hyperlinkId","dateId","dateFormat","groupIds","rowMargin","textIndent","marginLeft","marginRight","marginTop","minHeight","whiteSpace","textDecoration"],fo=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","rowMargin","textIndent","marginLeft","marginRight","marginTop","minHeight","whiteSpace","dashArray","trList","tableToolDisabled","borderType","borderColor","translateX","width","height","url","colgroup","valueList","control","checkbox","radio","dateFormat","block","level","title","listType","listStyle","listWrap","groupIds","conceptId","imgDisplay","imgFloatPosition","imgToolDisabled","imgPreviewDisabled","imgCrop","imgCaption","textDecoration","extension","externalId","areaId","area","hide","label","labelId","lineWidth","formInput"],So=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","slashTypes","disabled","deletable"],Te=["tdId","trId","tableId"],qe=["level","titleId","title"],We=["listId","listType","listStyle"],tn=["control","controlId","controlComponent"],Gt=["font","size","bold","highlight","italic","strikeout"],ie=["areaId","area"],Dn=[...Te,...qe,...We,...ie],Qt=[c.ElementType.TEXT,c.ElementType.HYPERLINK,c.ElementType.SUBSCRIPT,c.ElementType.SUPERSCRIPT,c.ElementType.CONTROL,c.ElementType.DATE],mo=[c.ElementType.IMAGE,c.ElementType.LATEX],Io=[c.ElementType.BLOCK,c.ElementType.PAGE_BREAK,c.ElementType.SEPARATOR,c.ElementType.TABLE],Xo=["HR","TABLE","UL","OL"],No=[c.ElementType.TITLE,c.ElementType.LIST],en=class{constructor(o){this.element=o}_defineIframeProperties(o){Object.defineProperties(o,{parent:{get:()=>null},__POWERED_BY_CANVAS_EDITOR__:{get:()=>!0}})}render(o){const{iframeBlock:t}=this.element.block||{},e=document.createElement("iframe");e.setAttribute("data-id",this.element.id),e.sandbox.add(...(t==null?void 0:t.sandbox)||en.sandbox),e.setAttribute("allow",[(t==null?void 0:t.allow)||en.allow].join(" ")),e.style.border="none",e.style.width="100%",e.style.height="100%",t!=null&&t.src?e.src=t.src:t!=null&&t.srcdoc&&(e.srcdoc=t.srcdoc),o.append(e),this._defineIframeProperties(e.contentWindow)}};let Pe=en;Pe.sandbox=["allow-scripts","allow-same-origin"],Pe.allow=["fullscreen"];class Kn{constructor(t){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=n=>{for(const i of n)if(i.type===c.ElementType.TABLE){const r=i.trList;for(let s=0;s<r.length;s++){const l=r[s];for(let a=0;a<l.tdList.length;a++){const R=l.tdList[a];e(R.value)}}}else i.type===c.ElementType.IMAGE&&t.push(i)};return e(this.draw.getOriginalMainElementList()),t}_countImagesBeforeTarget(t,e){let n=0;for(const i of t){if(i===e)break;if(i.type===c.ElementType.TABLE){const r=i.trList;for(const s of r)for(const l of s.tdList)n+=this._countImagesBeforeTarget(l.value,e)}else i.type===c.ElementType.IMAGE&&n++}return n}createFloatImage(t){const{scale:e}=this.options;let n=this.floatImageContainer,i=this.floatImage;n||(n=document.createElement("div"),n.classList.add(`${x}-float-image`),this.container.append(n),this.floatImageContainer=n),i||(i=document.createElement("img"),n.append(i),this.floatImage=i),n.style.display="none",i.style.width=`${t.width*e}px`,i.style.height=`${t.height*e}px`;const r=this.draw.getHeight(),s=this.draw.getPageGap(),l=this.draw.getPageNo()*(r+s),a=t.imgFloatPosition;n.style.left=`${a.x*e}px`,n.style.top=`${l+a.y*e}px`,i.src=t.value}dragFloatImage(t,e){if(!this.floatImageContainer)return;this.floatImageContainer.style.display="block";const n=parseFloat(this.floatImageContainer.style.left)+t,i=parseFloat(this.floatImageContainer.style.top)+e;this.floatImageContainer.style.left=`${n}px`,this.floatImageContainer.style.top=`${i}px`}destroyFloatImage(){this.floatImageContainer&&(this.floatImageContainer.style.display="none")}addImageObserver(t){this.draw.getImageObserver().add(t)}getFallbackImage(t,e){const i=(t-Math.ceil(t/8)*8)/2,r=(e-Math.ceil(e/8)*8)/2,s=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}" viewBox="0 0 ${t} ${e}">
|
|
@@ -88,7 +88,7 @@ ${T||`${P+1}.`}${t(O)}${M?`
|
|
|
88
88
|
`,r.append(a),l.selectNodeContents(r),s==null||s.removeAllRanges(),s==null||s.addRange(l),document.execCommand("copy"),r.remove()}Ns({text:o,elementList:e})}async function ti(o,t){const e=re(o,t);document.body.append(e);const n=e.innerText;e.remove();const i=e.innerHTML;!n&&!i&&!o.length||await ps(n,i,rt(o))}function Fs(o){let t=!1;for(let e=0;e<o.items.length;e++)if(o.items[e].kind==="file"){t=!0;break}return t}function Ln(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled()||e.getControl().getIsDisabledPasteControl())return;const n=e.getRange(),{startIndex:i}=n.getRange(),r=e.getElementList();if(~i&&!n.getIsSelectAll()){const s=r[i];if((s==null?void 0:s.titleId)||(s==null?void 0:s.listId)){let l=0;for(;l<t.length;){const a=t[l];if(s.titleId&&/^\n/.test(a.value))break;if(No.includes(a.type)){if(t.splice(l,1),a.valueList)for(let R=0;R<a.valueList.length;R++){const d=a.valueList[R];d.value===w||d.value===`
|
|
89
89
|
`||(t.splice(l,0,d),l++)}l--}l++}}It(r,t,i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function ei(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=le(t,{innerWidth:e.getOriginalInnerWidth()});Ln(o,n)}function Tn(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=e.getRange(),{startIndex:i}=n.getRange(),r=e.getElementList(),s=new FileReader;s.readAsDataURL(t),s.onload=()=>{const l=new Image,a=s.result;l.src=a,l.onload=()=>{const R={value:a,type:c.ElementType.IMAGE,width:l.width,height:l.height};~i&&It(r,[R],i,{editorOptions:e.getOptions()}),e.insertElementList([R])}}}function Ws(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=t.clipboardData;if(!n)return;const{paste:i}=e.getOverride();if(i){const s=i(t);if((s==null?void 0:s.preventDefault)!==!1)return}if(!Fs(n)){const s=n.getData("text"),l=jn();if(l&&pe(s)===pe(l.text)){Ln(o,l.elementList);return}}qn();let r=!1;for(let s=0;s<n.items.length;s++)if(n.items[s].type==="text/html"){r=!0;break}for(let s=0;s<n.items.length;s++){const l=n.items[s];if(l.kind==="string"){if(l.type==="text/plain"&&!r){l.getAsString(a=>{o.input(a)});break}if(l.type==="text/html"&&r){l.getAsString(a=>{ei(o,a)});break}}else if(l.kind==="file"&&l.type.includes("image")){const a=l.getAsFile();a&&Tn(o,a)}}}async function Vs(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const{paste:n}=e.getOverride();if(n){const s=n();if((s==null?void 0:s.preventDefault)!==!1)return}const i=await navigator.clipboard.readText(),r=jn();if(r&&pe(i)===pe(r.text)){Ln(o,r.elementList);return}if(qn(),t!=null&&t.isPlainText)i&&o.input(i);else{const s=await navigator.clipboard.read();let l=!1;for(const a of s)if(a.types.includes("text/html")){l=!0;break}for(const a of s)if(a.types.includes("text/plain")&&!l){const d=await(await a.getType("text/plain")).text();d&&o.input(d)}else if(a.types.includes("text/html")&&l){const d=await(await a.getType("text/html")).text();d&&ei(o,d)}else if(a.types.some(R=>R.startsWith("image/"))){const R=a.types.find(u=>u.startsWith("image/")),d=await a.getType(R);Tn(o,d)}}}class Ys{constructor(t,e){this.draw=t,this.container=t.getContainer(),this.canvasEvent=e,this.eventBus=t.getEventBus();const n=document.createElement("textarea");n.autocomplete="off",n.classList.add(`${x}-inputarea`),n.innerText="",this.container.append(n),this.agentCursorDom=n,n.onkeydown=i=>this._keyDown(i),n.oninput=this._input.bind(this),n.onpaste=i=>this._paste(i),n.addEventListener("compositionstart",this._compositionstart.bind(this)),n.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.isSubscribe("input")&&this.eventBus.emit("input",t)}_paste(t){this.draw.isReadonly()||!t.clipboardData||(Ws(this.canvasEvent,t),t.preventDefault())}_compositionstart(){this.canvasEvent.compositionstart()}_compositionend(t){this.canvasEvent.compositionend(t)}}class Zs{constructor(t,e){this.ANIMATION_CLASS=`${x}-cursor--animation`,this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${x}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new Ys(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(Po&&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:n,cursor:i}=this.options,{color:r,width:s,isShow:l=!0,isBlink:a=!0,isFocus:R=!0,hitLineStartIndex:d}={...i,...t},u=this.draw.getHeight(),h=this.draw.getPageGap();this.hitLineStartIndex=d,d&&(e=this.position.getPositionList()[d]);const{metrics:g,coordinate:{leftTop:L,rightTop:T},ascent:O,pageNo:P}=e,S=(this.draw.getZone().isMainActive()?P:this.draw.getPageNo())*(u+h),I=go*n,m=Math.min(g.height/4,I),N=g.height+m*2,F=this.cursorAgent.getAgentCursorDom();R&&setTimeout(()=>{this.focus()});const Z=g.boundingBoxDescent<0?0:g.boundingBoxDescent,W=L[1]+O+Z-(N-m)+S,V=d?L[0]:T[0];if(F.style.left=`${V}px`,F.style.top=`${W+N-I}px`,!l){this.recoveryCursor();return}const p=this.cursorDom.style.top,X=this.draw.isReadonly();this.cursorDom.style.width=`${s*n}px`,this.cursorDom.style.backgroundColor=r,this.cursorDom.style.left=`${V}px`,this.cursorDom.style.top=`${W}px`,this.cursorDom.style.display=X?"none":"block",this.cursorDom.style.height=`${N}px`,a?this._setBlinkTimeout():this._clearBlinkTimeout(),$e(()=>{this.moveCursorToVisible({cursorPosition:e,direction:parseInt(p)>W?Pt.UP:Pt.DOWN})})}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:n}=t;if(!e||!n)return;const{pageNo:i,coordinate:{leftTop:r,leftBottom:s}}=e,l=co(this.container),a={left:0,right:0,top:0,bottom:0},R=l===document.documentElement;if(R)a.right=window.innerWidth,a.bottom=window.innerHeight;else{const{left:T,right:O,top:P,bottom:M}=l.getBoundingClientRect();a.left=T,a.right=O,a.top=P,a.bottom=M}const d=i*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,u=n===Pt.UP,h=s[0]+(R?0:a.left),g=u?r[1]+d:s[1]+d,{maskMargin:L}=this.options;if(a.top+=L[0],a.bottom-=L[2],!(h>=a.left&&h<=a.right&&g>=a.top&&g<=a.bottom)){const{scrollLeft:T,scrollTop:O}=l;u?l.scroll(T,O-(a.top-g)):l.scroll(T,O+g-a.bottom)}}}var Pn;(function(o){o[o.LEFT=0]="LEFT",o[o.CENTER=1]="CENTER",o[o.RIGHT=2]="RIGHT"})(Pn||(Pn={}));function At(o){return qt?o.metaKey:o.ctrlKey}c.KeyMap=void 0,function(o){o.Delete="Delete",o.Backspace="Backspace",o.Enter="Enter",o.Left="ArrowLeft",o.Right="ArrowRight",o.Up="ArrowUp",o.Down="ArrowDown",o.ESC="Escape",o.TAB="Tab",o.META="Meta",o.LEFT_BRACKET="[",o.RIGHT_BRACKET="]",o.COMMA=",",o.PERIOD=".",o.LEFT_ANGLE_BRACKET="<",o.RIGHT_ANGLE_BRACKET=">",o.EQUAL="=",o.MINUS="-",o.PLUS="+",o.A="a",o.B="b",o.C="c",o.D="d",o.E="e",o.F="f",o.G="g",o.H="h",o.I="i",o.J="j",o.K="k",o.L="l",o.M="m",o.N="n",o.O="o",o.P="p",o.Q="q",o.R="r",o.S="s",o.T="t",o.U="u",o.V="v",o.W="w",o.X="x",o.Y="y",o.Z="z",o.A_UPPERCASE="A",o.B_UPPERCASE="B",o.C_UPPERCASE="C",o.D_UPPERCASE="D",o.E_UPPERCASE="E",o.F_UPPERCASE="F",o.G_UPPERCASE="G",o.H_UPPERCASE="H",o.I_UPPERCASE="I",o.J_UPPERCASE="J",o.K_UPPERCASE="K",o.L_UPPERCASE="L",o.M_UPPERCASE="M",o.N_UPPERCASE="N",o.O_UPPERCASE="O",o.P_UPPERCASE="P",o.Q_UPPERCASE="Q",o.R_UPPERCASE="R",o.S_UPPERCASE="S",o.T_UPPERCASE="T",o.U_UPPERCASE="U",o.V_UPPERCASE="V",o.W_UPPERCASE="W",o.X_UPPERCASE="X",o.Y_UPPERCASE="Y",o.Z_UPPERCASE="Z",o.ZERO="0",o.ONE="1",o.TWO="2",o.THREE="3",o.FOUR="4",o.FIVE="5",o.SIX="6",o.SEVEN="7",o.EIGHT="8",o.NINE="9"}(c.KeyMap||(c.KeyMap={}));class Ce{constructor(t,e){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(),n=t[e],i=[];let r=e;for(;r>0;){const l=t[r];if(l.controlId!==n.controlId||l.controlComponent===c.ControlComponent.PREFIX||l.controlComponent===c.ControlComponent.PRE_TEXT)break;l.controlComponent===c.ControlComponent.VALUE&&i.unshift(l),r--}let s=e+1;for(;s<t.length;){const l=t[s];if(l.controlId!==n.controlId||l.controlComponent===c.ControlComponent.POSTFIX||l.controlComponent===c.ControlComponent.POST_TEXT)break;l.controlComponent===c.ControlComponent.VALUE&&i.push(l),s++}return i}setValue(){return-1}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,r=e.elementList||this.control.getElementList(),{startIndex:s}=e.range||this.control.getRange(),l=r[s];let a=s;for(;a>0;){const d=r[a];if(d.controlId!==l.controlId||d.controlComponent===c.ControlComponent.PREFIX||d.controlComponent===c.ControlComponent.PRE_TEXT)break;if(d.controlComponent===c.ControlComponent.CHECKBOX){const u=d.checkbox;u.value=t.includes(u.code)}a--}let R=s+1;for(;R<r.length;){const d=r[R];if(d.controlId!==l.controlId||d.controlComponent===c.ControlComponent.POSTFIX||d.controlComponent===c.ControlComponent.POST_TEXT)break;if(d.controlComponent===c.ControlComponent.CHECKBOX){const u=d.checkbox;u.value=t.includes(u.code)}R++}i.code=t.join(","),this.control.repaintControl({curIndex:s,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:n,endIndex:i}=e;return t.key===c.KeyMap.Backspace||t.key===c.KeyMap.Delete?this.control.removeControl(n):i}cut(){return-1}}class On extends Ce{setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,r=e.elementList||this.control.getElementList(),{startIndex:s}=e.range||this.control.getRange(),l=r[s];let a=s;for(;a>0;){const d=r[a];if(d.controlId!==l.controlId||d.controlComponent===c.ControlComponent.PREFIX||d.controlComponent===c.ControlComponent.PRE_TEXT)break;if(d.controlComponent===c.ControlComponent.RADIO){const u=d.radio;u.value=t.includes(u.code)}a--}let R=s+1;for(;R<r.length;){const d=r[R];if(d.controlId!==l.controlId||d.controlComponent===c.ControlComponent.POSTFIX||d.controlComponent===c.ControlComponent.POST_TEXT)break;if(d.controlComponent===c.ControlComponent.RADIO){const u=d.radio;u.value=t.includes(u.code)}R++}i.code=t.join(","),this.control.repaintControl({curIndex:s,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}}function ni(o){const t=o.getDraw(),e=t.getPosition(),n=t.getRange();o.isAllowDrag=!0,o.cacheRange=et(n.getRange()),o.cacheElementList=t.getElementList(),o.cachePositionList=e.getPositionList(),o.cachePositionContext=e.getPositionContext()}function ii(o,t){const{checkbox:e,control:n}=o;if(!n)t.getCheckboxParticle().setSelect(o);else{const i=n!=null&&n.code?n.code.split(","):[];if(e!=null&&e.value){const s=i.findIndex(l=>l===e.code);i.splice(s,1)}else e!=null&&e.code&&i.push(e.code);const r=t.getControl().getActiveControl();r instanceof Ce&&r.setSelect(i)}}function oi(o,t){const{radio:e,control:n}=o;if(!n)t.getRadioParticle().setSelect(o);else{const i=e!=null&&e.code?[e.code]:[],r=t.getControl().getActiveControl();r instanceof On&&r.setSelect(i)}}function Us(o,t){var K,b;const e=t.getDraw();let n=e.isReadonly();const i=e.getRange(),r=e.getPosition(),s=i.getRange();if(o.button===Pn.RIGHT&&(s.isCrossRowCol||!i.getIsCollapsed()))return;if(!t.isAllowDrag&&!n&&s.startIndex!==s.endIndex&&i.getIsPointInRange(o.offsetX,o.offsetY)){ni(t);return}const a=o.target.dataset.index;a&&e.setPageNo(Number(a)),t.isAllowSelection=!0;const R=et(r.getPositionContext()),d=r.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!d)return;const{index:u,isDirectHit:h,isCheckbox:g,isRadio:L,isImage:T,isLabel:O,isTable:P,tdValueIndex:M,hitLineStartIndex:f}=d;t.mouseDownStartPosition={...d,index:P?M:u,x:o.offsetX,y:o.offsetY};const S=e.getElementList(),I=r.getPositionList(),m=P?M:u,N=S[m],F=!!(h&&T),Z=!!(h&&g),W=!!(h&&L),V=!!(h&&O);if(~u){let Y=m,y=m;if(o.shiftKey){const{startIndex:D}=i.getRange();~D&&r.getPositionContext().tdId===R.tdId&&(m>D?Y=D:y=D)}if(i.setRange(Y,y),r.setCursorPosition(I[m]),n=e.isReadonly(),Z&&!n)ii(N,e);else if(W&&!n)oi(N,e);else if(N.controlComponent===c.ControlComponent.VALUE&&(((K=N.control)==null?void 0:K.type)===c.ControlType.CHECKBOX||((b=N.control)==null?void 0:b.type)===c.ControlType.RADIO)){let D=m;for(;D>0;){const H=S[D];if(H.controlComponent===c.ControlComponent.CHECKBOX){ii(H,e);break}else if(H.controlComponent===c.ControlComponent.RADIO){oi(H,e);break}D--}}else e.render({curIndex:m,isCompute:!1,isSubmitHistory:!1,isSetCursor:!F&&!Z&&!W});f&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:f})}const p=e.getEventBus();V&&p.isSubscribe("labelMousedown")&&p.emit("labelMousedown",{evt:o,element:N});const X=e.getPreviewer();if(X.clearResizer(),F){const Y={dragDisable:n||!N.controlId&&e.getMode()===c.EditorMode.FORM};N.type===c.ElementType.LATEX&&(Y.mime="svg",Y.srcKey="laTexSVG"),X.drawResizer(N,I[m],Y),e.getCursor().drawCursor({isShow:!1}),ni(t),(N.imgDisplay===c.ImageDisplay.SURROUND||N.imgDisplay===c.ImageDisplay.FLOAT_TOP||N.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(N),p.isSubscribe("imageMousedown")&&p.emit("imageMousedown",{evt:o,element:N})}const E=e.getTableTool();E.dispose(),P&&!n&&e.getMode()!==c.EditorMode.FORM&&E.render();const C=e.getHyperlinkParticle();C.clearHyperlinkPopup(),N.type===c.ElementType.HYPERLINK&&(At(o)?C.openHyperlink(N):C.drawHyperlinkPopup(N,I[m]));const U=e.getDateParticle();U.clearDatePicker(),N.type===c.ElementType.DATE&&!n&&U.renderDatePicker(N,I[m])}function Qe(o){const t=q();return Reflect.set(o,"dragId",t),t}function be(o,t){return t.findIndex(e=>e.dragId===o)}function si(o,t,e){const n=e.getDraw();if(o.imgDisplay===c.ImageDisplay.SURROUND||o.imgDisplay===c.ImageDisplay.FLOAT_TOP||o.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM){const i=t.offsetX-e.mouseDownStartPosition.x,r=t.offsetY-e.mouseDownStartPosition.y,s=o.imgFloatPosition;o.imgFloatPosition={x:s.x+i,y:s.y+r,pageNo:n.getPageNo()}}n.getImageParticle().destroyFloatImage()}function Es(o,t){var e,n,i,r,s,l;if(t.isAllowDrop){const a=t.getDraw();if(a.isReadonly()||a.isDisabled()){t.mousedown(o);return}const R=a.getPosition(),d=R.getPositionList(),u=R.getPositionContext(),h=a.getRange(),g=t.cacheRange,L=t.cacheElementList,T=t.cachePositionList,O=t.cachePositionContext,P=h.getRange(),M=g.startIndex===g.endIndex,f=M?g.startIndex-1:g.startIndex,S=g.endIndex;if(P.startIndex>=f&&P.endIndex<=S&&((e=t.cachePositionContext)==null?void 0:e.tdId)===u.tdId){a.clearSideEffect();let tt=!1,j=!1;if(M){const Tt=L[S];if(Tt.type===c.ElementType.IMAGE||Tt.type===c.ElementType.LATEX){if(si(Tt,o,t),Tt.imgDisplay===c.ImageDisplay.SURROUND||Tt.imgDisplay===c.ImageDisplay.FLOAT_TOP||Tt.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)a.getPreviewer().drawResizer(Tt),tt=!0;else{const Dt=T[S];a.getPreviewer().drawResizer(Tt,Dt)}j=Tt.imgDisplay===c.ImageDisplay.SURROUND}}h.replaceRange({...g}),a.render({isCompute:j,isSubmitHistory:tt,isSetCursor:!1});return}const I=L.slice(f+1,S+1),m=I.find(tt=>tt.controlId);if(m){const tt=L[f+1],j=L[S];if(!((!tt.controlId||tt.controlComponent===c.ControlComponent.PREFIX)&&(!j.controlId||j.controlComponent===c.ControlComponent.POSTFIX)||tt.controlId===j.controlId&&tt.controlComponent===c.ControlComponent.PREFIX&&j.controlComponent===c.ControlComponent.POSTFIX||((n=tt.control)==null?void 0:n.type)===c.ControlType.TEXT&&tt.controlComponent===c.ControlComponent.VALUE&&((i=j.control)==null?void 0:i.type)===c.ControlType.TEXT&&j.controlComponent===c.ControlComponent.VALUE)){a.render({curIndex:P.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const N=a.getControl(),F=a.getElementList(),Z=!m||!!F[P.startIndex].controlId||!N.getIsElementListContainFullControl(I),W=a.getOptions(),V=I.map(tt=>{if(!tt.type||tt.type===c.ElementType.TEXT){const j={value:tt.value},Tt=Ct;return Z||Tt.push(...tn),Tt.forEach(Dt=>{const lt=tt[Dt];lt!==void 0&&(j[Dt]=lt)}),j}else{let j=et(tt);return Z&&(j=wt(j,tn)),Mt([j],{isHandleFirstElement:!1,editorOptions:W}),j}});It(F,V,P.startIndex,{editorOptions:a.getOptions()});const p=L[f],X=T[f],E=Qe(L[f]),C=Qe(L[S]),U=V.length;let K=P.startIndex,b=K+U;const Y=N.getActiveControl();if(Y&&L[K].controlComponent!==c.ControlComponent.POSTFIX?(b=Y.setValue(V),K=b-U):a.spliceElementList(F,K+1,0,V),!~b){a.render({isSetCursor:!1});return}const y=Qe(F[K]),D=Qe(F[b]),H=be(E,L),_=be(C,L),v=L[_];if(v.controlId&&v.controlComponent!==c.ControlComponent.POSTFIX)h.replaceRange({...g,startIndex:H,endIndex:_}),(r=N.getActiveControl())==null||r.cut();else{let tt=!0;if(O!=null&&O.isTable){const{tableId:j,trIndex:Tt,tdIndex:Dt}=O;tt=!a.getOriginalElementList().some(k=>{var Q,Xt,G,$t;return k.id===j&&(($t=(G=(Xt=(Q=k==null?void 0:k.trList)==null?void 0:Q[Tt])==null?void 0:Xt.tdList)==null?void 0:G[Dt])==null?void 0:$t.deletable)===!1})}tt&&a.spliceElementList(L,H+1,_-H)}const J=F[P.startIndex],z=d[P.startIndex];let ft=u.index;ft&&(J.tableId&&!p.tableId?X.index<ft&&(ft-=U):!J.tableId&&p.tableId&&z.index<ft&&(ft+=U),R.setPositionContext({...u,index:ft}));const ht=be(y,F),it=be(D,F);h.setRange(M?it:ht,it,P.tableId,P.startTdIndex,P.endTdIndex,P.startTrIndex,P.endTrIndex),a.clearSideEffect();let gt=null;if(M){const j=a.getElementList()[it];(j.type===c.ElementType.IMAGE||j.type===c.ElementType.LATEX)&&(si(j,o,t),gt=j)}if(a.render({isSetCursor:!1}),Y?N.emitControlContentChange():p.controlId&&N.emitControlContentChange({context:{range:g,elementList:L},controlElement:p}),gt)if(gt.imgDisplay===c.ImageDisplay.SURROUND||gt.imgDisplay===c.ImageDisplay.FLOAT_TOP||gt.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)a.getPreviewer().drawResizer(gt);else{const j=R.getPositionList()[it];a.getPreviewer().drawResizer(gt,j)}}else t.isAllowDrag&&((s=t.cacheRange)==null?void 0:s.startIndex)!==((l=t.cacheRange)==null?void 0:l.endIndex)&&t.mousedown(o)}function Cs(o,t){const e=t.getDraw();if(!e.getOptions().pageOuterSelectionDisable)return;const n=e.getPageContainer(),{x:i,y:r,width:s,height:l}=n.getBoundingClientRect();o.x>=i&&o.x<=i+s&&o.y>=r&&o.y<=r+l||t.setIsAllowSelection(!1)}function Qs(o,t){var m;const e=t.getDraw();if(t.isAllowDrag){const N=o.offsetX,F=o.offsetY,{startIndex:Z,endIndex:W}=t.cacheRange,V=t.cachePositionList;for(let X=Z+1;X<=W;X++){const{coordinate:{leftTop:E,rightBottom:C}}=V[X];if(N>=E[0]&&N<=C[0]&&F>=E[1]&&F<=C[1])return}const p=(m=t.cacheRange)==null?void 0:m.startIndex;if(p){const X=t.cacheElementList[p];(X==null?void 0:X.type)===c.ElementType.IMAGE&&(X.imgDisplay===c.ImageDisplay.SURROUND||X.imgDisplay===c.ImageDisplay.FLOAT_TOP||X.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)&&(e.getPreviewer().clearResizer(),e.getImageParticle().dragFloatImage(o.movementX,o.movementY))}t.dragover(o),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const i=o.target.dataset.index;i&&e.setPageNo(Number(i));const r=e.getPosition(),s=r.getPositionByXY({x:o.offsetX,y:o.offsetY});if(!~s.index)return;const{index:l,isTable:a,tdValueIndex:R,tdIndex:d,trIndex:u,tableId:h,trId:g,tdId:L}=s,{index:T,isTable:O,tdIndex:P,trIndex:M,tableId:f}=t.mouseDownStartPosition,S=a?R:l,I=e.getRange();if(a&&O&&(d!==P||u!==M))I.setRange(S,S,h,P,d,M,u),r.setPositionContext({isTable:a,index:l,trIndex:u,tdIndex:d,tdId:L,trId:g,tableId:h});else{let N=~S?S:0;if((O||a)&&f!==h)return;let F=T;if(F>N&&([F,N]=[N,F]),F===N)return;const Z=e.getElementList(),W=Z[F+1],V=Z[N];if((W==null?void 0:W.controlComponent)===c.ControlComponent.PLACEHOLDER&&(V==null?void 0:V.controlComponent)===c.ControlComponent.PLACEHOLDER&&W.controlId===V.controlId)return;I.setRange(F,N)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function bs(o){var l,a,R,d;const t=o.getDraw(),e=t.getRange(),n=e.getRange(),i=t.getElementList(),r=i[n.startIndex];if(!r.hide&&!((l=r.control)!=null&&l.hide)&&!((a=r.area)!=null&&a.hide))return;let s=n.startIndex;for(;s>0;){const u=i[s];let h=null;u.controlId?(h=t.getControl().removeControl(s),h!==null&&(s=h)):(t.spliceElementList(i,s,1),h=s-1,s--);const g=i[h];if(!g||!g.hide&&!((R=g.control)!=null&&R.hide)&&!((d=g.area)!=null&&d.hide)){if(h){n.startIndex=h,n.endIndex=h,e.replaceRange(n);const L=t.getPosition(),T=L.getPositionList();L.setCursorPosition(T[h])}break}}}function Ds(o,t){var R;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;n.getIsCollapsed()&&bs(t);const i=e.getControl(),{startIndex:r,endIndex:s,isCrossRowCol:l}=n.getRange();let a;if(l){const d=e.getTableParticle().getRangeRowCol();if(!d)return;let u=!1;for(let h=0;h<d.length;h++){const g=d[h];for(let L=0;L<g.length;L++){const T=g[L];T.value.length>1&&(e.spliceElementList(T.value,1,T.value.length-1),u=!0)}}a=u?0:null}else if(i.getActiveControl()&&i.getIsRangeCanCaptureEvent())a=i.keydown(o),a&&i.emitControlContentChange();else{const d=e.getPosition().getCursorPosition();if(!d)return;const{index:u}=d,h=n.getIsCollapsed(),g=e.getElementList();if(h&&u===0){const P=g[u];if(P.value===w){P.listId&&e.getListParticle().unsetList(),o.preventDefault();return}}const L=g[r];if(h&&L.rowFlex&&L.value===w){const P=n.getRangeRowElementList();if(P){const M=g[r-1];P.forEach(f=>{f.rowFlex=M==null?void 0:M.rowFlex})}}const T=L.value===w?g[r-1]:L,O=g[s+1];if((T==null?void 0:T.titleId)&&(O==null?void 0:O.titleId)&&T.level===O.level&&T.titleId!==O.titleId){const P=T.titleId,M=O.titleId;let f=s+1;for(;f<g.length&&((R=g[f])==null?void 0:R.titleId)===M;)g[f].titleId=P,f++}h?e.spliceElementList(g,u,1):e.spliceElementList(g,r+1,s-r),a=h?u-1:r}e.getGlobalEvent().setCanvasEventAbility(),a===null?(n.setRange(r,r),e.render({curIndex:r,isSubmitHistory:!1})):(n.setRange(a,a),e.render({curIndex:a}))}function Ks(o){var l,a,R,d;const t=o.getDraw(),n=t.getRange().getRange(),i=t.getElementList(),r=i[n.startIndex+1];if(!r.hide&&!((l=r.control)!=null&&l.hide)&&!((a=r.area)!=null&&a.hide))return;const s=n.startIndex+1;for(;s<i.length;){const u=i[s];let h=null;u.controlId?h=t.getControl().removeControl(s):(t.spliceElementList(i,s,1),h=s);const g=i[h];if(!g||!g.hide&&!((R=g.control)!=null&&R.hide)&&!((d=g.area)!=null&&d.hide))break}}function ys(o,t){var d;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:r,isCrossRowCol:s}=n.getRange(),l=e.getElementList(),a=e.getControl();n.getIsCollapsed()&&Ks(t);let R;if(s){const u=e.getTableParticle().getRangeRowCol();if(!u)return;let h=!1;for(let g=0;g<u.length;g++){const L=u[g];for(let T=0;T<L.length;T++){const O=L[T];O.value.length>1&&(e.spliceElementList(O.value,1,O.value.length-1),h=!0)}}R=h?0:null}else if(a.getActiveControl()&&a.getIsRangeWithinControl())R=a.keydown(o),R&&a.emitControlContentChange();else if((d=l[r+1])!=null&&d.controlId)R=a.removeControl(r+1);else{const u=e.getPosition(),h=u.getCursorPosition();if(!h)return;const{index:g}=h,L=u.getPositionContext();if(L.isDirectHit&&L.isImage)e.spliceElementList(l,g,1),R=g-1;else{const T=n.getIsCollapsed();if(!T)e.spliceElementList(l,i+1,r-i);else{if(!l[g+1])return;e.spliceElementList(l,g+1,1)}R=T?g:i}}e.getGlobalEvent().setCanvasEventAbility(),R===null?(n.setRange(i,i),e.render({curIndex:i,isSubmitHistory:!1})):(n.setRange(R,R),e.render({curIndex:R}))}function ws(o,t){var L,T,O,P,M,f,S;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:r}=n.getRange(),s=n.getIsCollapsed(),l=e.getElementList(),a=l[i],R=l[r];if(s&&R.listId&&R.value===w&&((L=l[r+1])==null?void 0:L.listId)!==R.listId){e.getListParticle().unsetList();return}let d={value:w};if(o.shiftKey&&a.listId&&(d.listWrap=!0),It(l,[d],i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),o.shiftKey&&R.areaId&&R.areaId!==((T=l[r+1])==null?void 0:T.areaId)&&(d=wt(d,ie)),!(((O=l[i+1])==null?void 0:O.titleId)&&(!a.titleId||a.titleId!==((P=l[i+1])==null?void 0:P.titleId)))&&!(R.titleId&&R.titleId!==((M=l[r+1])==null?void 0:M.titleId))){const I=n.getRangeAnchorStyle(l,r);if(I){const m=[...te];I.controlComponent!==c.ControlComponent.POSTFIX&&m.push(...Ct),m.forEach(N=>{const F=I[N];F!==void 0&&(d[N]=F)})}}const u=e.getControl(),h=u.getActiveControl();let g;if(h&&u.getIsRangeWithinControl())g=u.setValue([d]),u.emitControlContentChange();else{const m=e.getPosition().getCursorPosition();if(!m)return;const{index:N}=m;if(s){if(e.spliceElementList(l,N+1,0,[d]),R.titleId&&((f=l[N+2])==null?void 0:f.titleId)===R.titleId){const F=q();let Z=N+2;for(;Z<l.length&&((S=l[Z])==null?void 0:S.titleId)===R.titleId;)l[Z].titleId=F,Z++}}else e.spliceElementList(l,i+1,r-i,[d]);g=N+1}~g&&(n.setRange(g,g),e.render({curIndex:g})),o.preventDefault()}function Hs(o,t){var S,I,m;const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const s=i.getPositionContext(),{index:l}=r;if(l<=0&&!s.isTable)return;const a=e.getRange(),{startIndex:R,endIndex:d}=a.getRange(),u=a.getIsCollapsed(),h=e.getElementList(),g=e.getControl();if(e.getMode()===c.EditorMode.FORM&&g.getActiveControl()&&(((S=h[l])==null?void 0:S.controlComponent)===c.ControlComponent.PREFIX||((I=h[l])==null?void 0:I.controlComponent)===c.ControlComponent.PRE_TEXT)){g.initNextControl({direction:Pt.UP});return}let L=1;if(At(o)){const N=e.getLetterReg(),F=o.shiftKey&&!u&&R===(r==null?void 0:r.index)?d:R;if(N.test((m=h[F])==null?void 0:m.value)){let Z=F-1;for(;Z>0;){const W=h[Z];if(!N.test(W.value))break;L++,Z--}}}const T=R-L;let O=T,P=T;if(o.shiftKey&&r&&(R!==d?R===r.index?(O=R,P=d-L):(O=T,P=d):P=d),!o.shiftKey){const N=h[R];if(N.type===c.ElementType.TABLE){const F=N.trList,Z=F.length-1,W=F[Z],V=W.tdList.length-1,p=W.tdList[V];i.setPositionContext({isTable:!0,index:R,trIndex:Z,tdIndex:V,tdId:p.id,trId:W.id,tableId:N.id}),O=p.value.length-1,P=O,e.getTableTool().render()}else if(N.tableId&&R===0){const Z=e.getOriginalElementList()[s.index].trList;t:for(let W=0;W<Z.length;W++){const V=Z[W];if(V.id!==N.trId)continue;const p=V.tdList;for(let X=0;X<p.length;X++)if(p[X].id===N.tdId){if(W===0&&X===0)i.setPositionContext({isTable:!1}),O=s.index-1,P=O,e.getTableTool().dispose();else{let C=W,U=X-1;U<0&&(C=W-1,U=Z[C].tdList.length-1);const K=Z[C],b=K.tdList[U];i.setPositionContext({isTable:!0,index:s.index,trIndex:C,tdIndex:U,tdId:b.id,trId:K.id,tableId:N.tableId}),O=b.value.length-1,P=O,e.getTableTool().render()}break t}}}}if(!~O||!~P)return;const M=e.getElementList();O=Me(M,O),P=Me(M,P),a.setRange(O,P);const f=O===P;e.render({curIndex:f?O:void 0,isSetCursor:f,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function Gs(o,t){var m,N,F;const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const{index:s}=r,l=i.getPositionList(),a=i.getPositionContext();if(s>l.length-1&&!a.isTable)return;const R=e.getRange(),{startIndex:d,endIndex:u}=R.getRange(),h=R.getIsCollapsed();let g=e.getElementList();const L=e.getControl();if(e.getMode()===c.EditorMode.FORM&&L.getActiveControl()&&(((m=g[s+1])==null?void 0:m.controlComponent)===c.ControlComponent.POSTFIX||((N=g[s+1])==null?void 0:N.controlComponent)===c.ControlComponent.POST_TEXT)){L.initNextControl({direction:Pt.DOWN});return}let T=1;if(At(o)){const Z=e.getLetterReg(),W=o.shiftKey&&!h&&d===(r==null?void 0:r.index)?u:d;if(Z.test((F=g[W+1])==null?void 0:F.value)){let V=W+2;for(;V<g.length;){const p=g[V];if(!Z.test(p.value))break;T++,V++}}}const O=u+T;let P=O,M=O;if(o.shiftKey&&r&&(d!==u?d===r.index?(P=d,M=O):(P=d+T,M=u):P=d),!o.shiftKey){const Z=g[u],W=g[u+1];if((W==null?void 0:W.type)===c.ElementType.TABLE){const p=W.trList[0],X=p.tdList[0];i.setPositionContext({isTable:!0,index:u+1,trIndex:0,tdIndex:0,tdId:X.id,trId:p.id,tableId:W.id}),P=0,M=0,e.getTableTool().render()}else if(Z.tableId&&!W){const p=e.getOriginalElementList()[a.index].trList;t:for(let X=0;X<p.length;X++){const E=p[X];if(E.id!==Z.trId)continue;const C=E.tdList;for(let U=0;U<C.length;U++)if(C[U].id===Z.tdId){if(X===p.length-1&&U===C.length-1)i.setPositionContext({isTable:!1}),P=a.index,M=P,g=e.getElementList(),e.getTableTool().dispose();else{let b=X,Y=U+1;Y>C.length-1&&(b=X+1,Y=0);const y=p[b],D=y.tdList[Y];i.setPositionContext({isTable:!0,index:a.index,trIndex:b,tdIndex:Y,tdId:D.id,trId:y.id,tableId:Z.tableId}),P=0,M=P,e.getTableTool().render()}break t}}}}const f=g.length-1;if(P>f||M>f)return;const S=e.getElementList();P=Me(S,P,c.LocationPosition.AFTER),M=Me(S,M,c.LocationPosition.AFTER),R.setRange(P,M);const I=P===M;e.render({curIndex:I?P:void 0,isSetCursor:I,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function xs(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getControl();if(i.getActiveControl()&&i.getIsRangeWithinControl())i.initNextControl({direction:o.shiftKey?Pt.UP:Pt.DOWN});else{const s=e.getRange(),l=e.getElementList(),{startIndex:a,endIndex:R}=s.getRange(),d=s.getRangeAnchorStyle(l,R),h={...d?Wt(d,Ct):null,type:c.ElementType.TAB,value:""};It(l,[h],a,{editorOptions:e.getOptions()}),e.insertElementList([h])}}function Mn(o){const{positionList:t,index:e,isUp:n,rowNo:i,cursorX:r}=o;let s=-1;const l=[];if(n){let a=e-1;for(;a>=0;){const R=t[a];if(a--,R.rowNo!==i){if(l[0]&&l[0].rowNo!==R.rowNo)break;l.unshift(R)}}}else{let a=e+1;for(;a<t.length;){const R=t[a];if(a++,R.rowNo!==i){if(l[0]&&l[0].rowNo!==R.rowNo)break;l.push(R)}}}for(let a=0;a<l.length;a++){const R=l[a],{coordinate:{leftTop:[d],rightTop:[u]}}=R;if(a===l.length-1&&(s=R.index),!(r<d||r>u)){s=R.index;break}}return s}function Js(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const s=e.getRange(),{startIndex:l,endIndex:a}=s.getRange();let R=i.getPositionList();const d=o.key===c.KeyMap.Up;let u=-1,h=-1;const g=i.getPositionContext();if(!o.shiftKey&&g.isTable&&(d&&r.rowIndex===0||!d&&r.rowIndex===e.getRowCount()-1)){const{index:T,trIndex:O,tdIndex:P,tableId:M}=g;if(d)if(O===0)i.setPositionContext({isTable:!1}),u=T-1,h=u,e.getTableTool().dispose();else{let f=-1,S=-1;const m=e.getOriginalElementList()[T].trList,N=m[O].tdList[P].colIndex;t:for(let W=O-1;W>=0;W--){const p=m[W].tdList;for(let X=0;X<p.length;X++){const E=p[X];if(E.colIndex===N||E.colIndex+E.colspan-1>=N&&E.colIndex<=N){f=W,S=X;break t}}}if(!~f||!~S)return;const F=m[f],Z=F.tdList[S];i.setPositionContext({isTable:!0,index:T,trIndex:f,tdIndex:S,tdId:Z.id,trId:F.id,tableId:M}),u=Z.value.length-1,h=u,e.getTableTool().render()}else{const S=e.getOriginalElementList()[T].trList;if(O===S.length-1)i.setPositionContext({isTable:!1}),u=T,h=u,e.getTableTool().dispose();else{let I=-1,m=-1;const N=S[O].tdList[P].colIndex;t:for(let W=O+1;W<S.length;W++){const p=S[W].tdList;for(let X=0;X<p.length;X++){const E=p[X];if(E.colIndex===N||E.colIndex+E.colspan-1>=N&&E.colIndex<=N){I=W,m=X;break t}}}if(!~I||!~m)return;const F=S[I],Z=F.tdList[m];i.setPositionContext({isTable:!0,index:T,trIndex:I,tdIndex:m,tdId:Z.id,trId:F.id,tableId:M}),u=Z.value.length-1,h=u,e.getTableTool().render()}}}else{let T=r;o.shiftKey&&(l===r.index?T=R[a]:T=R[l]);const{index:O,rowNo:P,rowIndex:M,coordinate:{rightTop:[f]}}=T;if(d&&M===0||!d&&M===e.getRowCount()-1)return;const S=Mn({positionList:R,index:O,rowNo:P,isUp:d,cursorX:f});if(S<0)return;u=S,h=S,o.shiftKey&&(l!==a?l===r.index?u=l:h=a:d?h=a:u=l);const m=e.getElementList()[S];if(m.type===c.ElementType.TABLE){const{scale:N}=e.getOptions(),F=e.getMargins(),Z=m.trList;let W=-1,V=-1,p=-1;if(d){t:for(let X=Z.length-1;X>=0;X--){const C=Z[X].tdList;for(let U=0;U<C.length;U++){const K=C[U],b=K.x*N+F[3],Y=K.width*N;if(f>=b&&f<=b+Y){const y=K.positionList,D=y[y.length-1],H=Mn({positionList:y,index:D.index+1,rowNo:D.rowNo-1,isUp:d,cursorX:f})||D.index;W=X,V=U,p=H;break t}}}}else{t:for(let X=0;X<Z.length;X++){const C=Z[X].tdList;for(let U=0;U<C.length;U++){const K=C[U],b=K.x*N+F[3],Y=K.width*N;if(f>=b&&f<=b+Y){const y=K.positionList,D=Mn({positionList:y,index:-1,rowNo:-1,isUp:d,cursorX:f})||0;W=X,V=U,p=D;break t}}}}if(~W&&~V&&~p){const X=Z[W],E=X.tdList[V];i.setPositionContext({isTable:!0,index:S,trIndex:W,tdIndex:V,tdId:E.id,trId:X.id,tableId:m.id}),u=p,h=u,R=i.getPositionList(),e.getTableTool().render()}}}if(!~u||!~h)return;u>h&&([u,h]=[h,u]),s.setRange(u,h);const L=u===h;e.render({curIndex:L?u:void 0,isSetCursor:L,isSubmitHistory:!1,isCompute:!1}),L||e.getCursor().moveCursorToVisible({cursorPosition:R[d?u:h],direction:d?Pt.UP:Pt.DOWN})}function vs(o,t){if(t.isComposing)return;const e=t.getDraw();if(o.key===c.KeyMap.Backspace)Ds(o,t);else if(o.key===c.KeyMap.Delete)ys(o,t);else if(o.key===c.KeyMap.Enter)ws(o,t);else if(o.key===c.KeyMap.Left)Hs(o,t);else if(o.key===c.KeyMap.Right)Gs(o,t);else if(o.key===c.KeyMap.Up||o.key===c.KeyMap.Down)Js(o,t);else if(At(o)&&o.key.toLocaleLowerCase()===c.KeyMap.Z){if(e.isReadonly()&&e.getMode()!==c.EditorMode.FORM)return;e.getHistoryManager().undo(),o.preventDefault()}else if(At(o)&&o.key.toLocaleLowerCase()===c.KeyMap.Y){if(e.isReadonly()&&e.getMode()!==c.EditorMode.FORM)return;e.getHistoryManager().redo(),o.preventDefault()}else if(At(o)&&o.key.toLocaleLowerCase()===c.KeyMap.C)t.copy(),o.preventDefault();else if(At(o)&&o.key.toLocaleLowerCase()===c.KeyMap.X)t.cut(),o.preventDefault();else if(At(o)&&o.key.toLocaleLowerCase()===c.KeyMap.A)t.selectAll(),o.preventDefault();else if(At(o)&&o.key.toLocaleLowerCase()===c.KeyMap.S){if(e.isReadonly())return;const n=e.getListener();n.saved&&n.saved(e.getValue());const i=e.getEventBus();i.isSubscribe("saved")&&i.emit("saved",e.getValue()),o.preventDefault()}else if(o.key===c.KeyMap.ESC){t.clearPainterStyle();const n=e.getZone();n.isMainActive()||n.setZone(c.EditorZone.MAIN),o.preventDefault()}else o.key===c.KeyMap.TAB&&xs(o,t)}function fn(o,t){var N,F;const e=t.getDraw();if(e.isReadonly()||e.isDisabled())return;const i=e.getPosition().getCursorPosition();if(!o||!i)return;const r=t.isComposing;if(r&&((N=t.compositionInfo)==null?void 0:N.value)===o)return;const s=e.getRange();if(!s.getIsCanInput())return;const l=s.getDefaultStyle()||((F=t.compositionInfo)==null?void 0:F.defaultStyle)||null;ri(t),r||e.getCursor().clearAgentDomValue();const{TEXT:a,HYPERLINK:R,SUBSCRIPT:d,SUPERSCRIPT:u,DATE:h,TAB:g}=c.ElementType,L=o.replaceAll(`
|
|
90
90
|
`,w),{startIndex:T,endIndex:O}=s.getRange(),P=e.getElementList(),M=s.getRangeAnchorStyle(P,O);if(!M)return;const f=e.isDesignMode(),S=Ft(L).map(Z=>{var V,p;const W={value:Z};if(f||!((V=M.title)!=null&&V.disabled)&&!((p=M.control)!=null&&p.disabled)){const X=P[O+1];(!M.type||M.type===a||M.type===R&&(X==null?void 0:X.type)===R||M.type===h&&(X==null?void 0:X.type)===h||M.type===d&&(X==null?void 0:X.type)===d||M.type===u&&(X==null?void 0:X.type)===u)&&Mo.forEach(E=>{if(E==="groupIds"&&!(X!=null&&X.groupIds))return;const C=M[E];C!==void 0&&(W[E]=C)}),(l||M.type===g)&&Ct.forEach(E=>{const C=(l==null?void 0:l[E])||M[E];C!==void 0&&(W[E]=C)}),r&&(W.underline=!0)}return W}),I=e.getControl();let m;if(I.getActiveControl()&&I.getIsRangeWithinControl())m=I.setValue(S),r||I.emitControlContentChange();else{const Z=T+1;T!==O&&e.spliceElementList(P,Z,O-T),It(P,S,T,{editorOptions:e.getOptions()}),e.spliceElementList(P,Z,0,S),m=T+S.length}~m&&(s.setRange(m,m),e.render({curIndex:m,isSubmitHistory:!r})),r&&~m&&(t.compositionInfo={elementList:P,value:L,startIndex:m-S.length,endIndex:m,defaultStyle:l})}function ri(o){if(!o.compositionInfo)return;const{elementList:t,startIndex:e,endIndex:n}=o.compositionInfo;t.splice(e+1,n-e),o.getDraw().getRange().setRange(e,e),o.compositionInfo=null}async function As(o){const t=o.getDraw(),e=t.getRange(),{startIndex:n,endIndex:i}=e.getRange();if(!~n&&!~n||t.isReadonly()||!e.getIsCanInput())return;const r=t.getElementList();let s=n,l=i;if(n===i){const h=t.getPosition().getPositionList(),g=h[n],L=g.rowNo,T=g.pageNo,O=[];for(let M=0;M<h.length;M++){const f=h[M];if(f.pageNo>T)break;f.pageNo===T&&f.rowNo===L&&O.push(M)}const P=O[0]-1;s=P<0?0:P,l=O[O.length-1]}const a=t.getOptions();await ti(r.slice(s+1,l+1),a);const R=t.getControl();let d;R.getActiveControl()&&R.getIsRangeWithinControl()?(d=R.cut(),R.emitControlContentChange()):(t.spliceElementList(r,s+1,l-s),d=s),e.setRange(d,d),t.render({curIndex:d})}async function Bs(o,t){const e=o.getDraw(),{copy:n}=e.getOverride();if(n){const l=n();if((l==null?void 0:l.preventDefault)!==!1)return}const i=e.getRange();let r=null;if(i.getRange().isCrossRowCol){const l=i.getRangeTableElement();if(!l)return;const a=e.getTableParticle().getRangeRowCol();if(!a)return;const R={type:c.ElementType.TABLE,value:"",colgroup:[],trList:[]},d=a[0],u=d[0].colIndex,h=d[d.length-1],g=h.colIndex+h.colspan-1;for(let L=u;L<=g;L++)R.colgroup.push(l.colgroup[L]);for(let L=0;L<a.length;L++){const T=a[L],O=l.trList[T[0].rowIndex],P={tdList:[],height:O.height,minHeight:O.minHeight};for(let M=0;M<T.length;M++)P.tdList.push(T[M]);R.trList.push(P)}r=rt([R])}else r=i.getIsCollapsed()?i.getRangeRowElementList():i.getSelectionElementList();(t==null?void 0:t.isPlainText)&&(r==null?void 0:r.length)&&(r=[{value:ae(r)}]),r!=null&&r.length&&await ti(r,e.getOptions())}function ks(o,t){var r,s;const e=t.getDraw(),{drop:n}=e.getOverride();if(n){const l=n(o);if((l==null?void 0:l.preventDefault)!==!1)return}o.preventDefault();const i=(r=o.dataTransfer)==null?void 0:r.getData("text");if(i)t.input(i);else{const l=(s=o.dataTransfer)==null?void 0:s.files;if(!l)return;for(let a=0;a<l.length;a++){const R=l[a];R.type.startsWith("image")&&Tn(t,R)}}}function li(o){var h;if(!Intl.Segmenter)return null;const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const i=t.getRange().getRangeParagraphInfo();if(!i)return null;const r=((h=i==null?void 0:i.elementList)==null?void 0:h.map(g=>!g.type||g.type!==c.ElementType.CONTROL&&Qt.includes(g.type)?g.value:w).join(""))||"";if(!r)return null;const s=e.isFirstLetter||t.getCursor().getHitLineStartIndex()?e.index+1:e.index,l=i.startIndex,R=new Intl.Segmenter(void 0,{granularity:"word"}).segment(r);let d=-1,u=-1;for(const{segment:g,index:L,isWordLike:T}of R){const O=L+l;if(T&&s>=O&&s<O+g.length){d=O-1,u=d+g.length;break}}return~d&&~u?{startIndex:d,endIndex:u}:null}function _s(o){const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const{value:n,index:i}=e,r=t.getLetterReg();let s=0,l=0;const a=ve.test(n);if(a||r.test(n)){const d=t.getElementList();let u=i-1;for(;u>0;){const g=d[u].value;if(a&&ve.test(g)||!a&&r.test(g))s++,u--;else break}let h=i+1;for(;h<d.length;){const g=d[h].value;if(a&&ve.test(g)||!a&&r.test(g))l++,h++;else break}}const R=i-s-1;return R<0?null:{startIndex:R,endIndex:i+l}}function zs(o,t){const e=o.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(i.isImage&&i.isDirectHit){const l=e.getElementList(),a=e.getEventBus(),R=l[i.index];if(a.isSubscribe("imageDblclick")&&a.emit("imageDblclick",{evt:t,element:R}),R.formInput){const d=Reflect.get(window,"editor");if(console.log("curElement",R),R.formInput&&R.formInput.type==="checkbox"){d.showFormCheckboxConfig(R);return}if(R.formInput&&R.formInput.type==="radio"){d.showFormRadioConfig(R);return}if(R.formInput&&R.formInput.type==="image"){d.showFormImageConfig(R);return}if(R.formInput&&R.formInput.type==="signature"){d.showFormSignatureConfig(R);return}if(R.formInput&&R.formInput.type==="seal"){d.showFormSealConfig(R);return}if(R.formInput&&R.formInput.type==="riskCopy"){d.showFormRiskCopyConfig(R);return}d.showFormInputConfig(R);return}if(R.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&!~i.index&&i.zone){e.getZone().setZone(i.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((i.isCheckbox||i.isRadio)&&i.isDirectHit)return;const r=e.getRange(),s=li(o)||_s(o);!s||(r.setRange(s.startIndex,s.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),r.setRangeStyle())}function $s(o){var L,T;const t=o.getDraw(),e=t.getControl();if(e.getActiveControl()&&e.selectValue())return;const i=t.getPosition().getCursorPosition();if(!i)return;const{index:r}=i,s=t.getElementList();let l=0,a=0,R=r-1;for(;R>0;){const O=s[R],P=s[R-1];if(O.value===w&&!O.listWrap||O.listId!==(P==null?void 0:P.listId)||O.titleId!==(P==null?void 0:P.titleId))break;l++,R--}let d=r+1;for(;d<s.length;){const O=s[d],P=s[d+1];if(O.value===w&&!O.listWrap||O.listId!==(P==null?void 0:P.listId)||O.titleId!==(P==null?void 0:P.titleId))break;a++,d++}const u=t.getRange();let h=r-l-1;if(((L=s[h])==null?void 0:L.value)!==w&&(h-=1),h<0)return;let g=r+a+1;(((T=s[g])==null?void 0:T.value)===w||g>s.length-1)&&(g-=1),u.setRange(h,g),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}var ai={dblclick:zs,threeClick:$s};function js(o){o.isComposing=!0}function qs(o,t){o.isComposing=!1;const e=o.getDraw();if(t.data)Oo?setTimeout(()=>{o.compositionInfo&&fn(t.data,o)},1):o.compositionInfo&&fn(t.data,o);else{ri(o);const i=e.getRange(),{endIndex:r}=i.getRange();e.render({curIndex:r,isSubmitHistory:!1})}e.getCursor().clearAgentDomValue()}var Ri={compositionstart:js,compositionend:qs};function tr(o,t){var f;const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getPageContainer();if(!Xe(o.target,S=>S===i,!0))return;const l=o.target.dataset.index;l&&e.setPageNo(Number(l));const a=e.getPosition(),R=a.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!R)return;const{isTable:d,tdValueIndex:u,index:h}=R,g=a.getPositionList(),L=d?u:h;~h&&(e.getRange().setRange(L,L),a.setCursorPosition(g[L]));const T=e.getCursor(),{cursor:{dragColor:O,dragWidth:P,dragFloatImageDisabled:M}}=e.getOptions();if(M){const S=(f=t.cacheElementList)==null?void 0:f[t.cacheRange.startIndex];if((S==null?void 0:S.type)===c.ElementType.IMAGE&&(S.imgDisplay===c.ImageDisplay.FLOAT_TOP||S.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM||S.imgDisplay===c.ImageDisplay.SURROUND))return}T.drawCursor({width:P,color:O,isBlink:!1,isFocus:!1})}var er={dragover:tr};class nr{constructor(t){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.pageContainer.addEventListener("click",this.click.bind(this)),this.pageContainer.addEventListener("mousedown",this.mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this.mouseup.bind(this)),this.pageContainer.addEventListener("mouseleave",this.mouseleave.bind(this)),this.pageContainer.addEventListener("mousemove",this.mousemove.bind(this)),this.pageContainer.addEventListener("dblclick",this.dblclick.bind(this)),this.pageContainer.addEventListener("dragover",this.dragover.bind(this)),this.pageContainer.addEventListener("drop",this.drop.bind(this)),so(this.pageContainer,this.threeClick.bind(this))}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;let n=this.range.getSelection();if(!n){const s=li(this);s&&(n=this.draw.getElementList().slice(s.startIndex+1,s.endIndex+1))}if(!n)return;const i=Object.keys(t);n.forEach(s=>{i.forEach(l=>{const a=l;Reflect.set(s,a,t[a])})}),this.draw.render({isSetCursor:!1});const r=this.draw.getPainterOptions();(!r||!r.isDblclick)&&this.clearPainterStyle()}selectAll(){if(this.position.getPositionContext().isTable)this.draw.getTableOperate().tableSelectAll();else{const t=this.position.getPositionList();this.range.setRange(0,t.length-1),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}}mousemove(t){Qs(t,this)}mousedown(t){Us(t,this)}click(){To&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){Es(t,this)}mouseleave(t){Cs(t,this)}keydown(t){vs(t,this)}dblclick(t){ai.dblclick(this,t)}threeClick(){ai.threeClick(this)}input(t){fn(t,this)}async cut(){await As(this)}async copy(t){await Bs(this,t)}compositionstart(){Ri.compositionstart(this)}compositionend(t){Ri.compositionend(this,t)}drop(t){ks(t,this)}dragover(t){er.dragover(t,this)}}const ci={PAGE_SCALE:"pageScale"};class ir{constructor(t,e){this.clearSideEffect=n=>{if(!this.cursor)return;const i=(n==null?void 0:n.composedPath()[0])||n.target,r=this.draw.getPageList();if(Xe(i,a=>r.includes(a),!0))return;if(Xe(i,a=>!!a&&a.nodeType===1&&!!a.getAttribute(Ht),!0)){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()},this.setCanvasEventAbility=()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)},this.setPageScale=n=>{if(this.options.shortcutDisableKeys.includes(ci.PAGE_SCALE)||!n.ctrlKey)return;n.preventDefault();const{scale:i}=this.options;if(n.deltaY<0){const r=i*10+1;r<=30&&this.draw.setPageScale(r/10)}else{const r=i*10-1;r>=5&&this.draw.setPageScale(r/10)}},this._handleVisibilityChange=()=>{if(document.visibilityState==="visible"){const n=this.range.getRange(),i=!!~n.startIndex&&!!~n.endIndex&&n.startIndex===n.endIndex;this.range.replaceRange(n),this.draw.render({isSetCursor:i,isCompute:!1,isSubmitHistory:!1,curIndex:n.startIndex})}},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 or{constructor(t){this.undoStack=[],this.redoStack=[],this.maxRecordCount=t.getOptions().historyMaxRecordCount+1}undo(){if(this.undoStack.length>1){const t=this.undoStack.pop();this.redoStack.push(t),this.undoStack.length&&this.undoStack[this.undoStack.length-1]()}}redo(){if(this.redoStack.length){const t=this.redoStack.pop();this.undoStack.push(t),t()}}execute(t){for(this.undoStack.push(t),this.redoStack.length&&(this.redoStack=[]);this.undoStack.length>this.maxRecordCount;)this.undoStack.shift()}isCanUndo(){return this.undoStack.length>1}isCanRedo(){return!!this.redoStack.length}isStackEmpty(){return!this.undoStack.length&&!this.redoStack.length}recovery(){this.undoStack=[],this.redoStack=[]}popUndo(){return this.undoStack.pop()}}class sr{constructor(t){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:n,tdIndex:i}=this.positionContext;return t[e].trList[n].tdList[i].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:n,pageNo:i,startX:r,startY:s,startRowIndex:l,startIndex:a,innerWidth:R,zone:d}=t,{scale:u,table:{tdPadding:h}}=this.options;let g=r,L=s,T=a;for(let O=0;O<n.length;O++){const P=n[O];if(!P.isSurround){const S=P.width+(P.offsetX||0);P.rowFlex===c.RowFlex.CENTER?g+=(R-S)/2:P.rowFlex===c.RowFlex.RIGHT&&(g+=R-S)}g+=P.offsetX||0,L+=P.offsetY||0;const M=g,f=L;for(let S=0;S<P.elementList.length;S++){const I=P.elementList[S],m=I.metrics;I.left&&(g+=I.left),I.translateX&&(g+=I.translateX*u);const N={pageNo:i,index:T,value:I.value,rowIndex:l+O,rowNo:O,metrics:m,left:I.left||0,ascent:I.type===c.ElementType.IMAGE?4:17,lineHeight:P.height,isFirstLetter:S===0,isLastLetter:S===P.elementList.length-1,coordinate:{leftTop:[g,L],leftBottom:[g,L+P.height],rightTop:[g+m.width,L],rightBottom:[g+m.width,L+P.height]}};if(I.imgDisplay===c.ImageDisplay.SURROUND||I.imgDisplay===c.ImageDisplay.FLOAT_TOP||I.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM){const F=e[e.length-1];F&&(N.metrics=F.metrics,N.coordinate=F.coordinate),I.imgFloatPosition||(I.imgFloatPosition={x:g,y:L,pageNo:i}),this.floatPositionList.push({pageNo:i,element:I,position:N,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:T,zone:d})}if(e.push(N),T++,g+=m.width,I.type===c.ElementType.TABLE&&!I.hide){const F=h[1]+h[3],Z=h[0]+h[2];for(let W=0;W<I.trList.length;W++){const V=I.trList[W];for(let p=0;p<V.tdList.length;p++){const X=V.tdList[p];X.positionList=[];const E=X.rowList,C=this.computePageRowPosition({positionList:X.positionList,rowList:E,pageNo:i,startRowIndex:0,startIndex:0,startX:(X.x+h[3])*u+M+(I.translateX||0)*u,startY:(X.y+h[0])*u+f,innerWidth:(X.width-F)*u,isTable:!0,index:T-1,tdIndex:p,trIndex:W,zone:d});if(X.verticalAlign===c.VerticalAlign.MIDDLE||X.verticalAlign===c.VerticalAlign.BOTTOM){const U=E.reduce((Y,y)=>Y+y.height,0),K=(X.height-Z)*u-U,b=X.verticalAlign===c.VerticalAlign.MIDDLE?K/2:K;Math.floor(b)>0&&X.positionList.forEach(Y=>{const{coordinate:{leftTop:y,leftBottom:D,rightBottom:H,rightTop:_}}=Y;y[1]+=b,D[1]+=b,H[1]+=b,_[1]+=b})}g=C.x,L=C.y}}g=M,L=f}}g=r,L+=P.height}return{x:g,y:L,index:T}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),n=this.draw.getMargins(),i=n[3],s=this.draw.getHeader().getExtraHeight(),l=n[0]+s;let a=0;for(let R=0;R<e.length;R++){const d=e[R];if(!(d!=null&&d.length))continue;const u=d[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:d,pageNo:R,startRowIndex:a,startIndex:u,startX:i,startY:l,innerWidth:t}),a+=d.length}}computeRowPosition(t){const{row:e,innerWidth:n}=t,i=[];return this.computePageRowPosition({positionList:i,innerWidth:n,rowList:[et(e)],pageNo:0,startX:0,startY:0,startIndex:0,startRowIndex:0}),i}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 T,O,P,M,f;const{x:e,y:n,isTable:i}=t;let{elementList:r,positionList:s}=t;r||(r=this.draw.getOriginalElementList()),s||(s=this.getOriginalPositionList());const l=this.draw.getZone(),a=(T=t.pageNo)!=null?T:this.draw.getPageNo(),R=l.isMainActive(),d=R?a:0;if(!i){const S=this.getFloatPositionByXY({...t,imgDisplays:[c.ImageDisplay.FLOAT_TOP,c.ImageDisplay.SURROUND]});if(S)return S}for(let S=0;S<s.length;S++){const{index:I,pageNo:m,left:N,isFirstLetter:F,coordinate:{leftTop:Z,rightTop:W,leftBottom:V}}=s[S];if(d===m){if(m>d)break;if(Z[0]-N<=e&&W[0]>=e&&Z[1]<=n&&V[1]>=n){let p=S;const X=r[S];if(X.type===c.ElementType.TABLE)for(let C=0;C<X.trList.length;C++){const U=X.trList[C];for(let K=0;K<U.tdList.length;K++){const b=U.tdList[K],Y=this.getPositionByXY({x:e,y:n,td:b,pageNo:a,tablePosition:s[S],isTable:!0,elementList:b.value,positionList:b.positionList});if(~Y.index){const{index:y,hitLineStartIndex:D}=Y,H=b.value[y];return{index:I,isCheckbox:Y.isCheckbox||H.type===c.ElementType.CHECKBOX||H.controlComponent===c.ControlComponent.CHECKBOX,isRadio:H.type===c.ElementType.RADIO||H.controlComponent===c.ControlComponent.RADIO,isControl:!!H.controlId,isImage:Y.isImage,isDirectHit:Y.isDirectHit,isTable:!0,tdIndex:K,trIndex:C,tdValueIndex:y,tdId:b.id,trId:U.id,tableId:X.id,hitLineStartIndex:D}}}}if(X.type===c.ElementType.IMAGE||X.type===c.ElementType.LATEX)return{index:p,isDirectHit:!0,isImage:!0};if(X.type===c.ElementType.CHECKBOX||X.controlComponent===c.ControlComponent.CHECKBOX)return{index:p,isDirectHit:!0,isCheckbox:!0};if(X.type===c.ElementType.LABEL)return{index:p,isDirectHit:!0,isLabel:!0};if(X.type===c.ElementType.TAB&&X.listStyle===c.ListStyle.CHECKBOX){let C=p-1;for(;C>0;){const U=r[C];if(U.value===w&&U.listStyle===c.ListStyle.CHECKBOX)break;C--}return{index:C,isDirectHit:!0,isCheckbox:!0}}if(X.type===c.ElementType.RADIO||X.controlComponent===c.ControlComponent.RADIO)return{index:p,isDirectHit:!0,isRadio:!0};let E;if(r[I].value!==w){const C=W[0]-Z[0];e<Z[0]+C/2&&(p=S-1,F&&(E=S))}return{isDirectHit:!0,hitLineStartIndex:E,index:p,isControl:!!X.controlId}}}}if(!i){const S=this.getFloatPositionByXY({...t,imgDisplays:[c.ImageDisplay.FLOAT_BOTTOM]});if(S)return S}let u=!1,h=-1,g;if(i){const{scale:S}=this.options,{td:I,tablePosition:m}=t;if(I&&m){const{leftTop:N}=m.coordinate,F=I.x*S+N[0],Z=I.y*S+N[1],W=I.width*S,V=I.height*S;if(!(F<e&&e<F+W&&Z<n&&n<Z+V))return{index:h}}}const L=s.filter(S=>S.isLastLetter&&S.pageNo===d);for(let S=0;S<L.length;S++){const{index:I,rowNo:m,coordinate:{leftTop:N,leftBottom:F}}=L[S];if(n>N[1]&&n<=F[1]){const Z=s.findIndex(X=>X.pageNo===d&&X.rowNo===m),W=r[Z],V=s[Z],p=W.listStyle===c.ListStyle.CHECKBOX?this.draw.getMargins()[3]:V.coordinate.leftTop[0];if(e<p)~Z?V.value===w?h=Z:(h=Z-1,g=Z):h=I;else{if(W.listStyle===c.ListStyle.CHECKBOX&&e<N[0])return{index:Z,isDirectHit:!0,isCheckbox:!0};h=I}u=!0;break}}if(!u){if(this.draw.getIsPagingMode()){const I=this.draw.getHeader(),m=I.getHeight(),N=I.getHeaderTop()+m,F=this.draw.getFooter(),W=this.draw.getHeight()-(F.getFooterBottom()+F.getHeight());if(R){if(n<N)return{index:-1,zone:c.EditorZone.HEADER};if(n>W)return{index:-1,zone:c.EditorZone.FOOTER}}else if(n<=W&&n>=N)return{index:-1,zone:c.EditorZone.MAIN}}const S=this.draw.getMargins();if(n<=S[0])for(let I=0;I<s.length;I++){const m=s[I];if(m.pageNo!==d||m.rowNo!==0)continue;const{leftTop:N,rightTop:F}=m.coordinate;if(e<=S[3]||e>=N[0]&&e<=F[0]||((O=s[I+1])==null?void 0:O.rowNo)!==0)return{index:m.index}}else{const I=L[L.length-1];if(I){const m=I.rowNo;for(let N=0;N<s.length;N++){const F=s[N];if(F.pageNo!==d||F.rowNo!==m)continue;const{leftTop:Z,rightTop:W}=F.coordinate;if(e<=S[3]||e>=Z[0]&&e<=W[0]||((P=s[N+1])==null?void 0:P.rowNo)!==m)return{index:F.index}}}}return{index:((M=L[L.length-1])==null?void 0:M.index)||s.length-1}}return{hitLineStartIndex:g,index:h,isControl:!!((f=r[h])!=null&&f.controlId)}}getFloatPositionByXY(t){var l;const{x:e,y:n}=t,i=(l=t.pageNo)!=null?l:this.draw.getPageNo(),r=this.draw.getZone().getZone(),{scale:s}=this.options;for(let a=0;a<this.floatPositionList.length;a++){const{position:R,element:d,isTable:u,index:h,trIndex:g,tdIndex:L,tdValueIndex:T,zone:O,pageNo:P}=this.floatPositionList[a];if(i===P&&d.type===c.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!O||O===r)){const M=d.imgFloatPosition,f=M.x*s,S=M.y*s,I=d.width*s,m=d.height*s;if(e>=f&&e<=f+I&&n>=S&&n<=S+m)return u?{index:h,isDirectHit:!0,isImage:!0,isTable:u,trIndex:g,tdIndex:L,tdValueIndex:T,tdId:d.tdId,trId:d.trId,tableId:d.tableId}:{index:R.index,isDirectHit:!0,isImage:!0}}}}adjustPositionContext(t){const e=this.getPositionByXY(t);if(!~e.index)return null;if(e.isControl&&this.draw.getMode()!==c.EditorMode.READONLY){const{index:O,isTable:P,trIndex:M,tdIndex:f,tdValueIndex:S}=e,I=this.draw.getControl(),{newIndex:m}=I.moveCursor({index:O,isTable:P,trIndex:M,tdIndex:f,tdValueIndex:S});P?e.tdValueIndex=m:e.index=m}const{index:n,isCheckbox:i,isRadio:r,isControl:s,isImage:l,isLabel:a,isDirectHit:R,isTable:d,trIndex:u,tdIndex:h,tdId:g,trId:L,tableId:T}=e;return this.setPositionContext({isTable:d||!1,isCheckbox:i||!1,isRadio:r||!1,isControl:s||!1,isImage:l||!1,isLabel:a||!1,isDirectHit:R||!1,index:n,trIndex:u,tdIndex:h,tdId:g,trId:L,tableId:T}),e}setSurroundPosition(t){var u;const{scale:e}=this.options,{pageNo:n,row:i,rowElement:r,rowElementRect:s,surroundElementList:l,availableWidth:a}=t;let R=s.x,d=0;if(l.length&&!Re(r)&&!((u=r.control)!=null&&u.minWidth))for(let h=0;h<l.length;h++){const g=l[h],L=g.imgFloatPosition;if(L.pageNo!==n)continue;const T={...L,x:L.x*e,y:L.y*e,width:g.width*e,height:g.height*e};if(ho(s,T)){i.isSurround=!0;const O=T.width+T.x-s.x;if(r.left=O,i.width+=O,d+=O,R=T.x+T.width,i.width+r.metrics.width>a){r.left=0,i.width-=d;break}}}return{x:R,rowIncreaseWidth:d}}}class rr{constructor(t){this.draw=t,this.options=t.getOptions(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.range={startIndex:-1,endIndex:-1},this.defaultStyle=null}getRange(){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 n=Ee(t,e);return n?{...n,...this.defaultStyle}:null}getIsRangeChange(t,e,n,i,r,s,l){return this.range.startIndex!==t||this.range.endIndex!==e||this.range.tableId!==n||this.range.startTdIndex!==i||this.range.endTdIndex!==r||this.range.startTrIndex!==s||this.range.endTrIndex!==l}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(){var i;const{startIndex:t,endIndex:e}=this.range;if(t===e)return null;const n=this.draw.getElementList();return n.slice(((i=n[t])==null?void 0:i.value)===w?t:t+1,e+1)}getSelectionElementList(){if(this.range.isCrossRowCol){const t=this.draw.getTableParticle().getRangeRowCol();if(!t)return null;const e=[];for(let n=0;n<t.length;n++){const i=t[n];for(let r=0;r<i.length;r++){const s=i[r];e.push(...s.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||Qt.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||Qt.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=new Map;for(let r=t;r<e+1;r++){const{pageNo:s,rowNo:l}=n[r],a=i.get(s);a?a.has(l)||a.add(l):i.set(s,new Set([l]))}return i}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:n}=this.range;if(!~t&&!~e)return null;if(n)return this.getSelectionElementList();const i=this.getRangeRow();if(!i)return null;const r=this.position.getPositionList(),s=this.draw.getElementList(),l=[];for(let a=0;a<r.length;a++){const R=r[a],d=i.get(R.pageNo);!d||d.has(R.rowNo)&&l.push(s[a])}return l}getRangeParagraph(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=this.draw.getElementList(),r=new Map;let s=t;for(;s>=0;){const{pageNo:R,rowNo:d}=n[s];let u=r.get(R);u||(u=[],r.set(R,u)),u.includes(d)||u.unshift(d);const h=i[s],g=i[s-1];if(h.value===w&&!h.listWrap||h.listId!==(g==null?void 0:g.listId)||h.titleId!==(g==null?void 0:g.titleId))break;s--}const l=t===e;if(!l){let R=t+1;for(;R<e;){const{pageNo:d,rowNo:u}=n[R];let h=r.get(d);h||(h=[],r.set(d,h)),h.includes(u)||h.push(u),R++}}let a=e;for(l&&i[t].value===w&&(a+=1);a<n.length;){const R=i[a],d=i[a+1];if(R.value===w&&!R.listWrap||R.listId!==(d==null?void 0:d.listId)||R.titleId!==(d==null?void 0:d.titleId))break;const{pageNo:u,rowNo:h}=n[a];let g=r.get(u);g||(g=[],r.set(u,g)),g.includes(h)||g.push(h),a++}return r}getRangeParagraphInfo(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;let n=-1;const i=[],r=this.getRangeParagraph();if(!r)return null;const s=this.draw.getElementList(),l=this.position.getPositionList();for(let a=0;a<l.length;a++){const R=l[a],d=r.get(R.pageNo);!d||d.includes(R.rowNo)&&(~n||(n=R.index),i.push(s[a]))}return i.length?{elementList:i,startIndex:n}: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:n}=this.range;return e===0&&t.length-1===n&&!this.position.getPositionContext().isTable}getIsPointInRange(t,e){const{startIndex:n,endIndex:i}=this.range,r=this.position.getPositionList();for(let s=n+1;s<=i&&r[s];s++){const{coordinate:{leftTop:a,rightBottom:R}}=r[s];if(t>=a[0]&&t<=R[0]&&e>=a[1]&&e<=R[1])return!0}return!1}getKeywordRangeList(t){const e=this.draw.getSearch().getMatchList(t,this.draw.getOriginalElementList()),n=new Map;for(const r of e){const s=n.get(r.groupId);if(s)s.endIndex+=1;else{const{type:l,groupId:a,tableId:R,index:d,tdIndex:u,trIndex:h}=r,g={startIndex:d,endIndex:d};l===vt.TABLE&&(g.tableId=R,g.startTdIndex=u,g.endTdIndex=u,g.startTrIndex=h,g.endTrIndex=h),n.set(a,g)}}const i=[];return n.forEach(r=>{i.push(r)}),i}getIsCanInput(){var s;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.draw.getElementList(),i=n[t];if(t===e)return(i.controlComponent!==c.ControlComponent.PRE_TEXT||((s=n[t+1])==null?void 0:s.controlComponent)!==c.ControlComponent.PRE_TEXT)&&i.controlComponent!==c.ControlComponent.POST_TEXT;const r=n[e];return!i.controlId&&!r.controlId||(!i.controlId||i.controlComponent===c.ControlComponent.POSTFIX)&&(!r.controlId||r.controlComponent===c.ControlComponent.POSTFIX)||!!i.controlId&&r.controlId===i.controlId&&r.controlComponent!==c.ControlComponent.PRE_TEXT&&r.controlComponent!==c.ControlComponent.POST_TEXT&&r.controlComponent!==c.ControlComponent.POSTFIX}setRange(t,e,n,i,r,s,l){this.getIsRangeChange(t,e,n,i,r,s,l)&&(this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=n,this.range.startTdIndex=i,this.range.endTdIndex=r,this.range.startTrIndex=s,this.range.endTrIndex=l,this.range.isCrossRowCol=!!(i||r||s||l),this.setDefaultStyle(null)),this.range.zone=this.draw.getZone().getZone();const R=this.draw.getControl();if(~t&&~e){const u=this.draw.getElementList()[t];if(u!=null&&u.controlId){R.initControl();return}}R.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 E,C;const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:i,isCrossRowCol:r}=this.range;if(!~n&&!~i)return;let s;if(r){const U=this.draw.getOriginalElementList(),K=this.position.getPositionContext();s=U[K.index]}else{const U=~i?i:0,K=this.draw.getElementList();s=this.getRangeAnchorStyle(K,U)}if(!s)return;const l=this.getSelection()||[s],a=s.type||c.ElementType.TEXT,R=s.font||this.options.defaultFont,d=s.size||this.options.defaultSize,u=!~l.findIndex(U=>!U.bold),h=!~l.findIndex(U=>!U.italic),g=!~l.findIndex(U=>{var K;return!U.underline&&!((K=U.control)!=null&&K.underline)}),L=!~l.findIndex(U=>!U.strikeout),T=s.color||null,O=s.highlight||null,P=s.rowFlex||null,M=(E=s.rowMargin)!=null?E:this.options.defaultRowMargin,f=s.dashArray||[],S=s.level||null,I=s.listType||null,m=s.listStyle||null,N=g&&s.textDecoration||null,F=!!this.draw.getPainterStyle(),Z=this.historyManager.isCanUndo(),W=this.historyManager.isCanRedo(),V=s.groupIds||null,p=(C=s.extension)!=null?C:null,X={type:a,undo:Z,redo:W,painter:F,font:R,size:d,bold:u,italic:h,underline:g,strikeout:L,color:T,highlight:O,rowFlex:P,rowMargin:M,dashArray:f,level:S,listType:I,listStyle:m,groupIds:V,textDecoration:N,extension:p};t&&t(X),e&&this.eventBus.emit("rangeStyleChange",X)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const n=this.options.defaultFont,i=this.options.defaultSize,r=this.options.defaultRowMargin,s=!!this.draw.getPainterStyle(),l=this.historyManager.isCanUndo(),a=this.historyManager.isCanRedo(),R={type:null,undo:l,redo:a,painter:s,font:n,size:i,bold:!1,italic:!1,underline:!1,strikeout:!1,color:null,highlight:null,rowFlex:null,rowMargin:r,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null,textDecoration:null,extension:null};t&&t(R),e&&this.eventBus.emit("rangeStyleChange",R)}shrinkBoundary(t={}){const e=t.elementList||this.draw.getElementList(),n=t.range||this.getRange(),{startIndex:i,endIndex:r}=n;if(!~i&&!~r)return;const s=e[i],l=e[r];if(i===r){if(s.controlComponent===c.ControlComponent.PLACEHOLDER){let a=i-1;for(;a>0;){const R=e[a];if(R.controlId!==s.controlId||R.controlComponent===c.ControlComponent.PREFIX||R.controlComponent===c.ControlComponent.PRE_TEXT){n.startIndex=a,n.endIndex=a;break}a--}}}else{if(s.controlComponent===c.ControlComponent.PLACEHOLDER||l.controlComponent===c.ControlComponent.PLACEHOLDER){let a=r-1;for(;a>0;){const R=e[a];if(R.controlId!==l.controlId||R.controlComponent===c.ControlComponent.PREFIX||R.controlComponent===c.ControlComponent.PRE_TEXT){n.startIndex=a,n.endIndex=a;return}a--}}if(s.controlComponent===c.ControlComponent.PREFIX){let a=i+1;for(;a<e.length;){const R=e[a];if(R.controlId!==s.controlId||R.controlComponent===c.ControlComponent.VALUE){n.startIndex=a-1;break}else if(R.controlComponent===c.ControlComponent.PLACEHOLDER){n.startIndex=a-1,n.endIndex=a-1;return}a++}}if(l.controlComponent!==c.ControlComponent.VALUE){let a=i-1;for(;a>0;){const R=e[a];if(R.controlId!==s.controlId||R.controlComponent===c.ControlComponent.VALUE){n.startIndex=a;break}else if(R.controlComponent===c.ControlComponent.PLACEHOLDER){n.startIndex=a,n.endIndex=a;return}a--}}}}render(t,e,n,i,r){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,n,i,r),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(w,"g"),""):""}}class lr{constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}_renderBackgroundColor(t,e,n,i){t.save(),t.fillStyle=e,t.fillRect(0,0,n,i),t.restore()}_drawImage(t,e,n,i){const{background:r,scale:s}=this.options;if(r.size===c.BackgroundSize.CONTAIN){const l=e.width*s,a=e.height*s;if(!r.repeat||r.repeat===c.BackgroundRepeat.NO_REPEAT)t.drawImage(e,0,0,l,a);else{let R=0,d=0;const u=r.repeat===c.BackgroundRepeat.REPEAT||r.repeat===c.BackgroundRepeat.REPEAT_X?Math.ceil(n*s/l):1,h=r.repeat===c.BackgroundRepeat.REPEAT||r.repeat===c.BackgroundRepeat.REPEAT_Y?Math.ceil(i*s/a):1;for(let g=0;g<u;g++){for(let L=0;L<h;L++)t.drawImage(e,R,d,l,a),d+=a;d=0,R+=l}}}else t.drawImage(e,0,0,n*s,i*s)}_renderBackgroundImage(t,e,n){const{background:i}=this.options,r=this.imageCache.get(i.image);if(r)this._drawImage(t,r,e,n);else{const s=new Image;s.setAttribute("crossOrigin","Anonymous"),s.src=i.image,s.onload=()=>{this.imageCache.set(i.image,s),this._drawImage(t,s,e,n),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}}render(t,e){const{background:{image:n,color:i,applyPageNumbers:r}}=this.options;if(n&&(!(r!=null&&r.length)||r.includes(e))){const{width:s,height:l}=this.options;this._renderBackgroundImage(t,s,l)}else{const s=this.draw.getCanvasWidth(e),l=this.draw.getCanvasHeight(e);this._renderBackgroundColor(t,i,s,l)}}}class Sn{constructor(){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,n,i,r,s,l){const a=!this.fillRect.width;if(!a&&(this.fillColor!==s||this.fillDecorationStyle!==l)){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,n,i,r,s,l);return}a&&(this.fillRect.x=e,this.fillRect.y=n),r&&this.fillRect.height<r&&(this.fillRect.height=r),this.fillRect.width+=i,this.fillColor=s,this.fillDecorationStyle=l}}class ar extends Sn{constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:n,y:i,width:r,height:s}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(n,i,r,s),t.restore(),this.clearFillInfo()}}class Rr{constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:n,pageMode:i}=this.options,r=this.draw.getWidth(),s=i===c.PageMode.CONTINUITY?this.draw.getCanvasHeight(e)/this.draw.getPagePixelRatio():this.draw.getHeight(),l=this.draw.getMargins(),a=this.draw.getMarginIndicatorSize();t.save(),t.translate(.5,.5),t.strokeStyle=n,t.beginPath();const R=[l[3],l[0]],d=[r-l[1],l[0]],u=[l[3],s-l[2]],h=[r-l[1],s-l[2]];t.moveTo(R[0]-a,R[1]),t.lineTo(...R),t.lineTo(R[0],R[1]-a),t.moveTo(d[0]+a,d[1]),t.lineTo(...d),t.lineTo(d[0],d[1]-a),t.moveTo(u[0]-a,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]+a),t.moveTo(h[0]+a,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+a),t.stroke(),t.restore()}}class cr{constructor(t){this.draw=t,this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.searchNavigateIndex=null,this.searchOptions=null,this.searchKeyword=null,this.searchMatchList=[]}getSearchKeyword(){return this.searchKeyword}setSearchKeyword(t,e){this.searchKeyword=t,this.searchNavigateIndex=null,this.searchOptions=e||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 n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t>=0;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t-(this.searchKeyword.length-1);break}t--}if(!e){if(this.searchMatchList[this.searchMatchList.length-1].groupId===n)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 n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t<this.searchMatchList.length;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t;break}t++}if(!e){if(this.searchMatchList[0].groupId===n)return null;this.searchNavigateIndex=0}}return this.searchNavigateIndex}searchNavigateScrollIntoView(t){const{coordinate:{leftTop:e,leftBottom:n,rightTop:i},pageNo:r}=t,s=this.draw.getHeight(),l=this.draw.getPageGap(),a=r*(s+l),R=document.createElement("div");R.style.position="absolute";const d=50;R.style.width=`${i[0]-e[0]+d}px`,R.style.height=`${n[1]-e[1]+d}px`,R.style.left=`${e[0]}px`,R.style.top=`${e[1]+a}px`,this.draw.getContainer().append(R),R.scrollIntoView(!1),R.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,n=null;for(let i=0;i<this.searchMatchList.length;i++){const r=this.searchMatchList[i];n!==r.groupId&&(n=r.groupId,e+=1)}return{index:t,count:e}}getMatchList(t,e){const{isRegEnable:n=!1,isIgnoreCase:i=!0}=this.searchOptions||{},r=i?t.toLocaleLowerCase():t,s=[],l=[],a=e.length,R=[];for(let g=0;g<a;g++)e[g].type===c.ElementType.TABLE&&R.push(g);let d=0,u=0;for(;u<a-1;){const g=R.length?R[d]:a,L=e.slice(u,g);L.length&&l.push({index:u,type:vt.PAGE,elementList:L});const T=e[g];T&&l.push({index:g,type:vt.TABLE,elementList:[T]}),u=g+1,d++}function h(g,L,T,O){if(!g)return;let P=T.map(m=>{var N,F;return!m.type||Qt.includes(m.type)&&m.controlComponent!==c.ControlComponent.CHECKBOX&&m.controlComponent!==c.ControlComponent.RADIO&&!m.hide&&!((N=m.control)!=null&&N.hide)&&!((F=m.area)!=null&&F.hide)?m.value:w}).filter(Boolean).join("");i&&(P=P.toLocaleLowerCase());const M=[],f=n?new RegExp(g):g;let{index:S,length:I}=Qn(P,f);for(;S!==-1&&I!==0;){M.push({index:S,length:I});const m=Qn(P,f,S+I);S=m.index,I=m.length}for(let m=0;m<M.length;m++){const{index:N,length:F}=M[m],Z=q();for(let W=0;W<F;W++){const V=N+W+((O==null?void 0:O.startIndex)||0);s.push({type:L,index:V,groupId:Z,...O})}}}for(let g=0;g<l.length;g++){const L=l[g];if(L.type===vt.TABLE){const T=L.elementList[0];for(let O=0;O<T.trList.length;O++){const P=T.trList[O];for(let M=0;M<P.tdList.length;M++){const f=P.tdList[M],S={tableId:T.id,tableIndex:L.index,trIndex:O,tdIndex:M,tdId:f.id};h(r,L.type,f.value,S)}}}else h(r,L.type,L.elementList,{startIndex:L.index})}return s}compute(t){var s;const e=((s=this.searchOptions)==null?void 0:s.isLimitSelection)&&!this.range.getIsCollapsed(),n=e?this.range.getSelectionElementList():this.draw.getOriginalElementList();if(!(n!=null&&n.length)||(this.searchMatchList=this.getMatchList(t,n),!e||!this.searchMatchList.length))return;const{startIndex:i}=this.range.getRange(),r=i+1;for(const l of this.searchMatchList)l.type===vt.TABLE?l.tableIndex+=r:l.index+=r}render(t,e){var a,R;if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:n,searchMatchColor:i,searchNavigateMatchColor:r}=this.options,s=this.position.getOriginalPositionList(),l=this.draw.getOriginalElementList();t.save(),t.globalAlpha=n;for(let d=0;d<this.searchMatchList.length;d++){const u=this.searchMatchList[d];let h=null;if(u.type===vt.TABLE){const{tableIndex:m,trIndex:N,tdIndex:F,index:Z}=u;h=(R=(a=l[m])==null?void 0:a.trList[N].tdList[F])==null?void 0:R.positionList[Z]}else h=s[u.index];if(!h)continue;const{coordinate:{leftTop:g,leftBottom:L,rightTop:T},pageNo:O}=h;if(O!==e)continue;if(this.getSearchNavigateIndexList().includes(d)){t.fillStyle=r;const m=this.searchMatchList[d-1];(!m||m.groupId!==u.groupId)&&this.searchNavigateScrollIntoView(h)}else t.fillStyle=i;const M=g[0],f=g[1],S=T[0]-g[0],I=L[1]-g[1];t.fillRect(M,f,S,I)}t.restore()}replace(t,e){var T,O,P,M;if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const r=e==null?void 0:e.index;if(ze(r)){const f=[];i.forEach(S=>{const I=f[f.length-1];!I||I[0].groupId!==S.groupId?f.push([S]):I.push(S)}),i=f[r]}if(!(i!=null&&i.length))return;const s=this.draw.isDesignMode();let l=0,a=0,R="",d="",u=-1;const h=this.draw.getOriginalElementList();for(let f=0;f<i.length;f++){const S=i[f];if(S.type===vt.TABLE){const{tableIndex:I,trIndex:m,tdIndex:N,index:F,tdId:Z}=S;d&&Z!==d&&(a=0),d=Z;const W=I+l,V=h[W].trList[m].tdList[N].value,p=F+a,X=V[p];if(!s&&(((T=X==null?void 0:X.control)==null?void 0:T.deletable)===!1||((O=X==null?void 0:X.title)==null?void 0:O.deletable)===!1))continue;if(t===""){this.draw.spliceElementList(V,p,1),a--,~u||(u=f);continue}if(R===S.groupId){this.draw.spliceElementList(V,p,1),a--;continue}~u||(u=f);for(let E=0;E<t.length;E++){const C=t[E];E===0?X.value=C:(this.draw.spliceElementList(V,p+E,0,[{...X,value:C}]),a++)}}else{const I=S.index+l,m=h[I];if(!s&&(((P=m==null?void 0:m.control)==null?void 0:P.deletable)===!1||((M=m==null?void 0:m.title)==null?void 0:M.deletable)===!1)||m.type===c.ElementType.CONTROL&&m.controlComponent!==c.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(h,I,1),l--,~u||(u=f);continue}if(~u||(u=f),R===S.groupId){this.draw.spliceElementList(h,I,1),l--;continue}for(let N=0;N<t.length;N++){const F=t[N];N===0?m.value=F:(this.draw.spliceElementList(h,I+N,0,[{...m,value:F}]),l++)}}R=S.groupId}if(!~u)return;const g=i[u],L=g.index+(t.length-1);if(g.type===vt.TABLE){const{tableIndex:f,trIndex:S,tdIndex:I,index:m}=g,N=h[f].trList[S].tdList[I].value[m];this.position.setPositionContext({isTable:!0,index:f,trIndex:S,tdIndex:I,tdId:N.tdId,trId:N.trId,tableId:N.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(L,L),this.draw.render({curIndex:L})}}class dr extends Sn{constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{scale:e,strikeoutColor:n}=this.options,{x:i,y:r,width:s}=this.fillRect;t.save(),t.lineWidth=e,t.strokeStyle=n;const l=r+.5;t.beginPath(),t.moveTo(i,l),t.lineTo(i+s,l),t.stroke(),t.restore(),this.clearFillInfo()}}c.TextDecorationStyle=void 0,function(o){o.SOLID="solid",o.DOUBLE="double",o.DASHED="dashed",o.DOTTED="dotted",o.WAVY="wavy"}(c.TextDecorationStyle||(c.TextDecorationStyle={}));var ce;(function(o){o.SOLID="solid",o.DASHED="dashed",o.DOTTED="dotted"})(ce||(ce={}));class ur extends Sn{constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,r){const s=e+i;switch(t.beginPath(),r){case ce.DASHED:t.setLineDash([3,1]);break;case ce.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(s,n),t.stroke()}_drawDouble(t,e,n,i){const s=e+i,l=n+3*this.options.scale;t.beginPath(),t.moveTo(e,n),t.lineTo(s,n),t.stroke(),t.beginPath(),t.moveTo(e,l),t.lineTo(s,l),t.stroke()}_drawWave(t,e,n,i){const{scale:r}=this.options,s=1.2*r,l=1/r,a=n+2*s;t.beginPath();for(let R=0;R<i;R++){const d=s*Math.sin(l*R);t.lineTo(e+R,a+d)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:i,y:r,width:s}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const l=Math.floor(r+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case c.TextDecorationStyle.WAVY:this._drawWave(t,i,l,s);break;case c.TextDecorationStyle.DOUBLE:this._drawDouble(t,i,l,s);break;case c.TextDecorationStyle.DASHED:this._drawLine(t,i,l,s,ce.DASHED);break;case c.TextDecorationStyle.DOTTED:this._drawLine(t,i,l,s,ce.DOTTED);break;default:this._drawLine(t,i,l,s);break}t.restore(),this.clearFillInfo()}}class hr{constructor(t){this.draw=t,this.options=t.getOptions(),this.ctx=t.getCtx(),this.curX=-1,this.curY=-1,this.text="",this.curStyle="",this.cacheMeasureText=new Map}measureBasisWord(t,e){t.save(),t.font=e;const n=this.measureText(t,{value:zi});return t.restore(),n}measureWord(t,e,n){const i=this.draw.getLetterReg();let r=0,s=null,l=n;for(;l<e.length;){const a=e[l];if(a.type&&a.type!==c.ElementType.TEXT||!i.test(a.value)){s=a;break}r+=this.measureText(t,a).width,l++}return{width:r,endElement:s}}measurePunctuationWidth(t,e){return!e||!_i.includes(e.value)?0:(t.font=this.draw.getElementFont(e),this.measureText(t,e).width)}measureText(t,e){if(e.width){const s=t.measureText(e.value);return{width:e.width,actualBoundingBoxAscent:s.actualBoundingBoxAscent,actualBoundingBoxDescent:s.actualBoundingBoxDescent,actualBoundingBoxLeft:s.actualBoundingBoxLeft,actualBoundingBoxRight:s.actualBoundingBoxRight,fontBoundingBoxAscent:s.fontBoundingBoxAscent,fontBoundingBoxDescent:s.fontBoundingBoxDescent}}const n=`${e.value}${t.font}`,i=this.cacheMeasureText.get(n);if(i)return i;const r=t.measureText(e.value);return this.cacheMeasureText.set(n,r),r}getBasisWordBoundingBoxAscent(t,e){return this.measureBasisWord(t,e).actualBoundingBoxAscent}complete(){this._render(),this.text=""}record(t,e,n,i){if(this.ctx=t,this.options.renderMode===c.RenderMode.COMPATIBILITY){this._setCurXY(n,i),this.text=e.value,this.curStyle=e.style,this.curColor=e.color,this.complete();return}this.text||this._setCurXY(n,i),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(n,i)),this.text+=e.value,this.curStyle=e.style,this.curColor=e.color}_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,this.ctx.fillText(this.text,this.curX,this.curY),this.ctx.restore())}}class de{constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const r=i===c.NumberType.CHINESE?ao(e):`${e}`;return t.replace(n,r)}render(t,e){const{scale:n,pageNumber:{size:i,font:r,color:s,rowFlex:l,numberType:a,format:R,startPageNo:d,fromPageNo:u}}=this.options;if(e<u)return;let h=R;const g=new RegExp(Oe.PAGE_NO);g.test(h)&&(h=de.formatNumberPlaceholder(h,e+d-u,g,a));const L=new RegExp(Oe.PAGE_COUNT);L.test(h)&&(h=de.formatNumberPlaceholder(h,this.draw.getPageCount()-u,L,a));const T=this.draw.getWidth(),O=this.draw.getHeight(),P=this.draw.getPageNumberBottom(),M=O-P;t.save(),t.fillStyle=s,t.font=`${i*n}px ${r}`;let f=0;const S=this.draw.getMargins(),{width:I}=t.measureText(h);l===c.RowFlex.CENTER?f=(T-I)/2:l===c.RowFlex.RIGHT?f=T-I-S[1]:f=S[3],t.fillText(h,f,M),t.restore()}}class gr{constructor(t){this._observer=io(()=>{const{intersectionPageNo:e,visiblePageNoList:n}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(e),this.draw.setVisiblePageNoList(n)},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(),n=this.scrollContainer===document?Math.max(document.documentElement.clientHeight,window.innerHeight):this.scrollContainer.clientHeight,i=Math.min(e.bottom,n)-Math.max(e.top,0);return{intersectionHeight:i>0?i:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let n=0,i=0;for(let r=0;r<t.length;r++){const s=t[r],{intersectionHeight:l}=this.getElementVisibleInfo(s);if(i&&!l)break;l&&e.push(r),l>i&&(i=l,n=r)}return{intersectionPageNo:n,visiblePageNoList:e}}}class Lr{constructor(t){this.step=5,this.thresholdPoints=[70,40,10,20],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 n=this.selectionContainer.getBoundingClientRect();this.containerRect=n}},this._mouseup=()=>{this.isMousedown=!1,this._stopMove()},this._mousemove=n=>{if(!this.isMousedown||this.rangeManager.getIsCollapsed())return;let{x:i,y:r}=n;this.containerRect&&(i=i-this.containerRect.x,r=r-this.containerRect.y),r<this.thresholdPoints[0]?this._startMove(Pt.UP):this.clientHeight-r<=this.thresholdPoints[1]?this._startMove(Pt.DOWN):i<this.thresholdPoints[2]?this._startMove(Pt.LEFT):this.clientWidth-i<this.thresholdPoints[3]?this._startMove(Pt.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,n=this.selectionContainer instanceof Document?window.scrollX:e.scrollLeft,i=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===Pt.DOWN?e.scrollTo(n,i+this.step):t===Pt.UP?e.scrollTo(n,i-this.step):t===Pt.LEFT?e.scrollTo(n-this.step,i):e.scrollTo(n+this.step,i),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 Tr{constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){var n;const e=et(t);for(let i=0;i<t.length;i++){const r=e[i];for(let s=r.tdList.length-1;s>=0;s--){const l=r.tdList[s],{rowspan:a,rowIndex:R,colIndex:d}=l,u=R+a-1;if(u!==s){const h=r.tdList.splice(s,1)[0];(n=e[u])==null||n.tdList.splice(d,0,h)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:r,startTdIndex:s,endTdIndex:l,startTrIndex:a,endTrIndex:R}=this.range.getRange(),h=this.draw.getOriginalElementList()[e].trList;if(!r)return[[h[n].tdList[i]]];let g=h[a].tdList[s],L=h[R].tdList[l];(g.x>L.x||g.y>L.y)&&([g,L]=[L,g]);const T=g.colIndex,O=L.colIndex+(L.colspan-1),P=g.rowIndex,M=L.rowIndex+(L.rowspan-1),f=[];for(let S=0;S<h.length;S++){const I=h[S],m=[];for(let N=0;N<I.tdList.length;N++){const F=I.tdList[N],Z=F.colIndex,W=F.rowIndex;Z>=T&&Z<=O&&W>=P&&W<=M&&m.push(F)}m.length&&f.push(m)}return f.length?f:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:i,width:r,height:s,isDrawFullBorder:l,borderExternalWidth:a}=t,{scale:R}=this.options,d=e.lineWidth;a&&(e.lineWidth=a*R),e.beginPath();const u=Math.round(n),h=Math.round(i);e.translate(.5,.5),l?e.rect(u,h,r,s):(e.moveTo(u,h+s),e.lineTo(u,h),e.lineTo(u+r,h)),e.stroke(),a&&(e.lineWidth=d),e.translate(-.5,-.5)}_drawSlash(t,e,n,i){var d,u;const{scale:r}=this.options;t.save();const s=e.width*r,l=e.height*r,a=Math.round(e.x*r+n),R=Math.round(e.y*r+i);(d=e.slashTypes)!=null&&d.includes(c.TdSlash.FORWARD)&&(t.moveTo(a+s,R),t.lineTo(a,R+l)),(u=e.slashTypes)!=null&&u.includes(c.TdSlash.BACK)&&(t.moveTo(a,R),t.lineTo(a+s,R+l)),t.stroke(),t.restore()}_drawBorder(t,e,n,i){var M,f,S,I,m,N;const{colgroup:r,trList:s,borderType:l,borderColor:a,borderWidth:R=1,borderExternalWidth:d}=e;if(!r||!s)return;const{scale:u,table:{defaultBorderColor:h}}=this.options,g=e.width*u,L=e.height*u,T=l===c.TableBorder.EMPTY,O=l===c.TableBorder.EXTERNAL,P=l===c.TableBorder.INTERNAL;t.save(),l===c.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=R*u,t.strokeStyle=a||h,!T&&!P&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:g,height:L,borderExternalWidth:d,isDrawFullBorder:O});for(let F=0;F<s.length;F++){const Z=s[F];for(let W=0;W<Z.tdList.length;W++){const V=Z.tdList[W];if((M=V.slashTypes)!=null&&M.length&&this._drawSlash(t,V,n,i),!((f=V.borderTypes)!=null&&f.length)&&(T||O))continue;const p=V.width*u,X=V.height*u,E=Math.round(V.x*u+n+p),C=Math.round(V.y*u+i);if(t.translate(.5,.5),t.beginPath(),(S=V.borderTypes)!=null&&S.includes(c.TdBorder.TOP)&&(t.moveTo(E-p,C),t.lineTo(E,C),t.stroke()),(I=V.borderTypes)!=null&&I.includes(c.TdBorder.RIGHT)&&(t.moveTo(E,C),t.lineTo(E,C+X),t.stroke()),(m=V.borderTypes)!=null&&m.includes(c.TdBorder.BOTTOM)&&(t.moveTo(E,C+X),t.lineTo(E-p,C+X),t.stroke()),(N=V.borderTypes)!=null&&N.includes(c.TdBorder.LEFT)&&(t.moveTo(E-p,C),t.lineTo(E-p,C+X),t.stroke()),!T&&!O){if((!P||V.colIndex+V.colspan<r.length)&&(t.moveTo(E,C),t.lineTo(E,C+X),d&&d!==R&&V.colIndex+V.colspan===r.length)){const U=t.lineWidth;t.lineWidth=d*u,t.stroke(),t.beginPath(),t.lineWidth=U}if(!P||V.rowIndex+V.rowspan<s.length){const U=d&&d!==R&&V.rowIndex+V.rowspan===s.length;if(U&&(t.stroke(),t.beginPath()),t.moveTo(E,C+X),t.lineTo(E-p,C+X),U){const K=t.lineWidth;t.lineWidth=d*u,t.stroke(),t.beginPath(),t.lineWidth=K}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,i){const{trList:r}=e;if(!r)return;const{scale:s}=this.options;for(let l=0;l<r.length;l++){const a=r[l];for(let R=0;R<a.tdList.length;R++){const d=a.tdList[R];if(!d.backgroundColor)continue;t.save();const u=d.width*s,h=d.height*s,g=Math.round(d.x*s+n),L=Math.round(d.y*s+i);t.fillStyle=d.backgroundColor,t.fillRect(g,L,u,h),t.restore()}}}getTableWidth(t){return t.colgroup.reduce((e,n)=>e+n.width,0)}getTableHeight(t){const e=t.trList;return e!=null&&e.length?this.getTdListByColIndex(e,0).reduce((n,i)=>n+i.height,0):0}getRowCountByColIndex(t,e){return this.getTdListByColIndex(t,e).reduce((n,i)=>n+i.rowspan,0)}getTdListByColIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const r=t[i].tdList;for(let s=0;s<r.length;s++){const l=r[s],a=l.colIndex,R=a+l.colspan-1;e>=a&&e<=R&&n.push(l)}}return n}getTdListByRowIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const r=t[i].tdList;for(let s=0;s<r.length;s++){const l=r[s],a=l.rowIndex,R=a+l.rowspan-1;e>=a&&e<=R&&n.push(l)}}return n}computeRowColInfo(t){const{colgroup:e,trList:n}=t;if(!e||!n)return;let i=0;for(let r=0;r<n.length;r++){const s=n[r],l=n.length-1===r;for(let a=0;a<s.tdList.length;a++){const R=s.tdList[a];let d=0;if(n.length>1&&r!==0){const P=s.tdList[a-1],M=P?P.colIndex+P.colspan:a;for(let f=M;f<e.length;f++)if(this.getRowCountByColIndex(n.slice(0,r),f)===r){d=f;let I=0;for(let m=0;m<f;m++)I+=e[m].width;i=I;break}}else{const P=s.tdList[a-1];P&&(d=P.colIndex+P.colspan)}let u=0;for(let P=0;P<R.colspan;P++)u+=e[P+d].width;let h=0;for(let P=0;P<R.rowspan;P++)h+=(n[P+r]||n[r]).height;const g=s.tdList.length-1===a;let L=l;if(!L&&R.rowspan>1){const P=n.length-1-r;L=R.rowspan-1===P}const T=l&&g;R.isLastRowTd=g,R.isLastColTd=L,R.isLastTd=T,R.x=i;let O=0;for(let P=0;P<r;P++){const M=n[P].tdList;for(let f=0;f<M.length;f++){const S=M[f];if(d>=S.colIndex&&d<S.colIndex+S.colspan){O+=S.height;break}}}R.y=O,R.width=u,R.height=h,R.rowIndex=r,R.colIndex=d,R.trIndex=r,R.tdIndex=a,i+=u,g&&!T&&(i=0)}}}drawRange(t,e,n,i){const{scale:r,rangeAlpha:s,rangeColor:l}=this.options,{type:a,trList:R}=e;if(!R||a!==c.ElementType.TABLE)return;const{isCrossRowCol:d,startTdIndex:u,endTdIndex:h,startTrIndex:g,endTrIndex:L}=this.range.getRange();if(!d)return;let T=R[g].tdList[u],O=R[L].tdList[h];(T.x>O.x||T.y>O.y)&&([T,O]=[O,T]);const P=T.colIndex,M=O.colIndex+(O.colspan-1),f=T.rowIndex,S=O.rowIndex+(O.rowspan-1);t.save();for(let I=0;I<R.length;I++){const m=R[I];for(let N=0;N<m.tdList.length;N++){const F=m.tdList[N],Z=F.colIndex,W=F.rowIndex;if(Z>=P&&Z<=M&&W>=f&&W<=S){const V=F.x*r,p=F.y*r,X=F.width*r,E=F.height*r;t.globalAlpha=s,t.fillStyle=l,t.fillRect(V+n,p+i,X,E)}}}t.restore()}render(t,e,n,i){this._drawBackgroundColor(t,e,n,i),this._drawBorder(t,e,n,i)}}var Bt;(function(o){o.ROW="row",o.COL="col"})(Bt||(Bt={}));class Pr{constructor(t){this.MIN_TD_WIDTH=20,this.ROW_COL_OFFSET=18,this.ROW_COL_QUICK_WIDTH=16,this.ROW_COL_QUICK_OFFSET=5,this.ROW_COL_QUICK_POSITION=this.ROW_COL_OFFSET+(this.ROW_COL_OFFSET-this.ROW_COL_QUICK_WIDTH)/2,this.BORDER_VALUE=4,this.TABLE_SELECT_OFFSET=20,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,n,i,r,s;(t=this.toolRowContainer)==null||t.remove(),(e=this.toolRowAddBtn)==null||e.remove(),(n=this.toolColAddBtn)==null||n.remove(),(i=this.toolTableSelectBtn)==null||i.remove(),(r=this.toolColContainer)==null||r.remove(),(s=this.toolBorderContainer)==null||s.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:n,tdIndex:i}=this.position.getPositionContext();if(!t)return;this.dispose();const r=this.draw.getOriginalElementList(),s=this.position.getOriginalPositionList(),l=r[e];if(l.tableToolDisabled&&!this.draw.isDesignMode())return;const{scale:a,table:{overflow:R}}=this.options,d=s[e],{colgroup:u,trList:h}=l,{coordinate:{leftTop:g}}=d,L=this.draw.getHeight(),T=this.draw.getPageGap(),O=this.draw.getPageNo()*(L+T),P=g[0],M=g[1]+O,f=l.trList[n].tdList[i],S=f.rowIndex,I=f.colIndex,m=l.height*a,N=l.width*a,F=document.createElement("div");F.classList.add(`${x}-table-tool__select`),F.style.height=`${m*a}`,F.style.left=`${P}px`,F.style.top=`${M}px`,F.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*a}px, ${-this.TABLE_SELECT_OFFSET*a}px)`,F.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(F),this.toolTableSelectBtn=F;const Z=h.map(U=>U.height),W=document.createElement("div");W.classList.add(`${x}-table-tool__row`),W.style.transform=`translateX(-${this.ROW_COL_OFFSET*a}px)`;for(let U=0;U<Z.length;U++){const K=Z[U]*a,b=document.createElement("div");b.classList.add(`${x}-table-tool__row__item`),U===S&&b.classList.add("active"),b.onclick=()=>{const y=this.draw.getTableParticle().getTdListByRowIndex(h,U),D=y[0],H=y[y.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:D.trIndex,tdIndex:D.tdIndex,tableId:l.id}),this.range.setRange(0,0,l.id,D.tdIndex,H.tdIndex,D.trIndex,H.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(W,U)};const Y=document.createElement("div");Y.classList.add(`${x}-table-tool__anchor`),Y.onmousedown=y=>{this._mousedown({evt:y,element:l,index:U,order:Bt.ROW})},b.append(Y),b.style.height=`${K}px`,W.append(b)}W.style.left=`${P}px`,W.style.top=`${M}px`,this.container.append(W),this.toolRowContainer=W;const V=document.createElement("div");V.classList.add(`${x}-table-tool__quick__add`),V.style.height=`${m*a}`,V.style.left=`${P}px`,V.style.top=`${M+m}px`,V.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*a}px, ${this.ROW_COL_QUICK_OFFSET*a}px)`,V.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:h.length-1,tdIndex:0,tableId:l.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(V),this.toolRowAddBtn=V;const p=u.map(U=>U.width),X=document.createElement("div");X.classList.add(`${x}-table-tool__col`),X.style.transform=`translateY(-${this.ROW_COL_OFFSET*a}px)`;for(let U=0;U<p.length;U++){const K=p[U]*a,b=document.createElement("div");b.classList.add(`${x}-table-tool__col__item`),U===I&&b.classList.add("active"),b.onclick=()=>{const y=this.draw.getTableParticle().getTdListByColIndex(h,U),D=y[0],H=y[y.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:D.trIndex,tdIndex:D.tdIndex,tableId:l.id}),this.range.setRange(0,0,l.id,D.tdIndex,H.tdIndex,D.trIndex,H.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(X,U)};const Y=document.createElement("div");Y.classList.add(`${x}-table-tool__anchor`),Y.onmousedown=y=>{this._mousedown({evt:y,element:l,index:U,order:Bt.COL})},b.append(Y),b.style.width=`${K}px`,X.append(b)}X.style.left=`${P}px`,X.style.top=`${M}px`,this.container.append(X),this.toolColContainer=X;const E=document.createElement("div");E.classList.add(`${x}-table-tool__quick__add`),E.style.height=`${m*a}`,E.style.left=`${P+N}px`,E.style.top=`${M}px`,E.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*a}px, -${this.ROW_COL_QUICK_POSITION*a}px)`,E.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:h[0].tdList.length-1||0,tableId:l.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(E),this.toolColAddBtn=E;const C=document.createElement("div");C.classList.add(`${x}-table-tool__border`),C.style.height=`${m}px`,C.style.width=`${N}px`,C.style.left=`${P}px`,C.style.top=`${M}px`;for(let U=0;U<h.length;U++){const K=h[U];for(let b=0;b<K.tdList.length;b++){const Y=K.tdList[b],y=document.createElement("div");y.classList.add(`${x}-table-tool__border__row`),y.style.width=`${Y.width*a}px`,y.style.height=`${this.BORDER_VALUE}px`,y.style.top=`${(Y.y+Y.height)*a-this.BORDER_VALUE/2}px`,y.style.left=`${Y.x*a}px`,y.onmousedown=H=>{this._mousedown({evt:H,element:l,index:Y.rowIndex+Y.rowspan-1,order:Bt.ROW})},C.appendChild(y);const D=document.createElement("div");if(D.classList.add(`${x}-table-tool__border__col`),D.style.width=`${this.BORDER_VALUE}px`,D.style.height=`${Y.height*a}px`,D.style.top=`${Y.y*a}px`,D.style.left=`${(Y.x+Y.width)*a-this.BORDER_VALUE/2}px`,D.onmousedown=H=>{this._mousedown({evt:H,element:l,index:Y.colIndex+Y.colspan-1,order:Bt.COL})},C.appendChild(D),R&&Y.colIndex===0){const H=document.createElement("div");H.classList.add(`${x}-table-tool__border__col`),H.style.width=`${this.BORDER_VALUE}px`,H.style.height=`${Y.height*a}px`,H.style.top=`${Y.y*a}px`,H.style.left=`${Y.x*a-this.BORDER_VALUE/2}px`,H.onmousedown=_=>{this._mousedown({evt:_,element:l,index:0,isLeftStartBorder:!0,order:Bt.COL})},C.appendChild(H)}}}this.container.append(C),this.toolBorderContainer=C}_setAnchorActive(t,e){const n=t.children;for(let i=0;i<n.length;i++){const r=n[i];i===e?r.classList.add("active"):r.classList.remove("active")}}_mousedown(t){const{evt:e,index:n,order:i,element:r,isLeftStartBorder:s}=t;this.canvas=this.draw.getPage();const{scale:l,table:{overflow:a}}=this.options,R=this.draw.getWidth(),d=this.draw.getHeight(),u=this.draw.getPageGap(),h=this.draw.getPageNo()*(d+u);this.mousedownX=e.x,this.mousedownY=e.y;const g=e.target,L=this.canvas.getBoundingClientRect(),T=window.getComputedStyle(g).cursor;document.body.style.cursor=T,this.canvas.style.cursor=T;let O=0,P=0;const M=document.createElement("div");M.classList.add(`${x}-table-anchor__line`),i===Bt.ROW?(M.classList.add(`${x}-table-anchor__line__row`),M.style.width=`${R}px`,O=0,P=h+this.mousedownY-L.top):(M.classList.add(`${x}-table-anchor__line__col`),M.style.height=`${d}px`,O=this.mousedownX-L.left,P=h),M.style.left=`${O}px`,M.style.top=`${P}px`,this.container.append(M),this.anchorLine=M;let f=0,S=0;const I=m=>{const N=this._mousemove(m,i,O,P);N&&(f=N.dx,S=N.dy)};document.addEventListener("mousemove",I),document.addEventListener("mouseup",()=>{var N;let m=!1;if(i===Bt.ROW){const F=r.trList,Z=F[n]||F[n-1],{defaultTrMinHeight:W}=this.options.table;S<0&&Z.height+S<W&&(S=W-Z.height),S&&(Z.height+=S,Z.minHeight=Z.height,m=!0)}else{const{colgroup:F}=r;if(F&&f)if(a&&s)F[n].width-f/l<=this.MIN_TD_WIDTH&&(f=(F[n].width-this.MIN_TD_WIDTH)*l),F[n].width-=f/l,r.width-=f/l,r.translateX=(r.translateX||0)+f/l,m=!0;else{const Z=this.draw.getInnerWidth(),W=F[n].width;f<0&&W+f<this.MIN_TD_WIDTH&&(f=this.MIN_TD_WIDTH-W);const V=(N=F[n+1])==null?void 0:N.width;f>0&&V&&V-f<this.MIN_TD_WIDTH&&(f=V-this.MIN_TD_WIDTH);const p=W+f;if(!a&&n===F.length-1){let X=0;for(let E=0;E<F.length;E++){const C=F[E];E===n+1&&(X-=f),E===n&&(X+=p),E!==n&&(X+=C.width)}if(X>Z){const E=r.width;f=Z-E}}f&&(F.length-1!==n&&(F[n+1].width-=f/l),F[n].width+=f/l,m=!0)}}m&&this.draw.render({isSetCursor:!1}),M.remove(),document.removeEventListener("mousemove",I),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,i){if(!this.anchorLine)return null;const r=t.x-this.mousedownX,s=t.y-this.mousedownY;return e===Bt.ROW?this.anchorLine.style.top=`${i+s}px`:this.anchorLine.style.left=`${n+r}px`,t.preventDefault(),{dx:r,dy:s}}}class Or{constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:n}=this._createHyperlinkPopupDom();this.hyperlinkDom=n,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${x}-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}}drawHyperlinkPopup(t,e){const{coordinate:{leftTop:[n,i]},lineHeight:r}=e,s=this.draw.getHeight(),l=this.draw.getPageGap(),a=this.draw.getPageNo()*(s+l);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${i+a+r}px`;const R=t.url||"#";this.hyperlinkDom.href=R,this.hyperlinkDom.title=R,this.hyperlinkDom.innerText=R}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,i){t.save(),t.font=e.style,e.color||(e.color=this.options.defaultHyperlinkColor),t.fillStyle=e.color,e.underline===void 0&&(e.underline=!0),t.fillText(e.value,n,i),t.restore()}}class Mr{constructor(t){this.options=t.getOptions()}render(t,e,n,i){var P,M,f,S;const{scale:r,label:{defaultBackgroundColor:s,defaultColor:l,defaultBorderRadius:a,defaultPadding:R}}=this.options,d=((P=e.label)==null?void 0:P.backgroundColor)||s,u=((M=e.label)==null?void 0:M.color)||l,h=((f=e.label)==null?void 0:f.borderRadius)||a,g=((S=e.label)==null?void 0:S.padding)||R;t.save(),t.font=e.style;const{width:L,height:T,boundingBoxAscent:O}=e.metrics;t.fillStyle=d,this._drawRoundedRect(t,n,i-O,L,T+(g[0]+g[3])*r,h*r),t.fill(),t.fillStyle=u,t.fillText(e.value,n+g[3]*r,i),t.restore()}_drawRoundedRect(t,e,n,i,r,s){t.beginPath(),t.moveTo(e+s,n),t.lineTo(e+i-s,n),t.quadraticCurveTo(e+i,n,e+i,n+s),t.lineTo(e+i,n+r-s),t.quadraticCurveTo(e+i,n+r,e+i-s,n+r),t.lineTo(e+s,n+r),t.quadraticCurveTo(e,n+r,e,n+r-s),t.lineTo(e,n+s),t.quadraticCurveTo(e,n,e+s,n),t.closePath()}}class fr{constructor(t,e){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(),n=gn(this.elementList);this.rowList=this.draw.computeRowList({startX:e[3],startY:this.getHeaderTop(),innerWidth:t,elementList:this.elementList,surroundElementList:n})}_computePositionList(){const t=this.getHeaderTop(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],r=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:r,innerWidth:e,zone:c.EditorZone.HEADER})}getHeaderTop(){const{header:{top:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{header:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*Wn[t])}getHeight(){if(this.options.header.disabled)return 0;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(),i=this.getHeaderTop()+e-t[0];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isHeaderActive()?1:this.options.header.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),r=[];let s=0;for(let l=0;l<this.rowList.length;l++){const a=this.rowList[l];if(s+a.height>i)break;r.push(a),s+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:r,pageNo:e,startIndex:0,innerWidth:n,zone:c.EditorZone.HEADER}),t.restore()}}class Sr{getOffsetY(t){return-t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class mr{getOffsetY(t){return t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class Ir{constructor(t){this.options=t.getOptions()}render(t,e,n,i){var R;t.save();const{scale:r,separator:{lineWidth:s,strokeStyle:l}}=this.options;t.lineWidth=(e.lineWidth||s)*r,t.strokeStyle=e.color||l,(R=e.dashArray)!=null&&R.length&&t.setLineDash(e.dashArray);const a=Math.round(i);t.translate(0,t.lineWidth/2),t.beginPath(),t.moveTo(n,a),t.lineTo(n+e.width*r,a),t.stroke(),t.restore()}}class Xr{constructor(t){this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,n,i){const{pageBreak:{font:r,fontSize:s,lineDash:l}}=this.options,a=this.i18n.t("pageBreak.displayName"),{scale:R,defaultRowMargin:d}=this.options,u=s*R,h=e.width*R,g=this.draw.getDefaultBasicRowMarginHeight()*d;t.save(),t.font=`${u}px ${r}`;const L=t.measureText(a),T=(h-L.width)/2;t.setLineDash(l),t.translate(0,.5+g),t.beginPath(),t.moveTo(n,i),t.lineTo(n+T,i),t.moveTo(n+T+L.width,i),t.lineTo(n+h,i),t.stroke(),t.fillText(a,n+T,i+L.actualBoundingBoxAscent-u/2),t.restore()}}class Nr{constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}renderText(t,e){const{watermark:{data:n,opacity:i,font:r,size:s,color:l,repeat:a,gap:R,numberType:d},scale:u}=this.options,h=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=i,t.font=`${s*u}px ${r}`;let L=n;const T=new RegExp(Oe.PAGE_NO);T.test(L)&&(L=de.formatNumberPlaceholder(L,e+1,T,d));const O=new RegExp(Oe.PAGE_COUNT);O.test(L)&&(L=de.formatNumberPlaceholder(L,this.draw.getPageCount(),O,d));const P=t.measureText(L);if(a){const M=this.draw.getPagePixelRatio(),f=document.createElement("canvas"),S=f.getContext("2d"),I=P.width,m=P.actualBoundingBoxAscent+P.actualBoundingBoxDescent,N=Math.sqrt(Math.pow(I,2)+Math.pow(m,2)),F=N+2*R[0]*u,Z=N+2*R[1]*u;f.width=F,f.height=Z,f.style.width=`${F*M}px`,f.style.height=`${Z*M}px`,S.translate(F/2,Z/2),S.rotate(-45*Math.PI/180),S.translate(-F/2,-Z/2),S.font=`${s*u}px ${r}`,S.fillStyle=l,S.fillText(L,(F-I)/2,(Z-m)/2+P.actualBoundingBoxAscent);const W=t.createPattern(f,"repeat");W&&(t.fillStyle=W,t.fillRect(0,0,h,g))}else{const M=h/2,f=g/2;t.fillStyle=l,t.translate(M,f),t.rotate(-45*Math.PI/180),t.fillText(L,-P.width/2,P.actualBoundingBoxAscent-s*u/2)}t.restore()}renderImage(t){const{watermark:{width:e,height:n,data:i,opacity:r,repeat:s,gap:l},scale:a}=this.options;if(!this.imageCache.has(i)){const g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=i,g.onload=()=>{this.imageCache.set(i,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const R=this.draw.getWidth(),d=this.draw.getHeight(),u=e*a,h=n*a;if(t.save(),t.globalAlpha=r,s){const g=this.draw.getPagePixelRatio(),L=document.createElement("canvas"),T=L.getContext("2d"),O=Math.sqrt(Math.pow(u,2)+Math.pow(h,2)),P=O+2*l[0]*a,M=O+2*l[1]*a;L.width=P,L.height=M,L.style.width=`${P*g}px`,L.style.height=`${M*g}px`,T.translate(P/2,M/2),T.rotate(-45*Math.PI/180),T.translate(-P/2,-M/2),T.drawImage(this.imageCache.get(i),(P-u)/2,(M-h)/2,u,h);const f=t.createPattern(L,"repeat");f&&(t.fillStyle=f,t.fillRect(0,0,R,d))}else{const g=R/2,L=d/2;t.translate(g,L),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(i),-u/2,-h/2,u,h)}t.restore()}render(t,e){this.options.watermark.type===c.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class pr{constructor(t){this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){var L,T;const{control:{activeBackgroundColor:n,disabledBackgroundColor:i,existValueBackgroundColor:r,noValueBackgroundColor:s}}=this.options,l=t[e],a=this.draw.isPrintMode(),R=(L=this.control.getActiveControl())==null?void 0:L.getElement();let d=!1,u=!1,h=!1,g=!1;return l.highlight||(d=!a&&!!n&&!!R&&l.controlId===R.controlId&&!this.control.getIsRangeInPostfix()),d||(u=!a&&!!i&&!!((T=l.control)!=null&&T.disabled)),u||(h=!a&&!!r&&!!l.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),h||(g=!a&&!!s&&!!l.controlId&&!this.control.getIsExistValueByElementListIndex(t,e)),(d?n:"")||(u?i:"")||(h?r:"")||(g?s:"")}getHighlightMatchResult(){return this.highlightMatchResult}getHighlightList(){return this.highlightList}setHighlightList(t){this.highlightList=t}computeHighlightList(){const t=this.draw.getSearch(),e=(n,i)=>{let r=0;for(;r<n.length;){const s=n[r];if(r++,s.type===c.ElementType.TABLE){const L=s.trList;for(let T=0;T<L.length;T++){const O=L[T];for(let P=0;P<O.tdList.length;P++){const M=O.tdList[P],f={tableId:s.id,tableIndex:r-1,trIndex:T,tdIndex:P,tdId:M.id};e(M.value,f)}}}const l=s==null?void 0:s.control;if(!l)continue;const a=this.highlightList.findIndex(L=>L.id===s.controlId||l.conceptId&&l.conceptId===L.conceptId);if(!~a)continue;const R=r;let d=r;for(;d<n.length&&n[d].controlId===s.controlId;)d++;r=d;const u=n.slice(R,d).map(L=>L.controlComponent===c.ControlComponent.VALUE?L:{value:w}),h=this.highlightList[a],{ruleList:g}=h;for(let L=0;L<g.length;L++){const T=g[L],O=t.getMatchList(T.keyword,u);this.highlightMatchResult.push(...O.map(P=>({...P,...T,...i,index:P.index+R})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){var l,a,R;if(!((l=this.highlightMatchResult)!=null&&l.length))return;const{searchMatchAlpha:n,searchMatchColor:i}=this.options,r=this.draw.getPosition().getOriginalPositionList(),s=this.draw.getOriginalElementList();t.save();for(let d=0;d<this.highlightMatchResult.length;d++){const u=this.highlightMatchResult[d];let h=null;if(u.tableId){const{tableIndex:I,trIndex:m,tdIndex:N,index:F}=u;h=(R=(a=s[I])==null?void 0:a.trList[m].tdList[N])==null?void 0:R.positionList[F]}else h=r[u.index];if(!h)continue;const{coordinate:{leftTop:g,leftBottom:L,rightTop:T},pageNo:O}=h;if(O!==e)continue;t.fillStyle=u.backgroundColor||i,t.globalAlpha=u.alpha||n;const P=g[0],M=g[1],f=T[0]-g[0],S=L[1]-g[1];t.fillRect(P,M,f,S)}t.restore()}}class Fr{constructor(t){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,n,i){!this.borderRect.width&&(this.borderRect.x=t,this.borderRect.y=e,this.borderRect.height=i),this.borderRect.width+=n}render(t){if(!this.borderRect.width)return;const{scale:e,control:{borderWidth:n,borderColor:i}}=this.options,{x:r,y:s,width:l,height:a}=this.borderRect;t.save(),t.translate(0,1*e),t.lineWidth=n*e,t.strokeStyle=i,t.beginPath(),t.rect(r,s,l,a),t.stroke(),t.restore(),this.clearBorderInfo()}}class fe{constructor(t,e){this.VALUE_DELIMITER=",",this.DEFAULT_MULTI_SELECT_DELIMITER=",";const n=e.getDraw();this.draw=n,this.options=n.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 s,l;if(!((s=this.element)!=null&&s.control))return null;const e=this.element.control;if(!((l=e.valueSets)!=null&&l.length))return null;const n=(e==null?void 0:e.multiSelectDelimiter)||this.DEFAULT_MULTI_SELECT_DELIMITER,i=e.valueSets,r=[];return t.forEach(a=>{const R=i.find(d=>d.code===a);R&&!Cn(R.value)&&r.push(R.value)}),r.join(n)||null}getValue(t={}){const e=t.elementList||this.control.getElementList(),{startIndex:n}=t.range||this.control.getRange(),i=e[n],r=[];let s=n;for(;s>0;){const a=e[s];if(a.controlId!==i.controlId||a.controlComponent===c.ControlComponent.PREFIX||a.controlComponent===c.ControlComponent.PRE_TEXT)break;a.controlComponent===c.ControlComponent.VALUE&&r.unshift(a),s--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==i.controlId||a.controlComponent===c.ControlComponent.POSTFIX||a.controlComponent===c.ControlComponent.POST_TEXT)break;a.controlComponent===c.ControlComponent.VALUE&&r.push(a),l++}return r}setValue(t,e={},n={}){var h,g;if(!((g=(h=this.element.control)==null?void 0:h.selectExclusiveOptions)!=null&&g.inputAble)||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:s,endIndex:l}=r,a=this.control.getDraw();s!==l?a.spliceElementList(i,s+1,l-s):this.control.removePlaceholder(s,e);const R=i[s],d=R.type&&!Qt.includes(R.type)||R.controlComponent===c.ControlComponent.PREFIX||R.controlComponent===c.ControlComponent.PRE_TEXT?Wt(R,["control","controlId",...Gt]):wt(R,["type"]),u=r.startIndex+1;for(let L=0;L<t.length;L++){const T={...d,...t[L],controlComponent:c.ControlComponent.VALUE};It(i,[T],s,{editorOptions:this.options}),a.spliceElementList(i,u+L,0,[T])}return u+t.length-1}keydown(t){var R,d;if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],l=e[r],a=(d=(R=this.element.control)==null?void 0:R.selectExclusiveOptions)==null?void 0:d.inputAble;if(t.key===c.KeyMap.Backspace)return i!==r?a?(this.draw.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect():s.controlComponent===c.ControlComponent.PREFIX||s.controlComponent===c.ControlComponent.PRE_TEXT||l.controlComponent===c.ControlComponent.POSTFIX||l.controlComponent===c.ControlComponent.POST_TEXT||s.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):a?(this.draw.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1):this.clearSelect();if(t.key===c.KeyMap.Delete){if(i!==r)return a?(this.draw.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect();{const u=e[r+1];return(s.controlComponent===c.ControlComponent.PREFIX||s.controlComponent===c.ControlComponent.PRE_TEXT)&&u.controlComponent===c.ControlComponent.PLACEHOLDER||u.controlComponent===c.ControlComponent.POSTFIX||u.controlComponent===c.ControlComponent.POST_TEXT||s.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):a?(this.draw.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):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:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const r=t.elementList||this.control.getElementList(),{startIndex:s}=t.range||this.control.getRange(),l=r[s];let a=-1,R=-1,d=s;for(;d>0;){const g=r[d];if(g.controlId!==l.controlId||g.controlComponent===c.ControlComponent.PREFIX||g.controlComponent===c.ControlComponent.PRE_TEXT){a=d;break}d--}let u=s+1;for(;u<r.length;){const g=r[u];if(g.controlId!==l.controlId||g.controlComponent===c.ControlComponent.POSTFIX||g.controlComponent===c.ControlComponent.POST_TEXT){R=u-1;break}u++}return!~a||!~R?-1:(this.control.getDraw().spliceElementList(r,a+1,R-a,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(d,t),this.control.setControlProperties({code:null},{elementList:r,range:{startIndex:d,endIndex:d}}),d)}setSelect(t,e={},n={}){var S;if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange(),s=this.element.control,l=(t==null?void 0:t.split(this.VALUE_DELIMITER))||[],a=s.code,R=((S=s.code)==null?void 0:S.split(this.VALUE_DELIMITER))||[],d=s.isMultiSelect;if(!d&&t===a||d&&En(R,l)){this.control.repaintControl({curIndex:r.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const u=s.valueSets;if(!Array.isArray(u)||!u.length)return;const h=this.getText(l);if(!h){if(a){const I=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~I&&(this.control.repaintControl({curIndex:I}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],L=g?Wt(g,Ct):Wt(i[r.startIndex],Gt),T=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~T)return;a||this.control.removePlaceholder(T,e);const O=wt(i[T],Ct),P=T+1,M=Ft(h),f=this.control.getDraw();for(let I=0;I<M.length;I++){const m={...L,...O,type:c.ElementType.TEXT,value:M[I],controlComponent:c.ControlComponent.VALUE};It(i,[m],T,{editorOptions:this.options}),f.spliceElementList(i,P+I,0,[m])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:T,endIndex:T}}),!e.range){const I=P+M.length-1;this.control.repaintControl({curIndex:I}),this.control.emitControlContentChange({context:e}),d||this.destroy()}}_createSelectPopupDom(){const t=this.element.control,e=t.valueSets;if(!Array.isArray(e)||!e.length)return;const n=this.control.getPosition();if(!n)return;const i=document.createElement("div");i.classList.add(`${x}-select-control-popup`),i.setAttribute(Ht,c.EditorComponent.POPUP);const r=document.createElement("ul");let s=null;for(let h=0;h<e.length;h++){const g=e[h],L=document.createElement("li");let T=this.getCodes();T.includes(g.code)&&(L.classList.add("active"),s=L),L.onclick=()=>{const O=T.findIndex(P=>P===g.code);t.isMultiSelect?~O?T.splice(O,1):T.push(g.code):~O?T=[]:T=[g.code],this.setSelect(T.join(this.VALUE_DELIMITER))},L.append(document.createTextNode(g.value)),r.append(L)}i.append(r);const{coordinate:{leftTop:[l,a]},lineHeight:R}=n,d=this.control.getPreY();i.style.left=`${l}px`,i.style.top=`${a+d+R}px`,this.control.getContainer().append(i),this.selectDom=i,s&&bn(i,s)}awake(){var n;if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const{startIndex:t}=this.control.getRange();((n=this.control.getElementList()[t+1])==null?void 0:n.controlId)===this.element.controlId&&(this._createSelectPopupDom(),this.isPopup=!0)}destroy(){var t;!this.isPopup||((t=this.selectDom)==null||t.remove(),this.isPopup=!1)}}class mn{constructor(t,e){const n=e.getDraw();this.options=n.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:n}=t.range||this.control.getRange(),i=e[n],r=[];let s=n;for(;s>0;){const a=e[s];if(a.controlId!==i.controlId||a.controlComponent===c.ControlComponent.PREFIX||a.controlComponent===c.ControlComponent.PRE_TEXT)break;a.controlComponent===c.ControlComponent.VALUE&&r.unshift(a),s--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==i.controlId||a.controlComponent===c.ControlComponent.POSTFIX||a.controlComponent===c.ControlComponent.POST_TEXT)break;a.controlComponent===c.ControlComponent.VALUE&&r.push(a),l++}return r}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:s,endIndex:l}=r,a=this.control.getDraw();s!==l?a.spliceElementList(i,s+1,l-s,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):this.control.removePlaceholder(s,e);const R=i[s],d=R.type&&!Qt.includes(R.type)||R.controlComponent===c.ControlComponent.PREFIX||R.controlComponent===c.ControlComponent.PRE_TEXT?Wt(R,["control","controlId",...Gt]):wt(R,["type"]),u=r.startIndex+1;for(let h=0;h<t.length;h++){const g={...d,...t[h],controlComponent:c.ControlComponent.VALUE};It(i,[g],s,{editorOptions:this.options}),a.spliceElementList(i,u+h,0,[g])}return u+t.length-1}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),i=t.range||this.control.getValueRange()||this.control.getRange(),{startIndex:r,endIndex:s}=i;return this.control.getDraw().spliceElementList(n,r+1,s-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),this.getValue({range:i,elementList:n}).length||this.control.addPlaceholder(r,t),r}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],l=e[r],a=this.control.getDraw();if(t.key===c.KeyMap.Backspace)return i!==r?(a.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):s.controlComponent===c.ControlComponent.PREFIX||s.controlComponent===c.ControlComponent.PRE_TEXT||l.controlComponent===c.ControlComponent.POSTFIX||l.controlComponent===c.ControlComponent.POST_TEXT||s.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(a.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key===c.KeyMap.Delete){if(i!==r)return a.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i;{const R=e[r+1];return(s.controlComponent===c.ControlComponent.PREFIX||s.controlComponent===c.ControlComponent.PRE_TEXT)&&R.controlComponent===c.ControlComponent.PLACEHOLDER||R.controlComponent===c.ControlComponent.POSTFIX||R.controlComponent===c.ControlComponent.POST_TEXT||s.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(a.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}}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 n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}}class di{constructor(t,e={}){this.draw=t,this.options=e,this.lang=this._getLang(),this.now=new Date,this.dom=this._createDom(),this.renderOptions=null,this.isDatePicker=!0,this.pickDate=null,this._bindEvent()}_createDom(){const t=document.createElement("div");t.classList.add(`${x}-date-container`),t.setAttribute(Ht,c.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${x}-date-wrap`);const n=document.createElement("div");n.classList.add(`${x}-date-title`);const i=document.createElement("span");i.classList.add(`${x}-date-title__pre-year`),i.innerText="<<";const r=document.createElement("span");r.classList.add(`${x}-date-title__pre-month`),r.innerText="<";const s=document.createElement("span");s.classList.add(`${x}-date-title__now`);const l=document.createElement("span");l.classList.add(`${x}-date-title__next-month`),l.innerText=">";const a=document.createElement("span");a.classList.add(`${x}-date-title__next-year`),a.innerText=">>",n.append(i),n.append(r),n.append(s),n.append(l),n.append(a);const R=document.createElement("div");R.classList.add(`${x}-date-week`);const{weeks:{sun:d,mon:u,tue:h,wed:g,thu:L,fri:T,sat:O}}=this.lang;[d,u,h,g,L,T,O].forEach(p=>{const X=document.createElement("span");X.innerText=`${p}`,R.append(X)});const M=document.createElement("div");M.classList.add(`${x}-date-day`),e.append(n),e.append(R),e.append(M);const f=document.createElement("ul");f.classList.add(`${x}-time-wrap`);let S,I,m;[this.lang.hour,this.lang.minute,this.lang.second].forEach((p,X)=>{const E=document.createElement("li"),C=document.createElement("span");C.innerText=p,E.append(C);const U=document.createElement("ol"),K=X===0,b=X===1,Y=K?24:60;for(let y=0;y<Y;y++){const D=document.createElement("li");D.innerText=`${String(y).padStart(2,"0")}`,D.setAttribute("data-id",`${y}`),U.append(D)}K?S=U:b?I=U:m=U,E.append(U),f.append(E)});const F=document.createElement("div");F.classList.add(`${x}-date-menu`);const Z=document.createElement("button");Z.classList.add(`${x}-date-menu__time`),Z.innerText=this.lang.timeSelect;const W=document.createElement("button");W.classList.add(`${x}-date-menu__now`),W.innerText=this.lang.now;const V=document.createElement("button");return V.classList.add(`${x}-date-menu__submit`),V.innerText=this.lang.confirm,F.append(Z),F.append(W),F.append(V),t.append(e),t.append(f),t.append(F),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:R,timeWrap:f,title:{preYear:i,preMonth:r,now:s,nextMonth:l,nextYear:a},day:M,time:{hour:S,minute:I,second:m},menu:{time:Z,now:W,submit:V}}}_bindEvent(){this.dom.title.preYear.onclick=()=>{this._preYear()},this.dom.title.preMonth.onclick=()=>{this._preMonth()},this.dom.title.nextMonth.onclick=()=>{this._nextMonth()},this.dom.title.nextYear.onclick=()=>{this._nextYear()},this.dom.menu.time.onclick=()=>{this.isDatePicker=!this.isDatePicker,this._toggleDateTimePicker()},this.dom.menu.now.onclick=()=>{this._now(),this._submit()},this.dom.menu.submit.onclick=()=>{this.dispose(),this._submit()},this.dom.time.hour.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;!n||(this.pickDate.setHours(Number(n)),this._setTimePick(!1))},this.dom.time.minute.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;!n||(this.pickDate.setMinutes(Number(n)),this._setTimePick(!1))},this.dom.time.second.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;!n||(this.pickDate.setSeconds(Number(n)),this._setTimePick(!1))}}_setPosition(){if(!this.renderOptions)return;const{position:{coordinate:{leftTop:[t,e]},lineHeight:n,pageNo:i}}=this.renderOptions,r=this.draw.getHeight(),s=this.draw.getPageGap(),a=(i!=null?i:this.draw.getPageNo())*(r+s);this.dom.container.style.left=`${t}px`,this.dom.container.style.top=`${e+a+n}px`}isInvalidDate(t){return t.toDateString()==="Invalid Date"}_setValue(){var e;const t=(e=this.renderOptions)==null?void 0:e.value;if(t){const n=new Date(t);this.now=this.isInvalidDate(n)?new Date:n}else this.now=new Date;this.pickDate=new Date(this.now)}_getLang(){const t=this.draw.getI18n(),e=t.t.bind(t);return{now:e("datePicker.now"),confirm:e("datePicker.confirm"),return:e("datePicker.return"),timeSelect:e("datePicker.timeSelect"),weeks:{sun:e("datePicker.weeks.sun"),mon:e("datePicker.weeks.mon"),tue:e("datePicker.weeks.tue"),wed:e("datePicker.weeks.wed"),thu:e("datePicker.weeks.thu"),fri:e("datePicker.weeks.fri"),sat:e("datePicker.weeks.sat")},year:e("datePicker.year"),month:e("datePicker.month"),hour:e("datePicker.hour"),minute:e("datePicker.minute"),second:e("datePicker.second")}}_setLangChange(){this.dom.menu.time.innerText=this.lang.timeSelect,this.dom.menu.now.innerText=this.lang.now,this.dom.menu.submit.innerText=this.lang.confirm;const{weeks:{sun:t,mon:e,tue:n,wed:i,thu:r,fri:s,sat:l}}=this.lang,a=[t,e,n,i,r,s,l];this.dom.datePickerWeek.childNodes.forEach((h,g)=>{const L=h;L.innerText=a[g]});const R=this.dom.time.hour.previousElementSibling;R.innerText=this.lang.hour;const d=this.dom.time.minute.previousElementSibling;d.innerText=this.lang.minute;const u=this.dom.time.second.previousElementSibling;u.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),n=t.getMonth()+1,i=t.getDate();let r=null,s=null,l=null;this.pickDate&&(r=this.pickDate.getFullYear(),s=this.pickDate.getMonth()+1,l=this.pickDate.getDate());const a=this.now.getFullYear(),R=this.now.getMonth()+1;this.dom.title.now.innerText=`${a}${this.lang.year} ${String(R).padStart(2,"0")}${this.lang.month}`;const u=new Date(a,R,0).getDate();let h=new Date(a,R-1,1).getDay();h===0&&(h=7);const g=new Date(a,R-1,0).getDate();this.dom.day.innerHTML="";const L=g-h+1;for(let O=L;O<=g;O++){const P=document.createElement("div");P.classList.add("disable"),P.innerText=`${O}`,P.onclick=()=>{const M=R-2;this.now=new Date(a,M,O),this._setDatePick(a,M,O)},this.dom.day.append(P)}for(let O=1;O<=u;O++){const P=document.createElement("div");e===a&&n===R&&i===O&&P.classList.add("active"),this.pickDate&&r===a&&s===R&&l===O&&P.classList.add("select"),P.innerText=`${O}`,P.onclick=M=>{const f=R-1;this.now=new Date(a,f,O),this._setDatePick(a,f,O),M.stopPropagation()},this.dom.day.append(P)}const T=6*7-h-u;for(let O=1;O<=T;O++){const P=document.createElement("div");P.classList.add("disable"),P.innerText=`${O}`,P.onclick=()=>{this.now=new Date(a,R,O),this._setDatePick(a,R,O)},this.dom.day.append(P)}}_toggleDateTimePicker(){this.isDatePicker?(this.dom.dateWrap.classList.add("active"),this.dom.timeWrap.classList.remove("active"),this.dom.menu.time.innerText=this.lang.timeSelect):(this.dom.dateWrap.classList.remove("active"),this.dom.timeWrap.classList.add("active"),this.dom.menu.time.innerText=this.lang.return,this._setTimePick())}_setDatePick(t,e,n){var i,r,s;this.now=new Date(t,e,n),(i=this.pickDate)==null||i.setFullYear(t),(r=this.pickDate)==null||r.setMonth(e),(s=this.pickDate)==null||s.setDate(n),this._update()}_setTimePick(t=!0){var d,u,h;const e=((d=this.pickDate)==null?void 0:d.getHours())||0,n=((u=this.pickDate)==null?void 0:u.getMinutes())||0,i=((h=this.pickDate)==null?void 0:h.getSeconds())||0,{hour:r,minute:s,second:l}=this.dom.time;[r,s,l].forEach(g=>{g.querySelectorAll("li").forEach(L=>L.classList.remove("active"))}),[[r,e],[s,n],[l,i]].forEach(([g,L])=>{const T=g.querySelector(`[data-id='${L}']`);T.classList.add("active"),t&&bn(g,T)})}_preMonth(){this.now.setMonth(this.now.getMonth()-1),this._update()}_nextMonth(){this.now.setMonth(this.now.getMonth()+1),this._update()}_preYear(){this.now.setFullYear(this.now.getFullYear()-1),this._update()}_nextYear(){this.now.setFullYear(this.now.getFullYear()+1),this._update()}_now(){this.pickDate=new Date,this.dispose()}_toggleVisible(t){t?this.dom.container.classList.add("active"):this.dom.container.classList.remove("active")}_submit(){var t;if(this.options.onSubmit&&this.pickDate){const e=(t=this.renderOptions)==null?void 0:t.dateFormat,n=this.formatDate(this.pickDate,e);this.options.onSubmit(n)}}formatDate(t,e="YYYY-MM-DD HH:mm:ss"){let n=e;const i=t.getFullYear().toString(),r=(t.getMonth()+1).toString(),s=t.getDate().toString(),l=t.getHours(),a=l%12===0?12:l%12,R=t.getMinutes().toString(),d=t.getSeconds().toString(),u=t.getMilliseconds().toString(),h={"y+":i,"Y+":i,"M+":r,"d+":s,"D+":s,"h+":a.toString(),"H+":l.toString(),"m+":R,"s+":d,"S+":u};for(const g in h){const L=new RegExp("("+g+")").exec(e),T=g;L&&(n=n.replace(L[1],L[1].length===1?h[T]:h[T].padStart(L[1].length,"0")))}return n}render(t){this.renderOptions=t,this.lang=this._getLang(),this._setLangChange(),this._setValue(),this._update(),this._setPosition(),this.isDatePicker=!0,this._toggleDateTimePicker(),this._toggleVisible(!0)}dispose(){this._toggleVisible(!1)}destroy(){this.dom.container.remove()}}class Se{constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.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}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:r,endIndex:s}=n;for(let l=r;l<=s;l++){const a=e[l];a.controlComponent===c.ControlComponent.VALUE&&i.push(a)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:s,endIndex:l}=r,a=this.control.getDraw();s!==l?a.spliceElementList(i,s+1,l-s):this.control.removePlaceholder(s,e);const R=i[s],d=R.type&&!Qt.includes(R.type)||R.controlComponent===c.ControlComponent.PREFIX||R.controlComponent===c.ControlComponent.PRE_TEXT?Wt(R,["control","controlId",...Gt]):wt(R,["type"]),u=r.startIndex+1;for(let h=0;h<t.length;h++){const g={...d,...t[h],controlComponent:c.ControlComponent.VALUE};It(i,[g],s,{editorOptions:this.options}),a.spliceElementList(i,u+h,0,[g])}return u+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const r=this.control.getValueRange(t);if(!r)return-1;const{startIndex:s,endIndex:l}=r;if(!~s||!~l)return-1;const a=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(a,s+1,l-s,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(s,t),s}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange(),s=this.getValue(e)[0],l=s?Wt(s,Ct):Wt(i[r.startIndex],Gt),a=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~a)return;const R=wt(i[a],Ct),d=a+1,u=this.control.getDraw();for(let h=0;h<t.length;h++){const g={...l,...R,type:c.ElementType.TEXT,value:t[h],controlComponent:c.ControlComponent.VALUE};It(i,[g],a,{editorOptions:this.options}),u.spliceElementList(i,d+h,0,[g])}if(!e.range){const h=d+t.length-1;this.control.repaintControl({curIndex:h}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],l=e[r],a=this.control.getDraw();if(t.key===c.KeyMap.Backspace)return i!==r?(a.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):s.controlComponent===c.ControlComponent.PREFIX||s.controlComponent===c.ControlComponent.PRE_TEXT||l.controlComponent===c.ControlComponent.POSTFIX||l.controlComponent===c.ControlComponent.POST_TEXT||s.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(a.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key===c.KeyMap.Delete){if(i!==r)return a.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i;{const R=e[r+1];return(s.controlComponent===c.ControlComponent.PREFIX||s.controlComponent===c.ControlComponent.PRE_TEXT)&&R.controlComponent===c.ControlComponent.PLACEHOLDER||R.controlComponent===c.ControlComponent.POSTFIX||R.controlComponent===c.ControlComponent.POST_TEXT||s.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(a.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}}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 n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){var s,l;if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getPosition();if(!t)return;const e=this.draw.getElementList(),{startIndex:n}=this.control.getRange();if(((s=e[n+1])==null?void 0:s.controlId)!==this.element.controlId)return;this.datePicker=new di(this.draw,{onSubmit:this._setDate.bind(this)});const i=this.getValue().map(a=>a.value).join("")||"",r=(l=this.element.control)==null?void 0:l.dateFormat;this.datePicker.render({value:i,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 Wr{constructor(t){this.control=t.control,this.onCalculate=t.onCalculate,this.calculatorDom=null,this.currentExpression=""}createPopup(){const t=this.control.getPosition();if(!t)return;const e=document.createElement("div");e.classList.add(`${x}-calculator`),e.setAttribute(Ht,c.EditorComponent.POPUP);const n=document.createElement("div");n.classList.add(`${x}-calculator-display`),n.textContent="0";const i=document.createElement("div");i.classList.add(`${x}-calculator-buttons`),[[{text:"C",type:at.UTILITY},{text:"\u2190",type:at.UTILITY},{text:"%",type:at.OPERATOR},{text:"/",type:at.OPERATOR}],[{text:"7",type:at.NUMBER},{text:"8",type:at.NUMBER},{text:"9",type:at.NUMBER},{text:"*",type:at.OPERATOR}],[{text:"4",type:at.NUMBER},{text:"5",type:at.NUMBER},{text:"6",type:at.NUMBER},{text:"-",type:at.OPERATOR}],[{text:"1",type:at.NUMBER},{text:"2",type:at.NUMBER},{text:"3",type:at.NUMBER},{text:"+",type:at.OPERATOR}],[{text:"0",type:at.NUMBER},{text:".",type:at.NUMBER},{text:"=",type:at.EQUAL,span:2}]].forEach(u=>{u.forEach(h=>{const g=document.createElement("button");g.classList.add(`${x}-calculator-button`),h.type===at.OPERATOR?g.classList.add("operator"):h.type===at.EQUAL?g.classList.add("equal"):h.type===at.UTILITY&&g.classList.add("utility"),g.textContent=h.text,g.onclick=()=>{const L=h.text;if(L==="C")this.currentExpression="",n.textContent="0";else if(L==="\u2190")this.currentExpression=this.currentExpression.slice(0,-1),n.textContent=this.currentExpression||"0";else if(L==="="){const T=this.calculate(this.currentExpression);Number.isFinite(T)?(n.textContent=T.toString(),this.currentExpression=T.toString(),this.onCalculate(T)):(n.textContent="Error",this.currentExpression="")}else this.currentExpression+=L,n.textContent=this.currentExpression},h.span&&(g.style.gridColumn=`span ${h.span}`),i.appendChild(g)})}),e.appendChild(n),e.appendChild(i);const{coordinate:{leftTop:[s,l]},lineHeight:a}=t,R=this.control.getPreY();e.style.left=`${s}px`,e.style.top=`${l+R+a}px`,this.control.getContainer().appendChild(e),this.calculatorDom=e}destroy(){this.calculatorDom&&(this.calculatorDom.remove(),this.calculatorDom=null)}calculate(t){const e=Function("return "+t)();return!Number.isFinite(e)||Number.isInteger(e)?e:parseFloat(e.toFixed(10))}}class me extends mn{constructor(t,e){super(t,e),this.isPopup=!1,this.calculator=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(u=>!Rs(u)||eo.test(u.value)))return-1;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const s=et(t),{startIndex:l,endIndex:a}=r,R=i[l];if(this.control.getIsExistValueByElementListIndex(i,l)){let u=l;for(;u>0;){const g=i[u];if(g.controlId!==R.controlId||g.controlComponent===c.ControlComponent.PREFIX||g.controlComponent===c.ControlComponent.PRE_TEXT)break;s.unshift(g),u--}let h=a+1;for(;h<i.length;){const g=i[h];if(g.controlId!==R.controlId||g.controlComponent===c.ControlComponent.POSTFIX||g.controlComponent===c.ControlComponent.POST_TEXT)break;s.push(g),h++}}const d=cs(s);return Number.isNaN(Number(d))||!Number.isFinite(Number(d))?-1:super.setValue(t,e,n)}_setCalculatedValue(t){const e=super.clearValue({},{isAddPlaceholder:!1,isIgnoreDeletedRule:!0});if(!~e)return;const n=this.control.getElementList(),i=this.control.getRange(),r=this.getValue()[0],s=r?Wt(r,Ct):Wt(n[i.startIndex],Gt),l=wt(n[e],Ct),a=t.toString(),R=[];for(let d=0;d<a.length;d++){const u={...s,...l,type:c.ElementType.TEXT,value:a[d],controlComponent:c.ControlComponent.VALUE};R.push(u)}this.setValue(R),this.control.repaintControl({curIndex:e+R.length}),this.control.emitControlContentChange(),this.destroy()}awake(){var i,r,s;const t=((r=(i=this.element.control)==null?void 0:i.numberExclusiveOptions)==null?void 0:r.calculatorDisabled)===!1;if(this.isPopup||!t||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const{startIndex:e}=this.control.getRange();((s=this.control.getElementList()[e+1])==null?void 0:s.controlId)===this.element.controlId&&(this.calculator=new Wr({control:this.control,onCalculate:l=>{this._setCalculatedValue(l)}}),this.calculator.createPopup(),this.isPopup=!0)}destroy(){var t;!this.isPopup||((t=this.calculator)==null||t.destroy(),this.calculator=null,this.isPopup=!1)}}class Vr{constructor(t){this.controlBorder=new Fr(t),this.draw=t,this.range=t.getRange(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.controlSearch=new pr(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,n)=>{var i,r,s;if(e.type===c.ElementType.TABLE){const l=e.trList;for(let a=0;a<l.length;a++){const R=l[a];for(let d=0;d<R.tdList.length;d++){const u=R.tdList[d];u.value=this.filterAssistElement(u.value)}}}if(!e.controlId)return!0;if((i=e.control)!=null&&i.minWidth){if(e.controlComponent===c.ControlComponent.PREFIX||e.controlComponent===c.ControlComponent.POSTFIX)return e.value="",!0}else{if(((r=e.control)==null?void 0:r.preText)&&e.controlComponent===c.ControlComponent.PRE_TEXT){let l=!1,a=n+1;for(;a<t.length;){const R=t[a];if(e.controlId!==R.controlId)break;if(R.controlComponent===c.ControlComponent.VALUE){l=!0;break}a++}return l}if(((s=e.control)==null?void 0:s.postText)&&e.controlComponent===c.ControlComponent.POST_TEXT){let l=!1,a=n-1;for(;a<t.length;){const R=t[a];if(e.controlId!==R.controlId)break;if(R.controlComponent===c.ControlComponent.VALUE){l=!0;break}a--}return l}}return e.controlComponent!==c.ControlComponent.PREFIX&&e.controlComponent!==c.ControlComponent.POSTFIX&&e.controlComponent!==c.ControlComponent.PLACEHOLDER})}getIsRangeCanCaptureEvent(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.getElementList(),i=n[t];if(t===e&&i.controlComponent===c.ControlComponent.POSTFIX)return!0;const r=n[e];return!!(i.controlId&&i.controlId===r.controlId&&r.controlComponent!==c.ControlComponent.POSTFIX)}getIsRangeInPostfix(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();return t!==e?!1:this.getElementList()[t].controlComponent===c.ControlComponent.POSTFIX}getIsRangeWithinControl(){const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.getElementList(),i=n[t],r=n[e];return!!((i==null?void 0:i.controlId)&&i.controlId===r.controlId&&r.controlComponent!==c.ControlComponent.POSTFIX)}getIsElementListContainFullControl(t){if(!t.some(i=>i.controlId))return!1;let e=0,n=0;for(let i=0;i<t.length;i++){const r=t[i];r.controlComponent===c.ControlComponent.PREFIX?e++:r.controlComponent===c.ControlComponent.POSTFIX&&n++}return!e||!n?!1:e===n}getIsDisabledControl(t={}){var i,r;if(this.draw.isDesignMode()||!this.activeControl)return!1;const{startIndex:e,endIndex:n}=t.range||this.range.getRange();return e===n&&~e&&~n&&(t.elementList||this.getElementList())[e].controlComponent===c.ControlComponent.POSTFIX?!1:!!((r=(i=this.activeControl.getElement())==null?void 0:i.control)!=null&&r.disabled)}getIsDisabledPasteControl(t={}){var i,r;if(this.draw.isDesignMode()||!this.activeControl)return!1;const{startIndex:e,endIndex:n}=t.range||this.range.getRange();return e===n&&~e&&~n&&(t.elementList||this.getElementList())[e].controlComponent===c.ControlComponent.POSTFIX?!1:!!((r=(i=this.activeControl.getElement())==null?void 0:i.control)!=null&&r.pasteDisabled)}getIsExistValueByElementListIndex(t,e){var i,r,s;const n=t[e];if(!n.controlId)return!1;if(((i=n.control)==null?void 0:i.type)===c.ControlType.CHECKBOX||((r=n.control)==null?void 0:r.type)===c.ControlType.RADIO)return!!((s=n.control)!=null&&s.code);if(n.controlComponent===c.ControlComponent.VALUE)return!0;if(n.controlComponent===c.ControlComponent.PLACEHOLDER)return!1;if(n.controlComponent===c.ControlComponent.PREFIX||n.controlComponent===c.ControlComponent.PRE_TEXT){let l=e+1;for(;l<t.length;){const a=t[l];if(a.controlId!==n.controlId)return!1;if(a.controlComponent===c.ControlComponent.VALUE)return!0;if(a.controlComponent===c.ControlComponent.PLACEHOLDER)return!1;l++}}if(n.controlComponent===c.ControlComponent.POSTFIX||n.controlComponent===c.ControlComponent.POST_TEXT){let l=e-1;for(;l>=0;){const a=t[l];if(a.controlId!==n.controlId)return!1;if(a.controlComponent===c.ControlComponent.VALUE)return!0;if(a.controlComponent===c.ControlComponent.PLACEHOLDER)return!1;l--}}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 i,r;const t=this.draw.getHeight(),e=this.draw.getPageGap();return((r=(i=this.getPosition())==null?void 0:i.pageNo)!=null?r:this.draw.getPageNo())*(t+e)}getRange(){return this.range.getRange()}getValueRange(t={}){const e=t.elementList||this.getElementList(),{startIndex:n}=t.range||this.getRange(),i=e[n];let r=n;for(;r>0;){const l=e[r];if(l.controlId!==i.controlId||l.controlComponent===c.ControlComponent.PREFIX||l.controlComponent===c.ControlComponent.PRE_TEXT)break;r--}let s=n+1;for(;s<e.length;){const l=e[s];if(l.controlId!==i.controlId||l.controlComponent===c.ControlComponent.POSTFIX||l.controlComponent===c.ControlComponent.POST_TEXT)break;s++}return r===s?null:{startIndex:r,endIndex:s-1}}shrinkBoundary(t={}){this.range.shrinkBoundary(t)}getActiveControl(){return this.activeControl}getControlElementList(t={}){const e=t.elementList||this.getElementList(),{startIndex:n}=t.range||this.getRange(),i=e[n];if(!(i!=null&&i.controlId))return[];const r=[];let s=n;for(;s>0;){const a=e[s];if(a.controlId!==i.controlId)break;r.unshift(a),s--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==i.controlId)break;r.push(a),l++}return r}updateActiveControlValue(){this.activeControl&&(this.activeControlValue=this.getControlElementList())}emitControlChange(t){var l,a;if(!this.activeControl)return;const e=this.eventBus.isSubscribe("controlChange");if(!this.listener.controlChange&&!e)return;let n;const i=this.activeControlValue,r=this.activeControl.getElement();i!=null&&i.length?n=rt(i)[0].control:(n=se(et(r)).control,n.value=[]);const s={state:t,control:n,controlId:r.controlId};(a=(l=this.listener).controlChange)==null||a.call(l,s),e&&this.eventBus.emit("controlChange",s)}initControl(){var s,l;const t=this.getElementList(),e=this.getRange(),n=t[e.startIndex];if(this.activeControl){(this.activeControl instanceof fe||this.activeControl instanceof Se||this.activeControl instanceof me)&&(n.controlComponent===c.ControlComponent.POSTFIX?this.activeControl.destroy():this.activeControl.awake()),((s=this.preElement)==null?void 0:s.controlId)===n.controlId&&(n.controlComponent===c.ControlComponent.POSTFIX?this.emitControlChange(c.ControlState.INACTIVE):((l=this.preElement)==null?void 0:l.controlComponent)===c.ControlComponent.POSTFIX&&this.emitControlChange(c.ControlState.ACTIVE));const a=this.activeControl.getElement();if(n.controlId===a.controlId){this.updateActiveControlValue(),this.preElement=n;return}}if(this.destroyControl(),this.draw.isReadonly())return;const r=n.control;if(r.type===c.ControlType.TEXT)this.activeControl=new mn(n,this);else if(r.type===c.ControlType.SELECT){const a=new fe(n,this);this.activeControl=a,a.awake()}else if(r.type===c.ControlType.CHECKBOX)this.activeControl=new Ce(n,this);else if(r.type===c.ControlType.RADIO)this.activeControl=new On(n,this);else if(r.type===c.ControlType.DATE){const a=new Se(n,this);this.activeControl=a,a.awake()}else if(r.type===c.ControlType.NUMBER){const a=new me(n,this);this.activeControl=a,a.awake()}this.updateActiveControlValue(),this.preElement=n,n.controlComponent!==c.ControlComponent.POSTFIX&&this.emitControlChange(c.ControlState.ACTIVE)}destroyControl(t={}){var n;if(!this.activeControl)return;const{isEmitEvent:e=!0}=t;(this.activeControl instanceof fe||this.activeControl instanceof Se||this.activeControl instanceof me)&&this.activeControl.destroy(),e&&((n=this.preElement)==null?void 0:n.controlComponent)!==c.ControlComponent.POSTFIX&&this.emitControlChange(c.ControlState.INACTIVE),this.preElement=null,this.activeControl=null,this.activeControlValue=[]}repaintControl(t={}){const{curIndex:e,isCompute:n=!0,isSubmitHistory:i=!0,isSetCursor:r=!0}=t;e===void 0?(this.range.clearRange(),this.draw.render({isCompute:n,isSubmitHistory:i,isSetCursor:!1})):(this.range.setRange(e,e),this.draw.render({curIndex:e,isCompute:n,isSetCursor:r,isSubmitHistory:i}))}emitControlContentChange(t){var R,d,u,h,g,L;const e=this.eventBus.isSubscribe("controlContentChange");if(!e&&!this.listener.controlContentChange)return;const n=(t==null?void 0:t.controlElement)||((R=this.activeControl)==null?void 0:R.getElement());if(!n)return;const i=((d=t==null?void 0:t.context)==null?void 0:d.elementList)||this.getElementList(),{startIndex:r}=((u=t==null?void 0:t.context)==null?void 0:u.range)||this.getRange();if(!((h=i[r])!=null&&h.controlId))return;const s=(t==null?void 0:t.controlValue)||this.getControlElementList(t==null?void 0:t.context);let l;if(s!=null&&s.length?l=rt(s)[0].control:(l=n.control,l.value=[]),!l)return;const a={control:l,controlId:n.controlId};(L=(g=this.listener).controlContentChange)==null||L.call(g,a),e&&this.eventBus.emit("controlContentChange",a)}reAwakeControl(){if(!this.activeControl)return;const t=this.getElementList(),e=this.getRange(),n=t[e.startIndex];this.activeControl.setElement(n),(this.activeControl instanceof Se||this.activeControl instanceof fe||this.activeControl instanceof me)&&this.activeControl.getIsPopup()&&(this.activeControl.destroy(),this.activeControl.awake())}selectValue(){var s;const t=this.getElementList(),{startIndex:e}=this.getRange(),n=t[e];if(!(n!=null&&n.controlId)||n.controlComponent!==c.ControlComponent.VALUE&&((s=t[e+1])==null?void 0:s.controlComponent)===c.ControlComponent.VALUE)return!1;let i=e;for(;i>0&&t[i].controlComponent===c.ControlComponent.VALUE;)i--;let r=e+1;for(;r<t.length;){if(t[r].controlComponent!==c.ControlComponent.VALUE){r--;break}r++}if(i!==r){const l=this.range.getRange();return this.range.replaceRange({...l,startIndex:i,endIndex:r}),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),!0}return!1}moveCursor(t){var R,d;const{index:e,trIndex:n,tdIndex:i,tdValueIndex:r}=t;let s=this.draw.getOriginalElementList(),l;const a=t.isTable?r:e;if(t.isTable?(s=s[e].trList[n].tdList[i].value,l=s[r]):l=s[e],l.hide||((R=l.control)==null?void 0:R.hide)||((d=l.area)==null?void 0:d.hide)){const u=Me(s,a);return{newIndex:u,newElement:s[u]}}if(l.controlComponent===c.ControlComponent.VALUE)return{newIndex:a,newElement:l};if(l.controlComponent===c.ControlComponent.POSTFIX){let u=a+1;for(;u<s.length;){if(s[u].controlId!==l.controlId)return{newIndex:u-1,newElement:s[u-1]};if(u===s.length-1)return{newIndex:u,newElement:s[u]};u++}}else if(l.controlComponent===c.ControlComponent.PREFIX||l.controlComponent===c.ControlComponent.PRE_TEXT){let u=a+1;for(;u<s.length;){const h=s[u];if(h.controlId!==l.controlId||h.controlComponent!==c.ControlComponent.PREFIX&&h.controlComponent!==c.ControlComponent.PRE_TEXT)return{newIndex:u-1,newElement:s[u-1]};u++}}else if(l.controlComponent===c.ControlComponent.PLACEHOLDER||l.controlComponent===c.ControlComponent.POST_TEXT){let u=a-1;for(;u>0;){const h=s[u];if(h.controlId!==l.controlId||h.controlComponent===c.ControlComponent.VALUE||h.controlComponent===c.ControlComponent.PREFIX||h.controlComponent===c.ControlComponent.PRE_TEXT)return{newIndex:u,newElement:s[u]};u--}}return{newIndex:a,newElement:l}}removeControl(t,e={}){var R,d;const n=e.elementList||this.getElementList(),i=n[t];if(!this.draw.isDesignMode()&&!(i!=null&&i.hide)&&!((R=i==null?void 0:i.control)!=null&&R.hide)&&!((d=i==null?void 0:i.area)!=null&&d.hide)){const{deletable:u=!0}=i.control;if(!u)return null;const h=this.draw.getMode();if(h===c.EditorMode.FORM&&this.options.modeRule[h].controlDeletableDisabled)return null}let r=-1,s=-1,l=t;for(;l>0;){if(n[l].controlId!==i.controlId){r=l;break}l--}let a=t+1;for(;a<n.length;){if(n[a].controlId!==i.controlId){s=a-1;break}a++}return a===n.length&&(s=a-1),!~r&&!~s?t:(r=~r?r:0,this.draw.spliceElementList(n,r+1,s-r),r)}removePlaceholder(t,e={}){const n=e.elementList||this.getElementList(),i=n[t],r=n[t+1];if(i.controlComponent===c.ControlComponent.PLACEHOLDER||r.controlComponent===c.ControlComponent.PLACEHOLDER){let s=!1,l=t;for(;l<n.length;){const a=n[l];if(a.controlId!==i.controlId)break;a.controlComponent===c.ControlComponent.PLACEHOLDER?(s||(s=!0,this.draw.getHistoryManager().popUndo(),this.draw.submitHistory(t)),n.splice(l,1)):l++}}}addPlaceholder(t,e={}){const n=e.elementList||this.getElementList(),i=n[t],r=i.control;if(!r.placeholder)return;const s=Ft(r.placeholder),l=Wt(i,Gt);for(let a=0;a<s.length;a++){const R=s[a],d={...l,value:R===`
|
|
91
|
-
`?w:R,controlId:i.controlId,type:c.ElementType.CONTROL,control:i.control,controlComponent:c.ControlComponent.PLACEHOLDER,color:this.controlOptions.placeholderColor};It(n,[d],t,{editorOptions:this.options}),this.draw.spliceElementList(n,t+a+1,0,[d])}}setValue(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.setValue(t)}setControlProperties(t,e={}){const n=e.elementList||this.getElementList(),{startIndex:i}=e.range||this.getRange(),r=n[i];let s=i;for(;s>0;){const a=n[s];if(a.controlId!==r.controlId)break;a.control={...a.control,...t},s--}let l=i+1;for(;l<n.length;){const a=n[l];if(a.controlId!==r.controlId)break;a.control={...a.control,...t},l++}}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,groupId:n,conceptId:i,areaId:r}=t,s=[];if(!e&&!i&&!n)return s;const l=(R,d)=>{let u=0;for(;u<R.length;){const h=R[u];if(u++,h.type===c.ElementType.TABLE){const f=h.trList;for(let S=0;S<f.length;S++){const I=f[S];for(let m=0;m<I.tdList.length;m++){const N=I.tdList[m];l(N.value,d)}}}if(!h.control||n&&h.control.groupId!==n||e&&h.controlId!==e||i&&h.control.conceptId!==i||r&&h.areaId!==r)continue;const{type:g,code:L,valueSets:T}=h.control;let O=u,P="";const M=[];for(;O<R.length;){const f=R[O];if(f.controlId!==h.controlId)break;(g===c.ControlType.TEXT||g===c.ControlType.DATE||g===c.ControlType.NUMBER)&&f.controlComponent===c.ControlComponent.VALUE&&(P+=f.value,M.push(wt(f,tn))),O++}if(g===c.ControlType.TEXT||g===c.ControlType.DATE||g===c.ControlType.NUMBER)s.push({...h.control,zone:d,value:P||null,innerText:P||null,elementList:rt(M)});else if(g===c.ControlType.SELECT||g===c.ControlType.CHECKBOX||g===c.ControlType.RADIO){const f=L==null?void 0:L.split(",").map(S=>{var I;return(I=T==null?void 0:T.find(m=>m.code===S))==null?void 0:I.value}).filter(Boolean).join("");s.push({...h.control,zone:d,value:L||null,innerText:f||null})}u=O}},a=[{zone:c.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:c.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:c.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:R,elementList:d}of a)l(d,R);return s}setValueListById(t){if(!t.length)return;let e=!1,n=!1;const i=s=>{let l=0;for(;l<s.length;){const a=s[l];if(l++,a.type===c.ElementType.TABLE){const M=a.trList;for(let f=0;f<M.length;f++){const S=M[f];for(let I=0;I<S.tdList.length;I++){const m=S.tdList[I];i(m.value)}}}if(!a.control)continue;const R=t.find(M=>{var f;return(!M.groupId||M.groupId===((f=a.control)==null?void 0:f.groupId))&&(M.id&&a.controlId===M.id||M.conceptId&&a.control.conceptId===M.conceptId||M.areaId&&a.areaId===M.areaId)});if(!R)continue;const{value:d,isSubmitHistory:u=!0}=R;e=!0,u&&(n=!0);const{type:h}=a.control;let g=l;for(;g<s.length&&s[g].controlId===a.controlId;)g++;const T={range:{startIndex:l-1,endIndex:g-2},elementList:s},O={isIgnoreDisabledRule:!0,isIgnoreDeletedRule:!0};if(h===c.ControlType.TEXT){const M=Array.isArray(d)?d:d?[{value:d}]:[];M.length&&Mt(M,{isHandleFirstElement:!1,editorOptions:this.options});const f=new mn(a,this);this.activeControl=f,M.length?f.setValue(M,T,O):f.clearValue(T,O)}else if(h===c.ControlType.SELECT){if(Array.isArray(d))continue;const M=new fe(a,this);this.activeControl=M,d?M.setSelect(d,T,O):M.clearSelect(T,O)}else if(h===c.ControlType.CHECKBOX){if(Array.isArray(d))continue;const M=new Ce(a,this);this.activeControl=M;const f=d?d.split(","):[];M.setSelect(f,T,O)}else if(h===c.ControlType.RADIO){if(Array.isArray(d))continue;const M=new On(a,this);this.activeControl=M;const f=d?[d]:[];M.setSelect(f,T,O)}else if(h===c.ControlType.DATE){const M=new Se(a,this);this.activeControl=M,_e(d)?(d.length&&Mt(d,{isHandleFirstElement:!1,editorOptions:this.options}),M.setValue(d,T,O)):lo(d)?M.setSelect(d,T,O):M.clearSelect(T,O)}else if(h===c.ControlType.NUMBER){const M=Array.isArray(d)?d:d?[{value:d}]:[];M.length&&Mt(M,{isHandleFirstElement:!1,editorOptions:this.options});const f=new me(a,this);this.activeControl=f,M.length?f.setValue(M,T,O):f.clearValue(T,O)}this.emitControlContentChange({context:T}),this.activeControl=null;let P=l;for(;P<s.length&&s[P].controlId===a.controlId;)P++;l=P}};this.destroyControl({isEmitEvent:!1});const r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const s of r)i(s);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}setExtensionListById(t){if(!t.length)return;const e=i=>{let r=0;for(;r<i.length;){const s=i[r];if(r++,s.type===c.ElementType.TABLE){const d=s.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];e(L.value)}}}if(!s.control)continue;const l=t.find(d=>{var u;return(!d.groupId||d.groupId===((u=s.control)==null?void 0:u.groupId))&&(d.id&&s.controlId===d.id||d.conceptId&&s.control.conceptId===d.conceptId||d.areaId&&s.areaId===d.areaId)});if(!l)continue;const{extension:a}=l;this.setControlProperties({extension:a},{elementList:i,range:{startIndex:r,endIndex:r}});let R=r;for(;R<i.length&&i[R].controlId===s.controlId;)R++;r=R}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i)}setPropertiesListById(t){if(!t.length)return;let e=!1,n=!1;const i=s=>{let l=0;for(;l<s.length;){const a=s[l];if(l++,a.type===c.ElementType.TABLE){const g=a.trList;for(let L=0;L<g.length;L++){const T=g[L];for(let O=0;O<T.tdList.length;O++){const P=T.tdList[O];i(P.value)}}}if(!a.control)continue;const R=t.find(g=>{var L;return(!g.groupId||g.groupId===((L=a.control)==null?void 0:L.groupId))&&(g.id&&a.controlId===g.id||g.conceptId&&a.control.conceptId===g.conceptId||g.areaId&&a.areaId===g.areaId)});if(!R)continue;const{properties:d,isSubmitHistory:u=!0}=R;e=!0,u&&(n=!0),this.setControlProperties({...a.control,...d,value:a.control.value},{elementList:s,range:{startIndex:l,endIndex:l}}),Gt.forEach(g=>{const L=d[g];L&&Reflect.set(a,g,L)});let h=l;for(;h<s.length&&s[h].controlId===a.controlId;)h++;l=h}},r={header:this.draw.getHeaderElementList(),main:this.draw.getOriginalMainElementList(),footer:this.draw.getFooterElementList()};for(const s in r){const l=r[s];i(l)}if(!!e){for(const s in r){const l=s,a=rt(r[l],{isClassifyArea:!0,extraPickAttrs:["id"]});r[l]=a,Mt(a,{editorOptions:this.options,isForceCompensation:!0})}this.draw.setEditorData(r),n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1})}}getList(){const t=[];function e(i){for(let r=0;r<i.length;r++){const s=i[r];if(s.type===c.ElementType.TABLE){const l=s.trList;for(let a=0;a<l.length;a++){const R=l[a];for(let d=0;d<R.tdList.length;d++){const h=R.tdList[d].value;e(h)}}}if(s.controlId){const l=wt(s,[...qe,...We]);t.push(l)}}}const n=[this.draw.getHeader().getElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooter().getElementList()];for(const i of n)e(i);return rt(t,{extraPickAttrs:["controlId"]})}recordBorderInfo(t,e,n,i){this.controlBorder.recordBorderInfo(t,e,n,i)}drawBorder(t){this.controlBorder.render(t)}getPreControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function i(a,R){for(let d=R;d>0;d--){const u=a[d];if(u.type===c.ElementType.TABLE){const g=u.trList||[];for(let L=g.length-1;L>=0;L--){const T=g[L],O=T.tdList;for(let P=O.length-1;P>=0;P--){const M=O[P],f=i(M.value,M.value.length-1);if(f)return{positionContext:{isTable:!0,index:d,trIndex:L,tdIndex:P,tdId:M.id,trId:T.id,tableId:u.id},nextIndex:f.nextIndex}}}}if(!u.controlId||u.controlId===n.controlId)continue;let h=d;for(;h>0;){const g=a[h];if(g.controlComponent===c.ControlComponent.VALUE||g.controlComponent===c.ControlComponent.PREFIX||g.controlComponent===c.ControlComponent.PRE_TEXT)break;h--}return{positionContext:{isTable:!1},nextIndex:h}}return null}const{startIndex:r}=this.range.getRange(),s=this.getElementList(),l=i(s,r);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:R,trIndex:d,tdIndex:u}=e,h=a[R].trList;for(let L=d;L>=0;L--){const T=h[L],O=T.tdList;for(let P=O.length-1;P>=0;P--){if(d===L&&P>=u)continue;const M=O[P],f=i(M.value,M.value.length-1);if(f)return{positionContext:{isTable:!0,index:e.index,trIndex:L,tdIndex:P,tdId:M.id,trId:T.id,tableId:n.tableId},nextIndex:f.nextIndex}}}const g=i(a,R-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 n=this.activeControl.getElement();function i(a,R){var d,u;for(let h=R;h<a.length;h++){const g=a[h];if(g.type===c.ElementType.TABLE){const L=g.trList||[];for(let T=0;T<L.length;T++){const O=L[T],P=O.tdList;for(let M=0;M<P.length;M++){const f=P[M],S=i(f.value,0);if(S)return{positionContext:{isTable:!0,index:h,trIndex:T,tdIndex:M,tdId:f.id,trId:O.id,tableId:g.id},nextIndex:S.nextIndex}}}}if(!(!g.controlId||g.controlId===n.controlId||((d=a[h+1])==null?void 0:d.controlComponent)===c.ControlComponent.PREFIX||((u=a[h+1])==null?void 0:u.controlComponent)===c.ControlComponent.PRE_TEXT))return{positionContext:{isTable:!1},nextIndex:h}}return null}const{endIndex:r}=this.range.getRange(),s=this.getElementList(),l=i(s,r);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:R,trIndex:d,tdIndex:u}=e,h=a[R].trList;for(let L=d;L<h.length;L++){const T=h[L],O=T.tdList;for(let P=0;P<O.length;P++){if(d===L&&P<=u)continue;const M=O[P],f=i(M.value,0);if(f)return{positionContext:{isTable:!0,index:e.index,trIndex:L,tdIndex:P,tdId:M.id,trId:T.id,tableId:n.tableId},nextIndex:f.nextIndex}}}const g=i(a,R+1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}initNextControl(t={}){const{direction:e=Pt.DOWN}=t;let n=null;if(e===Pt.UP?n=this.getPreControlContext():n=this.getNextControlContext(),!n)return;const{nextIndex:i,positionContext:r}=n;this.draw.getPosition().setPositionContext(r),this.draw.getRange().replaceRange({startIndex:i,endIndex:i}),this.draw.render({curIndex:i,isCompute:!1,isSetCursor:!0,isSubmitHistory:!1})}setMinWidthControlInfo(t){var d,u,h,g,L;const{row:e,rowElement:n,controlRealWidth:i,availableWidth:r}=t;if(!((d=n.control)!=null&&d.minWidth))return;const{scale:s}=this.options,l=n.control.minWidth*s;let a=null;if(((u=n.control)==null?void 0:u.minWidth)&&(((h=n.control)==null?void 0:h.rowFlex)===c.RowFlex.CENTER||((g=n.control)==null?void 0:g.rowFlex)===c.RowFlex.RIGHT)){let T=n.metrics.width,O=e.elementList.length-1;for(;O>=0;){const P=e.elementList[O];if(T+=P.metrics.width,((L=e.elementList[O-1])==null?void 0:L.controlComponent)===c.ControlComponent.PREFIX){a=P;break}O--}a&&T<l&&(n.control.rowFlex===c.RowFlex.CENTER?a.left=(l-T)/2:n.control.rowFlex===c.RowFlex.RIGHT&&(a.left=l-T-n.metrics.width))}const R=l-i;if(R>0){const T=(a==null?void 0:a.left)||0,O=r-e.width-n.metrics.width,P=Math.min(O,R);n.left=P-T,e.width+=P-T}}}class Yr{constructor(t){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:n,index:i,row:r}=t;let{y:s}=t;const{checkbox:{gap:l,lineWidth:a,fillStyle:R,strokeStyle:d,verticalAlign:u},scale:h}=this.options,{metrics:g,checkbox:L}=r.elementList[i];if(u===c.VerticalAlign.TOP||u===c.VerticalAlign.MIDDLE){let f=i+1,S=null;for(;f<r.elementList.length&&(S=r.elementList[f],!(S.value!==w&&S.value!==Je));)f++;if(S){const{metrics:{boundingBoxAscent:I,boundingBoxDescent:m}}=S,N=I+m;N>g.height&&(u===c.VerticalAlign.TOP?s-=I-g.height:u===c.VerticalAlign.MIDDLE&&(s-=(N-g.height)/2))}}const T=Math.round(n+l*h),O=Math.round(s-g.height+a),P=g.width-l*2*h,M=g.height;e.save(),e.beginPath(),e.translate(.5,.5),L!=null&&L.value?(e.lineWidth=a,e.strokeStyle="red",e.rect(T,O,P,M),e.stroke(),e.beginPath(),e.fillStyle=R,e.fillRect(T,O,P,M),e.beginPath(),e.strokeStyle=d,e.lineWidth=a*2*h,e.moveTo(T+2*h,O+M/2),e.lineTo(T+P/2,O+M-3*h),e.lineTo(T+P-2*h,O+3*h),e.stroke()):(e.lineWidth=a,e.strokeStyle="red",e.rect(T,O,P,M),e.stroke());debugger;e.closePath(),e.restore()}}class Zr{constructor(t){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:n,index:i,row:r}=t;let{y:s}=t;const{radio:{gap:l,lineWidth:a,fillStyle:R,strokeStyle:d,verticalAlign:u},scale:h}=this.options,{metrics:g,radio:L}=r.elementList[i];if(u===c.VerticalAlign.TOP||u===c.VerticalAlign.MIDDLE){let f=i+1,S=null;for(;f<r.elementList.length&&(S=r.elementList[f],!(S.value!==w&&S.value!==Je));)f++;if(S){const{metrics:{boundingBoxAscent:I,boundingBoxDescent:m}}=S,N=I+m;N>g.height&&(u===c.VerticalAlign.TOP?s-=I-g.height:u===c.VerticalAlign.MIDDLE&&(s-=(N-g.height)/2))}}const T=Math.round(n+l*h),O=Math.round(s-g.height+a),P=g.width-l*2*h,M=g.height;e.save(),e.beginPath(),e.translate(.5,.5),e.strokeStyle=L!=null&&L.value?R:d,e.lineWidth=a,e.arc(T+P/2,O+M/2,P/2,0,Math.PI*2),e.stroke(),L!=null&&L.value&&(e.beginPath(),e.fillStyle=R,e.arc(T+P/2,O+M/2,P/3,0,Math.PI*2),e.fill()),e.closePath(),e.restore()}}const ui="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHA9Ilx1MjAwQiIsdT1gCmA7ZnVuY3Rpb24gYShpKXt2YXIgYyxmO2xldCBsPSIiLG49MDtmb3IoO248aS5sZW5ndGg7KXtjb25zdCB0PWlbbl07aWYodC50eXBlPT09InRhYmxlIil7aWYodC50ckxpc3QpZm9yKGxldCBzPTA7czx0LnRyTGlzdC5sZW5ndGg7cysrKXtjb25zdCBvPXQudHJMaXN0W3NdO2ZvcihsZXQgZT0wO2U8by50ZExpc3QubGVuZ3RoO2UrKyl7Y29uc3Qgcj1vLnRkTGlzdFtlXTtsKz1hKHIudmFsdWUpfX19ZWxzZSBpZih0LnR5cGU9PT0iaHlwZXJsaW5rIil7Y29uc3Qgcz10Lmh5cGVybGlua0lkLG89W107Zm9yKDtuPGkubGVuZ3RoOyl7Y29uc3QgZT1pW25dO2lmKHMhPT1lLmh5cGVybGlua0lkKXtuLS07YnJlYWt9ZGVsZXRlIGUudHlwZSxvLnB1c2goZSksbisrfWwrPWEobyl9ZWxzZSBpZih0LmNvbnRyb2xJZCl7aWYoISgoYz10LmNvbnRyb2wpIT1udWxsJiZjLmhpZGUpKXtjb25zdCBzPXQuY29udHJvbElkLG89W107Zm9yKDtuPGkubGVuZ3RoOyl7Y29uc3QgZT1pW25dO2lmKHMhPT1lLmNvbnRyb2xJZCl7bi0tO2JyZWFrfWUuY29udHJvbENvbXBvbmVudD09PSJ2YWx1ZSImJihkZWxldGUgZS5jb250cm9sSWQsby5wdXNoKGUpKSxuKyt9bCs9YShvKX19ZWxzZSghdC50eXBlfHx0LnR5cGU9PT0idGV4dCIpJiYhKChmPXQuYXJlYSkhPW51bGwmJmYuaGlkZSkmJihsKz10LnZhbHVlKTtuKyt9cmV0dXJuIGx9ZnVuY3Rpb24gaChpKXtjb25zdCBsPVtdLG49L1swLTldLyxjPS9bQS1aYS16XS8sZj0vXHMvO2xldCB0PSExLHM9ITEsbz0iIjtmdW5jdGlvbiBlKCl7byYmKGwucHVzaChvKSxvPSIiKX1mb3IoY29uc3QgciBvZiBpKWMudGVzdChyKT8odHx8ZSgpLG8rPXIsdD0hMCxzPSExKTpuLnRlc3Qocik/KHN8fGUoKSxvKz1yLHQ9ITEscz0hMCk6KGUoKSx0PSExLHM9ITEsZi50ZXN0KHIpfHxsLnB1c2gocikpO3JldHVybiBlKCksbH1vbm1lc3NhZ2U9aT0+e2NvbnN0IGw9aS5kYXRhLGM9YShsKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke3B9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChwLCJnIiksdSksZj1oKGMpO3Bvc3RNZXNzYWdlKGYubGVuZ3RoKX19KSgpOwo=",hi=typeof window!="undefined"&&window.Blob&&new Blob([atob(ui)],{type:"text/javascript;charset=utf-8"});function Ur(){const o=hi&&(window.URL||window.webkitURL).createObjectURL(hi);try{return o?new Worker(o,{}):new Worker("data:application/javascript;base64,"+ui,{type:"module"})}finally{o&&(window.URL||window.webkitURL).revokeObjectURL(o)}}const gi="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGg9e2ZpcnN0OjEsc2Vjb25kOjIsdGhpcmQ6Myxmb3VydGg6NCxmaWZ0aDo1LHNpeHRoOjZ9LGI9WyJ0ZXh0IiwiaHlwZXJsaW5rIiwic3Vic2NyaXB0Iiwic3VwZXJzY3JpcHQiLCJjb250cm9sIiwiZGF0ZSIsImxhYmVsIl0sbT0iXHUyMDBCIjtmdW5jdGlvbiBJKGMpe3JldHVybiFjLnR5cGV8fGIuaW5jbHVkZXMoYy50eXBlKX1mdW5jdGlvbiBOKGMpe3ZhciBFO2NvbnN0e2VsZW1lbnRMaXN0OmcscG9zaXRpb25MaXN0OmR9PWMscD1bXTtsZXQgcj0wO2Zvcig7cjxnLmxlbmd0aDspe2NvbnN0IHQ9Z1tyXSxsPShlLG4scyk9Pntjb25zdCB1PWUudGl0bGVJZCxMPWUubGV2ZWwsaT17dHlwZToidGl0bGUiLHZhbHVlOiIiLGxldmVsOkwsdGl0bGVJZDp1LHBhZ2VObzpkW3JdLnBhZ2VOb30sbz1bXTtmb3IoO3M8bi5sZW5ndGg7KXtjb25zdCBhPW5bc107aWYodSE9PWEudGl0bGVJZCl7cy0tO2JyZWFrfW8ucHVzaChhKSxzKyt9cmV0dXJuIGkudmFsdWU9by5maWx0ZXIoYT0+SShhKSkubWFwKGE9PmEudmFsdWUpLmpvaW4oIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChtLCJnIiksIiIpLHtwb3NpdGlvbjpzLHRpdGxlRWxlbWVudDppfX07aWYodC50aXRsZUlkKXtjb25zdHtwb3NpdGlvbjplLHRpdGxlRWxlbWVudDpufT1sKHQsZyxyKTtyPWUscC5wdXNoKG4pfWlmKHQudHlwZT09PSJ0YWJsZSIpe2NvbnN0IGU9dC50ckxpc3Q7Zm9yKGxldCBuPTA7bjxlLmxlbmd0aDtuKyspe2NvbnN0IHM9ZVtuXTtmb3IobGV0IHU9MDt1PHMudGRMaXN0Lmxlbmd0aDt1Kyspe2NvbnN0IGk9cy50ZExpc3RbdV0udmFsdWU7aWYoaS5sZW5ndGg+MSl7bGV0IG89MTtmb3IoO288aS5sZW5ndGg7KXtpZigoRT1pW29dKSE9bnVsbCYmRS50aXRsZUlkKXtjb25zdHt0aXRsZUVsZW1lbnQ6YSxwb3NpdGlvbjp5fT1sKGlbb10saSxvKTtwLnB1c2goYSksbz15fW8rK319fX19cisrfWlmKCFwLmxlbmd0aClyZXR1cm4gbnVsbDtjb25zdCBmPSh0LGwpPT57Y29uc3QgZT1sLnN1YkNhdGFsb2dbbC5zdWJDYXRhbG9nLmxlbmd0aC0xXSxuPWhbZT09bnVsbD92b2lkIDA6ZS5sZXZlbF0scz1oW3QubGV2ZWxdO2UmJnM+bj9mKHQsZSk6bC5zdWJDYXRhbG9nLnB1c2goe2lkOnQudGl0bGVJZCxuYW1lOnQudmFsdWUsbGV2ZWw6dC5sZXZlbCxwYWdlTm86dC5wYWdlTm8sc3ViQ2F0YWxvZzpbXX0pfSx2PVtdO2ZvcihsZXQgdD0wO3Q8cC5sZW5ndGg7dCsrKXtjb25zdCBsPXBbdF0sZT12W3YubGVuZ3RoLTFdLG49aFtlPT1udWxsP3ZvaWQgMDplLmxldmVsXSxzPWhbbC5sZXZlbF07ZSYmcz5uP2YobCxlKTp2LnB1c2goe2lkOmwudGl0bGVJZCxuYW1lOmwudmFsdWUsbGV2ZWw6bC5sZXZlbCxwYWdlTm86bC5wYWdlTm8sc3ViQ2F0YWxvZzpbXX0pfXJldHVybiB2fW9ubWVzc2FnZT1jPT57Y29uc3QgZz1jLmRhdGEsZD1OKGcpO3Bvc3RNZXNzYWdlKGQpfX0pKCk7Cg==",Li=typeof window!="undefined"&&window.Blob&&new Blob([atob(gi)],{type:"text/javascript;charset=utf-8"});function Er(){const o=Li&&(window.URL||window.webkitURL).createObjectURL(Li);try{return o?new Worker(o,{}):new Worker("data:application/javascript;base64,"+gi,{type:"module"})}finally{o&&(window.URL||window.webkitURL).revokeObjectURL(o)}}const Ti="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHUoZSl7Y29uc3QgdD1bXTtmb3IoY29uc3QgcyBvZiBlKXtpZihzLnR5cGU9PT0idGFibGUiKXtjb25zdCBvPXMudHJMaXN0O2ZvcihsZXQgbj0wO248by5sZW5ndGg7bisrKXtjb25zdCBjPW9bbl07Zm9yKGxldCByPTA7cjxjLnRkTGlzdC5sZW5ndGg7cisrKXtjb25zdCBpPWMudGRMaXN0W3JdO3QucHVzaCguLi51KGkudmFsdWUpKX19fWlmKCEhcy5ncm91cElkcylmb3IoY29uc3QgbyBvZiBzLmdyb3VwSWRzKXQuaW5jbHVkZXMobyl8fHQucHVzaChvKX1yZXR1cm4gdH1vbm1lc3NhZ2U9ZT0+e2NvbnN0IHQ9ZS5kYXRhLHM9dSh0KTtwb3N0TWVzc2FnZShzKX19KSgpOwo=",Pi=typeof window!="undefined"&&window.Blob&&new Blob([atob(Ti)],{type:"text/javascript;charset=utf-8"});function Cr(){const o=Pi&&(window.URL||window.webkitURL).createObjectURL(Pi);try{return o?new Worker(o,{}):new Worker("data:application/javascript;base64,"+Ti,{type:"module"})}finally{o&&(window.URL||window.webkitURL).revokeObjectURL(o)}}const Oi="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBSPShlPT4oZS5IQUxGPSJoYWxmIixlLk9ORV9USElSRD0ib25lLXRoaXJkIixlLlFVQVJURVI9InF1YXJ0ZXIiLGUpKShSfHx7fSksZz0oZT0+KGUuQVJBQklDPSJhcmFiaWMiLGUuQ0hJTkVTRT0iY2hpbmVzZSIsZSkpKGd8fHt9KSxtPShlPT4oZS5JTkxJTkU9ImlubGluZSIsZS5CTE9DSz0iYmxvY2siLGUuU1VSUk9VTkQ9InN1cnJvdW5kIixlLkZMT0FUX1RPUD0iZmxvYXQtdG9wIixlLkZMT0FUX0JPVFRPTT0iZmxvYXQtYm90dG9tIixlKSkobXx8e30pO2NvbnN0IHY9Ilx1MjAwQiI7Ui5IQUxGKyIiLDEvMixSLk9ORV9USElSRCsiIiwxLzMsUi5RVUFSVEVSKyIiLDEvNDtmdW5jdGlvbiBTKGUpe2lmKHR5cGVvZiBzdHJ1Y3R1cmVkQ2xvbmU9PSJmdW5jdGlvbiIpcmV0dXJuIHN0cnVjdHVyZWRDbG9uZShlKTtpZighZXx8dHlwZW9mIGUhPSJvYmplY3QiKXJldHVybiBlO2xldCBvPXt9O3JldHVybiBBcnJheS5pc0FycmF5KGUpP289ZS5tYXAoZD0+UyhkKSk6T2JqZWN0LmtleXMoZSkuZm9yRWFjaChkPT57b1tkXT1TKGVbZF0pfSksb31mdW5jdGlvbiBOKGUsbyl7Y29uc3QgZD17fTtmb3IoY29uc3QgZiBpbiBlKW8uaW5jbHVkZXMoZikmJihkW2ZdPWVbZl0pO3JldHVybiBkfWZ1bmN0aW9uIF8oZSxvKXtyZXR1cm4gZS5sZW5ndGghPT1vLmxlbmd0aD8hMTohZS5zb21lKGQ9PiFvLmluY2x1ZGVzKGQpKX12YXIgYT0oZT0+KGUuVEVYVD0idGV4dCIsZS5JTUFHRT0iaW1hZ2UiLGUuVEFCTEU9InRhYmxlIixlLkhZUEVSTElOSz0iaHlwZXJsaW5rIixlLlNVUEVSU0NSSVBUPSJzdXBlcnNjcmlwdCIsZS5TVUJTQ1JJUFQ9InN1YnNjcmlwdCIsZS5TRVBBUkFUT1I9InNlcGFyYXRvciIsZS5QQUdFX0JSRUFLPSJwYWdlQnJlYWsiLGUuQ09OVFJPTD0iY29udHJvbCIsZS5BUkVBPSJhcmVhIixlLkNIRUNLQk9YPSJjaGVja2JveCIsZS5SQURJTz0icmFkaW8iLGUuTEFURVg9ImxhdGV4IixlLlRBQj0idGFiIixlLkRBVEU9ImRhdGUiLGUuQkxPQ0s9ImJsb2NrIixlLlRJVExFPSJ0aXRsZSIsZS5MSVNUPSJsaXN0IixlLkxBQkVMPSJsYWJlbCIsZSkpKGF8fHt9KTtjb25zdCBCPVsicm93RmxleCIsInJvd01hcmdpbiIsInRleHRJbmRlbnQiLCJtYXJnaW5MZWZ0IiwibWFyZ2luUmlnaHQiLCJtYXJnaW5Ub3AiLCJtaW5IZWlnaHQiLCJ3aGl0ZVNwYWNlIl0sVT1bInR5cGUiLCJmb250Iiwic2l6ZSIsImJvbGQiLCJjb2xvciIsIml0YWxpYyIsImhpZ2hsaWdodCIsInVuZGVybGluZSIsInN0cmlrZW91dCIsInJvd0ZsZXgiLCJyb3dNYXJnaW4iLCJ0ZXh0SW5kZW50IiwibWFyZ2luTGVmdCIsIm1hcmdpblJpZ2h0IiwibWFyZ2luVG9wIiwibWluSGVpZ2h0Iiwid2hpdGVTcGFjZSIsImRhc2hBcnJheSIsInRyTGlzdCIsInRhYmxlVG9vbERpc2FibGVkIiwiYm9yZGVyVHlwZSIsImJvcmRlckNvbG9yIiwidHJhbnNsYXRlWCIsIndpZHRoIiwiaGVpZ2h0IiwidXJsIiwiY29sZ3JvdXAiLCJ2YWx1ZUxpc3QiLCJjb250cm9sIiwiY2hlY2tib3giLCJyYWRpbyIsImRhdGVGb3JtYXQiLCJibG9jayIsImxldmVsIiwidGl0bGUiLCJsaXN0VHlwZSIsImxpc3RTdHlsZSIsImxpc3RXcmFwIiwiZ3JvdXBJZHMiLCJjb25jZXB0SWQiLCJpbWdEaXNwbGF5IiwiaW1nRmxvYXRQb3NpdGlvbiIsImltZ1Rvb2xEaXNhYmxlZCIsImltZ1ByZXZpZXdEaXNhYmxlZCIsImltZ0Nyb3AiLCJpbWdDYXB0aW9uIiwidGV4dERlY29yYXRpb24iLCJleHRlbnNpb24iLCJleHRlcm5hbElkIiwiYXJlYUlkIiwiYXJlYSIsImhpZGUiLCJsYWJlbCIsImxhYmVsSWQiLCJsaW5lV2lkdGgiLCJmb3JtSW5wdXQiXSx3PVsiY29uY2VwdElkIiwiZXh0ZW5zaW9uIiwiZXh0ZXJuYWxJZCIsInZlcnRpY2FsQWxpZ24iLCJiYWNrZ3JvdW5kQ29sb3IiLCJib3JkZXJUeXBlcyIsInNsYXNoVHlwZXMiLCJkaXNhYmxlZCIsImRlbGV0YWJsZSJdLEs9WyJmb250Iiwic2l6ZSIsImJvbGQiLCJoaWdobGlnaHQiLCJpdGFsaWMiLCJzdHJpa2VvdXQiXTthLlRFWFQsYS5IWVBFUkxJTkssYS5TVUJTQ1JJUFQsYS5TVVBFUlNDUklQVCxhLkNPTlRST0wsYS5EQVRFLGEuSU1BR0UsYS5MQVRFWCxhLkJMT0NLLGEuUEFHRV9CUkVBSyxhLlNFUEFSQVRPUixhLlRBQkxFLGEuVElUTEUsYS5MSVNUO3ZhciBiPShlPT4oZS5VTD0idWwiLGUuT0w9Im9sIixlKSkoYnx8e30pLEw9KGU9PihlLkRJU0M9ImRpc2MiLGUuQ0lSQ0xFPSJjaXJjbGUiLGUuU1FVQVJFPSJzcXVhcmUiLGUuQ0hFQ0tCT1g9ImNoZWNrYm94IixlKSkoTHx8e30pLE89KGU9PihlLkRJU0M9ImRpc2MiLGUuQ0lSQ0xFPSJjaXJjbGUiLGUuU1FVQVJFPSJzcXVhcmUiLGUuREVDSU1BTD0iZGVjaW1hbCIsZS5DSEVDS0JPWD0iY2hlY2tib3giLGUpKShPfHx7fSk7TC5ESVNDKyIiLEwuQ0lSQ0xFKyIiLEwuU1FVQVJFKyIiLEwuQ0hFQ0tCT1grIiIsYi5PTCsiIixiLlVMKyIiLE8uRElTQysiIixPLkNJUkNMRSsiIixPLlNRVUFSRSsiIixPLkRFQ0lNQUwrIiIsTy5DSEVDS0JPWCsiIjt2YXIgRT0oZT0+KGUuRklSU1Q9ImZpcnN0IixlLlNFQ09ORD0ic2Vjb25kIixlLlRISVJEPSJ0aGlyZCIsZS5GT1VSVEg9ImZvdXJ0aCIsZS5GSUZUSD0iZmlmdGgiLGUuU0lYVEg9InNpeHRoIixlKSkoRXx8e30pO0UuRklSU1QrIiIsRS5TRUNPTkQrIiIsRS5USElSRCsiIixFLkZPVVJUSCsiIixFLkZJRlRIKyIiLEUuU0lYVEgrIiIsRS5GSVJTVCsiIixFLlNFQ09ORCsiIixFLlRISVJEKyIiLEUuRk9VUlRIKyIiLEUuRklGVEgrIiIsRS5TSVhUSCsiIixFLkZJUlNULEUuU0VDT05ELEUuVEhJUkQsRS5GT1VSVEgsRS5GSUZUSCxFLlNJWFRIO3ZhciBBPShlPT4oZS5QUkVGSVg9InByZWZpeCIsZS5QT1NURklYPSJwb3N0Zml4IixlLlBSRV9URVhUPSJwcmVUZXh0IixlLlBPU1RfVEVYVD0icG9zdFRleHQiLGUuUExBQ0VIT0xERVI9InBsYWNlaG9sZGVyIixlLlZBTFVFPSJ2YWx1ZSIsZS5DSEVDS0JPWD0iY2hlY2tib3giLGUuUkFESU89InJhZGlvIixlKSkoQXx8e30pLHk9KGU9PihlLkxFRlQ9ImxlZnQiLGUuQ0VOVEVSPSJjZW50ZXIiLGUuUklHSFQ9InJpZ2h0IixlLkFMSUdOTUVOVD0iYWxpZ25tZW50IixlLkpVU1RJRlk9Imp1c3RpZnkiLGUpKSh5fHx7fSksaz0oZT0+KGUuQ09OVEFJTj0iY29udGFpbiIsZS5DT1ZFUj0iY292ZXIiLGUpKShrfHx7fSksRD0oZT0+KGUuUkVQRUFUPSJyZXBlYXQiLGUuTk9fUkVQRUFUPSJuby1yZXBlYXQiLGUuUkVQRUFUX1g9InJlcGVhdC14IixlLlJFUEVBVF9ZPSJyZXBlYXQteSIsZSkpKER8fHt9KTtrLkNPVkVSLEQuTk9fUkVQRUFUO3ZhciBQPShlPT4oZS5UT1A9InRvcCIsZS5NSURETEU9Im1pZGRsZSIsZS5CT1RUT009ImJvdHRvbSIsZSkpKFB8fHt9KTtQLkJPVFRPTSxSLkhBTEYsUi5IQUxGO2NvbnN0IE09e1BBR0VfTk86IntwYWdlTm99IixQQUdFX0NPVU5UOiJ7cGFnZUNvdW50fSJ9O3kuQ0VOVEVSLE0uUEFHRV9OTyxnLkFSQUJJQyxQLkJPVFRPTTt2YXIgeD0oZT0+KGUuVEVYVD0idGV4dCIsZS5JTUFHRT0iaW1hZ2UiLGUpKSh4fHx7fSk7eC5URVhULGcuQVJBQklDO3ZhciBYPShlPT4oZS5QQUdFPSJwYWdlIixlLkNPTlRJTlVJVFk9ImNvbnRpbnVpdHkiLGUpKShYfHx7fSk7WC5DT05USU5VSVRZO2Z1bmN0aW9uIHooZSxvKXtjb25zdCBkPU9iamVjdC5rZXlzKGUpLGY9T2JqZWN0LmtleXMobyk7aWYoZC5sZW5ndGghPT1mLmxlbmd0aClyZXR1cm4hMTtmb3IobGV0IFQ9MDtUPGQubGVuZ3RoO1QrKyl7Y29uc3QgbD1kW1RdO2lmKGwhPT0idmFsdWUiJiYhKGw9PT0iZ3JvdXBJZHMiJiZBcnJheS5pc0FycmF5KGVbbF0pJiZBcnJheS5pc0FycmF5KG9bbF0pJiZfKGVbbF0sb1tsXSkpJiZlW2xdIT09b1tsXSlyZXR1cm4hMX1yZXR1cm4hMH1mdW5jdGlvbiBIKGUsbz17fSl7Y29uc3R7ZXh0cmFQaWNrQXR0cnM6ZH09byxmPVsuLi5VXTtkJiZmLnB1c2goLi4uZCk7Y29uc3QgVD17dmFsdWU6ZS52YWx1ZT09PXY/YApgOmUudmFsdWV9O3JldHVybiBmLmZvckVhY2gobD0+e2NvbnN0IHA9ZVtsXTtwIT09dm9pZCAwJiYoVFtsXT1wKX0pLFR9ZnVuY3Rpb24gSShlLG89e30pe2NvbnN0e2V4dHJhUGlja0F0dHJzOmQsaXNDbGFzc2lmeUFyZWE6Zj0hMSxpc0Nsb25lOlQ9ITB9PW8sbD1UP1MoZSk6ZSxwPVtdO2xldCBpPTA7Zm9yKDtpPGwubGVuZ3RoOyl7bGV0IHQ9bFtpXTtpZihpPT09MCYmdC52YWx1ZT09PXYmJiF0Lmxpc3RJZCYmKCF0LnR5cGV8fHQudHlwZT09PWEuVEVYVCkpe2krKztjb250aW51ZX1pZih0LmFyZWFJZCl7Y29uc3Qgcj10LmFyZWFJZCx1PXQuYXJlYSxjPVtdO2Zvcig7aTxsLmxlbmd0aDspe2NvbnN0IHM9bFtpXTtpZihyIT09cy5hcmVhSWQpe2ktLTticmVha31kZWxldGUgcy5hcmVhLGRlbGV0ZSBzLmFyZWFJZCxjLnB1c2gocyksaSsrfWNvbnN0IG49SShjLG8pO2lmKGYpe2NvbnN0IHM9e3R5cGU6YS5BUkVBLHZhbHVlOiIiLGFyZWFJZDpyLGFyZWE6dX07cy52YWx1ZUxpc3Q9bix0PXN9ZWxzZXtwLnNwbGljZShpLDAsLi4ubik7Y29udGludWV9fWVsc2UgaWYodC50aXRsZUlkJiZ0LmxldmVsKXtjb25zdCByPXQudGl0bGVJZDtpZihyKXtjb25zdCB1PXQubGV2ZWwsYz17dHlwZTphLlRJVExFLHRpdGxlOnQudGl0bGUsdGl0bGVJZDpyLHZhbHVlOiIiLGxldmVsOnV9LG49W107Zm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgcz1sW2ldO2lmKHIhPT1zLnRpdGxlSWQpe2ktLTticmVha31kZWxldGUgcy5sZXZlbCxkZWxldGUgcy50aXRsZSxuLnB1c2gocyksaSsrfWMudmFsdWVMaXN0PUkobixvKSx0PWN9fWVsc2UgaWYodC5saXN0SWQmJnQubGlzdFR5cGUpe2NvbnN0IHI9dC5saXN0SWQ7aWYocil7Y29uc3QgdT10Lmxpc3RUeXBlLGM9dC5saXN0U3R5bGUsbj17dHlwZTphLkxJU1QsdmFsdWU6IiIsbGlzdElkOnIsbGlzdFR5cGU6dSxsaXN0U3R5bGU6Y30scz1bXTtmb3IoO2k8bC5sZW5ndGg7KXtjb25zdCBoPWxbaV07aWYociE9PWgubGlzdElkKXtpLS07YnJlYWt9ZGVsZXRlIGgubGlzdFR5cGUsZGVsZXRlIGgubGlzdFN0eWxlLHMucHVzaChoKSxpKyt9bi52YWx1ZUxpc3Q9SShzLG8pLHQ9bn19ZWxzZSBpZih0LnR5cGU9PT1hLlRBQkxFKXtpZih0LnBhZ2luZ0lkKXtsZXQgcj1pKzEsdT0wO2Zvcig7cjxsLmxlbmd0aDspe2NvbnN0IGM9bFtyXTtpZihjLnBhZ2luZ0lkPT09dC5wYWdpbmdJZCl0LmhlaWdodCs9Yy5oZWlnaHQsdC50ckxpc3QucHVzaCguLi5jLnRyTGlzdCkscisrLHUrKztlbHNlIGJyZWFrfWkrPXV9aWYodC50ckxpc3QpZm9yKGxldCByPTA7cjx0LnRyTGlzdC5sZW5ndGg7cisrKXtjb25zdCB1PXQudHJMaXN0W3JdO2RlbGV0ZSB1LmlkO2ZvcihsZXQgYz0wO2M8dS50ZExpc3QubGVuZ3RoO2MrKyl7Y29uc3Qgbj11LnRkTGlzdFtjXSxzPXtjb2xzcGFuOm4uY29sc3Bhbixyb3dzcGFuOm4ucm93c3Bhbix2YWx1ZTpJKG4udmFsdWUsey4uLm8saXNDbGFzc2lmeUFyZWE6ITF9KX07dy5mb3JFYWNoKGg9Pntjb25zdCBDPW5baF07QyE9PXZvaWQgMCYmKHNbaF09Qyl9KSx1LnRkTGlzdFtjXT1zfX19ZWxzZSBpZih0LnR5cGU9PT1hLkhZUEVSTElOSyl7Y29uc3Qgcj10Lmh5cGVybGlua0lkO2lmKHIpe2NvbnN0IHU9e3R5cGU6YS5IWVBFUkxJTkssdmFsdWU6IiIsdXJsOnQudXJsfSxjPVtdO2Zvcig7aTxsLmxlbmd0aDspe2NvbnN0IG49bFtpXTtpZihyIT09bi5oeXBlcmxpbmtJZCl7aS0tO2JyZWFrfWRlbGV0ZSBuLnR5cGUsZGVsZXRlIG4udXJsLGMucHVzaChuKSxpKyt9dS52YWx1ZUxpc3Q9SShjLG8pLHQ9dX19ZWxzZSBpZih0LnR5cGU9PT1hLkRBVEUpe2NvbnN0IHI9dC5kYXRlSWQ7aWYocil7Y29uc3QgdT17dHlwZTphLkRBVEUsdmFsdWU6IiIsZGF0ZUZvcm1hdDp0LmRhdGVGb3JtYXR9LGM9W107Zm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgbj1sW2ldO2lmKHIhPT1uLmRhdGVJZCl7aS0tO2JyZWFrfWRlbGV0ZSBuLnR5cGUsZGVsZXRlIG4uZGF0ZUZvcm1hdCxjLnB1c2gobiksaSsrfXUudmFsdWVMaXN0PUkoYyxvKSx0PXV9fWVsc2UgaWYodC5jb250cm9sSWQpe2NvbnN0IHI9dC5jb250cm9sSWQ7aWYodC5jb250cm9sQ29tcG9uZW50PT09QS5QUkVGSVgpe2NvbnN0IHU9W107bGV0IGM9ITEsbj1pO2Zvcig7bjxsLmxlbmd0aDspe2NvbnN0IHM9bFtuXTtpZihyIT09cy5jb250cm9sSWQpYnJlYWs7cy5jb250cm9sQ29tcG9uZW50PT09QS5WQUxVRSYmKGRlbGV0ZSBzLmNvbnRyb2wsZGVsZXRlIHMuY29udHJvbElkLHUucHVzaChzKSkscy5jb250cm9sQ29tcG9uZW50PT09QS5QT1NURklYJiYoYz0hMCksbisrfWlmKGMpe2NvbnN0IHM9Tih0LEspLGg9ey4uLnQuY29udHJvbCwuLi5zfSxDPXsuLi5OKHQsQiksdHlwZTphLkNPTlRST0wsdmFsdWU6IiIsY29udHJvbDpoLGNvbnRyb2xJZDpyfTtDLmNvbnRyb2wudmFsdWU9SSh1LG8pLHQ9SChDLHtleHRyYVBpY2tBdHRyczpkfSksaSs9bi1pLTF9fWlmKHQuY29udHJvbENvbXBvbmVudCYmKGRlbGV0ZSB0LmNvbnRyb2wsZGVsZXRlIHQuY29udHJvbElkLHQuY29udHJvbENvbXBvbmVudCE9PUEuVkFMVUUmJnQuY29udHJvbENvbXBvbmVudCE9PUEuUFJFX1RFWFQmJnQuY29udHJvbENvbXBvbmVudCE9PUEuUE9TVF9URVhUKSl7aSsrO2NvbnRpbnVlfX1jb25zdCBGPUgodCx7ZXh0cmFQaWNrQXR0cnM6ZH0pO2lmKCF0LnR5cGV8fHQudHlwZT09PWEuVEVYVHx8dC50eXBlPT09YS5TVUJTQ1JJUFR8fHQudHlwZT09PWEuU1VQRVJTQ1JJUFQpZm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgcj1sW2krMV07aWYoaSsrLHImJnooRixIKHIse2V4dHJhUGlja0F0dHJzOmR9KSkpe2NvbnN0IHU9ci52YWx1ZT09PXY/YApgOnIudmFsdWU7Ri52YWx1ZSs9dX1lbHNlIGJyZWFrfWVsc2UgaSsrO3AucHVzaChGKX1yZXR1cm4gcH1PYmplY3QudmFsdWVzKG0pLG9ubWVzc2FnZT1lPT57Y29uc3Qgbz1lLmRhdGEse29wdGlvbnM6ZCxkYXRhOmZ9PW8se2V4dHJhUGlja0F0dHJzOlQ9W119PWR8fHt9LGw9e2hlYWRlcjpJKGYuaGVhZGVyLHtleHRyYVBpY2tBdHRyczpULGlzQ2xvbmU6ITF9KSxtYWluOkkoZi5tYWluLHtleHRyYVBpY2tBdHRyczpULGlzQ2xhc3NpZnlBcmVhOiEwLGlzQ2xvbmU6ITF9KSxmb290ZXI6SShmLmZvb3Rlcix7ZXh0cmFQaWNrQXR0cnM6VCxpc0Nsb25lOiExfSl9O3Bvc3RNZXNzYWdlKGwpfX0pKCk7Cg==",Mi=typeof window!="undefined"&&window.Blob&&new Blob([atob(Oi)],{type:"text/javascript;charset=utf-8"});function Qr(){const o=Mi&&(window.URL||window.webkitURL).createObjectURL(Mi);try{return o?new Worker(o,{}):new Worker("data:application/javascript;base64,"+Oi,{type:"module"})}finally{o&&(window.URL||window.webkitURL).revokeObjectURL(o)}}class br{constructor(t){this.draw=t,this.wordCountWorker=new Ur,this.catalogWorker=new Er,this.groupWorker=new Cr,this.valueWorker=new Qr}getWordCount(){return new Promise((t,e)=>{this.wordCountWorker.onmessage=i=>{t(i.data)},this.wordCountWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.wordCountWorker.postMessage(n)})}getCatalog(){return new Promise((t,e)=>{this.catalogWorker.onmessage=r=>{t(r.data)},this.catalogWorker.onerror=r=>{e(r)};const n=this.draw.getOriginalMainElementList(),i=this.draw.getPosition().getOriginalMainPositionList();this.catalogWorker.postMessage({elementList:n,positionList:i})})}getGroupIds(){return new Promise((t,e)=>{this.groupWorker.onmessage=i=>{t(i.data)},this.groupWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.groupWorker.postMessage(n)})}getValue(t){return new Promise((e,n)=>{this.valueWorker.onmessage=i=>{e({version:xe,data:i.data,options:et(this.draw.getOptions())})},this.valueWorker.onerror=i=>{n(i)},this.valueWorker.postMessage({data:this.draw.getOriginValue(t),options:t})})}}var Za="";class zt{constructor(t){this.options=t,this.mask=null,this.container=null,this.inputList=[],this.searchDropdowns=new Map,this._render()}_render(){var O;const{title:t,data:e,onClose:n,onCancel:i,onConfirm:r}=this.options,s=document.createElement("div");s.classList.add("dialog-mask"),s.setAttribute(Ht,c.EditorComponent.COMPONENT),document.body.append(s);const l=document.createElement("div");l.classList.add("dialog-container"),l.setAttribute(Ht,c.EditorComponent.COMPONENT);const a=document.createElement("div");a.classList.add("dialog"),l.append(a);const R=document.createElement("div");R.classList.add("dialog-title");const d=document.createElement("span");d.append(document.createTextNode(t));const u=document.createElement("i");u.onclick=()=>{n&&n(),this._dispose()},R.append(d),R.append(u),a.append(R);const h=document.createElement("div");h.classList.add("dialog-option");for(let P=0;P<e.length;P++){const M=e[P],f=document.createElement("div");if(f.classList.add("dialog-option__item"),M.label){const S=document.createElement("span");S.append(document.createTextNode(M.label)),f.append(S),M.required&&S.classList.add("dialog-option__item--require")}if(M.type==="select")if(M.searchable===!1){const S=document.createElement("select");M.width&&(S.style.width=`${M.width}px`),M.height&&(S.style.height=`${M.height}px`),S.name=M.name,S.value=M.value||"",(O=M.options)==null||O.forEach(I=>{const m=document.createElement("option");m.value=I.value,m.label=I.label,S.append(m)}),f.append(S),h.append(f),this.inputList.push(S)}else{const S=this._createSearchableSelect(M);f.append(S),h.append(f),this.inputList.push(S)}else{let S;if(M.type==="textarea")S=document.createElement("textarea");else if(M.type==="color"){S=document.createElement("input"),S.type="text",S.onclick=function(){I.click()};const I=document.querySelector("#color");I.oninput=function(){S.value=I.value}}else S=document.createElement("input"),S.type=M.type;M.width&&(S.style.width=`${M.width}px`),M.height&&(S.style.height=`${M.height}px`),S.name=M.name,S.value=M.value||"",S instanceof HTMLSelectElement||(S.placeholder=M.placeholder||""),f.append(S),h.append(f),this.inputList.push(S)}}a.append(h);const g=document.createElement("div");g.classList.add("dialog-menu");const L=document.createElement("button");L.classList.add("dialog-menu__cancel"),L.append(document.createTextNode("\u53D6\u6D88")),L.type="button",L.onclick=()=>{i&&i(),this._dispose()},g.append(L);const T=document.createElement("button");T.append(document.createTextNode("\u786E\u5B9A")),T.type="submit",T.onclick=()=>{if(r){const P=this.inputList.map(M=>{if(M instanceof HTMLDivElement&&M.classList.contains("searchable-select")){const S=M.getAttribute("data-name")||"",I=this.searchDropdowns.get(S);return{name:S,value:(I==null?void 0:I.selectedValue)||""}}const f=M;return{name:f.name,value:f.value}});r(P)}this._dispose()},g.append(T),a.append(g),document.body.append(l),this.container=l,this.mask=s}_createSearchableSelect(t){var h;const e=document.createElement("div");e.classList.add("searchable-select"),e.setAttribute("data-name",t.name),t.width&&(e.style.width=`${t.width}px`);const n=document.createElement("input");n.type="text",n.classList.add("searchable-select__input"),n.placeholder=t.placeholder||"\u8BF7\u9009\u62E9\u6216\u641C\u7D22";const i=this.searchDropdowns.get(t.name),r=(i==null?void 0:i.selectedValue)||t.value||"";if(r&&t.options){const g=t.options.find(L=>L.value===r);g&&(n.value=g.label)}const s=document.createElement("span");s.classList.add("searchable-select__arrow"),s.innerHTML="\u25BC";const l=document.createElement("div");l.classList.add("searchable-select__input-wrapper"),l.append(n),l.append(s);const a=document.createElement("div");a.classList.add("searchable-select__dropdown"),a.style.display="none";const R=(g="")=>{var P;a.innerHTML="";const L=((P=t.options)==null?void 0:P.filter(M=>!g||M.label.toLowerCase().includes(g.toLowerCase())))||[],T=this.searchDropdowns.get(t.name),O=(T==null?void 0:T.selectedValue)||t.value||"";if(L.length===0){const M=document.createElement("div");M.classList.add("searchable-select__option","searchable-select__option--empty"),M.textContent="\u65E0\u5339\u914D\u9009\u9879",a.append(M)}else L.forEach(M=>{const f=document.createElement("div");f.classList.add("searchable-select__option"),f.textContent=M.label,f.setAttribute("data-value",M.value),M.value===O&&f.classList.add("searchable-select__option--selected"),f.onclick=S=>{S.stopPropagation();const I=f.getAttribute("data-value")||"";n.value=M.label,a.querySelectorAll(".searchable-select__option").forEach(F=>{F.classList.remove("searchable-select__option--selected")}),f.classList.add("searchable-select__option--selected");const N=this.searchDropdowns.get(t.name);N&&(N.selectedValue=I),a.style.display="none"},a.append(f)})};R(),n.oninput=()=>{R(n.value),a.style.display="block"},n.onclick=g=>{g.stopPropagation(),document.querySelectorAll(".searchable-select__dropdown").forEach(T=>{T!==a&&(T.style.display="none")}),a.style.display=a.style.display==="block"?"none":"block"},s.onclick=g=>{g.stopPropagation(),document.querySelectorAll(".searchable-select__dropdown").forEach(T=>{T!==a&&(T.style.display="none")}),a.style.display=a.style.display==="block"?"none":"block",n.focus()};const d=g=>{const L=g.target;e.contains(L)||(a.style.display="none")};document.addEventListener("click",d);const u=document.createElement("select");return u.style.display="none",u.name=t.name,u.value=t.value||"",(h=t.options)==null||h.forEach(g=>{const L=document.createElement("option");L.value=g.value,L.label=g.label,u.append(L)}),this.searchDropdowns.set(t.name,{selectedValue:t.value||"",selectElement:u}),e.append(l),e.append(a),e.append(u),e}_dispose(){var t,e;(t=this.mask)==null||t.remove(),(e=this.container)==null||e.remove()}}function fi(o){const t={width:400,height:200,fontFamily:"Simsun",fontSize:20,color:"#ffffff",bold:!1,italic:!1,borderWidth:1,textBgColor:"#000000",borderColor:"#000000",text:"",...o};console.log("config",t);const e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height);let i="";t.bold&&(i+="bold "),t.italic&&(i+="italic ");let r=t.fontSize,s,l;do{const g=`${i}${r}px ${t.fontFamily}`;n.font=g;const L=n.measureText(t.text);if(s=L.width,l=L.actualBoundingBoxAscent+L.actualBoundingBoxDescent,(s>t.width||l>t.height)&&r>1)r--;else break}while(!0);const a=`${i}${r}px ${t.fontFamily}`;n.font=a;const R=n.measureText(t.text);s=R.width,l=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent;const d=(t.width-s)/2-4,u=(t.height-l)/2-4;n.fillStyle=t.textBgColor,n.fillRect(d,u,s+8,l+8),n.fillStyle=t.color,n.textAlign="center",n.textBaseline="middle",n.fillText(t.text,e.width/2,e.height/2);const h=t.borderWidth;return n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(h,h,t.width-h*2,t.height-h*2),e.toDataURL("image/png")}function Si(o){const t={checked:!1,width:100,height:40,label:"",fontSize:14,fontFamily:"SimSun",color:"#000000",borderColor:"#000000",checkColor:"#5175f4",boxSize:20,gap:8,borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=t.height/2,r=t.gap+t.borderWidth,s=i-t.boxSize/2;if(n.strokeStyle=t.borderColor,n.lineWidth=1.5,n.strokeRect(r,s,t.boxSize,t.boxSize),t.checked){n.fillStyle=t.checkColor,n.fillRect(r+2,s+2,t.boxSize-4,t.boxSize-4),n.beginPath(),n.strokeStyle="#ffffff",n.lineWidth=2,n.lineCap="round",n.lineJoin="round";const l=r+5,a=s+t.boxSize/2+2,R=r+t.boxSize/2-1,d=s+t.boxSize-6,u=r+t.boxSize-4,h=s+6;n.moveTo(l,a),n.lineTo(R,d),n.lineTo(u,h),n.stroke()}if(t.label){n.font=`${t.fontSize}px ${t.fontFamily}`,n.fillStyle=t.color,n.textAlign="left",n.textBaseline="middle";const l=r+t.boxSize+t.gap;n.fillText(t.label,l,i)}return e.toDataURL("image/png")}function mi(o){const t={checked:!1,width:100,height:40,label:"",fontSize:14,fontFamily:"SimSun",color:"#000000",borderColor:"#000000",checkColor:"#5175f4",boxSize:20,gap:8,borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=t.height/2,r=t.gap+t.borderWidth,s=i-t.boxSize/2,l=r+t.boxSize/2,a=s+t.boxSize/2;if(n.strokeStyle=t.borderColor,n.lineWidth=1.5,n.beginPath(),n.arc(l,a,t.boxSize/2,0,Math.PI*2),n.stroke(),t.checked&&(n.fillStyle=t.checkColor,n.beginPath(),n.arc(l,a,t.boxSize/4,0,Math.PI*2),n.fill()),t.label){n.font=`${t.fontSize}px ${t.fontFamily}`,n.fillStyle=t.color,n.textAlign="left",n.textBaseline="middle";const R=r+t.boxSize+t.gap;n.fillText(t.label,R,i)}return e.toDataURL("image/png")}function Ii(o,t){var e,n,i,r,s,l,a,R,d,u,h,g,L,T,O;console.log("el",o),new zt({title:"\u8868\u5355\u590D\u9009\u6846",data:[{type:"select",label:"\u8868\u5355 Key",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355 Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"120"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"40"},{type:"select",label:"\u9ED8\u8BA4\u9009\u4E2D",name:"checked",required:!0,value:(a=o==null?void 0:o.formInput)!=null&&a.checked?"true":"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"text",label:"\u6807\u7B7E\u6587\u5B57",name:"label",required:!0,value:(d=(R=o==null?void 0:o.formInput)==null?void 0:R.label)!=null?d:"",placeholder:"\u8BF7\u8F93\u5165\u6807\u7B7E\u6587\u5B57"},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(h=(u=o==null?void 0:o.formInput)==null?void 0:u.fontSize)!=null?h:"14"},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(L=(g=o==null?void 0:o.formInput)==null?void 0:g.color)!=null?L:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(O=(T=o==null?void 0:o.formInput)==null?void 0:T.fontFamily)!=null?O:"SimSun",options:t.getExtensionParam("fontOptions")==null||t.getExtensionParam("fontOptions")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("fontOptions")}],onConfirm:P=>{var K,b,Y,y,D,H,_,v;console.log("payload: ",P);const M=(K=P.find(J=>J.name==="key"))==null?void 0:K.value;if(!M)return;const f=(b=P.find(J=>J.name==="width"))==null?void 0:b.value;if(!f)return;const S=(Y=P.find(J=>J.name==="height"))==null?void 0:Y.value;if(!S)return;const I=((y=P.find(J=>J.name==="checked"))==null?void 0:y.value)==="true",m=((D=P.find(J=>J.name==="label"))==null?void 0:D.value)||"",N=(H=P.find(J=>J.name==="fontSize"))==null?void 0:H.value,F=(_=P.find(J=>J.name==="color"))==null?void 0:_.value,Z=(v=P.find(J=>J.name==="fontFamily"))==null?void 0:v.value,W="checkbox",p=t.getExtensionParam("formInputKeys").find(J=>J.value===M),X=p?JSON.stringify(p):"",E={key:M,width:f,height:S,checked:I,label:m,fontSize:N,fontFamily:Z,color:F,type:W,elemProp:X},U={value:Si({checked:I,label:m,width:Number(f),height:Number(S),fontSize:Number(N),fontFamily:Z,color:F}),type:c.ElementType.IMAGE,formInput:E,width:Number(f),height:Number(S)};if(o!=null&&o.id){const J={id:o.id,properties:U};console.log("deleteOpt12",J),t.command.executeUpdateElementById(J);return}t.command.executeInsertElementList([U])}})}function Xi(o,t){var e,n,i,r,s,l,a,R,d,u,h,g,L,T,O;console.log("el",o),new zt({title:"\u8868\u5355\u5355\u9009\u6846",data:[{type:"select",label:"\u8868\u5355 Key",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355 Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"120"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"40"},{type:"select",label:"\u9ED8\u8BA4\u9009\u4E2D",name:"checked",required:!0,value:(a=o==null?void 0:o.formInput)!=null&&a.checked?"true":"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"text",label:"\u6807\u7B7E\u6587\u5B57",name:"label",required:!0,value:(d=(R=o==null?void 0:o.formInput)==null?void 0:R.label)!=null?d:"",placeholder:"\u8BF7\u8F93\u5165\u6807\u7B7E\u6587\u5B57"},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(h=(u=o==null?void 0:o.formInput)==null?void 0:u.fontSize)!=null?h:"14"},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(L=(g=o==null?void 0:o.formInput)==null?void 0:g.color)!=null?L:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(O=(T=o==null?void 0:o.formInput)==null?void 0:T.fontFamily)!=null?O:"SimSun",options:t.getExtensionParam("fontOptions")==null||t.getExtensionParam("fontOptions")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("fontOptions")}],onConfirm:P=>{var K,b,Y,y,D,H,_,v;console.log("payload: ",P);const M=(K=P.find(J=>J.name==="key"))==null?void 0:K.value;if(!M)return;const f=(b=P.find(J=>J.name==="width"))==null?void 0:b.value;if(!f)return;const S=(Y=P.find(J=>J.name==="height"))==null?void 0:Y.value;if(!S)return;const I=((y=P.find(J=>J.name==="checked"))==null?void 0:y.value)==="true",m=((D=P.find(J=>J.name==="label"))==null?void 0:D.value)||"",N=(H=P.find(J=>J.name==="fontSize"))==null?void 0:H.value,F=(_=P.find(J=>J.name==="color"))==null?void 0:_.value,Z=(v=P.find(J=>J.name==="fontFamily"))==null?void 0:v.value,W="radio",p=t.getExtensionParam("formInputKeys").find(J=>J.value===M),X=p?JSON.stringify(p):"",E={key:M,width:f,height:S,checked:I,label:m,fontSize:N,fontFamily:Z,color:F,type:W,elemProp:X},U={value:mi({checked:I,label:m,width:Number(f),height:Number(S),fontSize:Number(N),fontFamily:Z,color:F}),type:c.ElementType.IMAGE,formInput:E,width:Number(f),height:Number(S)};if(o!=null&&o.id){const J={id:o.id,properties:U};t.command.executeUpdateElementById(J);return}t.command.executeInsertElementList([U])}})}function Ni(o,t){var e,n,i,r,s,l,a,R,d,u,h,g,L,T,O,P,M,f,S,I,m,N,F,Z;console.log("el",o),new zt({title:"\u8868\u5355\u6587\u672C\u6846",data:[{type:"select",label:"\u8868\u5355Key",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6(px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"100"},{type:"number",label:"\u9AD8\u5EA6(px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"50"},{type:"text",label:"\u884C\u9AD8",name:"lineHeight",required:!1,placeholder:"\u683C\u5F0F\u5316\u6587\u672C\u4F7F\u7528",value:(R=(a=o==null?void 0:o.formInput)==null?void 0:a.lineHeight)!=null?R:""},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(u=(d=o==null?void 0:o.formInput)==null?void 0:d.fontSize)!=null?u:"10"},{type:"select",label:"\u662F\u5426\u52A0\u7C97",name:"bold",required:!0,value:(h=o==null?void 0:o.formInput)!=null&&h.bold?String((g=o==null?void 0:o.formInput)==null?void 0:g.bold):"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"select",label:"\u662F\u5426\u659C\u4F53",name:"italic",required:!0,value:(L=o==null?void 0:o.formInput)!=null&&L.italic?String((T=o==null?void 0:o.formInput)==null?void 0:T.italic):"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"select",label:"\u586B\u5145\u7C7B\u578B",name:"txtFillType",required:!0,value:(O=o==null?void 0:o.formInput)!=null&&O.txtFillType?String((P=o==null?void 0:o.formInput)==null?void 0:P.txtFillType):"0",options:[{label:"\u6587\u672C",value:"0"},{label:"\u683C\u5F0F\u5316",value:"1"}]},{type:"select",label:"\u662F\u5426\u81EA\u52A8\u6362\u884C",name:"txtRowAutoFlag",required:!1,value:(M=o==null?void 0:o.formInput)!=null&&M.txtRowAutoFlag?String((f=o==null?void 0:o.formInput)==null?void 0:f.txtRowAutoFlag):"1",options:[{label:"\u662F",value:"0"},{label:"\u5426",value:"1"}]},{type:"select",label:"\u662F\u5426\u53EF\u7F16\u8F91",name:"txtEditFlag",required:!1,value:(S=o==null?void 0:o.formInput)!=null&&S.txtEditFlag?String((I=o==null?void 0:o.formInput)==null?void 0:I.txtEditFlag):"1",options:[{label:"\u662F",value:"0"},{label:"\u5426",value:"1"}]},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(N=(m=o==null?void 0:o.formInput)==null?void 0:m.color)!=null?N:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(Z=(F=o==null?void 0:o.formInput)==null?void 0:F.fontFamily)!=null?Z:"SimSun",options:t.getExtensionParam("fontOptions")==null||t.getExtensionParam("fontOptions")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("fontOptions")}],onConfirm:W=>{var gt,tt,j,Tt,Dt,lt,k,Q,Xt,G,$t,ye;console.log("payload: ",W);const V=(gt=W.find(B=>B.name==="key"))==null?void 0:gt.value;if(!V)return;const p=(tt=W.find(B=>B.name==="width"))==null?void 0:tt.value;if(!p)return;const X=(j=W.find(B=>B.name==="height"))==null?void 0:j.value;if(!X)return;const E=(Tt=W.find(B=>B.name==="fontSize"))==null?void 0:Tt.value,C=(Dt=W.find(B=>B.name==="lineHeight"))==null?void 0:Dt.value,U=((lt=W.find(B=>B.name==="bold"))==null?void 0:lt.value)==="true",K=((k=W.find(B=>B.name==="italic"))==null?void 0:k.value)==="true",b=(Q=W.find(B=>B.name==="color"))==null?void 0:Q.value,Y=(Xt=W.find(B=>B.name==="fontFamily"))==null?void 0:Xt.value,y="input",H=t.getExtensionParam("formInputKeys").find(B=>B.value===V),_=H?JSON.stringify(H):"",v=(G=W.find(B=>B.name==="txtFillType"))==null?void 0:G.value,J=($t=W.find(B=>B.name==="txtRowAutoFlag"))==null?void 0:$t.value,z=(ye=W.find(B=>B.name==="txtEditFlag"))==null?void 0:ye.value,ft={key:V,width:p,height:X,fontSize:E,bold:U,italic:K,color:b,fontFamily:Y,type:y,txtFillType:v,txtRowAutoFlag:J,txtEditFlag:z,elemProp:_,lineHeight:C},it={value:fi({text:V,width:p,height:X}),type:c.ElementType.IMAGE,formInput:ft,width:Number(p),height:Number(X),verticalAlign:"text-top"};if(o!=null&&o.id){const B={id:o.id,properties:it};console.log("deleteOpt12",B),t.command.executeUpdateElementById(B);return}t.command.executeInsertElementList([it])}})}function pi(o){const t={key:"",width:200,height:150,picAutoFlag:!1,picFillType:"default",borderColor:"#000000",borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=60,r=(t.width-i)/2,s=t.height/2-i/2-10;n.strokeStyle="#999999",n.lineWidth=2,n.strokeRect(r,s,i,i),n.fillStyle="#cccccc",n.beginPath(),n.moveTo(r+10,s+i-10),n.lineTo(r+i/2,s+15),n.lineTo(r+i-10,s+i-10),n.closePath(),n.fill(),n.fillStyle="#ffcc00",n.beginPath(),n.arc(r+i-20,s+15,8,0,Math.PI*2),n.fill(),t.key&&(n.font="14px SimSun",n.fillStyle="#000000",n.textAlign="center",n.textBaseline="middle",n.fillText(t.key,t.width/2,s+i+20)),t.picAutoFlag==="0"&&(n.font="12px SimSun",n.fillStyle="#5175f4",n.textAlign="left",n.fillText("\u2713 \u81EA\u9002\u5E94",10,t.height-15));const l=t.picFillType==="0"?"\u9ED8\u8BA4\u5927\u5C0F":t.picFillType==="1"?"\u5206\u5272":"\u987A\u5E8F";return n.font="12px SimSun",n.fillStyle="#666666",n.textAlign="right",n.fillText(`\u586B\u5145: ${l}`,t.width-10,t.height-15),e.toDataURL("image/png")}function Fi(o){const t={key:"",width:200,height:100,picAutoFlag:!1,borderColor:"#000000",borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=50,r=(t.width-i)/2,s=t.height/2-i/2-5;return n.fillStyle="#4a90e2",n.beginPath(),n.moveTo(r+10,s+i),n.lineTo(r+i-10,s+10),n.lineTo(r+i,s+15),n.lineTo(r+15,s+i+5),n.closePath(),n.fill(),n.fillStyle="#333333",n.beginPath(),n.moveTo(r+10,s+i),n.lineTo(r+15,s+i+5),n.lineTo(r+5,s+i+8),n.closePath(),n.fill(),t.key&&(n.font="14px SimSun",n.fillStyle="#000000",n.textAlign="center",n.textBaseline="middle",n.fillText(t.key,t.width/2,s+i+20)),t.picAutoFlag==="0"&&(n.font="12px SimSun",n.fillStyle="#5175f4",n.textAlign="left",n.fillText("\u2713 \u81EA\u9002\u5E94",10,t.height-15)),n.font="12px SimSun",n.fillStyle="#666666",n.textAlign="right",n.fillText("\u7B7E\u5B57\u6846",t.width-10,t.height-15),e.toDataURL("image/png")}function Wi(o){const t={key:"",width:200,height:100,picAutoFlag:!1,borderColor:"#000000",borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=50,r=(t.width-i)/2,s=t.height/2-i/2-5,l=r+i/2,a=s+i/2;return n.strokeStyle="#e74c3c",n.lineWidth=2.5,n.beginPath(),n.arc(l,a,i/2-5,0,Math.PI*2),n.stroke(),n.strokeStyle="#e74c3c",n.lineWidth=1.5,n.beginPath(),n.arc(l,a,i/2-10,0,Math.PI*2),n.stroke(),n.fillStyle="#e74c3c",n.font="bold 16px SimSun",n.textAlign="center",n.textBaseline="middle",n.fillText("\u7AE0",l,a),t.key&&(n.font="14px SimSun",n.fillStyle="#000000",n.textAlign="center",n.textBaseline="middle",n.fillText(t.key,t.width/2,s+i+20)),t.picAutoFlag==="0"&&(n.font="12px SimSun",n.fillStyle="#5175f4",n.textAlign="left",n.fillText("\u2713 \u81EA\u9002\u5E94",10,t.height-15)),n.font="12px SimSun",n.fillStyle="#666666",n.textAlign="right",n.fillText("\u7B7E\u7AE0\u6846",t.width-10,t.height-15),e.toDataURL("image/png")}function Vi(o){const t={key:"",width:200,height:100,riskCopyContent:"",borderColor:"#000000",borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=50,r=(t.width-i)/2,s=t.height/2-i/2-5;if(n.strokeStyle="#f39c12",n.lineWidth=2,n.strokeRect(r+5,s+5,i-10,i-10),n.beginPath(),n.moveTo(r+10,s+15),n.lineTo(r+i-10,s+15),n.moveTo(r+10,s+25),n.lineTo(r+i-10,s+25),n.moveTo(r+10,s+35),n.lineTo(r+i-20,s+35),n.stroke(),n.fillStyle="#e74c3c",n.beginPath(),n.moveTo(r+i-15,s+5),n.lineTo(r+i-5,s+20),n.lineTo(r+i-25,s+20),n.closePath(),n.fill(),n.fillStyle="#ffffff",n.font="bold 12px Arial",n.textAlign="center",n.textBaseline="middle",n.fillText("!",r+i-15,s+14),t.key&&(n.font="14px SimSun",n.fillStyle="#000000",n.textAlign="center",n.textBaseline="middle",n.fillText(t.key,t.width/2,s+i+20)),t.riskCopyContent){n.font="11px SimSun",n.fillStyle="#666666",n.textAlign="left";const l=t.riskCopyContent.length>20?t.riskCopyContent.substring(0,20)+"...":t.riskCopyContent;n.fillText(l,10,t.height-30)}return n.font="12px SimSun",n.fillStyle="#666666",n.textAlign="right",n.fillText("\u98CE\u9669\u6284\u5F55",t.width-10,t.height-15),e.toDataURL("image/png")}function Yi(o,t){var e,n,i,r,s,l,a,R,d,u,h,g,L,T,O,P;console.log("el",o),new zt({title:"\u56FE\u7247\u6846\u914D\u7F6E",data:[{type:"select",label:"\u5143\u7D20\u540D\u79F0",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u9009\u62E9\u5143\u7D20\u540D\u79F0",options:t.getExtensionParam("picKeys")==null||t.getExtensionParam("picKeys")==null?[]:t.getExtensionParam("picKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"200"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"150"},{type:"select",label:"\u662F\u5426\u81EA\u9002\u5E94",name:"picAutoFlag",required:!1,value:(R=(a=o==null?void 0:o.formInput)==null?void 0:a.picAutoFlag)!=null?R:"1",options:[{label:"\u5426",value:"1"},{label:"\u662F",value:"0"}]},{type:"select",label:"\u662F\u5426\u7F29\u653E\u56FE\u7247",name:"reduceSizeFlag",required:!1,value:(u=(d=o==null?void 0:o.formInput)==null?void 0:d.reduceSizeFlag)!=null?u:"1",options:[{label:"\u5426",value:"1"},{label:"\u662F",value:"0"}]},{type:"select",label:"\u56FE\u7247\u586B\u5145\u914D\u7F6E",name:"picFillType",required:!0,value:(g=(h=o==null?void 0:o.formInput)==null?void 0:h.picFillType)!=null?g:"0",options:[{label:"\u9ED8\u8BA4\u5927\u5C0F",value:"0"},{label:"\u5206\u5272",value:"1"},{label:"\u987A\u5E8F",value:"2"}]},{type:"number",label:"\u884C\u6570",name:"rowNum",required:!1,placeholder:"\u8BF7\u8F93\u5165\u884C\u6570",value:(T=(L=o==null?void 0:o.formInput)==null?void 0:L.rowNum)!=null?T:"1"},{type:"number",label:"\u5217\u6570",name:"colNum",required:!1,placeholder:"\u8BF7\u8F93\u5165\u5217\u6570",value:(P=(O=o==null?void 0:o.formInput)==null?void 0:O.colNum)!=null?P:"1"}],onConfirm:M=>{var b,Y,y,D,H,_,v,J;console.log("payload: ",M);const f=(b=M.find(z=>z.name==="key"))==null?void 0:b.value;if(!f)return;const S=(Y=M.find(z=>z.name==="width"))==null?void 0:Y.value;if(!S)return;const I=(y=M.find(z=>z.name==="height"))==null?void 0:y.value;if(!I)return;const m=((D=M.find(z=>z.name==="picAutoFlag"))==null?void 0:D.value)||"1",N=((H=M.find(z=>z.name==="picFillType"))==null?void 0:H.value)||"0",F="image",Z=t.getExtensionParam("picKeys");if(!Z)return;const W=Z.find(z=>z.value===f),V=W?JSON.stringify(W):"",p=((_=M.find(z=>z.name==="reduceSizeFlag"))==null?void 0:_.value)||"1",X=((v=M.find(z=>z.name==="rowNum"))==null?void 0:v.value)||"1",E=((J=M.find(z=>z.name==="colNum"))==null?void 0:J.value)||"1",C={key:f,width:S,height:I,type:F,picAutoFlag:m,picFillType:N,elemProp:V,reduceSizeFlag:p,rowNum:X,colNum:E},K={value:pi({key:f,width:Number(S),height:Number(I),picAutoFlag:m,picFillType:N}),type:c.ElementType.IMAGE,formInput:C,width:Number(S),height:Number(I)};if(o!=null&&o.id){const z={id:o.id,properties:K};console.log("updateOpt",z),t.command.executeUpdateElementById(z);return}t.command.executeInsertElementList([K])}})}function Zi(o,t){var e,n,i,r,s,l,a,R,d,u;console.log("el",o),new zt({title:"\u7B7E\u5B57\u6846\u914D\u7F6E",data:[{type:"select",label:"\u5143\u7D20\u540D\u79F0",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u9009\u62E9\u5143\u7D20\u540D\u79F0",options:t.getExtensionParam("signPicKeys")==null||t.getExtensionParam("signPicKeys")==null?[]:t.getExtensionParam("signPicKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"200"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"100"},{type:"select",label:"\u662F\u5426\u81EA\u9002\u5E94",name:"picAutoFlag",required:!1,value:(R=(a=o==null?void 0:o.formInput)==null?void 0:a.picAutoFlag)!=null?R:"1",options:[{label:"\u5426",value:"1"},{label:"\u662F",value:"0"}]},{type:"select",label:"\u662F\u5426\u7F29\u653E",name:"reduceSizeFlag",required:!1,value:(u=(d=o==null?void 0:o.formInput)==null?void 0:d.reduceSizeFlag)!=null?u:"1",options:[{label:"\u5426",value:"1"},{label:"\u662F",value:"0"}]}],onConfirm:h=>{var Z,W,V,p,X;console.log("payload: ",h);const g=(Z=h.find(E=>E.name==="key"))==null?void 0:Z.value;if(!g)return;const L=(W=h.find(E=>E.name==="width"))==null?void 0:W.value;if(!L)return;const T=(V=h.find(E=>E.name==="height"))==null?void 0:V.value;if(!T)return;const O=((p=h.find(E=>E.name==="picAutoFlag"))==null?void 0:p.value)||"1",P="signature",f=t.getExtensionParam("signPicKeys").find(E=>E.value===g),S=f?JSON.stringify(f):"",I=((X=h.find(E=>E.name==="reduceSizeFlag"))==null?void 0:X.value)||"1",m={key:g,width:L,height:T,type:P,picAutoFlag:O,elemProp:S,reduceSizeFlag:I},F={value:Fi({key:g,width:Number(L),height:Number(T),picAutoFlag:O}),type:c.ElementType.IMAGE,formInput:m,width:Number(L),height:Number(T)};if(o!=null&&o.id){const E={id:o.id,properties:F};console.log("updateOpt",E),t.command.executeUpdateElementById(E);return}t.command.executeInsertElementList([F])}})}function Ui(o,t){var e,n,i,r,s,l,a,R;console.log("el",o),new zt({title:"\u7B7E\u7AE0\u6846\u914D\u7F6E",data:[{type:"select",label:"\u5143\u7D20\u540D\u79F0",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u9009\u62E9\u5143\u7D20\u540D\u79F0",options:t.getExtensionParam("sealPicKeys")==null||t.getExtensionParam("sealPicKeys")==null?[]:t.getExtensionParam("sealPicKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"200"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"100"},{type:"select",label:"\u662F\u5426\u81EA\u9002\u5E94",name:"picAutoFlag",required:!1,value:(R=(a=o==null?void 0:o.formInput)==null?void 0:a.picAutoFlag)!=null?R:"1",options:[{label:"\u5426",value:"1"},{label:"\u662F",value:"0"}]}],onConfirm:d=>{var m,N,F,Z;console.log("payload: ",d);const u=(m=d.find(W=>W.name==="key"))==null?void 0:m.value;if(!u)return;const h=(N=d.find(W=>W.name==="width"))==null?void 0:N.value;if(!h)return;const g=(F=d.find(W=>W.name==="height"))==null?void 0:F.value;if(!g)return;const L=((Z=d.find(W=>W.name==="picAutoFlag"))==null?void 0:Z.value)||"1",T="seal",P=t.getExtensionParam("sealPicKeys").find(W=>W.value===u),M=P?JSON.stringify(P):"",f={key:u,width:h,height:g,type:T,picAutoFlag:L,elemProp:M},I={value:Wi({key:u,width:Number(h),height:Number(g),picAutoFlag:L}),type:c.ElementType.IMAGE,formInput:f,width:Number(h),height:Number(g)};if(o!=null&&o.id){const W={id:o.id,properties:I};console.log("updateOpt",W),t.command.executeUpdateElementById(W);return}t.command.executeInsertElementList([I])}})}function Ei(o,t){var e,n,i,r,s,l,a,R;console.log("el",o),new zt({title:"\u98CE\u9669\u6284\u5F55\u6846\u914D\u7F6E",data:[{type:"select",label:"\u5143\u7D20\u540D\u79F0",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u9009\u62E9\u5143\u7D20\u540D\u79F0",options:t.getExtensionParam("riskCopyKeys")==null||t.getExtensionParam("riskCopyKeys")==null?[]:t.getExtensionParam("riskCopyKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"200"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"100"},{type:"textarea",label:"\u98CE\u9669\u6284\u5F55\u5185\u5BB9",name:"riskCopyContent",required:!1,placeholder:"\u8BF7\u8F93\u5165\u98CE\u9669\u6284\u5F55\u5185\u5BB9",value:(R=(a=o==null?void 0:o.formInput)==null?void 0:a.riskCopyContent)!=null?R:""}],onConfirm:d=>{var m,N,F,Z;console.log("payload: ",d);const u=(m=d.find(W=>W.name==="key"))==null?void 0:m.value;if(!u)return;const h=(N=d.find(W=>W.name==="width"))==null?void 0:N.value;if(!h)return;const g=(F=d.find(W=>W.name==="height"))==null?void 0:F.value;if(!g)return;const L=((Z=d.find(W=>W.name==="riskCopyContent"))==null?void 0:Z.value)||"",T="riskCopy",P=t.getExtensionParam("riskCopyKeys").find(W=>W.value===u),M=P?JSON.stringify(P):"",f={key:u,width:h,height:g,type:T,riskCopyContent:L,elemProp:M},I={value:Vi({key:u,width:Number(h),height:Number(g),riskCopyContent:L}),type:c.ElementType.IMAGE,formInput:f,width:Number(h),height:Number(g)};if(o!=null&&o.id){const W={id:o.id,properties:I};console.log("updateOpt",W),t.command.executeUpdateElementById(W);return}t.command.executeInsertElementList([I])}})}class Dr{constructor(t){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:n,resizerImageContainer:i,resizerImage:r,resizerSize:s}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=n,this.resizerImageContainer=i,this.resizerImage=r,this.resizerSize=s,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){var d;const{scale:n}=this.options;let i=0,r=0;const s=this.draw.getHeight(),l=this.draw.getPageGap(),R=((d=e==null?void 0:e.pageNo)!=null?d:this.draw.getPageNo())*(s+l);if(t.imgFloatPosition)i=t.imgFloatPosition.x*n,r=t.imgFloatPosition.y*n+R;else if(e){const{coordinate:{leftTop:[u,h]},ascent:g}=e;i=u,r=h+R+g}return{x:i,y:r}}_createResizerDom(){const{scale:t}=this.options,e=document.createElement("div");e.classList.add(`${x}-resizer-selection`),e.style.display="none",e.style.borderColor=this.options.resizerColor,e.style.borderWidth=`${t}px`;const n=[];for(let a=0;a<8;a++){const R=document.createElement("div");R.style.background=this.options.resizerColor,R.classList.add("resizer-handle"),R.classList.add(`handle-${a}`),R.setAttribute("data-index",String(a)),R.onmousedown=this._mousedown.bind(this),e.append(R),n.push(R)}this.container.append(e);const i=document.createElement("div");i.classList.add(`${x}-resizer-size-view`);const r=document.createElement("span");i.append(r),e.append(i);const s=document.createElement("div");s.classList.add(`${x}-resizer-image`),s.style.display="none";const l=document.createElement("img");return s.append(l),this.container.append(s),{resizerSelection:e,resizerHandleList:n,resizerImageContainer:s,resizerImage:l,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 n=t.target;this.curHandleIndex=Number(n.dataset.index);const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,this.canvas.style.cursor=i,console.log(this.curElement),this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{x:r,y:s}=this._getElementPosition(this.curElement,this.curPosition);this.resizerImageContainer.style.left=`${r}px`,this.resizerImageContainer.style.top=`${s}px`,this.resizerImage.style.width=`${this.curElement.width*e}px`,this.resizerImage.style.height=`${this.curElement.height*e}px`;const l=this._mousemove.bind(this);document.addEventListener("mousemove",l),document.addEventListener("mouseup",()=>{var a;this.curElement&&!this.previewerDrawOption.dragDisable&&(this.curElement.width=this.width,this.curElement.height=this.height,this.curElement.formInput&&(this.curElement.formInput.width=`${this.width}`,this.curElement.formInput.height=`${this.height}`,this.curElement.formInput.type=="checkbox"?this.curElementSrc=Si(this.curElement.formInput):this.curElement.formInput.type=="radio"?this.curElementSrc=mi(this.curElement.formInput):this.curElement.formInput.type=="image"?this.curElementSrc=pi(this.curElement.formInput):this.curElement.formInput.type=="signature"?this.curElementSrc=Fi(this.curElement.formInput):this.curElement.formInput.type=="seal"?this.curElementSrc=Wi(this.curElement.formInput):this.curElement.formInput.type=="riskCopy"?this.curElementSrc=Vi(this.curElement.formInput):this.curElementSrc=fi({text:this.curElement.formInput.key,width:this.curElement.formInput.width,height:this.curElement.formInput.height}),this.curElement.value=this.curElementSrc),console.log("this.draw.render"),this.draw.render({isSetCursor:!0,curIndex:(a=this.curPosition)==null?void 0:a.index})),this.resizerImageContainer.style.display="none",document.removeEventListener("mousemove",l),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 n=0,i=0;switch(this.curHandleIndex){case 0:{const R=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 1:i=this.mousedownY-t.y;break;case 2:{const R=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 4:{const R=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const R=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 7:n=this.mousedownX-t.x;break}const r=this.curElement.width+n/e,s=this.curElement.height+i/e;if(r<=0||s<=0)return;this.width=r,this.height=s;const l=r*e,a=s*e;this.resizerImage.style.width=`${l}px`,this.resizerImage.style.height=`${a}px`,this._updateResizerRect(l,a),this._updateResizerSizeView(l,a),t.preventDefault(),this.eventBus.isSubscribe("imageSizeChange")&&this.eventBus.emit("imageSizeChange",{element:this.curElement})}_drawPreviewer(){const t=document.createElement("div");t.classList.add(`${x}-image-previewer`);const e=document.createElement("i");e.classList.add("image-close"),e.onclick=()=>{this._clearPreviewer()},t.append(e);const n=document.createElement("div");n.classList.add(`${x}-image-container`);const i=document.createElement("img");i.src=this.curElementSrc,i.draggable=!1,n.append(i),this.previewerImage=i,t.append(n);let r=0,s=0,l=1,a=0;const R=document.createElement("div");R.classList.add(`${x}-image-menu`);const d=document.createElement("div");d.classList.add("image-navigate");const u=document.createElement("i");u.classList.add("image-pre"),u.onclick=()=>{const m=this.imageList.findIndex(N=>{var F;return N.id===((F=this.curShowElement)==null?void 0:F.id)});m<=0||(this.curShowElement=this.imageList[m-1],i.src=this.curShowElement.value,this._updateImageNavigate())},d.append(u),this.imagePre=u;const h=document.createElement("span");h.classList.add("image-count"),this.imageCount=h,d.append(h);const g=document.createElement("i");g.classList.add("image-next"),g.onclick=()=>{const m=this.imageList.findIndex(N=>{var F;return N.id===((F=this.curShowElement)==null?void 0:F.id)});m>=this.imageList.length-1||(this.curShowElement=this.imageList[m+1],i.src=this.curShowElement.value,this._updateImageNavigate())},this.imageNext=g,d.append(g),R.append(d);const L=document.createElement("i");L.classList.add("zoom-in"),L.onclick=()=>{l+=.1,this._setPreviewerTransform(l,a,r,s)},R.append(L);const T=document.createElement("i");T.onclick=()=>{l-.1<=.1||(l-=.1,this._setPreviewerTransform(l,a,r,s))},T.classList.add("zoom-out"),R.append(T);const O=document.createElement("i");O.classList.add("rotate"),O.onclick=()=>{a+=1,this._setPreviewerTransform(l,a,r,s)},R.append(O);const P=document.createElement("i");P.classList.add("original-size"),P.onclick=()=>{r=0,s=0,l=1,a=0,this._setPreviewerTransform(l,a,r,s)},R.append(P);const M=document.createElement("i");M.classList.add("image-download"),M.onclick=()=>{var N;const{mime:m}=this.previewerDrawOption;Yn(i.src,`${(N=this.curElement)==null?void 0:N.id}.${m||"png"}`)},R.append(M),t.append(R),this.previewerContainer=t,document.body.append(t);let f=0,S=0,I=!1;i.onmousedown=m=>{I=!0,f=m.x,S=m.y,t.style.cursor="move"},t.onmousemove=m=>{!I||(r+=m.x-f,s+=m.y-S,f=m.x,S=m.y,this._setPreviewerTransform(l,a,r,s))},t.onmouseup=()=>{I=!1,t.style.cursor="auto"},t.onwheel=m=>{if(m.preventDefault(),m.stopPropagation(),m.deltaY<0)l+=.1;else{if(l-.1<=.1)return;l-=.1}this._setPreviewerTransform(l,a,r,s)},this._updateImageNavigate()}_updateImageNavigate(){const t=this.imageList.findIndex(e=>{var n;return e.id===((n=this.curShowElement)==null?void 0:n.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,n,i){!this.previewerImage||(this.previewerImage.style.left=`${n}px`,this.previewerImage.style.top=`${i}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:n,scale:i}=this.options,r=this.draw.isReadonly();this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let s=0;s<8;s++){const l=s===0||s===6||s===7?-n:s===1||s===5?t/2:t-n,a=s===0||s===1||s===2?-n:s===3||s===7?e/2-n:e-n;this.resizerHandleList[s].style.transform=`scale(${i})`,this.resizerHandleList[s].style.left=`${l}px`,this.resizerHandleList[s].style.top=`${a}px`,this.resizerHandleList[s].style.display=r?"none":"block"}}_updateResizerSizeView(t,e){this.resizerSize.innerText=`${Math.round(t)} \xD7 ${Math.round(e)}`}render(){var e,n;const t=this.draw.getMode();!this.curElement||this.curElement.imgToolDisabled&&!this.draw.isDesignMode()||t===c.EditorMode.PRINT&&((e=this.options.modeRule[c.EditorMode.PRINT])==null?void 0:e.imagePreviewerDisabled)||t===c.EditorMode.READONLY&&((n=this.options.modeRule[c.EditorMode.READONLY])==null?void 0:n.imagePreviewerDisabled)||(this.imageList=this.draw.getImageParticle().getOriginalMainImageList(),this.curShowElement=this.curElement,this._drawPreviewer(),document.body.style.overflow="hidden")}drawResizer(t,e=null,n={}){var r,s;const i=this.draw.getMode();t.imgToolDisabled&&!this.draw.isDesignMode()||i===c.EditorMode.PRINT&&((r=this.options.modeRule[c.EditorMode.PRINT])==null?void 0:r.imagePreviewerDisabled)||i===c.EditorMode.READONLY&&((s=this.options.modeRule[c.EditorMode.READONLY])==null?void 0:s.imagePreviewerDisabled)||(this.previewerDrawOption=n,this.curElementSrc=t[n.srcKey||"value"]||"",this.updateResizer(t,e),document.addEventListener("keydown",this._keydown))}updateResizer(t,e=null){console.log(t);const{scale:n}=this.options,i=t.width*n,r=t.height*n;this._updateResizerSizeView(i,r);const{x:s,y:l}=this._getElementPosition(t,e);this.resizerSelection.style.left=`${s}px`,this.resizerSelection.style.top=`${l}px`,this.resizerSelection.style.borderWidth=`${n}px`,this._updateResizerRect(i,r),this.resizerSelection.style.display="block",this.curElement=t,this.curPosition=e,this.width=i,this.height=r}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}class Kr{constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.datePicker=new di(t,{onSubmit:this._setValue.bind(this)})}_setValue(t){if(!t)return;const e=this.getDateElementRange();if(!e)return;const[n,i]=e,r=this.draw.getElementList(),s=r[n+1];this.draw.spliceElementList(r,n+1,i-n),this.range.setRange(n,n);const l={type:c.ElementType.DATE,value:"",dateFormat:s.dateFormat,valueList:[{value:t}]};It(r,[l],n,{editorOptions:this.options}),this.draw.insertElementList([l])}getDateElementRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=this.draw.getElementList(),s=r[n];if(s.type!==c.ElementType.DATE)return null;let l=n;for(;l>=0;){if(r[l].dateId!==s.dateId){t=l;break}l--}let a=n+1;for(;a<r.length;){if(r[a].dateId!==s.dateId){e=a-1;break}a++}return a===r.length&&(e=a-1),!~t||!~e?null:[t,e]}clearDatePicker(){this.datePicker.dispose()}renderDatePicker(t,e){const n=this.draw.getElementList(),i=this.getDateElementRange(),r=i?n.slice(i[0]+1,i[1]+1).map(s=>s.value).join(""):"";this.datePicker.render({value:r,position:e,dateFormat:t.dateFormat})}}class Ci{constructor(t){this.element=t,this.videoCache=new Map}snapshot(t,e,n){return new Promise((i,r)=>{var l,a;const s=((a=(l=this.element.block)==null?void 0:l.videoBlock)==null?void 0:a.src)||"";if(this.videoCache.has(s)){const R=this.videoCache.get(s);t.drawImage(R,e,n,this.element.metrics.width,this.element.metrics.height),i(this.element)}else{const R=document.createElement("video");R.src=s,R.muted=!0,R.crossOrigin="anonymous",R.onloadeddata=()=>{t.drawImage(R,e,n,this.element.metrics.width,this.element.metrics.height),this.videoCache.set(s,R),i(this.element)},R.onerror=d=>{r(d)},R.play().then(()=>{R.pause()})}})}render(t){var i;const e=this.element.block,n=document.createElement("video");n.style.width="100%",n.style.height="100%",n.style.objectFit="contain",n.src=((i=e.videoBlock)==null?void 0:i.src)||"",n.controls=!0,t.append(n)}}class yr{constructor(t,e){this.draw=t.getDraw(),this.options=this.draw.getOptions(),this.blockContainer=t.getBlockContainer(),this.element=e,this.block=null;const{blockItem:n,resizerMask:i,resizerSelection:r,resizerHandleList:s}=this._createBlockItem();this.blockItem=n,this.blockContainer.append(this.blockItem),this.blockCache=new Map,this.resizerMask=i,this.resizerSelection=r,this.resizerHandleList=s,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.isAllowResize=!1}getBlockElement(){return this.element}getBlockWidth(){return this.element.width||this.element.metrics.width}_createBlockItem(){const{scale:t,resizerColor:e}=this.options,n=document.createElement("div");n.classList.add(`${x}-block-item`);const i=document.createElement("div");i.style.display="none",i.classList.add(`${x}-resizer-selection`),i.style.borderColor=e,i.style.borderWidth=`${t}px`;const r=[];for(let l=0;l<8;l++){const a=document.createElement("div");a.style.background=e,a.classList.add("resizer-handle"),a.classList.add(`handle-${l}`),a.setAttribute("data-index",String(l)),a.onmousedown=this._mousedown.bind(this),i.append(a),r.push(a)}const s=document.createElement("div");return s.classList.add(`${x}-resizer-mask`),s.style.display="none",n.append(s),n.onmouseenter=()=>{if(this.draw.isReadonly())return;const{width:a,height:R}=this.element.metrics;this._updateResizerRect(a,R),i.style.display="block"},n.onmouseleave=()=>{this.isAllowResize||(i.style.display="none")},n.append(i),{blockItem:n,resizerMask:s,resizerSelection:i,resizerHandleList:r}}_updateResizerRect(t,e){const{resizerSize:n,scale:i}=this.options;this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let r=0;r<8;r++){const s=r===0||r===6||r===7?-n:r===1||r===5?t/2:t-n,l=r===0||r===1||r===2?-n:r===3||r===7?e/2-n:e-n;this.resizerHandleList[r].style.transform=`scale(${i})`,this.resizerHandleList[r].style.left=`${s}px`,this.resizerHandleList[r].style.top=`${l}px`}}_mousedown(t){const e=this.draw.getPage();this.mousedownX=t.x,this.mousedownY=t.y,this.isAllowResize=!0;const n=t.target;this.curHandleIndex=Number(n.dataset.index),this.resizerMask.style.display="block";const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,e.style.cursor=i;const r=this._mousemove.bind(this);document.addEventListener("mousemove",r),document.addEventListener("mouseup",()=>{this.element.width=Math.min(this.width,this.draw.getInnerWidth()),this.element.height=this.height,this.isAllowResize=!1,this.resizerSelection.style.display="none",this.resizerMask.style.display="none",document.removeEventListener("mousemove",r),document.body.style.cursor="",e.style.cursor="text",this.draw.render()},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.isAllowResize)return;const{scale:e}=this.options;let n=0,i=0;switch(this.curHandleIndex){case 0:{const R=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 1:i=this.mousedownY-t.y;break;case 2:{const R=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 4:{const R=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const R=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 7:n=this.mousedownX-t.x;break}const r=this.getBlockWidth()+n/e,s=this.element.height+i/e;if(r<=0||s<=0)return;this.width=r,this.height=s;const l=r*e,a=s*e;this._updateResizerRect(l,a),this.blockItem.style.width=`${l}px`,this.blockItem.style.height=`${a}px`,t.preventDefault()}snapshot(t,e,n){if(this.element.block.type===c.BlockType.VIDEO)if(this.blockItem.style.display="none",this.blockCache.has(this.element.id))this.blockCache.get(this.element.id).snapshot(t,e,n);else{this.block=new Ci(this.element);const r=this.block.snapshot(t,e,n);this.draw.getImageObserver().add(r),this.blockCache.set(this.element.id,this.block)}}render(){const t=this.element.block;t.type===c.BlockType.IFRAME?(this.block=new Pe(this.element),this.block.render(this.blockItem)):t.type===c.BlockType.VIDEO&&(this.block=new Ci(this.element),this.block.render(this.blockItem))}setClientRects(t,e,n){const i=this.draw.getHeight(),r=this.draw.getPageGap(),s=t*(i+r),{metrics:l}=this.element;this.blockItem.style.display="block",this.blockItem.style.width=`${l.width}px`,this.blockItem.style.height=`${l.height}px`,this.blockItem.style.left=`${e}px`,this.blockItem.style.top=`${s+n}px`}remove(){this.blockItem.remove()}}class wr{constructor(t){this.draw=t,this.container=t.getContainer(),this.blockMap=new Map,this.blockContainer=this._createBlockContainer(),this.container.append(this.blockContainer)}_createBlockContainer(){const t=document.createElement("div");return t.classList.add(`${x}-block-container`),t}getDraw(){return this.draw}getBlockContainer(){return this.blockContainer}render(t,e,n,i,r){const s=n.id;let l=this.blockMap.get(s);l||(l=new yr(this,n),l.render(),this.blockMap.set(s,l)),this.draw.isPrintMode()?l.snapshot(t,i,r):l.setClientRects(e,i,r)}clear(){if(!this.blockMap.size)return;const t=this.draw.getOriginalMainElementList(),e=[];for(let n=0;n<t.length;n++){const i=t[n];i.type===c.ElementType.BLOCK&&e.push(i.id)}this.blockMap.forEach(n=>{const i=n.getBlockElement().id;e.includes(i)||(n.remove(),this.blockMap.delete(i))})}}var In={contextmenu:{global:{cut:"\u526A\u5207",copy:"\u590D\u5236",paste:"\u7C98\u8D34",selectAll:"\u5168\u9009",print:"\u6253\u5370"},control:{delete:"\u5220\u9664\u63A7\u4EF6"},hyperlink:{delete:"\u5220\u9664\u94FE\u63A5",cancel:"\u53D6\u6D88\u94FE\u63A5",edit:"\u7F16\u8F91\u94FE\u63A5"},image:{change:"\u66F4\u6539\u56FE\u7247",saveAs:"\u53E6\u5B58\u4E3A\u56FE\u7247",textWrap:"\u6587\u5B57\u73AF\u7ED5",textWrapType:{embed:"\u5D4C\u5165\u578B",upDown:"\u4E0A\u4E0B\u578B\u73AF\u7ED5",surround:"\u56DB\u5468\u578B\u73AF\u7ED5",floatTop:"\u6D6E\u4E8E\u6587\u5B57\u4E0A\u65B9",floatBottom:"\u886C\u4E8E\u6587\u5B57\u4E0B\u65B9"}},table:{insertRowCol:"\u63D2\u5165\u884C\u5217",insertTopRow:"\u4E0A\u65B9\u63D2\u51651\u884C",insertBottomRow:"\u4E0B\u65B9\u63D2\u51651\u884C",insertLeftCol:"\u5DE6\u4FA7\u63D2\u51651\u5217",insertRightCol:"\u53F3\u4FA7\u63D2\u51651\u5217",deleteRowCol:"\u5220\u9664\u884C\u5217",deleteRow:"\u5220\u96641\u884C",deleteCol:"\u5220\u96641\u5217",deleteTable:"\u5220\u9664\u6574\u4E2A\u8868\u683C",mergeCell:"\u5408\u5E76\u5355\u5143\u683C",mergeCancelCell:"\u53D6\u6D88\u5408\u5E76",verticalAlign:"\u5782\u76F4\u5BF9\u9F50",verticalAlignTop:"\u9876\u7AEF\u5BF9\u9F50",verticalAlignMiddle:"\u5782\u76F4\u5C45\u4E2D",verticalAlignBottom:"\u5E95\u7AEF\u5BF9\u9F50",border:"\u8868\u683C\u8FB9\u6846",borderAll:"\u6240\u6709\u6846\u7EBF",borderEmpty:"\u65E0\u6846\u7EBF",borderDash:"\u865A\u6846\u7EBF",borderExternal:"\u5916\u4FA7\u6846\u7EBF",borderInternal:"\u5185\u4FA7\u6846\u7EBF",borderTd:"\u5355\u5143\u683C\u8FB9\u6846",borderTdTop:"\u4E0A\u8FB9\u6846",borderTdRight:"\u53F3\u8FB9\u6846",borderTdBottom:"\u4E0B\u8FB9\u6846",borderTdLeft:"\u5DE6\u8FB9\u6846",borderTdForward:"\u6B63\u659C\u7EBF",borderTdBack:"\u53CD\u659C\u7EBF"}},datePicker:{now:"\u6B64\u523B",confirm:"\u786E\u5B9A",return:"\u8FD4\u56DE\u65E5\u671F",timeSelect:"\u65F6\u95F4\u9009\u62E9",weeks:{sun:"\u65E5",mon:"\u4E00",tue:"\u4E8C",wed:"\u4E09",thu:"\u56DB",fri:"\u4E94",sat:"\u516D"},year:"\u5E74",month:"\u6708",hour:"\u65F6",minute:"\u5206",second:"\u79D2"},frame:{header:"\u9875\u7709",footer:"\u9875\u811A"},pageBreak:{displayName:"\u5206\u9875\u7B26"},zone:{headerTip:"\u53CC\u51FB\u7F16\u8F91\u9875\u7709",footerTip:"\u53CC\u51FB\u7F16\u8F91\u9875\u811A"}},Hr={contextmenu:{global:{cut:"Cut",copy:"Copy",paste:"Paste",selectAll:"Select all",print:"Print"},control:{delete:"Delete control"},hyperlink:{delete:"Delete hyperlink",cancel:"Cancel hyperlink",edit:"Edit hyperlink"},image:{change:"Change image",saveAs:"Save as image",textWrap:"Text wrap",textWrapType:{embed:"Embed",upDown:"Up down",surround:"Surround",floatTop:"Float above text",floatBottom:"Float below text"}},table:{insertRowCol:"Insert row col",insertTopRow:"Insert top 1 row",insertBottomRow:"Insert bottom 1 row",insertLeftCol:"Insert left 1 col",insertRightCol:"Insert right 1 col",deleteRowCol:"Delete row col",deleteRow:"Delete 1 row",deleteCol:"Delete 1 col",deleteTable:"Delete table",mergeCell:"Merge cell",mergeCancelCell:"Cancel merge cell",verticalAlign:"Vertical align",verticalAlignTop:"Top",verticalAlignMiddle:"Middle",verticalAlignBottom:"Bottom",border:"Table border",borderAll:"All",borderEmpty:"Empty",borderDash:"Dash",borderExternal:"External",borderInternal:"Internal",borderTd:"Table cell border",borderTdTop:"Top",borderTdRight:"Right",borderTdBottom:"Bottom",borderTdLeft:"Left",borderTdForward:"Forward",borderTdBack:"Back"}},datePicker:{now:"Now",confirm:"Confirm",return:"Return",timeSelect:"Time select",weeks:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},year:" ",month:" ",hour:"Hour",minute:"Minute",second:"Second"},frame:{header:"Header",footer:"Footer"},pageBreak:{displayName:"Page Break"},zone:{headerTip:"Double click to edit header",footerTip:"Double click to edit footer"}};class Gr{constructor(t){this.langMap=new Map([["zhCN",In],["en",Hr]]),this.currentLocale=t}registerLangMap(t,e){const n=this.langMap.get(t);this.langMap.set(t,Zn(n||In,e))}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale=t}getLang(){return this.langMap.get(this.currentLocale)||In}t(t){const e=t.split(".");let n="",i=this.getLang();for(let r=0;r<e.length;r++){const s=e[r],l=Reflect.get(i,s);if(l)n=i=l;else return""}return n}}class xr{constructor(){this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class Jr{constructor(t,e){this.draw=t,this.zone=e,this.i18n=t.getI18n(),this.container=t.getContainer(),this.pageContainer=t.getPageContainer();const{tipContainer:n,tipContent:i}=this._drawZoneTip();this.tipContainer=n,this.tipContent=i,this.isDisableMouseMove=!0,this.currentMoveZone=c.EditorZone.MAIN;const r=[],{header:s,footer:l}=t.getOptions();s.disabled||r.push(c.EditorZone.HEADER),l.disabled||r.push(c.EditorZone.FOOTER),r.length&&this._watchMouseMoveZoneChange(r)}_watchMouseMoveZoneChange(t){this.pageContainer.addEventListener("mousemove",oo(e=>{if(!(this.isDisableMouseMove||!this.draw.getIsPagingMode())&&!!e.offsetY)if(e.target instanceof HTMLCanvasElement){const n=this.zone.getZoneByY(e.offsetY);if(!t.includes(n)){this._updateZoneTip(!1);return}this.currentMoveZone=n,this._updateZoneTip(this.zone.getZone()===c.EditorZone.MAIN&&(n===c.EditorZone.HEADER||n===c.EditorZone.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(`${x}-zone-tip`);const e=document.createElement("span");return t.append(e),this.container.append(t),{tipContainer:t,tipContent:e}}_updateZoneTip(t,e,n){t?(this.tipContainer.classList.add("show"),this.tipContainer.style.left=`${e}px`,this.tipContainer.style.top=`${n}px`,this.tipContent.innerText=this.i18n.t(`zone.${this.currentMoveZone===c.EditorZone.HEADER?"headerTip":"footerTip"}`)):this.tipContainer.classList.remove("show")}}class vr{constructor(t){this.INDICATOR_PADDING=2,this.INDICATOR_TITLE_TRANSLATE=[20,5],this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=c.EditorZone.MAIN,this.indicatorContainer=null,this.options.zone.tipDisabled||new Jr(t,this)}isHeaderActive(){return this.getZone()===c.EditorZone.HEADER}isMainActive(){return this.getZone()===c.EditorZone.MAIN}isFooterActive(){return this.getZone()===c.EditorZone.FOOTER}getZone(){return this.currentZone}setZone(t){const{header:e,footer:n}=this.options;!e.editable&&t===c.EditorZone.HEADER||!n.editable&&t===c.EditorZone.FOOTER||this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),$e(()=>{const i=this.draw.getListener();i.zoneChange&&i.zoneChange(t);const r=this.draw.getEventBus();r.isSubscribe("zoneChange")&&r.emit("zoneChange",t)}))}getZoneByY(t){const e=this.draw.getHeader(),n=e.getHeaderTop()+e.getHeight(),i=this.draw.getFooter(),s=this.draw.getHeight()-(i.getFooterBottom()+i.getHeight());return t<n?c.EditorZone.HEADER:t>s?c.EditorZone.FOOTER:c.EditorZone.MAIN}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),[n,i]=this.INDICATOR_TITLE_TRANSLATE,r=this.draw.getPageList(),s=this.draw.getMargins(),l=this.draw.getInnerWidth(),a=this.draw.getHeight(),R=this.draw.getPageGap(),d=a+R;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${x}-zone-indicator`);const u=this.draw.getHeader(),h=this.draw.getFooter(),g=e?u.getHeight():h.getHeight(),L=e?u.getHeaderTop():a-h.getFooterBottom()-g;for(let T=0;T<r.length;T++){const O=d*T+L,P=s[3]-this.INDICATOR_PADDING,M=s[3]+l+this.INDICATOR_PADDING,f=e?O-this.INDICATOR_PADDING:O+g+this.INDICATOR_PADDING,S=e?O+g+this.INDICATOR_PADDING:O-this.INDICATOR_PADDING,I=document.createElement("div");I.innerText=this.i18n.t(`frame.${e?"header":"footer"}`),I.style.top=`${S}px`,I.style.transform=`translate(${n*t}px, ${i*t}px) scale(${t})`,this.indicatorContainer.append(I);const m=document.createElement("span");m.classList.add(`${x}-zone-indicator-border__top`),m.style.top=`${f}px`,m.style.width=`${l}px`,m.style.marginLeft=`${s[3]}px`,this.indicatorContainer.append(m);const N=document.createElement("span");N.classList.add(`${x}-zone-indicator-border__left`),N.style.top=`${O}px`,N.style.height=`${g}px`,N.style.left=`${P}px`,this.indicatorContainer.append(N);const F=document.createElement("span");F.classList.add(`${x}-zone-indicator-border__bottom`),F.style.top=`${S}px`,this.indicatorContainer.append(F);const Z=document.createElement("span");Z.classList.add(`${x}-zone-indicator-border__right`),Z.style.top=`${O}px`,Z.style.height=`${g}px`,Z.style.left=`${M}px`,this.indicatorContainer.append(Z)}this.container.append(this.indicatorContainer)}_clearZoneIndicator(){var t;(t=this.indicatorContainer)==null||t.remove(),this.indicatorContainer=null}}class Ar{constructor(t,e){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(),i=this.draw.getMargins()[3],r=this.draw.getHeight(),s=this.getHeight(),l=r-t-s;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:l,innerWidth:e,zone:c.EditorZone.FOOTER})}getFooterBottom(){const{footer:{bottom:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{footer:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*Wn[t])}getHeight(){if(this.options.footer.disabled)return 0;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(),i=this.getFooterBottom()+e-t[2];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isFooterActive()?1:this.options.footer.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),r=[];let s=0;for(let l=0;l<this.rowList.length;l++){const a=this.rowList[l];if(s+a.height>i)break;r.push(a),s+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:r,pageNo:e,startIndex:0,innerWidth:n,zone:c.EditorZone.FOOTER}),t.restore()}}class Br{constructor(t){this.UN_COUNT_STYLE_WIDTH=20,this.MEASURE_BASE_TEXT="0",this.LIST_GAP=10,this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}setList(t,e){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:r}=this.range.getRange();if(!~i&&!~r)return;const s=this.range.getRangeParagraphElementList();if(!s||!s.length)return;if(s.find(u=>u.listType===t&&u.listStyle===e)||!t){this.unsetList();return}const a=q();s.forEach(u=>{u.listId=a,u.listType=t,u.listStyle=e});const R=i===r,d=R?r:i;this.draw.render({curIndex:d,isSetCursor:R})}unsetList(){var R;if(this.draw.isReadonly())return;const{startIndex:e,endIndex:n}=this.range.getRange();if(!~e&&!~n)return;const i=(R=this.range.getRangeParagraphElementList())==null?void 0:R.filter(d=>d.listId);if(!i||!i.length)return;const r=this.draw.getElementList(),s=r[n];if(s.listId){let d=n+1;for(;d<r.length;){const u=r[d];if(u.value===w&&!u.listWrap)break;if(u.listId!==s.listId){this.draw.spliceElementList(r,d,0,[{value:w}]);break}d++}}i.forEach(d=>{delete d.listId,delete d.listType,delete d.listStyle,delete d.listWrap});const l=e===n,a=l?n:e;this.draw.render({curIndex:a,isSetCursor:l})}computeListStyle(t,e){const n=new Map;let i=0,r=e[i].listId,s=[];const l=e.length;for(;i<l;){const a=e[i];if(r&&r===a.listId)s.push(a);else if(a.listId&&a.listId!==r){if(s.length){const R=this.getListStyleWidth(t,s);n.set(r,R)}r=a.listId,s=r?[a]:[]}i++}if(s.length){const a=this.getListStyleWidth(t,s);n.set(r,a)}return n}findStyledElement(t){let e=t[0];for(let n=1;n<t.length;n++){const i=t[n];if(i.font||i.size||i.bold||i.italic){e=i;break}}return e}getListFontStyle(t,e){if(this.options.list.inheritStyle){const n=this.findStyledElement(t);return this.draw.getElementFont(n,e)}else{const{defaultFont:n,defaultSize:i}=this.options;return`${i*e}px ${n}`}}getListStyleWidth(t,e){const{scale:n,checkbox:i}=this.options,r=e[0];if(r.listStyle&&r.listStyle!==c.ListStyle.DECIMAL)return r.listStyle===c.ListStyle.CHECKBOX?(i.width+this.LIST_GAP)*n:this.UN_COUNT_STYLE_WIDTH*n;const s=e.reduce((R,d)=>(d.value===w&&(R+=1),R),0);if(!s)return 0;t.save(),t.font=this.getListFontStyle(e,n);const l=`${this.MEASURE_BASE_TEXT.repeat(String(s).length)}${c.KeyMap.PERIOD}`,a=t.measureText(l);return t.restore(),Math.ceil((a.width+this.LIST_GAP)*n)}drawListStyle(t,e,n){var O;const{elementList:i,offsetX:r,listIndex:s,ascent:l}=e,a=i[0];if(a.value!==w||a.listWrap)return;let R=0;const{defaultTabWidth:d,scale:u}=this.options;for(let P=1;P<i.length;P++){const M=i[P];if((M==null?void 0:M.type)!==c.ElementType.TAB)break;R+=d*u}const{coordinate:{leftTop:[h,g]}}=n,L=h-r+R,T=g+l;if(a.listStyle===c.ListStyle.CHECKBOX){const{width:P,height:M,gap:f}=this.options.checkbox,S={...a,checkbox:{value:!!((O=a.checkbox)!=null&&O.value)},metrics:{...a.metrics,width:(P+f*2)*u,height:M*u}};this.draw.getCheckboxParticle().render({ctx:t,x:L-f*u,y:T,index:0,row:{...e,elementList:[S,...e.elementList]}})}else{let P="";if(a.listType===c.ListType.UL?P=sn[a.listStyle]||sn[ee.DISC]:P=`${s+1}${c.KeyMap.PERIOD}`,!P)return;t.save(),t.font=this.getListFontStyle(i,u),t.fillText(P,L,T),t.restore()}}}const Qi=class{constructor(o){this.options=o.getOptions()}render(o,t,e,n){const{scale:i,lineBreak:{color:r,lineWidth:s}}=this.options;o.save(),o.beginPath();const l=n-Qi.HEIGHT*i/2,a=e+t.metrics.width;o.translate(a,l),o.scale(i,i),o.strokeStyle=r,o.lineWidth=s,o.lineCap="round",o.lineJoin="round",o.beginPath(),o.moveTo(8,0),o.lineTo(12,0),o.lineTo(12,6),o.lineTo(3,6),o.moveTo(3,6),o.lineTo(6,3),o.moveTo(3,6),o.lineTo(6,9),o.stroke(),o.closePath(),o.restore()}};let ue=Qi;ue.WIDTH=12,ue.HEIGHT=9,ue.GAP=3;class bi{constructor(t){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:n}=this.options,i=this.draw.getHeader().getExtraHeight(),r=this.draw.getInnerWidth(),s=this.draw.getMargins();let l=s[3];e.disabled||(l+=(ue.WIDTH+ue.GAP)*n);const a=(t==null?void 0:t.startY)||s[0]+i;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:l,startY:a,innerWidth:r})}render(t,e){const{placeholder:n=this.options.placeholder}=e||{},{data:i,font:r,size:s,color:l,opacity:a}=n;this._recovery(),this.elementList=[{value:i,font:r,size:s,color:l}],Mt(this.elementList,{editorOptions:this.options,isForceCompensation:!0}),this._compute(e);const R=this.draw.getInnerWidth();t.save(),t.globalAlpha=a,this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:this.rowList,pageNo:0,startIndex:0,innerWidth:R,isDrawLineBreak:!1}),t.restore()}}class kr{constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==c.EditorZone.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=q();return t.forEach(n=>{Array.isArray(n.groupIds)||(n.groupIds=[]),n.groupIds.push(e)}),this.draw.render({isSetCursor:!1,isCompute:!1}),e}getElementListByGroupId(t,e){var i,r;const n=[];for(let s=0;s<t.length;s++){const l=t[s];if(l.type===c.ElementType.TABLE){const a=l.trList;for(let R=0;R<a.length;R++){const d=a[R];for(let u=0;u<d.tdList.length;u++){const h=d.tdList[u],g=this.getElementListByGroupId(h.value,e);if(g.length)return n.push(...g),n}}}if((i=l==null?void 0:l.groupIds)!=null&&i.includes(e)){n.push(l);const a=t[s+1];if(!((r=a==null?void 0:a.groupIds)!=null&&r.includes(e)))break}}return n}deleteGroup(t){if(this.draw.isReadonly())return;const e=this.draw.getOriginalMainElementList(),n=this.getElementListByGroupId(e,t);if(!!n.length){for(let i=0;i<n.length;i++){const r=n[i],s=r.groupIds,l=s.findIndex(a=>a===t);s.splice(l,1),s.length||delete r.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){var n,i;for(let r=0;r<t.length;r++){const s=t[r];if(s.type===c.ElementType.TABLE){const a=s.trList;for(let R=0;R<a.length;R++){const d=a[R];for(let u=0;u<d.tdList.length;u++){const h=d.tdList[u],g=this.getContextByGroupId(h.value,e);if(g)return{...g,isTable:!0,index:r,trIndex:R,tdIndex:u,tdId:h.id,trId:d.id,tableId:s.tableId}}}}const l=t[r+1];if(((n=s.groupIds)==null?void 0:n.includes(e))&&!((i=l==null?void 0:l.groupIds)!=null&&i.includes(e)))return{isTable:!1,startIndex:r,endIndex:r}}return null}clearFillInfo(){this.fillRectMap.clear()}recordFillInfo(t,e,n,i,r){const s=t.groupIds;if(!!s)for(const l of s){const a=this.fillRectMap.get(l);a?a.width+=i:this.fillRectMap.set(l,{x:e,y:n,width:i,height:r})}}render(t){var R;if(!this.fillRectMap.size)return;const e=this.range.getRange(),i=(R=this.draw.getElementList()[e.endIndex])==null?void 0:R.groupIds,{group:{backgroundColor:r,opacity:s,activeOpacity:l,activeBackgroundColor:a}}=this.options;t.save(),this.fillRectMap.forEach((d,u)=>{const{x:h,y:g,width:L,height:T}=d;i!=null&&i.includes(u)?(t.globalAlpha=l,t.fillStyle=a):(t.globalAlpha=s,t.fillStyle=r),t.fillRect(h,g,L,T)}),t.restore(),this.clearFillInfo()}}class _r{constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:r,whiteSpace:{color:s,radius:l}}=this.options,a=e.metrics;t.save(),t.fillStyle=s,t.beginPath(),t.arc(n+a.width/2,i,l*r,0,Math.PI*2),t.fill(),t.closePath(),t.restore()}}class zr{constructor(t){this.draw=t,this.eventBus=this.draw.getEventBus(),this.pageContainer=this.draw.getPageContainer(),this.pageContainer.addEventListener("mousemove",this._mousemove.bind(this)),this.pageContainer.addEventListener("mouseenter",this._mouseenter.bind(this)),this.pageContainer.addEventListener("mouseleave",this._mouseleave.bind(this)),this.pageContainer.addEventListener("mousedown",this._mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this._mouseup.bind(this)),this.pageContainer.addEventListener("click",this._click.bind(this))}_mousemove(t){!this.eventBus.isSubscribe("mousemove")||this.eventBus.emit("mousemove",t)}_mouseenter(t){!this.eventBus.isSubscribe("mouseenter")||this.eventBus.emit("mouseenter",t)}_mouseleave(t){!this.eventBus.isSubscribe("mouseleave")||this.eventBus.emit("mouseleave",t)}_mousedown(t){!this.eventBus.isSubscribe("mousedown")||this.eventBus.emit("mousedown",t)}_mouseup(t){!this.eventBus.isSubscribe("mouseup")||this.eventBus.emit("mouseup",t)}_click(t){!this.eventBus.isSubscribe("click")||this.eventBus.emit("click",t)}}class $r{constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:n,lineNumber:{color:i,size:r,font:s,right:l,type:a}}=this.options,R=this.draw.getTextParticle(),d=this.draw.getMargins(),u=this.draw.getPosition().getOriginalMainPositionList(),g=this.draw.getPageRowList()[e];t.save(),t.fillStyle=i,t.font=`${r*n}px ${s}`;for(let L=0;L<g.length;L++){const T=g[L],{coordinate:{leftBottom:O}}=u[T.startIndex],P=a===c.LineNumberType.PAGE?L+1:T.rowIndex+1,M=R.measureText(t,{value:`${P}`}),f=d[3]-(M.width+l)*n,S=O[1]-M.actualBoundingBoxAscent*n;t.fillText(`${P}`,f,S)}t.restore()}}class jr{constructor(t){this.draw=t,this.header=t.getHeader(),this.footer=t.getFooter(),this.options=t.getOptions()}render(t){const{scale:e,pageBorder:{color:n,lineWidth:i,padding:r}}=this.options;t.save(),t.translate(.5,.5),t.strokeStyle=n,t.lineWidth=i*e;const s=this.draw.getMargins(),l=s[3]-r[3]*e,a=s[0]+this.header.getExtraHeight()-r[0]*e,R=this.draw.getInnerWidth()+(r[1]+r[3])*e,d=this.draw.getHeight()-a-this.footer.getExtraHeight()-s[2]+r[2]*e;t.rect(l,a,R,d),t.stroke(),t.restore()}}function qr(o,t){const{value:e,oldValue:n}=t;n.isTable&&!e.isTable&&o.getTableTool().dispose()}class tl{constructor(t){this.draw=t,this.eventBus=t.getEventBus(),this.execute()}execute(){this.eventBus.on("positionContextChange",t=>{qr(this.draw,t)})}}class el{constructor(t){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 L;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{defaultTrMinHeight:r}=this.options.table,s=this.draw.getElementList();let l=0;if((L=s[n])!=null&&L.listId){const T=this.position.getPositionList(),{rowIndex:O}=T[n],M=this.draw.getRowList()[O];l=(M==null?void 0:M.offsetX)||0}const a=this.draw.getContextInnerWidth()-l,R=[],d=a/e;for(let T=0;T<e;T++)R.push({width:d});const u=[];for(let T=0;T<t;T++){const O=[],P={height:r,tdList:O};for(let M=0;M<e;M++)O.push({colspan:1,rowspan:1,value:[]});u.push(P)}const h={type:c.ElementType.TABLE,value:"",colgroup:R,trList:u};Mt([h],{editorOptions:this.options}),It(s,[h],n,{editorOptions:this.options});const g=n+1;this.draw.spliceElementList(s,g,n===i?0:i-n,[h]),this.range.setRange(g,g),this.draw.render({curIndex:g,isSetCursor:!1})}insertTableTopRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tableId:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=l[n];if(a.tdList.length<s.colgroup.length){const u=a.tdList[0].rowIndex;for(let h=0;h<n;h++){const g=l[h];for(let L=0;L<g.tdList.length;L++){const T=g.tdList[L];T.rowspan>1&&T.rowIndex+T.rowspan>=u+1&&(T.rowspan+=1)}}}const R=q(),d={height:a.height,id:R,tdList:[]};for(let u=0;u<a.tdList.length;u++){const h=a.tdList[u],g=q();d.tdList.push({id:g,rowspan:1,colspan:h.colspan,value:[{value:w,size:16,tableId:i,trId:R,tdId:g}]})}l.splice(n,0,d),this.position.setPositionContext({isTable:!0,index:e,trIndex:n,tdIndex:0,tdId:d.tdList[0].id,trId:d.id,tableId:i}),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:n,tableId:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=l[n],R=l.length-1===n?a:l[n+1];if(R.tdList.length<s.colgroup.length){const h=R.tdList[0].rowIndex;for(let g=0;g<n+1;g++){const L=l[g];for(let T=0;T<L.tdList.length;T++){const O=L.tdList[T];O.rowspan>1&&O.rowIndex+O.rowspan>=h+1&&(O.rowspan+=1)}}}const d=q(),u={height:R.height,id:d,tdList:[]};for(let h=0;h<R.tdList.length;h++){const g=R.tdList[h],L=q();u.tdList.push({id:L,rowspan:1,colspan:g.colspan,value:[{value:w,size:16,tableId:i,trId:d,tdId:L}]})}l.splice(n+1,0,u),this.position.setPositionContext({isTable:!0,index:e,trIndex:n+1,tdIndex:0,tdId:u.tdList[0].id,trId:u.id,tableId:s.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}adjustColWidth(t){if(t.type!==c.ElementType.TABLE)return;const{defaultColMinWidth:e}=this.options.table,n=t.colgroup,i=n.reduce((s,l)=>s+l.width,0),r=this.draw.getOriginalInnerWidth();if(i>r){const s=n.filter(a=>a.width>e),l=(i-r)/s.length;for(let a=0;a<n.length;a++){const R=n[a];R.width-l>=e&&(R.width-=l)}}}insertTableLeftCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=n;for(let u=0;u<l.length;u++){const h=l[u],g=q();h.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:w,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:R}=this.options.table;s.colgroup.splice(a,0,{width:R}),this.adjustColWidth(s),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:i}),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:n,tableId:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=n+1;for(let u=0;u<l.length;u++){const h=l[u],g=q();h.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:w,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:R}=this.options.table;s.colgroup.splice(a,0,{width:R}),this.adjustColWidth(s),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:s.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:n,tdIndex:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=l[n],R=a.tdList[i].rowIndex;if(l.length<=1&&s.pagingIndex===0){this.deleteTable();return}for(let d=0;d<R;d++){const h=l[d].tdList;for(let g=0;g<h.length;g++){const L=h[g];L.rowIndex+L.rowspan>R&&L.rowspan--}}for(let d=0;d<a.tdList.length;d++){const u=a.tdList[d];if(u.rowspan>1){const h=q(),g=l[n+1];g.tdList.splice(d,0,{id:h,rowspan:u.rowspan-1,colspan:u.colspan,value:[{value:w,size:16,tableId:s.id,trId:g.id,tdId:h}]})}}l.splice(n,1),this.position.setPositionContext({isTable:!1}),this.range.clearRange(),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTableCol(){var u;const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,R=l[i].tdList[n].colIndex;if(!l.find(h=>h.tdList.length>1)){this.deleteTable();return}for(let h=0;h<l.length;h++){const g=l[h];for(let L=0;L<g.tdList.length;L++){const T=g.tdList[L];T.colIndex<=R&&T.colIndex+T.colspan>R&&(T.colspan>1?T.colspan--:g.tdList.splice(L,1))}}(u=s.colgroup)==null||u.splice(R,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(),n=e[t.index];let i=1,r=t.index;if(n.pagingId){r=t.index-n.pagingIndex;for(let l=r+1;l<e.length&&e[l].pagingId===n.pagingId;l++)i++}e.splice(r,i);const s=r-1;this.position.setPositionContext({isTable:!1,index:s}),this.range.setRange(s,s),this.draw.render({curIndex:s}),this.tableTool.dispose()}mergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{isCrossRowCol:e,startTdIndex:n,endTdIndex:i,startTrIndex:r,endTrIndex:s}=this.range.getRange();if(!e)return;const{index:l}=t,d=this.draw.getOriginalElementList()[l].trList;let u=d[r].tdList[n],h=d[s].tdList[i];(u.x>h.x||u.y>h.y)&&([u,h]=[h,u]);const g=u.colIndex,L=h.colIndex+(h.colspan-1),T=u.rowIndex,O=h.rowIndex+(h.rowspan-1),P=[];for(let X=0;X<d.length;X++){const E=d[X],C=[];for(let U=0;U<E.tdList.length;U++){const K=E.tdList[U],b=K.colIndex,Y=K.rowIndex;b>=g&&b<=L&&Y>=T&&Y<=O&&C.push(K)}C.length&&P.push(C)}if(!P.length)return;const M=P[P.length-1],f=P[0][0],S=M[M.length-1],I=f.x,m=f.y,N=S.x+S.width,F=S.y+S.height;for(let X=0;X<P.length;X++){const E=P[X];for(let C=0;C<E.length;C++){const U=E[C],K=U.x,b=U.y,Y=K+U.width,y=b+U.height;if(I>K||m>b||N<Y||F<y)return}}const Z=[],W=P[0][0],V=W.value[0];for(let X=0;X<P.length;X++){const E=P[X];for(let C=0;C<E.length;C++){const U=E[C];if(!(X===0&&C===0)){Z.push(U.id);const b=U.value.length>1?0:1;for(let Y=b;Y<U.value.length;Y++){const y=U.value[Y];jt(Te,V,y),W.value.push(y)}}X===0&&C!==0&&(W.colspan+=U.colspan),X!==0&&W.colIndex===U.colIndex&&(W.rowspan+=U.rowspan)}}for(let X=0;X<d.length;X++){const E=d[X];let C=0;for(;C<E.tdList.length;){const U=E.tdList[C];Z.includes(U.id)&&(E.tdList.splice(C,1),C--),C++}}this.position.setPositionContext({...t,trIndex:W.trIndex,tdIndex:W.tdIndex});const p=W.value.length-1;this.range.setRange(p,p),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=l[i],R=a.tdList[n];if(R.rowspan===1&&R.colspan===1)return;const d=R.colspan;if(R.colspan>1){for(let h=1;h<R.colspan;h++){const g=q();a.tdList.splice(n+h,0,{id:g,rowspan:1,colspan:1,value:[{value:w,size:16,tableId:s.id,trId:a.id,tdId:g}]})}R.colspan=1}if(R.rowspan>1){for(let h=1;h<R.rowspan;h++){const g=l[i+h];for(let L=0;L<d;L++){const T=q();g.tdList.splice(R.colIndex,0,{id:T,rowspan:1,colspan:1,value:[{value:w,size:16,tableId:s.id,trId:g.id,tdId:T}]})}}R.rowspan=1}const u=R.value.length-1;this.range.setRange(u,u),this.draw.render(),this.tableTool.render()}splitVerticalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:r}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,R=a[r],d=R.tdList[i];l.colgroup.splice(i+1,0,{width:this.options.table.defaultColMinWidth});for(let u=0;u<a.length;u++){const h=a[u];let g=0;for(;g<h.tdList.length;){const L=h.tdList[g];if(L.rowIndex!==d.rowIndex)L.colIndex<=d.colIndex&&L.colIndex+L.colspan>d.colIndex&&L.colspan++;else if(L.id===d.id){const T=q();R.tdList.splice(g+d.colspan,0,{id:T,rowspan:d.rowspan,colspan:1,value:[{value:w,size:16,tableId:l.id,trId:h.id,tdId:T}]}),g++}g++}}this.draw.render(),this.tableTool.render()}splitHorizontalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:r}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,d=a[r].tdList[i];let u=-1,h=0;for(;h<a.length;){if(h===u){h++;continue}const g=a[h];let L=0;for(;L<g.tdList.length;){const T=g.tdList[L];if(T.id===d.id){const O=q(),P=q();a.splice(h+d.rowspan,0,{id:O,height:this.options.table.defaultTrMinHeight,tdList:[{id:P,rowspan:1,colspan:d.colspan,value:[{value:w,size:16,tableId:l.id,trId:O,tdId:P}]}]}),u=h+d.rowspan}else T.rowIndex>=d.rowIndex&&T.rowIndex<d.rowIndex+d.rowspan&&T.rowIndex+T.rowspan>=d.rowIndex+d.rowspan&&T.rowspan++;L++}h++}this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const r=e[i];for(let s=0;s<r.length;s++){const l=r[s];!l||l.verticalAlign===t||!l.verticalAlign&&t===c.VerticalAlign.TOP||(l.verticalAlign=t)}}const{endIndex:n}=this.range.getRange();this.draw.render({curIndex:n})}tableBorderType(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,r=this.draw.getOriginalElementList()[n];if(!r.borderType&&t===c.TableBorder.ALL||r.borderType===t)return;r.borderType=t;const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s})}tableBorderColor(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,r=this.draw.getOriginalElementList()[n];if(!r.borderColor&&t===this.options.table.defaultBorderColor||r.borderColor===t)return;r.borderColor=t;const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s,isCompute:!1})}tableTdBorderType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(s=>{var l;return!((l=s.borderTypes)!=null&&l.includes(t))});n.forEach(s=>{s.borderTypes||(s.borderTypes=[]);const l=s.borderTypes.findIndex(a=>a===t);i?~l||s.borderTypes.push(t):~l&&s.borderTypes.splice(l,1),s.borderTypes.length||delete s.borderTypes});const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdSlashType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(s=>{var l;return!((l=s.slashTypes)!=null&&l.includes(t))});n.forEach(s=>{s.slashTypes||(s.slashTypes=[]);const l=s.slashTypes.findIndex(a=>a===t);i?~l||s.slashTypes.push(t):~l&&s.slashTypes.splice(l,1),s.slashTypes.length||delete s.slashTypes});const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdBackgroundColor(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const r=e[i];for(let s=0;s<r.length;s++){const l=r[s];l.backgroundColor=t}}const{endIndex:n}=this.range.getRange();this.range.setRange(n,n),this.draw.render({isCompute:!1})}tableSelectAll(){const t=this.position.getPositionContext(),{index:e,tableId:n,isTable:i}=t;if(!i||!n)return;const{startIndex:r,endIndex:s}=this.range.getRange(),a=this.draw.getOriginalElementList()[e].trList,R=a.length-1,d=a[R].tdList.length-1;this.range.replaceRange({startIndex:r,endIndex:s,tableId:n,startTdIndex:0,endTdIndex:d,startTrIndex:0,endTrIndex:R}),this.draw.render({isSetCursor:!1,isCompute:!1,isSubmitHistory:!1})}}c.AreaMode=void 0,function(o){o.EDIT="edit",o.READONLY="readonly",o.FORM="form"}(c.AreaMode||(c.AreaMode={}));class nl{constructor(t){this.areaInfoMap=new Map,this.draw=t,this.options=t.getOptions(),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(),n=this.draw.getElementList()[t];return(n==null?void 0:n.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 c.AreaMode.EDIT:return!1;case c.AreaMode.READONLY:return!0;case c.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:i,position:r,range:s}=t;if(this.zone.getZone()!==c.EditorZone.MAIN&&this.zone.setZone(c.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),s&&!this.getActiveAreaId()){const{startIndex:a,endIndex:R}=s,d=this.draw.getOriginalMainElementList();if(!d[a]||!d[R])return null;this.range.setRange(s.startIndex,s.endIndex)}else if(r===c.LocationPosition.BEFORE)this.range.setRange(0,0);else{const R=this.draw.getOriginalMainElementList().length-1;this.range.setRange(R,R)}const l=e||q();return this.draw.insertElementList([{type:c.ElementType.AREA,value:"",areaId:l,valueList:n,area:et(i)}]),l}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),i=this.draw.getInnerWidth();for(const r of this.areaInfoMap){const{area:s,positionList:l}=r[1];if((s==null?void 0:s.hide)||!(s!=null&&s.backgroundColor)&&!(s!=null&&s.borderColor)&&!(s!=null&&s.placeholder))continue;const a=l.filter(L=>L.pageNo===e);if(!a.length)continue;t.translate(.5,.5);const R=a[0],d=a[a.length-1],u=n[3],h=Math.ceil(R.coordinate.leftTop[1]),g=Math.ceil(d.coordinate.rightBottom[1]-h);s.backgroundColor&&(t.fillStyle=s.backgroundColor,t.fillRect(u,h,i,g)),s.borderColor&&(t.strokeStyle=s.borderColor,t.strokeRect(u,h,i,g)),s.placeholder&&l.length<=1&&new bi(this.draw).render(t,{placeholder:{...Jn,...s.placeholder},startY:R.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const i=t[n],r=i.areaId;if(r){const s=this.areaInfoMap.get(r);s?(s.elementList.push(i),s.positionList.push(e[n])):this.areaInfoMap.set(r,{id:r,area:i.area,elementList:[i],positionList:[e[n]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const n=this.areaInfoMap.get(e);return n?{area:n.area,id:n.id,startPageNo:n.positionList[0].pageNo,endPageNo:n.positionList[n.positionList.length-1].pageNo,value:rt(n.elementList)}:null}getContextByAreaId(t,e){var i,r,s;const n=this.draw.getOriginalMainElementList();for(let l=0;l<n.length;l++){const a=n[l];if((e==null?void 0:e.position)===c.LocationPosition.OUTER_BEFORE){if(((i=n[l+1])==null?void 0:i.areaId)!==t)continue}else if((e==null?void 0:e.position)===c.LocationPosition.AFTER){if(!(a.areaId===t&&((r=n[l+1])==null?void 0:r.areaId)!==t))continue}else if((e==null?void 0:e.position)===c.LocationPosition.OUTER_AFTER){if(!(a.areaId!==t&&((s=n[l-1])==null?void 0:s.areaId)===t))continue}else if(a.areaId!==t)continue;const R=this.position.getOriginalMainPositionList();return{range:{startIndex:l,endIndex:l},elementPosition:R[l]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;n.area||(n.area={});let i=!1;const r=["top","hide"];Object.entries(t.properties).forEach(([s,l])=>{if(Cn(l))return;const a=s;n.area[a]=l,r.includes(a)&&(i=!0)}),this.draw.render({isCompute:i,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:i}=n,r=this.draw.getOriginalMainElementList(),s=t.value;Mt([{type:c.ElementType.AREA,value:"",valueList:s,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(r,i[0].index,i.length,s,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class il{constructor(t){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,n,i,r,s){if(this.imageCache.has(s)){const l=this.imageCache.get(s);t.drawImage(l,e,n,i,r)}else{const l=new Image;l.setAttribute("crossOrigin","Anonymous"),l.src=s,l.onload=()=>{this.imageCache.set(s,l),t.drawImage(l,e,n,i,r)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:i}=this.options,{left:r,top:s,width:l,height:a,value:R}=this.mainBadge,d=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),u=(r||i.left)*n,h=(s||i.top)*n+d;this._drawImage(t,u,h,l*n,a*n,R)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:i,badge:r}=this.options;for(const s of n){const{positionList:l}=s[1],a=l[0];if(a.pageNo!==e)continue;const R=this.areaBadgeMap.get(s[0]);if(!R)continue;const{left:d,top:u,width:h,height:g,value:L}=R,T=(d||r.left)*i,O=(u||r.top)*i+a.coordinate.leftTop[1];this._drawImage(t,T,O,h*i,g*i,L)}}}}}class ol{constructor(t,e){this.isDrawing=!1,this.startStroke=null,this.draw=t,this.options=t.getOptions(),this.data=e||[],this.pageContainer=t.getPageContainer(),this.register()}register(){this.pageContainer.addEventListener("mousedown",this.start.bind(this)),this.pageContainer.addEventListener("mouseup",this.stop.bind(this)),this.pageContainer.addEventListener("mouseleave",this.stop.bind(this)),this.pageContainer.addEventListener("mousemove",this.drawing.bind(this))}start(t){if(!this.draw.isGraffitiMode())return;this.isDrawing=!0;const{scale:e}=this.options;this.startStroke={lineColor:this.options.graffiti.defaultLineColor,lineWidth:this.options.graffiti.defaultLineWidth,points:[t.offsetX/e,t.offsetY/e]}}stop(){this.isDrawing=!1}drawing(t){var R;if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,i=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<i&&Math.abs(this.startStroke.points[1]-n)<i)return;const r=this.draw.getPageNo();let s=this.data.find(d=>d.pageNo===r);if(this.startStroke&&(s||(s={pageNo:r,strokes:[]},this.data.push(s)),s.strokes.push(this.startStroke),this.startStroke=null),!((R=s==null?void 0:s.strokes)!=null&&R.length))return;const{scale:l}=this.options;s.strokes[s.strokes.length-1].points.push(e/l,n/l),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getValue(){return this.data}compute(){const t=this.draw.getPageRowList().length;for(let e=this.data.length-1;e>=0;e--)this.data[e].pageNo>t-1&&this.data.splice(e,1)}clear(){this.data=[]}render(t,e){var l;const n=(l=this.data.find(a=>a.pageNo===e))==null?void 0:l.strokes;if(!(n!=null&&n.length))return;const{graffiti:{defaultLineColor:i,defaultLineWidth:r},scale:s}=this.options;t.save();for(let a=0;a<n.length;a++){const R=n[a];t.beginPath(),t.strokeStyle=R.lineColor||i,t.lineWidth=(R.lineWidth||r)*s,t.moveTo(R.points[0]*s,R.points[1]*s);for(let d=2;d<R.points.length;d+=2)t.lineTo(R.points[d]*s,R.points[d+1]*s);t.stroke()}t.restore()}}class sl{constructor(t,e,n,i,r,s){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=n.main,this.listener=i,this.eventBus=r,this.override=s,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new Gr(e.locale),this.historyManager=new or(this),this.position=new sr(this),this.zone=new vr(this),this.range=new rr(this),this.margin=new Rr(this),this.background=new lr(this),this.badge=new il(this),this.search=new cr(this),this.group=new kr(this),this.area=new nl(this),this.underline=new ur(this),this.strikeout=new dr(this),this.highlight=new ar(this),this.previewer=new Dr(this),this.imageParticle=new Kn(this),this.laTexParticle=new Hn(this),this.textParticle=new hr(this),this.tableParticle=new Tr(this),this.tableTool=new Pr(this),this.tableOperate=new el(this),this.pageNumber=new de(this),this.lineNumber=new $r(this),this.waterMark=new Nr(this),this.placeholder=new bi(this),this.header=new fr(this,n.header),this.footer=new Ar(this,n.footer),this.hyperlinkParticle=new Or(this),this.labelParticle=new Mr(this),this.dateParticle=new Kr(this),this.separatorParticle=new Ir(this),this.pageBreakParticle=new Xr(this),this.superscriptParticle=new Sr,this.subscriptParticle=new mr,this.checkboxParticle=new Yr(this),this.radioParticle=new Zr(this),this.blockParticle=new wr(this),this.listParticle=new Br(this),this.lineBreakParticle=new ue(this),this.whiteSpaceParticle=new _r(this),this.control=new Vr(this),this.pageBorder=new jr(this),this.graffiti=new ol(this,n.graffiti),this.scrollObserver=new gr(this),this.selectionObserver=new Lr(this),this.imageObserver=new xr,new zr(this),this.canvasEvent=new nr(this),this.cursor=new Zs(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new ir(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new br(this),new tl(this);const{letterClass:l}=e;this.LETTER_REG=new RegExp(`[${l.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${l.map(a=>`[^${a}][${a}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.mode===c.EditorMode.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=et(this.printModeData);["header","main","footer"].forEach(n=>{t[n]=this.control.filterAssistElement(t[n])}),this.setEditorData(t)}clearPrintData(){this.printModeData&&(this.setEditorData(this.printModeData),this.printModeData=null)}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}setMode(t){this.mode!==t&&(t===c.EditorMode.PRINT&&this.setPrintData(),this.mode===c.EditorMode.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 c.EditorMode.DESIGN:return!1;case c.EditorMode.READONLY:case c.EditorMode.PRINT:case c.EditorMode.GRAFFITI:return!0;case c.EditorMode.FORM:return!this.control.getIsRangeWithinControl();default:return!1}}isDisabled(){var r,s,l,a,R;if(this.mode===c.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if((r=this.getTd())!=null&&r.disabled)return!0;if(t===e){const d=n[t],u=n[t+1];return!!(((s=d==null?void 0:d.title)==null?void 0:s.disabled)&&((l=u==null?void 0:u.title)==null?void 0:l.disabled)&&d.titleId===u.titleId||((a=d==null?void 0:d.control)==null?void 0:a.disabled)&&((R=u==null?void 0:u.control)==null?void 0:R.disabled)&&d.controlId===u.controlId)}return n.slice(t+1,e+1).some(d=>{var u,h;return((u=d.title)==null?void 0:u.disabled)||((h=d.control)==null?void 0:h.disabled)})}isDesignMode(){return this.mode===c.EditorMode.DESIGN}isPrintMode(){return this.mode===c.EditorMode.PRINT}isGraffitiMode(){return this.mode===c.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===c.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===c.PaperDirection.VERTICAL?n: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(),n=this.footer.getExtraHeight();return t[0]+t[2]+e+n}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:n,tdIndex:i}=t,s=this.getOriginalElementList()[e].trList[n].tdList[i],l=this.getTdPadding();return s.width-l[1]-l[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===c.PaperDirection.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(){const{table:{tdPadding:t},scale:e}=this.options;return t.map(n=>n*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.isSubscribe("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.isSubscribe("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:n,trIndex:i,tdIndex:r}=e;return t[n].trList[i].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}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 s;const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:r}=e;return((s=t[n].trList)==null?void 0:s[i].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:n,tdIndex:i,isTable:r}=t;return r?this.getOriginalElementList()[e].trList[n].tdList[i]:null}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{isSubmitHistory:r=!0}=e;Mt(t,{isHandleFirstElement:!1,editorOptions:this.options});let s=-1,l=this.control.getActiveControl();if(!l&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),l=this.control.getActiveControl()),l&&this.control.getIsRangeWithinControl())s=l.setValue(t,void 0,{isIgnoreDisabledRule:!0}),this.control.emitControlContentChange();else{const a=this.getElementList(),R=n===i,d=n+1;R||this.spliceElementList(a,d,i-n),this.spliceElementList(a,d,0,t),s=n+t.length;const u=a[d-1];t[0].listId&&u&&!u.listId&&(u==null?void 0:u.value)===w&&(!u.type||u.type===c.ElementType.TEXT)&&(a.splice(n,1),s-=1)}~s&&(this.range.setRange(s,s),this.render({curIndex:s,isSubmitHistory:r}))}appendElementList(t,e={}){if(!t.length)return;Mt(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:i,isSubmitHistory:r=!0}=e;i?(this.elementList.splice(1,0,...t),n=t.length):(this.elementList.push(...t),n=this.elementList.length-1),this.range.setRange(n,n),this.render({curIndex:n,isSubmitHistory:r})}spliceElementList(t,e,n,i,r){var R,d,u,h,g,L,T,O;const{isIgnoreDeletedRule:s=!1}=r||{},{group:l,modeRule:a}=this.options;if(n>0){const P=e+n,M=t[P],f=M==null?void 0:M.listId;if(f&&((R=t[e-1])==null?void 0:R.listId)!==f){let S=P;for(;S<t.length;){const I=t[S];if(I.listId!==f||I.value===w)break;delete I.listId,delete I.listType,delete I.listStyle,S++}}if(!s&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const S=(d=this.getTd())==null?void 0:d.deletable;let I=P-1;for(;I>=e;){const m=t[I];((m==null?void 0:m.hide)||((u=m==null?void 0:m.control)==null?void 0:u.hide)||((h=m==null?void 0:m.area)==null?void 0:h.hide)||S!==!1&&((g=m==null?void 0:m.control)==null?void 0:g.deletable)!==!1&&(!m.controlId||this.mode!==c.EditorMode.FORM||!a[this.mode].controlDeletableDisabled)&&((L=m==null?void 0:m.title)==null?void 0:L.deletable)!==!1&&(l.deletable!==!1||!((T=m.groupIds)!=null&&T.length))&&(((O=m==null?void 0:m.area)==null?void 0:O.deletable)!==!1||(m==null?void 0:m.areaIndex)!==0))&&t.splice(I,1),I--}}else t.splice(e,n)}if(i!=null&&i.length)for(let P=0;P<i.length;P++)t.splice(e+P,0,i[P])}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}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}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getGraffiti(){return this.graffiti}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:n}=t;e&&this.setPagePixelRatio(e);const i=this.mode,r=!!n&&i!==n;r&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const s=this.pageList.map(l=>l.toDataURL());return e&&this.setPagePixelRatio(null),r&&this.setMode(i),s}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(n=>n.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===c.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===c.PageMode.PAGING){const{height:i}=this.options,r=this.getPagePixelRatio(),s=this.pageList[0];s.style.height=`${i}px`,s.height=i*r,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(c.EditorZone.MAIN);const{startIndex:e}=this.range.getRange(),n=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),n||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.isSubscribe("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((s,l)=>{s.width=n*e,s.height=i*e,s.style.width=`${n}px`,s.style.height=`${i}px`,s.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[l])});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.isSubscribe("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(),n=this.getHeight();this.pageList.forEach((i,r)=>{i.width=e*t,i.height=n*t,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),i=this.getWidth(),r=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((s,l)=>{s.width=i*n,s.height=r*n,s.style.width=`${i}px`,s.style.height=`${r}px`,this._initPageContext(this.ctxList[l])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((r,s)=>{r.width=n*e,r.height=i*e,r.style.width=`${n}px`,r.style.height=`${i}px`,this._initPageContext(this.ctxList[s])}),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 n=this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(n=this.pageRowList[e].flatMap(r=>r.elementList)),{header:this.getHeaderElementList(),main:n,footer:this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t),{extraPickAttrs:n}=t,i={header:rt(e.header,{extraPickAttrs:n}),main:rt(e.main,{extraPickAttrs:n,isClassifyArea:!0}),footer:rt(e.footer,{extraPickAttrs:n}),graffiti:e.graffiti};return{version:xe,data:i,options:et(this.options)}}setValue(t,e){const{header:n,main:i,footer:r}=et(t);if(!n&&!i&&!r)return;const{isSetCursor:s=!1}=e||{};[n,i,r].forEach(R=>{!R||Mt(R,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:i,footer:r}),this.historyManager.recovery();const a=s?i!=null&&i.length?i.length-1:0:void 0;a!==void 0&&this.range.setRange(a,a),this.render({curIndex:a,isSetCursor:s,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:i}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),i&&this.footer.setElementList(i)}_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(Ht,c.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${x}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),i=document.createElement("canvas");i.style.width=`${e}px`,i.style.height=`${n}px`,i.style.display="block",i.style.backgroundColor="#ffffff",i.style.marginBottom=`${this.getPageGap()}px`,i.setAttribute("data-index",String(t)),this.pageContainer.append(i);const r=this.getPagePixelRatio();i.width=e*r,i.height=n*r,i.style.cursor="text";const s=i.getContext("2d");this._initPageContext(s),this.pageList.push(i),this.ctxList.push(s)}_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:n,defaultFont:i}=this.options,r=t.font||i,s=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${s*e}px ${r}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){var a;const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:i,scale:r}=this.options,s=t.size||e;let l=1;return s<12?l=s/12:s>30&&(l=1+(s-30)/30),n*l*((a=t.rowMargin)!=null?a:i)*r}computeRowList(t){var X,E,C,U,K,b,Y,y,D,H,_,v,J,z,ft,ht,it,gt,tt,j,Tt,Dt;const{innerWidth:e,elementList:n,isPagingMode:i=!1,isFromTable:r=!1,startX:s=0,startY:l=0,pageHeight:a=0,mainOuterHeight:R=0,surroundElementList:d=[]}=t,{defaultSize:u,scale:h,imgCaption:g,table:{tdPadding:L,defaultTrMinHeight:T},defaultTabWidth:O}=this.options,P=this.getDefaultBasicRowMarginHeight(),f=document.createElement("canvas").getContext("2d"),S=this.listParticle.computeListStyle(f,n),I=[];n.length&&I.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:((X=n==null?void 0:n[0])==null?void 0:X.rowFlex)||((E=n==null?void 0:n[1])==null?void 0:E.rowFlex)});let m=s,N=l,F=0,Z,W=0,V=0;const p=(lt,k)=>{const Q=lt.marginLeft||0,Xt=k&<.textIndent||0;return(Q+Xt)*h};for(let lt=0;lt<n.length;lt++){const k=I[I.length-1],Q=n[lt],Xt=this.getElementRowMargin(Q),G={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0};if(k.offsetX===void 0&&!Q.listId&&(Q.marginLeft||Q.textIndent||Q.marginRight||Q.marginTop)){const A=n[lt-1],st=lt===0||(A==null?void 0:A.value)===w||(A==null?void 0:A.type)===c.ElementType.PAGE_BREAK;k.offsetX=p(Q,st),st&&Q.marginTop&&(k.offsetY=(k.offsetY||0)+Q.marginTop*h)}const $t=k.offsetX||Q.listId&&S.get(Q.listId)||0,ye=(Q.marginRight||0)*h,B=e-$t-ye,xi=k.elementList.length===1;if(m+=xi?$t:0,N+=xi&&k.offsetY||0,(Q.hide||((C=Q.control)==null?void 0:C.hide)||((U=Q.area)==null?void 0:U.hide))&&!this.isDesignMode()){const A=k.elementList[k.elementList.length-1];G.height=(A==null?void 0:A.metrics.height)||this.options.defaultSize*h,G.boundingBoxAscent=(A==null?void 0:A.metrics.boundingBoxAscent)||0,G.boundingBoxDescent=(A==null?void 0:A.metrics.boundingBoxDescent)||0}else if(Q.type===c.ElementType.IMAGE||Q.type===c.ElementType.LATEX)if(Q.imgDisplay===c.ImageDisplay.SURROUND||Q.imgDisplay===c.ImageDisplay.FLOAT_TOP||Q.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)G.width=0,G.height=0,G.boundingBoxDescent=0;else{const A=Q.width*h,st=Q.height*h;if(A>B){const nt=st*B/A;Q.width=B/h,Q.height=nt/h,G.width=B,G.height=nt,G.boundingBoxDescent=nt}else G.width=A,G.height=st,G.boundingBoxDescent=st;if((K=Q.imgCaption)!=null&&K.value){const nt=Q.imgCaption.size||g.size,ct=(b=Q.imgCaption.top)!=null?b:g.top,_t=(nt+ct)*h;G.boundingBoxAscent+=_t}}else if(Q.type===c.ElementType.TABLE){const A=L[1]+L[3],st=L[0]+L[2];if(Q.pagingId){let Rt=lt+1,mt=0;for(;Rt<n.length;){const dt=n[Rt];if(dt.pagingId===Q.pagingId){const ut=dt.trList.filter(Ut=>!Ut.pagingRepeat);Q.trList.push(...ut),Q.height+=dt.height,Rt++,mt++}else break}mt&&n.splice(lt+1,mt)}Q.pagingIndex=(Y=Q.pagingIndex)!=null?Y:0;const nt=Q.trList;for(let Rt=0;Rt<nt.length;Rt++){const mt=nt[Rt];mt.height=mt.minHeight||T,mt.minHeight=mt.height}this.tableParticle.computeRowColInfo(Q);for(let Rt=0;Rt<nt.length;Rt++){const mt=nt[Rt];for(let dt=0;dt<mt.tdList.length;dt++){const ut=mt.tdList[dt],Ut=this.computeRowList({innerWidth:(ut.width-A)*h,elementList:ut.value,isFromTable:!0,isPagingMode:i}),Lt=Ut.reduce((pt,yt)=>pt+yt.height,0);ut.rowList=Ut;const St=Lt/h+st;if(ut.height<St){const pt=St-ut.height,yt=nt[Rt+ut.rowspan-1];yt.height+=pt,yt.tdList.forEach(kt=>{kt.height+=pt,kt.realHeight?kt.realHeight+=pt:kt.realHeight=kt.height})}let Nt=0,Et=0,Vt=0;for(;Vt<ut.rowspan;){const pt=nt[Vt+Rt]||nt[Rt];Nt+=pt.minHeight,Et+=pt.height,Vt++}ut.realMinHeight=Nt,ut.realHeight=Et,ut.mainHeight=St}}const ct=this.tableParticle.getTrListGroupByCol(nt);for(let Rt=0;Rt<ct.length;Rt++){const mt=ct[Rt];let dt=-1;for(let ut=0;ut<mt.tdList.length;ut++){const Ut=mt.tdList[ut],Lt=Ut.realHeight,St=Ut.mainHeight,Nt=Ut.realMinHeight,Et=St<Nt?Lt-Nt:Lt-St;(!~dt||Et<dt)&&(dt=Et)}if(dt>0){const ut=nt[Rt];ut.height-=dt,ut.tdList.forEach(Ut=>{Ut.height-=dt,Ut.realHeight-=dt})}}this.tableParticle.computeRowColInfo(Q);const _t=this.tableParticle.getTableHeight(Q),ki=this.tableParticle.getTableWidth(Q);Q.width=ki,Q.height=_t;const Ya=ki*h,Nn=_t*h;if(G.width=Ya,G.height=Nn,G.boundingBoxDescent=Nn,G.boundingBoxAscent=-Xt,((y=n[lt+1])==null?void 0:y.type)===c.ElementType.TABLE&&(G.boundingBoxAscent-=Xt),i){const Rt=this.getHeight(),mt=this.getMainOuterHeight();let dt=mt;for(let Lt=0;Lt<I.length;Lt++){const St=I[Lt],Nt=St.offsetY||0;St.height+dt+Nt>Rt||((D=I[Lt-1])==null?void 0:D.isPageBreak)?dt=mt+St.height+Nt:dt+=St.height+Nt}const ut=Xt*2*h,Ut=Q.trList[0].height*h;if((dt+Ut+ut>Rt||Q.pagingIndex!==0&&Q.trList[0].pagingRepeat||((H=n[lt-1])==null?void 0:H.type)===c.ElementType.PAGE_BREAK)&&(dt=mt),dt+ut+Nn>Rt){const Lt=Q.trList;let St=0,Nt=0,Et=0;if(Lt.length>1)for(let Vt=0;Vt<Lt.length;Vt++){const pt=Lt[Vt],yt=pt.height*h;if(dt+ut+Et+yt>Rt){const kt=pt.tdList.reduce((ne,Ge)=>ne+Ge.colspan,0);((_=Q.colgroup)==null?void 0:_.length)!==kt&&(Nt=0);break}else St=Vt+1,Nt=Lt.length-St,Et+=yt}if(Nt){const Vt=Lt.splice(St,Nt),pt=Vt.reduce((Le,pn)=>Le+pn.height,0),yt=pt*h,kt=Q.pagingId||q();Q.pagingId=kt,Q.height-=pt,G.height-=yt,G.boundingBoxDescent-=yt;const ne=et(Q);ne.pagingId=kt,ne.pagingIndex=Q.pagingIndex+1;const Ge=Lt.filter(Le=>Le.pagingRepeat);if(Ge.length){const Le=et(Ge);Le.forEach(pn=>pn.id=q()),Vt.unshift(...Le)}ne.trList=Vt,ne.id=q(),this.spliceElementList(n,lt+1,0,[ne])}}if(Q.pagingId){const Lt=this.position.getPositionContext();if(Lt.isTable){let St=-1,Nt=-1,Et=lt;for(;Et<n.length;){const Vt=n[Et];if(Vt.pagingId!==Q.pagingId)break;const pt=Vt.trList.findIndex(yt=>yt.id===Lt.trId);if(~pt){St=Et,Nt=pt;break}Et++}~St&&(Lt.index=St,Lt.trIndex=Nt,this.position.setPositionContext(Lt))}}}}else if(Q.type===c.ElementType.SEPARATOR){const{separator:{lineWidth:A}}=this.options,st=Q.lineWidth||A;Q.width=B/h,G.width=B,G.height=st*h,G.boundingBoxAscent=-Xt,G.boundingBoxDescent=-Xt+G.height}else if(Q.type===c.ElementType.PAGE_BREAK)Q.width=B/h,G.width=B,G.height=this.options.pageBreak.visible?u:0;else if(Q.type===c.ElementType.RADIO||Q.controlComponent===c.ControlComponent.RADIO){const{width:A,height:st,gap:nt}=this.options.radio,ct=A+nt*2;Q.width=ct,G.width=ct*h,G.height=st*h}else if(Q.type===c.ElementType.CHECKBOX||Q.controlComponent===c.ControlComponent.CHECKBOX){const{width:A,height:st,gap:nt}=this.options.checkbox,ct=A+nt*2;Q.width=ct,G.width=ct*h,G.height=st*h}else if(Q.type===c.ElementType.TAB)G.width=O*h,G.height=u*h,G.boundingBoxDescent=0,G.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(f,f.font);else if(Q.type===c.ElementType.BLOCK){if(!Q.width)G.width=B;else{const A=Q.width*h;G.width=Math.min(A,B)}G.height=Q.height*h,G.boundingBoxDescent=G.height,G.boundingBoxAscent=0}else if(Q.type===c.ElementType.LABEL){const{defaultSize:A,label:{defaultPadding:st}}=this.options;f.font=this.getElementFont(Q);const nt=this.textParticle.measureText(f,Q);G.width=(nt.width+st[1]+st[3])*h,G.height=(Q.size||A)*h,G.boundingBoxDescent=0,G.boundingBoxAscent=(st[0]+nt.actualBoundingBoxAscent)*h}else{const A=Q.size||u;(Q.type===c.ElementType.SUPERSCRIPT||Q.type===c.ElementType.SUBSCRIPT)&&(Q.actualSize=Math.ceil(A*.6)),G.height=(Q.actualSize||A)*h,f.font=this.getElementFont(Q);const st=this.textParticle.measureText(f,Q);G.width=st.width*h,Q.letterSpacing&&(G.width+=Q.letterSpacing*h),Q.wordSpacing&&(G.width+=Q.wordSpacing*h);const nt=this.textParticle.measureBasisWord(f,Q.font);G.boundingBoxAscent=nt.actualBoundingBoxAscent*h,G.boundingBoxDescent=nt.actualBoundingBoxDescent*h,Q.type===c.ElementType.SUPERSCRIPT?G.boundingBoxAscent+=G.height/2:Q.type===c.ElementType.SUBSCRIPT&&(G.boundingBoxDescent+=G.height/2)}const Ji=!Q.hide&&(Q.imgDisplay!==c.ImageDisplay.INLINE&&Q.type===c.ElementType.IMAGE||Q.type===c.ElementType.LATEX)?G.height+Xt:G.boundingBoxAscent+Xt,ge=Xt+G.boundingBoxAscent+G.boundingBoxDescent+Xt,Kt=Object.assign(Q,{metrics:G,left:0,style:this.getElementFont(Q,h)});(v=Kt.control)!=null&&v.minWidth&&(Kt.controlComponent&&(V+=G.width),Kt.controlComponent===c.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:k,rowElement:Kt,availableWidth:B,controlRealWidth:V}),V=0));const ot=n[lt-1];let vi=n[lt+1],we=k.width+G.width;if(this.options.wordBreak===c.WordBreak.BREAK_WORD&&(!(ot!=null&&ot.type)||(ot==null?void 0:ot.type)===c.ElementType.TEXT)&&(!Q.type||Q.type===c.ElementType.TEXT)){const A=`${(ot==null?void 0:ot.value)||""}${Q.value}`;if(this.WORD_LIKE_REG.test(A)){const{width:nt,endElement:ct}=this.textParticle.measureWord(f,n,lt),_t=nt*h;ct&&_t<=B&&(we+=_t,vi=ct)}we+=this.textParticle.measurePunctuationWidth(f,vi)*h}Q.listId&&(Q.listId!==Z?W=0:Q.value===w&&!Q.listWrap&&W++),Z=Q.listId;const Ai=this.position.setSurroundPosition({pageNo:F,rowElement:Kt,row:k,rowElementRect:{x:m,y:N,height:ge,width:G.width},availableWidth:B,surroundElementList:d});m=Ai.x,we+=Ai.rowIncreaseWidth,m+=G.width;const He=Q.type===c.ElementType.SEPARATOR||Q.type===c.ElementType.TABLE||(ot==null?void 0:ot.type)===c.ElementType.TABLE||(ot==null?void 0:ot.type)===c.ElementType.BLOCK||Q.type===c.ElementType.BLOCK||(ot==null?void 0:ot.imgDisplay)===c.ImageDisplay.INLINE||Q.imgDisplay===c.ImageDisplay.INLINE||(ot==null?void 0:ot.listId)!==Q.listId||(ot==null?void 0:ot.areaId)!==Q.areaId&&!((J=Q.area)!=null&&J.hide)||((z=Q.control)==null?void 0:z.flexDirection)===c.FlexDirection.COLUMN&&(Q.controlComponent===c.ControlComponent.CHECKBOX||Q.controlComponent===c.ControlComponent.RADIO)&&(ot==null?void 0:ot.controlComponent)===c.ControlComponent.VALUE||lt!==0&&Q.value===w&&!((ft=Q.area)!=null&&ft.hide),Bi=we>B,Xn=He||Bi;if(Xn){const A={width:G.width,height:ge,startIndex:lt,elementList:[Kt],ascent:Ji,rowIndex:k.rowIndex+1,rowFlex:((ht=n[lt])==null?void 0:ht.rowFlex)||((it=n[lt+1])==null?void 0:it.rowFlex),isPageBreak:Q.type===c.ElementType.PAGE_BREAK};if(Kt.controlComponent!==c.ControlComponent.PREFIX&&((gt=Kt.control)==null?void 0:gt.indentation)===c.ControlIndentation.VALUE_START){const st=k.elementList.findIndex(nt=>nt.controlId===Kt.controlId&&nt.controlComponent!==c.ControlComponent.PREFIX);if(~st){const ct=this.position.computeRowPosition({row:k,innerWidth:this.getInnerWidth()})[st];ct&&(A.offsetX=ct.coordinate.leftTop[0])}}Q.listId?(A.isList=!0,A.offsetX=S.get(Q.listId),A.listIndex=W):(Q.marginLeft||Q.textIndent||Q.marginRight)&&(A.offsetX=p(Q,He)),A.offsetY=!r&&((tt=Q.area)==null?void 0:tt.top)&&Q.areaId!==((j=n[lt-1])==null?void 0:j.areaId)?Q.area.top*h:0,He&&Q.marginTop&&(A.offsetY=(A.offsetY||0)+Q.marginTop*h),I.push(A)}else k.width+=G.width,lt===0&&(Re(n[1])||!!((Tt=n[1])!=null&&Tt.areaId))?(k.height=P,k.ascent=P):k.height<ge&&(k.height=ge,k.ascent=Ji),k.elementList.push(Kt);if(Xn||lt===n.length-1){k.isWidthNotEnough=Bi&&!He;let A=0;for(let st=0;st<k.elementList.length;st++){const ct=(k.elementList[st].minHeight||0)*h;ct>A&&(A=ct)}if(A>k.height&&(k.height=A),!k.isSurround&&((ot==null?void 0:ot.rowFlex)===c.RowFlex.JUSTIFY||(ot==null?void 0:ot.rowFlex)===c.RowFlex.ALIGNMENT&&k.isWidthNotEnough)){const st=((Dt=k.elementList[0])==null?void 0:Dt.value)===w?k.elementList.slice(1):k.elementList,nt=(B-k.width)/(st.length-1);for(let ct=0;ct<st.length-1;ct++){const _t=st[ct];_t.metrics.width+=nt}k.width=B}}if(Xn){m=s,N+=k.height,i&&!r&&a&&(N-l+R+ge>a||Q.type===c.ElementType.PAGE_BREAK)&&(N=l,Is(d,F),F+=1),Kt.left=0;const A=I[I.length-1];m=this.position.setSurroundPosition({pageNo:F,rowElement:Kt,row:A,rowElementRect:{x:m,y:N,height:ge,width:G.width},availableWidth:B,surroundElementList:d}).x,m+=G.width}}return I}_computePageList(){var a;const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,i=this.getHeight(),r=this.getMainOuterHeight();let s=r,l=0;if(e===c.PageMode.CONTINUITY){t[0]=this.rowList,s+=this.rowList.reduce((h,g)=>h+g.height+(g.offsetY||0),0);const R=this.getPagePixelRatio(),d=this.pageList[0],u=Number(d.style.height.replace("px",""));if(s>u)d.style.height=`${s}px`,d.height=s*R;else{const h=s<i?i:s;d.style.height=`${h}px`,d.height=h*R}this._initPageContext(this.ctxList[0])}else for(let R=0;R<this.rowList.length;R++){const d=this.rowList[R],u=d.offsetY||0;if(d.height+u+s>i||((a=this.rowList[R-1])==null?void 0:a.isPageBreak)){if(Number.isInteger(n)&&l>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}s=r+d.height+u,t.push([d]),l++}else s+=d.height+u,t[l].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:i,elementList:r}=e,s=this.getDefaultBasicRowMarginHeight(),l=this.getHighlightMarginHeight();for(let a=0;a<n.length;a++){const R=n[a];for(let d=0;d<R.elementList.length;d++){const u=R.elementList[d],h=R.elementList[d-1],g=u.highlight||this.control.getControlHighlight(r,R.startIndex+d);if(g){h&&h.highlight&&h.highlight!==u.highlight&&this.highlight.render(t);const{coordinate:{leftTop:[L,T]}}=i[R.startIndex+d],O=u.left||0;this.highlight.recordFillInfo(t,L-O,T+s-l,u.metrics.width+O,R.height-2*s+2*l,g)}else h!=null&&h.highlight&&this.highlight.render(t)}this.highlight.render(t)}}drawRow(t,e){var I,m,N,F,Z,W,V,p,X;debugger;this._drawHighlight(t,e);const{scale:n,table:{tdPadding:i},group:r,lineBreak:s,whiteSpace:l}=this.options,{rowList:a,pageNo:R,elementList:d,positionList:u,startIndex:h,zone:g,isDrawLineBreak:L=!s.disabled,isDrawWhiteSpace:T=!l.disabled}=e,O=this.isPrintMode(),P=this.isGraffitiMode(),{isCrossRowCol:M,tableId:f}=this.range.getRange();let S=h;for(let E=0;E<a.length;E++){const C=a[E],U={x:0,y:0,width:0,height:0};let K=null;for(let b=0;b<C.elementList.length;b++){const Y=C.elementList[b],y=Y.metrics,{coordinate:{leftTop:[D,H]}}=u[C.startIndex+b],_=17,v=C.elementList[b-1];if((Y.hide||((I=Y.control)==null?void 0:I.hide)||((m=Y.area)==null?void 0:m.hide))&&!this.isDesignMode())this.textParticle.complete();else if(Y.type===c.ElementType.IMAGE)this.textParticle.complete(),Y.imgDisplay!==c.ImageDisplay.SURROUND&&Y.imgDisplay!==c.ImageDisplay.FLOAT_TOP&&Y.imgDisplay!==c.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,Y,D,H+4);else if(Y.type===c.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,Y,D,H+_);else if(Y.type===c.ElementType.TABLE)M&&(U.x=D,U.y=H,K=Y),this.tableParticle.render(t,Y,D,H);else if(Y.type===c.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,Y,D,H+_);else if(Y.type===c.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,Y,D,H+_);else if(Y.type===c.ElementType.DATE){const ht=C.elementList[b+1];(!v||v.dateId!==Y.dateId)&&this.textParticle.complete(),this.textParticle.record(t,Y,D,H+_),(!ht||ht.dateId!==Y.dateId)&&this.textParticle.complete()}else Y.type===c.ElementType.SUPERSCRIPT?(this.textParticle.complete(),this.superscriptParticle.render(t,Y,D,H+_)):Y.type===c.ElementType.SUBSCRIPT?(this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,Y,D,H+_)):Y.type===c.ElementType.SEPARATOR?this.separatorParticle.render(t,Y,D,H):Y.type===c.ElementType.PAGE_BREAK?this.mode!==c.EditorMode.CLEAN&&!O&&this.options.pageBreak.visible&&this.pageBreakParticle.render(t,Y,D,H):Y.type===c.ElementType.CHECKBOX||Y.controlComponent===c.ControlComponent.CHECKBOX?(this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:D,y:H+_,index:b,row:C})):Y.type===c.ElementType.RADIO||Y.controlComponent===c.ControlComponent.RADIO?(this.textParticle.complete(),this.radioParticle.render({ctx:t,x:D,y:H+_,index:b,row:C})):Y.type===c.ElementType.TAB?this.textParticle.complete():Y.rowFlex===c.RowFlex.ALIGNMENT||Y.rowFlex===c.RowFlex.JUSTIFY?(this.textParticle.record(t,Y,D,H+_),this.textParticle.complete()):Y.type===c.ElementType.BLOCK?(this.textParticle.complete(),this.blockParticle.render(t,R,Y,D,H+_)):(Y.left&&this.textParticle.complete(),this.textParticle.record(t,Y,D,H+_),(Y.width||Y.letterSpacing||Y.wordSpacing||to.test(Y.value))&&this.textParticle.complete());if(L&&!O&&this.mode!==c.EditorMode.CLEAN&&!C.isWidthNotEnough&&b===C.elementList.length-1&&this.lineBreakParticle.render(t,Y,D,H+C.height/2),T&&no.test(Y.value)&&this.whiteSpaceParticle.render(t,Y,D,H+C.height/2),(N=Y.control)!=null&&N.border){((F=v==null?void 0:v.control)==null?void 0:F.border)&&v.controlId!==Y.controlId&&this.control.drawBorder(t);const ht=this.getElementRowMargin(Y);this.control.recordBorderInfo(D,H+ht,Y.metrics.width,C.height-2*ht)}else(Z=v==null?void 0:v.control)!=null&&Z.border&&this.control.drawBorder(t);if(Y.underline||((W=Y.control)==null?void 0:W.underline)){(v==null?void 0:v.type)===c.ElementType.SUBSCRIPT&&Y.type!==c.ElementType.SUBSCRIPT&&this.underline.render(t);const ht=this.getElementRowMargin(Y),it=Y.left||0;let gt=0;Y.type===c.ElementType.SUBSCRIPT&&(gt=this.subscriptParticle.getOffsetY(Y));const tt=(V=Y.control)!=null&&V.underline?this.options.underlineColor:Y.color;this.underline.recordFillInfo(t,D-it,H+C.height-ht+gt,y.width+it,0,tt,(p=Y.textDecoration)==null?void 0:p.style)}else((v==null?void 0:v.underline)||((X=v==null?void 0:v.control)==null?void 0:X.underline))&&this.underline.render(t);if(Y.strikeout){if(!Y.type||Qt.includes(Y.type)){v&&(v.type===c.ElementType.SUBSCRIPT&&Y.type!==c.ElementType.SUBSCRIPT||v.type===c.ElementType.SUPERSCRIPT&&Y.type!==c.ElementType.SUPERSCRIPT||this.getElementSize(v)!==this.getElementSize(Y))&&this.strikeout.render(t);const ht=this.textParticle.measureBasisWord(t,this.getElementFont(Y));let it=H+_+ht.actualBoundingBoxDescent*n-y.height/2;Y.type===c.ElementType.SUBSCRIPT?it+=this.subscriptParticle.getOffsetY(Y):Y.type===c.ElementType.SUPERSCRIPT&&(it+=this.superscriptParticle.getOffsetY(Y)),this.strikeout.recordFillInfo(t,D,it,y.width)}}else v!=null&&v.strikeout&&this.strikeout.render(t);const{zone:J,startIndex:z,endIndex:ft}=this.range.getRange();if(J===g&&z!==ft&&z<=S&&S<=ft){const ht=this.position.getPositionContext();if(!ht.isTable&&!Y.tdId||ht.tdId===Y.tdId)if(z===S){const it=d[z+1];it&&it.value===w&&(U.x=D+y.width,U.y=H,U.height=C.height,U.width+=this.options.rangeMinWidth)}else{let it=y.width;it===0&&C.elementList.length===1&&(it=this.options.rangeMinWidth),U.width||(U.x=D,U.y=H,U.height=C.height),U.width+=it}}if(!r.disabled&&Y.groupIds&&this.group.recordFillInfo(Y,D,H,y.width,C.height),S++,Y.type===c.ElementType.TABLE&&!Y.hide){const ht=i[1]+i[3];for(let it=0;it<Y.trList.length;it++){const gt=Y.trList[it];for(let tt=0;tt<gt.tdList.length;tt++){const j=gt.tdList[tt];this.drawRow(t,{elementList:j.value,positionList:j.positionList,rowList:j.rowList,pageNo:R,startIndex:0,innerWidth:(j.width-ht)*n,zone:g,isDrawLineBreak:L})}}}}if(C.isList&&this.listParticle.drawListStyle(t,C,u[C.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!O&&!P){if(U.width&&U.height){const{x:b,y:Y,width:y,height:D}=U;this.range.render(t,b,Y,y,D)}if(M&&K&&K.id===f){const{coordinate:{leftTop:[b,Y]}}=u[C.startIndex];this.tableParticle.drawRange(t,K,b,Y)}}}}_drawFloat(t,e){const{scale:n}=this.options,i=this.position.getFloatPositionList(),{imgDisplays:r,pageNo:s}=e;for(let l=0;l<i.length;l++){const a=i[l],R=a.element;if((s===a.pageNo||a.zone===c.EditorZone.HEADER||a.zone==c.EditorZone.FOOTER)&&R.imgDisplay&&r.includes(R.imgDisplay)&&R.type===c.ElementType.IMAGE){const d=R.imgFloatPosition;this.imageParticle.render(t,R,d.x*n,d.y*n)}}}_clearPage(t){const e=this.ctxList[t],n=this.pageList[t];e.clearRect(0,0,Math.max(n.width,this.getWidth()),Math.max(n.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){var P,M,f;const{elementList:e,positionList:n,rowList:i,pageNo:r}=t,{inactiveAlpha:s,pageMode:l,header:a,footer:R,pageNumber:d,lineNumber:u,pageBorder:h}=this.options,g=this.mode===c.EditorMode.PRINT,L=this.getInnerWidth(),T=this.ctxList[r];T.globalAlpha=this.zone.isMainActive()?1:s,this._clearPage(r),(!g||!((P=this.options.modeRule[c.EditorMode.PRINT])!=null&&P.backgroundDisabled))&&this.background.render(T,r),g||this.area.render(T,r),l!==c.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(T,r),g||this.margin.render(T,r),this._drawFloat(T,{pageNo:r,imgDisplays:[c.ImageDisplay.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(T,r);const O=(M=i[0])==null?void 0:M.startIndex;this.drawRow(T,{elementList:e,positionList:n,rowList:i,pageNo:r,startIndex:O,innerWidth:L,zone:c.EditorZone.MAIN}),this.getIsPagingMode()&&(a.disabled||this.header.render(T,r),d.disabled||this.pageNumber.render(T,r),R.disabled||this.footer.render(T,r)),this._drawFloat(T,{pageNo:r,imgDisplays:[c.ImageDisplay.FLOAT_TOP,c.ImageDisplay.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(T,r),this.elementList.length<=1&&!((f=this.elementList[0])!=null&&f.listId)&&this.placeholder.render(T),u.disabled||this.lineNumber.render(T,r),h.disabled||this.pageBorder.render(T),this.badge.render(T,r),this.isGraffitiMode()&&this.graffiti.render(T,r)}_disconnectLazyRender(){var t;(t=this.lazyRenderIntersectionObserver)==null||t.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(n=>{n.forEach(i=>{if(i.isIntersecting){const r=Number(i.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[r],pageNo:r})}})}),this.pageList.forEach(n=>{this.lazyRenderIntersectionObserver.observe(n)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let n=0;n<this.pageRowList.length;n++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[n],pageNo:n})}render(t){this.renderCount++;const{header:e,footer:n}=this.options,{isSubmitHistory:i=!0,isSetCursor:r=!0,isCompute:s=!0,isLazy:l=!0,isInit:a=!1,isSourceHistory:R=!1,isFirstRender:d=!1}=t||{};let{curIndex:u}=t||{};const h=this.getInnerWidth(),g=this.getIsPagingMode(),L=this.pageRowList.length;if(s){this.position.setFloatPositionList([]),g&&(e.disabled||this.header.compute(),n.disabled||this.footer.compute());const P=this.getMargins(),M=this.getHeight(),f=this.header.getExtraHeight(),S=this.getMainOuterHeight(),I=P[3],m=P[0]+f,N=gn(this.elementList);if(this.rowList=this.computeRowList({startX:I,startY:m,pageHeight:M,mainOuterHeight:S,isPagingMode:g,innerWidth:h,surroundElementList:N,elementList:this.elementList}),this.pageRowList=this._computePageList(),this.position.computePositionList(),this.area.compute(),!this.isPrintMode()){const F=this.search.getSearchKeyword();F&&this.search.compute(F),this.control.computeHighlightList()}this.isGraffitiMode()&&this.graffiti.compute()}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let P=0;P<this.pageRowList.length;P++)this.pageList[P]||this._createPage(P);const T=this.pageRowList.length,O=this.pageList.length;if(O>T){const P=O-T;this.ctxList.splice(T,P),this.pageList.splice(T,P).forEach(M=>M.remove())}l&&g?this._lazyRender():this._immediateRender(),r?u=this.setCursor(u):this.range.getIsSelection()&&this.cursor.focus(),(i&&!d||u!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(u),$e(()=>{this.range.setRangeStyle(),s&&this.control.getActiveControl()&&this.control.reAwakeControl(),s&&!this.isReadonly()&&this.position.getPositionContext().isTable&&this.tableTool.render(),s&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),L!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(i||R)&&!a&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"))})}setCursor(t){var r;const e=this.position.getPositionContext(),n=this.position.getPositionList();if(e.isTable){const{index:s,trIndex:l,tdIndex:a}=e,d=(r=this.getOriginalElementList()[s].trList)==null?void 0:r[l].tdList[a].positionList;t===void 0&&d&&(t=d.length-1);const u=d==null?void 0:d[t];this.position.setCursorPosition(u||null)}else this.position.setCursorPosition(t!==void 0?n[t]:null);let i=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const l=this.getElementList()[t];if(mo.includes(l.type)){i=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(l,a)}}return this.cursor.drawCursor({isShow:i}),t}submitHistory(t){const e=this.position.getPositionContext(),n=hn(this.elementList),i=hn(this.header.getElementList()),r=hn(this.footer.getElementList()),s=et(this.range.getRange()),l=this.pageNo,a=et(e),R=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(R),this.setPageNo(l),this.position.setPositionContext(et(a)),this.header.setElementList(et(i)),this.footer.setElementList(et(r)),this.elementList=et(n),this.range.replaceRange(et(s)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}}class Di{constructor(t){this.executeMode=t.mode.bind(t),this.executeCut=t.cut.bind(t),this.executeCopy=t.copy.bind(t),this.executePaste=t.paste.bind(t),this.executeSelectAll=t.selectAll.bind(t),this.executeBackspace=t.backspace.bind(t),this.executeSetRange=t.setRange.bind(t),this.executeReplaceRange=t.replaceRange.bind(t),this.executeSetPositionContext=t.setPositionContext.bind(t),this.executeForceUpdate=t.forceUpdate.bind(t),this.executeBlur=t.blur.bind(t),this.executeHideCursor=t.hideCursor.bind(t),this.executeUndo=t.undo.bind(t),this.executeRedo=t.redo.bind(t),this.executePainter=t.painter.bind(t),this.executeApplyPainterStyle=t.applyPainterStyle.bind(t),this.executeFormat=t.format.bind(t),this.executeFont=t.font.bind(t),this.executeSize=t.size.bind(t),this.executeSizeAdd=t.sizeAdd.bind(t),this.executeSizeMinus=t.sizeMinus.bind(t),this.executeBold=t.bold.bind(t),this.executeItalic=t.italic.bind(t),this.executeUnderline=t.underline.bind(t),this.executeStrikeout=t.strikeout.bind(t),this.executeSuperscript=t.superscript.bind(t),this.executeSubscript=t.subscript.bind(t),this.executeColor=t.color.bind(t),this.executeHighlight=t.highlight.bind(t),this.executeTitle=t.title.bind(t),this.executeList=t.list.bind(t),this.executeRowFlex=t.rowFlex.bind(t),this.executeRowMargin=t.rowMargin.bind(t),this.executeInsertTable=t.insertTable.bind(t),this.executeInsertTableTopRow=t.insertTableTopRow.bind(t),this.executeInsertTableBottomRow=t.insertTableBottomRow.bind(t),this.executeInsertTableLeftCol=t.insertTableLeftCol.bind(t),this.executeInsertTableRightCol=t.insertTableRightCol.bind(t),this.executeDeleteTableRow=t.deleteTableRow.bind(t),this.executeDeleteTableCol=t.deleteTableCol.bind(t),this.executeDeleteTable=t.deleteTable.bind(t),this.executeMergeTableCell=t.mergeTableCell.bind(t),this.executeCancelMergeTableCell=t.cancelMergeTableCell.bind(t),this.executeSplitVerticalTableCell=t.splitVerticalTableCell.bind(t),this.executeSplitHorizontalTableCell=t.splitHorizontalTableCell.bind(t),this.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.bind(t),this.executeTableBorderColor=t.tableBorderColor.bind(t),this.executeTableTdBorderType=t.tableTdBorderType.bind(t),this.executeTableTdSlashType=t.tableTdSlashType.bind(t),this.executeTableTdBackgroundColor=t.tableTdBackgroundColor.bind(t),this.executeTableSelectAll=t.tableSelectAll.bind(t),this.executeImage=t.image.bind(t),this.executeHyperlink=t.hyperlink.bind(t),this.executeDeleteHyperlink=t.deleteHyperlink.bind(t),this.executeCancelHyperlink=t.cancelHyperlink.bind(t),this.executeEditHyperlink=t.editHyperlink.bind(t),this.executeSeparator=t.separator.bind(t),this.executePageBreak=t.pageBreak.bind(t),this.executeAddWatermark=t.addWatermark.bind(t),this.executeDeleteWatermark=t.deleteWatermark.bind(t),this.executeSearch=t.search.bind(t),this.executeSearchNavigatePre=t.searchNavigatePre.bind(t),this.executeSearchNavigateNext=t.searchNavigateNext.bind(t),this.executeReplace=t.replace.bind(t),this.executePrint=t.print.bind(t),this.executeReplaceImageElement=t.replaceImageElement.bind(t),this.executeSaveAsImageElement=t.saveAsImageElement.bind(t),this.executeSetImageCrop=t.setImageCrop.bind(t),this.executeSetImageCaption=t.setImageCaption.bind(t),this.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.bind(t),this.executePageScale=t.pageScale.bind(t),this.executePageScaleRecovery=t.pageScaleRecovery.bind(t),this.executePageScaleMinus=t.pageScaleMinus.bind(t),this.executePageScaleAdd=t.pageScaleAdd.bind(t),this.executePaperSize=t.paperSize.bind(t),this.executePaperDirection=t.paperDirection.bind(t),this.executeSetPaperMargin=t.setPaperMargin.bind(t),this.executeSetMainBadge=t.setMainBadge.bind(t),this.executeSetAreaBadge=t.setAreaBadge.bind(t),this.getAreaValue=t.getAreaValue.bind(t),this.executeInsertArea=t.insertArea.bind(t),this.executeSetAreaValue=t.setAreaValue.bind(t),this.executeSetAreaProperties=t.setAreaProperties.bind(t),this.executeLocationArea=t.locationArea.bind(t),this.executeClearGraffiti=t.clearGraffiti.bind(t),this.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeUpdateElementById=t.updateElementById.bind(t),this.executeDeleteElementById=t.deleteElementById.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.bind(t),this.executeTranslate=t.translate.bind(t),this.executeSetLocale=t.setLocale.bind(t),this.executeLocationCatalog=t.locationCatalog.bind(t),this.executeWordTool=t.wordTool.bind(t),this.executeSetHTML=t.setHTML.bind(t),this.executeSetHtmlDocx=t.setHtmlDocx.bind(t),this.executeSetGroup=t.setGroup.bind(t),this.executeDeleteGroup=t.deleteGroup.bind(t),this.executeLocationGroup=t.locationGroup.bind(t),this.executeSetZone=t.setZone.bind(t),this.executeUpdateOptions=t.updateOptions.bind(t),this.executeInsertTitle=t.insertTitle.bind(t),this.executeFocus=t.focus.bind(t),this.executeComputeElementListHeight=t.computeElementListHeight.bind(t),this.getImage=t.getImage.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getValueAsync=t.getValueAsync.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.bind(t),this.getCursorPosition=t.getCursorPosition.bind(t),this.getRemainingContentHeight=t.getRemainingContentHeight.bind(t),this.getRange=t.getRange.bind(t),this.getRangeText=t.getRangeText.bind(t),this.getRangeContext=t.getRangeContext.bind(t),this.getRangeRow=t.getRangeRow.bind(t),this.getRangeParagraph=t.getRangeParagraph.bind(t),this.getKeywordRangeList=t.getKeywordRangeList.bind(t),this.getKeywordContext=t.getKeywordContext.bind(t),this.getCatalog=t.getCatalog.bind(t),this.getPaperMargin=t.getPaperMargin.bind(t),this.getSearchNavigateInfo=t.getSearchNavigateInfo.bind(t),this.getLocale=t.getLocale.bind(t),this.getGroupIds=t.getGroupIds.bind(t),this.getContainer=t.getContainer.bind(t),this.getTitleValue=t.getTitleValue.bind(t),this.getPositionContextByEvent=t.getPositionContextByEvent.bind(t),this.getElementById=t.getElementById.bind(t),this.executeSetControlValue=t.setControlValue.bind(t),this.executeSetControlValueList=t.setControlValueList.bind(t),this.executeSetControlExtension=t.setControlExtension.bind(t),this.executeSetControlExtensionList=t.setControlExtensionList.bind(t),this.executeSetControlProperties=t.setControlProperties.bind(t),this.executeSetControlPropertiesList=t.setControlPropertiesList.bind(t),this.executeSetControlHighlight=t.setControlHighlight.bind(t),this.getControlValue=t.getControlValue.bind(t),this.getControlList=t.getControlList.bind(t),this.executeLocationControl=t.locationControl.bind(t),this.executeInsertControl=t.insertControl.bind(t),this.executeJumpControl=t.jumpControl.bind(t)}}function Ki(o,t){let e=0;for(let n=1;n<t;n++){const i=o[n],r=o[n-1];(i.value===w&&!i.listWrap&&!i.listId||i.listId!==(r==null?void 0:r.listId)&&r.value!==w||i.titleId!==(r==null?void 0:r.titleId)&&r.value!==w)&&e++}return e}function Ot(o){const t=Number.parseFloat(o);return Number.isFinite(t)?t:0}function rl(o){const t=window.getComputedStyle(o),e=Math.round(Ot(t.width))||Math.round(o.clientWidth),n=Math.round(Ot(t.minHeight||t.height))||Math.round(o.clientHeight),i=[Math.round(Ot(t.paddingTop)),Math.round(Ot(t.paddingRight)),Math.round(Ot(t.paddingBottom)),Math.round(Ot(t.paddingLeft))];return{width:e||794,height:n||1123,margins:i}}function ll(o,t){const e=o.trim();if(!e||e==="normal")return;if(/^\d+(\.\d+)?$/.test(e)){const i=Number.parseFloat(e);return Number.isFinite(i)&&i>0?i:void 0}const n=Ot(e);if(n>0&&t>0)return n/t}function al(o){const t=window.getComputedStyle(o),e=Ot(t.fontSize)||14,n=Ze(o),i=ll(t.lineHeight,e),r=Ot(t.textIndent),s=Ot(t.marginInlineStart||t.marginLeft),l=Ot(t.marginInlineEnd||t.marginRight),a=Ot(t.marginTop);let R=Ot(t.minHeight);!R&&e&&(R=e);let d=t.whiteSpace;if(!d||d==="normal"){const h=o.querySelector("span");if(h){const g=window.getComputedStyle(h).whiteSpace;g&&g!=="normal"&&(d=g)}}(!d||d==="normal")&&o.closest(".docx, .docx-wrapper")&&(d="pre-wrap");const u={};return n!==c.RowFlex.LEFT&&(u.rowFlex=n),i!==void 0&&(u.rowMargin=i),r&&(u.textIndent=r),s&&(u.marginLeft=s),l&&(u.marginRight=l),a&&(u.marginTop=a),R&&(u.minHeight=R),d&&d!=="normal"&&(u.whiteSpace=d),u}function Rl(o,t){if(!(!o.length||!Object.keys(t).length))for(const n of o)Object.assign(n,t)}function cl(o){var r,s;const t=window.getComputedStyle(o),e={color:t.color,bold:Number(t.fontWeight)>500,italic:t.fontStyle.includes("italic"),size:Math.floor(Ot(t.fontSize))||void 0,font:(s=(r=t.fontFamily)==null?void 0:r.split(",")[0])==null?void 0:s.replace(/['"]/g,"").trim()};t.backgroundColor&&t.backgroundColor!=="rgba(0, 0, 0, 0)"&&(e.highlight=t.backgroundColor),t.textDecorationLine.includes("underline")&&(e.underline=!0),t.textDecorationLine.includes("line-through")&&(e.strikeout=!0);const n=Ot(t.letterSpacing);n&&(e.letterSpacing=n),t.whiteSpace&&t.whiteSpace!=="normal"&&(e.whiteSpace=t.whiteSpace);const i=Ot(t.minHeight);return i&&(e.minHeight=i),e}function De(o){if(o.nodeType===3){const i=o.textContent||"";if(!i)return[];const r=o.parentElement,s=r?cl(r):{};return Ft(i).map(l=>({value:l,...s}))}if(o.nodeType!==1)return[];const t=o,e=t.nodeName;if(e==="BR")return[{value:Zt}];if(e==="IMG")return yi(t);if(e==="A"){const i=t.innerText;return i?[{type:c.ElementType.HYPERLINK,value:"",valueList:Ft(i).map(r=>({value:r})),url:t.href}]:[]}const n=[];return t.childNodes.forEach(i=>{n.push(...De(i))}),n}function yi(o){const{src:t,width:e,height:n}=o,i=e||Ot(window.getComputedStyle(o).width),r=n||Ot(window.getComputedStyle(o).height);if(!t||!i||!r)return[];const s={width:i,height:r,value:t,type:c.ElementType.IMAGE,rowFlex:Ze(o.parentElement||o),verticalAlign:"text-top"};$n(o,s);const l=o.getAttribute("data-form-input");if(l)try{s.formInput=JSON.parse(l)}catch{}return[s]}function dl(o){const t=al(o),e=[];return o.childNodes.forEach(n=>{e.push(...De(n))}),e.length?(Rl(e,t),e.push({value:Zt,...t}),e):[{value:Zt,...t}]}function ul(o,t){var s;const e={type:c.ElementType.TABLE,value:Zt,colgroup:[],trList:[]},n=o.querySelectorAll("colgroup col");if(o.querySelectorAll("tr").forEach(l=>{const a=Ot(window.getComputedStyle(l).height)||0,R={height:a,minHeight:a,tdList:[]};l.querySelectorAll("th,td").forEach(d=>{const u=d,h=Ke(u,t),g={colspan:u.colSpan,rowspan:u.rowSpan,value:h,verticalAlign:window.getComputedStyle(d).verticalAlign,width:Ot(window.getComputedStyle(d).width)};u.style.backgroundColor&&(g.backgroundColor=u.style.backgroundColor),R.tdList.push(g)}),e.trList.push(R)}),!e.trList.length)return[];const i=e.trList[0].tdList.reduce((l,a)=>l+a.colspan,0),r=Math.ceil(t/Math.max(i,1));for(let l=0;l<i;l++){const a=(s=n[l])==null?void 0:s.getAttribute("width");e.colgroup.push({width:a?parseFloat(a):r})}return[e]}function Ke(o,t){const e=[];return o.childNodes.forEach(n=>{var s;if(n.nodeType!==1){n.nodeType===3&&((s=n.textContent)==null?void 0:s.trim())&&(e.push(...De(n)),e.push({value:Zt}));return}const i=n,r=i.nodeName;if(r==="P"||/^H[1-6]$/.test(r))e.push(...dl(i));else if(r==="TABLE")e.push(...ul(i,t));else if(r==="IMG")e.push(...yi(i)),e.push({value:Zt});else if(r==="BR")e.push({value:Zt});else if(r==="DIV"&&i.getAttribute("data-type")===c.ElementType.PAGE_BREAK)e.push({type:c.ElementType.PAGE_BREAK,value:Zt});else{if(r==="DIV"&&i.getAttribute("data-ce-clear")==="both")return;if(r==="ARTICLE"||r==="DIV"||r==="SECTION")e.push(...Ke(i,t));else{const l=Ke(i,t);if(l.length)e.push(...l);else{const a=De(i);a.length&&(e.push(...a),e.push({value:Zt}))}}}}),e}function hl(o,t){const e=o.querySelector("article")||o;return Ke(e,t)}function gl(o){const t=Array.from(o.querySelectorAll("section.docx")),e=Array.from(o.querySelectorAll(".ce-export-page")),n=t.length?t:e.length?e:[o],i=rl(n[0]),r=Math.max(i.width-i.margins[1]-i.margins[3],1),s=[];return n.forEach((l,a)=>{const R=hl(l,r);R.length&&s.push(...R),a<n.length-1&&s.push({type:c.ElementType.PAGE_BREAK,value:Zt})}),{paper:i,main:s}}function Ll(o,t){return o===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:o===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:o===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${o}px`,height:`${t}px`}}function Tl(o,t){const{width:e,height:n,direction:i=c.PaperDirection.VERTICAL}=t,r=document.createElement("iframe");r.style.visibility="hidden",r.style.position="absolute",r.style.left="0",r.style.top="0",r.style.width="0",r.style.height="0",r.style.border="none",document.body.append(r);const s=r.contentWindow,l=s.document;l.open();const a=document.createElement("div"),R=Ll(e,n);o.forEach(h=>{const g=document.createElement("img");g.style.width=i===c.PaperDirection.HORIZONTAL?R.height:R.width,g.style.height=i===c.PaperDirection.HORIZONTAL?R.width:R.height,g.src=h,a.append(g)});const d=document.createElement("style"),u=`
|
|
91
|
+
`?w:R,controlId:i.controlId,type:c.ElementType.CONTROL,control:i.control,controlComponent:c.ControlComponent.PLACEHOLDER,color:this.controlOptions.placeholderColor};It(n,[d],t,{editorOptions:this.options}),this.draw.spliceElementList(n,t+a+1,0,[d])}}setValue(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.setValue(t)}setControlProperties(t,e={}){const n=e.elementList||this.getElementList(),{startIndex:i}=e.range||this.getRange(),r=n[i];let s=i;for(;s>0;){const a=n[s];if(a.controlId!==r.controlId)break;a.control={...a.control,...t},s--}let l=i+1;for(;l<n.length;){const a=n[l];if(a.controlId!==r.controlId)break;a.control={...a.control,...t},l++}}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,groupId:n,conceptId:i,areaId:r}=t,s=[];if(!e&&!i&&!n)return s;const l=(R,d)=>{let u=0;for(;u<R.length;){const h=R[u];if(u++,h.type===c.ElementType.TABLE){const f=h.trList;for(let S=0;S<f.length;S++){const I=f[S];for(let m=0;m<I.tdList.length;m++){const N=I.tdList[m];l(N.value,d)}}}if(!h.control||n&&h.control.groupId!==n||e&&h.controlId!==e||i&&h.control.conceptId!==i||r&&h.areaId!==r)continue;const{type:g,code:L,valueSets:T}=h.control;let O=u,P="";const M=[];for(;O<R.length;){const f=R[O];if(f.controlId!==h.controlId)break;(g===c.ControlType.TEXT||g===c.ControlType.DATE||g===c.ControlType.NUMBER)&&f.controlComponent===c.ControlComponent.VALUE&&(P+=f.value,M.push(wt(f,tn))),O++}if(g===c.ControlType.TEXT||g===c.ControlType.DATE||g===c.ControlType.NUMBER)s.push({...h.control,zone:d,value:P||null,innerText:P||null,elementList:rt(M)});else if(g===c.ControlType.SELECT||g===c.ControlType.CHECKBOX||g===c.ControlType.RADIO){const f=L==null?void 0:L.split(",").map(S=>{var I;return(I=T==null?void 0:T.find(m=>m.code===S))==null?void 0:I.value}).filter(Boolean).join("");s.push({...h.control,zone:d,value:L||null,innerText:f||null})}u=O}},a=[{zone:c.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:c.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:c.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:R,elementList:d}of a)l(d,R);return s}setValueListById(t){if(!t.length)return;let e=!1,n=!1;const i=s=>{let l=0;for(;l<s.length;){const a=s[l];if(l++,a.type===c.ElementType.TABLE){const M=a.trList;for(let f=0;f<M.length;f++){const S=M[f];for(let I=0;I<S.tdList.length;I++){const m=S.tdList[I];i(m.value)}}}if(!a.control)continue;const R=t.find(M=>{var f;return(!M.groupId||M.groupId===((f=a.control)==null?void 0:f.groupId))&&(M.id&&a.controlId===M.id||M.conceptId&&a.control.conceptId===M.conceptId||M.areaId&&a.areaId===M.areaId)});if(!R)continue;const{value:d,isSubmitHistory:u=!0}=R;e=!0,u&&(n=!0);const{type:h}=a.control;let g=l;for(;g<s.length&&s[g].controlId===a.controlId;)g++;const T={range:{startIndex:l-1,endIndex:g-2},elementList:s},O={isIgnoreDisabledRule:!0,isIgnoreDeletedRule:!0};if(h===c.ControlType.TEXT){const M=Array.isArray(d)?d:d?[{value:d}]:[];M.length&&Mt(M,{isHandleFirstElement:!1,editorOptions:this.options});const f=new mn(a,this);this.activeControl=f,M.length?f.setValue(M,T,O):f.clearValue(T,O)}else if(h===c.ControlType.SELECT){if(Array.isArray(d))continue;const M=new fe(a,this);this.activeControl=M,d?M.setSelect(d,T,O):M.clearSelect(T,O)}else if(h===c.ControlType.CHECKBOX){if(Array.isArray(d))continue;const M=new Ce(a,this);this.activeControl=M;const f=d?d.split(","):[];M.setSelect(f,T,O)}else if(h===c.ControlType.RADIO){if(Array.isArray(d))continue;const M=new On(a,this);this.activeControl=M;const f=d?[d]:[];M.setSelect(f,T,O)}else if(h===c.ControlType.DATE){const M=new Se(a,this);this.activeControl=M,_e(d)?(d.length&&Mt(d,{isHandleFirstElement:!1,editorOptions:this.options}),M.setValue(d,T,O)):lo(d)?M.setSelect(d,T,O):M.clearSelect(T,O)}else if(h===c.ControlType.NUMBER){const M=Array.isArray(d)?d:d?[{value:d}]:[];M.length&&Mt(M,{isHandleFirstElement:!1,editorOptions:this.options});const f=new me(a,this);this.activeControl=f,M.length?f.setValue(M,T,O):f.clearValue(T,O)}this.emitControlContentChange({context:T}),this.activeControl=null;let P=l;for(;P<s.length&&s[P].controlId===a.controlId;)P++;l=P}};this.destroyControl({isEmitEvent:!1});const r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const s of r)i(s);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}setExtensionListById(t){if(!t.length)return;const e=i=>{let r=0;for(;r<i.length;){const s=i[r];if(r++,s.type===c.ElementType.TABLE){const d=s.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];e(L.value)}}}if(!s.control)continue;const l=t.find(d=>{var u;return(!d.groupId||d.groupId===((u=s.control)==null?void 0:u.groupId))&&(d.id&&s.controlId===d.id||d.conceptId&&s.control.conceptId===d.conceptId||d.areaId&&s.areaId===d.areaId)});if(!l)continue;const{extension:a}=l;this.setControlProperties({extension:a},{elementList:i,range:{startIndex:r,endIndex:r}});let R=r;for(;R<i.length&&i[R].controlId===s.controlId;)R++;r=R}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i)}setPropertiesListById(t){if(!t.length)return;let e=!1,n=!1;const i=s=>{let l=0;for(;l<s.length;){const a=s[l];if(l++,a.type===c.ElementType.TABLE){const g=a.trList;for(let L=0;L<g.length;L++){const T=g[L];for(let O=0;O<T.tdList.length;O++){const P=T.tdList[O];i(P.value)}}}if(!a.control)continue;const R=t.find(g=>{var L;return(!g.groupId||g.groupId===((L=a.control)==null?void 0:L.groupId))&&(g.id&&a.controlId===g.id||g.conceptId&&a.control.conceptId===g.conceptId||g.areaId&&a.areaId===g.areaId)});if(!R)continue;const{properties:d,isSubmitHistory:u=!0}=R;e=!0,u&&(n=!0),this.setControlProperties({...a.control,...d,value:a.control.value},{elementList:s,range:{startIndex:l,endIndex:l}}),Gt.forEach(g=>{const L=d[g];L&&Reflect.set(a,g,L)});let h=l;for(;h<s.length&&s[h].controlId===a.controlId;)h++;l=h}},r={header:this.draw.getHeaderElementList(),main:this.draw.getOriginalMainElementList(),footer:this.draw.getFooterElementList()};for(const s in r){const l=r[s];i(l)}if(!!e){for(const s in r){const l=s,a=rt(r[l],{isClassifyArea:!0,extraPickAttrs:["id"]});r[l]=a,Mt(a,{editorOptions:this.options,isForceCompensation:!0})}this.draw.setEditorData(r),n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1})}}getList(){const t=[];function e(i){for(let r=0;r<i.length;r++){const s=i[r];if(s.type===c.ElementType.TABLE){const l=s.trList;for(let a=0;a<l.length;a++){const R=l[a];for(let d=0;d<R.tdList.length;d++){const h=R.tdList[d].value;e(h)}}}if(s.controlId){const l=wt(s,[...qe,...We]);t.push(l)}}}const n=[this.draw.getHeader().getElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooter().getElementList()];for(const i of n)e(i);return rt(t,{extraPickAttrs:["controlId"]})}recordBorderInfo(t,e,n,i){this.controlBorder.recordBorderInfo(t,e,n,i)}drawBorder(t){this.controlBorder.render(t)}getPreControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function i(a,R){for(let d=R;d>0;d--){const u=a[d];if(u.type===c.ElementType.TABLE){const g=u.trList||[];for(let L=g.length-1;L>=0;L--){const T=g[L],O=T.tdList;for(let P=O.length-1;P>=0;P--){const M=O[P],f=i(M.value,M.value.length-1);if(f)return{positionContext:{isTable:!0,index:d,trIndex:L,tdIndex:P,tdId:M.id,trId:T.id,tableId:u.id},nextIndex:f.nextIndex}}}}if(!u.controlId||u.controlId===n.controlId)continue;let h=d;for(;h>0;){const g=a[h];if(g.controlComponent===c.ControlComponent.VALUE||g.controlComponent===c.ControlComponent.PREFIX||g.controlComponent===c.ControlComponent.PRE_TEXT)break;h--}return{positionContext:{isTable:!1},nextIndex:h}}return null}const{startIndex:r}=this.range.getRange(),s=this.getElementList(),l=i(s,r);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:R,trIndex:d,tdIndex:u}=e,h=a[R].trList;for(let L=d;L>=0;L--){const T=h[L],O=T.tdList;for(let P=O.length-1;P>=0;P--){if(d===L&&P>=u)continue;const M=O[P],f=i(M.value,M.value.length-1);if(f)return{positionContext:{isTable:!0,index:e.index,trIndex:L,tdIndex:P,tdId:M.id,trId:T.id,tableId:n.tableId},nextIndex:f.nextIndex}}}const g=i(a,R-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 n=this.activeControl.getElement();function i(a,R){var d,u;for(let h=R;h<a.length;h++){const g=a[h];if(g.type===c.ElementType.TABLE){const L=g.trList||[];for(let T=0;T<L.length;T++){const O=L[T],P=O.tdList;for(let M=0;M<P.length;M++){const f=P[M],S=i(f.value,0);if(S)return{positionContext:{isTable:!0,index:h,trIndex:T,tdIndex:M,tdId:f.id,trId:O.id,tableId:g.id},nextIndex:S.nextIndex}}}}if(!(!g.controlId||g.controlId===n.controlId||((d=a[h+1])==null?void 0:d.controlComponent)===c.ControlComponent.PREFIX||((u=a[h+1])==null?void 0:u.controlComponent)===c.ControlComponent.PRE_TEXT))return{positionContext:{isTable:!1},nextIndex:h}}return null}const{endIndex:r}=this.range.getRange(),s=this.getElementList(),l=i(s,r);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:R,trIndex:d,tdIndex:u}=e,h=a[R].trList;for(let L=d;L<h.length;L++){const T=h[L],O=T.tdList;for(let P=0;P<O.length;P++){if(d===L&&P<=u)continue;const M=O[P],f=i(M.value,0);if(f)return{positionContext:{isTable:!0,index:e.index,trIndex:L,tdIndex:P,tdId:M.id,trId:T.id,tableId:n.tableId},nextIndex:f.nextIndex}}}const g=i(a,R+1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}initNextControl(t={}){const{direction:e=Pt.DOWN}=t;let n=null;if(e===Pt.UP?n=this.getPreControlContext():n=this.getNextControlContext(),!n)return;const{nextIndex:i,positionContext:r}=n;this.draw.getPosition().setPositionContext(r),this.draw.getRange().replaceRange({startIndex:i,endIndex:i}),this.draw.render({curIndex:i,isCompute:!1,isSetCursor:!0,isSubmitHistory:!1})}setMinWidthControlInfo(t){var d,u,h,g,L;const{row:e,rowElement:n,controlRealWidth:i,availableWidth:r}=t;if(!((d=n.control)!=null&&d.minWidth))return;const{scale:s}=this.options,l=n.control.minWidth*s;let a=null;if(((u=n.control)==null?void 0:u.minWidth)&&(((h=n.control)==null?void 0:h.rowFlex)===c.RowFlex.CENTER||((g=n.control)==null?void 0:g.rowFlex)===c.RowFlex.RIGHT)){let T=n.metrics.width,O=e.elementList.length-1;for(;O>=0;){const P=e.elementList[O];if(T+=P.metrics.width,((L=e.elementList[O-1])==null?void 0:L.controlComponent)===c.ControlComponent.PREFIX){a=P;break}O--}a&&T<l&&(n.control.rowFlex===c.RowFlex.CENTER?a.left=(l-T)/2:n.control.rowFlex===c.RowFlex.RIGHT&&(a.left=l-T-n.metrics.width))}const R=l-i;if(R>0){const T=(a==null?void 0:a.left)||0,O=r-e.width-n.metrics.width,P=Math.min(O,R);n.left=P-T,e.width+=P-T}}}class Yr{constructor(t){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:n,index:i,row:r}=t;let{y:s}=t;const{checkbox:{gap:l,lineWidth:a,fillStyle:R,strokeStyle:d,verticalAlign:u},scale:h}=this.options,{metrics:g,checkbox:L}=r.elementList[i];if(u===c.VerticalAlign.TOP||u===c.VerticalAlign.MIDDLE){let f=i+1,S=null;for(;f<r.elementList.length&&(S=r.elementList[f],!(S.value!==w&&S.value!==Je));)f++;if(S){const{metrics:{boundingBoxAscent:I,boundingBoxDescent:m}}=S,N=I+m;N>g.height&&(u===c.VerticalAlign.TOP?s-=I-g.height:u===c.VerticalAlign.MIDDLE&&(s-=(N-g.height)/2))}}const T=Math.round(n+l*h),O=Math.round(s-g.height+a),P=g.width-l*2*h,M=g.height;e.save(),e.beginPath(),e.translate(.5,.5),L!=null&&L.value?(e.lineWidth=a,e.strokeStyle="red",e.rect(T,O,P,M),e.stroke(),e.beginPath(),e.fillStyle=R,e.fillRect(T,O,P,M),e.beginPath(),e.strokeStyle=d,e.lineWidth=a*2*h,e.moveTo(T+2*h,O+M/2),e.lineTo(T+P/2,O+M-3*h),e.lineTo(T+P-2*h,O+3*h),e.stroke()):(e.lineWidth=a,e.strokeStyle="red",e.rect(T,O,P,M),e.stroke());debugger;e.closePath(),e.restore()}}class Zr{constructor(t){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:n,index:i,row:r}=t;let{y:s}=t;const{radio:{gap:l,lineWidth:a,fillStyle:R,strokeStyle:d,verticalAlign:u},scale:h}=this.options,{metrics:g,radio:L}=r.elementList[i];if(u===c.VerticalAlign.TOP||u===c.VerticalAlign.MIDDLE){let f=i+1,S=null;for(;f<r.elementList.length&&(S=r.elementList[f],!(S.value!==w&&S.value!==Je));)f++;if(S){const{metrics:{boundingBoxAscent:I,boundingBoxDescent:m}}=S,N=I+m;N>g.height&&(u===c.VerticalAlign.TOP?s-=I-g.height:u===c.VerticalAlign.MIDDLE&&(s-=(N-g.height)/2))}}const T=Math.round(n+l*h),O=Math.round(s-g.height+a),P=g.width-l*2*h,M=g.height;e.save(),e.beginPath(),e.translate(.5,.5),e.strokeStyle=L!=null&&L.value?R:d,e.lineWidth=a,e.arc(T+P/2,O+M/2,P/2,0,Math.PI*2),e.stroke(),L!=null&&L.value&&(e.beginPath(),e.fillStyle=R,e.arc(T+P/2,O+M/2,P/3,0,Math.PI*2),e.fill()),e.closePath(),e.restore()}}const ui="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHA9Ilx1MjAwQiIsdT1gCmA7ZnVuY3Rpb24gYShpKXt2YXIgYyxmO2xldCBsPSIiLG49MDtmb3IoO248aS5sZW5ndGg7KXtjb25zdCB0PWlbbl07aWYodC50eXBlPT09InRhYmxlIil7aWYodC50ckxpc3QpZm9yKGxldCBzPTA7czx0LnRyTGlzdC5sZW5ndGg7cysrKXtjb25zdCBvPXQudHJMaXN0W3NdO2ZvcihsZXQgZT0wO2U8by50ZExpc3QubGVuZ3RoO2UrKyl7Y29uc3Qgcj1vLnRkTGlzdFtlXTtsKz1hKHIudmFsdWUpfX19ZWxzZSBpZih0LnR5cGU9PT0iaHlwZXJsaW5rIil7Y29uc3Qgcz10Lmh5cGVybGlua0lkLG89W107Zm9yKDtuPGkubGVuZ3RoOyl7Y29uc3QgZT1pW25dO2lmKHMhPT1lLmh5cGVybGlua0lkKXtuLS07YnJlYWt9ZGVsZXRlIGUudHlwZSxvLnB1c2goZSksbisrfWwrPWEobyl9ZWxzZSBpZih0LmNvbnRyb2xJZCl7aWYoISgoYz10LmNvbnRyb2wpIT1udWxsJiZjLmhpZGUpKXtjb25zdCBzPXQuY29udHJvbElkLG89W107Zm9yKDtuPGkubGVuZ3RoOyl7Y29uc3QgZT1pW25dO2lmKHMhPT1lLmNvbnRyb2xJZCl7bi0tO2JyZWFrfWUuY29udHJvbENvbXBvbmVudD09PSJ2YWx1ZSImJihkZWxldGUgZS5jb250cm9sSWQsby5wdXNoKGUpKSxuKyt9bCs9YShvKX19ZWxzZSghdC50eXBlfHx0LnR5cGU9PT0idGV4dCIpJiYhKChmPXQuYXJlYSkhPW51bGwmJmYuaGlkZSkmJihsKz10LnZhbHVlKTtuKyt9cmV0dXJuIGx9ZnVuY3Rpb24gaChpKXtjb25zdCBsPVtdLG49L1swLTldLyxjPS9bQS1aYS16XS8sZj0vXHMvO2xldCB0PSExLHM9ITEsbz0iIjtmdW5jdGlvbiBlKCl7byYmKGwucHVzaChvKSxvPSIiKX1mb3IoY29uc3QgciBvZiBpKWMudGVzdChyKT8odHx8ZSgpLG8rPXIsdD0hMCxzPSExKTpuLnRlc3Qocik/KHN8fGUoKSxvKz1yLHQ9ITEscz0hMCk6KGUoKSx0PSExLHM9ITEsZi50ZXN0KHIpfHxsLnB1c2gocikpO3JldHVybiBlKCksbH1vbm1lc3NhZ2U9aT0+e2NvbnN0IGw9aS5kYXRhLGM9YShsKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke3B9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChwLCJnIiksdSksZj1oKGMpO3Bvc3RNZXNzYWdlKGYubGVuZ3RoKX19KSgpOwo=",hi=typeof window!="undefined"&&window.Blob&&new Blob([atob(ui)],{type:"text/javascript;charset=utf-8"});function Ur(){const o=hi&&(window.URL||window.webkitURL).createObjectURL(hi);try{return o?new Worker(o,{}):new Worker("data:application/javascript;base64,"+ui,{type:"module"})}finally{o&&(window.URL||window.webkitURL).revokeObjectURL(o)}}const gi="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGg9e2ZpcnN0OjEsc2Vjb25kOjIsdGhpcmQ6Myxmb3VydGg6NCxmaWZ0aDo1LHNpeHRoOjZ9LGI9WyJ0ZXh0IiwiaHlwZXJsaW5rIiwic3Vic2NyaXB0Iiwic3VwZXJzY3JpcHQiLCJjb250cm9sIiwiZGF0ZSIsImxhYmVsIl0sbT0iXHUyMDBCIjtmdW5jdGlvbiBJKGMpe3JldHVybiFjLnR5cGV8fGIuaW5jbHVkZXMoYy50eXBlKX1mdW5jdGlvbiBOKGMpe3ZhciBFO2NvbnN0e2VsZW1lbnRMaXN0OmcscG9zaXRpb25MaXN0OmR9PWMscD1bXTtsZXQgcj0wO2Zvcig7cjxnLmxlbmd0aDspe2NvbnN0IHQ9Z1tyXSxsPShlLG4scyk9Pntjb25zdCB1PWUudGl0bGVJZCxMPWUubGV2ZWwsaT17dHlwZToidGl0bGUiLHZhbHVlOiIiLGxldmVsOkwsdGl0bGVJZDp1LHBhZ2VObzpkW3JdLnBhZ2VOb30sbz1bXTtmb3IoO3M8bi5sZW5ndGg7KXtjb25zdCBhPW5bc107aWYodSE9PWEudGl0bGVJZCl7cy0tO2JyZWFrfW8ucHVzaChhKSxzKyt9cmV0dXJuIGkudmFsdWU9by5maWx0ZXIoYT0+SShhKSkubWFwKGE9PmEudmFsdWUpLmpvaW4oIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChtLCJnIiksIiIpLHtwb3NpdGlvbjpzLHRpdGxlRWxlbWVudDppfX07aWYodC50aXRsZUlkKXtjb25zdHtwb3NpdGlvbjplLHRpdGxlRWxlbWVudDpufT1sKHQsZyxyKTtyPWUscC5wdXNoKG4pfWlmKHQudHlwZT09PSJ0YWJsZSIpe2NvbnN0IGU9dC50ckxpc3Q7Zm9yKGxldCBuPTA7bjxlLmxlbmd0aDtuKyspe2NvbnN0IHM9ZVtuXTtmb3IobGV0IHU9MDt1PHMudGRMaXN0Lmxlbmd0aDt1Kyspe2NvbnN0IGk9cy50ZExpc3RbdV0udmFsdWU7aWYoaS5sZW5ndGg+MSl7bGV0IG89MTtmb3IoO288aS5sZW5ndGg7KXtpZigoRT1pW29dKSE9bnVsbCYmRS50aXRsZUlkKXtjb25zdHt0aXRsZUVsZW1lbnQ6YSxwb3NpdGlvbjp5fT1sKGlbb10saSxvKTtwLnB1c2goYSksbz15fW8rK319fX19cisrfWlmKCFwLmxlbmd0aClyZXR1cm4gbnVsbDtjb25zdCBmPSh0LGwpPT57Y29uc3QgZT1sLnN1YkNhdGFsb2dbbC5zdWJDYXRhbG9nLmxlbmd0aC0xXSxuPWhbZT09bnVsbD92b2lkIDA6ZS5sZXZlbF0scz1oW3QubGV2ZWxdO2UmJnM+bj9mKHQsZSk6bC5zdWJDYXRhbG9nLnB1c2goe2lkOnQudGl0bGVJZCxuYW1lOnQudmFsdWUsbGV2ZWw6dC5sZXZlbCxwYWdlTm86dC5wYWdlTm8sc3ViQ2F0YWxvZzpbXX0pfSx2PVtdO2ZvcihsZXQgdD0wO3Q8cC5sZW5ndGg7dCsrKXtjb25zdCBsPXBbdF0sZT12W3YubGVuZ3RoLTFdLG49aFtlPT1udWxsP3ZvaWQgMDplLmxldmVsXSxzPWhbbC5sZXZlbF07ZSYmcz5uP2YobCxlKTp2LnB1c2goe2lkOmwudGl0bGVJZCxuYW1lOmwudmFsdWUsbGV2ZWw6bC5sZXZlbCxwYWdlTm86bC5wYWdlTm8sc3ViQ2F0YWxvZzpbXX0pfXJldHVybiB2fW9ubWVzc2FnZT1jPT57Y29uc3QgZz1jLmRhdGEsZD1OKGcpO3Bvc3RNZXNzYWdlKGQpfX0pKCk7Cg==",Li=typeof window!="undefined"&&window.Blob&&new Blob([atob(gi)],{type:"text/javascript;charset=utf-8"});function Er(){const o=Li&&(window.URL||window.webkitURL).createObjectURL(Li);try{return o?new Worker(o,{}):new Worker("data:application/javascript;base64,"+gi,{type:"module"})}finally{o&&(window.URL||window.webkitURL).revokeObjectURL(o)}}const Ti="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHUoZSl7Y29uc3QgdD1bXTtmb3IoY29uc3QgcyBvZiBlKXtpZihzLnR5cGU9PT0idGFibGUiKXtjb25zdCBvPXMudHJMaXN0O2ZvcihsZXQgbj0wO248by5sZW5ndGg7bisrKXtjb25zdCBjPW9bbl07Zm9yKGxldCByPTA7cjxjLnRkTGlzdC5sZW5ndGg7cisrKXtjb25zdCBpPWMudGRMaXN0W3JdO3QucHVzaCguLi51KGkudmFsdWUpKX19fWlmKCEhcy5ncm91cElkcylmb3IoY29uc3QgbyBvZiBzLmdyb3VwSWRzKXQuaW5jbHVkZXMobyl8fHQucHVzaChvKX1yZXR1cm4gdH1vbm1lc3NhZ2U9ZT0+e2NvbnN0IHQ9ZS5kYXRhLHM9dSh0KTtwb3N0TWVzc2FnZShzKX19KSgpOwo=",Pi=typeof window!="undefined"&&window.Blob&&new Blob([atob(Ti)],{type:"text/javascript;charset=utf-8"});function Cr(){const o=Pi&&(window.URL||window.webkitURL).createObjectURL(Pi);try{return o?new Worker(o,{}):new Worker("data:application/javascript;base64,"+Ti,{type:"module"})}finally{o&&(window.URL||window.webkitURL).revokeObjectURL(o)}}const Oi="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBSPShlPT4oZS5IQUxGPSJoYWxmIixlLk9ORV9USElSRD0ib25lLXRoaXJkIixlLlFVQVJURVI9InF1YXJ0ZXIiLGUpKShSfHx7fSksZz0oZT0+KGUuQVJBQklDPSJhcmFiaWMiLGUuQ0hJTkVTRT0iY2hpbmVzZSIsZSkpKGd8fHt9KSxtPShlPT4oZS5JTkxJTkU9ImlubGluZSIsZS5CTE9DSz0iYmxvY2siLGUuU1VSUk9VTkQ9InN1cnJvdW5kIixlLkZMT0FUX1RPUD0iZmxvYXQtdG9wIixlLkZMT0FUX0JPVFRPTT0iZmxvYXQtYm90dG9tIixlKSkobXx8e30pO2NvbnN0IHY9Ilx1MjAwQiI7Ui5IQUxGKyIiLDEvMixSLk9ORV9USElSRCsiIiwxLzMsUi5RVUFSVEVSKyIiLDEvNDtmdW5jdGlvbiBTKGUpe2lmKHR5cGVvZiBzdHJ1Y3R1cmVkQ2xvbmU9PSJmdW5jdGlvbiIpcmV0dXJuIHN0cnVjdHVyZWRDbG9uZShlKTtpZighZXx8dHlwZW9mIGUhPSJvYmplY3QiKXJldHVybiBlO2xldCBvPXt9O3JldHVybiBBcnJheS5pc0FycmF5KGUpP289ZS5tYXAoZD0+UyhkKSk6T2JqZWN0LmtleXMoZSkuZm9yRWFjaChkPT57b1tkXT1TKGVbZF0pfSksb31mdW5jdGlvbiBOKGUsbyl7Y29uc3QgZD17fTtmb3IoY29uc3QgZiBpbiBlKW8uaW5jbHVkZXMoZikmJihkW2ZdPWVbZl0pO3JldHVybiBkfWZ1bmN0aW9uIF8oZSxvKXtyZXR1cm4gZS5sZW5ndGghPT1vLmxlbmd0aD8hMTohZS5zb21lKGQ9PiFvLmluY2x1ZGVzKGQpKX12YXIgYT0oZT0+KGUuVEVYVD0idGV4dCIsZS5JTUFHRT0iaW1hZ2UiLGUuVEFCTEU9InRhYmxlIixlLkhZUEVSTElOSz0iaHlwZXJsaW5rIixlLlNVUEVSU0NSSVBUPSJzdXBlcnNjcmlwdCIsZS5TVUJTQ1JJUFQ9InN1YnNjcmlwdCIsZS5TRVBBUkFUT1I9InNlcGFyYXRvciIsZS5QQUdFX0JSRUFLPSJwYWdlQnJlYWsiLGUuQ09OVFJPTD0iY29udHJvbCIsZS5BUkVBPSJhcmVhIixlLkNIRUNLQk9YPSJjaGVja2JveCIsZS5SQURJTz0icmFkaW8iLGUuTEFURVg9ImxhdGV4IixlLlRBQj0idGFiIixlLkRBVEU9ImRhdGUiLGUuQkxPQ0s9ImJsb2NrIixlLlRJVExFPSJ0aXRsZSIsZS5MSVNUPSJsaXN0IixlLkxBQkVMPSJsYWJlbCIsZSkpKGF8fHt9KTtjb25zdCBCPVsicm93RmxleCIsInJvd01hcmdpbiIsInRleHRJbmRlbnQiLCJtYXJnaW5MZWZ0IiwibWFyZ2luUmlnaHQiLCJtYXJnaW5Ub3AiLCJtaW5IZWlnaHQiLCJ3aGl0ZVNwYWNlIl0sVT1bInR5cGUiLCJmb250Iiwic2l6ZSIsImJvbGQiLCJjb2xvciIsIml0YWxpYyIsImhpZ2hsaWdodCIsInVuZGVybGluZSIsInN0cmlrZW91dCIsInJvd0ZsZXgiLCJyb3dNYXJnaW4iLCJ0ZXh0SW5kZW50IiwibWFyZ2luTGVmdCIsIm1hcmdpblJpZ2h0IiwibWFyZ2luVG9wIiwibWluSGVpZ2h0Iiwid2hpdGVTcGFjZSIsImRhc2hBcnJheSIsInRyTGlzdCIsInRhYmxlVG9vbERpc2FibGVkIiwiYm9yZGVyVHlwZSIsImJvcmRlckNvbG9yIiwidHJhbnNsYXRlWCIsIndpZHRoIiwiaGVpZ2h0IiwidXJsIiwiY29sZ3JvdXAiLCJ2YWx1ZUxpc3QiLCJjb250cm9sIiwiY2hlY2tib3giLCJyYWRpbyIsImRhdGVGb3JtYXQiLCJibG9jayIsImxldmVsIiwidGl0bGUiLCJsaXN0VHlwZSIsImxpc3RTdHlsZSIsImxpc3RXcmFwIiwiZ3JvdXBJZHMiLCJjb25jZXB0SWQiLCJpbWdEaXNwbGF5IiwiaW1nRmxvYXRQb3NpdGlvbiIsImltZ1Rvb2xEaXNhYmxlZCIsImltZ1ByZXZpZXdEaXNhYmxlZCIsImltZ0Nyb3AiLCJpbWdDYXB0aW9uIiwidGV4dERlY29yYXRpb24iLCJleHRlbnNpb24iLCJleHRlcm5hbElkIiwiYXJlYUlkIiwiYXJlYSIsImhpZGUiLCJsYWJlbCIsImxhYmVsSWQiLCJsaW5lV2lkdGgiLCJmb3JtSW5wdXQiXSx3PVsiY29uY2VwdElkIiwiZXh0ZW5zaW9uIiwiZXh0ZXJuYWxJZCIsInZlcnRpY2FsQWxpZ24iLCJiYWNrZ3JvdW5kQ29sb3IiLCJib3JkZXJUeXBlcyIsInNsYXNoVHlwZXMiLCJkaXNhYmxlZCIsImRlbGV0YWJsZSJdLEs9WyJmb250Iiwic2l6ZSIsImJvbGQiLCJoaWdobGlnaHQiLCJpdGFsaWMiLCJzdHJpa2VvdXQiXTthLlRFWFQsYS5IWVBFUkxJTkssYS5TVUJTQ1JJUFQsYS5TVVBFUlNDUklQVCxhLkNPTlRST0wsYS5EQVRFLGEuSU1BR0UsYS5MQVRFWCxhLkJMT0NLLGEuUEFHRV9CUkVBSyxhLlNFUEFSQVRPUixhLlRBQkxFLGEuVElUTEUsYS5MSVNUO3ZhciBiPShlPT4oZS5VTD0idWwiLGUuT0w9Im9sIixlKSkoYnx8e30pLEw9KGU9PihlLkRJU0M9ImRpc2MiLGUuQ0lSQ0xFPSJjaXJjbGUiLGUuU1FVQVJFPSJzcXVhcmUiLGUuQ0hFQ0tCT1g9ImNoZWNrYm94IixlKSkoTHx8e30pLE89KGU9PihlLkRJU0M9ImRpc2MiLGUuQ0lSQ0xFPSJjaXJjbGUiLGUuU1FVQVJFPSJzcXVhcmUiLGUuREVDSU1BTD0iZGVjaW1hbCIsZS5DSEVDS0JPWD0iY2hlY2tib3giLGUpKShPfHx7fSk7TC5ESVNDKyIiLEwuQ0lSQ0xFKyIiLEwuU1FVQVJFKyIiLEwuQ0hFQ0tCT1grIiIsYi5PTCsiIixiLlVMKyIiLE8uRElTQysiIixPLkNJUkNMRSsiIixPLlNRVUFSRSsiIixPLkRFQ0lNQUwrIiIsTy5DSEVDS0JPWCsiIjt2YXIgRT0oZT0+KGUuRklSU1Q9ImZpcnN0IixlLlNFQ09ORD0ic2Vjb25kIixlLlRISVJEPSJ0aGlyZCIsZS5GT1VSVEg9ImZvdXJ0aCIsZS5GSUZUSD0iZmlmdGgiLGUuU0lYVEg9InNpeHRoIixlKSkoRXx8e30pO0UuRklSU1QrIiIsRS5TRUNPTkQrIiIsRS5USElSRCsiIixFLkZPVVJUSCsiIixFLkZJRlRIKyIiLEUuU0lYVEgrIiIsRS5GSVJTVCsiIixFLlNFQ09ORCsiIixFLlRISVJEKyIiLEUuRk9VUlRIKyIiLEUuRklGVEgrIiIsRS5TSVhUSCsiIixFLkZJUlNULEUuU0VDT05ELEUuVEhJUkQsRS5GT1VSVEgsRS5GSUZUSCxFLlNJWFRIO3ZhciBBPShlPT4oZS5QUkVGSVg9InByZWZpeCIsZS5QT1NURklYPSJwb3N0Zml4IixlLlBSRV9URVhUPSJwcmVUZXh0IixlLlBPU1RfVEVYVD0icG9zdFRleHQiLGUuUExBQ0VIT0xERVI9InBsYWNlaG9sZGVyIixlLlZBTFVFPSJ2YWx1ZSIsZS5DSEVDS0JPWD0iY2hlY2tib3giLGUuUkFESU89InJhZGlvIixlKSkoQXx8e30pLHk9KGU9PihlLkxFRlQ9ImxlZnQiLGUuQ0VOVEVSPSJjZW50ZXIiLGUuUklHSFQ9InJpZ2h0IixlLkFMSUdOTUVOVD0iYWxpZ25tZW50IixlLkpVU1RJRlk9Imp1c3RpZnkiLGUpKSh5fHx7fSksaz0oZT0+KGUuQ09OVEFJTj0iY29udGFpbiIsZS5DT1ZFUj0iY292ZXIiLGUpKShrfHx7fSksRD0oZT0+KGUuUkVQRUFUPSJyZXBlYXQiLGUuTk9fUkVQRUFUPSJuby1yZXBlYXQiLGUuUkVQRUFUX1g9InJlcGVhdC14IixlLlJFUEVBVF9ZPSJyZXBlYXQteSIsZSkpKER8fHt9KTtrLkNPVkVSLEQuTk9fUkVQRUFUO3ZhciBQPShlPT4oZS5UT1A9InRvcCIsZS5NSURETEU9Im1pZGRsZSIsZS5CT1RUT009ImJvdHRvbSIsZSkpKFB8fHt9KTtQLkJPVFRPTSxSLkhBTEYsUi5IQUxGO2NvbnN0IE09e1BBR0VfTk86IntwYWdlTm99IixQQUdFX0NPVU5UOiJ7cGFnZUNvdW50fSJ9O3kuQ0VOVEVSLE0uUEFHRV9OTyxnLkFSQUJJQyxQLkJPVFRPTTt2YXIgeD0oZT0+KGUuVEVYVD0idGV4dCIsZS5JTUFHRT0iaW1hZ2UiLGUpKSh4fHx7fSk7eC5URVhULGcuQVJBQklDO3ZhciBYPShlPT4oZS5QQUdFPSJwYWdlIixlLkNPTlRJTlVJVFk9ImNvbnRpbnVpdHkiLGUpKShYfHx7fSk7WC5DT05USU5VSVRZO2Z1bmN0aW9uIHooZSxvKXtjb25zdCBkPU9iamVjdC5rZXlzKGUpLGY9T2JqZWN0LmtleXMobyk7aWYoZC5sZW5ndGghPT1mLmxlbmd0aClyZXR1cm4hMTtmb3IobGV0IFQ9MDtUPGQubGVuZ3RoO1QrKyl7Y29uc3QgbD1kW1RdO2lmKGwhPT0idmFsdWUiJiYhKGw9PT0iZ3JvdXBJZHMiJiZBcnJheS5pc0FycmF5KGVbbF0pJiZBcnJheS5pc0FycmF5KG9bbF0pJiZfKGVbbF0sb1tsXSkpJiZlW2xdIT09b1tsXSlyZXR1cm4hMX1yZXR1cm4hMH1mdW5jdGlvbiBIKGUsbz17fSl7Y29uc3R7ZXh0cmFQaWNrQXR0cnM6ZH09byxmPVsuLi5VXTtkJiZmLnB1c2goLi4uZCk7Y29uc3QgVD17dmFsdWU6ZS52YWx1ZT09PXY/YApgOmUudmFsdWV9O3JldHVybiBmLmZvckVhY2gobD0+e2NvbnN0IHA9ZVtsXTtwIT09dm9pZCAwJiYoVFtsXT1wKX0pLFR9ZnVuY3Rpb24gSShlLG89e30pe2NvbnN0e2V4dHJhUGlja0F0dHJzOmQsaXNDbGFzc2lmeUFyZWE6Zj0hMSxpc0Nsb25lOlQ9ITB9PW8sbD1UP1MoZSk6ZSxwPVtdO2xldCBpPTA7Zm9yKDtpPGwubGVuZ3RoOyl7bGV0IHQ9bFtpXTtpZihpPT09MCYmdC52YWx1ZT09PXYmJiF0Lmxpc3RJZCYmKCF0LnR5cGV8fHQudHlwZT09PWEuVEVYVCkpe2krKztjb250aW51ZX1pZih0LmFyZWFJZCl7Y29uc3Qgcj10LmFyZWFJZCx1PXQuYXJlYSxjPVtdO2Zvcig7aTxsLmxlbmd0aDspe2NvbnN0IHM9bFtpXTtpZihyIT09cy5hcmVhSWQpe2ktLTticmVha31kZWxldGUgcy5hcmVhLGRlbGV0ZSBzLmFyZWFJZCxjLnB1c2gocyksaSsrfWNvbnN0IG49SShjLG8pO2lmKGYpe2NvbnN0IHM9e3R5cGU6YS5BUkVBLHZhbHVlOiIiLGFyZWFJZDpyLGFyZWE6dX07cy52YWx1ZUxpc3Q9bix0PXN9ZWxzZXtwLnNwbGljZShpLDAsLi4ubik7Y29udGludWV9fWVsc2UgaWYodC50aXRsZUlkJiZ0LmxldmVsKXtjb25zdCByPXQudGl0bGVJZDtpZihyKXtjb25zdCB1PXQubGV2ZWwsYz17dHlwZTphLlRJVExFLHRpdGxlOnQudGl0bGUsdGl0bGVJZDpyLHZhbHVlOiIiLGxldmVsOnV9LG49W107Zm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgcz1sW2ldO2lmKHIhPT1zLnRpdGxlSWQpe2ktLTticmVha31kZWxldGUgcy5sZXZlbCxkZWxldGUgcy50aXRsZSxuLnB1c2gocyksaSsrfWMudmFsdWVMaXN0PUkobixvKSx0PWN9fWVsc2UgaWYodC5saXN0SWQmJnQubGlzdFR5cGUpe2NvbnN0IHI9dC5saXN0SWQ7aWYocil7Y29uc3QgdT10Lmxpc3RUeXBlLGM9dC5saXN0U3R5bGUsbj17dHlwZTphLkxJU1QsdmFsdWU6IiIsbGlzdElkOnIsbGlzdFR5cGU6dSxsaXN0U3R5bGU6Y30scz1bXTtmb3IoO2k8bC5sZW5ndGg7KXtjb25zdCBoPWxbaV07aWYociE9PWgubGlzdElkKXtpLS07YnJlYWt9ZGVsZXRlIGgubGlzdFR5cGUsZGVsZXRlIGgubGlzdFN0eWxlLHMucHVzaChoKSxpKyt9bi52YWx1ZUxpc3Q9SShzLG8pLHQ9bn19ZWxzZSBpZih0LnR5cGU9PT1hLlRBQkxFKXtpZih0LnBhZ2luZ0lkKXtsZXQgcj1pKzEsdT0wO2Zvcig7cjxsLmxlbmd0aDspe2NvbnN0IGM9bFtyXTtpZihjLnBhZ2luZ0lkPT09dC5wYWdpbmdJZCl0LmhlaWdodCs9Yy5oZWlnaHQsdC50ckxpc3QucHVzaCguLi5jLnRyTGlzdCkscisrLHUrKztlbHNlIGJyZWFrfWkrPXV9aWYodC50ckxpc3QpZm9yKGxldCByPTA7cjx0LnRyTGlzdC5sZW5ndGg7cisrKXtjb25zdCB1PXQudHJMaXN0W3JdO2RlbGV0ZSB1LmlkO2ZvcihsZXQgYz0wO2M8dS50ZExpc3QubGVuZ3RoO2MrKyl7Y29uc3Qgbj11LnRkTGlzdFtjXSxzPXtjb2xzcGFuOm4uY29sc3Bhbixyb3dzcGFuOm4ucm93c3Bhbix2YWx1ZTpJKG4udmFsdWUsey4uLm8saXNDbGFzc2lmeUFyZWE6ITF9KX07dy5mb3JFYWNoKGg9Pntjb25zdCBDPW5baF07QyE9PXZvaWQgMCYmKHNbaF09Qyl9KSx1LnRkTGlzdFtjXT1zfX19ZWxzZSBpZih0LnR5cGU9PT1hLkhZUEVSTElOSyl7Y29uc3Qgcj10Lmh5cGVybGlua0lkO2lmKHIpe2NvbnN0IHU9e3R5cGU6YS5IWVBFUkxJTkssdmFsdWU6IiIsdXJsOnQudXJsfSxjPVtdO2Zvcig7aTxsLmxlbmd0aDspe2NvbnN0IG49bFtpXTtpZihyIT09bi5oeXBlcmxpbmtJZCl7aS0tO2JyZWFrfWRlbGV0ZSBuLnR5cGUsZGVsZXRlIG4udXJsLGMucHVzaChuKSxpKyt9dS52YWx1ZUxpc3Q9SShjLG8pLHQ9dX19ZWxzZSBpZih0LnR5cGU9PT1hLkRBVEUpe2NvbnN0IHI9dC5kYXRlSWQ7aWYocil7Y29uc3QgdT17dHlwZTphLkRBVEUsdmFsdWU6IiIsZGF0ZUZvcm1hdDp0LmRhdGVGb3JtYXR9LGM9W107Zm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgbj1sW2ldO2lmKHIhPT1uLmRhdGVJZCl7aS0tO2JyZWFrfWRlbGV0ZSBuLnR5cGUsZGVsZXRlIG4uZGF0ZUZvcm1hdCxjLnB1c2gobiksaSsrfXUudmFsdWVMaXN0PUkoYyxvKSx0PXV9fWVsc2UgaWYodC5jb250cm9sSWQpe2NvbnN0IHI9dC5jb250cm9sSWQ7aWYodC5jb250cm9sQ29tcG9uZW50PT09QS5QUkVGSVgpe2NvbnN0IHU9W107bGV0IGM9ITEsbj1pO2Zvcig7bjxsLmxlbmd0aDspe2NvbnN0IHM9bFtuXTtpZihyIT09cy5jb250cm9sSWQpYnJlYWs7cy5jb250cm9sQ29tcG9uZW50PT09QS5WQUxVRSYmKGRlbGV0ZSBzLmNvbnRyb2wsZGVsZXRlIHMuY29udHJvbElkLHUucHVzaChzKSkscy5jb250cm9sQ29tcG9uZW50PT09QS5QT1NURklYJiYoYz0hMCksbisrfWlmKGMpe2NvbnN0IHM9Tih0LEspLGg9ey4uLnQuY29udHJvbCwuLi5zfSxDPXsuLi5OKHQsQiksdHlwZTphLkNPTlRST0wsdmFsdWU6IiIsY29udHJvbDpoLGNvbnRyb2xJZDpyfTtDLmNvbnRyb2wudmFsdWU9SSh1LG8pLHQ9SChDLHtleHRyYVBpY2tBdHRyczpkfSksaSs9bi1pLTF9fWlmKHQuY29udHJvbENvbXBvbmVudCYmKGRlbGV0ZSB0LmNvbnRyb2wsZGVsZXRlIHQuY29udHJvbElkLHQuY29udHJvbENvbXBvbmVudCE9PUEuVkFMVUUmJnQuY29udHJvbENvbXBvbmVudCE9PUEuUFJFX1RFWFQmJnQuY29udHJvbENvbXBvbmVudCE9PUEuUE9TVF9URVhUKSl7aSsrO2NvbnRpbnVlfX1jb25zdCBGPUgodCx7ZXh0cmFQaWNrQXR0cnM6ZH0pO2lmKCF0LnR5cGV8fHQudHlwZT09PWEuVEVYVHx8dC50eXBlPT09YS5TVUJTQ1JJUFR8fHQudHlwZT09PWEuU1VQRVJTQ1JJUFQpZm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgcj1sW2krMV07aWYoaSsrLHImJnooRixIKHIse2V4dHJhUGlja0F0dHJzOmR9KSkpe2NvbnN0IHU9ci52YWx1ZT09PXY/YApgOnIudmFsdWU7Ri52YWx1ZSs9dX1lbHNlIGJyZWFrfWVsc2UgaSsrO3AucHVzaChGKX1yZXR1cm4gcH1PYmplY3QudmFsdWVzKG0pLG9ubWVzc2FnZT1lPT57Y29uc3Qgbz1lLmRhdGEse29wdGlvbnM6ZCxkYXRhOmZ9PW8se2V4dHJhUGlja0F0dHJzOlQ9W119PWR8fHt9LGw9e2hlYWRlcjpJKGYuaGVhZGVyLHtleHRyYVBpY2tBdHRyczpULGlzQ2xvbmU6ITF9KSxtYWluOkkoZi5tYWluLHtleHRyYVBpY2tBdHRyczpULGlzQ2xhc3NpZnlBcmVhOiEwLGlzQ2xvbmU6ITF9KSxmb290ZXI6SShmLmZvb3Rlcix7ZXh0cmFQaWNrQXR0cnM6VCxpc0Nsb25lOiExfSl9O3Bvc3RNZXNzYWdlKGwpfX0pKCk7Cg==",Mi=typeof window!="undefined"&&window.Blob&&new Blob([atob(Oi)],{type:"text/javascript;charset=utf-8"});function Qr(){const o=Mi&&(window.URL||window.webkitURL).createObjectURL(Mi);try{return o?new Worker(o,{}):new Worker("data:application/javascript;base64,"+Oi,{type:"module"})}finally{o&&(window.URL||window.webkitURL).revokeObjectURL(o)}}class br{constructor(t){this.draw=t,this.wordCountWorker=new Ur,this.catalogWorker=new Er,this.groupWorker=new Cr,this.valueWorker=new Qr}getWordCount(){return new Promise((t,e)=>{this.wordCountWorker.onmessage=i=>{t(i.data)},this.wordCountWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.wordCountWorker.postMessage(n)})}getCatalog(){return new Promise((t,e)=>{this.catalogWorker.onmessage=r=>{t(r.data)},this.catalogWorker.onerror=r=>{e(r)};const n=this.draw.getOriginalMainElementList(),i=this.draw.getPosition().getOriginalMainPositionList();this.catalogWorker.postMessage({elementList:n,positionList:i})})}getGroupIds(){return new Promise((t,e)=>{this.groupWorker.onmessage=i=>{t(i.data)},this.groupWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.groupWorker.postMessage(n)})}getValue(t){return new Promise((e,n)=>{this.valueWorker.onmessage=i=>{e({version:xe,data:i.data,options:et(this.draw.getOptions())})},this.valueWorker.onerror=i=>{n(i)},this.valueWorker.postMessage({data:this.draw.getOriginValue(t),options:t})})}}var Ya="";class zt{constructor(t){this.options=t,this.mask=null,this.container=null,this.inputList=[],this.searchDropdowns=new Map,this._render()}_render(){var O;const{title:t,data:e,onClose:n,onCancel:i,onConfirm:r}=this.options,s=document.createElement("div");s.classList.add("dialog-mask"),s.setAttribute(Ht,c.EditorComponent.COMPONENT),document.body.append(s);const l=document.createElement("div");l.classList.add("dialog-container"),l.setAttribute(Ht,c.EditorComponent.COMPONENT);const a=document.createElement("div");a.classList.add("dialog"),l.append(a);const R=document.createElement("div");R.classList.add("dialog-title");const d=document.createElement("span");d.append(document.createTextNode(t));const u=document.createElement("i");u.onclick=()=>{n&&n(),this._dispose()},R.append(d),R.append(u),a.append(R);const h=document.createElement("div");h.classList.add("dialog-option");for(let P=0;P<e.length;P++){const M=e[P],f=document.createElement("div");if(f.classList.add("dialog-option__item"),M.label){const S=document.createElement("span");S.append(document.createTextNode(M.label)),f.append(S),M.required&&S.classList.add("dialog-option__item--require")}if(M.type==="select")if(M.searchable===!1){const S=document.createElement("select");M.width&&(S.style.width=`${M.width}px`),M.height&&(S.style.height=`${M.height}px`),S.name=M.name,S.value=M.value||"",(O=M.options)==null||O.forEach(I=>{const m=document.createElement("option");m.value=I.value,m.label=I.label,S.append(m)}),f.append(S),h.append(f),this.inputList.push(S)}else{const S=this._createSearchableSelect(M);f.append(S),h.append(f),this.inputList.push(S)}else{let S;if(M.type==="textarea")S=document.createElement("textarea");else if(M.type==="color"){S=document.createElement("input"),S.type="text",S.onclick=function(){I.click()};const I=document.querySelector("#color");I.oninput=function(){S.value=I.value}}else S=document.createElement("input"),S.type=M.type;M.width&&(S.style.width=`${M.width}px`),M.height&&(S.style.height=`${M.height}px`),S.name=M.name,S.value=M.value||"",S instanceof HTMLSelectElement||(S.placeholder=M.placeholder||""),f.append(S),h.append(f),this.inputList.push(S)}}a.append(h);const g=document.createElement("div");g.classList.add("dialog-menu");const L=document.createElement("button");L.classList.add("dialog-menu__cancel"),L.append(document.createTextNode("\u53D6\u6D88")),L.type="button",L.onclick=()=>{i&&i(),this._dispose()},g.append(L);const T=document.createElement("button");T.append(document.createTextNode("\u786E\u5B9A")),T.type="submit",T.onclick=()=>{if(r){const P=this.inputList.map(M=>{if(M instanceof HTMLDivElement&&M.classList.contains("searchable-select")){const S=M.getAttribute("data-name")||"",I=this.searchDropdowns.get(S);return{name:S,value:(I==null?void 0:I.selectedValue)||""}}const f=M;return{name:f.name,value:f.value}});r(P)}this._dispose()},g.append(T),a.append(g),document.body.append(l),this.container=l,this.mask=s}_createSearchableSelect(t){var h;const e=document.createElement("div");e.classList.add("searchable-select"),e.setAttribute("data-name",t.name),t.width&&(e.style.width=`${t.width}px`);const n=document.createElement("input");n.type="text",n.classList.add("searchable-select__input"),n.placeholder=t.placeholder||"\u8BF7\u9009\u62E9\u6216\u641C\u7D22";const i=this.searchDropdowns.get(t.name),r=(i==null?void 0:i.selectedValue)||t.value||"";if(r&&t.options){const g=t.options.find(L=>L.value===r);g&&(n.value=g.label)}const s=document.createElement("span");s.classList.add("searchable-select__arrow"),s.innerHTML="\u25BC";const l=document.createElement("div");l.classList.add("searchable-select__input-wrapper"),l.append(n),l.append(s);const a=document.createElement("div");a.classList.add("searchable-select__dropdown"),a.style.display="none";const R=(g="")=>{var P;a.innerHTML="";const L=((P=t.options)==null?void 0:P.filter(M=>!g||M.label.toLowerCase().includes(g.toLowerCase())))||[],T=this.searchDropdowns.get(t.name),O=(T==null?void 0:T.selectedValue)||t.value||"";if(L.length===0){const M=document.createElement("div");M.classList.add("searchable-select__option","searchable-select__option--empty"),M.textContent="\u65E0\u5339\u914D\u9009\u9879",a.append(M)}else L.forEach(M=>{const f=document.createElement("div");f.classList.add("searchable-select__option"),f.textContent=M.label,f.setAttribute("data-value",M.value),M.value===O&&f.classList.add("searchable-select__option--selected"),f.onclick=S=>{S.stopPropagation();const I=f.getAttribute("data-value")||"";n.value=M.label,a.querySelectorAll(".searchable-select__option").forEach(F=>{F.classList.remove("searchable-select__option--selected")}),f.classList.add("searchable-select__option--selected");const N=this.searchDropdowns.get(t.name);N&&(N.selectedValue=I),a.style.display="none"},a.append(f)})};R(),n.oninput=()=>{R(n.value),a.style.display="block"},n.onclick=g=>{g.stopPropagation(),document.querySelectorAll(".searchable-select__dropdown").forEach(T=>{T!==a&&(T.style.display="none")}),a.style.display=a.style.display==="block"?"none":"block"},s.onclick=g=>{g.stopPropagation(),document.querySelectorAll(".searchable-select__dropdown").forEach(T=>{T!==a&&(T.style.display="none")}),a.style.display=a.style.display==="block"?"none":"block",n.focus()};const d=g=>{const L=g.target;e.contains(L)||(a.style.display="none")};document.addEventListener("click",d);const u=document.createElement("select");return u.style.display="none",u.name=t.name,u.value=t.value||"",(h=t.options)==null||h.forEach(g=>{const L=document.createElement("option");L.value=g.value,L.label=g.label,u.append(L)}),this.searchDropdowns.set(t.name,{selectedValue:t.value||"",selectElement:u}),e.append(l),e.append(a),e.append(u),e}_dispose(){var t,e;(t=this.mask)==null||t.remove(),(e=this.container)==null||e.remove()}}function fi(o){const t={width:400,height:200,fontFamily:"Simsun",fontSize:20,color:"#ffffff",bold:!1,italic:!1,borderWidth:1,textBgColor:"#000000",borderColor:"#000000",text:"",...o};console.log("config",t);const e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height);let i="";t.bold&&(i+="bold "),t.italic&&(i+="italic ");let r=t.fontSize,s,l;do{const g=`${i}${r}px ${t.fontFamily}`;n.font=g;const L=n.measureText(t.text);if(s=L.width,l=L.actualBoundingBoxAscent+L.actualBoundingBoxDescent,(s>t.width||l>t.height)&&r>1)r--;else break}while(!0);const a=`${i}${r}px ${t.fontFamily}`;n.font=a;const R=n.measureText(t.text);s=R.width,l=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent;const d=(t.width-s)/2-4,u=(t.height-l)/2-4;n.fillStyle=t.textBgColor,n.fillRect(d,u,s+8,l+8),n.fillStyle=t.color,n.textAlign="center",n.textBaseline="middle",n.fillText(t.text,e.width/2,e.height/2);const h=t.borderWidth;return n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(h,h,t.width-h*2,t.height-h*2),e.toDataURL("image/png")}function Si(o){const t={checked:!1,width:100,height:40,label:"",fontSize:14,fontFamily:"SimSun",color:"#000000",borderColor:"#000000",checkColor:"#5175f4",boxSize:20,gap:8,borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=t.height/2,r=t.gap+t.borderWidth,s=i-t.boxSize/2;if(n.strokeStyle=t.borderColor,n.lineWidth=1.5,n.strokeRect(r,s,t.boxSize,t.boxSize),t.checked){n.fillStyle=t.checkColor,n.fillRect(r+2,s+2,t.boxSize-4,t.boxSize-4),n.beginPath(),n.strokeStyle="#ffffff",n.lineWidth=2,n.lineCap="round",n.lineJoin="round";const l=r+5,a=s+t.boxSize/2+2,R=r+t.boxSize/2-1,d=s+t.boxSize-6,u=r+t.boxSize-4,h=s+6;n.moveTo(l,a),n.lineTo(R,d),n.lineTo(u,h),n.stroke()}if(t.label){n.font=`${t.fontSize}px ${t.fontFamily}`,n.fillStyle=t.color,n.textAlign="left",n.textBaseline="middle";const l=r+t.boxSize+t.gap;n.fillText(t.label,l,i)}return e.toDataURL("image/png")}function mi(o){const t={checked:!1,width:100,height:40,label:"",fontSize:14,fontFamily:"SimSun",color:"#000000",borderColor:"#000000",checkColor:"#5175f4",boxSize:20,gap:8,borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=t.height/2,r=t.gap+t.borderWidth,s=i-t.boxSize/2,l=r+t.boxSize/2,a=s+t.boxSize/2;if(n.strokeStyle=t.borderColor,n.lineWidth=1.5,n.beginPath(),n.arc(l,a,t.boxSize/2,0,Math.PI*2),n.stroke(),t.checked&&(n.fillStyle=t.checkColor,n.beginPath(),n.arc(l,a,t.boxSize/4,0,Math.PI*2),n.fill()),t.label){n.font=`${t.fontSize}px ${t.fontFamily}`,n.fillStyle=t.color,n.textAlign="left",n.textBaseline="middle";const R=r+t.boxSize+t.gap;n.fillText(t.label,R,i)}return e.toDataURL("image/png")}function Ii(o,t){var e,n,i,r,s,l,a,R,d,u,h,g,L,T,O;console.log("el",o),new zt({title:"\u8868\u5355\u590D\u9009\u6846",data:[{type:"select",label:"\u8868\u5355 Key",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355 Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"120"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"40"},{type:"select",label:"\u9ED8\u8BA4\u9009\u4E2D",name:"checked",required:!0,value:(a=o==null?void 0:o.formInput)!=null&&a.checked?"true":"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"text",label:"\u6807\u7B7E\u6587\u5B57",name:"label",required:!0,value:(d=(R=o==null?void 0:o.formInput)==null?void 0:R.label)!=null?d:"",placeholder:"\u8BF7\u8F93\u5165\u6807\u7B7E\u6587\u5B57"},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(h=(u=o==null?void 0:o.formInput)==null?void 0:u.fontSize)!=null?h:"14"},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(L=(g=o==null?void 0:o.formInput)==null?void 0:g.color)!=null?L:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(O=(T=o==null?void 0:o.formInput)==null?void 0:T.fontFamily)!=null?O:"SimSun",options:t.getExtensionParam("fontOptions")==null||t.getExtensionParam("fontOptions")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("fontOptions")}],onConfirm:P=>{var K,b,Y,y,D,H,_,v;console.log("payload: ",P);const M=(K=P.find(J=>J.name==="key"))==null?void 0:K.value;if(!M)return;const f=(b=P.find(J=>J.name==="width"))==null?void 0:b.value;if(!f)return;const S=(Y=P.find(J=>J.name==="height"))==null?void 0:Y.value;if(!S)return;const I=((y=P.find(J=>J.name==="checked"))==null?void 0:y.value)==="true",m=((D=P.find(J=>J.name==="label"))==null?void 0:D.value)||"",N=(H=P.find(J=>J.name==="fontSize"))==null?void 0:H.value,F=(_=P.find(J=>J.name==="color"))==null?void 0:_.value,Z=(v=P.find(J=>J.name==="fontFamily"))==null?void 0:v.value,W="checkbox",p=t.getExtensionParam("formInputKeys").find(J=>J.value===M),X=p?JSON.stringify(p):"",E={key:M,width:f,height:S,checked:I,label:m,fontSize:N,fontFamily:Z,color:F,type:W,elemProp:X},U={value:Si({checked:I,label:m,width:Number(f),height:Number(S),fontSize:Number(N),fontFamily:Z,color:F}),type:c.ElementType.IMAGE,formInput:E,width:Number(f),height:Number(S)};if(o!=null&&o.id){const J={id:o.id,properties:U};console.log("deleteOpt12",J),t.command.executeUpdateElementById(J);return}t.command.executeInsertElementList([U])}})}function Xi(o,t){var e,n,i,r,s,l,a,R,d,u,h,g,L,T,O;console.log("el",o),new zt({title:"\u8868\u5355\u5355\u9009\u6846",data:[{type:"select",label:"\u8868\u5355 Key",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355 Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"120"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"40"},{type:"select",label:"\u9ED8\u8BA4\u9009\u4E2D",name:"checked",required:!0,value:(a=o==null?void 0:o.formInput)!=null&&a.checked?"true":"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"text",label:"\u6807\u7B7E\u6587\u5B57",name:"label",required:!0,value:(d=(R=o==null?void 0:o.formInput)==null?void 0:R.label)!=null?d:"",placeholder:"\u8BF7\u8F93\u5165\u6807\u7B7E\u6587\u5B57"},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(h=(u=o==null?void 0:o.formInput)==null?void 0:u.fontSize)!=null?h:"14"},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(L=(g=o==null?void 0:o.formInput)==null?void 0:g.color)!=null?L:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(O=(T=o==null?void 0:o.formInput)==null?void 0:T.fontFamily)!=null?O:"SimSun",options:t.getExtensionParam("fontOptions")==null||t.getExtensionParam("fontOptions")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("fontOptions")}],onConfirm:P=>{var K,b,Y,y,D,H,_,v;console.log("payload: ",P);const M=(K=P.find(J=>J.name==="key"))==null?void 0:K.value;if(!M)return;const f=(b=P.find(J=>J.name==="width"))==null?void 0:b.value;if(!f)return;const S=(Y=P.find(J=>J.name==="height"))==null?void 0:Y.value;if(!S)return;const I=((y=P.find(J=>J.name==="checked"))==null?void 0:y.value)==="true",m=((D=P.find(J=>J.name==="label"))==null?void 0:D.value)||"",N=(H=P.find(J=>J.name==="fontSize"))==null?void 0:H.value,F=(_=P.find(J=>J.name==="color"))==null?void 0:_.value,Z=(v=P.find(J=>J.name==="fontFamily"))==null?void 0:v.value,W="radio",p=t.getExtensionParam("formInputKeys").find(J=>J.value===M),X=p?JSON.stringify(p):"",E={key:M,width:f,height:S,checked:I,label:m,fontSize:N,fontFamily:Z,color:F,type:W,elemProp:X},U={value:mi({checked:I,label:m,width:Number(f),height:Number(S),fontSize:Number(N),fontFamily:Z,color:F}),type:c.ElementType.IMAGE,formInput:E,width:Number(f),height:Number(S)};if(o!=null&&o.id){const J={id:o.id,properties:U};t.command.executeUpdateElementById(J);return}t.command.executeInsertElementList([U])}})}function Ni(o,t){var e,n,i,r,s,l,a,R,d,u,h,g,L,T,O,P,M,f,S,I,m,N,F,Z;console.log("el",o),new zt({title:"\u8868\u5355\u6587\u672C\u6846",data:[{type:"select",label:"\u8868\u5355Key",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6(px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"100"},{type:"number",label:"\u9AD8\u5EA6(px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"50"},{type:"text",label:"\u884C\u9AD8",name:"lineHeight",required:!1,placeholder:"\u683C\u5F0F\u5316\u6587\u672C\u4F7F\u7528",value:(R=(a=o==null?void 0:o.formInput)==null?void 0:a.lineHeight)!=null?R:""},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(u=(d=o==null?void 0:o.formInput)==null?void 0:d.fontSize)!=null?u:"10"},{type:"select",label:"\u662F\u5426\u52A0\u7C97",name:"bold",required:!0,value:(h=o==null?void 0:o.formInput)!=null&&h.bold?String((g=o==null?void 0:o.formInput)==null?void 0:g.bold):"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"select",label:"\u662F\u5426\u659C\u4F53",name:"italic",required:!0,value:(L=o==null?void 0:o.formInput)!=null&&L.italic?String((T=o==null?void 0:o.formInput)==null?void 0:T.italic):"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"select",label:"\u586B\u5145\u7C7B\u578B",name:"txtFillType",required:!0,value:(O=o==null?void 0:o.formInput)!=null&&O.txtFillType?String((P=o==null?void 0:o.formInput)==null?void 0:P.txtFillType):"0",options:[{label:"\u6587\u672C",value:"0"},{label:"\u683C\u5F0F\u5316",value:"1"}]},{type:"select",label:"\u662F\u5426\u81EA\u52A8\u6362\u884C",name:"txtRowAutoFlag",required:!1,value:(M=o==null?void 0:o.formInput)!=null&&M.txtRowAutoFlag?String((f=o==null?void 0:o.formInput)==null?void 0:f.txtRowAutoFlag):"1",options:[{label:"\u662F",value:"0"},{label:"\u5426",value:"1"}]},{type:"select",label:"\u662F\u5426\u53EF\u7F16\u8F91",name:"txtEditFlag",required:!1,value:(S=o==null?void 0:o.formInput)!=null&&S.txtEditFlag?String((I=o==null?void 0:o.formInput)==null?void 0:I.txtEditFlag):"1",options:[{label:"\u662F",value:"0"},{label:"\u5426",value:"1"}]},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(N=(m=o==null?void 0:o.formInput)==null?void 0:m.color)!=null?N:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(Z=(F=o==null?void 0:o.formInput)==null?void 0:F.fontFamily)!=null?Z:"SimSun",options:t.getExtensionParam("fontOptions")==null||t.getExtensionParam("fontOptions")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("fontOptions")}],onConfirm:W=>{var gt,tt,j,Tt,Dt,lt,k,Q,Xt,G,$t,ye;console.log("payload: ",W);const V=(gt=W.find(B=>B.name==="key"))==null?void 0:gt.value;if(!V)return;const p=(tt=W.find(B=>B.name==="width"))==null?void 0:tt.value;if(!p)return;const X=(j=W.find(B=>B.name==="height"))==null?void 0:j.value;if(!X)return;const E=(Tt=W.find(B=>B.name==="fontSize"))==null?void 0:Tt.value,C=(Dt=W.find(B=>B.name==="lineHeight"))==null?void 0:Dt.value,U=((lt=W.find(B=>B.name==="bold"))==null?void 0:lt.value)==="true",K=((k=W.find(B=>B.name==="italic"))==null?void 0:k.value)==="true",b=(Q=W.find(B=>B.name==="color"))==null?void 0:Q.value,Y=(Xt=W.find(B=>B.name==="fontFamily"))==null?void 0:Xt.value,y="input",H=t.getExtensionParam("formInputKeys").find(B=>B.value===V),_=H?JSON.stringify(H):"",v=(G=W.find(B=>B.name==="txtFillType"))==null?void 0:G.value,J=($t=W.find(B=>B.name==="txtRowAutoFlag"))==null?void 0:$t.value,z=(ye=W.find(B=>B.name==="txtEditFlag"))==null?void 0:ye.value,ft={key:V,width:p,height:X,fontSize:E,bold:U,italic:K,color:b,fontFamily:Y,type:y,txtFillType:v,txtRowAutoFlag:J,txtEditFlag:z,elemProp:_,lineHeight:C},it={value:fi({text:V,width:p,height:X}),type:c.ElementType.IMAGE,formInput:ft,width:Number(p),height:Number(X),verticalAlign:"text-top"};if(o!=null&&o.id){const B={id:o.id,properties:it};console.log("deleteOpt12",B),t.command.executeUpdateElementById(B);return}t.command.executeInsertElementList([it])}})}function pi(o){const t={key:"",width:200,height:150,picAutoFlag:!1,picFillType:"default",borderColor:"#000000",borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=60,r=(t.width-i)/2,s=t.height/2-i/2-10;n.strokeStyle="#999999",n.lineWidth=2,n.strokeRect(r,s,i,i),n.fillStyle="#cccccc",n.beginPath(),n.moveTo(r+10,s+i-10),n.lineTo(r+i/2,s+15),n.lineTo(r+i-10,s+i-10),n.closePath(),n.fill(),n.fillStyle="#ffcc00",n.beginPath(),n.arc(r+i-20,s+15,8,0,Math.PI*2),n.fill(),t.key&&(n.font="14px SimSun",n.fillStyle="#000000",n.textAlign="center",n.textBaseline="middle",n.fillText(t.key,t.width/2,s+i+20)),t.picAutoFlag==="0"&&(n.font="12px SimSun",n.fillStyle="#5175f4",n.textAlign="left",n.fillText("\u2713 \u81EA\u9002\u5E94",10,t.height-15));const l=t.picFillType==="0"?"\u9ED8\u8BA4\u5927\u5C0F":t.picFillType==="1"?"\u5206\u5272":"\u987A\u5E8F";return n.font="12px SimSun",n.fillStyle="#666666",n.textAlign="right",n.fillText(`\u586B\u5145: ${l}`,t.width-10,t.height-15),e.toDataURL("image/png")}function Fi(o){const t={key:"",width:200,height:100,picAutoFlag:!1,borderColor:"#000000",borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=50,r=(t.width-i)/2,s=t.height/2-i/2-5;return n.fillStyle="#4a90e2",n.beginPath(),n.moveTo(r+10,s+i),n.lineTo(r+i-10,s+10),n.lineTo(r+i,s+15),n.lineTo(r+15,s+i+5),n.closePath(),n.fill(),n.fillStyle="#333333",n.beginPath(),n.moveTo(r+10,s+i),n.lineTo(r+15,s+i+5),n.lineTo(r+5,s+i+8),n.closePath(),n.fill(),t.key&&(n.font="14px SimSun",n.fillStyle="#000000",n.textAlign="center",n.textBaseline="middle",n.fillText(t.key,t.width/2,s+i+20)),t.picAutoFlag==="0"&&(n.font="12px SimSun",n.fillStyle="#5175f4",n.textAlign="left",n.fillText("\u2713 \u81EA\u9002\u5E94",10,t.height-15)),n.font="12px SimSun",n.fillStyle="#666666",n.textAlign="right",n.fillText("\u7B7E\u5B57\u6846",t.width-10,t.height-15),e.toDataURL("image/png")}function Wi(o){const t={key:"",width:200,height:100,picAutoFlag:!1,borderColor:"#000000",borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=50,r=(t.width-i)/2,s=t.height/2-i/2-5,l=r+i/2,a=s+i/2;return n.strokeStyle="#e74c3c",n.lineWidth=2.5,n.beginPath(),n.arc(l,a,i/2-5,0,Math.PI*2),n.stroke(),n.strokeStyle="#e74c3c",n.lineWidth=1.5,n.beginPath(),n.arc(l,a,i/2-10,0,Math.PI*2),n.stroke(),n.fillStyle="#e74c3c",n.font="bold 16px SimSun",n.textAlign="center",n.textBaseline="middle",n.fillText("\u7AE0",l,a),t.key&&(n.font="14px SimSun",n.fillStyle="#000000",n.textAlign="center",n.textBaseline="middle",n.fillText(t.key,t.width/2,s+i+20)),t.picAutoFlag==="0"&&(n.font="12px SimSun",n.fillStyle="#5175f4",n.textAlign="left",n.fillText("\u2713 \u81EA\u9002\u5E94",10,t.height-15)),n.font="12px SimSun",n.fillStyle="#666666",n.textAlign="right",n.fillText("\u7B7E\u7AE0\u6846",t.width-10,t.height-15),e.toDataURL("image/png")}function Vi(o){const t={key:"",width:200,height:100,riskCopyContent:"",borderColor:"#000000",borderWidth:1,...o},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=50,r=(t.width-i)/2,s=t.height/2-i/2-5;if(n.strokeStyle="#f39c12",n.lineWidth=2,n.strokeRect(r+5,s+5,i-10,i-10),n.beginPath(),n.moveTo(r+10,s+15),n.lineTo(r+i-10,s+15),n.moveTo(r+10,s+25),n.lineTo(r+i-10,s+25),n.moveTo(r+10,s+35),n.lineTo(r+i-20,s+35),n.stroke(),n.fillStyle="#e74c3c",n.beginPath(),n.moveTo(r+i-15,s+5),n.lineTo(r+i-5,s+20),n.lineTo(r+i-25,s+20),n.closePath(),n.fill(),n.fillStyle="#ffffff",n.font="bold 12px Arial",n.textAlign="center",n.textBaseline="middle",n.fillText("!",r+i-15,s+14),t.key&&(n.font="14px SimSun",n.fillStyle="#000000",n.textAlign="center",n.textBaseline="middle",n.fillText(t.key,t.width/2,s+i+20)),t.riskCopyContent){n.font="11px SimSun",n.fillStyle="#666666",n.textAlign="left";const l=t.riskCopyContent.length>20?t.riskCopyContent.substring(0,20)+"...":t.riskCopyContent;n.fillText(l,10,t.height-30)}return n.font="12px SimSun",n.fillStyle="#666666",n.textAlign="right",n.fillText("\u98CE\u9669\u6284\u5F55",t.width-10,t.height-15),e.toDataURL("image/png")}function Yi(o,t){var e,n,i,r,s,l,a,R,d,u,h,g,L,T,O,P;console.log("el",o),new zt({title:"\u56FE\u7247\u6846\u914D\u7F6E",data:[{type:"select",label:"\u5143\u7D20\u540D\u79F0",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u9009\u62E9\u5143\u7D20\u540D\u79F0",options:t.getExtensionParam("picKeys")==null||t.getExtensionParam("picKeys")==null?[]:t.getExtensionParam("picKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"200"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"150"},{type:"select",label:"\u662F\u5426\u81EA\u9002\u5E94",name:"picAutoFlag",required:!1,value:(R=(a=o==null?void 0:o.formInput)==null?void 0:a.picAutoFlag)!=null?R:"1",options:[{label:"\u5426",value:"1"},{label:"\u662F",value:"0"}]},{type:"select",label:"\u662F\u5426\u7F29\u653E\u56FE\u7247",name:"reduceSizeFlag",required:!1,value:(u=(d=o==null?void 0:o.formInput)==null?void 0:d.reduceSizeFlag)!=null?u:"1",options:[{label:"\u5426",value:"1"},{label:"\u662F",value:"0"}]},{type:"select",label:"\u56FE\u7247\u586B\u5145\u914D\u7F6E",name:"picFillType",required:!0,value:(g=(h=o==null?void 0:o.formInput)==null?void 0:h.picFillType)!=null?g:"0",options:[{label:"\u9ED8\u8BA4\u5927\u5C0F",value:"0"},{label:"\u5206\u5272",value:"1"},{label:"\u987A\u5E8F",value:"2"}]},{type:"number",label:"\u884C\u6570",name:"rowNum",required:!1,placeholder:"\u8BF7\u8F93\u5165\u884C\u6570",value:(T=(L=o==null?void 0:o.formInput)==null?void 0:L.rowNum)!=null?T:"1"},{type:"number",label:"\u5217\u6570",name:"colNum",required:!1,placeholder:"\u8BF7\u8F93\u5165\u5217\u6570",value:(P=(O=o==null?void 0:o.formInput)==null?void 0:O.colNum)!=null?P:"1"}],onConfirm:M=>{var b,Y,y,D,H,_,v,J;console.log("payload: ",M);const f=(b=M.find(z=>z.name==="key"))==null?void 0:b.value;if(!f)return;const S=(Y=M.find(z=>z.name==="width"))==null?void 0:Y.value;if(!S)return;const I=(y=M.find(z=>z.name==="height"))==null?void 0:y.value;if(!I)return;const m=((D=M.find(z=>z.name==="picAutoFlag"))==null?void 0:D.value)||"1",N=((H=M.find(z=>z.name==="picFillType"))==null?void 0:H.value)||"0",F="image",Z=t.getExtensionParam("picKeys");if(!Z)return;const W=Z.find(z=>z.value===f),V=W?JSON.stringify(W):"",p=((_=M.find(z=>z.name==="reduceSizeFlag"))==null?void 0:_.value)||"1",X=((v=M.find(z=>z.name==="rowNum"))==null?void 0:v.value)||"1",E=((J=M.find(z=>z.name==="colNum"))==null?void 0:J.value)||"1",C={key:f,width:S,height:I,type:F,picAutoFlag:m,picFillType:N,elemProp:V,reduceSizeFlag:p,rowNum:X,colNum:E},K={value:pi({key:f,width:Number(S),height:Number(I),picAutoFlag:m,picFillType:N}),type:c.ElementType.IMAGE,formInput:C,width:Number(S),height:Number(I)};if(o!=null&&o.id){const z={id:o.id,properties:K};console.log("updateOpt",z),t.command.executeUpdateElementById(z);return}t.command.executeInsertElementList([K])}})}function Zi(o,t){var e,n,i,r,s,l,a,R,d,u;console.log("el",o),new zt({title:"\u7B7E\u5B57\u6846\u914D\u7F6E",data:[{type:"select",label:"\u5143\u7D20\u540D\u79F0",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u9009\u62E9\u5143\u7D20\u540D\u79F0",options:t.getExtensionParam("signPicKeys")==null||t.getExtensionParam("signPicKeys")==null?[]:t.getExtensionParam("signPicKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"200"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"100"},{type:"select",label:"\u662F\u5426\u81EA\u9002\u5E94",name:"picAutoFlag",required:!1,value:(R=(a=o==null?void 0:o.formInput)==null?void 0:a.picAutoFlag)!=null?R:"1",options:[{label:"\u5426",value:"1"},{label:"\u662F",value:"0"}]},{type:"select",label:"\u662F\u5426\u7F29\u653E",name:"reduceSizeFlag",required:!1,value:(u=(d=o==null?void 0:o.formInput)==null?void 0:d.reduceSizeFlag)!=null?u:"1",options:[{label:"\u5426",value:"1"},{label:"\u662F",value:"0"}]}],onConfirm:h=>{var Z,W,V,p,X;console.log("payload: ",h);const g=(Z=h.find(E=>E.name==="key"))==null?void 0:Z.value;if(!g)return;const L=(W=h.find(E=>E.name==="width"))==null?void 0:W.value;if(!L)return;const T=(V=h.find(E=>E.name==="height"))==null?void 0:V.value;if(!T)return;const O=((p=h.find(E=>E.name==="picAutoFlag"))==null?void 0:p.value)||"1",P="signature",f=t.getExtensionParam("signPicKeys").find(E=>E.value===g),S=f?JSON.stringify(f):"",I=((X=h.find(E=>E.name==="reduceSizeFlag"))==null?void 0:X.value)||"1",m={key:g,width:L,height:T,type:P,picAutoFlag:O,elemProp:S,reduceSizeFlag:I},F={value:Fi({key:g,width:Number(L),height:Number(T),picAutoFlag:O}),type:c.ElementType.IMAGE,formInput:m,width:Number(L),height:Number(T)};if(o!=null&&o.id){const E={id:o.id,properties:F};console.log("updateOpt",E),t.command.executeUpdateElementById(E);return}t.command.executeInsertElementList([F])}})}function Ui(o,t){var e,n,i,r,s,l,a,R;console.log("el",o),new zt({title:"\u7B7E\u7AE0\u6846\u914D\u7F6E",data:[{type:"select",label:"\u5143\u7D20\u540D\u79F0",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u9009\u62E9\u5143\u7D20\u540D\u79F0",options:t.getExtensionParam("sealPicKeys")==null||t.getExtensionParam("sealPicKeys")==null?[]:t.getExtensionParam("sealPicKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"200"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"100"},{type:"select",label:"\u662F\u5426\u81EA\u9002\u5E94",name:"picAutoFlag",required:!1,value:(R=(a=o==null?void 0:o.formInput)==null?void 0:a.picAutoFlag)!=null?R:"1",options:[{label:"\u5426",value:"1"},{label:"\u662F",value:"0"}]}],onConfirm:d=>{var m,N,F,Z;console.log("payload: ",d);const u=(m=d.find(W=>W.name==="key"))==null?void 0:m.value;if(!u)return;const h=(N=d.find(W=>W.name==="width"))==null?void 0:N.value;if(!h)return;const g=(F=d.find(W=>W.name==="height"))==null?void 0:F.value;if(!g)return;const L=((Z=d.find(W=>W.name==="picAutoFlag"))==null?void 0:Z.value)||"1",T="seal",P=t.getExtensionParam("sealPicKeys").find(W=>W.value===u),M=P?JSON.stringify(P):"",f={key:u,width:h,height:g,type:T,picAutoFlag:L,elemProp:M},I={value:Wi({key:u,width:Number(h),height:Number(g),picAutoFlag:L}),type:c.ElementType.IMAGE,formInput:f,width:Number(h),height:Number(g)};if(o!=null&&o.id){const W={id:o.id,properties:I};console.log("updateOpt",W),t.command.executeUpdateElementById(W);return}t.command.executeInsertElementList([I])}})}function Ei(o,t){var e,n,i,r,s,l,a,R;console.log("el",o),new zt({title:"\u98CE\u9669\u6284\u5F55\u6846\u914D\u7F6E",data:[{type:"select",label:"\u5143\u7D20\u540D\u79F0",name:"key",required:!0,value:(n=(e=o==null?void 0:o.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u9009\u62E9\u5143\u7D20\u540D\u79F0",options:t.getExtensionParam("riskCopyKeys")==null||t.getExtensionParam("riskCopyKeys")==null?[]:t.getExtensionParam("riskCopyKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=o==null?void 0:o.formInput)==null?void 0:i.width)!=null?r:"200"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(s=o==null?void 0:o.formInput)==null?void 0:s.height)!=null?l:"100"},{type:"textarea",label:"\u98CE\u9669\u6284\u5F55\u5185\u5BB9",name:"riskCopyContent",required:!1,placeholder:"\u8BF7\u8F93\u5165\u98CE\u9669\u6284\u5F55\u5185\u5BB9",value:(R=(a=o==null?void 0:o.formInput)==null?void 0:a.riskCopyContent)!=null?R:""}],onConfirm:d=>{var m,N,F,Z;console.log("payload: ",d);const u=(m=d.find(W=>W.name==="key"))==null?void 0:m.value;if(!u)return;const h=(N=d.find(W=>W.name==="width"))==null?void 0:N.value;if(!h)return;const g=(F=d.find(W=>W.name==="height"))==null?void 0:F.value;if(!g)return;const L=((Z=d.find(W=>W.name==="riskCopyContent"))==null?void 0:Z.value)||"",T="riskCopy",P=t.getExtensionParam("riskCopyKeys").find(W=>W.value===u),M=P?JSON.stringify(P):"",f={key:u,width:h,height:g,type:T,riskCopyContent:L,elemProp:M},I={value:Vi({key:u,width:Number(h),height:Number(g),riskCopyContent:L}),type:c.ElementType.IMAGE,formInput:f,width:Number(h),height:Number(g)};if(o!=null&&o.id){const W={id:o.id,properties:I};console.log("updateOpt",W),t.command.executeUpdateElementById(W);return}t.command.executeInsertElementList([I])}})}class Dr{constructor(t){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:n,resizerImageContainer:i,resizerImage:r,resizerSize:s}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=n,this.resizerImageContainer=i,this.resizerImage=r,this.resizerSize=s,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){var d;const{scale:n}=this.options;let i=0,r=0;const s=this.draw.getHeight(),l=this.draw.getPageGap(),R=((d=e==null?void 0:e.pageNo)!=null?d:this.draw.getPageNo())*(s+l);if(t.imgFloatPosition)i=t.imgFloatPosition.x*n,r=t.imgFloatPosition.y*n+R;else if(e){const{coordinate:{leftTop:[u,h]},ascent:g}=e;i=u,r=h+R+g}return{x:i,y:r}}_createResizerDom(){const{scale:t}=this.options,e=document.createElement("div");e.classList.add(`${x}-resizer-selection`),e.style.display="none",e.style.borderColor=this.options.resizerColor,e.style.borderWidth=`${t}px`;const n=[];for(let a=0;a<8;a++){const R=document.createElement("div");R.style.background=this.options.resizerColor,R.classList.add("resizer-handle"),R.classList.add(`handle-${a}`),R.setAttribute("data-index",String(a)),R.onmousedown=this._mousedown.bind(this),e.append(R),n.push(R)}this.container.append(e);const i=document.createElement("div");i.classList.add(`${x}-resizer-size-view`);const r=document.createElement("span");i.append(r),e.append(i);const s=document.createElement("div");s.classList.add(`${x}-resizer-image`),s.style.display="none";const l=document.createElement("img");return s.append(l),this.container.append(s),{resizerSelection:e,resizerHandleList:n,resizerImageContainer:s,resizerImage:l,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 n=t.target;this.curHandleIndex=Number(n.dataset.index);const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,this.canvas.style.cursor=i,console.log(this.curElement),this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{x:r,y:s}=this._getElementPosition(this.curElement,this.curPosition);this.resizerImageContainer.style.left=`${r}px`,this.resizerImageContainer.style.top=`${s}px`,this.resizerImage.style.width=`${this.curElement.width*e}px`,this.resizerImage.style.height=`${this.curElement.height*e}px`;const l=this._mousemove.bind(this);document.addEventListener("mousemove",l),document.addEventListener("mouseup",()=>{var a;this.curElement&&!this.previewerDrawOption.dragDisable&&(this.curElement.width=this.width,this.curElement.height=this.height,this.curElement.formInput&&(this.curElement.formInput.width=`${this.width}`,this.curElement.formInput.height=`${this.height}`,this.curElement.formInput.type=="checkbox"?this.curElementSrc=Si(this.curElement.formInput):this.curElement.formInput.type=="radio"?this.curElementSrc=mi(this.curElement.formInput):this.curElement.formInput.type=="image"?this.curElementSrc=pi(this.curElement.formInput):this.curElement.formInput.type=="signature"?this.curElementSrc=Fi(this.curElement.formInput):this.curElement.formInput.type=="seal"?this.curElementSrc=Wi(this.curElement.formInput):this.curElement.formInput.type=="riskCopy"?this.curElementSrc=Vi(this.curElement.formInput):this.curElementSrc=fi({text:this.curElement.formInput.key,width:this.curElement.formInput.width,height:this.curElement.formInput.height}),this.curElement.value=this.curElementSrc),console.log("this.draw.render"),this.draw.render({isSetCursor:!0,curIndex:(a=this.curPosition)==null?void 0:a.index})),this.resizerImageContainer.style.display="none",document.removeEventListener("mousemove",l),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 n=0,i=0;switch(this.curHandleIndex){case 0:{const R=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 1:i=this.mousedownY-t.y;break;case 2:{const R=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 4:{const R=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const R=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 7:n=this.mousedownX-t.x;break}const r=this.curElement.width+n/e,s=this.curElement.height+i/e;if(r<=0||s<=0)return;this.width=r,this.height=s;const l=r*e,a=s*e;this.resizerImage.style.width=`${l}px`,this.resizerImage.style.height=`${a}px`,this._updateResizerRect(l,a),this._updateResizerSizeView(l,a),t.preventDefault(),this.eventBus.isSubscribe("imageSizeChange")&&this.eventBus.emit("imageSizeChange",{element:this.curElement})}_drawPreviewer(){const t=document.createElement("div");t.classList.add(`${x}-image-previewer`);const e=document.createElement("i");e.classList.add("image-close"),e.onclick=()=>{this._clearPreviewer()},t.append(e);const n=document.createElement("div");n.classList.add(`${x}-image-container`);const i=document.createElement("img");i.src=this.curElementSrc,i.draggable=!1,n.append(i),this.previewerImage=i,t.append(n);let r=0,s=0,l=1,a=0;const R=document.createElement("div");R.classList.add(`${x}-image-menu`);const d=document.createElement("div");d.classList.add("image-navigate");const u=document.createElement("i");u.classList.add("image-pre"),u.onclick=()=>{const m=this.imageList.findIndex(N=>{var F;return N.id===((F=this.curShowElement)==null?void 0:F.id)});m<=0||(this.curShowElement=this.imageList[m-1],i.src=this.curShowElement.value,this._updateImageNavigate())},d.append(u),this.imagePre=u;const h=document.createElement("span");h.classList.add("image-count"),this.imageCount=h,d.append(h);const g=document.createElement("i");g.classList.add("image-next"),g.onclick=()=>{const m=this.imageList.findIndex(N=>{var F;return N.id===((F=this.curShowElement)==null?void 0:F.id)});m>=this.imageList.length-1||(this.curShowElement=this.imageList[m+1],i.src=this.curShowElement.value,this._updateImageNavigate())},this.imageNext=g,d.append(g),R.append(d);const L=document.createElement("i");L.classList.add("zoom-in"),L.onclick=()=>{l+=.1,this._setPreviewerTransform(l,a,r,s)},R.append(L);const T=document.createElement("i");T.onclick=()=>{l-.1<=.1||(l-=.1,this._setPreviewerTransform(l,a,r,s))},T.classList.add("zoom-out"),R.append(T);const O=document.createElement("i");O.classList.add("rotate"),O.onclick=()=>{a+=1,this._setPreviewerTransform(l,a,r,s)},R.append(O);const P=document.createElement("i");P.classList.add("original-size"),P.onclick=()=>{r=0,s=0,l=1,a=0,this._setPreviewerTransform(l,a,r,s)},R.append(P);const M=document.createElement("i");M.classList.add("image-download"),M.onclick=()=>{var N;const{mime:m}=this.previewerDrawOption;Yn(i.src,`${(N=this.curElement)==null?void 0:N.id}.${m||"png"}`)},R.append(M),t.append(R),this.previewerContainer=t,document.body.append(t);let f=0,S=0,I=!1;i.onmousedown=m=>{I=!0,f=m.x,S=m.y,t.style.cursor="move"},t.onmousemove=m=>{!I||(r+=m.x-f,s+=m.y-S,f=m.x,S=m.y,this._setPreviewerTransform(l,a,r,s))},t.onmouseup=()=>{I=!1,t.style.cursor="auto"},t.onwheel=m=>{if(m.preventDefault(),m.stopPropagation(),m.deltaY<0)l+=.1;else{if(l-.1<=.1)return;l-=.1}this._setPreviewerTransform(l,a,r,s)},this._updateImageNavigate()}_updateImageNavigate(){const t=this.imageList.findIndex(e=>{var n;return e.id===((n=this.curShowElement)==null?void 0:n.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,n,i){!this.previewerImage||(this.previewerImage.style.left=`${n}px`,this.previewerImage.style.top=`${i}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:n,scale:i}=this.options,r=this.draw.isReadonly();this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let s=0;s<8;s++){const l=s===0||s===6||s===7?-n:s===1||s===5?t/2:t-n,a=s===0||s===1||s===2?-n:s===3||s===7?e/2-n:e-n;this.resizerHandleList[s].style.transform=`scale(${i})`,this.resizerHandleList[s].style.left=`${l}px`,this.resizerHandleList[s].style.top=`${a}px`,this.resizerHandleList[s].style.display=r?"none":"block"}}_updateResizerSizeView(t,e){this.resizerSize.innerText=`${Math.round(t)} \xD7 ${Math.round(e)}`}render(){var e,n;const t=this.draw.getMode();!this.curElement||this.curElement.imgToolDisabled&&!this.draw.isDesignMode()||t===c.EditorMode.PRINT&&((e=this.options.modeRule[c.EditorMode.PRINT])==null?void 0:e.imagePreviewerDisabled)||t===c.EditorMode.READONLY&&((n=this.options.modeRule[c.EditorMode.READONLY])==null?void 0:n.imagePreviewerDisabled)||(this.imageList=this.draw.getImageParticle().getOriginalMainImageList(),this.curShowElement=this.curElement,this._drawPreviewer(),document.body.style.overflow="hidden")}drawResizer(t,e=null,n={}){var r,s;const i=this.draw.getMode();t.imgToolDisabled&&!this.draw.isDesignMode()||i===c.EditorMode.PRINT&&((r=this.options.modeRule[c.EditorMode.PRINT])==null?void 0:r.imagePreviewerDisabled)||i===c.EditorMode.READONLY&&((s=this.options.modeRule[c.EditorMode.READONLY])==null?void 0:s.imagePreviewerDisabled)||(this.previewerDrawOption=n,this.curElementSrc=t[n.srcKey||"value"]||"",this.updateResizer(t,e),document.addEventListener("keydown",this._keydown))}updateResizer(t,e=null){console.log(t);const{scale:n}=this.options,i=t.width*n,r=t.height*n;this._updateResizerSizeView(i,r);const{x:s,y:l}=this._getElementPosition(t,e);this.resizerSelection.style.left=`${s}px`,this.resizerSelection.style.top=`${l}px`,this.resizerSelection.style.borderWidth=`${n}px`,this._updateResizerRect(i,r),this.resizerSelection.style.display="block",this.curElement=t,this.curPosition=e,this.width=i,this.height=r}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}class Kr{constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.datePicker=new di(t,{onSubmit:this._setValue.bind(this)})}_setValue(t){if(!t)return;const e=this.getDateElementRange();if(!e)return;const[n,i]=e,r=this.draw.getElementList(),s=r[n+1];this.draw.spliceElementList(r,n+1,i-n),this.range.setRange(n,n);const l={type:c.ElementType.DATE,value:"",dateFormat:s.dateFormat,valueList:[{value:t}]};It(r,[l],n,{editorOptions:this.options}),this.draw.insertElementList([l])}getDateElementRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=this.draw.getElementList(),s=r[n];if(s.type!==c.ElementType.DATE)return null;let l=n;for(;l>=0;){if(r[l].dateId!==s.dateId){t=l;break}l--}let a=n+1;for(;a<r.length;){if(r[a].dateId!==s.dateId){e=a-1;break}a++}return a===r.length&&(e=a-1),!~t||!~e?null:[t,e]}clearDatePicker(){this.datePicker.dispose()}renderDatePicker(t,e){const n=this.draw.getElementList(),i=this.getDateElementRange(),r=i?n.slice(i[0]+1,i[1]+1).map(s=>s.value).join(""):"";this.datePicker.render({value:r,position:e,dateFormat:t.dateFormat})}}class Ci{constructor(t){this.element=t,this.videoCache=new Map}snapshot(t,e,n){return new Promise((i,r)=>{var l,a;const s=((a=(l=this.element.block)==null?void 0:l.videoBlock)==null?void 0:a.src)||"";if(this.videoCache.has(s)){const R=this.videoCache.get(s);t.drawImage(R,e,n,this.element.metrics.width,this.element.metrics.height),i(this.element)}else{const R=document.createElement("video");R.src=s,R.muted=!0,R.crossOrigin="anonymous",R.onloadeddata=()=>{t.drawImage(R,e,n,this.element.metrics.width,this.element.metrics.height),this.videoCache.set(s,R),i(this.element)},R.onerror=d=>{r(d)},R.play().then(()=>{R.pause()})}})}render(t){var i;const e=this.element.block,n=document.createElement("video");n.style.width="100%",n.style.height="100%",n.style.objectFit="contain",n.src=((i=e.videoBlock)==null?void 0:i.src)||"",n.controls=!0,t.append(n)}}class yr{constructor(t,e){this.draw=t.getDraw(),this.options=this.draw.getOptions(),this.blockContainer=t.getBlockContainer(),this.element=e,this.block=null;const{blockItem:n,resizerMask:i,resizerSelection:r,resizerHandleList:s}=this._createBlockItem();this.blockItem=n,this.blockContainer.append(this.blockItem),this.blockCache=new Map,this.resizerMask=i,this.resizerSelection=r,this.resizerHandleList=s,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.isAllowResize=!1}getBlockElement(){return this.element}getBlockWidth(){return this.element.width||this.element.metrics.width}_createBlockItem(){const{scale:t,resizerColor:e}=this.options,n=document.createElement("div");n.classList.add(`${x}-block-item`);const i=document.createElement("div");i.style.display="none",i.classList.add(`${x}-resizer-selection`),i.style.borderColor=e,i.style.borderWidth=`${t}px`;const r=[];for(let l=0;l<8;l++){const a=document.createElement("div");a.style.background=e,a.classList.add("resizer-handle"),a.classList.add(`handle-${l}`),a.setAttribute("data-index",String(l)),a.onmousedown=this._mousedown.bind(this),i.append(a),r.push(a)}const s=document.createElement("div");return s.classList.add(`${x}-resizer-mask`),s.style.display="none",n.append(s),n.onmouseenter=()=>{if(this.draw.isReadonly())return;const{width:a,height:R}=this.element.metrics;this._updateResizerRect(a,R),i.style.display="block"},n.onmouseleave=()=>{this.isAllowResize||(i.style.display="none")},n.append(i),{blockItem:n,resizerMask:s,resizerSelection:i,resizerHandleList:r}}_updateResizerRect(t,e){const{resizerSize:n,scale:i}=this.options;this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let r=0;r<8;r++){const s=r===0||r===6||r===7?-n:r===1||r===5?t/2:t-n,l=r===0||r===1||r===2?-n:r===3||r===7?e/2-n:e-n;this.resizerHandleList[r].style.transform=`scale(${i})`,this.resizerHandleList[r].style.left=`${s}px`,this.resizerHandleList[r].style.top=`${l}px`}}_mousedown(t){const e=this.draw.getPage();this.mousedownX=t.x,this.mousedownY=t.y,this.isAllowResize=!0;const n=t.target;this.curHandleIndex=Number(n.dataset.index),this.resizerMask.style.display="block";const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,e.style.cursor=i;const r=this._mousemove.bind(this);document.addEventListener("mousemove",r),document.addEventListener("mouseup",()=>{this.element.width=Math.min(this.width,this.draw.getInnerWidth()),this.element.height=this.height,this.isAllowResize=!1,this.resizerSelection.style.display="none",this.resizerMask.style.display="none",document.removeEventListener("mousemove",r),document.body.style.cursor="",e.style.cursor="text",this.draw.render()},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.isAllowResize)return;const{scale:e}=this.options;let n=0,i=0;switch(this.curHandleIndex){case 0:{const R=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 1:i=this.mousedownY-t.y;break;case 2:{const R=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 4:{const R=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const R=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 7:n=this.mousedownX-t.x;break}const r=this.getBlockWidth()+n/e,s=this.element.height+i/e;if(r<=0||s<=0)return;this.width=r,this.height=s;const l=r*e,a=s*e;this._updateResizerRect(l,a),this.blockItem.style.width=`${l}px`,this.blockItem.style.height=`${a}px`,t.preventDefault()}snapshot(t,e,n){if(this.element.block.type===c.BlockType.VIDEO)if(this.blockItem.style.display="none",this.blockCache.has(this.element.id))this.blockCache.get(this.element.id).snapshot(t,e,n);else{this.block=new Ci(this.element);const r=this.block.snapshot(t,e,n);this.draw.getImageObserver().add(r),this.blockCache.set(this.element.id,this.block)}}render(){const t=this.element.block;t.type===c.BlockType.IFRAME?(this.block=new Pe(this.element),this.block.render(this.blockItem)):t.type===c.BlockType.VIDEO&&(this.block=new Ci(this.element),this.block.render(this.blockItem))}setClientRects(t,e,n){const i=this.draw.getHeight(),r=this.draw.getPageGap(),s=t*(i+r),{metrics:l}=this.element;this.blockItem.style.display="block",this.blockItem.style.width=`${l.width}px`,this.blockItem.style.height=`${l.height}px`,this.blockItem.style.left=`${e}px`,this.blockItem.style.top=`${s+n}px`}remove(){this.blockItem.remove()}}class wr{constructor(t){this.draw=t,this.container=t.getContainer(),this.blockMap=new Map,this.blockContainer=this._createBlockContainer(),this.container.append(this.blockContainer)}_createBlockContainer(){const t=document.createElement("div");return t.classList.add(`${x}-block-container`),t}getDraw(){return this.draw}getBlockContainer(){return this.blockContainer}render(t,e,n,i,r){const s=n.id;let l=this.blockMap.get(s);l||(l=new yr(this,n),l.render(),this.blockMap.set(s,l)),this.draw.isPrintMode()?l.snapshot(t,i,r):l.setClientRects(e,i,r)}clear(){if(!this.blockMap.size)return;const t=this.draw.getOriginalMainElementList(),e=[];for(let n=0;n<t.length;n++){const i=t[n];i.type===c.ElementType.BLOCK&&e.push(i.id)}this.blockMap.forEach(n=>{const i=n.getBlockElement().id;e.includes(i)||(n.remove(),this.blockMap.delete(i))})}}var In={contextmenu:{global:{cut:"\u526A\u5207",copy:"\u590D\u5236",paste:"\u7C98\u8D34",selectAll:"\u5168\u9009",print:"\u6253\u5370"},control:{delete:"\u5220\u9664\u63A7\u4EF6"},hyperlink:{delete:"\u5220\u9664\u94FE\u63A5",cancel:"\u53D6\u6D88\u94FE\u63A5",edit:"\u7F16\u8F91\u94FE\u63A5"},image:{change:"\u66F4\u6539\u56FE\u7247",saveAs:"\u53E6\u5B58\u4E3A\u56FE\u7247",textWrap:"\u6587\u5B57\u73AF\u7ED5",textWrapType:{embed:"\u5D4C\u5165\u578B",upDown:"\u4E0A\u4E0B\u578B\u73AF\u7ED5",surround:"\u56DB\u5468\u578B\u73AF\u7ED5",floatTop:"\u6D6E\u4E8E\u6587\u5B57\u4E0A\u65B9",floatBottom:"\u886C\u4E8E\u6587\u5B57\u4E0B\u65B9"}},table:{insertRowCol:"\u63D2\u5165\u884C\u5217",insertTopRow:"\u4E0A\u65B9\u63D2\u51651\u884C",insertBottomRow:"\u4E0B\u65B9\u63D2\u51651\u884C",insertLeftCol:"\u5DE6\u4FA7\u63D2\u51651\u5217",insertRightCol:"\u53F3\u4FA7\u63D2\u51651\u5217",deleteRowCol:"\u5220\u9664\u884C\u5217",deleteRow:"\u5220\u96641\u884C",deleteCol:"\u5220\u96641\u5217",deleteTable:"\u5220\u9664\u6574\u4E2A\u8868\u683C",mergeCell:"\u5408\u5E76\u5355\u5143\u683C",mergeCancelCell:"\u53D6\u6D88\u5408\u5E76",verticalAlign:"\u5782\u76F4\u5BF9\u9F50",verticalAlignTop:"\u9876\u7AEF\u5BF9\u9F50",verticalAlignMiddle:"\u5782\u76F4\u5C45\u4E2D",verticalAlignBottom:"\u5E95\u7AEF\u5BF9\u9F50",border:"\u8868\u683C\u8FB9\u6846",borderAll:"\u6240\u6709\u6846\u7EBF",borderEmpty:"\u65E0\u6846\u7EBF",borderDash:"\u865A\u6846\u7EBF",borderExternal:"\u5916\u4FA7\u6846\u7EBF",borderInternal:"\u5185\u4FA7\u6846\u7EBF",borderTd:"\u5355\u5143\u683C\u8FB9\u6846",borderTdTop:"\u4E0A\u8FB9\u6846",borderTdRight:"\u53F3\u8FB9\u6846",borderTdBottom:"\u4E0B\u8FB9\u6846",borderTdLeft:"\u5DE6\u8FB9\u6846",borderTdForward:"\u6B63\u659C\u7EBF",borderTdBack:"\u53CD\u659C\u7EBF"}},datePicker:{now:"\u6B64\u523B",confirm:"\u786E\u5B9A",return:"\u8FD4\u56DE\u65E5\u671F",timeSelect:"\u65F6\u95F4\u9009\u62E9",weeks:{sun:"\u65E5",mon:"\u4E00",tue:"\u4E8C",wed:"\u4E09",thu:"\u56DB",fri:"\u4E94",sat:"\u516D"},year:"\u5E74",month:"\u6708",hour:"\u65F6",minute:"\u5206",second:"\u79D2"},frame:{header:"\u9875\u7709",footer:"\u9875\u811A"},pageBreak:{displayName:"\u5206\u9875\u7B26"},zone:{headerTip:"\u53CC\u51FB\u7F16\u8F91\u9875\u7709",footerTip:"\u53CC\u51FB\u7F16\u8F91\u9875\u811A"}},Hr={contextmenu:{global:{cut:"Cut",copy:"Copy",paste:"Paste",selectAll:"Select all",print:"Print"},control:{delete:"Delete control"},hyperlink:{delete:"Delete hyperlink",cancel:"Cancel hyperlink",edit:"Edit hyperlink"},image:{change:"Change image",saveAs:"Save as image",textWrap:"Text wrap",textWrapType:{embed:"Embed",upDown:"Up down",surround:"Surround",floatTop:"Float above text",floatBottom:"Float below text"}},table:{insertRowCol:"Insert row col",insertTopRow:"Insert top 1 row",insertBottomRow:"Insert bottom 1 row",insertLeftCol:"Insert left 1 col",insertRightCol:"Insert right 1 col",deleteRowCol:"Delete row col",deleteRow:"Delete 1 row",deleteCol:"Delete 1 col",deleteTable:"Delete table",mergeCell:"Merge cell",mergeCancelCell:"Cancel merge cell",verticalAlign:"Vertical align",verticalAlignTop:"Top",verticalAlignMiddle:"Middle",verticalAlignBottom:"Bottom",border:"Table border",borderAll:"All",borderEmpty:"Empty",borderDash:"Dash",borderExternal:"External",borderInternal:"Internal",borderTd:"Table cell border",borderTdTop:"Top",borderTdRight:"Right",borderTdBottom:"Bottom",borderTdLeft:"Left",borderTdForward:"Forward",borderTdBack:"Back"}},datePicker:{now:"Now",confirm:"Confirm",return:"Return",timeSelect:"Time select",weeks:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},year:" ",month:" ",hour:"Hour",minute:"Minute",second:"Second"},frame:{header:"Header",footer:"Footer"},pageBreak:{displayName:"Page Break"},zone:{headerTip:"Double click to edit header",footerTip:"Double click to edit footer"}};class Gr{constructor(t){this.langMap=new Map([["zhCN",In],["en",Hr]]),this.currentLocale=t}registerLangMap(t,e){const n=this.langMap.get(t);this.langMap.set(t,Zn(n||In,e))}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale=t}getLang(){return this.langMap.get(this.currentLocale)||In}t(t){const e=t.split(".");let n="",i=this.getLang();for(let r=0;r<e.length;r++){const s=e[r],l=Reflect.get(i,s);if(l)n=i=l;else return""}return n}}class xr{constructor(){this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class Jr{constructor(t,e){this.draw=t,this.zone=e,this.i18n=t.getI18n(),this.container=t.getContainer(),this.pageContainer=t.getPageContainer();const{tipContainer:n,tipContent:i}=this._drawZoneTip();this.tipContainer=n,this.tipContent=i,this.isDisableMouseMove=!0,this.currentMoveZone=c.EditorZone.MAIN;const r=[],{header:s,footer:l}=t.getOptions();s.disabled||r.push(c.EditorZone.HEADER),l.disabled||r.push(c.EditorZone.FOOTER),r.length&&this._watchMouseMoveZoneChange(r)}_watchMouseMoveZoneChange(t){this.pageContainer.addEventListener("mousemove",oo(e=>{if(!(this.isDisableMouseMove||!this.draw.getIsPagingMode())&&!!e.offsetY)if(e.target instanceof HTMLCanvasElement){const n=this.zone.getZoneByY(e.offsetY);if(!t.includes(n)){this._updateZoneTip(!1);return}this.currentMoveZone=n,this._updateZoneTip(this.zone.getZone()===c.EditorZone.MAIN&&(n===c.EditorZone.HEADER||n===c.EditorZone.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(`${x}-zone-tip`);const e=document.createElement("span");return t.append(e),this.container.append(t),{tipContainer:t,tipContent:e}}_updateZoneTip(t,e,n){t?(this.tipContainer.classList.add("show"),this.tipContainer.style.left=`${e}px`,this.tipContainer.style.top=`${n}px`,this.tipContent.innerText=this.i18n.t(`zone.${this.currentMoveZone===c.EditorZone.HEADER?"headerTip":"footerTip"}`)):this.tipContainer.classList.remove("show")}}class vr{constructor(t){this.INDICATOR_PADDING=2,this.INDICATOR_TITLE_TRANSLATE=[20,5],this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=c.EditorZone.MAIN,this.indicatorContainer=null,this.options.zone.tipDisabled||new Jr(t,this)}isHeaderActive(){return this.getZone()===c.EditorZone.HEADER}isMainActive(){return this.getZone()===c.EditorZone.MAIN}isFooterActive(){return this.getZone()===c.EditorZone.FOOTER}getZone(){return this.currentZone}setZone(t){const{header:e,footer:n}=this.options;!e.editable&&t===c.EditorZone.HEADER||!n.editable&&t===c.EditorZone.FOOTER||this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),$e(()=>{const i=this.draw.getListener();i.zoneChange&&i.zoneChange(t);const r=this.draw.getEventBus();r.isSubscribe("zoneChange")&&r.emit("zoneChange",t)}))}getZoneByY(t){const e=this.draw.getHeader(),n=e.getHeaderTop()+e.getHeight(),i=this.draw.getFooter(),s=this.draw.getHeight()-(i.getFooterBottom()+i.getHeight());return t<n?c.EditorZone.HEADER:t>s?c.EditorZone.FOOTER:c.EditorZone.MAIN}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),[n,i]=this.INDICATOR_TITLE_TRANSLATE,r=this.draw.getPageList(),s=this.draw.getMargins(),l=this.draw.getInnerWidth(),a=this.draw.getHeight(),R=this.draw.getPageGap(),d=a+R;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${x}-zone-indicator`);const u=this.draw.getHeader(),h=this.draw.getFooter(),g=e?u.getHeight():h.getHeight(),L=e?u.getHeaderTop():a-h.getFooterBottom()-g;for(let T=0;T<r.length;T++){const O=d*T+L,P=s[3]-this.INDICATOR_PADDING,M=s[3]+l+this.INDICATOR_PADDING,f=e?O-this.INDICATOR_PADDING:O+g+this.INDICATOR_PADDING,S=e?O+g+this.INDICATOR_PADDING:O-this.INDICATOR_PADDING,I=document.createElement("div");I.innerText=this.i18n.t(`frame.${e?"header":"footer"}`),I.style.top=`${S}px`,I.style.transform=`translate(${n*t}px, ${i*t}px) scale(${t})`,this.indicatorContainer.append(I);const m=document.createElement("span");m.classList.add(`${x}-zone-indicator-border__top`),m.style.top=`${f}px`,m.style.width=`${l}px`,m.style.marginLeft=`${s[3]}px`,this.indicatorContainer.append(m);const N=document.createElement("span");N.classList.add(`${x}-zone-indicator-border__left`),N.style.top=`${O}px`,N.style.height=`${g}px`,N.style.left=`${P}px`,this.indicatorContainer.append(N);const F=document.createElement("span");F.classList.add(`${x}-zone-indicator-border__bottom`),F.style.top=`${S}px`,this.indicatorContainer.append(F);const Z=document.createElement("span");Z.classList.add(`${x}-zone-indicator-border__right`),Z.style.top=`${O}px`,Z.style.height=`${g}px`,Z.style.left=`${M}px`,this.indicatorContainer.append(Z)}this.container.append(this.indicatorContainer)}_clearZoneIndicator(){var t;(t=this.indicatorContainer)==null||t.remove(),this.indicatorContainer=null}}class Ar{constructor(t,e){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(),i=this.draw.getMargins()[3],r=this.draw.getHeight(),s=this.getHeight(),l=r-t-s;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:l,innerWidth:e,zone:c.EditorZone.FOOTER})}getFooterBottom(){const{footer:{bottom:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{footer:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*Wn[t])}getHeight(){if(this.options.footer.disabled)return 0;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(),i=this.getFooterBottom()+e-t[2];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isFooterActive()?1:this.options.footer.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),r=[];let s=0;for(let l=0;l<this.rowList.length;l++){const a=this.rowList[l];if(s+a.height>i)break;r.push(a),s+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:r,pageNo:e,startIndex:0,innerWidth:n,zone:c.EditorZone.FOOTER}),t.restore()}}class Br{constructor(t){this.UN_COUNT_STYLE_WIDTH=20,this.MEASURE_BASE_TEXT="0",this.LIST_GAP=10,this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}setList(t,e){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:r}=this.range.getRange();if(!~i&&!~r)return;const s=this.range.getRangeParagraphElementList();if(!s||!s.length)return;if(s.find(u=>u.listType===t&&u.listStyle===e)||!t){this.unsetList();return}const a=q();s.forEach(u=>{u.listId=a,u.listType=t,u.listStyle=e});const R=i===r,d=R?r:i;this.draw.render({curIndex:d,isSetCursor:R})}unsetList(){var R;if(this.draw.isReadonly())return;const{startIndex:e,endIndex:n}=this.range.getRange();if(!~e&&!~n)return;const i=(R=this.range.getRangeParagraphElementList())==null?void 0:R.filter(d=>d.listId);if(!i||!i.length)return;const r=this.draw.getElementList(),s=r[n];if(s.listId){let d=n+1;for(;d<r.length;){const u=r[d];if(u.value===w&&!u.listWrap)break;if(u.listId!==s.listId){this.draw.spliceElementList(r,d,0,[{value:w}]);break}d++}}i.forEach(d=>{delete d.listId,delete d.listType,delete d.listStyle,delete d.listWrap});const l=e===n,a=l?n:e;this.draw.render({curIndex:a,isSetCursor:l})}computeListStyle(t,e){const n=new Map;let i=0,r=e[i].listId,s=[];const l=e.length;for(;i<l;){const a=e[i];if(r&&r===a.listId)s.push(a);else if(a.listId&&a.listId!==r){if(s.length){const R=this.getListStyleWidth(t,s);n.set(r,R)}r=a.listId,s=r?[a]:[]}i++}if(s.length){const a=this.getListStyleWidth(t,s);n.set(r,a)}return n}findStyledElement(t){let e=t[0];for(let n=1;n<t.length;n++){const i=t[n];if(i.font||i.size||i.bold||i.italic){e=i;break}}return e}getListFontStyle(t,e){if(this.options.list.inheritStyle){const n=this.findStyledElement(t);return this.draw.getElementFont(n,e)}else{const{defaultFont:n,defaultSize:i}=this.options;return`${i*e}px ${n}`}}getListStyleWidth(t,e){const{scale:n,checkbox:i}=this.options,r=e[0];if(r.listStyle&&r.listStyle!==c.ListStyle.DECIMAL)return r.listStyle===c.ListStyle.CHECKBOX?(i.width+this.LIST_GAP)*n:this.UN_COUNT_STYLE_WIDTH*n;const s=e.reduce((R,d)=>(d.value===w&&(R+=1),R),0);if(!s)return 0;t.save(),t.font=this.getListFontStyle(e,n);const l=`${this.MEASURE_BASE_TEXT.repeat(String(s).length)}${c.KeyMap.PERIOD}`,a=t.measureText(l);return t.restore(),Math.ceil((a.width+this.LIST_GAP)*n)}drawListStyle(t,e,n){var O;const{elementList:i,offsetX:r,listIndex:s,ascent:l}=e,a=i[0];if(a.value!==w||a.listWrap)return;let R=0;const{defaultTabWidth:d,scale:u}=this.options;for(let P=1;P<i.length;P++){const M=i[P];if((M==null?void 0:M.type)!==c.ElementType.TAB)break;R+=d*u}const{coordinate:{leftTop:[h,g]}}=n,L=h-r+R,T=g+l;if(a.listStyle===c.ListStyle.CHECKBOX){const{width:P,height:M,gap:f}=this.options.checkbox,S={...a,checkbox:{value:!!((O=a.checkbox)!=null&&O.value)},metrics:{...a.metrics,width:(P+f*2)*u,height:M*u}};this.draw.getCheckboxParticle().render({ctx:t,x:L-f*u,y:T,index:0,row:{...e,elementList:[S,...e.elementList]}})}else{let P="";if(a.listType===c.ListType.UL?P=sn[a.listStyle]||sn[ee.DISC]:P=`${s+1}${c.KeyMap.PERIOD}`,!P)return;t.save(),t.font=this.getListFontStyle(i,u),t.fillText(P,L,T),t.restore()}}}const Qi=class{constructor(o){this.options=o.getOptions()}render(o,t,e,n){const{scale:i,lineBreak:{color:r,lineWidth:s}}=this.options;o.save(),o.beginPath();const l=n-Qi.HEIGHT*i/2,a=e+t.metrics.width;o.translate(a,l),o.scale(i,i),o.strokeStyle=r,o.lineWidth=s,o.lineCap="round",o.lineJoin="round",o.beginPath(),o.moveTo(8,0),o.lineTo(12,0),o.lineTo(12,6),o.lineTo(3,6),o.moveTo(3,6),o.lineTo(6,3),o.moveTo(3,6),o.lineTo(6,9),o.stroke(),o.closePath(),o.restore()}};let ue=Qi;ue.WIDTH=12,ue.HEIGHT=9,ue.GAP=3;class bi{constructor(t){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:n}=this.options,i=this.draw.getHeader().getExtraHeight(),r=this.draw.getInnerWidth(),s=this.draw.getMargins();let l=s[3];e.disabled||(l+=(ue.WIDTH+ue.GAP)*n);const a=(t==null?void 0:t.startY)||s[0]+i;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:l,startY:a,innerWidth:r})}render(t,e){const{placeholder:n=this.options.placeholder}=e||{},{data:i,font:r,size:s,color:l,opacity:a}=n;this._recovery(),this.elementList=[{value:i,font:r,size:s,color:l}],Mt(this.elementList,{editorOptions:this.options,isForceCompensation:!0}),this._compute(e);const R=this.draw.getInnerWidth();t.save(),t.globalAlpha=a,this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:this.rowList,pageNo:0,startIndex:0,innerWidth:R,isDrawLineBreak:!1}),t.restore()}}class kr{constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==c.EditorZone.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=q();return t.forEach(n=>{Array.isArray(n.groupIds)||(n.groupIds=[]),n.groupIds.push(e)}),this.draw.render({isSetCursor:!1,isCompute:!1}),e}getElementListByGroupId(t,e){var i,r;const n=[];for(let s=0;s<t.length;s++){const l=t[s];if(l.type===c.ElementType.TABLE){const a=l.trList;for(let R=0;R<a.length;R++){const d=a[R];for(let u=0;u<d.tdList.length;u++){const h=d.tdList[u],g=this.getElementListByGroupId(h.value,e);if(g.length)return n.push(...g),n}}}if((i=l==null?void 0:l.groupIds)!=null&&i.includes(e)){n.push(l);const a=t[s+1];if(!((r=a==null?void 0:a.groupIds)!=null&&r.includes(e)))break}}return n}deleteGroup(t){if(this.draw.isReadonly())return;const e=this.draw.getOriginalMainElementList(),n=this.getElementListByGroupId(e,t);if(!!n.length){for(let i=0;i<n.length;i++){const r=n[i],s=r.groupIds,l=s.findIndex(a=>a===t);s.splice(l,1),s.length||delete r.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){var n,i;for(let r=0;r<t.length;r++){const s=t[r];if(s.type===c.ElementType.TABLE){const a=s.trList;for(let R=0;R<a.length;R++){const d=a[R];for(let u=0;u<d.tdList.length;u++){const h=d.tdList[u],g=this.getContextByGroupId(h.value,e);if(g)return{...g,isTable:!0,index:r,trIndex:R,tdIndex:u,tdId:h.id,trId:d.id,tableId:s.tableId}}}}const l=t[r+1];if(((n=s.groupIds)==null?void 0:n.includes(e))&&!((i=l==null?void 0:l.groupIds)!=null&&i.includes(e)))return{isTable:!1,startIndex:r,endIndex:r}}return null}clearFillInfo(){this.fillRectMap.clear()}recordFillInfo(t,e,n,i,r){const s=t.groupIds;if(!!s)for(const l of s){const a=this.fillRectMap.get(l);a?a.width+=i:this.fillRectMap.set(l,{x:e,y:n,width:i,height:r})}}render(t){var R;if(!this.fillRectMap.size)return;const e=this.range.getRange(),i=(R=this.draw.getElementList()[e.endIndex])==null?void 0:R.groupIds,{group:{backgroundColor:r,opacity:s,activeOpacity:l,activeBackgroundColor:a}}=this.options;t.save(),this.fillRectMap.forEach((d,u)=>{const{x:h,y:g,width:L,height:T}=d;i!=null&&i.includes(u)?(t.globalAlpha=l,t.fillStyle=a):(t.globalAlpha=s,t.fillStyle=r),t.fillRect(h,g,L,T)}),t.restore(),this.clearFillInfo()}}class _r{constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:r,whiteSpace:{color:s,radius:l}}=this.options,a=e.metrics;t.save(),t.fillStyle=s,t.beginPath(),t.arc(n+a.width/2,i,l*r,0,Math.PI*2),t.fill(),t.closePath(),t.restore()}}class zr{constructor(t){this.draw=t,this.eventBus=this.draw.getEventBus(),this.pageContainer=this.draw.getPageContainer(),this.pageContainer.addEventListener("mousemove",this._mousemove.bind(this)),this.pageContainer.addEventListener("mouseenter",this._mouseenter.bind(this)),this.pageContainer.addEventListener("mouseleave",this._mouseleave.bind(this)),this.pageContainer.addEventListener("mousedown",this._mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this._mouseup.bind(this)),this.pageContainer.addEventListener("click",this._click.bind(this))}_mousemove(t){!this.eventBus.isSubscribe("mousemove")||this.eventBus.emit("mousemove",t)}_mouseenter(t){!this.eventBus.isSubscribe("mouseenter")||this.eventBus.emit("mouseenter",t)}_mouseleave(t){!this.eventBus.isSubscribe("mouseleave")||this.eventBus.emit("mouseleave",t)}_mousedown(t){!this.eventBus.isSubscribe("mousedown")||this.eventBus.emit("mousedown",t)}_mouseup(t){!this.eventBus.isSubscribe("mouseup")||this.eventBus.emit("mouseup",t)}_click(t){!this.eventBus.isSubscribe("click")||this.eventBus.emit("click",t)}}class $r{constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:n,lineNumber:{color:i,size:r,font:s,right:l,type:a}}=this.options,R=this.draw.getTextParticle(),d=this.draw.getMargins(),u=this.draw.getPosition().getOriginalMainPositionList(),g=this.draw.getPageRowList()[e];t.save(),t.fillStyle=i,t.font=`${r*n}px ${s}`;for(let L=0;L<g.length;L++){const T=g[L],{coordinate:{leftBottom:O}}=u[T.startIndex],P=a===c.LineNumberType.PAGE?L+1:T.rowIndex+1,M=R.measureText(t,{value:`${P}`}),f=d[3]-(M.width+l)*n,S=O[1]-M.actualBoundingBoxAscent*n;t.fillText(`${P}`,f,S)}t.restore()}}class jr{constructor(t){this.draw=t,this.header=t.getHeader(),this.footer=t.getFooter(),this.options=t.getOptions()}render(t){const{scale:e,pageBorder:{color:n,lineWidth:i,padding:r}}=this.options;t.save(),t.translate(.5,.5),t.strokeStyle=n,t.lineWidth=i*e;const s=this.draw.getMargins(),l=s[3]-r[3]*e,a=s[0]+this.header.getExtraHeight()-r[0]*e,R=this.draw.getInnerWidth()+(r[1]+r[3])*e,d=this.draw.getHeight()-a-this.footer.getExtraHeight()-s[2]+r[2]*e;t.rect(l,a,R,d),t.stroke(),t.restore()}}function qr(o,t){const{value:e,oldValue:n}=t;n.isTable&&!e.isTable&&o.getTableTool().dispose()}class tl{constructor(t){this.draw=t,this.eventBus=t.getEventBus(),this.execute()}execute(){this.eventBus.on("positionContextChange",t=>{qr(this.draw,t)})}}class el{constructor(t){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 L;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{defaultTrMinHeight:r}=this.options.table,s=this.draw.getElementList();let l=0;if((L=s[n])!=null&&L.listId){const T=this.position.getPositionList(),{rowIndex:O}=T[n],M=this.draw.getRowList()[O];l=(M==null?void 0:M.offsetX)||0}const a=this.draw.getContextInnerWidth()-l,R=[],d=a/e;for(let T=0;T<e;T++)R.push({width:d});const u=[];for(let T=0;T<t;T++){const O=[],P={height:r,tdList:O};for(let M=0;M<e;M++)O.push({colspan:1,rowspan:1,value:[]});u.push(P)}const h={type:c.ElementType.TABLE,value:"",colgroup:R,trList:u};Mt([h],{editorOptions:this.options}),It(s,[h],n,{editorOptions:this.options});const g=n+1;this.draw.spliceElementList(s,g,n===i?0:i-n,[h]),this.range.setRange(g,g),this.draw.render({curIndex:g,isSetCursor:!1})}insertTableTopRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tableId:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=l[n];if(a.tdList.length<s.colgroup.length){const u=a.tdList[0].rowIndex;for(let h=0;h<n;h++){const g=l[h];for(let L=0;L<g.tdList.length;L++){const T=g.tdList[L];T.rowspan>1&&T.rowIndex+T.rowspan>=u+1&&(T.rowspan+=1)}}}const R=q(),d={height:a.height,id:R,tdList:[]};for(let u=0;u<a.tdList.length;u++){const h=a.tdList[u],g=q();d.tdList.push({id:g,rowspan:1,colspan:h.colspan,value:[{value:w,size:16,tableId:i,trId:R,tdId:g}]})}l.splice(n,0,d),this.position.setPositionContext({isTable:!0,index:e,trIndex:n,tdIndex:0,tdId:d.tdList[0].id,trId:d.id,tableId:i}),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:n,tableId:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=l[n],R=l.length-1===n?a:l[n+1];if(R.tdList.length<s.colgroup.length){const h=R.tdList[0].rowIndex;for(let g=0;g<n+1;g++){const L=l[g];for(let T=0;T<L.tdList.length;T++){const O=L.tdList[T];O.rowspan>1&&O.rowIndex+O.rowspan>=h+1&&(O.rowspan+=1)}}}const d=q(),u={height:R.height,id:d,tdList:[]};for(let h=0;h<R.tdList.length;h++){const g=R.tdList[h],L=q();u.tdList.push({id:L,rowspan:1,colspan:g.colspan,value:[{value:w,size:16,tableId:i,trId:d,tdId:L}]})}l.splice(n+1,0,u),this.position.setPositionContext({isTable:!0,index:e,trIndex:n+1,tdIndex:0,tdId:u.tdList[0].id,trId:u.id,tableId:s.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}adjustColWidth(t){if(t.type!==c.ElementType.TABLE)return;const{defaultColMinWidth:e}=this.options.table,n=t.colgroup,i=n.reduce((s,l)=>s+l.width,0),r=this.draw.getOriginalInnerWidth();if(i>r){const s=n.filter(a=>a.width>e),l=(i-r)/s.length;for(let a=0;a<n.length;a++){const R=n[a];R.width-l>=e&&(R.width-=l)}}}insertTableLeftCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=n;for(let u=0;u<l.length;u++){const h=l[u],g=q();h.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:w,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:R}=this.options.table;s.colgroup.splice(a,0,{width:R}),this.adjustColWidth(s),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:i}),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:n,tableId:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=n+1;for(let u=0;u<l.length;u++){const h=l[u],g=q();h.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:w,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:R}=this.options.table;s.colgroup.splice(a,0,{width:R}),this.adjustColWidth(s),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:s.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:n,tdIndex:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=l[n],R=a.tdList[i].rowIndex;if(l.length<=1&&s.pagingIndex===0){this.deleteTable();return}for(let d=0;d<R;d++){const h=l[d].tdList;for(let g=0;g<h.length;g++){const L=h[g];L.rowIndex+L.rowspan>R&&L.rowspan--}}for(let d=0;d<a.tdList.length;d++){const u=a.tdList[d];if(u.rowspan>1){const h=q(),g=l[n+1];g.tdList.splice(d,0,{id:h,rowspan:u.rowspan-1,colspan:u.colspan,value:[{value:w,size:16,tableId:s.id,trId:g.id,tdId:h}]})}}l.splice(n,1),this.position.setPositionContext({isTable:!1}),this.range.clearRange(),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTableCol(){var u;const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,R=l[i].tdList[n].colIndex;if(!l.find(h=>h.tdList.length>1)){this.deleteTable();return}for(let h=0;h<l.length;h++){const g=l[h];for(let L=0;L<g.tdList.length;L++){const T=g.tdList[L];T.colIndex<=R&&T.colIndex+T.colspan>R&&(T.colspan>1?T.colspan--:g.tdList.splice(L,1))}}(u=s.colgroup)==null||u.splice(R,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(),n=e[t.index];let i=1,r=t.index;if(n.pagingId){r=t.index-n.pagingIndex;for(let l=r+1;l<e.length&&e[l].pagingId===n.pagingId;l++)i++}e.splice(r,i);const s=r-1;this.position.setPositionContext({isTable:!1,index:s}),this.range.setRange(s,s),this.draw.render({curIndex:s}),this.tableTool.dispose()}mergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{isCrossRowCol:e,startTdIndex:n,endTdIndex:i,startTrIndex:r,endTrIndex:s}=this.range.getRange();if(!e)return;const{index:l}=t,d=this.draw.getOriginalElementList()[l].trList;let u=d[r].tdList[n],h=d[s].tdList[i];(u.x>h.x||u.y>h.y)&&([u,h]=[h,u]);const g=u.colIndex,L=h.colIndex+(h.colspan-1),T=u.rowIndex,O=h.rowIndex+(h.rowspan-1),P=[];for(let X=0;X<d.length;X++){const E=d[X],C=[];for(let U=0;U<E.tdList.length;U++){const K=E.tdList[U],b=K.colIndex,Y=K.rowIndex;b>=g&&b<=L&&Y>=T&&Y<=O&&C.push(K)}C.length&&P.push(C)}if(!P.length)return;const M=P[P.length-1],f=P[0][0],S=M[M.length-1],I=f.x,m=f.y,N=S.x+S.width,F=S.y+S.height;for(let X=0;X<P.length;X++){const E=P[X];for(let C=0;C<E.length;C++){const U=E[C],K=U.x,b=U.y,Y=K+U.width,y=b+U.height;if(I>K||m>b||N<Y||F<y)return}}const Z=[],W=P[0][0],V=W.value[0];for(let X=0;X<P.length;X++){const E=P[X];for(let C=0;C<E.length;C++){const U=E[C];if(!(X===0&&C===0)){Z.push(U.id);const b=U.value.length>1?0:1;for(let Y=b;Y<U.value.length;Y++){const y=U.value[Y];jt(Te,V,y),W.value.push(y)}}X===0&&C!==0&&(W.colspan+=U.colspan),X!==0&&W.colIndex===U.colIndex&&(W.rowspan+=U.rowspan)}}for(let X=0;X<d.length;X++){const E=d[X];let C=0;for(;C<E.tdList.length;){const U=E.tdList[C];Z.includes(U.id)&&(E.tdList.splice(C,1),C--),C++}}this.position.setPositionContext({...t,trIndex:W.trIndex,tdIndex:W.tdIndex});const p=W.value.length-1;this.range.setRange(p,p),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,s=this.draw.getOriginalElementList()[e],l=s.trList,a=l[i],R=a.tdList[n];if(R.rowspan===1&&R.colspan===1)return;const d=R.colspan;if(R.colspan>1){for(let h=1;h<R.colspan;h++){const g=q();a.tdList.splice(n+h,0,{id:g,rowspan:1,colspan:1,value:[{value:w,size:16,tableId:s.id,trId:a.id,tdId:g}]})}R.colspan=1}if(R.rowspan>1){for(let h=1;h<R.rowspan;h++){const g=l[i+h];for(let L=0;L<d;L++){const T=q();g.tdList.splice(R.colIndex,0,{id:T,rowspan:1,colspan:1,value:[{value:w,size:16,tableId:s.id,trId:g.id,tdId:T}]})}}R.rowspan=1}const u=R.value.length-1;this.range.setRange(u,u),this.draw.render(),this.tableTool.render()}splitVerticalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:r}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,R=a[r],d=R.tdList[i];l.colgroup.splice(i+1,0,{width:this.options.table.defaultColMinWidth});for(let u=0;u<a.length;u++){const h=a[u];let g=0;for(;g<h.tdList.length;){const L=h.tdList[g];if(L.rowIndex!==d.rowIndex)L.colIndex<=d.colIndex&&L.colIndex+L.colspan>d.colIndex&&L.colspan++;else if(L.id===d.id){const T=q();R.tdList.splice(g+d.colspan,0,{id:T,rowspan:d.rowspan,colspan:1,value:[{value:w,size:16,tableId:l.id,trId:h.id,tdId:T}]}),g++}g++}}this.draw.render(),this.tableTool.render()}splitHorizontalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:r}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,d=a[r].tdList[i];let u=-1,h=0;for(;h<a.length;){if(h===u){h++;continue}const g=a[h];let L=0;for(;L<g.tdList.length;){const T=g.tdList[L];if(T.id===d.id){const O=q(),P=q();a.splice(h+d.rowspan,0,{id:O,height:this.options.table.defaultTrMinHeight,tdList:[{id:P,rowspan:1,colspan:d.colspan,value:[{value:w,size:16,tableId:l.id,trId:O,tdId:P}]}]}),u=h+d.rowspan}else T.rowIndex>=d.rowIndex&&T.rowIndex<d.rowIndex+d.rowspan&&T.rowIndex+T.rowspan>=d.rowIndex+d.rowspan&&T.rowspan++;L++}h++}this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const r=e[i];for(let s=0;s<r.length;s++){const l=r[s];!l||l.verticalAlign===t||!l.verticalAlign&&t===c.VerticalAlign.TOP||(l.verticalAlign=t)}}const{endIndex:n}=this.range.getRange();this.draw.render({curIndex:n})}tableBorderType(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,r=this.draw.getOriginalElementList()[n];if(!r.borderType&&t===c.TableBorder.ALL||r.borderType===t)return;r.borderType=t;const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s})}tableBorderColor(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,r=this.draw.getOriginalElementList()[n];if(!r.borderColor&&t===this.options.table.defaultBorderColor||r.borderColor===t)return;r.borderColor=t;const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s,isCompute:!1})}tableTdBorderType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(s=>{var l;return!((l=s.borderTypes)!=null&&l.includes(t))});n.forEach(s=>{s.borderTypes||(s.borderTypes=[]);const l=s.borderTypes.findIndex(a=>a===t);i?~l||s.borderTypes.push(t):~l&&s.borderTypes.splice(l,1),s.borderTypes.length||delete s.borderTypes});const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdSlashType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(s=>{var l;return!((l=s.slashTypes)!=null&&l.includes(t))});n.forEach(s=>{s.slashTypes||(s.slashTypes=[]);const l=s.slashTypes.findIndex(a=>a===t);i?~l||s.slashTypes.push(t):~l&&s.slashTypes.splice(l,1),s.slashTypes.length||delete s.slashTypes});const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdBackgroundColor(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const r=e[i];for(let s=0;s<r.length;s++){const l=r[s];l.backgroundColor=t}}const{endIndex:n}=this.range.getRange();this.range.setRange(n,n),this.draw.render({isCompute:!1})}tableSelectAll(){const t=this.position.getPositionContext(),{index:e,tableId:n,isTable:i}=t;if(!i||!n)return;const{startIndex:r,endIndex:s}=this.range.getRange(),a=this.draw.getOriginalElementList()[e].trList,R=a.length-1,d=a[R].tdList.length-1;this.range.replaceRange({startIndex:r,endIndex:s,tableId:n,startTdIndex:0,endTdIndex:d,startTrIndex:0,endTrIndex:R}),this.draw.render({isSetCursor:!1,isCompute:!1,isSubmitHistory:!1})}}c.AreaMode=void 0,function(o){o.EDIT="edit",o.READONLY="readonly",o.FORM="form"}(c.AreaMode||(c.AreaMode={}));class nl{constructor(t){this.areaInfoMap=new Map,this.draw=t,this.options=t.getOptions(),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(),n=this.draw.getElementList()[t];return(n==null?void 0:n.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 c.AreaMode.EDIT:return!1;case c.AreaMode.READONLY:return!0;case c.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:i,position:r,range:s}=t;if(this.zone.getZone()!==c.EditorZone.MAIN&&this.zone.setZone(c.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),s&&!this.getActiveAreaId()){const{startIndex:a,endIndex:R}=s,d=this.draw.getOriginalMainElementList();if(!d[a]||!d[R])return null;this.range.setRange(s.startIndex,s.endIndex)}else if(r===c.LocationPosition.BEFORE)this.range.setRange(0,0);else{const R=this.draw.getOriginalMainElementList().length-1;this.range.setRange(R,R)}const l=e||q();return this.draw.insertElementList([{type:c.ElementType.AREA,value:"",areaId:l,valueList:n,area:et(i)}]),l}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),i=this.draw.getInnerWidth();for(const r of this.areaInfoMap){const{area:s,positionList:l}=r[1];if((s==null?void 0:s.hide)||!(s!=null&&s.backgroundColor)&&!(s!=null&&s.borderColor)&&!(s!=null&&s.placeholder))continue;const a=l.filter(L=>L.pageNo===e);if(!a.length)continue;t.translate(.5,.5);const R=a[0],d=a[a.length-1],u=n[3],h=Math.ceil(R.coordinate.leftTop[1]),g=Math.ceil(d.coordinate.rightBottom[1]-h);s.backgroundColor&&(t.fillStyle=s.backgroundColor,t.fillRect(u,h,i,g)),s.borderColor&&(t.strokeStyle=s.borderColor,t.strokeRect(u,h,i,g)),s.placeholder&&l.length<=1&&new bi(this.draw).render(t,{placeholder:{...Jn,...s.placeholder},startY:R.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const i=t[n],r=i.areaId;if(r){const s=this.areaInfoMap.get(r);s?(s.elementList.push(i),s.positionList.push(e[n])):this.areaInfoMap.set(r,{id:r,area:i.area,elementList:[i],positionList:[e[n]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const n=this.areaInfoMap.get(e);return n?{area:n.area,id:n.id,startPageNo:n.positionList[0].pageNo,endPageNo:n.positionList[n.positionList.length-1].pageNo,value:rt(n.elementList)}:null}getContextByAreaId(t,e){var i,r,s;const n=this.draw.getOriginalMainElementList();for(let l=0;l<n.length;l++){const a=n[l];if((e==null?void 0:e.position)===c.LocationPosition.OUTER_BEFORE){if(((i=n[l+1])==null?void 0:i.areaId)!==t)continue}else if((e==null?void 0:e.position)===c.LocationPosition.AFTER){if(!(a.areaId===t&&((r=n[l+1])==null?void 0:r.areaId)!==t))continue}else if((e==null?void 0:e.position)===c.LocationPosition.OUTER_AFTER){if(!(a.areaId!==t&&((s=n[l-1])==null?void 0:s.areaId)===t))continue}else if(a.areaId!==t)continue;const R=this.position.getOriginalMainPositionList();return{range:{startIndex:l,endIndex:l},elementPosition:R[l]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;n.area||(n.area={});let i=!1;const r=["top","hide"];Object.entries(t.properties).forEach(([s,l])=>{if(Cn(l))return;const a=s;n.area[a]=l,r.includes(a)&&(i=!0)}),this.draw.render({isCompute:i,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:i}=n,r=this.draw.getOriginalMainElementList(),s=t.value;Mt([{type:c.ElementType.AREA,value:"",valueList:s,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(r,i[0].index,i.length,s,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class il{constructor(t){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,n,i,r,s){if(this.imageCache.has(s)){const l=this.imageCache.get(s);t.drawImage(l,e,n,i,r)}else{const l=new Image;l.setAttribute("crossOrigin","Anonymous"),l.src=s,l.onload=()=>{this.imageCache.set(s,l),t.drawImage(l,e,n,i,r)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:i}=this.options,{left:r,top:s,width:l,height:a,value:R}=this.mainBadge,d=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),u=(r||i.left)*n,h=(s||i.top)*n+d;this._drawImage(t,u,h,l*n,a*n,R)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:i,badge:r}=this.options;for(const s of n){const{positionList:l}=s[1],a=l[0];if(a.pageNo!==e)continue;const R=this.areaBadgeMap.get(s[0]);if(!R)continue;const{left:d,top:u,width:h,height:g,value:L}=R,T=(d||r.left)*i,O=(u||r.top)*i+a.coordinate.leftTop[1];this._drawImage(t,T,O,h*i,g*i,L)}}}}}class ol{constructor(t,e){this.isDrawing=!1,this.startStroke=null,this.draw=t,this.options=t.getOptions(),this.data=e||[],this.pageContainer=t.getPageContainer(),this.register()}register(){this.pageContainer.addEventListener("mousedown",this.start.bind(this)),this.pageContainer.addEventListener("mouseup",this.stop.bind(this)),this.pageContainer.addEventListener("mouseleave",this.stop.bind(this)),this.pageContainer.addEventListener("mousemove",this.drawing.bind(this))}start(t){if(!this.draw.isGraffitiMode())return;this.isDrawing=!0;const{scale:e}=this.options;this.startStroke={lineColor:this.options.graffiti.defaultLineColor,lineWidth:this.options.graffiti.defaultLineWidth,points:[t.offsetX/e,t.offsetY/e]}}stop(){this.isDrawing=!1}drawing(t){var R;if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,i=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<i&&Math.abs(this.startStroke.points[1]-n)<i)return;const r=this.draw.getPageNo();let s=this.data.find(d=>d.pageNo===r);if(this.startStroke&&(s||(s={pageNo:r,strokes:[]},this.data.push(s)),s.strokes.push(this.startStroke),this.startStroke=null),!((R=s==null?void 0:s.strokes)!=null&&R.length))return;const{scale:l}=this.options;s.strokes[s.strokes.length-1].points.push(e/l,n/l),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getValue(){return this.data}compute(){const t=this.draw.getPageRowList().length;for(let e=this.data.length-1;e>=0;e--)this.data[e].pageNo>t-1&&this.data.splice(e,1)}clear(){this.data=[]}render(t,e){var l;const n=(l=this.data.find(a=>a.pageNo===e))==null?void 0:l.strokes;if(!(n!=null&&n.length))return;const{graffiti:{defaultLineColor:i,defaultLineWidth:r},scale:s}=this.options;t.save();for(let a=0;a<n.length;a++){const R=n[a];t.beginPath(),t.strokeStyle=R.lineColor||i,t.lineWidth=(R.lineWidth||r)*s,t.moveTo(R.points[0]*s,R.points[1]*s);for(let d=2;d<R.points.length;d+=2)t.lineTo(R.points[d]*s,R.points[d+1]*s);t.stroke()}t.restore()}}class sl{constructor(t,e,n,i,r,s){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=n.main,this.listener=i,this.eventBus=r,this.override=s,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new Gr(e.locale),this.historyManager=new or(this),this.position=new sr(this),this.zone=new vr(this),this.range=new rr(this),this.margin=new Rr(this),this.background=new lr(this),this.badge=new il(this),this.search=new cr(this),this.group=new kr(this),this.area=new nl(this),this.underline=new ur(this),this.strikeout=new dr(this),this.highlight=new ar(this),this.previewer=new Dr(this),this.imageParticle=new Kn(this),this.laTexParticle=new Hn(this),this.textParticle=new hr(this),this.tableParticle=new Tr(this),this.tableTool=new Pr(this),this.tableOperate=new el(this),this.pageNumber=new de(this),this.lineNumber=new $r(this),this.waterMark=new Nr(this),this.placeholder=new bi(this),this.header=new fr(this,n.header),this.footer=new Ar(this,n.footer),this.hyperlinkParticle=new Or(this),this.labelParticle=new Mr(this),this.dateParticle=new Kr(this),this.separatorParticle=new Ir(this),this.pageBreakParticle=new Xr(this),this.superscriptParticle=new Sr,this.subscriptParticle=new mr,this.checkboxParticle=new Yr(this),this.radioParticle=new Zr(this),this.blockParticle=new wr(this),this.listParticle=new Br(this),this.lineBreakParticle=new ue(this),this.whiteSpaceParticle=new _r(this),this.control=new Vr(this),this.pageBorder=new jr(this),this.graffiti=new ol(this,n.graffiti),this.scrollObserver=new gr(this),this.selectionObserver=new Lr(this),this.imageObserver=new xr,new zr(this),this.canvasEvent=new nr(this),this.cursor=new Zs(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new ir(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new br(this),new tl(this);const{letterClass:l}=e;this.LETTER_REG=new RegExp(`[${l.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${l.map(a=>`[^${a}][${a}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.mode===c.EditorMode.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=et(this.printModeData);["header","main","footer"].forEach(n=>{t[n]=this.control.filterAssistElement(t[n])}),this.setEditorData(t)}clearPrintData(){this.printModeData&&(this.setEditorData(this.printModeData),this.printModeData=null)}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}setMode(t){this.mode!==t&&(t===c.EditorMode.PRINT&&this.setPrintData(),this.mode===c.EditorMode.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 c.EditorMode.DESIGN:return!1;case c.EditorMode.READONLY:case c.EditorMode.PRINT:case c.EditorMode.GRAFFITI:return!0;case c.EditorMode.FORM:return!this.control.getIsRangeWithinControl();default:return!1}}isDisabled(){var r,s,l,a,R;if(this.mode===c.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if((r=this.getTd())!=null&&r.disabled)return!0;if(t===e){const d=n[t],u=n[t+1];return!!(((s=d==null?void 0:d.title)==null?void 0:s.disabled)&&((l=u==null?void 0:u.title)==null?void 0:l.disabled)&&d.titleId===u.titleId||((a=d==null?void 0:d.control)==null?void 0:a.disabled)&&((R=u==null?void 0:u.control)==null?void 0:R.disabled)&&d.controlId===u.controlId)}return n.slice(t+1,e+1).some(d=>{var u,h;return((u=d.title)==null?void 0:u.disabled)||((h=d.control)==null?void 0:h.disabled)})}isDesignMode(){return this.mode===c.EditorMode.DESIGN}isPrintMode(){return this.mode===c.EditorMode.PRINT}isGraffitiMode(){return this.mode===c.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===c.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===c.PaperDirection.VERTICAL?n: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(),n=this.footer.getExtraHeight();return t[0]+t[2]+e+n}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:n,tdIndex:i}=t,s=this.getOriginalElementList()[e].trList[n].tdList[i],l=this.getTdPadding();return s.width-l[1]-l[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===c.PaperDirection.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(){const{table:{tdPadding:t},scale:e}=this.options;return t.map(n=>n*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.isSubscribe("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.isSubscribe("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:n,trIndex:i,tdIndex:r}=e;return t[n].trList[i].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}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 s;const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:r}=e;return((s=t[n].trList)==null?void 0:s[i].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:n,tdIndex:i,isTable:r}=t;return r?this.getOriginalElementList()[e].trList[n].tdList[i]:null}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{isSubmitHistory:r=!0}=e;Mt(t,{isHandleFirstElement:!1,editorOptions:this.options});let s=-1,l=this.control.getActiveControl();if(!l&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),l=this.control.getActiveControl()),l&&this.control.getIsRangeWithinControl())s=l.setValue(t,void 0,{isIgnoreDisabledRule:!0}),this.control.emitControlContentChange();else{const a=this.getElementList(),R=n===i,d=n+1;R||this.spliceElementList(a,d,i-n),this.spliceElementList(a,d,0,t),s=n+t.length;const u=a[d-1];t[0].listId&&u&&!u.listId&&(u==null?void 0:u.value)===w&&(!u.type||u.type===c.ElementType.TEXT)&&(a.splice(n,1),s-=1)}~s&&(this.range.setRange(s,s),this.render({curIndex:s,isSubmitHistory:r}))}appendElementList(t,e={}){if(!t.length)return;Mt(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:i,isSubmitHistory:r=!0}=e;i?(this.elementList.splice(1,0,...t),n=t.length):(this.elementList.push(...t),n=this.elementList.length-1),this.range.setRange(n,n),this.render({curIndex:n,isSubmitHistory:r})}spliceElementList(t,e,n,i,r){var R,d,u,h,g,L,T,O;const{isIgnoreDeletedRule:s=!1}=r||{},{group:l,modeRule:a}=this.options;if(n>0){const P=e+n,M=t[P],f=M==null?void 0:M.listId;if(f&&((R=t[e-1])==null?void 0:R.listId)!==f){let S=P;for(;S<t.length;){const I=t[S];if(I.listId!==f||I.value===w)break;delete I.listId,delete I.listType,delete I.listStyle,S++}}if(!s&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const S=(d=this.getTd())==null?void 0:d.deletable;let I=P-1;for(;I>=e;){const m=t[I];((m==null?void 0:m.hide)||((u=m==null?void 0:m.control)==null?void 0:u.hide)||((h=m==null?void 0:m.area)==null?void 0:h.hide)||S!==!1&&((g=m==null?void 0:m.control)==null?void 0:g.deletable)!==!1&&(!m.controlId||this.mode!==c.EditorMode.FORM||!a[this.mode].controlDeletableDisabled)&&((L=m==null?void 0:m.title)==null?void 0:L.deletable)!==!1&&(l.deletable!==!1||!((T=m.groupIds)!=null&&T.length))&&(((O=m==null?void 0:m.area)==null?void 0:O.deletable)!==!1||(m==null?void 0:m.areaIndex)!==0))&&t.splice(I,1),I--}}else t.splice(e,n)}if(i!=null&&i.length)for(let P=0;P<i.length;P++)t.splice(e+P,0,i[P])}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}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}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getGraffiti(){return this.graffiti}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:n}=t;e&&this.setPagePixelRatio(e);const i=this.mode,r=!!n&&i!==n;r&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const s=this.pageList.map(l=>l.toDataURL());return e&&this.setPagePixelRatio(null),r&&this.setMode(i),s}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(n=>n.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===c.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===c.PageMode.PAGING){const{height:i}=this.options,r=this.getPagePixelRatio(),s=this.pageList[0];s.style.height=`${i}px`,s.height=i*r,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(c.EditorZone.MAIN);const{startIndex:e}=this.range.getRange(),n=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),n||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.isSubscribe("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((s,l)=>{s.width=n*e,s.height=i*e,s.style.width=`${n}px`,s.style.height=`${i}px`,s.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[l])});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.isSubscribe("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(),n=this.getHeight();this.pageList.forEach((i,r)=>{i.width=e*t,i.height=n*t,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),i=this.getWidth(),r=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((s,l)=>{s.width=i*n,s.height=r*n,s.style.width=`${i}px`,s.style.height=`${r}px`,this._initPageContext(this.ctxList[l])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((r,s)=>{r.width=n*e,r.height=i*e,r.style.width=`${n}px`,r.style.height=`${i}px`,this._initPageContext(this.ctxList[s])}),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 n=this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(n=this.pageRowList[e].flatMap(r=>r.elementList)),{header:this.getHeaderElementList(),main:n,footer:this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t),{extraPickAttrs:n}=t,i={header:rt(e.header,{extraPickAttrs:n}),main:rt(e.main,{extraPickAttrs:n,isClassifyArea:!0}),footer:rt(e.footer,{extraPickAttrs:n}),graffiti:e.graffiti};return{version:xe,data:i,options:et(this.options)}}setValue(t,e){const{header:n,main:i,footer:r}=et(t);if(!n&&!i&&!r)return;const{isSetCursor:s=!1}=e||{};[n,i,r].forEach(R=>{!R||Mt(R,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:i,footer:r}),this.historyManager.recovery();const a=s?i!=null&&i.length?i.length-1:0:void 0;a!==void 0&&this.range.setRange(a,a),this.render({curIndex:a,isSetCursor:s,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:i}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),i&&this.footer.setElementList(i)}_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(Ht,c.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${x}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),i=document.createElement("canvas");i.style.width=`${e}px`,i.style.height=`${n}px`,i.style.display="block",i.style.backgroundColor="#ffffff",i.style.marginBottom=`${this.getPageGap()}px`,i.setAttribute("data-index",String(t)),this.pageContainer.append(i);const r=this.getPagePixelRatio();i.width=e*r,i.height=n*r,i.style.cursor="text";const s=i.getContext("2d");this._initPageContext(s),this.pageList.push(i),this.ctxList.push(s)}_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:n,defaultFont:i}=this.options,r=t.font||i,s=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${s*e}px ${r}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){var a;const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:i,scale:r}=this.options,s=t.size||e;let l=1;return s<12?l=s/12:s>30&&(l=1+(s-30)/30),n*l*((a=t.rowMargin)!=null?a:i)*r}computeRowList(t){var X,E,C,U,K,b,Y,y,D,H,_,v,J,z,ft,ht,it,gt,tt,j,Tt,Dt;const{innerWidth:e,elementList:n,isPagingMode:i=!1,isFromTable:r=!1,startX:s=0,startY:l=0,pageHeight:a=0,mainOuterHeight:R=0,surroundElementList:d=[]}=t,{defaultSize:u,scale:h,imgCaption:g,table:{tdPadding:L,defaultTrMinHeight:T},defaultTabWidth:O}=this.options,P=this.getDefaultBasicRowMarginHeight(),f=document.createElement("canvas").getContext("2d"),S=this.listParticle.computeListStyle(f,n),I=[];n.length&&I.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:((X=n==null?void 0:n[0])==null?void 0:X.rowFlex)||((E=n==null?void 0:n[1])==null?void 0:E.rowFlex)});let m=s,N=l,F=0,Z,W=0,V=0;const p=(lt,k)=>{const Q=lt.marginLeft||0,Xt=k&<.textIndent||0;return(Q+Xt)*h};for(let lt=0;lt<n.length;lt++){const k=I[I.length-1],Q=n[lt],Xt=this.getElementRowMargin(Q),G={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0};if(k.offsetX===void 0&&!Q.listId&&(Q.marginLeft||Q.textIndent||Q.marginRight||Q.marginTop)){const A=n[lt-1],st=lt===0||(A==null?void 0:A.value)===w||(A==null?void 0:A.type)===c.ElementType.PAGE_BREAK;k.offsetX=p(Q,st),st&&Q.marginTop&&(k.offsetY=(k.offsetY||0)+Q.marginTop*h)}const $t=k.offsetX||Q.listId&&S.get(Q.listId)||0,ye=(Q.marginRight||0)*h,B=e-$t-ye,xi=k.elementList.length===1;if(m+=xi?$t:0,N+=xi&&k.offsetY||0,(Q.hide||((C=Q.control)==null?void 0:C.hide)||((U=Q.area)==null?void 0:U.hide))&&!this.isDesignMode()){const A=k.elementList[k.elementList.length-1];G.height=(A==null?void 0:A.metrics.height)||this.options.defaultSize*h,G.boundingBoxAscent=(A==null?void 0:A.metrics.boundingBoxAscent)||0,G.boundingBoxDescent=(A==null?void 0:A.metrics.boundingBoxDescent)||0}else if(Q.type===c.ElementType.IMAGE||Q.type===c.ElementType.LATEX)if(Q.imgDisplay===c.ImageDisplay.SURROUND||Q.imgDisplay===c.ImageDisplay.FLOAT_TOP||Q.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)G.width=0,G.height=0,G.boundingBoxDescent=0;else{const A=Q.width*h,st=Q.height*h;if(A>B){const nt=st*B/A;Q.width=B/h,Q.height=nt/h,G.width=B,G.height=nt,G.boundingBoxDescent=nt}else G.width=A,G.height=st,G.boundingBoxDescent=st;if((K=Q.imgCaption)!=null&&K.value){const nt=Q.imgCaption.size||g.size,ct=(b=Q.imgCaption.top)!=null?b:g.top,_t=(nt+ct)*h;G.boundingBoxAscent+=_t}}else if(Q.type===c.ElementType.TABLE){const A=L[1]+L[3],st=L[0]+L[2];if(Q.pagingId){let Rt=lt+1,mt=0;for(;Rt<n.length;){const dt=n[Rt];if(dt.pagingId===Q.pagingId){const ut=dt.trList.filter(Ut=>!Ut.pagingRepeat);Q.trList.push(...ut),Q.height+=dt.height,Rt++,mt++}else break}mt&&n.splice(lt+1,mt)}Q.pagingIndex=(Y=Q.pagingIndex)!=null?Y:0;const nt=Q.trList;for(let Rt=0;Rt<nt.length;Rt++){const mt=nt[Rt];mt.height=mt.minHeight||T,mt.minHeight=mt.height}this.tableParticle.computeRowColInfo(Q);for(let Rt=0;Rt<nt.length;Rt++){const mt=nt[Rt];for(let dt=0;dt<mt.tdList.length;dt++){const ut=mt.tdList[dt],Ut=this.computeRowList({innerWidth:(ut.width-A)*h,elementList:ut.value,isFromTable:!0,isPagingMode:i}),Lt=Ut.reduce((pt,yt)=>pt+yt.height,0);ut.rowList=Ut;const St=Lt/h+st;if(ut.height<St){const pt=St-ut.height,yt=nt[Rt+ut.rowspan-1];yt.height+=pt,yt.tdList.forEach(kt=>{kt.height+=pt,kt.realHeight?kt.realHeight+=pt:kt.realHeight=kt.height})}let Nt=0,Et=0,Vt=0;for(;Vt<ut.rowspan;){const pt=nt[Vt+Rt]||nt[Rt];Nt+=pt.minHeight,Et+=pt.height,Vt++}ut.realMinHeight=Nt,ut.realHeight=Et,ut.mainHeight=St}}const ct=this.tableParticle.getTrListGroupByCol(nt);for(let Rt=0;Rt<ct.length;Rt++){const mt=ct[Rt];let dt=-1;for(let ut=0;ut<mt.tdList.length;ut++){const Ut=mt.tdList[ut],Lt=Ut.realHeight,St=Ut.mainHeight,Nt=Ut.realMinHeight,Et=St<Nt?Lt-Nt:Lt-St;(!~dt||Et<dt)&&(dt=Et)}if(dt>0){const ut=nt[Rt];ut.height-=dt,ut.tdList.forEach(Ut=>{Ut.height-=dt,Ut.realHeight-=dt})}}this.tableParticle.computeRowColInfo(Q);const _t=this.tableParticle.getTableHeight(Q),ki=this.tableParticle.getTableWidth(Q);Q.width=ki,Q.height=_t;const Va=ki*h,Nn=_t*h;if(G.width=Va,G.height=Nn,G.boundingBoxDescent=Nn,G.boundingBoxAscent=-Xt,((y=n[lt+1])==null?void 0:y.type)===c.ElementType.TABLE&&(G.boundingBoxAscent-=Xt),i){const Rt=this.getHeight(),mt=this.getMainOuterHeight();let dt=mt;for(let Lt=0;Lt<I.length;Lt++){const St=I[Lt],Nt=St.offsetY||0;St.height+dt+Nt>Rt||((D=I[Lt-1])==null?void 0:D.isPageBreak)?dt=mt+St.height+Nt:dt+=St.height+Nt}const ut=Xt*2*h,Ut=Q.trList[0].height*h;if((dt+Ut+ut>Rt||Q.pagingIndex!==0&&Q.trList[0].pagingRepeat||((H=n[lt-1])==null?void 0:H.type)===c.ElementType.PAGE_BREAK)&&(dt=mt),dt+ut+Nn>Rt){const Lt=Q.trList;let St=0,Nt=0,Et=0;if(Lt.length>1)for(let Vt=0;Vt<Lt.length;Vt++){const pt=Lt[Vt],yt=pt.height*h;if(dt+ut+Et+yt>Rt){const kt=pt.tdList.reduce((ne,Ge)=>ne+Ge.colspan,0);((_=Q.colgroup)==null?void 0:_.length)!==kt&&(Nt=0);break}else St=Vt+1,Nt=Lt.length-St,Et+=yt}if(Nt){const Vt=Lt.splice(St,Nt),pt=Vt.reduce((Le,pn)=>Le+pn.height,0),yt=pt*h,kt=Q.pagingId||q();Q.pagingId=kt,Q.height-=pt,G.height-=yt,G.boundingBoxDescent-=yt;const ne=et(Q);ne.pagingId=kt,ne.pagingIndex=Q.pagingIndex+1;const Ge=Lt.filter(Le=>Le.pagingRepeat);if(Ge.length){const Le=et(Ge);Le.forEach(pn=>pn.id=q()),Vt.unshift(...Le)}ne.trList=Vt,ne.id=q(),this.spliceElementList(n,lt+1,0,[ne])}}if(Q.pagingId){const Lt=this.position.getPositionContext();if(Lt.isTable){let St=-1,Nt=-1,Et=lt;for(;Et<n.length;){const Vt=n[Et];if(Vt.pagingId!==Q.pagingId)break;const pt=Vt.trList.findIndex(yt=>yt.id===Lt.trId);if(~pt){St=Et,Nt=pt;break}Et++}~St&&(Lt.index=St,Lt.trIndex=Nt,this.position.setPositionContext(Lt))}}}}else if(Q.type===c.ElementType.SEPARATOR){const{separator:{lineWidth:A}}=this.options,st=Q.lineWidth||A;Q.width=B/h,G.width=B,G.height=st*h,G.boundingBoxAscent=-Xt,G.boundingBoxDescent=-Xt+G.height}else if(Q.type===c.ElementType.PAGE_BREAK)Q.width=B/h,G.width=B,G.height=this.options.pageBreak.visible?u:0;else if(Q.type===c.ElementType.RADIO||Q.controlComponent===c.ControlComponent.RADIO){const{width:A,height:st,gap:nt}=this.options.radio,ct=A+nt*2;Q.width=ct,G.width=ct*h,G.height=st*h}else if(Q.type===c.ElementType.CHECKBOX||Q.controlComponent===c.ControlComponent.CHECKBOX){const{width:A,height:st,gap:nt}=this.options.checkbox,ct=A+nt*2;Q.width=ct,G.width=ct*h,G.height=st*h}else if(Q.type===c.ElementType.TAB)G.width=O*h,G.height=u*h,G.boundingBoxDescent=0,G.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(f,f.font);else if(Q.type===c.ElementType.BLOCK){if(!Q.width)G.width=B;else{const A=Q.width*h;G.width=Math.min(A,B)}G.height=Q.height*h,G.boundingBoxDescent=G.height,G.boundingBoxAscent=0}else if(Q.type===c.ElementType.LABEL){const{defaultSize:A,label:{defaultPadding:st}}=this.options;f.font=this.getElementFont(Q);const nt=this.textParticle.measureText(f,Q);G.width=(nt.width+st[1]+st[3])*h,G.height=(Q.size||A)*h,G.boundingBoxDescent=0,G.boundingBoxAscent=(st[0]+nt.actualBoundingBoxAscent)*h}else{const A=Q.size||u;(Q.type===c.ElementType.SUPERSCRIPT||Q.type===c.ElementType.SUBSCRIPT)&&(Q.actualSize=Math.ceil(A*.6)),G.height=(Q.actualSize||A)*h,f.font=this.getElementFont(Q);const st=this.textParticle.measureText(f,Q);G.width=st.width*h,Q.letterSpacing&&(G.width+=Q.letterSpacing*h),Q.wordSpacing&&(G.width+=Q.wordSpacing*h);const nt=this.textParticle.measureBasisWord(f,Q.font);G.boundingBoxAscent=nt.actualBoundingBoxAscent*h,G.boundingBoxDescent=nt.actualBoundingBoxDescent*h,Q.type===c.ElementType.SUPERSCRIPT?G.boundingBoxAscent+=G.height/2:Q.type===c.ElementType.SUBSCRIPT&&(G.boundingBoxDescent+=G.height/2)}const Ji=!Q.hide&&(Q.imgDisplay!==c.ImageDisplay.INLINE&&Q.type===c.ElementType.IMAGE||Q.type===c.ElementType.LATEX)?G.height+Xt:G.boundingBoxAscent+Xt,ge=Xt+G.boundingBoxAscent+G.boundingBoxDescent+Xt,Kt=Object.assign(Q,{metrics:G,left:0,style:this.getElementFont(Q,h)});(v=Kt.control)!=null&&v.minWidth&&(Kt.controlComponent&&(V+=G.width),Kt.controlComponent===c.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:k,rowElement:Kt,availableWidth:B,controlRealWidth:V}),V=0));const ot=n[lt-1];let vi=n[lt+1],we=k.width+G.width;if(this.options.wordBreak===c.WordBreak.BREAK_WORD&&(!(ot!=null&&ot.type)||(ot==null?void 0:ot.type)===c.ElementType.TEXT)&&(!Q.type||Q.type===c.ElementType.TEXT)){const A=`${(ot==null?void 0:ot.value)||""}${Q.value}`;if(this.WORD_LIKE_REG.test(A)){const{width:nt,endElement:ct}=this.textParticle.measureWord(f,n,lt),_t=nt*h;ct&&_t<=B&&(we+=_t,vi=ct)}we+=this.textParticle.measurePunctuationWidth(f,vi)*h}Q.listId&&(Q.listId!==Z?W=0:Q.value===w&&!Q.listWrap&&W++),Z=Q.listId;const Ai=this.position.setSurroundPosition({pageNo:F,rowElement:Kt,row:k,rowElementRect:{x:m,y:N,height:ge,width:G.width},availableWidth:B,surroundElementList:d});m=Ai.x,we+=Ai.rowIncreaseWidth,m+=G.width;const He=Q.type===c.ElementType.SEPARATOR||Q.type===c.ElementType.TABLE||(ot==null?void 0:ot.type)===c.ElementType.TABLE||(ot==null?void 0:ot.type)===c.ElementType.BLOCK||Q.type===c.ElementType.BLOCK||(ot==null?void 0:ot.imgDisplay)===c.ImageDisplay.INLINE||Q.imgDisplay===c.ImageDisplay.INLINE||(ot==null?void 0:ot.listId)!==Q.listId||(ot==null?void 0:ot.areaId)!==Q.areaId&&!((J=Q.area)!=null&&J.hide)||((z=Q.control)==null?void 0:z.flexDirection)===c.FlexDirection.COLUMN&&(Q.controlComponent===c.ControlComponent.CHECKBOX||Q.controlComponent===c.ControlComponent.RADIO)&&(ot==null?void 0:ot.controlComponent)===c.ControlComponent.VALUE||lt!==0&&Q.value===w&&!((ft=Q.area)!=null&&ft.hide),Bi=we>B,Xn=He||Bi;if(Xn){const A={width:G.width,height:ge,startIndex:lt,elementList:[Kt],ascent:Ji,rowIndex:k.rowIndex+1,rowFlex:((ht=n[lt])==null?void 0:ht.rowFlex)||((it=n[lt+1])==null?void 0:it.rowFlex),isPageBreak:Q.type===c.ElementType.PAGE_BREAK};if(Kt.controlComponent!==c.ControlComponent.PREFIX&&((gt=Kt.control)==null?void 0:gt.indentation)===c.ControlIndentation.VALUE_START){const st=k.elementList.findIndex(nt=>nt.controlId===Kt.controlId&&nt.controlComponent!==c.ControlComponent.PREFIX);if(~st){const ct=this.position.computeRowPosition({row:k,innerWidth:this.getInnerWidth()})[st];ct&&(A.offsetX=ct.coordinate.leftTop[0])}}Q.listId?(A.isList=!0,A.offsetX=S.get(Q.listId),A.listIndex=W):(Q.marginLeft||Q.textIndent||Q.marginRight)&&(A.offsetX=p(Q,He)),A.offsetY=!r&&((tt=Q.area)==null?void 0:tt.top)&&Q.areaId!==((j=n[lt-1])==null?void 0:j.areaId)?Q.area.top*h:0,He&&Q.marginTop&&(A.offsetY=(A.offsetY||0)+Q.marginTop*h),I.push(A)}else k.width+=G.width,lt===0&&(Re(n[1])||!!((Tt=n[1])!=null&&Tt.areaId))?(k.height=P,k.ascent=P):k.height<ge&&(k.height=ge,k.ascent=Ji),k.elementList.push(Kt);if(Xn||lt===n.length-1){k.isWidthNotEnough=Bi&&!He;let A=0;for(let st=0;st<k.elementList.length;st++){const ct=(k.elementList[st].minHeight||0)*h;ct>A&&(A=ct)}if(A>k.height&&(k.height=A),!k.isSurround&&((ot==null?void 0:ot.rowFlex)===c.RowFlex.JUSTIFY||(ot==null?void 0:ot.rowFlex)===c.RowFlex.ALIGNMENT&&k.isWidthNotEnough)){const st=((Dt=k.elementList[0])==null?void 0:Dt.value)===w?k.elementList.slice(1):k.elementList,nt=(B-k.width)/(st.length-1);for(let ct=0;ct<st.length-1;ct++){const _t=st[ct];_t.metrics.width+=nt}k.width=B}}if(Xn){m=s,N+=k.height,i&&!r&&a&&(N-l+R+ge>a||Q.type===c.ElementType.PAGE_BREAK)&&(N=l,Is(d,F),F+=1),Kt.left=0;const A=I[I.length-1];m=this.position.setSurroundPosition({pageNo:F,rowElement:Kt,row:A,rowElementRect:{x:m,y:N,height:ge,width:G.width},availableWidth:B,surroundElementList:d}).x,m+=G.width}}return I}_computePageList(){var a;const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,i=this.getHeight(),r=this.getMainOuterHeight();let s=r,l=0;if(e===c.PageMode.CONTINUITY){t[0]=this.rowList,s+=this.rowList.reduce((h,g)=>h+g.height+(g.offsetY||0),0);const R=this.getPagePixelRatio(),d=this.pageList[0],u=Number(d.style.height.replace("px",""));if(s>u)d.style.height=`${s}px`,d.height=s*R;else{const h=s<i?i:s;d.style.height=`${h}px`,d.height=h*R}this._initPageContext(this.ctxList[0])}else for(let R=0;R<this.rowList.length;R++){const d=this.rowList[R],u=d.offsetY||0;if(d.height+u+s>i||((a=this.rowList[R-1])==null?void 0:a.isPageBreak)){if(Number.isInteger(n)&&l>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}s=r+d.height+u,t.push([d]),l++}else s+=d.height+u,t[l].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:i,elementList:r}=e,s=this.getDefaultBasicRowMarginHeight(),l=this.getHighlightMarginHeight();for(let a=0;a<n.length;a++){const R=n[a];for(let d=0;d<R.elementList.length;d++){const u=R.elementList[d],h=R.elementList[d-1],g=u.highlight||this.control.getControlHighlight(r,R.startIndex+d);if(g){h&&h.highlight&&h.highlight!==u.highlight&&this.highlight.render(t);const{coordinate:{leftTop:[L,T]}}=i[R.startIndex+d],O=u.left||0;this.highlight.recordFillInfo(t,L-O,T+s-l,u.metrics.width+O,R.height-2*s+2*l,g)}else h!=null&&h.highlight&&this.highlight.render(t)}this.highlight.render(t)}}drawRow(t,e){var I,m,N,F,Z,W,V,p,X;debugger;this._drawHighlight(t,e);const{scale:n,table:{tdPadding:i},group:r,lineBreak:s,whiteSpace:l}=this.options,{rowList:a,pageNo:R,elementList:d,positionList:u,startIndex:h,zone:g,isDrawLineBreak:L=!s.disabled,isDrawWhiteSpace:T=!l.disabled}=e,O=this.isPrintMode(),P=this.isGraffitiMode(),{isCrossRowCol:M,tableId:f}=this.range.getRange();let S=h;for(let E=0;E<a.length;E++){const C=a[E],U={x:0,y:0,width:0,height:0};let K=null;for(let b=0;b<C.elementList.length;b++){const Y=C.elementList[b],y=Y.metrics,{coordinate:{leftTop:[D,H]}}=u[C.startIndex+b],_=17,v=C.elementList[b-1];if((Y.hide||((I=Y.control)==null?void 0:I.hide)||((m=Y.area)==null?void 0:m.hide))&&!this.isDesignMode())this.textParticle.complete();else if(Y.type===c.ElementType.IMAGE)this.textParticle.complete(),Y.imgDisplay!==c.ImageDisplay.SURROUND&&Y.imgDisplay!==c.ImageDisplay.FLOAT_TOP&&Y.imgDisplay!==c.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,Y,D,H+4);else if(Y.type===c.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,Y,D,H+_);else if(Y.type===c.ElementType.TABLE)M&&(U.x=D,U.y=H,K=Y),this.tableParticle.render(t,Y,D,H);else if(Y.type===c.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,Y,D,H+_);else if(Y.type===c.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,Y,D,H+_);else if(Y.type===c.ElementType.DATE){const ht=C.elementList[b+1];(!v||v.dateId!==Y.dateId)&&this.textParticle.complete(),this.textParticle.record(t,Y,D,H+_),(!ht||ht.dateId!==Y.dateId)&&this.textParticle.complete()}else Y.type===c.ElementType.SUPERSCRIPT?(this.textParticle.complete(),this.superscriptParticle.render(t,Y,D,H+_)):Y.type===c.ElementType.SUBSCRIPT?(this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,Y,D,H+_)):Y.type===c.ElementType.SEPARATOR?this.separatorParticle.render(t,Y,D,H):Y.type===c.ElementType.PAGE_BREAK?this.mode!==c.EditorMode.CLEAN&&!O&&this.options.pageBreak.visible&&this.pageBreakParticle.render(t,Y,D,H):Y.type===c.ElementType.CHECKBOX||Y.controlComponent===c.ControlComponent.CHECKBOX?(this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:D,y:H+_,index:b,row:C})):Y.type===c.ElementType.RADIO||Y.controlComponent===c.ControlComponent.RADIO?(this.textParticle.complete(),this.radioParticle.render({ctx:t,x:D,y:H+_,index:b,row:C})):Y.type===c.ElementType.TAB?this.textParticle.complete():Y.rowFlex===c.RowFlex.ALIGNMENT||Y.rowFlex===c.RowFlex.JUSTIFY?(this.textParticle.record(t,Y,D,H+_),this.textParticle.complete()):Y.type===c.ElementType.BLOCK?(this.textParticle.complete(),this.blockParticle.render(t,R,Y,D,H+_)):(Y.left&&this.textParticle.complete(),this.textParticle.record(t,Y,D,H+_),(Y.width||Y.letterSpacing||Y.wordSpacing||to.test(Y.value))&&this.textParticle.complete());if(L&&!O&&this.mode!==c.EditorMode.CLEAN&&!C.isWidthNotEnough&&b===C.elementList.length-1&&this.lineBreakParticle.render(t,Y,D,H+C.height/2),T&&no.test(Y.value)&&this.whiteSpaceParticle.render(t,Y,D,H+C.height/2),(N=Y.control)!=null&&N.border){((F=v==null?void 0:v.control)==null?void 0:F.border)&&v.controlId!==Y.controlId&&this.control.drawBorder(t);const ht=this.getElementRowMargin(Y);this.control.recordBorderInfo(D,H+ht,Y.metrics.width,C.height-2*ht)}else(Z=v==null?void 0:v.control)!=null&&Z.border&&this.control.drawBorder(t);if(Y.underline||((W=Y.control)==null?void 0:W.underline)){(v==null?void 0:v.type)===c.ElementType.SUBSCRIPT&&Y.type!==c.ElementType.SUBSCRIPT&&this.underline.render(t);const ht=this.getElementRowMargin(Y),it=Y.left||0;let gt=0;Y.type===c.ElementType.SUBSCRIPT&&(gt=this.subscriptParticle.getOffsetY(Y));const tt=(V=Y.control)!=null&&V.underline?this.options.underlineColor:Y.color;this.underline.recordFillInfo(t,D-it,H+C.height-ht+gt,y.width+it,0,tt,(p=Y.textDecoration)==null?void 0:p.style)}else((v==null?void 0:v.underline)||((X=v==null?void 0:v.control)==null?void 0:X.underline))&&this.underline.render(t);if(Y.strikeout){if(!Y.type||Qt.includes(Y.type)){v&&(v.type===c.ElementType.SUBSCRIPT&&Y.type!==c.ElementType.SUBSCRIPT||v.type===c.ElementType.SUPERSCRIPT&&Y.type!==c.ElementType.SUPERSCRIPT||this.getElementSize(v)!==this.getElementSize(Y))&&this.strikeout.render(t);const ht=this.textParticle.measureBasisWord(t,this.getElementFont(Y));let it=H+_+ht.actualBoundingBoxDescent*n-y.height/2;Y.type===c.ElementType.SUBSCRIPT?it+=this.subscriptParticle.getOffsetY(Y):Y.type===c.ElementType.SUPERSCRIPT&&(it+=this.superscriptParticle.getOffsetY(Y)),this.strikeout.recordFillInfo(t,D,it,y.width)}}else v!=null&&v.strikeout&&this.strikeout.render(t);const{zone:J,startIndex:z,endIndex:ft}=this.range.getRange();if(J===g&&z!==ft&&z<=S&&S<=ft){const ht=this.position.getPositionContext();if(!ht.isTable&&!Y.tdId||ht.tdId===Y.tdId)if(z===S){const it=d[z+1];it&&it.value===w&&(U.x=D+y.width,U.y=H,U.height=C.height,U.width+=this.options.rangeMinWidth)}else{let it=y.width;it===0&&C.elementList.length===1&&(it=this.options.rangeMinWidth),U.width||(U.x=D,U.y=H,U.height=C.height),U.width+=it}}if(!r.disabled&&Y.groupIds&&this.group.recordFillInfo(Y,D,H,y.width,C.height),S++,Y.type===c.ElementType.TABLE&&!Y.hide){const ht=i[1]+i[3];for(let it=0;it<Y.trList.length;it++){const gt=Y.trList[it];for(let tt=0;tt<gt.tdList.length;tt++){const j=gt.tdList[tt];this.drawRow(t,{elementList:j.value,positionList:j.positionList,rowList:j.rowList,pageNo:R,startIndex:0,innerWidth:(j.width-ht)*n,zone:g,isDrawLineBreak:L})}}}}if(C.isList&&this.listParticle.drawListStyle(t,C,u[C.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!O&&!P){if(U.width&&U.height){const{x:b,y:Y,width:y,height:D}=U;this.range.render(t,b,Y,y,D)}if(M&&K&&K.id===f){const{coordinate:{leftTop:[b,Y]}}=u[C.startIndex];this.tableParticle.drawRange(t,K,b,Y)}}}}_drawFloat(t,e){const{scale:n}=this.options,i=this.position.getFloatPositionList(),{imgDisplays:r,pageNo:s}=e;for(let l=0;l<i.length;l++){const a=i[l],R=a.element;if((s===a.pageNo||a.zone===c.EditorZone.HEADER||a.zone==c.EditorZone.FOOTER)&&R.imgDisplay&&r.includes(R.imgDisplay)&&R.type===c.ElementType.IMAGE){const d=R.imgFloatPosition;this.imageParticle.render(t,R,d.x*n,d.y*n)}}}_clearPage(t){const e=this.ctxList[t],n=this.pageList[t];e.clearRect(0,0,Math.max(n.width,this.getWidth()),Math.max(n.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){var P,M,f;const{elementList:e,positionList:n,rowList:i,pageNo:r}=t,{inactiveAlpha:s,pageMode:l,header:a,footer:R,pageNumber:d,lineNumber:u,pageBorder:h}=this.options,g=this.mode===c.EditorMode.PRINT,L=this.getInnerWidth(),T=this.ctxList[r];T.globalAlpha=this.zone.isMainActive()?1:s,this._clearPage(r),(!g||!((P=this.options.modeRule[c.EditorMode.PRINT])!=null&&P.backgroundDisabled))&&this.background.render(T,r),g||this.area.render(T,r),l!==c.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(T,r),g||this.margin.render(T,r),this._drawFloat(T,{pageNo:r,imgDisplays:[c.ImageDisplay.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(T,r);const O=(M=i[0])==null?void 0:M.startIndex;this.drawRow(T,{elementList:e,positionList:n,rowList:i,pageNo:r,startIndex:O,innerWidth:L,zone:c.EditorZone.MAIN}),this.getIsPagingMode()&&(a.disabled||this.header.render(T,r),d.disabled||this.pageNumber.render(T,r),R.disabled||this.footer.render(T,r)),this._drawFloat(T,{pageNo:r,imgDisplays:[c.ImageDisplay.FLOAT_TOP,c.ImageDisplay.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(T,r),this.elementList.length<=1&&!((f=this.elementList[0])!=null&&f.listId)&&this.placeholder.render(T),u.disabled||this.lineNumber.render(T,r),h.disabled||this.pageBorder.render(T),this.badge.render(T,r),this.isGraffitiMode()&&this.graffiti.render(T,r)}_disconnectLazyRender(){var t;(t=this.lazyRenderIntersectionObserver)==null||t.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(n=>{n.forEach(i=>{if(i.isIntersecting){const r=Number(i.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[r],pageNo:r})}})}),this.pageList.forEach(n=>{this.lazyRenderIntersectionObserver.observe(n)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let n=0;n<this.pageRowList.length;n++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[n],pageNo:n})}render(t){this.renderCount++;const{header:e,footer:n}=this.options,{isSubmitHistory:i=!0,isSetCursor:r=!0,isCompute:s=!0,isLazy:l=!0,isInit:a=!1,isSourceHistory:R=!1,isFirstRender:d=!1}=t||{};let{curIndex:u}=t||{};const h=this.getInnerWidth(),g=this.getIsPagingMode(),L=this.pageRowList.length;if(s){this.position.setFloatPositionList([]),g&&(e.disabled||this.header.compute(),n.disabled||this.footer.compute());const P=this.getMargins(),M=this.getHeight(),f=this.header.getExtraHeight(),S=this.getMainOuterHeight(),I=P[3],m=P[0]+f,N=gn(this.elementList);if(this.rowList=this.computeRowList({startX:I,startY:m,pageHeight:M,mainOuterHeight:S,isPagingMode:g,innerWidth:h,surroundElementList:N,elementList:this.elementList}),this.pageRowList=this._computePageList(),this.position.computePositionList(),this.area.compute(),!this.isPrintMode()){const F=this.search.getSearchKeyword();F&&this.search.compute(F),this.control.computeHighlightList()}this.isGraffitiMode()&&this.graffiti.compute()}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let P=0;P<this.pageRowList.length;P++)this.pageList[P]||this._createPage(P);const T=this.pageRowList.length,O=this.pageList.length;if(O>T){const P=O-T;this.ctxList.splice(T,P),this.pageList.splice(T,P).forEach(M=>M.remove())}l&&g?this._lazyRender():this._immediateRender(),r?u=this.setCursor(u):this.range.getIsSelection()&&this.cursor.focus(),(i&&!d||u!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(u),$e(()=>{this.range.setRangeStyle(),s&&this.control.getActiveControl()&&this.control.reAwakeControl(),s&&!this.isReadonly()&&this.position.getPositionContext().isTable&&this.tableTool.render(),s&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),L!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(i||R)&&!a&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"))})}setCursor(t){var r;const e=this.position.getPositionContext(),n=this.position.getPositionList();if(e.isTable){const{index:s,trIndex:l,tdIndex:a}=e,d=(r=this.getOriginalElementList()[s].trList)==null?void 0:r[l].tdList[a].positionList;t===void 0&&d&&(t=d.length-1);const u=d==null?void 0:d[t];this.position.setCursorPosition(u||null)}else this.position.setCursorPosition(t!==void 0?n[t]:null);let i=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const l=this.getElementList()[t];if(mo.includes(l.type)){i=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(l,a)}}return this.cursor.drawCursor({isShow:i}),t}submitHistory(t){const e=this.position.getPositionContext(),n=hn(this.elementList),i=hn(this.header.getElementList()),r=hn(this.footer.getElementList()),s=et(this.range.getRange()),l=this.pageNo,a=et(e),R=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(R),this.setPageNo(l),this.position.setPositionContext(et(a)),this.header.setElementList(et(i)),this.footer.setElementList(et(r)),this.elementList=et(n),this.range.replaceRange(et(s)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}}class Di{constructor(t){this.executeMode=t.mode.bind(t),this.executeCut=t.cut.bind(t),this.executeCopy=t.copy.bind(t),this.executePaste=t.paste.bind(t),this.executeSelectAll=t.selectAll.bind(t),this.executeBackspace=t.backspace.bind(t),this.executeSetRange=t.setRange.bind(t),this.executeReplaceRange=t.replaceRange.bind(t),this.executeSetPositionContext=t.setPositionContext.bind(t),this.executeForceUpdate=t.forceUpdate.bind(t),this.executeBlur=t.blur.bind(t),this.executeHideCursor=t.hideCursor.bind(t),this.executeUndo=t.undo.bind(t),this.executeRedo=t.redo.bind(t),this.executePainter=t.painter.bind(t),this.executeApplyPainterStyle=t.applyPainterStyle.bind(t),this.executeFormat=t.format.bind(t),this.executeFont=t.font.bind(t),this.executeSize=t.size.bind(t),this.executeSizeAdd=t.sizeAdd.bind(t),this.executeSizeMinus=t.sizeMinus.bind(t),this.executeBold=t.bold.bind(t),this.executeItalic=t.italic.bind(t),this.executeUnderline=t.underline.bind(t),this.executeStrikeout=t.strikeout.bind(t),this.executeSuperscript=t.superscript.bind(t),this.executeSubscript=t.subscript.bind(t),this.executeColor=t.color.bind(t),this.executeHighlight=t.highlight.bind(t),this.executeTitle=t.title.bind(t),this.executeList=t.list.bind(t),this.executeRowFlex=t.rowFlex.bind(t),this.executeRowMargin=t.rowMargin.bind(t),this.executeInsertTable=t.insertTable.bind(t),this.executeInsertTableTopRow=t.insertTableTopRow.bind(t),this.executeInsertTableBottomRow=t.insertTableBottomRow.bind(t),this.executeInsertTableLeftCol=t.insertTableLeftCol.bind(t),this.executeInsertTableRightCol=t.insertTableRightCol.bind(t),this.executeDeleteTableRow=t.deleteTableRow.bind(t),this.executeDeleteTableCol=t.deleteTableCol.bind(t),this.executeDeleteTable=t.deleteTable.bind(t),this.executeMergeTableCell=t.mergeTableCell.bind(t),this.executeCancelMergeTableCell=t.cancelMergeTableCell.bind(t),this.executeSplitVerticalTableCell=t.splitVerticalTableCell.bind(t),this.executeSplitHorizontalTableCell=t.splitHorizontalTableCell.bind(t),this.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.bind(t),this.executeTableBorderColor=t.tableBorderColor.bind(t),this.executeTableTdBorderType=t.tableTdBorderType.bind(t),this.executeTableTdSlashType=t.tableTdSlashType.bind(t),this.executeTableTdBackgroundColor=t.tableTdBackgroundColor.bind(t),this.executeTableSelectAll=t.tableSelectAll.bind(t),this.executeImage=t.image.bind(t),this.executeHyperlink=t.hyperlink.bind(t),this.executeDeleteHyperlink=t.deleteHyperlink.bind(t),this.executeCancelHyperlink=t.cancelHyperlink.bind(t),this.executeEditHyperlink=t.editHyperlink.bind(t),this.executeSeparator=t.separator.bind(t),this.executePageBreak=t.pageBreak.bind(t),this.executeAddWatermark=t.addWatermark.bind(t),this.executeDeleteWatermark=t.deleteWatermark.bind(t),this.executeSearch=t.search.bind(t),this.executeSearchNavigatePre=t.searchNavigatePre.bind(t),this.executeSearchNavigateNext=t.searchNavigateNext.bind(t),this.executeReplace=t.replace.bind(t),this.executePrint=t.print.bind(t),this.executeReplaceImageElement=t.replaceImageElement.bind(t),this.executeSaveAsImageElement=t.saveAsImageElement.bind(t),this.executeSetImageCrop=t.setImageCrop.bind(t),this.executeSetImageCaption=t.setImageCaption.bind(t),this.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.bind(t),this.executePageScale=t.pageScale.bind(t),this.executePageScaleRecovery=t.pageScaleRecovery.bind(t),this.executePageScaleMinus=t.pageScaleMinus.bind(t),this.executePageScaleAdd=t.pageScaleAdd.bind(t),this.executePaperSize=t.paperSize.bind(t),this.executePaperDirection=t.paperDirection.bind(t),this.executeSetPaperMargin=t.setPaperMargin.bind(t),this.executeSetMainBadge=t.setMainBadge.bind(t),this.executeSetAreaBadge=t.setAreaBadge.bind(t),this.getAreaValue=t.getAreaValue.bind(t),this.executeInsertArea=t.insertArea.bind(t),this.executeSetAreaValue=t.setAreaValue.bind(t),this.executeSetAreaProperties=t.setAreaProperties.bind(t),this.executeLocationArea=t.locationArea.bind(t),this.executeClearGraffiti=t.clearGraffiti.bind(t),this.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeUpdateElementById=t.updateElementById.bind(t),this.executeDeleteElementById=t.deleteElementById.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.bind(t),this.executeTranslate=t.translate.bind(t),this.executeSetLocale=t.setLocale.bind(t),this.executeLocationCatalog=t.locationCatalog.bind(t),this.executeWordTool=t.wordTool.bind(t),this.executeSetHTML=t.setHTML.bind(t),this.executeSetHtmlDocx=t.setHtmlDocx.bind(t),this.executeImportDocx=t.importDocx.bind(t),this.executeSetGroup=t.setGroup.bind(t),this.executeDeleteGroup=t.deleteGroup.bind(t),this.executeLocationGroup=t.locationGroup.bind(t),this.executeSetZone=t.setZone.bind(t),this.executeUpdateOptions=t.updateOptions.bind(t),this.executeInsertTitle=t.insertTitle.bind(t),this.executeFocus=t.focus.bind(t),this.executeComputeElementListHeight=t.computeElementListHeight.bind(t),this.getImage=t.getImage.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getValueAsync=t.getValueAsync.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.bind(t),this.getCursorPosition=t.getCursorPosition.bind(t),this.getRemainingContentHeight=t.getRemainingContentHeight.bind(t),this.getRange=t.getRange.bind(t),this.getRangeText=t.getRangeText.bind(t),this.getRangeContext=t.getRangeContext.bind(t),this.getRangeRow=t.getRangeRow.bind(t),this.getRangeParagraph=t.getRangeParagraph.bind(t),this.getKeywordRangeList=t.getKeywordRangeList.bind(t),this.getKeywordContext=t.getKeywordContext.bind(t),this.getCatalog=t.getCatalog.bind(t),this.getPaperMargin=t.getPaperMargin.bind(t),this.getSearchNavigateInfo=t.getSearchNavigateInfo.bind(t),this.getLocale=t.getLocale.bind(t),this.getGroupIds=t.getGroupIds.bind(t),this.getContainer=t.getContainer.bind(t),this.getTitleValue=t.getTitleValue.bind(t),this.getPositionContextByEvent=t.getPositionContextByEvent.bind(t),this.getElementById=t.getElementById.bind(t),this.executeSetControlValue=t.setControlValue.bind(t),this.executeSetControlValueList=t.setControlValueList.bind(t),this.executeSetControlExtension=t.setControlExtension.bind(t),this.executeSetControlExtensionList=t.setControlExtensionList.bind(t),this.executeSetControlProperties=t.setControlProperties.bind(t),this.executeSetControlPropertiesList=t.setControlPropertiesList.bind(t),this.executeSetControlHighlight=t.setControlHighlight.bind(t),this.getControlValue=t.getControlValue.bind(t),this.getControlList=t.getControlList.bind(t),this.executeLocationControl=t.locationControl.bind(t),this.executeInsertControl=t.insertControl.bind(t),this.executeJumpControl=t.jumpControl.bind(t)}}function Ki(o,t){let e=0;for(let n=1;n<t;n++){const i=o[n],r=o[n-1];(i.value===w&&!i.listWrap&&!i.listId||i.listId!==(r==null?void 0:r.listId)&&r.value!==w||i.titleId!==(r==null?void 0:r.titleId)&&r.value!==w)&&e++}return e}function Ot(o){const t=Number.parseFloat(o);return Number.isFinite(t)?t:0}function rl(o){const t=window.getComputedStyle(o),e=Math.round(Ot(t.width))||Math.round(o.clientWidth),n=Math.round(Ot(t.minHeight||t.height))||Math.round(o.clientHeight),i=[Math.round(Ot(t.paddingTop)),Math.round(Ot(t.paddingRight)),Math.round(Ot(t.paddingBottom)),Math.round(Ot(t.paddingLeft))];return{width:e||794,height:n||1123,margins:i}}function ll(o,t){const e=o.trim();if(!e||e==="normal")return;if(/^\d+(\.\d+)?$/.test(e)){const i=Number.parseFloat(e);return Number.isFinite(i)&&i>0?i:void 0}const n=Ot(e);if(n>0&&t>0)return n/t}function al(o){const t=window.getComputedStyle(o),e=Ot(t.fontSize)||14,n=Ze(o),i=ll(t.lineHeight,e),r=Ot(t.textIndent),s=Ot(t.marginInlineStart||t.marginLeft),l=Ot(t.marginInlineEnd||t.marginRight),a=Ot(t.marginTop);let R=Ot(t.minHeight);!R&&e&&(R=e);let d=t.whiteSpace;if(!d||d==="normal"){const h=o.querySelector("span");if(h){const g=window.getComputedStyle(h).whiteSpace;g&&g!=="normal"&&(d=g)}}(!d||d==="normal")&&o.closest(".docx, .docx-wrapper")&&(d="pre-wrap");const u={};return n!==c.RowFlex.LEFT&&(u.rowFlex=n),i!==void 0&&(u.rowMargin=i),r&&(u.textIndent=r),s&&(u.marginLeft=s),l&&(u.marginRight=l),a&&(u.marginTop=a),R&&(u.minHeight=R),d&&d!=="normal"&&(u.whiteSpace=d),u}function Rl(o,t){if(!(!o.length||!Object.keys(t).length))for(const n of o)Object.assign(n,t)}function cl(o){var r,s;const t=window.getComputedStyle(o),e={color:t.color,bold:Number(t.fontWeight)>500,italic:t.fontStyle.includes("italic"),size:Math.floor(Ot(t.fontSize))||void 0,font:(s=(r=t.fontFamily)==null?void 0:r.split(",")[0])==null?void 0:s.replace(/['"]/g,"").trim()};t.backgroundColor&&t.backgroundColor!=="rgba(0, 0, 0, 0)"&&(e.highlight=t.backgroundColor),t.textDecorationLine.includes("underline")&&(e.underline=!0),t.textDecorationLine.includes("line-through")&&(e.strikeout=!0);const n=Ot(t.letterSpacing);n&&(e.letterSpacing=n),t.whiteSpace&&t.whiteSpace!=="normal"&&(e.whiteSpace=t.whiteSpace);const i=Ot(t.minHeight);return i&&(e.minHeight=i),e}function De(o){if(o.nodeType===3){const i=o.textContent||"";if(!i)return[];const r=o.parentElement,s=r?cl(r):{};return Ft(i).map(l=>({value:l,...s}))}if(o.nodeType!==1)return[];const t=o,e=t.nodeName;if(e==="BR")return[{value:Zt}];if(e==="IMG")return yi(t);if(e==="A"){const i=t.innerText;return i?[{type:c.ElementType.HYPERLINK,value:"",valueList:Ft(i).map(r=>({value:r})),url:t.href}]:[]}const n=[];return t.childNodes.forEach(i=>{n.push(...De(i))}),n}function yi(o){const{src:t,width:e,height:n}=o,i=e||Ot(window.getComputedStyle(o).width),r=n||Ot(window.getComputedStyle(o).height);if(!t||!i||!r)return[];const s={width:i,height:r,value:t,type:c.ElementType.IMAGE,rowFlex:Ze(o.parentElement||o),verticalAlign:"text-top"};$n(o,s);const l=o.getAttribute("data-form-input");if(l)try{s.formInput=JSON.parse(l)}catch{}return[s]}function dl(o){const t=al(o),e=[];return o.childNodes.forEach(n=>{e.push(...De(n))}),e.length?(Rl(e,t),e.push({value:Zt,...t}),e):[{value:Zt,...t}]}function ul(o,t){var s;const e={type:c.ElementType.TABLE,value:Zt,colgroup:[],trList:[]},n=o.querySelectorAll("colgroup col");if(o.querySelectorAll("tr").forEach(l=>{const a=Ot(window.getComputedStyle(l).height)||0,R={height:a,minHeight:a,tdList:[]};l.querySelectorAll("th,td").forEach(d=>{const u=d,h=Ke(u,t),g={colspan:u.colSpan,rowspan:u.rowSpan,value:h,verticalAlign:window.getComputedStyle(d).verticalAlign,width:Ot(window.getComputedStyle(d).width)};u.style.backgroundColor&&(g.backgroundColor=u.style.backgroundColor),R.tdList.push(g)}),e.trList.push(R)}),!e.trList.length)return[];const i=e.trList[0].tdList.reduce((l,a)=>l+a.colspan,0),r=Math.ceil(t/Math.max(i,1));for(let l=0;l<i;l++){const a=(s=n[l])==null?void 0:s.getAttribute("width");e.colgroup.push({width:a?parseFloat(a):r})}return[e]}function Ke(o,t){const e=[];return o.childNodes.forEach(n=>{var s;if(n.nodeType!==1){n.nodeType===3&&((s=n.textContent)==null?void 0:s.trim())&&(e.push(...De(n)),e.push({value:Zt}));return}const i=n,r=i.nodeName;if(r==="P"||/^H[1-6]$/.test(r))e.push(...dl(i));else if(r==="TABLE")e.push(...ul(i,t));else if(r==="IMG")e.push(...yi(i)),e.push({value:Zt});else if(r==="BR")e.push({value:Zt});else if(r==="DIV"&&i.getAttribute("data-type")===c.ElementType.PAGE_BREAK)e.push({type:c.ElementType.PAGE_BREAK,value:Zt});else{if(r==="DIV"&&i.getAttribute("data-ce-clear")==="both")return;if(r==="ARTICLE"||r==="DIV"||r==="SECTION")e.push(...Ke(i,t));else{const l=Ke(i,t);if(l.length)e.push(...l);else{const a=De(i);a.length&&(e.push(...a),e.push({value:Zt}))}}}}),e}function hl(o,t){const e=o.querySelector("article")||o;return Ke(e,t)}function gl(o){const t=Array.from(o.querySelectorAll("section.docx")),e=Array.from(o.querySelectorAll(".ce-export-page")),n=t.length?t:e.length?e:[o],i=rl(n[0]),r=Math.max(i.width-i.margins[1]-i.margins[3],1),s=[];return n.forEach((l,a)=>{const R=hl(l,r);R.length&&s.push(...R),a<n.length-1&&s.push({type:c.ElementType.PAGE_BREAK,value:Zt})}),{paper:i,main:s}}const Ll=Math.round(595.3*96/72),Tl=Math.round(841.95*96/72),Pl=[96,120,96,120];function wi(o){const[t,e,n,i]=o;return`${t}px ${e}px ${n}px ${i}px`}function Ol(o,t){const e=document.querySelector("#tempDiv")||document.createElement("div");e.isConnected||(e.style.cssText="opacity:0;position:absolute;left:-9999px;top:0;pointer-events:none;",document.body.append(e));const n=o.trim(),i=/<section[^>]*class=["'][^"']*\bdocx\b/i.test(n),r=/class=["'][^"']*\bce-export-page\b/i.test(n);if(i||r){if(e.innerHTML=n,t){const s=e.querySelector("section.docx")||e.querySelector(".ce-export-page");s&&(s.style.padding=wi(t),s.style.boxSizing="border-box")}}else{const s=wi(t!=null?t:Pl);e.innerHTML=`<section class="docx" style="width:${Ll}px;min-height:${Tl}px;padding:${s};box-sizing:border-box;background:#fff;"><article>${n}</article></section>`}return e}function Ml(o,t){return o===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:o===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:o===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${o}px`,height:`${t}px`}}function fl(o,t){const{width:e,height:n,direction:i=c.PaperDirection.VERTICAL}=t,r=document.createElement("iframe");r.style.visibility="hidden",r.style.position="absolute",r.style.left="0",r.style.top="0",r.style.width="0",r.style.height="0",r.style.border="none",document.body.append(r);const s=r.contentWindow,l=s.document;l.open();const a=document.createElement("div"),R=Ml(e,n);o.forEach(h=>{const g=document.createElement("img");g.style.width=i===c.PaperDirection.HORIZONTAL?R.height:R.width,g.style.height=i===c.PaperDirection.HORIZONTAL?R.width:R.height,g.src=h,a.append(g)});const d=document.createElement("style"),u=`
|
|
92
92
|
* {
|
|
93
93
|
margin: 0;
|
|
94
94
|
padding: 0;
|
|
@@ -96,5 +96,5 @@ ${T||`${P+1}.`}${t(O)}${M?`
|
|
|
96
96
|
@page {
|
|
97
97
|
margin: 0;
|
|
98
98
|
size: ${R.size} ${i===c.PaperDirection.HORIZONTAL?"landscape":"portrait"};
|
|
99
|
-
}`;d.append(document.createTextNode(u)),setTimeout(()=>{l.write(`${d.outerHTML}${a.innerHTML}`),s.print(),l.close(),window.addEventListener("mouseover",()=>{r==null||r.remove()},{once:!0})})}class Pl{constructor(t){this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.canvasEvent=t.getCanvasEvent(),this.options=t.getOptions(),this.control=t.getControl(),this.workerManager=t.getWorkerManager(),this.searchManager=t.getSearch(),this.i18n=t.getI18n(),this.zone=t.getZone(),this.tableOperate=t.getTableOperate()}mode(t){this.draw.setMode(t)}async cut(){this.draw.isReadonly()||this.draw.isDisabled()||await this.canvasEvent.cut()}async copy(t){await this.canvasEvent.copy(t)}paste(t){this.draw.isReadonly()||this.draw.isDisabled()||Vs(this.canvasEvent,t)}selectAll(){this.canvasEvent.selectAll()}backspace(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.draw.getElementList(),{startIndex:n,endIndex:i}=this.range.getRange(),r=n===i;if(r&&e[n].value===w&&n===0)return;r?this.draw.spliceElementList(e,n,1):this.draw.spliceElementList(e,n+1,i-n);const s=r?n-1:n;this.range.setRange(s,s),this.draw.render({curIndex:s})}setRange(t,e,n,i,r,s,l){if(t<0||e<0||e<t)return;this.range.setRange(t,e,n,i,r,s,l);const a=t===e;this.draw.render({curIndex:a?t:void 0,isCompute:!1,isSubmitHistory:!1,isSetCursor:a})}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}setPositionContext(t){const{tableId:e,startTrIndex:n,startTdIndex:i}=t,r=this.draw.getOriginalElementList();if(e){const s=r.findIndex(d=>d.id===e);if(!~s)return;const a=r[s].trList[n],R=a.tdList[i];this.position.setPositionContext({isTable:!0,index:s,trIndex:n,tdIndex:i,tdId:R.id,trId:a.id,tableId:e})}else this.position.setPositionContext({isTable:!1})}forceUpdate(t){const{isSubmitHistory:e=!1}=t||{};this.range.clearRange(),this.draw.render({isSubmitHistory:e,isSetCursor:!1})}blur(){this.range.clearRange(),this.draw.getCursor().recoveryCursor()}hideCursor(){this.draw.getCursor().recoveryCursor()}undo(){this.draw.isReadonly()||this.historyManager.undo()}redo(){this.draw.isReadonly()||this.historyManager.redo()}painter(t){if(!t.isDblclick&&this.draw.getPainterStyle()){this.canvasEvent.clearPainterStyle();return}const e=this.range.getSelection();if(!e)return;const n={};e.forEach(i=>{Ct.forEach(s=>{const l=s;n[l]===void 0&&Reflect.set(n,l,i[l])})}),this.draw.setPainterStyle(n,t)}applyPainterStyle(){this.draw.isReadonly()||this.draw.isDisabled()||this.canvasEvent.applyPainterStyle()}format(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();let r={},s=[];if(i!=null&&i.length)s=i,r={isSetCursor:!1};else{const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];(R==null?void 0:R.value)===w&&(s.push(R),r={curIndex:l})}!s.length||(s.forEach(l=>{Ct.forEach(a=>{delete l[a]})}),this.draw.render(r))}font(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r!=null&&r.length)r.forEach(s=>{s.font=t}),this.draw.render({isSetCursor:!1});else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({font:t}),(R==null?void 0:R.value)===w?R.font=t:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}size(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{minSize:r,maxSize:s,defaultSize:l}=this.options;if(t<r||t>s)return;let a={},R=[];const d=this.range.getTextLikeSelectionElementList();if(d!=null&&d.length)R=d,a={isSetCursor:!1};else{const{endIndex:h}=this.range.getRange(),L=this.draw.getElementList()[h];this.range.setDefaultStyle({size:t}),(L==null?void 0:L.value)===w?(R.push(L),a={curIndex:h}):this.draw.render({curIndex:h,isCompute:!1,isSubmitHistory:!1})}if(!R.length)return;let u=!1;R.forEach(h=>{!h.size&&t===l||h.size&&h.size===t||(h.size=t,u=!0)}),u&&this.draw.render(a)}sizeAdd(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,maxSize:r}=this.options,s=this.range.getTextLikeSelectionElementList();let l={},a=[];if(s!=null&&s.length)a=s,l={isSetCursor:!1};else{const{endIndex:d}=this.range.getRange(),h=this.draw.getElementList()[d],g=this.range.getDefaultStyle(),L=(g==null?void 0:g.size)||h.size||i;this.range.setDefaultStyle({size:L+2>r?r:L+2}),(h==null?void 0:h.value)===w?(a.push(h),l={curIndex:d}):this.draw.render({curIndex:d,isCompute:!1,isSubmitHistory:!1})}if(!a.length)return;let R=!1;a.forEach(d=>{d.size||(d.size=i),!(d.size>=r)&&(d.size+2>r?d.size=r:d.size+=2,R=!0)}),R&&this.draw.render(l)}sizeMinus(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,minSize:r}=this.options,s=this.range.getTextLikeSelectionElementList();let l={},a=[];if(s!=null&&s.length)a=s,l={isSetCursor:!1};else{const{endIndex:d}=this.range.getRange(),h=this.draw.getElementList()[d],g=this.range.getDefaultStyle(),L=(g==null?void 0:g.size)||h.size||i;this.range.setDefaultStyle({size:L-2<r?r:L-2}),(h==null?void 0:h.value)===w?(a.push(h),l={curIndex:d}):this.draw.render({curIndex:d,isCompute:!1,isSubmitHistory:!1})}if(!a.length)return;let R=!1;a.forEach(d=>{d.size||(d.size=i),!(d.size<=r)&&(d.size-2<r?d.size=r:d.size-=2,R=!0)}),R&&this.draw.render(l)}bold(t){var r;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i!=null&&i.length){const s=i.findIndex(l=>!l.bold);i.forEach(l=>{l.bold=!!~s}),this.draw.render({isSetCursor:!1})}else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({bold:R.bold?!1:!((r=this.range.getDefaultStyle())!=null&&r.bold)}),(R==null?void 0:R.value)===w?R.bold=!R.bold:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}italic(t){var r;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i!=null&&i.length){const s=i.findIndex(l=>!l.italic);i.forEach(l=>{l.italic=!!~s}),this.draw.render({isSetCursor:!1})}else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({italic:R.italic?!1:!((r=this.range.getDefaultStyle())!=null&&r.italic)}),(R==null?void 0:R.value)===w?R.italic=!R.italic:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}underline(t,e){var s;const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r!=null&&r.length){const l=r.some(a=>!a.underline||!t&&a.textDecoration||t&&!a.textDecoration||t&&a.textDecoration&&!uo(a.textDecoration,t));r.forEach(a=>{a.underline=l,l&&t?a.textDecoration=t:delete a.textDecoration}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let l=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({underline:d!=null&&d.underline?!1:!((s=this.range.getDefaultStyle())!=null&&s.underline)}),(d==null?void 0:d.value)===w?d.underline=!d.underline:l=!1,this.draw.render({isSubmitHistory:l,curIndex:a,isCompute:!1})}}strikeout(t){var r;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i!=null&&i.length){const s=i.findIndex(l=>!l.strikeout);i.forEach(l=>{l.strikeout=!!~s}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({strikeout:R.strikeout?!1:!((r=this.range.getDefaultStyle())!=null&&r.strikeout)}),(R==null?void 0:R.value)===w?R.strikeout=!R.strikeout:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}superscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const r=i.findIndex(s=>s.type===c.ElementType.SUPERSCRIPT);i.forEach(s=>{~r?s.type===c.ElementType.SUPERSCRIPT&&(s.type=c.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===c.ElementType.TEXT||s.type===c.ElementType.SUBSCRIPT)&&(s.type=c.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const r=i.findIndex(s=>s.type===c.ElementType.SUBSCRIPT);i.forEach(s=>{~r?s.type===c.ElementType.SUBSCRIPT&&(s.type=c.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===c.ElementType.TEXT||s.type===c.ElementType.SUPERSCRIPT)&&(s.type=c.ElementType.SUBSCRIPT)}),this.draw.render({isSetCursor:!1})}color(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r!=null&&r.length)r.forEach(s=>{t?s.color=t:delete s.color}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({color:t||void 0}),(R==null?void 0:R.value)===w?t?R.color=t:delete R.color:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}highlight(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r!=null&&r.length)r.forEach(s=>{t?s.highlight=t:delete s.highlight}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({highlight:t||void 0}),(R==null?void 0:R.value)===w?t?R.highlight=t:delete R.highlight:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}title(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.draw.getElementList(),s=n===i?this.range.getRangeParagraphElementList():r.slice(n+1,i+1);if(!s||!s.length)return;const l=q(),a=this.draw.getOptions().title;s.forEach(u=>{!u.type&&u.value===w||(t?(u.level=t,u.titleId=l,Ue(u)&&(u.size=a[xn[t]],u.bold=!0)):u.titleId&&(delete u.titleId,delete u.title,delete u.level,delete u.size,delete u.bold))});const R=n===i,d=R?i:n;this.draw.render({curIndex:d,isSetCursor:R})}list(t,e){this.draw.isReadonly()||this.draw.getListParticle().setList(t,e)}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.range.getRangeRowElementList();if(!r)return;r.forEach(a=>{a.rowFlex=t});const s=n===i,l=s?i:n;this.draw.render({curIndex:l,isSetCursor:s})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.range.getRangeRowElementList();if(!r)return;r.forEach(a=>{a.rowMargin=t});const s=n===i,l=s?i:n;this.draw.render({curIndex:l,isSetCursor:s})}insertTable(t,e){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.tableOperate.insertTable(t,e)}insertTableTopRow(){this.draw.isReadonly()||this.tableOperate.insertTableTopRow()}insertTableBottomRow(){this.draw.isReadonly()||this.tableOperate.insertTableBottomRow()}insertTableLeftCol(){this.draw.isReadonly()||this.tableOperate.insertTableLeftCol()}insertTableRightCol(){this.draw.isReadonly()||this.tableOperate.insertTableRightCol()}deleteTableRow(){this.draw.isReadonly()||this.tableOperate.deleteTableRow()}deleteTableCol(){this.draw.isReadonly()||this.tableOperate.deleteTableCol()}deleteTable(){this.draw.isReadonly()||this.tableOperate.deleteTable()}mergeTableCell(){this.draw.isReadonly()||this.tableOperate.mergeTableCell()}cancelMergeTableCell(){this.draw.isReadonly()||this.tableOperate.cancelMergeTableCell()}splitVerticalTableCell(){this.draw.isReadonly()||this.tableOperate.splitVerticalTableCell()}splitHorizontalTableCell(){this.draw.isReadonly()||this.tableOperate.splitHorizontalTableCell()}tableTdVerticalAlign(t){this.draw.isReadonly()||this.tableOperate.tableTdVerticalAlign(t)}tableBorderType(t){this.draw.isReadonly()||this.tableOperate.tableBorderType(t)}tableBorderColor(t){this.draw.isReadonly()||this.tableOperate.tableBorderColor(t)}tableTdBorderType(t){this.draw.isReadonly()||this.tableOperate.tableTdBorderType(t)}tableTdSlashType(t){this.draw.isReadonly()||this.tableOperate.tableTdSlashType(t)}tableTdBackgroundColor(t){this.draw.isReadonly()||this.tableOperate.tableTdBackgroundColor(t)}tableSelectAll(){this.tableOperate.tableSelectAll()}hyperlink(t){const{valueList:e,url:n,hyperlinkId:i}=t;if(!n||!(e!=null&&e.length)||this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl())return;const{startIndex:l,endIndex:a}=this.range.getRange();!~l&&!~a||this.insertElementList([{type:c.ElementType.HYPERLINK,value:"",valueList:e,url:n,hyperlinkId:i||q()}])}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=this.draw.getElementList(),s=r[n];if(s.type!==c.ElementType.HYPERLINK)return null;let l=n;for(;l>0;){if(r[l].hyperlinkId!==s.hyperlinkId){t=l+1;break}l--}let a=n+1;for(;a<r.length;){if(r[a].hyperlinkId!==s.hyperlinkId){e=a-1;break}a++}return a===r.length&&(e=a-1),!~t||!~e?null:[t,e]}deleteHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,r]=e;this.draw.spliceElementList(n,i,r-i+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const s=i-1;this.range.setRange(s,s),this.draw.render({curIndex:s})}cancelHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,r]=e;for(let l=i;l<=r;l++){const a=n[l];delete a.type,delete a.url,delete a.hyperlinkId,delete a.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s,isCompute:!1})}editHyperlink(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=this.getHyperlinkRange();if(!n)return;const i=this.draw.getElementList(),[r,s]=n;for(let a=r;a<=s;a++){const R=i[a];R.url=t}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:l}=this.range.getRange();this.draw.render({curIndex:l,isCompute:!1})}separator(t,e){if(this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl())return;const{startIndex:r,endIndex:s}=this.range.getRange();if(!~r&&!~s)return;const l=this.draw.getElementList();let a=-1;const R=l[s+1];if(R&&R.type===c.ElementType.SEPARATOR){if(R.dashArray&&R.dashArray.join()===t.join())return;a=s,Object.assign(R,{dashArray:t,...e})}else{const d={value:Zt,type:c.ElementType.SEPARATOR,dashArray:t,...e};It(l,[d],r,{editorOptions:this.options}),r!==0&&l[r].value===w?(this.draw.spliceElementList(l,r,1,[d]),a=r-1):(this.draw.spliceElementList(l,r+1,0,[d]),a=r)}this.range.setRange(a,a),this.draw.render({curIndex:a})}pageBreak(){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.insertElementList([{type:c.ElementType.PAGE_BREAK,value:Zt}])}addWatermark(t){if(this.draw.isReadonly())return;const n=this.draw.getOptions(),{color:i,size:r,opacity:s,font:l,gap:a}=ln;n.watermark.data=t.data,n.watermark.type=t.type||c.WatermarkType.TEXT,t.width&&(n.watermark.width=t.width),t.height&&(n.watermark.height=t.height),n.watermark.color=t.color||i,n.watermark.opacity=t.opacity||s,n.watermark.size=t.size||r,n.watermark.font=t.font||l,n.watermark.repeat=!!t.repeat,t.numberType&&(n.watermark.numberType=t.numberType),n.watermark.gap=t.gap||a,this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1})}deleteWatermark(){if(this.draw.isReadonly())return;const e=this.draw.getOptions();e.watermark&&e.watermark.data&&(e.watermark={...ln},this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.draw.isDisabled())return null;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=t.id||q();return this.insertElementList([{...t,id:r,type:c.ElementType.IMAGE}]),r}search(t,e){this.searchManager.setSearchKeyword(t,e),this.draw.render({isSubmitHistory:!1})}searchNavigatePre(){this.searchManager.searchNavigatePre()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}searchNavigateNext(){this.searchManager.searchNavigateNext()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}getSearchNavigateInfo(){return this.searchManager.getSearchNavigateInfo()}replace(t,e){this.draw.getSearch().replace(t,e)}async print(){const{scale:t,printPixelRatio:e,paperDirection:n,width:i,height:r}=this.options;t!==1&&this.draw.setPageScale(1);const s=await this.draw.getDataURL({pixelRatio:e,mode:c.EditorMode.PRINT});Tl(s,{width:i,height:r,direction:n}),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==c.ElementType.IMAGE||(i.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];!n||n.type!==c.ElementType.IMAGE||Yn(n.value,`${n.id}.png`)}setImageCrop(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==c.ElementType.IMAGE||(i.imgCrop=t,this.draw.render({isSetCursor:!1,isCompute:!1}))}setImageCaption(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];(i==null?void 0:i.type)===c.ElementType.IMAGE&&(i.imgCaption=t,this.draw.render({isSetCursor:!1}))}changeImageDisplay(t,e){if(t.imgDisplay===e)return;t.imgDisplay=e;const{startIndex:n,endIndex:i}=this.range.getRange();if(e===c.ImageDisplay.SURROUND||e===c.ImageDisplay.FLOAT_TOP||e===c.ImageDisplay.FLOAT_BOTTOM){const r=this.position.getPositionList(),{pageNo:s,coordinate:{leftTop:l}}=r[n];t.imgFloatPosition={pageNo:s,x:l[0],y:l[1]}}else delete t.imgFloatPosition;this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!0,curIndex:i})}getImage(t){return this.draw.getDataURL(t)}getOptions(){return this.options}getValue(t){return this.draw.getValue(t)}getValueAsync(t){return this.draw.getWorkerManager().getValue(t)}getAreaValue(t){return this.draw.getArea().getAreaValue(t)}getHTML(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList(),r=this.draw.getHeader().getPositionList(),s=this.position.getOriginalMainPositionList(),l=this.draw.getFooter().getPositionList(),{scale:a}=t;un(e,r,a),un(n,s,a),un(i,l,a);const R=d=>{const{width:u,height:h,margins:g}=t,L=document.createElement("div");for(L.className="ce-export-page",L.style.width=`${u}px`,L.style.minHeight=`${h}px`,L.style.padding=`${g[0]}px ${g[1]}px ${g[2]}px ${g[3]}px`,L.style.boxSizing="border-box",L.style.position="relative",L.style.background="#fff";d.firstChild;)L.append(d.firstChild);return Xs(L,{keepRoot:!0})};try{return{header:R(re(e,t)),main:R(re(n,t)),footer:R(re(i,t))}}finally{Ls()}}getText(){const t=this.draw.getHeaderElementList(),e=this.draw.getOriginalMainElementList(),n=this.draw.getFooterElementList();return{header:ae(t),main:ae(e),footer:ae(n)}}getWordCount(){return this.workerManager.getWordCount()}getCursorPosition(){return this.position.getCursorPosition()}getRemainingContentHeight(){if(!this.draw.getIsPagingMode())return 0;const t=this.draw.getPageRowList(),e=t.length-1,i=(t[e]||[]).reduce((a,R)=>a+R.height+(R.offsetY||0),0),r=this.draw.getHeight(),s=this.draw.getMainOuterHeight(),l=r-(s+i);return l>0?l:0}computeElementListHeight(t){if(!t.length)return 0;const e=this.draw.getInnerWidth();if(e<=0)return 0;const n=et(t);Mt(n,{isHandleFirstElement:!1,editorOptions:this.options});const i=gn(n);return this.draw.computeRowList({innerWidth:e,elementList:n,surroundElementList:i}).reduce((s,l)=>s+l.height+(l.offsetY||0),0)}getRange(){return et(this.range.getRange())}getRangeText(){return this.range.toString()}getRangeContext(){var D,H;const t=this.range.getRange(),{startIndex:e,endIndex:n}=t;if(!~e&&!~n)return null;const i=e===n,r=this.range.toString(),s=rt(this.range.getSelectionElementList()||[]),l=this.draw.getElementList(),a=se(l[i?e:e+1],{extraPickAttrs:["id","controlComponent"]}),R=se(l[n],{extraPickAttrs:["id","controlComponent"]}),d=this.draw.getRowList(),u=this.position.getPositionList(),h=u[e],g=u[n],L=h.pageNo,T=g.pageNo,O=h.rowIndex,P=g.rowIndex,M=d[O],f=d[P];let S=0,I=0;this.draw.getCursor().getHitLineStartIndex()||(S=((D=M.elementList[0])==null?void 0:D.value)===w?h.index-M.startIndex:h.index-M.startIndex+1),h===g?I=S:I=((H=f.elementList[0])==null?void 0:H.value)===w?g.index-f.startIndex:g.index-f.startIndex+1;const m=[],N=this.draw.getOriginalHeight(),F=this.draw.getOriginalPageGap(),Z=this.position.getSelectionPositionList();if(Z){let _=null,v=0,J=null;for(let z=0;z<Z.length;z++){const{rowNo:ft,pageNo:ht,coordinate:{leftTop:it,rightTop:gt},lineHeight:tt}=Z[z];_===null||_!==ft?(J&&m.push(J),J={x:it[0],y:it[1]+ht*(N+F),width:gt[0]-it[0],height:tt},_=ft,v=it[0]):J.width=gt[0]-v,z===Z.length-1&&J&&m.push(J)}}else{const v=this.position.getPositionList()[n],{coordinate:{rightTop:J},pageNo:z,lineHeight:ft}=v;m.push({x:J[0],y:J[1]+z*(N+F),width:0,height:ft})}const W=this.draw.getZone().getZone(),{isTable:V,trIndex:p,tdIndex:X,index:E}=this.position.getPositionContext();let C=null;if(V){const v=this.draw.getOriginalElementList()[E]||null;v&&(C=rt([v])[0])}let U=null,K=null,b=e-1;for(;b>0;){const _=l[b],v=l[b-1];if(_.titleId&&_.titleId!==(v==null?void 0:v.titleId)){U=_.titleId,K=u[b].pageNo;break}b--}const Y=Ki(l,e),y=e===n?Y:Ki(l,n);return et({isCollapsed:i,startElement:a,endElement:R,startPageNo:L,endPageNo:T,startRowNo:O,endRowNo:P,startColNo:S,endColNo:I,rangeRects:m,zone:W,isTable:V,trIndex:p!=null?p:null,tdIndex:X!=null?X:null,tableElement:C,selectionText:r,selectionElementList:s,titleId:U,titleStartPageNo:K,startParagraphNo:Y,endParagraphNo:y})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?rt(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?rt(t):null}getKeywordRangeList(t){return this.range.getKeywordRangeList(t)}getKeywordContext(t){var s,l,a,R;const e=this.getKeywordRangeList(t);if(!e.length)return null;const n=[],i=this.position.getOriginalMainPositionList(),r=this.draw.getOriginalMainElementList();for(let d=0;d<e.length;d++){const u=e[d],{startIndex:h,endIndex:g,tableId:L,startTrIndex:T,startTdIndex:O}=u;let P=i;if(u.tableId){const S=r.find(I=>I.id===L);S&&(P=((R=(a=(l=(s=S.trList)==null?void 0:s[T])==null?void 0:l.tdList)==null?void 0:a[O])==null?void 0:R.positionList)||[])}const M=et(P[h]),f=et(P[g]);n.push({range:u,startPosition:M,endPosition:f})}return n}pageMode(t){this.draw.setPageMode(t)}pageScale(t){t!==this.options.scale&&this.draw.setPageScale(t)}pageScaleRecovery(){const{scale:t}=this.options;t!==1&&this.draw.setPageScale(1)}pageScaleMinus(){const{scale:t}=this.options,e=t*10-1;e>=5&&this.draw.setPageScale(e/10)}pageScaleAdd(){const{scale:t}=this.options,e=t*10+1;e<=30&&this.draw.setPageScale(e/10)}paperSize(t,e){this.draw.setPaperSize(t,e)}paperDirection(t){this.draw.setPaperDirection(t)}getPaperMargin(){return this.options.margins}setPaperMargin(t){return this.draw.setPaperMargin(t)}setMainBadge(t){this.draw.getBadge().setMainBadge(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}setAreaBadge(t){this.draw.getBadge().setAreaBadgeMap(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}insertElementList(t,e={}){if(!t.length||this.draw.isReadonly()||this.draw.isDisabled())return;const{isReplace:i=!0,ignoreContextKeys:r}=e;i||this.range.shrinkRange();const s=et(t),{startIndex:l}=this.range.getRange(),a=this.draw.getElementList();It(a,s,l,{ignoreContextKeys:r,isBreakWhenWrap:!0,editorOptions:this.options}),this.draw.insertElementList(s,e)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList(et(t),e)}updateElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;const i=[];function r(l){let a=0;for(;a<l.length;){const R=l[a];if(a++,R.type===c.ElementType.TABLE){const d=R.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];r(L.value)}}}(e&&R.id===e||n&&R.conceptId===n)&&i.push({elementList:l,index:a-1})}}const s=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const l of s)r(l);if(!!i.length){for(let l=0;l<i.length;l++){const{elementList:a,index:R}=i[l],d=a[R],u=rt([{...d,...t.properties}],{extraPickAttrs:["id"]});jt(ie,d,u[0]),Mt(u,{isHandleFirstElement:!1,editorOptions:this.options}),a[R]=u[0]}this.draw.render({isSetCursor:!1})}}deleteElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;let i=!1;function r(l){let a=0;for(;a<l.length;){const R=l[a];if(R.type===c.ElementType.TABLE){const d=R.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];r(L.value)}}}(e&&R.id===e||n&&R.conceptId===n)&&(i=!0,l.splice(a,1),a--),a++}}const s=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const l of s)r(l);!i||this.draw.render({isSetCursor:!1})}getElementById(t){const{id:e,conceptId:n}=t,i=[];if(!e&&!n)return i;const r=l=>{let a=0;for(;a<l.length;){const R=l[a];if(a++,R.type===c.ElementType.TABLE){const d=R.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];r(L.value)}}}e&&R.id!==e||n&&R.conceptId!==n||i.push(R)}},s=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const l of s)r(l);return rt(i,{extraPickAttrs:["id"]})}setValue(t,e){this.draw.setValue(t,e)}removeControl(t){if((t==null?void 0:t.id)||(t==null?void 0:t.conceptId)){const{id:e,conceptId:n}=t;let i=!1;const r=l=>{let a=l.length-1;for(;a>=0;){const R=l[a];if(R.type===c.ElementType.TABLE){const d=R.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];r(L.value)}}}a--,!(!R.control||e&&R.controlId!==e||n&&R.control.conceptId!==n)&&(i=!0,l.splice(a+1,1))}},s=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const l of s)r(l);i&&this.draw.render({isSetCursor:!1})}else{const{startIndex:e,endIndex:n}=this.range.getRange();if(e!==n||!this.draw.getElementList()[e].controlId)return;const l=this.draw.getControl().removeControl(e);if(l===null)return;this.range.setRange(l,l),this.draw.render({curIndex:l})}}translate(t){return this.i18n.t(t)}setLocale(t){this.i18n.setLocale(t)}getLocale(){return this.i18n.getLocale()}getCatalog(){return this.workerManager.getCatalog()}locationCatalog(t){const e=this.draw.getOriginalElementList();function n(P,M){var f;for(let S=0;S<P.length;S++){const I=P[S];if(I.type===c.ElementType.TABLE){const m=I.trList;for(let N=0;N<m.length;N++){const F=m[N];for(let Z=0;Z<F.tdList.length;Z++){const W=F.tdList[Z],V=n(W.value,M);if(V)return{...V,isTable:!0,index:S,trIndex:N,tdIndex:Z,tdId:W.id,trId:F.id,tableId:I.id}}}}if(I.titleId===M){let m=S;for(;m<P.length;){if(((f=P[m+1])==null?void 0:f.titleId)!==M)return{isTable:!1,startIndex:m,endIndex:m};m++}}}return null}const i=n(e,t);if(!i)return;const{isTable:r,index:s,startTdIndex:l,endTdIndex:a,startTrIndex:R,endTrIndex:d,trIndex:u,tdIndex:h,tdId:g,trId:L,tableId:T,endIndex:O}=i;this.position.setPositionContext({isTable:r,index:s,trIndex:u,tdIndex:h,tdId:g,trId:L,tableId:T}),this.range.setRange(O,O,T,l,a,R,d),this.draw.render({curIndex:O,isCompute:!1,isSubmitHistory:!1})}wordTool(){const t=this.draw.getMainElementList();let e=!1;for(let n=0;n<t.length;n++)if(t[n].value===w)for(;n+1<t.length;){const r=t[n+1];if(r.value!==w&&r.value!==Je)break;t.splice(n+1,1),e=!0}if(e)this.draw.render({isSetCursor:!1});else{const n=this.range.getIsCollapsed();this.draw.getCursor().drawCursor({isShow:n})}}setHTML(t){const{header:e,main:n,footer:i,container:r}=t,s=this.draw.getOriginalInnerWidth(),l=a=>a!==void 0?le(a,{innerWidth:s,container:r}):void 0;this.setValue({header:l(e),main:l(n),footer:l(i)})}setHtmlDocx(t){const{container:e,margins:n}=t;if(!e)return;const{paper:i,main:r}=gl(e);this.options.margins=n!=null?n:i.margins,this.draw.setPaperSize(i.width,i.height),this.setValue({main:r})}setGroup(){return this.draw.isReadonly()?null:this.draw.getGroup().setGroup()}deleteGroup(t){this.draw.isReadonly()||this.draw.getGroup().deleteGroup(t)}getGroupIds(){return this.draw.getWorkerManager().getGroupIds()}locationGroup(t){const e=this.draw.getOriginalMainElementList(),n=this.draw.getGroup().getContextByGroupId(e,t);if(!n)return;const{isTable:i,index:r,trIndex:s,tdIndex:l,tdId:a,trId:R,tableId:d,endIndex:u}=n;this.position.setPositionContext({isTable:i,index:r,trIndex:s,tdIndex:l,tdId:a,trId:R,tableId:d}),this.range.setRange(u,u),this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}setZone(t){this.draw.getZone().setZone(t)}getControlValue(t){return this.draw.getControl().getValueById(t)}setControlValue(t){this.draw.getControl().setValueListById([t])}setControlValueList(t){this.draw.getControl().setValueListById(t)}setControlExtension(t){this.draw.getControl().setExtensionListById([t])}setControlExtensionList(t){this.draw.getControl().setExtensionListById(t)}setControlProperties(t){this.draw.getControl().setPropertiesListById([t])}setControlPropertiesList(t){this.draw.getControl().setPropertiesListById(t)}setControlHighlight(t){this.draw.getControl().setHighlightList(t),this.draw.render({isSubmitHistory:!1})}updateOptions(t){const e=an(t);Object.entries(e).forEach(([n,i])=>{Reflect.set(this.options,n,i)}),this.forceUpdate()}getControlList(){return this.draw.getControl().getList()}locationControl(t,e){function n(r,s){var a,R,d;let l=0;for(;l<r.length;){const u=r[l];if(l++,u.type===c.ElementType.TABLE){const g=u.trList;for(let L=0;L<g.length;L++){const T=g[L];for(let O=0;O<T.tdList.length;O++){const P=T.tdList[O],M=n(P.value,s);if(M)return{...M,positionContext:{isTable:!0,index:l-1,trIndex:L,tdIndex:O,tdId:u.tdId,trId:u.trId,tableId:u.tableId}}}}}if((u==null?void 0:u.controlId)!==t)continue;let h=l-1;if((e==null?void 0:e.position)===c.LocationPosition.OUTER_AFTER){if(!(u.controlComponent===c.ControlComponent.POSTFIX&&((a=r[l+1])==null?void 0:a.controlComponent)!==c.ControlComponent.POST_TEXT))continue}else if((e==null?void 0:e.position)===c.LocationPosition.OUTER_BEFORE)h-=1;else if((e==null?void 0:e.position)===c.LocationPosition.AFTER){if(h-=1,u.controlComponent!==c.ControlComponent.PLACEHOLDER&&u.controlComponent!==c.ControlComponent.POSTFIX&&u.controlComponent!==c.ControlComponent.POST_TEXT)continue}else if(u.controlComponent!==c.ControlComponent.PREFIX&&u.controlComponent!==c.ControlComponent.PRE_TEXT||((R=r[l])==null?void 0:R.controlComponent)===c.ControlComponent.PREFIX||((d=r[l])==null?void 0:d.controlComponent)===c.ControlComponent.PRE_TEXT)continue;return{zone:s,range:{startIndex:h,endIndex:h},positionContext:{isTable:!1}}}return null}const i=[{zone:c.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:c.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:c.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const r of i){const s=n(r.elementList,r.zone);if(s){this.setZone(s.zone),this.position.setPositionContext(s.positionContext),this.range.replaceRange(s.range),this.draw.render({curIndex:s.range.startIndex,isCompute:!1,isSubmitHistory:!1});break}}}insertControl(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=et(t),{startIndex:i}=this.range.getRange(),r=this.draw.getElementList(),s=Ee(r,i);if(!s)return;const l=[...Te,...te,...We,...ie];jt(l,s,n),this.draw.insertElementList([n])}jumpControl(t){this.draw.getControl().initNextControl({direction:t==null?void 0:t.direction})}getContainer(){return this.draw.getContainer()}getTitleValue(t){const{conceptId:e}=t,n=[],i=(s,l)=>{var R;let a=0;for(;a<s.length;){const d=s[a];if(a++,d.type===c.ElementType.TABLE){const g=d.trList;for(let L=0;L<g.length;L++){const T=g[L];for(let O=0;O<T.tdList.length;O++){const P=T.tdList[O];i(P.value,l)}}}if(((R=d==null?void 0:d.title)==null?void 0:R.conceptId)!==e)continue;const u=[];let h=a;for(;h<s.length;){const g=s[h];if(h++,d.titleId!==g.titleId){if(g.level&&rn[g.level]<=rn[d.level])break;u.push(g)}}n.push({...d.title,value:ae(u),elementList:rt(u),zone:l}),a=h}},r=[{zone:c.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:c.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:c.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:s,elementList:l}of r)i(l,s);return n}getPositionContextByEvent(t,e={}){var S,I,m;const n=(S=t.target)==null?void 0:S.dataset.index;if(!n)return null;const{isMustDirectHit:i=!0}=e,r=Number(n),s=this.position.getPositionByXY({x:t.offsetX,y:t.offsetY,pageNo:r}),{isDirectHit:l,isTable:a,index:R,trIndex:d,tdIndex:u,tdValueIndex:h,zone:g}=s;if(i&&!l||g&&g!==this.zone.getZone())return null;let L=null,T=null;const O=this.draw.getOriginalElementList();let P=null;const M=this.position.getOriginalPositionList();if(a){const N=(I=O[R].trList)==null?void 0:I[d].tdList[u];T=(N==null?void 0:N.value[h])||null,P=((m=N==null?void 0:N.positionList)==null?void 0:m[h])||null,L={element:O[R],trIndex:d,tdIndex:u}}else T=O[R]||null,P=M[R]||null;let f=null;if(P){const{pageNo:N,coordinate:{leftTop:F,rightTop:Z},lineHeight:W}=P,V=this.draw.getOriginalHeight(),p=this.draw.getOriginalPageGap();f={x:F[0],y:F[1]+N*(V+p),width:Z[0]-F[0],height:W}}return{pageNo:r,element:T,rangeRect:f,tableInfo:L}}insertTitle(t){var a;if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=et(t),{startIndex:i}=this.range.getRange(),r=this.draw.getElementList(),s=Ee(r,i);if(!s)return;const l=[...Te,...te,...We,...ie];(a=n.valueList)==null||a.forEach(R=>{jt(l,s,R)}),this.draw.insertElementList([n])}focus(t){var a,R;const{position:e=c.LocationPosition.AFTER,isMoveCursorToVisible:n=!0,rowNo:i,range:r}=t||{};let s=-1;if(r)this.range.replaceRange(r),s=e===c.LocationPosition.BEFORE?r.startIndex:r.endIndex;else if(ze(i)){const d=this.draw.getOriginalRowList();if(s=e===c.LocationPosition.BEFORE?(a=d[i])==null?void 0:a.startIndex:((R=d[i+1])==null?void 0:R.startIndex)-1,!ze(s))return;this.range.setRange(s,s)}else s=e===c.LocationPosition.BEFORE?0:this.draw.getOriginalMainElementList().length-1,this.range.setRange(s,s);const l={isCompute:!1,isSetCursor:!1,isSubmitHistory:!1};n&&~s&&this.range.getIsCollapsed()&&(l.curIndex=s,l.isSetCursor=!0),this.draw.render(l)}insertArea(t){return this.draw.getArea().insertArea(t)}setAreaValue(t){return this.draw.getArea().setAreaValue(t)}setAreaProperties(t){this.draw.getArea().setAreaProperties(t)}locationArea(t,e){if((e==null?void 0:e.isAppendLastLineBreak)&&(e==null?void 0:e.position)===c.LocationPosition.OUTER_AFTER){const r=this.draw.getOriginalMainElementList();r[r.length-1].areaId===t&&this.draw.appendElementList([{value:w}],{isSubmitHistory:!1})}const n=this.draw.getArea().getContextByAreaId(t,e);if(!n)return;const{range:{endIndex:i}}=n;this.position.setPositionContext({isTable:!1}),this.range.setRange(i,i),this.draw.render({curIndex:i,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1})}clearGraffiti(){this.draw.getGraffiti().clear(),this.draw.isGraffitiMode()&&this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}}class Ol{constructor(){this.rangeStyleChange=null,this.visiblePageNoListChange=null,this.intersectionPageNoChange=null,this.pageSizeChange=null,this.pageScaleChange=null,this.saved=null,this.contentChange=null,this.controlChange=null,this.controlContentChange=null,this.pageModeChange=null,this.zoneChange=null}}class Ml{constructor(t){const{contextMenu:e,shortcut:n,i18n:i}=t;this.contextMenuList=e.registerContextMenuList.bind(e),this.getContextMenuList=e.getContextMenuList.bind(e),this.shortcutList=n.registerShortcutList.bind(n),this.langMap=i.registerLangMap.bind(i)}}const wi={SELECTED_TEXT:"%s"},he={GLOBAL:{CUT:"globalCut",COPY:"globalCopy",PASTE:"globalPaste",SELECT_ALL:"globalSelectAll",PRINT:"globalPrint"},CONTROL:{DELETE:"controlDelete"},HYPERLINK:{DELETE:"hyperlinkDelete",CANCEL:"hyperlinkCancel",EDIT:"hyperlinkEdit"},IMAGE:{CHANGE:"imageChange",SAVE_AS:"imageSaveAs",TEXT_WRAP:"imageTextWrap",TEXT_WRAP_EMBED:"imageTextWrapEmbed",TEXT_WRAP_UP_DOWN:"imageTextWrapUpDown",TEXT_WRAP_SURROUND:"imageTextWrapSurround",TEXT_WRAP_FLOAT_TOP:"imageTextWrapFloatTop",TEXT_WRAP_FLOAT_BOTTOM:"imageTextWrapFloatBottom"},TABLE:{BORDER:"border",BORDER_ALL:"tableBorderAll",BORDER_EMPTY:"tableBorderEmpty",BORDER_DASH:"tableBorderDash",BORDER_EXTERNAL:"tableBorderExternal",BORDER_INTERNAL:"tableBorderInternal",BORDER_TD:"tableBorderTd",BORDER_TD_TOP:"tableBorderTdTop",BORDER_TD_RIGHT:"tableBorderTdRight",BORDER_TD_BOTTOM:"tableBorderTdBottom",BORDER_TD_LEFT:"tableBorderTdLeft",BORDER_TD_FORWARD:"tableBorderTdForward",BORDER_TD_BACK:"tableBorderTdBack",VERTICAL_ALIGN:"tableVerticalAlign",VERTICAL_ALIGN_TOP:"tableVerticalAlignTop",VERTICAL_ALIGN_MIDDLE:"tableVerticalAlignMiddle",VERTICAL_ALIGN_BOTTOM:"tableVerticalAlignBottom",INSERT_ROW_COL:"tableInsertRowCol",INSERT_TOP_ROW:"tableInsertTopRow",INSERT_BOTTOM_ROW:"tableInsertBottomRow",INSERT_LEFT_COL:"tableInsertLeftCol",INSERT_RIGHT_COL:"tableInsertRightCol",DELETE_ROW_COL:"tableDeleteRowCol",DELETE_ROW:"tableDeleteRow",DELETE_COL:"tableDeleteCol",DELETE_TABLE:"tableDeleteTable",MERGE_CELL:"tableMergeCell",CANCEL_MERGE_CELL:"tableCancelMergeCell"}},{CONTROL:{DELETE:fl}}=he,Sl=[{key:fl,i18nPath:"contextmenu.control.delete",when:o=>{var t;return!o.isReadonly&&!o.editorHasSelection&&!!((t=o.startElement)!=null&&t.controlId)&&o.options.mode!==c.EditorMode.FORM},callback:o=>{o.executeRemoveControl()}}],{GLOBAL:{CUT:ml,COPY:Il,PASTE:Xl,SELECT_ALL:Nl,PRINT:pl}}=he,Fl=[{key:ml,i18nPath:"contextmenu.global.cut",shortCut:`${qt?"\u2318":"Ctrl"} + X`,when:o=>!o.isReadonly,callback:o=>{o.executeCut()}},{key:Il,i18nPath:"contextmenu.global.copy",shortCut:`${qt?"\u2318":"Ctrl"} + C`,when:o=>o.editorHasSelection||o.isCrossRowCol,callback:o=>{o.executeCopy()}},{key:Xl,i18nPath:"contextmenu.global.paste",shortCut:`${qt?"\u2318":"Ctrl"} + V`,when:o=>!o.isReadonly&&o.editorTextFocus,callback:o=>{o.executePaste()}},{key:Nl,i18nPath:"contextmenu.global.selectAll",shortCut:`${qt?"\u2318":"Ctrl"} + A`,when:o=>o.editorTextFocus,callback:o=>{o.executeSelectAll()}},{isDivider:!0},{key:pl,i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:o=>{o.executePrint()}}],{HYPERLINK:{DELETE:Wl,CANCEL:Vl,EDIT:Yl}}=he,Zl=[{key:Wl,i18nPath:"contextmenu.hyperlink.delete",when:o=>{var t;return!o.isReadonly&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.HYPERLINK},callback:o=>{o.executeDeleteHyperlink()}},{key:Vl,i18nPath:"contextmenu.hyperlink.cancel",when:o=>{var t;return!o.isReadonly&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.HYPERLINK},callback:o=>{o.executeCancelHyperlink()}},{key:Yl,i18nPath:"contextmenu.hyperlink.edit",when:o=>{var t;return!o.isReadonly&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.HYPERLINK},callback:(o,t)=>{var n;const e=window.prompt(o.executeTranslate("contextmenu.hyperlink.edit"),(n=t.startElement)==null?void 0:n.url);e&&o.executeEditHyperlink(e)}}],{IMAGE:{CHANGE:Ul,SAVE_AS:El,TEXT_WRAP:Cl,TEXT_WRAP_EMBED:Ql,TEXT_WRAP_UP_DOWN:bl,TEXT_WRAP_SURROUND:Dl,TEXT_WRAP_FLOAT_TOP:Kl,TEXT_WRAP_FLOAT_BOTTOM:yl}}=he,wl=[{key:Ul,i18nPath:"contextmenu.image.change",icon:"image-change",when:o=>{var t;return!o.isReadonly&&!o.editorHasSelection&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.IMAGE},callback:o=>{const t=document.createElement("input");t.type="file",t.accept=".png, .jpg, .jpeg",t.onchange=()=>{const e=t.files[0],n=new FileReader;n.readAsDataURL(e),n.onload=()=>{const i=n.result;o.executeReplaceImageElement(i)}},t.click()}},{key:El,i18nPath:"contextmenu.image.saveAs",icon:"image",when:o=>{var t;return!o.editorHasSelection&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.IMAGE},callback:o=>{o.executeSaveAsImageElement()}},{key:Cl,i18nPath:"contextmenu.image.textWrap",when:o=>{var t;return!o.isReadonly&&!o.editorHasSelection&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.IMAGE},childMenus:[{key:Ql,i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,c.ImageDisplay.BLOCK)}},{key:bl,i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,c.ImageDisplay.INLINE)}},{key:Dl,i18nPath:"contextmenu.image.textWrapType.surround",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,c.ImageDisplay.SURROUND)}},{key:Kl,i18nPath:"contextmenu.image.textWrapType.floatTop",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,c.ImageDisplay.FLOAT_TOP)}},{key:yl,i18nPath:"contextmenu.image.textWrapType.floatBottom",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,c.ImageDisplay.FLOAT_BOTTOM)}}]}],{TABLE:{BORDER:Hl,BORDER_ALL:Gl,BORDER_EMPTY:xl,BORDER_DASH:Jl,BORDER_EXTERNAL:vl,BORDER_INTERNAL:Al,BORDER_TD:Bl,BORDER_TD_TOP:kl,BORDER_TD_LEFT:_l,BORDER_TD_BOTTOM:zl,BORDER_TD_RIGHT:$l,BORDER_TD_BACK:jl,BORDER_TD_FORWARD:ql,VERTICAL_ALIGN:ta,VERTICAL_ALIGN_TOP:ea,VERTICAL_ALIGN_MIDDLE:na,VERTICAL_ALIGN_BOTTOM:ia,INSERT_ROW_COL:oa,INSERT_TOP_ROW:sa,INSERT_BOTTOM_ROW:ra,INSERT_LEFT_COL:la,INSERT_RIGHT_COL:aa,DELETE_ROW_COL:Ra,DELETE_ROW:ca,DELETE_COL:da,DELETE_TABLE:ua,MERGE_CELL:ha,CANCEL_MERGE_CELL:ga}}=he,La=[{isDivider:!0},{key:Hl,i18nPath:"contextmenu.table.border",icon:"border-all",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==c.EditorMode.FORM,childMenus:[{key:Gl,i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:o=>{o.executeTableBorderType(c.TableBorder.ALL)}},{key:xl,i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:o=>{o.executeTableBorderType(c.TableBorder.EMPTY)}},{key:Jl,i18nPath:"contextmenu.table.borderDash",icon:"border-dash",when:()=>!0,callback:o=>{o.executeTableBorderType(c.TableBorder.DASH)}},{key:vl,i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:o=>{o.executeTableBorderType(c.TableBorder.EXTERNAL)}},{key:Al,i18nPath:"contextmenu.table.borderInternal",icon:"border-internal",when:()=>!0,callback:o=>{o.executeTableBorderType(c.TableBorder.INTERNAL)}},{key:Bl,i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{key:kl,i18nPath:"contextmenu.table.borderTdTop",icon:"border-td-top",when:()=>!0,callback:o=>{o.executeTableTdBorderType(c.TdBorder.TOP)}},{key:$l,i18nPath:"contextmenu.table.borderTdRight",icon:"border-td-right",when:()=>!0,callback:o=>{o.executeTableTdBorderType(c.TdBorder.RIGHT)}},{key:zl,i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:o=>{o.executeTableTdBorderType(c.TdBorder.BOTTOM)}},{key:_l,i18nPath:"contextmenu.table.borderTdLeft",icon:"border-td-left",when:()=>!0,callback:o=>{o.executeTableTdBorderType(c.TdBorder.LEFT)}},{key:ql,i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:o=>{o.executeTableTdSlashType(c.TdSlash.FORWARD)}},{key:jl,i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:o=>{o.executeTableTdSlashType(c.TdSlash.BACK)}}]}]},{key:ta,i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==c.EditorMode.FORM,childMenus:[{key:ea,i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(c.VerticalAlign.TOP)}},{key:na,i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(c.VerticalAlign.MIDDLE)}},{key:ia,i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(c.VerticalAlign.BOTTOM)}}]},{key:oa,i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==c.EditorMode.FORM,childMenus:[{key:sa,i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:o=>{o.executeInsertTableTopRow()}},{key:ra,i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:o=>{o.executeInsertTableBottomRow()}},{key:la,i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:o=>{o.executeInsertTableLeftCol()}},{key:aa,i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:o=>{o.executeInsertTableRightCol()}}]},{key:Ra,i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==c.EditorMode.FORM,childMenus:[{key:ca,i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:o=>{o.executeDeleteTableRow()}},{key:da,i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:o=>{o.executeDeleteTableCol()}},{key:ua,i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:o=>{o.executeDeleteTable()}}]},{key:ha,i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:o=>!o.isReadonly&&o.isCrossRowCol&&o.options.mode!==c.EditorMode.FORM,callback:o=>{o.executeMergeTableCell()}},{key:ga,i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==c.EditorMode.FORM,callback:o=>{o.executeCancelMergeTableCell()}}];class Ta{constructor(t,e){this._proxyContextMenuEvent=n=>{this.context=this._getContext();const i=this._filterMenuList(this.contextMenuList);i.some(s=>!s.isDivider)&&(this.dispose(),this._render({contextMenuList:i,left:n.x,top:n.y})),n.preventDefault()},this._handleSideEffect=n=>{if(this.contextMenuContainerList.length){const i=(n==null?void 0:n.composedPath()[0])||n.target;Xe(i,s=>!!s&&s.nodeType===1&&s.getAttribute(Ht)===c.EditorComponent.CONTEXTMENU,!0)||this.dispose()}},this.options=t.getOptions(),this.draw=t,this.command=e,this.range=t.getRange(),this.position=t.getPosition(),this.i18n=t.getI18n(),this.container=t.getContainer(),this.context=null,this.contextMenuList=[...Fl,...La,...wl,...Sl,...Zl],this.contextMenuContainerList=[],this.contextMenuRelationShip=new Map,this._addEvent()}getContextMenuList(){return this.contextMenuList}_addEvent(){this.container.addEventListener("contextmenu",this._proxyContextMenuEvent),document.addEventListener("mousedown",this._handleSideEffect)}removeEvent(){this.container.removeEventListener("contextmenu",this._proxyContextMenuEvent),document.removeEventListener("mousedown",this._handleSideEffect)}_filterMenuList(t){var i;const{contextMenuDisableKeys:e}=this.options,n=[];for(let r=0;r<t.length;r++){const s=t[r];s.disable||s.key&&e.includes(s.key)||(s.isDivider||(i=s.when)!=null&&i.call(s,this.context))&&n.push(s)}return n}_getContext(){const t=this.draw.isReadonly(),{isCrossRowCol:e,startIndex:n,endIndex:i}=this.range.getRange(),r=!!(~n||~i),s=r&&n!==i,{isTable:l,trIndex:a,tdIndex:R,index:d}=this.position.getPositionContext();let u=null;if(l){const M=this.draw.getOriginalElementList()[d]||null;M&&(u=rt([M],{extraPickAttrs:["id"]})[0])}const h=l&&!!e,g=this.draw.getElementList(),L=g[n]||null,T=g[i]||null,O=this.draw.getZone().getZone();return{startElement:L,endElement:T,isReadonly:t,editorHasSelection:s,editorTextFocus:r,isCrossRowCol:h,zone:O,isInTable:l,trIndex:a!=null?a:null,tdIndex:R!=null?R:null,tableElement:u,options:this.options}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${x}-contextmenu-container`),t.setAttribute(Ht,c.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){var O;const{contextMenuList:e,left:n,top:i,parentMenuContainer:r}=t,s=this._createContextMenuContainer(),l=document.createElement("div");l.classList.add(`${x}-contextmenu-content`);let a=null;r&&this.contextMenuRelationShip.set(r,s);for(let P=0;P<e.length;P++){const M=e[P];if(M.isDivider){if(P!==0&&P!==e.length-1&&!((O=e[P-1])!=null&&O.isDivider)){const f=document.createElement("div");f.classList.add(`${x}-contextmenu-divider`),l.append(f)}}else{const f=document.createElement("div");if(f.classList.add(`${x}-contextmenu-item`),M.childMenus){const N=this._filterMenuList(M.childMenus);N.some(Z=>!Z.isDivider)&&(f.classList.add(`${x}-contextmenu-sub-item`),f.onmouseenter=()=>{this._setHoverStatus(f,!0),this._removeSubMenu(s);const Z=f.getBoundingClientRect(),W=Z.left+Z.width,V=Z.top;a=this._render({contextMenuList:N,left:W,top:V,parentMenuContainer:s})},f.onmouseleave=Z=>{(!a||!a.contains(Z.relatedTarget))&&this._setHoverStatus(f,!1)})}else f.onmouseenter=()=>{this._setHoverStatus(f,!0),this._removeSubMenu(s)},f.onmouseleave=()=>{this._setHoverStatus(f,!1)},f.onclick=()=>{M.callback&&this.context&&M.callback(this.command,this.context),this.dispose()};const S=document.createElement("i");f.append(S),M.icon&&S.classList.add(`${x}-contextmenu-${M.icon}`);const I=document.createElement("span"),m=M.i18nPath?this._formatName(this.i18n.t(M.i18nPath)):this._formatName(M.name||"");if(I.append(document.createTextNode(m)),f.append(I),M.shortCut){const N=document.createElement("span");N.classList.add(`${x}-shortcut`),N.append(document.createTextNode(M.shortCut)),f.append(N)}l.append(f)}}s.append(l),s.style.display="block";const R=window.innerWidth,d=s.getBoundingClientRect(),u=d.width,h=n+u>R?n-u:n;s.style.left=`${h}px`;const g=window.innerHeight,L=d.height,T=i+L>g?i-L:i;return s.style.top=`${T}px`,this.contextMenuContainerList.push(s),s}_removeSubMenu(t){const e=this.contextMenuRelationShip.get(t);e&&(this._removeSubMenu(e),e.remove(),this.contextMenuRelationShip.delete(t))}_setHoverStatus(t,e){var n;e?((n=t.parentNode)==null||n.querySelectorAll(`${x}-contextmenu-item`).forEach(i=>i.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(wi),n=new RegExp(`${e.join("|")}`);let i=t;if(n.test(i)){const r=new RegExp(wi.SELECTED_TEXT,"g");if(r.test(i)){const s=this.range.toString();i=i.replace(r,s)}}return i}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const Pa=[{key:c.KeyMap.X,ctrl:!0,shift:!0,callback:o=>{o.executeStrikeout()}},{key:c.KeyMap.LEFT_BRACKET,mod:!0,callback:o=>{o.executeSizeAdd()}},{key:c.KeyMap.RIGHT_BRACKET,mod:!0,callback:o=>{o.executeSizeMinus()}},{key:c.KeyMap.B,mod:!0,callback:o=>{o.executeBold()}},{key:c.KeyMap.I,mod:!0,callback:o=>{o.executeItalic()}},{key:c.KeyMap.U,mod:!0,callback:o=>{o.executeUnderline()}},{key:qt?c.KeyMap.COMMA:c.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSuperscript()}},{key:qt?c.KeyMap.PERIOD:c.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSubscript()}},{key:c.KeyMap.L,mod:!0,callback:o=>{o.executeRowFlex(c.RowFlex.LEFT)}},{key:c.KeyMap.E,mod:!0,callback:o=>{o.executeRowFlex(c.RowFlex.CENTER)}},{key:c.KeyMap.R,mod:!0,callback:o=>{o.executeRowFlex(c.RowFlex.RIGHT)}},{key:c.KeyMap.J,mod:!0,callback:o=>{o.executeRowFlex(c.RowFlex.ALIGNMENT)}},{key:c.KeyMap.J,mod:!0,shift:!0,callback:o=>{o.executeRowFlex(c.RowFlex.JUSTIFY)}}],Oa=[{key:c.KeyMap.ZERO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(null)}},{key:c.KeyMap.ONE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.FIRST)}},{key:c.KeyMap.TWO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.SECOND)}},{key:c.KeyMap.THREE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.THIRD)}},{key:c.KeyMap.FOUR,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.FOURTH)}},{key:c.KeyMap.FIVE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.FIFTH)}},{key:c.KeyMap.SIX,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.SIXTH)}}],Ma=[{key:c.KeyMap.I,shift:!0,mod:!0,callback:o=>{o.executeList(c.ListType.UL,c.ListStyle.DISC)}},{key:c.KeyMap.U,shift:!0,mod:!0,callback:o=>{o.executeList(c.ListType.OL)}}];class fa{constructor(t,e){this._globalKeydown=i=>{!this.globalShortcutList.length||this._execute(i,this.globalShortcutList)},this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...Pa,...Oa,...Ma]),this._addEvent(),t.getCursor().getAgentDom().addEventListener("keydown",this._agentKeydown.bind(this))}_addEvent(){document.addEventListener("keydown",this._globalKeydown)}removeEvent(){document.removeEventListener("keydown",this._globalKeydown)}_addShortcutList(t){for(let e=t.length-1;e>=0;e--){const n=t[e];n.isGlobal?this.globalShortcutList.unshift(n):this.agentShortcutList.unshift(n)}}registerShortcutList(t){this._addShortcutList(t)}_agentKeydown(t){!this.agentShortcutList.length||this._execute(t,this.agentShortcutList)}_execute(t,e){var n;for(let i=0;i<e.length;i++){const r=e[i];if((r.mod?At(t)===!!r.mod:t.ctrlKey===!!r.ctrl&&t.metaKey===!!r.meta)&&t.shiftKey===!!r.shift&&t.altKey===!!r.alt&&t.key.toLowerCase()===r.key.toLowerCase()){r.disable||((n=r==null?void 0:r.callback)==null||n.call(r,this.command),t.preventDefault());break}}}}class Sa{constructor(t){this.editor=t}use(t,e){t(this.editor,e)}}class ma{constructor(){this.eventHub=new Map}on(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t)||new Set;n.add(e),this.eventHub.set(t,n)}emit(t,e){if(!t)return;const n=this.eventHub.get(t);if(!!n){if(n.size===1)return[...n][0](e);n.forEach(i=>i(e))}}off(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t);!n||n.delete(e)}isSubscribe(t){const e=this.eventHub.get(t);return!!e&&e.size>0}dangerouslyClearAll(){this.eventHub.clear()}}class Ia{}const Xa=Math.round(595.3*96/72),Na=Math.round(841.95*96/72),pa=[96,120,96,120];function Hi(o){const[t,e,n,i]=o;return`${t}px ${e}px ${n}px ${i}px`}function Fa(o,t){const e=document.querySelector("#tempDiv")||document.createElement("div");e.isConnected||(e.style.cssText="opacity:0;position:absolute;left:-9999px;top:0;pointer-events:none;",document.body.append(e));const n=o.trim(),i=/<section[^>]*class=["'][^"']*\bdocx\b/i.test(n),r=/class=["'][^"']*\bce-export-page\b/i.test(n);if(i||r){if(e.innerHTML=n,t){const s=e.querySelector("section.docx")||e.querySelector(".ce-export-page");s&&(s.style.padding=Hi(t),s.style.boxSizing="border-box")}}else{const s=Hi(t!=null?t:pa);e.innerHTML=`<section class="docx" style="width:${Xa}px;min-height:${Na}px;padding:${s};box-sizing:border-box;background:#fff;"><article>${n}</article></section>`}return e}function Wa(o){return function(t){const{html:e,margins:n}=t;if(!e)return;const i=Fa(e,n);o.executeSetHtmlDocx({container:i,margins:n})}}function Va(o){const t=o.command;t.executeImportDocx=Wa(t)}class Gi{showFormInputConfig(t){Ni(t,this)}showFormCheckboxConfig(t){Ii(t,this)}showFormRadioConfig(t){Xi(t,this)}showFormImageConfig(t){Yi(t,this)}showFormSignatureConfig(t){Zi(t,this)}showFormSealConfig(t){Ui(t,this)}showFormRiskCopyConfig(t){Ei(t,this)}setExtensionParam(t,e){this.extensionParams.set(t,e)}setExtensionParams(t){!t||typeof t!="object"||Object.entries(t).forEach(([e,n])=>{this.extensionParams.set(e,n)})}getExtensionParam(t){return this.extensionParams.get(t)}getAllExtensionParams(){const t={};return this.extensionParams.forEach((e,n)=>{t[n]=e}),t}deleteExtensionParam(t){return this.extensionParams.delete(t)}clearExtensionParams(){this.extensionParams.clear()}constructor(t,e,n={}){const i=an(n);e=et(e);let r=[],s=[],l=[],a=[];Array.isArray(e)?s=e:(r=e.header||[],s=e.main,l=e.footer||[],a=e.graffiti||[]),[r,s,l].forEach(L=>{Mt(L,{editorOptions:i,isForceCompensation:!0})}),this.version=xe,this.listener=new Ol,this.eventBus=new ma,this.override=new Ia;const d=new sl(t,i,{header:r,main:s,footer:l,graffiti:a},this.listener,this.eventBus,this.override);this.command=new Di(new Pl(d));const u=new Ta(d,this.command),h=new fa(d,this.command);this.register=new Ml({contextMenu:u,shortcut:h,i18n:d.getI18n()}),this.destroy=()=>{d.destroy(),h.removeEvent(),u.removeEvent(),this.eventBus.dangerouslyClearAll(),Reflect.set(window,"editor",null)};const g=new Sa(this);this.use=g.use.bind(g),this.extensionParams=new Map,Reflect.set(window,"editor",this)}}c.Command=Di,c.Dialog=zt,c.EDITOR_CLIPBOARD=Fe,c.EDITOR_COMPONENT=Ht,c.Editor=Gi,c.INTERNAL_CONTEXT_MENU_KEY=he,c.INTERNAL_SHORTCUT_KEY=ci,c.LETTER_CLASS=Vn,c.createDomFromElementList=re,c.default=Gi,c.docxPlugin=Va,c.formCheckboxPropertiesConfigDialog=Ii,c.formImagePropertiesConfigDialog=Yi,c.formInputPropertiesConfigDialog=Ni,c.formRadioPropertiesConfigDialog=Xi,c.formRiskCopyConfigDialog=Ei,c.formSealConfigDialog=Ui,c.formSignatureConfigDialog=Zi,c.getElementListByHTML=le,c.getTextFromElementList=ae,c.splitText=Ft,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
99
|
+
}`;d.append(document.createTextNode(u)),setTimeout(()=>{l.write(`${d.outerHTML}${a.innerHTML}`),s.print(),l.close(),window.addEventListener("mouseover",()=>{r==null||r.remove()},{once:!0})})}class Sl{constructor(t){this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.canvasEvent=t.getCanvasEvent(),this.options=t.getOptions(),this.control=t.getControl(),this.workerManager=t.getWorkerManager(),this.searchManager=t.getSearch(),this.i18n=t.getI18n(),this.zone=t.getZone(),this.tableOperate=t.getTableOperate()}mode(t){this.draw.setMode(t)}async cut(){this.draw.isReadonly()||this.draw.isDisabled()||await this.canvasEvent.cut()}async copy(t){await this.canvasEvent.copy(t)}paste(t){this.draw.isReadonly()||this.draw.isDisabled()||Vs(this.canvasEvent,t)}selectAll(){this.canvasEvent.selectAll()}backspace(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.draw.getElementList(),{startIndex:n,endIndex:i}=this.range.getRange(),r=n===i;if(r&&e[n].value===w&&n===0)return;r?this.draw.spliceElementList(e,n,1):this.draw.spliceElementList(e,n+1,i-n);const s=r?n-1:n;this.range.setRange(s,s),this.draw.render({curIndex:s})}setRange(t,e,n,i,r,s,l){if(t<0||e<0||e<t)return;this.range.setRange(t,e,n,i,r,s,l);const a=t===e;this.draw.render({curIndex:a?t:void 0,isCompute:!1,isSubmitHistory:!1,isSetCursor:a})}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}setPositionContext(t){const{tableId:e,startTrIndex:n,startTdIndex:i}=t,r=this.draw.getOriginalElementList();if(e){const s=r.findIndex(d=>d.id===e);if(!~s)return;const a=r[s].trList[n],R=a.tdList[i];this.position.setPositionContext({isTable:!0,index:s,trIndex:n,tdIndex:i,tdId:R.id,trId:a.id,tableId:e})}else this.position.setPositionContext({isTable:!1})}forceUpdate(t){const{isSubmitHistory:e=!1}=t||{};this.range.clearRange(),this.draw.render({isSubmitHistory:e,isSetCursor:!1})}blur(){this.range.clearRange(),this.draw.getCursor().recoveryCursor()}hideCursor(){this.draw.getCursor().recoveryCursor()}undo(){this.draw.isReadonly()||this.historyManager.undo()}redo(){this.draw.isReadonly()||this.historyManager.redo()}painter(t){if(!t.isDblclick&&this.draw.getPainterStyle()){this.canvasEvent.clearPainterStyle();return}const e=this.range.getSelection();if(!e)return;const n={};e.forEach(i=>{Ct.forEach(s=>{const l=s;n[l]===void 0&&Reflect.set(n,l,i[l])})}),this.draw.setPainterStyle(n,t)}applyPainterStyle(){this.draw.isReadonly()||this.draw.isDisabled()||this.canvasEvent.applyPainterStyle()}format(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();let r={},s=[];if(i!=null&&i.length)s=i,r={isSetCursor:!1};else{const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];(R==null?void 0:R.value)===w&&(s.push(R),r={curIndex:l})}!s.length||(s.forEach(l=>{Ct.forEach(a=>{delete l[a]})}),this.draw.render(r))}font(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r!=null&&r.length)r.forEach(s=>{s.font=t}),this.draw.render({isSetCursor:!1});else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({font:t}),(R==null?void 0:R.value)===w?R.font=t:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}size(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{minSize:r,maxSize:s,defaultSize:l}=this.options;if(t<r||t>s)return;let a={},R=[];const d=this.range.getTextLikeSelectionElementList();if(d!=null&&d.length)R=d,a={isSetCursor:!1};else{const{endIndex:h}=this.range.getRange(),L=this.draw.getElementList()[h];this.range.setDefaultStyle({size:t}),(L==null?void 0:L.value)===w?(R.push(L),a={curIndex:h}):this.draw.render({curIndex:h,isCompute:!1,isSubmitHistory:!1})}if(!R.length)return;let u=!1;R.forEach(h=>{!h.size&&t===l||h.size&&h.size===t||(h.size=t,u=!0)}),u&&this.draw.render(a)}sizeAdd(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,maxSize:r}=this.options,s=this.range.getTextLikeSelectionElementList();let l={},a=[];if(s!=null&&s.length)a=s,l={isSetCursor:!1};else{const{endIndex:d}=this.range.getRange(),h=this.draw.getElementList()[d],g=this.range.getDefaultStyle(),L=(g==null?void 0:g.size)||h.size||i;this.range.setDefaultStyle({size:L+2>r?r:L+2}),(h==null?void 0:h.value)===w?(a.push(h),l={curIndex:d}):this.draw.render({curIndex:d,isCompute:!1,isSubmitHistory:!1})}if(!a.length)return;let R=!1;a.forEach(d=>{d.size||(d.size=i),!(d.size>=r)&&(d.size+2>r?d.size=r:d.size+=2,R=!0)}),R&&this.draw.render(l)}sizeMinus(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,minSize:r}=this.options,s=this.range.getTextLikeSelectionElementList();let l={},a=[];if(s!=null&&s.length)a=s,l={isSetCursor:!1};else{const{endIndex:d}=this.range.getRange(),h=this.draw.getElementList()[d],g=this.range.getDefaultStyle(),L=(g==null?void 0:g.size)||h.size||i;this.range.setDefaultStyle({size:L-2<r?r:L-2}),(h==null?void 0:h.value)===w?(a.push(h),l={curIndex:d}):this.draw.render({curIndex:d,isCompute:!1,isSubmitHistory:!1})}if(!a.length)return;let R=!1;a.forEach(d=>{d.size||(d.size=i),!(d.size<=r)&&(d.size-2<r?d.size=r:d.size-=2,R=!0)}),R&&this.draw.render(l)}bold(t){var r;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i!=null&&i.length){const s=i.findIndex(l=>!l.bold);i.forEach(l=>{l.bold=!!~s}),this.draw.render({isSetCursor:!1})}else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({bold:R.bold?!1:!((r=this.range.getDefaultStyle())!=null&&r.bold)}),(R==null?void 0:R.value)===w?R.bold=!R.bold:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}italic(t){var r;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i!=null&&i.length){const s=i.findIndex(l=>!l.italic);i.forEach(l=>{l.italic=!!~s}),this.draw.render({isSetCursor:!1})}else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({italic:R.italic?!1:!((r=this.range.getDefaultStyle())!=null&&r.italic)}),(R==null?void 0:R.value)===w?R.italic=!R.italic:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}underline(t,e){var s;const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r!=null&&r.length){const l=r.some(a=>!a.underline||!t&&a.textDecoration||t&&!a.textDecoration||t&&a.textDecoration&&!uo(a.textDecoration,t));r.forEach(a=>{a.underline=l,l&&t?a.textDecoration=t:delete a.textDecoration}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let l=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({underline:d!=null&&d.underline?!1:!((s=this.range.getDefaultStyle())!=null&&s.underline)}),(d==null?void 0:d.value)===w?d.underline=!d.underline:l=!1,this.draw.render({isSubmitHistory:l,curIndex:a,isCompute:!1})}}strikeout(t){var r;const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i!=null&&i.length){const s=i.findIndex(l=>!l.strikeout);i.forEach(l=>{l.strikeout=!!~s}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({strikeout:R.strikeout?!1:!((r=this.range.getDefaultStyle())!=null&&r.strikeout)}),(R==null?void 0:R.value)===w?R.strikeout=!R.strikeout:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}superscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const r=i.findIndex(s=>s.type===c.ElementType.SUPERSCRIPT);i.forEach(s=>{~r?s.type===c.ElementType.SUPERSCRIPT&&(s.type=c.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===c.ElementType.TEXT||s.type===c.ElementType.SUBSCRIPT)&&(s.type=c.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const r=i.findIndex(s=>s.type===c.ElementType.SUBSCRIPT);i.forEach(s=>{~r?s.type===c.ElementType.SUBSCRIPT&&(s.type=c.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===c.ElementType.TEXT||s.type===c.ElementType.SUPERSCRIPT)&&(s.type=c.ElementType.SUBSCRIPT)}),this.draw.render({isSetCursor:!1})}color(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r!=null&&r.length)r.forEach(s=>{t?s.color=t:delete s.color}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({color:t||void 0}),(R==null?void 0:R.value)===w?t?R.color=t:delete R.color:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}highlight(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r!=null&&r.length)r.forEach(s=>{t?s.highlight=t:delete s.highlight}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let s=!0;const{endIndex:l}=this.range.getRange(),R=this.draw.getElementList()[l];this.range.setDefaultStyle({highlight:t||void 0}),(R==null?void 0:R.value)===w?t?R.highlight=t:delete R.highlight:s=!1,this.draw.render({isSubmitHistory:s,curIndex:l,isCompute:!1})}}title(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.draw.getElementList(),s=n===i?this.range.getRangeParagraphElementList():r.slice(n+1,i+1);if(!s||!s.length)return;const l=q(),a=this.draw.getOptions().title;s.forEach(u=>{!u.type&&u.value===w||(t?(u.level=t,u.titleId=l,Ue(u)&&(u.size=a[xn[t]],u.bold=!0)):u.titleId&&(delete u.titleId,delete u.title,delete u.level,delete u.size,delete u.bold))});const R=n===i,d=R?i:n;this.draw.render({curIndex:d,isSetCursor:R})}list(t,e){this.draw.isReadonly()||this.draw.getListParticle().setList(t,e)}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.range.getRangeRowElementList();if(!r)return;r.forEach(a=>{a.rowFlex=t});const s=n===i,l=s?i:n;this.draw.render({curIndex:l,isSetCursor:s})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.range.getRangeRowElementList();if(!r)return;r.forEach(a=>{a.rowMargin=t});const s=n===i,l=s?i:n;this.draw.render({curIndex:l,isSetCursor:s})}insertTable(t,e){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.tableOperate.insertTable(t,e)}insertTableTopRow(){this.draw.isReadonly()||this.tableOperate.insertTableTopRow()}insertTableBottomRow(){this.draw.isReadonly()||this.tableOperate.insertTableBottomRow()}insertTableLeftCol(){this.draw.isReadonly()||this.tableOperate.insertTableLeftCol()}insertTableRightCol(){this.draw.isReadonly()||this.tableOperate.insertTableRightCol()}deleteTableRow(){this.draw.isReadonly()||this.tableOperate.deleteTableRow()}deleteTableCol(){this.draw.isReadonly()||this.tableOperate.deleteTableCol()}deleteTable(){this.draw.isReadonly()||this.tableOperate.deleteTable()}mergeTableCell(){this.draw.isReadonly()||this.tableOperate.mergeTableCell()}cancelMergeTableCell(){this.draw.isReadonly()||this.tableOperate.cancelMergeTableCell()}splitVerticalTableCell(){this.draw.isReadonly()||this.tableOperate.splitVerticalTableCell()}splitHorizontalTableCell(){this.draw.isReadonly()||this.tableOperate.splitHorizontalTableCell()}tableTdVerticalAlign(t){this.draw.isReadonly()||this.tableOperate.tableTdVerticalAlign(t)}tableBorderType(t){this.draw.isReadonly()||this.tableOperate.tableBorderType(t)}tableBorderColor(t){this.draw.isReadonly()||this.tableOperate.tableBorderColor(t)}tableTdBorderType(t){this.draw.isReadonly()||this.tableOperate.tableTdBorderType(t)}tableTdSlashType(t){this.draw.isReadonly()||this.tableOperate.tableTdSlashType(t)}tableTdBackgroundColor(t){this.draw.isReadonly()||this.tableOperate.tableTdBackgroundColor(t)}tableSelectAll(){this.tableOperate.tableSelectAll()}hyperlink(t){const{valueList:e,url:n,hyperlinkId:i}=t;if(!n||!(e!=null&&e.length)||this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl())return;const{startIndex:l,endIndex:a}=this.range.getRange();!~l&&!~a||this.insertElementList([{type:c.ElementType.HYPERLINK,value:"",valueList:e,url:n,hyperlinkId:i||q()}])}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=this.draw.getElementList(),s=r[n];if(s.type!==c.ElementType.HYPERLINK)return null;let l=n;for(;l>0;){if(r[l].hyperlinkId!==s.hyperlinkId){t=l+1;break}l--}let a=n+1;for(;a<r.length;){if(r[a].hyperlinkId!==s.hyperlinkId){e=a-1;break}a++}return a===r.length&&(e=a-1),!~t||!~e?null:[t,e]}deleteHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,r]=e;this.draw.spliceElementList(n,i,r-i+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const s=i-1;this.range.setRange(s,s),this.draw.render({curIndex:s})}cancelHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,r]=e;for(let l=i;l<=r;l++){const a=n[l];delete a.type,delete a.url,delete a.hyperlinkId,delete a.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s,isCompute:!1})}editHyperlink(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=this.getHyperlinkRange();if(!n)return;const i=this.draw.getElementList(),[r,s]=n;for(let a=r;a<=s;a++){const R=i[a];R.url=t}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:l}=this.range.getRange();this.draw.render({curIndex:l,isCompute:!1})}separator(t,e){if(this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl())return;const{startIndex:r,endIndex:s}=this.range.getRange();if(!~r&&!~s)return;const l=this.draw.getElementList();let a=-1;const R=l[s+1];if(R&&R.type===c.ElementType.SEPARATOR){if(R.dashArray&&R.dashArray.join()===t.join())return;a=s,Object.assign(R,{dashArray:t,...e})}else{const d={value:Zt,type:c.ElementType.SEPARATOR,dashArray:t,...e};It(l,[d],r,{editorOptions:this.options}),r!==0&&l[r].value===w?(this.draw.spliceElementList(l,r,1,[d]),a=r-1):(this.draw.spliceElementList(l,r+1,0,[d]),a=r)}this.range.setRange(a,a),this.draw.render({curIndex:a})}pageBreak(){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.insertElementList([{type:c.ElementType.PAGE_BREAK,value:Zt}])}addWatermark(t){if(this.draw.isReadonly())return;const n=this.draw.getOptions(),{color:i,size:r,opacity:s,font:l,gap:a}=ln;n.watermark.data=t.data,n.watermark.type=t.type||c.WatermarkType.TEXT,t.width&&(n.watermark.width=t.width),t.height&&(n.watermark.height=t.height),n.watermark.color=t.color||i,n.watermark.opacity=t.opacity||s,n.watermark.size=t.size||r,n.watermark.font=t.font||l,n.watermark.repeat=!!t.repeat,t.numberType&&(n.watermark.numberType=t.numberType),n.watermark.gap=t.gap||a,this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1})}deleteWatermark(){if(this.draw.isReadonly())return;const e=this.draw.getOptions();e.watermark&&e.watermark.data&&(e.watermark={...ln},this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.draw.isDisabled())return null;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=t.id||q();return this.insertElementList([{...t,id:r,type:c.ElementType.IMAGE}]),r}search(t,e){this.searchManager.setSearchKeyword(t,e),this.draw.render({isSubmitHistory:!1})}searchNavigatePre(){this.searchManager.searchNavigatePre()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}searchNavigateNext(){this.searchManager.searchNavigateNext()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}getSearchNavigateInfo(){return this.searchManager.getSearchNavigateInfo()}replace(t,e){this.draw.getSearch().replace(t,e)}async print(){const{scale:t,printPixelRatio:e,paperDirection:n,width:i,height:r}=this.options;t!==1&&this.draw.setPageScale(1);const s=await this.draw.getDataURL({pixelRatio:e,mode:c.EditorMode.PRINT});fl(s,{width:i,height:r,direction:n}),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==c.ElementType.IMAGE||(i.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];!n||n.type!==c.ElementType.IMAGE||Yn(n.value,`${n.id}.png`)}setImageCrop(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==c.ElementType.IMAGE||(i.imgCrop=t,this.draw.render({isSetCursor:!1,isCompute:!1}))}setImageCaption(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];(i==null?void 0:i.type)===c.ElementType.IMAGE&&(i.imgCaption=t,this.draw.render({isSetCursor:!1}))}changeImageDisplay(t,e){if(t.imgDisplay===e)return;t.imgDisplay=e;const{startIndex:n,endIndex:i}=this.range.getRange();if(e===c.ImageDisplay.SURROUND||e===c.ImageDisplay.FLOAT_TOP||e===c.ImageDisplay.FLOAT_BOTTOM){const r=this.position.getPositionList(),{pageNo:s,coordinate:{leftTop:l}}=r[n];t.imgFloatPosition={pageNo:s,x:l[0],y:l[1]}}else delete t.imgFloatPosition;this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!0,curIndex:i})}getImage(t){return this.draw.getDataURL(t)}getOptions(){return this.options}getValue(t){return this.draw.getValue(t)}getValueAsync(t){return this.draw.getWorkerManager().getValue(t)}getAreaValue(t){return this.draw.getArea().getAreaValue(t)}getHTML(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList(),r=this.draw.getHeader().getPositionList(),s=this.position.getOriginalMainPositionList(),l=this.draw.getFooter().getPositionList(),{scale:a}=t;un(e,r,a),un(n,s,a),un(i,l,a);const R=d=>{const{width:u,height:h,margins:g}=t,L=document.createElement("div");for(L.className="ce-export-page",L.style.width=`${u}px`,L.style.minHeight=`${h}px`,L.style.padding=`${g[0]}px ${g[1]}px ${g[2]}px ${g[3]}px`,L.style.boxSizing="border-box",L.style.position="relative",L.style.background="#fff";d.firstChild;)L.append(d.firstChild);return Xs(L,{keepRoot:!0})};try{return{header:R(re(e,t)),main:R(re(n,t)),footer:R(re(i,t))}}finally{Ls()}}getText(){const t=this.draw.getHeaderElementList(),e=this.draw.getOriginalMainElementList(),n=this.draw.getFooterElementList();return{header:ae(t),main:ae(e),footer:ae(n)}}getWordCount(){return this.workerManager.getWordCount()}getCursorPosition(){return this.position.getCursorPosition()}getRemainingContentHeight(){if(!this.draw.getIsPagingMode())return 0;const t=this.draw.getPageRowList(),e=t.length-1,i=(t[e]||[]).reduce((a,R)=>a+R.height+(R.offsetY||0),0),r=this.draw.getHeight(),s=this.draw.getMainOuterHeight(),l=r-(s+i);return l>0?l:0}computeElementListHeight(t){if(!t.length)return 0;const e=this.draw.getInnerWidth();if(e<=0)return 0;const n=et(t);Mt(n,{isHandleFirstElement:!1,editorOptions:this.options});const i=gn(n);return this.draw.computeRowList({innerWidth:e,elementList:n,surroundElementList:i}).reduce((s,l)=>s+l.height+(l.offsetY||0),0)}getRange(){return et(this.range.getRange())}getRangeText(){return this.range.toString()}getRangeContext(){var D,H;const t=this.range.getRange(),{startIndex:e,endIndex:n}=t;if(!~e&&!~n)return null;const i=e===n,r=this.range.toString(),s=rt(this.range.getSelectionElementList()||[]),l=this.draw.getElementList(),a=se(l[i?e:e+1],{extraPickAttrs:["id","controlComponent"]}),R=se(l[n],{extraPickAttrs:["id","controlComponent"]}),d=this.draw.getRowList(),u=this.position.getPositionList(),h=u[e],g=u[n],L=h.pageNo,T=g.pageNo,O=h.rowIndex,P=g.rowIndex,M=d[O],f=d[P];let S=0,I=0;this.draw.getCursor().getHitLineStartIndex()||(S=((D=M.elementList[0])==null?void 0:D.value)===w?h.index-M.startIndex:h.index-M.startIndex+1),h===g?I=S:I=((H=f.elementList[0])==null?void 0:H.value)===w?g.index-f.startIndex:g.index-f.startIndex+1;const m=[],N=this.draw.getOriginalHeight(),F=this.draw.getOriginalPageGap(),Z=this.position.getSelectionPositionList();if(Z){let _=null,v=0,J=null;for(let z=0;z<Z.length;z++){const{rowNo:ft,pageNo:ht,coordinate:{leftTop:it,rightTop:gt},lineHeight:tt}=Z[z];_===null||_!==ft?(J&&m.push(J),J={x:it[0],y:it[1]+ht*(N+F),width:gt[0]-it[0],height:tt},_=ft,v=it[0]):J.width=gt[0]-v,z===Z.length-1&&J&&m.push(J)}}else{const v=this.position.getPositionList()[n],{coordinate:{rightTop:J},pageNo:z,lineHeight:ft}=v;m.push({x:J[0],y:J[1]+z*(N+F),width:0,height:ft})}const W=this.draw.getZone().getZone(),{isTable:V,trIndex:p,tdIndex:X,index:E}=this.position.getPositionContext();let C=null;if(V){const v=this.draw.getOriginalElementList()[E]||null;v&&(C=rt([v])[0])}let U=null,K=null,b=e-1;for(;b>0;){const _=l[b],v=l[b-1];if(_.titleId&&_.titleId!==(v==null?void 0:v.titleId)){U=_.titleId,K=u[b].pageNo;break}b--}const Y=Ki(l,e),y=e===n?Y:Ki(l,n);return et({isCollapsed:i,startElement:a,endElement:R,startPageNo:L,endPageNo:T,startRowNo:O,endRowNo:P,startColNo:S,endColNo:I,rangeRects:m,zone:W,isTable:V,trIndex:p!=null?p:null,tdIndex:X!=null?X:null,tableElement:C,selectionText:r,selectionElementList:s,titleId:U,titleStartPageNo:K,startParagraphNo:Y,endParagraphNo:y})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?rt(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?rt(t):null}getKeywordRangeList(t){return this.range.getKeywordRangeList(t)}getKeywordContext(t){var s,l,a,R;const e=this.getKeywordRangeList(t);if(!e.length)return null;const n=[],i=this.position.getOriginalMainPositionList(),r=this.draw.getOriginalMainElementList();for(let d=0;d<e.length;d++){const u=e[d],{startIndex:h,endIndex:g,tableId:L,startTrIndex:T,startTdIndex:O}=u;let P=i;if(u.tableId){const S=r.find(I=>I.id===L);S&&(P=((R=(a=(l=(s=S.trList)==null?void 0:s[T])==null?void 0:l.tdList)==null?void 0:a[O])==null?void 0:R.positionList)||[])}const M=et(P[h]),f=et(P[g]);n.push({range:u,startPosition:M,endPosition:f})}return n}pageMode(t){this.draw.setPageMode(t)}pageScale(t){t!==this.options.scale&&this.draw.setPageScale(t)}pageScaleRecovery(){const{scale:t}=this.options;t!==1&&this.draw.setPageScale(1)}pageScaleMinus(){const{scale:t}=this.options,e=t*10-1;e>=5&&this.draw.setPageScale(e/10)}pageScaleAdd(){const{scale:t}=this.options,e=t*10+1;e<=30&&this.draw.setPageScale(e/10)}paperSize(t,e){this.draw.setPaperSize(t,e)}paperDirection(t){this.draw.setPaperDirection(t)}getPaperMargin(){return this.options.margins}setPaperMargin(t){return this.draw.setPaperMargin(t)}setMainBadge(t){this.draw.getBadge().setMainBadge(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}setAreaBadge(t){this.draw.getBadge().setAreaBadgeMap(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}insertElementList(t,e={}){if(!t.length||this.draw.isReadonly()||this.draw.isDisabled())return;const{isReplace:i=!0,ignoreContextKeys:r}=e;i||this.range.shrinkRange();const s=et(t),{startIndex:l}=this.range.getRange(),a=this.draw.getElementList();It(a,s,l,{ignoreContextKeys:r,isBreakWhenWrap:!0,editorOptions:this.options}),this.draw.insertElementList(s,e)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList(et(t),e)}updateElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;const i=[];function r(l){let a=0;for(;a<l.length;){const R=l[a];if(a++,R.type===c.ElementType.TABLE){const d=R.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];r(L.value)}}}(e&&R.id===e||n&&R.conceptId===n)&&i.push({elementList:l,index:a-1})}}const s=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const l of s)r(l);if(!!i.length){for(let l=0;l<i.length;l++){const{elementList:a,index:R}=i[l],d=a[R],u=rt([{...d,...t.properties}],{extraPickAttrs:["id"]});jt(ie,d,u[0]),Mt(u,{isHandleFirstElement:!1,editorOptions:this.options}),a[R]=u[0]}this.draw.render({isSetCursor:!1})}}deleteElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;let i=!1;function r(l){let a=0;for(;a<l.length;){const R=l[a];if(R.type===c.ElementType.TABLE){const d=R.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];r(L.value)}}}(e&&R.id===e||n&&R.conceptId===n)&&(i=!0,l.splice(a,1),a--),a++}}const s=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const l of s)r(l);!i||this.draw.render({isSetCursor:!1})}getElementById(t){const{id:e,conceptId:n}=t,i=[];if(!e&&!n)return i;const r=l=>{let a=0;for(;a<l.length;){const R=l[a];if(a++,R.type===c.ElementType.TABLE){const d=R.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];r(L.value)}}}e&&R.id!==e||n&&R.conceptId!==n||i.push(R)}},s=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const l of s)r(l);return rt(i,{extraPickAttrs:["id"]})}setValue(t,e){this.draw.setValue(t,e)}removeControl(t){if((t==null?void 0:t.id)||(t==null?void 0:t.conceptId)){const{id:e,conceptId:n}=t;let i=!1;const r=l=>{let a=l.length-1;for(;a>=0;){const R=l[a];if(R.type===c.ElementType.TABLE){const d=R.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];r(L.value)}}}a--,!(!R.control||e&&R.controlId!==e||n&&R.control.conceptId!==n)&&(i=!0,l.splice(a+1,1))}},s=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const l of s)r(l);i&&this.draw.render({isSetCursor:!1})}else{const{startIndex:e,endIndex:n}=this.range.getRange();if(e!==n||!this.draw.getElementList()[e].controlId)return;const l=this.draw.getControl().removeControl(e);if(l===null)return;this.range.setRange(l,l),this.draw.render({curIndex:l})}}translate(t){return this.i18n.t(t)}setLocale(t){this.i18n.setLocale(t)}getLocale(){return this.i18n.getLocale()}getCatalog(){return this.workerManager.getCatalog()}locationCatalog(t){const e=this.draw.getOriginalElementList();function n(P,M){var f;for(let S=0;S<P.length;S++){const I=P[S];if(I.type===c.ElementType.TABLE){const m=I.trList;for(let N=0;N<m.length;N++){const F=m[N];for(let Z=0;Z<F.tdList.length;Z++){const W=F.tdList[Z],V=n(W.value,M);if(V)return{...V,isTable:!0,index:S,trIndex:N,tdIndex:Z,tdId:W.id,trId:F.id,tableId:I.id}}}}if(I.titleId===M){let m=S;for(;m<P.length;){if(((f=P[m+1])==null?void 0:f.titleId)!==M)return{isTable:!1,startIndex:m,endIndex:m};m++}}}return null}const i=n(e,t);if(!i)return;const{isTable:r,index:s,startTdIndex:l,endTdIndex:a,startTrIndex:R,endTrIndex:d,trIndex:u,tdIndex:h,tdId:g,trId:L,tableId:T,endIndex:O}=i;this.position.setPositionContext({isTable:r,index:s,trIndex:u,tdIndex:h,tdId:g,trId:L,tableId:T}),this.range.setRange(O,O,T,l,a,R,d),this.draw.render({curIndex:O,isCompute:!1,isSubmitHistory:!1})}wordTool(){const t=this.draw.getMainElementList();let e=!1;for(let n=0;n<t.length;n++)if(t[n].value===w)for(;n+1<t.length;){const r=t[n+1];if(r.value!==w&&r.value!==Je)break;t.splice(n+1,1),e=!0}if(e)this.draw.render({isSetCursor:!1});else{const n=this.range.getIsCollapsed();this.draw.getCursor().drawCursor({isShow:n})}}setHTML(t){const{header:e,main:n,footer:i,container:r}=t,s=this.draw.getOriginalInnerWidth(),l=a=>a!==void 0?le(a,{innerWidth:s,container:r}):void 0;this.setValue({header:l(e),main:l(n),footer:l(i)})}setHtmlDocx(t){const{container:e,margins:n}=t;if(!e)return;const{paper:i,main:r}=gl(e);this.options.margins=n!=null?n:i.margins,this.draw.setPaperSize(i.width,i.height),this.setValue({main:r})}importDocx(t){const{html:e,margins:n}=t;if(!e)return;const i=Ol(e,n);this.setHtmlDocx({container:i,margins:n})}setGroup(){return this.draw.isReadonly()?null:this.draw.getGroup().setGroup()}deleteGroup(t){this.draw.isReadonly()||this.draw.getGroup().deleteGroup(t)}getGroupIds(){return this.draw.getWorkerManager().getGroupIds()}locationGroup(t){const e=this.draw.getOriginalMainElementList(),n=this.draw.getGroup().getContextByGroupId(e,t);if(!n)return;const{isTable:i,index:r,trIndex:s,tdIndex:l,tdId:a,trId:R,tableId:d,endIndex:u}=n;this.position.setPositionContext({isTable:i,index:r,trIndex:s,tdIndex:l,tdId:a,trId:R,tableId:d}),this.range.setRange(u,u),this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}setZone(t){this.draw.getZone().setZone(t)}getControlValue(t){return this.draw.getControl().getValueById(t)}setControlValue(t){this.draw.getControl().setValueListById([t])}setControlValueList(t){this.draw.getControl().setValueListById(t)}setControlExtension(t){this.draw.getControl().setExtensionListById([t])}setControlExtensionList(t){this.draw.getControl().setExtensionListById(t)}setControlProperties(t){this.draw.getControl().setPropertiesListById([t])}setControlPropertiesList(t){this.draw.getControl().setPropertiesListById(t)}setControlHighlight(t){this.draw.getControl().setHighlightList(t),this.draw.render({isSubmitHistory:!1})}updateOptions(t){const e=an(t);Object.entries(e).forEach(([n,i])=>{Reflect.set(this.options,n,i)}),this.forceUpdate()}getControlList(){return this.draw.getControl().getList()}locationControl(t,e){function n(r,s){var a,R,d;let l=0;for(;l<r.length;){const u=r[l];if(l++,u.type===c.ElementType.TABLE){const g=u.trList;for(let L=0;L<g.length;L++){const T=g[L];for(let O=0;O<T.tdList.length;O++){const P=T.tdList[O],M=n(P.value,s);if(M)return{...M,positionContext:{isTable:!0,index:l-1,trIndex:L,tdIndex:O,tdId:u.tdId,trId:u.trId,tableId:u.tableId}}}}}if((u==null?void 0:u.controlId)!==t)continue;let h=l-1;if((e==null?void 0:e.position)===c.LocationPosition.OUTER_AFTER){if(!(u.controlComponent===c.ControlComponent.POSTFIX&&((a=r[l+1])==null?void 0:a.controlComponent)!==c.ControlComponent.POST_TEXT))continue}else if((e==null?void 0:e.position)===c.LocationPosition.OUTER_BEFORE)h-=1;else if((e==null?void 0:e.position)===c.LocationPosition.AFTER){if(h-=1,u.controlComponent!==c.ControlComponent.PLACEHOLDER&&u.controlComponent!==c.ControlComponent.POSTFIX&&u.controlComponent!==c.ControlComponent.POST_TEXT)continue}else if(u.controlComponent!==c.ControlComponent.PREFIX&&u.controlComponent!==c.ControlComponent.PRE_TEXT||((R=r[l])==null?void 0:R.controlComponent)===c.ControlComponent.PREFIX||((d=r[l])==null?void 0:d.controlComponent)===c.ControlComponent.PRE_TEXT)continue;return{zone:s,range:{startIndex:h,endIndex:h},positionContext:{isTable:!1}}}return null}const i=[{zone:c.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:c.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:c.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const r of i){const s=n(r.elementList,r.zone);if(s){this.setZone(s.zone),this.position.setPositionContext(s.positionContext),this.range.replaceRange(s.range),this.draw.render({curIndex:s.range.startIndex,isCompute:!1,isSubmitHistory:!1});break}}}insertControl(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=et(t),{startIndex:i}=this.range.getRange(),r=this.draw.getElementList(),s=Ee(r,i);if(!s)return;const l=[...Te,...te,...We,...ie];jt(l,s,n),this.draw.insertElementList([n])}jumpControl(t){this.draw.getControl().initNextControl({direction:t==null?void 0:t.direction})}getContainer(){return this.draw.getContainer()}getTitleValue(t){const{conceptId:e}=t,n=[],i=(s,l)=>{var R;let a=0;for(;a<s.length;){const d=s[a];if(a++,d.type===c.ElementType.TABLE){const g=d.trList;for(let L=0;L<g.length;L++){const T=g[L];for(let O=0;O<T.tdList.length;O++){const P=T.tdList[O];i(P.value,l)}}}if(((R=d==null?void 0:d.title)==null?void 0:R.conceptId)!==e)continue;const u=[];let h=a;for(;h<s.length;){const g=s[h];if(h++,d.titleId!==g.titleId){if(g.level&&rn[g.level]<=rn[d.level])break;u.push(g)}}n.push({...d.title,value:ae(u),elementList:rt(u),zone:l}),a=h}},r=[{zone:c.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:c.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:c.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:s,elementList:l}of r)i(l,s);return n}getPositionContextByEvent(t,e={}){var S,I,m;const n=(S=t.target)==null?void 0:S.dataset.index;if(!n)return null;const{isMustDirectHit:i=!0}=e,r=Number(n),s=this.position.getPositionByXY({x:t.offsetX,y:t.offsetY,pageNo:r}),{isDirectHit:l,isTable:a,index:R,trIndex:d,tdIndex:u,tdValueIndex:h,zone:g}=s;if(i&&!l||g&&g!==this.zone.getZone())return null;let L=null,T=null;const O=this.draw.getOriginalElementList();let P=null;const M=this.position.getOriginalPositionList();if(a){const N=(I=O[R].trList)==null?void 0:I[d].tdList[u];T=(N==null?void 0:N.value[h])||null,P=((m=N==null?void 0:N.positionList)==null?void 0:m[h])||null,L={element:O[R],trIndex:d,tdIndex:u}}else T=O[R]||null,P=M[R]||null;let f=null;if(P){const{pageNo:N,coordinate:{leftTop:F,rightTop:Z},lineHeight:W}=P,V=this.draw.getOriginalHeight(),p=this.draw.getOriginalPageGap();f={x:F[0],y:F[1]+N*(V+p),width:Z[0]-F[0],height:W}}return{pageNo:r,element:T,rangeRect:f,tableInfo:L}}insertTitle(t){var a;if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=et(t),{startIndex:i}=this.range.getRange(),r=this.draw.getElementList(),s=Ee(r,i);if(!s)return;const l=[...Te,...te,...We,...ie];(a=n.valueList)==null||a.forEach(R=>{jt(l,s,R)}),this.draw.insertElementList([n])}focus(t){var a,R;const{position:e=c.LocationPosition.AFTER,isMoveCursorToVisible:n=!0,rowNo:i,range:r}=t||{};let s=-1;if(r)this.range.replaceRange(r),s=e===c.LocationPosition.BEFORE?r.startIndex:r.endIndex;else if(ze(i)){const d=this.draw.getOriginalRowList();if(s=e===c.LocationPosition.BEFORE?(a=d[i])==null?void 0:a.startIndex:((R=d[i+1])==null?void 0:R.startIndex)-1,!ze(s))return;this.range.setRange(s,s)}else s=e===c.LocationPosition.BEFORE?0:this.draw.getOriginalMainElementList().length-1,this.range.setRange(s,s);const l={isCompute:!1,isSetCursor:!1,isSubmitHistory:!1};n&&~s&&this.range.getIsCollapsed()&&(l.curIndex=s,l.isSetCursor=!0),this.draw.render(l)}insertArea(t){return this.draw.getArea().insertArea(t)}setAreaValue(t){return this.draw.getArea().setAreaValue(t)}setAreaProperties(t){this.draw.getArea().setAreaProperties(t)}locationArea(t,e){if((e==null?void 0:e.isAppendLastLineBreak)&&(e==null?void 0:e.position)===c.LocationPosition.OUTER_AFTER){const r=this.draw.getOriginalMainElementList();r[r.length-1].areaId===t&&this.draw.appendElementList([{value:w}],{isSubmitHistory:!1})}const n=this.draw.getArea().getContextByAreaId(t,e);if(!n)return;const{range:{endIndex:i}}=n;this.position.setPositionContext({isTable:!1}),this.range.setRange(i,i),this.draw.render({curIndex:i,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1})}clearGraffiti(){this.draw.getGraffiti().clear(),this.draw.isGraffitiMode()&&this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}}class ml{constructor(){this.rangeStyleChange=null,this.visiblePageNoListChange=null,this.intersectionPageNoChange=null,this.pageSizeChange=null,this.pageScaleChange=null,this.saved=null,this.contentChange=null,this.controlChange=null,this.controlContentChange=null,this.pageModeChange=null,this.zoneChange=null}}class Il{constructor(t){const{contextMenu:e,shortcut:n,i18n:i}=t;this.contextMenuList=e.registerContextMenuList.bind(e),this.getContextMenuList=e.getContextMenuList.bind(e),this.shortcutList=n.registerShortcutList.bind(n),this.langMap=i.registerLangMap.bind(i)}}const Hi={SELECTED_TEXT:"%s"},he={GLOBAL:{CUT:"globalCut",COPY:"globalCopy",PASTE:"globalPaste",SELECT_ALL:"globalSelectAll",PRINT:"globalPrint"},CONTROL:{DELETE:"controlDelete"},HYPERLINK:{DELETE:"hyperlinkDelete",CANCEL:"hyperlinkCancel",EDIT:"hyperlinkEdit"},IMAGE:{CHANGE:"imageChange",SAVE_AS:"imageSaveAs",TEXT_WRAP:"imageTextWrap",TEXT_WRAP_EMBED:"imageTextWrapEmbed",TEXT_WRAP_UP_DOWN:"imageTextWrapUpDown",TEXT_WRAP_SURROUND:"imageTextWrapSurround",TEXT_WRAP_FLOAT_TOP:"imageTextWrapFloatTop",TEXT_WRAP_FLOAT_BOTTOM:"imageTextWrapFloatBottom"},TABLE:{BORDER:"border",BORDER_ALL:"tableBorderAll",BORDER_EMPTY:"tableBorderEmpty",BORDER_DASH:"tableBorderDash",BORDER_EXTERNAL:"tableBorderExternal",BORDER_INTERNAL:"tableBorderInternal",BORDER_TD:"tableBorderTd",BORDER_TD_TOP:"tableBorderTdTop",BORDER_TD_RIGHT:"tableBorderTdRight",BORDER_TD_BOTTOM:"tableBorderTdBottom",BORDER_TD_LEFT:"tableBorderTdLeft",BORDER_TD_FORWARD:"tableBorderTdForward",BORDER_TD_BACK:"tableBorderTdBack",VERTICAL_ALIGN:"tableVerticalAlign",VERTICAL_ALIGN_TOP:"tableVerticalAlignTop",VERTICAL_ALIGN_MIDDLE:"tableVerticalAlignMiddle",VERTICAL_ALIGN_BOTTOM:"tableVerticalAlignBottom",INSERT_ROW_COL:"tableInsertRowCol",INSERT_TOP_ROW:"tableInsertTopRow",INSERT_BOTTOM_ROW:"tableInsertBottomRow",INSERT_LEFT_COL:"tableInsertLeftCol",INSERT_RIGHT_COL:"tableInsertRightCol",DELETE_ROW_COL:"tableDeleteRowCol",DELETE_ROW:"tableDeleteRow",DELETE_COL:"tableDeleteCol",DELETE_TABLE:"tableDeleteTable",MERGE_CELL:"tableMergeCell",CANCEL_MERGE_CELL:"tableCancelMergeCell"}},{CONTROL:{DELETE:Xl}}=he,Nl=[{key:Xl,i18nPath:"contextmenu.control.delete",when:o=>{var t;return!o.isReadonly&&!o.editorHasSelection&&!!((t=o.startElement)!=null&&t.controlId)&&o.options.mode!==c.EditorMode.FORM},callback:o=>{o.executeRemoveControl()}}],{GLOBAL:{CUT:pl,COPY:Fl,PASTE:Wl,SELECT_ALL:Vl,PRINT:Yl}}=he,Zl=[{key:pl,i18nPath:"contextmenu.global.cut",shortCut:`${qt?"\u2318":"Ctrl"} + X`,when:o=>!o.isReadonly,callback:o=>{o.executeCut()}},{key:Fl,i18nPath:"contextmenu.global.copy",shortCut:`${qt?"\u2318":"Ctrl"} + C`,when:o=>o.editorHasSelection||o.isCrossRowCol,callback:o=>{o.executeCopy()}},{key:Wl,i18nPath:"contextmenu.global.paste",shortCut:`${qt?"\u2318":"Ctrl"} + V`,when:o=>!o.isReadonly&&o.editorTextFocus,callback:o=>{o.executePaste()}},{key:Vl,i18nPath:"contextmenu.global.selectAll",shortCut:`${qt?"\u2318":"Ctrl"} + A`,when:o=>o.editorTextFocus,callback:o=>{o.executeSelectAll()}},{isDivider:!0},{key:Yl,i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:o=>{o.executePrint()}}],{HYPERLINK:{DELETE:Ul,CANCEL:El,EDIT:Cl}}=he,Ql=[{key:Ul,i18nPath:"contextmenu.hyperlink.delete",when:o=>{var t;return!o.isReadonly&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.HYPERLINK},callback:o=>{o.executeDeleteHyperlink()}},{key:El,i18nPath:"contextmenu.hyperlink.cancel",when:o=>{var t;return!o.isReadonly&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.HYPERLINK},callback:o=>{o.executeCancelHyperlink()}},{key:Cl,i18nPath:"contextmenu.hyperlink.edit",when:o=>{var t;return!o.isReadonly&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.HYPERLINK},callback:(o,t)=>{var n;const e=window.prompt(o.executeTranslate("contextmenu.hyperlink.edit"),(n=t.startElement)==null?void 0:n.url);e&&o.executeEditHyperlink(e)}}],{IMAGE:{CHANGE:bl,SAVE_AS:Dl,TEXT_WRAP:Kl,TEXT_WRAP_EMBED:yl,TEXT_WRAP_UP_DOWN:wl,TEXT_WRAP_SURROUND:Hl,TEXT_WRAP_FLOAT_TOP:Gl,TEXT_WRAP_FLOAT_BOTTOM:xl}}=he,Jl=[{key:bl,i18nPath:"contextmenu.image.change",icon:"image-change",when:o=>{var t;return!o.isReadonly&&!o.editorHasSelection&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.IMAGE},callback:o=>{const t=document.createElement("input");t.type="file",t.accept=".png, .jpg, .jpeg",t.onchange=()=>{const e=t.files[0],n=new FileReader;n.readAsDataURL(e),n.onload=()=>{const i=n.result;o.executeReplaceImageElement(i)}},t.click()}},{key:Dl,i18nPath:"contextmenu.image.saveAs",icon:"image",when:o=>{var t;return!o.editorHasSelection&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.IMAGE},callback:o=>{o.executeSaveAsImageElement()}},{key:Kl,i18nPath:"contextmenu.image.textWrap",when:o=>{var t;return!o.isReadonly&&!o.editorHasSelection&&((t=o.startElement)==null?void 0:t.type)===c.ElementType.IMAGE},childMenus:[{key:yl,i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,c.ImageDisplay.BLOCK)}},{key:wl,i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,c.ImageDisplay.INLINE)}},{key:Hl,i18nPath:"contextmenu.image.textWrapType.surround",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,c.ImageDisplay.SURROUND)}},{key:Gl,i18nPath:"contextmenu.image.textWrapType.floatTop",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,c.ImageDisplay.FLOAT_TOP)}},{key:xl,i18nPath:"contextmenu.image.textWrapType.floatBottom",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,c.ImageDisplay.FLOAT_BOTTOM)}}]}],{TABLE:{BORDER:vl,BORDER_ALL:Al,BORDER_EMPTY:Bl,BORDER_DASH:kl,BORDER_EXTERNAL:_l,BORDER_INTERNAL:zl,BORDER_TD:$l,BORDER_TD_TOP:jl,BORDER_TD_LEFT:ql,BORDER_TD_BOTTOM:ta,BORDER_TD_RIGHT:ea,BORDER_TD_BACK:na,BORDER_TD_FORWARD:ia,VERTICAL_ALIGN:oa,VERTICAL_ALIGN_TOP:sa,VERTICAL_ALIGN_MIDDLE:ra,VERTICAL_ALIGN_BOTTOM:la,INSERT_ROW_COL:aa,INSERT_TOP_ROW:Ra,INSERT_BOTTOM_ROW:ca,INSERT_LEFT_COL:da,INSERT_RIGHT_COL:ua,DELETE_ROW_COL:ha,DELETE_ROW:ga,DELETE_COL:La,DELETE_TABLE:Ta,MERGE_CELL:Pa,CANCEL_MERGE_CELL:Oa}}=he,Ma=[{isDivider:!0},{key:vl,i18nPath:"contextmenu.table.border",icon:"border-all",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==c.EditorMode.FORM,childMenus:[{key:Al,i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:o=>{o.executeTableBorderType(c.TableBorder.ALL)}},{key:Bl,i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:o=>{o.executeTableBorderType(c.TableBorder.EMPTY)}},{key:kl,i18nPath:"contextmenu.table.borderDash",icon:"border-dash",when:()=>!0,callback:o=>{o.executeTableBorderType(c.TableBorder.DASH)}},{key:_l,i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:o=>{o.executeTableBorderType(c.TableBorder.EXTERNAL)}},{key:zl,i18nPath:"contextmenu.table.borderInternal",icon:"border-internal",when:()=>!0,callback:o=>{o.executeTableBorderType(c.TableBorder.INTERNAL)}},{key:$l,i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{key:jl,i18nPath:"contextmenu.table.borderTdTop",icon:"border-td-top",when:()=>!0,callback:o=>{o.executeTableTdBorderType(c.TdBorder.TOP)}},{key:ea,i18nPath:"contextmenu.table.borderTdRight",icon:"border-td-right",when:()=>!0,callback:o=>{o.executeTableTdBorderType(c.TdBorder.RIGHT)}},{key:ta,i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:o=>{o.executeTableTdBorderType(c.TdBorder.BOTTOM)}},{key:ql,i18nPath:"contextmenu.table.borderTdLeft",icon:"border-td-left",when:()=>!0,callback:o=>{o.executeTableTdBorderType(c.TdBorder.LEFT)}},{key:ia,i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:o=>{o.executeTableTdSlashType(c.TdSlash.FORWARD)}},{key:na,i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:o=>{o.executeTableTdSlashType(c.TdSlash.BACK)}}]}]},{key:oa,i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==c.EditorMode.FORM,childMenus:[{key:sa,i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(c.VerticalAlign.TOP)}},{key:ra,i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(c.VerticalAlign.MIDDLE)}},{key:la,i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(c.VerticalAlign.BOTTOM)}}]},{key:aa,i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==c.EditorMode.FORM,childMenus:[{key:Ra,i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:o=>{o.executeInsertTableTopRow()}},{key:ca,i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:o=>{o.executeInsertTableBottomRow()}},{key:da,i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:o=>{o.executeInsertTableLeftCol()}},{key:ua,i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:o=>{o.executeInsertTableRightCol()}}]},{key:ha,i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==c.EditorMode.FORM,childMenus:[{key:ga,i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:o=>{o.executeDeleteTableRow()}},{key:La,i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:o=>{o.executeDeleteTableCol()}},{key:Ta,i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:o=>{o.executeDeleteTable()}}]},{key:Pa,i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:o=>!o.isReadonly&&o.isCrossRowCol&&o.options.mode!==c.EditorMode.FORM,callback:o=>{o.executeMergeTableCell()}},{key:Oa,i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==c.EditorMode.FORM,callback:o=>{o.executeCancelMergeTableCell()}}];class fa{constructor(t,e){this._proxyContextMenuEvent=n=>{this.context=this._getContext();const i=this._filterMenuList(this.contextMenuList);i.some(s=>!s.isDivider)&&(this.dispose(),this._render({contextMenuList:i,left:n.x,top:n.y})),n.preventDefault()},this._handleSideEffect=n=>{if(this.contextMenuContainerList.length){const i=(n==null?void 0:n.composedPath()[0])||n.target;Xe(i,s=>!!s&&s.nodeType===1&&s.getAttribute(Ht)===c.EditorComponent.CONTEXTMENU,!0)||this.dispose()}},this.options=t.getOptions(),this.draw=t,this.command=e,this.range=t.getRange(),this.position=t.getPosition(),this.i18n=t.getI18n(),this.container=t.getContainer(),this.context=null,this.contextMenuList=[...Zl,...Ma,...Jl,...Nl,...Ql],this.contextMenuContainerList=[],this.contextMenuRelationShip=new Map,this._addEvent()}getContextMenuList(){return this.contextMenuList}_addEvent(){this.container.addEventListener("contextmenu",this._proxyContextMenuEvent),document.addEventListener("mousedown",this._handleSideEffect)}removeEvent(){this.container.removeEventListener("contextmenu",this._proxyContextMenuEvent),document.removeEventListener("mousedown",this._handleSideEffect)}_filterMenuList(t){var i;const{contextMenuDisableKeys:e}=this.options,n=[];for(let r=0;r<t.length;r++){const s=t[r];s.disable||s.key&&e.includes(s.key)||(s.isDivider||(i=s.when)!=null&&i.call(s,this.context))&&n.push(s)}return n}_getContext(){const t=this.draw.isReadonly(),{isCrossRowCol:e,startIndex:n,endIndex:i}=this.range.getRange(),r=!!(~n||~i),s=r&&n!==i,{isTable:l,trIndex:a,tdIndex:R,index:d}=this.position.getPositionContext();let u=null;if(l){const M=this.draw.getOriginalElementList()[d]||null;M&&(u=rt([M],{extraPickAttrs:["id"]})[0])}const h=l&&!!e,g=this.draw.getElementList(),L=g[n]||null,T=g[i]||null,O=this.draw.getZone().getZone();return{startElement:L,endElement:T,isReadonly:t,editorHasSelection:s,editorTextFocus:r,isCrossRowCol:h,zone:O,isInTable:l,trIndex:a!=null?a:null,tdIndex:R!=null?R:null,tableElement:u,options:this.options}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${x}-contextmenu-container`),t.setAttribute(Ht,c.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){var O;const{contextMenuList:e,left:n,top:i,parentMenuContainer:r}=t,s=this._createContextMenuContainer(),l=document.createElement("div");l.classList.add(`${x}-contextmenu-content`);let a=null;r&&this.contextMenuRelationShip.set(r,s);for(let P=0;P<e.length;P++){const M=e[P];if(M.isDivider){if(P!==0&&P!==e.length-1&&!((O=e[P-1])!=null&&O.isDivider)){const f=document.createElement("div");f.classList.add(`${x}-contextmenu-divider`),l.append(f)}}else{const f=document.createElement("div");if(f.classList.add(`${x}-contextmenu-item`),M.childMenus){const N=this._filterMenuList(M.childMenus);N.some(Z=>!Z.isDivider)&&(f.classList.add(`${x}-contextmenu-sub-item`),f.onmouseenter=()=>{this._setHoverStatus(f,!0),this._removeSubMenu(s);const Z=f.getBoundingClientRect(),W=Z.left+Z.width,V=Z.top;a=this._render({contextMenuList:N,left:W,top:V,parentMenuContainer:s})},f.onmouseleave=Z=>{(!a||!a.contains(Z.relatedTarget))&&this._setHoverStatus(f,!1)})}else f.onmouseenter=()=>{this._setHoverStatus(f,!0),this._removeSubMenu(s)},f.onmouseleave=()=>{this._setHoverStatus(f,!1)},f.onclick=()=>{M.callback&&this.context&&M.callback(this.command,this.context),this.dispose()};const S=document.createElement("i");f.append(S),M.icon&&S.classList.add(`${x}-contextmenu-${M.icon}`);const I=document.createElement("span"),m=M.i18nPath?this._formatName(this.i18n.t(M.i18nPath)):this._formatName(M.name||"");if(I.append(document.createTextNode(m)),f.append(I),M.shortCut){const N=document.createElement("span");N.classList.add(`${x}-shortcut`),N.append(document.createTextNode(M.shortCut)),f.append(N)}l.append(f)}}s.append(l),s.style.display="block";const R=window.innerWidth,d=s.getBoundingClientRect(),u=d.width,h=n+u>R?n-u:n;s.style.left=`${h}px`;const g=window.innerHeight,L=d.height,T=i+L>g?i-L:i;return s.style.top=`${T}px`,this.contextMenuContainerList.push(s),s}_removeSubMenu(t){const e=this.contextMenuRelationShip.get(t);e&&(this._removeSubMenu(e),e.remove(),this.contextMenuRelationShip.delete(t))}_setHoverStatus(t,e){var n;e?((n=t.parentNode)==null||n.querySelectorAll(`${x}-contextmenu-item`).forEach(i=>i.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(Hi),n=new RegExp(`${e.join("|")}`);let i=t;if(n.test(i)){const r=new RegExp(Hi.SELECTED_TEXT,"g");if(r.test(i)){const s=this.range.toString();i=i.replace(r,s)}}return i}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const Sa=[{key:c.KeyMap.X,ctrl:!0,shift:!0,callback:o=>{o.executeStrikeout()}},{key:c.KeyMap.LEFT_BRACKET,mod:!0,callback:o=>{o.executeSizeAdd()}},{key:c.KeyMap.RIGHT_BRACKET,mod:!0,callback:o=>{o.executeSizeMinus()}},{key:c.KeyMap.B,mod:!0,callback:o=>{o.executeBold()}},{key:c.KeyMap.I,mod:!0,callback:o=>{o.executeItalic()}},{key:c.KeyMap.U,mod:!0,callback:o=>{o.executeUnderline()}},{key:qt?c.KeyMap.COMMA:c.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSuperscript()}},{key:qt?c.KeyMap.PERIOD:c.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSubscript()}},{key:c.KeyMap.L,mod:!0,callback:o=>{o.executeRowFlex(c.RowFlex.LEFT)}},{key:c.KeyMap.E,mod:!0,callback:o=>{o.executeRowFlex(c.RowFlex.CENTER)}},{key:c.KeyMap.R,mod:!0,callback:o=>{o.executeRowFlex(c.RowFlex.RIGHT)}},{key:c.KeyMap.J,mod:!0,callback:o=>{o.executeRowFlex(c.RowFlex.ALIGNMENT)}},{key:c.KeyMap.J,mod:!0,shift:!0,callback:o=>{o.executeRowFlex(c.RowFlex.JUSTIFY)}}],ma=[{key:c.KeyMap.ZERO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(null)}},{key:c.KeyMap.ONE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.FIRST)}},{key:c.KeyMap.TWO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.SECOND)}},{key:c.KeyMap.THREE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.THIRD)}},{key:c.KeyMap.FOUR,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.FOURTH)}},{key:c.KeyMap.FIVE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.FIFTH)}},{key:c.KeyMap.SIX,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(c.TitleLevel.SIXTH)}}],Ia=[{key:c.KeyMap.I,shift:!0,mod:!0,callback:o=>{o.executeList(c.ListType.UL,c.ListStyle.DISC)}},{key:c.KeyMap.U,shift:!0,mod:!0,callback:o=>{o.executeList(c.ListType.OL)}}];class Xa{constructor(t,e){this._globalKeydown=i=>{!this.globalShortcutList.length||this._execute(i,this.globalShortcutList)},this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...Sa,...ma,...Ia]),this._addEvent(),t.getCursor().getAgentDom().addEventListener("keydown",this._agentKeydown.bind(this))}_addEvent(){document.addEventListener("keydown",this._globalKeydown)}removeEvent(){document.removeEventListener("keydown",this._globalKeydown)}_addShortcutList(t){for(let e=t.length-1;e>=0;e--){const n=t[e];n.isGlobal?this.globalShortcutList.unshift(n):this.agentShortcutList.unshift(n)}}registerShortcutList(t){this._addShortcutList(t)}_agentKeydown(t){!this.agentShortcutList.length||this._execute(t,this.agentShortcutList)}_execute(t,e){var n;for(let i=0;i<e.length;i++){const r=e[i];if((r.mod?At(t)===!!r.mod:t.ctrlKey===!!r.ctrl&&t.metaKey===!!r.meta)&&t.shiftKey===!!r.shift&&t.altKey===!!r.alt&&t.key.toLowerCase()===r.key.toLowerCase()){r.disable||((n=r==null?void 0:r.callback)==null||n.call(r,this.command),t.preventDefault());break}}}}class Na{constructor(t){this.editor=t}use(t,e){t(this.editor,e)}}class pa{constructor(){this.eventHub=new Map}on(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t)||new Set;n.add(e),this.eventHub.set(t,n)}emit(t,e){if(!t)return;const n=this.eventHub.get(t);if(!!n){if(n.size===1)return[...n][0](e);n.forEach(i=>i(e))}}off(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t);!n||n.delete(e)}isSubscribe(t){const e=this.eventHub.get(t);return!!e&&e.size>0}dangerouslyClearAll(){this.eventHub.clear()}}class Fa{}function Wa(o){}class Gi{showFormInputConfig(t){Ni(t,this)}showFormCheckboxConfig(t){Ii(t,this)}showFormRadioConfig(t){Xi(t,this)}showFormImageConfig(t){Yi(t,this)}showFormSignatureConfig(t){Zi(t,this)}showFormSealConfig(t){Ui(t,this)}showFormRiskCopyConfig(t){Ei(t,this)}setExtensionParam(t,e){this.extensionParams.set(t,e)}setExtensionParams(t){!t||typeof t!="object"||Object.entries(t).forEach(([e,n])=>{this.extensionParams.set(e,n)})}getExtensionParam(t){return this.extensionParams.get(t)}getAllExtensionParams(){const t={};return this.extensionParams.forEach((e,n)=>{t[n]=e}),t}deleteExtensionParam(t){return this.extensionParams.delete(t)}clearExtensionParams(){this.extensionParams.clear()}constructor(t,e,n={}){const i=an(n);e=et(e);let r=[],s=[],l=[],a=[];Array.isArray(e)?s=e:(r=e.header||[],s=e.main,l=e.footer||[],a=e.graffiti||[]),[r,s,l].forEach(L=>{Mt(L,{editorOptions:i,isForceCompensation:!0})}),this.version=xe,this.listener=new ml,this.eventBus=new pa,this.override=new Fa;const d=new sl(t,i,{header:r,main:s,footer:l,graffiti:a},this.listener,this.eventBus,this.override);this.command=new Di(new Sl(d));const u=new fa(d,this.command),h=new Xa(d,this.command);this.register=new Il({contextMenu:u,shortcut:h,i18n:d.getI18n()}),this.destroy=()=>{d.destroy(),h.removeEvent(),u.removeEvent(),this.eventBus.dangerouslyClearAll(),Reflect.set(window,"editor",null)};const g=new Na(this);this.use=g.use.bind(g),this.extensionParams=new Map,Reflect.set(window,"editor",this)}}c.Command=Di,c.Dialog=zt,c.EDITOR_CLIPBOARD=Fe,c.EDITOR_COMPONENT=Ht,c.Editor=Gi,c.INTERNAL_CONTEXT_MENU_KEY=he,c.INTERNAL_SHORTCUT_KEY=ci,c.LETTER_CLASS=Vn,c.createDomFromElementList=re,c.default=Gi,c.docxPlugin=Wa,c.formCheckboxPropertiesConfigDialog=Ii,c.formImagePropertiesConfigDialog=Yi,c.formInputPropertiesConfigDialog=Ni,c.formRadioPropertiesConfigDialog=Xi,c.formRiskCopyConfigDialog=Ei,c.formSealConfigDialog=Ui,c.formSignatureConfigDialog=Zi,c.getElementListByHTML=le,c.getTextFromElementList=ae,c.splitText=Ft,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
100
100
|
//# sourceMappingURL=canvas-editor.umd.js.map
|